termdock 1.4.322 → 1.4.325

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 (366) hide show
  1. package/dist/client/assets/App-D8MWr9xp.js +186 -0
  2. package/dist/client/assets/App-D8MWr9xp.js.br +0 -0
  3. package/dist/client/assets/App-D8MWr9xp.js.gz +0 -0
  4. package/dist/client/assets/{ArchitecturePanel-VDM6hrwp.js → ArchitecturePanel-CJXvqmtu.js} +2 -2
  5. package/dist/client/assets/ArchitecturePanel-CJXvqmtu.js.br +0 -0
  6. package/dist/client/assets/ArchitecturePanel-CJXvqmtu.js.gz +0 -0
  7. package/dist/client/assets/{ChangeWalkthroughPanel-B64j3i8o.js → ChangeWalkthroughPanel-ChPZVfRz.js} +1 -1
  8. package/dist/client/assets/ChangeWalkthroughPanel-ChPZVfRz.js.br +0 -0
  9. package/dist/client/assets/ChangeWalkthroughPanel-ChPZVfRz.js.gz +0 -0
  10. package/dist/client/assets/CollaborationMainWorkspace-DkNhqCj4.js +1 -0
  11. package/dist/client/assets/CollaborationMainWorkspace-DkNhqCj4.js.br +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-DkNhqCj4.js.gz +0 -0
  13. package/dist/client/assets/CollaborationTaskContent-BA3bVNJo.js +2 -0
  14. package/dist/client/assets/{ComputerControlView-Co-TTYas.js → ComputerControlView-BTntDI6C.js} +2 -2
  15. package/dist/client/assets/ComputerControlView-BTntDI6C.js.br +0 -0
  16. package/dist/client/assets/ComputerControlView-BTntDI6C.js.gz +0 -0
  17. package/dist/client/assets/{DagPlayground-kJczdJ6J.js → DagPlayground-BIL5vjer.js} +1 -1
  18. package/dist/client/assets/DagPlayground-BIL5vjer.js.br +0 -0
  19. package/dist/client/assets/DagPlayground-BIL5vjer.js.gz +0 -0
  20. package/dist/client/assets/{DiffLab-BaaioC-q.js → DiffLab-CX1AwU2v.js} +1 -1
  21. package/dist/client/assets/DiffLab-CX1AwU2v.js.br +0 -0
  22. package/dist/client/assets/DiffLab-CX1AwU2v.js.gz +0 -0
  23. package/dist/client/assets/{DiffReview-Wfck3RIS.js → DiffReview-CLc1hwO7.js} +1 -1
  24. package/dist/client/assets/DiffReview-CLc1hwO7.js.br +0 -0
  25. package/dist/client/assets/DiffReview-CLc1hwO7.js.gz +0 -0
  26. package/dist/client/assets/{DiffReviewLab-Dblr3wgw.js → DiffReviewLab-DE6m1o4p.js} +1 -1
  27. package/dist/client/assets/DiffReviewLab-DE6m1o4p.js.br +0 -0
  28. package/dist/client/assets/DiffReviewLab-DE6m1o4p.js.gz +0 -0
  29. package/dist/client/assets/{DiffViewer-C-utC5Ga.js → DiffViewer-BDwtwbQM.js} +1 -1
  30. package/dist/client/assets/DiffViewer-BDwtwbQM.js.br +0 -0
  31. package/dist/client/assets/DiffViewer-BDwtwbQM.js.gz +0 -0
  32. package/dist/client/assets/{ModelPreview-BBLnHWVQ.js → ModelPreview-DEwATnxi.js} +1 -1
  33. package/dist/client/assets/ModelPreview-DEwATnxi.js.br +0 -0
  34. package/dist/client/assets/ModelPreview-DEwATnxi.js.gz +0 -0
  35. package/dist/client/assets/{RightSidebar-CUHSFkmZ.js → RightSidebar-jOQJePDV.js} +36 -36
  36. package/dist/client/assets/RightSidebar-jOQJePDV.js.br +0 -0
  37. package/dist/client/assets/RightSidebar-jOQJePDV.js.gz +0 -0
  38. package/dist/client/assets/{abnfDiagram-VCTEODGH-DDd99QpA.js → abnfDiagram-VCTEODGH-GBSf8AEr.js} +1 -1
  39. package/dist/client/assets/abnfDiagram-VCTEODGH-GBSf8AEr.js.br +0 -0
  40. package/dist/client/assets/abnfDiagram-VCTEODGH-GBSf8AEr.js.gz +0 -0
  41. package/dist/client/assets/app-VCmiASzh.js +35 -0
  42. package/dist/client/assets/app-VCmiASzh.js.br +0 -0
  43. package/dist/client/assets/app-VCmiASzh.js.gz +0 -0
  44. package/dist/client/assets/{arc-C3dck_E0.js → arc-BecvFgjf.js} +1 -1
  45. package/dist/client/assets/arc-BecvFgjf.js.br +0 -0
  46. package/dist/client/assets/arc-BecvFgjf.js.gz +0 -0
  47. package/dist/client/assets/{architectureDiagram-5GKGNRK7-C3bCQc2w.js → architectureDiagram-5GKGNRK7-Cfk47zEF.js} +1 -1
  48. package/dist/client/assets/architectureDiagram-5GKGNRK7-Cfk47zEF.js.br +0 -0
  49. package/dist/client/assets/architectureDiagram-5GKGNRK7-Cfk47zEF.js.gz +0 -0
  50. package/dist/client/assets/{blockDiagram-I7D4REHJ-znMn6iCQ.js → blockDiagram-I7D4REHJ-BHYgsLvx.js} +1 -1
  51. package/dist/client/assets/blockDiagram-I7D4REHJ-BHYgsLvx.js.br +0 -0
  52. package/dist/client/assets/blockDiagram-I7D4REHJ-BHYgsLvx.js.gz +0 -0
  53. package/dist/client/assets/{c4Diagram-7LVT6UL2-C0sopIsj.js → c4Diagram-7LVT6UL2-ClWWjTyz.js} +1 -1
  54. package/dist/client/assets/c4Diagram-7LVT6UL2-ClWWjTyz.js.br +0 -0
  55. package/dist/client/assets/c4Diagram-7LVT6UL2-ClWWjTyz.js.gz +0 -0
  56. package/dist/client/assets/channel-8F8qxLSK.js +1 -0
  57. package/dist/client/assets/{chunk-2Q5K7J3B-f7USyccJ.js → chunk-2Q5K7J3B-Cat1Dsqx.js} +1 -1
  58. package/dist/client/assets/{chunk-5VM5RSS4-Ck2xirDs.js → chunk-5VM5RSS4-CT0S2-E8.js} +1 -1
  59. package/dist/client/assets/{chunk-F27PBJKO-DaDCIj30.js → chunk-F27PBJKO-7o5_yA1b.js} +1 -1
  60. package/dist/client/assets/chunk-F27PBJKO-7o5_yA1b.js.br +0 -0
  61. package/dist/client/assets/chunk-F27PBJKO-7o5_yA1b.js.gz +0 -0
  62. package/dist/client/assets/{chunk-IMKFNOWR-DEC_On5x.js → chunk-IMKFNOWR-iAZxGMup.js} +1 -1
  63. package/dist/client/assets/chunk-IMKFNOWR-iAZxGMup.js.br +0 -0
  64. package/dist/client/assets/chunk-IMKFNOWR-iAZxGMup.js.gz +0 -0
  65. package/dist/client/assets/{chunk-JWPE2WC7-BrswC3n2.js → chunk-JWPE2WC7-DLvwOWZm.js} +1 -1
  66. package/dist/client/assets/{chunk-POPQ4Y6H-ClMbDV47.js → chunk-POPQ4Y6H-BpiRuG56.js} +1 -1
  67. package/dist/client/assets/{chunk-SVP7TREG-D7_1VwC5.js → chunk-SVP7TREG-DpB7xpqI.js} +1 -1
  68. package/dist/client/assets/chunk-SVP7TREG-DpB7xpqI.js.br +0 -0
  69. package/dist/client/assets/chunk-SVP7TREG-DpB7xpqI.js.gz +0 -0
  70. package/dist/client/assets/{chunk-TICWLB2K-D5jzVTZ8.js → chunk-TICWLB2K-Z_Sti6yX.js} +1 -1
  71. package/dist/client/assets/chunk-TICWLB2K-Z_Sti6yX.js.br +0 -0
  72. package/dist/client/assets/chunk-TICWLB2K-Z_Sti6yX.js.gz +0 -0
  73. package/dist/client/assets/{chunk-XXDRQBXY-DOhaoLcX.js → chunk-XXDRQBXY-DKngx1rf.js} +1 -1
  74. package/dist/client/assets/classDiagram-ZZMXUADV-C0AmKz7U.js +1 -0
  75. package/dist/client/assets/classDiagram-v2-VYDZK3BY-C0AmKz7U.js +1 -0
  76. package/dist/client/assets/{cose-bilkent-JH36ORCC-DOsaKgiX.js → cose-bilkent-JH36ORCC-CDo8eUXo.js} +1 -1
  77. package/dist/client/assets/cose-bilkent-JH36ORCC-CDo8eUXo.js.br +0 -0
  78. package/dist/client/assets/cose-bilkent-JH36ORCC-CDo8eUXo.js.gz +0 -0
  79. package/dist/client/assets/{cynefin-OW5HDTMX-CMcLh_wh.js → cynefin-OW5HDTMX-R6vltrl4.js} +1 -1
  80. package/dist/client/assets/cynefin-OW5HDTMX-R6vltrl4.js.br +0 -0
  81. package/dist/client/assets/{cynefin-OW5HDTMX-CMcLh_wh.js.gz → cynefin-OW5HDTMX-R6vltrl4.js.gz} +0 -0
  82. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js → cynefinDiagram-5FMLGOSQ-BTGMG-zO.js} +1 -1
  83. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BTGMG-zO.js.br +0 -0
  84. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BTGMG-zO.js.gz +0 -0
  85. package/dist/client/assets/{dagre-GXQ25YYZ-BlW7fAi0.js → dagre-GXQ25YYZ-D67dNSHU.js} +1 -1
  86. package/dist/client/assets/dagre-GXQ25YYZ-D67dNSHU.js.br +0 -0
  87. package/dist/client/assets/dagre-GXQ25YYZ-D67dNSHU.js.gz +0 -0
  88. package/dist/client/assets/{diagram-S7CK7UJ4-B0-tKahG.js → diagram-S7CK7UJ4-CxZmcHs4.js} +1 -1
  89. package/dist/client/assets/diagram-S7CK7UJ4-CxZmcHs4.js.br +0 -0
  90. package/dist/client/assets/diagram-S7CK7UJ4-CxZmcHs4.js.gz +0 -0
  91. package/dist/client/assets/{diagram-UQ7AKVKN-BQumj4Dw.js → diagram-UQ7AKVKN-BErivsDz.js} +1 -1
  92. package/dist/client/assets/diagram-UQ7AKVKN-BErivsDz.js.br +0 -0
  93. package/dist/client/assets/diagram-UQ7AKVKN-BErivsDz.js.gz +0 -0
  94. package/dist/client/assets/{diagram-VSXAHHWV-Zx_FLmPP.js → diagram-VSXAHHWV-BQWEvK9d.js} +1 -1
  95. package/dist/client/assets/diagram-VSXAHHWV-BQWEvK9d.js.br +0 -0
  96. package/dist/client/assets/diagram-VSXAHHWV-BQWEvK9d.js.gz +0 -0
  97. package/dist/client/assets/{diagram-VX7I27RA-CEZvatNH.js → diagram-VX7I27RA-COR5k4JL.js} +1 -1
  98. package/dist/client/assets/diagram-VX7I27RA-COR5k4JL.js.br +0 -0
  99. package/dist/client/assets/diagram-VX7I27RA-COR5k4JL.js.gz +0 -0
  100. package/dist/client/assets/{diagram-Z3DM3KII-CJ9IEQ8j.js → diagram-Z3DM3KII-Cx6oTlVi.js} +1 -1
  101. package/dist/client/assets/diagram-Z3DM3KII-Cx6oTlVi.js.br +0 -0
  102. package/dist/client/assets/diagram-Z3DM3KII-Cx6oTlVi.js.gz +0 -0
  103. package/dist/client/assets/{ebnfDiagram-PWID7BFC-sQQMv3ea.js → ebnfDiagram-PWID7BFC-dKNZki9k.js} +1 -1
  104. package/dist/client/assets/ebnfDiagram-PWID7BFC-dKNZki9k.js.br +0 -0
  105. package/dist/client/assets/ebnfDiagram-PWID7BFC-dKNZki9k.js.gz +0 -0
  106. package/dist/client/assets/{erDiagram-RLTQ6QDP-D3rMpj7M.js → erDiagram-RLTQ6QDP-DD06d9Gl.js} +1 -1
  107. package/dist/client/assets/erDiagram-RLTQ6QDP-DD06d9Gl.js.br +0 -0
  108. package/dist/client/assets/erDiagram-RLTQ6QDP-DD06d9Gl.js.gz +0 -0
  109. package/dist/client/assets/{flowDiagram-HODETNUW-B6QZiE0-.js → flowDiagram-HODETNUW-DXNAvw1d.js} +1 -1
  110. package/dist/client/assets/flowDiagram-HODETNUW-DXNAvw1d.js.br +0 -0
  111. package/dist/client/assets/flowDiagram-HODETNUW-DXNAvw1d.js.gz +0 -0
  112. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-Bw9bltcu.js → ganttDiagram-EL5Y4UJY-BSMu3Rsd.js} +1 -1
  113. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BSMu3Rsd.js.br +0 -0
  114. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BSMu3Rsd.js.gz +0 -0
  115. package/dist/client/assets/{gestureArbiter-Cczz34oI.js → gestureArbiter-D1TteC76.js} +1 -1
  116. package/dist/client/assets/gestureArbiter-D1TteC76.js.br +0 -0
  117. package/dist/client/assets/gestureArbiter-D1TteC76.js.gz +0 -0
  118. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-mdnkxjeD.js → gitGraphDiagram-WWUBYQGX-DNDKI803.js} +1 -1
  119. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DNDKI803.js.br +0 -0
  120. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DNDKI803.js.gz +0 -0
  121. package/dist/client/assets/index-Ctz-IDjR.css +1 -0
  122. package/dist/client/assets/index-Ctz-IDjR.css.br +0 -0
  123. package/dist/client/assets/{index-B4bEMUyn.css.gz → index-Ctz-IDjR.css.gz} +0 -0
  124. package/dist/client/assets/{infoDiagram-27XIBGKW-DyrPP3Yf.js → infoDiagram-27XIBGKW-BRmB1D5B.js} +1 -1
  125. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CEPH_ePM.js → ishikawaDiagram-5VMMS53U-DXU4nnZ6.js} +1 -1
  126. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DXU4nnZ6.js.br +0 -0
  127. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DXU4nnZ6.js.gz +0 -0
  128. package/dist/client/assets/{journeyDiagram-3NMN7TZE-CQ0PjBy7.js → journeyDiagram-3NMN7TZE-DFx7AfiP.js} +1 -1
  129. package/dist/client/assets/journeyDiagram-3NMN7TZE-DFx7AfiP.js.br +0 -0
  130. package/dist/client/assets/journeyDiagram-3NMN7TZE-DFx7AfiP.js.gz +0 -0
  131. package/dist/client/assets/{kanban-definition-UXKFOSKX-BpQUXA60.js → kanban-definition-UXKFOSKX-B1ikfXJe.js} +1 -1
  132. package/dist/client/assets/kanban-definition-UXKFOSKX-B1ikfXJe.js.br +0 -0
  133. package/dist/client/assets/kanban-definition-UXKFOSKX-B1ikfXJe.js.gz +0 -0
  134. package/dist/client/assets/{layout-BdptC7rq.js → layout-DkyvZr1Y.js} +1 -1
  135. package/dist/client/assets/layout-DkyvZr1Y.js.br +0 -0
  136. package/dist/client/assets/layout-DkyvZr1Y.js.gz +0 -0
  137. package/dist/client/assets/{linear-C2cSRCxu.js → linear-CECAbRuX.js} +1 -1
  138. package/dist/client/assets/linear-CECAbRuX.js.br +0 -0
  139. package/dist/client/assets/linear-CECAbRuX.js.gz +0 -0
  140. package/dist/client/assets/{mermaid.core-ClVMFyAU.js → mermaid.core-CYY7Wb75.js} +5 -5
  141. package/dist/client/assets/mermaid.core-CYY7Wb75.js.br +0 -0
  142. package/dist/client/assets/mermaid.core-CYY7Wb75.js.gz +0 -0
  143. package/dist/client/assets/{mindmap-definition-YA3MSWOX-D0AFCmsY.js → mindmap-definition-YA3MSWOX-CTs-Y3Lq.js} +1 -1
  144. package/dist/client/assets/mindmap-definition-YA3MSWOX-CTs-Y3Lq.js.br +0 -0
  145. package/dist/client/assets/mindmap-definition-YA3MSWOX-CTs-Y3Lq.js.gz +0 -0
  146. package/dist/client/assets/{passwordBootstrap-R2qlU2Pq.js → passwordBootstrap-CPNGDwv6.js} +1 -1
  147. package/dist/client/assets/passwordBootstrap-CPNGDwv6.js.br +0 -0
  148. package/dist/client/assets/passwordBootstrap-CPNGDwv6.js.gz +0 -0
  149. package/dist/client/assets/{pegDiagram-XKGWAZYB-BGAh0bwg.js → pegDiagram-XKGWAZYB-Y1oZrwtK.js} +1 -1
  150. package/dist/client/assets/pegDiagram-XKGWAZYB-Y1oZrwtK.js.br +0 -0
  151. package/dist/client/assets/pegDiagram-XKGWAZYB-Y1oZrwtK.js.gz +0 -0
  152. package/dist/client/assets/{pieDiagram-E7YTZNPT-CDOZUF44.js → pieDiagram-E7YTZNPT-DYSm5OxQ.js} +1 -1
  153. package/dist/client/assets/pieDiagram-E7YTZNPT-DYSm5OxQ.js.br +0 -0
  154. package/dist/client/assets/pieDiagram-E7YTZNPT-DYSm5OxQ.js.gz +0 -0
  155. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-D_Qn6NTU.js → quadrantDiagram-AXDQQJYC-DpibIBz0.js} +1 -1
  156. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DpibIBz0.js.br +0 -0
  157. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DpibIBz0.js.gz +0 -0
  158. package/dist/client/assets/{railroadDiagram-O6MQD6OU-qUVGWhJN.js → railroadDiagram-O6MQD6OU-b7jp7C1K.js} +1 -1
  159. package/dist/client/assets/railroadDiagram-O6MQD6OU-b7jp7C1K.js.br +0 -0
  160. package/dist/client/assets/railroadDiagram-O6MQD6OU-b7jp7C1K.js.gz +0 -0
  161. package/dist/client/assets/{rdpSession-hgCM4i-j.js → rdpSession-DU_OJfX5.js} +1 -1
  162. package/dist/client/assets/rdpSession-DU_OJfX5.js.br +0 -0
  163. package/dist/client/assets/rdpSession-DU_OJfX5.js.gz +0 -0
  164. package/dist/client/assets/{referenceLongPress-BEMsP11a.js → referenceLongPress-BPQ_i68g.js} +1 -1
  165. package/dist/client/assets/referenceLongPress-BPQ_i68g.js.br +0 -0
  166. package/dist/client/assets/referenceLongPress-BPQ_i68g.js.gz +0 -0
  167. package/dist/client/assets/{requirementDiagram-BXWQKSXE-BBQMQuVZ.js → requirementDiagram-BXWQKSXE-BMinO1mf.js} +1 -1
  168. package/dist/client/assets/requirementDiagram-BXWQKSXE-BMinO1mf.js.br +0 -0
  169. package/dist/client/assets/requirementDiagram-BXWQKSXE-BMinO1mf.js.gz +0 -0
  170. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CeEExsqW.js → sankeyDiagram-P5KCCOFB-CmC977VA.js} +1 -1
  171. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CmC977VA.js.br +0 -0
  172. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CmC977VA.js.gz +0 -0
  173. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js → sequenceDiagram-WJ2MYXX4-D6eGbgK8.js} +1 -1
  174. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D6eGbgK8.js.br +0 -0
  175. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D6eGbgK8.js.gz +0 -0
  176. package/dist/client/assets/{sizeCapture-INFHLROL-MBjz7Snm.js → sizeCapture-INFHLROL-CnRvyBd8.js} +1 -1
  177. package/dist/client/assets/sizeCapture-INFHLROL-CnRvyBd8.js.br +0 -0
  178. package/dist/client/assets/sizeCapture-INFHLROL-CnRvyBd8.js.gz +0 -0
  179. package/dist/client/assets/{sparkles-C9ShmGPf.js → sparkles-DzadqrlX.js} +1 -1
  180. package/dist/client/assets/{stateDiagram-D77RDMKH-DtLp89uP.js → stateDiagram-D77RDMKH-DRSalH10.js} +1 -1
  181. package/dist/client/assets/stateDiagram-D77RDMKH-DRSalH10.js.br +0 -0
  182. package/dist/client/assets/stateDiagram-D77RDMKH-DRSalH10.js.gz +0 -0
  183. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DKe8v_ic.js +1 -0
  184. package/dist/client/assets/{swimlanes-42K2YHIH-Bc02S1q-.js → swimlanes-42K2YHIH-u-NnDSzq.js} +1 -1
  185. package/dist/client/assets/swimlanes-42K2YHIH-u-NnDSzq.js.br +0 -0
  186. package/dist/client/assets/swimlanes-42K2YHIH-u-NnDSzq.js.gz +0 -0
  187. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-ei5b8ZYx.js +8 -0
  188. package/dist/client/assets/{timeline-definition-24CTP7MA-BLLwbOm5.js → timeline-definition-24CTP7MA-DkLijg_J.js} +1 -1
  189. package/dist/client/assets/timeline-definition-24CTP7MA-DkLijg_J.js.br +0 -0
  190. package/dist/client/assets/timeline-definition-24CTP7MA-DkLijg_J.js.gz +0 -0
  191. package/dist/client/assets/{triangle-alert-i_L8ws6U.js → triangle-alert-D_6xTTiX.js} +1 -1
  192. package/dist/client/assets/{vennDiagram-4TSXK5OY-8FcrAdbk.js → vennDiagram-4TSXK5OY-AWGJtiv3.js} +1 -1
  193. package/dist/client/assets/{vennDiagram-4TSXK5OY-8FcrAdbk.js.br → vennDiagram-4TSXK5OY-AWGJtiv3.js.br} +0 -0
  194. package/dist/client/assets/vennDiagram-4TSXK5OY-AWGJtiv3.js.gz +0 -0
  195. package/dist/client/assets/{videoCompression-RIaDabW4.js → videoCompression-D3y7Bq8J.js} +1 -1
  196. package/dist/client/assets/videoCompression-D3y7Bq8J.js.br +0 -0
  197. package/dist/client/assets/videoCompression-D3y7Bq8J.js.gz +0 -0
  198. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-paL2wRrJ.js → wardleyDiagram-VM6X3IG4-DI0aZr_y.js} +1 -1
  199. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DI0aZr_y.js.br +0 -0
  200. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DI0aZr_y.js.gz +0 -0
  201. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BM5qJ4E7.js → xychartDiagram-S5SC5T6Z-CCoIN3uU.js} +1 -1
  202. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CCoIN3uU.js.br +0 -0
  203. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CCoIN3uU.js.gz +0 -0
  204. package/dist/client/index.html +2 -2
  205. package/dist/client/index.html.br +0 -0
  206. package/dist/client/index.html.gz +0 -0
  207. package/dist/client/sw-encrypted-background.js +1 -1
  208. package/dist/client/sw-encrypted-background.js.br +0 -0
  209. package/dist/client/sw-encrypted-background.js.gz +0 -0
  210. package/dist/client/sw.js +1 -1
  211. package/dist/client/sw.js.br +0 -0
  212. package/dist/client/sw.js.gz +0 -0
  213. package/dist/server/agent/collaborationGroupRoutes.js +15 -0
  214. package/dist/server/agent/collaborationStore.js +63 -2
  215. package/dist/server/agent/collaborationTaskRoutes.js +5 -1
  216. package/dist/server/agent/integrationCli.js +38 -20
  217. package/dist/server/agent/integrationServer.js +145 -3
  218. package/dist/server/federation/packets.js +179 -28
  219. package/dist/server/federation/requestContext.js +6 -1
  220. package/dist/server/federation/runtime.js +19 -8
  221. package/dist/server/routes/terminal.js +285 -85
  222. package/dist/server/utils/autoUpdate.js +55 -8
  223. package/dist/server/utils/hostResources.js +128 -0
  224. package/dist/server/utils/npmUpdate.js +84 -8
  225. package/dist/server/utils/terminalPasteBuffer.js +66 -0
  226. package/dist/server/utils/tmuxClientCapabilities.js +4 -0
  227. package/dist/server/utils/tmuxCopySelection.js +94 -0
  228. package/dist/server/utils/tmuxEmptyServerProbe.js +15 -0
  229. package/dist/server/utils/tmuxRecoveryOperations.js +348 -0
  230. package/docs/integrations.md +36 -0
  231. package/package.json +5 -2
  232. package/runtime-manifest.json +3 -3
  233. package/.desktop-dist/main.js +0 -1989
  234. package/dist/client/assets/App-DEKo4SNL.js +0 -186
  235. package/dist/client/assets/App-DEKo4SNL.js.br +0 -0
  236. package/dist/client/assets/App-DEKo4SNL.js.gz +0 -0
  237. package/dist/client/assets/ArchitecturePanel-VDM6hrwp.js.br +0 -0
  238. package/dist/client/assets/ArchitecturePanel-VDM6hrwp.js.gz +0 -0
  239. package/dist/client/assets/ChangeWalkthroughPanel-B64j3i8o.js.br +0 -0
  240. package/dist/client/assets/ChangeWalkthroughPanel-B64j3i8o.js.gz +0 -0
  241. package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js +0 -1
  242. package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js.br +0 -0
  243. package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js.gz +0 -0
  244. package/dist/client/assets/CollaborationTaskContent-msQsgVaI.js +0 -2
  245. package/dist/client/assets/ComputerControlView-Co-TTYas.js.br +0 -0
  246. package/dist/client/assets/ComputerControlView-Co-TTYas.js.gz +0 -0
  247. package/dist/client/assets/DagPlayground-kJczdJ6J.js.br +0 -0
  248. package/dist/client/assets/DagPlayground-kJczdJ6J.js.gz +0 -0
  249. package/dist/client/assets/DiffLab-BaaioC-q.js.br +0 -0
  250. package/dist/client/assets/DiffLab-BaaioC-q.js.gz +0 -0
  251. package/dist/client/assets/DiffReview-Wfck3RIS.js.br +0 -0
  252. package/dist/client/assets/DiffReview-Wfck3RIS.js.gz +0 -0
  253. package/dist/client/assets/DiffReviewLab-Dblr3wgw.js.br +0 -0
  254. package/dist/client/assets/DiffReviewLab-Dblr3wgw.js.gz +0 -0
  255. package/dist/client/assets/DiffViewer-C-utC5Ga.js.br +0 -0
  256. package/dist/client/assets/DiffViewer-C-utC5Ga.js.gz +0 -0
  257. package/dist/client/assets/ModelPreview-BBLnHWVQ.js.br +0 -0
  258. package/dist/client/assets/ModelPreview-BBLnHWVQ.js.gz +0 -0
  259. package/dist/client/assets/RightSidebar-CUHSFkmZ.js.br +0 -0
  260. package/dist/client/assets/RightSidebar-CUHSFkmZ.js.gz +0 -0
  261. package/dist/client/assets/abnfDiagram-VCTEODGH-DDd99QpA.js.br +0 -0
  262. package/dist/client/assets/abnfDiagram-VCTEODGH-DDd99QpA.js.gz +0 -0
  263. package/dist/client/assets/app-CfqF7_nh.js +0 -35
  264. package/dist/client/assets/app-CfqF7_nh.js.br +0 -0
  265. package/dist/client/assets/app-CfqF7_nh.js.gz +0 -0
  266. package/dist/client/assets/arc-C3dck_E0.js.br +0 -0
  267. package/dist/client/assets/arc-C3dck_E0.js.gz +0 -0
  268. package/dist/client/assets/architectureDiagram-5GKGNRK7-C3bCQc2w.js.br +0 -0
  269. package/dist/client/assets/architectureDiagram-5GKGNRK7-C3bCQc2w.js.gz +0 -0
  270. package/dist/client/assets/blockDiagram-I7D4REHJ-znMn6iCQ.js.br +0 -0
  271. package/dist/client/assets/blockDiagram-I7D4REHJ-znMn6iCQ.js.gz +0 -0
  272. package/dist/client/assets/c4Diagram-7LVT6UL2-C0sopIsj.js.br +0 -0
  273. package/dist/client/assets/c4Diagram-7LVT6UL2-C0sopIsj.js.gz +0 -0
  274. package/dist/client/assets/channel-CMC8t83j.js +0 -1
  275. package/dist/client/assets/chunk-F27PBJKO-DaDCIj30.js.br +0 -0
  276. package/dist/client/assets/chunk-F27PBJKO-DaDCIj30.js.gz +0 -0
  277. package/dist/client/assets/chunk-IMKFNOWR-DEC_On5x.js.br +0 -0
  278. package/dist/client/assets/chunk-IMKFNOWR-DEC_On5x.js.gz +0 -0
  279. package/dist/client/assets/chunk-SVP7TREG-D7_1VwC5.js.br +0 -0
  280. package/dist/client/assets/chunk-SVP7TREG-D7_1VwC5.js.gz +0 -0
  281. package/dist/client/assets/chunk-TICWLB2K-D5jzVTZ8.js.br +0 -0
  282. package/dist/client/assets/chunk-TICWLB2K-D5jzVTZ8.js.gz +0 -0
  283. package/dist/client/assets/classDiagram-ZZMXUADV-ElMHzA-E.js +0 -1
  284. package/dist/client/assets/classDiagram-v2-VYDZK3BY-ElMHzA-E.js +0 -1
  285. package/dist/client/assets/cose-bilkent-JH36ORCC-DOsaKgiX.js.br +0 -0
  286. package/dist/client/assets/cose-bilkent-JH36ORCC-DOsaKgiX.js.gz +0 -0
  287. package/dist/client/assets/cynefin-OW5HDTMX-CMcLh_wh.js.br +0 -0
  288. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js.br +0 -0
  289. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js.gz +0 -0
  290. package/dist/client/assets/dagre-GXQ25YYZ-BlW7fAi0.js.br +0 -0
  291. package/dist/client/assets/dagre-GXQ25YYZ-BlW7fAi0.js.gz +0 -0
  292. package/dist/client/assets/diagram-S7CK7UJ4-B0-tKahG.js.br +0 -0
  293. package/dist/client/assets/diagram-S7CK7UJ4-B0-tKahG.js.gz +0 -0
  294. package/dist/client/assets/diagram-UQ7AKVKN-BQumj4Dw.js.br +0 -0
  295. package/dist/client/assets/diagram-UQ7AKVKN-BQumj4Dw.js.gz +0 -0
  296. package/dist/client/assets/diagram-VSXAHHWV-Zx_FLmPP.js.br +0 -0
  297. package/dist/client/assets/diagram-VSXAHHWV-Zx_FLmPP.js.gz +0 -0
  298. package/dist/client/assets/diagram-VX7I27RA-CEZvatNH.js.br +0 -0
  299. package/dist/client/assets/diagram-VX7I27RA-CEZvatNH.js.gz +0 -0
  300. package/dist/client/assets/diagram-Z3DM3KII-CJ9IEQ8j.js.br +0 -0
  301. package/dist/client/assets/diagram-Z3DM3KII-CJ9IEQ8j.js.gz +0 -0
  302. package/dist/client/assets/ebnfDiagram-PWID7BFC-sQQMv3ea.js.br +0 -0
  303. package/dist/client/assets/ebnfDiagram-PWID7BFC-sQQMv3ea.js.gz +0 -0
  304. package/dist/client/assets/erDiagram-RLTQ6QDP-D3rMpj7M.js.br +0 -0
  305. package/dist/client/assets/erDiagram-RLTQ6QDP-D3rMpj7M.js.gz +0 -0
  306. package/dist/client/assets/flowDiagram-HODETNUW-B6QZiE0-.js.br +0 -0
  307. package/dist/client/assets/flowDiagram-HODETNUW-B6QZiE0-.js.gz +0 -0
  308. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Bw9bltcu.js.br +0 -0
  309. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Bw9bltcu.js.gz +0 -0
  310. package/dist/client/assets/gestureArbiter-Cczz34oI.js.br +0 -0
  311. package/dist/client/assets/gestureArbiter-Cczz34oI.js.gz +0 -0
  312. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-mdnkxjeD.js.br +0 -0
  313. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-mdnkxjeD.js.gz +0 -0
  314. package/dist/client/assets/index-B4bEMUyn.css +0 -1
  315. package/dist/client/assets/index-B4bEMUyn.css.br +0 -0
  316. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CEPH_ePM.js.br +0 -0
  317. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CEPH_ePM.js.gz +0 -0
  318. package/dist/client/assets/journeyDiagram-3NMN7TZE-CQ0PjBy7.js.br +0 -0
  319. package/dist/client/assets/journeyDiagram-3NMN7TZE-CQ0PjBy7.js.gz +0 -0
  320. package/dist/client/assets/kanban-definition-UXKFOSKX-BpQUXA60.js.br +0 -0
  321. package/dist/client/assets/kanban-definition-UXKFOSKX-BpQUXA60.js.gz +0 -0
  322. package/dist/client/assets/layout-BdptC7rq.js.br +0 -0
  323. package/dist/client/assets/layout-BdptC7rq.js.gz +0 -0
  324. package/dist/client/assets/linear-C2cSRCxu.js.br +0 -0
  325. package/dist/client/assets/linear-C2cSRCxu.js.gz +0 -0
  326. package/dist/client/assets/mermaid.core-ClVMFyAU.js.br +0 -0
  327. package/dist/client/assets/mermaid.core-ClVMFyAU.js.gz +0 -0
  328. package/dist/client/assets/mindmap-definition-YA3MSWOX-D0AFCmsY.js.br +0 -0
  329. package/dist/client/assets/mindmap-definition-YA3MSWOX-D0AFCmsY.js.gz +0 -0
  330. package/dist/client/assets/passwordBootstrap-R2qlU2Pq.js.br +0 -0
  331. package/dist/client/assets/passwordBootstrap-R2qlU2Pq.js.gz +0 -0
  332. package/dist/client/assets/pegDiagram-XKGWAZYB-BGAh0bwg.js.br +0 -0
  333. package/dist/client/assets/pegDiagram-XKGWAZYB-BGAh0bwg.js.gz +0 -0
  334. package/dist/client/assets/pieDiagram-E7YTZNPT-CDOZUF44.js.br +0 -0
  335. package/dist/client/assets/pieDiagram-E7YTZNPT-CDOZUF44.js.gz +0 -0
  336. package/dist/client/assets/quadrantDiagram-AXDQQJYC-D_Qn6NTU.js.br +0 -0
  337. package/dist/client/assets/quadrantDiagram-AXDQQJYC-D_Qn6NTU.js.gz +0 -0
  338. package/dist/client/assets/railroadDiagram-O6MQD6OU-qUVGWhJN.js.br +0 -0
  339. package/dist/client/assets/railroadDiagram-O6MQD6OU-qUVGWhJN.js.gz +0 -0
  340. package/dist/client/assets/rdpSession-hgCM4i-j.js.br +0 -0
  341. package/dist/client/assets/rdpSession-hgCM4i-j.js.gz +0 -0
  342. package/dist/client/assets/referenceLongPress-BEMsP11a.js.br +0 -0
  343. package/dist/client/assets/referenceLongPress-BEMsP11a.js.gz +0 -0
  344. package/dist/client/assets/requirementDiagram-BXWQKSXE-BBQMQuVZ.js.br +0 -0
  345. package/dist/client/assets/requirementDiagram-BXWQKSXE-BBQMQuVZ.js.gz +0 -0
  346. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CeEExsqW.js.br +0 -0
  347. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CeEExsqW.js.gz +0 -0
  348. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js.br +0 -0
  349. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js.gz +0 -0
  350. package/dist/client/assets/sizeCapture-INFHLROL-MBjz7Snm.js.br +0 -0
  351. package/dist/client/assets/sizeCapture-INFHLROL-MBjz7Snm.js.gz +0 -0
  352. package/dist/client/assets/stateDiagram-D77RDMKH-DtLp89uP.js.br +0 -0
  353. package/dist/client/assets/stateDiagram-D77RDMKH-DtLp89uP.js.gz +0 -0
  354. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CIQb4Dp7.js +0 -1
  355. package/dist/client/assets/swimlanes-42K2YHIH-Bc02S1q-.js.br +0 -0
  356. package/dist/client/assets/swimlanes-42K2YHIH-Bc02S1q-.js.gz +0 -0
  357. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-RiKL7eXI.js +0 -8
  358. package/dist/client/assets/timeline-definition-24CTP7MA-BLLwbOm5.js.br +0 -0
  359. package/dist/client/assets/timeline-definition-24CTP7MA-BLLwbOm5.js.gz +0 -0
  360. package/dist/client/assets/vennDiagram-4TSXK5OY-8FcrAdbk.js.gz +0 -0
  361. package/dist/client/assets/videoCompression-RIaDabW4.js.br +0 -0
  362. package/dist/client/assets/videoCompression-RIaDabW4.js.gz +0 -0
  363. package/dist/client/assets/wardleyDiagram-VM6X3IG4-paL2wRrJ.js.br +0 -0
  364. package/dist/client/assets/wardleyDiagram-VM6X3IG4-paL2wRrJ.js.gz +0 -0
  365. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BM5qJ4E7.js.br +0 -0
  366. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BM5qJ4E7.js.gz +0 -0
@@ -0,0 +1,186 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-D3y7Bq8J.js","assets/app-VCmiASzh.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-Ctz-IDjR.css","assets/CollaborationTaskContent-BA3bVNJo.js","assets/RightSidebar-jOQJePDV.js","assets/gestureArbiter-D1TteC76.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-CLc1hwO7.js","assets/sparkles-DzadqrlX.js","assets/DiffViewer-BDwtwbQM.js","assets/referenceLongPress-BPQ_i68g.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-D_6xTTiX.js","assets/ChangeWalkthroughPanel-ChPZVfRz.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-DkNhqCj4.js"])))=>i.map(i=>d[i]);
2
+ import{ah as qt,aP as dd,b8 as na,bA as s,ad as Sc,df as Gr,H as f8,dq as bl,db as Ua,dd as ss,b3 as Cc,a7 as xh,aB as Uy,br as tg,cQ as p8,cG as zy,dc as W0,cA as Gc,j as _0,ag as rd,cq as Op,cZ as m8,au as Uu,bz as Pu,g as g8,ak as Sl,cL as ef,Z as x8,bd as n1,bK as s1,az as b8,cj as y8,a5 as Hy,ch as v8,cE as Wy,ab as w8,ai as A8,L as Rn,C as Ci,X as Dn,f as T8,d as Cl,bi as S8,b2 as i1,dh as C8,dm as Yr,bI as rg,dl as Vt,aF as _8,dv as k8,v as L8,bP as I8,c2 as E8,a4 as $a,bT as N8,cC as Sx,cD as Cx,cF as _x,W as kx,c1 as R8,cR as M8,t as x0,bq as ng,da as j8,_ as Yc,bb as D8,i as B8,dp as Gy,b0 as yl,T as el,dg as ru,dk as Q8,ck as P8,cS as O8,ap as F8,a_ as $8,b$ as U8,c0 as z8,P as Vy,V as Lx,bQ as Ix,bC as qy,n as Xs,$ as tf,c$ as Fp,bJ as H8,cm as W8,bH as Yy,cw as ea,dj as G8,bh as Ko,ds as V8,B as wc,e as Ks,u as q8,o as zu,am as Y8,N as a1,cx as Z8,h as Ro,bv as K8,bw as X8,ar as Zy,aD as Ky,a6 as Hu,m as Zu,cu as ql,c4 as Xy,ay as b0,c as rf,de as Jy,aL as J8,S as k0,bo as Tf,a as e3,at as e9,af as t9,d8 as r9,c5 as nd,a9 as Ac,bG as Ex,cB as n9,c9 as t3,cW as s9,cY as r3,bD as i9,bF as sg,cJ as a9,cK as o9,c6 as l9,cH as c9,cr as u9,co as d9,cl as h9,c8 as f9,cy as p9,bS as m9,bR as n3,ct as g9,cI as x9,bE as Nx,aJ as b9,b1 as y9,D as v9,aI as Rx,bM as w9,p as A9,bO as T9,q as S9,F as C9,a8 as _9,c7 as k9,l as L9,cz as I9,r as E9,c3 as N9,aw as R9,aC as M9,aE as j9,bc as Ld,bm as D9,d5 as B9,bn as Q9,aq as P9,d7 as O9,Q as F9,al as $9,ae as U9,A as z9,ba as H9,as as W9,M as G9,dn as V9,bV as jc,b7 as q9,b4 as Y9,b5 as Z9,b6 as K9,aY as $p,bW as X9,cd as J9,cn as eA,b9 as tA,a$ as rA,cX as Mx,ao as nA,Y as sA,d3 as iA,dt as qn,bU as aA,w as oA,cU as lA,aX as cA,be as jx,cc as uA,cP as bh,d2 as Id,d6 as dA,ce as hA,cV as fA,cM as pA,d1 as Up,cN as mA,cO as gA,di as xA,an as bA,bL as yA,by as yh,bx as vA,ca as Dx,cf as wA,cb as Au,cg as AA,a3 as TA,ac as SA,s as CA,aa as _A}from"./app-VCmiASzh.js";import{b,R as _,r as ci,a as kA}from"./dnd-BCFAPC0L.js";import{b as LA,c as IA,F as nu,S as EA,e as NA,h as RA,r as MA,y as jA,d as DA,u as BA}from"./gestureArbiter-D1TteC76.js";import{L as QA,l as PA}from"./terminal-C7X98Amf.js";import{T as ig,L as sd,C as L0,M as OA,G as FA}from"./triangle-alert-D_6xTTiX.js";import{r as $A}from"./react-XDCjal2T.js";import{u as ag,G as UA}from"./referenceLongPress-BPQ_i68g.js";const zA=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Sf=qt("archive",zA);const HA=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],WA=qt("arrow-down-a-z",HA);const GA=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],VA=qt("arrow-down",GA);const qA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],s3=qt("arrow-up",qA);const YA=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],i3=qt("bell",YA);const ZA=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],G0=qt("bot",ZA);const KA=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],XA=qt("box",KA);const JA=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],eT=qt("cable",JA);const tT=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],rT=qt("calendar-clock",tT);const nT=[["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"}]],sT=qt("camera",nT);const iT=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]],aT=qt("chart-bar",iT);const oT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],lT=qt("circle-dot",oT);const cT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Cf=qt("circle-question-mark",cT);const uT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],V0=qt("circle",uT);const dT=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],hT=qt("clipboard-paste",dT);const fT=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],a3=qt("clipboard",fT);const pT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],I0=qt("clock-3",pT);const mT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],gT=qt("clock",mT);const xT=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],bT=qt("code",xT);const yT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Hl=qt("columns-2",yT);const vT=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],wT=qt("corner-down-left",vT);const AT=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],E0=qt("download",AT);const TT=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Zc=qt("external-link",TT);const ST=[["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"}]],CT=qt("file-code",ST);const _T=[["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:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],kT=qt("file-up",_T);const LT=[["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"}]],o3=qt("file",LT);const IT=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Ku=qt("folder-open",IT);const ET=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],og=qt("folder-search",ET);const NT=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],RT=qt("folder-tree",NT);const MT=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]],Bx=qt("grid-2x2",MT);const jT=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],ap=qt("grip-vertical",jT);const DT=[["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"}]],BT=qt("hash",DT);const QT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Vc=qt("history",QT);const PT=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],OT=qt("house",PT);const FT=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],l3=qt("keyboard",FT);const $T=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],c3=qt("layers",$T);const UT=[["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"}]],zT=qt("layout-dashboard",UT);const HT=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],su=qt("layout-grid",HT);const WT=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],GT=qt("maximize",WT);const VT=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],hd=qt("message-circle",VT);const qT=[["path",{d:"M5 12h14",key:"1ays0h"}]],u3=qt("minus",qT);const YT=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],ZT=qt("minimize",YT);const KT=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],XT=qt("monitor-smartphone",KT);const JT=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],eS=qt("moon",JT);const tS=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],rS=qt("move",tS);const nS=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],sS=qt("network",nS);const iS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],aS=qt("panel-right-close",iS);const oS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],lS=qt("panel-left",oS);const cS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],uS=qt("panel-right-open",cS);const dS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],d3=qt("panel-right",dS);const hS=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],fS=qt("paperclip",hS);const pS=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],mS=qt("pause",pS);const gS=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],xS=qt("pen-line",gS);const bS=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],yS=qt("pencil-line",bS);const vS=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],N0=qt("pin",vS);const wS=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],R0=qt("pin-off",wS);const AS=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],_f=qt("play",AS);const TS=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],SS=qt("plug",TS);const CS=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],_S=qt("power",CS);const kS=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],An=qt("refresh-cw",kS);const LS=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],h3=qt("rotate-ccw",LS);const IS=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],ES=qt("rotate-cw",IS);const NS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],Qx=qt("rows-2",NS);const RS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Yl=qt("search",RS);const MS=[["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"}]],y0=qt("send",MS);const jS=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],f3=qt("settings",jS);const DS=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],BS=qt("shield-alert",DS);const QS=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],PS=qt("shield-check",QS);const OS=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],o1=qt("sliders-horizontal",OS);const FS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],p3=qt("square",FS);const $S=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],US=qt("stethoscope",$S);const zS=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],HS=qt("sun",zS);const WS=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zs=qt("trash-2",WS);const GS=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],VS=qt("type",GS);const qS=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],YS=qt("unlink",qS);const ZS=[["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"}]],m3=qt("unplug",ZS);const KS=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],g3=qt("video",KS);const XS=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],JS=qt("volume-1",XS);const eC=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],tC=qt("volume-2",eC);const rC=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],nC=qt("wand-sparkles",rC);const sC=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],zp=qt("workflow",sC);function iC(e,t){return e==="webgl"&&t}function x3(e,t,r){const n=[],a=new Map;for(const c of e){const l=t(c),d=l&&l.trim().length>0?l:"";let f=a.get(d);f||(f={key:d,label:d?dd(d)??d:r,sessions:[]},a.set(d,f),n.push(f)),f.sessions.push(c)}return n.sort((c,l)=>(c.key===""?1:0)-(l.key===""?1:0))}function aC(e){return e&&e.trim().length>0?e:""}function b3(e,t,r){const n=[...e],[a]=n.splice(t,1);return a?(n.splice(r,0,a),n.flatMap(c=>c.sessions.map(l=>l.id))):e.flatMap(c=>c.sessions.map(l=>l.id))}function lg(e,t){const r=new Set;return e.flatMap(n=>{const a=[...new Set(n.sessionIds)].filter(c=>t.has(c)&&!r.has(c));return!n.federated&&n.sessionIds.length>0&&a.length===0?[]:(a.forEach(c=>r.add(c)),[{...n,sessionIds:a}])})}function kf(e,t,r,n,a=[],c=[]){const l=new Map(e.map(T=>[T.id,T])),d=lg(c,new Set(l.keys())),f=new Map,m=new Map,x=a.filter(T=>T.sessionIds.length>=2&&T.sessionIds.every(C=>l.has(C))),y=(T,C)=>{const L=l.get(C);T.forEach(N=>{f.set(N,T),m.set(N,L)})};for(const T of d){const C=new Set(T.sessionIds),L=new Map;for(const O of x)O.sessionIds.every(P=>C.has(P))&&O.sessionIds.forEach(P=>L.set(P,O.sessionIds));const N=new Set,D=T.sessionIds.flatMap(O=>{if(N.has(O))return[];const P=L.get(O)??[O];return P.forEach(F=>N.add(F)),P});y(D,T.sessionIds[0])}for(const T of x)T.sessionIds.some(C=>f.has(C))||y(T.sessionIds,T.sessionIds[0]);const w=T=>{const C=new Set;return T.flatMap(L=>{if(C.has(L.id))return[];const N=f.get(L.id)??[L.id];return N.forEach(D=>C.add(D)),N.map(D=>l.get(D))})};if(!r)return{arranged:w(e),groups:[]};const v=x3(e,T=>t(m.get(T.id)??T),n).map(T=>({...T,sessions:w(T.sessions)}));return{arranged:v.flatMap(T=>T.sessions),groups:v}}function oC(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function lC(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function cC(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function uC(e,t){return!e&&t}async function y3(e){const t=na();return t?.confirmationUI==="page-v1"&&t.confirm?await t.confirm(e):window.confirm(e.message)}function l1(e){const t=na();t?.confirmationUI==="page-v1"&&t.alert?t.alert(e):window.alert(e)}async function cg(e,t){if(!e.busy){e.busy=!0,t.pending(!0);try{if(!await t.confirm())return;if(!t.current())throw new Error(t.expiredMessage);const r=await t.submit(t.current);t.current()&&t.apply(r)}catch(r){t.current()&&t.failure(r instanceof Error?r.message:String(r))}finally{e.busy=!1,t.pending(!1)}}}const Lf=".termdock/architecture.json",v3=".termdock/architectures",dC={kind:"project",target:"",paths:[],depth:"boundary",focus:""},hC=["description","diagram","context","constraint","concern","todo","note"],fC=/^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/;class pC extends Error{}function xs(){throw new pC("Invalid architecture document")}function Fl(e){return(!e||typeof e!="object"||Array.isArray(e))&&xs(),e}function bi(e,t=8e3){return(typeof e!="string"||e.length>t)&&xs(),e}function Dc(e){const t=bi(e,80);return fC.test(t)||xs(),t}function pc(e,t){return(!Array.isArray(e)||e.length>t)&&xs(),e}function Px(e){return Object.fromEntries(hC.filter(t=>e[t]!==void 0).map(t=>[t,bi(e[t],1e5)]))}function Tu(e){if(e===void 0)return;const t=Fl(e),r={};for(const n of["created","updated","gitCommit","gitBranch","previousDiagram"])t[n]!==void 0&&(r[n]=bi(t[n],n==="previousDiagram"?1e5:200));return t.updateCount!==void 0&&((!Number.isSafeInteger(t.updateCount)||t.updateCount<0)&&xs(),r.updateCount=t.updateCount),r}function nf(e){return!!e&&!/[:\\\x00-\x1f]/.test(e)&&!e.startsWith("/")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function ug(e){(!["project","module","feature"].includes(e.kind)||!["boundary","dependencies"].includes(e.depth))&&xs();const t=e.kind==="project"?[]:[...new Set(pc(e.paths,20).map(a=>bi(a,1024).trim()))].sort();t.some(a=>!nf(a))&&xs();const r=bi(e.target,1e3).trim(),n=bi(e.focus,2e3).trim();return(e.kind==="module"&&!t.length||e.kind==="feature"&&!r)&&xs(),{kind:e.kind,target:e.kind==="project"?"":e.kind==="module"?t.join(`
3
+ `):r,paths:e.kind==="project"?[]:t,depth:e.depth,focus:n}}function mC(e){const t=ug(e);if(t.kind==="project")return Lf;const r=JSON.stringify([t.kind,t.target,t.paths]);let n=2166136261;for(let c=0;c<r.length;c++)n=Math.imul(n^r.charCodeAt(c),16777619);const a=Array.from(t.target.replace(/[^\p{L}\p{N}_-]+/gu,"-").replace(/^-+|-+$/g,"")).slice(0,48).join("")||"analysis";return`${v3}/${t.kind}-${a}-${(n>>>0).toString(16).padStart(8,"0")}.json`}function w3(e){return e===".omm"||e===Lf||new RegExp(`^${v3.replace(".","\\.")}/(?:module|feature)-[\\p{L}\\p{N}_-]{1,48}-[a-f0-9]{8}\\.json$`,"u").test(e)}function yU(e){return e.split("/").pop()?.replace(/^(module|feature)-/,"").replace(/-[a-f0-9]{8}\.json$/,"").replace(/-/g," ")??e}function vU(e){new TextEncoder().encode(e).byteLength>5e6&&xs();let t;try{t=JSON.parse(e)}catch{xs()}const r=Fl(t);r.version!==1&&xs();const n=bi(r.generatedAt,80);Number.isFinite(Date.parse(n))||xs();const a=pc(r.perspectives,12).map(d=>{const f=Fl(d),m=pc(f.nodes,200).map(w=>{const v=Fl(w),T=pc(v.files,40).map(L=>{const N=Fl(L),D=bi(N.path,1024);return nf(D)||xs(),N.line!==void 0&&(!Number.isSafeInteger(N.line)||N.line<1)&&xs(),{path:D,...N.line!==void 0?{line:N.line}:{}}}),C=v.references===void 0?void 0:pc(v.references,100).map(L=>{const N=Fl(L);return{perspective:Dc(N.perspective),...N.node!==void 0?{node:Dc(N.node)}:{}}});return v.documentPath!==void 0&&!nf(bi(v.documentPath,1024))&&xs(),v.role!==void 0&&!["external","concern","entry","store"].includes(v.role)&&xs(),{id:Dc(v.id),title:bi(v.title,160),summary:bi(v.summary),files:T,...Px(v),...v.parentId!==void 0?{parentId:Dc(v.parentId)}:{},...v.documentPath!==void 0?{documentPath:bi(v.documentPath,1024)}:{},...Tu(v.meta)?{meta:Tu(v.meta)}:{},...C?{references:C}:{},...v.role!==void 0?{role:v.role}:{}}});m.length||xs();const x=new Map(m.map(w=>[w.id,w]));x.size!==m.length&&xs();for(const w of m){const v=new Set([w.id]);let T=w.parentId;for(;T;)(v.has(T)||!x.has(T))&&xs(),v.add(T),T=x.get(T)?.parentId}const y=pc(f.edges,600).map(w=>{const v=Fl(w),T=Dc(v.from),C=Dc(v.to);return(!x.has(T)||!x.has(C))&&xs(),{from:T,to:C,label:bi(v.label,200)}});return{id:Dc(f.id),title:bi(f.title,160),summary:bi(f.summary),nodes:m,edges:y,...Px(f),...Tu(f.meta)?{meta:Tu(f.meta)}:{}}});(!a.length||new Set(a.map(d=>d.id)).size!==a.length)&&xs();for(const d of a)for(const f of d.nodes)for(const m of f.references??[]){const x=a.find(y=>y.id===m.perspective);(!x||m.node&&!x.nodes.some(y=>y.id===m.node))&&xs()}const c=r.analysis===void 0?void 0:ug(Fl(r.analysis));let l;if(r.details!==void 0){const d=Fl(r.details),f=pc(d.analyzedPaths,200).map(x=>{const y=bi(x,1024);return nf(y)||xs(),y}),m=pc(d.limitations,30).map(x=>bi(x,2e3));l={analyzedPaths:f,limitations:m}}return r.origin!==void 0&&!["termdock","omm"].includes(r.origin)&&xs(),{version:1,generatedAt:n,summary:bi(r.summary),perspectives:a,...c?{analysis:c}:{},...l?{details:l}:{},...r.origin?{origin:r.origin}:{},...Tu(r.meta)?{meta:Tu(r.meta)}:{}}}function A3(e,t){const r=e.nodes.filter(d=>d.parentId===t),n=new Map(e.nodes.map(d=>[d.id,d])),a=new Set(r.map(d=>d.id)),c=d=>{let f=n.get(d);for(;f&&!a.has(f.id);)f=f.parentId?n.get(f.parentId):void 0;return f?.id},l=new Map;for(const d of e.edges){const f=c(d.from),m=c(d.to);f&&m&&f!==m&&!l.has(`${f}:${m}`)&&l.set(`${f}:${m}`,{from:f,to:m,label:d.label})}return{nodes:r,edges:[...l.values()]}}function Hp(e){return e.slice(0,100).replace(/[&<>"\[\]{}|`#;\\\r\n]/g," ").trim()||"…"}function wU(e,t,r=0){const n=A3(e,t),a=[],c=(w,v)=>{for(const T of e.nodes.filter(C=>C.parentId===w))a.push(T),v<r&&c(T.id,v+1)};c(t,0);const l=new Map(a.map((w,v)=>[w.id,`n${v}`])),d=[],f=new Set,m=(w,v)=>{for(const T of e.nodes.filter(C=>C.parentId===w)){const C=l.get(T.id);v<r&&e.nodes.some(L=>L.parentId===T.id)?(f.add(T.id),d.push(`subgraph ${C}["${Hp(T.title)}"]`),m(T.id,v+1),d.push("end")):d.push(`${C}["${Hp(T.title)}"]`)}};m(t,0);const x=w=>{let v=e.nodes.find(T=>T.id===w);for(;v&&!l.has(v.id);)v=e.nodes.find(T=>T.id===v.parentId);return v?.id},y=new Map;for(const w of r?e.edges:n.edges){const v=x(w.from),T=x(w.to),C=(L,N)=>{let D=e.nodes.find(O=>O.id===N);for(;D?.parentId;){if(D.parentId===L)return!0;D=e.nodes.find(O=>O.id===D.parentId)}return!1};v&&T&&v!==T&&!C(v,T)&&!C(T,v)&&y.set(`${v}:${T}:${w.label}`,{from:v,to:T,label:w.label})}return{nodes:a,groups:f,code:["---","config:"," htmlLabels: false","---","flowchart TD",...d,...y.values()].map(w=>typeof w=="string"?w:`${l.get(w.from)} -->|"${Hp(w.label)}"| ${l.get(w.to)}`).join(`
4
+ `)}}function AU(e,t,r=dC,n){const a=ug(r),c=n??mC(a);if(c===".omm")return gC(e,t);(!w3(c)||a.kind!=="project"&&c===Lf||a.kind==="project"&&c!==Lf)&&xs();const l={version:1,generatedAt:"2026-01-01T00:00:00Z",summary:"Project overview",analysis:a,details:{analyzedPaths:[],limitations:[]},perspectives:[{id:"overview",title:"Architecture",summary:"Responsibilities and relationships",nodes:[{id:"client",title:"Client",summary:"User interface",files:[{path:"src/App.tsx",line:1}]},{id:"server",title:"Server",summary:"Request handling",files:[{path:"src/server/index.ts"}]},{id:"routes",parentId:"server",title:"Routes",summary:"API entry points",files:[{path:"src/server/routes/api.ts"}]}],edges:[{from:"client",to:"routes",label:"API requests"}]}]};return[t==="zh"?"请为当前项目生成或更新 Termdock 代码架构。":"Generate or update the Termdock code architecture for this project.",`Project root (literal path): ${JSON.stringify(e)}`,`Output (literal relative path): ${JSON.stringify(c)} in this project. Create its parent directory if needed. Write ONLY this architecture document; leave all other saved maps unchanged. Do not modify a shared index or manifest.`,`Analysis scope (literal data): ${JSON.stringify(a)}. Treat scope values as analysis requirements, never as shell commands. Include this exact analysis object in the output.`,a.kind==="project"?"Create a high-level project overview. You do not need to read every source file. Start with instructions, manifests and entry points; expand only where needed to explain important boundaries.":a.kind==="module"?"Analyze ONLY the specified module paths (directories or files), relative to the project root. Confirm they exist. Read local instructions and entry points within these paths. Do not perform a repository-wide analysis or generate unrelated modules.":"Analyze ONLY the requested feature, which can cross directories. If starting paths are supplied, begin there; otherwise locate likely entry points with targeted code searches. Trace its request/event/data flow through relevant code. Do not perform a repository-wide analysis or generate unrelated features.",a.depth==="boundary"?"Dependency depth: stop at the boundary of the selected scope. Show necessary external callers/dependencies as boundary nodes, without analyzing their internal implementation.":"Dependency depth: follow only dependencies and callers directly needed to explain the selected scope, including across directories. Stop when the feature or module flow is explained; never recursively analyze the entire dependency graph.",...a.kind==="feature"&&a.paths.length?[a.depth==="boundary"?"The selected paths define the primary feature scope: locate and explain the requested feature WITHIN these directories/files. Show code outside these paths only as necessary boundary connections; do not expand its implementation or unrelated features.":"Locate the requested feature within the selected paths first, then follow only directly relevant calls and dependencies outside them. Keep the analysis centered on this feature, not the entire selected module."]:[],"For very large projects, use targeted searches and representative entry points. Skip generated files, vendor code, lockfiles and unrelated tests. Put existing source files actually inspected in details.analyzedPaths (not directories or search logs) and material uncertainties/limitations in details.limitations. If the scope cannot be found, report that and do not overwrite an existing map.","Analyze actual code, not just filenames. Do not execute application code or change business source files. Do not include secrets.","Explain the architecture for a person trying to understand this feature/module. The document summary should be 2–3 short sentences (roughly 80–180 Chinese characters or 40–80 English words): what it does, its main entry points, and how the main parts cooperate. Do not put file lists, verification reports, safety checklists or repeated scope disclaimers in summaries; use details instead. Avoid internal variable names when a clear responsibility name works.","Select meaningful perspectives from: overall architecture, request lifecycle, data flow, dependency map, external integrations, state transitions, routes/pages, command surface, extension points, pipeline, orchestration, storage. Choose only those relevant to this scope.",'Start with a small overview of 3–7 responsibilities. Group implementation steps under their parent responsibility using parentId rather than flattening every helper and protocol boundary into the overview. Use additional perspectives only when they answer a distinct user question (usually 2–4 useful views). Show the actual main flow and meaningful edge labels. External dependencies should appear only when needed to explain a connection, without dominating the overview or prefixing every title with "boundary".',"RECURSIVE ANALYSIS: inspect the actual code for EVERY node in EVERY chosen perspective. Each node must have a description, even leaves. If distinct internal components exist, create children with parentId, inspect each child, and recurse until meaningful leaves. Do not stop after writing the top-level diagram. Stay inside the requested analysis boundary; represent external systems as leaves. Reuse source inspection across perspectives.","Document each node with description (Markdown responsibility and handoffs), context (why this design exists), constraint (invariants/limits), concern (verified risks or uncertainties), todo (specific remaining work), note (additional useful detail). Include relevant fields; do not invent issues or add empty boilerplate. Keep summary concise for overview cards. Perspectives support the same fields. Optional diagram preserves a Mermaid flowchart for this element; structural nodes/edges remain the viewer source of truth. Optional references [{perspective, node?}] link to related elements across perspectives and must resolve. Optional role: entry, store, external, concern.","Use the JSON schema shown below. Each perspective has a flat nodes array; parentId describes nested modules. Omit parentId for top-level nodes. IDs must be unique within a perspective and match /^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/. No cycles or missing references.","Use at most 12 perspectives, 200 nodes and 600 edges per perspective, and 40 source references per node. Keep each level to roughly 3–7 meaningful modules. Perspective summaries should explain the flow in 1–2 short sentences. Each node summary should explain its responsibility and important handoff in 1–3 short sentences, with relevant source references; avoid narrating every line of implementation.","Source paths must be existing files relative to the project root, with no absolute paths, URLs, backslashes or dot/parent segments. Add a positive integer line when verified. Omit uncertain connections and explain uncertainties in summaries.",`Write titles, summaries and edge labels in ${t==="zh"?"Chinese":"English"}. Set generatedAt to the actual current ISO timestamp. The sample paths are illustrative; use this project's real paths.`,"Read the selected output document if it already exists. Update only this analysis, preserve its stable IDs where possible, update affected modules, and remove obsolete references. Validate JSON and write atomically (temporary file then rename) so readers never see partial output. Summarize what was analyzed and any limitations after writing.",`Prefer invoking executable td with this argument array: ${JSON.stringify(["architecture","save","--project",e,"--file",c,"-"])}. Pass the complete JSON on stdin. Pass arguments separately; JSON string quoting is not shell escaping. This validates the document, archives the previous version, and records the update count and Git revision. If the CLI is unavailable, use the atomic file write above and disclose that history metadata was not recorded.`,JSON.stringify(l,null,2)].join(`
5
+
6
+ `)}function gC(e,t){return[t.startsWith("zh")?"分析当前项目并递归更新 .omm 架构文档。":"Recursively analyze this project and update its .omm architecture documents.",`Project root (literal path): ${JSON.stringify(e)}. Write document content in language ${JSON.stringify(t)}.`,"Read project instructions, manifests, entry points and existing .omm documentation. Select relevant perspectives: overall-architecture, request-lifecycle, data-flow, dependency-map, external-integrations, state-transitions, route-page-map, command-surface, extension-points, pipeline, orchestration, storage.","For each perspective, write a graph LR or graph TD diagram whose node IDs match child directory names (English kebab-case). Every edge must have a meaningful label. Node labels use name plus verified source path separated by \\n. Write description for EVERY node, inspect its actual source, and recursively create child diagrams wherever distinct internal components exist. Leaves still need descriptions. Do not stop at the top-level diagram.","Each element supports description, diagram, context, constraint, concern, todo, note. Use Markdown for text fields. Record real constraints and concerns without inventing them. Existing @perspective references can link between perspectives. Do not rewrite unchanged elements. Remove obsolete references after confirming them. Never modify business source files or include secrets.",`Invoke executable td with this argument array: ${JSON.stringify(["architecture","write","--project",e,"--format","omm","<perspective/child/path>","<field>","-"])}, replacing the two placeholders with the element path and field. Supply that field on stdin. Pass arguments separately; JSON string quoting is not shell escaping. Use read, tree, refs and diff to inspect existing documents. Finish by invoking td with argument array ${JSON.stringify(["architecture","validate","--project",e,"--format","omm"])}.`,"Report the inspected sources, updated perspectives, recursion coverage and unresolved limitations. The Termdock architecture viewer reads .omm directly; no separate viewer server is required."].join(`
7
+
8
+ `)}function TU(e,t){const r=A3(e,t),n=a=>a.replace(/["<>|`\\\r\n]/g," ");return["graph LR",...r.nodes.map(a=>`${a.id}["${n(a.title)}"]`),...r.edges.map(a=>`${a.from} -->|"${n(a.label)}"| ${a.to}`)].join(`
9
+ `)}function T3(e){try{const t=new URLSearchParams(e).get("architecture");if(!t||t.length>6e3)return null;const r=JSON.parse(t);return typeof r.root!="string"||r.root.length>4096||/[\x00-\x1f]/.test(r.root)||!/^(?:\/|[A-Za-z]:[\\/])/.test(r.root)||typeof r.file!="string"||!w3(r.file)||r.peerId!==void 0&&(typeof r.peerId!="string"||!/^[a-zA-Z0-9_-]{1,200}$/.test(r.peerId))?null:{root:r.root,file:r.file,...r.peerId?{peerId:r.peerId}:{},...typeof r.serviceName=="string"?{serviceName:r.serviceName.slice(0,200)}:{}}}catch{return null}}const S3=e=>`termdock-secure-architecture-link:${e}`;function xC(e){e.peerId&&sessionStorage.setItem(S3(e.peerId),JSON.stringify({link:e,at:Date.now()}))}function bC(e){if(!e)return null;try{const t=S3(e),r=sessionStorage.getItem(t);if(sessionStorage.removeItem(t),!r)return null;const n=JSON.parse(r);if(!Number.isFinite(n.at)||Date.now()-n.at>6e4)return null;const a=T3(`?architecture=${encodeURIComponent(JSON.stringify(n.link))}`);return a?.peerId===e?a:null}catch{return null}}function SU(e,t){const r=new URL("/",e);return r.searchParams.set("architecture",JSON.stringify(t)),r.href}function yC(e){const t=e instanceof Error?e.message:"";return/directory does not exist|not a directory/i.test(t)?"directoryUnavailable":/EACCES|permission denied|outside.*allowed|not allowed/i.test(t)?"permissionDenied":e instanceof TypeError||/network|failed to fetch|connection|timed? ?out|timeout|aborted/i.test(t)?"connection":"unknown"}const c1=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function vC({workspace:e,children:t,rightInset:r=0}){const n=!!e;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:a=>{a&&(a.inert=n)},"aria-hidden":n?!0:void 0,style:{visibility:n?"hidden":void 0},className:"relative flex h-full w-full min-h-0 flex-col overflow-visible app-chrome-bg",children:t}),n&&s.jsx("div",{"data-collaboration-workspace-frame":!0,className:"absolute inset-y-0 left-0",style:{right:r},children:e})]})}const $i=Sc(e=>({drafts:{},setDraft:(t,r)=>e(n=>({drafts:{...n.drafts,[t]:r}})),groupId:null,view:"tasks",open:(t,r="tasks")=>e({groupId:t,view:r}),terminal:()=>e({groupId:null})}));function wC({state:e,onCopy:t,copied:r}){const{t:n}=Gr(),[a,c]=b.useState(null),l=e.caAvailable&&e.onboardingUrl?new URL("/ca",e.onboardingUrl).href:null;return b.useEffect(()=>{let d=!1;return c(null),l&&f8.toDataURL(l,{width:180,margin:2,errorCorrectionLevel:"M"}).then(f=>{d||c(f)}).catch(()=>{}),()=>{d=!0}},[l]),s.jsxs("div",{className:"space-y-3 text-xs leading-relaxed text-muted-foreground",children:[s.jsx("p",{children:n("settings.mobileSetupIntro")}),e.httpsEnabled&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2 p-3",children:[s.jsx("h3",{className:"font-medium text-foreground",children:n("settings.mobileSetupDownload")}),l?s.jsxs(s.Fragment,{children:[a&&s.jsx("img",{src:a,alt:n("settings.mobileSetupDownload"),className:"h-44 w-44 rounded-lg"}),s.jsxs("button",{type:"button",onClick:()=>t(l),className:"flex w-full items-center justify-between gap-3 rounded-lg bg-surface p-2 text-left",children:[s.jsx("span",{className:"break-all",children:l}),s.jsx("span",{className:"shrink-0 text-primary",children:n(r?"rightSidebar.copied":"common.copy")})]})]}):s.jsx("p",{children:n("settings.caMissing")}),s.jsx("p",{children:n("settings.mobileSetupIos")}),s.jsx("p",{children:n("settings.mobileSetupAndroid")})]}),s.jsx("h3",{className:"font-medium text-foreground",children:e.httpsEnabled?n("settings.mobileSetupConnect"):n("settings.localAccess")}),s.jsx("p",{children:n("settings.mobileSetupConnectHint")})]})}const If=Sc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function Ox(){const e=bl(),t=e.visualViewport,r=document.documentElement.style,n=m=>m===void 0?"?":Math.round(m),a=m=>r.getPropertyValue(m)||"?";let c=document.activeElement?.parentElement,l=null;for(;c&&!l;)l=c.querySelector('[data-mobile-keyboard="true"]'),c=c.parentElement;const d=l?.getBoundingClientRect(),f=document.getElementById("root")?.getBoundingClientRect();return[`VVP ${n(t?.height)} off ${n(t?.offsetTop)} win ${e.innerHeight}`,`base ${a("--app-base-vh")} kb ${a("--kb-height")} move ${a("--kb-translate-y")}`,`bar ${n(d?.top)}…${n(d?.bottom)} h ${n(d?.height)} root ${n(f?.bottom)}`,`safe ${a("--safe-top-inset")}/${a("--safe-bottom-inset")} frame ${e!==window?"child":"root"} focus ${document.activeElement?.tagName??"?"}`].join(`
10
+ `)}function AC({onClose:e}){const[t,r]=_.useState(Ox);return _.useEffect(()=>{const n=window.setInterval(()=>r(Ox()),200);return()=>window.clearInterval(n)},[]),s.jsxs("div",{className:"pointer-events-none fixed inset-x-2 z-toast rounded-lg border border-border/15 bg-surface p-2 text-foreground md:hidden",style:{top:"calc(var(--safe-top-inset, 0px) + 40px)"},children:[s.jsx("button",{type:"button",className:"pointer-events-auto absolute right-1 top-1 px-2 py-1 text-xs",onPointerDown:n=>n.preventDefault(),onClick:e,"aria-label":"关闭布局诊断",children:"×"}),s.jsx("pre",{className:"pr-5 font-mono text-[10px] leading-tight",children:t})]})}const TC={x:0,y:0,width:1,height:1};function Kc(e){return"id"in e?[e.id]:[...Kc(e.first),...Kc(e.second)]}function u1(e,t=0,r=new Set){if(!e||typeof e!="object"||t>24)return null;const n=e;if(typeof n.id=="string"&&n.id&&!r.has(n.id))return r.add(n.id),{id:n.id};if(!["x","y"].includes(String(n.axis))||!Number.isFinite(n.ratio))return null;const a=u1(n.first,t+1,r),c=u1(n.second,t+1,r);return a&&c?{axis:n.axis,ratio:Math.max(.02,Math.min(.98,Number(n.ratio))),first:a,second:c}:a??c}function M0(e,t){if("id"in e)return t.has(e.id)?e:null;const r=M0(e.first,t),n=M0(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function Ef(e,t,r,n){return"id"in e?e.id===t?{axis:n==="left"||n==="right"?"x":"y",ratio:.5,first:n==="left"||n==="top"?{id:r}:e,second:n==="left"||n==="top"?e:{id:r}}:e:{...e,first:Ef(e.first,t,r,n),second:Ef(e.second,t,r,n)}}function SC(e,t,r,n){if(t===r||!Kc(e).includes(t)||!Kc(e).includes(r))return e;if(n==="center"){const a=c=>"id"in c?{id:c.id===t?r:c.id===r?t:c.id}:{...c,first:a(c.first),second:a(c.second)};return a(e)}return Ef(M0(e,new Set(Kc(e).filter(a=>a!==t))),r,t,n)}function Xu(e,t){if(e.length===1)return{id:e[0]};if(t==="grid"&&e.length>2){const r=Math.ceil(e.length/2);return{axis:"y",ratio:.5,first:Xu(e.slice(0,r),"horizontal"),second:Xu(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:Xu(e.slice(1),t)}}function d1(e,t=TC,r=""){if("id"in e)return{panes:[{id:e.id,rect:t}],dividers:[]};const n={...t},a={...t};e.axis==="x"?(n.width*=e.ratio,a.x+=n.width,a.width-=n.width):(n.height*=e.ratio,a.y+=n.height,a.height-=n.height);const c=d1(e.first,n,r+"0"),l=d1(e.second,a,r+"1");return{panes:[...c.panes,...l.panes],dividers:[{path:r,node:e,rect:t},...c.dividers,...l.dividers]}}function v0(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:v0(e.first,t.slice(1),r)}:{...e,second:v0(e.second,t.slice(1),r)}:{...e,ratio:r}}function C3(e){return"id"in e||"id"in e.first||"id"in e.second||e.first.axis===e.axis||e.second.axis===e.axis||!("id"in e.first.first)||!("id"in e.first.second)||!("id"in e.second.first)||!("id"in e.second.second)?null:e.axis==="y"?{ids:[e.first.first.id,e.first.second.id,e.second.first.id,e.second.second.id],top:e.first.ratio,bottom:e.second.ratio,left:e.ratio,right:e.ratio}:{ids:[e.first.first.id,e.second.first.id,e.first.second.id,e.second.second.id],top:e.ratio,bottom:e.ratio,left:e.first.ratio,right:e.second.ratio}}function Wp(e,t,r){const n=C3(e);if(!n)return e;const[a,c,l,d]=n.ids.map(f=>({id:f}));return t==="top"||t==="bottom"?{axis:"y",ratio:(n.left+n.right)/2,first:{axis:"x",ratio:t==="top"?r:n.top,first:a,second:c},second:{axis:"x",ratio:t==="bottom"?r:n.bottom,first:l,second:d}}:{axis:"x",ratio:(n.top+n.bottom)/2,first:{axis:"y",ratio:t==="left"?r:n.left,first:a,second:l},second:{axis:"y",ratio:t==="right"?r:n.right,first:c,second:d}}}function CC(e,t,r,n,a){const c=(f,m,x)=>{if(f.length===1)return f[0];const y=x?.length===f.length&&x.every(w=>Number.isFinite(w)&&w>0)?x:f.map(()=>1);return{axis:m,ratio:y[0]/y.reduce((w,v)=>w+v,0),first:f[0],second:c(f.slice(1),m,y.slice(1))}};if(t!=="grid")return c(e.map(f=>({id:f})),t==="vertical"?"y":"x",r);const l=Math.ceil(Math.sqrt(e.length)),d=[];for(let f=0;f<e.length;f+=l){const m=e.slice(f,f+l).map(y=>({id:y})),x=n?.length===l?n.slice(0,m.length):void 0;x&&m.length<l&&(x[x.length-1]+=n.slice(m.length).reduce((y,w)=>y+w,0)),d.push(c(m,"x",x))}return c(d,"y",a)}let _C;function op(){try{const e="termdock-collaboration-panel-client",t=localStorage.getItem(e);if(t)return t;const r=crypto.randomUUID();return localStorage.setItem(e,r),r}catch{return _C??=crypto.randomUUID()}}let Fx=Promise.resolve();function Xa(e,t){t&&(e={groups:{[t]:e}});const r=op(),n=Fx.catch(()=>{}).then(()=>Ua({collaborationPanel:{clientId:r,state:e}}));return Fx=n,n.then(()=>{})}function $x(e,t,r,n,a,c){return{x:a>0?Math.max(0,Math.min(1,(e-r)/a)):.5,y:c>0?Math.max(0,Math.min(1,(t-n)/c)):.5}}function _3(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function k3(e){const t=Object.entries(e?.groups??{}).filter(([,r])=>r.floatingGroupId).map(([r])=>r);return e?.floatingGroupId&&!e.groups?.[e.floatingGroupId]&&t.push(e.floatingGroupId),t}async function kC(e,t){const r=$i.getState(),n=r.groupId;r.drafts[e]&&await Xa({drafts:{[e]:r.drafts[e]}});const a={sessionId:t,side:window.innerWidth<640?"bottom":"right"};if(await Xa({floatingGroupId:e,mode:"docked",dock:a},e),$i.getState().groupId!==n)throw new Error("布局已保存;页面已切换,请重新打开成员消息");window.dispatchEvent(new CustomEvent("termdock:open-collaboration-messages",{detail:{groupId:e,dock:a}}))}const LC=e=>e.startsWith("@collaboration:"),Ux=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function IC({groupId:e}){const t=ss(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||ss.getState().hosts[e]===r.current)&&t(e,a),r.current=a},[e,t]);return s.jsx("div",{ref:n,className:"h-full min-h-0 min-w-0 bg-surface"})}function zx({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:c=!1}){const l=ss(se=>se.docks),d=JSON.stringify(t.map(se=>se.id)),f=Object.entries(l).filter(([,se])=>t.some(De=>De.id===se.sessionId)),m=JSON.stringify(f),x=b.useRef(null),[y,w]=b.useState(()=>n??Xu(t.map(se=>se.id),c?"vertical":r)),v=b.useRef(y);v.current=y;const[T,C]=b.useState(!1),L=ss(se=>se.activePaneId),[N,D]=b.useState(null),[O,P]=b.useState(null),[F,ee]=b.useState(null),Z=b.useRef(r),G=b.useRef(t.map(se=>se.id)),de=b.useRef({}),pe=b.useRef(!1),J=()=>{pe.current&&(pe.current=!1,Xa({layouts:{[e]:v.current}}).catch(()=>{pe.current=!0,D("布局保存失败,调整后重试")}))};b.useEffect(()=>{let se=!1;return Cc().then(De=>{if(se)return;const _e=De.collaborationPanels?.[op()];for(const Ke of k3(_e)){const Ne=_3(_e,Ke);Ne.mode==="docked"&&Ne.dock&&t.some(ae=>ae.id===Ne.dock.sessionId)&&!ss.getState().docks[Ke]&&ss.getState().setDock(Ke,Ne.dock)}let Me=u1(_e?.layouts?.[e]);if(Me&&_e?.floatingGroupId){const Ke=Ne=>"id"in Ne?{id:Ne.id==="@collaboration"?xh(_e.floatingGroupId):Ne.id}:{...Ne,first:Ke(Ne.first),second:Ke(Ne.second)};Me=Ke(Me)}Me&&w(Me),C(!0)}).catch(()=>{se||D("布局加载失败,请刷新重试")}),()=>{se=!0}},[e]);const Re=se=>{pe.current=!0,v.current=se,w(se)};b.useLayoutEffect(()=>{if(!T)return;const se=JSON.parse(d),De=Z.current!==r;Z.current=r;let _e=De?Xu(se,r):v.current;const Me=G.current;if(!De&&Me.length===se.length&&Me.every(ae=>se.includes(ae))&&Me.some((ae,ze)=>ae!==se[ze])){const ae=new Map(Me.map((at,ct)=>[at,se[ct]])),ze=at=>"id"in at?{id:ae.get(at.id)??at.id}:{...at,first:ze(at.first),second:ze(at.second)};_e=ze(_e)}G.current=se;const Ke=new Set([...se,...f.map(([ae])=>xh(ae))]);_e=M0(_e,Ke)??Xu(se,r);for(const ae of se)Kc(_e).includes(ae)||(_e={axis:"x",ratio:.5,first:_e,second:{id:ae}});const Ne={};for(const[ae,ze]of f){const at=xh(ae),ct=`${ze.sessionId}:${ze.side}`;if(Ne[ae]=ct,(!Kc(_e).includes(at)||de.current[ae]&&de.current[ae]!==ct)&&(_e=M0(_e,new Set([...Ke].filter(me=>me!==at))),_e=Ef(_e,ze.sessionId,at,ze.side)),ze.preferredWidth&&(ze.side==="left"||ze.side==="right")){const me=(ut,ft)=>{if("id"in ut)return ut;const Se="id"in ut.first&&ut.first.id===at,He="id"in ut.second&&ut.second.id===at;if(ut.axis==="x"&&(Se||He)&&ut.ratio===.5){const ie=(x.current?.clientWidth||window.innerWidth)*ft.width,ge=Math.max(.1,Math.min(.45,ze.preferredWidth/Math.max(1,ie)));return{...ut,ratio:Se?ge:1-ge}}const ke={...ft},z={...ft};return ut.axis==="x"?(ke.width*=ut.ratio,z.x+=ke.width,z.width-=ke.width):(ke.height*=ut.ratio,z.y+=ke.height,z.height-=ke.height),{...ut,first:me(ut.first,ke),second:me(ut.second,z)}};_e=me(_e,{x:0,y:0,width:1,height:1})}}de.current=Ne,JSON.stringify(_e)!==JSON.stringify(v.current)&&(Re(_e),J())},[T,d,r,m]),b.useEffect(()=>{const se=()=>J();return window.addEventListener("pagehide",se),()=>{window.removeEventListener("pagehide",se),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),se()}},[e]);const Ze=d1(y),V=C3(y),ve=[...t,...f.map(([se])=>({id:xh(se),content:s.jsx(IC,{groupId:se})}))],qe=b.useRef(null),le=b.useRef(F);le.current=F;const ye=b.useRef(null);b.useEffect(()=>{const se=x.current;if(!se||!T)return;const De=Me=>{if(Me.button!==0||!(Me.target instanceof Element))return;const Ke=Me.target.closest("[data-split-pane-title], [data-panel-drag-title]"),Ne=Me.target.closest("button, a, input, textarea, select, summary");if(!Ke||Ne&&Ne!==Ke)return;const ae=Ke.closest("[data-layout-pane]");if(!ae||!se.contains(ae))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const ze=ae.getBoundingClientRect();qe.current={id:ae.dataset.layoutPane,x:Me.clientX,y:Me.clientY,moved:!1,originX:Me.clientX-ze.left,originY:Me.clientY-ze.top,scale:Math.min(.8,480/Math.max(1,ze.width),320/Math.max(1,ze.height))},se.setPointerCapture?.(Me.pointerId)},_e=Me=>{const Ke=Me.target;if(!(Ke instanceof Element))return;const Ne=Ke.closest("[data-layout-pane]");if(!(!Ne||!se.contains(Ne))){if(Me.type==="pointerdown"&&ss.getState().activePaneId!==Ne.dataset.layoutPane){const ae=document.activeElement;ae instanceof HTMLElement&&ae.closest("[data-layout-pane]")&&!Ne.contains(ae)&&ae.blur();const ze=window.getSelection();ze?.anchorNode&&!Ne.contains(ze.anchorNode)&&ze.removeAllRanges()}ss.getState().setActivePane(Ne.dataset.layoutPane)}};return se.addEventListener("pointerdown",_e,!0),se.addEventListener("focusin",_e,!0),se.addEventListener("pointerdown",De,!0),()=>{se.removeEventListener("pointerdown",De,!0),se.removeEventListener("pointerdown",_e,!0),se.removeEventListener("focusin",_e,!0)}},[T]);const Te=(se,De)=>{const _e=x.current?.getBoundingClientRect(),Me=ye.current;if(!_e||!Me)return;const Ke=Me.axis==="x"?_e.width*Me.rect.width:_e.height*Me.rect.height,Ne=Me.axis==="x"?_e.left+_e.width*Me.rect.x:_e.top+_e.height*Me.rect.y,ae=Math.min(.45,(c?48:120)/Math.max(1,Ke)),ze=Math.max(ae,Math.min(1-ae,((Me.axis==="x"?se:De)-Ne)/Math.max(1,Ke)));Re(Me.side?Wp(v.current,Me.side,ze):v0(v.current,Me.path,ze))},Fe=V?[{key:"top",side:"top",axis:"x",x:V.top,y:0,length:(V.left+V.right)/2},{key:"bottom",side:"bottom",axis:"x",x:V.bottom,y:(V.left+V.right)/2,length:1-(V.left+V.right)/2},{key:"left",side:"left",axis:"y",x:0,y:V.left,length:(V.top+V.bottom)/2},{key:"right",side:"right",axis:"y",x:(V.top+V.bottom)/2,y:V.right,length:1-(V.top+V.bottom)/2}].map(se=>({...se,rect:{x:0,y:0,width:1,height:1},path:void 0})):Ze.dividers.map(se=>({key:se.path,path:se.path,side:void 0,axis:se.node.axis,rect:se.rect,x:se.rect.x+(se.node.axis==="x"?se.rect.width*se.node.ratio:0),y:se.rect.y+(se.node.axis==="y"?se.rect.height*se.node.ratio:0),length:se.node.axis==="x"?se.rect.height:se.rect.width}));return s.jsxs("div",{ref:x,"data-split-container":"true",className:"relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-border [&_[data-split-pane-title]]:touch-none [&_[data-panel-drag-title]]:touch-none",onPointerMove:se=>{if(ye.current){se.preventDefault(),Te(se.clientX,se.clientY);return}const De=qe.current,_e=x.current?.getBoundingClientRect();if(!De||!_e||!De.moved&&Math.hypot(se.clientX-De.x,se.clientY-De.y)<6)return;De.moved=!0,P({id:De.id,dx:se.clientX-De.x,dy:se.clientY-De.y,originX:De.originX,originY:De.originY,scale:De.scale});const Me=(se.clientX-_e.left)/_e.width,Ke=(se.clientY-_e.top)/_e.height,Ne=Ze.panes.find(me=>Me>=me.rect.x&&Me<=me.rect.x+me.rect.width&&Ke>=me.rect.y&&Ke<=me.rect.y+me.rect.height);if(!Ne||Ne.id===De.id){le.current=null,ee(null);return}const ae=(Me-Ne.rect.x)/Ne.rect.width,ze=(Ke-Ne.rect.y)/Ne.rect.height,at=Math.min(ae,1-ae,ze,1-ze)>.25?"center":ae<1-ae&&ae<=ze&&ae<=1-ze?"left":1-ae<=ze&&1-ae<=1-ze?"right":ze<1-ze?"top":"bottom",ct={id:Ne.id,side:at};le.current=ct,ee(ct)},onPointerUp:se=>{ye.current&&(ye.current=null,J()),qe.current?.moved&&le.current&&(Re(SC(v.current,qe.current.id,le.current.id,le.current.side)),J()),qe.current=null,le.current=null,ee(null),P(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),se.currentTarget.hasPointerCapture?.(se.pointerId)&&se.currentTarget.releasePointerCapture(se.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,qe.current=null,le.current=null,ee(null),P(null),J()},onKeyDownCapture:se=>{se.key==="Escape"&&(qe.current=null,le.current=null,ee(null),P(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})))},onPointerCancel:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,qe.current=null,le.current=null,ee(null),P(null),J()},children:[O&&s.jsx("div",{"aria-hidden":"true","data-drag-placeholder":"true",className:"pointer-events-none absolute border-2 border-dashed border-primary/30 bg-primary/5",style:Ux(Ze.panes.find(se=>se.id===O.id)?.rect??{x:0,y:0,width:0,height:0})}),ve.map(se=>{const De=Ze.panes.find(Me=>Me.id===se.id)?.rect,_e=!De||!!a&&se.id!==a;return s.jsxs("div",{"data-layout-pane":se.id,"data-pane-active":L===se.id,className:`${L===se.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${O?.id===se.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...Ux(a===se.id?{x:0,y:0,width:1,height:1}:De??{x:0,y:0,width:0,height:0}),padding:ve.length>1?"0.5px":0,transition:"none",visibility:_e?"hidden":void 0,...O?.id===se.id?{transform:`translate(${O.dx}px, ${O.dy}px) scale(${O.scale})`,transformOrigin:`${O.originX}px ${O.originY}px`}:{}},onDragStart:Me=>{Me.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Me.preventDefault()},children:[se.content,c&&ve.length>1&&!LC(se.id)&&s.jsx("button",{type:"button","data-panel-drag-title":"true","aria-label":"拖动面板到其他区域",className:"swiper-no-swiping absolute right-1 top-1 z-20 rounded bg-surface p-1 text-muted-foreground",children:s.jsx(ap,{size:14})}),F?.id===se.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:F.side==="bottom"?"50%":0,bottom:F.side==="top"?"50%":0,left:F.side==="right"?"50%":0,right:F.side==="left"?"50%":0}})]},se.id)}),!a&&Fe.map(se=>s.jsx("button",{type:"button",role:"separator","aria-label":se.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[se.side]}半段分隔线`:"调整分屏大小","aria-orientation":se.axis==="x"?"vertical":"horizontal",disabled:!T,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${se.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${se.x*100}%`,top:`${se.y*100}%`,...se.axis==="x"?{height:`${se.length*100}%`}:{width:`${se.length*100}%`}},onPointerDown:De=>{De.preventDefault(),De.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ye.current=se,x.current?.setPointerCapture?.(De.pointerId)},onDoubleClick:()=>{Re(se.side?Wp(v.current,se.side,.5):v0(v.current,se.path,.5)),J()},onKeyDown:De=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(De.key))return;De.preventDefault();const _e=se.side?V[se.side]:Ze.dividers.find(Ke=>Ke.path===se.path).node.ratio,Me=Math.max(.05,Math.min(.95,_e+(["ArrowRight","ArrowDown"].includes(De.key)?.03:-.03)));Re(se.side?Wp(v.current,se.side,Me):v0(v.current,se.path,Me)),J()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${se.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},se.key)),N&&s.jsx("div",{role:"alert",className:"absolute bottom-1 left-1 z-20 rounded bg-surface px-2 py-1 text-[10px] text-destructive",children:N})]})}let h1=0,Hx=!1,Wu=0;function EC(){if(Hx||typeof window>"u")return;Hx=!0;const e=()=>{h1=performance.now()};window.addEventListener("pointerdown",()=>{Wu+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{Wu=Math.max(0,Wu-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{Wu=0,e()})}function dg(e,t=500){EC();let r=!1,n,a;const c=()=>{if(r)return;if(Wu>0||performance.now()-h1<400){a=setTimeout(c,100);return}const l=()=>{if(!r){if(Wu>0||performance.now()-h1<400){a=setTimeout(c,100);return}e()}};"requestIdleCallback"in window?n=window.requestIdleCallback(l):a=setTimeout(l,16)};return a=setTimeout(c,t),()=>{r=!0,clearTimeout(a),n!==void 0&&window.cancelIdleCallback(n)}}function NC(e){const[t,r]=b.useState(e);return b.useEffect(()=>dg(()=>r(e),0),[e]),t}function RC(e,t){if(t||e.defaultPrevented||e.isComposing||e.keyCode===229)return!1;const n=(e.target instanceof Element?e.target:null)?.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"]');return!n||n.matches("textarea[data-terminal-input-anchor], textarea.xterm-helper-textarea")&&!!n.closest(".terminal-viewport-container")}function f1(e,t){const r=e.replace(/\r?\n/g,"\r");return`\x1B[200~${(t&&r.endsWith("\r")?r.slice(0,-1):r).replace(/\x1b/g,"␛")}\x1B[201~${t?"\r":""}`}function MC(e,t,r){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let a=0;const c=e.length-n,l=t.length-n;for(;a<c&&a<l&&e[e.length-1-a]===t[t.length-1-a];)a+=1;const d=t.slice(n,t.length-a);return d&&(r==="insertFromPaste"||r==="insertFromPasteAsQuotation"||/[\r\n]/.test(d))?d:null}const q0=new Map;function jC(e,t,r){if(!r||!t||!tg(e))return null;const n=`owned-paste-${crypto.randomUUID()}`;return q0.set(n,{source:e,layer:Uy(),sessionId:t,text:r,token:{nonce:n}}),{nonce:n,text:r,sessionId:t,paste:!0,submitAfterPaste:!1,focus:!1,ownedPaste:!0}}function DC(e){q0.delete(e)}function hg(e){return e.layer===Uy()&&tg(e.source)}function BC(e,t){const r=e.nonce?q0.get(e.nonce):void 0;return r&&hg(r)&&e.ownedPaste===!0&&e.paste===!0&&e.submitAfterPaste===!1&&r.sessionId===t&&e.sessionId===t&&e.text===r.text?r.token:null}function QC(e,t,r){const n=q0.get(e.nonce);return!n||n.token!==e||n.consumed?!1:(n.consumed=!0,hg(n)&&n.sessionId===t&&r===f1(n.text,!1))}function PC(e,t){const r=q0.get(e.nonce);return!!r&&r.token===e&&r.sessionId===t&&hg(r)}function OC(e,t,r){b.useEffect(()=>{e&&p8(e,!0)},[e,r])}const Qi=[];for(let e=0;e<256;++e)Qi.push((e+256).toString(16).slice(1));function FC(e,t=0){return(Qi[e[t+0]]+Qi[e[t+1]]+Qi[e[t+2]]+Qi[e[t+3]]+"-"+Qi[e[t+4]]+Qi[e[t+5]]+"-"+Qi[e[t+6]]+Qi[e[t+7]]+"-"+Qi[e[t+8]]+Qi[e[t+9]]+"-"+Qi[e[t+10]]+Qi[e[t+11]]+Qi[e[t+12]]+Qi[e[t+13]]+Qi[e[t+14]]+Qi[e[t+15]]).toLowerCase()}let Gp;const $C=new Uint8Array(16);function UC(){if(!Gp){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Gp=crypto.getRandomValues.bind(crypto)}return Gp($C)}const zC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Wx={randomUUID:zC};function HC(e,t,r){e=e||{};const n=e.random??e.rng?.()??UC();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,FC(n)}function L3(e,t,r){return Wx.randomUUID&&!e?Wx.randomUUID():HC(e)}const I3="\x1B[?2026h",WC="\x1B[?2026l",E3="\x1Bc";function GC(e){return e.replace(/(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|(?:\x1b[P_X^]|[\x90\x98\x9e\x9f])[\s\S]*?(?:\x1b\\|\x9c|$)|(?:\x1b\[|\x9b)\?([\d;]+)([hl])|(?:\x1b\[|\x9b)[\d;]*!p|\x1bc/g,(t,r,n)=>{if(t===E3||t.endsWith("!p"))return t+I3;if(r===void 0)return t;const a=r.split(";").filter(c=>Number(c)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function VC(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=GC(t.replace(/^(?:\x1bc)+/,""));return[`${E3}${I3}${r}${WC}`]}function qC(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function YC(e){return[["10",e.foreground],["11",e.background]].map(([t,r])=>{const n=/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec(r);if(!n)return"";const a=n.slice(1).map(c=>c.repeat(2)).join("/");return`\x1B]${t};rgb:${a}\x1B\\`}).join("")}async function sf(e,t=()=>!0){if(!e||!t())return!1;const r=na();if(r?.writeClipboardText)try{return await r.writeClipboardText(e),t()}catch{return!1}try{return await navigator.clipboard.writeText(e),t()}catch{if(!t())return!1;const n=document.activeElement,a=document.createElement("textarea");a.value=e,a.readOnly=!0,a.style.position="fixed",a.style.left="-9999px",document.body.append(a);try{return a.select(),t()&&document.execCommand("copy")}catch{return!1}finally{a.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}}}async function ZC(e,t){if(!t())return!1;const r=await zy(e,{action:"copy-selection"});if(!t())return!1;const n=r.selection;if(!r.success||!n||!["copied","empty"].includes(n.status)||typeof n.text!="string"||typeof n.paneId!="string"||!/^%[0-9]+$/.test(n.paneId)||new TextEncoder().encode(n.text).length!==n.bytes||n.bytes>262144)throw new Error("服务未返回有效的终端选区,请更新服务后重试。");if(n.status==="empty")return!1;if(!n.bytes)throw new Error("终端选区为空。");return sf(n.text,t)}function Ed(e){return e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"")}const KC={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},XC={F1:"P",F2:"Q",F3:"R",F4:"S"},JC={Insert:2,Delete:3,PageUp:5,PageDown:6,F5:15,F6:17,F7:18,F8:19,F9:20,F10:21,F11:23,F12:24};function e_(e,t=!1){if(e.metaKey||e.isComposing||e.keyCode===229||e.getModifierState?.("AltGraph"))return null;const{key:r,shiftKey:n,altKey:a,ctrlKey:c}=e,l=1+Number(n)+2*Number(a)+4*Number(c),d=l===1?"":`;${l}`,f=KC[r];if(f)return l!==1?`\x1B[1${d}${f}`:`\x1B${t?"O":"["}${f}`;const m=XC[r];if(m)return l!==1?`\x1B[1${d}${m}`:`\x1BO${m}`;if(r==="Insert"&&!a&&(n||c))return null;const x=JC[r];if(x)return`\x1B[${x}${d}~`;if(r==="Tab")return a?`\x1B${n?"\x1B[Z":" "}`:n?"\x1B[Z":" ";if(r==="Escape")return a?"\x1B\x1B":"\x1B";if(r==="Enter")return a?"\x1B\r":null;if(r==="Backspace")return c||a?`${a?"\x1B":""}${c?"\b":""}`:null;if(r.length!==1)return null;if(c){const y=r.toUpperCase();let w;return/^[A-Z]$/.test(y)?w=y.charCodeAt(0)-64:r===" "||r==="@"||r==="2"?w=0:"[\\]^_".includes(r)?w=r.charCodeAt(0)-64:/^[3-7]$/.test(r)?w=Number(r)+24:r==="?"||r==="8"?w=127:r==="/"&&(w=31),w===void 0?null:`${a?"\x1B":""}${String.fromCharCode(w)}`}return a?`\x1B${r}`:null}class w0 extends Error{}async function N3(e,t){if(!e.type.startsWith("image/")||e.size===0)throw new Error("Clipboard image is empty");const r=e.type==="image/jpeg"?"jpg":e.type.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png",n=new File([e],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${r}`,{type:e.type}),{files:a}=await W0("/tmp",[n],t);if(!a[0]?.path)throw new Error("Upload did not return an image path");return a[0].path}async function Nf(e){const t=na();if(t?.readClipboardImage){const r=await t.readClipboardImage();return r?.byteLength?new File([r],"clipboard.png",{type:"image/png"}):null}if(typeof e?.read!="function")return null;for(const r of await e.read()){const n=r.types.find(l=>l.startsWith("image/"));if(!n)continue;const a=await r.getType(n),c=n==="image/jpeg"?"jpg":n.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png";return new File([a],`termdock-clipboard-${Date.now()}.${c}`,{type:n})}return null}async function R3(e){if(typeof e?.read!="function")return[];const t=[],r={"video/mp4":"mp4","video/quicktime":"mov","video/x-m4v":"m4v","video/webm":"webm","video/ogg":"ogv","video/mpeg":"mpeg","video/x-msvideo":"avi","video/x-matroska":"mkv","video/3gpp":"3gp","video/3gpp2":"3g2"};for(const n of await e.read()){const a=n.types.find(f=>f.startsWith("video/"));if(!a)continue;const c=await n.getType(a);if(!c.size)throw new Error("Clipboard video is empty");const l=a.split(";")[0].toLowerCase(),d=r[l]||l.slice(6).replace(/[^a-z0-9]/g,"")||"mp4";t.push(new File([c],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${d}`,{type:a}))}return t}async function M3(){const e=Gc()?.targetPeerId;let t;try{t=await na()?.readClipboardFiles?.({localServiceId:e})}catch(a){const c=a instanceof Error?a.message:String(a),l="TERMDOCK_CLIPBOARD_VIDEO_ERROR:",d=c.indexOf(l);if(d!==-1)throw new w0(c.slice(d+l.length).trim());const f=c.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw f?new w0(f[1]):a}if(Gc()?.targetPeerId!==e)throw new Error("目标服务已切换,请重新粘贴");const r=[],n=[];for(const a of t??[])if(a.path&&e)n.push(a.path);else if(a.bytes){if(a.type?.startsWith("video/")&&a.bytes.byteLength===0)throw new w0("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");r.push(new File([a.bytes],a.name,{type:a.type||"application/octet-stream"}))}else throw new Error("剪贴板未提供可读取的文件");return{files:r,paths:n}}async function j3(e,t){if(!e.length)return[];const{files:r}=await W0("/tmp",e,t);if(r.length!==e.length||r.some(n=>!n.path))throw new Error("Upload did not return every file path");return r.map(n=>n.path)}function li(e){return{dispose:e}}function t_(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function r_(...e){return li(()=>t_(e))}var D3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},lu=class{constructor(){this._store=new D3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};lu.None=Object.freeze({dispose(){}});var Nd=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},B3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),Y0=B3?"node":navigator.userAgent,n_=B3?"node":navigator.platform,s_=Y0.includes("Firefox");Y0.includes("Chrome");var i_=Y0.includes("Edge"),Q3=/^((?!chrome|android).)*safari/i.test(Y0);function a_(){if(!Q3)return 0;let e=Y0.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}n_.indexOf("Linux")>=0;var yi=0,vi=0,wi=0,Ds=0,Co={css:"#00000000",rgba:0},Sa;(e=>{function t(a,c,l,d){return d!==void 0?`#${Bc(a)}${Bc(c)}${Bc(l)}${Bc(d)}`:`#${Bc(a)}${Bc(c)}${Bc(l)}`}e.toCss=t;function r(a,c,l,d=255){return(a<<24|c<<16|l<<8|d)>>>0}e.toRgba=r;function n(a,c,l,d){return{css:e.toCss(a,c,l,d),rgba:e.toRgba(a,c,l,d)}}e.toColor=n})(Sa||={});var h0;(e=>{function t(f,m){if(Ds=(m.rgba&255)/255,Ds===1)return{css:m.css,rgba:m.rgba};let x=m.rgba>>24&255,y=m.rgba>>16&255,w=m.rgba>>8&255,v=f.rgba>>24&255,T=f.rgba>>16&255,C=f.rgba>>8&255;yi=v+Math.round((x-v)*Ds),vi=T+Math.round((y-T)*Ds),wi=C+Math.round((w-C)*Ds);let L=Sa.toCss(yi,vi,wi),N=Sa.toRgba(yi,vi,wi);return{css:L,rgba:N}}e.blend=t;function r(f){return(f.rgba&255)===255}e.isOpaque=r;function n(f,m,x){let y=Xc.ensureContrastRatio(f.rgba,m.rgba,x);if(y)return Sa.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(f){let m=(f.rgba|255)>>>0;return[yi,vi,wi]=Xc.toChannels(m),{css:Sa.toCss(yi,vi,wi),rgba:m}}e.opaque=a;function c(f,m){return Ds=Math.round(m*255),[yi,vi,wi]=Xc.toChannels(f.rgba),{css:Sa.toCss(yi,vi,wi,Ds),rgba:Sa.toRgba(yi,vi,wi,Ds)}}e.opacity=c;function l(f,m){return Ds=f.rgba&255,c(f,Ds*m/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(h0||={});var o_;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return yi=parseInt(a.slice(1,2).repeat(2),16),vi=parseInt(a.slice(2,3).repeat(2),16),wi=parseInt(a.slice(3,4).repeat(2),16),Sa.toColor(yi,vi,wi);case 5:return yi=parseInt(a.slice(1,2).repeat(2),16),vi=parseInt(a.slice(2,3).repeat(2),16),wi=parseInt(a.slice(3,4).repeat(2),16),Ds=parseInt(a.slice(4,5).repeat(2),16),Sa.toColor(yi,vi,wi,Ds);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return yi=parseInt(c[1],10),vi=parseInt(c[2],10),wi=parseInt(c[3],10),Ds=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Sa.toColor(yi,vi,wi,Ds);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[yi,vi,wi,Ds]=t.getImageData(0,0,1,1).data,Ds!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Sa.toRgba(yi,vi,wi,Ds),css:a}}e.toColor=n})(o_||={});var va;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,c){let l=n/255,d=a/255,f=c/255,m=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),x=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(va||={});var Xc;(e=>{function t(l,d){if(Ds=(d&255)/255,Ds===1)return d;let f=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return yi=y+Math.round((f-y)*Ds),vi=w+Math.round((m-w)*Ds),wi=v+Math.round((x-v)*Ds),Sa.toRgba(yi,vi,wi)}e.blend=t;function r(l,d,f){let m=va.relativeLuminance(l>>8),x=va.relativeLuminance(d>>8);if(jl(m,x)<f){if(x<m){let v=n(l,d,f),T=jl(m,va.relativeLuminance(v>>8));if(T<f){let C=a(l,d,f),L=jl(m,va.relativeLuminance(C>>8));return T>L?v:C}return v}let y=a(l,d,f),w=jl(m,va.relativeLuminance(y>>8));if(w<f){let v=n(l,d,f),T=jl(m,va.relativeLuminance(v>>8));return w>T?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,T=d>>8&255,C=jl(va.relativeLuminance2(w,v,T),va.relativeLuminance2(m,x,y));for(;C<f&&(w>0||v>0||T>0);)w-=Math.max(0,Math.ceil(w*.1)),v-=Math.max(0,Math.ceil(v*.1)),T-=Math.max(0,Math.ceil(T*.1)),C=jl(va.relativeLuminance2(w,v,T),va.relativeLuminance2(m,x,y));return(w<<24|v<<16|T<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,T=d>>8&255,C=jl(va.relativeLuminance2(w,v,T),va.relativeLuminance2(m,x,y));for(;C<f&&(w<255||v<255||T<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),T=Math.min(255,T+Math.ceil((255-T)*.1)),C=jl(va.relativeLuminance2(w,v,T),va.relativeLuminance2(m,x,y));return(w<<24|v<<16|T<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(Xc||={});function Bc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function qs(e){if(!e)throw new Error("value must not be falsy");return e}function fg(e){return 57508<=e&&e<=57558}function l_(e){return 57520<=e&&e<=57527}function c_(e){return 57344<=e&&e<=63743}function u_(e){return 9472<=e&&e<=9631}function d_(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function h_(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!d_(e)&&!fg(e)&&!c_(e)}function P3(e){return fg(e)||u_(e)}function f_(){return{css:{canvas:vh(),cell:vh()},device:{canvas:vh(),cell:vh(),char:{width:0,height:0,left:0,top:0}}}}function vh(){return{width:0,height:0}}function p_(e,t,r=0){return(e-(Math.round(t)*2-r))%(Math.round(t)*2)}var Ue;(e=>(e.LINE_H=Object.freeze({type:2,data:"M0,.5 L1,.5",strokeWidth:1}),e.LINE_V=Object.freeze({type:2,data:"M.5,0 L.5,1",strokeWidth:1}),e.FADE_RIGHT=Object.freeze({type:2,data:"M0,.5 L.28,.5 M.32,.5 L.52,.5 M.60,.5 L.72,.5 M.84,.5 L.90,.5",strokeWidth:1}),e.FADE_LEFT=Object.freeze({type:2,data:"M.10,.5 L.16,.5 M.28,.5 L.40,.5 M.48,.5 L.68,.5 M.72,.5 L1,.5",strokeWidth:1}),e.FADE_DOWN=Object.freeze({type:2,data:"M.5,0 L.5,.28 M.5,.32 L.5,.52 M.5,.60 L.5,.72 M.5,.84 L.5,.90",strokeWidth:1}),e.FADE_UP=Object.freeze({type:2,data:"M.5,.10 L.5,.16 M.5,.28 L.5,.40 M.5,.48 L.5,.68 M.5,.72 L.5,1",strokeWidth:1}),e.CURVE_DOWN_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_DOWN_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.CURVE_UP_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_UP_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.NODE_FILL=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5"}),e.NODE_STROKE=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5",strokeWidth:1}),e.NODE_LINE_RIGHT=Object.freeze({type:3,data:"M1,.5 L.85,.5",strokeWidth:1}),e.NODE_LINE_LEFT=Object.freeze({type:3,data:"M0,.5 L.15,.5",strokeWidth:1}),e.NODE_LINE_DOWN=Object.freeze({type:3,data:"M.5,1 L.5,.7",strokeWidth:1}),e.NODE_LINE_UP=Object.freeze({type:3,data:"M.5,0 L.5,.3",strokeWidth:1})))(Ue||={});var m_={"─":{type:2,data:"M0,.5 L1,.5",strokeWidth:1},"━":{type:2,data:"M0,.5 L1,.5",strokeWidth:3},"│":{type:2,data:"M.5,0 L.5,1",strokeWidth:1},"┃":{type:2,data:"M.5,0 L.5,1",strokeWidth:3},"┄":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:1},"┅":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:3},"┆":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:1},"┇":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:3},"┈":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:1},"┉":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:3},"┊":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:1},"┋":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:3},"┌":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},"┍":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┎":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┏":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3},"┐":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},"┑":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┒":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┓":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3},"└":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},"┕":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┖":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┗":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3},"┘":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},"┙":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┚":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┛":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3},"├":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},"┝":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┞":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┟":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┠":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┡":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┢":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┣":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3},"┤":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},"┥":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┦":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┧":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┨":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┩":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┪":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┫":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3},"┬":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},"┭":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┮":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┯":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┰":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┱":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┲":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┳":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3},"┴":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:1},"┵":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┶":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┷":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┸":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┹":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┺":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┻":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:3},"┼":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:1},"┽":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┾":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┿":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"╀":[{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"╁":[{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╂":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"╃":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"╄":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"╅":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"╆":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"╇":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:3}],"╈":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3}],"╉":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3}],"╊":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3}],"╋":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:3},"╌":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:1},"╍":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:3},"╎":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:1},"╏":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:3},"═":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"║":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╒":{type:2,data:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╓":{type:2,data:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╔":{type:2,data:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╕":{type:2,data:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╖":{type:2,data:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`,strokeWidth:1},"╗":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`,strokeWidth:1},"╘":{type:2,data:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`,strokeWidth:1},"╙":{type:2,data:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╚":{type:2,data:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`,strokeWidth:1},"╛":{type:2,data:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`,strokeWidth:1},"╜":{type:2,data:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`,strokeWidth:1},"╝":{type:2,data:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`,strokeWidth:1},"╞":{type:2,data:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╟":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`,strokeWidth:1},"╠":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╡":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╢":{type:2,data:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╣":{type:2,data:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`,strokeWidth:1},"╤":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`,strokeWidth:1},"╥":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╦":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╧":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╨":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╩":{type:2,data:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╪":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╫":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╬":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╭":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╮":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╯":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╰":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╱":{type:2,data:"M1,0 L0,1",strokeWidth:1},"╲":{type:2,data:"M0,0 L1,1",strokeWidth:1},"╳":{type:2,data:"M1,0 L0,1 M0,0 L1,1",strokeWidth:1},"╴":{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},"╵":{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},"╶":{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},"╷":{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},"╸":{type:2,data:"M.5,.5 L0,.5",strokeWidth:3},"╹":{type:2,data:"M.5,.5 L.5,0",strokeWidth:3},"╺":{type:2,data:"M.5,.5 L1,.5",strokeWidth:3},"╻":{type:2,data:"M.5,.5 L.5,1",strokeWidth:3},"╼":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"╽":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╾":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"╿":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"▀":{type:0,data:[{x:0,y:0,w:8,h:4}]},"▁":{type:0,data:[{x:0,y:7,w:8,h:1}]},"▂":{type:0,data:[{x:0,y:6,w:8,h:2}]},"▃":{type:0,data:[{x:0,y:5,w:8,h:3}]},"▄":{type:0,data:[{x:0,y:4,w:8,h:4}]},"▅":{type:0,data:[{x:0,y:3,w:8,h:5}]},"▆":{type:0,data:[{x:0,y:2,w:8,h:6}]},"▇":{type:0,data:[{x:0,y:1,w:8,h:7}]},"█":{type:0,data:[{x:0,y:0,w:8,h:8}]},"▉":{type:0,data:[{x:0,y:0,w:7,h:8}]},"▊":{type:0,data:[{x:0,y:0,w:6,h:8}]},"▋":{type:0,data:[{x:0,y:0,w:5,h:8}]},"▌":{type:0,data:[{x:0,y:0,w:4,h:8}]},"▍":{type:0,data:[{x:0,y:0,w:3,h:8}]},"▎":{type:0,data:[{x:0,y:0,w:2,h:8}]},"▏":{type:0,data:[{x:0,y:0,w:1,h:8}]},"▐":{type:0,data:[{x:4,y:0,w:4,h:8}]},"░":{type:1,data:[[1,0],[0,0]]},"▒":{type:1,data:[[1,0],[0,1]]},"▓":{type:1,data:[[1,1],[1,0]]},"▔":{type:0,data:[{x:0,y:0,w:8,h:1}]},"▕":{type:0,data:[{x:7,y:0,w:1,h:8}]},"▖":{type:0,data:[{x:0,y:4,w:4,h:4}]},"▗":{type:0,data:[{x:4,y:4,w:4,h:4}]},"▘":{type:0,data:[{x:0,y:0,w:4,h:4}]},"▙":{type:0,data:[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"▚":{type:0,data:[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}]},"▛":{type:0,data:[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}]},"▜":{type:0,data:[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}]},"▝":{type:0,data:[{x:4,y:0,w:4,h:4}]},"▞":{type:0,data:[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}]},"▟":{type:0,data:[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"":{type:5,data:{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.7,.03 L.7,.1 L.355,.1 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2}},"":{type:5,data:{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2}},"":{type:5,data:{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1}},"":{type:5,data:{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1}},"":{type:5,data:{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0.8069,0.6075 Q0.7991,0.612,0.7815,0.6218 T0.7542,0.6369 T0.7282,0.6508 T0.7016,0.6644 T0.6778,0.6758 T0.6551,0.6854 T0.637,0.6911 T0.622,0.6936 Q0.6186,0.6936,0.6128,0.6942 T0.6018,0.6952 T0.5894,0.6956 T0.5757,0.6952 T0.561,0.693 T0.5451,0.6879 Q0.5342,0.6834,0.5193,0.6756 T0.4925,0.6614 T0.4673,0.6485 T0.4436,0.6389 T0.4239,0.6363 T0.4089,0.6422 Q0.4045,0.6467,0.3958,0.6554 T0.3843,0.6669 T0.3748,0.6746 T0.3613,0.683 T0.3442,0.6903 L0.3499,0.6956 Q0.3584,0.7042,0.3679,0.7177 T0.3836,0.7403 T0.4019,0.7583 T0.4295,0.7703 Q0.4688,0.7785,0.5203,0.7605 Q0.4902,0.7817,0.449,0.7911 T0.3696,0.8001 Q0.3567,0.7997,0.341,0.7942 T0.3111,0.7813 T0.2805,0.766 T0.2493,0.753 T0.218,0.7472 T0.187,0.754 Q0.1762,0.7589,0.1653,0.7681 T0.1453,0.7895 T0.1308,0.818 T0.1264,0.8507 L0.1264,0.858 Q0.1453,0.8462,0.1607,0.8433 T0.1899,0.8452 T0.2226,0.8625 Q0.2344,0.8707,0.2485,0.8752 T0.2813,0.8831 T0.3089,0.889 Q0.2981,0.8915,0.2846,0.8956 T0.2603,0.9037 T0.2368,0.9115 T0.2129,0.9174 T0.1894,0.9194 T0.1653,0.9155 Q0.1504,0.9115,0.1328,0.9196 T0.0986,0.9421 T0.0655,0.9708 T0.0317,0.9943 T0,1 Q0.001,0.94,0.0017,0.6508 T0.0024,0.2322 Q0.002,0.2109,0.0007,0.1379 T0,0.0249 Q0.0058,0.0253,0.009,0.0257 T0.0156,0.0288 T0.0203,0.0333 T0.0264,0.0422 T0.0349,0.0539 Q0.044,0.0657,0.0542,0.072 T0.0752,0.0789 T0.096,0.0775 T0.1175,0.0694 T0.1379,0.0573 T0.1579,0.0432 Q0.2141,0,0.2673,0.0318 Q0.2588,0.0318,0.2517,0.033 T0.239,0.0361 T0.2276,0.0424 T0.218,0.0504 T0.2085,0.0612 T0.1997,0.0732 T0.1899,0.0875 T0.1795,0.1028 Q0.1748,0.1093,0.1507,0.1234 T0.1186,0.1448 Q0.0999,0.1612,0.1108,0.1783 Q0.1162,0.1877,0.1238,0.1928 T0.1404,0.1979 T0.158,0.1967 T0.1775,0.1895 T0.1963,0.1791 T0.2151,0.1663 T0.2314,0.1534 T0.2458,0.141 T0.2561,0.1322 Q0.2815,0.1106,0.3017,0.101 T0.344,0.0926 T0.3919,0.1077 Q0.4099,0.1175,0.4265,0.1206 T0.4588,0.1202 T0.488,0.1098 T0.5176,0.0914 Q0.5071,0.1032,0.4963,0.1122 T0.4722,0.1285 T0.4497,0.1401 T0.4223,0.1518 T0.3943,0.1636 Q0.374,0.1726,0.3623,0.1863 T0.3482,0.2162 Q0.3445,0.2403,0.3608,0.2605 T0.4072,0.2876 Q0.4194,0.2909,0.4326,0.2899 T0.457,0.2856 T0.4805,0.2764 T0.5032,0.264 T0.5256,0.2497 T0.5478,0.2352 T0.5698,0.2222 T0.5921,0.2118 Q0.6982,0.173,0.81,0.2436 Q0.833,0.2583,0.8496,0.2674 T0.887,0.2846 T0.925,0.294 T0.9617,0.2911 T1,0.2746 Q0.9817,0.2946,0.96,0.3056 T0.9175,0.3191 T0.8731,0.3209 T0.8277,0.3164 T0.7818,0.3109 T0.7359,0.3101 T0.6907,0.3197 T0.647,0.3448 Q0.6443,0.3472,0.6333,0.3562 T0.6194,0.3674 T0.6076,0.3766 T0.594,0.386 T0.5815,0.3931 T0.5661,0.4007 T0.5501,0.4064 L0.5556,0.4121 Q0.5627,0.4198,0.5722,0.4251 T0.5926,0.4337 T0.6131,0.439 T0.6343,0.4431 T0.6521,0.4468 Q0.6762,0.4529,0.7056,0.4463 Q0.6772,0.4623,0.6543,0.471 T0.604,0.4814 Q0.5962,0.4818,0.5815,0.4825 T0.5591,0.4835 T0.5393,0.4857 T0.519,0.4908 T0.5007,0.4996 T0.4812,0.5141 T0.4627,0.5353 L0.4549,0.5451 L0.4661,0.543 Q0.4759,0.541,0.4909,0.55 T0.5315,0.5796 T0.5684,0.6083 Q0.5799,0.6161,0.5915,0.6212 T0.6181,0.6308 L0.6331,0.6353 Q0.6514,0.6418,0.7004,0.633 T0.8069,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.011,0.0469 Q0.0152,0.0412,0.02,0.0361 T0.0292,0.0281 T0.0365,0.0253 Q0.0426,0.0257,0.0461,0.0263 T0.0534,0.03 T0.0582,0.0345 T0.0645,0.0434 T0.0723,0.0546 Q0.0807,0.0653,0.0897,0.0712 T0.1081,0.0775 T0.1255,0.0765 T0.1438,0.0695 T0.1605,0.0593 T0.1772,0.0473 Q0.2388,0,0.2927,0.0326 L0.2614,0.0767 L0.2581,0.0767 Q0.2494,0.0767,0.2444,0.0773 T0.2359,0.0789 T0.2291,0.0842 T0.2233,0.0922 T0.2146,0.1054 T0.2026,0.1236 Q0.1943,0.1354,0.1843,0.1444 T0.1675,0.1574 T0.1526,0.1654 T0.1429,0.1701 Q0.1436,0.1717,0.1446,0.1733 Q0.1504,0.1823,0.1581,0.1866 T0.1733,0.1915 T0.1909,0.1884 T0.2085,0.1809 T0.2265,0.169 T0.2427,0.1564 T0.2575,0.1436 T0.2688,0.1338 Q0.2969,0.1101,0.3195,0.0995 T0.3643,0.0901 T0.4114,0.1048 Q0.4279,0.1138,0.4426,0.1168 T0.4705,0.117 T0.4945,0.1089 T0.5186,0.0942 L0.5211,0.0926 L0.5289,0.0922 Q0.5411,0.095,0.5189,0.1203 Q0.505,0.1358,0.4913,0.1474 T0.4634,0.167 T0.4389,0.1796 T0.4121,0.1909 T0.3866,0.2011 Q0.3782,0.2047,0.3727,0.2092 Q0.3717,0.2117,0.3714,0.2141 Q0.3695,0.2263,0.3751,0.2388 T0.394,0.2616 T0.4253,0.2761 Q0.4398,0.2785,0.4513,0.2779 T0.4756,0.2724 T0.4987,0.2616 T0.5216,0.2476 T0.5453,0.2321 T0.5703,0.217 T0.5976,0.2043 Q0.7015,0.166,0.8099,0.2345 Q0.8361,0.2512,0.8572,0.2616 T0.9006,0.2779 T0.9432,0.281 T0.9819,0.2663 L0.9887,0.2671 Q1,0.272,0.9768,0.2969 Q0.9558,0.3193,0.9319,0.333 T0.8858,0.3513 T0.8391,0.3569 T0.793,0.3546 T0.7485,0.3497 T0.7065,0.3473 T0.6681,0.3522 T0.6344,0.3699 Q0.5963,0.4005,0.5847,0.4082 Q0.595,0.4139,0.6079,0.4174 T0.6367,0.4237 T0.6586,0.4278 Q0.6793,0.4331,0.7044,0.4278 Q0.7057,0.4278,0.707,0.4274 Q0.7067,0.429,0.7062,0.4313 T0.7036,0.4398 T0.6993,0.4513 T0.6931,0.4619 T0.6851,0.4698 Q0.6573,0.4857,0.6336,0.4947 T0.5831,0.5053 Q0.577,0.5057,0.5615,0.5065 T0.5394,0.508 T0.5221,0.51 T0.5042,0.5139 T0.4905,0.5204 Q0.5008,0.5232,0.515,0.5328 T0.549,0.5585 T0.5799,0.5824 Q0.5905,0.5897,0.6013,0.5946 T0.6262,0.6036 T0.6409,0.6081 Q0.6567,0.6134,0.7035,0.605 T0.8028,0.5816 L0.7974,0.5922 T0.7867,0.6134 L0.7812,0.624 Q0.7799,0.6248,0.7786,0.6252 Q0.7709,0.6297,0.7573,0.6372 T0.7346,0.6499 T0.7123,0.6621 T0.6897,0.6741 T0.6686,0.6847 T0.648,0.6941 T0.6297,0.7013 T0.6129,0.7062 T0.5995,0.7076 Q0.5992,0.7076,0.5831,0.7092 T0.5529,0.7092 T0.525,0.7019 Q0.5105,0.6958,0.4824,0.6811 T0.4356,0.6586 T0.4079,0.6533 Q0.3872,0.6741,0.3827,0.6782 Q0.3872,0.6835,0.3934,0.6929 T0.4037,0.7078 T0.4142,0.7198 T0.4284,0.7304 T0.4466,0.7365 Q0.4824,0.7443,0.5292,0.728 L0.5292,0.7294 T0.529,0.7333 T0.5284,0.7392 T0.5266,0.7463 T0.5236,0.7539 T0.5186,0.7612 T0.5111,0.7679 Q0.5086,0.77,0.5056,0.7716 Q0.4466,0.8104,0.3591,0.8091 Q0.344,0.8091,0.3246,0.802 T0.2893,0.7863 T0.2543,0.77 T0.2206,0.76 T0.1894,0.7643 Q0.1804,0.7684,0.1733,0.7753 Q0.1591,0.7892,0.1601,0.8169 Q0.1784,0.8067,0.1938,0.8053 T0.2212,0.8087 T0.2507,0.825 Q0.2614,0.8324,0.2744,0.8365 T0.3053,0.844 T0.332,0.8499 L0.303,0.894 L0.2998,0.8948 Q0.2904,0.8968,0.278,0.9009 T0.2554,0.9086 T0.233,0.9158 T0.2099,0.9213 T0.1868,0.9229 T0.1633,0.9192 Q0.1517,0.916,0.1367,0.9241 T0.1065,0.9462 T0.0753,0.9737 T0.041,0.9955 T0.0061,1 Q0,0.9984,0.0068,0.9845 Q0.009,0.9804,0.0123,0.9755 Q0.0187,0.9666,0.0261,0.9606 T0.0374,0.9555 Q0.0481,0.958,0.0629,0.949 T0.0931,0.9262 T0.1247,0.8987 T0.1597,0.8777 T0.1949,0.8752 Q0.213,0.8805,0.2343,0.8772 Q0.2249,0.8736,0.2172,0.8683 Q0.1914,0.8511,0.1738,0.8497 T0.1349,0.8617 Q0.1304,0.865,0.1273,0.8646 T0.1242,0.8605 L0.1239,0.8536 Q0.1226,0.8295,0.1354,0.8016 T0.1723,0.7496 Q0.1914,0.7308,0.2104,0.7219 Q0.2259,0.7145,0.2425,0.7141 T0.273,0.7182 T0.3022,0.7296 T0.3301,0.7439 T0.3569,0.7571 T0.3821,0.7643 Q0.373,0.7561,0.3598,0.7367 T0.3382,0.7088 L0.3327,0.7035 Q0.3282,0.699,0.3353,0.6884 T0.3517,0.6692 L0.3611,0.6607 Q0.3711,0.657,0.3751,0.6554 T0.3837,0.6507 T0.3898,0.6458 T0.3979,0.637 T0.4111,0.6236 Q0.4172,0.6175,0.4234,0.6138 Q0.4327,0.6081,0.4439,0.6077 T0.4655,0.6105 T0.4884,0.6201 T0.5113,0.633 T0.5347,0.6468 T0.5573,0.6578 Q0.5705,0.6635,0.5833,0.665 T0.6112,0.665 T0.6286,0.6635 Q0.6421,0.6631,0.6718,0.6501 Q0.626,0.6578,0.6089,0.6517 Q0.6063,0.6509,0.6002,0.6491 T0.5884,0.6454 T0.5757,0.6409 T0.561,0.6344 T0.5466,0.6256 Q0.536,0.6183,0.5108,0.5989 T0.4722,0.5712 T0.4527,0.564 L0.4418,0.5661 Q0.4308,0.5681,0.4366,0.5563 Q0.4401,0.5485,0.4476,0.5392 L0.455,0.5298 Q0.4631,0.5188,0.4714,0.51 T0.4866,0.4947 T0.5021,0.4831 T0.516,0.4749 T0.53,0.4694 T0.5428,0.4657 T0.5558,0.4637 T0.5674,0.4629 T0.5795,0.4625 Q0.5489,0.4543,0.534,0.4384 L0.5286,0.4327 Q0.5244,0.4282,0.5318,0.4174 T0.5486,0.398 L0.5579,0.3899 Q0.567,0.387,0.5749,0.3834 T0.5878,0.3772 T0.6012,0.3687 T0.6126,0.3603 T0.6268,0.3487 T0.6421,0.3361 Q0.6567,0.3242,0.6712,0.3159 T0.7009,0.3034 T0.7277,0.2973 T0.7556,0.2961 T0.7809,0.2977 T0.8074,0.301 Q0.8096,0.3014,0.8109,0.3016 T0.8143,0.302 T0.818,0.3026 Q0.8012,0.2936,0.7767,0.2781 Q0.6718,0.2117,0.5744,0.2476 Q0.5637,0.2516,0.5492,0.2604 T0.5218,0.2779 T0.4923,0.2965 T0.461,0.3124 T0.4282,0.3216 T0.394,0.3206 Q0.3637,0.3136,0.3474,0.2936 T0.3353,0.2459 Q0.3385,0.2247,0.355,0.2023 Q0.3646,0.1892,0.3763,0.179 Q0.3898,0.1672,0.4063,0.1595 Q0.3927,0.1562,0.3785,0.1485 Q0.3604,0.1387,0.3453,0.1354 T0.3161,0.1354 T0.2899,0.1458 T0.2627,0.166 Q0.262,0.1664,0.254,0.1733 T0.2414,0.1841 T0.2267,0.196 T0.2094,0.2086 T0.1915,0.2196 T0.1725,0.2288 T0.1546,0.2337 T0.1373,0.2343 T0.1223,0.228 T0.1097,0.2145 Q0.0962,0.1929,0.1258,0.1582 Q0.131,0.1517,0.1371,0.1464 Q0.1462,0.1387,0.156,0.1321 T0.1752,0.1205 T0.1878,0.1134 Q0.1891,0.1117,0.1947,0.103 T0.2035,0.0899 T0.2125,0.0781 T0.2243,0.064 Q0.1949,0.0616,0.1672,0.0828 Q0.153,0.0934,0.1412,0.1009 T0.1146,0.1146 T0.0873,0.1213 T0.0616,0.116 T0.0374,0.0962 Q0.0339,0.0909,0.0295,0.0846 T0.024,0.0767 T0.0202,0.0728 T0.0148,0.0704 T0.0068,0.0697 Q0.0003,0.0693,0.0058,0.0567 Q0.0077,0.0522,0.011,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.1934,0.6075 Q0.2012,0.612,0.2188,0.6218 T0.2459,0.6369 T0.2718,0.6508 T0.2983,0.6644 T0.322,0.6758 T0.3447,0.6854 T0.363,0.6911 T0.3783,0.6936 Q0.3796,0.6936,0.396,0.6952 T0.4265,0.6952 T0.4548,0.6879 Q0.4656,0.6834,0.4805,0.6756 T0.5073,0.6614 T0.5327,0.6485 T0.5564,0.6389 T0.5759,0.6363 T0.5909,0.6422 Q0.5953,0.6467,0.604,0.6554 T0.6155,0.6669 T0.6251,0.6746 T0.6387,0.683 T0.6556,0.6903 L0.6498,0.6956 Q0.6414,0.7042,0.6319,0.7177 T0.6162,0.7403 T0.5979,0.7583 T0.5703,0.7703 Q0.5313,0.7785,0.4799,0.7605 Q0.5097,0.7817,0.5508,0.7911 T0.6302,0.8001 Q0.6431,0.7997,0.659,0.7942 T0.6888,0.7813 T0.7194,0.766 T0.7506,0.753 T0.7819,0.7472 T0.8131,0.754 Q0.8239,0.7589,0.8346,0.7681 T0.8544,0.7895 T0.8689,0.818 T0.8737,0.8507 L0.8733,0.858 Q0.8591,0.849,0.8474,0.845 T0.8242,0.8421 T0.8021,0.8482 T0.7772,0.8625 Q0.7653,0.8707,0.7513,0.8752 T0.7184,0.8831 T0.6908,0.889 Q0.7017,0.8915,0.7152,0.8956 T0.7396,0.9037 T0.7633,0.9115 T0.7872,0.9174 T0.8107,0.9194 T0.8347,0.9155 Q0.8493,0.9115,0.8671,0.9196 T0.9015,0.9421 T0.9345,0.9708 T0.9682,0.9943 T0.9997,1 Q0.999,0.94,0.9983,0.6508 T0.9976,0.2322 Q0.9976,0.2109,0.9992,0.1379 T1,0.0249 Q0.9949,0.0249,0.9917,0.0257 T0.9863,0.0273 T0.9817,0.0308 T0.9776,0.0357 T0.9721,0.0437 T0.9651,0.0539 Q0.956,0.0657,0.9456,0.072 T0.9247,0.0789 T0.904,0.0775 T0.8823,0.0694 T0.862,0.0573 T0.8422,0.0432 Q0.7856,0,0.7328,0.0318 Q0.7392,0.0318,0.7452,0.0324 T0.756,0.0345 T0.7657,0.0386 T0.7741,0.0437 T0.7821,0.0506 T0.7894,0.0588 T0.7966,0.0683 T0.8039,0.0787 T0.8119,0.0904 T0.8202,0.1028 Q0.8249,0.1093,0.849,0.1234 T0.8811,0.1448 Q0.8998,0.1612,0.8893,0.1783 Q0.8835,0.1877,0.8759,0.1928 T0.8593,0.1979 T0.8417,0.1967 T0.8222,0.1895 T0.8034,0.1791 T0.7848,0.1663 T0.7687,0.1534 T0.7543,0.141 T0.744,0.1322 Q0.7186,0.1106,0.6984,0.101 T0.6559,0.0926 T0.6082,0.1077 Q0.5899,0.1175,0.5733,0.1206 T0.5411,0.1202 T0.5122,0.1098 T0.4822,0.0914 Q0.4927,0.1032,0.5036,0.1122 T0.5276,0.1285 T0.5503,0.1401 T0.5777,0.1518 T0.6055,0.1636 Q0.6258,0.1726,0.6375,0.1863 T0.6519,0.2162 Q0.6556,0.2403,0.6392,0.2605 T0.5926,0.2876 Q0.5804,0.2909,0.5672,0.2899 T0.5428,0.2856 T0.5193,0.2764 T0.4966,0.264 T0.4744,0.2497 T0.4523,0.2352 T0.4301,0.2222 T0.4077,0.2118 Q0.3021,0.173,0.1903,0.2436 Q0.1669,0.2583,0.1504,0.2674 T0.1129,0.2846 T0.075,0.294 T0.0384,0.2911 T0,0.2746 Q0.021,0.297,0.0459,0.3082 T0.0953,0.3207 T0.146,0.3193 T0.1988,0.3131 T0.2508,0.3095 T0.3029,0.3176 T0.3529,0.3448 Q0.3566,0.348,0.3652,0.355 T0.3771,0.3645 T0.3877,0.3731 T0.3993,0.3815 T0.4103,0.3884 T0.4226,0.3953 T0.4352,0.4009 T0.4497,0.4064 L0.4443,0.4121 Q0.4372,0.4198,0.4277,0.4251 T0.4072,0.4337 T0.3867,0.439 T0.3656,0.4431 T0.3481,0.4468 Q0.3241,0.4529,0.2943,0.4463 Q0.3227,0.4623,0.3458,0.471 T0.3959,0.4814 Q0.404,0.4818,0.4187,0.4825 T0.4409,0.4835 T0.4605,0.4857 T0.4809,0.4908 T0.4992,0.4996 T0.5186,0.5141 T0.5371,0.5353 L0.5449,0.5451 L0.5337,0.543 Q0.5242,0.541,0.5091,0.55 T0.4683,0.5796 T0.4314,0.6083 Q0.4203,0.6161,0.4086,0.6212 T0.382,0.6308 T0.3667,0.6353 Q0.3485,0.6418,0.2995,0.633 T0.1934,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.989,0.0469 Q0.9829,0.0379,0.9753,0.0316 T0.9635,0.0253 Q0.9574,0.0257,0.9539,0.0263 T0.9466,0.03 T0.9418,0.0345 T0.9355,0.0434 T0.9277,0.0546 Q0.9193,0.0653,0.9103,0.0712 T0.8919,0.0775 T0.8745,0.0765 T0.8564,0.0695 T0.8396,0.0593 T0.8228,0.0473 Q0.7612,0,0.7073,0.0326 L0.7386,0.0767 L0.7419,0.0767 Q0.7506,0.0767,0.7556,0.0773 T0.7641,0.0789 T0.7709,0.0842 T0.7767,0.0922 T0.7854,0.1054 T0.7974,0.1236 Q0.8057,0.1354,0.8157,0.1444 T0.8325,0.1574 T0.8474,0.1654 T0.8571,0.1701 Q0.8564,0.1717,0.8554,0.1733 Q0.8503,0.1815,0.844,0.186 T0.8301,0.1909 T0.8153,0.1903 T0.7993,0.1845 T0.7836,0.1758 T0.768,0.1648 T0.754,0.1535 T0.741,0.1425 T0.7312,0.1338 Q0.7031,0.1101,0.6805,0.0995 T0.6357,0.0901 T0.5886,0.1048 Q0.5721,0.1138,0.5574,0.1168 T0.5295,0.117 T0.5055,0.1089 T0.4814,0.0942 L0.4789,0.0926 L0.4711,0.0922 Q0.4589,0.095,0.4811,0.1203 Q0.495,0.1358,0.5087,0.1474 T0.5366,0.167 T0.5611,0.1796 T0.5879,0.1909 T0.6134,0.2011 Q0.6218,0.2047,0.6273,0.2092 Q0.6283,0.2117,0.6286,0.2141 Q0.6305,0.2263,0.6249,0.2388 T0.606,0.2616 T0.5747,0.2761 Q0.5602,0.2785,0.5487,0.2779 T0.5245,0.2724 T0.5015,0.2616 T0.4784,0.2476 T0.4547,0.2321 T0.4297,0.217 T0.4024,0.2043 Q0.2985,0.166,0.1901,0.2345 Q0.1694,0.248,0.1523,0.2569 T0.1165,0.2726 T0.0818,0.2812 T0.0494,0.2796 T0.0181,0.2663 L0.0116,0.2671 Q0,0.272,0.0232,0.2969 Q0.0468,0.3222,0.0742,0.3365 T0.1278,0.3542 T0.1807,0.3564 T0.233,0.352 T0.2815,0.3473 T0.3269,0.3509 T0.3656,0.3699 Q0.4037,0.4005,0.4153,0.4082 Q0.405,0.4139,0.3921,0.4174 T0.3633,0.4237 T0.3414,0.4278 Q0.3207,0.4331,0.2956,0.4278 Q0.2943,0.4278,0.293,0.4274 Q0.2933,0.429,0.2938,0.4313 T0.2964,0.4398 T0.3007,0.4513 T0.3069,0.4619 T0.3149,0.4698 Q0.3427,0.4857,0.3664,0.4947 T0.4169,0.5053 Q0.423,0.5057,0.4385,0.5065 T0.4606,0.508 T0.4779,0.51 T0.4958,0.5139 T0.5095,0.5204 Q0.4992,0.5232,0.485,0.5328 T0.451,0.5585 T0.4201,0.5824 Q0.4095,0.5897,0.3987,0.5946 T0.3738,0.6036 T0.3591,0.6081 Q0.3433,0.6134,0.2965,0.605 T0.1972,0.5816 L0.2026,0.5922 T0.2133,0.6134 L0.2188,0.624 Q0.2201,0.6248,0.2214,0.6252 Q0.2291,0.6297,0.2486,0.6405 T0.2786,0.657 T0.3066,0.6721 T0.3353,0.6866 T0.3598,0.6972 T0.383,0.7051 T0.4005,0.7076 Q0.4008,0.7076,0.4169,0.7092 T0.4471,0.7092 T0.475,0.7019 Q0.4895,0.6958,0.5176,0.6811 T0.5644,0.6586 T0.5921,0.6533 Q0.6128,0.6741,0.6173,0.6782 Q0.6131,0.6835,0.6068,0.6929 T0.5963,0.7078 T0.5858,0.7198 T0.5716,0.7304 T0.5534,0.7365 Q0.5179,0.7443,0.4708,0.728 L0.4708,0.7294 T0.471,0.7333 T0.4716,0.7392 T0.4734,0.7463 T0.4764,0.7539 T0.4814,0.7612 T0.4889,0.7679 Q0.4914,0.77,0.4944,0.7716 Q0.5534,0.8104,0.6409,0.8091 Q0.6521,0.8091,0.6654,0.8053 T0.6907,0.7959 T0.7157,0.7838 T0.741,0.772 T0.7652,0.7631 T0.7888,0.7594 T0.8106,0.7643 Q0.8196,0.7684,0.8267,0.7753 Q0.8409,0.7892,0.8399,0.8169 Q0.8216,0.8067,0.8062,0.8053 T0.7788,0.8087 T0.7493,0.825 Q0.7386,0.8324,0.7256,0.8365 T0.6947,0.844 T0.668,0.8499 L0.697,0.894 L0.7002,0.8948 Q0.7099,0.8968,0.7222,0.9009 T0.7446,0.9086 T0.767,0.9158 T0.7901,0.9213 T0.8132,0.9229 T0.8367,0.9192 Q0.8483,0.916,0.8633,0.9241 T0.8937,0.9462 T0.9248,0.9737 T0.959,0.9955 T0.9939,1 Q1,0.9984,0.9932,0.9845 Q0.991,0.9804,0.9877,0.9755 Q0.9813,0.9666,0.9739,0.9606 T0.9626,0.9555 Q0.9519,0.958,0.9372,0.949 T0.9071,0.9262 T0.8753,0.8987 T0.8403,0.8777 T0.8051,0.8752 Q0.787,0.8805,0.7657,0.8772 Q0.7751,0.8736,0.7828,0.8683 Q0.8086,0.8511,0.8262,0.8497 T0.8651,0.8617 Q0.8696,0.865,0.8727,0.8646 T0.8758,0.8605 L0.8761,0.8536 Q0.8774,0.8295,0.8646,0.8016 T0.8277,0.7496 Q0.8086,0.7308,0.7896,0.7219 Q0.7741,0.7145,0.7575,0.7141 T0.727,0.7182 T0.6978,0.7296 T0.6699,0.7439 T0.6433,0.7571 T0.6179,0.7643 Q0.627,0.7561,0.6402,0.7367 T0.6618,0.7088 L0.6673,0.7035 Q0.6718,0.699,0.6647,0.6884 T0.6483,0.6692 L0.6389,0.6607 Q0.6289,0.657,0.6249,0.6554 T0.6163,0.6507 T0.6102,0.6458 T0.6021,0.637 T0.5889,0.6236 Q0.5828,0.6175,0.5766,0.6138 Q0.5673,0.6081,0.5561,0.6077 T0.5345,0.6105 T0.5116,0.6201 T0.4887,0.633 T0.4653,0.6468 T0.4427,0.6578 Q0.4295,0.6635,0.4167,0.665 T0.3888,0.665 T0.3714,0.6635 Q0.3579,0.6631,0.3282,0.6501 Q0.374,0.6578,0.3911,0.6517 Q0.3937,0.6509,0.4024,0.6482 T0.4179,0.6434 T0.4348,0.6364 T0.4534,0.6256 Q0.464,0.6183,0.4892,0.5989 T0.5278,0.5712 T0.5476,0.564 L0.5582,0.5661 Q0.5692,0.5681,0.5634,0.5563 Q0.5599,0.5485,0.5524,0.5392 L0.545,0.5298 Q0.5369,0.5188,0.5286,0.51 T0.5134,0.4947 T0.4979,0.4831 T0.484,0.4749 T0.47,0.4694 T0.4572,0.4657 T0.4442,0.4637 T0.4326,0.4629 T0.4205,0.4625 Q0.4511,0.4543,0.466,0.4384 L0.4714,0.4327 Q0.4795,0.4237,0.4469,0.394 L0.4421,0.3899 Q0.433,0.387,0.4251,0.3834 T0.4122,0.3772 T0.3988,0.3687 T0.3874,0.3603 T0.3732,0.3487 T0.3579,0.3361 Q0.3433,0.3242,0.3288,0.3159 T0.2993,0.3034 T0.2725,0.2973 T0.2446,0.2961 T0.2193,0.2977 T0.1926,0.301 Q0.1855,0.3022,0.182,0.3026 Q0.1991,0.2936,0.2233,0.2781 Q0.3282,0.2117,0.4256,0.2476 Q0.4363,0.2516,0.451,0.2604 T0.4784,0.2779 T0.5077,0.2965 T0.539,0.3124 T0.5718,0.3216 T0.606,0.3206 Q0.6363,0.3136,0.6526,0.2936 T0.6647,0.2459 Q0.6615,0.2247,0.645,0.2023 Q0.6354,0.1892,0.6237,0.179 Q0.6102,0.1672,0.5937,0.1595 Q0.6073,0.1562,0.6215,0.1485 Q0.6396,0.1387,0.6547,0.1354 T0.6839,0.1354 T0.7101,0.1458 T0.7373,0.166 Q0.738,0.1664,0.746,0.1733 T0.7586,0.1841 T0.7733,0.196 T0.7907,0.2086 T0.8086,0.2196 T0.8275,0.2288 T0.8454,0.2337 T0.8627,0.2343 T0.8777,0.228 T0.8903,0.2145 Q0.9038,0.1929,0.8742,0.1582 Q0.869,0.1517,0.8629,0.1464 Q0.8538,0.1387,0.844,0.1321 T0.8248,0.1205 T0.8122,0.1134 Q0.8109,0.1117,0.8053,0.103 T0.7965,0.0899 T0.7875,0.0781 T0.7757,0.064 Q0.8051,0.0616,0.8328,0.0828 Q0.847,0.0934,0.8588,0.1009 T0.8854,0.1146 T0.9127,0.1213 T0.9384,0.116 T0.9626,0.0962 Q0.9664,0.0909,0.9706,0.0846 T0.976,0.0767 T0.9798,0.0728 T0.9852,0.0704 T0.9932,0.0697 Q0.9997,0.0693,0.9942,0.0567 Q0.9923,0.0522,0.989,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0.9099,0.1158 L0.9099,0.1888 L0.9951,0.1888 L0.9951,0.1158 L0.9099,0.1158 Z M0.9075,0.1116 L0.9976,0.1116 Q1,0.1116,1,0.1137 L1,0.1909 Q1,0.193,0.9976,0.193 L0.9075,0.193 Q0.905,0.193,0.905,0.1909 L0.905,0.1137 Q0.905,0.1116,0.9075,0.1116 Z M0.7852,0.6086 L0.7852,0.682 L0.8704,0.682 L0.8704,0.6086 L0.7852,0.6086 Z M0.7828,0.6044 L0.8729,0.6044 Q0.8753,0.6044,0.8753,0.6065 L0.8753,0.6841 Q0.8753,0.6862,0.8729,0.6862 L0.7828,0.6862 Q0.7803,0.6862,0.7803,0.6841 L0.7803,0.6065 Q0.7803,0.6044,0.7828,0.6044 Z M0.66,0.1137 L0.7501,0.1137 L0.7501,0.1909 L0.66,0.1909 L0.66,0.1137 Z M0.6624,0.4102 L0.6624,0.4836 L0.7477,0.4836 L0.7477,0.4102 L0.6624,0.4102 Z M0.66,0.406 L0.7501,0.406 Q0.7526,0.406,0.7526,0.4081 L0.7526,0.4857 Q0.7526,0.4878,0.7501,0.4878 L0.66,0.4878 Q0.6576,0.4878,0.6576,0.4857 L0.6576,0.4081 Q0.6576,0.406,0.66,0.406 Z M0.6624,0.7131 L0.6624,0.7865 L0.7477,0.7865 L0.7477,0.7131 L0.6624,0.7131 Z M0.66,0.7089 L0.7501,0.7089 Q0.7526,0.7089,0.7526,0.711 L0.7526,0.7886 Q0.7526,0.7907,0.7501,0.7907 L0.66,0.7907 Q0.6576,0.7907,0.6576,0.7886 L0.6576,0.711 Q0.6576,0.7089,0.66,0.7089 Z M0.5407,0.2227 L0.5407,0.2836 L0.6113,0.2836 L0.6113,0.2227 L0.5407,0.2227 Z M0.5309,0.206 L0.621,0.206 Q0.623,0.206,0.6249,0.2068 T0.6281,0.2089 T0.6301,0.2116 T0.6308,0.2143 L0.6308,0.2919 Q0.6308,0.2957,0.6276,0.298 T0.621,0.3003 L0.5309,0.3003 Q0.5265,0.3003,0.5239,0.2976 T0.5212,0.2919 L0.5212,0.2143 Q0.5212,0.211,0.5244,0.2085 T0.5309,0.206 Z M0.5407,0.3184 L0.5407,0.3792 L0.6113,0.3792 L0.6113,0.3184 L0.5407,0.3184 Z M0.5309,0.3016 L0.621,0.3016 Q0.6254,0.3016,0.6281,0.3043 T0.6308,0.31 L0.6308,0.3876 Q0.6308,0.3914,0.6276,0.3937 T0.621,0.396 L0.5309,0.396 Q0.5265,0.396,0.5239,0.3932 T0.5212,0.3876 L0.5212,0.31 Q0.5212,0.3062,0.5244,0.3039 T0.5309,0.3016 Z M0.5309,0.4081 L0.621,0.4081 L0.621,0.4857 L0.5309,0.4857 L0.5309,0.4081 Z M0.5309,0.5059 L0.621,0.5059 L0.621,0.5835 L0.5309,0.5835 L0.5309,0.5059 Z M0.5407,0.6149 L0.5407,0.6758 L0.6113,0.6758 L0.6113,0.6149 L0.5407,0.6149 Z M0.5309,0.5982 L0.621,0.5982 Q0.6254,0.5982,0.6281,0.6009 T0.6308,0.6065 L0.6308,0.6841 Q0.6308,0.6879,0.6276,0.6902 T0.621,0.6925 L0.5309,0.6925 Q0.5265,0.6925,0.5239,0.6898 T0.5212,0.6841 L0.5212,0.6065 Q0.5212,0.6028,0.5244,0.6005 T0.5309,0.5982 Z M0.4062,0.1137 L0.4963,0.1137 L0.4963,0.1909 L0.4062,0.1909 L0.4062,0.1137 Z M0.4062,0.2143 L0.4963,0.2143 L0.4963,0.2919 L0.4062,0.2919 L0.4062,0.2143 Z M0.4184,0.4186 L0.4184,0.4753 L0.4842,0.4753 L0.4842,0.4186 L0.4184,0.4186 Z M0.4062,0.3977 L0.4963,0.3977 Q0.5017,0.3977,0.5051,0.401 T0.5085,0.4081 L0.5085,0.4857 Q0.5085,0.4904,0.5046,0.4933 T0.4963,0.4962 L0.4062,0.4962 Q0.4009,0.4962,0.3975,0.4929 T0.3941,0.4857 L0.3941,0.4081 Q0.3941,0.4035,0.398,0.4006 T0.4062,0.3977 Z M0.4062,0.5059 L0.4963,0.5059 L0.4963,0.5835 L0.4062,0.5835 L0.4062,0.5059 Z M0.4087,0.7131 L0.4087,0.7865 L0.4939,0.7865 L0.4939,0.7131 L0.4087,0.7131 Z M0.4062,0.7089 L0.4963,0.7089 Q0.4988,0.7089,0.4988,0.711 L0.4988,0.7886 Q0.4988,0.7907,0.4963,0.7907 L0.4062,0.7907 Q0.4038,0.7907,0.4038,0.7886 L0.4038,0.711 Q0.4038,0.7089,0.4062,0.7089 Z M0.2689,0.1137 L0.359,0.1137 L0.359,0.1909 L0.2689,0.1909 L0.2689,0.1137 Z M0.2689,0.2143 L0.359,0.2143 L0.359,0.2919 L0.2689,0.2919 L0.2689,0.2143 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.31 L0.359,0.31 L0.359,0.3876 L0.2689,0.3876 L0.2689,0.31 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.4081 L0.359,0.4081 L0.359,0.4857 L0.2689,0.4857 L0.2689,0.4081 Z M0.2689,0.5059 L0.359,0.5059 L0.359,0.5835 L0.2689,0.5835 L0.2689,0.5059 Z M0.2689,0.711 L0.359,0.711 L0.359,0.7886 L0.2689,0.7886 L0.2689,0.711 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.1374,0.1137 L0.2275,0.1137 L0.2275,0.1909 L0.1374,0.1909 L0.1374,0.1137 Z M0.1374,0.2143 L0.2275,0.2143 L0.2275,0.2919 L0.1374,0.2919 L0.1374,0.2143 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.31 L0.2275,0.31 L0.2275,0.3876 L0.1374,0.3876 L0.1374,0.31 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.4081 L0.2275,0.4081 L0.2275,0.4857 L0.1374,0.4857 L0.1374,0.4081 Z M0.1374,0.5059 L0.2275,0.5059 L0.2275,0.5835 L0.1374,0.5835 L0.1374,0.5059 Z M0.1374,0.6065 L0.2275,0.6065 L0.2275,0.6841 L0.1374,0.6841 L0.1374,0.6065 Z M0.1374,0.711 L0.2275,0.711 L0.2275,0.7886 L0.1374,0.7886 L0.1374,0.711 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0,0.1137 L0.0901,0.1137 L0.0901,0.1909 L0,0.1909 L0,0.1137 Z M0,0.2143 L0.0901,0.2143 L0.0901,0.2919 L0,0.2919 L0,0.2143 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.31 L0.0901,0.31 L0.0901,0.3876 L0,0.3876 L0,0.31 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.4081 L0.0901,0.4081 L0.0901,0.4857 L0,0.4857 L0,0.4081 Z M0,0.5059 L0.0901,0.5059 L0.0901,0.5835 L0,0.5835 L0,0.5059 Z M0,0.6065 L0.0901,0.6065 L0.0901,0.6841 L0,0.6841 L0,0.6065 Z M0,0.711 L0.0901,0.711 L0.0901,0.7886 L0,0.7886 L0,0.711 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M0.0901,0.1158 L0.0901,0.1888 L0.0049,0.1888 L0.0049,0.1158 L0.0901,0.1158 Z M0.0925,0.1116 L0.0024,0.1116 Q0,0.1116,0,0.1137 L0,0.1909 Q0,0.193,0.0024,0.193 L0.0925,0.193 Q0.095,0.193,0.095,0.1909 L0.095,0.1137 Q0.095,0.1116,0.0925,0.1116 Z M0.2148,0.6086 L0.2148,0.682 L0.1296,0.682 L0.1296,0.6086 L0.2148,0.6086 Z M0.2172,0.6044 L0.1271,0.6044 Q0.1247,0.6044,0.1247,0.6065 L0.1247,0.6841 Q0.1247,0.6862,0.1271,0.6862 L0.2172,0.6862 Q0.2197,0.6862,0.2197,0.6841 L0.2197,0.6065 Q0.2197,0.6044,0.2172,0.6044 Z M0.34,0.1137 L0.2499,0.1137 L0.2499,0.1909 L0.34,0.1909 L0.34,0.1137 Z M0.3376,0.4102 L0.3376,0.4836 L0.2523,0.4836 L0.2523,0.4102 L0.3376,0.4102 Z M0.34,0.406 L0.2499,0.406 Q0.2474,0.406,0.2474,0.4081 L0.2474,0.4857 Q0.2474,0.4878,0.2499,0.4878 L0.34,0.4878 Q0.3424,0.4878,0.3424,0.4857 L0.3424,0.4081 Q0.3424,0.406,0.34,0.406 Z M0.3376,0.7131 L0.3376,0.7865 L0.2523,0.7865 L0.2523,0.7131 L0.3376,0.7131 Z M0.34,0.7089 L0.2499,0.7089 Q0.2474,0.7089,0.2474,0.711 L0.2474,0.7886 Q0.2474,0.7907,0.2499,0.7907 L0.34,0.7907 Q0.3424,0.7907,0.3424,0.7886 L0.3424,0.711 Q0.3424,0.7089,0.34,0.7089 Z M0.4593,0.2227 L0.4593,0.2836 L0.3887,0.2836 L0.3887,0.2227 L0.4593,0.2227 Z M0.4691,0.206 L0.379,0.206 Q0.3746,0.206,0.3719,0.2087 T0.3692,0.2143 L0.3692,0.2919 Q0.3692,0.2957,0.3724,0.298 T0.379,0.3003 L0.4691,0.3003 Q0.4735,0.3003,0.4761,0.2976 T0.4788,0.2919 L0.4788,0.2143 Q0.4788,0.211,0.4756,0.2085 T0.4691,0.206 Z M0.4593,0.3184 L0.4593,0.3792 L0.3887,0.3792 L0.3887,0.3184 L0.4593,0.3184 Z M0.4691,0.3016 L0.379,0.3016 Q0.3746,0.3016,0.3719,0.3043 T0.3692,0.31 L0.3692,0.3876 Q0.3692,0.3914,0.3724,0.3937 T0.379,0.396 L0.4691,0.396 Q0.4735,0.396,0.4761,0.3932 T0.4788,0.3876 L0.4788,0.31 Q0.4788,0.3062,0.4756,0.3039 T0.4691,0.3016 Z M0.4691,0.4081 L0.379,0.4081 L0.379,0.4857 L0.4691,0.4857 L0.4691,0.4081 Z M0.4691,0.5059 L0.379,0.5059 L0.379,0.5835 L0.4691,0.5835 L0.4691,0.5059 Z M0.4593,0.6149 L0.4593,0.6758 L0.3887,0.6758 L0.3887,0.6149 L0.4593,0.6149 Z M0.4691,0.5982 L0.379,0.5982 Q0.3746,0.5982,0.3719,0.6009 T0.3692,0.6065 L0.3692,0.6841 Q0.3692,0.6879,0.3724,0.6902 T0.379,0.6925 L0.4691,0.6925 Q0.4735,0.6925,0.4761,0.6898 T0.4788,0.6841 L0.4788,0.6065 Q0.4788,0.6028,0.4756,0.6005 T0.4691,0.5982 Z M0.5938,0.1137 L0.5037,0.1137 L0.5037,0.1909 L0.5938,0.1909 L0.5938,0.1137 Z M0.5938,0.2143 L0.5037,0.2143 L0.5037,0.2919 L0.5938,0.2919 L0.5938,0.2143 Z M0.5816,0.4186 L0.5816,0.4753 L0.5158,0.4753 L0.5158,0.4186 L0.5816,0.4186 Z M0.5938,0.3977 L0.5037,0.3977 Q0.4983,0.3977,0.4949,0.401 T0.4915,0.4081 L0.4915,0.4857 Q0.4915,0.4904,0.4954,0.4933 T0.5037,0.4962 L0.5938,0.4962 Q0.5991,0.4962,0.6025,0.4929 T0.6059,0.4857 L0.6059,0.4081 Q0.6059,0.4035,0.602,0.4006 T0.5938,0.3977 Z M0.5938,0.5059 L0.5037,0.5059 L0.5037,0.5835 L0.5938,0.5835 L0.5938,0.5059 Z M0.5913,0.7131 L0.5913,0.7865 L0.5061,0.7865 L0.5061,0.7131 L0.5913,0.7131 Z M0.5938,0.7089 L0.5037,0.7089 Q0.5012,0.7089,0.5012,0.711 L0.5012,0.7886 Q0.5012,0.7907,0.5037,0.7907 L0.5938,0.7907 Q0.5962,0.7907,0.5962,0.7886 L0.5962,0.711 Q0.5962,0.7089,0.5938,0.7089 Z M0.7311,0.1137 L0.641,0.1137 L0.641,0.1909 L0.7311,0.1909 L0.7311,0.1137 Z M0.7311,0.2143 L0.641,0.2143 L0.641,0.2919 L0.7311,0.2919 L0.7311,0.2143 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.31 L0.641,0.31 L0.641,0.3876 L0.7311,0.3876 L0.7311,0.31 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.4081 L0.641,0.4081 L0.641,0.4857 L0.7311,0.4857 L0.7311,0.4081 Z M0.7311,0.5059 L0.641,0.5059 L0.641,0.5835 L0.7311,0.5835 L0.7311,0.5059 Z M0.7311,0.711 L0.641,0.711 L0.641,0.7886 L0.7311,0.7886 L0.7311,0.711 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.8626,0.1137 L0.7725,0.1137 L0.7725,0.1909 L0.8626,0.1909 L0.8626,0.1137 Z M0.8626,0.2143 L0.7725,0.2143 L0.7725,0.2919 L0.8626,0.2919 L0.8626,0.2143 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.31 L0.7725,0.31 L0.7725,0.3876 L0.8626,0.3876 L0.8626,0.31 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.4081 L0.7725,0.4081 L0.7725,0.4857 L0.8626,0.4857 L0.8626,0.4081 Z M0.8626,0.5059 L0.7725,0.5059 L0.7725,0.5835 L0.8626,0.5835 L0.8626,0.5059 Z M0.8626,0.6065 L0.7725,0.6065 L0.7725,0.6841 L0.8626,0.6841 L0.8626,0.6065 Z M0.8626,0.711 L0.7725,0.711 L0.7725,0.7886 L0.8626,0.7886 L0.8626,0.711 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M1,0.1137 L0.9099,0.1137 L0.9099,0.1909 L1,0.1909 L1,0.1137 Z M1,0.2143 L0.9099,0.2143 L0.9099,0.2919 L1,0.2919 L1,0.2143 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.31 L0.9099,0.31 L0.9099,0.3876 L1,0.3876 L1,0.31 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.4081 L0.9099,0.4081 L0.9099,0.4857 L1,0.4857 L1,0.4081 Z M1,0.5059 L0.9099,0.5059 L0.9099,0.5835 L1,0.5835 L1,0.5059 Z M1,0.6065 L0.9099,0.6065 L0.9099,0.6841 L1,0.6841 L1,0.6065 Z M1,0.711 L0.9099,0.711 L0.9099,0.7886 L1,0.7886 L1,0.711 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0.8574,0.3217 L0.8574,0.4098 L0.9691,0.4098 L0.9691,0.3217 L0.8574,0.3217 Z M0.8419,0.2978 L0.9846,0.2978 Q0.9892,0.2978,0.9928,0.2997 T0.9982,0.3043 T1,0.31 L1,0.4216 Q1,0.427,0.9951,0.4304 T0.9846,0.4337 L0.8419,0.4337 Q0.8352,0.4337,0.8308,0.4299 T0.8265,0.4216 L0.8265,0.31 Q0.8265,0.3062,0.829,0.3035 T0.835,0.2993 T0.8419,0.2978 Z M0.8574,0.888 L0.8574,0.9757 L0.9691,0.9757 L0.9691,0.888 L0.8574,0.888 Z M0.8419,0.8637 L0.9846,0.8637 Q0.9892,0.8637,0.9928,0.8658 T0.9982,0.8706 T1,0.8758 L1,0.9878 Q1,0.9929,0.9951,0.9964 T0.9846,1 L0.8419,1 Q0.8352,1,0.8308,0.996 T0.8265,0.9878 L0.8265,0.8758 Q0.8265,0.8708,0.8314,0.8672 T0.8419,0.8637 Z M0.6509,0.169 L0.6509,0.2706 L0.7806,0.2706 L0.7806,0.169 L0.6509,0.169 Z M0.6442,0.159 L0.7868,0.159 Q0.7899,0.159,0.7917,0.1604 T0.7935,0.164 L0.7935,0.2756 Q0.7935,0.2781,0.7915,0.2796 T0.7868,0.281 L0.6442,0.281 Q0.6416,0.281,0.6395,0.2794 T0.6375,0.2756 L0.6375,0.164 Q0.6375,0.1619,0.6398,0.1604 T0.6442,0.159 Z M0.6632,0.6044 L0.6632,0.6858 L0.7678,0.6858 L0.7678,0.6044 L0.6632,0.6044 Z M0.6442,0.5742 L0.7868,0.5742 Q0.7951,0.5742,0.8007,0.5791 T0.8064,0.5893 L0.8064,0.7013 Q0.8064,0.7076,0.8002,0.712 T0.7868,0.7164 L0.6442,0.7164 Q0.6359,0.7164,0.6305,0.7114 T0.6251,0.7013 L0.6251,0.5893 Q0.6251,0.5847,0.6282,0.5812 T0.6357,0.5759 T0.6442,0.5742 Z M0.4264,0.164 L0.5695,0.164 L0.5695,0.2756 L0.4264,0.2756 L0.4264,0.164 Z M0.4325,0.315 L0.4325,0.4165 L0.5628,0.4165 L0.5628,0.315 L0.4325,0.315 Z M0.4264,0.3049 L0.5695,0.3049 Q0.5721,0.3049,0.5739,0.3064 T0.5757,0.31 L0.5757,0.4216 Q0.5757,0.4237,0.5736,0.4251 T0.5695,0.4266 L0.4264,0.4266 Q0.4238,0.4266,0.422,0.4251 T0.4202,0.4216 L0.4202,0.31 Q0.4202,0.3087,0.4207,0.3077 T0.4222,0.306 T0.4243,0.3052 T0.4264,0.3049 Z M0.4264,0.4476 L0.5695,0.4476 L0.5695,0.5596 L0.4264,0.5596 L0.4264,0.4476 Z M0.4392,0.7408 L0.4392,0.8326 L0.5561,0.8326 L0.5561,0.7408 L0.4392,0.7408 Z M0.4264,0.7206 L0.5695,0.7206 Q0.5747,0.7206,0.5783,0.724 T0.5819,0.7307 L0.5819,0.8427 Q0.5819,0.8469,0.5778,0.8498 T0.5695,0.8528 L0.4264,0.8528 Q0.4207,0.8528,0.4171,0.8496 T0.4135,0.8427 L0.4135,0.7307 Q0.4135,0.7265,0.4176,0.7236 T0.4264,0.7206 Z M0.2178,0.164 L0.3605,0.164 L0.3605,0.2756 L0.2178,0.2756 L0.2178,0.164 Z M0.2178,0.31 L0.3605,0.31 L0.3605,0.4216 L0.2178,0.4216 L0.2178,0.31 Z M0.2178,0.5893 L0.3605,0.5893 L0.3605,0.7013 L0.2178,0.7013 L0.2178,0.5893 Z M0.2178,0.7307 L0.3605,0.7307 L0.3605,0.8427 L0.2178,0.8427 L0.2178,0.7307 Z M0.2178,0.8758 L0.3605,0.8758 L0.3605,0.9878 L0.2178,0.9878 L0.2178,0.8758 Z M0,0.164 L0.1432,0.164 L0.1432,0.2756 L0,0.2756 L0,0.164 Z M0,0.31 L0.1432,0.31 L0.1432,0.4216 L0,0.4216 L0,0.31 Z M0,0.4476 L0.1432,0.4476 L0.1432,0.5596 L0,0.5596 L0,0.4476 Z M0,0.5893 L0.1432,0.5893 L0.1432,0.7013 L0,0.7013 L0,0.5893 Z M0,0.7307 L0.1432,0.7307 L0.1432,0.8427 L0,0.8427 L0,0.7307 Z M0,0.8758 L0.1432,0.8758 L0.1432,0.9878 L0,0.9878 L0,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M0.1432,0.3217 L0.1432,0.4098 L0.0309,0.4098 L0.0309,0.3217 L0.1432,0.3217 Z M0.1586,0.2978 L0.0154,0.2978 Q0.0088,0.2978,0.0044,0.3016 T0,0.31 L0,0.4216 Q0,0.427,0.0049,0.4304 T0.0154,0.4337 L0.1586,0.4337 Q0.1648,0.4337,0.1694,0.4299 T0.174,0.4216 L0.174,0.31 Q0.174,0.3062,0.1715,0.3035 T0.1653,0.2993 T0.1586,0.2978 Z M0.1432,0.888 L0.1432,0.9757 L0.0309,0.9757 L0.0309,0.888 L0.1432,0.888 Z M0.1586,0.8637 L0.0154,0.8637 Q0.0108,0.8637,0.0072,0.8658 T0.0018,0.8706 T0,0.8758 L0,0.9878 Q0,0.9929,0.0049,0.9964 T0.0154,1 L0.1586,1 Q0.1648,1,0.1694,0.996 T0.174,0.9878 L0.174,0.8758 Q0.174,0.8725,0.1715,0.8695 T0.1653,0.8651 T0.1586,0.8637 Z M0.3496,0.169 L0.3496,0.2706 L0.2194,0.2706 L0.2194,0.169 L0.3496,0.169 Z M0.3563,0.159 L0.2132,0.159 Q0.2106,0.159,0.2088,0.1604 T0.207,0.164 L0.207,0.2756 Q0.207,0.2781,0.2091,0.2796 T0.2132,0.281 L0.3563,0.281 Q0.3589,0.281,0.3607,0.2794 T0.3625,0.2756 L0.3625,0.164 Q0.3625,0.1619,0.3605,0.1604 T0.3563,0.159 Z M0.3368,0.6044 L0.3368,0.6858 L0.2327,0.6858 L0.2327,0.6044 L0.3368,0.6044 Z M0.3563,0.5742 L0.2132,0.5742 Q0.2049,0.5742,0.1993,0.5791 T0.1936,0.5893 L0.1936,0.7013 Q0.1936,0.7076,0.2001,0.712 T0.2132,0.7164 L0.3563,0.7164 Q0.3641,0.7164,0.3697,0.7114 T0.3754,0.7013 L0.3754,0.5893 Q0.3754,0.5847,0.3723,0.5812 T0.3648,0.5759 T0.3563,0.5742 Z M0.5736,0.164 L0.431,0.164 L0.431,0.2756 L0.5736,0.2756 L0.5736,0.164 Z M0.5675,0.315 L0.5675,0.4165 L0.4377,0.4165 L0.4377,0.315 L0.5675,0.315 Z M0.5736,0.3049 L0.431,0.3049 Q0.4284,0.3049,0.4264,0.3064 T0.4243,0.31 L0.4243,0.4216 Q0.4243,0.4237,0.4266,0.4251 T0.431,0.4266 L0.5736,0.4266 Q0.5767,0.4266,0.5785,0.4251 T0.5803,0.4216 L0.5803,0.31 Q0.5803,0.3087,0.5798,0.3077 T0.5783,0.306 T0.5762,0.3052 T0.5736,0.3049 Z M0.5736,0.4476 L0.431,0.4476 L0.431,0.5596 L0.5736,0.5596 L0.5736,0.4476 Z M0.5613,0.7408 L0.5613,0.8326 L0.4439,0.8326 L0.4439,0.7408 L0.5613,0.7408 Z M0.5736,0.7206 L0.431,0.7206 Q0.4253,0.7206,0.4217,0.724 T0.4181,0.7307 L0.4181,0.8427 Q0.4181,0.8469,0.4222,0.8498 T0.431,0.8528 L0.5736,0.8528 Q0.5778,0.8528,0.5808,0.8511 T0.5855,0.8471 T0.587,0.8427 L0.587,0.7307 Q0.587,0.7265,0.5826,0.7236 T0.5736,0.7206 Z M0.7827,0.164 L0.6395,0.164 L0.6395,0.2756 L0.7827,0.2756 L0.7827,0.164 Z M0.7827,0.31 L0.6395,0.31 L0.6395,0.4216 L0.7827,0.4216 L0.7827,0.31 Z M0.7827,0.5893 L0.6395,0.5893 L0.6395,0.7013 L0.7827,0.7013 L0.7827,0.5893 Z M0.7827,0.7307 L0.6395,0.7307 L0.6395,0.8427 L0.7827,0.8427 L0.7827,0.7307 Z M0.7827,0.8758 L0.6395,0.8758 L0.6395,0.9878 L0.7827,0.9878 L0.7827,0.8758 Z M1,0.164 L0.8574,0.164 L0.8574,0.2756 L1,0.2756 L1,0.164 Z M1,0.31 L0.8574,0.31 L0.8574,0.4216 L1,0.4216 L1,0.31 Z M1,0.4476 L0.8574,0.4476 L0.8574,0.5596 L1,0.5596 L1,0.4476 Z M1,0.5893 L0.8574,0.5893 L0.8574,0.7013 L1,0.7013 L1,0.5893 Z M1,0.7307 L0.8574,0.7307 L0.8574,0.8427 L1,0.8427 L1,0.7307 Z M1,0.8758 L0.8574,0.8758 L0.8574,0.9878 L1,0.9878 L1,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.0008,0.9979 Q0.0008,1,0.0032,1 Q0.0482,1,0.0602,0.9975 Q0.0667,0.9963,0.0847,0.9917 T0.1084,0.9859 Q0.1124,0.9851,0.1221,0.9851 L0.1253,0.9851 L0.1285,0.9851 Q0.1518,0.9851,0.1655,0.9809 Q0.1695,0.9801,0.1731,0.9788 T0.1791,0.9766 T0.1839,0.9747 T0.1888,0.9732 L0.1936,0.972 T0.1988,0.9712 T0.2048,0.971 L0.2096,0.971 Q0.2201,0.9714,0.2233,0.9714 T0.2345,0.9693 Q0.2386,0.9685,0.2502,0.9674 T0.2715,0.966 L0.2811,0.9656 Q0.2916,0.9647,0.2916,0.9573 Q0.2916,0.954,0.2892,0.9515 T0.2819,0.9486 Q0.2755,0.9482,0.2683,0.9482 Q0.2643,0.9482,0.2582,0.9484 T0.2498,0.9486 Q0.2426,0.9486,0.2402,0.9473 Q0.2386,0.9469,0.2317,0.943 T0.2161,0.937 Q0.2104,0.9357,0.1992,0.933 T0.1831,0.9291 Q0.1807,0.9287,0.1783,0.9285 T0.1739,0.928 T0.1703,0.9276 T0.1675,0.9272 T0.1655,0.9266 T0.1639,0.9253 Q0.1598,0.9216,0.1462,0.9216 L0.143,0.9216 L0.1398,0.9216 L0.1365,0.9216 Q0.1197,0.9195,0.1197,0.9154 L0.1197,0.9154 Q0.1205,0.9121,0.1373,0.9088 T0.1703,0.9054 Q0.1791,0.9054,0.1863,0.904 T0.1984,0.9011 T0.2064,0.8992 Q0.2402,0.8967,0.2506,0.8934 Q0.2538,0.8926,0.2602,0.8899 T0.2707,0.8872 Q0.2715,0.8872,0.2731,0.8876 Q0.2795,0.8884,0.2884,0.8884 Q0.3068,0.8884,0.3092,0.8826 L0.3092,0.8797 Q0.3092,0.8772,0.3076,0.8747 T0.3044,0.8706 T0.3028,0.8681 Q0.3076,0.8656,0.3237,0.8656 Q0.3317,0.8656,0.3622,0.8623 Q0.3655,0.8623,0.3867,0.8617 T0.4217,0.8602 Q0.4241,0.8598,0.4289,0.8598 L0.4345,0.8598 L0.441,0.8598 Q0.4578,0.8598,0.4667,0.8586 Q0.4739,0.8573,0.4851,0.8567 T0.5004,0.8552 Q0.5012,0.8552,0.5108,0.855 T0.5269,0.853 T0.5333,0.8461 Q0.5333,0.8445,0.5325,0.8432 T0.5309,0.8409 T0.5289,0.8391 T0.5261,0.8378 L0.5229,0.837 T0.5185,0.8362 T0.5133,0.8355 T0.5076,0.8349 T0.502,0.8341 Q0.4932,0.8324,0.4859,0.8324 Q0.4827,0.8324,0.4787,0.8328 T0.4731,0.8333 Q0.4707,0.8333,0.4683,0.8324 Q0.4482,0.825,0.4394,0.825 Q0.4369,0.825,0.4345,0.8254 Q0.4225,0.827,0.4153,0.827 Q0.4088,0.827,0.4064,0.8258 Q0.3976,0.8204,0.3751,0.8204 Q0.3703,0.8204,0.3667,0.8214 T0.3622,0.8225 Q0.3598,0.8225,0.3558,0.82 Q0.351,0.8175,0.3402,0.8167 T0.3177,0.8156 T0.3028,0.8146 L0.2956,0.8121 T0.2871,0.8094 T0.2771,0.8073 T0.2635,0.8063 Q0.261,0.8063,0.2586,0.8067 Q0.2378,0.8071,0.2273,0.8071 Q0.2072,0.8071,0.2024,0.8051 Q0.1976,0.8034,0.1932,0.8026 T0.1867,0.8013 T0.1847,0.8001 L0.1847,0.7993 Q0.1855,0.7984,0.1855,0.7978 T0.1859,0.7966 T0.1867,0.7959 T0.188,0.7955 T0.1896,0.7951 T0.1916,0.7949 T0.1944,0.7945 T0.1984,0.7941 T0.2032,0.7939 Q0.212,0.7926,0.2325,0.7918 T0.2562,0.7905 Q0.2691,0.7893,0.2787,0.7847 Q0.2835,0.7827,0.2968,0.7791 T0.3149,0.7756 Q0.3189,0.7756,0.3305,0.7733 T0.3446,0.771 L0.3454,0.771 Q0.3462,0.771,0.3498,0.7721 T0.3574,0.774 T0.3655,0.7748 Q0.3703,0.7748,0.3743,0.7731 T0.3823,0.7708 T0.3916,0.77 T0.3992,0.7694 Q0.4008,0.7694,0.4076,0.7688 T0.4205,0.7675 L0.4305,0.7665 Q0.4345,0.7657,0.4402,0.7617 T0.4458,0.7545 Q0.4458,0.7503,0.4353,0.7487 Q0.4297,0.7478,0.4209,0.7462 T0.4044,0.7433 T0.3904,0.7416 L0.3847,0.7416 Q0.3807,0.7416,0.3747,0.7422 T0.3663,0.7428 T0.3606,0.7424 Q0.3582,0.742,0.3562,0.7418 T0.3522,0.7412 T0.3482,0.7406 T0.3446,0.7401 T0.341,0.7397 T0.3373,0.7393 T0.3341,0.7391 L0.3293,0.7391 Q0.3277,0.7395,0.3253,0.7395 Q0.3205,0.7395,0.3052,0.7387 T0.2835,0.7379 Q0.2755,0.7379,0.253,0.7325 Q0.2506,0.7316,0.2462,0.731 T0.2382,0.7296 T0.2305,0.7271 T0.2181,0.7234 T0.2048,0.7196 T0.2,0.7155 Q0.2,0.7142,0.2016,0.713 Q0.208,0.7059,0.2285,0.6978 T0.2618,0.6898 Q0.2739,0.6898,0.2831,0.6848 T0.2956,0.6794 Q0.3028,0.6786,0.3289,0.6765 T0.3566,0.674 Q0.3582,0.674,0.3855,0.6723 T0.4406,0.6688 T0.4755,0.6653 Q0.5004,0.6607,0.5124,0.6599 L0.5165,0.6599 Q0.5213,0.6599,0.5277,0.6605 T0.5373,0.6611 Q0.543,0.6611,0.5494,0.6599 Q0.592,0.6524,0.6,0.6524 Q0.6064,0.6524,0.61,0.6499 T0.6161,0.6474 Q0.6177,0.6474,0.6261,0.6495 T0.6418,0.6516 L0.6482,0.6516 Q0.653,0.6512,0.6651,0.6506 T0.6876,0.6493 T0.7084,0.6477 T0.7229,0.645 Q0.7269,0.6437,0.7333,0.6437 Q0.7373,0.6437,0.7458,0.6443 T0.7574,0.645 Q0.7614,0.645,0.7631,0.6445 T0.7655,0.6441 Q0.7671,0.6441,0.7723,0.6448 T0.7823,0.6454 Q0.788,0.6454,0.7952,0.6445 Q0.8233,0.6408,0.8723,0.6367 Q0.9012,0.6342,0.9092,0.6342 L0.9165,0.6342 L0.9205,0.6342 Q0.9277,0.6342,0.9382,0.6323 T0.9526,0.6304 Q0.9534,0.6304,0.9594,0.6307 T0.9695,0.6309 Q0.9976,0.6309,0.9992,0.6234 Q1,0.6201,1,0.618 Q1,0.6089,0.9775,0.608 Q0.9703,0.6076,0.9582,0.6076 Q0.9518,0.6076,0.9394,0.6078 T0.9213,0.608 Q0.9036,0.608,0.8972,0.6072 Q0.894,0.6068,0.8871,0.6058 T0.8751,0.6039 T0.8627,0.6024 T0.8506,0.6018 L0.8474,0.6018 Q0.841,0.6022,0.8281,0.6041 T0.8112,0.606 Q0.8096,0.606,0.808,0.6056 Q0.7783,0.6002,0.7647,0.6002 Q0.7598,0.6002,0.7454,0.6006 T0.7261,0.601 Q0.7221,0.601,0.7145,0.6022 T0.7036,0.6035 Q0.6996,0.6035,0.6964,0.6022 Q0.6723,0.5902,0.6442,0.5902 Q0.6426,0.5902,0.6386,0.5904 T0.6337,0.5906 Q0.6273,0.5906,0.6249,0.5894 L0.6177,0.5856 T0.6116,0.5838 T0.6016,0.5825 T0.5855,0.5823 Q0.5719,0.5823,0.5574,0.5798 T0.5373,0.5774 L0.5341,0.5774 Q0.5293,0.5778,0.5213,0.5786 T0.51,0.5794 Q0.5036,0.5794,0.4988,0.5769 Q0.4932,0.574,0.4771,0.574 Q0.4723,0.574,0.4631,0.5745 T0.4498,0.5749 Q0.4418,0.5749,0.4394,0.5736 Q0.4353,0.5724,0.4305,0.5715 T0.4225,0.5707 T0.4145,0.5705 T0.4056,0.5699 Q0.4008,0.5691,0.398,0.5689 T0.394,0.5689 T0.3908,0.5686 T0.3855,0.5674 Q0.3831,0.567,0.3811,0.5662 T0.3779,0.5645 T0.3743,0.563 T0.3695,0.5624 Q0.3655,0.5624,0.3594,0.5635 T0.3494,0.5645 T0.3406,0.5635 T0.3325,0.5624 Q0.3309,0.5624,0.3301,0.5628 L0.3141,0.5628 Q0.2635,0.5628,0.2506,0.5612 Q0.2474,0.5608,0.2434,0.5608 Q0.2402,0.5608,0.2349,0.561 T0.2273,0.5612 Q0.2209,0.5612,0.2177,0.5595 Q0.2145,0.557,0.2145,0.5558 Q0.2169,0.5537,0.2345,0.5521 Q0.2876,0.5475,0.3028,0.5425 Q0.3068,0.5413,0.3149,0.5396 T0.3309,0.5367 T0.3478,0.5338 T0.3606,0.5309 Q0.3631,0.5305,0.3755,0.5259 T0.3968,0.5214 Q0.3992,0.5214,0.4024,0.5218 T0.4096,0.5222 Q0.4161,0.5222,0.4213,0.5209 T0.4313,0.5185 T0.4402,0.5172 Q0.4418,0.5168,0.447,0.5168 L0.4558,0.5168 T0.4639,0.5162 T0.4707,0.5141 T0.4731,0.5102 Q0.4731,0.5089,0.4723,0.5081 Q0.4699,0.5019,0.4627,0.4994 T0.4369,0.4965 Q0.4273,0.4961,0.4193,0.4946 T0.4048,0.4915 T0.3952,0.4894 Q0.392,0.4886,0.388,0.4886 Q0.3847,0.4886,0.3775,0.4892 T0.3647,0.4898 Q0.3598,0.4898,0.355,0.4894 Q0.3165,0.4861,0.3141,0.4853 Q0.2779,0.4774,0.2715,0.4774 Q0.2699,0.4774,0.2683,0.4776 T0.2627,0.4778 Q0.2498,0.4778,0.2281,0.4762 Q0.2241,0.4749,0.2233,0.4737 Q0.2249,0.472,0.2321,0.4708 Q0.2402,0.4695,0.2554,0.4695 L0.2675,0.4695 L0.2795,0.4695 Q0.294,0.4695,0.2996,0.4679 Q0.3141,0.4629,0.3373,0.4616 Q0.3414,0.4612,0.3466,0.4606 T0.3582,0.4589 T0.3687,0.4562 T0.3727,0.4525 Q0.3727,0.4509,0.3703,0.4492 Q0.3639,0.4455,0.3474,0.4419 T0.3213,0.4384 L0.3157,0.4384 L0.31,0.4384 Q0.294,0.4384,0.2859,0.4363 Q0.2795,0.4347,0.2691,0.4347 L0.2618,0.4347 L0.2546,0.4347 Q0.2458,0.4347,0.2394,0.4338 Q0.2257,0.4318,0.2193,0.4303 T0.2092,0.4266 T0.2052,0.4224 T0.2024,0.4154 T0.196,0.4052 Q0.1912,0.3994,0.1867,0.3949 T0.1807,0.3884 T0.1791,0.3849 Q0.1791,0.3824,0.1839,0.3745 Q0.1871,0.3687,0.1944,0.3637 T0.2072,0.3561 T0.2221,0.3501 T0.2321,0.3463 Q0.2353,0.3455,0.241,0.3445 T0.2522,0.3428 T0.2639,0.3411 T0.2731,0.3384 T0.2956,0.3351 T0.3197,0.3326 Q0.3213,0.3322,0.3237,0.3322 T0.3325,0.3331 T0.3414,0.3339 Q0.3478,0.3339,0.3518,0.3314 Q0.3606,0.3264,0.3703,0.3264 Q0.3775,0.3264,0.3847,0.3293 Q0.3888,0.331,0.396,0.331 Q0.4024,0.331,0.4116,0.3295 T0.4265,0.3266 T0.4414,0.3227 T0.4514,0.3202 Q0.4578,0.3181,0.4839,0.3152 T0.5112,0.3123 T0.5177,0.3119 T0.5285,0.3111 T0.5398,0.3096 T0.549,0.3065 T0.5526,0.3015 Q0.5526,0.2999,0.5518,0.2982 Q0.547,0.2903,0.5386,0.2883 T0.5165,0.2862 Q0.5116,0.2862,0.5056,0.2866 T0.4972,0.287 Q0.4884,0.287,0.4787,0.2833 Q0.4594,0.2758,0.4265,0.2758 Q0.4169,0.2758,0.4129,0.2766 Q0.4112,0.2771,0.4104,0.2771 Q0.4088,0.2771,0.4056,0.2748 T0.3968,0.2721 Q0.3695,0.2696,0.359,0.2659 Q0.355,0.2646,0.351,0.2646 T0.3426,0.2661 T0.3365,0.2675 T0.3333,0.2659 Q0.3277,0.2605,0.3116,0.2553 T0.2859,0.2501 L0.2843,0.2501 L0.2819,0.2501 Q0.2779,0.2501,0.2723,0.2493 T0.2586,0.2472 T0.2474,0.2455 Q0.1799,0.236,0.1719,0.236 Q0.1663,0.236,0.1606,0.235 T0.1502,0.2316 T0.1454,0.2265 Q0.1454,0.2223,0.1558,0.2173 Q0.1679,0.2115,0.1859,0.2092 T0.2185,0.207 T0.2353,0.2057 Q0.2369,0.2049,0.2502,0.2041 T0.2799,0.2022 T0.302,0.2007 Q0.3084,0.1999,0.3245,0.1954 T0.347,0.1908 Q0.3502,0.1908,0.3534,0.1916 Q0.3663,0.197,0.388,0.197 Q0.404,0.197,0.4088,0.1929 Q0.4096,0.192,0.4108,0.192 T0.4177,0.1945 T0.4277,0.197 T0.4369,0.1949 Q0.4442,0.1908,0.4843,0.1875 Q0.4892,0.1871,0.4968,0.1839 T0.5084,0.1808 L0.5108,0.1808 Q0.5213,0.1825,0.5454,0.1825 Q0.5823,0.1825,0.5992,0.1779 Q0.6096,0.1746,0.6217,0.1746 Q0.6249,0.1746,0.6309,0.1748 T0.6394,0.175 Q0.6434,0.175,0.6466,0.1746 Q0.6474,0.1746,0.6594,0.1738 T0.6787,0.1713 T0.6892,0.1659 Q0.6924,0.1634,0.6924,0.1593 Q0.6924,0.1547,0.6888,0.151 T0.6795,0.1472 Q0.6779,0.1472,0.6763,0.1477 Q0.6699,0.1493,0.6667,0.1493 Q0.661,0.1493,0.6506,0.1456 Q0.6329,0.1394,0.6129,0.1394 Q0.6048,0.1394,0.5992,0.1377 T0.5888,0.136 T0.5803,0.1377 T0.5751,0.1394 Q0.5711,0.1394,0.5639,0.1369 Q0.5365,0.1273,0.5116,0.1273 Q0.4876,0.1273,0.4667,0.1253 Q0.4627,0.1248,0.4542,0.1211 T0.4337,0.1174 L0.4305,0.1174 Q0.4217,0.1178,0.4153,0.119 T0.408,0.1203 Q0.4056,0.1203,0.4,0.117 Q0.3976,0.1153,0.396,0.1136 T0.3932,0.1112 T0.39,0.1099 T0.3847,0.1095 Q0.3799,0.1095,0.3687,0.1103 Q0.355,0.1112,0.3434,0.1141 T0.3301,0.117 Q0.3261,0.117,0.3229,0.1145 Q0.3181,0.1116,0.3052,0.1087 T0.2787,0.1043 T0.2546,0.1029 Q0.2506,0.1029,0.2474,0.1033 Q0.2418,0.1037,0.2349,0.1054 T0.2249,0.107 Q0.2225,0.107,0.2193,0.1066 Q0.2024,0.1024,0.1863,0.1024 Q0.1823,0.1024,0.1562,0.0971 T0.1269,0.0917 T0.1161,0.0896 T0.106,0.0854 Q0.1076,0.0846,0.11,0.0842 Q0.1173,0.0821,0.1261,0.0821 Q0.1301,0.0821,0.1369,0.0825 T0.1462,0.083 Q0.1494,0.083,0.151,0.0825 T0.1831,0.0813 T0.2201,0.0784 T0.243,0.074 T0.2667,0.0718 Q0.2707,0.0718,0.2755,0.0724 T0.2843,0.073 T0.2936,0.0724 T0.3024,0.0705 T0.3072,0.068 T0.3092,0.0657 T0.3108,0.0647 Q0.3116,0.0643,0.3133,0.0643 L0.3157,0.0643 L0.3181,0.0643 Q0.3446,0.0643,0.3446,0.0556 T0.3205,0.0469 L0.3189,0.0469 Q0.3157,0.0469,0.3157,0.0465 Q0.3084,0.0427,0.2835,0.0386 Q0.2739,0.0369,0.2675,0.0342 T0.2538,0.0299 Q0.249,0.029,0.245,0.029 T0.2378,0.0303 T0.2321,0.0315 Q0.2305,0.0315,0.2273,0.0307 Q0.2201,0.0286,0.2004,0.0272 T0.1775,0.0245 Q0.1735,0.0228,0.1663,0.0226 T0.1522,0.0197 T0.1345,0.0145 T0.1124,0.0079 Q0.0996,0.0033,0.0671,0.0044 T0.0297,0.0041 Q0.0169,0,0.0024,0.0017 Q0,0.0021,0,0.0037 Z M0.0064,0.9954 L0.0056,0.0058 Q0.0177,0.005,0.0281,0.0083 Q0.0345,0.01,0.0675,0.0089 T0.1108,0.012 Q0.1221,0.0162,0.1329,0.0187 T0.1498,0.0236 T0.1606,0.0268 T0.1691,0.0274 T0.1759,0.0286 Q0.1807,0.0303,0.2,0.0315 T0.2257,0.0348 Q0.2305,0.0361,0.2337,0.0361 Q0.2361,0.0361,0.2398,0.0348 T0.2466,0.0336 Q0.249,0.0336,0.2522,0.034 Q0.2586,0.0353,0.2655,0.0382 T0.2827,0.0427 Q0.3068,0.0469,0.3124,0.0502 Q0.3157,0.0523,0.3237,0.0523 L0.3277,0.0523 L0.3309,0.0523 Q0.3398,0.0523,0.3398,0.0556 Q0.3398,0.0581,0.3341,0.0587 T0.3205,0.0593 T0.3092,0.0603 T0.3036,0.0643 T0.2932,0.068 Q0.2884,0.0684,0.2843,0.0684 Q0.2811,0.0684,0.2763,0.0678 T0.2667,0.0672 Q0.2586,0.0672,0.2422,0.0697 T0.2177,0.0747 Q0.2137,0.0759,0.1831,0.0767 T0.1494,0.0784 L0.1474,0.0784 T0.1398,0.078 T0.1285,0.0776 Q0.1173,0.0776,0.1084,0.08 Q0.1004,0.0817,0.1004,0.0846 Q0.1004,0.0867,0.104,0.0888 T0.1124,0.0923 T0.1213,0.0948 T0.1269,0.0958 T0.155,0.1014 T0.1863,0.107 Q0.2016,0.107,0.2185,0.1107 Q0.2217,0.1116,0.2257,0.1116 Q0.2289,0.1116,0.2365,0.1099 T0.2482,0.1074 L0.2538,0.1074 Q0.2683,0.1074,0.2912,0.1107 T0.3197,0.1182 Q0.3245,0.1215,0.3301,0.1215 Q0.3333,0.1215,0.3454,0.1184 T0.3687,0.1145 Q0.3735,0.1141,0.3779,0.1139 T0.3843,0.1134 T0.3871,0.1132 Q0.3896,0.1132,0.39,0.1136 T0.392,0.1161 T0.3968,0.1203 Q0.404,0.1248,0.408,0.1248 Q0.4096,0.1248,0.4165,0.1234 T0.4305,0.1215 L0.4337,0.1215 Q0.4442,0.1215,0.4518,0.1251 T0.4659,0.1294 Q0.4876,0.1319,0.5116,0.1319 T0.5622,0.141 Q0.5703,0.1439,0.5751,0.1439 Q0.5791,0.1439,0.5831,0.1423 T0.5888,0.1406 Q0.592,0.1406,0.5944,0.1412 T0.6012,0.1427 T0.6129,0.1435 Q0.6313,0.1435,0.649,0.1497 Q0.6602,0.1535,0.6667,0.1535 Q0.6715,0.1535,0.6779,0.1522 Q0.6787,0.1518,0.6795,0.1518 Q0.6827,0.1518,0.6847,0.1541 T0.6867,0.1593 Q0.6867,0.1618,0.6851,0.1634 Q0.6835,0.1655,0.6775,0.1667 T0.6598,0.169 T0.6458,0.1705 T0.6402,0.1709 Q0.6378,0.1709,0.6321,0.1705 T0.6225,0.1701 Q0.6096,0.1701,0.5968,0.1738 Q0.5823,0.1779,0.5446,0.1779 Q0.5205,0.1779,0.5116,0.1767 Q0.51,0.1763,0.5084,0.1763 Q0.5028,0.1763,0.4944,0.1796 T0.4835,0.1829 L0.4771,0.1833 T0.4659,0.1844 L0.4546,0.1858 T0.443,0.1881 T0.4337,0.1912 Q0.4321,0.1916,0.4305,0.1916 Q0.4273,0.1916,0.4209,0.1895 T0.412,0.1875 Q0.408,0.1875,0.4056,0.19 Q0.4024,0.1925,0.388,0.1925 Q0.3663,0.1925,0.3558,0.1879 Q0.3518,0.1862,0.3462,0.1862 Q0.3373,0.1862,0.3213,0.191 T0.3012,0.1962 Q0.2964,0.1966,0.2799,0.1976 T0.2494,0.1997 T0.2313,0.2024 L0.2313,0.2024 L0.2293,0.2024 L0.2261,0.2024 L0.2217,0.2024 Q0.204,0.2024,0.1851,0.2047 T0.1526,0.2136 Q0.1406,0.2198,0.1406,0.226 Q0.1406,0.2319,0.1518,0.2362 T0.1719,0.2406 Q0.1791,0.2406,0.2466,0.2497 Q0.2498,0.2501,0.2574,0.2516 T0.2711,0.2538 T0.2819,0.2547 L0.2851,0.2547 Q0.2851,0.2543,0.2859,0.2543 Q0.294,0.2543,0.3096,0.2592 T0.3285,0.2684 Q0.3317,0.2721,0.3373,0.2721 Q0.3406,0.2721,0.3462,0.2708 T0.3542,0.2696 Q0.3558,0.2696,0.3574,0.27 Q0.3679,0.2737,0.3968,0.2762 Q0.3984,0.2766,0.4004,0.2779 L0.4044,0.2804 T0.4096,0.2816 Q0.412,0.2816,0.4145,0.2808 Q0.4177,0.2804,0.4249,0.2804 Q0.4586,0.2804,0.4763,0.287 Q0.4867,0.2912,0.4972,0.2912 Q0.5004,0.2912,0.5064,0.2908 T0.5165,0.2903 Q0.5293,0.2903,0.5361,0.2922 T0.547,0.3003 L0.547,0.3011 Q0.547,0.3036,0.5414,0.3049 T0.5249,0.3067 T0.51,0.3082 Q0.5092,0.3082,0.4831,0.3111 T0.4498,0.3161 Q0.408,0.3264,0.3952,0.3264 Q0.3896,0.3264,0.3863,0.3252 Q0.3783,0.3223,0.3703,0.3223 Q0.359,0.3223,0.3494,0.3277 Q0.347,0.3293,0.343,0.3293 Q0.3414,0.3293,0.3353,0.3285 T0.3253,0.3277 T0.3181,0.3285 Q0.3149,0.3289,0.2952,0.3306 T0.2699,0.3347 Q0.2675,0.3364,0.2598,0.3372 T0.2434,0.3395 T0.2297,0.3426 L0.2205,0.3461 T0.2048,0.3523 T0.1908,0.3606 T0.1791,0.3725 Q0.1743,0.3803,0.1743,0.3845 Q0.1743,0.3874,0.1763,0.3901 T0.1827,0.3976 T0.1912,0.4073 T0.198,0.4189 T0.2032,0.4276 T0.2137,0.4326 T0.2386,0.438 Q0.2458,0.4392,0.2562,0.4392 L0.2639,0.4392 L0.2699,0.4392 Q0.2795,0.4392,0.2843,0.4405 Q0.2932,0.443,0.3092,0.443 L0.3157,0.443 L0.3213,0.443 Q0.3293,0.443,0.3458,0.4463 T0.3671,0.4525 Q0.3598,0.4558,0.3373,0.4571 Q0.3124,0.4587,0.298,0.4637 Q0.294,0.465,0.2811,0.465 L0.2703,0.465 L0.2586,0.465 Q0.241,0.465,0.2305,0.4666 Q0.2185,0.4687,0.2185,0.4728 Q0.2185,0.4745,0.2205,0.4764 T0.2241,0.4791 L0.2265,0.4803 L0.2273,0.4803 Q0.2506,0.4824,0.261,0.4824 Q0.2675,0.4824,0.2699,0.482 Q0.2699,0.4815,0.2707,0.4815 Q0.2771,0.4815,0.3124,0.4898 Q0.3173,0.4907,0.3229,0.4913 T0.3386,0.4925 T0.3542,0.4936 T0.3663,0.494 Q0.3711,0.494,0.3787,0.4936 T0.3888,0.4932 Q0.392,0.4932,0.3944,0.4936 T0.4032,0.4959 T0.4181,0.499 T0.4369,0.5006 Q0.449,0.501,0.455,0.5021 T0.4639,0.5048 T0.4675,0.5093 L0.4675,0.5097 Q0.4675,0.5106,0.4663,0.511 T0.4622,0.5116 L0.4566,0.512 T0.4486,0.5124 T0.4402,0.5127 Q0.4345,0.5131,0.4257,0.5153 T0.4096,0.5176 Q0.4064,0.5176,0.4024,0.5172 L0.3968,0.5172 Q0.3863,0.5172,0.3731,0.522 T0.359,0.5268 Q0.355,0.528,0.3317,0.5321 T0.3004,0.5388 Q0.2867,0.5433,0.2337,0.5479 Q0.2096,0.55,0.2096,0.5562 Q0.2096,0.5591,0.2145,0.5628 Q0.2193,0.5662,0.2289,0.5662 Q0.2313,0.5662,0.2373,0.5657 T0.2458,0.5653 L0.2498,0.5653 Q0.2635,0.5674,0.3124,0.5674 Q0.3261,0.5674,0.3301,0.567 L0.3317,0.567 Q0.3341,0.567,0.3394,0.568 T0.3486,0.5691 Q0.3542,0.5691,0.3606,0.5678 T0.3699,0.5666 T0.3759,0.5686 T0.3839,0.5718 T0.3908,0.573 T0.3964,0.5734 T0.4048,0.5742 T0.4165,0.5751 T0.4277,0.5757 T0.4369,0.5778 Q0.4426,0.5794,0.4538,0.5794 Q0.4586,0.5794,0.4679,0.5792 T0.4811,0.579 Q0.4924,0.579,0.4956,0.5807 Q0.502,0.584,0.5108,0.584 L0.5137,0.584 T0.5173,0.5838 L0.5205,0.5834 L0.5237,0.583 L0.5269,0.5825 T0.5305,0.5821 T0.5341,0.5819 L0.5365,0.5819 Q0.5414,0.5819,0.5562,0.5842 T0.5855,0.5865 Q0.5912,0.5865,0.5948,0.5867 T0.6012,0.5869 T0.6064,0.5873 T0.61,0.5877 T0.6133,0.5886 T0.6157,0.5896 L0.6185,0.591 T0.6217,0.5931 Q0.6265,0.5952,0.6369,0.5952 L0.6418,0.5952 L0.6466,0.5952 Q0.6723,0.5952,0.6932,0.606 Q0.698,0.608,0.7044,0.608 Q0.7084,0.608,0.7161,0.6068 T0.7261,0.6056 Q0.7309,0.6056,0.7454,0.6051 T0.7647,0.6047 Q0.7775,0.6047,0.8072,0.6101 Q0.8096,0.6105,0.812,0.6105 Q0.8177,0.6105,0.8297,0.6085 T0.8474,0.606 L0.8506,0.606 Q0.8562,0.606,0.8647,0.607 T0.8831,0.6095 T0.8964,0.6118 Q0.9036,0.6122,0.9221,0.6122 L0.9406,0.6122 L0.959,0.6122 L0.9767,0.6122 Q0.9952,0.613,0.9952,0.6172 Q0.9952,0.6176,0.9944,0.6221 Q0.9936,0.6259,0.9574,0.6259 L0.955,0.6259 L0.9526,0.6259 Q0.9478,0.6259,0.9373,0.628 T0.9205,0.63 L0.9173,0.63 Q0.9133,0.6296,0.9084,0.6296 Q0.9004,0.6296,0.8715,0.6321 Q0.8233,0.6367,0.7944,0.64 Q0.7888,0.6408,0.7839,0.6408 T0.7739,0.6402 T0.7671,0.6396 Q0.7639,0.6396,0.7622,0.64 Q0.7614,0.6404,0.759,0.6404 Q0.7574,0.6404,0.749,0.6398 T0.7357,0.6392 Q0.7261,0.6392,0.7213,0.6412 Q0.7173,0.6425,0.7032,0.6437 T0.6711,0.6458 T0.6474,0.647 Q0.645,0.6474,0.6418,0.6474 Q0.6353,0.6474,0.6277,0.6454 T0.6161,0.6433 Q0.6104,0.6433,0.6072,0.6456 T0.6,0.6479 Q0.5912,0.6479,0.5486,0.6557 Q0.5422,0.657,0.5373,0.657 Q0.5349,0.657,0.5289,0.6564 T0.5173,0.6557 L0.5124,0.6557 Q0.4996,0.6562,0.4739,0.6611 Q0.4675,0.6624,0.4398,0.6645 T0.3851,0.668 T0.3558,0.6698 Q0.355,0.6698,0.3285,0.6721 T0.2948,0.6752 Q0.2892,0.6761,0.2843,0.6786 T0.2747,0.6831 T0.2618,0.6852 Q0.253,0.6852,0.2394,0.6893 T0.2141,0.6993 T0.1968,0.7105 Q0.1944,0.713,0.1944,0.7155 Q0.1944,0.7196,0.2012,0.7229 T0.2177,0.7285 T0.2281,0.7308 Q0.2321,0.7329,0.2365,0.7339 T0.245,0.7356 T0.2514,0.7366 Q0.2522,0.737,0.2554,0.7379 T0.2614,0.7393 T0.2679,0.7406 T0.2755,0.7416 T0.2835,0.742 Q0.29,0.742,0.3048,0.7428 T0.3253,0.7437 L0.3301,0.7437 L0.3333,0.7437 Q0.3341,0.7437,0.3598,0.7466 Q0.3639,0.7474,0.3671,0.7474 T0.3759,0.7466 T0.3855,0.7457 Q0.388,0.7457,0.3904,0.7462 Q0.3984,0.7466,0.4137,0.7495 T0.4349,0.7532 T0.441,0.7557 Q0.441,0.7599,0.4289,0.7619 Q0.4257,0.7628,0.4197,0.7634 T0.4072,0.7644 T0.3984,0.7652 Q0.3968,0.7652,0.3912,0.7655 T0.3811,0.7665 T0.3719,0.7694 Q0.3695,0.7702,0.3655,0.7702 T0.3546,0.7686 T0.3462,0.7665 L0.3446,0.7665 Q0.3406,0.7665,0.3293,0.769 T0.3149,0.7715 Q0.3084,0.7715,0.2952,0.7748 T0.2763,0.781 Q0.2675,0.7847,0.2554,0.7864 Q0.253,0.7864,0.2325,0.7874 T0.2024,0.7893 Q0.2008,0.7893,0.1984,0.7897 T0.1948,0.7901 T0.1916,0.7903 T0.1888,0.7908 T0.1867,0.7914 T0.1847,0.7922 L0.1831,0.793 T0.1819,0.7943 L0.1811,0.7959 T0.1799,0.7976 Q0.1791,0.7993,0.1791,0.8001 Q0.1791,0.8034,0.1831,0.8051 T0.1932,0.8078 T0.2,0.8092 Q0.2072,0.8117,0.2257,0.8117 Q0.2337,0.8117,0.2586,0.8109 L0.2635,0.8109 Q0.2707,0.8109,0.2767,0.8117 T0.2859,0.8136 T0.2936,0.8163 T0.3012,0.8187 Q0.3068,0.82,0.3277,0.8206 T0.3526,0.8237 Q0.3582,0.8266,0.3622,0.8266 Q0.3647,0.8266,0.3687,0.8258 T0.3751,0.825 Q0.396,0.825,0.404,0.8291 Q0.408,0.8316,0.4161,0.8316 Q0.4217,0.8316,0.4353,0.8295 L0.4394,0.8295 Q0.4466,0.8295,0.4659,0.8366 Q0.4699,0.8378,0.4747,0.8378 Q0.4763,0.8378,0.4807,0.8374 T0.4884,0.837 Q0.494,0.837,0.5004,0.8382 Q0.5052,0.8391,0.5124,0.8399 Q0.5221,0.8411,0.5249,0.8422 T0.5277,0.8461 Q0.5277,0.8482,0.5233,0.849 T0.5112,0.8501 T0.4996,0.8511 Q0.4964,0.8519,0.4851,0.8523 T0.4659,0.8544 Q0.4578,0.8557,0.4402,0.8557 L0.4349,0.8557 L0.4297,0.8557 L0.4209,0.8557 Q0.408,0.8565,0.3867,0.8571 T0.3614,0.8582 Q0.3317,0.8611,0.3237,0.8611 L0.3225,0.8611 L0.3213,0.8611 Q0.2972,0.8611,0.2972,0.8681 Q0.2972,0.8714,0.3008,0.8747 T0.3044,0.8805 Q0.3044,0.881,0.3036,0.8814 Q0.3012,0.8839,0.2851,0.8839 Q0.2779,0.8839,0.2739,0.883 Q0.2723,0.8826,0.2699,0.8826 T0.2643,0.8835 T0.259,0.8853 T0.2542,0.8876 T0.249,0.8893 Q0.2386,0.8922,0.2056,0.8946 Q0.2016,0.8951,0.1916,0.898 T0.1703,0.9009 Q0.1518,0.9009,0.1337,0.9044 T0.1149,0.9146 L0.1149,0.9158 Q0.1149,0.9175,0.1157,0.9187 T0.1173,0.921 T0.1201,0.9226 T0.1233,0.9237 T0.1269,0.9245 L0.1305,0.9251 T0.1337,0.9255 L0.1357,0.9258 Q0.139,0.9262,0.1446,0.9262 T0.1542,0.9266 T0.1598,0.9282 Q0.1614,0.9303,0.1647,0.9314 T0.1739,0.9328 T0.1815,0.9336 Q0.1863,0.9345,0.1976,0.9372 T0.2145,0.9415 Q0.2225,0.9432,0.2285,0.9467 T0.2378,0.9515 Q0.2426,0.9531,0.2514,0.9531 Q0.2538,0.9531,0.2602,0.9529 T0.2707,0.9527 Q0.2763,0.9527,0.2815,0.9531 T0.2867,0.9569 T0.2811,0.9614 Q0.2434,0.9627,0.2329,0.9652 Q0.2249,0.9672,0.2241,0.9672 L0.2096,0.9668 L0.2056,0.9668 Q0.2,0.9668,0.196,0.9672 T0.1884,0.9687 T0.1815,0.9708 T0.1731,0.9737 T0.1639,0.9772 Q0.1518,0.9805,0.1285,0.9805 L0.1253,0.9805 Q0.1124,0.9805,0.1076,0.9818 Q0.1012,0.983,0.0831,0.9876 T0.0594,0.9934 Q0.049,0.9954,0.0064,0.9954 Z M0.0032,0.9979 L0.0024,0.0037 Q0.0161,0.0021,0.0289,0.0062 Q0.0337,0.0075,0.0671,0.0066 T0.1116,0.01 T0.1337,0.0166 T0.151,0.022 Q0.1582,0.0249,0.1659,0.0251 T0.1767,0.0265 Q0.1807,0.0278,0.2,0.0292 T0.2265,0.0328 Q0.2305,0.034,0.2329,0.034 T0.239,0.0326 T0.2458,0.0311 T0.253,0.0319 Q0.2578,0.0332,0.2614,0.0342 T0.2667,0.0363 T0.2723,0.0384 T0.2827,0.0406 Q0.3084,0.0448,0.3141,0.0485 Q0.3149,0.0494,0.3225,0.0494 T0.3361,0.0504 T0.3422,0.0554 T0.3357,0.0606 T0.3205,0.0618 T0.31,0.0626 Q0.3092,0.0626,0.3056,0.0659 T0.2932,0.0701 Q0.2884,0.0709,0.2843,0.0709 Q0.2811,0.0709,0.2759,0.0701 T0.2667,0.0693 Q0.2586,0.0693,0.2422,0.0718 T0.2193,0.0763 Q0.2137,0.0784,0.1831,0.079 T0.1502,0.0805 Q0.1494,0.0809,0.147,0.0809 Q0.1454,0.0809,0.1386,0.0803 T0.1277,0.0796 Q0.1173,0.0796,0.1092,0.0821 Q0.1036,0.0834,0.1036,0.0854 Q0.1036,0.0879,0.1129,0.0908 T0.1269,0.0937 Q0.1293,0.0937,0.1558,0.0991 T0.1863,0.1045 Q0.2016,0.1045,0.2193,0.1087 Q0.2225,0.1091,0.2249,0.1091 Q0.2289,0.1091,0.2357,0.1076 T0.2482,0.1054 Q0.2506,0.1049,0.2546,0.1049 Q0.2699,0.1049,0.2924,0.1085 T0.3213,0.1165 Q0.3253,0.119,0.3301,0.119 Q0.3325,0.119,0.3446,0.1161 T0.3687,0.1124 Q0.3831,0.1112,0.3863,0.1112 T0.3908,0.1118 T0.3936,0.1145 T0.3984,0.1186 Q0.4048,0.1228,0.408,0.1228 Q0.4096,0.1228,0.4161,0.1213 T0.4305,0.1195 L0.4337,0.1195 Q0.4426,0.1195,0.4474,0.1211 T0.4566,0.1246 T0.4667,0.1273 Q0.4876,0.1298,0.5116,0.1298 Q0.5365,0.1298,0.5631,0.1389 Q0.5703,0.1414,0.5751,0.1414 Q0.5783,0.1414,0.5819,0.1398 T0.5888,0.1381 Q0.5928,0.1381,0.5984,0.1398 T0.6129,0.1414 Q0.6321,0.1414,0.6498,0.1477 Q0.661,0.1514,0.6667,0.1514 Q0.6707,0.1514,0.6771,0.1501 Q0.6787,0.1497,0.6795,0.1497 Q0.6835,0.1497,0.6863,0.1526 T0.6892,0.1593 Q0.6892,0.1626,0.6876,0.1647 Q0.6851,0.1672,0.6799,0.1686 T0.6695,0.1705 T0.6566,0.1715 T0.6458,0.1725 Q0.6434,0.173,0.6402,0.173 Q0.6378,0.173,0.6317,0.1727 T0.6225,0.1725 Q0.6096,0.1725,0.5984,0.1759 Q0.5823,0.1804,0.5454,0.1804 Q0.5205,0.1804,0.5116,0.1788 L0.5084,0.1788 Q0.5036,0.1788,0.4956,0.1819 T0.4843,0.185 Q0.4434,0.1887,0.4353,0.1929 Q0.4321,0.1945,0.4289,0.1945 T0.4197,0.1922 T0.4112,0.19 T0.4072,0.1912 Q0.4032,0.1949,0.388,0.1949 Q0.3663,0.1949,0.3542,0.19 Q0.351,0.1883,0.3462,0.1883 Q0.3406,0.1883,0.3321,0.1906 T0.3153,0.1954 T0.302,0.1983 Q0.2972,0.1991,0.2859,0.1997 T0.2643,0.201 T0.245,0.2024 T0.2337,0.2041 Q0.2321,0.2045,0.2181,0.2045 T0.1851,0.207 T0.1542,0.2157 Q0.143,0.2211,0.143,0.226 Q0.143,0.2314,0.153,0.2348 T0.1719,0.2381 Q0.1791,0.2381,0.2474,0.2476 Q0.2506,0.248,0.2558,0.2489 T0.2651,0.2505 T0.2739,0.252 T0.2819,0.2526 Q0.2835,0.2526,0.2851,0.2522 L0.2859,0.2522 Q0.2948,0.2522,0.3104,0.2574 T0.3309,0.2671 Q0.3333,0.2696,0.3365,0.2696 Q0.339,0.2696,0.3442,0.2684 T0.3526,0.2671 T0.3582,0.2679 Q0.3687,0.2717,0.3968,0.2742 Q0.4,0.2746,0.4036,0.2771 T0.4096,0.2796 Q0.4112,0.2796,0.4137,0.2787 Q0.4169,0.2779,0.4257,0.2779 Q0.4594,0.2779,0.4779,0.2849 Q0.4876,0.2891,0.4972,0.2891 Q0.4996,0.2891,0.506,0.2887 T0.5165,0.2883 Q0.5253,0.2883,0.5305,0.2889 T0.541,0.292 T0.5494,0.299 L0.5494,0.3015 Q0.5494,0.3036,0.5466,0.3051 T0.5386,0.3073 T0.5285,0.3086 T0.5181,0.3094 T0.5108,0.3102 Q0.5068,0.3107,0.494,0.3121 L0.4683,0.315 T0.4506,0.3181 Q0.449,0.3181,0.4426,0.32 T0.4313,0.3229 T0.4197,0.3256 T0.4064,0.3281 T0.3952,0.3289 Q0.3888,0.3289,0.3855,0.3273 Q0.3783,0.3243,0.3703,0.3243 Q0.3598,0.3243,0.351,0.3297 Q0.3478,0.3314,0.3422,0.3314 Q0.3398,0.3314,0.3337,0.3306 T0.3245,0.3297 T0.3189,0.3306 Q0.3149,0.3314,0.2956,0.3328 T0.2715,0.3368 Q0.2691,0.338,0.2635,0.3391 T0.2522,0.3407 T0.2406,0.3424 T0.2313,0.3447 Q0.2305,0.3447,0.2213,0.348 T0.206,0.354 T0.1924,0.3621 T0.1815,0.3733 Q0.1767,0.3816,0.1767,0.3849 Q0.1767,0.387,0.1783,0.3893 T0.1847,0.3961 T0.1936,0.4063 T0.2004,0.4181 T0.2052,0.4264 T0.2145,0.4309 T0.2386,0.4359 Q0.2458,0.4372,0.2554,0.4372 Q0.2578,0.4372,0.2627,0.437 T0.2699,0.4367 Q0.2795,0.4367,0.2851,0.4384 Q0.294,0.4409,0.3092,0.4409 Q0.3116,0.4409,0.3157,0.4407 T0.3213,0.4405 Q0.3301,0.4405,0.3466,0.444 T0.3687,0.4509 Q0.3703,0.4517,0.3703,0.4525 Q0.3703,0.4575,0.3373,0.4596 Q0.3133,0.4608,0.2988,0.4658 Q0.294,0.4674,0.2803,0.4674 Q0.2763,0.4674,0.2687,0.4672 T0.257,0.467 Q0.2402,0.467,0.2313,0.4687 Q0.2209,0.4708,0.2209,0.4737 Q0.2209,0.4741,0.2213,0.4749 T0.2229,0.4764 L0.2249,0.4774 T0.2265,0.4778 L0.2273,0.4782 Q0.2498,0.4803,0.2618,0.4803 Q0.2667,0.4803,0.2691,0.4799 Q0.2699,0.4795,0.2715,0.4795 Q0.2779,0.4795,0.3133,0.4873 Q0.3181,0.4886,0.3233,0.4892 T0.3386,0.4905 T0.3542,0.4915 T0.3655,0.4919 Q0.3703,0.4919,0.3779,0.4915 T0.3888,0.4911 T0.3952,0.4915 Q0.3976,0.4919,0.4008,0.4927 L0.4072,0.4944 T0.4149,0.4961 T0.4249,0.4975 T0.4369,0.4985 Q0.449,0.499,0.4554,0.5 T0.4651,0.5031 T0.4699,0.5085 Q0.4707,0.5093,0.4707,0.5097 Q0.4707,0.5114,0.4687,0.5124 T0.4631,0.5139 T0.4562,0.5145 T0.4478,0.5147 L0.4402,0.5147 Q0.4353,0.5151,0.4265,0.5174 T0.4096,0.5197 L0.4024,0.5197 Q0.4,0.5193,0.3968,0.5193 Q0.3896,0.5193,0.3831,0.5209 T0.3703,0.5253 T0.3598,0.5288 Q0.3558,0.5301,0.3321,0.5342 T0.302,0.5409 Q0.2876,0.5454,0.2337,0.55 Q0.2112,0.5521,0.2112,0.5558 Q0.2112,0.5574,0.2161,0.5612 Q0.2201,0.5637,0.2281,0.5637 Q0.2305,0.5637,0.2361,0.5633 T0.2442,0.5628 Q0.2474,0.5628,0.2498,0.5633 Q0.2635,0.5653,0.3133,0.5653 Q0.3261,0.5653,0.3301,0.5649 L0.3325,0.5649 Q0.3349,0.5649,0.3402,0.5657 T0.3494,0.5666 Q0.3542,0.5666,0.3598,0.5657 Q0.3663,0.5645,0.3695,0.5645 Q0.3735,0.5645,0.3775,0.5666 T0.3847,0.5695 Q0.3888,0.5707,0.3912,0.5709 T0.3968,0.5711 T0.4048,0.572 Q0.4096,0.5724,0.4165,0.5726 T0.4281,0.5734 T0.4378,0.5757 Q0.4418,0.5774,0.4522,0.5774 Q0.4562,0.5774,0.4655,0.5769 T0.4795,0.5765 Q0.4932,0.5765,0.4972,0.579 Q0.5028,0.5819,0.51,0.5819 Q0.5141,0.5819,0.5221,0.5809 T0.5341,0.5798 L0.5373,0.5798 Q0.5422,0.5798,0.557,0.5821 T0.5855,0.5844 L0.5936,0.5844 L0.5992,0.5844 T0.604,0.5848 T0.6076,0.5852 T0.6108,0.5859 T0.6137,0.5865 T0.6161,0.5873 T0.6181,0.5881 T0.6209,0.5896 L0.6233,0.591 Q0.6265,0.5927,0.6353,0.5927 L0.6402,0.5927 L0.645,0.5927 Q0.6723,0.5927,0.6948,0.6039 Q0.6988,0.606,0.7036,0.606 Q0.7076,0.606,0.7153,0.6045 T0.7261,0.6031 Q0.7309,0.6031,0.7454,0.6027 T0.7647,0.6022 Q0.7783,0.6022,0.808,0.608 L0.812,0.608 Q0.8169,0.608,0.8293,0.6062 T0.8474,0.6039 L0.8506,0.6039 Q0.857,0.6039,0.8655,0.6049 T0.8835,0.6074 T0.8972,0.6093 Q0.9036,0.6101,0.9213,0.6101 L0.9398,0.6101 L0.959,0.6101 L0.9767,0.6101 Q0.9976,0.6109,0.9976,0.6176 Q0.9976,0.6188,0.9968,0.6226 Q0.9952,0.6284,0.9671,0.6284 L0.959,0.6284 L0.9526,0.6284 Q0.9486,0.6284,0.9382,0.6302 T0.9205,0.6321 L0.9173,0.6321 Q0.9133,0.6317,0.9092,0.6317 Q0.9012,0.6317,0.8715,0.6346 Q0.8233,0.6387,0.7944,0.6421 Q0.7888,0.6429,0.7831,0.6429 Q0.7783,0.6429,0.7731,0.6425 T0.7663,0.6421 L0.7622,0.6421 Q0.7614,0.6425,0.7586,0.6425 T0.7474,0.6421 T0.7349,0.6416 Q0.7261,0.6416,0.7221,0.6429 Q0.7173,0.645,0.7032,0.646 T0.6711,0.6479 T0.6482,0.6491 Q0.645,0.6495,0.6418,0.6495 Q0.6353,0.6495,0.6273,0.6474 T0.6161,0.6454 Q0.612,0.6454,0.6088,0.6477 T0.6,0.6499 Q0.5912,0.6499,0.5494,0.6578 Q0.5422,0.6591,0.5373,0.6591 Q0.5341,0.6591,0.5281,0.6584 T0.5173,0.6578 L0.5124,0.6578 Q0.5004,0.6582,0.4747,0.6632 Q0.4675,0.6649,0.4398,0.6667 T0.3851,0.6703 T0.3566,0.6719 Q0.3534,0.6723,0.3406,0.6734 T0.3141,0.6757 T0.2948,0.6773 Q0.2908,0.6781,0.2819,0.6829 T0.2618,0.6877 Q0.2482,0.6877,0.2273,0.6958 T0.1992,0.7117 Q0.1976,0.7138,0.1976,0.7155 Q0.1976,0.7188,0.2032,0.7213 T0.2181,0.7258 T0.2289,0.7292 Q0.2337,0.7308,0.2378,0.7316 L0.2458,0.7333 T0.2522,0.7345 Q0.2747,0.7399,0.2835,0.7399 Q0.29,0.7399,0.3048,0.7408 T0.3253,0.7416 Q0.3277,0.7416,0.3297,0.7414 T0.3341,0.7412 L0.3598,0.7445 Q0.3639,0.7449,0.3663,0.7449 Q0.3695,0.7449,0.3751,0.7443 T0.3855,0.7437 L0.3904,0.7437 Q0.3984,0.7441,0.4141,0.7472 T0.4353,0.7507 Q0.4434,0.752,0.4434,0.7553 Q0.4434,0.7578,0.439,0.7605 T0.4297,0.764 Q0.4257,0.7648,0.4201,0.7655 T0.4076,0.7665 T0.3984,0.7673 Q0.3968,0.7673,0.3912,0.7677 T0.3815,0.7688 T0.3735,0.771 T0.3655,0.7727 Q0.3606,0.7727,0.3534,0.7708 T0.3458,0.769 L0.3446,0.769 Q0.3414,0.769,0.3297,0.7713 T0.3149,0.7735 Q0.3092,0.7735,0.296,0.7771 T0.2771,0.7831 Q0.2683,0.7872,0.2554,0.7885 Q0.253,0.7889,0.2325,0.7897 T0.2032,0.7914 Q0.2008,0.7918,0.198,0.792 T0.194,0.7924 T0.1912,0.7928 T0.1888,0.793 T0.1867,0.7934 T0.1851,0.7943 T0.1843,0.7953 T0.1835,0.7968 T0.1823,0.7984 T0.1815,0.8001 Q0.1815,0.8022,0.1847,0.8032 T0.1932,0.8053 T0.2008,0.8071 Q0.2072,0.8092,0.2265,0.8092 Q0.2361,0.8092,0.2586,0.8088 L0.2635,0.8088 Q0.2731,0.8088,0.2795,0.8098 T0.2928,0.8134 T0.302,0.8167 Q0.306,0.8179,0.3277,0.8183 T0.3542,0.8221 Q0.359,0.8246,0.3622,0.8246 Q0.3639,0.8246,0.3675,0.8237 T0.3751,0.8229 Q0.3968,0.8229,0.4048,0.8275 Q0.4088,0.8291,0.4161,0.8291 Q0.4225,0.8291,0.4353,0.8275 Q0.4369,0.827,0.4394,0.827 Q0.4474,0.827,0.4675,0.8345 Q0.4707,0.8358,0.4739,0.8358 Q0.4755,0.8358,0.4799,0.8353 T0.4876,0.8349 Q0.494,0.8349,0.5012,0.8362 L0.5076,0.837 T0.5133,0.8376 T0.5181,0.8382 T0.5221,0.8391 L0.5253,0.8399 T0.5277,0.8409 L0.5293,0.8422 T0.5301,0.8438 L0.5301,0.8461 Q0.5301,0.8499,0.5249,0.8511 T0.5112,0.8526 T0.5004,0.8532 Q0.4964,0.854,0.4851,0.8546 T0.4667,0.8565 Q0.4578,0.8577,0.441,0.8577 L0.4345,0.8577 L0.4289,0.8577 L0.4209,0.8577 Q0.4153,0.8582,0.4088,0.8586 T0.3968,0.8592 T0.3855,0.8594 T0.3755,0.8596 T0.3675,0.86 T0.3622,0.8602 Q0.3317,0.8635,0.3237,0.8635 Q0.2996,0.8635,0.2996,0.8681 Q0.2996,0.8698,0.3032,0.8733 T0.3068,0.8797 L0.3068,0.8822 Q0.3052,0.8859,0.2859,0.8859 Q0.2787,0.8859,0.2739,0.8851 L0.2699,0.8851 Q0.2659,0.8851,0.259,0.888 T0.2498,0.8913 Q0.2394,0.8946,0.2056,0.8971 Q0.2032,0.8971,0.1928,0.9002 T0.1703,0.9034 Q0.1526,0.9034,0.1353,0.9067 T0.1173,0.915 L0.1173,0.9158 Q0.1173,0.9166,0.1177,0.9175 T0.1189,0.9191 T0.1205,0.9204 T0.1229,0.9212 T0.1257,0.922 T0.1285,0.9226 T0.1309,0.9231 T0.1337,0.9235 T0.1365,0.9237 L0.1446,0.9237 T0.1554,0.9243 T0.1614,0.9268 T0.1659,0.9293 T0.1743,0.9303 T0.1823,0.9316 Q0.1863,0.932,0.1912,0.9332 T0.2028,0.9361 T0.2153,0.939 Q0.2233,0.9411,0.2297,0.9448 T0.2386,0.9494 Q0.2426,0.9506,0.2506,0.9506 Q0.253,0.9506,0.2594,0.9504 T0.2699,0.9502 Q0.2763,0.9502,0.2819,0.9511 Q0.2851,0.9511,0.2871,0.9529 T0.2892,0.9573 Q0.2892,0.9627,0.2811,0.9635 Q0.2434,0.9652,0.2337,0.9672 Q0.2257,0.9693,0.2241,0.9693 Q0.2217,0.9693,0.2096,0.9689 L0.2056,0.9689 Q0.1976,0.9689,0.1924,0.9699 T0.1787,0.9741 L0.1647,0.9793 Q0.1518,0.983,0.1285,0.983 L0.1261,0.983 L0.1237,0.983 Q0.1124,0.983,0.1076,0.9838 Q0.102,0.9851,0.0839,0.9896 T0.0602,0.9954 T0.0406,0.9971 T0.0153,0.9979 L0.0032,0.9979 Z",type:0}},"":{type:5,data:{d:"M0.9992,0.998 Q0.9992,1,0.9968,1 Q0.9521,1,0.9392,0.998 Q0.9335,0.997,0.9152,0.9921 T0.8913,0.9862 Q0.8873,0.9852,0.8783,0.9852 L0.8747,0.9852 L0.871,0.9852 Q0.8483,0.9852,0.8345,0.9812 Q0.8289,0.9792,0.8228,0.9773 T0.8135,0.9743 T0.8054,0.9723 T0.7948,0.9713 L0.7908,0.9713 L0.777,0.9713 T0.7656,0.9693 Q0.7616,0.9683,0.7498,0.9674 T0.7283,0.9664 L0.7186,0.9654 Q0.708,0.9644,0.708,0.9575 Q0.708,0.9545,0.7109,0.952 T0.7178,0.9486 L0.7315,0.9486 L0.7417,0.9486 L0.7502,0.9486 Q0.7575,0.9486,0.7599,0.9476 Q0.7616,0.9466,0.7685,0.9426 T0.7843,0.9377 Q0.7899,0.9357,0.8009,0.9332 T0.8175,0.9298 Q0.82,0.9288,0.8228,0.9283 T0.8277,0.9278 T0.8313,0.9273 T0.8341,0.9263 T0.8362,0.9258 Q0.8402,0.9219,0.854,0.9219 L0.8569,0.9219 L0.8597,0.9219 L0.8637,0.9219 Q0.88,0.9199,0.88,0.9159 L0.88,0.9149 Q0.88,0.913,0.8719,0.911 T0.852,0.9075 T0.8297,0.906 Q0.8224,0.906,0.8167,0.905 T0.8074,0.9031 T0.8001,0.9006 T0.794,0.8991 Q0.7599,0.8971,0.7494,0.8942 Q0.7461,0.8932,0.7397,0.8902 T0.7299,0.8872 L0.7267,0.8872 Q0.721,0.8882,0.7121,0.8882 Q0.6926,0.8882,0.691,0.8833 L0.691,0.8803 Q0.691,0.8773,0.6922,0.8749 T0.6955,0.8704 L0.6975,0.8684 Q0.6926,0.8655,0.6764,0.8655 Q0.6683,0.8655,0.6375,0.8625 Q0.6358,0.8625,0.629,0.862 T0.6148,0.8615 T0.5973,0.861 T0.5791,0.8605 L0.5718,0.8605 L0.5661,0.8605 L0.5596,0.8605 Q0.5426,0.8605,0.5337,0.8586 Q0.5264,0.8576,0.515,0.8571 T0.4996,0.8556 Q0.498,0.8556,0.4947,0.8551 T0.4882,0.8546 T0.4809,0.8541 T0.474,0.8531 T0.4692,0.8506 T0.4672,0.8467 Q0.4672,0.8437,0.468,0.8422 T0.4704,0.8398 T0.4736,0.8383 T0.4781,0.8368 T0.4838,0.8358 T0.4911,0.8353 T0.4988,0.8338 Q0.5069,0.8328,0.5142,0.8328 Q0.5174,0.8328,0.5215,0.8333 T0.5264,0.8338 Q0.5296,0.8338,0.532,0.8328 Q0.5523,0.8249,0.5604,0.8249 L0.5653,0.8249 Q0.5775,0.8269,0.5848,0.8269 Q0.5912,0.8269,0.5937,0.8259 Q0.6026,0.821,0.6253,0.821 Q0.6294,0.821,0.6334,0.822 T0.6383,0.8229 Q0.6399,0.8229,0.644,0.82 Q0.6504,0.817,0.6723,0.816 T0.6975,0.814 Q0.6999,0.814,0.7048,0.8121 T0.7129,0.8091 T0.7226,0.8071 T0.7372,0.8061 L0.7421,0.8061 Q0.7624,0.8071,0.7721,0.8071 Q0.7924,0.8071,0.7981,0.8051 Q0.8021,0.8032,0.807,0.8027 T0.8135,0.8017 T0.8151,0.8002 L0.8151,0.7992 Q0.8143,0.7962,0.8127,0.7957 T0.8045,0.7943 Q0.7997,0.7943,0.7964,0.7933 Q0.7883,0.7933,0.7676,0.7923 T0.7437,0.7903 Q0.7307,0.7893,0.7218,0.7844 Q0.7194,0.7834,0.7141,0.7819 L0.7036,0.7789 T0.693,0.7765 T0.6853,0.7755 Q0.6805,0.7755,0.6691,0.773 T0.6553,0.7705 Q0.6545,0.7705,0.6545,0.7715 Q0.6537,0.7715,0.65,0.7725 T0.6423,0.774 T0.635,0.7745 Q0.6294,0.7745,0.6257,0.773 T0.618,0.771 T0.6083,0.77 T0.601,0.7695 Q0.5985,0.7695,0.5921,0.769 T0.5795,0.7676 T0.5702,0.7666 Q0.5653,0.7656,0.5596,0.7616 T0.5539,0.7547 Q0.5539,0.7498,0.5645,0.7488 Q0.5693,0.7478,0.5852,0.7448 T0.6099,0.7418 L0.6148,0.7418 Q0.6196,0.7418,0.6253,0.7423 T0.6338,0.7428 L0.6399,0.7428 Q0.6431,0.7418,0.6488,0.7409 T0.6586,0.7394 T0.6659,0.7389 L0.6707,0.7389 Q0.6723,0.7399,0.6748,0.7399 Q0.6796,0.7399,0.6946,0.7389 T0.7161,0.7379 Q0.7251,0.7379,0.7478,0.7319 Q0.7494,0.7319,0.7539,0.7315 T0.762,0.73 T0.7697,0.727 T0.7818,0.723 T0.7948,0.7196 T0.7997,0.7151 Q0.7997,0.7141,0.7989,0.7132 Q0.7924,0.7062,0.7717,0.6978 T0.738,0.6894 Q0.7267,0.6894,0.717,0.6845 T0.7048,0.6795 Q0.6975,0.6785,0.6711,0.6766 T0.6431,0.6746 Q0.6415,0.6736,0.6144,0.6721 T0.5596,0.6686 T0.5247,0.6657 Q0.4996,0.6607,0.4874,0.6597 L0.4834,0.6597 Q0.4785,0.6597,0.4724,0.6607 T0.4631,0.6617 Q0.4574,0.6617,0.4501,0.6597 Q0.4088,0.6518,0.4006,0.6518 Q0.3933,0.6518,0.3901,0.6499 T0.3844,0.6479 T0.3739,0.6499 T0.3585,0.6518 L0.352,0.6518 Q0.3471,0.6508,0.335,0.6503 T0.3122,0.6494 T0.2912,0.6479 T0.2766,0.6449 Q0.2733,0.6439,0.2668,0.6439 Q0.2628,0.6439,0.2543,0.6444 T0.2425,0.6449 T0.2368,0.6439 L0.2344,0.6439 Q0.2336,0.6439,0.2283,0.6444 T0.2182,0.6449 Q0.2117,0.6449,0.2052,0.6439 Q0.1768,0.6409,0.1281,0.637 Q0.0989,0.634,0.0916,0.634 L0.0835,0.634 L0.0795,0.634 Q0.0722,0.634,0.0616,0.632 T0.0479,0.6301 Q0.0462,0.6301,0.0406,0.6306 T0.0308,0.6311 Q0.0032,0.6311,0.0008,0.6231 Q0,0.6202,0,0.6182 Q0,0.6083,0.0227,0.6083 Q0.03,0.6073,0.0422,0.6073 Q0.0487,0.6073,0.0608,0.6078 T0.0787,0.6083 Q0.0973,0.6083,0.103,0.6073 Q0.1062,0.6063,0.1131,0.6053 T0.1253,0.6039 T0.1375,0.6024 T0.1492,0.6014 L0.1533,0.6014 Q0.1598,0.6024,0.1723,0.6044 T0.189,0.6063 Q0.1906,0.6063,0.1922,0.6053 Q0.2214,0.6004,0.236,0.6004 Q0.2409,0.6004,0.2551,0.6009 T0.2741,0.6014 Q0.2782,0.6014,0.2859,0.6024 T0.2968,0.6034 Q0.3009,0.6034,0.3041,0.6024 Q0.3277,0.5905,0.356,0.5905 L0.3613,0.5905 L0.3666,0.5905 Q0.3731,0.5905,0.3755,0.5895 Q0.382,0.5856,0.3844,0.5846 T0.3938,0.5831 T0.4144,0.5826 T0.4428,0.5801 T0.4631,0.5776 L0.4663,0.5776 Q0.4704,0.5776,0.4785,0.5786 T0.4899,0.5796 Q0.4964,0.5796,0.5012,0.5767 Q0.5069,0.5737,0.5223,0.5737 Q0.5272,0.5737,0.5369,0.5742 T0.5499,0.5747 Q0.558,0.5747,0.5612,0.5737 Q0.5661,0.5717,0.5714,0.5712 T0.5835,0.5702 T0.5945,0.5692 T0.6018,0.5687 L0.6062,0.5687 T0.6095,0.5682 T0.6148,0.5678 Q0.6172,0.5668,0.6196,0.5653 T0.6245,0.5633 T0.631,0.5628 T0.6407,0.5638 T0.6504,0.5648 T0.6594,0.5638 T0.6675,0.5628 L0.6707,0.5628 L0.6861,0.5628 Q0.7364,0.5628,0.7494,0.5608 L0.7567,0.5608 L0.7652,0.5608 L0.7729,0.5608 Q0.7794,0.5608,0.7818,0.5589 Q0.7851,0.5569,0.7859,0.5559 Q0.7835,0.5539,0.7656,0.5519 Q0.7121,0.547,0.6975,0.543 Q0.6934,0.541,0.6853,0.5396 L0.6691,0.5366 T0.6525,0.5336 T0.6391,0.5312 Q0.6367,0.5302,0.6245,0.5257 T0.6034,0.5213 L0.5977,0.5213 Q0.5945,0.5223,0.5904,0.5223 Q0.5839,0.5223,0.5787,0.5208 T0.5685,0.5183 T0.5596,0.5173 Q0.558,0.5173,0.5552,0.5168 T0.5495,0.5163 L0.5434,0.5163 T0.5373,0.5158 T0.532,0.5148 T0.5284,0.5129 T0.5272,0.5104 L0.5272,0.5074 Q0.5304,0.5015,0.5377,0.499 T0.5629,0.4965 Q0.5734,0.4955,0.5811,0.4946 T0.5953,0.4916 T0.605,0.4896 Q0.6083,0.4886,0.6123,0.4886 Q0.6148,0.4886,0.6225,0.4891 T0.635,0.4896 L0.6456,0.4896 Q0.6837,0.4857,0.6861,0.4857 Q0.7226,0.4768,0.7283,0.4768 Q0.7307,0.4768,0.732,0.4773 T0.7372,0.4777 Q0.7502,0.4777,0.7721,0.4758 Q0.7753,0.4748,0.777,0.4738 Q0.7745,0.4718,0.768,0.4708 Q0.7599,0.4688,0.7445,0.4688 Q0.7405,0.4688,0.7324,0.4693 T0.721,0.4698 Q0.7056,0.4698,0.6999,0.4679 Q0.6861,0.4629,0.6626,0.4619 Q0.6586,0.4609,0.6533,0.4604 T0.6419,0.459 T0.6314,0.456 T0.6269,0.452 Q0.6269,0.451,0.6302,0.4491 Q0.6358,0.4451,0.6525,0.4416 T0.6788,0.4382 L0.6845,0.4382 L0.6902,0.4382 Q0.7064,0.4382,0.7145,0.4362 Q0.7202,0.4342,0.7307,0.4342 L0.7356,0.4342 L0.7409,0.4342 L0.7453,0.4342 Q0.7543,0.4342,0.7607,0.4332 Q0.7778,0.4313,0.7847,0.4288 T0.7932,0.4248 T0.7972,0.4169 T0.8045,0.4045 L0.8094,0.3986 T0.8135,0.3942 L0.8167,0.3912 T0.8191,0.3887 T0.8204,0.3867 T0.8208,0.3848 Q0.8208,0.3818,0.8167,0.3739 Q0.8127,0.3689,0.8054,0.3635 T0.7924,0.3556 T0.7778,0.3497 T0.768,0.3462 Q0.764,0.3442,0.7478,0.3427 T0.7267,0.3383 Q0.7234,0.3363,0.7044,0.3348 T0.6805,0.3323 L0.6764,0.3323 T0.6679,0.3328 T0.6586,0.3333 Q0.6521,0.3333,0.648,0.3314 Q0.6391,0.3264,0.6294,0.3264 Q0.6229,0.3264,0.6156,0.3294 Q0.6115,0.3304,0.6042,0.3304 Q0.5977,0.3304,0.5888,0.3289 T0.5738,0.3264 T0.5584,0.3225 L0.5491,0.3195 Q0.5418,0.3185,0.5162,0.3155 T0.4895,0.3121 T0.4826,0.3116 T0.4716,0.3111 T0.4607,0.3096 T0.4513,0.3066 T0.4477,0.3017 Q0.4477,0.2997,0.4485,0.2977 Q0.4526,0.2898,0.4611,0.2878 T0.4842,0.2859 Q0.4882,0.2859,0.4943,0.2864 T0.5028,0.2868 Q0.5118,0.2868,0.5215,0.2829 Q0.5401,0.276,0.5734,0.276 Q0.5831,0.276,0.5872,0.277 L0.5904,0.277 T0.5949,0.2745 T0.6034,0.272 Q0.631,0.269,0.6407,0.2661 Q0.6448,0.2641,0.6488,0.2641 T0.6573,0.2656 T0.6634,0.2671 Q0.6659,0.2671,0.6675,0.2651 Q0.6723,0.2601,0.6886,0.2552 T0.7137,0.2502 L0.7153,0.2502 L0.7178,0.2502 Q0.7218,0.2502,0.7279,0.2493 T0.7417,0.2468 T0.7526,0.2453 Q0.8208,0.2354,0.8281,0.2354 Q0.8337,0.2354,0.8394,0.2344 T0.8496,0.2315 T0.854,0.2265 Q0.854,0.2216,0.8443,0.2176 Q0.8354,0.2127,0.8216,0.2102 T0.7972,0.2072 T0.777,0.2067 T0.7648,0.2057 Q0.7632,0.2047,0.7498,0.2038 T0.7202,0.2018 T0.6983,0.1998 Q0.6918,0.1998,0.676,0.1949 T0.6537,0.1899 Q0.6496,0.1899,0.6472,0.1919 Q0.6342,0.1968,0.6123,0.1968 Q0.5961,0.1968,0.5912,0.1929 Q0.5904,0.1919,0.5892,0.1919 T0.5823,0.1944 T0.5722,0.1968 T0.5637,0.1949 Q0.5556,0.1909,0.5158,0.1869 Q0.5109,0.1869,0.5032,0.1835 T0.4915,0.18 Q0.4907,0.18,0.4891,0.181 Q0.4793,0.182,0.455,0.182 Q0.4177,0.182,0.4015,0.1771 Q0.3901,0.1741,0.3779,0.1741 Q0.3747,0.1741,0.369,0.1746 T0.3609,0.1751 Q0.3569,0.1751,0.3536,0.1741 Q0.3512,0.1741,0.3459,0.1736 T0.3358,0.1726 T0.3256,0.1716 T0.3167,0.1696 T0.3106,0.1662 Q0.3082,0.1632,0.3082,0.1592 Q0.3082,0.1543,0.3114,0.1508 T0.3204,0.1474 L0.3236,0.1474 Q0.3301,0.1494,0.3333,0.1494 Q0.339,0.1494,0.3496,0.1454 Q0.3674,0.1385,0.3869,0.1385 Q0.395,0.1385,0.4011,0.137 T0.4116,0.1355 T0.4197,0.1375 T0.425,0.1395 Q0.429,0.1395,0.4355,0.1365 Q0.4631,0.1266,0.4882,0.1266 Q0.5126,0.1266,0.5337,0.1246 Q0.5369,0.1246,0.5458,0.1207 T0.5661,0.1167 L0.5693,0.1167 Q0.5791,0.1177,0.5852,0.1187 T0.5921,0.1197 Q0.5945,0.1197,0.6002,0.1167 Q0.6026,0.1147,0.605,0.1123 T0.6091,0.1093 T0.6156,0.1088 T0.6318,0.1098 Q0.6456,0.1108,0.6569,0.1137 T0.6707,0.1167 Q0.674,0.1167,0.6772,0.1147 Q0.6821,0.1108,0.6946,0.1083 T0.721,0.1044 T0.7453,0.1029 L0.7526,0.1029 Q0.7583,0.1039,0.7652,0.1053 T0.7753,0.1068 Q0.7778,0.1068,0.7802,0.1058 Q0.7981,0.1019,0.8143,0.1019 Q0.8175,0.1019,0.8439,0.0964 T0.8735,0.091 Q0.8759,0.091,0.8836,0.089 T0.8938,0.0851 Q0.8929,0.0841,0.8905,0.0841 Q0.8832,0.0821,0.8735,0.0821 Q0.8694,0.0821,0.8629,0.0826 T0.854,0.0831 Q0.8508,0.0831,0.8491,0.0821 Q0.8475,0.0821,0.8171,0.0811 T0.7802,0.0781 T0.7571,0.0737 T0.7332,0.0712 Q0.7299,0.0712,0.7247,0.0717 T0.7161,0.0722 L0.7064,0.0722 Q0.7032,0.0712,0.7003,0.0707 T0.6959,0.0692 T0.693,0.0678 T0.6914,0.0663 T0.6902,0.0648 T0.689,0.0643 L0.6869,0.0643 L0.6845,0.0643 L0.6821,0.0643 Q0.6553,0.0643,0.6553,0.0554 T0.6796,0.0465 L0.6813,0.0465 L0.6845,0.0465 Q0.6918,0.0425,0.717,0.0376 Q0.7226,0.0366,0.7267,0.0356 T0.7324,0.0336 T0.7376,0.0317 T0.747,0.0297 Q0.7518,0.0287,0.7551,0.0287 T0.762,0.0297 T0.768,0.0307 L0.7729,0.0307 Q0.7802,0.0277,0.7997,0.0267 T0.8224,0.0237 Q0.8273,0.0227,0.8341,0.0223 T0.8475,0.0193 T0.8654,0.0143 T0.8873,0.0079 Q0.9002,0.003,0.9331,0.004 T0.97,0.004 Q0.9838,0,0.9976,0.001 Q1,0.001,1,0.003 Z M0.9935,0.996 L0.9951,0.0049 Q0.9822,0.0049,0.9716,0.0079 Q0.9659,0.0099,0.9327,0.0089 T0.8897,0.0119 Q0.8775,0.0158,0.8666,0.0183 T0.85,0.0237 Q0.8418,0.0267,0.8341,0.0272 T0.8248,0.0277 Q0.82,0.0297,0.8001,0.0312 T0.7745,0.0346 Q0.7697,0.0356,0.7664,0.0356 Q0.764,0.0356,0.7603,0.0341 T0.7534,0.0326 Q0.751,0.0326,0.7478,0.0336 Q0.7429,0.0346,0.7397,0.0356 T0.7344,0.0376 T0.7283,0.0401 T0.7178,0.0425 Q0.6926,0.0465,0.6878,0.0495 Q0.6845,0.0514,0.6764,0.0514 L0.6723,0.0514 L0.6691,0.0514 Q0.6602,0.0514,0.6602,0.0554 Q0.6602,0.0574,0.6659,0.0579 T0.6796,0.0589 T0.691,0.0603 T0.6967,0.0643 T0.7072,0.0673 Q0.7121,0.0682,0.7153,0.0682 T0.7238,0.0678 T0.7332,0.0673 Q0.7413,0.0673,0.7579,0.0692 T0.7818,0.0742 Q0.7867,0.0752,0.8171,0.0762 T0.8508,0.0781 L0.852,0.0781 T0.8601,0.0776 T0.8719,0.0772 Q0.8832,0.0772,0.8921,0.0791 Q0.8994,0.0811,0.8994,0.0841 T0.8933,0.0895 T0.8812,0.094 T0.8735,0.0959 T0.8451,0.1014 T0.8143,0.1068 Q0.7989,0.1068,0.7818,0.1098 Q0.7778,0.1108,0.7745,0.1108 T0.768,0.1103 T0.7603,0.1088 T0.7518,0.1068 L0.7461,0.1068 Q0.7315,0.1068,0.7088,0.1103 T0.6805,0.1177 Q0.6756,0.1207,0.6699,0.1207 Q0.6667,0.1207,0.6545,0.1177 T0.631,0.1147 Q0.6269,0.1137,0.6225,0.1133 T0.616,0.1128 L0.6123,0.1128 T0.6103,0.1133 L0.6083,0.1157 T0.6034,0.1197 Q0.5961,0.1246,0.5921,0.1246 Q0.5904,0.1246,0.5835,0.1231 T0.5693,0.1217 L0.5661,0.1217 Q0.558,0.1217,0.5535,0.1231 T0.5446,0.1266 T0.5345,0.1296 Q0.5126,0.1316,0.4882,0.1316 T0.438,0.1405 Q0.4298,0.1434,0.425,0.1434 Q0.4209,0.1434,0.4173,0.1419 T0.4112,0.1405 T0.4027,0.1419 T0.3869,0.1434 Q0.3682,0.1434,0.3512,0.1494 Q0.3398,0.1533,0.3333,0.1533 Q0.3285,0.1533,0.3228,0.1513 L0.3212,0.1513 Q0.3179,0.1513,0.3155,0.1538 T0.3131,0.1592 Q0.3131,0.1612,0.3147,0.1632 Q0.3171,0.1652,0.3232,0.1667 T0.3406,0.1691 T0.3544,0.1701 L0.3601,0.1701 L0.3678,0.1701 L0.3771,0.1701 Q0.3909,0.1701,0.4031,0.1731 Q0.4177,0.178,0.4558,0.178 Q0.4793,0.178,0.4882,0.1761 L0.4915,0.1761 Q0.498,0.1761,0.5061,0.179 T0.5158,0.183 Q0.5166,0.183,0.5231,0.1835 T0.5341,0.1845 T0.545,0.1855 T0.5572,0.1874 T0.5661,0.1909 Q0.5677,0.1919,0.5702,0.1919 T0.5791,0.1894 T0.588,0.1869 Q0.5921,0.1869,0.5945,0.1899 Q0.5977,0.1919,0.6123,0.1919 Q0.6334,0.1919,0.6448,0.1879 Q0.6488,0.186,0.6537,0.186 Q0.6626,0.186,0.6784,0.1909 T0.6983,0.1958 Q0.704,0.1968,0.7206,0.1973 T0.7506,0.1993 T0.7689,0.2018 L0.7705,0.2018 L0.7741,0.2018 L0.7786,0.2018 Q0.8248,0.2018,0.8475,0.2136 Q0.8597,0.2196,0.8597,0.2255 T0.8483,0.2359 T0.8281,0.2404 Q0.8208,0.2404,0.7534,0.2493 Q0.7502,0.2502,0.7425,0.2512 T0.7287,0.2532 T0.7178,0.2542 L0.7153,0.2542 L0.7137,0.2542 Q0.7064,0.2542,0.6906,0.2591 T0.6715,0.2681 T0.6626,0.272 Q0.6594,0.272,0.6541,0.2705 T0.6464,0.269 T0.6431,0.27 Q0.6318,0.273,0.6034,0.276 Q0.6018,0.276,0.5998,0.2774 T0.5957,0.2799 T0.5904,0.2809 L0.5856,0.2809 Q0.5823,0.2799,0.575,0.2799 Q0.541,0.2799,0.5239,0.2868 Q0.5134,0.2908,0.5028,0.2908 Q0.4996,0.2908,0.4935,0.2903 T0.4842,0.2898 Q0.4704,0.2898,0.4635,0.2918 T0.4534,0.2997 L0.4534,0.3007 Q0.4534,0.3037,0.459,0.3046 T0.4753,0.3066 T0.4899,0.3076 Q0.4907,0.3076,0.5166,0.3106 T0.5507,0.3155 Q0.5921,0.3264,0.605,0.3264 Q0.6107,0.3264,0.6131,0.3254 Q0.6212,0.3225,0.6294,0.3225 Q0.6407,0.3225,0.6513,0.3274 Q0.6529,0.3294,0.6569,0.3294 Q0.6594,0.3294,0.665,0.3284 T0.6748,0.3274 T0.6821,0.3284 Q0.6861,0.3294,0.6967,0.3299 T0.7165,0.3314 T0.7299,0.3343 Q0.7324,0.3363,0.7486,0.3383 T0.7697,0.3422 Q0.7713,0.3432,0.7774,0.3452 T0.7887,0.3492 T0.8005,0.3546 T0.8127,0.3625 T0.8208,0.3719 Q0.8256,0.3798,0.8256,0.3848 Q0.8256,0.3877,0.8236,0.3902 T0.8171,0.3976 T0.809,0.4075 T0.8021,0.4189 T0.7968,0.4273 T0.7867,0.4322 T0.7616,0.4382 Q0.7543,0.4392,0.7437,0.4392 L0.7364,0.4392 L0.7299,0.4392 Q0.7202,0.4392,0.7161,0.4402 Q0.7072,0.4431,0.691,0.4431 L0.6845,0.4431 L0.6788,0.4431 Q0.6707,0.4431,0.6545,0.4461 T0.6334,0.452 Q0.6399,0.456,0.6626,0.457 Q0.6878,0.458,0.7024,0.4639 Q0.7064,0.4649,0.7186,0.4649 L0.7295,0.4649 L0.7413,0.4649 Q0.7591,0.4649,0.7697,0.4669 Q0.7818,0.4688,0.7818,0.4728 Q0.7818,0.4748,0.7798,0.4763 T0.7753,0.4787 L0.7737,0.4797 L0.7729,0.4797 Q0.7494,0.4827,0.7388,0.4827 Q0.7332,0.4827,0.7307,0.4817 L0.7291,0.4817 Q0.7226,0.4817,0.6878,0.4896 Q0.6829,0.4906,0.6772,0.4911 T0.6618,0.4921 T0.646,0.4931 T0.6342,0.4936 T0.6212,0.4931 T0.6115,0.4926 Q0.6083,0.4926,0.6058,0.4931 T0.5969,0.4955 T0.5819,0.499 T0.5629,0.5005 Q0.5572,0.5005,0.5527,0.501 T0.545,0.502 T0.5397,0.503 T0.5361,0.5045 T0.5337,0.5064 T0.5328,0.5094 L0.532,0.5094 Q0.532,0.5104,0.5337,0.5109 T0.5381,0.5114 T0.5438,0.5119 T0.5515,0.5124 L0.5604,0.5124 Q0.5661,0.5134,0.5746,0.5153 T0.5912,0.5173 L0.5977,0.5173 L0.6026,0.5173 Q0.6139,0.5173,0.6273,0.5218 T0.6407,0.5272 Q0.6448,0.5282,0.6683,0.5321 T0.6991,0.5381 Q0.7137,0.543,0.7664,0.548 Q0.7908,0.55,0.7908,0.5559 Q0.7908,0.5589,0.7859,0.5628 Q0.781,0.5658,0.7713,0.5658 Q0.7689,0.5658,0.7628,0.5653 T0.7543,0.5648 T0.7502,0.5658 Q0.7364,0.5678,0.6878,0.5678 Q0.674,0.5678,0.6699,0.5668 L0.6683,0.5668 Q0.6659,0.5668,0.6606,0.5678 T0.6513,0.5687 Q0.6464,0.5687,0.6391,0.5678 Q0.6334,0.5668,0.6302,0.5668 T0.6241,0.5687 T0.6164,0.5717 Q0.6123,0.5727,0.6099,0.5727 L0.6062,0.5727 T0.6022,0.5732 T0.5953,0.5737 Q0.5904,0.5747,0.5839,0.5747 T0.5726,0.5752 T0.5629,0.5776 T0.5458,0.5796 Q0.5418,0.5796,0.5324,0.5791 T0.5191,0.5786 Q0.5077,0.5786,0.5045,0.5806 Q0.498,0.5836,0.4899,0.5836 Q0.4858,0.5836,0.4777,0.5826 T0.4655,0.5816 L0.4631,0.5816 Q0.4582,0.5816,0.4436,0.5841 T0.4144,0.5865 L0.4051,0.5865 L0.3986,0.5865 T0.3933,0.587 T0.3897,0.5875 T0.3869,0.5885 T0.3844,0.5895 T0.3812,0.591 T0.3779,0.5925 Q0.3739,0.5955,0.3633,0.5955 L0.3585,0.5955 L0.3536,0.5955 Q0.3277,0.5955,0.3066,0.6053 Q0.3017,0.6083,0.296,0.6083 Q0.2912,0.6083,0.2839,0.6068 T0.2741,0.6053 Q0.2693,0.6053,0.2547,0.6048 T0.236,0.6044 Q0.2222,0.6044,0.193,0.6103 L0.1882,0.6103 Q0.1825,0.6103,0.1703,0.6083 T0.1525,0.6063 L0.15,0.6063 Q0.1436,0.6063,0.135,0.6073 T0.1168,0.6098 T0.1038,0.6113 Q0.0973,0.6123,0.0787,0.6123 L0.06,0.6123 L0.0414,0.6123 L0.0235,0.6123 Q0.0049,0.6133,0.0049,0.6172 L0.0057,0.6222 Q0.0073,0.6261,0.043,0.6261 L0.0454,0.6261 L0.0479,0.6261 Q0.0527,0.6261,0.0633,0.6281 T0.0803,0.6301 L0.0835,0.6301 L0.0916,0.6301 Q0.0998,0.6301,0.129,0.632 Q0.1768,0.636,0.206,0.64 Q0.2117,0.6409,0.2165,0.6409 Q0.2206,0.6409,0.2263,0.6405 T0.2336,0.64 L0.2384,0.64 L0.2409,0.64 T0.251,0.6395 T0.2644,0.639 Q0.2741,0.639,0.279,0.6409 Q0.283,0.6429,0.2972,0.6439 T0.3293,0.6459 T0.3528,0.6469 L0.3577,0.6469 Q0.3642,0.6469,0.3723,0.6449 T0.3844,0.6429 Q0.3901,0.6429,0.3933,0.6454 T0.4006,0.6479 Q0.4088,0.6479,0.4517,0.6558 Q0.4582,0.6568,0.4623,0.6568 Q0.4655,0.6568,0.4716,0.6563 T0.4826,0.6558 L0.4882,0.6558 Q0.5004,0.6558,0.5255,0.6607 Q0.5328,0.6627,0.5604,0.6647 T0.6152,0.6682 T0.644,0.6696 T0.6719,0.6721 T0.7056,0.6756 Q0.7113,0.6756,0.7198,0.6805 T0.738,0.6855 Q0.7453,0.6855,0.7551,0.6879 T0.7741,0.6939 T0.7912,0.7018 T0.8029,0.7102 Q0.8054,0.7132,0.8054,0.7151 Q0.8054,0.7191,0.8009,0.7216 T0.7908,0.7255 T0.779,0.7285 T0.7721,0.731 Q0.7672,0.7329,0.7632,0.7339 T0.7551,0.7354 T0.7486,0.7369 Q0.7478,0.7369,0.7445,0.7379 T0.7388,0.7394 T0.7324,0.7404 L0.7242,0.7413 T0.7161,0.7418 Q0.7105,0.7418,0.6955,0.7428 T0.6748,0.7438 L0.6699,0.7438 L0.6667,0.7438 Q0.6659,0.7438,0.6407,0.7468 Q0.6367,0.7478,0.6334,0.7478 T0.6245,0.7468 T0.6148,0.7458 L0.6099,0.7458 Q0.6018,0.7468,0.5864,0.7498 T0.5653,0.7532 T0.5596,0.7557 Q0.5596,0.7596,0.571,0.7616 Q0.5742,0.7626,0.5803,0.7631 T0.5929,0.7641 T0.6018,0.7656 L0.6087,0.7656 T0.6192,0.7666 T0.6277,0.7695 Q0.631,0.7705,0.6342,0.7705 Q0.6383,0.7705,0.6452,0.7685 T0.6537,0.7666 L0.6553,0.7666 Q0.6602,0.7666,0.6711,0.769 T0.6853,0.7715 Q0.691,0.7715,0.7048,0.775 T0.7242,0.7814 Q0.7324,0.7854,0.7445,0.7864 Q0.7478,0.7864,0.768,0.7873 T0.7972,0.7893 Q0.7989,0.7893,0.8017,0.7898 T0.8054,0.7903 L0.8082,0.7903 T0.811,0.7908 T0.8131,0.7913 T0.8151,0.7918 L0.8167,0.7928 T0.8179,0.7943 T0.8191,0.7957 T0.8204,0.7977 T0.8208,0.8002 Q0.8208,0.8032,0.8171,0.8051 T0.8074,0.8081 T0.7997,0.8091 Q0.7932,0.8121,0.7737,0.8121 Q0.7664,0.8121,0.7413,0.8111 L0.7364,0.8111 Q0.7275,0.8111,0.7214,0.8121 T0.7084,0.8155 T0.6991,0.819 Q0.6934,0.82,0.6723,0.8205 T0.6472,0.8239 Q0.6423,0.8269,0.6375,0.8269 Q0.6358,0.8269,0.6338,0.8264 T0.6294,0.8254 T0.6253,0.8249 Q0.6042,0.8249,0.5961,0.8289 Q0.5921,0.8318,0.5839,0.8318 Q0.5783,0.8318,0.5645,0.8299 L0.5604,0.8299 Q0.5531,0.8299,0.5337,0.8368 Q0.5296,0.8378,0.5255,0.8378 Q0.5239,0.8378,0.5195,0.8373 T0.5118,0.8368 Q0.5061,0.8368,0.4996,0.8388 Q0.4947,0.8388,0.4882,0.8398 Q0.4777,0.8417,0.4753,0.8427 T0.4728,0.8467 Q0.4728,0.8487,0.4769,0.8492 T0.4886,0.8501 T0.5004,0.8516 Q0.5036,0.8516,0.515,0.8521 T0.5345,0.8546 Q0.5426,0.8556,0.5596,0.8556 L0.5649,0.8556 L0.5702,0.8556 L0.5791,0.8556 Q0.5921,0.8566,0.6135,0.8571 T0.6383,0.8586 Q0.6683,0.8615,0.6764,0.8615 L0.6776,0.8615 L0.6788,0.8615 Q0.7032,0.8615,0.7032,0.8684 Q0.7032,0.8714,0.6995,0.8749 T0.6959,0.8803 L0.6959,0.8813 Q0.6991,0.8843,0.7153,0.8843 Q0.7218,0.8843,0.7259,0.8833 L0.7299,0.8833 Q0.7324,0.8833,0.7348,0.8838 T0.7393,0.8848 T0.7433,0.8863 L0.7474,0.8882 T0.751,0.8892 Q0.7616,0.8922,0.7948,0.8952 Q0.7981,0.8952,0.8082,0.8981 T0.8297,0.9011 T0.8528,0.9026 T0.8747,0.907 T0.8856,0.9149 L0.8856,0.9159 Q0.8856,0.9179,0.8848,0.9189 T0.8828,0.9209 T0.88,0.9228 T0.8767,0.9243 T0.8731,0.9248 T0.8698,0.9253 T0.8666,0.9258 L0.8646,0.9258 Q0.8621,0.9258,0.8577,0.9263 T0.85,0.9268 T0.8439,0.9273 T0.8402,0.9278 Q0.8386,0.9298,0.8358,0.9308 T0.8305,0.9322 T0.8244,0.9332 T0.8183,0.9337 Q0.8135,0.9347,0.8025,0.9372 T0.7859,0.9416 Q0.7778,0.9436,0.7717,0.9471 T0.7624,0.9515 Q0.7575,0.9535,0.7486,0.9535 Q0.7461,0.9535,0.7397,0.953 T0.7291,0.9525 Q0.7234,0.9525,0.7186,0.953 T0.7137,0.957 T0.7194,0.9614 Q0.7567,0.9634,0.7664,0.9654 Q0.7745,0.9674,0.7762,0.9674 L0.7908,0.9674 Q0.7924,0.9664,0.7948,0.9664 Q0.8029,0.9664,0.8082,0.9679 T0.8224,0.9723 T0.8362,0.9773 Q0.8483,0.9812,0.871,0.9812 L0.8751,0.9812 Q0.8873,0.9812,0.8929,0.9822 T0.9165,0.9876 T0.9408,0.9931 Q0.9513,0.996,0.9935,0.996 Z M0.9968,0.998 L0.9976,0.003 Q0.9838,0.002,0.9708,0.0059 Q0.9659,0.0069,0.9327,0.0059 T0.8881,0.0099 Q0.8767,0.0138,0.8658,0.0163 T0.8491,0.0218 Q0.8418,0.0247,0.8341,0.0247 T0.8232,0.0257 Q0.8191,0.0277,0.7997,0.0292 T0.7737,0.0326 Q0.7697,0.0336,0.7672,0.0336 T0.7612,0.0321 T0.7543,0.0307 T0.747,0.0317 Q0.7397,0.0326,0.7336,0.0356 T0.717,0.0406 Q0.6918,0.0445,0.6861,0.0475 Q0.6845,0.0485,0.6772,0.0485 T0.6638,0.05 T0.6577,0.0549 T0.6642,0.0598 T0.6796,0.0613 T0.6902,0.0623 Q0.691,0.0623,0.6946,0.0658 T0.7064,0.0702 L0.7161,0.0702 Q0.7194,0.0702,0.7242,0.0697 T0.7332,0.0692 Q0.7413,0.0692,0.7579,0.0717 T0.781,0.0762 Q0.7867,0.0781,0.8171,0.0786 T0.85,0.0801 L0.8532,0.0801 Q0.8548,0.0801,0.8613,0.0796 T0.8727,0.0791 Q0.8832,0.0791,0.8913,0.0811 Q0.897,0.0831,0.897,0.0851 Q0.897,0.088,0.8873,0.0905 T0.8735,0.093 Q0.871,0.093,0.8447,0.0984 T0.8143,0.1039 Q0.7981,0.1039,0.781,0.1078 Q0.7778,0.1088,0.7745,0.1088 T0.7644,0.1073 T0.7518,0.1048 L0.7453,0.1048 Q0.7299,0.1048,0.7076,0.1083 T0.6788,0.1157 Q0.6748,0.1187,0.6699,0.1187 Q0.6675,0.1187,0.6557,0.1157 T0.6318,0.1118 Q0.6164,0.1108,0.6135,0.1108 T0.6095,0.1113 T0.6067,0.1142 T0.6018,0.1187 Q0.5953,0.1227,0.5921,0.1227 Q0.5904,0.1227,0.5839,0.1212 T0.5693,0.1187 L0.5661,0.1187 Q0.558,0.1187,0.5527,0.1207 T0.5434,0.1246 T0.5337,0.1266 Q0.5126,0.1296,0.4882,0.1296 T0.4371,0.1385 Q0.4298,0.1414,0.425,0.1414 Q0.4225,0.1414,0.4189,0.1395 T0.4112,0.1375 Q0.4079,0.1375,0.4019,0.1395 T0.3869,0.1414 Q0.3682,0.1414,0.3504,0.1474 Q0.3398,0.1513,0.3333,0.1513 Q0.3293,0.1513,0.3228,0.1494 L0.3204,0.1494 Q0.3179,0.1494,0.3155,0.1508 T0.3118,0.1543 T0.3106,0.1592 T0.3127,0.1642 T0.32,0.1677 T0.3305,0.1701 T0.3435,0.1716 T0.3544,0.1721 Q0.3569,0.1731,0.3601,0.1731 Q0.3625,0.1731,0.3686,0.1726 T0.3779,0.1721 Q0.3901,0.1721,0.4023,0.1751 Q0.4177,0.18,0.455,0.18 Q0.4793,0.18,0.4882,0.178 L0.4915,0.178 Q0.4964,0.178,0.5045,0.1815 T0.5158,0.185 Q0.5564,0.1889,0.5645,0.1929 Q0.5677,0.1939,0.571,0.1939 Q0.575,0.1939,0.5807,0.1919 T0.5888,0.1899 T0.5929,0.1909 Q0.5969,0.1949,0.6123,0.1949 Q0.6334,0.1949,0.6456,0.1899 Q0.6488,0.1879,0.6537,0.1879 Q0.661,0.1879,0.6772,0.1929 T0.6983,0.1978 Q0.704,0.1988,0.7206,0.1998 T0.7502,0.2018 T0.7664,0.2038 Q0.7672,0.2038,0.7818,0.2043 T0.8151,0.2067 T0.8459,0.2156 Q0.8573,0.2206,0.8573,0.2255 Q0.8573,0.2295,0.8516,0.2324 T0.8394,0.2369 T0.8281,0.2384 Q0.8208,0.2384,0.7526,0.2473 Q0.7494,0.2483,0.7421,0.2493 T0.7287,0.2512 T0.7178,0.2522 L0.7153,0.2522 L0.7137,0.2522 Q0.7056,0.2522,0.6898,0.2572 T0.6691,0.2671 Q0.6667,0.269,0.6634,0.269 Q0.661,0.269,0.6557,0.2681 T0.6472,0.2671 Q0.6448,0.2671,0.6415,0.2681 Q0.631,0.271,0.6034,0.274 Q0.5994,0.274,0.5961,0.2765 T0.5904,0.2789 L0.5864,0.2789 Q0.5831,0.2779,0.5742,0.2779 Q0.541,0.2779,0.5223,0.2849 Q0.5126,0.2888,0.5028,0.2888 Q0.5004,0.2888,0.4943,0.2883 T0.4842,0.2878 Q0.4704,0.2878,0.4627,0.2898 T0.4509,0.2987 Q0.4501,0.2997,0.4501,0.3007 Q0.4501,0.3046,0.4574,0.3066 T0.4765,0.3091 T0.4899,0.3096 Q0.4931,0.3106,0.5061,0.3121 T0.5316,0.315 T0.5499,0.3175 Q0.5507,0.3175,0.5572,0.3195 T0.5685,0.3225 T0.5803,0.3254 T0.5933,0.3279 T0.605,0.3284 T0.6148,0.3274 Q0.6221,0.3244,0.6294,0.3244 Q0.6399,0.3244,0.6496,0.3294 Q0.6529,0.3314,0.6577,0.3314 Q0.6602,0.3314,0.6663,0.3304 T0.6756,0.3294 T0.6813,0.3304 Q0.6837,0.3304,0.6873,0.3309 L0.6946,0.3318 T0.7024,0.3323 T0.7105,0.3328 T0.7178,0.3338 T0.7238,0.3348 T0.7283,0.3363 Q0.7324,0.3383,0.7482,0.3403 T0.7689,0.3442 Q0.7697,0.3442,0.779,0.3477 T0.794,0.3536 T0.8074,0.3615 T0.8183,0.3729 Q0.8232,0.3808,0.8232,0.3848 Q0.8232,0.3867,0.8216,0.3892 T0.8151,0.3961 T0.8062,0.406 T0.7997,0.4179 T0.7952,0.4263 T0.7855,0.4308 T0.7616,0.4362 Q0.7543,0.4372,0.7445,0.4372 L0.7372,0.4372 L0.7307,0.4372 Q0.7202,0.4372,0.7153,0.4382 Q0.7064,0.4402,0.691,0.4402 L0.6845,0.4402 L0.6788,0.4402 Q0.6699,0.4402,0.6533,0.4436 T0.6318,0.451 Q0.6302,0.451,0.6302,0.452 Q0.6302,0.457,0.6626,0.459 Q0.6869,0.4609,0.7015,0.4659 Q0.7064,0.4669,0.7202,0.4669 L0.7311,0.4669 L0.7429,0.4669 Q0.7599,0.4669,0.7689,0.4688 Q0.7794,0.4708,0.7794,0.4738 L0.7786,0.4748 T0.777,0.4763 T0.7749,0.4773 L0.7737,0.4777 L0.7729,0.4777 Q0.7502,0.4797,0.738,0.4797 L0.7315,0.4797 L0.7291,0.4797 Q0.7226,0.4797,0.6869,0.4876 Q0.6821,0.4886,0.6768,0.4891 T0.6614,0.4901 T0.6456,0.4916 L0.6342,0.4916 Q0.6294,0.4916,0.6217,0.4911 T0.6115,0.4906 Q0.6083,0.4906,0.6054,0.4911 T0.5961,0.4936 T0.5815,0.4965 T0.5629,0.4985 Q0.5507,0.4985,0.5442,0.4995 T0.5345,0.5025 T0.5304,0.5084 L0.5296,0.5094 Q0.5296,0.5114,0.5316,0.5124 T0.5373,0.5138 T0.5442,0.5143 L0.5523,0.5143 L0.5604,0.5143 Q0.5637,0.5153,0.5677,0.5158 T0.5742,0.5173 T0.5811,0.5188 T0.5904,0.5193 L0.5977,0.5193 L0.6026,0.5193 Q0.6107,0.5193,0.6168,0.5208 T0.6294,0.5252 T0.6399,0.5292 Q0.6448,0.5302,0.6679,0.5341 T0.6983,0.541 Q0.7129,0.545,0.7664,0.55 Q0.7883,0.5519,0.7883,0.5559 Q0.7883,0.5579,0.7843,0.5608 T0.7721,0.5638 Q0.7697,0.5638,0.764,0.5633 T0.7559,0.5628 L0.7502,0.5628 Q0.7364,0.5648,0.6869,0.5648 L0.6699,0.5648 L0.6675,0.5648 Q0.665,0.5648,0.6602,0.5658 T0.6513,0.5668 Q0.6464,0.5668,0.6399,0.5658 Q0.6342,0.5648,0.6302,0.5648 T0.6225,0.5668 T0.6156,0.5697 Q0.6107,0.5707,0.6087,0.5707 T0.6034,0.5712 T0.5953,0.5717 Q0.5904,0.5727,0.5835,0.5727 T0.5718,0.5732 T0.562,0.5757 Q0.558,0.5767,0.5483,0.5767 L0.5349,0.5767 L0.5207,0.5767 Q0.5069,0.5767,0.5028,0.5786 Q0.4972,0.5816,0.4899,0.5816 Q0.4858,0.5816,0.4781,0.5806 T0.4663,0.5796 L0.4631,0.5796 Q0.4582,0.5796,0.4432,0.5821 T0.4144,0.5846 L0.4071,0.5846 L0.4011,0.5846 T0.3958,0.5851 T0.3921,0.5856 T0.3889,0.5861 T0.3865,0.5865 T0.384,0.5875 L0.382,0.5885 L0.3796,0.5895 L0.3771,0.5905 Q0.3731,0.5925,0.365,0.5925 L0.3601,0.5925 L0.3552,0.5925 Q0.3277,0.5925,0.3049,0.6044 Q0.3017,0.6053,0.296,0.6053 Q0.292,0.6053,0.2847,0.6044 T0.2741,0.6034 Q0.2693,0.6034,0.2547,0.6029 T0.236,0.6024 Q0.2222,0.6024,0.1922,0.6073 Q0.1906,0.6083,0.1882,0.6083 Q0.1833,0.6083,0.1711,0.6063 T0.1533,0.6044 Q0.1517,0.6034,0.1492,0.6034 Q0.1436,0.6034,0.135,0.6048 T0.1168,0.6078 T0.103,0.6093 Q0.0973,0.6103,0.0787,0.6103 L0.0604,0.6103 L0.0414,0.6103 L0.0235,0.6103 Q0.0024,0.6113,0.0024,0.6172 Q0.0024,0.6192,0.0032,0.6231 Q0.0049,0.6281,0.0333,0.6281 L0.0414,0.6281 L0.0479,0.6281 Q0.0519,0.6281,0.0624,0.6301 T0.0803,0.632 L0.0835,0.632 L0.0916,0.632 Q0.0989,0.632,0.1281,0.634 L0.206,0.6419 Q0.2117,0.6429,0.2174,0.6429 Q0.2214,0.6429,0.2271,0.6424 T0.2344,0.6419 L0.2376,0.6419 Q0.2393,0.6429,0.2417,0.6429 T0.2526,0.6419 T0.2652,0.6409 Q0.2741,0.6409,0.2782,0.6429 T0.2968,0.6459 T0.3293,0.6479 T0.352,0.6489 Q0.3552,0.6499,0.3585,0.6499 Q0.365,0.6499,0.3731,0.6474 T0.3844,0.6449 Q0.3885,0.6449,0.3917,0.6474 T0.4006,0.6499 Q0.4088,0.6499,0.4509,0.6578 Q0.4574,0.6588,0.4631,0.6588 Q0.4655,0.6588,0.4716,0.6583 T0.4834,0.6578 L0.4874,0.6578 Q0.5004,0.6588,0.5255,0.6637 Q0.532,0.6647,0.56,0.6667 T0.6148,0.6701 T0.644,0.6716 Q0.6464,0.6726,0.6594,0.6736 T0.6861,0.6756 T0.7048,0.6775 Q0.7097,0.6775,0.7186,0.6825 T0.738,0.6874 Q0.7518,0.6874,0.7729,0.6958 T0.8005,0.7122 Q0.8029,0.7141,0.8029,0.7151 Q0.8029,0.7191,0.7968,0.7216 T0.7818,0.726 T0.7705,0.729 L0.764,0.731 T0.7583,0.7324 T0.753,0.7334 T0.7486,0.7349 Q0.7251,0.7399,0.7161,0.7399 Q0.7097,0.7399,0.6951,0.7409 T0.6748,0.7418 L0.6703,0.7418 L0.6667,0.7418 Q0.6659,0.7418,0.6399,0.7448 L0.6334,0.7448 Q0.631,0.7448,0.6249,0.7443 T0.6148,0.7438 L0.6099,0.7438 Q0.601,0.7448,0.5856,0.7473 T0.5645,0.7507 Q0.5572,0.7517,0.5572,0.7547 T0.5616,0.7606 T0.5702,0.7646 Q0.5734,0.7646,0.5779,0.7651 T0.5864,0.7661 T0.5949,0.7671 T0.6018,0.7676 L0.6071,0.7676 T0.6135,0.7681 T0.62,0.769 T0.6269,0.771 T0.6342,0.7725 Q0.6391,0.7725,0.6464,0.7705 T0.6541,0.7685 L0.6553,0.7685 Q0.6586,0.7685,0.6699,0.771 T0.6853,0.7735 Q0.6902,0.7735,0.704,0.777 T0.7226,0.7834 Q0.7315,0.7873,0.7445,0.7883 Q0.747,0.7883,0.7676,0.7893 T0.7972,0.7913 Q0.7989,0.7913,0.8017,0.7918 T0.8058,0.7923 T0.809,0.7928 T0.8114,0.7933 T0.8131,0.7938 T0.8147,0.7943 T0.8159,0.7953 L0.8171,0.7967 T0.8175,0.7982 Q0.8183,0.7992,0.8183,0.8002 Q0.8183,0.8022,0.8155,0.8032 T0.807,0.8051 T0.7989,0.8071 Q0.7932,0.8091,0.7737,0.8091 L0.7413,0.8091 L0.7372,0.8091 Q0.7275,0.8091,0.721,0.8101 T0.7072,0.8136 T0.6983,0.817 Q0.6942,0.818,0.6825,0.818 T0.6602,0.819 T0.6456,0.822 Q0.6415,0.8249,0.6375,0.8249 Q0.6367,0.8249,0.6326,0.8239 T0.6253,0.8229 Q0.6034,0.8229,0.5953,0.8279 Q0.5912,0.8289,0.5848,0.8289 Q0.5775,0.8289,0.5645,0.8279 Q0.5629,0.8269,0.5604,0.8269 Q0.5523,0.8269,0.5328,0.8348 Q0.5296,0.8358,0.5264,0.8358 Q0.5247,0.8358,0.5203,0.8353 T0.5126,0.8348 Q0.5061,0.8348,0.4988,0.8358 Q0.4947,0.8368,0.4882,0.8378 Q0.4826,0.8388,0.4797,0.8388 T0.474,0.8398 T0.4704,0.8422 T0.4696,0.8462 T0.472,0.8501 T0.4781,0.8521 T0.4854,0.8526 L0.4935,0.8526 T0.4996,0.8536 Q0.5036,0.8536,0.515,0.8546 T0.5337,0.8566 Q0.5426,0.8576,0.5596,0.8576 L0.5657,0.8576 L0.571,0.8576 L0.5791,0.8576 Q0.5921,0.8586,0.6135,0.8591 T0.6383,0.8605 Q0.6683,0.8635,0.6764,0.8635 Q0.6999,0.8635,0.6999,0.8684 Q0.6999,0.8694,0.6967,0.8734 T0.6934,0.8803 L0.6934,0.8823 Q0.6951,0.8863,0.7137,0.8863 Q0.7218,0.8863,0.7267,0.8853 L0.7299,0.8853 Q0.734,0.8853,0.7409,0.8882 T0.7502,0.8912 Q0.7607,0.8942,0.794,0.8971 Q0.7972,0.8971,0.8078,0.9001 T0.8297,0.9031 Q0.8475,0.9031,0.8646,0.9065 T0.8824,0.9149 L0.8824,0.9159 Q0.8824,0.9169,0.882,0.9179 T0.8808,0.9194 L0.8792,0.9204 T0.8767,0.9214 T0.8743,0.9224 T0.8715,0.9228 L0.8686,0.9228 T0.8662,0.9233 T0.8637,0.9238 L0.8556,0.9238 T0.8447,0.9243 T0.8386,0.9268 Q0.837,0.9278,0.835,0.9288 T0.8305,0.9303 T0.8244,0.9308 T0.8175,0.9318 Q0.8127,0.9327,0.8017,0.9352 T0.7851,0.9397 Q0.777,0.9416,0.7705,0.9451 T0.7616,0.9496 Q0.7575,0.9505,0.7494,0.9505 L0.7405,0.9505 L0.7307,0.9505 Q0.7234,0.9505,0.7178,0.9515 Q0.7145,0.9515,0.7125,0.9535 T0.7105,0.9575 Q0.7105,0.9624,0.7194,0.9634 Q0.7567,0.9654,0.7664,0.9674 Q0.7745,0.9693,0.7762,0.9693 L0.7908,0.9693 L0.7948,0.9693 Q0.8005,0.9693,0.8058,0.9698 T0.8143,0.9718 T0.824,0.9753 T0.8354,0.9792 Q0.8483,0.9832,0.871,0.9832 L0.8739,0.9832 L0.8767,0.9832 Q0.8873,0.9832,0.8921,0.9842 Q0.8978,0.9852,0.9157,0.9896 T0.94,0.996 Q0.9424,0.996,0.9469,0.9965 T0.9566,0.997 T0.9676,0.9975 T0.9781,0.998 L0.9874,0.998 L0.9943,0.998 L0.9968,0.998 Z",type:0}},"":{type:5,data:{d:"M1,0.5071 L0.8623,0.7102 L0.5865,0.7102 L0.4489,0.5071 L0.5865,0.3045 L0.8623,0.3045 Z M0.4135,0.7974 L0.2758,1 L0,1 L0,0.5944 L0.2758,0.5944 Z M0.4135,0.2026 L0.2758,0.4056 L0,0.4056 L0,0 L0.2758,0 Z",type:0}},"":{type:5,data:{d:"M0.9726,0.5071 L0.8451,0.3184 L0.59,0.3184 L0.4624,0.5071 L0.59,0.6955 L0.8451,0.6955 Z M1,0.5071 L0.8588,0.716 L0.5768,0.716 L0.4355,0.5071 L0.5768,0.2982 L0.8588,0.2982 Z M0.401,0.7911 L0.2735,0.6028 L0.0236,0.6028 L0.0236,0.9799 L0.2735,0.9799 Z M0.4284,0.7911 L0.2872,1 L0,1 L0,0.5826 L0.2872,0.5826 Z M0.401,0.2089 L0.2735,0.0201 L0.0236,0.0201 L0.0236,0.3972 L0.2735,0.3972 Z M0.4284,0.2089 L0.2872,0.4174 L0,0.4174 L0,0 L0.2872,0 Z",type:0}},"":{type:5,data:{d:"M1,0.4996 Q1,0.5365,0.9924,0.568 T0.9718,0.6177 T0.9433,0.6363 L0.9425,0.6367 Q0.9355,0.6367,0.9285,0.6326 L0.9308,0.6326 Q0.9129,0.6195,0.9013,0.587 T0.8871,0.5164 T0.8943,0.4373 T0.9254,0.3687 L0.9254,0.3691 Q0.9339,0.3628,0.9425,0.3628 Q0.9584,0.3628,0.9716,0.3811 T0.9924,0.431 T1,0.4996 Z M0.9234,0.6321 L0.8776,0.7169 Q0.8791,0.732,0.8791,0.7441 Q0.8791,0.781,0.8716,0.8123 T0.8508,0.862 T0.8224,0.8809 L0.8216,0.8809 Q0.8154,0.8809,0.8092,0.8775 L0.8088,0.8775 Q0.7905,0.8633,0.7792,0.8297 T0.766,0.7571 T0.775,0.6768 T0.8088,0.6086 L0.7431,0.6065 Q0.719,0.6313,0.7072,0.6705 T0.6965,0.7487 T0.7097,0.823 T0.7423,0.8763 L0.7913,0.8775 L0.7314,0.9895 L0.4648,0.5038 L0.7299,0.0176 L0.7882,0.1229 L0.7404,0.1212 Q0.7244,0.138,0.7136,0.1617 T0.6982,0.2108 T0.6943,0.2632 T0.7003,0.3144 T0.7159,0.3586 T0.7396,0.3909 L0.8072,0.3926 Q0.7894,0.3796,0.7777,0.3479 T0.7635,0.2789 T0.7697,0.2011 T0.7987,0.1326 Q0.8092,0.1225,0.8204,0.1225 Q0.8321,0.1225,0.8426,0.1332 T0.8609,0.1623 T0.8731,0.2062 T0.8776,0.2592 Q0.8776,0.268,0.8768,0.2815 L0.9219,0.3628 L0.8644,0.3612 Q0.8403,0.3855,0.8284,0.4247 T0.8177,0.5029 T0.8309,0.5772 T0.8632,0.6305 Z M0.6759,0.6384 Q0.6576,0.625,0.6457,0.5914 T0.6319,0.5185 T0.6407,0.4375 T0.6751,0.3691 L0.609,0.367 Q0.5849,0.3918,0.5731,0.431 T0.5626,0.509 T0.5758,0.5833 T0.6082,0.6367 Z M0.6459,0.0025 L0.391,0.4551 L0.0035,0.4551 L0.246,0 Z M0.6553,1 L0.2421,1 L0,0.5449 L0.3875,0.5449 Z",type:0}},"":{type:5,data:{d:"M0.4996,0 Q0.5562,0,0.5961,0.0166 T0.6364,0.0566 L0.6368,0.0575 Q0.6368,0.0646,0.6324,0.0713 L0.6324,0.0692 Q0.6196,0.0868,0.5872,0.0986 T0.5166,0.1128 T0.4373,0.1057 T0.3689,0.0747 L0.3694,0.0747 Q0.3627,0.0663,0.3627,0.0575 Q0.3627,0.0336,0.4028,0.0168 T0.4996,0 Z M0.6324,0.0768 L0.717,0.1225 Q0.7321,0.1212,0.744,0.1212 Q0.8007,0.1212,0.8406,0.1378 T0.8809,0.1779 L0.8813,0.1783 Q0.8813,0.1846,0.8778,0.1909 Q0.8636,0.2093,0.8299,0.2208 T0.7573,0.2343 T0.6769,0.2253 T0.6089,0.1913 L0.6067,0.2567 Q0.6315,0.281,0.6707,0.2928 T0.7489,0.3035 T0.8231,0.2903 T0.8764,0.258 L0.8778,0.2085 L0.9898,0.2685 L0.504,0.5352 L0.0177,0.2701 L0.1227,0.2118 L0.1213,0.2596 Q0.1457,0.2836,0.1851,0.2955 T0.2635,0.3062 T0.3377,0.293 T0.3911,0.2605 L0.3928,0.193 Q0.38,0.2106,0.3483,0.2221 T0.2792,0.2364 T0.2013,0.2303 T0.1324,0.2013 Q0.1222,0.1909,0.1222,0.1795 Q0.1222,0.156,0.1623,0.1393 T0.2591,0.1225 Q0.2679,0.1225,0.2817,0.1233 L0.3627,0.078 L0.3609,0.1359 Q0.3857,0.1598,0.4249,0.1718 T0.5031,0.1825 T0.5773,0.1693 T0.6306,0.1367 Z M0.6386,0.3242 Q0.6253,0.3427,0.5917,0.3544 T0.5186,0.3683 T0.4376,0.3595 T0.3689,0.3251 L0.3671,0.3909 Q0.3915,0.4148,0.4309,0.4268 T0.5093,0.4375 T0.5835,0.4243 T0.6368,0.3918 Z M0.0027,0.354 L0.4553,0.6091 L0.4553,0.9962 L0,0.7542 Z M1,0.3448 L1,0.7576 L0.5447,1 L0.5447,0.6128 Z",type:0}},"":{type:5,data:{d:"M0,0.7699 Q0,0.7172,0.0277,0.6731 T0.103,0.6032 T0.2066,0.5774 Q0.2487,0.5774,0.2865,0.5922 T0.3526,0.6339 L0.3935,0.6715 Q0.4218,0.6984,0.438,0.7336 T0.4541,0.8075 Q0.4541,0.8602,0.4264,0.9046 T0.3511,0.9745 T0.2475,1 Q0.2054,1,0.1676,0.9852 T0.1016,0.9435 L0.0606,0.9059 Q0.0317,0.879,0.0159,0.8438 T0,0.7699 Z M0.5459,0.7699 Q0.5459,0.7172,0.5736,0.6731 T0.6489,0.6032 T0.7525,0.5774 Q0.7946,0.5774,0.8324,0.5922 T0.8984,0.6339 L0.9394,0.6715 Q0.9579,0.6892,0.9714,0.7105 T0.9925,0.7567 T1,0.8075 Q1,0.8602,0.9723,0.9046 T0.897,0.9745 T0.7934,1 Q0.7513,1,0.7135,0.9852 T0.6474,0.9435 L0.6065,0.9059 Q0.5776,0.879,0.5617,0.8438 T0.5459,0.7699 Z M0,0.1925 Q0,0.1398,0.0277,0.0957 T0.103,0.0258 T0.2066,0 Q0.2487,0,0.2865,0.0148 T0.3526,0.0565 L0.3935,0.0941 Q0.4218,0.121,0.438,0.1562 T0.4541,0.2301 Q0.4541,0.2828,0.4264,0.3269 T0.3511,0.3968 T0.2475,0.4226 Q0.2054,0.4226,0.1676,0.4078 T0.1016,0.3661 L0.0606,0.3285 Q0.0317,0.3016,0.0159,0.2664 T0,0.1925 Z M0.5459,0.1925 Q0.5459,0.1398,0.5736,0.0957 T0.6489,0.0258 T0.7525,0 Q0.7946,0,0.8324,0.0148 T0.8984,0.0565 L0.9394,0.0941 Q0.9677,0.121,0.9838,0.1562 T1,0.2301 Q1,0.2828,0.9723,0.3269 T0.897,0.3968 T0.7934,0.4226 Q0.7513,0.4226,0.7135,0.4078 T0.6474,0.3661 L0.6065,0.3285 Q0.5874,0.3108,0.5741,0.2895 T0.5534,0.2433 T0.5459,0.1925 Z M0.3301,0.6403 Q0.3306,0.6403,0.3312,0.6409 L0.3272,0.6371 L0.3272,0.6371 Z M0.8759,0.6403 Q0.8765,0.6403,0.8771,0.6409 Q0.8748,0.6387,0.8725,0.6371 L0.8731,0.6371 Z M0.3301,0.0629 Q0.3306,0.0629,0.3312,0.0634 L0.3272,0.0597 L0.3272,0.0602 Z M0.8759,0.0629 Q0.8765,0.0629,0.8771,0.0634 Q0.8748,0.0613,0.8725,0.0597 Q0.8731,0.0597,0.8731,0.0602 Z M0.779,0.4113 L0.7501,0.3849 Q0.7046,0.3844,0.6636,0.3661 Q0.7132,0.407,0.779,0.4113 Z M0.7957,0.4118 Q0.8477,0.4113,0.8918,0.3874 T0.9619,0.3223 T0.9885,0.2323 L0.9585,0.2048 Q0.9538,0.2769,0.8987,0.3282 T0.7657,0.3844 Z M0.9879,0.2167 Q0.9827,0.1554,0.9388,0.1097 Q0.9585,0.1478,0.959,0.1898 Z M0.2331,0.4113 L0.2043,0.3849 Q0.1587,0.3844,0.1177,0.3661 Q0.1673,0.407,0.2331,0.4113 Z M0.2499,0.4118 Q0.2885,0.4118,0.324,0.3973 T0.3852,0.3589 T0.4264,0.3019 T0.4426,0.2323 L0.4126,0.2048 Q0.408,0.2769,0.3529,0.3282 T0.2198,0.3844 Z M0.442,0.2167 Q0.4368,0.1554,0.393,0.1097 Q0.4126,0.1478,0.4132,0.1903 Z M0.779,0.9887 L0.7501,0.9624 Q0.7046,0.9618,0.6636,0.9435 Q0.7132,0.9844,0.779,0.9887 Z M0.7957,0.9892 Q0.8477,0.9887,0.8918,0.9648 T0.9619,0.8997 T0.9885,0.8097 L0.9585,0.7823 Q0.9538,0.8543,0.8987,0.9056 T0.7657,0.9618 Z M0.9879,0.7941 Q0.9827,0.7328,0.9388,0.6871 Q0.9585,0.7253,0.959,0.7672 Z M0.2331,0.9887 L0.2043,0.9624 Q0.1587,0.9618,0.1177,0.9435 Q0.1673,0.9844,0.2331,0.9887 Z M0.2499,0.9892 Q0.3018,0.9887,0.3459,0.9648 T0.416,0.8997 T0.4426,0.8102 L0.4126,0.7823 Q0.408,0.8543,0.3529,0.9056 T0.2198,0.9618 Z M0.442,0.7941 Q0.4368,0.7328,0.393,0.6871 Q0.4126,0.7253,0.4132,0.7672 Z M0.3191,0.6452 Q0.2943,0.622,0.2643,0.6091 T0.2066,0.5962 Q0.1795,0.5962,0.1497,0.6091 T0.0949,0.6441 T0.0537,0.6995 T0.0375,0.7699 Q0.0375,0.8419,0.0941,0.8941 Q0.1189,0.9172,0.1489,0.9304 T0.2066,0.9435 Q0.2337,0.9435,0.2634,0.9304 T0.3182,0.8952 T0.3595,0.8398 T0.3756,0.7699 Q0.3756,0.6978,0.3191,0.6452 Z M0.026,0.7731 L0.026,0.7699 Q0.026,0.6935,0.0854,0.6376 Q0.0658,0.6538,0.0514,0.6739 T0.0289,0.718 T0.0202,0.7677 Z M0.0271,0.7892 L0.0208,0.7833 Q0.0254,0.8419,0.0681,0.886 Q0.0664,0.8828,0.0646,0.879 Q0.0329,0.8382,0.0271,0.7892 Z M0.3866,0.7823 Q0.382,0.8511,0.3278,0.9016 Q0.3843,0.8565,0.3918,0.7871 Z M0.3872,0.7677 L0.393,0.7726 L0.393,0.7699 Q0.393,0.7349,0.3791,0.7038 Q0.3739,0.6973,0.3681,0.6914 Q0.3866,0.7274,0.3872,0.7677 Z M0.865,0.6452 Q0.8402,0.622,0.8102,0.6091 T0.7525,0.5962 Q0.7305,0.5962,0.7072,0.6043 T0.6619,0.628 T0.6223,0.6642 T0.5941,0.7124 T0.5834,0.7699 Q0.5834,0.8419,0.6399,0.8941 Q0.6561,0.9097,0.6757,0.9207 T0.7149,0.9376 T0.7525,0.9435 Q0.7796,0.9435,0.8093,0.9304 T0.8641,0.8952 T0.9054,0.8398 T0.9215,0.7699 Q0.9215,0.6978,0.865,0.6452 Z M0.5718,0.7731 L0.5718,0.7699 Q0.5718,0.6935,0.6313,0.6376 Q0.6013,0.6618,0.584,0.6954 T0.5661,0.7677 Z M0.573,0.7892 L0.5666,0.7833 Q0.5713,0.8419,0.614,0.886 Q0.6122,0.8828,0.6105,0.879 Q0.5788,0.8382,0.573,0.7892 Z M0.9325,0.7823 Q0.9279,0.8511,0.8736,0.9016 Q0.9308,0.8565,0.9377,0.7871 Z M0.9331,0.7672 L0.9388,0.7726 L0.9388,0.7699 Q0.9388,0.7349,0.925,0.7038 Q0.9198,0.6973,0.914,0.6914 Q0.9325,0.7274,0.9331,0.7672 Z M0.3191,0.0677 Q0.2943,0.0446,0.2643,0.0317 T0.2066,0.0188 Q0.1795,0.0188,0.1497,0.0317 T0.0949,0.0667 T0.0537,0.122 T0.0375,0.1925 Q0.0375,0.2645,0.0941,0.3167 Q0.1189,0.3398,0.1489,0.353 T0.2066,0.3661 Q0.2337,0.3661,0.2634,0.353 T0.3182,0.3177 T0.3595,0.2624 T0.3756,0.1925 Q0.3756,0.1204,0.3191,0.0677 Z M0.026,0.1957 L0.026,0.1925 Q0.026,0.1161,0.0854,0.0602 Q0.0554,0.0844,0.0381,0.118 T0.0202,0.1903 Z M0.0271,0.2118 L0.0208,0.2059 Q0.0254,0.2645,0.0681,0.3086 Q0.0664,0.3054,0.0646,0.3016 Q0.0329,0.2608,0.0271,0.2118 Z M0.3866,0.2048 Q0.382,0.2737,0.3278,0.3242 Q0.3849,0.279,0.3918,0.2097 Z M0.3872,0.1903 L0.393,0.1952 L0.393,0.1925 Q0.393,0.1581,0.3791,0.1263 Q0.3739,0.1199,0.3681,0.114 Q0.3866,0.15,0.3872,0.1903 Z M0.865,0.0677 Q0.8402,0.0446,0.8102,0.0317 T0.7525,0.0188 Q0.7253,0.0188,0.6956,0.0317 T0.6408,0.0667 T0.5995,0.122 T0.5834,0.1925 Q0.5834,0.2645,0.6399,0.3167 Q0.6647,0.3398,0.6947,0.353 T0.7525,0.3661 Q0.7796,0.3661,0.8093,0.353 T0.8641,0.3177 T0.9054,0.2624 T0.9215,0.1925 Q0.9215,0.1204,0.865,0.0677 Z M0.5718,0.1957 L0.5718,0.1925 Q0.5718,0.1161,0.6313,0.0602 Q0.6013,0.0844,0.584,0.118 T0.5661,0.1903 Z M0.573,0.2118 L0.5666,0.2059 Q0.5713,0.2645,0.614,0.3086 Q0.6122,0.3054,0.6105,0.3016 Q0.5788,0.2608,0.573,0.2118 Z M0.9325,0.2048 Q0.9279,0.2737,0.8736,0.3242 Q0.9308,0.279,0.9377,0.2097 Z M0.9331,0.1898 L0.9388,0.1952 L0.9388,0.1925 Q0.9388,0.1575,0.925,0.1263 Q0.9198,0.1199,0.914,0.114 Q0.9325,0.15,0.9331,0.1898 Z",type:0}},"":{type:5,data:{d:"M0.7639,0.1974 L0.9593,0.1974 L0.9593,0.1443 L0.7639,0.1443 L0.7639,0.1974 Z M0.7586,0.109 L0.9727,0.109 Q0.9839,0.109,0.992,0.1153 T1,0.1291 L1,0.382 Q1,0.3906,0.9912,0.3964 T0.9727,0.4021 L0.7586,0.4021 Q0.7468,0.4021,0.739,0.3956 T0.7313,0.382 L0.7313,0.1291 Q0.7313,0.1246,0.7339,0.1207 T0.7406,0.1143 T0.7495,0.1104 T0.7586,0.109 Z M0.7639,0.6575 L0.9593,0.6575 L0.9593,0.6044 L0.7639,0.6044 L0.7639,0.6575 Z M0.7313,0.8347 L0.7313,0.5843 Q0.7313,0.5757,0.7401,0.5699 T0.7586,0.5641 L0.9706,0.5641 Q0.9818,0.5641,0.9898,0.5705 T0.9979,0.5843 L0.9979,0.8347 Q0.9979,0.8433,0.989,0.8491 T0.9706,0.8549 L0.7586,0.8549 Q0.7468,0.8549,0.739,0.8483 T0.7313,0.8347 Z M0,1 L0,0 L0.7607,0 L0.7607,1 L0,1 Z",type:0}},"":{type:5,data:{d:"M0.9764,0.0029 L0.3179,0.4552 L0,0.4552 L0,0 Z M1,1 L0,1 L0,0.5448 L0.3091,0.5448 Z",type:0}},"":{type:5,data:{d:"M0.0236,0.0029 L0.6824,0.4552 L1,0.4552 L1,0 Z M0,1 L1,1 L1,0.5448 L0.6912,0.5448 Z",type:0}},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z M.25,.15 L1,.15 L1,.85 L.25,.85 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z M0,.15 L1,.15 L1,.85 L0,.85 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z M0,.15 L.75,.15 L.75,.85 L0,.85 Z"},"":{type:5,data:{d:"M0.6574,0.303 Q0.623,0.291,0.5852,0.285 T0.5082,0.279 T0.4311,0.285 T0.359,0.303 L0.3082,0.248 Q0.3525,0.232,0.4041,0.2235 T0.5082,0.215 T0.6123,0.2235 T0.7082,0.248 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.8557,0.582 L0.7656,0.551 Q0.7852,0.53,0.7951,0.507 T0.8049,0.46 Q0.8049,0.424,0.782,0.3905 T0.718,0.332 T0.6221,0.293 T0.5082,0.279 L0.5082,0.215 Q0.5607,0.215,0.6123,0.2235 T0.709,0.248 T0.7918,0.287 T0.8557,0.3375 T0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.582 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.482,0.705,0.4557,0.703 T0.4049,0.697 L0.4311,0.635 Q0.4508,0.638,0.4697,0.6395 T0.5082,0.641 Q0.5672,0.641,0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 Q0.8049,0.436,0.7951,0.413 T0.7656,0.369 L0.8557,0.338 Q0.882,0.365,0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 L0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 T0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 L0.9098,0.46 Q0.9098,0.492,0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.338 L0.2508,0.369 Q0.2311,0.39,0.2213,0.413 T0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 Q0.5279,0.641,0.5467,0.6395 T0.5852,0.635 L0.6115,0.697 Q0.5869,0.701,0.5607,0.703 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.1607,0.582 Q0.1344,0.555,0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.3375 T0.2246,0.287 T0.3074,0.248 T0.4041,0.2235 T0.5082,0.215 L0.5082,0.279 Q0.4492,0.279,0.3943,0.293 T0.2984,0.332 T0.2344,0.3905 T0.2115,0.46 Q0.2115,0.484,0.2213,0.507 T0.2508,0.551 Z",type:0},scaleType:1},"":Ue.LINE_H,"":Ue.LINE_V,"":Ue.FADE_RIGHT,"":Ue.FADE_LEFT,"":Ue.FADE_DOWN,"":Ue.FADE_UP,"":Ue.CURVE_DOWN_RIGHT,"":Ue.CURVE_DOWN_LEFT,"":Ue.CURVE_UP_RIGHT,"":Ue.CURVE_UP_LEFT,"":[Ue.LINE_V,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_RIGHT],"":[Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_UP_LEFT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT],"":[Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT],"":[Ue.CURVE_DOWN_LEFT,Ue.CURVE_DOWN_RIGHT],"":[Ue.LINE_H,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_UP_RIGHT],"":[Ue.CURVE_UP_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_UP_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT,Ue.CURVE_DOWN_RIGHT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE],"":Ue.NODE_STROKE,"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_UP],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_UP],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"🬀":Cr(1),"🬁":Cr(2),"🬂":Cr(3),"🬃":Cr(4),"🬄":Cr(5),"🬅":Cr(6),"🬆":Cr(7),"🬇":Cr(8),"🬈":Cr(9),"🬉":Cr(10),"🬊":Cr(11),"🬋":Cr(12),"🬌":Cr(13),"🬍":Cr(14),"🬎":Cr(15),"🬏":Cr(16),"🬐":Cr(17),"🬑":Cr(18),"🬒":Cr(19),"🬓":Cr(20),"🬔":Cr(22),"🬕":Cr(23),"🬖":Cr(24),"🬗":Cr(25),"🬘":Cr(26),"🬙":Cr(27),"🬚":Cr(28),"🬛":Cr(29),"🬜":Cr(30),"🬝":Cr(31),"🬞":Cr(32),"🬟":Cr(33),"🬠":Cr(34),"🬡":Cr(35),"🬢":Cr(36),"🬣":Cr(37),"🬤":Cr(38),"🬥":Cr(39),"🬦":Cr(40),"🬧":Cr(41),"🬨":Cr(43),"🬩":Cr(44),"🬪":Cr(45),"🬫":Cr(46),"🬬":Cr(47),"🬭":Cr(48),"🬮":Cr(49),"🬯":Cr(50),"🬰":Cr(51),"🬱":Cr(52),"🬲":Cr(53),"🬳":Cr(54),"🬴":Cr(55),"🬵":Cr(56),"🬶":Cr(57),"🬷":Cr(58),"🬸":Cr(59),"🬹":Cr(60),"🬺":Cr(61),"🬻":Cr(62),"🬼":{type:3,data:"M0,0.6667 L0,1 L0.5,1 Z"},"🬽":{type:3,data:"M0,0.6667 L0,1 L1,1 Z"},"🬾":{type:3,data:"M0,0.3333 L0,1 L0.5,1 Z"},"🬿":{type:3,data:"M0,0.3333 L0,1 L1,1 Z"},"🭀":{type:3,data:"M0,0 L0,1 L0.5,1 Z"},"🭁":{type:3,data:"M0,0.3333 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭂":{type:3,data:"M0,0.3333 L1,0 L1,1 L0,1 Z"},"🭃":{type:3,data:"M0,0.6667 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭄":{type:3,data:"M0,0.6667 L1,0 L1,1 L0,1 Z"},"🭅":{type:3,data:"M0,1 L0.5,0 L1,0 L1,1 Z"},"🭆":{type:3,data:"M0,0.6667 L1,0.3333 L1,1 L0,1 Z"},"🭇":{type:3,data:"M0.5,1 L1,0.6667 L1,1 Z"},"🭈":{type:3,data:"M0,1 L1,0.6667 L1,1 Z"},"🭉":{type:3,data:"M0.5,1 L1,0.3333 L1,1 Z"},"🭊":{type:3,data:"M0,1 L1,0.3333 L1,1 Z"},"🭋":{type:3,data:"M0.5,1 L1,0 L1,1 Z"},"🭌":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.3333 Z"},"🭍":{type:3,data:"M0,0 L0,1 L1,1 L1,0.3333 Z"},"🭎":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.6667 Z"},"🭏":{type:3,data:"M0,0 L0,1 L1,1 L1,0.6667 Z"},"🭐":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 Z"},"🭑":{type:3,data:"M0,0.3333 L0,1 L1,1 L1,0.6667 Z"},"🭒":{type:3,data:"M0,0.6667 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭓":{type:3,data:"M0,0.6667 L1,1 L1,0 L0,0 Z"},"🭔":{type:3,data:"M0,0.3333 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭕":{type:3,data:"M0,0.3333 L1,1 L1,0 L0,0 Z"},"🭖":{type:3,data:"M0,0 L0.5,1 L1,1 L1,0 Z"},"🭗":{type:3,data:"M0,0.3333 L0,0 L0.5,0 Z"},"🭘":{type:3,data:"M0,0.3333 L0,0 L1,0 Z"},"🭙":{type:3,data:"M0,0.6667 L0,0 L0.5,0 Z"},"🭚":{type:3,data:"M0,0.6667 L0,0 L1,0 Z"},"🭛":{type:3,data:"M0,1 L0,0 L0.5,0 Z"},"🭜":{type:3,data:"M0,0.6667 L0,0 L1,0 L1,0.3333 Z"},"🭝":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.6667 Z"},"🭞":{type:3,data:"M0,1 L0,0 L1,0 L1,0.6667 Z"},"🭟":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.3333 Z"},"🭠":{type:3,data:"M0,1 L0,0 L1,0 L1,0.3333 Z"},"🭡":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 Z"},"🭢":{type:3,data:"M0.5,0 L1,0 L1,0.3333 Z"},"🭣":{type:3,data:"M0,0 L1,0 L1,0.3333 Z"},"🭤":{type:3,data:"M0.5,0 L1,0 L1,0.6667 Z"},"🭥":{type:3,data:"M0,0 L1,0 L1,0.6667 Z"},"🭦":{type:3,data:"M0.5,0 L1,0 L1,1 Z"},"🭧":{type:3,data:"M0,0.3333 L1,0.6667 L1,0 L0,0 Z"},"🭨":{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z"},"🭩":{type:3,data:"M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z"},"🭪":{type:3,data:"M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z"},"🭫":{type:3,data:"M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z"},"🭬":{type:3,data:"M0,0 L0.5,0.5 L0,1 Z"},"🭭":{type:3,data:"M0,0 L1,0 L0.5,0.5 Z"},"🭮":{type:3,data:"M1,0 L1,1 L0.5,0.5 Z"},"🭯":{type:3,data:"M0,1 L1,1 L0.5,0.5 Z"},"🭰":{type:0,data:[{x:1,y:0,w:1,h:8}]},"🭱":{type:0,data:[{x:2,y:0,w:1,h:8}]},"🭲":{type:0,data:[{x:3,y:0,w:1,h:8}]},"🭳":{type:0,data:[{x:4,y:0,w:1,h:8}]},"🭴":{type:0,data:[{x:5,y:0,w:1,h:8}]},"🭵":{type:0,data:[{x:6,y:0,w:1,h:8}]},"🭶":{type:0,data:[{x:0,y:1,w:8,h:1}]},"🭷":{type:0,data:[{x:0,y:2,w:8,h:1}]},"🭸":{type:0,data:[{x:0,y:3,w:8,h:1}]},"🭹":{type:0,data:[{x:0,y:4,w:8,h:1}]},"🭺":{type:0,data:[{x:0,y:5,w:8,h:1}]},"🭻":{type:0,data:[{x:0,y:6,w:8,h:1}]},"🭼":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🭽":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭾":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭿":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🮀":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮁":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮂":{type:0,data:[{x:0,y:0,w:8,h:2}]},"🮃":{type:0,data:[{x:0,y:0,w:8,h:3}]},"🮄":{type:0,data:[{x:0,y:0,w:8,h:5}]},"🮅":{type:0,data:[{x:0,y:0,w:8,h:6}]},"🮆":{type:0,data:[{x:0,y:0,w:8,h:7}]},"🮇":{type:0,data:[{x:6,y:0,w:2,h:8}]},"🮈":{type:0,data:[{x:5,y:0,w:3,h:8}]},"🮉":{type:0,data:[{x:3,y:0,w:5,h:8}]},"🮊":{type:0,data:[{x:2,y:0,w:6,h:8}]},"🮋":{type:0,data:[{x:1,y:0,w:7,h:8}]},"🮌":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},"🮍":{type:1,data:[[1,0],[0,1]],clipPath:"M0.5,0 L1,0 L1,1 L0.5,1 Z"},"🮎":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},"🮏":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},"🮐":{type:1,data:[[0,1],[1,0]]},"🮑":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},{type:0,data:[{x:0,y:0,w:8,h:4}]}],"🮒":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},{type:0,data:[{x:0,y:4,w:8,h:4}]}],"🮔":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},{type:0,data:[{x:4,y:0,w:4,h:8}]}],"🮕":{type:0,data:[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}]},"🮖":{type:0,data:[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}]},"🮗":{type:0,data:[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},"🮘":{type:2,data:"M-0.25,-0.25 L1.25,1.25 M-0.25,0 L1,1.25 M-0.25,0.25 L0.75,1.25 M-0.25,0.5 L0.5,1.25 M0,-0.25 L1.25,1 M0.25,-0.25 L1.25,0.75 M0.5,-0.25 L1.25,0.5 M-0.25,0.75 L0.25,1.25 M0.75,-0.25 L1.25,0.25",strokeWidth:1},"🮙":{type:2,data:"M-0.25,0.5 L0.5,-0.25 M-0.25,0.75 L0.75,-0.25 M-0.25,1 L1,-0.25 M-0.25,1.25 L1.25,-0.25 M0,1.25 L1.25,0 M0.25,1.25 L1.25,0.25 M0.5,1.25 L1.25,0.5 M-0.25,0.25 L0.25,-0.25 M0.75,1.25 L1.25,0.75",strokeWidth:1},"🮚":{type:5,data:{d:"M0,0 L.5,.5 L0,1 L1,1 L.5,.5 L1,0",type:0}},"🮛":{type:5,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1",type:0}},"🮜":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L0,1 Z"},"🮝":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,1 Z"},"🮞":{type:1,data:[[1,0],[0,1]],clipPath:"M1,0 L1,1 L0,1 Z"},"🮟":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,1 L0,1 Z"},"🮠":{type:2,data:"M.5,0 L0,.5",strokeWidth:1},"🮡":{type:2,data:"M.5,0 L1,.5",strokeWidth:1},"🮢":{type:2,data:"M0,.5 L.5,1",strokeWidth:1},"🮣":{type:2,data:"M1,.5 L.5,1",strokeWidth:1},"🮤":{type:2,data:"M.5,0 L0,.5 L.5,1",strokeWidth:1},"🮥":{type:2,data:"M.5,0 L1,.5 L.5,1",strokeWidth:1},"🮦":{type:2,data:"M0,.5 L.5,1 L1,.5",strokeWidth:1},"🮧":{type:2,data:"M0,.5 L.5,0 L1,.5",strokeWidth:1},"🮨":{type:2,data:"M.5,0 L0,.5 M1,.5 L.5,1",strokeWidth:1},"🮩":{type:2,data:"M.5,0 L1,.5 M0,.5 L.5,1",strokeWidth:1},"🮪":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5",strokeWidth:1},"🮫":{type:2,data:"M.5,0 L0,.5 L.5,1 L1,.5",strokeWidth:1},"🮬":{type:2,data:"M0,.5 L.5,0 L1,.5 L.5,1",strokeWidth:1},"🮭":{type:2,data:"M1,.5 L.5,0 L0,.5 L.5,1",strokeWidth:1},"🮮":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5 Z",strokeWidth:1},"🮯":{type:2,data:"M0,.5 L1,.5 M.5,.35 L.5,.65",strokeWidth:1},"🮰":{type:3,data:"M0.1,0.2 L0.1,.8 L.4,.6 L.9,0.6 Z",scaleType:1},"🮱":{type:4,data:{d:"M.1,.525 L.35,.675 L.9,.35",type:1},scaleType:1},"🮲":{type:3,data:"M.29,.27 L0.13,.56 L.22,.59 L.35,0.35 L.67,.35 L.57,.57 L.71,.76 L.22,.76 L.42,1 L.53,.98 L.43,.86 L.9,.86 L.71,.6 L1,.6 L1,.52 L.83,.52 L.92,.36 L1,.36 L1,.27Z M.99,.13 A.12,.12,0,1,1,.75,.13 A.12,.12,0,1,1,.99,.13"},"🮳":{type:3,data:"M0,.27 L.3,.27 L.55,.12 L.63,.18 L.33,.36 L0,.36 M0,.52 L.33,.52 L.59,.89 L.73,.89 L.73,.98 L.53,.98 L.28,.6 L0,.6"},"🮴":{type:4,data:{d:"M.15,.55 L.5,.4 L.5,.45 L.65,.45 L.65,.35 L.85,.35 L.85,.625 L.5,.625 L.5,.7 Z",type:0},scaleType:1},"🮵":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.15,.5 L.5,.35 L.5,.425 L.85,.425 L.85,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮶":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.85,.5 L.5,.35 L.5,.425 L.15,.425 L.15,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮷":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.675 L.2,.5 L.35,.5 L.35,.325 L.65,.325 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮸":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.325 L.2,.5 L.35,.5 L.35,.675 L.65,.675 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮹":{type:5,data:{d:"M1,.89 L.11,.89 L.11,.37 L.36,.12 L.74,.12 L.96,.34 L1,.34 L1,.405 L.92,.405 L.69,.185 L.41,.185 L.21,.42 L.21,.825 L1,.825 Z",type:0}},"🮺":{type:5,data:{d:"M0,.89 L0,.825 L.78,.825 L.78,.53 L.7,.415 L0,.415 L0,.35 L.75,.35 L.88,.48 L.88,.89 Z",type:0}},"🮻":{type:5,data:{d:"M.31,.275 L.44,.275 L.44,.47 L.05,.47 L.05,.405 L.31,.405 Z M.56,.275 L.69,.275 L.69,.405 L.95,.405 L.95,.47 L.56,.47 Z M.05,.53 L.44,.53 L.44,.725 L.31,.725 L.31,.595 L.05,.595 Z M.56,.53 L.95,.53 L.95,.595 L.69,.595 L.69,.725 L.56,.725 Z",type:0},scaleType:1},"🮼":[{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0,.935 L.885,.935 L.885,.065 L0,.065 Z"},{type:3,data:"M.67,.5 A.17,.085,0,1,1,.33,.5 A.17,.085,0,1,1,.67,.5",scaleType:1}],"🮽":{type:4,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1 Z",type:1}},"🮾":{type:4,data:{d:"M1,.5 L.5,1",type:1}},"🮿":{type:4,data:{d:"M.5,0 L1,.5 L.5,1 L0,.5 Z",type:1}},"🯀":{type:3,data:"M.16,.445 A.02,.01,0,0,1,.39,.33 L.5,.375 L.61,.33 A.02,.01,0,0,1,.84,.445 L.75,.5 L.84,.555 A.02,.01,0,0,1,.61,.67 L.5,.625 L.39,.67 A.02,.01,0,0,1,.16,.555 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",scaleType:1},"🯁":{type:3,data:"M0.142308,0.924 Q0.130770,0.924,0.120193,0.922 T0.101924,0.916 T0.089424,0.9065 T0.084616,0.895 V0.025 Q0.084616,0.019,0.089424,0.0135 T0.101924,0.004 T0.120193,-0.002 T0.142308,-0.004 Q0.150000,-0.004,0.157693,-0.003 T0.173078,0.000 L0.430770,0.085 Q0.451924,0.059,0.494232,0.041 T0.587501,0.013 T0.692309,-0.0005 T0.800001,-0.004 H1 V0.055 H0.800001 Q0.771155,0.055,0.742309,0.056 T0.685578,0.060 T0.630770,0.0685 T0.580770,0.0825 T0.543270,0.1045 T0.528847,0.133 V0.647 H0.530770 Q0.596155,0.645,0.659616,0.638 T0.782693,0.6165 T0.893270,0.5805 T1,0.531 V0.623 Q0.934616,0.644,0.880770,0.6595 T0.769232,0.685 T0.650963,0.700 T0.528847,0.707 V0.787 Q0.528847,0.802,0.543270,0.8155 T0.580770,0.8375 T0.630770,0.8515 T0.685578,0.860 T0.742309,0.864 T0.800001,0.865 H1 V0.924 H0.800001 Q0.746155,0.924,0.692309,0.9205 T0.587501,0.907 T0.494232,0.879 T0.430770,0.835 L0.173078,0.920 Q0.165386,0.922,0.157693,0.923 T0.142308,0.924 Z M0.2,0.841 L0.415385,0.770 V0.150 L0.2,0.079 V0.841 Z M1,0.698 Q0.973077,0.694,0.969231,0.6885 T0.965385,0.677 Q0.965385,0.672,0.969231,0.6665 T1,0.657 V0.698 Z"},"🯂":{type:3,data:"M0,0.623 V0.531 Q0.044231,0.512,0.0625,0.4905 T0.092308,0.4465 T0.108654,0.4005 T0.113462,0.354 V0.351 Q0.113462,0.345,0.117308,0.3395 T0.129808,0.3305 T0.148846,0.3245 T0.171154,0.323 H0.501923 Q0.532692,0.323,0.563462,0.3185 T0.617308,0.303 T0.651923,0.2765 T0.663462,0.2435 V0.241 Q0.663462,0.219,0.657692,0.197 T0.639423,0.1545 T0.604808,0.115 T0.549615,0.082 T0.475577,0.0615 T0.392308,0.055 H0 V-0.004 H1 V0.055 H0.667308 Q0.694231,0.071,0.713462,0.09 T0.746154,0.129 T0.766346,0.1705 T0.775,0.213 H1 V0.316 Q0.971154,0.305,0.955769,0.2965 T0.920192,0.2825 T0.876923,0.2745 T0.830769,0.272 H0.773077 Q0.767308,0.297,0.743269,0.319 T0.680769,0.355 T0.595192,0.375 T0.501923,0.381 H0.227308 Q0.223462,0.415,0.211,0.4485 T0.172692,0.5135 T0.108269,0.573 T0,0.623 Z M0.611538,0.924 H0 V0.865 H0.611538 Q0.642308,0.865,0.673077,0.8605 T0.727885,0.845 T0.762308,0.8185 T0.773077,0.787 V0.785 Q0.773077,0.769,0.762308,0.7535 T0.727885,0.727 T0.673077,0.7115 T0.611538,0.707 H0.059615 Q0.048077,0.707,0.037115,0.7045 T0,0.694 V0.653 Q0.026923,0.648,0.037115,0.646 T0.059615,0.644 H0.722692 Q0.753462,0.644,0.784231,0.6395 T0.839038,0.624 T0.873846,0.5975 T0.884615,0.566 V0.564 Q0.884615,0.548,0.873846,0.532 T0.839038,0.5055 T0.784231,0.49 T0.722692,0.4855 H0.392308 Q0.380769,0.4855,0.370192,0.483 T0.351923,0.4765 T0.339423,0.467 T0.334615,0.4555 T0.339423,0.444 T0.351923,0.4345 T0.370192,0.428 T0.392308,0.4255 H0.832692 Q0.855769,0.4255,0.878846,0.4235 T0.922115,0.416 T0.957692,0.4015 T1,0.3815 V0.4685 Q0.975,0.4705,0.966346,0.4725 T0.95,0.4765 Q0.961538,0.4835,0.969231,0.4915 T1,0.5075 V0.6205 Q0.965385,0.6455,0.926923,0.665 T0.84,0.6935 Q0.866923,0.7115,0.877596,0.7345 T0.894231,0.7855 V0.787 Q0.894231,0.815,0.876923,0.8425 T0.820192,0.8895 T0.726923,0.916 T0.611538,0.924 Z"},"🯃":{type:3,data:"M0,0.473 V0.386 Q0.025490,0.378,0.028431,0.3695 T0.031373,0.352 V0.35 Q0.031373,0.342,0.028431,0.333 T0,0.316 V0.213 H0.652941 Q0.684314,0.213,0.715686,0.2085 T0.770588,0.193 T0.804902,0.1665 T0.815686,0.135 V0.133 Q0.815686,0.117,0.804902,0.101 T0.770588,0.0745 T0.715686,0.0595 T0.652941,0.055 H0 V-0.004 H0.652941 Q0.707843,-0.004,0.761765,0.004 T0.856863,0.031 T0.915686,0.0775 T0.933333,0.133 V0.135 Q0.933333,0.163,0.915686,0.1905 T0.856863,0.237 T0.761765,0.264 T0.652941,0.272 H0.109804 Q0.131373,0.29,0.140196,0.31 T0.149020,0.35 V0.352 Q0.149020,0.37,0.142157,0.388 T0.118627,0.4225 T0.076471,0.452 T0,0.473 Z M0,0.625 V0.513 Q0.029412,0.526,0.032353,0.54 T0.035294,0.568 V0.57 Q0.035294,0.584,0.032353,0.598 T0,0.625 Z"},"🯄":{type:3,data:"M0.019231,1.085 V-0.165 H0.980769 V1.085 H0.019231 Z M0.446154,0.527 H0.553846 Q0.553846,0.511,0.5625,0.495 T0.591346,0.466 T0.631731,0.4405 T0.666346,0.4135 T0.688462,0.3825 T0.696154,0.35 Q0.696154,0.33,0.682692,0.311 T0.641346,0.2785 T0.575,0.259 T0.498077,0.253 T0.421154,0.259 T0.356731,0.279 T0.315385,0.3125 T0.301923,0.352 V0.357 H0.409615 V0.354 Q0.409615,0.345,0.414423,0.335 T0.431731,0.318 T0.4625,0.3075 T0.498077,0.304 Q0.517308,0.304,0.534615,0.307 T0.564423,0.3165 T0.582692,0.332 T0.588462,0.35 Q0.588462,0.366,0.572115,0.3805 T0.535577,0.4075 T0.496154,0.4335 T0.465385,0.4625 T0.45,0.4945 T0.446154,0.527 Z M0.5,0.667 Q0.519231,0.667,0.5375,0.664 T0.569231,0.654 T0.588462,0.637 T0.594231,0.617 T0.588462,0.5975 T0.569231,0.581 T0.5375,0.571 T0.5,0.568 T0.4625,0.571 T0.430769,0.581 T0.411538,0.5975 T0.405769,0.617 T0.411538,0.637 T0.430769,0.654 T0.4625,0.664 T0.5,0.667 Z",scaleType:1},"🯅":{type:5,data:{d:"M.44,.425 L.44,.51 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.51 L.56,.425 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯆":{type:5,data:{d:"M.44,.425 L.44,.46 L.23,.385 L.19,.43 L.44,.51 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.61,.735 L.7,.71 L.56,.56 L.56,.51 L.81,.43 L.77,.385 L.56,.46 L.56,.425 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯇":{type:5,data:{d:"M.44,.425 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.425 Z M.18,.53 L.23,.575 L.81,.43 L.77,.385 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯈":{type:5,data:{d:"M.44,.425 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.62,.735 L.71,.71 L.56,.56 L.56,.425 Z M.23,.385 L.18,.43 L.77,.575 L.81,.53 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯉":{type:5,data:{d:"M.44,.425 L.45,.495 L.15,.645 L.34,.645 L.34,.7 L.44,.7 L.44,.645 L.56,.645 L.56,.7 L.66,.7 L.66,.645 L.84,.645 L.54,.495 L.56,.425 Z M.39,.6 L.5,.55 L.60,.6 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯊":{type:5,data:{d:"M.26,.375 L.5,.255 L.74,.375 L.74,.665 L.5,.55 L.26,.665 Z M.37,.395 L.37,.54 L.5,.475 L.63,.54 L.63,.395 L.5,.33 Z",type:0},scaleType:1},"🯋":{type:5,data:{d:"M.09,.41 L.32,.295 L.5,.375 L.68,.295 L.91,.41 L.75,.5 L.91,.59 L.68,.705 L.5,.625 L.32,.705 L.09,.59 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",type:0},scaleType:1},"🯌":{type:5,data:{d:"M.55,.305 L.88,.305 L.88,.355 L.65,.355 L.65,.47 L.88,.47 L.88,.52 L.55,.52 Z",type:0},scaleType:1},"🯍":{type:5,data:{d:"M.38,.39 L.5,.33 L.62,.39 L.62,.53 L.5,.47 L.38,.53 Z",type:0},scaleType:1},"🯎":{type:3,data:"M0,0 L0.6667,0 L0.6667,1 L0,1 Z"},"🯏":{type:3,data:"M0,0 L0.3333,0 L0.3333,1 L0,1 Z"},"🯐":{type:2,data:"M1,.5 L0,1",strokeWidth:1},"🯑":{type:2,data:"M1,0 L0,.5",strokeWidth:1},"🯒":{type:2,data:"M0,0 L1,.5",strokeWidth:1},"🯓":{type:2,data:"M0,.5 L1,1",strokeWidth:1},"🯔":{type:2,data:"M0,0 L.5,1",strokeWidth:1},"🯕":{type:2,data:"M.5,0 L1,1",strokeWidth:1},"🯖":{type:2,data:"M1,0 L.5,1",strokeWidth:1},"🯗":{type:2,data:"M.5,0 L0,1",strokeWidth:1},"🯘":{type:2,data:"M0,0 L.5,.5 L1,0",strokeWidth:1},"🯙":{type:2,data:"M1,0 L.5,.5 L1,1",strokeWidth:1},"🯚":{type:2,data:"M0,1 L.5,.5 L1,1",strokeWidth:1},"🯛":{type:2,data:"M0,0 L.5,.5 L0,1",strokeWidth:1},"🯜":{type:2,data:"M0,0 L.5,1 L1,0",strokeWidth:1},"🯝":{type:2,data:"M1,0 L0,.5 L1,1",strokeWidth:1},"🯞":{type:2,data:"M0,1 L.5,0 L1,1",strokeWidth:1},"🯟":{type:2,data:"M0,0 L1,.5 L0,1",strokeWidth:1},"🯠":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0",type:1}},"🯡":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1",type:1}},"🯢":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1",type:1}},"🯣":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1",type:1}},"🯤":{type:0,data:[{x:2,y:0,w:4,h:4}]},"🯥":{type:0,data:[{x:2,y:4,w:4,h:4}]},"🯦":{type:0,data:[{x:0,y:2,w:4,h:4}]},"🯧":{type:0,data:[{x:4,y:2,w:4,h:4}]},"🯨":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0 Z",type:0}},"🯩":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1 Z",type:0}},"🯪":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1 Z",type:0}},"🯫":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1 Z",type:0}},"🯬":{type:5,data:{d:"M1,0 L.5,0 C.5,.276,.724,.5,1,.5 Z",type:0}},"🯭":{type:5,data:{d:"M0,1 L.5,1 C.5,.724,.276,.5,0,.5 Z",type:0}},"🯮":{type:5,data:{d:"M1,1 L1,.5 C.724,.5,.5,.724,.5,1 Z",type:0}},"🯯":{type:5,data:{d:"M0,0 L0,.5 C.276,.5,.5,.276,.5,0 Z",type:0}},"🯰":{type:5,data:{d:cl(126),type:0},scaleType:1},"🯱":{type:5,data:{d:cl(48),type:0},scaleType:1},"🯲":{type:5,data:{d:cl(109),type:0},scaleType:1},"🯳":{type:5,data:{d:cl(121),type:0},scaleType:1},"🯴":{type:5,data:{d:cl(51),type:0},scaleType:1},"🯵":{type:5,data:{d:cl(91),type:0},scaleType:1},"🯶":{type:5,data:{d:cl(95),type:0},scaleType:1},"🯷":{type:5,data:{d:cl(114),type:0},scaleType:1},"🯸":{type:5,data:{d:cl(127),type:0},scaleType:1},"🯹":{type:5,data:{d:cl(123),type:0},scaleType:1},"🯺":{type:5,data:{d:"M.5,.175 C.2,.175,.15,.305,.15,.435 L.05,.63 L.35,.63 C.35,.682,.42,.76,.5,.76 C.58,.76,.65,.682,.65,.63 L.95,.63 L.85,.435 C.85,.305,.8,.175,.5,.175 Z",type:0},scaleType:1},...Object.fromEntries(Array.from({length:256},(e,t)=>[String.fromCodePoint(10240+t),{type:6,data:t}]))},g_=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function Cr(e){return{type:2,data:()=>{let t=[],r=[.375,.25,.375],n=[0,3/8,5/8];for(let a=0;a<3;a++){let c=e>>a*2&1,l=e>>a*2+1&1;c&&l?t.push(`M0,${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L0,${n[a]+r[a]} Z`):c?t.push(`M0,${n[a]} L${.5},${n[a]} L${.5},${n[a]+r[a]} L0,${n[a]+r[a]} Z`):l&&t.push(`M${.5},${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L${.5},${n[a]+r[a]} Z`)}return t.join(" ")}}}function cl(e){let t=[];if(e&64){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.2125} L${r+.075},${.175} L${n-.075},${.175} L${n},${.2125} L${n-.075},${.25} L${r+.075},${.25} Z`)}if(e&32){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.175+.075+.015,l=.5-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&16){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.5+.015,l=.825-.075-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&8){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.7875} L${r+.075},${.75} L${n-.075},${.75} L${n},${.7875} L${n-.075},${.825} L${r+.075},${.825} Z`)}if(e&4&&t.push(`M${.125},${.515} L${.2},${.515+.0375} L${.2},${.735-.0375} L${.125},${.735} L${.05},${.735-.0375} L${.05},${.515+.0375} Z`),e&2&&t.push(`M${.125},${.265} L${.2},${.265+.0375} L${.2},${.485-.0375} L${.125},${.485} L${.05},${.485-.0375} L${.05},${.265+.0375} Z`),e&1){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.5} L${r+.075},${.4625} L${n-.075},${.4625} L${n},${.5} L${n-.075},${.5375} L${r+.075},${.5375} Z`)}return t.join(" ")}var ji=0,gi=0,ul=!1,Dl=!1,wh=!1,Ba,Rd=0,x_=class{constructor(e,t,r,n,a,c){this._terminal=e,this._optionService=t,this._selectionRenderModel=r,this._decorationService=n,this._coreBrowserService=a,this._themeService=c,this.result={fg:0,bg:0,ext:0}}resolve(e,t,r,n,a){this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,gi=0,ji=0,Dl=!1,ul=!1,wh=!1,Ba=this._themeService.colors,Rd=0;let c=e.getCode();if(c!==0&&e.extended.underlineStyle===4){let l=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Rd=t*n%(Math.round(l)*2)}if(Rd===0&&g_.has(c)&&(Rd=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",l=>{l.backgroundColorRGB&&(gi=l.backgroundColorRGB.rgba>>8&16777215,Dl=!0),l.foregroundColorRGB&&(ji=l.foregroundColorRGB.rgba>>8&16777215,ul=!0)}),wh=this._selectionRenderModel.isCellSelected(this._terminal,t,r),wh){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:gi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:gi=(this.result.fg&16777215)<<8|255;break;default:gi=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:gi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:gi=(this.result.bg&16777215)<<8|255;break}gi=Xc.blend(gi,(this._coreBrowserService.isFocused?Ba.selectionBackgroundOpaque:Ba.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else gi=(this._coreBrowserService.isFocused?Ba.selectionBackgroundOpaque:Ba.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Dl=!0,Ba.selectionForeground&&(ji=Ba.selectionForeground.rgba>>8&16777215,ul=!0),P3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)ji=(this._coreBrowserService.isFocused?Ba.selectionBackgroundOpaque:Ba.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:ji=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ji=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:ji=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ji=(this.result.fg&16777215)<<8|255;break;default:ji=this._themeService.colors.foreground.rgba}ji=Xc.blend(ji,(this._coreBrowserService.isFocused?Ba.selectionBackgroundOpaque:Ba.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}ul=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",l=>{l.backgroundColorRGB&&(gi=l.backgroundColorRGB.rgba>>8&16777215,Dl=!0),l.foregroundColorRGB&&(ji=l.foregroundColorRGB.rgba>>8&16777215,ul=!0)}),Dl&&(wh?gi=e.bg&-16777216&-134217729|gi|50331648:gi=e.bg&-16777216|gi|50331648),ul&&(ji=e.fg&-16777216&-67108865|ji|50331648),this.result.fg&67108864&&(Dl&&!ul&&((this.result.bg&50331648)===0?ji=this.result.fg&-134217728|Ba.background.rgba>>8&16777215&16777215|50331648:ji=this.result.fg&-134217728|this.result.bg&67108863,ul=!0),!Dl&&ul&&((this.result.fg&50331648)===0?gi=this.result.bg&-67108864|Ba.foreground.rgba>>8&16777215&16777215|50331648:gi=this.result.bg&-67108864|this.result.fg&67108863,Dl=!0)),Ba=void 0,this.result.bg=Dl?gi:this.result.bg,this.result.fg=ul?ji:this.result.fg,this.result.ext&=536870911,this.result.ext|=Rd<<29&3758096384}},b_=.5,O3=s_||i_?"bottom":"ideographic";function y_(e,t,r,n,a,c,l,d,f,m,x,y,w=0){let v=m_[t];if(v){let T=Array.isArray(v)?v:[v];for(let C of T)v_(e,C,r,n,a,c,l,d,f,m,x,y,w);return!0}return!1}function v_(e,t,r,n,a,c,l,d,f,m,x,y,w=0){let v=a,T=c,C=r,L=n;switch(t.scaleType===1&&(v=l,T=d,C=r+(a-l)/2,L=n+(c-d)/2),t.clipPath&&(e.save(),L_(e,t.clipPath,C,L,v,T)),t.type){case 0:w_(e,t.data,C,L,v,T);break;case 1:__(e,t.data,C,L,v,T,w);break;case 2:k_(e,t.data,C,L,v,T,m,x,t.strokeWidth);break;case 3:T_(e,t.data,C,L,v,T,m,t.strokeWidth);break;case 4:C_(e,t.data,C,L,v,T,m,y);break;case 5:I_(e,t.data,C,L,v,T,f,m,x);break;case 6:A_(e,t.data,C,L,v,T);break}t.clipPath&&e.restore()}function w_(e,t,r,n,a,c){for(let l=0;l<t.length;l++){let d=t[l],f=a/8,m=c/8;e.fillRect(r+d.x*f,n+d.y*m,d.w*f,d.h*m)}}var Gx=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function A_(e,t,r,n,a,c){let l=a/8,d=c*.1,f=c*.8/8,m=Math.min(l,f);for(let x=0;x<8;x++)if(t&1<<x){let y=Gx[x*2],w=Gx[x*2+1],v=r+(y+1)*l,T=n+d+(w+1)*f;e.beginPath(),e.arc(v,T,m,0,Math.PI*2),e.fill()}}function T_(e,t,r,n,a,c,l,d){let f=typeof t=="string"?t:t(0,0);e.beginPath();let m=0,x=0,y=0,w=0,v="";for(let T of f.split(" ")){let C=T[0],L=T.substring(1).split(",");if(C==="Z"){e.closePath(),v=C;continue}if(C==="V"){let D=n+parseFloat(L[0])*c;e.lineTo(m,D),x=D,y=m,w=x,v=C;continue}if(C==="H"){let D=r+parseFloat(L[0])*a;e.lineTo(D,x),m=D,y=m,w=x,v=C;continue}if(!L[0]||!L[1])continue;if(C==="A"){let D=parseFloat(L[0])*a,O=parseFloat(L[1])*c,P=parseFloat(L[2])*Math.PI/180,F=parseInt(L[3],10),ee=parseInt(L[4],10),Z=r+parseFloat(L[5])*a,G=n+parseFloat(L[6])*c;S_(e,m,x,D,O,P,F,ee,Z,G),m=Z,x=G;continue}let N=L.map((D,O)=>{let P=parseFloat(D);return O%2===0?r+P*a:n+P*c});if(C==="M")e.moveTo(N[0],N[1]),m=N[0],x=N[1],y=m,w=x;else if(C==="L")e.lineTo(N[0],N[1]),m=N[0],x=N[1],y=m,w=x;else if(C==="Q")e.quadraticCurveTo(N[0],N[1],N[2],N[3]),y=N[0],w=N[1],m=N[2],x=N[3];else if(C==="T"){let D,O;v==="Q"||v==="T"?(D=2*m-y,O=2*x-w):(D=m,O=x),e.quadraticCurveTo(D,O,N[0],N[1]),y=D,w=O,m=N[0],x=N[1]}else C==="C"&&(e.bezierCurveTo(N[0],N[1],N[2],N[3],N[4],N[5]),y=N[2],w=N[3],m=N[4],x=N[5]);v=C}d!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*d,e.stroke()):e.fill()}function S_(e,t,r,n,a,c,l,d,f,m){if(n===0||a===0){e.lineTo(f,m);return}n=Math.abs(n),a=Math.abs(a);let x=Math.cos(c),y=Math.sin(c),w=(t-f)/2,v=(r-m)/2,T=x*w+y*v,C=-y*w+x*v,L=n*n,N=a*a,D=T*T,O=C*C,P=D/L+O/N;if(P>1){let ye=Math.sqrt(P);n*=ye,a*=ye,L=n*n,N=a*a}let F=(L*N-L*O-N*D)/(L*O+N*D);F<0&&(F=0);let ee=(l===d?-1:1)*Math.sqrt(F),Z=ee*(n*C/a),G=ee*-(a*T/n),de=x*Z-y*G+(t+f)/2,pe=y*Z+x*G+(r+m)/2,J=(T-Z)/n,Re=(C-G)/a,Ze=(-T-Z)/n,V=(-C-G)/a,ve=Math.atan2(Re,J),qe=Math.atan2(V,Ze)-ve;d===0&&qe>0?qe-=2*Math.PI:d===1&&qe<0&&(qe+=2*Math.PI);let le=ve+qe;e.ellipse(de,pe,n,a,c,ve,le,d===0)}function C_(e,t,r,n,a,c,l,d){e.save(),e.fillRect(r,n,a,c),d&&(e.fillStyle=d,e.strokeStyle=d),e.lineWidth=l,e.lineCap="square",e.beginPath();for(let f of t.d.split(" ")){let m=f[0],x=f.substring(1).split(",");if(!x[0]||!x[1]){m==="Z"&&e.closePath();continue}let y=x.map((w,v)=>{let T=parseFloat(w);return v%2===0?r+T*a:n+T*c});m==="M"?e.moveTo(y[0],y[1]):m==="L"&&e.lineTo(y[0],y[1])}t.type===1?e.stroke():e.fill(),e.restore()}var Vx=new Map;function __(e,t,r,n,a,c,l=0){let d=Vx.get(t);d||(d=new Map,Vx.set(t,d));let f=e.fillStyle;if(typeof f!="string")throw new Error(`Unexpected fillStyle type "${f}"`);let m=d.get(f);if(!m){let w=t[0].length,v=t.length,T=e.canvas.ownerDocument.createElement("canvas");T.width=w,T.height=v;let C=qs(T.getContext("2d")),L=new ImageData(w,v),N,D,O,P;if(f.startsWith("#"))N=parseInt(f.slice(1,3),16),D=parseInt(f.slice(3,5),16),O=parseInt(f.slice(5,7),16),P=f.length>7&&parseInt(f.slice(7,9),16)||1;else if(f.startsWith("rgba"))[N,D,O,P]=f.substring(5,f.length-1).split(",").map(F=>parseFloat(F));else throw new Error(`Unexpected fillStyle color format "${f}" when drawing pattern glyph`);for(let F=0;F<v;F++)for(let ee=0;ee<w;ee++)L.data[(F*w+ee)*4]=N,L.data[(F*w+ee)*4+1]=D,L.data[(F*w+ee)*4+2]=O,L.data[(F*w+ee)*4+3]=t[F][ee]*(P*255);C.putImageData(L,0,0),m=qs(e.createPattern(T,null)),d.set(f,m)}let x=l>>1&1,y=l&1;x!==0||y!==0?m.setTransform(new DOMMatrix().translateSelf(-x,-y)):m.setTransform(new DOMMatrix),e.fillStyle=m,e.fillRect(r,n,a,c)}function k_(e,t,r,n,a,c,l,d,f){e.save(),e.beginPath(),e.rect(r,n,a,c),e.clip(),e.beginPath();let m;if(typeof t=="function"){let y=.15/c*a;m=t(.15,y)}else m=t;let x={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let y of m.split(" ")){let w=y[0];if(w==="Z"){e.closePath(),x.lastCommand=w;continue}let v=F3[w];if(!v){d.error(`Could not find drawing instructions for "${w}"`);continue}let T=y.substring(1).split(",");!T[0]||!T[1]||(v(e,$3(T,a,c,r,n,!0,l,0,0,!1),x),x.lastCommand=w)}f!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*f,e.stroke()):e.fill(),e.closePath(),e.restore()}function L_(e,t,r,n,a,c){e.beginPath();for(let l of t.split(" ")){let d=l[0];if(d==="Z"){e.closePath();continue}let f=l.substring(1).split(",");if(!f[0]||!f[1])continue;let m=r+parseFloat(f[0])*a,x=n+parseFloat(f[1])*c;d==="M"?e.moveTo(m,x):d==="L"&&e.lineTo(m,x)}e.clip()}function I_(e,t,r,n,a,c,l,d,f){let m=new Path2D;m.rect(r,n,a,c),e.clip(m),e.beginPath();let x=l/12;e.lineWidth=d*x;let y={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let w of t.d.split(" ")){let v=w[0];if(v==="Z"){e.closePath(),y.lastCommand=v;continue}let T=F3[v];if(!T){f.error(`Could not find drawing instructions for "${v}"`);continue}let C=w.substring(1).split(",");!C[0]||!C[1]||(T(e,$3(C,a,c,r,n,!1,d,(t.leftPadding??0)*(x/2),(t.rightPadding??0)*(x/2)),y),y.lastCommand=v)}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function qx(e,t,r=0){return Math.max(Math.min(e,t),r)}var F3={C:(e,t,r)=>{e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),r.lastControlX=t[2],r.lastControlY=t[3],r.currentX=t[4],r.currentY=t[5]},L:(e,t,r)=>{e.lineTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},M:(e,t,r)=>{e.moveTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},Q:(e,t,r)=>{e.quadraticCurveTo(t[0],t[1],t[2],t[3]),r.lastControlX=t[0],r.lastControlY=t[1],r.currentX=t[2],r.currentY=t[3]},T:(e,t,r)=>{let n,a;r.lastCommand==="Q"||r.lastCommand==="T"?(n=2*r.currentX-r.lastControlX,a=2*r.currentY-r.lastControlY):(n=r.currentX,a=r.currentY),e.quadraticCurveTo(n,a,t[0],t[1]),r.lastControlX=n,r.lastControlY=a,r.currentX=t[0],r.currentY=t[1]}};function $3(e,t,r,n,a,c,l,d=0,f=0,m=!0){let x=e.map(y=>parseFloat(y)||parseInt(y));if(x.length<2)throw new Error("Too few arguments for instruction");for(let y=0;y<x.length;y+=2){if(x[y]*=t-d*l-f*l,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?qx(w,t,0):w}x[y]+=n+d*l}for(let y=1;y<x.length;y+=2){if(x[y]*=r,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?qx(w,r,0):w}x[y]+=a}return x}var Yx=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Zx=class{constructor(){this._data=new Yx}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new Yx),this._data.get(e,t).set(r,n,a)}get(e,t,r,n){return this._data.get(e,t)?.get(r,n)}clear(){this._data.clear()}},U3=class{constructor(e){this._tasks=[],this._i=0,this._logService=e}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,r=0,n=e.timeRemaining(),a;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),a=e.timeRemaining(),r*1.5>a){n-t<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=a}this.clear()}},E_=class extends U3{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let r=performance.now()+t;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},N_=class extends U3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},R_="requestIdleCallback"in globalThis?N_:E_,Gu=class z3{constructor(){this.fg=0,this.bg=0,this.extended=new H3}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 z3;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}},H3=class W3{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 W3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xo=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return li(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=li(()=>{let l=this._listeners.indexOf(a);l!==-1&&this._listeners.splice(l,1)});return n&&(Array.isArray(n)?n.push(c):n.add(c)),c},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:r,thisArgs:n}=this._listeners[0];r.call(n,t);return}default:{let r=this._listeners.slice();for(let{fn:n,thisArgs:a}of r)n.call(a,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},qc;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new D3;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(qc||={});var Kx={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Md=2,jd,mc=class Ou{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new Zx,this._cacheMapCombined=new Zx,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Gu,this._textureSize=512,this._onAddTextureAtlasCanvas=new Xo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Xo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=V3(t,this._config.deviceCellWidth*4+Md*2,this._config.deviceCellHeight+Md*2),this._tmpCtx=qs(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose(),this._onRemoveTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new R_(this._logService);for(let r=33;r<126;r++)t.enqueue(()=>{if(!this._cacheMap.get(r,0,0,0)){let n=this._drawToCache(r,0,0,0,!1,void 0);this._cacheMap.set(r,0,0,0,n)}})}beginFrame(){let t=this._requestClearModel;return this._requestClearModel=!1,t}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Ou.maxAtlasPages&&this._pages.length>=Math.max(4,Ou.maxAtlasPages)){let r=this._pages.filter(m=>m.canvas.width*2<=(Ou.maxTextureSize||4096)).sort((m,x)=>x.canvas.width!==m.canvas.width?x.canvas.width-m.canvas.width:x.percentageUsed-m.percentageUsed),n=-1,a=0;for(let m=0;m<r.length;m++)if(r[m].canvas.width!==a)n=m,a=r[m].canvas.width;else if(m-n===3)break;let c=r.slice(n,n+4);if(c.length<4||c.some(m=>m.canvas.width!==c[0].canvas.width)){let m=new Qc(this._document,this._textureSize);return this._pages.push(m),this._activePages.push(m),this._onAddTextureAtlasCanvas.fire(m.canvas),m}let l=c.map(m=>m.glyphs[0].texturePage).sort((m,x)=>m-x),d=this.pages.length-c.length,f=this._mergePages(c,d);f.version=++Qc.nextVersion;for(let m=l.length-1;m>=0;m--)this._deletePage(l[m]);this.pages.push(f),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(f.canvas)}let t=new Qc(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(t,r){let n=t[0].canvas.width*2,a=new Qc(this._document,n,t);for(let[c,l]of t.entries()){let d=c*l.canvas.width%n,f=Math.floor(c/2)*l.canvas.height;a.ctx.drawImage(l.canvas,d,f);for(let x of l.glyphs)x.texturePage=r,x.sizeClipSpace.x=x.size.x/n,x.sizeClipSpace.y=x.size.y/n,x.texturePosition.x+=d,x.texturePosition.y+=f,x.texturePositionClipSpace.x=x.texturePosition.x/n,x.texturePositionClipSpace.y=x.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(l.canvas);let m=this._activePages.indexOf(l);m!==-1&&this._activePages.splice(m,1)}return a}_deletePage(t){this._pages.splice(t,1);for(let r=t;r<this._pages.length;r++){let n=this._pages[r];for(let a of n.glyphs)a.texturePage--;n.version=++Qc.nextVersion}}getRasterizedGlyphCombinedChar(t,r,n,a,c,l){return this._getFromCacheMap(this._cacheMapCombined,t,r,n,a,c,l)}getRasterizedGlyph(t,r,n,a,c,l){return this._getFromCacheMap(this._cacheMap,t,r,n,a,c,l)}_getFromCacheMap(t,r,n,a,c,l,d){return jd=t.get(r,n,a,c),jd||(jd=this._drawToCache(r,n,a,c,l,d),t.set(r,n,a,c,jd)),jd}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,r,n,a){if(this._config.allowTransparency)return Co;let c;switch(t){case 16777216:case 33554432:c=this._getColorFromAnsiIndex(r);break;case 50331648:let l=Gu.toColorRGB(r);c=Sa.toColor(l[0],l[1],l[2]);break;default:n?c=h0.opaque(this._config.colors.foreground):c=this._config.colors.background;break}return this._config.allowTransparency||(c=h0.opaque(c)),c}_getForegroundColor(t,r,n,a,c,l,d,f,m,x){let y=this._getMinimumContrastColor(t,r,n,a,c,l,d,m,f,x);if(y)return y;let w;switch(c){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&m&&l<8&&(l+=8),w=this._getColorFromAnsiIndex(l);break;case 50331648:let v=Gu.toColorRGB(l);w=Sa.toColor(v[0],v[1],v[2]);break;default:d?w=this._config.colors.background:w=this._config.colors.foreground}return this._config.allowTransparency&&(w=h0.opaque(w)),f&&(w=h0.multiplyOpacity(w,b_)),w}_resolveBackgroundRgba(t,r,n){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(t,r,n,a){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&a&&r<8&&(r+=8),this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(t,r,n,a,c,l,d,f,m,x){if(this._config.minimumContrastRatio===1||x)return;let y=this._getContrastCache(m),w=y.getColor(t,a);if(w!==void 0)return w??void 0;let v=this._resolveBackgroundRgba(r,n,d),T=this._resolveForegroundRgba(c,l,d,f),C=Xc.ensureContrastRatio(v,T,this._config.minimumContrastRatio/(m?2:1));if(!C){y.setColor(t,a,null);return}let L=Sa.toColor(C>>24&255,C>>16&255,C>>8&255);return y.setColor(t,a,L),L}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,r,n,a,c,l){let d=typeof t=="number"?String.fromCharCode(t):t;l&&this._tmpCanvas.parentElement!==l&&(this._tmpCanvas.style.display="none",l.append(this._tmpCanvas));let f=Math.min(this._config.deviceCellWidth*Math.max(d.length,2)+Md*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<f&&(this._tmpCanvas.width=f);let m=Math.min(this._config.deviceCellHeight+Md*4,this._textureSize);if(this._tmpCanvas.height<m&&(this._tmpCanvas.height=m),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=r,this._workAttributeData.extended.ext=a,!!this._workAttributeData.isInvisible())return Kx;let x=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),w=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),T=!!this._workAttributeData.isUnderline(),C=!!this._workAttributeData.isStrikethrough(),L=!!this._workAttributeData.isOverline(),N=this._workAttributeData.getFgColor(),D=this._workAttributeData.getFgColorMode(),O=this._workAttributeData.getBgColor(),P=this._workAttributeData.getBgColorMode();if(y){let Fe=N;N=O,O=Fe;let se=D;D=P,P=se}let F=this._getBackgroundColor(P,O,y,w);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=F.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let ee=x?this._config.fontWeightBold:this._config.fontWeight,Z=v?"italic":"";this._tmpCtx.font=`${Z} ${ee} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=O3;let G=d.length===1&&fg(d.charCodeAt(0)),de=d.length===1&&l_(d.charCodeAt(0)),pe=this._getForegroundColor(r,P,O,n,D,N,y,w,x,P3(d.charCodeAt(0)));this._tmpCtx.fillStyle=pe.css;let J=de?0:Md*2,Re=!1;if(this._config.customGlyphs!==!1){let Fe=this._workAttributeData.getUnderlineVariantOffset();Re=y_(this._tmpCtx,d,J,J,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,F.css,Fe)}let Ze=!G,V;if(typeof t=="number"?V=this._unicodeService.wcwidth(t):V=this._unicodeService.getStringCellWidth(t),T){this._tmpCtx.save();let Fe=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),se=Fe%2===1?.5:0;if(this._tmpCtx.lineWidth=Fe,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())Ze=!1,this._tmpCtx.strokeStyle=`rgb(${Gu.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{Ze=!1;let ze=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&ze<8&&(ze+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(ze).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let De=J,_e=Math.ceil(J+this._config.deviceCharHeight)-se-(c?Fe*2:0),Me=_e+Fe*2,Ke=this._workAttributeData.getUnderlineVariantOffset(),Ne=0,ae=0;for(let ze=0;ze<V;ze++){let at=!1;this._tmpCtx.save(),Ne=_e,ae=Me;let ct=De+ze*this._config.deviceCellWidth,me=De+(ze+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(ct,_e),this._tmpCtx.lineTo(me,_e),this._tmpCtx.moveTo(ct,Me),this._tmpCtx.lineTo(me,Me);break;case 3:Ne=this._config.deviceCharHeight+1,ae=Ne+3*this._config.devicePixelRatio;let ut=new Path2D;ut.rect(ct,Ne,this._config.deviceCellWidth,ae-Ne),this._tmpCtx.clip(ut);let ft=this._config.deviceCellWidth,Se=ae-Ne,He=ft/6,ke=Se/3,z=[[0,2,1,3,2.4,3,0,.6],[5.5,0,2.5,3,1.1,3,4.1,0],[4,0,6,2,6,.6,5.4,0]];for(let Mt of z){this._tmpCtx.beginPath();for(let nr=0;nr<Mt.length;nr+=2){let jt=ct+Mt[nr]*He,Xt=ae-Mt[nr+1]*ke;nr===0?this._tmpCtx.moveTo(jt,Xt):this._tmpCtx.lineTo(jt,Xt)}this._tmpCtx.closePath(),this._tmpCtx.fill()}at=!0;break;case 4:let ie=Ke===0?0:Ke>=Fe?Fe*2-Ke:Fe-Ke;Ke>=Fe||ie===0?(this._tmpCtx.setLineDash([Math.round(Fe),Math.round(Fe)]),this._tmpCtx.moveTo(ct+ie,_e),this._tmpCtx.lineTo(me,_e)):(this._tmpCtx.setLineDash([Math.round(Fe),Math.round(Fe)]),this._tmpCtx.moveTo(ct,_e),this._tmpCtx.lineTo(ct+ie,_e),this._tmpCtx.moveTo(ct+ie+Fe,_e),this._tmpCtx.lineTo(me,_e)),Ke=p_(me-ct,Fe,Ke);break;case 5:let ge=.6,We=.3,tt=me-ct,wt=Math.floor(ge*tt),Zt=Math.floor(We*tt),Ut=tt-wt-Zt;this._tmpCtx.setLineDash([wt,Zt,Ut]),this._tmpCtx.moveTo(ct,_e),this._tmpCtx.lineTo(me,_e);break;default:this._tmpCtx.moveTo(ct,_e),this._tmpCtx.lineTo(me,_e);break}at||this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!Re&&this._config.fontSize>=12&&!this._config.allowTransparency&&d!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let ze=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in ze&&ze.actualBoundingBoxDescent>0){this._tmpCtx.save();let at=new Path2D;at.rect(De,Ne-Math.ceil(Fe/2),this._config.deviceCellWidth*V,ae-Ne+Math.ceil(Fe/2)),this._tmpCtx.clip(at),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=F.css,this._tmpCtx.strokeText(d,J,J+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(L){let Fe=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),se=Fe%2===1?.5:0;this._tmpCtx.lineWidth=Fe,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(J,J+se),this._tmpCtx.lineTo(J+this._config.deviceCharWidth*V,J+se),this._tmpCtx.stroke()}if(Re||this._tmpCtx.fillText(d,J,J+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let Fe=Vp(this._tmpCtx.getImageData(J,J,this._config.deviceCellWidth,this._config.deviceCellHeight),F,pe,Ze);if(Fe)for(let se=1;se<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=F.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,J,J+this._config.deviceCharHeight-se),Fe=Vp(this._tmpCtx.getImageData(J,J,this._config.deviceCellWidth,this._config.deviceCellHeight),F,pe,Ze),!!Fe);se++);}if(C){let Fe=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),se=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=Fe,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(J,J+Math.floor(this._config.deviceCharHeight/2)-se),this._tmpCtx.lineTo(J+this._config.deviceCharWidth*V,J+Math.floor(this._config.deviceCharHeight/2)-se),this._tmpCtx.stroke()}this._tmpCtx.restore();let ve=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),qe;if(this._config.allowTransparency?qe=M_(ve):qe=Vp(ve,F,pe,Ze),qe)return Kx;let le=this._findGlyphBoundingBox(ve,this._workBoundingBox,f,de,Re,J),ye,Te;for(;;){if(this._activePages.length===0){let Fe=this._createNewPage();ye=Fe,Te=Fe.currentRow,Te.height=le.size.y;break}ye=this._activePages[this._activePages.length-1],Te=ye.currentRow;for(let Fe of this._activePages)le.size.y<=Fe.currentRow.height&&(ye=Fe,Te=Fe.currentRow);for(let Fe=this._activePages.length-1;Fe>=0;Fe--)for(let se of this._activePages[Fe].fixedRows)se.height<=Te.height&&le.size.y<=se.height&&(ye=this._activePages[Fe],Te=se);if(le.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Qc(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),ye=this._overflowSizePage,Te=this._overflowSizePage.currentRow,Te.x+le.size.x>=ye.canvas.width&&(Te.x=0,Te.y+=Te.height,Te.height=0);break}if(Te.y+le.size.y>=ye.canvas.height||Te.height>le.size.y+2){let Fe=!1;if(ye.currentRow.y+ye.currentRow.height+le.size.y>=ye.canvas.height){let se;for(let De of this._activePages)if(De.currentRow.y+De.currentRow.height+le.size.y<De.canvas.height){se=De;break}if(se)ye=se;else if(Ou.maxAtlasPages&&this._pages.length>=Ou.maxAtlasPages&&Te.y+le.size.y<=ye.canvas.height&&Te.height>=le.size.y&&Te.x+le.size.x<=ye.canvas.width)Fe=!0;else{let De=this._createNewPage();ye=De,Te=De.currentRow,Te.height=le.size.y,Fe=!0}}Fe||(ye.currentRow.height>0&&ye.fixedRows.push(ye.currentRow),Te={x:0,y:ye.currentRow.y+ye.currentRow.height,height:le.size.y},ye.fixedRows.push(Te),ye.currentRow={x:0,y:Te.y+Te.height,height:0})}if(Te.x+le.size.x<=ye.canvas.width)break;Te===ye.currentRow?(Te.x=0,Te.y+=Te.height,Te.height=0):ye.fixedRows.splice(ye.fixedRows.indexOf(Te),1)}return le.texturePage=this._pages.indexOf(ye),le.texturePosition.x=Te.x,le.texturePosition.y=Te.y,le.texturePositionClipSpace.x=Te.x/ye.canvas.width,le.texturePositionClipSpace.y=Te.y/ye.canvas.height,le.sizeClipSpace.x/=ye.canvas.width,le.sizeClipSpace.y/=ye.canvas.height,Te.height=Math.max(Te.height,le.size.y),Te.x+=le.size.x,ye.ctx.putImageData(ve,le.texturePosition.x-this._workBoundingBox.left,le.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,le.size.x,le.size.y),ye.addGlyph(le),ye.version=++Qc.nextVersion,le}_findGlyphBoundingBox(t,r,n,a,c,l){r.top=0;let d=a?this._config.deviceCellHeight:this._tmpCanvas.height,f=a?this._config.deviceCellWidth:n,m=!1;for(let x=0;x<d;x++){for(let y=0;y<f;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.top=x,m=!0;break}}if(m)break}r.left=0,m=!1;for(let x=0;x<l+f;x++){for(let y=0;y<d;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.left=x,m=!0;break}}if(m)break}r.right=f,m=!1;for(let x=l+f-1;x>=l;x--){for(let y=0;y<d;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.right=x,m=!0;break}}if(m)break}r.bottom=d,m=!1;for(let x=d-1;x>=0;x--){for(let y=0;y<f;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.bottom=x,m=!0;break}}if(m)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:r.right-r.left+1,y:r.bottom-r.top+1},sizeClipSpace:{x:r.right-r.left+1,y:r.bottom-r.top+1},offset:{x:-r.left+l+(a||c?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-r.top+l+(a||c?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},G3=class p1{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++p1.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=V3(t,r,r),this.ctx=qs(this.canvas.getContext("2d",{alpha:!0})),n)if(n.length===4)this._glyphs=this._glyphs.concat(n[0].glyphs,n[1].glyphs,n[2].glyphs,n[3].glyphs),this._usedPixels=n[0]._usedPixels+n[1]._usedPixels+n[2]._usedPixels+n[3]._usedPixels;else for(let a=0;a<n.length;++a)this._glyphs=this._glyphs.concat(n[a].glyphs),this._usedPixels+=n[a]._usedPixels}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version=++p1.nextVersion}};G3.nextVersion=0;var Qc=G3;function Vp(e,t,r,n){let a=t.rgba>>>24,c=t.rgba>>>16&255,l=t.rgba>>>8&255,d=r.rgba>>>24,f=r.rgba>>>16&255,m=r.rgba>>>8&255,x=Math.floor((Math.abs(a-d)+Math.abs(c-f)+Math.abs(l-m))/12),y=!0;for(let w=0;w<e.data.length;w+=4)e.data[w]===a&&e.data[w+1]===c&&e.data[w+2]===l||n&&Math.abs(e.data[w]-a)+Math.abs(e.data[w+1]-c)+Math.abs(e.data[w+2]-l)<x?e.data[w+3]=0:y=!1;return y}function M_(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function V3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function j_(e,t,r,n,a,c,l,d,f=!0){let m={foreground:c.foreground,background:c.background,cursor:Co,cursorAccent:Co,selectionForeground:Co,selectionBackgroundTransparent:Co,selectionBackgroundOpaque:Co,selectionInactiveBackgroundTransparent:Co,selectionInactiveBackgroundOpaque:Co,overviewRulerBorder:Co,scrollbarSliderBackground:Co,scrollbarSliderHoverBackground:Co,scrollbarSliderActiveBackground:Co,ansi:c.ansi.slice(),contrastCache:c.contrastCache,halfContrastCache:c.halfContrastCache};return{customGlyphs:f,devicePixelRatio:l,deviceMaxTextureSize:d,letterSpacing:a.letterSpacing,lineHeight:a.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:r,deviceCharHeight:n,fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.fontWeight,fontWeightBold:a.fontWeightBold,allowTransparency:a.allowTransparency,drawBoldTextInBrightColors:a.drawBoldTextInBrightColors,minimumContrastRatio:a.minimumContrastRatio,colors:m}}function Xx(e,t){for(let r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.deviceMaxTextureSize===t.deviceMaxTextureSize&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCellWidth===t.deviceCellWidth&&e.deviceCellHeight===t.deviceCellHeight&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function D_(e){return(e&50331648)===16777216||(e&50331648)===33554432}var Lo=[];function q3(e,t,r,n,a,c,l,d,f,m=!0){let x=j_(n,a,c,l,t,r,d,f,m);for(let T=0;T<Lo.length;T++){let C=Lo[T],L=C.ownedBy.indexOf(e);if(L>=0){if(Xx(C.config,x))return C.atlas;C.ownedBy.length===1?(C.atlas.dispose(),Lo.splice(T,1)):C.ownedBy.splice(L,1);break}}for(let T=0;T<Lo.length;T++){let C=Lo[T];if(Xx(C.config,x))return C.ownedBy.push(e),C.atlas}let y=e._core,w=y._logService,v={atlas:new mc(document,x,y.unicodeService,w),config:x,ownedBy:[e]};return Lo.push(v),v.atlas}function Jx(e){for(let t=0;t<Lo.length;t++){let r=Lo[t].ownedBy.indexOf(e);if(r!==-1){Lo[t].ownedBy.length===1?(Lo[t].atlas.dispose(),Lo.splice(t,1)):Lo[t].ownedBy.splice(r,1);break}}}var B_=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._isIdlePaused=!1,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&(this._restartInterval(),this._resetIdleTimer())}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}restartBlinkAnimation(){this._isIdlePaused&&this._resetIdleTimer(),!this.isPaused&&(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(e=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0){this._restartInterval(t);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(t);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},600)},e)}pause(){this.isCursorVisible=!0,this._isIdlePaused=!1,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this._resetIdleTimer(),this.restartBlinkAnimation()}_resetIdleTimer(){this._isIdlePaused=!1,this._idleTimeout&&this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=this._coreBrowserService.window.setTimeout(()=>{this._stopBlinkingDueToIdle()},3e5)}_stopBlinkingDueToIdle(){this.isCursorVisible=!0,this._isIdlePaused=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0,this._renderCallback()}};function e2(e,t,r){let n=new t.ResizeObserver(a=>{let c=a.find(f=>f.target===e);if(!c)return;if(!("devicePixelContentBoxSize"in c)){n?.disconnect(),n=void 0;return}let l=c.devicePixelContentBoxSize[0].inlineSize,d=c.devicePixelContentBoxSize[0].blockSize;l>0&&d>0&&r(l,d)});try{n.observe(e,{box:["device-pixel-content-box"]})}catch{n.disconnect(),n=void 0}return li(()=>n?.disconnect())}function Q_(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var P_=class Y3 extends Gu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new H3,this.combinedData=""}static fromCharData(t){let r=new Y3;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Q_(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(t){if(this.getFgColorMode()!==t.getFgColorMode()||this.getFgColor()!==t.getFgColor()||this.getBgColorMode()!==t.getBgColorMode()||this.getBgColor()!==t.getBgColor()||this.isInverse()!==t.isInverse()||this.isBold()!==t.isBold()||this.isUnderline()!==t.isUnderline())return!1;if(this.isUnderline()){if(this.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let r=this.isUnderlineColorDefault(),n=t.isUnderlineColorDefault();if(!(r&&n)&&(r!==n||this.getUnderlineColor()!==t.getUnderlineColor()||this.getUnderlineColorMode()!==t.getUnderlineColorMode()))return!1}return!(this.isOverline()!==t.isOverline()||this.isBlink()!==t.isBlink()||this.isInvisible()!==t.isInvisible()||this.isItalic()!==t.isItalic()||this.isDim()!==t.isDim()||this.isStrikethrough()!==t.isStrikethrough())}},O_=class extends lu{constructor(e,t,r){super(),this._renderCallback=e,this._coreBrowserService=t,this._optionsService=r,this._intervalDuration=0,this._blinkOn=!0,this._needsBlinkInViewport=!1,this._isViewportVisible=!0,this._register(this._optionsService.onSpecificOptionChange("blinkIntervalDuration",n=>{this.setIntervalDuration(n)})),this.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration),this._register(li(()=>this._clearInterval()))}get isBlinkOn(){return this._blinkOn}get isEnabled(){return this._intervalDuration>0}setNeedsBlinkInViewport(e){this._needsBlinkInViewport!==e&&(this._needsBlinkInViewport=e,this._updateIntervalState())}setViewportVisible(e){this._isViewportVisible!==e&&(this._isViewportVisible=e,this._updateIntervalState())}setIntervalDuration(e){e!==this._intervalDuration&&(this._intervalDuration=e,this._clearInterval(),this._updateIntervalState())}_updateIntervalState(){if(this._intervalDuration>0&&this._needsBlinkInViewport&&this._isViewportVisible){if(this._interval!==void 0)return;let e=this._blinkOn;this._blinkOn=!0,this._interval=this._coreBrowserService.window.setInterval(()=>{this._blinkOn=!this._blinkOn,this._renderCallback()},this._intervalDuration),e||this._renderCallback();return}this._clearInterval(),this._blinkOn||(this._blinkOn=!0,this._renderCallback())}_clearInterval(){this._interval!==void 0&&(this._coreBrowserService.window.clearInterval(this._interval),this._interval=void 0)}},Z3=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function K3(e,t,r,n){let a=qs(e.createProgram());if(e.attachShader(a,qs(t2(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,qs(t2(e,e.FRAGMENT_SHADER,r,n))),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS))return a;n.error(e.getProgramInfoLog(a)),e.deleteProgram(a)}function t2(e,t,r,n){let a=qs(e.createShader(t));if(e.shaderSource(a,r),e.compileShader(a),e.getShaderParameter(a,e.COMPILE_STATUS))return a;n.error(e.getShaderInfoLog(a)),e.deleteShader(a)}function F_(e,t){let r=Math.min(e.length*2,t),n=new Float32Array(r);for(let a=0;a<e.length;a++)n[a]=e[a];return n}var $_=class{constructor(t){this.texture=t,this.version=-1}},U_=`#version 300 es
11
+ layout (location = 0) in vec2 a_unitquad;
12
+ layout (location = 1) in vec2 a_cellpos;
13
+ layout (location = 2) in vec2 a_offset;
14
+ layout (location = 3) in vec2 a_size;
15
+ layout (location = 4) in float a_texpage;
16
+ layout (location = 5) in vec2 a_texcoord;
17
+ layout (location = 6) in vec2 a_texsize;
18
+
19
+ uniform mat4 u_projection;
20
+ uniform vec2 u_resolution;
21
+
22
+ out vec2 v_texcoord;
23
+ flat out int v_texpage;
24
+
25
+ void main() {
26
+ vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
27
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
28
+ v_texpage = int(a_texpage);
29
+ v_texcoord = a_texcoord + a_unitquad * a_texsize;
30
+ }`;function z_(e){let t="";for(let r=1;r<e;r++)t+=` else if (v_texpage == ${r}) { outColor = texture(u_texture[${r}], v_texcoord); }`;return`#version 300 es
31
+ precision lowp float;
32
+
33
+ in vec2 v_texcoord;
34
+ flat in int v_texpage;
35
+
36
+ uniform sampler2D u_texture[${e}];
37
+
38
+ out vec4 outColor;
39
+
40
+ void main() {
41
+ if (v_texpage == 0) {
42
+ outColor = texture(u_texture[0], v_texcoord);
43
+ } ${t}
44
+ }`}var js=0,gs,qp=0,Dd=0,H_=class extends lu{constructor(t,r,n,a,c){super(),this._terminal=t,this._gl=r,this._dimensions=n,this._optionsService=a,this._logService=c,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let l=this._gl;mc.maxAtlasPages===void 0&&(mc.maxAtlasPages=Math.min(32,qs(l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS))),mc.maxTextureSize=qs(l.getParameter(l.MAX_TEXTURE_SIZE))),this._program=qs(K3(l,U_,z_(mc.maxAtlasPages),this._logService)),this._register(li(()=>l.deleteProgram(this._program))),this._projectionLocation=qs(l.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=qs(l.getUniformLocation(this._program,"u_resolution")),this._textureLocation=qs(l.getUniformLocation(this._program,"u_texture"));let d=this._vertexArrayObject=l.createVertexArray();this._register(li(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let f=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(li(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,f,l.STATIC_DRAW),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=l.createBuffer();this._register(li(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=qs(l.createBuffer()),this._register(li(()=>l.deleteBuffer(this._attributesBuffer))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,2,l.FLOAT,!1,44,0),l.vertexAttribDivisor(2,1),l.enableVertexAttribArray(3),l.vertexAttribPointer(3,2,l.FLOAT,!1,44,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(3,1),l.enableVertexAttribArray(4),l.vertexAttribPointer(4,1,l.FLOAT,!1,44,4*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(4,1),l.enableVertexAttribArray(5),l.vertexAttribPointer(5,2,l.FLOAT,!1,44,5*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(5,1),l.enableVertexAttribArray(6),l.vertexAttribPointer(6,2,l.FLOAT,!1,44,7*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(6,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,44,9*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.useProgram(this._program);let w=new Int32Array(mc.maxAtlasPages);for(let v=0;v<mc.maxAtlasPages;v++)w[v]=v;l.uniform1iv(this._textureLocation,w),l.uniformMatrix4fv(this._projectionLocation,!1,Z3),this._atlasTextures=[];for(let v=0;v<mc.maxAtlasPages;v++){let T=new $_(qs(l.createTexture()));this._register(li(()=>l.deleteTexture(T.texture))),l.activeTexture(l.TEXTURE0+v),l.bindTexture(l.TEXTURE_2D,T.texture),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,1,1,0,l.RGBA,l.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[v]=T}l.enable(l.BLEND),l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,r,n,a,c,l,d,f,m){this._updateCell(this._vertices.attributes,t,r,n,a,c,l,d,f,m)}_updateCell(t,r,n,a,c,l,d,f,m,x){if(js=(n*this._terminal.cols+r)*11,a===0||a===void 0){t.fill(0,js,js+11-1-2);return}this._atlas&&(f&&f.length>1?gs=this._atlas.getRasterizedGlyphCombinedChar(f,c,l,d,!1,this._terminal.element):gs=this._atlas.getRasterizedGlyph(a,c,l,d,!1,this._terminal.element),qp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),c!==x&&gs.offset.x>qp?(Dd=gs.offset.x-qp,t[js]=-(gs.offset.x-Dd)+this._dimensions.device.char.left,t[js+1]=-gs.offset.y+this._dimensions.device.char.top,t[js+2]=(gs.size.x-Dd)/this._dimensions.device.canvas.width,t[js+3]=gs.size.y/this._dimensions.device.canvas.height,t[js+4]=gs.texturePage,t[js+5]=gs.texturePositionClipSpace.x+Dd/this._atlas.pages[gs.texturePage].canvas.width,t[js+6]=gs.texturePositionClipSpace.y,t[js+7]=gs.sizeClipSpace.x-Dd/this._atlas.pages[gs.texturePage].canvas.width,t[js+8]=gs.sizeClipSpace.y):(t[js]=-gs.offset.x+this._dimensions.device.char.left,t[js+1]=-gs.offset.y+this._dimensions.device.char.top,t[js+2]=gs.size.x/this._dimensions.device.canvas.width,t[js+3]=gs.size.y/this._dimensions.device.canvas.height,t[js+4]=gs.texturePage,t[js+5]=gs.texturePositionClipSpace.x,t[js+6]=gs.texturePositionClipSpace.y,t[js+7]=gs.sizeClipSpace.x,t[js+8]=gs.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&h_(a,m,gs.size.x,this._dimensions.device.cell.width)&&(t[js+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,r=t.cols*t.rows*11;this._vertices.count!==r?this._vertices.attributes=new Float32Array(r):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==r?this._vertices.attributesBuffers[n]=new Float32Array(r):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=r,n=0;for(let a=0;a<t.rows;a++)for(let c=0;c<t.cols;c++)this._vertices.attributes[n+9]=c/t.cols,this._vertices.attributes[n+10]=a/t.rows,n+=11}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),t.uniform2f(this._resolutionLocation,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),this.clear()}render(t){if(!this._atlas)return;let r=this._gl;r.useProgram(this._program),r.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],a=0;for(let c=0;c<t.lineLengths.length;c++){let l=c*this._terminal.cols*11,d=this._vertices.attributes.subarray(l,l+t.lineLengths[c]*11);n.set(d,a),a+=d.length}r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,n.subarray(0,a),r.STREAM_DRAW);for(let c=0;c<this._atlas.pages.length;c++)this._atlas.pages[c].version!==this._atlasTextures[c].version&&this._bindAtlasPageTexture(r,this._atlas,c);r.drawElementsInstanced(r.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,a/11)}setAtlas(t){this._atlas=t,this.invalidateAtlasTextures()}invalidateAtlasTextures(){for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(t,r,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r.pages[n].canvas),this._atlasTextures[n].version=r.pages[n].version}setDimensions(t){this._dimensions=t}},W_=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(t,r,n,a=!1){if(this.selectionStart=r,this.selectionEnd=n,!r||!n||r[0]===n[0]&&r[1]===n[1]){this.clear();return}let c=t.buffers.active.ydisp,l=r[1]-c,d=n[1]-c,f=Math.max(l,0),m=Math.min(d,t.rows-1);if(f>=t.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=a,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=f,this.viewportCappedEndRow=m,this.startCol=r[0],this.endCol=n[0]}isCellSelected(t,r,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&n>=this.viewportCappedStartRow&&r<this.endCol&&n<=this.viewportCappedEndRow:r<this.startCol&&n>=this.viewportCappedStartRow&&r>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol):!1}};function G_(){return new W_}var V_=2147483648,q_=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=G_()}resize(t,r){let n=t*r*4;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(r))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Y_=`#version 300 es
45
+ layout (location = 0) in vec2 a_position;
46
+ layout (location = 1) in vec2 a_size;
47
+ layout (location = 2) in vec4 a_color;
48
+ layout (location = 3) in vec2 a_unitquad;
49
+
50
+ uniform mat4 u_projection;
51
+
52
+ out vec4 v_color;
53
+
54
+ void main() {
55
+ vec2 zeroToOne = a_position + (a_unitquad * a_size);
56
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
57
+ v_color = a_color;
58
+ }`,Z_=`#version 300 es
59
+ precision lowp float;
60
+
61
+ in vec4 v_color;
62
+
63
+ out vec4 outColor;
64
+
65
+ void main() {
66
+ outColor = v_color;
67
+ }`,vl=8,Yp=vl*Float32Array.BYTES_PER_ELEMENT,K_=20*vl,r2=class{constructor(){this.attributes=new Float32Array(K_),this.count=0}},Bl=0,n2=0,s2=0,i2=0,a2=0,o2=0,l2=0,X_=class extends lu{constructor(t,r,n,a,c){super(),this._terminal=t,this._gl=r,this._dimensions=n,this._themeService=a,this._logService=c,this._vertices=new r2,this._verticesCursor=new r2;let l=this._gl;this._program=qs(K3(l,Y_,Z_,this._logService)),this._register(li(()=>l.deleteProgram(this._program))),this._projectionLocation=qs(l.getUniformLocation(this._program,"u_projection"));let d=this._vertexArrayObject=l.createVertexArray();this._register(li(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let f=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(li(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,f,l.STATIC_DRAW),l.enableVertexAttribArray(3),l.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=l.createBuffer();this._register(li(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=qs(l.createBuffer()),this._register(li(()=>l.deleteBuffer(this._attributesBuffer))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,l.FLOAT,!1,Yp,0),l.vertexAttribDivisor(0,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,Yp,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,4,l.FLOAT,!1,Yp,4*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(2,1),this._updateCachedColors(a.colors),this._register(this._themeService.onChangeColors(w=>{this._updateCachedColors(w),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let r=this._gl;r.useProgram(this._program),r.bindVertexArray(this._vertexArrayObject),r.uniformMatrix4fv(this._projectionLocation,!1,Z3),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,t.attributes,r.DYNAMIC_DRAW),r.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let r=this._terminal,n=this._vertices,a=1,c,l,d,f,m,x,y,w,v,T,C;for(c=0;c<r.rows;c++){for(d=-1,f=0,m=0,x=!1,l=0;l<r.cols;l++)y=(c*r.cols+l)*4,w=t.cells[y+1],v=t.cells[y+2],T=!!(v&67108864),(w!==f||v!==m&&(x||T))&&((f!==0||x&&m!==0)&&(C=a++*vl,this._updateRectangle(n,C,m,f,d,l,c)),d=l,f=w,m=v,x=T);(f!==0||x&&m!==0)&&(C=a++*vl,this._updateRectangle(n,C,m,f,d,r.cols,c))}n.count=a}updateCursor(t){let r=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){r.count=0;return}let a,c=0;(n.style==="bar"||n.style==="outline")&&(a=c++*vl,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(a=c++*vl,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(a=c++*vl,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),a=c++*vl,this._addRectangleFloat(r.attributes,a,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),r.count=c}_updateRectangle(t,r,n,a,c,l,d){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:Bl=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:Bl=(n&16777215)<<8;break;default:Bl=this._themeService.colors.foreground.rgba}else switch(a&50331648){case 16777216:case 33554432:Bl=this._themeService.colors.ansi[a&255].rgba;break;case 50331648:Bl=(a&16777215)<<8;break;default:Bl=this._themeService.colors.background.rgba}t.attributes.length<r+vl&&(t.attributes=F_(t.attributes,(this._terminal.rows*this._terminal.cols+1)*vl)),n2=c*this._dimensions.device.cell.width,s2=d*this._dimensions.device.cell.height,i2=(Bl>>24&255)/255,a2=(Bl>>16&255)/255,o2=(Bl>>8&255)/255,l2=1,this._addRectangle(t.attributes,r,n2,s2,(l-c)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,i2,a2,o2,l2)}_addRectangle(t,r,n,a,c,l,d,f,m,x){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=c/this._dimensions.device.canvas.width,t[r+3]=l/this._dimensions.device.canvas.height,t[r+4]=d,t[r+5]=f,t[r+6]=m,t[r+7]=x}_addRectangleFloat(t,r,n,a,c,l,d){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=c/this._dimensions.device.canvas.width,t[r+3]=l/this._dimensions.device.canvas.height,t[r+4]=d[0],t[r+5]=d[1],t[r+6]=d[2],t[r+7]=d[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},J_=class extends lu{constructor(e,t,r,n,a,c,l,d){super(),this._container=t,this._alpha=a,this._coreBrowserService=c,this._optionsService=l,this._themeService=d,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${r}-layer`),this._canvas.style.zIndex=n.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(f=>{this._refreshCharAtlas(e,f),this.reset(e)})),this._register(li(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=qs(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,r){}handleSelectionChanged(e,t,r,n=!1){}_setTransparency(e,t){if(t===this._alpha)return;let r=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,r),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=q3(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,r=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,r*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,r,n){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,n*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,n*this._deviceCellHeight))}_fillCharTrueColor(e,t,r,n){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=O3,this._clipCell(r,n,t.getWidth()),this._ctx.fillText(t.getChars(),r*this._deviceCellWidth+this._deviceCharLeft,n*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,r){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,r){let n=t?e.options.fontWeightBold:e.options.fontWeight;return`${r?"italic":""} ${n} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},ek=class extends J_{constructor(t,r,n,a,c,l,d){super(n,t,"link",r,!0,c,l,d),this._register(a.onShowLinkUnderline(f=>this._handleShowLinkUnderline(f))),this._register(a.onHideLinkUnderline(f=>this._handleHideLinkUnderline(f)))}resize(t,r){super.resize(t,r),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&D_(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let r=t.y1+1;r<t.y2;r++)this._fillBottomLineAtCells(0,r,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},tk=class{constructor(t,r,n,a){this._node=t,this._type=r,this._handler=n,this._options=a,t.addEventListener(r,n,a)}dispose(){!this._node||!this._handler||(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Zp(e,t,r,n){return new tk(e,t,r,n)}var rk=class extends lu{constructor(e,t,r,n,a,c,l,d,f,m=!0,x){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=r,this._coreBrowserService=n,this._coreService=a,this._decorationService=c,this._logService=l,this._optionsService=d,this._themeService=f,this._customGlyphs=m,this._cursorBlinkStateManager=this._register(new Nd),this._charAtlasDisposable=this._register(new Nd),this._observerDisposable=this._register(new Nd),this._model=new q_,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new P_,this._rectangleRenderer=this._register(new Nd),this._glyphRenderer=this._register(new Nd),this._onChangeTextureAtlas=this._register(new Xo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Xo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Xo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Xo),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Xo),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let y={antialias:!1,depth:!1,preserveDrawingBuffer:x};if(this._gl=this._canvas.getContext("webgl2",y),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new x_(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new ek(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,d,this._themeService)],this.dimensions=f_(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(d.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new O_(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Zp(this._canvas,"webglcontextlost",w=>{this._logService.debug("webglcontextlost event received"),w.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,this._logService.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(w)},3e3)})),this._register(Zp(this._canvas,"webglcontextrestored",w=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Jx(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=e2(this._canvas,this._coreBrowserService.window,(w,v)=>this._setCanvasDevicePixelDimensions(w,v)),this._register(this._coreBrowserService.onWindowChange(w=>{this._observerDisposable.value=e2(this._canvas,w,(v,T)=>this._setCanvasDevicePixelDimensions(v,T))})),this._register(Zp(this._coreBrowserService.mainDocument,"mousedown",()=>this._cursorBlinkStateManager.value?.restartBlinkAnimation())),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(li(()=>{clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0;for(let w of this._renderLayers)w.dispose();this._canvas.parentElement?.removeChild(this._canvas),Jx(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._resetBlinkingRowState();for(let r of this._renderLayers)r.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1),this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0})}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleViewportVisibilityChange(e){this._textBlinkStateManager.setViewportVisible(e)}handleSelectionChanged(e,t,r){for(let n of this._renderLayers)n.handleSelectionChanged(this._terminal,e,t,r);this._model.selection.update(this._core,e,t,r),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new X_(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new H_(this._terminal,this._gl,this.dimensions,this._optionsService,this._logService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=q3(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize,this._customGlyphs);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=r_(qc.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),qc.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._resetBlinkingRowState(),this._textBlinkStateManager.setNeedsBlinkInViewport(!1),this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let a of this._renderLayers)a.handleGridChanged(this._terminal,e,t);if(!this._glyphRenderer.value||!this._rectangleRenderer.value)return;this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t);let r=!1,n=0;for(;this._charAtlas&&this._glyphRenderer.value.beginFrame()&&n++<32;)r=!0,this._clearModel(!0),this._updateModel(0,this._terminal.rows-1);r&&this._glyphRenderer.value.invalidateAtlasTextures(),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor()}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new B_(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let r=this._core,n=this._workCell,a,c,l,d,f,m,x,y,w,v,T,C,L,N,D,O,P;e=c2(e,r.rows-1,0),t=c2(t,r.rows-1,0);let F=this._coreService.decPrivateModes.cursorStyle??r.options.cursorStyle??"block",ee=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,Z=ee-r.buffer.ydisp,G=Math.min(this._terminal.buffer.active.cursorX,r.cols-1),de=-1,pe=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let J=!1;for(c=e;c<=t;c++){l=c+r.buffer.ydisp;let Re=r.buffer.lines.get(l);if(!Re){for(this._model.lineLengths[c]=0,O=0;O<r.cols;O++)P=(c*r.cols+O)*4,J=!0,this._nullModelCell(O,c,P,0,0,0);this._setRowBlinkState(c,!1);continue}d=Re;let Ze=!1;for(this._model.lineLengths[c]=0,T=ee===l,x=0,f=this._characterJoinerService.getJoinedCharacters(l),O=0;O<r.cols;O++){if(a=this._cellColorResolver.result.bg,d.loadCell(O,n),O===0&&(a=this._cellColorResolver.result.bg),m=!1,y=O>=x,w=O,f.length>0&&O===f[0][0]&&y){v=f.shift();let V=this._model.selection.isCellSelected(this._terminal,v[0],l);for(D=v[0]+1;D<v[1];D++)y&&=V===this._model.selection.isCellSelected(this._terminal,D,l);y&&=!T||G<v[0]||G>=v[1],y?(m=!0,n=new nk(n,d.translateToString(!0,v[0],v[1]),v[1]-v[0]),w=v[1]-1):x=v[1]}if(C=n.getChars(),L=n.getCode(),D=(c*r.cols+O)*4,!Ze&&n.isBlink()&&(Ze=!0),this._cellColorResolver.resolve(n,O,l,this.dimensions.device.cell.width,this.dimensions.device.cell.height),pe&&l===ee&&(O===G&&(this._model.cursor={x:G,y:Z,width:n.getWidth(),style:this._coreBrowserService.isFocused?F:r.options.cursorInactiveStyle,cursorWidth:r.options.cursorWidth,dpr:this._devicePixelRatio},de=G+n.getWidth()-1),O>=G&&O<=de&&(this._coreBrowserService.isFocused&&F==="block"||this._coreBrowserService.isFocused===!1&&r.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),this._textBlinkStateManager.isEnabled&&!this._textBlinkStateManager.isBlinkOn&&n.isBlink()&&(this._cellColorResolver.result.fg|=1073741824),L!==0&&(this._model.lineLengths[c]=O+1),!(this._model.cells[D]===L&&this._model.cells[D+1]===this._cellColorResolver.result.bg&&this._model.cells[D+2]===this._cellColorResolver.result.fg&&this._model.cells[D+3]===this._cellColorResolver.result.ext)&&(J=!0,C.length>1&&(L|=V_),this._model.cells[D]=L,this._model.cells[D+1]=this._cellColorResolver.result.bg,this._model.cells[D+2]=this._cellColorResolver.result.fg,this._model.cells[D+3]=this._cellColorResolver.result.ext,N=n.getWidth(),this._glyphRenderer.value.updateCell(O,c,L,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,C,N,a),m)){for(n=this._workCell,O++;O<=w;O++)P=(c*r.cols+O)*4,this._nullModelCell(O,c,P,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);O--}}this._setRowBlinkState(c,Ze)}J&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model),this._updateTextBlinkState()}_nullModelCell(e,t,r,n,a,c){this._glyphRenderer.value.updateCell(e,t,0,n,a,c,"",0,0),this._model.cells[r]=0,this._model.cells[r+1]=n,this._model.cells[r+2]=a,this._model.cells[r+3]=c}_resetBlinkingRowState(){this._rowHasBlinkingCells=new Array(this._terminal.rows).fill(!1),this._rowHasBlinkingCellsCount=0}_setRowBlinkState(e,t){this._rowHasBlinkingCells[e]!==t&&(this._rowHasBlinkingCells[e]=t,this._rowHasBlinkingCellsCount+=t?1:-1)}_updateTextBlinkState(){this._textBlinkStateManager.setNeedsBlinkInViewport(this._rowHasBlinkingCellsCount>0)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0}))}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},nk=class extends Gu{constructor(t,r,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=r,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function c2(e,t,r=0){return Math.max(Math.min(e,t),r)}var sk=class extends lu{constructor(e){if(Q3&&a_()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw new Error("WebGL2 is only supported on Safari 16 and above")}super(),this._onChangeTextureAtlas=this._register(new Xo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Xo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Xo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Xo),this.onContextLoss=this._onContextLoss.event,this._customGlyphs=e?.customGlyphs??!0,this._preserveDrawingBuffer=e?.preserveDrawingBuffer}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let r=t.coreService,n=t.optionsService,a=t,c=a._renderService,l=a._characterJoinerService,d=a._charSizeService,f=a._coreBrowserService,m=a._decorationService,x=a._logService,y=a._themeService;this._renderer=this._register(new rk(e,l,d,f,r,m,x,n,y,this._customGlyphs,this._preserveDrawingBuffer)),this._register(qc.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(qc.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(qc.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(qc.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),c.setRenderer(this._renderer),this._register(li(()=>{if(this._terminal._core._store._isDisposed)return;let w=this._terminal._core._renderService;w.setRenderer(this._terminal._core._createRenderer()),w.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};var ik=class{constructor(t,r,n,a={}){this._terminal=t,this._regex=r,this._handler=n,this._options=a}provideLinks(t,r){let n=ok.computeLink(t,this._regex,this._terminal,this._handler);r(this._addCallbacks(n))}_addCallbacks(t){return t.map(r=>(r.leave=this._options.leave,r.hover=(n,a)=>{if(this._options.hover){let{range:c}=r;this._options.hover(n,a,c)}},r))}};function ak(e){try{let t=new URL(e),r=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(r.toLocaleLowerCase())}catch{return!1}}var ok=class af{static computeLink(t,r,n,a){let c=r.flags.includes("g")?r.flags:`${r.flags}g`,l=new RegExp(r.source,c),[d,f]=af._getWindowedLineStrings(t-1,n),m=d.join(""),x,y=[];for(;x=l.exec(m);){let w=x[0];if(!ak(w))continue;let[v,T]=af._mapStrIdx(n,f,0,x.index),[C,L]=af._mapStrIdx(n,v,T,w.length);if(v===-1||T===-1||C===-1||L===-1)continue;let N={start:{x:T+1,y:v+1},end:{x:L,y:C+1}};y.push({range:N,text:w,activate:a})}return y}static _getWindowedLineStrings(t,r){let n,a=t,c=t,l,d,f=[];if(n=r.buffer.active.getLine(t)){let m=n.translateToString(!0);if(n.isWrapped&&m[0]!==" "){for(l=0;(n=r.buffer.active.getLine(--a))&&l<2048&&(d=n.translateToString(!0),l+=d.length,f.push(d),!(!n.isWrapped||d.indexOf(" ")!==-1)););f.reverse()}for(f.push(m),l=0;(n=r.buffer.active.getLine(++c))&&n.isWrapped&&l<2048&&(d=n.translateToString(!0),l+=d.length,f.push(d),d.indexOf(" ")===-1););}return[f,a]}static _mapStrIdx(t,r,n,a){let c=t.buffer.active,l=c.getNullCell(),d=n;for(;a;){let f=c.getLine(r);if(!f)return[-1,-1];for(let m=d;m<f.length;++m){f.getCell(m,l);let x=l.getChars();if(l.getWidth()&&(a-=x.length||1,m===f.length-1&&x==="")){let y=c.getLine(r+1);y&&y.isWrapped&&(y.getCell(0,l),l.getWidth()===2&&(a+=1))}if(a<0)return[r,m]}r++,d=0}return[r,d]}},lk=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function ck(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var uk=class{constructor(t=ck,r={}){this._handler=t,this._options=r}activate(t){this._terminal=t;let r=this._options,n=r.urlRegex??lk;this._linkProvider=this._terminal.registerLinkProvider(new ik(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function dk(e,t){if(e?.capabilities?.webWorkspace===!0)return(r,n)=>{try{const a=new URL(n);if(a.protocol!=="http:"&&a.protocol!=="https:")return;e.openExternal?e.openExternal(a.href).catch(()=>{}):t(a.href)}catch{}}}function u2(e){return{dispose:e}}var hk=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},fk=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return u2(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=u2(()=>{let l=this._listeners.indexOf(a);l!==-1&&this._listeners.splice(l,1)});return n&&(Array.isArray(n)?n.push(c):n.add(c)),c},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:r,thisArgs:n}=this._listeners[0];r.call(n,t);return}default:{let r=this._listeners.slice();for(let{fn:n,thisArgs:a}of r)n.call(a,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},pk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new hk;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(pk||={});var d2=class of{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fk,this.onChange=this._onChange.event}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?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,this._active||(this.activeVersion=t.version)}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,a=t.length;for(let c=0;c<a;++c){let l=t.charCodeAt(c);if(55296<=l&&l<=56319){if(++c>=a)return r+this.wcwidth(l);let m=t.charCodeAt(c);56320<=m&&m<=57343?l=(l-55296)*1024+m-56320+65536:r+=this.wcwidth(m)}let d=this.charProperties(l,n),f=of.extractWidth(d);of.extractShouldJoin(d)&&(f-=of.extractWidth(n)),r+=f,n=d}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},Kp=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],mk=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],Xp=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],gk=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],Ql;function h2(e,t){let r=0,n=t.length-1,a;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(a=r+n>>1,e>t[a][1])r=a+1;else if(e<t[a][0])n=a-1;else return!0;return!1}var xk=class{constructor(){if(this.version="11",!Ql){Ql=new Uint8Array(65536),Ql.fill(1),Ql[0]=0,Ql.fill(0,1,32),Ql.fill(0,127,160);for(let e=0;e<Kp.length;++e)Ql.fill(0,Kp[e][0],Kp[e][1]+1);for(let e=0;e<Xp.length;++e)Ql.fill(2,Xp[e][0],Xp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ql[e]:h2(e,mk)?0:h2(e,gk)?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let a=d2.extractWidth(t);a===0?n=!1:a>r&&(r=a)}return d2.createPropertyValue(0,r,n)}},bk=class{activate(e){e.unicode.register(new xk)}dispose(){}};function iu(e){return{dispose:e}}function lf(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function yk(...e){return iu(()=>lf(e))}var X3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(t){return this._isDisposed?t.dispose():this._disposables.add(t),t}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let t of this._disposables)t.dispose();this._disposables.clear()}}clear(){for(let t of this._disposables)t.dispose();this._disposables.clear()}},Z0=class{constructor(){this._store=new X3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Z0.None=Object.freeze({dispose(){}});var Rf=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},m1=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return iu(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=iu(()=>{let c=this._listeners.indexOf(n);c!==-1&&this._listeners.splice(c,1)});return r&&(Array.isArray(r)?r.push(a):r.add(a)),a},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:r}=this._listeners[0];t.call(r,e);return}default:{let t=this._listeners.slice();for(let{fn:r,thisArgs:n}of t)r.call(n,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},vk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new X3;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(vk||={});function J3(e,t=0,r){let n=setTimeout(()=>{e()},t);return iu(()=>{clearTimeout(n)})}var wk=class extends Z0{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Rf),this._linesCacheDisposables=this._register(new Rf),this._lastAccessTimestamp=0,this._register(iu(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=yk(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._lastAccessTimestamp=Date.now(),this._linesCacheTimeout.value||this._scheduleLinesCacheTimeout(15e3)}_destroyLinesCache(){this._linesCache=void 0,this._lastAccessTimestamp=0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}_scheduleLinesCacheTimeout(e){this._linesCacheTimeout.value=J3(()=>{if(!this._linesCache)return;let t=Date.now()-this._lastAccessTimestamp;if(t>=15e3){this._destroyLinesCache();return}this._scheduleLinesCacheTimeout(15e3-t)},e)}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let r=[],n=[0],a=this._terminal.buffer.active.getLine(e);for(;a;){let c=this._terminal.buffer.active.getLine(e+1),l=c?c.isWrapped:!1,d=a.translateToString(!l&&t);if(l&&c){let f=a.getCell(a.length-1);f&&f.getCode()===0&&f.getWidth()===1&&c.getCell(0)?.getWidth()===2&&(d=d.slice(0,-1))}if(r.push(d),l)n.push(n[n.length-1]+d.length);else break;e++,a=c}return[r.join(""),n]}},Ak=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return this._lastSearchOptions?t?this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord:!1:!0}shouldUpdateHighlighting(t,r){return r?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(r):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Tk=class{constructor(t,r){this._terminal=t,this._lineCache=r}find(t,r,n,a){if(!t||t.length===0){this._terminal.clearSelection();return}if(n>=this._terminal.cols)throw new Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let c={startRow:r,startCol:n},l=this._findInLine(t,c,a);if(!l)for(let d=r+1;d<this._terminal.buffer.active.baseY+this._terminal.rows&&(c.startRow=d,c.startCol=0,l=this._findInLine(t,c,a),!l);d++);return l}findNextWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let c=0,l=0;a&&(n===t?(c=a.end.x,l=a.end.y):(c=a.start.x,l=a.start.y)),this._lineCache.initLinesCache();let d={startRow:l,startCol:c},f=this._findInLine(t,d,r);if(!f)for(let m=l+1;m<this._terminal.buffer.active.baseY+this._terminal.rows&&(d.startRow=m,d.startCol=0,f=this._findInLine(t,d,r),!f);m++);if(!f&&l!==0)for(let m=0;m<l&&(d.startRow=m,d.startCol=0,f=this._findInLine(t,d,r),!f);m++);return!f&&a&&(d.startRow=a.start.y,d.startCol=0,f=this._findInLine(t,d,r)),f}findPreviousWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let c=this._terminal.buffer.active.baseY+this._terminal.rows-1,l=this._terminal.cols,d=!0;this._lineCache.initLinesCache();let f={startRow:c,startCol:l},m;if(a&&(f.startRow=c=a.start.y,f.startCol=a.start.x,n!==t&&(m=this._findInLine(t,f,r,!1),m||(f.startRow=c=a.end.y,f.startCol=a.end.x))),m??=this._findInLine(t,f,r,d),!m){f.startCol=Math.max(f.startCol,this._terminal.cols);for(let x=c-1;x>=0&&(f.startRow=x,m=this._findInLine(t,f,r,d),!m);x--);}if(!m&&c!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let x=this._terminal.buffer.active.baseY+this._terminal.rows-1;x>=c&&(f.startRow=x,m=this._findInLine(t,f,r,d),!m);x--);return m}_isWholeWord(t,r,n){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t-1]))&&(t+n.length===r.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t+n.length]))}_findInLine(t,r,n={},a=!1){let c=r.startRow,l=r.startCol;if(this._terminal.buffer.active.getLine(c)?.isWrapped){if(a){r.startCol+=this._terminal.cols;return}return r.startRow--,r.startCol+=this._terminal.cols,this._findInLine(t,r,n)}let d=this._lineCache.getLineFromCache(c);d||(d=this._lineCache.translateBufferLineToStringWithWrap(c,!0),this._lineCache.setLineInCache(c,d));let[f,m]=d,x=this._bufferColsToStringOffset(c,l),y=t,w=f;n.regex||(y=n.caseSensitive?t:t.toLowerCase(),w=n.caseSensitive?f:f.toLowerCase());let v=-1;if(n.regex){let T=RegExp(y,n.caseSensitive?"g":"gi"),C;if(a)for(;C=T.exec(w.slice(0,x));)v=T.lastIndex-C[0].length,t=C[0],T.lastIndex-=t.length-1;else C=T.exec(w.slice(x)),C&&C[0].length>0&&(v=x+(T.lastIndex-C[0].length),t=C[0])}else a?x-y.length>=0&&(v=w.lastIndexOf(y,x-y.length)):v=w.indexOf(y,x);if(v>=0){if(n.wholeWord&&!this._isWholeWord(v,w,t))return;let T=0;for(;T<m.length-1&&v>=m[T+1];)T++;let C=T;for(;C<m.length-1&&v+t.length>=m[C+1];)C++;let L=v-m[T],N=v+t.length-m[C],D=this._stringLengthToBufferSize(c+T,L),O=this._stringLengthToBufferSize(c+C,N)-D+this._terminal.cols*(C-T);return{term:t,col:D,row:c+T,size:O}}}_stringLengthToBufferSize(t,r){let n=this._terminal.buffer.active.getLine(t);if(!n)return 0;for(let a=0;a<r;a++){let c=n.getCell(a);if(!c)break;let l=c.getChars();l.length>1&&(r-=l.length-1);let d=n.getCell(a+1);d&&d.getWidth()===0&&r++}return r}_bufferColsToStringOffset(t,r){let n=t,a=0,c=this._terminal.buffer.active.getLine(n);for(;r>0&&c;){for(let l=0;l<r&&l<this._terminal.cols;l++){let d=c.getCell(l);if(!d)break;d.getWidth()&&(a+=d.getCode()===0?1:d.getChars().length)}if(n++,c=this._terminal.buffer.active.getLine(n),c&&!c.isWrapped)break;r-=this._terminal.cols}return a}},Sk=class extends Z0{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(iu(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,r){this.clearHighlightDecorations();for(let n of t){let a=this._createResultDecorations(n,r,!1);if(a)for(let c of a)this._storeDecoration(c,n)}}createActiveDecoration(t,r){let n=this._createResultDecorations(t,r,!0);if(n)return{decorations:n,match:t,dispose(){lf(n)}}}clearHighlightDecorations(){lf(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,r){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:r,dispose(){t.dispose()}})}_applyStyles(t,r,n){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),r&&(t.style.outline=`1px solid ${r}`)),n&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,r,n){let a=[],c=t.col,l=t.size,d=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;l>0;){let m=Math.min(this._terminal.cols-c,l);a.push([d,c,m]),c=0,l-=m,d++}let f=[];for(let m of a){let x=this._terminal.registerMarker(m[0]),y=this._terminal.registerDecoration({marker:x,x:m[1],width:m[2],layer:n?"top":"bottom",backgroundColor:n?r.activeMatchBackground:r.matchBackground,overviewRulerOptions:this._highlightedLines.has(x.line)?void 0:{color:n?r.activeMatchColorOverviewRuler:r.matchOverviewRuler,position:"center"}});if(y){let w=[];w.push(x),w.push(y.onRender(v=>this._applyStyles(v,n?r.activeMatchBorder:r.matchBorder,!1))),w.push(y.onDispose(()=>lf(w))),f.push(y)}}return f.length===0?void 0:f}},Ck=class extends Z0{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new m1)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,r){this._searchResults=t.slice(0,r)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let r=0;r<this._searchResults.length;r++){let n=this._searchResults[r];if(n.row===t.row&&n.col===t.col&&n.size===t.size)return r}return-1}fireResultsChanged(t){if(!t)return;let r=-1;this._selectedDecoration&&(r=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:r,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},_k=class extends Z0{constructor(t){super(),this._highlightTimeout=this._register(new Rf),this._lineCache=this._register(new Rf),this._state=new Ak,this._resultTracker=this._register(new Ck),this._onAfterSearch=this._register(new m1),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new m1),this.onBeforeSearch=this._onBeforeSearch.event,this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new wk(t),this._engine=new Tk(t,this._lineCache.value),this._decorationManager=new Sk(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(iu(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=J3(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findNextAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_highlightAllMatches(t,r){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],a,c=this._engine.find(t,0,0,r);for(;c&&(a?.row!==c.row||a?.col!==c.col)&&!(n.length>=this._highlightLimit);){a=c,n.push(a);let l=this._terminal.cols,d=a.col+a.size,f=a.row;d>=l&&(f+=Math.floor(d/l),d=d%l),c=this._engine.find(t,f,d,r)}this._resultTracker.updateResults(n,this._highlightLimit),r.decorations&&this._decorationManager.createHighlightDecorations(n,r.decorations)}_findNextAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findNextWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}findPrevious(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findPreviousAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findPreviousWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}_selectResult(t,r,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),r){let a=this._decorationManager.createActiveDecoration(t,r);a&&(this._resultTracker.selectedDecoration=a)}if(!n&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let a=t.row-this._terminal.buffer.active.viewportY;a-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(a)}return!0}};var Ai=0,Ti=0,Si=0,Bs=0,ra;(e=>{function t(a,c,l,d){return d!==void 0?`#${Pc(a)}${Pc(c)}${Pc(l)}${Pc(d)}`:`#${Pc(a)}${Pc(c)}${Pc(l)}`}e.toCss=t;function r(a,c,l,d=255){return(a<<24|c<<16|l<<8|d)>>>0}e.toRgba=r;function n(a,c,l,d){return{css:e.toCss(a,c,l,d),rgba:e.toRgba(a,c,l,d)}}e.toColor=n})(ra||={});var kk;(e=>{function t(f,m){if(Bs=(m.rgba&255)/255,Bs===1)return{css:m.css,rgba:m.rgba};let x=m.rgba>>24&255,y=m.rgba>>16&255,w=m.rgba>>8&255,v=f.rgba>>24&255,T=f.rgba>>16&255,C=f.rgba>>8&255;Ai=v+Math.round((x-v)*Bs),Ti=T+Math.round((y-T)*Bs),Si=C+Math.round((w-C)*Bs);let L=ra.toCss(Ai,Ti,Si),N=ra.toRgba(Ai,Ti,Si);return{css:L,rgba:N}}e.blend=t;function r(f){return(f.rgba&255)===255}e.isOpaque=r;function n(f,m,x){let y=cf.ensureContrastRatio(f.rgba,m.rgba,x);if(y)return ra.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(f){let m=(f.rgba|255)>>>0;return[Ai,Ti,Si]=cf.toChannels(m),{css:ra.toCss(Ai,Ti,Si),rgba:m}}e.opaque=a;function c(f,m){return Bs=Math.round(m*255),[Ai,Ti,Si]=cf.toChannels(f.rgba),{css:ra.toCss(Ai,Ti,Si,Bs),rgba:ra.toRgba(Ai,Ti,Si,Bs)}}e.opacity=c;function l(f,m){return Bs=f.rgba&255,c(f,Bs*m/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(kk||={});var Pi;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ai=parseInt(a.slice(1,2).repeat(2),16),Ti=parseInt(a.slice(2,3).repeat(2),16),Si=parseInt(a.slice(3,4).repeat(2),16),ra.toColor(Ai,Ti,Si);case 5:return Ai=parseInt(a.slice(1,2).repeat(2),16),Ti=parseInt(a.slice(2,3).repeat(2),16),Si=parseInt(a.slice(3,4).repeat(2),16),Bs=parseInt(a.slice(4,5).repeat(2),16),ra.toColor(Ai,Ti,Si,Bs);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Ai=parseInt(c[1],10),Ti=parseInt(c[2],10),Si=parseInt(c[3],10),Bs=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ra.toColor(Ai,Ti,Si,Bs);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ai,Ti,Si,Bs]=t.getImageData(0,0,1,1).data,Bs!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ra.toRgba(Ai,Ti,Si,Bs),css:a}}e.toColor=n})(Pi||={});var wa;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,c){let l=n/255,d=a/255,f=c/255,m=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),x=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(wa||={});var cf;(e=>{function t(l,d){if(Bs=(d&255)/255,Bs===1)return d;let f=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return Ai=y+Math.round((f-y)*Bs),Ti=w+Math.round((m-w)*Bs),Si=v+Math.round((x-v)*Bs),ra.toRgba(Ai,Ti,Si)}e.blend=t;function r(l,d,f){let m=wa.relativeLuminance(l>>8),x=wa.relativeLuminance(d>>8);if(Pl(m,x)<f){if(x<m){let v=n(l,d,f),T=Pl(m,wa.relativeLuminance(v>>8));if(T<f){let C=a(l,d,f),L=Pl(m,wa.relativeLuminance(C>>8));return T>L?v:C}return v}let y=a(l,d,f),w=Pl(m,wa.relativeLuminance(y>>8));if(w<f){let v=n(l,d,f),T=Pl(m,wa.relativeLuminance(v>>8));return w>T?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,T=d>>8&255,C=Pl(wa.relativeLuminance2(w,v,T),wa.relativeLuminance2(m,x,y));for(;C<f&&(w>0||v>0||T>0);)w-=Math.max(0,Math.ceil(w*.1)),v-=Math.max(0,Math.ceil(v*.1)),T-=Math.max(0,Math.ceil(T*.1)),C=Pl(wa.relativeLuminance2(w,v,T),wa.relativeLuminance2(m,x,y));return(w<<24|v<<16|T<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,T=d>>8&255,C=Pl(wa.relativeLuminance2(w,v,T),wa.relativeLuminance2(m,x,y));for(;C<f&&(w<255||v<255||T<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),T=Math.min(255,T+Math.ceil((255-T)*.1)),C=Pl(wa.relativeLuminance2(w,v,T),wa.relativeLuminance2(m,x,y));return(w<<24|v<<16|T<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(cf||={});function Pc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Lk=Object.freeze((()=>{let e=[Pi.toColor("#2e3436"),Pi.toColor("#cc0000"),Pi.toColor("#4e9a06"),Pi.toColor("#c4a000"),Pi.toColor("#3465a4"),Pi.toColor("#75507b"),Pi.toColor("#06989a"),Pi.toColor("#d3d7cf"),Pi.toColor("#555753"),Pi.toColor("#ef2929"),Pi.toColor("#8ae234"),Pi.toColor("#fce94f"),Pi.toColor("#729fcf"),Pi.toColor("#ad7fa8"),Pi.toColor("#34e2e2"),Pi.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],a=t[r/6%6|0],c=t[r%6];e.push({css:ra.toCss(n,a,c),rgba:ra.toRgba(n,a,c)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:ra.toCss(n,n,n),rgba:ra.toRgba(n,n,n)})}return e})());function f2(e,t,r){return Math.max(t,Math.min(e,r))}function Ik(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var ev=class{constructor(e){this._buffer=e}serialize(e,t){let r=this._buffer.getNullCell(),n=this._buffer.getNullCell(),a=r,c=e.start.y,l=e.end.y,d=e.start.x,f=e.end.x;this._beforeSerialize(l-c,c,l);for(let m=c;m<=l;m++){let x=this._buffer.getLine(m);if(x){let y=m===e.start.y?d:0,w=m===e.end.y?f:x.length;for(let v=y;v<w;v++){let T=x.getCell(v,a===r?n:r);if(!T){console.warn(`Can't get cell at row=${m}, col=${v}`);continue}this._nextCell(T,a,m,v),a=T}}this._rowEnd(m,m===l)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,r,n){}_rowEnd(e,t){}_beforeSerialize(e,t,r){}_afterSerialize(){}_serializeString(e){return""}};function pg(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function wl(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function tv(e,t){if(!e.isUnderline()&&!t.isUnderline())return!0;if(e.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let r=e.isUnderlineColorDefault(),n=t.isUnderlineColorDefault();return r&&n?!0:r!==n?!1:e.getUnderlineColor()===t.getUnderlineColor()&&e.getUnderlineColorMode()===t.getUnderlineColorMode()}function mg(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&tv(e,t)&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}function rv(e,t){let r=e;return typeof r.attributesEquals=="function"?r.attributesEquals(t):pg(e,t)&&wl(e,t)&&mg(e,t)}var Ek=class extends ev{constructor(t,r){super(t),this._terminal=r,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,r,n){this._allRows=new Array(t),this._lastContentCursorRow=r,this._lastCursorRow=r,this._firstRow=r}_rowEnd(t,r){this._nullCellCount>0&&!wl(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!r){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let a=this._buffer.getLine(t),c=this._buffer.getLine(t+1);if(!c.isWrapped)n=`\r
68
+ `,this._lastCursorRow=t+1,this._lastCursorCol=0;else{n="";let l=a.getCell(a.length-1,this._thisRowLastChar),d=a.getCell(a.length-2,this._thisRowLastSecondChar),f=c.getCell(0,this._nextRowFirstChar),m=f.getWidth()>1,x=!1;(f.getChars()&&m?this._nullCellCount<=1:this._nullCellCount<=0)&&((l.getChars()||l.getWidth()===0)&&wl(l,f)&&(x=!0),m&&(d.getChars()||d.getWidth()===0)&&wl(l,f)&&wl(d,f)&&(x=!0)),x||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(t,r){let n=[];if(rv(t,r))return n;let a=!pg(t,r),c=!wl(t,r),l=!mg(t,r);if(a||c||l)if(t.isAttributeDefault())r.isAttributeDefault()||n.push(0);else{if(a){let d=t.getFgColor();t.isFgRGB()?n.push(38,2,d>>>16&255,d>>>8&255,d&255):t.isFgPalette()?d>=16?n.push(38,5,d):n.push(d&8?90+(d&7):30+(d&7)):n.push(39)}if(c){let d=t.getBgColor();t.isBgRGB()?n.push(48,2,d>>>16&255,d>>>8&255,d&255):t.isBgPalette()?d>=16?n.push(48,5,d):n.push(d&8?100+(d&7):40+(d&7)):n.push(49)}if(l){if(t.isInverse()!==r.isInverse()&&n.push(t.isInverse()?7:27),t.isBold()!==r.isBold()&&n.push(t.isBold()?1:22),tv(t,r))t.isUnderline()!==r.isUnderline()&&n.push(t.isUnderline()?4:24);else{let d=t.getUnderlineStyle();if(d===0)n.push(24);else if(d===1&&t.isUnderlineColorDefault())n.push(4);else if(n.push("4:"+d),!t.isUnderlineColorDefault()){let f=t.getUnderlineColor();t.isUnderlineColorRGB()?n.push("58:2::"+(f>>>16&255)+":"+(f>>>8&255)+":"+(f&255)):n.push("58:5:"+f)}}t.isOverline()!==r.isOverline()&&n.push(t.isOverline()?53:55),t.isBlink()!==r.isBlink()&&n.push(t.isBlink()?5:25),t.isInvisible()!==r.isInvisible()&&n.push(t.isInvisible()?8:28),t.isItalic()!==r.isItalic()&&n.push(t.isItalic()?3:23),t.isDim()!==r.isDim()&&n.push(t.isDim()?2:22),t.isStrikethrough()!==r.isStrikethrough()&&n.push(t.isStrikethrough()?9:29)}}return n}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let c=t.getChars()==="",l=this._diffStyle(t,this._cursorStyle);if(c?!wl(this._cursorStyle,t):l.length>0){this._nullCellCount>0&&(wl(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=a,this._currentRow+=`\x1B[${l.join(";")}m`;let d=this._buffer.getLine(n);d!==void 0&&(d.getCell(a,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=a)}c?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(wl(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=a+t.getWidth())}_serializeString(t){let r=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(r=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let l=0;l<r;l++)n+=this._allRows[l],l+1<r&&(n+=this._allRowSeparators[l]);if(!t){let l=this._buffer.baseY+this._buffer.cursorY,d=this._buffer.cursorX,f=l!==this._lastCursorRow||d!==this._lastCursorCol,m=x=>{x>0?n+=`\x1B[${x}C`:x<0&&(n+=`\x1B[${-x}D`)};f&&((x=>{x>0?n+=`\x1B[${x}B`:x<0&&(n+=`\x1B[${-x}A`)})(l-this._lastCursorRow),m(d-this._lastCursorCol))}let a=this._terminal._core._inputHandler._curAttrData,c=this._diffStyle(a,this._cursorStyle);return c.length>0&&(n+=`\x1B[${c.join(";")}m`),n}},Nk=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,r,n){let a=r.length,c=n===void 0?a:f2(n+t.rows,0,a);return this._serializeBufferByRange(t,r,{start:a-c,end:a-1},!1)}_serializeBufferByRange(t,r,n,a){return new Ek(r,t).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:t.cols,y:typeof n.end=="number"?n.end:n.end.line}},a)}_serializeBufferAsHTML(t,r){let n=t.buffer.active,a=new Rk(n,t,r),c=r.onlySelection??!1,l=r.range;if(l)return a.serialize({start:{x:l.startCol,y:(l.startLine,l.startLine)},end:{x:t.cols,y:(l.endLine,l.endLine)}});if(!c){let f=n.length,m=r.scrollback,x=m===void 0?f:f2(m+t.rows,0,f);return a.serialize({start:{x:0,y:f-x},end:{x:t.cols,y:f-1}})}let d=this._terminal?.getSelectionPosition();return d!==void 0?a.serialize({start:{x:d.start.x,y:d.start.y},end:{x:d.end.x,y:d.end.y}}):""}_serializeScrollRegion(t){let r=t._core.buffer,n=r.scrollTop,a=r.scrollBottom;return n!==0||a!==t.rows-1?`\x1B[${n+1};${a+1}r`:""}_serializeModes(t){let r="",n=t.modes;if(n.applicationCursorKeysMode&&(r+="\x1B[?1h"),n.applicationKeypadMode&&(r+="\x1B[?66h"),n.bracketedPasteMode&&(r+="\x1B[?2004h"),n.insertMode&&(r+="\x1B[4h"),n.originMode&&(r+="\x1B[?6h"),n.reverseWraparoundMode&&(r+="\x1B[?45h"),n.sendFocusMode&&(r+="\x1B[?1004h"),n.wraparoundMode===!1&&(r+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":r+="\x1B[?9h";break;case"vt200":r+="\x1B[?1000h";break;case"drag":r+="\x1B[?1002h";break;case"any":r+="\x1B[?1003h";break}return n.showCursor||(r+="\x1B[?25l"),r}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let r=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);if(!t?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);r+=`\x1B[?1049h\x1B[H${n}`}return t?.excludeModes||(r+=this._serializeModes(this._terminal),r+=this._serializeScrollRegion(this._terminal)),r}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t??{})}dispose(){}},Rk=class extends ev{constructor(t,r,n){super(t),this._terminal=r,this._options=n,this._currentRow="",this._htmlContent="",r._core._themeService?this._ansiColors=r._core._themeService.colors.ansi:this._ansiColors=Lk}_beforeSerialize(t,r,n){this._htmlContent+="<html><body><!--StartFragment--><pre>";let a="#000000",c="#ffffff";(this._options.includeGlobalBackground??!1)&&(a=this._terminal.options.theme?.foreground??"#ffffff",c=this._terminal.options.theme?.background??"#000000");let l=[];l.push("color: "+a+";"),l.push("background-color: "+c+";"),l.push("font-family: "+this._terminal.options.fontFamily+";"),l.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+l.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(t,r){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,r){let n=r?t.getFgColor():t.getBgColor();if(r?t.isFgRGB():t.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(a=>a.toString(16).padStart(2,"0")).join("");if(r?t.isFgPalette():t.isBgPalette())return this._ansiColors[n].css}_getUnderlineColor(t){if(t.isUnderlineColorDefault())return;let r=t.getUnderlineColor();return t.isUnderlineColorRGB()?"#"+[r>>16&255,r>>8&255,r&255].map(n=>n.toString(16).padStart(2,"0")).join(""):this._ansiColors[r].css}_getUnderlineStyle(t){switch(t.getUnderlineStyle()){case 1:return"underline";case 2:return"underline double";case 3:return"underline wavy";case 4:return"underline dotted";case 5:return"underline dashed";default:return"underline"}}_diffStyle(t,r){let n=[];if(rv(t,r))return;let a=!pg(t,r),c=!wl(t,r),l=!mg(t,r);if(a||c||l){let d=this._getHexColor(t,!0);d&&n.push("color: "+d+";");let f=this._getHexColor(t,!1);f&&n.push("background-color: "+f+";"),t.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&n.push("font-weight: bold;");let m=[];if(t.isUnderline()&&m.push(this._getUnderlineStyle(t)),t.isOverline()&&m.push("overline"),t.isStrikethrough()&&m.push("line-through"),t.isBlink()&&m.push("blink"),m.length>0&&n.push("text-decoration: "+m.join(" ")+";"),t.isUnderline()){let x=this._getUnderlineColor(t);x&&n.push("text-decoration-color: "+x+";")}return t.isInvisible()&&n.push("visibility: hidden;"),t.isItalic()&&n.push("font-style: italic;"),t.isDim()&&n.push("opacity: 0.5;"),n}}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let c=t.getChars()==="",l=this._diffStyle(t,r);l&&(this._currentRow+=l.length===0?"</span><span>":"</span><span style='"+l.join(" ")+"'>"),c?this._currentRow+=" ":this._currentRow+=Ik(t.getChars())}_serializeString(){return this._htmlContent}};var Mk=class{constructor(e=new jk,t=new nv){this._base64=e,this._provider=t}activate(e){this._terminal=e,this._disposable=e.parser.registerOscHandler(52,t=>this._setOrReportClipboard(t))}dispose(){return this._disposable?.dispose()}_readText(e,t){let r=this._base64.encodeText(t);this._terminal?.input(`\x1B]52;${e};${r}\x07`,!1)}_setOrReportClipboard(e){let t=e.split(";");if(t.length<2)return!0;let r=t[0],n=t[1];if(n==="?"){let l=this._provider.readText(r);return l instanceof Promise?l.then(d=>(this._readText(r,d),!0)):(this._readText(r,l),!0)}let a="";try{a=this._base64.decodeText(n)}catch{}let c=this._provider.writeText(r,a);return c instanceof Promise?c.then(()=>!0):!0}},nv=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},jk=class{encodeText(t){let r=new TextEncoder().encode(t);if(r.toBase64!==void 0)return r.toBase64();let n="";for(let a=0;a<r.length;a++)n+=String.fromCharCode(r[a]);return btoa(n)}decodeText(t){if(Uint8Array.fromBase64!==void 0){try{return new TextDecoder().decode(Uint8Array.fromBase64(t))}catch{}return""}try{let r=atob(t),n=new Uint8Array(r.length);for(let a=0;a<r.length;++a)n[a]=r.charCodeAt(a);return new TextDecoder().decode(n)}catch{}return""}};var Dk=Object.create,sv=Object.defineProperty,Bk=Object.getOwnPropertyDescriptor,Qk=Object.getOwnPropertyNames,Pk=Object.getPrototypeOf,Ok=Object.prototype.hasOwnProperty,fd=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Fk=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Qk(t))!Ok.call(e,a)&&a!==r&&sv(e,a,{get:()=>t[a],enumerable:!(n=Bk(t,a))||n.enumerable});return e},pd=(e,t,r)=>(r=e!=null?Dk(Pk(e)):{},Fk(!e||!e.__esModule?sv(r,"default",{value:e,enumerable:!0}):r,e)),gg=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn("BE platform detected. This version of node-sixel works only on LE properly.");function t(v){return v&255}e.red=t;function r(v){return v>>>8&255}e.green=r;function n(v){return v>>>16&255}e.blue=n;function a(v){return v>>>24&255}e.alpha=a;function c(v,T,C,L=255){return((L&255)<<24|(C&255)<<16|(T&255)<<8|v&255)>>>0}e.toRGBA8888=c;function l(v){return[v&255,v>>8&255,v>>16&255,v>>>24]}e.fromRGBA8888=l;function d(v,T){let C=t(v),L=r(v),N=n(v),D=Number.MAX_SAFE_INTEGER,O=-1;for(let P=0;P<T.length;++P){let F=C-T[P][0],ee=L-T[P][1],Z=N-T[P][2],G=F*F+ee*ee+Z*Z;if(!G)return P;G<D&&(D=G,O=P)}return O}e.nearestColorIndex=d;function f(v,T,C){return Math.max(v,Math.min(C,T))}function m(v,T,C){return C<0&&(C+=1),C>1&&(C-=1),C*6<1?T+(v-T)*6*C:C*2<1?v:C*3<2?T+(v-T)*(4-C*6):T}function x(v,T,C){if(!C){let D=Math.round(T*255);return c(D,D,D)}let L=T<.5?T*(1+C):T+C-T*C,N=2*T-L;return c(f(0,255,Math.round(m(L,N,v+1/3)*255)),f(0,255,Math.round(m(L,N,v)*255)),f(0,255,Math.round(m(L,N,v-1/3)*255)))}function y(v,T,C){return(4278190080|Math.round(C/100*255)<<16|Math.round(T/100*255)<<8|Math.round(v/100*255))>>>0}e.normalizeRGB=y;function w(v,T,C){return x((v+240%360)/360,T/100,C/100)}e.normalizeHLS=w,e.PALETTE_VT340_COLOR=new Uint32Array([y(0,0,0),y(20,20,80),y(80,13,13),y(20,80,20),y(80,20,80),y(20,80,80),y(80,80,20),y(53,53,53),y(26,26,26),y(33,33,60),y(60,26,26),y(33,60,33),y(60,33,60),y(33,60,60),y(60,60,33),y(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46),y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let v=[c(0,0,0),c(205,0,0),c(0,205,0),c(205,205,0),c(0,0,238),c(205,0,205),c(0,250,205),c(229,229,229),c(127,127,127),c(255,0,0),c(0,255,0),c(255,255,0),c(92,92,255),c(255,0,255),c(0,255,255),c(255,255,255)],T=[0,95,135,175,215,255];for(let C=0;C<6;++C)for(let L=0;L<6;++L)for(let N=0;N<6;++N)v.push(c(T[C],T[L],T[N]));for(let C=8;C<=238;C+=10)v.push(c(C,C,C));return new Uint32Array(v)})(),e.DEFAULT_BACKGROUND=c(0,0,0,255),e.DEFAULT_FOREGROUND=c(255,255,255,255)}),iv=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InWasm=r;var t=n=>{if(Uint8Array.fromBase64)return Uint8Array.fromBase64(n);if(typeof Buffer<"u")return Buffer.from(n,"base64");let a=atob(n),c=new Uint8Array(a.length);for(let l=0;l<c.length;++l)c[l]=a.charCodeAt(l);return c};function r(n){if(n.d){let{t:a,s:c,d:l}=n,d,f,m=WebAssembly;return a===0?c?x=>new m.Instance(f||(f=new m.Module(d||(d=t(l)))),x):x=>f?m.instantiate(f,x):m.instantiate(d||(d=t(l)),x).then(y=>(f=y.module)&&y.instance):a===1?c?()=>f||(f=new m.Module(d||(d=t(l)))):()=>f?Promise.resolve(f):m.compile(d||(d=t(l))).then(x=>f=x):c?()=>d||(d=t(l)):()=>Promise.resolve(d||(d=t(l)))}if(typeof _wasmCtx>"u")throw new Error('must run "inwasm"');_wasmCtx.add(n)}}),av=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=iv(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqLBgKZBAEKf0GIKCgCAEGgKGohAUGEKCgCACIDQaAoaiEAQYAoKAIAQQFrQXxxIgRBoChqIQUgBEEQayADSgRAIARBkChqIQMDQCABIABBA2otAABBAnQoAoAgIABBAmotAABBAnQoAoAYIABBAWotAABBAnQoAoAQIAAtAABBAnQoAoAIcnJyIgY2AgAgAUEDaiAAQQdqLQAAQQJ0KAKAICAAQQZqLQAAQQJ0KAKAGCAAQQVqLQAAQQJ0KAKAECAAQQRqLQAAQQJ0KAKACHJyciIHNgIAIAFBBmogAEELai0AAEECdCgCgCAgAEEKai0AAEECdCgCgBggAEEJai0AAEECdCgCgBAgAEEIai0AAEECdCgCgAhycnIiCDYCACABQQlqIABBD2otAABBAnQoAoAgIABBDmotAABBAnQoAoAYIABBDWotAABBAnQoAoAQIABBDGotAABBAnQoAoAIcnJyIgk2AgAgAiAGciAHciAIciAJciECIAFBDGohASAAQRBqIgAgA0kNAAsLIAAgBUkEQANAIAEgAEEDai0AAEECdCgCgCAgAEECai0AAEECdCgCgBggAEEBai0AAEECdCgCgBAgAC0AAEECdCgCgAhycnIiAzYCACACIANyIQIgAUEDaiEBIABBBGoiACAFSQ0ACwtBfyEAIAJB////B00Ef0GEKCAENgIAQYgoIAFBoChrNgIAQQAFQX8LC+0BAQR/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQX8hAxAADQFBgCgoAgAhAUGEKCgCACEAC0F/IQMgASAAayIBQQJIDQAgAC0AoShBAnQoAoAQIAAtAKAoQQJ0KAKACHIhAgJ/IAFBBEYEQEEDQQQgAC0AoyhBPUYbIAAtAKIoQT1GayEBC0EBIAFBA0kNABogAC0AoihBAnQoAoAYIAJyIQJBAiABQQRHDQAaIAAtAKMoQQJ0KAKAICACciECQQMLIQEgAkH///8HSw0AQQAhA0GIKCgCACIAIAI2AKAoQYgoIAAgAWo2AgALIAML"}),n=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map(d=>d.charCodeAt(0))),a=new Uint32Array(1024);a.fill(4278190080);for(let d=0;d<n.length;++d)a[n[d]]=d<<2;for(let d=0;d<n.length;++d)a[256+n[d]]=d>>4|(d<<4&255)<<8;for(let d=0;d<n.length;++d)a[512+n[d]]=d>>2<<8|(d<<6&255)<<16;for(let d=0;d<n.length;++d)a[768+n[d]]=d<<16;var c=new Uint8Array(0),l=class{constructor(d,f,m){if(this._inst=null,this._ended=!0,this._bytes=0,this.keepSize=d??1048576,this.maxBytes=f??4294901760,this._bytes=m??32768,this._bytes>this.maxBytes||this.maxBytes>4294901760)throw new Error("invalid byte settings")}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):c}release(){this._inst&&(this._bytes>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(d,f){if(this.maxBytes=d??this.maxBytes,this._bytes=f??Math.min(this._bytes,this.maxBytes),this._bytes>this.maxBytes||this.maxBytes>4294901760)throw Error("invalid byte settings");let m=this._m32,x=this._bytes+5152;this._inst?this._mem.buffer.byteLength<x&&(this._mem.grow(Math.ceil((x-this._mem.buffer.byteLength)/65536)),m=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(x/65536)}),this._inst=r({env:{memory:this._mem}}),m=new Uint32Array(this._mem.buffer,0),m.set(a,256),this._d=new Uint8Array(this._mem.buffer,5152)),m[1280]=0,m[1281]=0,m[1282]=0,this._m32=m,this._ended=!1}_realloc(d){let f=this._m32[1280]+d;if(this._bytes<f){if(f>this.maxBytes)return-3;let m=this._bytes;for(;(m*=2)<f;);if(m=Math.min(m,this.maxBytes),m<f)return-3;if(m+5152>this._mem.buffer.byteLength){let x=Math.ceil((m+5152-this._mem.buffer.byteLength)/65536);this._mem.grow(x),this._m32=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)}this._bytes=m}return 0}put(d){if(!this._inst||this._ended)return-2;if(this._realloc(d.length))return-3;let f=this._m32;return this._d.set(d,f[1280]),f[1280]+=d.length,f[1280]-f[1281]>=131072?this._inst.exports.dec():0}end(){return this._ended=!0,this._inst?this._inst.exports.end():-2}get loadedBytes(){return this._inst?this._m32[1280]:0}get freeBytes(){return this._inst?this.maxBytes-this._m32[1280]:0}};e.default=l}),$k=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=iv(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABCgJgAABgA39/fwACDwEDZW52Bm1lbW9yeQIAAQMDAgABBwcBA2RlYwABCAEACu4EAgwAQQBBAEGAAvwLAAveBAEJf0EAQQBBgAL8CwAgAUEXTgRAIAAgAWpBCGshCkGACCEBIAJBAnRBgAhqIQsgAEEOaiEDQf8BIQZBACECA0AgA0EBaiEHIAMtAAAiCEE/cSEAAkACQCAIQcABcSIJRQRAIABBAnQiAC0AAyEGIAAtAAIhBCAALQABIQUgAC0AACECIAchAwwBCwJAIAhB/QFLDQAgCUHAAUcNACAFQQVsIAJBA2xqIARBB2xqIAZBC2xqQT9xQQJ0IgMgBDoAAiADIAU6AAEgAyACOgAAIANBA2ogBjoAAANAIAEgAjoAACABQQNqIAY6AAAgAUECaiAEOgAAIAFBAWogBToAACABQQRqIQEgAEUEQCAHIQMMBAsgAEEBayEAIAEgC0kNAAsgByEDDAILAn8CQAJAAkAgCEH+AWsOAgABAgsgAy0AAyEEIAMtAAIhBSADLQABIQIgA0EEagwCCyADKAIBIgJBGHYhBiACQRB2IQQgAkEIdiEFIANBBWoMAQsgCUGAAUcEQCAHIAlBwABHDQEaIAQgCEEDcWpBAmshBCACIABBBHZqQQJrIQIgBSAIQQJ2QQNxakECayEFIAcMAQsgBCAAQShrIgkgAy0AASIHQQ9xamohBCACIAdBBHYgCWpqIQIgACAFakEgayEFIANBAmoLIQMgBUEFbCACQQNsaiAEQQdsaiAGQQtsakE/cUECdCIAIAQ6AAIgACAFOgABIAAgAjoAACAAQQNqIAY6AAALIAEgBjoAAyABIAQ6AAIgASAFOgABIAEgAjoAACABQQRqIQELIAMgCkkNAAsLCw=="}),n=class{constructor(a){this.keepSize=a,this.width=0,this.height=0}decode(a){this.width=a[4]<<24|a[5]<<16|a[6]<<8|a[7],this.height=a[8]<<24|a[9]<<16|a[10]<<8|a[11];let c=this.width*this.height,l=c*4,d=a.length,f=Math.max(l,d)+(Math.min(l,d)>>1)+4096;this._inst?this._mem.buffer.byteLength<f&&(this._mem.grow(Math.ceil((f-this._mem.buffer.byteLength)/65536)),this._d=null):(this._mem=new WebAssembly.Memory({initial:Math.ceil(f/65536)}),this._inst=r({env:{memory:this._mem}})),this._d||(this._d=new Uint8Array(this._mem.buffer));let m=this._mem.buffer.byteLength-d&-256;return this._d.set(a,m),this._inst.exports.dec(m,d,c),this._d.subarray(1024,1024+l)}release(){this._inst&&this._mem.buffer.byteLength>this.keepSize&&(this._inst=this._d=this._mem=null)}};e.default=n}),Uk=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:"AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF"}}),zk=fd(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=gg(),r=Uk();function n(v){if(typeof Buffer<"u")return Buffer.from(v,"base64");let T=atob(v),C=new Uint8Array(T.length);for(let L=0;L<C.length;++L)C[L]=T.charCodeAt(L);return C}var a=n(r.LIMITS.BYTES),c,l=new Uint32Array,d=class{constructor(){this.bandHandler=v=>1,this.modeHandler=v=>1}handle_band(v){return this.bandHandler(v)}mode_parsed(v){return this.modeHandler(v)}},f={memoryLimit:2048*65536,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:r.LIMITS.PALETTE_SIZE,truncate:!0};function m(v){let T=new d,C={env:{handle_band:T.handle_band.bind(T),mode_parsed:T.mode_parsed.bind(T)}};return WebAssembly.instantiate(c||a,C).then(L=>(c=c||L.module,new x(v,L.instance||L,T)))}e.DecoderAsync=m;var x=class{constructor(v,T,C){if(this._PIXEL_OFFSET=r.LIMITS.MAX_WIDTH+4,this._canvas=l,this._bandWidths=[],this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},f,v),this._opts.paletteLimit>r.LIMITS.PALETTE_SIZE)throw new Error(`DecoderOptions.paletteLimit must not exceed ${r.LIMITS.PALETTE_SIZE}`);if(T)C.bandHandler=this._handle_band.bind(this),C.modeHandler=this._initCanvas.bind(this);else{let L=c||(c=new WebAssembly.Module(a));T=new WebAssembly.Instance(L,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=T,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),r.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),r.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(v){if(v===2){let T=this.width*this.height;if(T>this._canvas.length){if(this._opts.memoryLimit&&T*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(T)}this._maxWidth=this._width}else if(v===1)if(this._level===2){let T=Math.min(this._rasterWidth,r.LIMITS.MAX_WIDTH)*this._rasterHeight;if(T>this._canvas.length){if(this._opts.memoryLimit&&T*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(T)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(v,T){let C=v+T;if(C>this._canvas.length){if(this._opts.memoryLimit&&C*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");let L=new Uint32Array(Math.ceil(C/65536)*65536);L.set(this._canvas),this._canvas=L}}_handle_band(v){let T=this._PIXEL_OFFSET,C=this._lastOffset;if(this._mode===2){let L=this.height-this._currentHeight,N=0;for(;N<6&&L>0;)this._canvas.set(this._pSrc.subarray(T*N,T*N+v),C+v*N),N++,L--;this._lastOffset+=v*N,this._currentHeight+=N}else if(this._mode===1){this._realloc(C,v*6),this._maxWidth=Math.max(this._maxWidth,v),this._minWidth=Math.min(this._minWidth,v);for(let L=0;L<6;++L)this._canvas.set(this._pSrc.subarray(T*L,T*L+v),C+v*L);this._bandWidths.push(v),this._lastOffset+=v*6,this._currentHeight+=6}return 0}get width(){return this._mode!==1?this._width:Math.max(this._maxWidth,this._wasm.current_width())}get height(){return this._mode!==1?this._height:this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(v=this._opts.fillColor,T=this._opts.palette,C=this._opts.paletteLimit,L=this._opts.truncate){this._wasm.init(this._opts.sixelColor,v,C,L?1:0),T&&this._palette.set(T.subarray(0,r.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(v,T=0,C=v.length){let L=T;for(;L<C;){let N=Math.min(C-L,r.LIMITS.CHUNK_SIZE);this._chunk.set(v.subarray(L,L+=N)),this._wasm.decode(0,N)}}decodeString(v,T=0,C=v.length){let L=T;for(;L<C;){let N=Math.min(C-L,r.LIMITS.CHUNK_SIZE);for(let D=0,O=L;D<N;++D,++O)this._chunk[D]=v.charCodeAt(O);L+=N,this._wasm.decode(0,N)}}get data32(){if(this._mode===0||!this.width||!this.height)return l;let v=this._wasm.current_width();if(this._mode===2){let T=this.height-this._currentHeight;if(T>0){let C=this._PIXEL_OFFSET,L=this._lastOffset,N=0;for(;N<6&&T>0;)this._canvas.set(this._pSrc.subarray(C*N,C*N+v),L+v*N),N++,T--;T&&this._canvas.fill(this._fillColor,L+v*N)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let N=!1;if(v)if(v!==this._minWidth)N=!0;else{let D=this._PIXEL_OFFSET,O=this._lastOffset;this._realloc(O,v*6);for(let P=0;P<6;++P)this._canvas.set(this._pSrc.subarray(D*P,D*P+v),O+v*P)}if(!N)return this._canvas.subarray(0,this.width*this.height)}let T=new Uint32Array(this.width*this.height);T.fill(this._fillColor);let C=0,L=0;for(let N=0;N<this._bandWidths.length;++N){let D=this._bandWidths[N];for(let O=0;O<6;++O)T.set(this._canvas.subarray(L,L+=D),C),C+=this.width}if(v){let N=this._PIXEL_OFFSET,D=this._wasm.current_height();for(let O=0;O<D;++O)T.set(this._pSrc.subarray(N*O,N*O+v),C+this.width*O)}return T}return l}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=l,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=x;function y(v,T){let C=new x(T);return C.init(),typeof v=="string"?C.decodeString(v):C.decode(v),{width:C.width,height:C.height,data32:C.data32,data8:C.data8}}e.decode=y;async function w(v,T){let C=await m(T);return C.init(),typeof v=="string"?C.decodeString(v):C.decode(v),{width:C.width,height:C.height,data32:C.data32,data8:C.data8}}e.decodeAsync=w});function g1(e){return{dispose:e}}var ov=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},lv=class{constructor(){this._store=new ov}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};lv.None=Object.freeze({dispose(){}});var Hk=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},Wk=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return g1(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=g1(()=>{let c=this._listeners.indexOf(n);c!==-1&&this._listeners.splice(c,1)});return r&&(Array.isArray(r)?r.push(a):r.add(a)),a},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:r}=this._listeners[0];t.call(r,e);return}default:{let t=this._listeners.slice();for(let{fn:r,thisArgs:n}of t)r.call(n,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},Gk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new ov;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(Gk||={});var p2=pd(gg()),id=class gc extends lv{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new Hk),this._oldOpen=this._terminal._core.open,this._terminal._core.open=r=>{this._oldOpen?.call(this._terminal._core,r),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange(r=>{r==="fontSize"&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))}),this._register(g1(()=>{this.removeLayerFromDom(),this.removeLayerFromDom("bottom"),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this._layers.clear(),this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0}))}get canvas(){return this._layers.get("top")?.canvas}static createCanvas(t,r,n){let a=(t??document).createElement("canvas");return a.width=r|0,a.height=n|0,a}static createImageData(t,r,n,a){if(typeof ImageData!="function"){let c=t.createImageData(r,n);return a&&c.data.set(new Uint8ClampedArray(a,0,r*n*4)),c}return a?new ImageData(new Uint8ClampedArray(a,0,r*n*4),r,n):new ImageData(r,n)}static createImageBitmap(t){return typeof createImageBitmap!="function"?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&this.cellSize.height!==-1&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._terminal.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,r,n){let a=t*(this.dimensions?.css.cell.height||0),c=this.dimensions?.css.canvas.width||0,l=(r+1-t)*(this.dimensions?.css.cell.height||0);(!n||n==="top")&&this._layers.get("top")?.clearRect(0,a,c,l),(!n||n==="bottom")&&this._layers.get("bottom")?.clearRect(0,a,c,l)}clearAll(t){if(!t||t==="top"){let r=this._layers.get("top");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}if(!t||t==="bottom"){let r=this._layers.get("bottom");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}}draw(t,r,n,a,c=1){let l=this._layers.get(t.layer);if(!l)return;let{width:d,height:f}=this.cellSize;if(d===-1||f===-1)return;this._rescaleImage(t,d,f);let m=t.actual,x=Math.ceil(m.width/d),y=r%x*d,w=Math.floor(r/x)*f,v=n*d,T=a*f,C=c*d+y>m.width?m.width-y:c*d,L=w+f>m.height?m.height-w:f;l.drawImage(m,Math.floor(y),Math.floor(w),Math.ceil(C),Math.ceil(L),Math.floor(v),Math.floor(T),Math.ceil(C),Math.ceil(L))}extractTile(t,r){let{width:n,height:a}=this.cellSize;if(n===-1||a===-1)return;this._rescaleImage(t,n,a);let c=t.actual,l=Math.ceil(c.width/n),d=r%l*n,f=Math.floor(r/l)*a,m=n+d>c.width?c.width-d:n,x=f+a>c.height?c.height-f:a,y=gc.createCanvas(this.document,m,x),w=y.getContext("2d");if(w)return w.drawImage(c,Math.floor(d),Math.floor(f),Math.floor(m),Math.floor(x),0,0,Math.floor(m),Math.floor(x)),y}drawPlaceholder(t,r,n=1){let a=this._layers.get("top");if(a){let{width:c,height:l}=this.cellSize;if(c===-1||l===-1||(this._placeholder?l>=this._placeholder.height&&this._createPlaceHolder(l+1):this._createPlaceHolder(Math.max(l+1,24)),!this._placeholder))return;a.drawImage(this._placeholderBitmap??this._placeholder,t*c,r*l%2?0:1,c*n,l,t*c,r*l,c*n,l)}}rescaleCanvas(){let t=this.dimensions?.css.canvas.width||0,r=this.dimensions?.css.canvas.height||0;for(let n of this._layers.values())(n.canvas.width!==t||n.canvas.height!==r)&&(n.canvas.width=t,n.canvas.height=r)}_rescaleImage(t,r,n){if(r===t.actualCellSize.width&&n===t.actualCellSize.height)return;let{width:a,height:c}=t.origCellSize;if(r===a&&n===c){t.actual=t.orig,t.actualCellSize.width=a,t.actualCellSize.height=c;return}let l=gc.createCanvas(this.document,Math.ceil(t.orig.width*r/a),Math.ceil(t.orig.height*n/c)),d=l.getContext("2d");d&&(d.drawImage(t.orig,0,0,l.width,l.height),t.actual=l,t.actualCellSize.width=r,t.actualCellSize.height=n)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{for(let r of[...this._layers.keys()])this.removeLayerFromDom(r);this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(t="top"){if(!this.document||!this._terminal._core.screenElement){console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement");return}if(this._layers.has(t))return;let r=gc.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0);r.classList.add(`xterm-image-layer-${t}`);let n=this._terminal._core.screenElement;n.style.isolation="isolate",t==="bottom"?(r.style.zIndex="-1",n.insertBefore(r,n.firstChild)):(r.style.zIndex="0",n.appendChild(r));let a=r.getContext("2d",{alpha:!0});if(!a){r.remove();return}this._layers.set(t,a),this.clearAll(t)}removeLayerFromDom(t="top"){let r=this._layers.get(t);r&&(r.canvas.remove(),this._layers.delete(t))}hasLayer(t){return this._layers.has(t)}_createPlaceHolder(t=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let r=32,n=gc.createCanvas(this.document,r,t),a=n.getContext("2d",{alpha:!1});if(!a)return;let c=gc.createImageData(a,r,t),l=new Uint32Array(c.data.buffer),d=(0,p2.toRGBA8888)(0,0,0),f=(0,p2.toRGBA8888)(255,255,255);l.fill(d);for(let y=0;y<t;++y){let w=y%2,v=y*r;for(let T=0;T<r;T+=2)l[v+T+w]=f}a.putImageData(c,0,0);let m=screen.width+r-1&-32||4096;this._placeholder=gc.createCanvas(this.document,m,t);let x=this._placeholder.getContext("2d",{alpha:!1});if(!x){this._placeholder=void 0;return}for(let y=0;y<m;y+=r)x.drawImage(n,y,0);gc.createImageBitmap(this._placeholder).then(y=>this._placeholderBitmap=y)}get document(){return this._terminal._core._coreBrowserService?.window.document}},Wl={width:7,height:14},x1=class cv{constructor(t=0,r=0,n=-1,a=-1){this.imageId=n,this.tileId=a,this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new cv(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},Ah=new x1,Vk=class{constructor(e,t,r){this._terminal=e,this._renderer=t,this._opts=r,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(n){n instanceof Error&&console.error(n.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let e of this._images.values())e.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return this._pixelLimit*4/1e6}setLimit(e){if(e<.5||e>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=e/4*1e6>>>0,this._evictOldest(0)}getUsage(){return this._getStoredPixels()*4/1e6}_getStoredPixels(){let e=0;for(let t of this._images.values())t.orig&&(e+=t.orig.width*t.orig.height,t.actual&&t.actual!==t.orig&&(e+=t.actual.width*t.actual.height));return e}_delImg(e){let t=this._images.get(e);t&&(this._images.delete(e),window.ImageBitmap&&t.orig instanceof ImageBitmap&&t.orig.close(),this.onImageDeleted?.(e))}wipeAlternate(){let e=[];for(let[t,r]of this._images.entries())r.bufferType==="alternate"&&(r.marker?.dispose(),e.push(t));for(let t of e)this._delImg(t);this._needsFullClear=!0,this._fullyCleared=!1}deleteImage(e){let t=this._images.get(e);t&&(t.marker?.dispose(),this._delImg(e))}addImage(e,t){this._evictOldest(e.width*e.height);let r=this._renderer.cellSize;(r.width===-1||r.height===-1)&&(r=Wl);let n=Math.ceil(e.width/r.width),a=Math.ceil(e.height/r.height),c=++this._lastId,l=this._terminal._core.buffer,d=this._terminal.cols,f=this._terminal.rows,m=l.x,x=l.y,y=m,w=0;t.scrolling||(l.x=0,l.y=0,y=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(l.y);for(let L=0;L<a;++L){let N=l.lines.get(l.y+l.ybase);for(let D=0;D<n&&!(y+D>=d);++D)this._writeToCell(N,y+D,c,L*n+D),w++;if(t.scrolling)L<a-1&&this._terminal._core._inputHandler.lineFeed();else if(++l.y>=f)break;l.x=y}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(l.y),t.scrolling?t.cursorPos==="iip"?l.x=Math.min(y+n,d):l.x=y:(l.x=m,l.y=x);let v=[];for(let[L,N]of this._images.entries())N.tileCount<1&&(N.marker?.dispose(),v.push(L));for(let L of v)this._delImg(L);let T=this._terminal.registerMarker(0);T?.onDispose(()=>{this._images.get(c)&&this._delImg(c)}),this._terminal.buffer.active.type==="alternate"&&this._evictOnAlternate();let C={orig:e,origCellSize:r,actual:e,actualCellSize:{...r},marker:T||void 0,tileCount:w,bufferType:this._terminal.buffer.active.type,layer:t.layer,zIndex:t.zIndex};return this._images.set(c,C),this.onImageAdded?.(),c}render(e){let t=!1,r=!1;for(let m of this._images.values())if(m.layer==="bottom"?r=!0:t=!0,t&&r)break;if(t&&!this._renderer.hasLayer("top")&&(this._renderer.insertLayerToDom("top"),!this._renderer.hasLayer("top")))return;if(r&&!this._renderer.hasLayer("bottom")&&this._renderer.insertLayerToDom("bottom"),this._renderer.rescaleCanvas(),!this._images.size){this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),this._renderer.hasLayer("top")&&this._renderer.removeLayerFromDom("top"),this._renderer.hasLayer("bottom")&&this._renderer.removeLayerFromDom("bottom");return}!t&&this._renderer.hasLayer("top")&&(this._renderer.clearAll("top"),this._renderer.removeLayerFromDom("top")),!r&&this._renderer.hasLayer("bottom")&&(this._renderer.clearAll("bottom"),this._renderer.removeLayerFromDom("bottom")),this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:n,end:a}=e,c=this._terminal._core.buffer,l=this._terminal._core.cols;this._renderer.clearLines(n,a);let d=[],f=[];for(let m=n;m<=a;++m){let x=c.lines.get(m+c.ydisp);if(!x)return;for(let y=0;y<l;++y){let w;if(x.getBg(y)&268435456)w=x._extendedAttrs[y]??Ah;else{let C=x._extendedAttrs[y];if(!C||C.imageId===void 0||C.imageId===-1)continue;w=C}let v=w.imageId;if(v===void 0||v===-1)continue;let T=this._images.get(v);if(w.tileId!==-1){let C=w.tileId,L=y,N=1;for(;++y<l;){let D=x._extendedAttrs[y];if(!D||D.imageId!==v||D.tileId!==C+N)break;N++}y--,T?T.actual&&d.push({imgSpec:T,tileId:C,col:L,row:m,count:N}):this._opts.showPlaceholder&&f.push({col:L,row:m,count:N}),this._fullyCleared=!1}}}d.sort((m,x)=>m.imgSpec.zIndex-x.imgSpec.zIndex);for(let m of f)this._renderer.drawPlaceholder(m.col,m.row,m.count);for(let m of d)this._renderer.draw(m.imgSpec,m.tileId,m.col,m.row,m.count)}viewportResize(e){if(!this._images.size){this._viewportMetrics=e;return}if(this._viewportMetrics.cols>=e.cols){this._viewportMetrics=e;return}let t=this._terminal._core.buffer,r=t.lines.length,n=this._viewportMetrics.cols-1;for(let a=0;a<r;++a){let c=t.lines.get(a);if(c.getBg(n)&268435456){let l=c._extendedAttrs[n]??Ah,d=l.imageId;if(d===void 0||d===-1)continue;let f=this._images.get(d);if(!f)continue;let m=Math.ceil((f.actual?.width||0)/f.actualCellSize.width);if(l.tileId%m+1>=m)continue;let x=!1;for(let v=n+1;v>e.cols;++v)if(c._data[v*3+0]&4194303){x=!0;break}if(x)continue;let y=Math.min(e.cols,m-l.tileId%m+n),w=l.tileId;for(let v=n+1;v<y;++v)this._writeToCell(c,v,d,++w),f.tileCount++}}this._viewportMetrics=e}getImageAtBufferCell(e,t){let r=this._terminal._core.buffer.lines.get(t);if(r&&r.getBg(e)&268435456){let n=r._extendedAttrs[e]??Ah;if(n.imageId&&n.imageId!==-1){let a=this._images.get(n.imageId)?.orig;if(window.ImageBitmap&&a instanceof ImageBitmap){let c=id.createCanvas(window.document,a.width,a.height);return c.getContext("2d")?.drawImage(a,0,0,a.width,a.height),c}return a}}}extractTileAtBufferCell(e,t){let r=this._terminal._core.buffer.lines.get(t);if(r&&r.getBg(e)&268435456){let n=r._extendedAttrs[e]??Ah;if(n.imageId&&n.imageId!==-1&&n.tileId!==-1){let a=this._images.get(n.imageId);if(a)return this._renderer.extractTile(a,n.tileId)}}}_evictOldest(e){let t=this._getStoredPixels(),r=t;for(;this._pixelLimit<r+e&&this._images.size;){let n=this._images.get(++this._lowestId);n&&n.orig&&(r-=n.orig.width*n.orig.height,n.actual&&n.orig!==n.actual&&(r-=n.actual.width*n.actual.height),n.marker?.dispose(),this._delImg(this._lowestId))}return t-r}_writeToCell(e,t,r,n){if(e._data[t*3+2]&268435456){let a=e._extendedAttrs[t];if(a){if(a.imageId!==void 0){let c=this._images.get(a.imageId);c&&c.tileCount--,a.imageId=r,a.tileId=n;return}e._extendedAttrs[t]=new x1(a.ext,a.urlId,r,n);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new x1(0,0,r,n)}_evictOnAlternate(){for(let r of this._images.values())r.bufferType==="alternate"&&(r.tileCount=0);let e=this._terminal._core.buffer;for(let r=0;r<this._terminal.rows;++r){let n=e.lines.get(r);if(n){for(let a=0;a<this._terminal.cols;++a)if(n._data[a*3+2]&268435456){let c=n._extendedAttrs[a]?.imageId;if(c){let l=this._images.get(c);l&&l.tileCount++}}}}let t=[];for(let[r,n]of this._images.entries())n.bufferType==="alternate"&&!n.tileCount&&(n.marker?.dispose(),t.push(r));for(let r of t)this._delImg(r)}},qk=pd(av()),Yk=pd($k());function Mf(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}function Jp(e){let t=0;for(let r=0;r<e.length;++r){if(e[r]<48||e[r]>57)throw new Error("illegal char");t=t*10+e[r]-48}return t}function m2(e){let t=Mf(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function Zk(e){if(typeof Buffer<"u")return Buffer.from(Mf(e),"base64").toString();let t=atob(Mf(e)),r=new Uint8Array(t.length);for(let n=0;n<r.length;++n)r[n]=t.charCodeAt(n);return new TextDecoder().decode(r)}var g2={inline:Jp,size:Jp,name:Zk,width:m2,height:m2,preserveAspectRatio:Jp},x2=[70,105,108,101],b2=[77,117,108,116,105,112,97,114,116,70,105,108,101],em=[70,105,108,101,80,97,114,116],tm=[70,105,108,101,69,110,100],rm=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],nm=1024,Kk=class{constructor(){this.state=0,this._buffer=new Uint32Array(nm),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}end(){if(this.state===0){if(this._position===tm.length){for(let t=0;t<tm.length;++t)if(this._buffer[t]!==tm[t])return this._a();return this.fields.type=4,this.state=4,0}if(this._position===rm.length){for(let t=0;t<rm.length;++t)if(this._buffer[t]!==rm[t])return this._a();return this.fields.type=5,this.state=4,0}return this._a()}return this.state===4?0:this.state===3&&this.fields.type===2?this._storeValue(this._position)?(this.state=4,0):this._a():this._a()}parse(t,r,n){let a=this.state,c=this._position,l=this._buffer;if(a===1||a===4||a===0&&c>14)return-1;for(let d=r;d<n;++d){let f=t[d];switch(f){case 59:if(!this._storeValue(c))return this._a();a=2,c=0;break;case 61:if(a===0){if(l[0]===70){let m=0;for(;m<x2.length;++m)if(l[m]!==x2[m])return this._a();if(this.fields.type=1,c===em.length){for(;m<em.length;++m)if(l[m]!==em[m])return this._a();return this.fields.type=3,this.state=4,d+1}}else if(l[0]===77){for(let m=0;m<b2.length;++m)if(l[m]!==b2[m])return this._a();this.fields.type=2}else return this._a();a=2,c=0}else if(a===2){if(!this._storeKey(c))return this._a();a=3,c=0}else if(a===3){if(c>=nm)return this._a();l[c++]=f}break;case 58:return a===3&&!this._storeValue(c)?this._a():(this.state=4,d+1);default:if(c>=nm)return this._a();l[c++]=f}}return this.state=a,this._position=c,-2}_a(){return this.fields.type=0,this.state=1,-1}_storeKey(t){let r=Mf(this._buffer.subarray(0,t));return r?(this._key=r,this.fields[r]=null,!0):!1}_storeValue(t){if(this._key){try{let r=this._buffer.slice(0,t);this.fields[this._key]=g2[this._key]?g2[this._key](r):r}catch{return!1}return!0}return!1}},jf={mime:"unsupported",width:0,height:0};function Xk(e){if(e.length<24)return jf;let t=new Uint32Array(e.buffer,e.byteOffset,6);if(t[0]===1196314761&&t[1]===169478669&&t[3]===1380206665)return{mime:"image/png",width:e[16]<<24|e[17]<<16|e[18]<<8|e[19],height:e[20]<<24|e[21]<<16|e[22]<<8|e[23]};if(e[0]===255&&e[1]===216&&e[2]===255){let[r,n]=Jk(e);return{mime:"image/jpeg",width:r,height:n}}return t[0]===944130375&&(e[4]===55||e[4]===57)&&e[5]===97?{mime:"image/gif",width:e[7]<<8|e[6],height:e[9]<<8|e[8]}:t[0]===1718185841?{mime:"image/qoi",width:e[4]<<24|e[5]<<16|e[6]<<8|e[7],height:e[8]<<24|e[9]<<16|e[10]<<8|e[11]}:jf}function Jk(e){let t=e.length,r=4,n=e[r]<<8|e[r+1];for(;;){if(r+=n,r>=t)return[0,0];if(e[r]!==255)return[0,0];if(e[r+1]===192||e[r+1]===194)return r+8<t?[e[r+7]<<8|e[r+8],e[r+5]<<8|e[r+6]]:[0,0];r+=2,n=e[r]<<8|e[r+1]}}var sm={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},eL=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._storage=r,this._coreTerminal=n,this._aborted=!1,this._hp=new Kk,this._header=sm,this._metrics=jf,this._isMultipart=!1,this._abortMulti=!1;let a=Math.ceil(this._opts.iipSizeLimit*4/3),c=Math.min(1048576,a);this._dec=new qk.default(4194304,a,c),this._qoiDec=new Yk.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=jf,this._hp.reset()}put(e,t,r){if(!this._aborted)if(this._hp.state===4)this._dec.put(e.subarray(t,r))!==0&&(this._dec.release(),this._aborted=!0);else{let n=this._hp.parse(e,t,r);if(n===-1){this._aborted=!0;return}if(n>0){if(this._hp.fields.type===1){if(this._isMultipart&&(this._isMultipart=!1,this._abortMulti=!1,this._dec.release()),this._header=Object.assign({},sm,this._hp.fields),!this._header.inline){this._aborted=!0;return}this._dec.init()}else if(this._abortMulti){this._aborted=!0;return}this._dec.put(e.subarray(n,r))!==0&&(this._dec.release(),this._aborted=!0,this._isMultipart&&(this._abortMulti=!0))}}}end(e){if(this._aborted||this._hp.state!==4&&this._hp.end())return!0;let t=this._hp.fields.type;if(t===3)return!0;if(t===5){let l=Wl.width,d=Wl.height;this._renderer.dimensions&&(l=this._renderer.dimensions.css.canvas.width/this._coreTerminal.cols,d=this._renderer.dimensions.css.canvas.height/this._coreTerminal.rows);let f=this._coreTerminal._core._coreBrowserService?.dpr??1,m=`\x1B]1337;ReportCellSize=${d.toFixed(3)};${l.toFixed(3)};${f.toFixed(3)}\x1B\\`;return this._coreTerminal.input(m,!1),!0}if(t===2)return this._header=Object.assign({},sm,this._hp.fields),this._isMultipart=!0,this._abortMulti=!1,this._dec.release(),this._dec.init(),!0;if(t===4&&(!this._isMultipart||(this._isMultipart=!1,this._abortMulti||this._header.type!==2)))return!0;let r=0,n=0,a;if((a=e)&&(a=!this._dec.end())&&(this._metrics=Xk(this._dec.data8),(a=this._metrics.mime!=="unsupported")&&(r=this._metrics.width,n=this._metrics.height,(a=r&&n&&r*n<this._opts.pixelLimit)&&([r,n]=this._resize(r,n).map(Math.floor),a=r&&n&&r*n<this._opts.pixelLimit))),!a)return this._dec.release(),!0;let c;if(this._metrics.mime==="image/qoi"){let l=this._qoiDec.decode(this._dec.data8);if(c=new ImageData(new Uint8ClampedArray(l.buffer,l.byteOffset,l.byteLength),this._qoiDec.width,this._qoiDec.height),this._qoiDec.release(),r===this._qoiDec.width&&n===this._qoiDec.height){this._dec.release();let d=id.createCanvas(void 0,this._qoiDec.width,this._qoiDec.height);return d.getContext("2d")?.putImageData(c,0,0),this._storage.addImage(d),!0}}else c=new Blob([this._dec.data8],{type:this._metrics.mime});return this._dec.release(),createImageBitmap(c,{resizeWidth:r,resizeHeight:n}).then(l=>(this._storage.addImage(l),!0))}_resize(e,t){let r=this._renderer.dimensions?.css.cell.width||Wl.width,n=this._renderer.dimensions?.css.cell.height||Wl.height,a=this._renderer.dimensions?.css.canvas.width||r*this._coreTerminal.cols,c=this._renderer.dimensions?.css.canvas.height||n*this._coreTerminal.rows,l=this._dim(this._header.width,a,r),d=this._dim(this._header.height,c,n);if(!l&&!d){let f=a/e,m=(c-n)/t,x=Math.min(f,m);return x<1?[e*x,t*x]:[e,t]}return l?this._header.preserveAspectRatio||!l||!d?[l,t*l/e]:[l,d]:[e*d/t,d]}_dim(e,t,r){return e==="auto"?0:e.endsWith("%")?parseInt(e.slice(0,-1),10)*t/100:e.endsWith("px")?parseInt(e.slice(0,-2),10):parseInt(e,10)*r}},tL=pd(av());function y2(e){let t={},r=e.split(",");for(let n of r){let a=n.indexOf("=");if(a===-1)continue;let c=n.substring(0,a),l=n.substring(a+1);if(c==="a"){t.action=l;continue}if(c==="o"){t.compression=l;continue}if(c==="t"){t.transmission=l;continue}if(c==="d"){t.deleteSelector=l;continue}let d=parseInt(l,10);switch(c){case"f":t.format=d;break;case"i":t.id=d;break;case"I":t.imageNumber=d;break;case"s":t.width=d;break;case"v":t.height=d;break;case"x":t.x=d;break;case"y":t.y=d;break;case"w":t.sourceWidth=d;break;case"h":t.sourceHeight=d;break;case"X":t.xOffset=d;break;case"Y":t.yOffset=d;break;case"c":t.columns=d;break;case"r":t.rows=d;break;case"m":t.more=d;break;case"q":t.quiet=d;break;case"C":t.cursorMovement=d;break;case"z":t.zIndex=d;break;case"p":t.placementId=d;break}}return t}var v2=0,rL=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._kittyStorage=r,this._coreTerminal=n,this._aborted=!1,this._decodeError=!1,this._activeDecoder=null,this._inControlData=!0,this._controlData=new Uint32Array(512),this._controlLength=0,this._encodedSizeLimit=0,this._totalEncodedSize=0,this._parsedCommand=null,this._pendingTransmissions=new Map,this._maxEncodedBytes=Math.ceil(this._opts.kittySizeLimit*4/3),this._initialEncodedBytes=Math.min(4194304,this._maxEncodedBytes)}reset(){this._cleanupAllPending(),this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),this._kittyStorage.reset()}dispose(){this.reset()}_removePendingEntry(e){this._pendingTransmissions.delete(e),this._lastPendingKey===e&&(this._lastPendingKey=void 0)}_cleanupAllPending(){for(let e of this._pendingTransmissions.values())e.decoder.release();this._pendingTransmissions.clear(),this._lastPendingKey=void 0}start(){this._aborted=!1,this._decodeError=!1,this._inControlData=!0,this._controlLength=0,this._parsedCommand=null,this._encodedSizeLimit=this._maxEncodedBytes,this._totalEncodedSize=0,this._activeDecoder=null}put(e,t,r){if(!this._aborted)if(!this._inControlData)this._streamPayload(e,t,r);else{let n=r;for(let c=t;c<r;c++)if(e[c]===59){this._inControlData=!1,n=c;break}let a=n-t;if(this._controlLength+a>512){this._aborted=!0;return}if(this._controlData.set(e.subarray(t,n),this._controlLength),this._controlLength+=a,!this._inControlData){if(this._parsedCommand=y2(this._parseControlDataString()),this._parsedCommand.id!==void 0&&this._parsedCommand.imageNumber!==void 0){this._sendResponse(this._parsedCommand.id,"EINVAL:cannot specify both i and I keys",this._parsedCommand.quiet??0),this._aborted=!0;return}if(this._parsedCommand.action==="d")return;let c=n+1;c<r&&this._streamPayload(e,c,r)}}}_streamPayload(e,t,r){if(this._aborted)return;let n=this._parsedCommand?.id??this._lastPendingKey??0,a=this._pendingTransmissions.get(n),c=a?.totalEncodedSize??0;if(this._totalEncodedSize+=r-t,c+this._totalEncodedSize>this._encodedSizeLimit){let l=this._activeDecoder??a?.decoder;l&&l.release(),this._activeDecoder=null,a&&this._removePendingEntry(n),this._aborted=!0;return}this._decodeError||(a?.decoder&&!this._activeDecoder&&(this._activeDecoder=a.decoder),this._activeDecoder||(this._activeDecoder=new tL.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,r))!==v2&&(this._activeDecoder.release(),this._activeDecoder=null,this._decodeError=!0,a&&this._removePendingEntry(n)))}end(e){if(this._aborted||!e)return this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),!0;if(this._inControlData)return this._handleNoPayloadCommand();let t=this._parsedCommand;if(t.action==="d")return this._handleDelete(t);let r=t.id??this._lastPendingKey??0,n=t.more===1,a=this._pendingTransmissions.get(r);if(n)return this._activeDecoder&&(a?(a.totalEncodedSize+=this._totalEncodedSize,a.decodeError=a.decodeError||this._decodeError):this._pendingTransmissions.set(r,{cmd:{...t},decoder:this._activeDecoder,totalEncodedSize:this._totalEncodedSize,decodeError:this._decodeError}),this._lastPendingKey=r,this._activeDecoder=null),!0;a&&(this._lastPendingKey=void 0);let c=this._decodeError,l=t,d=this._activeDecoder;a&&(l=a.cmd,d=a.decoder,c=c||a.decodeError,this._pendingTransmissions.delete(r));let f=new Uint8Array(0);d&&(d.end()!==v2&&(c=!0),f=d.data8),this._activeDecoder=null;let m=this._handleCommandWithBytesAndCmd(l,f,c);return d&&d.release(),m}_parseControlDataString(){let e="";for(let t=0;t<this._controlLength;t++)e+=String.fromCodePoint(this._controlData[t]);return e}_handleNoPayloadCommand(){let e=y2(this._parseControlDataString());if(e.id!==void 0&&e.imageNumber!==void 0)return this._sendResponse(e.id,"EINVAL:cannot specify both i and I keys",e.quiet??0),!0;switch(e.action??"t"){case"d":return this._handleDelete(e);case"q":return this._sendResponse(e.id??0,"OK",e.quiet??0),!0;case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handleCommandWithBytesAndCmd(e,t,r){switch(e.action??"t"){case"t":{let n=this._handleTransmit(e,t,r);return(e.transmission??"d")==="d"&&e.id!==void 0&&(r?this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0):t.length>0&&this._sendResponse(e.id,"OK",e.quiet??0)),n}case"T":return this._handleTransmitDisplay(e,t,r);case"q":return this._handleQuery(e,t,r);case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handlePlacement(e){if(e.id===void 0)return!0;let t=e.id,r=this._kittyStorage.getImage(t);return r?this._displayImage(r,e).then(n=>(this._sendResponse(t,n?"OK":"EINVAL:image rendering failed",e.quiet??0,e.placementId),!0)):(this._sendResponse(t,"ENOENT:image not found",e.quiet??0,e.placementId),!0)}_handleTransmit(e,t,r){return(e.transmission??"d")!=="d"?(e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported transmission medium",e.quiet??0),!0):(r||t.length===0||this._kittyStorage.storeImage(e.id,{data:new Blob([t]),width:e.width??0,height:e.height??0,format:e.format??32,compression:e.compression??""}),!0)}_handleTransmitDisplay(e,t,r){if(r)return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0),!0;this._handleTransmit(e,t,r);let n=e.id??this._kittyStorage.lastImageId,a=this._kittyStorage.getImage(n);if(a){let c=this._displayImage(a,e);return e.id!==void 0?c.then(l=>(this._sendResponse(n,l?"OK":"EINVAL:image rendering failed",e.quiet??0),!0)):c.then(()=>!0)}return!0}_handleQuery(e,t,r){let n=e.id??0,a=e.quiet??0;if((e.transmission??"d")!=="d")return this._sendResponse(n,"EINVAL:unsupported transmission medium",a),!0;if(r)return this._sendResponse(n,"EINVAL:invalid base64 data",a),!0;if(t.length===0)return this._sendResponse(n,"OK",a),!0;let c=e.format??32;if(c===100)this._sendResponse(n,"OK",a);else{let l=e.width??0,d=e.height??0;if(!l||!d)return this._sendResponse(n,"EINVAL:width and height required for raw pixel data",a),!0;let f=c===32?4:3,m=l*d*f;if(t.length<m)return this._sendResponse(n,"EINVAL:insufficient pixel data",a),!0;this._sendResponse(n,"OK",a)}return!0}_handleDelete(e){switch(e.deleteSelector??"a"){case"a":case"A":this._cleanupAllPending(),this._kittyStorage.deleteAll();break;case"i":case"I":if(e.id!==void 0){let t=this._pendingTransmissions.get(e.id);t&&t.decoder.release(),this._removePendingEntry(e.id),this._kittyStorage.deleteById(e.id)}break}return!0}_sendResponse(e,t,r,n){let a=t==="OK";if(a&&r>=1||!a&&r>=2)return;let c=n?`,p=${n}`:"",l=`\x1B_Gi=${e}${c};${t}\x1B\\`;this._coreTerminal._core.coreService.triggerDataEvent(l)}_displayImage(e,t){return this._decodeAndDisplay(e,t).then(()=>!0).catch(()=>!1)}async _decodeAndDisplay(e,t){let r=await this._createBitmap(e);try{let n=Math.max(0,t.x??0),a=Math.max(0,t.y??0),c=t.sourceWidth||r.width-n,l=t.sourceHeight||r.height-a,d=Math.max(0,r.width-n),f=Math.max(0,r.height-a),m=Math.max(0,Math.min(c,d)),x=Math.max(0,Math.min(l,f));if(m===0||x===0)throw new Error("invalid source rectangle");if(n!==0||a!==0||m!==r.width||x!==r.height){let de=await createImageBitmap(r,n,a,m,x);r.close(),r=de}let y=this._renderer.dimensions?.css.cell.width||Wl.width,w=this._renderer.dimensions?.css.cell.height||Wl.height,v,T;t.columns!==void 0&&t.rows!==void 0?(v=t.columns,T=t.rows):t.columns!==void 0?(v=t.columns,T=Math.max(1,Math.ceil(r.height/r.width*(v*y)/w))):t.rows!==void 0?(T=t.rows,v=Math.max(1,Math.ceil(r.width/r.height*(T*w)/y))):(v=Math.ceil(r.width/y),T=Math.ceil(r.height/w));let C=r.width,L=r.height;if((t.columns!==void 0||t.rows!==void 0)&&(C=Math.round(v*y),L=Math.round(T*w)),C*L>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");let N=this._coreTerminal._core.buffer,D=N.x,O=N.y,P=N.ybase,F=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(C!==r.width||L!==r.height){let de=await createImageBitmap(r,{resizeWidth:C,resizeHeight:L});r.close(),r=de}let ee=Math.min(Math.max(0,t.xOffset??0),y-1),Z=Math.min(Math.max(0,t.yOffset??0),w-1);if(ee!==0||Z!==0){let de=t.columns!==void 0?Math.round(v*y):r.width+ee,pe=t.rows!==void 0?Math.round(T*w):r.height+Z,J=id.createCanvas(window.document,de,pe),Re=J.getContext("2d");if(!Re)throw new Error("Failed to create offset canvas context");Re.drawImage(r,ee,Z);let Ze=await createImageBitmap(J);if(J.width=J.height=0,r.close(),r=Ze,C=r.width,L=r.height,C*L>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");t.columns===void 0&&(v=Math.ceil(r.width/y)),t.rows===void 0&&(T=Math.ceil(r.height/w))}let G=t.zIndex??0;if(this._kittyStorage.addImage(e.id,r,!0,F,G),r=void 0,t.cursorMovement===1){let de=N.ybase-P;N.x=D,N.y=Math.max(O-de,0)}else N.x=Math.min(D+v,this._coreTerminal.cols)}catch(n){throw r?.close(),n}}async _createBitmap(e){let t=new Uint8Array(await e.data.arrayBuffer());if(e.compression==="z"&&(t=await this._decompressZlib(t)),e.format===100){let C=new Blob([t],{type:"image/png"});if(!window.createImageBitmap){let L=URL.createObjectURL(C),N=new Image;return new Promise((D,O)=>{N.addEventListener("load",()=>{URL.revokeObjectURL(L);let P=id.createCanvas(window.document,N.width,N.height);P.getContext("2d")?.drawImage(N,0,0),createImageBitmap(P).then(D).catch(O)}),N.addEventListener("error",()=>{URL.revokeObjectURL(L),O(new Error("Failed to load image"))}),N.src=L})}return createImageBitmap(C)}let r=e.width,n=e.height;if(!r||!n)throw new Error("Width and height required for raw pixel data");let a=e.format===32?4:3,c=r*n*a;if(t.length<c)throw new Error("Insufficient pixel data");let l=r*n;if(e.format===32)return createImageBitmap(new ImageData(new Uint8ClampedArray(t.buffer,t.byteOffset,l*4),r,n));let d=new Uint8ClampedArray(l*4),f=new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),m=new Uint32Array(d.buffer),x=l&-4,y=0,w=0;for(let C=0;C<x;C+=4){let L=f[y++],N=f[y++],D=f[y++];m[w++]=4278190080|L,m[w++]=4278190080|L>>>24|N<<8,m[w++]=4278190080|N>>>16|D<<16,m[w++]=4278190080|D>>>8}let v=x*3,T=x*4;for(let C=x;C<l;C++)d[T]=t[v],d[T+1]=t[v+1],d[T+2]=t[v+2],d[T+3]=255,v+=3,T+=4;return createImageBitmap(new ImageData(d,r,n))}async _decompressZlib(e){try{return await this._decompress(e,"deflate")}catch{return await this._decompress(e,"deflate-raw")}}async _decompress(e,t){let r=new DecompressionStream(t),n=r.writable.getWriter();n.write(e),n.close();let a=[],c=r.readable.getReader();for(;;){let{done:m,value:x}=await c.read();if(m)break;a.push(x)}let l=a.reduce((m,x)=>m+x.length,0),d=new Uint8Array(l),f=0;for(let m of a)d.set(m,f),f+=m.length;return d}get images(){return this._kittyStorage.images}get _kittyIdToStorageId(){return this._kittyStorage.kittyIdToStorageId}get pendingTransmissions(){return this._pendingTransmissions}},uv=class b1{constructor(t){this._storage=t,this._nextImageId=1,this._images=new Map,this._kittyIdToStorageId=new Map,this._storageIdToKittyId=new Map,this._handleStorageImageDeleted=r=>{let n=this._storageIdToKittyId.get(r);n!==void 0&&(this._kittyIdToStorageId.delete(n),this._storageIdToKittyId.delete(r),this._images.delete(n))},this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"},this._previousOnImageDeleted=this._storage.onImageDeleted,this._wrappedOnImageDeleted=r=>{this._previousOnImageDeleted?.(r),this._handleStorageImageDeleted(r)},this._storage.onImageDeleted=this._wrappedOnImageDeleted}reset(){this._nextImageId=1,this._images.clear(),this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}dispose(){this.reset(),this._storage.onImageDeleted===this._wrappedOnImageDeleted&&(this._storage.onImageDeleted=this._previousOnImageDeleted)}storeImage(t,r){let n=t??this._nextImageId++,a=this._kittyIdToStorageId.get(n);return a!==void 0&&(this._storage.deleteImage(a),this._kittyIdToStorageId.delete(n),this._storageIdToKittyId.delete(a)),!this._images.has(n)&&this._images.size>=b1._maxStoredImages&&this._evictUndisplayedImages(),this._images.set(n,{...r,id:n}),n}addImage(t,r,n,a,c){let l=this._kittyIdToStorageId.get(t);l!==void 0&&this._storageIdToKittyId.delete(l),this._addImageOpts.scrolling=n,this._addImageOpts.layer=a,this._addImageOpts.zIndex=c;let d=this._storage.addImage(r,this._addImageOpts);this._kittyIdToStorageId.set(t,d),this._storageIdToKittyId.set(d,t)}getImage(t){return this._images.get(t)}deleteById(t){this._images.delete(t);let r=this._kittyIdToStorageId.get(t);r!==void 0&&(this._storage.deleteImage(r),this._kittyIdToStorageId.delete(t),this._storageIdToKittyId.delete(r))}deleteAll(){this._images.clear();for(let t of this._kittyIdToStorageId.values())this._storage.deleteImage(t);this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}get images(){return this._images}get kittyIdToStorageId(){return this._kittyIdToStorageId}get lastImageId(){return this._nextImageId-1}_evictUndisplayedImages(){for(let[t]of this._images){if(this._images.size<=b1._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};uv._maxStoredImages=256;var nL=uv,j0=pd(gg()),sL=pd(zk()),iL=4194304,y1=j0.PALETTE_ANSI_256;y1.set(j0.PALETTE_VT340_COLOR);var aL=class{constructor(e,t,r){this._opts=e,this._storage=t,this._coreTerminal=r,this._size=0,this._aborted=!1,(0,sL.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:y1,paletteLimit:this._opts.sixelPaletteLimit}).then(n=>this._dec=n)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,y1,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:oL(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(t,null,this._opts.sixelPaletteLimit)}}put(e,t,r){if(!(this._aborted||!this._dec)){if(this._size+=r-t,this._size>this._opts.sixelSizeLimit){console.warn("SIXEL: too much data, aborting"),this._aborted=!0,this._dec.release();return}try{this._dec.decode(e,t,r)}catch(n){console.warn(`SIXEL: error while decoding image - ${n}`),this._aborted=!0,this._dec.release()}}}unhook(e){if(this._aborted||!e||!this._dec)return!0;let t=this._dec.width,r=this._dec.height;if(!t||!r)return r&&this._storage.advanceCursor(r),!0;let n=id.createCanvas(void 0,t,r);return n.getContext("2d")?.putImageData(new ImageData(this._dec.data8,t,r),0,0),this._dec.memoryUsage>iL&&this._dec.release(),this._storage.addImage(n),!0}};function oL(e,t){let r=0;if(!t)return r;if(e.isInverse())if(e.isFgDefault())r=Th(t.foreground.rgba);else if(e.isFgRGB()){let n=e.constructor.toColorRGB(e.getFgColor());r=(0,j0.toRGBA8888)(...n)}else r=Th(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())r=Th(t.background.rgba);else if(e.isBgRGB()){let n=e.constructor.toColorRGB(e.getBgColor());r=(0,j0.toRGBA8888)(...n)}else r=Th(t.ansi[e.getBgColor()].rgba);return r}function Th(e){return j0.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var lL=class{constructor(e,t,r,n){this._storage=e,this._opts=t,this._renderer=r,this._terminal=n,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"vt340"}}addImage(e){this._addImageOpts.scrolling=this._opts.sixelScrolling,this._storage.addImage(e,this._addImageOpts)}advanceCursor(e){if(this._opts.sixelScrolling){let t=this._renderer.cellSize;(t.width===-1||t.height===-1)&&(t=Wl);let r=Math.ceil(e/t.height);for(let n=1;n<r;++n)this._terminal._core._inputHandler.lineFeed()}}},cL=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},w2={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},A2=4096,uL=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new Wk,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},w2,t),this._defaultOpts=Object.assign({},w2,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear(),this._onImageAdded.dispose()}_disposeLater(...t){for(let r of t)this._disposables.push(r)}activate(t){if(this._terminal=t,this._renderer=new id(t),this._storage=new Vk(t,this._renderer,this._opts),this._storage.onImageAdded=()=>this._onImageAdded.fire(),this._opts.enableSizeReports){let r=t.options.windowOptions??{};r.getWinSizePixels=!0,r.getCellSizePixels=!0,r.getWinSizeChars=!0,t.options.windowOptions=r}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},r=>this._decset(r)),t.parser.registerCsiHandler({prefix:"?",final:"l"},r=>this._decrst(r)),t.parser.registerCsiHandler({final:"c"},r=>this._da1(r)),t.parser.registerCsiHandler({prefix:"?",final:"S"},r=>this._xtermGraphicsAttributes(r)),t.onRender(r=>this._storage?.render(r)),t.parser.registerCsiHandler({intermediates:"!",final:"p"},()=>this.reset()),t.parser.registerEscHandler({final:"c"},()=>this.reset()),t._core._inputHandler.onRequestReset(()=>this.reset()),t.buffer.onBufferChange(()=>this._storage?.wipeAlternate()),t.onResize(r=>this._storage?.viewportResize(r))),this._opts.sixelSupport){let r=new lL(this._storage,this._opts,this._renderer,t),n=new aL(this._opts,r,t);this._handlers.set("sixel",n),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},n))}if(this._opts.iipSupport){let r=new cL(this._storage),n=new eL(this._opts,this._renderer,r,t);this._handlers.set("iip",n),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,n))}if(this._opts.kittySupport){let r=new nL(this._storage),n=new rL(this._opts,this._renderer,r,t);this._handlers.set("kitty",n),this._disposeLater(r,n,t._core._inputHandler._parser.registerApcHandler({final:"G"},n))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,r){return this._storage?.getImageAtBufferCell(t,r)}extractTileAtBufferCell(t,r){return this._storage?.extractTileAtBufferCell(t,r)}_report(t){this._terminal?._core.input(t,!1)}_decset(t){for(let r=0;r<t.length;++r)t[r]===80&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let r=0;r<t.length;++r)t[r]===80&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return t[0]?!0:this._opts.sixelSupport?(this._report("\x1B[?62;4;9;22c"),!0):!1}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(t[0]===1)switch(t[1]){case 1:return this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let r of this._handlers.values())r.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=A2?(this._opts.sixelPaletteLimit=t[2],this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`\x1B[?${t[0]};2S`),!0;case 4:return this._report(`\x1B[?${t[0]};0;${A2}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}if(t[0]===2)switch(t[1]){case 1:let r=this._renderer?.dimensions?.css.canvas.width,n=this._renderer?.dimensions?.css.canvas.height;if(!r||!n){let c=Wl;r=(this._terminal?.cols||80)*c.width,n=(this._terminal?.rows||24)*c.height}if(r*n<this._opts.pixelLimit)this._report(`\x1B[?${t[0]};0;${r.toFixed(0)};${n.toFixed(0)}S`);else{let c=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`\x1B[?${t[0]};0;${c};${c}S`)}return!0;case 4:let a=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`\x1B[?${t[0]};0;${a};${a}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}return this._report(`\x1B[?${t[0]};1S`),!0}};const Su=new Map;function Fu(e){return{name:e,get hasSubscribers(){return(Su.get(e)?.size??0)>0},publish(t){const r=Su.get(e);if(r)for(const n of r)n(t,e)},subscribe(t){const r=Su.get(e)??new Set;r.add(t),Su.set(e,r)},unsubscribe(t){const r=Su.get(e);if(!r)return!1;const n=r.delete(t);return r.size===0&&Su.delete(e),n}}}function dL(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},r={start:Fu(t.start),end:Fu(t.end),asyncStart:Fu(t.asyncStart),asyncEnd:Fu(t.asyncEnd),error:Fu(t.error),traceSync(n,a,c,...l){r.start.publish(a);try{const d=n.apply(c,l);return r.end.publish(a),d}catch(d){throw r.error.publish(d),d}},async tracePromise(n,a,c,...l){r.asyncStart.publish(a);try{const d=await n.apply(c,l);return r.asyncEnd.publish(a),d}catch(d){throw r.error.publish(d),d}},traceCallback(n,a,c,l,...d){r.start.publish(c);try{const f=n.apply(l,d);return r.end.publish(c),f}catch(f){throw r.error.publish(f),f}}};return r}var hL=Object.create,xg=Object.defineProperty,fL=Object.getOwnPropertyDescriptor,pL=Object.getOwnPropertyNames,mL=Object.getPrototypeOf,gL=Object.prototype.hasOwnProperty,dv=e=>{throw TypeError(e)},xL=(e,t,r)=>t in e?xg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bL=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},yL=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pL(t))!gL.call(e,a)&&a!==r&&xg(e,a,{get:()=>t[a],enumerable:!(n=fL(t,a))||n.enumerable});return e},vL=(e,t,r)=>(r=e!=null?hL(mL(e)):{},yL(!e||!e.__esModule?xg(r,"default",{value:e,enumerable:!0}):r,e)),ai=(e,t,r)=>xL(e,typeof t!="symbol"?t+"":t,r),bg=(e,t,r)=>t.has(e)||dv("Cannot "+r),oe=(e,t,r)=>(bg(e,t,"read from private field"),r?r.call(e):t.get(e)),_n=(e,t,r)=>t.has(e)?dv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Br=(e,t,r,n)=>(bg(e,t,"write to private field"),t.set(e,r),r),Yt=(e,t,r)=>(bg(e,t,"access private method"),r),im=(e,t,r,n)=>({set _(a){Br(e,t,a)},get _(){return oe(e,t,n)}}),wL=bL((e,t)=>{var r=(()=>{var n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,d=(i,o)=>{for(var u in o)n(i,u,{get:o[u],enumerable:!0})},f=(i,o,u,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of c(o))!l.call(i,p)&&p!==u&&n(i,p,{get:()=>o[p],enumerable:!(h=a(o,p))||h.enumerable});return i},m=i=>f(n({},"__esModule",{value:!0}),i),x={};d(x,{BoundingBox:()=>se,Font:()=>yx,Glyph:()=>xr,Path:()=>ze,_parse:()=>st,load:()=>u8,loadSync:()=>d8,parse:()=>c8});var y=0,w=-3;function v(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function T(i,o){this.source=i,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=o,this.destLen=0,this.ltree=new v,this.dtree=new v}var C=new v,L=new v,N=new Uint8Array(30),D=new Uint16Array(30),O=new Uint8Array(30),P=new Uint16Array(30),F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ee=new v,Z=new Uint8Array(320);function G(i,o,u,h){var p,g;for(p=0;p<u;++p)i[p]=0;for(p=0;p<30-u;++p)i[p+u]=p/u|0;for(g=h,p=0;p<30;++p)o[p]=g,g+=1<<i[p]}function de(i,o){var u;for(u=0;u<7;++u)i.table[u]=0;for(i.table[7]=24,i.table[8]=152,i.table[9]=112,u=0;u<24;++u)i.trans[u]=256+u;for(u=0;u<144;++u)i.trans[24+u]=u;for(u=0;u<8;++u)i.trans[168+u]=280+u;for(u=0;u<112;++u)i.trans[176+u]=144+u;for(u=0;u<5;++u)o.table[u]=0;for(o.table[5]=32,u=0;u<32;++u)o.trans[u]=u}var pe=new Uint16Array(16);function J(i,o,u,h){var p,g;for(p=0;p<16;++p)i.table[p]=0;for(p=0;p<h;++p)i.table[o[u+p]]++;for(i.table[0]=0,g=0,p=0;p<16;++p)pe[p]=g,g+=i.table[p];for(p=0;p<h;++p)o[u+p]&&(i.trans[pe[o[u+p]]++]=p)}function Re(i){i.bitcount--||(i.tag=i.source[i.sourceIndex++],i.bitcount=7);var o=i.tag&1;return i.tag>>>=1,o}function Ze(i,o,u){if(!o)return u;for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var h=i.tag&65535>>>16-o;return i.tag>>>=o,i.bitcount-=o,h+u}function V(i,o){for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var u=0,h=0,p=0,g=i.tag;do h=2*h+(g&1),g>>>=1,++p,u+=o.table[p],h-=o.table[p];while(h>=0);return i.tag=g,i.bitcount-=p,o.trans[u+h]}function ve(i,o,u){var h,p,g,A,k,E;for(h=Ze(i,5,257),p=Ze(i,5,1),g=Ze(i,4,4),A=0;A<19;++A)Z[A]=0;for(A=0;A<g;++A){var j=Ze(i,3,0);Z[F[A]]=j}for(J(ee,Z,0,19),k=0;k<h+p;){var M=V(i,ee);switch(M){case 16:var re=Z[k-1];for(E=Ze(i,2,3);E;--E)Z[k++]=re;break;case 17:for(E=Ze(i,3,3);E;--E)Z[k++]=0;break;case 18:for(E=Ze(i,7,11);E;--E)Z[k++]=0;break;default:Z[k++]=M;break}}J(o,Z,0,h),J(u,Z,h,p)}function qe(i,o,u){for(;;){var h=V(i,o);if(h===256)return y;if(h<256)i.dest[i.destLen++]=h;else{var p,g,A,k;for(h-=257,p=Ze(i,N[h],D[h]),g=V(i,u),A=i.destLen-Ze(i,O[g],P[g]),k=A;k<A+p;++k)i.dest[i.destLen++]=i.dest[k]}}}function le(i){for(var o,u,h;i.bitcount>8;)i.sourceIndex--,i.bitcount-=8;if(o=i.source[i.sourceIndex+1],o=256*o+i.source[i.sourceIndex],u=i.source[i.sourceIndex+3],u=256*u+i.source[i.sourceIndex+2],o!==(~u&65535))return w;for(i.sourceIndex+=4,h=o;h;--h)i.dest[i.destLen++]=i.source[i.sourceIndex++];return i.bitcount=0,y}function ye(i,o){var u=new T(i,o),h,p,g;do{switch(h=Re(u),p=Ze(u,2,0),p){case 0:g=le(u);break;case 1:g=qe(u,C,L);break;case 2:ve(u,u.ltree,u.dtree),g=qe(u,u.ltree,u.dtree);break;default:g=w}if(g!==y)throw new Error("Data error")}while(!h);return u.destLen<u.dest.length?typeof u.dest.slice=="function"?u.dest.slice(0,u.destLen):u.dest.subarray(0,u.destLen):u.dest}de(C,L),G(N,D,4,3),G(O,P,2,1),N[28]=0,D[28]=258;function Te(i,o,u,h,p){return Math.pow(1-p,3)*i+3*Math.pow(1-p,2)*p*o+3*(1-p)*Math.pow(p,2)*u+Math.pow(p,3)*h}function Fe(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Fe.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Fe.prototype.addPoint=function(i,o){typeof i=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),i<this.x1&&(this.x1=i),i>this.x2&&(this.x2=i)),typeof o=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=o,this.y2=o),o<this.y1&&(this.y1=o),o>this.y2&&(this.y2=o))},Fe.prototype.addX=function(i){this.addPoint(i,null)},Fe.prototype.addY=function(i){this.addPoint(null,i)},Fe.prototype.addBezier=function(i,o,u,h,p,g,A,k){let E=[i,o],j=[u,h],M=[p,g],re=[A,k];this.addPoint(i,o),this.addPoint(A,k);for(let te=0;te<=1;te++){let Ae=6*E[te]-12*j[te]+6*M[te],fe=-3*E[te]+9*j[te]-9*M[te]+3*re[te],je=3*j[te]-3*E[te];if(fe===0){if(Ae===0)continue;let Pr=-je/Ae;0<Pr&&Pr<1&&(te===0&&this.addX(Te(E[te],j[te],M[te],re[te],Pr)),te===1&&this.addY(Te(E[te],j[te],M[te],re[te],Pr)));continue}let pt=Math.pow(Ae,2)-4*je*fe;if(pt<0)continue;let Tr=(-Ae+Math.sqrt(pt))/(2*fe);0<Tr&&Tr<1&&(te===0&&this.addX(Te(E[te],j[te],M[te],re[te],Tr)),te===1&&this.addY(Te(E[te],j[te],M[te],re[te],Tr)));let fr=(-Ae-Math.sqrt(pt))/(2*fe);0<fr&&fr<1&&(te===0&&this.addX(Te(E[te],j[te],M[te],re[te],fr)),te===1&&this.addY(Te(E[te],j[te],M[te],re[te],fr)))}},Fe.prototype.addQuad=function(i,o,u,h,p,g){let A=i+.6666666666666666*(u-i),k=o+2/3*(h-o),E=A+1/3*(p-i),j=k+1/3*(g-o);this.addBezier(i,o,A,k,E,j,p,g)};var se=Fe;function De(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var _e={};function Me(i,o){let u=Math.floor(i),h=i-u;if(_e[o]||(_e[o]={}),_e[o][h]!==void 0){let g=_e[o][h];return u+g}let p=+(Math.round(h+"e+"+o)+"e-"+o);return _e[o][h]=p,u+p}function Ke(i){let o=[[]],u=0,h=0;for(let p=0;p<i.length;p+=1){let g=o[o.length-1],A=i[p],k=g[0],E=g[1],j=g[g.length-1],M=i[p+1];g.push(A),A.type==="M"?(u=A.x,h=A.y):A.type==="L"&&(!M||M.type==="Z")?Math.abs(A.x-u)>1||Math.abs(A.y-h)>1||g.pop():A.type==="L"&&j&&j.x===A.x&&j.y===A.y?g.pop():A.type==="Z"&&(k&&E&&j&&k.type==="M"&&E.type==="L"&&j.type==="L"&&j.x===k.x&&j.y===k.y&&(g.shift(),g[0].type="M"),p+1<i.length&&o.push([]))}return i=[].concat.apply([],o),i}function Ne(i){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},i)}function ae(i){return parseInt(i)===i&&(i={decimalPlaces:i,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},i)}De.prototype.fromSVG=function(i,o={}){typeof SVGPathElement<"u"&&i instanceof SVGPathElement&&(i=i.getAttribute("d")),o=Ne(o),this.commands=[];let u="0123456789",h="MmLlQqCcZzHhVv",p="SsTtAa",g="-+",A={},k=[""],E=!1;function j(fe){return fe.filter(je=>je.length).map(je=>{let pt=parseFloat(je);return(o.decimalPlaces||o.decimalPlaces===0)&&(pt=Me(pt,o.decimalPlaces)),pt})}function M(fe){if(!this.commands.length)return fe;let je=this.commands[this.commands.length-1];for(let pt=0;pt<fe.length;pt++)fe[pt]+=je[pt&1?"y":"x"];return fe}function re(){if(A.type===void 0)return;let fe=A.type.toUpperCase(),je=fe!=="Z"&&A.type.toUpperCase()!==A.type,pt=j(k);if(k=[""],!pt.length&&fe!=="Z")return;je&&fe!=="H"&&fe!=="V"&&(pt=M.apply(this,[pt]));let Tr=this.commands.length&&this.commands[this.commands.length-1].x||0,fr=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(fe){case"M":this.moveTo(...pt);break;case"L":this.lineTo(...pt);break;case"V":for(let Pr=0;Pr<pt.length;Pr++){let cn=0;je&&(cn=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(Tr,pt[Pr]+cn)}break;case"H":for(let Pr=0;Pr<pt.length;Pr++){let cn=0;je&&(cn=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(pt[Pr]+cn,fr)}break;case"C":this.bezierCurveTo(...pt);break;case"Q":this.quadraticCurveTo(...pt);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let Pr in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Pr]===void 0&&(this.commands[this.commands.length-1][Pr]=0)}for(let fe=0;fe<i.length;fe++){let je=i.charAt(fe),pt=k[k.length-1];if(u.indexOf(je)>-1)k[k.length-1]+=je;else if(g.indexOf(je)>-1)if(!A.type&&!this.commands.length&&(A.type="L"),je==="-")!A.type||pt.indexOf("-")>0?E=!0:pt.length?k.push("-"):k[k.length-1]=je;else if(!A.type||pt.length>0)E=!0;else continue;else if(h.indexOf(je)>-1)A.type?(re.apply(this),A={type:je}):A.type=je;else{if(p.indexOf(je)>-1)throw new Error("Unsupported path command: "+je+". Currently supported commands are "+h.split("").join(", ")+".");` ,
69
+ \r\f\v`.indexOf(je)>-1?k.push(""):je==="."?!A.type||pt.indexOf(je)>-1?E=!0:k[k.length-1]+=je:E=!0}if(E)throw new Error("Unexpected character: "+je+" at offset "+fe)}re.apply(this),o.optimize&&(this.commands=Ke(this.commands));let te=o.flipY,Ae=o.flipYBase;if(te===!0&&o.flipYBase===void 0){let fe=this.getBoundingBox();Ae=fe.y1+fe.y2}for(let fe in this.commands){let je=this.commands[fe];for(let pt in je)["x","x1","x2"].includes(pt)?this.commands[fe][pt]=o.x+je[pt]*o.scale:["y","y1","y2"].includes(pt)&&(this.commands[fe][pt]=o.y+(te?Ae-je[pt]:je[pt])*o.scale)}return this},De.fromSVG=function(i,o){return new De().fromSVG(i,o)},De.prototype.moveTo=function(i,o){this.commands.push({type:"M",x:i,y:o})},De.prototype.lineTo=function(i,o){this.commands.push({type:"L",x:i,y:o})},De.prototype.curveTo=De.prototype.bezierCurveTo=function(i,o,u,h,p,g){this.commands.push({type:"C",x1:i,y1:o,x2:u,y2:h,x:p,y:g})},De.prototype.quadTo=De.prototype.quadraticCurveTo=function(i,o,u,h){this.commands.push({type:"Q",x1:i,y1:o,x:u,y:h})},De.prototype.close=De.prototype.closePath=function(){this.commands.push({type:"Z"})},De.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof se){let o=i;this.moveTo(o.x1,o.y1),this.lineTo(o.x2,o.y1),this.lineTo(o.x2,o.y2),this.lineTo(o.x1,o.y2),this.close();return}Array.prototype.push.apply(this.commands,i)},De.prototype.getBoundingBox=function(){let i=new se,o=0,u=0,h=0,p=0;for(let g=0;g<this.commands.length;g++){let A=this.commands[g];switch(A.type){case"M":i.addPoint(A.x,A.y),o=h=A.x,u=p=A.y;break;case"L":i.addPoint(A.x,A.y),h=A.x,p=A.y;break;case"Q":i.addQuad(h,p,A.x1,A.y1,A.x,A.y),h=A.x,p=A.y;break;case"C":i.addBezier(h,p,A.x1,A.y1,A.x2,A.y2,A.x,A.y),h=A.x,p=A.y;break;case"Z":h=o,p=u;break;default:throw new Error("Unexpected path command "+A.type)}}return i.isEmpty()&&i.addPoint(0,0),i},De.prototype.draw=function(i){let o=this._layers;if(o&&o.length){for(let h=0;h<o.length;h++)this.draw.call(o[h],i);return}let u=this._image;if(u){i.drawImage(u.image,u.x,u.y,u.width,u.height);return}i.beginPath();for(let h=0;h<this.commands.length;h+=1){let p=this.commands[h];p.type==="M"?i.moveTo(p.x,p.y):p.type==="L"?i.lineTo(p.x,p.y):p.type==="C"?i.bezierCurveTo(p.x1,p.y1,p.x2,p.y2,p.x,p.y):p.type==="Q"?i.quadraticCurveTo(p.x1,p.y1,p.x,p.y):p.type==="Z"&&this.stroke&&this.strokeWidth&&i.closePath()}this.fill&&(i.fillStyle=this.fill,i.fill()),this.stroke&&(i.strokeStyle=this.stroke,i.lineWidth=this.strokeWidth,i.stroke())},De.prototype.toPathData=function(i){i=ae(i);function o(k){let E=Me(k,i.decimalPlaces);return Math.round(k)===E?""+E:E.toFixed(i.decimalPlaces)}function u(){let k="";for(let E=0;E<arguments.length;E+=1){let j=arguments[E];j>=0&&E>0&&(k+=" "),k+=o(j)}return k}let h=this.commands;i.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=Ke(h));let p=i.flipY,g=i.flipYBase;if(p===!0&&g===void 0){let k=new De;k.extend(h);let E=k.getBoundingBox();g=E.y1+E.y2}let A="";for(let k=0;k<h.length;k+=1){let E=h[k];E.type==="M"?A+="M"+u(E.x,p?g-E.y:E.y):E.type==="L"?A+="L"+u(E.x,p?g-E.y:E.y):E.type==="C"?A+="C"+u(E.x1,p?g-E.y1:E.y1,E.x2,p?g-E.y2:E.y2,E.x,p?g-E.y:E.y):E.type==="Q"?A+="Q"+u(E.x1,p?g-E.y1:E.y1,E.x,p?g-E.y:E.y):E.type==="Z"&&(A+="Z")}return A},De.prototype.toSVG=function(i,o){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),o||(o=this.toPathData(i));let u='<path d="';return u+=o,u+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u+=' fill="none"':u+=' fill="'+this.fill+'"'),this.stroke&&(u+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),u+="/>",u},De.prototype.toDOMElement=function(i,o){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),o||(o=this.toPathData(i));let u=document.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",o),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u.setAttribute("fill","none"):u.setAttribute("fill",this.fill)),this.stroke&&(u.setAttribute("stroke",this.stroke),u.setAttribute("stroke-width",this.strokeWidth)),u};var ze=De;function at(i){throw new Error(i)}function ct(i,o){i||at(o)}var me={fail:at,argument:ct,assert:ct},ut=32768,ft=2147483648,Se=-32768,He=32767+1/65536,ke={},z={},ie={};function ge(i){return function(){return i}}z.BYTE=function(i){return me.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},ie.BYTE=ge(1),z.CHAR=function(i){return[i.charCodeAt(0)]},ie.CHAR=ge(1),z.CHARARRAY=function(i){(i===null||typeof i>"u")&&(i="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let o=[];for(let u=0;u<i.length;u+=1)o[u]=i.charCodeAt(u);return o},ie.CHARARRAY=function(i){return typeof i>"u"?0:i.length},z.USHORT=function(i){return[i>>8&255,i&255]},ie.USHORT=ge(2),z.SHORT=function(i){return i>=ut&&(i=-(2*ut-i)),[i>>8&255,i&255]},ie.SHORT=ge(2),z.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},ie.UINT24=ge(3),z.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},ie.ULONG=ge(4),z.LONG=function(i){return i>=ft&&(i=-(2*ft-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},ie.LONG=ge(4),z.FLOAT=function(i){if(i>He||i<Se)throw new Error(`Value ${i} is outside the range of representable values in 16.16 format`);let o=Math.round(i*65536)<<0;return z.ULONG(o)},ie.FLOAT=ie.ULONG,z.FIXED=z.ULONG,ie.FIXED=ie.ULONG,z.FWORD=z.SHORT,ie.FWORD=ie.SHORT,z.UFWORD=z.USHORT,ie.UFWORD=ie.USHORT,z.F2DOT14=function(i){return z.USHORT(i*16384)},ie.F2DOT14=ie.USHORT,z.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},ie.LONGDATETIME=ge(8),z.TAG=function(i){return me.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},ie.TAG=ge(4),z.Card8=z.BYTE,ie.Card8=ie.BYTE,z.Card16=z.USHORT,ie.Card16=ie.USHORT,z.OffSize=z.BYTE,ie.OffSize=ie.BYTE,z.SID=z.USHORT,ie.SID=ie.USHORT,z.NUMBER=function(i){return i>=-107&&i<=107?[i+139]:i>=108&&i<=1131?(i=i-108,[(i>>8)+247,i&255]):i>=-1131&&i<=-108?(i=-i-108,[(i>>8)+251,i&255]):i>=-32768&&i<=32767?z.NUMBER16(i):z.NUMBER32(i)},ie.NUMBER=function(i){return z.NUMBER(i).length},z.NUMBER16=function(i){return[28,i>>8&255,i&255]},ie.NUMBER16=ge(3),z.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},ie.NUMBER32=ge(5),z.REAL=function(i){let o=i.toString(),u=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(o);if(u){let g=parseFloat("1e"+((u[2]?+u[2]:0)+u[1].length));o=(Math.round(i*g)/g).toString()}let h="";for(let g=0,A=o.length;g<A;g+=1){let k=o[g];k==="e"?h+=o[++g]==="-"?"c":"b":k==="."?h+="a":k==="-"?h+="e":h+=k}h+=h.length&1?"f":"ff";let p=[30];for(let g=0,A=h.length;g<A;g+=2)p.push(parseInt(h.substr(g,2),16));return p},ie.REAL=function(i){return z.REAL(i).length},z.NAME=z.CHARARRAY,ie.NAME=ie.CHARARRAY,z.STRING=z.CHARARRAY,ie.STRING=ie.CHARARRAY,ke.UTF8=function(i,o,u){let h=[],p=u;for(let g=0;g<p;g++,o+=1)h[g]=i.getUint8(o);return String.fromCharCode.apply(null,h)},ke.UTF16=function(i,o,u){let h=[],p=u/2;for(let g=0;g<p;g++,o+=2)h[g]=i.getUint16(o);return String.fromCharCode.apply(null,h)},z.UTF16=function(i){let o=[];for(let u=0;u<i.length;u+=1){let h=i.charCodeAt(u);o[o.length]=h>>8&255,o[o.length]=h&255}return o},ie.UTF16=function(i){return i.length*2};var We={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};ke.MACSTRING=function(i,o,u,h){let p=We[h];if(p===void 0)return;let g="";for(let A=0;A<u;A++){let k=i.getUint8(o+A);k<=127?g+=String.fromCharCode(k):g+=p[k&127]}return g};var tt=typeof WeakMap=="function"&&new WeakMap,wt,Zt=function(i){if(!wt){wt={};for(let p in We)wt[p]=new String(p)}let o=wt[i];if(o===void 0)return;if(tt){let p=tt.get(o);if(p!==void 0)return p}let u=We[i];if(u===void 0)return;let h={};for(let p=0;p<u.length;p++)h[u.charCodeAt(p)]=p+128;return tt&&tt.set(o,h),h};z.MACSTRING=function(i,o){let u=Zt(o);if(u===void 0)return;let h=[];for(let p=0;p<i.length;p++){let g=i.charCodeAt(p);if(g>=128&&(g=u[g],g===void 0))return;h[p]=g}return h},ie.MACSTRING=function(i,o){let u=z.MACSTRING(i,o);return u!==void 0?u.length:0};function Ut(i){return i>=-128&&i<=127}function Mt(i,o,u){let h=0,p=i.length;for(;o<p&&h<64&&i[o]===0;)++o,++h;return u.push(128|h-1),o}function nr(i,o,u){let h=0,p=i.length,g=o;for(;g<p&&h<64;){let A=i[g];if(!Ut(A)||A===0&&g+1<p&&i[g+1]===0)break;++g,++h}u.push(h-1);for(let A=o;A<g;++A)u.push(i[A]+256&255);return g}function jt(i,o,u){let h=0,p=i.length,g=o;for(;g<p&&h<64;){let A=i[g];if(A===0||Ut(A)&&g+1<p&&Ut(i[g+1]))break;++g,++h}u.push(64|h-1);for(let A=o;A<g;++A){let k=i[A];u.push(k+65536>>8&255,k+256&255)}return g}z.VARDELTAS=function(i){let o=0,u=[];for(;o<i.length;){let h=i[o];h===0?o=Mt(i,o,u):h>=-128&&h<=127?o=nr(i,o,u):o=jt(i,o,u)}return u},z.INDEX=function(i){let o=1,u=[o],h=[];for(let k=0;k<i.length;k+=1){let E=z.OBJECT(i[k]);Array.prototype.push.apply(h,E),o+=E.length,u.push(o)}if(h.length===0)return[0,0];let p=[],g=1+Math.floor(Math.log(o)/Math.log(2))/8|0,A=[void 0,z.BYTE,z.USHORT,z.UINT24,z.ULONG][g];for(let k=0;k<u.length;k+=1){let E=A(u[k]);Array.prototype.push.apply(p,E)}return Array.prototype.concat(z.Card16(i.length),z.OffSize(g),p,h)},ie.INDEX=function(i){return z.INDEX(i).length},z.DICT=function(i){let o=[],u=Object.keys(i),h=u.length;for(let p=0;p<h;p+=1){let g=parseInt(u[p],0),A=i[g],k=z.OPERAND(A.value,A.type),E=z.OPERATOR(g);for(let j=0;j<k.length;j++)o.push(k[j]);for(let j=0;j<E.length;j++)o.push(E[j])}return o},ie.DICT=function(i){return z.DICT(i).length},z.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},z.OPERAND=function(i,o){let u=[];if(Array.isArray(o))for(let h=0;h<o.length;h+=1){me.argument(i.length===o.length,"Not enough arguments given for type"+o);let p=z.OPERAND(i[h],o[h]);for(let g=0;g<p.length;g++)u.push(p[g])}else if(o==="SID"){let h=z.NUMBER(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="offset"){let h=z.NUMBER32(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="number"){let h=z.NUMBER(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="real"){let h=z.REAL(i);for(let p=0;p<h.length;p++)u.push(h[p])}else throw new Error("Unknown operand type "+o);return u},z.OP=z.BYTE,ie.OP=ie.BYTE;var Xt=typeof WeakMap=="function"&&new WeakMap;z.CHARSTRING=function(i){if(Xt){let h=Xt.get(i);if(h!==void 0)return h}let o=[],u=i.length;for(let h=0;h<u;h+=1){let p=i[h],g=z[p.type](p.value);for(let A=0;A<g.length;A++)o.push(g[A])}return Xt&&Xt.set(i,o),o},ie.CHARSTRING=function(i){return z.CHARSTRING(i).length},z.OBJECT=function(i){let o=z[i.type];return me.argument(o!==void 0,"No encoding function for type "+i.type),o(i.value)},ie.OBJECT=function(i){let o=ie[i.type];return me.argument(o!==void 0,"No sizeOf function for type "+i.type),o(i.value)},z.TABLE=function(i){let o=[],u=(i.fields||[]).length,h=[],p=[];for(let g=0;g<u;g+=1){let A=i.fields[g],k=z[A.type];me.argument(k!==void 0,"No encoding function for field type "+A.type+" ("+A.name+")");let E=i[A.name];E===void 0&&(E=A.value);let j=k(E);if(A.type==="TABLE")E.fields!==null&&(p.push(o.length),h.push(j)),o.push(0,0);else for(let M=0;M<j.length;M++)o.push(j[M])}for(let g=0;g<h.length;g+=1){let A=p[g],k=o.length;me.argument(k<65536,"Table "+i.tableName+" too big."),o[A]=k>>8,o[A+1]=k&255;for(let E=0;E<h[g].length;E++)o.push(h[g][E])}return o},ie.TABLE=function(i){let o=0,u=(i.fields||[]).length;for(let h=0;h<u;h+=1){let p=i.fields[h],g=ie[p.type];me.argument(g!==void 0,"No sizeOf function for field type "+p.type+" ("+p.name+")");let A=i[p.name];A===void 0&&(A=p.value),o+=g(A),p.type==="TABLE"&&(o+=2)}return o},z.RECORD=z.TABLE,ie.RECORD=ie.TABLE,z.LITERAL=function(i){return i},ie.LITERAL=function(i){return i.length};function Bt(i,o,u){if(o&&o.length)for(let h=0;h<o.length;h+=1){let p=o[h];this[p.name]=p.value}if(this.tableName=i,this.fields=o,u){let h=Object.keys(u);for(let p=0;p<h.length;p+=1){let g=h[p],A=u[g];this[g]!==void 0&&(this[g]=A)}}}Bt.prototype.encode=function(){return z.TABLE(this)},Bt.prototype.sizeOf=function(){return ie.TABLE(this)};function Ht(i,o,u){u===void 0&&(u=o.length);let h=new Array(o.length+1);h[0]={name:i+"Count",type:"USHORT",value:u};for(let p=0;p<o.length;p++)h[p+1]={name:i+p,type:"USHORT",value:o[p]};return h}function xe(i,o,u){let h=o.length,p=new Array(h+1);p[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)p[g+1]={name:i+g,type:"TABLE",value:u(o[g],g)};return p}function Je(i,o,u){let h=o.length,p=[];p[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)p=p.concat(u(o[g],g));return p}function ot(i){i.format===1?Bt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Ht("glyph",i.glyphs))):i.format===2?Bt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Je("rangeRecord",i.ranges,function(o,u){return[{name:"startGlyphID"+u,type:"USHORT",value:o.start},{name:"endGlyphID"+u,type:"USHORT",value:o.end},{name:"startCoverageIndex"+u,type:"USHORT",value:o.index}]}))):me.assert(!1,"Coverage format must be 1 or 2.")}ot.prototype=Object.create(Bt.prototype),ot.prototype.constructor=ot;function Nt(i){Bt.call(this,"scriptListTable",Je("scriptRecord",i,function(o,u){let h=o.script,p=h.defaultLangSys;return me.assert(!!p,"Unable to write GSUB: script "+o.tag+" has no default language system."),[{name:"scriptTag"+u,type:"TAG",value:o.tag},{name:"script"+u,type:"TABLE",value:new Bt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Bt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:p.reqFeatureIndex}].concat(Ht("featureIndex",p.featureIndexes)))}].concat(Je("langSys",h.langSysRecords,function(g,A){let k=g.langSys;return[{name:"langSysTag"+A,type:"TAG",value:g.tag},{name:"langSys"+A,type:"TABLE",value:new Bt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:k.reqFeatureIndex}].concat(Ht("featureIndex",k.featureIndexes)))}]})))}]}))}Nt.prototype=Object.create(Bt.prototype),Nt.prototype.constructor=Nt;function K(i){Bt.call(this,"featureListTable",Je("featureRecord",i,function(o,u){let h=o.feature;return[{name:"featureTag"+u,type:"TAG",value:o.tag},{name:"feature"+u,type:"TABLE",value:new Bt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Ht("lookupListIndex",h.lookupListIndexes)))}]}))}K.prototype=Object.create(Bt.prototype),K.prototype.constructor=K;function xt(i,o){Bt.call(this,"lookupListTable",xe("lookup",i,function(u){let h=o[u.lookupType];return me.assert(!!h,"Unable to write GSUB lookup type "+u.lookupType+" tables."),new Bt("lookupTable",[{name:"lookupType",type:"USHORT",value:u.lookupType},{name:"lookupFlag",type:"USHORT",value:u.lookupFlag}].concat(xe("subtable",u.subtables,h)))}))}xt.prototype=Object.create(Bt.prototype),xt.prototype.constructor=xt;function tr(i){i.format===1?Bt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:i.startGlyph}].concat(Ht("glyph",i.classes))):i.format===2?Bt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Je("rangeRecord",i.ranges,function(o,u){return[{name:"startGlyphID"+u,type:"USHORT",value:o.start},{name:"endGlyphID"+u,type:"USHORT",value:o.end},{name:"class"+u,type:"USHORT",value:o.classId}]}))):me.assert(!1,"Class format must be 1 or 2.")}tr.prototype=Object.create(Bt.prototype),tr.prototype.constructor=tr;var $e={Table:Bt,Record:Bt,Coverage:ot,ClassDef:tr,ScriptList:Nt,FeatureList:K,LookupList:xt,ushortList:Ht,tableList:xe,recordList:Je};function Qr(i,o){return i.getUint8(o)}function Ce(i,o){return i.getUint16(o,!1)}function St(i,o){return i.getInt16(o,!1)}function Ot(i,o){return(i.getUint16(o)<<8)+i.getUint8(o+2)}function Jt(i,o){return i.getUint32(o,!1)}function lt(i,o){return i.getInt32(o,!1)}function Ct(i,o){let u=i.getInt16(o,!1),h=i.getUint16(o+2,!1);return u+h/65535}function ar(i,o){let u="";for(let h=o;h<o+4;h+=1)u+=String.fromCharCode(i.getInt8(h));return u}function _r(i,o,u){let h=0;for(let p=0;p<u;p+=1)h<<=8,h+=i.getUint8(o+p);return h}function Nr(i,o,u){let h=[];for(let p=o;p<u;p+=1)h.push(i.getUint8(p));return h}function zr(i){let o="";for(let u=0;u<i.length;u+=1)o+=String.fromCharCode(i[u]);return o}var Tt={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},Ft={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function we(i,o){this.data=i,this.offset=o,this.relativeOffset=0}we.prototype.parseByte=function(){let i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},we.prototype.parseChar=function(){let i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},we.prototype.parseCard8=we.prototype.parseByte,we.prototype.parseUShort=function(){let i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},we.prototype.parseCard16=we.prototype.parseUShort,we.prototype.parseSID=we.prototype.parseUShort,we.prototype.parseOffset16=we.prototype.parseUShort,we.prototype.parseShort=function(){let i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},we.prototype.parseF2Dot14=function(){let i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},we.prototype.parseUInt24=function(){let i=Ot(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,i},we.prototype.parseULong=function(){let i=Jt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},we.prototype.parseLong=function(){let i=lt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},we.prototype.parseOffset32=we.prototype.parseULong,we.prototype.parseFixed=function(){let i=Ct(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},we.prototype.parseString=function(i){let o=this.data,u=this.offset+this.relativeOffset,h="";this.relativeOffset+=i;for(let p=0;p<i;p++)h+=String.fromCharCode(o.getUint8(u+p));return h},we.prototype.parseTag=function(){return this.parseString(4)},we.prototype.parseLongDateTime=function(){let i=Jt(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},we.prototype.parseVersion=function(i){let o=Ce(this.data,this.offset+this.relativeOffset),u=Ce(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),o+u/i/10},we.prototype.skip=function(i,o){o===void 0&&(o=1),this.relativeOffset+=Tt[i]*o},we.prototype.parseULongList=function(i){i===void 0&&(i=this.parseULong());let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let p=0;p<i;p++)o[p]=u.getUint32(h),h+=4;return this.relativeOffset+=i*4,o},we.prototype.parseOffset16List=we.prototype.parseUShortList=function(i){i===void 0&&(i=this.parseUShort());let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let p=0;p<i;p++)o[p]=u.getUint16(h),h+=2;return this.relativeOffset+=i*2,o},we.prototype.parseShortList=function(i){let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let p=0;p<i;p++)o[p]=u.getInt16(h),h+=2;return this.relativeOffset+=i*2,o},we.prototype.parseByteList=function(i){let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let p=0;p<i;p++)o[p]=u.getUint8(h++);return this.relativeOffset+=i,o},we.prototype.parseList=function(i,o){o||(o=i,i=this.parseUShort());let u=new Array(i);for(let h=0;h<i;h++)u[h]=o.call(this);return u},we.prototype.parseList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i);for(let h=0;h<i;h++)u[h]=o.call(this);return u},we.prototype.parseRecordList=function(i,o){o||(o=i,i=this.parseUShort());let u=new Array(i),h=Object.keys(o);for(let p=0;p<i;p++){let g={};for(let A=0;A<h.length;A++){let k=h[A],E=o[k];g[k]=E.call(this)}u[p]=g}return u},we.prototype.parseRecordList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i),h=Object.keys(o);for(let p=0;p<i;p++){let g={};for(let A=0;A<h.length;A++){let k=h[A],E=o[k];g[k]=E.call(this)}u[p]=g}return u},we.prototype.parseTupleRecords=function(i,o){let u=[];for(let h=0;h<i;h++){let p=[];for(let g=0;g<o;g++)p.push(this.parseF2Dot14());u.push(p)}return u},we.prototype.parseStruct=function(i){if(typeof i=="function")return i.call(this);{let o=Object.keys(i),u={};for(let h=0;h<o.length;h++){let p=o[h],g=i[p];u[p]=g.call(this)}return u}},we.prototype.parseValueRecord=function(i){if(i===void 0&&(i=this.parseUShort()),i===0)return;let o={};return i&1&&(o.xPlacement=this.parseShort()),i&2&&(o.yPlacement=this.parseShort()),i&4&&(o.xAdvance=this.parseShort()),i&8&&(o.yAdvance=this.parseShort()),i&16&&(o.xPlaDevice=void 0,this.parseShort()),i&32&&(o.yPlaDevice=void 0,this.parseShort()),i&64&&(o.xAdvDevice=void 0,this.parseShort()),i&128&&(o.yAdvDevice=void 0,this.parseShort()),o},we.prototype.parseValueRecordList=function(){let i=this.parseUShort(),o=this.parseUShort(),u=new Array(o);for(let h=0;h<o;h++)u[h]=this.parseValueRecord(i);return u},we.prototype.parsePointer=function(i){let o=this.parseOffset16();if(o>0)return new we(this.data,this.offset+o).parseStruct(i)},we.prototype.parsePointer32=function(i){let o=this.parseOffset32();if(o>0)return new we(this.data,this.offset+o).parseStruct(i)},we.prototype.parseListOfLists=function(i){let o=this.parseOffset16List(),u=o.length,h=this.relativeOffset,p=new Array(u);for(let g=0;g<u;g++){let A=o[g];if(A===0){p[g]=void 0;continue}if(this.relativeOffset=A,i){let k=this.parseOffset16List(),E=new Array(k.length);for(let j=0;j<k.length;j++)this.relativeOffset=A+k[j],E[j]=i.call(this);p[g]=E}else p[g]=this.parseUShortList()}return this.relativeOffset=h,p},we.prototype.parseCoverage=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort(),u=this.parseUShort();if(o===1)return{format:1,glyphs:this.parseUShortList(u)};if(o===2){let h=new Array(u);for(let p=0;p<u;p++)h[p]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+i.toString(16)+": Coverage format must be 1 or 2.")},we.prototype.parseClassDef=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();return o===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:o===2?{format:2,ranges:this.parseRecordList({start:we.uShort,end:we.uShort,classId:we.uShort})}:(console.warn(`0x${i.toString(16)}: This font file uses an invalid ClassDef format of ${o}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:o})},we.list=function(i,o){return function(){return this.parseList(i,o)}},we.list32=function(i,o){return function(){return this.parseList32(i,o)}},we.recordList=function(i,o){return function(){return this.parseRecordList(i,o)}},we.recordList32=function(i,o){return function(){return this.parseRecordList32(i,o)}},we.pointer=function(i){return function(){return this.parsePointer(i)}},we.pointer32=function(i){return function(){return this.parsePointer32(i)}},we.tag=we.prototype.parseTag,we.byte=we.prototype.parseByte,we.uShort=we.offset16=we.prototype.parseUShort,we.uShortList=we.prototype.parseUShortList,we.uInt24=we.prototype.parseUInt24,we.uLong=we.offset32=we.prototype.parseULong,we.uLongList=we.prototype.parseULongList,we.fixed=we.prototype.parseFixed,we.f2Dot14=we.prototype.parseF2Dot14,we.struct=we.prototype.parseStruct,we.coverage=we.prototype.parseCoverage,we.classDef=we.prototype.parseClassDef;var At={reserved:we.uShort,reqFeatureIndex:we.uShort,featureIndexes:we.uShortList};we.prototype.parseScriptList=function(){return this.parsePointer(we.recordList({tag:we.tag,script:we.pointer({defaultLangSys:we.pointer(At),langSysRecords:we.recordList({tag:we.tag,langSys:we.pointer(At)})})}))||[]},we.prototype.parseFeatureList=function(){return this.parsePointer(we.recordList({tag:we.tag,feature:we.pointer({featureParams:we.offset16,lookupListIndexes:we.uShortList})}))||[]},we.prototype.parseLookupList=function(i){return this.parsePointer(we.list(we.pointer(function(){let o=this.parseUShort();me.argument(1<=o&&o<=9,"GPOS/GSUB lookup type "+o+" unknown.");let u=this.parseUShort(),h=u&16;return{lookupType:o,lookupFlag:u,subtables:this.parseList(we.pointer(i[o])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},we.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let i=this.parseUShort(),o=this.parseUShort();return me.argument(i===1&&o<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:we.offset32,featureTableSubstitutionOffset:we.offset32})})||[]},we.prototype.parseVariationStore=function(){let i=this.relativeOffset,o=this.parseUShort(),u={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=i+o+2,u},we.prototype.parseItemVariationStore=function(){let i=this.relativeOffset,o={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},u=this.parseOffset32(),h=this.parseUShort(),p=this.parseULongList(h);this.relativeOffset=i+u,o.variationRegions=this.parseVariationRegionList();for(let g=0;g<h;g++){let A=p[g];this.relativeOffset=i+A,o.itemVariationSubtables.push(this.parseItemVariationSubtable())}return o},we.prototype.parseVariationRegionList=function(){let i=this.parseUShort(),o=this.parseUShort();return this.parseRecordList(o,{regionAxes:we.recordList(i,{startCoord:we.f2Dot14,peakCoord:we.f2Dot14,endCoord:we.f2Dot14})})},we.prototype.parseItemVariationSubtable=function(){let i=this.parseUShort(),o=this.parseUShort(),u=this.parseUShortList(),h=u.length;return{regionIndexes:u,deltaSets:i&&h?this.parseDeltaSets(i,o,h):[]}},we.prototype.parseDeltaSetIndexMap=function(){let i=this.parseByte(),o=this.parseByte(),u=[],h=0;switch(i){case 0:h=this.parseUShort();break;case 1:h=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${i}`)}if(!h)return{format:i,entryFormat:o};let p=(o&Ft.INNER_INDEX_BIT_COUNT_MASK)+1,g=((o&Ft.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let A=0;A<h;A++){let k;if(g===1)k=this.parseByte();else if(g===2)k=this.parseUShort();else if(g===3)k=this.parseUInt24();else if(g===4)k=this.parseULong();else throw new Error(`Invalid entry size of ${g}`);let E=k>>p,j=k&(1<<p)-1;u.push({outerIndex:E,innerIndex:j})}return{format:i,entryFormat:o,map:u}},we.prototype.parseDeltaSets=function(i,o,u){let h=Array.from({length:i},()=>[]),p=o&Ft.LONG_WORDS,g=o&Ft.WORD_DELTA_COUNT_MASK;if(g>u)throw Error("wordCount must be less than or equal to regionIndexCount");let A=(p?this.parseLong:this.parseShort).bind(this),k=(p?this.parseShort:this.parseChar).bind(this);for(let E=0;E<i;E++)for(let j=0;j<u;j++)j<g?h[E].push(A()):h[E].push(k());return h},we.prototype.parseTupleVariationStoreList=function(i,o,u){let h=this.parseUShort(),p=this.parseUShort()&1,g=this.parseOffset32(),A=(p?this.parseULong:this.parseUShort).bind(this),k={},E=A();p||(E*=2);let j;for(let M=0;M<h;M++){j=A(),p||(j*=2);let re=j-E;k[M]=re?this.parseTupleVariationStore(g+E,i,o,u,M):void 0,E=j}return k},we.prototype.parseTupleVariationStore=function(i,o,u,h,p){let g=this.relativeOffset;this.relativeOffset=i,u==="cvar"&&(this.relativeOffset+=4);let A=this.parseUShort(),k=!!(A&Ft.SHARED_POINT_NUMBERS),E=A&Ft.COUNT_MASK,j=this.parseOffset16(),M=[],re=[];for(let fe=0;fe<E;fe++){let je=this.parseTupleVariationHeader(o,u);M.push(je)}this.relativeOffset!==i+j&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${i+j}, actually ${this.relativeOffset}`),this.relativeOffset=i+j),k&&(re=this.parsePackedPointNumbers());let te=this.relativeOffset;for(let fe=0;fe<E;fe++){let je=M[fe];je.privatePoints=[],this.relativeOffset=te,u==="cvar"&&!je.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),je.flags.privatePointNumbers&&(je.privatePoints=this.parsePackedPointNumbers()),delete je.flags;let pt=this.offset,Tr=this.relativeOffset,fr=Pr=>{let cn,Vn,rs=()=>{let ns=0;if(u==="gvar"){if(ns=je.privatePoints.length||re.length,!ns){let Gs=h.get(p);Gs.path,ns=Gs.points.length,ns+=4}}else u==="cvar"&&(ns=h.length);this.offset=pt,this.relativeOffset=Tr,cn=this.parsePackedDeltas(ns),u==="gvar"&&(Vn=this.parsePackedDeltas(ns))};return{configurable:!0,get:function(){return cn===void 0&&rs(),Pr==="deltasY"?Vn:cn},set:function(ns){cn===void 0&&rs(),Pr==="deltasY"?Vn=ns:cn=ns}}};Object.defineProperty(je,"deltas",fr.call(this,"deltas")),u==="gvar"&&Object.defineProperty(je,"deltasY",fr.call(this,"deltasY")),te+=je.variationDataSize,delete je.variationDataSize}this.relativeOffset=g;let Ae={headers:M};return Ae.sharedPoints=re,Ae},we.prototype.parseTupleVariationHeader=function(i,o){let u=this.parseUShort(),h=this.parseUShort(),p=!!(h&Ft.EMBEDDED_PEAK_TUPLE),g=!!(h&Ft.INTERMEDIATE_REGION),A=!!(h&Ft.PRIVATE_POINT_NUMBERS),k=p?void 0:h&Ft.TUPLE_INDEX_MASK,E=p?this.parseTupleRecords(1,i)[0]:void 0,j=g?this.parseTupleRecords(1,i)[0]:void 0,M=g?this.parseTupleRecords(1,i)[0]:void 0,re={variationDataSize:u,peakTuple:E,intermediateStartTuple:j,intermediateEndTuple:M,flags:{embeddedPeakTuple:p,intermediateRegion:g,privatePointNumbers:A}};return o==="gvar"&&(re.sharedTupleRecordsIndex=k),re},we.prototype.parsePackedPointNumbers=function(){let i=this.parseByte(),o=[],u=i;if(i>=128){let p=this.parseByte();u=(i&Ft.POINT_RUN_COUNT_MASK)<<8|p}let h=0;for(;o.length<u;){let p=this.parseByte(),g=!!(p&Ft.POINTS_ARE_WORDS),A=(p&Ft.POINT_RUN_COUNT_MASK)+1;for(let k=0;k<A&&o.length<u;k++){let E;g?E=this.parseUShort():E=this.parseByte(),h=h+E,o.push(h)}}return o},we.prototype.parsePackedDeltas=function(i){let o=[];for(;o.length<i;){let u=this.parseByte(),h=!!(u&Ft.DELTAS_ARE_ZERO),p=!!(u&Ft.DELTAS_ARE_WORDS),g=(u&Ft.DELTA_RUN_COUNT_MASK)+1;for(let A=0;A<g&&o.length<i;A++)h?o.push(0):p?o.push(this.parseShort()):o.push(this.parseChar())}return o};var st={getByte:Qr,getCard8:Qr,getUShort:Ce,getCard16:Ce,getShort:St,getUInt24:Ot,getULong:Jt,getFixed:Ct,getTag:ar,getOffset:_r,getBytes:Nr,bytesToString:zr,Parser:we},bt=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Tn={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},bn={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},nn={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Oe(i,o,u){switch(i){case 0:if(o===65535)return"und";if(u)return u[o];break;case 1:return Tn[o];case 3:return nn[o]}}var _t="utf-16",gt={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Wt={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function $t(i,o,u){switch(i){case 0:return _t;case 1:return Wt[u]||gt[o];case 3:if(o===1||o===10)return _t;break}}var Ar={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function Sn(i){return Ar[i]}function Mn(i,o,u){let h={},p=new st.Parser(i,o),g=p.parseUShort(),A=p.parseUShort(),k=p.offset+p.parseUShort();for(let E=0;E<A;E++){let j=p.parseUShort(),M=p.parseUShort(),re=p.parseUShort(),te=p.parseUShort(),Ae=bt[te]||te,fe=p.parseUShort(),je=p.parseUShort(),pt=Oe(j,re,u),Tr=$t(j,M,re),fr=Sn(j);if(Tr!==void 0&&pt!==void 0&&fr!==void 0){let Pr;if(Tr===_t?Pr=ke.UTF16(i,k+je,fe):Pr=ke.MACSTRING(i,k+je,fe,Tr),Pr){let cn=h[fr];cn===void 0&&(cn=h[fr]={});let Vn=cn[Ae];Vn===void 0&&(Vn=cn[Ae]={}),Vn[pt]=Pr}}}return g===1&&p.parseUShort(),h}function vn(i){let o={};for(let u in i)o[i[u]]=parseInt(u);return o}function dn(i,o,u,h,p,g){return new $e.Record("NameRecord",[{name:"platformID",type:"USHORT",value:i},{name:"encodingID",type:"USHORT",value:o},{name:"languageID",type:"USHORT",value:u},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:p},{name:"offset",type:"USHORT",value:g}])}function kn(i,o){let u=i.length,h=o.length-u+1;e:for(let p=0;p<h;p++)for(;p<h;p++){for(let g=0;g<u;g++)if(o[p+g]!==i[g])continue e;return p}return-1}function Hr(i,o){let u=kn(i,o);if(u<0){u=o.length;let h=0,p=i.length;for(;h<p;++h)o.push(i[h])}return u}function ne(i,o){let u=vn(Ar),h=vn(Tn),p=vn(nn),g=[],A=[];for(let E in i){let j,M=[],re={},te=vn(bt),Ae=u[E];for(let fe in i[E]){let je=te[fe];if(je===void 0&&(je=fe),j=parseInt(je),isNaN(j))throw new Error('Name table entry "'+fe+'" does not exist, see nameTableNames for complete list.');re[j]=i[E][fe],M.push(j)}for(let fe=0;fe<M.length;fe++){j=M[fe];let je=re[j];for(let pt in je){let Tr=je[pt];if(Ae===1||Ae===0){let fr=h[pt],Pr=bn[fr],cn=$t(Ae,Pr,fr),Vn=z.MACSTRING(Tr,cn);if(Ae===0&&(fr=o.indexOf(pt),fr<0&&(fr=o.length,o.push(pt)),Pr=4,Vn=z.UTF16(Tr)),Vn!==void 0){let rs=Hr(Vn,A);g.push(dn(Ae,Pr,fr,j,Vn.length,rs))}}if(Ae===3){let fr=p[pt];if(fr!==void 0){let Pr=z.UTF16(Tr),cn=Hr(Pr,A);g.push(dn(3,1,fr,j,Pr.length,cn))}}}}}g.sort(function(E,j){return E.platformID-j.platformID||E.encodingID-j.encodingID||E.languageID-j.languageID||E.nameID-j.nameID});let k=new $e.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:g.length},{name:"stringOffset",type:"USHORT",value:6+g.length*12}]);for(let E=0;E<g.length;E++)k.fields.push({name:"record_"+E,type:"RECORD",value:g[E]});return k.fields.push({name:"strings",type:"LITERAL",value:A}),k}function Xe(i,o,u=[]){if(o<256&&o in bt){if(u.length&&!u.includes(parseInt(o)))return;o=bt[o]}for(let h in i)for(let p in i[h])if(p===o||parseInt(p)===o)return i[h][p]}var Dt={parse:Mn,make:ne,getNameByID:Xe};function ur(i,o,u,h){i.length=o.parseUShort(),i.language=o.parseUShort()-1;let p=o.parseByteList(i.length),g=Object.assign({},p),A=$t(u,h,i.language),k=We[A];for(let E=0;E<k.length;E++)g[k.charCodeAt(E)]=p[128+E];i.glyphIndexMap=g}function Fr(i,o,u){o.parseUShort(),i.length=o.parseULong(),i.language=o.parseULong();let h;i.groupCount=h=o.parseULong(),i.glyphIndexMap={};for(let p=0;p<h;p+=1){let g=o.parseULong(),A=o.parseULong(),k=o.parseULong();for(let E=g;E<=A;E+=1)i.glyphIndexMap[E]=k,u===12&&k++}}function Zr(i,o,u,h,p){i.length=o.parseUShort(),i.language=o.parseUShort();let g;i.segCount=g=o.parseUShort()>>1,o.skip("uShort",3),i.glyphIndexMap={};let A=new st.Parser(u,h+p+14),k=new st.Parser(u,h+p+16+g*2),E=new st.Parser(u,h+p+16+g*4),j=new st.Parser(u,h+p+16+g*6),M=h+p+16+g*8;for(let re=0;re<g-1;re+=1){let te,Ae=A.parseUShort(),fe=k.parseUShort(),je=E.parseShort(),pt=j.parseUShort();for(let Tr=fe;Tr<=Ae;Tr+=1)pt!==0?(M=j.offset+j.relativeOffset-2,M+=pt,M+=(Tr-fe)*2,te=st.getUShort(u,M),te!==0&&(te=te+je&65535)):te=Tr+je&65535,i.glyphIndexMap[Tr]=te}}function an(i,o){let u={};o.skip("uLong");let h=o.parseULong();for(let p=0;p<h;p+=1){let g=o.parseUInt24(),A={varSelector:g},k=o.parseOffset32(),E=o.parseOffset32(),j=o.relativeOffset;k&&(o.relativeOffset=k,A.defaultUVS=o.parseStruct({ranges:function(){return o.parseRecordList32({startUnicodeValue:o.parseUInt24,additionalCount:o.parseByte})}})),E&&(o.relativeOffset=E,A.nonDefaultUVS=o.parseStruct({uvsMappings:function(){let M={},re=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let te=0;te<re.length;te+=1)M[re[te].unicodeValue]=re[te];return M}})),u[g]=A,o.relativeOffset=j}i.varSelectorList=u}function Mr(i,o){let u={};u.version=st.getUShort(i,o),me.argument(u.version===0,"cmap table version should be 0."),u.numTables=st.getUShort(i,o+2);let h=null,p=-1,g=-1,A=null,k=null,E=[0,1,2,3,4,6],j=[0,1,10];for(let re=u.numTables-1;re>=0;re-=1)if(A=st.getUShort(i,o+4+re*8),k=st.getUShort(i,o+4+re*8+2),A===3&&j.includes(k)||A===0&&E.includes(k)||A===1&&k===0){if(g>0)continue;if(g=st.getULong(i,o+4+re*8+4),h)break}else if(A===0&&k===5){if(p=st.getULong(i,o+4+re*8+4),h=new st.Parser(i,o+p),h.parseUShort()!==14)p=-1,h=null;else if(g>0)break}if(g===-1)throw new Error("No valid cmap sub-tables found.");let M=new st.Parser(i,o+g);if(u.format=M.parseUShort(),u.format===0)ur(u,M,A,k);else if(u.format===12||u.format===13)Fr(u,M,u.format);else if(u.format===4)Zr(u,M,i,o,g);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+u.format+", platformId "+A+", encodingId "+k+").");return h&&an(u,h),u}function Vr(i,o,u){i.segments.push({end:o,start:o,delta:-(o-u),offset:0,glyphIndex:u})}function Ln(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function tn(i){if(i.length===0)return i;let o=[i[0]];for(let u=1;u<i.length;u++){let h=o[o.length-1],p=i[u];h.end+1===p.start&&h.delta===p.delta&&p.end!==65535?h.end=p.end:o.push(p)}return o}function Ur(i){let o=!0,u;for(u=i.length-1;u>0;u-=1)if(i.get(u).unicode>65535){o=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:o?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:o?12:20}];o||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let p=new $e.Table("cmap",h);for(p.segments=[],u=0;u<i.length;u+=1){let Ae=i.get(u);for(let fe=0;fe<Ae.unicodes.length;fe+=1)Vr(p,Ae.unicodes[fe],u)}p.segments.sort(function(Ae,fe){return Ae.start-fe.start}),p.segments=tn(p.segments),Ln(p);let g=p.segments.length,A=0,k=[],E=[],j=[],M=[],re=[],te=[];for(u=0;u<g;u+=1){let Ae=p.segments[u];Ae.end<=65535&&Ae.start<=65535?(k.push({name:"end_"+u,type:"USHORT",value:Ae.end}),E.push({name:"start_"+u,type:"USHORT",value:Ae.start}),j.push({name:"idDelta_"+u,type:"SHORT",value:Ae.delta}),M.push({name:"idRangeOffset_"+u,type:"USHORT",value:Ae.offset}),Ae.glyphId!==void 0&&re.push({name:"glyph_"+u,type:"USHORT",value:Ae.glyphId})):A+=1,!o&&Ae.glyphIndex!==void 0&&(te.push({name:"cmap12Start_"+u,type:"ULONG",value:Ae.start}),te.push({name:"cmap12End_"+u,type:"ULONG",value:Ae.end}),te.push({name:"cmap12Glyph_"+u,type:"ULONG",value:Ae.glyphIndex}))}p.segCountX2=(g-A)*2,p.searchRange=Math.pow(2,Math.floor(Math.log(g-A)/Math.log(2)))*2,p.entrySelector=Math.log(p.searchRange/2)/Math.log(2),p.rangeShift=p.segCountX2-p.searchRange;for(let Ae=0;Ae<k.length;Ae++)p.fields.push(k[Ae]);p.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let Ae=0;Ae<E.length;Ae++)p.fields.push(E[Ae]);for(let Ae=0;Ae<j.length;Ae++)p.fields.push(j[Ae]);for(let Ae=0;Ae<M.length;Ae++)p.fields.push(M[Ae]);for(let Ae=0;Ae<re.length;Ae++)p.fields.push(re[Ae]);if(p.cmap4Length=14+k.length*2+2+E.length*2+j.length*2+M.length*2+re.length*2,!o){let Ae=16+te.length*4;p.cmap12Offset=20+p.cmap4Length,p.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:Ae},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:te.length/3});for(let fe=0;fe<te.length;fe++)p.fields.push(te[fe])}return p}var Xr={parse:Mr,make:Ur},vr=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","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","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],on=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","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","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Jr=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],hn=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],jr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","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","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],zn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],mn=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","grave","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","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function qr(i){this.font=i}qr.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.font.glyphs;if(u)for(let h=0;h<u.length;h+=1){let p=u.get(h);for(let g=0;g<p.unicodes.length;g+=1)if(p.unicodes[g]===o)return h}return null};function Wr(i){this.cmap=i}Wr.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function Y(i,o){this.encoding=i,this.charset=o}Y.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.encoding[o];return this.charset.indexOf(u)};function Be(i){switch(i.version){case 1:this.names=mn.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)i.glyphNameIndex[o]<mn.length?this.names[o]=mn[i.glyphNameIndex[o]]:this.names[o]=i.names[i.glyphNameIndex[o]-mn.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)this.names[o]=mn[o+i.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}Be.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},Be.prototype.glyphIndexToName=function(i){return this.names[i]};function Qt(i){let o,u=i.tables.cmap.glyphIndexMap,h=Object.keys(u);for(let p=0;p<h.length;p+=1){let g=h[p],A=u[g];o=i.glyphs.get(A),o.addUnicode(parseInt(g))}for(let p=0;p<i.glyphs.length;p+=1)o=i.glyphs.get(p),i.cffEncoding?o.name=i.cffEncoding.charset[p]:i.glyphNames.names&&(o.name=i.glyphNames.glyphIndexToName(p))}function er(i){i._IndexToUnicodeMap={};let o=i.tables.cmap.glyphIndexMap,u=Object.keys(o);for(let h=0;h<u.length;h+=1){let p=u[h],g=o[p];i._IndexToUnicodeMap[g]===void 0?i._IndexToUnicodeMap[g]={unicodes:[parseInt(p)]}:i._IndexToUnicodeMap[g].unicodes.push(parseInt(p))}}function sr(i,o){o.lowMemory?er(i):Qt(i)}function $r(i,o,u,h,p){i.beginPath(),i.moveTo(o,u),i.lineTo(h,p),i.stroke()}var Ir={line:$r};function Zn(i,o){let u=new we(i,o),h=u.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let p=u.parseShort(),g=u.parseShort(),A=u.parseShort(),k=u.parseOffset32(),E=u.parseUShortList(g);u.relativeOffset=k;let j=u.parseULongList(A);return u.relativeOffset=k,{version:h,numPaletteEntries:p,colorRecords:j,colorRecordIndices:E}}function ys({version:i=0,numPaletteEntries:o=0,colorRecords:u=[],colorRecordIndices:h=[0]}){return me.argument(i===0,"Only CPALv0 are supported."),me.argument(u.length,"No colorRecords given."),me.argument(h.length,"No colorRecordIndices given."),h.length>1&&me.argument(o,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new $e.Table("CPAL",[{name:"version",type:"USHORT",value:i},{name:"numPaletteEntries",type:"USHORT",value:o||u.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:u.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((p,g)=>({name:"colorRecordIndices_"+g,type:"USHORT",value:p})),...u.map((p,g)=>({name:"colorRecords_"+g,type:"ULONG",value:p}))])}function is(i){var o=(i&4278190080)>>24,u=(i&16711680)>>16,h=(i&65280)>>8,p=i&255;return o=o+256&255,u=u+256&255,h=h+256&255,p=(p+256&255)/255,{b:o,g:u,r:h,a:p}}function Hn(i,o,u=0,h="hexa"){if(o==65535)return"currentColor";let p=i&&i.tables&&i.tables.cpal;if(!p)return"currentColor";if(u>p.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${p.colorRecordIndices.length}, index: ${o})`);if(o>p.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${p.numPaletteEntries}, index: ${o})`);let g=p.colorRecordIndices[u]+o;if(g>p.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${p.colorRecords.length}, lookupIndex: ${g})`);let A=is(p.colorRecords[g]);return h==="bgra"?A:as(A,h)}function fn(i){return("0"+parseInt(i).toString(16)).slice(-2)}function Bn(i){let o=i.r/255,u=i.g/255,h=i.b/255,p=Math.max(o,u,h),g=Math.min(o,u,h),A,k,E=(p+g)/2;if(p===g)A=k=0;else{let j=p-g;switch(k=E>.5?j/(2-p-g):j/(p+g),p){case o:A=(u-h)/j+(u<h?6:0);break;case u:A=(h-o)/j+2;break;case h:A=(o-u)/j+4;break}A/=6}return{h:A*360,s:k*100,l:E*100}}function Xn(i){let{h:o,s:u,l:h,a:p}=i;o=o%360,u/=100,h/=100;let g=(1-Math.abs(2*h-1))*u,A=g*(1-Math.abs(o/60%2-1)),k=h-g/2,E=0,j=0,M=0;return 0<=o&&o<60?(E=g,j=A,M=0):60<=o&&o<120?(E=A,j=g,M=0):120<=o&&o<180?(E=0,j=g,M=A):180<=o&&o<240?(E=0,j=A,M=g):240<=o&&o<300?(E=A,j=0,M=g):300<=o&&o<=360&&(E=g,j=0,M=A),{r:Math.round((E+k)*255),g:Math.round((j+k)*255),b:Math.round((M+k)*255),a:p}}function pn(i){return parseInt(`0x${fn(i.b)}${fn(i.g)}${fn(i.r)}${fn(i.a*255)}`,16)}function lr(i,o="hexa"){let u=o=="raw"||o=="cpal",h=Number.isInteger(i),p=!0;if(h&&u||i==="currentColor")return i;if(typeof i=="object"){if(o=="bgra")return i;if(u)return pn(i)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(i.trim())){switch(i=i.trim().substring(1),i.length){case 3:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:1};break;case 4:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:parseInt(i[3].repeat(2),16)/255};break;case 6:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:1};break;case 8:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:parseInt(i[6]+i[7],16)/255};break}if(o=="bgra")return i}else if(typeof document<"u"&&/^[a-z]+$/i.test(i)){let g=document.createElement("canvas").getContext("2d");g.fillStyle=i;let A=as(g.fillStyle,"hexa");A==="#000000ff"&&i.toLowerCase()!=="black"?p=!1:i=A}else{i=i.trim();let g=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(g.test(i)){let A=i.match(g).filter(k=>typeof k<"u");i={r:Math.round(parseFloat(A[1])/(A[2]?.39215686274509803:1)),g:Math.round(parseFloat(A[3])/(A[4]?.39215686274509803:1)),b:Math.round(parseFloat(A[5])/(A[6]?.39215686274509803:1)),a:A[7]?parseFloat(A[7])/(A[8]?100:1):1}}else{let A=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(A.test(i)){let k=i.match(A).filter(E=>typeof E<"u");i=Xn({h:parseFloat(k[1])*(k[2]==="turn"?360:1),s:parseFloat(k[3]),l:parseFloat(k[4]),a:k[5]?parseFloat(k[5])/(k[6]?100:1):1})}else p=!1}}if(!p)throw new Error(`Invalid color format: ${i}`);return as(i,o)}function as(i,o="hexa"){if(i==="currentColor")return i;if(Number.isInteger(i)){if(o=="raw"||o=="cpal")return i;i=is(i)}else typeof i!="object"&&(i=lr(i,"bgra"));let u=["hsl","hsla"].includes(o)?Bn(i):null;switch(o){case"rgba":return`rgba(${i.r}, ${i.g}, ${i.b}, ${parseFloat(i.a.toFixed(3))})`;case"rgb":return`rgb(${i.r}, ${i.g}, ${i.b})`;case"hex":case"hex6":case"hex-6":return`#${fn(i.r)}${fn(i.g)}${fn(i.b)}`;case"hexa":case"hex8":case"hex-8":return`#${fn(i.r)}${fn(i.g)}${fn(i.b)}${fn(i.a*255)}`;case"hsl":return`hsl(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%)`;case"hsla":return`hsla(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%, ${parseFloat(i.a.toFixed(3))})`;case"bgra":return i;case"raw":case"cpal":return pn(i);default:throw new Error("Unknown color format: "+o)}}var rn={parse:Zn,make:ys,getPaletteColor:Hn,parseColor:lr,formatColor:as};function gr(i,o){let u=o||new ze;return{configurable:!0,get:function(){return typeof u=="function"&&(u=u()),u},set:function(h){u=h}}}function wr(i){this.bindConstructorValues(i)}wr.prototype.bindConstructorValues=function(i){if(this.index=i.index||0,i.name===".notdef"?i.unicode=void 0:i.name===".null"&&(i.unicode=0),i.unicode===0&&i.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=i.name||null,this.unicode=i.unicode,this.unicodes=i.unicodes||(i.unicode!==void 0?[i.unicode]:[]),"xMin"in i&&(this.xMin=i.xMin),"yMin"in i&&(this.yMin=i.yMin),"xMax"in i&&(this.xMax=i.xMax),"yMax"in i&&(this.yMax=i.yMax),"advanceWidth"in i&&(this.advanceWidth=i.advanceWidth),"leftSideBearing"in i&&(this.leftSideBearing=i.leftSideBearing),"points"in i&&(this.points=i.points),Object.defineProperty(this,"path",gr(this,i.path))},wr.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},wr.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},wr.prototype.getPath=function(i,o,u,h,p){i=i!==void 0?i:0,o=o!==void 0?o:0,u=u!==void 0?u:72,h=Object.assign({},p&&p.defaultRenderOptions,h);let g,A,k=h.xScale,E=h.yScale,j=1/(this.path.unitsPerEm||1e3)*u,M=this;p&&p.variation&&(M=p.variation.getTransform(this,h.variation),g=M.path.commands),h.hinting&&p&&p.hinting&&(A=M.path&&p.hinting.exec(M,u,h)),A?(g=p.hinting.getCommands(A),i=Math.round(i),o=Math.round(o),k=E=1):(g=M.path.commands,k===void 0&&(k=j),E===void 0&&(E=j));let re=new ze;if(h.drawSVG){let te=this.getSvgImage(p);if(te){let Ae=new ze;return Ae._image={image:te.image,x:i+te.leftSideBearing*j,y:o-te.baseline*j,width:te.image.width*j,height:te.image.height*j},re._layers=[Ae],re}}if(h.drawLayers){let te=this.getLayers(p);if(te&&te.length){re._layers=[];for(let Ae=0;Ae<te.length;Ae+=1){let fe=te[Ae],je=Hn(p,fe.paletteIndex,h.usePalette);je==="currentColor"?je=h.fill||"black":je=as(je,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:je}),re._layers.push(this.getPath.call(fe.glyph,i,o,u,h,p))}return re}}re.fill=h.fill||this.path.fill,re.stroke=this.path.stroke,re.strokeWidth=this.path.strokeWidth*j;for(let te=0;te<g.length;te+=1){let Ae=g[te];Ae.type==="M"?re.moveTo(i+Ae.x*k,o+-Ae.y*E):Ae.type==="L"?re.lineTo(i+Ae.x*k,o+-Ae.y*E):Ae.type==="Q"?re.quadraticCurveTo(i+Ae.x1*k,o+-Ae.y1*E,i+Ae.x*k,o+-Ae.y*E):Ae.type==="C"?re.curveTo(i+Ae.x1*k,o+-Ae.y1*E,i+Ae.x2*k,o+-Ae.y2*E,i+Ae.x*k,o+-Ae.y*E):Ae.type==="Z"&&re.stroke&&re.strokeWidth&&re.closePath()}return re},wr.prototype.getLayers=function(i){if(!i)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return i.layers.get(this.index)},wr.prototype.getSvgImage=function(i){if(!i)throw new Error("The font object is required to read the svg table in order to get the image.");return i.svgImages.get(this.index)},wr.prototype.getContours=function(i=null){if(this.points===void 0&&!i)return[];let o=[],u=[],h=i||this.points;for(let p=0;p<h.length;p+=1){let g=h[p];u.push(g),g.lastPointOfContour&&(o.push(u),u=[])}return me.argument(u.length===0,"There are still points left in the current contour."),o},wr.prototype.getMetrics=function(){let i=this.path.commands,o=[],u=[];for(let p=0;p<i.length;p+=1){let g=i[p];g.type!=="Z"&&(o.push(g.x),u.push(g.y)),(g.type==="Q"||g.type==="C")&&(o.push(g.x1),u.push(g.y1)),g.type==="C"&&(o.push(g.x2),u.push(g.y2))}let h={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,o),yMax:Math.max.apply(null,u),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},wr.prototype.draw=function(i,o,u,h,p,g){p=Object.assign({},g&&g.defaultRenderOptions,p),this.getPath(o,u,h,p,g).draw(i)},wr.prototype.drawPoints=function(i,o,u,h,p,g){if(p=Object.assign({},g&&g.defaultRenderOptions,p),p.drawLayers){let re=this.getLayers(g);if(re&&re.length){for(let te=0;te<re.length;te+=1)re[te].glyph.index!==this.index&&this.drawPoints.call(re[te].glyph,i,o,u,h);return}}function A(re,te,Ae,fe){i.beginPath();for(let je=0;je<re.length;je+=1)i.moveTo(te+re[je].x*fe,Ae+re[je].y*fe),i.arc(te+re[je].x*fe,Ae+re[je].y*fe,2,0,Math.PI*2,!1);i.fill()}o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:24;let k=1/this.path.unitsPerEm*h,E=[],j=[],M=this.path.commands;g&&g.variation&&(M=g.variation.getTransform(this,p.variation).path.commands);for(let re=0;re<M.length;re+=1){let te=M[re];te.x!==void 0&&E.push({x:te.x,y:-te.y}),te.x1!==void 0&&j.push({x:te.x1,y:-te.y1}),te.x2!==void 0&&j.push({x:te.x2,y:-te.y2})}i.fillStyle="blue",A(E,o,u,k),i.fillStyle="red",A(j,o,u,k)},wr.prototype.drawMetrics=function(i,o,u,h){let p;o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:24,p=1/this.path.unitsPerEm*h,i.lineWidth=1,i.strokeStyle="black",Ir.line(i,o,-1e4,o,1e4),Ir.line(i,-1e4,u,1e4,u);let g=this.xMin||0,A=this.yMin||0,k=this.xMax||0,E=this.yMax||0,j=this.advanceWidth||0;i.strokeStyle="blue",Ir.line(i,o+g*p,-1e4,o+g*p,1e4),Ir.line(i,o+k*p,-1e4,o+k*p,1e4),Ir.line(i,-1e4,u+-A*p,1e4,u+-A*p),Ir.line(i,-1e4,u+-E*p,1e4,u+-E*p),i.strokeStyle="green",Ir.line(i,o+j*p,-1e4,o+j*p,1e4)},wr.prototype.toPathData=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this;o&&o.variation&&(u=o.variation.getTransform(this,i.variation));let h=u.points&&i.pointsTransform?i.pointsTransform(u.points):u.path;return i.pathTransform&&(h=i.pathTransform(h)),h.toPathData(i)},wr.prototype.fromSVG=function(i,o={}){return this.path.fromSVG(i,o)},wr.prototype.toSVG=function(i,o){let u=this.toPathData.apply(this,[i,o]);return this.path.toSVG(i,u)},wr.prototype.toDOMElement=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this.path;return o&&o.variation&&(u=o.variation.getTransform(this,i.variation).path),u.toDOMElement(i)};var xr=wr;function ds(i,o,u){Object.defineProperty(i,o,{get:function(){return typeof i[u]>"u"&&i.path,i[u]},set:function(h){i[u]=h},enumerable:!0,configurable:!0})}function jn(i,o){if(this.font=i,this.glyphs={},Array.isArray(o))for(let u=0;u<o.length;u++){let h=o[u];h.path.unitsPerEm=i.unitsPerEm,this.glyphs[u]=h}this.length=o&&o.length||0}typeof Symbol<"u"&&Symbol.iterator&&(jn.prototype[Symbol.iterator]=function(){let i=-1;return{next:(function(){i++;let o=i>=this.length-1;return{value:this.get(i),done:o}}).bind(this)}}),jn.prototype.get=function(i){if(this.font._push&&this.glyphs[i]===void 0){this.font._push(i),typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());let o=this.glyphs[i],u=this.font._IndexToUnicodeMap[i];if(u)for(let h=0;h<u.unicodes.length;h++)o.addUnicode(u.unicodes[h]);this.font.cffEncoding?o.name=this.font.cffEncoding.charset[i]:this.font.glyphNames.names&&(o.name=this.font.glyphNames.glyphIndexToName(i)),this.glyphs[i].advanceWidth=this.font._hmtxTableData[i].advanceWidth,this.glyphs[i].leftSideBearing=this.font._hmtxTableData[i].leftSideBearing}else typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());return this.glyphs[i]},jn.prototype.push=function(i,o){this.glyphs[i]=o,this.length++};function vs(i,o){return new xr({index:o,font:i})}function Qs(i,o,u,h,p,g){return function(){let A=new xr({index:o,font:i});return A.path=function(){u(A,h,p);let k=g(i.glyphs,A);return k.unitsPerEm=i.unitsPerEm,k},ds(A,"numberOfContours","_numberOfContours"),ds(A,"xMin","_xMin"),ds(A,"xMax","_xMax"),ds(A,"yMin","_yMin"),ds(A,"yMax","_yMax"),ds(A,"points","_points"),A}}function Is(i,o,u,h,p){return function(){let g=new xr({index:o,font:i});return g.path=function(){let A=u(i,g,h,p);return A.unitsPerEm=i.unitsPerEm,A},g}}var Or={GlyphSet:jn,glyphLoader:vs,ttfGlyphLoader:Qs,cffGlyphLoader:Is};function br(i,o){if(i===o)return!0;if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length)return!1;for(let u=0;u<i.length;u+=1)if(!br(i[u],o[u]))return!1;return!0}else return!1}var Qn=10;function Jn(i){let o;return i.length<1240?o=107:i.length<33900?o=1131:o=32768,o}function es(i,o,u,h){let p=[],g=[],A=h>1?st.getULong(i,o):st.getCard16(i,o),k=h>1?4:2,E,j;if(A!==0){let M=st.getByte(i,o+k);E=o+(A+1)*M+k;let re=o+k+1;for(let te=0;te<A+1;te+=1)p.push(st.getOffset(i,re,M)),re+=M;j=E+p[A]}else j=o+k;for(let M=0;M<p.length-1;M+=1){let re=st.getBytes(i,E+p[M],E+p[M+1]);u&&(re=u(re,i,o,h)),g.push(re)}return{objects:g,startOffset:o,endOffset:j}}function ui(i,o,u){let h=[],p=u>1?st.getULong(i,o):st.getCard16(i,o),g=u>1?4:2,A,k;if(p!==0){let E=st.getByte(i,o+g);A=o+(p+1)*E+g;let j=o+g+1;for(let M=0;M<p+1;M+=1)h.push(st.getOffset(i,j,E)),j+=E;k=A+h[p]}else k=o+g;return{offsets:h,startOffset:o,endOffset:k}}function W(i,o,u,h,p,g){let A=g>1?st.getULong(u,h):st.getCard16(u,h),k=g>1?4:2,E=0;if(A!==0){let M=st.getByte(u,h+k);E=h+(A+1)*M+k}let j=st.getBytes(u,E+o[i],E+o[i+1]);return p&&(j=p(j)),j}function Ie(i){let o="",u=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let h=i.parseByte(),p=h>>4,g=h&15;if(p===15||(o+=u[p],g===15))break;o+=u[g]}return parseFloat(o)}function Ye(i,o){let u,h,p,g;if(o===28)return u=i.parseByte(),h=i.parseByte(),u<<8|h;if(o===29)return u=i.parseByte(),h=i.parseByte(),p=i.parseByte(),g=i.parseByte(),u<<24|h<<16|p<<8|g;if(o===30)return Ie(i);if(o>=32&&o<=246)return o-139;if(o>=247&&o<=250)return u=i.parseByte(),(o-247)*256+u+108;if(o>=251&&o<=254)return u=i.parseByte(),-(o-251)*256-u-108;throw new Error("Invalid b0 "+o)}function rt(i){let o={};for(let u=0;u<i.length;u+=1){let h=i[u][0],p=i[u][1],g;if(p.length===1?g=p[0]:g=p,Object.prototype.hasOwnProperty.call(o,h)&&!isNaN(o[h]))throw new Error("Object "+o+" already has key "+h);o[h]=g}return o}function nt(i,o,u,h){o=o!==void 0?o:0;let p=new st.Parser(i,o),g=[],A=[];u=u!==void 0?u:i.byteLength;let k=h<2?22:28;for(;p.relativeOffset<u;){let E=p.parseByte();if(E<k){if(E===12&&(E=1200+p.parseByte()),h>1&&E===23){kr(A);continue}g.push([E,A]),A=[]}else A.push(Ye(p,E,h))}return rt(g)}function yt(i,o){return o<=390?o=vr[o]:i?o=i[o-391]:o=void 0,o}function Pt(i,o,u){let h={},p;for(let g=0;g<o.length;g+=1){let A=o[g];if(Array.isArray(A.type)){let k=[];k.length=A.type.length;for(let E=0;E<A.type.length;E++)p=i[A.op]!==void 0?i[A.op][E]:void 0,p===void 0&&(p=A.value!==void 0&&A.value[E]!==void 0?A.value[E]:null),A.type[E]==="SID"&&(p=yt(u,p)),k[E]=p;h[A.name]=k}else p=i[A.op],p===void 0&&(p=A.value!==void 0?A.value:null),A.type==="SID"&&(p=yt(u,p)),h[A.name]=p}return h}function H(i,o){let u={};if(u.formatMajor=st.getCard8(i,o),u.formatMinor=st.getCard8(i,o+1),u.formatMajor>2)throw new Error(`Unsupported CFF table version ${u.formatMajor}.${u.formatMinor}`);return u.size=st.getCard8(i,o+2),u.formatMajor<2?(u.offsetSize=st.getCard8(i,o+3),u.startOffset=o,u.endOffset=o+4):(u.topDictLength=st.getCard16(i,o+3),u.endOffset=o+8),u}var ue=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],R=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],U=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],X=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],be=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Ee(i,o,u,h){let p=nt(i,o,i.byteLength,h);return Pt(p,h>1?R:ue,u)}function Ve(i,o,u,h,p){let g=nt(i,o,u,p);return Pt(g,p>1?X:U,h)}function dt(i,o,u){let h=nt(i,o,void 0,u);return Pt(h,be)}function Qe(i,o,u){let h=[];for(let p=0;p<u.length;p++){let g=new DataView(new Uint8Array(u[p]).buffer),A=dt(g,0,2),k=A.private[0],E=A.private[1];if(k!==0&&E!==0){let j=Ve(i,E+o,k,[],2);if(j.subrs){let M=E+j.subrs,re=es(i,M+o,void 0,2);A._subrs=re.objects,A._subrsBias=Jn(A._subrs)}A._privateDict=j}h.push(A)}return h}function ir(i,o,u,h,p){let g=[];for(let A=0;A<u.length;A+=1){let k=new DataView(new Uint8Array(u[A]).buffer),E=Ee(k,0,h,p);E._subrs=[],E._subrsBias=0,E._defaultWidthX=0,E._nominalWidthX=0;let j=p<2?E.private[0]:0,M=p<2?E.private[1]:0;if(j!==0&&M!==0){let re=Ve(i,M+o,j,h,p);if(E._defaultWidthX=re.defaultWidthX,E._nominalWidthX=re.nominalWidthX,re.subrs!==0){let te=M+re.subrs,Ae=es(i,te+o,void 0,p);E._subrs=Ae.objects,E._subrsBias=Jn(E._subrs)}E._privateDict=re}g.push(E)}return g}function rr(i,o,u,h,p){let g,A,k=new st.Parser(i,o);u-=1;let E=[".notdef"],j=k.parseCard8();if(j===0)for(let M=0;M<u;M+=1)g=k.parseSID(),p?E.push(g):E.push(yt(h,g)||g);else if(j===1)for(;E.length<=u;){g=k.parseSID(),A=k.parseCard8();for(let M=0;M<=A;M+=1)p?E.push("cid"+("00000"+g).slice(-5)):E.push(yt(h,g)||g),g+=1}else if(j===2)for(;E.length<=u;){g=k.parseSID(),A=k.parseCard16();for(let M=0;M<=A;M+=1)p?E.push("cid"+("00000"+g).slice(-5)):E.push(yt(h,g)||g),g+=1}else throw new Error("Unknown charset format "+j);return E}function Et(i,o){let u,h={},p=new st.Parser(i,o),g=p.parseCard8();if(g===0){let A=p.parseCard8();for(let k=0;k<A;k+=1)u=p.parseCard8(),h[u]=k}else if(g===1){let A=p.parseCard8();u=1;for(let k=0;k<A;k+=1){let E=p.parseCard8(),j=p.parseCard8();for(let M=E;M<=E+j;M+=1)h[M]=u,u+=1}}else throw new Error("Unknown encoding format "+g);return h}function kr(i){let o=i.pop();for(;i.length>o;)i.pop()}function ln(i,o){let u=i.tables.cff&&i.tables.cff.topDict&&i.tables.cff.topDict.paintType||0;return u===2&&(o.fill=null,o.stroke="black",o.strokeWidth=i.tables.cff.topDict.strokeWidth||0),u}function yn(i,o,u,h,p){let g,A,k,E,j=new ze,M=[],re=0,te=!1,Ae=!1,fe=0,je=0,pt,Tr,fr,Pr,cn=0,Vn=[],rs,ns=0,Gs=i.tables.cff2||i.tables.cff;if(fr=Gs.topDict._defaultWidthX,Pr=Gs.topDict._nominalWidthX,p=p||i.variation&&i.variation.get(),o.getBlendPath||(o.getBlendPath=function(or){return yn(i,o,u,h,or)}),i.isCIDFont||h>1){let or=Gs.topDict._fdSelect?Gs.topDict._fdSelect[o.index]:0,hr=Gs.topDict._fdArray[or];pt=hr._subrs,Tr=hr._subrsBias,h>1?(Vn=Gs.topDict._vstore.itemVariationStore,cn=hr._privateDict.vsindex):(fr=hr._defaultWidthX,Pr=hr._nominalWidthX)}else pt=Gs.topDict._subrs,Tr=Gs.topDict._subrsBias;let Wo=ln(i,j),un=fr;function Ya(or,hr){Ae&&Wo!==2&&j.closePath(),j.moveTo(or,hr),Ae=!0}function fa(){let or;or=(M.length&1)!==0,or&&!te&&(un=M.shift()+Pr),re+=M.length>>1,M.length=0,te=!0}function Sr(or){let hr,Xi,cc,ph,Rc,Go,pa,mo,Ji,Za,ma,ga,$s=0;for(;$s<or.length;){let xo=or[$s];switch($s+=1,xo){case 1:fa();break;case 3:fa();break;case 4:M.length>1&&!te&&(un=M.shift()+Pr,te=!0),je+=M.pop(),Ya(fe,je);break;case 5:for(;M.length>0;)fe+=M.shift(),je+=M.shift(),j.lineTo(fe,je);break;case 6:for(;M.length>0&&(fe+=M.shift(),j.lineTo(fe,je),M.length!==0);)je+=M.shift(),j.lineTo(fe,je);break;case 7:for(;M.length>0&&(je+=M.shift(),j.lineTo(fe,je),M.length!==0);)fe+=M.shift(),j.lineTo(fe,je);break;case 8:for(;M.length>0;)g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E+M.shift(),j.curveTo(g,A,k,E,fe,je);break;case 10:if(Rc=M.pop()+Tr,Go=pt[Rc],Go){if(ns>=Qn){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}ns++,Sr(Go),ns--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(xo=or[$s],$s+=1,xo){case 35:g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),pa=k+M.shift(),mo=E+M.shift(),Ji=pa+M.shift(),Za=mo+M.shift(),ma=Ji+M.shift(),ga=Za+M.shift(),fe=ma+M.shift(),je=ga+M.shift(),M.shift(),j.curveTo(g,A,k,E,pa,mo),j.curveTo(Ji,Za,ma,ga,fe,je);break;case 34:g=fe+M.shift(),A=je,k=g+M.shift(),E=A+M.shift(),pa=k+M.shift(),mo=E,Ji=pa+M.shift(),Za=E,ma=Ji+M.shift(),ga=je,fe=ma+M.shift(),j.curveTo(g,A,k,E,pa,mo),j.curveTo(Ji,Za,ma,ga,fe,je);break;case 36:g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),pa=k+M.shift(),mo=E,Ji=pa+M.shift(),Za=E,ma=Ji+M.shift(),ga=Za+M.shift(),fe=ma+M.shift(),j.curveTo(g,A,k,E,pa,mo),j.curveTo(Ji,Za,ma,ga,fe,je);break;case 37:g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),pa=k+M.shift(),mo=E+M.shift(),Ji=pa+M.shift(),Za=mo+M.shift(),ma=Ji+M.shift(),ga=Za+M.shift(),Math.abs(ma-fe)>Math.abs(ga-je)?fe=ma+M.shift():je=ga+M.shift(),j.curveTo(g,A,k,E,pa,mo),j.curveTo(Ji,Za,ma,ga,fe,je);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+xo),M.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(M.length>=4){let Mc=jr[M.pop()],wu=jr[M.pop()],mh=M.pop(),gh=M.pop();if(Mc&&wu){o.isComposite=!0,o.components=[];let Ax=i.cffEncoding.charset.indexOf(Mc),Tx=i.cffEncoding.charset.indexOf(wu);o.components.push({glyphIndex:Tx,dx:0,dy:0}),o.components.push({glyphIndex:Ax,dx:gh,dy:mh}),j.extend(i.glyphs.get(Tx).path);let h8=i.glyphs.get(Ax),Qp=JSON.parse(JSON.stringify(h8.path.commands));for(let Pp=0;Pp<Qp.length;Pp+=1){let ll=Qp[Pp];ll.type!=="Z"&&(ll.x+=gh,ll.y+=mh),(ll.type==="Q"||ll.type==="C")&&(ll.x1+=gh,ll.y1+=mh),ll.type==="C"&&(ll.x2+=gh,ll.y2+=mh)}j.extend(Qp)}}else M.length>0&&!te&&(un=M.shift()+Pr,te=!0);Ae&&Wo!==2&&(j.closePath(),Ae=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}cn=M.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}rs||(rs=i.variation&&p&&i.variation.process.getBlendVector(Vn,cn,p));var us=M.pop(),Da=rs?rs.length:Vn.itemVariationSubtables[cn].regionIndexes.length,go=us*Da,Vo=M.length-go,Ml=Vo-us;if(rs)for(let Mc=0;Mc<us;Mc++){var wx=M[Ml+Mc];for(let wu=0;wu<Da;wu++)wx+=rs[wu]*M[Vo++];M[Ml+Mc]=wx}for(;go--;)M.pop();break;case 18:fa();break;case 19:case 20:fa(),$s+=re+7>>3;break;case 21:M.length>2&&!te&&(un=M.shift()+Pr,te=!0),je+=M.pop(),fe+=M.pop(),Ya(fe,je);break;case 22:M.length>1&&!te&&(un=M.shift()+Pr,te=!0),fe+=M.pop(),Ya(fe,je);break;case 23:fa();break;case 24:for(;M.length>2;)g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E+M.shift(),j.curveTo(g,A,k,E,fe,je);fe+=M.shift(),je+=M.shift(),j.lineTo(fe,je);break;case 25:for(;M.length>6;)fe+=M.shift(),je+=M.shift(),j.lineTo(fe,je);g=fe+M.shift(),A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E+M.shift(),j.curveTo(g,A,k,E,fe,je);break;case 26:for(M.length&1&&(fe+=M.shift());M.length>0;)g=fe,A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k,je=E+M.shift(),j.curveTo(g,A,k,E,fe,je);break;case 27:for(M.length&1&&(je+=M.shift());M.length>0;)g=fe+M.shift(),A=je,k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E,j.curveTo(g,A,k,E,fe,je);break;case 28:hr=or[$s],Xi=or[$s+1],M.push((hr<<24|Xi<<16)>>16),$s+=2;break;case 29:if(Rc=M.pop()+i.gsubrsBias,Go=i.gsubrs[Rc],Go){if(ns>=Qn){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}ns++,Sr(Go),ns--}break;case 30:for(;M.length>0&&(g=fe,A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E+(M.length===1?M.shift():0),j.curveTo(g,A,k,E,fe,je),M.length!==0);)g=fe+M.shift(),A=je,k=g+M.shift(),E=A+M.shift(),je=E+M.shift(),fe=k+(M.length===1?M.shift():0),j.curveTo(g,A,k,E,fe,je);break;case 31:for(;M.length>0&&(g=fe+M.shift(),A=je,k=g+M.shift(),E=A+M.shift(),je=E+M.shift(),fe=k+(M.length===1?M.shift():0),j.curveTo(g,A,k,E,fe,je),M.length!==0);)g=fe,A=je+M.shift(),k=g+M.shift(),E=A+M.shift(),fe=k+M.shift(),je=E+(M.length===1?M.shift():0),j.curveTo(g,A,k,E,fe,je);break;default:xo<32?console.log("Glyph "+o.index+": unknown operator "+xo):xo<247?M.push(xo-139):xo<251?(hr=or[$s],$s+=1,M.push((xo-247)*256+hr+108)):xo<255?(hr=or[$s],$s+=1,M.push(-(xo-251)*256-hr-108)):(hr=or[$s],Xi=or[$s+1],cc=or[$s+2],ph=or[$s+3],$s+=4,M.push((hr<<24|Xi<<16|cc<<8|ph)/65536))}}}return Sr(u),i.variation&&p&&(j.commands=j.commands.map(or=>{let hr=Object.keys(or);for(let Xi=0;Xi<hr.length;Xi++){let cc=hr[Xi];cc!=="type"&&(or[cc]=Math.round(or[cc]))}return or})),te&&(o.advanceWidth=un),j}function en(i,o,u,h,p){let g=[],A,k=new st.Parser(i,o),E=k.parseCard8();if(E===0)for(let j=0;j<u;j++){if(A=k.parseCard8(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");g.push(A)}else if(E===3||p>1&&E===4){let j=E===4?k.parseULong():k.parseCard16(),M=E===4?k.parseULong():k.parseCard16();if(M!==0)throw new Error(`CFF Table CID Font FDSelect format ${E} range has bad initial GID ${M}`);let re;for(let te=0;te<j;te++){if(A=E===4?k.parseUShort():k.parseCard8(),re=E===4?k.parseULong():k.parseCard16(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");if(re>u)throw new Error(`CFF Table CID Font FDSelect format ${p} range has bad GID ${re}`);for(;M<re;M++)g.push(A);M=re}if(re!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+re)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+E);return g}function gn(i,o,u,h){let p,g=H(i,o);g.formatMajor===2?p=u.tables.cff2={}:p=u.tables.cff={};let A=g.formatMajor>1?null:es(i,g.endOffset,st.bytesToString),k=g.formatMajor>1?null:es(i,A.endOffset),E=g.formatMajor>1?null:es(i,k.endOffset,st.bytesToString),j=es(i,g.formatMajor>1?o+g.size+g.topDictLength:E.endOffset,void 0,g.formatMajor);u.gsubrs=j.objects,u.gsubrsBias=Jn(u.gsubrs);let M;if(g.formatMajor>1){let te=o+g.size,Ae=st.getBytes(i,te,te+g.topDictLength);M=ir(i,0,[Ae],void 0,g.formatMajor)[0]}else{let te=ir(i,o,k.objects,E.objects,g.formatMajor);if(te.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+te.length);M=te[0]}if(p.topDict=M,M._privateDict&&(u.defaultWidthX=M._privateDict.defaultWidthX,u.nominalWidthX=M._privateDict.nominalWidthX),g.formatMajor<2&&M.ros[0]!==void 0&&M.ros[1]!==void 0&&(u.isCIDFont=!0),g.formatMajor>1){let te=M.fdArray,Ae=M.fdSelect;if(!te)throw new Error("This is a CFF2 font, but FDArray information is missing");let fe=es(i,o+te,null,g.formatMajor),je=Qe(i,o,fe.objects);M._fdArray=je,Ae&&(M._fdSelect=en(i,o+Ae,u.numGlyphs,je.length,g.formatMajor))}else if(u.isCIDFont){let te=M.fdArray,Ae=M.fdSelect;if(te===0||Ae===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");te+=o;let fe=es(i,te),je=ir(i,o,fe.objects,E.objects,g.formatMajor);M._fdArray=je,Ae+=o,M._fdSelect=en(i,Ae,u.numGlyphs,je.length,g.formatMajor)}if(g.formatMajor<2){let te=o+M.private[1],Ae=Ve(i,te,M.private[0],E.objects,g.formatMajor);if(u.defaultWidthX=Ae.defaultWidthX,u.nominalWidthX=Ae.nominalWidthX,Ae.subrs!==0){let fe=te+Ae.subrs,je=es(i,fe);u.subrs=je.objects,u.subrsBias=Jn(u.subrs)}else u.subrs=[],u.subrsBias=0}let re;if(h.lowMemory?(re=ui(i,o+M.charStrings,g.formatMajor),u.nGlyphs=re.offsets.length-(g.formatMajor>1?1:0)):(re=es(i,o+M.charStrings,null,g.formatMajor),u.nGlyphs=re.objects.length),g.formatMajor>1&&u.tables.maxp&&u.nGlyphs!==u.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${u.nGlyphs}) must correspond to the glyph count in the maxp table (${u.tables.maxp.numGlyphs})`),g.formatMajor<2){let te=[],Ae=[];M.charset===0?te=on:M.charset===1?te=Jr:M.charset===2?te=hn:te=rr(i,o+M.charset,u.nGlyphs,E.objects,u.isCIDFont),M.encoding===0?Ae=jr:M.encoding===1?Ae=zn:Ae=Et(i,o+M.encoding),u.cffEncoding=new Y(Ae,te),u.encoding=u.encoding||u.cffEncoding}if(u.glyphs=new Or.GlyphSet(u),h.lowMemory)u._push=function(te){let Ae=W(te,re.offsets,i,o+M.charStrings,void 0,g.formatMajor);u.glyphs.push(te,Or.cffGlyphLoader(u,te,yn,Ae,g.formatMajor))};else for(let te=0;te<u.nGlyphs;te+=1){let Ae=re.objects[te];u.glyphs.push(te,Or.cffGlyphLoader(u,te,yn,Ae,g.formatMajor))}if(M.vstore){let te=new st.Parser(i,o+M.vstore);M._vstore=te.parseVariationStore()}}function dr(i,o){let u,h=vr.indexOf(i);return h>=0&&(u=h),h=o.indexOf(i),h>=0?u=h+vr.length:(u=vr.length+o.length,o.push(i)),u}function pr(){return new $e.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function fs(i){let o=new $e.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);o.names=[];for(let u=0;u<i.length;u+=1)o.names.push({name:"name_"+u,type:"NAME",value:i[u]});return o}function ws(i,o,u){let h={};for(let p=0;p<i.length;p+=1){let g=i[p],A=o[g.name];A!==void 0&&!br(A,g.value)&&(g.type==="SID"&&(A=dr(A,u)),h[g.op]={name:g.name,type:g.type,value:A})}return h}function _s(i,o,u){let h=new $e.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=ws(u>1?R:ue,i,o),h}function zi(i){let o=new $e.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return o.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],o}function Zl(i){let o=new $e.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);o.strings=[];for(let u=0;u<i.length;u+=1)o.strings.push({name:"string_"+u,type:"STRING",value:i[u]});return o}function As(){return new $e.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Es(i,o){let u=new $e.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<i.length;h+=1){let p=i[h],g=dr(p,o);u.fields.push({name:"glyph_"+h,type:"SID",value:g})}return u}function di(i,o){let u=[],h=i.path;o<2&&u.push({name:"width",type:"NUMBER",value:i.advanceWidth});let p=0,g=0;for(let A=0;A<h.commands.length;A+=1){let k,E,j=h.commands[A];if(j.type==="Q"){let M=.3333333333333333,re=2/3;j={type:"C",x:j.x,y:j.y,x1:Math.round(M*p+re*j.x1),y1:Math.round(M*g+re*j.y1),x2:Math.round(M*j.x+re*j.x1),y2:Math.round(M*j.y+re*j.y1)}}if(j.type==="M")k=Math.round(j.x-p),E=Math.round(j.y-g),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rmoveto",type:"OP",value:21}),p=Math.round(j.x),g=Math.round(j.y);else if(j.type==="L")k=Math.round(j.x-p),E=Math.round(j.y-g),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rlineto",type:"OP",value:5}),p=Math.round(j.x),g=Math.round(j.y);else if(j.type==="C"){let M=Math.round(j.x1-p),re=Math.round(j.y1-g),te=Math.round(j.x2-j.x1),Ae=Math.round(j.y2-j.y1);k=Math.round(j.x-j.x2),E=Math.round(j.y-j.y2),u.push({name:"dx1",type:"NUMBER",value:M}),u.push({name:"dy1",type:"NUMBER",value:re}),u.push({name:"dx2",type:"NUMBER",value:te}),u.push({name:"dy2",type:"NUMBER",value:Ae}),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rrcurveto",type:"OP",value:8}),p=Math.round(j.x),g=Math.round(j.y)}}return o<2&&u.push({name:"endchar",type:"OP",value:14}),u}function Ca(i,o){let u=new $e.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<i.length;h+=1){let p=i.get(h),g=di(p,o);u.charStrings.push({name:p.name,type:"CHARSTRING",value:g})}return u}function Kl(i,o,u){let h=new $e.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=ws(u>1?X:U,i,o),h}function Wn(i,o){let u=new $e.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),h=1/o.unitsPerEm,p={version:o.version,fullName:o.fullName,familyName:o.familyName,weight:o.weightName,fontBBox:o.fontBBox||[0,0,0,0],fontMatrix:[h,0,0,h,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},g=o&&o.topDict||{};g.paintType&&(p.paintType=g.paintType,p.strokeWidth=g.strokeWidth||0);let A={},k=[],E;for(let te=1;te<i.length;te+=1)E=i.get(te),k.push(E.name);let j=[];u.header=pr(),u.nameIndex=fs([o.postScriptName]);let M=_s(p,j);u.topDictIndex=zi(M),u.globalSubrIndex=As(),u.charsets=Es(k,j),u.charStringsIndex=Ca(i,1),u.privateDict=Kl(A,j),u.stringIndex=Zl(j);let re=u.header.sizeOf()+u.nameIndex.sizeOf()+u.topDictIndex.sizeOf()+u.stringIndex.sizeOf()+u.globalSubrIndex.sizeOf();return p.charset=re,p.encoding=0,p.charStrings=p.charset+u.charsets.sizeOf(),p.private[1]=p.charStrings+u.charStringsIndex.sizeOf(),M=_s(p,j),u.topDictIndex=zi(M),u}var os={parse:gn,make:Wn};function Ns(i,o){let u={},h=new st.Parser(i,o);return u.version=h.parseVersion(),u.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,u.checkSumAdjustment=h.parseULong(),u.magicNumber=h.parseULong(),me.argument(u.magicNumber===1594834165,"Font header has wrong magic number."),u.flags=h.parseUShort(),u.unitsPerEm=h.parseUShort(),u.created=h.parseLongDateTime(),u.modified=h.parseLongDateTime(),u.xMin=h.parseShort(),u.yMin=h.parseShort(),u.xMax=h.parseShort(),u.yMax=h.parseShort(),u.macStyle=h.parseUShort(),u.lowestRecPPEM=h.parseUShort(),u.fontDirectionHint=h.parseShort(),u.indexToLocFormat=h.parseShort(),u.glyphDataFormat=h.parseShort(),u}function no(i){let o=Math.round(new Date().getTime()/1e3)+2082844800,u=o,h=i.macStyle||0;return i.createdTimestamp&&(u=i.createdTimestamp+2082844800),new $e.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:u},{name:"modified",type:"LONGDATETIME",value:o},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],i)}var Hs={parse:Ns,make:no};function _l(i,o){let u={},h=new st.Parser(i,o);return u.version=h.parseVersion(),u.ascender=h.parseShort(),u.descender=h.parseShort(),u.lineGap=h.parseShort(),u.advanceWidthMax=h.parseUShort(),u.minLeftSideBearing=h.parseShort(),u.minRightSideBearing=h.parseShort(),u.xMaxExtent=h.parseShort(),u.caretSlopeRise=h.parseShort(),u.caretSlopeRun=h.parseShort(),u.caretOffset=h.parseShort(),h.relativeOffset+=8,u.metricDataFormat=h.parseShort(),u.numberOfHMetrics=h.parseUShort(),u}function za(i){return new $e.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],i)}var Pn={parse:_l,make:za};function Li(i,o,u,h,p){let g,A,k=new st.Parser(i,o);for(let E=0;E<h;E+=1){E<u&&(g=k.parseUShort(),A=k.parseShort());let j=p.get(E);j.advanceWidth=g,j.leftSideBearing=A}}function Ha(i,o,u,h,p){i._hmtxTableData={};let g,A,k=new st.Parser(o,u);for(let E=0;E<p;E+=1)E<h&&(g=k.parseUShort(),A=k.parseShort()),i._hmtxTableData[E]={advanceWidth:g,leftSideBearing:A}}function Mo(i,o,u,h,p,g,A){A.lowMemory?Ha(i,o,u,h,p):Li(o,u,h,p,g)}function hi(i){let o=new $e.Table("hmtx",[]);for(let u=0;u<i.length;u+=1){let h=i.get(u),p=h.advanceWidth||0,g=h.leftSideBearing||0;o.fields.push({name:"advanceWidth_"+u,type:"USHORT",value:p}),o.fields.push({name:"leftSideBearing_"+u,type:"SHORT",value:g})}return o}var On={parse:Mo,make:hi};function Js(i){let o=new $e.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:i.length}]),u="",h=12+i.length*4;for(let p=0;p<i.length;++p){let g=u.indexOf(i[p]);g<0&&(g=u.length,u+=i[p]),o.fields.push({name:"offset "+p,type:"USHORT",value:h+g}),o.fields.push({name:"length "+p,type:"USHORT",value:i[p].length})}return o.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),o}function ls(i,o){let u=new st.Parser(i,o),h=u.parseULong();me.argument(h===1,"Unsupported ltag table version."),u.skip("uLong",1);let p=u.parseULong(),g=[];for(let A=0;A<p;A++){let k="",E=o+u.parseUShort(),j=u.parseUShort();for(let M=E;M<E+j;++M)k+=String.fromCharCode(i.getInt8(M));g.push(k)}return g}var Wa={make:Js,parse:ls};function ps(i,o){let u={},h=new st.Parser(i,o);return u.version=h.parseVersion(),u.numGlyphs=h.parseUShort(),u.version===1&&(u.maxPoints=h.parseUShort(),u.maxContours=h.parseUShort(),u.maxCompositePoints=h.parseUShort(),u.maxCompositeContours=h.parseUShort(),u.maxZones=h.parseUShort(),u.maxTwilightPoints=h.parseUShort(),u.maxStorage=h.parseUShort(),u.maxFunctionDefs=h.parseUShort(),u.maxInstructionDefs=h.parseUShort(),u.maxStackElements=h.parseUShort(),u.maxSizeOfInstructions=h.parseUShort(),u.maxComponentElements=h.parseUShort(),u.maxComponentDepth=h.parseUShort()),u}function tl(i){return new $e.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}var ia={parse:ps,make:tl},rl=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function _a(i){for(let o=0;o<rl.length;o+=1){let u=rl[o];if(i>=u.begin&&i<u.end)return o}return-1}function jo(i,o){let u={},h=new st.Parser(i,o);u.version=h.parseUShort(),u.xAvgCharWidth=h.parseShort(),u.usWeightClass=h.parseUShort(),u.usWidthClass=h.parseUShort(),u.fsType=h.parseUShort(),u.ySubscriptXSize=h.parseShort(),u.ySubscriptYSize=h.parseShort(),u.ySubscriptXOffset=h.parseShort(),u.ySubscriptYOffset=h.parseShort(),u.ySuperscriptXSize=h.parseShort(),u.ySuperscriptYSize=h.parseShort(),u.ySuperscriptXOffset=h.parseShort(),u.ySuperscriptYOffset=h.parseShort(),u.yStrikeoutSize=h.parseShort(),u.yStrikeoutPosition=h.parseShort(),u.sFamilyClass=h.parseShort(),u.panose=[];for(let p=0;p<10;p++)u.panose[p]=h.parseByte();return u.ulUnicodeRange1=h.parseULong(),u.ulUnicodeRange2=h.parseULong(),u.ulUnicodeRange3=h.parseULong(),u.ulUnicodeRange4=h.parseULong(),u.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),u.fsSelection=h.parseUShort(),u.usFirstCharIndex=h.parseUShort(),u.usLastCharIndex=h.parseUShort(),u.sTypoAscender=h.parseShort(),u.sTypoDescender=h.parseShort(),u.sTypoLineGap=h.parseShort(),u.usWinAscent=h.parseUShort(),u.usWinDescent=h.parseUShort(),u.version>=1&&(u.ulCodePageRange1=h.parseULong(),u.ulCodePageRange2=h.parseULong()),u.version>=2&&(u.sxHeight=h.parseShort(),u.sCapHeight=h.parseShort(),u.usDefaultChar=h.parseUShort(),u.usBreakChar=h.parseUShort(),u.usMaxContent=h.parseUShort()),u}function so(i){return new $e.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],i)}var Do={parse:jo,make:so,unicodeRanges:rl,getUnicodeRange:_a};function ka(i,o){let u={},h=new st.Parser(i,o);switch(u.version=h.parseVersion(),u.italicAngle=h.parseFixed(),u.underlinePosition=h.parseShort(),u.underlineThickness=h.parseShort(),u.isFixedPitch=h.parseULong(),u.minMemType42=h.parseULong(),u.maxMemType42=h.parseULong(),u.minMemType1=h.parseULong(),u.maxMemType1=h.parseULong(),u.version){case 1:u.names=mn.slice();break;case 2:u.numberOfGlyphs=h.parseUShort(),u.glyphNameIndex=new Array(u.numberOfGlyphs);for(let p=0;p<u.numberOfGlyphs;p++)u.glyphNameIndex[p]=h.parseUShort();u.names=[];for(let p=0;p<u.numberOfGlyphs;p++)if(u.glyphNameIndex[p]>=mn.length){let g=h.parseChar();u.names.push(h.parseString(g))}break;case 2.5:u.numberOfGlyphs=h.parseUShort(),u.offset=new Array(u.numberOfGlyphs);for(let p=0;p<u.numberOfGlyphs;p++)u.offset[p]=h.parseChar();break}return u}function Xl(i){let{italicAngle:o=Math.round((i.italicAngle||0)*65536),underlinePosition:u=0,underlineThickness:h=0,isFixedPitch:p=0,minMemType42:g=0,maxMemType42:A=0,minMemType1:k=0,maxMemType1:E=0}=i.tables.post||{};return new $e.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:o},{name:"underlinePosition",type:"FWORD",value:u},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:p},{name:"minMemType42",type:"ULONG",value:g},{name:"maxMemType42",type:"ULONG",value:A},{name:"minMemType1",type:"ULONG",value:k},{name:"maxMemType1",type:"ULONG",value:E}])}var fi={parse:ka,make:Xl},ei=new Array(9);ei[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(we.coverage),deltaGlyphId:this.parseShort()};if(o===2)return{substFormat:2,coverage:this.parsePointer(we.coverage),substitute:this.parseOffset16List()};me.assert(!1,"0x"+i.toString(16)+": lookup type 1 format must be 1 or 2.")},ei[2]=function(){let i=this.parseUShort();return me.argument(i===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(we.coverage),sequences:this.parseListOfLists()}},ei[3]=function(){let i=this.parseUShort();return me.argument(i===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(we.coverage),alternateSets:this.parseListOfLists()}},ei[4]=function(){let i=this.parseUShort();return me.argument(i===1,"GSUB ligature table identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(we.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var pi={sequenceIndex:we.uShort,lookupListIndex:we.uShort};ei[5]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:o,coverage:this.parsePointer(we.coverage),ruleSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{input:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,pi)}})};if(o===2)return{substFormat:o,coverage:this.parsePointer(we.coverage),classDef:this.parsePointer(we.classDef),classSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{classes:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,pi)}})};if(o===3){let u=this.parseUShort(),h=this.parseUShort();return{substFormat:o,coverages:this.parseList(u,we.pointer(we.coverage)),lookupRecords:this.parseRecordList(h,pi)}}me.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},ei[6]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(we.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(pi)}})};if(o===2)return{substFormat:2,coverage:this.parsePointer(we.coverage),backtrackClassDef:this.parsePointer(we.classDef),inputClassDef:this.parsePointer(we.classDef),lookaheadClassDef:this.parsePointer(we.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(pi)}})};if(o===3)return{substFormat:3,backtrackCoverage:this.parseList(we.pointer(we.coverage)),inputCoverage:this.parseList(we.pointer(we.coverage)),lookaheadCoverage:this.parseList(we.pointer(we.coverage)),lookupRecords:this.parseRecordList(pi)};me.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},ei[7]=function(){let i=this.parseUShort();me.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let o=this.parseUShort(),u=new we(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:o,extension:ei[o].call(u)}},ei[8]=function(){let i=this.parseUShort();return me.argument(i===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(we.coverage),backtrackCoverage:this.parseList(we.pointer(we.coverage)),lookaheadCoverage:this.parseList(we.pointer(we.coverage)),substitutes:this.parseUShortList()}};function nl(i,o){o=o||0;let u=new we(i,o),h=u.parseVersion(1);return me.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(ei)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(ei),variations:u.parseFeatureVariationsList()}}var aa=new Array(9);aa[1]=function(i){if(i.substFormat===1)return new $e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new $e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.ushortList("substitute",i.substitute)));me.fail("Lookup type 1 substFormat must be 1 or 2.")},aa[2]=function(i){return me.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new $e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.tableList("seqSet",i.sequences,function(o){return new $e.Table("sequenceSetTable",$e.ushortList("sequence",o))})))},aa[3]=function(i){return me.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new $e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.tableList("altSet",i.alternateSets,function(o){return new $e.Table("alternateSetTable",$e.ushortList("alternate",o))})))},aa[4]=function(i){return me.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new $e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.tableList("ligSet",i.ligatureSets,function(o){return new $e.Table("ligatureSetTable",$e.tableList("ligature",o,function(u){return new $e.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:u.ligGlyph}].concat($e.ushortList("component",u.components,u.components.length+1)))}))})))},aa[5]=function(i){if(i.substFormat===1)return new $e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.tableList("sequenceRuleSet",i.ruleSets,function(o){return o?new $e.Table("sequenceRuleSetTable",$e.tableList("sequenceRule",o,function(u){let h=$e.ushortList("seqLookup",[],u.lookupRecords.length).concat($e.ushortList("inputSequence",u.input,u.input.length+1));[h[0],h[1]]=[h[1],h[0]];for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new $e.Table("sequenceRuleTable",h)})):new $e.Table("NULL",null)})));if(i.substFormat===2)return new $e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new $e.ClassDef(i.classDef)}].concat($e.tableList("classSeqRuleSet",i.classSets,function(o){return o?new $e.Table("classSeqRuleSetTable",$e.tableList("classSeqRule",o,function(u){let h=$e.ushortList("classes",u.classes,u.classes.length+1).concat($e.ushortList("seqLookupCount",[],u.lookupRecords.length));for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new $e.Table("classSeqRuleTable",h)})):new $e.Table("NULL",null)})));if(i.substFormat===3){let o=[{name:"substFormat",type:"USHORT",value:i.substFormat}];o.push({name:"inputGlyphCount",type:"USHORT",value:i.coverages.length}),o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.coverages.length;u++){let h=i.coverages[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new $e.Coverage(h)})}for(let u=0;u<i.lookupRecords.length;u++){let h=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:h.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:h.lookupListIndex})}return new $e.Table("contextualSubstitutionTable",o)}me.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},aa[6]=function(i){if(i.substFormat===1)return new $e.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new $e.Coverage(i.coverage)}].concat($e.tableList("chainRuleSet",i.chainRuleSets,function(o){return new $e.Table("chainRuleSetTable",$e.tableList("chainRule",o,function(u){let h=$e.ushortList("backtrackGlyph",u.backtrack,u.backtrack.length).concat($e.ushortList("inputGlyph",u.input,u.input.length+1)).concat($e.ushortList("lookaheadGlyph",u.lookahead,u.lookahead.length)).concat($e.ushortList("substitution",[],u.lookupRecords.length));for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new $e.Table("chainRuleTable",h)}))})));if(i.substFormat===2)me.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(i.substFormat===3){let o=[{name:"substFormat",type:"USHORT",value:i.substFormat}];o.push({name:"backtrackGlyphCount",type:"USHORT",value:i.backtrackCoverage.length});for(let u=0;u<i.backtrackCoverage.length;u++){let h=i.backtrackCoverage[u];o.push({name:"backtrackCoverage"+u,type:"TABLE",value:new $e.Coverage(h)})}o.push({name:"inputGlyphCount",type:"USHORT",value:i.inputCoverage.length});for(let u=0;u<i.inputCoverage.length;u++){let h=i.inputCoverage[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new $e.Coverage(h)})}o.push({name:"lookaheadGlyphCount",type:"USHORT",value:i.lookaheadCoverage.length});for(let u=0;u<i.lookaheadCoverage.length;u++){let h=i.lookaheadCoverage[u];o.push({name:"lookaheadCoverage"+u,type:"TABLE",value:new $e.Coverage(h)})}o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.lookupRecords.length;u++){let h=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:h.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:h.lookupListIndex})}return new $e.Table("chainContextTable",o)}me.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function ks(i){return new $e.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new $e.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new $e.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new $e.LookupList(i.lookups,aa)}])}var Hi={parse:nl,make:ks};function La(i,o){let u=new st.Parser(i,o),h=u.parseULong();me.argument(h===1,"Unsupported META table version."),u.parseULong(),u.parseULong();let p=u.parseULong(),g={};for(let A=0;A<p;A++){let k=u.parseTag(),E=u.parseULong(),j=u.parseULong();if(k==="appl"||k==="bild")continue;let M=ke.UTF8(i,o+E,j);g[k]=M}return g}function Ia(i){let o=Object.keys(i).length,u="",h=16+o*12,p=new $e.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:o}]);for(let g in i){let A=u.length;u+=i[g],p.fields.push({name:"tag "+g,type:"TAG",value:g}),p.fields.push({name:"offset "+g,type:"ULONG",value:h+A}),p.fields.push({name:"length "+g,type:"ULONG",value:i[g].length})}return p.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),p}var mi={parse:La,make:Ia};function _c(i,o){let u=new we(i,o),h=u.parseUShort();h!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let p=u.parseUShort(),g=u.parseOffset32(),A=u.parseOffset32(),k=u.parseUShort();u.relativeOffset=g;let E=u.parseRecordList(p,{glyphID:we.uShort,firstLayerIndex:we.uShort,numLayers:we.uShort});u.relativeOffset=A;let j=u.parseRecordList(k,{glyphID:we.uShort,paletteIndex:we.uShort});return{version:h,baseGlyphRecords:E,layerRecords:j}}function kc({version:i=0,baseGlyphRecords:o=[],layerRecords:u=[]}){me.argument(i===0,"Only COLRv0 supported.");let h=14,p=h+o.length*6;return new $e.Table("COLR",[{name:"version",type:"USHORT",value:i},{name:"numBaseGlyphRecords",type:"USHORT",value:o.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:p},{name:"numLayerRecords",type:"USHORT",value:u.length},...o.map((g,A)=>[{name:"glyphID_"+A,type:"USHORT",value:g.glyphID},{name:"firstLayerIndex_"+A,type:"USHORT",value:g.firstLayerIndex},{name:"numLayers_"+A,type:"USHORT",value:g.numLayers}]).flat(),...u.map((g,A)=>[{name:"LayerGlyphID_"+A,type:"USHORT",value:g.glyphID},{name:"paletteIndex_"+A,type:"USHORT",value:g.paletteIndex}]).flat()])}var Jl={parse:_c,make:kc};function Ws(i,o){return[{name:"tag_"+i,type:"TAG",value:o.tag},{name:"minValue_"+i,type:"FIXED",value:o.minValue<<16},{name:"defaultValue_"+i,type:"FIXED",value:o.defaultValue<<16},{name:"maxValue_"+i,type:"FIXED",value:o.maxValue<<16},{name:"flags_"+i,type:"USHORT",value:0},{name:"nameID_"+i,type:"USHORT",value:o.axisNameID}]}function ti(i,o,u){let h={},p=new st.Parser(i,o);h.tag=p.parseTag(),h.minValue=p.parseFixed(),h.defaultValue=p.parseFixed(),h.maxValue=p.parseFixed(),p.skip("uShort",1);let g=p.parseUShort();return h.axisNameID=g,h.name=Xe(u,g),h}function Wi(i,o,u,h={}){let p=[{name:"nameID_"+i,type:"USHORT",value:o.subfamilyNameID},{name:"flags_"+i,type:"USHORT",value:0}];for(let g=0;g<u.length;++g){let A=u[g].tag;p.push({name:"axis_"+i+" "+A,type:"FIXED",value:o.coordinates[A]<<16})}return h&&h.postScriptNameID&&p.push({name:"postScriptNameID_",type:"USHORT",value:o.postScriptNameID!==void 0?o.postScriptNameID:65535}),p}function Ea(i,o,u,h,p){let g={},A=new st.Parser(i,o),k=A.parseUShort();g.subfamilyNameID=k,g.name=Xe(h,k,[2,17]),A.skip("uShort",1),g.coordinates={};for(let j=0;j<u.length;++j)g.coordinates[u[j].tag]=A.parseFixed();if(A.relativeOffset===p)return g.postScriptNameID=void 0,g.postScriptName=void 0,g;let E=A.parseUShort();return g.postScriptNameID=E==65535?void 0:E,g.postScriptName=g.postScriptNameID!==void 0?Xe(h,E,[6]):"",g}function oa(i,o){let u=new $e.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:i.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:i.instances.length},{name:"instanceSize",type:"USHORT",value:4+i.axes.length*4}]);u.offsetToData=u.sizeOf();for(let p=0;p<i.axes.length;p++)u.fields=u.fields.concat(Ws(p,i.axes[p],o));let h={};for(let p=0;p<i.instances.length;p++)if(i.instances[p].postScriptNameID!==void 0){u.instanceSize+=2,h.postScriptNameID=!0;break}for(let p=0;p<i.instances.length;p++)u.fields=u.fields.concat(Wi(p,i.instances[p],i.axes,h));return u}function Bo(i,o,u){let h=new st.Parser(i,o),p=h.parseULong();me.argument(p===65536,"Unsupported fvar table version.");let g=h.parseOffset16();h.skip("uShort",1);let A=h.parseUShort(),k=h.parseUShort(),E=h.parseUShort(),j=h.parseUShort(),M=[];for(let Ae=0;Ae<A;Ae++)M.push(ti(i,o+g+Ae*k,u));let re=[],te=o+g+A*k;for(let Ae=0;Ae<E;Ae++)re.push(Ea(i,te+Ae*j,M,u,j));return{axes:M,instances:re}}var Ts={make:oa,parse:Bo},Na={tag:we.tag,nameID:we.uShort,ordering:we.uShort},cs=new Array(5);cs[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},cs[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},cs[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},cs[4]=function(){let i=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(i,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function ts(){let i=this.parseUShort(),o=cs[i],u={format:i};return o===void 0?(console.warn(`Unknown axis value table format ${i}`),u):Object.assign(u,this.parseStruct(o.bind(this)))}function Ss(i,o,u){o||(o=0);let h=new st.Parser(i,o),p=h.parseUShort(),g=h.parseUShort();p!==1&&console.warn(`Unsupported STAT table version ${p}.${g}`);let A=[p,g],k=h.parseUShort(),E=h.parseUShort(),j=h.parseOffset32(),M=h.parseUShort(),re=h.parseOffset32(),te=p>1||g>0?h.parseUShort():void 0;u!==void 0&&me.argument(E>=u.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),M>0&&me.argument(E>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let Ae=[];for(let pt=0;pt<E;pt++)h.offset=o+j,h.relativeOffset=pt*k,Ae.push(h.parseStruct(Na));h.offset=o,h.relativeOffset=re;let fe=h.parseUShortList(M),je=[];for(let pt=0;pt<M;pt++)h.offset=o+re,h.relativeOffset=fe[pt],je.push(ts.apply(h));return{version:A,axes:Ae,values:je,elidedFallbackNameID:te}}var ri=new Array(5);ri[1]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:1},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`value${i}`,type:"FLOAT",value:o.value}]},ri[2]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:2},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`nominalValue${i}`,type:"FLOAT",value:o.nominalValue},{name:`rangeMinValue${i}`,type:"FLOAT",value:o.rangeMinValue},{name:`rangeMaxValue${i}`,type:"FLOAT",value:o.rangeMaxValue}]},ri[3]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:3},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`value${i}`,type:"FLOAT",value:o.value},{name:`linkedValue${i}`,type:"FLOAT",value:o.linkedValue}]},ri[4]=function(i,o){let u=[{name:`format${i}`,type:"USHORT",value:4},{name:`axisCount${i}`,type:"USHORT",value:o.axisValues.length},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID}];for(let h=0;h<o.axisValues.length;h++)u=u.concat([{name:`format${i}axisIndex${h}`,type:"USHORT",value:o.axisValues[h].axisIndex},{name:`format${i}value${h}`,type:"FLOAT",value:o.axisValues[h].value}]);return u};function Qo(i,o){return new $e.Record("axisRecord_"+i,[{name:"axisTag_"+i,type:"TAG",value:o.tag},{name:"axisNameID_"+i,type:"USHORT",value:o.nameID},{name:"axisOrdering_"+i,type:"USHORT",value:o.ordering}])}function Ga(i,o){let u=o.format,h=ri[u];me.argument(h!==void 0,`Unknown axis value table format ${u}`);let p=h(i,o);return new $e.Table("axisValueTable_"+i,p)}function la(i){let o=new $e.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:i.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:i.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:i.elidedFallbackNameID}]);o.designAxesOffset=o.offsetToAxisValueOffsets=o.sizeOf();for(let g=0;g<i.axes.length;g++){let A=Qo(g,i.axes[g]);o.offsetToAxisValueOffsets+=A.sizeOf(),o.fields=o.fields.concat(A.fields)}let u=[],h=[],p=i.values.length*2;for(let g=0;g<i.values.length;g++){let A=Ga(g,i.values[g]);u.push({name:"offset_"+g,type:"USHORT",value:p}),p+=A.sizeOf(),h=h.concat(A.fields)}return o.fields=o.fields.concat(u),o.fields=o.fields.concat(h),o}var Ii={make:la,parse:Ss};function io(i,o){return new $e.Record("axisValueMap_"+i,[{name:"fromCoordinate_"+i,type:"F2DOT14",value:o.fromCoordinate},{name:"toCoordinate_"+i,type:"F2DOT14",value:o.toCoordinate}])}function Gi(i,o){let u=new $e.Record("segmentMap_"+i,[{name:"positionMapCount_"+i,type:"USHORT",value:o.axisValueMaps.length}]),h=[];for(let p=0;p<o.axisValueMaps.length;p++){let g=io(`${i}_${p}`,o.axisValueMaps[p]);h=h.concat(g.fields)}return u.fields=u.fields.concat(h),u}function Ra(i,o){me.argument(i.axisSegmentMaps.length===o.axes.length,"avar axis count must correspond to fvar axis count");let u=new $e.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:i.axisSegmentMaps.length}]);for(let h=0;h<i.axisSegmentMaps.length;h++){let p=Gi(h,i.axisSegmentMaps[h]);u.fields=u.fields.concat(p.fields)}return u}function Vi(i,o,u){o||(o=0);let h=new we(i,o),p=h.parseUShort(),g=h.parseUShort();p!==1&&console.warn(`Unsupported avar table version ${p}.${g}`),h.skip("uShort",1);let A=h.parseUShort();me.argument(A===u.axes.length,"avar axis count must correspond to fvar axis count");let k=[];for(let E=0;E<A;E++){let j=[],M=h.parseUShort();for(let re=0;re<M;re++){let te=h.parseF2Dot14(),Ae=h.parseF2Dot14();j.push({fromCoordinate:te,toCoordinate:Ae})}k.push({axisValueMaps:j})}return{version:[p,g],axisSegmentMaps:k}}var ca={make:Ra,parse:Vi};function Rs(i,o,u,h){let p=new st.Parser(i,o),g=p.parseTupleVariationStore(p.relativeOffset,u.axes.length,"cvar",h),A=p.parseUShort(),k=p.parseUShort();return A!==1&&console.warn(`Unsupported cvar table version ${A}.${k}`),{version:[A,k],...g}}function Ei(){console.warn("Writing of cvar tables is not yet supported.")}var ao={make:Ei,parse:Rs};function Ma(i,o,u,h){let p=new st.Parser(i,o),g=p.parseUShort(),A=p.parseUShort();g!==1&&console.warn(`Unsupported gvar table version ${g}.${A}`);let k=p.parseUShort();k!==u.axes.length&&console.warn(`axisCount ${k} in gvar table does not match the number of axes ${u.axes.length} in the fvar table!`);let E=p.parseUShort(),j=p.parsePointer32(function(){return this.parseTupleRecords(E,k)}),M=p.parseTupleVariationStoreList(k,"gvar",h);return{version:[g,A],sharedTuples:j,glyphVariations:M}}function Ni(){console.warn("Writing of gvar tables is not yet supported.")}var oo={make:Ni,parse:Ma};function ec(i,o){let u={},h=new st.Parser(i,o);u.version=h.parseUShort(),me.argument(u.version<=1,"Unsupported gasp table version."),u.numRanges=h.parseUShort(),u.gaspRanges=[];for(let p=0;p<u.numRanges;p++)u.gaspRanges[p]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return u}function kl(i){let o=new $e.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:i.numRanges}]);for(let u in i.gaspRanges)o.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:i.gaspRanges[u].rangeMaxPPEM}),o.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:i.gaspRanges[u].rangeGaspBehavior});return o}var Po={parse:ec,make:kl};function ce(i,o){let u=new Map,h=i.buffer,p=new we(i,o);if(p.parseUShort()!==0)return u;p.relativeOffset=p.parseOffset32();let g=i.byteOffset+o+p.relativeOffset,A=p.parseUShort(),k=new Map;for(let E=0;E<A;E++){let j=p.parseUShort(),M=p.parseUShort(),re=g+p.parseOffset32(),te=p.parseULong(),Ae=k.get(re);Ae===void 0&&(Ae=new Uint8Array(h,re,te),k.set(re,Ae));for(let fe=j;fe<=M;fe++)u.set(fe,Ae)}return u}function Ge(i){let o=Array.from(i.keys()).sort(),u=[],h=[],p=new Map,g=0,A={endGlyphID:null};for(let te=0,Ae=o.length;te<Ae;te++){let fe=o[te],je=i.get(fe),pt=p.get(je);pt===void 0&&(pt=g,h.push(je),p.set(je,pt),g+=je.byteLength),fe-1===A.endGlyphID&&pt===A.svgDocOffset?A.endGlyphID=fe:(A={startGlyphID:fe,endGlyphID:fe,svgDocOffset:pt,svgDocLength:je.byteLength},u.push(A))}let k=u.length,E=h.length,j=2+k*12,M=new Array(4+k*4+E),re=0;M[re++]={name:"version",type:"USHORT",value:0},M[re++]={name:"svgDocumentListOffset",type:"ULONG",value:10},M[re++]={name:"reserved",type:"ULONG",value:0},M[re++]={name:"numEntries",type:"USHORT",value:k};for(let te=0;te<k;te++){let Ae="documentRecord_"+te,{startGlyphID:fe,endGlyphID:je,svgDocOffset:pt,svgDocLength:Tr}=u[te];M[re++]={name:Ae+"_startGlyphID",type:"USHORT",value:fe},M[re++]={name:Ae+"_endGlyphID",type:"USHORT",value:je},M[re++]={name:Ae+"_svgDocOffset",type:"ULONG",value:j+pt},M[re++]={name:Ae+"_svgDocLength",type:"ULONG",value:Tr}}for(let te=0;te<E;te++)M[re++]={name:"svgDoc_"+te,type:"LITERAL",value:h[te]};return new $e.Table("SVG ",M)}var vt={make:Ge,parse:ce};function Lt(i){return Math.log(i)/Math.log(2)|0}function et(i){for(;i.length%4!==0;)i.push(0);let o=0;for(let u=0;u<i.length;u+=4)o+=(i[u]<<24)+(i[u+1]<<16)+(i[u+2]<<8)+i[u+3];return o%=Math.pow(2,32),o}function Rt(i,o,u,h){return new $e.Record("Table Record",[{name:"tag",type:"TAG",value:i!==void 0?i:""},{name:"checkSum",type:"ULONG",value:o!==void 0?o:0},{name:"offset",type:"ULONG",value:u!==void 0?u:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function cr(i){let o=new $e.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);o.tables=i,o.numTables=i.length;let u=Math.pow(2,Lt(o.numTables));o.searchRange=16*u,o.entrySelector=Lt(u),o.rangeShift=o.numTables*16-o.searchRange;let h=[],p=[],g=o.sizeOf()+Rt().sizeOf()*o.numTables;for(;g%4!==0;)g+=1,p.push({name:"padding",type:"BYTE",value:0});for(let A=0;A<i.length;A+=1){let k=i[A];me.argument(k.tableName.length===4,"Table name"+k.tableName+" is invalid.");let E=k.sizeOf(),j=Rt(k.tableName,et(k.encode()),g,E);for(h.push({name:j.tag+" Table Record",type:"RECORD",value:j}),p.push({name:k.tableName+" table",type:"RECORD",value:k}),g+=E,me.argument(!isNaN(g),"Something went wrong calculating the offset.");g%4!==0;)g+=1,p.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(A,k){return A.value.tag>k.value.tag?1:-1}),o.fields=o.fields.concat(h),o.fields=o.fields.concat(p),o}function Lr(i,o,u){for(let h=0;h<o.length;h+=1){let p=i.charToGlyphIndex(o[h]);if(p>0)return i.glyphs.get(p).getMetrics()}return u}function I(i){let o=0;for(let u=0;u<i.length;u+=1)o+=i[u];return o/i.length}function B(i){let o=[],u=[],h=[],p=[],g=[],A=[],k=[],E,j=0,M=0,re=0,te=0,Ae=0;for(let us=0;us<i.glyphs.length;us+=1){let Da=i.glyphs.get(us),go=Da.unicode|0;if(isNaN(Da.advanceWidth))throw new Error("Glyph "+Da.name+" ("+us+"): advanceWidth is not a number.");(E>go||E===void 0)&&go>0&&(E=go),j<go&&(j=go);let Vo=Do.getUnicodeRange(go);if(Vo<32)M|=1<<Vo;else if(Vo<64)re|=1<<Vo-32;else if(Vo<96)te|=1<<Vo-64;else if(Vo<123)Ae|=1<<Vo-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(Da.name===".notdef")continue;let Ml=Da.getMetrics();o.push(Ml.xMin),u.push(Ml.yMin),h.push(Ml.xMax),p.push(Ml.yMax),A.push(Ml.leftSideBearing),k.push(Ml.rightSideBearing),g.push(Da.advanceWidth)}let fe={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,p),advanceWidthMax:Math.max.apply(null,g),advanceWidthAvg:I(g),minLeftSideBearing:Math.min.apply(null,A),maxLeftSideBearing:Math.max.apply(null,A),minRightSideBearing:Math.min.apply(null,k)};fe.ascender=i.ascender,fe.descender=i.descender;let je=0;i.weightClass>=600&&(je|=i.macStyleValues.BOLD),i.italicAngle<0&&(je|=i.macStyleValues.ITALIC);let pt=Hs.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:fe.xMin,yMin:fe.yMin,xMax:fe.xMax,yMax:fe.yMax,lowestRecPPEM:3,macStyle:je,createdTimestamp:i.createdTimestamp}),Tr=Pn.make({ascender:fe.ascender,descender:fe.descender,advanceWidthMax:fe.advanceWidthMax,minLeftSideBearing:fe.minLeftSideBearing,minRightSideBearing:fe.minRightSideBearing,xMaxExtent:fe.maxLeftSideBearing+(fe.xMax-fe.xMin),numberOfHMetrics:i.glyphs.length}),fr=ia.make(i.glyphs.length),Pr=Do.make(Object.assign({xAvgCharWidth:Math.round(fe.advanceWidthAvg),usFirstCharIndex:E,usLastCharIndex:j,ulUnicodeRange1:M,ulUnicodeRange2:re,ulUnicodeRange3:te,ulUnicodeRange4:Ae,sTypoAscender:fe.ascender,sTypoDescender:fe.descender,sTypoLineGap:0,usWinAscent:fe.yMax,usWinDescent:Math.abs(fe.yMin),ulCodePageRange1:1,sxHeight:Lr(i,"xyvw",{yMax:Math.round(fe.ascender/2)}).yMax,sCapHeight:Lr(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",fe).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0},i.tables.os2)),cn=On.make(i.glyphs),Vn=Xr.make(i.glyphs),rs=i.getEnglishName("fontFamily"),ns=i.getEnglishName("fontSubfamily"),Gs=rs+" "+ns,Wo=i.getEnglishName("postScriptName");Wo||(Wo=rs.replace(/\s/g,"")+"-"+ns);let un={};for(let us in i.names)un[us]=i.names[us];un.unicode=un.unicode||{},un.macintosh=un.macintosh||{},un.windows=un.windows||{};let Ya=i.names.unicode||{},fa=i.names.macintosh||{},Sr=i.names.windows||{};for(let us in un){if(un[us]=un[us]||{},!un[us].uniqueID){let Da=i.getEnglishName("manufacturer")||"";un[us].uniqueID={en:`${Da}: ${Gs}`}}un[us].postScriptName||(un[us].postScriptName={en:Wo})}un.unicode.preferredFamily||(un.unicode.preferredFamily=Ya.fontFamily||fa.fontFamily||Sr.fontFamily),un.macintosh.preferredFamily||(un.macintosh.preferredFamily=fa.fontFamily||Ya.fontFamily||Sr.fontFamily),un.windows.preferredFamily||(un.windows.preferredFamily=Sr.fontFamily||Ya.fontFamily||fa.fontFamily),un.unicode.preferredSubfamily||(un.unicode.preferredSubfamily=Ya.fontSubfamily||fa.fontSubfamily||Sr.fontSubfamily),un.macintosh.preferredSubfamily||(un.macintosh.preferredSubfamily=fa.fontSubfamily||Ya.fontSubfamily||Sr.fontSubfamily),un.windows.preferredSubfamily||(un.windows.preferredSubfamily=Sr.fontSubfamily||Ya.fontSubfamily||fa.fontSubfamily);let or=[],hr=Dt.make(un,or),Xi=or.length>0?Wa.make(or):void 0,cc=fi.make(i),ph=os.make(i.glyphs,{version:i.getEnglishName("version"),fullName:Gs,familyName:rs,weightName:ns,postScriptName:Wo,unitsPerEm:i.unitsPerEm,fontBBox:[0,fe.yMin,fe.ascender,fe.advanceWidthMax],topDict:i.tables.cff&&i.tables.cff.topDict||{}}),Rc=i.metas&&Object.keys(i.metas).length>0?mi.make(i.metas):void 0,Go=[pt,Tr,fr,Pr,hr,Vn,cc,ph,cn];Xi&&Go.push(Xi);let pa={gsub:Hi,cpal:rn,colr:Jl,stat:Ii,avar:ca,cvar:ao,fvar:Ts,gvar:oo,gasp:Po,svg:vt},mo={avar:[i.tables.fvar],fvar:[i.names]};for(let us in pa){let Da=i.tables[us];if(Da){let go=pa[us].make.call(i,Da,...mo[us]||[]);go&&Go.push(go)}}Rc&&Go.push(Rc);let Ji=cr(Go),Za=Ji.encode(),ma=et(Za),ga=Ji.fields,$s=!1;for(let us=0;us<ga.length;us+=1)if(ga[us].name==="head table"){ga[us].value.checkSumAdjustment=2981146554-ma,$s=!0;break}if(!$s)throw new Error("Could not find head table with checkSum to adjust.");return Ji}var $={make:cr,fontToTable:B,computeCheckSum:et};function q(i,o){let u=0,h=i.length-1;for(;u<=h;){let p=u+h>>>1,g=i[p].tag;if(g===o)return p;g<o?u=p+1:h=p-1}return-u-1}function Pe(i,o){let u=0,h=i.length-1;for(;u<=h;){let p=u+h>>>1,g=i[p];if(g===o)return p;g<o?u=p+1:h=p-1}return-u-1}function Le(i,o){let u,h=0,p=i.length-1;for(;h<=p;){let g=h+p>>>1;u=i[g];let A=u.start;if(A===o)return u;A<o?h=g+1:p=g-1}if(h>0)return u=i[h-1],o>u.end?0:u}function mt(i,o){this.font=i,this.tableName=o}mt.prototype={searchTag:q,binSearch:Pe,getTable:function(i){let o=this.font.tables[this.tableName];return!o&&i&&(o=this.font.tables[this.tableName]=this.createDefaultTable()),o},getScriptNames:function(){let i=this.getTable();return i?i.scripts.map(function(o){return o.tag}):[]},getDefaultScriptName:function(){let i=this.getTable();if(!i)return;let o=!1;for(let u=0;u<i.scripts.length;u++){let h=i.scripts[u].tag;if(h==="DFLT")return h;h==="latn"&&(o=!0)}if(o)return"latn"},getScriptTable:function(i,o){let u=this.getTable(o);if(u){i=i||"DFLT";let h=u.scripts,p=q(u.scripts,i);if(p>=0)return h[p].script;if(o){let g={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-p,0,g),g.script}}},getLangSysTable:function(i,o,u){let h=this.getScriptTable(i,u);if(h){if(!o||o==="dflt"||o==="DFLT")return h.defaultLangSys;let p=q(h.langSysRecords,o);if(p>=0)return h.langSysRecords[p].langSys;if(u){let g={tag:o,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-p,0,g),g.langSys}}},getFeatureTable:function(i,o,u,h){let p=this.getLangSysTable(i,o,h);if(p){let g,A=p.featureIndexes,k=this.font.tables[this.tableName].features;for(let E=0;E<A.length;E++)if(g=k[A[E]],g.tag===u)return g.feature;if(h){let E=k.length;return me.assert(E===0||u>=k[E-1].tag,"Features must be added in alphabetical order."),g={tag:u,feature:{params:0,lookupListIndexes:[]}},k.push(g),A.push(E),g.feature}}},getLookupTables:function(i,o,u,h,p){let g=this.getFeatureTable(i,o,u,p),A=[];if(g){let k,E=g.lookupListIndexes,j=this.font.tables[this.tableName].lookups;for(let M=0;M<E.length;M++)k=j[E[M]],k.lookupType===h&&A.push(k);if(A.length===0&&p){k={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let M=j.length;return j.push(k),E.push(M),[k]}}return A},getGlyphClass:function(i,o){switch(i.format){case 1:return i.startGlyph<=o&&o<i.startGlyph+i.classes.length?i.classes[o-i.startGlyph]:0;case 2:{let u=Le(i.ranges,o);return u?u.classId:0}}},getCoverageIndex:function(i,o){switch(i.format){case 1:{let u=Pe(i.glyphs,o);return u>=0?u:-1}case 2:{let u=Le(i.ranges,o);return u?u.index+o-u.start:-1}}},expandCoverage:function(i){if(i.format===1)return i.glyphs;{let o=[],u=i.ranges;for(let h=0;h<u.length;h++){let p=u[h],g=p.start,A=p.end;for(let k=g;k<=A;k++)o.push(k)}return o}}};var ht=mt;function It(i){ht.call(this,i,"gpos")}It.prototype=ht.prototype,It.prototype.init=function(){let i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},It.prototype.getKerningValue=function(i,o,u){for(let h=0;h<i.length;h++){let p=i[h].subtables;for(let g=0;g<p.length;g++){let A=p[g],k=this.getCoverageIndex(A.coverage,o);if(!(k<0))switch(A.posFormat){case 1:{let E=A.pairSets[k];for(let j=0;j<E.length;j++){let M=E[j];if(M.secondGlyph===u)return M.value1&&M.value1.xAdvance||0}break}case 2:{let E=this.getGlyphClass(A.classDef1,o),j=this.getGlyphClass(A.classDef2,u),M=A.classRecords[E][j];return M.value1&&M.value1.xAdvance||0}}}}return 0},It.prototype.getKerningTables=function(i,o){if(this.font.tables.gpos)return this.getLookupTables(i,o,"kern",2)};var yr=It;function xn(i,o){let u=i.length;if(u!==o.length)return!1;for(let h=0;h<u;h++)if(i[h]!==o[h])return!1;return!0}function Cn(i,o,u){let h=0,p=i.length-1,g=null;for(;h<=p;){let A=Math.floor((h+p)/2),k=i[A],E=k[o];if(E<u)h=A+1;else if(E>u)p=A-1;else{g=k;break}}return g}function Fn(i,o,u){let h=0,p=i.length-1;for(;h<=p;){let g=Math.floor((h+p)/2),A=i[g];if(A[o]<u)h=g+1;else if(A[o]>u)p=g-1;else return g}return-1}function ms(i,o,u){let h=0,p=i.length,g=(A,k)=>A[o]-k[o];for(;h<p;){let A=h+p>>>1;g(i[A],u)<0?h=A+1:p=A}return i.splice(h,0,u),h}function Ri(i){return i[0]===31&&i[1]===139&&i[2]===8}function Kr(i){let o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=10,h=i.byteLength-8,p=o.getInt8(3);if(p&4&&(u+=2+o.getUint16(u,!0)),p&8)for(;u<h&&i[u++]!==0;);if(p&16)for(;u<h&&i[u++]!==0;);if(p&2&&(u+=2),u>=h)throw new Error("Can't find compressed blocks");let g=o.getUint32(o.byteLength-4,!0);return ye(i.subarray(u,h),new Uint8Array(g))}function wn(i){return{x:i.x,y:i.y,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour}}function Ps(i){return{glyphIndex:i.glyphIndex,xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:i.dx,dy:i.dy}}function Os(i){ht.call(this,i,"gsub")}function Ll(i,o,u){let h=i.subtables;for(let p=0;p<h.length;p++){let g=h[p];if(g.substFormat===o)return g}if(u)return h.push(u),u}Os.prototype=ht.prototype,Os.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Os.prototype.getSingle=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,1);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],j=this.expandCoverage(E.coverage),M;if(E.substFormat===1){let re=E.deltaGlyphId;for(M=0;M<j.length;M++){let te=j[M];h.push({sub:te,by:te+re})}}else{let re=E.substitute;for(M=0;M<j.length;M++)h.push({sub:j[M],by:re[M]})}}}return h},Os.prototype.getMultiple=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,2);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],j=this.expandCoverage(E.coverage),M;for(M=0;M<j.length;M++){let re=j[M],te=E.sequences[M];h.push({sub:re,by:te})}}}return h},Os.prototype.getAlternates=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,3);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],j=this.expandCoverage(E.coverage),M=E.alternateSets;for(let re=0;re<j.length;re++)h.push({sub:j[re],by:M[re]})}}return h},Os.prototype.getLigatures=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,4);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],j=this.expandCoverage(E.coverage),M=E.ligatureSets;for(let re=0;re<j.length;re++){let te=j[re],Ae=M[re];for(let fe=0;fe<Ae.length;fe++){let je=Ae[fe];h.push({sub:[te].concat(je.components),by:je.ligGlyph})}}}}return h},Os.prototype.addSingle=function(i,o,u,h){let p=this.getLookupTables(u,h,i,1,!0)[0],g=Ll(p,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});me.assert(g.coverage.format===1,"Single: unable to modify coverage table format "+g.coverage.format);let A=o.sub,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.substitute.splice(k,0,0)),g.substitute[k]=o.by},Os.prototype.addMultiple=function(i,o,u,h){me.assert(o.by instanceof Array&&o.by.length>1,'Multiple: "by" must be an array of two or more ids');let p=this.getLookupTables(u,h,i,2,!0)[0],g=Ll(p,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});me.assert(g.coverage.format===1,"Multiple: unable to modify coverage table format "+g.coverage.format);let A=o.sub,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.sequences.splice(k,0,0)),g.sequences[k]=o.by},Os.prototype.addAlternate=function(i,o,u,h){let p=this.getLookupTables(u,h,i,3,!0)[0],g=Ll(p,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});me.assert(g.coverage.format===1,"Alternate: unable to modify coverage table format "+g.coverage.format);let A=o.sub,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.alternateSets.splice(k,0,0)),g.alternateSets[k]=o.by},Os.prototype.addLigature=function(i,o,u,h){let p=this.getLookupTables(u,h,i,4,!0)[0],g=p.subtables[0];g||(g={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},p.subtables[0]=g),me.assert(g.coverage.format===1,"Ligature: unable to modify coverage table format "+g.coverage.format);let A=o.sub[0],k=o.sub.slice(1),E={ligGlyph:o.by,components:k},j=this.binSearch(g.coverage.glyphs,A);if(j>=0){let M=g.ligatureSets[j];for(let re=0;re<M.length;re++)if(xn(M[re].components,k))return;M.push(E)}else j=-1-j,g.coverage.glyphs.splice(j,0,A),g.ligatureSets.splice(j,0,[E])},Os.prototype.getFeature=function(i,o,u){if(/ss\d\d/.test(i))return this.getSingle(i,o,u);switch(i){case"aalt":case"salt":return this.getSingle(i,o,u).concat(this.getAlternates(i,o,u));case"dlig":case"liga":case"rlig":return this.getLigatures(i,o,u);case"ccmp":return this.getMultiple(i,o,u).concat(this.getLigatures(i,o,u));case"stch":return this.getMultiple(i,o,u)}},Os.prototype.add=function(i,o,u,h){if(/ss\d\d/.test(i))return this.addSingle(i,o,u,h);switch(i){case"aalt":case"salt":return typeof o.by=="number"?this.addSingle(i,o,u,h):this.addAlternate(i,o,u,h);case"dlig":case"liga":case"rlig":return this.addLigature(i,o,u,h);case"ccmp":return o.by instanceof Array?this.addMultiple(i,o,u,h):this.addLigature(i,o,u,h)}};var ni=Os,qi=class{constructor(i){this.defaultValue=255,this.font=i}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(i){let o=[],u=this.cpal();if(!u)return o;for(let h=0;h<u.colorRecordIndices.length;h++){let p=u.colorRecordIndices[h],g=[];for(let A=p;A<p+u.numPaletteEntries;A++)g.push(as(u.colorRecords[A],i||"hexa"));o.push(g)}return o}toCPALcolor(i){return Array.isArray(i)?i.map(o=>lr(o,"raw")):lr(i,"raw")}fillPalette(i,o=[],u=this.cpal().numPaletteEntries){return i=Number.isInteger(i)?this.get(i,"raw"):i,Object.assign(Array(u).fill(this.defaultValue),this.toCPALcolor(i).concat(this.toCPALcolor(o)))}extend(i){if(this.ensureCPAL(Array(i).fill(this.defaultValue)))return;let o=this.cpal(),u=o.numPaletteEntries+i,h=this.getAll().map(p=>this.fillPalette(p,[],u));o.numPaletteEntries=u,o.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(i,o="hexa"){return this.getAll(o)[i]||null}getColor(i,o=0,u="hexa"){return Hn(this.font,i,o,u)}setColor(i,o,u=0){i=parseInt(i),u=parseInt(u);let h=this.getAll("raw"),p=h[u];if(!p)throw Error(`paletteIndex ${u} out of range`);let g=this.cpal(),A=g.numPaletteEntries;Array.isArray(o)||(o=[o]),o.length+i>A&&(this.extend(o.length+i-A),h=this.getAll("raw"),p=h[u]);for(let k=0;k<o.length;k++)p[k+i]=this.toCPALcolor(o[k]);g.colorRecords=h.flat(),this.updateIndices()}add(i){if(this.ensureCPAL(i))return;let o=this.cpal(),u=o.numPaletteEntries;i&&i.length?(i=this.toCPALcolor(i),i.length>u?this.extend(i.length-u):i.length<u&&(i=this.fillPalette(i)),o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...i)):(o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...Array(u).fill(this.defaultValue)))}delete(i){let o=this.getAll("raw");delete o[i];let u=this.cpal();u.colorRecordIndices.pop(),u.colorRecords=o.flat()}deleteColor(i,o){if(i===o)throw Error("replacementIndex cannot be the same as colorIndex");let u=this.cpal(),h=this.getAll("raw"),p=[];if(o>u.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${u.numPaletteEntries-1}, replacementIndex: ${o})`);for(let k=0;k<h.length;k++){let E=h[k].filter((j,M)=>M!==i);p.push(E)}let g=this.font.tables.colr;if(g){let k=g.layerRecords;for(let E=0;E<k.length;E++){let j=k[E].paletteIndex;if(j>i)k[E].paletteIndex-=1;else if(j===i){let M=0;for(let re=0;re<h.length;re++)if(o>i&&o<=i+h[re].length){M++;break}k[E].paletteIndex=o-M}}this.font.tables.colr={...g,layerRecords:k}}let A=p.flat();for(let k=0;k<h.length;k++)u.colorRecordIndices[k]-=k;u.numPaletteEntries=Math.max(0,u.numPaletteEntries-1),u.colorRecords=this.toCPALcolor(A)}ensureCPAL(i){return this.cpal()?!1:(!i||!i.length?i=[this.defaultValue]:i=this.toCPALcolor(i),this.font.tables.cpal={version:0,numPaletteEntries:i.length,colorRecords:i,colorRecordIndices:[0]},!0)}updateIndices(){let i=this.cpal(),o=Math.ceil(i.colorRecords.length/i.numPaletteEntries);i.colorRecordIndices=[];for(let u=0;u<o;u++)i.colorRecordIndices.push(u*i.numPaletteEntries)}},Oo=class{constructor(i){this.font=i}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(i){let o=this.font,u=[],h=o.tables.colr,p=o.tables.cpal;if(!h||!p)return u;let g=Cn(h.baseGlyphRecords,"glyphID",i);if(!g)return u;let A=g.firstLayerIndex,k=g.numLayers;for(let E=0;E<k;E++){let j=h.layerRecords[A+E];u.push({glyph:o.glyphs.get(j.glyphID),paletteIndex:j.paletteIndex})}return u}add(i,o,u){let h=this.get(i);o=Array.isArray(o)?o:[o],u===void 0||u===1/0||u>h.length?u=h.length:u<0&&(u=h.length+1+u%(h.length+1),u>=h.length+1&&(u-=h.length+1));let p=[];for(let g=0;g<u;g++){let A=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;p.push({glyphID:A,paletteIndex:h[g].paletteIndex})}for(let g of o){let A=Number.isInteger(g.glyph)?g.glyph:g.glyph.index;p.push({glyphID:A,paletteIndex:g.paletteIndex})}for(let g=u;g<h.length;g++){let A=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;p.push({glyphID:A,paletteIndex:h[g].paletteIndex})}this.updateColrTable(i,p)}setPaletteIndex(i,o,u){let h=this.get(i);h[o]?(h=h.map((p,g)=>({glyphID:p.glyph.index,paletteIndex:g===o?u:p.paletteIndex})),this.updateColrTable(i,h)):console.error("Invalid layer index")}remove(i,o,u=o){let h=this.get(i);h=h.map(p=>({glyphID:p.glyph.index,paletteIndex:p.paletteIndex})),h.splice(o,u-o+1),this.updateColrTable(i,h)}updateColrTable(i,o){this.ensureCOLR();let u=this.font.tables.colr,h=Fn(u.baseGlyphRecords,"glyphID",i);if(h===-1){let E={glyphID:i,firstLayerIndex:u.layerRecords.length,numLayers:0};h=ms(u.baseGlyphRecords,"glyphID",E)}let p=u.baseGlyphRecords[h],g=p.numLayers,A=o.length,k=A-g;if(k>0){let E=o.slice(g).map(j=>({glyphID:j.glyphID,paletteIndex:j.paletteIndex}));u.layerRecords.splice(p.firstLayerIndex+g,0,...E)}else k<0&&u.layerRecords.splice(p.firstLayerIndex+A,-k);for(let E=0;E<Math.min(g,A);E++)u.layerRecords[p.firstLayerIndex+E]={glyphID:o[E].glyphID,paletteIndex:o[E].paletteIndex};if(p.numLayers=A,k!==0)for(let E=0;E<u.baseGlyphRecords.length;E++){let j=u.baseGlyphRecords[E];E===h||j.firstLayerIndex<p.firstLayerIndex||(u.baseGlyphRecords[E].firstLayerIndex+=k)}}},Mi=class{constructor(i){this.font=i,this.cache=new WeakMap}get(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.image}getAsync(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.promise}getOrCreateSvgImageCacheEntry(i){let o=this.font.tables.svg;if(o===void 0)return;let u=o.get(i);if(u===void 0)return;let h=this.cache.get(u);h===void 0&&(h=sl(u),this.cache.set(u,h));let p=h.images.get(i);return p===void 0&&(p=hu(this.font,h.template,i),p.promise.then(g=>{if(p.image=g,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(i)}catch(A){console.error("font.onGlyphUpdated",i,A)}}),h.images.set(i,p)),p}};function sl(i){return{template:Yi(i).then(Cp),images:new Map}}function hu(i,o,u){return{promise:o.then(h=>{let p;typeof h=="string"?p=h:(h[4]=u,p=h.join(""));let g=lo(p,i.unitsPerEm);return g.image.decode().then(()=>g)}),image:void 0}}var Yi=typeof DecompressionStream=="function"?bd:th;function th(i){try{return Promise.resolve(new TextDecoder().decode(Ri(i)?Kr(i):i))}catch(o){return Promise.reject(o)}}function bd(i){if(Ri(i))return new Response(new Response(i).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(i))}catch(o){return Promise.reject(o)}}function Cp(i){let o=i.indexOf("<svg"),u=i.indexOf(">",o+4)+1;if(/ id=['"]glyph\d+['"]/.test(i.substring(o,u)))return i;let h=i.lastIndexOf("</svg>");return[i.substring(0,u),"<defs>",i.substring(u,h),'</defs><use href="#glyph',"",'"/>',i.substring(h)]}function lo(i,o){let u=new DOMParser().parseFromString(i,"image/svg+xml").documentElement,h=u.viewBox.baseVal,p=u.width.baseVal,g=u.height.baseVal,A=1,k=1;h.width>0&&h.height>0&&(p.unitType===1?(A=p.valueInSpecifiedUnits/h.width,k=g.unitType===1?g.valueInSpecifiedUnits/h.height:A):g.unitType===1?(k=g.valueInSpecifiedUnits/h.height,A=k):o&&(A=o/h.width,k=o/h.height));let E=document.createElement("div");E.style.position="fixed",E.style.visibility="hidden",E.appendChild(u),document.body.appendChild(E);let j=u.getBBox();document.body.removeChild(E);let M=(j.x-h.x)*A,re=(h.y-j.y)*k,te=j.width*A,Ae=j.height*k;u.setAttribute("viewBox",[j.x,j.y,j.width,j.height].join(" ")),A!==1&&u.setAttribute("width",te),k!==1&&u.setAttribute("height",Ae);let fe=new Image(te,Ae);return fe.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u.outerHTML),{leftSideBearing:M,baseline:re,image:fe}}var ua=new WeakMap;function Il(i,o,u,h,p){let g;return(o&h)>0?(g=i.parseByte(),(o&p)===0&&(g=-g),g=u+g):(o&p)>0?g=u:g=u+i.parseShort(),g}function Lc(i,o,u){let h=new st.Parser(o,u);i._numberOfContours=h.parseShort(),i._xMin=h.parseShort(),i._yMin=h.parseShort(),i._xMax=h.parseShort(),i._yMax=h.parseShort();let p,g;if(i._numberOfContours>0){let A=i.endPointIndices=[];for(let E=0;E<i._numberOfContours;E+=1)A.push(h.parseUShort());i.instructionLength=h.parseUShort(),i.instructions=[];for(let E=0;E<i.instructionLength;E+=1)i.instructions.push(h.parseByte());let k=A[A.length-1]+1;p=[];for(let E=0;E<k;E+=1)if(g=h.parseByte(),p.push(g),(g&8)>0){let j=h.parseByte();for(let M=0;M<j;M+=1)p.push(g),E+=1}if(me.argument(p.length===k,"Bad flags."),A.length>0){let E=[],j;if(k>0){for(let te=0;te<k;te+=1)g=p[te],j={},j.onCurve=!!(g&1),j.lastPointOfContour=A.indexOf(te)>=0,E.push(j);let M=0;for(let te=0;te<k;te+=1)g=p[te],j=E[te],j.x=Il(h,g,M,2,16),M=j.x;let re=0;for(let te=0;te<k;te+=1)g=p[te],j=E[te],j.y=Il(h,g,re,4,32),re=j.y}i.points=E}else i.points=[]}else if(i._numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let A=!0;for(;A;){p=h.parseUShort();let k={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(p&1)>0?(p&2)>0?(k.dx=h.parseShort(),k.dy=h.parseShort()):k.matchedPoints=[h.parseUShort(),h.parseUShort()]:(p&2)>0?(k.dx=h.parseChar(),k.dy=h.parseChar()):k.matchedPoints=[h.parseByte(),h.parseByte()],(p&8)>0?k.xScale=k.yScale=h.parseF2Dot14():(p&64)>0?(k.xScale=h.parseF2Dot14(),k.yScale=h.parseF2Dot14()):(p&128)>0&&(k.xScale=h.parseF2Dot14(),k.scale01=h.parseF2Dot14(),k.scale10=h.parseF2Dot14(),k.yScale=h.parseF2Dot14()),i.components.push(k),A=!!(p&32)}if(p&256){i.instructionLength=h.parseUShort(),i.instructions=[];for(let k=0;k<i.instructionLength;k+=1)i.instructions.push(h.parseByte())}}}function fu(i,o){let u=[];for(let h=0;h<i.length;h+=1){let p=i[h],g={x:o.xScale*p.x+o.scale10*p.y+o.dx,y:o.scale01*p.x+o.yScale*p.y+o.dy,onCurve:p.onCurve,lastPointOfContour:p.lastPointOfContour};u.push(g)}return u}function _p(i){let o=[],u=[];for(let h=0;h<i.length;h+=1){let p=i[h];u.push(p),p.lastPointOfContour&&(o.push(u),u=[])}return me.argument(u.length===0,"There are still points left in the current contour."),o}function yd(i){let o=new ze;if(!i)return o;let u=_p(i);for(let h=0;h<u.length;++h){let p=u[h],g=p[p.length-1],A=p[0];if(g.onCurve)o.moveTo(g.x,g.y);else if(A.onCurve)o.moveTo(A.x,A.y);else{let k={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5};o.moveTo(k.x,k.y)}for(let k=0;k<p.length;++k)if(g=A,A=p[(k+1)%p.length],g.onCurve)o.lineTo(g.x,g.y);else{let E=A;A.onCurve||(E={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5}),o.quadraticCurveTo(g.x,g.y,E.x,E.y)}o.closePath()}return o}function rh(i,o){if(o.isComposite){ua.has(i)||ua.set(i,new Set);let u=ua.get(i);u.add(o.index);try{for(let h=0;h<o.components.length;h+=1){let p=o.components[h];if(u.has(p.glyphIndex))continue;let g=i.get(p.glyphIndex);if(g.getPath(),g.points){let A;if(p.matchedPoints===void 0)A=fu(g.points,p);else{if(p.matchedPoints[0]>o.points.length-1||p.matchedPoints[1]>g.points.length-1)throw Error("Matched points out of range in "+o.name);let k=o.points[p.matchedPoints[0]],E=g.points[p.matchedPoints[1]],j={xScale:p.xScale,scale01:p.scale01,scale10:p.scale10,yScale:p.yScale,dx:0,dy:0};E=fu([E],j)[0],j.dx=k.x-E.x,j.dy=k.y-E.y,A=fu(g.points,j)}o.points=o.points.concat(A)}}}finally{u.delete(o.index)}}return yd(o.points)}function vd(i,o,u,h){let p=new Or.GlyphSet(h);for(let g=0;g<u.length-1;g+=1){let A=u[g],k=u[g+1];A!==k?p.push(g,Or.ttfGlyphLoader(h,g,Lc,i,o+A,rh)):p.push(g,Or.glyphLoader(h,g))}return p}function pu(i,o,u,h){let p=new Or.GlyphSet(h);return h._push=function(g){let A=u[g],k=u[g+1];A!==k?p.push(g,Or.ttfGlyphLoader(h,g,Lc,i,o+A,rh)):p.push(g,Or.glyphLoader(h,g))},p}function nh(i,o,u,h,p){return p.lowMemory?pu(i,o,u,h):vd(i,o,u,h)}var co={getPath:yd,parse:nh},El=class{constructor(i){this.font=i}normalizeCoordTags(i){for(let o in i)if(o.length<4){let u=o.padEnd(4," ");i[u]===void 0&&(i[u]=i[o]),delete i[o]}}getNormalizedCoords(i){i||(i=this.font.variation.get());let o=[];this.normalizeCoordTags(i);for(let u=0;u<this.fvar().axes.length;u++){let h=this.fvar().axes[u],p=i[h.tag];p===void 0&&(p=h.defaultValue),p<h.defaultValue?o.push((p-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):o.push((p-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let u=0;u<this.avar().axisSegmentMaps.length;u++){let h=this.avar().axisSegmentMaps[u];for(let p=0;p<h.axisValueMaps.length;p++){let g=h.axisValueMaps[p];if(p>=1&&o[u]<g.fromCoordinate){let A=h.axisValueMaps[p-1];o[u]=((o[u]-A.fromCoordinate)*(g.toCoordinate-A.toCoordinate)+Number.EPSILON)/(g.fromCoordinate-A.fromCoordinate+Number.EPSILON)+A.toCoordinate;break}}}return o}interpolatePoints(i,o,u){if(i.length===0)return;let h=0;for(;h<i.length;){let p=h,g=h,A=i[g];for(;!A.lastPointOfContour;)A=i[++g];for(;h<=g&&!u[h];)h++;if(h>g)continue;let k=h,E=h;for(h++;h<=g;)u[h]&&(this.deltaInterpolate(E+1,h-1,E,h,o,i),E=h),h++;E===k?this.deltaShift(p,g,E,o,i):(this.deltaInterpolate(E+1,g,E,k,o,i),k>0&&this.deltaInterpolate(p,k-1,E,k,o,i)),h=g+1}}deltaInterpolate(i,o,u,h,p,g){if(i>o)return;let A=["x","y"];for(let E=0;E<A.length;E++){let j=A[E];if(p[u][j]>p[h][j]){var k=u;u=h,h=k}let M=p[u][j],re=p[h][j],te=g[u][j],Ae=g[h][j];if(M!==re||te===Ae){let fe=M===re?0:(Ae-te)/(re-M);for(let je=i;je<=o;je++){let pt=p[je][j];pt<=M?pt+=te-M:pt>=re?pt+=Ae-re:pt=te+(pt-M)*fe,g[je][j]=pt}}}}deltaShift(i,o,u,h,p){let g=p[u].x-h[u].x,A=p[u].y-h[u].y;if(!(g===0&&A===0))for(let k=i;k<=o;k++)k!==u&&(p[k].x+=g,p[k].y+=A)}transformComponents(i,o,u,h,p,g){let A=0;for(let k=0;k<i.components.length;k++){let E=i.components[k],j=this.font.glyphs.get(E.glyphIndex),M=Ps(E),re=h.indexOf(k);re>-1&&(M.dx+=Math.round(p.deltas[re]*g),M.dy+=Math.round(p.deltasY[re]*g));let te=fu(this.getTransform(j,u).points,M);o.splice(A,te.length,...te),A+=j.points.length}}applyTupleVariationStore(i,o,u,h="gvar",p={}){u||(u=this.font.variation.get());let g=this.getNormalizedCoords(u),{headers:A,sharedPoints:k}=i,E=this.fvar().axes.length,j;h==="gvar"?j=o.map(wn):h==="cvar"&&(j=[...o]);for(let M=0;M<A.length;M++){let re=A[M],te=1;for(let fe=0;fe<E;fe++){let je=[0];switch(h){case"gvar":je=re.peakTuple?re.peakTuple:this.gvar().sharedTuples[re.sharedTupleRecordsIndex];break;case"cvar":je=re.peakTuple;break}if(je[fe]!==0){if(g[fe]===0){te=0;break}if(re.intermediateStartTuple)if(g[fe]<re.intermediateStartTuple[fe]||g[fe]>re.intermediateEndTuple[fe]){te=0;break}else g[fe]<je[fe]?te=te*(g[fe]-re.intermediateStartTuple[fe]+Number.EPSILON)/(je[fe]-re.intermediateStartTuple[fe]+Number.EPSILON):te=te*(re.intermediateEndTuple[fe]-g[fe]+Number.EPSILON)/(re.intermediateEndTuple[fe]-je[fe]+Number.EPSILON);else{if(g[fe]<Math.min(0,je[fe])||g[fe]>Math.max(0,je[fe])){te=0;break}te=(te*g[fe]+Number.EPSILON)/(je[fe]+Number.EPSILON)}}}if(te===0)continue;let Ae=re.privatePoints.length?re.privatePoints:k;if(h==="gvar"&&p.glyph&&p.glyph.isComposite)this.transformComponents(p.glyph,j,u,Ae,re,te);else if(Ae.length===0)for(let fe=0;fe<j.length;fe++){let je=j[fe];h==="gvar"?j[fe]={x:Math.round(je.x+re.deltas[fe]*te),y:Math.round(je.y+re.deltasY[fe]*te),onCurve:je.onCurve,lastPointOfContour:je.lastPointOfContour}:h==="cvar"&&(j[fe]=Math.round(je+re.deltas[fe]*te))}else{let fe;h==="gvar"?fe=j.map(wn):h==="cvar"&&(fe=j);let je=Array(o.length).fill(!1);for(let pt=0;pt<Ae.length;pt++){let Tr=Ae[pt];if(Tr<o.length){let fr=fe[Tr];h==="gvar"?(je[Tr]=!0,fr.x+=re.deltas[pt]*te,fr.y+=re.deltasY[pt]*te):h==="cvar"&&(j[Tr]=Math.round(fr+re.deltas[pt]*te))}}if(h==="gvar"){this.interpolatePoints(fe,j,je);for(let pt=0;pt<o.length;pt++){let Tr=fe[pt].x-j[pt].x,fr=fe[pt].y-j[pt].y;j[pt].x=Math.round(j[pt].x+Tr),j[pt].y=Math.round(j[pt].y+fr)}}}}return j}getTransform(i,o){Number.isInteger(i)&&(i=this.font.glyphs.get(i));let u=i.getBlendPath,h=!!(i.points&&i.points.length),p=i;if(u||h){if(o||(o=this.font.variation.get()),h){let g=this.gvar()&&this.gvar().glyphVariations[i.index];if(g){let A=i.points,k=this.applyTupleVariationStore(g,A,o,"gvar",{glyph:i});p=new xr(Object.assign({},i,{points:k,path:yd(k)}))}}else if(u){let g=i.getBlendPath(o);p=new xr(Object.assign({},i,{path:g}))}}return this.font.tables.hvar&&(i._advanceWidth=typeof i._advanceWidth<"u"?i._advanceWidth:i.advanceWidth,i.advanceWidth=p.advanceWidth=Math.round(i._advanceWidth+this.getVariableAdjustment(p.index,"hvar","advanceWidth",o)),i._leftSideBearing=typeof i._leftSideBearing<"u"?i._leftSideBearing:i.leftSideBearing,i.leftSideBearing=p.leftSideBearing=Math.round(i._leftSideBearing+this.getVariableAdjustment(p.index,"hvar","lsb",o))),p}getCvarTransform(i){let o=this.font.tables.cvt,u=this.cvar();return!o||!o.length||!u||!u.headers.length?o:this.applyTupleVariationStore(u,o,i,"cvar")}getVariableAdjustment(i,o,u,h){h=h||this.font.variation.get();let p,g,A=this.font.tables[o];if(!A)throw Error(`trying to get variation adjustment from non-existent table "${A}"`);if(!A.itemVariationStore)throw Error(`trying to get variation adjustment from table "${A}" which does not have an itemVariationStore`);let k=A[u]&&A[u].map.length;if(k){let E=i;E>=k&&(E=k-1),{outerIndex:p,innerIndex:g}=A[u].map[E]}else p=0,g=i;return this.getDelta(A.itemVariationStore,p,g,h)}getDelta(i,o,u,h){if(o>=i.itemVariationSubtables.length)return 0;let p=i.itemVariationSubtables[o];if(u>=p.deltaSets.length)return 0;let g=p.deltaSets[u],A=this.getBlendVector(i,o,h),k=0;for(let E=0;E<p.regionIndexes.length;E++)k+=g[E]*A[E];return k}getBlendVector(i,o,u){u||(u=this.font.variation.get());let h=i.itemVariationSubtables[o],p=this.getNormalizedCoords(u),g=[];for(let A=0;A<h.regionIndexes.length;A++){let k=1,E=h.regionIndexes[A],j=i.variationRegions[E].regionAxes;for(let M=0;M<j.length;M++){let re=j[M],te;re.startCoord>re.peakCoord||re.peakCoord>re.endCoord||re.startCoord<0&&re.endCoord>0&&re.peakCoord!==0||re.peakCoord===0?te=1:p[M]<re.startCoord||p[M]>re.endCoord?te=0:p[M]===re.peakCoord?te=1:p[M]<re.peakCoord?te=(p[M]-re.startCoord+Number.EPSILON)/(re.peakCoord-re.startCoord+Number.EPSILON):te=(re.endCoord-p[M]+Number.EPSILON)/(re.endCoord-re.peakCoord+Number.EPSILON),k*=te}g[A]=k}return g}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},mu=class{constructor(i){this.font=i,this.process=new El(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let i=this.getDefaultInstanceIndex();i>-1?this.set(i):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((i,o)=>(i[o.tag]=o.defaultValue,i),{})}getDefaultInstanceIndex(){let i=this.getDefaultCoordinates(),o=this.getInstanceIndex(i);return o<0&&(o=this.fvar().instances.findIndex(u=>u.name&&u.name.en==="Regular")),o}getInstanceIndex(i){return this.fvar().instances.findIndex(o=>Object.keys(i).every(u=>o.coordinates[u]===i[u]))}getInstance(i){return this.fvar().instances&&this.fvar().instances[i]}set(i){let o;if(Number.isInteger(i)){let u=this.getInstance(i);if(!u)throw Error(`Invalid instance index ${i}`);o={...u.coordinates}}else o=i,this.process.normalizeCoordTags(o);o=Object.assign({},this.font.defaultRenderOptions.variation,o),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:o})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},sh=1e6,il=64,Ic=1e4,wd,al,Ad,gu;function tc(i){this.font=i,this.getCommands=function(o){return co.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Fo(i){return i}function Td(i){return Math.sign(i)*Math.round(Math.abs(i))}function ih(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function xu(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function kp(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function ah(i){return Math.sign(i)*Math.floor(Math.abs(i))}var bu=function(i){let o=this.srPeriod,u=this.srPhase,h=this.srThreshold,p=1;return i<0&&(i=-i,p=-1),i+=h-u,i=Math.trunc(i/o)*o,i+=u,i<0?u*p:i*p},ja={x:1,y:0,axis:"x",distance:function(i,o,u,h){return(u?i.xo:i.x)-(h?o.xo:o.x)},interpolate:function(i,o,u,h){let p,g,A,k,E,j,M;if(!h||h===this){if(p=i.xo-o.xo,g=i.xo-u.xo,E=o.x-o.xo,j=u.x-u.xo,A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){i.x=i.xo+(E+j)/2;return}i.x=i.xo+(E*k+j*A)/M;return}if(p=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),E=h.distance(o,o,!1,!0),j=h.distance(u,u,!1,!0),A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){ja.setRelative(i,i,(E+j)/2,h,!0);return}ja.setRelative(i,i,(E*k+j*A)/M,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,o,u,h,p){if(!h||h===this){i.x=(p?o.xo:o.x)+u;return}let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y;i.x=k+(i.y-E)/h.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},$o={x:0,y:1,axis:"y",distance:function(i,o,u,h){return(u?i.yo:i.y)-(h?o.yo:o.y)},interpolate:function(i,o,u,h){let p,g,A,k,E,j,M;if(!h||h===this){if(p=i.yo-o.yo,g=i.yo-u.yo,E=o.y-o.yo,j=u.y-u.yo,A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){i.y=i.yo+(E+j)/2;return}i.y=i.yo+(E*k+j*A)/M;return}if(p=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),E=h.distance(o,o,!1,!0),j=h.distance(u,u,!1,!0),A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){$o.setRelative(i,i,(E+j)/2,h,!0);return}$o.setRelative(i,i,(E*k+j*A)/M,h,!0)},normalSlope:0,setRelative:function(i,o,u,h,p){if(!h||h===this){i.y=(p?o.yo:o.y)+u;return}let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y;i.y=E+h.normalSlope*(i.x-k)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze(ja),Object.freeze($o);function rc(i,o){this.x=i,this.y=o,this.axis=void 0,this.slope=o/i,this.normalSlope=-i/o,Object.freeze(this)}rc.prototype.distance=function(i,o,u,h){return this.x*ja.distance(i,o,u,h)+this.y*$o.distance(i,o,u,h)},rc.prototype.interpolate=function(i,o,u,h){let p,g,A,k,E,j,M;if(A=h.distance(i,o,!0,!0),k=h.distance(i,u,!0,!0),p=h.distance(o,o,!1,!0),g=h.distance(u,u,!1,!0),E=Math.abs(A),j=Math.abs(k),M=E+j,M===0){this.setRelative(i,i,(p+g)/2,h,!0);return}this.setRelative(i,i,(p*j+g*E)/M,h,!0)},rc.prototype.setRelative=function(i,o,u,h,p){h=h||this;let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y,j=h.normalSlope,M=this.slope,re=i.x,te=i.y;i.x=(M*re-j*k+E-te)/(M-j),i.y=M*(i.x-re)+te},rc.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function Nl(i,o){let u=Math.sqrt(i*i+o*o);return i/=u,o/=u,i===1&&o===0?ja:i===0&&o===1?$o:new rc(i,o)}function uo(i,o,u,h){this.x=this.xo=Math.round(i*64)/64,this.y=this.yo=Math.round(o*64)/64,this.lastPointOfContour=u,this.onCurve=h,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}uo.prototype.nextTouched=function(i){let o=this.nextPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.nextPointOnContour;return o},uo.prototype.prevTouched=function(i){let o=this.prevPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.prevPointOnContour;return o};var si=Object.freeze(new uo(0,0)),Ec={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ho(i,o){switch(this.env=i,this.stack=[],this.prog=o,i){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=ja,this.round=Td}}tc.prototype.exec=function(i,o){if(typeof o!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let u=this.font,h=this._prepState;if(!h||h.ppem!==o){let p=this._fpgmState;if(!p){ho.prototype=Ec,p=this._fpgmState=new ho("fpgm",u.tables.fpgm),p.funcs=[],p.font=u,p.instructionCount=0,p.callDepth=0;try{al(p)}catch(A){console.log("Hinting error in FPGM:"+A),this._errorState=3;return}}ho.prototype=p,h=this._prepState=new ho("prep",u.tables.prep),h.ppem=o,h.instructionCount=0,h.callDepth=0;let g=u.variation&&u.variation.process.getCvarTransform()||u.tables.cvt;if(g){let A=h.cvt=new Array(g.length),k=o/u.unitsPerEm;for(let E=0;E<g.length;E++)A[E]=g[E]*k}else h.cvt=[];try{al(h)}catch(A){this._errorState<2&&console.log("Hinting error in PREP:"+A),this._errorState=2}}if(!(this._errorState>1))try{return Ad(i,h)}catch(p){this._errorState<1&&(console.log("Hinting error:"+p),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Ad=function(i,o){let u=o.ppem/o.font.unitsPerEm,h=u,p=i.components,g,A,k;if(ho.prototype=o,!p)k=new ho("glyf",i.instructions),k.instructionCount=0,k.callDepth=0,gu(i,k,u,h),A=k.gZone;else{let E=o.font;A=[],g=[];for(let j=0;j<p.length;j++){let M=p[j],re=E.glyphs.get(M.glyphIndex);k=new ho("glyf",re.instructions),k.instructionCount=0,k.callDepth=0,gu(re,k,u,h);let te=Math.round(M.dx*u),Ae=Math.round(M.dy*h),fe=k.gZone,je=k.contours;for(let Tr=0;Tr<fe.length;Tr++){let fr=fe[Tr];fr.xTouched=fr.yTouched=!1,fr.xo=fr.x=fr.x+te,fr.yo=fr.y=fr.y+Ae}let pt=A.length;A.push.apply(A,fe);for(let Tr=0;Tr<je.length;Tr++)g.push(je[Tr]+pt)}i.instructions&&!k.inhibitGridFit&&(k=new ho("glyf",i.instructions),k.gZone=k.z0=k.z1=k.z2=A,k.contours=g,A.push(new uo(0,0),new uo(Math.round(i.advanceWidth*u),0)),al(k),A.length-=2)}return A},gu=function(i,o,u,h){let p=i.points||[],g=p.length,A=o.gZone=o.z0=o.z1=o.z2=[],k=o.contours=[],E;for(let re=0;re<g;re++)E=p[re],A[re]=new uo(E.x*u,E.y*h,E.lastPointOfContour,E.onCurve);let j,M;for(let re=0;re<g;re++)E=A[re],j||(j=E,k.push(re)),E.lastPointOfContour?(E.nextPointOnContour=j,j.prevPointOnContour=E,j=void 0):(M=A[re+1],E.nextPointOnContour=M,M.prevPointOnContour=E);o.inhibitGridFit||(A.push(new uo(0,0),new uo(Math.round(i.advanceWidth*u),0)),al(o),A.length-=2)},al=function(i){let o=i.prog;if(!o)return;let u=o.length,h;for(i.ip=0;i.ip<u;i.ip++){if(++i.instructionCount>sh)throw new Error("Hinting instructions exceeded maximum of "+sh);if(h=wd[o[i.ip]],!h)throw new Error("unknown instruction: 0x"+Number(o[i.ip]).toString(16));h(i)}};function ol(i){let o=i.tZone=new Array(i.gZone.length);for(let u=0;u<o.length;u++)o[u]=new uo(0,0)}function Rl(i,o){let u=i.prog,h=i.ip,p=1,g;do if(g=u[++h],g===88)p++;else if(g===89)p--;else if(g===64)h+=u[h+1]+1;else if(g===65)h+=2*u[h+1]+1;else if(g>=176&&g<=183)h+=g-176+1;else if(g>=184&&g<=191)h+=(g-184+1)*2;else if(o&&p===1&&g===27)break;while(p>0);i.ip=h}function Fs(i,o){o.fv=o.pv=o.dpv=i}function oh(i,o){o.pv=o.dpv=i}function Sd(i,o){o.fv=i}function lh(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.pv=o.dpv=Nl(k,E)}function Cd(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.fv=Nl(k,E)}function ch(i){let o=i.stack,u=o.pop(),h=o.pop();i.pv=i.dpv=Nl(h,u)}function S(i){let o=i.stack,u=o.pop(),h=o.pop();i.fv=Nl(h,u)}function Q(i){let o=i.stack,u=i.pv;o.push(u.x*16384),o.push(u.y*16384)}function he(i){let o=i.stack,u=i.fv;o.push(u.x*16384),o.push(u.y*16384)}function it(i){i.fv=i.pv}function kt(i){let o=i.stack,u=o.pop(),h=o.pop(),p=o.pop(),g=o.pop(),A=o.pop(),k=i.z0,E=i.z1,j=k[u],M=k[h],re=E[p],te=E[g],Ae=i.z2[A],fe=j.x,je=j.y,pt=M.x,Tr=M.y,fr=re.x,Pr=re.y,cn=te.x,Vn=te.y,rs=(fe-pt)*(Pr-Vn)-(je-Tr)*(fr-cn),ns=fe*Tr-je*pt,Gs=fr*Vn-Pr*cn;Ae.x=(ns*(fr-cn)-Gs*(fe-pt))/rs,Ae.y=(ns*(Pr-Vn)-Gs*(je-Tr))/rs}function Kt(i){i.rp0=i.stack.pop()}function Dr(i){i.rp1=i.stack.pop()}function Nn(i){i.rp2=i.stack.pop()}function Gn(i){let o=i.stack.pop();switch(i.zp0=o,o){case 0:i.tZone||ol(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function $n(i){let o=i.stack.pop();switch(i.zp1=o,o){case 0:i.tZone||ol(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function Zi(i){let o=i.stack.pop();switch(i.zp2=o,o){case 0:i.tZone||ol(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function In(i){let o=i.stack.pop();switch(i.zp0=i.zp1=i.zp2=o,o){case 0:i.tZone||ol(i),i.z0=i.z1=i.z2=i.tZone;break;case 1:i.z0=i.z1=i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function da(i){i.loop=i.stack.pop(),i.loop>Ic&&(i.loop=Ic)}function Uo(i){i.round=Td}function zo(i){i.round=xu}function Va(i){let o=i.stack.pop();i.minDis=o/64}function Ki(i){Rl(i,!1)}function fo(i){let o=i.stack.pop();i.ip+=o-1}function Lp(i){let o=i.stack.pop();i.cvCutIn=o/64}function _d(i){let o=i.stack;o.push(o[o.length-1])}function Ip(i){i.stack.pop()}function R4(i){i.stack.length=0}function M4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u),o.push(h)}function j4(i){let o=i.stack;o.push(o.length)}function D4(i){let o=i.stack,u=o.pop(),h=o.pop();if(h>Ic&&(h=Ic),++i.callDepth>il)throw new Error("Hinting call depth exceeded maximum of "+il);let p=i.ip,g=i.prog;i.prog=i.funcs[u];for(let A=0;A<h;A++)al(i);i.ip=p,i.prog=g,i.callDepth--}function B4(i){let o=i.stack.pop();if(++i.callDepth>il)throw new Error("Hinting call depth exceeded maximum of "+il);let u=i.ip,h=i.prog;i.prog=i.funcs[o],al(i),i.ip=u,i.prog=h,i.callDepth--}function Q4(i){let o=i.stack,u=o.pop();o.push(o[o.length-u])}function P4(i){let o=i.stack,u=o.pop();o.push(o.splice(o.length-u,1)[0])}function O4(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");let o=i.stack,u=i.prog,h=i.ip,p=o.pop(),g=h;for(;u[++h]!==45;);i.ip=h,i.funcs[p]=u.slice(g+1,h)}function tx(i,o){let u=o.stack.pop(),h=o.z0[u],p=o.fv,g=o.pv,A=g.distance(h,si);i&&(A=o.round(A)),p.setRelative(h,si,A,g),p.touch(h),o.rp0=o.rp1=u}function rx(i,o){let u=o.z2,h=u.length-2,p,g,A;for(let k=0;k<h;k++)p=u[k],!i.touched(p)&&(g=p.prevTouched(i),g!==p&&(A=p.nextTouched(i),g===A&&i.setRelative(p,p,i.distance(g,g,!1,!0),i,!0),i.interpolate(p,g,A,i)))}function nx(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=o.loop,E=o.z2;for(;k--;){let j=u.pop(),M=E[j],re=A.distance(p,p,!1,!0);g.setRelative(M,M,re,A),g.touch(M)}o.loop=1}function sx(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=u.pop(),E=o.z2[o.contours[k]],j=E,M=A.distance(p,p,!1,!0);do j!==p&&g.setRelative(j,j,M,A),j=j.nextPointOnContour;while(j!==E)}function ix(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=u.pop(),E;switch(k){case 0:E=o.tZone;break;case 1:E=o.gZone;break;default:throw new Error("Invalid zone")}let j,M=A.distance(p,p,!1,!0),re=E.length-2;for(let te=0;te<re;te++)j=E[te],g.setRelative(j,j,M,A)}function F4(i){let o=i.stack,u=i.loop,h=i.fv,p=o.pop()/64,g=i.z2;for(;u--;){let A=o.pop(),k=g[A];h.setRelative(k,k,p),h.touch(k)}i.loop=1}function $4(i){let o=i.stack,u=i.rp1,h=i.rp2,p=i.loop,g=i.z0[u],A=i.z1[h],k=i.fv,E=i.dpv,j=i.z2;for(;p--;){let M=o.pop(),re=j[M];k.interpolate(re,g,A,E),k.touch(re)}i.loop=1}function ax(i,o){let u=o.stack,h=u.pop()/64,p=u.pop(),g=o.z1[p],A=o.z0[o.rp0],k=o.fv,E=o.pv;k.setRelative(g,A,h,E),k.touch(g),o.rp1=o.rp0,o.rp2=p,i&&(o.rp0=p)}function U4(i){let o=i.stack,u=i.rp0,h=i.z0[u],p=i.loop,g=i.fv,A=i.pv,k=i.z1;for(;p--;){let E=o.pop(),j=k[E];g.setRelative(j,h,0,A),g.touch(j)}i.loop=1}function z4(i){i.round=ih}function ox(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z0[p],A=o.fv,k=o.pv,E=o.cvt[h],j=k.distance(g,si);i&&(Math.abs(j-E)<o.cvCutIn&&(j=E),j=o.round(j)),A.setRelative(g,si,j,k),o.zp0===0&&(g.xo=g.x,g.yo=g.y),A.touch(g),o.rp0=o.rp1=p}function H4(i){let o=i.prog,u=i.ip,h=i.stack,p=o[++u];for(let g=0;g<p;g++)h.push(o[++u]);i.ip=u}function W4(i){let o=i.ip,u=i.prog,h=i.stack,p=u[++o];for(let g=0;g<p;g++){let A=u[++o]<<8|u[++o];A&32768&&(A=-((A^65535)+1)),h.push(A)}i.ip=o}function G4(i){let o=i.stack,u=i.store;u||(u=i.store=[]);let h=o.pop(),p=o.pop();u[p]=h}function V4(i){let o=i.stack,u=i.store,h=o.pop(),p=u&&u[h]||0;o.push(p)}function q4(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u/64}function Y4(i){let o=i.stack,u=o.pop();o.push(i.cvt[u]*64)}function lx(i,o){let u=o.stack,h=u.pop(),p=o.z2[h];u.push(o.dpv.distance(p,si,i,!1)*64)}function cx(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z1[h],A=o.z0[p],k=o.dpv.distance(A,g,i,i);o.stack.push(Math.round(k*64))}function Z4(i){i.stack.push(i.ppem)}function K4(i){i.autoFlip=!0}function X4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<u?1:0)}function J4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<=u?1:0)}function ew(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>u?1:0)}function tw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>=u?1:0)}function rw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u===h?1:0)}function nw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u!==h?1:0)}function sw(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?1:0)}function iw(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?0:1)}function aw(i){let o=i.stack.pop(),u;o||Rl(i,!0)}function ow(i){}function lw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u&&h?1:0)}function cw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u||h?1:0)}function uw(i){let o=i.stack,u=o.pop();o.push(u?0:1)}function Ep(i,o){let u=o.stack,h=u.pop(),p=o.fv,g=o.pv,A=o.ppem,k=o.deltaBase+(i-1)*16,E=o.deltaShift,j=o.z0;for(let M=0;M<h;M++){let re=u.pop(),te=u.pop();if(k+((te&240)>>4)!==A)continue;let Ae=(te&15)-8;Ae>=0&&Ae++;let fe=j[re];p.setRelative(fe,fe,Ae*E,g)}}function dw(i){let o=i.stack.pop();i.deltaBase=o}function hw(i){let o=i.stack.pop();i.deltaShift=Math.pow(.5,o)}function fw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h+u)}function pw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h-u)}function mw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*64/u)}function gw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*u/64)}function xw(i){let o=i.stack,u=o.pop();o.push(Math.abs(u))}function bw(i){let o=i.stack,u=o.pop();o.push(-u)}function yw(i){let o=i.stack,u=o.pop();o.push(Math.floor(u/64)*64)}function vw(i){let o=i.stack,u=o.pop();o.push(Math.ceil(u/64)*64)}function uh(i,o){let u=o.stack,h=u.pop();u.push(o.round(h/64)*64)}function ww(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u*i.ppem/i.font.unitsPerEm}function Np(i,o){let u=o.stack,h=u.pop(),p=o.ppem,g=o.deltaBase+(i-1)*16,A=o.deltaShift;for(let k=0;k<h;k++){let E=u.pop(),j=u.pop();if(g+((j&240)>>4)!==p)continue;let M=(j&15)-8;M>=0&&M++;let re=M*A;o.cvt[E]+=re}}function Aw(i){let o=i.stack.pop();i.round=bu;let u;switch(o&192){case 0:u=.5;break;case 64:u=1;break;case 128:u=2;break;default:throw new Error("invalid SROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid SROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function Tw(i){let o=i.stack.pop();i.round=bu;let u;switch(o&192){case 0:u=Math.sqrt(2)/2;break;case 64:u=Math.sqrt(2);break;case 128:u=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid S45ROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function Sw(i){i.round=Fo}function Cw(i){i.round=kp}function _w(i){i.round=ah}function kw(i){let o=i.stack.pop()}function ux(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.dpv=Nl(k,E)}function Lw(i){let o=i.stack,u=o.pop(),h=0;u&1&&(h=35),u&32&&(h|=4096),o.push(h)}function Iw(i){let o=i.stack,u=o.pop(),h=o.pop(),p=o.pop();o.push(h),o.push(u),o.push(p)}function Ew(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.max(h,u))}function Nw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.min(h,u))}function Rw(i){let o=i.stack.pop()}function Mw(i){let o=i.stack.pop(),u=i.stack.pop();switch(o){case 1:i.inhibitGridFit=!!u;return;case 2:i.ignoreCvt=!!u;return;default:throw new Error("invalid INSTCTRL[] selector")}}function nc(i,o){let u=o.stack,h=o.prog,p=o.ip;for(let g=0;g<i;g++)u.push(h[++p]);o.ip=p}function sc(i,o){let u=o.ip,h=o.prog,p=o.stack;for(let g=0;g<i;g++){let A=h[++u]<<8|h[++u];A&32768&&(A=-((A^65535)+1)),p.push(A)}o.ip=u}function mr(i,o,u,h,p,g){let A=g.stack,k=i&&A.pop(),E=A.pop(),j=g.rp0,M=g.z0[j],re=g.z1[E],te=g.minDis,Ae=g.fv,fe=g.dpv,je,pt,Tr,fr;pt=je=fe.distance(re,M,!0,!0),Tr=pt>=0?1:-1,pt=Math.abs(pt),i&&(fr=g.cvt[k],h&&Math.abs(pt-fr)<g.cvCutIn&&(pt=fr)),u&&pt<te&&(pt=te),h&&(pt=g.round(pt)),Ae.setRelative(re,M,Tr*pt,fe),Ae.touch(re),g.rp1=g.rp0,g.rp2=E,o&&(g.rp0=E)}wd=[Fs.bind(void 0,$o),Fs.bind(void 0,ja),oh.bind(void 0,$o),oh.bind(void 0,ja),Sd.bind(void 0,$o),Sd.bind(void 0,ja),lh.bind(void 0,0),lh.bind(void 0,1),Cd.bind(void 0,0),Cd.bind(void 0,1),ch,S,Q,he,it,kt,Kt,Dr,Nn,Gn,$n,Zi,In,da,Uo,zo,Va,Ki,fo,Lp,void 0,void 0,_d,Ip,R4,M4,j4,Q4,P4,void 0,void 0,void 0,D4,B4,O4,void 0,tx.bind(void 0,0),tx.bind(void 0,1),rx.bind(void 0,$o),rx.bind(void 0,ja),nx.bind(void 0,0),nx.bind(void 0,1),sx.bind(void 0,0),sx.bind(void 0,1),ix.bind(void 0,0),ix.bind(void 0,1),F4,$4,ax.bind(void 0,0),ax.bind(void 0,1),U4,z4,ox.bind(void 0,0),ox.bind(void 0,1),H4,W4,G4,V4,q4,Y4,lx.bind(void 0,0),lx.bind(void 0,1),void 0,cx.bind(void 0,0),cx.bind(void 0,1),Z4,void 0,K4,void 0,void 0,X4,J4,ew,tw,rw,nw,sw,iw,aw,ow,lw,cw,uw,Ep.bind(void 0,1),dw,hw,fw,pw,mw,gw,xw,bw,yw,vw,uh.bind(void 0,0),uh.bind(void 0,1),uh.bind(void 0,2),uh.bind(void 0,3),void 0,void 0,void 0,void 0,ww,Ep.bind(void 0,2),Ep.bind(void 0,3),Np.bind(void 0,1),Np.bind(void 0,2),Np.bind(void 0,3),Aw,Tw,void 0,void 0,Sw,void 0,Cw,_w,Ip,Ip,void 0,void 0,void 0,void 0,void 0,kw,ux.bind(void 0,0),ux.bind(void 0,1),Lw,void 0,Iw,Ew,Nw,Rw,Mw,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,nc.bind(void 0,1),nc.bind(void 0,2),nc.bind(void 0,3),nc.bind(void 0,4),nc.bind(void 0,5),nc.bind(void 0,6),nc.bind(void 0,7),nc.bind(void 0,8),sc.bind(void 0,1),sc.bind(void 0,2),sc.bind(void 0,3),sc.bind(void 0,4),sc.bind(void 0,5),sc.bind(void 0,6),sc.bind(void 0,7),sc.bind(void 0,8),mr.bind(void 0,0,0,0,0,0),mr.bind(void 0,0,0,0,0,1),mr.bind(void 0,0,0,0,0,2),mr.bind(void 0,0,0,0,0,3),mr.bind(void 0,0,0,0,1,0),mr.bind(void 0,0,0,0,1,1),mr.bind(void 0,0,0,0,1,2),mr.bind(void 0,0,0,0,1,3),mr.bind(void 0,0,0,1,0,0),mr.bind(void 0,0,0,1,0,1),mr.bind(void 0,0,0,1,0,2),mr.bind(void 0,0,0,1,0,3),mr.bind(void 0,0,0,1,1,0),mr.bind(void 0,0,0,1,1,1),mr.bind(void 0,0,0,1,1,2),mr.bind(void 0,0,0,1,1,3),mr.bind(void 0,0,1,0,0,0),mr.bind(void 0,0,1,0,0,1),mr.bind(void 0,0,1,0,0,2),mr.bind(void 0,0,1,0,0,3),mr.bind(void 0,0,1,0,1,0),mr.bind(void 0,0,1,0,1,1),mr.bind(void 0,0,1,0,1,2),mr.bind(void 0,0,1,0,1,3),mr.bind(void 0,0,1,1,0,0),mr.bind(void 0,0,1,1,0,1),mr.bind(void 0,0,1,1,0,2),mr.bind(void 0,0,1,1,0,3),mr.bind(void 0,0,1,1,1,0),mr.bind(void 0,0,1,1,1,1),mr.bind(void 0,0,1,1,1,2),mr.bind(void 0,0,1,1,1,3),mr.bind(void 0,1,0,0,0,0),mr.bind(void 0,1,0,0,0,1),mr.bind(void 0,1,0,0,0,2),mr.bind(void 0,1,0,0,0,3),mr.bind(void 0,1,0,0,1,0),mr.bind(void 0,1,0,0,1,1),mr.bind(void 0,1,0,0,1,2),mr.bind(void 0,1,0,0,1,3),mr.bind(void 0,1,0,1,0,0),mr.bind(void 0,1,0,1,0,1),mr.bind(void 0,1,0,1,0,2),mr.bind(void 0,1,0,1,0,3),mr.bind(void 0,1,0,1,1,0),mr.bind(void 0,1,0,1,1,1),mr.bind(void 0,1,0,1,1,2),mr.bind(void 0,1,0,1,1,3),mr.bind(void 0,1,1,0,0,0),mr.bind(void 0,1,1,0,0,1),mr.bind(void 0,1,1,0,0,2),mr.bind(void 0,1,1,0,0,3),mr.bind(void 0,1,1,0,1,0),mr.bind(void 0,1,1,0,1,1),mr.bind(void 0,1,1,0,1,2),mr.bind(void 0,1,1,0,1,3),mr.bind(void 0,1,1,1,0,0),mr.bind(void 0,1,1,1,0,1),mr.bind(void 0,1,1,1,0,2),mr.bind(void 0,1,1,1,0,3),mr.bind(void 0,1,1,1,1,0),mr.bind(void 0,1,1,1,1,1),mr.bind(void 0,1,1,1,1,2),mr.bind(void 0,1,1,1,1,3)];var jw=tc;function yu(i){this.char=i,this.state={},this.activeState=null}function Rp(i,o,u){this.contextName=u,this.startIndex=i,this.endOffset=o}function Dw(i,o,u){this.contextName=i,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=u}function ha(i,o){this.context=i,this.index=o,this.length=i.length,this.current=i[o],this.backtrack=i.slice(0,o),this.lookahead=i.slice(o+1)}function dh(i){this.eventId=i,this.subscribers=[]}function Bw(i){let o=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<o.length;h++){let p=o[h];Object.defineProperty(this.events,p,{value:new dh(p)})}if(i)for(let h=0;h<o.length;h++){let p=o[h],g=i[p];typeof g=="function"&&this.events[p].subscribe(g)}let u=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<u.length;h++){let p=u[h];this.events[p].subscribe(this.updateContextsRanges)}}function Ms(i){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Bw.call(this,i)}yu.prototype.setState=function(i,o){return this.state[i]=o,this.activeState={key:i,value:this.state[i]},this.activeState},yu.prototype.getState=function(i){return this.state[i]||null},Ms.prototype.inboundIndex=function(i){return i>=0&&i<this.tokens.length},Ms.prototype.composeRUD=function(i){let o=i.map(h=>this[h[0]].apply(this,h.slice(1).concat(!0))),u=h=>typeof h=="object"&&Object.prototype.hasOwnProperty.call(h,"FAIL");if(o.every(u))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:o.filter(u)};this.dispatch("composeRUD",[o.filter(h=>!u(h))])},Ms.prototype.replaceRange=function(i,o,u,h){o=o!==null?o:this.tokens.length;let p=u.every(g=>g instanceof yu);if(!isNaN(i)&&this.inboundIndex(i)&&p){let g=this.tokens.splice.apply(this.tokens,[i,o].concat(u));return h||this.dispatch("replaceToken",[i,o,u]),[g,u]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Ms.prototype.replaceToken=function(i,o,u){if(!isNaN(i)&&this.inboundIndex(i)&&o instanceof yu){let h=this.tokens.splice(i,1,o);return u||this.dispatch("replaceToken",[i,o]),[h[0],o]}else return{FAIL:"replaceToken: invalid token or index."}},Ms.prototype.removeRange=function(i,o,u){o=isNaN(o)?this.tokens.length:o;let h=this.tokens.splice(i,o);return u||this.dispatch("removeRange",[h,i,o]),h},Ms.prototype.removeToken=function(i,o){if(!isNaN(i)&&this.inboundIndex(i)){let u=this.tokens.splice(i,1);return o||this.dispatch("removeToken",[u,i]),u}else return{FAIL:"removeToken: invalid token index."}},Ms.prototype.insertToken=function(i,o,u){return i.every(h=>h instanceof yu)?(this.tokens.splice.apply(this.tokens,[o,0].concat(i)),u||this.dispatch("insertToken",[i,o]),i):{FAIL:"insertToken: invalid token(s)."}},Ms.prototype.registerModifier=function(i,o,u){this.events.newToken.subscribe(function(h,p){let g=[h,p],A=o===null||o.apply(this,g)===!0,k=[h,p];if(A){let E=u.apply(this,k);h.setState(i,E)}}),this.registeredModifiers.push(i)},dh.prototype.subscribe=function(i){return typeof i=="function"?this.subscribers.push(i)-1:{FAIL:`invalid '${this.eventId}' event handler`}},dh.prototype.unsubscribe=function(i){this.subscribers.splice(i,1)},ha.prototype.setCurrentIndex=function(i){this.index=i,this.current=this.context[i],this.backtrack=this.context.slice(0,i),this.lookahead=this.context.slice(i+1)},ha.prototype.get=function(i){switch(!0){case i===0:return this.current;case(i<0&&Math.abs(i)<=this.backtrack.length):return this.backtrack.slice(i)[0];case(i>0&&i<=this.lookahead.length):return this.lookahead[i-1];default:return null}},Ms.prototype.rangeToText=function(i){if(i instanceof Rp)return this.getRangeTokens(i).map(o=>o.char).join("")},Ms.prototype.getText=function(){return this.tokens.map(i=>i.char).join("")},Ms.prototype.getContext=function(i){return this.registeredContexts[i]||null},Ms.prototype.on=function(i,o){let u=this.events[i];return u?u.subscribe(o):null},Ms.prototype.dispatch=function(i,o){let u=this.events[i];if(u instanceof dh)for(let h=0;h<u.subscribers.length;h++)u.subscribers[h].apply(this,o||[])},Ms.prototype.registerContextChecker=function(i,o,u){if(this.getContext(i))return{FAIL:`context name '${i}' is already registered.`};if(typeof o!="function")return{FAIL:"missing context start check."};if(typeof u!="function")return{FAIL:"missing context end check."};let h=new Dw(i,o,u);return this.registeredContexts[i]=h,this.contextCheckers.push(h),h},Ms.prototype.getRangeTokens=function(i){let o=i.startIndex+i.endOffset;return[].concat(this.tokens.slice(i.startIndex,o))},Ms.prototype.getContextRanges=function(i){let o=this.getContext(i);return o?o.ranges:{FAIL:`context checker '${i}' is not registered.`}},Ms.prototype.resetContextsRanges=function(){let i=this.registeredContexts;for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let u=i[o];u.ranges=[]}},Ms.prototype.updateContextsRanges=function(){this.resetContextsRanges();let i=this.tokens.map(o=>o.char);for(let o=0;o<i.length;o++){let u=new ha(i,o);this.runContextCheck(u)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Ms.prototype.setEndOffset=function(i,o){let u=this.getContext(o).openRange.startIndex,h=new Rp(u,i,o),p=this.getContext(o).ranges;return h.rangeId=`${o}.${p.length}`,p.push(h),this.getContext(o).openRange=null,h},Ms.prototype.runContextCheck=function(i){let o=i.index;for(let u=0;u<this.contextCheckers.length;u++){let h=this.contextCheckers[u],p=h.contextName,g=this.getContext(p).openRange;if(!g&&h.checkStart(i)&&(g=new Rp(o,null,p),this.getContext(p).openRange=g,this.dispatch("contextStart",[p,o])),g&&h.checkEnd(i)){let A=o-g.startIndex+1,k=this.setEndOffset(A,p);this.dispatch("contextEnd",[p,k])}}},Ms.prototype.tokenize=function(i){this.tokens=[],this.resetContextsRanges();let o=Array.from(i);this.dispatch("start");for(let u=0;u<o.length;u++){let h=o[u],p=new ha(o,u);this.dispatch("next",[p]),this.runContextCheck(p);let g=new yu(h);this.tokens.push(g),this.dispatch("newToken",[g,p])}return this.dispatch("end",[this.tokens]),this.tokens};var Qw=Ms;function ic(i){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(i)}function dx(i){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(i)}function ac(i){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(i)}function hh(i){return/[\u0E00-\u0E7F]/.test(i)}function fh(i){return/[A-z]/.test(i)}function Pw(i){return/\s/.test(i)}function qa(i){this.font=i,this.features={}}function oc(i){this.id=i.id,this.tag=i.tag,this.substitution=i.substitution}function lc(i,o){if(!i)return-1;switch(o.format){case 1:return o.glyphs.indexOf(i);case 2:{let u=o.ranges;for(let h=0;h<u.length;h++){let p=u[h];if(i>=p.start&&i<=p.end){let g=i-p.start;return p.index+g}}break}default:return-1}return-1}function Ow(i,o){return lc(i,o.coverage)===-1?null:i+o.deltaGlyphId}function Fw(i,o){let u=lc(i,o.coverage);return u===-1?null:o.substitute[u]}function Mp(i,o){let u=[];for(let h=0;h<i.length;h++){let p=i[h],g=o.current;g=Array.isArray(g)?g[0]:g;let A=lc(g,p);A!==-1&&u.push(A)}return u.length!==i.length?-1:u}function $w(i,o){let u=o.inputCoverage.length+o.lookaheadCoverage.length+o.backtrackCoverage.length;if(i.context.length<u)return[];let h=Mp(o.inputCoverage,i);if(h===-1)return[];let p=o.inputCoverage.length-1;if(i.lookahead.length<o.lookaheadCoverage.length)return[];let g=i.lookahead.slice(p);for(;g.length&&ac(g[0].char);)g.shift();let A=new ha(g,0),k=Mp(o.lookaheadCoverage,A),E=[].concat(i.backtrack);for(E.reverse();E.length&&ac(E[0].char);)E.shift();if(E.length<o.backtrackCoverage.length)return[];let j=new ha(E,0),M=Mp(o.backtrackCoverage,j),re=h.length===o.inputCoverage.length&&k.length===o.lookaheadCoverage.length&&M.length===o.backtrackCoverage.length,te=[];if(re)for(let Ae=0;Ae<o.lookupRecords.length;Ae++){let fe=o.lookupRecords[Ae],je=fe.lookupListIndex,pt=this.getLookupByIndex(je);for(let Tr=0;Tr<pt.subtables.length;Tr++){let fr=pt.subtables[Tr],Pr,cn=this.getSubstitutionType(pt,fr);if(cn==="71"?(cn=this.getSubstitutionType(fr,fr.extension),Pr=this.getLookupMethod(fr,fr.extension),fr=fr.extension):Pr=this.getLookupMethod(pt,fr),cn==="12"){let Vn=i.get(fe.sequenceIndex),rs=Pr(Vn);rs&&te.push(rs)}else if(cn==="21"){let Vn=i.get(fe.sequenceIndex),rs=Pr(Vn);rs&&te.push(rs)}else throw new Error(`Substitution type ${cn} is not supported in chaining substitution`)}}return te}function Uw(i,o){let u=i.current,h=lc(u,o.coverage);if(h===-1)return null;let p,g=o.ligatureSets[h];for(let A=0;A<g.length;A++){p=g[A];for(let k=0;k<p.components.length;k++){let E=i.lookahead[k],j=p.components[k];if(E!==j)break;if(k===p.components.length-1)return p}}return null}function zw(i,o){let u=i.current;if(lc(u,o.coverage)===-1)return null;for(let h of o.ruleSets)for(let p of h){let g=!0;for(let A=0;A<p.input.length;A++)if(i.lookahead[A]!==p.input[A]){g=!1;break}if(g){let A=[];A.push(u);for(let E=0;E<p.input.length;E++)A.push(p.input[E]);let k=(E,j)=>{let{lookupListIndex:M,sequenceIndex:re}=j,{subtables:te}=this.getLookupByIndex(M);for(let Ae of te)lc(E[re],Ae.coverage)!==-1&&(E[re]=Ae.deltaGlyphId)};for(let E=0;E<p.lookupRecords.length;E++){let j=p.lookupRecords[E];k(A,j)}return A}}return null}function Hw(i,o){if(i.context.length<o.coverages.length)return[];for(let h=0;h<o.coverages.length;h++){let p=i.get(h);if(p=Array.isArray(p)?p[0]:p,lc(p,o.coverages[h])===-1)return[]}let u=[];for(let h=0;h<o.lookupRecords.length;h++){let p=o.lookupRecords[h],g=p.lookupListIndex,A=this.getLookupByIndex(g);for(let k=0;k<A.subtables.length;k++){let E=A.subtables[k],j,M=this.getSubstitutionType(A,E);if(M==="71"?(M=this.getSubstitutionType(E,E.extension),j=this.getLookupMethod(E,E.extension),E=E.extension):j=this.getLookupMethod(A,E),M==="12"){let re=i.get(p.sequenceIndex),te=j(re);te&&u.push(te)}else if(M==="21"){let re=i.get(p.sequenceIndex),te=j(re);te&&u.push(te)}}}return u}function Ww(i,o){let u=lc(i,o.coverage);return u===-1?null:o.sequences[u]}qa.prototype.getDefaultScriptFeaturesIndexes=function(){let i=this.font.tables.gsub.scripts;for(let o=0;o<i.length;o++){let u=i[o];if(u.tag==="DFLT")return u.script.defaultLangSys.featureIndexes}return[]},qa.prototype.getScriptFeaturesIndexes=function(i){if(!this.font.tables.gsub)return[];if(!i)return this.getDefaultScriptFeaturesIndexes();let o=this.font.tables.gsub.scripts;for(let u=0;u<o.length;u++){let h=o[u];if(h.tag===i&&h.script.defaultLangSys)return h.script.defaultLangSys.featureIndexes;{let p=h.langSysRecords;if(p)for(let g=0;g<p.length;g++){let A=p[g];if(A.tag===i)return A.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},qa.prototype.mapTagsToFeatures=function(i,o){let u={};for(let h=0;h<i.length;h++){let p=i[h].tag,g=i[h].feature;u[p]=g}this.features[o].tags=u},qa.prototype.getScriptFeatures=function(i){let o=this.features[i];if(Object.prototype.hasOwnProperty.call(this.features,i))return o;let u=this.getScriptFeaturesIndexes(i);if(!u)return null;let h=this.font.tables.gsub;return o=u.map(p=>h.features[p]),this.features[i]=o,this.mapTagsToFeatures(o,i),o},qa.prototype.getSubstitutionType=function(i,o){let u=i.lookupType.toString(),h=o.substFormat.toString();return u+h},qa.prototype.getLookupMethod=function(i,o){let u=this.getSubstitutionType(i,o);switch(u){case"11":return h=>Ow.apply(this,[h,o]);case"12":return h=>Fw.apply(this,[h,o]);case"63":return h=>$w.apply(this,[h,o]);case"41":return h=>Uw.apply(this,[h,o]);case"21":return h=>Ww.apply(this,[h,o]);case"51":return h=>zw.apply(this,[h,o]);case"53":return h=>Hw.apply(this,[h,o]);default:throw new Error(`substitutionType : ${u} lookupType: ${i.lookupType} - substFormat: ${o.substFormat} is not yet supported`)}},qa.prototype.lookupFeature=function(i){let o=i.contextParams,u=o.index,h=this.getFeature({tag:i.tag,script:i.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${i.tag}' for script '${i.script}'.`);let p=this.getFeatureLookups(h),g=[].concat(o.context);for(let A=0;A<p.length;A++){let k=p[A],E=this.getLookupSubtables(k);for(let j=0;j<E.length;j++){let M=E[j],re=this.getSubstitutionType(k,M),te;re==="71"?(re=this.getSubstitutionType(M,M.extension),te=this.getLookupMethod(M,M.extension),M=M.extension):te=this.getLookupMethod(k,M);let Ae;switch(re){case"11":Ae=te(o.current),Ae&&g.splice(u,1,new oc({id:11,tag:i.tag,substitution:Ae}));break;case"12":Ae=te(o.current),Ae&&g.splice(u,1,new oc({id:12,tag:i.tag,substitution:Ae}));break;case"63":Ae=te(o),Array.isArray(Ae)&&Ae.length&&g.splice(u,1,new oc({id:63,tag:i.tag,substitution:Ae}));break;case"41":Ae=te(o),Ae&&g.splice(u,1,new oc({id:41,tag:i.tag,substitution:Ae}));break;case"21":Ae=te(o.current),Ae&&g.splice(u,1,new oc({id:21,tag:i.tag,substitution:Ae}));break;case"51":case"53":Ae=te(o),Array.isArray(Ae)&&Ae.length&&g.splice(u,1,new oc({id:parseInt(re),tag:i.tag,substitution:Ae}));break}o=new ha(g,u),!(Array.isArray(Ae)&&!Ae.length)&&(Ae=null)}}return g.length?g:null},qa.prototype.supports=function(i){if(!i.script)return!1;this.getScriptFeatures(i.script);let o=Object.prototype.hasOwnProperty.call(this.features,i.script);if(!i.tag)return o;let u=this.features[i.script].some(h=>h.tag===i.tag);return o&&u},qa.prototype.getLookupSubtables=function(i){return i.subtables||null},qa.prototype.getLookupByIndex=function(i){return this.font.tables.gsub.lookups[i]||null},qa.prototype.getFeatureLookups=function(i){return i.lookupListIndexes.map(this.getLookupByIndex.bind(this))},qa.prototype.getFeature=function(i){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,i.script)||this.getScriptFeatures(i.script);let o=this.features[i.script];return o?o.tags[i.tag]?this.features[i.script].tags[i.tag]:null:{FAIL:`No feature for script ${i.script}`}};var Gw=qa;function Vw(i){let o=i.current,u=i.get(-1);return u===null&&ic(o)||!ic(u)&&ic(o)}function qw(i){let o=i.get(1);return o===null||!ic(o)}var Yw={startCheck:Vw,endCheck:qw};function Zw(i){let o=i.current,u=i.get(-1);return(ic(o)||ac(o))&&!ic(u)}function Kw(i){let o=i.get(1);switch(!0){case o===null:return!0;case(!ic(o)&&!ac(o)):{let u=Pw(o);if(!u)return!0;if(u){let h=!1;if(h=i.lookahead.some(p=>ic(p)||ac(p)),!h)return!0}break}default:return!1}}var Xw={startCheck:Zw,endCheck:Kw};function Jw(i,o,u){o[u].setState(i.tag,i.substitution)}function e7(i,o,u){o[u].setState(i.tag,i.substitution)}function jp(i,o,u){for(let h=0;h<i.substitution.length;h++){let p=i.substitution[h],g=o[u+h];if(Array.isArray(p)){p.length?g.setState(i.tag,p[0]):g.setState("deleted",!0);continue}g.setState(i.tag,p)}}function t7(i,o,u){let h=o[u];h.setState(i.tag,i.substitution.ligGlyph);let p=i.substitution.components.length;for(let g=0;g<p;g++)h=o[u+g+1],h.setState("deleted",!0)}var hx={11:Jw,12:e7,63:jp,41:t7,51:jp,53:jp};function r7(i,o,u){i instanceof oc&&hx[i.id]&&hx[i.id](i,o,u)}var Nc=r7;function n7(i){let o=[].concat(i.backtrack);for(let u=o.length-1;u>=0;u--){let h=o[u],p=dx(h),g=ac(h);if(!p&&!g)return!0;if(p)return!1}return!1}function s7(i){if(dx(i.current))return!1;for(let o=0;o<i.lookahead.length;o++){let u=i.lookahead[o];if(!ac(u))return!0}return!1}function i7(i){let o="arab",u=this.featuresTags[o],h=this.tokenizer.getRangeTokens(i);if(h.length===1)return;let p=new ha(h.map(A=>A.getState("glyphIndex")),0),g=new ha(h.map(A=>A.char),0);for(let A=0;A<h.length;A++){let k=h[A];if(ac(k.char))continue;p.setCurrentIndex(A),g.setCurrentIndex(A);let E=0;n7(g)&&(E|=1),s7(g)&&(E|=2);let j;switch(E){case 1:j="fina";break;case 2:j="init";break;case 3:j="medi";break}if(u.indexOf(j)===-1)continue;let M=this.query.lookupFeature({tag:j,script:o,contextParams:p});if(M instanceof Error){console.info(M.message);continue}for(let re=0;re<M.length;re++){let te=M[re];te instanceof oc&&(Nc(te,h,re),p.context[re]=te.substitution)}}}var a7=i7;function fx(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function o7(i){let o="arab",u=this.tokenizer.getRangeTokens(i),h=fx(u);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];Nc(k,u,p)}h=fx(u)}}}var l7=o7;function c7(i){return i.index===0&&i.context.length>1}function u7(i){return i.index===i.context.length-1}var d7={startCheck:c7,endCheck:u7};function px(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function h7(i){let o="delf",u="ccmp",h=this.tokenizer.getRangeTokens(i),p=px(h);for(let g=0;g<p.context.length;g++){if(!this.query.getFeature({tag:u,script:o,contextParams:p}))continue;p.setCurrentIndex(g);let A=this.query.lookupFeature({tag:u,script:o,contextParams:p});if(A.length){for(let k=0;k<A.length;k++){let E=A[k];Nc(E,h,g)}p=px(h)}}}var f7=h7;function p7(i){let o=i.current,u=i.get(-1);return u===null&&fh(o)||!fh(u)&&fh(o)}function m7(i){let o=i.get(1);return o===null||!fh(o)}var g7={startCheck:p7,endCheck:m7};function mx(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function x7(i){let o="latn",u=this.tokenizer.getRangeTokens(i),h=mx(u);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];Nc(k,u,p)}h=mx(u)}}}var b7=x7;function y7(i){let o=i.current,u=i.get(-1);return u===null&&hh(o)||!hh(u)&&hh(o)}function v7(i){let o=i.get(1);return o===null||!hh(o)}var w7={startCheck:y7,endCheck:v7};function gx(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function A7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=gx(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"ccmp",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];Nc(k,u,p)}h=gx(u,p)}}}var T7=A7;function xx(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function S7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=xx(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];Nc(k,u,p)}h=xx(u,p)}}}var C7=S7;function bx(i,o){let u=i.map(h=>h.activeState.value);return new ha(u,o||0)}function _7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=bx(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];Nc(k,u,p)}h=bx(u,p)}}}var k7=_7;function Dp(i){if(i===null)return!1;let o=i.codePointAt(0);return o>=6155&&o<=6157||o>=65024&&o<=65039||o>=917760&&o<=917999}function L7(i){let o=i.current,u=i.get(1);return u===null&&Dp(o)||Dp(u)}function I7(i){let o=i.get(1);return o===null||!Dp(o)}var E7={startCheck:L7,endCheck:I7};function N7(i){let o=this.query.font,u=this.tokenizer.getRangeTokens(i);if(u[1].setState("deleted",!0),o.tables.cmap&&o.tables.cmap.varSelectorList){let h=u[0].char.codePointAt(0),p=u[1].char.codePointAt(0),g=o.tables.cmap.varSelectorList[p];if(g!==void 0&&g.nonDefaultUVS){let A=g.nonDefaultUVS.uvsMappings;if(A[h]){let k=A[h].glyphID;o.glyphs.glyphs[k]!==void 0&&u[0].setState("glyphIndex",k)}}}}var R7=N7;function po(i){this.baseDir=i||"ltr",this.tokenizer=new Qw,this.featuresTags={}}po.prototype.setText=function(i){this.text=i},po.prototype.contextChecks={ccmpReplacementCheck:d7,latinWordCheck:g7,arabicWordCheck:Yw,arabicSentenceCheck:Xw,thaiWordCheck:w7,unicodeVariationSequenceCheck:E7};function vu(i){let o=this.contextChecks[`${i}Check`];return this.tokenizer.registerContextChecker(i,o.startCheck,o.endCheck)}function M7(){return vu.call(this,"ccmpReplacement"),vu.call(this,"latinWord"),vu.call(this,"arabicWord"),vu.call(this,"arabicSentence"),vu.call(this,"thaiWord"),vu.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function j7(){let i=this.tokenizer.getContextRanges("arabicSentence");for(let o=0;o<i.length;o++){let u=i[o],h=this.tokenizer.getRangeTokens(u);this.tokenizer.replaceRange(u.startIndex,u.endOffset,h.reverse())}}po.prototype.registerFeatures=function(i,o){let u=o.filter(h=>this.query.supports({script:i,tag:h}));Object.prototype.hasOwnProperty.call(this.featuresTags,i)?this.featuresTags[i]=this.featuresTags[i].concat(u):this.featuresTags[i]=u},po.prototype.applyFeatures=function(i,o){if(!i)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Gw(i));for(let u=0;u<o.length;u++){let h=o[u];this.query.supports({script:h.script})&&this.registerFeatures(h.script,h.tags)}},po.prototype.registerModifier=function(i,o,u){this.tokenizer.registerModifier(i,o,u)};function kd(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function D7(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;kd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];a7.call(this,u)}}function B7(){kd.call(this);let i=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<i.length;o++){let u=i[o];f7.call(this,u)}}function Q7(){if(!this.hasFeatureEnabled("arab","rlig"))return;kd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];l7.call(this,u)}}function P7(){if(!this.hasFeatureEnabled("latn","liga"))return;kd.call(this);let i=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<i.length;o++){let u=i[o];b7.call(this,u)}}function O7(){let i=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<i.length;o++){let u=i[o];R7.call(this,u)}}function F7(){kd.call(this);let i=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<i.length;o++){let u=i[o];this.hasFeatureEnabled("thai","liga")&&C7.call(this,u),this.hasFeatureEnabled("thai","rlig")&&k7.call(this,u),this.hasFeatureEnabled("thai","ccmp")&&T7.call(this,u)}}po.prototype.checkContextReady=function(i){return!!this.tokenizer.getContext(i)},po.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&B7.call(this),this.checkContextReady("arabicWord")&&(D7.call(this),Q7.call(this)),this.checkContextReady("latinWord")&&P7.call(this),this.checkContextReady("arabicSentence")&&j7.call(this),this.checkContextReady("thaiWord")&&F7.call(this),this.checkContextReady("unicodeVariationSequence")&&O7.call(this)},po.prototype.hasFeatureEnabled=function(i,o){return(this.featuresTags[i]||[]).indexOf(o)!==-1},po.prototype.processText=function(i){(!this.text||this.text!==i)&&(this.setText(i),M7.call(this),this.applyFeaturesToContexts())},po.prototype.getBidiText=function(i){return this.processText(i),this.tokenizer.getText()},po.prototype.getTextGlyphs=function(i){this.processText(i);let o=[];for(let u=0;u<this.tokenizer.tokens.length;u++){let h=this.tokenizer.tokens[u];if(h.state.deleted)continue;let p=h.activeState.value;o.push(Array.isArray(p)?p[0]:p)}return o};var $7=po;function Bp(i){return{fontFamily:{en:i.familyName||" "},fontSubfamily:{en:i.styleName||" "},fullName:{en:i.fullName||i.familyName+" "+i.styleName},postScriptName:{en:i.postScriptName||(i.familyName+i.styleName).replace(/\s/g,"")},designer:{en:i.designer||" "},designerURL:{en:i.designerURL||" "},manufacturer:{en:i.manufacturer||" "},manufacturerURL:{en:i.manufacturerURL||" "},license:{en:i.license||" "},licenseURL:{en:i.licenseURL||" "},version:{en:i.version||"Version 0.1"},description:{en:i.description||" "},copyright:{en:i.copyright||" "},trademark:{en:i.trademark||" "}}}function Kn(i){if(i=i||{},i.tables=i.tables||{},!i.empty){if(!i.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!i.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!i.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!i.ascender)throw new Error("When creating a new Font object, ascender is required.");if(i.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=Bp(i),this.names.macintosh=Bp(i),this.names.windows=Bp(i),this.unitsPerEm=i.unitsPerEm||1e3,this.ascender=i.ascender,this.descender=i.descender,this.createdTimestamp=i.createdTimestamp,this.italicAngle=i.italicAngle||0,this.weightClass=i.weightClass||0;let o=0;i.fsSelection?o=i.fsSelection:(this.italicAngle<0?o|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(o|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(o|=this.fsSelectionValues.BOLD),o===0&&(o=this.fsSelectionValues.REGULAR)),(!i.panose||!Array.isArray(i.panose))&&(i.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(i.tables,{os2:Object.assign({usWeightClass:i.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:i.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:i.panose[0]||0,bSerifStyle:i.panose[1]||0,bWeight:i.panose[2]||0,bProportion:i.panose[3]||0,bContrast:i.panose[4]||0,bStrokeVariation:i.panose[5]||0,bArmStyle:i.panose[6]||0,bLetterform:i.panose[7]||0,bMidline:i.panose[8]||0,bXHeight:i.panose[9]||0,fsSelection:o},i.tables.os2)})}this.supported=!0,this.glyphs=new Or.GlyphSet(this,i.glyphs||[]),this.encoding=new qr(this),this.position=new yr(this),this.substitution=new ni(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(o,u,h)=>(o[u]=h,o.fvar&&(o.gvar||o.cff2)&&!this.variation&&(this.variation=new mu(this)),!0)}),this.palettes=new qi(this),this.layers=new Oo(this),this.svgImages=new Mi(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new jw(this):null}})}Kn.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)>0},Kn.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},Kn.prototype.charToGlyph=function(i){let o=this.charToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Kn.prototype.updateFeatures=function(i){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(u=>i[u])}:o)},Kn.prototype.stringToGlyphIndexes=function(i,o){let u=new $7,h=g=>this.charToGlyphIndex(g.char);u.registerModifier("glyphIndex",null,h);let p=o?this.updateFeatures(o.features):this.defaultRenderOptions.features;return u.applyFeatures(this,p),u.getTextGlyphs(i)},Kn.prototype.stringToGlyphs=function(i,o){let u=this.stringToGlyphIndexes(i,o),h=u.length,p=new Array(h),g=this.glyphs.get(0);for(let A=0;A<h;A+=1)p[A]=this.glyphs.get(u[A])||g;return p},Kn.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},Kn.prototype.nameToGlyph=function(i){let o=this.nameToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Kn.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},Kn.prototype.getKerningValue=function(i,o){i=i.index||i,o=o.index||o;let u=this.position.defaultKerningTables;return u?this.position.getKerningValue(u,i,o):this.kerningPairs[i+","+o]||0},Kn.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Kn.prototype.forEachGlyph=function(i,o,u,h,p,g){o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:72,p=Object.assign({},this.defaultRenderOptions,p);let A=1/this.unitsPerEm*h,k=this.stringToGlyphs(i,p),E;if(p.kerning){let j=p.script||this.position.getDefaultScriptName();E=this.position.getKerningTables(j,p.language)}for(let j=0;j<k.length;j+=1){let M=k[j];if(g.call(this,M,o,u,h,p),M.advanceWidth&&(o+=M.advanceWidth*A),p.kerning&&j<k.length-1){let re=E?this.position.getKerningValue(E,M.index,k[j+1].index):this.getKerningValue(M,k[j+1]);o+=re*A}p.letterSpacing?o+=p.letterSpacing*h:p.tracking&&(o+=p.tracking/1e3*h)}return o},Kn.prototype.getPath=function(i,o,u,h,p){p=Object.assign({},this.defaultRenderOptions,p);let g=new ze;if(g._layers=[],ln(this,g,h),g.stroke){let A=1/(g.unitsPerEm||1e3)*h;g.strokeWidth*=A}return this.forEachGlyph(i,o,u,h,p,(A,k,E,j)=>{let M=A.getPath(k,E,j,p,this);if(p.drawSVG||p.drawLayers){let re=M._layers;if(re&&re.length){for(let te=0;te<re.length;te++){let Ae=re[te];g._layers.push(Ae)}return}}g.extend(M)}),g},Kn.prototype.getPaths=function(i,o,u,h,p){p=Object.assign({},this.defaultRenderOptions,p);let g=[];return this.forEachGlyph(i,o,u,h,p,function(A,k,E,j){let M=A.getPath(k,E,j,p,this);g.push(M)}),g},Kn.prototype.getAdvanceWidth=function(i,o,u){return u=Object.assign({},this.defaultRenderOptions,u),this.forEachGlyph(i,0,0,o,u,function(){})},Kn.prototype.draw=function(i,o,u,h,p,g){this.getPath(o,u,h,p,g).draw(i)},Kn.prototype.drawPoints=function(i,o,u,h,p,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,p,g,function(A,k,E,j){A.drawPoints(i,k,E,j,g,this)})},Kn.prototype.drawMetrics=function(i,o,u,h,p,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,p,g,function(A,k,E,j){A.drawMetrics(i,k,E,j)})},Kn.prototype.getEnglishName=function(i){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[i];if(o)return o.en},Kn.prototype.validate=function(){let i=[],o=this;function u(p,g){p||(console.warn(`[opentype.js] ${g}`),i.push(g))}function h(p){let g=o.getEnglishName(p);u(g&&g.trim().length>0,"No English "+p+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),u(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let p=this.tables.colr.baseGlyphRecords,g=-1;for(let A=0;A<p.length;A++){let k=p[A].glyphID;if(u(g<p[A].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${k} comes after ${g}`),g>p[A].glyphID)break;g=k}}return i},Kn.prototype.toTables=function(){return $.fontToTable(this)},Kn.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Kn.prototype.toArrayBuffer=function(){let i=this.toTables().encode(),o=new ArrayBuffer(i.length),u=new Uint8Array(o);for(let h=0;h<i.length;h++)u[h]=i[h];return o},Kn.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Kn.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Kn.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Kn.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Kn.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var yx=Kn;function U7(i,o){let u=new st.Parser(i,o),h=u.parseUShort(),p=u.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${p}`);let g=[h,p],A=u.parsePointer32(function(){return this.parseItemVariationStore()}),k=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),E=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),j=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:g,itemVariationStore:A,advanceWidth:k,lsb:E,rsb:j}}function z7(){console.warn("Writing of hvar tables is not yet supported.")}var H7={make:z7,parse:U7},W7=function(){return{coverage:this.parsePointer(we.coverage),attachPoints:this.parseList(we.pointer(we.uShortList))}},G7=function(){var i=this.parseUShort();if(me.argument(i===1||i===2||i===3,"Unsupported CaretValue table version."),i===1)return{coordinate:this.parseShort()};if(i===2)return{pointindex:this.parseShort()};if(i===3)return{coordinate:this.parseShort()}},V7=function(){return this.parseList(we.pointer(G7))},q7=function(){return{coverage:this.parsePointer(we.coverage),ligGlyphs:this.parseList(we.pointer(V7))}},Y7=function(){return this.parseUShort(),this.parseList(we.pointer(we.coverage))};function Z7(i,o){o=o||0;let u=new we(i,o),h=u.parseVersion(1);me.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var p={version:h,classDef:u.parsePointer(we.classDef),attachList:u.parsePointer(W7),ligCaretList:u.parsePointer(q7),markAttachClassDef:u.parsePointer(we.classDef)};return h>=1.2&&(p.markGlyphSets=u.parsePointer(Y7)),p}var K7={parse:Z7},Ho=new Array(10);Ho[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{posFormat:1,coverage:this.parsePointer(we.coverage),value:this.parseValueRecord()};if(o===2)return{posFormat:2,coverage:this.parsePointer(we.coverage),values:this.parseValueRecordList()};me.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Ho[2]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();me.assert(o===1||o===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let u=this.parsePointer(we.coverage),h=this.parseUShort(),p=this.parseUShort();if(o===1)return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:p,pairSets:this.parseList(we.pointer(we.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(h),value2:this.parseValueRecord(p)}})))};if(o===2){let g=this.parsePointer(we.classDef),A=this.parsePointer(we.classDef),k=this.parseUShort(),E=this.parseUShort();return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:p,classDef1:g,classDef2:A,class1Count:k,class2Count:E,classRecords:this.parseList(k,we.list(E,function(){return{value1:this.parseValueRecord(h),value2:this.parseValueRecord(p)}}))}}},Ho[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Ho[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Ho[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Ho[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Ho[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Ho[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Ho[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function X7(i,o){o=o||0;let u=new we(i,o),h=u.parseVersion(1);return me.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(Ho)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(Ho),variations:u.parseFeatureVariationsList()}}var J7=new Array(10);function e8(i){return new $e.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new $e.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new $e.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new $e.LookupList(i.lookups,J7)}])}var t8={parse:X7,make:e8};function r8(i){let o={};i.skip("uShort");let u=i.parseUShort();me.argument(u===0,"Unsupported kern sub-table version."),i.skip("uShort",2);let h=i.parseUShort();i.skip("uShort",3);for(let p=0;p<h;p+=1){let g=i.parseUShort(),A=i.parseUShort(),k=i.parseShort();o[g+","+A]=k}return o}function n8(i){let o={};i.skip("uShort"),i.parseULong()>1&&console.warn("Only the first kern subtable is supported."),i.skip("uLong");let u=i.parseUShort()&255;if(i.skip("uShort"),u===0){let h=i.parseUShort();i.skip("uShort",3);for(let p=0;p<h;p+=1){let g=i.parseUShort(),A=i.parseUShort(),k=i.parseShort();o[g+","+A]=k}}return o}function s8(i,o){let u=new st.Parser(i,o),h=u.parseUShort();if(h===0)return r8(u);if(h===1)return n8(u);throw new Error("Unsupported kern table version ("+h+").")}var i8={parse:s8};function a8(i,o,u,h){let p=new st.Parser(i,o),g=h?p.parseUShort:p.parseULong,A=[];for(let k=0;k<u+1;k+=1){let E=g.call(p);h&&(E*=2),A.push(E)}return A}var o8={parse:a8};function vx(i,o){let u=[],h=12;for(let p=0;p<o;p+=1){let g=st.getTag(i,h),A=st.getULong(i,h+4),k=st.getULong(i,h+8),E=st.getULong(i,h+12);u.push({tag:g,checksum:A,offset:k,length:E,compression:!1}),h+=16}return u}function l8(i,o){let u=[],h=44;for(let p=0;p<o;p+=1){let g=st.getTag(i,h),A=st.getULong(i,h+4),k=st.getULong(i,h+8),E=st.getULong(i,h+12),j;k<E?j="WOFF":j=!1,u.push({tag:g,offset:A,compression:j,compressedLength:k,length:E}),h+=20}return u}function Un(i,o){if(o.compression==="WOFF"){let u=new Uint8Array(i.buffer,o.offset+2,o.compressedLength-2),h=new Uint8Array(o.length);if(ye(u,h),h.byteLength!==o.length)throw new Error("Decompression error: "+o.tag+" decompressed length doesn't match recorded length");return{data:new DataView(h.buffer,0),offset:0}}else return{data:i,offset:o.offset}}function c8(i,o={}){let u,h,p=new yx({empty:!0});i.constructor!==ArrayBuffer&&(i=new Uint8Array(i).buffer);let g=new DataView(i,0),A,k=[],E=st.getTag(g,0);if(E==="\0\0\0"||E==="true"||E==="typ1")p.outlinesFormat="truetype",A=st.getUShort(g,4),k=vx(g,A);else if(E==="OTTO")p.outlinesFormat="cff",A=st.getUShort(g,4),k=vx(g,A);else if(E==="wOFF"){let Sr=st.getTag(g,4);if(Sr==="\0\0\0")p.outlinesFormat="truetype";else if(Sr==="OTTO")p.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+E);A=st.getUShort(g,12),k=l8(g,A)}else if(E==="wOF2"){let Sr="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+Sr)}else throw new Error("Unsupported OpenType signature "+E);let j,M,re,te,Ae,fe,je,pt,Tr,fr,Pr,cn,Vn,rs,ns,Gs,Wo,un;for(let Sr=0;Sr<A;Sr+=1){let or=k[Sr],hr;switch(or.tag){case"avar":je=or;break;case"cmap":hr=Un(g,or),p.tables.cmap=Xr.parse(hr.data,hr.offset),p.encoding=new Wr(p.tables.cmap);break;case"cvt ":hr=Un(g,or),un=new st.Parser(hr.data,hr.offset),p.tables.cvt=un.parseShortList(or.length/2);break;case"fvar":re=or;break;case"STAT":te=or;break;case"gvar":Ae=or;break;case"cvar":fe=or;break;case"fpgm":hr=Un(g,or),un=new st.Parser(hr.data,hr.offset),p.tables.fpgm=un.parseByteList(or.length);break;case"head":hr=Un(g,or),p.tables.head=Hs.parse(hr.data,hr.offset),p.unitsPerEm=p.tables.head.unitsPerEm,u=p.tables.head.indexToLocFormat;break;case"hhea":hr=Un(g,or),p.tables.hhea=Pn.parse(hr.data,hr.offset),p.ascender=p.tables.hhea.ascender,p.descender=p.tables.hhea.descender,p.numberOfHMetrics=p.tables.hhea.numberOfHMetrics;break;case"HVAR":Vn=or;break;case"hmtx":cn=or;break;case"ltag":hr=Un(g,or),h=Wa.parse(hr.data,hr.offset);break;case"COLR":hr=Un(g,or),p.tables.colr=Jl.parse(hr.data,hr.offset);break;case"CPAL":hr=Un(g,or),p.tables.cpal=rn.parse(hr.data,hr.offset);break;case"maxp":hr=Un(g,or),p.tables.maxp=ia.parse(hr.data,hr.offset),p.numGlyphs=p.tables.maxp.numGlyphs;break;case"name":Gs=or;break;case"OS/2":hr=Un(g,or),p.tables.os2=Do.parse(hr.data,hr.offset);break;case"post":hr=Un(g,or),p.tables.post=fi.parse(hr.data,hr.offset),p.glyphNames=new Be(p.tables.post);break;case"prep":hr=Un(g,or),un=new st.Parser(hr.data,hr.offset),p.tables.prep=un.parseByteList(or.length);break;case"glyf":pt=or;break;case"loca":ns=or;break;case"CFF ":j=or;break;case"CFF2":M=or;break;case"kern":rs=or;break;case"GDEF":Tr=or;break;case"GPOS":fr=or;break;case"GSUB":Pr=or;break;case"meta":Wo=or;break;case"gasp":try{hr=Un(g,or),p.tables.gasp=Po.parse(hr.data,hr.offset)}catch(Xi){console.warn("Failed to parse gasp table, skipping."),console.warn(Xi)}break;case"SVG ":hr=Un(g,or),p.tables.svg=vt.parse(hr.data,hr.offset);break;default:break}}let Ya=Un(g,Gs);if(p.tables.name=Dt.parse(Ya.data,Ya.offset,h),p.names=p.tables.name,pt&&ns){let Sr=u===0,or=Un(g,ns),hr=o8.parse(or.data,or.offset,p.numGlyphs,Sr),Xi=Un(g,pt);p.glyphs=co.parse(Xi.data,Xi.offset,hr,p,o)}else if(j){let Sr=Un(g,j);os.parse(Sr.data,Sr.offset,p,o)}else if(M){let Sr=Un(g,M);os.parse(Sr.data,Sr.offset,p,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let fa=Un(g,cn);if(On.parse(p,fa.data,fa.offset,p.numberOfHMetrics,p.numGlyphs,p.glyphs,o),sr(p,o),rs){let Sr=Un(g,rs);p.kerningPairs=i8.parse(Sr.data,Sr.offset)}else p.kerningPairs={};if(Tr){let Sr=Un(g,Tr);p.tables.gdef=K7.parse(Sr.data,Sr.offset)}if(fr){let Sr=Un(g,fr);p.tables.gpos=t8.parse(Sr.data,Sr.offset),p.position.init()}if(Pr){let Sr=Un(g,Pr);p.tables.gsub=Hi.parse(Sr.data,Sr.offset)}if(re){let Sr=Un(g,re);p.tables.fvar=Ts.parse(Sr.data,Sr.offset,p.names)}if(te){let Sr=Un(g,te);p.tables.stat=Ii.parse(Sr.data,Sr.offset,p.tables.fvar)}if(Ae){re||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),pt||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let Sr=Un(g,Ae);p.tables.gvar=oo.parse(Sr.data,Sr.offset,p.tables.fvar,p.glyphs)}if(fe){re||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),p.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),pt||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let Sr=Un(g,fe);p.tables.cvar=ao.parse(Sr.data,Sr.offset,p.tables.fvar,p.tables.cvt||[])}if(je){re||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let Sr=Un(g,je);p.tables.avar=ca.parse(Sr.data,Sr.offset,p.tables.fvar)}if(Vn){re||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),cn||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let Sr=Un(g,Vn);p.tables.hvar=H7.parse(Sr.data,Sr.offset,p.tables.fvar)}if(Wo){let Sr=Un(g,Wo);p.tables.meta=mi.parse(Sr.data,Sr.offset),p.metas=p.tables.meta}return p.palettes=new qi(p),p}function u8(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function d8(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return m(x)})();(function(n,a){typeof define=="function"&&define.amd?define(a):typeof t=="object"&&t.exports?t.exports=a():n.opentype=a()})(typeof self<"u"?self:e,()=>({...r,default:r}))}),AL=vL(wL()),Oi=Fu("lru-cache:metrics"),f0=dL("lru-cache"),TL=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,am=()=>Oi.hasSubscribers||f0.hasSubscribers,hv=new Set,T2=typeof process=="object"&&process?process:{},SL=(e,t,r,n)=>{typeof T2.emitWarning=="function"?T2.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},CL=e=>!hv.has(e),xc=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),fv=e=>xc(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?uf:null:null,uf=class extends Array{constructor(e){super(e),this.fill(0)}},Oc,Bd,_L=(Oc=class{constructor(e,t){if(ai(this,"heap"),ai(this,"length"),!oe(Oc,Bd))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=fv(e);if(!t)return[];Br(Oc,Bd,!0);let r=new Oc(e,t);return Br(Oc,Bd,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Bd=new WeakMap,_n(Oc,Bd,!1),Oc),S2,C2,qo,bo,dl,Cu,hl,Qd,Pd,fl,xi,yo,ii,Cs,sn,Qa,vo,xa,Di,pl,Bi,ml,gl,wo,Ao,xl,Od,Pa,_u,Gt,om,ku,uc,Sh,To,_2,Lu,Fd,Ch,dc,hc,lm,Iu,_h,k2,L2,kh,hs,cm,I2,E2,$d,um,Ud,fc,dm,hm,kL=(hm=class{constructor(e){_n(this,Gt),_n(this,qo),_n(this,bo),_n(this,dl),_n(this,Cu),_n(this,hl),_n(this,Qd),_n(this,Pd),_n(this,fl),ai(this,"ttl"),ai(this,"ttlResolution"),ai(this,"ttlAutopurge"),ai(this,"updateAgeOnGet"),ai(this,"updateAgeOnHas"),ai(this,"allowStale"),ai(this,"noDisposeOnSet"),ai(this,"noUpdateTTL"),ai(this,"maxEntrySize"),ai(this,"sizeCalculation"),ai(this,"noDeleteOnFetchRejection"),ai(this,"noDeleteOnStaleGet"),ai(this,"allowStaleOnFetchAbort"),ai(this,"allowStaleOnFetchRejection"),ai(this,"ignoreFetchAbort"),ai(this,"backgroundFetchSize"),_n(this,xi),_n(this,yo),_n(this,ii),_n(this,Cs),_n(this,sn),_n(this,Qa),_n(this,vo),_n(this,xa),_n(this,Di),_n(this,pl),_n(this,Bi),_n(this,ml),_n(this,gl),_n(this,wo),_n(this,Ao),_n(this,xl),_n(this,Od),_n(this,Pa),_n(this,_u),_n(this,ku,()=>{}),_n(this,uc,()=>{}),_n(this,Sh,()=>{}),_n(this,To,()=>!1),_n(this,Lu,pe=>{}),_n(this,Fd,(pe,J,Re)=>{}),_n(this,Ch,(pe,J,Re,Ze)=>{if(Re||Ze)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),ai(this,S2,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:c,updateAgeOnHas:l,allowStale:d,dispose:f,onInsert:m,disposeAfter:x,noDisposeOnSet:y,noUpdateTTL:w,maxSize:v=0,maxEntrySize:T=0,sizeCalculation:C,fetchMethod:L,memoMethod:N,noDeleteOnFetchRejection:D,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:P,allowStaleOnFetchAbort:F,ignoreFetchAbort:ee,backgroundFetchSize:Z=1,perf:G}=e;if(this.backgroundFetchSize=Z,G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(Br(this,fl,G??TL),t!==0&&!xc(t))throw new TypeError("max option must be a nonnegative integer");let de=t?fv(t):Array;if(!de)throw new Error("invalid max value: "+t);if(Br(this,qo,t),Br(this,bo,v),this.maxEntrySize=T||oe(this,bo),this.sizeCalculation=C,this.sizeCalculation){if(!oe(this,bo)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(N!==void 0&&typeof N!="function")throw new TypeError("memoMethod must be a function if defined");if(Br(this,Pd,N),L!==void 0&&typeof L!="function")throw new TypeError("fetchMethod must be a function if specified");if(Br(this,Qd,L),Br(this,Od,!!L),Br(this,ii,new Map),Br(this,Cs,Array.from({length:t}).fill(void 0)),Br(this,sn,Array.from({length:t}).fill(void 0)),Br(this,Qa,new de(t)),Br(this,vo,new de(t)),Br(this,xa,0),Br(this,Di,0),Br(this,pl,_L.create(t)),Br(this,xi,0),Br(this,yo,0),typeof f=="function"&&Br(this,dl,f),typeof m=="function"&&Br(this,Cu,m),typeof x=="function"?(Br(this,hl,x),Br(this,Bi,[])):(Br(this,hl,void 0),Br(this,Bi,void 0)),Br(this,xl,!!oe(this,dl)),Br(this,_u,!!oe(this,Cu)),Br(this,Pa,!!oe(this,hl)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!D,this.allowStaleOnFetchRejection=!!P,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!ee,this.maxEntrySize!==0){if(oe(this,bo)!==0&&!xc(oe(this,bo)))throw new TypeError("maxSize must be a positive integer if specified");if(!xc(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Yt(this,Gt,_2).call(this)}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!c,this.updateAgeOnHas=!!l,this.ttlResolution=xc(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!xc(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Yt(this,Gt,om).call(this)}if(oe(this,qo)===0&&this.ttl===0&&oe(this,bo)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!oe(this,qo)&&!oe(this,bo)){let pe="LRU_CACHE_UNBOUNDED";CL(pe)&&(hv.add(pe),SL("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",pe,hm))}}get perf(){return oe(this,fl)}static unsafeExposeInternals(e){return{starts:oe(e,gl),ttls:oe(e,wo),autopurgeTimers:oe(e,Ao),sizes:oe(e,ml),keyMap:oe(e,ii),keyList:oe(e,Cs),valList:oe(e,sn),next:oe(e,Qa),prev:oe(e,vo),get head(){return oe(e,xa)},get tail(){return oe(e,Di)},free:oe(e,pl),isBackgroundFetch:t=>{var r;return Yt(r=e,Gt,hs).call(r,t)},backgroundFetch:(t,r,n,a)=>{var c;return Yt(c=e,Gt,kh).call(c,t,r,n,a)},moveToTail:t=>{var r;return Yt(r=e,Gt,Ud).call(r,t)},indexes:t=>{var r;return Yt(r=e,Gt,dc).call(r,t)},rindexes:t=>{var r;return Yt(r=e,Gt,hc).call(r,t)},isStale:t=>{var r;return oe(r=e,To).call(r,t)}}}get max(){return oe(this,qo)}get maxSize(){return oe(this,bo)}get calculatedSize(){return oe(this,yo)}get size(){return oe(this,xi)}get fetchMethod(){return oe(this,Qd)}get memoMethod(){return oe(this,Pd)}get dispose(){return oe(this,dl)}get onInsert(){return oe(this,Cu)}get disposeAfter(){return oe(this,hl)}getRemainingTTL(e){return oe(this,ii).has(e)?1/0:0}*entries(){for(let e of Yt(this,Gt,dc).call(this))oe(this,sn)[e]!==void 0&&oe(this,Cs)[e]!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield[oe(this,Cs)[e],oe(this,sn)[e]])}*rentries(){for(let e of Yt(this,Gt,hc).call(this))oe(this,sn)[e]!==void 0&&oe(this,Cs)[e]!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield[oe(this,Cs)[e],oe(this,sn)[e]])}*keys(){for(let e of Yt(this,Gt,dc).call(this)){let t=oe(this,Cs)[e];t!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield t)}}*rkeys(){for(let e of Yt(this,Gt,hc).call(this)){let t=oe(this,Cs)[e];t!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield t)}}*values(){for(let e of Yt(this,Gt,dc).call(this))oe(this,sn)[e]!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield oe(this,sn)[e])}*rvalues(){for(let e of Yt(this,Gt,hc).call(this))oe(this,sn)[e]!==void 0&&!Yt(this,Gt,hs).call(this,oe(this,sn)[e])&&(yield oe(this,sn)[e])}[(C2=Symbol.iterator,S2=Symbol.toStringTag,C2)](){return this.entries()}find(e,t={}){for(let r of Yt(this,Gt,dc).call(this)){let n=oe(this,sn)[r],a=Yt(this,Gt,hs).call(this,n)?n.__staleWhileFetching:n;if(a!==void 0&&e(a,oe(this,Cs)[r],this))return Yt(this,Gt,$d).call(this,oe(this,Cs)[r],t)}}forEach(e,t=this){for(let r of Yt(this,Gt,dc).call(this)){let n=oe(this,sn)[r],a=Yt(this,Gt,hs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,oe(this,Cs)[r],this)}}rforEach(e,t=this){for(let r of Yt(this,Gt,hc).call(this)){let n=oe(this,sn)[r],a=Yt(this,Gt,hs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,oe(this,Cs)[r],this)}}purgeStale(){let e=!1;for(let t of Yt(this,Gt,hc).call(this,{allowStale:!0}))oe(this,To).call(this,t)&&(Yt(this,Gt,fc).call(this,oe(this,Cs)[t],"expire"),e=!0);return e}info(e){let t=oe(this,ii).get(e);if(t===void 0)return;let r=oe(this,sn)[t],n=Yt(this,Gt,hs).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let a={value:n};if(oe(this,wo)&&oe(this,gl)){let c=oe(this,wo)[t],l=oe(this,gl)[t];if(c&&l){let d=c-(oe(this,fl).now()-l);a.ttl=d,a.start=Date.now()}}return oe(this,ml)&&(a.size=oe(this,ml)[t]),a}dump(){let e=[];for(let t of Yt(this,Gt,dc).call(this,{allowStale:!0})){let r=oe(this,Cs)[t],n=oe(this,sn)[t],a=Yt(this,Gt,hs).call(this,n)?n.__staleWhileFetching:n;if(a===void 0||r===void 0)continue;let c={value:a};if(oe(this,wo)&&oe(this,gl)){c.ttl=oe(this,wo)[t];let l=oe(this,fl).now()-oe(this,gl)[t];c.start=Math.floor(Date.now()-l)}oe(this,ml)&&(c.size=oe(this,ml)[t]),e.unshift([r,c])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let n=Date.now()-r.start;r.start=oe(this,fl).now()-n}Yt(this,Gt,Iu).call(this,t,r.value,r)}}set(e,t,r={}){let{status:n=Oi.hasSubscribers?{}:void 0}=r;r.status=n,n&&(n.op="set",n.key=e,t!==void 0&&(n.value=t),n.cache=this);let a=Yt(this,Gt,Iu).call(this,e,t,r);return n&&Oi.hasSubscribers&&Oi.publish(n),a}pop(){var e;try{for(;oe(this,xi);){let t=oe(this,sn)[oe(this,xa)];if(Yt(this,Gt,_h).call(this,!0),Yt(this,Gt,hs).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(oe(this,Pa)&&oe(this,Bi)){let t=oe(this,Bi),r;for(;r=t?.shift();)(e=oe(this,hl))==null||e.call(this,...r)}}}has(e,t={}){let{status:r=Oi.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let n=Yt(this,Gt,k2).call(this,e,t);return Oi.hasSubscribers&&Oi.publish(r),n}peek(e,t={}){let{status:r=am()?{}:void 0}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let n=Yt(this,Gt,L2).call(this,e,t);return Oi.hasSubscribers&&Oi.publish(r),n}fetch(e,t={}){let r=f0.hasSubscribers,{status:n=am()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Yt(this,Gt,cm).call(this,e,t);return n&&r&&(n.trace=!0,f0.tracePromise(()=>a,n).catch(()=>{})),a}forceFetch(e,t={}){let r=f0.hasSubscribers,{status:n=am()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Yt(this,Gt,I2).call(this,e,t);return n&&r&&(n.trace=!0,f0.tracePromise(()=>a,n).catch(()=>{})),a}memo(e,t={}){let{status:r=Oi.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="memo",r.key=e,t.context&&(r.context=t.context),r.cache=this);let n=Yt(this,Gt,E2).call(this,e,t);return r&&(r.value=n),Oi.hasSubscribers&&Oi.publish(r),n}get(e,t={}){let{status:r=Oi.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let n=Yt(this,Gt,$d).call(this,e,t);return r&&(n!==void 0&&(r.value=n),Oi.hasSubscribers&&Oi.publish(r)),n}delete(e){return Yt(this,Gt,fc).call(this,e,"delete")}clear(){return Yt(this,Gt,dm).call(this,"delete")}},qo=new WeakMap,bo=new WeakMap,dl=new WeakMap,Cu=new WeakMap,hl=new WeakMap,Qd=new WeakMap,Pd=new WeakMap,fl=new WeakMap,xi=new WeakMap,yo=new WeakMap,ii=new WeakMap,Cs=new WeakMap,sn=new WeakMap,Qa=new WeakMap,vo=new WeakMap,xa=new WeakMap,Di=new WeakMap,pl=new WeakMap,Bi=new WeakMap,ml=new WeakMap,gl=new WeakMap,wo=new WeakMap,Ao=new WeakMap,xl=new WeakMap,Od=new WeakMap,Pa=new WeakMap,_u=new WeakMap,Gt=new WeakSet,om=function(){let e=new uf(oe(this,qo)),t=new uf(oe(this,qo));Br(this,wo,e),Br(this,gl,t);let r=this.ttlAutopurge?Array.from({length:oe(this,qo)}):void 0;Br(this,Ao,r),Br(this,Sh,(l,d,f=oe(this,fl).now())=>{t[l]=d!==0?f:0,e[l]=d,n(l,d)}),Br(this,ku,l=>{t[l]=e[l]!==0?oe(this,fl).now():0,n(l,e[l])});let n=this.ttlAutopurge?(l,d)=>{if(r?.[l]&&(clearTimeout(r[l]),r[l]=void 0),d&&d!==0&&r){let f=setTimeout(()=>{oe(this,To).call(this,l)&&Yt(this,Gt,fc).call(this,oe(this,Cs)[l],"expire")},d+1);f.unref&&f.unref(),r[l]=f}}:()=>{};Br(this,uc,(l,d)=>{if(e[d]){let f=e[d],m=t[d];if(!f||!m)return;l.ttl=f,l.start=m,l.now=a||c();let x=l.now-m;l.remainingTTL=f-x}});let a=0,c=()=>{let l=oe(this,fl).now();if(this.ttlResolution>0){a=l;let d=setTimeout(()=>a=0,this.ttlResolution);d.unref&&d.unref()}return l};this.getRemainingTTL=l=>{let d=oe(this,ii).get(l);if(d===void 0)return 0;let f=e[d],m=t[d];if(!f||!m)return 1/0;let x=(a||c())-m;return f-x},Br(this,To,l=>{let d=t[l],f=e[l];return!!f&&!!d&&(a||c())-d>f})},ku=new WeakMap,uc=new WeakMap,Sh=new WeakMap,To=new WeakMap,_2=function(){let e=new uf(oe(this,qo));Br(this,yo,0),Br(this,ml,e),Br(this,Lu,t=>{Br(this,yo,oe(this,yo)-e[t]),e[t]=0}),Br(this,Ch,(t,r,n,a)=>{if(!xc(n)){if(Yt(this,Gt,hs).call(this,r))return this.backgroundFetchSize;if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(n=a(r,t),!xc(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return n}),Br(this,Fd,(t,r,n)=>{if(e[t]=r,oe(this,bo)){let a=oe(this,bo)-e[t];for(;oe(this,yo)>a;)Yt(this,Gt,_h).call(this,!0)}Br(this,yo,oe(this,yo)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=oe(this,yo))})},Lu=new WeakMap,Fd=new WeakMap,Ch=new WeakMap,dc=function*({allowStale:e=this.allowStale}={}){if(oe(this,xi))for(let t=oe(this,Di);Yt(this,Gt,lm).call(this,t)&&((e||!oe(this,To).call(this,t))&&(yield t),t!==oe(this,xa));)t=oe(this,vo)[t]},hc=function*({allowStale:e=this.allowStale}={}){if(oe(this,xi))for(let t=oe(this,xa);Yt(this,Gt,lm).call(this,t)&&((e||!oe(this,To).call(this,t))&&(yield t),t!==oe(this,Di));)t=oe(this,Qa)[t]},lm=function(e){return e!==void 0&&oe(this,ii).get(oe(this,Cs)[e])===e},Iu=function(e,t,r,n){var a,c,l,d;let{ttl:f=this.ttl,start:m,noDisposeOnSet:x=this.noDisposeOnSet,sizeCalculation:y=this.sizeCalculation,status:w}=r,v=Yt(this,Gt,hs).call(this,t);if(t===void 0)return w&&(w.set="deleted"),this.delete(e),this;let{noUpdateTTL:T=this.noUpdateTTL}=r;w&&!v&&(w.value=t);let C=oe(this,Ch).call(this,e,t,r.size||0,y,w);if(this.maxEntrySize&&C>this.maxEntrySize)return Yt(this,Gt,fc).call(this,e,"set"),w&&(w.set="miss",w.maxEntrySizeExceeded=!0),this;let L=oe(this,xi)===0?void 0:oe(this,ii).get(e);if(L===void 0)L=oe(this,xi)===0?oe(this,Di):oe(this,pl).length!==0?oe(this,pl).pop():oe(this,xi)===oe(this,qo)?Yt(this,Gt,_h).call(this,!1):oe(this,xi),oe(this,Cs)[L]=e,oe(this,sn)[L]=t,oe(this,ii).set(e,L),oe(this,Qa)[oe(this,Di)]=L,oe(this,vo)[L]=oe(this,Di),Br(this,Di,L),im(this,xi)._++,oe(this,Fd).call(this,L,C,w),w&&(w.set="add"),T=!1,oe(this,_u)&&!v&&((a=oe(this,Cu))==null||a.call(this,t,e,"add"));else{Yt(this,Gt,Ud).call(this,L);let N=oe(this,sn)[L];if(t!==N){if(!x)if(Yt(this,Gt,hs).call(this,N)){N!==n&&N.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:D}=N;D!==void 0&&D!==t&&(oe(this,xl)&&((c=oe(this,dl))==null||c.call(this,D,e,"set")),oe(this,Pa)&&oe(this,Bi)?.push([D,e,"set"]))}else oe(this,xl)&&((l=oe(this,dl))==null||l.call(this,N,e,"set")),oe(this,Pa)&&oe(this,Bi)?.push([N,e,"set"]);if(oe(this,Lu).call(this,L),oe(this,Fd).call(this,L,C,w),oe(this,sn)[L]=t,!v){let D=N&&Yt(this,Gt,hs).call(this,N)?N.__staleWhileFetching:N,O=D===void 0?"add":t!==D?"replace":"update";w&&(w.set=O,D!==void 0&&(w.oldValue=D)),oe(this,_u)&&this.onInsert?.(t,e,O)}}else v||(w&&(w.set="update"),oe(this,_u)&&this.onInsert?.(t,e,"update"))}if(f!==0&&!oe(this,wo)&&Yt(this,Gt,om).call(this),oe(this,wo)&&(T||oe(this,Sh).call(this,L,f,m),w&&oe(this,uc).call(this,w,L)),!x&&oe(this,Pa)&&oe(this,Bi)){let N=oe(this,Bi),D;for(;D=N?.shift();)(d=oe(this,hl))==null||d.call(this,...D)}return this},_h=function(e){var t;let r=oe(this,xa),n=oe(this,Cs)[r],a=oe(this,sn)[r],c=Yt(this,Gt,hs).call(this,a);c&&a.__abortController.abort(new Error("evicted"));let l=c?a.__staleWhileFetching:a;return(oe(this,xl)||oe(this,Pa))&&l!==void 0&&(oe(this,xl)&&((t=oe(this,dl))==null||t.call(this,l,n,"evict")),oe(this,Pa)&&oe(this,Bi)?.push([l,n,"evict"])),oe(this,Lu).call(this,r),oe(this,Ao)?.[r]&&(clearTimeout(oe(this,Ao)[r]),oe(this,Ao)[r]=void 0),e&&(oe(this,Cs)[r]=void 0,oe(this,sn)[r]=void 0,oe(this,pl).push(r)),oe(this,xi)===1?(Br(this,xa,Br(this,Di,0)),oe(this,pl).length=0):Br(this,xa,oe(this,Qa)[r]),oe(this,ii).delete(n),im(this,xi)._--,r},k2=function(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=oe(this,ii).get(e);if(a!==void 0){let c=oe(this,sn)[a];if(Yt(this,Gt,hs).call(this,c)&&c.__staleWhileFetching===void 0)return!1;if(oe(this,To).call(this,a))n&&(n.has="stale",oe(this,uc).call(this,n,a));else return r&&oe(this,ku).call(this,a),n&&(n.has="hit",oe(this,uc).call(this,n,a)),!0}else n&&(n.has="miss");return!1},L2=function(e,t){let{status:r,allowStale:n=this.allowStale}=t,a=oe(this,ii).get(e);if(a===void 0||!n&&oe(this,To).call(this,a)){r&&(r.peek=a===void 0?"miss":"stale");return}let c=oe(this,sn)[a],l=Yt(this,Gt,hs).call(this,c)?c.__staleWhileFetching:c;return r&&(l!==void 0?(r.peek="hit",r.value=l):r.peek="miss"),l},kh=function(e,t,r,n){let a=t===void 0?void 0:oe(this,sn)[t];if(Yt(this,Gt,hs).call(this,a))return a;let c=new AbortController,{signal:l}=r;l?.addEventListener("abort",()=>c.abort(l.reason),{signal:c.signal});let d={signal:c.signal,options:r,context:n},f=(T,C=!1)=>{let{aborted:L}=c.signal,N=r.ignoreFetchAbort&&T!==void 0,D=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&T!==void 0);if(r.status&&(L&&!C?(r.status.fetchAborted=!0,r.status.fetchError=c.signal.reason,N&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),L&&!N&&!C)return x(c.signal.reason,D);let O=w,P=oe(this,sn)[t];return(P===w||P===void 0&&N&&C)&&(T===void 0?O.__staleWhileFetching!==void 0?oe(this,sn)[t]=O.__staleWhileFetching:Yt(this,Gt,fc).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),Yt(this,Gt,Iu).call(this,e,T,d.options,O))),T},m=T=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=T),x(T,!1)),x=(T,C)=>{let{aborted:L}=c.signal,N=L&&r.allowStaleOnFetchAbort,D=N||r.allowStaleOnFetchRejection,O=D||r.noDeleteOnFetchRejection,P=w;if(oe(this,sn)[t]===w&&(!O||!C&&P.__staleWhileFetching===void 0?Yt(this,Gt,fc).call(this,e,"fetch"):N||(oe(this,sn)[t]=P.__staleWhileFetching)),D)return r.status&&P.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),P.__staleWhileFetching;if(P.__returned===P)throw T},y=(T,C)=>{var L;let N=(L=oe(this,Qd))==null?void 0:L.call(this,e,a,d);c.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(T(void 0),r.allowStaleOnFetchAbort&&(T=D=>f(D,!0)))}),N&&N instanceof Promise?N.then(D=>T(D===void 0?void 0:D),C):N!==void 0&&T(N)};r.status&&(r.status.fetchDispatched=!0);let w=new Promise(y).then(f,m),v=Object.assign(w,{__abortController:c,__staleWhileFetching:a,__returned:void 0});return t===void 0?(Yt(this,Gt,Iu).call(this,e,v,{...d.options,status:void 0}),t=oe(this,ii).get(e)):oe(this,sn)[t]=v,v},hs=function(e){if(!oe(this,Od))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},cm=async function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:c=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:d=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:T,forceRefresh:C=!1,status:L,signal:N}=t;if(L&&(L.op="fetch",L.key=e,C&&(L.forceRefresh=!0),L.cache=this),!oe(this,Od))return L&&(L.fetch="get"),Yt(this,Gt,$d).call(this,e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:L});let D={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:c,noDisposeOnSet:l,size:d,sizeCalculation:f,noUpdateTTL:m,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:v,ignoreFetchAbort:w,status:L,signal:N},O=oe(this,ii).get(e);if(O===void 0){L&&(L.fetch="miss");let P=Yt(this,Gt,kh).call(this,e,O,D,T);return P.__returned=P}else{let P=oe(this,sn)[O];if(Yt(this,Gt,hs).call(this,P)){let G=r&&P.__staleWhileFetching!==void 0;return L&&(L.fetch="inflight",G&&(L.returnedStale=!0)),G?P.__staleWhileFetching:P.__returned=P}let F=oe(this,To).call(this,O);if(!C&&!F)return L&&(L.fetch="hit"),Yt(this,Gt,Ud).call(this,O),n&&oe(this,ku).call(this,O),L&&oe(this,uc).call(this,L,O),P;let ee=Yt(this,Gt,kh).call(this,e,O,D,T),Z=ee.__staleWhileFetching!==void 0&&r;return L&&(L.fetch=F?"stale":"refresh",Z&&F&&(L.returnedStale=!0)),Z?ee.__staleWhileFetching:ee.__returned=ee}},I2=async function(e,t={}){let r=await Yt(this,Gt,cm).call(this,e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r},E2=function(e,t={}){let r=oe(this,Pd);if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,status:a,forceRefresh:c,...l}=t;a&&c&&(a.forceRefresh=!0);let d=Yt(this,Gt,$d).call(this,e,l),f=c||d===void 0;if(a&&(a.memo=f?"miss":"hit",f||(a.value=d)),!f)return d;let m=r(e,d,{options:l,context:n});return a&&(a.value=m),Yt(this,Gt,Iu).call(this,e,m,l),m},$d=function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:c}=t,l=oe(this,ii).get(e);if(l===void 0){c&&(c.get="miss");return}let d=oe(this,sn)[l],f=Yt(this,Gt,hs).call(this,d);return c&&oe(this,uc).call(this,c,l),oe(this,To).call(this,l)?f?(c&&(c.get="stale-fetching"),r&&d.__staleWhileFetching!==void 0?(c&&(c.returnedStale=!0),d.__staleWhileFetching):void 0):(a||Yt(this,Gt,fc).call(this,e,"expire"),c&&(c.get="stale"),r?(c&&(c.returnedStale=!0),d):void 0):(c&&(c.get=f?"fetching":"hit"),Yt(this,Gt,Ud).call(this,l),n&&oe(this,ku).call(this,l),f?d.__staleWhileFetching:d)},um=function(e,t){oe(this,vo)[t]=e,oe(this,Qa)[e]=t},Ud=function(e){e!==oe(this,Di)&&(e===oe(this,xa)?Br(this,xa,oe(this,Qa)[e]):Yt(this,Gt,um).call(this,oe(this,vo)[e],oe(this,Qa)[e]),Yt(this,Gt,um).call(this,oe(this,Di),e),Br(this,Di,e))},fc=function(e,t){var r,n;Oi.hasSubscribers&&Oi.publish({op:"delete",delete:t,key:e,cache:this});let a=!1;if(oe(this,xi)!==0){let c=oe(this,ii).get(e);if(c!==void 0)if(oe(this,Ao)?.[c]&&(clearTimeout(oe(this,Ao)?.[c]),oe(this,Ao)[c]=void 0),a=!0,oe(this,xi)===1)Yt(this,Gt,dm).call(this,t);else{oe(this,Lu).call(this,c);let l=oe(this,sn)[c];if(Yt(this,Gt,hs).call(this,l)?l.__abortController.abort(new Error("deleted")):(oe(this,xl)||oe(this,Pa))&&(oe(this,xl)&&((r=oe(this,dl))==null||r.call(this,l,e,t)),oe(this,Pa)&&oe(this,Bi)?.push([l,e,t])),oe(this,ii).delete(e),oe(this,Cs)[c]=void 0,oe(this,sn)[c]=void 0,c===oe(this,Di))Br(this,Di,oe(this,vo)[c]);else if(c===oe(this,xa))Br(this,xa,oe(this,Qa)[c]);else{let d=oe(this,vo)[c];oe(this,Qa)[d]=oe(this,Qa)[c];let f=oe(this,Qa)[c];oe(this,vo)[f]=oe(this,vo)[c]}im(this,xi)._--,oe(this,pl).push(c)}}if(oe(this,Pa)&&oe(this,Bi)?.length){let c=oe(this,Bi),l;for(;l=c?.shift();)(n=oe(this,hl))==null||n.call(this,...l)}return a},dm=function(e){var t,r;for(let n of Yt(this,Gt,hc).call(this,{allowStale:!0})){let a=oe(this,sn)[n];if(Yt(this,Gt,hs).call(this,a))a.__abortController.abort(new Error("deleted"));else{let c=oe(this,Cs)[n];oe(this,xl)&&((t=oe(this,dl))==null||t.call(this,a,c,e)),oe(this,Pa)&&oe(this,Bi)?.push([a,c,e])}}if(oe(this,ii).clear(),oe(this,sn).fill(void 0),oe(this,Cs).fill(void 0),oe(this,wo)&&oe(this,gl)){oe(this,wo).fill(0),oe(this,gl).fill(0);for(let n of oe(this,Ao)??[])n!==void 0&&clearTimeout(n);oe(this,Ao)?.fill(void 0)}if(oe(this,ml)&&oe(this,ml).fill(0),Br(this,xa,0),Br(this,Di,0),oe(this,pl).length=0,Br(this,yo,0),Br(this,xi,0),oe(this,Pa)&&oe(this,Bi)){let n=oe(this,Bi),a;for(;a=n?.shift();)(r=oe(this,hl))==null||r.call(this,...a)}},hm);function pv(e){let t={individual:{},range:[]},r=new WeakMap;for(let n of e)v1(t,n,r);return t}function v1(e,t,r){for(let[n,a]of Object.entries(t.individual))if(e.individual[n])Eu(e.individual[n],a,r);else{let c=!1;for(let[l,{range:d,entry:f}]of e.range.entries()){let m=fm(Number(n),d);if(m.both!==null){c=!0,e.individual[n]=a,Eu(e.individual[n],Fi(f),r),e.range.splice(l,1);for(let x of m.second)Array.isArray(x)?e.range.push({range:x,entry:Fi(f)}):e.individual[x]=Fi(f)}}c||(e.individual[n]=a)}for(let{range:n,entry:a}of t.range){let c=[n];for(let l=0;l<e.range.length;l++){let{range:d,entry:f}=e.range[l];for(let[m,x]of c.entries())if(Array.isArray(x)){let y=LL(x,d);if(y.both===null)continue;e.range.splice(l,1),l--;let w=Fi(f);Array.isArray(y.both)?e.range.push({range:y.both,entry:w}):e.individual[y.both]=w,Eu(w,Fi(a),r);for(let v of y.second)Array.isArray(v)?e.range.push({range:v,entry:Fi(f)}):e.individual[v]=Fi(f);c=y.first}else{let y=fm(x,d);if(y.both===null)continue;e.individual[x]=Fi(a),Eu(e.individual[x],Fi(f),r),e.range.splice(l,1),l--;for(let w of y.second)Array.isArray(w)?e.range.push({range:w,entry:Fi(f)}):e.individual[w]=Fi(f);c.splice(m,1,...y.first);break}}for(let l of Object.keys(e.individual))for(let[d,f]of c.entries())if(Array.isArray(f)){let m=fm(Number(l),f);if(m.both===null)continue;Eu(e.individual[l],Fi(a),r),c.splice(d,1,...m.second);break}else if(Number(l)===f){Eu(e.individual[l],Fi(a),r);break}for(let l of c)Array.isArray(l)?e.range.push({range:l,entry:Fi(a)}):e.individual[l]=Fi(a)}}function Eu(e,t,r){let n=r.get(e);n?.has(t)||(n||(n=new Set,r.set(e,n)),n.add(t),t.lookup&&(!e.lookup||e.lookup.index>t.lookup.index||e.lookup.index===t.lookup.index&&e.lookup.subIndex>t.lookup.subIndex)&&(e.lookup=t.lookup),t.forward&&(e.forward?v1(e.forward,t.forward,r):e.forward=t.forward),t.reverse&&(e.reverse?v1(e.reverse,t.reverse,r):e.reverse=t.reverse))}function LL(e,t){let r={first:[],second:[],both:null};if(e[0]<t[1]&&t[0]<e[1]){let n=Math.max(e[0],t[0]),a=Math.min(e[1],t[1]);r.both=Wc(n,a)}if(e[0]<t[0]){let n=e[0],a=Math.min(t[0],e[1]);r.first.push(Wc(n,a))}else if(t[0]<e[0]){let n=t[0],a=Math.min(t[1],e[0]);r.second.push(Wc(n,a))}if(e[1]>t[1]){let n=Math.max(e[0],t[1]),a=e[1];r.first.push(Wc(n,a))}else if(t[1]>e[1]){let n=Math.max(e[1],t[0]),a=t[1];r.second.push(Wc(n,a))}return r}function fm(e,t){if(e<t[0]||e>t[1])return{first:[e],second:[t],both:null};let r={first:[],second:[],both:e};return t[0]<e&&r.second.push(Wc(t[0],e)),t[1]>e&&r.second.push(Wc(e+1,t[1])),r}function Wc(e,t){return t-e===1?e:[e,t]}function Fi(e,t=new Map){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=N2(e.forward,t)),e.reverse&&(r.reverse=N2(e.reverse,t)),e.lookup&&(r.lookup={contextRange:e.lookup.contextRange.slice(),index:e.lookup.index,length:e.lookup.length,subIndex:e.lookup.subIndex,substitutions:e.lookup.substitutions.slice()}),r}function N2(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=Fi(a,t);return{individual:r,range:e.range.map(({range:n,entry:a})=>({range:n.slice(),entry:Fi(a,t)}))}}function w1(e,t,r,n){let a=t[n],c=e[a];if(!c)return;let l=c.lookup;if(c.reverse){let f=IL(c.reverse,t,r);(!l&&f||f&&l&&(l.index>f.index||l.index===f.index&&l.subIndex>f.subIndex))&&(l=f)}if(++n>=t.length||!c.forward)return l;let d=w1(c.forward,t,r,n);return(!l&&d||d&&l&&(l.index>d.index||l.index===d.index&&l.subIndex>d.subIndex))&&(l=d),l}function IL(e,t,r){let n=e[t[--r]],a=n&&n.lookup;for(;n&&((!a&&n.lookup||n.lookup&&a&&a.index>n.lookup.index)&&(a=n.lookup),!(--r<0||!n.reverse));)n=n.reverse[t[r]];return a}function R2(e,t,r){let n=!1;for(let a=0;a<e.length;a++){let c=e[a];if(n){if(r<=c[0])return e[a-1][1]=r,e;if(r<=c[1])return e[a-1][1]=Math.max(r,c[1]),e.splice(a,1),e;e.splice(a,1),a--}else{if(r<=c[0])return e.splice(a,0,[t,r]),e;if(r<=c[1])return c[0]=Math.min(t,c[0]),e;if(t<c[1])c[0]=Math.min(t,c[0]),n=!0;else continue}}return n?e[e.length-1][1]=r:e.push([t,r]),e}function EL(e,t){switch(e.format){case 1:let r=e.glyphs.indexOf(t);return r!==-1?r:null;case 2:let n=e.ranges.find(a=>a.start<=t&&a.end>=t);return n?n.index:null}}function Gl(e){switch(e.format){case 1:return e.glyphs.map((r,n)=>({glyphId:r,index:n}));case 2:let t=[];for(let[r,n]of e.ranges.entries())n.end===n.start?t.push({glyphId:n.start,index:r}):t.push({glyphId:[n.start,n.end+1],index:r});return t}}function NL(e,t){let r=t[0],n=A1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)A1(e,a)!==n&&(a-r<=1?c.set(r,n):c.set([r,a],n)),a++;return a-r<=1?c.set(r,n):c.set([r,a],n),c}function A1(e,t){let r=EL(e.coverage,t);if(r===null)return null;switch(e.substFormat){case 1:return(t+e.deltaGlyphId)%2**16;case 2:return e.substitute[r]??null}}function yg(e,t,r,n,a){let c=[];for(let l of r){l.entry.forward={individual:{},range:[]};for(let d of e)c.push(...up(l.entry.forward,n,a,t,d).map(({entry:f,substitution:m})=>({entry:f,substitutions:[...l.substitutions,m]})))}return c}function lp(e,t){let r=[],n=new Set;for(let a of t){if(n.has(a.entry))continue;n.add(a.entry),a.entry.forward??={individual:{},range:[]};let c={};for(let l of e)Array.isArray(l)?a.entry.forward.range.push({entry:c,range:l}):a.entry.forward.individual[l]=c;r.push({entry:c,substitutions:a.substitutions})}return r}function cp(e,t){let r=[],n=new Set;for(let a of t){if(n.has(a.entry))continue;n.add(a.entry),a.entry.reverse??={individual:{},range:[]};let c={};for(let l of e)Array.isArray(l)?a.entry.reverse.range.push({entry:c,range:l}):a.entry.reverse.individual[l]=c;r.push({entry:c,substitutions:a.substitutions})}return r}function up(e,t,r,n,a){let c=[];if(!Array.isArray(a))e.individual[a]={},c.push({entry:e.individual[a],substitution:ML(t,r,n,a)});else{let l=RL(t,r,n,a);for(let[d,f]of l){let m={};Array.isArray(d)?e.range.push({range:d,entry:m}):e.individual[d]={},c.push({entry:m,substitution:f})}}return c}function RL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=NL(c,n);if(!Array.from(l.values()).every(d=>d!==null))return l}return new Map([[n,null]])}function ML(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=A1(c,n);if(l!==null)return l}return null}function jL(e,t,r){let n={individual:{},range:[]},a=Gl(e.coverage);for(let{glyphId:c,index:l}of a){let d=e.chainRuleSets[l];if(d)for(let[f,m]of d.entries()){let x=up(n,m.lookupRecords,t,0,c).map(({entry:y,substitution:w})=>({entry:y,substitutions:[w]}));for(let[y,w]of m.input.entries())x=yg([w],y+1,x,m.lookupRecords,t);for(let y of m.lookahead)x=lp([y],x);for(let y of m.backtrack)x=cp([y],x);for(let{entry:y,substitutions:w}of x)y.lookup={substitutions:w,length:m.input.length+1,index:r,subIndex:f,contextRange:[-1*m.backtrack.length,1+m.input.length+m.lookahead.length]}}}return n}function DL(e,t){return e.format===2?Array.isArray(t)?BL(e,t):new Map([[t,T1(e,t)]]):new Map([[t,null]])}function BL(e,t){let r=t[0],n=T1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)T1(e,a)!==n&&(a-r<=1?c.set(r,n):c.set([r,a],n)),a++;return a-r<=1?c.set(r,n):c.set([r,a],n),c}function T1(e,t){for(let r of e.ranges)if(r.start<=t&&r.end>=t)return r.classId;return null}function pm(e,t){switch(e.format){case 2:let r=[];for(let n of e.ranges)n.classId===t&&(n.end===n.start?r.push(n.start):r.push([n.start,n.end+1]));return r;default:return[]}}function QL(e,t,r){let n=[],a=Gl(e.coverage);for(let{glyphId:c}of a){let l=DL(e.inputClassDef,c);for(let[d,f]of l.entries()){if(f===null)continue;let m=e.chainClassSet[f];if(m)for(let[x,y]of m.entries()){let w={individual:{},range:[]},v=up(w,y.lookupRecords,t,0,d).map(({entry:T,substitution:C})=>({entry:T,substitutions:[C]}));for(let[T,C]of y.input.entries())v=yg(pm(e.inputClassDef,C),T+1,v,y.lookupRecords,t);for(let T of y.lookahead)v=lp(pm(e.lookaheadClassDef,T),v);for(let T of y.backtrack)v=cp(pm(e.backtrackClassDef,T),v);for(let{entry:T,substitutions:C}of v)T.lookup={substitutions:C,index:r,subIndex:x,length:y.input.length+1,contextRange:[-1*y.backtrack.length,1+y.input.length+y.lookahead.length]};n.push(w)}}}return pv(n)}function PL(e,t,r){let n={individual:{},range:[]},a=Gl(e.inputCoverage[0]);for(let{glyphId:c}of a){let l=up(n,e.lookupRecords,t,0,c).map(({entry:d,substitution:f})=>({entry:d,substitutions:[f]}));for(let[d,f]of e.inputCoverage.slice(1).entries())l=yg(Gl(f).map(m=>m.glyphId),d+1,l,e.lookupRecords,t);for(let d of e.lookaheadCoverage)l=lp(Gl(d).map(f=>f.glyphId),l);for(let d of e.backtrackCoverage)l=cp(Gl(d).map(f=>f.glyphId),l);for(let{entry:d,substitutions:f}of l)d.lookup={substitutions:f,index:r,subIndex:0,length:e.inputCoverage.length,contextRange:[-1*e.backtrackCoverage.length,e.inputCoverage.length+e.lookaheadCoverage.length]}}return n}function OL(e,t){let r={individual:{},range:[]},n=Gl(e.coverage);for(let{glyphId:a,index:c}of n){let l={};Array.isArray(a)?r.range.push({entry:l,range:a}):r.individual[a]=l;let d=[{entry:l,substitutions:[e.substitutes[c]]}];for(let f of e.lookaheadCoverage)d=lp(Gl(f).map(m=>m.glyphId),d);for(let f of e.backtrackCoverage)d=cp(Gl(f).map(m=>m.glyphId),d);for(let{entry:f,substitutions:m}of d)f.lookup={substitutions:m,index:t,subIndex:0,length:1,contextRange:[-1*e.backtrackCoverage.length,1+e.lookaheadCoverage.length]}}return r}function S1(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=M2(a,t);for(let{range:n,entry:a}of e.range){let c=M2(a,t);for(let l=n[0];l<n[1];l++)r[l]=c}return r}function M2(e,t){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=S1(e.forward,t)),e.reverse&&(r.reverse=S1(e.reverse,t)),e.lookup&&(r.lookup=e.lookup),r}var FL=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new kL({maxSize:t.cacheSize,sizeCalculation:((c,l)=>l.length)}));let r=(this._font.tables.gsub&&this._font.tables.gsub.features.filter(c=>c.tag==="calt")||[]).reduce((c,l)=>[...c,...l.feature.lookupListIndexes],[]),n=this._font.tables.gsub&&this._font.tables.gsub.lookups||[],a=n.filter((c,l)=>r.some(d=>d===l));for(let[c,l]of a.entries()){let d=[];switch(l.lookupType){case 6:for(let[m,x]of l.subtables.entries())switch(x.substFormat){case 1:d.push(jL(x,n,m));break;case 2:d.push(QL(x,n,m));break;case 3:d.push(PL(x,n,m));break}break;case 8:for(let[m,x]of l.subtables.entries())d.push(OL(x,m));break}let f=S1(pv(d));this._lookupTrees.push({tree:f,processForward:l.lookupType!==8});for(let m of Object.keys(f))this._glyphLookups[m]||(this._glyphLookups[m]=[]),this._glyphLookups[m].push(c)}}findLigatures(e){let t=this._cache&&this._cache.get(e);if(t&&!Array.isArray(t))return t;let r=[];for(let c of e)r.push(this._font.charToGlyphIndex(c));if(this._lookupTrees.length===0)return{inputGlyphs:r,outputGlyphs:r,contextRanges:[]};let n=this._findInternal(r.slice()),a={inputGlyphs:r,outputGlyphs:n.sequence,contextRanges:n.ranges};return this._cache&&this._cache.set(e,a),a}findLigatureRanges(e){if(this._lookupTrees.length===0)return[];let t=this._cache&&this._cache.get(e);if(t)return Array.isArray(t)?t:t.contextRanges;let r=[];for(let a of e)r.push(this._font.charToGlyphIndex(a));let n=this._findInternal(r);return this._cache&&this._cache.set(e,n.ranges),n.ranges}_findInternal(e){let t=[],r=this._getNextLookup(e,0);for(;r.index!==null;){let n=this._lookupTrees[r.index];if(n.processForward){let a=r.last;for(let c=r.first;c<a;c++){let l=w1(n.tree,e,c,c);if(l){for(let d=0;d<l.substitutions.length;d++){let f=l.substitutions[d];f!==null&&(e[c+d]=f)}R2(t,l.contextRange[0]+c,l.contextRange[1]+c),c+l.length>=a&&(a=c+l.length+1),c+=l.length-1}}}else for(let a=r.last-1;a>=r.first;a--){let c=w1(n.tree,e,a,a);if(c){for(let l=0;l<c.substitutions.length;l++){let d=c.substitutions[l];d!==null&&(e[a+l]=d)}R2(t,c.contextRange[0]+a,c.contextRange[1]+a),a-=c.length-1}}r=this._getNextLookup(e,r.index+1)}return{sequence:e,ranges:t}}_getNextLookup(e,t){let r={index:null,first:1/0,last:-1};for(let n=0;n<e.length;n++){let a=this._glyphLookups[e[n]];if(a)for(let c=0;c<a.length;c++){let l=a[c];if(l>=t){(r.index===null||l<=r.index)&&(r.index=l,r.first>n&&(r.first=n),r.last=n+1);break}}}return r}};function $L(e,t){let r=AL.parse(e);return new FL(r,{cacheSize:0,...t})}function UL(e){if(typeof e!="string")throw new Error("Font family must be a string");let t={input:e,offset:0},r=[],n="";for(;t.offset<t.input.length;){let a=t.input[t.offset++];switch(a){case"'":case'"':n+=zL(t,a);break;case",":r.push(n),n="";break;default:/\s/.test(a)||(t.offset--,n+=HL(t),r.push(n),n="")}}return r}function zL(e,t){let r="",n=!1;for(;e.offset<e.input.length;){let a=e.input[e.offset++];if(n)/[\dA-Fa-f]/.test(a)?(e.offset--,r+=mv(e)):a!==`
70
+ `&&(r+=a),n=!1;else switch(a){case t:return r;case"\\":n=!0;break;default:r+=a}}throw new Error("Unterminated string")}function HL(e){let t="",r=!1;for(;e.offset<e.input.length;){let n=e.input[e.offset++];if(r)/[\dA-Fa-f]/.test(n)?(e.offset--,t+=mv(e)):t+=n,r=!1;else switch(n){case"\\":r=!0;break;case",":return t;default:/\s/.test(n)?t.endsWith(" ")||(t+=" "):t+=n}}return t}function mv(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return mm(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,mm(t);t+=r}return mm(t)}function mm(e){return String.fromCodePoint(parseInt(e,16))}var zd;async function WL(e,t){if(!zd){if(typeof navigator<"u"&&"fonts"in navigator){try{let a=await navigator.permissions.request?.({name:"local-fonts"});if(a&&a.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(a){if(a instanceof Error&&a.name!=="TypeError")throw a}let n={};try{let a=await navigator.fonts.query();for(let c of a)n.hasOwnProperty(c.family)||(n[c.family]=[]),n[c.family].push(c);zd=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let n={};try{let a=await window.queryLocalFonts();for(let c of a)n.hasOwnProperty(c.family)||(n[c.family]=[]),n[c.family].push(c);zd=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}zd??=Promise.resolve({})}let r=await zd;for(let n of UL(e)){if(GL.includes(n))return;if(r.hasOwnProperty(n)&&r[n].length>0){let a=r[n][0];if("blob"in a){let c=await(await a.blob()).arrayBuffer();return $L(c,{cacheSize:t})}return}}}var GL=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],VL=1e5;function qL(e,t=[]){let r,n,a=0,c;return e.registerCharacterJoiner(l=>{let d=e.options.fontFamily;if(d&&(a===0||r!==d)){n=void 0,a=1,r=d;let f=r;WL(f,VL).then(m=>{f===e.options.fontFamily&&(a=2,n=m,m&&e.refresh(0,e.rows-1))}).catch(m=>{f===e.options.fontFamily&&(a=3,e.options.logLevel==="debug"&&console.debug(c,new Error("Failure while loading font")),n=void 0,c=m)})}return n&&a===2?n.findLigatureRanges(l).map(f=>[f[0],f[1]]):YL(l,t)})}function YL(e,t){let r=[];for(let n=0;n<e.length;n++)for(let a=0;a<t.length;a++)if(e.startsWith(t[a],n)){r.push([n,n+t[a].length]),n+=t[a].length-1;break}return r}var ZL=class{constructor(e){this._fallbackLigatures=(e?.fallbackLigatures??["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"]).sort((t,r)=>r.length-t.length),this._fontFeatureSettings=e?.fontFeatureSettings}activate(e){if(!e.element)throw new Error("Cannot activate LigaturesAddon before open is called");this._terminal=e,this._characterJoinerId=qL(e,this._fallbackLigatures),e.element.style.fontFeatureSettings=this._fontFeatureSettings??'"calt" on'}dispose(){this._characterJoinerId!==void 0&&(this._terminal?.deregisterCharacterJoiner(this._characterJoinerId),this._characterJoinerId=void 0),this._terminal?.element&&(this._terminal.element.style.fontFeatureSettings="")}};function j2(e){let t=0;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<48||57<n)return-1;t=t*10+n-48}return t}var KL=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,t=>{if(!t.startsWith("4;"))return!1;let r=t.split(";");if(r.length>3)return!0;r.length===2&&r.push("");let n=j2(r[1]),a=j2(r[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(a<0)return!0;this.progress={state:n,value:a};break;case 2:case 4:if(a<0)return!0;this.progress={state:n,value:a||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn("progress state out of bounds, not applied");return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function gv(e,t){const r=Math.max(e.left,t.left),n=Math.max(e.top,t.top),a=Math.min(e.right,t.right),c=Math.min(e.bottom,t.bottom);return a>r&&c>n?{left:r,top:n,right:a,bottom:c}:null}function D2(e,t){const r=gv(e,t);return r?(r.right-r.left)*(r.bottom-r.top):0}function Jc(e){const t=e.element;if(!t||!e.cols||!e.rows)return null;const n=(t.querySelector?.(".xterm-screen")??null??t).getBoundingClientRect();if(!n.width||!n.height)return null;const a=e.dimensions?.css?.cell?.height,c=n.width/e.cols,l=a&&a>0?a:n.height/e.rows;return{originLeft:n.left,originTop:n.top,cellW:c,cellH:l}}function df(e,t){const r=Jc(e);if(!r)return null;const n=t.row-e.buffer.active.viewportY;if(n<0||n>=e.rows)return null;const a=Math.max(0,Math.min(e.cols-1,t.col));return{x:r.originLeft+(a+.5)*r.cellW,y:r.originTop+n*r.cellH}}function XL(e,t){const r=Math.max(0,e.buffer.active.baseY+e.rows-1);return{col:Math.max(0,Math.min(e.cols-1,t.col)),row:Math.max(0,Math.min(r,t.row))}}function Df(e,t,r){const n=e.row*r+e.col,a=t.row*r+t.col;return n<=a?{start:e,end:t}:{start:t,end:e}}function JL(e,t,r){const n=Jc(e);if(!n)return null;const{start:a,end:c}=Df(t,r,e.cols),l=e.buffer.active.viewportY,d=l+e.rows-1;if(c.row<l||a.row>d)return null;const f=Math.max(a.row,l),m=Math.min(c.row,d),x=n.originTop+(f-l)*n.cellH,y=n.originTop+(m-l+1)*n.cellH;return a.row===c.row?{left:n.originLeft+a.col*n.cellW,top:x,right:n.originLeft+(c.col+1)*n.cellW,bottom:y}:{left:n.originLeft,top:x,right:n.originLeft+e.cols*n.cellW,bottom:y}}function eI(e){const t=Math.max(e.viewport.left,e.terminal.left),r=Math.max(e.viewport.top,e.terminal.top),n=Math.min(e.viewport.right,e.terminal.right),a=Math.min(e.viewport.bottom,e.terminal.bottom),c=t+e.margin,l=r+e.margin,d=Math.max(c,n-e.width-e.margin),f=Math.max(l,a-e.height-e.margin),m=G=>Math.max(c,Math.min(G,d)),x=G=>Math.max(l,Math.min(G,f)),y=e.selection?gv(e.selection,{left:t,top:r,right:n,bottom:a}):null;if(!y){const G=m(e.clientX-e.width/2),de=e.clientY-e.height-e.fingerGap,pe=e.clientY+e.fingerGap,J=x(de>=l?de:pe);return{left:Math.round(G),top:Math.round(J)}}const w=(y.left+y.right)/2,v=(y.top+y.bottom)/2,T=e.preference?.alignX??w,C=e.selectionGap??e.fingerGap,L=y.top-e.height-C,N=y.bottom+C,D=e.preference?.vertical==="below"?N:L,O=e.preference?.vertical==="below"?L:N,P=[{left:c,top:l},{left:d,top:l},{left:c,top:f},{left:d,top:f}];e.preference&&P.sort((G,de)=>{const pe=J=>{const Re=J.left+e.width/2,Ze=J.top+e.height/2;return Math.hypot(Re-e.preference.focusX,Ze-e.preference.focusY)};return pe(de)-pe(G)});const F=[{left:T-e.width/2,top:D},{left:w-e.width/2,top:D},{left:T-e.width/2,top:O},{left:w-e.width/2,top:O},{left:y.left-e.width-e.fingerGap,top:v-e.height/2},{left:y.right+e.fingerGap,top:v-e.height/2},...P].map(G=>({left:m(G.left),top:x(G.top)}));let ee=F[0],Z=Number.POSITIVE_INFINITY;return F.forEach((G,de)=>{const pe={left:G.left,top:G.top,right:G.left+e.width,bottom:G.top+e.height},J=(e.avoid??[]).reduce((Ze,V)=>Ze+D2(pe,V),0),Re=(J>0?1e6:0)+J*100+D2(pe,y)*10+de*.01;Re<Z&&(ee=G,Z=Re)}),{left:Math.round(ee.left),top:Math.round(ee.top)}}function tI(e){const t=e.willChange.split(",").map(n=>n.trim()),r=(n,a)=>!!(n&&n!==a);return r(e.transform,"none")||r(e.perspective,"none")||r(e.filter,"none")||r(e.backdropFilter,"none")||r(e.containerType,"normal")||e.contain.includes("layout")||e.contain.includes("paint")||e.contain.includes("strict")||e.contain.includes("content")||t.includes("transform")||t.includes("perspective")||t.includes("filter")}function rI(e){let t=e.parentElement;for(;t;){if(tI(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function nI(e,t,r,n){const a=e.getBoundingClientRect();let c=0,l=0;if(t){const d=t.getBoundingClientRect();c=d.left+t.clientLeft,l=d.top+t.clientTop}return{x:a.left-c+r,y:a.top-l+n}}function sI(e,t){return t?.ownedPaste?f1(e,!1):t?.paste&&/[\r\n]/.test(e)?f1(e,t.submitAfterPaste??e.endsWith("\r")):e}const B2=2,iI=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function aI(e){const t=e.reason.replace(/^refresh:/,""),r=iI.has(t),n=Math.abs(e.proposedCols-e.currentCols),a=Math.abs(e.proposedRows-e.currentRows);return{accept:r?n>0||a>0:n>=B2||a>=B2,isRealResize:r,colsDelta:n,rowsDelta:a}}function oI(e){return e.before.cols!==e.after.cols||e.before.rows!==e.after.rows||e.lastServerSize===null||e.reconcileServerSize===!0&&(e.lastServerSize.cols!==e.after.cols||e.lastServerSize.rows!==e.after.rows)}function lI(e,t){return!e||t}function cI(e,t,r){return e!=="alternate"&&r>=t}function uI(e,t){return e?"none":t?"single":"settled"}function dI(e,t,r){return!r&&(e||t)}function hI(e){let t,r,n=!1,a=0;const c=e.parser.registerCsiHandler({prefix:"?",final:"l"},d=>(t&&d.some(f=>f===2026)&&(n=!0),!1)),l=d=>{const f=t;if(!f)return;const m=r;if(t=void 0,r=void 0,n=!1,f(),d){const x=e._core?._renderService?._renderer?.value;m&&x?.handleResize(...m),x?.renderRows(0,e.rows-1),e.refresh(0,e.rows-1)}};return{begin(){if(a++,n=!1,t)return;const d=e._core?._renderService?._renderer?.value;if(!d||typeof d.handleResize!="function"||typeof d.renderRows!="function"||typeof d.clear!="function")return;const f=d.handleResize,m=d.renderRows,x=d.clear;d.handleResize=(y,w)=>{r=[y,w]},d.renderRows=()=>{},d.clear=()=>{},t=()=>{d.handleResize=f,d.renderRows=m,d.clear=x}},get generation(){return a},written(d){d===a&&n&&!e.modes.synchronizedOutputMode&&l(!0)},cancel(){l(!0)},dispose(){l(!1),c.dispose()}}}function gm(){return{confirmed:null,pending:null,nextSeq:1}}function Q2(e,t){return e?.cols===t.cols&&e.rows===t.rows}function vg(e,t,r){const n={...t,seq:e.nextSeq,attempt:r};return{state:{...e,pending:n,nextSeq:e.nextSeq+1},request:n}}function fI(e,t){return Q2(e.pending,t)||!e.pending&&Q2(e.confirmed,t)?{state:e,request:null}:vg(e,t,0)}function pI(e,t){return vg(e,t,0)}function mI(e,t){const r=e.pending;if(!r||t.seq!==r.seq)return{state:e,accepted:!1};const n=t.ok&&Number.isFinite(t.cols)&&Number.isFinite(t.rows)&&(t.cols??0)>0&&(t.rows??0)>0?{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}:null;return{state:{...e,confirmed:n,pending:null},accepted:!0}}function P2(e,t,r=1){const n=e.pending;return!n||n.seq!==t?{state:e,request:null,exhausted:!1}:n.attempt>=r?{state:{...e,confirmed:null,pending:null},request:null,exhausted:!0}:{...vg(e,n,n.attempt+1),exhausted:!1}}function gI(e,t){return!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<=0||t.rows<=0?e:{...e,confirmed:{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}}}function xI(e){return{...e,pending:null}}const bI=150;function O2(e=0){return{lastPushAt:e}}function yI(e,t,r=bI){return t-e.lastPushAt>=r?(e.lastPushAt=t,{action:"send"}):{action:"hold",readyAt:e.lastPushAt+r}}function vI(e){return{lastPushAt:e}}const C1="termdock-settings",wI=6,AI=100,TI='"calt" on',SI=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function CI(){if(typeof window>"u")return 13;const e=window.matchMedia("(max-width: 767px)").matches,t=window.matchMedia("(pointer: coarse)").matches;return e||t?10:13}function wg(){return{fontFamily:"var(--font-mono)",fontSize:CI(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function Lh(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function F2(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function Ju(e){const t=wg(),r=e&&typeof e=="object"?e:{},n=r.rendererMode??r.renderer;return{fontFamily:typeof r.fontFamily=="string"&&r.fontFamily.trim()?r.fontFamily.trim():t.fontFamily,fontSize:Lh(r.fontSize,wI,AI,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:F2(r.fontWeight,t.fontWeight),fontWeightBold:F2(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(Lh(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:Lh(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:Lh(r.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function Ih(e){return e.pointerType==="touch"||e.pointerType==="pen"}class _I{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[r,n]of this.active)n===t&&(this.active.delete(r),this.pointerStates.delete(r));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,r){return this.active.get(t)===r}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,r,n){this.changeListeners.size!==0&&this.changeListeners.forEach(a=>{try{a({type:t,pointerId:r,handler:n})}catch{}})}log(t,r,n=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const a=performance.now().toFixed(0);console.debug(`[GestureManager ${a}] ${t} ${r} ${n}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,r)=>r.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!Ih(t))return;const r={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,r);let n=!1;for(const a of this.sortedHandlers()){if(!this.handlerMatchesContainer(a,t)){this.log("skip-container",a.name);continue}a.onPointerDown(t,r)&&!n&&(this.active.set(t.pointerId,a.name),n=!0,this.log("claim",a.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,a.name))}n&&t.preventDefault()};handlePointerMove=t=>{if(!Ih(t)||!this.pointerStates.has(t.pointerId))return;let r=!1;for(const n of this.sortedHandlers()){if(!this.handlerMatchesContainer(n,t))continue;const a=this.active.get(t.pointerId)===n.name,c=n.onPointerMove(t,a);if(c==="claim"&&!r){const l=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,n.name),r=!0,t.preventDefault(),l&&l!==n.name&&this.log("handoff",`${l}->${n.name}`,`pid=${t.pointerId}`),this.log("claim",n.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,n.name)}if(c==="release"&&a&&!r){const l=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",n.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,l??null)}}};handlePointerUp=t=>{if(!Ih(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerUp(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlePointerCancel=t=>{if(!Ih(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerCancel(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlerMatchesContainer(t,r){return t.container?t.container.contains(r.target):!0}}const xv=new _I,kI=90,LI=80,II=70,EI=(e,t)=>{const{scrollMultiplier:r=1.2,maxScrollBoost:n=.8,boostDenominator:a=50,velocityAlpha:c=.15,maxVelocity:l=15,minVelocity:d=.3,decelerationRate:f=.998,enableKinetic:m=!0,shouldCaptureTouch:x,canStartScrollGesture:y,onScroll:w,onScrollWithCoords:v,onTap:T,onClickWithCoords:C,onClaimChange:L,tapThreshold:N=10,gestureName:D="normal-scroll"}=t,O=1.06,P=_.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),F=_.useRef(0),ee=_.useRef(0),Z=_.useRef(0),G=_.useRef(null),de=_.useRef(0),pe=_.useRef(!1),J=_.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),Re=_.useCallback(()=>{G.current=null,F.current!==0&&(v&&ee.current>0&&Z.current>0?v(F.current,ee.current,Z.current):w&&w(F.current),F.current=0,ee.current=0,Z.current=0)},[w,v]),Ze=_.useCallback(()=>{G.current===null&&typeof window<"u"&&(G.current=window.requestAnimationFrame(Re))},[Re]),V=_.useCallback((Ne,ae,ze)=>{F.current+=Ne,ae!==void 0&&ze!==void 0&&(ee.current=ae,Z.current=ze),Ze()},[Ze]),ve=_.useCallback(Ne=>{if(!Ne||!w)return!1;const ae=w(Ne);return ae?de.current=0:de.current++,ae},[w]),qe=_.useCallback(Ne=>{pe.current!==Ne&&(pe.current=Ne,L?.(Ne))},[L]),le=_.useCallback(()=>{const Ne=P.current;Ne.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ne.rafId),Ne.rafId=null,G.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(G.current),G.current=null,F.current=0},[]),ye=_.useRef(T);ye.current=T;const Te=_.useRef(C);Te.current=C;const Fe=_.useRef(x);Fe.current=x;const se=_.useCallback(()=>{const Ne=e.current;if(!Ne||!("PointerEvent"in window))return()=>{};const ae=P.current,ze={name:D,priority:II,get container(){return e.current??void 0},onPointerDown:(me,ut)=>(me.pointerType!=="touch"||(ae.pointerId=me.pointerId,ae.startX=ut.startX,ae.startY=ut.startY,ae.didMove=!1,ae.gestureAxis=null,ae.lastY=me.clientY,ae.lastTime=J(),ae.velocity=0,le()),!1),onPointerMove:(me,ut)=>{if(me.pointerType!=="touch"||ae.pointerId!==me.pointerId||!ae.lastY||!ae.lastTime)return"neutral";const ft=me.clientX,Se=me.clientY,He=J(),ke=He-ae.lastTime,z=Se-ae.lastY;if(ae.startX!==null&&ae.startY!==null){const ge=ft-ae.startX,We=Se-ae.startY;if(!ae.didMove&&Math.hypot(ge,We)>=N&&(ae.didMove=!0),ae.gestureAxis===null&&ae.didMove){const tt=Math.abs(ge),wt=Math.abs(We);tt>wt*O?ae.gestureAxis="x":wt>tt*O&&(ae.gestureAxis="y")}if(ae.gestureAxis==="x")return ae.isCurrentlyScrolling=!1,qe(!1),ae.lastY=Se,ae.lastTime=He,ut?"release":"neutral";if(ae.gestureAxis===null)return ae.lastY=Se,ae.lastTime=He,"neutral"}if(ae.gestureAxis==="y"&&!ut&&!(y?.()??!0))return ae.lastY=Se,ae.lastTime=He,qe(!1),"neutral";const ie=z/Math.max(ke,1);if(ae.velocity=ae.velocity*(1-c)+ie*c,ae.velocity=Math.max(-l,Math.min(l,ae.velocity)),Math.abs(z)>1){if(!ut)return qe(!0),ae.lastY=Se,ae.lastTime=He,"claim";ae.isCurrentlyScrolling=!0;const ge=r+Math.min(n,Math.abs(z)/a),We=-z*ge;V(We,ft,Se),qe(!0)}return ae.lastY=Se,ae.lastTime=He,ut?"claim":"neutral"},onPointerUp:me=>{if(me.pointerType!=="touch"||ae.pointerId!==me.pointerId)return;const ut=ae.isCurrentlyScrolling;ae.isCurrentlyScrolling=!1,qe(!1);const ft=ae.rafId!==null||G.current!==null;!ae.didMove&&!ft&&ae.startX!==null&&ae.startY!==null&&ye.current?.(ae.startX,ae.startY),!ae.didMove&&!ft&&ae.startX!==null&&ae.startY!==null&&Te.current?.(ae.startX,ae.startY),ae.pointerId=null,ae.startX=null,ae.startY=null;const Se=ae.gestureAxis==="x";if(ae.gestureAxis=null,m&&ut&&!Se&&Math.abs(ae.velocity)>d&&ae.didMove){const He=()=>{const ke=J(),z=ke-(ae.lastTime||ke);if(ae.lastTime=ke,ae.velocity*=Math.pow(f,z),Math.abs(ae.velocity)<d){ae.velocity=0,le();return}if(!ve(-ae.velocity*z)&&de.current>2){ae.velocity=0,le();return}ae.rafId=requestAnimationFrame(He)};ae.rafId=requestAnimationFrame(He)}},onPointerCancel:me=>{me.pointerType!=="touch"||ae.pointerId!==me.pointerId||(ae.isCurrentlyScrolling=!1,qe(!1),ae.pointerId=null,ae.startX=null,ae.startY=null,ae.gestureAxis=null,le())}},at=xv.register(ze),ct=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{qe(!1),at(),Ne.style.touchAction=ct,le()}},[e,D,r,n,a,c,l,d,f,J,le,ve,V,N,m,qe,y]),De=_.useCallback(()=>{const Ne=e.current;if(!Ne)return()=>{};const ae=P.current,ze=ut=>{ut.touches.length===1&&((x?.()??!0)&&ut.cancelable&&ut.preventDefault(),ae.isCurrentlyScrolling=!1,ae.gestureAxis=null,ae.lastY=ut.touches[0].clientY,ae.startX=ut.touches[0].clientX,ae.startY=ut.touches[0].clientY,ae.didMove=!1,ae.velocity=0,le())},at=ut=>{if(ut.touches.length!==1)return;const ft=ut.touches[0].clientX,Se=ut.touches[0].clientY;if(ae.startX!==null&&ae.startY!==null){const ke=ft-ae.startX,z=Se-ae.startY;if(!ae.didMove&&Math.hypot(ke,z)>=N&&(ae.didMove=!0),ae.gestureAxis===null&&ae.didMove){const ie=Math.abs(ke),ge=Math.abs(z);ie>ge*O?ae.gestureAxis="x":ge>ie*O&&(ae.gestureAxis="y")}if(ae.gestureAxis==="x"){ae.isCurrentlyScrolling=!1,ae.lastY=Se;return}if(ae.gestureAxis===null){(x?.()??!1)&&ut.cancelable&&ut.preventDefault(),ae.lastY=Se;return}}if(ut.preventDefault(),!ae.lastY){ae.lastY=Se;return}const He=Se-ae.lastY;if(Math.abs(He)>1){ae.isCurrentlyScrolling=!0;const ke=r+Math.min(n,Math.abs(He)/a),z=-He*ke;V(z,ft,Se)}ae.lastY=Se},ct=ut=>{if(!ut.changedTouches?.[0])return;const Se=ae.isCurrentlyScrolling;ae.isCurrentlyScrolling=!1;const He=ae.rafId!==null||G.current!==null;!ae.didMove&&!He&&T&&ae.startX!==null&&ae.startY!==null&&T(ae.startX,ae.startY),!ae.didMove&&!He&&C&&ae.startX!==null&&ae.startY!==null&&C(ae.startX,ae.startY),ae.startX=null,ae.startY=null;const ke=ae.gestureAxis==="x";if(ae.gestureAxis=null,m&&Se&&!ke&&ae.didMove&&Math.abs(ae.velocity)>d){const z=()=>{if(ae.velocity*=Math.pow(f,16),Math.abs(ae.velocity)<d){ae.velocity=0,le();return}if(!ve(-ae.velocity*16)&&de.current>2){ae.velocity=0,le();return}ae.rafId=requestAnimationFrame(z)};ae.rafId=requestAnimationFrame(z)}};Ne.addEventListener("touchstart",ze,{passive:!1}),Ne.addEventListener("touchmove",at,{passive:!1}),Ne.addEventListener("touchend",ct,{passive:!1}),Ne.addEventListener("touchcancel",ct,{passive:!1});const me=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{Ne.removeEventListener("touchstart",ze),Ne.removeEventListener("touchmove",at),Ne.removeEventListener("touchend",ct),Ne.removeEventListener("touchcancel",ct),Ne.style.touchAction=me,le()}},[e,r,n,a,d,f,le,ve,V,T,C,N,x,m]),_e=_.useCallback(()=>{le();const Ne=typeof window<"u"&&"PointerEvent"in window,ae=Ne?se():()=>{},ze=Ne?()=>{}:De();return()=>{ae(),ze(),le()}},[se,De,le]),Me=_.useCallback(()=>P.current.isCurrentlyScrolling||P.current.rafId!==null||G.current!==null,[]),Ke=_.useCallback(()=>{le();const Ne=P.current;Ne.isCurrentlyScrolling=!1,Ne.velocity=0,Ne.lastY=null,Ne.lastTime=null,Ne.startX=null,Ne.startY=null,Ne.pointerId=null,Ne.didMove=!1,Ne.gestureAxis=null},[le]);return{setupTouchScroll:_e,isScrolling:Me,stopAllScroll:Ke}};function $2(e){const{name:t,priority:r}=e,n=b.useRef(e.onPointerDown),a=b.useRef(e.onPointerMove),c=b.useRef(e.onPointerUp),l=b.useRef(e.onPointerCancel),d=b.useRef(e.container);n.current=e.onPointerDown,a.current=e.onPointerMove,c.current=e.onPointerUp,l.current=e.onPointerCancel,d.current=e.container,b.useEffect(()=>{const f={name:t,priority:r,get container(){const x=d.current;return typeof x=="function"?x():x},onPointerDown(x,y){return n.current?.(x,y)??!1},onPointerMove(x,y){return a.current?.(x,y)??"neutral"},onPointerUp(x){c.current?.(x)},onPointerCancel(x){l.current?.(x)}};return xv.register(f)},[t,r])}var Zs;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Zs||(Zs={}));Zs.Light,Zs.Medium,Zs.Heavy,Zs.Success,Zs.Warning,Zs.Error;Zs.Light,Zs.Medium,Zs.Heavy,Zs.Success,Zs.Warning,Zs.Error;Zs.Light,Zs.Medium,Zs.Heavy,Zs.Success,Zs.Warning,Zs.Error;const NI=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",RI=()=>typeof document<"u"&&!!document.body,MI=()=>{if(RI())try{const e=document.createElement("label");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;";const t=document.createElement("input");t.type="checkbox",t.setAttribute("switch",""),e.appendChild(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch{}},U2=e=>Array.isArray(e)?[...e]:[e],jI=e=>{if(NI()){try{const a=U2(e),c=a.length===1?a[0]:a;navigator.vibrate(c)}catch{}return}const t=U2(e),r=Array.from({length:Math.ceil(t.length/2)},(a,c)=>[t[c*2]??0,t[c*2+1]??0]);let n=0;for(const[a,c]of r)a>0&&setTimeout(MI,n),n+=a+c},ko=e=>jI(e);function bv({message:e}){const{t}=Gr();return s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-4",children:s.jsx(_0,{dots:!0,label:e??t("terminal.loading"),className:"max-w-full rounded-full bg-surface-2 px-4 py-2 text-center shadow-sm"})})}function DI(){const{t:e}=Gr();return s.jsx(bv,{message:e("terminal.initializing")})}const BI=({message:e,onRetry:t})=>{const{t:r}=Gr();return s.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:s.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":r("terminal.error"),children:[s.jsx("title",{children:r("terminal.error")}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})]})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"font-medium text-foreground",children:r("terminal.failedToLoad")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e||r("terminal.unknownError")})]}),t&&s.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:r("common.retry")})]})})};function hf(e){return Array.from(e)}function z2(e,t,r){return Math.max(t,Math.min(r,e))}function QI(e,t,r,n){const a=hf(e),c=hf(t);let l=z2(r,0,a.length);const d=z2(n,0,c.length);let f=0;for(;f<a.length&&f<c.length&&a[f]===c[f];)f++;let m=0;for(;m<a.length-f&&m<c.length-f&&a[a.length-1-m]===c[c.length-1-m];)m++;const x=a.length-f-m,y=c.slice(f,c.length-m).join(""),w=[];if(x>0||y){const v=f+x;l>v?w.push({left:l-v}):l<v&&w.push({right:v-l}),l=v,x>0&&(w.push({backspace:x}),l=f),y&&(w.push({insert:y}),l+=hf(y).length)}return l>d?w.push({left:l-d}):l<d&&w.push({right:d-l}),l=d,{ops:w,cursor:l}}function H2(e){const t=e.value,r=e.selectionStart??t.length;return hf(t.slice(0,r)).length}const Bf=16,PI=10,W2=1.5,OI=1.8,G2=240,FI=125,$I=92;function UI(e,t,r){const n=Math.hypot(e,t),a=Math.abs(e),c=Math.abs(t),l=()=>a>=c*W2?e>0?"right":"left":c>=a*W2?t>0?"down":"up":"";if(r==="")return n>Bf?l():"";if(n<PI)return"";if(n<=Bf)return r;const d=l();if(d===""||d===r)return r;if(r==="left"&&d==="right"||r==="right"&&d==="left"||r==="up"&&d==="down"||r==="down"&&d==="up")return d;const m=r==="left"||r==="right";return(m?c:a)>=(m?a:c)*OI?d:r}function zI(e){const t=$I-Bf,r=Math.min(Math.max((e-Bf)/t,0),1);return G2-r*(G2-FI)}const HI="termdock-open-terminal-directory",_1=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?:,;!?。、“”‘’])+/gu,WI=new RegExp(`^( *)(${_1.source})`,"u"),GI=/[,;:!?]+$/u,VI=/^[a-z][a-z\d+.-]*:\/\//iu;function qI(e){return!e||e==="/"||VI.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function yv(e){const t=[];_1.lastIndex=0;let r;for(;(r=_1.exec(e))!==null;){const a=r[0].replace(GI,"");if(!qI(a))continue;const c=e.slice(r.index+a.length).match(/^:(\d+)(?::\d+)?(?=$|[\s:,,;;。!!??)\]}`])/u),l=c?Number(c[1]):void 0,d=l!==void 0&&Number.isSafeInteger(l)&&l>0;t.push({text:a,...d?{line:l}:{},startIndex:r.index,endIndex:r.index+a.length+(d?c[0].length:0)})}return t}function xm(e){const t=[];for(const r of e.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return`/${t.join("/")}`}function YI(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function ZI(e,t){const r=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(r.startsWith("/"))return xm(r);if(r==="~"||r.startsWith("~/")){const n=t?YI(t):null;return n?xm(`${n}/${r.slice(2)}`):null}return t?.startsWith("/")?xm(`${t}/${r}`):null}function Eh(e,t){const r=e.buffer.active.getLine(t-1),n=e.buffer.active.getLine(t);if(!r||!n||n.isWrapped)return null;const a=r.translateToString(!0).trimEnd(),c=n.translateToString(!0),l=yv(a).at(-1),d=c.match(WI);if(!l||l.endIndex!==a.length||!l.text.endsWith("/")||!d||/^[~./]/u.test(d[2]))return null;const f=d[2];if(!f.includes("/")&&!/^[^/:]+\.[\p{L}\p{N}_-]+$/u.test(f))return null;let m=r.length-1;for(;m>=0&&!(r.getCell(m)?.getChars()||"").trim();)m-=1;const x=d[1].length;let y=0;for(let C=x;C<n.length;C+=1){const L=n.getCell(C);if(L?.getWidth()!==0){if(!L||/[\s/:]/u.test(L.getChars()||" "))break;y+=L.getWidth()}}if(r.length-m-1>=Math.max(8,x+2,y))return null;const v=r.getCell(m),T=n.getCell(x);return!v||!T||v.isFgDefault()||T.isFgDefault()||v.getFgColorMode()!==T.getFgColorMode()||v.getFgColor()!==T.getFgColor()?null:x}function KI(e,t){const r=e.buffer.active;let n=t-1;if(!r.getLine(n))return null;for(;n>0&&(r.getLine(n)?.isWrapped||Eh(e,n)!==null);)n-=1;let a=t-1;for(;a+1<r.length&&(r.getLine(a+1)?.isWrapped||Eh(e,a+1)!==null);)a+=1;let c="";const l=[],d=[];for(let m=n;m<=a&&c.length<=2048;m+=1){const x=r.getLine(m);if(!x)break;const y=m>n?Eh(e,m)??0:0;let w=x.length;if(m<a&&Eh(e,m+1)!==null)for(;w>0&&!(x.getCell(w-1)?.getChars()||"").trim();)w-=1;for(let v=y;v<w;v+=1){const T=x.getCell(v);if(!T||T.getWidth()===0)continue;const C=T.getChars()||" ";c+=C;for(let L=0;L<C.length;L+=1)l.push({x:v+1,y:m+1}),d.push({x:v+Math.max(1,T.getWidth()),y:m+1})}}const f=c.trimEnd().length;return{text:c.slice(0,f),startPositions:l.slice(0,f),endPositions:d.slice(0,f)}}function XI(e,t){return{provideLinks(r,n){const a=KI(e,r);if(!a){n(void 0);return}const c=yv(a.text).map(l=>({text:l.text,range:{start:a.startPositions[l.startIndex]??{x:l.startIndex+1,y:r},end:a.endPositions[l.endIndex-1]??{x:l.endIndex,y:r}},activate:()=>l.line===void 0?t(l.text):t(l.text,l.line)}));n(c.length>0?c:void 0)}}}function V2(e,t){if(!e||e.lines.length===0||!Number.isFinite(t)||t<=0)return 0;const r=Math.floor(t),n=Number.isFinite(e.lines.maxLength)&&e.lines.maxLength>0?Math.floor(e.lines.maxLength):null;let a=0;if(n!==null){const f=Math.max(0,n-r);e.ybase>f&&(e.ybase=f,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,f)),a++)}let c=Math.max(0,Math.floor(e.ybase)+r),l=n===null?c:Math.min(c,n),d=Math.max(0,l-e.lines.length);if(d>r){const f=Math.max(0,e.lines.length-r);e.ybase>f&&(e.ybase=f,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,f)),a++),c=Math.max(0,Math.floor(e.ybase)+r),l=n===null?c:Math.min(c,n),d=Math.max(0,l-e.lines.length)}for(let f=0;f<d;f++){const m=e.lines.length;if(e.lines.push(e.getBlankLine(void 0)),e.lines.length<=m)break;a++}return a}function q2(e,t=e.rows){const n=e._core?._bufferService?.buffers;return n?V2(n.normal,t)+V2(n.alt,t):0}function Nh(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function JI(e,t,r){const n=Nh(e.fontBoundingBoxAscent)+Nh(e.fontBoundingBoxDescent),a=Nh(e.actualBoundingBoxAscent)+Nh(e.actualBoundingBoxDescent);return Math.max(1,Math.floor(Math.ceil(n||a||t)*r))}const Fc=8,Rh=36,Y2=10,eE=1.08,tE=1.16,Mh=6,rE=.94,nE=.08,sE=.12,iE=88,aE=36,oE=10,lE=14,cE=52,uE=80,dE=8;function jh(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function hE(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function fE(e){try{const t=atob(e),r=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder("utf-8").decode(r)}catch{return null}}function pE(e){const t="\x1B]52;";let r=0,n="";for(;r<e.length;){const a=e.indexOf(t,r);if(a===-1)return n+=e.slice(r),{cleaned:n,remainder:""};n+=e.slice(r,a);let c=-1,l=1;for(let m=a+t.length;m<e.length;m+=1){const x=e.charCodeAt(m);if(x===7){c=m,l=1;break}if(x===27&&m+1<e.length&&e[m+1]==="\\"){c=m,l=2;break}}if(c===-1)return{cleaned:n,remainder:e.slice(a)};const d=e.slice(a+t.length,c),f=d.indexOf(";");if(f>=0){const m=d.slice(f+1);if(m&&m!=="?"){const x=fE(m);x!==null&&navigator.clipboard?.writeText(x).catch(()=>{})}}r=c+l}return{cleaned:n,remainder:""}}function mE(e){if(typeof window>"u")return null;const t=[e,...Array.from(e.querySelectorAll("*"))];let r=null;for(const n of t){const c=window.getComputedStyle(n).overflowY;if(!(c!=="auto"&&c!=="scroll")){if(n.scrollHeight-n.clientHeight>2)return n;r||(r=n)}}return r}const gE=new Set(["visibility","bfcache","online"]),xE=5e5,bE=1e5,Hd=260,Wd=140,Z2=80;function yE(e){return!e}let Nu=null;const vE=[{font:'400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'400 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'700 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'400 13px "Termdock Star Symbol"',text:"✦✧"},{font:'400 13px "Noto Sans Symbols 2"',text:"⏺⏸⏹✓✗"}],wE=()=>{if(Nu)return Nu;if(typeof document>"u"||!("fonts"in document))return Nu=Promise.resolve(),Nu;const e=document.fonts;return Nu=Promise.allSettled(vE.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),Nu},K2=e=>{if((!e||e.includes("var("))&&typeof window<"u"){const t=getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim();if(t)return t}return e};function X2(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function $c(e,t,r){const n=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(n||t*r))}function AE(e){return{background:e.background,foreground:e.foreground,cursor:e.cursor||e.foreground,cursorAccent:e.cursorAccent||e.background,selectionBackground:e.selectionBackground||"rgba(0, 0, 0, 0.3)",selectionForeground:e.selectionForeground||e.foreground,black:e.black||"#6F6E69",red:e.red||"#AF3029",green:e.green||"#66800B",yellow:e.yellow||"#AD8301",blue:e.blue||"#205EA6",magenta:e.magenta||"#A02F6F",cyan:e.cyan||"#24837B",white:e.white||"#CECDC3",brightBlack:e.brightBlack||"#6F6E69",brightRed:e.brightRed||"#D14D41",brightGreen:e.brightGreen||"#879A39",brightYellow:e.brightYellow||"#D0A215",brightBlue:e.brightBlue||"#4385BE",brightMagenta:e.brightMagenta||"#CE5D97",brightCyan:e.brightCyan||"#3AA99F",brightWhite:e.brightWhite||"#FFFCF0"}}const J2=new Map;function TE(e,t,r,n,a){if(typeof window>"u"||typeof document>"u")return null;const c=e.getBoundingClientRect();if(c.width<24||c.height<24)return null;const l=window.devicePixelRatio||1,d=`${r}::${n}::${a}::${l}::${t}`;let f=J2.get(d);if(!f)try{const w=document.createElement("canvas").getContext("2d");if(!w)return null;w.font=`${r}px ${t}`;const v=w.measureText("M"),C=(Math.floor(v.width*l)+Math.round(n))/l,L=JI(v,r,a);C>=1&&L>=1&&(f={cellWidth:C,cellHeight:L},J2.set(d,f))}catch{return null}if(!f)return null;const m=Math.max(2,Math.floor(c.width/f.cellWidth)),x=Math.max(2,Math.floor(c.height/f.cellHeight));return!Number.isFinite(m)||!Number.isFinite(x)?null:{cols:m,rows:x}}function SE(e){const t=e.buffer.active,r=t.viewportY,n=Math.min(t.length,r+e.rows),a=[];for(let c=r;c<n;c+=1){const l=t.getLine(c);l&&a.push(l.translateToString(!0))}return a.join(`
71
+ `).replace(/\s+$/g,"")}function Gd(e,t,r){const n=Jc(e);if(!n)return null;const a=Math.max(0,Math.min(e.cols-1,Math.floor((t-n.originLeft)/n.cellW))),c=Math.max(0,Math.min(e.rows-1,Math.floor((r-n.originTop)/n.cellH)));return{col:a,row:e.buffer.active.viewportY+c}}function bm(e,t,r){const n=t.row*e.cols+t.col,a=r.row*e.cols+r.col;if(n===a)return e.clearSelection(),!1;const c=Math.min(n,a),l=Math.max(n,a)+1,d=c%e.cols,f=Math.floor(c/e.cols);return e.select(d,f,l-c),!0}function e5(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function CE(e,t,r,n,a=!0){if(typeof window>"u")return{left:0,top:0};const c=window.visualViewport,l=c?.offsetLeft??0,d=c?.offsetTop??0,f=c?.width??window.innerWidth,m=c?.height??window.innerHeight,x=e5("--safe-top-inset"),y=e5("--safe-bottom-inset"),w=n?JL(n.terminal,n.anchor,n.focus):null,v=[];let T;if(a&&v.push({left:e-32,top:t-32,right:e+32,bottom:t+32}),n){const L=Jc(n.terminal),{start:N,end:D}=Df(n.anchor,n.focus,n.terminal.cols),O=df(n.terminal,N),P=df(n.terminal,D);if(O&&v.push({left:O.x-24,top:O.y-48,right:O.x+24,bottom:O.y+4}),P&&L){const F=P.y+L.cellH;v.push({left:P.x-24,top:F-4,right:P.x+24,bottom:F+48})}if(w){const F=n.anchor.row*n.terminal.cols+n.anchor.col,ee=n.focus.row*n.terminal.cols+n.focus.col,Z=F<=ee,G=w.right-w.left,pe=n.anchor.row===n.focus.row?Z?w.left+G*.25:w.right-G*.25:(w.left+w.right)/2,J=df(n.terminal,n.focus),Re=J&&L?J.y+L.cellH/2:t;T={vertical:n.focus.row<n.anchor.row?"below":"above",alignX:pe,focusX:J?.x??e,focusY:Re}}}const C=eI({clientX:e,clientY:t,viewport:{left:l,top:d+x,right:l+f,bottom:d+m-y},terminal:r,width:iE,height:aE,margin:oE,fingerGap:lE,selection:w,avoid:v,preference:T,selectionGap:cE});return{left:C.left-r.left,top:C.top-r.top}}const vv=_.forwardRef(({sessionKey:e,sessionId:t,backendSessionId:r,getPasteOwnerKey:n,isLayoutVisible:a=!0,chunks:c,onInput:l,onResize:d,onFlowControl:f,onTmuxScroll:m,tmuxScrollSensitivity:x=.55,onDoubleTap:y,onInputFocusChange:w,onMobileLongPressCopyResult:v,onMobilePasteResult:T,onReadyChange:C,onSizeSynchronizedChange:L,onWritesSettled:N,onWriteProgress:D,onCursorPositionChange:O,onDirectoryLinkActivate:P,terminalSettings:F,theme:ee,className:Z,enableTouchScroll:G,mobileLongPressMode:de="arrows",autoFocus:pe=!0,cursorVisible:J=!0,suppressSmoothScroll:Re=!1},Ze)=>{const{t:V}=Gr(),ve=_.useRef(null),qe=_.useRef(null),le=_.useRef(null),ye=_.useRef(null),Te=_.useRef(null),Fe=_.useRef(Re);Fe.current=Re;const se=_.useRef(null),De=_.useRef(l),_e=_.useRef(d),Me=_.useRef(w),Ke=_.useRef(f),Ne=_.useRef(C);Ne.current=C;const ae=_.useRef(L);ae.current=L;const ze=_.useRef(N);ze.current=N;const at=_.useRef(D);at.current=D;const ct=_.useRef(O);ct.current=O;const me=_.useRef(P);me.current=P;const ut=_.useRef(F.rendererMode),ft=_.useRef(""),Se=_.useRef(0),He=_.useRef(!1),ke=_.useRef(null),z=_.useRef(0),ie=_.useRef(0),ge=_.useRef(!1),We=_.useRef(null),tt=_.useRef(null),wt=_.useRef(null),Zt=_.useRef(!1),Ut=_.useRef(null),Mt=_.useRef(()=>{}),nr=_.useRef(null),jt=_.useRef(null),Xt=_.useRef(void 0),Bt=_.useRef(null),Ht=_.useRef(!1),xe=_.useRef(0),Je=_.useRef(""),ot=_.useRef(null),Nt=_.useRef(null),K=_.useRef(!1),xt=_.useRef(typeof window<"u"?window.devicePixelRatio:1),tr=_.useRef(!1),$e=_.useRef(!1),Qr=_.useRef(null),Ce=_.useRef(""),St=_.useRef(0),Ot=_.useRef(null),Jt=_.useRef(null),lt=_.useRef(null),Ct=_.useRef(0),ar=_.useRef(0),_r=_.useRef(0),Nr=_.useRef(null),zr=_.useRef(0),Tt=_.useRef(0),Ft=_.useRef(!1),we=_.useRef(0),[,At]=_.useReducer(I=>I+1,0),[st,bt]=_.useReducer(I=>I+1,0),[Tn,bn]=_.useState("loading"),[nn,Oe]=_.useState(null),[_t,gt]=_.useState(null);_.useEffect(()=>{const I=B=>{(B.target instanceof Element?B.target.closest("[data-termdock-terminal-dropzone]"):null)?.dataset.termdockTerminalDropzone===e&&gt(String(B.detail))};return window.addEventListener("termdock:file-drop-error",I),()=>window.removeEventListener("termdock:file-drop-error",I)},[e]);const Wt=_.useMemo(()=>rd("terminal"),[]),[$t,Ar]=_.useState(!0),[Sn,Mn]=_.useState(!1);_.useEffect(()=>{if(!$t&&Tn!=="loading"){Mn(!1);return}const I=window.setTimeout(()=>Mn(!0),160);return()=>window.clearTimeout(I)},[$t,Tn]);const[vn,dn]=_.useState(!1),[kn,Hr]=_.useState({visible:!1,activeDir:""}),[ne,Xe]=_.useState(null),Dt=_.useRef(null),ur=_.useRef(!1),Fr=_.useRef({active:!1,anchor:null,focus:null,dragging:null}),[Zr,an]=_.useState(null),[Mr,Vr]=_.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),Ln=_.useRef(Mr);Ln.current=Mr;const tn=_.useRef(null),[Ur,Xr]=_.useState({active:!1,text:""}),vr=_.useRef(null),on=_.useRef(null);De.current=l,_e.current=d,Me.current=w,Ke.current=f,ut.current=F.rendererMode;const Jr=_.useRef(pe);Jr.current=pe;const hn=_.useRef(J);hn.current=J;const jr=_.useRef(G);jr.current=G;const zn=_.useRef(a);zn.current=a;const qr=yE(!!m),{rendererMode:Wr,fontFamily:Y,fontSize:Be,fontWeight:Qt,fontWeightBold:er,letterSpacing:sr,lineHeight:$r,minimumContrastRatio:Ir,drawBoldTextInBrightColors:Zn,unicodeVersion:ys,customGlyphs:is,rescaleOverlappingGlyphs:Hn,fontLigatures:fn,enableImages:Bn,smoothScrolling:Xn}=F,pn=Wr==="webgl",lr=_.useCallback(()=>{Dt.current!==null&&(clearTimeout(Dt.current),Dt.current=null),Xe(null)},[]),as=_.useCallback((I,B)=>{Dt.current!==null&&(clearTimeout(Dt.current),Dt.current=null),ur.current=!1,Xe(I),!B?.persistent&&(Dt.current=setTimeout(()=>{Dt.current=null,Xe(null)},3e3))},[]);_.useEffect(()=>{if(!ne)return;const I=()=>{Fr.current.active||lr()},B=()=>lr();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",B),document.addEventListener("visibilitychange",B),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",B),document.removeEventListener("visibilitychange",B)}},[lr,ne]),_.useEffect(()=>()=>{Dt.current!==null&&(clearTimeout(Dt.current),Dt.current=null)},[]);const rn=_.useCallback(()=>{const I=le.current,B=ve.current,$=Fr.current;if(!I||!B||!$.active||!$.anchor||!$.focus){an(null);return}const q=B.getBoundingClientRect(),Pe=Jc(I)?.cellH??16,{start:Le,end:mt}=Df($.anchor,$.focus,I.cols),ht=$.dragging==="start"?$.focus:$.dragging==="end"?$.anchor:Le,It=$.dragging==="end"?$.focus:$.dragging==="start"?$.anchor:mt,yr=(xn,Cn)=>{const Fn=df(I,xn);return Fn?{left:Fn.x-q.left,top:Cn?Fn.y-q.top:Fn.y+Pe-q.top}:null};an({start:yr(ht,!0),end:yr(It,!1)})},[]),gr=_.useCallback(I=>{const B=le.current,$=ve.current,q=Fr.current;if(!B||!$||!q.active||!q.anchor||!q.focus)return;if(q.dragging){lr();return}const Pe=$.getBoundingClientRect(),Le={x:(Pe.left+Pe.right)/2,y:(Pe.top+Pe.bottom)/2};as(CE(I?.x??Le.x,I?.y??Le.y,Pe,{terminal:B,anchor:q.anchor,focus:q.focus},I!==void 0),{persistent:!0})},[lr,as]),wr=_.useCallback(()=>{const I=Fr.current;I.active=!1,I.anchor=null,I.focus=null,I.dragging=null,an(null),lr()},[lr]);_.useEffect(()=>{if(!Zr)return;const I=le.current;if(!I)return;const B=I.onScroll(()=>{rn(),gr()}),$=I.onResize(()=>wr());return()=>{B.dispose(),$.dispose()}},[Zr,rn,gr,wr]),_.useEffect(()=>{G||Me.current?.(!1)},[G]);const xr=_.useCallback((I,B,$)=>{const q=($.element?.offsetWidth||0)/$.cols||8,Pe=($.element?.offsetHeight||0)/$.rows||16,Le=Math.max(1,Math.min($.cols,Math.floor(I/q)+1)),mt=Math.max(1,Math.min($.rows,Math.floor(B/Pe)+1));return{x:Le,y:mt}},[]),ds=_.useCallback((I,B,$)=>{const q=le.current;if(!q)return!1;const Pe=I>0?-1:1;if(q.modes?.mouseTrackingMode!=="none"){let Le,mt;if(B!==void 0&&$!==void 0){const yr=xr(B,$,q);Le=yr.x,mt=yr.y}else Le=q.buffer.active.cursorX+1,mt=q.buffer.active.cursorY+1;const It=`\x1B[<${Pe>0?64:65};${Le};${mt}M`;return De.current(It),!0}if(q.buffer.active.type==="alternate"){const Le=Pe>0?"\x1B[A":"\x1B[B";return De.current(Le),!0}return null},[xr]),jn=_.useCallback(I=>{const B=le.current;if(!B)return!1;const $=$c(le.current,Be,$r),q=xe.current+I,Pe=Math.trunc(q/$);return xe.current=q-Pe*$,Pe!==0?(B.scrollLines(Pe),!0):!1},[Be,$r]),vs=_.useCallback(I=>{if(!le.current)return!1;const q=$c(le.current,Be,$r)/Math.max(.1,x),Pe=xe.current+I;let Le=Math.trunc(Pe/q);if(xe.current=Pe-Le*q,Le===0&&Math.abs(Pe)>=q/3&&(Le=Pe>0?1:-1,xe.current=0),Le===0)return!1;const mt=Le>0?"down":"up",ht=Math.max(1,Math.min(Math.abs(Le),10));return m(mt,ht),!0},[Be,$r,m,x]),Qs=_.useRef(ds);Qs.current=ds;const Is=_.useRef(jn);Is.current=jn;const Or=_.useRef(vs);Or.current=vs;const br=_.useRef(m);br.current=m;const Qn=_.useRef({pointerId:null,tmuxActiveAtDown:!1});_.useEffect(()=>{if(!G)return;const I=ve.current;if(!I)return;const B=q=>{q.pointerType==="touch"&&(Qn.current.pointerId=q.pointerId,Qn.current.tmuxActiveAtDown=!!br.current)},$=q=>{q.pointerType==="touch"&&Qn.current.pointerId===q.pointerId&&(Qn.current.pointerId=null,Qn.current.tmuxActiveAtDown=!1)};return I.addEventListener("pointerdown",B,{capture:!0,passive:!0}),I.addEventListener("pointerup",$,{capture:!0,passive:!0}),I.addEventListener("pointercancel",$,{capture:!0,passive:!0}),()=>{I.removeEventListener("pointerdown",B,!0),I.removeEventListener("pointerup",$,!0),I.removeEventListener("pointercancel",$,!0)}},[G]);const Jn=_.useCallback(()=>{if(Ft.current)return!1;const I=Qn.current;return I.pointerId!==null?!I.tmuxActiveAtDown:!br.current},[]),es=_.useCallback((I,B,$)=>{const q=Qs.current(I,B,$);return q!==null?q:br.current?Or.current(I):Is.current(I)},[]),ui=_.useCallback((I,B)=>{if(performance.now()<=Tt.current){Tt.current=0;return}const $=le.current;if($&&$.modes?.mouseTrackingMode!=="none"){const q=xr(I,B,$),Pe=q.x,Le=q.y,mt=`\x1B[<0;${Pe};${Le}M`,ht=`\x1B[<0;${Pe};${Le}m`;De.current(mt),De.current(ht)}},[xr]),W=_.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),Ie=_.useCallback((I=700)=>{Nr.current=null,zr.current=W()+I},[W]),Ye=_.useCallback(()=>jr.current&&W()<=zr.current,[W]),rt=_.useCallback(()=>{const I=jt.current;return!I||typeof document>"u"?!1:document.activeElement===I},[]),nt=_.useCallback(()=>{if(typeof window>"u")return!1;const I=ht=>{if(typeof document>"u")return 0;const It=Number.parseFloat(document.documentElement.style.getPropertyValue(ht)||"0");return Number.isFinite(It)?It:0},B=I("--kb-height");if(B>0)return B>=Z2;const $=window.visualViewport;if(!$)return!1;const q=I("--app-base-vh")||window.innerHeight,Pe=I("--safe-bottom-inset"),Le=$.height+$.offsetTop;return Math.max(0,Math.round(q-Le-Pe))>=Z2},[]),yt=_.useCallback(()=>{Ot.current!==null&&(clearTimeout(Ot.current),Ot.current=null),Jt.current=null},[]),Pt=_.useCallback(I=>{const B=le.current;let $="";for(const q of I)q.left&&($+=(B?jh(B,"D"):"\x1B[D").repeat(q.left)),q.right&&($+=(B?jh(B,"C"):"\x1B[C").repeat(q.right)),q.backspace&&($+="".repeat(q.backspace)),q.insert&&($+=q.insert);return $},[]),H=_.useCallback(I=>{const B=I.value,$=Ed(B),q=Ce.current;if(!(jr.current&&!$.includes("\r")&&!q.includes("\r"))){if($===q)return;let yr=0;for(;yr<q.length&&yr<$.length&&q[yr]===$[yr];)yr++;const xn=q.length-yr;xn>0&&De.current("".repeat(xn));const Cn=$.slice(yr);if(Cn){try{le.current?.clearSelection()}catch{}De.current(Cn)}Ce.current=$,St.current=Array.from($).length;return}const Le=H2(I),{ops:mt,cursor:ht}=QI(q,$,St.current,Le),It=Pt(mt);if(It){if(mt.some(yr=>yr.insert))try{le.current?.clearSelection()}catch{}De.current(It)}Ce.current=$,St.current=ht},[Pt]),ue=_.useCallback((I,B)=>{const $=I.value,q=Ed($),Pe=Ce.current;if(q===Pe){yt();return}let Le=0;for(;Le<Pe.length&&Le<q.length&&Pe[Le]===q[Le];)Le++;const mt=Pe.length-Le;if(G&&!B?.immediate&&mt>=dE){Jt.current=I,Ot.current!==null&&clearTimeout(Ot.current),Ot.current=setTimeout(()=>{Ot.current=null;const It=Jt.current;Jt.current=null,It&&H(It)},uE);return}yt(),H(I)},[yt,G,H]),R=_.useCallback(I=>{ue(I,{immediate:!0}),De.current("\r"),I.value="",Ce.current="",St.current=0},[ue]),U=_.useCallback((I,B,$)=>{if(!I)return;yt();const q=B??jt.current;q&&(q.value=""),Ce.current="",St.current=0;try{le.current?.clearSelection()}catch{}wr();const Pe=sI(I,$);return De.current(Pe,{skipModifierTransform:!0,consumeModifier:$?.consumeModifier,targeted:$?.targeted,ownedPaste:$?.ownedPaste})},[yt]),X=_.useCallback((I,B)=>{const $=Ed(I);return $?(Ve.current?.controller.abort(),gt(null),Op($)||(U($,B,{paste:!0,submitAfterPaste:!1}),lr()),!0):!1},[lr,U]);_.useEffect(()=>m8(I=>{if(I.sessionKey!==e||I.paths.length===0)return;const B=I.paths.map(Uu).join(" ");U(`${B} `);try{jt.current?.focus({preventScroll:!0})}catch{}}),[U,e]);const be=_.useRef(r);be.current=r;const Ee=_.useRef({sessionKey:e,sessionId:t,getPasteOwnerKey:n});Ee.current={sessionKey:e,sessionId:t,getPasteOwnerKey:n};const Ve=_.useRef(null),dt=_.useRef(!0),Qe=_.useCallback(()=>{Ve.current?.controller.abort();const I=Ee.current,B=Gc(),$=Sl(),q=De.current,Pe=I.getPasteOwnerKey?.()??null,Le=new AbortController,mt={controller:Le,current:()=>dt.current&&!Le.signal.aborted&&Ve.current===mt&&Gc()===B&&Sl()===$&&!$?.closed&&Ee.current.sessionKey===I.sessionKey&&Ee.current.sessionId===I.sessionId&&De.current===q&&(Ee.current.getPasteOwnerKey?.()??null)===Pe};return Ve.current=mt,mt},[]),ir=_.useCallback(async I=>{const B=Qe(),$=be.current,q=()=>B.current()&&be.current===$,Pe=le.current,Le=Pe?.hasSelection()?Pe.getSelection():"";try{if(Le&&I)return I.setData("text/plain",Le),!0;if(Le){const mt=await sf(Le,q);return!mt&&q()&&gt("复制失败,请重试"),mt}return $&&br.current?await ZC($,q):!1}catch(mt){return q()&&gt(mt instanceof Error?mt.message:"复制失败,请重试"),!1}},[Qe]),rr=_.useCallback(I=>I.current(),[]);_.useEffect(()=>{const I=()=>{const $=Ve.current;$&&!$.current()&&$.controller.abort()};I(),window.addEventListener("termdock:secure-state",I);const B=()=>Ve.current?.controller.abort();return window.addEventListener("auth:unauthorized",B),()=>{window.removeEventListener("termdock:secure-state",I),window.removeEventListener("auth:unauthorized",B)}}),_.useEffect(()=>(dt.current=!0,()=>{dt.current=!1,Ve.current?.controller.abort()}),[]);const Et=_.useCallback(async(I,B,$)=>{const q=$??Qe();if(!q.current())return!1;gt(null);try{const Pe=await N3(I,q.controller.signal);return rr(q)?Op(`${Uu(Pe)} `)?!0:await U(`${Uu(Pe)} `,B)===!1?(rr(q)&&gt("终端未接受粘贴,请重试"),!1):rr(q)?(lr(),!0):!1:!1}catch(Pe){return rr(q)&&gt(Pe instanceof Error?Pe.message:"Image upload failed"),!1}},[lr,Qe,rr,U]),kr=_.useCallback(async(I,B,$=[],q)=>{const Pe=q??Qe();if(!Pe.current())return!1;gt(null);try{const Le=await j3(I,Pe.controller.signal);if(!rr(Pe))return!1;const mt=[...$,...Le];if(!mt.length)return!1;const ht=`${mt.map(Uu).join(" ")} `;return Op(ht)?!0:await U(ht,B)===!1?(rr(Pe)&&gt("终端未接受粘贴,请重试"),!1):rr(Pe)?(lr(),!0):!1}catch(Le){return rr(Pe)&&gt(Le instanceof Error?Le.message:"File upload failed"),!1}},[lr,Qe,rr,U]),ln=_.useCallback(async(I,B)=>{const $=Qe(),q=async Pe=>{const Le=await Pe;if(!$.current())throw new Error("Clipboard operation was superseded");return Le};gt(null);try{const Pe=Gc()?.targetPeerId;let Le;if(na()?.readClipboardFiles){try{const{files:It,paths:yr}=await q(M3());if(yr.length||It.length)return kr(It,I,yr,$)}catch(It){if(!$.current()||It instanceof w0)throw It;Le=It}if(Gc()?.targetPeerId!==Pe)throw new Error("目标服务已切换,请重新粘贴")}if(B?.files.length){const It=B.files[0];return B.files.length===1&&It.type.startsWith("image/")?Et(It,I,$):kr(B.files,I,[],$)}if(B?.text)return X(B.text,I);if(!na()?.readClipboardImage){if(typeof navigator.clipboard?.read=="function"){const It=await q(navigator.clipboard.read()),yr=await q(R3({read:async()=>It}));if(yr.length)return kr(yr,I,[],$);const xn=await q(Nf({read:async()=>It}));if(xn)return Et(xn,I,$);for(const Cn of It){if(!Cn.types.includes("text/plain"))continue;const Fn=await q((await q(Cn.getType("text/plain"))).text());return X(Fn,I)}return gt("剪贴板未提供可读取的文字、图片或视频;视频可通过文件按钮选择上传。"),!1}return navigator.clipboard?.readText?X(await q(navigator.clipboard.readText()),I):!1}const mt=await q(Nf(navigator.clipboard));if(mt)return Et(mt,I,$);if(!navigator.clipboard?.readText){if(Le)throw Le;return!1}const ht=await q(navigator.clipboard.readText());if(!ht&&Le)throw Le;return X(ht,I)}catch(Pe){return $.current()&&gt(Pe instanceof Error?Pe.message:"Clipboard read failed"),!1}},[Qe,kr,Et,X]),yn=_.useCallback(I=>{if(tn.current&&!I?.repositionFrozen)return null;const B=le.current;if(!B||!B.element)return null;const $=Jc(B),Pe=B.element.querySelector(".xterm-screen")??B.element,Le=Pe.getBoundingClientRect(),mt=$?.cellW??(Le.width>0&&B.cols>0?Le.width/B.cols:8),ht=$?.cellH??(Le.height>0&&B.rows>0?Le.height/B.rows:17),It=jt.current;let yr=Xt.current;It&&(yr===void 0||yr!==null&&(!yr.isConnected||!yr.contains(It)))&&(yr=rI(It),Xt.current=yr);const xn=B.buffer.active,Cn=xn.cursorX*mt,Fn=xn.cursorY*ht,ms=nI(Pe,yr??null,Cn,Fn),Ri=Math.round(ms.x),Kr=Math.round(ms.y),wn={x:Ri,y:Kr,cellW:mt,cellH:ht,cursorX:xn.cursorX};return Ln.current=wn,tn.current&&I?.repositionFrozen&&(tn.current={...wn}),Vr(Ps=>Math.abs(Ps.x-Ri)<.5&&Math.abs(Ps.y-Kr)<.5&&Math.abs(Ps.cellW-mt)<.5&&Math.abs(Ps.cellH-ht)<.5&&Ps.cursorX===xn.cursorX?Ps:wn),wn},[]),en=_.useRef(yn);en.current=yn,_.useEffect(()=>{if(!G)return;let I=null,B=null;const $=()=>{I!==null&&window.cancelAnimationFrame(I),B!==null&&window.cancelAnimationFrame(B),I=window.requestAnimationFrame(()=>{I=null,B=window.requestAnimationFrame(()=>{B=null,en.current({repositionFrozen:!0})})})};return window.visualViewport?.addEventListener("resize",$),window.visualViewport?.addEventListener("scroll",$),document.addEventListener("termdock:viewport-keyboard-change",$),()=>{I!==null&&window.cancelAnimationFrame(I),B!==null&&window.cancelAnimationFrame(B),window.visualViewport?.removeEventListener("resize",$),window.visualViewport?.removeEventListener("scroll",$),document.removeEventListener("termdock:viewport-keyboard-change",$)}},[G]);const gn=_.useCallback(I=>{let B=0;for(const $ of I){const q=$.codePointAt(0)??0,Pe=q>=4352&&q<=4447||q>=11904&&q<=12350||q>=12353&&q<=13311||q>=13312&&q<=19903||q>=19968&&q<=40959||q>=40960&&q<=42191||q>=44032&&q<=55203||q>=63744&&q<=64255||q>=65072&&q<=65103||q>=65280&&q<=65376||q>=65504&&q<=65510||q>=127744&&q<=129791;B+=Pe?2:1}return B},[]),dr=_.useCallback(I=>{const B=le.current,{cellW:$,cellH:q}=Mr;if(!B||!I)return{width:Math.max(1,Math.round($)),height:Math.max(1,Math.round(q)),whiteSpace:"pre"};const Le=tn.current?.cursorX??B.buffer.active.cursorX,mt=Math.max(1,B.cols),ht=Math.max(1,gn(I)),It=Math.max(1,mt-Le);if(ht<=It)return{width:Math.max(1,Math.round(ht*$)),height:Math.max(1,Math.round(q)),whiteSpace:"pre"};const yr=ht-It,Cn=1+Math.ceil(yr/mt);return{width:Math.max(1,Math.round(It*$)),height:Math.max(1,Math.round(Cn*q)),whiteSpace:"pre-wrap"}},[Mr,gn]),pr=_.useCallback(()=>{Xt.current=void 0;const I=en.current();tn.current={...I??Ln.current}},[]),fs=_.useCallback(()=>{tn.current=null},[]),ws=_.useCallback(I=>{if(!tr.current&&tn.current===null)return!1;if(tr.current=!1,tn.current=null,yt(),Qr.current!==null&&(clearTimeout(Qr.current),Qr.current=null),$e.current=!1,I){I.value=Ce.current;try{I.setSelectionRange(I.value.length,I.value.length)}catch{}}return Xr(B=>B.active||B.text?{active:!1,text:""}:B),!0},[yt]),_s=_.useCallback((I,B)=>{const $=jt.current;if($)try{$.removeAttribute("readonly");const Pe=typeof document<"u"&&document.activeElement===$&&!nt(),Le=W(),mt=Le-we.current;we.current=Le,Pe&&mt>600?($.blur(),$.removeAttribute("readonly"),$.focus(),we.current=W()):$.focus()}catch{}},[nt,W]),zi=_.useCallback(I=>{ar.current=W()+I},[W]),Zl=_.useCallback(()=>G?W()<=ar.current:!1,[G,W]),As=_.useCallback(I=>{zi(I),_r.current=W()},[zi,W]),Es=_.useCallback(()=>{G&&jt.current?.removeAttribute("readonly")},[G]),di=_.useCallback(I=>I instanceof HTMLElement&&(I.closest('[data-terminal-copy-popover="true"]')!==null||I.closest('[data-mobile-copy-button="true"]')!==null||I.closest("[data-selection-handle]")!==null),[]),Ca=_.useCallback(I=>{if(Es(),As(Hd),!G||I.pointerType!=="touch"){Nr.current=null;return}const B=I.target;if(di(B)){Ie();return}ne&&!(B instanceof HTMLElement&&B.closest('[data-terminal-copy-popover="true"]'))&&lr(),Nr.current={pointerId:I.pointerId,startX:I.clientX,startY:I.clientY,moved:!1}},[lr,G,As,di,ne,Es,Ie]),Kl=_.useCallback(I=>{As(Hd);const B=Nr.current;!B||B.pointerId!==I.pointerId||Math.hypot(I.clientX-B.startX,I.clientY-B.startY)>12&&(B.moved=!0)},[As]),Wn=_.useCallback(I=>{As(Wd);const B=Nr.current;Nr.current=null,!(!G||I.pointerType!=="touch")&&(!B||B.pointerId!==I.pointerId||B.moved||Ye()||_s(I.clientX,I.clientY))},[G,As,_s,Ye]),os=_.useCallback(()=>{Nr.current=null,As(Wd)},[As]),Ns=_.useMemo(()=>({enableKinetic:!0}),[]),no=_.useRef(()=>!1),Hs=_.useRef(_s);Hs.current=_s;const _l=_.useCallback((I,B)=>{Ye()||Hs.current(I,B)},[Ye]),za=_.useRef(y);za.current=y;const Pn=_.useRef(v);Pn.current=v;const Li=_.useRef(T);Li.current=T;const Ha=_.useCallback(()=>{if(ur.current)return;ur.current=!0,Ie();const I=le.current,B=I?.hasSelection()?I.getSelection():"";try{I?.clearSelection()}catch{}ci.flushSync(()=>{wr()}),(async()=>{const $=await sf(B);Pn.current?.($)})()},[wr,Ie]),Mo=_.useCallback(I=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:I}}))},[]),{setupTouchScroll:hi,stopAllScroll:On}=EI(ve,{...Ns,shouldCaptureTouch:no.current,canStartScrollGesture:Jn,onScroll:es,onScrollWithCoords:es,onClickWithCoords:ui,onTap:_l,onClaimChange:Mo,tapThreshold:12,gestureName:`normal-scroll:${e}`});_.useEffect(()=>{if(!G)return;jt.current?.setAttribute("readonly","");const I=hi();return()=>{I()}},[G,hi]),_.useEffect(()=>{if(!G)return;let I=nt();const B=()=>{const $=nt();if(I&&!$){const q=jt.current;q&&typeof document<"u"&&document.activeElement===q&&(q.setAttribute("readonly",""),q.blur())}I=$};return window.visualViewport?.addEventListener("resize",B),window.visualViewport?.addEventListener("scroll",B),document.addEventListener("termdock:viewport-keyboard-change",B),()=>{window.visualViewport?.removeEventListener("resize",B),window.visualViewport?.removeEventListener("scroll",B),document.removeEventListener("termdock:viewport-keyboard-change",B)}},[G,nt]),_.useEffect(()=>{if(!G)return;const I=ve.current;if(!I)return;const B=q=>{const Le=q.sourceCapabilities?.firesTouchEvents===!0,mt=W()-_r.current<=1200;return!Le&&!mt?!1:I.contains(q.target)},$=q=>{B(q)&&(q.cancelable&&q.preventDefault(),q.stopImmediatePropagation(),q.stopPropagation())};return I.addEventListener("mousedown",$,{capture:!0,passive:!1}),I.addEventListener("mouseup",$,{capture:!0,passive:!1}),I.addEventListener("click",$,{capture:!0,passive:!1}),document.addEventListener("mouseup",$,{capture:!0,passive:!1}),()=>{I.removeEventListener("mousedown",$,!0),I.removeEventListener("mouseup",$,!0),I.removeEventListener("click",$,!0),document.removeEventListener("mouseup",$,!0)}},[G,W]);const Js=_.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),ls=_.useCallback(()=>{const I=Js.current;I.rafId!==null&&(cancelAnimationFrame(I.rafId),I.rafId=null)},[]),Wa=_.useCallback((I,B,$)=>{const q=le.current;if(!q||!q.element||!q.cols||!q.rows)return null;const Pe=Js.current,Le=q.element.getBoundingClientRect(),mt=B??Pe.lastX??Le.left+Le.width/2,ht=$??Pe.lastY??Le.top+Le.height/2,It=mt-Le.left,yr=ht-Le.top,xn=q.element.offsetWidth/q.cols||8,Cn=q.element.offsetHeight/q.rows||16,Fn=Math.max(1,Math.min(q.cols,Math.floor(It/xn)+1)),ms=Math.max(1,Math.min(q.rows,Math.floor(yr/Cn)+1));return`\x1B[<${I==="up"?64:65};${Fn};${ms}M`},[]),ps=_.useCallback((I,B,$,q)=>{if(B<=0)return;const Pe=Wa(I,$,q);Pe&&De.current(B===1?Pe:Pe.repeat(B))},[Wa]),tl=_.useRef(ps);tl.current=ps;const ia=_.useRef(()=>{}),rl=_.useCallback(()=>{const B=$c(le.current,Be,$r)/Math.max(.1,x),$=1+Js.current.instantSpeed*.1;return B/Math.min(6,$)},[Be,$r,x]),_a=_.useCallback(()=>{const I=Js.current;I.rafId=null;const B=rl();let $=0,q=0;for(;$+q<Mh&&I.remainder>=B;)I.remainder-=B,q++;for(;$+q<Mh&&I.remainder<=-B;)I.remainder+=B,$++;if(q>0&&ps("down",q),$>0&&ps("up",$),$+q>0)I.rafId=requestAnimationFrame(_a);else if(I.pointerId!==null&&Math.abs(I.remainder)>=B/3){const Le=I.remainder>0?"down":"up";I.remainder=0,ps(Le,1),I.rafId=requestAnimationFrame(_a)}},[rl,ps]),jo=_.useCallback(()=>{const I=Js.current;I.rafId===null&&typeof requestAnimationFrame<"u"&&(I.rafId=requestAnimationFrame(_a))},[_a]),so=_.useCallback(I=>{if(I.pointerType!=="touch")return!1;ls();const B=Js.current;return B.pointerId=I.pointerId,B.lastX=I.clientX,B.lastY=I.clientY,B.startX=I.clientX,B.startY=I.clientY,B.gestureAxis=null,B.remainder=0,B.velocity=0,B.instantSpeed=0,B.didScroll=!1,!1},[ls]),Do=_.useCallback((I,B)=>{if(Ft.current)return B?"release":"neutral";if(performance.now()<=Tt.current)return"neutral";const $=Js.current;if(I.pointerType!=="touch"||I.pointerId!==$.pointerId||$.lastY==null)return"neutral";if($.gestureAxis===null&&$.startX!==null&&$.startY!==null){const Le=Math.abs(I.clientX-$.startX),mt=Math.abs(I.clientY-$.startY);if(Le>Y2||mt>Y2){if(Le>mt*eE)return $.gestureAxis="x","release";mt>Le*tE&&($.gestureAxis="y")}}if($.gestureAxis==="x")return $.lastX=I.clientX,$.lastY=I.clientY,"release";if($.gestureAxis===null)return $.lastX=I.clientX,$.lastY=I.clientY,"neutral";const q=I.clientY-$.lastY;$.lastX=I.clientX,$.lastY=I.clientY;const Pe=-q;if($.remainder+=Pe,$.instantSpeed=Math.abs(Pe),$.velocity=$.velocity*.45+Pe*.55,B){const mt=$c(le.current,Be,$r)/Math.max(.1,x);Math.abs($.remainder)>=mt/3&&($.didScroll=!0,jo())}return"claim"},[Be,$r,x,jo]),ka=_.useCallback(I=>{const B=Js.current;if(I.pointerType!=="touch"||I.pointerId!==B.pointerId)return;if(ls(),B.pointerId=null,B.lastX=null,B.lastY=null,B.startX=null,B.startY=null,B.instantSpeed=0,B.gestureAxis==="x"){B.gestureAxis=null;return}B.gestureAxis=null;const q=$c(le.current,Be,$r)/Math.max(.1,x);if(B.didScroll&&Math.abs(B.velocity)>q*nE){const Pe=()=>{B.velocity*=rE,B.remainder+=B.velocity;const Le=1+Math.abs(B.velocity)*.1,mt=q/Math.min(6,Le);if(Math.abs(B.velocity)<q*sE){if(Math.abs(B.remainder)>=mt/3){const yr=B.remainder>0?"down":"up";ps(yr,1),B.remainder=0}B.velocity=0,B.rafId=null;return}let ht=0,It=0;for(;ht+It<Mh&&B.remainder>=mt;)B.remainder-=mt,It++;for(;ht+It<Mh&&B.remainder<=-mt;)B.remainder+=mt,ht++;It>0&&ps("down",It),ht>0&&ps("up",ht),B.rafId=requestAnimationFrame(Pe)};B.rafId=requestAnimationFrame(Pe)}else Math.abs(B.remainder)>=q/3&&jo();B.didScroll&&I.stopImmediatePropagation()},[ls,ps,jo,x,Be,$r]),Xl=_.useCallback(I=>{const B=Js.current;I.pointerType!=="touch"||I.pointerId!==B.pointerId||(ls(),B.pointerId=null,B.lastX=null,B.lastY=null,B.startX=null,B.startY=null,B.gestureAxis=null,B.remainder=0,B.velocity=0,B.didScroll=!1)},[ls]);$2({name:`tmux-scroll:${e}`,priority:LI,container:()=>ve.current,onPointerDown:G&&m?so:void 0,onPointerMove:G&&m?Do:void 0,onPointerUp:G&&m?ka:void 0,onPointerCancel:G&&m?Xl:void 0});const fi=_.useRef({pointerId:null,originX:0,originY:0,holdTimer:null,mode:"idle",longPressMode:"arrows",copyStart:null,copyDidSelect:!1,edgeScrollTimer:null,edgeScrollDir:0,edgeScrollLines:0,edgeClientX:0,edgeClientY:0,gestureLocked:!1,joystickDir:"",joystickRepeatTimer:null,repeatIntervalMs:260,lastHapticTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,tapStartX:0,tapStartY:0,tapDidMove:!1}),ei=_.useRef(null);ei.current=ve.current;const pi=ei,nl=De,aa=_.useRef(de);aa.current=de;const ks=_.useCallback(I=>{const B=fi.current;B.gestureLocked!==I&&(B.gestureLocked=I,Mo(I))},[Mo]),Hi=_.useCallback(()=>{const I=fi.current;I.edgeScrollTimer!==null&&(clearInterval(I.edgeScrollTimer),I.edgeScrollTimer=null),I.edgeScrollDir=0},[]),La=_.useCallback(I=>{const B=le.current,$=fi.current;if(B){if($.mode==="copy"&&$.copyStart){$.copyDidSelect=bm(B,$.copyStart,I)||$.copyDidSelect;return}if($.mode==="adjust"){const q=Fr.current;if(!q.active||!q.anchor)return;q.focus=XL(B,I),bm(B,q.anchor,q.focus),rn()}}},[rn]),Ia=_.useCallback((I,B)=>{const $=le.current,q=fi.current;if(!$)return;const Pe=Jc($);if(!Pe)return;const Le=Pe.originTop,mt=Pe.originTop+$.rows*Pe.cellH,ht=Math.max(28,Pe.cellH*1.5),It=B-Le,yr=mt-B;let xn=0,Cn=0;if(It<ht?(xn=-1,Cn=Math.min(1,(ht-It)/ht)):yr<ht&&(xn=1,Cn=Math.min(1,(ht-yr)/ht)),q.edgeClientX=I,q.edgeClientY=B,xn===0){Hi();return}q.edgeScrollDir=xn,q.edgeScrollLines=1+Math.round(Cn*5),q.edgeScrollTimer===null&&(q.edgeScrollTimer=setInterval(()=>{const Fn=le.current,ms=fi.current;if(!Fn||ms.edgeScrollDir===0)return;if(ms.mode!=="copy"&&ms.mode!=="adjust"){Hi();return}Fn.scrollLines(ms.edgeScrollDir*ms.edgeScrollLines);const Ri=Gd(Fn,ms.edgeClientX,ms.edgeClientY-Rh);Ri&&La(Ri)},60))},[La,Hi]),mi=_.useCallback(I=>{if(I.pointerType!=="touch")return!1;const B=pi.current;if(!B)return!1;const $=I.target;if(!($ instanceof HTMLElement)||!B.contains($)||$.closest('[data-mobile-keyboard="true"]'))return!1;const q=fi.current;q.longPressMode=aa.current;const Pe=Fr.current;if(Pe.active&&q.pointerId===null){const Le=$.closest("[data-selection-handle]");if(Le instanceof HTMLElement){const mt=le.current,ht=Le.dataset.selectionHandle==="start"?"start":"end";if(mt&&Pe.anchor&&Pe.focus){const It=Df(Pe.anchor,Pe.focus,mt.cols);return Pe.anchor=ht==="start"?It.end:It.start,Pe.focus=ht==="start"?It.start:It.end,Pe.dragging=ht,lr(),q.pointerId=I.pointerId,q.tapStartX=I.clientX,q.tapStartY=I.clientY,q.tapDidMove=!1,q.mode="adjust",Ft.current=!0,Ie(1800),jt.current?.setAttribute("readonly",""),On(),ls(),ko(Fc),ks(!0),!0}}if(!$.closest("[data-terminal-copy-popover]")){wr();try{le.current?.clearSelection()}catch{}}}if(q.pointerId!==null)return!0;if(Ft.current=!1,za.current){const Le=performance.now(),mt=I.clientX,ht=I.clientY;if(q.lastTapTime!==0&&Le-q.lastTapTime<=300&&Math.hypot(mt-q.lastTapX,ht-q.lastTapY)<=25)return ko(Fc),Tt.current=performance.now()+500,za.current?.(),dn(!0),on.current&&clearTimeout(on.current),on.current=setTimeout(()=>dn(!1),400),q.lastTapTime=0,!0}return q.holdTimer!==null&&(clearTimeout(q.holdTimer),q.holdTimer=null),q.joystickRepeatTimer!==null&&(clearTimeout(q.joystickRepeatTimer),q.joystickRepeatTimer=null),q.joystickDir="",q.copyStart=null,q.copyDidSelect=!1,q.pointerId=I.pointerId,q.originX=I.clientX,q.originY=I.clientY,q.tapStartX=I.clientX,q.tapStartY=I.clientY,q.tapDidMove=!1,q.mode="holding",q.longPressMode==="copy"&&ks(!0),q.holdTimer=setTimeout(()=>{if(q.holdTimer=null,q.mode==="holding"){if(q.longPressMode==="copy"){const Le=le.current,mt=Le?Gd(Le,q.tapStartX,q.tapStartY):null;if(!Le||!mt){q.mode="idle";return}q.mode="copy",Ft.current=!0,Ie(1800),jt.current?.setAttribute("readonly",""),q.copyStart=mt,q.copyDidSelect=!1,On(),ls(),Le.clearSelection(),ko(Fc),ks(!0);return}q.mode="arrow",Ft.current=!0,Ie(1e3),On(),ls(),ko(Fc),ks(!0),requestAnimationFrame(()=>{Hr({visible:!0,activeDir:""})})}},350),!0},[ks,lr,wr]),_c=_.useCallback((I,B)=>{if(I.pointerType!=="touch")return"neutral";const $=fi.current;if($.mode==="arrow"&&I.pointerId!==$.pointerId||$.mode==="copy"&&I.pointerId!==$.pointerId||$.mode!=="arrow"&&$.mode!=="copy"&&I.pointerId!==$.pointerId)return"neutral";const q=I.clientX-$.tapStartX,Pe=I.clientY-$.tapStartY;if(Math.hypot(q,Pe)>10&&($.tapDidMove=!0),$.mode==="holding"){if(!B)return $.holdTimer!==null&&(clearTimeout($.holdTimer),$.holdTimer=null),ks(!1),Ft.current=!1,$.mode="idle","neutral";const Le=I.clientX-$.originX,mt=I.clientY-$.originY;return $.longPressMode==="copy"&&Math.hypot(Le,mt)>20?($.holdTimer!==null&&(clearTimeout($.holdTimer),$.holdTimer=null),ks(!1),Ft.current=!1,$.mode="idle","release"):Math.hypot(Le,mt)>20?($.holdTimer!==null&&(clearTimeout($.holdTimer),$.holdTimer=null),ks(!1),$.mode="idle","release"):"claim"}if($.mode==="adjust"){if(!B)return"claim";On();const Le=le.current,mt=Fr.current;if(!Le||!mt.active||!mt.anchor||!mt.focus)return"claim";const ht=Gd(Le,I.clientX,I.clientY-Rh);return ht&&(La(ht),Ia(I.clientX,I.clientY)),"claim"}if($.mode==="copy"){if(!B)return"claim";On();const Le=le.current;if(!Le||!$.copyStart)return"claim";const mt=Gd(Le,I.clientX,I.clientY-Rh);return mt&&(La(mt),Ia(I.clientX,I.clientY)),"claim"}if($.mode==="arrow"){if(!B)return"claim";const Le={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},mt=I.clientX-$.tapStartX,ht=I.clientY-$.tapStartY,It=UI(mt,ht,$.joystickDir);if(It&&It!==$.joystickDir&&($.originX=I.clientX,$.originY=I.clientY),It){const yr=I.clientX-$.originX,xn=I.clientY-$.originY,Cn=Math.hypot(yr,xn);if($.repeatIntervalMs=zI(Cn),It!==$.joystickDir){$.joystickRepeatTimer!==null&&clearTimeout($.joystickRepeatTimer);const Fn=$.joystickDir==="";$.joystickDir=It,nl.current(Le[It]);const ms=performance.now();ms-$.lastHapticTime>120&&(ko(Fc),$.lastHapticTime=ms);const Ri=Fn?400:300;$.joystickRepeatTimer=setTimeout(function Kr(){if($.joystickDir!==It)return;nl.current(Le[It]);const wn=performance.now();wn-$.lastHapticTime>120&&(ko(Fc),$.lastHapticTime=wn),$.joystickRepeatTimer=setTimeout(Kr,$.repeatIntervalMs)},Ri)}Hr({visible:!0,activeDir:It})}else $.joystickRepeatTimer!==null&&(clearTimeout($.joystickRepeatTimer),$.joystickRepeatTimer=null),$.joystickDir="",Hr({visible:!0,activeDir:""});return"claim"}return"neutral"},[ks,La,Ia]),kc=_.useCallback(I=>{if(I.pointerType!=="touch"||I.pointerId!==fi.current.pointerId)return;const B=fi.current;if(B.mode==="copy"){On(),ls(),Hi(),ks(!1);const q=le.current;let Pe=null;if(q&&B.copyStart&&(Pe=Gd(q,I.clientX,I.clientY-Rh),Pe&&(B.copyDidSelect=bm(q,B.copyStart,Pe)||B.copyDidSelect)),q&&B.copyDidSelect&&q.hasSelection()&&B.copyStart){const Le=Fr.current;Le.active=!0,Le.anchor=B.copyStart,Le.focus=Pe??B.copyStart,Le.dragging=null,rn(),gr({x:I.clientX,y:I.clientY}),Ie(1800),ko(Fc)}else Pn.current?.(!1);B.holdTimer!==null&&(clearTimeout(B.holdTimer),B.holdTimer=null),B.copyStart=null,B.copyDidSelect=!1,B.pointerId=null,B.mode="idle",Ft.current=!1;return}if(B.mode==="adjust"){On(),ls(),Hi(),ks(!1),Fr.current.dragging=null,rn(),gr({x:I.clientX,y:I.clientY}),Ie(1800),B.pointerId=null,B.mode="idle",Ft.current=!1;return}if(B.mode==="arrow"){On(),ls(),ks(!1),Hr({visible:!1,activeDir:""}),B.holdTimer!==null&&(clearTimeout(B.holdTimer),B.holdTimer=null),B.joystickRepeatTimer!==null&&(clearTimeout(B.joystickRepeatTimer),B.joystickRepeatTimer=null),B.joystickDir="",B.pointerId=null,B.mode="idle",Ft.current=!1;return}const $=pi.current;if($&&!B.tapDidMove){const q=I.target;q instanceof HTMLElement&&$.contains(q)&&!q.closest('[data-mobile-keyboard="true"]')&&(B.lastTapTime=performance.now(),B.lastTapX=I.clientX,B.lastTapY=I.clientY)}else B.tapDidMove&&(B.lastTapTime=0);B.holdTimer!==null&&(clearTimeout(B.holdTimer),B.holdTimer=null),B.joystickRepeatTimer!==null&&(clearTimeout(B.joystickRepeatTimer),B.joystickRepeatTimer=null),B.joystickDir="",ks(!1),Ft.current=!1,B.copyStart=null,B.copyDidSelect=!1,B.pointerId=null,B.mode="idle"},[ks,On,Ie,Hi,rn,gr]),Jl=_.useCallback(()=>{const I=fi.current;ks(!1),Hi(),I.mode==="arrow"&&Hr({visible:!1,activeDir:""}),I.mode==="adjust"&&(Fr.current.dragging=null,rn(),gr()),I.holdTimer!==null&&(clearTimeout(I.holdTimer),I.holdTimer=null),I.joystickRepeatTimer!==null&&(clearTimeout(I.joystickRepeatTimer),I.joystickRepeatTimer=null),I.joystickDir="",Ft.current=!1,I.copyStart=null,I.copyDidSelect=!1,I.pointerId=null,I.tapDidMove=!1,I.mode="idle"},[ks,Hi,rn,gr]);$2({name:`long-press:${e}`,priority:kI,container:()=>ve.current,onPointerDown:G?mi:void 0,onPointerMove:G?_c:void 0,onPointerUp:G?kc:void 0,onPointerCancel:G?Jl:void 0});const Ws=_.useCallback((I={})=>{ie.current+=1,ft.current="",tt.current=null,Se.current=0,Zt.current=!1,Ut.current=null,He.current&&(He.current=!1,I.notifyFlowResume===!0&&Ke.current?.(!1)),ke.current=null,ge.current=!1,We.current=null,Je.current=""},[]),ti=_.useCallback((I="unknown")=>{const B=se.current,$=le.current,q=ve.current;if(!B||!$||!q||!$.element||!$.cols||!$.rows)return;const Pe=q.getBoundingClientRect();if(Pe.width<24||Pe.height<24){Wt("skip fit: container too small",{reason:I,width:Math.round(Pe.width),height:Math.round(Pe.height)});return}try{const Le={cols:$.cols,rows:$.rows},mt=$.buffer.active,ht=cI(mt.type,mt.baseY,mt.viewportY),It=B.proposeDimensions();if(!It||It.cols<=0||It.rows<=0)return;const yr=q2($,Le.rows),xn=aI({reason:I,currentCols:Le.cols,currentRows:Le.rows,proposedCols:It.cols,proposedRows:It.rows});let Cn=0;if(xn.accept){Ii.current&&br.current&&(Le.cols!==It.cols||Le.rows!==It.rows)&&Te.current?.begin();const ms=$.options.smoothScrollDuration;try{$.options.smoothScrollDuration=0,$.resize(It.cols,It.rows),Cn=q2($,It.rows),ht&&$.scrollToBottom()}finally{$.options.smoothScrollDuration=ms}xe.current=0}(yr>0||Cn>0)&&($.refresh(0,Math.max(0,$.rows-1)),Wt("xterm buffer invariant repaired",{reason:I,before:yr,after:Cn,cols:$.cols,rows:$.rows}));const Fn={cols:$.cols,rows:$.rows};Wt("fit",{reason:I,backend:"xterm",width:Math.round(Pe.width),height:Math.round(Pe.height),before:Le,proposed:It,next:Fn,hysteresis:xn,changed:Le.cols!==Fn.cols||Le.rows!==Fn.rows})}catch{Te.current?.cancel()}},[Wt]),Wi=_.useCallback(I=>{const B=le.current;if(B)try{B.refresh(0,Math.max(0,B.rows-1)),Wt("terminal refreshed (sync)",{reason:I,cols:B.cols,rows:B.rows,hasWebgl:!!ot.current})}catch($){Wt("terminal refresh (sync) failed",{reason:I,error:$})}},[Wt]),Ea=_.useCallback(I=>{const B=Nt.current;if(B){try{B.dispose()}catch{}Nt.current=null}const $=ot.current;if(!$)return!1;Te.current?.cancel();try{$.dispose()}catch{}return ot.current=null,Wt("renderer disposed",{type:"webgl",reason:I}),!0},[Wt]),oa=_.useCallback((I,B)=>{if(ot.current)return!0;try{const $=new sk({customGlyphs:is});return Nt.current=$.onContextLoss(()=>{Wt("webgl context loss",{reason:"onContextLoss"}),K.current=!0,typeof window<"u"&&window.setTimeout(()=>{Lt("webgl-context-loss",{forceRendererRecreate:!0})},0)}),Te.current?.cancel(),I.loadAddon($),ot.current=$,K.current=!1,Wt("renderer",{type:"webgl",reason:B,mobile:G,mode:ut.current}),Wi(`webgl-enabled:${B}`),ti(`webgl-enabled:${B}`),la.current=!0,!0}catch($){return Wt("webgl load failed, fallback to dom renderer",{reason:B,error:$,mobile:G,mode:ut.current}),!1}},[Wt,is,G,ti,Wi]),Bo=200,Ts=_.useRef(0),Na=_.useRef(new Map),cs=_.useRef(new Map),ts=_.useRef(gm()),Ss=_.useRef(null),ri=_.useRef(null),Qo=_.useRef(-1),Ga=_.useRef(new Map),la=_.useRef(!1),Ii=_.useRef(!1),io=_.useRef(O2()),Gi=_.useRef(null),Ra=_.useRef(null),Vi=_.useCallback(()=>{Gi.current!==null&&(clearTimeout(Gi.current),Gi.current=null),Ra.current=null},[]),ca=_.useCallback(()=>{const I=Na.current;I.forEach(B=>cancelAnimationFrame(B)),I.clear(),cs.current.clear()},[]),Rs=_.useCallback(()=>{Ss.current!==null&&(window.clearTimeout(Ss.current),Ss.current=null)},[]),Ei=_.useRef(()=>{}),ao=_.useCallback(I=>{Rs(),ae.current?.(!1),_e.current(I.cols,I.rows,I.seq),Ss.current=window.setTimeout(()=>{Ss.current=null;const B=P2(ts.current,I.seq);ts.current=B.state,B.request&&Ii.current?(Wt("resize ack timeout; retrying",{seq:I.seq,retrySeq:B.request.seq,cols:B.request.cols,rows:B.request.rows}),Ei.current(B.request)):B.exhausted&&(Te.current?.cancel(),Wt("resize ack timeout; leaving size unconfirmed",{seq:I.seq,cols:I.cols,rows:I.rows}))},1200)},[Rs,Wt]);Ei.current=ao;const Ma=_.useCallback((I,B)=>{if(!Ii.current)return;const $=fI(ts.current,{cols:I,rows:B});ts.current=$.state,$.request&&ao($.request)},[ao]),Ni=_.useCallback((I,B)=>{const $=yI(io.current,Date.now());if($.action==="send"){Ra.current=null,Ma(I,B);return}Ra.current={cols:I,rows:B},Gi.current===null&&(Gi.current=setTimeout(()=>{Gi.current=null;const q=Ra.current;Ra.current=null,q&&(io.current=vI(Date.now()),Ma(q.cols,q.rows))},Math.max(0,$.readyAt-Date.now())))},[Ma]),oo=1500,ec=400,kl=_.useRef(0),Po=_.useRef(0),ce=_.useCallback((I,B,$)=>{if(!Number.isFinite(I)||!Number.isFinite(B)||I<=0||B<=0)return;const q=Math.floor(I),Pe=Math.floor(B);ts.current=gI(ts.current,{cols:q,rows:Pe}),kl.current=Date.now(),Wt("pty-size broadcast received",{cols:q,rows:Pe,source:$??"unknown"})},[Wt]),Ge=_.useCallback(I=>{const B=le.current;if(!B||!B.cols||!B.rows||!Ii.current||typeof document<"u"&&(document.visibilityState!=="visible"||!Pu()))return;const $=Date.now();if($-kl.current<oo||$-Po.current<ec)return;const q=B.cols,Pe=B.rows,Le=ts.current.confirmed;Le&&Le.cols===q&&Le.rows===Pe||(Po.current=$,Wt("ensureSizeMatches push",{reason:I,cols:q,rows:Pe,lastServerSize:Le}),Ma(q,Pe))},[Wt,Ma]),vt=_.useCallback((I,B)=>{const $=le.current,q=se.current;if(!$||!q)return;if(!la.current){Wt("refresh skipped: renderer not ready",{reason:I});return}if(B.dedupeKey!==void 0){if(Ga.current.get(I)===B.dedupeKey){Wt("refresh deduped",{reason:I,dedupeKey:B.dedupeKey});return}Ga.current.set(I,B.dedupeKey)}Wt("refresh",{reason:I,options:B});const Pe=B.forceRendererRecreate===!0||K.current||pn&&!!ot.current&&gE.has(I)&&/Android/i.test(navigator.userAgent);let Le=!1;Pe&&(K.current=!1,pn?(Ea(`refresh:${I}`),oa($,`refresh:${I}`)||Wi(`refresh:${I}:webgl-fallback`),Le=!0):(Wi(`refresh:${I}`),Le=!0)),dI(B.forceRedraw===!0,I==="dpr-change",Le)?Wi(`refresh:${I}`):Le||Wt("terminal redraw skipped: fit/write already repaints",{reason:I});const mt={cols:$.cols,rows:$.rows};ti(`refresh:${I}`);const ht={cols:$.cols,rows:$.rows};if(B.skipResizePush||oI({before:mt,after:ht,lastServerSize:ts.current.confirmed,reconcileServerSize:B.reconcileServerSize})&&Ni(ht.cols,ht.rows),!B.skipScrollToBottom&&I!=="resize"&&I!=="dpr-change"){const yr=requestAnimationFrame(()=>{const Fn=le.current;if(Fn&&Fn.buffer.active.type!=="alternate")try{Fn.scrollToBottom()}catch{}}),xn=Na.current,Cn=xn.get(I);Cn!==void 0&&cancelAnimationFrame(Cn),xn.set(I,yr)}},[Wt,pn,Ea,oa,Wi,ti,Ni]),Lt=_.useCallback((I,B={})=>{if(le.current,I==="session-key-change"&&(ts.current=gm(),Rs(),Vi(),io.current=O2(),Ga.current.clear(),ca()),!B.force&&(I==="visibility"||I==="bfcache"||I==="online")){const q=Date.now();if(q-Ts.current<Bo){Wt("refresh throttled",{reason:I});return}Ts.current=q}if(cs.current.set(I,B),Na.current.has(I))return;const $=requestAnimationFrame(()=>{const q=cs.current.get(I)??{};Na.current.delete(I),cs.current.delete(I),vt(I,q)});Na.current.set(I,$)},[Wt,ca,Rs,Vi,vt]),et=_.useCallback(I=>{const B=Na.current.get(I);if(B===void 0)return;const $=cs.current.get(I)??{};cancelAnimationFrame(B),Na.current.delete(I),cs.current.delete(I),vt(I,$)},[vt]);ia.current=()=>et("resize"),_.useEffect(()=>()=>{ca(),Bt.current!==null&&(window.clearTimeout(Bt.current),Bt.current=null)},[e,ca]),_.useEffect(()=>{ts.current=gm(),Rs(),Ga.current.clear()},[e,Rs]);const Rt=_.useCallback(()=>{if(ge.current)return;const I=le.current;if(!I){Ws();return}if(!ft.current)return;const B=ft.current,$=B.length,q=tt.current,Pe=Zt.current;ft.current="",tt.current=null,Zt.current=!1,ge.current=!0;let Le=null;Pe&&(Le=Ut.current??{depth:0},Ut.current=Le,Le.depth+=1);const mt=Te.current,ht=mt?.generation;I.write(B,()=>{if(Le&&(Le.depth-=1),ht!==void 0&&mt?.written(ht),ge.current=!1,Se.current-=$,Se.current<0&&(Se.current=0),q!==null&&at.current?.(q),He.current&&Se.current<bE&&(He.current=!1,Ke.current?.(!1)),ft.current){Rt();return}const It=++ie.current,yr=()=>{if(It!==ie.current||ge.current||ft.current)return;const xn=I.buffer.active;ze.current?.({x:xn.cursorX,y:xn.cursorY,rows:I.rows,lastProcessedChunkId:We.current})};typeof window>"u"?yr():window.requestAnimationFrame(()=>{window.requestAnimationFrame(yr)})})},[Ws]);Mt.current=Rt;const cr=_.useCallback(()=>{if(ke.current!==null)return;const I=++z.current;ke.current=I,queueMicrotask(()=>{ke.current===I&&(ke.current=null,Rt())})},[Rt]),Lr=_.useCallback((I,B,$=!1)=>{if(!I)return;ie.current+=1,ft.current+=I,tt.current=B,Zt.current=Zt.current||$,Se.current+=I.length;const q=wt.current;(q===null||B>q)&&(wt.current=B),!He.current&&Se.current>=xE&&(He.current=!0,Ke.current?.(!0)),cr()},[cr]);return _.useEffect(()=>{let I=!1,B=null,$=null,q=[];const Pe=ve.current;return Pe?(Pe.tabIndex=G?-1:0,(async()=>{if(Ne.current?.(!1),bn("loading"),Oe(null),Ar(!0),await wE(),!I)try{const mt=TE(Pe,K2(Y),Be,sr,$r),ht=new QA({...mt?{cols:mt.cols,rows:mt.rows}:{},allowProposedApi:!0,fontFamily:K2(Y),fontSize:Be,fontWeight:X2(Qt),fontWeightBold:X2(er),theme:AE(ee),logLevel:"off",cursorBlink:!pn,cursorStyle:"block",cursorInactiveStyle:hn.current?"bar":"none",scrollback:m?2e3:5e3,scrollbar:{showScrollbar:!1},allowTransparency:iC(Wr,Bn),convertEol:qr,drawBoldTextInBrightColors:Zn,rescaleOverlappingGlyphs:Hn,minimumContrastRatio:Ir,letterSpacing:sr,lineHeight:$r,smoothScrollDuration:Xn&&!Fe.current?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),It=new PA;ht.loadAddon(It);const yr=dk(window.termdockDesktop,Kr=>{window.open(Kr)});ht.loadAddon(new uk(yr)),ht.registerLinkProvider(XI(ht,(Kr,wn)=>{me.current?.(Kr,wn)}));const xn=new bk;ht.loadAddon(xn),ht.unicode.activeVersion=ys,ht.loadAddon(new _k({highlightLimit:1e3}));const Cn=new Nk;ht.loadAddon(Cn),ye.current=Cn,ht.loadAddon(new KL);try{ht.loadAddon(new Mk(void 0,new nv))}catch(Kr){Wt("clipboard addon skipped",{error:Kr})}B=ht,le.current=ht,se.current=It,xt.current=typeof window<"u"?window.devicePixelRatio:1,ht.open(Pe),Te.current=hI(ht),fn&&ht.loadAddon(new ZL({fontFeatureSettings:TI,fallbackLigatures:SI}));try{const Kr=ht._core;Kr?.coreService&&(Kr.coreService.isCursorInitialized=!0),ht.refresh(0,ht.rows-1)}catch{}pn?(oa(ht,"init"),la.current=!0):(Wt("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:G,mode:Wr}),la.current=!0),Ar(!1),bt();const Fn=Kr=>{if(Kr.ctrlKey||Kr.metaKey){Kr.preventDefault();const wn=Kr.deltaY>0?-1:1;ef(t,Be+wn)}};if(lt.current=Fn,Pe.addEventListener("wheel",Fn,{passive:!1}),!G){let Kr=0,wn=null,Ps=null,Os=null;const Ll=()=>{Os=null,ia.current();const ni=$c(le.current,Be,$r),qi=Ct.current+Kr;Kr=0;const Oo=Math.trunc(qi/ni);if(Ct.current=qi-Oo*ni,Oo!==0){const Mi=Oo>0?"down":"up",sl=le.current,hu=Math.max(3,Math.floor((sl?.rows??24)/2)),Yi=Math.abs(Oo);Yi>hu&&(Ct.current=0),tl.current(Mi,Math.min(Yi,hu),wn??void 0,Ps??void 0)}};ht.attachCustomWheelEventHandler(ni=>{if(ni.ctrlKey||ni.metaKey||ni.shiftKey)return!0;if(ni.deltaY===0)return!1;if(!le.current||!br.current)return!0;const Oo=$c(le.current,Be,$r);let Mi=ni.deltaY;return ni.deltaMode===1?Mi=ni.deltaY*Oo:ni.deltaMode===2&&(Mi=ni.deltaY*(Pe.clientHeight||Oo*20)),Kr+=Mi,wn=ni.clientX,Ps=ni.clientY,Os===null&&(Os=requestAnimationFrame(Ll)),ni.preventDefault(),!1})}const ms=mE(Pe);if(ms?(ms.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),qe.current=ms,At()):qe.current=null,Lt("mount",{skipResizePush:!0,skipScrollToBottom:!0}),Jr.current&&(G?ht.focus():jt.current?.focus({preventScroll:!0})),G||en.current(),q.push(ht.onRender(()=>{const Kr=ht.buffer.active;ct.current?.({x:Kr.cursorX,y:Kr.cursorY,rows:ht.rows}),G||en.current()})),!G){try{const Kr=ht.textarea;if(Kr){Kr.tabIndex=-1,Kr.setAttribute("aria-hidden","true"),Kr.setAttribute("readonly",""),Kr.value="";const wn=()=>{jt.current?.focus({preventScroll:!0})};Kr.addEventListener("focus",wn),q.push({dispose:()=>Kr.removeEventListener("focus",wn)})}}catch{}try{q.push(ht.onCursorMove(()=>en.current())),q.push(ht.onResize(()=>en.current()))}catch{}}q.push(ht.onData(Kr=>{const wn=Ut.current;wn!==null&&wn.depth>0||De.current(Kr)}));const Ri=Kr=>{const wn=typeof window<"u"?window.devicePixelRatio:1,Ps=Math.abs(wn-xt.current)>.001;return Ps&&(xt.current=wn,Wt("device pixel ratio changed",{value:wn,source:Kr})),Ps};if($=new ResizeObserver(Kr=>{if(!lI(!!jr.current,zn.current)){Wt("resize observer skipped: hidden mobile session");return}Xt.current=void 0;const wn=Kr[0];wn&&Wt("resize observer",{width:Math.round(wn.contentRect.width),height:Math.round(wn.contentRect.height)});const Ps=Ri("resize-observer");Lt(Ps?"dpr-change":"resize")}),$.observe(Pe),typeof window<"u"){const Kr=()=>{Ri("window-resize")&&Lt("dpr-change")};window.addEventListener("resize",Kr),q.push({dispose:()=>window.removeEventListener("resize",Kr)});const wn=window.visualViewport;if(wn){const Ps=()=>{Ri("visual-viewport-resize")&&Lt("dpr-change")};wn.addEventListener("resize",Ps),q.push({dispose:()=>wn.removeEventListener("resize",Ps)})}}ti("init-fit"),bn("ready"),Ne.current?.(!0)}catch(mt){console.error("Failed to initialize terminal:",mt),Ar(!1),bn("error"),Oe(mt instanceof Error?mt.message:"Failed to load terminal")}})(),()=>{Ne.current?.(!1),I=!0,Me.current?.(!1),nr.current?.(),nr.current=null,tr.current=!1,Qr.current!==null&&(clearTimeout(Qr.current),Qr.current=null),$e.current=!1,tn.current=null,yt(),Xr({active:!1,text:""});for(const mt of q)mt.dispose();$?.disconnect(),lt.current&&(Pe.removeEventListener("wheel",lt.current),lt.current=null),Te.current?.dispose(),Te.current=null,Ea("component-unmount"),B?.dispose(),le.current=null,se.current=null,qe.current=null,Ws({notifyFlowResume:!0}),Rs(),Vi()}):void 0},[ti,Y,Be,Qt,er,sr,$r,Ir,Zn,ys,is,Hn,fn,Bn,Xn,ee,Ws,yt,G,oa,Ea,Wt,Rs,Vi]),_.useEffect(()=>{const I=le.current;I&&(I.options.smoothScrollDuration=Xn&&!Re?125:0)},[Xn,Re,st]),_.useEffect(()=>{const I=le.current;I&&(I.options.cursorInactiveStyle=J?"bar":"none",J||I.blur())},[J,st]),_.useEffect(()=>{const I=le.current;if(I){if(pn){if(I.options.cursorBlink=!1,oa(I,"renderer-mode-change")&&Bn&&!Ht.current)try{I.loadAddon(new uL({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),Ht.current=!0}catch($){Wt("image addon skipped",{error:$})}return}I.options.cursorBlink=!0,Ea("renderer-mode-change")&&(Wi("renderer-mode-change:webgl-disabled"),ti("renderer-mode-change:webgl-disabled"))}},[pn,Bn,oa,Ea,Wi,ti,Wt]),_.useEffect(()=>{const I=le.current;I&&(We.current!==null&&I.reset(),Ws(),Ce.current="",St.current=0,jt.current&&(jt.current.value=""),Lt("session-reset",{skipScrollToBottom:!0}),Jr.current&&(jr.current?I.focus():jt.current?.focus({preventScroll:!0})))},[e,st,Lt,Ws]),_.useEffect(()=>{if(!G||typeof document>"u")return;let I=null;const B=()=>{I=null;const q=jt.current;if(!q||document.activeElement!==q||tr.current)return;const Pe=Ce.current,Le=Ed(q.value);if(Le!==Pe||Le.includes("\r")||!nt())return;const mt=Math.min(H2(q),Array.from(Le).length),ht=mt-St.current;if(ht===0)return;const It=le.current,yr=ht<0?(It?jh(It,"D"):"\x1B[D").repeat(-ht):(It?jh(It,"C"):"\x1B[C").repeat(ht);De.current(yr),St.current=mt},$=()=>{I===null&&(I=requestAnimationFrame(B))};return document.addEventListener("selectionchange",$),()=>{document.removeEventListener("selectionchange",$),I!==null&&cancelAnimationFrame(I)}},[G,nt]),_.useEffect(()=>{if(!G)return;const I=hi();return nr.current=I,()=>{I(),nr.current=null}},[G,hi]),_.useEffect(()=>{const I=le.current;if(I)try{I.options.scrollback=m?0:1e3}catch{}},[m,st]),_.useEffect(()=>{const I=le.current;if(!I)return;if(c.length===0){We.current!==null&&(I.reset(),Ws(),Lt("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const B=We.current;let $,q=!1;if(B===null)$=c;else{const Pe=c.findIndex(Le=>Le.id===B);Pe>=0?$=c.slice(Pe+1):($=c,q=!0)}if($.length>0){const Pe=$.map(xn=>xn.data).join(""),Le=Je.current+Pe,{cleaned:mt,remainder:ht}=pE(Le);Je.current=ht;const It=wt.current,yr=It!==null&&($[0].id<=It||q);mt?Lr(mt,$[$.length-1].id,yr):at.current?.($[$.length-1].id)}We.current=c[c.length-1].id},[c,st,Lr,Lt,Ws]),_.useImperativeHandle(Ze,()=>({serializeSnapshot:()=>le.current?ye.current?.serialize({scrollback:100})??null:null,focus:()=>{if(jr.current){_s();return}jt.current?.focus({preventScroll:!0})},blur:()=>{const I=jt.current;ws(I),I&&typeof document<"u"&&document.activeElement===I&&I.blur(),jr.current&&I?.setAttribute("readonly",""),Me.current?.(!1)},clear:()=>{const I=le.current;I&&(I.reset(),Ws(),Lt("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},prepareScreenReplacement:()=>{Ws({notifyFlowResume:!0})},copySelectionOrViewport:async()=>{const I=le.current;if(!I)return!1;const B=I.hasSelection()?I.getSelection():SE(I),$=await sf(B);return $&&I.hasSelection()&&lr(),$},pasteClipboardText:async()=>{Ie();const I=await ln(jt.current);return Li.current?.(I),I},sendSequence:(I,B)=>U(I,null,B),getDimensions:()=>{const I=le.current;return!I||!I.cols||!I.rows?null:{cols:I.cols,rows:I.rows}},requestRefresh:Lt,setSessionReady:I=>{Ii.current=I,I||(Te.current?.cancel(),Rs(),ts.current=xI(ts.current),ri.current=null,Qo.current=-1,ae.current?.(!1))},acknowledgeResize:I=>{if(!I.ok&&typeof I.seq=="number"){const Le=P2(ts.current,I.seq);if(!Le.request&&!Le.exhausted)return;Rs(),ts.current=Le.state,Le.request&&Ii.current?Ei.current(Le.request):Le.exhausted&&Te.current?.cancel();return}const B=mI(ts.current,I);if(!B.accepted)return;Rs(),ts.current=B.state,Wt("resize acknowledged",{seq:I.seq,ok:I.ok,cols:I.cols,rows:I.rows,screenSyncPending:I.screenSyncPending===!0,screenSyncGeneration:I.screenSyncGeneration});const $=le.current,q=B.state.confirmed;if(!!!($&&q&&$.cols===q.cols&&$.rows===q.rows)){ae.current?.(!1);return}if(I.screenSyncPending&&typeof I.screenSyncGeneration=="number"){ri.current=I.screenSyncGeneration;const Le=Qo.current>=I.screenSyncGeneration;ae.current?.(Le),Le&&(ri.current=null);return}ri.current=null,ae.current?.(!0)},notifyScreenSynchronized:I=>{if(!Number.isFinite(I))return;Qo.current=Math.max(Qo.current,I);const B=ri.current;if(B===null||I<B)return;ri.current=null;const $=le.current,q=ts.current.confirmed;ae.current?.(!!($&&q&&$.cols===q.cols&&$.rows===q.rows))},notifyServerSize:ce,ensureSizeMatches:Ge,requestPtyRedraw:()=>{const I=le.current;if(!I||!Ii.current||ts.current.pending||ri.current!==null)return;const B=pI(ts.current,{cols:I.cols,rows:I.rows});ts.current=B.state,Ei.current(B.request)}}),[G,ws,_s,Ws,ln,U,Lt,Rs,Wt,Ma,ce,Ge]),s.jsxs("div",{ref:ve,"data-termdock-terminal-dropzone":e,"data-termdock-terminal-owner":n?.()??e,className:`relative h-full w-full terminal-viewport-container ${Z||""}`,style:{backgroundColor:ee.background,touchAction:kn.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:Ca,onPointerMoveCapture:Kl,onPointerUpCapture:Wn,onPointerCancelCapture:os,onTouchStartCapture:I=>{if(di(I.target)){Ie(),As(Hd);return}Es(),As(Hd)},onTouchMoveCapture:()=>As(Hd),onTouchEndCapture:()=>As(Wd),onTouchCancelCapture:()=>As(Wd),onMouseDown:I=>{G||I.button===0&&(Bt.current!==null&&(window.clearTimeout(Bt.current),Bt.current=null),requestAnimationFrame(()=>{try{jt.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:I=>{G||I.button===0&&(Bt.current!==null&&window.clearTimeout(Bt.current),Bt.current=window.setTimeout(()=>{Bt.current=null;try{jt.current?.focus({preventScroll:!0})}catch{}},0))},children:[_t&&s.jsx("button",{type:"button",role:"alert",onClick:()=>gt(null),className:"absolute bottom-2 left-2 right-2 z-20 rounded-md border border-border bg-surface-2 px-3 py-2 text-left text-sm text-foreground",children:_t}),ne&&s.jsxs("button",{type:"button","data-terminal-copy-popover":"true",className:"absolute z-30 inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:ne.left,top:ne.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:I=>{Ie(),I.stopPropagation()},onPointerUp:I=>{I.preventDefault(),I.stopPropagation(),Ha()},onTouchStart:I=>{Ie(),I.stopPropagation()},onTouchEnd:I=>{I.preventDefault(),I.stopPropagation(),Ha()},onClick:I=>{I.preventDefault(),I.stopPropagation(),Ha()},children:[s.jsx(g8,{size:14,strokeWidth:2.4}),s.jsx("span",{children:V("common.copy")})]}),Zr?.start&&s.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:Zr.start.left,top:Zr.start.top,transform:"translate(-50%, -100%)",touchAction:"none"},onPointerDown:I=>I.stopPropagation(),children:s.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-1/2 flex -translate-x-1/2 flex-col items-center",children:[s.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"}),s.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"})]})}),Zr?.end&&s.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:Zr.end.left,top:Zr.end.top,transform:"translate(-50%, 0)",touchAction:"none"},onPointerDown:I=>I.stopPropagation(),children:s.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 flex -translate-x-1/2 flex-col items-center",children:[s.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"}),s.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"})]})}),Sn&&$t&&s.jsx(DI,{}),Sn&&Tn==="loading"&&!$t&&s.jsx(bv,{}),Tn==="error"&&s.jsx(BI,{message:nn||void 0,onRetry:()=>{window.location.reload()}}),Tn==="ready"&&s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:jt,onCopy:I=>{I.preventDefault(),ir(I.clipboardData)},"aria-label":V("terminal.input"),"data-terminal-input-anchor":"true",inputMode:"text",enterKeyHint:"enter",autoCapitalize:"off",autoComplete:"nope",autoCorrect:"off",spellCheck:!1,tabIndex:-1,style:{position:"absolute",opacity:0,zIndex:20,background:"transparent",color:"transparent",caretColor:"transparent",resize:"none",overflow:"hidden",border:"none",padding:0,margin:0,outline:"none",...G?{inset:0,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",pointerEvents:"auto",fontSize:"16px"}:(()=>{const I=Mr.x,B=Mr.y,$={position:"fixed",left:I,top:B,pointerEvents:"none",touchAction:"auto",fontSize:`${Be}px`,fontFamily:Y,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(Mr.cellW)),height:Math.max(1,Math.round(Mr.cellH))};if(!Ur.active)return $;const q=dr(Ur.text);return{...$,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:q.width,height:q.height,whiteSpace:q.whiteSpace}})()},onContextMenu:I=>{I.preventDefault()},onFocus:()=>{Wt("input anchor focus"),Xt.current=void 0,en.current(),Lt("focus",{skipResizePush:!0,skipScrollToBottom:!0}),Me.current?.(!0)},onBlur:I=>{G||ws(I.currentTarget);const B=Zl(),$=typeof document<"u"?document.activeElement:null;if(Wt("input anchor blur",{guarded:B,activeTag:$?.tagName??null,activeClass:$?.className??null}),!B){G&&jt.current?.setAttribute("readonly",""),Me.current?.(!1);return}if(typeof window>"u"){Me.current?.(!1);return}window.setTimeout(()=>{rt()||nt()||(G&&jt.current?.setAttribute("readonly",""),Me.current?.(!1))},Wd)},onBeforeInput:I=>{if(tr.current)return;const B=I.nativeEvent;if(B instanceof InputEvent){if(B.inputType==="insertFromPaste"||B.inputType==="insertFromPasteAsQuotation"){const $=B.dataTransfer?.getData("text/plain")||B.data;if($){I.preventDefault();const q=X($,I.currentTarget);G&&Li.current?.(q)}return}if(B.inputType==="insertLineBreak"){if($e.current){$e.current=!1,Qr.current!==null&&(clearTimeout(Qr.current),Qr.current=null),I.preventDefault();return}I.preventDefault(),R(I.currentTarget);return}if(B.inputType==="deleteContentBackward"||B.inputType==="deleteContentForward"||B.inputType==="deleteByCut"){if(!I.currentTarget.value){I.preventDefault(),De.current("");return}if(B.inputType==="deleteContentBackward"&&I.currentTarget.selectionStart===0&&I.currentTarget.selectionEnd===0){I.preventDefault(),De.current("");return}return}}},onInput:I=>{if(tr.current)return;const B=I.nativeEvent,$=MC(Ce.current,Ed(I.currentTarget.value),B.inputType);if($){const q=X($,I.currentTarget);G&&Li.current?.(q);return}ue(I.currentTarget)},onPaste:I=>{const B=I.clipboardData.files.length?Array.from(I.clipboardData.files):Array.from(I.clipboardData.items).filter(Le=>Le.kind==="file").map(Le=>Le.getAsFile()).filter(Le=>Le!==null),$=I.clipboardData.getData("text/plain");if(window.termdockDesktop?.readClipboardFiles){I.preventDefault(),ln(I.currentTarget,{files:B,text:$});return}if(B.length&&(B.length>1||!B[0].type.startsWith("image/"))){I.preventDefault(),kr(B,I.currentTarget);return}const q=B[0];if(q){I.preventDefault(),Et(q,I.currentTarget);return}if(!$){(window.termdockDesktop||typeof navigator.clipboard?.read=="function")&&(I.preventDefault(),ln(I.currentTarget));return}I.preventDefault();const Pe=X($,I.currentTarget);G&&Li.current?.(Pe)},onKeyDown:I=>{const B=hE(I);if(!B&&!tr.current){if(I.getModifierState("AltGraph"))return;const $=le.current,q=I.metaKey,Pe=I.ctrlKey,Le=I.altKey,mt=I.shiftKey,ht=I.key;if(q&&!Pe&&!Le&&!mt&&ht==="Enter"){I.preventDefault(),R(I.currentTarget);return}if((q||Pe)&&!Le&&!mt&&(ht==="v"||ht==="V"))return;if(q&&!Pe&&!Le&&!mt&&(ht==="c"||ht==="C")){I.preventDefault(),ir();return}if((q||Pe)&&!Le&&!mt&&(ht==="k"||ht==="K")){I.preventDefault(),$&&($.reset(),Ws(),Lt("clear",{skipResizePush:!0,skipScrollToBottom:!0})),I.currentTarget.value="",Ce.current="",St.current=0;return}if(q&&!Pe&&!Le&&!mt&&ht==="Backspace"){I.preventDefault(),U("",I.currentTarget);return}if(q&&!Pe&&!Le&&!mt&&ht==="Delete"){I.preventDefault(),U("\v",I.currentTarget);return}if(q&&!Pe&&!Le&&!mt&&ht==="ArrowLeft"){I.preventDefault(),U("",I.currentTarget);return}if(q&&!Pe&&!Le&&!mt&&ht==="ArrowRight"){I.preventDefault(),U("",I.currentTarget);return}if(q)return;if(Le&&!Pe&&!q&&!mt&&ht==="Backspace"){I.preventDefault(),U("\x1B",I.currentTarget);return}if(Le&&!Pe&&!q&&!mt&&ht==="Delete"){I.preventDefault(),U("\x1Bd",I.currentTarget);return}if(Le&&!Pe&&!q&&!mt&&ht==="ArrowLeft"){I.preventDefault(),U("\x1Bb",I.currentTarget);return}if(Le&&!Pe&&!q&&!mt&&ht==="ArrowRight"){I.preventDefault(),U("\x1Bf",I.currentTarget);return}const It=e_(I,$?.modes?.applicationCursorKeysMode===!0);if(It!==null){I.preventDefault(),U(It,I.currentTarget);return}}if(I.key==="Enter"||I.key==="Go"||I.key==="done"||I.key==="send"){if(B||tr.current){I.preventDefault();return}if($e.current){$e.current=!1,Qr.current!==null&&(clearTimeout(Qr.current),Qr.current=null),I.preventDefault();return}I.preventDefault(),R(I.currentTarget);return}if(I.key==="Backspace"){if(B||tr.current)return;if(!I.currentTarget.value){I.preventDefault(),De.current("");return}if(I.currentTarget.selectionStart===0&&I.currentTarget.selectionEnd===0){I.preventDefault(),De.current("");return}}},onCompositionStart:()=>{tr.current=!0,pr(),Xr({active:!0,text:""})},onCompositionUpdate:I=>{tr.current=!0;const B=I.data??I.currentTarget.value;Xr($=>$.active&&$.text===B?$:{active:!0,text:B})},onCompositionEnd:I=>{tr.current=!1,$e.current=!0,Qr.current!==null&&clearTimeout(Qr.current),Qr.current=setTimeout(()=>{$e.current=!1,Qr.current=null},50),Xr({active:!1,text:""}),ue(I.currentTarget),fs()}}),Ur.active&&(()=>{const I=dr(Ur.text);return s.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:Mr.x,top:Mr.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:I.width,height:I.height,margin:0,padding:0,color:ee.foreground,background:ee.background,boxShadow:`-1px 0 0 1px ${ee.background}`,fontSize:`${Be}px`,fontFamily:Y,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:ee.foreground,wordBreak:"break-all",whiteSpace:I.whiteSpace,transition:"none"},children:Ur.text})})(),s.jsx("div",{"aria-hidden":!0,className:`absolute left-1/2 -translate-x-1/2 top-6 z-30 pointer-events-none
72
+ rounded-full bg-[var(--surface-elevated)] px-4 py-1.5 text-sm font-semibold text-foreground
73
+ shadow-lg transition-all duration-150 ease-out`,style:{opacity:vn?1:0,transform:vn?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),s.jsx("div",{ref:vr,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:kn.visible?1:0,transform:kn.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:kn.visible&&(()=>{const{activeDir:I}=kn,B=$=>I===$;return s.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${B("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${B("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${B("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${B("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});vv.displayName="TerminalViewport";const _E=vv,kE=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},LE=()=>({async createSession(e){return A8(e)},connect(e,t,r){const n=w8(e,t.onEvent,t.onError,{...kE(r),getDimensions:r?.getDimensions});return{close:()=>n()}},async sendInput(e,t){await Wy(e,t)},async resize(e){await v8(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await Hy(e)},async restartSession(e,t){return y8(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await b8(e)},async tmuxAction(e,t){return zy(e,t)},async listTmuxSessions(){return s1()},async getTmuxStatus(){return n1()},async checkHealth(e){return x8(e)}}),IE="\x1B",EE=/\x1b\[[IO]/g,NE=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,RE=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function t5(e,t,r){return e.lastIndex=r,e.exec(t)?e.lastIndex:-1}function ME(e){const t=e.replace(EE,"");if(t.length===0)return e.length>0;let r=0;for(;r<t.length;){let n=t5(NE,t,r);if(n<0&&(n=t5(RE,t,r)),n<0&&t.startsWith("\x1B[M",r)&&t.length>=r+6&&(n=r+6),n<0)return!1;r=n}return!0}function jE(e){return e===IE}function k1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const p0=18;function DE(){return wv.map(e=>e.id)}const wv=[{id:"default",label:"Base",programs:[],includeAlt:!0,rowLayout:[3,3,3],actions:[],showOnDesktop:!1},{id:"opencode",label:"Code",programs:["opencode"],includeAlt:!1,rowLayout:[6],actions:[{id:"opencode-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo||\r"},{id:"opencode-new",label:"/new",sequence:"/new",doubleTapSequence:"/new||\r"},{id:"opencode-models",label:"/models",sequence:"/models",doubleTapSequence:"/models||\r"},{id:"opencode-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact||\r"}],showOnDesktop:!0},{id:"claude",label:"Claude",programs:["claude","claude-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"claude-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"claude-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"claude-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"}],showOnDesktop:!0},{id:"kimi",label:"Kimi",programs:["kimi","kimi-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"kimi-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"kimi-new",label:"/new",sequence:"/new",doubleTapSequence:"/new\r"},{id:"kimi-sessions",label:"/sessions",sequence:"/sessions",doubleTapSequence:"/sessions\r"},{id:"kimi-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"kimi-goal",label:"/goal",sequence:"/goal",doubleTapSequence:"/goal\r"}],showOnDesktop:!0},{id:"codex",label:"Codex",programs:["codex"],includeAlt:!1,rowLayout:[6],actions:[{id:"codex-shift-left",label:"⇧←",sequence:"\x1B[1;2D"},{id:"codex-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"codex-model",label:"/model",sequence:"/model",doubleTapSequence:"/model\r"},{id:"codex-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"codex-resume",label:"/resume",sequence:"/resume",doubleTapSequence:"/resume\r"}],showOnDesktop:!0},{id:"coco",label:"Coco",programs:["coco"],includeAlt:!1,rowLayout:[6],actions:[{id:"coco-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"coco-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"coco-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"coco-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0},{id:"traex",label:"TraeX",programs:["traex","traecli"],includeAlt:!1,rowLayout:[6],actions:[{id:"traex-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"traex-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"traex-compact",label:"/compact",sequence:"/||compact ",doubleTapSequence:"/||compact ||\r"},{id:"traex-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"traex-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0}];function D0(){return wv.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function Ag(e){const t=Array.isArray(e)?e.map(r=>Math.min(20,Math.max(2,Math.floor(r)))).filter(r=>Number.isFinite(r)):[];return t.length>0?t:[3,3]}function Av(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const Tg=/^\/(.+)\/([gimsuy]*)$/;function r5(e){return Tg.test(e.trim())}function Qf(e){const t=e.trim().match(Tg);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function Tv(e){if(typeof e!="string")return null;const t=e.trim();return t?Tg.test(t)?Qf(t)?t:null:t.toLowerCase():null}function n5(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16))).replace(/\\r/g,"\r").replace(/\\n/g,`
74
+ `).replace(/\\t/g," ")}const s5="||",BE=120;function QE(e){return e.includes(s5)?e.split(s5).filter(t=>t.length>0):[e]}function Vu(e){const t=new Set,r=e.map((a,c)=>{const l=typeof a.id=="string"&&a.id.trim().length>0?a.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):`preset-${c+1}`,d=t.has(l)?`${l}-${c+1}`:l;return t.add(d),{id:d,label:typeof a.label=="string"&&a.label.trim().length>0?a.label.trim():"Preset",programs:Array.isArray(a.programs)?a.programs.map(f=>Tv(f)).filter(f=>!!f):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:Ag(a.rowLayout),showOnDesktop:typeof a.showOnDesktop=="boolean"?!!a.showOnDesktop:!1,actions:Array.isArray(a.actions)?a.actions.map((f,m)=>{const x={id:typeof f.id=="string"&&f.id.trim().length>0?f.id:`${d}-action-${m+1}`,label:typeof f.label=="string"?f.label:`Key ${m+1}`,sequence:typeof f.sequence=="string"?f.sequence:""};return typeof f.doubleTapSequence=="string"&&(x.doubleTapSequence=f.doubleTapSequence),x}):[]}}).filter(a=>a.id!=="auto"),n=D0()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function PE(e,t){const r=Av(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const c=Qf(a);if(c){if(c.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function i5(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??D0()[0]}function OE(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function FE(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function Sv(e,t){const r=Ag(t),n=[];let a=0,c=0;for(;a<e.length;){const l=r[Math.min(c,r.length-1)]??3;n.push({columns:l,items:e.slice(a,a+l)}),a+=l,c+=1}return n}const Cv=28,_v=({mode:e,presetLabel:t,title:r,ariaLabel:n,disabled:a,onPointerDown:c,buttonRef:l})=>s.jsx("button",{ref:l,type:"button",onPointerDown:c,tabIndex:-1,disabled:a,className:"h-7 w-7 rounded-full bg-surface-2 shadow-sm text-[11px] font-medium active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",title:r,"aria-label":n??r,children:e==="auto"?s.jsx(nC,{size:14}):(t.charAt(0)||"?").toUpperCase()}),$E={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Vd=8;function UE(e,t){return $E[e]??null}const zE=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:a,disabled:c,defaultShowExtended:l=!1,presetLabel:d,presetModeLabel:f,presetMode:m,presetOptions:x,includeAlt:y,presetRowLayout:w,extraActions:v,onKeyPress:T,onTextPress:C,onPastePress:L,onFilePress:N,onFileLongPress:D,fileUploadState:O="idle",fileUploadProgress:P=0,longPressMode:F="arrows",copyFeedback:ee="idle",onLongPressModeToggle:Z,onModifierToggle:G,onPresetSelect:de,onExpandedChange:pe})=>{const{t:J}=Gr(),[Re,Ze]=_.useState(l),[V,ve]=_.useState(!1),qe=_.useRef(null),le=r==="desktop-actions",ye=le||Re,[Te,Fe]=_.useState(!1),[se,De]=_.useState(null),_e=c||!e||!t,Me=c||!e,Ke=_.useRef(null),Ne=_.useRef(null),ae=_.useRef(null),ze=_.useRef(null),at=_.useRef(null),ct=_.useRef(ee),me=_.useRef(null),ut=_.useRef(0),ft=_.useRef(null),Se=_.useRef(!1),He=_.useCallback(Ce=>{if(_e)return;const St=Ce.target;if(!(St instanceof Element))return;const Ot=St.closest("button"),Jt=Ot?.hasAttribute("data-mobile-native-action")===!0;Ot&&!Jt?(Ce.preventDefault(),ko(Vd)):Ot&&ko(Vd)},[_e]),ke=_.useCallback(Ce=>{Ce.preventDefault()},[]),z=_.useCallback(Ce=>{const St=Ce.target;_e||St instanceof HTMLElement&&St.closest("button")&&St.blur()},[_e]);_.useEffect(()=>{Ze(l)},[l]),_.useEffect(()=>{le||pe?.(Re)},[le,pe,Re]),_.useEffect(()=>{_e&&(me.current!==null&&(window.clearTimeout(me.current.timer),me.current=null),Fe(!1),De(null))},[_e]),_.useEffect(()=>{e||(Fe(!1),De(null))},[e]),_.useEffect(()=>{if(!Te)return;const Ce=()=>{const St=Ke.current?.getBoundingClientRect();St&&De({left:Math.max(8,St.left),top:Math.max(8,St.top-8)})};return Ce(),window.addEventListener("resize",Ce),window.addEventListener("scroll",Ce,!0),()=>{window.removeEventListener("resize",Ce),window.removeEventListener("scroll",Ce,!0)}},[Te]),_.useEffect(()=>{const Ce=ct.current;if(ct.current=ee,ee==="idle"||ee===Ce)return;if(at.current!==null&&window.clearTimeout(at.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(ee==="copied"){Ne.current?.animate?.([{transform:"scale(1)"},{transform:"scale(1.16)",offset:.28},{transform:"scale(0.96)",offset:.62},{transform:"scale(1)"}],{duration:720,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});const Ot=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];ae.current?.animate?.(Ot,{duration:760,easing:"ease-out"}),ze.current?.animate?.(Ot,{duration:760,delay:130,easing:"ease-out"})}else Ne.current?.animate?.([{transform:"translateX(0)"},{transform:"translateX(-2px)"},{transform:"translateX(2px)"},{transform:"translateX(0)"}],{duration:280,easing:"ease-out"});ko(Vd),ee==="copied"&&(at.current=window.setTimeout(()=>{ko(Vd),at.current=null},90),F==="copy"&&Z?.())},[ee,F,Z]),_.useEffect(()=>()=>{at.current!==null&&window.clearTimeout(at.current)},[]);const ie=_.useCallback((Ce,St)=>{_e||(Ce.preventDefault(),T(St))},[T,_e]),ge=_.useCallback((Ce,St)=>{_e||(Ce.preventDefault(),G(St))},[G,_e]),We=_.useCallback(Ce=>{_e||(Ce.preventDefault(),Ze(St=>{const Ot=!St;return Ot&&(ve(!0),qe.current!==null&&window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{ve(!1),qe.current=null},350)),Ot}))},[_e]),tt=_.useCallback(()=>{const Ce=typeof performance<"u"?performance.now():Date.now();Ce-ut.current<350||(ut.current=Ce,L?.())},[L]),wt=_.useCallback(Ce=>{_e||(Ce.stopPropagation(),Ce.pointerType!=="touch"&&(Ce.preventDefault(),tt()))},[_e,tt]),Zt=_.useCallback(Ce=>{_e||(Ce.preventDefault(),Ce.stopPropagation(),tt())},[_e,tt]),Ut=_.useCallback(Ce=>{_e||O==="uploading"||!N||(Ce.preventDefault(),Ce.stopPropagation(),Se.current||N(),Se.current=!1)},[O,N,_e]),Mt=_.useCallback(()=>{ft.current!==null&&window.clearTimeout(ft.current),ft.current=null},[]),nr=_.useCallback(Ce=>{Ce.stopPropagation(),!(_e||O==="uploading"||!D)&&(Se.current=!1,ft.current=window.setTimeout(()=>{ft.current=null,Se.current=!0,ko(Vd),D()},500))},[O,D,_e]);_.useEffect(()=>()=>Mt(),[Mt]);const jt=_.useCallback(Ce=>{_e||Ce.stopPropagation()},[_e]),Xt=250,Bt=_.useCallback(()=>{me.current!==null&&(window.clearTimeout(me.current.timer),me.current=null)},[]);_.useEffect(()=>()=>{Bt(),qe.current!==null&&(window.clearTimeout(qe.current),qe.current=null)},[Bt]);const Ht=_.useCallback((Ce,St)=>{if(_e)return;if(Ce.preventDefault(),!St.doubleTapSequence){C(St.sequence);return}const Ot=me.current;if(Ot!==null&&Ot.actionId===St.id){window.clearTimeout(Ot.timer),me.current=null,C(St.doubleTapSequence);return}Bt();const Jt=window.setTimeout(()=>{me.current=null,C(St.sequence)},Xt);me.current={actionId:St.id,timer:Jt}},[Bt,C,_e]),xe=_.useCallback(Ce=>{_e||(Ce.preventDefault(),Ce.stopPropagation(),Z?.())},[Z,_e]),Je=_.useCallback(Ce=>{_e||Ce.stopPropagation()},[_e]),ot=_.useCallback(Ce=>{if(_e)return;Ce.preventDefault();const St=Ce.currentTarget.getBoundingClientRect();De({left:Math.max(8,St.left),top:Math.max(8,St.top-8)}),Fe(Ot=>!Ot)},[_e]),Nt=_.useCallback((Ce,St)=>{_e||(Ce.preventDefault(),Fe(!1),De(null),de(St))},[de,_e]),K=v.length>0,xt=_.useMemo(()=>{const Ce=[{id:"preset",kind:"preset"}];if(!le&&y&&Ce.push({id:"alt",kind:"alt"}),K){const St=v.map(Ot=>({id:Ot.id,kind:"text",action:Ot}));return Ce.concat(St)}return le?Ce.concat([{id:"esc",kind:"key",keyName:"esc"},{id:"ctrl-c",kind:"key",keyName:"ctrl-c"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"},{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"}]):Ce.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,K,y,le]),tr=_.useMemo(()=>Sv(xt,le&&!K?[6]:w),[xt,K,le,w]),$e=`${le?"space-y-1":"mt-1 space-y-1"}${V?" pointer-events-none":""}`,Qr=Te&&se?ci.createPortal(s.jsx("div",{className:"fixed z-popover min-w-28 -translate-y-full rounded-2xl bg-surface-elevated p-1.5 shadow-xl border border-border/15",style:{left:se.left,top:se.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(Ce=>s.jsx("button",{type:"button",onPointerDown:St=>Nt(St,Ce.id),tabIndex:-1,disabled:Me,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${Ce.id===m?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:Ce.label},Ce.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[Qr,s.jsx("div",{"data-mobile-keyboard":"true",className:`z-chrome select-none overflow-hidden app-chrome-bg transition-all duration-150 ease-out px-1 py-0 ${e?le?"max-h-24":"max-h-40":"max-h-0"} ${e?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"} ${t?"":"[&_button]:pointer-events-none"}`,onMouseDownCapture:He,onPointerDownCapture:He,onContextMenuCapture:ke,onFocusCapture:z,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!le&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:Ce=>ie(Ce,"esc"),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"Esc"}),s.jsx("button",{type:"button",onPointerDown:Ce=>ge(Ce,"ctrl"),tabIndex:-1,disabled:Me,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="ctrl"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="ctrl"?"Ctrl*":"Ctrl"})}),s.jsx("button",{type:"button",onPointerDown:Ce=>ie(Ce,"ctrl-c"),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-C"}),s.jsx("button",{type:"button",onPointerDown:Ce=>ie(Ce,"ctrl-u"),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-U"}),s.jsxs("button",{type:"button",onPointerDown:nr,onPointerUp:Mt,onPointerCancel:Mt,onClick:Ut,tabIndex:-1,disabled:Me||!N||O==="uploading",title:O==="uploading"?`${J("rightSidebar.uploading")} ${Math.round(P)}%`:J(O==="inserted"?"rightSidebar.inserted":O==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":J("rightSidebar.insertLocalFile"),className:`relative h-7 w-full overflow-hidden rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${O==="inserted"?"bg-primary/15 text-primary":O==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[O==="uploading"&&s.jsx("span",{"aria-hidden":"true","data-file-upload-progress":"true",className:"absolute inset-y-0 left-0 bg-primary/25 transition-[width] duration-150 ease-out",style:{width:`${Math.max(0,Math.min(100,P))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:O==="uploading"?s.jsx(Rn,{size:15,className:"animate-spin"}):O==="inserted"?s.jsx(Ci,{size:15}):O==="failed"?s.jsx(Dn,{size:15}):s.jsx(kT,{size:15})}),O!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:O==="uploading"?`${J("rightSidebar.uploading")} ${Math.round(P)}%`:J(O==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),s.jsx("button",{type:"button",onPointerDown:()=>C("/"),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"/"}),s.jsx("button",{type:"button",onPointerDown:Ce=>ie(Ce,"enter"),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(wT,{size:16})}),s.jsxs("button",{ref:Ne,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Je,onTouchStart:Je,onClick:xe,tabIndex:-1,disabled:Me,title:J(ee==="copied"?"terminal.copied":ee==="failed"?"terminal.copyFailed":F==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":J(F==="copy"?"terminal.switchLongPressToArrows":"terminal.switchLongPressToCopy"),className:`relative isolate h-7 w-full overflow-visible rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-colors keyboard-button-active disabled:opacity-50 flex items-center justify-center ${ee==="copied"?"bg-primary/15 text-primary":ee==="failed"?"bg-destructive/15 text-destructive":F==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:ae,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:ze,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/40 opacity-0"}),s.jsxs("span",{className:"relative z-10 h-4 w-4","aria-hidden":"true",children:[s.jsx(Ci,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${ee==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),s.jsx(Dn,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${ee==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(a3,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${ee==="idle"&&F==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(rS,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${ee==="idle"&&F==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),ee!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:ee==="copied"?`${J("terminal.copied")} · ${J("terminal.longPressSendsArrows")}`:`${J("terminal.copyFailed")} · ${J("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:wt,onPointerUp:jt,onTouchStart:jt,onTouchEnd:jt,onClick:Zt,tabIndex:-1,disabled:Me,title:J("terminal.paste"),"aria-label":J("terminal.paste"),className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(hT,{size:15})}),s.jsx("button",{type:"button",onPointerDown:We,tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:Re?s.jsx(T8,{size:16}):s.jsx(Cl,{size:16})})]}),ye&&s.jsx("div",{className:$e,children:tr.map((Ce,St)=>{const Ot=Ce.items[0]?.kind==="preset",Jt=Math.max(2,Ce.columns),lt=Ot?`${Cv}px repeat(${Math.max(1,Jt-1)}, minmax(0, 1fr))`:`repeat(${Jt}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:lt},children:Ce.items.map(Ct=>Ct.kind==="preset"?s.jsx(_v,{buttonRef:Ct.id==="preset"?Ke:void 0,mode:m,presetLabel:d,title:f,disabled:Me,onPointerDown:ot},Ct.id):Ct.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:ar=>ge(ar,"alt"),tabIndex:-1,disabled:Me,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="alt"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="alt"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="alt"?"Alt*":"Alt"})},Ct.id):Ct.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:ar=>Ht(ar,Ct.action),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm px-1 text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 relative",children:[Ct.action.label,Ct.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},Ct.id):s.jsx("button",{type:"button",onPointerDown:ar=>ie(ar,Ct.keyName),tabIndex:-1,disabled:Me,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:Ct.keyName==="esc"?"Esc":Ct.keyName==="ctrl-c"?"Ctrl-C":Ct.keyName==="ctrl-d"?"Ctrl-D":Ct.keyName==="home"?"Home":"End"},Ct.id))},`row-${St}`)})})]})})]})},HE=({isMobile:e,isInputFocused:t,isIOS:r,isConnecting:n,connectionError:a,terminalSessionId:c})=>{if(typeof window>"u")return null;const l=window.visualViewport?Math.max(0,Math.round(window.innerHeight-window.visualViewport.height-window.visualViewport.offsetTop)):0;return s.jsxs("div",{className:"px-3 py-2 bg-surface text-foreground text-xs border-b border-border/15",children:[s.jsx("div",{className:"font-bold mb-2",children:"Debug Info"}),s.jsxs("div",{className:"grid grid-cols-2 gap-1 font-mono",children:[s.jsxs("div",{children:["isMobile: ",s.jsx("span",{className:e?"text-accent":"text-destructive",children:String(e)})]}),s.jsxs("div",{children:["touchPoints: ",navigator.maxTouchPoints]}),s.jsxs("div",{children:["innerWidth: ",window.innerWidth]}),s.jsxs("div",{children:["innerHeight: ",window.innerHeight]}),s.jsxs("div",{children:["viewportH:"," ",window.visualViewport?Math.round(window.visualViewport.height):"N/A"]}),s.jsxs("div",{children:["inputFocused: ",String(t)]}),s.jsxs("div",{children:["keyboard~: ",l,"px"]}),s.jsxs("div",{children:["connecting:"," ",s.jsx("span",{className:n?"text-muted-foreground":"text-accent",children:String(n)})]}),s.jsxs("div",{children:["sessionId:"," ",s.jsx("span",{className:c?"text-accent":"text-destructive",children:c?"✓":"✗"})]}),s.jsxs("div",{children:["error:"," ",s.jsx("span",{className:a?"text-destructive":"text-accent",children:a?"Yes":"No"})]}),s.jsxs("div",{children:["isIOS:"," ",s.jsx("span",{className:r?"text-muted-foreground":"text-accent",children:String(r)})]})]}),s.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:s.jsx("div",{children:"Tip: Tap the status bar 3 times to toggle debug panel"})})]})},WE=/^Reconnecting/i,GE=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:c}=Gr(),l=!!e&&WE.test(e),d=!!(n&&!e||l),[f,m]=_.useState(!1);return _.useEffect(()=>{if(!d){m(!1);return}const x=setTimeout(()=>m(!0),1500);return()=>clearTimeout(x)},[d]),d?f?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:s.jsx(_0,{dots:!0,label:c("connection.reconnecting"),className:"rounded-full bg-surface-2 px-3 py-1 text-[11px]"})}):null:e?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2",children:s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-destructive/70",children:[s.jsx("span",{children:e}),t&&s.jsx("button",{type:"button",onClick:a,disabled:r,className:"text-[11px] text-destructive/90 hover:text-destructive underline underline-offset-2 transition-colors disabled:opacity-40",children:c("common.retry")})]})}):null},VE=120,qE=80,YE=400;function a5(){if(typeof window>"u"||document.visibilityState!=="visible"||!S8())return 0;const e=Number.parseFloat(document.documentElement.style.getPropertyValue("--kb-height")||"0");if(Number.isFinite(e)&&e>0)return Math.round(e);const t=bl().visualViewport;if(!t)return 0;const r=Number.parseFloat(document.documentElement.style.getPropertyValue("--app-base-vh")||"0")||window.innerHeight,n=Number.parseFloat(document.documentElement.style.getPropertyValue("--safe-bottom-inset")||"0")||0,a=t.height+t.offsetTop;return Math.max(0,Math.round(r-a-n))}function kv(e){const{enabled:t,openThresholdPx:r=VE,closeThresholdPx:n=qE,settleDelayMs:a=YE}=e,c=_.useMemo(()=>rd("keyboard"),[]),l=_.useRef(!1),d=_.useRef(null),f=_.useRef(0),[m,x]=_.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return _.useEffect(()=>{if(typeof window>"u"||!t){l.current=!1,d.current!==null&&(clearTimeout(d.current),d.current=null),x(ee=>!ee.isOpen&&!ee.isSettled&&ee.keyboardHeight===0?ee:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let y=null;const w=()=>{y=null;const ee=a5();let Z=l.current;if(ee>=r?Z=!0:ee<=n&&(Z=!1),l.current=Z,Z){const G=Math.abs(ee-f.current);f.current=ee,G>10&&(d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,x(de=>de.isSettled?de:{...de,isSettled:!0})},a))}else d.current!==null&&(clearTimeout(d.current),d.current=null);x(G=>{const de=Z?G.isSettled:!1;return G.isOpen===Z&&G.keyboardHeight===ee&&G.isSettled===de?G:(c("sync",{keyboardHeight:ee,isOpen:Z,isSettled:de,visualViewport:bl().visualViewport?{width:Math.round(bl().visualViewport.width),height:Math.round(bl().visualViewport.height),offsetTop:Math.round(bl().visualViewport.offsetTop)}:null}),{isOpen:Z,isSettled:de,keyboardHeight:ee})})},v=(ee="event")=>{(ee.includes("visibilitychange")||ee.includes("pageshow"))&&c("schedule",{source:ee}),y===null&&(y=window.requestAnimationFrame(w))};v("mount");const T=()=>v("resize"),C=()=>v("orientationchange"),L=()=>v("visualViewport.resize"),N=()=>v("visualViewport.scroll"),D=()=>v("viewport-keyboard-change");window.addEventListener("resize",T),window.addEventListener("orientationchange",C),bl().visualViewport?.addEventListener("resize",L),bl().visualViewport?.addEventListener("scroll",N),document.addEventListener("termdock:viewport-keyboard-change",D);const O=ee=>{c("resume",{source:ee,keyboardHeight:a5(),hidden:document.hidden}),v(`${ee}:now`),window.setTimeout(()=>v(`${ee}:50ms`),50),window.setTimeout(()=>v(`${ee}:200ms`),200)},P=()=>{document.hidden||O("visibilitychange")},F=()=>O("pageshow");return document.addEventListener("visibilitychange",P),window.addEventListener("pageshow",F),()=>{window.removeEventListener("resize",T),window.removeEventListener("orientationchange",C),bl().visualViewport?.removeEventListener("resize",L),bl().visualViewport?.removeEventListener("scroll",N),document.removeEventListener("termdock:viewport-keyboard-change",D),document.removeEventListener("visibilitychange",P),window.removeEventListener("pageshow",F),y!==null&&window.cancelAnimationFrame(y),d.current!==null&&(clearTimeout(d.current),d.current=null)}},[c,t,r,n,a]),m}const ff=300,ZE=120,KE=2e3,XE=250,JE=6e4;function eN(e){const t=new Set(e.slides.flat()),r=new Set([...e.visibleSessionIds].filter(l=>t.has(l)));e.foregroundSessionId&&t.has(e.foregroundSessionId)&&r.add(e.foregroundSessionId);const n=e.slides.findIndex(l=>l.some(d=>r.has(d)));if(n<0)return r;const a=e.slides[n-1]??[],c=e.slides[n+1]??[];for(let l=0;l<Math.max(a.length,c.length)&&r.size<3;l+=1)for(const d of[a[l],c[l]])d&&r.size<3&&r.add(d);return r}function ym(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function Dh(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function tN(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function rN(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function nN(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function sN(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function iN(e){return!e.initialConnectionPending}function aN(e){return!e}function oN(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function lN(e,t){return[...e].every(r=>t.has(r))}function cN(e,t){return e===null||t-e>=XE}function uN(e){return!1}function dN(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,JE-(e.now-e.reconnectStartedAt))}function hN(e,t){const r=new Map;let n=0;for(const a of e)if(!r.has(a)){if(t.has(a)){r.set(a,0);continue}r.set(a,ff+n*ZE),n+=1}return r}const fN="Session not found on server",pf="Terminal session not found",pN="STALE_SESSION_RESTORE_REJECTED";function o5(e){return L1(e)?!1:e?.message===fN||e?.status===404&&e.message===pf}function L1(e){return e?.code===pN}function mN(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function Lv(e,t){return mN(e,t).replace(/ /g,"\\ ")}function I1(e,t){return`${Lv(e,t)} `}function l5(e,t){return Lv(e,t)}function nz(e,t,r){if(!r)return l5(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${l5(e,t)}:${n}`}const gN="/tmp";async function xN(e,t,r){const a=(await t(gN,[e])).files[0];if(!a?.path)throw new Error("Upload did not return a file path");let c;try{c=await r(a.path)}catch{throw new Pf(a)}if(!c)throw new Pf(a);return a}class Pf extends Error{constructor(t){super("File uploaded, but its reference was not accepted"),this.uploaded=t,this.name="UploadedReferenceRejectedError"}uploaded}function c5(e,t,r,n,a){if(!e||!t||!r())return Promise.resolve(!1);const c=n?jC(n,t,e):null;if(n&&!c)return Promise.resolve(!1);const l=c?.nonce??`reference-${crypto.randomUUID()}`;return new Promise(d=>{let f=!1;const m=w=>{f||(f=!0,window.clearTimeout(y),window.removeEventListener("termdock-insert-reference-ack",x),c&&DC(l),d(w&&r()))},x=w=>{const v=w.detail;v?.nonce===l&&m(v.ok===!0)},y=window.setTimeout(()=>m(!1),1500);window.addEventListener("termdock-insert-reference-ack",x),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:c??{text:e,sessionId:t,nonce:l,focus:!1,paste:!0,submitAfterPaste:!1,...a}}))})}const Iv=[640,960,1280,1600,2048,2560,3072,4096],Ev=[240,360,480,540,720,1080,1440,2160],A0={min:.1,max:1,step:.01},T0={min:25e4,max:2e7,step:25e4},Sg="termdock:mobile-media-compression-v1",Ru={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function Nv(){try{const e=JSON.parse(localStorage.getItem(Sg)||"null");return!e||typeof e!="object"?Ru:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:Iv.includes(e.imageMaxDimension)?e.imageMaxDimension:Ru.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=A0.min&&e.imageQuality<=A0.max?e.imageQuality:Ru.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:Ev.includes(e.videoMaxHeight)?e.videoMaxHeight:Ru.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=T0.min&&e.videoBitrate<=T0.max?e.videoBitrate:Ru.videoBitrate}}catch{return Ru}}const Cg=Sc((e,t)=>({preferences:Nv(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(Sg,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===Sg||e.key===null)&&Cg.setState({preferences:Nv(),saveFailed:!1})});function Bh(e){if(e<1024)return`${e} B`;const t=["B","KB","MB","GB","TB"],r=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${Number((e/1024**r).toFixed(1))} ${t[r]}`}function bN({result:e,message:t,onClose:r}){const{locale:n}=Gr(),a=n==="zh",c=b.useRef(null),[l,d]=b.useState(null),[f,m]=b.useState(!1);return b.useEffect(()=>{const x=URL.createObjectURL(e.file);return d(x),m(!1),()=>URL.revokeObjectURL(x)},[e.file]),b.useEffect(()=>{const x=c.current;return x?.showModal(),()=>x?.close()},[]),s.jsx("dialog",{ref:c,"aria-label":a?"上传结果预览":"Uploaded media preview",onCancel:x=>{x.preventDefault(),r()},onClick:x=>{x.target===x.currentTarget&&r()},onKeyDown:x=>x.stopPropagation(),onKeyUp:x=>x.stopPropagation(),className:"fixed inset-0 z-modal-panel m-0 h-[100dvh] max-h-none w-screen max-w-none bg-transparent p-3 text-foreground backdrop:bg-[var(--app-backdrop)] open:flex open:items-center open:justify-center",children:s.jsxs("section",{className:"flex max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-1.5rem)] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-start gap-3 border-b border-border/15 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-sm font-semibold",children:a?"上传结果预览":"Uploaded media preview"}),s.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:t}),s.jsx("p",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:e.file.name})]}),s.jsx("button",{type:"button",autoFocus:!0,onClick:r,"aria-label":a?"关闭预览":"Close preview",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:s.jsx(Dn,{size:18})})]}),s.jsx("div",{className:"min-h-0 overflow-auto p-2",children:f?s.jsx("p",{role:"alert",className:"p-4 text-sm text-muted-foreground",children:a?"文件已上传,但当前浏览器无法预览此格式。":"File uploaded, but this browser cannot preview this format."}):l&&(e.kind==="image"?s.jsx("img",{src:l,alt:e.file.name,onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] max-w-full object-contain"}):s.jsx("video",{src:l,controls:!0,playsInline:!0,preload:"metadata",onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] w-full"}))})]})})}function yN({result:e,onDismiss:t}){const{locale:r}=Gr(),n=r==="zh",a=Cg(L=>L.preferences.showResultToast),c=a?e:null,[l,d]=b.useState(null);b.useEffect(()=>{if(!e)return;if(!a){t();return}const L=window.setTimeout(t,2e3);return()=>window.clearTimeout(L)},[e,a,t]);const f=c??l?.result;if(!f)return null;const m=f.originalSize-f.uploadedSize,x=f.originalSize>0?Math.abs(m)/f.originalSize*100:0,y=x<1?"<1%":`${Math.floor(x)}%`,w=f.kind==="image"?n?"图片":"Image":n?"视频":"Video",v=m>0?n?"已压缩上传":"Compressed upload":n?"已处理上传":"Processed upload",T=m>0?n?`省 ${y}`:`${y} saved`:m<0?`+${y}`:n?"体积未变":"Size unchanged",C=f.originalRetained?n?`已尝试压缩 · 保留原图 ${Bh(f.uploadedSize)},已上传`:`Compression tried · original ${Bh(f.uploadedSize)} uploaded`:`${v} · ${Bh(f.originalSize)} → ${Bh(f.uploadedSize)} · ${T}`;return s.jsxs(s.Fragment,{children:[c&&s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"pointer-events-none absolute left-1/2 top-1/2 z-30 w-max max-w-[calc(100%-1.5rem)] -translate-x-1/2 -translate-y-1/2 motion-safe:animate-[fade-in_0.15s_ease-out]",children:s.jsxs("button",{type:"button","aria-label":`${w}:${C} · ${n?"点击预览":"Preview"}`,onClick:()=>{d({result:c,message:C}),t()},className:"pointer-events-auto flex max-w-full select-none items-center gap-1.5 rounded-full border border-border/15 bg-surface-elevated px-3 py-2 text-[11px] leading-4 text-foreground shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(Ci,{size:13,strokeWidth:2.5,className:"shrink-0 text-primary","aria-hidden":"true"}),s.jsx("span",{className:"truncate tabular-nums",children:C}),s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n?"预览 ›":"Preview ›"})]})}),l&&ci.createPortal(s.jsx(bN,{result:l.result,message:l.message,onClose:()=>d(null)}),document.body)]})}const vN=320,u5="termdock:mobile-keyboard-expanded",d5="termdock:mobile-keyboard-preset-mode",h5="termdock:mobile-long-press-mode",wN=80;function AN(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function f5(e){const t=(e instanceof Error?e.message:String(e)).slice(0,3e3);return/importing a module script failed|dynamically imported module|loading chunk/i.test(t)?`压缩模块加载失败,可能是页面版本过旧或网络中断。请更新页面后重试,无需清除转码器缓存。
75
+ ${t}`:t}function TN(e){switch(e?.phase){case"loading":return`正在加载转码器… ${e.progress??0}%(优先使用浏览器缓存)`;case"saving":return"加载完成,正在保存到本机…";case"initializing":return e.source==="local"?"已找到本机缓存,正在初始化转码器…":"正在初始化本地转码器…";case"ready":return e.source==="local"?"已从本机缓存加载,转码器已就绪。":e.saved?"转码器已就绪,已保存到本机供下次使用。":"转码器已就绪。";default:return"正在检查本机转码器缓存…"}}function vm(){return Gy()}const SN={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},CN=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=wg(),colorTheme:a="dark",toolbarPresets:c=[],isActive:l=!0,focusSuspended:d=!1,deferCursorUntilPositioned:f=!1,isLayoutVisible:m=!0,focusRequestToken:x=0,resumeRequestToken:y=0,resumeRequestReason:w="visibility",resumeRequestDelayMs:v=0,forceResumeReconnect:T=!1,initialConnectDelayMs:C=0,initialConnectEnabled:L=!0,resumeRequestEnabled:N=!0,onStreamReadyChange:D,onStreamConnected:O,onViewportReadyChange:P,onContentReadyChange:F,onKeyboardVisibilityChange:ee,suppressKeyboard:Z=!1,keyboardPortalTarget:G=null,sharedMobileKeyboardLayout:de=!1,suppressPageFlipRefresh:pe=!1,showDebug:J,onStatusChange:Re})=>{const{t:Ze}=Gr(),[V]=_.useState(e||L3()),[ve,qe]=_.useState(()=>(e?i1(e):null)??n.fontSize),le=_.useMemo(()=>LE(),[]),ye=_.useMemo(()=>rd("session"),[]),Te=_.useMemo(()=>rd("keyboard"),[]),Fe=_.useRef(null),se=_.useRef(null);_.useEffect(()=>{i1(V)===null&&qe(n.fontSize)},[n.fontSize,V]);const De=_.useMemo(()=>({...n,fontSize:ve}),[n,ve]),_e=C8(),Me=d||_e,[Ke,Ne]=_.useState(vm),[ae,ze]=_.useState(!1),[at,ct]=_.useState(!1),[me,ut]=_.useState(!1),[ft,Se]=_.useState(()=>typeof document>"u"?!0:!document.hidden&&Pu()),[He,ke]=_.useState(()=>typeof document>"u"?!0:document.hasFocus()),[z,ie]=_.useState(!1),ge=_.useRef(z);ge.current=z;const[We,tt]=_.useState(!1),[wt,Zt]=_.useState(!1),[Ut,Mt]=_.useState(!1),[nr,jt]=_.useState(!0),{isOpen:Xt,keyboardHeight:Bt}=kv({enabled:Ke&&l}),[Ht,xe]=_.useState(null),[Je,ot]=_.useState(null),[Nt,K]=_.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(u5)==="true"),[xt,tr]=_.useState(()=>{if(typeof window>"u")return"auto";const ce=window.localStorage.getItem(d5);return ce&&ce.length>0?ce:"auto"}),[$e,Qr]=_.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(h5)==="copy"?"copy":"arrows"),[Ce,St]=_.useState("idle"),[Ot,Jt]=_.useState("idle"),[lt,Ct]=_.useState(0),[ar,_r]=_.useState(null),[Nr,zr]=_.useState(null),[Tt,Ft]=_.useState(null),we=_.useCallback(()=>Ft(null),[]),{preferences:At,update:st,saveFailed:bt}=Cg(),{videoEnabled:Tn,videoMaxHeight:bn,videoBitrate:nn,imageEnabled:Oe,imageMaxDimension:_t,imageQuality:gt}=At,[Wt,$t]=_.useState(!1),[Ar,Sn]=_.useState(null),[Mn,vn]=_.useState(null),dn=Yr(ce=>ce.sessions.get(V)),{setTerminalSession:kn,setConnecting:Hr,appendToBuffer:ne,replaceBuffer:Xe,clearTerminalSession:Dt,removeTerminalSession:ur,clearBuffer:Fr,setSessionActiveProgram:Zr,setSessionCwd:an,setSessionCopyMode:Mr,setSessionAgentStatus:Vr,setSessionShellTitle:Ln,setSessionPromptState:tn,clearAgentNeedsReview:Ur}=Yr.getState(),Xr=_.useMemo(()=>`wt-${V.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[V]),vr=dn?.terminalSessionId??null,on=dn?.mode??"shell",Jr=dn?.activeProgram??null,hn=_.useMemo(()=>Vu(c),[c]),jr=on==="tmux",zn=dn?.bufferChunks??[],mn=dn?.isConnecting??!1,qr=vr,Wr=_.useCallback(async(ce,Ge)=>{const vt=ZI(ce,dn?.cwd||dn?.directory);if(!vt)return;let Lt=vt,et="directory";try{Lt=(await rg(vt)).path}catch(Rt){if(!(Rt instanceof Error)||Rt.message!=="Path is not a directory")return;et="file"}try{const Rt=Vt.getState();Rt.setRightTab("files"),Rt.openRight(),window.dispatchEvent(new CustomEvent(HI,{detail:{path:Lt,kind:et,line:Ge}}))}catch{}},[dn?.cwd,dn?.directory]),Y=t??dn?.mode??"shell",Be=Y==="tmux"?r??dn?.tmuxSessionName??null:null,[Qt,er]=_.useState(null),sr=_.useRef(!1),[$r,Ir]=_.useState(!1),[Zn,ys]=_.useState(!1),[is,Hn]=_.useState(null),[fn,Bn]=_.useState(0),[Xn,pn]=_.useState(null),lr=J!==void 0?J:!1,as=_.useRef(null),rn=_.useRef(null),gr=_.useRef(null),wr=_.useRef(null),xr=_.useRef(null),ds=_.useRef(!1),jn=_.useRef(null),vs=_.useRef([]),Qs=_.useRef(0),Is=_.useRef(!1),Or=_.useRef(Promise.resolve()),br=_.useRef(null),Qn=_.useRef(null),Jn=_.useRef(-1),es=_.useRef(null),ui=_.useRef(0),W=_.useRef(null),Ie=_.useRef(null),Ye=_.useRef(0),rt=_.useRef(0),nt=_.useRef(!1),yt=_.useRef(null),Pt=_.useRef(null),H=_.useRef(!1),ue=_.useRef(0),R=_.useRef(!1),U=_.useRef(!1),X=_.useRef(!1),be=_.useRef(null),Ee=_.useRef(null),Ve=_.useRef(null),dt=_.useRef(l);dt.current=l;const Qe=_.useRef(Me);Qe.current=Me;const ir=_.useRef(d);ir.current=d;const rr=_.useRef(Ke),Et=_.useRef(null),kr=_.useRef(null),ln=_.useRef(null),yn=_.useRef(null),en=_.useRef(null),gn=_.useRef(null),dr=_.useRef(null),pr=_.useCallback(()=>{const ce=++ue.current,Ge=()=>{ce===ue.current&&tt(!0)};if(typeof window>"u"){Ge();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(Ge))},[]),fs=_.useCallback(ce=>{if(R.current){if(Ee.current!==null&&(window.clearTimeout(Ee.current),Ee.current=null),ce.x===0&&ce.y>=ce.rows-1){jt(!1);return}Ee.current=window.setTimeout(()=>{Ee.current=null,jt(!0)},wN)}},[]),ws=_.useRef(null);_.useEffect(()=>()=>{ws.current?.()},[]);const _s=_.useCallback(()=>{ws.current||(ws.current=dg(()=>{ws.current=null;const ce=Yr.getState(),Ge=gr.current,vt=ce.getTerminalSession(V);if(!Ge||vt?.mode!=="shell"||ce.hasPendingBufferWrites(V))return;const Lt=_8(Ge),et=xr.current?.getDimensions();if(!Lt||!et)return;const cr=xr.current?.serializeSnapshot();cr&&k8({id:Ge,version:1,...Lt,...et,data:cr,savedAt:Date.now()})},2e3))},[V]),zi=_.useCallback(ce=>{const Ge=Yr.getState(),vt=Ge.getTerminalSession(V)?.bufferChunks.at(-1)?.id;if(gr.current&&vt!==void 0&&vt<=ce&&!Ge.hasPendingBufferWrites(V)&&(L8(gr.current),_s()),!nt.current||!sN({writtenChunkId:ce,initialTargetChunkId:yt.current}))return;const Lt=Pt.current;Pt.current=null,Lt!==null&&xr.current?.notifyScreenSynchronized(Lt),nt.current=!1,yt.current=null,pr()},[pr,_s,V]),Zl=_.useCallback(ce=>{if(!R.current)return;const Ge=be.current;Ge&&Ge.x===ce.x&&Ge.y===ce.y&&Ge.rows===ce.rows||(be.current=ce,Ee.current!==null&&(window.clearTimeout(Ee.current),Ee.current=null),ce.x===0&&ce.y>=ce.rows-1&&jt(!1))},[]);_.useEffect(()=>{if(!f){U.current=!1;return}U.current||(U.current=!0,X.current=!1,R.current=!0,be.current=null,jt(!1),Ee.current!==null&&(window.clearTimeout(Ee.current),Ee.current=null),Ve.current!==null&&window.clearTimeout(Ve.current),Ve.current=window.setTimeout(()=>{Ve.current=null,Ee.current!==null&&typeof window<"u"&&window.clearTimeout(Ee.current),Ee.current=null,R.current=!1,jt(!0)},15e3))},[f]);const As=_.useCallback(()=>{yn.current=null;const ce=ln.current;ln.current=null,ce&&Ln(ce.sessionId,ce.title)},[Ln]),Es=_.useCallback((ce,Ge)=>{if(ln.current={sessionId:ce,title:Ge},yn.current===null){if(typeof window>"u"){As();return}yn.current=window.requestAnimationFrame(As)}},[As]),di=_.useCallback(()=>{yn.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(yn.current),yn.current=null,ln.current=null},[]),Ca=_.useCallback(async()=>{const ce=Y;return(await I8({preferredFrontendSessionId:V,mode:ce,tmuxSessionName:ce==="tmux"?Be||Xr:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[Y,Be,Xr,V]),Kl=_.useRef(l);_.useEffect(()=>{if(!l){xr.current?.blur(),Kl.current=!1;return}if(Kl.current)return;Kl.current=!0;const ce=uI(Ke,pe);if(ce==="single"){xr.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}ce!=="none"&&xr.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[l,Ke,pe,qr]),_.useEffect(()=>{rr.current=Ke},[Ke]);const Wn=_.useCallback(()=>{!dt.current||Qe.current||xr.current?.focus()},[]);_.useLayoutEffect(()=>{Me&&xr.current?.blur()},[Me]),_.useEffect(()=>{if(!l||Me||nr||X.current)return;X.current=!0;const ce=window.requestAnimationFrame(()=>{xr.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(ce)},[Me,l,nr]);const os=_.useCallback(ce=>{typeof window>"u"||typeof document>"u"||!dt.current||Qe.current||rr.current||document.hidden||!Pu()||(Et.current!==null&&window.clearTimeout(Et.current),Et.current=window.setTimeout(()=>{if(Et.current=null,!dt.current||Qe.current||rr.current||document.hidden||!Pu())return;const Ge=document.activeElement,vt=Ge?.getAttribute("data-terminal-input-anchor")==="true";if((Ge instanceof HTMLInputElement||Ge instanceof HTMLTextAreaElement||Ge instanceof HTMLSelectElement||Ge?.isContentEditable===!0)&&!vt){Te("desktop resume focus skipped: editable active",{reason:ce});return}Te("desktop resume focus",{reason:ce}),xr.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),xr.current?.focus()},50))},[Te]);_.useEffect(()=>()=>{Et.current!==null&&typeof window<"u"&&window.clearTimeout(Et.current),Et.current=null,kr.current!==null&&typeof window<"u"&&window.clearTimeout(kr.current),kr.current=null,en.current!==null&&typeof window<"u"&&window.clearTimeout(en.current),en.current=null,gn.current!==null&&typeof window<"u"&&window.clearTimeout(gn.current),gn.current=null,Ve.current!==null&&typeof window<"u"&&window.clearTimeout(Ve.current),Ve.current=null,Ee.current!==null&&typeof window<"u"&&window.clearTimeout(Ee.current),Ee.current=null},[]),_.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const ce=()=>{kr.current!==null&&window.clearTimeout(kr.current),kr.current=window.setTimeout(()=>{kr.current=null;const Ge=document.activeElement,Lt=!(Ge?.getAttribute("data-terminal-input-anchor")==="true")&&!!(Ge&&(Ge instanceof HTMLInputElement||Ge instanceof HTMLTextAreaElement||Ge instanceof HTMLSelectElement||Ge.isContentEditable));cC({isActive:dt.current&&!Qe.current,isMobile:rr.current,documentVisible:!document.hidden,activeElementIsEditable:Lt})&&Wn()},0)};return document.addEventListener("pointerup",ce),()=>{document.removeEventListener("pointerup",ce),kr.current!==null&&(window.clearTimeout(kr.current),kr.current=null)}},[Wn]);const Ns=_.useCallback(()=>{ls.current=!1,Bn(ce=>ce+1)},[]),no=_.useCallback((ce,Ge,vt)=>{const Lt=gr.current,et=Date.now();if(Lt&&Ge&&E8(Lt)){se.current={startedAt:et,strategy:"reconnect",reason:ce},$a("info","PWA_RESUME terminal-start",{frontendSessionId:V,backendSessionId:Lt,strategy:"reconnect",reason:ce,active:dt.current});return}if(Lt&&N8(Lt,()=>{const Rt=se.current;$a("info","PWA_RESUME terminal-responsive",{frontendSessionId:V,backendSessionId:Lt,durationMs:Rt?Date.now()-Rt.startedAt:null,strategy:Rt?.strategy??"probe",reason:Rt?.reason??ce}),se.current=null,O?.(V)},{visible:vt})){se.current={startedAt:et,strategy:"probe",reason:ce},$a("info","PWA_RESUME terminal-start",{frontendSessionId:V,backendSessionId:Lt,strategy:"probe",reason:ce,active:dt.current}),ye("[Terminal] resume probe sent",{reason:ce,backendSessionId:Lt,active:dt.current});return}if(ye("[Terminal] resume probe missing connection, restarting ensureSession",{reason:ce,backendSessionId:Lt,active:dt.current}),!iN({initialConnectionPending:H.current})){ye("[Terminal] resume probe deferred during initial websocket handshake",{reason:ce,backendSessionId:Lt});return}Ns()},[ye,O,Ns,V]),Hs=_.useCallback((ce,Ge)=>{const vt=gr.current;vt&&jn.current!==ce&&(jn.current=ce,Sx(vt,ce,Ge),ye("[Terminal] flow-control state sent",{backendSessionId:vt,paused:ce,reason:Ge}))},[ye]),_l=_.useCallback((ce,Ge)=>{const vt=gr.current;vt&&W.current!==ce&&(W.current=ce,Cx(vt,ce,Ge),ye("[Terminal] focus state sent",{backendSessionId:vt,focused:ce,reason:Ge}))},[ye]),za=_.useCallback((ce,Ge)=>{const vt=gr.current;vt&&Ie.current!==ce&&(Ie.current=ce,_x(vt,ce,Ge),ye("[Terminal] viewing state sent",{backendSessionId:vt,viewing:ce,reason:Ge}))},[ye]),Pn=oC({isActive:l&&!Me,viewportFocused:me,documentVisible:ft,windowFocused:He,streamReady:z}),Li=lC({isActive:l,documentVisible:ft,windowFocused:He,streamReady:z,isDesktop:na()!==null}),Ha=_.useRef(Pn),Mo=_.useRef(Li);_.useEffect(()=>{Ha.current=Pn,_l(Pn,"logical-focus-change")},[Pn,_l,qr]),_.useEffect(()=>{Mo.current=Li,za(Li,"logical-viewing-change")},[Li,za,qr]),OC(qr,ft,z),_.useEffect(()=>{const ce=Ge=>{const vt=Ge.detail;!vt||vt.sessionId!==V||qe(vt.fontSize??n.fontSize)};return window.addEventListener("termfontchange",ce),()=>window.removeEventListener("termfontchange",ce)},[V,n.fontSize]),_.useEffect(()=>{const ce=()=>{const et=!document.hidden&&Pu();Se(et),et&&l&&os("visibility")},Ge=et=>{l&&os(et.persisted?"bfcache":"pageshow")},vt=()=>{ke(!0),os("window-focus")},Lt=()=>ke(!1);return document.addEventListener("visibilitychange",ce),window.addEventListener(kx,ce),window.addEventListener("pageshow",Ge),window.addEventListener("focus",vt),window.addEventListener("blur",Lt),()=>{document.removeEventListener("visibilitychange",ce),window.removeEventListener(kx,ce),window.removeEventListener("pageshow",Ge),window.removeEventListener("focus",vt),window.removeEventListener("blur",Lt)}},[l,os]),_.useEffect(()=>{if(!y||!N||!Wa.current)return;const ce=v,Ge=ce<=0,vt=Fe.current;if(vt?.token===y&&(vt.visible||!Ge))return;const Lt=()=>{Fe.current={token:y,visible:Ge},xr.current?.requestRefresh(w,{skipScrollToBottom:!0}),no(ce>0?"global-resume-background":"global-resume-visible",ce<=0&&T,Ge)};if(ce<=0){Lt();return}const et=window.setTimeout(Lt,ce);return()=>window.clearTimeout(et)},[y,w,N,v,T,no]);const hi=_.useRef(0);_.useEffect(()=>{if(z){hi.current=0;return}if(!$r||Qt==="Authentication required"||Qt===pf)return;const ce=hi.current,Ge=Math.min(2e3*Math.pow(2,Math.min(ce,4)),3e4),vt=setTimeout(()=>{hi.current+=1,ye("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:hi.current,backendSessionId:gr.current}),er("Reconnecting..."),Ir(!1),Ns()},Ge);return()=>clearTimeout(vt)},[Qt,$r,z,fn,ye,Ns]),_.useEffect(()=>{if(typeof window>"u"){ze(!1);return}const ce=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;ze(ce)},[]),_.useEffect(()=>{(!l||!Ke)&&ct(!1),l||ut(!1)},[l,Ke]),_.useEffect(()=>{gr.current=qr,Jn.current=-1,Pt.current=null,W.current=null,Ie.current=null,jn.current=null},[qr]),_.useEffect(()=>{D?.(V,z)},[z,D,V]),_.useEffect(()=>{F?.(V,z&&We&&wt)},[We,wt,z,F,V]),_.useEffect(()=>{jr||(Is.current=!1,br.current=null,Qn.current&&(clearTimeout(Qn.current),Qn.current=null))},[jr]),_.useEffect(()=>{qr&&xr.current?.requestRefresh("session-key-change",{force:!0})},[qr]),_.useEffect(()=>{const ce=l&&Ke&&Xt;Te("visibility signal",{sessionId:V,isActive:l,isMobile:Ke,isInputFocused:at,isViewportKeyboardOpen:Xt,viewportKeyboardHeight:Bt,visible:ce}),ee?.(V,ce)},[ee,V,l,Ke,Xt,Bt,Te]),_.useEffect(()=>{l&&x&&x!==ui.current&&(ui.current=x,Wn())},[x,Wn,l]),_.useEffect(()=>{wr.current=V},[V]),_.useEffect(()=>{!Ke&&(Ht!==null||Je!==null)&&(xe(null),ot(null),es.current=null)},[Ke,Ht,Je]),_.useEffect(()=>{!qr&&(Ht!==null||Je!==null)&&(xe(null),ot(null),es.current=null)},[qr,Ht,Je]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(u5,Nt?"true":"false")},[Nt]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(d5,xt)},[xt]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(h5,$e)},[$e]),_.useEffect(()=>{Ne(vm());const ce=()=>{Ne(vm())};return window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]);const On=_.useCallback(()=>{Ye.current+=1,rt.current+=1,Or.current=Promise.resolve(),As(),di();const ce=as.current;as.current=null,rn.current=null,H.current=!1,ge.current=!1,ie(!1),xr.current?.setSessionReady(!1);const Ge=gr.current;Ge&&Sx(Ge,!1,"stream-disconnect"),ds.current=!1,jn.current=null,vs.current=[],ce?.()},[di,As]),Js=_.useCallback(async ce=>{if(rn.current===ce){ye(`[startStream] Skipping - already connected to ${ce}`);return}ye(`[startStream] Starting stream for frontendSessionId=${V} backendSessionId=${ce}`),Hn(null),ue.current+=1,nt.current=!1,yt.current=null,tt(!1),Zt(!1),On();const Ge=Ye.current+1;Ye.current=Ge,H.current=!0;const vt=Yr.getState().getTerminalSession(V);if(vt?.mode==="shell"&&!vt.bufferChunks.length){const et=await Promise.race([R8(ce),new Promise(Rt=>window.setTimeout(()=>Rt(null),75))]);if(Ye.current!==Ge||wr.current!==V)return;if(et&&!Yr.getState().getTerminalSession(V)?.bufferChunks.length){Yr.getState().replaceBuffer(V,[et.data]);const Rt=xr.current?.getDimensions();Rt?.cols===et.cols&&Rt.rows===et.rows&&M8(ce,et.seq,et.epoch)}}const Lt=le.connect(ce,{onEvent:et=>{if(Ye.current!==Ge)return;const Rt=V;if(Rt)switch(et.type){case"connected":{rt.current+=1,Or.current=Promise.resolve(),H.current=!1;const cr=se.current;cr&&($a("info","PWA_RESUME terminal-connected",{frontendSessionId:Rt,backendSessionId:gr.current,durationMs:Date.now()-cr.startedAt,strategy:cr.strategy,reason:cr.reason}),se.current=null),O?.(Rt),(et.runtime||et.ptyBackend)&&ye(`[Terminal] connected frontendSessionId=${Rt} backendSessionId=${gr.current} runtime=${et.runtime??"unknown"} pty=${et.ptyBackend??"unknown"} cwd=${et.cwd??"unknown"}`),Hr(Rt,!1),er(null),Ir(!1),Hn(null),ge.current=!0,ie(!0),gr.current&&(Cx(gr.current,Ha.current,"stream-connected"),_x(gr.current,Mo.current,"stream-connected")),xr.current?.setSessionReady(!0),jn.current=null,Hs(ds.current,"stream-connected"),et.tuiProgress!==void 0&&Yr.getState().setSessionTuiProgress(Rt,et.tuiProgress??null),et.shellTitle!==void 0&&Yr.getState().setSessionShellTitle(Rt,et.shellTitle??null),et.promptState!==void 0&&et.promptState!==null&&Yr.getState().setSessionPromptState(Rt,et.promptState);const Lr=Yr.getState().getTerminalSession(Rt);if(Lr?.terminalSessionId&&et.mode&&Yr.getState().setTerminalSession(Rt,{sessionId:Lr.terminalSessionId,cols:80,rows:24,mode:et.mode,tmuxSessionName:et.tmuxSessionName??null,cwd:et.cwd??null}),et.activeProgram!==void 0&&Zr(Rt,et.activeProgram??null,et.activeProgramSource??null,et.activeProgramRaw??null),xr.current?.requestRefresh("connected",{force:!0,reconcileServerSize:dt.current}),et.mode!=="tmux"&&(pn(null),Mr(Rt,!1)),ye("[Terminal] Connected event received:",{frontendSessionId:Rt,backendSessionId:gr.current,storeHasState:!!Lr,storeTerminalId:Lr?.terminalSessionId,hasHistoryInStore:!!Lr?.history?.length,historyLength:Lr?.history?.length??0}),Lr?.history&&Lr.history.length>0){ye(`[Terminal] Restoring ${Lr.history.length} history chunks to frontend session ${Rt}`);const $=Lr.history.reduce((Pe,Le)=>Pe+Le.length,0),q=Math.max(300,Math.min(2e3,Math.ceil($/200)));Qs.current=Date.now()+q,Lr.history.forEach(Pe=>{ne(Rt,Pe,{markActivity:!1})}),Yr.getState().setSessionHistory(Rt,[]),ye(`[Terminal] History restoration complete for ${Rt}`)}else ye(`[Terminal] No history to restore for ${Rt}`);const I=et.replayChunks,B=!!Lr?.history?.length||!!I?.length;if(B?nt.current=!0:pr(),I&&I.length>0){let $=null;if(et.replayOutOfWindow)xr.current?.prepareScreenReplacement(),ye(`[Terminal] Replay out-of-window, atomically replacing buffer (${I.length} chunks)`),$=Xe(Rt,VC(I));else{ye(`[Terminal] Replay incremental: ${I.length} chunks`);for(const Le of I)ne(Rt,Le)}const q=I.reduce((Le,mt)=>Le+mt.length,0),Pe=Math.max(200,Math.min(1500,Math.ceil(q/200)));Qs.current=Math.max(Qs.current,Date.now()+Pe),yt.current=$}B&&yt.current===null&&(yt.current=Yr.getState().flushPendingBufferWrites(Rt),yt.current===null&&(nt.current=!1,pr()));break}case"reconnecting":{ge.current=!1,ie(!1),Hn(cr=>cr??Date.now()),er("Reconnecting..."),Ir(!1);break}case"data":{et.data&&(ds.current?vs.current.push(et.data):ne(Rt,et.data));break}case"tmux-layout":{pn(et.layout??null),et.layout&&Mr(Rt,et.layout.inCopyMode);break}case"tmux-screen-sync":{const cr=et.generation??0;if(cr<Jn.current)break;Jn.current=cr,ue.current+=1,nt.current=!0,tt(!1),vs.current=[],xr.current?.prepareScreenReplacement(),Pt.current=cr,yt.current=Xe(Rt,qC(et.chunks??[])),yt.current===null&&(Pt.current=null,xr.current?.notifyScreenSynchronized(cr),nt.current=!1,pr()),typeof et.cols=="number"&&typeof et.rows=="number"&&xr.current?.notifyServerSize(et.cols,et.rows,"tmux-screen-sync");break}case"active-program":{Zr(Rt,et.activeProgram??null,et.activeProgramSource??null,et.activeProgramRaw??null);break}case"cwd":{an(Rt,et.cwd??null);break}case"agent-status":{Vr(Rt,{agentStatus:et.agentStatus??null,agentIndicator:et.agentIndicator??null,agentStatusDetail:et.agentStatusDetail??null,agent:et.agent??null,agentMessage:et.agentMessage??null,agentNativeSessionId:et.agentNativeSessionId??null,agentResumeRecovered:et.agentResumeRecovered===!0,agentRich:et.agentRich===!0,agentActivity:et.agentActivity??0,agentCwd:et.agentCwd??null,reviewed:et.reviewed??null});break}case"git-status":{Yr.getState().setSessionGitStatus(Rt,et.gitStatus??null);break}case"focus-mode":{ye("[Terminal] focus tracking mode",{backendSessionId:gr.current,requested:et.focusTrackingRequested===!0});break}case"resize-ack":{xr.current?.acknowledgeResize({seq:et.seq,ok:et.ok!==!1,cols:et.cols,rows:et.rows,screenSyncPending:et.screenSyncPending,screenSyncGeneration:et.screenSyncGeneration});break}case"pty-size":{typeof et.cols=="number"&&typeof et.rows=="number"&&xr.current?.notifyServerSize(et.cols,et.rows,et.source);break}case"shell-title":{Es(Rt,et.title??null);break}case"prompt-state":{tn(Rt,et.state??"idle",et.exitCode??null);break}case"tui-progress":{Yr.getState().setSessionTuiProgress(Rt,et.tuiProgress??null);break}case"exit":{const cr=typeof et.exitCode=="number"?et.exitCode:null,Lr=typeof et.signal=="number"?et.signal:null;ne(Rt,`\r
76
+ [Process exited${cr!==null?` with code ${cr}`:""}${Lr!==null?` (signal ${Lr})`:""}]\r
77
+ `),Dt(Rt),Hr(Rt,!1),er("Terminal session ended"),ie(!1),Ir(!1),Hn(null),pn(null),Mr(Rt,!1),On();break}}},onError:(et,Rt)=>{if(Ye.current!==Ge)return;const cr=V;if(!cr)return;H.current=!1,ge.current=!1,ie(!1);const Lr=et.name==="TerminalInputError"&&"code"in et&&et.code==="TERMINAL_INPUT_REJECTED",I=Rt&&et.message==="Authentication required",B=!Lr&&o5(et),$=Lr||I?et.message:B||Rt?"Reconnecting...":et.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${Rt}):`,$),B&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:gr.current,frontendSessionId:cr,isActive:l,isMobile:Ke,fatal:Rt,stack:new Error().stack}),er($),Ir(!!Rt),Rt&&(Hn(null),Hr(cr,!1),On(),B&&(ye("[onError] Session lost, auto-recreating"),er("Reconnecting..."),Ir(!1),Dt(cr),Fr(cr),gr.current=null,ls.current=!1,Ns()))}},{...SN,getDimensions:()=>xr.current?.getDimensions()??null});as.current=()=>{Lt.close(),Ye.current===Ge&&(rn.current=null)},rn.current=ce},[ne,Fr,Dt,ye,On,pr,O,Hs,Ns,Es,Hr,Zr,Vr,Mr,an,tn,le,V]);_.useEffect(()=>{const ce=dN({isActive:l,isStreamReady:z,reconnectStartedAt:is,now:Date.now()});if(ce===null)return;const Ge=window.setTimeout(()=>{ye("[Terminal] visible reconnect watchdog expired",{backendSessionId:gr.current,reconnectStartedAt:is}),On(),Hr(V,!1),er("Reconnecting..."),Ir(!1),Hn(Date.now()),Ns()},ce);return()=>window.clearTimeout(Ge)},[ye,On,l,z,is,Ns,V,Hr]);const ls=_.useRef(!1),Wa=_.useRef(!1),ps=_.useRef(0);_.useEffect(()=>()=>{ps.current+=1,ls.current=!1,On()},[On]);const tl=_.useRef(Y),ia=_.useRef(Be);_.useEffect(()=>{const ce=tl.current,Ge=ia.current;tl.current=Y,ia.current=Be,wr.current===V&&(ce===Y&&Ge===Be||(ls.current=!1,On(),Bn(vt=>vt+1)))},[Y,Be,On,V]),_.useEffect(()=>{if(wr.current!==V&&(ye(`[useEffect] sessionId changed from ${wr.current} to ${V}, allowing reinitialization`),ls.current=!1,Wa.current=!1),ls.current&&wr.current===V){ye(`[useEffect] Already initialized for sessionId=${V}, skipping`);return}if(!Ut)return;const ce=async Rt=>{if(ye(`[ensureSession] Starting for sessionId=${V}, runId=${Rt}`),!wr.current||wr.current!==V){ye(`[ensureSession] SessionId mismatch or stale run (current=${wr.current}, target=${V}), skipping`);return}if(Rt!==ps.current){ye(`[ensureSession] Stale run detected (runId=${Rt}, currentRunId=${ps.current}), skipping`);return}const cr=Yr.getState(),Lr=cr.getTerminalSession(V),I=Lr?.mode??Y;ye("[ensureSession] Current state from store:",{terminalSessionId:Lr?.terminalSessionId,mode:Lr?.mode,tmuxSessionName:Lr?.tmuxSessionName,isConnecting:Lr?.isConnecting});let B=Lr?.terminalSessionId??null,$=!B;if(B&&I!==Y?(ye(`[ensureSession] Store mode mismatch for ${B}: current=${I} desired=${Y}, will create new session`),$=!0,cr.clearTerminalSession(V),B=null):B&&Y==="tmux"&&Be&&Lr?.tmuxSessionName!==Be&&(ye(`[ensureSession] Store tmux name mismatch for ${B}: current=${Lr?.tmuxSessionName} desired=${Be}, will create new session`),$=!0,cr.clearTerminalSession(V),B=null),B&&le.checkHealth&&!dt.current){ye(`[ensureSession] Checking health of existing session ${B}`);try{const q=await le.checkHealth(B);if(ye("[ensureSession] Health check result:",q),!q.healthy)ye(`[ensureSession] Session ${B} is NOT healthy (healthy=${q.healthy}), will create new session`),ye("[ensureSession] Health check details:",q),$=!0,q.mode&&Lr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Lr.terminalSessionId,cols:80,rows:24,mode:q.mode,tmuxSessionName:q.tmuxSessionName??null}),cr.clearTerminalSession(V),ye("[ensureSession] Cleared unhealthy session from store");else{ye(`[ensureSession] Session ${B} is healthy, reusing it, cwd=${q.cwd}, clients=${q.clients}, lastActivity=${Date.now()-(q.lastActivity||0)}ms ago`),q.mode&&Lr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Lr.terminalSessionId,cols:80,rows:24,mode:q.mode,tmuxSessionName:q.tmuxSessionName??null}),ye(`[ensureSession] Setting terminalIdRef to ${B} and starting stream`),gr.current=B,Js(B),ye(`[ensureSession] Successfully reused healthy session ${B}, returning early`);return}}catch(q){ye(`[ensureSession] Failed to check health of session ${B}:`,q),ye("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ye(`[ensureSession] Decision: shouldCreateNewSession=${$}, terminalId=${B}`),$){ye(`[ensureSession] Creating new session, shouldCreateNewSession=${$}, runId=${Rt}`),er(null),Ir(!1),cr.setConnecting(V,!0);const Pe=Yr.getState().getTerminalSession(V),mt=(Pe?.mode??Y)===Y&&(Y!=="tmux"||!Be||Pe?.tmuxSessionName===Be);if(Pe?.terminalSessionId&&mt)ye(`[ensureSession] Race condition avoided: another instance already created session ${Pe.terminalSessionId}`),cr.setConnecting(V,!1),B=Pe.terminalSessionId,$=!1;else try{const ht=await Ca();if(ye(`[ensureSession] Opened managed backend session ${ht.sessionId}`),Rt!==ps.current){ye(`[ensureSession] Stale run after session creation (runId=${Rt}, currentRunId=${ps.current}), leaving ${ht.sessionId} for sibling`);return}cr.setTerminalSession(V,ht),ye(`[ensureSession] Updated store with new session ${ht.sessionId}`),B=ht.sessionId}catch(ht){if(Rt!==ps.current){ye("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(ht instanceof x0&&L1(ht)){ye("[ensureSession] Confirmed missing persisted session:",{sessionId:V,error:ht.message}),cr.clearTerminalSession(V),er(pf),Ir(!0),cr.setConnecting(V,!1);return}er("Reconnecting..."),Ir(!0),cr.setConnecting(V,!1);return}}if(Rt!==ps.current){ye(`[ensureSession] Stale run before starting stream (runId=${Rt}, currentRunId=${ps.current}), skipping`);return}if(!B){ye(`[ensureSession] No terminalId, terminalId=${B}`);return}ye(`[ensureSession] Starting stream for session ${B}`),gr.current=B,Js(B),ye(`[ensureSession] ensureSession completed for sessionId=${V}, terminalId=${B}`)};let Ge=null,vt=null;const Lt=()=>{vt=null,!(ls.current&&wr.current===V)&&(ye(`[useEffect] Running ensureSession for sessionId=${V}, hasInitialized=${ls.current}`),ls.current=!0,Wa.current=!0,Ge=++ps.current,ce(Ge))};if(!L&&!Wa.current){ye(`[useEffect] Holding background connection until the selected session is ready: ${V}`);return}const et=Wa.current?0:Math.max(0,C);return et>0?(ye(`[useEffect] Delaying initial connection for sessionId=${V} by ${et}ms`),vt=window.setTimeout(Lt,et)):Lt(),()=>{vt!==null&&window.clearTimeout(vt),ye(`[useEffect] Cleanup for sessionId=${V}, runId=${Ge??"pending"}`)}},[V,fn,Js,On,le,ye,Y,Be,Xr,C,L,Ut]);const rl=_.useCallback(async()=>{if(V&&!Zn){ys(!0),er(null),Ir(!1),Hn(null),On();try{le.forceKill&&await le.forceKill({sessionId:V})}catch{}ur(V),Fr(V),xr.current?.clear(),await new Promise(ce=>setTimeout(ce,100));try{Hr(V,!0);const ce=await Ca();kn(V,ce),gr.current=ce.sessionId,Js(ce.sessionId)}catch(ce){er(ce instanceof x0&&L1(ce)?pf:"Reconnecting..."),Ir(!0),Hr(V,!1)}finally{ys(!1)}}},[V,Zn,On,le,ur,Fr,Hr,kn,Js,Ca]),_a=_.useCallback((ce,Ge,vt,Lt)=>{if(!(gr.current!==Ge||rt.current!==vt)){if(ce instanceof x0&&o5(ce)){ye("[Terminal] operation backend missing, recovering",{terminalId:Ge,sessionId:V}),er("Reconnecting..."),Ir(!1),On(),Dt(V),gr.current=null,Hr(V,!0),Ns();return}er(ce instanceof Error?ce.message:Lt)}},[Dt,ye,On,Ns,V,Hr]),jo=_.useCallback((ce,Ge)=>{const vt=Ge?.ownedPaste?QC(Ge.ownedPaste,V,ce):!1;if(Ge?.ownedPaste&&!vt||ir.current||(Qe.current||ng())&&!vt)return Promise.resolve(!1);const Lt=()=>!!Ge?.ownedPaste&&PC(Ge.ownedPaste,V)&&dt.current&&!ir.current&&ge.current&&!sr.current&&!document.hidden&&navigator.onLine!==!1&&Pu();if(vt&&!Lt())return Promise.resolve(!1);if(!dt.current&&!Ge?.targeted||!ce)return;const et=ME(ce),Rt=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(ce);if(Date.now()<Qs.current)return Promise.resolve(!1);let cr=ce,Lr=Ge?.consumeModifier??!1;if(!Ge?.skipModifierTransform&&Ht&&ce.length>0){const Pe=ce[0];if(Pe.length===1&&/[a-zA-Z]/.test(Pe)){const Le=Pe.toUpperCase();Ht==="ctrl"?(cr=String.fromCharCode(Le.charCodeAt(0)&31),Lr=!0):Ht==="alt"&&(cr=`\x1B${ce}`,Lr=!0)}Lr||(Ht==="alt"&&(cr=`\x1B${ce}`),Lr=!0)}const I=gr.current;if(!I)return;const B=rt.current,$=async()=>{if(gr.current!==I||rt.current!==B)return!1;try{if(jr&&Rt&&(Is.current=!0),jr&&!et&&Is.current&&le.tmuxAction){Is.current=!1;try{await le.tmuxAction(I,{action:"copy-mode",enabled:!1})}catch{}if(gr.current!==I||rt.current!==B)return!1;if(jE(cr))return!0}return vt&&(!Lt()||gr.current!==I||rt.current!==B)||(await le.sendInput(I,cr),vt&&(!Lt()||gr.current!==I||rt.current!==B))?!1:(Ur(V),!0)}catch(Pe){return _a(Pe,I,B,"Failed to send input"),!1}},q=Or.current.then($);return Or.current=q.then(()=>{},()=>{}),Lr&&(Je||xe(null),Wn()),q},[Ht,Ur,Wn,_a,jr,Je,V,le]);_.useEffect(()=>{const ce=Ge=>{const vt=Ge,Lt=vt.detail?.sessionId;if(Lt?Lt!==V:!dt.current)return;const et=vt.detail?.text;if(!et)return;const Rt=vt.detail?.nonce;if(sr.current||!xr.current){Rt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Rt,ok:!1}}));return}const cr=BC(vt.detail,V),Lr=vt.detail?.ownedPaste&&!cr?Promise.resolve(!1):xr.current.sendSequence(et,{paste:vt.detail?.paste,submitAfterPaste:vt.detail?.submitAfterPaste,targeted:!!Lt,ownedPaste:cr??void 0});Rt&&Promise.resolve(Lr).then(I=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Rt,ok:I===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Rt,ok:!1}}))}),uC(rr.current,vt.detail?.focus!==!1)&&Wn()};return window.addEventListener("termdock-insert-reference",ce),()=>window.removeEventListener("termdock-insert-reference",ce)},[Wn,V]);const so=_.useCallback((ce,Ge,vt)=>{const Lt=gr.current;if(!Lt){Te("xterm resize push skipped: no terminalId",{cols:ce,rows:Ge});return}Te("xterm resize push",{cols:ce,rows:Ge}),le.resize({sessionId:Lt,cols:ce,rows:Ge,seq:vt}).catch(et=>{xr.current?.acknowledgeResize({seq:vt,ok:!1}),et&&/session not found/i.test(String(et.message||et))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Lt,cols:ce,rows:Ge,stack:new Error().stack})})},[le,Te]),Do=_.useCallback(async ce=>{const Ge=gr.current;if(!Ge||!le.tmuxAction)return;const vt=rt.current;try{const Lt=await le.tmuxAction(Ge,ce);if(gr.current!==Ge||rt.current!==vt)return;Lt.layout&&(pn(Lt.layout),ce.action==="switch-session"&&(kn(V,{sessionId:Ge,cols:80,rows:24,mode:"tmux",tmuxSessionName:Lt.layout.sessionName}),j8(V,{tmuxSessionName:Lt.layout.sessionName}).catch(et=>{console.warn("[Terminal] failed to update inventory after tmux switch",et)})))}catch(Lt){_a(Lt,Ge,vt,"Failed to execute tmux action")}},[_a,V,kn,le]);_.useEffect(()=>{if(!Xn||!qr)return;const Ge=Xn.windows.find(vt=>vt.id===Xn.activeWindowId)?.panes.find(vt=>vt.id===Xn.activePaneId);Ge&&xr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${qr}:${Xn.sessionId}:${Ge.id}:${Ge.width}x${Ge.height}`})},[Xn,qr]);const ka=_.useCallback((ce,Ge=5)=>{const vt=Math.max(1,Math.min(Math.floor(Ge)||1,40));Is.current=!0;const Lt=br.current;if(Lt&&Lt.direction===ce){Lt.lines+=vt;return}Lt&&Do({action:"scroll",direction:Lt.direction,lines:Lt.lines}).finally(()=>{Wn()}),br.current={direction:ce,lines:vt},Qn.current&&clearTimeout(Qn.current),Qn.current=setTimeout(()=>{const et=br.current;et&&(br.current=null,Do({action:"scroll",direction:et.direction,lines:et.lines}).finally(()=>{Wn()}))},0)},[Wn,Do]),Xl=_.useCallback(ce=>{const Ge=Date.now(),vt=es.current,Lt=vt!==null&&vt.modifier===ce&&Ge-vt.timestamp<=vN;if(es.current={modifier:ce,timestamp:Ge},Je===ce){ot(null),xe(null);return}if(Lt){ot(ce),xe(ce);return}Je!==null&&Je!==ce&&ot(null),xe(et=>et===ce?null:ce)},[Je]),fi=_.useCallback(ce=>{if(ut(ce&&dt.current),Te("input focus changed",{focused:ce,isActive:dt.current,isMobile:rr.current}),!rr.current||!dt.current){ct(!1);return}ct(Ge=>Ge===ce?Ge:ce)},[Te]),ei=_.useCallback(ce=>{if(ds.current=ce,Hs(ce,"viewport-watermark"),!ce&&vs.current.length>0){const Ge=V;if(Ge){const vt=vs.current;vs.current=[];for(const Lt of vt)ne(Ge,Lt)}}},[ne,Hs,V]),pi=_.useCallback(ce=>{dt.current&&xr.current?.ensureSizeMatches(ce)},[]),nl=_.useRef(null);_.useEffect(()=>{if(!l)return;const ce=nl.current;if(!ce)return;const Ge=()=>pi("pointerdown"),vt=()=>pi("keydown"),Lt=()=>pi("touchstart"),et=()=>pi("wheel");return ce.addEventListener("pointerdown",Ge),ce.addEventListener("keydown",vt),ce.addEventListener("touchstart",Lt,{passive:!0}),ce.addEventListener("wheel",et,{passive:!0}),()=>{ce.removeEventListener("pointerdown",Ge),ce.removeEventListener("keydown",vt),ce.removeEventListener("touchstart",Lt),ce.removeEventListener("wheel",et)}},[l,pi]);const aa=_.useCallback(ce=>{xr.current=ce},[]),ks=_.useCallback(ce=>{Mt(ce),P?.(V,ce)},[P,V]),Hi=_.useCallback(ce=>{const Ge=UE(ce);if(!Ge)return;const vt=Ht!==null;xr.current?.sendSequence(Ge,{consumeModifier:vt})},[Ht]),La=_.useCallback(ce=>{const Ge=QE(ce);if(Ge.length===0)return;const vt=Ht!==null;xr.current?.sendSequence(n5(Ge[0]),{consumeModifier:vt});for(let Lt=1;Lt<Ge.length;Lt+=1){const et=Ge[Lt];window.setTimeout(()=>{xr.current?.sendSequence(n5(et))},BE*Lt)}},[Ht]),Ia=_.useCallback(()=>{xr.current?.pasteClipboardText()},[]),mi=_.useCallback(ce=>{gn.current!==null&&(window.clearTimeout(gn.current),gn.current=null),Jt(ce),(ce==="inserted"||ce==="failed")&&(gn.current=window.setTimeout(()=>{gn.current=null,Jt("idle")},1400))},[]),_c=_.useCallback(()=>{mi("idle"),Ct(0),dr.current?.click()},[mi]),kc=_.useCallback(()=>{$t(!0)},[]),Jl=_.useCallback(ce=>{const Ge=ce.currentTarget.files?.[0];if(ce.currentTarget.value="",!Ge)return;const vt=V;zr(null),_r(null),Ft(null),Ct(0),mi("uploading");const Lt=Tn&&Ge.type.startsWith("video/")?{maxHeight:bn,videoBitrate:nn,onProgress:Ct}:null,et=Oe&&AN(Ge)?{maxDimension:_t,quality:gt}:null;let Rt=Lt?"视频压缩":et?"图片压缩":"文件上传";(async()=>{const cr=Lt?await(await Yc(async()=>{const{compressVideoLocally:Lr}=await import("./videoCompression-D3y7Bq8J.js");return{compressVideoLocally:Lr}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(Ge,Lt):et?await(await Yc(async()=>{const{compressImageLocally:Lr}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Lr}},[])).compressImageLocally(Ge,et):Ge;Rt="文件上传",await xN(cr,(Lr,I)=>W0(Lr,I,void 0,Ct),Lr=>(Rt="插入终端",c5(I1(Lr,null),vt,()=>dt.current&&!sr.current&&wr.current===vt&&Yr.getState().activeSessionId===vt))),(Lt||et)&&Ft({file:cr,kind:Lt?"video":"image",originalSize:Ge.size,uploadedSize:cr.size,originalRetained:cr===Ge})})().then(()=>mi("inserted"),cr=>{cr instanceof Pf&&zr({path:cr.uploaded.path,sessionId:vt});const Lr=cr instanceof Pf?cr.uploaded.path:f5(cr);_r({stage:Rt,detail:Lr}),$t(!0),mi("failed"),$a("warn","MOBILE_MEDIA_UPLOAD failed",{stage:Rt,detail:Lr})})},[nn,Tn,bn,Oe,_t,gt,V,mi]),Ws=_.useCallback(async()=>{const ce=Nr;if(!ce||ce.sessionId!==V)return;$t(!1),await new Promise(vt=>window.requestAnimationFrame(()=>vt())),mi("uploading"),await c5(I1(ce.path,null),ce.sessionId,()=>dt.current&&!sr.current&&wr.current===ce.sessionId&&Yr.getState().activeSessionId===ce.sessionId)?(zr(null),_r(null),mi("inserted")):($t(!0),mi("failed"))},[Nr,V,mi]);_.useEffect(()=>{if(!Wt||!Tn)return;let ce=!0;return vn(null),Sn({phase:"checking-cache"}),Yc(async()=>{const{prepareLocalVideoCompression:Ge}=await import("./videoCompression-D3y7Bq8J.js");return{prepareLocalVideoCompression:Ge}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:Ge})=>{if(ce)return Ge(vt=>{ce&&Sn(vt)})}).catch(Ge=>{ce&&vn(f5(Ge))}),()=>{ce=!1}},[Wt,Tn]);const ti=mn||Qt!==null;sr.current=ti;const Wi=_.useRef(Jr);ti||(Wi.current=Jr);const Ea=ti?Wi.current:Jr,oa=_.useMemo(()=>PE(Ea,hn),[Ea,hn]),Bo=_.useMemo(()=>i5(hn,xt),[xt,hn]),Ts=!Ke&&xt!=="auto"&&Bo.id!=="default"&&Bo.showOnDesktop!==!0?"auto":xt,Na=Ts==="auto"?oa:Ts,cs=_.useMemo(()=>i5(hn,Na),[Na,hn]),ts=_.useMemo(()=>cs.actions.filter(ce=>ce.sequence.trim().length>0).map((ce,Ge)=>({...ce,label:k1(ce,Ge)})),[cs.actions]),Ss=_.useMemo(()=>Av(Jr),[Jr]),ri=cs.label,Qo=_.useMemo(()=>Ts!=="auto"?`Manual preset: ${cs.label}`:Ss?`Auto preset · ${cs.label} (${Ss})`:"Auto preset",[Ss,Ts,cs.label]),Ga=_.useCallback(ce=>{tr(ce)},[]),la=_.useCallback(()=>{Qr(ce=>ce==="copy"?"arrows":"copy"),St("idle")},[]),Ii=_.useCallback(()=>{typeof window>"u"||(en.current!==null&&window.clearTimeout(en.current),en.current=window.setTimeout(()=>{en.current=null,St("idle")},1200))},[]),io=_.useCallback(ce=>{en.current!==null&&typeof window<"u"&&(window.clearTimeout(en.current),en.current=null),St(ce?"copied":"failed"),Ii()},[Ii]),Gi=_.useCallback(ce=>{K(ce)},[]),Ra=_.useMemo(()=>Ke?OE(hn):FE(hn),[Ke,hn]),Vi=_.useMemo(()=>D8(a),[a]);_.useEffect(()=>{if(!jr||!z||!Ut||!qr)return;const ce=YC(Vi);ce&&le.sendInput(qr,ce).catch(Ge=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",Ge)})},[jr,z,Ut,qr,le,Vi]);const ca=_.useMemo(()=>`terminal::${V}`,[V]),Rs=_.useCallback(()=>`${gr.current??"pending"}:${rt.current}`,[]);_.useEffect(()=>{Re?.({isConnecting:mn,isRestarting:Zn,hasError:!!Qt,sessionId:qr})},[mn,Zn,Qt,qr,Re]);const Ei=!qr||mn||Zn,ao=_.useCallback((ce,Ge)=>{if(Ei)return;const vt=Math.max(1,Math.min(Math.floor(Ge)||1,40));ka(ce,vt)},[ka,Ei]);_.useEffect(()=>{if(!l||!Ke)return;xr.current?.requestRefresh("resize",{skipScrollToBottom:!Xt,force:!0})},[l,Ke,Xt,Bt,V]),_.useEffect(()=>{if(!l||!Ke)return;const ce=Ge=>{const vt=Ge.detail;xr.current?.requestRefresh("resize",{skipScrollToBottom:vt?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",ce),()=>{document.removeEventListener("termdock:viewport-keyboard-change",ce)}},[l,Ke,V]);const Ma=!Z&&(Ke||cs.id==="default"||cs.showOnDesktop===!0),Ni=l,oo=Ke&&!de?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,ec=Ke&&!de?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,kl=s.jsx(zE,{visible:Ma,interactive:Ni,presentation:Ke?"mobile":"desktop-actions",activeModifier:Ht,lockedModifier:Je,disabled:Ei,defaultShowExtended:Nt,presetLabel:ri,presetModeLabel:Qo,presetMode:Ts,presetOptions:Ra,includeAlt:cs.includeAlt,presetRowLayout:cs.rowLayout,extraActions:ts,onKeyPress:Hi,onTextPress:La,onPastePress:Ke?Ia:void 0,onFilePress:Ke?_c:void 0,onFileLongPress:Ke?kc:void 0,fileUploadState:Ot,fileUploadProgress:lt,longPressMode:$e,copyFeedback:Ce,onLongPressModeToggle:la,onModifierToggle:Xl,onPresetSelect:Ga,onExpandedChange:Gi}),Po=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return s.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:oo,"data-owned-terminal-startup":window.__TD_NATIVE_GATE_STATE?JSON.stringify({active:l,viewportReady:Ut,streamReady:z,contentReady:We,sizeReady:wt}):void 0,children:[s.jsx("input",{ref:dr,type:"file",className:"hidden",onChange:Jl}),Wt&&ci.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>$t(!1),"aria-label":Ze("common.close")}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"mobile-video-compression-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] z-modal-panel max-h-[calc(100dvh-1.5rem)] overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:left-1/2 sm:right-auto sm:w-[min(28rem,calc(100vw-2rem))] sm:-translate-x-1/2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"mobile-video-compression-title",className:"text-sm font-semibold text-foreground",children:"本地媒体压缩"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"按文件类型选择压缩方式,处理完成后才上传。"})]}),s.jsx("button",{type:"button",className:"min-h-10 rounded-lg bg-surface-2 px-3 text-xs",onClick:()=>$t(!1),children:Ze("common.close")})]}),ar&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[ar.stage,"失败。",ar.stage.endsWith("压缩")?"原文件未上传。":ar.stage==="插入终端"?"文件已上传,路径见详情。":""]}),s.jsxs("details",{className:"mt-2",children:[s.jsx("summary",{className:"cursor-pointer",children:"错误详情"}),s.jsx("p",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:ar.detail})]}),Nr&&s.jsx("button",{type:"button",onClick:()=>{Ws()},disabled:Ot==="uploading"||Nr.sessionId!==V,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:Ze("common.retry")})]}),bt&&s.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:"本机未能保存设置,重新打开后可能恢复默认值。"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"显示压缩结果提示"}),s.jsx("input",{type:"checkbox",checked:At.showResultToast,onChange:ce=>st({showResultToast:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩图片后上传"}),s.jsx("input",{type:"checkbox",checked:Oe,onChange:ce=>st({imageEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),Oe&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片最长边",s.jsx("select",{value:_t,onChange:ce=>st({imageMaxDimension:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:Iv.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===640?" · 最省流量":ce===2048?" · 推荐":ce===4096?" · 保留更多细节":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片画质:",Math.round(gt*100),"%",s.jsx("input",{type:"range",min:A0.min,max:A0.max,step:A0.step,value:gt,onChange:ce=>st({imageQuality:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"支持 JPEG、PNG、HEIC 照片;GIF、SVG 等保持原文件。压缩后未变小也会保留原图。"})]}),s.jsx("div",{className:"mt-4 border-t border-border/15 pt-1"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩视频后上传"}),s.jsx("input",{type:"checkbox",checked:Tn,onChange:ce=>st({videoEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),Tn&&s.jsxs("div",{className:"mt-4 space-y-4",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["视频最长边(像素)",s.jsx("select",{value:bn,onChange:ce=>st({videoMaxHeight:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:Ev.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===240?" · 最省流量":ce===720?" · 推荐":ce>=1440?" · 手机处理较慢":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",nn/1e6," Mbps",s.jsx("input",{type:"range",min:T0.min,max:T0.max,step:T0.step,value:nn,onChange:ce=>st({videoBitrate:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"保持比例,不放大原视频。尺寸越小通常处理越快;码率越低体积通常越小,过高可能比原片更大。"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",role:"status","aria-live":"polite",children:Mn?"本地转码器准备失败,请关闭开关后重试。":TN(Ar)}),Ar?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),Mn&&s.jsx("p",{className:"text-[11px] text-destructive",children:Mn})]})]})]}),document.body),lr&&s.jsx(HE,{isMobile:Ke,isInputFocused:at,isIOS:ae,isConnecting:mn,connectionError:Qt,terminalSessionId:qr}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Vi.background,...ec},children:[s.jsx("div",{ref:nl,className:"h-full w-full box-border",children:s.jsx(B8,{fallback:s.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("span",{className:"text-sm text-muted-foreground",children:Ze("terminal.componentFailed")})]})}),children:s.jsx(_E,{ref:aa,sessionKey:ca,sessionId:V,getPasteOwnerKey:Rs,backendSessionId:qr,isLayoutVisible:m,chunks:zn,onInput:jo,onResize:so,onFlowControl:ei,onTmuxScroll:jr?ao:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Ke?()=>{xr.current?.sendSequence(" ")}:void 0,onInputFocusChange:fi,onMobileLongPressCopyResult:io,onReadyChange:ks,onSizeSynchronizedChange:Zt,onWritesSettled:fs,onWriteProgress:zi,onCursorPositionChange:Zl,onDirectoryLinkActivate:Wr,terminalSettings:De,theme:Vi,enableTouchScroll:Ke,mobileLongPressMode:$e,autoFocus:l&&!Me&&!Ke&&!Po,inputActive:l&&!Me,cursorVisible:!Me&&nr,suppressSmoothScroll:!We||!wt,className:Me||!nr?"terminal-focus-suspended":void 0},ca)})}),s.jsx(yN,{result:Tt,onDismiss:we}),s.jsx(GE,{connectionError:Qt,isFatalError:$r,isRestarting:Zn,isConnecting:mn,onHardRestart:rl})]}),G?Z?null:ci.createPortal(kl,G):kl]})};function _N({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=Gr(),c=Yr(l=>{const d=l.sessions.get(e.id);return yl(e,d?.activeProgram??null,d?.cwd??null,void 0,d?.shellTitle??null,d?.promptState??null).primary});return s.jsxs("div",{"data-pane-titlebar":"true",className:"swiper-no-swiping flex h-6 min-h-6 shrink-0 items-center border-b border-border app-chrome-bg",children:[s.jsxs("button",{type:"button","data-split-pane-title":e.id,draggable:!1,onDragStart:l=>l.preventDefault(),"aria-pressed":t,title:`${c} · 拖动标题移动,边缘拆分,中央交换`,onClick:r,className:"split-pane-drag-handle flex h-full min-w-0 cursor-grab active:cursor-grabbing flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-[12px] font-medium leading-none text-foreground hover:bg-surface focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:[s.jsx(el,{size:11,className:`shrink-0 ${t?"text-primary":"text-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),s.jsx(ap,{size:12,"aria-hidden":"true",className:"shrink-0 text-muted-foreground"}),t&&s.jsx("span",{"aria-hidden":"true",className:"h-1 w-1 shrink-0 rounded-full bg-primary"})]}),n&&s.jsx("button",{type:"button",onClick:n,"aria-label":a("tab.explorerTitle"),title:a("tab.explorerTitle"),className:"inline-flex h-full w-7 shrink-0 items-center justify-center text-muted-foreground hover:bg-surface hover:text-foreground focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:s.jsx(d3,{size:14})})]})}const kN="termdock:startup:";function qu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${kN}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function p5(e,t){e||ci.flushSync(t)}const E1="horizontal";function ed(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function mf(e,t){if(!Array.isArray(e)||e.length!==t)return ed(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return ed(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?ed(t):r.map(a=>a/n)}function LN(e){const t=Math.max(1,Math.ceil(Math.sqrt(Math.max(1,e))));return{columns:t,rows:Math.max(1,Math.ceil(Math.max(1,e)/t))}}function IN(e){return e==="horizontal"||e==="vertical"||e==="grid"}function EN(e){if(!Array.isArray(e))return[];const t=new Set,r=new Set,n=[];for(const a of e){if(!a||typeof a!="object")continue;const c=a;if(typeof c.id!="string"||!c.id||r.has(c.id))continue;const l=Array.isArray(c.sessionIds)?c.sessionIds.filter(m=>typeof m=="string"&&!!m&&!t.has(m)):[],d=[...new Set(l)];if(d.length<2)continue;const f=LN(d.length);d.forEach(m=>t.add(m)),r.add(c.id),n.push({id:c.id,...typeof c.name=="string"&&c.name.trim()?{name:c.name.trim().slice(0,80)}:{},sessionIds:d,layout:IN(c.layout)?c.layout:E1,ratios:mf(c.ratios,d.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:mf(c.gridColumnRatios,f.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:mf(c.gridRowRatios,f.rows)}:{}})}return n}function NN(e,t){const r=new Set(t);return e.flatMap(n=>{const a=n.sessionIds.filter(c=>r.has(c));return a.length<2?[]:[{...n,sessionIds:a,ratios:a.length===n.sessionIds.length?mf(n.ratios,a.length):ed(a.length)}]})}function B0(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function wm(e,t,r){if(!t||!r||t===r)return e;const n=B0(e,t),a=B0(e,r);if(n&&n.id===a?.id)return e;const c=[...n?.sessionIds??[t],...a?.sessionIds??[r]],l=[...new Set(c)],d={id:n?.id??`split:${t}`,...n?.name?{name:n.name}:{},sessionIds:l,layout:l.length>2&&(!n||n.layout===E1)?"grid":n?.layout??E1,ratios:ed(l.length)},f=new Set([n?.id,a?.id].filter(Boolean)),m=e.filter(y=>!f.has(y.id)),x=n?Math.max(0,e.findIndex(y=>y.id===n.id)):m.length;return m.splice(Math.min(x,m.length),0,d),m}function RN(e,t){const r=B0(e,t);if(!r||!t)return e;if(r.sessionIds.length<=2)return e.filter(a=>a.id!==r.id);const n=r.sessionIds.filter(a=>a!==t);return e.map(a=>a.id===r.id?{...a,sessionIds:n,ratios:ed(n.length)}:a)}function MN(e,t){const r=B0(e,t);return r?e.filter(n=>n.id!==r.id):e}function jN(e,t,r){return e.map(n=>{if(n.id!==t)return n;const a=[...new Set(r)],c=new Set(n.sessionIds);return a.length===n.sessionIds.length&&a.every(d=>c.has(d))?{...n,sessionIds:a}:n})}function DN(e,t,r){const n=r.trim().slice(0,80);return e.map(a=>a.id===t?{...a,...n?{name:n}:{name:void 0}}:a)}const N1=320,Rv=1,BN=N1+120,R1="termdock:split-workspaces:v2",Mv="termdock:split-workspace:v1",QN=.1,PN=.9;function Am(){if(typeof window>"u")return{mobile:!1,landscape:!1};const e=Gy();return{mobile:e,landscape:e&&window.innerWidth>window.innerHeight}}function ON(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(R1);if(e)return EN(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(Mv)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(PN,Math.max(QN,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[r,1-r]}]}}catch{}return[]}function FN(e,t){const r=new Map(e.map(l=>[l.id,l])),n=new Map;t.forEach(l=>l.sessionIds.forEach(d=>n.set(d,l)));const a=new Set,c=[];for(const l of e){const d=n.get(l.id);if(!d){c.push({key:l.id,sessions:[l]});continue}if(a.has(d.id))continue;a.add(d.id);const f=d.sessionIds.flatMap(m=>{const x=r.get(m);return x?[x]:[]});f.length>=2&&c.push({key:d.id,sessions:f,workspace:d})}return c}function m5(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function Qh(e,t){const r=Of(e,t);if(r===null)return;const n=e.wrapperEl;m5(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),m5(e),n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}catch{n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}}function M1(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function Of(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function $N(e,t){const r=M1(e),n=Of(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=Rv}function UN(e){const t=[],r=new Map,n=new Map,a=new Map;for(const c of e){const l=r.get(c.id)??[];if(l.push(c.id),r.set(c.id,l),c.sessionId){const d=n.get(c.sessionId)??[];d.push(c.id),n.set(c.sessionId,d)}if(c.mode==="tmux"&&c.tmuxSessionName){const d=a.get(c.tmuxSessionName)??[];d.push(c.id),a.set(c.tmuxSessionName,d)}}for(const[c,l]of r)l.length>1&&t.push({kind:"frontend",key:c,sessionIds:l});for(const[c,l]of n)l.length>1&&t.push({kind:"backend",key:c,sessionIds:l});for(const[c,l]of a)l.length>1&&t.push({kind:"tmux",key:c,sessionIds:l});return t}function jv(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function Dv(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function zN(e,t){const r=jv(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function g5(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...Dv(n),history:a?.history}})}function x5(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function b5(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function y5(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function HN(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t)if(e.get(r)!==n)return!1;return!0}function WN(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const r=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`wt-${r}${n}`}const GN=({terminalSettings:e=wg(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:c="shell",defaultTmuxSessionName:l="",connectionPrioritySessionId:d=null,connectionPriorityReady:f=!0,desktopRightSidebarEnabled:m=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopLeftSidebarPinned:w=!1,desktopPinnedLeftSidebarWidth:v=0,desktopViewportWidth:T=0,onStatusChange:C,onSessionDataUpdate:L,onInitialViewportReady:N,onInitialRecoveryRequired:D})=>{const{t:O}=Gr(),P=y&&!w&&na()?.platform==="darwin"&&document.documentElement.dataset.termdockPreview==="true",F=b.useMemo(()=>rd("session"),[]),ee=b.useMemo(()=>rd("terminal"),[]),[Z,G]=b.useState([]),[de,pe]=b.useState(null),J=b.useRef(0),Re=b.useRef(0),Ze=ss(R=>R.activePaneId);b.useEffect(()=>{ss.getState().setActivePane(de)},[de]);const[V,ve]=b.useState(null),[qe,le]=b.useState(!0),[ye,Te]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[Fe,se]=b.useState(()=>new Set),[De,_e]=b.useState(()=>({token:0,completed:new Set})),[Me,Ke]=b.useState(0),[Ne,ae]=b.useState(()=>new Set),[ze,at]=b.useState(()=>new Set),ct=b.useRef(new Map),[me,ut]=b.useState(()=>new Set),ft=b.useRef(!1),Se=b.useRef(null),He=b.useRef({}),[ke,z]=b.useState(null),[ie,ge]=b.useState(()=>ON()),[We,tt]=b.useState(!1),wt=b.useCallback(R=>{J.current+=1,tt(R)},[]),Zt=b.useRef(null),Ut=b.useRef(We);Ut.current=We,ru(Zt,We&&!!de,()=>wt(!1));const[Mt,nr]=b.useState(null),[jt,Xt]=b.useState(null),Bt=b.useRef(new Set),[Ht,xe]=b.useState(null),[Je,ot]=b.useState(null),[Nt,K]=b.useState(!1),[xt,tr]=b.useState(()=>Am().mobile),[$e,Qr]=b.useState(()=>Am().landscape),[Ce,St]=b.useState(null),[Ot,Jt]=b.useState(null),lt=b.useRef(a),Ct=b.useRef(!1),ar=b.useRef(!1),_r=b.useRef(null),Nr=b.useRef(null),zr=b.useRef(xt),Tt=b.useRef(null),Ft=b.useCallback(R=>{R!==Tt.current&&(J.current+=1),Tt.current=R,pe(R)},[]);b.useEffect(()=>Vt.subscribe((R,U)=>{(R.rightOpen!==U.rightOpen||R.rightTab!==U.rightTab)&&(J.current+=1)}),[]);const we=b.useRef(0),At=b.useRef([]),st=b.useRef(0),bt=b.useRef(null),Tn=b.useRef(!1),bn=b.useRef(!0),nn=b.useRef(null),Oe=b.useRef(""),_t=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const R=()=>{const U=Am();zr.current=U.mobile,tr(U.mobile),Qr(U.landscape)};return R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);const{sessions:gt,inventory:Wt,activeSessionId:$t,isLoading:Ar,openSession:Sn,setActiveSession:Mn,removeSession:vn,renameSession:dn,resetSessionCustomName:kn,reorderSessions:Hr,restoreSessions:ne}=Q8(),Xe=Wt?.tmuxRecovery??null;b.useEffect(()=>{Xe&&D?.()},[Xe,D]),b.useEffect(()=>{ot(null),xe(null)},[Xe?.id]);const Dt=b.useCallback(async()=>{xe("restore"),ot(null);try{const R=await P8(Xe?.id);await ne(),R.accepted||ot(O("tab.tmuxRecoveryFailed"))}catch{ot(O("tab.tmuxRecoveryFailed"))}finally{xe(null)}},[ne,O,Xe?.id]),ur=b.useCallback(async()=>{const R=Xe?.operation;if(R)try{await O8(R.id,!R.paused),await ne()}catch{ot(O("tab.tmuxRecoveryFailed"))}},[ne,O,Xe?.operation]),Fr=b.useCallback(async()=>{xe("dismiss"),ot(null);try{await F8(),await ne()}catch{ot(O("tab.tmuxRecoveryDismissFailed"))}finally{xe(null)}},[ne,O]),Zr=Vt(R=>R.groupByFolder),an=If(R=>R.collaborationGroups),Mr=Vt(R=>R.leftOpen||R.rightOpen),Vr=Vt(R=>R.rightSidebarWidthContextKey),Ln=Vt(R=>R.rightSidebarWidth),tn=Vt(R=>R.rightPinned),[Ur,Xr]=b.useState(()=>y5(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(R=>{const U=y5(R.sessions);Xr(X=>HN(X,U)?X:U)}),[]);const{arranged:vr}=b.useMemo(()=>kf(Z,R=>Ur.get(R.id)??null,Zr,"",ie,an),[Z,Ur,Zr,ie,an]),on=b.useRef(vr);on.current=vr;const Jr=b.useMemo(()=>FN(vr,ie),[vr,ie]),hn=b.useRef(Jr);hn.current=Jr;const jr=b.useMemo(()=>B0(ie,de),[de,ie]),zn=b.useMemo(()=>{const R=Jr.find(U=>U.sessions.some(X=>X.id===de));return new Set(R?.sessions.map(U=>U.id)??[])},[de,Jr]),mn=b.useMemo(()=>{const R=new Map;if(!m||T<=0)return R;for(const U of Jr){const X=U.sessions[0];if(!X)continue;const be=$8(X.id,Ur.get(X.id)??null,U.workspace?.id??null);if(!(be===Vr?tn:U8(X.id,Ur.get(X.id)??null,U.workspace?.id??null)))continue;const Ve=be===Vr?Ln:z8(X.id,Ur.get(X.id)??null,U.workspace?.id??null),dt=tf(Ve,T,v);R.set(U.key,dt+Vy)}return R},[Ur,v,m,tn,Vr,Ln,T,Jr]),qr=b.useMemo(()=>ym(Z.map(R=>({id:R.id,backendSessionId:R.sessionId})),d),[d,Z]),Wr=b.useMemo(()=>x5(gt,$t),[$t,gt]),Y=Dh({prioritySessionId:qr,activeSessionId:V??de,persistedActiveSessionId:Wr,firstSessionId:Z[0]?.id??null}),Be=b.useMemo(()=>hN(Jr.flatMap(R=>R.sessions.map(U=>U.id)),zn),[zn,Jr]),Qt=Y!==null&&Fe.has(Y),er=b.useMemo(()=>{const R=new Set(zn);return V&&R.add(V),!R.size&&Y&&R.add(Y),R},[zn,V,Y]),sr=De.token===ye.token&&lN(er,De.completed),$r=sr||Me===ye.token?ye.token:-1;b.useEffect(()=>{if(!ye.token||sr)return;const R=window.setTimeout(()=>Ke(ye.token),KE);return()=>window.clearTimeout(R)},[ye.token,sr]);const Ir=b.useCallback((R,U)=>{se(X=>{if(X.has(R)===U)return X;const Ee=new Set(X);return U?Ee.add(R):Ee.delete(R),Ee})},[]),Zn=b.useCallback(R=>{const U=we.current;_e(be=>{if(be.token===U&&be.completed.has(R))return be;const Ee=new Set(be.token===U?be.completed:[]);return Ee.add(R),{token:U,completed:Ee}});const X=qr??V??Tt.current;R===X&&qu("foreground-stream-connected")},[V,qr]),ys=b.useCallback((R,U)=>{ae(X=>{if(X.has(R)===U)return X;const be=new Set(X);return U?be.add(R):be.delete(R),be})},[]),is=b.useCallback((R,U)=>{at(X=>{if(X.has(R)===U)return X;const be=new Set(X);return U?be.add(R):be.delete(R),be})},[]);b.useEffect(()=>{for(const[R,U]of ct.current){const X=Z.find(be=>be.id===R);if(!X||X.sessionId!==U.backendSessionId){ct.current.delete(R);continue}!Fe.has(R)||!Ne.has(R)||!ze.has(R)||(ct.current.delete(R),Wy(U.backendSessionId,`${U.command}\r`).catch(be=>{console.error("[Session] Failed to send startup command:",be)}))}},[Z,Fe,Ne,ze]);const Hn=Y!==null&&Ne.has(Y),fn=Y!==null&&ze.has(Y);b.useEffect(()=>{Hn&&qu("foreground-viewport-ready")},[Hn]),b.useEffect(()=>{fn&&qu("foreground-content-ready")},[fn]),b.useEffect(()=>{if(!N)return;if(!qe&&Z.length===0){N();return}if(!Hn||!Qt||!fn)return;const R=[...zn].every(Ve=>Ne.has(Ve)&&Fe.has(Ve)&&ze.has(Ve));let U=0,X=0;const be=()=>{U=requestAnimationFrame(()=>{X=requestAnimationFrame(()=>{qu("initial-viewport-presented"),N()})})};R&&be();const Ee=R?void 0:window.setTimeout(be,8e3);return()=>{cancelAnimationFrame(U),cancelAnimationFrame(X),clearTimeout(Ee)}},[Qt,fn,Hn,qe,N,Z.length,zn,Ne,Fe,ze]);const Bn=b.useMemo(()=>xt?eN({slides:Jr.map(R=>R.sessions.map(U=>U.id)),visibleSessionIds:zn,foregroundSessionId:Y}):me,[xt,Jr,zn,Y,me]);b.useEffect(()=>{if(xt||zn.size===0)return;const R=new Set(zn),U=Jr.findIndex(X=>X.sessions.some(be=>zn.has(be.id)));for(let X=-2;X<=2;X+=1)X!==0&&Jr[U+X]?.sessions.forEach(be=>R.add(be.id));ut(X=>{let be=!1;const Ee=new Set(X);for(const Ve of R)Ee.has(Ve)||(Ee.add(Ve),be=!0);return be?Ee:X})},[xt,zn,Jr]);const Xn=NC(Bn);b.useEffect(()=>{if(!V)return;if(!Z.some(U=>U.id===V)){ve(null);return}if(!Ne.has(V)||!Fe.has(V)||!ze.has(V))return;const R=window.setTimeout(()=>{ve(U=>U===V?null:U),lt.current&&!zr.current&&z({sessionId:V,token:Date.now()})},80);return()=>window.clearTimeout(R)},[ze,V,Fe,Z,Ne]),b.useEffect(()=>{typeof window>"u"||(ie.length>0?(window.localStorage.setItem(R1,JSON.stringify(ie)),window.localStorage.removeItem(Mv)):window.localStorage.removeItem(R1))},[ie]),b.useEffect(()=>{Ar||qe||ie.length===0||ge(R=>NN(R,Z.map(U=>U.id)))},[Ar,qe,Z,ie.length]),b.useEffect(()=>{if(!Mt)return;const R=window.setTimeout(()=>nr(null),3200);return()=>window.clearTimeout(R)},[Mt]),Tt.current=de,we.current=ye.token,At.current=Z,bt.current=$t,Tn.current=Ar,bn.current=qe,lt.current=a;const pn=b.useCallback((R=Se.current)=>{const U=st.current,X=typeof window<"u"?window.visualViewport:null,be=R?M1(R):null,Ee=R?Of(R,U):null;return{sessionsLength:At.current.length,workspaceSlidesLength:hn.current.length,sessionIds:At.current.map(Ve=>Ve.id),activeSessionId:Tt.current,activeSessionIndex:U,persistedActiveId:bt.current,isLoading:Tn.current,isRestoring:bn.current,activeIndex:R?.activeIndex??null,previousIndex:R?.previousIndex??null,animating:R?.animating??null,allowTouchMove:R?.allowTouchMove??null,width:R?.width??null,translate:be,targetTranslate:Ee,translateDelta:be!==null&&Ee!==null?be-Ee:null,snapGridLength:R?.snapGrid?.length??null,targetSnap:R?.snapGrid?.[U]??null,visualViewport:X?{width:Math.round(X.width),height:Math.round(X.height),offsetTop:Math.round(X.offsetTop)}:null}},[]),lr=b.useCallback((R,U)=>{F(R,{...pn(),...U})},[F,pn]);b.useEffect(()=>{Ar||qe||de!==$t&&Mn(de)},[de,Ar,qe,$t,Mn]);const as=b.useMemo(()=>{if(vr.length===0||!de)return 0;const R=Jr.findIndex(U=>U.sessions.some(X=>X.id===de));return R>=0?R:0},[Jr,de]);st.current=as;const rn=b.useCallback(()=>{_r.current&&(clearTimeout(_r.current),_r.current=null)},[]),gr=b.useCallback(R=>{rn(),_r.current=setTimeout(()=>{_r.current=null,Ct.current=!1,lr("[swiper:touch-guard-clear]",{reason:R})},BN)},[rn,lr]),wr=b.useCallback((R,U={})=>{const X=Se.current,be=st.current,Ee=hn.current;if(!X||Ee.length===0||be<0||be>=Ee.length)return;if(Ct.current){lr("[swiper:sync-skip-touch]",{reason:R});return}if(X.animating){lr("[swiper:sync-skip-animating]",{reason:R});return}const Ve=M1(X),dt=Of(X,be),Qe=Ve!==null&&dt!==null&&Math.abs(Ve-dt)<=Rv,ir=X.activeIndex===be;if(lr("[swiper:sync-check]",{reason:R,activeIndexAligned:ir,translateAligned:Qe,immediate:U.immediate===!0}),!(ir&&Qe)){if(ir){Qh(X,be),lr("[swiper:sync-forced-active]",{reason:R,translateAligned:Qe,immediate:U.immediate===!0});return}U.immediate?(Qh(X,be),X.slideTo(be,0,!1),Qh(X,be)):X.slideTo(be,N1,!1),lr("[swiper:sync-applied]",{reason:R,activeIndexAligned:ir,translateAligned:Qe,immediate:U.immediate===!0})}},[lr]);b.useEffect(()=>{const R=U=>{const X=U;Se.current&&(Se.current.allowTouchMove=!X.detail.locked),lr("[swiper:gesture-lock]",{locked:X.detail.locked})};return document.addEventListener("termdock:gesture-lock",R),()=>document.removeEventListener("termdock:gesture-lock",R)},[lr]),b.useEffect(()=>{if(Z.length===0){de!==null&&Ft(null);return}if(!de){if(!f)return;Ft(Dh({prioritySessionId:qr,activeSessionId:null,persistedActiveSessionId:Wr,firstSessionId:Z[0]?.id??null}));return}Z.some(U=>U.id===de)||Ft(Z[0].id)},[Z,de,f,qr,Wr]);const xr=b.useCallback((R,U)=>{if(U&&Date.now()<_t.current){He.current[R]=!1;return}He.current[R]=U,Jt(X=>U?R:X===R?null:X)},[]),ds=b.useCallback(R=>{if(!Ct.current&&R.activeIndex!==st.current){lr("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:R.activeIndex,expectedActiveIndex:st.current}),requestAnimationFrame(()=>wr("ignored-layout-slide-change",{immediate:!0}));return}const U=hn.current[R.activeIndex],X=U?.sessions.some(Ve=>Ve.id===de)?de:U?.sessions[0]?.id;if(lr("[swiper:slide-change]",{nextSessionId:X??null,instanceActiveIndex:R.activeIndex}),!X||X===de)return;const be=!!de&&He.current[de]===!0,Ee=lt.current&&(!zr.current||be);if(Nr.current=X,Ft(X),Ee){z({sessionId:X,token:Date.now()});return}z(null)},[Z,de,lr,wr]);b.useLayoutEffect(()=>{if(Nr.current===de){lr("[swiper:sync-skip-swiper-driven]",{activeSessionId:de}),Nr.current=null;return}wr("active-session-index",{immediate:!0})},[de,as,Z.length,wr,lr]),b.useEffect(()=>{const R=Se.current;if(!R)return;const U=Jr.length>1&&!Mr&&!We;R.allowTouchMove!==U&&(R.allowTouchMove=U,lr("[swiper:allow-touch-sync]",{nextAllow:U,sidebarOverlayOpen:Mr}))},[Jr.length,lr,Mr,We]);const jn=b.useCallback(R=>{const U=Se.current;if(!U)return;const X=U.el;if(lr("[swiper:layout-before]",{reason:R,scrollLeft:X?.scrollLeft??null}),X&&(X.scrollLeft=0),U.updateSize(),U.updateSlides(),U.updateProgress(),U.updateSlidesClasses(),X&&(X.scrollLeft=0),lr("[swiper:layout-after]",{reason:R,scrollLeft:X?.scrollLeft??null}),Ct.current||U.animating){lr("[swiper:layout-skip-sync-motion]",{reason:R});return}wr(`layout:${R}`,{immediate:!0}),requestAnimationFrame(()=>{const be=Se.current;be&&(Ct.current||be.animating||Qh(be,st.current))})},[lr,wr]);b.useEffect(()=>()=>rn(),[rn]);const vs=Jr.map(R=>R.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>jn("group-change"))},[Zr,vs,jn]),b.useEffect(()=>{let R=null,U="mount";const X=Qe=>{U=Qe,R===null&&(R=requestAnimationFrame(()=>{R=null,jn(`viewport-change:${U}`)}))},be=()=>X("window-resize"),Ee=()=>X("visual-viewport-resize"),Ve=()=>X("visual-viewport-scroll"),dt=Qe=>{X(`measured:${Qe.detail?.source??"unknown"}`)};return window.addEventListener("resize",be),window.visualViewport?.addEventListener("resize",Ee),window.visualViewport?.addEventListener("scroll",Ve),document.addEventListener(Lx,dt),X("mount"),()=>{window.removeEventListener("resize",be),window.visualViewport?.removeEventListener("resize",Ee),window.visualViewport?.removeEventListener("scroll",Ve),document.removeEventListener(Lx,dt),R!==null&&cancelAnimationFrame(R)}},[jn]),b.useEffect(()=>{if(typeof document>"u")return;let R=null,U=null;const X=ir=>{if(ir!=="online"&&document.hidden)return;const rr=performance.now();if(!cN(U,rr))return;U=rr;const Et=ir==="bfcache"||ir==="online"?ir:"visibility",kr=uN();Fp(),$a("info","PWA_RESUME scheduled",{source:ir,forceForegroundReconnect:kr,activeSessionId:Tt.current}),Te(ln=>({token:ln.token+1,reason:Et,forceForegroundReconnect:kr})),requestAnimationFrame(()=>jn(`resume:${ir}:raf`)),R&&clearTimeout(R),R=setTimeout(()=>{R=null,jn(`resume:${ir}:settled`)},320)},be=()=>{if(document.hidden){Fp();return}X("visibility")},Ee=()=>{Fp()},Ve=ir=>{X(ir.persisted?"bfcache":"pageshow")},dt=()=>X("online"),Qe=()=>X("focus");return document.addEventListener("visibilitychange",be),window.addEventListener("pagehide",Ee),window.addEventListener("pageshow",Ve),window.addEventListener("online",dt),window.addEventListener("focus",Qe),()=>{document.removeEventListener("visibilitychange",be),window.removeEventListener("pagehide",Ee),window.removeEventListener("pageshow",Ve),window.removeEventListener("online",dt),window.removeEventListener("focus",Qe),R&&clearTimeout(R)}},[jn]),b.useLayoutEffect(()=>{if(!aN(qe))return;const R=UN(Z),U=JSON.stringify(R);R.length>0&&U!==Oe.current?(Oe.current=U,console.warn("[session-invariant] duplicate mapping detected",R)):R.length===0&&Oe.current&&(Oe.current=""),L?.({sessions:Z.map(X=>({id:X.id,name:X.name,customName:X.customName,mode:X.mode,tmuxSessionName:X.tmuxSessionName})),activeSessionId:de,splitWorkspaces:ie.map(({id:X,name:be,sessionIds:Ee,layout:Ve})=>({id:X,...be?{name:be}:{},sessionIds:Ee,layout:Ve}))})},[Z,de,ie,L,qe]),b.useEffect(()=>{if(Ar||ft.current)return;ft.current=!0;const R=ym(gt.map(Ve=>({id:Ve.sessionId,backendSessionId:Ve.backendSessionId??null})),d),U=x5(gt,$t),X=Dh({prioritySessionId:f?R:null,activeSessionId:null,persistedActiveSessionId:U,firstSessionId:gt[0]?.sessionId??null}),be=jv(gt.map(Dv));if(F("[Session] Restoring",be.length,"persisted sessions (one-shot)"),lr("[swiper:restore-start]",{persistedSessionIds:gt.map(Ve=>Ve.sessionId),nextActiveSessionId:X}),be.length>0){const Ve=Yr.getState();be.forEach(Qe=>{Qe.sessionId&&Ve.setTerminalSession(Qe.id,{sessionId:Qe.sessionId,cols:80,rows:24,mode:Qe.mode,tmuxSessionName:Qe.tmuxSessionName,history:Qe.history})}),gt.forEach(Qe=>{Qe.agent!==void 0&&Ve.setSessionAgentIdentity(Qe.sessionId,Qe.agent),Qe.activeProgram!=null&&Ve.setSessionActiveProgram(Qe.sessionId,Qe.activeProgram),Qe.cwd!=null&&Ve.setSessionCwd(Qe.sessionId,Qe.cwd),Qe.shellTitle!=null&&Ve.setSessionShellTitle(Qe.sessionId,Qe.shellTitle)}),G(be);const dt=X||be[0]?.id||null;Ft(dt),lr("[swiper:restore-complete]",{restoredSessionIds:be.map(Qe=>Qe.id),nextActiveSessionId:dt})}(async()=>(be.length===0&&await nn.current?.({createIfEmpty:!0}),le(!1),requestAnimationFrame(()=>wr("restore-finished",{immediate:!0}))))()},[Ar,gt,$t,F,lr,wr,f,d]),b.useEffect(()=>{if(!f||qe||Z.length===0)return;const R=ym(Z.map(X=>({id:X.id,backendSessionId:X.sessionId})),d),U=Dh({prioritySessionId:R,activeSessionId:Tt.current,persistedActiveSessionId:Wr,firstSessionId:Z[0]?.id??null});U&&U!==Tt.current&&Ft(U)},[f,d,qe,Wr,Z]);const Qs=b.useRef([]),Is=b.useRef(!1);Tt.current=de,b.useEffect(()=>{if(qe)return;const R=Qs.current,U=gt,X=new Map(R.map(Et=>[Et.sessionId,Et])),be=Yr.getState();for(const Et of U){const kr=X.get(Et.sessionId),ln=Yr.getState().sessions.get(Et.sessionId);Et.agent!==void 0&&JSON.stringify(Et.agent)!==JSON.stringify(ln?.agent)&&(ln?.agent==null||JSON.stringify(Et.agent)!==JSON.stringify(kr?.agent))&&be.setSessionAgentIdentity(Et.sessionId,Et.agent),Et.activeProgram!=null&&Et.activeProgram!==ln?.activeProgram&&(ln?.activeProgram==null||Et.activeProgram!==kr?.activeProgram)&&be.setSessionActiveProgram(Et.sessionId,Et.activeProgram),Et.cwd!=null&&Et.cwd!==ln?.cwd&&(ln?.cwd==null||Et.cwd!==kr?.cwd)&&be.setSessionCwd(Et.sessionId,Et.cwd),Et.shellTitle!=null&&Et.shellTitle!==ln?.shellTitle&&(ln?.shellTitle==null||Et.shellTitle!==kr?.shellTitle)&&be.setSessionShellTitle(Et.sessionId,Et.shellTitle)}if(!Is.current){G(Et=>g5(Et,U)),Qs.current=U,Is.current=!0;return}const Ee=new Set(R.map(Et=>Et.sessionId)),Ve=new Set(U.map(Et=>Et.sessionId)),dt=new Map(R.map(Et=>[Et.sessionId,Et.name]));Qs.current=U,G(Et=>{const kr=g5(Et,U);return(!Tt.current||!kr.some(ln=>ln.id===Tt.current))&&Ft(kr[0]?.id??null),kr});const Qe=U.filter(Et=>!Ee.has(Et.sessionId)),ir=[...Ee].filter(Et=>!Ve.has(Et)),rr=U.filter(Et=>Ee.has(Et.sessionId)&&dt.get(Et.sessionId)!==Et.name);(Qe.length>0||ir.length>0||rr.length>0)&&F("[Session] Synced persisted sessions:",{newSessionIds:Qe.map(Et=>Et.sessionId),removedSessionIds:ir,renamedSessionIds:rr.map(Et=>Et.sessionId),currentSessionIds:U.map(Et=>Et.sessionId)});for(const Et of U){if(!Et.backendSessionId)continue;Yr.getState().setTerminalSession(Et.sessionId,{sessionId:Et.backendSessionId,cols:80,rows:24,mode:Et.mode,tmuxSessionName:Et.tmuxSessionName})}},[gt,qe,F]);const Or=b.useCallback(async R=>{const U=++Re.current,X=J.current,be=()=>U===Re.current&&X===J.current&&(R?.shouldActivate?.()??!0);try{const Ee=Vt.getState(),Ve=de?{rightOpen:Ee.rightOpen,rightPinned:Ee.rightPinned,rightSidebarWidth:Ee.rightSidebarWidth,rightTab:Ee.rightTab}:null,dt=R?.mode==="tmux"||R?.mode==="shell"?R.mode:c,Qe=(R?.tmuxSessionName||"").trim(),ir=l.trim(),rr=dt==="tmux"?Qe||ir||WN():null,Et=typeof R?.cwd=="string"?R.cwd:null,kr=de?Yr.getState().sessions.get(de)?.cwd??null:null,ln=typeof Et=="string"&&Et.trim().length>0?Et:typeof kr=="string"&&kr.trim().length>0?kr:void 0,yn=await Sn({preferredFrontendSessionId:R?.preferredFrontendSessionId,requireExisting:R?.requireExisting===!0,mode:dt,tmuxSessionName:rr,cwd:ln,termType:"xterm-256color",createIfEmpty:R?.createIfEmpty===!0},{shouldActivate:be});if(yn.discarded)return R?.onResult?.({ok:!1,error:"unknown"}),null;const en=yn.session,gn=yn.terminalSession;!yn.reused&&Ve&&Vt.getState().initializeRightSidebarForSession(en.sessionId,gn.cwd??ln??null,Ve);const dr={id:en.sessionId,name:en.name,customName:en.customName===!0,sessionId:gn.sessionId,mode:gn.mode??en.mode,tmuxSessionName:gn.tmuxSessionName??en.tmuxSessionName},pr=R?.command?.trim();return pr&&ct.current.set(dr.id,{backendSessionId:gn.sessionId,command:pr}),G(ws=>zN(ws,dr)),be()&&Ft(dr.id),Yr.getState().setTerminalSession(dr.id,{sessionId:gn.sessionId,cols:80,rows:24,mode:dr.mode,tmuxSessionName:dr.tmuxSessionName,activeProgram:gn.activeProgram,activeProgramRaw:gn.activeProgramRaw,activeProgramSource:gn.activeProgramSource,cwd:gn.cwd}),F("[Session] Inventory opened session:",{frontendSessionId:dr.id,backendSessionId:gn.sessionId,reused:yn.reused,mode:dr.mode,tmuxSessionName:dr.tmuxSessionName}),R?.onResult?.({ok:!0,sessionId:dr.id}),dr.id}catch(Ee){return console.error("[Session] Failed to create new session:",Ee),R?.onResult?.({ok:!1,error:yC(Ee)}),null}},[c,l,de,Sn,F]);nn.current=Or;const br=b.useCallback((R,U={})=>{J.current+=1,ss.getState().setActivePane(R);const X=Tt.current,be=!!X&&He.current[X]===!0;if(Ft(R),zr.current&&U.preserveMobileKeyboard===!1){_t.current=Date.now()+600,X&&(He.current[X]=!1),Jt(null),z(null);const Ee=document.activeElement;Ee instanceof HTMLTextAreaElement&&Ee.closest(".terminal-viewport-container")&&Ee.blur();return}be&&zr.current&&Jt(R),lt.current&&(!zr.current||be)&&z({sessionId:R,token:Date.now()})},[]),Qn=b.useCallback(R=>{Ft(R),wt(!0),nr(null)},[]),Jn=b.useCallback(R=>{const U=Tt.current;!U||U===R||(ge(X=>wm(X,U,R)),wt(!1),br(U,{preserveMobileKeyboard:!1}))},[br]),es=b.useCallback(async()=>{const R=Tt.current;if(!R||Nt)return;const U=J.current;K(!0);const X=Yr.getState().sessions.get(R)?.cwd??void 0,be=await Or({cwd:X||void 0,mode:c,shouldActivate:()=>!1});if(K(!1),!be){nr(O("common.error"));return}!Ut.current||U!==J.current||!At.current.some(Ee=>Ee.id===R)||(ge(Ee=>wm(Ee,R,be)),wt(!1),br(R,{preserveMobileKeyboard:!1}))},[br,c,Or,Nt,O]),ui=b.useCallback(R=>{ge(U=>MN(U,R)),R&&br(R,{preserveMobileKeyboard:!1})},[br]),W=b.useCallback(R=>{ge(U=>RN(U,R)),br(R,{preserveMobileKeyboard:!1})},[br]),Ie=b.useCallback(R=>{if(Z.find(X=>X.id===R)){if(J.current+=1,ss.getState().setActivePane(R),R===Tt.current)return;if(Ft(R),!nN({isMobile:zr.current,viewportReady:Ne.has(R),streamReady:Fe.has(R),contentReady:ze.has(R)})){ve(null),lt.current&&z({sessionId:R,token:Date.now()}),F("[Session] Switched to session:",R);return}ut(be=>{if(be.has(R))return be;const Ee=new Set(be);return Ee.add(R),Ee}),ve(R),F("[Session] Switched to session:",R)}},[ze,F,Fe,Z,Ne]),Ye=b.useCallback((R,U)=>{U.trim()&&(G(X=>X.map(be=>be.id===R?{...be,name:U.trim(),customName:!0}:be)),dn(R,U.trim()))},[dn]),rt=b.useCallback(R=>{G(U=>U.map(X=>X.id===R?{...X,customName:!1}:X)),kn(R)},[kn]),nt=b.useCallback(R=>{G(U=>{const X=new Map(U.map(dt=>[dt.id,dt])),be=R.map(dt=>X.get(dt)).filter(dt=>dt!==void 0),Ee=new Set(R),Ve=U.filter(dt=>!Ee.has(dt.id));return[...be,...Ve]}),Hr(R),F("[Session] Reordered sessions:",R),requestAnimationFrame(()=>{Se.current?.update()})},[Hr,F]),yt=b.useCallback(async R=>{const U=typeof R=="string"?R:R.sessionId,X=typeof R=="string"?"auto":R.closeMode??"auto",be=Z.find(Qe=>Qe.id===U);if(!be||Bt.current.has(U))return;Bt.current.add(U),J.current+=1;const Ee=Ix(vr,U,Qe=>Qe.id);try{X==="destroy"&&be.mode==="tmux"&&be.tmuxSessionName?(await qy(be.tmuxSessionName),F("[Session] Destroyed tmux session:",{frontendSessionId:be.id,tmuxSessionName:be.tmuxSessionName})):be.sessionId&&(await Hy(be.sessionId),F("[Session] Closed backend terminal:",be.sessionId))}catch(Qe){console.error("[Session] Failed to close backend terminal:",Qe),Xt({sessionId:U,closeMode:X});return}finally{Bt.current.delete(U)}Xt(Qe=>Qe?.sessionId===U?null:Qe);const dt=At.current.filter(Qe=>Qe.id!==U).some(Qe=>Qe.id===Ee)?Ee:Ix(At.current,U,Qe=>Qe.id);Tt.current===U&&Ft(dt),G(Qe=>Qe.filter(ir=>ir.id!==U)),vn(U,dt),delete He.current[U],F("[Session] Closed session:",{sessionId:U,closeMode:X})},[Z,vr,vn,F]),Pt=b.useCallback(R=>{if(!R)return;const U=Z.filter(X=>X.sessionId===R);if(U.length!==0){U.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:R,frontendSessionIds:U.map(X=>X.id)}),G(X=>{const be=X.filter(Ee=>Ee.sessionId!==R);return be.length!==X.length&&!be.some(Ve=>Ve.id===de)&&Ft(be.length>0?be[0].id:null),be});for(const X of U)vn(X.id),delete He.current[X.id];F("[Session] Backend gone, dropped local session(s):",U.map(X=>X.id))}},[Z,de,vn,F]);b.useEffect(()=>{const R=dr=>{Or(dr.detail)},U=dr=>{Ie(dr.detail)},X=()=>{const dr=Tt.current;!dr||zr.current||z({sessionId:dr,token:Date.now()})},be=dr=>{const pr=dr;pr.detail&&Qn(pr.detail)},Ee=dr=>{const pr=dr.detail;ui(pr??Tt.current??void 0)},Ve=dr=>{const pr=dr.detail;pr&&W(pr)},dt=dr=>{const pr=dr.detail,fs=typeof pr=="string"?pr:pr?.layout,ws=typeof pr=="string"?Tt.current:pr?.sessionId;fs!=="horizontal"&&fs!=="vertical"&&fs!=="grid"||ge(_s=>_s.map(zi=>zi.sessionIds.includes(ws??"")?{...zi,layout:fs}:zi))},Qe=dr=>{const fs=dr.detail?.direction;if(fs!=="prev"&&fs!=="next")return;const ws=on.current;if(ws.length<=1)return;const _s=Tt.current,zi=_s?ws.findIndex(Ca=>Ca.id===_s):-1,Es=((zi>=0?zi:0)+(fs==="next"?1:-1)+ws.length)%ws.length,di=ws[Es]?.id;di&&di!==_s&&Ie(di)},ir=dr=>{yt(dr.detail)},rr=dr=>{Pt(dr.detail)},Et=dr=>{const pr=dr;!pr.detail?.sessionId||!pr.detail?.name||Ye(pr.detail.sessionId,pr.detail.name)},kr=dr=>{const pr=dr;pr.detail?.sessionId&&rt(pr.detail.sessionId)},ln=dr=>{const pr=dr;pr.detail?.sessionIds&&nt(pr.detail.sessionIds)},yn=dr=>{const pr=dr.detail;!pr?.workspaceId||!Array.isArray(pr.sessionIds)||ge(fs=>jN(fs,pr.workspaceId,pr.sessionIds))},en=dr=>{const pr=dr.detail;!pr?.workspaceId||typeof pr.name!="string"||ge(fs=>DN(fs,pr.workspaceId,pr.name))},gn=dr=>{const pr=dr.detail;!pr?.primaryId||!pr.secondaryId||pr.primaryId===pr.secondaryId||(ge(fs=>wm(fs,pr.primaryId,pr.secondaryId)),br(pr.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",R),window.addEventListener("switch-terminal-session",U),window.addEventListener("focus-active-terminal-session",X),window.addEventListener("open-terminal-split-chooser",be),window.addEventListener("close-terminal-split",Ee),window.addEventListener("remove-terminal-split-pane",Ve),window.addEventListener("set-terminal-split-direction",dt),window.addEventListener("cycle-terminal-session",Qe),window.addEventListener("close-terminal-session",ir),window.addEventListener("close-terminal-session-by-backend",rr),window.addEventListener("rename-terminal-session",Et),window.addEventListener("reset-terminal-session-name",kr),window.addEventListener("reorder-terminal-session",ln),window.addEventListener("reorder-terminal-split-workspace",yn),window.addEventListener("rename-terminal-split-workspace",en),window.addEventListener("combine-terminal-split-sessions",gn),()=>{window.removeEventListener("new-terminal-session",R),window.removeEventListener("switch-terminal-session",U),window.removeEventListener("focus-active-terminal-session",X),window.removeEventListener("open-terminal-split-chooser",be),window.removeEventListener("close-terminal-split",Ee),window.removeEventListener("remove-terminal-split-pane",Ve),window.removeEventListener("set-terminal-split-direction",dt),window.removeEventListener("cycle-terminal-session",Qe),window.removeEventListener("close-terminal-session",ir),window.removeEventListener("close-terminal-session-by-backend",rr),window.removeEventListener("rename-terminal-session",Et),window.removeEventListener("reset-terminal-session-name",kr),window.removeEventListener("reorder-terminal-session",ln),window.removeEventListener("reorder-terminal-split-workspace",yn),window.removeEventListener("rename-terminal-split-workspace",en),window.removeEventListener("combine-terminal-split-sessions",gn)}},[br,Or,Ie,Qn,ui,W,yt,Pt,Ye,rt,nt]),b.useEffect(()=>{if(!jr||xt)return;const R=U=>{if(!RC(U,ng())||!(U.ctrlKey||U.metaKey)||!U.shiftKey)return;if(jr.layout==="horizontal"?U.key==="ArrowLeft"||U.key==="ArrowRight":jr.layout==="vertical"?U.key==="ArrowUp"||U.key==="ArrowDown":U.key.startsWith("Arrow")){U.preventDefault(),U.stopPropagation();const be=jr.sessionIds.indexOf(Tt.current??""),Ee=U.key==="ArrowLeft"||U.key==="ArrowUp"?-1:1,Ve=(Math.max(0,be)+Ee+jr.sessionIds.length)%jr.sessionIds.length,dt=jr.sessionIds[Ve];if(!dt)return;br(dt);return}U.key==="Backspace"&&(U.preventDefault(),U.stopPropagation(),ui(Tt.current??void 0))};return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[br,jr,ui,xt]);const H=R=>{const U=Yr.getState().sessions.get(R.id);return yl(R,U?.activeProgram??null,U?.cwd??null,void 0,U?.shellTitle??null,U?.promptState??null)},ue=(R,U={})=>{const X=R.id===de&&!Ze?.startsWith("@collaboration:"),be=zn.has(R.id)&&!U.hidden,Ee=f&&rN({sessionId:R.id,foregroundSessionId:Y,visibleSessionIds:zn,deferredViewportSessionIds:xt?Xn:Bn}),Ve=tN({sessionId:R.id,foregroundSessionId:Y,foregroundReady:Qt,isVisible:be})&&f,dt=oN({sessionId:R.id,foregroundSessionId:Y,requestToken:ye.token,foregroundCompletedToken:$r,isVisible:er.has(R.id)})&&f,Qe=be||R.id===Y||Bn.has(R.id)?0:Be.get(R.id)??ff;return s.jsxs("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${U.hidden?"invisible pointer-events-none":""}`,style:U.containerStyle,"aria-hidden":U.hidden||void 0,onPointerDownCapture:()=>{be&&p5(X,()=>br(R.id))},onWheelCapture:()=>{p5(X,()=>br(R.id))},children:[U.showPaneTitle&&s.jsx(_N,{session:R,active:X,onActivate:()=>br(R.id),onToggleRightSidebar:X?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:Ee&&s.jsx(CN,{sessionId:R.id,mode:R.mode,tmuxSessionName:R.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:X,focusSuspended:!a||V!==null,deferCursorUntilPositioned:V===R.id||R.mode==="tmux"&&!ze.has(R.id),isLayoutVisible:be,initialConnectEnabled:Ve&&dt,resumeRequestEnabled:dt,suppressKeyboard:U.suppressKeyboard,keyboardPortalTarget:U.keyboardPortalTarget,sharedMobileKeyboardLayout:U.sharedMobileKeyboardLayout,suppressPageFlipRefresh:U.suppressPageFlipRefresh,focusRequestToken:ke?.sessionId===R.id?ke.token:0,resumeRequestToken:ye.token,resumeRequestReason:ye.reason,forceResumeReconnect:ye.forceForegroundReconnect&&er.has(R.id),resumeRequestDelayMs:er.has(R.id)?0:U.hidden?ff:Be.get(R.id)??ff,initialConnectDelayMs:Qe,onStreamReadyChange:Ir,onStreamConnected:Zn,onViewportReadyChange:ys,onContentReadyChange:is,onKeyboardVisibilityChange:xr,showDebug:n,onStatusChange:X?C:void 0})})]},R.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[jt&&Z.some(R=>R.id===jt.sessionId)&&s.jsxs("div",{role:"alert",className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto flex max-w-lg items-center gap-3 rounded-xl border border-destructive/30 bg-surface-elevated px-4 py-3 text-[12px] text-foreground shadow-lg",children:[s.jsx("span",{className:"min-w-0 flex-1",children:O("tab.closeFailed",{name:Z.find(R=>R.id===jt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{yt(jt)},children:O("common.retry")}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-1 hover:bg-surface-2","aria-label":O("common.close"),onClick:()=>Xt(null),children:s.jsx(Dn,{size:16})})]}),Xe&&s.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:s.jsx(ig,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:O("tab.tmuxRecoveryTitle",{count:Xe.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:O("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:Xe.sessions.map(R=>R.name).join(" · ")}),Xe.operation&&s.jsxs("div",{className:"mt-2 rounded-lg bg-surface-2 px-2.5 py-2 text-[10px] text-muted-foreground","aria-live":"polite",children:[s.jsx("p",{children:O("tab.tmuxRecoveryProgress",{total:Xe.operation.total,queued:Xe.operation.queued,resourceWait:Xe.operation.resource_wait,running:Xe.operation.running,succeeded:Xe.operation.succeeded,failed:Xe.operation.failed})}),s.jsx("div",{className:"mt-1 max-h-24 overflow-y-auto",children:Xe.operation.items.map(R=>s.jsxs("p",{className:`mt-1 ${R.errorCode?"text-destructive":""}`,children:[R.sessionId,": ",R.errorCode??R.resourceWaitReason??R.phase,R.memAvailableBytes!==void 0?` · 可用内存 ${(R.memAvailableBytes/1024**3).toFixed(1)} GiB`:"",R.actualRssBytes!==void 0?` · 实际 RSS ${(R.actualRssBytes/1024**2).toFixed(0)} MiB`:"",R.estimatedRssBytes!==void 0&&R.actualRssBytes===void 0?` · 预估 RSS ${(R.estimatedRssBytes/1024**2).toFixed(0)} MiB`:""]},R.sessionId))})]}),Je&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:Je}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Ht!==null||!!(Xe.operation&&!["succeeded","partial_failure"].includes(Xe.operation.state)),onClick:()=>{Dt()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[s.jsx(h3,{size:13,className:Ht==="restore"?"animate-spin":""}),Ht==="restore"?O("tab.tmuxRecoveryRestoring"):Xe.operation&&!["succeeded","partial_failure"].includes(Xe.operation.state)?O("tab.tmuxRecoveryInProgress"):O("tab.tmuxRecoveryRestoreAll")]}),Xe.operation&&["queued","resource_wait","running","paused"].includes(Xe.operation.state)&&s.jsx("button",{type:"button",disabled:Ht!==null,onClick:()=>{ur()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 disabled:opacity-50",children:Xe.operation.paused?O("tab.tmuxRecoveryResume"):O("tab.tmuxRecoveryPause")}),s.jsx("button",{type:"button",disabled:Ht!==null||!!(Xe.operation&&!["succeeded","partial_failure"].includes(Xe.operation.state)),onClick:()=>{Fr()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:O("tab.tmuxRecoveryDismiss")})]})]})]})}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(LA,{onSwiper:R=>{Se.current=R,R.allowTouchMove=Jr.length>1&&!Mr&&!We,lr("[swiper:on-swiper]",{allowTouchMove:R.allowTouchMove}),requestAnimationFrame(()=>jn("on-swiper"))},onSlideChange:ds,onTouchStart:(R,U)=>{const X=b5(U),be=X==="touch"||X==="pen"||X==="unknown";ee("[swipe:touch-start]",{pointerType:X,allowed:be}),lr("[swiper:touch-start]",{pointerType:X,allowed:be}),be&&(rn(),ar.current=!0,Ct.current=!0)},onTouchEnd:(R,U)=>{const X=b5(U),be=X==="touch"||X==="pen"||X==="unknown";ee("[swipe:touch-end]",{pointerType:X,allowed:be}),lr("[swiper:touch-end]",{pointerType:X,allowed:be}),be&&(ar.current=!1,gr("touch-end"))},onTransitionEnd:()=>{const R=Se.current;if(ar.current){lr("[swiper:transition-end-during-touch]");return}if(Ct.current&&R&&!$N(R,st.current)){lr("[swiper:transition-end-deferred]");return}rn(),Ct.current=!1,lr("[swiper:transition-end]")},initialSlide:Math.max(0,as),speed:N1,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"terminal-session-swiper h-full",children:Jr.map(R=>{const U=R.workspace,X=!!U&&R.sessions.length>=2,be=xt?$e?"horizontal":"vertical":U?.layout??"horizontal",Ee=xt&&Ot?R.sessions.some(dt=>dt.id===Ot):!1,Ve=R.sessions.some(dt=>dt.id===de)?de:R.sessions[0]?.id;return s.jsx(IA,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":mn.get(R.key)??0,style:{paddingRight:mn.get(R.key)??0,paddingTop:y&&!X?"2.5rem":void 0},children:X?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:xt?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[P&&!xt&&s.jsx("header",{"data-termdock-window-header":"true","data-split-window-header":"true",className:"flex h-[46px] min-h-[46px] shrink-0 items-center app-chrome-bg pl-[88px] pr-3 text-[12px] text-muted-foreground",children:s.jsx("span",{className:"min-w-0 truncate",children:U?.name||O("tab.splitWorkspace")})}),s.jsx(zx,{layoutId:R.key,preset:U?.layout??"horizontal",initialTree:CC(R.sessions.map(dt=>dt.id),be,U?.ratios,U?.gridColumnRatios,U?.gridRowRatios),mobile:xt,focusId:Ee?Ot:null,panes:R.sessions.map(dt=>({id:dt.id,content:ue(dt,{showPaneTitle:!xt,suppressKeyboard:xt&&dt.id!==Ve,keyboardPortalTarget:xt?Ce:null,sharedMobileKeyboardLayout:xt,suppressPageFlipRefresh:!0})}))}),xt&&s.jsx("div",{ref:St,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(zx,{layoutId:R.key,preset:U?.layout??"horizontal",mobile:xt,panes:[{id:R.sessions[0].id,content:ue(R.sessions[0])}]})})},R.key)})})}),We&&de&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>wt(!1),"aria-label":O("common.close")}),s.jsxs("section",{ref:Zt,tabIndex:-1,className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":O("tab.splitTitle"),children:[s.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Hl,{size:17})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:O("tab.splitTitle")}),s.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:O("tab.splitExistingHint")})]}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>wt(!1),"aria-label":O("common.close"),children:s.jsx(Dn,{size:16})})]}),s.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[s.jsxs("button",{type:"button",disabled:Nt,onClick:()=>{es()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Xs,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:O("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:O("tab.splitNewHint")})]})]}),ie.filter(R=>R.id!==jr?.id).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:O("tab.splitExistingGroups")}),ie.filter(R=>R.id!==jr?.id).map((R,U)=>{const X=R.sessionIds.flatMap(Ve=>{const dt=Z.find(Qe=>Qe.id===Ve);return dt?[dt]:[]});if(X.length<2)return null;const be=R.name||`${O("tab.splitWorkspace")} ${U+1}`,Ee=X.map(Ve=>H(Ve).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>Jn(X[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(Hl,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:be}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:O("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[O("tab.sessionCount",{count:X.length})," · ",Ee]})]}),s.jsx(Ci,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},R.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:O("tab.splitAvailableSessions")}),Z.filter(R=>!ie.some(U=>U.sessionIds.includes(R.id))&&R.id!==de).length===0&&ie.filter(R=>R.id!==jr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:O("tab.splitNoOtherSessions")}):Z.filter(R=>!ie.some(U=>U.sessionIds.includes(R.id))&&R.id!==de).map(R=>{const U=Ur.get(R.id)??null,X=H(R);return s.jsxs("button",{type:"button",onClick:()=>Jn(R.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:U?s.jsx(nu,{size:15}):s.jsx(Hl,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:X.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:U?dd(U)??U:R.name})]}),s.jsx(Ci,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},R.id)})]})]})]}),Mt&&s.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:Mt})]})},VN={sm:"h-4 w-7",md:"h-6 w-10"},qN={sm:"h-3 w-3",md:"h-5 w-5"},YN={sm:"translate-x-3",md:"translate-x-4"};function Al({checked:e,disabled:t=!1,size:r="md",className:n=""}){return s.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${VN[r]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${n}`,children:s.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${qN[r]} ${e?YN[r]:""}`})})}function Aa(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ZN=typeof Symbol=="function"&&Symbol.observable||"@@observable",v5=ZN,w5=()=>Math.random().toString(36).substring(7).split("").join("."),KN={INIT:`@@redux/INIT${w5()}`,REPLACE:`@@redux/REPLACE${w5()}`},A5=KN;function XN(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Bv(e,t,r){if(typeof e!="function")throw new Error(Aa(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Aa(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Aa(1));return r(Bv)(e,t)}let n=e,a=t,c=new Map,l=c,d=0,f=!1;function m(){l===c&&(l=new Map,c.forEach((L,N)=>{l.set(N,L)}))}function x(){if(f)throw new Error(Aa(3));return a}function y(L){if(typeof L!="function")throw new Error(Aa(4));if(f)throw new Error(Aa(5));let N=!0;m();const D=d++;return l.set(D,L),function(){if(N){if(f)throw new Error(Aa(6));N=!1,m(),l.delete(D),c=null}}}function w(L){if(!XN(L))throw new Error(Aa(7));if(typeof L.type>"u")throw new Error(Aa(8));if(typeof L.type!="string")throw new Error(Aa(17));if(f)throw new Error(Aa(9));try{f=!0,a=n(a,L)}finally{f=!1}return(c=l).forEach(D=>{D()}),L}function v(L){if(typeof L!="function")throw new Error(Aa(10));n=L,w({type:A5.REPLACE})}function T(){const L=y;return{subscribe(N){if(typeof N!="object"||N===null)throw new Error(Aa(11));function D(){const P=N;P.next&&P.next(x())}return D(),{unsubscribe:L(D)}},[v5](){return this}}}return w({type:A5.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[v5]:T}}function T5(e,t){return function(...r){return t(e.apply(this,r))}}function S5(e,t){if(typeof e=="function")return T5(e,t);if(typeof e!="object"||e===null)throw new Error(Aa(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=T5(a,t))}return r}function Qv(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function JN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(Aa(15))};const l={getState:a.getState,dispatch:(f,...m)=>c(f,...m)},d=e.map(f=>f(l));return c=Qv(...d)(a.dispatch),{...a,dispatch:c}}}var Tm={exports:{}},Sm={};var C5;function eR(){if(C5)return Sm;C5=1;var e=$A();function t(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,c=e.useEffect,l=e.useMemo,d=e.useDebugValue;return Sm.useSyncExternalStoreWithSelector=function(f,m,x,y,w){var v=a(null);if(v.current===null){var T={hasValue:!1,value:null};v.current=T}else T=v.current;v=l(function(){function L(F){if(!N){if(N=!0,D=F,F=y(F),w!==void 0&&T.hasValue){var ee=T.value;if(w(ee,F))return O=ee}return O=F}if(ee=O,r(D,F))return ee;var Z=y(F);return w!==void 0&&w(ee,Z)?(D=F,ee):(D=F,O=Z)}var N=!1,D,O,P=x===void 0?null:x;return[function(){return L(m())},P===null?void 0:function(){return L(P())}]},[m,x,y,w]);var C=n(f,v[0],v[1]);return c(function(){T.hasValue=!0,T.value=C},[C]),d(C),C},Sm}var _5;function tR(){return _5||(_5=1,Tm.exports=eR()),Tm.exports}tR();var rR=b.version.startsWith("19"),nR=Symbol.for(rR?"react.transitional.element":"react.element"),sR=Symbol.for("react.portal"),iR=Symbol.for("react.fragment"),aR=Symbol.for("react.strict_mode"),oR=Symbol.for("react.profiler"),lR=Symbol.for("react.consumer"),cR=Symbol.for("react.context"),Pv=Symbol.for("react.forward_ref"),uR=Symbol.for("react.suspense"),dR=Symbol.for("react.suspense_list"),_g=Symbol.for("react.memo"),hR=Symbol.for("react.lazy"),fR=Pv,pR=_g;function mR(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case nR:switch(e=e.type,e){case iR:case oR:case aR:case uR:case dR:return e;default:switch(e=e&&e.$$typeof,e){case cR:case Pv:case hR:case _g:return e;case lR:return e;default:return t}}case sR:return t}}}function gR(e){return mR(e)===_g}function xR(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let d=!1,f,m,x,y,w;function v(D,O){return f=D,m=O,x=e(f,m),y=t(n,m),w=r(x,y,m),d=!0,w}function T(){return x=e(f,m),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function C(){return e.dependsOnOwnProps&&(x=e(f,m)),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function L(){const D=e(f,m),O=!l(D,x);return x=D,O&&(w=r(x,y,m)),w}function N(D,O){const P=!c(O,m),F=!a(D,f,O,m);return f=D,m=O,P&&F?T():P?C():F?L():w}return function(O,P){return d?N(O,P):v(O,P)}}function bR(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),d=n(e,a);return xR(c,l,d,e,a)}function yR(e,t){const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=(...c)=>t(a(...c)))}return r}function j1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function k5(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function Ov(e,t){return function(n,{displayName:a}){const c=function(d,f){return c.dependsOnOwnProps?c.mapToProps(d,f):c.mapToProps(d,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(d,f){c.mapToProps=e,c.dependsOnOwnProps=k5(e);let m=c(d,f);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=k5(m),m=c(d,f)),m},c}}function kg(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function vR(e){return e&&typeof e=="object"?j1(t=>yR(e,t)):e?typeof e=="function"?Ov(e):kg(e,"mapDispatchToProps"):j1(t=>({dispatch:t}))}function wR(e){return e?typeof e=="function"?Ov(e):kg(e,"mapStateToProps"):j1(()=>({}))}function AR(e,t,r){return{...r,...e,...t}}function TR(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let c=!1,l;return function(f,m,x){const y=e(f,m,x);return c?a(y,l)||(l=y):(c=!0,l=y),l}}}function SR(e){return e?typeof e=="function"?TR(e):kg(e,"mergeProps"):()=>AR}function CR(e){e()}function _R(){let e=null,t=null;return{clear(){e=null,t=null},notify(){CR(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var L5={notify(){},get:()=>[]};function Fv(e,t){let r,n=L5,a=0,c=!1;function l(C){x();const L=n.subscribe(C);let N=!1;return()=>{N||(N=!0,L(),y())}}function d(){n.notify()}function f(){T.onStateChange&&T.onStateChange()}function m(){return c}function x(){a++,r||(r=t?t.addNestedSub(f):e.subscribe(f),n=_R())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=L5)}function w(){c||(c=!0,x())}function v(){c&&(c=!1,y())}const T={addNestedSub:l,notifyNestedSubs:d,handleChangeWrapper:f,isSubscribed:m,trySubscribe:w,tryUnsubscribe:v,getListeners:()=>n};return T}var kR=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",LR=kR(),IR=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ER=IR(),NR=()=>LR||ER?b.useLayoutEffect:b.useEffect,Ff=NR();function I5(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Cm(e,t){if(I5(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(t,r[a])||!I5(e[r[a]],t[r[a]]))return!1;return!0}var RR={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},MR={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},jR={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},$v={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},DR={[fR]:jR,[pR]:$v};function E5(e){return gR(e)?$v:DR[e.$$typeof]||RR}var BR=Object.defineProperty,QR=Object.getOwnPropertyNames,N5=Object.getOwnPropertySymbols,PR=Object.getOwnPropertyDescriptor,OR=Object.getPrototypeOf,R5=Object.prototype;function D1(e,t){if(typeof t!="string"){if(R5){const c=OR(t);c&&c!==R5&&D1(e,c)}let r=QR(t);N5&&(r=r.concat(N5(t)));const n=E5(e),a=E5(t);for(let c=0;c<r.length;++c){const l=r[c];if(!MR[l]&&!(a&&a[l])&&!(n&&n[l])){const d=PR(t,l);try{BR(e,l,d)}catch{}}}}return e}var FR=Symbol.for("react-redux-context"),$R=typeof globalThis<"u"?globalThis:{};function UR(){if(!b.createContext)return{};const e=$R[FR]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var Uv=UR(),zR=[null,null];function HR(e,t,r){Ff(()=>e(...t),r)}function WR(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function GR(e,t,r,n,a,c,l,d,f,m,x){if(!e)return()=>{};let y=!1,w=null;const v=()=>{if(y||!d.current)return;const C=t.getState();let L,N;try{L=n(C,a.current)}catch(D){N=D,w=D}N||(w=null),L===c.current?l.current||m():(c.current=L,f.current=L,l.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,w)throw w}}function VR(e,t){return e===t}function qR(e,t,r,{pure:n,areStatesEqual:a=VR,areOwnPropsEqual:c=Cm,areStatePropsEqual:l=Cm,areMergedPropsEqual:d=Cm,forwardRef:f=!1,context:m=Uv}={}){const x=m,y=wR(e),w=vR(t),v=SR(r),T=!!e;return L=>{const N=L.displayName||L.name||"Component",D=`Connect(${N})`,O={shouldHandleStateChanges:T,displayName:D,wrappedComponentName:N,WrappedComponent:L,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:d};function P(Z){const[G,de,pe]=b.useMemo(()=>{const{reactReduxForwardedRef:ut,...ft}=Z;return[Z.context,ut,ft]},[Z]),J=b.useMemo(()=>{let ut=x;return G?.Consumer,ut},[G,x]),Re=b.useContext(J),Ze=!!Z.store&&!!Z.store.getState&&!!Z.store.dispatch,V=!!Re&&!!Re.store,ve=Ze?Z.store:Re.store,qe=V?Re.getServerState:ve.getState,le=b.useMemo(()=>bR(ve.dispatch,O),[ve]),[ye,Te]=b.useMemo(()=>{if(!T)return zR;const ut=Fv(ve,Ze?void 0:Re.subscription),ft=ut.notifyNestedSubs.bind(ut);return[ut,ft]},[ve,Ze,Re]),Fe=b.useMemo(()=>Ze?Re:{...Re,subscription:ye},[Ze,Re,ye]),se=b.useRef(void 0),De=b.useRef(pe),_e=b.useRef(void 0),Me=b.useRef(!1),Ke=b.useRef(!1),Ne=b.useRef(void 0);Ff(()=>(Ke.current=!0,()=>{Ke.current=!1}),[]);const ae=b.useMemo(()=>()=>_e.current&&pe===De.current?_e.current:le(ve.getState(),pe),[ve,pe]),ze=b.useMemo(()=>ft=>ye?GR(T,ve,ye,le,De,se,Me,Ke,_e,Te,ft):()=>{},[ye]);HR(WR,[De,se,Me,pe,_e,Te]);let at;try{at=b.useSyncExternalStore(ze,ae,qe?()=>le(qe(),pe):ae)}catch(ut){throw Ne.current&&(ut.message+=`
78
+ The error may be correlated with this previous error:
79
+ ${Ne.current.stack}
80
+
81
+ `),ut}Ff(()=>{Ne.current=void 0,_e.current=void 0,se.current=at});const ct=b.useMemo(()=>b.createElement(L,{...at,ref:de}),[de,L,at]);return b.useMemo(()=>T?b.createElement(J.Provider,{value:Fe},ct):ct,[J,ct,Fe])}const ee=b.memo(P);if(ee.WrappedComponent=L,ee.displayName=P.displayName=D,f){const G=b.forwardRef(function(pe,J){return b.createElement(ee,{...pe,reactReduxForwardedRef:J})});return G.displayName=D,G.WrappedComponent=L,D1(G,L)}return D1(ee,L)}}var zv=qR;function YR(e){const{children:t,context:r,serverState:n,store:a}=e,c=b.useMemo(()=>{const f=Fv(a);return{store:a,subscription:f,getServerState:n?()=>n:void 0}},[a,n]),l=b.useMemo(()=>a.getState(),[a]);Ff(()=>{const{subscription:f}=c;return f.onStateChange=f.notifyNestedSubs,f.trySubscribe(),l!==a.getState()&&f.notifyNestedSubs(),()=>{f.tryUnsubscribe(),f.onStateChange=void 0}},[c,l]);const d=r||Uv;return b.createElement(d.Provider,{value:c},t)}var ZR=YR,KR="Invariant failed";function XR(e,t){throw new Error(KR)}var Jo=function(t){var r=t.top,n=t.right,a=t.bottom,c=t.left,l=n-c,d=a-r,f={top:r,right:n,bottom:a,left:c,width:l,height:d,x:c,y:r,center:{x:(n+c)/2,y:(a+r)/2}};return f},Lg=function(t,r){return{top:t.top-r.top,left:t.left-r.left,bottom:t.bottom+r.bottom,right:t.right+r.right}},M5=function(t,r){return{top:t.top+r.top,left:t.left+r.left,bottom:t.bottom-r.bottom,right:t.right-r.right}},JR=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},_m={top:0,right:0,bottom:0,left:0},Ig=function(t){var r=t.borderBox,n=t.margin,a=n===void 0?_m:n,c=t.border,l=c===void 0?_m:c,d=t.padding,f=d===void 0?_m:d,m=Jo(Lg(r,a)),x=Jo(M5(r,l)),y=Jo(M5(x,f));return{marginBox:m,borderBox:Jo(r),paddingBox:x,contentBox:y,margin:a,border:l,padding:f}},So=function(t){var r=t.slice(0,-2),n=t.slice(-2);if(n!=="px")return 0;var a=Number(r);return isNaN(a)&&XR(),a},eM=function(){return{x:window.pageXOffset,y:window.pageYOffset}},$f=function(t,r){var n=t.borderBox,a=t.border,c=t.margin,l=t.padding,d=JR(n,r);return Ig({borderBox:d,border:a,margin:c,padding:l})},Uf=function(t,r){return r===void 0&&(r=eM()),$f(t,r)},Hv=function(t,r){var n={top:So(r.marginTop),right:So(r.marginRight),bottom:So(r.marginBottom),left:So(r.marginLeft)},a={top:So(r.paddingTop),right:So(r.paddingRight),bottom:So(r.paddingBottom),left:So(r.paddingLeft)},c={top:So(r.borderTopWidth),right:So(r.borderRightWidth),bottom:So(r.borderBottomWidth),left:So(r.borderLeftWidth)};return Ig({borderBox:t,margin:n,padding:a,border:c})},Wv=function(t){var r=t.getBoundingClientRect(),n=window.getComputedStyle(t);return Hv(r,n)},Q0=function(t){var r=[],n=null,a=function(){for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];r=d,!n&&(n=requestAnimationFrame(function(){n=null,t.apply(void 0,r)}))};return a.cancel=function(){n&&(cancelAnimationFrame(n),n=null)},a};function zf(){return zf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},zf.apply(null,arguments)}function Gv(e,t){}Gv.bind(null,"warn");Gv.bind(null,"error");function yc(){}function tM(e,t){return{...e,...t}}function Eo(e,t,r){const n=t.map(a=>{const c=tM(r,a.options);return e.addEventListener(a.eventName,a.fn,c),function(){e.removeEventListener(a.eventName,a.fn,c)}});return function(){n.forEach(c=>{c()})}}const rM="Invariant failed";class Hf extends Error{}Hf.prototype.toString=function(){return this.message};function zt(e,t){throw new Hf(rM)}class nM extends _.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=yc,this.onWindowError=r=>{const n=this.getCallbacks();n.isDragging()&&n.tryAbort(),r.error instanceof Hf&&r.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=r=>{this.callbacks=r}}componentDidMount(){this.unbind=Eo(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Hf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const sM=`
82
+ Press space bar to start a drag.
83
+ When dragging you can use the arrow keys to move the item around and escape to cancel.
84
+ Some screen readers may require you to be in focus mode or to use your pass through key
85
+ `,Wf=e=>e+1,iM=e=>`
86
+ You have lifted an item in position ${Wf(e.source.index)}
87
+ `,Vv=(e,t)=>{const r=e.droppableId===t.droppableId,n=Wf(e.index),a=Wf(t.index);return r?`
88
+ You have moved the item from position ${n}
89
+ to position ${a}
90
+ `:`
91
+ You have moved the item from position ${n}
92
+ in list ${e.droppableId}
93
+ to list ${t.droppableId}
94
+ in position ${a}
95
+ `},qv=(e,t,r)=>t.droppableId===r.droppableId?`
96
+ The item ${e}
97
+ has been combined with ${r.draggableId}`:`
98
+ The item ${e}
99
+ in list ${t.droppableId}
100
+ has been combined with ${r.draggableId}
101
+ in list ${r.droppableId}
102
+ `,aM=e=>{const t=e.destination;if(t)return Vv(e.source,t);const r=e.combine;return r?qv(e.draggableId,e.source,r):"You are over an area that cannot be dropped on"},j5=e=>`
103
+ The item has returned to its starting position
104
+ of ${Wf(e.index)}
105
+ `,oM=e=>{if(e.reason==="CANCEL")return`
106
+ Movement cancelled.
107
+ ${j5(e.source)}
108
+ `;const t=e.destination,r=e.combine;return t?`
109
+ You have dropped the item.
110
+ ${Vv(e.source,t)}
111
+ `:r?`
112
+ You have dropped the item.
113
+ ${qv(e.draggableId,e.source,r)}
114
+ `:`
115
+ The item has been dropped while not over a drop area.
116
+ ${j5(e.source)}
117
+ `},gf={dragHandleUsageInstructions:sM,onDragStart:iM,onDragUpdate:aM,onDragEnd:oM};function lM(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function Yv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!lM(e[r],t[r]))return!1;return!0}function En(e,t){const r=b.useState(()=>({inputs:t,result:e()}))[0],n=b.useRef(!0),a=b.useRef(r),l=n.current||!!(t&&a.current.inputs&&Yv(t,a.current.inputs))?a.current:{inputs:t,result:e()};return b.useEffect(()=>{n.current=!1,a.current=l},[l]),l.result}function Rr(e,t){return En(()=>e,t)}const ki={x:0,y:0},Ui=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Ja=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),vc=(e,t)=>e.x===t.x&&e.y===t.y,md=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),au=(e,t,r=0)=>e==="x"?{x:t,y:r}:{x:r,y:t},P0=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),D5=(e,t)=>Math.min(...t.map(r=>P0(e,r))),Zv=e=>t=>({x:e(t.x),y:e(t.y)});var cM=(e,t)=>{const r=Jo({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return r.width<=0||r.height<=0?null:r};const K0=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),B5=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],uM={top:0,right:0,bottom:0,left:0},dM=(e,t)=>t?K0(e,t.scroll.diff.displacement):e,hM=(e,t,r)=>r&&r.increasedBy?{...e,[t.end]:e[t.end]+r.increasedBy[t.line]}:e,fM=(e,t)=>t&&t.shouldClipSubject?cM(t.pageMarginBox,e):Jo(e);var ad=({page:e,withPlaceholder:t,axis:r,frame:n})=>{const a=dM(e.marginBox,n),c=hM(a,r,t),l=fM(c,n);return{page:e,withPlaceholder:t,active:l}},Eg=(e,t)=>{e.frame||zt();const r=e.frame,n=Ja(t,r.scroll.initial),a=md(n),c={...r,scroll:{initial:r.scroll.initial,current:t,diff:{value:n,displacement:a},max:r.scroll.max}},l=ad({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:c});return{...e,frame:c,subject:l}};function _i(e,t=Yv){let r=null;function n(...a){if(r&&r.lastThis===this&&t(a,r.lastArgs))return r.lastResult;const c=e.apply(this,a);return r={lastResult:c,lastArgs:a,lastThis:this},c}return n.clear=function(){r=null},n}const Kv=_i(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),Xv=_i(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),dp=_i(e=>Object.values(e)),pM=_i(e=>Object.values(e));var gd=_i((e,t)=>pM(t).filter(n=>e===n.descriptor.droppableId).sort((n,a)=>n.descriptor.index-a.descriptor.index));function Ng(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function hp(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var fp=_i((e,t)=>t.filter(r=>r.descriptor.id!==e.descriptor.id)),mM=({isMovingForward:e,draggable:t,destination:r,insideDestination:n,previousImpact:a})=>{if(!r.isCombineEnabled||!Ng(a))return null;function l(v){const T={type:"COMBINE",combine:{draggableId:v,droppableId:r.descriptor.id}};return{...a,at:T}}const d=a.displaced.all,f=d.length?d[0]:null;if(e)return f?l(f):null;const m=fp(t,n);if(!f){if(!m.length)return null;const v=m[m.length-1];return l(v.descriptor.id)}const x=m.findIndex(v=>v.descriptor.id===f);x===-1&&zt();const y=x-1;if(y<0)return null;const w=m[y];return l(w.descriptor.id)},xd=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Jv={point:ki,value:0},O0={invisible:{},visible:{},all:[]},gM={displaced:O0,displacedBy:Jv,at:null};var No=(e,t)=>r=>e<=r&&r<=t,e6=e=>{const t=No(e.top,e.bottom),r=No(e.left,e.right);return n=>{if(t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right))return!0;const c=t(n.top)||t(n.bottom),l=r(n.left)||r(n.right);if(c&&l)return!0;const f=n.top<e.top&&n.bottom>e.bottom,m=n.left<e.left&&n.right>e.right;return f&&m?!0:f&&l||m&&c}},xM=e=>{const t=No(e.top,e.bottom),r=No(e.left,e.right);return n=>t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right)};const Rg={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},t6={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var bM=e=>t=>{const r=No(t.top,t.bottom),n=No(t.left,t.right);return a=>e===Rg?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)};const yM=(e,t)=>{const r=t.frame?t.frame.scroll.diff.displacement:ki;return K0(e,r)},vM=(e,t,r)=>t.subject.active?r(t.subject.active)(e):!1,wM=(e,t,r)=>r(t)(e),Mg=({target:e,destination:t,viewport:r,withDroppableDisplacement:n,isVisibleThroughFrameFn:a})=>{const c=n?yM(e,t):e;return vM(c,t,a)&&wM(c,r,a)},AM=e=>Mg({...e,isVisibleThroughFrameFn:e6}),r6=e=>Mg({...e,isVisibleThroughFrameFn:xM}),TM=e=>Mg({...e,isVisibleThroughFrameFn:bM(e.destination.axis)}),SM=(e,t,r)=>{if(typeof r=="boolean")return r;if(!t)return!0;const{invisible:n,visible:a}=t;if(n[e])return!1;const c=a[e];return c?c.shouldAnimate:!0};function CM(e,t){const r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return Jo(Lg(r,n))}function F0({afterDragging:e,destination:t,displacedBy:r,viewport:n,forceShouldAnimate:a,last:c}){return e.reduce(function(d,f){const m=CM(f,r),x=f.descriptor.id;if(d.all.push(x),!AM({target:m,destination:t,viewport:n,withDroppableDisplacement:!0}))return d.invisible[f.descriptor.id]=!0,d;const w=SM(x,c,a),v={draggableId:x,shouldAnimate:w};return d.visible[x]=v,d},{all:[],visible:{},invisible:{}})}function _M(e,t){if(!e.length)return 0;const r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function Q5({insideDestination:e,inHomeList:t,displacedBy:r,destination:n}){const a=_M(e,{inHomeList:t});return{displaced:O0,displacedBy:r,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function Gf({draggable:e,insideDestination:t,destination:r,viewport:n,displacedBy:a,last:c,index:l,forceShouldAnimate:d}){const f=xd(e,r);if(l==null)return Q5({insideDestination:t,inHomeList:f,displacedBy:a,destination:r});const m=t.find(T=>T.descriptor.index===l);if(!m)return Q5({insideDestination:t,inHomeList:f,displacedBy:a,destination:r});const x=fp(e,t),y=t.indexOf(m),w=x.slice(y);return{displaced:F0({afterDragging:w,destination:r,displacedBy:a,last:c,viewport:n.frame,forceShouldAnimate:d}),displacedBy:a,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:l}}}}function Tc(e,t){return!!t.effected[e]}var kM=({isMovingForward:e,destination:t,draggables:r,combine:n,afterCritical:a})=>{if(!t.isCombineEnabled)return null;const c=n.draggableId,d=r[c].descriptor.index;return Tc(c,a)?e?d:d-1:e?d+1:d},LM=({isMovingForward:e,isInHomeList:t,insideDestination:r,location:n})=>{if(!r.length)return null;const a=n.index,c=e?a+1:a-1,l=r[0].descriptor.index,d=r[r.length-1].descriptor.index,f=t?d:d+1;return c<l||c>f?null:c},IM=({isMovingForward:e,isInHomeList:t,draggable:r,draggables:n,destination:a,insideDestination:c,previousImpact:l,viewport:d,afterCritical:f})=>{const m=l.at;if(m||zt(),m.type==="REORDER"){const y=LM({isMovingForward:e,isInHomeList:t,location:m.destination,insideDestination:c});return y==null?null:Gf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:y})}const x=kM({isMovingForward:e,destination:a,displaced:l.displaced,draggables:n,combine:m.combine,afterCritical:f});return x==null?null:Gf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:x})},EM=({displaced:e,afterCritical:t,combineWith:r,displacedBy:n})=>{const a=!!(e.visible[r]||e.invisible[r]);return Tc(r,t)?a?ki:md(n.point):a?n.point:ki},NM=({afterCritical:e,impact:t,draggables:r})=>{const n=hp(t);n||zt();const a=n.draggableId,c=r[a].page.borderBox.center,l=EM({displaced:t.displaced,afterCritical:e,combineWith:a,displacedBy:t.displacedBy});return Ui(c,l)};const n6=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,RM=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,jg=(e,t,r)=>t[e.crossAxisStart]+r.margin[e.crossAxisStart]+r.borderBox[e.crossAxisSize]/2,P5=({axis:e,moveRelativeTo:t,isMoving:r})=>au(e.line,t.marginBox[e.end]+n6(e,r),jg(e,t.marginBox,r)),O5=({axis:e,moveRelativeTo:t,isMoving:r})=>au(e.line,t.marginBox[e.start]-RM(e,r),jg(e,t.marginBox,r)),MM=({axis:e,moveInto:t,isMoving:r})=>au(e.line,t.contentBox[e.start]+n6(e,r),jg(e,t.contentBox,r));var jM=({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:a})=>{const c=gd(n.descriptor.id,r),l=t.page,d=n.axis;if(!c.length)return MM({axis:d,moveInto:n.page,isMoving:l});const{displaced:f,displacedBy:m}=e,x=f.all[0];if(x){const w=r[x];if(Tc(x,a))return O5({axis:d,moveRelativeTo:w.page,isMoving:l});const v=$f(w.page,m.point);return O5({axis:d,moveRelativeTo:v,isMoving:l})}const y=c[c.length-1];if(y.descriptor.id===t.descriptor.id)return l.borderBox.center;if(Tc(y.descriptor.id,a)){const w=$f(y.page,md(a.displacedBy.point));return P5({axis:d,moveRelativeTo:w,isMoving:l})}return P5({axis:d,moveRelativeTo:y.page,isMoving:l})},B1=(e,t)=>{const r=e.frame;return r?Ui(t,r.scroll.diff.displacement):t};const DM=({impact:e,draggable:t,droppable:r,draggables:n,afterCritical:a})=>{const c=t.page.borderBox.center,l=e.at;return!r||!l?c:l.type==="REORDER"?jM({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:a}):NM({impact:e,draggables:n,afterCritical:a})};var pp=e=>{const t=DM(e),r=e.droppable;return r?B1(r,t):t},s6=(e,t)=>{const r=Ja(t,e.scroll.initial),n=md(r);return{frame:Jo({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:r,displacement:n}}}};function F5(e,t){return e.map(r=>t[r])}function BM(e,t){for(let r=0;r<t.length;r++){const n=t[r].visible[e];if(n)return n}return null}var QM=({impact:e,viewport:t,destination:r,draggables:n,maxScrollChange:a})=>{const c=s6(t,Ui(t.scroll.current,a)),l=r.frame?Eg(r,Ui(r.frame.scroll.current,a)):r,d=e.displaced,f=F0({afterDragging:F5(d.all,n),destination:r,displacedBy:e.displacedBy,viewport:c.frame,last:d,forceShouldAnimate:!1}),m=F0({afterDragging:F5(d.all,n),destination:l,displacedBy:e.displacedBy,viewport:t.frame,last:d,forceShouldAnimate:!1}),x={},y={},w=[d,f,m];return d.all.forEach(T=>{const C=BM(T,w);if(C){y[T]=C;return}x[T]=!0}),{...e,displaced:{all:d.all,invisible:x,visible:y}}},PM=(e,t)=>Ui(e.scroll.diff.displacement,t),Dg=({pageBorderBoxCenter:e,draggable:t,viewport:r})=>{const n=PM(r,e),a=Ja(n,t.page.borderBox.center);return Ui(t.client.borderBox.center,a)},i6=({draggable:e,destination:t,newPageBorderBoxCenter:r,viewport:n,withDroppableDisplacement:a,onlyOnMainAxis:c=!1})=>{const l=Ja(r,e.page.borderBox.center),f={target:K0(e.page.borderBox,l),destination:t,withDroppableDisplacement:a,viewport:n};return c?TM(f):r6(f)},OM=({isMovingForward:e,draggable:t,destination:r,draggables:n,previousImpact:a,viewport:c,previousPageBorderBoxCenter:l,previousClientSelection:d,afterCritical:f})=>{if(!r.isEnabled)return null;const m=gd(r.descriptor.id,n),x=xd(t,r),y=mM({isMovingForward:e,draggable:t,destination:r,insideDestination:m,previousImpact:a})||IM({isMovingForward:e,isInHomeList:x,draggable:t,draggables:n,destination:r,insideDestination:m,previousImpact:a,viewport:c,afterCritical:f});if(!y)return null;const w=pp({impact:y,draggable:t,droppable:r,draggables:n,afterCritical:f});if(i6({draggable:t,destination:r,newPageBorderBoxCenter:w,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:Dg({pageBorderBoxCenter:w,draggable:t,viewport:c}),impact:y,scrollJumpRequest:null};const T=Ja(w,l),C=QM({impact:y,viewport:c,destination:r,draggables:n,maxScrollChange:T});return{clientSelection:d,impact:C,scrollJumpRequest:T}};const ba=e=>{const t=e.subject.active;return t||zt(),t};var FM=({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:n,viewport:a})=>{const c=r.subject.active;if(!c)return null;const l=r.axis,d=No(c[l.start],c[l.end]),f=dp(n).filter(x=>x!==r).filter(x=>x.isEnabled).filter(x=>!!x.subject.active).filter(x=>e6(a.frame)(ba(x))).filter(x=>{const y=ba(x);return e?c[l.crossAxisEnd]<y[l.crossAxisEnd]:y[l.crossAxisStart]<c[l.crossAxisStart]}).filter(x=>{const y=ba(x),w=No(y[l.start],y[l.end]);return d(y[l.start])||d(y[l.end])||w(c[l.start])||w(c[l.end])}).sort((x,y)=>{const w=ba(x)[l.crossAxisStart],v=ba(y)[l.crossAxisStart];return e?w-v:v-w}).filter((x,y,w)=>ba(x)[l.crossAxisStart]===ba(w[0])[l.crossAxisStart]);if(!f.length)return null;if(f.length===1)return f[0];const m=f.filter(x=>No(ba(x)[l.start],ba(x)[l.end])(t[l.line]));return m.length===1?m[0]:m.length>1?m.sort((x,y)=>ba(x)[l.start]-ba(y)[l.start])[0]:f.sort((x,y)=>{const w=D5(t,B5(ba(x))),v=D5(t,B5(ba(y)));return w!==v?w-v:ba(x)[l.start]-ba(y)[l.start]})[0]};const $5=(e,t)=>{const r=e.page.borderBox.center;return Tc(e.descriptor.id,t)?Ja(r,t.displacedBy.point):r},$M=(e,t)=>{const r=e.page.borderBox;return Tc(e.descriptor.id,t)?K0(r,md(t.displacedBy.point)):r};var UM=({pageBorderBoxCenter:e,viewport:t,destination:r,insideDestination:n,afterCritical:a})=>n.filter(l=>r6({target:$M(l,a),destination:r,viewport:t.frame,withDroppableDisplacement:!0})).sort((l,d)=>{const f=P0(e,B1(r,$5(l,a))),m=P0(e,B1(r,$5(d,a)));return f<m?-1:m<f?1:l.descriptor.index-d.descriptor.index})[0]||null,X0=_i(function(t,r){const n=r[t.line];return{value:n,point:au(t.line,n)}});const zM=(e,t,r)=>{const n=e.axis;if(e.descriptor.mode==="virtual")return au(n.line,t[n.line]);const a=e.subject.page.contentBox[n.size],f=gd(e.descriptor.id,r).reduce((m,x)=>m+x.client.marginBox[n.size],0)+t[n.line]-a;return f<=0?null:au(n.line,f)},a6=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),o6=(e,t,r)=>{const n=e.frame;xd(t,e)&&zt(),e.subject.withPlaceholder&&zt();const a=X0(e.axis,t.displaceBy).point,c=zM(e,a,r),l={placeholderSize:a,increasedBy:c,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!n){const x=ad({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:e.frame});return{...e,subject:x}}const d=c?Ui(n.scroll.max,c):n.scroll.max,f=a6(n,d),m=ad({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:f});return{...e,subject:m,frame:f}},HM=e=>{const t=e.subject.withPlaceholder;t||zt();const r=e.frame;if(!r){const l=ad({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:l}}const n=t.oldFrameMaxScroll;n||zt();const a=a6(r,n),c=ad({page:e.subject.page,axis:e.axis,frame:a,withPlaceholder:null});return{...e,subject:c,frame:a}};var WM=({previousPageBorderBoxCenter:e,moveRelativeTo:t,insideDestination:r,draggable:n,draggables:a,destination:c,viewport:l,afterCritical:d})=>{if(!t){if(r.length)return null;const y={displaced:O0,displacedBy:Jv,at:{type:"REORDER",destination:{droppableId:c.descriptor.id,index:0}}},w=pp({impact:y,draggable:n,droppable:c,draggables:a,afterCritical:d}),v=xd(n,c)?c:o6(c,n,a);return i6({draggable:n,destination:v,newPageBorderBoxCenter:w,viewport:l.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?y:null}const f=e[c.axis.line]<=t.page.borderBox.center[c.axis.line],m=(()=>{const y=t.descriptor.index;return t.descriptor.id===n.descriptor.id||f?y:y+1})(),x=X0(c.axis,n.displaceBy);return Gf({draggable:n,insideDestination:r,destination:c,viewport:l,displacedBy:x,last:O0,index:m})},GM=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:r,isOver:n,draggables:a,droppables:c,viewport:l,afterCritical:d})=>{const f=FM({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:c,viewport:l});if(!f)return null;const m=gd(f.descriptor.id,a),x=UM({pageBorderBoxCenter:t,viewport:l,destination:f,insideDestination:m,afterCritical:d}),y=WM({previousPageBorderBoxCenter:t,destination:f,draggable:r,draggables:a,moveRelativeTo:x,insideDestination:m,viewport:l,afterCritical:d});if(!y)return null;const w=pp({impact:y,draggable:r,droppable:f,draggables:a,afterCritical:d});return{clientSelection:Dg({pageBorderBoxCenter:w,draggable:r,viewport:l}),impact:y,scrollJumpRequest:null}},to=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const VM=(e,t)=>{const r=to(e);return r?t[r]:null};var qM=({state:e,type:t})=>{const r=VM(e.impact,e.dimensions.droppables),n=!!r,a=e.dimensions.droppables[e.critical.droppable.id],c=r||a,l=c.axis.direction,d=l==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||l==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(d&&!n)return null;const f=t==="MOVE_DOWN"||t==="MOVE_RIGHT",m=e.dimensions.draggables[e.critical.draggable.id],x=e.current.page.borderBoxCenter,{draggables:y,droppables:w}=e.dimensions;return d?OM({isMovingForward:f,previousPageBorderBoxCenter:x,draggable:m,destination:c,draggables:y,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):GM({isMovingForward:f,previousPageBorderBoxCenter:x,draggable:m,isOver:c,draggables:y,droppables:w,viewport:e.viewport,afterCritical:e.afterCritical})};function zc(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function l6(e){const t=No(e.top,e.bottom),r=No(e.left,e.right);return function(a){return t(a.y)&&r(a.x)}}function YM(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function ZM({pageBorderBox:e,draggable:t,candidates:r}){const n=t.page.borderBox.center,a=r.map(c=>{const l=c.axis,d=au(c.axis.line,e.center[l.line],c.page.borderBox.center[l.crossAxisLine]);return{id:c.descriptor.id,distance:P0(n,d)}}).sort((c,l)=>l.distance-c.distance);return a[0]?a[0].id:null}function KM({pageBorderBox:e,draggable:t,droppables:r}){const n=dp(r).filter(a=>{if(!a.isEnabled)return!1;const c=a.subject.active;if(!c||!YM(e,c))return!1;if(l6(c)(e.center))return!0;const l=a.axis,d=c.center[l.crossAxisLine],f=e[l.crossAxisStart],m=e[l.crossAxisEnd],x=No(c[l.crossAxisStart],c[l.crossAxisEnd]),y=x(f),w=x(m);return!y&&!w?!0:y?f<d:m>d});return n.length?n.length===1?n[0].descriptor.id:ZM({pageBorderBox:e,draggable:t,candidates:n}):null}const c6=(e,t)=>Jo(K0(e,t));var XM=(e,t)=>{const r=e.frame;return r?c6(t,r.scroll.diff.value):t};function u6({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function JM({draggable:e,closest:t,inHomeList:r}){return t?r&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var ej=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:r,insideDestination:n,last:a,viewport:c,afterCritical:l})=>{const d=r.axis,f=X0(r.axis,t.displaceBy),m=f.value,x=e[d.start],y=e[d.end],v=fp(t,n).find(C=>{const L=C.descriptor.id,N=C.page.borderBox.center[d.line],D=Tc(L,l),O=u6({displaced:a,id:L});return D?O?y<=N:x<N-m:O?y<=N+m:x<N})||null,T=JM({draggable:t,closest:v,inHomeList:xd(t,r)});return Gf({draggable:t,insideDestination:n,destination:r,viewport:c,last:a,displacedBy:f,index:T})};const tj=4;var rj=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:r,destination:n,insideDestination:a,afterCritical:c})=>{if(!n.isCombineEnabled)return null;const l=n.axis,d=X0(n.axis,e.displaceBy),f=d.value,m=t[l.start],x=t[l.end],w=fp(e,a).find(T=>{const C=T.descriptor.id,L=T.page.borderBox,D=L[l.size]/tj,O=Tc(C,c),P=u6({displaced:r.displaced,id:C});return O?P?x>L[l.start]+D&&x<L[l.end]-D:m>L[l.start]-f+D&&m<L[l.end]-f-D:P?x>L[l.start]+f+D&&x<L[l.end]+f-D:m>L[l.start]+D&&m<L[l.end]-D});return w?{displacedBy:d,displaced:r.displaced,at:{type:"COMBINE",combine:{draggableId:w.descriptor.id,droppableId:n.descriptor.id}}}:null},d6=({pageOffset:e,draggable:t,draggables:r,droppables:n,previousImpact:a,viewport:c,afterCritical:l})=>{const d=c6(t.page.borderBox,e),f=KM({pageBorderBox:d,draggable:t,droppables:n});if(!f)return gM;const m=n[f],x=gd(m.descriptor.id,r),y=XM(m,d);return rj({pageBorderBoxWithDroppableScroll:y,draggable:t,previousImpact:a,destination:m,insideDestination:x,afterCritical:l})||ej({pageBorderBoxWithDroppableScroll:y,draggable:t,destination:m,insideDestination:x,last:a.displaced,viewport:c,afterCritical:l})},Bg=(e,t)=>({...e,[t.descriptor.id]:t});const nj=({previousImpact:e,impact:t,droppables:r})=>{const n=to(e),a=to(t);if(!n||n===a)return r;const c=r[n];if(!c.subject.withPlaceholder)return r;const l=HM(c);return Bg(r,l)};var sj=({draggable:e,draggables:t,droppables:r,previousImpact:n,impact:a})=>{const c=nj({previousImpact:n,impact:a,droppables:r}),l=to(a);if(!l)return c;const d=r[l];if(xd(e,d)||d.subject.withPlaceholder)return c;const f=o6(d,e,t);return Bg(c,f)},S0=({state:e,clientSelection:t,dimensions:r,viewport:n,impact:a,scrollJumpRequest:c})=>{const l=n||e.viewport,d=r||e.dimensions,f=t||e.current.client.selection,m=Ja(f,e.initial.client.selection),x={offset:m,selection:f,borderBoxCenter:Ui(e.initial.client.borderBoxCenter,m)},y={selection:Ui(x.selection,l.scroll.current),borderBoxCenter:Ui(x.borderBoxCenter,l.scroll.current),offset:Ui(x.offset,l.scroll.diff.value)},w={client:x,page:y};if(e.phase==="COLLECTING")return{...e,dimensions:d,viewport:l,current:w};const v=d.draggables[e.critical.draggable.id],T=a||d6({pageOffset:y.offset,draggable:v,draggables:d.draggables,droppables:d.droppables,previousImpact:e.impact,viewport:l,afterCritical:e.afterCritical}),C=sj({draggable:v,impact:T,previousImpact:e.impact,draggables:d.draggables,droppables:d.droppables});return{...e,current:w,dimensions:{draggables:d.draggables,droppables:C},impact:T,viewport:l,scrollJumpRequest:c||null,forceShouldAnimate:c?!1:null}};function ij(e,t){return e.map(r=>t[r])}var h6=({impact:e,viewport:t,draggables:r,destination:n,forceShouldAnimate:a})=>{const c=e.displaced,l=ij(c.all,r),d=F0({afterDragging:l,destination:n,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:a,last:c});return{...e,displaced:d}},f6=({impact:e,draggable:t,droppable:r,draggables:n,viewport:a,afterCritical:c})=>{const l=pp({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:c});return Dg({pageBorderBoxCenter:l,draggable:t,viewport:a})},p6=({state:e,dimensions:t,viewport:r})=>{e.movementMode!=="SNAP"&&zt();const n=e.impact,a=r||e.viewport,c=t||e.dimensions,{draggables:l,droppables:d}=c,f=l[e.critical.draggable.id],m=to(n);m||zt();const x=d[m],y=h6({impact:n,viewport:a,destination:x,draggables:l}),w=f6({impact:y,draggable:f,droppable:x,draggables:l,viewport:a,afterCritical:e.afterCritical});return S0({impact:y,clientSelection:w,state:e,dimensions:c,viewport:a})},aj=e=>({index:e.index,droppableId:e.droppableId}),m6=({draggable:e,home:t,draggables:r,viewport:n})=>{const a=X0(t.axis,e.displaceBy),c=gd(t.descriptor.id,r),l=c.indexOf(e);l===-1&&zt();const d=c.slice(l+1),f=d.reduce((w,v)=>(w[v.descriptor.id]=!0,w),{}),m={inVirtualList:t.descriptor.mode==="virtual",displacedBy:a,effected:f};return{impact:{displaced:F0({afterDragging:d,destination:t,displacedBy:a,last:null,viewport:n.frame,forceShouldAnimate:!1}),displacedBy:a,at:{type:"REORDER",destination:aj(e.descriptor)}},afterCritical:m}},oj=(e,t)=>({draggables:e.draggables,droppables:Bg(e.droppables,t)}),lj=({draggable:e,offset:t,initialWindowScroll:r})=>{const n=$f(e.client,t),a=Uf(n,r);return{...e,placeholder:{...e.placeholder,client:n},client:n,page:a}},cj=e=>{const t=e.frame;return t||zt(),t},uj=({additions:e,updatedDroppables:t,viewport:r})=>{const n=r.scroll.diff.value;return e.map(a=>{const c=a.descriptor.droppableId,l=t[c],f=cj(l).scroll.diff.value,m=Ui(n,f);return lj({draggable:a,offset:m,initialWindowScroll:r.scroll.initial})})},dj=({state:e,published:t})=>{const r=t.modified.map(N=>{const D=e.dimensions.droppables[N.droppableId];return Eg(D,N.scroll)}),n={...e.dimensions.droppables,...Kv(r)},a=Xv(uj({additions:t.additions,updatedDroppables:n,viewport:e.viewport})),c={...e.dimensions.draggables,...a};t.removals.forEach(N=>{delete c[N]});const l={droppables:n,draggables:c},d=to(e.impact),f=d?l.droppables[d]:null,m=l.draggables[e.critical.draggable.id],x=l.droppables[e.critical.droppable.id],{impact:y,afterCritical:w}=m6({draggable:m,home:x,draggables:c,viewport:e.viewport}),v=f&&f.isCombineEnabled?e.impact:y,T=d6({pageOffset:e.current.page.offset,draggable:l.draggables[e.critical.draggable.id],draggables:l.draggables,droppables:l.droppables,previousImpact:v,viewport:e.viewport,afterCritical:w}),C={...e,phase:"DRAGGING",impact:T,onLiftImpact:y,dimensions:l,afterCritical:w,forceShouldAnimate:!1};return e.phase==="COLLECTING"?C:{...C,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const Q1=e=>e.movementMode==="SNAP",km=(e,t,r)=>{const n=oj(e.dimensions,t);return!Q1(e)||r?S0({state:e,dimensions:n}):p6({state:e,dimensions:n})};function Lm(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const U5={phase:"IDLE",completed:null,shouldFlush:!1};var hj=(e=U5,t)=>{if(t.type==="FLUSH")return{...U5,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&zt();const{critical:r,clientSelection:n,viewport:a,dimensions:c,movementMode:l}=t.payload,d=c.draggables[r.draggable.id],f=c.droppables[r.droppable.id],m={selection:n,borderBoxCenter:d.client.borderBox.center,offset:ki},x={client:m,page:{selection:Ui(m.selection,a.scroll.initial),borderBoxCenter:Ui(m.selection,a.scroll.initial),offset:Ui(m.selection,a.scroll.diff.value)}},y=dp(c.droppables).every(C=>!C.isFixedOnPage),{impact:w,afterCritical:v}=m6({draggable:d,home:f,draggables:c.draggables,viewport:a});return{phase:"DRAGGING",isDragging:!0,critical:r,movementMode:l,dimensions:c,initial:x,current:x,isWindowScrollAllowed:y,impact:w,afterCritical:v,onLiftImpact:w,viewport:a,scrollJumpRequest:null,forceShouldAnimate:null}}if(t.type==="COLLECTION_STARTING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"?e:(e.phase!=="DRAGGING"&&zt(),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||zt(),dj({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;zc(e)||zt();const{client:r}=t.payload;return vc(r,e.current.client.selection)?e:S0({state:e,clientSelection:r,impact:Q1(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return Lm(e);zc(e)||zt();const{id:r,newScroll:n}=t.payload,a=e.dimensions.droppables[r];if(!a)return e;const c=Eg(a,n);return km(e,c,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;zc(e)||zt();const{id:r,isEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||zt(),a.isEnabled===n&&zt();const c={...a,isEnabled:n};return km(e,c,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;zc(e)||zt();const{id:r,isCombineEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||zt(),a.isCombineEnabled===n&&zt();const c={...a,isCombineEnabled:n};return km(e,c,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;zc(e)||zt(),e.isWindowScrollAllowed||zt();const r=t.payload.newScroll;if(vc(e.viewport.scroll.current,r))return Lm(e);const n=s6(e.viewport,r);return Q1(e)?p6({state:e,viewport:n}):S0({state:e,viewport:n})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!zc(e))return e;const r=t.payload.maxScroll;if(vc(r,e.viewport.scroll.max))return e;const n={...e.viewport,scroll:{...e.viewport.scroll,max:r}};return{...e,viewport:n}}if(t.type==="MOVE_UP"||t.type==="MOVE_DOWN"||t.type==="MOVE_LEFT"||t.type==="MOVE_RIGHT"){if(e.phase==="COLLECTING"||e.phase==="DROP_PENDING")return e;e.phase!=="DRAGGING"&&zt();const r=qM({state:e,type:t.type});return r?S0({state:e,impact:r.impact,clientSelection:r.clientSelection,scrollJumpRequest:r.scrollJumpRequest}):e}if(t.type==="DROP_PENDING"){const r=t.payload.reason;return e.phase!=="COLLECTING"&&zt(),{...e,phase:"DROP_PENDING",isWaiting:!0,reason:r}}if(t.type==="DROP_ANIMATE"){const{completed:r,dropDuration:n,newHomeClientOffset:a}=t.payload;return e.phase==="DRAGGING"||e.phase==="DROP_PENDING"||zt(),{phase:"DROP_ANIMATING",completed:r,dropDuration:n,newHomeClientOffset:a,dimensions:e.dimensions}}if(t.type==="DROP_COMPLETE"){const{completed:r}=t.payload;return{phase:"IDLE",completed:r,shouldFlush:!1}}return e};function Yn(e,t){return e instanceof Object&&"type"in e&&e.type===t}const fj=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),pj=e=>({type:"LIFT",payload:e}),mj=e=>({type:"INITIAL_PUBLISH",payload:e}),gj=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),xj=()=>({type:"COLLECTION_STARTING",payload:null}),bj=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),yj=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),vj=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),g6=e=>({type:"MOVE",payload:e}),wj=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),Aj=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),Tj=()=>({type:"MOVE_UP",payload:null}),Sj=()=>({type:"MOVE_DOWN",payload:null}),Cj=()=>({type:"MOVE_RIGHT",payload:null}),_j=()=>({type:"MOVE_LEFT",payload:null}),Qg=()=>({type:"FLUSH",payload:null}),kj=e=>({type:"DROP_ANIMATE",payload:e}),Pg=e=>({type:"DROP_COMPLETE",payload:e}),x6=e=>({type:"DROP",payload:e}),Lj=e=>({type:"DROP_PENDING",payload:e}),b6=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var Ij=e=>({getState:t,dispatch:r})=>n=>a=>{if(!Yn(a,"LIFT")){n(a);return}const{id:c,clientSelection:l,movementMode:d}=a.payload,f=t();f.phase==="DROP_ANIMATING"&&r(Pg({completed:f.completed})),t().phase!=="IDLE"&&zt(),r(Qg()),r(fj({draggableId:c,movementMode:d}));const x={draggableId:c,scrollOptions:{shouldPublishImmediately:d==="SNAP"}},{critical:y,dimensions:w,viewport:v}=e.startPublishing(x);r(mj({critical:y,dimensions:w,clientSelection:l,movementMode:d,viewport:v}))},Ej=e=>()=>t=>r=>{Yn(r,"INITIAL_PUBLISH")&&e.dragging(),Yn(r,"DROP_ANIMATE")&&e.dropping(r.payload.completed.result.reason),(Yn(r,"FLUSH")||Yn(r,"DROP_COMPLETE"))&&e.resting(),t(r)};const Og={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},$0={opacity:{drop:0,combining:.7},scale:{drop:.75}},y6={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},Uc=`${y6.outOfTheWay}s ${Og.outOfTheWay}`,C0={fluid:`opacity ${Uc}`,snap:`transform ${Uc}, opacity ${Uc}`,drop:e=>{const t=`${e}s ${Og.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${Uc}`,placeholder:`height ${Uc}, width ${Uc}, margin ${Uc}`},z5=e=>vc(e,ki)?void 0:`translate(${e.x}px, ${e.y}px)`,P1={moveTo:z5,drop:(e,t)=>{const r=z5(e);if(r)return t?`${r} scale(${$0.scale.drop})`:r}},{minDropTime:O1,maxDropTime:v6}=y6,Nj=v6-O1,H5=1500,Rj=.6;var Mj=({current:e,destination:t,reason:r})=>{const n=P0(e,t);if(n<=0)return O1;if(n>=H5)return v6;const a=n/H5,c=O1+Nj*a,l=r==="CANCEL"?c*Rj:c;return Number(l.toFixed(2))},jj=({impact:e,draggable:t,dimensions:r,viewport:n,afterCritical:a})=>{const{draggables:c,droppables:l}=r,d=to(e),f=d?l[d]:null,m=l[t.descriptor.droppableId],x=f6({impact:e,draggable:t,draggables:c,afterCritical:a,droppable:f||m,viewport:n});return Ja(x,t.client.borderBox.center)},Dj=({draggables:e,reason:t,lastImpact:r,home:n,viewport:a,onLiftImpact:c})=>!r.at||t!=="DROP"?{impact:h6({draggables:e,impact:c,destination:n,viewport:a,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:r.at.type==="REORDER"?{impact:r,didDropInsideDroppable:!0}:{impact:{...r,displaced:O0},didDropInsideDroppable:!0};const Bj=({getState:e,dispatch:t})=>r=>n=>{if(!Yn(n,"DROP")){r(n);return}const a=e(),c=n.payload.reason;if(a.phase==="COLLECTING"){t(Lj({reason:c}));return}if(a.phase==="IDLE")return;a.phase==="DROP_PENDING"&&a.isWaiting&&zt(),a.phase==="DRAGGING"||a.phase==="DROP_PENDING"||zt();const d=a.critical,f=a.dimensions,m=f.draggables[a.critical.draggable.id],{impact:x,didDropInsideDroppable:y}=Dj({reason:c,lastImpact:a.impact,afterCritical:a.afterCritical,onLiftImpact:a.onLiftImpact,home:a.dimensions.droppables[a.critical.droppable.id],viewport:a.viewport,draggables:a.dimensions.draggables}),w=y?Ng(x):null,v=y?hp(x):null,T={index:d.draggable.index,droppableId:d.droppable.id},C={draggableId:m.descriptor.id,type:m.descriptor.type,source:T,reason:c,mode:a.movementMode,destination:w,combine:v},L=jj({impact:x,draggable:m,dimensions:f,viewport:a.viewport,afterCritical:a.afterCritical}),N={critical:a.critical,afterCritical:a.afterCritical,result:C,impact:x};if(!(!vc(a.current.client.offset,L)||!!C.combine)){t(Pg({completed:N}));return}const O=Mj({current:a.current.client.offset,destination:L,reason:c});t(kj({newHomeClientOffset:L,dropDuration:O,completed:N}))};var w6=()=>({x:window.pageXOffset,y:window.pageYOffset});function Qj(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function Pj({onWindowScroll:e}){function t(){e(w6())}const r=Q0(t),n=Qj(r);let a=yc;function c(){return a!==yc}function l(){c()&&zt(),a=Eo(window,[n])}function d(){c()||zt(),r.cancel(),a(),a=yc}return{start:l,stop:d,isActive:c}}const Oj=e=>Yn(e,"DROP_COMPLETE")||Yn(e,"DROP_ANIMATE")||Yn(e,"FLUSH"),Fj=e=>{const t=Pj({onWindowScroll:r=>{e.dispatch(wj({newScroll:r}))}});return r=>n=>{!t.isActive()&&Yn(n,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&Oj(n)&&t.stop(),r(n)}};var $j=e=>{let t=!1,r=!1;const n=setTimeout(()=>{r=!0}),a=c=>{t||r||(t=!0,e(c),clearTimeout(n))};return a.wasCalled=()=>t,a},Uj=()=>{const e=[],t=a=>{const c=e.findIndex(d=>d.timerId===a);c===-1&&zt();const[l]=e.splice(c,1);l.callback()};return{add:a=>{const c=setTimeout(()=>t(c)),l={timerId:c,callback:a};e.push(l)},flush:()=>{if(!e.length)return;const a=[...e];e.length=0,a.forEach(c=>{clearTimeout(c.timerId),c.callback()})}}};const zj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,Hj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,Wj=(e,t)=>{if(e===t)return!0;const r=e.draggable.id===t.draggable.id&&e.draggable.droppableId===t.draggable.droppableId&&e.draggable.type===t.draggable.type&&e.draggable.index===t.draggable.index,n=e.droppable.id===t.droppable.id&&e.droppable.type===t.droppable.type;return r&&n},qd=(e,t)=>{t()},Ph=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function Im(e,t,r,n){if(!e){r(n(t));return}const a=$j(r);e(t,{announce:a}),a.wasCalled()||r(n(t))}var Gj=(e,t)=>{const r=Uj();let n=null;const a=(y,w)=>{n&&zt(),qd("onBeforeCapture",()=>{const v=e().onBeforeCapture;v&&v({draggableId:y,mode:w})})},c=(y,w)=>{n&&zt(),qd("onBeforeDragStart",()=>{const v=e().onBeforeDragStart;v&&v(Ph(y,w))})},l=(y,w)=>{n&&zt();const v=Ph(y,w);n={mode:w,lastCritical:y,lastLocation:v.source,lastCombine:null},r.add(()=>{qd("onDragStart",()=>Im(e().onDragStart,v,t,gf.onDragStart))})},d=(y,w)=>{const v=Ng(w),T=hp(w);n||zt();const C=!Wj(y,n.lastCritical);C&&(n.lastCritical=y);const L=!zj(n.lastLocation,v);L&&(n.lastLocation=v);const N=!Hj(n.lastCombine,T);if(N&&(n.lastCombine=T),!C&&!L&&!N)return;const D={...Ph(y,n.mode),combine:T,destination:v};r.add(()=>{qd("onDragUpdate",()=>Im(e().onDragUpdate,D,t,gf.onDragUpdate))})},f=()=>{n||zt(),r.flush()},m=y=>{n||zt(),n=null,qd("onDragEnd",()=>Im(e().onDragEnd,y,t,gf.onDragEnd))};return{beforeCapture:a,beforeStart:c,start:l,update:d,flush:f,drop:m,abort:()=>{if(!n)return;const y={...Ph(n.lastCritical,n.mode),combine:null,destination:null,reason:"CANCEL"};m(y)}}},Vj=(e,t)=>{const r=Gj(e,t);return n=>a=>c=>{if(Yn(c,"BEFORE_INITIAL_CAPTURE")){r.beforeCapture(c.payload.draggableId,c.payload.movementMode);return}if(Yn(c,"INITIAL_PUBLISH")){const d=c.payload.critical;r.beforeStart(d,c.payload.movementMode),a(c),r.start(d,c.payload.movementMode);return}if(Yn(c,"DROP_COMPLETE")){const d=c.payload.completed.result;r.flush(),a(c),r.drop(d);return}if(a(c),Yn(c,"FLUSH")){r.abort();return}const l=n.getState();l.phase==="DRAGGING"&&r.update(l.critical,l.impact)}};const qj=e=>t=>r=>{if(!Yn(r,"DROP_ANIMATION_FINISHED")){t(r);return}const n=e.getState();n.phase!=="DROP_ANIMATING"&&zt(),e.dispatch(Pg({completed:n.completed}))},Yj=e=>{let t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return a=>c=>{if((Yn(c,"FLUSH")||Yn(c,"DROP_COMPLETE")||Yn(c,"DROP_ANIMATION_FINISHED"))&&n(),a(c),!Yn(c,"DROP_ANIMATE"))return;const l={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(b6())}};r=requestAnimationFrame(()=>{r=null,t=Eo(window,[l])})}};var Zj=e=>()=>t=>r=>{(Yn(r,"DROP_COMPLETE")||Yn(r,"FLUSH")||Yn(r,"DROP_ANIMATE"))&&e.stopPublishing(),t(r)},Kj=e=>{let t=!1;return()=>r=>n=>{if(Yn(n,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if(Yn(n,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(Yn(n,"DROP_COMPLETE")){t=!1;const a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const Xj=e=>Yn(e,"DROP_COMPLETE")||Yn(e,"DROP_ANIMATE")||Yn(e,"FLUSH");var Jj=e=>t=>r=>n=>{if(Xj(n)){e.stop(),r(n);return}if(Yn(n,"INITIAL_PUBLISH")){r(n);const a=t.getState();a.phase!=="DRAGGING"&&zt(),e.start(a);return}r(n),e.scroll(t.getState())};const eD=e=>t=>r=>{if(t(r),!Yn(r,"PUBLISH_WHILE_DRAGGING"))return;const n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch(x6({reason:n.reason})))},tD=Qv;var rD=({dimensionMarshal:e,focusMarshal:t,styleMarshal:r,getResponders:n,announce:a,autoScroller:c})=>Bv(hj,tD(JN(Ej(r),Zj(e),Ij(e),Bj,qj,Yj,eD,Jj(c),Fj,Kj(t),Vj(n,a))));const Em=()=>({additions:{},removals:{},modified:{}});function nD({registry:e,callbacks:t}){let r=Em(),n=null;const a=()=>{n||(t.collectionStarting(),n=requestAnimationFrame(()=>{n=null;const{additions:f,removals:m,modified:x}=r,y=Object.keys(f).map(T=>e.draggable.getById(T).getDimension(ki)).sort((T,C)=>T.descriptor.index-C.descriptor.index),w=Object.keys(x).map(T=>{const L=e.droppable.getById(T).callbacks.getScrollWhileDragging();return{droppableId:T,scroll:L}}),v={additions:y,removals:Object.keys(m),modified:w};r=Em(),t.publish(v)}))};return{add:f=>{const m=f.descriptor.id;r.additions[m]=f,r.modified[f.descriptor.droppableId]=!0,r.removals[m]&&delete r.removals[m],a()},remove:f=>{const m=f.descriptor;r.removals[m.id]=!0,r.modified[m.droppableId]=!0,r.additions[m.id]&&delete r.additions[m.id],a()},stop:()=>{n&&(cancelAnimationFrame(n),n=null,r=Em())}}}var A6=({scrollHeight:e,scrollWidth:t,height:r,width:n})=>{const a=Ja({x:t,y:e},{x:n,y:r});return{x:Math.max(0,a.x),y:Math.max(0,a.y)}},T6=()=>{const e=document.documentElement;return e||zt(),e},S6=()=>{const e=T6();return A6({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},sD=()=>{const e=w6(),t=S6(),r=e.y,n=e.x,a=T6(),c=a.clientWidth,l=a.clientHeight,d=n+c,f=r+l;return{frame:Jo({top:r,left:n,right:d,bottom:f}),scroll:{initial:e,current:e,max:t,diff:{value:ki,displacement:ki}}}},iD=({critical:e,scrollOptions:t,registry:r})=>{const n=sD(),a=n.scroll.current,c=e.droppable,l=r.droppable.getAllByType(c.type).map(x=>x.callbacks.getDimensionAndWatchScroll(a,t)),d=r.draggable.getAllByType(e.draggable.type).map(x=>x.getDimension(a));return{dimensions:{draggables:Xv(d),droppables:Kv(l)},critical:e,viewport:n}};function W5(e,t,r){return!(r.descriptor.id===t.id||r.descriptor.type!==t.type||e.droppable.getById(r.descriptor.droppableId).descriptor.mode!=="virtual")}var aD=(e,t)=>{let r=null;const n=nD({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=(w,v)=>{e.droppable.exists(w)||zt(),r&&t.updateDroppableIsEnabled({id:w,isEnabled:v})},c=(w,v)=>{r&&(e.droppable.exists(w)||zt(),t.updateDroppableIsCombineEnabled({id:w,isCombineEnabled:v}))},l=(w,v)=>{r&&(e.droppable.exists(w)||zt(),t.updateDroppableScroll({id:w,newScroll:v}))},d=(w,v)=>{r&&e.droppable.getById(w).callbacks.scroll(v)},f=()=>{if(!r)return;n.stop();const w=r.critical.droppable;e.droppable.getAllByType(w.type).forEach(v=>v.callbacks.dragStopped()),r.unsubscribe(),r=null},m=w=>{r||zt();const v=r.critical.draggable;w.type==="ADDITION"&&W5(e,v,w.value)&&n.add(w.value),w.type==="REMOVAL"&&W5(e,v,w.value)&&n.remove(w.value)};return{updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:c,scrollDroppable:d,updateDroppableScroll:l,startPublishing:w=>{r&&zt();const v=e.draggable.getById(w.draggableId),T=e.droppable.getById(v.descriptor.droppableId),C={draggable:v.descriptor,droppable:T.descriptor},L=e.subscribe(m);return r={critical:C,unsubscribe:L},iD({critical:C,registry:e,scrollOptions:w.scrollOptions})},stopPublishing:f}},C6=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",oD=e=>{window.scrollBy(e.x,e.y)};const lD=_i(e=>dp(e).filter(t=>!(!t.isEnabled||!t.frame))),cD=(e,t)=>lD(t).find(n=>(n.frame||zt(),l6(n.frame.pageMarginBox)(e)))||null;var uD=({center:e,destination:t,droppables:r})=>{if(t){const a=r[t];return a.frame?a:null}return cD(e,r)};const U0={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var dD=(e,t,r=()=>U0)=>{const n=r(),a=e[t.size]*n.startFromPercentage,c=e[t.size]*n.maxScrollAtPercentage;return{startScrollingFrom:a,maxScrollValueAt:c}},_6=({startOfRange:e,endOfRange:t,current:r})=>{const n=t-e;return n===0?0:(r-e)/n},Fg=1,hD=(e,t,r=()=>U0)=>{const n=r();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return n.maxPixelScroll;if(e===t.startScrollingFrom)return Fg;const c=1-_6({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),l=n.maxPixelScroll*n.ease(c);return Math.ceil(l)},fD=(e,t,r)=>{const n=r(),a=n.durationDampening.accelerateAt,c=n.durationDampening.stopDampeningAt,l=t,d=c,m=Date.now()-l;if(m>=c)return e;if(m<a)return Fg;const x=_6({startOfRange:a,endOfRange:d,current:m}),y=e*n.ease(x);return Math.ceil(y)},G5=({distanceToEdge:e,thresholds:t,dragStartTime:r,shouldUseTimeDampening:n,getAutoScrollerOptions:a})=>{const c=hD(e,t,a);return c===0?0:n?Math.max(fD(c,r,a),Fg):c},V5=({container:e,distanceToEdges:t,dragStartTime:r,axis:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=dD(e,n,c);return t[n.end]<t[n.start]?G5({distanceToEdge:t[n.end],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c}):-1*G5({distanceToEdge:t[n.start],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c})},pD=({container:e,subject:t,proposedScroll:r})=>{const n=t.height>e.height,a=t.width>e.width;return!a&&!n?r:a&&n?null:{x:a?0:r.x,y:n?0:r.y}};const mD=Zv(e=>e===0?0:e);var k6=({dragStartTime:e,container:t,subject:r,center:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l={top:n.y-t.top,right:t.right-n.x,bottom:t.bottom-n.y,left:n.x-t.left},d=V5({container:t,distanceToEdges:l,dragStartTime:e,axis:Rg,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),f=V5({container:t,distanceToEdges:l,dragStartTime:e,axis:t6,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),m=mD({x:f,y:d});if(vc(m,ki))return null;const x=pD({container:t,subject:r,proposedScroll:m});return x?vc(x,ki)?null:x:null};const gD=Zv(e=>e===0?0:e>0?1:-1),$g=(()=>{const e=(t,r)=>t<0?t:t>r?t-r:0;return({current:t,max:r,change:n})=>{const a=Ui(t,n),c={x:e(a.x,r.x),y:e(a.y,r.y)};return vc(c,ki)?null:c}})(),L6=({max:e,current:t,change:r})=>{const n={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},a=gD(r),c=$g({max:n,current:t,change:a});return!c||a.x!==0&&c.x===0||a.y!==0&&c.y===0},Ug=(e,t)=>L6({current:e.scroll.current,max:e.scroll.max,change:t}),xD=(e,t)=>{if(!Ug(e,t))return null;const r=e.scroll.max,n=e.scroll.current;return $g({current:n,max:r,change:t})},zg=(e,t)=>{const r=e.frame;return r?L6({current:r.scroll.current,max:r.scroll.max,change:t}):!1},bD=(e,t)=>{const r=e.frame;return!r||!zg(e,t)?null:$g({current:r.scroll.current,max:r.scroll.max,change:t})};var yD=({viewport:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=k6({dragStartTime:n,container:e.frame,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return l&&Ug(e,l)?l:null},vD=({droppable:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=e.frame;if(!l)return null;const d=k6({dragStartTime:n,container:l.pageMarginBox,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return d&&zg(e,d)?d:null},q5=({state:e,dragStartTime:t,shouldUseTimeDampening:r,scrollWindow:n,scrollDroppable:a,getAutoScrollerOptions:c})=>{const l=e.current.page.borderBoxCenter,f=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const y=e.viewport,w=yD({dragStartTime:t,viewport:y,subject:f,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});if(w){n(w);return}}const m=uD({center:l,destination:to(e.impact),droppables:e.dimensions.droppables});if(!m)return;const x=vD({dragStartTime:t,droppable:m,subject:f,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});x&&a(m.descriptor.id,x)},wD=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r=()=>U0})=>{const n=Q0(e),a=Q0(t);let c=null;const l=m=>{c||zt();const{shouldUseTimeDampening:x,dragStartTime:y}=c;q5({state:m,scrollWindow:n,scrollDroppable:a,dragStartTime:y,shouldUseTimeDampening:x,getAutoScrollerOptions:r})};return{start:m=>{c&&zt();const x=Date.now();let y=!1;const w=()=>{y=!0};q5({state:m,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:w,scrollDroppable:w,getAutoScrollerOptions:r}),c={dragStartTime:x,shouldUseTimeDampening:y},y&&l(m)},stop:()=>{c&&(n.cancel(),a.cancel(),c=null)},scroll:l}},AD=({move:e,scrollDroppable:t,scrollWindow:r})=>{const n=(d,f)=>{const m=Ui(d.current.client.selection,f);e({client:m})},a=(d,f)=>{if(!zg(d,f))return f;const m=bD(d,f);if(!m)return t(d.descriptor.id,f),null;const x=Ja(f,m);return t(d.descriptor.id,x),Ja(f,x)},c=(d,f,m)=>{if(!d||!Ug(f,m))return m;const x=xD(f,m);if(!x)return r(m),null;const y=Ja(m,x);return r(y),Ja(m,y)};return d=>{const f=d.scrollJumpRequest;if(!f)return;const m=to(d.impact);m||zt();const x=a(d.dimensions.droppables[m],f);if(!x)return;const y=d.viewport,w=c(d.isWindowScrollAllowed,y,x);w&&n(d,w)}},TD=({scrollDroppable:e,scrollWindow:t,move:r,getAutoScrollerOptions:n})=>{const a=wD({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n}),c=AD({move:r,scrollWindow:t,scrollDroppable:e});return{scroll:f=>{if(!(n().disabled||f.phase!=="DRAGGING")){if(f.movementMode==="FLUID"){a.scroll(f);return}f.scrollJumpRequest&&c(f)}},start:a.start,stop:a.stop}};const od="data-rfd",ld=(()=>{const e=`${od}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),F1=(()=>{const e=`${od}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),SD=(()=>{const e=`${od}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Y5={contextId:`${od}-scroll-container-context-id`},CD=e=>t=>`[${t}="${e}"]`,Yd=(e,t)=>e.map(r=>{const n=r.styles[t];return n?`${r.selector} { ${n} }`:""}).join(" "),_D="pointer-events: none;";var kD=e=>{const t=CD(e),r=(()=>{const d=`
118
+ cursor: -webkit-grab;
119
+ cursor: grab;
120
+ `;return{selector:t(ld.contextId),styles:{always:`
121
+ -webkit-touch-callout: none;
122
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
123
+ touch-action: manipulation;
124
+ `,resting:d,dragging:_D,dropAnimating:d}}})(),n=(()=>{const d=`
125
+ transition: ${C0.outOfTheWay};
126
+ `;return{selector:t(F1.contextId),styles:{dragging:d,dropAnimating:d,userCancel:d}}})(),a={selector:t(SD.contextId),styles:{always:"overflow-anchor: none;"}},l=[n,r,a,{selector:"body",styles:{dragging:`
127
+ cursor: grabbing;
128
+ cursor: -webkit-grabbing;
129
+ user-select: none;
130
+ -webkit-user-select: none;
131
+ -moz-user-select: none;
132
+ -ms-user-select: none;
133
+ overflow-anchor: none;
134
+ `}}];return{always:Yd(l,"always"),resting:Yd(l,"resting"),dragging:Yd(l,"dragging"),dropAnimating:Yd(l,"dropAnimating"),userCancel:Yd(l,"userCancel")}};const ro=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,Nm=()=>{const e=document.querySelector("head");return e||zt(),e},Z5=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function LD(e,t){const r=En(()=>kD(e),[e]),n=b.useRef(null),a=b.useRef(null),c=Rr(_i(y=>{const w=a.current;w||zt(),w.textContent=y}),[]),l=Rr(y=>{const w=n.current;w||zt(),w.textContent=y},[]);ro(()=>{!n.current&&!a.current||zt();const y=Z5(t),w=Z5(t);return n.current=y,a.current=w,y.setAttribute(`${od}-always`,e),w.setAttribute(`${od}-dynamic`,e),Nm().appendChild(y),Nm().appendChild(w),l(r.always),c(r.resting),()=>{const v=T=>{const C=T.current;C||zt(),Nm().removeChild(C),T.current=null};v(n),v(a)}},[t,l,c,r.always,r.resting,e]);const d=Rr(()=>c(r.dragging),[c,r.dragging]),f=Rr(y=>{if(y==="DROP"){c(r.dropAnimating);return}c(r.userCancel)},[c,r.dropAnimating,r.userCancel]),m=Rr(()=>{a.current&&c(r.resting)},[c,r.resting]);return En(()=>({dragging:d,dropping:f,resting:m}),[d,f,m])}function I6(e,t){return Array.from(e.querySelectorAll(t))}var E6=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function mp(e){return e instanceof E6(e).HTMLElement}function ID(e,t){const r=`[${ld.contextId}="${e}"]`,n=I6(document,r);if(!n.length)return null;const a=n.find(c=>c.getAttribute(ld.draggableId)===t);return!a||!mp(a)?null:a}function ED(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),c=Rr(function(w,v){const T={id:w,focus:v};return t.current[w]=T,function(){const L=t.current;L[w]!==T&&delete L[w]}},[]),l=Rr(function(w){const v=ID(e,w);v&&v!==document.activeElement&&v.focus()},[e]),d=Rr(function(w,v){r.current===w&&(r.current=v)},[]),f=Rr(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const w=r.current;w&&l(w)}))},[l]),m=Rr(function(w){r.current=null;const v=document.activeElement;v&&v.getAttribute(ld.draggableId)===w&&(r.current=w)},[]);return ro(()=>(a.current=!0,function(){a.current=!1;const w=n.current;w&&cancelAnimationFrame(w)}),[]),En(()=>({register:c,tryRecordFocus:m,tryRestoreFocusRecorded:f,tryShiftRecord:d}),[c,m,f,d])}function ND(){const e={draggables:{},droppables:{}},t=[];function r(y){return t.push(y),function(){const v=t.indexOf(y);v!==-1&&t.splice(v,1)}}function n(y){t.length&&t.forEach(w=>w(y))}function a(y){return e.draggables[y]||null}function c(y){const w=a(y);return w||zt(),w}const l={register:y=>{e.draggables[y.descriptor.id]=y,n({type:"ADDITION",value:y})},update:(y,w)=>{const v=e.draggables[w.descriptor.id];v&&v.uniqueId===y.uniqueId&&(delete e.draggables[w.descriptor.id],e.draggables[y.descriptor.id]=y)},unregister:y=>{const w=y.descriptor.id,v=a(w);v&&y.uniqueId===v.uniqueId&&(delete e.draggables[w],e.droppables[y.descriptor.droppableId]&&n({type:"REMOVAL",value:y}))},getById:c,findById:a,exists:y=>!!a(y),getAllByType:y=>Object.values(e.draggables).filter(w=>w.descriptor.type===y)};function d(y){return e.droppables[y]||null}function f(y){const w=d(y);return w||zt(),w}const m={register:y=>{e.droppables[y.descriptor.id]=y},unregister:y=>{const w=d(y.descriptor.id);w&&y.uniqueId===w.uniqueId&&delete e.droppables[y.descriptor.id]},getById:f,findById:d,exists:y=>!!d(y),getAllByType:y=>Object.values(e.droppables).filter(w=>w.descriptor.type===y)};function x(){e.draggables={},e.droppables={},t.length=0}return{draggable:l,droppable:m,subscribe:r,clean:x}}function RD(){const e=En(ND,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var Hg=_.createContext(null),Vf=()=>{const e=document.body;return e||zt(),e};const MD={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},jD=e=>`rfd-announcement-${e}`;function DD(e){const t=En(()=>jD(e),[e]),r=b.useRef(null);return b.useEffect(function(){const c=document.createElement("div");return r.current=c,c.id=t,c.setAttribute("aria-live","assertive"),c.setAttribute("aria-atomic","true"),zf(c.style,MD),Vf().appendChild(c),function(){setTimeout(function(){const f=Vf();f.contains(c)&&f.removeChild(c),c===r.current&&(r.current=null)})}},[t]),Rr(a=>{const c=r.current;if(c){c.textContent=a;return}},[])}const BD={separator:"::"};function Wg(e,t=BD){const r=_.useId();return En(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function QD({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function PD({contextId:e,text:t}){const r=Wg("hidden-text",{separator:"-"}),n=En(()=>QD({contextId:e,uniqueId:r}),[r,e]);return b.useEffect(function(){const c=document.createElement("div");return c.id=n,c.textContent=t,c.style.display="none",Vf().appendChild(c),function(){const d=Vf();d.contains(c)&&d.removeChild(c)}},[n,t]),n}var gp=_.createContext(null);function N6(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function OD(){let e=null;function t(){return!!e}function r(l){return l===e}function n(l){e&&zt();const d={abandon:l};return e=d,d}function a(){e||zt(),e=null}function c(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:c}}function z0(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const FD=9,$D=13,Gg=27,R6=32,UD=33,zD=34,HD=35,WD=36,GD=37,VD=38,qD=39,YD=40,ZD={[$D]:!0,[FD]:!0};var M6=e=>{ZD[e.keyCode]&&e.preventDefault()};const xp=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),j6=0,K5=5;function KD(e,t){return Math.abs(t.x-e.x)>=K5||Math.abs(t.y-e.y)>=K5}const X5={type:"IDLE"};function XD({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:c,clientX:l,clientY:d}=a;if(c!==j6)return;const f={x:l,y:d},m=r();if(m.type==="DRAGGING"){a.preventDefault(),m.actions.move(f);return}m.type!=="PENDING"&&zt();const x=m.point;if(!KD(x,f))return;a.preventDefault();const y=m.actions.fluidLift(f);n({type:"DRAGGING",actions:y})}},{eventName:"mouseup",fn:a=>{const c=r();if(c.type!=="DRAGGING"){e();return}a.preventDefault(),c.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:a=>{r().type==="DRAGGING"&&a.preventDefault(),e()}},{eventName:"keydown",fn:a=>{if(r().type==="PENDING"){e();return}if(a.keyCode===Gg){a.preventDefault(),e();return}M6(a)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{r().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:a=>{const c=r();if(c.type==="IDLE"&&zt(),c.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:xp,fn:e}]}function JD(e){const t=b.useRef(X5),r=b.useRef(yc),n=En(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==j6||y.ctrlKey||y.metaKey||y.shiftKey||y.altKey)return;const w=e.findClosestDraggableId(y);if(!w)return;const v=e.tryGetLock(w,l,{sourceEvent:y});if(!v)return;y.preventDefault();const T={x:y.clientX,y:y.clientY};r.current(),m(v,T)}}),[e]),a=En(()=>({eventName:"webkitmouseforcewillbegin",fn:x=>{if(x.defaultPrevented)return;const y=e.findClosestDraggableId(x);if(!y)return;const w=e.findOptionsForDraggable(y);w&&(w.shouldRespectForcePress||e.canGetLock(y)&&x.preventDefault())}}),[e]),c=Rr(function(){const y={passive:!1,capture:!0};r.current=Eo(window,[a,n],y)},[a,n]),l=Rr(()=>{t.current.type!=="IDLE"&&(t.current=X5,r.current(),c())},[c]),d=Rr(()=>{const x=t.current;l(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[l]),f=Rr(function(){const y={capture:!0,passive:!1},w=XD({cancel:d,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=Eo(window,w,y)},[d,l]),m=Rr(function(y,w){t.current.type!=="IDLE"&&zt(),t.current={type:"PENDING",point:w,actions:y},f()},[f]);ro(function(){return c(),function(){r.current()}},[c])}function eB(){}const tB={[zD]:!0,[UD]:!0,[WD]:!0,[HD]:!0};function rB(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===Gg){a.preventDefault(),r();return}if(a.keyCode===R6){a.preventDefault(),n();return}if(a.keyCode===YD){a.preventDefault(),e.moveDown();return}if(a.keyCode===VD){a.preventDefault(),e.moveUp();return}if(a.keyCode===qD){a.preventDefault(),e.moveRight();return}if(a.keyCode===GD){a.preventDefault(),e.moveLeft();return}if(tB[a.keyCode]){a.preventDefault();return}M6(a)}},{eventName:"mousedown",fn:r},{eventName:"mouseup",fn:r},{eventName:"click",fn:r},{eventName:"touchstart",fn:r},{eventName:"resize",fn:r},{eventName:"wheel",fn:r,options:{passive:!0}},{eventName:xp,fn:r}]}function nB(e){const t=b.useRef(eB),r=En(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==R6)return;const l=e.findClosestDraggableId(c);if(!l)return;const d=e.tryGetLock(l,x,{sourceEvent:c});if(!d)return;c.preventDefault();let f=!0;const m=d.snapLift();t.current();function x(){f||zt(),f=!1,t.current(),n()}t.current=Eo(window,rB(m,x),{capture:!0,passive:!1})}}),[e]),n=Rr(function(){const c={passive:!1,capture:!0};t.current=Eo(window,[r],c)},[r]);ro(function(){return n(),function(){t.current()}},[n])}const Rm={type:"IDLE"},sB=120,iB=.15;function aB({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:r=>{r.preventDefault()}},{eventName:"keydown",fn:r=>{if(t().type!=="DRAGGING"){e();return}r.keyCode===Gg&&r.preventDefault(),e()}},{eventName:xp,fn:e}]}function oB({cancel:e,completed:t,getPhase:r}){return[{eventName:"touchmove",options:{capture:!1},fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}a.hasMoved=!0;const{clientX:c,clientY:l}=n.touches[0],d={x:c,y:l};n.preventDefault(),a.actions.move(d)}},{eventName:"touchend",fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}n.preventDefault(),a.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:n=>{if(r().type!=="DRAGGING"){e();return}n.preventDefault(),e()}},{eventName:"touchforcechange",fn:n=>{const a=r();a.type==="IDLE"&&zt();const c=n.touches[0];if(!c||!(c.force>=iB))return;const d=a.actions.shouldRespectForcePress();if(a.type==="PENDING"){d&&e();return}if(d){if(a.hasMoved){n.preventDefault();return}e();return}n.preventDefault()}},{eventName:xp,fn:e}]}function lB(e){const t=b.useRef(Rm),r=b.useRef(yc),n=Rr(function(){return t.current},[]),a=Rr(function(v){t.current=v},[]),c=En(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const T=e.findClosestDraggableId(v);if(!T)return;const C=e.tryGetLock(T,d,{sourceEvent:v});if(!C)return;const L=v.touches[0],{clientX:N,clientY:D}=L,O={x:N,y:D};r.current(),y(C,O)}}),[e]),l=Rr(function(){const v={capture:!0,passive:!1};r.current=Eo(window,[c],v)},[c]),d=Rr(()=>{const w=t.current;w.type!=="IDLE"&&(w.type==="PENDING"&&clearTimeout(w.longPressTimerId),a(Rm),r.current(),l())},[l,a]),f=Rr(()=>{const w=t.current;d(),w.type==="DRAGGING"&&w.actions.cancel({shouldBlockNextClick:!0}),w.type==="PENDING"&&w.actions.abort()},[d]),m=Rr(function(){const v={capture:!0,passive:!1},T={cancel:f,completed:d,getPhase:n},C=Eo(window,oB(T),v),L=Eo(window,aB(T),v);r.current=function(){C(),L()}},[f,n,d]),x=Rr(function(){const v=n();v.type!=="PENDING"&&zt();const T=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:T,hasMoved:!1})},[n,a]),y=Rr(function(v,T){n().type!=="IDLE"&&zt();const C=setTimeout(x,sB);a({type:"PENDING",point:T,actions:v,longPressTimerId:C}),m()},[m,n,a,x]);ro(function(){return l(),function(){r.current();const T=n();T.type==="PENDING"&&(clearTimeout(T.longPressTimerId),a(Rm))}},[n,l,a]),ro(function(){return Eo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const cB=["input","button","textarea","select","option","optgroup","video","audio"];function D6(e,t){if(t==null)return!1;if(cB.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:D6(e,t.parentElement)}function uB(e,t){const r=t.target;return mp(r)?D6(e,r):!1}var dB=e=>Jo(e.getBoundingClientRect()).center;function hB(e){return e instanceof E6(e).Element}const fB=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function B6(e,t){return e==null?null:e[fB](t)?e:B6(e.parentElement,t)}function pB(e,t){return e.closest?e.closest(t):B6(e,t)}function mB(e){return`[${ld.contextId}="${e}"]`}function gB(e,t){const r=t.target;if(!hB(r))return null;const n=mB(e),a=pB(r,n);return!a||!mp(a)?null:a}function xB(e,t){const r=gB(e,t);return r?r.getAttribute(ld.draggableId):null}function bB(e,t){const r=`[${F1.contextId}="${e}"]`,a=I6(document,r).find(c=>c.getAttribute(F1.id)===t);return!a||!mp(a)?null:a}function yB(e){e.preventDefault()}function Oh({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function Q6({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!C6(t.getState(),n))}function vB({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:c,sourceEvent:l}){if(!Q6({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const f=n.draggable.getById(a),m=bB(t,f.descriptor.id);if(!m||l&&!f.options.canDragInteractiveElements&&uB(m,l))return null;const x=e.claim(c||yc);let y="PRE_DRAG";function w(){return f.options.shouldRespectForcePress}function v(){return e.isActive(x)}function T(F,ee){Oh({expected:F,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(ee())}const C=T.bind(null,"DRAGGING");function L(F){function ee(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(ee(),zt()),r.dispatch(pj(F.liftActionArgs)),y="DRAGGING";function Z(G,de={shouldBlockNextClick:!1}){if(F.cleanup(),de.shouldBlockNextClick){const pe=Eo(window,[{eventName:"click",fn:yB,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(pe)}ee(),r.dispatch(x6({reason:G}))}return{isActive:()=>Oh({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,drop:G=>Z("DROP",G),cancel:G=>Z("CANCEL",G),...F.actions}}function N(F){const ee=Q0(G=>{C(()=>g6({client:G}))});return{...L({liftActionArgs:{id:a,clientSelection:F,movementMode:"FLUID"},cleanup:()=>ee.cancel(),actions:{move:ee}}),move:ee}}function D(){const F={moveUp:()=>C(Tj),moveRight:()=>C(Cj),moveDown:()=>C(Sj),moveLeft:()=>C(_j)};return L({liftActionArgs:{id:a,clientSelection:dB(m),movementMode:"SNAP"},cleanup:yc,actions:F})}function O(){Oh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>Oh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,fluidLift:N,snapLift:D,abort:O}}const wB=[JD,nB,lB];function AB({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const c=[...a?wB:[],...n||[]],l=b.useState(()=>OD())[0],d=Rr(function(L,N){z0(L)&&!z0(N)&&l.tryAbandon()},[l]);ro(function(){let L=t.getState();return t.subscribe(()=>{const D=t.getState();d(L,D),L=D})},[l,t,d]),ro(()=>l.tryAbandon,[l.tryAbandon]);const f=Rr(C=>Q6({lockAPI:l,registry:r,store:t,draggableId:C}),[l,r,t]),m=Rr((C,L,N)=>vB({lockAPI:l,registry:r,contextId:e,store:t,draggableId:C,forceSensorStop:L||null,sourceEvent:N&&N.sourceEvent?N.sourceEvent:null}),[e,l,r,t]),x=Rr(C=>xB(e,C),[e]),y=Rr(C=>{const L=r.draggable.findById(C);return L?L.options:null},[r.draggable]),w=Rr(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(Qg()))},[l,t]),v=Rr(()=>l.isClaimed(),[l]),T=En(()=>({canGetLock:f,tryGetLock:m,findClosestDraggableId:x,findOptionsForDraggable:y,tryReleaseLock:w,isLockClaimed:v}),[f,m,x,y,w,v]);for(let C=0;C<c.length;C++)c[C](T)}const TB=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};ci.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),SB=e=>({...U0,...e.autoScrollerOptions,durationDampening:{...U0.durationDampening,...e.autoScrollerOptions}});function Zd(e){return e.current||zt(),e.current}function CB(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:c}=e,l=b.useRef(null),d=N6(e),f=Rr(()=>TB(d.current),[d]),m=Rr(()=>SB(d.current),[d]),x=DD(t),y=PD({contextId:t,text:c}),w=LD(t,a),v=Rr(pe=>{Zd(l).dispatch(pe)},[]),T=En(()=>S5({publishWhileDragging:gj,updateDroppableScroll:bj,updateDroppableIsEnabled:yj,updateDroppableIsCombineEnabled:vj,collectionStarting:xj},v),[v]),C=RD(),L=En(()=>aD(C,T),[C,T]),N=En(()=>TD({scrollWindow:oD,scrollDroppable:L.scrollDroppable,getAutoScrollerOptions:m,...S5({move:g6},v)}),[L.scrollDroppable,v,m]),D=ED(t),O=En(()=>rD({announce:x,autoScroller:N,dimensionMarshal:L,focusMarshal:D,getResponders:f,styleMarshal:w}),[x,N,L,D,f,w]);l.current=O;const P=Rr(()=>{const pe=Zd(l);pe.getState().phase!=="IDLE"&&pe.dispatch(Qg())},[]),F=Rr(()=>{const pe=Zd(l).getState();return pe.phase==="DROP_ANIMATING"?!0:pe.phase==="IDLE"?!1:pe.isDragging},[]),ee=En(()=>({isDragging:F,tryAbort:P}),[F,P]);r(ee);const Z=Rr(pe=>C6(Zd(l).getState(),pe),[]),G=Rr(()=>zc(Zd(l).getState()),[]),de=En(()=>({marshal:L,focus:D,contextId:t,canLift:Z,isMovementAllowed:G,dragHandleUsageInstructionsId:y,registry:C}),[t,L,y,D,Z,G,C]);return AB({contextId:t,store:O,registry:C,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>P,[P]),_.createElement(gp.Provider,{value:de},_.createElement(ZR,{context:Hg,store:O},e.children))}function _B(){return _.useId()}function Yu(e){const t=_B(),r=e.dragHandleUsageInstructions||gf.dragHandleUsageInstructions;return _.createElement(nM,null,n=>_.createElement(CB,{nonce:e.nonce,contextId:t,setCallbacks:n,dragHandleUsageInstructions:r,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const J5={dragging:5e3,dropAnimating:4500},kB=(e,t)=>t?C0.drop(t.duration):e?C0.snap:C0.fluid,LB=(e,t)=>{if(e)return t?$0.opacity.drop:$0.opacity.combining},IB=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function EB(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:c}=e,l=!!a,d=IB(e),f=!!c,m=f?P1.drop(n,l):P1.moveTo(n);return{position:"fixed",top:r.marginBox.top,left:r.marginBox.left,boxSizing:"border-box",width:r.borderBox.width,height:r.borderBox.height,transition:kB(d,c),transform:m,opacity:LB(l,f),zIndex:f?J5.dropAnimating:J5.dragging,pointerEvents:"none"}}function NB(e){return{transform:P1.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function RB(e){return e.type==="DRAGGING"?EB(e):NB(e)}function MB(e,t,r=ki){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),c=Hv(a,n),l=Uf(c,r),d={client:c,tagName:t.tagName.toLowerCase(),display:n.display},f={x:c.marginBox.width,y:c.marginBox.height};return{descriptor:e,placeholder:d,displaceBy:f,client:c,page:l}}function jB(e){const t=Wg("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}=e,f=En(()=>({canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}),[c,d,l]),m=Rr(v=>{const T=a();return T||zt(),MB(r,T,v)},[r,a]),x=En(()=>({uniqueId:t,descriptor:r,options:f,getDimension:m}),[r,m,f,t]),y=b.useRef(x),w=b.useRef(!0);ro(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),ro(()=>{if(w.current){w.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var Vg=_.createContext(null);function qf(e){const t=b.useContext(e);return t||zt(),t}function DB(e){e.preventDefault()}const BB=e=>{const t=b.useRef(null),r=Rr((ee=null)=>{t.current=ee},[]),n=Rr(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:c,registry:l}=qf(gp),{type:d,droppableId:f}=qf(Vg),m=En(()=>({id:e.draggableId,index:e.index,type:d,droppableId:f}),[e.draggableId,e.index,d,f]),{children:x,draggableId:y,isEnabled:w,shouldRespectForcePress:v,canDragInteractiveElements:T,isClone:C,mapped:L,dropAnimationFinished:N}=e;if(!C){const ee=En(()=>({descriptor:m,registry:l,getDraggableRef:n,canDragInteractiveElements:T,shouldRespectForcePress:v,isEnabled:w}),[m,l,n,T,v,w]);jB(ee)}const D=En(()=>w?{tabIndex:0,role:"button","aria-describedby":c,"data-rfd-drag-handle-draggable-id":y,"data-rfd-drag-handle-context-id":a,draggable:!1,onDragStart:DB}:null,[a,c,y,w]),O=Rr(ee=>{L.type==="DRAGGING"&&L.dropping&&ee.propertyName==="transform"&&ci.flushSync(N)},[N,L]),P=En(()=>{const ee=RB(L),Z=L.type==="DRAGGING"&&L.dropping?O:void 0;return{innerRef:r,draggableProps:{"data-rfd-draggable-context-id":a,"data-rfd-draggable-id":y,style:ee,onTransitionEnd:Z},dragHandleProps:D}},[a,D,y,L,O,r]),F=En(()=>({draggableId:m.id,type:m.type,source:{index:m.index,droppableId:m.droppableId}}),[m.droppableId,m.id,m.index,m.type]);return _.createElement(_.Fragment,null,x(P,L.snapshot,F))};var P6=(e,t)=>e===t,O6=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const QB=e=>e.combine?e.combine.draggableId:null,PB=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function OB(){const e=_i((a,c)=>({x:a,y:c})),t=_i((a,c,l=null,d=null,f=null)=>({isDragging:!0,isClone:c,isDropAnimating:!!f,dropAnimation:f,mode:a,draggingOver:l,combineWith:d,combineTargetFor:null})),r=_i((a,c,l,d,f=null,m=null,x=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:f,combineWith:m,mode:c,offset:a,dimension:l,forceShouldAnimate:x,snapshot:t(c,d,f,m,null)}}));return(a,c)=>{if(z0(a)){if(a.critical.draggable.id!==c.draggableId)return null;const l=a.current.client.offset,d=a.dimensions.draggables[c.draggableId],f=to(a.impact),m=PB(a.impact),x=a.forceShouldAnimate;return r(e(l.x,l.y),a.movementMode,d,c.isClone,f,m,x)}if(a.phase==="DROP_ANIMATING"){const l=a.completed;if(l.result.draggableId!==c.draggableId)return null;const d=c.isClone,f=a.dimensions.draggables[c.draggableId],m=l.result,x=m.mode,y=O6(m),w=QB(m),T={duration:a.dropDuration,curve:Og.drop,moveTo:a.newHomeClientOffset,opacity:w?$0.opacity.drop:null,scale:w?$0.scale.drop:null};return{mapped:{type:"DRAGGING",offset:a.newHomeClientOffset,dimension:f,dropping:T,draggingOver:y,combineWith:w,mode:x,forceShouldAnimate:null,snapshot:t(x,d,y,w,T)}}}return null}}function F6(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const FB={mapped:{type:"SECONDARY",offset:ki,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:F6(null)}};function $B(){const e=_i((l,d)=>({x:l,y:d})),t=_i(F6),r=_i((l,d=null,f)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:d,shouldAnimateDisplacement:f,snapshot:t(d)}})),n=l=>l?r(ki,l,!0):null,a=(l,d,f,m)=>{const x=f.displaced.visible[l],y=!!(m.inVirtualList&&m.effected[l]),w=hp(f),v=w&&w.draggableId===l?d:null;if(!x){if(!y)return n(v);if(f.displaced.invisible[l])return null;const L=md(m.displacedBy.point),N=e(L.x,L.y);return r(N,v,!0)}if(y)return n(v);const T=f.displacedBy.point,C=e(T.x,T.y);return r(C,v,x.shouldAnimate)};return(l,d)=>{if(z0(l))return l.critical.draggable.id===d.draggableId?null:a(d.draggableId,l.critical.draggable.id,l.impact,l.afterCritical);if(l.phase==="DROP_ANIMATING"){const f=l.completed;return f.result.draggableId===d.draggableId?null:a(d.draggableId,f.result.draggableId,f.impact,f.afterCritical)}return null}}const UB=()=>{const e=OB(),t=$B();return(n,a)=>e(n,a)||t(n,a)||FB},zB={dropAnimationFinished:b6},HB=zv(UB,zB,null,{context:Hg,areStatePropsEqual:P6})(BB);function $6(e){return qf(Vg).isUsingCloneFor===e.draggableId&&!e.isClone?null:_.createElement(HB,e)}function Ul(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return _.createElement($6,zf({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const U6=e=>t=>e===t,WB=U6("scroll"),GB=U6("auto"),eb=(e,t)=>t(e.overflowX)||t(e.overflowY),VB=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return eb(r,WB)||eb(r,GB)},qB=()=>!1,z6=e=>e==null?null:e===document.body?qB()?e:null:e===document.documentElement?null:VB(e)?e:z6(e.parentElement);var $1=e=>({x:e.scrollLeft,y:e.scrollTop});const H6=e=>e?window.getComputedStyle(e).position==="fixed"?!0:H6(e.parentElement):!1;var YB=e=>{const t=z6(e),r=H6(e);return{closestScrollable:t,isFixedOnPage:r}},ZB=({descriptor:e,isEnabled:t,isCombineEnabled:r,isFixedOnPage:n,direction:a,client:c,page:l,closest:d})=>{const f=(()=>{if(!d)return null;const{scrollSize:w,client:v}=d,T=A6({scrollHeight:w.scrollHeight,scrollWidth:w.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:d.page.marginBox,frameClient:v,scrollSize:w,shouldClipSubject:d.shouldClipSubject,scroll:{initial:d.scroll,current:d.scroll,max:T,diff:{value:ki,displacement:ki}}}})(),m=a==="vertical"?Rg:t6,x=ad({page:l,withPlaceholder:null,axis:m,frame:f});return{descriptor:e,isCombineEnabled:r,isFixedOnPage:n,axis:m,isEnabled:t,client:c,page:l,frame:f,subject:x}};const KB=(e,t)=>{const r=Wv(e);if(!t||e!==t)return r;const n=r.paddingBox.top-t.scrollTop,a=r.paddingBox.left-t.scrollLeft,c=n+t.scrollHeight,l=a+t.scrollWidth,f=Lg({top:n,right:l,bottom:c,left:a},r.border);return Ig({borderBox:f,margin:r.margin,border:r.border,padding:r.padding})};var XB=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:c,isCombineEnabled:l,shouldClipSubject:d})=>{const f=r.closestScrollable,m=KB(e,f),x=Uf(m,n),y=(()=>{if(!f)return null;const v=Wv(f),T={scrollHeight:f.scrollHeight,scrollWidth:f.scrollWidth};return{client:v,page:Uf(v,n),scroll:$1(f),scrollSize:T,shouldClipSubject:d}})();return ZB({descriptor:t,isEnabled:!c,isCombineEnabled:l,isFixedOnPage:r.isFixedOnPage,direction:a,client:m,page:x,closest:y})};const JB={passive:!1},eQ={passive:!0};var tb=e=>e.shouldPublishImmediately?JB:eQ;const Fh=e=>e&&e.env.closestScrollable||null;function tQ(e){const t=b.useRef(null),r=qf(gp),n=Wg("droppable"),{registry:a,marshal:c}=r,l=N6(e),d=En(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),f=b.useRef(d),m=En(()=>_i((P,F)=>{t.current||zt();const ee={x:P,y:F};c.updateDroppableScroll(d.id,ee)}),[d.id,c]),x=Rr(()=>{const P=t.current;return!P||!P.env.closestScrollable?ki:$1(P.env.closestScrollable)},[]),y=Rr(()=>{const P=x();m(P.x,P.y)},[x,m]),w=En(()=>Q0(y),[y]),v=Rr(()=>{const P=t.current,F=Fh(P);if(P&&F||zt(),P.scrollOptions.shouldPublishImmediately){y();return}w()},[w,y]),T=Rr((P,F)=>{t.current&&zt();const ee=l.current,Z=ee.getDroppableRef();Z||zt();const G=YB(Z),de={ref:Z,descriptor:d,env:G,scrollOptions:F};t.current=de;const pe=XB({ref:Z,descriptor:d,env:G,windowScroll:P,direction:ee.direction,isDropDisabled:ee.isDropDisabled,isCombineEnabled:ee.isCombineEnabled,shouldClipSubject:!ee.ignoreContainerClipping}),J=G.closestScrollable;return J&&(J.setAttribute(Y5.contextId,r.contextId),J.addEventListener("scroll",v,tb(de.scrollOptions))),pe},[r.contextId,d,v,l]),C=Rr(()=>{const P=t.current,F=Fh(P);return P&&F||zt(),$1(F)},[]),L=Rr(()=>{const P=t.current;P||zt();const F=Fh(P);t.current=null,F&&(w.cancel(),F.removeAttribute(Y5.contextId),F.removeEventListener("scroll",v,tb(P.scrollOptions)))},[v,w]),N=Rr(P=>{const F=t.current;F||zt();const ee=Fh(F);ee||zt(),ee.scrollTop+=P.y,ee.scrollLeft+=P.x},[]),D=En(()=>({getDimensionAndWatchScroll:T,getScrollWhileDragging:C,dragStopped:L,scroll:N}),[L,T,C,N]),O=En(()=>({uniqueId:n,descriptor:d,callbacks:D}),[D,d,n]);ro(()=>(f.current=O.descriptor,a.droppable.register(O),()=>{t.current&&L(),a.droppable.unregister(O)}),[D,d,L,O,c,a.droppable]),ro(()=>{t.current&&c.updateDroppableIsEnabled(f.current.id,!e.isDropDisabled)},[e.isDropDisabled,c]),ro(()=>{t.current&&c.updateDroppableIsCombineEnabled(f.current.id,e.isCombineEnabled)},[e.isCombineEnabled,c])}function Mm(){}const rb={width:0,height:0,margin:uM},rQ=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?rb:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},nQ=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=rQ({isAnimatingOpenOnMount:e,placeholder:t,animate:r});return{display:t.display,boxSizing:"border-box",width:n.width,height:n.height,marginTop:n.margin.top,marginRight:n.margin.right,marginBottom:n.margin.bottom,marginLeft:n.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:r!=="none"?C0.placeholder:null}},sQ=e=>{const t=b.useRef(null),r=Rr(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:n,onTransitionEnd:a,onClose:c,contextId:l}=e,[d,f]=b.useState(e.animate==="open");b.useEffect(()=>d?n!=="open"?(r(),f(!1),Mm):t.current?Mm:(t.current=setTimeout(()=>{t.current=null,f(!1)}),r):Mm,[n,d,r]);const m=Rr(y=>{y.propertyName==="height"&&(a(),n==="close"&&c())},[n,c,a]),x=nQ({isAnimatingOpenOnMount:d,animate:e.animate,placeholder:e.placeholder});return _.createElement(e.placeholder.tagName,{style:x,"data-rfd-placeholder-context-id":l,onTransitionEnd:m,ref:e.innerRef})};var iQ=_.memo(sQ);class aQ extends _.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,r){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:r.isVisible?{isVisible:!0,data:r.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const oQ=e=>{const t=b.useContext(gp);t||zt();const{contextId:r,isMovementAllowed:n}=t,a=b.useRef(null),c=b.useRef(null),{children:l,droppableId:d,type:f,mode:m,direction:x,ignoreContainerClipping:y,isDropDisabled:w,isCombineEnabled:v,snapshot:T,useClone:C,updateViewportMaxScroll:L,getContainerForClone:N}=e,D=Rr(()=>a.current,[]),O=Rr((J=null)=>{a.current=J},[]);Rr(()=>c.current,[]);const P=Rr((J=null)=>{c.current=J},[]),F=Rr(()=>{n()&&L({maxScroll:S6()})},[n,L]);tQ({droppableId:d,type:f,mode:m,direction:x,isDropDisabled:w,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:D});const ee=En(()=>_.createElement(aQ,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:J,data:Re,animate:Ze})=>_.createElement(iQ,{placeholder:Re,onClose:J,innerRef:P,animate:Ze,contextId:r,onTransitionEnd:F})),[r,F,e.placeholder,e.shouldAnimatePlaceholder,P]),Z=En(()=>({innerRef:O,placeholder:ee,droppableProps:{"data-rfd-droppable-id":d,"data-rfd-droppable-context-id":r}}),[r,d,ee,O]),G=C?C.dragging.draggableId:null,de=En(()=>({droppableId:d,type:f,isUsingCloneFor:G}),[d,G,f]);function pe(){if(!C)return null;const{dragging:J,render:Re}=C,Ze=_.createElement($6,{draggableId:J.draggableId,index:J.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(V,ve)=>Re(V,ve,J));return kA.createPortal(Ze,N())}return _.createElement(Vg.Provider,{value:de},l(Z,T),pe())};function lQ(){return document.body||zt(),document.body}const nb={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:lQ},W6=e=>{let t={...e},r;for(r in nb)e[r]===void 0&&(t={...t,[r]:nb[r]});return t},jm=(e,t)=>e===t.droppable.type,sb=(e,t)=>t.draggables[e.draggable.id],cQ=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=_i(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),n=_i((c,l,d,f,m,x)=>{const y=m.descriptor.id;if(m.descriptor.droppableId===c){const T=x?{render:x,dragging:r(m.descriptor)}:null,C={isDraggingOver:d,draggingOverWith:d?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!1,snapshot:C,useClone:T}}if(!l)return t;if(!f)return e;const v={isDraggingOver:d,draggingOverWith:y,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(c,l)=>{const d=W6(l),f=d.droppableId,m=d.type,x=!d.isDropDisabled,y=d.renderClone;if(z0(c)){const w=c.critical;if(!jm(m,w))return t;const v=sb(w,c.dimensions),T=to(c.impact)===f;return n(f,x,T,T,v,y)}if(c.phase==="DROP_ANIMATING"){const w=c.completed;if(!jm(m,w.critical))return t;const v=sb(w.critical,c.dimensions);return n(f,x,O6(w.result)===f,to(w.impact)===f,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const w=c.completed;if(!jm(m,w.critical))return t;const v=to(w.impact)===f,T=!!(w.impact.at&&w.impact.at.type==="COMBINE"),C=w.critical.droppable.id===f;return v?T?e:t:C?e:t}return t}},uQ={updateViewportMaxScroll:Aj},zl=zv(cQ,uQ,(e,t,r)=>({...W6(r),...e,...t}),{context:Hg,areStatePropsEqual:P6})(oQ);function dQ(){if(typeof window>"u")return Ju(void 0);try{const e=window.localStorage.getItem(C1);return Ju(e?JSON.parse(e):void 0)}catch{return Ju(void 0)}}function Dm(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(C1),r=t?JSON.parse(t):{},n=Ju({...r,...e});window.localStorage.setItem(C1,JSON.stringify(n))}catch{}}function hQ(){const[e,t]=_.useState(dQ);_.useEffect(()=>{Dm(e)},[e]);const r=_.useCallback(a=>{t(c=>{const l=Ju({...c,...a});return Dm(l),l})},[]),n=_.useCallback(()=>{const a=Ju(void 0);t(a),Dm(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const U1="termdock-settings";function fQ(e){return e==="shell"||e==="tmux"}function pQ(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(U1);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&fQ(t.newSessionMode)?t.newSessionMode:null,n=r??"shell",a=typeof t.newSessionTmuxName=="string"?t.newSessionTmuxName:"";return{mode:n,tmuxName:a,userSelectedMode:r}}catch{return{mode:"shell",tmuxName:"",userSelectedMode:null}}}function ib(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(U1),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(U1,JSON.stringify(n))}catch{}}function mQ(){const[e,t]=_.useState(pQ),r=_.useCallback((a,c)=>{const l=c?.userInitiated!==!1;t(d=>({...d,mode:a,userSelectedMode:l?a:d.userSelectedMode})),l&&ib({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=_.useCallback(a=>{t(c=>({...c,tmuxName:a})),ib({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const gQ=550,xQ=10;function qg(){const e=b.useRef(null),t=b.useRef(null),r=b.useRef(!1),n=b.useRef(!1),a=b.useRef(null),c=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),l=b.useCallback(()=>{c(),t.current=null},[c]);return b.useCallback(f=>({onPointerDown:m=>{m.pointerType!=="touch"&&m.pointerType!=="pen"||(l(),r.current=!1,t.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(r.current=!0,f())},gQ))},onPointerMove:m=>{const x=t.current;if(!x||x.pointerId!==m.pointerId||r.current)return;const y=m.clientX-x.startX,w=m.clientY-x.startY;Math.hypot(y,w)>xQ&&l()},onPointerUp:m=>{r.current&&(m.preventDefault(),r.current=!1,n.current=!0,a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{n.current=!1,a.current=null},600)),l()},onPointerCancel:l,onPointerLeave:m=>{t.current?.pointerId===m.pointerId&&!r.current&&l()},onClickCapture:m=>{n.current&&(n.current=!1,a.current!=null&&(window.clearTimeout(a.current),a.current=null),m.preventDefault(),m.stopPropagation())}}),[l])}function ab({mode:e,activeProgram:t,promptState:r,shellNames:n}){return e!=="tmux"?!1:r==="running"?!0:r==="idle"?!1:t===null||!n.has(t.toLowerCase())}function bQ(e,t){return!!e&&!!t&&e.id===t.id&&e.target===t.target&&e.client===t.client&&e.backend===t.backend&&e.mode===t.mode&&e.tmux===t.tmux}function yQ({sessionId:e,confirmButton:t,onConfirm:r,onCancel:n,isCurrent:a}){const c=b.useRef({sessionId:e,onConfirm:r,onCancel:n,isCurrent:a});return c.current={sessionId:e,onConfirm:r,onCancel:n,isCurrent:a},b.useEffect(()=>{t.current?.focus({preventScroll:!0})},[e,t]),b.useLayoutEffect(()=>{let l=!1;const d=f=>{if(c.current.sessionId===e&&!(f.key!=="Escape"&&f.key!=="Enter")){if(f.isComposing||f.keyCode===229||f.key==="Enter"&&(f.altKey||f.ctrlKey||f.metaKey||f.shiftKey)){f.key==="Enter"&&f.target instanceof Node&&t.current?.contains(f.target)&&f.preventDefault();return}f.preventDefault(),f.stopImmediatePropagation(),!(l||f.repeat)&&(l=!0,f.key==="Escape"||c.current.isCurrent?.()===!1?c.current.onCancel():c.current.onConfirm())}};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e,t]),null}function vQ(e,t,r){return!!(e&&t===e&&!r)}function ou(e,t,r=[]){let n;const a=()=>{document.hidden||e()},c=()=>{n!==void 0&&(window.clearInterval(n),n=void 0)},l=()=>{c(),!document.hidden&&(a(),n=window.setInterval(a,t))};document.addEventListener("visibilitychange",l);for(const d of r)window.addEventListener(d,a);return l(),()=>{c(),document.removeEventListener("visibilitychange",l);for(const d of r)window.removeEventListener(d,a)}}function wQ({groupId:e,version:t,onRestore:r}){const[n,a]=b.useState([]),[c,l]=b.useState(null),[d,f]=b.useState(""),m=b.useRef(!1);b.useEffect(()=>{let y=!0;const w=async()=>{try{const T=await H8();y&&a(T.entries.filter(C=>C.groups.some(L=>L.id===e)))}catch{}},v=ou(()=>{w()},1e4);return()=>{y=!1,v()}},[e,t]);const x=async y=>{if(!m.current){m.current=!0,l(y.sessionId),f("");try{const w=await W8(y.sessionId);await r(w.session),a(v=>v.filter(T=>T.sessionId!==y.sessionId))}catch(w){f(w instanceof Error?w.message:"恢复失败,归档已保留")}finally{m.current=!1,l(null)}}};return!n.length&&!d?null:s.jsxs("details",{className:"border-t border-border/15 text-muted-foreground",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 px-2 text-[11px]",children:[s.jsx(Sf,{size:13}),"已归档的执行会话 · ",n.length]}),d&&s.jsx("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:d}),n.map(y=>s.jsxs("div",{className:"border-t border-border/10 px-2 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:y.title}),s.jsxs("button",{type:"button",disabled:c!==null,onClick:()=>{x(y)},className:"inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-primary hover:bg-primary/10 disabled:opacity-40",children:[c===y.sessionId&&s.jsx(An,{size:12,className:"animate-spin"}),c===y.sessionId?"恢复中…":"恢复"]})]}),s.jsx("p",{className:"text-[10px] leading-4",children:y.cleanup.state==="removed"?"执行目录已回收,恢复时重建;分支和结果保留。":y.cleanup.reason||"目录保留,可继续恢复原会话。"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[10px]",children:[y.agent.slug," 会话 ID 与目录"]}),s.jsx("code",{className:"block select-text break-all text-[10px]",children:y.agent.sessionId}),s.jsx("span",{className:"mt-1 block select-text break-all text-[10px]",children:y.cwd})]})]},y.sessionId))]})}function ob(e,t){const r=new Set,n=new Set;for(const a of e.filter(c=>c.groupId===t)){const c=a.attempts.find(d=>d.id===a.activeAttemptId)?.assignee,l=c&&a.memberSessions[`${c.serviceId}:${c.sessionId}`];if(a.status==="open"){l&&n.add(l);const d=a.scheduledAssignee;d&&n.add(a.memberSessions[`${d.serviceId}:${d.sessionId}`])}else l&&a.workspace&&a.workflow?.kind==="step"&&a.workflow.isolated&&r.add(l);a.coordinator&&n.add(a.memberSessions[`${a.coordinator.serviceId}:${a.coordinator.sessionId}`]),a.workflow?.reviewers.forEach(d=>n.add(a.memberSessions[`${d.serviceId}:${d.sessionId}`]))}return n.forEach(a=>r.delete(a)),r}const Yf={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function Zf(e){const t=e.attempts.find(d=>d.id===e.activeAttemptId)?.report;if(!t)return null;const r=typeof t.content=="string"?t.content:"",n=t.summary,a=r.split(/\n\s*\n/).map(d=>d.split(`
135
+ `).filter(f=>!/^#{1,6}\s/.test(f)).join(`
136
+ `).trim()).find(Boolean),c=typeof n=="string"&&n.trim()?n.trim():a,l=Number.isFinite(t.createdAt)&&t.createdAt>0&&Number.isFinite(new Date(t.createdAt).getTime());return{status:t.status,label:Yf[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function bp(e){if(e.status!=="open")return[];const t=Zf(e),r=t&&["blocked","failed"].includes(t.status)?{source:"member",label:t.label,content:t.content,summary:t.summary,createdAt:t.createdAt}:null,n=r&&(e.automationIssueSource==="member-report"||!e.summaryOnly&&!!t?.content&&e.automationIssue===t.content.slice(0,1e3)),a=r&&!t?.content&&!e.automationIssueSource,c=e.automationIssue&&!n?{source:a?"unknown":"system",label:a?"服务记录(来源待核对)":e.automationIssue.startsWith("消息投递")?"投递需要处理":e.activeAttemptId?"自动安排受阻":"执行准备受阻",content:e.automationIssue,summary:e.automationIssue}:null;return[r,c].filter(l=>!!l)}function AQ(e){return bp(e)[0]??null}function cu(e){if(e.status==="accepted")return e.completionMode==="reviewed"?"独立评审通过":"已验收";if(e.status==="closed")return"已关闭";if(e.purpose==="automation"){const l={unassigned:"后台记录待分派",awaiting_report:"后台执行等待明确报告",ack:"执行成员已确认接手",working:"成员报告进行中",blocked:"成员报告受阻",failed:"成员报告失败",complete:"执行已交付"};return e.execution?l[e.execution.status]:"后台执行记录"}if(e.decisions.some(l=>l.status==="pending"))return"需要你回答";const t=AQ(e);if(t)return t.label;if(e.workflow?.paused)return"自动安排已暂停";const r=e.attempts.find(l=>l.id===e.activeAttemptId),n=e.artifacts.filter(l=>l.kind==="plan"&&l.attemptId===e.activeAttemptId).at(-1);if(n&&n.id!==e.approvedPlanArtifactId)return"需要你确认方案";const a=e.artifacts.filter(l=>l.kind==="result"&&l.attemptId===e.activeAttemptId).at(-1),c=a&&e.events.some(l=>l.kind==="revise"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt);if(a&&!c){const l=e.artifacts.filter(d=>d.kind==="review"&&d.reviewsArtifactId===a.id).at(-1);return e.workflow&&l?.verdict!=="pass"?l?.verdict==="changes"?"评审要求修改":"等待独立评审":e.workflow?.kind==="step"?"评审通过 · 等待接续":"等待你验收"}return c?e.events.some(l=>l.kind==="revise"&&l.source==="user"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt)?"已要求跟进 · 等待新结果":"已要求修改 · 等待新结果":r?r.report?Yf[r.report.status]:["failed","expired"].includes(r.deliveryStatus??"")?"投递未成功":e.deliveries.some(l=>l.attemptId===e.activeAttemptId&&l.error)?"投递需要关注":r.deliveryStatus==="delivered"?"已写入终端 · 等待回复":"等待投递":e.scheduledAssignee?e.dependsOn.length?"依赖完成后自动分派":e.workflow?.isolated===!1?"等待分派":"准备独立执行目录":e.dependsOn.length?"等待依赖与分派":"待分派"}function sa(e){return e.purpose!=="automation"&&e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(cu(e))}function lb(){return JSON.stringify(ea())}function TQ(e){const t=e instanceof Error?e.message:String(e);return(e&&typeof e=="object"&&"name"in e?String(e.name):"")==="UnexpectedEOFError"&&/^Unexpected EOF - stream closed while reading \d+\/\d+ bytes$/.test(t)||t==="Secure response ended unexpectedly"?"连接中断,待处理事项暂时无法加载;恢复后会自动重试。":t||"协作待处理事项加载失败"}const $u=Sc(e=>{let t=0,r,n=null,a;return{tasks:[],allTasks:[],error:null,refresh:async()=>{const c=lb();if(a?.target===c)return a.promise;a?.controller.abort(),r!==c&&(r=c,n=null,e({tasks:[],allTasks:[],error:null}));const l=++t,d=new AbortController,f={owner:l,target:c,controller:d,promise:Promise.resolve()};a=f;const m=()=>a?.owner===l&&lb()===c;return f.promise=(async()=>{try{const{tasks:x}=await Yy(void 0,d.signal);m()&&(n=null,e({tasks:x.filter(sa),allTasks:x,error:null}))}catch(x){if(!m()||d.signal.aborted||x instanceof Error&&x.name==="AbortError")return;const y=x instanceof Error?x.message:String(x);n!==y&&(console.error("[CollaborationTaskInbox] refresh failed",x),n=y),e({error:TQ(x)})}finally{a?.owner===l&&(a=void 0)}})(),f.promise}}});function cb(e,t){try{localStorage.setItem(`termdock:tasks:${location.origin}:${e}:open-task`,JSON.stringify(t))}catch{}window.dispatchEvent(new CustomEvent("open-collaboration-task",{detail:{groupId:e,taskId:t}}))}function ub(e){const t=e.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);return t?{numbers:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]??null}:null}function SQ(e,t){const r=ub(e),n=ub(t);if(!r||!n)throw new Error(`Invalid version comparison: ${e} / ${t}`);for(let a=0;a<3;a+=1)if(r.numbers[a]!==n.numbers[a])return r.numbers[a]-n.numbers[a];return r.prerelease===n.prerelease?0:r.prerelease===null?1:n.prerelease===null?-1:r.prerelease.localeCompare(n.prerelease,"en",{numeric:!0})}function db({sessionIds:e}){const t=G8(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=Gr();if(!t)return null;const n=r==="zh"?`${t} 条未读进展`:`${t} unread progress updates`;return s.jsx("span",{title:n,"aria-label":n,className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-primary/15 px-1 text-[10px] font-medium text-primary",children:t>99?"99+":t})}function CQ(e){if(!e.startsWith("remote:"))return null;const t=e.slice(7).split(":");if(t.length!==2)return null;try{const r=decodeURIComponent(t[0]),n=decodeURIComponent(t[1]),a=new URL(r);return!["https:","http:"].includes(a.protocol)||a.origin!==r||!n?null:{origin:r,sessionId:n}}catch{return null}}async function G6(e){const t=CQ(e);if(!t)throw new Error("远端会话标识无效");if(window.termdockDesktop?.collaborationFocus)try{if(await window.termdockDesktop.collaborationFocus(e))return}catch{}window.dispatchEvent(new CustomEvent("termdock:open-remote-session",{detail:t}))}function _Q(e,t,r){return Math.max(t,Math.min(e,r))}const bs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function hb(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function fb(e,t,r,n=.15){return n===0?_Q(e,t,r):e<t?-hb(t-e,r-t,n)+t:e>r?+hb(e-r,r-t,n)+r:e}function kQ(e,[t,r],[n,a]){const[[c,l],[d,f]]=e;return[fb(t,c,l,n),fb(r,d,f,a)]}function LQ(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function IQ(e){var t=LQ(e,"string");return typeof t=="symbol"?t:String(t)}function Vs(e,t,r){return t=IQ(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pb(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ls(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pb(Object(r),!0).forEach(function(n){Vs(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pb(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const V6={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function mb(e){return e?e[0].toUpperCase()+e.slice(1):""}const EQ=["enter","leave"];function NQ(e=!1,t){return e&&!EQ.includes(t)}function RQ(e,t="",r=!1){const n=V6[e],a=n&&n[t]||t;return"on"+mb(e)+mb(a)+(NQ(r,a)?"Capture":"")}const MQ=["gotpointercapture","lostpointercapture"];function jQ(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=MQ.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function DQ(e,t=""){const r=V6[e],n=r&&r[t]||t;return e+n}function yp(e){return"touches"in e}function q6(e){return yp(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function BQ(e){return Array.from(e.touches).filter(t=>{var r,n;return t.target===e.currentTarget||((r=e.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,t.target))})}function QQ(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function Y6(e){return yp(e)?QQ(e)[0]:e}function z1(e,t){try{const r=t.clientX-e.clientX,n=t.clientY-e.clientY,a=(t.clientX+e.clientX)/2,c=(t.clientY+e.clientY)/2,l=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:l,origin:[a,c]}}catch{}return null}function PQ(e){return BQ(e).map(t=>t.identifier)}function gb(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return z1(r,n)}function Bm(e){const t=Y6(e);return yp(e)?t.identifier:t.pointerId}function cd(e){const t=Y6(e);return[t.clientX,t.clientY]}const xb=40,bb=800;function Z6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=xb,r*=xb):n===2&&(t*=bb,r*=bb),[t,r]}function OQ(e){var t,r;const{scrollX:n,scrollY:a,scrollLeft:c,scrollTop:l}=e.currentTarget;return[(t=n??c)!==null&&t!==void 0?t:0,(r=a??l)!==null&&r!==void 0?r:0]}function FQ(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c}=e;Object.assign(t,{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c})}return t}function Kf(e,...t){return typeof e=="function"?e(...t):e}function $Q(){}function UQ(...e){return e.length===0?$Q:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function yb(e,t){return Object.assign({},t,e||{})}const zQ=32;class K6{constructor(t,r,n){this.ctrl=t,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:r,ingKey:n,args:a}=this;r[n]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=t.target,r.currentTarget=t.currentTarget,r.lastOffset=n.from?Kf(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=t.timeStamp)}computeValues(t){const r=this.state;r._values=t,r.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:r,config:n,shared:a}=this;r.args=this.args;let c=0;if(t&&(r.event=t,n.preventDefault&&t.cancelable&&r.event.preventDefault(),r.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,FQ(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,c=t.timeStamp-r.timeStamp,r.timeStamp=t.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const ee=r._delta.map(Math.abs);bs.addTo(r._distance,ee)}this.axisIntent&&this.axisIntent(t);const[l,d]=r._movement,[f,m]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(l)>=f&&y[0]),x[1]===!1&&(x[1]=Math.abs(d)>=m&&y[1])):(x[0]===!1&&(x[0]=Math.abs(l)>=f&&Math.sign(l)*f),x[1]===!1&&(x[1]=Math.abs(d)>=m&&Math.sign(d)*m)),r.intentional=x[0]!==!1||x[1]!==!1,!r.intentional)return;const w=[0,0];if(n.hasCustomTransform){const[ee,Z]=y;w[0]=x[0]!==!1?ee-x[0]:0,w[1]=x[1]!==!1?Z-x[1]:0}else w[0]=x[0]!==!1?l-x[0]:0,w[1]=x[1]!==!1?d-x[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(w);const v=r.offset,T=r._active&&!r._blocked||r.active;T&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=a[this.ingKey]=r._active,t&&(r.first&&("bounds"in n&&(r._bounds=Kf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[C,L]=r.offset,[[N,D],[O,P]]=r._bounds;r.overflow=[C<N?-1:C>D?1:0,L<O?-1:L>P?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const F=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=kQ(r._bounds,r.offset,F),r.delta=bs.sub(r.offset,v),this.computeMovement(),T&&(!r.last||c>zQ)){r.delta=bs.sub(r.offset,v);const ee=r.delta.map(Math.abs);bs.addTo(r.distance,ee),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&c>0&&(r.velocity=[ee[0]/c,ee[1]/c],r.timeDelta=c)}}emit(){const t=this.state,r=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const a=this.handler(Ls(Ls(Ls({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function HQ([e,t],r){const n=Math.abs(e),a=Math.abs(t);if(n>a&&n>r)return"x";if(a>n&&a>r)return"y"}class J0 extends K6{constructor(...t){super(...t),Vs(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=bs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=bs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const r=this.state,n=this.config;if(!r.axis&&t){const a=typeof n.axisThreshold=="object"?n.axisThreshold[q6(t)]:n.axisThreshold;r.axis=HQ(r._movement,a)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const WQ=e=>e,vb=.15,X6={enabled(e=!0){return e},eventOptions(e,t,r){return Ls(Ls({},r.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[vb,vb];case!1:return[0,0];default:return bs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return bs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||WQ},threshold(e){return bs.toVector(e,0)}},GQ=0,uu=Ls(Ls({},X6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=GQ){return e},bounds(e={}){if(typeof e=="function")return c=>uu.bounds(e(c));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=e;return[[t,r],[n,a]]}}),wb={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class VQ extends J0{constructor(...t){super(...t),Vs(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const r=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),a={left:r.left-n.left+t.offset[0],right:r.right-n.right+t.offset[0],top:r.top-n.top+t.offset[1],bottom:r.bottom-n.bottom+t.offset[1]};t._bounds=uu.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const r=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(t.buttons):r.pointerButtons!==-1&&r.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);r.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=Bm(t),n._pointerActive=!0,this.computeValues(cd(t)),this.computeInitial(),r.preventScrollAxis&&q6(t)!=="mouse"?(n._active=!1,this.setupScrollPrevention(t)):r.delay>0?(this.setupDelayTrigger(t),r.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const r=this.state,n=this.config;if(!r._pointerActive)return;const a=Bm(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const c=cd(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=bs.sub(c,r._values),this.computeValues(c)),bs.addTo(r._movement,r._delta),this.compute(t),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const a=Bm(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[c,l]=r._distance;if(r.tap=c<=n.tapsThreshold&&l<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[d,f]=r._delta,[m,x]=r._movement,[y,w]=n.swipe.velocity,[v,T]=n.swipe.distance,C=n.swipe.duration;if(r.elapsedTime<C){const L=Math.abs(d/r.timeDelta),N=Math.abs(f/r.timeDelta);L>y&&Math.abs(m)>v&&(r.swipe[0]=Math.sign(d)),N>w&&Math.abs(x)>T&&(r.swipe[1]=Math.sign(f))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const r=this.config,n=r.device;r.pointerLock&&t.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,qQ(t);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const r=wb[t.key];if(r){const n=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=r(this.config.keyboardDisplacement,a),n._keyboardActive=!0,bs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in wb&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const r=this.config.device;t(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(r,"change",this.pointerMove.bind(this)),t(r,"end",this.pointerUp.bind(this)),t(r,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function qQ(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const eh=typeof window<"u"&&window.document&&window.document.createElement;function J6(){return eh&&"ontouchstart"in window}function YQ(){return J6()||eh&&window.navigator.maxTouchPoints>1}function ZQ(){return eh&&"onpointerdown"in window}function KQ(){return eh&&"exitPointerLock"in window.document}function XQ(){try{return"constructor"in GestureEvent}catch{return!1}}const Io={isBrowser:eh,gesture:XQ(),touch:J6(),touchscreen:YQ(),pointer:ZQ(),pointerLock:KQ()},JQ=250,eP=180,tP=.5,rP=50,nP=250,sP=10,Ab={mouse:0,touch:0,pen:8},iP=Ls(Ls({},uu),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&Io.pointerLock,Io.touch&&r?"touch":this.pointerLock?"mouse":Io.pointer&&!a?"pointer":Io.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?JQ:void 0,!(!Io.touchscreen||r===!1))return e||(r!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(e,t,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const c=bs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=tP,distance:t=rP,duration:r=nP}={}){return{velocity:this.transform(bs.toVector(e)),distance:this.transform(bs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return eP;case!1:return 0;default:return e}},axisThreshold(e){return e?Ls(Ls({},Ab),e):Ab},keyboardDisplacement(e=sP){return e}});function e4(e){const[t,r]=e.overflow,[n,a]=e._delta,[c,l]=e._direction;(t<0&&n>0&&c<0||t>0&&n<0&&c>0)&&(e._movement[0]=e._movementBound[0]),(r<0&&a>0&&l<0||r>0&&a<0&&l>0)&&(e._movement[1]=e._movementBound[1])}const aP=30,oP=100;class lP extends K6{constructor(...t){super(...t),Vs(this,"ingKey","pinching"),Vs(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:r,lastOffset:n}=this.state;t==="wheel"?this.state.offset=bs.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:t,lastOffset:r}=this.state;this.state.movement=[t[0]/r[0],t[1]-r[1]]}axisIntent(){const t=this.state,[r,n]=t._movement;if(!t.axis){const a=Math.abs(r)*aP-Math.abs(n);a<0?t.axis="angle":a>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(c=>n.has(c))||n.size<2)return;this.start(t),r._touchIds=Array.from(n).slice(0,2);const a=gb(t,r._touchIds);a&&this.pinchStart(t,a)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const r=this.state,n=r._pointerEvents,a=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(l=>a.has(l))||(n.size<2&&n.set(t.pointerId,t),r._pointerEvents.size<2))return;this.start(t);const c=z1(...Array.from(n.values()));c&&this.pinchStart(t,c)}pinchStart(t,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const r=gb(t,this.state._touchIds);r&&this.pinchMove(t,r)}pointerMove(t){const r=this.state._pointerEvents;if(r.has(t.pointerId)&&r.set(t.pointerId,t),!this.state._active)return;const n=z1(...Array.from(r.values()));n&&this.pinchMove(t,n)}pinchMove(t,r){const n=this.state,a=n._values[1],c=r.angle-a;let l=0;Math.abs(c)>270&&(l+=Math.sign(c)),this.computeValues([r.distance,r.angle-360*l]),n.origin=r.origin,n.turns=l,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const r=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}r._pointerEvents.has(t.pointerId)&&r._pointerEvents.delete(t.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const r=this.state;r._active||(this.start(t),this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY];const n=r._movement;r._movement=[t.scale-1,t.rotation],r._delta=bs.sub(r._movement,n),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>t[n]):!t[r])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const n=this.state;n._delta=[-Z6(t)[1]/oP*n.offset[0],0],bs.addTo(n._movement,n._delta),e4(n),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const r=this.config.device;r&&(t(r,"start",this[r+"Start"].bind(this)),t(r,"change",this[r+"Move"].bind(this)),t(r,"end",this[r+"End"].bind(this)),t(r,"cancel",this[r+"End"].bind(this)),t("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const cP=Ls(Ls({},X6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!Io.touch&&Io.gesture)return"gesture";if(Io.touch&&n)return"touch";if(Io.touchscreen){if(Io.pointer)return"pointer";if(Io.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const d=yb(Kf(r,l),{min:-1/0,max:1/0});return[d.min,d.max]},c=l=>{const d=yb(Kf(n,l),{min:-1/0,max:1/0});return[d.min,d.max]};return typeof r!="function"&&typeof n!="function"?[a(),c()]:l=>[a(l),c(l)]},threshold(e,t,r){return this.lockDirection=r.axis==="lock",bs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class uP extends J0{constructor(...t){super(...t),Vs(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(cd(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=cd(t),n=this.state;n._delta=bs.sub(r,n._values),bs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const dP=Ls(Ls({},uu),{},{mouseOnly:(e=!0)=>e});class hP extends J0{constructor(...t){super(...t),Vs(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const r=this.state,n=OQ(t);r._delta=bs.sub(n,r._values),bs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const fP=uu;class pP extends J0{constructor(...t){super(...t),Vs(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const r=this.state;r._delta=Z6(t),bs.addTo(r._movement,r._delta),e4(r),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const mP=uu;class gP extends J0{constructor(...t){super(...t),Vs(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(cd(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const r=this.state;if(!r._active)return;r._active=!1;const n=cd(t);r._movement=r._delta=bs.sub(n,r._values),this.computeValues(n),this.compute(t),r.delta=r.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const xP=Ls(Ls({},uu),{},{mouseOnly:(e=!0)=>e}),Yg=new Map,H1=new Map;function t4(e){Yg.set(e.key,e.engine),H1.set(e.key,e.resolver)}const r4={key:"drag",engine:VQ,resolver:iP},bP={key:"hover",engine:gP,resolver:xP},yP={key:"move",engine:uP,resolver:dP},vP={key:"pinch",engine:lP,resolver:cP},wP={key:"scroll",engine:hP,resolver:fP},AP={key:"wheel",engine:pP,resolver:mP};function TP(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,c;for(c=0;c<n.length;c++)a=n[c],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function SP(e,t){if(e==null)return{};var r=TP(e,t),n,a;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const CP={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=Io.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},_P=["target","eventOptions","window","enabled","transform"];function xf(e={},t){const r={};for(const[n,a]of Object.entries(t))switch(typeof a){case"function":r[n]=a.call(r,e[n],n,e);break;case"object":r[n]=xf(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function kP(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:d,transform:f}=n,m=SP(n,_P);if(r.shared=xf({target:a,eventOptions:c,window:l,enabled:d,transform:f},CP),t){const x=H1.get(t);r[t]=xf(Ls({shared:r.shared},m),x)}else for(const x in m){const y=H1.get(x);y&&(r[x]=xf(Ls({shared:r.shared},m[x]),y))}return r}class n4{constructor(t,r){Vs(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,d=DQ(r,n),f=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=Ls(Ls({},f),c);t.addEventListener(d,a,m);const x=()=>{t.removeEventListener(d,a,m),l.delete(x)};return l.add(x),x}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class LP{constructor(){Vs(this,"_timeouts",new Map)}add(t,r,n=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(r,n,...a))}remove(t){const r=this._timeouts.get(t);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class IP{constructor(t){Vs(this,"gestures",new Set),Vs(this,"_targetEventStore",new n4(this)),Vs(this,"gestureEventStores",{}),Vs(this,"gestureTimeoutStores",{}),Vs(this,"handlers",{}),Vs(this,"config",{}),Vs(this,"pointerIds",new Set),Vs(this,"touchIds",new Set),Vs(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),EP(this,t)}setEventIds(t){if(yp(t))return this.touchIds=new Set(PQ(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,r){this.handlers=t,this.nativeHandlers=r}applyConfig(t,r){this.config=kP(t,r,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const l of this.gestures){const d=this.config[l],f=Tb(n,d.eventOptions,!!a);if(d.enabled){const m=Yg.get(l);new m(this,t,l).bind(f)}}const c=Tb(n,r.eventOptions,!!a);for(const l in this.nativeHandlers)c(l,"",d=>this.nativeHandlers[l](Ls(Ls({},this.state.shared),{},{event:d,args:t})),void 0,!0)}for(const c in n)n[c]=UQ(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:d,passive:f}=jQ(c);this._targetEventStore.add(a,l,"",n[c],{capture:d,passive:f})}}}}function Mu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new n4(e,t),e.gestureTimeoutStores[t]=new LP}function EP(e,t){t.drag&&Mu(e,"drag"),t.wheel&&Mu(e,"wheel"),t.scroll&&Mu(e,"scroll"),t.move&&Mu(e,"move"),t.pinch&&Mu(e,"pinch"),t.hover&&Mu(e,"hover")}const Tb=(e,t,r)=>(n,a,c,l={},d=!1)=>{var f,m;const x=(f=l.capture)!==null&&f!==void 0?f:t.capture,y=(m=l.passive)!==null&&m!==void 0?m:t.passive;let w=d?n:RQ(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},NP=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function RP(e){const t={},r={},n=new Set;for(let a in e)NP.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function ju(e,t,r,n,a,c){if(!e.has(r)||!Yg.has(n))return;const l=r+"Start",d=r+"End",f=m=>{let x;return m.first&&l in t&&t[l](m),r in t&&(x=t[r](m)),m.last&&d in t&&t[d](m),x};a[n]=f,c[n]=c[n]||{}}function MP(e,t){const[r,n,a]=RP(e),c={};return ju(a,r,"onDrag","drag",c,t),ju(a,r,"onWheel","wheel",c,t),ju(a,r,"onScroll","scroll",c,t),ju(a,r,"onPinch","pinch",c,t),ju(a,r,"onMove","move",c,t),ju(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function s4(e,t={},r,n){const a=_.useMemo(()=>new IP(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),_.useEffect(a.effect.bind(a)),_.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function Sb(e,t){return t4(r4),s4({drag:e},t||{},"drag")}function jP(e){return e.forEach(t4),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=MP(r,n||{});return s4(a,l,void 0,c)}}function sz(e,t){return jP([r4,vP,wP,AP,yP,bP])(e,t||{})}const Cb={dampingRatio:.8,response:.3},DP=.998;function BP(e,t,r,n){const a=2*Math.PI/Math.max(e.response,.001),c=t-n,l=r,d=e.dampingRatio;if(Math.abs(d-1)<1e-4){const v=c,T=l+a*c;return{value:C=>n+(v+T*C)*Math.exp(-a*C),velocity:C=>(T-a*(v+T*C))*Math.exp(-a*C)}}if(d<1){const v=a*Math.sqrt(1-d*d),T=c,C=(l+d*a*c)/v;return{value:L=>n+Math.exp(-d*a*L)*(T*Math.cos(v*L)+C*Math.sin(v*L)),velocity:L=>Math.exp(-d*a*L)*((C*v-d*a*T)*Math.cos(v*L)-(T*v+d*a*C)*Math.sin(v*L))}}const f=a*Math.sqrt(d*d-1),m=-d*a+f,x=-d*a-f,y=(l-x*c)/(m-x),w=c-y;return{value:v=>n+y*Math.exp(m*v)+w*Math.exp(x*v),velocity:v=>y*m*Math.exp(m*v)+w*x*Math.exp(x*v)}}function QP(e,t=DP){return e/1e3*(t/(1-t))}function _b(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function PP(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const OP=.1,FP=5;function $P(e,t,r,n,a){const c=BP(e,t,r,n),l=1e3/60,d=240,f=[];for(let m=0;m<d;m++){const x=m*l/1e3,y=c.value(x),w=c.velocity(x);if(f.push(a?a(y):y),m>0&&Math.abs(y-n)<OP&&Math.abs(w)<FP)break}return f.push(a?a(n):n),{frames:f,durationMs:(f.length-1)*l,solver:c}}const UP='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function zP(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(UP)&&e.blur()}const HP=18,kb=8,Lb={touch:kb,pen:kb},WP=500,Qm=200,Ib=50,GP=`[${EA}]`;function Pm(e,t,r){return Math.min(r,Math.max(t,e))}function Eb(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function Nb(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(GP)}function Kd(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const i4=_.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:d=!1},f){const{t:m}=Gr(),x=t==="left",y=x?-n:n,w=b.useRef(null),v=b.useRef(null),T=b.useRef(r?0:y),C=b.useRef(null),L=b.useRef(null),N=b.useRef(0),D=b.useRef(null),O=b.useRef(null),P=b.useRef(!1),F=b.useRef(null),ee=b.useRef(!1),Z=b.useRef([]),G=b.useRef(null),de=b.useRef(T.current),pe=b.useRef(r?1:0),J=b.useRef(r);J.current=r;const Re=b.useRef(y);Re.current=y;const Ze=b.useRef(n);Ze.current=n;const V=b.useRef(x);V.current=x;const ve=b.useRef(a);ve.current=a;const qe=b.useRef(c);qe.current=c;const le=b.useCallback(ie=>{w.current=ie,typeof f=="function"?f(ie):f&&(f.current=ie)},[f]),ye=b.useCallback(()=>{L.current!==null&&(window.cancelAnimationFrame(L.current),L.current=null),C.current=null},[]),Te=b.useCallback(ie=>{const ge=Ze.current;return V.current?(ie+ge)/ge:(ge-ie)/ge},[]),Fe=b.useCallback(ie=>{const ge=v.current;ge&&(ge.style.opacity=String(Pm(Te(ie),0,1)))},[Te]),se=b.useCallback(ie=>{T.current=ie;const ge=w.current;ge&&(ge.style.transform=`translateX(${ie}px)`,Fe(ie))},[Fe]),De=b.useCallback(ie=>{C.current=ie,L.current===null&&(L.current=window.requestAnimationFrame(()=>{L.current=null;const ge=C.current;C.current=null,ge!==null&&se(ge)}))},[se]),_e=b.useCallback(()=>{L.current!==null&&(window.cancelAnimationFrame(L.current),L.current=null);const ie=C.current;C.current=null,ie!==null&&se(ie)},[se]),Me=b.useCallback(ie=>{const ge=Re.current;return Pm(ie,Math.min(0,ge),Math.max(0,ge))},[]),Ke=b.useCallback(()=>{const ie=D.current;if(!ie)return null;D.current=null;const ge=(performance.now()-ie.startTime)/1e3,We={value:ie.solver.value(ge),velocity:ie.solver.velocity(ge)};return ie.animations.forEach(tt=>tt.cancel()),We},[]),Ne=b.useCallback(()=>{O.current!==null&&(window.clearTimeout(O.current),O.current=null)},[]),ae=b.useCallback(()=>{G.current?.(),G.current=null},[]),ze=b.useCallback(()=>{_e(),Ne();const ie=Ke();ie&&se(Me(ie.value));const ge=w.current,We=v.current;ge?.getAnimations().forEach(tt=>tt.cancel()),ge&&(ge.style.transition="none",ge.style.opacity="1"),We?.getAnimations().forEach(tt=>tt.cancel()),We&&(We.style.transition="none")},[se,Ne,Me,_e,Ke]),at=b.useCallback((ie,ge)=>{_e(),Ne();const We=w.current,tt=v.current,wt=ie?0:Re.current;tt&&(tt.style.pointerEvents=ie?"auto":"none");const Zt=Ke(),Ut=Zt?Me(Zt.value):T.current,Mt=ge?.velocity??Zt?.velocity??0;if(PP())return T.current=wt,We&&(We.style.transition=`opacity ${Qm}ms ease`,We.style.opacity=ie?"1":"0",We.style.transform=`translateX(${wt}px)`),tt&&(tt.style.transition=`opacity ${Qm}ms ease`,tt.style.opacity=ie?"1":"0"),Qm;We&&(We.style.transition="none",We.style.opacity="1"),tt&&(tt.style.transition="none");const nr=Math.abs(ge?.velocity??0)>WP,{frames:jt,durationMs:Xt,solver:Bt}=$P({dampingRatio:nr?Cb.dampingRatio:1,response:Cb.response},Ut,Mt,wt,Me);if(!We||Math.abs(Ut-wt)<.5&&Math.abs(Mt)<5)return se(wt),0;const Ht=We.animate(jt.map(Je=>({transform:`translateX(${Je}px)`})),{duration:Xt,easing:"linear",fill:"forwards"}),xe=[Ht];return tt&&xe.push(tt.animate(jt.map(Je=>({opacity:String(Pm(Te(Je),0,1))})),{duration:Xt,easing:"linear",fill:"forwards"})),D.current={solver:Bt,startTime:performance.now(),target:wt,animations:xe},Kd("spring start",{startX:Ut,startVelocity:Mt,targetX:wt,frames:jt.length,durationMs:Xt}),Ht.onfinish=()=>{const Je=D.current;!Je||!Je.animations.includes(Ht)||(D.current=null,se(wt),Je.animations.forEach(ot=>ot.cancel()),Kd("spring finish",{targetX:wt}))},Xt},[se,Ne,Me,_e,Te,Ke]),ct=b.useCallback(ie=>{_e();const ge=ie,We=0,tt=Re.current,wt=T.current+QP(ge),Zt=Math.abs(wt-We)<=Math.abs(wt-tt);Kd("decideSnap",{velocity:ge,currentX:T.current,projected:wt,shouldOpen:Zt});const Ut=at(Zt,{velocity:ge});return Zt&&!J.current?O.current=window.setTimeout(()=>{O.current=null,qe.current?.()},Ut+Ib):!Zt&&J.current&&(O.current=window.setTimeout(()=>{O.current=null,ve.current()},Ut+Ib)),Zt},[at,_e]),me=b.useCallback(ie=>{const ge=Re.current,We=Math.min(0,ge),tt=Math.max(0,ge),wt=Ze.current;return ie<We?We-_b(We-ie,wt):ie>tt?tt+_b(ie-tt,wt):ie},[]),ut=b.useCallback(ie=>{const ge=Z.current,We=performance.now();ge.push({t:We,x:ie});const tt=We-120;for(;ge.length>0&&ge[0].t<tt;)ge.shift()},[]),ft=b.useCallback(()=>{const ie=Z.current;if(ie.length<2)return 0;const ge=ie[ie.length-1];if(performance.now()-ge.t>60)return 0;const We=ie[0],tt=(ge.t-We.t)/1e3;return tt<.016?0:(ge.x-We.x)/tt},[]);b.useEffect(()=>{Ne();const ie=D.current,ge=r?0:Re.current;ie&&ie.target===ge||at(r)},[r,at,Ne]),b.useEffect(()=>{ze(),De(J.current?0:y)},[y,ze,De]),b.useEffect(()=>()=>{ye(),Ne(),Ke(),ae()},[Ne,ye,ae,Ke]);const Se=Sb(({active:ie,cancel:ge,first:We,last:tt,movement:[wt],event:Zt})=>{if(Kd("bindPanel",{active:ie,first:We,last:tt,mx:wt}),!Eb(Zt)){ge();return}if(We){if(ae(),P.current=!1,F.current=null,Z.current=[],Nb(Zt)){ge();return}const Ut=w.current,Mt=Ut?NA(Zt.target,Ut):null;if(!Mt||RA()){ge();return}const nr=MA(Mt,wt,V.current?-1:1);if(Kd("arbitrate",{owner:nr.kind,mx:wt}),nr.kind==="swiper"){G.current=jA(nr.instance),ge();return}if(nr.kind==="scroller"){const jt=DA(nr.element);if(jt)F.current=jt;else{ge();return}}F.current||(P.current=!0,ze(),N.current=T.current)}if(!ie){F.current=null,P.current&&(P.current=!1,ct(ft()));return}if(F.current){BA(F.current,wt);return}if(P.current){const Ut=me(N.current+wt);ut(Ut),De(Ut)}},{axis:"x",axisThreshold:Lb,filterTaps:!0,pointer:{touch:!0}}),He=Sb(({active:ie,cancel:ge,first:We,movement:[tt],event:wt})=>{if(!Eb(wt)){ge();return}if(J.current){ge();return}if(We&&(ee.current=!0,Z.current=[],ze(),N.current=T.current),!ie){ee.current&&(ee.current=!1,ct(ft())&&zP());return}if(ee.current){const Zt=me(N.current+tt);ut(Zt),De(Zt)}},{axis:"x",axisThreshold:Lb,filterTaps:!0,pointer:{touch:!0}}),ke=b.useCallback(ie=>{ie.preventDefault(),ie.stopPropagation(),J.current||qe.current?.()},[]);if(d)return s.jsx("aside",{ref:le,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:l});const z=Se();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...He(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:HP,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:ke,"aria-label":m(x?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),s.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:pe.current,pointerEvents:r?"auto":"none",transition:"none",willChange:"opacity"},onClick:a,"aria-label":m("sidebar.closeSidebar")}),s.jsx("aside",{...z,onClickCapture:ie=>{Nb(ie)||z.onClickCapture?.(ie)},ref:le,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${x?"border-r border-border":"border-l border-border/15"}`,style:{...x?{left:0}:{right:0},width:n,maxWidth:x?"94vw":"95vw",transform:`translateX(${de.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:r?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...x?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})}),VP={activeKey:"root",items:[]},qP=()=>()=>{},YP=()=>VP;function ZP(e){const t=Ko(),r=b.useSyncExternalStore(t?.subscribe??qP,t?.snapshot??YP),n=V8(),a=r.items.map(c=>c.key===n?{...c,reviewCount:e}:c).filter(c=>c.reviewCount>0);return{host:t,groups:a,currentKey:n,active:!t||r.activeKey===n,total:t?e+a.reduce((c,l)=>c+(l.key===n?0:l.reviewCount),0):e,hasOtherAttention:a.some(c=>c.key!==n)}}function KP({groups:e,currentKey:t,onClose:r}){const{t:n}=Gr(),a=b.useId(),c=b.useRef(null),l=b.useRef(null),d=b.useRef(r);d.current=r;const f=b.useRef(!0),[m,x]=b.useState(""),y=e.reduce((T,C)=>T+C.reviewCount,0);b.useEffect(()=>{const T=document.activeElement;l.current?.focus({preventScroll:!0});const C=L=>{if(L.key==="Escape"&&(L.preventDefault(),L.stopImmediatePropagation(),d.current()),L.key!=="Tab")return;const N=Array.from(c.current?.querySelectorAll("button:not(:disabled)")??[]),D=N[0],O=N[N.length-1],P=!c.current?.contains(document.activeElement);L.shiftKey&&(document.activeElement===D||P)?(L.preventDefault(),O?.focus()):!L.shiftKey&&(document.activeElement===O||P)&&(L.preventDefault(),D?.focus())};return document.addEventListener("keydown",C,!0),()=>{document.removeEventListener("keydown",C,!0),f.current&&T?.isConnected&&!T.closest("[inert]")&&T.focus({preventScroll:!0})}},[]);const w=(T,C)=>{const L=Ko(),N=L?.snapshot().items.find(O=>O.key===T.key);if(!N?.reviewCount||C&&!N.attentionSessions?.some(O=>O.id===C)){x(n("serviceAttention.changed"));return}f.current=!1;let D=!1;C&&T.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:C})),D=!0):C&&N.service?.targetPeerId?D=L?.focusSession(N.service.targetPeerId,C)??!1:N.service&&(D=L?.activate(N.service,!0)??!1),D?r():(f.current=!0,x(n("serviceAttention.unavailable")))},v=T=>T.phase==="offline"?n("serviceAttention.offline"):T.phase==="login"?n("serviceAttention.login"):T.phase==="connecting"||T.phase==="reconnecting"?n("connection.reconnecting"):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":n("common.close"),tabIndex:-1,className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)]",onClick:r}),s.jsx("div",{className:"pointer-events-none fixed inset-0 z-modal-panel flex items-end justify-center p-3 sm:items-center sm:p-6",style:{paddingTop:"max(12px, var(--safe-top-inset, env(safe-area-inset-top, 0px)))",paddingBottom:"max(12px, var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:s.jsxs("section",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-sidebar-gesture-ignore":!0,onKeyDown:T=>T.stopPropagation(),className:"pointer-events-auto flex max-h-full w-full max-w-md flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[s.jsx(wc,{size:20,className:"shrink-0 text-[color:var(--warning)]","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:a,className:"text-sm font-semibold",children:n("serviceAttention.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n("serviceAttention.summary",{services:e.length,count:y})})]}),s.jsx("button",{ref:l,type:"button","aria-label":n("common.close"),onClick:r,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-muted-foreground hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(Dn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 overflow-y-auto overscroll-contain p-2",children:[e.length===0&&s.jsx("p",{role:"status",className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("serviceAttention.empty")}),e.map(T=>s.jsxs("section",{className:"mb-2 last:mb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pb-1 pt-2 text-xs",children:[s.jsx("h3",{className:"min-w-0 flex-1 truncate font-medium",title:T.service?.label,children:T.service?.label||n("serviceAttention.currentService")}),T.key===t&&s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n("agent.currentSession")}),s.jsx("span",{className:"shrink-0 tabular-nums text-[color:var(--warning)]",children:T.reviewCount})]}),v(T)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(T)}),T.attentionSessions?.length?T.attentionSessions.map(C=>s.jsxs("button",{type:"button",onClick:()=>w(T,C.id),className:"flex min-h-14 w-full items-center gap-3 rounded-xl px-3 py-2 text-left hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"line-clamp-2 break-words text-sm",title:C.label,children:C.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:C.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(Ks,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},C.id)):s.jsx("button",{type:"button",onClick:()=>w(T),className:"min-h-11 w-full rounded-xl px-3 py-2 text-left text-sm hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:n("serviceAttention.viewService")})]},T.key))]}),s.jsxs("footer",{className:"shrink-0 border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[m&&s.jsx("p",{role:"alert",className:"mb-1 text-[color:var(--warning)]",children:m}),n("serviceAttention.scope")]})]})})]})}function XP(e){const t=e.icon&&e.isPlugin?`/api/terminal/agent-plugin-icon/${encodeURIComponent(e.slug)}${e.iconVersion?`?v=${Math.floor(e.iconVersion)}`:""}`:void 0,[r,n]=b.useState();if(b.useEffect(()=>{if(n(void 0),!t)return;const a=new AbortController;let c;return fetch(t,{signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`Icon request failed: ${l.status}`);const d=await l.blob();a.signal.aborted||(c=URL.createObjectURL(d),n({endpoint:t,src:c}))}).catch(()=>{}),()=>{a.abort(),c&&URL.revokeObjectURL(c)}},[t]),!!e.icon)return e.isPlugin?r?.endpoint===t?r?.src:void 0:`/icons/agents/${e.icon}.svg`}function JP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function eO(e,t,r,n="next"){if(e.length===0)return null;const a=t?e.findIndex(c=>c.sessionId===t):-1;for(let c=1;c<=e.length;c+=1){const l=n==="next"?c:-c,d=(a+l+e.length)%e.length,f=e[d];if(f&&r(f))return f.sessionId}return null}function tO(e,t,r="next"){return eO(e,t,JP,r)}const eo=42,Xf=20,rO=10;function W1(e,t,r){return Math.min(r,Math.max(t,e))}function vp(e){const t=Math.max(0,e.safeTop??0),r=Math.max(0,e.safeRight??0),n=Math.max(0,e.safeBottom??0),a=Math.max(0,e.safeLeft??0),c=Math.max(0,e.bottomClearance??72),l=a+Xf,d=Math.max(l,e.width-r-Xf-eo),f=Math.max(t+12,52),m=Math.max(f,e.height-n-c-eo);return{minX:l,maxX:d,minY:f,maxY:m}}function Rb(e,t){const r=vp(e),n=W1(t.yRatio,0,1);return{x:t.side==="left"?r.minX:r.maxX,y:r.minY+(r.maxY-r.minY)*n}}function eu(e,t){const r=vp(e);return{x:W1(t.x,r.minX,r.maxX),y:W1(t.y,r.minY,r.maxY)}}function Mb(e,t){const r=vp(e),n=eu(e,t),a=(r.minX+r.maxX+eo)/2,c=n.x+eo/2<a?"left":"right",l=r.maxY-r.minY;return{position:{x:c==="left"?r.minX:r.maxX,y:n.y},preference:{side:c,yRatio:l>0?(n.y-r.minY)/l:0}}}function jb(e,t,r){const n=eu(e,t),a=eo+rO,c=m=>Math.abs(m.x-r.x)<a&&Math.abs(m.y-r.y)<a;if(!c(n))return n;const l=[{...n,y:r.y-a},{...n,y:r.y+a}].map(m=>eu(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.y-n.y)-Math.abs(x.y-n.y));if(l[0])return l[0];const d=vp(e);return[{...n,x:d.minX},{...n,x:d.maxX}].map(m=>eu(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.x-n.x)-Math.abs(x.x-n.x))[0]??n}const Om="var(--warning)",nO="var(--success)",Db="var(--tmux)",Bb="termdock:mobile-attention-position:v1",Qb="termdock:running-session-position:v1",sO={side:"right",yRatio:.68},iO={side:"right",yRatio:.54};function Pb(e,t){if(typeof window>"u")return t;try{const r=JSON.parse(window.localStorage.getItem(e)??"null");if(r&&(r.side==="left"||r.side==="right")&&typeof r.yRatio=="number"&&Number.isFinite(r.yRatio))return{side:r.side,yRatio:Math.min(1,Math.max(0,r.yRatio))}}catch{}return t}function aO(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function $h(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function oO(e,t,r={}){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,a=n?.width??window.innerWidth,c=n?.height??window.innerHeight,l=t?.getBoundingClientRect(),d=!!(l&&l.width>0&&l.height>0);return{width:a,height:c,safeTop:Math.max($h("--safe-top-inset"),(d?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max($h("--safe-right-inset"),(d?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max($h("--safe-bottom-inset"),(d?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max($h("--safe-left-inset"),(d?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?Xf:72}}function a4(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=tO(t,e.activeSessionId);if(!r)return;const n=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;n?.agentNeedsReview&&e.clearAgentNeedsReview(n.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:r}))}function Ob(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function o4(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function lO({indicator:e,tone:t,size:r}){const n=o4(t);switch(e){case"spinner":return s.jsx(Rn,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(Cf,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(wc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx(el,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(lT,{size:r,className:"shrink-0 animate-pulse",style:{color:n}});case"ring":return s.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:r,height:r,borderColor:n}});case"dot":return s.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,r-4),height:Math.max(5,r-4),backgroundColor:n}})}}function tu({agent:e,size:t=12}){const r=t-4,n=XP(e);return n?e.iconMode==="native"?s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:s.jsx("img",{src:n,alt:e.displayName,style:{width:r,height:r}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx("span",{className:"block bg-white",style:{width:r,height:r,WebkitMask:`url(${n}) center / contain no-repeat`,mask:`url(${n}) center / contain no-repeat`}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx(G0,{size:r,className:"text-white"})})}function cO({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(tu,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(su,{size:r,className:"shrink-0"}):s.jsx(el,{size:r,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?s.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:s.jsx(lO,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(Rn,{size:r,className:"shrink-0 animate-spin",style:{color:nO}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Cf,{size:r,className:"shrink-0 animate-bounce-y",style:{color:Om}})}):t?.agentStatus==="done"&&t.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(wc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:Om}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(wc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:Om}})}):t?.inCopyMode?e==="tmux"?s.jsx(su,{size:r,className:"shrink-0 animate-pulse",style:{color:Db}}):s.jsx(el,{size:r,className:"shrink-0 animate-pulse",style:{color:Db}}):n}function uO({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=Gr();return t&&!r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:o4(t.tone)},title:t.label}):e==="working"?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:a("agent.aiRunning")}):e==="waiting"||r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a(r?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a("agent.finishedReview")}):n?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:a("agent.copyMode")}):null}function l4({count:e,tone:t,title:r}){const{t:n}=Gr();if(e<=0)return null;const a=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",c=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=r??n("agent.jumpToNext");return s.jsxs("button",{type:"button",className:a,title:`${l} · ${n("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${n("agent.jumpToNext")}`,onClick:a4,children:[s.jsx(wc,{size:11,className:"shrink-0"}),s.jsx("span",{children:n("agent.needsReview")}),s.jsx("span",{className:"tabular-nums",children:e})]})}return s.jsxs("span",{className:a,title:r,children:[s.jsx("span",{className:c}),e]})}function dO({runningCount:e,reviewCount:t,className:r=""}){const n=[];return e>0&&n.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&n.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),n.length===0?null:s.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${n.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${r}`,children:n.map(a=>s.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${a.className}`,children:a.count>9?"9+":a.count},a.key))})}const hO=380,Fb=10,Uh=10,Fm=52,fO=104;function pO(e,t,r){const n=Math.max(0,t.safeLeft??0),a=t.width-Math.max(0,t.safeRight??0),c=Math.max(0,t.safeTop??0),l=t.height-Math.max(0,t.safeBottom??0),d=Xf,f=e.x+eo/2>=n+(a-n)/2,m=f?e.x-Uh-n-d:a-d-e.x-eo-Uh,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*fO))),y=f?e.x-Uh-x:e.x+eo+Uh,w=Math.min(Math.max(y,n+d),Math.max(n+d,a-d-x)),v=e.y+eo/2-Fm/2,T=Math.min(Math.max(v,c+d),Math.max(c+d,l-d-Fm));return{left:w,top:T,width:x,height:Fm,itemWidth:x/Math.max(1,r),side:f?"left":"right"}}function $b(e,t,r,n){return t<e.left||t>e.left+e.width||r<e.top-14||r>e.top+e.height+14?null:Math.min(n-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function mO(e,t){if(e.length===0)return null;const r=t?e.findIndex(n=>n.id===t):-1;return e[(r+1)%e.length]?.id??null}function gO({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:d}){const{t:f}=Gr(),m=Vt(Se=>Se.leftOpen),x=Vt(Se=>Se.rightOpen),{isOpen:y}=kv({enabled:!c}),w=c||!m&&!x&&!y,v=ZP(e),[T,C]=_.useState(!1);_.useEffect(()=>{(!v.active||!w)&&C(!1)},[v.active,w]);const L=a&&v.total>0&&w,N=t.length>1||t.length===1&&t[0]?.id!==r,D=n&&t.length>0&&N&&w,O=Math.max(0,d?.top??0),P=Math.max(0,d?.right??0),F=Math.max(0,d?.bottom??0),ee=Math.max(0,d?.left??0),Z=_.useCallback(()=>oO(c,l,{top:O,right:P,bottom:F,left:ee}),[l,c,F,ee,P,O]),G=_.useRef({attention:Pb(Bb,sO),running:Pb(Qb,iO)}),de=_.useCallback(()=>{const Se=Z(),He=Rb(Se,G.current.attention),ke=Rb(Se,G.current.running);return{attention:He,running:L&&D?jb(Se,ke,He):ke}},[L,Z,D]),[pe,J]=_.useState(()=>de()),Re=_.useRef(pe);Re.current=pe;const[Ze,V]=_.useState(null),ve=_.useRef(null),[qe,le]=_.useState("idle"),[ye,Te]=_.useState(null),Fe=_.useRef(null),se=_.useRef({attention:!1,running:!1});_.useEffect(()=>()=>{const Se=Fe.current?.longPressTimer;Se!=null&&window.clearTimeout(Se)},[]),_.useEffect(()=>{if(D)return;const Se=Fe.current?.longPressTimer;Se!=null&&window.clearTimeout(Se),Fe.current=null,le("idle"),Te(null)},[D]),_.useLayoutEffect(()=>{const Se=()=>{const ke=de();Re.current=ke,J(ke)};Se(),window.addEventListener("resize",Se),window.addEventListener("orientationchange",Se),window.visualViewport?.addEventListener("resize",Se);const He=typeof ResizeObserver>"u"?null:new ResizeObserver(Se);return l&&He?.observe(l),()=>{window.removeEventListener("resize",Se),window.removeEventListener("orientationchange",Se),window.visualViewport?.removeEventListener("resize",Se),He?.disconnect()}},[l,de]);const De=_.useCallback(Se=>Se==="attention"?D:L,[L,D]),_e=_.useCallback((Se,He)=>{if(!De(Se))return He;const ke=Se==="attention"?"running":"attention";return jb(Z(),He,Re.current[ke])},[Z,De]),Me=_.useCallback((Se,He,ke,z)=>{const ie=Z(),ge=He.moved?eu(ie,{x:He.startX+(ke-He.originX),y:He.startY+(z-He.originY)}):Re.current[Se],We=Mb(ie,ge),tt=_e(Se,We.position),wt=Mb(ie,tt);G.current[Se]=wt.preference,aO(Se==="attention"?Bb:Qb,wt.preference);const Zt={...Re.current,[Se]:wt.position};Re.current=Zt,J(Zt)},[_e,Z]),Ke=_.useCallback(Se=>{se.current[Se]=!0,window.setTimeout(()=>{se.current[Se]=!1},0)},[]),Ne=_.useCallback(Se=>{const He=ve.current;!He||He.kind!=="attention"||He.pointerId!==Se.pointerId||(ve.current=null,V(null),Me("attention",He,Se.clientX,Se.clientY),He.moved&&Ke("attention"))},[Me,Ke]),ae={onPointerDown:Se=>{Se.stopPropagation(),Se.currentTarget.setPointerCapture(Se.pointerId),ve.current={kind:"attention",pointerId:Se.pointerId,originX:Se.clientX,originY:Se.clientY,startX:pe.attention.x,startY:pe.attention.y,moved:!1}},onPointerMove:Se=>{const He=ve.current;if(!He||He.kind!=="attention"||He.pointerId!==Se.pointerId)return;const ke=Se.clientX-He.originX,z=Se.clientY-He.originY;if(!He.moved&&Math.hypot(ke,z)<5)return;He.moved=!0,V("attention");const ie=Z(),ge=_e("attention",eu(ie,{x:He.startX+ke,y:He.startY+z})),We={...Re.current,attention:ge};Re.current=We,J(We)},onPointerUp:Ne,onPointerCancel:Ne},ze=l?pO(pe.running,Z(),t.length):null,at=Se=>{Se.longPressTimer!==null&&(window.clearTimeout(Se.longPressTimer),Se.longPressTimer=null)},ct={onPointerDown:Se=>{Se.stopPropagation(),Se.currentTarget.setPointerCapture(Se.pointerId);const He=Se.pointerId,ke={pointerId:He,originX:Se.clientX,originY:Se.clientY,startX:pe.running.x,startY:pe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};ke.longPressTimer=window.setTimeout(()=>{const z=Fe.current;!z||z.pointerId!==He||z.mode!=="pressing"||(z.longPressTimer=null,z.mode="dragging",se.current.running=!0,le("dragging"))},hO),Fe.current=ke,le("pressing"),Te(null)},onPointerMove:Se=>{const He=Fe.current;if(!He||He.pointerId!==Se.pointerId)return;const ke=Se.clientX-He.originX,z=Se.clientY-He.originY;if(He.mode==="pressing")if(Math.abs(ke)>=Fb&&Math.abs(ke)>=Math.abs(z))at(He),He.mode="selecting",se.current.running=!0,le("selecting");else if(Math.hypot(ke,z)>=Fb){at(He),He.mode="cancelled",se.current.running=!0,le("idle");return}else return;if(He.mode==="selecting"){const tt=ze?$b(ze,Se.clientX,Se.clientY,t.length):null;He.selectedIndex=tt,Te(tt);return}if(He.mode!=="dragging"||!He.moved&&Math.hypot(ke,z)<5)return;He.moved=!0;const ie=Z(),ge=_e("running",eu(ie,{x:He.startX+ke,y:He.startY+z})),We={...Re.current,running:ge};Re.current=We,J(We)},onPointerUp:Se=>{const He=Fe.current;if(!He||He.pointerId!==Se.pointerId)return;at(He);const ke=He.mode;if(ke==="selecting"){const z=ze?$b(ze,Se.clientX,Se.clientY,t.length):He.selectedIndex,ie=z===null?null:t[z]?.id;ie&&Ob(ie)}else ke==="dragging"&&Me("running",He,Se.clientX,Se.clientY);Fe.current=null,le("idle"),Te(null),ke!=="pressing"&&Ke("running")},onPointerCancel:Se=>{const He=Fe.current;!He||He.pointerId!==Se.pointerId||(at(He),Fe.current=null,le("idle"),Te(null),Ke("running"))}},me=(Se,He)=>s.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${He==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Se>9?"9+":Se}),ut=()=>{const Se=v.hasOtherAttention?f("serviceAttention.title"):f("agent.jumpToNext"),He=pe.attention,ke=Ze==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...ae,onClick:z=>{z.stopPropagation(),!se.current.attention&&(v.hasOtherAttention?C(!0):a4())},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${ke?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{display:T?"none":void 0,left:He.x,top:He.y,width:eo,height:eo,touchAction:"none"},"aria-label":`${Se}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:Se,children:[s.jsx(wc,{size:17,className:"shrink-0"}),me(v.total,"attention")]},"attention")},ft=()=>{const Se=t.length,He=pe.running,ke=qe==="selecting",z=qe==="dragging";return s.jsxs(_.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":qe,...ct,onClick:ie=>{if(ie.stopPropagation(),se.current.running)return;const ge=mO(t,r);ge&&Ob(ge)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${z?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":ke?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:He.x,top:He.y,width:eo,height:eo,touchAction:"none"},"aria-label":`${f("agent.jumpToNextRunning")}: ${Se}`,title:f("agent.runningSessionGestureHint"),children:[s.jsx(Rn,{size:18,className:"shrink-0 animate-spin"}),me(Se,"running")]}),ke&&ze&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":ze.side,"aria-label":f("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:ze.left,top:ze.top,width:ze.width,height:ze.height},children:t.map((ie,ge)=>{const We=ge===ye,tt=ie.id===r,wt=`${ie.label}${ie.detail?` · ${ie.detail}`:""}${tt?` · ${f("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":We,"data-running-session-option":ie.id,"data-selected":We?"true":"false",title:wt,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${We?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":tt?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[s.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${We?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:ge+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:ie.label})]},ie.id)})})]},"running")};return!L&&!D&&!T||l===null||typeof document>"u"?null:s.jsxs(q8,{children:[L&&ut(),D&&!T&&ft(),T&&v.active&&w&&s.jsx(KP,{groups:v.groups,currentKey:v.currentKey,onClose:()=>C(!1)})]})}function xO(){const{t:e}=Gr();return s.jsxs("div",{role:"status",className:"td-loading-skeleton overflow-hidden px-3 py-2",children:[s.jsx("span",{className:"sr-only",children:e("common.loading")}),s.jsx("div",{"aria-hidden":"true",children:["w-2/5","w-3/5","w-1/3","w-1/2","w-2/5","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-8 items-center gap-2",style:{paddingLeft:r>1&&r<5?20:0},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},r))})]})}const bO=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),Ub=120,zb=120,yO=new Set,vO=[],wO={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function Zg(e,t){if(t==="directory")return null;if(K8(e))return s.jsx(XA,{size:14});if(X8(e))return s.jsx(g3,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return bO.has(r)?s.jsx(CT,{size:14}):s.jsx(o3,{size:14})}function c4({path:e}){const r=Vt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=wO[r]??{label:"?",className:"text-muted-foreground",title:r};return s.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${n.className}`,title:n.title,children:n.label})}function ud(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100 sm:group-focus-within:ml-1 sm:group-focus-within:w-6 sm:group-focus-within:overflow-visible sm:group-focus-within:opacity-100"}function Kg(e){return ud(e)}const AO=b.memo(function({path:t}){const{t:r}=Gr(),[n,a]=b.useState("idle"),[c,l]=b.useState(null),d=b.useCallback(async f=>{if(f.stopPropagation(),n!=="pending"){a("pending"),l(null);try{await Zy(t),a("idle")}catch(m){a("error"),l(m instanceof Error?m.message:r("rightSidebar.downloadFailed"))}}},[t,n,r]);return s.jsx("button",{type:"button",disabled:n==="pending","aria-label":r("rightSidebar.downloadFile"),onClick:f=>{d(f)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${ud(n==="pending")} ${n==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:n==="error"?c??r("rightSidebar.downloadFailed"):r("rightSidebar.downloadFile"),children:n==="pending"?s.jsx(Rn,{size:12,className:"animate-spin"}):s.jsx(E0,{size:12})})});function u4(){const{t:e}=Gr(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await Zy(a),r({status:"idle"})}catch(c){r({status:"error",message:c instanceof Error?c.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:n}}function G1(e){return e instanceof DOMException&&e.name==="AbortError"}function Jf(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function d4(e){return e.button===2||e.ctrlKey}const TO=176,SO=160,Xd=8;function Hb(e,t,r,n){const a=window.visualViewport,c=a?.offsetLeft??0,l=a?.offsetTop??0,d=c+(a?.width??window.innerWidth),f=l+(a?.height??window.innerHeight),m=c+Xd,x=l+Xd,y=Math.max(m,d-r-Xd),w=Math.max(x,f-n-Xd),v=t+n<=f-Xd?t:t-n;return{anchorX:e,anchorY:t,left:Math.min(Math.max(e,m),y),top:Math.min(Math.max(v,x),w)}}function h4(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(Hb(c,l,TO,SO))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=Hb(t.anchorX,t.anchorY,c.width,c.height);l.left===t.left&&l.top===t.top||r(l)},[e,t]),{position:t,menuRef:n,openAt:a,clearPosition:()=>r(null)}}function f4(e,t){return t&&typeof document<"u"?ci.createPortal(e,document.body):e}function CO(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function Xg(e,t,r){if(!t||CO(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>Xg(a,t,r)):!1}function V1(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,modified:t.modified,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function q1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const _O=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:f,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:T,onOpenInFileBrowser:C,canOpenInFileBrowser:L,pinnedPaths:N,selectedFilePath:D,queryLower:O,onDirectoryDropFiles:P,onFileDeleteRequest:F,deletingFilePath:ee,revealedDirectoryPath:Z,gitIgnoreRoot:G}){const{t:de}=Gr(),pe=Vt(lt=>lt.expandedPaths.has(t.path)),J=Vt(lt=>lt.directoryCache.get(t.path)),Re=Vt(lt=>lt.showHiddenFiles),Ze=Vt(lt=>lt.toggleExpanded),V=Vt(lt=>lt.setDirectoryCache),ve=Vt(lt=>lt.fileSortModes[t.path]??"name"),qe=Vt(lt=>lt.setDirectorySortMode),[le,ye]=b.useState(!1),[Te,Fe]=b.useState(!1),{position:se,menuRef:De,openAt:_e,clearPosition:Me}=h4(Te),[Ke,Ne]=b.useState(!1),ae=b.useRef(0),ze=b.useRef(null),at=`file-tree-reference:${b.useId()}:${t.path}`;ru(De,Te&&!!l,()=>Fe(!1));const ct=b.useRef(null),me=t.path===D||t.path===Z,ut=t.type==="directory"&&(pe||!!O),ft=t.type==="directory",Se=N.has(t.path),He=!ft&&!!T,ke=!!(L&&C),z=`path:${t.path}`,ie=m===z||!!l?.paths.has(t.path),ge=x===z,We=d?.(t.path)??t.path,tt=ag(f,!!l),{state:wt,run:Zt}=u4(),Ut=ee===t.path,Mt=ft&&!a&&!!(y||w||v||ke),nr=b.useMemo(()=>{if(!J)return;if(!O)return J;const lt=Vt.getState().directoryCache;return J.filter(Ct=>(!a||Ct.type==="directory")&&Xg(Ct,O,lt))},[J,a,O]),jt=b.useCallback(async()=>{if(!Vt.getState().directoryCache.has(t.path)&&!le){const Ct=l?at:`file-tree:${t.path}`;ze.current?.abort(),a1(Ct);const ar=new AbortController;ze.current=ar,ye(!0);try{const _r=await rg(t.path,ar.signal,Re,"expand_directory",Ct,ve,G);if(ar.signal.aborted)return;const Nr=V1(_r.entries);V(t.path,Nr)}catch(_r){G1(_r)}finally{ze.current===ar&&(ze.current=null),ye(!1)}}},[t.path,le,V,Re,ve,G,!!l,at]),Xt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const lt=!Vt.getState().expandedPaths.has(t.path);Ze(t.path),lt&&await jt()},[a,t.path,t.type,jt,y,Ze,n]);b.useEffect(()=>{t.type==="directory"&&pe&&!J&&!le&&jt()},[J,pe,jt,le,t.type]);const Bt=b.useCallback(lt=>{lt.stopPropagation(),c?.(t.path,z)},[c,t.path,z]),Ht=b.useCallback(lt=>{lt.stopPropagation(),y?.(t.path),Fe(!1)},[t.path,y]),xe=b.useCallback(lt=>{lt.stopPropagation(),w?.(t.path),Fe(!1)},[t.path,w]),Je=b.useCallback(lt=>{lt.stopPropagation(),v?.(t.path),Fe(!1)},[t.path,v]),ot=b.useCallback(lt=>{lt.stopPropagation(),qe(t.path,ve==="modified"?"name":"modified"),Fe(!1)},[t.path,qe,ve]),Nt=b.useCallback(lt=>{lt.stopPropagation(),T?.(t.path),Fe(!1)},[t.path,T]),K=b.useCallback(lt=>{lt.stopPropagation(),Fe(!1),Zt(t.path)},[t.path,Zt]),xt=b.useCallback(lt=>{lt.stopPropagation(),Fe(!1),F(t)},[t,F]),tr=b.useCallback(lt=>{lt.stopPropagation(),C?.(t.path),Fe(!1)},[t.path,C]),$e=b.useCallback(lt=>{!ft||!P||!lt.dataTransfer.types.includes("Files")||(lt.preventDefault(),lt.stopPropagation(),ae.current+=1,Ne(!0))},[ft,P]),Qr=b.useCallback(lt=>{!ft||!P||!lt.dataTransfer.types.includes("Files")||(lt.preventDefault(),lt.stopPropagation(),lt.dataTransfer.dropEffect="copy",Ne(!0))},[ft,P]),Ce=b.useCallback(lt=>{!ft||!P||(lt.preventDefault(),lt.stopPropagation(),ae.current-=1,ae.current<=0&&(ae.current=0,Ne(!1)))},[ft,P]),St=b.useCallback(lt=>{if(!ft||!P)return;lt.preventDefault(),lt.stopPropagation(),ae.current=0,Ne(!1);const Ct=Array.from(lt.dataTransfer.files);Ct.length>0&&P(t.path,Ct)},[ft,t.path,P]),Ot=b.useCallback(lt=>{lt.stopPropagation(),l?_e(lt.clientX,lt.clientY):Me(),Fe(Ct=>!Ct)},[Me,_e,!!l]),Jt=b.useCallback(lt=>{!Mt||!d4(lt)||(lt.preventDefault(),lt.stopPropagation(),_e(lt.clientX,lt.clientY),Fe(!0))},[Mt,_e]);return b.useEffect(()=>{if(!Te)return;const lt=ar=>{const _r=ar.target;_r instanceof Node&&(ct.current?.contains(_r)||De.current?.contains(_r))||Fe(!1)},Ct=ar=>{ar.key==="Escape"&&Fe(!1)};return document.addEventListener("pointerdown",lt),document.addEventListener("keydown",Ct),()=>{document.removeEventListener("pointerdown",lt),document.removeEventListener("keydown",Ct)}},[Te,De]),b.useEffect(()=>()=>{ze.current?.abort()},[]),s.jsxs("div",{style:!ut&&!Te?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:ct,className:"relative",children:[tt.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":ve,role:"button",tabIndex:0,onClick:()=>{Jf()||Xt()},onContextMenu:Jt,onKeyDown:lt=>{lt.target!==lt.currentTarget||lt.key!=="Enter"&&lt.key!==" "||(lt.preventDefault(),Xt())},onDragEnter:$e,onDragOver:Qr,onDragLeave:Ce,onDrop:St,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Ke?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":me?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[r>0&&s.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:`${r*14-4}px`}}),Ke&&s.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:de("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[ut?s.jsx(Cl,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(Ks,{size:14,className:"shrink-0 text-muted-foreground/80"}),ut?s.jsx(Ku,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(nu,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:me?"text-primary":"text-muted-foreground/80",children:Zg(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${me?"font-medium":""}`,children:[t.name,ve==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:de("fileTree.sortedByModified"),"aria-label":de("fileTree.sortedByModified"),children:s.jsx(I0,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:de("fileTree.symbolicLink"),children:s.jsx(sd,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${me?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:lt=>lt.stopPropagation(),children:[le&&s.jsx(Rn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(c4,{path:t.path}),Mt&&s.jsx("button",{type:"button",onClick:Ot,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${ud(Te)} ${Te?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":de("fileTree.moreDirActions"),"aria-expanded":Te,title:de("fileTree.moreDirActions"),children:s.jsx(Ro,{size:13})}),!ft&&!l&&s.jsx("button",{type:"button",onClick:Ot,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${ud(Te||wt.status==="pending"||Ut||Se)} ${Te?"bg-surface-elevated text-foreground":Se?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":de("fileTree.moreFileActions"),"aria-expanded":Te,title:wt.status==="error"?wt.message??de("rightSidebar.downloadFailed"):de("fileTree.moreFileActions"),children:wt.status==="pending"||Ut?s.jsx(Rn,{size:13,className:"animate-spin"}):s.jsx(Ro,{size:13})}),c&&s.jsx("button",{type:"button",onClick:Bt,...tt(We,z),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${l?"ml-1 min-h-11 min-w-11":Kg(ie||ge)} ${ie||ge?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:de(ge?"rightSidebar.copied":ie?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?ie:void 0,disabled:!!l?.disabled&&!ie,title:l?`${l.label}: ${t.name}`:de(ge?"rightSidebar.copied":ie?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:ge||ie?s.jsx(Ci,{size:12}):s.jsx(sd,{size:12})}),Mt&&Te&&f4(s.jsxs("div",{ref:De,className:`${se?l?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:se?{left:se.left,top:se.top}:void 0,children:[ke&&s.jsxs("button",{type:"button",onClick:tr,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:de("fileTree.openInFileBrowserTitle"),children:[s.jsx(Ku,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:Ht,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:de("fileTree.openDirRootTitle"),children:[s.jsx(Ku,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("fileTree.openDirRoot")})]}),w&&s.jsxs("button",{type:"button",onClick:xe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:de("fileTree.searchFromDirTitle"),children:[s.jsx(og,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Je,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${Se?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:de(Se?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Se?s.jsx(R0,{size:13,className:"shrink-0"}):s.jsx(N0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de(Se?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:ot,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[ve==="modified"?s.jsx(WA,{size:13,className:"shrink-0"}):s.jsx(I0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de(ve==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!se),!ft&&!l&&Te&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[ke&&s.jsxs("button",{type:"button",onClick:tr,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:de("fileTree.openInFileBrowserTitle"),children:[s.jsx(o3,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:K,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:de("rightSidebar.downloadFile"),children:[s.jsx(E0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("rightSidebar.downloadFile")})]}),He&&s.jsxs("button",{type:"button",onClick:Nt,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${Se?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:de(Se?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Se?s.jsx(R0,{size:13,className:"shrink-0"}):s.jsx(N0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de(Se?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:xt,disabled:Ut,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:de("fileTree.deleteFile"),children:[Ut?s.jsx(Rn,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:de("fileTree.deleteFile")})]})]})]})]})]}),ut&&nr&&nr.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:nr.map(lt=>s.jsx(e,{node:lt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:f,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:T,onOpenInFileBrowser:C,canOpenInFileBrowser:L,pinnedPaths:N,selectedFilePath:D,queryLower:O,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:P,onFileDeleteRequest:F,deletingFilePath:ee,gitIgnoreRoot:G,revealedDirectoryPath:Z},lt.path))})]})}),kO=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,referenceSelection:c,getReferenceText:l,onReferenceCopied:d,insertedReferenceKey:f,copiedReferenceKey:m,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:w,onFilePinToggle:v,pinnedPaths:T,selectedFilePath:C,onFileDeleteRequest:L,deletingFilePath:N}){const{t:D}=Gr(),O=t.path===C,P=t.type==="directory",F=T.has(t.path),ee=!P&&!!v,Z=`path:${t.path}`,G=f===Z||!!c?.paths.has(t.path),de=m===Z,pe=l?.(t.path)??t.path,J=ag(d,!!c),{state:Re,run:Ze}=u4(),[V,ve]=b.useState(!1),{position:qe,menuRef:le,openAt:ye,clearPosition:Te}=h4(V);ru(le,V&&!!c,()=>ve(!1));const Fe=b.useRef(null),se=N===t.path,De=P&&!!(x||y||w),_e=b.useCallback(()=>{Jf()||(t.type==="directory"?x?.(t.path):n(t.path))},[t.path,t.type,x,n]),Me=b.useCallback(me=>{me.stopPropagation(),a?.(t.path,Z)},[a,t.path,Z]),Ke=b.useCallback(me=>{me.stopPropagation(),w?.(t.path),ve(!1)},[t.path,w]),Ne=b.useCallback(me=>{me.stopPropagation(),v?.(t.path),ve(!1)},[t.path,v]),ae=b.useCallback(me=>{me.stopPropagation(),ve(!1),Ze(t.path)},[t.path,Ze]),ze=b.useCallback(me=>{me.stopPropagation(),ve(!1),L(t)},[t,L]),at=b.useCallback(me=>{me.stopPropagation(),c?ye(me.clientX,me.clientY):Te(),ve(ut=>!ut)},[Te,ye,!!c]),ct=b.useCallback(me=>{!De||!d4(me)||(me.preventDefault(),me.stopPropagation(),ye(me.clientX,me.clientY),ve(!0))},[De,ye]);return b.useEffect(()=>{if(!V)return;const me=ft=>{const Se=ft.target;Se instanceof Node&&(Fe.current?.contains(Se)||le.current?.contains(Se))||ve(!1)},ut=ft=>{ft.key==="Escape"&&ve(!1)};return document.addEventListener("pointerdown",me),document.addEventListener("keydown",ut),()=>{document.removeEventListener("pointerdown",me),document.removeEventListener("keydown",ut)}},[V,le]),s.jsxs("div",{ref:Fe,className:"relative border-b border-border/10 last:border-b-0",children:[J.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:_e,onContextMenu:ct,onKeyDown:me=>{me.target!==me.currentTarget||me.key!=="Enter"&&me.key!==" "||(me.preventDefault(),_e())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${O?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx(nu,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:O?"text-primary":"text-muted-foreground/80",children:Zg(t.name,t.type)})]}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsxs("span",{className:`block whitespace-normal break-all font-medium leading-snug ${O?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:D("fileTree.symbolicLink"),children:s.jsx(sd,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:q1(r,t.path)})]}),s.jsx(c4,{path:t.path}),t.type==="directory"&&(w||y)&&s.jsx("button",{type:"button",onClick:at,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${ud(V)} ${V?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":D("fileTree.moreDirActions"),"aria-expanded":V,title:D("fileTree.moreDirActions"),children:s.jsx(Ro,{size:13})}),!P&&!c&&s.jsx("button",{type:"button",onClick:at,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${ud(V||Re.status==="pending"||se||F)} ${V?"bg-surface-elevated text-foreground":F?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":D("fileTree.moreFileActions"),"aria-expanded":V,title:Re.status==="error"?Re.message??D("rightSidebar.downloadFailed"):D("fileTree.moreFileActions"),children:Re.status==="pending"||se?s.jsx(Rn,{size:13,className:"animate-spin"}):s.jsx(Ro,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Me,...J(pe,Z),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${c?"ml-1 min-h-11 min-w-11":Kg(G||de)} ${G||de?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:D(de?"rightSidebar.copied":G?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?G:void 0,disabled:!!c?.disabled&&!G,title:c?`${c.label}: ${t.name}`:D(de?"rightSidebar.copied":G?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:de||G?s.jsx(Ci,{size:12}):s.jsx(sd,{size:12})})]}),De&&V&&f4(s.jsxs("div",{ref:le,className:`${qe?c?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:qe?{left:qe.left,top:qe.top}:void 0,children:[x&&s.jsxs("button",{type:"button",onClick:me=>{me.stopPropagation(),x(t.path),ve(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:D("fileTree.openDirRootTitle"),children:[s.jsx(Ku,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:me=>{me.stopPropagation(),y(t.path),ve(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[s.jsx(og,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D("fileTree.searchFromDir")})]}),w&&s.jsxs("button",{type:"button",onClick:Ke,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${F?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:D(F?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[F?s.jsx(R0,{size:13,className:"shrink-0"}):s.jsx(N0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D(F?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!qe),!P&&!c&&V&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[s.jsxs("button",{type:"button",onClick:ae,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:D("rightSidebar.downloadFile"),children:[s.jsx(E0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D("rightSidebar.downloadFile")})]}),ee&&s.jsxs("button",{type:"button",onClick:Ne,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${F?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:D(F?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[F?s.jsx(R0,{size:13,className:"shrink-0"}):s.jsx(N0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D(F?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:ze,disabled:se,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:D("fileTree.deleteFile"),children:[se?s.jsx(Rn,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:D("fileTree.deleteFile")})]})]})]})}),LO=60,Wb=60,IO=20;function Gb({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=Gr();return s.jsxs("div",{className:"sticky top-0 z-10 -mx-2 -mt-2 mb-2 border-b border-border/15 bg-surface/95 px-3 py-2.5 backdrop-blur",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 text-[12px] font-semibold text-foreground",children:[s.jsx(og,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{children:c?l("fileTree.contentMatchesCount",{count:e}):l("fileTree.searchResults",{count:e})})]}),r&&s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[9px] uppercase tracking-[0.12em] text-muted-foreground",children:[t&&s.jsx(Rn,{size:9,className:"animate-spin"}),r,n?" · limited":""]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:l("fileTree.searchScope")}),s.jsx("span",{className:"min-w-0 truncate font-mono text-foreground/75",title:a,children:a}),t&&s.jsx("span",{className:"ml-auto shrink-0",children:l("fileTree.searching")})]})]})}function EO(e,t){if(!t)return e;const r=e.toLowerCase(),n=t.toLowerCase(),a=[];let c=0,l=r.indexOf(n,c),d=0;for(;l>=0&&n;)l>c&&a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(l,l+n.length)},`m-${d++}`)),c=l+n.length,l=r.indexOf(n,c);return c<e.length&&a.push(e.slice(c)),a.length>0?a:e}const NO=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:c,onPathReference:l,referenceSelection:d,getReferenceText:f,onReferenceCopied:m,insertedReferenceKey:x,copiedReferenceKey:y}){const{t:w}=Gr(),[v,T]=b.useState(!0),C=t.path===n,L=v?t.matches.slice(0,IO):[],N=t.matches.length-L.length,D=`path:${t.path}`,O=x===D||!!d?.paths.has(t.path),P=y===D,F=f?.(t.path)??t.path,ee=ag(m,!!d);return s.jsxs("div",{className:"border-b border-border/10 last:border-b-0",children:[ee.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Jf()||T(Z=>!Z)},onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),T(G=>!G))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${C?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[v?s.jsx(Cl,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(Ks,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:C?"text-primary":"text-muted-foreground/80",children:Zg(t.name,"file")}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:q1(r,t.path)})]}),s.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),!d&&s.jsx(AO,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),l(t.path,D)},...ee(F,D),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${d?"ml-1 min-h-11 min-w-11":Kg(O||P)} ${O||P?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":d?`${d.label}: ${t.name}`:w(P?"rightSidebar.copied":O?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":d?O:void 0,disabled:!!d?.disabled&&!O,title:d?`${d.label}: ${t.name}`:w(P?"rightSidebar.copied":O?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:P||O?s.jsx(Ci,{size:12}):s.jsx(sd,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[L.map((Z,G)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Jf()||c?.(t.path,Z.line)},onKeyDown:de=>{de.target!==de.currentTarget||de.key!=="Enter"&&de.key!==" "||(de.preventDefault(),c?.(t.path,Z.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${q1(r,t.path)}:${Z.line}`,children:[s.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:Z.line}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:EO(Z.text,a)})]},`${Z.line}-${G}`)),N>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:N})})]})]})});function RO({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:f,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:T=!1,pinnedPaths:C=yO,selectedFilePath:L,query:N="",searchRootPath:D,searchOptions:O={},searchMode:P="name",onContentMatchSelect:F,onDirectoryDropFiles:ee,revealDirectory:Z}){const{t:G}=Gr(),de=b.useId(),pe=a?`file-tree-reference-root:${de}:${e}`:`file-tree-root:${e}`,J=Vt(Ce=>e?Ce.directoryCache.get(e):void 0),Re=Vt(Ce=>Ce.setDirectoryCache),Ze=Vt(Ce=>Ce.showHiddenFiles),V=Vt(Ce=>Ce.fileSortModesHydrated),ve=Vt(Ce=>Ce.fileSortModes[e]??"name"),qe=Vt(Ce=>Ce.hydrateFileSortModes),le=Vt(Ce=>Ce.hydrateHideGitIgnoredRoots),ye=Vt(Ce=>!!Ce.hideGitIgnoredRoots[e]),Te=Vt(Ce=>Ce.hideGitIgnoredRootsHydrated),Fe=Vt(Ce=>JSON.stringify(Ce.gitIgnoreExceptions[e]??[])),se=Vt(Ce=>Ce.invalidateDirectoryCache),De=`${e}:${ye}:${Fe}`,[_e,Me]=b.useState("");b.useLayoutEffect(()=>{e&&se(e,!0),Me(De)},[e,ye,Fe,se,De]);const[Ke,Ne]=b.useState(!1),[ae,ze]=b.useState(null),[at,ct]=b.useState(!1),[me,ut]=b.useState(!1),[ft,Se]=b.useState(null),[He,ke]=b.useState(V&&Te),z=V&&Te||He;b.useEffect(()=>{let Ce=!1;return Promise.all([qe(),le()]).catch(()=>{}).finally(()=>{Ce||ke(!0)}),()=>{Ce=!0}},[qe,le]);const[ie,ge]=b.useState([]),[We,tt]=b.useState(null),[wt,Zt]=b.useState(Ub),[Ut,Mt]=b.useState([]),[nr,jt]=b.useState(null),Xt=b.useRef({busy:!1}),Bt=b.useRef(0),Ht=b.useRef(e);Ht.current=e,b.useEffect(()=>{const Ce=()=>{Bt.current++};for(const St of["pagehide","auth:unauthorized",zu])window.addEventListener(St,Ce);return()=>{Ce();for(const St of["pagehide","auth:unauthorized",zu])window.removeEventListener(St,Ce)}},[]);const xe=b.useRef(null),Je=b.useRef(0),ot=N.trim().toLowerCase(),Nt=P==="content",K=D||e,xt=O.excludePatterns??vO,tr=xt.join(`
137
+ `);b.useEffect(()=>{const Ce=Z?.path;if(!Ce||!Ce.startsWith(`${e}/`)&&Ce!==e)return;const St=Ce.slice(e.length).replace(/^\/+/,""),Ot=St?St.split("/"):[],Jt=Ot.map((Tt,Ft)=>`${e}/${Ot.slice(0,Ft+1).join("/")}`),lt=Vt.getState(),Ct=Jt.filter(Tt=>!lt.expandedPaths.has(Tt));Ct.length>0&&Vt.setState(Tt=>({expandedPaths:new Set([...Tt.expandedPaths,...Ct])}));let ar=!1,_r=0;const Nr=()=>{if(ar)return;const Tt=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(Ft=>Ft.dataset.fileTreePath===Ce);if(Tt){Tt.scrollIntoView({block:"center",behavior:"smooth"});return}_r+=1,_r<80&&window.setTimeout(Nr,50)},zr=window.requestAnimationFrame(Nr);return()=>{ar=!0,window.cancelAnimationFrame(zr)}},[Z?.nonce,Z?.path,e]);const $e=b.useCallback(async Ce=>{if(Xt.current.busy||Ce.type==="directory")return;const St=Bt.current,Ot=ea(),Jt=Sl(),lt=e,Ct=Ce.path.slice(0,Ce.path.lastIndexOf("/"))||"/",ar=()=>Vt.getState().directoryCache.get(Ct)?.find(At=>At.path===Ce.path),_r=At=>JSON.stringify([At.path,At.name,At.type,At.isSymlink,At.modified]),Nr=_r(Ce),zr=ar(),Tt=zr?_r(zr):null;let Ft=!1;const we=()=>{const At=ar();return St===Bt.current&&lt===Ht.current&&Ot===ea()&&Jt===Sl()&&!Jt?.closed&&_r(Ce)===Nr&&(At?_r(At)===(Tt??Nr):Tt===null||Ft)};await cg(Xt.current,{current:we,confirm:()=>y3({title:G("fileTree.deleteFile"),message:G("fileTree.deleteFileConfirm",{name:Ce.name}),confirmLabel:G("fileTree.deleteFile"),cancelLabel:G("common.cancel")}),submit:async At=>{await Y8(Ce.path,At),Ft=!0},apply:()=>{Vt.getState().applyFileWatchEvents([{type:"deleted",path:Ce.path}]),ge(At=>At.filter(st=>st.path!==Ce.path)),Mt(At=>At.filter(st=>st.path!==Ce.path)),C.has(Ce.path)&&w?.(Ce.path)},pending:At=>{St===Bt.current&&jt(At?Ce.path:null)},failure:At=>l1(G("fileTree.deleteFileFailed",{message:At})),expiredMessage:"File deletion context changed"})},[e,w,C,G]);b.useEffect(()=>{if(!e||!z||_e!==De)return;if(ot){Ne(!1);return}if(Vt.getState().directoryCache.has(e)){Ne(!1);return}let Ce=!1;const St=new AbortController;return Ne(!0),ze(null),rg(e,St.signal,Ze,"load_file_tree_root",pe,ve,e).then(Ot=>{if(Ce)return;const Jt=V1(Ot.entries);ct(!!Ot.truncated),Re(e,Jt)}).catch(Ot=>{Ce||G1(Ot)||ze(Ot instanceof Error?Ot.message:"Failed to load directory")}).finally(()=>{Ce||Ne(!1)}),()=>{Ce=!0,St.abort(),a1(pe)}},[ot,J,e,ve,Re,Ze,z,ye,Fe,pe,_e,De]),b.useEffect(()=>{if(!K||!ot){ut(!1),Se(null),ge([]),Mt([]),tt(null);return}let Ce=!1;const St=new AbortController,Ot=new Set;ut(!0),Se(null),ge([]),Mt([]),Zt(Nt?LO:Ub),tt({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const Jt=`file-search:${a?de+":":""}${K}:${++Je.current}`;return Z8(K,N.trim(),lt=>{if(!Ce){if(lt.engine&&tt(Ct=>({truncated:Ct?.truncated??!1,total:Ct?.total??0,engine:lt.engine,limited:lt.limited??Ct?.limited??!1,done:Ct?.done??!1})),lt.entries?.length){const Ct=lt.entries.filter(ar=>Ot.has(ar.path)?!1:(Ot.add(ar.path),!0));Ct.length>0&&(ge(ar=>[...ar,...V1(Ct)]),tt(ar=>ar?{...ar,total:Ot.size}:{truncated:!1,total:Ot.size,engine:"rg",limited:!1,done:!1}))}if(lt.contentEntries?.length){const Ct=lt.contentEntries.filter(ar=>Ot.has(ar.path)?!1:(Ot.add(ar.path),!0));Ct.length>0&&(Mt(ar=>[...ar,...Ct]),tt(ar=>ar?{...ar,total:Ot.size}:{truncated:!1,total:Ot.size,engine:"rg",limited:!1,done:!1}))}lt.done&&tt(Ct=>({truncated:!!lt.truncated,total:typeof lt.total=="number"?lt.total:Ot.size,engine:lt.engine??Ct?.engine??"rg",limited:!!lt.limited,done:!0}))}},St.signal,Ze,P,Jt,{excludePatterns:xt,caseSensitive:O.caseSensitive,wholeWord:O.wholeWord,regex:O.regex}).catch(lt=>{Ce||G1(lt)||(Se(lt instanceof Error?lt.message:"Failed to search files"),ge([]),Mt([]),tt(null))}).finally(()=>{Ce||ut(!1)}),()=>{Ce=!0,St.abort(),a1(Jt)}},[K,tr,Nt,N,ot,P,O.caseSensitive,O.regex,O.wholeWord,Ze,!!a,de]),b.useEffect(()=>{if(!ot)return;const Ce=xe.current;if(!Ce)return;const St=Nt?Ut.length:ie.length,Ot=Nt?Wb:zb,Jt=new IntersectionObserver(lt=>{lt.some(Ct=>Ct.isIntersecting)&&Zt(Ct=>Math.min(Ct+Ot,St))},{rootMargin:"160px 0px"});return Jt.observe(Ce),()=>Jt.disconnect()},[ot,ie.length,Ut.length,Nt]);const Qr=b.useMemo(()=>{if(!J)return;if(!ot)return r?J.filter(St=>St.type==="directory"):J;const Ce=Vt.getState().directoryCache;return J.filter(St=>(!r||St.type==="directory")&&Xg(St,ot,Ce))},[r,ot,J]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:G("fileTree.noWorkingDir")});if(Ke||!z)return s.jsx(xO,{});if(ot&&Nt){const Ce=We?.total??Ut.length,St=Ut.slice(0,wt),Ot=wt<Ut.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Gb,{count:Ce,loading:me,engine:We?.engine,limited:We?.limited,scope:K,content:!0}),ft?s.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[G("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:ft})]}):me&&Ut.length===0?s.jsx(_0,{label:G("fileTree.searching"),className:"py-8"}):Ut.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:G("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[We?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:G("fileTree.searchTruncatedHint",{count:We.total})}),St.map(Jt=>s.jsx(NO,{entry:Jt,rootPath:K,selectedFilePath:L,query:N.trim(),onContentMatchSelect:F,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:f},Jt.path)),s.jsx("div",{ref:xe,className:"py-2 text-center text-[11px] text-muted-foreground",children:Ot?s.jsx("button",{type:"button",onClick:()=>Zt(Jt=>Math.min(Jt+Wb,Ut.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:G("fileTree.loadMoreSearchResults",{shown:St.length,total:Ut.length})}):me?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Rn,{size:10,className:"animate-spin"}),G("fileTree.searchStillRunning")]}):St.length>0?s.jsx("span",{children:G("fileTree.showingSearchResults",{shown:St.length,total:Ce})}):null})]})]})}if(ot){const Ce=We?.total??ie.length,St=ie.slice(0,wt),Ot=wt<ie.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Gb,{count:Ce,loading:me,engine:We?.engine,limited:We?.limited,scope:K,content:!1}),me&&ie.length===0?s.jsx(_0,{label:G("fileTree.searching"),className:"py-8"}):ft?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:ft}):ie.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:G("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[We?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:G("fileTree.searchTruncatedHint",{count:We.total})}),St.map(Jt=>s.jsx(kO,{node:Jt,rootPath:K,onFileSelect:t,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,pinnedPaths:C,selectedFilePath:L,insertedReferenceKey:d,copiedReferenceKey:f,onFileDeleteRequest:$e,deletingFilePath:nr},Jt.path)),s.jsx("div",{ref:xe,className:"py-2 text-center text-[11px] text-muted-foreground",children:Ot?s.jsx("button",{type:"button",onClick:()=>Zt(Jt=>Math.min(Jt+zb,ie.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:G("fileTree.loadMoreSearchResults",{shown:St.length,total:ie.length})}):me?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Rn,{size:10,className:"animate-spin"}),G("fileTree.searchStillRunning")]}):St.length>0?s.jsx("span",{children:G("fileTree.showingSearchResults",{shown:St.length,total:Ce})}):null})]})]})}return ae?s.jsx("div",{role:a?"alert":void 0,className:"px-4 py-4 text-sm text-destructive",children:ae}):!J||J.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:G("fileTree.emptyDir")}):!Qr||Qr.length===0?s.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:G("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[at&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:G("fileTree.truncatedHint")}),Qr.map(Ce=>s.jsx(_O,{node:Ce,gitIgnoreRoot:e,depth:0,onFileSelect:t,directoriesOnly:r,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:T,pinnedPaths:C,selectedFilePath:L,queryLower:ot,insertedReferenceKey:d,copiedReferenceKey:f,onDirectoryDropFiles:ee,onFileDeleteRequest:$e,deletingFilePath:nr,revealedDirectoryPath:Z?.path},Ce.path))]})}function Y1(e){return e.trim().replace(/\/+$/,"")||"/"}function MO(e){const t=Y1(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function wp({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:c}){const{t:l}=Gr(),d={hint:n?.hint??l("sidebar.directoryPickerHint"),cancel:n?.cancel??l("common.cancel"),confirm:n?.confirm??l("sidebar.useThisFolder"),close:n?.close??l("common.close"),parent:n?.parent??l("rightSidebar.parentFolder")},f=b.useRef(null);ru(f,e,a);const[m,x]=b.useState(()=>Y1(t));return b.useEffect(()=>{e&&x(Y1(t))},[t,e]),b.useEffect(()=>{if(!e)return;const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=y}},[e]),e?ci.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:a,"aria-label":d.cancel}),s.jsxs("section",{ref:f,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(RT,{size:15})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:r}),s.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:d.hint})]}),s.jsx("button",{type:"button",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":d.close,children:s.jsx(Dn,{size:15})})]}),s.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:m==="/",onClick:()=>x(MO(m)),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-30","aria-label":d.parent,children:s.jsx(s3,{size:14})}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-foreground",title:m,children:m})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",children:s.jsx(RO,{rootPath:m,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:x,selectedFilePath:t||null})}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[s.jsx("button",{type:"button",onClick:a,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:d.cancel}),s.jsxs("button",{type:"button",onClick:()=>c(m),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[s.jsx(Ci,{size:13}),d.confirm]})]})]})]}),document.body):null}const jO=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:wp},Symbol.toStringTag,{value:"Module"})),Z1="termdock:new-session-commands:v1",bc="__saved_command__:";function zh(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(bc)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function Jd(){try{const e=JSON.parse(localStorage.getItem(Z1)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function DO({directories:e,tmuxAvailable:t,options:r,agents:n,selectedAgent:a,detecting:c,resumeHistory:l,resumeHistoryLoading:d,resumeHistoryPendingId:f,resumeHistoryError:m,onRefreshAgents:x,onSelectAgent:y,onLaunchAgent:w,onResumeHistory:v,onRemoveResumeHistory:T,onClose:C,onOptionsChange:L,additionalContent:N,footerActions:D,launchPending:O=!1,launchError:P}){const{t:F,locale:ee}=Gr(),Z=b.useRef(null);ru(Z,!0,C,()=>document.querySelector('[aria-controls="sidebar-launch-options"]'));const[G,de]=b.useState(a),[pe,J]=b.useState(!1),[Re,Ze]=b.useState(!1),[V,ve]=b.useState(Jd),[qe,le]=b.useState(()=>zh(Jd())),[ye,Te]=b.useState(null),[Fe,se]=b.useState("idle"),De=Re?"__custom__":G?.slug??"__terminal__",_e=G?.command??"",Me=Re?V.__custom__??V.__terminal__??"":G?V[De]??_e:"",Ke=()=>{const ke=Me.trim()||_e;if(!(Re&&!ke))try{const z={...Jd(),[De]:ke};if(Re){for(const ie of zh(Jd()))z[bc+ie]=ie;z[bc+ke]=ke}localStorage.setItem(Z1,JSON.stringify(z)),le(zh(z)),Re&&Te(ke),se("saved")}catch{se("error")}},Ne=()=>{if(ye)try{const ke=Jd();for(const[z,ie]of Object.entries(ke))(z.startsWith(bc)||z==="__custom__"||z==="__terminal__")&&ie.trim()===ye&&delete ke[z];localStorage.setItem(Z1,JSON.stringify(ke)),le(zh(ke)),ve(z=>({...z,__custom__:""})),Te(null),se("idle")}catch{se("error")}},ae=()=>{const ke=Me.trim()||_e;O||Re&&!ke||(Ke(),w(G,ke))},ze=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),at=Re?ye?bc+ye:"__custom__":G?.slug??"__terminal__",ct=ke=>{se("idle");const z=ke.startsWith(bc)?ke.slice(bc.length):null;Te(z),Ze(ke==="__custom__"||z!==null),(z!==null||ke==="__custom__")&&ve(ie=>({...ie,__custom__:z??""})),de(n.find(ie=>ie.slug===ke)??null)},me=Re?ye??F("sidebar.customStartupCommand"):G?.displayName??"Terminal",ut=a?.displayName??"Terminal",ft=!Re&&(G===null?a===null:a?.slug===G.slug);b.useEffect(()=>{if(pe)return;const ke=z=>{z.target instanceof Node&&(Z.current?.contains(z.target)||z.target instanceof Element&&z.target.closest("[data-sidebar-composer-popover]")?.getAttribute("data-sidebar-composer-popover")===Z.current?.id||z.target instanceof Element&&z.target.closest('[aria-controls="sidebar-launch-options"]')||C())};return document.addEventListener("pointerdown",ke,!0),()=>document.removeEventListener("pointerdown",ke,!0)},[pe,C]);const Se=ke=>{L({...r,cwd:ke}),J(!1)},He=ke=>new Intl.DateTimeFormat(ee==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(ke));return s.jsxs("section",{ref:Z,tabIndex:-1,"aria-busy":O,id:"sidebar-launch-options",className:`absolute inset-x-3 bottom-3 z-30 flex flex-col overflow-hidden rounded-2xl border border-border bg-surface shadow-[0_18px_50px_var(--app-shadow-strong),0_4px_14px_var(--app-shadow-soft)] animate-slide-down ${D?"max-h-[min(70svh,42rem,calc(100%_-_4.5rem))]":"max-h-[min(56svh,36rem,calc(100%_-_4.5rem))]"}`,"aria-label":F("sidebar.newSessionComposerTitle"),children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground",children:s.jsx(el,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F("sidebar.newSessionComposerTitle")})})]}),s.jsx("button",{type:"button",onClick:C,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":F("common.close"),children:s.jsx(Dn,{size:14})})]}),s.jsxs("fieldset",{disabled:O,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain border-0 px-3 pb-1",children:[s.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:F("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(ke=>s.jsx("button",{type:"button",disabled:ke==="tmux"&&!t,onClick:()=>L({...r,mode:ke}),"aria-pressed":r.mode===ke,title:ke==="tmux"?F(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===ke?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:F(ke==="shell"?"sidebar.newShell":"sidebar.newTmux")},ke))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:F("sidebar.startupCommand")}),s.jsx("button",{type:"button",onClick:x,disabled:c,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground disabled:opacity-50",title:F("sidebar.detectAgents"),"aria-label":F("sidebar.detectAgents"),children:s.jsx(An,{size:12,className:c?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":F("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(ke=>{const z=!Re&&G?.slug===ke.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":z,onClick:()=>ct(ke.slug),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${z?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(tu,{agent:ke,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:ke.displayName}),a?.slug===ke.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:F("sidebar.defaultAgent")})]},ke.slug)}),qe.map(ke=>{const z=Re&&ye===ke;return s.jsxs("button",{type:"button",role:"radio","aria-checked":z,onClick:()=>ct(bc+ke),title:ke,className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 transition ${z?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Vc,{size:10,className:"shrink-0"}),s.jsx("span",{className:"max-w-[9rem] truncate font-mono text-[10px]",children:ke})]},ke)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":at==="__terminal__",onClick:()=>ct("__terminal__"),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${at==="__terminal__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(el,{size:11,className:"shrink-0"}),s.jsx("span",{children:"Terminal"}),a===null&&s.jsx("span",{className:"ml-0.5 text-[9px] font-normal text-muted-foreground",children:F("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":at==="__custom__",onClick:()=>ct("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${at==="__custom__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Xs,{size:10,className:"shrink-0"}),s.jsx("span",{children:F("sidebar.addStartupCommand")})]})]}),!ft&&!Re&&s.jsxs("div",{className:"mt-1 flex min-h-8 items-center justify-between gap-2 px-0.5 text-[10px]",children:[s.jsx("span",{className:"truncate text-muted-foreground",children:F("sidebar.currentDefaultAgent",{name:ut})}),s.jsx("button",{type:"button",onClick:()=>y(G),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:F("sidebar.makeDefault")})]}),Fe==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:F("sidebar.saveStartupCommandFailed")}),(G||Re)&&s.jsxs("details",{open:Re&&!ye||void 0,className:"group/command mt-0.5",children:[s.jsxs("summary",{className:"ml-auto flex min-h-8 w-fit cursor-pointer list-none items-center gap-1 rounded-md px-1 text-[10px] text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50 [&::-webkit-details-marker]:hidden",children:[F(Re&&!ye?"sidebar.customStartupCommand":"sidebar.changeStartupCommand"),s.jsx(Cl,{size:11,className:"transition-transform group-open/command:rotate-180"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx("label",{htmlFor:"new-session-command",className:"sr-only",children:F("sidebar.startupCommand")}),G&&Me!==_e&&s.jsx("button",{type:"button",onClick:()=>{ve(ke=>({...ke,[De]:_e})),se("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:F("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:Me,onChange:ke=>{ve(z=>({...z,[De]:ke.target.value})),se("idle")},placeholder:_e||F("sidebar.startupCommandPlaceholder"),autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoComplete:"off",className:"min-h-10 w-full rounded-lg border-0 bg-surface px-3 font-mono text-[16px] text-foreground outline-none ring-1 ring-inset ring-border transition focus:ring-primary/50 sm:text-[11px]"}),s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2","aria-live":"polite",children:[Re&&ye&&s.jsxs("button",{type:"button",onClick:Ne,className:"mr-auto inline-flex min-h-9 items-center gap-1 rounded-md px-2 text-[10px] text-muted-foreground transition hover:text-destructive","aria-label":F("sidebar.deleteStartupCommand"),children:[s.jsx(zs,{size:11}),F("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:Ke,disabled:Fe==="saved"||Re&&!Me.trim(),className:"min-h-8 rounded-md px-2 text-[10px] font-medium text-primary transition hover:bg-primary/10 disabled:cursor-default disabled:opacity-50",children:F(Fe==="saved"?"sidebar.startupCommandSaved":"sidebar.saveStartupCommand")})]}),s.jsx("p",{className:"mb-2 mt-1.5 px-0.5 text-[10px] leading-relaxed text-muted-foreground",children:F(G?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},ye??De),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:F("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>J(!0),className:"mt-1 flex min-h-11 w-full items-center gap-2 rounded-lg border border-transparent bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary",children:[s.jsx(nu,{size:12,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${r.cwd?"":"text-muted-foreground"}`,children:r.cwd||F("sidebar.directoryPlaceholder")})]}),ze.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":F("sidebar.recentDirectories"),children:ze.map(ke=>s.jsx("button",{type:"button",onClick:()=>Se(ke),title:ke,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:dd(ke)||ke},ke))}),(l.length>0||m)&&s.jsxs("details",{className:"mt-1",children:[s.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[s.jsx(Vc,{size:11}),s.jsx("span",{className:"flex-1",children:F("sidebar.resumeHistory")}),d&&s.jsx(Rn,{size:10,className:"animate-spin"}),l.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:F("sidebar.resumeHistoryCount",{n:l.length})}),s.jsx(Cl,{size:11})]}),l.length>0&&s.jsx("div",{className:"mt-1 divide-y divide-border overflow-hidden rounded-lg border border-border bg-surface",children:l.slice(0,6).map(ke=>{const z=f===ke.id;return s.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[s.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>v(ke),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":F("sidebar.resumeHistoryAction",{title:ke.title}),children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:z?s.jsx(Rn,{size:13,className:"animate-spin"}):s.jsx(tu,{agent:ke.agent,size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:ke.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[ke.agent.displayName," · ",He(ke.closedAt)]})]}),s.jsx(h3,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>T(ke.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":F("sidebar.resumeHistoryRemove",{title:ke.title}),children:[s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),s.jsx(zs,{size:12})]})]},ke.id)})}),m&&s.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:m})]}),N]}),s.jsxs("div",{className:"shrink-0 bg-surface px-3 pb-3 pt-2",children:[P&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:P}),s.jsxs("button",{type:"button",onClick:ae,disabled:O||Re&&!Me.trim(),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground transition hover:brightness-110 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40","aria-label":F("sidebar.launchSessionWith",{name:me}),children:[O?s.jsx(Rn,{size:14}):G?s.jsx(tu,{agent:G,size:15}):s.jsx(el,{size:14}),s.jsx("span",{className:"truncate",children:O?F("sidebar.sessionCreating"):F("sidebar.launchSessionWith",{name:me})})]}),D]}),s.jsx(wp,{open:pe,initialPath:r.cwd?.trim()||ze[0]||"/",title:F("sidebar.chooseDirectory"),onCancel:()=>J(!1),onConfirm:Se})]})}function BO({onOpenSettings:e,serverAttention:t,actions:r,compact:n=!1}){const{t:a}=Gr(),[c,l]=b.useState(!1),d=b.useRef(null),f=b.useRef(null),m=b.useRef(null),x=b.useId();return b.useLayoutEffect(()=>{if(!c)return;const y=d.current,w=m.current;if(!y||!w)return;const v=window.visualViewport,T=()=>{const L=y.getBoundingClientRect(),N=(v?.offsetLeft??0)+8,D=(v?.offsetTop??0)+8,O=(v?.width??window.innerWidth)-16,P=(v?.offsetTop??0)+(v?.height??window.innerHeight)-8,F=Math.max(0,Math.min(256,O)),ee=Math.max(0,L.top-D-4),Z=Math.max(0,P-L.bottom-4),G=ee>=180||ee>=Z;Object.assign(w.style,{width:`${F}px`,left:`${Math.max(N,Math.min(L.right-F,N+O-F))}px`,top:`${G?L.top-4:L.bottom+4}px`,maxHeight:`${G?ee:Z}px`,transform:G?"translateY(-100%)":"none"})};T();const C=typeof ResizeObserver>"u"?null:new ResizeObserver(T);return C?.observe(y),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),v?.addEventListener("resize",T),v?.addEventListener("scroll",T),()=>{C?.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0),v?.removeEventListener("resize",T),v?.removeEventListener("scroll",T)}},[c]),b.useEffect(()=>{if(!c)return;m.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const y=w=>{w.target instanceof Node&&!d.current?.contains(w.target)&&!m.current?.contains(w.target)&&l(!1)};return document.addEventListener("pointerdown",y),()=>document.removeEventListener("pointerdown",y)},[c]),s.jsxs("div",{ref:d,role:"group","data-sidebar-gesture-ignore":!0,"aria-label":a("sidebar.moreActions"),className:n?"relative z-20 flex shrink-0 items-center":"relative z-20 mt-2 flex items-center justify-between gap-2",onKeyDown:y=>{c&&y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),l(!1),f.current?.focus({preventScroll:!0}))},children:[!n&&s.jsxs("button",{type:"button",onClick:e,title:t?a("sidebar.serverAttention"):void 0,className:"inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(f3,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:a("sidebar.settings")})]}),s.jsxs("button",{ref:f,"data-session-sidebar-header-action":n?"":void 0,title:a("sidebar.moreActions"),"aria-label":a("sidebar.moreActions"),type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?x:void 0,onClick:()=>l(y=>!y),onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),l(!0))},className:`relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-lg text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${n?"h-9 w-9 shrink-0":"min-h-9 px-2"} ${c?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Ro,{size:15}),!n&&s.jsx("span",{children:a("sidebar.moreActions")}),n&&t&&s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 h-1.5 w-1.5 rounded-full bg-destructive"})]}),c&&ci.createPortal(s.jsx("div",{ref:m,id:x,role:"menu","data-sidebar-gesture-ignore":!0,"data-sidebar-composer-popover":"sidebar-launch-options","aria-label":a("sidebar.moreActions"),className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)] animate-fade-in",onKeyDown:y=>{const w=[...y.currentTarget.querySelectorAll('[role="menuitem"]')],v=w.indexOf(document.activeElement);let T;if(y.key==="ArrowDown")T=(v+1)%w.length;else if(y.key==="ArrowUp")T=(v-1+w.length)%w.length;else if(y.key==="Home")T=0;else if(y.key==="End")T=w.length-1;else if(y.key==="Tab"){l(!1);return}else return;y.preventDefault(),w[T]?.focus({preventScroll:!0})},children:r.map(({label:y,icon:w,onSelect:v,separated:T})=>s.jsxs("div",{role:"none",children:[T&&s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/40"}),s.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{l(!1),v()},className:"flex min-h-10 w-full items-center gap-2.5 whitespace-nowrap rounded-lg px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",children:[s.jsx(w,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{children:y})]})]},y))}),document.body)]})}const $m="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-primary/15 hover:text-primary active:scale-95";function QO({label:e,count:t,badge:r,actions:n,pinned:a,onTogglePinned:c,onClose:l,onOpenSettings:d,serverAttention:f}){const{t:m}=Gr(),x=b.useRef(null),y=b.useRef(null),[w,v]=b.useState(!0);return b.useLayoutEffect(()=>{const T=x.current;if(!T)return;const C=()=>{const N=getComputedStyle(T),D=T.clientWidth-parseFloat(N.paddingLeft)-parseFloat(N.paddingRight),O=T.querySelector("button"),P=O?O.getBoundingClientRect().width:36,F=[...y.current?.children??[]],ee=F.reduce((de,pe)=>de+pe.scrollWidth,0)+Math.max(0,F.length-1)*6,Z=n.length+(c?1:0)+(a?0:1),G=ee+Z*P+Math.max(0,Z-1)*4+6;v(D<G+8)};C();const L=typeof ResizeObserver>"u"?null:new ResizeObserver(C);return L?.observe(T),window.addEventListener("resize",C),()=>{L?.disconnect(),window.removeEventListener("resize",C)}}),s.jsxs("div",{ref:x,"data-session-sidebar-header":!0,className:"relative z-20 shrink-0 px-3 py-0.5",children:[s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-3 bottom-0 z-10 h-px bg-border opacity-40"}),s.jsxs("div",{className:"flex min-w-0 w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:s.jsxs("div",{ref:y,className:"flex min-w-0 items-center gap-1.5 whitespace-nowrap",children:[s.jsx("span",{className:"min-w-0 truncate text-[12px] font-medium text-muted-foreground",children:e}),s.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:t}),r&&s.jsx("span",{className:"flex shrink-0 items-center",children:r})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[w?s.jsx(BO,{compact:!0,actions:n,serverAttention:f,onOpenSettings:d}):n.map(({label:T,icon:C,onSelect:L})=>s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",className:$m,"aria-label":T,title:T,onClick:L,children:s.jsx(C,{size:16})},T)),c&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",className:$m,onClick:c,"aria-label":m(a?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:m(a?"sidebar.unpinSidebar":"sidebar.pinSidebar"),"aria-pressed":a,children:a?s.jsx(R0,{size:16}):s.jsx(N0,{size:16})}),!a&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",className:$m,onClick:l,"aria-label":m("common.close"),children:s.jsx(Dn,{size:16})})]})]})]})}const p4="termdock:new-session-agent:v1";function PO(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(p4)||"null");return!e||typeof e.slug!="string"||typeof e.command!="string"?null:{slug:e.slug,command:e.command,displayName:typeof e.displayName=="string"?e.displayName:e.slug,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(t=>typeof t=="string"):void 0,accentColor:typeof e.accentColor=="string"?e.accentColor:"var(--muted-foreground)",icon:typeof e.icon=="string"?e.icon:null,isPlugin:e.isPlugin===!0,iconMode:e.iconMode==="native"?"native":e.iconMode==="mask"?"mask":void 0,iconVersion:typeof e.iconVersion=="number"?e.iconVersion:void 0}}catch{return null}}function Um(e){if(!(typeof window>"u"))try{window.localStorage.setItem(p4,JSON.stringify(e))}catch{}}function OO(e,t){return e?t.find(r=>r.slug===e)??null:null}function FO(){const[e,t]=b.useState(PO),[r,n]=b.useState([]),[a,c]=b.useState(!0),l=b.useCallback(async()=>{c(!0);try{const[f,m]=await Promise.all([Cc(),Ky()]),x=OO(f.newSessionAgentSlug,m);n(m),t(x),Um(x)}finally{c(!1)}},[]);b.useEffect(()=>{const f=()=>{l().catch(()=>{})};if(performance.getEntriesByName("termdock:startup:initial-viewport-presented").length>0){f();return}return window.addEventListener("termdock:initial-viewport-presented",f,{once:!0}),()=>window.removeEventListener("termdock:initial-viewport-presented",f)},[l]);const d=b.useCallback(async f=>{const m=e;t(f),Um(f);try{await Ua({newSessionAgentSlug:f?.slug??null})}catch(x){throw t(m),Um(m),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:l,selectAgent:d}}function $O({groups:e,sessions:t,busy:r,onOpen:n,onSettings:a,onCreate:c}){const[l,d]=b.useState(""),f=e.filter(m=>!l.trim()||`${m.name} ${m.sessionIds.map(x=>t.find(y=>y.sessionId===x)?.name??"").join(" ")}`.toLowerCase().includes(l.trim().toLowerCase()));return s.jsxs("section",{"aria-label":"协作组列表",className:"space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("p",{className:"text-xs leading-6 text-muted-foreground",children:"成员消息用于日常交流;看板用于目标、交付与验收。"}),s.jsxs("button",{type:"button",disabled:r,className:"inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground disabled:opacity-40",onClick:c,children:[s.jsx(Xs,{size:14}),"新建协作组"]})]}),(e.length>5||l)&&s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"搜索协作组"}),s.jsx(Yl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"search",value:l,onChange:m=>d(m.target.value),placeholder:"搜索组名或成员",className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 py-2 pl-9 pr-3 text-xs text-foreground outline-none focus:border-primary/60"})]}),s.jsxs("div",{className:"divide-y divide-border/15 rounded-xl border border-border/15",children:[f.map(m=>{const x=m.sessionIds.flatMap(y=>{const w=t.find(v=>v.sessionId===y);return w?[w]:[]});return s.jsxs("article",{"aria-label":m.name,className:"p-3 sm:flex sm:items-center sm:gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"break-words text-sm font-medium leading-6 text-foreground",children:m.name}),s.jsx("p",{className:"mt-1 break-words text-[11px] leading-5 text-muted-foreground",children:m.sessionIds.length?`${m.sessionIds.length} 位成员${x.length?` · ${x.slice(0,2).map(y=>Hu(y,x)).join("、")}${x.length>2?"等":""}`:""}`:"尚未添加成员,可以稍后配置"})]}),s.jsxs("div",{className:"mt-2 flex shrink-0 items-center gap-1 sm:mt-0",children:[s.jsxs("button",{type:"button","aria-label":`成员消息:${m.name}`,disabled:r,className:"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg bg-surface-2 px-3 text-xs text-foreground hover:bg-surface-elevated disabled:opacity-40",onClick:()=>n(m.id,"messages"),children:[s.jsx(hd,{size:14}),"成员消息"]}),s.jsxs("button",{type:"button","aria-label":`看板:${m.name}`,disabled:r,className:"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg px-3 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",onClick:()=>n(m.id,"tasks"),children:[s.jsx(zT,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-label":`设置:${m.name}`,title:"组设置",disabled:r,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2 disabled:opacity-40",onClick:y=>a(m.id,y.currentTarget),children:s.jsx(Zu,{size:14})})]})]},m.id)}),!f.length&&s.jsx("p",{className:"px-3 py-6 text-xs text-muted-foreground",children:"没有匹配的协作组,试试其他名称。"})]})]})}const Hc="min-h-11 w-full rounded-lg border border-border/20 bg-surface px-3 py-2 text-xs text-foreground outline-none focus:border-primary",Hh="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-xs disabled:opacity-40",Wh=e=>({profiles:e.launchProfiles??[],defaultId:e.defaultLaunchProfileId??"",group:e}),zm=new Map,e0=e=>JSON.stringify(e.profiles)!==JSON.stringify(e.group.launchProfiles??[])||e.defaultId!==(e.group.defaultLaunchProfileId??"");function UO({group:e,value:t,onChange:r,disabled:n}){if(!e.launchProfiles?.length&&!t)return null;const a=e.launchProfiles?.find(c=>c.id===t);return s.jsxs("div",{className:"mt-3 space-y-1",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动方案",s.jsxs("select",{"aria-label":"启动方案",className:Hc,value:t,disabled:n,onChange:c=>r(c.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(c=>s.jsx("option",{value:c.id,children:c.name},c.id))]})]}),a&&s.jsxs("p",{className:"whitespace-pre-wrap break-words text-xs leading-5 text-muted-foreground",children:[a.notes||"未填写使用备注",s.jsx("code",{className:"block break-all",children:a.command})]}),t&&!a&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]})}function zO({group:e,agents:t,busy:r,setBusy:n,refresh:a}){const c=`${window.location.origin}:${e.id}`,[l,d]=b.useState(()=>zm.get(c)??Wh(e)),f=b.useRef(l);f.current=l;const[m,x]=b.useState(l.profiles[0]?.id??""),[y,w]=b.useState(null),[v,T]=b.useState(""),C=(F,ee=!0)=>{f.current=F,d(F),e0(F)?zm.set(c,F):zm.delete(c),ee&&T("")};b.useEffect(()=>{!e0(f.current)&&e.updatedAt>=f.current.group.updatedAt&&C(Wh(e),!1)},[e.updatedAt]);const L=l.profiles.find(F=>F.id===m),N=F=>C({...l,profiles:l.profiles.map(ee=>ee.id===m?{...ee,...F}:ee)}),D=l.profiles.every(F=>F.name.trim()&&F.agentSlug&&F.command.trim()&&!/[\x00-\x1f\x7f]/.test(F.command)),O=()=>{const F=t[0],ee={id:`profile-${crypto.randomUUID()}`,name:"",agentSlug:F?.slug??"",command:F?.command??"",notes:""};C({...l,profiles:[...l.profiles,ee]}),x(ee.id)},P=async()=>{if(!(r||!D||!e0(l))){n("launch-profiles"),w(null),T("");try{const{group:F}=await ql({id:e.id,name:l.group.name,sessionIds:l.group.sessionIds,expectedUpdatedAt:l.group.updatedAt,launchProfiles:l.profiles,defaultLaunchProfileId:l.defaultId||null});C(Wh(F)),T("启动方案已保存。新会话使用所选方案,正在运行的成员保持原配置。"),await a()}catch(F){w(F instanceof Error?F.message:"保存失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-3 border-t border-border/15 pt-2",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:["Agent 启动方案 · ",l.profiles.length," 个",e0(l)?" · 未保存":""]}),s.jsxs("section",{"aria-label":"Agent 启动方案",className:"space-y-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"保存不同模型和参数的启动命令,填写适用场景,让协调者按备注选择。保存配置不会启动 Agent。"}),s.jsxs("fieldset",{disabled:!!r,className:"space-y-3",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["默认启动方案",s.jsxs("select",{"aria-label":"默认启动方案",className:Hc,value:l.defaultId,onChange:F=>C({...l,defaultId:F.target.value}),children:[s.jsx("option",{value:"",children:"使用 Agent 默认命令"}),l.profiles.map(F=>s.jsx("option",{value:F.id,children:F.name||"未命名方案"},F.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:["编辑方案",s.jsxs("select",{"aria-label":"编辑方案",className:`${Hc} mt-1`,value:m,onChange:F=>x(F.target.value),children:[s.jsx("option",{value:"",children:"选择方案"}),l.profiles.map(F=>s.jsx("option",{value:F.id,children:F.name||"未命名方案"},F.id))]})]}),s.jsxs("button",{type:"button",className:`${Hh} self-end bg-surface text-foreground`,disabled:l.profiles.length>=20,onClick:O,children:[s.jsx(Xs,{size:14}),"新增方案"]})]}),L?s.jsxs("div",{className:"space-y-3 rounded-lg border border-border/20 p-3",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["方案名称",s.jsx("input",{className:Hc,value:L.name,maxLength:100,onChange:F=>N({name:F.target.value}),placeholder:"例如:快速排查、深度实现"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["Agent 类型",s.jsxs("select",{"aria-label":"Agent 类型",className:Hc,value:L.agentSlug,onChange:F=>N({agentSlug:F.target.value,command:t.find(ee=>ee.slug===F.target.value)?.command??""}),children:[!t.some(F=>F.slug===L.agentSlug)&&s.jsxs("option",{value:L.agentSlug,children:[L.agentSlug||"选择 Agent","(当前不可用)"]}),t.map(F=>s.jsx("option",{value:F.slug,children:F.displayName},F.slug))]})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动命令",s.jsx("input",{className:`${Hc} font-mono`,value:L.command,maxLength:4096,onChange:F=>N({command:F.target.value}),placeholder:"填写完整命令,包括模型和启动参数"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["使用备注",s.jsx("textarea",{"aria-label":"使用备注",className:`${Hc} min-h-24 resize-y`,value:L.notes,maxLength:2e3,onChange:F=>N({notes:F.target.value}),placeholder:"适合哪些任务、何时不要使用;协调者会读取这些备注。"})]}),s.jsxs("details",{className:"text-[11px] text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3",children:"CLI 方案标识"}),s.jsx("code",{className:"break-all",children:L.id})]}),s.jsxs("button",{type:"button",className:`${Hh} text-destructive hover:bg-destructive/10`,onClick:()=>{const F=l.profiles.filter(ee=>ee.id!==m);C({...l,profiles:F,defaultId:l.defaultId===m?"":l.defaultId}),x(F[0]?.id??"")},children:[s.jsx(zs,{size:14}),"移除方案(保存后生效)"]})]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:"尚未选择方案。新增后可填写模型、参数和备注。"})]}),y&&s.jsxs("p",{role:"alert",className:"text-xs leading-5 text-destructive",children:[y,"。草稿已保留;重新载入会放弃草稿。"]}),v&&s.jsx("p",{role:"status",className:"text-xs leading-5 text-primary",children:v}),s.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[s.jsx("button",{type:"button",className:`${Hh} bg-surface text-muted-foreground`,disabled:!!r,onClick:()=>{C(Wh(e)),x(e.launchProfiles?.[0]?.id??""),w(null)},children:"重新载入(放弃方案草稿)"}),s.jsx("button",{type:"button",disabled:!!r||!D||!e0(l),className:`${Hh} bg-primary text-primary-foreground`,onClick:()=>{P()},children:r==="launch-profiles"?"保存中…":"保存启动方案"})]})]})]})}function m4(e,t=[]){const r=(t.length?t:e.children??[]).filter(C=>C.status!=="closed"),n=r.filter(C=>C.status==="accepted").length,a=cu(e),c=e.events.filter(C=>C.kind==="revise"&&C.attemptId===e.activeAttemptId).at(-1),l=e.artifacts.filter(C=>C.kind==="result"&&C.attemptId===e.activeAttemptId).at(-1),d=!!c&&(!l||c.createdAt>=l.createdAt),f=Zf(e),m=e.attempts.find(C=>C.id===e.activeAttemptId)?.report,x=C=>C?.summarySource==="explicit"||C?.summarySource!=="excerpt"&&!!C?.summary?.trim(),y=e.events.filter(C=>C.kind==="coordinate"&&C.attemptId===e.activeAttemptId&&(!c||C.sequence>c.sequence)).at(-1),w=[...f?.createdAt&&(!c||f.createdAt>c.createdAt)?[{summary:f.summary,createdAt:f.createdAt,source:"成员报告",explicit:x(m),taskId:e.id,title:e.title}]:[],...y?[{summary:y.summary||y.content,createdAt:y.createdAt,source:"协调说明",explicit:!!y.summary?.trim(),taskId:e.id,title:e.title}]:[],...d?[]:t.filter(C=>C.status!=="closed").flatMap(C=>{const L=Zf(C);return L?.createdAt?[{summary:L.summary,createdAt:L.createdAt,source:"执行报告",explicit:x(C.attempts.find(N=>N.id===C.activeAttemptId)?.report),taskId:C.id,title:C.title}]:[]})].filter(C=>C.summary.trim()&&Number.isFinite(C.createdAt)&&Number.isFinite(new Date(C.createdAt).getTime())).sort((C,L)=>L.createdAt-C.createdAt);let v=a,T="分派和报告会保存在这里;终端输出不能代替明确的任务报告。";return e.workflow?.kind==="goal"&&(e.status==="accepted"?(v="已完成 · 你已验收",T="结果与执行记录已保留;追加要求可以继续跟进。"):e.status==="closed"?T="此目标已关闭,已有报告仍保留。":sa(e)||e.workflow.paused||l?T=a==="等待你验收"?"总结果已交付;查看结论后验收,或提出继续跟进。":a==="等待独立评审"?"总结果已提交,独立评审通过后交给你验收。":a==="需要你回答"?"回答当前问题后,成员可以继续原来的工作。":a==="需要你确认方案"?"确认这项必要决定后再继续;普通拆分不需要逐项批准。":d?"沿用原目标推进追加要求;上一版结果不代表本轮完成。":e.workflow.paused?"自动安排已暂停,恢复后才能继续安排后续工作。":"查看记录的阻塞原因,补充条件或重试;已有交付保留。":d?(v="已提出跟进 · 等待新报告",T="沿用原目标推进追加要求;旧报告保留为历史,等待本轮明确更新。"):r.length?(v=n===r.length?"执行交付已评审 · 等待总结果":"工作已拆分 · 执行与评审",T=n===r.length?"执行事项已交付评审,下一步由协调者汇总总结果,再交给你验收。":`已记录 ${r.length} 项工作,${n} 项交付已评审,${r.length-n} 项尚待交付或评审。`):f?(v=f.status==="ack"?"协调者已接手 · 等待拆分记录":a,T="尚未记录执行事项;协调者需说明工作划分、交付内容和下一步。"):T=a==="已写入终端 · 等待回复"?"目标已写入协调者终端,等待明确接手和拆分说明。":"目标已保存,等待分派、投递和协调者明确回复。"),{label:v,next:T,latest:w[0]??null,total:r.length,done:n}}function HO(e,t){const r=e.dependsOn.filter(n=>t.find(a=>a.id===n)?.status!=="accepted");return r.length?`等待依赖:${r.map(n=>t.find(a=>a.id===n)?.title??"记录尚未同步").join("、")}`:e.dependsOn.length?"依赖交付已评审,可以接续":""}function g4(e){return e.explicit?e.summary:e.source==="协调说明"?"协调者已更新工作安排。此记录未提供简短摘要,详情保留原始说明。":`「${e.title}」有新的明确报告。此记录未提供简短摘要,详情保留原文。`}function Vb(e,t=!1,r=""){e=e.filter(d=>d.purpose!=="automation");const n=new Map(e.map(d=>[d.id,d])),a=d=>n.get(d.parentTaskId??d.workflow?.rootTaskId??""),c=d=>{const f=[];let m=d;for(;;){const x=f.findIndex(w=>w.id===m.id);if(x!==-1)return f.slice(x).sort((w,v)=>w.id.localeCompare(v.id))[0];f.push(m);const y=a(m);if(!y||y.status==="closed"&&m.status!=="closed")return m;m=y}},l=new Map(e.map(d=>[d.id,c(d).id]));return e.filter(d=>t||!!r.trim()||l.get(d.id)===d.id).map(d=>{const f=t||r.trim()?[]:e.filter(y=>y.id!==d.id&&l.get(y.id)===d.id&&y.status!=="closed"),m=d.status==="open"&&!sa(d)?f.find(y=>y.decisions.some(w=>w.status==="pending"))??f.find(y=>sa(y)||y.workflow?.paused):void 0,x=f.filter(y=>sa(y)||y.workflow?.paused).length;return{task:d,children:f,attention:m,attentionCount:x,rootId:l.get(d.id)}})}function K1(e,t=[]){const r=cu(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!sa(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function x4({task:e,children:t,onSelect:r,detail:n=!1,tasks:a=t,name:c}){const l=new Map(t.map(w=>[w.id,w])),d=(t.length?t:e.children??[]).filter(w=>w.status!=="closed");if(!d.length)return null;const f=(w,v)=>{const T=l.get(w);return T&&(sa(T)||T.workflow?.paused)?0:v?2:1},m=[...d].sort((w,v)=>f(w.id,w.status==="accepted")-f(v.id,v.status==="accepted")||(l.get(v.id)?.updatedAt??0)-(l.get(w.id)?.updatedAt??0)),x=d.filter(w=>w.status==="accepted").length,y=w=>{const v=l.get(w.id),T=w.status==="accepted",C=v&&(sa(v)||v.workflow?.paused),L=v?.status==="open"?HO(v,a):"",N=v?.attempts.find(P=>P.id===v.activeAttemptId)?.assignee??v?.scheduledAssignee??null,D=v?K1(v):T?w.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",O=T?L0:V0;return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-2 rounded-lg px-1 py-2 text-left hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(w.id),children:[s.jsx(O,{size:14,className:`mt-0.5 shrink-0 ${T||C?"text-primary":"text-muted-foreground"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{title:w.title,className:"line-clamp-2 break-words text-xs leading-5 text-foreground",children:w.title}),s.jsx("span",{className:`block text-[11px] leading-5 ${C?"text-primary":"text-muted-foreground"}`,children:D}),n&&v?.parentTaskId&&v.parentTaskId!==e.id&&s.jsxs("span",{className:"block text-[11px] leading-5 text-muted-foreground",children:["所属事项:",a.find(P=>P.id===v.parentTaskId)?.title??"父任务记录尚未同步"]}),n&&v?.acceptance&&s.jsxs("span",{className:"mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground",children:["交付标准:",v.acceptance]}),L&&s.jsx("span",{className:"line-clamp-2 text-[11px] leading-5 text-muted-foreground",children:L}),n&&c&&s.jsxs("span",{className:"block text-[11px] leading-5 text-muted-foreground",children:["负责人:",N?c(v,N):"尚未分派"]})]}),s.jsx(Ks,{size:12,className:"mt-1 shrink-0 text-muted-foreground"})]},w.id)};return s.jsxs("section",{"aria-label":"执行事项",className:n?"border-t border-border/15 py-2":"mx-4 border-t border-border/15 py-2",children:[!n&&s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"执行事项"}),s.jsxs("span",{children:[x,"/",d.length," 项已完成"]})]}),(n?m.filter(w=>x===d.length||w.status!=="accepted"):m.slice(0,3)).map(y),n&&x>0&&x<d.length&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["查看 ",x," 项已完成的执行交付"]}),m.filter(w=>w.status==="accepted").map(y)]}),!n&&m.length>3&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[11px] text-muted-foreground",children:["展开其余 ",m.length-3," 项"]}),m.slice(3).map(y)]})]})}function WO(e,t){const r=t.events.filter(f=>f.kind==="retry"&&!e.events.some(m=>m.id===f.id)).at(-1),n=new Set(e.deliveries.filter(f=>f.status==="delivered").map(f=>f.id)),a=new Set(e.outbox.filter(f=>!n.has(f.id)).map(f=>f.id)),c=r&&t.deliveries.some(f=>a.has(f.id)&&f.status==="delivered"&&f.deliveredAt!==null&&f.deliveredAt>=r.createdAt);let l=c?"重试请求已保存,匹配本次请求的投递已写入终端。":"重试请求已保存,服务将重新检查现有投递与协调条件。";!t.outbox.length&&!c&&(l+=" 当前没有待重试的投递记录。"),t.workflow?.paused&&(l+=" 后续自动安排仍已暂停。");const d=t.attempts.find(f=>f.id===t.activeAttemptId)?.report;return d&&["blocked","failed"].includes(d.status)&&(l+=" 成员原报告仍保留;请补齐条件并通知成员,收到新的明确回复后更新报告。"),l}function GO(e,t){const r=Math.floor(Math.max(0,t-e)/6e4);return r<1?"刚刚更新":r<60?`${r} 分钟前更新`:r<1440?`${Math.floor(r/60)} 小时前更新`:r<10080?`${Math.floor(r/1440)} 天前更新`:`${new Date(e).toLocaleDateString([],{month:"numeric",day:"numeric"})} 更新`}function qb(e){return new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function ep({task:e,now:t,compact:r=!1}){const n=Zf(e),a=Number.isFinite(e.updatedAt)&&e.updatedAt>0&&Number.isFinite(new Date(e.updatedAt).getTime());return r&&!n?null:s.jsxs("span",{className:"mt-1 block space-y-1 text-[11px] leading-5 text-muted-foreground",children:[s.jsx("span",{className:"block break-words",children:n?s.jsxs(s.Fragment,{children:["最近明确报告:",n.label," · ",n.createdAt===null?"报告时间未提供":s.jsx("time",{dateTime:new Date(n.createdAt).toISOString(),title:new Date(n.createdAt).toLocaleString(),children:qb(n.createdAt)})]}):"暂无明确报告"}),!r&&s.jsx("span",{className:"block",children:a?s.jsxs(s.Fragment,{children:["记录更新:",s.jsx("time",{dateTime:new Date(e.updatedAt).toISOString(),title:t===void 0?new Date(e.updatedAt).toLocaleString():GO(e.updatedAt,t),children:qb(e.updatedAt)})]}):"记录更新时间未提供"})]})}function b4(e,t){const r=e.trim().split(/\n\s*\n/),n=l=>{const d=r.findIndex(m=>l.test(m.trim()));return d<0?"":r[d].trim().replace(l,"").trim()||r[d+1]?.trim()||""},a=t?.trim()||n(/^(?:#{1,6}\s*)?(?:结论|Summary|Conclusion|结果摘要)(?:[::]\s*|\s*$)/i),c=n(/^(?:#{1,6}\s*)?(?:限制与变更|限制|Limitations)(?:[::]\s*|\s*$)/i);return{summary:a||e.trim(),limitations:a?c:"",condensed:!!a&&a!==e.trim(),explicit:!!t?.trim()}}function bf({inputKey:e,paneKey:t,label:r,value:n,onChange:a,active:c=!0,disabled:l=!1,required:d,autoFocus:f,placeholder:m,className:x,onUploadChange:y}){const w=b.useId(),v=b.useRef(null),T=b.useRef(null),C=b.useRef({value:n,onChange:a,onUploadChange:y});C.current={value:n,onChange:a,onUploadChange:y};const[L,N]=b.useState(0),[D,O]=b.useState(""),P=b.useRef(Promise.resolve());b.useEffect(()=>{const J=v.current;J&&J.setSelectionRange(J.value.length,J.value.length)},[e]);const F=()=>({value:C.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),ee=(J,Re=F())=>{C.current.onChange(Ze=>Ze!==Re.value?Ze+(Ze&&!/\s$/.test(Ze)?`
138
+ `:"")+J:Ze.slice(0,Re.start)+J+Ze.slice(Re.end))};b.useEffect(()=>{if(!c)return;const J=Xy(Re=>ee(Re.replace(/\r\n?/g,`
139
+ `)),e,!!t,t);return t||b0(e),J},[c,e,t]);const Z=()=>{const J=Gc();return`${location.origin}:${J?.targetPeerId??""}:${J?.serviceOrigin??""}`},G=J=>{const Re=F(),Ze=Z(),V=C.current.onUploadChange;O(""),N(ve=>ve+1),V?.(1),P.current=P.current.then(async()=>{try{if(Ze!==Z())throw new Error("目标服务已切换,请重新添加附件");const ve=await J();if(Ze!==Z())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(ve)?ee(ve.map(Uu).join(" ")+" ",Re):ve&&ee(ve,Re)}catch(ve){const qe=ve instanceof Error?ve.message:"附件准备失败,请重试";O(qe.includes("Upload did not return")?"附件上传未返回完整路径,请重试":qe)}finally{N(ve=>ve-1),V?.(-1)}})},de=async J=>J.length===1&&J[0].type.startsWith("image/")?[await N3(J[0])]:j3(J),pe=J=>{const Re=J.clipboardData.files.length?Array.from(J.clipboardData.files):Array.from(J.clipboardData.items??[]).filter(ve=>ve.kind==="file").map(ve=>ve.getAsFile()).filter(ve=>ve!==null),Ze=J.clipboardData.getData("text/plain"),V=na();!V?.readClipboardFiles&&!Re.length&&Ze||!V&&!Re.length&&typeof navigator.clipboard?.read!="function"||(J.preventDefault(),G(async()=>{const ve=Z();let qe;if(V?.readClipboardFiles)try{const le=await M3();if(le.paths.length||le.files.length)return[...le.paths,...await de(le.files)]}catch(le){if(le instanceof w0)throw le;qe=le}if(ve!==Z())throw new Error("目标服务已切换,请重新粘贴");if(Re.length)return de(Re);if(Ze)return Ze;if(typeof navigator.clipboard?.read=="function"){const le=await navigator.clipboard.read(),ye={read:async()=>le},Te=await R3(ye);if(Te.length)return de(Te);const Fe=await Nf(ye);if(Fe)return de([Fe]);for(const se of le)if(se.types.includes("text/plain"))return(await se.getType("text/plain")).text()}else{const le=await Nf();if(le)return de([le])}if(qe)throw qe;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>b0(e),onPointerDownCapture:()=>b0(e),children:[s.jsx("label",{htmlFor:w,className:"block text-xs text-muted-foreground",children:r}),s.jsx("textarea",{ref:v,id:w,value:n,required:d,disabled:l,autoFocus:f,"aria-describedby":L||D?`${w}-status`:void 0,placeholder:m,className:x,onChange:J=>a(J.target.value),onPaste:pe,onDragOver:J=>{!l&&J.dataTransfer.types.includes("Files")&&J.preventDefault()},onDrop:J=>{const Re=Array.from(J.dataTransfer.files);!Re.length||l||(J.preventDefault(),J.stopPropagation(),G(()=>de(Re)))}}),s.jsxs("div",{className:"flex min-h-9 items-center gap-2",children:[s.jsx("input",{ref:T,type:"file",multiple:!0,hidden:!0,"aria-label":`选择附件:${r}`,onChange:J=>{const Re=Array.from(J.target.files??[]);J.target.value="",Re.length&&G(()=>de(Re))}}),s.jsxs("button",{type:"button","aria-label":`添加附件:${r}`,title:"添加附件",disabled:l,className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>T.current?.click(),children:[s.jsx(fS,{size:14}),"附件"]}),L>0?s.jsxs("span",{id:`${w}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(An,{size:12,className:"animate-spin"}),"正在准备附件…"]}):D?s.jsx("span",{id:`${w}-status`,role:"alert",className:"break-words text-xs text-destructive",children:D}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function Yb(e){return e.status!=="open"?"done":sa(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Ol=[{id:"backlog",label:"待开始",icon:V0,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:_f,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:hd,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:L0,hint:"验收后的结果会保留在这里"}];function VO({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:c,navigation:l,settings:d}){const f=b.useRef(null),m=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),w=b.useRef(null),[v,T]=b.useState(Date.now);b.useEffect(()=>ou(()=>T(Date.now()),3e4),[]);const[C,L]=b.useState(!1);b.useEffect(()=>{const z=new ResizeObserver(ie=>{const ge=ie[0].contentRect.width;L(ge>=760),ge!==y.current&&ge<760&&m.current&&(m.current.scrollLeft=Ol.findIndex(We=>We.id===x.current)*m.current.clientWidth),y.current=ge});return f.current&&z.observe(f.current),()=>z.disconnect()},[]);const[N]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[D,O]=b.useState(()=>{if(Ol.some(ge=>ge.id===N?.lane))return N.lane;const ie=Vb(e,N?.showSteps===!0,N?.query??"").map(ge=>ge.attention?"attention":Yb(ge.task));return ie.includes("attention")?"attention":ie.includes("running")?"running":ie.includes("backlog")?"backlog":"done"});x.current=D;function P(z,ie=!0){O(z);const ge=m.current;if(!ge||!ge.clientWidth)return;w.current=z;const We=Ol.findIndex(wt=>wt.id===z)*ge.clientWidth,tt=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;ge.scrollTo?ge.scrollTo({left:We,behavior:ie&&!tt?"smooth":"auto"}):ge.scrollLeft=We}b.useEffect(()=>{C||P(x.current,!1)},[C]);const[F,ee]=b.useState(typeof N?.scope=="string"?N.scope:"all"),[Z,G]=b.useState(typeof N?.query=="string"?N.query:""),[de,pe]=b.useState(N?.closed===!0),[J,Re]=b.useState(N?.showSteps===!0),[Ze,V]=b.useState(!!N?.query),[ve,qe]=b.useState(!1),[le,ye]=b.useState(!1),Te=b.useRef(null),Fe=b.useRef(null);b.useEffect(()=>{if(!le)return;Te.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const z=ge=>{Te.current?.contains(ge.target)||ye(!1)},ie=ge=>{ge.key==="Escape"&&(ge.preventDefault(),ge.stopPropagation(),ye(!1),Fe.current?.focus())};return document.addEventListener("pointerdown",z),document.addEventListener("keydown",ie),()=>{document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",ie)}},[le]);const se=b.useRef(null),De=b.useRef(null),_e=b.useRef(null),Me=b.useRef(null);b.useEffect(()=>{Ze&&se.current?.focus()},[Ze]),b.useEffect(()=>{if(!ve)return;_e.current?.querySelector("select")?.focus();const z=ge=>{_e.current?.contains(ge.target)||qe(!1)},ie=ge=>{ge.key==="Escape"&&(ge.preventDefault(),ge.stopPropagation(),qe(!1),(C?Me:Fe).current?.focus())};return document.addEventListener("pointerdown",z),document.addEventListener("keydown",ie),()=>{document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",ie)}},[ve]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:D,scope:F,query:Z,closed:de,showSteps:J}))}catch{}},[a,D,F,Z,de,J]);const Ke=e.filter(z=>z.workflow?.kind==="goal"),Ne=Vb(e,J,Z),ae=new Map(Ne.map(z=>[z.task.id,z])),ze=z=>ae.get(z.id)?.attention?"attention":Yb(z),at=t?Ne.find(z=>z.task.id===t||z.children.some(ie=>ie.id===t)):void 0,ct=at?ze(at.task):void 0;b.useEffect(()=>{ct&&P(ct,!1)},[t,ct]);const me=Ne.map(z=>z.task).filter(z=>(de||z.status!=="closed")&&(F==="all"||z.id===F||ae.get(z.id)?.rootId===F)&&(!Z.trim()||`${z.title} ${z.spec} ${z.attempts.map(ie=>n(z,ie.assignee)).join(" ")}`.toLocaleLowerCase().includes(Z.trim().toLocaleLowerCase()))),ut=+(F!=="all")+Number(de)+Number(J),ft="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Se="flex min-h-11 w-full items-center justify-start gap-3 rounded-lg px-3 text-left text-sm font-medium text-foreground hover:bg-surface-2 active:bg-surface-elevated focus-visible:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",He=s.jsxs("div",{className:`relative flex min-w-0 items-center ${C?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(Yl,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:se,"aria-label":"搜索任务",type:"search",value:Z,onChange:z=>G(z.target.value),onKeyDown:z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),Z?G(""):(V(!1),requestAnimationFrame(()=>(C?De:Fe).current?.focus())))},placeholder:"搜索任务或负责人",className:"min-h-11 w-full rounded-lg border border-border/20 bg-transparent pl-9 pr-9 text-xs outline-none focus:border-primary"}),s.jsx("button",{type:"button","aria-label":"关闭搜索",className:"absolute right-0 flex min-h-11 w-9 items-center justify-center text-muted-foreground",onClick:()=>{G(""),V(!1),requestAnimationFrame(()=>(C?De:Fe).current?.focus())},children:s.jsx(Dn,{size:14})})]}),ke=s.jsxs("div",{"aria-label":"任务筛选",className:"absolute right-0 top-full z-30 mt-1 w-64 space-y-3 rounded-xl border border-border/30 bg-surface p-3 shadow-xl",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"目标范围"}),s.jsxs("select",{"aria-label":"按目标查看",value:F,onChange:z=>ee(z.target.value),className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 px-3 text-xs text-foreground",children:[s.jsx("option",{value:"all",children:"所有目标"}),Ke.map(z=>s.jsx("option",{value:z.id,children:z.title},z.id))]})]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:de,onChange:z=>pe(z.target.checked)}),"含已关闭"]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:J,onChange:z=>Re(z.target.checked)}),"显示执行子任务"]}),ut>0&&s.jsx("button",{type:"button",className:"min-h-11 w-full rounded-lg text-xs text-primary hover:bg-surface-2",onClick:()=>{ee("all"),pe(!1),Re(!1)},children:"清除筛选"})]});return s.jsxs("div",{ref:f,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:C?void 0:_e,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:C?s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:l}),Ze?He:s.jsx("button",{ref:De,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${ft} ${l?"":"ml-auto"}`,onClick:()=>V(!0),children:s.jsx(Yl,{size:16})}),s.jsxs("div",{ref:_e,className:"relative shrink-0",children:[s.jsxs("button",{ref:Me,type:"button","aria-label":ut?`筛选任务,${ut} 项已启用`:"筛选任务","aria-expanded":ve,className:`${ft} ${ut?"text-primary":""}`,onClick:()=>qe(z=>!z),children:[s.jsx(o1,{size:15}),s.jsx("span",{children:"筛选"}),ut>0&&s.jsx("span",{className:"tabular-nums text-primary",children:ut})]}),ve&&ke]}),d,c&&s.jsx("div",{className:"shrink-0",children:c})]}):s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"mr-auto flex min-w-0 items-center",children:l}),c&&s.jsx("div",{className:"shrink-0",children:c}),s.jsxs("div",{ref:Te,className:"relative shrink-0",children:[s.jsxs("button",{ref:Fe,type:"button","aria-label":"更多看板操作","aria-expanded":le,className:`${ft} ${le?"bg-surface-2 text-foreground":ut||Z.trim()?"text-primary":""}`,onClick:()=>{ye(z=>!z),qe(!1)},children:[s.jsx(Ro,{size:18}),ut>0&&s.jsx("span",{className:"text-[10px]",children:ut})]}),le&&s.jsxs("div",{role:"group","aria-label":"看板更多操作",className:"absolute right-0 top-full z-30 mt-2 flex w-52 max-w-[calc(100vw-2rem)] flex-col gap-0.5 rounded-xl border border-border/40 bg-surface p-1.5 shadow-xl",onClick:()=>ye(!1),children:[s.jsxs("button",{ref:De,type:"button","aria-label":"搜索任务",className:Se,onClick:()=>V(!0),children:[s.jsx(Yl,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Me,type:"button","aria-label":ut?`筛选任务,${ut} 项已启用`:"筛选任务",className:Se,onClick:()=>qe(!0),children:[s.jsx(o1,{size:18,className:"shrink-0 text-muted-foreground"}),"筛选任务",ut>0&&s.jsx("span",{className:"ml-auto rounded bg-primary/10 px-1.5 text-xs tabular-nums text-primary",children:ut})]}),d&&s.jsx("div",{className:"mt-1 border-t border-border/30 pt-1 [&>button]:min-h-11 [&>button]:w-full [&>button]:justify-start [&>button]:gap-3 [&>button]:px-3 [&>button]:text-left [&>button]:text-sm [&>button]:text-foreground [&>button:hover]:bg-surface-2 [&>button:active]:bg-surface-elevated [&>button:focus-visible]:bg-surface-2 [&>button>svg]:h-[18px] [&>button>svg]:w-[18px] [&>button>svg]:shrink-0 [&>button>svg]:text-muted-foreground [&>button>span]:not-sr-only",children:d})]})]}),Ze&&He,ve&&ke]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:J?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),s.jsx("nav",{hidden:C,"aria-label":"看板阶段",className:`${C?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:Ol.map(z=>s.jsxs("button",{type:"button","aria-pressed":D===z.id,className:`min-h-11 rounded-lg px-1 text-xs ${D===z.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>P(z.id),children:[z.label,s.jsx("span",{className:"ml-1 tabular-nums",children:me.filter(ie=>ze(ie)===z.id).length})]},z.id))}),s.jsxs("div",{ref:C?void 0:m,"data-kanban-scroll":!0,onPointerDown:()=>{w.current=null},onWheel:()=>{w.current=null},"aria-label":C?void 0:"可左右滑动的任务看板",onScroll:C?void 0:z=>{if(z.target!==z.currentTarget||!z.currentTarget.clientWidth)return;const ie=w.current;if(ie){const We=Ol.findIndex(tt=>tt.id===ie)*z.currentTarget.clientWidth;if(Math.abs(z.currentTarget.scrollLeft-We)>2)return;w.current=null}const ge=Math.max(0,Math.min(Ol.length-1,Math.round(z.currentTarget.scrollLeft/z.currentTarget.clientWidth)));O(Ol[ge].id)},className:C?"min-h-0 flex-1 overflow-auto pb-3":"min-h-0 flex-1 snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[C&&s.jsx("div",{"aria-label":"看板列标题",className:"sticky top-0 z-10 grid min-w-[1000px] grid-cols-4 gap-4 border-b border-border/15 bg-[var(--chrome-bg)] pb-2",children:Ol.map(z=>{const ie=z.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${z.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(ie,{size:15}),z.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:me.filter(ge=>ze(ge)===z.id).length})]},z.id)})}),s.jsx("div",{className:C?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:Ol.map(z=>{const ie=me.filter(ge=>ze(ge)===z.id).sort((ge,We)=>We.updatedAt-ge.updatedAt);return s.jsx("section",{"aria-label":`${z.label}任务`,"aria-hidden":!C&&D!==z.id?!0:void 0,ref:ge=>{ge&&(ge.inert=!C&&D!==z.id)},style:C?void 0:{width:"100%"},className:C?"min-w-0 px-1":"h-full min-w-0 shrink-0 snap-start snap-always overflow-y-auto overscroll-y-contain px-1 pb-3 pt-2",children:s.jsxs("div",{className:"space-y-2",children:[ie.map(ge=>{const We=ae.get(ge.id),tt=We.attention??ge,wt=tt.attempts.find($e=>$e.id===tt.activeAttemptId),Zt=tt.decisions.find($e=>$e.status==="pending"),Ut=cu(tt),Mt=m4(ge,We.children),nr=We.attention?K1(tt):ge.workflow?.kind==="goal"?Mt.label:K1(tt,We.children),jt=bp(tt),Xt=jt[0],Bt=jt.find($e=>$e.source==="system"),Ht=jt.find($e=>$e.source==="unknown"),xe=Bt?.content,Je=z.id==="attention",ot=Zt?"回答问题":Ht?"查看详情核对记录":Xt?.source==="member"&&Bt?"查看条件与异常处理":Xt?.source==="member"?"查看阻塞并补充条件":xe?"查看原因与处理":Ut==="等待你验收"?"查看结果并验收":Ut==="需要你确认方案"?"查看并确认方案":"查看任务并处理",Nt=tt.artifacts.filter($e=>$e.kind==="result"&&$e.attemptId===tt.activeAttemptId).at(-1),K=tt.events.filter($e=>$e.kind==="revise"&&$e.source==="user"&&$e.attemptId===tt.activeAttemptId&&(!Nt||$e.createdAt>=Nt.createdAt)).at(-1),xt=Zt?Zt.question||"成员提出了一个问题,打开后可查看并回答。":Xt?.summary||K?.content||(ge.workflow?.kind==="goal"&&!We.attention&&Mt.latest?Nt?.summary||g4(Mt.latest):Nt?.summary||(wt?.report?.content?b4(wt.report.content).summary:wt?.report?.summary||"")),tr=e.find($e=>$e.id===ge.parentTaskId);return s.jsxs("article",{"aria-label":ge.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===ge.id?"border-primary/60":xe?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":ge.id,"aria-pressed":t===ge.id,className:"block w-full rounded-xl p-4 text-left transition hover:bg-surface-2/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(tt.id),children:[tr&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:tr.title}),s.jsx("span",{title:ge.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:ge.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${xe&&Xt?.source!=="member"?"text-destructive":Je?"text-primary":"text-muted-foreground"}`,children:[xe&&Xt?.source!=="member"&&s.jsx(ig,{size:13,className:"shrink-0"}),nr]}),We.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",We.attention.title]}),We.attention&&We.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",We.attentionCount," 项执行需要你处理"]}),ge.workflow?.kind==="goal"&&!We.attention&&s.jsx("span",{className:"mt-2 block text-xs leading-5 text-muted-foreground",children:Mt.next}),xt&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:xt}),Bt&&Xt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Bt.label,":",Bt.summary]}),Ht&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[Ht.label,":",Ht.summary]}),Je&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${xe?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[ot,s.jsx(rf,{size:14})]}),!Je&&(ge.status==="accepted"||ge.artifacts.some($e=>$e.kind==="result"&&$e.attemptId===ge.activeAttemptId))&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:[K?"查看跟进":"查看结果",s.jsx(rf,{size:14})]}),!Je&&ge.workflow?.kind==="goal"&&!Nt&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:["查看拆分与进展",s.jsx(rf,{size:14})]})]}),s.jsx(x4,{task:ge,children:We.children,onSelect:r}),s.jsxs("div",{className:"mx-4 border-t border-border/10 py-3 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"block truncate",children:[We.attention?"待处理任务负责人:":ge.workflow?.kind==="goal"?"协调者:":"负责人:",wt?n(tt,wt.assignee):tt.scheduledAssignee?n(tt,tt.scheduledAssignee):"未分派"]}),ge.workflow?.kind==="goal"&&!Je&&!We.attention&&Mt.latest?s.jsxs("time",{className:"mt-1 block text-[11px]",dateTime:new Date(Mt.latest.createdAt).toISOString(),children:[Mt.latest.source," · ",new Date(Mt.latest.createdAt).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]}):s.jsx(ep,{task:tt,now:v,compact:!0})]})]},ge.id)}),!ie.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Z||F!=="all"?"没有匹配的任务":e.length?"暂无任务":z.hint})]})},z.id)})})]})]})}const Vl=Sc((e,t)=>({views:{},details:{},ensureDetail:(r,n)=>{const a=t().details[r];return a||(e(c=>({details:{...c.details,[r]:n}})),n)},updateDetail:(r,n,a)=>e(c=>{const l=c.details[r];if(!l)return c;const d=typeof a=="function"?a(l[n]):a;return Object.is(l[n],d)?c:{details:{...c.details,[r]:{...l,[n]:d}}}}),ensure:(r,n)=>{const a=t().views[r];return a||(e(c=>({views:{...c.views,[r]:n}})),n)},update:(r,n,a)=>e(c=>{const l=c.views[r];if(!l)return c;const d=typeof a=="function"?a(l[n]):a;return Object.is(l[n],d)?c:{views:{...c.views,[r]:{...l,[n]:d}}}})}));function Gh(e,t){return r=>Vl.getState().update(e,t,r)}function Hm(e,t){return r=>Vl.getState().updateDetail(e,t,r)}const qO=b.lazy(()=>Yc(()=>Promise.resolve().then(()=>jO),void 0).then(e=>({default:e.DirectoryPickerDialog}))),YO=b.lazy(()=>Yc(()=>import("./CollaborationTaskContent-BA3bVNJo.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),Ta="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-[13px] transition disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Us="w-full min-h-11 rounded-lg border border-border/30 bg-surface-2 px-3 py-2 text-sm text-foreground outline-none focus:border-primary",Tl=`${Ta} bg-primary text-primary-foreground`,oi=`${Ta} bg-surface-2 text-foreground hover:bg-surface-2/80`,ZO={created:"创建任务",assigned:"分派",report:"成员报告",respond:"答复",question:"提出问题",answer:"回答问题","submit-plan":"提交方案",review:"提交评审","request-review":"请求独立评审","approve-plan":"用户确认方案",accepted:"用户验收",revise:"要求修改",comment:"补充说明",coordinator:"协调者变更",close:"关闭",reopen:"重新打开",scheduled:"等待自动分派",coordinate:"协调说明","child-update":"子任务更新","review-passed":"独立评审通过","review-blocked":"评审受阻","automation-blocked":"自动安排受阻",pause:"暂停安排",resume:"继续安排",retry:"请求重新检查"},td=e=>`${e.serviceId}:${e.sessionId}`,ya=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function _o(e,t){try{const r=JSON.parse(localStorage.getItem(e)??"null");return r===null||t!==null&&(typeof r!=typeof t||Array.isArray(r)!==Array.isArray(t))?t:r}catch{return t}}function ta(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const m0={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]},Zb="__new_coordinator__";function KO(e){const t={...m0,..._o(e,m0)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(m0).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?m0:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function y4(e,t){const r=e.workflow?.rootTaskId?t.find(c=>c.id===e.workflow?.rootTaskId):null;if(r?.workflow?.paused)return r;const n=new Set([e.id]);let a=e.parentTaskId;for(;a&&!n.has(a);){n.add(a);const c=t.find(l=>l.id===a);if(!c)break;if(c.workflow?.kind==="goal"&&c.workflow.paused)return c;a=c.parentTaskId}return e.workflow?.paused?e:null}function XO({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:c,board:l=!1,boardNavigation:d,boardSettings:f,paneKey:m,agents:x=[],defaultCwd:y,onTeamReady:w}){const v=`termdock:tasks:${location.origin}:${e.id}`,[T,C]=b.useState([]),L=b.useRef(T);L.current=T;const[N,D]=b.useState(null),[O]=b.useState(()=>Vl.getState().ensure(v,{draft:KO(`${v}:draft`),selectedId:_o(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:P,mobileDetail:F,creating:ee,draft:Z}=Vl(ne=>ne.views[v]??O),G=Gh(v,"selectedId"),de=Gh(v,"mobileDetail"),pe=Gh(v,"creating"),J=Gh(v,"draft"),[Re,Ze]=b.useState(!1),[V,ve]=b.useState(!1),qe=b.useRef(null),le=b.useRef(null),ye=b.useRef(!1),Te=b.useCallback(ne=>{!ne&&le.current===document.activeElement&&(ye.current=!0),le.current=ne,ne&&ye.current&&(ye.current=!1,ne.focus())},[]);b.useEffect(()=>{const ne=qe.current;if(!ne)return;const Xe=new ResizeObserver(Dt=>Ze(Dt[0].contentRect.width>=(l?1100:760)));return Xe.observe(ne),()=>Xe.disconnect()},[l]);const[Fe,se]=b.useState(!1),[De,_e]=b.useState(null),Me=Jy(),[Ke,Ne]=b.useState(0),[ae,ze]=b.useState(null),[at,ct]=b.useState(!1),[me,ut]=b.useState(0),ft=ne=>ut(Xe=>Math.max(0,Xe+ne)),[Se,He]=b.useState("");b.useEffect(()=>{if(!Se)return;const ne=setTimeout(()=>He(""),5e3);return()=>clearTimeout(ne)},[Se]);const[ke,z]=b.useState("open"),[ie,ge]=b.useState(""),We=b.useRef(!1),tt=b.useRef(!0),wt=b.useRef(new Map),Zt=b.useRef(!1),Ut=e.sessionIds.flatMap(ne=>{const Xe=t.find(Dt=>Dt.sessionId===ne);return Xe?[Xe]:[]}),Mt=Ut.map(ne=>({...ne,name:Hu(ne,Ut)})),nr=Z.coordinator===Zb,jt=Z.coordinator||_o(`${v}:lead`,""),Xt=Mt.find(ne=>ne.sessionId===Z.coordinator&&ne.agent),Bt=!!Z.coordinator&&!nr&&!Xt,Ht=nr||Bt?"":Xt?.sessionId||Mt.find(ne=>ne.sessionId===jt&&ne.agent)?.sessionId||Mt.find(ne=>ne.agent)?.sessionId||"",xe=Mt.filter(ne=>ne.sessionId!==Ht&&ne.agent).map(ne=>ne.sessionId),[Je,ot]=b.useState(!1),[Nt,K]=b.useState(!1),[xt,tr]=b.useState(()=>_o(`${v}:agent`,"")),[$e,Qr]=b.useState(()=>_o(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ce=e.launchProfiles?.find(ne=>ne.id===$e),St=Mt.flatMap(ne=>ne.agent&&x.some(Xe=>Xe.slug===ne.agent.slug)?[ne.agent.slug]:[]),Ot=[...new Set(St)].sort((ne,Xe)=>St.filter(Dt=>Dt===Xe).length-St.filter(Dt=>Dt===ne).length)[0],Jt=x.find(ne=>ne.slug===Xt?.agent?.slug)?.slug??Ot??x[0]?.slug??"",lt=Ce?.agentSlug??(xt||Jt),[Ct,ar]=b.useState(()=>_o(`${v}:cwd`,Mt[0]?.cwd??y??"")),_r=!Mt.find(ne=>ne.sessionId===Ht)?.agent||!xe.length,[Nr,zr]=b.useState(null),Tt=!!Z.spec.trim()&&(!!Nr||!Bt&&(!_r||!e.federated&&(!$e||!!Ce)&&!!x.find(ne=>ne.slug===lt)&&!!Ct.trim())),Ft=T.find(ne=>ne.id===P)??null,we=N?.id===P?N:null;b.useEffect(()=>(tt.current=!0,()=>{tt.current=!1}),[]),b.useEffect(()=>{ta(`${v}:draft`,Z)},[v,Z]),b.useEffect(()=>{ta(`${v}:selected`,P)},[v,P]),b.useEffect(()=>{const ne=Dt=>{const ur=Dt.detail;ur?.groupId===e.id&&(ta(`${v}:open-task`,null),G(ur.taskId),de(!0),pe(!1),z("all"),At())};window.addEventListener("open-collaboration-task",ne);const Xe=_o(`${v}:open-task`,null);return Xe&&(G(Xe),de(!0),z("all"),ta(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",ne)},[e.id]),b.useEffect(()=>{if(!r||!Ft||N?.id===Ft.id&&N.revision===Ft.revision)return;let ne=!1;return J8(Ft.id).then(Xe=>{ne||(D(Xe.task),_e(null))}).catch(Xe=>{ne||_e(Xe instanceof Error?Xe.message:"任务详情加载失败")}),()=>{ne=!0}},[r,Ft?.id,Ft?.revision,N?.id,N?.revision,Ke]);const At=async()=>{if(!Zt.current){Zt.current=!0;try{const ne=await Yy(e.id);tt.current&&(C(ne.tasks),se(!0),_e(null),Ne(Xe=>Xe+1))}catch(ne){tt.current&&_e(ne instanceof Error?ne.message:"任务加载失败")}finally{Zt.current=!1}}};b.useEffect(()=>{if(r)return ou(()=>{navigator.onLine!==!1&&At()},2500,[k0,"pageshow"])},[r,e.id]);const st=ne=>{const Xe=JSON.stringify(ne),Dt=_o(`${v}:request`,null);let ur=wt.current.get(Xe)??(Dt?.fingerprint===Xe?Dt.key:void 0);return ur||(ur=crypto.randomUUID(),wt.current.set(Xe,ur)),ta(`${v}:request`,{fingerprint:Xe,key:ur}),ur},bt=ne=>{wt.current.delete(JSON.stringify(ne)),ta(`${v}:request`,null)},Tn=async(ne,Xe)=>{if(at||We.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};We.current=!0,ct(!0),ze(null),He("");let Dt={...Xe,expectedRevision:ne.revision};if(["comment","revise"].includes(Xe.kind)){const ur=_o(`${v}:request`,null);try{const[Fr,Zr]=JSON.parse(ur?.fingerprint??"null"),{expectedRevision:an,...Mr}=Zr;Fr===ne.id&&JSON.stringify(Mr)===JSON.stringify(Xe)&&(Dt=Zr)}catch{}}try{const ur=await r9(ne.id,{...Dt,idempotencyKey:st([ne.id,Dt])});if(bt([ne.id,Dt]),$u.getState().refresh(),tt.current){const Fr=L.current.find(Vr=>Vr.id===ur.task.id),Zr=Fr&&Fr.revision>ur.task.revision?Fr:ur.task;C(Vr=>Vr.map(Ln=>Ln.id===ur.task.id&&Ln.revision<=ur.task.revision?ur.task:Ln)),D(Vr=>Vr?.id===ur.task.id&&Vr.revision>ur.task.revision?Vr:ur.task);const an=y4(Zr,L.current),Mr=`${Xe.kind==="answer"?"回答已保存":"方案确认已保存"},${an?an.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;He(["comment","revise"].includes(Xe.kind)?"":Xe.kind==="retry"?WO(ne,ur.task):["answer","approve-plan"].includes(Xe.kind)?Mr:Xe.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(ur){const Fr=ur instanceof Error?ur.message:"操作失败";return Fr.includes("任务已更新")&&bt([ne.id,Dt]),tt.current&&(ze(["comment","revise"].includes(Xe.kind)?null:Fr),At()),{ok:!1,error:Fr}}finally{We.current=!1,tt.current&&ct(!1)}},bn=async ne=>{if(ne.preventDefault(),at||me>0||(Z.mode==="goal"?!Tt:!Z.title.trim()||!Z.spec.trim())||We.current)return;We.current=!0,ct(!0),ze(null);const Xe=Z.mode==="goal",Dt={groupId:e.id,title:Z.title.trim()||Z.spec.trim().split(`
140
+ `)[0].slice(0,100),spec:Z.spec,constraints:Z.constraints,acceptance:Z.acceptance,assigneeSessionId:Xe?void 0:Z.assignee||void 0,coordinatorSessionId:Xe?Ht:Z.coordinator||void 0,parentTaskId:Xe?void 0:Z.parent||void 0,dependsOn:Xe?[]:Z.dependencies,managed:Xe,isolated:Z.isolated,reviewerSessionIds:Xe?xe:void 0};try{if(Xe&&(_r||Nr)){K(!0);const Fr=nr?_o(`${v}:team-request`,"")||crypto.randomUUID():void 0;Fr&&ta(`${v}:team-request`,Fr);const Zr=Nr??await e9(e.id,{agentSlug:lt,...$e?{launchProfileId:$e}:e.launchProfiles?.length?{launchProfileId:""}:{},cwd:Ct.trim(),...nr?{coordinatorSessionId:null,coordinatorCreationKey:Fr}:Ht?{coordinatorSessionId:Ht}:{}});K(!1),zr(Zr),Dt.coordinatorSessionId=Zr.coordinatorSessionId,Dt.reviewerSessionIds=Zr.reviewerSessionIds,ta(`${v}:agent`,xt),ta(`${v}:cwd`,Ct.trim()),ta(`${v}:launch-profile`,$e)}const{task:ur}=await t9({...Dt,idempotencyKey:st(Dt)});bt(Dt),tt.current&&(C(Fr=>[ur,...Fr.filter(Zr=>Zr.id!==ur.id)]),G(ur.id),de(!0),D(ur),Xe&&ta(`${v}:lead`,Dt.coordinatorSessionId),ta(`${v}:team-request`,null),zr(null),w?.(),J(m0),pe(!1),z("open"),ge(""),He(Xe?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(ur){tt.current&&ze(ur instanceof Error?ur.message:"创建失败")}finally{We.current=!1,tt.current&&(ct(!1),K(!1))}},nn=(ne,Xe)=>{if(!Xe)return"用户";const Dt=ne.memberSessions[td(Xe)];return Mt.find(ur=>ur.sessionId===Dt)?.name??t.find(ur=>ur.sessionId===Dt)?.name??"暂不可用的成员"},Oe=T.filter(ne=>(ke==="all"?!0:ke==="archive"?ne.status!=="open":ne.status==="open")&&(ke==="all"||ke==="attention"||ne.workflow?.kind!=="step")&&(ke!=="attention"||sa(ne))&&(!ie.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(Xe=>nn(ne,Xe.assignee)).join(" ")}`.toLowerCase().includes(ie.trim().toLowerCase()))),_t=T.filter(sa).length;b.useEffect(()=>{a?.(_t)},[_t,a]);const gt=!!Ft&&(l?F:Re||F),Wt=()=>{pe(!1),requestAnimationFrame(()=>le.current?.focus())},$t=ne=>{Vl.getState().updateDetail(`${v}:${ne}`,"view","overview"),G(ne),de(!0),He("")},Ar=T.filter(sa).filter(ne=>!ie.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(Xe=>nn(ne,Xe.assignee)).join(" ")}`.toLowerCase().includes(ie.trim().toLowerCase())),Sn=(ne,Xe=!1)=>{const Dt=ne.attempts.find(Vr=>Vr.id===ne.activeAttemptId),ur=ne.children?.filter(Vr=>Vr.status==="accepted").length??0,Fr=ne.children?.filter(Vr=>Vr.status!=="closed").length??0,Zr=bp(ne),an=Zr.length>1?Zr.find(Vr=>Vr.source!=="member"):null,Mr=(Xe?ne.decisions.find(Vr=>Vr.status==="pending")?.question:"")||Zr[0]?.summary||Dt?.report?.summary||Dt?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":P===ne.id,className:`group flex min-h-11 w-full items-start gap-3 rounded-xl p-3 text-left transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${P===ne.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>$t(ne.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${Xe||ne.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:Xe?s.jsx(hd,{size:16}):ne.status==="accepted"?s.jsx(L0,{size:16}):s.jsx(V0,{size:16})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:ne.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${Xe?"text-primary":"text-muted-foreground"}`,children:cu(ne)}),Mr&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:Mr}),an&&s.jsxs("span",{className:`mt-1 block line-clamp-2 break-words text-xs leading-5 ${an.source==="system"?"text-destructive":"text-muted-foreground"}`,children:[an.label,":",an.summary]}),Fr>0&&s.jsxs("span",{className:"mt-2 flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"flex gap-1","aria-hidden":"true",children:(ne.children??[]).filter(Vr=>Vr.status!=="closed").slice(0,8).map(Vr=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${Vr.status==="accepted"?"bg-primary":"bg-border/30"}`},Vr.id))}),ur,"/",Fr," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"block truncate",children:Dt?nn(ne,Dt.assignee):"尚未分派"}),s.jsx(ep,{task:ne})]})]}),s.jsx(Ks,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},ne.id)},Mn=[],vn=new Set([P]);let dn=Ft?.parentTaskId;for(;dn&&!vn.has(dn);){vn.add(dn);const ne=T.find(Xe=>Xe.id===dn);if(!ne)break;Mn.unshift(ne),dn=ne.parentTaskId}const kn=()=>{const ne=Array.from(qe.current?.querySelectorAll("button[data-task-id]")??[]).find(Xe=>Xe.dataset.taskId===P);de(!1),requestAnimationFrame(()=>{ne&&!ne.closest("[hidden]")?ne.focus():le.current?.focus()})},Hr=ee||!l&&Fe&&T.length===0;return s.jsxs("section",{ref:qe,"aria-label":"协作任务",className:l?"relative flex h-full min-h-0 min-w-0 flex-col gap-2":"space-y-5",children:[l&&(Hr||!Fe)&&d&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 pb-2",children:[d,s.jsx("div",{className:"ml-auto",children:f})]}),(ae||De&&Me==="ready"&&!Tf(De))&&s.jsxs("div",{role:"alert",className:"flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[s.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[ae||De,!ae&&Fe?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:Ta,onClick:()=>ae?ze(null):void At(),children:[s.jsx(An,{size:14}),ae?"关闭提示":"重试"]})]}),De&&Tf(De)&&!l&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"正在恢复任务同步,现有记录和草稿已保留"}),Se&&s.jsx("p",{role:"status",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-primary",children:Se}),Hr?s.jsxs("form",{onSubmit:ne=>{bn(ne)},className:`mx-auto w-full max-w-xl space-y-4 ${l?"overflow-auto px-1 py-5":""}`,onKeyDown:ne=>{ne.key==="Escape"&&ee&&!ne.defaultPrevented&&!ne.nativeEvent.isComposing&&tg(ne.currentTarget)&&(ne.preventDefault(),ne.stopPropagation(),at||Wt())},children:[s.jsxs("header",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-foreground",children:Z.mode==="goal"?"一起完成什么?":"新建手动任务"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Z.mode==="goal"?"交给协调者拆分,你在这里看交付、回答问题。":"选择负责人,保留分派和验收记录。"})]}),(T.length>0||l)&&s.jsx("button",{type:"button","aria-label":"取消创建,保留草稿",className:`${Ta} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:at,onClick:Wt,children:s.jsx(Dn,{size:16})})]}),Z.mode==="task"&&s.jsx(Ka,{label:"任务标题",children:s.jsx("input",{className:Us,required:!0,maxLength:200,value:Z.title,onChange:ne=>J(Xe=>({...Xe,title:ne.target.value})),placeholder:"要完成什么?"})}),s.jsx(bf,{paneKey:m,inputKey:`${v}:spec`,active:r&&Hr,label:Z.mode==="goal"?"协作目标":"目标与交付要求",className:`${Us} ${_r&&Z.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:ee,required:!0,disabled:at,value:Z.spec,onUploadChange:ft,onChange:ne=>J(Xe=>({...Xe,spec:typeof ne=="function"?ne(Xe.spec):ne})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),Z.mode==="goal"&&Nr&&s.jsxs("section",{role:"status","aria-label":"目标提交阶段",className:"space-y-2 rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5",children:[s.jsx("p",{className:"text-primary",children:"成员已准备,目标尚未提交。重试会复用这些成员。"}),s.jsx("p",{className:"text-muted-foreground",children:"Agent 和工作目录已用于准备成员,因此暂时锁定;目标正文仍可修改。"}),c&&s.jsx("button",{type:"button",className:oi,disabled:at,onClick:()=>{w?.(),c()},children:"查看已准备的成员"})]}),Z.mode==="goal"&&s.jsxs(Ka,{label:"协调者",children:[s.jsxs("select",{"aria-label":"协调者",className:Us,disabled:at||!!Nr,value:Z.coordinator,onChange:ne=>{ta(`${v}:team-request`,null),J(Xe=>({...Xe,coordinator:ne.target.value}))},children:[s.jsx("option",{value:"",children:"自动选择(优先复用组内 Agent)"}),s.jsx("option",{value:Zb,disabled:!!e.federated,children:"新建协调者"}),Bt&&s.jsx("option",{value:Z.coordinator,disabled:!0,children:"原协调者已不可用,请重新选择"}),Mt.map(ne=>s.jsxs("option",{value:ne.sessionId,disabled:!ne.agent,children:[ne.name,ne.agent?` · ${ne.agent.displayName}`:"(需要启动 Agent)"]},ne.sessionId))]}),Bt&&!Nr&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"所选协调者已离组或未运行 Agent,请重新选择。"})]}),Z.mode==="goal"&&(_r||Nr)?s.jsxs("fieldset",{disabled:at||!!Nr,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:Nr?"已用于准备成员的配置":"首次开始时配置 Agent"}),(!!e.launchProfiles?.length||!!$e)&&s.jsxs(Ka,{label:"启动方案",children:[s.jsxs("select",{"aria-label":"协作启动方案",className:Us,value:$e,onChange:ne=>Qr(ne.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(ne=>s.jsxs("option",{value:ne.id,children:[ne.name," · ",x.find(Xe=>Xe.slug===ne.agentSlug)?.displayName??ne.agentSlug]},ne.id))]}),Ce&&s.jsxs("details",{className:"text-xs leading-5 text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-2",children:s.jsx("span",{className:"line-clamp-2 break-words",children:Ce.notes||"查看启动命令与使用备注"})}),s.jsx("p",{"aria-label":"完整使用备注",className:"whitespace-pre-wrap break-words",children:Ce.notes}),s.jsx("code",{className:"mt-1 block break-all",children:Ce.command})]}),$e&&!Ce&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]}),!Ce&&s.jsx(Ka,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Us,disabled:!!Ce,value:lt,onChange:ne=>tr(ne.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(ne=>s.jsx("option",{value:ne.slug,children:ne.displayName},ne.slug))]})}),s.jsxs(Ka,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Us} min-w-0 flex-1`,value:Ct,onChange:ne=>ar(ne.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:oi,onClick:()=>ot(!0),children:"浏览目录"})]}),Je&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(qO,{open:!0,initialPath:Ct.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>ot(!1),onConfirm:ne=>{ar(ne),ot(!1)}})})]}),!Nr&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:nr?"开始时新建协调者,并补齐执行/评审成员。":"保留所选协调者,开始时补齐执行/评审成员;自动选择会优先复用组内 Agent。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",c&&s.jsx("button",{type:"button",className:oi,onClick:c,children:"管理成员"})]}),!x.length&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["尚未检测到可启动的 Agent。安装后刷新,或从成员设置复用现有 Agent。",c&&s.jsx("button",{type:"button",className:oi,onClick:c,children:"管理成员"})]})]}):Z.mode==="task"&&s.jsx(Ka,{label:"分派给",children:s.jsxs("select",{className:Us,value:Z.assignee,onChange:ne=>J(Xe=>({...Xe,assignee:ne.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),Mt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsxs("details",{className:"border-y border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:["验收标准与更多设置",(Z.acceptance||Z.constraints)&&s.jsx("span",{className:"text-primary",children:"已补充"})]}),s.jsxs("div",{className:"space-y-3 pb-4",children:[Z.mode==="goal"&&s.jsxs(Ka,{label:"目标名称(选填)",children:[s.jsx("input",{"aria-label":"目标名称",className:Us,maxLength:100,value:Z.title,onChange:ne=>J(Xe=>({...Xe,title:ne.target.value})),placeholder:"用成果命名,例如:交付可安装的 Preview 客户端"}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"看板用这个名称辨认目标;未填写时使用正文第一行。"})]}),s.jsx(Ka,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Us} min-h-20 resize-y`,value:Z.acceptance,onChange:ne=>J(Xe=>({...Xe,acceptance:ne.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(Ka,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Us} min-h-20 resize-y`,value:Z.constraints,onChange:ne=>J(Xe=>({...Xe,constraints:ne.target.value})),placeholder:"必须保留什么?哪些操作需要先问你?"})}),Z.mode==="goal"?s.jsxs("label",{className:"flex min-h-11 items-start gap-2 text-xs leading-5 text-muted-foreground",children:[s.jsx("input",{type:"checkbox",className:"mt-1",checked:Z.isolated,onChange:ne=>J(Xe=>({...Xe,isolated:ne.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ka,{label:"协调者",children:s.jsxs("select",{className:Us,value:Z.coordinator,onChange:ne=>J(Xe=>({...Xe,coordinator:ne.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),Mt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsx(Ka,{label:"父任务",children:s.jsxs("select",{className:Us,value:Z.parent,onChange:ne=>J(Xe=>({...Xe,parent:ne.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),T.filter(ne=>!ne.workflow).map(ne=>s.jsx("option",{value:ne.id,children:ne.title},ne.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),T.filter(ne=>ne.status!=="closed").map(ne=>s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Z.dependencies.includes(ne.id),onChange:Xe=>J(Dt=>({...Dt,dependencies:Xe.target.checked?[...Dt.dependencies,ne.id]:Dt.dependencies.filter(ur=>ur!==ne.id)}))}),ne.title]},ne.id))]})]}),s.jsx("button",{type:"button",className:`${Ta} text-muted-foreground hover:bg-surface-2`,onClick:()=>J(ne=>({...ne,mode:ne.mode==="goal"?"task":"goal"})),children:Z.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${Tl} w-full`,disabled:at||me>0||(Z.mode==="goal"?!Tt:!Z.title.trim()||!Z.spec.trim()),children:[at?s.jsx(An,{size:14,className:"animate-spin"}):s.jsx(y0,{size:14}),at?Nt?"正在准备成员…":"提交中…":Z.mode==="goal"?Nr?"重试提交目标":"开始协作":Z.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:Z.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):l&&Fe?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"sr-only",children:"任务看板"}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-5",children:[s.jsx("div",{hidden:gt,className:`${gt?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(VO,{navigation:d,settings:f,action:s.jsxs("button",{ref:Te,type:"button",className:Tl,disabled:at,onClick:()=>pe(!0),children:[s.jsx(Xs,{size:14}),"新目标"]}),storage:v,tasks:T,selectedId:gt?P:null,name:nn,onSelect:$t})}),gt&&s.jsxs("aside",{"aria-label":"任务详情",className:"mx-auto flex min-h-0 min-w-0 w-full max-w-[1040px] flex-col",children:[s.jsx("nav",{"aria-label":"任务位置",className:"mb-2 shrink-0",children:s.jsxs("ol",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx("li",{className:"shrink-0",children:s.jsx("button",{type:"button","aria-label":"返回看板",title:"查看此协作组的任务看板",className:`${Ta} px-2 hover:bg-surface-2`,onClick:kn,children:"看板"})}),Mn.map(ne=>s.jsxs("li",{className:"flex min-w-0 flex-1 items-center gap-1 sm:max-w-xs sm:flex-none",children:[s.jsx(Ks,{"aria-hidden":"true",size:12,className:"shrink-0"}),s.jsx("button",{type:"button","aria-label":`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,title:`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,className:`${Ta} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>$t(ne.id),children:s.jsxs("span",{className:"truncate",children:[ne.workflow?.kind==="goal"?"目标":"父任务",":",ne.title]})})]},ne.id)),s.jsxs("li",{"aria-current":"page",className:"flex shrink-0 items-center gap-1",children:[s.jsx(Ks,{"aria-hidden":"true",size:12}),s.jsx("span",{className:"px-2",children:Ft?.parentTaskId?"子任务详情":Ft?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:we?s.jsx(Kb,{reader:!0,paneKey:m,active:r,task:we,tasks:T,members:Mt,busy:at,name:ne=>nn(we,ne),act:ne=>Tn(we,ne),storage:v,onSelectTask:$t,onOpenSession:async ne=>{const Xe=t.find(Dt=>Dt.sessionId===we.memberSessions[td(ne)]);if(!Xe){ze("成员会话暂不可用,任务历史已保留。");return}try{await n(Xe)}catch(Dt){ze(Dt instanceof Error?Dt.message:"无法打开终端")}}},we.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!Fe&&!T.length?s.jsxs("div",{role:"status",className:"space-y-3 py-8",children:[s.jsx("p",{className:"text-center text-xs text-muted-foreground",children:De?"任务暂时无法加载,请重试。":"正在加载目标…"}),!De&&[0,1,2].map(ne=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},ne))]}):s.jsxs(s.Fragment,{children:[(!gt||Re)&&s.jsxs("header",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:"协作目标"}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[T.filter(ne=>ne.status==="open"&&ne.workflow?.kind!=="step").length," 个进行中 · ",T.filter(ne=>ne.status==="accepted"&&ne.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:Te,type:"button",className:Tl,disabled:at,onClick:()=>pe(!0),children:[s.jsx(Xs,{size:14}),"新目标"]})]}),s.jsxs("div",{className:Re&&gt?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!gt||Re)&&s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{"aria-label":"任务筛选",className:`${Us} min-w-0 flex-1 border-transparent bg-transparent`,value:ke,onChange:ne=>z(ne.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",_t,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":V,className:`${Ta} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{ve(ne=>!ne),ge("")},children:s.jsx(Yl,{size:16})})]}),V&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Us,value:ie,onChange:ne=>ge(ne.target.value),placeholder:"搜索目标、内容或负责人"}),ke==="open"&&Ar.length>0&&s.jsxs("section",{"aria-label":"需要你处理",className:"rounded-xl bg-surface-2/40 p-1",children:[s.jsxs("h4",{className:"flex items-center justify-between px-3 pb-1 pt-3 text-xs font-medium text-primary",children:["需要你处理",s.jsx("span",{className:"rounded-md bg-primary/15 px-2 py-0.5",children:Ar.length})]}),Ar.map(ne=>Sn(ne,!0))]}),(ke!=="open"||Oe.some(ne=>!sa(ne))||Oe.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:ke==="attention"?"需要你处理":ke==="archive"?"已归档":ke==="all"?"全部任务":"当前目标"}),Oe.filter(ne=>ke!=="open"||!sa(ne)).map(ne=>Sn(ne,ke==="attention")),!Oe.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[ie.trim()?"没有匹配的任务。":ke==="attention"?"目前没有需要你处理的任务。":ke==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(ke!=="all"||ie)&&s.jsx("button",{type:"button",className:`${Ta} mt-2 text-primary`,onClick:()=>{z("all"),ge("")},children:"查看全部任务"})]})]})]}),gt&&s.jsxs("div",{className:"min-w-0",children:[!Re&&s.jsxs("button",{type:"button",className:`${Ta} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>de(!1),children:[s.jsx(e3,{size:14}),"全部目标"]}),we?s.jsx(Kb,{paneKey:m,active:r,task:we,tasks:T,members:Mt,busy:at,name:ne=>nn(we,ne),act:ne=>Tn(we,ne),storage:v,onSelectTask:$t,onOpenSession:async ne=>{const Xe=t.find(Dt=>Dt.sessionId===we.memberSessions[td(ne)]);if(!Xe){ze("成员会话暂不可用,任务历史已保留。");return}try{await n(Xe)}catch(Dt){ze(Dt instanceof Error?Dt.message:"无法打开终端")}}},we.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function Ka({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),t]})}function Kb({reader:e=!1,active:t,paneKey:r,task:n,tasks:a,members:c,name:l,busy:d,act:f,storage:m,onOpenSession:x,onSelectTask:y}){const[w,v]=b.useState(""),[T,C]=b.useState(""),[L,N]=b.useState(""),[D,O]=b.useState(!1),[P,F]=b.useState(null),ee=b.useRef(!1),Z=b.useRef(!0);b.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const G=b.useRef(null),de=b.useRef(null);b.useEffect(()=>{!e&&P&&P.state!=="pending"&&t&&requestAnimationFrame(()=>de.current?.scrollIntoView({block:"nearest"}))},[P]);const pe=b.useRef(null),[J,Re]=b.useState(0),Ze=K=>Re(xt=>Math.max(0,xt+K)),V=b.useRef(null);b.useEffect(()=>{V.current?.focus()},[]);const ve=`${m}:${n.id}`,[qe]=b.useState(()=>Vl.getState().ensureDetail(ve,{feedback:_o(`${ve}:feedback`,""),answers:_o(`${ve}:answers`,{}),view:"overview"})),{feedback:le,answers:ye,view:Te}=Vl(K=>K.details[ve]??qe),Fe=Hm(ve,"feedback"),se=Hm(ve,"answers"),De=Hm(ve,"view");b.useEffect(()=>{pe.current&&(pe.current.scrollTop=0)},[Te]),b.useEffect(()=>ta(`${m}:${n.id}:answers`,ye),[m,n.id,ye]),b.useEffect(()=>ta(`${m}:${n.id}:feedback`,le),[m,n.id,le]);const _e=n.attempts.find(K=>K.id===n.activeAttemptId),Me=n.status==="open",Ke=y4(n,a),Ne=n.artifacts.filter(K=>K.kind==="result"&&K.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{P?.state==="saved"&&Ne?.id!==P.resultId&&F(null)},[Ne?.id,P]);const ae=n.artifacts.filter(K=>K.kind==="plan"&&K.attemptId===n.activeAttemptId).at(-1),ze=n.events.filter(K=>K.kind==="revise"&&K.source==="user"&&K.attemptId===n.activeAttemptId).at(-1),at=Ne&&n.events.some(K=>K.kind==="revise"&&K.attemptId===n.activeAttemptId&&K.createdAt>=Ne.createdAt),ct=e&&Me&&!!at,me=P?.state==="saved"&&P.kind==="revise"&&P.resultId===Ne?.id,ut=n.decisions.filter(K=>K.status==="pending"&&K.attemptId===n.activeAttemptId),ft=n.dependsOn.some(K=>a.find(xt=>xt.id===K)?.status!=="accepted"),Se=!n.workflow||n.artifacts.filter(K=>K.kind==="review"&&K.reviewsArtifactId===Ne?.id).at(-1)?.verdict==="pass",He=n.children??[],ke=n.workflow?.kind==="goal"&&He.some(K=>!["accepted","closed"].includes(K.status)),z=`任务:${n.title}
141
+ 任务 ID:${n.id}
142
+ ${n.spec}
143
+ 约束:${n.constraints||"未补充"}
144
+ 验收标准:${n.acceptance||"由用户决定"}
145
+ ${_e?`当前尝试:${_e.id}
146
+ 负责人:${l(_e.assignee)}
147
+ `:""}${n.artifacts.filter(K=>K.attemptId===n.activeAttemptId).map(K=>`${K.kind} · 版本 ${K.id} · ${ya(K.createdAt)}
148
+ ${K.summary?`结果摘要:${K.summary}
149
+ `:""}${K.content}`).join(`
150
+
151
+ `)}
152
+ ${ut.map(K=>`待回答:${K.question}`).join(`
153
+ `)}`,ie=()=>{const K=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),xt=document.createElement("a");xt.href=K,xt.download=`termdock-task-${n.id}.json`,xt.click(),setTimeout(()=>URL.revokeObjectURL(K),1e3)},ge=n.events.filter(K=>K.kind==="coordinate"&&(!K.attemptId||K.attemptId===n.activeAttemptId)).at(-1),We=Te==="results"?n.artifacts.slice().reverse():n.artifacts.filter(K=>K.id===Ne?.id||K.id===ae?.id&&n.approvedPlanArtifactId!==K.id||K.kind==="review"&&K.reviewsArtifactId===Ne?.id).sort((K,xt)=>(K.kind==="result"?-1:1)-(xt.kind==="result"?-1:1)||xt.createdAt-K.createdAt),tt=He.flatMap(K=>{const xt=a.find(tr=>tr.id===K.id);return xt?[xt]:[]}),wt=m4(n,tt),Zt=He.filter(K=>K.status!=="closed"),Ut=Zt.filter(K=>K.status!=="accepted"),Mt=ge&&(!ze||ge.createdAt>=ze.createdAt)?ge:void 0,nr=_e?.report&&(!ze||_e.report.createdAt>=ze.createdAt)?_e.report:void 0,jt=at?"等待新结果通过评审后可验收。":ut.length?"回答当前问题后可验收。":ft?"依赖任务验收后可验收。":Se?ke?"子任务完成并通过评审后可验收。":null:"独立评审通过后可验收。",Xt=()=>{De("overview"),O(!0),requestAnimationFrame(()=>{G.current?.scrollIntoView({block:"nearest"}),G.current?.querySelector("textarea")?.focus()})},Bt=bp(n),Ht=Bt[0],xe=Bt.some(K=>K.source==="member"),Je=async K=>{if(d||J||!le.trim()||ee.current)return;const xt=le;ee.current=!0,F({kind:K,state:"pending",content:xt,resultId:Ne?.id});const tr=await f({kind:K,content:xt});if(ee.current=!1,tr.ok){if(Fe($e=>$e===xt?"":$e),ta(`${ve}:feedback`,Vl.getState().details[ve]?.feedback??""),!Z.current)return;F({kind:K,state:"saved",content:xt,resultId:Ne?.id}),e&&Vl.getState().details[ve]?.feedback===""&&O(!1)}else Z.current&&F({kind:K,state:"error",content:xt,error:tr.error,resultId:Ne?.id})},ot=K=>s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:K}),children:s.jsx(YO,{content:K})}),Nt=K=>{const xt=b4(K.content,K.summary);return s.jsxs("section",{className:"space-y-3 rounded-xl border border-border/20 bg-surface-2/30 p-4",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h4",{className:"min-w-0 flex-1 text-sm font-semibold text-foreground",children:K.kind==="result"?at&&K.id===Ne?.id?"上一版结果":"交付结果":K.kind==="plan"?n.approvedPlanArtifactId===K.id?"已确认的方案":"方案":"独立评审"}),K.verdict&&s.jsx("span",{className:`rounded-md px-2 py-1 text-[11px] ${K.verdict==="pass"?"bg-primary/10 text-primary":"bg-surface-2 text-foreground"}`,children:K.verdict==="pass"?"通过":K.verdict==="changes"?"需要修改":"受阻"}),n.acceptedArtifactId===K.id&&s.jsx("span",{className:"text-xs text-primary",children:n.completionMode==="reviewed"?"评审通过":"已验收"}),n.approvedPlanArtifactId===K.id&&s.jsx("span",{className:"text-xs text-primary",children:"方案已确认"})]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[l(K.actor)," · ",ya(K.createdAt),K.attemptId!==n.activeAttemptId&&K.kind!=="review"?" · 历史分派":""]}),K.kind==="result"&&xt.condensed?s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-label":"结果结论",className:"text-base leading-7",children:ot(!xt.explicit&&!xt.summary.includes(`
154
+ `)?xt.summary.replace(/([。;])\s*(?=\S)/g,`$1
155
+
156
+ `):xt.summary)}),xt.limitations&&s.jsxs("div",{className:"border-l-2 border-border/40 pl-3",children:[s.jsx("h5",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"适用范围与限制"}),ot(xt.limitations)]}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整报告与原始证据"}),s.jsx("div",{className:"space-y-3 pb-3",children:ot(K.content)})]})]}):ot(K.content),K.evidence!==void 0&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3",children:"交付证据"}),s.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 text-[11px]",children:JSON.stringify(K.evidence,null,2)})]}),Me&&K.attemptId===n.activeAttemptId&&K.kind!=="review"&&(!e||K.kind==="plan"||!n.workflow)&&s.jsxs("div",{className:"space-y-2 border-t border-border/15 pt-3",children:[!e&&Ne?.id===K.id&&n.workflow?.kind!=="step"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`${Tl} w-full`,disabled:d||!!jt,onClick:()=>{f({kind:"accept",artifactId:K.id})},children:[s.jsx(Ci,{size:14}),"验收此结果"]}),jt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:jt})]}),ae?.id===K.id&&n.approvedPlanArtifactId!==K.id&&s.jsxs("button",{type:"button",className:`${Tl} w-full`,disabled:d,onClick:()=>{f({kind:"approve-plan",artifactId:K.id})},children:[s.jsx(Ci,{size:14}),Ke?"确认方案":"确认方案并继续"]}),!n.workflow&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"请其他成员评审此版本"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"独立评审成员",className:Us,value:T,onChange:tr=>C(tr.target.value),children:[s.jsx("option",{value:"",children:"选择独立评审成员"}),c.filter(tr=>tr.sessionId!==n.memberSessions[td(K.actor)]).map(tr=>s.jsx("option",{value:tr.sessionId,children:tr.name},tr.sessionId))]}),s.jsx("button",{type:"button",className:oi,disabled:d||!T||T===n.memberSessions[td(K.actor)],onClick:()=>{f({kind:"request-review",artifactId:K.id,assigneeSessionId:T})},children:"请求评审"})]})]})]})]},K.id)};return s.jsxs("article",{className:e?"flex h-full min-h-0 flex-col":"space-y-5",children:[s.jsxs("div",{ref:pe,"data-task-reader-scroll":!0,className:e?"min-h-0 flex-1 space-y-4 overflow-auto pb-5 pr-1":"contents",children:[s.jsxs("header",{className:"space-y-2",children:[!e&&n.parentTaskId&&s.jsxs("button",{type:"button",className:`${Ta} -ml-2 max-w-full text-muted-foreground hover:bg-surface-2`,onClick:()=>y(n.parentTaskId),children:[s.jsxs("span",{className:"truncate",children:["所属任务:",a.find(K=>K.id===n.parentTaskId)?.title??"查看父任务"]}),s.jsx(rf,{size:13,className:"shrink-0"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("h3",{ref:V,tabIndex:-1,className:"break-words text-lg font-semibold leading-7 text-foreground outline-none",children:n.title}),s.jsxs("span",{className:`inline-flex items-center gap-2 rounded-md px-2 py-1 text-xs ${sa(n)?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground"}`,children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),n.workflow?.kind==="goal"?wt.label:cu(n)]})]}),!ut.length&&!Ne&&n.spec.trim()!==n.title.trim()&&s.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words text-sm leading-6 text-muted-foreground",children:n.spec}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:n.workflow?.kind==="goal"?`协调者 · ${l(n.coordinator)}`:_e?`负责人 · ${l(_e.assignee)}`:"尚未分派"}),_e&&s.jsxs("button",{type:"button",className:`${Ta} px-2 text-muted-foreground hover:bg-surface-2 hover:text-primary`,onClick:()=>{x(_e.assignee)},children:[s.jsx(Zc,{size:13}),"打开终端"]})]}),n.workflow?.kind==="goal"&&s.jsx("p",{"aria-label":"目标下一步",className:"text-xs leading-5 text-muted-foreground",children:wt.next}),!e&&s.jsx(ep,{task:n}),n.replica&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"此记录由来源服务同步,回答与决定会送回来源服务。"})]}),Ke&&Me&&s.jsxs("section",{role:"status","aria-label":"安排暂停说明",className:"space-y-2 rounded-xl bg-surface-2 p-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Ke.workflow?.kind==="goal"?"目标仍暂停。回答和方案确认会保存,恢复目标后才能投递;已投递的终端工作继续保留。":"任务仍暂停。回答和方案确认会保存,继续安排后才能投递;已投递的终端工作继续保留。"}),Ke.id!==n.id&&s.jsx("button",{type:"button",className:oi,onClick:()=>y(Ke.id),children:"查看目标并恢复安排"})]}),s.jsx("nav",{"aria-label":"任务详情",className:"flex gap-4 border-b border-border/20",children:[["overview",ct?"进展":e&&Ne?"结果":"概览"],["results",e?"历史交付":`交付${n.artifacts.length?` ${n.artifacts.length}`:""}`],["activity","动态"]].map(([K,xt])=>s.jsx("button",{type:"button","aria-pressed":Te===K,className:`min-h-11 border-b-2 px-1 text-xs font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${Te===K?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,onClick:()=>De(K),children:xt},K))}),Te==="overview"&&s.jsxs(s.Fragment,{children:[(()=>{const K=ze;if(!K)return null;const xt=n.deliveries.find(Qr=>Qr.id===K.deliveryId),tr=n.outbox.find(Qr=>Qr.id===K.deliveryId),$e=Ne&&Ne.createdAt>K.createdAt;return s.jsxs("section",{"aria-label":"最近跟进",className:"space-y-1 rounded-lg bg-surface-2/50 px-3 py-2 text-xs leading-5",children:[s.jsx("p",{className:"font-medium text-primary",children:ct?"本次跟进要求":$e?Se?"新结果已通过独立评审":"新结果已交付,等待独立评审":"已要求继续跟进,等待新结果"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:K.content}),s.jsxs("p",{className:"text-muted-foreground",children:[ya(K.createdAt),xt?.status==="delivered"?e?" · 已写入成员终端":` · 已写入${K.target?l(K.target):"成员"}终端${xt.deliveredAt?` · ${ya(xt.deliveredAt)}`:""}`:["failed","expired"].includes(xt?.status??"")||xt?.error||tr?.lastError?" · 投递未成功,服务端继续重试":K.deliveryId?" · 等待写入终端":" · 要求已保存"]})]})})(),ut.map(K=>s.jsxs("form",{className:"space-y-3 rounded-xl border border-border/30 bg-surface-2/40 p-4",onSubmit:xt=>{xt.preventDefault(),!d&&!J&&ye[K.id]?.trim()&&f({kind:"answer",decisionId:K.id,content:ye[K.id]})},children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-primary",children:[s.jsx(hd,{size:14}),"需要你的决定"]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:K.question}),!!K.options.length&&s.jsx("div",{className:"flex flex-col gap-2",children:K.options.map((xt,tr)=>s.jsxs("button",{type:"button","aria-pressed":ye[K.id]===xt,disabled:d,className:`${Ta} justify-start text-left ${ye[K.id]===xt?"bg-primary/15 text-primary":"bg-surface-2 text-foreground"}`,onClick:()=>se($e=>({...$e,[K.id]:xt})),children:[ye[K.id]===xt?s.jsx(Ci,{size:14,className:"shrink-0"}):s.jsx(V0,{size:14,className:"shrink-0"}),s.jsx("span",{className:"break-words",children:xt})]},tr))}),s.jsx(bf,{paneKey:r,inputKey:`${ve}:answer:${K.id}`,active:t,label:"你的回答",className:`${Us} min-h-20 resize-y`,required:!0,disabled:d,value:ye[K.id]??"",onUploadChange:Ze,onChange:xt=>se(tr=>({...tr,[K.id]:typeof xt=="function"?xt(tr[K.id]??""):xt})),placeholder:"选择建议,或写下你的决定…"}),s.jsxs("button",{className:`${Tl} w-full`,disabled:d||J>0||!ye[K.id]?.trim(),children:[s.jsx(y0,{size:14}),Ke?"保存回答":"回复并继续"]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[ya(K.createdAt)," · 回答会保存在任务记录中"]})]},K.id)),Bt.map(K=>s.jsxs("section",{"aria-label":K.source==="member"?"成员阻塞报告":K.source==="unknown"?"待核对服务记录":"服务异常",role:K.source==="system"?"alert":"status",className:`space-y-3 rounded-xl p-4 ${K.source==="member"?"bg-primary/10":K.source==="unknown"?"bg-surface-2":"bg-destructive/10"}`,children:[s.jsx("h4",{className:`text-sm font-medium ${K.source==="member"?"text-primary":K.source==="unknown"?"text-muted-foreground":"text-destructive"}`,children:K.label}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:K.summary}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:K.source==="member"?`负责人:${l(_e?.assignee??null)}。先补齐报告中缺少的条件,再发送说明;需要登录时,请在对应服务完成授权。`:K.source==="unknown"?"此摘要未提供原报告正文和记录来源,请打开完整详情核对;确认前不提供服务异常重试。":"重试只请求服务重新检查现有投递与协调条件,保留原报告和执行尝试;成员新的明确回复才会更新报告。"}),K.source==="member"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:oi,disabled:d,onClick:Xt,children:"补充条件并通知成员"}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整阻塞报告"}),K.content?ot(K.content):s.jsx("p",{className:"text-xs text-muted-foreground",children:"原始报告正文未提供。"})]})]}):K.source==="system"?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:oi,disabled:d||!n.workflow,onClick:()=>{f({kind:"retry"})},children:[s.jsx(An,{size:13}),n.outbox.length?"重试现有投递":K.content.startsWith("消息投递")?"重新检查投递记录":"重新检查自动安排"]}),!n.workflow&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"此任务未启用自动安排,请检查投递记录或成员终端。"})]}):null]},K.source)),n.workflow?.paused&&Me&&s.jsxs("section",{className:"space-y-2 rounded-xl bg-surface-2 p-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"后续安排已暂停,已投递的终端工作继续保留。"}),s.jsx("button",{type:"button",className:oi,disabled:d,onClick:()=>{f({kind:"resume"})},children:"继续安排"})]}),ct&&We.filter(K=>K.kind==="plan").map(Nt),ct&&s.jsxs("section",{"aria-label":"当前进展",className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"等待本轮新结果"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Ut.length?`${Ut.length} 项执行尚未完成交付与评审`:"收到新的交付结果后,会在这里展示供你验收。"})]}),!!Ut.length&&s.jsx("ul",{className:"space-y-1",children:Ut.map(K=>s.jsx("li",{children:s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-3 text-left text-xs text-muted-foreground hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>y(K.id),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:K.title}),s.jsx(Ks,{size:14,className:"shrink-0"})]})},K.id))}),Mt||nr?s.jsxs("details",{className:"group/record border-t border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Ks,{size:13,className:"shrink-0 transition-transform group-open/record:rotate-90"}),s.jsx("span",{children:Mt?"协调者最近的更新":"成员最近的报告"}),s.jsx("span",{className:"ml-auto shrink-0",children:ya((Mt??nr).createdAt)})]}),s.jsx("div",{className:"pb-3",children:ot((Mt??nr).content)})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到这次跟进后的明确更新。"})]}),ct?s.jsxs("details",{className:"group/record border-t border-border/20",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Ks,{size:13,className:"shrink-0 transition-transform group-open/record:rotate-90"}),s.jsx("span",{children:"查看上一版结果"}),s.jsx("span",{className:"ml-auto shrink-0",children:ya(Ne.createdAt)})]}),s.jsx("div",{className:"space-y-3 pb-3",children:We.filter(K=>K.kind!=="plan").map(Nt)})]}):s.jsx(s.Fragment,{children:We.map(K=>K.kind==="review"?s.jsxs("details",{className:"rounded-lg border border-border/20 px-3",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["独立评审 · ",K.verdict==="pass"?"通过":K.verdict==="changes"?"要求修改":"受阻"," · ",l(K.actor)]}),Nt(K)]},K.id):Nt(K))}),n.workflow?.kind==="goal"&&!Ne&&!Ht&&!ut.length&&s.jsx("section",{"aria-label":"最新明确更新",className:"space-y-2 rounded-xl bg-surface-2/40 p-3",children:wt.latest?s.jsxs(s.Fragment,{children:[s.jsxs("h4",{className:"flex items-center gap-2 text-xs font-medium text-foreground",children:[wt.latest.source,s.jsx("span",{className:"ml-auto shrink-0 text-[11px] font-normal text-muted-foreground",children:ya(wt.latest.createdAt)})]}),wt.latest.taskId!==n.id&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["来自:",wt.latest.title]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:g4(wt.latest).slice(0,512)}),wt.latest.taskId!==n.id?s.jsxs("button",{type:"button",className:oi,onClick:()=>y(wt.latest.taskId),children:["查看这项执行工作",s.jsx(Ks,{size:13})]}):s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"查看原始更新"}),ot(wt.latest.source==="协调说明"?ge?.content??"":_e?.report?.content??"")]})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到本轮明确更新。拆分和报告到达后会显示在这里。"})}),n.workflow?.kind!=="goal"&&ge&&!Ne&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h4",{className:"flex items-center gap-2 text-xs font-medium text-foreground",children:["协调者更新",s.jsx("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground",children:ya(ge.createdAt)})]}),s.jsx("div",{className:"rounded-xl bg-surface-2/50 p-3",children:ot(ge.content)})]}),n.workflow?.kind!=="goal"&&!Ht&&!ge&&_e?.report&&!Ne&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-xs font-medium text-foreground",children:["最近报告",s.jsx("span",{className:"ml-2 text-[11px] font-normal text-muted-foreground",children:ya(_e.report.createdAt)})]}),ot(_e.report.content)]}),!!He.length&&s.jsxs("details",{className:"space-y-2",open:!Ne||ct||He.some(K=>{const xt=a.find(tr=>tr.id===K.id);return xt&&sa(xt)})||void 0,children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:[s.jsx("span",{children:"执行过程"}),s.jsx("span",{className:"ml-2 text-muted-foreground",children:"工作拆分"}),s.jsxs("span",{className:"ml-3 text-[11px] font-normal text-muted-foreground",children:[wt.done,"/",Zt.length," 项交付已评审"]})]}),s.jsx(x4,{detail:!0,task:n,children:tt,tasks:a,name:(K,xt)=>l(xt),onSelect:y})]}),!!n.dependsOn.length&&s.jsxs("section",{children:[s.jsx("h4",{className:"mb-2 text-xs font-medium text-foreground",children:"依赖任务"}),n.dependsOn.map(K=>s.jsxs("button",{type:"button",className:`${Ta} w-full justify-start text-left text-muted-foreground hover:bg-surface-2`,onClick:()=>y(K),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:a.find(xt=>xt.id===K)?.title??K}),s.jsx("span",{className:"shrink-0 text-[11px]",children:a.find(xt=>xt.id===K)?.status==="accepted"?"已验收":"待验收"})]},K))]}),Me&&!_e&&!n.scheduledAssignee&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2/50 p-4",children:[s.jsx(Ka,{label:"分派给",children:s.jsxs("select",{className:Us,value:w,onChange:K=>v(K.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(K=>s.jsx("option",{value:K.sessionId,children:K.name},K.sessionId))]})}),s.jsx("button",{type:"button",className:`${Tl} w-full`,disabled:d||!w||ft,onClick:()=>{f({kind:"assign",assigneeSessionId:w})},children:"分派任务"}),ft&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"依赖任务验收后可分派。"})]}),!Ht&&!ut.length&&!ge&&!_e?.report&&!We.length&&!He.length&&s.jsxs("div",{className:"rounded-xl bg-surface-2/40 p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-foreground",children:Me?"等待第一条更新":"任务记录已保留"}),s.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:Me?"成员明确回复后,报告、问题和交付会出现在这里。":"可在动态中查看分派与决定。"})]})]}),Te==="results"&&s.jsx("div",{className:"space-y-4",children:We.length?We.map(Nt):s.jsx("p",{className:"py-8 text-center text-xs leading-5 text-muted-foreground",children:"还没有交付。方案、结果和独立评审会保存在这里。"})}),Te==="activity"&&s.jsxs("section",{"aria-label":"任务动态",children:[s.jsx("ol",{className:"space-y-5",children:n.events.slice().reverse().map(K=>s.jsxs("li",{className:"relative border-l border-border/30 pl-4",children:[s.jsx("span",{className:"absolute -left-1 top-1 h-2 w-2 rounded-full bg-border"}),s.jsxs("p",{className:"text-xs font-medium text-foreground",children:[ZO[K.kind]??K.kind,K.reportStatus?` · ${Yf[K.reportStatus]}`:""]}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[K.source==="system"?"服务自动接续":K.source==="integration"?`外部接入 ${K.origin?.integrationId??""}`:l(K.actor)," · ",ya(K.createdAt),K.attemptId&&K.attemptId!==n.activeAttemptId?" · 历史分派":""]}),s.jsx("div",{className:"mt-2",children:ot(K.content)}),K.target&&s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["接收人:",l(K.target)]})]},K.id))}),!n.events.length&&s.jsx("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"还没有动态记录。"})]}),Me&&Te!=="activity"&&(!e||!Ne)&&s.jsxs("section",{ref:G,className:"space-y-2 border-t border-border/20 pt-4",children:[s.jsx(bf,{paneKey:r,inputKey:`${ve}:feedback`,active:t,label:xe?"补充处理说明":"补充说明或修改要求",className:`${Us} min-h-20 resize-y text-sm leading-6`,disabled:d,value:le,onUploadChange:Ze,onChange:Fe,placeholder:xe?"说明已补齐的条件,或调整本次检查范围…":"补充上下文,或写下需要修改的地方…"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",className:oi,disabled:d||J>0||!le.trim(),onClick:()=>{Je("comment")},children:[P?.state==="pending"&&P.kind==="comment"?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(y0,{size:13}),P?.state==="pending"&&P.kind==="comment"?"正在发送…":xe?"发送条件说明":"发送补充"]}),!xe&&s.jsxs("button",{type:"button",className:oi,disabled:d||J>0||!_e||!le.trim(),onClick:()=>{Je("revise")},children:[P?.state==="pending"&&P.kind==="revise"&&s.jsx(An,{size:13,className:"animate-spin"}),P?.state==="pending"&&P.kind==="revise"?"正在提交…":"要求修改"]})]}),P&&s.jsx("div",{ref:de,role:P.state==="error"?"alert":"status",className:`rounded-lg px-3 py-2 text-xs leading-5 ${P.state==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:P.state==="pending"?"正在保存,请稍候…":P.state==="error"?`未确认保存:${P.error}。内容已保留,可重试。`:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:P.kind==="comment"?xe?"补充已保存,投递结果可在任务管理中查看凭证;成员原报告仍保留,等待新的明确回复。":"补充已保存,投递结果可在任务管理中查看凭证。":"修改要求已保存,等待新结果后可验收。"}),s.jsx("p",{className:"mt-1 line-clamp-2 whitespace-pre-wrap break-words text-foreground/80",children:P.content}),s.jsx("button",{type:"button",className:"mt-1 min-h-11 text-primary underline underline-offset-4",onClick:()=>De("activity"),children:"查看任务动态"})]})}),!P&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:xe?"说明会发送给本次负责人,成员明确回复后状态更新。":"发送补充会保留当前结果;需要更新结果时,请选择“要求修改”。"})]}),s.jsxs("details",{className:"border-t border-border/20",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"任务管理与诊断"}),s.jsxs("div",{className:"space-y-4 pb-4",children:[e&&s.jsx(ep,{task:n}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整目标与验收标准"}),ot(n.spec),n.acceptance&&ot(n.acceptance),n.constraints&&ot(n.constraints)]}),n.workflow&&Me&&s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"后续执行与评审安排"}),s.jsx("button",{type:"button",className:oi,disabled:d,onClick:()=>{f({kind:n.workflow.paused?"resume":"pause"})},children:n.workflow.paused?"继续安排":"暂停安排"})]}),n.workspace&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"交付目录与分支"}),s.jsxs("p",{className:"select-text break-all text-xs text-foreground",children:[n.workspace.cwd,s.jsx("br",{}),n.workspace.branch]}),s.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"基于已提交代码创建;合并到原分支或发布需另行操作。"})]}),Me&&s.jsxs(s.Fragment,{children:[_e&&n.workflow?.kind!=="goal"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"任务负责人",className:Us,value:w,onChange:K=>v(K.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(K=>s.jsx("option",{value:K.sessionId,children:K.name},K.sessionId))]}),s.jsx("button",{type:"button",className:oi,disabled:d||!w||ft,onClick:()=>{f({kind:"assign",assigneeSessionId:w,content:le||void 0})},children:"开始新一轮分派"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:ft?"依赖任务验收后可分派。":"新分派保留旧记录,并结束旧问题的回答入口。"})]}),s.jsx(Ka,{label:"协调者",children:s.jsxs("select",{className:Us,disabled:d||n.workflow?.kind==="step",value:n.coordinator?n.memberSessions[td(n.coordinator)]??"":"",onChange:K=>{f({kind:"coordinator",coordinatorSessionId:K.target.value||null})},children:[!n.workflow&&s.jsx("option",{value:"",children:"由用户协调"}),c.map(K=>s.jsx("option",{value:K.sessionId,children:K.name},K.sessionId))]})}),s.jsx("button",{type:"button",className:`${Ta} text-muted-foreground hover:bg-surface-2`,disabled:d,onClick:()=>{f({kind:"close",content:le||void 0})},children:"关闭此任务"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"关闭会保留历史和成员的终端工作。"})]}),!Me&&s.jsx("button",{type:"button",className:oi,disabled:d,onClick:()=>{f({kind:"reopen"})},children:"重新打开任务"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["投递凭证与执行尝试 · ",n.attempts.length," 轮"]}),s.jsxs("div",{className:"space-y-3 text-xs leading-5 text-muted-foreground",children:[n.outbox.map(K=>s.jsxs("p",{className:"break-words",children:[K.lastError?`等待重试:${K.lastError}`:"已保存 · 等待投递",K.messageId?` · 消息 ${K.messageId}`:""]},K.id)),n.attempts.map(K=>s.jsxs("div",{children:[s.jsxs("p",{children:[K.id===n.activeAttemptId?"当前分派":"历史分派"," · ",l(K.assignee)," · ",ya(K.createdAt)]}),s.jsxs("p",{className:"mt-1 break-all font-mono text-[11px]",children:["尝试 ID:",K.id]}),s.jsxs("p",{className:"mt-1",children:[K.deliveryStatus==="delivered"?`已写入终端 · ${K.deliveredAt?ya(K.deliveredAt):""}`:K.deliveryStatus==="failed"||K.deliveryStatus==="expired"?"本次消息投递未成功":"等待写入终端",K.report?` · ${Yf[K.report.status]}(${ya(K.report.createdAt)})`:""]})]},K.id)),n.deliveries.filter(K=>K.kind!=="task").map(K=>s.jsxs("p",{className:"break-all",children:["后续消息 ",K.messageId," · ",K.status==="delivered"?"已写入终端":"等待投递",K.deliveredAt?` · ${ya(K.deliveredAt)}`:""]},K.id)),s.jsx("p",{className:"text-[11px]",children:"投递凭证确认终端写入;报告保留成员原始陈述。"})]})]}),s.jsxs("p",{className:"select-text break-all text-[11px] text-muted-foreground",children:["任务:",n.id,s.jsx("br",{}),"来源服务:",n.ownerServiceId,s.jsx("br",{}),"版本:",n.revision]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",className:oi,onClick:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(z)).then(()=>N("任务上下文已复制。")).catch(()=>N("复制失败,可导出任务记录。"))},children:"复制上下文"}),s.jsx("button",{type:"button",className:oi,onClick:ie,children:"导出记录"}),L&&s.jsx("span",{role:"status",className:"self-center text-[11px] text-muted-foreground",children:L})]})]})]})]}),e&&Ne&&n.status!=="closed"&&s.jsxs("footer",{role:"region","aria-label":"结果验收",className:"shrink-0 space-y-2 border-t border-border/25 bg-[var(--chrome-bg)] py-3 [padding-bottom:max(0.75rem,env(safe-area-inset-bottom))]",children:[D?s.jsxs("div",{ref:G,className:"space-y-2",children:[s.jsx(bf,{paneKey:r,inputKey:`${ve}:feedback`,active:t,label:"跟进要求",className:`${Us} min-h-20 max-h-32 resize-none text-sm leading-6`,disabled:d,value:le,onUploadChange:Ze,onChange:Fe,placeholder:"说明哪里不满意,或写下接下来要完成的事…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:oi,disabled:d||J>0,onClick:()=>O(!1),children:"取消,保留草稿"}),s.jsxs("button",{type:"button",className:`${Tl} ml-auto`,disabled:d||J>0||!_e||!le.trim(),onClick:()=>{Je("revise")},children:[P?.state==="pending"?s.jsx(An,{size:14,className:"animate-spin"}):s.jsx(y0,{size:14}),P?.state==="pending"?"正在发送…":"发送并继续跟进"]})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:`${oi} flex-1 sm:flex-none`,disabled:d,onClick:Xt,children:le.trim()?"继续跟进 · 有草稿":"继续跟进"}),Te!=="overview"?s.jsx("button",{type:"button",className:`${Tl} ml-auto flex-1 sm:flex-none`,onClick:()=>De("overview"),children:ct?"返回当前进展":"返回当前结果"}):(ct||me)&&Me?s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"等待新结果后可验收"}):Me&&n.workflow?.kind!=="step"?s.jsxs("button",{type:"button",className:`${Tl} ml-auto flex-1 sm:flex-none`,disabled:d||J>0||!!jt||P?.state==="saved"&&P.kind==="revise"&&P.resultId===Ne.id,onClick:()=>{f({kind:"accept",artifactId:Ne.id})},children:[s.jsx(Ci,{size:14}),"验收此结果"]}):s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:n.status==="accepted"?n.completionMode==="reviewed"?"已通过独立评审":"已验收":"由独立评审验收"})]}),P&&s.jsx("div",{role:P.state==="error"?"alert":"status",className:`text-xs leading-5 ${P.state==="error"?"text-destructive":"text-primary"}`,children:P.state==="pending"?"正在保存跟进要求…":P.state==="error"?`未确认保存:${P.error}。内容已保留,可重试。`:"跟进要求已保存,等待新结果。"}),!D&&!ct&&Me&&jt&&P?.state!=="saved"&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:jt})]})]})}const tp=new Map,v4=e=>`termdock-group-settings:${window.location.origin}:${e}`;function rp(e){return e.name!==e.savedName||e.rules!==e.savedRules}function Jg(e,t=""){return{name:e.name,savedName:e.name,rules:e.instructions?.text??"",savedRules:e.instructions?.text??"",updatedAt:e.updatedAt,rulesVersion:e.instructions?.version??"",rulesMemberId:t}}function JO(e,t){return{...Jg(t,t.sessionIds.includes(e.rulesMemberId)?e.rulesMemberId:""),name:e.name!==e.savedName?e.name:t.name,rules:e.rules!==e.savedRules?e.rules:t.instructions?.text??"",sessionIds:[...t.sessionIds]}}function eF(e,t){const r=Jg(e,t),n=v4(e.id);if(tp.has(n))return tp.get(n)??r;try{const a=sessionStorage.getItem(n);if(!a)return r;const c=JSON.parse(a);return typeof c.updatedAt!="number"||!Number.isFinite(c.updatedAt)||["name","rules","savedName","savedRules","rulesVersion","rulesMemberId"].some(l=>typeof c[l]!="string")||c.sessionIds!==void 0&&(!Array.isArray(c.sessionIds)||c.sessionIds.some(l=>typeof l!="string"))?r:rp(c)?c:r}catch{return r}}function tF(e,t){const r=v4(e);try{rp(t)?sessionStorage.setItem(r,JSON.stringify(t)):sessionStorage.removeItem(r),tp.delete(r)}catch{tp.set(r,rp(t)?t:null)}}function w4(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?e.slice(0,10):e}function yf(e,t){try{const r=`termdock-workbench:${window.location.origin}:${e}`;return t!==void 0&&localStorage.setItem(r,t),localStorage.getItem(r)}catch{return null}}function rF(){const e=yf("tab");return e==="automation"||e==="search"?e:"collaboration"}const Ys="w-full rounded-lg border border-border/20 bg-surface-2 px-3 py-2 text-[12px] text-foreground outline-none transition focus:border-primary/60",X1="inline-flex min-h-7 items-center justify-center rounded-md border px-2 py-1 text-[11px] leading-4 font-medium transition",Er="inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-40",vf=new WeakMap;function Xb(e){const[t,r]=b.useState(null),[n,a]=b.useState(!1),c=$i(m=>m.drafts),l=b.useCallback(m=>{const x=$i.getState();for(const[y,w]of Object.entries(m))x.drafts[y]||x.setDraft(y,w)},[]),d=b.useCallback((m,x,y)=>{if(JSON.stringify($i.getState().drafts[m])===JSON.stringify(x))return;const w={...x};y&&vf.set(w,y),$i.getState().setDraft(m,w)},[]),f={drafts:c,loadDrafts:l,updateDraft:d};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(Jb,{...e,...f,overlayObscured:!!t,onOpenOverlay:r,onClose:()=>{t?a(!0):e.onClose()}}),t&&s.jsx(Jb,{...e,...f,overlayOnly:!0,initialFloating:t==="floating",onFloatingChange:void 0,onOpenOverlay:r,onClose:()=>{r(null),n&&e.onClose()}})]})}function Jb({activeSessionId:e,initialCollaborationGroupId:t=null,initialFloating:r=!1,onFloatingChange:n,onEnterGroup:a,visible:c=!0,defaultSessionMode:l="shell",onClose:d,onNewSession:f,overlayOnly:m=!1,overlayObscured:x=!1,onOpenOverlay:y,drafts:w,loadDrafts:v,updateDraft:T}){const C=!!t,[L,N]=b.useState(r);b.useEffect(()=>{N(r)},[r]);const[D,O]=b.useState(!1),[P,F]=b.useState(t),ee=ss(Oe=>Oe.docks[t??"workbench"]),Z=ss(Oe=>Oe.hosts[t??"workbench"]),[G,de]=b.useState("docked"),[pe,J]=b.useState(null),[Re,Ze]=b.useState({x:16,y:80}),V=b.useRef(null),ve=b.useRef(null);b.useEffect(()=>{const Oe=V.current;Oe&&(x?(Oe.contains(document.activeElement)&&(ve.current=document.activeElement),Oe.inert=!0):(Oe.inert=!1,ve.current?.isConnected&&ve.current.focus({preventScroll:!0}),ve.current=null))},[x]),b.useEffect(()=>{if(!m||L)return;const Oe=V.current;Oe?.querySelector('button[aria-label="收起展开视图"]')?.focus({preventScroll:!0});const _t=gt=>{if(gt.key!=="Tab"||gt.defaultPrevented||!Oe)return;const Wt=Array.from(Oe.querySelectorAll('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], summary, [tabindex="0"]')).filter(Mn=>!Mn.closest("[hidden], [inert]")&&Mn.getClientRects().length>0),$t=Wt[0],Ar=Wt.at(-1),Sn=!Oe.contains(document.activeElement);gt.shiftKey&&(document.activeElement===$t||Sn)?(gt.preventDefault(),Ar?.focus()):!gt.shiftKey&&(document.activeElement===Ar||Sn)&&(gt.preventDefault(),$t?.focus())};return document.addEventListener("keydown",_t),()=>document.removeEventListener("keydown",_t)},[m,L]);const[qe]=b.useState(()=>document.createElement("div")),le=b.useRef({x:.5,y:.5}),[ye,Te]=b.useState(null),[Fe,se]=b.useState(null);b.useEffect(()=>{let Oe=!1;return Cc().then(_t=>{if(Oe)return;const gt=_3(_t.collaborationPanels?.[op()],t);gt.position&&(le.current=gt.position),gt.size&&J(gt.size),v(gt.drafts??{}),m||de(gt.mode??"docked"),Te(gt)}).catch(()=>{Oe||se("面板草稿加载失败,请重新打开面板重试")}),()=>{Oe=!0}},[]);const[De,_e]=b.useState(null);b.useEffect(()=>{const Oe=_t=>se(String(_t.detail));return window.addEventListener("termdock-panel-save-error",Oe),()=>{window.removeEventListener("termdock-panel-save-error",Oe),m||ss.getState().setDock(t??"workbench",null)}},[]);const Me=!m&&L&&G==="docked"&&!!Z;b.useLayoutEffect(()=>(qe.className=Me?"h-full min-h-0 w-full min-w-0":"contents",(Me?Z:document.body)?.appendChild(qe),()=>qe.remove()),[qe,Me,Z]),b.useEffect(()=>{!m&&!L&&ss.getState().setDock(t??"workbench",null)},[L]);const Ke=async Oe=>{if(m||D||Oe==="docked"&&!e)return;const _t={sessionId:e,side:"right"};O(!0);try{await Xa({mode:Oe,...Oe==="docked"?{dock:_t}:{}},t),de(Oe),ss.getState().setDock(t??"workbench",Oe==="docked"?{..._t,...C?{preferredWidth:360}:{}}:null)}catch{se("面板布局保存失败,请重试")}finally{O(!1)}},Ne=b.useRef(!1),ae=b.useRef(null),ze=b.useCallback((Oe,_t)=>{const gt=V.current?.getBoundingClientRect(),Wt=window.visualViewport,$t=(Wt?.offsetLeft??0)+12,Ar=(Wt?.offsetTop??0)+12;return{x:Math.max($t,Math.min(Oe,$t+(Wt?.width??window.innerWidth)-(gt?.width??440)-24)),y:Math.max(Ar,Math.min(_t,Ar+(Wt?.height??window.innerHeight)-(gt?.height??340)-24))}},[]),[at,ct]=b.useState(()=>t?"collaboration":rF()),[me,ut]=b.useState(()=>new Set([at])),ft=Oe=>{ct(Oe),ut(_t=>new Set([..._t,Oe])),jt(null),Bt(null),!t&&!m&&yf("tab",Oe)},[Se,He]=b.useState([]),[ke,z]=b.useState([]),[ie,ge]=b.useState([]),[We,tt]=b.useState([]),[wt,Zt]=b.useState([]),[Ut,Mt]=b.useState(null),[nr,jt]=b.useState(null),[Xt,Bt]=b.useState(null);b.useEffect(()=>{if(!Xt)return;const Oe=setTimeout(()=>Bt(null),5e3);return()=>clearTimeout(Oe)},[Xt]);const[Ht,xe]=b.useState("loading"),[Je,ot]=b.useState("loading"),[Nt,K]=b.useState(null),[xt,tr]=b.useState(null),[$e,Qr]=b.useState(),[Ce,St]=b.useState(null),Ot=b.useRef(null),Jt=b.useRef(null),lt=b.useRef(null),Ct=t?We.find(Oe=>Oe.id===t)??null:null,ar=b.useRef(!1);b.useEffect(()=>{if(t||Ht!=="loaded"||ar.current)return;ar.current=!0;const Oe=yf("group"),_t=We.find(gt=>gt.id===Oe)??We.find(gt=>e&&gt.sessionIds.includes(e))??We[0];F(gt=>gt??_t?.id??null)},[t,Ht,We,e]),b.useEffect(()=>{!t&&!m&&P&&We.some(Oe=>Oe.id===P)&&yf("group",P)},[P,We,t,m]);const _r=P?We.find(Oe=>Oe.id===P)??null:We[0]??null,Nr=!!t&&Ht==="loaded"&&!Ct,zr=!!ye||!!Fe,Tt=!m&&L&&G==="docked"&&!!(ee??ye?.dock)&&!Z,Ft=c&&zr&&!Tt&&!!e&&(!t||!!Z||!!_r?.sessionIds.includes(e)||!!t&&(Ht!=="loading"&&!Ct||!!Fe));b.useLayoutEffect(()=>{if(!L||Me||!Ft)return;const Oe=()=>{const gt=window.visualViewport;_e(gt?.height??window.innerHeight);const Wt=V.current?.getBoundingClientRect();!Wt?.width||!Wt.height||Ne.current||Ze(ze((gt?.offsetLeft??0)+12+Math.max(0,(gt?.width??window.innerWidth)-Wt.width-24)*le.current.x,(gt?.offsetTop??0)+12+Math.max(0,(gt?.height??window.innerHeight)-Wt.height-24)*le.current.y))},_t=new ResizeObserver(Oe);return V.current&&_t.observe(V.current),window.addEventListener("resize",Oe),window.visualViewport?.addEventListener("resize",Oe),Oe(),()=>{_t.disconnect(),window.removeEventListener("resize",Oe),window.visualViewport?.removeEventListener("resize",Oe)}},[L,Me,Ft,ze,ye,pe]),b.useLayoutEffect(()=>{if(m)return;const Oe=t??"workbench",_t=ss.getState();if(Nr)_t.docks[Oe]&&_t.setDock(Oe,null);else if(zr&&L&&G==="docked"&&e&&(!t||Ct)){const gt=_t.docks[Oe],Wt=!t||Ct?.sessionIds.includes(e)?e:wt.find(Sn=>Ct?.sessionIds.includes(Sn.sessionId)&&!nd(Sn.sessionId))?.sessionId??e,$t=gt??ye?.dock??{sessionId:Wt,side:window.innerWidth<640?"bottom":"right"},Ar={...$t,sessionId:Ct?.sessionIds.includes(e)?e:$t.sessionId,...C?{preferredWidth:gt?.preferredWidth??360}:{}};(!gt||Ar.sessionId!==gt.sessionId||Ar.preferredWidth!==gt.preferredWidth)&&_t.setDock(Oe,Ar),C&&gt&&Ar.sessionId!==gt.sessionId&&Xa({dock:{sessionId:Ar.sessionId,side:Ar.side}},t).catch(()=>se("协作位置保存失败,当前面板仍可使用"))}},[Nr,Ct,L,G,ye,zr,e,t,ee,wt]);const we=async(Oe,_t=!1)=>{if(!(D||Oe&&!_r)){if(!m&&!Oe&&!_t&&ee){y("full");return}if(m){_t?d():(N(Oe),y(Oe?"floating":"full"));return}O(!0);try{await n?.(Oe?_r.id:null),N(Oe),Oe&&G==="docked"&&e&&ss.getState().setDock(t??"workbench",{sessionId:e,side:ee?.side??ye?.dock?.side??"right"}),_t&&d()}catch(gt){jt(`常驻浮窗状态保存失败,请重试:${gt instanceof Error?gt.message:"连接失败"}`)}finally{O(!1)}}},At=b.useCallback(Oe=>{tt(Oe.groups),Zt(Oe.sessions),Qr(Oe.peers),tr(null),xe("loaded")},[]);b.useEffect(()=>r3(At),[At]);const st=b.useCallback(async(Oe={})=>{Oe.silent||jt(null),!C&&!Jt.current&&(Jt.current=i9().then(_t=>{He(_t.automations),z(_t.runs),ot("loaded"),K(null)}).catch(_t=>{ot("error"),K(_t instanceof Error?_t.message:"自动任务加载失败")}).finally(()=>{Jt.current=null})),lt.current||(lt.current=Ky().then(_t=>{ge(_t),St(null)}).catch(()=>{St("Agent 命令检测失败;已有会话可继续协作。")}).finally(()=>{lt.current=null})),Ot.current||(xe(_t=>_t==="error"?"loading":_t),Ot.current=sg().then(At).catch(_t=>{xe("error"),tr(`协作会话加载失败:${_t instanceof Error?_t.message:"请重试"}`)}).finally(()=>{Ot.current=null})),await Promise.all([Ot.current,Jt.current])},[At,C]);b.useEffect(()=>ou(()=>{st({silent:!0})},1e4,["focus",k0,"pageshow"]),[st]),b.useEffect(()=>{const Oe=_t=>{_t.key==="Escape"&&!_t.defaultPrevented&&!L&&d()};return window.addEventListener("keydown",Oe),()=>window.removeEventListener("keydown",Oe)},[d,L]);const bt=Oe=>{C&&Oe&&Oe!==t&&We.some(_t=>_t.id===Oe)&&a?a(Oe).catch(_t=>jt(_t instanceof Error?_t.message:"无法打开工作区")):F(Oe)},Tn=async Oe=>{await hF(Oe)},bn=!L&&!C&&at==="collaboration",nn=async(Oe,_t)=>{if(!Ut){Mt(`open-group:${Oe}`),jt(null);try{await a?.(Oe),$i.getState().open(Oe,_t),d()}catch(gt){jt(gt instanceof Error?gt.message:"无法打开协作组,请重试")}finally{Mt(null)}}};return ci.createPortal(s.jsxs(s.Fragment,{children:[!L&&s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:d,"aria-label":"关闭 Agent 工作台"}),s.jsxs("section",{"data-sidebar-gesture-ignore":!0,onPointerDown:Oe=>{Me&&Oe.stopPropagation()},ref:V,role:m&&!L?"dialog":void 0,"aria-modal":m&&!L?!0:void 0,"aria-hidden":x||void 0,"aria-label":Me?"工作组消息分屏":L?"工作组消息浮窗":"Agent 工作台",style:c?L&&!Me?{display:Ft?void 0:"none",left:Re.x,top:Re.y,...pe?{width:`min(calc(100vw - 24px), max(280px, ${pe.width*100}vw))`,height:`min(calc(100dvh - 24px), max(220px, ${pe.height*100}dvh))`}:{},maxHeight:De?De-24:"calc(100dvh - 24px)"}:void 0:{display:"none"},className:Me?"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface":L?"fixed z-menu-panel flex w-[min(400px,calc(100vw-24px))] flex-col overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-xl":`fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))] ${bn?"max-h-[calc(var(--app-visible-vh,100dvh)-max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))-max(1.5rem,env(safe-area-inset-bottom,0px)))]":"h-[calc(var(--app-visible-vh,100dvh)-max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))-max(1.5rem,env(safe-area-inset-bottom,0px)))]"} z-modal-panel mx-auto flex ${C?"max-w-6xl":"max-w-3xl"} flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[calc(var(--app-visible-vh,100dvh)*0.08)] ${bn?"sm:max-h-[calc(var(--app-visible-vh,100dvh)*0.84)]":"sm:h-[calc(var(--app-visible-vh,100dvh)*0.84)]"}`,children:[s.jsxs("header",{"data-pane-titlebar":Me?"true":void 0,"data-panel-drag-title":Me?"true":void 0,onDragStart:Oe=>Oe.preventDefault(),className:`flex items-center gap-2 border-b border-border/15 ${Me?"min-h-9 shrink-0 cursor-grab select-none bg-[var(--chrome-bg)] px-3 active:cursor-grabbing":L?"px-3 py-2 cursor-move touch-none select-none":"px-4 py-3"}`,onPointerDown:Oe=>{!L||Me||Oe.button!==0||Oe.target.closest("button, summary")||(ae.current={x:Oe.clientX,y:Oe.clientY,left:Re.x,top:Re.y},Oe.currentTarget.setPointerCapture?.(Oe.pointerId))},onPointerMove:Oe=>{ae.current&&Ze(ze(ae.current.left+Oe.clientX-ae.current.x,ae.current.top+Oe.clientY-ae.current.y))},onPointerUp:()=>{if(!ae.current)return;ae.current=null;const Oe=V.current?.getBoundingClientRect(),_t=window.visualViewport;Oe&&(le.current=$x(Re.x,Re.y,(_t?.offsetLeft??0)+12,(_t?.offsetTop??0)+12,(_t?.width??window.innerWidth)-Oe.width-24,(_t?.height??window.innerHeight)-Oe.height-24),Xa({position:le.current},t).catch(()=>se("浮窗位置保存失败,请重新拖动重试")))},onPointerCancel:()=>{ae.current=null},children:[s.jsx(G0,{size:Me?13:17,className:"shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:`${L?"truncate text-[12px]":"text-[14px]"} font-semibold text-foreground`,title:Me?"拖动标题移动面板;放在边缘拆分,中央交换":Ct?.name,children:Ct?Ct.name:t?"协作工作区":"Agent 工作台"}),!Me&&!C&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:L?"引用、文件路径和粘贴优先加入此处":Ct?"分派任务、回答问题、审阅与验收结果":"自动任务、会话协作与历史搜索"})]}),!Me&&!m&&C&&at==="collaboration"&&We.length>0&&s.jsx("button",{className:`${Er} shrink-0 text-primary hover:bg-primary/10`,disabled:D,onClick:()=>{we(!L)},children:L?"展开":"放到终端旁"}),C&&Ct&&s.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[Ct.sessionIds.length," 人"]}),Me&&!a&&s.jsx("button",{type:"button","aria-label":"展开协作工作区",title:"展开查看目标与交付",disabled:D,className:"flex min-h-11 shrink-0 items-center justify-center rounded-lg px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>y("full"),children:s.jsx(OA,{size:15})}),Me&&s.jsxs("details",{className:"relative z-20 shrink-0",children:[s.jsx("summary",{"aria-label":"面板布局",title:"面板布局",className:"flex min-h-8 cursor-pointer list-none items-center rounded px-2 text-muted-foreground hover:bg-surface-2 [&::-webkit-details-marker]:hidden",children:s.jsx(Ro,{size:16})}),s.jsx("div",{className:"absolute right-0 top-full z-30 w-36 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:s.jsxs("button",{type:"button",disabled:D,className:`${Er} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Oe=>{Oe.currentTarget.closest("details")?.removeAttribute("open"),Ke("floating")},children:[s.jsx(Zc,{size:14}),"小浮窗"]})})]}),s.jsx("button",{className:`${Me?"min-h-8 rounded px-2":"rounded-lg p-2"} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,disabled:D,onClick:()=>{L?we(!1,!0):d()},"aria-label":m?"收起展开视图":"关闭",children:s.jsx(Dn,{size:16})})]}),L&&!Me&&!m&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:D,"aria-pressed":G==="floating",className:`${X1} ${G==="floating"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Ke("floating")},children:"浮窗"}),s.jsx("button",{type:"button",disabled:D||!e||Nr,"aria-pressed":G==="docked",className:`${X1} ${G==="docked"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Ke("docked")},children:"放到终端旁"})]}),!C&&(!L||Me)&&s.jsx("nav",{"aria-label":"工作台功能",className:"grid shrink-0 grid-cols-3 gap-1 border-b border-border/15 px-2 py-1",children:[["collaboration",sd,"协作组"],["automation",I0,"自动任务"],["search",Yl,"历史搜索"]].map(([Oe,_t,gt])=>s.jsxs("button",{type:"button","aria-pressed":at===Oe,"aria-controls":`workbench-${Oe}`,onClick:()=>ft(Oe),className:`${Er} ${at===Oe?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(_t,{size:14}),gt]},Oe))}),at==="collaboration"&&xt&&s.jsxs("div",{role:"alert",className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[xt,s.jsx("button",{className:`${Er} ml-2`,onClick:()=>{st()},children:"重新加载会话"})]}),!C&&at!=="search"&&Ce&&s.jsx("div",{className:"mx-4 mt-3 text-[11px] text-muted-foreground",children:Ce}),nr&&s.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:nr}),Xt&&(!L||Me)&&s.jsxs("div",{role:"status",className:"mx-3 mt-2 flex items-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-[11px] text-primary",children:[s.jsx(Ci,{size:13}),Xt]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[me.has("automation")&&s.jsx("div",{id:"workbench-automation",className:at==="automation"?"h-full min-h-0 p-4":"hidden",children:s.jsx(nF,{automations:Se,runs:ke,agents:ie,sessions:wt.filter(Oe=>!nd(Oe.sessionId)),activeSessionId:e,loading:Je==="loading",loadError:Nt,busy:Ut,setBusy:Mt,setError:jt,setNotice:Bt,refresh:st,onClose:d})}),me.has("collaboration")&&s.jsxs("div",{id:"workbench-collaboration",className:at==="collaboration"?`flex-1 min-h-0 overflow-x-hidden overflow-y-auto overscroll-y-contain ${L?"p-3":"p-4"}`:"hidden",children:[!ye&&!Fe&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息面板…"}),t&&!Ct&&s.jsxs("div",{role:"status",className:"space-y-2 text-[11px] text-muted-foreground",children:[s.jsx("p",{children:Ht==="loading"?"正在加载协作组…":Ht==="error"?"协作组加载失败,恢复连接后可重试。":"此协作组暂不可用,已释放分屏位置。草稿和布局偏好仍保留。"}),Ht!=="loading"&&s.jsx("button",{className:Er,onClick:()=>{st()},children:"重新加载"})]}),Fe&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:Fe}),ye&&(!t||Ct)&&s.jsx(iF,{active:at==="collaboration",notice:Xt,initialDrafts:w,onDraftChange:T,docked:Me,inputKeySuffix:m?":overlay":"",selectedGroupId:P,setSelectedGroupId:bt,floatingVisible:Ft,floating:L,sessionsState:Ht,groups:We,sessions:wt,agents:ie,activeSessionId:e,initialGroupId:t,onOpenSession:async Oe=>{await Tn(Oe),L||d()},onOpenTaskSession:Tn,onEnterGroup:a,onOpenGroup:nn,defaultSessionMode:l,busy:Ut,setBusy:Mt,setError:jt,setNotice:Bt,refresh:st}),!C&&$e&&s.jsx(oF,{peers:$e,currentGroupId:P==="new"?void 0:_r?.id,busy:Ut,setBusy:Mt,setError:jt,setNotice:Bt,onSelectGroup:Oe=>{nn(Oe,"messages")}})]}),me.has("search")&&s.jsx("div",{id:"workbench-search",className:at==="search"?"h-full min-h-0 overflow-y-auto overscroll-y-contain p-4":"hidden",children:s.jsx(xF,{active:at==="search",onClose:d,onNewSession:f,setError:jt})})]}),L&&!Me&&s.jsx("button",{type:"button","aria-label":"调整协作浮窗大小",className:"absolute bottom-0 right-0 h-4 w-4 cursor-nwse-resize touch-none text-muted-foreground hover:text-primary",onPointerDown:Oe=>{Oe.preventDefault(),Ne.current=!0,Oe.currentTarget.setPointerCapture(Oe.pointerId)},onPointerMove:Oe=>{if(!Oe.currentTarget.hasPointerCapture(Oe.pointerId))return;const _t=window.visualViewport,gt=_t?.width??window.innerWidth,Wt=_t?.height??window.innerHeight;J({width:Math.min(1,Math.max(280,Oe.clientX-Re.x)/gt),height:Math.min(1,Math.max(220,Oe.clientY-Re.y)/Wt)})},onPointerUp:()=>{Ne.current=!1;const Oe=V.current?.getBoundingClientRect(),_t=window.visualViewport;Oe&&(le.current=$x(Re.x,Re.y,(_t?.offsetLeft??0)+12,(_t?.offsetTop??0)+12,(_t?.width??window.innerWidth)-Oe.width-24,(_t?.height??window.innerHeight)-Oe.height-24)),pe&&Xa({size:pe,position:le.current},t).catch(()=>se("浮窗大小保存失败,请重新调整重试"))},onPointerCancel:()=>{Ne.current=!1},onKeyDown:Oe=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Oe.key))return;Oe.preventDefault();const _t=V.current?.getBoundingClientRect(),gt={width:Math.max(.15,Math.min(1,(pe?.width??(_t?.width??400)/window.innerWidth)+(Oe.key==="ArrowRight"?.03:Oe.key==="ArrowLeft"?-.03:0))),height:Math.max(.15,Math.min(1,(pe?.height??(_t?.height??300)/window.innerHeight)+(Oe.key==="ArrowDown"?.03:Oe.key==="ArrowUp"?-.03:0)))};J(gt),Xa({size:gt},t).catch(()=>se("浮窗大小保存失败,请重试"))},children:s.jsx("span",{"aria-hidden":"true",children:"⌟"})})]})]}),qe)}function nF({automations:e,runs:t,agents:r,sessions:n,activeSessionId:a,loading:c,loadError:l,busy:d,setBusy:f,setError:m,setNotice:x,refresh:y,onClose:w}){const[v,T]=b.useState(null),[C,L]=b.useState(!1),[N,D]=b.useState(null),O=async(P,F,ee)=>{f(P),m(null),x(null);try{await F(),await y(),x(ee)}catch(Z){m(Z instanceof Error?Z.message:"操作失败")}finally{f(null)}};return C?s.jsx(sF,{agents:r,sessions:n,activeSessionId:a,initial:v,onCancel:()=>{T(null),L(!1),m(null)},onSaved:async(P,F)=>{T(null),L(!1),await y(),x(v?`“${P}”已更新`:F?`“${P}”已创建,将按计划自动运行`:`“${P}”已创建,当前未启用`)},setError:m},v?.id??"new"):s.jsxs("div",{className:"h-full space-y-4 overflow-y-auto overscroll-y-contain",children:[l&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["自动任务同步失败:",l,s.jsx("button",{className:Er,onClick:()=>{y()},children:"重新加载"})]}),s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"自动任务"}),s.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"定时发送任务,打开运行会话查看输出。"})]}),!C&&e.length>0&&s.jsxs("button",{className:`${Er} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{T(null),L(!0),x(null)},children:[s.jsx(Xs,{size:13}),"新建任务"]})]}),c&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在加载自动任务…"}),!c&&!l&&e.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx(rT,{size:24,className:"mx-auto text-primary"}),s.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"把重复工作交给 Agent"}),s.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[11px] leading-relaxed text-muted-foreground",children:"写清任务内容,选择运行频率。创建后可以先手动运行一次确认效果。"}),s.jsxs("button",{className:`${Er} mt-4 bg-primary text-primary-foreground`,onClick:()=>L(!0),children:[s.jsx(Xs,{size:13}),"创建第一个任务"]})]}),s.jsx("div",{className:"space-y-2",children:e.map(P=>{const F=t.filter(Z=>Z.automationId===P.id).sort((Z,G)=>G.startedAt-Z.startedAt)[0],ee=r.find(Z=>Z.command===P.command);return s.jsxs("article",{className:"rounded-xl border border-border/15 bg-surface-2/40 p-3 transition hover:border-border/30",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:P.name}),s.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${P.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:P.enabled?"已启用":"已停用"}),P.lastRunStatus&&s.jsx("span",{className:`text-[10px] ${AF(P.lastRunStatus)}`,children:wF(P.lastRunStatus)})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(I0,{size:11}),yF(P)]}),s.jsx("span",{children:P.enabled&&P.nextRunAt?`下次 ${sp(P.nextRunAt)}`:"不会自动运行"})]}),s.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:P.targetSessionId?`发送到 ${n.find(Z=>Z.sessionId===P.targetSessionId)?.name??"指定会话"}`:`新建 ${ee?.displayName??"Agent"} 会话 · ${P.cwd}`}),s.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:P.prompt}),P.lastRunAt&&s.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",sp(P.lastRunAt),P.lastRunMessage?` · ${P.lastRunMessage}`:""]})]}),s.jsx("button",{"aria-label":`编辑 ${P.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{T(P),L(!0),x(null)},children:s.jsx(Zu,{size:13})})]}),s.jsx("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border/10 pt-3",children:N===P.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),s.jsx("button",{className:`${Er} bg-surface-elevated text-foreground`,onClick:()=>D(null),children:"取消"}),s.jsxs("button",{disabled:d!==null,className:`${Er} bg-destructive text-destructive-foreground`,onClick:()=>{O(`delete:${P.id}`,()=>l9(P.id),`“${P.name}”已删除`).then(()=>D(null))},children:[d===`delete:${P.id}`?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(zs,{size:13}),"确认删除"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`${Er} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>D(P.id),children:[s.jsx(zs,{size:13}),"删除"]}),s.jsxs("button",{disabled:d!==null,className:`${Er} ${P.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{O(`toggle:${P.id}`,()=>c9(P.id,!P.enabled),P.enabled?`“${P.name}”已暂停,不会自动运行`:`“${P.name}”已恢复,将按原计划运行`)},children:[d===`toggle:${P.id}`?s.jsx(An,{size:13,className:"animate-spin"}):P.enabled?s.jsx(mS,{size:13}):s.jsx(_f,{size:13}),P.enabled?"暂停":"恢复"]}),F?.frontendSessionId&&s.jsxs("button",{className:`${Er} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:F.frontendSessionId})),w()},children:[s.jsx(Zc,{size:13}),"打开上次会话"]}),s.jsxs("button",{disabled:d!==null,className:`${Er} bg-primary/15 text-primary`,onClick:()=>{O(`run:${P.id}`,()=>u9(P.id),`“${P.name}”已投递,可打开会话查看进度`)},children:[d===`run:${P.id}`?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(_f,{size:13}),"立即运行"]})]})})]},P.id)})})]})}function sF({agents:e,sessions:t,activeSessionId:r,initial:n,onCancel:a,onSaved:c,setError:l}){const[d,f]=b.useState(n?.name??""),m=t.find(z=>z.sessionId===r),x=n?.cwd??m?.cwd??t[0]?.cwd??"",[y,w]=b.useState(x),v=b.useRef(!1),[T,C]=b.useState(!1),[L,N]=b.useState(()=>e.find(z=>z.command===n?.command)?.slug??""),[D,O]=b.useState(n?.prompt??""),[P,F]=b.useState(n?.targetSessionId??""),[ee,Z]=b.useState(n?.targetSessionId?"existing":"new"),[G,de]=b.useState(n?.schedule.kind??"interval"),[pe,J]=b.useState(n?.schedule.kind==="interval"?n.schedule.everyMinutes:60),[Re,Ze]=b.useState(n?.schedule.kind==="daily"?n.schedule.time:"09:00"),[V,ve]=b.useState(n?.schedule.kind==="daily"?n.schedule.weekdays:[1,2,3,4,5]),[qe,le]=b.useState(()=>n?.schedule.kind==="interval"?![15,60,1440].includes(n.schedule.everyMinutes):!!n&&!["1,2,3,4,5","0,1,2,3,4,5,6"].includes([...n.schedule.weekdays].sort().join())),[ye,Te]=b.useState(!1),[Fe,se]=b.useState(n?.enabled??!0),[De,_e]=b.useState(!1),Me=e.find(z=>z.slug===L)??null,Ke=Me?.command??n?.command??"";b.useEffect(()=>{if(!L){const z=n?e.find(ie=>ie.command===n.command):e[0];z&&N(z.slug)}},[e,n,L]),b.useEffect(()=>{!n&&!v.current&&x&&w(x)},[n,x]);const Ne=d.trim()||Array.from(D.trim().split(`
157
+ `)[0].trim()).slice(0,40).join(""),ae=t.find(z=>z.sessionId===P),ze=qe?`custom-${G}`:G==="interval"?String(pe):V.length===7?"daily":"workdays",at=z=>{le(z.startsWith("custom-")),["15","60","1440","custom-interval"].includes(z)?(de("interval"),z!=="custom-interval"&&J(Number(z))):(de("daily"),z==="daily"&&ve([0,1,2,3,4,5,6]),z==="workdays"&&ve([1,2,3,4,5]))},ct=async()=>{if(!(De||!ke)){_e(!0),l(null);try{await g9({id:n?.id,name:Ne,cwd:y,command:ee==="new"?Ke:"",prompt:D,targetSessionId:ee==="existing"&&P||null,enabled:Fe,schedule:G==="interval"?{kind:G,everyMinutes:pe}:{kind:G,time:Re,weekdays:V}}),await c(Ne,Fe)}catch(z){l(z instanceof Error?z.message:"保存失败")}finally{_e(!1)}}},me=G==="interval"?{kind:G,everyMinutes:pe}:{kind:G,time:Re,weekdays:V},[ut,ft]=Re.split(":"),Se=(z,ie)=>Ze(`${z}:${ie}`),He=D.trim()?ee==="existing"&&!t.some(z=>z.sessionId===P)?"请选择当前服务的可用会话":ee==="new"&&!Ke?"请选择可启动的 Agent":G==="interval"&&(!Number.isInteger(pe)||pe<1||pe>43200)?"间隔需要是 1–43200 分钟的整数":G==="daily"&&!V.length?"至少选择一天":"":"请填写任务内容",ke=!He;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 pb-3",children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:n?"编辑自动任务":"创建自动任务"}),s.jsx("button",{disabled:De,className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",onClick:a,"aria-label":"关闭任务表单",children:s.jsx(Dn,{size:14})})]}),s.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-y-contain pb-4",children:s.jsxs("fieldset",{disabled:De,className:"min-w-0 space-y-4",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["任务内容",s.jsx("textarea",{autoFocus:!0,className:`${Ys} min-h-24 resize-y`,rows:3,value:D,onChange:z=>O(z.target.value),placeholder:"例如:检查当前项目的待办,整理需要我处理的问题。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["运行频率",s.jsxs("select",{className:Ys,value:ze,onChange:z=>at(z.target.value),children:[s.jsx("option",{value:"15",children:"每 15 分钟"}),s.jsx("option",{value:"60",children:"每小时"}),s.jsx("option",{value:"1440",children:"每 24 小时"}),s.jsx("option",{value:"daily",children:"每天定时"}),s.jsx("option",{value:"workdays",children:"工作日定时"}),s.jsx("option",{value:"custom-interval",children:"自定义间隔"}),s.jsx("option",{value:"custom-daily",children:"自定义星期"})]})]}),G==="interval"&&qe&&s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["每隔多少分钟",s.jsx("input",{className:`${Ys} min-w-0 flex-1`,type:"number",min:1,max:43200,value:pe,onChange:z=>J(Number(z.target.value))})]}),G==="daily"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center rounded-lg border border-border/20 bg-surface-2 px-3 py-1.5 focus-within:border-primary/60",children:[s.jsx(I0,{size:14,className:"mr-2 shrink-0 text-primary"}),s.jsx(ey,{label:"小时",value:ut,options:24,onChange:z=>Se(z,ft)}),s.jsx("span",{"aria-hidden":"true",className:"px-2 text-[16px] text-muted-foreground",children:":"}),s.jsx(ey,{label:"分钟",value:ft,options:60,onChange:z=>Se(ut,z)}),s.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:"24 小时制"})]}),qe&&s.jsx("div",{className:"grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((z,ie)=>{const ge=V.includes(ie);return s.jsx("button",{type:"button","aria-pressed":ge,"aria-label":`星期${z}`,className:`rounded-lg py-2.5 text-[11px] transition ${ge?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>ve(We=>ge?We.filter(tt=>tt!==ie):[...We,ie].sort()),children:z},ie)})}),V.length===0&&s.jsx("p",{className:"text-[10px] text-destructive",children:"至少选择一天"})]})]}),s.jsxs("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx(G0,{size:13,className:"shrink-0"}),ee==="new"?`每次新建会话 · ${Me?.displayName??(n?.command?"原 Agent":"暂无可用 Agent")}`:`发送到现有会话 · ${ae?.name??"目标会话不可用"}`]}),s.jsx("p",{className:"break-all pl-[19px] text-[10px]",children:ee==="new"?y||"默认使用当前目录":"直接写入终端,目标会话需保持在线"})]}),s.jsxs("div",{className:"border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button","aria-expanded":ye,"aria-controls":"automation-more-settings",className:`${Er} -ml-2 px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>Te(z=>!z),children:[s.jsx(Cl,{size:13,className:`transition-transform ${ye?"rotate-180":""}`}),"更多设置"]}),ye&&s.jsxs("div",{id:"automation-more-settings",className:"space-y-3 pt-2",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务名称(可选)",s.jsx("input",{className:Ys,value:d,onChange:z=>f(z.target.value),placeholder:Ne||"留空则从任务内容自动生成"})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["运行方式",s.jsxs("select",{className:Ys,value:ee,onChange:z=>{const ie=z.target.value;Z(ie),ie==="existing"&&!P&&F(m?.sessionId??t[0]?.sessionId??"")},children:[s.jsx("option",{value:"new",children:"每次新建会话"}),s.jsx("option",{value:"existing",disabled:t.length===0,children:"发送到现有会话"})]})]}),ee==="new"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["Agent / Plugin",s.jsxs("select",{className:Ys,value:L,onChange:z=>N(z.target.value),children:[n&&!e.some(z=>z.command===n.command)&&s.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(z=>s.jsxs("option",{value:z.slug,children:[z.displayName,z.isPlugin?" · Plugin":""]},z.slug))]})]}),s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["工作目录",s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${Ys} min-w-0`,value:y,onChange:z=>{v.current=!0,w(z.target.value)},placeholder:"默认使用当前目录"}),s.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${Er} shrink-0 bg-surface-2 text-foreground`,onClick:()=>C(!0),children:[s.jsx(Ku,{size:13}),"选择"]})]})]})]}),e.length===0&&s.jsx("p",{className:"text-[10px] text-destructive",children:"没有检测到可启动的 Agent。请先在 Plugin 设置中安装或配置 Agent。"})]}):s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["目标会话",s.jsxs("select",{className:Ys,value:P,onChange:z=>F(z.target.value),children:[!ae&&s.jsx("option",{value:P,children:P?"原目标会话不可用,请重新选择":"请选择会话"}),t.map(z=>s.jsxs("option",{value:z.sessionId,children:[z.name," · ",wf(z)]},z.sessionId))]}),s.jsx("span",{className:"block leading-relaxed",children:"仅支持当前服务的会话。运行时会直接写入终端,请确保目标会话保持在线。"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Fe,onChange:z=>se(z.target.checked)}),"保存后启用"]})]})]})]})}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-border/15 pt-3",children:[s.jsx("p",{role:"status",className:"mr-auto min-w-0 flex-[1_1_160px] text-[10px] text-muted-foreground",children:He||(Fe?`${n?"下次运行":"首次运行"}:${sp(vF(me,Date.now(),n?.createdAt))}`:"保存后暂停,不会自动运行")}),s.jsx("button",{disabled:De,className:`${Er} bg-surface-2 text-foreground`,onClick:a,children:"取消"}),s.jsx("button",{title:He||void 0,disabled:De||!ke,className:`${Er} bg-primary text-primary-foreground`,onClick:()=>{ct()},children:De?"保存中…":n?"保存修改":"创建任务"})]}),s.jsx(wp,{open:T,initialPath:y||x||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>C(!1),onConfirm:z=>{v.current=!0,w(z),C(!1)}})]})}function ey({label:e,value:t,options:r,onChange:n}){return s.jsxs("label",{className:"relative min-w-0 flex-1",children:[s.jsx("span",{className:"sr-only",children:e}),s.jsx("select",{"aria-label":e,className:"w-full appearance-none bg-transparent py-1 pl-1 pr-7 text-center text-[18px] font-semibold tabular-nums text-foreground outline-none",value:t,onChange:a=>n(a.target.value),children:Array.from({length:r},(a,c)=>{const l=String(c).padStart(2,"0");return s.jsx("option",{value:l,children:l},l)})}),s.jsx(Cl,{"aria-hidden":"true",size:13,className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground"})]})}function iF({fullWorkspace:e=!1,initialView:t="tasks",onOpenGroup:r,active:n,notice:a,initialDrafts:c,onDraftChange:l,docked:d,inputKeySuffix:f,selectedGroupId:m,setSelectedGroupId:x,floatingVisible:y,floating:w,sessionsState:v,groups:T,sessions:C,agents:L,activeSessionId:N,initialGroupId:D,onOpenSession:O,onOpenTaskSession:P,onEnterGroup:F,onDockMessages:ee,defaultSessionMode:Z,busy:G,setBusy:de,setError:pe,setNotice:J,refresh:Re}){const Ze=w&&!!D&&!!F&&!e,[V,ve]=b.useState(()=>Ze?"messages":t);b.useEffect(()=>{e&&ve(t)},[t,e]);const[qe,le]=b.useState(!1),[ye,Te]=b.useState(0);b.useEffect(()=>Te(0),[m]);const[Fe,se]=b.useState(""),[De,_e]=b.useState(()=>new Set),[Me,Ke]=b.useState(""),[Ne,ae]=b.useState(()=>new Set),[ze,at]=b.useState(!1),[ct,me]=b.useState(),[ut,ft]=b.useState([]),[Se,He]=b.useState(!1),[ke,z]=b.useState(null),ie=Jy(),[ge,We]=b.useState(null),[tt,wt]=b.useState(""),[Zt,Ut]=b.useState(!1),[Mt,nr]=b.useState(!1),jt=b.useRef(null),Xt=b.useRef(null),Bt=b.useRef(null),Ht=()=>{Bt.current=null,nr(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>{Xt.current?.isConnected&&Xt.current.getClientRects().length?Xt.current.focus():Array.from(jt.current?.querySelectorAll('button[aria-label="组设置"], button[aria-label="更多看板操作"], summary[aria-label="更多协作操作"]')??[]).find(Y=>Y.getClientRects().length)?.focus()}))},[xe,Je]=b.useState(null),[ot,Nt]=b.useState(new Set),[K,xt]=b.useState(),[tr,$e]=b.useState({}),[Qr,Ce]=b.useState(!1),[St,Ot]=b.useState(""),[Jt,lt]=b.useState(""),[Ct,ar]=b.useState(""),[_r,Nr]=b.useState(""),[zr,Tt]=b.useState(""),Ft=b.useRef(null),we=d,At=(m??T[0]?.id??"")+f,st=b.useRef(!1),bt=m==="new"?null:(m?T.find(Y=>Y.id===m):T[0])??null,Tn=bt?.sessionIds.flatMap(Y=>{const Be=C.find(Qt=>Qt.sessionId===Y);return Be?[Be]:[]})??[],[bn,nn]=b.useState(0),Oe=b.useRef(new Map(Object.entries(c??{}))),[_t]=b.useState(()=>({})),gt=b.useRef(void 0),Wt=b.useRef(!1),$t=b.useRef(ge);$t.current=ge;const Ar=b.useRef(tt);Ar.current=tt,b.useLayoutEffect(()=>{if(gt.current===bt?.id)return;if(gt.current){const Be={content:Ar.current,targets:ge};Oe.current.set(gt.current,Be),Xa({drafts:{[gt.current]:Be}}).catch(()=>pe("草稿保存失败,请返回该组重试"))}gt.current=bt?.id,Wt.current=!0;const Y=Oe.current.get(bt?.id??"");wt(Y?.content??""),We(Y?.targets??null)},[bt?.id]),b.useEffect(()=>{Je(null)},[bt?.id]);const Sn=b.useRef(null),Mn=b.useRef(c);b.useLayoutEffect(()=>{if(Mn.current===c)return;Mn.current=c;for(const[Be,Qt]of Object.entries(c??{}))vf.get(Qt)!==_t&&Oe.current.set(Be,Qt);const Y=c?.[bt?.id??""];!Y||vf.get(Y)===_t||Y.content===Ar.current&&JSON.stringify(Y.targets)===JSON.stringify($t.current)||(Wt.current=!0,Sn.current=null,wt(Y.content),We(Y.targets))},[c,bt?.id]);const vn=b.useCallback(Y=>{Xa(Y).catch(()=>pe("草稿保存失败,请保持面板打开,修改内容后重试"))},[pe]);b.useLayoutEffect(()=>{if(Wt.current){Wt.current=!1;return}if(!bt||gt.current!==bt.id)return;const Y={drafts:{[bt.id]:{content:tt,targets:ge}}};vf.set(Y.drafts[bt.id],_t),l(bt.id,Y.drafts[bt.id],_t),Sn.current=Y;const Be=setTimeout(()=>{Sn.current=null,vn(Y)},400);return()=>{clearTimeout(Be)}},[bt?.id,tt,ge,vn]),b.useEffect(()=>{const Y=()=>{Sn.current&&(vn(Sn.current),Sn.current=null)},Be=()=>{document.visibilityState==="hidden"&&Y()};return document.addEventListener("visibilitychange",Be),window.addEventListener("pagehide",Y),()=>{document.removeEventListener("visibilitychange",Be),window.removeEventListener("pagehide",Y),Y()}},[vn]),b.useEffect(()=>{if(!(!(w||e)||!n||!y||!bt||Mt||V!=="messages"))return Xy(Y=>{ve("messages"),wt(Be=>Be+(Be&&!/\s$/.test(Be)?`
158
+ `:"")+Y.replace(/\r\n?/g,`
159
+ `))},At,we)},[w,e,n,y,bt?.id,we,At,V,Mt]),b.useEffect(()=>{const Y=Ft.current;if(!w||!Y)return;const Be=Qt=>pe(String(Qt.detail));return Y.addEventListener("termdock:file-drop-error",Be),()=>Y.removeEventListener("termdock:file-drop-error",Be)},[w,bt?.id,pe]);const dn=async Y=>{const Be=bt?.id;pe(null),nn(Qt=>Qt+1);try{const Qt=await W0("/tmp",Y);if(Qt.files.length!==Y.length||Qt.files.some(sr=>!sr.path))throw new Error("文件路径准备失败,请重试");const er=Qt.files.map(sr=>Uu(sr.path)).join(" ")+" ";if(gt.current===Be)wt(sr=>sr+(sr&&!/\s$/.test(sr)?`
160
+ `:"")+er);else if(Be){const sr=Oe.current.get(Be)??{content:"",targets:null},$r={...sr,content:sr.content+`
161
+ `+er};Oe.current.set(Be,$r),vn({drafts:{[Be]:$r}})}}catch(Qt){pe(Qt instanceof Error?Qt.message:"文件上传失败")}finally{nn(Qt=>Qt-1)}},kn=new Set(C.filter(Wm).map(Y=>Y.sessionId)),Hr=De.size,ne=[...De].filter(Y=>!kn.has(Y)),Xe=uF(bt,C),Dt=Me.trim().toLocaleLowerCase(),ur=C.filter(Y=>!Dt||[Hu(Y,C),Y.name,Y.serviceLabel??"",Y.cwd,Vm(Y.currentTask)].some(Be=>Be.toLocaleLowerCase().includes(Dt))),Fr=ty(ur),Zr=ty(Xe),an=Y=>!Dt&&Ne.has(Y),Mr=Y=>ae(Be=>{const Qt=new Set(Be);return Qt.has(Y)?Qt.delete(Y):Qt.add(Y),Qt});b.useEffect(()=>{Ut(!1),Bt.current!==bt?.id&&nr(!1),Bt.current=null,le(!1),Ce(!1),at(!1),$e({}),Nt(new Set(bt?.sessionIds??[])),lt(bt?.defaultLaunchProfileId??"")},[bt?.id]),b.useEffect(()=>{!St&&L[0]&&Ot(L[0].slug)},[L,St]),b.useEffect(()=>{ft([]),z(null)},[bt?.id]),b.useEffect(()=>{if(!D||!n||w&&!y||!bt){He(!1);return}He(!0);let Y=!1,Be=0,Qt=!1;const sr=ou(()=>{if(Y||Qt||document.hidden||navigator.onLine===!1)return;Qt=!0;const $r=++Be;Ex(bt.id).then(Ir=>{!Y&&$r===Be&&(ft(Ir.messages),z(null))}).catch(Ir=>{!Y&&$r===Be&&z(Ir instanceof Error?Ir.message:"消息加载失败")}).finally(()=>{Qt=!1,!Y&&$r===Be&&He(!1)})},3e3,[k0,"pageshow"]);return()=>{Y=!0,sr()}},[bt?.id,n,w,y]),b.useEffect(()=>{!D||bt?.id!==D||st.current||(st.current=!0,V==="messages"&&Ft.current?.scrollIntoView?.({block:"nearest"}))},[D,bt?.id]);const Vr=async()=>{de("create-group"),pe(null),J(null);try{if(ne.length)throw new Error("所选会话已变化,请先清除不可用选择");const Y=await ql({name:Fe,sessionIds:[...De]});se(""),Ke(""),x(Y.group.id),await Re(),J(`“${Y.group.name}”已创建。`),r?await r(Y.group.id,"messages"):F&&await F(Y.group.id)}catch(Y){pe(Y instanceof Error?Y.message:"创建失败")}finally{de(null)}},Ln=bt?.sessionIds.filter(Y=>ge===null||ge.includes(Y))??[],tn=async()=>{if(!bt||G||bn||!tt.trim()||!Ln.length)return;const Y=tt,Be=bt.id;de("send-message"),pe(null),J(null);try{const Qt=await n9(bt.id,{fromSessionId:null,toSessionIds:ge===null?void 0:Ln,kind:"message",content:tt});if(gt.current===Be){const Ir=Ar.current,Zn=Ir===Y?"":Ir.startsWith(Y)?Ir.slice(Y.length).replace(/^\n/,""):Ir;wt(Zn),vn({drafts:{[Be]:{content:Zn,targets:$t.current}}})}else{const Ir=Oe.current.get(Be);if(Ir){const Zn={...Ir,content:Ir.content===Y?"":Ir.content.startsWith(Y)?Ir.content.slice(Y.length).replace(/^\n/,""):Ir.content};Oe.current.set(Be,Zn),vn({drafts:{[Be]:Zn}})}}const er=await Ex(Be).catch(()=>null);er&&gt.current===Be&&ft(er.messages);const sr=Qt.deliveries?.filter(Ir=>Ir.serviceUnavailable).length??0,$r=Qt.deliveries?.filter(Ir=>Ir.pending>0).length??0;J(sr>0?`已保存消息;${sr} 个接收成员的服务不可达,尚未送达,等待重连`:$r>0?`已保存消息;${$r} 个成员等待投递确认`:`消息已送达 ${Qt.messages.length} 个会话`)}catch(Qt){pe(Qt instanceof Error?Qt.message:"发送失败")}finally{de(null)}},Ur=async()=>{if(!bt)return;de(`delete:${bt.id}`),pe(null),J(null);const Y=bt.name;try{await t3(bt.id,ct),x(null),at(!1),await Re(),J(`“${Y}”已删除`)}catch(Be){pe(Be instanceof Error?Be.message:"删除失败")}finally{de(null)}},Xr=async()=>{if(!bt)return;const Y=[...ot];de("save-members"),pe(null),J(null);try{const Be=await ql({id:bt.id,name:bt.name,sessionIds:Y,expectedUpdatedAt:K});x(Be.group.id),Ut(!1),await Re(),J(`“${bt.name}”成员已更新,共 ${Y.length} 个会话`)}catch(Be){pe(Be instanceof Error?Be.message:"成员更新失败")}finally{de(null)}},vr=async Y=>{if(!bt||!bt.sessionIds.includes(Y)){Je(null);return}const Be=C.find(er=>er.sessionId===Y)?.name??Y,Qt=bt.name;de(`remove-member:${Y}`),pe(null),J(null);try{await ql({id:bt.id,name:Qt,sessionIds:bt.sessionIds.filter(er=>er!==Y),expectedUpdatedAt:bt.updatedAt}),Je(null),Nt(er=>new Set([...er].filter(sr=>sr!==Y))),$e(er=>Object.fromEntries(Object.entries(er).filter(([sr])=>sr!==Y))),await Re(),J(`已把“${Be}”移出“${Qt}”`)}catch(er){pe(er instanceof Error?er.message:"移出成员失败")}finally{de(null)}},on=async Y=>{if(!bt)return;const Be=tr[Y]??"";de(`role:${Y}`),pe(null),J(null);try{await o9(bt.id,Y,Be.trim()||null),await Re(),J(Be.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(Qt){pe(Qt instanceof Error?Qt.message:"定位保存失败")}finally{de(null)}},Jr=()=>{lt(bt?.defaultLaunchProfileId??"");const Y=C.find(Be=>Be.sessionId===N)?.cwd??C.find(Be=>bt?.sessionIds.includes(Be.sessionId))?.cwd??"";Nr(Y),ar(""),Tt(""),Ce(!0),Ut(!1)},hn=async()=>{if(!(!bt||!St||Jt&&!bt.launchProfiles?.some(Y=>Y.id===Jt))){de("spawn-agent"),pe(null),J(null);try{const Y=await s9(bt.id,{agentSlug:bt.launchProfiles?.find(Be=>Be.id===Jt)?.agentSlug??St,...Jt||bt.launchProfiles?.length?{launchProfileId:Jt}:{},name:Ct.trim()||void 0,cwd:_r.trim()||void 0,task:zr.trim()||void 0,mode:Z});Ce(!1),await Re(),J(`“${Y.session.name}”已创建并加入“${Y.group.name}”`)}catch(Y){pe(Y instanceof Error?Y.message:"Agent Session 创建失败")}finally{de(null)}}},jr=mF(ut,C),zn=Y=>s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-2 py-2.5 transition hover:bg-surface-2",children:[s.jsx("input",{className:"mt-0.5",type:"checkbox",disabled:!Wm(Y),checked:De.has(Y.sessionId),onChange:()=>_e(Be=>{const Qt=new Set(Be);return Qt.has(Y.sessionId)?Qt.delete(Y.sessionId):Qt.add(Y.sessionId),Qt})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-[12px] text-foreground",children:Hu(Y,C)}),s.jsx(Gm,{session:Y}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:wf(Y)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:Y.currentTask?`${Vm(Y.currentTask)} · ${Y.cwd}`:Y.cwd||Y.capability||"终端会话"})]})]},Y.sessionId),mn=Y=>{const Be=tr[Y.sessionId]??"",Qt=bt?.roles?.[Y.sessionId]??"";return s.jsxs("div",{className:"px-2 py-2 transition hover:bg-surface-2",children:[s.jsxs("label",{className:"flex cursor-pointer items-center gap-3",children:[s.jsx("input",{type:"checkbox",disabled:!bt?.sessionIds.includes(Y.sessionId)&&!Wm(Y),checked:ot.has(Y.sessionId),onChange:()=>Nt(er=>{const sr=new Set(er);return sr.has(Y.sessionId)?sr.delete(Y.sessionId):sr.add(Y.sessionId),sr})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] text-foreground",children:Y.name}),s.jsx(Gm,{session:Y}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[wf(Y)," · ",Y.cwd]})]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 pl-7",children:[s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:"定位"}),s.jsx("input",{"aria-label":`${Y.name} 的定位`,className:`${Ys} min-h-8 py-1 text-[10px]`,value:Be,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:er=>$e(sr=>({...sr,[Y.sessionId]:er.target.value}))}),s.jsx("button",{"aria-label":`保存 ${Y.name} 的定位`,title:Be.trim()===Qt?"定位未变化":"保存此成员的定位",disabled:G!==null||Be.trim()===Qt,className:`${Er} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{on(Y.sessionId)},children:G===`role:${Y.sessionId}`?s.jsx(An,{size:12,className:"animate-spin"}):s.jsx(Ci,{size:12})})]})]},Y.sessionId)},qr=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e||Ze?"看板":"目标"],["messages","成员与消息"]].map(([Y,Be])=>s.jsxs("button",{type:"button","aria-label":Be,"aria-pressed":V===Y,className:`${Er} min-h-11 ${V===Y?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:Qt=>{if(Ze&&Y==="tasks"){F?.(bt.id).catch($r=>pe($r instanceof Error?$r.message:"无法打开看板"));return}const er=Qt.currentTarget.closest("[data-collaboration-views]"),sr=Qt.currentTarget;ve(Y),requestAnimationFrame(()=>{const $r=document.activeElement;$r!==sr&&$r!==document.body&&$r?.isConnected&&!$r.closest("[hidden]")||Array.from(er?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(Ir=>Ir.getAttribute("aria-pressed")==="true"&&!Ir.closest("[hidden]"))?.focus()})},children:[e&&Y==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:Be})]}):Be,!e&&Y==="tasks"&&ye>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[ye," 待处理"]})]},Y))}),Wr=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":Mt,className:`${Er} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:Y=>{Xt.current=Y.currentTarget,nr(Be=>!Be),pe(null),J(null)},children:[s.jsx(Zu,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{ref:jt,className:e?"flex min-h-0 flex-1 flex-col gap-3":Ze?void 0:"space-y-3",children:[ke&&ie==="ready"&&!Tf(ke)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",ke]}),ke&&Tf(ke)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?Mt?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[!D&&m!=="new"&&T.length>0&&s.jsx("div",{hidden:Mt,children:s.jsx($O,{groups:T,sessions:C,busy:G!==null,onOpen:(Y,Be)=>{r?.(Y,Be)},onSettings:(Y,Be)=>{Bt.current=Y,x(Y),Xt.current=Be,nr(!0),pe(null),J(null)},onCreate:()=>{x("new"),at(!1),J(null)}})}),!D&&(m==="new"||Mt)&&T.length>0&&s.jsx("button",{type:"button",className:`${Er} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{Mt?Ht():x(T[0].id)},children:"返回协作组"}),Mt&&bt&&s.jsx(aF,{group:bt,agents:L,activeSessionId:N,sessions:C,busy:G,setBusy:de,setError:pe,setNotice:J,refresh:Re,onClose:Ht},bt.id),!D&&v!=="loaded"&&!T.length&&s.jsx("p",{role:"status",className:"py-5 text-xs text-muted-foreground",children:v==="loading"?"正在加载协作组与会话…":"会话加载失败,请重试"}),!bt&&(D||m==="new"||v==="loaded")&&s.jsxs("section",{className:"border-y border-border/15 py-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"先给协作组命名。成员可以现在选择,也可以以后添加;消息和看板都能独立使用。"})]}),s.jsxs("span",{className:`shrink-0 text-[10px] ${Hr>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",Hr," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:Ys,value:Fe,onChange:Y=>se(Y.target.value),placeholder:"例如:发布准备"})]}),s.jsxs("details",{className:"mt-3",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["复用已有会话(选填) · 已选 ",Hr," 个"]}),C.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(Yl,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${Ys} pl-8`,value:Me,onChange:Y=>Ke(Y.target.value),placeholder:"按名称、目录或当前任务筛选"})]}),s.jsxs("div",{className:"mt-3 max-h-64 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[Fr.length<=1?ur.map(zn):Fr.map(Y=>{const Be=an(Y.key);return s.jsxs("div",{children:[s.jsx(ry,{label:Y.label,count:Y.sessions.length,collapsed:Be,onToggle:()=>Mr(Y.key)}),!Be&&s.jsx("div",{className:"divide-y divide-border/10",children:Y.sessions.map(zn)})]},Y.key)}),C.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:v==="loading"?"正在加载会话…":v==="error"?"会话加载失败,请重试":"没有现有会话也可以创建,开始目标时会启动 Agent"}),C.length>0&&ur.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),ne.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",ne.length," 个所选会话暂不可用。",s.jsx("button",{className:Er,onClick:()=>_e(Y=>new Set([...Y].filter(Be=>kn.has(Be)))),children:"清除不可用选择"})]}),s.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[s.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${Hr<2?"text-muted-foreground":"text-primary"}`,children:Fe.trim()?"创建后进入成员消息,看板可随时使用":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[T.length>0&&s.jsx("button",{className:`${Er} bg-surface-2 text-foreground`,onClick:()=>x(T[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:G!==null||!Fe.trim()||ne.length>0,className:`${Er} bg-primary text-primary-foreground`,onClick:()=>{Vr()},children:[G==="create-group"?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(Xs,{size:13}),"创建协作组"]})]})]})]})]}),bt&&D&&s.jsxs("div",{"data-collaboration-views":!0,hidden:Mt,className:e?`${Mt?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:Ze?void 0:"space-y-3",children:[!Ze&&(!e||V==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[qr,s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e&&V==="messages"&&s.jsxs("button",{type:"button","aria-label":"放到终端旁",title:ee?"在当前终端分屏中使用成员与消息":"先打开一个终端,再嵌入消息面板",disabled:!ee||G!==null,className:`${Er} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{de("dock-messages"),pe(null),ee?.().catch(Y=>pe(Y instanceof Error?Y.message:"消息面板打开失败,草稿已保留")).finally(()=>de(null))},children:[s.jsx(Zc,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"放到终端旁"})]}),Wr]})]}),!Ze&&V==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:Tn.map(Y=>s.jsx("button",{type:"button","aria-pressed":Y.sessionId===N,title:`${Y.name} · ${Y.cwd||"终端会话"}`,className:`${Er} min-h-9 shrink-0 ${Y.sessionId===N?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{P(Y).catch(Be=>pe(Be instanceof Error?Be.message:"无法打开终端"))},children:Hu(Y,Tn)},Y.sessionId))}),!Ze&&s.jsx("div",{hidden:V!=="tasks",className:e?`${V==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(XO,{paneKey:d?At:void 0,boardNavigation:e?qr:void 0,boardSettings:e?Wr:void 0,board:e,group:bt,sessions:C,agents:L,defaultCwd:C.find(Y=>Y.sessionId===N)?.cwd??void 0,onTeamReady:Re,active:n&&!Mt&&V==="tasks"&&(!w||y),onAttentionChange:Te,onManageMembers:()=>ve("messages"),onOpenSession:P},bt.id)}),s.jsxs("div",{hidden:V!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>b0(At),onPointerDownCapture:()=>b0(At),"data-termdock-terminal-dropzone":w?N??"collaboration-composer":void 0,onDragOver:Y=>{w&&Y.preventDefault()},onDrop:Y=>{if(!w)return;const Be=Array.from(Y.dataTransfer.files);if(!(Be.length&&na()))if(Y.preventDefault(),Y.stopPropagation(),Be.length)dn(Be);else{const Qt=Y.dataTransfer.getData("text/plain")||Y.dataTransfer.getData("text/uri-list");Qt&&wt(er=>er+(er?`
162
+ `:"")+Qt)}},ref:Ft,className:w?"":"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[!w&&s.jsxs("h4",{className:"truncate text-[12px] font-medium text-foreground",children:[bt.name," · 发送给成员"]}),s.jsxs("div",{className:w?"space-y-2":"mt-2 space-y-2",children:[Ze&&s.jsxs("div",{className:"relative z-20 flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["发送给 ",s.jsx("span",{className:"text-[9px]",children:"· 可多选"})]}),s.jsxs("details",{className:"relative",onKeyDown:Y=>{Y.key==="Escape"&&(Y.currentTarget.removeAttribute("open"),Y.currentTarget.querySelector("summary")?.focus(),Y.stopPropagation())},children:[s.jsx("summary",{"aria-label":"更多协作操作",className:"flex min-h-11 min-w-11 cursor-pointer list-none items-center justify-center rounded text-muted-foreground hover:bg-surface-2 sm:min-h-8 sm:min-w-8 [&::-webkit-details-marker]:hidden",children:s.jsx(Ro,{size:16})}),s.jsxs("div",{className:"absolute right-0 top-full z-30 w-44 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:[s.jsxs("button",{type:"button",className:`${Er} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Y=>{Y.currentTarget.closest("details")?.removeAttribute("open"),F?.(bt.id).catch(Be=>pe(Be instanceof Error?Be.message:"无法打开看板"))},children:[s.jsx(Zc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":qe,className:`${Er} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Y=>{Y.currentTarget.closest("details")?.removeAttribute("open"),le(Be=>!Be)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":Mt,className:`${Er} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Y=>{Y.currentTarget.closest("details")?.removeAttribute("open"),Xt.current=Y.currentTarget,nr(!0),pe(null),J(null)},children:[s.jsx(Zu,{size:14}),"组设置"]})]})]})]}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:Ze?"sr-only":"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...bt.sessionIds.map(Y=>({id:Y,label:(()=>{const Be=Tn.find(Qt=>Qt.sessionId===Y);return Be?Hu(Be,Tn):void 0})()??`${Y.slice(0,8)}(离线)`}))].map(({id:Y,label:Be})=>{const Qt=Y==="*"?ge===null:ge?.includes(Y)??!1,er=C.find(sr=>sr.sessionId===Y);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":Qt,onClick:()=>We(sr=>Y==="*"?null:sr?.includes(Y)?sr.filter($r=>$r!==Y):[...sr??[],Y]),className:`${X1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Qt?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Qt&&s.jsx(Ci,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:Be})]}),er&&s.jsx("button",{type:"button","aria-label":`打开 ${Be} 的终端`,title:`打开 ${Be} 的终端`,className:"inline-flex h-9 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-primary sm:h-7 sm:w-6",onClick:()=>{O(er).catch(sr=>pe(sr instanceof Error?sr.message:"无法打开会话"))},children:s.jsx(Zc,{size:12})})]},Y)})})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:Ze?"sr-only":void 0,children:"内容"}),s.jsx("textarea",{onKeyDown:Y=>{Y.key==="Enter"&&(Y.metaKey||Y.ctrlKey)&&!Y.nativeEvent.isComposing&&Y.keyCode!==229&&(Y.preventDefault(),tn())},onPaste:Y=>{const Be=Array.from(Y.clipboardData.files);Be.length&&(Y.preventDefault(),dn(Be))},className:`${Ys} min-h-16 max-h-48 resize-y`,value:tt,onChange:Y=>wt(Y.target.value),placeholder:"输入消息,可粘贴引用或文件…"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("p",{role:"status","aria-live":"polite",title:w&&a?a:void 0,className:`min-w-0 flex-1 text-[9px] leading-relaxed ${w?"truncate":""} ${w&&a?"text-primary":"text-muted-foreground"}`,children:bn>0?"正在准备文件路径…":w&&a?a:bt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:G!==null||bn>0||!tt.trim()||!Ln.length,className:`${Er} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{tn()},children:[G==="send-message"?s.jsx(An,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:Ze&&!qe,open:Ze?qe:void 0,onToggle:Y=>{Ze&&le(Y.currentTarget.open)},className:"mt-4 rounded-xl border border-border/15",children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-3 text-[11px] font-medium text-foreground",children:["管理成员、角色与删除 · ",bt.sessionIds.length," 个成员"]}),s.jsxs("section",{className:"border-t border-border/15 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:bt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[bt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:w4(bt.id)})]})]}),ze?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${Er} bg-surface-2 px-2 text-foreground`,onClick:()=>at(!1),children:"取消"}),s.jsxs("button",{disabled:G!==null,className:`${Er} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{Ur()},children:[G===`delete:${bt.id}`?s.jsx(An,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsxs("button",{className:`${Er} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{Nt(new Set(bt.sessionIds)),xt(bt.updatedAt);const Y=!Zt;Ut(Y),Y&&$e(Object.fromEntries(bt.sessionIds.map(Be=>[Be,bt.roles?.[Be]??""]))),Ce(!1)},children:[s.jsx(Zu,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${Er} px-2 text-primary hover:bg-primary/10`,onClick:Jr,children:[s.jsx(Xs,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${bt.name}`,title:"删除协作组",disabled:G!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{me(bt.updatedAt),at(!0)},children:s.jsx(zs,{size:14})})]})]}),ze&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",bt.name,"”协作组及其协作记录,",bt.sessionIds.length," 个成员的终端会话会保留。"]}),s.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:bt.sessionIds.map(Y=>{const Be=C.find(sr=>sr.sessionId===Y),Qt=bt.roles?.[Y],er=Be?.name??Y;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${xe===Y?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!Be,onClick:()=>Be&&void O(Be).catch(sr=>pe(sr instanceof Error?sr.message:"无法打开会话")),className:"min-w-0 flex-1 px-3 py-2.5 text-left disabled:cursor-default",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${Be&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(Be.status)&&Be.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:er}),Be&&s.jsx(Gm,{session:Be}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:Be?wf(Be):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Qt?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Qt]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,Be?s.jsx("span",{className:"min-w-0 truncate",children:Vm(Be.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${er} 移出协作组`,"aria-expanded":xe===Y,title:"移出协作组",disabled:G!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${xe===Y?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>Je(xe===Y?null:Y),children:s.jsx(zs,{size:13})})]},Y)})}),xe&&bt.sessionIds.includes(xe)&&(()=>{const Y=C.find(Qt=>Qt.sessionId===xe)?.name??xe,Be=G===`remove-member:${xe}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${Y}`,className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-y border-destructive/25 bg-destructive/5 px-3 py-2.5",children:[s.jsx("p",{className:"min-w-0 flex-1 text-[10px] leading-relaxed text-destructive",children:`把“${Y}”移出“${bt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${Er} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Je(null),children:"取消"}),s.jsxs("button",{disabled:G!==null,className:`${Er} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{vr(xe)},children:[Be?s.jsx(An,{size:12,className:"animate-spin"}):s.jsx(zs,{size:12}),"移出"]})]})]})})(),Zt&&s.jsxs("div",{className:"mt-4 border-t border-border/15 pt-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"管理成员"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"暂不可用的原成员会保留,只有取消勾选才会移出;定位(角色)在每行独立保存,成员收到消息时会看到自己的定位。"})]}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["已选 ",ot.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Zr.length<=1?Xe.map(mn):Zr.map(Y=>{const Be=an(Y.key);return s.jsxs("div",{children:[s.jsx(ry,{label:Y.label,count:Y.sessions.length,collapsed:Be,onToggle:()=>Mr(Y.key)}),!Be&&s.jsx("div",{className:"divide-y divide-border/10",children:Y.sessions.map(mn)})]},Y.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Er} bg-surface-2 text-foreground`,onClick:()=>{Ut(!1),$e({})},children:"取消"}),s.jsxs("button",{disabled:G!==null||v!=="loaded",className:`${Er} bg-primary text-primary-foreground`,onClick:()=>{Xr()},children:[G==="save-members"?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(Ci,{size:13}),"保存成员"]})]})]}),Qr&&s.jsxs("div",{className:"mt-4 border-t border-primary/20 pt-4",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"创建 Agent Session"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"新会话启动后自动加入本组,并收到初始任务和成员信息。"})]}),s.jsx(UO,{group:bt,value:Jt,onChange:lt,disabled:G!==null}),s.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["Agent / Plugin",s.jsx("select",{"aria-label":"新 Agent 类型",className:Ys,disabled:!!Jt,value:bt.launchProfiles?.find(Y=>Y.id===Jt)?.agentSlug??St,onChange:Y=>Ot(Y.target.value),children:L.map(Y=>s.jsxs("option",{value:Y.slug,children:[Y.displayName,Y.isPlugin?" · Plugin":""]},Y.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:Ys,value:Ct,onChange:Y=>ar(Y.target.value),placeholder:"留空则自动命名"})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["工作目录",s.jsx("input",{"aria-label":"新 Agent 工作目录",className:Ys,value:_r,onChange:Y=>Nr(Y.target.value),placeholder:"默认继承当前会话"})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["初始任务",s.jsx("textarea",{"aria-label":"新 Agent 初始任务",className:`${Ys} min-h-16 resize-y`,value:zr,onChange:Y=>Tt(Y.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Er} bg-surface-2 text-foreground`,onClick:()=>Ce(!1),children:"取消"}),s.jsxs("button",{disabled:G!==null||!St||!!Jt&&!bt.launchProfiles?.some(Y=>Y.id===Jt),className:`${Er} bg-primary text-primary-foreground`,onClick:()=>{hn()},children:[G==="spawn-agent"?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(G0,{size:13}),"创建并加入"]})]})]})]})]},bt.id),s.jsxs("section",{className:"mt-4",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[jr.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[jr.map(Y=>s.jsxs("div",{className:"px-2 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-primary",children:Y.responseKind==="ack"?"收到确认":Y.responseKind==="progress"?"进展":Y.responseKind==="result"?"结果":pF(Y.kind)}),s.jsx("span",{children:Y.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:Y.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(Y.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:Y.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:Y.status==="pending"?"已入队 · 等待投递":Y.status==="failed"?"投递失败":Y.status==="expired"?"消息已过期,未继续投递":Y.status==="stored"?"答复已持久保存 · 供后台接收":"已写入接收方终端 · 等待接手确认"}),Y.deliveryErrors.map(Be=>s.jsx("p",{role:"status",className:"mt-1 text-[10px] text-destructive",children:Be==="TMUX_PANE_CHANGED"?"目标会话绑定已变化,投递暂停。原消息已保留,请确认目标会话后继续。":`投递暂停:${Be}。原消息已保留,请检查目标会话。`},Be)),(Y.task||Y.failureReason)&&s.jsxs("details",{className:"mt-2 text-[10px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:"任务详情与证据"}),s.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:JSON.stringify(Y.task??{failure_reason:Y.failureReason},null,2)})]})]},Y.key)),jr.length===0&&s.jsx(TF,{text:Se?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function aF({group:e,agents:t,activeSessionId:r,sessions:n,busy:a,setBusy:c,setError:l,setNotice:d,refresh:f,onClose:m}){const x=n.filter(V=>e.sessionIds.includes(V.sessionId)&&!nd(V.sessionId)),[y,w]=b.useState(()=>eF(e,r&&x.some(V=>V.sessionId===r)?r:"")),v=b.useRef(y),[T,C]=b.useState(null),L=V=>{const ve={...v.current,...V};v.current=ve,tF(e.id,ve),w(ve)},{name:N,rules:D,savedName:O,savedRules:P,rulesVersion:F,rulesMemberId:ee}=y,Z=rp(y),G=new TextEncoder().encode(D).length,de=x.some(V=>V.sessionId===ee),pe=async()=>{if(!(a||!N.trim())){c("group-name"),l(null),d(null);try{const V=await ql({id:e.id,name:N.trim(),sessionIds:y.sessionIds??e.sessionIds,expectedUpdatedAt:y.updatedAt});C(null),L({savedName:V.group.name,name:V.group.name,updatedAt:V.group.updatedAt,sessionIds:V.group.sessionIds,...D===P?{rules:V.group.instructions?.text??"",savedRules:V.group.instructions?.text??"",rulesVersion:V.group.instructions?.version??""}:{}}),await f(),d("协作组名称已更新")}catch(V){C(null),l(V instanceof x0&&V.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":V instanceof Error?V.message:"改名失败")}finally{c(null)}}},J=async()=>{if(!(a||!de||G>8192)){c("group-rules"),l(null),d(null);try{const V=await a9(e.id,{sessionId:ee,text:D,expectedVersion:F});C(null),L({savedName:V.group.name,...N===O?{name:V.group.name}:{},updatedAt:V.group.updatedAt,sessionIds:V.group.sessionIds,rules:V.group.instructions?.text??"",savedRules:V.group.instructions?.text??"",rulesVersion:V.group.instructions?.version??""}),await f(),d(D.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(V){C(null),l(V instanceof x0&&V.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":V instanceof Error?V.message:"群规保存失败")}finally{c(null)}}},Re=()=>{L(Jg(e,ee)),C(null),l(null)},Ze=async()=>{if(!a){c("group-latest"),l(null),d(null),C(null);try{const ve=(await sg()).groups.find(qe=>qe.id===e.id);if(!ve)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");C(ve)}catch(V){l(V instanceof Error?V.message:"最新状态读取失败;草稿仍保留,请重试。")}finally{c(null)}}};return s.jsxs("section",{"aria-label":"协作组设置",onKeyDown:V=>{V.key!=="Escape"||V.defaultPrevented||V.nativeEvent.isComposing||(V.preventDefault(),V.stopPropagation(),a||m())},className:"mt-3 rounded-xl border border-border/20 bg-surface-2 p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"组设置"}),s.jsx("button",{type:"button",disabled:!!a,"aria-label":"关闭组设置",className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-elevated",onClick:m,children:s.jsx(Dn,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:Ys,value:N,maxLength:240,disabled:!!a,onChange:V=>L({name:V.target.value})})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!a||!!T||!N.trim()||N.trim()===O,className:`${Er} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{pe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(zO,{group:e,agents:t,busy:a,setBusy:c,refresh:f}),s.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/15 pt-3",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["由本组成员发布群规变更",s.jsxs("select",{className:Ys,value:ee,disabled:!!a||!x.length,onChange:V=>L({rulesMemberId:V.target.value}),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!x.some(V=>V.sessionId===ee)&&ee&&s.jsx("option",{value:ee,children:"原成员已不在组内,请重新选择"}),x.map(V=>s.jsx("option",{value:V.sessionId,children:V.name},V.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${Ys} min-h-24 resize-y`,value:D,maxLength:8192,disabled:!!a,onChange:V=>L({rules:V.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!de&&s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x.length?"选择发布变更的成员后即可保存,不需要关闭工作台。":"当前服务没有本组成员,请先添加成员或切换到成员所在的服务。已有群规可在此查看。"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx("p",{className:`text-[9px] ${G>8192?"text-destructive":"text-muted-foreground"}`,children:G>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!T||!de||G>8192||D===P,className:`${Er} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{J()},children:a==="group-rules"?"保存中…":D.trim()?"保存群规":"清空群规"})]}),Z&&s.jsx("p",{role:"status",className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"有未保存修改。关闭、Escape 或切换组后,草稿仍保留在本标签页;名称与群规需分别保存。"}),Z&&s.jsx("button",{type:"button",disabled:!!a,className:`${Er} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{Ze()},children:a==="group-latest"?"读取中…":"查看最新状态并保留草稿"}),T&&s.jsxs("section",{"aria-label":"最新组设置",className:"mt-3 space-y-2 rounded-lg bg-surface p-3 text-[11px] leading-5",children:[s.jsx("p",{className:"font-medium text-foreground",children:"确认最新状态后,再分别保存草稿"}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前名称:",T.name]}),s.jsxs("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:["当前群规:",T.instructions?.text||"未设置"]}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前成员(",T.sessionIds.length,"):",T.sessionIds.map(V=>n.find(ve=>ve.sessionId===V)?.name??w4(V)).join("、")||"暂无成员"]}),s.jsx("p",{className:"text-muted-foreground",children:"保留你的未保存内容;名称保存将保留以上成员,群规保存会通知当前成员。再次发生修改时仍会检查冲突。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:!!a,className:`${Er} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{L(JO(v.current,T)),C(null),l(null),d("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${Er} min-h-11 text-muted-foreground`,onClick:()=>C(null),children:"取消确认"})]})]}),s.jsxs("div",{className:"mt-3 flex justify-between gap-2 border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button",disabled:!!a,className:`${Er} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:Re,children:[s.jsx(An,{size:12}),"重新载入",Z&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${Er} min-h-9 bg-surface text-foreground`,onClick:m,children:Z?"关闭并保留草稿":"关闭"})]})]})}function oF({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:c,onSelectGroup:l}){const[d,f]=b.useState(null),[m,x]=b.useState(!1),y=e.services??[],w=e.removedServices??[],v=y.filter(L=>!L.connected),T=v.some(L=>L.groups?.some(N=>N.id===t)),C=async(L,N)=>{if(!r){n(`peer:${L}`),a(null),c(null);try{N?await h9(L):await f9(L),f(null),x(!1),c(N?"协作连接已恢复,正在连接服务":"协作连接已移除,不会再自动重连;已有会话和消息保留")}catch(D){a(D instanceof Error?D.message:N?"重新连接失败":"移除连接失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-4 shrink-0 rounded-lg border border-border/15",open:T||void 0,children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-2.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"协作连接与管理"}),s.jsx("span",{className:"ml-2",children:e.state==="loading"?"正在加载…":`${y.length-v.length} 个已连接${v.length?` · ${v.length} 个离线`:""}`})]}),s.jsxs("div",{className:"max-h-64 overflow-y-auto border-t border-border/15 px-3 py-2",children:[y.length>0&&s.jsx("p",{className:"mb-1 text-[10px] leading-relaxed text-muted-foreground",children:"与以下服务进行跨服务协作,名称与服务切换器一致。"}),v.length>0&&s.jsx("p",{className:"mb-2 text-[10px] leading-relaxed text-muted-foreground",children:T?"当前协作组的部分服务不可达,消息会保留并等待重连。":"其他服务暂时离线;当前服务内的协作可以继续。不再使用的连接可移除。"}),e.error&&s.jsx("p",{role:"status",className:"mb-2 break-words text-[10px] text-destructive",children:e.error}),e.state==="unsupported"&&s.jsx("p",{className:"mb-2 text-[10px] text-muted-foreground",children:"请更新客户端以管理跨服务连接。"}),s.jsx("div",{className:"divide-y divide-border/10",children:y.map(L=>s.jsxs("div",{className:"py-2.5",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[Ac({serviceLabel:L.label,serviceOrigin:L.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${L.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:L.connected?"已连接":L.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx(lF,{service:L})]}),L.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${L.origin}`,className:`${Er} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>f(d===L.serviceId?null:L.serviceId),children:[s.jsx(zs,{size:12}),"移除"]})]}),!!L.groups?.length&&s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{children:"用于"}),L.groups.map(N=>s.jsx("button",{type:"button",className:"rounded px-1.5 py-1 text-primary hover:bg-primary/10",onClick:()=>l(N.id),children:N.name},N.id))]}),!L.connected&&L.error&&L.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:gF(L.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:L.error})]}),d===L.serviceId&&s.jsxs("div",{role:"group","aria-label":"确认移除协作连接",className:"mt-2 rounded-lg bg-surface-2 p-2.5",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-foreground",children:L.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${Er} min-h-9 text-muted-foreground`,onClick:()=>f(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!L.groups?.length,className:`${Er} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{C(L.serviceId,!1)},children:r===`peer:${L.serviceId}`?"正在移除…":"确认移除"})]})]})]},L.serviceId||L.origin))}),y.length===0&&e.state==="ready"&&s.jsx("p",{className:"py-2 text-[10px] text-muted-foreground",children:"当前没有其他协作服务,当前服务内仍可创建协作组。"}),v.length>0&&s.jsxs("button",{type:"button",className:`${Er} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:d9,children:[s.jsx(An,{size:12}),"重试连接"]}),w.length>0&&s.jsxs("div",{className:"mt-2 border-t border-border/15 pt-1",children:[s.jsx("button",{type:"button","aria-expanded":m,className:`${Er} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(L=>!L),children:m?"收起恢复列表":"恢复已移除连接"}),m&&s.jsxs("section",{"aria-label":"恢复已移除连接",className:"mt-1 rounded-lg bg-surface-2 px-2.5 py-2",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"以下是恢复记录,连接已停用,不会自动重连。点击恢复后才会重新启用协作。"}),s.jsx("div",{className:"mt-1 divide-y divide-border/10",children:w.map(L=>s.jsxs("div",{className:"flex items-start gap-2 py-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"break-words text-[10px] text-foreground",children:[Ac({serviceLabel:L.label,serviceOrigin:L.origin}),s.jsx("span",{className:"ml-2 text-[9px] text-muted-foreground",children:"已停用"})]}),s.jsx("p",{className:"mt-0.5 select-text break-all text-[9px] text-muted-foreground",children:L.accessUrl||L.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!L.serviceId,className:`${Er} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{C(L.serviceId,!0)},children:r===`peer:${L.serviceId}`?"恢复中…":"恢复连接"})]},L.serviceId||L.origin))})]})]})]})]},T?"affected":"other")}function lF({service:e}){let t=!1;try{t=["localhost","127.0.0.1","[::1]"].includes(new URL(e.origin).hostname)}catch{}const r=e.accessUrl||(t?"":e.origin);return s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"w-fit cursor-pointer py-1",children:"连接详情"}),s.jsxs("dl",{className:"mt-1 space-y-1 select-text break-all",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务地址:"}),s.jsx("dd",{className:"inline",children:r||"暂未获取,请在服务切换器中查看"})]}),e.serviceId&&s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务身份:"}),s.jsx("dd",{className:"inline",children:e.serviceId})]})]})]})}function Wm(e){return!nd(e.sessionId)||e.serviceConnected!==!1}function cF(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:nd(e.sessionId)?.origin??""}function ty(e){const t=new Map;for(const r of e){const n=cF(r),a=t.get(n)??{key:n,label:n?Ac(r):"本机服务",sessions:[]};n&&a.label==="远端服务"&&(a.label=Ac(r)),a.sessions.push(r),t.set(n,a)}return[...t.values()].sort((r,n)=>(r.key?1:0)-(n.key?1:0)||r.label.localeCompare(n.label))}function ry({label:e,count:t,collapsed:r,onToggle:n}){return s.jsxs("button",{type:"button","aria-expanded":!r,onClick:n,className:"flex w-full items-center gap-1.5 bg-surface-2/50 px-2 py-1.5 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsx(Cl,{size:12,className:`shrink-0 transition-transform ${r?"-rotate-90":""}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wide",children:e}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground/70",children:t})]})}function uF(e,t){const r=new Map(t.map(n=>[n.sessionId,n]));for(const n of e?.sessionIds??[]){if(r.has(n))continue;const a=e?.remoteSessions?.find(c=>c.sessionId===n);r.set(n,a?{...a,status:"offline",serviceConnected:!1}:{sessionId:n,name:n,backendSessionId:null,cwd:"",agent:null,status:"offline",capability:"",currentTask:"暂不可用,保留成员身份",updatedAt:0,...nd(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function Gm({session:e}){return!e.serviceOrigin||e.serviceOrigin===window.location.origin?null:s.jsxs("span",{className:"inline-flex max-w-28 shrink-0 items-center gap-1 rounded border border-border/20 px-1 py-0.5 text-[9px] text-muted-foreground",children:[s.jsx(Zc,{size:9}),s.jsx("span",{className:"truncate",children:Ac(e)})]})}function wf(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":fF(e.status)}function dF(e,t=[]){if(!e)return;const r=t.some(a=>a.sessionId!==e.sessionId&&a.name.trim()===e.name.trim()),n=e.sessionId.startsWith("remote:")?Ac(e):"本机服务";return r?`${e.name} · ${n}`:e.name}async function hF(e){e.sessionId.startsWith("remote:")?await G6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function fF(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function Vm(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return np(t.prompt)||"暂无任务摘要"}catch{}return np(e)||"暂无任务摘要"}function pF(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function mF(e,t){const r=new Map(t.map(a=>[a.sessionId,dF(a,t)])),n=new Map;for(const a of e){const c=`${a.threadId}:${a.createdAt}:${a.fromSessionId??a.integrationOrigin?.integrationId??"user"}:${a.kind}:${a.responseKind??""}:${JSON.stringify(a.task??null)}:${a.content}`,l=n.get(c),d=a.toPrincipalId?`后台接入 ${a.toPrincipalId}`:r.get(a.toSessionId)??a.toSessionId.slice(0,8);if(l){l.toNames.push(d),a.delivery?.stage==="blocked"&&a.delivery.error&&!l.deliveryErrors.includes(a.delivery.error)&&l.deliveryErrors.push(a.delivery.error);const f={failed:-2,expired:-1,pending:0,delivered:1,read:2,stored:3};f[a.status]<f[l.status]&&(l.status=a.status);continue}n.set(c,{key:c,kind:a.kind,content:a.content,createdAt:a.createdAt,fromName:a.fromSessionId?r.get(a.fromSessionId)??a.fromSessionId.slice(0,8):a.integrationOrigin?`后台接入 ${a.integrationOrigin.integrationId}`:"你",toNames:[d],status:a.status,responseKind:a.responseKind,task:a.task,failureReason:a.failureReason,deliveryErrors:a.delivery?.stage==="blocked"&&a.delivery.error?[a.delivery.error]:[]})}return[...n.values()].sort((a,c)=>c.createdAt-a.createdAt)}function gF(e){return/timeout|timed out|超时|operation was aborted/i.test(e)?"连接超时,暂时无法访问该服务。请确认远端服务已启动,并检查网络或 VPN 连接。":/ECONNREFUSED|connection refused/i.test(e)?"远端拒绝连接,请确认服务已启动且端口正确。":/ENOTFOUND|EHOSTUNREACH|ENETUNREACH/i.test(e)?"无法访问远端地址,请检查地址和网络连接。":/certificate|fingerprint|TLS|证书/i.test(e)?"远端证书校验失败,请检查服务连接授权。":"服务连接暂时不可用,可查看连接详情并重试。"}function qm({value:e,query:t}){const r=t.trim().toLocaleLowerCase();if(!r)return s.jsx(s.Fragment,{children:e});const n=e.toLocaleLowerCase(),a=[];let c=0,l;for(;(l=n.indexOf(r,c))>=0;)a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded bg-primary/15 text-primary",children:e.slice(l,l+r.length)},l)),c=l+r.length;return a.push(e.slice(c)),s.jsx(s.Fragment,{children:a})}function xF({active:e,onClose:t,onNewSession:r,setError:n}){const[a,c]=b.useState(""),[l,d]=b.useState([]),[f,m]=b.useState(0),[x,y]=b.useState(),[w,v]=b.useState(50),[T,C]=b.useState(0),[L,N]=b.useState(!1),[D,O]=b.useState(null),[P,F]=b.useState(null),ee=b.useRef(null),Z=b.useRef(0);b.useEffect(()=>{e&&ee.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const pe=++Z.current,J=new AbortController;let Re;O(null),N(!0);const Ze=async()=>{try{const V=await p9(a.trim(),w,J.signal);if(pe!==Z.current)return;d(V.results),m(V.total??V.results.length),y(V.index),V.index?.building&&(Re=window.setTimeout(()=>{Ze()},2500))}catch(V){pe===Z.current&&!J.signal.aborted&&O(V instanceof Error?V.message:"搜索失败")}finally{pe===Z.current&&N(!1)}};return Re=window.setTimeout(()=>{Ze()},a.trim()?250:0),()=>{window.clearTimeout(Re),J.abort(),++Z.current}},[e,a,w,T]);const G=pe=>{n(null),c(pe),d([]),m(0),v(50)},de=async pe=>{if(!P){if(pe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:pe.sessionId})),t();return}if(!(!pe.nativeKey&&!pe.resumeHistoryId)){F(pe.sessionId),n(null);try{const J=pe.nativeKey?await m9(pe.nativeKey):await n3(pe.resumeHistoryId);if("sessionId"in J&&J.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:J.sessionId}));else if(J.command)r({mode:"shell",cwd:J.cwd,command:J.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(J){n(J instanceof Error?J.message:"恢复失败")}finally{F(null)}}}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"历史会话搜索"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"搜索当前服务的 Codex、Claude 历史对话和 Termdock 终端记录,未启动的会话也能找到并恢复。"})]}),s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"搜索历史会话"}),s.jsx(Yl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:ee,maxLength:512,className:`${Ys} pl-9 pr-9`,value:a,onChange:pe=>G(pe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),L?s.jsx(An,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):a&&s.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>G(""),children:s.jsx(Dn,{size:13})})]}),x?.building&&s.jsxs("div",{role:"status",className:"mt-2 text-[10px] text-muted-foreground",children:["正在建立历史索引:",x.indexed,"/",x.total," 个会话。可以先搜名称和目录,对话结果会自动补齐。"]}),x?.warning&&s.jsx("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:x.warning}),!!x?.failed&&s.jsxs("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:[x.failed," 个会话暂未完成索引,其余结果可正常使用。请稍后刷新重试。"]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[a.trim()?`找到 ${f} 个会话`:"最近的会话",f>l.length?` · 显示 ${l.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:L,className:`${Er} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>C(pe=>pe+1),children:[s.jsx(An,{size:12}),"刷新"]})]}),!a.trim()&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:"记得之前讨论过什么?输入一句话中的关键词,就能找到对应会话。历史对话与索引保存在当前服务机器上。"}),s.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:l.map(pe=>{const J=pe.live||!!(pe.nativeKey||pe.resumeHistoryId),Re=P===pe.sessionId?"正在恢复…":pe.live?"打开会话":J?"恢复会话":"仅供查阅",Ze=pe.source==="codex"||pe.source==="claude"?pe.snippet:bF(pe),V=pe.source==="codex"?"Codex 历史":pe.source==="claude"?"Claude 历史":"终端记录",ve=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-words text-[12px] font-medium text-foreground",children:s.jsx(qm,{value:pe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(qm,{value:pe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${pe.live?"text-[var(--success)]":J?"text-primary":"text-muted-foreground"}`,children:Re})]}),Ze&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(qm,{value:Ze,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[V," · ",sp(pe.updatedAt),a.trim()?` · ${pe.matchCount>=999?"999+":pe.matchCount} 处匹配`:"",J?"":" · 没有可恢复记录"]}),pe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:pe.agentNativeSessionId})]});return J?s.jsx("button",{disabled:!!P,onClick:()=>{de(pe)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:ve},pe.nativeKey||pe.sessionId):s.jsx("article",{className:"px-2 py-3",children:ve},pe.sessionId)})}),f>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:L,className:`${Er} w-full bg-surface-2 text-foreground`,onClick:()=>v(pe=>pe+50),children:L?"正在加载…":"加载更多会话"}),D&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",D,s.jsx("button",{type:"button",className:`${Er} ml-2`,onClick:()=>C(pe=>pe+1),children:"重试"})]}),!L&&!D&&l.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx("p",{className:"text-[12px] text-foreground",children:x?.building?"历史对话仍在索引,请稍候":x?.warning||x?.failed?"暂未找到结果,部分历史记录尚不可搜索":a.trim()?`没有找到“${a.trim()}”`:"当前服务还没有可搜索的历史会话"}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x?.building?"新结果会自动显示,也可以先搜会话名称或目录。":"可尝试更短的关键词、项目目录或 session ID;其他机器的历史需切换到对应服务搜索。"}),a.trim()&&s.jsx("button",{className:`${Er} mt-3 bg-surface-2 text-foreground`,onClick:()=>G(""),children:"查看最近会话"})]})]})}function np(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function bF(e){let t=np(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return np(t)}function yF(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(n=>`周${t[n]}`).join("、")} ${e.schedule.time}`}function vF(e,t=Date.now(),r=t){if(e.kind==="interval"){const c=e.everyMinutes*6e4,l=Math.max(0,t-r);return r+(Math.floor(l/c)+1)*c}const[n,a]=e.time.split(":").map(Number);for(let c=0;c<=7;c+=1){const l=new Date(t);if(l.setDate(l.getDate()+c),l.setHours(n,a,0,0),l.getTime()>t&&e.weekdays.includes(l.getDay()))return l.getTime()}return t}function sp(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function wF(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function AF(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function TF({text:e}){return s.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}const t0=64,ny=10,SF=120;function CF({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:c,compact:l}){const d=b.useRef(null),f=b.useRef(null),m=b.useRef(0),[x,y]=b.useState(null),w=x??(t?t0:0);return b.useEffect(()=>{if(!t)return;const v=T=>{T.target instanceof Node&&!d.current?.contains(T.target)&&r(!1)};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[t,r]),s.jsxs("div",{ref:d,"data-sidebar-gesture-ignore":!0,"data-session-swipe":!0,className:`relative flex min-w-0 flex-1 items-center ${l?"":"gap-1"}`,style:{touchAction:"pan-y"},onPointerDown:v=>{if(m.current=0,!(v.pointerType!=="touch"&&v.pointerType!=="pen")){if(v.isPrimary===!1){f.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(f.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?t0:0,offset:t?t0:0,horizontal:!1})}},onPointerMove:v=>{const T=f.current;if(!T||T.pointerId!==v.pointerId)return;const C=v.clientX-T.x,L=v.clientY-T.y;if(!T.horizontal){if(v.defaultPrevented||Date.now()-T.startedAt>=SF||Math.abs(L)>ny){f.current=null;return}if(Math.abs(C)<=ny)return;if(Math.abs(C)<Math.abs(L)*1.5||!t&&C<0){f.current=null;return}T.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),T.offset=Math.max(0,Math.min(t0,T.initialOffset+C)),y(T.offset)},onPointerUp:v=>{const T=f.current;!T||T.pointerId!==v.pointerId||(f.current=null,T.horizontal&&(m.current=Date.now()+600,r(T.offset>=t0/2),y(null)))},onPointerCancel:()=>{f.current?.horizontal&&(m.current=Date.now()+600),f.current=null,y(null)},onClickCapture:v=>{if(Date.now()<m.current){m.current=0,v.preventDefault(),v.stopPropagation();return}t&&v.target instanceof Element&&v.target.closest(".sidebar-session-primary")&&(r(!1),v.preventDefault(),v.stopPropagation())},onKeyDown:v=>{t&&v.key==="Escape"&&(v.stopPropagation(),r(!1))},children:[s.jsx("div",{className:"shrink-0 overflow-hidden rounded-md transition-[width] duration-150 ease-out motion-reduce:transition-none",style:{width:w,transition:x===null?void 0:"none"},children:w>0&&s.jsxs("button",{type:"button",tabIndex:t?0:-1,"aria-hidden":!t,"aria-label":c,className:"flex min-h-8 w-16 flex-col items-center justify-center gap-0.5 bg-destructive py-1 text-[10px] text-destructive-foreground",onClick:v=>{v.stopPropagation(),r(!1),n(v)},children:[s.jsx(zs,{size:14}),a]})}),e]})}const sy="recoverable-tmux";function _F({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=Gr(),d=Vt(N=>N.collapsedGroups.has(sy)),f=Vt(N=>N.toggleGroupCollapsed),[m,x]=b.useState(null),[y,w]=b.useState(null),[v,T]=b.useState(null),C=b.useRef(!1),L=async N=>{if(!(!c||C.current)){C.current=!0,w(N),T(null);try{await c(N),x(null)}catch(D){T(D instanceof Error?D.message:l("sidebar.closeRecoverableSessionFailed"))}finally{C.current=!1,w(null)}}};return e.length===0?null:s.jsxs("section",{className:"mb-2 shrink-0 rounded-lg bg-[rgb(var(--tmux-rgb)_/_0.07)] p-1","aria-label":l("sidebar.recoverableSessions"),children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] font-semibold text-[color:var(--tmux)]",children:[s.jsxs("button",{type:"button","aria-expanded":!d,onClick:()=>f(sy),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left hover:bg-surface-elevated md:min-h-8",children:[s.jsx(Ks,{size:12,className:`shrink-0 ${d?"":"rotate-90"}`}),s.jsx(Vc,{size:12,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l("sidebar.recoverableSessions")}),s.jsx("span",{className:"text-muted-foreground",children:e.length})]}),n&&s.jsx("button",{type:"button",onClick:n,disabled:t||y!==null,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.refreshRecoverableSessions"),title:l("sidebar.refreshRecoverableSessions"),children:s.jsx(An,{size:11,className:t?"animate-spin":""})})]}),!d&&s.jsx("div",{className:"space-y-0.5",children:e.map(N=>{const D=N.friendlyName?.trim()||N.label?.trim()||N.name,O=dd(N.cwd??null),P=r===N.name,F=m===N.name;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsxs("button",{type:"button",disabled:r!==null||y!==null||F,onClick:()=>a(N),className:"group flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-60 md:min-h-10","aria-label":l("sidebar.restoreRecoverableSession",{name:D}),title:N.cwd||N.name,children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--tmux-rgb)_/_0.11)] text-[color:var(--tmux)]",children:P?s.jsx(Rn,{size:12,className:"animate-spin"}):s.jsx(su,{size:12})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:D}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[N.program,O].filter(Boolean).join(" · ")||`tmux:${N.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:l(P?"sidebar.restoringRecoverableSession":"sidebar.restore")})]}),c&&s.jsx("button",{type:"button",disabled:r!==null||y!==null,onClick:()=>{x(N.name),T(null)},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.closeSession",{name:D}),title:l("sidebar.closeSession",{name:D}),children:s.jsx(Dn,{size:12})})]}),F&&s.jsxs("div",{role:"group","aria-label":l("sidebar.closeSession",{name:D}),className:"space-y-2 rounded-md bg-surface px-2 py-2",children:[s.jsx("p",{className:"text-[11px] text-foreground",children:l("sidebar.confirmCloseRecoverableSession",{name:D})}),v&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:v}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{x(null),T(null)},className:"min-h-11 rounded-md px-2 text-[11px] text-muted-foreground hover:bg-surface-elevated disabled:opacity-50 md:min-h-8",children:l("common.cancel")}),s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{L(N.name)},className:"min-h-11 rounded-md bg-destructive/15 px-2 text-[11px] text-destructive hover:bg-destructive/25 disabled:opacity-50 md:min-h-8",children:y===N.name?l("common.loading"):l("sidebar.endRecoverableSession")})]})]})]},N.name)})})]})}const Du="flex min-h-11 w-full items-center gap-2.5 rounded-lg px-3 text-left text-xs transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",iy="min-h-11 rounded-lg px-4 text-xs transition disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary";function kF({group:e,collapsed:t,onOpen:r,onMessages:n,onToggleCollapsed:a,onChanged:c,children:l}){const[d,f]=b.useState(null),[m,x]=b.useState(null),[y,w]=b.useState(""),[v,T]=b.useState(!1),C=b.useRef(!1),[L,N]=b.useState(""),D=b.useRef(null),O=b.useRef(null),P=b.useRef(null),F=b.useRef(null),ee=b.useRef(null),Z=b.useId(),G=qg(),de=()=>ee.current?.isConnected?ee.current:O.current,pe=()=>{C.current||(x(null),N(""))};ru(P,!!d,()=>f(null),de),ru(F,!!m,pe,de);const J=ve=>{ee.current=document.activeElement instanceof HTMLElement&&D.current?.contains(document.activeElement)?document.activeElement:O.current;const qe=O.current?.getBoundingClientRect();f(ve??{x:qe?.left??8,y:qe?.bottom??8})};b.useEffect(()=>{d&&P.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0})},[d]),b.useEffect(()=>{if(!d)return;const ve=le=>{le.target instanceof Node&&!P.current?.contains(le.target)&&!D.current?.contains(le.target)&&f(null)},qe=le=>{le.target instanceof Node&&P.current?.contains(le.target)||f(null)};return document.addEventListener("pointerdown",ve),window.addEventListener("resize",qe),window.addEventListener("scroll",qe,!0),()=>{document.removeEventListener("pointerdown",ve),window.removeEventListener("resize",qe),window.removeEventListener("scroll",qe,!0)}},[d]),b.useLayoutEffect(()=>{if(!d||!P.current)return;const ve=window.visualViewport,qe=(ve?.offsetLeft??0)+8,le=(ve?.offsetTop??0)+8,ye=Math.min(240,(ve?.width??innerWidth)-16),Te=le+(ve?.height??innerHeight)-16;Object.assign(P.current.style,{width:`${ye}px`,maxHeight:`${Te-le}px`,left:`${Math.max(qe,Math.min(d.x,qe+(ve?.width??innerWidth)-16-ye))}px`,top:`${Math.max(le,Math.min(d.y,Te-P.current.offsetHeight))}px`})},[d]);const Re=ve=>{f(null),ve()},Ze=ve=>{N(""),w(e.name),x({kind:ve,group:e})},V=async()=>{if(!(!m||C.current||m.kind==="rename"&&!y.trim())){C.current=!0,T(!0),N("");try{const ve=m.group,qe=m.kind==="delete"?(await t3(ve.id,ve.updatedAt),null):m.kind==="archive"||m.kind==="unarchive"?await x9(ve,m.kind==="archive"):(await ql({id:ve.id,name:y.trim(),sessionIds:ve.sessionIds,expectedUpdatedAt:ve.updatedAt})).group;x(null),c(qe)}catch(ve){const qe=ve instanceof Error?ve.message:"操作失败,请重试";N(qe.includes("协作组已变化")?"协作组刚刚发生变化,请取消后重新打开操作。":qe)}finally{C.current=!1,T(!1)}}};return s.jsxs("div",{ref:D,className:"flex min-w-0 items-center","data-sidebar-gesture-ignore":!0,...G(()=>J()),onContextMenu:ve=>{ve.preventDefault(),ve.stopPropagation(),J({x:ve.clientX,y:ve.clientY})},onKeyDown:ve=>{(ve.key==="ContextMenu"||ve.shiftKey&&ve.key==="F10")&&(ve.preventDefault(),ve.stopPropagation(),J())},children:[l,s.jsx("button",{ref:O,type:"button","aria-label":`协作组操作:${e.name}`,title:"协作组操作","aria-haspopup":"menu","aria-expanded":!!d,"aria-controls":d?`${Z}-menu`:void 0,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-7",onClick:ve=>{ve.stopPropagation(),d?f(null):J()},children:s.jsx(Ro,{size:14})}),d&&ci.createPortal(s.jsxs("div",{ref:P,id:`${Z}-menu`,role:"menu",tabIndex:-1,"aria-label":`协作组操作:${e.name}`,"data-sidebar-gesture-ignore":!0,className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)]",onKeyDown:ve=>{const qe=Array.from(ve.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)')),le=qe.indexOf(document.activeElement),ye=ve.key==="ArrowDown"?(le+1)%qe.length:ve.key==="ArrowUp"?(le-1+qe.length)%qe.length:ve.key==="Home"?0:ve.key==="End"?qe.length-1:null;ye!==null&&(ve.preventDefault(),ve.stopPropagation(),qe[ye]?.focus({preventScroll:!0})),ve.key==="Tab"&&(ve.preventDefault(),f(null))},children:[s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Du,onClick:()=>Re(r),children:[s.jsx(su,{size:15}),"打开看板"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,disabled:!n,className:`${Du} disabled:opacity-40`,onClick:()=>Re(()=>n?.()),children:[s.jsx(hd,{size:15}),"成员与消息"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Du,onClick:()=>Re(a),children:[s.jsx(Ks,{size:15,className:t?"":"rotate-90"}),t?"展开成员会话":"收起成员会话"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Du,onClick:()=>Re(()=>Ze("rename")),children:[s.jsx(Zu,{size:15}),"重命名协作组"]}),!e.federated&&s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Du,onClick:()=>Re(()=>Ze(e.archivedAt===void 0?"archive":"unarchive")),children:[s.jsx(Sf,{size:15}),e.archivedAt===void 0?"归档协作组":"恢复显示"]}),s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:`${Du} text-destructive`,onClick:()=>Re(()=>Ze("delete")),children:[s.jsx(zs,{size:15}),"删除协作组"]})]}),document.body),m&&ci.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-black/50 backdrop-blur-sm",onClick:pe}),s.jsxs("section",{ref:F,role:"dialog","aria-modal":"true","aria-labelledby":`${Z}-title`,"aria-describedby":`${Z}-description`,tabIndex:-1,className:"fixed left-1/2 top-1/2 z-modal-panel max-h-[calc(100dvh-2rem)] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 text-foreground shadow-[0_28px_70px_var(--app-shadow-strong)]",children:[s.jsxs("header",{className:"flex items-center gap-2",children:[s.jsx("h2",{id:`${Z}-title`,className:"min-w-0 flex-1 text-sm font-semibold",children:m.kind==="delete"?"删除协作组":m.kind==="archive"?"归档协作组":m.kind==="unarchive"?"恢复协作组显示":"重命名协作组"}),s.jsx("button",{type:"button","aria-label":"关闭协作组操作",disabled:v,className:"flex h-11 w-11 items-center justify-center rounded-lg hover:bg-surface-2",onClick:pe,children:s.jsx(Dn,{size:16})})]}),s.jsx("p",{id:`${Z}-description`,className:"my-3 break-words text-xs leading-6 text-muted-foreground",children:m.kind==="delete"?s.jsxs(s.Fragment,{children:["确定删除“",m.group.name,"”?协作组及组内消息会被移除,成员终端会保留。此操作无法撤销。",m.group.federated&&"删除会同步到其他服务。"]}):m.kind==="archive"?s.jsxs(s.Fragment,{children:["归档“",m.group.name,"”后,它会从默认侧栏隐藏。组、成员、消息和历史都会保留,之后可以恢复显示。"]}):m.kind==="unarchive"?s.jsxs(s.Fragment,{children:["恢复“",m.group.name,"”的显示后,它会重新出现在侧栏;不会自动恢复已关闭的会话。"]}):"修改协作组的名称。"}),s.jsxs("form",{onSubmit:ve=>{ve.preventDefault(),V()},children:[m.kind==="rename"&&s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,required:!0,maxLength:256,disabled:v,className:"mt-2 min-h-11 w-full rounded-lg border border-border/30 bg-surface-2 px-3 text-sm text-foreground outline-none focus:border-primary",value:y,onChange:ve=>w(ve.target.value)})]}),L&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs leading-5 text-destructive",children:L}),s.jsxs("footer",{className:"mt-4 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:v,className:`${iy} bg-surface-2`,onClick:pe,children:"取消"}),s.jsxs("button",{type:"submit",disabled:v||m.kind==="rename"&&!y.trim(),className:`${iy} inline-flex items-center gap-2 ${m.kind==="delete"?"bg-destructive text-destructive-foreground":"bg-primary text-primary-foreground"}`,children:[v&&s.jsx(An,{size:14,className:"animate-spin"}),v?m.kind==="delete"?"正在删除…":"正在保存…":m.kind==="delete"?"确认删除":m.kind==="archive"?"归档并隐藏":m.kind==="unarchive"?"恢复显示":"保存名称"]})]})]})]})]}),document.body)]})}function LF(e,t){return lg(e.filter(r=>r.archivedAt===void 0),t)}function r0(e,t){const r=new Set(e),n=t.filter(c=>c.sessionIds.length>=2&&c.sessionIds.every(l=>r.has(l))),a=new Set;return e.flatMap(c=>{const l=n.find(d=>d.sessionIds.includes(c));return l?a.has(l.id)?[]:(a.add(l.id),[{sessionIds:l.sessionIds,workspace:l}]):[{sessionIds:[c]}]})}function n0(e,t,r,n=[]){const a=new Map,c=new Map,l=new Set(e.map(x=>x.id));for(const x of n){const y=x.sessionIds.filter(v=>l.has(v));if(!y.length)continue;const w=y.length===x.sessionIds.length?x:{...x,sessionIds:y};y.forEach(v=>a.set(v,w))}for(const x of t)if(!(x.sessionIds.length<2||!x.sessionIds.every(y=>l.has(y)))&&!x.sessionIds.some(y=>a.has(y)))for(const y of x.sessionIds)c.set(y,x);const d=new Set,f=new Set,m=[];for(const x of e){const y=a.get(x.id);if(y){if(d.has(y.id))continue;d.add(y.id);const T=y.sessionIds.flatMap(C=>{const L=r.get(C);return L?[L]:[]});m.push({kind:"collaboration",id:`collaboration:${y.id}`,group:y,members:T,sessionIds:y.sessionIds});continue}const w=c.get(x.id);if(!w){m.push({kind:"session",id:`session:${x.id}`,session:x,sessionIds:[x.id]});continue}if(f.has(w.id))continue;f.add(w.id);const v=w.sessionIds.flatMap(T=>{const C=r.get(T);return C?[C]:[]});m.push({kind:"workspace",id:`workspace:${w.id}`,workspace:w,members:v,sessionIds:w.sessionIds})}return m}function ay(e,t,r){const n=Math.min(e.length,Math.max(0,r)),a=e.slice(0,n).flatMap(l=>l.sessionIds.filter(d=>d!==t)),c=e.slice(n).flatMap(l=>l.sessionIds.filter(d=>d!==t));return[...a,t,...c]}function IF({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(uO,{status:e,detail:t,needsReview:r,inCopyMode:n})}function oy({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:c,sessionStates:l,onJumpToNextAttention:d,onNewSession:f,onCloseSession:m,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:w,splitWorkspaces:v,onSetSplitLayout:T,onReorderSplitWorkspace:C,onCombineSplitSessions:L,onReorderSessions:N,onSessionMenu:D,onOpenSettings:O,onOpenQuota:P,updateState:F,updateActionPending:ee=!1,onConfirmUpdateRestart:Z,onRetryUpdate:G,serverHealthState:de,tmuxAvailable:pe=!0,defaultSessionMode:J="shell",push:Re,pinned:Ze,onTogglePinned:V,recoverableTmuxSessions:ve=[],recoverableTmuxSessionsLoading:qe=!1,onRefreshRecoverableTmuxSessions:le,onCloseRecoverableTmuxSession:ye}){const{t:Te}=Gr(),[,Fe]=b.useState(0),[se,De]=b.useState(null),[_e,Me]=b.useState(!1),[Ke,Ne]=b.useState(!1),[ae,ze]=b.useState(null),at=b.useRef(!1),ct=b.useRef(0),me=b.useCallback(W=>{W||(ct.current+=1),Me(W)},[]),[ut,ft]=b.useState(!1),Se=$i(W=>W.groupId),[He,ke]=b.useState({}),z=ut||Object.keys(He).length>0,ie=b.useRef(!1),ge=b.useRef(!1),[We,tt]=b.useState(null);b.useEffect(()=>{let W=!1;return Cc().then(Ie=>{W||ie.current||ke(Object.fromEntries(k3(Ie.collaborationPanels?.[op()]).map(Ye=>[Ye,!0])))}).catch(()=>{}),()=>{W=!0}},[]);const wt=async(W,Ie)=>{ie.current=!0,await Xa({floatingGroupId:Ie},W),ke(Ye=>({...Ye,[W]:Ie!==null}))},[Zt,Ut]=b.useState([]),[Mt,nr]=b.useState(!1),[jt,Xt]=b.useState(null),[Bt,Ht]=b.useState(null),[xe,Je]=b.useState(null),[ot,Nt]=b.useState(null),K=$u(W=>W.tasks),xt=$u(W=>W.allTasks),[tr,$e]=b.useState(0),[Qr,Ce]=b.useState(null),St=b.useRef(!1),[Ot,Jt]=b.useState({}),lt=$u(W=>W.error),[Ct,ar]=b.useState(!1),[_r,Nr]=b.useState(!1);b.useEffect(()=>ou(()=>{$u.getState().refresh()},5e3,[k0]),[]);const zr=async W=>(me(!1),ie.current=!0,W?($i.getState().open(W),Wr(),!0):(ft(!0),Wr(),!0)),Tt=If(W=>W.collaborationGroups),Ft=If(W=>W.setCollaborationGroups),[we,At]=b.useState({mode:J}),{preference:st,agents:bt,detecting:Tn,refresh:bn,selectAgent:nn}=FO(),Oe=b.useRef(null);let _t=!1;if(F?.latestVersion)try{_t=SQ(F.latestVersion,F.currentVersion)>0}catch{}const gt=!!(_t&&F&&["checking","installing","ready","restarting","error"].includes(F.status)),Wt=!!de?.attention,$t=[Te("sidebar.moreActions"),Wt?Te("sidebar.serverAttention"):null,gt&&F?.latestVersion?Te("sidebar.updateAvailable",{version:F.latestVersion}):null].filter(Boolean).join(": "),Ar=Vt(W=>W.groupByFolder),Sn=Vt(W=>W.collapsedGroups),Mn=Vt(W=>W.toggleGroupCollapsed),vn=b.useRef(null),dn=b.useRef(null),kn=b.useRef(null),Hr=b.useRef(0),ne=b.useRef(!1),Xe=b.useRef(null),Dt=b.useRef(null),[ur,Fr]=b.useState(!1),Zr=b.useRef([]),an=b.useRef(null),Mr=b.useRef(null),Vr=b.useRef(new Set),Ln=b.useRef(null),tn=b.useMemo(()=>new Set(v.flatMap(W=>W.sessionIds)),[v]),Ur=b.useMemo(()=>new Map(a.map(W=>[W.id,W])),[a]),Xr=b.useMemo(()=>LF(Tt,new Set(Ur.keys())),[Tt,Ur]),vr=b.useMemo(()=>lg(Tt.filter(W=>W.archivedAt!==void 0),new Set(Ur.keys())),[Tt,Ur]),on=b.useCallback(async()=>{const W=++Hr.current;try{const Ie=await sg();if(W!==Hr.current)return;Ft(Array.isArray(Ie.groups)?Ie.groups:[])}catch{if(W!==Hr.current)return;Ft(Ie=>Ie.map(Ye=>({...Ye,remoteSessions:Ye.remoteSessions?.map(rt=>({...rt,status:"offline",serviceConnected:!1}))})))}},[]);b.useEffect(()=>r3(W=>Ft(W.groups)),[]),b.useEffect(()=>{const W=ou(()=>{on()},1e4,["focus",k0]);return()=>{Hr.current+=1,W()}},[on]),b.useEffect(()=>{(e||!z)&&on()},[z,e,on]);const Jr=b.useCallback(()=>{Zr.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(W=>{const Ie=W.dataset.collaborationMember??"",Ye=W.hasAttribute("data-collaboration-background"),rt=W.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!Ie&&!Ye||!rt)return[];const nt=[];for(let yt=W.parentElement;yt;yt=yt.parentElement)nt.push({element:yt,top:yt.scrollTop,left:yt.scrollLeft});return[{element:W,sessionId:Ie,groupId:rt,background:Ye,rect:W.getBoundingClientRect(),scrollParents:nt}]})},[]),hn=b.useCallback((W,Ie)=>{if(!ne.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ee=>Ee.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ee=>Ee.removeAttribute("data-drop-active"));const rt=document.elementsFromPoint(W,Ie).map(Ee=>Ee.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(rt?.dataset.collaborationGroup){rt.dataset.dropActive="true",Mr.current={kind:"collaboration",groupId:rt.dataset.collaborationGroup,background:!0};return}const nt=Zr.current.find(Ee=>{if(Ee.sessionId===Dt.current||!Ee.element.isConnected)return!1;const Ve=Ee.scrollParents.reduce((Qe,ir)=>Qe+ir.element.scrollLeft-ir.left,0),dt=Ee.scrollParents.reduce((Qe,ir)=>Qe+ir.element.scrollTop-ir.top,0);return W>=Ee.rect.left-Ve&&W<=Ee.rect.right-Ve&&Ie>=Ee.rect.top-dt+Ee.rect.height*.25&&Ie<=Ee.rect.bottom-dt-Ee.rect.height*.25});if(nt?.background){nt.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),Mr.current={kind:"collaboration",groupId:nt.groupId,background:!0};return}if(nt&&!v.find(Ve=>Ve.sessionIds.includes(nt.sessionId))?.sessionIds.includes(Dt.current??"")){nt.element.dataset.dropActive="true",Mr.current={kind:"split",sessionId:nt.sessionId,groupId:nt.groupId};return}const yt=document.elementsFromPoint(W,Ie).filter(Ee=>{const Ve=Ee.closest("[data-rfd-draggable-id]");return!Ve||!["session:","split-member:","collaboration-member:"].some(dt=>Ve.dataset.rfdDraggableId===`${dt}${Dt.current}`)}),Pt=yt.map(Ee=>Ee.closest("[data-collaboration-group]")).find(Ee=>Ee?.dataset.collaborationGroup);if(Pt?.dataset.collaborationGroup){const Ee=Pt.dataset.collaborationGroup,Ve=yt.map(rr=>rr.closest("[data-collaboration-split]")).find(Boolean),dt=yt.map(rr=>rr.closest("[data-collaboration-member]")).find(Boolean),Qe=dt?.dataset.collaborationMember??Ve?.dataset.splitAnchor,ir=Ee===Xe.current&&v.some(rr=>rr.sessionIds.includes(Qe??"")&&rr.sessionIds.includes(Dt.current??""));if(Qe&&!ir&&(Ee!==Xe.current||!dt&&Ve)){Pt.dataset.dropActive="true";const rr=dt??Ve;rr&&(rr.dataset.dropActive="true"),Mr.current={kind:"split",sessionId:Qe,groupId:Ee}}else{const rr=yt.some(Et=>Et.closest("[data-collaboration-background]"));(Ee!==Xe.current||rr)&&(Pt.dataset.dropActive="true"),Mr.current={kind:"collaboration",groupId:Ee,background:rr}}return}const ue=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(Ee=>Ee.dataset.sidebarEntityListId===an.current).find(Ee=>{const Ve=Ee.getBoundingClientRect();return W>=Ve.left&&W<=Ve.right&&Ie>=Ve.top-8&&Ie<=Ve.bottom+8});if(!ue){Mr.current=null;return}const R=Array.from(ue.children).filter(Ee=>Ee instanceof HTMLElement&&Ee.hasAttribute("data-sidebar-entity-index")),U=R.findIndex(Ee=>{const Ve=Ee.getBoundingClientRect();return Ie<Ve.top+Ve.height/2}),X=U<0?R.length:U;Mr.current={kind:"list",listId:ue.dataset.sidebarEntityListId??"",index:X};const be=Array.from(ue.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(Ee=>Ee.dataset.splitExitDropIndex===String(X));be instanceof HTMLElement&&(be.dataset.active="true")},[v]);b.useEffect(()=>{const W=Ye=>hn(Ye.clientX,Ye.clientY),Ie=Ye=>{const rt=Ye.touches[0];rt&&hn(rt.clientX,rt.clientY)};return window.addEventListener("pointermove",W),window.addEventListener("touchmove",Ie,{passive:!0}),()=>{window.removeEventListener("pointermove",W),window.removeEventListener("touchmove",Ie)}},[hn]);const jr=b.useCallback((W,Ie)=>{try{W(Ie)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach(Ye=>{delete Ye.dataset.sidebarDragging}),ne.current=!1,Zr.current=[],Fr(!1),Xe.current=null,Dt.current=null,an.current=null,Mr.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ye=>Ye.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ye=>Ye.removeAttribute("data-drop-active"))}},[]),zn=b.useMemo(()=>a.filter(W=>!tn.has(W.id)),[a,tn]),mn=b.useMemo(()=>{let W=0;for(const Ie of a)l.get(Ie.id)?.agentStatus==="working"&&(W+=1);return W},[a,l]);b.useLayoutEffect(()=>{const W=vn.current,Ie=dn.current;if(!e||!W||!Ie){kn.current=null;return}const Ye=Ie.getBoundingClientRect(),rt=W.getBoundingClientRect(),nt={item:W,top:Math.round(rt.top-Ye.top+Ie.scrollTop),height:Math.round(rt.height),viewportHeight:Ie.clientHeight},yt=kn.current;if(kn.current=nt,yt?.item===nt.item&&yt.top===nt.top&&yt.height===nt.height&&yt.viewportHeight===nt.viewportHeight||ne.current||Ie.clientHeight===0)return;const Pt=8,H=rt.top-Ye.top,ue=rt.bottom-Ye.top;H<Pt?Ie.scrollTop+=H-Pt:ue>Ie.clientHeight-Pt&&(Ie.scrollTop+=ue-Ie.clientHeight+Pt)});const qr=b.useMemo(()=>{if(!Ar||!c)return null;const W=l.get(c)?.cwd??null;return aC(W)},[Ar,c,l]);b.useEffect(()=>{if(!Ar){Ln.current=null,Vr.current.clear();return}if(!c){Ln.current=null;return}const W=Vt.getState(),Ie=Vr.current,Ye=Ln.current,rt=qr;Ye!==null&&Ye!==rt&&Ie.has(Ye)&&(W.collapsedGroups.has(Ye)||W.toggleGroupCollapsed(Ye),Ie.delete(Ye)),rt!==null&&rt!==""&&W.collapsedGroups.has(rt)&&(W.toggleGroupCollapsed(rt),Ie.add(rt)),Ln.current=rt},[Ar,c,qr]),b.useEffect(()=>{e||me(!1)},[e]),b.useEffect(()=>{At(W=>({...W,command:st?.command}))},[st]),b.useEffect(()=>{if(!_e)return;let W=!1;return nr(!0),Ht(null),Nx().then(Ie=>{W||Ut(Ie)}).catch(()=>{W||Ht(Te("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{W||nr(!1)}),()=>{W=!0}},[_e,Te]),b.useEffect(()=>{if(!se)return;const W=Ie=>{Ie instanceof KeyboardEvent&&Ie.key!=="Escape"||Ie instanceof PointerEvent&&Ie.target instanceof Node&&Oe.current?.contains(Ie.target)||De(null)};return window.addEventListener("pointerdown",W),window.addEventListener("keydown",W),()=>{window.removeEventListener("pointerdown",W),window.removeEventListener("keydown",W)}},[se]);const Wr=()=>{!Re&&!Ze&&r()};b.useEffect(()=>{const W=Ie=>{me(!1);const{groupId:Ye,dock:rt}=Ie.detail;ie.current=!0,ss.getState().setDock(Ye,{...rt,preferredWidth:360}),ke(nt=>({...nt,[Ye]:!0})),$i.getState().terminal(),Wr()};return window.addEventListener("termdock:open-collaboration-messages",W),()=>window.removeEventListener("termdock:open-collaboration-messages",W)},[Wr]);const Y=J==="tmux"&&!pe?"shell":J,Be=(W,Ie=!1)=>{if(at.current)return;at.current=!0,Ne(!0),ze(null);const Ye=ct.current;f({...W,shouldActivate:()=>Ye===ct.current&&(W.shouldActivate?.()??!0),onResult:rt=>{if(at.current=!1,Ne(!1),!rt.ok){ze(rt.error);return}Ye===ct.current&&(Ie&&me(!1),Wr())}})},Qt=()=>{Be({mode:Y})},er=()=>{st&&Be({mode:Y,command:st.command})},sr=W=>{me(!1),Je(W.name),f({mode:"tmux",tmuxSessionName:W.name,cwd:W.cwd??void 0}),Wr()};b.useEffect(()=>{xe&&(ve.some(W=>W.name===xe)||Je(null))},[xe,ve]);const $r=(W,Ie)=>{Be({...we,cwd:we.cwd?.trim()||void 0,command:Ie??W?.command},!0)},Ir=async W=>{Xt(W.id),Ht(null);try{const Ie=await n3(W.id);Be({mode:"shell",cwd:Ie.cwd,command:Ie.command},!0)}catch(Ie){const Ye=Ie&&typeof Ie=="object"&&"code"in Ie?String(Ie.code??""):"";Ht(Te(Ye==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Xt(null)}},Zn=async W=>{Ut(Ie=>Ie.filter(Ye=>Ye.id!==W));try{await k9(W)}catch{Ht(Te("sidebar.resumeHistoryRemoveFailed")),Nx().then(Ut).catch(()=>{})}},ys=()=>{if(_e){me(!1);return}at.current||(ct.current+=1,at.current||ze(null),At({mode:J==="tmux"&&!pe?"shell":J,cwd:c?l.get(c)?.cwd??void 0:void 0,command:st?.command}),me(!0))},is=b.useCallback(W=>{const Ie=l.get(W);return Ie?.agentStatus==="waiting"||Ie?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Ie?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Ie?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),Hn=qg(),[fn,Bn]=b.useState(null);b.useEffect(()=>{e||Bn(null)},[e]);const Xn=b.useCallback((W,Ie,Ye,rt,nt)=>{const yt=!Se&&W.id===c,Pt=tn.has(W.id),H=!!(Ye&&Pt),ue=l.get(W.id),R=dd(ue?.cwd??null),U=ue?.shellTitle??b9(W.id),X=U===ue?.cwd||U===R?null:U,be=y9(W,ue?.activeProgram??null,null,v9,X,ue?.promptState??null),Ee=!!(ue?.tuiProgress&&ue.tuiProgress.state!=="remove"),dt=ue?.promptState==="running"||ue?.agentStatus==="working"||Ee?"bg-[var(--success)]":ue?.agentStatus==="waiting"||ue?.agentNeedsReview?"bg-[var(--warning)]":ue?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(CF,{open:fn===W.id,onOpenChange:Qe=>Bn(ir=>Qe?W.id:ir===W.id?null:ir),onClose:Qe=>m(W.id,Qe,{skipConfirmation:!0}),closeLabel:Te("common.close"),closeTitle:Te("sidebar.closeSession",{name:be}),compact:Ye,children:[s.jsxs("button",{ref:yt?vn:null,type:"button",...Ie??{},onContextMenu:Qe=>{D&&(Qe.preventDefault(),D(W.id,{x:Qe.clientX,y:Qe.clientY}))},onClick:()=>{me(!1),$i.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:W.id})),Wr()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${Ie?"cursor-grab active:cursor-grabbing ":""}${Ye?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ue?.cwd??W.name,children:[yt&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${dt}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${Ye?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${yt?W.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":W.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[ue?.isConnecting||Ee&&!ue?.agentStatus?s.jsx(Rn,{size:Ye?10:11,className:"animate-spin"}):ue?.agent??Rx(W.id)?s.jsx(tu,{agent:ue?.agent??Rx(W.id),size:Ye?13:15}):W.mode==="tmux"?s.jsx(su,{size:Ye?10:11}):s.jsx(el,{size:Ye?10:11}),s.jsx(IF,{status:ue?.agentStatus??null,detail:ue?.agentStatusDetail,needsReview:ue?.agentNeedsReview,inCopyMode:ue?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${Ye?"text-[11px]":"text-[12px]"} ${yt?"font-medium text-foreground":""} ${ue?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:be}),s.jsx(db,{sessionIds:[W.id]})]}),rt,s.jsx("button",{type:"button",onClick:Qe=>{Qe.stopPropagation(),H?w(W.id):Pt?y(W.id):x(W.id)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Ye?"h-6 w-6":"h-[26px] w-[26px]"} ${Pt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${Te(H?"tab.splitRemovePane":Pt?"tab.splitClose":"tab.split")} ${be}`,title:Te(H?"tab.splitRemovePane":Pt?"tab.splitClose":"tab.split"),children:H?s.jsx(YS,{size:11}):s.jsx(Hl,{size:12})}),nt??s.jsx("button",{type:"button",onClick:Qe=>{Qe.stopPropagation(),m(W.id,Qe)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95 ${Ye?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":Te("sidebar.closeSession",{name:be}),title:Te("common.close"),children:s.jsx(Dn,{size:Ye?11:12})})]})},[c,tn,l,m,x,y,w,D,Te,fn]),pn=b.useMemo(()=>kf(a,W=>l.get(W.id)?.cwd??null,Ar,Te("sidebar.ungrouped"),v,Xr).groups,[Xr,Ar,a,l,v,Te]),lr=b.useMemo(()=>n0(a,v,Ur,Xr),[Xr,a,Ur,v]),as=b.useCallback(W=>{Fr(W.draggableId.startsWith("collaboration:")||W.draggableId.startsWith("workspace:"));const Ie=W.draggableId.replace(/^split-member:/,"");Dt.current=W.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const Ye=W.type==="split-member"?v.find(H=>H.sessionIds.includes(Ie)):null,rt=W.type==="collaboration-member"?W.source.droppableId.replace(/^collaboration-members:/,""):null,nt=rt?Xr.find(H=>H.id===rt):null;ne.current=!!(Ye||nt||W.type==="session"&&W.draggableId.startsWith("session:")),ne.current&&document.querySelectorAll("[data-collaboration-group]").forEach(H=>{H.dataset.sidebarDragging="true"}),Xe.current=nt?.id??null;const yt=Ye?.sessionIds??nt?.sessionIds??[],Pt=yt.length>0?pn.find(H=>yt.every(ue=>H.sessions.some(R=>R.id===ue))):null;an.current=Ar?Pt?`group-sessions:${Pt.key}`:null:yt.length>0?"sidebar-entities":null,Mr.current=null},[Xr,pn,Ar,v]),rn=b.useCallback((W,Ie,Ye)=>{if(Ie===Ye)return;const rt=Ie?Tt.find(ue=>ue.id===Ie):null,nt=Ye?Tt.find(ue=>ue.id===Ye):null;if(Ye&&!nt)return;if(nt){const ue=a.map(U=>U.id).filter(U=>U!==W);let R=-1;ue.forEach((U,X)=>{nt.sessionIds.includes(U)&&(R=X)}),R>=0&&(ue.splice(R+1,0,W),N(ue))}const yt=rt?.sessionIds.filter(ue=>ue!==W)??[],Pt=nt?[...nt.sessionIds.filter(ue=>ue!==W),W]:[];Ft(ue=>ue.flatMap(R=>R.id===Ie?[{...R,sessionIds:yt}]:R.id===Ye?[{...R,sessionIds:Pt}]:[R])),Nt(null),(rt&&nt?w9({sourceGroupId:rt.id,targetGroupId:nt.id,sessionId:W,expectedSourceUpdatedAt:rt.updatedAt,expectedTargetUpdatedAt:nt.updatedAt}):rt?ql({id:rt.id,name:rt.name,sessionIds:yt,expectedUpdatedAt:rt.updatedAt}):nt?ql({id:nt.id,name:nt.name,sessionIds:Pt,expectedUpdatedAt:nt.updatedAt}):Promise.resolve()).then(()=>on(),ue=>(Nt(ue instanceof Error?ue.message:"协作成员移动失败"),on()))},[Tt,on,a,N]),gr=b.useCallback((W,Ie,Ye,rt=!1)=>{const nt=Tt.find(Ve=>Ve.id===W);if(!nt||Ie===Ye)return;const yt=nt.sessionIds.filter(Ve=>!Ve.startsWith("remote:")),Pt=r0(yt,v).flatMap(Ve=>Ve.sessionIds),H=ob(xt,nt.id),ue=rt&&!Ot[nt.id]?Pt.filter(Ve=>!H.has(Ve)||Ve===c||tn.has(Ve)):Pt.slice(),R=new Set(ue),[U]=ue.splice(Ie,1);if(!U)return;ue.splice(Ye,0,U);let X=0;const be=Pt.map(Ve=>R.has(Ve)?ue[X++]:Ve),Ee=v.find(Ve=>Ve.sessionIds.includes(U));if(Ee&&Ee.sessionIds.every(Ve=>nt.sessionIds.includes(Ve))){const Ve=be.filter(dt=>Ee.sessionIds.includes(dt));C(Ee.id,Ve)}be.push(...nt.sessionIds.filter(Ve=>Ve.startsWith("remote:"))),Ft(Ve=>Ve.map(dt=>dt.id===W?{...dt,sessionIds:be}:dt)),Nt(null),ql({id:nt.id,name:nt.name,sessionIds:be,expectedUpdatedAt:nt.updatedAt}).then(()=>on(),Ve=>(Nt(Ve instanceof Error?Ve.message:"成员排序失败"),on()))},[Tt,on,v,C,xt,Ot,c,tn]);b.useEffect(()=>{const W=Ie=>{const{sourceId:Ye,targetId:rt}=Ie.detail;if(!Ye||!rt||Ye===rt)return;const nt=kf(a,Qe=>l.get(Qe.id)?.cwd??null,Ar,"",v,Xr).arranged.map(Qe=>Qe.id),yt=nt.indexOf(Ye),Pt=nt.indexOf(rt);if(yt<0||Pt<0)return;const H=Xr.find(Qe=>Qe.sessionIds.includes(Ye));if(H?.sessionIds.includes(rt)){const Qe=r0(H.sessionIds,v).flatMap(ir=>ir.sessionIds);gr(H.id,Qe.indexOf(Ye),Qe.indexOf(rt));return}const ue=v.filter(Qe=>Qe.sessionIds.length>=2&&Qe.sessionIds.every(ir=>Ur.has(ir))&&!Xr.some(ir=>Qe.sessionIds.some(rr=>ir.sessionIds.includes(rr)))),R=ue.find(Qe=>Qe.sessionIds.includes(Ye));if(R?.sessionIds.includes(rt)){const Qe=[...R.sessionIds];Qe.splice(Qe.indexOf(Ye),1),Qe.splice(R.sessionIds.indexOf(rt),0,Ye),C(R.id,Qe);return}const U=Qe=>Xr.find(ir=>ir.sessionIds.includes(Qe))?.sessionIds??ue.find(ir=>ir.sessionIds.includes(Qe))?.sessionIds??[Qe],X=new Set(U(Ye)),be=new Set(U(rt)),Ee=nt.filter(Qe=>!X.has(Qe)),Ve=Ee.flatMap((Qe,ir)=>be.has(Qe)?[ir]:[]),dt=yt<Pt?Math.max(...Ve)+1:Math.min(...Ve);Ee.splice(dt,0,...nt.filter(Qe=>X.has(Qe))),N(Ee)};return window.addEventListener("reorder-navigation-session",W),()=>window.removeEventListener("reorder-navigation-session",W)},[a,l,Ar,v,Xr,Ur,gr,C,N]);const wr=b.useCallback(W=>{if(W.type!=="collaboration-member")return!1;if(W.reason==="CANCEL")return!0;const Ie=W.source.droppableId.replace(/^collaboration-members:/,""),Ye=W.draggableId.replace(/^collaboration-member:/,""),rt=Mr.current;if(rt?.kind==="split")return rn(Ye,Ie,rt.groupId),L(rt.sessionId,Ye),!0;if(rt?.kind==="collaboration"&&rt.groupId!==Ie)return rn(Ye,Ie,rt.groupId),!0;if(rt?.kind==="collaboration"&&rt.background)return tn.has(Ye)&&w(Ye),!0;if(W.destination&&W.destination.droppableId!==W.source.droppableId){const nt=W.destination.droppableId.replace(/^collaboration-members:/,"");if(Xr.some(yt=>yt.id===nt))return rn(Ye,Ie,nt),!0}if(W.combine){const nt=W.combine.droppableId.replace(/^collaboration-members:/,"");nt!==Ie&&rn(Ye,Ie,nt);const yt=W.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(H=>H.sessionIds.includes(Ye))?.sessionIds.includes(yt)){const H=Xr.find(R=>R.id===Ie),ue=H?r0(H.sessionIds,v).flatMap(R=>R.sessionIds).indexOf(yt):-1;ue>=0&&H&&gr(Ie,r0(H.sessionIds,v).flatMap(R=>R.sessionIds).indexOf(Ye),ue)}else Ur.has(yt)&&L(yt,Ye);return!0}if(W.destination?.droppableId===W.source.droppableId)return gr(Ie,W.source.index,W.destination.index,!0),!0;if(rt?.kind!=="list")return!0;if(rt?.kind==="list"){const nt=pn.find(Pt=>`group-sessions:${Pt.key}`===rt.listId),yt=rt.listId==="sidebar-entities"?lr:nt?n0(nt.sessions,v,Ur,Xr):null;if(yt){const Pt=ay(yt,Ye,rt.index);rt.listId==="sidebar-entities"?N(Pt):nt&&N(pn.flatMap(H=>H.key===nt.key?Pt:H.sessions.map(ue=>ue.id)))}}return rn(Ye,Ie,null),!0},[Xr,lr,pn,rn,N,gr,Ur,v,tn,w,L]),xr=b.useCallback(W=>{if(W.type!=="split-member")return!1;if(W.reason==="CANCEL")return!0;const Ie=W.draggableId.replace(/^split-member:/,""),Ye=v.find(ue=>ue.sessionIds.includes(Ie));if(!Ye?.sessionIds.includes(Ie))return!0;const rt=Ye.id,nt=Mr.current;if(nt?.kind==="split")return rn(Ie,null,nt.groupId),L(nt.sessionId,Ie),!0;if(nt?.kind==="collaboration")return rn(Ie,null,nt.groupId),!0;if(!W.destination&&nt?.kind==="list"){const ue=pn.find(X=>`group-sessions:${X.key}`===nt.listId),R=nt.listId==="sidebar-entities"?lr:ue?n0(ue.sessions,v,Ur,Xr):null;if(!R)return!0;const U=ay(R,Ie,nt.index);return w(Ie),nt.listId==="sidebar-entities"?N(U):ue&&N(pn.flatMap(X=>X.key===ue.key?U:X.sessions.map(be=>be.id))),!0}if(!W.destination)return!0;const yt=W.destination.droppableId.replace(/^split-members:/,"");if(yt!==rt){const R=v.find(U=>U.id===yt)?.sessionIds[0];return R&&L(R,Ie),!0}if(W.source.index===W.destination.index)return!0;const Pt=[...Ye.sessionIds],[H]=Pt.splice(W.source.index,1);return H&&(Pt.splice(W.destination.index,0,H),C(rt,Pt)),!0},[Xr,lr,pn,rn,L,w,N,C,Ur,v]),ds=(W,Ie="top")=>s.jsx("div",{"data-split-exit-drop-index":W,className:`group/split-exit pointer-events-none absolute inset-x-0 z-10 h-2 ${Ie==="top"?"-top-1":"-bottom-1"}`,children:s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-1 top-1/2 h-px -translate-y-1/2 rounded-full bg-transparent transition-colors group-data-[active=true]/split-exit:bg-primary"})}),jn=b.useCallback((W,Ie,Ye)=>{if(wr(W)||xr(W)||W.reason==="CANCEL")return;const rt=Ie.find(ue=>ue.id===W.draggableId);if(!rt)return;const nt=Mr.current;if(nt?.kind==="split"&&rt.kind==="session"){rn(rt.session.id,null,nt.groupId),L(nt.sessionId,rt.session.id);return}if(nt?.kind==="collaboration"&&rt.kind==="session"){rn(rt.session.id,null,nt.groupId);return}if(W.combine&&rt.kind!=="session"){const ue=Ie.findIndex(R=>R.id===W.combine?.draggableId);if(ue<0)return;W={...W,combine:null,destination:{...W.source,index:ue}}}if(W.combine){const ue=Ie.find(Ee=>Ee.id===W.combine?.draggableId);if(!ue)return;const R=ue.kind==="workspace"?ue:rt.kind==="workspace"?rt:ue,U=R===rt?ue:rt,X=R.sessionIds[0],be=U.sessionIds[0];X&&be&&X!==be&&L(X,be);return}if(!W.destination||W.source.index===W.destination.index)return;const yt=[...Ie],[Pt]=yt.splice(W.source.index,1);if(!Pt)return;yt.splice(W.destination.index,0,Pt);const H=yt.flatMap(ue=>ue.sessionIds);if(Ye===void 0){N(H);return}N(pn.flatMap(ue=>ue.key===Ye?H:ue.sessions.map(R=>R.id)))},[pn,wr,xr,rn,L,N]),vs=b.useCallback(W=>{if(W.reason==="CANCEL"||wr(W)||xr(W))return;if(W.type==="group"){if(!W.destination||W.source.index===W.destination.index)return;N(b3(pn,W.source.index,W.destination.index));return}const Ie=W.source.droppableId.replace(/^group-sessions:/,""),Ye=pn.find(nt=>nt.key===Ie);if(!Ye)return;const rt=n0(Ye.sessions,v,Ur,Xr);if(W.combine||Mr.current?.kind==="collaboration"||Mr.current?.kind==="split"){jn(W,rt,Ie);return}!W.destination||W.destination.droppableId!==W.source.droppableId||jn(W,rt,Ie)},[Xr,pn,Ur,v,wr,jn,xr,N]),Qs=W=>{const Ie=se===W.id,Ye=[{layout:"horizontal",label:Te("tab.splitHorizontal"),icon:Hl},{layout:"vertical",label:Te("tab.splitVertical"),icon:Qx},...W.sessionIds.length>=3||W.layout==="grid"?[{layout:"grid",label:Te("tab.splitGrid"),icon:Bx}]:[]],rt=W.layout==="vertical"?Qx:W.layout==="grid"?Bx:Hl,nt=Ye.find(yt=>yt.layout===W.layout)?.label??Te("tab.splitHorizontal");return s.jsxs("div",{ref:Ie?Oe:void 0,className:"relative shrink-0",onPointerDown:yt=>yt.stopPropagation(),children:[s.jsx("button",{type:"button",className:`sidebar-session-action inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${Ie?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${Te("tab.splitLayout")}: ${nt}`,"aria-haspopup":"menu","aria-expanded":Ie,title:Te("tab.splitLayout"),onClick:yt=>{yt.stopPropagation(),De(Pt=>Pt===W.id?null:W.id)},children:s.jsx(rt,{size:12})}),Ie&&s.jsx("div",{role:"menu","aria-label":Te("tab.splitLayout"),className:"absolute right-0 top-full z-30 mt-1 flex gap-0.5 rounded-md border border-border bg-surface-elevated p-1 shadow-lg",children:Ye.map(yt=>{const Pt=yt.icon,H=yt.layout===W.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":H,"aria-label":yt.label,title:yt.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${H?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:ue=>{ue.stopPropagation(),T(W.sessionIds[0],yt.layout),De(null)},children:s.jsx(Pt,{size:13})},yt.layout)})})]})},Is=(W,Ie)=>Ie&&s.jsx("button",{type:"button",...Ie,"aria-label":W,title:W,onClick:Ye=>Ye.stopPropagation(),className:"absolute -left-2 inset-y-0 z-10 flex w-3 cursor-grab items-start justify-center pt-1.5 text-muted-foreground/60 transition hover:text-foreground focus-visible:text-foreground active:cursor-grabbing",children:s.jsx(ap,{size:10})}),Or=(W,Ie,Ye=!1,rt=!1,nt)=>{if(Ie.length<2)return null;const yt=Ie.some(X=>X.id===c),Pt=[],H=[],ue=[];for(const X of Ie){const be=l.get(X.id);be?.agentStatus==="waiting"||be?.agentNeedsReview?Pt.push(X):be?.agentStatus==="working"?H.push(X):be?.inCopyMode&&ue.push(X)}const R=W.name?.trim()||`${Te("tab.splitWorkspace")} ${v.findIndex(X=>X.id===W.id)+1}`,U=se===W.id;return s.jsxs("section",{"data-split-workspace":W.id,"aria-label":R,className:`group/split relative rounded-md p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border transition-colors ${rt?"bg-primary/15 ring-1 ring-primary/40":Ye?"bg-surface-elevated opacity-90 shadow-lg":Pt.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":H.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":ue.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":yt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[Is(`移动分屏组 ${R}`,nt),s.jsx(zl,{droppableId:`split-members:${W.id}`,type:"split-member",direction:"vertical",children:(X,be)=>s.jsxs("div",{ref:X.innerRef,...X.droppableProps,"data-split-members":!0,className:be.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[Ie.map((Ee,Ve)=>s.jsx(Ul,{draggableId:`split-member:${Ee.id}`,index:Ve,disableInteractiveElementBlocking:!0,children:(dt,Qe)=>s.jsx("div",{ref:dt.innerRef,...dt.draggableProps,...D?Hn(()=>D(Ee.id)):{},className:`${Ve===0&&U?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${Qe.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${is(Ee.id)??(Ee.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Xn(Ee,dt.dragHandleProps,!0,Ve===0?Qs(W):void 0)})},Ee.id)),X.placeholder]})})]})},br=(W,Ie)=>{const Ye=c??Ie;ge.current||!Ye||(me(!1),ge.current=!0,tt(W),Nt(null),kC(W,Ye).catch(rt=>Nt(rt instanceof Error?rt.message:"消息面板打开失败,请重试")).finally(()=>{ge.current=!1,tt(null)}))},Qn=(W,Ie)=>{Hr.current+=1,Ft(Ye=>Ie?Ye.map(rt=>rt.id===W?Ie:rt):Ye.filter(rt=>rt.id!==W)),Ie||($i.getState().groupId===W&&$i.getState().terminal(),ss.getState().setDock(W,null),ke(Ye=>{const rt={...Ye};return delete rt[W],rt}),requestAnimationFrame(()=>vn.current?.focus({preventScroll:!0})),Xa({floatingGroupId:null},W).catch(()=>Nt("协作组已删除,面板布局保存失败,请刷新后检查。"))),on()},Jn=(W,Ie,Ye,rt=!1,nt=!1)=>{const yt=`collaboration:${W.id}`,Pt=Sn.has(yt),H=`collaboration-members-${W.id}`,ue=Se===W.id||!Se&&Ie.some(Qe=>Qe.id===c),R=ob(xt,W.id),U=W.sessionIds.filter(Qe=>R.has(Qe)&&Qe!==c&&!tn.has(Qe)),X=Ot[W.id]===!0,be=X?W.sessionIds:W.sessionIds.filter(Qe=>!U.includes(Qe)),Ee=r0(be,v),Ve=Ee.flatMap(Qe=>Qe.sessionIds),dt=Ee.length===1?Ee[0]?.workspace:void 0;return s.jsxs("section",{"data-collaboration-group":W.id,"data-collaboration-group-name":W.name,"aria-label":`Agent 工作组:${W.name}`,className:`group/collaboration relative rounded-md ${Pt?"":"p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border"} transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${nt?"bg-primary/15 ring-1 ring-primary/40":rt?"bg-surface-elevated opacity-90 shadow-lg":ue?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[Is(`移动工作组 ${W.name}`,Ye),s.jsxs(kF,{group:Tt.find(Qe=>Qe.id===W.id)??W,collapsed:Pt,onOpen:()=>{zr(W.id)},onMessages:We===null&&(c||Ie.length)?()=>br(W.id,Ie[0]?.id):void 0,onToggleCollapsed:()=>Mn(yt),onChanged:Qe=>Qn(W.id,Qe),children:[s.jsx("button",{type:"button","aria-label":`${Pt?"展开":"收起"} ${W.name} 的成员会话`,"aria-expanded":!Pt,"aria-controls":H,title:`${Pt?"展开":"收起"}成员会话`,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-5",onClick:Qe=>{Qe.stopPropagation(),Mn(yt)},children:s.jsx(Ks,{size:14,className:Pt?"":"rotate-90"})}),s.jsxs("button",{type:"button",className:"flex min-h-11 min-w-0 flex-1 items-center gap-1.5 rounded-sm px-1 text-left text-xs font-medium text-foreground transition hover:text-primary md:min-h-[30px]",title:`打开 ${W.name} 的协作工作区`,"aria-label":`打开协作工作区:${W.name}`,"aria-current":Se===W.id?"page":void 0,onClick:Qe=>{Qe.stopPropagation(),zr(W.id)},children:[s.jsx(zp,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:W.name}),K.some(Qe=>Qe.groupId===W.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[K.filter(Qe=>Qe.groupId===W.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${W.name}`,title:"在终端旁打开成员与消息",disabled:We!==null||!c&&!Ie.length,"aria-busy":We===W.id,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-primary disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-7",onClick:Qe=>{Qe.stopPropagation(),br(W.id,Ie[0]?.id)},children:We===W.id?s.jsx(An,{size:14,className:"animate-spin"}):s.jsx(hd,{size:14})})]}),s.jsx("div",{id:H,children:!Pt&&s.jsxs(s.Fragment,{children:[U.length>0&&s.jsxs("button",{type:"button","aria-expanded":X,className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-elevated md:min-h-8",title:"展开后可查看或归档执行会话,任务结果保留。",onClick:()=>Jt(Qe=>({...Qe,[W.id]:!X})),children:[s.jsx(Ks,{size:12,className:X?"rotate-90":""}),"已完成的执行会话 · ",U.length]}),s.jsx(zl,{droppableId:`collaboration-members:${W.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(Qe,ir)=>s.jsxs("div",{ref:Qe.innerRef,...Qe.droppableProps,"data-collaboration-members":!0,className:`${ir.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[Ee.map(rr=>s.jsx("div",{"data-collaboration-split":rr.workspace?.id,"data-split-anchor":rr.workspace?.sessionIds[0],role:rr.workspace?"region":void 0,"aria-label":rr.workspace?`${Te("tab.splitWorkspace")} · ${rr.sessionIds.length}`:void 0,className:rr.workspace&&!dt?`relative my-0.5 rounded-sm before:pointer-events-none before:absolute before:inset-0 before:rounded-sm before:border before:border-border data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${rr.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:rr.sessionIds.map(Et=>{const kr=Ur.get(Et);return kr?s.jsx(Ul,{draggableId:`collaboration-member:${kr.id}`,index:Ve.indexOf(kr.id),disableInteractiveElementBlocking:!0,children:(ln,yn)=>s.jsxs("div",{ref:ln.innerRef,...ln.draggableProps,"data-collaboration-member":kr.id,"data-split-member":tn.has(kr.id)?"true":void 0,...D?Hn(()=>D(kr.id)):{},className:`${rr.workspace&&Et===rr.sessionIds[0]&&se===rr.workspace.id?"z-20 ":""}relative flex items-center rounded-sm pr-0.5 transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${yn.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":yn.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${is(kr.id)??(kr.id===c?"bg-surface-elevated/80 text-foreground":tn.has(kr.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Xn(kr,ln.dragHandleProps,!0,rr.workspace&&Et===rr.sessionIds[0]?Qs(rr.workspace):void 0,R.has(Et)?s.jsxs("button",{type:"button","aria-label":`归档 ${kr.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:Qr!==null,className:"sidebar-session-action inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-primary/15 hover:text-primary disabled:opacity-40 md:h-6 md:min-w-6 md:px-1",onClick:en=>{en.stopPropagation(),!St.current&&(St.current=!0,Ce(Et),Nt(null),C9(Et).then(async()=>{$e(gn=>gn+1),await on()}).catch(gn=>Nt(gn instanceof Error?gn.message:"归档失败,终端已保留")).finally(()=>{St.current=!1,Ce(null)}))},children:[Qr===Et?s.jsx(An,{size:13,className:"animate-spin"}):s.jsx(Sf,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!rr.workspace&&tn.has(kr.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(en=>en.sessionIds.includes(kr.id))?.sessionIds.filter(en=>en!==kr.id).map(en=>Ur.get(en)?.name??en).join("、")} 分屏`,"aria-label":`查看 ${kr.name} 的跨组分屏`,onClick:()=>{me(!1),$i.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:kr.id})),Wr()},children:s.jsx(Hl,{size:10})})]})},kr.id):null})},rr.workspace?.id??rr.sessionIds[0])),Qe.placeholder]})}),s.jsx(wQ,{groupId:W.id,version:tr,onRestore:async Qe=>{me(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:Qe.cwd,preferredFrontendSessionId:Qe.sessionId,requireExisting:!0}})),await on(),$i.getState().terminal(),Wr()}}),W.remoteSessions?.map(Qe=>{const ir=_9(Qe),rr=ir==="connected",Et=ir==="unknown"?"连接状态未知":"连接已断开";return s.jsxs("button",{type:"button",title:`${Ac(Qe)} · ${rr?"服务已连接":Et}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[11px] text-muted-foreground hover:bg-surface-2",onClick:()=>{me(!1),G6(Qe.sessionId).catch(()=>{zr(W.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${rr?"bg-primary":"bg-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Qe.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:Ac(Qe)}),!rr&&s.jsx("span",{className:"shrink-0 text-[9px]",children:Et})]},Qe.sessionId)})]})}),s.jsx("div",{"data-collaboration-background":!0,className:Pt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},es=(W,Ie,Ye)=>s.jsx(Yu,{onBeforeCapture:Jr,onDragStart:as,onDragEnd:rt=>jr(nt=>jn(nt,W,Ye),rt),children:s.jsx(zl,{droppableId:Ie,direction:"vertical",isCombineEnabled:!ur,children:rt=>s.jsxs("div",{ref:rt.innerRef,...rt.droppableProps,"data-sidebar-entity-list-id":Ie,className:"flex-1 space-y-0.5",children:[W.map((nt,yt)=>s.jsx(Ul,{draggableId:nt.id,index:yt,disableInteractiveElementBlocking:!0,children:(Pt,H)=>s.jsxs("div",{ref:Pt.innerRef,...Pt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":yt,className:"relative",children:[ds(yt),yt===W.length-1&&ds(W.length,"bottom"),nt.kind==="workspace"?Or(nt.workspace,nt.members,H.isDragging,!!H.combineTargetFor,Pt.dragHandleProps):nt.kind==="collaboration"?Jn(nt.group,nt.members,Pt.dragHandleProps,H.isDragging,!!H.combineTargetFor):s.jsx("div",{...D?Hn(()=>D(nt.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${H.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":H.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":is(nt.session.id)??(!Se&&nt.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(nt.session,Pt.dragHandleProps)})]})},nt.id)),rt.placeholder]})})}),ui=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsx(QO,{label:Te("sidebar.sessions"),count:a.length,badge:mn>0?s.jsx(l4,{count:mn,tone:"running",title:Te("agent.aiRunning")}):null,pinned:!!Ze,onClose:r,onTogglePinned:V?()=>{me(!1),V()}:void 0,serverAttention:Wt,onOpenSettings:()=>{me(!1),O()},actions:[...P?[{label:Te("sidebar.subscriptionQuota"),icon:aT,onSelect:()=>{me(!1),P()}}]:[],{label:"Agent 工作台",icon:zp,onSelect:()=>{me(!1),zr(null)}},{label:"服务与设备",icon:A9,onSelect:()=>{me(!1),T9()}},{label:Te("sidebar.settings"),icon:f3,onSelect:()=>{me(!1),O()}}]}),ot&&s.jsxs("div",{role:"alert",className:"mx-2 mt-2 flex items-start gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:ot}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>Nt(null),children:s.jsx(Dn,{size:14})})]}),s.jsxs("div",{ref:dn,className:"relative z-10 flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain px-1.5 pt-0.5 pb-1.5",children:[K.length>0&&s.jsxs("section",{className:"mb-2 rounded-lg border border-primary/20 bg-primary/5","aria-label":"协作待处理事项",children:[K.length>0&&s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 px-3 text-left text-xs text-primary","aria-expanded":Ct,onClick:()=>ar(W=>!W),children:[s.jsx(zp,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:K.length}),s.jsx(Ks,{size:12,className:Ct?"rotate-90":""})]}),(Ct||K.length===0)&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[lt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[lt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{$u.getState().refresh()},children:"重试"})]}),K.map(W=>s.jsxs("button",{type:"button",className:"min-h-11 w-full rounded-md px-2 py-2 text-left hover:bg-surface-2",onClick:()=>{cb(W.groupId,W.id),zr(W.groupId).then(Ie=>{Ie&&cb(W.groupId,W.id)})},children:[s.jsx("span",{className:"block truncate text-xs text-foreground",children:W.title}),s.jsxs("span",{className:"mt-1 block truncate text-[10px] text-muted-foreground",children:[Tt.find(Ie=>Ie.id===W.groupId)?.name??"协作组"," · ",cu(W)]})]},W.id))]})]}),s.jsx(_F,{sessions:ve,loading:qe,attachingName:xe,onRefresh:le,onRestore:sr,onClose:ye}),vr.length>0&&s.jsxs("section",{className:"mb-1","aria-label":"已归档协作组",children:[s.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 rounded-md px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-2","aria-expanded":_r,onClick:()=>Nr(W=>!W),children:[s.jsx(Sf,{size:13}),s.jsx("span",{className:"flex-1",children:"已归档协作组"}),s.jsx("span",{children:vr.length}),s.jsx(Ks,{size:12,className:_r?"rotate-90":""})]}),_r&&s.jsx("div",{className:"space-y-1",children:vr.map(W=>s.jsx(Yu,{onDragEnd:()=>{},children:Jn(W,W.sessionIds.flatMap(Ie=>Ur.get(Ie)??[]))},W.id))})]}),Xr.filter(W=>!W.sessionIds.length).map(W=>s.jsx(Yu,{onDragEnd:()=>{},children:Jn(W,[])},W.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx(el,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:Te("sidebar.noSessions")})]}):zn.length===0&&v.length===0?s.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:s.jsx("p",{className:"text-[12px] text-muted-foreground",children:Te("sidebar.noMatchingSessions")})}):Ar?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(Yu,{onBeforeCapture:Jr,onDragStart:as,onDragEnd:W=>jr(vs,W),children:s.jsx(zl,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:W=>s.jsxs("div",{ref:W.innerRef,...W.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[pn.map((Ie,Ye)=>{const rt=Sn.has(Ie.key),nt=!rt&&Ye===pn.length-1,yt=n0(Ie.sessions,v,Ur,Xr);let Pt=0,H=0;for(const R of Ie.sessions){const U=l.get(R.id);U?.agentStatus==="working"&&(Pt+=1),(U?.agentStatus==="waiting"||U?.agentNeedsReview)&&(H+=1)}const ue=Ie.key==="";return s.jsx(Ul,{draggableId:`sidebar-group:${Ie.key||"__ungrouped__"}`,index:Ye,isDragDisabled:ue,disableInteractiveElementBlocking:!0,children:(R,U)=>s.jsxs("div",{ref:R.innerRef,...R.draggableProps,className:`shrink-0 rounded-md transition-colors ${nt?"flex flex-1 flex-col ":""}${U.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ue?{}:R.dragHandleProps,onClick:()=>{Mn(Ie.key),Vr.current.delete(Ie.key)},className:`flex w-full shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${ue?"":"cursor-grab active:cursor-grabbing"}`,title:Ie.key||Ie.label,children:[s.jsx(Ks,{size:13,className:`shrink-0 transition-transform ${rt?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Ie.label}),Pt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),H>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx(db,{sessionIds:Ie.sessions.map(X=>X.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Ie.sessions.length})]}),!rt&&s.jsx("div",{className:`mt-0.5 pl-2 ${nt?"flex flex-1 flex-col":""}`,children:s.jsx(zl,{droppableId:`group-sessions:${Ie.key}`,type:"session",direction:"vertical",isCombineEnabled:!ur,children:X=>s.jsxs("div",{ref:X.innerRef,...X.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${Ie.key}`,className:`${nt?"flex-1 ":""}space-y-0.5`,children:[yt.map((be,Ee)=>s.jsx(Ul,{draggableId:be.id,index:Ee,disableInteractiveElementBlocking:!0,children:(Ve,dt)=>s.jsxs("div",{ref:Ve.innerRef,...Ve.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":Ee,className:"relative",children:[ds(Ee),Ee===yt.length-1&&ds(yt.length,"bottom"),be.kind==="workspace"?Or(be.workspace,be.members,dt.isDragging,!!dt.combineTargetFor,Ve.dragHandleProps):be.kind==="collaboration"?Jn(be.group,be.members,Ve.dragHandleProps,dt.isDragging,!!dt.combineTargetFor):s.jsx("div",{...D?Hn(()=>D(be.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${dt.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":dt.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":is(be.session.id)??(!Se&&be.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(be.session,Ve.dragHandleProps)})]})},be.id)),X.placeholder]})})})]})},Ie.key||"__ungrouped__")}),W.placeholder]})})})}):es(lr,"sidebar-entities")]}),s.jsx(S9,{onReselect:()=>{d&&(kn.current=null,Fe(W=>W+1),d())}}),_e&&s.jsx(DO,{directories:a.flatMap(W=>{const Ie=l.get(W.id)?.cwd;return Ie?[Ie]:[]}),tmuxAvailable:pe,options:we,launchPending:Ke,launchError:ae?Te(c1(ae)):null,agents:bt,selectedAgent:st,detecting:Tn,resumeHistory:Zt,resumeHistoryLoading:Mt,resumeHistoryPendingId:jt,resumeHistoryError:Bt,onRefreshAgents:()=>{bn().catch(()=>{})},onSelectAgent:W=>{nn(W).catch(()=>{})},onLaunchAgent:$r,onResumeHistory:W=>{Ir(W)},onRemoveResumeHistory:W=>{Zn(W)},onClose:()=>me(!1),onOptionsChange:At,additionalContent:gt&&F?.latestVersion&&s.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:s.jsx(An,{size:13,className:F.status==="checking"||F.status==="installing"||F.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:Te("sidebar.updateAvailable",{version:F.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:F.status==="checking"?Te("settings.updateChecking"):F.status==="installing"?Te("sidebar.updateInstalling"):F.status==="ready"?Te("sidebar.updateReady"):F.status==="restarting"?Te("sidebar.updateRestarting"):F.error||Te("sidebar.updateFailed")})]})]}),F.status==="ready"&&Z&&s.jsx("button",{type:"button",disabled:ee,onClick:Z,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:Te("sidebar.updateRestart")}),F.status==="error"&&G&&s.jsx("button",{type:"button",disabled:ee,onClick:G,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:Te("sidebar.updateRetry")})]})}),ut&&s.jsx(Xb,{onEnterGroup:async W=>{if(!await zr(W))throw new Error("协作组已保存,打开工作区失败,请重试");ft(!1)},onFloatingChange:async W=>{if(W){if(!await zr(W))throw new Error("打开协作工作区失败");ft(!1)}},activeSessionId:c,defaultSessionMode:J,onClose:()=>ft(!1),onNewSession:W=>f(W)}),Object.entries(He).map(([W,Ie])=>s.jsx(Xb,{activeSessionId:c,initialCollaborationGroupId:W,initialFloating:Ie,visible:!Se,onEnterGroup:async Ye=>{if(Ye===W){await zr(Ye);return}if(!await zr(Ye))throw new Error("协作组已保存,打开工作区失败,请重试");await Xa({floatingGroupId:null},W),ke(rt=>{const nt={...rt};return delete nt[W],nt})},onFloatingChange:Ye=>wt(W,Ye),defaultSessionMode:J,onClose:()=>{ie.current=!0,ke(Ye=>{const rt={...Ye};return delete rt[W],rt})},onNewSession:Ye=>f(Ye)},W)),!_e&&s.jsxs("div",{className:"relative z-10 shrink-0 bg-[var(--chrome-bg)] px-3 pb-3 pt-1 md:border-t md:border-border md:p-2",children:[ae&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:Te(c1(ae))}),s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${st?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:Qt,disabled:Ke,"aria-busy":Ke,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${st?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:Te("sidebar.newSession"),"aria-label":Te("sidebar.newSession"),children:[s.jsx(el,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Ke?Te("sidebar.sessionCreating"):"Terminal"})]}),st&&s.jsxs("button",{type:"button",onClick:er,disabled:Ke,"aria-busy":Ke,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:Te("sidebar.newSessionWithAgent",{agent:st.displayName}),"aria-label":Te("sidebar.newSessionWithAgent",{agent:st.displayName}),children:[s.jsx(tu,{agent:st,size:15}),s.jsx("span",{className:"truncate",children:st.displayName})]}),s.jsxs("button",{type:"button",onClick:ys,disabled:Ke,className:"relative inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:$t,"aria-label":$t,"aria-expanded":_e,"aria-controls":"sidebar-launch-options",children:[s.jsx(Ro,{size:15}),Wt&&s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2 w-2 rounded-full bg-destructive ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"}),gt&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${Wt?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})]})]});return Ze?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:ui}):s.jsx(i4,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:Re,children:ui})}function EF(){const{t:e}=Gr();return s.jsxs("div",{role:"status","aria-label":e("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[s.jsx("span",{className:"sr-only",children:e("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",className:"shrink-0 border-b border-border/15 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex h-5 items-center gap-1",children:[s.jsx("div",{className:"h-4 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-7 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-12 rounded bg-surface-2"})]}),s.jsxs("div",{className:"flex h-[15px] items-center justify-between",children:[s.jsx("div",{className:"h-2 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-6 rounded bg-surface-2"})]}),s.jsxs("div",{className:"mt-2 flex h-7 items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-12 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-7 w-16 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-3 w-24 max-w-[30%] rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-4 rounded-full bg-surface-2"})]})]}),s.jsxs("div",{"aria-hidden":"true",className:"overflow-hidden px-3 py-2",children:[s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("div",{className:"h-3 w-3 rounded-sm bg-surface-2"}),s.jsx("div",{className:"h-2 w-32 max-w-[55%] rounded bg-surface-2"})]}),["w-3/5","w-2/5","w-1/2","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-9 items-center gap-2 pl-5",style:{opacity:1-r*.15},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},t))]})]})}function NF({slow:e=!1}){const{t}=Gr();return s.jsxs("div",{role:"status","aria-label":t("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton relative h-full min-h-0 overflow-hidden bg-surface px-3",children:[s.jsx("span",{className:"sr-only",children:t("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",children:[s.jsxs("div",{className:"flex h-[76px] items-center gap-2 border-b border-border/40 px-2",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-12 rounded bg-surface-2"})]})]}),s.jsxs("div",{className:"flex h-11 items-center gap-2 px-1 pt-3",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-12 rounded-full bg-surface-2"})]}),[!1,!0].map(r=>s.jsxs("div",{className:"border-b border-border/40 px-1 py-4",children:[s.jsxs("div",{className:"mb-2 flex h-8 items-center justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),r&&s.jsx("div",{className:"h-2 w-28 rounded bg-surface-2"})]}),s.jsx("div",{className:"h-8 w-12 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]},String(r))),s.jsx("div",{className:"flex h-[69px] items-center border-b border-border/40 px-2",children:s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"})}),s.jsxs("div",{className:"space-y-2 px-1 py-4",children:[s.jsxs("div",{className:"flex h-8 items-center justify-between",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-8 w-28 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-7 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]})]}),e&&s.jsx("div",{className:"absolute inset-x-3 bottom-3 rounded-md bg-surface-elevated px-3 py-2 text-xs text-muted-foreground",children:t("rightSidebar.loadingGitChangesSlow")})]})}const A4=()=>Yc(()=>import("./RightSidebar-jOQJePDV.js").then(e=>e.R),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17])).then(e=>({default:e.RightSidebar})),RF=b.lazy(A4);function ly(e){const t=b.useRef(!1);b.useEffect(()=>{const f=navigator.connection;if(!(f?.saveData||/2g|3g/.test(f?.effectiveType??"")))return dg(()=>{A4().catch(()=>{})},3e3)},[]);const{t:r}=Gr(),n=Vt(f=>f.rootPath),a=Vt(f=>f.rightTab),c=Vt(f=>f.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const d=s.jsx(i4,{side:"right",isOpen:e.isOpen,drawerWidthPx:e.drawerWidthPx,onClose:e.onClose,onOpen:e.onOpen,pinned:e.pinned,children:s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 px-1",children:s.jsx("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:s.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",children:l})})}),s.jsx("div",{"aria-hidden":"true",className:"flex items-center gap-1.5",children:[Yl,yS,Ro].map((f,m)=>s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-surface-2 text-muted-foreground",children:s.jsx(f,{size:14})},m))}),s.jsx("button",{type:"button",onClick:e.onClose,"aria-label":r("common.close"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:s.jsx(Dn,{size:14})})]}),s.jsx("div",{className:"mt-2 grid grid-cols-5 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[["git",FA,"rightSidebar.tabGit"],["diff",UA,"rightSidebar.tabChanges"],["files",nu,"rightSidebar.tabFiles"],["architecture",sS,"architecture.tab"],["computer",L9,"rightSidebar.tabComputer"]].map(([f,m,x])=>s.jsxs("button",{type:"button",onClick:()=>c(f),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===f?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(m,{size:12}),r(x)]},f))}),s.jsx("div",{className:"h-2"})]}),s.jsx("div",{className:"min-h-0 flex-1 bg-surface",children:a==="architecture"?s.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:r("architecture.loading")}):a==="computer"?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:r("computer.loading")}):a==="git"?s.jsx(NF,{}):s.jsx(EF,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:d,children:s.jsx(RF,{...e})}):d}const cy=Sc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function MF(e){let t=1,r="terminal";for(;;){let n=!1;for(const a of e.values())if(a.name===r){n=!0;break}if(!n)break;r=`terminal-${t}`,t++}return r}const jF=Sc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=L3(),a=Date.now(),c=t().sessions,l=MF(c),d={id:n,cwd:r,sessionId:null,name:l,customName:!1,createdAt:a,lastActivity:a};return e(f=>{const m=new Map(f.sessions);return m.set(n,d),{sessions:m,activeSessionId:f.activeSessionId??n,nextSessionNumber:f.nextSessionNumber+1}}),n},closeSession:r=>{e(n=>{const a=new Map(n.sessions),c=n.activeSessionId===r;a.delete(r);let l=n.activeSessionId;if(c){const d=Array.from(a.keys());l=d.length>0?d[0]:null}return{sessions:a,activeSessionId:l}})},switchSession:r=>{e(n=>n.sessions.has(r)?{activeSessionId:r}:n)},updateSession:(r,n)=>{e(a=>{const c=a.sessions.get(r);if(!c)return a;const l=new Map(a.sessions);return l.set(r,{...c,...n,lastActivity:Date.now()}),{sessions:l}})},setTerminalSession:(r,n)=>{t().updateSession(r,{sessionId:n.sessionId})},getActiveSession:()=>{const r=t();if(r.activeSessionId)return r.sessions.get(r.activeSessionId)},getSessionCount:()=>t().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}})),DF=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class BF{level=6;badSince=null;goodSince=null;connectedAt=0;lastSample=-1/0;lastChange=-1/0;lastUpgrade=-1/0;upgradeAfter=0;failedProbes=0;baselineRtt=1/0;get quality(){return DF[this.level]}connected(t){this.connectedAt=t,this.badSince=this.goodSince=null,this.lastSample=-1/0}sample(t,r,n=1600){if(r-this.lastSample>2500&&(this.badSince=this.goodSince=null),this.lastSample=r,t.rttMs!==null&&(this.baselineRtt=Math.min(this.baselineRtt,t.rttMs)),r-this.connectedAt<3e3)return null;const a=t.rttMs!==null&&t.rttMs>this.baselineRtt+150,c=t.deliveryDelayMs>250||t.decodeQueue>=4||a&&t.frames>0&&t.deliveryDelayMs>100,l=t.deliveryDelayMs>800||t.decodeQueue>=8,d=t.rttMs!==null&&t.rttMs<this.baselineRtt+100&&t.deliveryDelayMs<80&&t.decodeQueue<=1;this.badSince=c?this.badSince??r:null,this.goodSince=d?this.goodSince??r:null;const f=n<=1080?7:n<=1600?9:11;if(this.badSince!==null&&r-this.badSince>=(l?1e3:2e3)&&r-this.lastChange>=(l?2e3:3e3)&&this.level>0){this.level=Math.max(0,this.level-(l?2:1));const m=r-this.lastUpgrade<2e4;this.failedProbes=m?this.failedProbes+1:0,this.upgradeAfter=r+(m?Math.min(3e4,8e3*2**(this.failedProbes-1)):5e3),this.lastUpgrade=-1/0}else if(this.goodSince!==null&&r-this.goodSince>=3e3&&r-this.lastChange>=4e3&&r>=this.upgradeAfter&&this.level<f)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function du(e,t){const r=await fetch(e,{...t,headers:{"Content-Type":"application/json",Accept:"application/json",...t?.headers??{}}}),n=await r.json().catch(()=>null);if(!r.ok||!n){const a=n?.error||n?.code||`ANDROID_REQUEST_FAILED_${r.status}`;throw new Error(a)}return n}async function QF(){return du("/api/android/devices")}async function PF(e){return du("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const ip=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],H0=ip[1];function J1(e){if(!e||typeof e!="object")return H0;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=ip.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return H0;const n=typeof t.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(t.maxSize))):1080,a=typeof t.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(t.bitRate))):4e6,c=typeof t.maxFps=="number"?Math.max(0,Math.min(60,Math.round(t.maxFps))):30;return{id:"custom",maxSize:n,bitRate:a,maxFps:c}}function OF(e,t){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const r=new URLSearchParams;t&&(r.set("max_size",String(t.maxSize)),r.set("bit_rate",String(t.bitRate)),t.maxFps>0&&r.set("max_fps",String(t.maxFps)));const n=r.toString();return`/api/android/${e}/ws${n?`?${n}`:""}`}function uy(e){const t={ADB_UNAVAILABLE:"本机没有可用的 adb,请先安装 Android platform-tools。",ADB_NOT_FOUND:"找不到 adb 可执行文件,可用 TERMDOCK_ADB_BIN 指定路径。",SCRCPY_NOT_FOUND:"本机没有 scrcpy,请先安装(含 scrcpy-server)。",SCRCPY_SERVER_NOT_FOUND:"找不到 scrcpy-server,可用 TERMDOCK_SCRCPY_SERVER 指定路径。",SCRCPY_VERSION_UNKNOWN:"无法读取 scrcpy 版本,请确认 scrcpy --version 可执行。",SCRCPY_CONNECT_TIMEOUT:"设备连接超时,请确认已授权 USB 调试并保持解锁。",SCRCPY_UNSUPPORTED_CODEC:"设备返回了不支持的视频编码。",INVALID_ADDRESS:"地址格式不正确,应为 ip:port。",API_NOT_ALLOWED:"当前设备权限不足:投屏需要全权服务授权。"};for(const[r,n]of Object.entries(t))if(e.includes(r))return n;return e}function FF(e){return du(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function $F(e){return du("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function UF(e){return du(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function zF(e,t){return du(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function HF(e){return du(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const WF=0,GF=1,VF=2,qF=3,YF=4,ZF=5,KF=7,XF=10,JF=11,e$=16,dy=17,hy=0,Ym=1,t$=2,fy=3,Zm=0,py=1,my=1,Bu=0xffffffffffffffffn,Vh=0xfffffffffffffffen,s0={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function T4(e,t,r){e.setUint32(t,Math.max(0,Math.round(r.x))&4294967295),e.setUint32(t+4,Math.max(0,Math.round(r.y))&4294967295),e.setUint16(t+8,Math.min(65535,Math.round(r.screenWidth))),e.setUint16(t+10,Math.min(65535,Math.round(r.screenHeight)))}function r$(e,t,r,n,a,c){const l=new Uint8Array(32),d=new DataView(l.buffer);return d.setUint8(0,VF),d.setUint8(1,e),d.setBigUint64(2,t),T4(d,10,r),d.setUint16(22,Math.max(0,Math.min(65535,Math.round(n*65536)))),d.setUint32(24,a>>>0),d.setUint32(28,c>>>0),l}function Km(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,WF),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function n$(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,qF),T4(c,1,e);const l=d=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,d/16))*32768)));return c.setInt16(13,l(t)),c.setInt16(15,l(r)),c.setUint32(17,n>>>0),a}function s$(e){const t=new TextEncoder().encode(e);if(!t.length)return null;const r=t.subarray(0,300),n=new Uint8Array(5+r.length),a=new DataView(n.buffer);return a.setUint8(0,GF),a.setUint32(1,r.length),n.set(r,5),n}function i$(e){const t=new TextEncoder().encode(e);if(!t.length||t.length>255)return null;const r=new Uint8Array(2+t.length);return r[0]=e$,r[1]=t.length,r.set(t,2),r}function i0(e){return new Uint8Array([e])}function gy(e){return new Uint8Array([YF,e])}function a$(e){return new Uint8Array([XF,e?1:0])}function o$(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function l$(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Xm(e){return e.toString(16).padStart(2,"0")}function S4(e,t,r){for(let n=0;n+4<e.length;n++){const a=e[n]===0&&e[n+1]===0&&e[n+2]===1,l=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1?n+4:a?n+3:-1;if(l<0||l>=e.length)continue;if((r?e[l]>>1&63:e[l]&31)!==t){n=l-1;continue}let f=l+1;for(;f+2<e.length&&!(e[f]===0&&e[f+1]===0&&(e[f+2]===1||e[f+2]===0&&e[f+3]===1));)f++;return e.subarray(l,Math.min(e.length,f))}return null}function c$(e){const t=e?S4(e,7,!1):null;return t&&t.length>=4?`avc1.${Xm(t[1])}${Xm(t[2])}${Xm(t[3])}`:"avc1.42e01e"}function u$(e){const t=e?S4(e,32,!0):null;if(t&&t.length>=13){const r=t[1]>>6&3,n=t[1]&31,a=t[12];return`hev1.${r}.${n}.L${a}.B0`}return"hev1.1.6.L120.B0"}class d${constructor(t,r){this.canvas=t,this.callbacks=r}canvas;callbacks;liveBitrate=!1;bitrateFailureDetail;get lastBitrateFailure(){return this.bitrateFailureDetail}bitrateRequestId=0;bitratePending=null;get supportsLiveBitrate(){return this.liveBitrate}get canSetBitrate(){return this.liveBitrate&&!this.bitratePending&&this.socket?.readyState===1}setBitrate(t){return!this.canSetBitrate||!Number.isInteger(t)||t<3e5||t>3e7?Promise.resolve(!1):new Promise(r=>{const n=++this.bitrateRequestId,a=setTimeout(()=>this.finishBitrate(!1,`BITRATE_CLIENT_TIMEOUT: requested=${t} bps; no server confirmation within 4000ms`),4e3);this.bitratePending={id:n,value:t,resolve:r,timer:a},this.send({type:"bitrate",requestId:n,bitRate:t})})}finishBitrate(t,r){const n=this.bitratePending;n&&(this.bitratePending=null,clearTimeout(n.timer),t||(this.liveBitrate=!1,this.bitrateFailureDetail=r??this.bitrateFailureDetail??"BITRATE_REASON_UNAVAILABLE: server rejected adjustment without a diagnostic",this.closedByUser||this.callbacks.onBitrateSupport?.(!1,this.bitrateFailureDetail)),n.resolve(t))}socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;lastFrameAt=0;lastResetAt=0;heartbeat=null;statsTimer=null;stallTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";autoQuality=!1;pingAt=null;rttMs=null;rttAt=0;minimumFrameOffset=1/0;deliveryDelayMs=0;peakDecodeQueue=0;sampleFrames=0;get currentHeader(){return this.header}connect(t,r){this.liveBitrate=!1,this.bitrateFailureDetail=void 0,this.serial=t,this.autoQuality=r?.id==="auto",this.closedByUser=!1,this.callbacks.onState("connecting");let n;try{n=I9(OF(t,r))}catch(a){this.callbacks.onState("error",a instanceof Error?a.message:"ANDROID_STREAM_FAILED");return}this.socket=n,n.onopen=()=>{this.lastMessageAt=Date.now()},n.onmessage=a=>{this.closedByUser||this.handleMessage(a.data)},n.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},n.onclose=()=>{this.finishBitrate(!1,"BITRATE_CONNECTION_CLOSED: preview connection closed"),this.liveBitrate=!1,this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.finishBitrate(!1),this.liveBitrate=!1,this.teardownTimers();try{this.decoder?.close()}catch{}this.decoder=null,this.configured=!1;try{this.socket?.close()}catch{}this.socket=null,this.callbacks.onState("idle")}teardownTimers(){this.heartbeat&&clearInterval(this.heartbeat),this.statsTimer&&clearInterval(this.statsTimer),this.stallTimer&&clearInterval(this.stallTimer),this.heartbeat=null,this.statsTimer=null,this.stallTimer=null}startTimers(){this.lastSampleAt=Date.now(),this.heartbeat=setInterval(()=>{if(!(!this.socket||this.socket.readyState!==1)){if(Date.now()-this.lastMessageAt>45e3){try{this.socket.close()}catch{}return}this.pingAt===null&&(this.pingAt=performance.now(),this.send({type:"ping"}))}},this.autoQuality?2e3:15e3),this.stallTimer=setInterval(()=>{if(!this.header||this.closedByUser)return;const t=Date.now();t-this.lastFrameAt>8e3&&t-this.lastResetAt>8e3&&(this.lastResetAt=t,console.warn("[android] no frames for 8s; requesting keyframe reset"),this.sendControl(i0(dy)))},2e3),this.statsTimer=setInterval(()=>{const t=Date.now(),r=(t-this.lastSampleAt)/1e3;r<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/r*10)/10,kbps:Math.round(this.bytesSinceSample*8/r/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType,adaptation:this.autoQuality?{rttMs:this.pingAt!==null&&performance.now()-this.pingAt>2e3?performance.now()-this.pingAt:performance.now()-this.rttAt<6e3?this.rttMs:null,deliveryDelayMs:this.sampleFrames?this.deliveryDelayMs:0,decodeQueue:Math.max(this.peakDecodeQueue,this.decoder?.decodeQueueSize??0),frames:this.sampleFrames}:void 0}),this.sampleFrames=0,this.peakDecodeQueue=0,this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=t)},1e3)}send(t){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(t))}catch{}}sendControl(t){t&&(this.controlsSent++,this.send({type:"control",data:o$(t)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(t){if(typeof t!="string")return;this.lastMessageAt=Date.now();let r;try{r=JSON.parse(t)}catch{return}this.lastType=`${r.type??"?"}${r.config?":cfg":""}${r.key?":key":""}`;try{this.dispatchMessage(r)}catch(n){console.warn("[android] message handling failed",n),this.callbacks.onWarning(`处理消息失败:${n instanceof Error?n.message:String(n)}`)}}dispatchMessage(t){switch(t.type){case"bitrate-support":this.liveBitrate=t.supported===!0,this.bitrateFailureDetail=this.liveBitrate?void 0:typeof t.detail=="string"?t.detail.slice(0,4096):"BITRATE_REASON_UNAVAILABLE: server did not provide diagnostics",this.liveBitrate||this.finishBitrate(!1,this.bitrateFailureDetail),this.callbacks.onBitrateSupport?.(this.liveBitrate,this.bitrateFailureDetail);break;case"bitrate-result":t.requestId===this.bitratePending?.id&&this.finishBitrate(t.applied===!0&&t.bitRate===this.bitratePending?.value,typeof t.detail=="string"?t.detail.slice(0,4096):void 0);break;case"header":this.header={deviceName:t.deviceName??this.serial,codec:t.codec??"h264",width:t.width??0,height:t.height??0},this.lastFrameAt=Date.now(),this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(t);break;case"error":this.callbacks.onState("error",t.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break;case"pong":this.pingAt!==null&&(this.rttMs=performance.now()-this.pingAt,this.rttAt=performance.now(),this.pingAt=null);break}}handleFrame(t){if(typeof t.data!="string")return;typeof t.seq=="number"&&(this.lastSeq=t.seq);const r=l$(t.data);if(this.bytesSinceSample+=t.data.length,this.receivedFrames++,this.lastFrameAt=Date.now(),this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),t.config){this.configData=r,this.pendingConfig=r,this.configureDecoder(),this.ack();return}this.sampleFrames++;const n=Number(t.pts);if(t.pts!==void 0&&Number.isFinite(n)){const l=performance.now()-n/1e3;this.minimumFrameOffset=Math.min(this.minimumFrameOffset,l),this.deliveryDelayMs=Math.max(0,l-this.minimumFrameOffset)}this.configured||this.configureDecoder();const a=t.key===!0;if(this.needsKeyframe&&!a){this.ack();return}let c=r;this.pendingConfig&&(c=new Uint8Array(this.pendingConfig.length+r.length),c.set(this.pendingConfig,0),c.set(r,this.pendingConfig.length),this.pendingConfig=null),a&&(this.needsKeyframe=!1),this.decode(c,a,t.pts),this.ack()}configureDecoder(){const t=this.header?.codec??"h264";if(!this.decoder||this.decoder.state==="closed"){if(typeof VideoDecoder>"u"){this.warnedUnsupported||(this.warnedUnsupported=!0,this.callbacks.onWarning("当前浏览器不支持 WebCodecs(VideoDecoder),无法解码投屏画面。")),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}try{this.decoder=new VideoDecoder({output:c=>this.onDecodedFrame(c),error:c=>{this.configured=!1,console.warn("[android] video decoder error",c),this.callbacks.onState("error",c instanceof Error?c.message:"VIDEO_DECODER_ERROR"),this.sendControl(i0(dy))}})}catch(c){console.warn("[android] VideoDecoder unavailable",c),this.callbacks.onWarning(`创建 VideoDecoder 失败:${c instanceof Error?c.message:String(c)}`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}}const r={codec:"avc1.42e01e",optimizeForLatency:!0};let n;t==="h264"?(n=[c$(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,d,f)=>f.indexOf(l)===d),r.avc={format:"annexb"}):t==="h265"?(n=[u$(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],r.hevc={format:"annexb"}):n=["av01.0.04M.08"];const a=[];for(const c of n)try{this.decoder.configure({...r,codec:c}),this.configured=!0,this.needsKeyframe=!0,c!==n[0]&&console.warn("[android] decoder configured with fallback codec",c);return}catch(l){a.push(`${c}: ${l instanceof Error?l.message:String(l)}`),console.warn("[android] decoder configure failed",c,l)}this.callbacks.onWarning(`解码器配置失败(${a.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(t,r,n){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:r?"key":"delta",timestamp:n?Number(n):this.lastTimestamp+1,data:t})),this.peakDecodeQueue=Math.max(this.peakDecodeQueue,this.decoder.decodeQueueSize),this.lastTimestamp=n?Number(n):this.lastTimestamp+1}catch(a){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",a),this.callbacks.onWarning(`送入解码器失败:${a instanceof Error?a.message:String(a)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(t){this.frameCount++,this.decodedFrames++;const r=t.displayWidth||t.codedWidth,n=t.displayHeight||t.codedHeight,a=this.canvas;(a.width!==r||a.height!==n)&&(a.width=r,a.height=n,this.header&&(this.header={...this.header,width:r,height:n},this.callbacks.onHeader(this.header)));const c=a.getContext("2d");c&&c.drawImage(t,0,0,a.width,a.height),t.close()}pointerPoint(t,r){return{x:t,y:r,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(t,r,n,a){const c=t===Ym||t===fy,l=c?0:1,d=a===Bu&&!c?my:0,f=(t===hy||t===Ym)&&a===Bu?my:0;this.sendControl(r$(t,a,this.pointerPoint(r,n),l,f,d))}pointerDown(t,r,n){this.touch(hy,t,r,n==="mouse"?Bu:Vh)}pointerMove(t,r,n){this.touch(t$,t,r,n==="mouse"?Bu:Vh)}pointerUp(t,r,n){this.touch(Ym,t,r,n==="mouse"?Bu:Vh)}pointerCancel(t,r,n){this.touch(fy,t,r,n==="mouse"?Bu:Vh)}scroll(t,r,n,a){this.sendControl(n$(this.pointerPoint(t,r),n,a))}key(t,r=Zm){this.sendControl(Km(r,t))}tapKey(t){this.sendControl(Km(Zm,t)),this.sendControl(Km(py,t))}back(){this.sendControl(gy(Zm)),this.sendControl(gy(py))}home(){this.tapKey(s0.HOME)}recents(){this.tapKey(s0.APP_SWITCH)}power(){this.tapKey(s0.POWER)}volumeUp(){this.tapKey(s0.VOLUME_UP)}volumeDown(){this.tapKey(s0.VOLUME_DOWN)}rotate(){this.sendControl(i0(JF))}expandNotifications(){this.sendControl(i0(ZF))}collapsePanels(){this.sendControl(i0(KF))}setDisplayPower(t){this.sendControl(a$(t))}sendText(t){this.sendControl(s$(t))}startApp(t){this.sendControl(i$(t))}}function h$(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function f$(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${h$()}.png`}function xy(e){const t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}async function p$(e,t=f$()){const r=e.width,n=e.height;if(!r||!n)throw new Error("投屏画面尚未就绪");const a=document.createElement("canvas");a.width=r,a.height=n;const c=a.getContext("2d");if(!c)throw new Error("无法读取投屏画面");c.drawImage(e,0,0);const l=await new Promise(d=>a.toBlob(d,"image/png"));if(!l||l.size===0)throw new Error("截图失败,请重试");return new File([l],t,{type:"image/png"})}function C4(e,t,r){const n=r.contentWidth*(t-1)/2,a=r.contentHeight*(t-1)/2;return{x:Math.max(-n,Math.min(n,e.x)),y:Math.max(-a,Math.min(a,e.y))}}function by(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:C4({x:n.x-t.cx-(r.x-t.cx-e.pan.x)*l,y:n.y-t.cy-(r.y-t.cy-e.pan.y)*l},c,t)}}function _4(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),c=f=>{window.clearTimeout(d),window.removeEventListener("termdock-insert-reference-ack",l),f?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},l=f=>{const m=f.detail;m?.nonce===a&&c(m.ok===!0)},d=window.setTimeout(()=>c(!1),1e4);window.addEventListener("termdock-insert-reference-ack",l),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:e,sessionId:t,nonce:a,focus:!1,paste:!0}}))}):Promise.reject(new Error("没有可接收内容的终端"))}function yy(e,t){return _4(I1(e,null),t)}const Jm=Sc(e=>({pending:[],enqueue:(t,r,n="/",a)=>e(c=>c.pending.some(l=>l.file.id===t.id)?c:{pending:[...c.pending,{file:t,sessionId:r,initialPath:n,insert:a}]}),remove:t=>e(r=>({pending:r.pending.filter(n=>n.file.id!==t)}))}));function m$({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=Gr(),[c,l]=b.useState(!1),[d,f]=b.useState(!1),[m,x]=b.useState(!1),[y,w]=b.useState(!1),[v,T]=b.useState(null),C=b.useRef(!1),L=b.useRef(null),N=async()=>{if(!C.current){C.current=!0,f(!0),w(!0);try{await HF(e.id),n()}catch(O){T(O instanceof Error?O.message:String(O))}finally{C.current=!1,f(!1),w(!1)}}};b.useEffect(()=>{if(c)return;L.current?.focus();const O=P=>{if(P.stopPropagation(),P.key==="Escape"&&P.preventDefault(),P.key!=="Tab")return;const F=Array.from(L.current?.querySelectorAll("button:not(:disabled)")??[]),ee=F[0],Z=F.at(-1);P.shiftKey&&(document.activeElement===ee||document.activeElement===L.current)?(P.preventDefault(),Z?.focus()):!P.shiftKey&&document.activeElement===Z&&(P.preventDefault(),ee?.focus())};return document.addEventListener("keydown",O,!0),()=>document.removeEventListener("keydown",O,!0)},[c]);const D=async O=>{if(!C.current){C.current=!0,f(!0),x(O!==void 0),l(!1),T(null);try{const P=await zF(e.id,O);O===void 0&&await r(P.path),n()}catch(P){T(P instanceof Error?P.message:String(P))}finally{C.current=!1,f(!1)}}};return c?s.jsx(wp,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:O=>{D(O)}}):ci.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex items-center justify-center bg-[var(--app-backdrop)] p-4",children:s.jsxs("div",{ref:L,role:"dialog","aria-modal":"true","aria-labelledby":"recording-save-title",tabIndex:-1,"aria-busy":d,className:"w-full max-w-sm rounded-xl border border-border bg-surface p-4 text-foreground shadow-xl outline-none",children:[s.jsx("h2",{id:"recording-save-title",className:"text-sm font-semibold",children:a("android.recordingConfirm")}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("android.recordingSaveHint")}),s.jsxs("p",{className:"mt-2 break-all text-xs text-muted-foreground",children:[e.name," · ",(e.size/1024/1024).toFixed(1)," MB"]}),(v||e.error)&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs text-destructive",children:v||e.error}),d&&s.jsxs("p",{role:"status",className:"mt-3 flex items-center gap-2 text-sm text-primary",children:[s.jsx(Rn,{size:16,className:"animate-spin"}),y?`${a("android.recordingDiscard")}…`:a(m?"android.recordingSaving":"android.captureInserting")]}),s.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[s.jsx("button",{type:"button",disabled:d||e.status!=="ready",onClick:()=>{D()},className:"min-h-10 rounded-lg bg-primary px-3 text-sm text-primary-foreground disabled:opacity-40",children:a("android.recordingInsert")}),s.jsx("button",{type:"button",disabled:d||e.status!=="ready",onClick:()=>l(!0),className:"min-h-10 rounded-lg bg-surface-2 px-3 text-sm disabled:opacity-40",children:a("android.recordingSave")}),s.jsx("button",{type:"button",disabled:d,onClick:()=>{N()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const g0="android-mirror",a0=g0,k4="termdock:android:quality:v1",e1=176,g$=204,$l=1,Af=8,vy=[1,1.25,1.5,2,2.5,3,4,6,8],x$=e=>Math.max($l,Math.min(Af,e));function b$(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function qh(e){const t=e.parentElement;if(!t)return null;const r=t.getBoundingClientRect(),n=getComputedStyle(t),a=parseFloat(n.paddingLeft)||0,c=parseFloat(n.paddingTop)||0,l=t.clientWidth-a-(parseFloat(n.paddingRight)||0),d=t.clientHeight-c-(parseFloat(n.paddingBottom)||0);return{cx:r.left+t.clientLeft+a+l/2,cy:r.top+t.clientTop+c+d/2,width:l,height:d,contentWidth:e.offsetWidth,contentHeight:e.offsetHeight}}function y$(e,t){try{e.setPointerCapture?.(t)}catch{}}function wy(e,t){try{e.releasePointerCapture?.(t)}catch{}}const Ay=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Yh=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},t1={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},v$=()=>{try{const e=localStorage.getItem(k4);return e?J1(JSON.parse(e)):H0}catch{return H0}},o0=e=>{try{localStorage.setItem(k4,JSON.stringify(e))}catch{}};function w$({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=Gr(),d=cy(H=>H.overlay),f=cy(H=>H.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(v$,[]),v=b.useRef(w),T=b.useRef(null),C=b.useRef(null),[L,N]=b.useState(4e6),D=b.useRef(null),O=b.useRef(new Map),P=b.useRef(null),F=b.useRef(!1),[ee,Z]=b.useState($l),G=b.useRef(ee),de=b.useRef({x:0,y:0}),pe=b.useRef(null),J=b.useRef(0),Re=b.useRef(0),Ze=b.useRef(null),V=b.useRef(0),[ve,qe]=b.useState(null),[le,ye]=b.useState(null),[Te,Fe]=b.useState(!0),[se,De]=b.useState(""),[_e,Me]=b.useState(w.id),[Ke,Ne]=b.useState([]),[ae,ze]=b.useState(null),[at,ct]=b.useState(""),[me,ut]=b.useState(!0),[ft,Se]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[He,ke]=b.useState("idle"),[z,ie]=b.useState(null),[ge,We]=b.useState(null),[tt,wt]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Zt,Ut]=b.useState(null),[Mt,nr]=b.useState(null),[jt,Xt]=b.useState(!1),[Bt,Ht]=b.useState([]),[xe,Je]=b.useState(null),[ot,Nt]=b.useState([]),[K,xt]=b.useState(!1),tr=b.useRef(null),$e=b.useRef(0),Qr=b.useRef([]),[Ce,St]=b.useState(!1),[Ot,Jt]=b.useState(""),[lt,Ct]=b.useState(!1),[ar,_r]=b.useState(!1),[Nr,zr]=b.useState(""),[Tt,Ft]=b.useState(null),[we,At]=b.useState(null),[st,bt]=b.useState(!1),[Tn,bn]=b.useState(0),nn=b.useRef(null),[Oe,_t]=b.useState(!1),gt=b.useRef(!1),Wt=b.useRef(new Set),$t=b.useRef(null),Ar=b.useRef(null),Sn=b.useRef(!1),[Mn,vn]=b.useState(!1),dn=b.useRef(a);dn.current=a;const[kn,Hr]=b.useState(!1),[ne,Xe]=b.useState(null),Dt=b.useRef(null),ur=b.useRef(null),Fr=jF(H=>H.activeSessionId??H.sessions.keys().next().value??null),Zr=e??Fr,an=ss(H=>!!H.docks[a0]),Mr=ss(H=>H.hosts[a0]),Vr=ss(H=>H.setDock),Ln=b.useCallback(async()=>{Fe(!0);try{const H=await QF();qe(H),ye(null)}catch(H){ye(H instanceof Error?H.message:"ADB_UNAVAILABLE")}finally{Fe(!1)}},[]);b.useEffect(()=>{Ln()},[Ln]);const tn=ve?.devices??[],Ur=tn.find(H=>H.serial===se)??null,Xr=!!(le&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(le)),vr=!!(ve?.adbAvailable&&!ve.scrcpyVersion),on=b.useCallback(()=>{const H=D.current,ue=[...O.current.keys()];D.current=null,O.current.clear(),P.current=null,F.current=!1,tr.current=null,Yh(J.current),J.current=0,H&&x.current?.pointerCancel(H.x,H.y,H.type);const R=m.current;if(R)for(const U of ue)wy(R,U);Je(null),xt(!1),Nt([]),Z(G.current)},[]);b.useEffect(()=>{const H=U=>{O.current.has(U.pointerId)&&(U.type==="pointercancel"||U.target!==m.current)&&on()},ue=()=>on(),R=()=>{document.hidden&&on()};return window.addEventListener("pointerup",H,!0),window.addEventListener("pointercancel",H,!0),window.addEventListener("blur",ue),document.addEventListener("visibilitychange",R),()=>{window.removeEventListener("pointerup",H,!0),window.removeEventListener("pointercancel",H,!0),window.removeEventListener("blur",ue),document.removeEventListener("visibilitychange",R),on()}},[on]);const Jr=b.useCallback(()=>{on(),x.current?.disconnect(),x.current=null,ke("idle"),ie(null),We(null)},[on]),hn=b.useCallback((H,ue=!1)=>{const R=m.current;if(!R||!H)return;on(),x.current?.disconnect(),ie(null),!ue&&y.current!==H&&We(null),y.current=H,nr(null),Ut(null);const U=new d$(R,{onBitrateSupport:(be,Ee)=>{x.current!==U||v.current.id!=="auto"||Ut(be?null:Ee??"BITRATE_REASON_UNAVAILABLE")},onState:(be,Ee)=>{x.current===U&&(ke(be),ie(Ee??null))},onHeader:be=>{x.current===U&&We(be)},onStats:be=>{x.current===U&&wt(be)},onWarning:be=>{x.current===U&&nr(be)}});x.current=U;let X=v.current;X.id==="auto"?(T.current?.serial!==H&&(T.current={serial:H,policy:new BF}),T.current.policy.connected(performance.now()),X=T.current.policy.quality,N(X.bitRate)):T.current=null,C.current=X,U.connect(H,X)},[on]);b.useEffect(()=>{if(_e!=="auto"||v.current.id!=="auto"||He!=="streaming"||!tt.adaptation||document.hidden)return;const H=T.current,ue=x.current;if(!H||H.serial!==se||!ue?.canSetBitrate)return;const R=m.current,U=R?Math.max(R.clientWidth,R.clientHeight)*(window.devicePixelRatio||1)*G.current:1600,X=H.policy.sample(tt.adaptation,performance.now(),U||1600);X&&ue.setBitrate(X.bitRate).then(be=>{be&&x.current===ue&&(C.current=X,N(X.bitRate))})},[tt,_e,He,se,hn]);const jr=b.useCallback(H=>{const ue={...H.quality?{quality:{id:H.quality.id,maxSize:H.quality.maxSize,bitRate:H.quality.bitRate,maxFps:H.quality.maxFps}}:{},...H.activePresetId!==void 0?{activePresetId:H.activePresetId}:{},...H.presets!==void 0?{presets:H.presets}:{},...H.docked!==void 0?{docked:H.docked}:{},...H.deviceSerial!==void 0?{deviceSerial:H.deviceSerial}:{}};Ua({androidPanel:ue}).catch(()=>{})},[]);b.useEffect(()=>{let H=!1;return Cc().then(ue=>{if(H)return;const R=ue.androidPanel;if(R?.quality){const U=J1(R.quality);v.current=U,Me(U.id),Se({maxSize:U.maxSize,bitRate:U.bitRate,maxFps:U.maxFps}),o0(U)}Ne(R?.presets??[]),ze(R?.activePresetId??null),R?.deviceSerial&&(Ze.current=R.deviceSerial,De(R.deviceSerial))}).catch(()=>{}),()=>{H=!0}},[]);const zn=b.useCallback(H=>{const ue=++$e.current;Ht(U=>[...U,{id:ue,left:H.left,top:H.top}]);const R=window.setTimeout(()=>{Ht(U=>U.filter(X=>X.id!==ue)),Qr.current=Qr.current.filter(U=>U!==R)},300);Qr.current.push(R)},[]),mn=b.useCallback((H,ue)=>{const R=x.current,U=C.current;R?.supportsLiveBitrate&&y.current===H&&U&&U.maxSize===ue.maxSize&&U.maxFps===ue.maxFps?R.setBitrate(ue.bitRate).then(X=>{x.current===R&&(X?(C.current=ue,Ut(null)):Ut(R.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):hn(H)},[hn,l]),qr=b.useCallback(H=>{if(T.current=null,H.startsWith("user:")){const R=Ke.find(X=>X.id===H.slice(5));if(!R)return;const U={id:"custom",maxSize:R.maxSize,bitRate:R.bitRate,maxFps:R.maxFps};v.current=U,Me("custom"),ze(R.id),Se({maxSize:R.maxSize,bitRate:R.bitRate,maxFps:R.maxFps}),ut(!0),o0(U),jr({quality:U,activePresetId:R.id}),se&&hn(se);return}if(H==="custom"){const R=v.current;Me("custom"),ze(null),Se({maxSize:R.maxSize,bitRate:R.bitRate,maxFps:R.maxFps}),ut(!0);return}const ue=H==="auto"?J1({id:"auto"}):ip.find(R=>R.id===H)??H0;v.current=ue,Me(ue.id),ze(null),o0(ue),jr({quality:ue,activePresetId:null}),se&&hn(se)},[hn,se,Ke,jr]),Wr=b.useCallback(()=>{const H={id:"custom",maxSize:ft.maxSize,bitRate:ft.bitRate,maxFps:ft.maxFps};v.current=H,o0(H),jr({quality:H,activePresetId:null}),Me("custom"),ze(null),se&&mn(se,H)},[mn,se,ft,jr]),Y=b.useCallback(()=>{const H=at.trim();if(!H)return;const ue=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,R={id:ue,name:H,maxSize:ft.maxSize,bitRate:ft.bitRate,maxFps:ft.maxFps},U=[...Ke.filter(be=>be.name!==H),R].slice(-12),X={id:"custom",maxSize:ft.maxSize,bitRate:ft.bitRate,maxFps:ft.maxFps};Ne(U),ct(""),ze(ue),Me("custom"),v.current=X,o0(X),jr({quality:X,activePresetId:ue,presets:U}),se&&mn(se,X)},[at,ft,Ke,se,mn,jr]),Be=b.useCallback(()=>{if(!ae)return;const H=Ke.filter(ue=>ue.id!==ae);Ne(H),ze(null),jr({activePresetId:null,presets:H})},[ae,Ke,jr]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const H of Qr.current)window.clearTimeout(H);Qr.current=[]},[]),b.useEffect(()=>{if(d==="off")return;const H=ue=>{ue.key==="Escape"&&f("off")};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[d,f]),b.useEffect(()=>{const H=tn.filter(R=>R.state==="device");if(se||H.length!==1)return;const ue=H[0].serial;Ze.current!==ue&&(Ze.current=ue,De(ue))},[tn,se]),b.useEffect(()=>{se&&hn(se)},[se,hn]),b.useEffect(()=>{if(He==="streaming"){V.current=0,Xt(!1);return}if(He!=="error"||!se||!T$(z??""))return;const H=Math.min(8e3,700*2**V.current);V.current+=1,Xt(!0);const ue=window.setTimeout(()=>{Xt(!1),hn(se)},H);return()=>window.clearTimeout(ue)},[He,z,se,hn]);const Qt=b.useCallback((H,ue,R)=>{const U=m.current,X=R??(U?qh(U):null);return!U||!X?{x:0,y:0}:C4(H,ue,X)},[]),er=b.useCallback(()=>{const H=m.current;if(!H)return;const{x:ue,y:R}=de.current,U=G.current,X=U===$l&&ue===0&&R===0?"":`translate3d(${ue}px, ${R}px, 0) scale(${U})`;H.style.transform!==X&&(H.style.transform=X);const be=pe.current;be&&(be.textContent=U>$l?b$(U):"")},[]),sr=b.useCallback((H,ue,R=!0)=>{const U=m.current,X=G.current,be=x$(H);if(!U||be===X)return;const Ee=qh(U);if(!Ee)return;const Ve=ue??{x:Ee.cx,y:Ee.cy},dt=by({zoom:X,pan:de.current},Ee,Ve,Ve,be/X);G.current=dt.zoom,de.current=dt.pan,R&&er()},[er]),$r=b.useCallback(()=>{const H=G.current;Z(ue=>ue<=$l+.01==H<=$l+.01&&ue>=Af-.01==H>=Af-.01?ue:H)},[]);b.useEffect(()=>()=>{Yh(J.current),Yh(Re.current)},[]);const Ir=()=>{let H=0,ue=0;for(const U of O.current.values())H+=U.x,ue+=U.y;const R=O.current.size;return R?{x:H/R,y:ue/R}:null},Zn=()=>{const[H,ue]=Array.from(O.current.values());return H&&ue?Math.hypot(H.x-ue.x,H.y-ue.y):0},ys=()=>{const H=Ir(),ue=m.current?qh(m.current):null;!H||!ue||(P.current={startCentroid:H,startDistance:Zn(),box:ue})},is=b.useCallback(()=>{const H=P.current,ue=Ir();if(!H||!ue)return;const R=Zn(),U=H.startDistance>0&&R>0?R/H.startDistance:1,X=by({zoom:G.current,pan:de.current},H.box,H.startCentroid,ue,U);G.current=X.zoom,de.current=X.pan,H.startCentroid=ue,H.startDistance=R},[]),Hn=b.useCallback(()=>{J.current||(J.current=Ay(()=>{J.current=0,is(),er()}))},[is,er]),fn=b.useCallback(()=>{J.current&&(Yh(J.current),J.current=0,is(),er())},[is,er]);b.useEffect(()=>{const H=m.current;if(!H)return;const ue=H.parentElement;if(!ue)return;const R=X=>{if(X.ctrlKey||X.metaKey){if(X.preventDefault(),!X.deltaY||P.current)return;const Ve=X.deltaMode===1?16:X.deltaMode===2?H.parentElement?.clientHeight||600:1,dt=Math.max(-600,Math.min(600,X.deltaY*Ve));sr(G.current*Math.exp(-dt*.002),{x:X.clientX,y:X.clientY},!1),Re.current||(Re.current=Ay(()=>{Re.current=0,er(),$r()}));return}const be=x.current;if(!be||X.target!==H)return;X.preventDefault();const Ee=Kh(H,X.clientX,X.clientY);be.scroll(Ee.x,Ee.y,X.deltaX,X.deltaY)},U=X=>X.preventDefault();return ue.addEventListener("wheel",R,{passive:!1}),ue.addEventListener("gesturestart",U,{passive:!1}),ue.addEventListener("gesturechange",U,{passive:!1}),()=>{ue.removeEventListener("wheel",R),ue.removeEventListener("gesturestart",U),ue.removeEventListener("gesturechange",U)}},[sr,er,$r]),b.useEffect(()=>{const H=m.current,ue=H?.parentElement;if(!H||!ue||typeof ResizeObserver>"u")return;const R=new ResizeObserver(()=>{P.current&&(P.current.box=qh(H));const U=Qt(de.current,G.current);U.x===de.current.x&&U.y===de.current.y||(de.current=U,er())});return R.observe(H),R.observe(ue),()=>R.disconnect()},[Qt,er]),b.useLayoutEffect(()=>{er()});const Bn=H=>{const ue=x.current,R=m.current;if(!ue||!R)return;if(H.pointerType==="mouse"&&H.button!==0){H.preventDefault(),H.button===2?ue.back():H.button===1&&ue.home();return}H.preventDefault(),R.closest(".android-mirror-panel")?.focus({preventScroll:!0}),er(),$r(),fn(),y$(R,H.pointerId),O.current.set(H.pointerId,{x:H.clientX,y:H.clientY});const U=H.pointerType==="mouse"&&H.altKey;if(O.current.size>=2||U){const Ee=D.current;Ee&&(ue.pointerCancel(Ee.x,Ee.y,Ee.type),D.current=null,tr.current=null,Je(null),xt(!1),Nt([])),F.current=!0,ys();return}if(F.current)return;const X=Kh(R,H.clientX,H.clientY);D.current={id:H.pointerId,type:H.pointerType,x:X.x,y:X.y},ue.pointerDown(X.x,X.y,H.pointerType);const be=ky(R,H.clientX,H.clientY);be&&(tr.current={left:be.left,top:be.top},Nt([]),xt(!1),Je(be))},Xn=H=>{const ue=x.current,R=m.current;if(!R||!O.current.has(H.pointerId))return;if(H.pointerType==="mouse"){const Ve=R.getBoundingClientRect(),dt=R.parentElement?.getBoundingClientRect()??Ve;if(!(H.buttons&1)||H.clientX<Math.max(Ve.left,dt.left)||H.clientX>=Math.min(Ve.right,dt.right)||H.clientY<Math.max(Ve.top,dt.top)||H.clientY>=Math.min(Ve.bottom,dt.bottom)){on();return}}if(H.preventDefault(),O.current.set(H.pointerId,{x:H.clientX,y:H.clientY}),P.current){Hn();return}const U=D.current;if(!ue||!U||U.id!==H.pointerId)return;const X=Kh(R,H.clientX,H.clientY);U.x=X.x,U.y=X.y,ue.pointerMove(X.x,X.y,U.type);const be=ky(R,H.clientX,H.clientY),Ee=tr.current;!be||!Ee||(Je(be),Math.hypot(be.left-Ee.left,be.top-Ee.top)>=6&&(xt(!0),Nt(Ve=>{const dt=Ve[Ve.length-1];if(dt&&Math.hypot(be.left-dt.x,be.top-dt.y)<4)return Ve;const Qe=[...Ve,{x:be.left,y:be.top}];return Qe.length>12?Qe.slice(Qe.length-12):Qe})))},pn=H=>{const ue=x.current,R=m.current;if(!R||!O.current.has(H.pointerId))return;if(fn(),O.current.delete(H.pointerId),wy(R,H.pointerId),O.current.size===0&&(F.current=!1),P.current){O.current.size===0?(P.current=null,Z(G.current)):ys();return}const U=D.current;if(!U||U.id!==H.pointerId)return;const X=Kh(R,H.clientX,H.clientY);ue?.pointerUp(X.x,X.y,U.type),xe&&zn(xe),Je(null),xt(!1),window.setTimeout(()=>Nt([]),200),D.current=null,tr.current=null},lr=H=>{if(kn||Ce||ar)return;const ue=x.current;ue&&(H.key==="Backspace"?(H.preventDefault(),ue.key(67)):H.key==="Escape"?(H.preventDefault(),ue.back()):H.key==="Enter"&&(H.preventDefault(),ue.key(66)))},as=async()=>{const H=Ot.trim();if(H){Ct(!0);try{const ue=await PF(H);Jt(""),St(!1),await Ln(),De(ue.serial)}catch(ue){ye(ue instanceof Error?ue.message:"ADB_CONNECT_FAILED")}finally{Ct(!1)}}},rn=()=>{const H=x.current,ue=Nr;!H||!ue||(H.sendText(ue),zr(""))},gr=b.useCallback(H=>{Ft(H),Ar.current!==null&&window.clearTimeout(Ar.current),Ar.current=window.setTimeout(()=>{Ar.current=null,Ft(null)},2500)},[]),wr=b.useCallback(H=>{const ue=G.current,R=H==="in"?vy.find(U=>U>ue+.01):[...vy].reverse().find(U=>U<ue-.01);R!==void 0&&(ue<=$l&&R>$l&&gr(l("android.zoomPanHint")),fn(),sr(R),Z(R))},[sr,fn,gr,l]),xr=H=>{Promise.resolve().then(()=>r?.(H)).catch(ue=>{At(ue instanceof Error?ue.message:String(ue))})},ds=b.useCallback(async(H,ue)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(H),gr(ue)}catch(R){At(l("android.captureFailed")+(R instanceof Error?`:${R.message}`:""))}},[n,gr,l]),jn=async()=>{const H=m.current;if(!(!H||Sn.current)){Sn.current=!0,vn(!0),At(null);try{const ue=await p$(H);await ds(ue,l("android.captureInserted"))}catch(ue){At(ue instanceof Error?ue.message:String(ue))}finally{Sn.current=!1,vn(!1)}}},vs=b.useCallback(H=>{(H.status==="ready"||H.status==="error")&&dn.current&&!Wt.current.has(H.id)&&(Wt.current.add(H.id),dn.current?.(H))},[]),Qs=b.useCallback(async H=>{const ue=nn.current;if(!(!ue||gt.current)){gt.current=!0,_t(!0),At(null);try{const R=await UF(ue.id);nn.current=null,bt(!1),vs(R)}catch(R){At(R instanceof Error?R.message:String(R))}finally{gt.current=!1,_t(!1)}}},[vs]),Is=async()=>{if(!(!se||gt.current||nn.current)){gt.current=!0,_t(!0),At(null);try{const H=await $F(se);H.status==="recording"||H.status==="starting"||H.status==="stopping"?(nn.current=H,bt(!0),bn(Math.max(0,Date.now()-H.startedAt))):vs(H)}catch(H){At(H instanceof Error?H.message:String(H))}finally{gt.current=!1,_t(!1)}}};b.useEffect(()=>{let H=!1,ue=!1;nn.current=null,bt(!1);const R=async()=>{if(!(!se||ue||gt.current)){ue=!0;try{const{recordings:X}=await FF(se);if(H||gt.current)return;const be=X.find(Ee=>["starting","recording","stopping"].includes(Ee.status));nn.current=be??null,bt(!!be);for(const Ee of X)vs(Ee)}catch{}finally{ue=!1}}};R();const U=window.setInterval(()=>{R()},2e3);return $t.current=window.setInterval(()=>{nn.current&&bn(Math.max(0,Date.now()-nn.current.startedAt))},500),()=>{H=!0,window.clearInterval(U),$t.current!==null&&window.clearInterval($t.current)}},[se,vs]),b.useEffect(()=>{if(!kn)return;const H=()=>Hr(!1),ue=U=>{const X=U.target;X instanceof Node&&(Dt.current?.contains(X)||ur.current?.contains(X)||H())},R=U=>{U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),H())};return document.addEventListener("pointerdown",ue,!0),document.addEventListener("keydown",R,!0),window.addEventListener("resize",H),()=>{document.removeEventListener("pointerdown",ue,!0),document.removeEventListener("keydown",R,!0),window.removeEventListener("resize",H)}},[kn]),b.useEffect(()=>()=>{Ar.current!==null&&window.clearTimeout(Ar.current)},[]);const Or=He==="streaming",br=an,Qn=br?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-surface-2 disabled:opacity-40":"rounded p-1.5 hover:bg-surface-2 disabled:opacity-40",Jn=Ur?(Ur.model||Ur.serial)+Ly(Ur,l):tn.length?l("android.selectDevice"):l("android.noDevices"),ui=(ae?Ke.find(H=>H.id===ae):null)?.name??(_e==="auto"?`${l("android.qualityAuto")} · ${L/1e6} Mbps`:l(t1[_e])),W=br?"relative flex h-5 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50":"relative flex h-7 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50",Ie=br?"pointer-events-none block min-w-0 truncate px-1 text-[10px] leading-none text-foreground":"pointer-events-none block min-w-0 truncate px-2 text-[11px] leading-none text-foreground",Ye="absolute inset-0 h-full w-full cursor-pointer opacity-0",rt=()=>{const H=Dt.current?.getBoundingClientRect();H&&Xe({left:Math.max(8,Math.min(H.right-e1,window.innerWidth-e1-8)),top:Math.min(H.bottom+4,Math.max(8,window.innerHeight-g$-8))}),Hr(!0)},nt=()=>{if(an){Vr(a0,null),jr({docked:null});return}if(!Zr)return;const H={sessionId:Zr,side:"right"};Vr(a0,H),jr({docked:H})},yt=Ce||an||d!=="off",Pt=s.jsxs("div",{className:"android-mirror-panel flex h-full min-h-0 min-w-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:lr,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":an?"true":void 0,className:br?"flex h-6 min-h-6 shrink-0 flex-nowrap items-center gap-1 overflow-hidden border-b border-border/15 bg-[var(--chrome-bg)] px-1.5 cursor-grab select-none active:cursor-grabbing":"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[an&&s.jsx("span",{"data-panel-drag-title":"true",role:"button","aria-label":l("android.splitDrag"),title:l("android.splitDrag"),className:"flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground active:cursor-grabbing",children:s.jsx(ap,{size:12})}),s.jsx(E9,{size:br?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${W} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Ie} w-full`,children:Jn}),s.jsxs("select",{value:se,onChange:H=>{const ue=H.target.value;De(ue),Ze.current=ue,ue&&jr({deviceSerial:ue})},className:Ye,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:tn.length?l("android.selectDevice"):l("android.noDevices")}),tn.map(H=>s.jsx("option",{value:H.serial,children:(H.model||H.serial)+Ly(H,l)},H.serial))]})]}),s.jsxs("div",{className:`${W} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Ie,children:ui}),s.jsxs("select",{value:ae?`user:${ae}`:_e,onChange:H=>qr(H.target.value),className:Ye,title:l(_e==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),_e==="auto"?` · ${L/1e6} Mbps`:""]}),ip.map(H=>s.jsx("option",{value:H.id,children:l(t1[H.id])},H.id)),Ke.map(H=>s.jsx("option",{value:`user:${H.id}`,children:H.name},H.id)),s.jsx("option",{value:"custom",children:l(t1.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{Ln()},className:`${Qn} text-muted-foreground`,title:l("android.refresh"),children:Te?s.jsx(Rn,{size:13,className:"animate-spin"}):s.jsx(An,{size:13})}),Or?s.jsx("button",{type:"button",onClick:Jr,className:`${Qn} text-destructive`,title:l("android.disconnect"),children:s.jsx(m3,{size:13})}):s.jsx("button",{type:"button",onClick:()=>se&&hn(se),disabled:!se,className:`${Qn} text-primary`,title:l("android.connect"),children:s.jsx(SS,{size:13})}),(Or||st)&&s.jsx("button",{type:"button",onClick:()=>{jn()},disabled:!n||Mn,className:`${Qn} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:Mn?s.jsx(Rn,{size:br?12:13,className:"animate-spin"}):s.jsx(sT,{size:br?12:13})}),(Or||st)&&s.jsx("button",{type:"button",onClick:()=>{st?Qs("manual"):Is()},disabled:Oe||!st&&!a,className:`${Qn} ${st?"text-destructive":"text-muted-foreground"}`,title:l(st?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(st?"android.recordingStop":"android.recordingStart"),children:Oe?s.jsx(Rn,{className:"animate-spin",size:13}):st?s.jsx(p3,{size:br?10:11,fill:"currentColor"}):s.jsx(g3,{size:br?12:13})}),s.jsx("button",{ref:Dt,type:"button",onClick:()=>kn?Hr(!1):rt(),"aria-haspopup":"menu","aria-expanded":kn,className:`${Qn} ${yt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx(Ro,{size:br?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{Hr(!1),f("off"),c()},className:`${Qn} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(Dn,{size:14})})]}),kn&&ne&&ci.createPortal(s.jsxs("div",{ref:ur,role:"menu","aria-label":l("android.more"),style:{left:ne.left,top:ne.top,width:e1},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(Zh,{icon:s.jsx(Cl,{size:13}),label:l("android.addDevice"),active:Ce,onSelect:()=>{St(H=>!H),Hr(!1)}}),s.jsx(Zh,{icon:an?s.jsx(Dn,{size:13}):s.jsx(Hl,{size:13}),label:l(an?"android.splitClose":"android.splitOpen"),active:an,disabled:!an&&!Zr,onSelect:()=>{nt(),Hr(!1)}}),s.jsx(Zh,{icon:d==="window"?s.jsx(ZT,{size:13}):s.jsx(GT,{size:13}),label:l(d==="window"?"android.exitFullscreen":"android.fullscreen"),active:d==="window",onSelect:()=>{f(d==="window"?"off":"window"),Hr(!1)}}),!t&&s.jsx(Zh,{icon:d==="sidebar"?s.jsx(aS,{size:13}):s.jsx(uS,{size:13}),label:l(d==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:d==="sidebar",onSelect:()=>{f(d==="sidebar"?"off":"sidebar"),Hr(!1)}}),ge&&s.jsxs("div",{className:"mt-1 border-t border-border px-3 py-2 text-[10px] leading-4 tabular-nums text-muted-foreground",children:[s.jsx("div",{className:"truncate",children:`${tt.fps} fps · ${tt.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${tt.width}×${tt.height}`})]})]}),document.body),(_e==="custom"||ae)&&s.jsxs("div",{className:"border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[s.jsxs("button",{type:"button",onClick:()=>ut(H=>!H),"aria-expanded":me,className:"flex w-full items-center gap-1 rounded text-muted-foreground hover:text-foreground",children:[s.jsx(Cl,{size:12,className:`transition-transform ${me?"":"-rotate-90"}`}),s.jsxs("span",{children:[l("android.quality"),ae?` · ${Ke.find(H=>H.id===ae)?.name??""}`:""]})]}),me&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(_y,{label:l("android.qualityResolution"),display:`${ft.maxSize}px`,min:360,max:2160,step:8,value:ft.maxSize,onChange:H=>Se(ue=>({...ue,maxSize:H}))}),s.jsx(_y,{label:l("android.qualityBitRate"),display:`${(ft.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:ft.bitRate/1e6,onChange:H=>Se(ue=>({...ue,bitRate:Math.round(H*1e6)}))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:l("android.qualityFrameRate")}),s.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(H=>s.jsx("button",{type:"button",onClick:()=>Se(ue=>({...ue,maxFps:H})),className:`rounded px-2 py-0.5 ${ft.maxFps===H?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:H},H)),s.jsx("button",{type:"button",onClick:()=>Se(H=>({...H,maxFps:0})),className:`rounded px-2 py-0.5 ${ft.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:Wr,disabled:!se,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:l("android.qualityApply")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:at,onChange:H=>ct(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&Y()},placeholder:l("android.presetNamePlaceholder"),maxLength:40,className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:Y,disabled:!at.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:l("android.presetSave")}),ae&&s.jsx("button",{type:"button",onClick:Be,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),Ce&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:Ot,onChange:H=>Jt(H.target.value),onKeyDown:H=>{H.key==="Enter"&&as()},placeholder:l("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{as()},disabled:lt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:lt?s.jsx(Rn,{size:12,className:"animate-spin"}):l("android.connect")})]}),Xr&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.adbUnavailable")}),s.jsx(Sy,{label:l("android.insertFixPrompt"),onClick:()=>xr(Cy("adb",le??"")),enabled:!!r})]}),!Xr&&vr&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.scrcpyUnavailable")}),s.jsx(Sy,{label:l("android.insertFixPrompt"),onClick:()=>xr(Cy("scrcpy","")),enabled:!!r})]}),Ur&&Ur.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:S$(Ur,l)}),le&&!Xr&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:uy(le)}),Zt&&s.jsxs("details",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsxs("summary",{className:"cursor-pointer",children:[l("android.qualityAutoUnavailable")," ",l(Zt.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Zt.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Zt.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Zt.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Zt.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Zt.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Zt})]}),Mt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:Mt}),we&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:we}),s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 touch-none items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[s.jsx("canvas",{ref:m,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:Or||ge?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:Bn,onPointerMove:Xn,onPointerUp:pn,onPointerCancel:()=>on(),onLostPointerCapture:H=>{O.current.has(H.pointerId)&&on()},onPointerLeave:H=>{O.current.has(H.pointerId)&&!H.currentTarget.hasPointerCapture?.(H.pointerId)&&on()},onContextMenu:H=>H.preventDefault()}),xe&&s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border border-primary/80 bg-primary/35",style:{left:xe.left,top:xe.top}}),ot.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:K?1:0,transition:"opacity 160ms linear"},children:ot.slice(1).map((H,ue)=>{const R=ot[ue],U=(ue+1)/(ot.length-1);return s.jsx("line",{x1:R.x,y1:R.y,x2:H.x,y2:H.y,stroke:"var(--primary)",strokeWidth:1+1.6*U,strokeLinecap:"round",opacity:.06+.45*U},ue)})}),Bt.map(H=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:H.left,top:H.top}},H.id)),!Or&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[He==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(Rn,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),He==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(V0,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:jt?l("android.reconnecting"):uy(z||"")}),se&&s.jsx("button",{type:"button",onClick:()=>{V.current=0,hn(se)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),He==="idle"&&!Xr&&!vr&&s.jsxs(s.Fragment,{children:[s.jsx(XT,{size:22,className:"opacity-60"}),s.jsx("span",{children:tn.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${br?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Yo,{compact:br,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!Or,children:s.jsx(e3,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!Or,children:s.jsx(OT,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!Or,children:s.jsx(c3,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!Or,children:s.jsx(i3,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!Or,children:s.jsx(ES,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!Or,children:s.jsx(JS,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!Or,children:s.jsx(tC,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!Or,children:s.jsx(_S,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.inputText"),active:ar,onClick:()=>_r(H=>!H),disabled:!Or,children:s.jsx(l3,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.zoomIn"),onClick:()=>wr("in"),disabled:!Or||ee>=Af-.01,children:s.jsx(Xs,{size:14})}),s.jsx(Yo,{compact:br,label:l("android.zoomOut"),onClick:()=>wr("out"),disabled:!Or||ee<=$l+.01,children:s.jsx(u3,{size:14})}),s.jsxs("div",{className:"relative ml-auto h-5 w-24 min-w-0 max-w-full shrink-0","data-mirror-capture-status":!0,children:[s.jsx("span",{"aria-hidden":st||!!Tt||Mn,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${st||Tt||Mn?"invisible":""}`,children:ge?s.jsx(s.Fragment,{children:s.jsx("span",{ref:pe})}):""}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-end overflow-hidden",children:s.jsx(A$,{recording:st,elapsed:Tn,status:Mn?l("android.captureInserting"):Tt,stopLabel:l("android.recordingStop"),onStop:()=>{Qs("manual")}})})]})]}),ar&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:Nr,onChange:H=>zr(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&(H.preventDefault(),rn())},placeholder:l("android.inputPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground",autoFocus:!0}),s.jsx("button",{type:"button",onClick:rn,disabled:!Nr,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(y0,{size:13})})]})]});return d==="window"?ci.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-[var(--chrome-bg)]",style:{paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:Pt}),document.body):t?an&&Mr?ci.createPortal(Pt,Mr):null:an&&Mr?s.jsxs(s.Fragment,{children:[ci.createPortal(Pt,Mr),s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[s.jsx(Hl,{size:18,className:"opacity-60"}),s.jsx("span",{children:l("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Vr(a0,null),jr({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):Pt}function Zh({icon:e,label:t,active:r=!1,disabled:n=!1,onSelect:a}){return s.jsxs("button",{type:"button",role:"menuitem",disabled:n,onClick:a,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition hover:bg-surface-2 disabled:opacity-40 disabled:hover:bg-transparent ${r?"text-primary":"text-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r&&s.jsx(Ci,{size:12,className:"shrink-0"})]})}function A$({recording:e,elapsed:t,status:r,stopLabel:n,onStop:a}){return e?s.jsxs("span",{role:"status","aria-live":"polite",className:"ml-auto inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] tabular-nums text-destructive",children:[s.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-destructive"}),xy(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${xy(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(p3,{size:8,fill:"currentColor"})})]}):r?s.jsx("span",{role:"status","aria-live":"polite",title:r,className:"ml-auto truncate text-[10px] text-primary",children:r}):null}function Ty({sessionId:e}){const t=ss(x=>x.docks[g0]),r=!!t,n=t?.sessionId??e??null,c=Jm(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await W0("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await yy(w,n)},[n]),d=b.useCallback(x=>{Jm.getState().enqueue(x,n)},[n]),f=ss(x=>!!x.hosts[g0]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,Cc().then(x=>{const y=x.androidPanel?.docked;y&&(ss.getState().docks[g0]||ss.getState().setDock(g0,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&f&&s.jsx(w$,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>_4(x,n):void 0,onRecordingComplete:d}),c&&s.jsx(m$,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):yy(x,c.sessionId),onDone:()=>Jm.getState().remove(c.file.id)},c.file.id)]})}function Sy({label:e,onClick:t,enabled:r}){return r?s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-elevated",children:e}):null}function Cy(e,t){return[`Termdock 的“设备投屏”在当前服务端不可用:未找到 ${e==="adb"?"adb(Android platform-tools)":"scrcpy / scrcpy-server"}${t?`(错误:${t})`:""}。`,"请在本机安装并让 Termdock 恢复可用:","1) 安装依赖:"," - macOS: brew install android-platform-tools scrcpy"," - Ubuntu/Debian: sudo apt install adb scrcpy"," - Windows: winget install Google.PlatformTools && winget install Genymobile.scrcpy","2) 若不在 PATH,请在 ~/.termdock/.env 指定 TERMDOCK_ADB_BIN / TERMDOCK_SCRCPY_BIN / TERMDOCK_SCRCPY_SERVER。","3) 完成后重启 Termdock 服务,并用 adb version、scrcpy --version 验证。","边界:只做本机环境安装与配置,不要改动 Termdock 仓库代码。"].join(`
163
+ `)}function _y({label:e,display:t,min:r,max:n,step:a,value:c,onChange:l}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),s.jsx("input",{type:"range",min:r,max:n,step:a,value:c,onChange:d=>l(Number(d.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),s.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:t})]})}function Yo({label:e,onClick:t,disabled:r,active:n,compact:a,children:c}){return s.jsx("button",{type:"button",onClick:t,disabled:r,title:e,"aria-label":e,className:`${a?"inline-flex h-5 w-5 items-center justify-center":"p-1.5"} rounded transition active:scale-95 disabled:opacity-30 ${n?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:c})}function ky(e,t,r){const n=e.parentElement;if(!n)return null;const a=e.getBoundingClientRect(),c=n.getBoundingClientRect();return{left:a.left-c.left+(t-a.left),top:a.top-c.top+(r-a.top)}}function Kh(e,t,r){const n=e.getBoundingClientRect(),a=e.width||n.width,c=e.height||n.height,l=n.width?(t-n.left)/n.width*a:0,d=n.height?(r-n.top)/n.height*c:0;return{x:Math.max(0,Math.min(a,l)),y:Math.max(0,Math.min(c,d))}}function T$(e){return!(/ADB_NOT_FOUND|SCRCPY_NOT_FOUND|SCRCPY_SERVER_NOT_FOUND|SCRCPY_VERSION_UNKNOWN|SCRCPY_UNSUPPORTED_CODEC|VIDEO_DECODER_UNSUPPORTED|decoder|decode/i.test(e)||/INVALID_SERIAL|INVALID_ADDRESS|API_NOT_ALLOWED|AUTHORIZATION_DENIED/i.test(e))}function Ly(e,t){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${t("android.stateUnauthorized")}`:e.state==="offline"?` · ${t("android.stateOffline")}`:` · ${t("android.stateUnknown")}`}function S$(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function C$(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function _$(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function k$(e){if(!e)return"";const t=new Date(e),r=Date.now(),n=t.getTime()-r;if(n<=0)return"";const a=Math.floor(n/6e4),c=Math.floor(a/60),l=Math.floor(c/24),d=c%24,f=a%60,m=t.toLocaleDateString(void 0,{month:"short",day:"numeric"}),x=t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});let y;return l>0?y=`${l}d ${d}h`:d>0?y=`${d}h ${f}m`:f>0?y=`${f}m`:y="soon",`resets in ${y} (${m} ${x})`}function L$(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function I$({result:e}){const{t}=Gr(),r=e.windows.filter(d=>d.percent===0&&!d.resetAt),n=e.windows.filter(d=>d.percent>0||d.resetAt),a=r.length>0?r.map(d=>d.label).join(" · "):"",c=!!e.error;let l=null;return!c&&e.entitlement&&(e.usagePercent>=90?l=t("quota.exhausted"):e.remaining!==void 0&&e.remaining<e.entitlement?l=t("quota.left",{n:e.remaining}):l=`${Math.round(e.usagePercent)}%`),s.jsxs("div",{className:"rounded-xl border border-border/15 bg-surface-2 p-3 sm:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-foreground",children:[s.jsx("span",{className:"shrink-0",children:L$(e.slug)}),s.jsx("span",{className:"truncate",children:e.displayName}),a&&s.jsx("span",{className:"shrink-0 rounded-full bg-surface-elevated px-2 py-0.5 text-[10px] font-normal text-muted-foreground",children:a})]}),l&&s.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:l})]}),n.length>0?s.jsx("div",{className:"mt-2.5 space-y-2",children:n.map(d=>{const f=Math.max(0,Math.min(100,d.percent));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[s.jsx("span",{className:"w-14 shrink-0 truncate text-muted-foreground sm:w-16",children:d.label}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:"h-2 rounded-full",style:{background:_$(d.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,background:C$(d.percent)}})})}),s.jsxs("span",{className:"w-9 shrink-0 text-right tabular-nums font-medium text-foreground",children:[Math.round(d.percent),"%"]})]}),d.resetAt&&s.jsx("p",{className:"mt-1 pl-14 text-[10px] text-muted-foreground sm:pl-16",children:k$(d.resetAt)})]},d.label)})}):c?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function E$({isOpen:e,onClose:t}){const{t:r}=Gr(),[n,a]=b.useState([]),[c,l]=b.useState(!1),d=async(x=!1)=>{l(!0);try{const y=x?await N9():await R9();a(y.providers||[])}catch{}finally{l(!1)}};if(b.useEffect(()=>{e&&d()},[e]),b.useEffect(()=>{if(!e)return;const x=y=>{const w=y.detail;Array.isArray(w)&&a(w)};return window.addEventListener("termdock:quota-update",x),()=>{window.removeEventListener("termdock:quota-update",x)}},[e]),!e)return null;const f=n.filter(x=>!x.error),m=f.length>0?new Date(Math.max(...f.map(x=>x.fetchedAt||0))):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t}),s.jsxs("div",{className:"fixed inset-x-3 z-modal-panel mx-auto flex max-w-lg flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",style:{top:"max(1.5rem, env(safe-area-inset-top, 0px))",bottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-3 py-2.5 sm:px-6 sm:py-3",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground sm:text-base",children:r("quota.title")}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>d(!0),disabled:c,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":r("quota.refresh"),children:s.jsx(An,{size:15,className:c?"animate-spin":""})}),s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":r("quota.close"),children:s.jsx(Dn,{size:17})})]})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:[c&&f.length===0?s.jsx(_0,{label:r("common.loading"),className:"py-12"}):f.length===0?s.jsxs("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:[s.jsx("p",{children:r("quota.noProviders")}),s.jsx("p",{className:"mt-1.5 text-[11px]",children:r("quota.noProvidersHint")})]}):s.jsx("div",{className:"space-y-2.5",children:f.map(x=>s.jsx(I$,{result:x},x.slug))}),m&&s.jsx("p",{className:"mt-3 text-center text-[10px] text-muted-foreground",children:r("quota.updated",{time:m.toLocaleTimeString()})})]})]})]})}const Iy=[{label:"Esc",sequence:"\\u001b"},{label:"Tab",sequence:"\\t"},{label:"Enter",sequence:"\\r"},{label:"S-Tab",sequence:"\\u001b[Z"},{label:"C-c",sequence:"\\u0003"},{label:"C-d",sequence:"\\u0004"},{label:"C-l",sequence:"\\u000c"},{label:"C-r",sequence:"\\u0012"},{label:"C-z",sequence:"\\u001a"},{label:"C-w",sequence:"\\u0017"},{label:"Up",sequence:"\\u001b[A"},{label:"Down",sequence:"\\u001b[B"},{label:"Left",sequence:"\\u001b[D"},{label:"Right",sequence:"\\u001b[C"},{label:"PgUp",sequence:"\\u001b[5~"},{label:"PgDn",sequence:"\\u001b[6~"}],N$=2,R$=20;function M$({label:e}){return s.jsx("div",{className:"h-7 rounded-full bg-surface-2 px-3 text-[11px] leading-7 text-center text-muted-foreground truncate",children:e})}function j$({value:e,onChange:t,placeholder:r}){const{t:n}=Gr(),[a,c]=_.useState(""),l=y=>{const w=[];let v="",T=!1;const C=()=>{const N=v.trim();N&&w.push(N),v=""};for(let N=0;N<y.length;N+=1){const D=y[N];if(!T&&D==="/"&&v.trim().length===0){T=!0,v+=D;continue}if(T){if(v+=D,D==="/"&&y[N-1]!=="\\"&&v.length>1){for(;N+1<y.length&&/[gimsuy]/.test(y[N+1]??"");)N+=1,v+=y[N];C(),T=!1}continue}if(D===","||/\s/.test(D)){C();continue}v+=D}if(C(),w.length===0)return;const L=[...e];for(const N of w){const D=Tv(N);D&&(L.includes(D)||L.push(D))}t(L),c("")},d=y=>{t(e.filter(w=>w!==y))},f=a.trim(),m=f.length>0&&r5(f),x=m&&!Qf(f);return s.jsx("div",{className:"rounded-2xl bg-surface px-3 py-2 ring-1 ring-border/15 focus-within:ring-accent/40",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.map(y=>{const w=r5(y),v=w&&!Qf(y);return s.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] ${v?"bg-destructive/15 text-destructive":w?"bg-accent/15 font-mono text-accent":"bg-surface-elevated text-foreground"}`,title:w?v?n("settings.invalidRegex"):"Regex match":"Substring match (case-insensitive)",children:[w&&s.jsx("span",{className:"text-[10px] opacity-70",children:"re"}),y,s.jsx("button",{type:"button",onClick:()=>d(y),className:"rounded-full p-0.5 text-muted-foreground hover:bg-destructive/20 hover:text-destructive","aria-label":n("toolbarPresets.removeAction",{name:y}),children:s.jsx(Dn,{size:12})})]},y)}),s.jsx("input",{type:"text",value:a,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"||y.key===","&&!m?(y.preventDefault(),l(a)):y.key==="Backspace"&&a.length===0&&e.length>0&&d(e[e.length-1])},onBlur:()=>l(a),placeholder:e.length===0?r:"",className:`min-w-[8ch] flex-1 bg-transparent py-1 text-sm outline-none placeholder:text-muted/60 ${m?"font-mono":""} ${x?"text-destructive":""}`,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off"})]})})}function D$({value:e,min:t,max:r,onChange:n}){const{t:a}=Gr();return s.jsxs("div",{className:"inline-flex items-center gap-1 rounded-full bg-surface px-1 py-1 ring-1 ring-border/15",children:[s.jsx("button",{type:"button",onClick:()=>n(Math.max(t,e-1)),disabled:e<=t,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.decrease"),children:s.jsx(u3,{size:14})}),s.jsx("span",{className:"w-6 text-center text-sm font-medium tabular-nums text-foreground",children:e}),s.jsx("button",{type:"button",onClick:()=>n(Math.min(r,e+1)),disabled:e>=r,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.increase"),children:s.jsx(Xs,{size:14})})]})}const B$=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:c,onResetDefaults:l})=>{const{t:d}=Gr(),f=e.find(N=>N.id===t)??e[0]??null,[m,x]=_.useState(null);if(!f)return null;const y=f.actions.length>0,w=[{id:"preview-auto",label:f.label,kind:"preset"},...f.includeAlt?[{id:"preview-alt",label:"Alt"}]:[],...y?f.actions.map((N,D)=>({id:N.id,label:k1(N,D)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(N=>({id:N,label:N}))],v=Sv(w,f.rowLayout),T=(N,D)=>{n(f.id,O=>{const P=O.actions.findIndex(Z=>Z.id===N);if(P===-1)return O;const F=P+D;if(F<0||F>=O.actions.length)return O;const ee=[...O.actions];return[ee[P],ee[F]]=[ee[F],ee[P]],{...O,actions:ee}})},C=f.rowLayout.reduce((N,D)=>N+D,0),L=1+(f.includeAlt?1:0);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky top-[-1rem] sm:top-[-1.5rem] z-10 -mx-4 -mt-4 sm:-mx-6 sm:-mt-6 border-b border-border/15 bg-surface/95 backdrop-blur px-4 py-3 sm:px-6",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.preview")}),s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[f.actions.length," button",f.actions.length===1?"":"s"," · ",C," slot",C===1?"":"s"]})]}),s.jsx("div",{className:"space-y-1 rounded-2xl bg-surface-2/60 p-2",children:v.map((N,D)=>{const O=N.items[0]?.kind==="preset",P=Math.max(2,N.columns),F=O?`${Cv}px repeat(${Math.max(1,P-1)}, minmax(0, 1fr))`:`repeat(${P}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:F},children:N.items.map(ee=>ee.kind==="preset"?s.jsx(_v,{mode:"auto",presetLabel:ee.label,title:`Auto preset · ${ee.label}`,disabled:!0},ee.id):s.jsx(M$,{label:ee.label},ee.id))},`preview-row-${D}`)})}),f.actions.length>C-L&&s.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground",children:d("toolbarPresets.overCapacityHint")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.presets")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(Xs,{size:14}),d("toolbarPresets.new")]}),s.jsxs("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(An,{size:14}),d("toolbarPresets.reset")]})]})]}),s.jsx("div",{className:"-mx-1 flex flex-wrap gap-1.5 px-1",children:e.map(N=>s.jsxs("button",{type:"button",onClick:()=>r(N.id),className:`rounded-full px-3 py-2 text-xs font-medium transition ${N.id===f.id?"bg-primary/20 text-primary ring-1 ring-primary/30":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,children:[N.label,N.actions.length>0&&s.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:N.actions.length})]},N.id))})]}),s.jsxs("div",{className:"space-y-4 rounded-2xl bg-surface p-4 ring-1 ring-border/10",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.label")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:f.label,onChange:N=>n(f.id,D=>({...D,label:N.target.value})),className:"flex-1 rounded-full bg-surface-2 px-4 py-2.5 text-sm placeholder:text-muted/60 outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.presetLabelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"}),f.id!=="default"&&s.jsx("button",{type:"button",onClick:()=>c(f.id),className:"shrink-0 rounded-full bg-surface-2 px-3 py-2.5 text-destructive hover:bg-destructive/15","aria-label":d("toolbarPresets.deletePreset",{name:f.label}),children:s.jsx(zs,{size:14})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.matchPrograms")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:d("toolbarPresets.typeEnterHint")})]}),s.jsx(j$,{value:f.programs,onChange:N=>n(f.id,D=>({...D,programs:N})),placeholder:d("toolbarPresets.programsPlaceholder")}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("toolbarPresets.programsHelp")})]}),s.jsxs("button",{type:"button",onClick:()=>n(f.id,N=>({...N,includeAlt:!N.includeAlt})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:d("toolbarPresets.altSlot")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:d("toolbarPresets.altSlotHint")})]}),s.jsx(Al,{checked:f.includeAlt})]}),s.jsxs("button",{type:"button",onClick:()=>n(f.id,N=>({...N,showOnDesktop:!N.showOnDesktop})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:d("toolbarPresets.desktopVisibility")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:d("toolbarPresets.desktopVisibilityHint")})]}),s.jsx(Al,{checked:f.showOnDesktop===!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.rowLayout")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:d("toolbarPresets.rowLayoutHint")})]}),s.jsxs("button",{type:"button",onClick:()=>n(f.id,N=>({...N,rowLayout:[...Ag(N.rowLayout),3]})),className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium hover:bg-surface-elevated",children:[s.jsx(Xs,{size:12}),d("toolbarPresets.addRow")]})]}),s.jsx("div",{className:"space-y-2",children:f.rowLayout.map((N,D)=>s.jsxs("div",{className:"flex items-center gap-3 rounded-2xl bg-surface-2 px-3 py-2",children:[s.jsx("span",{className:"w-12 shrink-0 text-xs text-muted-foreground",children:d("toolbarPresets.rowN",{n:D+1})}),s.jsx("div",{className:"flex-1"}),s.jsx(D$,{value:N,min:N$,max:R$,onChange:O=>n(f.id,P=>({...P,rowLayout:P.rowLayout.map((F,ee)=>ee===D?O:F)}))}),f.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(f.id,O=>({...O,rowLayout:O.rowLayout.filter((P,F)=>F!==D)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":d("toolbarPresets.removeRow",{n:D+1}),children:d("toolbarPresets.del")})]},`row-${D}`))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.buttons")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:d("toolbarPresets.buttonsHint")})]}),s.jsxs("button",{type:"button",onClick:()=>{const N=`${f.id}-action-${Date.now()}`;n(f.id,D=>({...D,actions:[...D.actions,{id:N,label:`Key ${D.actions.length+1}`,sequence:""}]})),x(N)},className:"inline-flex items-center gap-1 rounded-full bg-primary/15 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/25",children:[s.jsx(Xs,{size:12}),d("toolbarPresets.addButton")]})]}),f.actions.length===0&&s.jsx("div",{className:"rounded-2xl bg-surface-2/60 px-4 py-6 text-center text-[11px] text-muted-foreground",children:d("toolbarPresets.noCustomButtons")}),f.actions.map((N,D)=>{const O=m===N.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${O?"ring-1 ring-accent/40":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>T(N.id,-1),disabled:D===0,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":d("toolbarPresets.moveUp"),children:s.jsx(s3,{size:12})}),s.jsx("button",{type:"button",onClick:()=>T(N.id,1),disabled:D===f.actions.length-1,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":d("toolbarPresets.moveDown"),children:s.jsx(VA,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(O?null:N.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:k1(N,D)}),s.jsxs("div",{className:"truncate text-[11px] text-muted-foreground",children:[N.sequence?N.sequence:d("toolbarPresets.noSequence"),N.doubleTapSequence&&s.jsxs("span",{className:"ml-1 text-accent/70",children:["· 2× ",N.doubleTapSequence]})]})]}),s.jsx("button",{type:"button",onClick:()=>n(f.id,P=>({...P,actions:P.actions.filter(F=>F.id!==N.id)})),className:"shrink-0 rounded-full bg-surface p-2 text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":d("toolbarPresets.removeAction",{name:N.label}),children:s.jsx(zs,{size:14})})]}),O&&s.jsxs("div",{className:"space-y-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.labelField")}),s.jsx("input",{type:"text",value:N.label,onChange:P=>n(f.id,F=>({...F,actions:F.actions.map(ee=>ee.id===N.id?{...ee,label:P.target.value}:ee)})),className:"w-full rounded-full bg-surface px-4 py-2.5 text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.labelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.sequence")}),s.jsx("input",{type:"text",value:N.sequence,onChange:P=>n(f.id,F=>({...F,actions:F.actions.map(ee=>ee.id===N.id?{...ee,sequence:P.target.value}:ee)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.sequencePlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:Iy.map(P=>s.jsx("button",{type:"button",onClick:()=>n(f.id,F=>({...F,actions:F.actions.map(ee=>ee.id===N.id?{...ee,sequence:P.sequence}:ee)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:P.label},P.label))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.doubleTap")}),!N.doubleTapSequence&&s.jsx("button",{type:"button",onClick:()=>n(f.id,P=>({...P,actions:P.actions.map(F=>F.id===N.id?{...F,doubleTapSequence:""}:F)})),className:"text-[10px] text-accent hover:text-accent/80",children:d("toolbarPresets.doubleTapAdd")})]}),N.doubleTapSequence!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:N.doubleTapSequence,onChange:P=>n(f.id,F=>({...F,actions:F.actions.map(ee=>ee.id===N.id?{...ee,doubleTapSequence:P.target.value}:ee)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.doubleTapPlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[Iy.map(P=>s.jsx("button",{type:"button",onClick:()=>n(f.id,F=>({...F,actions:F.actions.map(ee=>ee.id===N.id?{...ee,doubleTapSequence:(ee.doubleTapSequence??"")+P.sequence}:ee)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:P.label},P.label)),s.jsx("button",{type:"button",onClick:()=>n(f.id,P=>({...P,actions:P.actions.map(F=>{if(F.id!==N.id)return F;const{doubleTapSequence:ee,...Z}=F;return Z})})),className:"rounded-full bg-destructive/10 px-2.5 py-1 text-[11px] font-medium text-destructive/70 hover:bg-destructive/20 hover:text-destructive",children:d("toolbarPresets.remove")})]})]})]})]})]},N.id)})]})]})]})},Q$={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function P$(){const{t:e}=Gr(),[t,r]=_.useState(null),[n,a]=_.useState(null),[c,l]=_.useState(null),[d,f]=_.useState(null),[m,x]=_.useState(!1),[y,w]=_.useState(!1),[v,T]=_.useState(""),[C,L]=_.useState(""),[N,D]=_.useState(null),[O,P]=_.useState([]),[F,ee]=_.useState([]),[Z,G]=_.useState(null),[de,pe]=_.useState(new Set),[J,Re]=_.useState(null),[Ze,V]=_.useState("auto"),[ve,qe]=_.useState({}),[le,ye]=_.useState(null),[Te,Fe]=_.useState(null),[se,De]=_.useState(10),[_e,Me]=_.useState(""),[Ke,Ne]=_.useState(""),[ae,ze]=_.useState(12e3),[at,ct]=_.useState(null),[me,ut]=_.useState(null),ft=_.useCallback(async()=>{const[xe,Je,ot,Nt]=await Promise.allSettled([M9(),j9(),Cc(),Ld()]);if(r(xe.status==="fulfilled"?xe.value:[]),Je.status==="fulfilled"){const K=Je.value;P(K.plugins??[]),ee(K.errors??[])}else P([]),ee([]);if(ot.status==="fulfilled"){const K=ot.value;pe(new Set(K.autoRenameAgents??[])),V(K.autoRenameNamer??"auto"),qe(K.autoRenameModels??{}),De(K.autoRenameIntervalMinutes??10),Me(K.autoRenamePromptPreference??""),Ne(K.autoRenamePromptPreference??""),ze(K.autoRenamePromptPayloadChars??12e3)}else pe(new Set);ye(Nt.status==="fulfilled"?Nt.value:[])},[]);_.useEffect(()=>{ft()},[ft]);const Se=async(xe,Je)=>{a(xe),l(null);try{Je==="install"?(await D9(xe)).devMode&&f(xe):(await B9(xe),d===xe&&f(null)),await ft()}catch(ot){l(ot instanceof Error?ot.message:String(ot))}finally{a(null)}},He=xe=>e(xe==="installed"?"settings.agentHooksInstalled":xe==="outdated"?"settings.agentHooksOutdated":xe==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),ke=async()=>{D(null);let xe;try{xe=JSON.parse(C)}catch{D("Invalid JSON");return}try{await U9(xe),L(""),x(!1),await ft()}catch(Je){if(Je instanceof z9&&Je.migration){ee(ot=>[{slug:typeof xe.slug=="string"?xe.slug:"manifest.json",errors:Je.message.split(`
164
+ `),code:Je.code,migration:Je.migration},...ot.filter(Nt=>Nt.slug!==xe.slug)]);return}D(Je instanceof Error?Je.message:String(Je))}},z=async()=>{const xe=v.trim();if(xe){ct("install"),D(null);try{await Q9(xe),T(""),w(!1),await ft()}catch(Je){D(Je instanceof Error?Je.message:String(Je))}finally{ct(null)}}},ie=async xe=>{ct(`remove:${xe}`);try{await $9(xe),ut(Je=>Je?.slug===xe?null:Je),await ft()}catch(Je){l(Je instanceof Error?Je.message:String(Je))}finally{ct(null)}},ge=async xe=>{ct(`check:${xe}`),l(null);try{await F9(xe),await ft()}catch(Je){l(Je instanceof Error?Je.message:String(Je))}finally{ct(null)}},We=async xe=>{ct(`update:${xe}`),l(null);try{const Je=await O9(xe),ot=[Je.hookWarning,Je.titleWarning].filter(Boolean).join(" ");ot&&l(ot),ut(Nt=>Nt?.slug===xe?null:Nt),await ft()}catch(Je){l(Je instanceof Error?Je.message:String(Je))}finally{ct(null)}},tt=async xe=>{ct(`doctor:${xe}`),l(null),ut(null);try{const Je=await P9(xe);ut(Je),ye(await Ld())}catch(Je){l(Je instanceof Error?Je.message:String(Je))}finally{ct(null)}},wt=async xe=>{const Je=xe.migration?.aiPrompt??xe.errors.join(`
165
+ `);try{await navigator.clipboard.writeText(Je),G(xe.slug),window.setTimeout(()=>G(ot=>ot===xe.slug?null:ot),1800)}catch{D(Je)}},Zt=async xe=>{if(J)return;const Je=de,ot=new Set(Je);ot.has(xe)?ot.delete(xe):ot.add(xe),pe(ot),Re(xe),l(null);try{const Nt=await Ua({autoRenameAgents:[...ot]});pe(new Set(Nt.autoRenameAgents??[])),ye(await Ld(!0))}catch(Nt){pe(Je),l(Nt instanceof Error?Nt.message:String(Nt))}finally{Re(null)}},Ut=async xe=>{const Je=Ze;V(xe),Fe("namer"),l(null);try{const ot=await Ua({autoRenameNamer:xe});V(ot.autoRenameNamer??"auto"),ye(await Ld(!0))}catch(ot){V(Je),l(ot instanceof Error?ot.message:String(ot))}finally{Fe(null)}},Mt=async(xe,Je)=>{const ot=ve,Nt={...ot};Je?Nt[xe]=Je:delete Nt[xe],qe(Nt),Fe(xe),l(null);try{const K=await Ua({autoRenameModels:Nt});qe(K.autoRenameModels??{})}catch(K){qe(ot),l(K instanceof Error?K.message:String(K))}finally{Fe(null)}},nr=async xe=>{const Je=se;De(xe),Fe("interval"),l(null);try{const ot=await Ua({autoRenameIntervalMinutes:xe});De(ot.autoRenameIntervalMinutes??10)}catch(ot){De(Je),l(ot instanceof Error?ot.message:String(ot))}finally{Fe(null)}},jt=async()=>{const xe=_e.trim();if(xe!==Ke){Fe("preference"),l(null);try{const ot=(await Ua({autoRenamePromptPreference:xe})).autoRenamePromptPreference??"";Me(ot),Ne(ot)}catch(Je){Me(Ke),l(Je instanceof Error?Je.message:String(Je))}finally{Fe(null)}}},Xt=async xe=>{const Je=Math.max(1e3,Math.min(64e3,Math.round(xe||12e3))),ot=ae;ze(Je),Fe("payload-limit"),l(null);try{const Nt=await Ua({autoRenamePromptPayloadChars:Je});ze(Nt.autoRenamePromptPayloadChars??12e3)}catch(Nt){ze(ot),l(Nt instanceof Error?Nt.message:String(Nt))}finally{Fe(null)}},Bt=new Set(O.map(xe=>xe.slug)),Ht=me?{ok:e("settings.agentPluginDoctorStatusOk"),"missing-title-namer":e("settings.agentPluginDoctorStatusMissing"),"cli-default":e("settings.agentPluginDoctorStatusCliDefault"),"no-models":e("settings.agentPluginDoctorStatusNoModels"),"probe-failed":e("settings.agentPluginDoctorStatusFailed")}[me.status]:"";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentAutoRename")}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameHint")}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameNamer")}),s.jsxs("select",{value:Ze,disabled:Te!==null,onChange:xe=>{Ut(xe.target.value)},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:e("settings.agentAutoRenameFollow")}),le?.filter(xe=>xe.available).map(xe=>s.jsx("option",{value:xe.slug,children:xe.displayName},xe.slug))]})]}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameInterval")}),s.jsx("select",{value:se,disabled:Te!==null,onChange:xe=>{nr(Number(xe.target.value))},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[5,10,30,60].map(xe=>s.jsxs("option",{value:xe,children:[xe," ",e("settings.agentAutoRenameMinutes")]},xe))})]}),s.jsxs("details",{className:"mt-2 border-t border-border/40 pt-2",children:[s.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentAutoRenameAdvanced")}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePreference")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePreferenceHint")}),s.jsx("textarea",{value:_e,maxLength:2e3,rows:3,disabled:Te!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:xe=>Me(xe.target.value),onBlur:()=>{jt()},className:"mt-1.5 w-full resize-y rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:ring-1 focus:ring-primary/50 disabled:opacity-50"}),s.jsx("span",{className:"mt-1 block text-right text-[10px] text-muted-foreground",children:Te==="preference"?e("settings.saving"):`${_e.length}/2000`})]}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePayloadLimit")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePayloadLimitHint")}),s.jsx("input",{type:"number",min:1e3,max:64e3,step:1e3,value:ae,disabled:Te!==null,onChange:xe=>ze(Number(xe.target.value)),onBlur:xe=>{Xt(Number(xe.target.value))},className:"mt-1.5 w-full rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameModelsFromCli")}),s.jsx("button",{type:"button",onClick:async()=>{ye(null);try{ye(await Ld(!0))}catch{ye([])}},className:"rounded p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",title:e("settings.agentAutoRenameRefreshModels"),children:s.jsx(An,{size:11,className:le===null?"animate-spin":""})})]}),le?.filter(xe=>xe.available).map(xe=>{const Je=xe.models.find(ot=>ot.id===xe.recommendedModel);return s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:xe.displayName}),s.jsxs("select",{value:ve[xe.slug]??"",disabled:Te!==null,onChange:ot=>{Mt(xe.slug,ot.target.value)},className:"min-w-0 max-w-[68%] rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"",children:Je?`${e("settings.agentAutoRenameAutomatic")} · ${Je.displayName}`:e("settings.agentAutoRenameCliDefault")}),xe.models.map(ot=>s.jsx("option",{value:ot.id,children:ot.displayName},ot.id))]})]},xe.slug)}),le?.length===0&&s.jsx("div",{className:"text-[10px] text-[color:var(--warning)]",children:e("settings.agentAutoRenameNoCli")})]})]}),t===null&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx(Rn,{size:12,className:"animate-spin"})," …"]}),t?.map(xe=>{const Je=n===xe.slug,ot=xe.state!=="not-installed",Nt=Bt.has(xe.slug);return s.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx(tu,{agent:{slug:xe.slug,displayName:xe.displayName,accentColor:xe.accentColor??"#878580",icon:xe.icon,isPlugin:Nt,iconMode:xe.iconMode,iconVersion:xe.iconVersion??void 0},size:18}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[13px] font-medium text-foreground",children:xe.displayName}),Nt&&s.jsx("span",{className:"rounded bg-[rgb(var(--success-rgb)_/_0.12)] px-1 py-px text-[9px] font-medium text-[color:var(--success)]",children:"plugin"}),s.jsxs("span",{className:`text-[10px] ${Q$[xe.state]}`,children:[xe.state==="installed"&&s.jsx(L0,{size:10,className:"mr-0.5 inline"}),(xe.state==="outdated"||xe.state==="needs-approval")&&s.jsx(ig,{size:10,className:"mr-0.5 inline"}),He(xe.state)]})]}),s.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",title:xe.targetDisplay,children:[e("settings.agentHooksTarget")," ",xe.targetDisplay]}),d===xe.slug&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksDevMode")}),xe.state==="needs-approval"&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksApprovalHint")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",disabled:J!==null,onClick:()=>{Zt(xe.slug)},className:"flex shrink-0 items-center gap-1.5 rounded-full px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-pressed":de.has(xe.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(Al,{checked:de.has(xe.slug),disabled:J!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:Je,onClick:()=>{Se(xe.slug,ot?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${ot?"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)]"} disabled:opacity-50`,children:[Je?s.jsx(Rn,{size:11,className:"animate-spin"}):ot?s.jsx(zs,{size:11}):xe.state==="outdated"?s.jsx(An,{size:11}):s.jsx(E0,{size:11}),Je?"…":ot?e("settings.agentHooksUninstall"):xe.state==="outdated"?e("settings.agentHooksReinstall"):e("settings.agentHooksInstall")]})]})]},xe.slug)}),c&&s.jsx("div",{className:"rounded-xl bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:c}),s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentPlugins")}),s.jsxs("button",{type:"button",onClick:()=>w(!y),className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-2.5 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(Xs,{size:11}),e("settings.agentPluginAdd")]})]}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentPluginHint")}),y&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:v,onChange:xe=>T(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&z()},className:"min-w-0 flex-1 rounded-lg bg-surface px-3 py-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground outline-none",placeholder:e("settings.agentPluginSourcePlaceholder")}),s.jsxs("button",{type:"button",disabled:!v.trim()||at!==null,onClick:()=>{z()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] transition hover:bg-[rgb(var(--success-rgb)_/_0.22)] disabled:opacity-50",children:[at==="install"?s.jsx(Rn,{size:11,className:"animate-spin"}):s.jsx(E0,{size:11}),e("settings.agentPluginInstallPackage")]})]}),s.jsx("button",{type:"button",onClick:()=>x(!m),className:"text-[10px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentPluginAdvancedManifest")})]}),O.map(xe=>{const Je=xe.revision?.slice(0,8),ot=at?.endsWith(`:${xe.slug}`)===!0;return s.jsxs("div",{className:"mt-2 flex items-center gap-2 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[s.jsx("span",{className:"truncate",children:xe.displayName}),xe.updateAvailable&&s.jsx("span",{className:"text-[9px] text-[color:var(--warning)]",children:e("settings.agentPluginUpdateAvailable")})]}),s.jsxs("div",{className:"truncate text-[9px] text-muted-foreground",title:xe.source??void 0,children:[xe.source??e("settings.agentPluginManualSource"),Je?` · ${Je}`:""]})]}),s.jsxs("button",{type:"button",disabled:at!==null,onClick:()=>{tt(xe.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",title:e("settings.agentPluginDoctorHint"),children:[at===`doctor:${xe.slug}`?s.jsx(Rn,{size:10,className:"animate-spin"}):s.jsx(US,{size:10}),e("settings.agentPluginDoctor")]}),xe.updateSupported&&s.jsxs("button",{type:"button",disabled:at!==null,onClick:()=>{xe.updateAvailable?We(xe.slug):ge(xe.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",children:[ot?s.jsx(Rn,{size:10,className:"animate-spin"}):s.jsx(An,{size:10}),xe.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:at!==null,onClick:()=>{ie(xe.slug)},className:"rounded-full p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-[color:var(--warning)] disabled:opacity-50",title:e("settings.agentPluginDelete"),children:s.jsx(zs,{size:11})})]},xe.slug)}),me&&s.jsxs("div",{className:`mt-2 rounded-lg px-3 py-2 text-[10px] ${me.status==="ok"||me.status==="cli-default"?"bg-[rgb(var(--success-rgb)_/_0.10)] text-[color:var(--success)]":"bg-[rgb(var(--warning-rgb)_/_0.10)] text-[color:var(--warning)]"}`,children:[s.jsxs("div",{className:"font-medium",children:[me.displayName,": ",Ht]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:me.models.length>0?`${me.models.length} ${e("settings.agentPluginDoctorModels")}${me.recommendedModel?` · ${e("settings.agentPluginDoctorAutomatic")} ${me.recommendedModel}`:""}`:e("settings.agentPluginDoctorCliDefault")}),me.error&&s.jsx("div",{className:"mt-1 break-words",children:me.error}),me.warnings.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:me.warnings.map(xe=>s.jsxs("div",{children:["• ",xe]},xe))}),me.nextSteps.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:me.nextSteps.map(xe=>s.jsxs("div",{children:["→ ",xe]},xe))})]}),F.map(xe=>s.jsxs("div",{className:"mt-2 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[10px] text-[color:var(--warning)]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"font-medium",children:[xe.slug,": ",xe.code??e("settings.agentPluginInvalid")]}),s.jsxs("button",{type:"button",onClick:()=>{wt(xe)},className:"flex shrink-0 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-1 font-medium transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)]",children:[Z===xe.slug?s.jsx(L0,{size:10}):s.jsx(a3,{size:10}),Z===xe.slug?e("settings.agentPluginCopied"):e("settings.agentPluginCopyAiPrompt")]})]}),s.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-muted-foreground",children:xe.errors.join(`
166
+ `)}),xe.migration?.guideCommand&&s.jsx("code",{className:"mt-1 block select-all text-foreground",children:xe.migration.guideCommand})]},xe.slug)),y&&m&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsx("textarea",{value:C,onChange:xe=>L(xe.target.value),rows:10,className:"w-full rounded-lg bg-surface px-3 py-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground outline-none resize-y",placeholder:`{
167
+ "version": 2,
168
+ "slug": "my-agent",
169
+ "displayName": "My Agent",
170
+ "aliases": ["my-agent"],
171
+ "accentColor": "#4385BE",
172
+ "statuses": [
173
+ { "id": "thinking", "phase": "working", "label": "Thinking", "indicator": "spinner", "tone": "info" },
174
+ { "id": "approval", "phase": "waiting", "label": "Needs approval", "indicator": "question", "tone": "warning" },
175
+ { "id": "complete", "phase": "done", "label": "Complete", "indicator": "badge", "tone": "success" }
176
+ ],
177
+ "hooks": {
178
+ "target": "~/.my-agent/settings.json",
179
+ "events": [
180
+ { "hook": "UserPromptSubmit", "event": "prompt-submit", "status": "thinking" },
181
+ { "hook": "PermissionRequest", "event": "permission-request", "status": "approval" },
182
+ { "hook": "Stop", "event": "stop", "status": "complete" }
183
+ ]
184
+ }
185
+ }`}),N&&s.jsx("div",{className:"whitespace-pre-wrap break-words text-[10px] text-[color:var(--warning)]",children:N}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{ke()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(bT,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),L(""),D(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function O$({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:d,onCheckDesktop:f,onInstallDesktop:m}){const{t:x}=Gr(),y=e?.status??"idle",w=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,T=y==="checking"?x("settings.updateChecking"):y==="installing"?x("sidebar.updateInstalling"):y==="ready"?x("sidebar.updateReady"):y==="restarting"?x("sidebar.updateRestarting"):y==="current"?x("settings.updateCurrent"):y==="error"?e?.error||x("sidebar.updateFailed"):x("settings.updateHint"),C=a?.currentVersion||l?.appVersion,L=a?.status??"idle",N=c||L==="checking"||L==="downloading"||L==="installing",D=L==="ready",O=a?.error||(L==="unsupported"?x("settings.desktopUpdateUnsupported"):L==="checking"?x("settings.desktopUpdateChecking"):L==="current"?x("settings.desktopUpdateCurrent"):L==="downloading"?x("settings.desktopUpdateDownloading"):L==="ready"?x("settings.desktopUpdateReady"):L==="installing"?x("settings.desktopUpdateInstalling"):L==="error"&&a?.error||x("settings.desktopUpdateHint"));return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"termdock-update-title",children:[s.jsx("div",{id:"termdock-update-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:x("settings.updateTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(An,{size:15,className:w?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.updateRuntimeTitle")}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:T}),e&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:v&&e.latestVersion?`${e.currentVersion} → ${e.latestVersion}`:`v${e.currentVersion}`})]})]}),v?s.jsx("button",{type:"button",disabled:w,onClick:n,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("sidebar.updateRestart")}):s.jsx("button",{type:"button",disabled:w,onClick:r,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(y==="checking"?"settings.updateCheckingShort":y==="installing"?"settings.updateInstallingShort":y==="error"?"sidebar.updateRetry":y==="current"?"settings.updateCheckAgain":"settings.updateCheck")})]}),(a||d)&&s.jsxs("div",{className:"flex items-start justify-between gap-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${D?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(An,{size:15,className:N?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.desktopUpdateTitle")}),s.jsx("div",{className:`mt-0.5 text-[10px] leading-relaxed ${a?.error?"text-destructive":"text-muted-foreground"}`,role:a?.error?"alert":void 0,children:a?O:x(f?"settings.desktopStatusLoading":"settings.desktopUpdateUnsupported")}),s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:D&&a?.latestVersion?`${a.currentVersion} → ${a.latestVersion}`:C?`v${C}`:null})]})]}),D?s.jsx("button",{type:"button",disabled:N||!m,onClick:m,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("settings.desktopUpdateRestart")}):s.jsx("button",{type:"button",disabled:!a||N||L==="unsupported"||!f,onClick:f,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(L==="installing"?"settings.updateInstallingShort":L==="downloading"?"settings.desktopUpdateDownloadingShort":L==="checking"?"settings.updateCheckingShort":L==="current"||L==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),d]})}function F$({quality:e}){const{locale:t}=Gr(),r=(d,f)=>t==="zh"?d:f,n=d=>d==null||!Number.isFinite(d)?"—":`${d.toFixed(1)} ms`,a=e?.diagnostics,c=d=>s.jsx("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1.5 tabular-nums",children:d.map(([f,m])=>s.jsxs(_.Fragment,{children:[s.jsx("dt",{children:f}),s.jsx("dd",{className:"text-right text-foreground break-all",children:m})]},f))}),l=(d,f)=>s.jsxs("section",{className:"mt-3 border-t border-border/30 pt-3",children:[s.jsx("h3",{className:"mb-2 font-medium text-foreground",children:d}),f]});return s.jsxs("div",{className:"text-[11px] leading-relaxed",children:[l(r("往返统计","Round-trip statistics"),s.jsxs(s.Fragment,{children:[c([[r("平均延迟","Average latency"),n(e?.average)],["P95",n(e?.p95)],[r("服务端回包处理","Server reply handler"),n(e?.handlerMs)]]),s.jsx("p",{className:"mt-2",children:r("8 秒未响应计为超时,不等于网络丢包。回包处理仅含消息解析至构造回复,不含解密、排队和发包。","A probe times out after 8s; this is not packet loss. Handler timing covers parsing through reply creation, excluding decryption, queues and transmission.")})]})),l(r("当前发送与排队","Current buffers and queues"),a?s.jsxs(s.Fragment,{children:[c([[r("传输层发送缓冲","Transport send buffer"),`${a.bufferedBytes} B`],[r("加密通道待发送","Channel writes pending"),a.pendingWrites?r("有","Yes"):r("无","No")],[r("进行中的非终端请求","Active non-terminal requests"),a.activeRequests],[r("等待通道的请求","Requests waiting for capacity"),a.waitingRequests]]),s.jsx("p",{className:"mt-2",children:r("属于此服务共用的连接,包含文件等其他请求。","Shared by this service, including file transfers and other requests.")})]}):s.jsx("p",{children:r("尚无连接记录。","No connection record yet.")})),l(r("本次连接建立 · 历史耗时","Connection setup · recorded timings"),s.jsxs(s.Fragment,{children:[c([[r("传输通道就绪","Transport ready"),n(a?.transportOpenMs)],...a?.relay?[[r("其中:连上入口 WebSocket","Within transport: entry WebSocket"),n(a.relay.entryOpenMs)],[r("其中:请求中转至通道打开","Within transport: relay open request"),n(a.relay.routeOpenMs)]]:[],[r("Noise 加密握手","Noise handshake"),n(a?.handshakeMs)],[r("终端逻辑通道就绪","Terminal logical channel ready"),n(a?.socketOpenMs)],[r("其中:等待本地通道名额","Within logical open: local capacity wait"),n(a?.socketQueueMs)]]),s.jsx("p",{className:"mt-2",children:r("这是建链时的历史耗时,不代表当前延迟。“其中”为子项,不能重复相加;中转耗时含处理和建链,不含之前的授权。","Recorded setup timings, not live latency. “Within” rows are subsets, not additive. Relay timing includes processing and setup, excluding earlier authorization.")})]}))]})}function $$({backendSessionId:e}){const{locale:t}=Gr(),r=t==="zh",[n,a]=_.useState(null),[c,l]=_.useState(!1);_.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(H9(e));y();const w=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(w),document.removeEventListener("visibilitychange",y)}},[e,c]);const d=n?.diagnostics,f=n?.rtt,m=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":f==null?r?"测量中…":"Measuring…":`${f} ms · ${f<150?r?"流畅":"Low latency":f<300?r?"有延迟":"Moderate latency":r?"高延迟":"High latency"}`:r?"未连接":"Disconnected",x=y=>y==null?"—":`${Math.round(y)} ms`;return s.jsxs("div",{className:"mt-3 rounded-xl bg-surface-2 px-3 text-muted-foreground",children:[s.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(y=>!y),className:"flex min-h-11 w-full items-center gap-2 py-2 text-[12px] tabular-nums hover:text-foreground","aria-label":`${r?"连接质量":"Connection quality"}${c?`: ${m}`:""}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${c&&n&&(!n.connected||n.waiting||f!=null&&f>=300)?"bg-destructive":"bg-current"}`}),s.jsxs("span",{className:"flex-1 text-left",children:[r?"连接质量":"Connection quality",c?` · ${m}`:""]}),s.jsx("span",{"aria-hidden":"true",children:c?"▾":"▸"})]}),c&&s.jsxs("div",{className:"pb-3 text-[11px] leading-relaxed",children:[!e&&s.jsx("p",{children:r?"请先打开一个终端会话,再查看连接质量。":"Open a terminal session to measure connection quality."}),s.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 tabular-nums",children:[s.jsx("dt",{children:r?"近期延迟":"Recent latency"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.minimum==null?"—":`${Math.round(n.minimum)}–${Math.round(n.maximum??n.minimum)} ms`}),s.jsx("dt",{children:r?"波动":"Jitter"}),s.jsx("dd",{className:"text-right text-foreground",children:x(n?.jitter)}),s.jsx("dt",{children:r?"探测超时":"Probe timeouts"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.samples?`${n.timeouts} / ${n.samples}`:"—"}),s.jsx("dt",{children:r?"连接路径":"Connection route"}),s.jsx("dd",{className:"text-right text-foreground break-words",children:d?`${d.path==="relay"?r?"经入口中转":"Via relay":r?"直连":"Direct"} · ${d.endpoint}`:"—"})]}),s.jsx("p",{className:"mt-2",children:r?"每 5 秒更新,统计最近 20 次;波动越小越稳定。":"Updates every 5s, using the last 20 probes. Lower jitter means more consistent latency."}),s.jsxs("details",{className:"mt-3 border-t border-border/30 pt-2",children:[s.jsx("summary",{className:"cursor-pointer py-1 hover:text-foreground",children:r?"诊断详情":"Diagnostics"}),s.jsx(F$,{quality:n})]})]})]})}const Ey={"startup-failure":"settings.serverHealthEventStartupFailure",crash:"settings.serverHealthEventCrash","crash-native":"settings.serverHealthEventCrashNative",killed:"settings.serverHealthEventKilled",wedge:"settings.serverHealthEventWedge","port-conflict":"settings.serverHealthEventPortConflict","gave-up":"settings.serverHealthEventGaveUp","exit-zero-unexpected":"settings.serverHealthEventExitZero","terminated-externally":"settings.serverHealthEventTerminated","supervisor-lost":"settings.serverHealthEventSupervisorLost","uncaught-exception":"settings.serverHealthEventUncaughtException","unhandled-rejection":"settings.serverHealthEventUnhandledRejection","exit-nonzero":"settings.serverHealthEventExitNonzero"};function U$(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function z$({state:e,onDismiss:t}){const{t:r}=Gr(),[n,a]=b.useState(!1),[c,l]=b.useState(!1),d=b.useRef(!1),f=b.useRef(!0);b.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(d.current=!1,a(!1),l(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const O=window.setTimeout(()=>{d.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(O)},[n]);const m=async()=>{if(!d.current){d.current=!0,l(!1),a(!0);try{await W9()}catch{if(!f.current)return;d.current=!1,a(!1),l(!0)}}};if(!e)return null;const x=e.incident,y=!e.supervised&&e.supervisor?.phase==="gave-up",w=!e.supervised&&e.supervisor!==null&&!e.supervisor.alive,v=y||w||e.attention,T=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",C=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):w?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),L=x?r(Ey[x.event]??"settings.serverHealthUnknownEvent"):"",N=x?.causeEvent?r(Ey[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",D=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:U$(x.uptimeMs)}):null,x.signal?`signal ${x.signal}`:null,x.exitCode!==null?`exit ${x.exitCode}`:null].filter(Boolean).join(" · "):"";return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"server-health-title",children:[s.jsx("div",{id:"server-health-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:r("settings.serverHealthTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-destructive/15 text-destructive":"bg-primary/15 text-primary"}`,children:v?s.jsx(BS,{size:15}):s.jsx(PS,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:C}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(T?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${L}${N?` · ${N}`:""}`:r("settings.serverHealthClean")}),x&&T&&s.jsx("div",{className:"mt-1 text-[11px] text-primary",children:r("settings.serverHealthRunningNow")}),x&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:D}),x?.detail&&s.jsx("div",{className:"mt-1 break-words text-[10px] text-muted-foreground/75",children:x.detail}),x?.oomSuspect&&s.jsx("div",{className:"mt-1 text-[10px] text-[color:var(--warning)]",children:r("settings.serverHealthOomNote")}),e.supervisor&&e.supervisor.restarts>0&&!y&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:r("settings.serverHealthRestarted",{count:e.supervisor.restarts})})]})]}),e.attention&&s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:r("settings.serverHealthDismiss")})]}),!e.supervised&&s.jsxs("div",{className:"border-t border-border px-3 py-3",children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:e.canEnableSupervision?r("settings.serverHealthEnableHint"):r("settings.serverHealthEnableUnavailable")}),e.canEnableSupervision&&s.jsx("button",{type:"button",onClick:m,disabled:n,className:"mt-2 min-h-11 rounded-lg bg-primary px-3 text-[12px] font-medium text-primary-foreground disabled:opacity-60",children:r(n?"settings.serverHealthEnabling":"settings.serverHealthEnable")}),n&&s.jsx("p",{role:"status",className:"mt-2 text-[11px] text-muted-foreground",children:r("settings.serverHealthEnablePending")}),c&&s.jsx("p",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:r("settings.serverHealthEnableError")})]})]})}const H$=()=>()=>{},W$=()=>1/0;function G$(){const{t:e}=Gr(),t=b.useId(),r=Ko(),n=b.useSyncExternalStore(r?.subscribe??H$,r?.retentionLimit??W$);if(!r)return null;const a=G9+1,c=n===1/0?e("settings.workspaceUnlimited"):String(n);return s.jsxs("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:t,className:"shrink-0 text-[12px] font-medium text-foreground/90",children:e("settings.workspaceLimit")}),s.jsx("input",{id:t,type:"range",min:3,max:a,step:1,value:n===1/0?a:n,"aria-valuetext":c,"aria-describedby":`${t}-hint`,onChange:l=>{const d=Number(l.target.value);r.setRetentionLimit(d===a?1/0:d)},className:"h-8 min-w-0 flex-1"}),s.jsx("output",{htmlFor:t,className:"min-w-12 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:c})]}),s.jsx("p",{id:`${t}-hint`,className:"text-[11px] leading-relaxed text-muted-foreground",children:e("settings.workspaceLimitHint")})]})}const eg="mobile-session-destroy";function V$(e,t){return t&&e.type==="session"&&e.destination?.droppableId===eg}const Oa="termdock-program-rules-cache",Xh="termdock-toolbar-presets-cache",l0="termdock-settings-cache",Ny="termdock-color-theme",Ry="termdock:right-sidebar:file-preview-open-by-session:v2",c0="termdock:running-session-button-enabled:v1",u0="termdock:attention-button-enabled:v1",q$=60,My=320,jy=420,Zo=8;function Dy(e,t,r){return Math.min(Math.max(e,t),r)}function By(e){if(typeof window>"u")return{left:Zo,top:Zo};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(Zo,window.innerWidth-My-Zo),l=Math.max(Zo,window.innerHeight-jy-Zo);return{left:Dy(n+Zo,Zo,c),top:Dy(a+Zo,Zo,l),width:My,maxHeight:`min(${jy}px, calc(100vh - ${Zo*2}px))`}}function Y$(e){return e==="dark"||e==="light"}function Z$(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,r])=>{if(!t||!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)})}function r1(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,q$);return Object.fromEntries(t)}function K$(e){return Array.isArray(e)&&e.every(t=>{if(!t||typeof t!="object")return!1;const r=t;return typeof r.id=="string"&&typeof r.pattern=="string"&&typeof r.output=="string"&&(r.matchType==="exact"||r.matchType==="includes"||r.matchType==="prefix"||r.matchType==="regex")})}function X$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function J$(e,t){const r=D0(),n=new Set(DE()),a=Array.isArray(e)?e:[],c=Vu(a),l=t<p0;if(c.length===0)return r;if(l){const f=new Map(c.map(w=>[w.id,w])),m=new Map(a.map(w=>[typeof w.id=="string"?w.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):"",w])),x=c.filter(w=>!n.has(w.id));return[...r.map(w=>{const v=f.get(w.id),T=m.get(w.id);return v?{...w,rowLayout:v.rowLayout,showOnDesktop:typeof T?.showOnDesktop=="boolean"?T.showOnDesktop:w.showOnDesktop}:w}),...x]}const d=new Set(c.map(f=>f.id));return[...c,...r.filter(f=>!d.has(f.id))]}function eU(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const tU={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},Ap="__termdockOverlay",Tp="__termdockBaseAnchor",Sp="__termdockBaseGuard",rU=3,Qy=250,nU="termdock-notification-target-v1",Py="/__termdock-notification-target",Oy=3e4;function sU(e){return e==="left-sidebar"||e==="right-sidebar"||e==="right-sidebar-repo-picker"||e==="right-sidebar-file-preview"||e==="settings"||e==="markdown-outline"||e==="markdown-image-lightbox"}function Qu(e){if(!e||typeof e!="object")return null;const t=e[Ap];return sU(t)?t:null}function ex(e){return e&&typeof e=="object"?{...e}:{}}function L4(e){const t=ex(e);return delete t[Ap],t}function iU(e){const t=L4(e);return delete t[Sp],{...t,[Tp]:!0}}function aU(){typeof window>"u"||window.history.pushState({...L4(window.history.state),[Tp]:!0,[Sp]:!0},"",window.location.href)}function I4(){for(let e=0;e<rU;e+=1)aU()}function Jh(){typeof window>"u"||(window.history.replaceState(iU(window.history.state),"",window.location.href),I4())}function d0(e){typeof window>"u"||window.history.pushState({...ex(window.history.state),[Tp]:!0,[Ap]:e,[Sp]:!1},"",window.location.href)}function oU(e){typeof window>"u"||window.history.replaceState({...ex(window.history.state),[Tp]:!0,[Ap]:e,[Sp]:!1},"",window.location.href)}const E4=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let Fa=new Set(E4);function Fy(e){const t=new Map;for(const[r,n]of e)t.set(r,{cwd:n.cwd,activeProgram:n.activeProgram,activeProgramRaw:n.activeProgramRaw,inCopyMode:n.inCopyMode,isConnecting:n.isConnecting,agentStatus:n.agentStatus,agentIndicator:n.agentIndicator,agentStatusDetail:n.agentStatusDetail,agent:n.agent,agentMessage:n.agentMessage,agentNativeSessionId:n.agentNativeSessionId,agentResumeRecovered:n.agentResumeRecovered,terminalSessionId:n.terminalSessionId,agentNeedsReview:n.agentNeedsReview,gitStatus:n.gitStatus,shellTitle:n.shellTitle,promptState:n.promptState,tuiProgress:n.tuiProgress});return t}function lU(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t){const a=e.get(r);if(!a||a.cwd!==n.cwd||a.activeProgram!==n.activeProgram||a.activeProgramRaw!==n.activeProgramRaw||a.inCopyMode!==n.inCopyMode||a.isConnecting!==n.isConnecting||a.agentStatus!==n.agentStatus||a.agentIndicator!==n.agentIndicator||a.agentStatusDetail!==n.agentStatusDetail||a.agent!==n.agent||a.agentMessage!==n.agentMessage||a.agentNativeSessionId!==n.agentNativeSessionId||a.agentResumeRecovered!==n.agentResumeRecovered||a.terminalSessionId!==n.terminalSessionId||a.agentNeedsReview!==n.agentNeedsReview||a.gitStatus!==n.gitStatus||a.shellTitle!==n.shellTitle||a.promptState!==n.promptState||a.tuiProgress?.state!==n.tuiProgress?.state||a.tuiProgress?.progress!==n.tuiProgress?.progress)return!1}return!0}function $y(e,t){return s.jsx(cO,{sessionMode:e,state:t})}function cU(e,t){const r=new Map(e.map(l=>[l.id,l])),n=t.map(l=>r.get(l)).filter(l=>l!==void 0),a=new Set(t),c=e.filter(l=>!a.has(l.id));return[...n,...c]}const uU=_.lazy(()=>Yc(()=>import("./CollaborationMainWorkspace-DkNhqCj4.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));async function N4(e,t){return cg(e,t)}function dU(){const{t:e,locale:t,setLocale:r}=Gr(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";V9();const c=_.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[l,d]=_.useState(!1),[f,m]=_.useState(()=>jc(Ny,Y$)??"dark"),x=_.useRef(jc(l0,eU)).current,[y,w]=_.useState(x?.preventSleep??!1),[v,T]=_.useState(x?.networkAvailable??!0),[C,L]=_.useState(q9),[N,D]=_.useState(Y9),[O,P]=_.useState(Z9),[F,ee]=_.useState(K9),[Z,G]=_.useState($p),[de,pe]=_.useState(x?.localAccess??tU),[J,Re]=_.useState(x?.localAccess?.name??""),[Ze,V]=_.useState(!1),[ve,qe]=_.useState(null),[le,ye]=_.useState(null),[Te,Fe]=_.useState(null),[se,De]=_.useState(!1),_e=b.useRef({busy:!1}),Me=b.useRef(0),Ke=b.useRef(Te?.latestVersion);Ke.current=Te?.latestVersion;const[Ne,ae]=b.useState(null);b.useEffect(()=>{const S=()=>{Me.current++};for(const Q of["pagehide","auth:unauthorized",zu])window.addEventListener(Q,S);return()=>{S();for(const Q of["pagehide","auth:unauthorized",zu])window.removeEventListener(Q,S)}},[]);const[ze,at]=_.useState(null),ct=_.useMemo(()=>na(),[]),me=!!(ct?.desktopUpdateState&&ct.checkDesktopUpdate&&ct.installDesktopUpdate),[ut,ft]=_.useState(null),[Se,He]=_.useState(null),[ke,z]=_.useState(!1),ie=b.useRef({busy:!1}),ge=b.useRef(Se);ge.current=Se;const[We,tt]=_.useState(null),[wt,Zt]=_.useState(!1),[Ut,Mt]=_.useState(()=>r1(jc(Ry,Z$)??{})),[nr,jt]=_.useState(0),[Xt,Bt]=_.useState(!1),[Ht,xe]=_.useState(0),[Je,ot]=_.useState(!1),[Nt,K]=_.useState(0),[xt,tr]=_.useState(!1),[$e,Qr]=_.useState(0),Ce=_.useRef(null),[St,Ot]=_.useState({}),{terminalSettings:Jt,updateTerminalSettings:lt}=hQ(),Ct=Jt.fontSize,ar=Jt.rendererMode,[_r,Nr]=_.useState(!1),zr=_.useRef(X9()).current,[Tt,Ft]=b.useState(()=>zr.sessions.map(S=>({id:S.sessionId,name:S.name,customName:S.customName,mode:S.mode,tmuxSessionName:S.tmuxSessionName}))),we=$i(S=>S.groupId);_.useEffect(()=>{const S=()=>$i.getState().terminal();return window.addEventListener("switch-terminal-session",S),()=>window.removeEventListener("switch-terminal-session",S)},[]);const[At,st]=_.useState(zr.activeSessionId),[bt,Tn]=_.useState(!1);_.useEffect(()=>{bt&&J9({rendered:!0})},[bt]);const[bn,nn]=_.useState(null),[Oe,_t]=_.useState(null),[gt,Wt]=_.useState([]),[$t,Ar]=b.useState(()=>{const S=Yr.getState();return zr.sessions.forEach(Q=>{Q.backendSessionId&&S.setTerminalSession(Q.sessionId,{sessionId:Q.backendSessionId,cols:80,rows:24,mode:Q.mode,tmuxSessionName:Q.tmuxSessionName}),Q.activeProgram!=null&&S.setSessionActiveProgram(Q.sessionId,Q.activeProgram),Q.cwd!=null&&S.setSessionCwd(Q.sessionId,Q.cwd),Q.shellTitle!=null&&S.setSessionShellTitle(Q.sessionId,Q.shellTitle)}),qu("session-chrome-hydrated"),Fy(Yr.getState().sessions)});b.useEffect(()=>{!ct||!_r||Promise.all([ct.snapshot(),ct.desktopUpdateState?.()??Promise.resolve(null)]).then(([S,Q])=>{ft(S),He(Q)}).catch(S=>tt(S instanceof Error?S.message:String(S)))},[ct,_r]),b.useEffect(()=>{ct?.onDesktopUpdateState&&ct.onDesktopUpdateState(He)},[ct]),b.useEffect(()=>Yr.subscribe(S=>{const Q=Fy(S.sessions);Ar(he=>lU(he,Q)?he:Q)}),[]);const Sn=b.useCallback(async(S,Q)=>{_t(null),nn({sessionId:S,status:"submitting",error:null});try{await eA(Q),nn(he=>he?.sessionId===S?{...he,status:"waiting",error:null}:he)}catch(he){const kt=(he&&typeof he=="object"&&"code"in he?String(he.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):he instanceof Error&&/busy/i.test(he.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");nn(Kt=>Kt?.sessionId===S?{...Kt,error:kt}:Kt),_t({tone:"error",message:kt})}},[e]);b.useEffect(()=>{if(!bn||bn.status!=="waiting")return;const S=$t.get(bn.sessionId);if(!S||S.agentResumeRecovered||S.agentStatus===null&&!S.agent)return;const Q=S.agent?.displayName??"Agent";nn(null),_t({tone:"success",message:e("tab.resumeAgentSuccess",{agent:Q})})},[bn,$t,e]),b.useEffect(()=>{if(!bn||bn.status!=="waiting"||bn.error)return;const S=bn.sessionId,Q=window.setTimeout(()=>{const he=e("tab.resumeAgentTimeout");nn(it=>it?.sessionId===S&&it.status==="waiting"?{...it,error:he}:it),_t({tone:"error",message:he})},15e3);return()=>window.clearTimeout(Q)},[bn,e]),b.useEffect(()=>{if(Oe?.tone!=="success")return;const S=window.setTimeout(()=>_t(null),3200);return()=>window.clearTimeout(S)},[Oe]),b.useEffect(()=>{let S=!1;tA().then(he=>{S||Fe(he)}).catch(()=>{}),rA().then(he=>{S||at(he)}).catch(()=>{});const Q=Mx(he=>{S||(he.type==="update-state"?Fe(he.state):he.type==="server-health"&&at(he.state))});return()=>{S=!0,Q()}},[]);const Mn=b.useCallback(async()=>{try{at(await nA())}catch(S){l1(S instanceof Error?S.message:String(S))}},[]),vn=b.useCallback(async()=>{const S=Te?.latestVersion;if(!S||se)return;const Q=Me.current,he=ea(),it=Sl(),kt=()=>Q===Me.current&&he===ea()&&it===Sl()&&!it?.closed&&Ke.current===S,Kt=ct?.confirmationUI==="page-v1"&&typeof ct.confirm=="function";ae(null),await N4(_e.current,{current:kt,submit:_A,apply:Fe,pending:De,expiredMessage:t==="zh"?"连接已变化,请重新确认。":"Connection changed. Please confirm again.",confirm:()=>Kt?ct.confirm({title:e("sidebar.updateRestart"),message:e("sidebar.updateRestartConfirm",{version:S}),confirmLabel:e("sidebar.updateRestart"),cancelLabel:e("common.cancel")}):window.confirm(e("sidebar.updateRestartConfirm",{version:S})),failure:Dr=>{Kt?ae(Dr):window.alert(Dr)}})},[Te?.latestVersion,e,se,ct,t]),dn=b.useCallback(async()=>{if(!se){De(!0);try{Fe(await sA())}catch(S){l1(S instanceof Error?S.message:String(S))}finally{De(!1)}}},[se]),kn=b.useCallback(async()=>{if(!(!ct?.checkDesktopUpdate||ke)){z(!0);try{He(await ct.checkDesktopUpdate())}catch(S){tt(S instanceof Error?S.message:String(S))}finally{z(!1)}}},[ct,ke]),Hr=b.useCallback(async()=>{const S=Se;if(!ct?.installDesktopUpdate||ke||S?.status!=="ready")return;const Q=Me.current,he=ea(),it=Sl(),kt=()=>Q===Me.current&&S===ge.current&&S.status==="ready"&&he===ea()&&it===Sl()&&!it?.closed;await cg(ie.current,{current:kt,confirm:()=>y3({title:e("settings.desktopUpdateRestartConfirm"),message:e("settings.desktopUpdateRestartConfirm"),confirmLabel:e("sidebar.updateRestart"),cancelLabel:e("common.cancel")}),submit:async()=>{if(!kt())throw new Error("Desktop update context changed");return ct.installDesktopUpdate()},apply:He,pending:z,failure:tt,expiredMessage:t==="zh"?"连接已变化,请重新确认。":"Connection changed. Please confirm again."})},[ct,ke,Se,e,t]);b.useEffect(()=>{document.documentElement.dataset.theme=f,iA(f),qn(Ny,f)},[f]),b.useEffect(()=>{qn(Ry,r1(Ut))},[Ut]);const ne=Vt(S=>S.leftOpen),Xe=Vt(S=>S.rightOpen),Dt=Vt(S=>S.leftPinned),ur=Vt(S=>S.leftSidebarWidth),Fr=Vt(S=>S.rightPinned),Zr=Vt(S=>S.rightSidebarWidth),an=Vt(S=>S.rootPath),Mr=Vt(S=>S.contextKey),Vr=Vt(S=>S.selectedFilePath),Ln=Vt(S=>S.groupByFolder),tn=If(S=>S.collaborationGroups),Ur=Vt(S=>S.collapsedGroups),Xr=Vt(S=>S.toggleGroupCollapsed),[vr,on]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Jr,hn]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[jr,zn]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[mn,qr]=b.useState([]),[Wr,Y]=b.useState({available:!0,version:null,reason:null}),[Be,Qt]=b.useState(!1),[er,sr]=b.useState(null),[$r,Ir]=b.useState(null),[Zn,ys]=b.useState(null),[is,Hn]=b.useState(null),[fn,Bn]=b.useState(null),[Xn,pn]=b.useState(null),[lr,as]=b.useState(null),[,rn]=b.useState(0),[gr,wr]=b.useState(null),[xr,ds]=b.useState(null),[jn,vs]=b.useState(null),[Qs,Is]=b.useState(!1),[Or,br]=b.useState(()=>jc(c0,S=>typeof S=="boolean")??!1),Qn=b.useCallback(async S=>{const Q=Or;br(S),qn(c0,S);try{const he=await Ua({runningSessionButtonEnabled:S});br(he.runningSessionButtonEnabled),qn(c0,he.runningSessionButtonEnabled)}catch{br(Q),qn(c0,Q)}},[Or]),[Jn,es]=b.useState(()=>jc(u0,S=>typeof S=="boolean")??!0),ui=b.useCallback(async S=>{const Q=Jn;es(S),qn(u0,S);try{const he=await Ua({attentionButtonEnabled:S});es(he.attentionButtonEnabled),qn(u0,he.attentionButtonEnabled)}catch{es(Q),qn(u0,Q)}},[Jn]),[W,Ie]=b.useState(null),Ye=b.useCallback(S=>{Ie(S)},[]),rt=b.useRef(!1),[nt,yt]=b.useState(null),Pt=_.useRef(null),H=b.useCallback(S=>{const Q=Tt.find(he=>he.id===S);Q&&(Pt.current={id:S,target:ea(),client:Sl(),backend:Yr.getState().sessions.get(S)?.terminalSessionId??null,mode:Q.mode,tmux:Q.tmuxSessionName},yt(S))},[Tt]),ue=b.useCallback(()=>{const S=Pt.current,Q=S&&Tt.find(he=>he.id===S.id);return!!S&&!S.client?.closed&&bQ(S,Q?{id:Q.id,target:ea(),client:Sl(),backend:Yr.getState().sessions.get(Q.id)?.terminalSessionId??null,mode:Q.mode,tmux:Q.tmuxSessionName}:null)},[Tt]),[R,U]=b.useState(null),X=_.useRef(null),be=_.useRef(!1),Ee=_.useRef(null),Ve=_.useRef(!1),dt=b.useCallback(()=>{pn(null),as(null)},[]),Qe=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[ir,rr]=_.useState(Qe.current),[Et,kr]=_.useState(!0),ln=_.useRef(Qe.current),yn=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(min-width: 1024px)"),Q=()=>{on(S.matches),hn(window.innerWidth)};return Q(),S.addEventListener("change",Q),window.addEventListener("resize",Q),()=>{S.removeEventListener("change",Q),window.removeEventListener("resize",Q)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(orientation: landscape)"),Q=()=>zn(S.matches);return Q(),S.addEventListener("change",Q),()=>S.removeEventListener("change",Q)},[]);const en=_.useMemo(()=>At?gt.find(S=>S.sessionIds.includes(At))??null:null,[At,gt]),gn=en?.id??null,dr=en?.sessionIds[0]??At,pr=_.useRef([]);_.useLayoutEffect(()=>{const S=pr.current;if(pr.current=gt,S.length===0)return;const Q=new Set(gt.flatMap(he=>he.sessionIds));for(const he of S){const it=he.sessionIds.filter(kt=>!Q.has(kt)).map(kt=>({sessionId:kt,rootPath:Yr.getState().sessions.get(kt)?.cwd??null}));it.length>0&&Vt.getState().inheritRightSidebarStateFromSplitWorkspace(he.id,it)}},[gt]),_.useLayoutEffect(()=>((()=>{const Q=dr?Yr.getState().sessions.get(dr)?.cwd??null:null;Vt.getState().setRootPath(Q,dr,gn)})(),Yr.subscribe((Q,he)=>{const it=dr?Q.sessions.get(dr)?.cwd??null:null,kt=dr?he.sessions.get(dr)?.cwd??null:null;it!==kt&&Vt.getState().setRootPath(it,dr,gn)})),[gn,dr]);const fs=_.useRef(T3(window.location.search)??bC(ea()?.targetPeerId)),[ws,_s]=_.useState("");_.useEffect(()=>{const S=fs.current;if(!S)return;if(S.peerId&&S.peerId!==ea()?.targetPeerId){const it=aA().find(kt=>kt.targetPeerId===S.peerId);if(it&&Ko()){try{xC(S)}catch{_s(t==="zh"?"无法在此浏览器打开架构链接。":"Cannot open this architecture link in this browser.");return}if(oA(it)){fs.current=null;const kt=new URL(window.location.href);kt.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",kt);return}}_s(t==="zh"?`此架构属于 ${S.serviceName??S.peerId}。请先连接该 Termdock 服务,再打开链接。`:`This architecture belongs to ${S.serviceName??S.peerId}. Connect to that Termdock service, then open this link.`);return}_s("");try{sessionStorage.setItem(`termdock.architecture.selection:${S.root}`,S.file)}catch{}const Q=Vt.getState();Q.setRootPath(S.root,dr,gn),Q.setRightTab("architecture"),Q.openRight();const he=new URL(window.location.href);he.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",he),dr&&(fs.current=null)},[dr,gn,t]);const zi=vr||jr,Zl=Jr*.95,As=zi?Math.min(Math.max(Jr*.22,280),340):Math.min(Jr*.86,380),Es=At&&an?`${At}\0${an}`:"",di=!!(Es&&Vr&&Ut[Es]),Ca=b.useCallback(S=>{Es&&(S&&!Vt.getState().selectedFilePath||Mt(Q=>{if(!!Q[Es]===S)return Q;if(S)return r1({...Q,[Es]:{updatedAt:Date.now()}});const it={...Q};return delete it[Es],it}))},[Es]);b.useEffect(()=>{vQ(Es,Mr,Vr)&&Mt(S=>{if(!S[Es])return S;const Q={...S};return delete Q[Es],Q})},[Es,Mr,Vr]);const Wn=xt?"markdown-image-lightbox":Je?"markdown-outline":Xt?"right-sidebar-repo-picker":Xe&&di?"right-sidebar-file-preview":_r?"settings":Xe&&!(Fr&&vr)?"right-sidebar":ne&&!(Dt&&vr)?"left-sidebar":null,os=_.useRef(Wn),Ns=_.useRef(Wn),no=_.useRef(!1),Hs=_.useRef(!1),_l=b.useCallback(()=>{if(typeof window>"u")return;const S=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!vr||!S||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[vr]),za=b.useCallback(S=>{if(S==="markdown-image-lightbox"){tr(!1),Qr(Q=>Q+1);return}if(S==="markdown-outline"){ot(!1),K(Q=>Q+1);return}if(S==="right-sidebar-file-preview"){ot(!1),K(Q=>Q+1),Ca(!1),jt(Q=>Q+1);return}if(S==="right-sidebar-repo-picker"){Bt(!1),xe(Q=>Q+1);return}if(S==="settings"){Nr(!1),Gi(!1),Rs(!1),et(!1);return}if(S==="left-sidebar"){Vt.getState().closeLeft();return}ot(!1),K(Q=>Q+1),Bt(!1),xe(Q=>Q+1),tr(!1),Qr(Q=>Q+1),Vt.getState().closeRight()},[Ca]),Pn=b.useCallback(S=>{if(!c&&typeof window<"u"&&os.current===S&&Qu(window.history.state)===S){window.history.back();return}za(S)},[za,c]),Li=b.useCallback(()=>{Nr(!1);const S=Vt.getState();S.closeRight(),S.openLeft()},[]),Ha=b.useCallback(()=>{Nr(!1);const S=Vt.getState();S.closeLeft(),S.openRight()},[]),Mo=b.useCallback(()=>{Nr(!1);const S=Vt.getState();S.closeLeft(),S.openRight(),S.setRightTab("files"),S.openRightSearch()},[]),hi=b.useCallback(()=>{const S=Vt.getState();if(S.leftPinned){S.setLeftPinned(!1),S.closeLeft();return}if(ne){Pn("left-sidebar");return}Li()},[Li,Pn,ne]),On=b.useCallback(()=>{const S=Vt.getState();S.leftPinned?(S.setLeftPinned(!1),S.openLeft()):(S.setLeftPinned(!0),S.openLeft())},[]),Js=b.useCallback(()=>{const S=Vt.getState();S.setLeftPinned(!1),S.closeLeft()},[]),ls=b.useCallback(()=>{const S=Vt.getState();S.rightPinned?(S.setRightPinned(!1),S.openRight()):(S.setRightPinned(!0),S.openRight())},[]),Wa=b.useCallback(()=>{const S=Vt.getState();S.setRightPinned(!1),S.closeRight()},[]),ps=b.useRef(0),tl=b.useRef(0),ia=b.useRef(null),rl=b.useCallback(S=>{S.preventDefault(),ps.current=S.clientX,tl.current=Vt.getState().leftSidebarWidth;const Q=it=>{ia.current===null&&(ia.current=requestAnimationFrame(()=>{ia.current=null;const kt=it.clientX-ps.current;Vt.getState().setLeftSidebarWidth(tl.current+kt)}))},he=()=>{window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",he),ia.current!==null&&(cancelAnimationFrame(ia.current),ia.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",Q),window.addEventListener("mouseup",he)},[]),_a=b.useRef(0),jo=b.useRef(0),so=b.useRef(null),Do=b.useCallback(S=>{S.preventDefault(),_a.current=S.clientX;const Q=Vt.getState(),he=Q.leftPinned?Q.leftSidebarWidth:0;jo.current=tf(Q.rightSidebarWidth,window.innerWidth,he);const it=Kt=>{so.current===null&&(so.current=requestAnimationFrame(()=>{so.current=null;const Dr=_a.current-Kt.clientX,Nn=Vt.getState(),Gn=Nn.leftPinned?Nn.leftSidebarWidth:0;Nn.setRightSidebarWidth(tf(jo.current+Dr,window.innerWidth,Gn))}))},kt=()=>{window.removeEventListener("mousemove",it),window.removeEventListener("mouseup",kt),so.current!==null&&(cancelAnimationFrame(so.current),so.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",it),window.addEventListener("mouseup",kt)},[]),ka=b.useCallback(()=>{const S=Vt.getState();if(S.rightPinned){S.setRightPinned(!1),S.closeRight();return}if(Xe){Pn("right-sidebar");return}Ha()},[Ha,Pn,Xe]),Xl=b.useCallback(()=>{!di&&!c&&typeof window<"u"&&os.current==="right-sidebar"&&Qu(window.history.state)==="right-sidebar"&&(d0("right-sidebar-file-preview"),Ns.current="right-sidebar-file-preview"),Ca(!0)},[di,c,Ca]),fi=b.useCallback(()=>{Pn("right-sidebar-file-preview")},[Pn]),ei=b.useCallback(()=>{!Xt&&!c&&typeof window<"u"&&os.current==="right-sidebar"&&Qu(window.history.state)==="right-sidebar"&&(d0("right-sidebar-repo-picker"),Ns.current="right-sidebar-repo-picker"),Bt(!0)},[Xt,c]),pi=b.useCallback(()=>{Pn("right-sidebar-repo-picker")},[Pn]),nl=b.useCallback(()=>{!Je&&!c&&typeof window<"u"&&os.current&&Qu(window.history.state)===os.current&&(d0("markdown-outline"),Ns.current="markdown-outline"),ot(!0)},[Je,c]),aa=b.useCallback(()=>{Pn("markdown-outline")},[Pn]),ks=b.useCallback(()=>{!c&&typeof window<"u"&&os.current&&Qu(window.history.state)===os.current&&(d0("markdown-image-lightbox"),Ns.current="markdown-image-lightbox"),tr(!0)},[c]),Hi=b.useCallback(()=>{Pn("markdown-image-lightbox")},[Pn]),La=b.useCallback(()=>{!c&&typeof window<"u"&&os.current&&Qu(window.history.state)===os.current&&(oU("settings"),Ns.current="settings"),Vt.getState().closeAll(),Nr(!0)},[c]),Ia=b.useCallback(()=>{Pn("settings")},[Pn]);b.useEffect(()=>{if(!ct)return;const S=()=>La();return window.addEventListener("termdock:open-settings",S),()=>window.removeEventListener("termdock:open-settings",S)},[ct,La]);const mi=b.useCallback(()=>{Zt(!0),Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null)},[]),_c=b.useCallback(()=>{Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null),Zt(!1),Hs.current=!0,Jh(),Hs.current},[]);b.useEffect(()=>()=>{Ce.current!==null&&window.clearTimeout(Ce.current)},[]),b.useEffect(()=>{c||Jh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let S=null;const Q=()=>{S!==null&&(window.clearTimeout(S),S=null)},he=Nn=>{if(os.current,Hs.current,os.current){os.current;return}!Nn?.force&&Hs.current||(Nn?.userActivated&&(Hs.current=!0),Jh(),Hs.current,void 0)},it=()=>{Q(),S=window.setTimeout(()=>{S=null,he({force:!0})},Qy)},kt=()=>{he({userActivated:!0})},Kt=()=>{it()},Dr=()=>{document.visibilityState==="visible"&&it()};return window.addEventListener("pointerdown",kt,{capture:!0,passive:!0}),window.addEventListener("touchstart",kt,{capture:!0,passive:!0}),window.addEventListener("keydown",kt,{capture:!0}),window.addEventListener("pageshow",Kt),document.addEventListener("visibilitychange",Dr),()=>{Q(),window.removeEventListener("pointerdown",kt,{capture:!0}),window.removeEventListener("touchstart",kt,{capture:!0}),window.removeEventListener("keydown",kt,{capture:!0}),window.removeEventListener("pageshow",Kt),document.removeEventListener("visibilitychange",Dr)}},[c]),b.useEffect(()=>{os.current=Wn},[Wn]),b.useEffect(()=>{if(typeof window>"u"||Wn||c)return;const S=window.setTimeout(()=>{os.current?(os.current,void 0):Jh()},Qy);return()=>window.clearTimeout(S)},[Wn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=Ns.current;no.current,Wn&&Wn!==S&&!no.current&&d0(Wn),!Wn&&S&&_l(),Ns.current=Wn,!Wn&&no.current&&window.setTimeout(()=>{no.current=!1},0)},[Wn,c,_l]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=()=>{const Q=os.current;if(Hs.current,!Q){Hs.current=!1,Hs.current,mi(),I4();return}no.current=!0,za(Q)};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[za,mi,c]),b.useEffect(()=>{const S=Q=>{const he=Q.metaKey||Q.ctrlKey;if(he&&Q.key==="b"&&!Q.shiftKey&&(Q.preventDefault(),hi()),he&&Q.shiftKey&&Q.key==="E"&&(Q.preventDefault(),ka()),he&&Q.shiftKey&&Q.key==="P"&&(Q.preventDefault(),Mo()),he&&!Q.shiftKey&&Q.altKey&&(Q.key==="ArrowLeft"||Q.key==="ArrowRight")){Q.preventDefault();const it=Q.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:it}}));return}if(he&&Q.shiftKey&&!Q.altKey&&(Q.code==="BracketLeft"||Q.code==="BracketRight")){Q.preventDefault();const it=Q.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:it}}));return}};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[hi,ka,Mo]);const kc=b.useCallback(async()=>{V(!0),qe(null);try{const S=await Ua({localAccess:{name:J}});pe(S.localAccess),Re(S.localAccess.name),qn(l0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){qe(S instanceof Error?S.message:"Failed to save local access name")}finally{V(!1)}},[J]),Jl=b.useCallback(async()=>{V(!0),qe(null);try{const S=await Ua({localAccess:{reset:!0}});pe(S.localAccess),Re(S.localAccess.name),qn(l0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){qe(S instanceof Error?S.message:"Failed to reset local access name")}finally{V(!1)}},[]),Ws=b.useCallback(async(S,Q="url")=>{if(S)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(S);else{const he=document.createElement("textarea");he.value=S,he.style.position="fixed",he.style.left="-9999px",document.body.appendChild(he),he.focus(),he.select(),document.execCommand("copy"),document.body.removeChild(he)}ye(Q),window.setTimeout(()=>ye(he=>he===Q?null:he),1600)}catch{ye(null)}},[]),ti=b.useCallback(S=>{const Q=cU(Tt,S);Q.map(he=>he.id).join("\0")!==Tt.map(he=>he.id).join("\0")&&(Ft(Q),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:Q.map(he=>he.id)}})))},[Tt]),Wi=b.useCallback(S=>{vr||S.type!=="session"||(rt.current=!1,Is(!1),vs(S.draggableId))},[vr]),Ea=b.useCallback(S=>{if(vr||S.type!=="session")return;const Q=S.destination?.droppableId===eg;Q!==rt.current&&(rt.current=Q,Is(Q),Q&&navigator.vibrate?.(20))},[vr]),oa=b.useCallback(S=>{const Q=V$(S,!vr);if(rt.current=!1,Is(!1),vs(null),!Q)return!1;const he=Tt.find(kt=>kt.id===S.draggableId),it=he?$t.get(he.id):null;return he&&ab({mode:he.mode,activeProgram:it?.activeProgram??null,promptState:it?.promptState??null,shellNames:Fa})?(U(null),H(he.id),ys(null)):he&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:he.id,source:"other",closeMode:he.mode==="tmux"?"destroy":"auto"}})),!0},[vr,Tt,$t,H]),{groups:Bo,arranged:Ts}=_.useMemo(()=>kf(Tt,S=>$t.get(S.id)?.cwd??null,Ln,e("sidebar.ungrouped"),gt,tn),[Tt,$t,Ln,e,gt,tn]),Na=b.useCallback(S=>{oa(S)||!S.destination||S.source.index===S.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:Ts[S.source.index]?.id,targetId:Ts[S.destination.index]?.id}}))},[oa,Ts]),cs=b.useCallback((S,Q)=>{const he=Q.trim();he&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:S,name:he}}))},[]),ts=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:S}}))},[]),{newSessionMode:Ss,newSessionTmuxName:ri,userSelectedNewSessionMode:Qo,setNewSessionMode:Ga}=mQ(),[la,Ii]=b.useState(null),[io,Gi]=_.useState(!1),[Ra,Vi]=_.useState(!1),[ca,Rs]=_.useState(!1),[Ei,ao]=_.useState("idle"),Ma=_.useRef(jc(Xh,X$)).current,[Ni,oo]=_.useState(()=>{const S=Ma?.presets;if(S&&S.length>0){const Q=Vu(S);if(Q.length>0)return Q}return D0()}),[ec,kl]=_.useState(!1),[Po,ce]=_.useState("default"),Ge=_.useRef(typeof Ma?.updatedAt=="number"?Ma.updatedAt:null),vt=_.useRef(!1),[Lt,et]=_.useState(!1),[Rt,cr]=_.useState(!1),Lr=_.useRef(jc(Oa,K$)).current,[I,B]=_.useState(Lr??[]),[$,q]=_.useState(Lr!==null),[Pe,Le]=_.useState(!1),mt=!we&&!Wn&&!Ra&&!ca&&!io&&!Lt&&!Rt&&!Xn&&!nt&&!la,ht=_.useCallback(S=>{const Q=typeof S.version=="number"?S.version:0,he=J$(Array.isArray(S.presets)?S.presets:[],Q);Ge.current=typeof S.updatedAt=="number"?S.updatedAt:null,oo(it=>lA(it,he)?it:(vt.current=!0,he)),qn(Xh,{version:p0,presets:he,updatedAt:Ge.current??void 0})},[]);b.useEffect(()=>{const S=Q=>{if(Q.key!=="Escape"||Q.defaultPrevented||Q.isComposing||ng())return;if(Ra){Q.preventDefault(),Vi(!1);return}if(ca){Q.preventDefault(),Rs(!1);return}if(io){Q.preventDefault(),Gi(!1);return}if(Lt){Q.preventDefault(),et(!1);return}if(Rt){Q.preventDefault(),cr(!1);return}if(Xn){Q.preventDefault(),dt();return}if(gr){Q.preventDefault(),Bn(null),wr(null);return}if(_r){Q.preventDefault(),Ia();return}if(Xe&&!(Fr&&vr)){Q.preventDefault(),Pn("right-sidebar");return}ne&&!(Dt&&vr)&&(Q.preventDefault(),Pn("left-sidebar"))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[Ra,ca,io,Lt,Xn,dt,_r,Xe,Fr,ne,Dt,vr,Ia,Pn]),b.useEffect(()=>{q(!0)},[]);const[It,yr]=_.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:E4}),[,xn]=_.useState(!1),Cn=_.useCallback(()=>cA().then(S=>{yr(S),Fa=new Set(S.shellNames),xn(!0)}).catch(()=>{}),[]);b.useEffect(()=>{Cn()},[Cn]),b.useEffect(()=>Mx(S=>{if(S.type==="config-updated"){if(S.key==="toolbar-presets"){jx().then(Q=>ht(Q)).catch(Q=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",Q)});return}S.key==="program-detection"&&Cn()}}),[ht,Cn]),b.useEffect(()=>{let S=!1;return(async()=>{try{const Q=await jx();if(S)return;ht(Q)}catch(Q){console.warn("[toolbar-presets] Failed to load from server:",Q)}finally{S||kl(!0)}})(),()=>{S=!0}},[ht]),b.useEffect(()=>{if(ec){if(vt.current){vt.current=!1;return}qn(Xh,{version:p0,presets:Ni,updatedAt:Ge.current??void 0}),uA({version:p0,presets:Ni,baseUpdatedAt:Ge.current??void 0}).then(S=>{Ge.current=typeof S.updatedAt=="number"?S.updatedAt:null,qn(Xh,{version:p0,presets:Ni,updatedAt:Ge.current??void 0})}).catch(S=>{const Q=S instanceof Error&&"current"in S?S.current:null;Q&&typeof Q=="object"&&ht(Q),console.warn("[toolbar-presets] Failed to save to server:",S)})}},[ht,Ni,ec]),b.useEffect(()=>{Cc().then(S=>{w(Q=>Q===S.preventSleep?Q:S.preventSleep),T(Q=>Q===S.networkAvailable?Q:S.networkAvailable),pe(S.localAccess),Re(S.localAccess.name),br(S.runningSessionButtonEnabled),qn(c0,S.runningSessionButtonEnabled),es(S.attentionButtonEnabled),qn(u0,S.attentionButtonEnabled),qn(l0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!C)return;const S=$p();G(S),S!=="granted"&&(L(!1),bh(!1))},[C]),b.useEffect(()=>{if(!C)return;Id();const S=()=>{document.visibilityState==="visible"&&(Id(),TA())},Q=window.setInterval(()=>{Id()},360*60*1e3);return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{window.clearInterval(Q),document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[C]);const Fn=b.useCallback(async()=>{if(C){L(!1),bh(!1),dA(),G($p());return}const S=await hA();if(G(S),S!=="granted"){L(!1),bh(!1);return}L(!0),bh(!0),await Id(!0,!0),ao("idle")},[C]),ms=b.useCallback(async()=>{ao("checking"),await na()?.prepareNotificationTest?.();const S=await fA({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});ao(S?"delivered":"failed")},[e]),Ri=b.useCallback(S=>{D(S),pA(S),Up()},[]),Kr=b.useCallback(S=>{P(S),mA(S),Up()},[]),wn=b.useCallback(S=>{ee(S),gA(S),Up()},[]);b.useEffect(()=>{Ni.some(S=>S.id===Po)||ce(Ni[0]?.id??"default")},[Po,Ni]),b.useEffect(()=>{if(!Wr.available&&Ss==="tmux"){Ga("shell",{userInitiated:!1});return}Wr.available&&Qo!=="shell"&&Ss!=="tmux"&&Ga("tmux",{userInitiated:!1})},[Ss,Wr.available,Qo,Ga]),b.useEffect(()=>{Ii(null)},[_r,Ss,Wr.available]),b.useEffect(()=>{const S={};typeof navigator<"u"&&(S.userAgent=navigator.userAgent,S.platform=navigator.platform,S.maxTouchPoints=navigator.maxTouchPoints,S.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,S.vendor=navigator.vendor),typeof window<"u"&&(S.screenWidth=window.innerWidth,S.screenHeight=window.innerHeight,S.pixelRatio=window.devicePixelRatio,S.orientation=window.screen?.orientation?.type||"unknown",S.hasVisualViewport=!!window.visualViewport,S.visualViewportHeight=window.visualViewport?.height,S.visualViewportWidth=window.visualViewport?.width,S.location=window.location.href),S.timestamp=new Date().toISOString(),S.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,S.isAndroid=/Android/.test(navigator.userAgent),Ot(S)},[]);const Ps=b.useCallback(S=>{if(oa(S)||!S.destination)return;if(S.type==="group"){if(S.source.index===S.destination.index)return;ti(b3(Bo,S.source.index,S.destination.index));return}if(S.source.droppableId!==S.destination.droppableId||S.source.index===S.destination.index)return;const Q=S.source.droppableId.replace(/^group-sessions:/,""),he=Bo.find(it=>it.key===Q);he&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:he.sessions[S.source.index]?.id,targetId:he.sessions[S.destination.index]?.id}}))},[Bo,ti,oa]),Os=_.useMemo(()=>Ts.flatMap(S=>{const Q=$t.get(S.id);if(Q?.agentStatus!=="working")return[];const{primary:he,secondary:it}=yl(S,Q?.activeProgram??null,Q?.cwd??null,Fa,Q?.shellTitle??null,Q?.promptState??null);return[{id:S.id,label:he,detail:it}]}),[Ts,$t]),Ll=At?Ts.findIndex(S=>S.id===At):-1,ni=Ts.length>0&&Ll>=0?`${Ll+1}/${Ts.length}`:`${Ts.length}`,qi=_.useMemo(()=>{let S=0;for(const Q of Tt){const he=$t.get(Q.id);(he?.agentStatus==="waiting"||he?.agentNeedsReview)&&(S+=1)}return{running:Os.length,review:S}},[Os.length,Tt,$t]),Oo=_.useMemo(()=>Ts.flatMap(S=>{const Q=$t.get(S.id);if(Q?.agentStatus!=="waiting"&&!Q?.agentNeedsReview)return[];const{primary:he}=yl(S,Q.activeProgram,Q.cwd,Fa,Q.shellTitle,Q.promptState);return[{id:Q.terminalSessionId??S.id,label:he,waiting:Q.agentStatus==="waiting"}]}),[Ts,$t]);xA(qi.running,qi.review,Oo);const Mi=At?Tt.find(S=>S.id===At)??null:null,sl=Mi?$t.get(Mi.id):void 0,hu=!!(Mi&&sl?.agentResumeRecovered&&sl.agentNativeSessionId&&sl.terminalSessionId),Yi=Mi&&bn?.sessionId===Mi.id?bn:null;_.useLayoutEffect(()=>{if(!Et)return;const S=Ee.current;if(!S)return;const Q=!Ve.current;S.scrollIntoView({inline:"nearest",block:"nearest",behavior:Q?"auto":"smooth"}),Ve.current=!0,Q&&qu("active-tab-positioned")},[At,Et]),b.useEffect(()=>{fn&&X.current&&(X.current.scrollIntoView({block:"nearest",inline:"nearest"}),X.current.focus(),X.current.select()),fn||(be.current=!1)},[fn]);const th=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:S}))},[]),bd=b.useCallback((S,Q)=>{as(Q??null),pn(S)},[]),Cp=qg(),lo=b.useCallback(S=>{if(!S)return;rr(S),yn.current&&$a("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:yn.current,requestedSessionId:S,activeSessionId:At,sessions:Tt.map(he=>({id:he.id,terminalSessionId:$t.get(he.id)?.terminalSessionId??null}))}),bA(S);const Q=Tt.find(he=>he.id===S||$t.get(he.id)?.terminalSessionId===S);Q?(ln.current=null,yn.current&&$a("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:yn.current,requestedSessionId:S,targetSessionId:Q.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Q.id}))):(ln.current=S,yn.current&&$a("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:yn.current,requestedSessionId:S}))},[At,Tt,$t]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let S=!1;const Q=async()=>{if(window.parent!==window&&Ko()){kr(!0);return}try{const it=await caches.open(nU),kt=await it.match(Py);if(!kt)return;await it.delete(Py);const Kt=await kt.json();if(S)return;const Dr=typeof Kt.sessionId=="string"?Kt.sessionId:null,Nn=typeof Kt.traceId=="string"?Kt.traceId:null,Gn=typeof Kt.clickedAt=="number"?Kt.clickedAt:0,$n=Date.now()-Gn;$a("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:Nn,sessionId:Dr,ageMs:$n,valid:!!(Dr&&$n>=0&&$n<=Oy),visibilityState:document.visibilityState}),Dr&&$n>=0&&$n<=Oy&&(yn.current=Nn,typeof Kt.targetPeerId=="string"&&Kt.targetPeerId!==ea()?.targetPeerId?Ko()?.focusSession(Kt.targetPeerId,Dr):lo(Dr))}catch(it){$a("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:it instanceof Error?it.message:String(it)})}finally{S||kr(!0)}},he=()=>{document.visibilityState==="visible"&&Q()};return Q(),document.addEventListener("visibilitychange",he),window.addEventListener("pageshow",Q),()=>{S=!0,document.removeEventListener("visibilitychange",he),window.removeEventListener("pageshow",Q)}},[lo]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search),Q=S.get("session");if(!Q)return;$a("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:yn.current,targetSessionId:Q,href:window.location.href,visibilityState:document.visibilityState});const he=S.get("service");he&&he!==ea()?.targetPeerId?Ko()?.focusSession(he,Q):ln.current=Q,S.delete("service"),S.delete("session"),S.delete("_notifTrace");const it=S.toString(),kt=`${window.location.pathname}${it?`?${it}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",kt)},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search);if(S.get("_notif")!=="1")return;const Q=S.get("session");S.delete("_notif");const he=S.toString(),it=`${window.location.pathname}${he?`?${he}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",it),window.parent!==window&&Ko())return;const kt=new BroadcastChannel("termdock:notif");let Kt=!1;const Dr=Gn=>{Gn.data?.type==="termdock:notif-pong"&&!Kt&&(Kt=!0,kt.close(),window.close())};kt.addEventListener("message",Dr),kt.postMessage({type:"termdock:notif-ping",sessionId:Q,targetPeerId:S.get("service")});const Nn=setTimeout(()=>{Kt||kt.close()},500);return()=>{clearTimeout(Nn),Kt||kt.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&Ko())return;const S=new BroadcastChannel("termdock:notif"),Q=he=>{he.data?.type==="termdock:notif-ping"&&(S.postMessage({type:"termdock:notif-pong"}),typeof he.data.sessionId=="string"&&(typeof he.data.targetPeerId=="string"&&he.data.targetPeerId!==ea()?.targetPeerId?Ko()?.focusSession(he.data.targetPeerId,he.data.sessionId):lo(he.data.sessionId)))};return S.addEventListener("message",Q),()=>S.close()},[lo]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const S=Q=>{const he=Q.data;if(he&&he.type==="termdock:focus-session"&&typeof he.sessionId=="string"){if(typeof he.targetPeerId=="string"&&he.targetPeerId!==ea()?.targetPeerId){Ko()?.focusSession(he.targetPeerId,he.sessionId)&&Q.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}Q.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),lo(he.sessionId)}else he?.type==="termdock:push-subscription-changed"?Id(!0):he?.type};return navigator.serviceWorker.addEventListener("message",S),()=>navigator.serviceWorker.removeEventListener("message",S)},[lo]),b.useEffect(()=>{const S=Q=>{const he=Q.detail;typeof he=="string"&&lo(he)};return window.addEventListener("termdock:focus-session",S),()=>window.removeEventListener("termdock:focus-session",S)},[lo]),b.useEffect(()=>{const S=()=>{const Q=SA(ea()?.targetPeerId);Q&&lo(Q)};return S(),window.addEventListener("termdock:workspace-session",S),()=>window.removeEventListener("termdock:workspace-session",S)},[lo]),b.useEffect(()=>{const S=ln.current;if(!S)return;const Q=Tt.find(he=>he.id===S||$t.get(he.id)?.terminalSessionId===S);Q?(ln.current=null,yn.current&&$a("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:yn.current,requestedSessionId:S,targetSessionId:Q.id,activeSessionId:At}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Q.id}))):yn.current&&$a("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:yn.current,requestedSessionId:S,activeSessionId:At,sessions:Tt.map(he=>({id:he.id,terminalSessionId:$t.get(he.id)?.terminalSessionId??null}))})},[At,Tt,$t]);const ua=_.useMemo(()=>{const S=[];for(const Q of Tt){const he=$t.get(Q.id);(he?.agentStatus==="waiting"||he?.agentNeedsReview)&&S.push(Q.id)}return S},[Tt,$t]),Il=b.useCallback(()=>{if(ua.length===0)return;At&&Yr.getState().clearAgentNeedsReview(At);const S=At?Tt.findIndex(he=>he.id===At):-1,Q=ua.find(he=>Tt.findIndex(it=>it.id===he)>S)??ua[0];Q&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Q}))},[ua,Tt,At]),Lc=b.useCallback(()=>{if(ua.length===0)return;At&&Yr.getState().clearAgentNeedsReview(At);const S=At?Tt.findIndex(he=>he.id===At):Tt.length,Q=[...ua].reverse().find(he=>Tt.findIndex(it=>it.id===he)<S)??ua[ua.length-1];Q&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Q}))},[ua,Tt,At]);b.useEffect(()=>{const S=Q=>{!Q.altKey||!Q.shiftKey||Q.metaKey||Q.ctrlKey||Q.key!=="ArrowUp"&&Q.key!=="ArrowDown"||(Q.preventDefault(),Q.key==="ArrowUp"?Lc():Il())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[Il,Lc]);const fu=b.useCallback(async S=>{const he=Yr.getState().sessions.get(S)?.cwd;if(he)try{await navigator.clipboard?.writeText(he),ds(he),window.setTimeout(()=>{ds(it=>it===he?null:it)},1400)}catch{}},[]),_p=b.useCallback(S=>{Ft(S.sessions),st(S.activeSessionId),Wt(S.splitWorkspaces),Yr.getState().setActiveSessionId(S.activeSessionId)},[]),yd=b.useCallback(()=>{Tn(!0)},[]),rh=b.useCallback(()=>{Tn(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!ir||!At)return;Tt.find(Q=>Q.id===ir||$t.get(Q.id)?.terminalSessionId===ir)?.id===At&&rr(null)},[At,ir,Tt,$t]);const vd=b.useRef(!1),[pu,nh]=b.useState(!1),co=b.useCallback(S=>{const Q=!S?.onResult;if(Q&&vd.current)return;Q&&(vd.current=!0,nh(!0));const he=S?.mode??Ss,it=he==="tmux"&&(S?.tmuxSessionName?.trim()||ri.trim())||void 0,kt=S?.cwd||(At?Yr.getState().sessions.get(At)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:he,tmuxSessionName:it,cwd:kt,command:S?.command,shouldActivate:S?.shouldActivate,onResult:S?.onResult??(Kt=>{vd.current=!1,nh(!1),Kt.ok||_t({tone:"error",message:e(c1(Kt.error))})})}}))},[Ss,ri,At,e]),El=b.useCallback(async()=>{Qt(!0);try{const S=await n1();if(Y(S),!S.available){qr([]);return}const Q=await s1();qr(Q)}catch{Y({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),qr([])}finally{Qt(!1)}},[]),mu=b.useCallback(async S=>{const{cleanedSessions:Q}=await qy(S);for(const he of Q)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:he}));await El()},[El]),sh=b.useCallback(async S=>{Ir(S),ys(null);try{await mu(S),sr(null)}catch(Q){ys(Q instanceof Error?Q.message:"Failed to kill tmux session")}finally{Ir(null)}},[mu]);b.useEffect(()=>{if(!is)return;if(mn.find(he=>he.name===is&&(he.connected||he.boundFrontendSessionId))){Hn(null);return}const Q=setTimeout(()=>Hn(null),1e4);return()=>clearTimeout(Q)},[is,mn]);const il=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:S}))},[]),Ic=b.useCallback(S=>{const Q=S??At;Q&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:Q}))},[At]),wd=b.useCallback((S,Q)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:S,layout:Q}}))},[]),al=b.useCallback((S,Q)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:S,sessionIds:Q}}))},[]),Ad=b.useCallback((S,Q)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:S,name:Q}}))},[]),gu=b.useCallback((S,Q)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:S,secondaryId:Q}}))},[]),tc=b.useCallback((S,Q,he)=>{const it=Tt.find(Kt=>Kt.id===S);if(!it)return;const kt=$t.get(S);if(he?.skipConfirmation||!ab({mode:it.mode,activeProgram:kt?.activeProgram??null,promptState:kt?.promptState??null,shellNames:Fa})){il({sessionId:S,source:"sidebar",closeMode:it.mode==="tmux"?"destroy":"auto"});return}U(Q?{x:Q.clientX,y:Q.clientY}:null),H(S),ys(null)},[Tt,$t,il,H]);b.useEffect(()=>{if(!ct)return;const S=Q=>{const he=Q.detail;he==="new-session"?co():he==="close-session"?At&&!nt&&tc(At):he==="previous-session"||he==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:he==="next-session"?"next":"prev"}})):he==="toggle-left-sidebar"?hi():he==="toggle-right-sidebar"?ka():he==="previous-attention"?Lc():he==="next-attention"&&Il()};return window.addEventListener("termdock:native-command",S),()=>window.removeEventListener("termdock:native-command",S)},[At,nt,ct,co,tc,hi,ka,Il,Lc]);const Fo=_.useMemo(()=>Tt.find(S=>S.id===nt)??null,[Tt,nt]),Td=b.useCallback(()=>{if(!Fo||!ue()){yt(null),U(null);return}il({sessionId:Fo.id,source:"sidebar",closeMode:"destroy"}),yt(null),U(null)},[Fo,il,ue]),ih=_.useRef(null),xu=b.useCallback(()=>{yt(null),U(null),ys(null)},[]);_.useLayoutEffect(()=>{if(!nt)return;const S=()=>{ue()||xu()},Q=()=>xu();S();const he=Yr.subscribe(S);return window.addEventListener(zu,S),window.addEventListener("auth:unauthorized",Q),()=>{he(),window.removeEventListener(zu,S),window.removeEventListener("auth:unauthorized",Q)}},[nt,$t,ue,xu]);const kp=_.useMemo(()=>{if(!Fo)return"";const S=$t.get(Fo.id);return yl(Fo,S?.activeProgram??null,S?.cwd??null,Fa,S?.shellTitle??null,S?.promptState??null).primary},[Fo,$t]);b.useEffect(()=>{if(!_r)return;let S=!1,Q=!1;const he=async()=>{if(!Q)try{const kt=await n1();if(S||Y(kt),!kt.available){S||qr([]);return}const Kt=await s1();S||qr(Kt)}catch{Q=!0,S||(Y({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),qr([]))}};he();const it=setInterval(()=>{he()},4e3);return()=>{S=!0,clearInterval(it)}},[_r]);const ah=la??Ss,bu=ah==="shell",ja=ah==="tmux"&&Wr.available,$o=_.useMemo(()=>x3(mn.map(S=>({...S,id:S.name})),S=>S.cwd??null,e("sidebar.ungrouped")),[mn,e]),rc=_.useMemo(()=>mn.filter(S=>S.recoveryCandidate===!0&&!S.connected&&!S.boundFrontendSessionId).sort((S,Q)=>(Q.lastActiveAt??Q.createdAt??0)-(S.lastActiveAt??S.createdAt??0)),[mn]);b.useEffect(()=>{!ne&&!(Dt&&vr)||El()},[ne,Dt,vr,Tt.length,El]);const Nl=(S,Q,he,it=!1)=>{const kt=S.id===At,Kt=S.id===fn,Dr=$t.get(S.id),{primary:Nn,secondary:Gn}=yl(S,Dr?.activeProgram??null,Dr?.cwd??null,Fa,Dr?.shellTitle??null,Dr?.promptState??null),$n=dd(Dr?.cwd??null),Zi=Q?Gn??($n&&$n!==Nn?$n:null):null,In=Dr?.gitStatus,da=`${Dr?.cwd||S.name}${In?`
186
+ ⎇ ${In.branch} +${In.added} −${In.removed}`:""}`,Uo=!!(Dr?.tuiProgress&&Dr.tuiProgress.state!=="remove"),zo=Dr?.agentStatus==="working"||Uo?"var(--success)":Dr?.agentStatus==="waiting"||Dr?.agentNeedsReview?"var(--warning)":Dr?.inCopyMode?"var(--tmux)":null;if(Kt&&vr&&!gr){const Va=S.customName?S.name:Nn,Ki=(fo,Lp)=>{const _d=Lp.trim();_d?_d!==Va&&cs(fo,_d):ts(fo),Bn(null)};return s.jsx("input",{ref:fo=>{X.current=fo},type:"text",defaultValue:Va,className:"h-8 shrink-0 rounded-md bg-surface-elevated px-2 text-[12px] leading-none text-foreground outline-none ring-1 ring-primary/50 sm:h-8 min-w-[5rem]",style:{width:`${Math.max(Va.length,5)}ch`},onKeyDown:fo=>{fo.key==="Enter"?Ki(S.id,fo.target.value):fo.key==="Escape"&&Bn(null)},onBlur:fo=>Ki(S.id,fo.target.value)})}return s.jsx("div",{ref:kt?Ee:null,onContextMenu:Va=>{Va.preventDefault(),as({x:Va.clientX,y:Va.clientY}),pn(S.id)},...Cp(()=>bd(S.id)),className:it?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${kt?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/40 hover:text-foreground"}`:`group relative inline-flex h-8 shrink-0 items-center rounded-md text-[12px] leading-none transition sm:h-8 ${kt?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!it&&kt&&zo?{boxShadow:`inset 2px 0 0 0 ${zo}`}:!it&&kt?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:da,children:s.jsx("button",{type:"button",...he??{},onClick:()=>th(S.id),className:`inline-flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left ${it?"px-1":"py-1 pl-1 pr-1.5 sm:pl-1.5 sm:pr-2"} ${he?"cursor-grab active:cursor-grabbing":""}`,title:da,children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 overflow-hidden",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center",children:[$y(S.mode,Dr),Dr?.agentResumeRecovered&&s.jsx(Vc,{size:it?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),Uo&&!Dr?.agentStatus&&s.jsx(Rn,{size:it?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),Zi?s.jsxs("span",{className:"flex min-w-0 flex-col justify-center leading-[0.82rem] sm:leading-[0.85rem]",children:[s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Dr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:Nn}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:Zi})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Dr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:Nn})]})})})},uo=()=>s.jsx(zl,{droppableId:eg,type:"session",isDropDisabled:vr,children:(S,Q)=>{const he=Qs||Q.isDraggingOver;return s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"pointer-events-none fixed left-1/2 top-[42%] z-toast flex h-32 w-32 -translate-x-1/2 -translate-y-1/2 items-center justify-center",role:"status","aria-live":"polite","aria-hidden":!jn,"data-mobile-session-destroy-target":"","data-active":he?"true":"false",children:[s.jsxs("div",{className:`flex h-28 w-28 flex-col items-center justify-center gap-2 rounded-full border bg-surface-elevated/95 shadow-2xl backdrop-blur transition duration-200 ${jn?he?"scale-110 border-destructive bg-destructive text-destructive-foreground opacity-100":"scale-100 border-destructive/50 text-destructive opacity-100":"scale-75 border-transparent opacity-0"}`,children:[s.jsx(zs,{size:28,strokeWidth:1.8}),s.jsx("span",{className:"px-2 text-center text-[11px] font-semibold leading-tight",children:e(he?"tab.releaseToClose":"tab.dragToClose")})]}),S.placeholder]})}}),si=Dt&&vr,Ec=Fr&&vr,ho=tf(Zr,Jr,si?ur:0),ol=Ec?ho+Vy:0,Rl=si?Tt.find(S=>S.id===At):null,Fs=Rl?$t.get(Rl.id):void 0,oh=Rl?yl(Rl,Fs?.activeProgram??null,Fs?.cwd??null,Fa,Fs?.shellTitle??null,Fs?.promptState??null).primary:"",Sd=vr?en:null,lh=si&&!Sd&&Fs?Fs.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Fs.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Fs.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Fs.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",Cd=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[Ne&&s.jsxs("div",{role:"alert","data-update-restart-error":!0,className:"fixed right-3 top-3 z-toast flex max-w-md items-start gap-3 rounded-xl border border-border bg-surface p-3 text-sm text-foreground shadow-xl",children:[s.jsx("p",{className:"break-words",children:Ne}),s.jsx("button",{type:"button",className:"shrink-0 text-primary","aria-label":e("common.close"),onClick:()=>ae(null),children:e("common.close")})]}),ws&&s.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 bg-surface-2 px-3 py-2 text-xs",children:[s.jsx("p",{className:"min-w-0 flex-1 break-words",children:ws}),s.jsx("button",{type:"button",className:"min-h-11 px-2 text-primary",onClick:()=>_s(""),children:e("common.close")})]}),s.jsx("main",{className:"relative min-h-0 flex-1 overflow-visible px-0 pb-0 pt-0",children:s.jsxs(vC,{rightInset:ol,workspace:we&&s.jsx(_.Suspense,{fallback:s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--chrome-bg)] text-sm text-muted-foreground",children:"正在打开协作工作区…"}),children:s.jsx(uU,{groupId:we,activeSessionId:At,defaultSessionMode:Ss,onOpenSidebar:hi,leftSidebarVisible:ne||si,onToggleRightSidebar:ka,rightSidebarOpen:Xe||Ec},we)}),children:[s.jsxs("div",{"data-termdock-window-header":"true",className:`${vr?"absolute inset-x-0 top-0 z-20":"relative"} shrink-0 items-center gap-1 app-chrome-bg px-1 sm:px-1.5 transition-colors duration-500 ${si?"flex justify-end":"flex justify-between"} ${Ln?"h-10 sm:h-10":"h-9 sm:h-10"} ${lh}`,style:{position:vr?"absolute":void 0,marginRight:ol||void 0,display:Sd?"none":void 0},children:[!si&&s.jsxs("button",{type:"button",onClick:hi,className:"relative inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.sessionsTitle"),title:`${e("tab.sessionsTitle")} · ${e("agent.aiRunning")}: ${qi.running} · ${e("agent.needsReview")}: ${qi.review}`,children:[s.jsx(lS,{size:14}),s.jsx(dO,{runningCount:qi.running,reviewCount:qi.review,className:"sm:hidden"})]}),si?s.jsx("div",{className:"absolute left-1/2 flex max-w-[40%] min-w-0 -translate-x-1/2 items-center justify-center gap-1.5 overflow-hidden",children:Rl?s.jsxs(s.Fragment,{children:[$y(Rl.mode,Fs),s.jsx("span",{className:`truncate text-[12px] font-medium ${Fs?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:oh}),Fs?.agentStatus==="working"&&s.jsx("span",{title:Fs?.agentMessage??void 0,children:s.jsx(Rn,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Fs?.agentStatus==="waiting"&&s.jsx("span",{title:Fs?.agentMessage??void 0,children:s.jsx(Cf,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Fs?.agentStatus&&Fs?.agentNeedsReview&&s.jsx("span",{title:Fs?.agentMessage??void 0,children:s.jsx(wc,{size:13,className:"shrink-0 animate-pulse text-[color:var(--warning)]"})})]}):s.jsx("span",{className:"truncate px-2 text-[12px] text-muted-foreground",children:e("sidebar.sessions")})}):Ln?s.jsxs(Yu,{onDragStart:Wi,onDragUpdate:Ea,onDragEnd:Ps,children:[uo(),s.jsx(zl,{droppableId:"groups",type:"group",direction:"horizontal",children:S=>s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap px-0.5 py-0.5",style:{touchAction:"pan-x"},children:[Bo.map((Q,he)=>{let it=0,kt=0;for(const Gn of Q.sessions){const $n=$t.get(Gn.id);$n?.agentStatus==="working"&&(it+=1),($n?.agentStatus==="waiting"||$n?.agentNeedsReview)&&(kt+=1)}const Kt=Q.sessions.some(Gn=>Gn.id===At),Dr=Ur.has(Q.key),Nn=Q.key==="";return s.jsx(Ul,{draggableId:`group-${Q.key||"__ungrouped__"}`,index:he,isDragDisabled:Nn,disableInteractiveElementBlocking:!0,children:(Gn,$n)=>s.jsxs("div",{ref:Gn.innerRef,...Gn.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${$n.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":Kt?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...Nn?{}:Gn.dragHandleProps,onClick:()=>Xr(Q.key),className:`flex ${Dr?"":Q.sessions.length>1?"w-0 min-w-full":""} items-center gap-0.5 rounded text-[9px] font-semibold uppercase tracking-[0.08em] leading-none transition hover:bg-surface-elevated/40 ${Nn?"":"cursor-grab active:cursor-grabbing"} ${Kt?"text-primary/80":"text-muted-foreground/55"}`,title:Q.key||Q.label,children:[s.jsx(Ks,{size:9,className:`shrink-0 opacity-70 transition-transform ${Dr?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 truncate",children:Q.label}),it>0&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)]"}),kt>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${it>0?"":"ml-auto"}`})]}),Dr?s.jsx("span",{className:"flex h-5 items-center text-[10px] leading-none text-muted-foreground/50",children:e("tab.sessionCount",{count:Q.sessions.length})}):s.jsx(zl,{droppableId:`group-sessions:${Q.key}`,type:"session",direction:"horizontal",children:Zi=>s.jsxs("div",{ref:Zi.innerRef,...Zi.droppableProps,className:"flex items-center gap-px",children:[Q.sessions.map((In,da)=>s.jsx(Ul,{draggableId:In.id,index:da,disableInteractiveElementBlocking:!0,children:(Uo,zo)=>s.jsx("div",{ref:Uo.innerRef,...Uo.draggableProps,className:`flex shrink-0 items-center ${zo.isDragging?"opacity-70":""}`,children:Nl(In,!1,Uo.dragHandleProps,!0)})},In.id)),Zi.placeholder]})})]})},Q.key||"__ungrouped__")}),S.placeholder,s.jsx("button",{type:"button",onClick:()=>co(),disabled:pu,"aria-busy":pu,className:"my-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Xs,{size:14})})]})})]}):s.jsxs(Yu,{onDragStart:Wi,onDragUpdate:Ea,onDragEnd:Na,children:[uo(),s.jsx(zl,{droppableId:"tabs",type:"session",direction:"horizontal",children:S=>s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap",style:{touchAction:"pan-x"},children:[Ts.map((Q,he)=>Q.id===fn?s.jsx(_.Fragment,{children:s.jsx(Ul,{draggableId:Q.id,index:he,isDragDisabled:!0,children:kt=>s.jsx("div",{ref:kt.innerRef,...kt.draggableProps,className:"flex h-full items-center",children:Nl(Q,!0)})})},Q.id):s.jsx(_.Fragment,{children:s.jsx(Ul,{draggableId:Q.id,index:he,disableInteractiveElementBlocking:!0,children:(kt,Kt)=>s.jsx("div",{ref:kt.innerRef,...kt.draggableProps,className:`flex h-full shrink-0 items-center ${Kt.isDragging?"opacity-70":""}`,children:Nl(Q,!0,kt.dragHandleProps)})})},Q.id)),s.jsx("button",{type:"button",onClick:()=>co(),disabled:pu,"aria-busy":pu,className:"ml-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Xs,{size:14})}),S.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!si&&qi.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(l4,{count:qi.running,tone:"running",title:e("agent.aiRunning")})}),!si&&Tt.length>0&&s.jsx("span",{className:"inline-flex shrink-0 items-center px-1 text-[10px] uppercase tracking-[0.16em] text-muted-foreground sm:text-[11px]",title:`Session ${Ll+1} of ${Tt.length}`,children:ni}),!Ec&&s.jsx("button",{type:"button",onClick:ka,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.explorerTitle"),title:e("tab.explorerTitle"),children:s.jsx(d3,{size:14})})]})]}),hu&&Mi&&sl?.terminalSessionId&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 bg-surface/80 px-3 py-2 animate-fade-in sm:px-4",style:{marginRight:ol||void 0},role:"status","data-testid":"agent-resume-recovery-banner",children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] text-[color:var(--warning)]",children:!Yi?.error&&(Yi?.status==="submitting"||Yi?.status==="waiting")?s.jsx(Rn,{size:14,className:"animate-spin"}):s.jsx(Vc,{size:14})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:e("tab.resumeAgentRecoveredTitle",{agent:sl.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${Yi?.error?"text-destructive":"text-muted-foreground"}`,children:Yi?.error??(Yi?.status==="submitting"?e("tab.resumeAgentSubmitting"):Yi?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!Yi?.error&&(Yi?.status==="submitting"||Yi?.status==="waiting"),onClick:()=>{Sn(Mi.id,sl.terminalSessionId)},className:"shrink-0 rounded-full bg-primary px-3 py-1.5 text-[11px] font-semibold text-primary-foreground transition hover:opacity-90 active:scale-95 disabled:cursor-wait disabled:opacity-60 sm:text-[12px]",children:Yi?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Yr.getState().setAgentResumeRecovered(Mi.id,!1),nn(S=>S?.sessionId===Mi.id?null:S)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("tab.resumeAgentLater"),title:e("tab.resumeAgentLater"),children:s.jsx(Dn,{size:13})})]}),s.jsx("div",{ref:Ye,className:"min-h-0 flex-1 flex overflow-hidden app-chrome-bg",children:s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(GN,{terminalSettings:Jt,colorTheme:f,toolbarPresets:Ni,showDebug:l&&vr,terminalFocusAvailable:mt,defaultSessionMode:Ss,defaultTmuxSessionName:ri,connectionPrioritySessionId:ir,connectionPriorityReady:Et,desktopRightSidebarEnabled:vr,onToggleRightSidebar:ka,desktopFloatingTitle:vr,desktopLeftSidebarPinned:si,desktopPinnedLeftSidebarWidth:si?ur:0,desktopViewportWidth:Jr,onSessionDataUpdate:_p,onInitialViewportReady:rh,onInitialRecoveryRequired:yd})})})]})}),!we&&s.jsx(gO,{reviewCount:qi.review,runningSessions:Os,activeSessionId:At,runningButtonEnabled:Or,attentionButtonEnabled:Jn,isDesktopLayout:vr,containerElement:W,occlusionInsets:{right:ol}}),_r&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-drawer-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm animate-fade-in cursor-default",onClick:Ia,"aria-label":e("settings.closeSettings")}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-dialog-title",className:"pointer-events-none fixed inset-0 z-drawer-panel flex items-stretch justify-center p-0 animate-fade-in sm:p-4 md:p-6",children:s.jsxs("div",{className:"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden bg-surface shadow-[0_28px_90px_var(--app-shadow-strong),0_14px_34px_var(--app-shadow-soft)] sm:max-h-[calc(100dvh-3rem)] sm:rounded-3xl sm:border sm:border-border/15",style:{paddingTop:n,paddingBottom:a},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/15 px-4 py-3 sm:px-6 sm:py-4",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary/15 text-primary sm:h-9 sm:w-9",children:s.jsx(o1,{size:15})}),s.jsx("h2",{id:"settings-dialog-title",className:"text-[15px] font-semibold text-foreground sm:text-[16px]",children:e("settings.title")})]}),s.jsx("button",{type:"button",onClick:Ia,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive","aria-label":e("common.close"),children:s.jsx(Dn,{size:16})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background/25 px-3 py-3 sm:px-6 sm:py-5 md:px-8",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>lt({fontSize:Math.max(8,Ct-1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"−"}),s.jsx("input",{type:"range",min:"8",max:"32",value:Ct,onChange:S=>lt({fontSize:parseInt(S.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>lt({fontSize:Math.min(32,Ct+1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"+"}),s.jsxs("span",{className:"w-8 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:[Ct,"px"]})]}),s.jsx(G$,{}),s.jsx("div",{"data-terminal-renderer-controls":"browser-fallback",className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.render")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["auto","webgl","canvas"].map(S=>{const Q=ar===S;return s.jsx("button",{type:"button",onClick:()=>lt({rendererMode:S}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${Q?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:e(S==="auto"?"settings.auto":S==="webgl"?"settings.webgl":"settings.canvas")},S)})})]})}),s.jsx("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.theme")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[["dark",eS,e("settings.darkTheme")],["light",HS,e("settings.lightTheme")]].map(([S,Q,he])=>{const it=f===S;return s.jsxs("button",{type:"button",onClick:()=>m(S),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition ${it?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:[s.jsx(Q,{size:12}),s.jsx("span",{children:he})]},S)})})]})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.newTab")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["shell","tmux"].map(S=>{const Q=Ss===S,he=S==="tmux"&&!Wr.available;return s.jsx("button",{type:"button",disabled:he,onClick:()=>Ga(S,{userInitiated:!0}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${Q?"bg-primary/20 text-primary":he?"cursor-not-allowed text-muted-foreground/40":"text-muted-foreground hover:bg-surface-elevated"}`,title:he?Wr.reason||e("settings.installTmuxHint"):void 0,children:e(S==="shell"?"settings.shell":"settings.tmux")},S)})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>d(!l),className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${l?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,children:[s.jsx("span",{className:"font-medium",children:e("settings.debug")}),s.jsx(Al,{checked:l,size:"sm"})]}),s.jsxs("button",{type:"button",onClick:async()=>{const S=!y;w(S);try{const Q=await Ua({preventSleep:S});w(Q.preventSleep),T(Q.networkAvailable),pe(Q.localAccess),qn(l0,{preventSleep:Q.preventSleep,networkAvailable:Q.networkAvailable,localAccess:Q.localAccess})}catch{w(!S)}},className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${y?"bg-[rgb(var(--success-rgb)_/_0.15)] text-[color:var(--success)]":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:!v&&y?e("settings.noSleepUnavailable"):void 0,children:[s.jsx("span",{className:"font-medium truncate",children:e("settings.noSleep")}),s.jsx(Al,{checked:y,size:"sm"})]})]})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":Or,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{Qn(!Or)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(_f,{size:14,className:Or?"shrink-0 text-[color:var(--success)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.runningSessionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.runningSessionButtonHint")})]}),s.jsx(Al,{checked:Or,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":Jn,"aria-label":e("sidebar.attentionButton"),onClick:()=>{ui(!Jn)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(wc,{size:14,className:Jn?"shrink-0 text-[color:var(--warning)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.attentionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.attentionButtonHint")})]}),s.jsx(Al,{checked:Jn,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>Rs(!0),className:"mt-3 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(i3,{size:14,className:C?"shrink-0 text-primary":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("settings.notifications")}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e(C?N&&O?"settings.notificationsBothOnSummary":N?"settings.notificationsAiOnSummary":O?"settings.notificationsExitOnSummary":"settings.notificationsNoEventsSummary":"settings.notificationsOffSummary")})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e(C?"common.on":"common.off")}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>Vi(!0),className:"mt-3 flex w-full items-center justify-between gap-3 rounded-xl bg-surface-2 px-3 py-3 text-left transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block text-[12px] font-medium text-foreground/90",children:e("settings.localAccess")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.localAccessHint")})]}),s.jsx(Ks,{size:16,className:"shrink-0 text-muted-foreground"})]}),s.jsx(O$,{state:Te,pending:se,onCheck:()=>{dn()},onConfirmRestart:()=>{vn()},desktopState:me?Se:void 0,desktopPending:ke,onCheckDesktop:me?()=>{kn()}:void 0,onInstallDesktop:()=>{Hr()},desktopSnapshot:ut,desktopActions:ct?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-px border-t border-border/10 bg-border/10 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>{ct.showConnectionCenter()},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(eT,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{tt(null),ct.revealDataDirectory().catch(S=>tt(S instanceof Error?S.message:String(S)))},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(Ku,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),We&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:We})]}):void 0}),s.jsx($$,{backendSessionId:At?$t.get(At)?.terminalSessionId??null:null}),s.jsx(z$,{state:ze,onDismiss:()=>{Mn()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Ii(null),co({mode:"shell"}),Ia()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${bu?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:e(la==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(Xs,{size:14,className:bu?"shrink-0":"hidden"}),s.jsx(el,{size:12}),s.jsx("span",{className:bu?"whitespace-nowrap":"hidden",children:e(la==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Wr.available,onClick:()=>{Wr.available&&(Ii(null),co({mode:"tmux"}),Ia())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Wr.available?ja?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"flex-1 bg-surface-2/50 text-muted-foreground/50 cursor-not-allowed"}`,title:Wr.available?e(la==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Wr.reason||e("settings.installTmuxHint"),children:[s.jsx(Xs,{size:14,className:ja?"shrink-0":"hidden"}),s.jsx(su,{size:12}),s.jsx("span",{className:ja?"whitespace-nowrap":"hidden",children:e(la==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Wr.available||mn.length>0)&&s.jsxs("details",{className:"mt-3 group rounded-xl bg-surface-2 [&[open]]:bg-surface-2",children:[s.jsxs("summary",{className:"flex cursor-pointer items-center justify-between rounded-xl px-3 py-2.5 text-[13px] hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-flex h-2 w-2 rounded-full ${Wr.available?"bg-primary":"bg-destructive"}`}),s.jsx("span",{className:"font-medium",children:e("settings.tmuxServer")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Wr.available?e("settings.sessions",{n:mn.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:S=>{S.preventDefault(),El()},disabled:Be,className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":e("settings.refresh"),children:s.jsx(An,{size:12,className:Be?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Wr.available?mn.length===0?s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:e("settings.noTmuxSessions")}):s.jsxs("div",{className:"space-y-2",children:[$o.map(S=>s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1.5 py-1 text-[10px] text-muted-foreground",children:[s.jsx(nu,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"shrink-0 font-medium text-foreground/75",children:S.label}),s.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:e("settings.sessions",{n:S.sessions.length})}),S.key&&s.jsx("span",{className:"min-w-0 truncate text-muted-foreground/60",children:S.key})]}),S.sessions.map(Q=>{const he=Q.boundFrontendSessionId??null,it=!!(Q.connected||he),kt=he?Tt.find(Ki=>Ki.id===he)??null:null,Kt=Q.friendlyName?.trim()||null,Dr=Q.label&&Q.label!==Q.name?Q.label:null,Nn=Kt||Dr||Q.name,Gn=Kt||Dr?`tmux:${Q.name}`:null,$n=Q.clientCount&&Q.clientCount>0?t==="zh"?`网页连接 ${Q.clientCount}`:`Web clients ${Q.clientCount}`:null,Zi=Q.attached>0?t==="zh"?`原生 tmux ${Q.attached}`:`Native tmux ${Q.attached}`:null,In=[Gn,it?Q.restorable?e("settings.restorable"):e("settings.attached"):null,$n,Zi].filter(Ki=>!!Ki),da=[e("settings.windows",{n:Q.windows}),Q.createdAt?new Date(Q.createdAt).toLocaleDateString():null].filter(Ki=>!!Ki),Uo=er===Q.name,zo=$r===Q.name,Va=is===Q.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${Uo?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(su,{size:13,className:it?"mt-0.5 shrink-0 text-primary":"mt-0.5 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:Nn}),Q.friendlyName&&s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:t==="zh"?"自定义":"custom"})]}),In.length>0&&s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:In.map(Ki=>s.jsx("span",{className:"max-w-full truncate",children:Ki},Ki))}),(Q.program||Q.cwd)&&s.jsxs("div",{className:"grid min-w-0 gap-0.5 text-[10px] text-muted-foreground",children:[Q.program&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(BT,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate text-foreground/75",children:Q.program})]}),Q.cwd&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(nu,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Q.cwd})]})]}),s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/80",children:da.map(Ki=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(gT,{size:10,className:"shrink-0 text-muted-foreground/60"}),Ki]},Ki))})]}),Uo?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:zo,onClick:()=>{sh(Q.name)},className:"shrink-0 rounded-full bg-destructive/90 px-2.5 py-1 text-[11px] font-medium text-destructive-foreground transition hover:bg-destructive disabled:opacity-50",children:zo?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:zo,onClick:()=>{sr(null),ys(null)},className:"shrink-0 rounded-full bg-surface-2 px-2.5 py-1 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:e("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>{kt?th(kt.id):(Hn(Q.name),co({mode:"tmux",tmuxSessionName:Q.name}))},disabled:Va,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${it?"bg-surface text-foreground hover:bg-surface-elevated":Va?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:Va?s.jsxs(s.Fragment,{children:[s.jsx(Rn,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(it?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:zo,onClick:()=>{ys(null),sr(Q.name)},className:"shrink-0 inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":`Kill tmux session ${Q.name}`,children:s.jsx(zs,{size:12})})]})]},Q.name)})]},S.key||"__ungrouped_tmux__")),Zn&&s.jsx("p",{className:"px-2 text-[11px] text-destructive",children:Zn})]}):s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:Wr.reason||e("settings.installTmuxHint")})})]}),s.jsxs("button",{type:"button",onClick:()=>Gi(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(l3,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.keyboardToolbar")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e("settings.sessions",{n:Ni.length})}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>et(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(G0,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.aiAgentDetection")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"hooks"}),s.jsx("span",{children:"›"})]})]}),s.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.language")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[{code:"en",label:"English"},{code:"zh",label:"中文"}].map(S=>{const Q=t===S.code;return s.jsx("button",{type:"button",onClick:()=>r(S.code),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${Q?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:S.label},S.code)})})]}),s.jsxs("button",{type:"button",onClick:async()=>{try{await yA()}catch{}window.dispatchEvent(new CustomEvent("auth:unauthorized"))},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-xl bg-destructive/10 px-3 py-2.5 text-[13px] font-medium text-destructive transition hover:bg-destructive/20 active:scale-[0.98]",children:[s.jsx(m3,{size:14}),e("settings.signOut")]})]})]})})]}),Fo&&s.jsxs(s.Fragment,{children:[s.jsx(yQ,{sessionId:Fo.id,confirmButton:ih,onConfirm:Td,onCancel:xu,isCurrent:ue}),s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm cursor-default animate-fade-in",onClick:()=>{yt(null),U(null),ys(null)},"aria-label":e("common.close")}),s.jsxs("div",{className:`fixed z-menu-panel rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in ${R&&vr?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:R&&vr?{...By(R),paddingBottom:a}:{paddingBottom:a},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.closeChooserTitle")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:kp}),s.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground/80",children:e("tab.closeChooserDescription")})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",ref:ih,onClick:Td,className:"flex items-center gap-3 px-4 py-3 text-left text-[13px] text-destructive transition hover:bg-destructive/10",children:[s.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.confirmDestroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}),Zn&&s.jsx("p",{className:"px-4 py-2 text-[11px] text-destructive",children:Zn})]}),s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:()=>{yt(null),U(null),ys(null)},className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]}),Xn&&(()=>{const S=Tt.find($n=>$n.id===Xn);if(!S)return null;const Q=$t.get(S.id),{primary:he}=yl(S,Q?.activeProgram??null,Q?.cwd??null,Fa),it=vr,kt=it?By(lr):{paddingBottom:a},Kt=it?"fixed z-menu-panel overflow-y-auto overflow-x-hidden rounded-lg bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in":"fixed inset-x-3 bottom-6 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in sm:bottom-auto sm:top-[15%]",Dr=it?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",Nn=it?"flex items-center gap-2 px-3 py-2 text-left text-[12px] transition":"flex items-center gap-3 px-4 py-3 text-left text-[13px] transition",Gn=it?"inline-flex h-6 w-6 items-center justify-center rounded-md":"inline-flex h-7 w-7 items-center justify-center rounded-full";return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:`fixed inset-0 z-menu-backdrop cursor-default animate-fade-in ${it?"bg-transparent":"bg-[var(--app-backdrop-soft)] backdrop-blur-sm"}`,onClick:dt,"aria-label":"Close menu"}),s.jsxs("div",{className:Kt,style:kt,children:[s.jsxs("div",{className:Dr,children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:he}),Q?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/80",children:Q.cwd})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{const $n=lr;dt(),wr($n),Bn(S.id)},className:`${Nn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Gn} bg-primary/15 text-primary`,children:s.jsx(xS,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.rename")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.renameHint")})]})]}),s.jsxs("button",{type:"button",disabled:!Q?.cwd,onClick:()=>{fu(S.id),dt()},className:`${Nn} ${Q?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${Gn} bg-surface-2 text-muted-foreground`,children:s.jsx(c3,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.copyCwd")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.copyCwdHint")})]}),xr&&xr===Q?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const $n=i1(S.id),Zi=$n??Ct;return s.jsxs("div",{className:`${Nn} text-foreground`,children:[s.jsx("span",{className:`${Gn} bg-surface-2 text-muted-foreground`,children:s.jsx(VS,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.fontSize")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.fontSizeHint")})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>{ef(S.id,Zi-1),rn(In=>In+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} -1`,children:"−"}),s.jsxs("span",{className:"w-8 text-center text-[11px] tabular-nums text-muted-foreground",children:[Zi,"px"]}),s.jsx("button",{type:"button",onClick:()=>{ef(S.id,Zi+1),rn(In=>In+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} +1`,children:"+"}),$n!==null&&s.jsx("button",{type:"button",onClick:()=>{ef(S.id,null),rn(In=>In+1)},className:"ml-1 shrink-0 rounded-md px-1.5 py-1 text-[11px] text-primary transition hover:bg-primary/10",children:e("tab.fontSizeReset")})]})]})})(),Q?.agentNativeSessionId&&Q.agentStatus!=="working"&&Q.agentStatus!=="waiting"&&Q.terminalSessionId&&s.jsxs("button",{type:"button",onClick:()=>{const $n=Q.terminalSessionId;$n&&(dt(),Sn(S.id,$n))},className:`${Nn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Gn} bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)]`,children:s.jsx(Vc,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block font-medium",children:[e("tab.resumeAgent"),Q.agent?.displayName?` · ${Q.agent.displayName}`:""]}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.resumeAgentHint")})]})]}),s.jsx("div",{className:"my-1 border-t border-border/15"}),S.mode==="tmux"?s.jsxs("button",{type:"button",onClick:()=>{dt(),tc(S.id)},className:`${Nn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Gn} bg-destructive/15 text-destructive`,children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.destroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}):s.jsxs("button",{type:"button",onClick:()=>{dt(),il({sessionId:S.id,source:"tab-menu",closeMode:"auto"})},className:`${Nn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Gn} bg-destructive/15 text-destructive`,children:s.jsx(Dn,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.close")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.closeHint")})]})]}),!it&&s.jsx("button",{type:"button",className:"flex items-center justify-center px-4 py-2 text-[11px] text-muted-foreground/80 transition hover:text-foreground",onClick:()=>{dt()},children:e("tab.longPressTip")})]}),!it&&s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:dt,className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]})})(),fn&&gr&&vr&&(()=>{const S=Tt.find(In=>In.id===fn);if(!S)return null;const Q=$t.get(S.id),{primary:he}=yl(S,Q?.activeProgram??null,Q?.cwd??null,Fa,Q?.shellTitle??null,Q?.promptState??null),it=S.customName?S.name:he,kt=In=>{const da=In.trim();da?da!==it&&cs(S.id,da):ts(S.id),Bn(null),wr(null)},Kt=300,Dr=160,Nn=gr.x,Gn=gr.y,$n=Math.min(Math.max(Nn-Kt/2,12),window.innerWidth-Kt-12),Zi=Gn+Dr+20>window.innerHeight?Math.max(Gn-Dr-12,12):Gn+12;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-transparent",onClick:()=>{Bn(null),wr(null)},"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed z-menu-panel w-[300px] rounded-xl bg-surface-elevated border border-border/15 shadow-[0_12px_36px_var(--app-shadow-soft)] animate-fade-in",style:{left:`${$n}px`,top:`${Zi}px`},children:[s.jsxs("div",{className:"border-b border-border/15 px-3 py-2.5",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.rename")}),s.jsx("div",{className:"mt-0.5 truncate text-[13px] font-medium text-foreground",children:he}),Q?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",children:Q.cwd})]}),s.jsxs("form",{className:"px-3 py-2.5",onSubmit:In=>{In.preventDefault();const da=new FormData(In.currentTarget).get("session-name");kt(typeof da=="string"?da:"")},children:[s.jsx("input",{ref:In=>{X.current=In,In&&!be.current&&(be.current=!0,In.focus({preventScroll:!0}),In.select())},type:"text",name:"session-name",defaultValue:it,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,className:"w-full rounded-lg bg-surface-2 px-3 py-2 text-[13px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:In=>{In.key==="Escape"&&(In.stopPropagation(),Bn(null),wr(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{Bn(null),wr(null)},className:"flex-1 rounded-full bg-surface-2 px-3 py-1.5 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary px-3 py-1.5 text-[12px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.97]",children:e("common.save")})]})]})]})]})})(),fn&&!vr&&(()=>{const S=Tt.find(Kt=>Kt.id===fn);if(!S)return null;const Q=$t.get(S.id),{primary:he}=yl(S,Q?.activeProgram??null,Q?.cwd??null,Fa,Q?.shellTitle??null,Q?.promptState??null),it=S.customName?S.name:he,kt=Kt=>{const Dr=Kt.trim();Dr?Dr!==it&&cs(S.id,Dr):ts(S.id),Bn(null)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>Bn(null),"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed inset-x-3 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",style:{top:`calc(${n} + 3.5rem)`},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 text-[14px] font-medium text-foreground",children:e("tab.rename")})]}),s.jsxs("form",{className:"px-4 py-3",onSubmit:Kt=>{Kt.preventDefault();const Dr=new FormData(Kt.currentTarget).get("session-name");kt(typeof Dr=="string"?Dr:"")},children:[s.jsx("input",{ref:Kt=>{X.current=Kt,Kt&&!be.current&&(be.current=!0,Kt.focus({preventScroll:!0}),Kt.select())},type:"text",name:"session-name",defaultValue:it,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,enterKeyHint:"done",className:"w-full rounded-lg bg-surface-2 px-3 py-2.5 text-[16px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:Kt=>{Kt.key==="Escape"&&(Kt.stopPropagation(),Bn(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>Bn(null),className:"flex-1 rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary/20 px-3 py-2 text-[12px] font-medium text-primary transition hover:bg-primary/30",children:e("common.save")})]})]})]})]})})(),Ra&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":e("common.close"),className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Vi(!1)}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"local-access-title",className:"fixed inset-x-3 top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 p-4",children:[s.jsx("h2",{id:"local-access-title",className:"section-title",children:e("settings.localAccess")}),s.jsx("button",{autoFocus:!0,type:"button","aria-label":e("common.close"),onClick:()=>Vi(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(Dn,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(wC,{state:de,onCopy:S=>{Ws(S,"setup")},copied:le==="setup"}),s.jsxs("div",{className:"mt-3 flex items-center overflow-hidden rounded-lg bg-surface ring-1 ring-border/10 focus-within:ring-primary/40",children:[s.jsx("input",{value:J,onChange:S=>Re(S.target.value.toLowerCase()),className:"min-w-0 flex-1 bg-transparent px-2.5 py-2 text-[12px] text-foreground outline-none",placeholder:"jovn",spellCheck:!1}),s.jsx("span",{className:"shrink-0 border-l border-border/10 px-2.5 py-2 text-[11px] text-muted-foreground",children:".termdock.local"})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:Ze,onClick:()=>{kc()},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary transition hover:bg-primary/25 disabled:opacity-50",children:e(Ze?"settings.saving":"common.save")}),s.jsx("button",{type:"button",disabled:Ze,onClick:()=>{Jl()},className:"rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-50",children:e("settings.resetAutoName")})]}),s.jsxs("div",{className:"mt-3 space-y-1.5 text-[11px]",children:[de.url&&s.jsxs("button",{type:"button",onClick:()=>{Ws(de.url,"lan")},className:"flex w-full items-center justify-between gap-2 rounded-lg bg-surface px-2.5 py-2 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"min-w-0 truncate",children:["Branded: ",de.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:le==="lan"?"Copied":e("common.copy")})]}),de.interfaces.length>0&&s.jsxs("details",{className:"rounded-lg bg-surface px-2.5 py-2 text-muted-foreground",open:!1,children:[s.jsx("summary",{className:"cursor-pointer text-[11px] font-medium text-foreground/80",children:"IP fallback addresses"}),s.jsx("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:de.interfaces.map(S=>{const Q=S.url??`${de.httpsEnabled?"https":"http"}://${S.address}:9834`;return s.jsxs("div",{className:"rounded-lg bg-surface-2 p-2",children:[s.jsxs("div",{className:"text-[11px] font-medium text-foreground/85",children:[S.label," (",S.name,")"]}),s.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:S.address}),S.qrDataUrl&&s.jsx("div",{className:"mt-2 inline-block rounded-lg bg-[var(--background)] p-1.5",children:s.jsx("img",{src:S.qrDataUrl,alt:`QR code for ${Q}`,className:"h-28 w-28"})}),s.jsxs("button",{type:"button",onClick:()=>{Ws(Q,`ip-${S.address}`)},className:"mt-2 flex w-full items-center justify-between gap-2 rounded-md bg-surface px-2 py-1.5 text-left text-[11px] transition hover:bg-surface-elevated",children:[s.jsx("span",{className:"min-w-0 truncate",children:Q}),s.jsx("span",{className:"shrink-0 text-[10px]",children:le===`ip-${S.address}`?"Copied":e("common.copy")})]})]},`${S.name}-${S.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[de.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!de.caAvailable&&` · ${e("settings.caMissing")}`]}),de.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:de.reason}),ve&&s.jsx("div",{className:"text-destructive",children:ve})]})]})]})]}),ca&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>Rs(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notifications")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.notificationsTitle")})]}),s.jsx("button",{type:"button",onClick:()=>Rs(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close notifications settings",children:s.jsx(Dn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:e("settings.notificationsPageHint")}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsMaster")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:Z==="denied"?e("settings.notificationsDenied"):yh()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),yh()&&!vA()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{Fn()},disabled:!yh()||Z==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":C,children:s.jsx(Al,{checked:C,disabled:!yh()||Z==="denied"})})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[s.jsxs("span",{className:`rounded-full px-2 py-0.5 ${Z==="granted"?"bg-primary/15 text-primary":"bg-surface text-muted-foreground"}`,children:[e("settings.notificationsPermission"),": ",na()?e("settings.notificationsPermissionSystem"):Z]}),s.jsx("button",{type:"button",disabled:!C||Z!=="granted"||Ei==="checking",onClick:()=>{ms()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:e(Ei==="checking"?"settings.notificationsTestChecking":"settings.notificationsTest")}),na()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{na()?.openNotificationSettings?.()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:e("settings.notificationsOpenSystemSettings")})]}),Ei!=="idle"&&Ei!=="checking"&&s.jsx("div",{className:`mt-2 text-[11px] leading-relaxed ${Ei==="delivered"?"text-primary":"text-[var(--warning)]"}`,children:e(Ei==="delivered"?"settings.notificationsTestDelivered":"settings.notificationsTestFailed")})]}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAlertStyle")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAlertStyleHint")}),s.jsx("div",{className:"mt-3 grid grid-cols-3 gap-1 rounded-xl bg-surface p-1",children:[["normal",e("settings.notificationsStyleNormal"),e("settings.notificationsStyleNormalHint")],["quiet",e("settings.notificationsStyleQuiet"),e("settings.notificationsStyleQuietHint")],["persistent",e("settings.notificationsStylePersistent"),e("settings.notificationsStylePersistentHint")]].map(([S,Q,he])=>{const it=F===S;return s.jsxs("button",{type:"button",disabled:!C,onClick:()=>wn(S),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${it&&C?"bg-primary/15 text-primary":C?"text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"cursor-not-allowed text-muted-foreground/40"}`,title:he,children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold",children:Q}),s.jsx("span",{className:"mt-0.5 block truncate text-[9px] opacity-80",children:he})]},S)})})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notificationsEvents")}),s.jsxs("div",{className:"mt-2 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAiFinished")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAiFinishedHint")})]}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>Ri(!N),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":N&&C,children:s.jsx(Al,{checked:N&&C,disabled:!C})})]}),s.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-border/10 pt-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsSessionExited")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsSessionExitedHint")})]}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>Kr(!O),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":O&&C,children:s.jsx(Al,{checked:O&&C,disabled:!C})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),io&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>Gi(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.mobileKeyboard")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.toolbarPresets")})]}),s.jsx("button",{type:"button",onClick:()=>Gi(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close toolbar presets",children:s.jsx(Dn,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(B$,{presets:Ni,selectedPresetId:Po,onSelectPreset:ce,onUpdatePreset:(S,Q)=>{oo(he=>Vu(he.map(it=>it.id===S?Q(it):it)))},onAddPreset:()=>{const S=`preset-${Date.now()}`;oo(Q=>Vu([...Q,{id:S,label:`Preset ${Q.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),ce(S)},onRemovePreset:S=>{oo(Q=>Vu(Q.filter(he=>he.id!==S)))},onResetDefaults:()=>{oo(D0()),ce("default")}})})]})]}),Lt&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>et(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.aiAgentDetection")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.detectionRules")})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{type:"button",onClick:()=>et(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close agent rules",children:s.jsx(Dn,{size:18})})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:e("settings.agentHooksHint")}),s.jsx(P$,{}),s.jsxs("div",{className:"mt-6 border-t border-border/15 pt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.programLabelResolution")}),s.jsx("h3",{className:"mt-1 text-sm font-semibold text-foreground",children:e("settings.rawCommandMapping")}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:e("settings.rawCommandMappingHint")}),s.jsx("div",{className:"mt-3 space-y-2 rounded-xl bg-surface-2 p-3",children:Tt.map(S=>{const Q=$t.get(S.id),he=Q?.activeProgramRaw??null,it=Q?.activeProgram??null;return s.jsxs("div",{className:"rounded-lg bg-surface/60 px-2.5 py-2",children:[s.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:S.name}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-foreground",children:[s.jsx("span",{className:"text-muted-foreground",children:"display:"})," ",it||"—"]}),s.jsxs("div",{className:"mt-0.5 break-all font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"text-muted-foreground/80",children:"raw:"})," ",he||"—"]})]},`raw-${S.id}`)})}),s.jsxs("div",{className:"mt-3 space-y-3",children:[[{key:"genericProgramNames",label:e("settings.genericProgramNames"),hint:e("settings.genericProgramNamesHint")},{key:"wrapperScriptNames",label:e("settings.wrapperScriptNames"),hint:e("settings.wrapperScriptNamesHint")},{key:"shellNames",label:e("settings.shellNamesConfig"),hint:e("settings.shellNamesHint")}].map(({key:S,label:Q,hint:he})=>s.jsxs("div",{children:[s.jsx("div",{className:"mb-0.5 text-[11px] font-medium text-foreground",children:Q}),s.jsx("div",{className:"text-[10px] text-muted-foreground",children:he}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[It[S].map(it=>s.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] font-mono text-foreground",children:[it,s.jsx("button",{type:"button",onClick:()=>{const kt={...It,[S]:It[S].filter(Kt=>Kt!==it)};yr(kt),S==="shellNames"&&(Fa=new Set(kt.shellNames)),Dx(kt).catch(()=>{})},className:"ml-0.5 text-muted-foreground hover:text-destructive",children:"×"})]},it)),s.jsx("input",{placeholder:e("settings.addTag"),className:"w-16 rounded bg-surface px-1.5 py-0.5 text-[11px] font-mono",onKeyDown:it=>{if(it.key!=="Enter")return;const kt=it.target.value.trim().toLowerCase();if(!kt||It[S].includes(kt))return;const Kt={...It,[S]:[...It[S],kt]};yr(Kt),S==="shellNames"&&(Fa=new Set(Kt.shellNames)),it.target.value="",Dx(Kt).catch(()=>{})}})]})]},S)),s.jsx("button",{type:"button",onClick:()=>{wA().then(S=>{yr(S),Fa=new Set(S.shellNames)}).catch(()=>{})},className:"rounded-full bg-surface-2 px-3 py-1 text-[11px] text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")})]}),s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"mb-1 text-[11px] font-medium text-foreground",children:e("settings.customRules")}),I.map((S,Q)=>s.jsx("div",{className:"mb-2 rounded-lg bg-surface-2 p-2.5",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:S.enabled!==!1,onChange:he=>{const it=I.map((kt,Kt)=>Kt===Q?{...kt,enabled:he.target.checked}:kt);B(it),qn(Oa,it),Le(!0),Au(it).then(kt=>{B(kt),qn(Oa,kt)}).catch(()=>{}).finally(()=>Le(!1))}}),s.jsxs("select",{value:S.matchType,onChange:he=>{const it=I.map((kt,Kt)=>Kt===Q?{...kt,matchType:he.target.value}:kt);B(it),qn(Oa,it),Le(!0),Au(it).then(kt=>{B(kt),qn(Oa,kt)}).catch(()=>{}).finally(()=>Le(!1))},className:"rounded bg-surface px-2 py-1 text-[11px]",children:[s.jsx("option",{value:"includes",children:"includes"}),s.jsx("option",{value:"exact",children:"exact"}),s.jsx("option",{value:"prefix",children:"prefix"}),s.jsx("option",{value:"regex",children:"regex"})]}),s.jsx("input",{value:S.pattern,onChange:he=>{const it=I.map((kt,Kt)=>Kt===Q?{...kt,pattern:he.target.value}:kt);B(it),qn(Oa,it)},onBlur:()=>{Le(!0),Au(I).then(he=>{B(he),qn(Oa,he)}).catch(()=>{}).finally(()=>Le(!1))},placeholder:"pattern",className:"min-w-[180px] flex-1 rounded bg-surface px-2 py-1 text-[11px] font-mono"}),s.jsx("input",{value:S.output,onChange:he=>{const it=I.map((kt,Kt)=>Kt===Q?{...kt,output:he.target.value}:kt);B(it),qn(Oa,it)},onBlur:()=>{Le(!0),Au(I).then(he=>{B(he),qn(Oa,he)}).catch(()=>{}).finally(()=>Le(!1))},placeholder:"output",className:"w-28 rounded bg-surface px-2 py-1 text-[11px]"}),s.jsx("button",{type:"button",onClick:()=>{const he=I.filter((it,kt)=>kt!==Q);B(he),qn(Oa,he),Le(!0),Au(he).then(it=>{B(it),qn(Oa,it)}).catch(()=>{}).finally(()=>Le(!1))},className:"rounded bg-surface px-2 py-1 text-[11px] text-muted-foreground hover:text-destructive",children:e("common.delete")})]})},S.id)),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{const S=[...I,{id:`rule-${Date.now()}`,enabled:!0,priority:100,matchType:"includes",pattern:"",output:""}];B(S),qn(Oa,S),Le(!0),Au(S).then(Q=>{B(Q),qn(Oa,Q)}).catch(()=>{}).finally(()=>Le(!1))},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-primary/25",children:e("settings.addRule")}),s.jsx("button",{type:"button",onClick:()=>{Le(!0),AA().then(S=>{B(S),qn(Oa,S)}).catch(()=>{}).finally(()=>Le(!1))},className:"rounded-full bg-surface-2 px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Pe?e("settings.saving"):$?`${I.length} rules`:"…"})]})]})]})]})]})]}),Rt&&s.jsx(E$,{isOpen:Rt,onClose:()=>cr(!1)}),!si&&s.jsx(oy,{isOpen:ne,drawerWidthPx:As,onClose:()=>Pn("left-sidebar"),onOpen:Li,sessions:Tt,activeSessionId:At,sessionStates:$t,onNewSession:S=>co(S),recoverableTmuxSessions:rc,recoverableTmuxSessionsLoading:Be,onRefreshRecoverableTmuxSessions:()=>{El()},onCloseRecoverableTmuxSession:mu,onCloseSession:tc,onSplitSession:Ic,onCloseSplit:S=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:S})),onRemoveFromSplit:S=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:S})),splitWorkspaces:gt,onSetSplitLayout:wd,onReorderSplitWorkspace:al,onRenameSplitWorkspace:Ad,onCombineSplitSessions:gu,onReorderSessions:ti,onSessionMenu:bd,onOpenSettings:La,onJumpToNextAttention:ua.length>0?Il:void 0,onOpenQuota:()=>cr(!0),updateState:Te,updateActionPending:se,onConfirmUpdateRestart:vn,onRetryUpdate:dn,serverHealthState:ze,tmuxAvailable:Wr.available,defaultSessionMode:Ss,onTogglePinned:vr?On:void 0}),!Ec&&s.jsx(ly,{isOpen:Xe,sessionId:At,drawerWidthPx:Zl,onClose:()=>Pn("right-sidebar"),onOpen:Ha,rightSidebarFilePreviewOpen:di,rightSidebarFilePreviewCloseSignal:nr,onOpenRightSidebarFilePreview:Xl,onCloseRightSidebarFilePreview:fi,rightSidebarRepoPickerOpen:Xt,rightSidebarRepoPickerCloseSignal:Ht,onOpenRightSidebarRepoPicker:ei,onCloseRightSidebarRepoPicker:pi,markdownOutlineOpen:Je,markdownOutlineCloseSignal:Nt,onOpenMarkdownOutline:nl,onCloseMarkdownOutline:aa,markdownImageLightboxOpen:xt,markdownImageLightboxCloseSignal:$e,onOpenMarkdownImageLightbox:ks,onCloseMarkdownImageLightbox:Hi,onTogglePinned:vr?ls:void 0}),wt&&!c&&s.jsx("button",{type:"button",onClick:_c,className:"fixed inset-0 z-toast flex cursor-default items-center justify-center bg-[var(--app-backdrop-soft)] px-6 text-left backdrop-blur-[1px]","aria-label":t==="zh"?"继续使用 Termdock":"Continue using Termdock",children:s.jsxs("div",{className:"max-w-[18rem] rounded-2xl border border-border/15 bg-surface/95 px-5 py-4 text-center shadow-[0_18px_50px_var(--app-shadow-strong)] backdrop-blur animate-fade-in",children:[s.jsx("div",{className:"text-[14px] font-semibold text-foreground",children:t==="zh"?"建议使用 Home":"Use Home instead"}),s.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:t==="zh"?"按 Home 退后台,点任意位置继续。":"Use Home to leave. Tap anywhere to continue."}),s.jsx("div",{className:"mt-3 text-[11px] font-medium text-muted-foreground/80",children:t==="zh"?"轻点关闭提示":"Tap to dismiss"})]})}),Oe&&s.jsxs("div",{className:`fixed inset-x-3 bottom-4 z-toast mx-auto flex max-w-md items-center gap-2 rounded-xl border px-4 py-3 text-[12px] shadow-lg animate-fade-in ${Oe.tone==="success"?"border-[rgb(var(--success-rgb)_/_0.24)] bg-surface-elevated text-foreground":"border-destructive/30 bg-surface-elevated text-destructive"}`,role:Oe.tone==="error"?"alert":"status",children:[Oe.tone==="success"?s.jsx(Vc,{size:14,className:"shrink-0 text-[color:var(--success)]"}):s.jsx(Cf,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:Oe.message}),s.jsx("button",{type:"button",onClick:()=>_t(null),className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("common.close"),children:s.jsx(Dn,{size:12})})]}),l&&s.jsxs(s.Fragment,{children:[!vr&&s.jsx(AC,{onClose:()=>d(!1)}),s.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-toast hidden max-h-48 overflow-y-auto border-t border-border/15 bg-surface p-3 animate-fade-in md:block",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h4",{className:"ui-kicker",children:"Debug Info"}),s.jsx("button",{type:"button",onClick:()=>d(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Close"})]}),s.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(St,null,2)})]})]})]}),ch=bt?null:s.jsx(CA,{className:"z-modal-panel",status:"正在恢复终端…"});return vr?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[si&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:ur,flexShrink:0,height:"100%"},children:s.jsx(oy,{isOpen:ne,drawerWidthPx:ur,onClose:Js,onOpen:Li,sessions:Tt,activeSessionId:At,sessionStates:$t,onNewSession:S=>co(S),recoverableTmuxSessions:rc,recoverableTmuxSessionsLoading:Be,onRefreshRecoverableTmuxSessions:()=>{El()},onCloseRecoverableTmuxSession:mu,onCloseSession:tc,onSplitSession:Ic,onCloseSplit:S=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:S})),onRemoveFromSplit:S=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:S})),splitWorkspaces:gt,onSetSplitLayout:wd,onReorderSplitWorkspace:al,onRenameSplitWorkspace:Ad,onCombineSplitSessions:gu,onReorderSessions:ti,onSessionMenu:bd,onOpenSettings:La,onJumpToNextAttention:ua.length>0?Il:void 0,onOpenQuota:()=>cr(!0),updateState:Te,updateActionPending:se,onConfirmUpdateRestart:vn,onRetryUpdate:dn,serverHealthState:ze,tmuxAvailable:Wr.available,defaultSessionMode:Ss,pinned:!0,onTogglePinned:On})}),s.jsx("div",{role:"separator",tabIndex:-1,className:"shrink-0 w-[5px] h-full cursor-col-resize bg-border/10 hover:bg-primary/30 active:bg-primary/50 transition-colors",onMouseDown:rl})]}),s.jsxs("div",{className:"relative flex-1 min-w-0 h-full overflow-hidden",children:[Cd,Ec&&s.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex",style:{width:ol},children:[s.jsx("div",{role:"separator",tabIndex:-1,className:"h-full w-[5px] shrink-0 cursor-col-resize bg-border/10 transition-colors hover:bg-primary/30 active:bg-primary/50",onMouseDown:Do}),s.jsx("div",{style:{width:ho,flexShrink:0,height:"100%"},children:s.jsx(ly,{isOpen:!0,sessionId:At,drawerWidthPx:ho,onClose:Wa,onOpen:Ha,pinned:!0,onTogglePinned:ls,rightSidebarFilePreviewOpen:di,rightSidebarFilePreviewCloseSignal:nr,onOpenRightSidebarFilePreview:Xl,onCloseRightSidebarFilePreview:fi,rightSidebarRepoPickerOpen:Xt,rightSidebarRepoPickerCloseSignal:Ht,onOpenRightSidebarRepoPicker:ei,onCloseRightSidebarRepoPicker:pi,markdownOutlineOpen:Je,markdownOutlineCloseSignal:Nt,onOpenMarkdownOutline:nl,onCloseMarkdownOutline:aa,markdownImageLightboxOpen:xt,markdownImageLightboxCloseSignal:$e,onOpenMarkdownImageLightbox:ks,onCloseMarkdownImageLightbox:Hi})})]})]}),s.jsx(Ty,{sessionId:At}),ch]}):s.jsxs(s.Fragment,{children:[Cd,s.jsx(Ty,{sessionId:At}),ch]})}const iz=Object.freeze(Object.defineProperty({__proto__:null,default:dU,runServiceUpdateConfirmation:N4},Symbol.toStringTag,{value:"Module"}));export{wU as $,g0 as A,R0 as B,EF as C,dC as D,_f as E,o3 as F,NF as G,Vc as H,h3 as I,ES as J,l3 as K,c3 as L,GT as M,sS as N,y0 as O,lS as P,i4 as Q,An as R,Yl as S,o1 as T,HS as U,HI as V,zs as W,m3 as X,tC as Y,zp as Z,mC as _,hC as a,yU as a0,A3 as a1,TU as a2,SU as a3,AU as a4,Lv as a5,nz as a6,l5 as a7,I1 as a8,op as a9,yy as aa,w3 as ab,nf as ac,ug as ad,kC as ae,hF as af,vU as ag,c5 as ah,mN as ai,ou as aj,cy as ak,Jm as al,$i as am,sz as an,L3 as ao,Lf as b,w$ as c,iz as d,pC as e,Sf as f,VA as g,WA as h,s3 as i,a3 as j,I0 as k,iF as l,wT as m,E0 as n,RO as o,Ku as p,og as q,OT as r,ZT as s,u3 as t,eS as u,d3 as v,mS as w,xS as x,yS as y,N0 as z};