termdock 1.4.317 → 1.4.319

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 (347) hide show
  1. package/dist/client/assets/App-9yy2aYiT.js +186 -0
  2. package/dist/client/assets/App-9yy2aYiT.js.br +0 -0
  3. package/dist/client/assets/App-9yy2aYiT.js.gz +0 -0
  4. package/dist/client/assets/{ArchitecturePanel-CdgUQsVD.js → ArchitecturePanel-CHMjbrPM.js} +2 -2
  5. package/dist/client/assets/ArchitecturePanel-CHMjbrPM.js.br +0 -0
  6. package/dist/client/assets/ArchitecturePanel-CHMjbrPM.js.gz +0 -0
  7. package/dist/client/assets/{ChangeWalkthroughPanel-DHp5r1k9.js → ChangeWalkthroughPanel-B0JYVVwB.js} +1 -1
  8. package/dist/client/assets/ChangeWalkthroughPanel-B0JYVVwB.js.br +0 -0
  9. package/dist/client/assets/ChangeWalkthroughPanel-B0JYVVwB.js.gz +0 -0
  10. package/dist/client/assets/{CollaborationMainWorkspace-P_jXjsT-.js → CollaborationMainWorkspace-BJzMdyZc.js} +1 -1
  11. package/dist/client/assets/CollaborationMainWorkspace-BJzMdyZc.js.br +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-BJzMdyZc.js.gz +0 -0
  13. package/dist/client/assets/CollaborationTaskContent-BwHxwcOP.js +2 -0
  14. package/dist/client/assets/{ComputerControlView-B5Yng8Dt.js → ComputerControlView-CdMNRZsH.js} +2 -2
  15. package/dist/client/assets/ComputerControlView-CdMNRZsH.js.br +0 -0
  16. package/dist/client/assets/ComputerControlView-CdMNRZsH.js.gz +0 -0
  17. package/dist/client/assets/{DagPlayground-rZE40fcL.js → DagPlayground-C1xEyYVK.js} +1 -1
  18. package/dist/client/assets/DagPlayground-C1xEyYVK.js.br +0 -0
  19. package/dist/client/assets/DagPlayground-C1xEyYVK.js.gz +0 -0
  20. package/dist/client/assets/{DiffLab-3sIn0W3p.js → DiffLab-DcCKWB7G.js} +1 -1
  21. package/dist/client/assets/DiffLab-DcCKWB7G.js.br +0 -0
  22. package/dist/client/assets/DiffLab-DcCKWB7G.js.gz +0 -0
  23. package/dist/client/assets/{DiffReview-CBf8-Tli.js → DiffReview-C1TyvrA9.js} +1 -1
  24. package/dist/client/assets/DiffReview-C1TyvrA9.js.br +0 -0
  25. package/dist/client/assets/DiffReview-C1TyvrA9.js.gz +0 -0
  26. package/dist/client/assets/{DiffReviewLab-BXhskTlx.js → DiffReviewLab-D784yT2y.js} +1 -1
  27. package/dist/client/assets/DiffReviewLab-D784yT2y.js.br +0 -0
  28. package/dist/client/assets/DiffReviewLab-D784yT2y.js.gz +0 -0
  29. package/dist/client/assets/{DiffViewer-DZfgjOBh.js → DiffViewer-ByAlz2NG.js} +1 -1
  30. package/dist/client/assets/DiffViewer-ByAlz2NG.js.br +0 -0
  31. package/dist/client/assets/DiffViewer-ByAlz2NG.js.gz +0 -0
  32. package/dist/client/assets/{ModelPreview-Bzdi_sPh.js → ModelPreview-DxMcmJZy.js} +1 -1
  33. package/dist/client/assets/ModelPreview-DxMcmJZy.js.br +0 -0
  34. package/dist/client/assets/ModelPreview-DxMcmJZy.js.gz +0 -0
  35. package/dist/client/assets/{RightSidebar-DaRdlJzn.js → RightSidebar-CXykcIPb.js} +3 -3
  36. package/dist/client/assets/RightSidebar-CXykcIPb.js.br +0 -0
  37. package/dist/client/assets/RightSidebar-CXykcIPb.js.gz +0 -0
  38. package/dist/client/assets/{abnfDiagram-VCTEODGH-CarKrfAf.js → abnfDiagram-VCTEODGH-DZZIayJV.js} +1 -1
  39. package/dist/client/assets/abnfDiagram-VCTEODGH-DZZIayJV.js.br +0 -0
  40. package/dist/client/assets/abnfDiagram-VCTEODGH-DZZIayJV.js.gz +0 -0
  41. package/dist/client/assets/{app-BCTEfclM.js → app-CI3Oh-41.js} +3 -3
  42. package/dist/client/assets/app-CI3Oh-41.js.br +0 -0
  43. package/dist/client/assets/app-CI3Oh-41.js.gz +0 -0
  44. package/dist/client/assets/{arc-B6Qdq2Vw.js → arc-CjpEX_Ug.js} +1 -1
  45. package/dist/client/assets/arc-CjpEX_Ug.js.br +0 -0
  46. package/dist/client/assets/arc-CjpEX_Ug.js.gz +0 -0
  47. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DgPJ0l9i.js → architectureDiagram-5GKGNRK7-DUx2_xyE.js} +1 -1
  48. package/dist/client/assets/architectureDiagram-5GKGNRK7-DUx2_xyE.js.br +0 -0
  49. package/dist/client/assets/architectureDiagram-5GKGNRK7-DUx2_xyE.js.gz +0 -0
  50. package/dist/client/assets/{blockDiagram-I7D4REHJ-BsorvNo4.js → blockDiagram-I7D4REHJ-DP-lXaM3.js} +1 -1
  51. package/dist/client/assets/blockDiagram-I7D4REHJ-DP-lXaM3.js.br +0 -0
  52. package/dist/client/assets/blockDiagram-I7D4REHJ-DP-lXaM3.js.gz +0 -0
  53. package/dist/client/assets/{c4Diagram-7LVT6UL2-Bbpi62ab.js → c4Diagram-7LVT6UL2-DomY5VR-.js} +1 -1
  54. package/dist/client/assets/c4Diagram-7LVT6UL2-DomY5VR-.js.br +0 -0
  55. package/dist/client/assets/c4Diagram-7LVT6UL2-DomY5VR-.js.gz +0 -0
  56. package/dist/client/assets/channel-DIO7oiN5.js +1 -0
  57. package/dist/client/assets/{chunk-2Q5K7J3B-Cm7mDz66.js → chunk-2Q5K7J3B-BPtKxDa8.js} +1 -1
  58. package/dist/client/assets/{chunk-5VM5RSS4-BMERXU_m.js → chunk-5VM5RSS4-CRCqW368.js} +1 -1
  59. package/dist/client/assets/{chunk-F27PBJKO-fe9Yw7OI.js → chunk-F27PBJKO-Bs1ITIOZ.js} +1 -1
  60. package/dist/client/assets/chunk-F27PBJKO-Bs1ITIOZ.js.br +0 -0
  61. package/dist/client/assets/chunk-F27PBJKO-Bs1ITIOZ.js.gz +0 -0
  62. package/dist/client/assets/{chunk-IMKFNOWR-QquKV9k-.js → chunk-IMKFNOWR-Cw7kOnvo.js} +1 -1
  63. package/dist/client/assets/chunk-IMKFNOWR-Cw7kOnvo.js.br +0 -0
  64. package/dist/client/assets/chunk-IMKFNOWR-Cw7kOnvo.js.gz +0 -0
  65. package/dist/client/assets/{chunk-JWPE2WC7-CVe8_YO4.js → chunk-JWPE2WC7-DBNaGHE2.js} +1 -1
  66. package/dist/client/assets/{chunk-POPQ4Y6H-DT8PalJ4.js → chunk-POPQ4Y6H-B_OEr0FR.js} +1 -1
  67. package/dist/client/assets/{chunk-SVP7TREG-BUQulipE.js → chunk-SVP7TREG-Ct25uRBl.js} +1 -1
  68. package/dist/client/assets/chunk-SVP7TREG-Ct25uRBl.js.br +0 -0
  69. package/dist/client/assets/chunk-SVP7TREG-Ct25uRBl.js.gz +0 -0
  70. package/dist/client/assets/{chunk-TICWLB2K-fubKwUCg.js → chunk-TICWLB2K-BVxQwSUB.js} +1 -1
  71. package/dist/client/assets/chunk-TICWLB2K-BVxQwSUB.js.br +0 -0
  72. package/dist/client/assets/chunk-TICWLB2K-BVxQwSUB.js.gz +0 -0
  73. package/dist/client/assets/{chunk-XXDRQBXY-CdwTi82y.js → chunk-XXDRQBXY-B6PLILau.js} +1 -1
  74. package/dist/client/assets/classDiagram-ZZMXUADV-DukHh254.js +1 -0
  75. package/dist/client/assets/classDiagram-v2-VYDZK3BY-DukHh254.js +1 -0
  76. package/dist/client/assets/{cose-bilkent-JH36ORCC-DmEDc2ee.js → cose-bilkent-JH36ORCC-Df23Xlgg.js} +1 -1
  77. package/dist/client/assets/cose-bilkent-JH36ORCC-Df23Xlgg.js.br +0 -0
  78. package/dist/client/assets/cose-bilkent-JH36ORCC-Df23Xlgg.js.gz +0 -0
  79. package/dist/client/assets/{cynefin-OW5HDTMX-C-mfarRX.js → cynefin-OW5HDTMX-Dxy4auKS.js} +1 -1
  80. package/dist/client/assets/cynefin-OW5HDTMX-Dxy4auKS.js.br +0 -0
  81. package/dist/client/assets/cynefin-OW5HDTMX-Dxy4auKS.js.gz +0 -0
  82. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CgVmp8od.js → cynefinDiagram-5FMLGOSQ-CRypsJyP.js} +1 -1
  83. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CRypsJyP.js.br +0 -0
  84. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CRypsJyP.js.gz +0 -0
  85. package/dist/client/assets/{dagre-GXQ25YYZ-WU_d2fSU.js → dagre-GXQ25YYZ-B2XmJ6IF.js} +1 -1
  86. package/dist/client/assets/dagre-GXQ25YYZ-B2XmJ6IF.js.br +0 -0
  87. package/dist/client/assets/dagre-GXQ25YYZ-B2XmJ6IF.js.gz +0 -0
  88. package/dist/client/assets/{diagram-S7CK7UJ4-Dtikk80Z.js → diagram-S7CK7UJ4-BQcwNDWz.js} +1 -1
  89. package/dist/client/assets/diagram-S7CK7UJ4-BQcwNDWz.js.br +0 -0
  90. package/dist/client/assets/diagram-S7CK7UJ4-BQcwNDWz.js.gz +0 -0
  91. package/dist/client/assets/{diagram-UQ7AKVKN-DuTCB36P.js → diagram-UQ7AKVKN-B6LD6n6P.js} +1 -1
  92. package/dist/client/assets/diagram-UQ7AKVKN-B6LD6n6P.js.br +0 -0
  93. package/dist/client/assets/diagram-UQ7AKVKN-B6LD6n6P.js.gz +0 -0
  94. package/dist/client/assets/{diagram-VSXAHHWV-DSLAcWi6.js → diagram-VSXAHHWV-DDI4SMid.js} +1 -1
  95. package/dist/client/assets/diagram-VSXAHHWV-DDI4SMid.js.br +0 -0
  96. package/dist/client/assets/diagram-VSXAHHWV-DDI4SMid.js.gz +0 -0
  97. package/dist/client/assets/{diagram-VX7I27RA-DyQOu10m.js → diagram-VX7I27RA-CRq35BVZ.js} +1 -1
  98. package/dist/client/assets/diagram-VX7I27RA-CRq35BVZ.js.br +0 -0
  99. package/dist/client/assets/diagram-VX7I27RA-CRq35BVZ.js.gz +0 -0
  100. package/dist/client/assets/{diagram-Z3DM3KII-CuMI1k1t.js → diagram-Z3DM3KII-Br2tE-aw.js} +1 -1
  101. package/dist/client/assets/diagram-Z3DM3KII-Br2tE-aw.js.br +0 -0
  102. package/dist/client/assets/diagram-Z3DM3KII-Br2tE-aw.js.gz +0 -0
  103. package/dist/client/assets/{ebnfDiagram-PWID7BFC-Di8RxhNL.js → ebnfDiagram-PWID7BFC-CLERVjPA.js} +1 -1
  104. package/dist/client/assets/ebnfDiagram-PWID7BFC-CLERVjPA.js.br +0 -0
  105. package/dist/client/assets/ebnfDiagram-PWID7BFC-CLERVjPA.js.gz +0 -0
  106. package/dist/client/assets/{erDiagram-RLTQ6QDP-C1wPuBtH.js → erDiagram-RLTQ6QDP-CdjRSsSD.js} +1 -1
  107. package/dist/client/assets/erDiagram-RLTQ6QDP-CdjRSsSD.js.br +0 -0
  108. package/dist/client/assets/erDiagram-RLTQ6QDP-CdjRSsSD.js.gz +0 -0
  109. package/dist/client/assets/{flowDiagram-HODETNUW-D0SIEpUy.js → flowDiagram-HODETNUW-CJcQ479Z.js} +1 -1
  110. package/dist/client/assets/flowDiagram-HODETNUW-CJcQ479Z.js.br +0 -0
  111. package/dist/client/assets/flowDiagram-HODETNUW-CJcQ479Z.js.gz +0 -0
  112. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DgeD2fKd.js → ganttDiagram-EL5Y4UJY-CdDCSJ3h.js} +1 -1
  113. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CdDCSJ3h.js.br +0 -0
  114. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CdDCSJ3h.js.gz +0 -0
  115. package/dist/client/assets/{gestureArbiter-Xl7awIrX.js → gestureArbiter-D6uN_O0i.js} +1 -1
  116. package/dist/client/assets/gestureArbiter-D6uN_O0i.js.br +0 -0
  117. package/dist/client/assets/gestureArbiter-D6uN_O0i.js.gz +0 -0
  118. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CzFKSKK_.js → gitGraphDiagram-WWUBYQGX-tcLWvosg.js} +1 -1
  119. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tcLWvosg.js.br +0 -0
  120. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tcLWvosg.js.gz +0 -0
  121. package/dist/client/assets/index-_7yzQpVq.css +1 -0
  122. package/dist/client/assets/index-_7yzQpVq.css.br +0 -0
  123. package/dist/client/assets/{index-BObjbh2R.css.gz → index-_7yzQpVq.css.gz} +0 -0
  124. package/dist/client/assets/{infoDiagram-27XIBGKW-C9mmJGhv.js → infoDiagram-27XIBGKW-D7ze39D4.js} +1 -1
  125. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-D9uVb4Og.js → ishikawaDiagram-5VMMS53U-BmvDG55X.js} +1 -1
  126. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BmvDG55X.js.br +0 -0
  127. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BmvDG55X.js.gz +0 -0
  128. package/dist/client/assets/{journeyDiagram-3NMN7TZE-BMKNUyUx.js → journeyDiagram-3NMN7TZE-Ba2oQRdr.js} +1 -1
  129. package/dist/client/assets/journeyDiagram-3NMN7TZE-Ba2oQRdr.js.br +0 -0
  130. package/dist/client/assets/journeyDiagram-3NMN7TZE-Ba2oQRdr.js.gz +0 -0
  131. package/dist/client/assets/{kanban-definition-UXKFOSKX-8i7nyqix.js → kanban-definition-UXKFOSKX-BGrEtfSU.js} +1 -1
  132. package/dist/client/assets/{kanban-definition-UXKFOSKX-8i7nyqix.js.br → kanban-definition-UXKFOSKX-BGrEtfSU.js.br} +0 -0
  133. package/dist/client/assets/kanban-definition-UXKFOSKX-BGrEtfSU.js.gz +0 -0
  134. package/dist/client/assets/{layout-BS5SCHbc.js → layout-Df_WxQ7_.js} +1 -1
  135. package/dist/client/assets/layout-Df_WxQ7_.js.br +0 -0
  136. package/dist/client/assets/layout-Df_WxQ7_.js.gz +0 -0
  137. package/dist/client/assets/{linear-fo2zkK6T.js → linear-yjCZ1UPt.js} +1 -1
  138. package/dist/client/assets/{linear-fo2zkK6T.js.br → linear-yjCZ1UPt.js.br} +0 -0
  139. package/dist/client/assets/linear-yjCZ1UPt.js.gz +0 -0
  140. package/dist/client/assets/{mermaid.core-B8k3pAmc.js → mermaid.core-wqB76PXA.js} +5 -5
  141. package/dist/client/assets/mermaid.core-wqB76PXA.js.br +0 -0
  142. package/dist/client/assets/mermaid.core-wqB76PXA.js.gz +0 -0
  143. package/dist/client/assets/{mindmap-definition-YA3MSWOX-BwgQTj2Q.js → mindmap-definition-YA3MSWOX-BvFfuDI9.js} +1 -1
  144. package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFfuDI9.js.br +0 -0
  145. package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFfuDI9.js.gz +0 -0
  146. package/dist/client/assets/{passwordBootstrap-DvQk0qYt.js → passwordBootstrap-CeMHRTET.js} +1 -1
  147. package/dist/client/assets/passwordBootstrap-CeMHRTET.js.br +0 -0
  148. package/dist/client/assets/passwordBootstrap-CeMHRTET.js.gz +0 -0
  149. package/dist/client/assets/{pegDiagram-XKGWAZYB-CumSoxLr.js → pegDiagram-XKGWAZYB-GFNFRFcn.js} +1 -1
  150. package/dist/client/assets/pegDiagram-XKGWAZYB-GFNFRFcn.js.br +0 -0
  151. package/dist/client/assets/pegDiagram-XKGWAZYB-GFNFRFcn.js.gz +0 -0
  152. package/dist/client/assets/{pieDiagram-E7YTZNPT-Dc3txkBL.js → pieDiagram-E7YTZNPT-i_OnIQ5S.js} +1 -1
  153. package/dist/client/assets/pieDiagram-E7YTZNPT-i_OnIQ5S.js.br +0 -0
  154. package/dist/client/assets/pieDiagram-E7YTZNPT-i_OnIQ5S.js.gz +0 -0
  155. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-D92mwZnT.js → quadrantDiagram-AXDQQJYC-DgclfhW2.js} +1 -1
  156. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DgclfhW2.js.br +0 -0
  157. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DgclfhW2.js.gz +0 -0
  158. package/dist/client/assets/{railroadDiagram-O6MQD6OU-O1UOZ30Y.js → railroadDiagram-O6MQD6OU-Bta7NOF1.js} +1 -1
  159. package/dist/client/assets/railroadDiagram-O6MQD6OU-Bta7NOF1.js.br +0 -0
  160. package/dist/client/assets/railroadDiagram-O6MQD6OU-Bta7NOF1.js.gz +0 -0
  161. package/dist/client/assets/{rdpSession-Dr_tPwzx.js → rdpSession-CVTDBhDb.js} +1 -1
  162. package/dist/client/assets/rdpSession-CVTDBhDb.js.br +0 -0
  163. package/dist/client/assets/rdpSession-CVTDBhDb.js.gz +0 -0
  164. package/dist/client/assets/{referenceLongPress-YuGU-PYw.js → referenceLongPress-C91ZK5h8.js} +1 -1
  165. package/dist/client/assets/referenceLongPress-C91ZK5h8.js.br +0 -0
  166. package/dist/client/assets/referenceLongPress-C91ZK5h8.js.gz +0 -0
  167. package/dist/client/assets/{requirementDiagram-BXWQKSXE-uD1cgrxA.js → requirementDiagram-BXWQKSXE-CjVvykFZ.js} +1 -1
  168. package/dist/client/assets/requirementDiagram-BXWQKSXE-CjVvykFZ.js.br +0 -0
  169. package/dist/client/assets/requirementDiagram-BXWQKSXE-CjVvykFZ.js.gz +0 -0
  170. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CIJE4-pc.js → sankeyDiagram-P5KCCOFB-DkRiE5xj.js} +1 -1
  171. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DkRiE5xj.js.br +0 -0
  172. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DkRiE5xj.js.gz +0 -0
  173. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-BT6LG37W.js → sequenceDiagram-WJ2MYXX4-BW-TiTTz.js} +1 -1
  174. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BW-TiTTz.js.br +0 -0
  175. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BW-TiTTz.js.gz +0 -0
  176. package/dist/client/assets/{sizeCapture-INFHLROL-DoYY94Rj.js → sizeCapture-INFHLROL-CknYHWYz.js} +1 -1
  177. package/dist/client/assets/sizeCapture-INFHLROL-CknYHWYz.js.br +0 -0
  178. package/dist/client/assets/sizeCapture-INFHLROL-CknYHWYz.js.gz +0 -0
  179. package/dist/client/assets/{sparkles-DFYGpezN.js → sparkles-BhmNaa1u.js} +1 -1
  180. package/dist/client/assets/{stateDiagram-D77RDMKH-C4xmgR_-.js → stateDiagram-D77RDMKH-do6p3u1y.js} +1 -1
  181. package/dist/client/assets/stateDiagram-D77RDMKH-do6p3u1y.js.br +0 -0
  182. package/dist/client/assets/stateDiagram-D77RDMKH-do6p3u1y.js.gz +0 -0
  183. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CBBKJJkB.js +1 -0
  184. package/dist/client/assets/{swimlanes-42K2YHIH-mRdmZmAA.js → swimlanes-42K2YHIH-BloliwwH.js} +1 -1
  185. package/dist/client/assets/swimlanes-42K2YHIH-BloliwwH.js.br +0 -0
  186. package/dist/client/assets/swimlanes-42K2YHIH-BloliwwH.js.gz +0 -0
  187. package/dist/client/assets/swimlanesDiagram-VR7AAH4N--bexkZyM.js +8 -0
  188. package/dist/client/assets/{timeline-definition-24CTP7MA-BFFrD5kR.js → timeline-definition-24CTP7MA-DelADR0N.js} +1 -1
  189. package/dist/client/assets/timeline-definition-24CTP7MA-DelADR0N.js.br +0 -0
  190. package/dist/client/assets/timeline-definition-24CTP7MA-DelADR0N.js.gz +0 -0
  191. package/dist/client/assets/{triangle-alert-BwJ6Q_Y0.js → triangle-alert-B5d_l343.js} +1 -1
  192. package/dist/client/assets/{vennDiagram-4TSXK5OY-Dy59OxIM.js → vennDiagram-4TSXK5OY-BJhlRAwF.js} +1 -1
  193. package/dist/client/assets/{vennDiagram-4TSXK5OY-Dy59OxIM.js.br → vennDiagram-4TSXK5OY-BJhlRAwF.js.br} +0 -0
  194. package/dist/client/assets/vennDiagram-4TSXK5OY-BJhlRAwF.js.gz +0 -0
  195. package/dist/client/assets/{videoCompression-DrQ47oZA.js → videoCompression-CuDMhYU3.js} +1 -1
  196. package/dist/client/assets/videoCompression-CuDMhYU3.js.br +0 -0
  197. package/dist/client/assets/videoCompression-CuDMhYU3.js.gz +0 -0
  198. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-B-BKlX7o.js → wardleyDiagram-VM6X3IG4-3MDCa0Rt.js} +1 -1
  199. package/dist/client/assets/wardleyDiagram-VM6X3IG4-3MDCa0Rt.js.br +0 -0
  200. package/dist/client/assets/wardleyDiagram-VM6X3IG4-3MDCa0Rt.js.gz +0 -0
  201. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-79qktI_4.js → xychartDiagram-S5SC5T6Z-LWuDetCo.js} +1 -1
  202. package/dist/client/assets/xychartDiagram-S5SC5T6Z-LWuDetCo.js.br +0 -0
  203. package/dist/client/assets/xychartDiagram-S5SC5T6Z-LWuDetCo.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.js +1 -1
  208. package/dist/client/sw.js.br +0 -0
  209. package/dist/client/sw.js.gz +0 -0
  210. package/dist/server/agent/collaborationStore.js +83 -7
  211. package/dist/server/agent/collaborationTeam.js +11 -4
  212. package/dist/server/agent/integrationCli.js +49 -4
  213. package/dist/server/agent/integrationServer.js +14 -2
  214. package/dist/server/routes/terminal.js +12 -6
  215. package/docs/integrations.md +80 -4
  216. package/package.json +1 -1
  217. package/runtime-manifest.json +3 -3
  218. package/dist/client/assets/App-BF_s1-_u.js +0 -186
  219. package/dist/client/assets/App-BF_s1-_u.js.br +0 -0
  220. package/dist/client/assets/App-BF_s1-_u.js.gz +0 -0
  221. package/dist/client/assets/ArchitecturePanel-CdgUQsVD.js.br +0 -0
  222. package/dist/client/assets/ArchitecturePanel-CdgUQsVD.js.gz +0 -0
  223. package/dist/client/assets/ChangeWalkthroughPanel-DHp5r1k9.js.br +0 -0
  224. package/dist/client/assets/ChangeWalkthroughPanel-DHp5r1k9.js.gz +0 -0
  225. package/dist/client/assets/CollaborationMainWorkspace-P_jXjsT-.js.br +0 -0
  226. package/dist/client/assets/CollaborationMainWorkspace-P_jXjsT-.js.gz +0 -0
  227. package/dist/client/assets/CollaborationTaskContent-DSkxOlKQ.js +0 -2
  228. package/dist/client/assets/ComputerControlView-B5Yng8Dt.js.br +0 -0
  229. package/dist/client/assets/ComputerControlView-B5Yng8Dt.js.gz +0 -0
  230. package/dist/client/assets/DagPlayground-rZE40fcL.js.br +0 -0
  231. package/dist/client/assets/DagPlayground-rZE40fcL.js.gz +0 -0
  232. package/dist/client/assets/DiffLab-3sIn0W3p.js.br +0 -0
  233. package/dist/client/assets/DiffLab-3sIn0W3p.js.gz +0 -0
  234. package/dist/client/assets/DiffReview-CBf8-Tli.js.br +0 -0
  235. package/dist/client/assets/DiffReview-CBf8-Tli.js.gz +0 -0
  236. package/dist/client/assets/DiffReviewLab-BXhskTlx.js.br +0 -0
  237. package/dist/client/assets/DiffReviewLab-BXhskTlx.js.gz +0 -0
  238. package/dist/client/assets/DiffViewer-DZfgjOBh.js.br +0 -0
  239. package/dist/client/assets/DiffViewer-DZfgjOBh.js.gz +0 -0
  240. package/dist/client/assets/ModelPreview-Bzdi_sPh.js.br +0 -0
  241. package/dist/client/assets/ModelPreview-Bzdi_sPh.js.gz +0 -0
  242. package/dist/client/assets/RightSidebar-DaRdlJzn.js.br +0 -0
  243. package/dist/client/assets/RightSidebar-DaRdlJzn.js.gz +0 -0
  244. package/dist/client/assets/abnfDiagram-VCTEODGH-CarKrfAf.js.br +0 -0
  245. package/dist/client/assets/abnfDiagram-VCTEODGH-CarKrfAf.js.gz +0 -0
  246. package/dist/client/assets/app-BCTEfclM.js.br +0 -0
  247. package/dist/client/assets/app-BCTEfclM.js.gz +0 -0
  248. package/dist/client/assets/arc-B6Qdq2Vw.js.br +0 -0
  249. package/dist/client/assets/arc-B6Qdq2Vw.js.gz +0 -0
  250. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgPJ0l9i.js.br +0 -0
  251. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgPJ0l9i.js.gz +0 -0
  252. package/dist/client/assets/blockDiagram-I7D4REHJ-BsorvNo4.js.br +0 -0
  253. package/dist/client/assets/blockDiagram-I7D4REHJ-BsorvNo4.js.gz +0 -0
  254. package/dist/client/assets/c4Diagram-7LVT6UL2-Bbpi62ab.js.br +0 -0
  255. package/dist/client/assets/c4Diagram-7LVT6UL2-Bbpi62ab.js.gz +0 -0
  256. package/dist/client/assets/channel-uZtI4GD8.js +0 -1
  257. package/dist/client/assets/chunk-F27PBJKO-fe9Yw7OI.js.br +0 -0
  258. package/dist/client/assets/chunk-F27PBJKO-fe9Yw7OI.js.gz +0 -0
  259. package/dist/client/assets/chunk-IMKFNOWR-QquKV9k-.js.br +0 -0
  260. package/dist/client/assets/chunk-IMKFNOWR-QquKV9k-.js.gz +0 -0
  261. package/dist/client/assets/chunk-SVP7TREG-BUQulipE.js.br +0 -0
  262. package/dist/client/assets/chunk-SVP7TREG-BUQulipE.js.gz +0 -0
  263. package/dist/client/assets/chunk-TICWLB2K-fubKwUCg.js.br +0 -0
  264. package/dist/client/assets/chunk-TICWLB2K-fubKwUCg.js.gz +0 -0
  265. package/dist/client/assets/classDiagram-ZZMXUADV-CgJJ1J4J.js +0 -1
  266. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CgJJ1J4J.js +0 -1
  267. package/dist/client/assets/cose-bilkent-JH36ORCC-DmEDc2ee.js.br +0 -0
  268. package/dist/client/assets/cose-bilkent-JH36ORCC-DmEDc2ee.js.gz +0 -0
  269. package/dist/client/assets/cynefin-OW5HDTMX-C-mfarRX.js.br +0 -0
  270. package/dist/client/assets/cynefin-OW5HDTMX-C-mfarRX.js.gz +0 -0
  271. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CgVmp8od.js.br +0 -0
  272. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CgVmp8od.js.gz +0 -0
  273. package/dist/client/assets/dagre-GXQ25YYZ-WU_d2fSU.js.br +0 -0
  274. package/dist/client/assets/dagre-GXQ25YYZ-WU_d2fSU.js.gz +0 -0
  275. package/dist/client/assets/diagram-S7CK7UJ4-Dtikk80Z.js.br +0 -0
  276. package/dist/client/assets/diagram-S7CK7UJ4-Dtikk80Z.js.gz +0 -0
  277. package/dist/client/assets/diagram-UQ7AKVKN-DuTCB36P.js.br +0 -0
  278. package/dist/client/assets/diagram-UQ7AKVKN-DuTCB36P.js.gz +0 -0
  279. package/dist/client/assets/diagram-VSXAHHWV-DSLAcWi6.js.br +0 -0
  280. package/dist/client/assets/diagram-VSXAHHWV-DSLAcWi6.js.gz +0 -0
  281. package/dist/client/assets/diagram-VX7I27RA-DyQOu10m.js.br +0 -0
  282. package/dist/client/assets/diagram-VX7I27RA-DyQOu10m.js.gz +0 -0
  283. package/dist/client/assets/diagram-Z3DM3KII-CuMI1k1t.js.br +0 -0
  284. package/dist/client/assets/diagram-Z3DM3KII-CuMI1k1t.js.gz +0 -0
  285. package/dist/client/assets/ebnfDiagram-PWID7BFC-Di8RxhNL.js.br +0 -0
  286. package/dist/client/assets/ebnfDiagram-PWID7BFC-Di8RxhNL.js.gz +0 -0
  287. package/dist/client/assets/erDiagram-RLTQ6QDP-C1wPuBtH.js.br +0 -0
  288. package/dist/client/assets/erDiagram-RLTQ6QDP-C1wPuBtH.js.gz +0 -0
  289. package/dist/client/assets/flowDiagram-HODETNUW-D0SIEpUy.js.br +0 -0
  290. package/dist/client/assets/flowDiagram-HODETNUW-D0SIEpUy.js.gz +0 -0
  291. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DgeD2fKd.js.br +0 -0
  292. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DgeD2fKd.js.gz +0 -0
  293. package/dist/client/assets/gestureArbiter-Xl7awIrX.js.br +0 -0
  294. package/dist/client/assets/gestureArbiter-Xl7awIrX.js.gz +0 -0
  295. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CzFKSKK_.js.br +0 -0
  296. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CzFKSKK_.js.gz +0 -0
  297. package/dist/client/assets/index-BObjbh2R.css +0 -1
  298. package/dist/client/assets/index-BObjbh2R.css.br +0 -0
  299. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D9uVb4Og.js.br +0 -0
  300. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D9uVb4Og.js.gz +0 -0
  301. package/dist/client/assets/journeyDiagram-3NMN7TZE-BMKNUyUx.js.br +0 -0
  302. package/dist/client/assets/journeyDiagram-3NMN7TZE-BMKNUyUx.js.gz +0 -0
  303. package/dist/client/assets/kanban-definition-UXKFOSKX-8i7nyqix.js.gz +0 -0
  304. package/dist/client/assets/layout-BS5SCHbc.js.br +0 -0
  305. package/dist/client/assets/layout-BS5SCHbc.js.gz +0 -0
  306. package/dist/client/assets/linear-fo2zkK6T.js.gz +0 -0
  307. package/dist/client/assets/mermaid.core-B8k3pAmc.js.br +0 -0
  308. package/dist/client/assets/mermaid.core-B8k3pAmc.js.gz +0 -0
  309. package/dist/client/assets/mindmap-definition-YA3MSWOX-BwgQTj2Q.js.br +0 -0
  310. package/dist/client/assets/mindmap-definition-YA3MSWOX-BwgQTj2Q.js.gz +0 -0
  311. package/dist/client/assets/passwordBootstrap-DvQk0qYt.js.br +0 -0
  312. package/dist/client/assets/passwordBootstrap-DvQk0qYt.js.gz +0 -0
  313. package/dist/client/assets/pegDiagram-XKGWAZYB-CumSoxLr.js.br +0 -0
  314. package/dist/client/assets/pegDiagram-XKGWAZYB-CumSoxLr.js.gz +0 -0
  315. package/dist/client/assets/pieDiagram-E7YTZNPT-Dc3txkBL.js.br +0 -0
  316. package/dist/client/assets/pieDiagram-E7YTZNPT-Dc3txkBL.js.gz +0 -0
  317. package/dist/client/assets/quadrantDiagram-AXDQQJYC-D92mwZnT.js.br +0 -0
  318. package/dist/client/assets/quadrantDiagram-AXDQQJYC-D92mwZnT.js.gz +0 -0
  319. package/dist/client/assets/railroadDiagram-O6MQD6OU-O1UOZ30Y.js.br +0 -0
  320. package/dist/client/assets/railroadDiagram-O6MQD6OU-O1UOZ30Y.js.gz +0 -0
  321. package/dist/client/assets/rdpSession-Dr_tPwzx.js.br +0 -0
  322. package/dist/client/assets/rdpSession-Dr_tPwzx.js.gz +0 -0
  323. package/dist/client/assets/referenceLongPress-YuGU-PYw.js.br +0 -0
  324. package/dist/client/assets/referenceLongPress-YuGU-PYw.js.gz +0 -0
  325. package/dist/client/assets/requirementDiagram-BXWQKSXE-uD1cgrxA.js.br +0 -0
  326. package/dist/client/assets/requirementDiagram-BXWQKSXE-uD1cgrxA.js.gz +0 -0
  327. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CIJE4-pc.js.br +0 -0
  328. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CIJE4-pc.js.gz +0 -0
  329. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BT6LG37W.js.br +0 -0
  330. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BT6LG37W.js.gz +0 -0
  331. package/dist/client/assets/sizeCapture-INFHLROL-DoYY94Rj.js.br +0 -0
  332. package/dist/client/assets/sizeCapture-INFHLROL-DoYY94Rj.js.gz +0 -0
  333. package/dist/client/assets/stateDiagram-D77RDMKH-C4xmgR_-.js.br +0 -0
  334. package/dist/client/assets/stateDiagram-D77RDMKH-C4xmgR_-.js.gz +0 -0
  335. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BLHH60cg.js +0 -1
  336. package/dist/client/assets/swimlanes-42K2YHIH-mRdmZmAA.js.br +0 -0
  337. package/dist/client/assets/swimlanes-42K2YHIH-mRdmZmAA.js.gz +0 -0
  338. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-D-lNPW5d.js +0 -8
  339. package/dist/client/assets/timeline-definition-24CTP7MA-BFFrD5kR.js.br +0 -0
  340. package/dist/client/assets/timeline-definition-24CTP7MA-BFFrD5kR.js.gz +0 -0
  341. package/dist/client/assets/vennDiagram-4TSXK5OY-Dy59OxIM.js.gz +0 -0
  342. package/dist/client/assets/videoCompression-DrQ47oZA.js.br +0 -0
  343. package/dist/client/assets/videoCompression-DrQ47oZA.js.gz +0 -0
  344. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-BKlX7o.js.br +0 -0
  345. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-BKlX7o.js.gz +0 -0
  346. package/dist/client/assets/xychartDiagram-S5SC5T6Z-79qktI_4.js.br +0 -0
  347. package/dist/client/assets/xychartDiagram-S5SC5T6Z-79qktI_4.js.gz +0 -0
@@ -0,0 +1,186 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-CuDMhYU3.js","assets/app-CI3Oh-41.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-_7yzQpVq.css","assets/CollaborationTaskContent-BwHxwcOP.js","assets/RightSidebar-CXykcIPb.js","assets/gestureArbiter-D6uN_O0i.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-C1TyvrA9.js","assets/sparkles-BhmNaa1u.js","assets/DiffViewer-ByAlz2NG.js","assets/referenceLongPress-C91ZK5h8.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-B5d_l343.js","assets/ChangeWalkthroughPanel-B0JYVVwB.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-BJzMdyZc.js"])))=>i.map(i=>d[i]);
2
+ import{ag as Ut,aN as Ku,by as s,ac as hc,da as Ur,H as Xw,dk as sl,d6 as La,d8 as Kn,b1 as fc,a7 as eh,az as by,bp as j1,cN as Jw,d7 as N0,cy as f0,b6 as vo,j as p0,af as Fu,co as wp,cV as e8,as as Dc,bx as Cu,g as t8,cI as Ph,Z as r8,bb as Qm,bI as Pm,cE as n8,ax as s8,ch as i8,a5 as yy,cf as a8,cC as vy,aa as o8,ah as l8,L as _n,C as pi,X as In,f as c8,d as ul,bg as u8,b0 as Om,dc as d8,dh as Yr,bG as D1,dg as Wt,aD as h8,dq as f8,v as p8,bN as m8,c0 as g8,a4 as ka,bR as x8,cA as tx,cB as rx,cD as nx,W as sx,b$ as b8,cO as y8,t as n0,bo as B1,d5 as v8,_ as Oc,b9 as w8,i as A8,dj as wy,a_ as il,T as $o,db as Gc,df as T8,ci as S8,an as C8,aY as _8,bZ as k8,b_ as L8,P as Ay,V as ix,bO as ax,bA as Ty,n as zs,$ as Oh,cW as Ap,bH as I8,ck as E8,bF as Sy,de as N8,bf as Po,dm as R8,B as cc,e as Ks,u as M8,ak as j8,N as Fm,cv as D8,h as To,bt as B8,bu as Q8,ap as Cy,aB as _y,a6 as Iu,m as ju,cs as Ml,c2 as ky,aw as s0,c as $m,d9 as Ly,aJ as P8,S as sf,bm as af,a as Iy,ar as O8,ae as F8,d3 as $8,c3 as $u,a8 as uc,bE as ox,cz as U8,c7 as Ey,cS as z8,cU as Ny,bB as H8,bD as Q1,cG as W8,cH as G8,c4 as V8,cF as q8,cp as Y8,cm as Z8,cj as K8,c6 as X8,cw as J8,bQ as e9,bP as Ry,cr as t9,bC as lx,aH as r9,a$ as n9,D as s9,aG as cx,bK as i9,q as a9,p as o9,bM as l9,F as c9,c5 as u9,l as d9,cx as h9,r as f9,c1 as p9,au as m9,aA as g9,aC as x9,ba as fd,bk as b9,d0 as y9,bl as v9,ao as w9,d2 as A9,Q as T9,aj as S9,ad as C9,A as _9,b8 as k9,aq as L9,M as I9,di as E9,bT as Tc,b5 as N9,b2 as R9,b3 as M9,b4 as j9,aW as Tp,bU as D9,cb as B9,cl as Q9,b7 as P9,aZ as O9,cT as ux,am as F9,a9 as $9,Y as U9,c_ as z9,dn as Fn,cu as Sc,bS as H9,w as W9,cQ as G9,aV as V9,bc as dx,ca as q9,cM as th,cZ as pd,d1 as Y9,cc as Z9,cR as K9,cJ as X9,cY as Sp,cK as J9,cL as eA,dd as tA,al as rA,bJ as nA,bw as rh,bv as sA,c8 as hx,cd as iA,c9 as uu,ce as aA,a3 as oA,ab as lA,s as cA}from"./app-CI3Oh-41.js";import{b,R as k,r as Xs,a as uA}from"./dnd-BCFAPC0L.js";import{b as dA,c as hA,F as Vc,S as fA,e as pA,h as mA,r as gA,y as xA,d as bA,u as yA}from"./gestureArbiter-D6uN_O0i.js";import{L as vA,l as wA}from"./terminal-C7X98Amf.js";import{T as P1,L as Uu,C as zu,M as AA,G as TA}from"./triangle-alert-B5d_l343.js";import{r as SA}from"./react-XDCjal2T.js";import{u as O1,G as CA}from"./referenceLongPress-C91ZK5h8.js";const _A=[["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"}]],My=Ut("archive",_A);const kA=[["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"}]],LA=Ut("arrow-down-a-z",kA);const IA=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],EA=Ut("arrow-down",IA);const NA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],jy=Ut("arrow-up",NA);const RA=[["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"}]],Dy=Ut("bell",RA);const MA=[["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"}]],R0=Ut("bot",MA);const jA=[["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"}]],DA=Ut("box",jA);const BA=[["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"}]],QA=Ut("cable",BA);const PA=[["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"}]],OA=Ut("calendar-clock",PA);const FA=[["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"}]],$A=Ut("camera",FA);const UA=[["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"}]],zA=Ut("chart-bar",UA);const HA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],WA=Ut("circle-dot",HA);const GA=[["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"}]],of=Ut("circle-question-mark",GA);const VA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hu=Ut("circle",VA);const qA=[["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"}]],YA=Ut("clipboard-paste",qA);const ZA=[["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"}]],By=Ut("clipboard",ZA);const KA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],m0=Ut("clock-3",KA);const XA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],JA=Ut("clock",XA);const eT=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],tT=Ut("code",eT);const rT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Il=Ut("columns-2",rT);const nT=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],sT=Ut("corner-down-left",nT);const iT=[["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"}]],g0=Ut("download",iT);const aT=[["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"}]],Fc=Ut("external-link",aT);const oT=[["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"}]],lT=Ut("file-code",oT);const cT=[["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"}]],uT=Ut("file-up",cT);const dT=[["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"}]],Qy=Ut("file",dT);const hT=[["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"}]],Du=Ut("folder-open",hT);const fT=[["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"}]],F1=Ut("folder-search",fT);const pT=[["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"}]],mT=Ut("folder-tree",pT);const gT=[["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"}]],fx=Ut("grid-2x2",gT);const xT=[["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"}]],$f=Ut("grip-vertical",xT);const bT=[["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"}]],yT=Ut("hash",bT);const vT=[["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"}]],Qc=Ut("history",vT);const wT=[["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"}]],AT=Ut("house",wT);const TT=[["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"}]],Py=Ut("keyboard",TT);const ST=[["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"}]],Oy=Ut("layers",ST);const CT=[["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"}]],_T=Ut("layout-dashboard",CT);const kT=[["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"}]],qc=Ut("layout-grid",kT);const LT=[["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"}]],IT=Ut("maximize",LT);const ET=[["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"}]],Xu=Ut("message-circle",ET);const NT=[["path",{d:"M5 12h14",key:"1ays0h"}]],Fy=Ut("minus",NT);const RT=[["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"}]],MT=Ut("minimize",RT);const jT=[["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"}]],DT=Ut("monitor-smartphone",jT);const BT=[["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"}]],QT=Ut("moon",BT);const PT=[["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"}]],OT=Ut("move",PT);const FT=[["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"}]],$T=Ut("network",FT);const UT=[["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"}]],zT=Ut("panel-right-close",UT);const HT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],WT=Ut("panel-left",HT);const GT=[["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"}]],VT=Ut("panel-right-open",GT);const qT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],$y=Ut("panel-right",qT);const YT=[["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"}]],ZT=Ut("paperclip",YT);const KT=[["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"}]],XT=Ut("pause",KT);const JT=[["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"}]],eS=Ut("pen-line",JT);const tS=[["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"}]],rS=Ut("pencil-line",tS);const nS=[["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"}]],x0=Ut("pin",nS);const sS=[["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"}]],b0=Ut("pin-off",sS);const iS=[["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"}]],lf=Ut("play",iS);const aS=[["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"}]],oS=Ut("plug",aS);const lS=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],cS=Ut("power",lS);const uS=[["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"}]],bn=Ut("refresh-cw",uS);const dS=[["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"}]],Uy=Ut("rotate-ccw",dS);const hS=[["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"}]],fS=Ut("rotate-cw",hS);const pS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],px=Ut("rows-2",pS);const mS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],jl=Ut("search",mS);const gS=[["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"}]],i0=Ut("send",gS);const xS=[["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"}]],bS=Ut("settings",xS);const yS=[["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"}]],vS=Ut("shield-alert",yS);const wS=[["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"}]],AS=Ut("shield-check",wS);const TS=[["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"}]],Um=Ut("sliders-horizontal",TS);const SS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],zy=Ut("square",SS);const CS=[["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"}]],_S=Ut("stethoscope",CS);const kS=[["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"}]],LS=Ut("sun",kS);const IS=[["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"}]],Rs=Ut("trash-2",IS);const ES=[["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"}]],NS=Ut("type",ES);const RS=[["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"}]],MS=Ut("unlink",RS);const jS=[["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"}]],Hy=Ut("unplug",jS);const DS=[["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"}]],Wy=Ut("video",DS);const BS=[["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"}]],QS=Ut("volume-1",BS);const PS=[["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"}]],OS=Ut("volume-2",PS);const FS=[["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"}]],$S=Ut("wand-sparkles",FS);const US=[["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"}]],nh=Ut("workflow",US);function zS(e,t){return e==="webgl"&&t}function Gy(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 p=a.get(d);p||(p={key:d,label:d?Ku(d)??d:r,sessions:[]},a.set(d,p),n.push(p)),p.sessions.push(c)}return n.sort((c,l)=>(c.key===""?1:0)-(l.key===""?1:0))}function HS(e){return e&&e.trim().length>0?e:""}function Vy(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 qy(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 cf(e,t,r,n,a=[],c=[]){const l=new Map(e.map(S=>[S.id,S])),d=qy(c,new Set(l.keys())),p=new Map,m=new Map,x=a.filter(S=>S.sessionIds.length>=2&&S.sessionIds.every(L=>l.has(L))),y=(S,L)=>{const E=l.get(L);S.forEach(R=>{p.set(R,S),m.set(R,E)})};for(const S of d){const L=new Set(S.sessionIds),E=new Map;for(const z of x)z.sessionIds.every(O=>L.has(O))&&z.sessionIds.forEach(O=>E.set(O,z.sessionIds));const R=new Set,B=S.sessionIds.flatMap(z=>{if(R.has(z))return[];const O=E.get(z)??[z];return O.forEach($=>R.add($)),O});y(B,S.sessionIds[0])}for(const S of x)S.sessionIds.some(L=>p.has(L))||y(S.sessionIds,S.sessionIds[0]);const w=S=>{const L=new Set;return S.flatMap(E=>{if(L.has(E.id))return[];const R=p.get(E.id)??[E.id];return R.forEach(B=>L.add(B)),R.map(B=>l.get(B))})};if(!r)return{arranged:w(e),groups:[]};const v=Gy(e,S=>t(m.get(S.id)??S),n).map(S=>({...S,sessions:w(S.sessions)}));return{arranged:v.flatMap(S=>S.sessions),groups:v}}function WS(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function GS(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function VS(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function qS(e,t){return!e&&t}const uf=".termdock/architecture.json",Yy=".termdock/architectures",YS={kind:"project",target:"",paths:[],depth:"boundary",focus:""},ZS=["description","diagram","context","constraint","concern","todo","note"],KS=/^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/;class XS extends Error{}function hs(){throw new XS("Invalid architecture document")}function Cl(e){return(!e||typeof e!="object"||Array.isArray(e))&&hs(),e}function oi(e,t=8e3){return(typeof e!="string"||e.length>t)&&hs(),e}function Cc(e){const t=oi(e,80);return KS.test(t)||hs(),t}function rc(e,t){return(!Array.isArray(e)||e.length>t)&&hs(),e}function mx(e){return Object.fromEntries(ZS.filter(t=>e[t]!==void 0).map(t=>[t,oi(e[t],1e5)]))}function du(e){if(e===void 0)return;const t=Cl(e),r={};for(const n of["created","updated","gitCommit","gitBranch","previousDiagram"])t[n]!==void 0&&(r[n]=oi(t[n],n==="previousDiagram"?1e5:200));return t.updateCount!==void 0&&((!Number.isSafeInteger(t.updateCount)||t.updateCount<0)&&hs(),r.updateCount=t.updateCount),r}function Fh(e){return!!e&&!/[:\\\x00-\x1f]/.test(e)&&!e.startsWith("/")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function $1(e){(!["project","module","feature"].includes(e.kind)||!["boundary","dependencies"].includes(e.depth))&&hs();const t=e.kind==="project"?[]:[...new Set(rc(e.paths,20).map(a=>oi(a,1024).trim()))].sort();t.some(a=>!Fh(a))&&hs();const r=oi(e.target,1e3).trim(),n=oi(e.focus,2e3).trim();return(e.kind==="module"&&!t.length||e.kind==="feature"&&!r)&&hs(),{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 JS(e){const t=$1(e);if(t.kind==="project")return uf;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`${Yy}/${t.kind}-${a}-${(n>>>0).toString(16).padStart(8,"0")}.json`}function Zy(e){return e===".omm"||e===uf||new RegExp(`^${Yy.replace(".","\\.")}/(?:module|feature)-[\\p{L}\\p{N}_-]{1,48}-[a-f0-9]{8}\\.json$`,"u").test(e)}function Z$(e){return e.split("/").pop()?.replace(/^(module|feature)-/,"").replace(/-[a-f0-9]{8}\.json$/,"").replace(/-/g," ")??e}function K$(e){new TextEncoder().encode(e).byteLength>5e6&&hs();let t;try{t=JSON.parse(e)}catch{hs()}const r=Cl(t);r.version!==1&&hs();const n=oi(r.generatedAt,80);Number.isFinite(Date.parse(n))||hs();const a=rc(r.perspectives,12).map(d=>{const p=Cl(d),m=rc(p.nodes,200).map(w=>{const v=Cl(w),S=rc(v.files,40).map(E=>{const R=Cl(E),B=oi(R.path,1024);return Fh(B)||hs(),R.line!==void 0&&(!Number.isSafeInteger(R.line)||R.line<1)&&hs(),{path:B,...R.line!==void 0?{line:R.line}:{}}}),L=v.references===void 0?void 0:rc(v.references,100).map(E=>{const R=Cl(E);return{perspective:Cc(R.perspective),...R.node!==void 0?{node:Cc(R.node)}:{}}});return v.documentPath!==void 0&&!Fh(oi(v.documentPath,1024))&&hs(),v.role!==void 0&&!["external","concern","entry","store"].includes(v.role)&&hs(),{id:Cc(v.id),title:oi(v.title,160),summary:oi(v.summary),files:S,...mx(v),...v.parentId!==void 0?{parentId:Cc(v.parentId)}:{},...v.documentPath!==void 0?{documentPath:oi(v.documentPath,1024)}:{},...du(v.meta)?{meta:du(v.meta)}:{},...L?{references:L}:{},...v.role!==void 0?{role:v.role}:{}}});m.length||hs();const x=new Map(m.map(w=>[w.id,w]));x.size!==m.length&&hs();for(const w of m){const v=new Set([w.id]);let S=w.parentId;for(;S;)(v.has(S)||!x.has(S))&&hs(),v.add(S),S=x.get(S)?.parentId}const y=rc(p.edges,600).map(w=>{const v=Cl(w),S=Cc(v.from),L=Cc(v.to);return(!x.has(S)||!x.has(L))&&hs(),{from:S,to:L,label:oi(v.label,200)}});return{id:Cc(p.id),title:oi(p.title,160),summary:oi(p.summary),nodes:m,edges:y,...mx(p),...du(p.meta)?{meta:du(p.meta)}:{}}});(!a.length||new Set(a.map(d=>d.id)).size!==a.length)&&hs();for(const d of a)for(const p of d.nodes)for(const m of p.references??[]){const x=a.find(y=>y.id===m.perspective);(!x||m.node&&!x.nodes.some(y=>y.id===m.node))&&hs()}const c=r.analysis===void 0?void 0:$1(Cl(r.analysis));let l;if(r.details!==void 0){const d=Cl(r.details),p=rc(d.analyzedPaths,200).map(x=>{const y=oi(x,1024);return Fh(y)||hs(),y}),m=rc(d.limitations,30).map(x=>oi(x,2e3));l={analyzedPaths:p,limitations:m}}return r.origin!==void 0&&!["termdock","omm"].includes(r.origin)&&hs(),{version:1,generatedAt:n,summary:oi(r.summary),perspectives:a,...c?{analysis:c}:{},...l?{details:l}:{},...r.origin?{origin:r.origin}:{},...du(r.meta)?{meta:du(r.meta)}:{}}}function Ky(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 p=n.get(d);for(;p&&!a.has(p.id);)p=p.parentId?n.get(p.parentId):void 0;return p?.id},l=new Map;for(const d of e.edges){const p=c(d.from),m=c(d.to);p&&m&&p!==m&&!l.has(`${p}:${m}`)&&l.set(`${p}:${m}`,{from:p,to:m,label:d.label})}return{nodes:r,edges:[...l.values()]}}function Cp(e){return e.slice(0,100).replace(/[&<>"\[\]{}|`#;\\\r\n]/g," ").trim()||"…"}function X$(e,t,r=0){const n=Ky(e,t),a=[],c=(w,v)=>{for(const S of e.nodes.filter(L=>L.parentId===w))a.push(S),v<r&&c(S.id,v+1)};c(t,0);const l=new Map(a.map((w,v)=>[w.id,`n${v}`])),d=[],p=new Set,m=(w,v)=>{for(const S of e.nodes.filter(L=>L.parentId===w)){const L=l.get(S.id);v<r&&e.nodes.some(E=>E.parentId===S.id)?(p.add(S.id),d.push(`subgraph ${L}["${Cp(S.title)}"]`),m(S.id,v+1),d.push("end")):d.push(`${L}["${Cp(S.title)}"]`)}};m(t,0);const x=w=>{let v=e.nodes.find(S=>S.id===w);for(;v&&!l.has(v.id);)v=e.nodes.find(S=>S.id===v.parentId);return v?.id},y=new Map;for(const w of r?e.edges:n.edges){const v=x(w.from),S=x(w.to),L=(E,R)=>{let B=e.nodes.find(z=>z.id===R);for(;B?.parentId;){if(B.parentId===E)return!0;B=e.nodes.find(z=>z.id===B.parentId)}return!1};v&&S&&v!==S&&!L(v,S)&&!L(S,v)&&y.set(`${v}:${S}:${w.label}`,{from:v,to:S,label:w.label})}return{nodes:a,groups:p,code:["---","config:"," htmlLabels: false","---","flowchart TD",...d,...y.values()].map(w=>typeof w=="string"?w:`${l.get(w.from)} -->|"${Cp(w.label)}"| ${l.get(w.to)}`).join(`
4
+ `)}}function J$(e,t,r=YS,n){const a=$1(r),c=n??JS(a);if(c===".omm")return eC(e,t);(!Zy(c)||a.kind!=="project"&&c===uf||a.kind==="project"&&c!==uf)&&hs();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 eC(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 eU(e,t){const r=Ky(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 Xy(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"||!Zy(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 Jy=e=>`termdock-secure-architecture-link:${e}`;function tC(e){e.peerId&&sessionStorage.setItem(Jy(e.peerId),JSON.stringify({link:e,at:Date.now()}))}function rC(e){if(!e)return null;try{const t=Jy(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=Xy(`?architecture=${encodeURIComponent(JSON.stringify(n.link))}`);return a?.peerId===e?a:null}catch{return null}}function tU(e,t){const r=new URL("/",e);return r.searchParams.set("architecture",JSON.stringify(t)),r.href}function nC(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 zm=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function sC({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 Ei=hc(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 iC({state:e,onCopy:t,copied:r}){const{t:n}=Ur(),[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&&Xw.toDataURL(l,{width:180,margin:2,errorCorrectionLevel:"M"}).then(p=>{d||c(p)}).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 df=hc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function gx(){const e=sl(),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(),p=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(p?.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]=k.useState(gx);return k.useEffect(()=>{const n=window.setInterval(()=>r(gx()),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 oC={x:0,y:0,width:1,height:1};function $c(e){return"id"in e?[e.id]:[...$c(e.first),...$c(e.second)]}function Hm(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=Hm(n.first,t+1,r),c=Hm(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 y0(e,t){if("id"in e)return t.has(e.id)?e:null;const r=y0(e.first,t),n=y0(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function hf(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:hf(e.first,t,r,n),second:hf(e.second,t,r,n)}}function lC(e,t,r,n){if(t===r||!$c(e).includes(t)||!$c(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 hf(y0(e,new Set($c(e).filter(a=>a!==t))),r,t,n)}function Bu(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:Bu(e.slice(0,r),"horizontal"),second:Bu(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:Bu(e.slice(1),t)}}function Wm(e,t=oC,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=Wm(e.first,n,r+"0"),l=Wm(e.second,a,r+"1");return{panes:[...c.panes,...l.panes],dividers:[{path:r,node:e,rect:t},...c.dividers,...l.dividers]}}function a0(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:a0(e.first,t.slice(1),r)}:{...e,second:a0(e.second,t.slice(1),r)}:{...e,ratio:r}}function e3(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 _p(e,t,r){const n=e3(e);if(!n)return e;const[a,c,l,d]=n.ids.map(p=>({id:p}));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=(p,m,x)=>{if(p.length===1)return p[0];const y=x?.length===p.length&&x.every(w=>Number.isFinite(w)&&w>0)?x:p.map(()=>1);return{axis:m,ratio:y[0]/y.reduce((w,v)=>w+v,0),first:p[0],second:c(p.slice(1),m,y.slice(1))}};if(t!=="grid")return c(e.map(p=>({id:p})),t==="vertical"?"y":"x",r);const l=Math.ceil(Math.sqrt(e.length)),d=[];for(let p=0;p<e.length;p+=l){const m=e.slice(p,p+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 uC;function Uf(){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 uC??=crypto.randomUUID()}}let xx=Promise.resolve();function Fa(e,t){t&&(e={groups:{[t]:e}});const r=Uf(),n=xx.catch(()=>{}).then(()=>La({collaborationPanel:{clientId:r,state:e}}));return xx=n,n.then(()=>{})}function bx(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 t3(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function r3(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 dC(e,t){const r=Ei.getState(),n=r.groupId;r.drafts[e]&&await Fa({drafts:{[e]:r.drafts[e]}});const a={sessionId:t,side:window.innerWidth<640?"bottom":"right"};if(await Fa({floatingGroupId:e,mode:"docked",dock:a},e),Ei.getState().groupId!==n)throw new Error("布局已保存;页面已切换,请重新打开成员消息");window.dispatchEvent(new CustomEvent("termdock:open-collaboration-messages",{detail:{groupId:e,dock:a}}))}const hC=e=>e.startsWith("@collaboration:"),yx=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function fC({groupId:e}){const t=Kn(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||Kn.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 vx({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:c=!1}){const l=Kn(ne=>ne.docks),d=JSON.stringify(t.map(ne=>ne.id)),p=Object.entries(l).filter(([,ne])=>t.some(Fe=>Fe.id===ne.sessionId)),m=JSON.stringify(p),x=b.useRef(null),[y,w]=b.useState(()=>n??Bu(t.map(ne=>ne.id),c?"vertical":r)),v=b.useRef(y);v.current=y;const[S,L]=b.useState(!1),E=Kn(ne=>ne.activePaneId),[R,B]=b.useState(null),[z,O]=b.useState(null),[$,V]=b.useState(null),Z=b.useRef(r),le=b.useRef(t.map(ne=>ne.id)),be=b.useRef({}),pe=b.useRef(!1),ee=()=>{pe.current&&(pe.current=!1,Fa({layouts:{[e]:v.current}}).catch(()=>{pe.current=!0,B("布局保存失败,调整后重试")}))};b.useEffect(()=>{let ne=!1;return fc().then(Fe=>{if(ne)return;const ke=Fe.collaborationPanels?.[Uf()];for(const Pe of r3(ke)){const Ne=t3(ke,Pe);Ne.mode==="docked"&&Ne.dock&&t.some(oe=>oe.id===Ne.dock.sessionId)&&!Kn.getState().docks[Pe]&&Kn.getState().setDock(Pe,Ne.dock)}let Ee=Hm(ke?.layouts?.[e]);if(Ee&&ke?.floatingGroupId){const Pe=Ne=>"id"in Ne?{id:Ne.id==="@collaboration"?eh(ke.floatingGroupId):Ne.id}:{...Ne,first:Pe(Ne.first),second:Pe(Ne.second)};Ee=Pe(Ee)}Ee&&w(Ee),L(!0)}).catch(()=>{ne||B("布局加载失败,请刷新重试")}),()=>{ne=!0}},[e]);const _e=ne=>{pe.current=!0,v.current=ne,w(ne)};b.useLayoutEffect(()=>{if(!S)return;const ne=JSON.parse(d),Fe=Z.current!==r;Z.current=r;let ke=Fe?Bu(ne,r):v.current;const Ee=le.current;if(!Fe&&Ee.length===ne.length&&Ee.every(oe=>ne.includes(oe))&&Ee.some((oe,We)=>oe!==ne[We])){const oe=new Map(Ee.map((nt,gt)=>[nt,ne[gt]])),We=nt=>"id"in nt?{id:oe.get(nt.id)??nt.id}:{...nt,first:We(nt.first),second:We(nt.second)};ke=We(ke)}le.current=ne;const Pe=new Set([...ne,...p.map(([oe])=>eh(oe))]);ke=y0(ke,Pe)??Bu(ne,r);for(const oe of ne)$c(ke).includes(oe)||(ke={axis:"x",ratio:.5,first:ke,second:{id:oe}});const Ne={};for(const[oe,We]of p){const nt=eh(oe),gt=`${We.sessionId}:${We.side}`;if(Ne[oe]=gt,(!$c(ke).includes(nt)||be.current[oe]&&be.current[oe]!==gt)&&(ke=y0(ke,new Set([...Pe].filter(ue=>ue!==nt))),ke=hf(ke,We.sessionId,nt,We.side)),We.preferredWidth&&(We.side==="left"||We.side==="right")){const ue=(Ze,at)=>{if("id"in Ze)return Ze;const Ie="id"in Ze.first&&Ze.first.id===nt,Ge="id"in Ze.second&&Ze.second.id===nt;if(Ze.axis==="x"&&(Ie||Ge)&&Ze.ratio===.5){const ae=(x.current?.clientWidth||window.innerWidth)*at.width,Ae=Math.max(.1,Math.min(.45,We.preferredWidth/Math.max(1,ae)));return{...Ze,ratio:Ie?Ae:1-Ae}}const Ce={...at},H={...at};return Ze.axis==="x"?(Ce.width*=Ze.ratio,H.x+=Ce.width,H.width-=Ce.width):(Ce.height*=Ze.ratio,H.y+=Ce.height,H.height-=Ce.height),{...Ze,first:ue(Ze.first,Ce),second:ue(Ze.second,H)}};ke=ue(ke,{x:0,y:0,width:1,height:1})}}be.current=Ne,JSON.stringify(ke)!==JSON.stringify(v.current)&&(_e(ke),ee())},[S,d,r,m]),b.useEffect(()=>{const ne=()=>ee();return window.addEventListener("pagehide",ne),()=>{window.removeEventListener("pagehide",ne),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ne()}},[e]);const ze=Wm(y),Y=e3(y),ce=[...t,...p.map(([ne])=>({id:eh(ne),content:s.jsx(fC,{groupId:ne})}))],qe=b.useRef(null),we=b.useRef($);we.current=$;const ye=b.useRef(null);b.useEffect(()=>{const ne=x.current;if(!ne||!S)return;const Fe=Ee=>{if(Ee.button!==0||!(Ee.target instanceof Element))return;const Pe=Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]"),Ne=Ee.target.closest("button, a, input, textarea, select, summary");if(!Pe||Ne&&Ne!==Pe)return;const oe=Pe.closest("[data-layout-pane]");if(!oe||!ne.contains(oe))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const We=oe.getBoundingClientRect();qe.current={id:oe.dataset.layoutPane,x:Ee.clientX,y:Ee.clientY,moved:!1,originX:Ee.clientX-We.left,originY:Ee.clientY-We.top,scale:Math.min(.8,480/Math.max(1,We.width),320/Math.max(1,We.height))},ne.setPointerCapture?.(Ee.pointerId)},ke=Ee=>{const Pe=Ee.target;if(!(Pe instanceof Element))return;const Ne=Pe.closest("[data-layout-pane]");if(!(!Ne||!ne.contains(Ne))){if(Ee.type==="pointerdown"&&Kn.getState().activePaneId!==Ne.dataset.layoutPane){const oe=document.activeElement;oe instanceof HTMLElement&&oe.closest("[data-layout-pane]")&&!Ne.contains(oe)&&oe.blur();const We=window.getSelection();We?.anchorNode&&!Ne.contains(We.anchorNode)&&We.removeAllRanges()}Kn.getState().setActivePane(Ne.dataset.layoutPane)}};return ne.addEventListener("pointerdown",ke,!0),ne.addEventListener("focusin",ke,!0),ne.addEventListener("pointerdown",Fe,!0),()=>{ne.removeEventListener("pointerdown",Fe,!0),ne.removeEventListener("pointerdown",ke,!0),ne.removeEventListener("focusin",ke,!0)}},[S]);const Le=(ne,Fe)=>{const ke=x.current?.getBoundingClientRect(),Ee=ye.current;if(!ke||!Ee)return;const Pe=Ee.axis==="x"?ke.width*Ee.rect.width:ke.height*Ee.rect.height,Ne=Ee.axis==="x"?ke.left+ke.width*Ee.rect.x:ke.top+ke.height*Ee.rect.y,oe=Math.min(.45,(c?48:120)/Math.max(1,Pe)),We=Math.max(oe,Math.min(1-oe,((Ee.axis==="x"?ne:Fe)-Ne)/Math.max(1,Pe)));_e(Ee.side?_p(v.current,Ee.side,We):a0(v.current,Ee.path,We))},Be=Y?[{key:"top",side:"top",axis:"x",x:Y.top,y:0,length:(Y.left+Y.right)/2},{key:"bottom",side:"bottom",axis:"x",x:Y.bottom,y:(Y.left+Y.right)/2,length:1-(Y.left+Y.right)/2},{key:"left",side:"left",axis:"y",x:0,y:Y.left,length:(Y.top+Y.bottom)/2},{key:"right",side:"right",axis:"y",x:(Y.top+Y.bottom)/2,y:Y.right,length:1-(Y.top+Y.bottom)/2}].map(ne=>({...ne,rect:{x:0,y:0,width:1,height:1},path:void 0})):ze.dividers.map(ne=>({key:ne.path,path:ne.path,side:void 0,axis:ne.node.axis,rect:ne.rect,x:ne.rect.x+(ne.node.axis==="x"?ne.rect.width*ne.node.ratio:0),y:ne.rect.y+(ne.node.axis==="y"?ne.rect.height*ne.node.ratio:0),length:ne.node.axis==="x"?ne.rect.height:ne.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:ne=>{if(ye.current){ne.preventDefault(),Le(ne.clientX,ne.clientY);return}const Fe=qe.current,ke=x.current?.getBoundingClientRect();if(!Fe||!ke||!Fe.moved&&Math.hypot(ne.clientX-Fe.x,ne.clientY-Fe.y)<6)return;Fe.moved=!0,O({id:Fe.id,dx:ne.clientX-Fe.x,dy:ne.clientY-Fe.y,originX:Fe.originX,originY:Fe.originY,scale:Fe.scale});const Ee=(ne.clientX-ke.left)/ke.width,Pe=(ne.clientY-ke.top)/ke.height,Ne=ze.panes.find(ue=>Ee>=ue.rect.x&&Ee<=ue.rect.x+ue.rect.width&&Pe>=ue.rect.y&&Pe<=ue.rect.y+ue.rect.height);if(!Ne||Ne.id===Fe.id){we.current=null,V(null);return}const oe=(Ee-Ne.rect.x)/Ne.rect.width,We=(Pe-Ne.rect.y)/Ne.rect.height,nt=Math.min(oe,1-oe,We,1-We)>.25?"center":oe<1-oe&&oe<=We&&oe<=1-We?"left":1-oe<=We&&1-oe<=1-We?"right":We<1-We?"top":"bottom",gt={id:Ne.id,side:nt};we.current=gt,V(gt)},onPointerUp:ne=>{ye.current&&(ye.current=null,ee()),qe.current?.moved&&we.current&&(_e(lC(v.current,qe.current.id,we.current.id,we.current.side)),ee()),qe.current=null,we.current=null,V(null),O(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ne.currentTarget.hasPointerCapture?.(ne.pointerId)&&ne.currentTarget.releasePointerCapture(ne.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,qe.current=null,we.current=null,V(null),O(null),ee()},onKeyDownCapture:ne=>{ne.key==="Escape"&&(qe.current=null,we.current=null,V(null),O(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,we.current=null,V(null),O(null),ee()},children:[z&&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:yx(ze.panes.find(ne=>ne.id===z.id)?.rect??{x:0,y:0,width:0,height:0})}),ce.map(ne=>{const Fe=ze.panes.find(Ee=>Ee.id===ne.id)?.rect,ke=!Fe||!!a&&ne.id!==a;return s.jsxs("div",{"data-layout-pane":ne.id,"data-pane-active":E===ne.id,className:`${E===ne.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${z?.id===ne.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...yx(a===ne.id?{x:0,y:0,width:1,height:1}:Fe??{x:0,y:0,width:0,height:0}),padding:ce.length>1?"0.5px":0,transition:"none",visibility:ke?"hidden":void 0,...z?.id===ne.id?{transform:`translate(${z.dx}px, ${z.dy}px) scale(${z.scale})`,transformOrigin:`${z.originX}px ${z.originY}px`}:{}},onDragStart:Ee=>{Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Ee.preventDefault()},children:[ne.content,c&&ce.length>1&&!hC(ne.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($f,{size:14})}),$?.id===ne.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:$.side==="bottom"?"50%":0,bottom:$.side==="top"?"50%":0,left:$.side==="right"?"50%":0,right:$.side==="left"?"50%":0}})]},ne.id)}),!a&&Be.map(ne=>s.jsx("button",{type:"button",role:"separator","aria-label":ne.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[ne.side]}半段分隔线`:"调整分屏大小","aria-orientation":ne.axis==="x"?"vertical":"horizontal",disabled:!S,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${ne.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${ne.x*100}%`,top:`${ne.y*100}%`,...ne.axis==="x"?{height:`${ne.length*100}%`}:{width:`${ne.length*100}%`}},onPointerDown:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ye.current=ne,x.current?.setPointerCapture?.(Fe.pointerId)},onDoubleClick:()=>{_e(ne.side?_p(v.current,ne.side,.5):a0(v.current,ne.path,.5)),ee()},onKeyDown:Fe=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Fe.key))return;Fe.preventDefault();const ke=ne.side?Y[ne.side]:ze.dividers.find(Pe=>Pe.path===ne.path).node.ratio,Ee=Math.max(.05,Math.min(.95,ke+(["ArrowRight","ArrowDown"].includes(Fe.key)?.03:-.03)));_e(ne.side?_p(v.current,ne.side,Ee):a0(v.current,ne.path,Ee)),ee()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${ne.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},ne.key)),R&&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:R})]})}let Gm=0,wx=!1,Eu=0;function pC(){if(wx||typeof window>"u")return;wx=!0;const e=()=>{Gm=performance.now()};window.addEventListener("pointerdown",()=>{Eu+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{Eu=Math.max(0,Eu-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{Eu=0,e()})}function U1(e,t=500){pC();let r=!1,n,a;const c=()=>{if(r)return;if(Eu>0||performance.now()-Gm<400){a=setTimeout(c,100);return}const l=()=>{if(!r){if(Eu>0||performance.now()-Gm<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 mC(e){const[t,r]=b.useState(e);return b.useEffect(()=>U1(()=>r(e),0),[e]),t}function gC(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 Vm(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 xC(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 M0=new Map;function bC(e,t,r){if(!r||!t||!j1(e))return null;const n=`owned-paste-${crypto.randomUUID()}`;return M0.set(n,{source:e,layer:by(),sessionId:t,text:r,token:{nonce:n}}),{nonce:n,text:r,sessionId:t,paste:!0,submitAfterPaste:!1,focus:!1,ownedPaste:!0}}function yC(e){M0.delete(e)}function z1(e){return e.layer===by()&&j1(e.source)}function vC(e,t){const r=e.nonce?M0.get(e.nonce):void 0;return r&&z1(r)&&e.ownedPaste===!0&&e.paste===!0&&e.submitAfterPaste===!1&&r.sessionId===t&&e.sessionId===t&&e.text===r.text?r.token:null}function wC(e,t,r){const n=M0.get(e.nonce);return!n||n.token!==e||n.consumed?!1:(n.consumed=!0,z1(n)&&n.sessionId===t&&r===Vm(n.text,!1))}function AC(e,t){const r=M0.get(e.nonce);return!!r&&r.token===e&&r.sessionId===t&&z1(r)}function TC(e,t,r){b.useEffect(()=>{e&&Jw(e,!0)},[e,r])}const _i=[];for(let e=0;e<256;++e)_i.push((e+256).toString(16).slice(1));function SC(e,t=0){return(_i[e[t+0]]+_i[e[t+1]]+_i[e[t+2]]+_i[e[t+3]]+"-"+_i[e[t+4]]+_i[e[t+5]]+"-"+_i[e[t+6]]+_i[e[t+7]]+"-"+_i[e[t+8]]+_i[e[t+9]]+"-"+_i[e[t+10]]+_i[e[t+11]]+_i[e[t+12]]+_i[e[t+13]]+_i[e[t+14]]+_i[e[t+15]]).toLowerCase()}let kp;const CC=new Uint8Array(16);function _C(){if(!kp){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");kp=crypto.getRandomValues.bind(crypto)}return kp(CC)}const kC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ax={randomUUID:kC};function LC(e,t,r){e=e||{};const n=e.random??e.rng?.()??_C();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,SC(n)}function n3(e,t,r){return Ax.randomUUID&&!e?Ax.randomUUID():LC(e)}const s3="\x1B[?2026h",IC="\x1B[?2026l",i3="\x1Bc";function EC(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===i3||t.endsWith("!p"))return t+s3;if(r===void 0)return t;const a=r.split(";").filter(c=>Number(c)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function NC(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=EC(t.replace(/^(?:\x1bc)+/,""));return[`${i3}${s3}${r}${IC}`]}function RC(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function MC(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("")}const jC={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},DC={F1:"P",F2:"Q",F3:"R",F4:"S"},BC={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 QC(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}`,p=jC[r];if(p)return l!==1?`\x1B[1${d}${p}`:`\x1B${t?"O":"["}${p}`;const m=DC[r];if(m)return l!==1?`\x1B[1${d}${m}`:`\x1BO${m}`;if(r==="Insert"&&!a&&(n||c))return null;const x=BC[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 o0 extends Error{}async function a3(e){if(!e.type.startsWith("image/")||e.size===0)throw new Error("Clipboard image is empty");const t=e.type==="image/jpeg"?"jpg":e.type.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png",r=new File([e],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${t}`,{type:e.type}),{files:n}=await N0("/tmp",[r]);if(!n[0]?.path)throw new Error("Upload did not return an image path");return n[0].path}async function ff(e){const t=vo();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 o3(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(p=>p.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 l3(){const e=f0()?.targetPeerId;let t;try{t=await vo()?.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 o0(c.slice(d+l.length).trim());const p=c.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw p?new o0(p[1]):a}if(f0()?.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 o0("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");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 c3(e){if(!e.length)return[];const{files:t}=await N0("/tmp",e);if(t.length!==e.length||t.some(r=>!r.path))throw new Error("Upload did not return every file path");return t.map(r=>r.path)}function Zs(e){return{dispose:e}}function PC(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function OC(...e){return Zs(()=>PC(e))}var u3=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()}},Xc=class{constructor(){this._store=new u3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Xc.None=Object.freeze({dispose(){}});var md=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}},d3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),j0=d3?"node":navigator.userAgent,FC=d3?"node":navigator.platform,$C=j0.includes("Firefox");j0.includes("Chrome");var UC=j0.includes("Edge"),h3=/^((?!chrome|android).)*safari/i.test(j0);function zC(){if(!h3)return 0;let e=j0.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}FC.indexOf("Linux")>=0;var li=0,ci=0,ui=0,Cs=0,po={css:"#00000000",rgba:0},ua;(e=>{function t(a,c,l,d){return d!==void 0?`#${_c(a)}${_c(c)}${_c(l)}${_c(d)}`:`#${_c(a)}${_c(c)}${_c(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})(ua||={});var Xd;(e=>{function t(p,m){if(Cs=(m.rgba&255)/255,Cs===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=p.rgba>>24&255,S=p.rgba>>16&255,L=p.rgba>>8&255;li=v+Math.round((x-v)*Cs),ci=S+Math.round((y-S)*Cs),ui=L+Math.round((w-L)*Cs);let E=ua.toCss(li,ci,ui),R=ua.toRgba(li,ci,ui);return{css:E,rgba:R}}e.blend=t;function r(p){return(p.rgba&255)===255}e.isOpaque=r;function n(p,m,x){let y=Uc.ensureContrastRatio(p.rgba,m.rgba,x);if(y)return ua.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let m=(p.rgba|255)>>>0;return[li,ci,ui]=Uc.toChannels(m),{css:ua.toCss(li,ci,ui),rgba:m}}e.opaque=a;function c(p,m){return Cs=Math.round(m*255),[li,ci,ui]=Uc.toChannels(p.rgba),{css:ua.toCss(li,ci,ui,Cs),rgba:ua.toRgba(li,ci,ui,Cs)}}e.opacity=c;function l(p,m){return Cs=p.rgba&255,c(p,Cs*m/255)}e.multiplyOpacity=l;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(Xd||={});var HC;(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 li=parseInt(a.slice(1,2).repeat(2),16),ci=parseInt(a.slice(2,3).repeat(2),16),ui=parseInt(a.slice(3,4).repeat(2),16),ua.toColor(li,ci,ui);case 5:return li=parseInt(a.slice(1,2).repeat(2),16),ci=parseInt(a.slice(2,3).repeat(2),16),ui=parseInt(a.slice(3,4).repeat(2),16),Cs=parseInt(a.slice(4,5).repeat(2),16),ua.toColor(li,ci,ui,Cs);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 li=parseInt(c[1],10),ci=parseInt(c[2],10),ui=parseInt(c[3],10),Cs=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ua.toColor(li,ci,ui,Cs);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),[li,ci,ui,Cs]=t.getImageData(0,0,1,1).data,Cs!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ua.toRgba(li,ci,ui,Cs),css:a}}e.toColor=n})(HC||={});var aa;(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,p=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=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(aa||={});var Uc;(e=>{function t(l,d){if(Cs=(d&255)/255,Cs===1)return d;let p=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return li=y+Math.round((p-y)*Cs),ci=w+Math.round((m-w)*Cs),ui=v+Math.round((x-v)*Cs),ua.toRgba(li,ci,ui)}e.blend=t;function r(l,d,p){let m=aa.relativeLuminance(l>>8),x=aa.relativeLuminance(d>>8);if(yl(m,x)<p){if(x<m){let v=n(l,d,p),S=yl(m,aa.relativeLuminance(v>>8));if(S<p){let L=a(l,d,p),E=yl(m,aa.relativeLuminance(L>>8));return S>E?v:L}return v}let y=a(l,d,p),w=yl(m,aa.relativeLuminance(y>>8));if(w<p){let v=n(l,d,p),S=yl(m,aa.relativeLuminance(v>>8));return w>S?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,L=yl(aa.relativeLuminance2(w,v,S),aa.relativeLuminance2(m,x,y));for(;L<p&&(w>0||v>0||S>0);)w-=Math.max(0,Math.ceil(w*.1)),v-=Math.max(0,Math.ceil(v*.1)),S-=Math.max(0,Math.ceil(S*.1)),L=yl(aa.relativeLuminance2(w,v,S),aa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,L=yl(aa.relativeLuminance2(w,v,S),aa.relativeLuminance2(m,x,y));for(;L<p&&(w<255||v<255||S<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),L=yl(aa.relativeLuminance2(w,v,S),aa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(Uc||={});function _c(e){let t=e.toString(16);return t.length<2?"0"+t:t}function yl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Fs(e){if(!e)throw new Error("value must not be falsy");return e}function H1(e){return 57508<=e&&e<=57558}function WC(e){return 57520<=e&&e<=57527}function GC(e){return 57344<=e&&e<=63743}function VC(e){return 9472<=e&&e<=9631}function qC(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 YC(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!qC(e)&&!H1(e)&&!GC(e)}function f3(e){return H1(e)||VC(e)}function ZC(){return{css:{canvas:sh(),cell:sh()},device:{canvas:sh(),cell:sh(),char:{width:0,height:0,left:0,top:0}}}}function sh(){return{width:0,height:0}}function KC(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 XC={"─":{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],"🬀":xr(1),"🬁":xr(2),"🬂":xr(3),"🬃":xr(4),"🬄":xr(5),"🬅":xr(6),"🬆":xr(7),"🬇":xr(8),"🬈":xr(9),"🬉":xr(10),"🬊":xr(11),"🬋":xr(12),"🬌":xr(13),"🬍":xr(14),"🬎":xr(15),"🬏":xr(16),"🬐":xr(17),"🬑":xr(18),"🬒":xr(19),"🬓":xr(20),"🬔":xr(22),"🬕":xr(23),"🬖":xr(24),"🬗":xr(25),"🬘":xr(26),"🬙":xr(27),"🬚":xr(28),"🬛":xr(29),"🬜":xr(30),"🬝":xr(31),"🬞":xr(32),"🬟":xr(33),"🬠":xr(34),"🬡":xr(35),"🬢":xr(36),"🬣":xr(37),"🬤":xr(38),"🬥":xr(39),"🬦":xr(40),"🬧":xr(41),"🬨":xr(43),"🬩":xr(44),"🬪":xr(45),"🬫":xr(46),"🬬":xr(47),"🬭":xr(48),"🬮":xr(49),"🬯":xr(50),"🬰":xr(51),"🬱":xr(52),"🬲":xr(53),"🬳":xr(54),"🬴":xr(55),"🬵":xr(56),"🬶":xr(57),"🬷":xr(58),"🬸":xr(59),"🬹":xr(60),"🬺":xr(61),"🬻":xr(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:Yo(126),type:0},scaleType:1},"🯱":{type:5,data:{d:Yo(48),type:0},scaleType:1},"🯲":{type:5,data:{d:Yo(109),type:0},scaleType:1},"🯳":{type:5,data:{d:Yo(121),type:0},scaleType:1},"🯴":{type:5,data:{d:Yo(51),type:0},scaleType:1},"🯵":{type:5,data:{d:Yo(91),type:0},scaleType:1},"🯶":{type:5,data:{d:Yo(95),type:0},scaleType:1},"🯷":{type:5,data:{d:Yo(114),type:0},scaleType:1},"🯸":{type:5,data:{d:Yo(127),type:0},scaleType:1},"🯹":{type:5,data:{d:Yo(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}]))},JC=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function xr(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 Yo(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 Ti=0,si=0,Zo=!1,vl=!1,ih=!1,wa,gd=0,e_=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,si=0,Ti=0,vl=!1,Zo=!1,ih=!1,wa=this._themeService.colors,gd=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));gd=t*n%(Math.round(l)*2)}if(gd===0&&JC.has(c)&&(gd=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",l=>{l.backgroundColorRGB&&(si=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ti=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),ih=this._selectionRenderModel.isCellSelected(this._terminal,t,r),ih){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:si=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:si=(this.result.fg&16777215)<<8|255;break;default:si=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:si=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:si=(this.result.bg&16777215)<<8|255;break}si=Uc.blend(si,(this._coreBrowserService.isFocused?wa.selectionBackgroundOpaque:wa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else si=(this._coreBrowserService.isFocused?wa.selectionBackgroundOpaque:wa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(vl=!0,wa.selectionForeground&&(Ti=wa.selectionForeground.rgba>>8&16777215,Zo=!0),f3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)Ti=(this._coreBrowserService.isFocused?wa.selectionBackgroundOpaque:wa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Ti=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Ti=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Ti=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Ti=(this.result.fg&16777215)<<8|255;break;default:Ti=this._themeService.colors.foreground.rgba}Ti=Uc.blend(Ti,(this._coreBrowserService.isFocused?wa.selectionBackgroundOpaque:wa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Zo=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",l=>{l.backgroundColorRGB&&(si=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ti=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),vl&&(ih?si=e.bg&-16777216&-134217729|si|50331648:si=e.bg&-16777216|si|50331648),Zo&&(Ti=e.fg&-16777216&-67108865|Ti|50331648),this.result.fg&67108864&&(vl&&!Zo&&((this.result.bg&50331648)===0?Ti=this.result.fg&-134217728|wa.background.rgba>>8&16777215&16777215|50331648:Ti=this.result.fg&-134217728|this.result.bg&67108863,Zo=!0),!vl&&Zo&&((this.result.fg&50331648)===0?si=this.result.bg&-67108864|wa.foreground.rgba>>8&16777215&16777215|50331648:si=this.result.bg&-67108864|this.result.fg&67108863,vl=!0)),wa=void 0,this.result.bg=vl?si:this.result.bg,this.result.fg=Zo?Ti:this.result.fg,this.result.ext&=536870911,this.result.ext|=gd<<29&3758096384}},t_=.5,p3=$C||UC?"bottom":"ideographic";function r_(e,t,r,n,a,c,l,d,p,m,x,y,w=0){let v=XC[t];if(v){let S=Array.isArray(v)?v:[v];for(let L of S)n_(e,L,r,n,a,c,l,d,p,m,x,y,w);return!0}return!1}function n_(e,t,r,n,a,c,l,d,p,m,x,y,w=0){let v=a,S=c,L=r,E=n;switch(t.scaleType===1&&(v=l,S=d,L=r+(a-l)/2,E=n+(c-d)/2),t.clipPath&&(e.save(),d_(e,t.clipPath,L,E,v,S)),t.type){case 0:s_(e,t.data,L,E,v,S);break;case 1:c_(e,t.data,L,E,v,S,w);break;case 2:u_(e,t.data,L,E,v,S,m,x,t.strokeWidth);break;case 3:a_(e,t.data,L,E,v,S,m,t.strokeWidth);break;case 4:l_(e,t.data,L,E,v,S,m,y);break;case 5:h_(e,t.data,L,E,v,S,p,m,x);break;case 6:i_(e,t.data,L,E,v,S);break}t.clipPath&&e.restore()}function s_(e,t,r,n,a,c){for(let l=0;l<t.length;l++){let d=t[l],p=a/8,m=c/8;e.fillRect(r+d.x*p,n+d.y*m,d.w*p,d.h*m)}}var Tx=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function i_(e,t,r,n,a,c){let l=a/8,d=c*.1,p=c*.8/8,m=Math.min(l,p);for(let x=0;x<8;x++)if(t&1<<x){let y=Tx[x*2],w=Tx[x*2+1],v=r+(y+1)*l,S=n+d+(w+1)*p;e.beginPath(),e.arc(v,S,m,0,Math.PI*2),e.fill()}}function a_(e,t,r,n,a,c,l,d){let p=typeof t=="string"?t:t(0,0);e.beginPath();let m=0,x=0,y=0,w=0,v="";for(let S of p.split(" ")){let L=S[0],E=S.substring(1).split(",");if(L==="Z"){e.closePath(),v=L;continue}if(L==="V"){let B=n+parseFloat(E[0])*c;e.lineTo(m,B),x=B,y=m,w=x,v=L;continue}if(L==="H"){let B=r+parseFloat(E[0])*a;e.lineTo(B,x),m=B,y=m,w=x,v=L;continue}if(!E[0]||!E[1])continue;if(L==="A"){let B=parseFloat(E[0])*a,z=parseFloat(E[1])*c,O=parseFloat(E[2])*Math.PI/180,$=parseInt(E[3],10),V=parseInt(E[4],10),Z=r+parseFloat(E[5])*a,le=n+parseFloat(E[6])*c;o_(e,m,x,B,z,O,$,V,Z,le),m=Z,x=le;continue}let R=E.map((B,z)=>{let O=parseFloat(B);return z%2===0?r+O*a:n+O*c});if(L==="M")e.moveTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(L==="L")e.lineTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(L==="Q")e.quadraticCurveTo(R[0],R[1],R[2],R[3]),y=R[0],w=R[1],m=R[2],x=R[3];else if(L==="T"){let B,z;v==="Q"||v==="T"?(B=2*m-y,z=2*x-w):(B=m,z=x),e.quadraticCurveTo(B,z,R[0],R[1]),y=B,w=z,m=R[0],x=R[1]}else L==="C"&&(e.bezierCurveTo(R[0],R[1],R[2],R[3],R[4],R[5]),y=R[2],w=R[3],m=R[4],x=R[5]);v=L}d!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*d,e.stroke()):e.fill()}function o_(e,t,r,n,a,c,l,d,p,m){if(n===0||a===0){e.lineTo(p,m);return}n=Math.abs(n),a=Math.abs(a);let x=Math.cos(c),y=Math.sin(c),w=(t-p)/2,v=(r-m)/2,S=x*w+y*v,L=-y*w+x*v,E=n*n,R=a*a,B=S*S,z=L*L,O=B/E+z/R;if(O>1){let ye=Math.sqrt(O);n*=ye,a*=ye,E=n*n,R=a*a}let $=(E*R-E*z-R*B)/(E*z+R*B);$<0&&($=0);let V=(l===d?-1:1)*Math.sqrt($),Z=V*(n*L/a),le=V*-(a*S/n),be=x*Z-y*le+(t+p)/2,pe=y*Z+x*le+(r+m)/2,ee=(S-Z)/n,_e=(L-le)/a,ze=(-S-Z)/n,Y=(-L-le)/a,ce=Math.atan2(_e,ee),qe=Math.atan2(Y,ze)-ce;d===0&&qe>0?qe-=2*Math.PI:d===1&&qe<0&&(qe+=2*Math.PI);let we=ce+qe;e.ellipse(be,pe,n,a,c,ce,we,d===0)}function l_(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 p of t.d.split(" ")){let m=p[0],x=p.substring(1).split(",");if(!x[0]||!x[1]){m==="Z"&&e.closePath();continue}let y=x.map((w,v)=>{let S=parseFloat(w);return v%2===0?r+S*a:n+S*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 Sx=new Map;function c_(e,t,r,n,a,c,l=0){let d=Sx.get(t);d||(d=new Map,Sx.set(t,d));let p=e.fillStyle;if(typeof p!="string")throw new Error(`Unexpected fillStyle type "${p}"`);let m=d.get(p);if(!m){let w=t[0].length,v=t.length,S=e.canvas.ownerDocument.createElement("canvas");S.width=w,S.height=v;let L=Fs(S.getContext("2d")),E=new ImageData(w,v),R,B,z,O;if(p.startsWith("#"))R=parseInt(p.slice(1,3),16),B=parseInt(p.slice(3,5),16),z=parseInt(p.slice(5,7),16),O=p.length>7&&parseInt(p.slice(7,9),16)||1;else if(p.startsWith("rgba"))[R,B,z,O]=p.substring(5,p.length-1).split(",").map($=>parseFloat($));else throw new Error(`Unexpected fillStyle color format "${p}" when drawing pattern glyph`);for(let $=0;$<v;$++)for(let V=0;V<w;V++)E.data[($*w+V)*4]=R,E.data[($*w+V)*4+1]=B,E.data[($*w+V)*4+2]=z,E.data[($*w+V)*4+3]=t[$][V]*(O*255);L.putImageData(E,0,0),m=Fs(e.createPattern(S,null)),d.set(p,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 u_(e,t,r,n,a,c,l,d,p){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=m3[w];if(!v){d.error(`Could not find drawing instructions for "${w}"`);continue}let S=y.substring(1).split(",");!S[0]||!S[1]||(v(e,g3(S,a,c,r,n,!0,l,0,0,!1),x),x.lastCommand=w)}p!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*p,e.stroke()):e.fill(),e.closePath(),e.restore()}function d_(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 p=l.substring(1).split(",");if(!p[0]||!p[1])continue;let m=r+parseFloat(p[0])*a,x=n+parseFloat(p[1])*c;d==="M"?e.moveTo(m,x):d==="L"&&e.lineTo(m,x)}e.clip()}function h_(e,t,r,n,a,c,l,d,p){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 S=m3[v];if(!S){p.error(`Could not find drawing instructions for "${v}"`);continue}let L=w.substring(1).split(",");!L[0]||!L[1]||(S(e,g3(L,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 Cx(e,t,r=0){return Math.max(Math.min(e,t),r)}var m3={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 g3(e,t,r,n,a,c,l,d=0,p=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-p*l,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?Cx(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?Cx(w,r,0):w}x[y]+=a}return x}var _x=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={}}},kx=class{constructor(){this._data=new _x}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new _x),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()}},x3=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()}},f_=class extends x3{_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())}}},p_=class extends x3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},m_="requestIdleCallback"in globalThis?p_:f_,Nu=class b3{constructor(){this.fg=0,this.bg=0,this.extended=new y3}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 b3;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}},y3=class v3{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 v3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oo=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return Zs(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=Zs(()=>{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)}},Pc;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,p,m)=>c(x=>d.call(p,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,p)=>{let m=new u3;for(let x of c)m.add(x(y=>l.call(d,y)));return p&&(Array.isArray(p)?p.push(m):p.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(p=>l(p))}e.runAndSubscribe=a})(Pc||={});var Lx={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}},xd=2,bd,nc=class _u{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new kx,this._cacheMapCombined=new kx,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Nu,this._textureSize=512,this._onAddTextureAtlasCanvas=new Oo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Oo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=A3(t,this._config.deviceCellWidth*4+xd*2,this._config.deviceCellHeight+xd*2),this._tmpCtx=Fs(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 m_(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(_u.maxAtlasPages&&this._pages.length>=Math.max(4,_u.maxAtlasPages)){let r=this._pages.filter(m=>m.canvas.width*2<=(_u.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 kc(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,p=this._mergePages(c,d);p.version=++kc.nextVersion;for(let m=l.length-1;m>=0;m--)this._deletePage(l[m]);this.pages.push(p),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(p.canvas)}let t=new kc(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 kc(this._document,n,t);for(let[c,l]of t.entries()){let d=c*l.canvas.width%n,p=Math.floor(c/2)*l.canvas.height;a.ctx.drawImage(l.canvas,d,p);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+=p,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=++kc.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 bd=t.get(r,n,a,c),bd||(bd=this._drawToCache(r,n,a,c,l,d),t.set(r,n,a,c,bd)),bd}_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 po;let c;switch(t){case 16777216:case 33554432:c=this._getColorFromAnsiIndex(r);break;case 50331648:let l=Nu.toColorRGB(r);c=ua.toColor(l[0],l[1],l[2]);break;default:n?c=Xd.opaque(this._config.colors.foreground):c=this._config.colors.background;break}return this._config.allowTransparency||(c=Xd.opaque(c)),c}_getForegroundColor(t,r,n,a,c,l,d,p,m,x){let y=this._getMinimumContrastColor(t,r,n,a,c,l,d,m,p,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=Nu.toColorRGB(l);w=ua.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=Xd.opaque(w)),p&&(w=Xd.multiplyOpacity(w,t_)),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,p,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),S=this._resolveForegroundRgba(c,l,d,p),L=Uc.ensureContrastRatio(v,S,this._config.minimumContrastRatio/(m?2:1));if(!L){y.setColor(t,a,null);return}let E=ua.toColor(L>>24&255,L>>16&255,L>>8&255);return y.setColor(t,a,E),E}_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 p=Math.min(this._config.deviceCellWidth*Math.max(d.length,2)+xd*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<p&&(this._tmpCanvas.width=p);let m=Math.min(this._config.deviceCellHeight+xd*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 Lx;let x=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),w=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),S=!!this._workAttributeData.isUnderline(),L=!!this._workAttributeData.isStrikethrough(),E=!!this._workAttributeData.isOverline(),R=this._workAttributeData.getFgColor(),B=this._workAttributeData.getFgColorMode(),z=this._workAttributeData.getBgColor(),O=this._workAttributeData.getBgColorMode();if(y){let Be=R;R=z,z=Be;let ne=B;B=O,O=ne}let $=this._getBackgroundColor(O,z,y,w);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=$.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let V=x?this._config.fontWeightBold:this._config.fontWeight,Z=v?"italic":"";this._tmpCtx.font=`${Z} ${V} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=p3;let le=d.length===1&&H1(d.charCodeAt(0)),be=d.length===1&&WC(d.charCodeAt(0)),pe=this._getForegroundColor(r,O,z,n,B,R,y,w,x,f3(d.charCodeAt(0)));this._tmpCtx.fillStyle=pe.css;let ee=be?0:xd*2,_e=!1;if(this._config.customGlyphs!==!1){let Be=this._workAttributeData.getUnderlineVariantOffset();_e=r_(this._tmpCtx,d,ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,$.css,Be)}let ze=!le,Y;if(typeof t=="number"?Y=this._unicodeService.wcwidth(t):Y=this._unicodeService.getStringCellWidth(t),S){this._tmpCtx.save();let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ne=Be%2===1?.5:0;if(this._tmpCtx.lineWidth=Be,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())ze=!1,this._tmpCtx.strokeStyle=`rgb(${Nu.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{ze=!1;let We=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&We<8&&(We+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(We).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let Fe=ee,ke=Math.ceil(ee+this._config.deviceCharHeight)-ne-(c?Be*2:0),Ee=ke+Be*2,Pe=this._workAttributeData.getUnderlineVariantOffset(),Ne=0,oe=0;for(let We=0;We<Y;We++){let nt=!1;this._tmpCtx.save(),Ne=ke,oe=Ee;let gt=Fe+We*this._config.deviceCellWidth,ue=Fe+(We+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(gt,ke),this._tmpCtx.lineTo(ue,ke),this._tmpCtx.moveTo(gt,Ee),this._tmpCtx.lineTo(ue,Ee);break;case 3:Ne=this._config.deviceCharHeight+1,oe=Ne+3*this._config.devicePixelRatio;let Ze=new Path2D;Ze.rect(gt,Ne,this._config.deviceCellWidth,oe-Ne),this._tmpCtx.clip(Ze);let at=this._config.deviceCellWidth,Ie=oe-Ne,Ge=at/6,Ce=Ie/3,H=[[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 wt of H){this._tmpCtx.beginPath();for(let zt=0;zt<wt.length;zt+=2){let Vt=gt+wt[zt]*Ge,Kt=oe-wt[zt+1]*Ce;zt===0?this._tmpCtx.moveTo(Vt,Kt):this._tmpCtx.lineTo(Vt,Kt)}this._tmpCtx.closePath(),this._tmpCtx.fill()}nt=!0;break;case 4:let ae=Pe===0?0:Pe>=Be?Be*2-Pe:Be-Pe;Pe>=Be||ae===0?(this._tmpCtx.setLineDash([Math.round(Be),Math.round(Be)]),this._tmpCtx.moveTo(gt+ae,ke),this._tmpCtx.lineTo(ue,ke)):(this._tmpCtx.setLineDash([Math.round(Be),Math.round(Be)]),this._tmpCtx.moveTo(gt,ke),this._tmpCtx.lineTo(gt+ae,ke),this._tmpCtx.moveTo(gt+ae+Be,ke),this._tmpCtx.lineTo(ue,ke)),Pe=KC(ue-gt,Be,Pe);break;case 5:let Ae=.6,Ye=.3,et=ue-gt,St=Math.floor(Ae*et),Gt=Math.floor(Ye*et),Qt=et-St-Gt;this._tmpCtx.setLineDash([St,Gt,Qt]),this._tmpCtx.moveTo(gt,ke),this._tmpCtx.lineTo(ue,ke);break;default:this._tmpCtx.moveTo(gt,ke),this._tmpCtx.lineTo(ue,ke);break}nt||this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!_e&&this._config.fontSize>=12&&!this._config.allowTransparency&&d!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let We=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in We&&We.actualBoundingBoxDescent>0){this._tmpCtx.save();let nt=new Path2D;nt.rect(Fe,Ne-Math.ceil(Be/2),this._config.deviceCellWidth*Y,oe-Ne+Math.ceil(Be/2)),this._tmpCtx.clip(nt),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=$.css,this._tmpCtx.strokeText(d,ee,ee+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(E){let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ne=Be%2===1?.5:0;this._tmpCtx.lineWidth=Be,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(ee,ee+ne),this._tmpCtx.lineTo(ee+this._config.deviceCharWidth*Y,ee+ne),this._tmpCtx.stroke()}if(_e||this._tmpCtx.fillText(d,ee,ee+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let Be=Lp(this._tmpCtx.getImageData(ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight),$,pe,ze);if(Be)for(let ne=1;ne<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=$.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,ee,ee+this._config.deviceCharHeight-ne),Be=Lp(this._tmpCtx.getImageData(ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight),$,pe,ze),!!Be);ne++);}if(L){let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),ne=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=Be,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(ee,ee+Math.floor(this._config.deviceCharHeight/2)-ne),this._tmpCtx.lineTo(ee+this._config.deviceCharWidth*Y,ee+Math.floor(this._config.deviceCharHeight/2)-ne),this._tmpCtx.stroke()}this._tmpCtx.restore();let ce=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),qe;if(this._config.allowTransparency?qe=g_(ce):qe=Lp(ce,$,pe,ze),qe)return Lx;let we=this._findGlyphBoundingBox(ce,this._workBoundingBox,p,be,_e,ee),ye,Le;for(;;){if(this._activePages.length===0){let Be=this._createNewPage();ye=Be,Le=Be.currentRow,Le.height=we.size.y;break}ye=this._activePages[this._activePages.length-1],Le=ye.currentRow;for(let Be of this._activePages)we.size.y<=Be.currentRow.height&&(ye=Be,Le=Be.currentRow);for(let Be=this._activePages.length-1;Be>=0;Be--)for(let ne of this._activePages[Be].fixedRows)ne.height<=Le.height&&we.size.y<=ne.height&&(ye=this._activePages[Be],Le=ne);if(we.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new kc(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),ye=this._overflowSizePage,Le=this._overflowSizePage.currentRow,Le.x+we.size.x>=ye.canvas.width&&(Le.x=0,Le.y+=Le.height,Le.height=0);break}if(Le.y+we.size.y>=ye.canvas.height||Le.height>we.size.y+2){let Be=!1;if(ye.currentRow.y+ye.currentRow.height+we.size.y>=ye.canvas.height){let ne;for(let Fe of this._activePages)if(Fe.currentRow.y+Fe.currentRow.height+we.size.y<Fe.canvas.height){ne=Fe;break}if(ne)ye=ne;else if(_u.maxAtlasPages&&this._pages.length>=_u.maxAtlasPages&&Le.y+we.size.y<=ye.canvas.height&&Le.height>=we.size.y&&Le.x+we.size.x<=ye.canvas.width)Be=!0;else{let Fe=this._createNewPage();ye=Fe,Le=Fe.currentRow,Le.height=we.size.y,Be=!0}}Be||(ye.currentRow.height>0&&ye.fixedRows.push(ye.currentRow),Le={x:0,y:ye.currentRow.y+ye.currentRow.height,height:we.size.y},ye.fixedRows.push(Le),ye.currentRow={x:0,y:Le.y+Le.height,height:0})}if(Le.x+we.size.x<=ye.canvas.width)break;Le===ye.currentRow?(Le.x=0,Le.y+=Le.height,Le.height=0):ye.fixedRows.splice(ye.fixedRows.indexOf(Le),1)}return we.texturePage=this._pages.indexOf(ye),we.texturePosition.x=Le.x,we.texturePosition.y=Le.y,we.texturePositionClipSpace.x=Le.x/ye.canvas.width,we.texturePositionClipSpace.y=Le.y/ye.canvas.height,we.sizeClipSpace.x/=ye.canvas.width,we.sizeClipSpace.y/=ye.canvas.height,Le.height=Math.max(Le.height,we.size.y),Le.x+=we.size.x,ye.ctx.putImageData(ce,we.texturePosition.x-this._workBoundingBox.left,we.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,we.size.x,we.size.y),ye.addGlyph(we),ye.version=++kc.nextVersion,we}_findGlyphBoundingBox(t,r,n,a,c,l){r.top=0;let d=a?this._config.deviceCellHeight:this._tmpCanvas.height,p=a?this._config.deviceCellWidth:n,m=!1;for(let x=0;x<d;x++){for(let y=0;y<p;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+p;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=p,m=!1;for(let x=l+p-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<p;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)}}}},w3=class qm{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++qm.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=A3(t,r,r),this.ctx=Fs(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=++qm.nextVersion}};w3.nextVersion=0;var kc=w3;function Lp(e,t,r,n){let a=t.rgba>>>24,c=t.rgba>>>16&255,l=t.rgba>>>8&255,d=r.rgba>>>24,p=r.rgba>>>16&255,m=r.rgba>>>8&255,x=Math.floor((Math.abs(a-d)+Math.abs(c-p)+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 g_(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function A3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function x_(e,t,r,n,a,c,l,d,p=!0){let m={foreground:c.foreground,background:c.background,cursor:po,cursorAccent:po,selectionForeground:po,selectionBackgroundTransparent:po,selectionBackgroundOpaque:po,selectionInactiveBackgroundTransparent:po,selectionInactiveBackgroundOpaque:po,overviewRulerBorder:po,scrollbarSliderBackground:po,scrollbarSliderHoverBackground:po,scrollbarSliderActiveBackground:po,ansi:c.ansi.slice(),contrastCache:c.contrastCache,halfContrastCache:c.halfContrastCache};return{customGlyphs:p,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 Ix(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 b_(e){return(e&50331648)===16777216||(e&50331648)===33554432}var bo=[];function T3(e,t,r,n,a,c,l,d,p,m=!0){let x=x_(n,a,c,l,t,r,d,p,m);for(let S=0;S<bo.length;S++){let L=bo[S],E=L.ownedBy.indexOf(e);if(E>=0){if(Ix(L.config,x))return L.atlas;L.ownedBy.length===1?(L.atlas.dispose(),bo.splice(S,1)):L.ownedBy.splice(E,1);break}}for(let S=0;S<bo.length;S++){let L=bo[S];if(Ix(L.config,x))return L.ownedBy.push(e),L.atlas}let y=e._core,w=y._logService,v={atlas:new nc(document,x,y.unicodeService,w),config:x,ownedBy:[e]};return bo.push(v),v.atlas}function Ex(e){for(let t=0;t<bo.length;t++){let r=bo[t].ownedBy.indexOf(e);if(r!==-1){bo[t].ownedBy.length===1?(bo[t].atlas.dispose(),bo.splice(t,1)):bo[t].ownedBy.splice(r,1);break}}}var y_=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 Nx(e,t,r){let n=new t.ResizeObserver(a=>{let c=a.find(p=>p.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 Zs(()=>n?.disconnect())}function v_(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var w_=class S3 extends Nu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new y3,this.combinedData=""}static fromCharData(t){let r=new S3;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?v_(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())}},A_=class extends Xc{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(Zs(()=>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)}},C3=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function _3(e,t,r,n){let a=Fs(e.createProgram());if(e.attachShader(a,Fs(Rx(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,Fs(Rx(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 Rx(e,t,r,n){let a=Fs(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 T_(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 S_=class{constructor(t){this.texture=t,this.version=-1}},C_=`#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 __(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 Ss=0,ds,Ip=0,yd=0,k_=class extends Xc{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;nc.maxAtlasPages===void 0&&(nc.maxAtlasPages=Math.min(32,Fs(l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS))),nc.maxTextureSize=Fs(l.getParameter(l.MAX_TEXTURE_SIZE))),this._program=Fs(_3(l,C_,__(nc.maxAtlasPages),this._logService)),this._register(Zs(()=>l.deleteProgram(this._program))),this._projectionLocation=Fs(l.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Fs(l.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Fs(l.getUniformLocation(this._program,"u_texture"));let d=this._vertexArrayObject=l.createVertexArray();this._register(Zs(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let p=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(Zs(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,p,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(Zs(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=Fs(l.createBuffer()),this._register(Zs(()=>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(nc.maxAtlasPages);for(let v=0;v<nc.maxAtlasPages;v++)w[v]=v;l.uniform1iv(this._textureLocation,w),l.uniformMatrix4fv(this._projectionLocation,!1,C3),this._atlasTextures=[];for(let v=0;v<nc.maxAtlasPages;v++){let S=new S_(Fs(l.createTexture()));this._register(Zs(()=>l.deleteTexture(S.texture))),l.activeTexture(l.TEXTURE0+v),l.bindTexture(l.TEXTURE_2D,S.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]=S}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,p,m){this._updateCell(this._vertices.attributes,t,r,n,a,c,l,d,p,m)}_updateCell(t,r,n,a,c,l,d,p,m,x){if(Ss=(n*this._terminal.cols+r)*11,a===0||a===void 0){t.fill(0,Ss,Ss+11-1-2);return}this._atlas&&(p&&p.length>1?ds=this._atlas.getRasterizedGlyphCombinedChar(p,c,l,d,!1,this._terminal.element):ds=this._atlas.getRasterizedGlyph(a,c,l,d,!1,this._terminal.element),Ip=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),c!==x&&ds.offset.x>Ip?(yd=ds.offset.x-Ip,t[Ss]=-(ds.offset.x-yd)+this._dimensions.device.char.left,t[Ss+1]=-ds.offset.y+this._dimensions.device.char.top,t[Ss+2]=(ds.size.x-yd)/this._dimensions.device.canvas.width,t[Ss+3]=ds.size.y/this._dimensions.device.canvas.height,t[Ss+4]=ds.texturePage,t[Ss+5]=ds.texturePositionClipSpace.x+yd/this._atlas.pages[ds.texturePage].canvas.width,t[Ss+6]=ds.texturePositionClipSpace.y,t[Ss+7]=ds.sizeClipSpace.x-yd/this._atlas.pages[ds.texturePage].canvas.width,t[Ss+8]=ds.sizeClipSpace.y):(t[Ss]=-ds.offset.x+this._dimensions.device.char.left,t[Ss+1]=-ds.offset.y+this._dimensions.device.char.top,t[Ss+2]=ds.size.x/this._dimensions.device.canvas.width,t[Ss+3]=ds.size.y/this._dimensions.device.canvas.height,t[Ss+4]=ds.texturePage,t[Ss+5]=ds.texturePositionClipSpace.x,t[Ss+6]=ds.texturePositionClipSpace.y,t[Ss+7]=ds.sizeClipSpace.x,t[Ss+8]=ds.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&YC(a,m,ds.size.x,this._dimensions.device.cell.width)&&(t[Ss+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}},L_=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,p=Math.max(l,0),m=Math.min(d,t.rows-1);if(p>=t.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=a,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=p,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 I_(){return new L_}var E_=2147483648,N_=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=I_()}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)}},R_=`#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
+ }`,M_=`#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
+ }`,al=8,Ep=al*Float32Array.BYTES_PER_ELEMENT,j_=20*al,Mx=class{constructor(){this.attributes=new Float32Array(j_),this.count=0}},wl=0,jx=0,Dx=0,Bx=0,Qx=0,Px=0,Ox=0,D_=class extends Xc{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 Mx,this._verticesCursor=new Mx;let l=this._gl;this._program=Fs(_3(l,R_,M_,this._logService)),this._register(Zs(()=>l.deleteProgram(this._program))),this._projectionLocation=Fs(l.getUniformLocation(this._program,"u_projection"));let d=this._vertexArrayObject=l.createVertexArray();this._register(Zs(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let p=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(Zs(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,p,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(Zs(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=Fs(l.createBuffer()),this._register(Zs(()=>l.deleteBuffer(this._attributesBuffer))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,l.FLOAT,!1,Ep,0),l.vertexAttribDivisor(0,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,Ep,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,4,l.FLOAT,!1,Ep,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,C3),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,p,m,x,y,w,v,S,L;for(c=0;c<r.rows;c++){for(d=-1,p=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],S=!!(v&67108864),(w!==p||v!==m&&(x||S))&&((p!==0||x&&m!==0)&&(L=a++*al,this._updateRectangle(n,L,m,p,d,l,c)),d=l,p=w,m=v,x=S);(p!==0||x&&m!==0)&&(L=a++*al,this._updateRectangle(n,L,m,p,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++*al,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++*al,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++*al,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++*al,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:wl=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:wl=(n&16777215)<<8;break;default:wl=this._themeService.colors.foreground.rgba}else switch(a&50331648){case 16777216:case 33554432:wl=this._themeService.colors.ansi[a&255].rgba;break;case 50331648:wl=(a&16777215)<<8;break;default:wl=this._themeService.colors.background.rgba}t.attributes.length<r+al&&(t.attributes=T_(t.attributes,(this._terminal.rows*this._terminal.cols+1)*al)),jx=c*this._dimensions.device.cell.width,Dx=d*this._dimensions.device.cell.height,Bx=(wl>>24&255)/255,Qx=(wl>>16&255)/255,Px=(wl>>8&255)/255,Ox=1,this._addRectangle(t.attributes,r,jx,Dx,(l-c)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Bx,Qx,Px,Ox)}_addRectangle(t,r,n,a,c,l,d,p,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]=p,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])}},B_=class extends Xc{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(p=>{this._refreshCharAtlas(e,p),this.reset(e)})),this._register(Zs(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Fs(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=T3(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=p3,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}`}},Q_=class extends B_{constructor(t,r,n,a,c,l,d){super(n,t,"link",r,!0,c,l,d),this._register(a.onShowLinkUnderline(p=>this._handleShowLinkUnderline(p))),this._register(a.onHideLinkUnderline(p=>this._handleHideLinkUnderline(p)))}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&&b_(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()}},P_=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 Np(e,t,r,n){return new P_(e,t,r,n)}var O_=class extends Xc{constructor(e,t,r,n,a,c,l,d,p,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=p,this._customGlyphs=m,this._cursorBlinkStateManager=this._register(new md),this._charAtlasDisposable=this._register(new md),this._observerDisposable=this._register(new md),this._model=new N_,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new w_,this._rectangleRenderer=this._register(new md),this._glyphRenderer=this._register(new md),this._onChangeTextureAtlas=this._register(new Oo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Oo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Oo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Oo),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Oo),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 e_(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Q_(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,d,this._themeService)],this.dimensions=ZC(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(d.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new A_(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Np(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(Np(this._canvas,"webglcontextrestored",w=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Ex(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Nx(this._canvas,this._coreBrowserService.window,(w,v)=>this._setCanvasDevicePixelDimensions(w,v)),this._register(this._coreBrowserService.onWindowChange(w=>{this._observerDisposable.value=Nx(this._canvas,w,(v,S)=>this._setCanvasDevicePixelDimensions(v,S))})),this._register(Np(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(Zs(()=>{clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0;for(let w of this._renderLayers)w.dispose();this._canvas.parentElement?.removeChild(this._canvas),Ex(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 D_(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new k_(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=T3(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=OC(Pc.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Pc.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 y_(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let r=this._core,n=this._workCell,a,c,l,d,p,m,x,y,w,v,S,L,E,R,B,z,O;e=Fx(e,r.rows-1,0),t=Fx(t,r.rows-1,0);let $=this._coreService.decPrivateModes.cursorStyle??r.options.cursorStyle??"block",V=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,Z=V-r.buffer.ydisp,le=Math.min(this._terminal.buffer.active.cursorX,r.cols-1),be=-1,pe=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let ee=!1;for(c=e;c<=t;c++){l=c+r.buffer.ydisp;let _e=r.buffer.lines.get(l);if(!_e){for(this._model.lineLengths[c]=0,z=0;z<r.cols;z++)O=(c*r.cols+z)*4,ee=!0,this._nullModelCell(z,c,O,0,0,0);this._setRowBlinkState(c,!1);continue}d=_e;let ze=!1;for(this._model.lineLengths[c]=0,S=V===l,x=0,p=this._characterJoinerService.getJoinedCharacters(l),z=0;z<r.cols;z++){if(a=this._cellColorResolver.result.bg,d.loadCell(z,n),z===0&&(a=this._cellColorResolver.result.bg),m=!1,y=z>=x,w=z,p.length>0&&z===p[0][0]&&y){v=p.shift();let Y=this._model.selection.isCellSelected(this._terminal,v[0],l);for(B=v[0]+1;B<v[1];B++)y&&=Y===this._model.selection.isCellSelected(this._terminal,B,l);y&&=!S||le<v[0]||le>=v[1],y?(m=!0,n=new F_(n,d.translateToString(!0,v[0],v[1]),v[1]-v[0]),w=v[1]-1):x=v[1]}if(L=n.getChars(),E=n.getCode(),B=(c*r.cols+z)*4,!ze&&n.isBlink()&&(ze=!0),this._cellColorResolver.resolve(n,z,l,this.dimensions.device.cell.width,this.dimensions.device.cell.height),pe&&l===V&&(z===le&&(this._model.cursor={x:le,y:Z,width:n.getWidth(),style:this._coreBrowserService.isFocused?$:r.options.cursorInactiveStyle,cursorWidth:r.options.cursorWidth,dpr:this._devicePixelRatio},be=le+n.getWidth()-1),z>=le&&z<=be&&(this._coreBrowserService.isFocused&&$==="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),E!==0&&(this._model.lineLengths[c]=z+1),!(this._model.cells[B]===E&&this._model.cells[B+1]===this._cellColorResolver.result.bg&&this._model.cells[B+2]===this._cellColorResolver.result.fg&&this._model.cells[B+3]===this._cellColorResolver.result.ext)&&(ee=!0,L.length>1&&(E|=E_),this._model.cells[B]=E,this._model.cells[B+1]=this._cellColorResolver.result.bg,this._model.cells[B+2]=this._cellColorResolver.result.fg,this._model.cells[B+3]=this._cellColorResolver.result.ext,R=n.getWidth(),this._glyphRenderer.value.updateCell(z,c,E,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,L,R,a),m)){for(n=this._workCell,z++;z<=w;z++)O=(c*r.cols+z)*4,this._nullModelCell(z,c,O,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);z--}}this._setRowBlinkState(c,ze)}ee&&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})}},F_=class extends Nu{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 Fx(e,t,r=0){return Math.max(Math.min(e,t),r)}var $_=class extends Xc{constructor(e){if(h3&&zC()<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 Oo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Oo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Oo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Oo),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,p=a._coreBrowserService,m=a._decorationService,x=a._logService,y=a._themeService;this._renderer=this._register(new O_(e,l,d,p,r,m,x,n,y,this._customGlyphs,this._preserveDrawingBuffer)),this._register(Pc.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Pc.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Pc.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Pc.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),c.setRenderer(this._renderer),this._register(Zs(()=>{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 U_=class{constructor(t,r,n,a={}){this._terminal=t,this._regex=r,this._handler=n,this._options=a}provideLinks(t,r){let n=H_.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 z_(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 H_=class $h{static computeLink(t,r,n,a){let c=r.flags.includes("g")?r.flags:`${r.flags}g`,l=new RegExp(r.source,c),[d,p]=$h._getWindowedLineStrings(t-1,n),m=d.join(""),x,y=[];for(;x=l.exec(m);){let w=x[0];if(!z_(w))continue;let[v,S]=$h._mapStrIdx(n,p,0,x.index),[L,E]=$h._mapStrIdx(n,v,S,w.length);if(v===-1||S===-1||L===-1||E===-1)continue;let R={start:{x:S+1,y:v+1},end:{x:E,y:L+1}};y.push({range:R,text:w,activate:a})}return y}static _getWindowedLineStrings(t,r){let n,a=t,c=t,l,d,p=[];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,p.push(d),!(!n.isWrapped||d.indexOf(" ")!==-1)););p.reverse()}for(p.push(m),l=0;(n=r.buffer.active.getLine(++c))&&n.isWrapped&&l<2048&&(d=n.translateToString(!0),l+=d.length,p.push(d),d.indexOf(" ")===-1););}return[p,a]}static _mapStrIdx(t,r,n,a){let c=t.buffer.active,l=c.getNullCell(),d=n;for(;a;){let p=c.getLine(r);if(!p)return[-1,-1];for(let m=d;m<p.length;++m){p.getCell(m,l);let x=l.getChars();if(l.getWidth()&&(a-=x.length||1,m===p.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]}},W_=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function G_(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 V_=class{constructor(t=G_,r={}){this._handler=t,this._options=r}activate(t){this._terminal=t;let r=this._options,n=r.urlRegex??W_;this._linkProvider=this._terminal.registerLinkProvider(new U_(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function $x(e){return{dispose:e}}var q_=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()}},Y_=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return $x(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=$x(()=>{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)}},Z_;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,p,m)=>c(x=>d.call(p,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,p)=>{let m=new q_;for(let x of c)m.add(x(y=>l.call(d,y)));return p&&(Array.isArray(p)?p.push(m):p.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(p=>l(p))}e.runAndSubscribe=a})(Z_||={});var Ux=class Uh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Y_,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),p=Uh.extractWidth(d);Uh.extractShouldJoin(d)&&(p-=Uh.extractWidth(n)),r+=p,n=d}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},Rp=[[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]],K_=[[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]],Mp=[[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]],X_=[[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]],Al;function zx(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 J_=class{constructor(){if(this.version="11",!Al){Al=new Uint8Array(65536),Al.fill(1),Al[0]=0,Al.fill(0,1,32),Al.fill(0,127,160);for(let e=0;e<Rp.length;++e)Al.fill(0,Rp[e][0],Rp[e][1]+1);for(let e=0;e<Mp.length;++e)Al.fill(2,Mp[e][0],Mp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Al[e]:zx(e,K_)?0:zx(e,X_)?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let a=Ux.extractWidth(t);a===0?n=!1:a>r&&(r=a)}return Ux.createPropertyValue(0,r,n)}},ek=class{activate(e){e.unicode.register(new J_)}dispose(){}};function Yc(e){return{dispose:e}}function zh(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function tk(...e){return Yc(()=>zh(e))}var k3=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()}},D0=class{constructor(){this._store=new k3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};D0.None=Object.freeze({dispose(){}});var pf=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}},Ym=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Yc(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Yc(()=>{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)}},rk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,p,m)=>c(x=>d.call(p,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,p)=>{let m=new k3;for(let x of c)m.add(x(y=>l.call(d,y)));return p&&(Array.isArray(p)?p.push(m):p.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(p=>l(p))}e.runAndSubscribe=a})(rk||={});function L3(e,t=0,r){let n=setTimeout(()=>{e()},t);return Yc(()=>{clearTimeout(n)})}var nk=class extends D0{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new pf),this._linesCacheDisposables=this._register(new pf),this._lastAccessTimestamp=0,this._register(Yc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=tk(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=L3(()=>{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 p=a.getCell(a.length-1);p&&p.getCode()===0&&p.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]}},sk=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}},ik=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},p=this._findInLine(t,d,r);if(!p)for(let m=l+1;m<this._terminal.buffer.active.baseY+this._terminal.rows&&(d.startRow=m,d.startCol=0,p=this._findInLine(t,d,r),!p);m++);if(!p&&l!==0)for(let m=0;m<l&&(d.startRow=m,d.startCol=0,p=this._findInLine(t,d,r),!p);m++);return!p&&a&&(d.startRow=a.start.y,d.startCol=0,p=this._findInLine(t,d,r)),p}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 p={startRow:c,startCol:l},m;if(a&&(p.startRow=c=a.start.y,p.startCol=a.start.x,n!==t&&(m=this._findInLine(t,p,r,!1),m||(p.startRow=c=a.end.y,p.startCol=a.end.x))),m??=this._findInLine(t,p,r,d),!m){p.startCol=Math.max(p.startCol,this._terminal.cols);for(let x=c-1;x>=0&&(p.startRow=x,m=this._findInLine(t,p,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&&(p.startRow=x,m=this._findInLine(t,p,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[p,m]=d,x=this._bufferColsToStringOffset(c,l),y=t,w=p;n.regex||(y=n.caseSensitive?t:t.toLowerCase(),w=n.caseSensitive?p:p.toLowerCase());let v=-1;if(n.regex){let S=RegExp(y,n.caseSensitive?"g":"gi"),L;if(a)for(;L=S.exec(w.slice(0,x));)v=S.lastIndex-L[0].length,t=L[0],S.lastIndex-=t.length-1;else L=S.exec(w.slice(x)),L&&L[0].length>0&&(v=x+(S.lastIndex-L[0].length),t=L[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 S=0;for(;S<m.length-1&&v>=m[S+1];)S++;let L=S;for(;L<m.length-1&&v+t.length>=m[L+1];)L++;let E=v-m[S],R=v+t.length-m[L],B=this._stringLengthToBufferSize(c+S,E),z=this._stringLengthToBufferSize(c+L,R)-B+this._terminal.cols*(L-S);return{term:t,col:B,row:c+S,size:z}}}_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}},ak=class extends D0{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Yc(()=>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(){zh(n)}}}clearHighlightDecorations(){zh(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 p=[];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(()=>zh(w))),p.push(y)}}return p.length===0?void 0:p}},ok=class extends D0{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Ym)}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()}},lk=class extends D0{constructor(t){super(),this._highlightTimeout=this._register(new pf),this._lineCache=this._register(new pf),this._state=new sk,this._resultTracker=this._register(new ok),this._onAfterSearch=this._register(new Ym),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new Ym),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 nk(t),this._engine=new ik(t,this._lineCache.value),this._decorationManager=new ak(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Yc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=L3(()=>{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,p=a.row;d>=l&&(p+=Math.floor(d/l),d=d%l),c=this._engine.find(t,p,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 di=0,hi=0,fi=0,_s=0,$i;(e=>{function t(a,c,l,d){return d!==void 0?`#${Lc(a)}${Lc(c)}${Lc(l)}${Lc(d)}`:`#${Lc(a)}${Lc(c)}${Lc(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})($i||={});var ck;(e=>{function t(p,m){if(_s=(m.rgba&255)/255,_s===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=p.rgba>>24&255,S=p.rgba>>16&255,L=p.rgba>>8&255;di=v+Math.round((x-v)*_s),hi=S+Math.round((y-S)*_s),fi=L+Math.round((w-L)*_s);let E=$i.toCss(di,hi,fi),R=$i.toRgba(di,hi,fi);return{css:E,rgba:R}}e.blend=t;function r(p){return(p.rgba&255)===255}e.isOpaque=r;function n(p,m,x){let y=Hh.ensureContrastRatio(p.rgba,m.rgba,x);if(y)return $i.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let m=(p.rgba|255)>>>0;return[di,hi,fi]=Hh.toChannels(m),{css:$i.toCss(di,hi,fi),rgba:m}}e.opaque=a;function c(p,m){return _s=Math.round(m*255),[di,hi,fi]=Hh.toChannels(p.rgba),{css:$i.toCss(di,hi,fi,_s),rgba:$i.toRgba(di,hi,fi,_s)}}e.opacity=c;function l(p,m){return _s=p.rgba&255,c(p,_s*m/255)}e.multiplyOpacity=l;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(ck||={});var ki;(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 di=parseInt(a.slice(1,2).repeat(2),16),hi=parseInt(a.slice(2,3).repeat(2),16),fi=parseInt(a.slice(3,4).repeat(2),16),$i.toColor(di,hi,fi);case 5:return di=parseInt(a.slice(1,2).repeat(2),16),hi=parseInt(a.slice(2,3).repeat(2),16),fi=parseInt(a.slice(3,4).repeat(2),16),_s=parseInt(a.slice(4,5).repeat(2),16),$i.toColor(di,hi,fi,_s);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 di=parseInt(c[1],10),hi=parseInt(c[2],10),fi=parseInt(c[3],10),_s=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),$i.toColor(di,hi,fi,_s);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),[di,hi,fi,_s]=t.getImageData(0,0,1,1).data,_s!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$i.toRgba(di,hi,fi,_s),css:a}}e.toColor=n})(ki||={});var oa;(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,p=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=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(oa||={});var Hh;(e=>{function t(l,d){if(_s=(d&255)/255,_s===1)return d;let p=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return di=y+Math.round((p-y)*_s),hi=w+Math.round((m-w)*_s),fi=v+Math.round((x-v)*_s),$i.toRgba(di,hi,fi)}e.blend=t;function r(l,d,p){let m=oa.relativeLuminance(l>>8),x=oa.relativeLuminance(d>>8);if(Tl(m,x)<p){if(x<m){let v=n(l,d,p),S=Tl(m,oa.relativeLuminance(v>>8));if(S<p){let L=a(l,d,p),E=Tl(m,oa.relativeLuminance(L>>8));return S>E?v:L}return v}let y=a(l,d,p),w=Tl(m,oa.relativeLuminance(y>>8));if(w<p){let v=n(l,d,p),S=Tl(m,oa.relativeLuminance(v>>8));return w>S?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,L=Tl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));for(;L<p&&(w>0||v>0||S>0);)w-=Math.max(0,Math.ceil(w*.1)),v-=Math.max(0,Math.ceil(v*.1)),S-=Math.max(0,Math.ceil(S*.1)),L=Tl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,L=Tl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));for(;L<p&&(w<255||v<255||S<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),L=Tl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(Hh||={});function Lc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Tl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var uk=Object.freeze((()=>{let e=[ki.toColor("#2e3436"),ki.toColor("#cc0000"),ki.toColor("#4e9a06"),ki.toColor("#c4a000"),ki.toColor("#3465a4"),ki.toColor("#75507b"),ki.toColor("#06989a"),ki.toColor("#d3d7cf"),ki.toColor("#555753"),ki.toColor("#ef2929"),ki.toColor("#8ae234"),ki.toColor("#fce94f"),ki.toColor("#729fcf"),ki.toColor("#ad7fa8"),ki.toColor("#34e2e2"),ki.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:$i.toCss(n,a,c),rgba:$i.toRgba(n,a,c)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:$i.toCss(n,n,n),rgba:$i.toRgba(n,n,n)})}return e})());function Hx(e,t,r){return Math.max(t,Math.min(e,r))}function dk(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var I3=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,p=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?p:x.length;for(let v=y;v<w;v++){let S=x.getCell(v,a===r?n:r);if(!S){console.warn(`Can't get cell at row=${m}, col=${v}`);continue}this._nextCell(S,a,m,v),a=S}}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 W1(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function ol(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function E3(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 G1(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&E3(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 N3(e,t){let r=e;return typeof r.attributesEquals=="function"?r.attributesEquals(t):W1(e,t)&&ol(e,t)&&G1(e,t)}var hk=class extends I3{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&&!ol(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),p=c.getCell(0,this._nextRowFirstChar),m=p.getWidth()>1,x=!1;(p.getChars()&&m?this._nullCellCount<=1:this._nullCellCount<=0)&&((l.getChars()||l.getWidth()===0)&&ol(l,p)&&(x=!0),m&&(d.getChars()||d.getWidth()===0)&&ol(l,p)&&ol(d,p)&&(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(N3(t,r))return n;let a=!W1(t,r),c=!ol(t,r),l=!G1(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),E3(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 p=t.getUnderlineColor();t.isUnderlineColorRGB()?n.push("58:2::"+(p>>>16&255)+":"+(p>>>8&255)+":"+(p&255)):n.push("58:5:"+p)}}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?!ol(this._cursorStyle,t):l.length>0){this._nullCellCount>0&&(ol(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&&(ol(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,p=l!==this._lastCursorRow||d!==this._lastCursorCol,m=x=>{x>0?n+=`\x1B[${x}C`:x<0&&(n+=`\x1B[${-x}D`)};p&&((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}},fk=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,r,n){let a=r.length,c=n===void 0?a:Hx(n+t.rows,0,a);return this._serializeBufferByRange(t,r,{start:a-c,end:a-1},!1)}_serializeBufferByRange(t,r,n,a){return new hk(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 pk(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 p=n.length,m=r.scrollback,x=m===void 0?p:Hx(m+t.rows,0,p);return a.serialize({start:{x:0,y:p-x},end:{x:t.cols,y:p-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(){}},pk=class extends I3{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=uk}_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(N3(t,r))return;let a=!W1(t,r),c=!ol(t,r),l=!G1(t,r);if(a||c||l){let d=this._getHexColor(t,!0);d&&n.push("color: "+d+";");let p=this._getHexColor(t,!1);p&&n.push("background-color: "+p+";"),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+=dk(t.getChars())}_serializeString(){return this._htmlContent}};var mk=class{constructor(e=new gk,t=new R3){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}},R3=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},gk=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 xk=Object.create,M3=Object.defineProperty,bk=Object.getOwnPropertyDescriptor,yk=Object.getOwnPropertyNames,vk=Object.getPrototypeOf,wk=Object.prototype.hasOwnProperty,Ju=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Ak=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of yk(t))!wk.call(e,a)&&a!==r&&M3(e,a,{get:()=>t[a],enumerable:!(n=bk(t,a))||n.enumerable});return e},ed=(e,t,r)=>(r=e!=null?xk(vk(e)):{},Ak(!e||!e.__esModule?M3(r,"default",{value:e,enumerable:!0}):r,e)),V1=Ju(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,S,L,E=255){return((E&255)<<24|(L&255)<<16|(S&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,S){let L=t(v),E=r(v),R=n(v),B=Number.MAX_SAFE_INTEGER,z=-1;for(let O=0;O<S.length;++O){let $=L-S[O][0],V=E-S[O][1],Z=R-S[O][2],le=$*$+V*V+Z*Z;if(!le)return O;le<B&&(B=le,z=O)}return z}e.nearestColorIndex=d;function p(v,S,L){return Math.max(v,Math.min(L,S))}function m(v,S,L){return L<0&&(L+=1),L>1&&(L-=1),L*6<1?S+(v-S)*6*L:L*2<1?v:L*3<2?S+(v-S)*(4-L*6):S}function x(v,S,L){if(!L){let B=Math.round(S*255);return c(B,B,B)}let E=S<.5?S*(1+L):S+L-S*L,R=2*S-E;return c(p(0,255,Math.round(m(E,R,v+1/3)*255)),p(0,255,Math.round(m(E,R,v)*255)),p(0,255,Math.round(m(E,R,v-1/3)*255)))}function y(v,S,L){return(4278190080|Math.round(L/100*255)<<16|Math.round(S/100*255)<<8|Math.round(v/100*255))>>>0}e.normalizeRGB=y;function w(v,S,L){return x((v+240%360)/360,S/100,L/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)],S=[0,95,135,175,215,255];for(let L=0;L<6;++L)for(let E=0;E<6;++E)for(let R=0;R<6;++R)v.push(c(S[L],S[E],S[R]));for(let L=8;L<=238;L+=10)v.push(c(L,L,L));return new Uint32Array(v)})(),e.DEFAULT_BACKGROUND=c(0,0,0,255),e.DEFAULT_FOREGROUND=c(255,255,255,255)}),j3=Ju(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,p,m=WebAssembly;return a===0?c?x=>new m.Instance(p||(p=new m.Module(d||(d=t(l)))),x):x=>p?m.instantiate(p,x):m.instantiate(d||(d=t(l)),x).then(y=>(p=y.module)&&y.instance):a===1?c?()=>p||(p=new m.Module(d||(d=t(l)))):()=>p?Promise.resolve(p):m.compile(d||(d=t(l))).then(x=>p=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)}}),D3=Ju(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=j3(),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,p,m){if(this._inst=null,this._ended=!0,this._bytes=0,this.keepSize=d??1048576,this.maxBytes=p??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,p){if(this.maxBytes=d??this.maxBytes,this._bytes=p??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 p=this._m32[1280]+d;if(this._bytes<p){if(p>this.maxBytes)return-3;let m=this._bytes;for(;(m*=2)<p;);if(m=Math.min(m,this.maxBytes),m<p)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 p=this._m32;return this._d.set(d,p[1280]),p[1280]+=d.length,p[1280]-p[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}),Tk=Ju(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=j3(),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,p=Math.max(l,d)+(Math.min(l,d)>>1)+4096;this._inst?this._mem.buffer.byteLength<p&&(this._mem.grow(Math.ceil((p-this._mem.buffer.byteLength)/65536)),this._d=null):(this._mem=new WebAssembly.Memory({initial:Math.ceil(p/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}),Sk=Ju(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"}}),Ck=Ju(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=V1(),r=Sk();function n(v){if(typeof Buffer<"u")return Buffer.from(v,"base64");let S=atob(v),L=new Uint8Array(S.length);for(let E=0;E<L.length;++E)L[E]=S.charCodeAt(E);return L}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)}},p={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 S=new d,L={env:{handle_band:S.handle_band.bind(S),mode_parsed:S.mode_parsed.bind(S)}};return WebAssembly.instantiate(c||a,L).then(E=>(c=c||E.module,new x(v,E.instance||E,S)))}e.DecoderAsync=m;var x=class{constructor(v,S,L){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({},p,v),this._opts.paletteLimit>r.LIMITS.PALETTE_SIZE)throw new Error(`DecoderOptions.paletteLimit must not exceed ${r.LIMITS.PALETTE_SIZE}`);if(S)L.bandHandler=this._handle_band.bind(this),L.modeHandler=this._initCanvas.bind(this);else{let E=c||(c=new WebAssembly.Module(a));S=new WebAssembly.Instance(E,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=S,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 S=this.width*this.height;if(S>this._canvas.length){if(this._opts.memoryLimit&&S*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(S)}this._maxWidth=this._width}else if(v===1)if(this._level===2){let S=Math.min(this._rasterWidth,r.LIMITS.MAX_WIDTH)*this._rasterHeight;if(S>this._canvas.length){if(this._opts.memoryLimit&&S*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(S)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(v,S){let L=v+S;if(L>this._canvas.length){if(this._opts.memoryLimit&&L*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");let E=new Uint32Array(Math.ceil(L/65536)*65536);E.set(this._canvas),this._canvas=E}}_handle_band(v){let S=this._PIXEL_OFFSET,L=this._lastOffset;if(this._mode===2){let E=this.height-this._currentHeight,R=0;for(;R<6&&E>0;)this._canvas.set(this._pSrc.subarray(S*R,S*R+v),L+v*R),R++,E--;this._lastOffset+=v*R,this._currentHeight+=R}else if(this._mode===1){this._realloc(L,v*6),this._maxWidth=Math.max(this._maxWidth,v),this._minWidth=Math.min(this._minWidth,v);for(let E=0;E<6;++E)this._canvas.set(this._pSrc.subarray(S*E,S*E+v),L+v*E);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,S=this._opts.palette,L=this._opts.paletteLimit,E=this._opts.truncate){this._wasm.init(this._opts.sixelColor,v,L,E?1:0),S&&this._palette.set(S.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,S=0,L=v.length){let E=S;for(;E<L;){let R=Math.min(L-E,r.LIMITS.CHUNK_SIZE);this._chunk.set(v.subarray(E,E+=R)),this._wasm.decode(0,R)}}decodeString(v,S=0,L=v.length){let E=S;for(;E<L;){let R=Math.min(L-E,r.LIMITS.CHUNK_SIZE);for(let B=0,z=E;B<R;++B,++z)this._chunk[B]=v.charCodeAt(z);E+=R,this._wasm.decode(0,R)}}get data32(){if(this._mode===0||!this.width||!this.height)return l;let v=this._wasm.current_width();if(this._mode===2){let S=this.height-this._currentHeight;if(S>0){let L=this._PIXEL_OFFSET,E=this._lastOffset,R=0;for(;R<6&&S>0;)this._canvas.set(this._pSrc.subarray(L*R,L*R+v),E+v*R),R++,S--;S&&this._canvas.fill(this._fillColor,E+v*R)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let R=!1;if(v)if(v!==this._minWidth)R=!0;else{let B=this._PIXEL_OFFSET,z=this._lastOffset;this._realloc(z,v*6);for(let O=0;O<6;++O)this._canvas.set(this._pSrc.subarray(B*O,B*O+v),z+v*O)}if(!R)return this._canvas.subarray(0,this.width*this.height)}let S=new Uint32Array(this.width*this.height);S.fill(this._fillColor);let L=0,E=0;for(let R=0;R<this._bandWidths.length;++R){let B=this._bandWidths[R];for(let z=0;z<6;++z)S.set(this._canvas.subarray(E,E+=B),L),L+=this.width}if(v){let R=this._PIXEL_OFFSET,B=this._wasm.current_height();for(let z=0;z<B;++z)S.set(this._pSrc.subarray(R*z,R*z+v),L+this.width*z)}return S}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,S){let L=new x(S);return L.init(),typeof v=="string"?L.decodeString(v):L.decode(v),{width:L.width,height:L.height,data32:L.data32,data8:L.data8}}e.decode=y;async function w(v,S){let L=await m(S);return L.init(),typeof v=="string"?L.decodeString(v):L.decode(v),{width:L.width,height:L.height,data32:L.data32,data8:L.data8}}e.decodeAsync=w});function Zm(e){return{dispose:e}}var B3=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()}},Q3=class{constructor(){this._store=new B3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Q3.None=Object.freeze({dispose(){}});var _k=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}},kk=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Zm(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Zm(()=>{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)}},Lk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,p,m)=>c(x=>d.call(p,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,p)=>{let m=new B3;for(let x of c)m.add(x(y=>l.call(d,y)));return p&&(Array.isArray(p)?p.push(m):p.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(p=>l(p))}e.runAndSubscribe=a})(Lk||={});var Wx=ed(V1()),Wu=class sc extends Q3{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new _k),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(Zm(()=>{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:p}=this.cellSize;if(d===-1||p===-1)return;this._rescaleImage(t,d,p);let m=t.actual,x=Math.ceil(m.width/d),y=r%x*d,w=Math.floor(r/x)*p,v=n*d,S=a*p,L=c*d+y>m.width?m.width-y:c*d,E=w+p>m.height?m.height-w:p;l.drawImage(m,Math.floor(y),Math.floor(w),Math.ceil(L),Math.ceil(E),Math.floor(v),Math.floor(S),Math.ceil(L),Math.ceil(E))}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,p=Math.floor(r/l)*a,m=n+d>c.width?c.width-d:n,x=p+a>c.height?c.height-p:a,y=sc.createCanvas(this.document,m,x),w=y.getContext("2d");if(w)return w.drawImage(c,Math.floor(d),Math.floor(p),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=sc.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=sc.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=sc.createCanvas(this.document,r,t),a=n.getContext("2d",{alpha:!1});if(!a)return;let c=sc.createImageData(a,r,t),l=new Uint32Array(c.data.buffer),d=(0,Wx.toRGBA8888)(0,0,0),p=(0,Wx.toRGBA8888)(255,255,255);l.fill(d);for(let y=0;y<t;++y){let w=y%2,v=y*r;for(let S=0;S<r;S+=2)l[v+S+w]=p}a.putImageData(c,0,0);let m=screen.width+r-1&-32||4096;this._placeholder=sc.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);sc.createImageBitmap(this._placeholder).then(y=>this._placeholderBitmap=y)}get document(){return this._terminal._core._coreBrowserService?.window.document}},El={width:7,height:14},Km=class P3{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 P3(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},ah=new Km,Ik=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=El);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,p=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 E=0;E<a;++E){let R=l.lines.get(l.y+l.ybase);for(let B=0;B<n&&!(y+B>=d);++B)this._writeToCell(R,y+B,c,E*n+B),w++;if(t.scrolling)E<a-1&&this._terminal._core._inputHandler.lineFeed();else if(++l.y>=p)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[E,R]of this._images.entries())R.tileCount<1&&(R.marker?.dispose(),v.push(E));for(let E of v)this._delImg(E);let S=this._terminal.registerMarker(0);S?.onDispose(()=>{this._images.get(c)&&this._delImg(c)}),this._terminal.buffer.active.type==="alternate"&&this._evictOnAlternate();let L={orig:e,origCellSize:r,actual:e,actualCellSize:{...r},marker:S||void 0,tileCount:w,bufferType:this._terminal.buffer.active.type,layer:t.layer,zIndex:t.zIndex};return this._images.set(c,L),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=[],p=[];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 L=x._extendedAttrs[y];if(!L||L.imageId===void 0||L.imageId===-1)continue;w=L}let v=w.imageId;if(v===void 0||v===-1)continue;let S=this._images.get(v);if(w.tileId!==-1){let L=w.tileId,E=y,R=1;for(;++y<l;){let B=x._extendedAttrs[y];if(!B||B.imageId!==v||B.tileId!==L+R)break;R++}y--,S?S.actual&&d.push({imgSpec:S,tileId:L,col:E,row:m,count:R}):this._opts.showPlaceholder&&p.push({col:E,row:m,count:R}),this._fullyCleared=!1}}}d.sort((m,x)=>m.imgSpec.zIndex-x.imgSpec.zIndex);for(let m of p)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 p=this._images.get(d);if(!p)continue;let m=Math.ceil((p.actual?.width||0)/p.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),p.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=Wu.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 Km(a.ext,a.urlId,r,n);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new Km(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)}},Ek=ed(D3()),Nk=ed(Tk());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 Gx(e){let t=mf(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function Rk(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 Vx={inline:jp,size:jp,name:Rk,width:Gx,height:Gx,preserveAspectRatio:jp},qx=[70,105,108,101],Yx=[77,117,108,116,105,112,97,114,116,70,105,108,101],Dp=[70,105,108,101,80,97,114,116],Bp=[70,105,108,101,69,110,100],Qp=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],Pp=1024,Mk=class{constructor(){this.state=0,this._buffer=new Uint32Array(Pp),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===Bp.length){for(let t=0;t<Bp.length;++t)if(this._buffer[t]!==Bp[t])return this._a();return this.fields.type=4,this.state=4,0}if(this._position===Qp.length){for(let t=0;t<Qp.length;++t)if(this._buffer[t]!==Qp[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 p=t[d];switch(p){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<qx.length;++m)if(l[m]!==qx[m])return this._a();if(this.fields.type=1,c===Dp.length){for(;m<Dp.length;++m)if(l[m]!==Dp[m])return this._a();return this.fields.type=3,this.state=4,d+1}}else if(l[0]===77){for(let m=0;m<Yx.length;++m)if(l[m]!==Yx[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>=Pp)return this._a();l[c++]=p}break;case 58:return a===3&&!this._storeValue(c)?this._a():(this.state=4,d+1);default:if(c>=Pp)return this._a();l[c++]=p}}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]=Vx[this._key]?Vx[this._key](r):r}catch{return!1}return!0}return!1}},gf={mime:"unsupported",width:0,height:0};function jk(e){if(e.length<24)return gf;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]=Dk(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]}:gf}function Dk(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 Op={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},Bk=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._storage=r,this._coreTerminal=n,this._aborted=!1,this._hp=new Mk,this._header=Op,this._metrics=gf,this._isMultipart=!1,this._abortMulti=!1;let a=Math.ceil(this._opts.iipSizeLimit*4/3),c=Math.min(1048576,a);this._dec=new Ek.default(4194304,a,c),this._qoiDec=new Nk.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=gf,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({},Op,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=El.width,d=El.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 p=this._coreTerminal._core._coreBrowserService?.dpr??1,m=`\x1B]1337;ReportCellSize=${d.toFixed(3)};${l.toFixed(3)};${p.toFixed(3)}\x1B\\`;return this._coreTerminal.input(m,!1),!0}if(t===2)return this._header=Object.assign({},Op,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=jk(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=Wu.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||El.width,n=this._renderer.dimensions?.css.cell.height||El.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 p=a/e,m=(c-n)/t,x=Math.min(p,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}},Qk=ed(D3());function Zx(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 Kx=0,Pk=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=Zx(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 Qk.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,r))!==Kx&&(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 p=new Uint8Array(0);d&&(d.end()!==Kx&&(c=!0),p=d.data8),this._activeDecoder=null;let m=this._handleCommandWithBytesAndCmd(l,p,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=Zx(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 p=c===32?4:3,m=l*d*p;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),p=Math.max(0,r.height-a),m=Math.max(0,Math.min(c,d)),x=Math.max(0,Math.min(l,p));if(m===0||x===0)throw new Error("invalid source rectangle");if(n!==0||a!==0||m!==r.width||x!==r.height){let be=await createImageBitmap(r,n,a,m,x);r.close(),r=be}let y=this._renderer.dimensions?.css.cell.width||El.width,w=this._renderer.dimensions?.css.cell.height||El.height,v,S;t.columns!==void 0&&t.rows!==void 0?(v=t.columns,S=t.rows):t.columns!==void 0?(v=t.columns,S=Math.max(1,Math.ceil(r.height/r.width*(v*y)/w))):t.rows!==void 0?(S=t.rows,v=Math.max(1,Math.ceil(r.width/r.height*(S*w)/y))):(v=Math.ceil(r.width/y),S=Math.ceil(r.height/w));let L=r.width,E=r.height;if((t.columns!==void 0||t.rows!==void 0)&&(L=Math.round(v*y),E=Math.round(S*w)),L*E>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");let R=this._coreTerminal._core.buffer,B=R.x,z=R.y,O=R.ybase,$=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(L!==r.width||E!==r.height){let be=await createImageBitmap(r,{resizeWidth:L,resizeHeight:E});r.close(),r=be}let V=Math.min(Math.max(0,t.xOffset??0),y-1),Z=Math.min(Math.max(0,t.yOffset??0),w-1);if(V!==0||Z!==0){let be=t.columns!==void 0?Math.round(v*y):r.width+V,pe=t.rows!==void 0?Math.round(S*w):r.height+Z,ee=Wu.createCanvas(window.document,be,pe),_e=ee.getContext("2d");if(!_e)throw new Error("Failed to create offset canvas context");_e.drawImage(r,V,Z);let ze=await createImageBitmap(ee);if(ee.width=ee.height=0,r.close(),r=ze,L=r.width,E=r.height,L*E>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");t.columns===void 0&&(v=Math.ceil(r.width/y)),t.rows===void 0&&(S=Math.ceil(r.height/w))}let le=t.zIndex??0;if(this._kittyStorage.addImage(e.id,r,!0,$,le),r=void 0,t.cursorMovement===1){let be=R.ybase-O;R.x=B,R.y=Math.max(z-be,0)}else R.x=Math.min(B+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 L=new Blob([t],{type:"image/png"});if(!window.createImageBitmap){let E=URL.createObjectURL(L),R=new Image;return new Promise((B,z)=>{R.addEventListener("load",()=>{URL.revokeObjectURL(E);let O=Wu.createCanvas(window.document,R.width,R.height);O.getContext("2d")?.drawImage(R,0,0),createImageBitmap(O).then(B).catch(z)}),R.addEventListener("error",()=>{URL.revokeObjectURL(E),z(new Error("Failed to load image"))}),R.src=E})}return createImageBitmap(L)}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),p=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 L=0;L<x;L+=4){let E=p[y++],R=p[y++],B=p[y++];m[w++]=4278190080|E,m[w++]=4278190080|E>>>24|R<<8,m[w++]=4278190080|R>>>16|B<<16,m[w++]=4278190080|B>>>8}let v=x*3,S=x*4;for(let L=x;L<l;L++)d[S]=t[v],d[S+1]=t[v+1],d[S+2]=t[v+2],d[S+3]=255,v+=3,S+=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),p=0;for(let m of a)d.set(m,p),p+=m.length;return d}get images(){return this._kittyStorage.images}get _kittyIdToStorageId(){return this._kittyStorage.kittyIdToStorageId}get pendingTransmissions(){return this._pendingTransmissions}},O3=class Xm{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>=Xm._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<=Xm._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};O3._maxStoredImages=256;var Ok=O3,v0=ed(V1()),Fk=ed(Ck()),$k=4194304,Jm=v0.PALETTE_ANSI_256;Jm.set(v0.PALETTE_VT340_COLOR);var Uk=class{constructor(e,t,r){this._opts=e,this._storage=t,this._coreTerminal=r,this._size=0,this._aborted=!1,(0,Fk.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:Jm,paletteLimit:this._opts.sixelPaletteLimit}).then(n=>this._dec=n)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Jm,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:zk(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=Wu.createCanvas(void 0,t,r);return n.getContext("2d")?.putImageData(new ImageData(this._dec.data8,t,r),0,0),this._dec.memoryUsage>$k&&this._dec.release(),this._storage.addImage(n),!0}};function zk(e,t){let r=0;if(!t)return r;if(e.isInverse())if(e.isFgDefault())r=oh(t.foreground.rgba);else if(e.isFgRGB()){let n=e.constructor.toColorRGB(e.getFgColor());r=(0,v0.toRGBA8888)(...n)}else r=oh(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())r=oh(t.background.rgba);else if(e.isBgRGB()){let n=e.constructor.toColorRGB(e.getBgColor());r=(0,v0.toRGBA8888)(...n)}else r=oh(t.ansi[e.getBgColor()].rgba);return r}function oh(e){return v0.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var Hk=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=El);let r=Math.ceil(e/t.height);for(let n=1;n<r;++n)this._terminal._core._inputHandler.lineFeed()}}},Wk=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},Xx={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},Jx=4096,Gk=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new kk,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},Xx,t),this._defaultOpts=Object.assign({},Xx,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 Wu(t),this._storage=new Ik(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 Hk(this._storage,this._opts,this._renderer,t),n=new Uk(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 Wk(this._storage),n=new Bk(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 Ok(this._storage),n=new Pk(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]<=Jx?(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;${Jx}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=El;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 hu=new Map;function ku(e){return{name:e,get hasSubscribers(){return(hu.get(e)?.size??0)>0},publish(t){const r=hu.get(e);if(r)for(const n of r)n(t,e)},subscribe(t){const r=hu.get(e)??new Set;r.add(t),hu.set(e,r)},unsubscribe(t){const r=hu.get(e);if(!r)return!1;const n=r.delete(t);return r.size===0&&hu.delete(e),n}}}function Vk(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},r={start:ku(t.start),end:ku(t.end),asyncStart:ku(t.asyncStart),asyncEnd:ku(t.asyncEnd),error:ku(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 p=n.apply(l,d);return r.end.publish(c),p}catch(p){throw r.error.publish(p),p}}};return r}var qk=Object.create,q1=Object.defineProperty,Yk=Object.getOwnPropertyDescriptor,Zk=Object.getOwnPropertyNames,Kk=Object.getPrototypeOf,Xk=Object.prototype.hasOwnProperty,F3=e=>{throw TypeError(e)},Jk=(e,t,r)=>t in e?q1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,eL=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},tL=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Zk(t))!Xk.call(e,a)&&a!==r&&q1(e,a,{get:()=>t[a],enumerable:!(n=Yk(t,a))||n.enumerable});return e},rL=(e,t,r)=>(r=e!=null?qk(Kk(e)):{},tL(!e||!e.__esModule?q1(r,"default",{value:e,enumerable:!0}):r,e)),Ys=(e,t,r)=>Jk(e,typeof t!="symbol"?t+"":t,r),Y1=(e,t,r)=>t.has(e)||F3("Cannot "+r),ie=(e,t,r)=>(Y1(e,t,"read from private field"),r?r.call(e):t.get(e)),vn=(e,t,r)=>t.has(e)?F3("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ir=(e,t,r,n)=>(Y1(e,t,"write to private field"),t.set(e,r),r),Ht=(e,t,r)=>(Y1(e,t,"access private method"),r),Fp=(e,t,r,n)=>({set _(a){Ir(e,t,a)},get _(){return ie(e,t,n)}}),nL=eL((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})},p=(i,o,u,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let f of c(o))!l.call(i,f)&&f!==u&&n(i,f,{get:()=>o[f],enumerable:!(h=a(o,f))||h.enumerable});return i},m=i=>p(n({},"__esModule",{value:!0}),i),x={};d(x,{BoundingBox:()=>ne,Font:()=>Zg,Glyph:()=>pr,Path:()=>We,_parse:()=>ot,load:()=>Yw,loadSync:()=>Zw,parse:()=>qw});var y=0,w=-3;function v(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function S(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 L=new v,E=new v,R=new Uint8Array(30),B=new Uint16Array(30),z=new Uint8Array(30),O=new Uint16Array(30),$=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),V=new v,Z=new Uint8Array(320);function le(i,o,u,h){var f,g;for(f=0;f<u;++f)i[f]=0;for(f=0;f<30-u;++f)i[f+u]=f/u|0;for(g=h,f=0;f<30;++f)o[f]=g,g+=1<<i[f]}function be(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 ee(i,o,u,h){var f,g;for(f=0;f<16;++f)i.table[f]=0;for(f=0;f<h;++f)i.table[o[u+f]]++;for(i.table[0]=0,g=0,f=0;f<16;++f)pe[f]=g,g+=i.table[f];for(f=0;f<h;++f)o[u+f]&&(i.trans[pe[o[u+f]]++]=f)}function _e(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 Y(i,o){for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var u=0,h=0,f=0,g=i.tag;do h=2*h+(g&1),g>>>=1,++f,u+=o.table[f],h-=o.table[f];while(h>=0);return i.tag=g,i.bitcount-=f,o.trans[u+h]}function ce(i,o,u){var h,f,g,A,_,I;for(h=ze(i,5,257),f=ze(i,5,1),g=ze(i,4,4),A=0;A<19;++A)Z[A]=0;for(A=0;A<g;++A){var D=ze(i,3,0);Z[$[A]]=D}for(ee(V,Z,0,19),_=0;_<h+f;){var M=Y(i,V);switch(M){case 16:var te=Z[_-1];for(I=ze(i,2,3);I;--I)Z[_++]=te;break;case 17:for(I=ze(i,3,3);I;--I)Z[_++]=0;break;case 18:for(I=ze(i,7,11);I;--I)Z[_++]=0;break;default:Z[_++]=M;break}}ee(o,Z,0,h),ee(u,Z,h,f)}function qe(i,o,u){for(;;){var h=Y(i,o);if(h===256)return y;if(h<256)i.dest[i.destLen++]=h;else{var f,g,A,_;for(h-=257,f=ze(i,R[h],B[h]),g=Y(i,u),A=i.destLen-ze(i,z[g],O[g]),_=A;_<A+f;++_)i.dest[i.destLen++]=i.dest[_]}}}function we(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 S(i,o),h,f,g;do{switch(h=_e(u),f=ze(u,2,0),f){case 0:g=we(u);break;case 1:g=qe(u,L,E);break;case 2:ce(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}be(L,E),le(R,B,4,3),le(z,O,2,1),R[28]=0,B[28]=258;function Le(i,o,u,h,f){return Math.pow(1-f,3)*i+3*Math.pow(1-f,2)*f*o+3*(1-f)*Math.pow(f,2)*u+Math.pow(f,3)*h}function Be(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Be.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Be.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))},Be.prototype.addX=function(i){this.addPoint(i,null)},Be.prototype.addY=function(i){this.addPoint(null,i)},Be.prototype.addBezier=function(i,o,u,h,f,g,A,_){let I=[i,o],D=[u,h],M=[f,g],te=[A,_];this.addPoint(i,o),this.addPoint(A,_);for(let J=0;J<=1;J++){let Te=6*I[J]-12*D[J]+6*M[J],he=-3*I[J]+9*D[J]-9*M[J]+3*te[J],Re=3*D[J]-3*I[J];if(he===0){if(Te===0)continue;let Rr=-Re/Te;0<Rr&&Rr<1&&(J===0&&this.addX(Le(I[J],D[J],M[J],te[J],Rr)),J===1&&this.addY(Le(I[J],D[J],M[J],te[J],Rr)));continue}let ct=Math.pow(Te,2)-4*Re*he;if(ct<0)continue;let mr=(-Te+Math.sqrt(ct))/(2*he);0<mr&&mr<1&&(J===0&&this.addX(Le(I[J],D[J],M[J],te[J],mr)),J===1&&this.addY(Le(I[J],D[J],M[J],te[J],mr)));let lr=(-Te-Math.sqrt(ct))/(2*he);0<lr&&lr<1&&(J===0&&this.addX(Le(I[J],D[J],M[J],te[J],lr)),J===1&&this.addY(Le(I[J],D[J],M[J],te[J],lr)))}},Be.prototype.addQuad=function(i,o,u,h,f,g){let A=i+.6666666666666666*(u-i),_=o+2/3*(h-o),I=A+1/3*(f-i),D=_+1/3*(g-o);this.addBezier(i,o,A,_,I,D,f,g)};var ne=Be;function Fe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var ke={};function Ee(i,o){let u=Math.floor(i),h=i-u;if(ke[o]||(ke[o]={}),ke[o][h]!==void 0){let g=ke[o][h];return u+g}let f=+(Math.round(h+"e+"+o)+"e-"+o);return ke[o][h]=f,u+f}function Pe(i){let o=[[]],u=0,h=0;for(let f=0;f<i.length;f+=1){let g=o[o.length-1],A=i[f],_=g[0],I=g[1],D=g[g.length-1],M=i[f+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"&&D&&D.x===A.x&&D.y===A.y?g.pop():A.type==="Z"&&(_&&I&&D&&_.type==="M"&&I.type==="L"&&D.type==="L"&&D.x===_.x&&D.y===_.y&&(g.shift(),g[0].type="M"),f+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 oe(i){return parseInt(i)===i&&(i={decimalPlaces:i,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},i)}Fe.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",f="SsTtAa",g="-+",A={},_=[""],I=!1;function D(he){return he.filter(Re=>Re.length).map(Re=>{let ct=parseFloat(Re);return(o.decimalPlaces||o.decimalPlaces===0)&&(ct=Ee(ct,o.decimalPlaces)),ct})}function M(he){if(!this.commands.length)return he;let Re=this.commands[this.commands.length-1];for(let ct=0;ct<he.length;ct++)he[ct]+=Re[ct&1?"y":"x"];return he}function te(){if(A.type===void 0)return;let he=A.type.toUpperCase(),Re=he!=="Z"&&A.type.toUpperCase()!==A.type,ct=D(_);if(_=[""],!ct.length&&he!=="Z")return;Re&&he!=="H"&&he!=="V"&&(ct=M.apply(this,[ct]));let mr=this.commands.length&&this.commands[this.commands.length-1].x||0,lr=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(he){case"M":this.moveTo(...ct);break;case"L":this.lineTo(...ct);break;case"V":for(let Rr=0;Rr<ct.length;Rr++){let sn=0;Re&&(sn=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(mr,ct[Rr]+sn)}break;case"H":for(let Rr=0;Rr<ct.length;Rr++){let sn=0;Re&&(sn=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(ct[Rr]+sn,lr)}break;case"C":this.bezierCurveTo(...ct);break;case"Q":this.quadraticCurveTo(...ct);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let Rr in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Rr]===void 0&&(this.commands[this.commands.length-1][Rr]=0)}for(let he=0;he<i.length;he++){let Re=i.charAt(he),ct=_[_.length-1];if(u.indexOf(Re)>-1)_[_.length-1]+=Re;else if(g.indexOf(Re)>-1)if(!A.type&&!this.commands.length&&(A.type="L"),Re==="-")!A.type||ct.indexOf("-")>0?I=!0:ct.length?_.push("-"):_[_.length-1]=Re;else if(!A.type||ct.length>0)I=!0;else continue;else if(h.indexOf(Re)>-1)A.type?(te.apply(this),A={type:Re}):A.type=Re;else{if(f.indexOf(Re)>-1)throw new Error("Unsupported path command: "+Re+". Currently supported commands are "+h.split("").join(", ")+".");` ,
69
+ \r\f\v`.indexOf(Re)>-1?_.push(""):Re==="."?!A.type||ct.indexOf(Re)>-1?I=!0:_[_.length-1]+=Re:I=!0}if(I)throw new Error("Unexpected character: "+Re+" at offset "+he)}te.apply(this),o.optimize&&(this.commands=Pe(this.commands));let J=o.flipY,Te=o.flipYBase;if(J===!0&&o.flipYBase===void 0){let he=this.getBoundingBox();Te=he.y1+he.y2}for(let he in this.commands){let Re=this.commands[he];for(let ct in Re)["x","x1","x2"].includes(ct)?this.commands[he][ct]=o.x+Re[ct]*o.scale:["y","y1","y2"].includes(ct)&&(this.commands[he][ct]=o.y+(J?Te-Re[ct]:Re[ct])*o.scale)}return this},Fe.fromSVG=function(i,o){return new Fe().fromSVG(i,o)},Fe.prototype.moveTo=function(i,o){this.commands.push({type:"M",x:i,y:o})},Fe.prototype.lineTo=function(i,o){this.commands.push({type:"L",x:i,y:o})},Fe.prototype.curveTo=Fe.prototype.bezierCurveTo=function(i,o,u,h,f,g){this.commands.push({type:"C",x1:i,y1:o,x2:u,y2:h,x:f,y:g})},Fe.prototype.quadTo=Fe.prototype.quadraticCurveTo=function(i,o,u,h){this.commands.push({type:"Q",x1:i,y1:o,x:u,y:h})},Fe.prototype.close=Fe.prototype.closePath=function(){this.commands.push({type:"Z"})},Fe.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof ne){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)},Fe.prototype.getBoundingBox=function(){let i=new ne,o=0,u=0,h=0,f=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=f=A.y;break;case"L":i.addPoint(A.x,A.y),h=A.x,f=A.y;break;case"Q":i.addQuad(h,f,A.x1,A.y1,A.x,A.y),h=A.x,f=A.y;break;case"C":i.addBezier(h,f,A.x1,A.y1,A.x2,A.y2,A.x,A.y),h=A.x,f=A.y;break;case"Z":h=o,f=u;break;default:throw new Error("Unexpected path command "+A.type)}}return i.isEmpty()&&i.addPoint(0,0),i},Fe.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 f=this.commands[h];f.type==="M"?i.moveTo(f.x,f.y):f.type==="L"?i.lineTo(f.x,f.y):f.type==="C"?i.bezierCurveTo(f.x1,f.y1,f.x2,f.y2,f.x,f.y):f.type==="Q"?i.quadraticCurveTo(f.x1,f.y1,f.x,f.y):f.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())},Fe.prototype.toPathData=function(i){i=oe(i);function o(_){let I=Ee(_,i.decimalPlaces);return Math.round(_)===I?""+I:I.toFixed(i.decimalPlaces)}function u(){let _="";for(let I=0;I<arguments.length;I+=1){let D=arguments[I];D>=0&&I>0&&(_+=" "),_+=o(D)}return _}let h=this.commands;i.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=Pe(h));let f=i.flipY,g=i.flipYBase;if(f===!0&&g===void 0){let _=new Fe;_.extend(h);let I=_.getBoundingBox();g=I.y1+I.y2}let A="";for(let _=0;_<h.length;_+=1){let I=h[_];I.type==="M"?A+="M"+u(I.x,f?g-I.y:I.y):I.type==="L"?A+="L"+u(I.x,f?g-I.y:I.y):I.type==="C"?A+="C"+u(I.x1,f?g-I.y1:I.y1,I.x2,f?g-I.y2:I.y2,I.x,f?g-I.y:I.y):I.type==="Q"?A+="Q"+u(I.x1,f?g-I.y1:I.y1,I.x,f?g-I.y:I.y):I.type==="Z"&&(A+="Z")}return A},Fe.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},Fe.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 We=Fe;function nt(i){throw new Error(i)}function gt(i,o){i||nt(o)}var ue={fail:nt,argument:gt,assert:gt},Ze=32768,at=2147483648,Ie=-32768,Ge=32767+1/65536,Ce={},H={},ae={};function Ae(i){return function(){return i}}H.BYTE=function(i){return ue.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},ae.BYTE=Ae(1),H.CHAR=function(i){return[i.charCodeAt(0)]},ae.CHAR=Ae(1),H.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},ae.CHARARRAY=function(i){return typeof i>"u"?0:i.length},H.USHORT=function(i){return[i>>8&255,i&255]},ae.USHORT=Ae(2),H.SHORT=function(i){return i>=Ze&&(i=-(2*Ze-i)),[i>>8&255,i&255]},ae.SHORT=Ae(2),H.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},ae.UINT24=Ae(3),H.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},ae.ULONG=Ae(4),H.LONG=function(i){return i>=at&&(i=-(2*at-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},ae.LONG=Ae(4),H.FLOAT=function(i){if(i>Ge||i<Ie)throw new Error(`Value ${i} is outside the range of representable values in 16.16 format`);let o=Math.round(i*65536)<<0;return H.ULONG(o)},ae.FLOAT=ae.ULONG,H.FIXED=H.ULONG,ae.FIXED=ae.ULONG,H.FWORD=H.SHORT,ae.FWORD=ae.SHORT,H.UFWORD=H.USHORT,ae.UFWORD=ae.USHORT,H.F2DOT14=function(i){return H.USHORT(i*16384)},ae.F2DOT14=ae.USHORT,H.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},ae.LONGDATETIME=Ae(8),H.TAG=function(i){return ue.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},ae.TAG=Ae(4),H.Card8=H.BYTE,ae.Card8=ae.BYTE,H.Card16=H.USHORT,ae.Card16=ae.USHORT,H.OffSize=H.BYTE,ae.OffSize=ae.BYTE,H.SID=H.USHORT,ae.SID=ae.USHORT,H.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?H.NUMBER16(i):H.NUMBER32(i)},ae.NUMBER=function(i){return H.NUMBER(i).length},H.NUMBER16=function(i){return[28,i>>8&255,i&255]},ae.NUMBER16=Ae(3),H.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},ae.NUMBER32=Ae(5),H.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 _=o[g];_==="e"?h+=o[++g]==="-"?"c":"b":_==="."?h+="a":_==="-"?h+="e":h+=_}h+=h.length&1?"f":"ff";let f=[30];for(let g=0,A=h.length;g<A;g+=2)f.push(parseInt(h.substr(g,2),16));return f},ae.REAL=function(i){return H.REAL(i).length},H.NAME=H.CHARARRAY,ae.NAME=ae.CHARARRAY,H.STRING=H.CHARARRAY,ae.STRING=ae.CHARARRAY,Ce.UTF8=function(i,o,u){let h=[],f=u;for(let g=0;g<f;g++,o+=1)h[g]=i.getUint8(o);return String.fromCharCode.apply(null,h)},Ce.UTF16=function(i,o,u){let h=[],f=u/2;for(let g=0;g<f;g++,o+=2)h[g]=i.getUint16(o);return String.fromCharCode.apply(null,h)},H.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},ae.UTF16=function(i){return i.length*2};var Ye={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Ce.MACSTRING=function(i,o,u,h){let f=Ye[h];if(f===void 0)return;let g="";for(let A=0;A<u;A++){let _=i.getUint8(o+A);_<=127?g+=String.fromCharCode(_):g+=f[_&127]}return g};var et=typeof WeakMap=="function"&&new WeakMap,St,Gt=function(i){if(!St){St={};for(let f in Ye)St[f]=new String(f)}let o=St[i];if(o===void 0)return;if(et){let f=et.get(o);if(f!==void 0)return f}let u=Ye[i];if(u===void 0)return;let h={};for(let f=0;f<u.length;f++)h[u.charCodeAt(f)]=f+128;return et&&et.set(o,h),h};H.MACSTRING=function(i,o){let u=Gt(o);if(u===void 0)return;let h=[];for(let f=0;f<i.length;f++){let g=i.charCodeAt(f);if(g>=128&&(g=u[g],g===void 0))return;h[f]=g}return h},ae.MACSTRING=function(i,o){let u=H.MACSTRING(i,o);return u!==void 0?u.length:0};function Qt(i){return i>=-128&&i<=127}function wt(i,o,u){let h=0,f=i.length;for(;o<f&&h<64&&i[o]===0;)++o,++h;return u.push(128|h-1),o}function zt(i,o,u){let h=0,f=i.length,g=o;for(;g<f&&h<64;){let A=i[g];if(!Qt(A)||A===0&&g+1<f&&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 Vt(i,o,u){let h=0,f=i.length,g=o;for(;g<f&&h<64;){let A=i[g];if(A===0||Qt(A)&&g+1<f&&Qt(i[g+1]))break;++g,++h}u.push(64|h-1);for(let A=o;A<g;++A){let _=i[A];u.push(_+65536>>8&255,_+256&255)}return g}H.VARDELTAS=function(i){let o=0,u=[];for(;o<i.length;){let h=i[o];h===0?o=wt(i,o,u):h>=-128&&h<=127?o=zt(i,o,u):o=Vt(i,o,u)}return u},H.INDEX=function(i){let o=1,u=[o],h=[];for(let _=0;_<i.length;_+=1){let I=H.OBJECT(i[_]);Array.prototype.push.apply(h,I),o+=I.length,u.push(o)}if(h.length===0)return[0,0];let f=[],g=1+Math.floor(Math.log(o)/Math.log(2))/8|0,A=[void 0,H.BYTE,H.USHORT,H.UINT24,H.ULONG][g];for(let _=0;_<u.length;_+=1){let I=A(u[_]);Array.prototype.push.apply(f,I)}return Array.prototype.concat(H.Card16(i.length),H.OffSize(g),f,h)},ae.INDEX=function(i){return H.INDEX(i).length},H.DICT=function(i){let o=[],u=Object.keys(i),h=u.length;for(let f=0;f<h;f+=1){let g=parseInt(u[f],0),A=i[g],_=H.OPERAND(A.value,A.type),I=H.OPERATOR(g);for(let D=0;D<_.length;D++)o.push(_[D]);for(let D=0;D<I.length;D++)o.push(I[D])}return o},ae.DICT=function(i){return H.DICT(i).length},H.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},H.OPERAND=function(i,o){let u=[];if(Array.isArray(o))for(let h=0;h<o.length;h+=1){ue.argument(i.length===o.length,"Not enough arguments given for type"+o);let f=H.OPERAND(i[h],o[h]);for(let g=0;g<f.length;g++)u.push(f[g])}else if(o==="SID"){let h=H.NUMBER(i);for(let f=0;f<h.length;f++)u.push(h[f])}else if(o==="offset"){let h=H.NUMBER32(i);for(let f=0;f<h.length;f++)u.push(h[f])}else if(o==="number"){let h=H.NUMBER(i);for(let f=0;f<h.length;f++)u.push(h[f])}else if(o==="real"){let h=H.REAL(i);for(let f=0;f<h.length;f++)u.push(h[f])}else throw new Error("Unknown operand type "+o);return u},H.OP=H.BYTE,ae.OP=ae.BYTE;var Kt=typeof WeakMap=="function"&&new WeakMap;H.CHARSTRING=function(i){if(Kt){let h=Kt.get(i);if(h!==void 0)return h}let o=[],u=i.length;for(let h=0;h<u;h+=1){let f=i[h],g=H[f.type](f.value);for(let A=0;A<g.length;A++)o.push(g[A])}return Kt&&Kt.set(i,o),o},ae.CHARSTRING=function(i){return H.CHARSTRING(i).length},H.OBJECT=function(i){let o=H[i.type];return ue.argument(o!==void 0,"No encoding function for type "+i.type),o(i.value)},ae.OBJECT=function(i){let o=ae[i.type];return ue.argument(o!==void 0,"No sizeOf function for type "+i.type),o(i.value)},H.TABLE=function(i){let o=[],u=(i.fields||[]).length,h=[],f=[];for(let g=0;g<u;g+=1){let A=i.fields[g],_=H[A.type];ue.argument(_!==void 0,"No encoding function for field type "+A.type+" ("+A.name+")");let I=i[A.name];I===void 0&&(I=A.value);let D=_(I);if(A.type==="TABLE")I.fields!==null&&(f.push(o.length),h.push(D)),o.push(0,0);else for(let M=0;M<D.length;M++)o.push(D[M])}for(let g=0;g<h.length;g+=1){let A=f[g],_=o.length;ue.argument(_<65536,"Table "+i.tableName+" too big."),o[A]=_>>8,o[A+1]=_&255;for(let I=0;I<h[g].length;I++)o.push(h[g][I])}return o},ae.TABLE=function(i){let o=0,u=(i.fields||[]).length;for(let h=0;h<u;h+=1){let f=i.fields[h],g=ae[f.type];ue.argument(g!==void 0,"No sizeOf function for field type "+f.type+" ("+f.name+")");let A=i[f.name];A===void 0&&(A=f.value),o+=g(A),f.type==="TABLE"&&(o+=2)}return o},H.RECORD=H.TABLE,ae.RECORD=ae.TABLE,H.LITERAL=function(i){return i},ae.LITERAL=function(i){return i.length};function Ot(i,o,u){if(o&&o.length)for(let h=0;h<o.length;h+=1){let f=o[h];this[f.name]=f.value}if(this.tableName=i,this.fields=o,u){let h=Object.keys(u);for(let f=0;f<h.length;f+=1){let g=h[f],A=u[g];this[g]!==void 0&&(this[g]=A)}}}Ot.prototype.encode=function(){return H.TABLE(this)},Ot.prototype.sizeOf=function(){return ae.TABLE(this)};function It(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 f=0;f<o.length;f++)h[f+1]={name:i+f,type:"USHORT",value:o[f]};return h}function xe(i,o,u){let h=o.length,f=new Array(h+1);f[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)f[g+1]={name:i+g,type:"TABLE",value:u(o[g],g)};return f}function Ve(i,o,u){let h=o.length,f=[];f[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)f=f.concat(u(o[g],g));return f}function ht(i){i.format===1?Ot.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(It("glyph",i.glyphs))):i.format===2?Ot.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Ve("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}]}))):ue.assert(!1,"Coverage format must be 1 or 2.")}ht.prototype=Object.create(Ot.prototype),ht.prototype.constructor=ht;function q(i){Ot.call(this,"scriptListTable",Ve("scriptRecord",i,function(o,u){let h=o.script,f=h.defaultLangSys;return ue.assert(!!f,"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 Ot("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Ot("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:f.reqFeatureIndex}].concat(It("featureIndex",f.featureIndexes)))}].concat(Ve("langSys",h.langSysRecords,function(g,A){let _=g.langSys;return[{name:"langSysTag"+A,type:"TAG",value:g.tag},{name:"langSys"+A,type:"TABLE",value:new Ot("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:_.reqFeatureIndex}].concat(It("featureIndex",_.featureIndexes)))}]})))}]}))}q.prototype=Object.create(Ot.prototype),q.prototype.constructor=q;function ut(i){Ot.call(this,"featureListTable",Ve("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 Ot("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(It("lookupListIndex",h.lookupListIndexes)))}]}))}ut.prototype=Object.create(Ot.prototype),ut.prototype.constructor=ut;function qt(i,o){Ot.call(this,"lookupListTable",xe("lookup",i,function(u){let h=o[u.lookupType];return ue.assert(!!h,"Unable to write GSUB lookup type "+u.lookupType+" tables."),new Ot("lookupTable",[{name:"lookupType",type:"USHORT",value:u.lookupType},{name:"lookupFlag",type:"USHORT",value:u.lookupFlag}].concat(xe("subtable",u.subtables,h)))}))}qt.prototype=Object.create(Ot.prototype),qt.prototype.constructor=qt;function tt(i){i.format===1?Ot.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:i.startGlyph}].concat(It("glyph",i.classes))):i.format===2?Ot.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Ve("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}]}))):ue.assert(!1,"Class format must be 1 or 2.")}tt.prototype=Object.create(Ot.prototype),tt.prototype.constructor=tt;var De={Table:Ot,Record:Ot,Coverage:ht,ClassDef:tt,ScriptList:q,FeatureList:ut,LookupList:qt,ushortList:It,tableList:xe,recordList:Ve};function nr(i,o){return i.getUint8(o)}function Ke(i,o){return i.getUint16(o,!1)}function _t(i,o){return i.getInt16(o,!1)}function $t(i,o){return(i.getUint16(o)<<8)+i.getUint8(o+2)}function yt(i,o){return i.getUint32(o,!1)}function xt(i,o){return i.getInt32(o,!1)}function Rt(i,o){let u=i.getInt16(o,!1),h=i.getUint16(o+2,!1);return u+h/65535}function Ct(i,o){let u="";for(let h=o;h<o+4;h+=1)u+=String.fromCharCode(i.getInt8(h));return u}function fr(i,o,u){let h=0;for(let f=0;f<u;f+=1)h<<=8,h+=i.getUint8(o+f);return h}function Yt(i,o,u){let h=[];for(let f=o;f<u;f+=1)h.push(i.getUint8(f));return h}function Sr(i){let o="";for(let u=0;u<i.length;u+=1)o+=String.fromCharCode(i[u]);return o}var pn={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},dr={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 me(i,o){this.data=i,this.offset=o,this.relativeOffset=0}me.prototype.parseByte=function(){let i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},me.prototype.parseChar=function(){let i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},me.prototype.parseCard8=me.prototype.parseByte,me.prototype.parseUShort=function(){let i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},me.prototype.parseCard16=me.prototype.parseUShort,me.prototype.parseSID=me.prototype.parseUShort,me.prototype.parseOffset16=me.prototype.parseUShort,me.prototype.parseShort=function(){let i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},me.prototype.parseF2Dot14=function(){let i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},me.prototype.parseUInt24=function(){let i=$t(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,i},me.prototype.parseULong=function(){let i=yt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},me.prototype.parseLong=function(){let i=xt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},me.prototype.parseOffset32=me.prototype.parseULong,me.prototype.parseFixed=function(){let i=Rt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},me.prototype.parseString=function(i){let o=this.data,u=this.offset+this.relativeOffset,h="";this.relativeOffset+=i;for(let f=0;f<i;f++)h+=String.fromCharCode(o.getUint8(u+f));return h},me.prototype.parseTag=function(){return this.parseString(4)},me.prototype.parseLongDateTime=function(){let i=yt(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},me.prototype.parseVersion=function(i){let o=Ke(this.data,this.offset+this.relativeOffset),u=Ke(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),o+u/i/10},me.prototype.skip=function(i,o){o===void 0&&(o=1),this.relativeOffset+=pn[i]*o},me.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 f=0;f<i;f++)o[f]=u.getUint32(h),h+=4;return this.relativeOffset+=i*4,o},me.prototype.parseOffset16List=me.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 f=0;f<i;f++)o[f]=u.getUint16(h),h+=2;return this.relativeOffset+=i*2,o},me.prototype.parseShortList=function(i){let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getInt16(h),h+=2;return this.relativeOffset+=i*2,o},me.prototype.parseByteList=function(i){let o=new Array(i),u=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getUint8(h++);return this.relativeOffset+=i,o},me.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},me.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},me.prototype.parseRecordList=function(i,o){o||(o=i,i=this.parseUShort());let u=new Array(i),h=Object.keys(o);for(let f=0;f<i;f++){let g={};for(let A=0;A<h.length;A++){let _=h[A],I=o[_];g[_]=I.call(this)}u[f]=g}return u},me.prototype.parseRecordList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i),h=Object.keys(o);for(let f=0;f<i;f++){let g={};for(let A=0;A<h.length;A++){let _=h[A],I=o[_];g[_]=I.call(this)}u[f]=g}return u},me.prototype.parseTupleRecords=function(i,o){let u=[];for(let h=0;h<i;h++){let f=[];for(let g=0;g<o;g++)f.push(this.parseF2Dot14());u.push(f)}return u},me.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 f=o[h],g=i[f];u[f]=g.call(this)}return u}},me.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},me.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},me.prototype.parsePointer=function(i){let o=this.parseOffset16();if(o>0)return new me(this.data,this.offset+o).parseStruct(i)},me.prototype.parsePointer32=function(i){let o=this.parseOffset32();if(o>0)return new me(this.data,this.offset+o).parseStruct(i)},me.prototype.parseListOfLists=function(i){let o=this.parseOffset16List(),u=o.length,h=this.relativeOffset,f=new Array(u);for(let g=0;g<u;g++){let A=o[g];if(A===0){f[g]=void 0;continue}if(this.relativeOffset=A,i){let _=this.parseOffset16List(),I=new Array(_.length);for(let D=0;D<_.length;D++)this.relativeOffset=A+_[D],I[D]=i.call(this);f[g]=I}else f[g]=this.parseUShortList()}return this.relativeOffset=h,f},me.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 f=0;f<u;f++)h[f]={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.")},me.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:me.uShort,end:me.uShort,classId:me.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})},me.list=function(i,o){return function(){return this.parseList(i,o)}},me.list32=function(i,o){return function(){return this.parseList32(i,o)}},me.recordList=function(i,o){return function(){return this.parseRecordList(i,o)}},me.recordList32=function(i,o){return function(){return this.parseRecordList32(i,o)}},me.pointer=function(i){return function(){return this.parsePointer(i)}},me.pointer32=function(i){return function(){return this.parsePointer32(i)}},me.tag=me.prototype.parseTag,me.byte=me.prototype.parseByte,me.uShort=me.offset16=me.prototype.parseUShort,me.uShortList=me.prototype.parseUShortList,me.uInt24=me.prototype.parseUInt24,me.uLong=me.offset32=me.prototype.parseULong,me.uLongList=me.prototype.parseULongList,me.fixed=me.prototype.parseFixed,me.f2Dot14=me.prototype.parseF2Dot14,me.struct=me.prototype.parseStruct,me.coverage=me.prototype.parseCoverage,me.classDef=me.prototype.parseClassDef;var Gr={reserved:me.uShort,reqFeatureIndex:me.uShort,featureIndexes:me.uShortList};me.prototype.parseScriptList=function(){return this.parsePointer(me.recordList({tag:me.tag,script:me.pointer({defaultLangSys:me.pointer(Gr),langSysRecords:me.recordList({tag:me.tag,langSys:me.pointer(Gr)})})}))||[]},me.prototype.parseFeatureList=function(){return this.parsePointer(me.recordList({tag:me.tag,feature:me.pointer({featureParams:me.offset16,lookupListIndexes:me.uShortList})}))||[]},me.prototype.parseLookupList=function(i){return this.parsePointer(me.list(me.pointer(function(){let o=this.parseUShort();ue.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(me.pointer(i[o])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},me.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let i=this.parseUShort(),o=this.parseUShort();return ue.argument(i===1&&o<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:me.offset32,featureTableSubstitutionOffset:me.offset32})})||[]},me.prototype.parseVariationStore=function(){let i=this.relativeOffset,o=this.parseUShort(),u={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=i+o+2,u},me.prototype.parseItemVariationStore=function(){let i=this.relativeOffset,o={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},u=this.parseOffset32(),h=this.parseUShort(),f=this.parseULongList(h);this.relativeOffset=i+u,o.variationRegions=this.parseVariationRegionList();for(let g=0;g<h;g++){let A=f[g];this.relativeOffset=i+A,o.itemVariationSubtables.push(this.parseItemVariationSubtable())}return o},me.prototype.parseVariationRegionList=function(){let i=this.parseUShort(),o=this.parseUShort();return this.parseRecordList(o,{regionAxes:me.recordList(i,{startCoord:me.f2Dot14,peakCoord:me.f2Dot14,endCoord:me.f2Dot14})})},me.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):[]}},me.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 f=(o&dr.INNER_INDEX_BIT_COUNT_MASK)+1,g=((o&dr.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let A=0;A<h;A++){let _;if(g===1)_=this.parseByte();else if(g===2)_=this.parseUShort();else if(g===3)_=this.parseUInt24();else if(g===4)_=this.parseULong();else throw new Error(`Invalid entry size of ${g}`);let I=_>>f,D=_&(1<<f)-1;u.push({outerIndex:I,innerIndex:D})}return{format:i,entryFormat:o,map:u}},me.prototype.parseDeltaSets=function(i,o,u){let h=Array.from({length:i},()=>[]),f=o&dr.LONG_WORDS,g=o&dr.WORD_DELTA_COUNT_MASK;if(g>u)throw Error("wordCount must be less than or equal to regionIndexCount");let A=(f?this.parseLong:this.parseShort).bind(this),_=(f?this.parseShort:this.parseChar).bind(this);for(let I=0;I<i;I++)for(let D=0;D<u;D++)D<g?h[I].push(A()):h[I].push(_());return h},me.prototype.parseTupleVariationStoreList=function(i,o,u){let h=this.parseUShort(),f=this.parseUShort()&1,g=this.parseOffset32(),A=(f?this.parseULong:this.parseUShort).bind(this),_={},I=A();f||(I*=2);let D;for(let M=0;M<h;M++){D=A(),f||(D*=2);let te=D-I;_[M]=te?this.parseTupleVariationStore(g+I,i,o,u,M):void 0,I=D}return _},me.prototype.parseTupleVariationStore=function(i,o,u,h,f){let g=this.relativeOffset;this.relativeOffset=i,u==="cvar"&&(this.relativeOffset+=4);let A=this.parseUShort(),_=!!(A&dr.SHARED_POINT_NUMBERS),I=A&dr.COUNT_MASK,D=this.parseOffset16(),M=[],te=[];for(let he=0;he<I;he++){let Re=this.parseTupleVariationHeader(o,u);M.push(Re)}this.relativeOffset!==i+D&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${i+D}, actually ${this.relativeOffset}`),this.relativeOffset=i+D),_&&(te=this.parsePackedPointNumbers());let J=this.relativeOffset;for(let he=0;he<I;he++){let Re=M[he];Re.privatePoints=[],this.relativeOffset=J,u==="cvar"&&!Re.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),Re.flags.privatePointNumbers&&(Re.privatePoints=this.parsePackedPointNumbers()),delete Re.flags;let ct=this.offset,mr=this.relativeOffset,lr=Rr=>{let sn,On,Yn=()=>{let Zn=0;if(u==="gvar"){if(Zn=Re.privatePoints.length||te.length,!Zn){let Qs=h.get(f);Qs.path,Zn=Qs.points.length,Zn+=4}}else u==="cvar"&&(Zn=h.length);this.offset=ct,this.relativeOffset=mr,sn=this.parsePackedDeltas(Zn),u==="gvar"&&(On=this.parsePackedDeltas(Zn))};return{configurable:!0,get:function(){return sn===void 0&&Yn(),Rr==="deltasY"?On:sn},set:function(Zn){sn===void 0&&Yn(),Rr==="deltasY"?On=Zn:sn=Zn}}};Object.defineProperty(Re,"deltas",lr.call(this,"deltas")),u==="gvar"&&Object.defineProperty(Re,"deltasY",lr.call(this,"deltasY")),J+=Re.variationDataSize,delete Re.variationDataSize}this.relativeOffset=g;let Te={headers:M};return Te.sharedPoints=te,Te},me.prototype.parseTupleVariationHeader=function(i,o){let u=this.parseUShort(),h=this.parseUShort(),f=!!(h&dr.EMBEDDED_PEAK_TUPLE),g=!!(h&dr.INTERMEDIATE_REGION),A=!!(h&dr.PRIVATE_POINT_NUMBERS),_=f?void 0:h&dr.TUPLE_INDEX_MASK,I=f?this.parseTupleRecords(1,i)[0]:void 0,D=g?this.parseTupleRecords(1,i)[0]:void 0,M=g?this.parseTupleRecords(1,i)[0]:void 0,te={variationDataSize:u,peakTuple:I,intermediateStartTuple:D,intermediateEndTuple:M,flags:{embeddedPeakTuple:f,intermediateRegion:g,privatePointNumbers:A}};return o==="gvar"&&(te.sharedTupleRecordsIndex=_),te},me.prototype.parsePackedPointNumbers=function(){let i=this.parseByte(),o=[],u=i;if(i>=128){let f=this.parseByte();u=(i&dr.POINT_RUN_COUNT_MASK)<<8|f}let h=0;for(;o.length<u;){let f=this.parseByte(),g=!!(f&dr.POINTS_ARE_WORDS),A=(f&dr.POINT_RUN_COUNT_MASK)+1;for(let _=0;_<A&&o.length<u;_++){let I;g?I=this.parseUShort():I=this.parseByte(),h=h+I,o.push(h)}}return o},me.prototype.parsePackedDeltas=function(i){let o=[];for(;o.length<i;){let u=this.parseByte(),h=!!(u&dr.DELTAS_ARE_ZERO),f=!!(u&dr.DELTAS_ARE_WORDS),g=(u&dr.DELTA_RUN_COUNT_MASK)+1;for(let A=0;A<g&&o.length<i;A++)h?o.push(0):f?o.push(this.parseShort()):o.push(this.parseChar())}return o};var ot={getByte:nr,getCard8:nr,getUShort:Ke,getCard16:Ke,getShort:_t,getUInt24:$t,getULong:yt,getFixed:Rt,getTag:Ct,getOffset:fr,getBytes:Yt,bytesToString:Sr,Parser:me},pt=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],ir={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"},Mn={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},Xr={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 je(i,o,u){switch(i){case 0:if(o===65535)return"und";if(u)return u[o];break;case 1:return ir[o];case 3:return Xr[o]}}var st="utf-16",bt={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"},Br={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 Vr(i,o,u){switch(i){case 0:return st;case 1:return Br[u]||bt[o];case 3:if(o===1||o===10)return st;break}}var Cr={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function qr(i){return Cr[i]}function mn(i,o,u){let h={},f=new ot.Parser(i,o),g=f.parseUShort(),A=f.parseUShort(),_=f.offset+f.parseUShort();for(let I=0;I<A;I++){let D=f.parseUShort(),M=f.parseUShort(),te=f.parseUShort(),J=f.parseUShort(),Te=pt[J]||J,he=f.parseUShort(),Re=f.parseUShort(),ct=je(D,te,u),mr=Vr(D,M,te),lr=qr(D);if(mr!==void 0&&ct!==void 0&&lr!==void 0){let Rr;if(mr===st?Rr=Ce.UTF16(i,_+Re,he):Rr=Ce.MACSTRING(i,_+Re,he,mr),Rr){let sn=h[lr];sn===void 0&&(sn=h[lr]={});let On=sn[Te];On===void 0&&(On=sn[Te]={}),On[ct]=Rr}}}return g===1&&f.parseUShort(),h}function on(i){let o={};for(let u in i)o[i[u]]=parseInt(u);return o}function zr(i,o,u,h,f,g){return new De.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:f},{name:"offset",type:"USHORT",value:g}])}function un(i,o){let u=i.length,h=o.length-u+1;e:for(let f=0;f<h;f++)for(;f<h;f++){for(let g=0;g<u;g++)if(o[f+g]!==i[g])continue e;return f}return-1}function Er(i,o){let u=un(i,o);if(u<0){u=o.length;let h=0,f=i.length;for(;h<f;++h)o.push(i[h])}return u}function re(i,o){let u=on(Cr),h=on(ir),f=on(Xr),g=[],A=[];for(let I in i){let D,M=[],te={},J=on(pt),Te=u[I];for(let he in i[I]){let Re=J[he];if(Re===void 0&&(Re=he),D=parseInt(Re),isNaN(D))throw new Error('Name table entry "'+he+'" does not exist, see nameTableNames for complete list.');te[D]=i[I][he],M.push(D)}for(let he=0;he<M.length;he++){D=M[he];let Re=te[D];for(let ct in Re){let mr=Re[ct];if(Te===1||Te===0){let lr=h[ct],Rr=Mn[lr],sn=Vr(Te,Rr,lr),On=H.MACSTRING(mr,sn);if(Te===0&&(lr=o.indexOf(ct),lr<0&&(lr=o.length,o.push(ct)),Rr=4,On=H.UTF16(mr)),On!==void 0){let Yn=Er(On,A);g.push(zr(Te,Rr,lr,D,On.length,Yn))}}if(Te===3){let lr=f[ct];if(lr!==void 0){let Rr=H.UTF16(mr),sn=Er(Rr,A);g.push(zr(3,1,lr,D,Rr.length,sn))}}}}}g.sort(function(I,D){return I.platformID-D.platformID||I.encodingID-D.encodingID||I.languageID-D.languageID||I.nameID-D.nameID});let _=new De.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 I=0;I<g.length;I++)_.fields.push({name:"record_"+I,type:"RECORD",value:g[I]});return _.fields.push({name:"strings",type:"LITERAL",value:A}),_}function mt(i,o,u=[]){if(o<256&&o in pt){if(u.length&&!u.includes(parseInt(o)))return;o=pt[o]}for(let h in i)for(let f in i[h])if(f===o||parseInt(f)===o)return i[h][f]}var Mt={parse:mn,make:re,getNameByID:mt};function rr(i,o,u,h){i.length=o.parseUShort(),i.language=o.parseUShort()-1;let f=o.parseByteList(i.length),g=Object.assign({},f),A=Vr(u,h,i.language),_=Ye[A];for(let I=0;I<_.length;I++)g[_.charCodeAt(I)]=f[128+I];i.glyphIndexMap=g}function Ar(i,o,u){o.parseUShort(),i.length=o.parseULong(),i.language=o.parseULong();let h;i.groupCount=h=o.parseULong(),i.glyphIndexMap={};for(let f=0;f<h;f+=1){let g=o.parseULong(),A=o.parseULong(),_=o.parseULong();for(let I=g;I<=A;I+=1)i.glyphIndexMap[I]=_,u===12&&_++}}function Fr(i,o,u,h,f){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 ot.Parser(u,h+f+14),_=new ot.Parser(u,h+f+16+g*2),I=new ot.Parser(u,h+f+16+g*4),D=new ot.Parser(u,h+f+16+g*6),M=h+f+16+g*8;for(let te=0;te<g-1;te+=1){let J,Te=A.parseUShort(),he=_.parseUShort(),Re=I.parseShort(),ct=D.parseUShort();for(let mr=he;mr<=Te;mr+=1)ct!==0?(M=D.offset+D.relativeOffset-2,M+=ct,M+=(mr-he)*2,J=ot.getUShort(u,M),J!==0&&(J=J+Re&65535)):J=mr+Re&65535,i.glyphIndexMap[mr]=J}}function Xt(i,o){let u={};o.skip("uLong");let h=o.parseULong();for(let f=0;f<h;f+=1){let g=o.parseUInt24(),A={varSelector:g},_=o.parseOffset32(),I=o.parseOffset32(),D=o.relativeOffset;_&&(o.relativeOffset=_,A.defaultUVS=o.parseStruct({ranges:function(){return o.parseRecordList32({startUnicodeValue:o.parseUInt24,additionalCount:o.parseByte})}})),I&&(o.relativeOffset=I,A.nonDefaultUVS=o.parseStruct({uvsMappings:function(){let M={},te=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let J=0;J<te.length;J+=1)M[te[J].unicodeValue]=te[J];return M}})),u[g]=A,o.relativeOffset=D}i.varSelectorList=u}function Zr(i,o){let u={};u.version=ot.getUShort(i,o),ue.argument(u.version===0,"cmap table version should be 0."),u.numTables=ot.getUShort(i,o+2);let h=null,f=-1,g=-1,A=null,_=null,I=[0,1,2,3,4,6],D=[0,1,10];for(let te=u.numTables-1;te>=0;te-=1)if(A=ot.getUShort(i,o+4+te*8),_=ot.getUShort(i,o+4+te*8+2),A===3&&D.includes(_)||A===0&&I.includes(_)||A===1&&_===0){if(g>0)continue;if(g=ot.getULong(i,o+4+te*8+4),h)break}else if(A===0&&_===5){if(f=ot.getULong(i,o+4+te*8+4),h=new ot.Parser(i,o+f),h.parseUShort()!==14)f=-1,h=null;else if(g>0)break}if(g===-1)throw new Error("No valid cmap sub-tables found.");let M=new ot.Parser(i,o+g);if(u.format=M.parseUShort(),u.format===0)rr(u,M,A,_);else if(u.format===12||u.format===13)Ar(u,M,u.format);else if(u.format===4)Fr(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 "+_+").");return h&&Xt(u,h),u}function Jt(i,o,u){i.segments.push({end:o,start:o,delta:-(o-u),offset:0,glyphIndex:u})}function Pr(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function Hr(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],f=i[u];h.end+1===f.start&&h.delta===f.delta&&f.end!==65535?h.end=f.end:o.push(f)}return o}function ps(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 f=new De.Table("cmap",h);for(f.segments=[],u=0;u<i.length;u+=1){let Te=i.get(u);for(let he=0;he<Te.unicodes.length;he+=1)Jt(f,Te.unicodes[he],u)}f.segments.sort(function(Te,he){return Te.start-he.start}),f.segments=Hr(f.segments),Pr(f);let g=f.segments.length,A=0,_=[],I=[],D=[],M=[],te=[],J=[];for(u=0;u<g;u+=1){let Te=f.segments[u];Te.end<=65535&&Te.start<=65535?(_.push({name:"end_"+u,type:"USHORT",value:Te.end}),I.push({name:"start_"+u,type:"USHORT",value:Te.start}),D.push({name:"idDelta_"+u,type:"SHORT",value:Te.delta}),M.push({name:"idRangeOffset_"+u,type:"USHORT",value:Te.offset}),Te.glyphId!==void 0&&te.push({name:"glyph_"+u,type:"USHORT",value:Te.glyphId})):A+=1,!o&&Te.glyphIndex!==void 0&&(J.push({name:"cmap12Start_"+u,type:"ULONG",value:Te.start}),J.push({name:"cmap12End_"+u,type:"ULONG",value:Te.end}),J.push({name:"cmap12Glyph_"+u,type:"ULONG",value:Te.glyphIndex}))}f.segCountX2=(g-A)*2,f.searchRange=Math.pow(2,Math.floor(Math.log(g-A)/Math.log(2)))*2,f.entrySelector=Math.log(f.searchRange/2)/Math.log(2),f.rangeShift=f.segCountX2-f.searchRange;for(let Te=0;Te<_.length;Te++)f.fields.push(_[Te]);f.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let Te=0;Te<I.length;Te++)f.fields.push(I[Te]);for(let Te=0;Te<D.length;Te++)f.fields.push(D[Te]);for(let Te=0;Te<M.length;Te++)f.fields.push(M[Te]);for(let Te=0;Te<te.length;Te++)f.fields.push(te[Te]);if(f.cmap4Length=14+_.length*2+2+I.length*2+D.length*2+M.length*2+te.length*2,!o){let Te=16+J.length*4;f.cmap12Offset=20+f.cmap4Length,f.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:Te},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:J.length/3});for(let he=0;he<J.length;he++)f.fields.push(J[he])}return f}var Mr={parse:Zr,make:ps},jn=[".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"],Tr=[".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"],ln=[".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"],Qr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],ks=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Dr=[".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 en(i){this.font=i}en.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 f=u.get(h);for(let g=0;g<f.unicodes.length;g+=1)if(f.unicodes[g]===o)return h}return null};function xn(i){this.cmap=i}xn.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function X(i,o){this.encoding=i,this.charset=o}X.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.encoding[o];return this.charset.indexOf(u)};function He(i){switch(i.version){case 1:this.names=Dr.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)i.glyphNameIndex[o]<Dr.length?this.names[o]=Dr[i.glyphNameIndex[o]]:this.names[o]=i.names[i.glyphNameIndex[o]-Dr.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)this.names[o]=Dr[o+i.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}He.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},He.prototype.glyphIndexToName=function(i){return this.names[i]};function Nt(i){let o,u=i.tables.cmap.glyphIndexMap,h=Object.keys(u);for(let f=0;f<h.length;f+=1){let g=h[f],A=u[g];o=i.glyphs.get(A),o.addUnicode(parseInt(g))}for(let f=0;f<i.glyphs.length;f+=1)o=i.glyphs.get(f),i.cffEncoding?o.name=i.cffEncoding.charset[f]:i.glyphNames.names&&(o.name=i.glyphNames.glyphIndexToName(f))}function Et(i){i._IndexToUnicodeMap={};let o=i.tables.cmap.glyphIndexMap,u=Object.keys(o);for(let h=0;h<u.length;h+=1){let f=u[h],g=o[f];i._IndexToUnicodeMap[g]===void 0?i._IndexToUnicodeMap[g]={unicodes:[parseInt(f)]}:i._IndexToUnicodeMap[g].unicodes.push(parseInt(f))}}function tr(i,o){o.lowMemory?Et(i):Nt(i)}function jr(i,o,u,h,f){i.beginPath(),i.moveTo(o,u),i.lineTo(h,f),i.stroke()}var cr={line:jr};function Cn(i,o){let u=new me(i,o),h=u.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let f=u.parseShort(),g=u.parseShort(),A=u.parseShort(),_=u.parseOffset32(),I=u.parseUShortList(g);u.relativeOffset=_;let D=u.parseULongList(A);return u.relativeOffset=_,{version:h,numPaletteEntries:f,colorRecords:D,colorRecordIndices:I}}function Ls({version:i=0,numPaletteEntries:o=0,colorRecords:u=[],colorRecordIndices:h=[0]}){return ue.argument(i===0,"Only CPALv0 are supported."),ue.argument(u.length,"No colorRecords given."),ue.argument(h.length,"No colorRecordIndices given."),h.length>1&&ue.argument(o,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new De.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((f,g)=>({name:"colorRecordIndices_"+g,type:"USHORT",value:f})),...u.map((f,g)=>({name:"colorRecords_"+g,type:"ULONG",value:f}))])}function Xn(i){var o=(i&4278190080)>>24,u=(i&16711680)>>16,h=(i&65280)>>8,f=i&255;return o=o+256&255,u=u+256&255,h=h+256&255,f=(f+256&255)/255,{b:o,g:u,r:h,a:f}}function cn(i,o,u=0,h="hexa"){if(o==65535)return"currentColor";let f=i&&i.tables&&i.tables.cpal;if(!f)return"currentColor";if(u>f.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${f.colorRecordIndices.length}, index: ${o})`);if(o>f.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${f.numPaletteEntries}, index: ${o})`);let g=f.colorRecordIndices[u]+o;if(g>f.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${f.colorRecords.length}, lookupIndex: ${g})`);let A=Xn(f.colorRecords[g]);return h==="bgra"?A:gn(A,h)}function dn(i){return("0"+parseInt(i).toString(16)).slice(-2)}function _r(i){let o=i.r/255,u=i.g/255,h=i.b/255,f=Math.max(o,u,h),g=Math.min(o,u,h),A,_,I=(f+g)/2;if(f===g)A=_=0;else{let D=f-g;switch(_=I>.5?D/(2-f-g):D/(f+g),f){case o:A=(u-h)/D+(u<h?6:0);break;case u:A=(h-o)/D+2;break;case h:A=(o-u)/D+4;break}A/=6}return{h:A*360,s:_*100,l:I*100}}function Or(i){let{h:o,s:u,l:h,a:f}=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)),_=h-g/2,I=0,D=0,M=0;return 0<=o&&o<60?(I=g,D=A,M=0):60<=o&&o<120?(I=A,D=g,M=0):120<=o&&o<180?(I=0,D=g,M=A):180<=o&&o<240?(I=0,D=A,M=g):240<=o&&o<300?(I=A,D=0,M=g):300<=o&&o<=360&&(I=g,D=0,M=A),{r:Math.round((I+_)*255),g:Math.round((D+_)*255),b:Math.round((M+_)*255),a:f}}function Gn(i){return parseInt(`0x${dn(i.b)}${dn(i.g)}${dn(i.r)}${dn(i.a*255)}`,16)}function Vn(i,o="hexa"){let u=o=="raw"||o=="cpal",h=Number.isInteger(i),f=!0;if(h&&u||i==="currentColor")return i;if(typeof i=="object"){if(o=="bgra")return i;if(u)return Gn(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=gn(g.fillStyle,"hexa");A==="#000000ff"&&i.toLowerCase()!=="black"?f=!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(_=>typeof _<"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 _=i.match(A).filter(I=>typeof I<"u");i=Or({h:parseFloat(_[1])*(_[2]==="turn"?360:1),s:parseFloat(_[3]),l:parseFloat(_[4]),a:_[5]?parseFloat(_[5])/(_[6]?100:1):1})}else f=!1}}if(!f)throw new Error(`Invalid color format: ${i}`);return gn(i,o)}function gn(i,o="hexa"){if(i==="currentColor")return i;if(Number.isInteger(i)){if(o=="raw"||o=="cpal")return i;i=Xn(i)}else typeof i!="object"&&(i=Vn(i,"bgra"));let u=["hsl","hsla"].includes(o)?_r(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`#${dn(i.r)}${dn(i.g)}${dn(i.b)}`;case"hexa":case"hex8":case"hex-8":return`#${dn(i.r)}${dn(i.g)}${dn(i.b)}${dn(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 Gn(i);default:throw new Error("Unknown color format: "+o)}}var Jn={parse:Cn,make:Ls,getPaletteColor:cn,parseColor:Vn,formatColor:gn};function kr(i,o){let u=o||new We;return{configurable:!0,get:function(){return typeof u=="function"&&(u=u()),u},set:function(h){u=h}}}function Lr(i){this.bindConstructorValues(i)}Lr.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",kr(this,i.path))},Lr.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},Lr.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Lr.prototype.getPath=function(i,o,u,h,f){i=i!==void 0?i:0,o=o!==void 0?o:0,u=u!==void 0?u:72,h=Object.assign({},f&&f.defaultRenderOptions,h);let g,A,_=h.xScale,I=h.yScale,D=1/(this.path.unitsPerEm||1e3)*u,M=this;f&&f.variation&&(M=f.variation.getTransform(this,h.variation),g=M.path.commands),h.hinting&&f&&f.hinting&&(A=M.path&&f.hinting.exec(M,u,h)),A?(g=f.hinting.getCommands(A),i=Math.round(i),o=Math.round(o),_=I=1):(g=M.path.commands,_===void 0&&(_=D),I===void 0&&(I=D));let te=new We;if(h.drawSVG){let J=this.getSvgImage(f);if(J){let Te=new We;return Te._image={image:J.image,x:i+J.leftSideBearing*D,y:o-J.baseline*D,width:J.image.width*D,height:J.image.height*D},te._layers=[Te],te}}if(h.drawLayers){let J=this.getLayers(f);if(J&&J.length){te._layers=[];for(let Te=0;Te<J.length;Te+=1){let he=J[Te],Re=cn(f,he.paletteIndex,h.usePalette);Re==="currentColor"?Re=h.fill||"black":Re=gn(Re,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:Re}),te._layers.push(this.getPath.call(he.glyph,i,o,u,h,f))}return te}}te.fill=h.fill||this.path.fill,te.stroke=this.path.stroke,te.strokeWidth=this.path.strokeWidth*D;for(let J=0;J<g.length;J+=1){let Te=g[J];Te.type==="M"?te.moveTo(i+Te.x*_,o+-Te.y*I):Te.type==="L"?te.lineTo(i+Te.x*_,o+-Te.y*I):Te.type==="Q"?te.quadraticCurveTo(i+Te.x1*_,o+-Te.y1*I,i+Te.x*_,o+-Te.y*I):Te.type==="C"?te.curveTo(i+Te.x1*_,o+-Te.y1*I,i+Te.x2*_,o+-Te.y2*I,i+Te.x*_,o+-Te.y*I):Te.type==="Z"&&te.stroke&&te.strokeWidth&&te.closePath()}return te},Lr.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)},Lr.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)},Lr.prototype.getContours=function(i=null){if(this.points===void 0&&!i)return[];let o=[],u=[],h=i||this.points;for(let f=0;f<h.length;f+=1){let g=h[f];u.push(g),g.lastPointOfContour&&(o.push(u),u=[])}return ue.argument(u.length===0,"There are still points left in the current contour."),o},Lr.prototype.getMetrics=function(){let i=this.path.commands,o=[],u=[];for(let f=0;f<i.length;f+=1){let g=i[f];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},Lr.prototype.draw=function(i,o,u,h,f,g){f=Object.assign({},g&&g.defaultRenderOptions,f),this.getPath(o,u,h,f,g).draw(i)},Lr.prototype.drawPoints=function(i,o,u,h,f,g){if(f=Object.assign({},g&&g.defaultRenderOptions,f),f.drawLayers){let te=this.getLayers(g);if(te&&te.length){for(let J=0;J<te.length;J+=1)te[J].glyph.index!==this.index&&this.drawPoints.call(te[J].glyph,i,o,u,h);return}}function A(te,J,Te,he){i.beginPath();for(let Re=0;Re<te.length;Re+=1)i.moveTo(J+te[Re].x*he,Te+te[Re].y*he),i.arc(J+te[Re].x*he,Te+te[Re].y*he,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 _=1/this.path.unitsPerEm*h,I=[],D=[],M=this.path.commands;g&&g.variation&&(M=g.variation.getTransform(this,f.variation).path.commands);for(let te=0;te<M.length;te+=1){let J=M[te];J.x!==void 0&&I.push({x:J.x,y:-J.y}),J.x1!==void 0&&D.push({x:J.x1,y:-J.y1}),J.x2!==void 0&&D.push({x:J.x2,y:-J.y2})}i.fillStyle="blue",A(I,o,u,_),i.fillStyle="red",A(D,o,u,_)},Lr.prototype.drawMetrics=function(i,o,u,h){let f;o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:24,f=1/this.path.unitsPerEm*h,i.lineWidth=1,i.strokeStyle="black",cr.line(i,o,-1e4,o,1e4),cr.line(i,-1e4,u,1e4,u);let g=this.xMin||0,A=this.yMin||0,_=this.xMax||0,I=this.yMax||0,D=this.advanceWidth||0;i.strokeStyle="blue",cr.line(i,o+g*f,-1e4,o+g*f,1e4),cr.line(i,o+_*f,-1e4,o+_*f,1e4),cr.line(i,-1e4,u+-A*f,1e4,u+-A*f),cr.line(i,-1e4,u+-I*f,1e4,u+-I*f),i.strokeStyle="green",cr.line(i,o+D*f,-1e4,o+D*f,1e4)},Lr.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)},Lr.prototype.fromSVG=function(i,o={}){return this.path.fromSVG(i,o)},Lr.prototype.toSVG=function(i,o){let u=this.toPathData.apply(this,[i,o]);return this.path.toSVG(i,u)},Lr.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 pr=Lr;function ns(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 Un(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&&(Un.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)}}),Un.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]},Un.prototype.push=function(i,o){this.glyphs[i]=o,this.length++};function En(i,o){return new pr({index:o,font:i})}function kn(i,o,u,h,f,g){return function(){let A=new pr({index:o,font:i});return A.path=function(){u(A,h,f);let _=g(i.glyphs,A);return _.unitsPerEm=i.unitsPerEm,_},ns(A,"numberOfContours","_numberOfContours"),ns(A,"xMin","_xMin"),ns(A,"xMax","_xMax"),ns(A,"yMin","_yMin"),ns(A,"yMax","_yMax"),ns(A,"points","_points"),A}}function ss(i,o,u,h,f){return function(){let g=new pr({index:o,font:i});return g.path=function(){let A=u(i,g,h,f);return A.unitsPerEm=i.unitsPerEm,A},g}}var Wr={GlyphSet:Un,glyphLoader:En,ttfGlyphLoader:kn,cffGlyphLoader:ss};function tn(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(!tn(i[u],o[u]))return!1;return!0}else return!1}var G=10;function Me(i){let o;return i.length<1240?o=107:i.length<33900?o=1131:o=32768,o}function $e(i,o,u,h){let f=[],g=[],A=h>1?ot.getULong(i,o):ot.getCard16(i,o),_=h>1?4:2,I,D;if(A!==0){let M=ot.getByte(i,o+_);I=o+(A+1)*M+_;let te=o+_+1;for(let J=0;J<A+1;J+=1)f.push(ot.getOffset(i,te,M)),te+=M;D=I+f[A]}else D=o+_;for(let M=0;M<f.length-1;M+=1){let te=ot.getBytes(i,I+f[M],I+f[M+1]);u&&(te=u(te,i,o,h)),g.push(te)}return{objects:g,startOffset:o,endOffset:D}}function Je(i,o,u){let h=[],f=u>1?ot.getULong(i,o):ot.getCard16(i,o),g=u>1?4:2,A,_;if(f!==0){let I=ot.getByte(i,o+g);A=o+(f+1)*I+g;let D=o+g+1;for(let M=0;M<f+1;M+=1)h.push(ot.getOffset(i,D,I)),D+=I;_=A+h[f]}else _=o+g;return{offsets:h,startOffset:o,endOffset:_}}function it(i,o,u,h,f,g){let A=g>1?ot.getULong(u,h):ot.getCard16(u,h),_=g>1?4:2,I=0;if(A!==0){let M=ot.getByte(u,h+_);I=h+(A+1)*M+_}let D=ot.getBytes(u,I+o[i],I+o[i+1]);return f&&(D=f(D)),D}function Tt(i){let o="",u=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let h=i.parseByte(),f=h>>4,g=h&15;if(f===15||(o+=u[f],g===15))break;o+=u[g]}return parseFloat(o)}function kt(i,o){let u,h,f,g;if(o===28)return u=i.parseByte(),h=i.parseByte(),u<<8|h;if(o===29)return u=i.parseByte(),h=i.parseByte(),f=i.parseByte(),g=i.parseByte(),u<<24|h<<16|f<<8|g;if(o===30)return Tt(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 Dt(i){let o={};for(let u=0;u<i.length;u+=1){let h=i[u][0],f=i[u][1],g;if(f.length===1?g=f[0]:g=f,Object.prototype.hasOwnProperty.call(o,h)&&!isNaN(o[h]))throw new Error("Object "+o+" already has key "+h);o[h]=g}return o}function ft(i,o,u,h){o=o!==void 0?o:0;let f=new ot.Parser(i,o),g=[],A=[];u=u!==void 0?u:i.byteLength;let _=h<2?22:28;for(;f.relativeOffset<u;){let I=f.parseByte();if(I<_){if(I===12&&(I=1200+f.parseByte()),h>1&&I===23){Dn(A);continue}g.push([I,A]),A=[]}else A.push(kt(f,I,h))}return Dt(g)}function Bt(i,o){return o<=390?o=jn[o]:i?o=i[o-391]:o=void 0,o}function W(i,o,u){let h={},f;for(let g=0;g<o.length;g+=1){let A=o[g];if(Array.isArray(A.type)){let _=[];_.length=A.type.length;for(let I=0;I<A.type.length;I++)f=i[A.op]!==void 0?i[A.op][I]:void 0,f===void 0&&(f=A.value!==void 0&&A.value[I]!==void 0?A.value[I]:null),A.type[I]==="SID"&&(f=Bt(u,f)),_[I]=f;h[A.name]=_}else f=i[A.op],f===void 0&&(f=A.value!==void 0?A.value:null),A.type==="SID"&&(f=Bt(u,f)),h[A.name]=f}return h}function N(i,o){let u={};if(u.formatMajor=ot.getCard8(i,o),u.formatMinor=ot.getCard8(i,o+1),u.formatMajor>2)throw new Error(`Unsupported CFF table version ${u.formatMajor}.${u.formatMinor}`);return u.size=ot.getCard8(i,o+2),u.formatMajor<2?(u.offsetSize=ot.getCard8(i,o+3),u.startOffset=o,u.endOffset=o+4):(u.topDictLength=ot.getCard16(i,o+3),u.endOffset=o+8),u}var U=[{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"}],K=[{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"}],fe=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Qe=[{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"}],ve=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function lt(i,o,u,h){let f=ft(i,o,i.byteLength,h);return W(f,h>1?K:U,u)}function vt(i,o,u,h,f){let g=ft(i,o,u,f);return W(g,f>1?Qe:fe,h)}function br(i,o,u){let h=ft(i,o,void 0,u);return W(h,ve)}function Lt(i,o,u){let h=[];for(let f=0;f<u.length;f++){let g=new DataView(new Uint8Array(u[f]).buffer),A=br(g,0,2),_=A.private[0],I=A.private[1];if(_!==0&&I!==0){let D=vt(i,I+o,_,[],2);if(D.subrs){let M=I+D.subrs,te=$e(i,M+o,void 0,2);A._subrs=te.objects,A._subrsBias=Me(A._subrs)}A._privateDict=D}h.push(A)}return h}function rn(i,o,u,h,f){let g=[];for(let A=0;A<u.length;A+=1){let _=new DataView(new Uint8Array(u[A]).buffer),I=lt(_,0,h,f);I._subrs=[],I._subrsBias=0,I._defaultWidthX=0,I._nominalWidthX=0;let D=f<2?I.private[0]:0,M=f<2?I.private[1]:0;if(D!==0&&M!==0){let te=vt(i,M+o,D,h,f);if(I._defaultWidthX=te.defaultWidthX,I._nominalWidthX=te.nominalWidthX,te.subrs!==0){let J=M+te.subrs,Te=$e(i,J+o,void 0,f);I._subrs=Te.objects,I._subrsBias=Me(I._subrs)}I._privateDict=te}g.push(I)}return g}function yn(i,o,u,h,f){let g,A,_=new ot.Parser(i,o);u-=1;let I=[".notdef"],D=_.parseCard8();if(D===0)for(let M=0;M<u;M+=1)g=_.parseSID(),f?I.push(g):I.push(Bt(h,g)||g);else if(D===1)for(;I.length<=u;){g=_.parseSID(),A=_.parseCard8();for(let M=0;M<=A;M+=1)f?I.push("cid"+("00000"+g).slice(-5)):I.push(Bt(h,g)||g),g+=1}else if(D===2)for(;I.length<=u;){g=_.parseSID(),A=_.parseCard16();for(let M=0;M<=A;M+=1)f?I.push("cid"+("00000"+g).slice(-5)):I.push(Bt(h,g)||g),g+=1}else throw new Error("Unknown charset format "+D);return I}function hn(i,o){let u,h={},f=new ot.Parser(i,o),g=f.parseCard8();if(g===0){let A=f.parseCard8();for(let _=0;_<A;_+=1)u=f.parseCard8(),h[u]=_}else if(g===1){let A=f.parseCard8();u=1;for(let _=0;_<A;_+=1){let I=f.parseCard8(),D=f.parseCard8();for(let M=I;M<=I+D;M+=1)h[M]=u,u+=1}}else throw new Error("Unknown encoding format "+g);return h}function Dn(i){let o=i.pop();for(;i.length>o;)i.pop()}function zn(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 hr(i,o,u,h,f){let g,A,_,I,D=new We,M=[],te=0,J=!1,Te=!1,he=0,Re=0,ct,mr,lr,Rr,sn=0,On=[],Yn,Zn=0,Qs=i.tables.cff2||i.tables.cff;if(lr=Qs.topDict._defaultWidthX,Rr=Qs.topDict._nominalWidthX,f=f||i.variation&&i.variation.get(),o.getBlendPath||(o.getBlendPath=function(sr){return hr(i,o,u,h,sr)}),i.isCIDFont||h>1){let sr=Qs.topDict._fdSelect?Qs.topDict._fdSelect[o.index]:0,ar=Qs.topDict._fdArray[sr];ct=ar._subrs,mr=ar._subrsBias,h>1?(On=Qs.topDict._vstore.itemVariationStore,sn=ar._privateDict.vsindex):(lr=ar._defaultWidthX,Rr=ar._nominalWidthX)}else ct=Qs.topDict._subrs,mr=Qs.topDict._subrsBias;let Ro=zn(i,D),an=lr;function Pa(sr,ar){Te&&Ro!==2&&D.closePath(),D.moveTo(sr,ar),Te=!0}function ea(){let sr;sr=(M.length&1)!==0,sr&&!J&&(an=M.shift()+Rr),te+=M.length>>1,M.length=0,J=!0}function gr(sr){let ar,Pi,Kl,K0,wc,Mo,ta,no,Oi,Oa,ra,na,Ns=0;for(;Ns<sr.length;){let io=sr[Ns];switch(Ns+=1,io){case 1:ea();break;case 3:ea();break;case 4:M.length>1&&!J&&(an=M.shift()+Rr,J=!0),Re+=M.pop(),Pa(he,Re);break;case 5:for(;M.length>0;)he+=M.shift(),Re+=M.shift(),D.lineTo(he,Re);break;case 6:for(;M.length>0&&(he+=M.shift(),D.lineTo(he,Re),M.length!==0);)Re+=M.shift(),D.lineTo(he,Re);break;case 7:for(;M.length>0&&(Re+=M.shift(),D.lineTo(he,Re),M.length!==0);)he+=M.shift(),D.lineTo(he,Re);break;case 8:for(;M.length>0;)g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I+M.shift(),D.curveTo(g,A,_,I,he,Re);break;case 10:if(wc=M.pop()+mr,Mo=ct[wc],Mo){if(Zn>=G){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Zn++,gr(Mo),Zn--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(io=sr[Ns],Ns+=1,io){case 35:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),ta=_+M.shift(),no=I+M.shift(),Oi=ta+M.shift(),Oa=no+M.shift(),ra=Oi+M.shift(),na=Oa+M.shift(),he=ra+M.shift(),Re=na+M.shift(),M.shift(),D.curveTo(g,A,_,I,ta,no),D.curveTo(Oi,Oa,ra,na,he,Re);break;case 34:g=he+M.shift(),A=Re,_=g+M.shift(),I=A+M.shift(),ta=_+M.shift(),no=I,Oi=ta+M.shift(),Oa=I,ra=Oi+M.shift(),na=Re,he=ra+M.shift(),D.curveTo(g,A,_,I,ta,no),D.curveTo(Oi,Oa,ra,na,he,Re);break;case 36:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),ta=_+M.shift(),no=I,Oi=ta+M.shift(),Oa=I,ra=Oi+M.shift(),na=Oa+M.shift(),he=ra+M.shift(),D.curveTo(g,A,_,I,ta,no),D.curveTo(Oi,Oa,ra,na,he,Re);break;case 37:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),ta=_+M.shift(),no=I+M.shift(),Oi=ta+M.shift(),Oa=no+M.shift(),ra=Oi+M.shift(),na=Oa+M.shift(),Math.abs(ra-he)>Math.abs(na-Re)?he=ra+M.shift():Re=na+M.shift(),D.curveTo(g,A,_,I,ta,no),D.curveTo(Oi,Oa,ra,na,he,Re);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+io),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 Ac=Qr[M.pop()],cu=Qr[M.pop()],X0=M.pop(),J0=M.pop();if(Ac&&cu){o.isComposite=!0,o.components=[];let Jg=i.cffEncoding.charset.indexOf(Ac),ex=i.cffEncoding.charset.indexOf(cu);o.components.push({glyphIndex:ex,dx:0,dy:0}),o.components.push({glyphIndex:Jg,dx:J0,dy:X0}),D.extend(i.glyphs.get(ex).path);let Kw=i.glyphs.get(Jg),yp=JSON.parse(JSON.stringify(Kw.path.commands));for(let vp=0;vp<yp.length;vp+=1){let qo=yp[vp];qo.type!=="Z"&&(qo.x+=J0,qo.y+=X0),(qo.type==="Q"||qo.type==="C")&&(qo.x1+=J0,qo.y1+=X0),qo.type==="C"&&(qo.x2+=J0,qo.y2+=X0)}D.extend(yp)}}else M.length>0&&!J&&(an=M.shift()+Rr,J=!0);Te&&Ro!==2&&(D.closePath(),Te=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}sn=M.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Yn||(Yn=i.variation&&f&&i.variation.process.getBlendVector(On,sn,f));var ts=M.pop(),va=Yn?Yn.length:On.itemVariationSubtables[sn].regionIndexes.length,so=ts*va,jo=M.length-so,bl=jo-ts;if(Yn)for(let Ac=0;Ac<ts;Ac++){var Xg=M[bl+Ac];for(let cu=0;cu<va;cu++)Xg+=Yn[cu]*M[jo++];M[bl+Ac]=Xg}for(;so--;)M.pop();break;case 18:ea();break;case 19:case 20:ea(),Ns+=te+7>>3;break;case 21:M.length>2&&!J&&(an=M.shift()+Rr,J=!0),Re+=M.pop(),he+=M.pop(),Pa(he,Re);break;case 22:M.length>1&&!J&&(an=M.shift()+Rr,J=!0),he+=M.pop(),Pa(he,Re);break;case 23:ea();break;case 24:for(;M.length>2;)g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I+M.shift(),D.curveTo(g,A,_,I,he,Re);he+=M.shift(),Re+=M.shift(),D.lineTo(he,Re);break;case 25:for(;M.length>6;)he+=M.shift(),Re+=M.shift(),D.lineTo(he,Re);g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I+M.shift(),D.curveTo(g,A,_,I,he,Re);break;case 26:for(M.length&1&&(he+=M.shift());M.length>0;)g=he,A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_,Re=I+M.shift(),D.curveTo(g,A,_,I,he,Re);break;case 27:for(M.length&1&&(Re+=M.shift());M.length>0;)g=he+M.shift(),A=Re,_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I,D.curveTo(g,A,_,I,he,Re);break;case 28:ar=sr[Ns],Pi=sr[Ns+1],M.push((ar<<24|Pi<<16)>>16),Ns+=2;break;case 29:if(wc=M.pop()+i.gsubrsBias,Mo=i.gsubrs[wc],Mo){if(Zn>=G){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Zn++,gr(Mo),Zn--}break;case 30:for(;M.length>0&&(g=he,A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I+(M.length===1?M.shift():0),D.curveTo(g,A,_,I,he,Re),M.length!==0);)g=he+M.shift(),A=Re,_=g+M.shift(),I=A+M.shift(),Re=I+M.shift(),he=_+(M.length===1?M.shift():0),D.curveTo(g,A,_,I,he,Re);break;case 31:for(;M.length>0&&(g=he+M.shift(),A=Re,_=g+M.shift(),I=A+M.shift(),Re=I+M.shift(),he=_+(M.length===1?M.shift():0),D.curveTo(g,A,_,I,he,Re),M.length!==0);)g=he,A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),he=_+M.shift(),Re=I+(M.length===1?M.shift():0),D.curveTo(g,A,_,I,he,Re);break;default:io<32?console.log("Glyph "+o.index+": unknown operator "+io):io<247?M.push(io-139):io<251?(ar=sr[Ns],Ns+=1,M.push((io-247)*256+ar+108)):io<255?(ar=sr[Ns],Ns+=1,M.push(-(io-251)*256-ar-108)):(ar=sr[Ns],Pi=sr[Ns+1],Kl=sr[Ns+2],K0=sr[Ns+3],Ns+=4,M.push((ar<<24|Pi<<16|Kl<<8|K0)/65536))}}}return gr(u),i.variation&&f&&(D.commands=D.commands.map(sr=>{let ar=Object.keys(sr);for(let Pi=0;Pi<ar.length;Pi++){let Kl=ar[Pi];Kl!=="type"&&(sr[Kl]=Math.round(sr[Kl]))}return sr})),J&&(o.advanceWidth=an),D}function jt(i,o,u,h,f){let g=[],A,_=new ot.Parser(i,o),I=_.parseCard8();if(I===0)for(let D=0;D<u;D++){if(A=_.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(I===3||f>1&&I===4){let D=I===4?_.parseULong():_.parseCard16(),M=I===4?_.parseULong():_.parseCard16();if(M!==0)throw new Error(`CFF Table CID Font FDSelect format ${I} range has bad initial GID ${M}`);let te;for(let J=0;J<D;J++){if(A=I===4?_.parseUShort():_.parseCard8(),te=I===4?_.parseULong():_.parseCard16(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");if(te>u)throw new Error(`CFF Table CID Font FDSelect format ${f} range has bad GID ${te}`);for(;M<te;M++)g.push(A);M=te}if(te!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+te)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+I);return g}function Bn(i,o,u,h){let f,g=N(i,o);g.formatMajor===2?f=u.tables.cff2={}:f=u.tables.cff={};let A=g.formatMajor>1?null:$e(i,g.endOffset,ot.bytesToString),_=g.formatMajor>1?null:$e(i,A.endOffset),I=g.formatMajor>1?null:$e(i,_.endOffset,ot.bytesToString),D=$e(i,g.formatMajor>1?o+g.size+g.topDictLength:I.endOffset,void 0,g.formatMajor);u.gsubrs=D.objects,u.gsubrsBias=Me(u.gsubrs);let M;if(g.formatMajor>1){let J=o+g.size,Te=ot.getBytes(i,J,J+g.topDictLength);M=rn(i,0,[Te],void 0,g.formatMajor)[0]}else{let J=rn(i,o,_.objects,I.objects,g.formatMajor);if(J.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+J.length);M=J[0]}if(f.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 J=M.fdArray,Te=M.fdSelect;if(!J)throw new Error("This is a CFF2 font, but FDArray information is missing");let he=$e(i,o+J,null,g.formatMajor),Re=Lt(i,o,he.objects);M._fdArray=Re,Te&&(M._fdSelect=jt(i,o+Te,u.numGlyphs,Re.length,g.formatMajor))}else if(u.isCIDFont){let J=M.fdArray,Te=M.fdSelect;if(J===0||Te===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");J+=o;let he=$e(i,J),Re=rn(i,o,he.objects,I.objects,g.formatMajor);M._fdArray=Re,Te+=o,M._fdSelect=jt(i,Te,u.numGlyphs,Re.length,g.formatMajor)}if(g.formatMajor<2){let J=o+M.private[1],Te=vt(i,J,M.private[0],I.objects,g.formatMajor);if(u.defaultWidthX=Te.defaultWidthX,u.nominalWidthX=Te.nominalWidthX,Te.subrs!==0){let he=J+Te.subrs,Re=$e(i,he);u.subrs=Re.objects,u.subrsBias=Me(u.subrs)}else u.subrs=[],u.subrsBias=0}let te;if(h.lowMemory?(te=Je(i,o+M.charStrings,g.formatMajor),u.nGlyphs=te.offsets.length-(g.formatMajor>1?1:0)):(te=$e(i,o+M.charStrings,null,g.formatMajor),u.nGlyphs=te.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 J=[],Te=[];M.charset===0?J=Tr:M.charset===1?J=Jr:M.charset===2?J=ln:J=yn(i,o+M.charset,u.nGlyphs,I.objects,u.isCIDFont),M.encoding===0?Te=Qr:M.encoding===1?Te=ks:Te=hn(i,o+M.encoding),u.cffEncoding=new X(Te,J),u.encoding=u.encoding||u.cffEncoding}if(u.glyphs=new Wr.GlyphSet(u),h.lowMemory)u._push=function(J){let Te=it(J,te.offsets,i,o+M.charStrings,void 0,g.formatMajor);u.glyphs.push(J,Wr.cffGlyphLoader(u,J,hr,Te,g.formatMajor))};else for(let J=0;J<u.nGlyphs;J+=1){let Te=te.objects[J];u.glyphs.push(J,Wr.cffGlyphLoader(u,J,hr,Te,g.formatMajor))}if(M.vstore){let J=new ot.Parser(i,o+M.vstore);M._vstore=J.parseVariationStore()}}function qn(i,o){let u,h=jn.indexOf(i);return h>=0&&(u=h),h=o.indexOf(i),h>=0?u=h+jn.length:(u=jn.length+o.length,o.push(i)),u}function Wa(){return new De.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 Qn(i){let o=new De.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 is(i,o,u){let h={};for(let f=0;f<i.length;f+=1){let g=i[f],A=o[g.name];A!==void 0&&!tn(A,g.value)&&(g.type==="SID"&&(A=qn(A,u)),h[g.op]={name:g.name,type:g.type,value:A})}return h}function zi(i,o,u){let h=new De.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=is(u>1?K:U,i,o),h}function da(i){let o=new De.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return o.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],o}function bs(i){let o=new De.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 Ga(){return new De.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function So(i,o){let u=new De.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<i.length;h+=1){let f=i[h],g=qn(f,o);u.fields.push({name:"glyph_"+h,type:"SID",value:g})}return u}function Hn(i,o){let u=[],h=i.path;o<2&&u.push({name:"width",type:"NUMBER",value:i.advanceWidth});let f=0,g=0;for(let A=0;A<h.commands.length;A+=1){let _,I,D=h.commands[A];if(D.type==="Q"){let M=.3333333333333333,te=2/3;D={type:"C",x:D.x,y:D.y,x1:Math.round(M*f+te*D.x1),y1:Math.round(M*g+te*D.y1),x2:Math.round(M*D.x+te*D.x1),y2:Math.round(M*D.y+te*D.y1)}}if(D.type==="M")_=Math.round(D.x-f),I=Math.round(D.y-g),u.push({name:"dx",type:"NUMBER",value:_}),u.push({name:"dy",type:"NUMBER",value:I}),u.push({name:"rmoveto",type:"OP",value:21}),f=Math.round(D.x),g=Math.round(D.y);else if(D.type==="L")_=Math.round(D.x-f),I=Math.round(D.y-g),u.push({name:"dx",type:"NUMBER",value:_}),u.push({name:"dy",type:"NUMBER",value:I}),u.push({name:"rlineto",type:"OP",value:5}),f=Math.round(D.x),g=Math.round(D.y);else if(D.type==="C"){let M=Math.round(D.x1-f),te=Math.round(D.y1-g),J=Math.round(D.x2-D.x1),Te=Math.round(D.y2-D.y1);_=Math.round(D.x-D.x2),I=Math.round(D.y-D.y2),u.push({name:"dx1",type:"NUMBER",value:M}),u.push({name:"dy1",type:"NUMBER",value:te}),u.push({name:"dx2",type:"NUMBER",value:J}),u.push({name:"dy2",type:"NUMBER",value:Te}),u.push({name:"dx",type:"NUMBER",value:_}),u.push({name:"dy",type:"NUMBER",value:I}),u.push({name:"rrcurveto",type:"OP",value:8}),f=Math.round(D.x),g=Math.round(D.y)}}return o<2&&u.push({name:"endchar",type:"OP",value:14}),u}function ha(i,o){let u=new De.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<i.length;h+=1){let f=i.get(h),g=Hn(f,o);u.charStrings.push({name:f.name,type:"CHARSTRING",value:g})}return u}function ms(i,o,u){let h=new De.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=is(u>1?Qe:fe,i,o),h}function Ia(i,o){let u=new De.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,f={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&&(f.paintType=g.paintType,f.strokeWidth=g.strokeWidth||0);let A={},_=[],I;for(let J=1;J<i.length;J+=1)I=i.get(J),_.push(I.name);let D=[];u.header=Wa(),u.nameIndex=Qn([o.postScriptName]);let M=zi(f,D);u.topDictIndex=da(M),u.globalSubrIndex=Ga(),u.charsets=So(_,D),u.charStringsIndex=ha(i,1),u.privateDict=ms(A,D),u.stringIndex=bs(D);let te=u.header.sizeOf()+u.nameIndex.sizeOf()+u.topDictIndex.sizeOf()+u.stringIndex.sizeOf()+u.globalSubrIndex.sizeOf();return f.charset=te,f.encoding=0,f.charStrings=f.charset+u.charsets.sizeOf(),f.private[1]=f.charStrings+u.charStringsIndex.sizeOf(),M=zi(f,D),u.topDictIndex=da(M),u}var as={parse:Bn,make:Ia};function Va(i,o){let u={},h=new ot.Parser(i,o);return u.version=h.parseVersion(),u.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,u.checkSumAdjustment=h.parseULong(),u.magicNumber=h.parseULong(),ue.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 Js(i){let o=Math.round(new Date().getTime()/1e3)+2082844800,u=o,h=i.macStyle||0;return i.createdTimestamp&&(u=i.createdTimestamp+2082844800),new De.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 ei={parse:Va,make:Js};function Hs(i,o){let u={},h=new ot.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 qa(i){return new De.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 Is={parse:Hs,make:qa};function fa(i,o,u,h,f){let g,A,_=new ot.Parser(i,o);for(let I=0;I<h;I+=1){I<u&&(g=_.parseUShort(),A=_.parseShort());let D=f.get(I);D.advanceWidth=g,D.leftSideBearing=A}}function dl(i,o,u,h,f){i._hmtxTableData={};let g,A,_=new ot.Parser(o,u);for(let I=0;I<f;I+=1)I<h&&(g=_.parseUShort(),A=_.parseShort()),i._hmtxTableData[I]={advanceWidth:g,leftSideBearing:A}}function Ya(i,o,u,h,f,g,A){A.lowMemory?dl(i,o,u,h,f):fa(o,u,h,f,g)}function os(i){let o=new De.Table("hmtx",[]);for(let u=0;u<i.length;u+=1){let h=i.get(u),f=h.advanceWidth||0,g=h.leftSideBearing||0;o.fields.push({name:"advanceWidth_"+u,type:"USHORT",value:f}),o.fields.push({name:"leftSideBearing_"+u,type:"SHORT",value:g})}return o}var Ms={parse:Ya,make:os};function Hi(i){let o=new De.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 f=0;f<i.length;++f){let g=u.indexOf(i[f]);g<0&&(g=u.length,u+=i[f]),o.fields.push({name:"offset "+f,type:"USHORT",value:h+g}),o.fields.push({name:"length "+f,type:"USHORT",value:i[f].length})}return o.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),o}function xi(i,o){let u=new ot.Parser(i,o),h=u.parseULong();ue.argument(h===1,"Unsupported ltag table version."),u.skip("uLong",1);let f=u.parseULong(),g=[];for(let A=0;A<f;A++){let _="",I=o+u.parseUShort(),D=u.parseUShort();for(let M=I;M<I+D;++M)_+=String.fromCharCode(i.getInt8(M));g.push(_)}return g}var bi={make:Hi,parse:xi};function hl(i,o){let u={},h=new ot.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 ti(i){return new De.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}var Uo={parse:hl,make:ti},pa=[{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 fl(i){for(let o=0;o<pa.length;o+=1){let u=pa[o];if(i>=u.begin&&i<u.end)return o}return-1}function pl(i,o){let u={},h=new ot.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 f=0;f<10;f++)u.panose[f]=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 ls(i){return new De.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 js={parse:pl,make:ls,unicodeRanges:pa,getUnicodeRange:fl};function Ri(i,o){let u={},h=new ot.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=Dr.slice();break;case 2:u.numberOfGlyphs=h.parseUShort(),u.glyphNameIndex=new Array(u.numberOfGlyphs);for(let f=0;f<u.numberOfGlyphs;f++)u.glyphNameIndex[f]=h.parseUShort();u.names=[];for(let f=0;f<u.numberOfGlyphs;f++)if(u.glyphNameIndex[f]>=Dr.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 f=0;f<u.numberOfGlyphs;f++)u.offset[f]=h.parseChar();break}return u}function zo(i){let{italicAngle:o=Math.round((i.italicAngle||0)*65536),underlinePosition:u=0,underlineThickness:h=0,isFixedPitch:f=0,minMemType42:g=0,maxMemType42:A=0,minMemType1:_=0,maxMemType1:I=0}=i.tables.post||{};return new De.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:f},{name:"minMemType42",type:"ULONG",value:g},{name:"maxMemType42",type:"ULONG",value:A},{name:"minMemType1",type:"ULONG",value:_},{name:"maxMemType1",type:"ULONG",value:I}])}var Dl={parse:Ri,make:zo},Es=new Array(9);Es[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(me.coverage),deltaGlyphId:this.parseShort()};if(o===2)return{substFormat:2,coverage:this.parsePointer(me.coverage),substitute:this.parseOffset16List()};ue.assert(!1,"0x"+i.toString(16)+": lookup type 1 format must be 1 or 2.")},Es[2]=function(){let i=this.parseUShort();return ue.argument(i===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(me.coverage),sequences:this.parseListOfLists()}},Es[3]=function(){let i=this.parseUShort();return ue.argument(i===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(me.coverage),alternateSets:this.parseListOfLists()}},Es[4]=function(){let i=this.parseUShort();return ue.argument(i===1,"GSUB ligature table identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(me.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ea={sequenceIndex:me.uShort,lookupListIndex:me.uShort};Es[5]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:o,coverage:this.parsePointer(me.coverage),ruleSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{input:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,Ea)}})};if(o===2)return{substFormat:o,coverage:this.parsePointer(me.coverage),classDef:this.parsePointer(me.classDef),classSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{classes:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,Ea)}})};if(o===3){let u=this.parseUShort(),h=this.parseUShort();return{substFormat:o,coverages:this.parseList(u,me.pointer(me.coverage)),lookupRecords:this.parseRecordList(h,Ea)}}ue.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Es[6]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(me.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ea)}})};if(o===2)return{substFormat:2,coverage:this.parsePointer(me.coverage),backtrackClassDef:this.parsePointer(me.classDef),inputClassDef:this.parsePointer(me.classDef),lookaheadClassDef:this.parsePointer(me.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ea)}})};if(o===3)return{substFormat:3,backtrackCoverage:this.parseList(me.pointer(me.coverage)),inputCoverage:this.parseList(me.pointer(me.coverage)),lookaheadCoverage:this.parseList(me.pointer(me.coverage)),lookupRecords:this.parseRecordList(Ea)};ue.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Es[7]=function(){let i=this.parseUShort();ue.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let o=this.parseUShort(),u=new me(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:o,extension:Es[o].call(u)}},Es[8]=function(){let i=this.parseUShort();return ue.argument(i===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(me.coverage),backtrackCoverage:this.parseList(me.pointer(me.coverage)),lookaheadCoverage:this.parseList(me.pointer(me.coverage)),substitutes:this.parseUShortList()}};function ml(i,o){o=o||0;let u=new me(i,o),h=u.parseVersion(1);return ue.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(Es)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(Es),variations:u.parseFeatureVariationsList()}}var es=new Array(9);es[1]=function(i){if(i.substFormat===1)return new De.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new De.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.ushortList("substitute",i.substitute)));ue.fail("Lookup type 1 substFormat must be 1 or 2.")},es[2]=function(i){return ue.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new De.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.tableList("seqSet",i.sequences,function(o){return new De.Table("sequenceSetTable",De.ushortList("sequence",o))})))},es[3]=function(i){return ue.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new De.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.tableList("altSet",i.alternateSets,function(o){return new De.Table("alternateSetTable",De.ushortList("alternate",o))})))},es[4]=function(i){return ue.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new De.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.tableList("ligSet",i.ligatureSets,function(o){return new De.Table("ligatureSetTable",De.tableList("ligature",o,function(u){return new De.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:u.ligGlyph}].concat(De.ushortList("component",u.components,u.components.length+1)))}))})))},es[5]=function(i){if(i.substFormat===1)return new De.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.tableList("sequenceRuleSet",i.ruleSets,function(o){return o?new De.Table("sequenceRuleSetTable",De.tableList("sequenceRule",o,function(u){let h=De.ushortList("seqLookup",[],u.lookupRecords.length).concat(De.ushortList("inputSequence",u.input,u.input.length+1));[h[0],h[1]]=[h[1],h[0]];for(let f=0;f<u.lookupRecords.length;f++){let g=u.lookupRecords[f];h=h.concat({name:"sequenceIndex"+f,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:g.lookupListIndex})}return new De.Table("sequenceRuleTable",h)})):new De.Table("NULL",null)})));if(i.substFormat===2)return new De.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new De.ClassDef(i.classDef)}].concat(De.tableList("classSeqRuleSet",i.classSets,function(o){return o?new De.Table("classSeqRuleSetTable",De.tableList("classSeqRule",o,function(u){let h=De.ushortList("classes",u.classes,u.classes.length+1).concat(De.ushortList("seqLookupCount",[],u.lookupRecords.length));for(let f=0;f<u.lookupRecords.length;f++){let g=u.lookupRecords[f];h=h.concat({name:"sequenceIndex"+f,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:g.lookupListIndex})}return new De.Table("classSeqRuleTable",h)})):new De.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 De.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 De.Table("contextualSubstitutionTable",o)}ue.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},es[6]=function(i){if(i.substFormat===1)return new De.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new De.Coverage(i.coverage)}].concat(De.tableList("chainRuleSet",i.chainRuleSets,function(o){return new De.Table("chainRuleSetTable",De.tableList("chainRule",o,function(u){let h=De.ushortList("backtrackGlyph",u.backtrack,u.backtrack.length).concat(De.ushortList("inputGlyph",u.input,u.input.length+1)).concat(De.ushortList("lookaheadGlyph",u.lookahead,u.lookahead.length)).concat(De.ushortList("substitution",[],u.lookupRecords.length));for(let f=0;f<u.lookupRecords.length;f++){let g=u.lookupRecords[f];h=h.concat({name:"sequenceIndex"+f,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:g.lookupListIndex})}return new De.Table("chainRuleTable",h)}))})));if(i.substFormat===2)ue.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 De.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 De.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 De.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 De.Table("chainContextTable",o)}ue.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Wi(i){return new De.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new De.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new De.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new De.LookupList(i.lookups,es)}])}var Mi={parse:ml,make:Wi};function Gi(i,o){let u=new ot.Parser(i,o),h=u.parseULong();ue.argument(h===1,"Unsupported META table version."),u.parseULong(),u.parseULong();let f=u.parseULong(),g={};for(let A=0;A<f;A++){let _=u.parseTag(),I=u.parseULong(),D=u.parseULong();if(_==="appl"||_==="bild")continue;let M=Ce.UTF8(i,o+I,D);g[_]=M}return g}function gs(i){let o=Object.keys(i).length,u="",h=16+o*12,f=new De.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],f.fields.push({name:"tag "+g,type:"TAG",value:g}),f.fields.push({name:"offset "+g,type:"ULONG",value:h+A}),f.fields.push({name:"length "+g,type:"ULONG",value:i[g].length})}return f.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),f}var Ws={parse:Gi,make:gs};function Bl(i,o){let u=new me(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 f=u.parseUShort(),g=u.parseOffset32(),A=u.parseOffset32(),_=u.parseUShort();u.relativeOffset=g;let I=u.parseRecordList(f,{glyphID:me.uShort,firstLayerIndex:me.uShort,numLayers:me.uShort});u.relativeOffset=A;let D=u.parseRecordList(_,{glyphID:me.uShort,paletteIndex:me.uShort});return{version:h,baseGlyphRecords:I,layerRecords:D}}function Vi({version:i=0,baseGlyphRecords:o=[],layerRecords:u=[]}){ue.argument(i===0,"Only COLRv0 supported.");let h=14,f=h+o.length*6;return new De.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:f},{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 qi={parse:Bl,make:Vi};function fn(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 ma(i,o,u){let h={},f=new ot.Parser(i,o);h.tag=f.parseTag(),h.minValue=f.parseFixed(),h.defaultValue=f.parseFixed(),h.maxValue=f.parseFixed(),f.skip("uShort",1);let g=f.parseUShort();return h.axisNameID=g,h.name=mt(u,g),h}function Yi(i,o,u,h={}){let f=[{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;f.push({name:"axis_"+i+" "+A,type:"FIXED",value:o.coordinates[A]<<16})}return h&&h.postScriptNameID&&f.push({name:"postScriptNameID_",type:"USHORT",value:o.postScriptNameID!==void 0?o.postScriptNameID:65535}),f}function Na(i,o,u,h,f){let g={},A=new ot.Parser(i,o),_=A.parseUShort();g.subfamilyNameID=_,g.name=mt(h,_,[2,17]),A.skip("uShort",1),g.coordinates={};for(let D=0;D<u.length;++D)g.coordinates[u[D].tag]=A.parseFixed();if(A.relativeOffset===f)return g.postScriptNameID=void 0,g.postScriptName=void 0,g;let I=A.parseUShort();return g.postScriptNameID=I==65535?void 0:I,g.postScriptName=g.postScriptNameID!==void 0?mt(h,I,[6]):"",g}function ji(i,o){let u=new De.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 f=0;f<i.axes.length;f++)u.fields=u.fields.concat(fn(f,i.axes[f],o));let h={};for(let f=0;f<i.instances.length;f++)if(i.instances[f].postScriptNameID!==void 0){u.instanceSize+=2,h.postScriptNameID=!0;break}for(let f=0;f<i.instances.length;f++)u.fields=u.fields.concat(Yi(f,i.instances[f],i.axes,h));return u}function Di(i,o,u){let h=new ot.Parser(i,o),f=h.parseULong();ue.argument(f===65536,"Unsupported fvar table version.");let g=h.parseOffset16();h.skip("uShort",1);let A=h.parseUShort(),_=h.parseUShort(),I=h.parseUShort(),D=h.parseUShort(),M=[];for(let Te=0;Te<A;Te++)M.push(ma(i,o+g+Te*_,u));let te=[],J=o+g+A*_;for(let Te=0;Te<I;Te++)te.push(Na(i,J+Te*D,M,u,D));return{axes:M,instances:te}}var ri={make:ji,parse:Di},ws={tag:me.tag,nameID:me.uShort,ordering:me.uShort},Gs=new Array(5);Gs[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},Gs[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},Gs[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},Gs[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 Bi(){let i=this.parseUShort(),o=Gs[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 Ra(i,o,u){o||(o=0);let h=new ot.Parser(i,o),f=h.parseUShort(),g=h.parseUShort();f!==1&&console.warn(`Unsupported STAT table version ${f}.${g}`);let A=[f,g],_=h.parseUShort(),I=h.parseUShort(),D=h.parseOffset32(),M=h.parseUShort(),te=h.parseOffset32(),J=f>1||g>0?h.parseUShort():void 0;u!==void 0&&ue.argument(I>=u.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),M>0&&ue.argument(I>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let Te=[];for(let ct=0;ct<I;ct++)h.offset=o+D,h.relativeOffset=ct*_,Te.push(h.parseStruct(ws));h.offset=o,h.relativeOffset=te;let he=h.parseUShortList(M),Re=[];for(let ct=0;ct<M;ct++)h.offset=o+te,h.relativeOffset=he[ct],Re.push(Bi.apply(h));return{version:A,axes:Te,values:Re,elidedFallbackNameID:J}}var ni=new Array(5);ni[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}]},ni[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}]},ni[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}]},ni[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 ys(i,o){return new De.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 Za(i,o){let u=o.format,h=ni[u];ue.argument(h!==void 0,`Unknown axis value table format ${u}`);let f=h(i,o);return new De.Table("axisValueTable_"+i,f)}function Ka(i){let o=new De.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=ys(g,i.axes[g]);o.offsetToAxisValueOffsets+=A.sizeOf(),o.fields=o.fields.concat(A.fields)}let u=[],h=[],f=i.values.length*2;for(let g=0;g<i.values.length;g++){let A=Za(g,i.values[g]);u.push({name:"offset_"+g,type:"USHORT",value:f}),f+=A.sizeOf(),h=h.concat(A.fields)}return o.fields=o.fields.concat(u),o.fields=o.fields.concat(h),o}var As={make:Ka,parse:Ra};function Xa(i,o){return new De.Record("axisValueMap_"+i,[{name:"fromCoordinate_"+i,type:"F2DOT14",value:o.fromCoordinate},{name:"toCoordinate_"+i,type:"F2DOT14",value:o.toCoordinate}])}function Ql(i,o){let u=new De.Record("segmentMap_"+i,[{name:"positionMapCount_"+i,type:"USHORT",value:o.axisValueMaps.length}]),h=[];for(let f=0;f<o.axisValueMaps.length;f++){let g=Xa(`${i}_${f}`,o.axisValueMaps[f]);h=h.concat(g.fields)}return u.fields=u.fields.concat(h),u}function Ho(i,o){ue.argument(i.axisSegmentMaps.length===o.axes.length,"avar axis count must correspond to fvar axis count");let u=new De.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 f=Ql(h,i.axisSegmentMaps[h]);u.fields=u.fields.concat(f.fields)}return u}function Co(i,o,u){o||(o=0);let h=new me(i,o),f=h.parseUShort(),g=h.parseUShort();f!==1&&console.warn(`Unsupported avar table version ${f}.${g}`),h.skip("uShort",1);let A=h.parseUShort();ue.argument(A===u.axes.length,"avar axis count must correspond to fvar axis count");let _=[];for(let I=0;I<A;I++){let D=[],M=h.parseUShort();for(let te=0;te<M;te++){let J=h.parseF2Dot14(),Te=h.parseF2Dot14();D.push({fromCoordinate:J,toCoordinate:Te})}_.push({axisValueMaps:D})}return{version:[f,g],axisSegmentMaps:_}}var ga={make:Ho,parse:Co};function Ma(i,o,u,h){let f=new ot.Parser(i,o),g=f.parseTupleVariationStore(f.relativeOffset,u.axes.length,"cvar",h),A=f.parseUShort(),_=f.parseUShort();return A!==1&&console.warn(`Unsupported cvar table version ${A}.${_}`),{version:[A,_],...g}}function Wo(){console.warn("Writing of cvar tables is not yet supported.")}var xa={make:Wo,parse:Ma};function cs(i,o,u,h){let f=new ot.Parser(i,o),g=f.parseUShort(),A=f.parseUShort();g!==1&&console.warn(`Unsupported gvar table version ${g}.${A}`);let _=f.parseUShort();_!==u.axes.length&&console.warn(`axisCount ${_} in gvar table does not match the number of axes ${u.axes.length} in the fvar table!`);let I=f.parseUShort(),D=f.parsePointer32(function(){return this.parseTupleRecords(I,_)}),M=f.parseTupleVariationStoreList(_,"gvar",h);return{version:[g,A],sharedTuples:D,glyphVariations:M}}function Go(){console.warn("Writing of gvar tables is not yet supported.")}var Zi={make:Go,parse:cs};function gl(i,o){let u={},h=new ot.Parser(i,o);u.version=h.parseUShort(),ue.argument(u.version<=1,"Unsupported gasp table version."),u.numRanges=h.parseUShort(),u.gaspRanges=[];for(let f=0;f<u.numRanges;f++)u.gaspRanges[f]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return u}function se(i){let o=new De.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 T={parse:gl,make:se};function j(i,o){let u=new Map,h=i.buffer,f=new me(i,o);if(f.parseUShort()!==0)return u;f.relativeOffset=f.parseOffset32();let g=i.byteOffset+o+f.relativeOffset,A=f.parseUShort(),_=new Map;for(let I=0;I<A;I++){let D=f.parseUShort(),M=f.parseUShort(),te=g+f.parseOffset32(),J=f.parseULong(),Te=_.get(te);Te===void 0&&(Te=new Uint8Array(h,te,J),_.set(te,Te));for(let he=D;he<=M;he++)u.set(he,Te)}return u}function Q(i){let o=Array.from(i.keys()).sort(),u=[],h=[],f=new Map,g=0,A={endGlyphID:null};for(let J=0,Te=o.length;J<Te;J++){let he=o[J],Re=i.get(he),ct=f.get(Re);ct===void 0&&(ct=g,h.push(Re),f.set(Re,ct),g+=Re.byteLength),he-1===A.endGlyphID&&ct===A.svgDocOffset?A.endGlyphID=he:(A={startGlyphID:he,endGlyphID:he,svgDocOffset:ct,svgDocLength:Re.byteLength},u.push(A))}let _=u.length,I=h.length,D=2+_*12,M=new Array(4+_*4+I),te=0;M[te++]={name:"version",type:"USHORT",value:0},M[te++]={name:"svgDocumentListOffset",type:"ULONG",value:10},M[te++]={name:"reserved",type:"ULONG",value:0},M[te++]={name:"numEntries",type:"USHORT",value:_};for(let J=0;J<_;J++){let Te="documentRecord_"+J,{startGlyphID:he,endGlyphID:Re,svgDocOffset:ct,svgDocLength:mr}=u[J];M[te++]={name:Te+"_startGlyphID",type:"USHORT",value:he},M[te++]={name:Te+"_endGlyphID",type:"USHORT",value:Re},M[te++]={name:Te+"_svgDocOffset",type:"ULONG",value:D+ct},M[te++]={name:Te+"_svgDocLength",type:"ULONG",value:mr}}for(let J=0;J<I;J++)M[te++]={name:"svgDoc_"+J,type:"LITERAL",value:h[J]};return new De.Table("SVG ",M)}var F={make:Q,parse:j};function ge(i){return Math.log(i)/Math.log(2)|0}function Se(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 Oe(i,o,u,h){return new De.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 Xe(i){let o=new De.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,ge(o.numTables));o.searchRange=16*u,o.entrySelector=ge(u),o.rangeShift=o.numTables*16-o.searchRange;let h=[],f=[],g=o.sizeOf()+Oe().sizeOf()*o.numTables;for(;g%4!==0;)g+=1,f.push({name:"padding",type:"BYTE",value:0});for(let A=0;A<i.length;A+=1){let _=i[A];ue.argument(_.tableName.length===4,"Table name"+_.tableName+" is invalid.");let I=_.sizeOf(),D=Oe(_.tableName,Se(_.encode()),g,I);for(h.push({name:D.tag+" Table Record",type:"RECORD",value:D}),f.push({name:_.tableName+" table",type:"RECORD",value:_}),g+=I,ue.argument(!isNaN(g),"Something went wrong calculating the offset.");g%4!==0;)g+=1,f.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(A,_){return A.value.tag>_.value.tag?1:-1}),o.fields=o.fields.concat(h),o.fields=o.fields.concat(f),o}function dt(i,o,u){for(let h=0;h<o.length;h+=1){let f=i.charToGlyphIndex(o[h]);if(f>0)return i.glyphs.get(f).getMetrics()}return u}function er(i){let o=0;for(let u=0;u<i.length;u+=1)o+=i[u];return o/i.length}function or(i){let o=[],u=[],h=[],f=[],g=[],A=[],_=[],I,D=0,M=0,te=0,J=0,Te=0;for(let ts=0;ts<i.glyphs.length;ts+=1){let va=i.glyphs.get(ts),so=va.unicode|0;if(isNaN(va.advanceWidth))throw new Error("Glyph "+va.name+" ("+ts+"): advanceWidth is not a number.");(I>so||I===void 0)&&so>0&&(I=so),D<so&&(D=so);let jo=js.getUnicodeRange(so);if(jo<32)M|=1<<jo;else if(jo<64)te|=1<<jo-32;else if(jo<96)J|=1<<jo-64;else if(jo<123)Te|=1<<jo-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(va.name===".notdef")continue;let bl=va.getMetrics();o.push(bl.xMin),u.push(bl.yMin),h.push(bl.xMax),f.push(bl.yMax),A.push(bl.leftSideBearing),_.push(bl.rightSideBearing),g.push(va.advanceWidth)}let he={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,f),advanceWidthMax:Math.max.apply(null,g),advanceWidthAvg:er(g),minLeftSideBearing:Math.min.apply(null,A),maxLeftSideBearing:Math.max.apply(null,A),minRightSideBearing:Math.min.apply(null,_)};he.ascender=i.ascender,he.descender=i.descender;let Re=0;i.weightClass>=600&&(Re|=i.macStyleValues.BOLD),i.italicAngle<0&&(Re|=i.macStyleValues.ITALIC);let ct=ei.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:he.xMin,yMin:he.yMin,xMax:he.xMax,yMax:he.yMax,lowestRecPPEM:3,macStyle:Re,createdTimestamp:i.createdTimestamp}),mr=Is.make({ascender:he.ascender,descender:he.descender,advanceWidthMax:he.advanceWidthMax,minLeftSideBearing:he.minLeftSideBearing,minRightSideBearing:he.minRightSideBearing,xMaxExtent:he.maxLeftSideBearing+(he.xMax-he.xMin),numberOfHMetrics:i.glyphs.length}),lr=Uo.make(i.glyphs.length),Rr=js.make(Object.assign({xAvgCharWidth:Math.round(he.advanceWidthAvg),usFirstCharIndex:I,usLastCharIndex:D,ulUnicodeRange1:M,ulUnicodeRange2:te,ulUnicodeRange3:J,ulUnicodeRange4:Te,sTypoAscender:he.ascender,sTypoDescender:he.descender,sTypoLineGap:0,usWinAscent:he.yMax,usWinDescent:Math.abs(he.yMin),ulCodePageRange1:1,sxHeight:dt(i,"xyvw",{yMax:Math.round(he.ascender/2)}).yMax,sCapHeight:dt(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",he).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0},i.tables.os2)),sn=Ms.make(i.glyphs),On=Mr.make(i.glyphs),Yn=i.getEnglishName("fontFamily"),Zn=i.getEnglishName("fontSubfamily"),Qs=Yn+" "+Zn,Ro=i.getEnglishName("postScriptName");Ro||(Ro=Yn.replace(/\s/g,"")+"-"+Zn);let an={};for(let ts in i.names)an[ts]=i.names[ts];an.unicode=an.unicode||{},an.macintosh=an.macintosh||{},an.windows=an.windows||{};let Pa=i.names.unicode||{},ea=i.names.macintosh||{},gr=i.names.windows||{};for(let ts in an){if(an[ts]=an[ts]||{},!an[ts].uniqueID){let va=i.getEnglishName("manufacturer")||"";an[ts].uniqueID={en:`${va}: ${Qs}`}}an[ts].postScriptName||(an[ts].postScriptName={en:Ro})}an.unicode.preferredFamily||(an.unicode.preferredFamily=Pa.fontFamily||ea.fontFamily||gr.fontFamily),an.macintosh.preferredFamily||(an.macintosh.preferredFamily=ea.fontFamily||Pa.fontFamily||gr.fontFamily),an.windows.preferredFamily||(an.windows.preferredFamily=gr.fontFamily||Pa.fontFamily||ea.fontFamily),an.unicode.preferredSubfamily||(an.unicode.preferredSubfamily=Pa.fontSubfamily||ea.fontSubfamily||gr.fontSubfamily),an.macintosh.preferredSubfamily||(an.macintosh.preferredSubfamily=ea.fontSubfamily||Pa.fontSubfamily||gr.fontSubfamily),an.windows.preferredSubfamily||(an.windows.preferredSubfamily=gr.fontSubfamily||Pa.fontSubfamily||ea.fontSubfamily);let sr=[],ar=Mt.make(an,sr),Pi=sr.length>0?bi.make(sr):void 0,Kl=Dl.make(i),K0=as.make(i.glyphs,{version:i.getEnglishName("version"),fullName:Qs,familyName:Yn,weightName:Zn,postScriptName:Ro,unitsPerEm:i.unitsPerEm,fontBBox:[0,he.yMin,he.ascender,he.advanceWidthMax],topDict:i.tables.cff&&i.tables.cff.topDict||{}}),wc=i.metas&&Object.keys(i.metas).length>0?Ws.make(i.metas):void 0,Mo=[ct,mr,lr,Rr,ar,On,Kl,K0,sn];Pi&&Mo.push(Pi);let ta={gsub:Mi,cpal:Jn,colr:qi,stat:As,avar:ga,cvar:xa,fvar:ri,gvar:Zi,gasp:T,svg:F},no={avar:[i.tables.fvar],fvar:[i.names]};for(let ts in ta){let va=i.tables[ts];if(va){let so=ta[ts].make.call(i,va,...no[ts]||[]);so&&Mo.push(so)}}wc&&Mo.push(wc);let Oi=Xe(Mo),Oa=Oi.encode(),ra=Se(Oa),na=Oi.fields,Ns=!1;for(let ts=0;ts<na.length;ts+=1)if(na[ts].name==="head table"){na[ts].value.checkSumAdjustment=2981146554-ra,Ns=!0;break}if(!Ns)throw new Error("Could not find head table with checkSum to adjust.");return Oi}var $r={make:Xe,fontToTable:or,computeCheckSum:Se};function nn(i,o){let u=0,h=i.length-1;for(;u<=h;){let f=u+h>>>1,g=i[f].tag;if(g===o)return f;g<o?u=f+1:h=f-1}return-u-1}function Pn(i,o){let u=0,h=i.length-1;for(;u<=h;){let f=u+h>>>1,g=i[f];if(g===o)return f;g<o?u=f+1:h=f-1}return-u-1}function yr(i,o){let u,h=0,f=i.length-1;for(;h<=f;){let g=h+f>>>1;u=i[g];let A=u.start;if(A===o)return u;A<o?h=g+1:f=g-1}if(h>0)return u=i[h-1],o>u.end?0:u}function wn(i,o){this.font=i,this.tableName=o}wn.prototype={searchTag:nn,binSearch:Pn,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,f=nn(u.scripts,i);if(f>=0)return h[f].script;if(o){let g={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-f,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 f=nn(h.langSysRecords,o);if(f>=0)return h.langSysRecords[f].langSys;if(u){let g={tag:o,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-f,0,g),g.langSys}}},getFeatureTable:function(i,o,u,h){let f=this.getLangSysTable(i,o,h);if(f){let g,A=f.featureIndexes,_=this.font.tables[this.tableName].features;for(let I=0;I<A.length;I++)if(g=_[A[I]],g.tag===u)return g.feature;if(h){let I=_.length;return ue.assert(I===0||u>=_[I-1].tag,"Features must be added in alphabetical order."),g={tag:u,feature:{params:0,lookupListIndexes:[]}},_.push(g),A.push(I),g.feature}}},getLookupTables:function(i,o,u,h,f){let g=this.getFeatureTable(i,o,u,f),A=[];if(g){let _,I=g.lookupListIndexes,D=this.font.tables[this.tableName].lookups;for(let M=0;M<I.length;M++)_=D[I[M]],_.lookupType===h&&A.push(_);if(A.length===0&&f){_={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let M=D.length;return D.push(_),I.push(M),[_]}}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=yr(i.ranges,o);return u?u.classId:0}}},getCoverageIndex:function(i,o){switch(i.format){case 1:{let u=Pn(i.glyphs,o);return u>=0?u:-1}case 2:{let u=yr(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 f=u[h],g=f.start,A=f.end;for(let _=g;_<=A;_++)o.push(_)}return o}}};var us=wn;function Ds(i){us.call(this,i,"gpos")}Ds.prototype=us.prototype,Ds.prototype.init=function(){let i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},Ds.prototype.getKerningValue=function(i,o,u){for(let h=0;h<i.length;h++){let f=i[h].subtables;for(let g=0;g<f.length;g++){let A=f[g],_=this.getCoverageIndex(A.coverage,o);if(!(_<0))switch(A.posFormat){case 1:{let I=A.pairSets[_];for(let D=0;D<I.length;D++){let M=I[D];if(M.secondGlyph===u)return M.value1&&M.value1.xAdvance||0}break}case 2:{let I=this.getGlyphClass(A.classDef1,o),D=this.getGlyphClass(A.classDef2,u),M=A.classRecords[I][D];return M.value1&&M.value1.xAdvance||0}}}}return 0},Ds.prototype.getKerningTables=function(i,o){if(this.font.tables.gpos)return this.getLookupTables(i,o,"kern",2)};var pc=Ds;function Vs(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 Ki(i,o,u){let h=0,f=i.length-1,g=null;for(;h<=f;){let A=Math.floor((h+f)/2),_=i[A],I=_[o];if(I<u)h=A+1;else if(I>u)f=A-1;else{g=_;break}}return g}function _o(i,o,u){let h=0,f=i.length-1;for(;h<=f;){let g=Math.floor((h+f)/2),A=i[g];if(A[o]<u)h=g+1;else if(A[o]>u)f=g-1;else return g}return-1}function yi(i,o,u){let h=0,f=i.length,g=(A,_)=>A[o]-_[o];for(;h<f;){let A=h+f>>>1;g(i[A],u)<0?h=A+1:f=A}return i.splice(h,0,u),h}function ko(i){return i[0]===31&&i[1]===139&&i[2]===8}function tu(i){let o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=10,h=i.byteLength-8,f=o.getInt8(3);if(f&4&&(u+=2+o.getUint16(u,!0)),f&8)for(;u<h&&i[u++]!==0;);if(f&16)for(;u<h&&i[u++]!==0;);if(f&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 vi(i){return{x:i.x,y:i.y,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour}}function F0(i){return{glyphIndex:i.glyphIndex,xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:i.dx,dy:i.dy}}function wi(i){us.call(this,i,"gsub")}function sd(i,o,u){let h=i.subtables;for(let f=0;f<h.length;f++){let g=h[f];if(g.substFormat===o)return g}if(u)return h.push(u),u}wi.prototype=us.prototype,wi.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},wi.prototype.getSingle=function(i,o,u){let h=[],f=this.getLookupTables(o,u,i,1);for(let g=0;g<f.length;g++){let A=f[g].subtables;for(let _=0;_<A.length;_++){let I=A[_],D=this.expandCoverage(I.coverage),M;if(I.substFormat===1){let te=I.deltaGlyphId;for(M=0;M<D.length;M++){let J=D[M];h.push({sub:J,by:J+te})}}else{let te=I.substitute;for(M=0;M<D.length;M++)h.push({sub:D[M],by:te[M]})}}}return h},wi.prototype.getMultiple=function(i,o,u){let h=[],f=this.getLookupTables(o,u,i,2);for(let g=0;g<f.length;g++){let A=f[g].subtables;for(let _=0;_<A.length;_++){let I=A[_],D=this.expandCoverage(I.coverage),M;for(M=0;M<D.length;M++){let te=D[M],J=I.sequences[M];h.push({sub:te,by:J})}}}return h},wi.prototype.getAlternates=function(i,o,u){let h=[],f=this.getLookupTables(o,u,i,3);for(let g=0;g<f.length;g++){let A=f[g].subtables;for(let _=0;_<A.length;_++){let I=A[_],D=this.expandCoverage(I.coverage),M=I.alternateSets;for(let te=0;te<D.length;te++)h.push({sub:D[te],by:M[te]})}}return h},wi.prototype.getLigatures=function(i,o,u){let h=[],f=this.getLookupTables(o,u,i,4);for(let g=0;g<f.length;g++){let A=f[g].subtables;for(let _=0;_<A.length;_++){let I=A[_],D=this.expandCoverage(I.coverage),M=I.ligatureSets;for(let te=0;te<D.length;te++){let J=D[te],Te=M[te];for(let he=0;he<Te.length;he++){let Re=Te[he];h.push({sub:[J].concat(Re.components),by:Re.ligGlyph})}}}}return h},wi.prototype.addSingle=function(i,o,u,h){let f=this.getLookupTables(u,h,i,1,!0)[0],g=sd(f,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});ue.assert(g.coverage.format===1,"Single: unable to modify coverage table format "+g.coverage.format);let A=o.sub,_=this.binSearch(g.coverage.glyphs,A);_<0&&(_=-1-_,g.coverage.glyphs.splice(_,0,A),g.substitute.splice(_,0,0)),g.substitute[_]=o.by},wi.prototype.addMultiple=function(i,o,u,h){ue.assert(o.by instanceof Array&&o.by.length>1,'Multiple: "by" must be an array of two or more ids');let f=this.getLookupTables(u,h,i,2,!0)[0],g=sd(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ue.assert(g.coverage.format===1,"Multiple: unable to modify coverage table format "+g.coverage.format);let A=o.sub,_=this.binSearch(g.coverage.glyphs,A);_<0&&(_=-1-_,g.coverage.glyphs.splice(_,0,A),g.sequences.splice(_,0,0)),g.sequences[_]=o.by},wi.prototype.addAlternate=function(i,o,u,h){let f=this.getLookupTables(u,h,i,3,!0)[0],g=sd(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ue.assert(g.coverage.format===1,"Alternate: unable to modify coverage table format "+g.coverage.format);let A=o.sub,_=this.binSearch(g.coverage.glyphs,A);_<0&&(_=-1-_,g.coverage.glyphs.splice(_,0,A),g.alternateSets.splice(_,0,0)),g.alternateSets[_]=o.by},wi.prototype.addLigature=function(i,o,u,h){let f=this.getLookupTables(u,h,i,4,!0)[0],g=f.subtables[0];g||(g={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},f.subtables[0]=g),ue.assert(g.coverage.format===1,"Ligature: unable to modify coverage table format "+g.coverage.format);let A=o.sub[0],_=o.sub.slice(1),I={ligGlyph:o.by,components:_},D=this.binSearch(g.coverage.glyphs,A);if(D>=0){let M=g.ligatureSets[D];for(let te=0;te<M.length;te++)if(Vs(M[te].components,_))return;M.push(I)}else D=-1-D,g.coverage.glyphs.splice(D,0,A),g.ligatureSets.splice(D,0,[I])},wi.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)}},wi.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 Ja=wi,ba=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 f=u.colorRecordIndices[h],g=[];for(let A=f;A<f+u.numPaletteEntries;A++)g.push(gn(u.colorRecords[A],i||"hexa"));o.push(g)}return o}toCPALcolor(i){return Array.isArray(i)?i.map(o=>Vn(o,"raw")):Vn(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(f=>this.fillPalette(f,[],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 cn(this.font,i,o,u)}setColor(i,o,u=0){i=parseInt(i),u=parseInt(u);let h=this.getAll("raw"),f=h[u];if(!f)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"),f=h[u]);for(let _=0;_<o.length;_++)f[_+i]=this.toCPALcolor(o[_]);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"),f=[];if(o>u.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${u.numPaletteEntries-1}, replacementIndex: ${o})`);for(let _=0;_<h.length;_++){let I=h[_].filter((D,M)=>M!==i);f.push(I)}let g=this.font.tables.colr;if(g){let _=g.layerRecords;for(let I=0;I<_.length;I++){let D=_[I].paletteIndex;if(D>i)_[I].paletteIndex-=1;else if(D===i){let M=0;for(let te=0;te<h.length;te++)if(o>i&&o<=i+h[te].length){M++;break}_[I].paletteIndex=o-M}}this.font.tables.colr={...g,layerRecords:_}}let A=f.flat();for(let _=0;_<h.length;_++)u.colorRecordIndices[_]-=_;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)}},Pl=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,f=o.tables.cpal;if(!h||!f)return u;let g=Ki(h.baseGlyphRecords,"glyphID",i);if(!g)return u;let A=g.firstLayerIndex,_=g.numLayers;for(let I=0;I<_;I++){let D=h.layerRecords[A+I];u.push({glyph:o.glyphs.get(D.glyphID),paletteIndex:D.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 f=[];for(let g=0;g<u;g++){let A=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;f.push({glyphID:A,paletteIndex:h[g].paletteIndex})}for(let g of o){let A=Number.isInteger(g.glyph)?g.glyph:g.glyph.index;f.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;f.push({glyphID:A,paletteIndex:h[g].paletteIndex})}this.updateColrTable(i,f)}setPaletteIndex(i,o,u){let h=this.get(i);h[o]?(h=h.map((f,g)=>({glyphID:f.glyph.index,paletteIndex:g===o?u:f.paletteIndex})),this.updateColrTable(i,h)):console.error("Invalid layer index")}remove(i,o,u=o){let h=this.get(i);h=h.map(f=>({glyphID:f.glyph.index,paletteIndex:f.paletteIndex})),h.splice(o,u-o+1),this.updateColrTable(i,h)}updateColrTable(i,o){this.ensureCOLR();let u=this.font.tables.colr,h=_o(u.baseGlyphRecords,"glyphID",i);if(h===-1){let I={glyphID:i,firstLayerIndex:u.layerRecords.length,numLayers:0};h=yi(u.baseGlyphRecords,"glyphID",I)}let f=u.baseGlyphRecords[h],g=f.numLayers,A=o.length,_=A-g;if(_>0){let I=o.slice(g).map(D=>({glyphID:D.glyphID,paletteIndex:D.paletteIndex}));u.layerRecords.splice(f.firstLayerIndex+g,0,...I)}else _<0&&u.layerRecords.splice(f.firstLayerIndex+A,-_);for(let I=0;I<Math.min(g,A);I++)u.layerRecords[f.firstLayerIndex+I]={glyphID:o[I].glyphID,paletteIndex:o[I].paletteIndex};if(f.numLayers=A,_!==0)for(let I=0;I<u.baseGlyphRecords.length;I++){let D=u.baseGlyphRecords[I];I===h||D.firstLayerIndex<f.firstLayerIndex||(u.baseGlyphRecords[I].firstLayerIndex+=_)}}},ru=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=ap(u),this.cache.set(u,h));let f=h.images.get(i);return f===void 0&&(f=op(this.font,h.template,i),f.promise.then(g=>{if(f.image=g,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(i)}catch(A){console.error("font.onGlyphUpdated",i,A)}}),h.images.set(i,f)),f}};function ap(i){return{template:lp(i).then(nu),images:new Map}}function op(i,o,u){return{promise:o.then(h=>{let f;typeof h=="string"?f=h:(h[4]=u,f=h.join(""));let g=$0(f,i.unitsPerEm);return g.image.decode().then(()=>g)}),image:void 0}}var lp=typeof DecompressionStream=="function"?id:cp;function cp(i){try{return Promise.resolve(new TextDecoder().decode(ko(i)?tu(i):i))}catch(o){return Promise.reject(o)}}function id(i){if(ko(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 nu(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 $0(i,o){let u=new DOMParser().parseFromString(i,"image/svg+xml").documentElement,h=u.viewBox.baseVal,f=u.width.baseVal,g=u.height.baseVal,A=1,_=1;h.width>0&&h.height>0&&(f.unitType===1?(A=f.valueInSpecifiedUnits/h.width,_=g.unitType===1?g.valueInSpecifiedUnits/h.height:A):g.unitType===1?(_=g.valueInSpecifiedUnits/h.height,A=_):o&&(A=o/h.width,_=o/h.height));let I=document.createElement("div");I.style.position="fixed",I.style.visibility="hidden",I.appendChild(u),document.body.appendChild(I);let D=u.getBBox();document.body.removeChild(I);let M=(D.x-h.x)*A,te=(h.y-D.y)*_,J=D.width*A,Te=D.height*_;u.setAttribute("viewBox",[D.x,D.y,D.width,D.height].join(" ")),A!==1&&u.setAttribute("width",J),_!==1&&u.setAttribute("height",Te);let he=new Image(J,Te);return he.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u.outerHTML),{leftSideBearing:M,baseline:te,image:he}}var ja=new WeakMap;function Vo(i,o,u,h,f){let g;return(o&h)>0?(g=i.parseByte(),(o&f)===0&&(g=-g),g=u+g):(o&f)>0?g=u:g=u+i.parseShort(),g}function mc(i,o,u){let h=new ot.Parser(o,u);i._numberOfContours=h.parseShort(),i._xMin=h.parseShort(),i._yMin=h.parseShort(),i._xMax=h.parseShort(),i._yMax=h.parseShort();let f,g;if(i._numberOfContours>0){let A=i.endPointIndices=[];for(let I=0;I<i._numberOfContours;I+=1)A.push(h.parseUShort());i.instructionLength=h.parseUShort(),i.instructions=[];for(let I=0;I<i.instructionLength;I+=1)i.instructions.push(h.parseByte());let _=A[A.length-1]+1;f=[];for(let I=0;I<_;I+=1)if(g=h.parseByte(),f.push(g),(g&8)>0){let D=h.parseByte();for(let M=0;M<D;M+=1)f.push(g),I+=1}if(ue.argument(f.length===_,"Bad flags."),A.length>0){let I=[],D;if(_>0){for(let J=0;J<_;J+=1)g=f[J],D={},D.onCurve=!!(g&1),D.lastPointOfContour=A.indexOf(J)>=0,I.push(D);let M=0;for(let J=0;J<_;J+=1)g=f[J],D=I[J],D.x=Vo(h,g,M,2,16),M=D.x;let te=0;for(let J=0;J<_;J+=1)g=f[J],D=I[J],D.y=Vo(h,g,te,4,32),te=D.y}i.points=I}else i.points=[]}else if(i._numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let A=!0;for(;A;){f=h.parseUShort();let _={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(f&1)>0?(f&2)>0?(_.dx=h.parseShort(),_.dy=h.parseShort()):_.matchedPoints=[h.parseUShort(),h.parseUShort()]:(f&2)>0?(_.dx=h.parseChar(),_.dy=h.parseChar()):_.matchedPoints=[h.parseByte(),h.parseByte()],(f&8)>0?_.xScale=_.yScale=h.parseF2Dot14():(f&64)>0?(_.xScale=h.parseF2Dot14(),_.yScale=h.parseF2Dot14()):(f&128)>0&&(_.xScale=h.parseF2Dot14(),_.scale01=h.parseF2Dot14(),_.scale10=h.parseF2Dot14(),_.yScale=h.parseF2Dot14()),i.components.push(_),A=!!(f&32)}if(f&256){i.instructionLength=h.parseUShort(),i.instructions=[];for(let _=0;_<i.instructionLength;_+=1)i.instructions.push(h.parseByte())}}}function su(i,o){let u=[];for(let h=0;h<i.length;h+=1){let f=i[h],g={x:o.xScale*f.x+o.scale10*f.y+o.dx,y:o.scale01*f.x+o.yScale*f.y+o.dy,onCurve:f.onCurve,lastPointOfContour:f.lastPointOfContour};u.push(g)}return u}function gc(i){let o=[],u=[];for(let h=0;h<i.length;h+=1){let f=i[h];u.push(f),f.lastPointOfContour&&(o.push(u),u=[])}return ue.argument(u.length===0,"There are still points left in the current contour."),o}function iu(i){let o=new We;if(!i)return o;let u=gc(i);for(let h=0;h<u.length;++h){let f=u[h],g=f[f.length-1],A=f[0];if(g.onCurve)o.moveTo(g.x,g.y);else if(A.onCurve)o.moveTo(A.x,A.y);else{let _={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5};o.moveTo(_.x,_.y)}for(let _=0;_<f.length;++_)if(g=A,A=f[(_+1)%f.length],g.onCurve)o.lineTo(g.x,g.y);else{let I=A;A.onCurve||(I={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5}),o.quadraticCurveTo(g.x,g.y,I.x,I.y)}o.closePath()}return o}function ad(i,o){if(o.isComposite){ja.has(i)||ja.set(i,new Set);let u=ja.get(i);u.add(o.index);try{for(let h=0;h<o.components.length;h+=1){let f=o.components[h];if(u.has(f.glyphIndex))continue;let g=i.get(f.glyphIndex);if(g.getPath(),g.points){let A;if(f.matchedPoints===void 0)A=su(g.points,f);else{if(f.matchedPoints[0]>o.points.length-1||f.matchedPoints[1]>g.points.length-1)throw Error("Matched points out of range in "+o.name);let _=o.points[f.matchedPoints[0]],I=g.points[f.matchedPoints[1]],D={xScale:f.xScale,scale01:f.scale01,scale10:f.scale10,yScale:f.yScale,dx:0,dy:0};I=su([I],D)[0],D.dx=_.x-I.x,D.dy=_.y-I.y,A=su(g.points,D)}o.points=o.points.concat(A)}}}finally{u.delete(o.index)}}return iu(o.points)}function U0(i,o,u,h){let f=new Wr.GlyphSet(h);for(let g=0;g<u.length-1;g+=1){let A=u[g],_=u[g+1];A!==_?f.push(g,Wr.ttfGlyphLoader(h,g,mc,i,o+A,ad)):f.push(g,Wr.glyphLoader(h,g))}return f}function z0(i,o,u,h){let f=new Wr.GlyphSet(h);return h._push=function(g){let A=u[g],_=u[g+1];A!==_?f.push(g,Wr.ttfGlyphLoader(h,g,mc,i,o+A,ad)):f.push(g,Wr.glyphLoader(h,g))},f}function H0(i,o,u,h,f){return f.lowMemory?z0(i,o,u,h):U0(i,o,u,h)}var Ol={getPath:iu,parse:H0},eo=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],f=i[h.tag];f===void 0&&(f=h.defaultValue),f<h.defaultValue?o.push((f-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):o.push((f-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 f=0;f<h.axisValueMaps.length;f++){let g=h.axisValueMaps[f];if(f>=1&&o[u]<g.fromCoordinate){let A=h.axisValueMaps[f-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 f=h,g=h,A=i[g];for(;!A.lastPointOfContour;)A=i[++g];for(;h<=g&&!u[h];)h++;if(h>g)continue;let _=h,I=h;for(h++;h<=g;)u[h]&&(this.deltaInterpolate(I+1,h-1,I,h,o,i),I=h),h++;I===_?this.deltaShift(f,g,I,o,i):(this.deltaInterpolate(I+1,g,I,_,o,i),_>0&&this.deltaInterpolate(f,_-1,I,_,o,i)),h=g+1}}deltaInterpolate(i,o,u,h,f,g){if(i>o)return;let A=["x","y"];for(let I=0;I<A.length;I++){let D=A[I];if(f[u][D]>f[h][D]){var _=u;u=h,h=_}let M=f[u][D],te=f[h][D],J=g[u][D],Te=g[h][D];if(M!==te||J===Te){let he=M===te?0:(Te-J)/(te-M);for(let Re=i;Re<=o;Re++){let ct=f[Re][D];ct<=M?ct+=J-M:ct>=te?ct+=Te-te:ct=J+(ct-M)*he,g[Re][D]=ct}}}}deltaShift(i,o,u,h,f){let g=f[u].x-h[u].x,A=f[u].y-h[u].y;if(!(g===0&&A===0))for(let _=i;_<=o;_++)_!==u&&(f[_].x+=g,f[_].y+=A)}transformComponents(i,o,u,h,f,g){let A=0;for(let _=0;_<i.components.length;_++){let I=i.components[_],D=this.font.glyphs.get(I.glyphIndex),M=F0(I),te=h.indexOf(_);te>-1&&(M.dx+=Math.round(f.deltas[te]*g),M.dy+=Math.round(f.deltasY[te]*g));let J=su(this.getTransform(D,u).points,M);o.splice(A,J.length,...J),A+=D.points.length}}applyTupleVariationStore(i,o,u,h="gvar",f={}){u||(u=this.font.variation.get());let g=this.getNormalizedCoords(u),{headers:A,sharedPoints:_}=i,I=this.fvar().axes.length,D;h==="gvar"?D=o.map(vi):h==="cvar"&&(D=[...o]);for(let M=0;M<A.length;M++){let te=A[M],J=1;for(let he=0;he<I;he++){let Re=[0];switch(h){case"gvar":Re=te.peakTuple?te.peakTuple:this.gvar().sharedTuples[te.sharedTupleRecordsIndex];break;case"cvar":Re=te.peakTuple;break}if(Re[he]!==0){if(g[he]===0){J=0;break}if(te.intermediateStartTuple)if(g[he]<te.intermediateStartTuple[he]||g[he]>te.intermediateEndTuple[he]){J=0;break}else g[he]<Re[he]?J=J*(g[he]-te.intermediateStartTuple[he]+Number.EPSILON)/(Re[he]-te.intermediateStartTuple[he]+Number.EPSILON):J=J*(te.intermediateEndTuple[he]-g[he]+Number.EPSILON)/(te.intermediateEndTuple[he]-Re[he]+Number.EPSILON);else{if(g[he]<Math.min(0,Re[he])||g[he]>Math.max(0,Re[he])){J=0;break}J=(J*g[he]+Number.EPSILON)/(Re[he]+Number.EPSILON)}}}if(J===0)continue;let Te=te.privatePoints.length?te.privatePoints:_;if(h==="gvar"&&f.glyph&&f.glyph.isComposite)this.transformComponents(f.glyph,D,u,Te,te,J);else if(Te.length===0)for(let he=0;he<D.length;he++){let Re=D[he];h==="gvar"?D[he]={x:Math.round(Re.x+te.deltas[he]*J),y:Math.round(Re.y+te.deltasY[he]*J),onCurve:Re.onCurve,lastPointOfContour:Re.lastPointOfContour}:h==="cvar"&&(D[he]=Math.round(Re+te.deltas[he]*J))}else{let he;h==="gvar"?he=D.map(vi):h==="cvar"&&(he=D);let Re=Array(o.length).fill(!1);for(let ct=0;ct<Te.length;ct++){let mr=Te[ct];if(mr<o.length){let lr=he[mr];h==="gvar"?(Re[mr]=!0,lr.x+=te.deltas[ct]*J,lr.y+=te.deltasY[ct]*J):h==="cvar"&&(D[mr]=Math.round(lr+te.deltas[ct]*J))}}if(h==="gvar"){this.interpolatePoints(he,D,Re);for(let ct=0;ct<o.length;ct++){let mr=he[ct].x-D[ct].x,lr=he[ct].y-D[ct].y;D[ct].x=Math.round(D[ct].x+mr),D[ct].y=Math.round(D[ct].y+lr)}}}}return D}getTransform(i,o){Number.isInteger(i)&&(i=this.font.glyphs.get(i));let u=i.getBlendPath,h=!!(i.points&&i.points.length),f=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,_=this.applyTupleVariationStore(g,A,o,"gvar",{glyph:i});f=new pr(Object.assign({},i,{points:_,path:iu(_)}))}}else if(u){let g=i.getBlendPath(o);f=new pr(Object.assign({},i,{path:g}))}}return this.font.tables.hvar&&(i._advanceWidth=typeof i._advanceWidth<"u"?i._advanceWidth:i.advanceWidth,i.advanceWidth=f.advanceWidth=Math.round(i._advanceWidth+this.getVariableAdjustment(f.index,"hvar","advanceWidth",o)),i._leftSideBearing=typeof i._leftSideBearing<"u"?i._leftSideBearing:i.leftSideBearing,i.leftSideBearing=f.leftSideBearing=Math.round(i._leftSideBearing+this.getVariableAdjustment(f.index,"hvar","lsb",o))),f}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 f,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 _=A[u]&&A[u].map.length;if(_){let I=i;I>=_&&(I=_-1),{outerIndex:f,innerIndex:g}=A[u].map[I]}else f=0,g=i;return this.getDelta(A.itemVariationStore,f,g,h)}getDelta(i,o,u,h){if(o>=i.itemVariationSubtables.length)return 0;let f=i.itemVariationSubtables[o];if(u>=f.deltaSets.length)return 0;let g=f.deltaSets[u],A=this.getBlendVector(i,o,h),_=0;for(let I=0;I<f.regionIndexes.length;I++)_+=g[I]*A[I];return _}getBlendVector(i,o,u){u||(u=this.font.variation.get());let h=i.itemVariationSubtables[o],f=this.getNormalizedCoords(u),g=[];for(let A=0;A<h.regionIndexes.length;A++){let _=1,I=h.regionIndexes[A],D=i.variationRegions[I].regionAxes;for(let M=0;M<D.length;M++){let te=D[M],J;te.startCoord>te.peakCoord||te.peakCoord>te.endCoord||te.startCoord<0&&te.endCoord>0&&te.peakCoord!==0||te.peakCoord===0?J=1:f[M]<te.startCoord||f[M]>te.endCoord?J=0:f[M]===te.peakCoord?J=1:f[M]<te.peakCoord?J=(f[M]-te.startCoord+Number.EPSILON)/(te.peakCoord-te.startCoord+Number.EPSILON):J=(te.endCoord-f[M]+Number.EPSILON)/(te.endCoord-te.peakCoord+Number.EPSILON),_*=J}g[A]=_}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}},od=class{constructor(i){this.font=i,this.process=new eo(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}},W0=1e6,xc=64,Fl=1e4,au,xl,ld,bc;function cd(i){this.font=i,this.getCommands=function(o){return Ol.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ya(i){return i}function $l(i){return Math.sign(i)*Math.round(Math.abs(i))}function ud(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function yc(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function Ul(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function Bs(i){return Math.sign(i)*Math.floor(Math.abs(i))}var G0=function(i){let o=this.srPeriod,u=this.srPhase,h=this.srThreshold,f=1;return i<0&&(i=-i,f=-1),i+=h-u,i=Math.trunc(i/o)*o,i+=u,i<0?u*f:i*f},Da={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 f,g,A,_,I,D,M;if(!h||h===this){if(f=i.xo-o.xo,g=i.xo-u.xo,I=o.x-o.xo,D=u.x-u.xo,A=Math.abs(f),_=Math.abs(g),M=A+_,M===0){i.x=i.xo+(I+D)/2;return}i.x=i.xo+(I*_+D*A)/M;return}if(f=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),I=h.distance(o,o,!1,!0),D=h.distance(u,u,!1,!0),A=Math.abs(f),_=Math.abs(g),M=A+_,M===0){Da.setRelative(i,i,(I+D)/2,h,!0);return}Da.setRelative(i,i,(I*_+D*A)/M,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,o,u,h,f){if(!h||h===this){i.x=(f?o.xo:o.x)+u;return}let g=f?o.xo:o.x,A=f?o.yo:o.y,_=g+u*h.x,I=A+u*h.y;i.x=_+(i.y-I)/h.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},Lo={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 f,g,A,_,I,D,M;if(!h||h===this){if(f=i.yo-o.yo,g=i.yo-u.yo,I=o.y-o.yo,D=u.y-u.yo,A=Math.abs(f),_=Math.abs(g),M=A+_,M===0){i.y=i.yo+(I+D)/2;return}i.y=i.yo+(I*_+D*A)/M;return}if(f=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),I=h.distance(o,o,!1,!0),D=h.distance(u,u,!1,!0),A=Math.abs(f),_=Math.abs(g),M=A+_,M===0){Lo.setRelative(i,i,(I+D)/2,h,!0);return}Lo.setRelative(i,i,(I*_+D*A)/M,h,!0)},normalSlope:0,setRelative:function(i,o,u,h,f){if(!h||h===this){i.y=(f?o.yo:o.y)+u;return}let g=f?o.xo:o.x,A=f?o.yo:o.y,_=g+u*h.x,I=A+u*h.y;i.y=I+h.normalSlope*(i.x-_)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze(Da),Object.freeze(Lo);function zl(i,o){this.x=i,this.y=o,this.axis=void 0,this.slope=o/i,this.normalSlope=-i/o,Object.freeze(this)}zl.prototype.distance=function(i,o,u,h){return this.x*Da.distance(i,o,u,h)+this.y*Lo.distance(i,o,u,h)},zl.prototype.interpolate=function(i,o,u,h){let f,g,A,_,I,D,M;if(A=h.distance(i,o,!0,!0),_=h.distance(i,u,!0,!0),f=h.distance(o,o,!1,!0),g=h.distance(u,u,!1,!0),I=Math.abs(A),D=Math.abs(_),M=I+D,M===0){this.setRelative(i,i,(f+g)/2,h,!0);return}this.setRelative(i,i,(f*D+g*I)/M,h,!0)},zl.prototype.setRelative=function(i,o,u,h,f){h=h||this;let g=f?o.xo:o.x,A=f?o.yo:o.y,_=g+u*h.x,I=A+u*h.y,D=h.normalSlope,M=this.slope,te=i.x,J=i.y;i.x=(M*te-D*_+I-J)/(M-D),i.y=M*(i.x-te)+J},zl.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function Hl(i,o){let u=Math.sqrt(i*i+o*o);return i/=u,o/=u,i===1&&o===0?Da:i===0&&o===1?Lo:new zl(i,o)}function C(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)}C.prototype.nextTouched=function(i){let o=this.nextPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.nextPointOnContour;return o},C.prototype.prevTouched=function(i){let o=this.prevPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.prevPointOnContour;return o};var P=Object.freeze(new C(0,0)),de={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function rt(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=Da,this.round=$l}}cd.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 f=this._fpgmState;if(!f){rt.prototype=de,f=this._fpgmState=new rt("fpgm",u.tables.fpgm),f.funcs=[],f.font=u,f.instructionCount=0,f.callDepth=0;try{xl(f)}catch(A){console.log("Hinting error in FPGM:"+A),this._errorState=3;return}}rt.prototype=f,h=this._prepState=new rt("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),_=o/u.unitsPerEm;for(let I=0;I<g.length;I++)A[I]=g[I]*_}else h.cvt=[];try{xl(h)}catch(A){this._errorState<2&&console.log("Hinting error in PREP:"+A),this._errorState=2}}if(!(this._errorState>1))try{return ld(i,h)}catch(f){this._errorState<1&&(console.log("Hinting error:"+f),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},ld=function(i,o){let u=o.ppem/o.font.unitsPerEm,h=u,f=i.components,g,A,_;if(rt.prototype=o,!f)_=new rt("glyf",i.instructions),_.instructionCount=0,_.callDepth=0,bc(i,_,u,h),A=_.gZone;else{let I=o.font;A=[],g=[];for(let D=0;D<f.length;D++){let M=f[D],te=I.glyphs.get(M.glyphIndex);_=new rt("glyf",te.instructions),_.instructionCount=0,_.callDepth=0,bc(te,_,u,h);let J=Math.round(M.dx*u),Te=Math.round(M.dy*h),he=_.gZone,Re=_.contours;for(let mr=0;mr<he.length;mr++){let lr=he[mr];lr.xTouched=lr.yTouched=!1,lr.xo=lr.x=lr.x+J,lr.yo=lr.y=lr.y+Te}let ct=A.length;A.push.apply(A,he);for(let mr=0;mr<Re.length;mr++)g.push(Re[mr]+ct)}i.instructions&&!_.inhibitGridFit&&(_=new rt("glyf",i.instructions),_.gZone=_.z0=_.z1=_.z2=A,_.contours=g,A.push(new C(0,0),new C(Math.round(i.advanceWidth*u),0)),xl(_),A.length-=2)}return A},bc=function(i,o,u,h){let f=i.points||[],g=f.length,A=o.gZone=o.z0=o.z1=o.z2=[],_=o.contours=[],I;for(let te=0;te<g;te++)I=f[te],A[te]=new C(I.x*u,I.y*h,I.lastPointOfContour,I.onCurve);let D,M;for(let te=0;te<g;te++)I=A[te],D||(D=I,_.push(te)),I.lastPointOfContour?(I.nextPointOnContour=D,D.prevPointOnContour=I,D=void 0):(M=A[te+1],I.nextPointOnContour=M,M.prevPointOnContour=I);o.inhibitGridFit||(A.push(new C(0,0),new C(Math.round(i.advanceWidth*u),0)),xl(o),A.length-=2)},xl=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>W0)throw new Error("Hinting instructions exceeded maximum of "+W0);if(h=au[o[i.ip]],!h)throw new Error("unknown instruction: 0x"+Number(o[i.ip]).toString(16));h(i)}};function At(i){let o=i.tZone=new Array(i.gZone.length);for(let u=0;u<o.length;u++)o[u]=new C(0,0)}function Zt(i,o){let u=i.prog,h=i.ip,f=1,g;do if(g=u[++h],g===88)f++;else if(g===89)f--;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&&f===1&&g===27)break;while(f>0);i.ip=h}function Nr(i,o){o.fv=o.pv=o.dpv=i}function An(i,o){o.pv=o.dpv=i}function Nn(i,o){o.fv=i}function Ln(i,o){let u=o.stack,h=u.pop(),f=u.pop(),g=o.z2[h],A=o.z1[f],_,I;i?(_=g.y-A.y,I=A.x-g.x):(_=A.x-g.x,I=A.y-g.y),o.pv=o.dpv=Hl(_,I)}function Ai(i,o){let u=o.stack,h=u.pop(),f=u.pop(),g=o.z2[h],A=o.z1[f],_,I;i?(_=g.y-A.y,I=A.x-g.x):(_=A.x-g.x,I=A.y-g.y),o.fv=Hl(_,I)}function Tn(i){let o=i.stack,u=o.pop(),h=o.pop();i.pv=i.dpv=Hl(h,u)}function Xi(i){let o=i.stack,u=o.pop(),h=o.pop();i.fv=Hl(h,u)}function Io(i){let o=i.stack,u=i.pv;o.push(u.x*16384),o.push(u.y*16384)}function Eo(i){let o=i.stack,u=i.fv;o.push(u.x*16384),o.push(u.y*16384)}function Ba(i){i.fv=i.pv}function Qi(i){let o=i.stack,u=o.pop(),h=o.pop(),f=o.pop(),g=o.pop(),A=o.pop(),_=i.z0,I=i.z1,D=_[u],M=_[h],te=I[f],J=I[g],Te=i.z2[A],he=D.x,Re=D.y,ct=M.x,mr=M.y,lr=te.x,Rr=te.y,sn=J.x,On=J.y,Yn=(he-ct)*(Rr-On)-(Re-mr)*(lr-sn),Zn=he*mr-Re*ct,Qs=lr*On-Rr*sn;Te.x=(Zn*(lr-sn)-Qs*(he-ct))/Yn,Te.y=(Zn*(Rr-On)-Qs*(Re-mr))/Yn}function to(i){i.rp0=i.stack.pop()}function up(i){i.rp1=i.stack.pop()}function dd(i){i.rp2=i.stack.pop()}function i4(i){let o=i.stack.pop();switch(i.zp0=o,o){case 0:i.tZone||At(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function a4(i){let o=i.stack.pop();switch(i.zp1=o,o){case 0:i.tZone||At(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function o4(i){let o=i.stack.pop();switch(i.zp2=o,o){case 0:i.tZone||At(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function l4(i){let o=i.stack.pop();switch(i.zp0=i.zp1=i.zp2=o,o){case 0:i.tZone||At(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 c4(i){i.loop=i.stack.pop(),i.loop>Fl&&(i.loop=Fl)}function u4(i){i.round=$l}function d4(i){i.round=yc}function h4(i){let o=i.stack.pop();i.minDis=o/64}function f4(i){Zt(i,!1)}function p4(i){let o=i.stack.pop();i.ip+=o-1}function m4(i){let o=i.stack.pop();i.cvCutIn=o/64}function g4(i){let o=i.stack;o.push(o[o.length-1])}function dp(i){i.stack.pop()}function x4(i){i.stack.length=0}function b4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u),o.push(h)}function y4(i){let o=i.stack;o.push(o.length)}function v4(i){let o=i.stack,u=o.pop(),h=o.pop();if(h>Fl&&(h=Fl),++i.callDepth>xc)throw new Error("Hinting call depth exceeded maximum of "+xc);let f=i.ip,g=i.prog;i.prog=i.funcs[u];for(let A=0;A<h;A++)xl(i);i.ip=f,i.prog=g,i.callDepth--}function w4(i){let o=i.stack.pop();if(++i.callDepth>xc)throw new Error("Hinting call depth exceeded maximum of "+xc);let u=i.ip,h=i.prog;i.prog=i.funcs[o],xl(i),i.ip=u,i.prog=h,i.callDepth--}function A4(i){let o=i.stack,u=o.pop();o.push(o[o.length-u])}function T4(i){let o=i.stack,u=o.pop();o.push(o.splice(o.length-u,1)[0])}function S4(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");let o=i.stack,u=i.prog,h=i.ip,f=o.pop(),g=h;for(;u[++h]!==45;);i.ip=h,i.funcs[f]=u.slice(g+1,h)}function Rg(i,o){let u=o.stack.pop(),h=o.z0[u],f=o.fv,g=o.pv,A=g.distance(h,P);i&&(A=o.round(A)),f.setRelative(h,P,A,g),f.touch(h),o.rp0=o.rp1=u}function Mg(i,o){let u=o.z2,h=u.length-2,f,g,A;for(let _=0;_<h;_++)f=u[_],!i.touched(f)&&(g=f.prevTouched(i),g!==f&&(A=f.nextTouched(i),g===A&&i.setRelative(f,f,i.distance(g,g,!1,!0),i,!0),i.interpolate(f,g,A,i)))}function jg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,_=o.loop,I=o.z2;for(;_--;){let D=u.pop(),M=I[D],te=A.distance(f,f,!1,!0);g.setRelative(M,M,te,A),g.touch(M)}o.loop=1}function Dg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,_=u.pop(),I=o.z2[o.contours[_]],D=I,M=A.distance(f,f,!1,!0);do D!==f&&g.setRelative(D,D,M,A),D=D.nextPointOnContour;while(D!==I)}function Bg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,_=u.pop(),I;switch(_){case 0:I=o.tZone;break;case 1:I=o.gZone;break;default:throw new Error("Invalid zone")}let D,M=A.distance(f,f,!1,!0),te=I.length-2;for(let J=0;J<te;J++)D=I[J],g.setRelative(D,D,M,A)}function C4(i){let o=i.stack,u=i.loop,h=i.fv,f=o.pop()/64,g=i.z2;for(;u--;){let A=o.pop(),_=g[A];h.setRelative(_,_,f),h.touch(_)}i.loop=1}function _4(i){let o=i.stack,u=i.rp1,h=i.rp2,f=i.loop,g=i.z0[u],A=i.z1[h],_=i.fv,I=i.dpv,D=i.z2;for(;f--;){let M=o.pop(),te=D[M];_.interpolate(te,g,A,I),_.touch(te)}i.loop=1}function Qg(i,o){let u=o.stack,h=u.pop()/64,f=u.pop(),g=o.z1[f],A=o.z0[o.rp0],_=o.fv,I=o.pv;_.setRelative(g,A,h,I),_.touch(g),o.rp1=o.rp0,o.rp2=f,i&&(o.rp0=f)}function k4(i){let o=i.stack,u=i.rp0,h=i.z0[u],f=i.loop,g=i.fv,A=i.pv,_=i.z1;for(;f--;){let I=o.pop(),D=_[I];g.setRelative(D,h,0,A),g.touch(D)}i.loop=1}function L4(i){i.round=ud}function Pg(i,o){let u=o.stack,h=u.pop(),f=u.pop(),g=o.z0[f],A=o.fv,_=o.pv,I=o.cvt[h],D=_.distance(g,P);i&&(Math.abs(D-I)<o.cvCutIn&&(D=I),D=o.round(D)),A.setRelative(g,P,D,_),o.zp0===0&&(g.xo=g.x,g.yo=g.y),A.touch(g),o.rp0=o.rp1=f}function I4(i){let o=i.prog,u=i.ip,h=i.stack,f=o[++u];for(let g=0;g<f;g++)h.push(o[++u]);i.ip=u}function E4(i){let o=i.ip,u=i.prog,h=i.stack,f=u[++o];for(let g=0;g<f;g++){let A=u[++o]<<8|u[++o];A&32768&&(A=-((A^65535)+1)),h.push(A)}i.ip=o}function N4(i){let o=i.stack,u=i.store;u||(u=i.store=[]);let h=o.pop(),f=o.pop();u[f]=h}function R4(i){let o=i.stack,u=i.store,h=o.pop(),f=u&&u[h]||0;o.push(f)}function M4(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u/64}function j4(i){let o=i.stack,u=o.pop();o.push(i.cvt[u]*64)}function Og(i,o){let u=o.stack,h=u.pop(),f=o.z2[h];u.push(o.dpv.distance(f,P,i,!1)*64)}function Fg(i,o){let u=o.stack,h=u.pop(),f=u.pop(),g=o.z1[h],A=o.z0[f],_=o.dpv.distance(A,g,i,i);o.stack.push(Math.round(_*64))}function D4(i){i.stack.push(i.ppem)}function B4(i){i.autoFlip=!0}function Q4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<u?1:0)}function P4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<=u?1:0)}function O4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>u?1:0)}function F4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>=u?1:0)}function $4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u===h?1:0)}function U4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u!==h?1:0)}function z4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?1:0)}function H4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?0:1)}function W4(i){let o=i.stack.pop(),u;o||Zt(i,!0)}function G4(i){}function V4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u&&h?1:0)}function q4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u||h?1:0)}function Y4(i){let o=i.stack,u=o.pop();o.push(u?0:1)}function hp(i,o){let u=o.stack,h=u.pop(),f=o.fv,g=o.pv,A=o.ppem,_=o.deltaBase+(i-1)*16,I=o.deltaShift,D=o.z0;for(let M=0;M<h;M++){let te=u.pop(),J=u.pop();if(_+((J&240)>>4)!==A)continue;let Te=(J&15)-8;Te>=0&&Te++;let he=D[te];f.setRelative(he,he,Te*I,g)}}function Z4(i){let o=i.stack.pop();i.deltaBase=o}function K4(i){let o=i.stack.pop();i.deltaShift=Math.pow(.5,o)}function X4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h+u)}function J4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h-u)}function e7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*64/u)}function t7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*u/64)}function r7(i){let o=i.stack,u=o.pop();o.push(Math.abs(u))}function n7(i){let o=i.stack,u=o.pop();o.push(-u)}function s7(i){let o=i.stack,u=o.pop();o.push(Math.floor(u/64)*64)}function i7(i){let o=i.stack,u=o.pop();o.push(Math.ceil(u/64)*64)}function V0(i,o){let u=o.stack,h=u.pop();u.push(o.round(h/64)*64)}function a7(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u*i.ppem/i.font.unitsPerEm}function fp(i,o){let u=o.stack,h=u.pop(),f=o.ppem,g=o.deltaBase+(i-1)*16,A=o.deltaShift;for(let _=0;_<h;_++){let I=u.pop(),D=u.pop();if(g+((D&240)>>4)!==f)continue;let M=(D&15)-8;M>=0&&M++;let te=M*A;o.cvt[I]+=te}}function o7(i){let o=i.stack.pop();i.round=G0;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 l7(i){let o=i.stack.pop();i.round=G0;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 c7(i){i.round=ya}function u7(i){i.round=Ul}function d7(i){i.round=Bs}function h7(i){let o=i.stack.pop()}function $g(i,o){let u=o.stack,h=u.pop(),f=u.pop(),g=o.z2[h],A=o.z1[f],_,I;i?(_=g.y-A.y,I=A.x-g.x):(_=A.x-g.x,I=A.y-g.y),o.dpv=Hl(_,I)}function f7(i){let o=i.stack,u=o.pop(),h=0;u&1&&(h=35),u&32&&(h|=4096),o.push(h)}function p7(i){let o=i.stack,u=o.pop(),h=o.pop(),f=o.pop();o.push(h),o.push(u),o.push(f)}function m7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.max(h,u))}function g7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.min(h,u))}function x7(i){let o=i.stack.pop()}function b7(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 Wl(i,o){let u=o.stack,h=o.prog,f=o.ip;for(let g=0;g<i;g++)u.push(h[++f]);o.ip=f}function Gl(i,o){let u=o.ip,h=o.prog,f=o.stack;for(let g=0;g<i;g++){let A=h[++u]<<8|h[++u];A&32768&&(A=-((A^65535)+1)),f.push(A)}o.ip=u}function ur(i,o,u,h,f,g){let A=g.stack,_=i&&A.pop(),I=A.pop(),D=g.rp0,M=g.z0[D],te=g.z1[I],J=g.minDis,Te=g.fv,he=g.dpv,Re,ct,mr,lr;ct=Re=he.distance(te,M,!0,!0),mr=ct>=0?1:-1,ct=Math.abs(ct),i&&(lr=g.cvt[_],h&&Math.abs(ct-lr)<g.cvCutIn&&(ct=lr)),u&&ct<J&&(ct=J),h&&(ct=g.round(ct)),Te.setRelative(te,M,mr*ct,he),Te.touch(te),g.rp1=g.rp0,g.rp2=I,o&&(g.rp0=I)}au=[Nr.bind(void 0,Lo),Nr.bind(void 0,Da),An.bind(void 0,Lo),An.bind(void 0,Da),Nn.bind(void 0,Lo),Nn.bind(void 0,Da),Ln.bind(void 0,0),Ln.bind(void 0,1),Ai.bind(void 0,0),Ai.bind(void 0,1),Tn,Xi,Io,Eo,Ba,Qi,to,up,dd,i4,a4,o4,l4,c4,u4,d4,h4,f4,p4,m4,void 0,void 0,g4,dp,x4,b4,y4,A4,T4,void 0,void 0,void 0,v4,w4,S4,void 0,Rg.bind(void 0,0),Rg.bind(void 0,1),Mg.bind(void 0,Lo),Mg.bind(void 0,Da),jg.bind(void 0,0),jg.bind(void 0,1),Dg.bind(void 0,0),Dg.bind(void 0,1),Bg.bind(void 0,0),Bg.bind(void 0,1),C4,_4,Qg.bind(void 0,0),Qg.bind(void 0,1),k4,L4,Pg.bind(void 0,0),Pg.bind(void 0,1),I4,E4,N4,R4,M4,j4,Og.bind(void 0,0),Og.bind(void 0,1),void 0,Fg.bind(void 0,0),Fg.bind(void 0,1),D4,void 0,B4,void 0,void 0,Q4,P4,O4,F4,$4,U4,z4,H4,W4,G4,V4,q4,Y4,hp.bind(void 0,1),Z4,K4,X4,J4,e7,t7,r7,n7,s7,i7,V0.bind(void 0,0),V0.bind(void 0,1),V0.bind(void 0,2),V0.bind(void 0,3),void 0,void 0,void 0,void 0,a7,hp.bind(void 0,2),hp.bind(void 0,3),fp.bind(void 0,1),fp.bind(void 0,2),fp.bind(void 0,3),o7,l7,void 0,void 0,c7,void 0,u7,d7,dp,dp,void 0,void 0,void 0,void 0,void 0,h7,$g.bind(void 0,0),$g.bind(void 0,1),f7,void 0,p7,m7,g7,x7,b7,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,Wl.bind(void 0,1),Wl.bind(void 0,2),Wl.bind(void 0,3),Wl.bind(void 0,4),Wl.bind(void 0,5),Wl.bind(void 0,6),Wl.bind(void 0,7),Wl.bind(void 0,8),Gl.bind(void 0,1),Gl.bind(void 0,2),Gl.bind(void 0,3),Gl.bind(void 0,4),Gl.bind(void 0,5),Gl.bind(void 0,6),Gl.bind(void 0,7),Gl.bind(void 0,8),ur.bind(void 0,0,0,0,0,0),ur.bind(void 0,0,0,0,0,1),ur.bind(void 0,0,0,0,0,2),ur.bind(void 0,0,0,0,0,3),ur.bind(void 0,0,0,0,1,0),ur.bind(void 0,0,0,0,1,1),ur.bind(void 0,0,0,0,1,2),ur.bind(void 0,0,0,0,1,3),ur.bind(void 0,0,0,1,0,0),ur.bind(void 0,0,0,1,0,1),ur.bind(void 0,0,0,1,0,2),ur.bind(void 0,0,0,1,0,3),ur.bind(void 0,0,0,1,1,0),ur.bind(void 0,0,0,1,1,1),ur.bind(void 0,0,0,1,1,2),ur.bind(void 0,0,0,1,1,3),ur.bind(void 0,0,1,0,0,0),ur.bind(void 0,0,1,0,0,1),ur.bind(void 0,0,1,0,0,2),ur.bind(void 0,0,1,0,0,3),ur.bind(void 0,0,1,0,1,0),ur.bind(void 0,0,1,0,1,1),ur.bind(void 0,0,1,0,1,2),ur.bind(void 0,0,1,0,1,3),ur.bind(void 0,0,1,1,0,0),ur.bind(void 0,0,1,1,0,1),ur.bind(void 0,0,1,1,0,2),ur.bind(void 0,0,1,1,0,3),ur.bind(void 0,0,1,1,1,0),ur.bind(void 0,0,1,1,1,1),ur.bind(void 0,0,1,1,1,2),ur.bind(void 0,0,1,1,1,3),ur.bind(void 0,1,0,0,0,0),ur.bind(void 0,1,0,0,0,1),ur.bind(void 0,1,0,0,0,2),ur.bind(void 0,1,0,0,0,3),ur.bind(void 0,1,0,0,1,0),ur.bind(void 0,1,0,0,1,1),ur.bind(void 0,1,0,0,1,2),ur.bind(void 0,1,0,0,1,3),ur.bind(void 0,1,0,1,0,0),ur.bind(void 0,1,0,1,0,1),ur.bind(void 0,1,0,1,0,2),ur.bind(void 0,1,0,1,0,3),ur.bind(void 0,1,0,1,1,0),ur.bind(void 0,1,0,1,1,1),ur.bind(void 0,1,0,1,1,2),ur.bind(void 0,1,0,1,1,3),ur.bind(void 0,1,1,0,0,0),ur.bind(void 0,1,1,0,0,1),ur.bind(void 0,1,1,0,0,2),ur.bind(void 0,1,1,0,0,3),ur.bind(void 0,1,1,0,1,0),ur.bind(void 0,1,1,0,1,1),ur.bind(void 0,1,1,0,1,2),ur.bind(void 0,1,1,0,1,3),ur.bind(void 0,1,1,1,0,0),ur.bind(void 0,1,1,1,0,1),ur.bind(void 0,1,1,1,0,2),ur.bind(void 0,1,1,1,0,3),ur.bind(void 0,1,1,1,1,0),ur.bind(void 0,1,1,1,1,1),ur.bind(void 0,1,1,1,1,2),ur.bind(void 0,1,1,1,1,3)];var y7=cd;function ou(i){this.char=i,this.state={},this.activeState=null}function pp(i,o,u){this.contextName=u,this.startIndex=i,this.endOffset=o}function v7(i,o,u){this.contextName=i,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=u}function Ji(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 q0(i){this.eventId=i,this.subscribers=[]}function w7(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 f=o[h];Object.defineProperty(this.events,f,{value:new q0(f)})}if(i)for(let h=0;h<o.length;h++){let f=o[h],g=i[f];typeof g=="function"&&this.events[f].subscribe(g)}let u=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<u.length;h++){let f=u[h];this.events[f].subscribe(this.updateContextsRanges)}}function Ts(i){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],w7.call(this,i)}ou.prototype.setState=function(i,o){return this.state[i]=o,this.activeState={key:i,value:this.state[i]},this.activeState},ou.prototype.getState=function(i){return this.state[i]||null},Ts.prototype.inboundIndex=function(i){return i>=0&&i<this.tokens.length},Ts.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))])},Ts.prototype.replaceRange=function(i,o,u,h){o=o!==null?o:this.tokens.length;let f=u.every(g=>g instanceof ou);if(!isNaN(i)&&this.inboundIndex(i)&&f){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."}},Ts.prototype.replaceToken=function(i,o,u){if(!isNaN(i)&&this.inboundIndex(i)&&o instanceof ou){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."}},Ts.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},Ts.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."}},Ts.prototype.insertToken=function(i,o,u){return i.every(h=>h instanceof ou)?(this.tokens.splice.apply(this.tokens,[o,0].concat(i)),u||this.dispatch("insertToken",[i,o]),i):{FAIL:"insertToken: invalid token(s)."}},Ts.prototype.registerModifier=function(i,o,u){this.events.newToken.subscribe(function(h,f){let g=[h,f],A=o===null||o.apply(this,g)===!0,_=[h,f];if(A){let I=u.apply(this,_);h.setState(i,I)}}),this.registeredModifiers.push(i)},q0.prototype.subscribe=function(i){return typeof i=="function"?this.subscribers.push(i)-1:{FAIL:`invalid '${this.eventId}' event handler`}},q0.prototype.unsubscribe=function(i){this.subscribers.splice(i,1)},Ji.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)},Ji.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}},Ts.prototype.rangeToText=function(i){if(i instanceof pp)return this.getRangeTokens(i).map(o=>o.char).join("")},Ts.prototype.getText=function(){return this.tokens.map(i=>i.char).join("")},Ts.prototype.getContext=function(i){return this.registeredContexts[i]||null},Ts.prototype.on=function(i,o){let u=this.events[i];return u?u.subscribe(o):null},Ts.prototype.dispatch=function(i,o){let u=this.events[i];if(u instanceof q0)for(let h=0;h<u.subscribers.length;h++)u.subscribers[h].apply(this,o||[])},Ts.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 v7(i,o,u);return this.registeredContexts[i]=h,this.contextCheckers.push(h),h},Ts.prototype.getRangeTokens=function(i){let o=i.startIndex+i.endOffset;return[].concat(this.tokens.slice(i.startIndex,o))},Ts.prototype.getContextRanges=function(i){let o=this.getContext(i);return o?o.ranges:{FAIL:`context checker '${i}' is not registered.`}},Ts.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=[]}},Ts.prototype.updateContextsRanges=function(){this.resetContextsRanges();let i=this.tokens.map(o=>o.char);for(let o=0;o<i.length;o++){let u=new Ji(i,o);this.runContextCheck(u)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Ts.prototype.setEndOffset=function(i,o){let u=this.getContext(o).openRange.startIndex,h=new pp(u,i,o),f=this.getContext(o).ranges;return h.rangeId=`${o}.${f.length}`,f.push(h),this.getContext(o).openRange=null,h},Ts.prototype.runContextCheck=function(i){let o=i.index;for(let u=0;u<this.contextCheckers.length;u++){let h=this.contextCheckers[u],f=h.contextName,g=this.getContext(f).openRange;if(!g&&h.checkStart(i)&&(g=new pp(o,null,f),this.getContext(f).openRange=g,this.dispatch("contextStart",[f,o])),g&&h.checkEnd(i)){let A=o-g.startIndex+1,_=this.setEndOffset(A,f);this.dispatch("contextEnd",[f,_])}}},Ts.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],f=new Ji(o,u);this.dispatch("next",[f]),this.runContextCheck(f);let g=new ou(h);this.tokens.push(g),this.dispatch("newToken",[g,f])}return this.dispatch("end",[this.tokens]),this.tokens};var A7=Ts;function Vl(i){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(i)}function Ug(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 ql(i){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(i)}function Y0(i){return/[\u0E00-\u0E7F]/.test(i)}function Z0(i){return/[A-z]/.test(i)}function T7(i){return/\s/.test(i)}function Qa(i){this.font=i,this.features={}}function Yl(i){this.id=i.id,this.tag=i.tag,this.substitution=i.substitution}function Zl(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 f=u[h];if(i>=f.start&&i<=f.end){let g=i-f.start;return f.index+g}}break}default:return-1}return-1}function S7(i,o){return Zl(i,o.coverage)===-1?null:i+o.deltaGlyphId}function C7(i,o){let u=Zl(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 f=i[h],g=o.current;g=Array.isArray(g)?g[0]:g;let A=Zl(g,f);A!==-1&&u.push(A)}return u.length!==i.length?-1:u}function _7(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 f=o.inputCoverage.length-1;if(i.lookahead.length<o.lookaheadCoverage.length)return[];let g=i.lookahead.slice(f);for(;g.length&&ql(g[0].char);)g.shift();let A=new Ji(g,0),_=mp(o.lookaheadCoverage,A),I=[].concat(i.backtrack);for(I.reverse();I.length&&ql(I[0].char);)I.shift();if(I.length<o.backtrackCoverage.length)return[];let D=new Ji(I,0),M=mp(o.backtrackCoverage,D),te=h.length===o.inputCoverage.length&&_.length===o.lookaheadCoverage.length&&M.length===o.backtrackCoverage.length,J=[];if(te)for(let Te=0;Te<o.lookupRecords.length;Te++){let he=o.lookupRecords[Te],Re=he.lookupListIndex,ct=this.getLookupByIndex(Re);for(let mr=0;mr<ct.subtables.length;mr++){let lr=ct.subtables[mr],Rr,sn=this.getSubstitutionType(ct,lr);if(sn==="71"?(sn=this.getSubstitutionType(lr,lr.extension),Rr=this.getLookupMethod(lr,lr.extension),lr=lr.extension):Rr=this.getLookupMethod(ct,lr),sn==="12"){let On=i.get(he.sequenceIndex),Yn=Rr(On);Yn&&J.push(Yn)}else if(sn==="21"){let On=i.get(he.sequenceIndex),Yn=Rr(On);Yn&&J.push(Yn)}else throw new Error(`Substitution type ${sn} is not supported in chaining substitution`)}}return J}function k7(i,o){let u=i.current,h=Zl(u,o.coverage);if(h===-1)return null;let f,g=o.ligatureSets[h];for(let A=0;A<g.length;A++){f=g[A];for(let _=0;_<f.components.length;_++){let I=i.lookahead[_],D=f.components[_];if(I!==D)break;if(_===f.components.length-1)return f}}return null}function L7(i,o){let u=i.current;if(Zl(u,o.coverage)===-1)return null;for(let h of o.ruleSets)for(let f of h){let g=!0;for(let A=0;A<f.input.length;A++)if(i.lookahead[A]!==f.input[A]){g=!1;break}if(g){let A=[];A.push(u);for(let I=0;I<f.input.length;I++)A.push(f.input[I]);let _=(I,D)=>{let{lookupListIndex:M,sequenceIndex:te}=D,{subtables:J}=this.getLookupByIndex(M);for(let Te of J)Zl(I[te],Te.coverage)!==-1&&(I[te]=Te.deltaGlyphId)};for(let I=0;I<f.lookupRecords.length;I++){let D=f.lookupRecords[I];_(A,D)}return A}}return null}function I7(i,o){if(i.context.length<o.coverages.length)return[];for(let h=0;h<o.coverages.length;h++){let f=i.get(h);if(f=Array.isArray(f)?f[0]:f,Zl(f,o.coverages[h])===-1)return[]}let u=[];for(let h=0;h<o.lookupRecords.length;h++){let f=o.lookupRecords[h],g=f.lookupListIndex,A=this.getLookupByIndex(g);for(let _=0;_<A.subtables.length;_++){let I=A.subtables[_],D,M=this.getSubstitutionType(A,I);if(M==="71"?(M=this.getSubstitutionType(I,I.extension),D=this.getLookupMethod(I,I.extension),I=I.extension):D=this.getLookupMethod(A,I),M==="12"){let te=i.get(f.sequenceIndex),J=D(te);J&&u.push(J)}else if(M==="21"){let te=i.get(f.sequenceIndex),J=D(te);J&&u.push(J)}}}return u}function E7(i,o){let u=Zl(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 f=h.langSysRecords;if(f)for(let g=0;g<f.length;g++){let A=f[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 f=i[h].tag,g=i[h].feature;u[f]=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(f=>h.features[f]),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=>S7.apply(this,[h,o]);case"12":return h=>C7.apply(this,[h,o]);case"63":return h=>_7.apply(this,[h,o]);case"41":return h=>k7.apply(this,[h,o]);case"21":return h=>E7.apply(this,[h,o]);case"51":return h=>L7.apply(this,[h,o]);case"53":return h=>I7.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 f=this.getFeatureLookups(h),g=[].concat(o.context);for(let A=0;A<f.length;A++){let _=f[A],I=this.getLookupSubtables(_);for(let D=0;D<I.length;D++){let M=I[D],te=this.getSubstitutionType(_,M),J;te==="71"?(te=this.getSubstitutionType(M,M.extension),J=this.getLookupMethod(M,M.extension),M=M.extension):J=this.getLookupMethod(_,M);let Te;switch(te){case"11":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:11,tag:i.tag,substitution:Te}));break;case"12":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:12,tag:i.tag,substitution:Te}));break;case"63":Te=J(o),Array.isArray(Te)&&Te.length&&g.splice(u,1,new Yl({id:63,tag:i.tag,substitution:Te}));break;case"41":Te=J(o),Te&&g.splice(u,1,new Yl({id:41,tag:i.tag,substitution:Te}));break;case"21":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:21,tag:i.tag,substitution:Te}));break;case"51":case"53":Te=J(o),Array.isArray(Te)&&Te.length&&g.splice(u,1,new Yl({id:parseInt(te),tag:i.tag,substitution:Te}));break}o=new Ji(g,u),!(Array.isArray(Te)&&!Te.length)&&(Te=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 N7=Qa;function R7(i){let o=i.current,u=i.get(-1);return u===null&&Vl(o)||!Vl(u)&&Vl(o)}function M7(i){let o=i.get(1);return o===null||!Vl(o)}var j7={startCheck:R7,endCheck:M7};function D7(i){let o=i.current,u=i.get(-1);return(Vl(o)||ql(o))&&!Vl(u)}function B7(i){let o=i.get(1);switch(!0){case o===null:return!0;case(!Vl(o)&&!ql(o)):{let u=T7(o);if(!u)return!0;if(u){let h=!1;if(h=i.lookahead.some(f=>Vl(f)||ql(f)),!h)return!0}break}default:return!1}}var Q7={startCheck:D7,endCheck:B7};function P7(i,o,u){o[u].setState(i.tag,i.substitution)}function O7(i,o,u){o[u].setState(i.tag,i.substitution)}function gp(i,o,u){for(let h=0;h<i.substitution.length;h++){let f=i.substitution[h],g=o[u+h];if(Array.isArray(f)){f.length?g.setState(i.tag,f[0]):g.setState("deleted",!0);continue}g.setState(i.tag,f)}}function F7(i,o,u){let h=o[u];h.setState(i.tag,i.substitution.ligGlyph);let f=i.substitution.components.length;for(let g=0;g<f;g++)h=o[u+g+1],h.setState("deleted",!0)}var zg={11:P7,12:O7,63:gp,41:F7,51:gp,53:gp};function $7(i,o,u){i instanceof Yl&&zg[i.id]&&zg[i.id](i,o,u)}var vc=$7;function U7(i){let o=[].concat(i.backtrack);for(let u=o.length-1;u>=0;u--){let h=o[u],f=Ug(h),g=ql(h);if(!f&&!g)return!0;if(f)return!1}return!1}function z7(i){if(Ug(i.current))return!1;for(let o=0;o<i.lookahead.length;o++){let u=i.lookahead[o];if(!ql(u))return!0}return!1}function H7(i){let o="arab",u=this.featuresTags[o],h=this.tokenizer.getRangeTokens(i);if(h.length===1)return;let f=new Ji(h.map(A=>A.getState("glyphIndex")),0),g=new Ji(h.map(A=>A.char),0);for(let A=0;A<h.length;A++){let _=h[A];if(ql(_.char))continue;f.setCurrentIndex(A),g.setCurrentIndex(A);let I=0;U7(g)&&(I|=1),z7(g)&&(I|=2);let D;switch(I){case 1:D="fina";break;case 2:D="init";break;case 3:D="medi";break}if(u.indexOf(D)===-1)continue;let M=this.query.lookupFeature({tag:D,script:o,contextParams:f});if(M instanceof Error){console.info(M.message);continue}for(let te=0;te<M.length;te++){let J=M[te];J instanceof Yl&&(vc(J,h,te),f.context[te]=J.substitution)}}}var W7=H7;function Hg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function G7(i){let o="arab",u=this.tokenizer.getRangeTokens(i),h=Hg(u);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let _=g[A];vc(_,u,f)}h=Hg(u)}}}var V7=G7;function q7(i){return i.index===0&&i.context.length>1}function Y7(i){return i.index===i.context.length-1}var Z7={startCheck:q7,endCheck:Y7};function Wg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function K7(i){let o="delf",u="ccmp",h=this.tokenizer.getRangeTokens(i),f=Wg(h);for(let g=0;g<f.context.length;g++){if(!this.query.getFeature({tag:u,script:o,contextParams:f}))continue;f.setCurrentIndex(g);let A=this.query.lookupFeature({tag:u,script:o,contextParams:f});if(A.length){for(let _=0;_<A.length;_++){let I=A[_];vc(I,h,g)}f=Wg(h)}}}var X7=K7;function J7(i){let o=i.current,u=i.get(-1);return u===null&&Z0(o)||!Z0(u)&&Z0(o)}function ew(i){let o=i.get(1);return o===null||!Z0(o)}var tw={startCheck:J7,endCheck:ew};function Gg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function rw(i){let o="latn",u=this.tokenizer.getRangeTokens(i),h=Gg(u);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let _=g[A];vc(_,u,f)}h=Gg(u)}}}var nw=rw;function sw(i){let o=i.current,u=i.get(-1);return u===null&&Y0(o)||!Y0(u)&&Y0(o)}function iw(i){let o=i.get(1);return o===null||!Y0(o)}var aw={startCheck:sw,endCheck:iw};function Vg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function ow(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Vg(u,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"ccmp",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let _=g[A];vc(_,u,f)}h=Vg(u,f)}}}var lw=ow;function qg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function cw(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=qg(u,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let _=g[A];vc(_,u,f)}h=qg(u,f)}}}var uw=cw;function Yg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function dw(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Yg(u,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let _=g[A];vc(_,u,f)}h=Yg(u,f)}}}var hw=dw;function xp(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 fw(i){let o=i.current,u=i.get(1);return u===null&&xp(o)||xp(u)}function pw(i){let o=i.get(1);return o===null||!xp(o)}var mw={startCheck:fw,endCheck:pw};function gw(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),f=u[1].char.codePointAt(0),g=o.tables.cmap.varSelectorList[f];if(g!==void 0&&g.nonDefaultUVS){let A=g.nonDefaultUVS.uvsMappings;if(A[h]){let _=A[h].glyphID;o.glyphs.glyphs[_]!==void 0&&u[0].setState("glyphIndex",_)}}}}var xw=gw;function ro(i){this.baseDir=i||"ltr",this.tokenizer=new A7,this.featuresTags={}}ro.prototype.setText=function(i){this.text=i},ro.prototype.contextChecks={ccmpReplacementCheck:Z7,latinWordCheck:tw,arabicWordCheck:j7,arabicSentenceCheck:Q7,thaiWordCheck:aw,unicodeVariationSequenceCheck:mw};function lu(i){let o=this.contextChecks[`${i}Check`];return this.tokenizer.registerContextChecker(i,o.startCheck,o.endCheck)}function bw(){return lu.call(this,"ccmpReplacement"),lu.call(this,"latinWord"),lu.call(this,"arabicWord"),lu.call(this,"arabicSentence"),lu.call(this,"thaiWord"),lu.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function yw(){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())}}ro.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},ro.prototype.applyFeatures=function(i,o){if(!i)throw new Error("No valid font was provided to apply features");this.query||(this.query=new N7(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)}},ro.prototype.registerModifier=function(i,o,u){this.tokenizer.registerModifier(i,o,u)};function hd(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function vw(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;hd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];W7.call(this,u)}}function ww(){hd.call(this);let i=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<i.length;o++){let u=i[o];X7.call(this,u)}}function Aw(){if(!this.hasFeatureEnabled("arab","rlig"))return;hd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];V7.call(this,u)}}function Tw(){if(!this.hasFeatureEnabled("latn","liga"))return;hd.call(this);let i=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<i.length;o++){let u=i[o];nw.call(this,u)}}function Sw(){let i=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<i.length;o++){let u=i[o];xw.call(this,u)}}function Cw(){hd.call(this);let i=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<i.length;o++){let u=i[o];this.hasFeatureEnabled("thai","liga")&&uw.call(this,u),this.hasFeatureEnabled("thai","rlig")&&hw.call(this,u),this.hasFeatureEnabled("thai","ccmp")&&lw.call(this,u)}}ro.prototype.checkContextReady=function(i){return!!this.tokenizer.getContext(i)},ro.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&ww.call(this),this.checkContextReady("arabicWord")&&(vw.call(this),Aw.call(this)),this.checkContextReady("latinWord")&&Tw.call(this),this.checkContextReady("arabicSentence")&&yw.call(this),this.checkContextReady("thaiWord")&&Cw.call(this),this.checkContextReady("unicodeVariationSequence")&&Sw.call(this)},ro.prototype.hasFeatureEnabled=function(i,o){return(this.featuresTags[i]||[]).indexOf(o)!==-1},ro.prototype.processText=function(i){(!this.text||this.text!==i)&&(this.setText(i),bw.call(this),this.applyFeaturesToContexts())},ro.prototype.getBidiText=function(i){return this.processText(i),this.tokenizer.getText()},ro.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 f=h.activeState.value;o.push(Array.isArray(f)?f[0]:f)}return o};var _w=ro;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 Wn(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 Wr.GlyphSet(this,i.glyphs||[]),this.encoding=new en(this),this.position=new pc(this),this.substitution=new Ja(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 od(this)),!0)}),this.palettes=new ba(this),this.layers=new Pl(this),this.svgImages=new ru(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new y7(this):null}})}Wn.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)>0},Wn.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},Wn.prototype.charToGlyph=function(i){let o=this.charToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Wn.prototype.updateFeatures=function(i){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(u=>i[u])}:o)},Wn.prototype.stringToGlyphIndexes=function(i,o){let u=new _w,h=g=>this.charToGlyphIndex(g.char);u.registerModifier("glyphIndex",null,h);let f=o?this.updateFeatures(o.features):this.defaultRenderOptions.features;return u.applyFeatures(this,f),u.getTextGlyphs(i)},Wn.prototype.stringToGlyphs=function(i,o){let u=this.stringToGlyphIndexes(i,o),h=u.length,f=new Array(h),g=this.glyphs.get(0);for(let A=0;A<h;A+=1)f[A]=this.glyphs.get(u[A])||g;return f},Wn.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},Wn.prototype.nameToGlyph=function(i){let o=this.nameToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Wn.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},Wn.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},Wn.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},Wn.prototype.forEachGlyph=function(i,o,u,h,f,g){o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:72,f=Object.assign({},this.defaultRenderOptions,f);let A=1/this.unitsPerEm*h,_=this.stringToGlyphs(i,f),I;if(f.kerning){let D=f.script||this.position.getDefaultScriptName();I=this.position.getKerningTables(D,f.language)}for(let D=0;D<_.length;D+=1){let M=_[D];if(g.call(this,M,o,u,h,f),M.advanceWidth&&(o+=M.advanceWidth*A),f.kerning&&D<_.length-1){let te=I?this.position.getKerningValue(I,M.index,_[D+1].index):this.getKerningValue(M,_[D+1]);o+=te*A}f.letterSpacing?o+=f.letterSpacing*h:f.tracking&&(o+=f.tracking/1e3*h)}return o},Wn.prototype.getPath=function(i,o,u,h,f){f=Object.assign({},this.defaultRenderOptions,f);let g=new We;if(g._layers=[],zn(this,g,h),g.stroke){let A=1/(g.unitsPerEm||1e3)*h;g.strokeWidth*=A}return this.forEachGlyph(i,o,u,h,f,(A,_,I,D)=>{let M=A.getPath(_,I,D,f,this);if(f.drawSVG||f.drawLayers){let te=M._layers;if(te&&te.length){for(let J=0;J<te.length;J++){let Te=te[J];g._layers.push(Te)}return}}g.extend(M)}),g},Wn.prototype.getPaths=function(i,o,u,h,f){f=Object.assign({},this.defaultRenderOptions,f);let g=[];return this.forEachGlyph(i,o,u,h,f,function(A,_,I,D){let M=A.getPath(_,I,D,f,this);g.push(M)}),g},Wn.prototype.getAdvanceWidth=function(i,o,u){return u=Object.assign({},this.defaultRenderOptions,u),this.forEachGlyph(i,0,0,o,u,function(){})},Wn.prototype.draw=function(i,o,u,h,f,g){this.getPath(o,u,h,f,g).draw(i)},Wn.prototype.drawPoints=function(i,o,u,h,f,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,f,g,function(A,_,I,D){A.drawPoints(i,_,I,D,g,this)})},Wn.prototype.drawMetrics=function(i,o,u,h,f,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,f,g,function(A,_,I,D){A.drawMetrics(i,_,I,D)})},Wn.prototype.getEnglishName=function(i){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[i];if(o)return o.en},Wn.prototype.validate=function(){let i=[],o=this;function u(f,g){f||(console.warn(`[opentype.js] ${g}`),i.push(g))}function h(f){let g=o.getEnglishName(f);u(g&&g.trim().length>0,"No English "+f+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),u(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let f=this.tables.colr.baseGlyphRecords,g=-1;for(let A=0;A<f.length;A++){let _=f[A].glyphID;if(u(g<f[A].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${_} comes after ${g}`),g>f[A].glyphID)break;g=_}}return i},Wn.prototype.toTables=function(){return $r.fontToTable(this)},Wn.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Wn.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},Wn.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Wn.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Wn.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Wn.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},Wn.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Zg=Wn;function kw(i,o){let u=new ot.Parser(i,o),h=u.parseUShort(),f=u.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${f}`);let g=[h,f],A=u.parsePointer32(function(){return this.parseItemVariationStore()}),_=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),I=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),D=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:g,itemVariationStore:A,advanceWidth:_,lsb:I,rsb:D}}function Lw(){console.warn("Writing of hvar tables is not yet supported.")}var Iw={make:Lw,parse:kw},Ew=function(){return{coverage:this.parsePointer(me.coverage),attachPoints:this.parseList(me.pointer(me.uShortList))}},Nw=function(){var i=this.parseUShort();if(ue.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()}},Rw=function(){return this.parseList(me.pointer(Nw))},Mw=function(){return{coverage:this.parsePointer(me.coverage),ligGlyphs:this.parseList(me.pointer(Rw))}},jw=function(){return this.parseUShort(),this.parseList(me.pointer(me.coverage))};function Dw(i,o){o=o||0;let u=new me(i,o),h=u.parseVersion(1);ue.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var f={version:h,classDef:u.parsePointer(me.classDef),attachList:u.parsePointer(Ew),ligCaretList:u.parsePointer(Mw),markAttachClassDef:u.parsePointer(me.classDef)};return h>=1.2&&(f.markGlyphSets=u.parsePointer(jw)),f}var Bw={parse:Dw},No=new Array(10);No[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{posFormat:1,coverage:this.parsePointer(me.coverage),value:this.parseValueRecord()};if(o===2)return{posFormat:2,coverage:this.parsePointer(me.coverage),values:this.parseValueRecordList()};ue.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},No[2]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();ue.assert(o===1||o===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let u=this.parsePointer(me.coverage),h=this.parseUShort(),f=this.parseUShort();if(o===1)return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:f,pairSets:this.parseList(me.pointer(me.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(h),value2:this.parseValueRecord(f)}})))};if(o===2){let g=this.parsePointer(me.classDef),A=this.parsePointer(me.classDef),_=this.parseUShort(),I=this.parseUShort();return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:f,classDef1:g,classDef2:A,class1Count:_,class2Count:I,classRecords:this.parseList(_,me.list(I,function(){return{value1:this.parseValueRecord(h),value2:this.parseValueRecord(f)}}))}}},No[3]=function(){return{error:"GPOS Lookup 3 not supported"}},No[4]=function(){return{error:"GPOS Lookup 4 not supported"}},No[5]=function(){return{error:"GPOS Lookup 5 not supported"}},No[6]=function(){return{error:"GPOS Lookup 6 not supported"}},No[7]=function(){return{error:"GPOS Lookup 7 not supported"}},No[8]=function(){return{error:"GPOS Lookup 8 not supported"}},No[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Qw(i,o){o=o||0;let u=new me(i,o),h=u.parseVersion(1);return ue.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(No)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(No),variations:u.parseFeatureVariationsList()}}var Pw=new Array(10);function Ow(i){return new De.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new De.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new De.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new De.LookupList(i.lookups,Pw)}])}var Fw={parse:Qw,make:Ow};function $w(i){let o={};i.skip("uShort");let u=i.parseUShort();ue.argument(u===0,"Unsupported kern sub-table version."),i.skip("uShort",2);let h=i.parseUShort();i.skip("uShort",3);for(let f=0;f<h;f+=1){let g=i.parseUShort(),A=i.parseUShort(),_=i.parseShort();o[g+","+A]=_}return o}function Uw(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 f=0;f<h;f+=1){let g=i.parseUShort(),A=i.parseUShort(),_=i.parseShort();o[g+","+A]=_}}return o}function zw(i,o){let u=new ot.Parser(i,o),h=u.parseUShort();if(h===0)return $w(u);if(h===1)return Uw(u);throw new Error("Unsupported kern table version ("+h+").")}var Hw={parse:zw};function Ww(i,o,u,h){let f=new ot.Parser(i,o),g=h?f.parseUShort:f.parseULong,A=[];for(let _=0;_<u+1;_+=1){let I=g.call(f);h&&(I*=2),A.push(I)}return A}var Gw={parse:Ww};function Kg(i,o){let u=[],h=12;for(let f=0;f<o;f+=1){let g=ot.getTag(i,h),A=ot.getULong(i,h+4),_=ot.getULong(i,h+8),I=ot.getULong(i,h+12);u.push({tag:g,checksum:A,offset:_,length:I,compression:!1}),h+=16}return u}function Vw(i,o){let u=[],h=44;for(let f=0;f<o;f+=1){let g=ot.getTag(i,h),A=ot.getULong(i,h+4),_=ot.getULong(i,h+8),I=ot.getULong(i,h+12),D;_<I?D="WOFF":D=!1,u.push({tag:g,offset:A,compression:D,compressedLength:_,length:I}),h+=20}return u}function Rn(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 qw(i,o={}){let u,h,f=new Zg({empty:!0});i.constructor!==ArrayBuffer&&(i=new Uint8Array(i).buffer);let g=new DataView(i,0),A,_=[],I=ot.getTag(g,0);if(I==="\0\0\0"||I==="true"||I==="typ1")f.outlinesFormat="truetype",A=ot.getUShort(g,4),_=Kg(g,A);else if(I==="OTTO")f.outlinesFormat="cff",A=ot.getUShort(g,4),_=Kg(g,A);else if(I==="wOFF"){let gr=ot.getTag(g,4);if(gr==="\0\0\0")f.outlinesFormat="truetype";else if(gr==="OTTO")f.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+I);A=ot.getUShort(g,12),_=Vw(g,A)}else if(I==="wOF2"){let gr="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+gr)}else throw new Error("Unsupported OpenType signature "+I);let D,M,te,J,Te,he,Re,ct,mr,lr,Rr,sn,On,Yn,Zn,Qs,Ro,an;for(let gr=0;gr<A;gr+=1){let sr=_[gr],ar;switch(sr.tag){case"avar":Re=sr;break;case"cmap":ar=Rn(g,sr),f.tables.cmap=Mr.parse(ar.data,ar.offset),f.encoding=new xn(f.tables.cmap);break;case"cvt ":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),f.tables.cvt=an.parseShortList(sr.length/2);break;case"fvar":te=sr;break;case"STAT":J=sr;break;case"gvar":Te=sr;break;case"cvar":he=sr;break;case"fpgm":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),f.tables.fpgm=an.parseByteList(sr.length);break;case"head":ar=Rn(g,sr),f.tables.head=ei.parse(ar.data,ar.offset),f.unitsPerEm=f.tables.head.unitsPerEm,u=f.tables.head.indexToLocFormat;break;case"hhea":ar=Rn(g,sr),f.tables.hhea=Is.parse(ar.data,ar.offset),f.ascender=f.tables.hhea.ascender,f.descender=f.tables.hhea.descender,f.numberOfHMetrics=f.tables.hhea.numberOfHMetrics;break;case"HVAR":On=sr;break;case"hmtx":sn=sr;break;case"ltag":ar=Rn(g,sr),h=bi.parse(ar.data,ar.offset);break;case"COLR":ar=Rn(g,sr),f.tables.colr=qi.parse(ar.data,ar.offset);break;case"CPAL":ar=Rn(g,sr),f.tables.cpal=Jn.parse(ar.data,ar.offset);break;case"maxp":ar=Rn(g,sr),f.tables.maxp=Uo.parse(ar.data,ar.offset),f.numGlyphs=f.tables.maxp.numGlyphs;break;case"name":Qs=sr;break;case"OS/2":ar=Rn(g,sr),f.tables.os2=js.parse(ar.data,ar.offset);break;case"post":ar=Rn(g,sr),f.tables.post=Dl.parse(ar.data,ar.offset),f.glyphNames=new He(f.tables.post);break;case"prep":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),f.tables.prep=an.parseByteList(sr.length);break;case"glyf":ct=sr;break;case"loca":Zn=sr;break;case"CFF ":D=sr;break;case"CFF2":M=sr;break;case"kern":Yn=sr;break;case"GDEF":mr=sr;break;case"GPOS":lr=sr;break;case"GSUB":Rr=sr;break;case"meta":Ro=sr;break;case"gasp":try{ar=Rn(g,sr),f.tables.gasp=T.parse(ar.data,ar.offset)}catch(Pi){console.warn("Failed to parse gasp table, skipping."),console.warn(Pi)}break;case"SVG ":ar=Rn(g,sr),f.tables.svg=F.parse(ar.data,ar.offset);break;default:break}}let Pa=Rn(g,Qs);if(f.tables.name=Mt.parse(Pa.data,Pa.offset,h),f.names=f.tables.name,ct&&Zn){let gr=u===0,sr=Rn(g,Zn),ar=Gw.parse(sr.data,sr.offset,f.numGlyphs,gr),Pi=Rn(g,ct);f.glyphs=Ol.parse(Pi.data,Pi.offset,ar,f,o)}else if(D){let gr=Rn(g,D);as.parse(gr.data,gr.offset,f,o)}else if(M){let gr=Rn(g,M);as.parse(gr.data,gr.offset,f,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let ea=Rn(g,sn);if(Ms.parse(f,ea.data,ea.offset,f.numberOfHMetrics,f.numGlyphs,f.glyphs,o),tr(f,o),Yn){let gr=Rn(g,Yn);f.kerningPairs=Hw.parse(gr.data,gr.offset)}else f.kerningPairs={};if(mr){let gr=Rn(g,mr);f.tables.gdef=Bw.parse(gr.data,gr.offset)}if(lr){let gr=Rn(g,lr);f.tables.gpos=Fw.parse(gr.data,gr.offset),f.position.init()}if(Rr){let gr=Rn(g,Rr);f.tables.gsub=Mi.parse(gr.data,gr.offset)}if(te){let gr=Rn(g,te);f.tables.fvar=ri.parse(gr.data,gr.offset,f.names)}if(J){let gr=Rn(g,J);f.tables.stat=As.parse(gr.data,gr.offset,f.tables.fvar)}if(Te){te||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),ct||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let gr=Rn(g,Te);f.tables.gvar=Zi.parse(gr.data,gr.offset,f.tables.fvar,f.glyphs)}if(he){te||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),f.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),ct||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let gr=Rn(g,he);f.tables.cvar=xa.parse(gr.data,gr.offset,f.tables.fvar,f.tables.cvt||[])}if(Re){te||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let gr=Rn(g,Re);f.tables.avar=ga.parse(gr.data,gr.offset,f.tables.fvar)}if(On){te||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),sn||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let gr=Rn(g,On);f.tables.hvar=Iw.parse(gr.data,gr.offset,f.tables.fvar)}if(Ro){let gr=Rn(g,Ro);f.tables.meta=Ws.parse(gr.data,gr.offset),f.metas=f.tables.meta}return f.palettes=new ba(f),f}function Yw(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function Zw(){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}))}),sL=rL(nL()),Li=ku("lru-cache:metrics"),Jd=Vk("lru-cache"),iL=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$p=()=>Li.hasSubscribers||Jd.hasSubscribers,$3=new Set,e2=typeof process=="object"&&process?process:{},aL=(e,t,r,n)=>{typeof e2.emitWarning=="function"?e2.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},oL=e=>!$3.has(e),ic=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),U3=e=>ic(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Wh:null:null,Wh=class extends Array{constructor(e){super(e),this.fill(0)}},Ic,vd,lL=(Ic=class{constructor(e,t){if(Ys(this,"heap"),Ys(this,"length"),!ie(Ic,vd))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=U3(e);if(!t)return[];Ir(Ic,vd,!0);let r=new Ic(e,t);return Ir(Ic,vd,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},vd=new WeakMap,vn(Ic,vd,!1),Ic),t2,r2,Do,ao,Ko,fu,Xo,wd,Ad,Jo,ii,oo,qs,xs,Kr,Aa,lo,sa,Si,el,Ci,tl,rl,co,uo,nl,Td,Ta,pu,Ft,Up,mu,Xl,lh,ho,n2,gu,Sd,ch,Jl,ec,zp,xu,uh,s2,i2,dh,rs,Hp,a2,o2,Cd,Wp,_d,tc,Gp,Vp,cL=(Vp=class{constructor(e){vn(this,Ft),vn(this,Do),vn(this,ao),vn(this,Ko),vn(this,fu),vn(this,Xo),vn(this,wd),vn(this,Ad),vn(this,Jo),Ys(this,"ttl"),Ys(this,"ttlResolution"),Ys(this,"ttlAutopurge"),Ys(this,"updateAgeOnGet"),Ys(this,"updateAgeOnHas"),Ys(this,"allowStale"),Ys(this,"noDisposeOnSet"),Ys(this,"noUpdateTTL"),Ys(this,"maxEntrySize"),Ys(this,"sizeCalculation"),Ys(this,"noDeleteOnFetchRejection"),Ys(this,"noDeleteOnStaleGet"),Ys(this,"allowStaleOnFetchAbort"),Ys(this,"allowStaleOnFetchRejection"),Ys(this,"ignoreFetchAbort"),Ys(this,"backgroundFetchSize"),vn(this,ii),vn(this,oo),vn(this,qs),vn(this,xs),vn(this,Kr),vn(this,Aa),vn(this,lo),vn(this,sa),vn(this,Si),vn(this,el),vn(this,Ci),vn(this,tl),vn(this,rl),vn(this,co),vn(this,uo),vn(this,nl),vn(this,Td),vn(this,Ta),vn(this,pu),vn(this,mu,()=>{}),vn(this,Xl,()=>{}),vn(this,lh,()=>{}),vn(this,ho,()=>!1),vn(this,gu,pe=>{}),vn(this,Sd,(pe,ee,_e)=>{}),vn(this,ch,(pe,ee,_e,ze)=>{if(_e||ze)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),Ys(this,t2,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:c,updateAgeOnHas:l,allowStale:d,dispose:p,onInsert:m,disposeAfter:x,noDisposeOnSet:y,noUpdateTTL:w,maxSize:v=0,maxEntrySize:S=0,sizeCalculation:L,fetchMethod:E,memoMethod:R,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:z,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:$,ignoreFetchAbort:V,backgroundFetchSize:Z=1,perf:le}=e;if(this.backgroundFetchSize=Z,le!==void 0&&typeof le?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(Ir(this,Jo,le??iL),t!==0&&!ic(t))throw new TypeError("max option must be a nonnegative integer");let be=t?U3(t):Array;if(!be)throw new Error("invalid max value: "+t);if(Ir(this,Do,t),Ir(this,ao,v),this.maxEntrySize=S||ie(this,ao),this.sizeCalculation=L,this.sizeCalculation){if(!ie(this,ao)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(Ir(this,Ad,R),E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(Ir(this,wd,E),Ir(this,Td,!!E),Ir(this,qs,new Map),Ir(this,xs,Array.from({length:t}).fill(void 0)),Ir(this,Kr,Array.from({length:t}).fill(void 0)),Ir(this,Aa,new be(t)),Ir(this,lo,new be(t)),Ir(this,sa,0),Ir(this,Si,0),Ir(this,el,lL.create(t)),Ir(this,ii,0),Ir(this,oo,0),typeof p=="function"&&Ir(this,Ko,p),typeof m=="function"&&Ir(this,fu,m),typeof x=="function"?(Ir(this,Xo,x),Ir(this,Ci,[])):(Ir(this,Xo,void 0),Ir(this,Ci,void 0)),Ir(this,nl,!!ie(this,Ko)),Ir(this,pu,!!ie(this,fu)),Ir(this,Ta,!!ie(this,Xo)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!V,this.maxEntrySize!==0){if(ie(this,ao)!==0&&!ic(ie(this,ao)))throw new TypeError("maxSize must be a positive integer if specified");if(!ic(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Ht(this,Ft,n2).call(this)}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!z,this.updateAgeOnGet=!!c,this.updateAgeOnHas=!!l,this.ttlResolution=ic(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!ic(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Ht(this,Ft,Up).call(this)}if(ie(this,Do)===0&&this.ttl===0&&ie(this,ao)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ie(this,Do)&&!ie(this,ao)){let pe="LRU_CACHE_UNBOUNDED";oL(pe)&&($3.add(pe),aL("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",pe,Vp))}}get perf(){return ie(this,Jo)}static unsafeExposeInternals(e){return{starts:ie(e,rl),ttls:ie(e,co),autopurgeTimers:ie(e,uo),sizes:ie(e,tl),keyMap:ie(e,qs),keyList:ie(e,xs),valList:ie(e,Kr),next:ie(e,Aa),prev:ie(e,lo),get head(){return ie(e,sa)},get tail(){return ie(e,Si)},free:ie(e,el),isBackgroundFetch:t=>{var r;return Ht(r=e,Ft,rs).call(r,t)},backgroundFetch:(t,r,n,a)=>{var c;return Ht(c=e,Ft,dh).call(c,t,r,n,a)},moveToTail:t=>{var r;return Ht(r=e,Ft,_d).call(r,t)},indexes:t=>{var r;return Ht(r=e,Ft,Jl).call(r,t)},rindexes:t=>{var r;return Ht(r=e,Ft,ec).call(r,t)},isStale:t=>{var r;return ie(r=e,ho).call(r,t)}}}get max(){return ie(this,Do)}get maxSize(){return ie(this,ao)}get calculatedSize(){return ie(this,oo)}get size(){return ie(this,ii)}get fetchMethod(){return ie(this,wd)}get memoMethod(){return ie(this,Ad)}get dispose(){return ie(this,Ko)}get onInsert(){return ie(this,fu)}get disposeAfter(){return ie(this,Xo)}getRemainingTTL(e){return ie(this,qs).has(e)?1/0:0}*entries(){for(let e of Ht(this,Ft,Jl).call(this))ie(this,Kr)[e]!==void 0&&ie(this,xs)[e]!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield[ie(this,xs)[e],ie(this,Kr)[e]])}*rentries(){for(let e of Ht(this,Ft,ec).call(this))ie(this,Kr)[e]!==void 0&&ie(this,xs)[e]!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield[ie(this,xs)[e],ie(this,Kr)[e]])}*keys(){for(let e of Ht(this,Ft,Jl).call(this)){let t=ie(this,xs)[e];t!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield t)}}*rkeys(){for(let e of Ht(this,Ft,ec).call(this)){let t=ie(this,xs)[e];t!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield t)}}*values(){for(let e of Ht(this,Ft,Jl).call(this))ie(this,Kr)[e]!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}*rvalues(){for(let e of Ht(this,Ft,ec).call(this))ie(this,Kr)[e]!==void 0&&!Ht(this,Ft,rs).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}[(r2=Symbol.iterator,t2=Symbol.toStringTag,r2)](){return this.entries()}find(e,t={}){for(let r of Ht(this,Ft,Jl).call(this)){let n=ie(this,Kr)[r],a=Ht(this,Ft,rs).call(this,n)?n.__staleWhileFetching:n;if(a!==void 0&&e(a,ie(this,xs)[r],this))return Ht(this,Ft,Cd).call(this,ie(this,xs)[r],t)}}forEach(e,t=this){for(let r of Ht(this,Ft,Jl).call(this)){let n=ie(this,Kr)[r],a=Ht(this,Ft,rs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,xs)[r],this)}}rforEach(e,t=this){for(let r of Ht(this,Ft,ec).call(this)){let n=ie(this,Kr)[r],a=Ht(this,Ft,rs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,xs)[r],this)}}purgeStale(){let e=!1;for(let t of Ht(this,Ft,ec).call(this,{allowStale:!0}))ie(this,ho).call(this,t)&&(Ht(this,Ft,tc).call(this,ie(this,xs)[t],"expire"),e=!0);return e}info(e){let t=ie(this,qs).get(e);if(t===void 0)return;let r=ie(this,Kr)[t],n=Ht(this,Ft,rs).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let a={value:n};if(ie(this,co)&&ie(this,rl)){let c=ie(this,co)[t],l=ie(this,rl)[t];if(c&&l){let d=c-(ie(this,Jo).now()-l);a.ttl=d,a.start=Date.now()}}return ie(this,tl)&&(a.size=ie(this,tl)[t]),a}dump(){let e=[];for(let t of Ht(this,Ft,Jl).call(this,{allowStale:!0})){let r=ie(this,xs)[t],n=ie(this,Kr)[t],a=Ht(this,Ft,rs).call(this,n)?n.__staleWhileFetching:n;if(a===void 0||r===void 0)continue;let c={value:a};if(ie(this,co)&&ie(this,rl)){c.ttl=ie(this,co)[t];let l=ie(this,Jo).now()-ie(this,rl)[t];c.start=Math.floor(Date.now()-l)}ie(this,tl)&&(c.size=ie(this,tl)[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=ie(this,Jo).now()-n}Ht(this,Ft,xu).call(this,t,r.value,r)}}set(e,t,r={}){let{status:n=Li.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=Ht(this,Ft,xu).call(this,e,t,r);return n&&Li.hasSubscribers&&Li.publish(n),a}pop(){var e;try{for(;ie(this,ii);){let t=ie(this,Kr)[ie(this,sa)];if(Ht(this,Ft,uh).call(this,!0),Ht(this,Ft,rs).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(ie(this,Ta)&&ie(this,Ci)){let t=ie(this,Ci),r;for(;r=t?.shift();)(e=ie(this,Xo))==null||e.call(this,...r)}}}has(e,t={}){let{status:r=Li.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let n=Ht(this,Ft,s2).call(this,e,t);return Li.hasSubscribers&&Li.publish(r),n}peek(e,t={}){let{status:r=$p()?{}:void 0}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let n=Ht(this,Ft,i2).call(this,e,t);return Li.hasSubscribers&&Li.publish(r),n}fetch(e,t={}){let r=Jd.hasSubscribers,{status:n=$p()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Ht(this,Ft,Hp).call(this,e,t);return n&&r&&(n.trace=!0,Jd.tracePromise(()=>a,n).catch(()=>{})),a}forceFetch(e,t={}){let r=Jd.hasSubscribers,{status:n=$p()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Ht(this,Ft,a2).call(this,e,t);return n&&r&&(n.trace=!0,Jd.tracePromise(()=>a,n).catch(()=>{})),a}memo(e,t={}){let{status:r=Li.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=Ht(this,Ft,o2).call(this,e,t);return r&&(r.value=n),Li.hasSubscribers&&Li.publish(r),n}get(e,t={}){let{status:r=Li.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let n=Ht(this,Ft,Cd).call(this,e,t);return r&&(n!==void 0&&(r.value=n),Li.hasSubscribers&&Li.publish(r)),n}delete(e){return Ht(this,Ft,tc).call(this,e,"delete")}clear(){return Ht(this,Ft,Gp).call(this,"delete")}},Do=new WeakMap,ao=new WeakMap,Ko=new WeakMap,fu=new WeakMap,Xo=new WeakMap,wd=new WeakMap,Ad=new WeakMap,Jo=new WeakMap,ii=new WeakMap,oo=new WeakMap,qs=new WeakMap,xs=new WeakMap,Kr=new WeakMap,Aa=new WeakMap,lo=new WeakMap,sa=new WeakMap,Si=new WeakMap,el=new WeakMap,Ci=new WeakMap,tl=new WeakMap,rl=new WeakMap,co=new WeakMap,uo=new WeakMap,nl=new WeakMap,Td=new WeakMap,Ta=new WeakMap,pu=new WeakMap,Ft=new WeakSet,Up=function(){let e=new Wh(ie(this,Do)),t=new Wh(ie(this,Do));Ir(this,co,e),Ir(this,rl,t);let r=this.ttlAutopurge?Array.from({length:ie(this,Do)}):void 0;Ir(this,uo,r),Ir(this,lh,(l,d,p=ie(this,Jo).now())=>{t[l]=d!==0?p:0,e[l]=d,n(l,d)}),Ir(this,mu,l=>{t[l]=e[l]!==0?ie(this,Jo).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 p=setTimeout(()=>{ie(this,ho).call(this,l)&&Ht(this,Ft,tc).call(this,ie(this,xs)[l],"expire")},d+1);p.unref&&p.unref(),r[l]=p}}:()=>{};Ir(this,Xl,(l,d)=>{if(e[d]){let p=e[d],m=t[d];if(!p||!m)return;l.ttl=p,l.start=m,l.now=a||c();let x=l.now-m;l.remainingTTL=p-x}});let a=0,c=()=>{let l=ie(this,Jo).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=ie(this,qs).get(l);if(d===void 0)return 0;let p=e[d],m=t[d];if(!p||!m)return 1/0;let x=(a||c())-m;return p-x},Ir(this,ho,l=>{let d=t[l],p=e[l];return!!p&&!!d&&(a||c())-d>p})},mu=new WeakMap,Xl=new WeakMap,lh=new WeakMap,ho=new WeakMap,n2=function(){let e=new Wh(ie(this,Do));Ir(this,oo,0),Ir(this,tl,e),Ir(this,gu,t=>{Ir(this,oo,ie(this,oo)-e[t]),e[t]=0}),Ir(this,ch,(t,r,n,a)=>{if(!ic(n)){if(Ht(this,Ft,rs).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),!ic(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}),Ir(this,Sd,(t,r,n)=>{if(e[t]=r,ie(this,ao)){let a=ie(this,ao)-e[t];for(;ie(this,oo)>a;)Ht(this,Ft,uh).call(this,!0)}Ir(this,oo,ie(this,oo)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=ie(this,oo))})},gu=new WeakMap,Sd=new WeakMap,ch=new WeakMap,Jl=function*({allowStale:e=this.allowStale}={}){if(ie(this,ii))for(let t=ie(this,Si);Ht(this,Ft,zp).call(this,t)&&((e||!ie(this,ho).call(this,t))&&(yield t),t!==ie(this,sa));)t=ie(this,lo)[t]},ec=function*({allowStale:e=this.allowStale}={}){if(ie(this,ii))for(let t=ie(this,sa);Ht(this,Ft,zp).call(this,t)&&((e||!ie(this,ho).call(this,t))&&(yield t),t!==ie(this,Si));)t=ie(this,Aa)[t]},zp=function(e){return e!==void 0&&ie(this,qs).get(ie(this,xs)[e])===e},xu=function(e,t,r,n){var a,c,l,d;let{ttl:p=this.ttl,start:m,noDisposeOnSet:x=this.noDisposeOnSet,sizeCalculation:y=this.sizeCalculation,status:w}=r,v=Ht(this,Ft,rs).call(this,t);if(t===void 0)return w&&(w.set="deleted"),this.delete(e),this;let{noUpdateTTL:S=this.noUpdateTTL}=r;w&&!v&&(w.value=t);let L=ie(this,ch).call(this,e,t,r.size||0,y,w);if(this.maxEntrySize&&L>this.maxEntrySize)return Ht(this,Ft,tc).call(this,e,"set"),w&&(w.set="miss",w.maxEntrySizeExceeded=!0),this;let E=ie(this,ii)===0?void 0:ie(this,qs).get(e);if(E===void 0)E=ie(this,ii)===0?ie(this,Si):ie(this,el).length!==0?ie(this,el).pop():ie(this,ii)===ie(this,Do)?Ht(this,Ft,uh).call(this,!1):ie(this,ii),ie(this,xs)[E]=e,ie(this,Kr)[E]=t,ie(this,qs).set(e,E),ie(this,Aa)[ie(this,Si)]=E,ie(this,lo)[E]=ie(this,Si),Ir(this,Si,E),Fp(this,ii)._++,ie(this,Sd).call(this,E,L,w),w&&(w.set="add"),S=!1,ie(this,pu)&&!v&&((a=ie(this,fu))==null||a.call(this,t,e,"add"));else{Ht(this,Ft,_d).call(this,E);let R=ie(this,Kr)[E];if(t!==R){if(!x)if(Ht(this,Ft,rs).call(this,R)){R!==n&&R.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:B}=R;B!==void 0&&B!==t&&(ie(this,nl)&&((c=ie(this,Ko))==null||c.call(this,B,e,"set")),ie(this,Ta)&&ie(this,Ci)?.push([B,e,"set"]))}else ie(this,nl)&&((l=ie(this,Ko))==null||l.call(this,R,e,"set")),ie(this,Ta)&&ie(this,Ci)?.push([R,e,"set"]);if(ie(this,gu).call(this,E),ie(this,Sd).call(this,E,L,w),ie(this,Kr)[E]=t,!v){let B=R&&Ht(this,Ft,rs).call(this,R)?R.__staleWhileFetching:R,z=B===void 0?"add":t!==B?"replace":"update";w&&(w.set=z,B!==void 0&&(w.oldValue=B)),ie(this,pu)&&this.onInsert?.(t,e,z)}}else v||(w&&(w.set="update"),ie(this,pu)&&this.onInsert?.(t,e,"update"))}if(p!==0&&!ie(this,co)&&Ht(this,Ft,Up).call(this),ie(this,co)&&(S||ie(this,lh).call(this,E,p,m),w&&ie(this,Xl).call(this,w,E)),!x&&ie(this,Ta)&&ie(this,Ci)){let R=ie(this,Ci),B;for(;B=R?.shift();)(d=ie(this,Xo))==null||d.call(this,...B)}return this},uh=function(e){var t;let r=ie(this,sa),n=ie(this,xs)[r],a=ie(this,Kr)[r],c=Ht(this,Ft,rs).call(this,a);c&&a.__abortController.abort(new Error("evicted"));let l=c?a.__staleWhileFetching:a;return(ie(this,nl)||ie(this,Ta))&&l!==void 0&&(ie(this,nl)&&((t=ie(this,Ko))==null||t.call(this,l,n,"evict")),ie(this,Ta)&&ie(this,Ci)?.push([l,n,"evict"])),ie(this,gu).call(this,r),ie(this,uo)?.[r]&&(clearTimeout(ie(this,uo)[r]),ie(this,uo)[r]=void 0),e&&(ie(this,xs)[r]=void 0,ie(this,Kr)[r]=void 0,ie(this,el).push(r)),ie(this,ii)===1?(Ir(this,sa,Ir(this,Si,0)),ie(this,el).length=0):Ir(this,sa,ie(this,Aa)[r]),ie(this,qs).delete(n),Fp(this,ii)._--,r},s2=function(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=ie(this,qs).get(e);if(a!==void 0){let c=ie(this,Kr)[a];if(Ht(this,Ft,rs).call(this,c)&&c.__staleWhileFetching===void 0)return!1;if(ie(this,ho).call(this,a))n&&(n.has="stale",ie(this,Xl).call(this,n,a));else return r&&ie(this,mu).call(this,a),n&&(n.has="hit",ie(this,Xl).call(this,n,a)),!0}else n&&(n.has="miss");return!1},i2=function(e,t){let{status:r,allowStale:n=this.allowStale}=t,a=ie(this,qs).get(e);if(a===void 0||!n&&ie(this,ho).call(this,a)){r&&(r.peek=a===void 0?"miss":"stale");return}let c=ie(this,Kr)[a],l=Ht(this,Ft,rs).call(this,c)?c.__staleWhileFetching:c;return r&&(l!==void 0?(r.peek="hit",r.value=l):r.peek="miss"),l},dh=function(e,t,r,n){let a=t===void 0?void 0:ie(this,Kr)[t];if(Ht(this,Ft,rs).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},p=(S,L=!1)=>{let{aborted:E}=c.signal,R=r.ignoreFetchAbort&&S!==void 0,B=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&S!==void 0);if(r.status&&(E&&!L?(r.status.fetchAborted=!0,r.status.fetchError=c.signal.reason,R&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),E&&!R&&!L)return x(c.signal.reason,B);let z=w,O=ie(this,Kr)[t];return(O===w||O===void 0&&R&&L)&&(S===void 0?z.__staleWhileFetching!==void 0?ie(this,Kr)[t]=z.__staleWhileFetching:Ht(this,Ft,tc).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),Ht(this,Ft,xu).call(this,e,S,d.options,z))),S},m=S=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=S),x(S,!1)),x=(S,L)=>{let{aborted:E}=c.signal,R=E&&r.allowStaleOnFetchAbort,B=R||r.allowStaleOnFetchRejection,z=B||r.noDeleteOnFetchRejection,O=w;if(ie(this,Kr)[t]===w&&(!z||!L&&O.__staleWhileFetching===void 0?Ht(this,Ft,tc).call(this,e,"fetch"):R||(ie(this,Kr)[t]=O.__staleWhileFetching)),B)return r.status&&O.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),O.__staleWhileFetching;if(O.__returned===O)throw S},y=(S,L)=>{var E;let R=(E=ie(this,wd))==null?void 0:E.call(this,e,a,d);c.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(S(void 0),r.allowStaleOnFetchAbort&&(S=B=>p(B,!0)))}),R&&R instanceof Promise?R.then(B=>S(B===void 0?void 0:B),L):R!==void 0&&S(R)};r.status&&(r.status.fetchDispatched=!0);let w=new Promise(y).then(p,m),v=Object.assign(w,{__abortController:c,__staleWhileFetching:a,__returned:void 0});return t===void 0?(Ht(this,Ft,xu).call(this,e,v,{...d.options,status:void 0}),t=ie(this,qs).get(e)):ie(this,Kr)[t]=v,v},rs=function(e){if(!ie(this,Td))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},Hp=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:p=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:S,forceRefresh:L=!1,status:E,signal:R}=t;if(E&&(E.op="fetch",E.key=e,L&&(E.forceRefresh=!0),E.cache=this),!ie(this,Td))return E&&(E.fetch="get"),Ht(this,Ft,Cd).call(this,e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:E});let B={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:c,noDisposeOnSet:l,size:d,sizeCalculation:p,noUpdateTTL:m,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:v,ignoreFetchAbort:w,status:E,signal:R},z=ie(this,qs).get(e);if(z===void 0){E&&(E.fetch="miss");let O=Ht(this,Ft,dh).call(this,e,z,B,S);return O.__returned=O}else{let O=ie(this,Kr)[z];if(Ht(this,Ft,rs).call(this,O)){let le=r&&O.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",le&&(E.returnedStale=!0)),le?O.__staleWhileFetching:O.__returned=O}let $=ie(this,ho).call(this,z);if(!L&&!$)return E&&(E.fetch="hit"),Ht(this,Ft,_d).call(this,z),n&&ie(this,mu).call(this,z),E&&ie(this,Xl).call(this,E,z),O;let V=Ht(this,Ft,dh).call(this,e,z,B,S),Z=V.__staleWhileFetching!==void 0&&r;return E&&(E.fetch=$?"stale":"refresh",Z&&$&&(E.returnedStale=!0)),Z?V.__staleWhileFetching:V.__returned=V}},a2=async function(e,t={}){let r=await Ht(this,Ft,Hp).call(this,e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r},o2=function(e,t={}){let r=ie(this,Ad);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=Ht(this,Ft,Cd).call(this,e,l),p=c||d===void 0;if(a&&(a.memo=p?"miss":"hit",p||(a.value=d)),!p)return d;let m=r(e,d,{options:l,context:n});return a&&(a.value=m),Ht(this,Ft,xu).call(this,e,m,l),m},Cd=function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:c}=t,l=ie(this,qs).get(e);if(l===void 0){c&&(c.get="miss");return}let d=ie(this,Kr)[l],p=Ht(this,Ft,rs).call(this,d);return c&&ie(this,Xl).call(this,c,l),ie(this,ho).call(this,l)?p?(c&&(c.get="stale-fetching"),r&&d.__staleWhileFetching!==void 0?(c&&(c.returnedStale=!0),d.__staleWhileFetching):void 0):(a||Ht(this,Ft,tc).call(this,e,"expire"),c&&(c.get="stale"),r?(c&&(c.returnedStale=!0),d):void 0):(c&&(c.get=p?"fetching":"hit"),Ht(this,Ft,_d).call(this,l),n&&ie(this,mu).call(this,l),p?d.__staleWhileFetching:d)},Wp=function(e,t){ie(this,lo)[t]=e,ie(this,Aa)[e]=t},_d=function(e){e!==ie(this,Si)&&(e===ie(this,sa)?Ir(this,sa,ie(this,Aa)[e]):Ht(this,Ft,Wp).call(this,ie(this,lo)[e],ie(this,Aa)[e]),Ht(this,Ft,Wp).call(this,ie(this,Si),e),Ir(this,Si,e))},tc=function(e,t){var r,n;Li.hasSubscribers&&Li.publish({op:"delete",delete:t,key:e,cache:this});let a=!1;if(ie(this,ii)!==0){let c=ie(this,qs).get(e);if(c!==void 0)if(ie(this,uo)?.[c]&&(clearTimeout(ie(this,uo)?.[c]),ie(this,uo)[c]=void 0),a=!0,ie(this,ii)===1)Ht(this,Ft,Gp).call(this,t);else{ie(this,gu).call(this,c);let l=ie(this,Kr)[c];if(Ht(this,Ft,rs).call(this,l)?l.__abortController.abort(new Error("deleted")):(ie(this,nl)||ie(this,Ta))&&(ie(this,nl)&&((r=ie(this,Ko))==null||r.call(this,l,e,t)),ie(this,Ta)&&ie(this,Ci)?.push([l,e,t])),ie(this,qs).delete(e),ie(this,xs)[c]=void 0,ie(this,Kr)[c]=void 0,c===ie(this,Si))Ir(this,Si,ie(this,lo)[c]);else if(c===ie(this,sa))Ir(this,sa,ie(this,Aa)[c]);else{let d=ie(this,lo)[c];ie(this,Aa)[d]=ie(this,Aa)[c];let p=ie(this,Aa)[c];ie(this,lo)[p]=ie(this,lo)[c]}Fp(this,ii)._--,ie(this,el).push(c)}}if(ie(this,Ta)&&ie(this,Ci)?.length){let c=ie(this,Ci),l;for(;l=c?.shift();)(n=ie(this,Xo))==null||n.call(this,...l)}return a},Gp=function(e){var t,r;for(let n of Ht(this,Ft,ec).call(this,{allowStale:!0})){let a=ie(this,Kr)[n];if(Ht(this,Ft,rs).call(this,a))a.__abortController.abort(new Error("deleted"));else{let c=ie(this,xs)[n];ie(this,nl)&&((t=ie(this,Ko))==null||t.call(this,a,c,e)),ie(this,Ta)&&ie(this,Ci)?.push([a,c,e])}}if(ie(this,qs).clear(),ie(this,Kr).fill(void 0),ie(this,xs).fill(void 0),ie(this,co)&&ie(this,rl)){ie(this,co).fill(0),ie(this,rl).fill(0);for(let n of ie(this,uo)??[])n!==void 0&&clearTimeout(n);ie(this,uo)?.fill(void 0)}if(ie(this,tl)&&ie(this,tl).fill(0),Ir(this,sa,0),Ir(this,Si,0),ie(this,el).length=0,Ir(this,oo,0),Ir(this,ii,0),ie(this,Ta)&&ie(this,Ci)){let n=ie(this,Ci),a;for(;a=n?.shift();)(r=ie(this,Xo))==null||r.call(this,...a)}},Vp);function z3(e){let t={individual:{},range:[]},r=new WeakMap;for(let n of e)e1(t,n,r);return t}function e1(e,t,r){for(let[n,a]of Object.entries(t.individual))if(e.individual[n])bu(e.individual[n],a,r);else{let c=!1;for(let[l,{range:d,entry:p}]of e.range.entries()){let m=qp(Number(n),d);if(m.both!==null){c=!0,e.individual[n]=a,bu(e.individual[n],Ii(p),r),e.range.splice(l,1);for(let x of m.second)Array.isArray(x)?e.range.push({range:x,entry:Ii(p)}):e.individual[x]=Ii(p)}}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:p}=e.range[l];for(let[m,x]of c.entries())if(Array.isArray(x)){let y=uL(x,d);if(y.both===null)continue;e.range.splice(l,1),l--;let w=Ii(p);Array.isArray(y.both)?e.range.push({range:y.both,entry:w}):e.individual[y.both]=w,bu(w,Ii(a),r);for(let v of y.second)Array.isArray(v)?e.range.push({range:v,entry:Ii(p)}):e.individual[v]=Ii(p);c=y.first}else{let y=qp(x,d);if(y.both===null)continue;e.individual[x]=Ii(a),bu(e.individual[x],Ii(p),r),e.range.splice(l,1),l--;for(let w of y.second)Array.isArray(w)?e.range.push({range:w,entry:Ii(p)}):e.individual[w]=Ii(p);c.splice(m,1,...y.first);break}}for(let l of Object.keys(e.individual))for(let[d,p]of c.entries())if(Array.isArray(p)){let m=qp(Number(l),p);if(m.both===null)continue;bu(e.individual[l],Ii(a),r),c.splice(d,1,...m.second);break}else if(Number(l)===p){bu(e.individual[l],Ii(a),r);break}for(let l of c)Array.isArray(l)?e.range.push({range:l,entry:Ii(a)}):e.individual[l]=Ii(a)}}function bu(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?e1(e.forward,t.forward,r):e.forward=t.forward),t.reverse&&(e.reverse?e1(e.reverse,t.reverse,r):e.reverse=t.reverse))}function uL(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=Bc(n,a)}if(e[0]<t[0]){let n=e[0],a=Math.min(t[0],e[1]);r.first.push(Bc(n,a))}else if(t[0]<e[0]){let n=t[0],a=Math.min(t[1],e[0]);r.second.push(Bc(n,a))}if(e[1]>t[1]){let n=Math.max(e[0],t[1]),a=e[1];r.first.push(Bc(n,a))}else if(t[1]>e[1]){let n=Math.max(e[1],t[0]),a=t[1];r.second.push(Bc(n,a))}return r}function qp(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(Bc(t[0],e)),t[1]>e&&r.second.push(Bc(e+1,t[1])),r}function Bc(e,t){return t-e===1?e:[e,t]}function Ii(e,t=new Map){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=l2(e.forward,t)),e.reverse&&(r.reverse=l2(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 l2(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=Ii(a,t);return{individual:r,range:e.range.map(({range:n,entry:a})=>({range:n.slice(),entry:Ii(a,t)}))}}function t1(e,t,r,n){let a=t[n],c=e[a];if(!c)return;let l=c.lookup;if(c.reverse){let p=dL(c.reverse,t,r);(!l&&p||p&&l&&(l.index>p.index||l.index===p.index&&l.subIndex>p.subIndex))&&(l=p)}if(++n>=t.length||!c.forward)return l;let d=t1(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 dL(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 c2(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 hL(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 Nl(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 fL(e,t){let r=t[0],n=r1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)r1(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 r1(e,t){let r=hL(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 Z1(e,t,r,n,a){let c=[];for(let l of r){l.entry.forward={individual:{},range:[]};for(let d of e)c.push(...Wf(l.entry.forward,n,a,t,d).map(({entry:p,substitution:m})=>({entry:p,substitutions:[...l.substitutions,m]})))}return c}function zf(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 Hf(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 Wf(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=pL(t,r,n,a);for(let[d,p]of l){let m={};Array.isArray(d)?e.range.push({range:d,entry:m}):e.individual[d]={},c.push({entry:m,substitution:p})}}return c}function pL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=fL(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=r1(c,n);if(l!==null)return l}return null}function gL(e,t,r){let n={individual:{},range:[]},a=Nl(e.coverage);for(let{glyphId:c,index:l}of a){let d=e.chainRuleSets[l];if(d)for(let[p,m]of d.entries()){let x=Wf(n,m.lookupRecords,t,0,c).map(({entry:y,substitution:w})=>({entry:y,substitutions:[w]}));for(let[y,w]of m.input.entries())x=Z1([w],y+1,x,m.lookupRecords,t);for(let y of m.lookahead)x=zf([y],x);for(let y of m.backtrack)x=Hf([y],x);for(let{entry:y,substitutions:w}of x)y.lookup={substitutions:w,length:m.input.length+1,index:r,subIndex:p,contextRange:[-1*m.backtrack.length,1+m.input.length+m.lookahead.length]}}}return n}function xL(e,t){return e.format===2?Array.isArray(t)?bL(e,t):new Map([[t,n1(e,t)]]):new Map([[t,null]])}function bL(e,t){let r=t[0],n=n1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)n1(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 n1(e,t){for(let r of e.ranges)if(r.start<=t&&r.end>=t)return r.classId;return null}function Yp(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 yL(e,t,r){let n=[],a=Nl(e.coverage);for(let{glyphId:c}of a){let l=xL(e.inputClassDef,c);for(let[d,p]of l.entries()){if(p===null)continue;let m=e.chainClassSet[p];if(m)for(let[x,y]of m.entries()){let w={individual:{},range:[]},v=Wf(w,y.lookupRecords,t,0,d).map(({entry:S,substitution:L})=>({entry:S,substitutions:[L]}));for(let[S,L]of y.input.entries())v=Z1(Yp(e.inputClassDef,L),S+1,v,y.lookupRecords,t);for(let S of y.lookahead)v=zf(Yp(e.lookaheadClassDef,S),v);for(let S of y.backtrack)v=Hf(Yp(e.backtrackClassDef,S),v);for(let{entry:S,substitutions:L}of v)S.lookup={substitutions:L,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 z3(n)}function vL(e,t,r){let n={individual:{},range:[]},a=Nl(e.inputCoverage[0]);for(let{glyphId:c}of a){let l=Wf(n,e.lookupRecords,t,0,c).map(({entry:d,substitution:p})=>({entry:d,substitutions:[p]}));for(let[d,p]of e.inputCoverage.slice(1).entries())l=Z1(Nl(p).map(m=>m.glyphId),d+1,l,e.lookupRecords,t);for(let d of e.lookaheadCoverage)l=zf(Nl(d).map(p=>p.glyphId),l);for(let d of e.backtrackCoverage)l=Hf(Nl(d).map(p=>p.glyphId),l);for(let{entry:d,substitutions:p}of l)d.lookup={substitutions:p,index:r,subIndex:0,length:e.inputCoverage.length,contextRange:[-1*e.backtrackCoverage.length,e.inputCoverage.length+e.lookaheadCoverage.length]}}return n}function wL(e,t){let r={individual:{},range:[]},n=Nl(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 p of e.lookaheadCoverage)d=zf(Nl(p).map(m=>m.glyphId),d);for(let p of e.backtrackCoverage)d=Hf(Nl(p).map(m=>m.glyphId),d);for(let{entry:p,substitutions:m}of d)p.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]=u2(a,t);for(let{range:n,entry:a}of e.range){let c=u2(a,t);for(let l=n[0];l<n[1];l++)r[l]=c}return r}function u2(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 AL=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new cL({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(gL(x,n,m));break;case 2:d.push(yL(x,n,m));break;case 3:d.push(vL(x,n,m));break}break;case 8:for(let[m,x]of l.subtables.entries())d.push(wL(x,m));break}let p=s1(z3(d));this._lookupTrees.push({tree:p,processForward:l.lookupType!==8});for(let m of Object.keys(p))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=t1(n.tree,e,c,c);if(l){for(let d=0;d<l.substitutions.length;d++){let p=l.substitutions[d];p!==null&&(e[c+d]=p)}c2(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=t1(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)}c2(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 TL(e,t){let r=sL.parse(e);return new AL(r,{cacheSize:0,...t})}function SL(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+=CL(t,a);break;case",":r.push(n),n="";break;default:/\s/.test(a)||(t.offset--,n+=_L(t),r.push(n),n="")}}return r}function CL(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+=H3(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 _L(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+=H3(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 H3(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return Zp(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,Zp(t);t+=r}return Zp(t)}function Zp(e){return String.fromCodePoint(parseInt(e,16))}var kd;async function kL(e,t){if(!kd){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);kd=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);kd=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}kd??=Promise.resolve({})}let r=await kd;for(let n of SL(e)){if(LL.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 TL(c,{cacheSize:t})}return}}}var LL=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],IL=1e5;function EL(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 p=r;kL(p,IL).then(m=>{p===e.options.fontFamily&&(a=2,n=m,m&&e.refresh(0,e.rows-1))}).catch(m=>{p===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(p=>[p[0],p[1]]):NL(l,t)})}function NL(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 RL=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=EL(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 d2(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 ML=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=d2(r[1]),a=d2(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 W3(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 h2(e,t){const r=W3(e,t);return r?(r.right-r.left)*(r.bottom-r.top):0}function zc(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 Gh(e,t){const r=zc(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 jL(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 xf(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 DL(e,t,r){const n=zc(e);if(!n)return null;const{start:a,end:c}=xf(t,r,e.cols),l=e.buffer.active.viewportY,d=l+e.rows-1;if(c.row<l||a.row>d)return null;const p=Math.max(a.row,l),m=Math.min(c.row,d),x=n.originTop+(p-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 BL(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),p=Math.max(l,a-e.height-e.margin),m=le=>Math.max(c,Math.min(le,d)),x=le=>Math.max(l,Math.min(le,p)),y=e.selection?W3(e.selection,{left:t,top:r,right:n,bottom:a}):null;if(!y){const le=m(e.clientX-e.width/2),be=e.clientY-e.height-e.fingerGap,pe=e.clientY+e.fingerGap,ee=x(be>=l?be:pe);return{left:Math.round(le),top:Math.round(ee)}}const w=(y.left+y.right)/2,v=(y.top+y.bottom)/2,S=e.preference?.alignX??w,L=e.selectionGap??e.fingerGap,E=y.top-e.height-L,R=y.bottom+L,B=e.preference?.vertical==="below"?R:E,z=e.preference?.vertical==="below"?E:R,O=[{left:c,top:l},{left:d,top:l},{left:c,top:p},{left:d,top:p}];e.preference&&O.sort((le,be)=>{const pe=ee=>{const _e=ee.left+e.width/2,ze=ee.top+e.height/2;return Math.hypot(_e-e.preference.focusX,ze-e.preference.focusY)};return pe(be)-pe(le)});const $=[{left:S-e.width/2,top:B},{left:w-e.width/2,top:B},{left:S-e.width/2,top:z},{left:w-e.width/2,top:z},{left:y.left-e.width-e.fingerGap,top:v-e.height/2},{left:y.right+e.fingerGap,top:v-e.height/2},...O].map(le=>({left:m(le.left),top:x(le.top)}));let V=$[0],Z=Number.POSITIVE_INFINITY;return $.forEach((le,be)=>{const pe={left:le.left,top:le.top,right:le.left+e.width,bottom:le.top+e.height},ee=(e.avoid??[]).reduce((ze,Y)=>ze+h2(pe,Y),0),_e=(ee>0?1e6:0)+ee*100+h2(pe,y)*10+be*.01;_e<Z&&(V=le,Z=_e)}),{left:Math.round(V.left),top:Math.round(V.top)}}function QL(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 PL(e){let t=e.parentElement;for(;t;){if(QL(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function OL(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 FL(e,t){return t?.ownedPaste?Vm(e,!1):t?.paste&&/[\r\n]/.test(e)?Vm(e,t.submitAfterPaste??e.endsWith("\r")):e}const f2=2,$L=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function UL(e){const t=e.reason.replace(/^refresh:/,""),r=$L.has(t),n=Math.abs(e.proposedCols-e.currentCols),a=Math.abs(e.proposedRows-e.currentRows);return{accept:r?n>0||a>0:n>=f2||a>=f2,isRealResize:r,colsDelta:n,rowsDelta:a}}function zL(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 HL(e,t){return!e||t}function WL(e,t,r){return e!=="alternate"&&r>=t}function GL(e,t){return e?"none":t?"single":"settled"}function VL(e,t,r){return!r&&(e||t)}function qL(e){let t,r,n=!1,a=0;const c=e.parser.registerCsiHandler({prefix:"?",final:"l"},d=>(t&&d.some(p=>p===2026)&&(n=!0),!1)),l=d=>{const p=t;if(!p)return;const m=r;if(t=void 0,r=void 0,n=!1,p(),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 p=d.handleResize,m=d.renderRows,x=d.clear;d.handleResize=(y,w)=>{r=[y,w]},d.renderRows=()=>{},d.clear=()=>{},t=()=>{d.handleResize=p,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 Kp(){return{confirmed:null,pending:null,nextSeq:1}}function p2(e,t){return e?.cols===t.cols&&e.rows===t.rows}function K1(e,t,r){const n={...t,seq:e.nextSeq,attempt:r};return{state:{...e,pending:n,nextSeq:e.nextSeq+1},request:n}}function YL(e,t){return p2(e.pending,t)||!e.pending&&p2(e.confirmed,t)?{state:e,request:null}:K1(e,t,0)}function ZL(e,t){return K1(e,t,0)}function KL(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 m2(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}:{...K1(e,n,n.attempt+1),exhausted:!1}}function XL(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 JL(e){return{...e,pending:null}}const eI=150;function g2(e=0){return{lastPushAt:e}}function tI(e,t,r=eI){return t-e.lastPushAt>=r?(e.lastPushAt=t,{action:"send"}):{action:"hold",readyAt:e.lastPushAt+r}}function rI(e){return{lastPushAt:e}}const i1="termdock-settings",nI=6,sI=100,iI='"calt" on',aI=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function oI(){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 X1(){return{fontFamily:"var(--font-mono)",fontSize:oI(),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 hh(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function x2(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 Qu(e){const t=X1(),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:hh(r.fontSize,nI,sI,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:x2(r.fontWeight,t.fontWeight),fontWeightBold:x2(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(hh(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:hh(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:hh(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 fh(e){return e.pointerType==="touch"||e.pointerType==="pen"}class lI{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(!fh(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(!fh(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(!fh(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(!fh(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 G3=new lI,cI=90,uI=80,dI=70,hI=(e,t)=>{const{scrollMultiplier:r=1.2,maxScrollBoost:n=.8,boostDenominator:a=50,velocityAlpha:c=.15,maxVelocity:l=15,minVelocity:d=.3,decelerationRate:p=.998,enableKinetic:m=!0,shouldCaptureTouch:x,canStartScrollGesture:y,onScroll:w,onScrollWithCoords:v,onTap:S,onClickWithCoords:L,onClaimChange:E,tapThreshold:R=10,gestureName:B="normal-scroll"}=t,z=1.06,O=k.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),$=k.useRef(0),V=k.useRef(0),Z=k.useRef(0),le=k.useRef(null),be=k.useRef(0),pe=k.useRef(!1),ee=k.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),_e=k.useCallback(()=>{le.current=null,$.current!==0&&(v&&V.current>0&&Z.current>0?v($.current,V.current,Z.current):w&&w($.current),$.current=0,V.current=0,Z.current=0)},[w,v]),ze=k.useCallback(()=>{le.current===null&&typeof window<"u"&&(le.current=window.requestAnimationFrame(_e))},[_e]),Y=k.useCallback((Ne,oe,We)=>{$.current+=Ne,oe!==void 0&&We!==void 0&&(V.current=oe,Z.current=We),ze()},[ze]),ce=k.useCallback(Ne=>{if(!Ne||!w)return!1;const oe=w(Ne);return oe?be.current=0:be.current++,oe},[w]),qe=k.useCallback(Ne=>{pe.current!==Ne&&(pe.current=Ne,E?.(Ne))},[E]),we=k.useCallback(()=>{const Ne=O.current;Ne.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ne.rafId),Ne.rafId=null,le.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(le.current),le.current=null,$.current=0},[]),ye=k.useRef(S);ye.current=S;const Le=k.useRef(L);Le.current=L;const Be=k.useRef(x);Be.current=x;const ne=k.useCallback(()=>{const Ne=e.current;if(!Ne||!("PointerEvent"in window))return()=>{};const oe=O.current,We={name:B,priority:dI,get container(){return e.current??void 0},onPointerDown:(ue,Ze)=>(ue.pointerType!=="touch"||(oe.pointerId=ue.pointerId,oe.startX=Ze.startX,oe.startY=Ze.startY,oe.didMove=!1,oe.gestureAxis=null,oe.lastY=ue.clientY,oe.lastTime=ee(),oe.velocity=0,we()),!1),onPointerMove:(ue,Ze)=>{if(ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId||!oe.lastY||!oe.lastTime)return"neutral";const at=ue.clientX,Ie=ue.clientY,Ge=ee(),Ce=Ge-oe.lastTime,H=Ie-oe.lastY;if(oe.startX!==null&&oe.startY!==null){const Ae=at-oe.startX,Ye=Ie-oe.startY;if(!oe.didMove&&Math.hypot(Ae,Ye)>=R&&(oe.didMove=!0),oe.gestureAxis===null&&oe.didMove){const et=Math.abs(Ae),St=Math.abs(Ye);et>St*z?oe.gestureAxis="x":St>et*z&&(oe.gestureAxis="y")}if(oe.gestureAxis==="x")return oe.isCurrentlyScrolling=!1,qe(!1),oe.lastY=Ie,oe.lastTime=Ge,Ze?"release":"neutral";if(oe.gestureAxis===null)return oe.lastY=Ie,oe.lastTime=Ge,"neutral"}if(oe.gestureAxis==="y"&&!Ze&&!(y?.()??!0))return oe.lastY=Ie,oe.lastTime=Ge,qe(!1),"neutral";const ae=H/Math.max(Ce,1);if(oe.velocity=oe.velocity*(1-c)+ae*c,oe.velocity=Math.max(-l,Math.min(l,oe.velocity)),Math.abs(H)>1){if(!Ze)return qe(!0),oe.lastY=Ie,oe.lastTime=Ge,"claim";oe.isCurrentlyScrolling=!0;const Ae=r+Math.min(n,Math.abs(H)/a),Ye=-H*Ae;Y(Ye,at,Ie),qe(!0)}return oe.lastY=Ie,oe.lastTime=Ge,Ze?"claim":"neutral"},onPointerUp:ue=>{if(ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId)return;const Ze=oe.isCurrentlyScrolling;oe.isCurrentlyScrolling=!1,qe(!1);const at=oe.rafId!==null||le.current!==null;!oe.didMove&&!at&&oe.startX!==null&&oe.startY!==null&&ye.current?.(oe.startX,oe.startY),!oe.didMove&&!at&&oe.startX!==null&&oe.startY!==null&&Le.current?.(oe.startX,oe.startY),oe.pointerId=null,oe.startX=null,oe.startY=null;const Ie=oe.gestureAxis==="x";if(oe.gestureAxis=null,m&&Ze&&!Ie&&Math.abs(oe.velocity)>d&&oe.didMove){const Ge=()=>{const Ce=ee(),H=Ce-(oe.lastTime||Ce);if(oe.lastTime=Ce,oe.velocity*=Math.pow(p,H),Math.abs(oe.velocity)<d){oe.velocity=0,we();return}if(!ce(-oe.velocity*H)&&be.current>2){oe.velocity=0,we();return}oe.rafId=requestAnimationFrame(Ge)};oe.rafId=requestAnimationFrame(Ge)}},onPointerCancel:ue=>{ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId||(oe.isCurrentlyScrolling=!1,qe(!1),oe.pointerId=null,oe.startX=null,oe.startY=null,oe.gestureAxis=null,we())}},nt=G3.register(We),gt=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{qe(!1),nt(),Ne.style.touchAction=gt,we()}},[e,B,r,n,a,c,l,d,p,ee,we,ce,Y,R,m,qe,y]),Fe=k.useCallback(()=>{const Ne=e.current;if(!Ne)return()=>{};const oe=O.current,We=Ze=>{Ze.touches.length===1&&((x?.()??!0)&&Ze.cancelable&&Ze.preventDefault(),oe.isCurrentlyScrolling=!1,oe.gestureAxis=null,oe.lastY=Ze.touches[0].clientY,oe.startX=Ze.touches[0].clientX,oe.startY=Ze.touches[0].clientY,oe.didMove=!1,oe.velocity=0,we())},nt=Ze=>{if(Ze.touches.length!==1)return;const at=Ze.touches[0].clientX,Ie=Ze.touches[0].clientY;if(oe.startX!==null&&oe.startY!==null){const Ce=at-oe.startX,H=Ie-oe.startY;if(!oe.didMove&&Math.hypot(Ce,H)>=R&&(oe.didMove=!0),oe.gestureAxis===null&&oe.didMove){const ae=Math.abs(Ce),Ae=Math.abs(H);ae>Ae*z?oe.gestureAxis="x":Ae>ae*z&&(oe.gestureAxis="y")}if(oe.gestureAxis==="x"){oe.isCurrentlyScrolling=!1,oe.lastY=Ie;return}if(oe.gestureAxis===null){(x?.()??!1)&&Ze.cancelable&&Ze.preventDefault(),oe.lastY=Ie;return}}if(Ze.preventDefault(),!oe.lastY){oe.lastY=Ie;return}const Ge=Ie-oe.lastY;if(Math.abs(Ge)>1){oe.isCurrentlyScrolling=!0;const Ce=r+Math.min(n,Math.abs(Ge)/a),H=-Ge*Ce;Y(H,at,Ie)}oe.lastY=Ie},gt=Ze=>{if(!Ze.changedTouches?.[0])return;const Ie=oe.isCurrentlyScrolling;oe.isCurrentlyScrolling=!1;const Ge=oe.rafId!==null||le.current!==null;!oe.didMove&&!Ge&&S&&oe.startX!==null&&oe.startY!==null&&S(oe.startX,oe.startY),!oe.didMove&&!Ge&&L&&oe.startX!==null&&oe.startY!==null&&L(oe.startX,oe.startY),oe.startX=null,oe.startY=null;const Ce=oe.gestureAxis==="x";if(oe.gestureAxis=null,m&&Ie&&!Ce&&oe.didMove&&Math.abs(oe.velocity)>d){const H=()=>{if(oe.velocity*=Math.pow(p,16),Math.abs(oe.velocity)<d){oe.velocity=0,we();return}if(!ce(-oe.velocity*16)&&be.current>2){oe.velocity=0,we();return}oe.rafId=requestAnimationFrame(H)};oe.rafId=requestAnimationFrame(H)}};Ne.addEventListener("touchstart",We,{passive:!1}),Ne.addEventListener("touchmove",nt,{passive:!1}),Ne.addEventListener("touchend",gt,{passive:!1}),Ne.addEventListener("touchcancel",gt,{passive:!1});const ue=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{Ne.removeEventListener("touchstart",We),Ne.removeEventListener("touchmove",nt),Ne.removeEventListener("touchend",gt),Ne.removeEventListener("touchcancel",gt),Ne.style.touchAction=ue,we()}},[e,r,n,a,d,p,we,ce,Y,S,L,R,x,m]),ke=k.useCallback(()=>{we();const Ne=typeof window<"u"&&"PointerEvent"in window,oe=Ne?ne():()=>{},We=Ne?()=>{}:Fe();return()=>{oe(),We(),we()}},[ne,Fe,we]),Ee=k.useCallback(()=>O.current.isCurrentlyScrolling||O.current.rafId!==null||le.current!==null,[]),Pe=k.useCallback(()=>{we();const Ne=O.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},[we]);return{setupTouchScroll:ke,isScrolling:Ee,stopAllScroll:Pe}};function b2(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 p={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 G3.register(p)},[t,r])}var Us;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Us||(Us={}));Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;const fI=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",pI=()=>typeof document<"u"&&!!document.body,mI=()=>{if(pI())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{}},y2=e=>Array.isArray(e)?[...e]:[e],gI=e=>{if(fI()){try{const a=y2(e),c=a.length===1?a[0]:a;navigator.vibrate(c)}catch{}return}const t=y2(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},xo=e=>gI(e);function V3({message:e}){const{t}=Ur();return s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-4",children:s.jsx(p0,{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 xI(){const{t:e}=Ur();return s.jsx(V3,{message:e("terminal.initializing")})}const bI=({message:e,onRetry:t})=>{const{t:r}=Ur();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 Vh(e){return Array.from(e)}function v2(e,t,r){return Math.max(t,Math.min(r,e))}function yI(e,t,r,n){const a=Vh(e),c=Vh(t);let l=v2(r,0,a.length);const d=v2(n,0,c.length);let p=0;for(;p<a.length&&p<c.length&&a[p]===c[p];)p++;let m=0;for(;m<a.length-p&&m<c.length-p&&a[a.length-1-m]===c[c.length-1-m];)m++;const x=a.length-p-m,y=c.slice(p,c.length-m).join(""),w=[];if(x>0||y){const v=p+x;l>v?w.push({left:l-v}):l<v&&w.push({right:v-l}),l=v,x>0&&(w.push({backspace:x}),l=p),y&&(w.push({insert:y}),l+=Vh(y).length)}return l>d?w.push({left:l-d}):l<d&&w.push({right:d-l}),l=d,{ops:w,cursor:l}}function w2(e){const t=e.value,r=e.selectionStart??t.length;return Vh(t.slice(0,r)).length}const bf=16,vI=10,A2=1.5,wI=1.8,T2=240,AI=125,TI=92;function SI(e,t,r){const n=Math.hypot(e,t),a=Math.abs(e),c=Math.abs(t),l=()=>a>=c*A2?e>0?"right":"left":c>=a*A2?t>0?"down":"up":"";if(r==="")return n>bf?l():"";if(n<vI)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)*wI?d:r}function CI(e){const t=TI-bf,r=Math.min(Math.max((e-bf)/t,0),1);return T2-r*(T2-AI)}const _I="termdock-open-terminal-directory",a1=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?:,;!?。、“”‘’])+/gu,kI=new RegExp(`^( *)(${a1.source})`,"u"),LI=/[,;:!?]+$/u,II=/^[a-z][a-z\d+.-]*:\/\//iu;function EI(e){return!e||e==="/"||II.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function q3(e){const t=[];a1.lastIndex=0;let r;for(;(r=a1.exec(e))!==null;){const a=r[0].replace(LI,"");if(!EI(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 Xp(e){const t=[];for(const r of e.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return`/${t.join("/")}`}function NI(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function RI(e,t){const r=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(r.startsWith("/"))return Xp(r);if(r==="~"||r.startsWith("~/")){const n=t?NI(t):null;return n?Xp(`${n}/${r.slice(2)}`):null}return t?.startsWith("/")?Xp(`${t}/${r}`):null}function ph(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=q3(a).at(-1),d=c.match(kI);if(!l||l.endIndex!==a.length||!l.text.endsWith("/")||!d||/^[~./]/u.test(d[2]))return null;const p=d[2];if(!p.includes("/")&&!/^[^/:]+\.[\p{L}\p{N}_-]+$/u.test(p))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 L=x;L<n.length;L+=1){const E=n.getCell(L);if(E?.getWidth()!==0){if(!E||/[\s/:]/u.test(E.getChars()||" "))break;y+=E.getWidth()}}if(r.length-m-1>=Math.max(8,x+2,y))return null;const v=r.getCell(m),S=n.getCell(x);return!v||!S||v.isFgDefault()||S.isFgDefault()||v.getFgColorMode()!==S.getFgColorMode()||v.getFgColor()!==S.getFgColor()?null:x}function MI(e,t){const r=e.buffer.active;let n=t-1;if(!r.getLine(n))return null;for(;n>0&&(r.getLine(n)?.isWrapped||ph(e,n)!==null);)n-=1;let a=t-1;for(;a+1<r.length&&(r.getLine(a+1)?.isWrapped||ph(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?ph(e,m)??0:0;let w=x.length;if(m<a&&ph(e,m+1)!==null)for(;w>0&&!(x.getCell(w-1)?.getChars()||"").trim();)w-=1;for(let v=y;v<w;v+=1){const S=x.getCell(v);if(!S||S.getWidth()===0)continue;const L=S.getChars()||" ";c+=L;for(let E=0;E<L.length;E+=1)l.push({x:v+1,y:m+1}),d.push({x:v+Math.max(1,S.getWidth()),y:m+1})}}const p=c.trimEnd().length;return{text:c.slice(0,p),startPositions:l.slice(0,p),endPositions:d.slice(0,p)}}function jI(e,t){return{provideLinks(r,n){const a=MI(e,r);if(!a){n(void 0);return}const c=q3(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 S2(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 p=Math.max(0,n-r);e.ybase>p&&(e.ybase=p,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,p)),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 p=Math.max(0,e.lines.length-r);e.ybase>p&&(e.ybase=p,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,p)),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 p=0;p<d;p++){const m=e.lines.length;if(e.lines.push(e.getBlankLine(void 0)),e.lines.length<=m)break;a++}return a}function C2(e,t=e.rows){const n=e._core?._bufferService?.buffers;return n?S2(n.normal,t)+S2(n.alt,t):0}function mh(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function DI(e,t,r){const n=mh(e.fontBoundingBoxAscent)+mh(e.fontBoundingBoxDescent),a=mh(e.actualBoundingBoxAscent)+mh(e.actualBoundingBoxDescent);return Math.max(1,Math.floor(Math.ceil(n||a||t)*r))}const Ec=8,gh=36,_2=10,BI=1.08,QI=1.16,xh=6,PI=.94,OI=.08,FI=.12,$I=88,UI=36,zI=10,HI=14,WI=52;function Ld(e){return e?e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,""):""}const GI=80,VI=8;function bh(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function qI(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function YI(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 ZI(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),p=d.indexOf(";");if(p>=0){const m=d.slice(p+1);if(m&&m!=="?"){const x=YI(m);x!==null&&navigator.clipboard?.writeText(x).catch(()=>{})}}r=c+l}return{cleaned:n,remainder:""}}function KI(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 XI=new Set(["visibility","bfcache","online"]),JI=5e5,eE=1e5,Id=260,Ed=140,k2=80;function tE(e){return!e}let yu=null;const rE=[{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:"⏺⏸⏹✓✗"}],nE=()=>{if(yu)return yu;if(typeof document>"u"||!("fonts"in document))return yu=Promise.resolve(),yu;const e=document.fonts;return yu=Promise.allSettled(rE.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),yu},L2=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 I2(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function Nc(e,t,r){const n=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(n||t*r))}function sE(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 E2=new Map;function iE(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 p=E2.get(d);if(!p)try{const w=document.createElement("canvas").getContext("2d");if(!w)return null;w.font=`${r}px ${t}`;const v=w.measureText("M"),L=(Math.floor(v.width*l)+Math.round(n))/l,E=DI(v,r,a);L>=1&&E>=1&&(p={cellWidth:L,cellHeight:E},E2.set(d,p))}catch{return null}if(!p)return null;const m=Math.max(2,Math.floor(c.width/p.cellWidth)),x=Math.max(2,Math.floor(c.height/p.cellHeight));return!Number.isFinite(m)||!Number.isFinite(x)?null:{cols:m,rows:x}}async function N2(e){if(!e)return!1;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return t.remove(),r}catch{return!1}}}function aE(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 Nd(e,t,r){const n=zc(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 Jp(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,p=Math.floor(c/e.cols);return e.select(d,p,l-c),!0}function R2(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function oE(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,p=c?.width??window.innerWidth,m=c?.height??window.innerHeight,x=R2("--safe-top-inset"),y=R2("--safe-bottom-inset"),w=n?DL(n.terminal,n.anchor,n.focus):null,v=[];let S;if(a&&v.push({left:e-32,top:t-32,right:e+32,bottom:t+32}),n){const E=zc(n.terminal),{start:R,end:B}=xf(n.anchor,n.focus,n.terminal.cols),z=Gh(n.terminal,R),O=Gh(n.terminal,B);if(z&&v.push({left:z.x-24,top:z.y-48,right:z.x+24,bottom:z.y+4}),O&&E){const $=O.y+E.cellH;v.push({left:O.x-24,top:$-4,right:O.x+24,bottom:$+48})}if(w){const $=n.anchor.row*n.terminal.cols+n.anchor.col,V=n.focus.row*n.terminal.cols+n.focus.col,Z=$<=V,le=w.right-w.left,pe=n.anchor.row===n.focus.row?Z?w.left+le*.25:w.right-le*.25:(w.left+w.right)/2,ee=Gh(n.terminal,n.focus),_e=ee&&E?ee.y+E.cellH/2:t;S={vertical:n.focus.row<n.anchor.row?"below":"above",alignX:pe,focusX:ee?.x??e,focusY:_e}}}const L=BL({clientX:e,clientY:t,viewport:{left:l,top:d+x,right:l+p,bottom:d+m-y},terminal:r,width:$I,height:UI,margin:zI,fingerGap:HI,selection:w,avoid:v,preference:S,selectionGap:WI});return{left:L.left-r.left,top:L.top-r.top}}const Y3=k.forwardRef(({sessionKey:e,sessionId:t,isLayoutVisible:r=!0,chunks:n,onInput:a,onResize:c,onFlowControl:l,onTmuxScroll:d,tmuxScrollSensitivity:p=.55,onDoubleTap:m,onInputFocusChange:x,onMobileLongPressCopyResult:y,onMobilePasteResult:w,onReadyChange:v,onSizeSynchronizedChange:S,onWritesSettled:L,onWriteProgress:E,onCursorPositionChange:R,onDirectoryLinkActivate:B,terminalSettings:z,theme:O,className:$,enableTouchScroll:V,mobileLongPressMode:Z="arrows",autoFocus:le=!0,cursorVisible:be=!0,suppressSmoothScroll:pe=!1},ee)=>{const{t:_e}=Ur(),ze=k.useRef(null),Y=k.useRef(null),ce=k.useRef(null),qe=k.useRef(null),we=k.useRef(null),ye=k.useRef(pe);ye.current=pe;const Le=k.useRef(null),Be=k.useRef(a),ne=k.useRef(c),Fe=k.useRef(x),ke=k.useRef(l),Ee=k.useRef(v);Ee.current=v;const Pe=k.useRef(S);Pe.current=S;const Ne=k.useRef(L);Ne.current=L;const oe=k.useRef(E);oe.current=E;const We=k.useRef(R);We.current=R;const nt=k.useRef(B);nt.current=B;const gt=k.useRef(z.rendererMode),ue=k.useRef(""),Ze=k.useRef(0),at=k.useRef(!1),Ie=k.useRef(null),Ge=k.useRef(0),Ce=k.useRef(0),H=k.useRef(!1),ae=k.useRef(null),Ae=k.useRef(null),Ye=k.useRef(null),et=k.useRef(!1),St=k.useRef(null),Gt=k.useRef(()=>{}),Qt=k.useRef(null),wt=k.useRef(null),zt=k.useRef(void 0),Vt=k.useRef(null),Kt=k.useRef(!1),Ot=k.useRef(0),It=k.useRef(""),xe=k.useRef(null),Ve=k.useRef(null),ht=k.useRef(!1),q=k.useRef(typeof window<"u"?window.devicePixelRatio:1),ut=k.useRef(!1),qt=k.useRef(!1),tt=k.useRef(null),De=k.useRef(""),nr=k.useRef(0),Ke=k.useRef(null),_t=k.useRef(null),$t=k.useRef(null),yt=k.useRef(0),xt=k.useRef(0),Rt=k.useRef(0),Ct=k.useRef(null),fr=k.useRef(0),Yt=k.useRef(0),Sr=k.useRef(!1),pn=k.useRef(0),[,dr]=k.useReducer(T=>T+1,0),[me,Gr]=k.useReducer(T=>T+1,0),[ot,pt]=k.useState("loading"),[ir,Mn]=k.useState(null),[Xr,je]=k.useState(null);k.useEffect(()=>{const T=j=>{(j.target instanceof Element?j.target.closest("[data-termdock-terminal-dropzone]"):null)?.dataset.termdockTerminalDropzone===e&&je(String(j.detail))};return window.addEventListener("termdock:file-drop-error",T),()=>window.removeEventListener("termdock:file-drop-error",T)},[e]);const st=k.useMemo(()=>Fu("terminal"),[]),[bt,Br]=k.useState(!0),[Vr,Cr]=k.useState(!1);k.useEffect(()=>{if(!bt&&ot!=="loading"){Cr(!1);return}const T=window.setTimeout(()=>Cr(!0),160);return()=>window.clearTimeout(T)},[bt,ot]);const[qr,mn]=k.useState(!1),[on,zr]=k.useState({visible:!1,activeDir:""}),[un,Er]=k.useState(null),re=k.useRef(null),mt=k.useRef(!1),Mt=k.useRef({active:!1,anchor:null,focus:null,dragging:null}),[rr,Ar]=k.useState(null),[Fr,Xt]=k.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),Zr=k.useRef(Fr);Zr.current=Fr;const Jt=k.useRef(null),[Pr,Hr]=k.useState({active:!1,text:""}),ps=k.useRef(null),Mr=k.useRef(null);Be.current=a,ne.current=c,Fe.current=x,ke.current=l,gt.current=z.rendererMode;const jn=k.useRef(le);jn.current=le;const Tr=k.useRef(be);Tr.current=be;const Jr=k.useRef(V);Jr.current=V;const ln=k.useRef(r);ln.current=r;const ks=tE(!!d),{rendererMode:Dr,fontFamily:en,fontSize:xn,fontWeight:X,fontWeightBold:He,letterSpacing:Nt,lineHeight:Et,minimumContrastRatio:tr,drawBoldTextInBrightColors:jr,unicodeVersion:cr,customGlyphs:Cn,rescaleOverlappingGlyphs:Ls,fontLigatures:Xn,enableImages:cn,smoothScrolling:dn}=z,_r=Dr==="webgl",Or=k.useCallback(()=>{re.current!==null&&(clearTimeout(re.current),re.current=null),Er(null)},[]),Gn=k.useCallback((T,j)=>{re.current!==null&&(clearTimeout(re.current),re.current=null),mt.current=!1,Er(T),!j?.persistent&&(re.current=setTimeout(()=>{re.current=null,Er(null)},3e3))},[]);k.useEffect(()=>{if(!un)return;const T=()=>{Mt.current.active||Or()},j=()=>Or();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",j),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",j),document.removeEventListener("visibilitychange",j)}},[Or,un]),k.useEffect(()=>()=>{re.current!==null&&(clearTimeout(re.current),re.current=null)},[]);const Vn=k.useCallback(()=>{const T=ce.current,j=ze.current,Q=Mt.current;if(!T||!j||!Q.active||!Q.anchor||!Q.focus){Ar(null);return}const F=j.getBoundingClientRect(),ge=zc(T)?.cellH??16,{start:Se,end:Oe}=xf(Q.anchor,Q.focus,T.cols),Xe=Q.dragging==="start"?Q.focus:Q.dragging==="end"?Q.anchor:Se,dt=Q.dragging==="end"?Q.focus:Q.dragging==="start"?Q.anchor:Oe,er=(or,$r)=>{const nn=Gh(T,or);return nn?{left:nn.x-F.left,top:$r?nn.y-F.top:nn.y+ge-F.top}:null};Ar({start:er(Xe,!0),end:er(dt,!1)})},[]),gn=k.useCallback(T=>{const j=ce.current,Q=ze.current,F=Mt.current;if(!j||!Q||!F.active||!F.anchor||!F.focus)return;if(F.dragging){Or();return}const ge=Q.getBoundingClientRect(),Se={x:(ge.left+ge.right)/2,y:(ge.top+ge.bottom)/2};Gn(oE(T?.x??Se.x,T?.y??Se.y,ge,{terminal:j,anchor:F.anchor,focus:F.focus},T!==void 0),{persistent:!0})},[Or,Gn]),Jn=k.useCallback(()=>{const T=Mt.current;T.active=!1,T.anchor=null,T.focus=null,T.dragging=null,Ar(null),Or()},[Or]);k.useEffect(()=>{if(!rr)return;const T=ce.current;if(!T)return;const j=T.onScroll(()=>{Vn(),gn()}),Q=T.onResize(()=>Jn());return()=>{j.dispose(),Q.dispose()}},[rr,Vn,gn,Jn]),k.useEffect(()=>{V||Fe.current?.(!1)},[V]);const kr=k.useCallback((T,j,Q)=>{const F=(Q.element?.offsetWidth||0)/Q.cols||8,ge=(Q.element?.offsetHeight||0)/Q.rows||16,Se=Math.max(1,Math.min(Q.cols,Math.floor(T/F)+1)),Oe=Math.max(1,Math.min(Q.rows,Math.floor(j/ge)+1));return{x:Se,y:Oe}},[]),Lr=k.useCallback((T,j,Q)=>{const F=ce.current;if(!F)return!1;const ge=T>0?-1:1;if(F.modes?.mouseTrackingMode!=="none"){let Se,Oe;if(j!==void 0&&Q!==void 0){const er=kr(j,Q,F);Se=er.x,Oe=er.y}else Se=F.buffer.active.cursorX+1,Oe=F.buffer.active.cursorY+1;const dt=`\x1B[<${ge>0?64:65};${Se};${Oe}M`;return Be.current(dt),!0}if(F.buffer.active.type==="alternate"){const Se=ge>0?"\x1B[A":"\x1B[B";return Be.current(Se),!0}return null},[kr]),pr=k.useCallback(T=>{const j=ce.current;if(!j)return!1;const Q=Nc(ce.current,xn,Et),F=Ot.current+T,ge=Math.trunc(F/Q);return Ot.current=F-ge*Q,ge!==0?(j.scrollLines(ge),!0):!1},[xn,Et]),ns=k.useCallback(T=>{if(!ce.current)return!1;const F=Nc(ce.current,xn,Et)/Math.max(.1,p),ge=Ot.current+T;let Se=Math.trunc(ge/F);if(Ot.current=ge-Se*F,Se===0&&Math.abs(ge)>=F/3&&(Se=ge>0?1:-1,Ot.current=0),Se===0)return!1;const Oe=Se>0?"down":"up",Xe=Math.max(1,Math.min(Math.abs(Se),10));return d(Oe,Xe),!0},[xn,Et,d,p]),Un=k.useRef(Lr);Un.current=Lr;const En=k.useRef(pr);En.current=pr;const kn=k.useRef(ns);kn.current=ns;const ss=k.useRef(d);ss.current=d;const Wr=k.useRef({pointerId:null,tmuxActiveAtDown:!1});k.useEffect(()=>{if(!V)return;const T=ze.current;if(!T)return;const j=F=>{F.pointerType==="touch"&&(Wr.current.pointerId=F.pointerId,Wr.current.tmuxActiveAtDown=!!ss.current)},Q=F=>{F.pointerType==="touch"&&Wr.current.pointerId===F.pointerId&&(Wr.current.pointerId=null,Wr.current.tmuxActiveAtDown=!1)};return T.addEventListener("pointerdown",j,{capture:!0,passive:!0}),T.addEventListener("pointerup",Q,{capture:!0,passive:!0}),T.addEventListener("pointercancel",Q,{capture:!0,passive:!0}),()=>{T.removeEventListener("pointerdown",j,!0),T.removeEventListener("pointerup",Q,!0),T.removeEventListener("pointercancel",Q,!0)}},[V]);const tn=k.useCallback(()=>{if(Sr.current)return!1;const T=Wr.current;return T.pointerId!==null?!T.tmuxActiveAtDown:!ss.current},[]),G=k.useCallback((T,j,Q)=>{const F=Un.current(T,j,Q);return F!==null?F:ss.current?kn.current(T):En.current(T)},[]),Me=k.useCallback((T,j)=>{if(performance.now()<=Yt.current){Yt.current=0;return}const Q=ce.current;if(Q&&Q.modes?.mouseTrackingMode!=="none"){const F=kr(T,j,Q),ge=F.x,Se=F.y,Oe=`\x1B[<0;${ge};${Se}M`,Xe=`\x1B[<0;${ge};${Se}m`;Be.current(Oe),Be.current(Xe)}},[kr]),$e=k.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),Je=k.useCallback((T=700)=>{Ct.current=null,fr.current=$e()+T},[$e]),it=k.useCallback(()=>Jr.current&&$e()<=fr.current,[$e]),Tt=k.useCallback(()=>{const T=wt.current;return!T||typeof document>"u"?!1:document.activeElement===T},[]),kt=k.useCallback(()=>{if(typeof window>"u")return!1;const T=Xe=>{if(typeof document>"u")return 0;const dt=Number.parseFloat(document.documentElement.style.getPropertyValue(Xe)||"0");return Number.isFinite(dt)?dt:0},j=T("--kb-height");if(j>0)return j>=k2;const Q=window.visualViewport;if(!Q)return!1;const F=T("--app-base-vh")||window.innerHeight,ge=T("--safe-bottom-inset"),Se=Q.height+Q.offsetTop;return Math.max(0,Math.round(F-Se-ge))>=k2},[]),Dt=k.useCallback(()=>{Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),_t.current=null},[]),ft=k.useCallback(T=>{const j=ce.current;let Q="";for(const F of T)F.left&&(Q+=(j?bh(j,"D"):"\x1B[D").repeat(F.left)),F.right&&(Q+=(j?bh(j,"C"):"\x1B[C").repeat(F.right)),F.backspace&&(Q+="".repeat(F.backspace)),F.insert&&(Q+=F.insert);return Q},[]),Bt=k.useCallback(T=>{const j=T.value,Q=Ld(j),F=De.current;if(!(Jr.current&&!Q.includes("\r")&&!F.includes("\r"))){if(Q===F)return;let er=0;for(;er<F.length&&er<Q.length&&F[er]===Q[er];)er++;const or=F.length-er;or>0&&Be.current("".repeat(or));const $r=Q.slice(er);if($r){try{ce.current?.clearSelection()}catch{}Be.current($r)}De.current=Q,nr.current=Array.from(Q).length;return}const Se=w2(T),{ops:Oe,cursor:Xe}=yI(F,Q,nr.current,Se),dt=ft(Oe);if(dt){if(Oe.some(er=>er.insert))try{ce.current?.clearSelection()}catch{}Be.current(dt)}De.current=Q,nr.current=Xe},[ft]),W=k.useCallback((T,j)=>{const Q=T.value,F=Ld(Q),ge=De.current;if(F===ge){Dt();return}let Se=0;for(;Se<ge.length&&Se<F.length&&ge[Se]===F[Se];)Se++;const Oe=ge.length-Se;if(V&&!j?.immediate&&Oe>=VI){_t.current=T,Ke.current!==null&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{Ke.current=null;const dt=_t.current;_t.current=null,dt&&Bt(dt)},GI);return}Dt(),Bt(T)},[Dt,V,Bt]),N=k.useCallback(T=>{W(T,{immediate:!0}),Be.current("\r"),T.value="",De.current="",nr.current=0},[W]),U=k.useCallback((T,j,Q)=>{if(!T)return;Dt();const F=j??wt.current;F&&(F.value=""),De.current="",nr.current=0;try{ce.current?.clearSelection()}catch{}Jn();const ge=FL(T,Q);return Be.current(ge,{skipModifierTransform:!0,consumeModifier:Q?.consumeModifier,targeted:Q?.targeted,ownedPaste:Q?.ownedPaste})},[Dt]),K=k.useCallback((T,j)=>{const Q=Ld(T);return Q?(je(null),wp(Q)||(U(Q,j,{paste:!0,submitAfterPaste:!1}),Or()),!0):!1},[Or,U]);k.useEffect(()=>e8(T=>{if(T.sessionKey!==e||T.paths.length===0)return;const j=T.paths.map(Dc).join(" ");U(`${j} `);try{wt.current?.focus({preventScroll:!0})}catch{}}),[U,e]);const fe=k.useCallback(async(T,j)=>{je(null);try{const Q=await a3(T);return wp(`${Dc(Q)} `)||(U(`${Dc(Q)} `,j),Or()),!0}catch(Q){return je(Q instanceof Error?Q.message:"Image upload failed"),!1}},[Or,U]),Qe=k.useCallback(async(T,j)=>{je(null);try{const Q=await c3(T);if(!Q.length)return!1;const F=`${Q.map(Dc).join(" ")} `;return wp(F)||(U(F,j),Or()),!0}catch(Q){return je(Q instanceof Error?Q.message:"File upload failed"),!1}},[Or,U]),ve=k.useCallback(async(T,j)=>{je(null);try{const Q=f0()?.targetPeerId;let F;if(vo()?.readClipboardFiles){try{const{files:Oe,paths:Xe}=await l3();if(Xe.length)return K(`${Xe.map(Dc).join(" ")} `,T);if(Oe.length)return Qe(Oe,T)}catch(Oe){if(Oe instanceof o0)throw Oe;F=Oe}if(f0()?.targetPeerId!==Q)throw new Error("目标服务已切换,请重新粘贴")}if(j?.files.length){const Oe=j.files[0];return j.files.length===1&&Oe.type.startsWith("image/")?fe(Oe,T):Qe(j.files,T)}if(j?.text)return K(j.text,T);if(!vo()?.readClipboardImage){if(typeof navigator.clipboard?.read=="function"){const Oe=await navigator.clipboard.read(),Xe=await o3({read:async()=>Oe});if(Xe.length)return Qe(Xe,T);const dt=await ff({read:async()=>Oe});if(dt)return fe(dt,T);for(const er of Oe){if(!er.types.includes("text/plain"))continue;const or=await(await er.getType("text/plain")).text();return K(or,T)}return je("剪贴板未提供可读取的文字、图片或视频;视频可通过文件按钮选择上传。"),!1}return navigator.clipboard?.readText?K(await navigator.clipboard.readText(),T):!1}const ge=await ff(navigator.clipboard);if(ge)return fe(ge,T);if(!navigator.clipboard?.readText){if(F)throw F;return!1}const Se=await navigator.clipboard.readText();if(!Se&&F)throw F;return K(Se,T)}catch(Q){return je(Q instanceof Error?Q.message:"Clipboard read failed"),!1}},[Qe,fe,K]),lt=k.useCallback(T=>{if(Jt.current&&!T?.repositionFrozen)return null;const j=ce.current;if(!j||!j.element)return null;const Q=zc(j),ge=j.element.querySelector(".xterm-screen")??j.element,Se=ge.getBoundingClientRect(),Oe=Q?.cellW??(Se.width>0&&j.cols>0?Se.width/j.cols:8),Xe=Q?.cellH??(Se.height>0&&j.rows>0?Se.height/j.rows:17),dt=wt.current;let er=zt.current;dt&&(er===void 0||er!==null&&(!er.isConnected||!er.contains(dt)))&&(er=PL(dt),zt.current=er);const or=j.buffer.active,$r=or.cursorX*Oe,nn=or.cursorY*Xe,Pn=OL(ge,er??null,$r,nn),yr=Math.round(Pn.x),wn=Math.round(Pn.y),us={x:yr,y:wn,cellW:Oe,cellH:Xe,cursorX:or.cursorX};return Zr.current=us,Jt.current&&T?.repositionFrozen&&(Jt.current={...us}),Xt(Ds=>Math.abs(Ds.x-yr)<.5&&Math.abs(Ds.y-wn)<.5&&Math.abs(Ds.cellW-Oe)<.5&&Math.abs(Ds.cellH-Xe)<.5&&Ds.cursorX===or.cursorX?Ds:us),us},[]),vt=k.useRef(lt);vt.current=lt,k.useEffect(()=>{if(!V)return;let T=null,j=null;const Q=()=>{T!==null&&window.cancelAnimationFrame(T),j!==null&&window.cancelAnimationFrame(j),T=window.requestAnimationFrame(()=>{T=null,j=window.requestAnimationFrame(()=>{j=null,vt.current({repositionFrozen:!0})})})};return window.visualViewport?.addEventListener("resize",Q),window.visualViewport?.addEventListener("scroll",Q),document.addEventListener("termdock:viewport-keyboard-change",Q),()=>{T!==null&&window.cancelAnimationFrame(T),j!==null&&window.cancelAnimationFrame(j),window.visualViewport?.removeEventListener("resize",Q),window.visualViewport?.removeEventListener("scroll",Q),document.removeEventListener("termdock:viewport-keyboard-change",Q)}},[V]);const br=k.useCallback(T=>{let j=0;for(const Q of T){const F=Q.codePointAt(0)??0,ge=F>=4352&&F<=4447||F>=11904&&F<=12350||F>=12353&&F<=13311||F>=13312&&F<=19903||F>=19968&&F<=40959||F>=40960&&F<=42191||F>=44032&&F<=55203||F>=63744&&F<=64255||F>=65072&&F<=65103||F>=65280&&F<=65376||F>=65504&&F<=65510||F>=127744&&F<=129791;j+=ge?2:1}return j},[]),Lt=k.useCallback(T=>{const j=ce.current,{cellW:Q,cellH:F}=Fr;if(!j||!T)return{width:Math.max(1,Math.round(Q)),height:Math.max(1,Math.round(F)),whiteSpace:"pre"};const Se=Jt.current?.cursorX??j.buffer.active.cursorX,Oe=Math.max(1,j.cols),Xe=Math.max(1,br(T)),dt=Math.max(1,Oe-Se);if(Xe<=dt)return{width:Math.max(1,Math.round(Xe*Q)),height:Math.max(1,Math.round(F)),whiteSpace:"pre"};const er=Xe-dt,$r=1+Math.ceil(er/Oe);return{width:Math.max(1,Math.round(dt*Q)),height:Math.max(1,Math.round($r*F)),whiteSpace:"pre-wrap"}},[Fr,br]),rn=k.useCallback(()=>{zt.current=void 0;const T=vt.current();Jt.current={...T??Zr.current}},[]),yn=k.useCallback(()=>{Jt.current=null},[]),hn=k.useCallback(T=>{if(!ut.current&&Jt.current===null)return!1;if(ut.current=!1,Jt.current=null,Dt(),tt.current!==null&&(clearTimeout(tt.current),tt.current=null),qt.current=!1,T){T.value=De.current;try{T.setSelectionRange(T.value.length,T.value.length)}catch{}}return Hr(j=>j.active||j.text?{active:!1,text:""}:j),!0},[Dt]),Dn=k.useCallback((T,j)=>{const Q=wt.current;if(Q)try{Q.removeAttribute("readonly");const ge=typeof document<"u"&&document.activeElement===Q&&!kt(),Se=$e(),Oe=Se-pn.current;pn.current=Se,ge&&Oe>600?(Q.blur(),Q.removeAttribute("readonly"),Q.focus(),pn.current=$e()):Q.focus()}catch{}},[kt,$e]),zn=k.useCallback(T=>{xt.current=$e()+T},[$e]),hr=k.useCallback(()=>V?$e()<=xt.current:!1,[V,$e]),jt=k.useCallback(T=>{zn(T),Rt.current=$e()},[zn,$e]),Bn=k.useCallback(()=>{V&&wt.current?.removeAttribute("readonly")},[V]),qn=k.useCallback(T=>T instanceof HTMLElement&&(T.closest('[data-terminal-copy-popover="true"]')!==null||T.closest('[data-mobile-copy-button="true"]')!==null||T.closest("[data-selection-handle]")!==null),[]),Wa=k.useCallback(T=>{if(Bn(),jt(Id),!V||T.pointerType!=="touch"){Ct.current=null;return}const j=T.target;if(qn(j)){Je();return}un&&!(j instanceof HTMLElement&&j.closest('[data-terminal-copy-popover="true"]'))&&Or(),Ct.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,moved:!1}},[Or,V,jt,qn,un,Bn,Je]),Qn=k.useCallback(T=>{jt(Id);const j=Ct.current;!j||j.pointerId!==T.pointerId||Math.hypot(T.clientX-j.startX,T.clientY-j.startY)>12&&(j.moved=!0)},[jt]),is=k.useCallback(T=>{jt(Ed);const j=Ct.current;Ct.current=null,!(!V||T.pointerType!=="touch")&&(!j||j.pointerId!==T.pointerId||j.moved||it()||Dn(T.clientX,T.clientY))},[V,jt,Dn,it]),zi=k.useCallback(()=>{Ct.current=null,jt(Ed)},[jt]),da=k.useMemo(()=>({enableKinetic:!0}),[]),bs=k.useRef(()=>!1),Ga=k.useRef(Dn);Ga.current=Dn;const So=k.useCallback((T,j)=>{it()||Ga.current(T,j)},[it]),Hn=k.useRef(m);Hn.current=m;const ha=k.useRef(y);ha.current=y;const ms=k.useRef(w);ms.current=w;const Ia=k.useCallback(()=>{if(mt.current)return;mt.current=!0,Je();const T=ce.current,j=T?.hasSelection()?T.getSelection():"";try{T?.clearSelection()}catch{}Xs.flushSync(()=>{Jn()}),(async()=>{const Q=await N2(j);ha.current?.(Q)})()},[Jn,Je]),as=k.useCallback(T=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:T}}))},[]),{setupTouchScroll:Va,stopAllScroll:Js}=hI(ze,{...da,shouldCaptureTouch:bs.current,canStartScrollGesture:tn,onScroll:G,onScrollWithCoords:G,onClickWithCoords:Me,onTap:So,onClaimChange:as,tapThreshold:12,gestureName:`normal-scroll:${e}`});k.useEffect(()=>{if(!V)return;wt.current?.setAttribute("readonly","");const T=Va();return()=>{T()}},[V,Va]),k.useEffect(()=>{if(!V)return;let T=kt();const j=()=>{const Q=kt();if(T&&!Q){const F=wt.current;F&&typeof document<"u"&&document.activeElement===F&&(F.setAttribute("readonly",""),F.blur())}T=Q};return window.visualViewport?.addEventListener("resize",j),window.visualViewport?.addEventListener("scroll",j),document.addEventListener("termdock:viewport-keyboard-change",j),()=>{window.visualViewport?.removeEventListener("resize",j),window.visualViewport?.removeEventListener("scroll",j),document.removeEventListener("termdock:viewport-keyboard-change",j)}},[V,kt]),k.useEffect(()=>{if(!V)return;const T=ze.current;if(!T)return;const j=F=>{const Se=F.sourceCapabilities?.firesTouchEvents===!0,Oe=$e()-Rt.current<=1200;return!Se&&!Oe?!1:T.contains(F.target)},Q=F=>{j(F)&&(F.cancelable&&F.preventDefault(),F.stopImmediatePropagation(),F.stopPropagation())};return T.addEventListener("mousedown",Q,{capture:!0,passive:!1}),T.addEventListener("mouseup",Q,{capture:!0,passive:!1}),T.addEventListener("click",Q,{capture:!0,passive:!1}),document.addEventListener("mouseup",Q,{capture:!0,passive:!1}),()=>{T.removeEventListener("mousedown",Q,!0),T.removeEventListener("mouseup",Q,!0),T.removeEventListener("click",Q,!0),document.removeEventListener("mouseup",Q,!0)}},[V,$e]);const ei=k.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),Hs=k.useCallback(()=>{const T=ei.current;T.rafId!==null&&(cancelAnimationFrame(T.rafId),T.rafId=null)},[]),qa=k.useCallback((T,j,Q)=>{const F=ce.current;if(!F||!F.element||!F.cols||!F.rows)return null;const ge=ei.current,Se=F.element.getBoundingClientRect(),Oe=j??ge.lastX??Se.left+Se.width/2,Xe=Q??ge.lastY??Se.top+Se.height/2,dt=Oe-Se.left,er=Xe-Se.top,or=F.element.offsetWidth/F.cols||8,$r=F.element.offsetHeight/F.rows||16,nn=Math.max(1,Math.min(F.cols,Math.floor(dt/or)+1)),Pn=Math.max(1,Math.min(F.rows,Math.floor(er/$r)+1));return`\x1B[<${T==="up"?64:65};${nn};${Pn}M`},[]),Is=k.useCallback((T,j,Q,F)=>{if(j<=0)return;const ge=qa(T,Q,F);ge&&Be.current(j===1?ge:ge.repeat(j))},[qa]),fa=k.useRef(Is);fa.current=Is;const dl=k.useRef(()=>{}),Ya=k.useCallback(()=>{const j=Nc(ce.current,xn,Et)/Math.max(.1,p),Q=1+ei.current.instantSpeed*.1;return j/Math.min(6,Q)},[xn,Et,p]),os=k.useCallback(()=>{const T=ei.current;T.rafId=null;const j=Ya();let Q=0,F=0;for(;Q+F<xh&&T.remainder>=j;)T.remainder-=j,F++;for(;Q+F<xh&&T.remainder<=-j;)T.remainder+=j,Q++;if(F>0&&Is("down",F),Q>0&&Is("up",Q),Q+F>0)T.rafId=requestAnimationFrame(os);else if(T.pointerId!==null&&Math.abs(T.remainder)>=j/3){const Se=T.remainder>0?"down":"up";T.remainder=0,Is(Se,1),T.rafId=requestAnimationFrame(os)}},[Ya,Is]),Ms=k.useCallback(()=>{const T=ei.current;T.rafId===null&&typeof requestAnimationFrame<"u"&&(T.rafId=requestAnimationFrame(os))},[os]),Hi=k.useCallback(T=>{if(T.pointerType!=="touch")return!1;Hs();const j=ei.current;return j.pointerId=T.pointerId,j.lastX=T.clientX,j.lastY=T.clientY,j.startX=T.clientX,j.startY=T.clientY,j.gestureAxis=null,j.remainder=0,j.velocity=0,j.instantSpeed=0,j.didScroll=!1,!1},[Hs]),xi=k.useCallback((T,j)=>{if(Sr.current)return j?"release":"neutral";if(performance.now()<=Yt.current)return"neutral";const Q=ei.current;if(T.pointerType!=="touch"||T.pointerId!==Q.pointerId||Q.lastY==null)return"neutral";if(Q.gestureAxis===null&&Q.startX!==null&&Q.startY!==null){const Se=Math.abs(T.clientX-Q.startX),Oe=Math.abs(T.clientY-Q.startY);if(Se>_2||Oe>_2){if(Se>Oe*BI)return Q.gestureAxis="x","release";Oe>Se*QI&&(Q.gestureAxis="y")}}if(Q.gestureAxis==="x")return Q.lastX=T.clientX,Q.lastY=T.clientY,"release";if(Q.gestureAxis===null)return Q.lastX=T.clientX,Q.lastY=T.clientY,"neutral";const F=T.clientY-Q.lastY;Q.lastX=T.clientX,Q.lastY=T.clientY;const ge=-F;if(Q.remainder+=ge,Q.instantSpeed=Math.abs(ge),Q.velocity=Q.velocity*.45+ge*.55,j){const Oe=Nc(ce.current,xn,Et)/Math.max(.1,p);Math.abs(Q.remainder)>=Oe/3&&(Q.didScroll=!0,Ms())}return"claim"},[xn,Et,p,Ms]),bi=k.useCallback(T=>{const j=ei.current;if(T.pointerType!=="touch"||T.pointerId!==j.pointerId)return;if(Hs(),j.pointerId=null,j.lastX=null,j.lastY=null,j.startX=null,j.startY=null,j.instantSpeed=0,j.gestureAxis==="x"){j.gestureAxis=null;return}j.gestureAxis=null;const F=Nc(ce.current,xn,Et)/Math.max(.1,p);if(j.didScroll&&Math.abs(j.velocity)>F*OI){const ge=()=>{j.velocity*=PI,j.remainder+=j.velocity;const Se=1+Math.abs(j.velocity)*.1,Oe=F/Math.min(6,Se);if(Math.abs(j.velocity)<F*FI){if(Math.abs(j.remainder)>=Oe/3){const er=j.remainder>0?"down":"up";Is(er,1),j.remainder=0}j.velocity=0,j.rafId=null;return}let Xe=0,dt=0;for(;Xe+dt<xh&&j.remainder>=Oe;)j.remainder-=Oe,dt++;for(;Xe+dt<xh&&j.remainder<=-Oe;)j.remainder+=Oe,Xe++;dt>0&&Is("down",dt),Xe>0&&Is("up",Xe),j.rafId=requestAnimationFrame(ge)};j.rafId=requestAnimationFrame(ge)}else Math.abs(j.remainder)>=F/3&&Ms();j.didScroll&&T.stopImmediatePropagation()},[Hs,Is,Ms,p,xn,Et]),hl=k.useCallback(T=>{const j=ei.current;T.pointerType!=="touch"||T.pointerId!==j.pointerId||(Hs(),j.pointerId=null,j.lastX=null,j.lastY=null,j.startX=null,j.startY=null,j.gestureAxis=null,j.remainder=0,j.velocity=0,j.didScroll=!1)},[Hs]);b2({name:`tmux-scroll:${e}`,priority:uI,container:()=>ze.current,onPointerDown:V&&d?Hi:void 0,onPointerMove:V&&d?xi:void 0,onPointerUp:V&&d?bi:void 0,onPointerCancel:V&&d?hl:void 0});const ti=k.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}),Uo=k.useRef(null);Uo.current=ze.current;const pa=Uo,fl=Be,pl=k.useRef(Z);pl.current=Z;const ls=k.useCallback(T=>{const j=ti.current;j.gestureLocked!==T&&(j.gestureLocked=T,as(T))},[as]),js=k.useCallback(()=>{const T=ti.current;T.edgeScrollTimer!==null&&(clearInterval(T.edgeScrollTimer),T.edgeScrollTimer=null),T.edgeScrollDir=0},[]),Ri=k.useCallback(T=>{const j=ce.current,Q=ti.current;if(j){if(Q.mode==="copy"&&Q.copyStart){Q.copyDidSelect=Jp(j,Q.copyStart,T)||Q.copyDidSelect;return}if(Q.mode==="adjust"){const F=Mt.current;if(!F.active||!F.anchor)return;F.focus=jL(j,T),Jp(j,F.anchor,F.focus),Vn()}}},[Vn]),zo=k.useCallback((T,j)=>{const Q=ce.current,F=ti.current;if(!Q)return;const ge=zc(Q);if(!ge)return;const Se=ge.originTop,Oe=ge.originTop+Q.rows*ge.cellH,Xe=Math.max(28,ge.cellH*1.5),dt=j-Se,er=Oe-j;let or=0,$r=0;if(dt<Xe?(or=-1,$r=Math.min(1,(Xe-dt)/Xe)):er<Xe&&(or=1,$r=Math.min(1,(Xe-er)/Xe)),F.edgeClientX=T,F.edgeClientY=j,or===0){js();return}F.edgeScrollDir=or,F.edgeScrollLines=1+Math.round($r*5),F.edgeScrollTimer===null&&(F.edgeScrollTimer=setInterval(()=>{const nn=ce.current,Pn=ti.current;if(!nn||Pn.edgeScrollDir===0)return;if(Pn.mode!=="copy"&&Pn.mode!=="adjust"){js();return}nn.scrollLines(Pn.edgeScrollDir*Pn.edgeScrollLines);const yr=Nd(nn,Pn.edgeClientX,Pn.edgeClientY-gh);yr&&Ri(yr)},60))},[Ri,js]),Dl=k.useCallback(T=>{if(T.pointerType!=="touch")return!1;const j=pa.current;if(!j)return!1;const Q=T.target;if(!(Q instanceof HTMLElement)||!j.contains(Q)||Q.closest('[data-mobile-keyboard="true"]'))return!1;const F=ti.current;F.longPressMode=pl.current;const ge=Mt.current;if(ge.active&&F.pointerId===null){const Se=Q.closest("[data-selection-handle]");if(Se instanceof HTMLElement){const Oe=ce.current,Xe=Se.dataset.selectionHandle==="start"?"start":"end";if(Oe&&ge.anchor&&ge.focus){const dt=xf(ge.anchor,ge.focus,Oe.cols);return ge.anchor=Xe==="start"?dt.end:dt.start,ge.focus=Xe==="start"?dt.start:dt.end,ge.dragging=Xe,Or(),F.pointerId=T.pointerId,F.tapStartX=T.clientX,F.tapStartY=T.clientY,F.tapDidMove=!1,F.mode="adjust",Sr.current=!0,Je(1800),wt.current?.setAttribute("readonly",""),Js(),Hs(),xo(Ec),ls(!0),!0}}if(!Q.closest("[data-terminal-copy-popover]")){Jn();try{ce.current?.clearSelection()}catch{}}}if(F.pointerId!==null)return!0;if(Sr.current=!1,Hn.current){const Se=performance.now(),Oe=T.clientX,Xe=T.clientY;if(F.lastTapTime!==0&&Se-F.lastTapTime<=300&&Math.hypot(Oe-F.lastTapX,Xe-F.lastTapY)<=25)return xo(Ec),Yt.current=performance.now()+500,Hn.current?.(),mn(!0),Mr.current&&clearTimeout(Mr.current),Mr.current=setTimeout(()=>mn(!1),400),F.lastTapTime=0,!0}return F.holdTimer!==null&&(clearTimeout(F.holdTimer),F.holdTimer=null),F.joystickRepeatTimer!==null&&(clearTimeout(F.joystickRepeatTimer),F.joystickRepeatTimer=null),F.joystickDir="",F.copyStart=null,F.copyDidSelect=!1,F.pointerId=T.pointerId,F.originX=T.clientX,F.originY=T.clientY,F.tapStartX=T.clientX,F.tapStartY=T.clientY,F.tapDidMove=!1,F.mode="holding",F.longPressMode==="copy"&&ls(!0),F.holdTimer=setTimeout(()=>{if(F.holdTimer=null,F.mode==="holding"){if(F.longPressMode==="copy"){const Se=ce.current,Oe=Se?Nd(Se,F.tapStartX,F.tapStartY):null;if(!Se||!Oe){F.mode="idle";return}F.mode="copy",Sr.current=!0,Je(1800),wt.current?.setAttribute("readonly",""),F.copyStart=Oe,F.copyDidSelect=!1,Js(),Hs(),Se.clearSelection(),xo(Ec),ls(!0);return}F.mode="arrow",Sr.current=!0,Je(1e3),Js(),Hs(),xo(Ec),ls(!0),requestAnimationFrame(()=>{zr({visible:!0,activeDir:""})})}},350),!0},[ls,Or,Jn]),Es=k.useCallback((T,j)=>{if(T.pointerType!=="touch")return"neutral";const Q=ti.current;if(Q.mode==="arrow"&&T.pointerId!==Q.pointerId||Q.mode==="copy"&&T.pointerId!==Q.pointerId||Q.mode!=="arrow"&&Q.mode!=="copy"&&T.pointerId!==Q.pointerId)return"neutral";const F=T.clientX-Q.tapStartX,ge=T.clientY-Q.tapStartY;if(Math.hypot(F,ge)>10&&(Q.tapDidMove=!0),Q.mode==="holding"){if(!j)return Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Sr.current=!1,Q.mode="idle","neutral";const Se=T.clientX-Q.originX,Oe=T.clientY-Q.originY;return Q.longPressMode==="copy"&&Math.hypot(Se,Oe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Sr.current=!1,Q.mode="idle","release"):Math.hypot(Se,Oe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Q.mode="idle","release"):"claim"}if(Q.mode==="adjust"){if(!j)return"claim";Js();const Se=ce.current,Oe=Mt.current;if(!Se||!Oe.active||!Oe.anchor||!Oe.focus)return"claim";const Xe=Nd(Se,T.clientX,T.clientY-gh);return Xe&&(Ri(Xe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="copy"){if(!j)return"claim";Js();const Se=ce.current;if(!Se||!Q.copyStart)return"claim";const Oe=Nd(Se,T.clientX,T.clientY-gh);return Oe&&(Ri(Oe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="arrow"){if(!j)return"claim";const Se={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},Oe=T.clientX-Q.tapStartX,Xe=T.clientY-Q.tapStartY,dt=SI(Oe,Xe,Q.joystickDir);if(dt&&dt!==Q.joystickDir&&(Q.originX=T.clientX,Q.originY=T.clientY),dt){const er=T.clientX-Q.originX,or=T.clientY-Q.originY,$r=Math.hypot(er,or);if(Q.repeatIntervalMs=CI($r),dt!==Q.joystickDir){Q.joystickRepeatTimer!==null&&clearTimeout(Q.joystickRepeatTimer);const nn=Q.joystickDir==="";Q.joystickDir=dt,fl.current(Se[dt]);const Pn=performance.now();Pn-Q.lastHapticTime>120&&(xo(Ec),Q.lastHapticTime=Pn);const yr=nn?400:300;Q.joystickRepeatTimer=setTimeout(function wn(){if(Q.joystickDir!==dt)return;fl.current(Se[dt]);const us=performance.now();us-Q.lastHapticTime>120&&(xo(Ec),Q.lastHapticTime=us),Q.joystickRepeatTimer=setTimeout(wn,Q.repeatIntervalMs)},yr)}zr({visible:!0,activeDir:dt})}else Q.joystickRepeatTimer!==null&&(clearTimeout(Q.joystickRepeatTimer),Q.joystickRepeatTimer=null),Q.joystickDir="",zr({visible:!0,activeDir:""});return"claim"}return"neutral"},[ls,Ri,zo]),Ea=k.useCallback(T=>{if(T.pointerType!=="touch"||T.pointerId!==ti.current.pointerId)return;const j=ti.current;if(j.mode==="copy"){Js(),Hs(),js(),ls(!1);const F=ce.current;let ge=null;if(F&&j.copyStart&&(ge=Nd(F,T.clientX,T.clientY-gh),ge&&(j.copyDidSelect=Jp(F,j.copyStart,ge)||j.copyDidSelect)),F&&j.copyDidSelect&&F.hasSelection()&&j.copyStart){const Se=Mt.current;Se.active=!0,Se.anchor=j.copyStart,Se.focus=ge??j.copyStart,Se.dragging=null,Vn(),gn({x:T.clientX,y:T.clientY}),Je(1800),xo(Ec)}else ha.current?.(!1);j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle",Sr.current=!1;return}if(j.mode==="adjust"){Js(),Hs(),js(),ls(!1),Mt.current.dragging=null,Vn(),gn({x:T.clientX,y:T.clientY}),Je(1800),j.pointerId=null,j.mode="idle",Sr.current=!1;return}if(j.mode==="arrow"){Js(),Hs(),ls(!1),zr({visible:!1,activeDir:""}),j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.joystickRepeatTimer!==null&&(clearTimeout(j.joystickRepeatTimer),j.joystickRepeatTimer=null),j.joystickDir="",j.pointerId=null,j.mode="idle",Sr.current=!1;return}const Q=pa.current;if(Q&&!j.tapDidMove){const F=T.target;F instanceof HTMLElement&&Q.contains(F)&&!F.closest('[data-mobile-keyboard="true"]')&&(j.lastTapTime=performance.now(),j.lastTapX=T.clientX,j.lastTapY=T.clientY)}else j.tapDidMove&&(j.lastTapTime=0);j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.joystickRepeatTimer!==null&&(clearTimeout(j.joystickRepeatTimer),j.joystickRepeatTimer=null),j.joystickDir="",ls(!1),Sr.current=!1,j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle"},[ls,Js,Je,js,Vn,gn]),ml=k.useCallback(()=>{const T=ti.current;ls(!1),js(),T.mode==="arrow"&&zr({visible:!1,activeDir:""}),T.mode==="adjust"&&(Mt.current.dragging=null,Vn(),gn()),T.holdTimer!==null&&(clearTimeout(T.holdTimer),T.holdTimer=null),T.joystickRepeatTimer!==null&&(clearTimeout(T.joystickRepeatTimer),T.joystickRepeatTimer=null),T.joystickDir="",Sr.current=!1,T.copyStart=null,T.copyDidSelect=!1,T.pointerId=null,T.tapDidMove=!1,T.mode="idle"},[ls,js,Vn,gn]);b2({name:`long-press:${e}`,priority:cI,container:()=>ze.current,onPointerDown:V?Dl:void 0,onPointerMove:V?Es:void 0,onPointerUp:V?Ea:void 0,onPointerCancel:V?ml:void 0});const es=k.useCallback((T={})=>{Ce.current+=1,ue.current="",Ae.current=null,Ze.current=0,et.current=!1,St.current=null,at.current&&(at.current=!1,T.notifyFlowResume===!0&&ke.current?.(!1)),Ie.current=null,H.current=!1,ae.current=null,It.current=""},[]),Wi=k.useCallback((T="unknown")=>{const j=Le.current,Q=ce.current,F=ze.current;if(!j||!Q||!F||!Q.element||!Q.cols||!Q.rows)return;const ge=F.getBoundingClientRect();if(ge.width<24||ge.height<24){st("skip fit: container too small",{reason:T,width:Math.round(ge.width),height:Math.round(ge.height)});return}try{const Se={cols:Q.cols,rows:Q.rows},Oe=Q.buffer.active,Xe=WL(Oe.type,Oe.baseY,Oe.viewportY),dt=j.proposeDimensions();if(!dt||dt.cols<=0||dt.rows<=0)return;const er=C2(Q,Se.rows),or=UL({reason:T,currentCols:Se.cols,currentRows:Se.rows,proposedCols:dt.cols,proposedRows:dt.rows});let $r=0;if(or.accept){ri.current&&ss.current&&(Se.cols!==dt.cols||Se.rows!==dt.rows)&&we.current?.begin();const Pn=Q.options.smoothScrollDuration;try{Q.options.smoothScrollDuration=0,Q.resize(dt.cols,dt.rows),$r=C2(Q,dt.rows),Xe&&Q.scrollToBottom()}finally{Q.options.smoothScrollDuration=Pn}Ot.current=0}(er>0||$r>0)&&(Q.refresh(0,Math.max(0,Q.rows-1)),st("xterm buffer invariant repaired",{reason:T,before:er,after:$r,cols:Q.cols,rows:Q.rows}));const nn={cols:Q.cols,rows:Q.rows};st("fit",{reason:T,backend:"xterm",width:Math.round(ge.width),height:Math.round(ge.height),before:Se,proposed:dt,next:nn,hysteresis:or,changed:Se.cols!==nn.cols||Se.rows!==nn.rows})}catch{we.current?.cancel()}},[st]),Mi=k.useCallback(T=>{const j=ce.current;if(j)try{j.refresh(0,Math.max(0,j.rows-1)),st("terminal refreshed (sync)",{reason:T,cols:j.cols,rows:j.rows,hasWebgl:!!xe.current})}catch(Q){st("terminal refresh (sync) failed",{reason:T,error:Q})}},[st]),Gi=k.useCallback(T=>{const j=Ve.current;if(j){try{j.dispose()}catch{}Ve.current=null}const Q=xe.current;if(!Q)return!1;we.current?.cancel();try{Q.dispose()}catch{}return xe.current=null,st("renderer disposed",{type:"webgl",reason:T}),!0},[st]),gs=k.useCallback((T,j)=>{if(xe.current)return!0;try{const Q=new $_({customGlyphs:Cn});return Ve.current=Q.onContextLoss(()=>{st("webgl context loss",{reason:"onContextLoss"}),ht.current=!0,typeof window<"u"&&window.setTimeout(()=>{cs("webgl-context-loss",{forceRendererRecreate:!0})},0)}),we.current?.cancel(),T.loadAddon(Q),xe.current=Q,ht.current=!1,st("renderer",{type:"webgl",reason:j,mobile:V,mode:gt.current}),Mi(`webgl-enabled:${j}`),Wi(`webgl-enabled:${j}`),Di.current=!0,!0}catch(Q){return st("webgl load failed, fallback to dom renderer",{reason:j,error:Q,mobile:V,mode:gt.current}),!1}},[st,Cn,V,Wi,Mi]),Ws=200,Bl=k.useRef(0),Vi=k.useRef(new Map),qi=k.useRef(new Map),fn=k.useRef(Kp()),ma=k.useRef(null),Yi=k.useRef(null),Na=k.useRef(-1),ji=k.useRef(new Map),Di=k.useRef(!1),ri=k.useRef(!1),ws=k.useRef(g2()),Gs=k.useRef(null),Bi=k.useRef(null),Ra=k.useCallback(()=>{Gs.current!==null&&(clearTimeout(Gs.current),Gs.current=null),Bi.current=null},[]),ni=k.useCallback(()=>{const T=Vi.current;T.forEach(j=>cancelAnimationFrame(j)),T.clear(),qi.current.clear()},[]),ys=k.useCallback(()=>{ma.current!==null&&(window.clearTimeout(ma.current),ma.current=null)},[]),Za=k.useRef(()=>{}),Ka=k.useCallback(T=>{ys(),Pe.current?.(!1),ne.current(T.cols,T.rows,T.seq),ma.current=window.setTimeout(()=>{ma.current=null;const j=m2(fn.current,T.seq);fn.current=j.state,j.request&&ri.current?(st("resize ack timeout; retrying",{seq:T.seq,retrySeq:j.request.seq,cols:j.request.cols,rows:j.request.rows}),Za.current(j.request)):j.exhausted&&(we.current?.cancel(),st("resize ack timeout; leaving size unconfirmed",{seq:T.seq,cols:T.cols,rows:T.rows}))},1200)},[ys,st]);Za.current=Ka;const As=k.useCallback((T,j)=>{if(!ri.current)return;const Q=YL(fn.current,{cols:T,rows:j});fn.current=Q.state,Q.request&&Ka(Q.request)},[Ka]),Xa=k.useCallback((T,j)=>{const Q=tI(ws.current,Date.now());if(Q.action==="send"){Bi.current=null,As(T,j);return}Bi.current={cols:T,rows:j},Gs.current===null&&(Gs.current=setTimeout(()=>{Gs.current=null;const F=Bi.current;Bi.current=null,F&&(ws.current=rI(Date.now()),As(F.cols,F.rows))},Math.max(0,Q.readyAt-Date.now())))},[As]),Ql=1500,Ho=400,Co=k.useRef(0),ga=k.useRef(0),Ma=k.useCallback((T,j,Q)=>{if(!Number.isFinite(T)||!Number.isFinite(j)||T<=0||j<=0)return;const F=Math.floor(T),ge=Math.floor(j);fn.current=XL(fn.current,{cols:F,rows:ge}),Co.current=Date.now(),st("pty-size broadcast received",{cols:F,rows:ge,source:Q??"unknown"})},[st]),Wo=k.useCallback(T=>{const j=ce.current;if(!j||!j.cols||!j.rows||!ri.current||typeof document<"u"&&(document.visibilityState!=="visible"||!Cu()))return;const Q=Date.now();if(Q-Co.current<Ql||Q-ga.current<Ho)return;const F=j.cols,ge=j.rows,Se=fn.current.confirmed;Se&&Se.cols===F&&Se.rows===ge||(ga.current=Q,st("ensureSizeMatches push",{reason:T,cols:F,rows:ge,lastServerSize:Se}),As(F,ge))},[st,As]),xa=k.useCallback((T,j)=>{const Q=ce.current,F=Le.current;if(!Q||!F)return;if(!Di.current){st("refresh skipped: renderer not ready",{reason:T});return}if(j.dedupeKey!==void 0){if(ji.current.get(T)===j.dedupeKey){st("refresh deduped",{reason:T,dedupeKey:j.dedupeKey});return}ji.current.set(T,j.dedupeKey)}st("refresh",{reason:T,options:j});const ge=j.forceRendererRecreate===!0||ht.current||_r&&!!xe.current&&XI.has(T)&&/Android/i.test(navigator.userAgent);let Se=!1;ge&&(ht.current=!1,_r?(Gi(`refresh:${T}`),gs(Q,`refresh:${T}`)||Mi(`refresh:${T}:webgl-fallback`),Se=!0):(Mi(`refresh:${T}`),Se=!0)),VL(j.forceRedraw===!0,T==="dpr-change",Se)?Mi(`refresh:${T}`):Se||st("terminal redraw skipped: fit/write already repaints",{reason:T});const Oe={cols:Q.cols,rows:Q.rows};Wi(`refresh:${T}`);const Xe={cols:Q.cols,rows:Q.rows};if(j.skipResizePush||zL({before:Oe,after:Xe,lastServerSize:fn.current.confirmed,reconcileServerSize:j.reconcileServerSize})&&Xa(Xe.cols,Xe.rows),!j.skipScrollToBottom&&T!=="resize"&&T!=="dpr-change"){const er=requestAnimationFrame(()=>{const nn=ce.current;if(nn&&nn.buffer.active.type!=="alternate")try{nn.scrollToBottom()}catch{}}),or=Vi.current,$r=or.get(T);$r!==void 0&&cancelAnimationFrame($r),or.set(T,er)}},[st,_r,Gi,gs,Mi,Wi,Xa]),cs=k.useCallback((T,j={})=>{if(ce.current,T==="session-key-change"&&(fn.current=Kp(),ys(),Ra(),ws.current=g2(),ji.current.clear(),ni()),!j.force&&(T==="visibility"||T==="bfcache"||T==="online")){const F=Date.now();if(F-Bl.current<Ws){st("refresh throttled",{reason:T});return}Bl.current=F}if(qi.current.set(T,j),Vi.current.has(T))return;const Q=requestAnimationFrame(()=>{const F=qi.current.get(T)??{};Vi.current.delete(T),qi.current.delete(T),xa(T,F)});Vi.current.set(T,Q)},[st,ni,ys,Ra,xa]),Go=k.useCallback(T=>{const j=Vi.current.get(T);if(j===void 0)return;const Q=qi.current.get(T)??{};cancelAnimationFrame(j),Vi.current.delete(T),qi.current.delete(T),xa(T,Q)},[xa]);dl.current=()=>Go("resize"),k.useEffect(()=>()=>{ni(),Vt.current!==null&&(window.clearTimeout(Vt.current),Vt.current=null)},[e,ni]),k.useEffect(()=>{fn.current=Kp(),ys(),ji.current.clear()},[e,ys]);const Zi=k.useCallback(()=>{if(H.current)return;const T=ce.current;if(!T){es();return}if(!ue.current)return;const j=ue.current,Q=j.length,F=Ae.current,ge=et.current;ue.current="",Ae.current=null,et.current=!1,H.current=!0;let Se=null;ge&&(Se=St.current??{depth:0},St.current=Se,Se.depth+=1);const Oe=we.current,Xe=Oe?.generation;T.write(j,()=>{if(Se&&(Se.depth-=1),Xe!==void 0&&Oe?.written(Xe),H.current=!1,Ze.current-=Q,Ze.current<0&&(Ze.current=0),F!==null&&oe.current?.(F),at.current&&Ze.current<eE&&(at.current=!1,ke.current?.(!1)),ue.current){Zi();return}const dt=++Ce.current,er=()=>{if(dt!==Ce.current||H.current||ue.current)return;const or=T.buffer.active;Ne.current?.({x:or.cursorX,y:or.cursorY,rows:T.rows,lastProcessedChunkId:ae.current})};typeof window>"u"?er():window.requestAnimationFrame(()=>{window.requestAnimationFrame(er)})})},[es]);Gt.current=Zi;const gl=k.useCallback(()=>{if(Ie.current!==null)return;const T=++Ge.current;Ie.current=T,queueMicrotask(()=>{Ie.current===T&&(Ie.current=null,Zi())})},[Zi]),se=k.useCallback((T,j,Q=!1)=>{if(!T)return;Ce.current+=1,ue.current+=T,Ae.current=j,et.current=et.current||Q,Ze.current+=T.length;const F=Ye.current;(F===null||j>F)&&(Ye.current=j),!at.current&&Ze.current>=JI&&(at.current=!0,ke.current?.(!0)),gl()},[gl]);return k.useEffect(()=>{let T=!1,j=null,Q=null,F=[];const ge=ze.current;return ge?(ge.tabIndex=V?-1:0,(async()=>{if(Ee.current?.(!1),pt("loading"),Mn(null),Br(!0),await nE(),!T)try{const Oe=iE(ge,L2(en),xn,Nt,Et),Xe=new vA({...Oe?{cols:Oe.cols,rows:Oe.rows}:{},allowProposedApi:!0,fontFamily:L2(en),fontSize:xn,fontWeight:I2(X),fontWeightBold:I2(He),theme:sE(O),logLevel:"off",cursorBlink:!_r,cursorStyle:"block",cursorInactiveStyle:Tr.current?"bar":"none",scrollback:d?2e3:5e3,scrollbar:{showScrollbar:!1},allowTransparency:zS(Dr,cn),convertEol:ks,drawBoldTextInBrightColors:jr,rescaleOverlappingGlyphs:Ls,minimumContrastRatio:tr,letterSpacing:Nt,lineHeight:Et,smoothScrollDuration:dn&&!ye.current?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),dt=new wA;Xe.loadAddon(dt),Xe.loadAddon(new V_),Xe.registerLinkProvider(jI(Xe,(yr,wn)=>{nt.current?.(yr,wn)}));const er=new ek;Xe.loadAddon(er),Xe.unicode.activeVersion=cr,Xe.loadAddon(new lk({highlightLimit:1e3}));const or=new fk;Xe.loadAddon(or),qe.current=or,Xe.loadAddon(new ML);try{Xe.loadAddon(new mk(void 0,new R3))}catch(yr){st("clipboard addon skipped",{error:yr})}j=Xe,ce.current=Xe,Le.current=dt,q.current=typeof window<"u"?window.devicePixelRatio:1,Xe.open(ge),we.current=qL(Xe),Xn&&Xe.loadAddon(new RL({fontFeatureSettings:iI,fallbackLigatures:aI}));try{const yr=Xe._core;yr?.coreService&&(yr.coreService.isCursorInitialized=!0),Xe.refresh(0,Xe.rows-1)}catch{}_r?(gs(Xe,"init"),Di.current=!0):(st("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:V,mode:Dr}),Di.current=!0),Br(!1),Gr();const $r=yr=>{if(yr.ctrlKey||yr.metaKey){yr.preventDefault();const wn=yr.deltaY>0?-1:1;Ph(t,xn+wn)}};if($t.current=$r,ge.addEventListener("wheel",$r,{passive:!1}),!V){let yr=0,wn=null,us=null,Ds=null;const pc=()=>{Ds=null,dl.current();const Vs=Nc(ce.current,xn,Et),Ki=yt.current+yr;yr=0;const _o=Math.trunc(Ki/Vs);if(yt.current=Ki-_o*Vs,_o!==0){const yi=_o>0?"down":"up",ko=ce.current,tu=Math.max(3,Math.floor((ko?.rows??24)/2)),vi=Math.abs(_o);vi>tu&&(yt.current=0),fa.current(yi,Math.min(vi,tu),wn??void 0,us??void 0)}};Xe.attachCustomWheelEventHandler(Vs=>{if(Vs.ctrlKey||Vs.metaKey||Vs.shiftKey)return!0;if(Vs.deltaY===0)return!1;if(!ce.current||!ss.current)return!0;const _o=Nc(ce.current,xn,Et);let yi=Vs.deltaY;return Vs.deltaMode===1?yi=Vs.deltaY*_o:Vs.deltaMode===2&&(yi=Vs.deltaY*(ge.clientHeight||_o*20)),yr+=yi,wn=Vs.clientX,us=Vs.clientY,Ds===null&&(Ds=requestAnimationFrame(pc)),Vs.preventDefault(),!1})}const nn=KI(ge);if(nn?(nn.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Y.current=nn,dr()):Y.current=null,cs("mount",{skipResizePush:!0,skipScrollToBottom:!0}),jn.current&&(V?Xe.focus():wt.current?.focus({preventScroll:!0})),V||vt.current(),F.push(Xe.onRender(()=>{const yr=Xe.buffer.active;We.current?.({x:yr.cursorX,y:yr.cursorY,rows:Xe.rows}),V||vt.current()})),!V){try{const yr=Xe.textarea;if(yr){yr.tabIndex=-1,yr.setAttribute("aria-hidden","true"),yr.setAttribute("readonly",""),yr.value="";const wn=()=>{wt.current?.focus({preventScroll:!0})};yr.addEventListener("focus",wn),F.push({dispose:()=>yr.removeEventListener("focus",wn)})}}catch{}try{F.push(Xe.onCursorMove(()=>vt.current())),F.push(Xe.onResize(()=>vt.current()))}catch{}}F.push(Xe.onData(yr=>{const wn=St.current;wn!==null&&wn.depth>0||Be.current(yr)}));const Pn=yr=>{const wn=typeof window<"u"?window.devicePixelRatio:1,us=Math.abs(wn-q.current)>.001;return us&&(q.current=wn,st("device pixel ratio changed",{value:wn,source:yr})),us};if(Q=new ResizeObserver(yr=>{if(!HL(!!Jr.current,ln.current)){st("resize observer skipped: hidden mobile session");return}zt.current=void 0;const wn=yr[0];wn&&st("resize observer",{width:Math.round(wn.contentRect.width),height:Math.round(wn.contentRect.height)});const us=Pn("resize-observer");cs(us?"dpr-change":"resize")}),Q.observe(ge),typeof window<"u"){const yr=()=>{Pn("window-resize")&&cs("dpr-change")};window.addEventListener("resize",yr),F.push({dispose:()=>window.removeEventListener("resize",yr)});const wn=window.visualViewport;if(wn){const us=()=>{Pn("visual-viewport-resize")&&cs("dpr-change")};wn.addEventListener("resize",us),F.push({dispose:()=>wn.removeEventListener("resize",us)})}}Wi("init-fit"),pt("ready"),Ee.current?.(!0)}catch(Oe){console.error("Failed to initialize terminal:",Oe),Br(!1),pt("error"),Mn(Oe instanceof Error?Oe.message:"Failed to load terminal")}})(),()=>{Ee.current?.(!1),T=!0,Fe.current?.(!1),Qt.current?.(),Qt.current=null,ut.current=!1,tt.current!==null&&(clearTimeout(tt.current),tt.current=null),qt.current=!1,Jt.current=null,Dt(),Hr({active:!1,text:""});for(const Oe of F)Oe.dispose();Q?.disconnect(),$t.current&&(ge.removeEventListener("wheel",$t.current),$t.current=null),we.current?.dispose(),we.current=null,Gi("component-unmount"),j?.dispose(),ce.current=null,Le.current=null,Y.current=null,es({notifyFlowResume:!0}),ys(),Ra()}):void 0},[Wi,en,xn,X,He,Nt,Et,tr,jr,cr,Cn,Ls,Xn,cn,dn,O,es,Dt,V,gs,Gi,st,ys,Ra]),k.useEffect(()=>{const T=ce.current;T&&(T.options.smoothScrollDuration=dn&&!pe?125:0)},[dn,pe,me]),k.useEffect(()=>{const T=ce.current;T&&(T.options.cursorInactiveStyle=be?"bar":"none",be||T.blur())},[be,me]),k.useEffect(()=>{const T=ce.current;if(T){if(_r){if(T.options.cursorBlink=!1,gs(T,"renderer-mode-change")&&cn&&!Kt.current)try{T.loadAddon(new Gk({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),Kt.current=!0}catch(Q){st("image addon skipped",{error:Q})}return}T.options.cursorBlink=!0,Gi("renderer-mode-change")&&(Mi("renderer-mode-change:webgl-disabled"),Wi("renderer-mode-change:webgl-disabled"))}},[_r,cn,gs,Gi,Mi,Wi,st]),k.useEffect(()=>{const T=ce.current;T&&(ae.current!==null&&T.reset(),es(),De.current="",nr.current=0,wt.current&&(wt.current.value=""),cs("session-reset",{skipScrollToBottom:!0}),jn.current&&(Jr.current?T.focus():wt.current?.focus({preventScroll:!0})))},[e,me,cs,es]),k.useEffect(()=>{if(!V||typeof document>"u")return;let T=null;const j=()=>{T=null;const F=wt.current;if(!F||document.activeElement!==F||ut.current)return;const ge=De.current,Se=Ld(F.value);if(Se!==ge||Se.includes("\r")||!kt())return;const Oe=Math.min(w2(F),Array.from(Se).length),Xe=Oe-nr.current;if(Xe===0)return;const dt=ce.current,er=Xe<0?(dt?bh(dt,"D"):"\x1B[D").repeat(-Xe):(dt?bh(dt,"C"):"\x1B[C").repeat(Xe);Be.current(er),nr.current=Oe},Q=()=>{T===null&&(T=requestAnimationFrame(j))};return document.addEventListener("selectionchange",Q),()=>{document.removeEventListener("selectionchange",Q),T!==null&&cancelAnimationFrame(T)}},[V,kt]),k.useEffect(()=>{if(!V)return;const T=Va();return Qt.current=T,()=>{T(),Qt.current=null}},[V,Va]),k.useEffect(()=>{const T=ce.current;if(T)try{T.options.scrollback=d?0:1e3}catch{}},[d,me]),k.useEffect(()=>{const T=ce.current;if(!T)return;if(n.length===0){ae.current!==null&&(T.reset(),es(),cs("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const j=ae.current;let Q,F=!1;if(j===null)Q=n;else{const ge=n.findIndex(Se=>Se.id===j);ge>=0?Q=n.slice(ge+1):(Q=n,F=!0)}if(Q.length>0){const ge=Q.map(or=>or.data).join(""),Se=It.current+ge,{cleaned:Oe,remainder:Xe}=ZI(Se);It.current=Xe;const dt=Ye.current,er=dt!==null&&(Q[0].id<=dt||F);Oe?se(Oe,Q[Q.length-1].id,er):oe.current?.(Q[Q.length-1].id)}ae.current=n[n.length-1].id},[n,me,se,cs,es]),k.useImperativeHandle(ee,()=>({serializeSnapshot:()=>ce.current?qe.current?.serialize({scrollback:100})??null:null,focus:()=>{if(Jr.current){Dn();return}wt.current?.focus({preventScroll:!0})},blur:()=>{const T=wt.current;hn(T),T&&typeof document<"u"&&document.activeElement===T&&T.blur(),Jr.current&&T?.setAttribute("readonly",""),Fe.current?.(!1)},clear:()=>{const T=ce.current;T&&(T.reset(),es(),cs("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},prepareScreenReplacement:()=>{es({notifyFlowResume:!0})},copySelectionOrViewport:async()=>{const T=ce.current;if(!T)return!1;const j=T.hasSelection()?T.getSelection():aE(T),Q=await N2(j);return Q&&T.hasSelection()&&Or(),Q},pasteClipboardText:async()=>{Je();const T=await ve(wt.current);return ms.current?.(T),T},sendSequence:(T,j)=>U(T,null,j),getDimensions:()=>{const T=ce.current;return!T||!T.cols||!T.rows?null:{cols:T.cols,rows:T.rows}},requestRefresh:cs,setSessionReady:T=>{ri.current=T,T||(we.current?.cancel(),ys(),fn.current=JL(fn.current),Yi.current=null,Na.current=-1,Pe.current?.(!1))},acknowledgeResize:T=>{if(!T.ok&&typeof T.seq=="number"){const Se=m2(fn.current,T.seq);if(!Se.request&&!Se.exhausted)return;ys(),fn.current=Se.state,Se.request&&ri.current?Za.current(Se.request):Se.exhausted&&we.current?.cancel();return}const j=KL(fn.current,T);if(!j.accepted)return;ys(),fn.current=j.state,st("resize acknowledged",{seq:T.seq,ok:T.ok,cols:T.cols,rows:T.rows,screenSyncPending:T.screenSyncPending===!0,screenSyncGeneration:T.screenSyncGeneration});const Q=ce.current,F=j.state.confirmed;if(!!!(Q&&F&&Q.cols===F.cols&&Q.rows===F.rows)){Pe.current?.(!1);return}if(T.screenSyncPending&&typeof T.screenSyncGeneration=="number"){Yi.current=T.screenSyncGeneration;const Se=Na.current>=T.screenSyncGeneration;Pe.current?.(Se),Se&&(Yi.current=null);return}Yi.current=null,Pe.current?.(!0)},notifyScreenSynchronized:T=>{if(!Number.isFinite(T))return;Na.current=Math.max(Na.current,T);const j=Yi.current;if(j===null||T<j)return;Yi.current=null;const Q=ce.current,F=fn.current.confirmed;Pe.current?.(!!(Q&&F&&Q.cols===F.cols&&Q.rows===F.rows))},notifyServerSize:Ma,ensureSizeMatches:Wo,requestPtyRedraw:()=>{const T=ce.current;if(!T||!ri.current||fn.current.pending||Yi.current!==null)return;const j=ZL(fn.current,{cols:T.cols,rows:T.rows});fn.current=j.state,Za.current(j.request)}}),[V,hn,Dn,es,ve,U,cs,ys,st,As,Ma,Wo]),s.jsxs("div",{ref:ze,"data-termdock-terminal-dropzone":e,className:`relative h-full w-full terminal-viewport-container ${$||""}`,style:{backgroundColor:O.background,touchAction:on.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:Wa,onPointerMoveCapture:Qn,onPointerUpCapture:is,onPointerCancelCapture:zi,onTouchStartCapture:T=>{if(qn(T.target)){Je(),jt(Id);return}Bn(),jt(Id)},onTouchMoveCapture:()=>jt(Id),onTouchEndCapture:()=>jt(Ed),onTouchCancelCapture:()=>jt(Ed),onMouseDown:T=>{V||T.button===0&&(Vt.current!==null&&(window.clearTimeout(Vt.current),Vt.current=null),requestAnimationFrame(()=>{try{wt.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:T=>{V||T.button===0&&(Vt.current!==null&&window.clearTimeout(Vt.current),Vt.current=window.setTimeout(()=>{Vt.current=null;try{wt.current?.focus({preventScroll:!0})}catch{}},0))},children:[Xr&&s.jsx("button",{type:"button",role:"alert",onClick:()=>je(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:Xr}),un&&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:un.left,top:un.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:T=>{Je(),T.stopPropagation()},onPointerUp:T=>{T.preventDefault(),T.stopPropagation(),Ia()},onTouchStart:T=>{Je(),T.stopPropagation()},onTouchEnd:T=>{T.preventDefault(),T.stopPropagation(),Ia()},onClick:T=>{T.preventDefault(),T.stopPropagation(),Ia()},children:[s.jsx(t8,{size:14,strokeWidth:2.4}),s.jsx("span",{children:_e("common.copy")})]}),rr?.start&&s.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:rr.start.left,top:rr.start.top,transform:"translate(-50%, -100%)",touchAction:"none"},onPointerDown:T=>T.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)]"})]})}),rr?.end&&s.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:rr.end.left,top:rr.end.top,transform:"translate(-50%, 0)",touchAction:"none"},onPointerDown:T=>T.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)]"})]})}),Vr&&bt&&s.jsx(xI,{}),Vr&&ot==="loading"&&!bt&&s.jsx(V3,{}),ot==="error"&&s.jsx(bI,{message:ir||void 0,onRetry:()=>{window.location.reload()}}),ot==="ready"&&s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:wt,"aria-label":_e("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",...V?{inset:0,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",pointerEvents:"auto",fontSize:"16px"}:(()=>{const T=Fr.x,j=Fr.y,Q={position:"fixed",left:T,top:j,pointerEvents:"none",touchAction:"auto",fontSize:`${xn}px`,fontFamily:en,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(Fr.cellW)),height:Math.max(1,Math.round(Fr.cellH))};if(!Pr.active)return Q;const F=Lt(Pr.text);return{...Q,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:F.width,height:F.height,whiteSpace:F.whiteSpace}})()},onContextMenu:T=>{T.preventDefault()},onFocus:()=>{st("input anchor focus"),zt.current=void 0,vt.current(),cs("focus",{skipResizePush:!0,skipScrollToBottom:!0}),Fe.current?.(!0)},onBlur:T=>{V||hn(T.currentTarget);const j=hr(),Q=typeof document<"u"?document.activeElement:null;if(st("input anchor blur",{guarded:j,activeTag:Q?.tagName??null,activeClass:Q?.className??null}),!j){V&&wt.current?.setAttribute("readonly",""),Fe.current?.(!1);return}if(typeof window>"u"){Fe.current?.(!1);return}window.setTimeout(()=>{Tt()||kt()||(V&&wt.current?.setAttribute("readonly",""),Fe.current?.(!1))},Ed)},onBeforeInput:T=>{if(ut.current)return;const j=T.nativeEvent;if(j instanceof InputEvent){if(j.inputType==="insertFromPaste"||j.inputType==="insertFromPasteAsQuotation"){const Q=j.dataTransfer?.getData("text/plain")||j.data;if(Q){T.preventDefault();const F=K(Q,T.currentTarget);V&&ms.current?.(F)}return}if(j.inputType==="insertLineBreak"){if(qt.current){qt.current=!1,tt.current!==null&&(clearTimeout(tt.current),tt.current=null),T.preventDefault();return}T.preventDefault(),N(T.currentTarget);return}if(j.inputType==="deleteContentBackward"||j.inputType==="deleteContentForward"||j.inputType==="deleteByCut"){if(!T.currentTarget.value){T.preventDefault(),Be.current("");return}if(j.inputType==="deleteContentBackward"&&T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),Be.current("");return}return}}},onInput:T=>{if(ut.current)return;const j=T.nativeEvent,Q=xC(De.current,Ld(T.currentTarget.value),j.inputType);if(Q){const F=K(Q,T.currentTarget);V&&ms.current?.(F);return}W(T.currentTarget)},onPaste:T=>{const j=T.clipboardData.files.length?Array.from(T.clipboardData.files):Array.from(T.clipboardData.items).filter(Se=>Se.kind==="file").map(Se=>Se.getAsFile()).filter(Se=>Se!==null),Q=T.clipboardData.getData("text/plain");if(window.termdockDesktop?.readClipboardFiles){T.preventDefault(),ve(T.currentTarget,{files:j,text:Q});return}if(j.length&&(j.length>1||!j[0].type.startsWith("image/"))){T.preventDefault(),Qe(j,T.currentTarget);return}const F=j[0];if(F){T.preventDefault(),fe(F,T.currentTarget);return}if(!Q){(window.termdockDesktop||typeof navigator.clipboard?.read=="function")&&(T.preventDefault(),ve(T.currentTarget));return}T.preventDefault();const ge=K(Q,T.currentTarget);V&&ms.current?.(ge)},onKeyDown:T=>{const j=qI(T);if(!j&&!ut.current){if(T.getModifierState("AltGraph"))return;const Q=ce.current,F=T.metaKey,ge=T.ctrlKey,Se=T.altKey,Oe=T.shiftKey,Xe=T.key;if(F&&!ge&&!Se&&!Oe&&Xe==="Enter"){T.preventDefault(),N(T.currentTarget);return}if((F||ge)&&!Se&&!Oe&&(Xe==="v"||Xe==="V"))return;if(F&&!ge&&!Se&&!Oe&&(Xe==="c"||Xe==="C")){T.preventDefault();const er=Q?.hasSelection()?Q.getSelection():"";er&&navigator.clipboard?.writeText(er).catch(()=>{});return}if((F||ge)&&!Se&&!Oe&&(Xe==="k"||Xe==="K")){T.preventDefault(),Q&&(Q.reset(),es(),cs("clear",{skipResizePush:!0,skipScrollToBottom:!0})),T.currentTarget.value="",De.current="",nr.current=0;return}if(F&&!ge&&!Se&&!Oe&&Xe==="Backspace"){T.preventDefault(),U("",T.currentTarget);return}if(F&&!ge&&!Se&&!Oe&&Xe==="Delete"){T.preventDefault(),U("\v",T.currentTarget);return}if(F&&!ge&&!Se&&!Oe&&Xe==="ArrowLeft"){T.preventDefault(),U("",T.currentTarget);return}if(F&&!ge&&!Se&&!Oe&&Xe==="ArrowRight"){T.preventDefault(),U("",T.currentTarget);return}if(F)return;if(Se&&!ge&&!F&&!Oe&&Xe==="Backspace"){T.preventDefault(),U("\x1B",T.currentTarget);return}if(Se&&!ge&&!F&&!Oe&&Xe==="Delete"){T.preventDefault(),U("\x1Bd",T.currentTarget);return}if(Se&&!ge&&!F&&!Oe&&Xe==="ArrowLeft"){T.preventDefault(),U("\x1Bb",T.currentTarget);return}if(Se&&!ge&&!F&&!Oe&&Xe==="ArrowRight"){T.preventDefault(),U("\x1Bf",T.currentTarget);return}const dt=QC(T,Q?.modes?.applicationCursorKeysMode===!0);if(dt!==null){T.preventDefault(),U(dt,T.currentTarget);return}}if(T.key==="Enter"||T.key==="Go"||T.key==="done"||T.key==="send"){if(j||ut.current){T.preventDefault();return}if(qt.current){qt.current=!1,tt.current!==null&&(clearTimeout(tt.current),tt.current=null),T.preventDefault();return}T.preventDefault(),N(T.currentTarget);return}if(T.key==="Backspace"){if(j||ut.current)return;if(!T.currentTarget.value){T.preventDefault(),Be.current("");return}if(T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),Be.current("");return}}},onCompositionStart:()=>{ut.current=!0,rn(),Hr({active:!0,text:""})},onCompositionUpdate:T=>{ut.current=!0;const j=T.data??T.currentTarget.value;Hr(Q=>Q.active&&Q.text===j?Q:{active:!0,text:j})},onCompositionEnd:T=>{ut.current=!1,qt.current=!0,tt.current!==null&&clearTimeout(tt.current),tt.current=setTimeout(()=>{qt.current=!1,tt.current=null},50),Hr({active:!1,text:""}),W(T.currentTarget),yn()}}),Pr.active&&(()=>{const T=Lt(Pr.text);return s.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:Fr.x,top:Fr.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:T.width,height:T.height,margin:0,padding:0,color:O.foreground,background:O.background,boxShadow:`-1px 0 0 1px ${O.background}`,fontSize:`${xn}px`,fontFamily:en,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:O.foreground,wordBreak:"break-all",whiteSpace:T.whiteSpace,transition:"none"},children:Pr.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:qr?1:0,transform:qr?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),s.jsx("div",{ref:ps,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:on.visible?1:0,transform:on.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:on.visible&&(()=>{const{activeDir:T}=on,j=Q=>T===Q;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 ${j("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 ${j("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 ${j("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 ${j("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"})})})]})})()})]})]})});Y3.displayName="TerminalViewport";const lE=Y3,cE=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},uE=()=>({async createSession(e){return l8(e)},connect(e,t,r){const n=o8(e,t.onEvent,t.onError,{...cE(r),getDimensions:r?.getDimensions});return{close:()=>n()}},async sendInput(e,t){await vy(e,t)},async resize(e){await a8(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await yy(e)},async restartSession(e,t){return i8(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await s8(e)},async tmuxAction(e,t){return n8(e,t)},async listTmuxSessions(){return Pm()},async getTmuxStatus(){return Qm()},async checkHealth(e){return r8(e)}}),dE="\x1B",hE=/\x1b\[[IO]/g,fE=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,pE=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function M2(e,t,r){return e.lastIndex=r,e.exec(t)?e.lastIndex:-1}function mE(e){const t=e.replace(hE,"");if(t.length===0)return e.length>0;let r=0;for(;r<t.length;){let n=M2(fE,t,r);if(n<0&&(n=M2(pE,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 gE(e){return e===dE}function o1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const e0=18;function xE(){return Z3.map(e=>e.id)}const Z3=[{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 w0(){return Z3.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function J1(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 K3(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const eg=/^\/(.+)\/([gimsuy]*)$/;function j2(e){return eg.test(e.trim())}function yf(e){const t=e.trim().match(eg);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function X3(e){if(typeof e!="string")return null;const t=e.trim();return t?eg.test(t)?yf(t)?t:null:t.toLowerCase():null}function D2(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 B2="||",bE=120;function yE(e){return e.includes(B2)?e.split(B2).filter(t=>t.length>0):[e]}function Ru(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(p=>X3(p)).filter(p=>!!p):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:J1(a.rowLayout),showOnDesktop:typeof a.showOnDesktop=="boolean"?!!a.showOnDesktop:!1,actions:Array.isArray(a.actions)?a.actions.map((p,m)=>{const x={id:typeof p.id=="string"&&p.id.trim().length>0?p.id:`${d}-action-${m+1}`,label:typeof p.label=="string"?p.label:`Key ${m+1}`,sequence:typeof p.sequence=="string"?p.sequence:""};return typeof p.doubleTapSequence=="string"&&(x.doubleTapSequence=p.doubleTapSequence),x}):[]}}).filter(a=>a.id!=="auto"),n=w0()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function vE(e,t){const r=K3(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const c=yf(a);if(c){if(c.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function Q2(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??w0()[0]}function wE(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function AE(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function J3(e,t){const r=J1(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 ev=28,tv=({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($S,{size:14}):(t.charAt(0)||"?").toUpperCase()}),TE={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Rd=8;function SE(e,t){return TE[e]??null}const CE=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:a,disabled:c,defaultShowExtended:l=!1,presetLabel:d,presetModeLabel:p,presetMode:m,presetOptions:x,includeAlt:y,presetRowLayout:w,extraActions:v,onKeyPress:S,onTextPress:L,onPastePress:E,onFilePress:R,onFileLongPress:B,fileUploadState:z="idle",fileUploadProgress:O=0,longPressMode:$="arrows",copyFeedback:V="idle",onLongPressModeToggle:Z,onModifierToggle:le,onPresetSelect:be,onExpandedChange:pe})=>{const{t:ee}=Ur(),[_e,ze]=k.useState(l),[Y,ce]=k.useState(!1),qe=k.useRef(null),we=r==="desktop-actions",ye=we||_e,[Le,Be]=k.useState(!1),[ne,Fe]=k.useState(null),ke=c||!e||!t,Ee=c||!e,Pe=k.useRef(null),Ne=k.useRef(null),oe=k.useRef(null),We=k.useRef(null),nt=k.useRef(null),gt=k.useRef(V),ue=k.useRef(null),Ze=k.useRef(0),at=k.useRef(null),Ie=k.useRef(!1),Ge=k.useCallback(Ke=>{if(ke)return;const _t=Ke.target;if(!(_t instanceof Element))return;const $t=_t.closest("button"),yt=$t?.hasAttribute("data-mobile-native-action")===!0;$t&&!yt?(Ke.preventDefault(),xo(Rd)):$t&&xo(Rd)},[ke]),Ce=k.useCallback(Ke=>{Ke.preventDefault()},[]),H=k.useCallback(Ke=>{const _t=Ke.target;ke||_t instanceof HTMLElement&&_t.closest("button")&&_t.blur()},[ke]);k.useEffect(()=>{ze(l)},[l]),k.useEffect(()=>{we||pe?.(_e)},[we,pe,_e]),k.useEffect(()=>{ke&&(ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null),Be(!1),Fe(null))},[ke]),k.useEffect(()=>{e||(Be(!1),Fe(null))},[e]),k.useEffect(()=>{if(!Le)return;const Ke=()=>{const _t=Pe.current?.getBoundingClientRect();_t&&Fe({left:Math.max(8,_t.left),top:Math.max(8,_t.top-8)})};return Ke(),window.addEventListener("resize",Ke),window.addEventListener("scroll",Ke,!0),()=>{window.removeEventListener("resize",Ke),window.removeEventListener("scroll",Ke,!0)}},[Le]),k.useEffect(()=>{const Ke=gt.current;if(gt.current=V,V==="idle"||V===Ke)return;if(nt.current!==null&&window.clearTimeout(nt.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(V==="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 $t=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];oe.current?.animate?.($t,{duration:760,easing:"ease-out"}),We.current?.animate?.($t,{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"});xo(Rd),V==="copied"&&(nt.current=window.setTimeout(()=>{xo(Rd),nt.current=null},90),$==="copy"&&Z?.())},[V,$,Z]),k.useEffect(()=>()=>{nt.current!==null&&window.clearTimeout(nt.current)},[]);const ae=k.useCallback((Ke,_t)=>{ke||(Ke.preventDefault(),S(_t))},[S,ke]),Ae=k.useCallback((Ke,_t)=>{ke||(Ke.preventDefault(),le(_t))},[le,ke]),Ye=k.useCallback(Ke=>{ke||(Ke.preventDefault(),ze(_t=>{const $t=!_t;return $t&&(ce(!0),qe.current!==null&&window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{ce(!1),qe.current=null},350)),$t}))},[ke]),et=k.useCallback(()=>{const Ke=typeof performance<"u"?performance.now():Date.now();Ke-Ze.current<350||(Ze.current=Ke,E?.())},[E]),St=k.useCallback(Ke=>{ke||(Ke.stopPropagation(),Ke.pointerType!=="touch"&&(Ke.preventDefault(),et()))},[ke,et]),Gt=k.useCallback(Ke=>{ke||(Ke.preventDefault(),Ke.stopPropagation(),et())},[ke,et]),Qt=k.useCallback(Ke=>{ke||z==="uploading"||!R||(Ke.preventDefault(),Ke.stopPropagation(),Ie.current||R(),Ie.current=!1)},[z,R,ke]),wt=k.useCallback(()=>{at.current!==null&&window.clearTimeout(at.current),at.current=null},[]),zt=k.useCallback(Ke=>{Ke.stopPropagation(),!(ke||z==="uploading"||!B)&&(Ie.current=!1,at.current=window.setTimeout(()=>{at.current=null,Ie.current=!0,xo(Rd),B()},500))},[z,B,ke]);k.useEffect(()=>()=>wt(),[wt]);const Vt=k.useCallback(Ke=>{ke||Ke.stopPropagation()},[ke]),Kt=250,Ot=k.useCallback(()=>{ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null)},[]);k.useEffect(()=>()=>{Ot(),qe.current!==null&&(window.clearTimeout(qe.current),qe.current=null)},[Ot]);const It=k.useCallback((Ke,_t)=>{if(ke)return;if(Ke.preventDefault(),!_t.doubleTapSequence){L(_t.sequence);return}const $t=ue.current;if($t!==null&&$t.actionId===_t.id){window.clearTimeout($t.timer),ue.current=null,L(_t.doubleTapSequence);return}Ot();const yt=window.setTimeout(()=>{ue.current=null,L(_t.sequence)},Kt);ue.current={actionId:_t.id,timer:yt}},[Ot,L,ke]),xe=k.useCallback(Ke=>{ke||(Ke.preventDefault(),Ke.stopPropagation(),Z?.())},[Z,ke]),Ve=k.useCallback(Ke=>{ke||Ke.stopPropagation()},[ke]),ht=k.useCallback(Ke=>{if(ke)return;Ke.preventDefault();const _t=Ke.currentTarget.getBoundingClientRect();Fe({left:Math.max(8,_t.left),top:Math.max(8,_t.top-8)}),Be($t=>!$t)},[ke]),q=k.useCallback((Ke,_t)=>{ke||(Ke.preventDefault(),Be(!1),Fe(null),be(_t))},[be,ke]),ut=v.length>0,qt=k.useMemo(()=>{const Ke=[{id:"preset",kind:"preset"}];if(!we&&y&&Ke.push({id:"alt",kind:"alt"}),ut){const _t=v.map($t=>({id:$t.id,kind:"text",action:$t}));return Ke.concat(_t)}return we?Ke.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"}]):Ke.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,ut,y,we]),tt=k.useMemo(()=>J3(qt,we&&!ut?[6]:w),[qt,ut,we,w]),De=`${we?"space-y-1":"mt-1 space-y-1"}${Y?" pointer-events-none":""}`,nr=Le&&ne?Xs.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:ne.left,top:ne.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(Ke=>s.jsx("button",{type:"button",onPointerDown:_t=>q(_t,Ke.id),tabIndex:-1,disabled:Ee,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${Ke.id===m?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:Ke.label},Ke.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[nr,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?we?"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:Ge,onPointerDownCapture:Ge,onContextMenuCapture:Ce,onFocusCapture:H,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!we&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:Ke=>ae(Ke,"esc"),tabIndex:-1,disabled:Ee,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:Ke=>Ae(Ke,"ctrl"),tabIndex:-1,disabled:Ee,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:Ke=>ae(Ke,"ctrl-c"),tabIndex:-1,disabled:Ee,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:Ke=>ae(Ke,"ctrl-u"),tabIndex:-1,disabled:Ee,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:zt,onPointerUp:wt,onPointerCancel:wt,onClick:Qt,tabIndex:-1,disabled:Ee||!R||z==="uploading",title:z==="uploading"?`${ee("rightSidebar.uploading")} ${Math.round(O)}%`:ee(z==="inserted"?"rightSidebar.inserted":z==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":ee("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 ${z==="inserted"?"bg-primary/15 text-primary":z==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[z==="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,O))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:z==="uploading"?s.jsx(_n,{size:15,className:"animate-spin"}):z==="inserted"?s.jsx(pi,{size:15}):z==="failed"?s.jsx(In,{size:15}):s.jsx(uT,{size:15})}),z!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:z==="uploading"?`${ee("rightSidebar.uploading")} ${Math.round(O)}%`:ee(z==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),s.jsx("button",{type:"button",onPointerDown:()=>L("/"),tabIndex:-1,disabled:Ee,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:Ke=>ae(Ke,"enter"),tabIndex:-1,disabled:Ee,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(sT,{size:16})}),s.jsxs("button",{ref:Ne,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Ve,onTouchStart:Ve,onClick:xe,tabIndex:-1,disabled:Ee,title:ee(V==="copied"?"terminal.copied":V==="failed"?"terminal.copyFailed":$==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":ee($==="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 ${V==="copied"?"bg-primary/15 text-primary":V==="failed"?"bg-destructive/15 text-destructive":$==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:oe,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:We,"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(pi,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),s.jsx(In,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${V==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(By,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&$==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(OT,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&$==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),V!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:V==="copied"?`${ee("terminal.copied")} · ${ee("terminal.longPressSendsArrows")}`:`${ee("terminal.copyFailed")} · ${ee("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:St,onPointerUp:Vt,onTouchStart:Vt,onTouchEnd:Vt,onClick:Gt,tabIndex:-1,disabled:Ee,title:ee("terminal.paste"),"aria-label":ee("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(YA,{size:15})}),s.jsx("button",{type:"button",onPointerDown:Ye,tabIndex:-1,disabled:Ee,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:_e?s.jsx(c8,{size:16}):s.jsx(ul,{size:16})})]}),ye&&s.jsx("div",{className:De,children:tt.map((Ke,_t)=>{const $t=Ke.items[0]?.kind==="preset",yt=Math.max(2,Ke.columns),xt=$t?`${ev}px repeat(${Math.max(1,yt-1)}, minmax(0, 1fr))`:`repeat(${yt}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:xt},children:Ke.items.map(Rt=>Rt.kind==="preset"?s.jsx(tv,{buttonRef:Rt.id==="preset"?Pe:void 0,mode:m,presetLabel:d,title:p,disabled:Ee,onPointerDown:ht},Rt.id):Rt.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:Ct=>Ae(Ct,"alt"),tabIndex:-1,disabled:Ee,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"})},Rt.id):Rt.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:Ct=>It(Ct,Rt.action),tabIndex:-1,disabled:Ee,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:[Rt.action.label,Rt.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},Rt.id):s.jsx("button",{type:"button",onPointerDown:Ct=>ae(Ct,Rt.keyName),tabIndex:-1,disabled:Ee,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:Rt.keyName==="esc"?"Esc":Rt.keyName==="ctrl-c"?"Ctrl-C":Rt.keyName==="ctrl-d"?"Ctrl-D":Rt.keyName==="home"?"Home":"End"},Rt.id))},`row-${_t}`)})})]})})]})},_E=({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"})})]})},kE=/^Reconnecting/i,LE=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:c}=Ur(),l=!!e&&kE.test(e),d=!!(n&&!e||l),[p,m]=k.useState(!1);return k.useEffect(()=>{if(!d){m(!1);return}const x=setTimeout(()=>m(!0),1500);return()=>clearTimeout(x)},[d]),d?p?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:s.jsx(p0,{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},IE=120,EE=80,NE=400;function P2(){if(typeof window>"u"||document.visibilityState!=="visible"||!u8())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=sl().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 rv(e){const{enabled:t,openThresholdPx:r=IE,closeThresholdPx:n=EE,settleDelayMs:a=NE}=e,c=k.useMemo(()=>Fu("keyboard"),[]),l=k.useRef(!1),d=k.useRef(null),p=k.useRef(0),[m,x]=k.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return k.useEffect(()=>{if(typeof window>"u"||!t){l.current=!1,d.current!==null&&(clearTimeout(d.current),d.current=null),x(V=>!V.isOpen&&!V.isSettled&&V.keyboardHeight===0?V:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let y=null;const w=()=>{y=null;const V=P2();let Z=l.current;if(V>=r?Z=!0:V<=n&&(Z=!1),l.current=Z,Z){const le=Math.abs(V-p.current);p.current=V,le>10&&(d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,x(be=>be.isSettled?be:{...be,isSettled:!0})},a))}else d.current!==null&&(clearTimeout(d.current),d.current=null);x(le=>{const be=Z?le.isSettled:!1;return le.isOpen===Z&&le.keyboardHeight===V&&le.isSettled===be?le:(c("sync",{keyboardHeight:V,isOpen:Z,isSettled:be,visualViewport:sl().visualViewport?{width:Math.round(sl().visualViewport.width),height:Math.round(sl().visualViewport.height),offsetTop:Math.round(sl().visualViewport.offsetTop)}:null}),{isOpen:Z,isSettled:be,keyboardHeight:V})})},v=(V="event")=>{(V.includes("visibilitychange")||V.includes("pageshow"))&&c("schedule",{source:V}),y===null&&(y=window.requestAnimationFrame(w))};v("mount");const S=()=>v("resize"),L=()=>v("orientationchange"),E=()=>v("visualViewport.resize"),R=()=>v("visualViewport.scroll"),B=()=>v("viewport-keyboard-change");window.addEventListener("resize",S),window.addEventListener("orientationchange",L),sl().visualViewport?.addEventListener("resize",E),sl().visualViewport?.addEventListener("scroll",R),document.addEventListener("termdock:viewport-keyboard-change",B);const z=V=>{c("resume",{source:V,keyboardHeight:P2(),hidden:document.hidden}),v(`${V}:now`),window.setTimeout(()=>v(`${V}:50ms`),50),window.setTimeout(()=>v(`${V}:200ms`),200)},O=()=>{document.hidden||z("visibilitychange")},$=()=>z("pageshow");return document.addEventListener("visibilitychange",O),window.addEventListener("pageshow",$),()=>{window.removeEventListener("resize",S),window.removeEventListener("orientationchange",L),sl().visualViewport?.removeEventListener("resize",E),sl().visualViewport?.removeEventListener("scroll",R),document.removeEventListener("termdock:viewport-keyboard-change",B),document.removeEventListener("visibilitychange",O),window.removeEventListener("pageshow",$),y!==null&&window.cancelAnimationFrame(y),d.current!==null&&(clearTimeout(d.current),d.current=null)}},[c,t,r,n,a]),m}const qh=300,RE=120,ME=2e3,jE=250,DE=6e4;function BE(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 em(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function yh(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function QE(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function PE(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function OE(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function FE(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function $E(e){return!e.initialConnectionPending}function UE(e){return!e}function zE(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function HE(e,t){return[...e].every(r=>t.has(r))}function WE(e,t){return e===null||t-e>=jE}function GE(e){return!1}function VE(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,DE-(e.now-e.reconnectStartedAt))}function qE(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,qh+n*RE),n+=1}return r}const YE="Session not found on server",Yh="Terminal session not found",ZE="STALE_SESSION_RESTORE_REJECTED";function O2(e){return l1(e)?!1:e?.message===YE||e?.status===404&&e.message===Yh}function l1(e){return e?.code===ZE}function KE(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function nv(e,t){return KE(e,t).replace(/ /g,"\\ ")}function c1(e,t){return`${nv(e,t)} `}function F2(e,t){return nv(e,t)}function jU(e,t,r){if(!r)return F2(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${F2(e,t)}:${n}`}const XE="/tmp";async function JE(e,t,r){const a=(await t(XE,[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 vf(a)}if(!c)throw new vf(a);return a}class vf extends Error{constructor(t){super("File uploaded, but its reference was not accepted"),this.uploaded=t,this.name="UploadedReferenceRejectedError"}uploaded}function $2(e,t,r,n,a){if(!e||!t||!r())return Promise.resolve(!1);const c=n?bC(n,t,e):null;if(n&&!c)return Promise.resolve(!1);const l=c?.nonce??`reference-${crypto.randomUUID()}`;return new Promise(d=>{let p=!1;const m=w=>{p||(p=!0,window.clearTimeout(y),window.removeEventListener("termdock-insert-reference-ack",x),c&&yC(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 sv=[640,960,1280,1600,2048,2560,3072,4096],iv=[240,360,480,540,720,1080,1440,2160],l0={min:.1,max:1,step:.01},c0={min:25e4,max:2e7,step:25e4},tg="termdock:mobile-media-compression-v1",vu={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function av(){try{const e=JSON.parse(localStorage.getItem(tg)||"null");return!e||typeof e!="object"?vu:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:sv.includes(e.imageMaxDimension)?e.imageMaxDimension:vu.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=l0.min&&e.imageQuality<=l0.max?e.imageQuality:vu.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:iv.includes(e.videoMaxHeight)?e.videoMaxHeight:vu.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=c0.min&&e.videoBitrate<=c0.max?e.videoBitrate:vu.videoBitrate}}catch{return vu}}const rg=hc((e,t)=>({preferences:av(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(tg,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===tg||e.key===null)&&rg.setState({preferences:av(),saveFailed:!1})});function vh(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 eN({result:e,message:t,onClose:r}){const{locale:n}=Ur(),a=n==="zh",c=b.useRef(null),[l,d]=b.useState(null),[p,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(In,{size:18})})]}),s.jsx("div",{className:"min-h-0 overflow-auto p-2",children:p?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 tN({result:e,onDismiss:t}){const{locale:r}=Ur(),n=r==="zh",a=rg(E=>E.preferences.showResultToast),c=a?e:null,[l,d]=b.useState(null);b.useEffect(()=>{if(!e)return;if(!a){t();return}const E=window.setTimeout(t,2e3);return()=>window.clearTimeout(E)},[e,a,t]);const p=c??l?.result;if(!p)return null;const m=p.originalSize-p.uploadedSize,x=p.originalSize>0?Math.abs(m)/p.originalSize*100:0,y=x<1?"<1%":`${Math.floor(x)}%`,w=p.kind==="image"?n?"图片":"Image":n?"视频":"Video",v=m>0?n?"已压缩上传":"Compressed upload":n?"已处理上传":"Processed upload",S=m>0?n?`省 ${y}`:`${y} saved`:m<0?`+${y}`:n?"体积未变":"Size unchanged",L=p.originalRetained?n?`已尝试压缩 · 保留原图 ${vh(p.uploadedSize)},已上传`:`Compression tried · original ${vh(p.uploadedSize)} uploaded`:`${v} · ${vh(p.originalSize)} → ${vh(p.uploadedSize)} · ${S}`;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}:${L} · ${n?"点击预览":"Preview"}`,onClick:()=>{d({result:c,message:L}),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(pi,{size:13,strokeWidth:2.5,className:"shrink-0 text-primary","aria-hidden":"true"}),s.jsx("span",{className:"truncate tabular-nums",children:L}),s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n?"预览 ›":"Preview ›"})]})}),l&&Xs.createPortal(s.jsx(eN,{result:l.result,message:l.message,onClose:()=>d(null)}),document.body)]})}const rN=320,U2="termdock:mobile-keyboard-expanded",z2="termdock:mobile-keyboard-preset-mode",H2="termdock:mobile-long-press-mode",nN=80;function sN(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function W2(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 iN(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 tm(){return wy()}const aN={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},oN=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=X1(),colorTheme:a="dark",toolbarPresets:c=[],isActive:l=!0,focusSuspended:d=!1,deferCursorUntilPositioned:p=!1,isLayoutVisible:m=!0,focusRequestToken:x=0,resumeRequestToken:y=0,resumeRequestReason:w="visibility",resumeRequestDelayMs:v=0,forceResumeReconnect:S=!1,initialConnectDelayMs:L=0,initialConnectEnabled:E=!0,resumeRequestEnabled:R=!0,onStreamReadyChange:B,onStreamConnected:z,onViewportReadyChange:O,onContentReadyChange:$,onKeyboardVisibilityChange:V,suppressKeyboard:Z=!1,keyboardPortalTarget:le=null,sharedMobileKeyboardLayout:be=!1,suppressPageFlipRefresh:pe=!1,showDebug:ee,onStatusChange:_e})=>{const{t:ze}=Ur(),[Y]=k.useState(e||n3()),[ce,qe]=k.useState(()=>(e?Om(e):null)??n.fontSize),we=k.useMemo(()=>uE(),[]),ye=k.useMemo(()=>Fu("session"),[]),Le=k.useMemo(()=>Fu("keyboard"),[]),Be=k.useRef(null),ne=k.useRef(null);k.useEffect(()=>{Om(Y)===null&&qe(n.fontSize)},[n.fontSize,Y]);const Fe=k.useMemo(()=>({...n,fontSize:ce}),[n,ce]),ke=d8(),Ee=d||ke,[Pe,Ne]=k.useState(tm),[oe,We]=k.useState(!1),[nt,gt]=k.useState(!1),[ue,Ze]=k.useState(!1),[at,Ie]=k.useState(()=>typeof document>"u"?!0:!document.hidden&&Cu()),[Ge,Ce]=k.useState(()=>typeof document>"u"?!0:document.hasFocus()),[H,ae]=k.useState(!1),Ae=k.useRef(H);Ae.current=H;const[Ye,et]=k.useState(!1),[St,Gt]=k.useState(!1),[Qt,wt]=k.useState(!1),[zt,Vt]=k.useState(!0),{isOpen:Kt,keyboardHeight:Ot}=rv({enabled:Pe&&l}),[It,xe]=k.useState(null),[Ve,ht]=k.useState(null),[q,ut]=k.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(U2)==="true"),[qt,tt]=k.useState(()=>{if(typeof window>"u")return"auto";const se=window.localStorage.getItem(z2);return se&&se.length>0?se:"auto"}),[De,nr]=k.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(H2)==="copy"?"copy":"arrows"),[Ke,_t]=k.useState("idle"),[$t,yt]=k.useState("idle"),[xt,Rt]=k.useState(0),[Ct,fr]=k.useState(null),[Yt,Sr]=k.useState(null),[pn,dr]=k.useState(null),me=k.useCallback(()=>dr(null),[]),{preferences:Gr,update:ot,saveFailed:pt}=rg(),{videoEnabled:ir,videoMaxHeight:Mn,videoBitrate:Xr,imageEnabled:je,imageMaxDimension:st,imageQuality:bt}=Gr,[Br,Vr]=k.useState(!1),[Cr,qr]=k.useState(null),[mn,on]=k.useState(null),zr=Yr(se=>se.sessions.get(Y)),{setTerminalSession:un,setConnecting:Er,appendToBuffer:re,replaceBuffer:mt,clearTerminalSession:Mt,removeTerminalSession:rr,clearBuffer:Ar,setSessionActiveProgram:Fr,setSessionCwd:Xt,setSessionCopyMode:Zr,setSessionAgentStatus:Jt,setSessionShellTitle:Pr,setSessionPromptState:Hr,clearAgentNeedsReview:ps}=Yr.getState(),Mr=k.useMemo(()=>`wt-${Y.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[Y]),jn=zr?.terminalSessionId??null,Tr=zr?.mode??"shell",Jr=zr?.activeProgram??null,ln=k.useMemo(()=>Ru(c),[c]),Qr=Tr==="tmux",ks=zr?.bufferChunks??[],Dr=zr?.isConnecting??!1,en=jn,xn=k.useCallback(async(se,T)=>{const j=RI(se,zr?.cwd||zr?.directory);if(!j)return;let Q=j,F="directory";try{Q=(await D1(j)).path}catch(ge){if(!(ge instanceof Error)||ge.message!=="Path is not a directory")return;F="file"}try{const ge=Wt.getState();ge.setRightTab("files"),ge.openRight(),window.dispatchEvent(new CustomEvent(_I,{detail:{path:Q,kind:F,line:T}}))}catch{}},[zr?.cwd,zr?.directory]),X=t??zr?.mode??"shell",He=X==="tmux"?r??zr?.tmuxSessionName??null:null,[Nt,Et]=k.useState(null),tr=k.useRef(!1),[jr,cr]=k.useState(!1),[Cn,Ls]=k.useState(!1),[Xn,cn]=k.useState(null),[dn,_r]=k.useState(0),[Or,Gn]=k.useState(null),Vn=ee!==void 0?ee:!1,gn=k.useRef(null),Jn=k.useRef(null),kr=k.useRef(null),Lr=k.useRef(null),pr=k.useRef(null),ns=k.useRef(!1),Un=k.useRef(null),En=k.useRef([]),kn=k.useRef(0),ss=k.useRef(!1),Wr=k.useRef(null),tn=k.useRef(null),G=k.useRef(-1),Me=k.useRef(null),$e=k.useRef(0),Je=k.useRef(null),it=k.useRef(null),Tt=k.useRef(0),kt=k.useRef(0),Dt=k.useRef(!1),ft=k.useRef(null),Bt=k.useRef(null),W=k.useRef(!1),N=k.useRef(0),U=k.useRef(!1),K=k.useRef(!1),fe=k.useRef(!1),Qe=k.useRef(null),ve=k.useRef(null),lt=k.useRef(null),vt=k.useRef(l);vt.current=l;const br=k.useRef(Ee);br.current=Ee;const Lt=k.useRef(d);Lt.current=d;const rn=k.useRef(Pe),yn=k.useRef(null),hn=k.useRef(null),Dn=k.useRef(null),zn=k.useRef(null),hr=k.useRef(null),jt=k.useRef(null),Bn=k.useRef(null),qn=k.useCallback(()=>{const se=++N.current,T=()=>{se===N.current&&et(!0)};if(typeof window>"u"){T();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(T))},[]),Wa=k.useCallback(se=>{if(U.current){if(ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),se.x===0&&se.y>=se.rows-1){Vt(!1);return}ve.current=window.setTimeout(()=>{ve.current=null,Vt(!0)},nN)}},[]),Qn=k.useRef(null);k.useEffect(()=>()=>{Qn.current?.()},[]);const is=k.useCallback(()=>{Qn.current||(Qn.current=U1(()=>{Qn.current=null;const se=Yr.getState(),T=kr.current,j=se.getTerminalSession(Y);if(!T||j?.mode!=="shell"||se.hasPendingBufferWrites(Y))return;const Q=h8(T),F=pr.current?.getDimensions();if(!Q||!F)return;const ge=pr.current?.serializeSnapshot();ge&&f8({id:T,version:1,...Q,...F,data:ge,savedAt:Date.now()})},2e3))},[Y]),zi=k.useCallback(se=>{const T=Yr.getState(),j=T.getTerminalSession(Y)?.bufferChunks.at(-1)?.id;if(kr.current&&j!==void 0&&j<=se&&!T.hasPendingBufferWrites(Y)&&(p8(kr.current),is()),!Dt.current||!FE({writtenChunkId:se,initialTargetChunkId:ft.current}))return;const Q=Bt.current;Bt.current=null,Q!==null&&pr.current?.notifyScreenSynchronized(Q),Dt.current=!1,ft.current=null,qn()},[qn,is,Y]),da=k.useCallback(se=>{if(!U.current)return;const T=Qe.current;T&&T.x===se.x&&T.y===se.y&&T.rows===se.rows||(Qe.current=se,ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),se.x===0&&se.y>=se.rows-1&&Vt(!1))},[]);k.useEffect(()=>{if(!p){K.current=!1;return}K.current||(K.current=!0,fe.current=!1,U.current=!0,Qe.current=null,Vt(!1),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),lt.current!==null&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>{lt.current=null,ve.current!==null&&typeof window<"u"&&window.clearTimeout(ve.current),ve.current=null,U.current=!1,Vt(!0)},15e3))},[p]);const bs=k.useCallback(()=>{zn.current=null;const se=Dn.current;Dn.current=null,se&&Pr(se.sessionId,se.title)},[Pr]),Ga=k.useCallback((se,T)=>{if(Dn.current={sessionId:se,title:T},zn.current===null){if(typeof window>"u"){bs();return}zn.current=window.requestAnimationFrame(bs)}},[bs]),So=k.useCallback(()=>{zn.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(zn.current),zn.current=null,Dn.current=null},[]),Hn=k.useCallback(async()=>{const se=X;return(await m8({preferredFrontendSessionId:Y,mode:se,tmuxSessionName:se==="tmux"?He||Mr:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[X,He,Mr,Y]),ha=k.useRef(l);k.useEffect(()=>{if(!l){pr.current?.blur(),ha.current=!1;return}if(ha.current)return;ha.current=!0;const se=GL(Pe,pe);if(se==="single"){pr.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}se!=="none"&&pr.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[l,Pe,pe,en]),k.useEffect(()=>{rn.current=Pe},[Pe]);const ms=k.useCallback(()=>{!vt.current||br.current||pr.current?.focus()},[]);k.useLayoutEffect(()=>{Ee&&pr.current?.blur()},[Ee]),k.useEffect(()=>{if(!l||Ee||zt||fe.current)return;fe.current=!0;const se=window.requestAnimationFrame(()=>{pr.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(se)},[Ee,l,zt]);const Ia=k.useCallback(se=>{typeof window>"u"||typeof document>"u"||!vt.current||br.current||rn.current||document.hidden||!Cu()||(yn.current!==null&&window.clearTimeout(yn.current),yn.current=window.setTimeout(()=>{if(yn.current=null,!vt.current||br.current||rn.current||document.hidden||!Cu())return;const T=document.activeElement,j=T?.getAttribute("data-terminal-input-anchor")==="true";if((T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T?.isContentEditable===!0)&&!j){Le("desktop resume focus skipped: editable active",{reason:se});return}Le("desktop resume focus",{reason:se}),pr.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),pr.current?.focus()},50))},[Le]);k.useEffect(()=>()=>{yn.current!==null&&typeof window<"u"&&window.clearTimeout(yn.current),yn.current=null,hn.current!==null&&typeof window<"u"&&window.clearTimeout(hn.current),hn.current=null,hr.current!==null&&typeof window<"u"&&window.clearTimeout(hr.current),hr.current=null,jt.current!==null&&typeof window<"u"&&window.clearTimeout(jt.current),jt.current=null,lt.current!==null&&typeof window<"u"&&window.clearTimeout(lt.current),lt.current=null,ve.current!==null&&typeof window<"u"&&window.clearTimeout(ve.current),ve.current=null},[]),k.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const se=()=>{hn.current!==null&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>{hn.current=null;const T=document.activeElement,Q=!(T?.getAttribute("data-terminal-input-anchor")==="true")&&!!(T&&(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T.isContentEditable));VS({isActive:vt.current&&!br.current,isMobile:rn.current,documentVisible:!document.hidden,activeElementIsEditable:Q})&&ms()},0)};return document.addEventListener("pointerup",se),()=>{document.removeEventListener("pointerup",se),hn.current!==null&&(window.clearTimeout(hn.current),hn.current=null)}},[ms]);const as=k.useCallback(()=>{Hi.current=!1,_r(se=>se+1)},[]),Va=k.useCallback((se,T,j)=>{const Q=kr.current,F=Date.now();if(Q&&T&&g8(Q)){ne.current={startedAt:F,strategy:"reconnect",reason:se},ka("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"reconnect",reason:se,active:vt.current});return}if(Q&&x8(Q,()=>{const ge=ne.current;ka("info","PWA_RESUME terminal-responsive",{frontendSessionId:Y,backendSessionId:Q,durationMs:ge?Date.now()-ge.startedAt:null,strategy:ge?.strategy??"probe",reason:ge?.reason??se}),ne.current=null,z?.(Y)},{visible:j})){ne.current={startedAt:F,strategy:"probe",reason:se},ka("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"probe",reason:se,active:vt.current}),ye("[Terminal] resume probe sent",{reason:se,backendSessionId:Q,active:vt.current});return}if(ye("[Terminal] resume probe missing connection, restarting ensureSession",{reason:se,backendSessionId:Q,active:vt.current}),!$E({initialConnectionPending:W.current})){ye("[Terminal] resume probe deferred during initial websocket handshake",{reason:se,backendSessionId:Q});return}as()},[ye,z,as,Y]),Js=k.useCallback((se,T)=>{const j=kr.current;j&&Un.current!==se&&(Un.current=se,tx(j,se,T),ye("[Terminal] flow-control state sent",{backendSessionId:j,paused:se,reason:T}))},[ye]),ei=k.useCallback((se,T)=>{const j=kr.current;j&&Je.current!==se&&(Je.current=se,rx(j,se,T),ye("[Terminal] focus state sent",{backendSessionId:j,focused:se,reason:T}))},[ye]),Hs=k.useCallback((se,T)=>{const j=kr.current;j&&it.current!==se&&(it.current=se,nx(j,se,T),ye("[Terminal] viewing state sent",{backendSessionId:j,viewing:se,reason:T}))},[ye]),qa=WS({isActive:l&&!Ee,viewportFocused:ue,documentVisible:at,windowFocused:Ge,streamReady:H}),Is=GS({isActive:l,documentVisible:at,windowFocused:Ge,streamReady:H,isDesktop:vo()!==null}),fa=k.useRef(qa),dl=k.useRef(Is);k.useEffect(()=>{fa.current=qa,ei(qa,"logical-focus-change")},[qa,ei,en]),k.useEffect(()=>{dl.current=Is,Hs(Is,"logical-viewing-change")},[Is,Hs,en]),TC(en,at,H),k.useEffect(()=>{const se=T=>{const j=T.detail;!j||j.sessionId!==Y||qe(j.fontSize??n.fontSize)};return window.addEventListener("termfontchange",se),()=>window.removeEventListener("termfontchange",se)},[Y,n.fontSize]),k.useEffect(()=>{const se=()=>{const F=!document.hidden&&Cu();Ie(F),F&&l&&Ia("visibility")},T=F=>{l&&Ia(F.persisted?"bfcache":"pageshow")},j=()=>{Ce(!0),Ia("window-focus")},Q=()=>Ce(!1);return document.addEventListener("visibilitychange",se),window.addEventListener(sx,se),window.addEventListener("pageshow",T),window.addEventListener("focus",j),window.addEventListener("blur",Q),()=>{document.removeEventListener("visibilitychange",se),window.removeEventListener(sx,se),window.removeEventListener("pageshow",T),window.removeEventListener("focus",j),window.removeEventListener("blur",Q)}},[l,Ia]),k.useEffect(()=>{if(!y||!R||!xi.current)return;const se=v,T=se<=0,j=Be.current;if(j?.token===y&&(j.visible||!T))return;const Q=()=>{Be.current={token:y,visible:T},pr.current?.requestRefresh(w,{skipScrollToBottom:!0}),Va(se>0?"global-resume-background":"global-resume-visible",se<=0&&S,T)};if(se<=0){Q();return}const F=window.setTimeout(Q,se);return()=>window.clearTimeout(F)},[y,w,R,v,S,Va]);const Ya=k.useRef(0);k.useEffect(()=>{if(H){Ya.current=0;return}if(!jr||Nt==="Authentication required"||Nt===Yh)return;const se=Ya.current,T=Math.min(2e3*Math.pow(2,Math.min(se,4)),3e4),j=setTimeout(()=>{Ya.current+=1,ye("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:Ya.current,backendSessionId:kr.current}),Et("Reconnecting..."),cr(!1),as()},T);return()=>clearTimeout(j)},[Nt,jr,H,dn,ye,as]),k.useEffect(()=>{if(typeof window>"u"){We(!1);return}const se=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;We(se)},[]),k.useEffect(()=>{(!l||!Pe)&&gt(!1),l||Ze(!1)},[l,Pe]),k.useEffect(()=>{kr.current=en,G.current=-1,Bt.current=null,Je.current=null,it.current=null,Un.current=null},[en]),k.useEffect(()=>{B?.(Y,H)},[H,B,Y]),k.useEffect(()=>{$?.(Y,H&&Ye&&St)},[Ye,St,H,$,Y]),k.useEffect(()=>{Qr||(ss.current=!1,Wr.current=null,tn.current&&(clearTimeout(tn.current),tn.current=null))},[Qr]),k.useEffect(()=>{en&&pr.current?.requestRefresh("session-key-change",{force:!0})},[en]),k.useEffect(()=>{const se=l&&Pe&&Kt;Le("visibility signal",{sessionId:Y,isActive:l,isMobile:Pe,isInputFocused:nt,isViewportKeyboardOpen:Kt,viewportKeyboardHeight:Ot,visible:se}),V?.(Y,se)},[V,Y,l,Pe,Kt,Ot,Le]),k.useEffect(()=>{l&&x&&x!==$e.current&&($e.current=x,ms())},[x,ms,l]),k.useEffect(()=>{Lr.current=Y},[Y]),k.useEffect(()=>{!Pe&&(It!==null||Ve!==null)&&(xe(null),ht(null),Me.current=null)},[Pe,It,Ve]),k.useEffect(()=>{!en&&(It!==null||Ve!==null)&&(xe(null),ht(null),Me.current=null)},[en,It,Ve]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(U2,q?"true":"false")},[q]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(z2,qt)},[qt]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(H2,De)},[De]),k.useEffect(()=>{Ne(tm());const se=()=>{Ne(tm())};return window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]);const os=k.useCallback(()=>{Tt.current+=1,kt.current+=1,bs(),So();const se=gn.current;gn.current=null,Jn.current=null,W.current=!1,Ae.current=!1,ae(!1),pr.current?.setSessionReady(!1);const T=kr.current;T&&tx(T,!1,"stream-disconnect"),ns.current=!1,Un.current=null,En.current=[],se?.()},[So,bs]),Ms=k.useCallback(async se=>{if(Jn.current===se){ye(`[startStream] Skipping - already connected to ${se}`);return}ye(`[startStream] Starting stream for frontendSessionId=${Y} backendSessionId=${se}`),cn(null),N.current+=1,Dt.current=!1,ft.current=null,et(!1),Gt(!1),os();const T=Tt.current+1;Tt.current=T,W.current=!0;const j=Yr.getState().getTerminalSession(Y);if(j?.mode==="shell"&&!j.bufferChunks.length){const F=await Promise.race([b8(se),new Promise(ge=>window.setTimeout(()=>ge(null),75))]);if(Tt.current!==T||Lr.current!==Y)return;if(F&&!Yr.getState().getTerminalSession(Y)?.bufferChunks.length){Yr.getState().replaceBuffer(Y,[F.data]);const ge=pr.current?.getDimensions();ge?.cols===F.cols&&ge.rows===F.rows&&y8(se,F.seq,F.epoch)}}const Q=we.connect(se,{onEvent:F=>{if(Tt.current!==T)return;const ge=Y;if(ge)switch(F.type){case"connected":{kt.current+=1,W.current=!1;const Se=ne.current;Se&&(ka("info","PWA_RESUME terminal-connected",{frontendSessionId:ge,backendSessionId:kr.current,durationMs:Date.now()-Se.startedAt,strategy:Se.strategy,reason:Se.reason}),ne.current=null),z?.(ge),(F.runtime||F.ptyBackend)&&ye(`[Terminal] connected frontendSessionId=${ge} backendSessionId=${kr.current} runtime=${F.runtime??"unknown"} pty=${F.ptyBackend??"unknown"} cwd=${F.cwd??"unknown"}`),Er(ge,!1),Et(null),cr(!1),cn(null),Ae.current=!0,ae(!0),kr.current&&(rx(kr.current,fa.current,"stream-connected"),nx(kr.current,dl.current,"stream-connected")),pr.current?.setSessionReady(!0),Un.current=null,Js(ns.current,"stream-connected"),F.tuiProgress!==void 0&&Yr.getState().setSessionTuiProgress(ge,F.tuiProgress??null),F.shellTitle!==void 0&&Yr.getState().setSessionShellTitle(ge,F.shellTitle??null),F.promptState!==void 0&&F.promptState!==null&&Yr.getState().setSessionPromptState(ge,F.promptState);const Oe=Yr.getState().getTerminalSession(ge);if(Oe?.terminalSessionId&&F.mode&&Yr.getState().setTerminalSession(ge,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:F.mode,tmuxSessionName:F.tmuxSessionName??null,cwd:F.cwd??null}),F.activeProgram!==void 0&&Fr(ge,F.activeProgram??null,F.activeProgramSource??null,F.activeProgramRaw??null),pr.current?.requestRefresh("connected",{force:!0,reconcileServerSize:vt.current}),F.mode!=="tmux"&&(Gn(null),Zr(ge,!1)),ye("[Terminal] Connected event received:",{frontendSessionId:ge,backendSessionId:kr.current,storeHasState:!!Oe,storeTerminalId:Oe?.terminalSessionId,hasHistoryInStore:!!Oe?.history?.length,historyLength:Oe?.history?.length??0}),Oe?.history&&Oe.history.length>0){ye(`[Terminal] Restoring ${Oe.history.length} history chunks to frontend session ${ge}`);const er=Oe.history.reduce(($r,nn)=>$r+nn.length,0),or=Math.max(300,Math.min(2e3,Math.ceil(er/200)));kn.current=Date.now()+or,Oe.history.forEach($r=>{re(ge,$r,{markActivity:!1})}),Yr.getState().setSessionHistory(ge,[]),ye(`[Terminal] History restoration complete for ${ge}`)}else ye(`[Terminal] No history to restore for ${ge}`);const Xe=F.replayChunks,dt=!!Oe?.history?.length||!!Xe?.length;if(dt?Dt.current=!0:qn(),Xe&&Xe.length>0){let er=null;if(F.replayOutOfWindow)ye(`[Terminal] Replay out-of-window, atomically replacing buffer (${Xe.length} chunks)`),er=mt(ge,NC(Xe));else{ye(`[Terminal] Replay incremental: ${Xe.length} chunks`);for(const nn of Xe)re(ge,nn)}const or=Xe.reduce((nn,Pn)=>nn+Pn.length,0),$r=Math.max(200,Math.min(1500,Math.ceil(or/200)));kn.current=Math.max(kn.current,Date.now()+$r),ft.current=er}dt&&ft.current===null&&(ft.current=Yr.getState().flushPendingBufferWrites(ge),ft.current===null&&(Dt.current=!1,qn()));break}case"reconnecting":{Ae.current=!1,ae(!1),cn(Se=>Se??Date.now()),Et("Reconnecting..."),cr(!1);break}case"data":{F.data&&(ns.current?En.current.push(F.data):re(ge,F.data));break}case"tmux-layout":{Gn(F.layout??null),F.layout&&Zr(ge,F.layout.inCopyMode);break}case"tmux-screen-sync":{const Se=F.generation??0;if(Se<G.current)break;G.current=Se,N.current+=1,Dt.current=!0,et(!1),En.current=[],pr.current?.prepareScreenReplacement(),Bt.current=Se,ft.current=mt(ge,RC(F.chunks??[])),ft.current===null&&(Bt.current=null,pr.current?.notifyScreenSynchronized(Se),Dt.current=!1,qn()),typeof F.cols=="number"&&typeof F.rows=="number"&&pr.current?.notifyServerSize(F.cols,F.rows,"tmux-screen-sync");break}case"active-program":{Fr(ge,F.activeProgram??null,F.activeProgramSource??null,F.activeProgramRaw??null);break}case"cwd":{Xt(ge,F.cwd??null);break}case"agent-status":{Jt(ge,{agentStatus:F.agentStatus??null,agentIndicator:F.agentIndicator??null,agentStatusDetail:F.agentStatusDetail??null,agent:F.agent??null,agentMessage:F.agentMessage??null,agentNativeSessionId:F.agentNativeSessionId??null,agentResumeRecovered:F.agentResumeRecovered===!0,agentRich:F.agentRich===!0,agentActivity:F.agentActivity??0,agentCwd:F.agentCwd??null,reviewed:F.reviewed??null});break}case"git-status":{Yr.getState().setSessionGitStatus(ge,F.gitStatus??null);break}case"focus-mode":{ye("[Terminal] focus tracking mode",{backendSessionId:kr.current,requested:F.focusTrackingRequested===!0});break}case"resize-ack":{pr.current?.acknowledgeResize({seq:F.seq,ok:F.ok!==!1,cols:F.cols,rows:F.rows,screenSyncPending:F.screenSyncPending,screenSyncGeneration:F.screenSyncGeneration});break}case"pty-size":{typeof F.cols=="number"&&typeof F.rows=="number"&&pr.current?.notifyServerSize(F.cols,F.rows,F.source);break}case"shell-title":{Ga(ge,F.title??null);break}case"prompt-state":{Hr(ge,F.state??"idle",F.exitCode??null);break}case"tui-progress":{Yr.getState().setSessionTuiProgress(ge,F.tuiProgress??null);break}case"exit":{const Se=typeof F.exitCode=="number"?F.exitCode:null,Oe=typeof F.signal=="number"?F.signal:null;re(ge,`\r
76
+ [Process exited${Se!==null?` with code ${Se}`:""}${Oe!==null?` (signal ${Oe})`:""}]\r
77
+ `),Mt(ge),Er(ge,!1),Et("Terminal session ended"),ae(!1),cr(!1),cn(null),Gn(null),Zr(ge,!1),os();break}}},onError:(F,ge)=>{if(Tt.current!==T)return;const Se=Y;if(!Se)return;W.current=!1,Ae.current=!1,ae(!1);const Oe=ge&&F.message==="Authentication required",Xe=O2(F),dt=Oe?F.message:Xe||ge?"Reconnecting...":F.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${ge}):`,dt),Xe&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:kr.current,frontendSessionId:Se,isActive:l,isMobile:Pe,fatal:ge,stack:new Error().stack}),Et(dt),cr(!!ge),ge&&(cn(null),Er(Se,!1),os(),Xe&&(ye("[onError] Session lost, auto-recreating"),Et("Reconnecting..."),cr(!1),Mt(Se),Ar(Se),kr.current=null,Hi.current=!1,as()))}},{...aN,getDimensions:()=>pr.current?.getDimensions()??null});gn.current=()=>{Q.close(),Tt.current===T&&(Jn.current=null)},Jn.current=se},[re,Ar,Mt,ye,os,qn,z,Js,as,Ga,Er,Fr,Jt,Zr,Xt,Hr,we,Y]);k.useEffect(()=>{const se=VE({isActive:l,isStreamReady:H,reconnectStartedAt:Xn,now:Date.now()});if(se===null)return;const T=window.setTimeout(()=>{ye("[Terminal] visible reconnect watchdog expired",{backendSessionId:kr.current,reconnectStartedAt:Xn}),os(),Er(Y,!1),Et("Reconnecting..."),cr(!1),cn(Date.now()),as()},se);return()=>window.clearTimeout(T)},[ye,os,l,H,Xn,as,Y,Er]);const Hi=k.useRef(!1),xi=k.useRef(!1),bi=k.useRef(0);k.useEffect(()=>()=>{bi.current+=1,Hi.current=!1,os()},[os]);const hl=k.useRef(X),ti=k.useRef(He);k.useEffect(()=>{const se=hl.current,T=ti.current;hl.current=X,ti.current=He,Lr.current===Y&&(se===X&&T===He||(Hi.current=!1,os(),_r(j=>j+1)))},[X,He,os,Y]),k.useEffect(()=>{if(Lr.current!==Y&&(ye(`[useEffect] sessionId changed from ${Lr.current} to ${Y}, allowing reinitialization`),Hi.current=!1,xi.current=!1),Hi.current&&Lr.current===Y){ye(`[useEffect] Already initialized for sessionId=${Y}, skipping`);return}if(!Qt)return;const se=async ge=>{if(ye(`[ensureSession] Starting for sessionId=${Y}, runId=${ge}`),!Lr.current||Lr.current!==Y){ye(`[ensureSession] SessionId mismatch or stale run (current=${Lr.current}, target=${Y}), skipping`);return}if(ge!==bi.current){ye(`[ensureSession] Stale run detected (runId=${ge}, currentRunId=${bi.current}), skipping`);return}const Se=Yr.getState(),Oe=Se.getTerminalSession(Y),Xe=Oe?.mode??X;ye("[ensureSession] Current state from store:",{terminalSessionId:Oe?.terminalSessionId,mode:Oe?.mode,tmuxSessionName:Oe?.tmuxSessionName,isConnecting:Oe?.isConnecting});let dt=Oe?.terminalSessionId??null,er=!dt;if(dt&&Xe!==X?(ye(`[ensureSession] Store mode mismatch for ${dt}: current=${Xe} desired=${X}, will create new session`),er=!0,Se.clearTerminalSession(Y),dt=null):dt&&X==="tmux"&&He&&Oe?.tmuxSessionName!==He&&(ye(`[ensureSession] Store tmux name mismatch for ${dt}: current=${Oe?.tmuxSessionName} desired=${He}, will create new session`),er=!0,Se.clearTerminalSession(Y),dt=null),dt&&we.checkHealth&&!vt.current){ye(`[ensureSession] Checking health of existing session ${dt}`);try{const or=await we.checkHealth(dt);if(ye("[ensureSession] Health check result:",or),!or.healthy)ye(`[ensureSession] Session ${dt} is NOT healthy (healthy=${or.healthy}), will create new session`),ye("[ensureSession] Health check details:",or),er=!0,or.mode&&Oe?.terminalSessionId&&Se.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),Se.clearTerminalSession(Y),ye("[ensureSession] Cleared unhealthy session from store");else{ye(`[ensureSession] Session ${dt} is healthy, reusing it, cwd=${or.cwd}, clients=${or.clients}, lastActivity=${Date.now()-(or.lastActivity||0)}ms ago`),or.mode&&Oe?.terminalSessionId&&Se.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),ye(`[ensureSession] Setting terminalIdRef to ${dt} and starting stream`),kr.current=dt,Ms(dt),ye(`[ensureSession] Successfully reused healthy session ${dt}, returning early`);return}}catch(or){ye(`[ensureSession] Failed to check health of session ${dt}:`,or),ye("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ye(`[ensureSession] Decision: shouldCreateNewSession=${er}, terminalId=${dt}`),er){ye(`[ensureSession] Creating new session, shouldCreateNewSession=${er}, runId=${ge}`),Et(null),cr(!1),Se.setConnecting(Y,!0);const $r=Yr.getState().getTerminalSession(Y),Pn=($r?.mode??X)===X&&(X!=="tmux"||!He||$r?.tmuxSessionName===He);if($r?.terminalSessionId&&Pn)ye(`[ensureSession] Race condition avoided: another instance already created session ${$r.terminalSessionId}`),Se.setConnecting(Y,!1),dt=$r.terminalSessionId,er=!1;else try{const yr=await Hn();if(ye(`[ensureSession] Opened managed backend session ${yr.sessionId}`),ge!==bi.current){ye(`[ensureSession] Stale run after session creation (runId=${ge}, currentRunId=${bi.current}), leaving ${yr.sessionId} for sibling`);return}Se.setTerminalSession(Y,yr),ye(`[ensureSession] Updated store with new session ${yr.sessionId}`),dt=yr.sessionId}catch(yr){if(ge!==bi.current){ye("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(yr instanceof n0&&l1(yr)){ye("[ensureSession] Confirmed missing persisted session:",{sessionId:Y,error:yr.message}),Se.clearTerminalSession(Y),Et(Yh),cr(!0),Se.setConnecting(Y,!1);return}Et("Reconnecting..."),cr(!0),Se.setConnecting(Y,!1);return}}if(ge!==bi.current){ye(`[ensureSession] Stale run before starting stream (runId=${ge}, currentRunId=${bi.current}), skipping`);return}if(!dt){ye(`[ensureSession] No terminalId, terminalId=${dt}`);return}ye(`[ensureSession] Starting stream for session ${dt}`),kr.current=dt,Ms(dt),ye(`[ensureSession] ensureSession completed for sessionId=${Y}, terminalId=${dt}`)};let T=null,j=null;const Q=()=>{j=null,!(Hi.current&&Lr.current===Y)&&(ye(`[useEffect] Running ensureSession for sessionId=${Y}, hasInitialized=${Hi.current}`),Hi.current=!0,xi.current=!0,T=++bi.current,se(T))};if(!E&&!xi.current){ye(`[useEffect] Holding background connection until the selected session is ready: ${Y}`);return}const F=xi.current?0:Math.max(0,L);return F>0?(ye(`[useEffect] Delaying initial connection for sessionId=${Y} by ${F}ms`),j=window.setTimeout(Q,F)):Q(),()=>{j!==null&&window.clearTimeout(j),ye(`[useEffect] Cleanup for sessionId=${Y}, runId=${T??"pending"}`)}},[Y,dn,Ms,os,we,ye,X,He,Mr,L,E,Qt]);const Uo=k.useCallback(async()=>{if(Y&&!Cn){Ls(!0),Et(null),cr(!1),cn(null),os();try{we.forceKill&&await we.forceKill({sessionId:Y})}catch{}rr(Y),Ar(Y),pr.current?.clear(),await new Promise(se=>setTimeout(se,100));try{Er(Y,!0);const se=await Hn();un(Y,se),kr.current=se.sessionId,Ms(se.sessionId)}catch(se){Et(se instanceof n0&&l1(se)?Yh:"Reconnecting..."),cr(!0),Er(Y,!1)}finally{Ls(!1)}}},[Y,Cn,os,we,rr,Ar,Er,un,Ms,Hn]),pa=k.useCallback((se,T,j,Q)=>{if(!(kr.current!==T||kt.current!==j)){if(se instanceof n0&&O2(se)){ye("[Terminal] operation backend missing, recovering",{terminalId:T,sessionId:Y}),Et("Reconnecting..."),cr(!1),os(),Mt(Y),kr.current=null,Er(Y,!0),as();return}Et(se instanceof Error?se.message:Q)}},[Mt,ye,os,as,Y,Er]),fl=k.useCallback((se,T)=>{const j=T?.ownedPaste?wC(T.ownedPaste,Y,se):!1;if(T?.ownedPaste&&!j||Lt.current||(br.current||B1())&&!j)return Promise.resolve(!1);const Q=()=>!!T?.ownedPaste&&AC(T.ownedPaste,Y)&&vt.current&&!Lt.current&&Ae.current&&!tr.current&&!document.hidden&&navigator.onLine!==!1&&Cu();if(j&&!Q())return Promise.resolve(!1);if(!vt.current&&!T?.targeted||!se)return;const F=mE(se),ge=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(se);if(Qr&&ge&&(ss.current=!0),Date.now()<kn.current)return;let Se=se,Oe=T?.consumeModifier??!1;if(!T?.skipModifierTransform&&It&&se.length>0){const $r=se[0];if($r.length===1&&/[a-zA-Z]/.test($r)){const nn=$r.toUpperCase();It==="ctrl"?(Se=String.fromCharCode(nn.charCodeAt(0)&31),Oe=!0):It==="alt"&&(Se=`\x1B${se}`,Oe=!0)}Oe||(It==="alt"&&(Se=`\x1B${se}`),Oe=!0)}const Xe=kr.current;if(!Xe)return;const dt=kt.current,or=(async()=>{try{if(Qr&&!F&&ss.current&&we.tmuxAction){ss.current=!1;try{await we.tmuxAction(Xe,{action:"copy-mode",enabled:!1})}catch{}if(kr.current!==Xe||kt.current!==dt)return!1;if(gE(Se))return!0}return j&&(!Q()||kr.current!==Xe||kt.current!==dt)||(await we.sendInput(Xe,Se),j&&(!Q()||kr.current!==Xe||kt.current!==dt))?!1:(ps(Y),!0)}catch($r){return pa($r,Xe,dt,"Failed to send input"),!1}})();return Oe&&(Ve||xe(null),ms()),or},[It,ps,ms,pa,Qr,Ve,Y,we]);k.useEffect(()=>{const se=T=>{const j=T,Q=j.detail?.sessionId;if(Q?Q!==Y:!vt.current)return;const F=j.detail?.text;if(!F)return;const ge=j.detail?.nonce;if(tr.current||!pr.current){ge&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}));return}const Se=vC(j.detail,Y),Oe=j.detail?.ownedPaste&&!Se?Promise.resolve(!1):pr.current.sendSequence(F,{paste:j.detail?.paste,submitAfterPaste:j.detail?.submitAfterPaste,targeted:!!Q,ownedPaste:Se??void 0});ge&&Promise.resolve(Oe).then(Xe=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:Xe===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}))}),qS(rn.current,j.detail?.focus!==!1)&&ms()};return window.addEventListener("termdock-insert-reference",se),()=>window.removeEventListener("termdock-insert-reference",se)},[ms,Y]);const pl=k.useCallback((se,T,j)=>{const Q=kr.current;if(!Q){Le("xterm resize push skipped: no terminalId",{cols:se,rows:T});return}Le("xterm resize push",{cols:se,rows:T}),we.resize({sessionId:Q,cols:se,rows:T,seq:j}).catch(F=>{pr.current?.acknowledgeResize({seq:j,ok:!1}),F&&/session not found/i.test(String(F.message||F))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Q,cols:se,rows:T,stack:new Error().stack})})},[we,Le]),ls=k.useCallback(async se=>{const T=kr.current;if(!T||!we.tmuxAction)return;const j=kt.current;try{const Q=await we.tmuxAction(T,se);if(kr.current!==T||kt.current!==j)return;Q.layout&&(Gn(Q.layout),se.action==="switch-session"&&(un(Y,{sessionId:T,cols:80,rows:24,mode:"tmux",tmuxSessionName:Q.layout.sessionName}),v8(Y,{tmuxSessionName:Q.layout.sessionName}).catch(F=>{console.warn("[Terminal] failed to update inventory after tmux switch",F)})))}catch(Q){pa(Q,T,j,"Failed to execute tmux action")}},[pa,Y,un,we]);k.useEffect(()=>{if(!Or||!en)return;const T=Or.windows.find(j=>j.id===Or.activeWindowId)?.panes.find(j=>j.id===Or.activePaneId);T&&pr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${en}:${Or.sessionId}:${T.id}:${T.width}x${T.height}`})},[Or,en]);const js=k.useCallback((se,T=5)=>{const j=Math.max(1,Math.min(Math.floor(T)||1,40));ss.current=!0;const Q=Wr.current;if(Q&&Q.direction===se){Q.lines+=j;return}Q&&ls({action:"scroll",direction:Q.direction,lines:Q.lines}).finally(()=>{ms()}),Wr.current={direction:se,lines:j},tn.current&&clearTimeout(tn.current),tn.current=setTimeout(()=>{const F=Wr.current;F&&(Wr.current=null,ls({action:"scroll",direction:F.direction,lines:F.lines}).finally(()=>{ms()}))},0)},[ms,ls]),Ri=k.useCallback(se=>{const T=Date.now(),j=Me.current,Q=j!==null&&j.modifier===se&&T-j.timestamp<=rN;if(Me.current={modifier:se,timestamp:T},Ve===se){ht(null),xe(null);return}if(Q){ht(se),xe(se);return}Ve!==null&&Ve!==se&&ht(null),xe(F=>F===se?null:se)},[Ve]),zo=k.useCallback(se=>{if(Ze(se&&vt.current),Le("input focus changed",{focused:se,isActive:vt.current,isMobile:rn.current}),!rn.current||!vt.current){gt(!1);return}gt(T=>T===se?T:se)},[Le]),Dl=k.useCallback(se=>{if(ns.current=se,Js(se,"viewport-watermark"),!se&&En.current.length>0){const T=Y;if(T){const j=En.current;En.current=[];for(const Q of j)re(T,Q)}}},[re,Js,Y]),Es=k.useCallback(se=>{vt.current&&pr.current?.ensureSizeMatches(se)},[]),Ea=k.useRef(null);k.useEffect(()=>{if(!l)return;const se=Ea.current;if(!se)return;const T=()=>Es("pointerdown"),j=()=>Es("keydown"),Q=()=>Es("touchstart"),F=()=>Es("wheel");return se.addEventListener("pointerdown",T),se.addEventListener("keydown",j),se.addEventListener("touchstart",Q,{passive:!0}),se.addEventListener("wheel",F,{passive:!0}),()=>{se.removeEventListener("pointerdown",T),se.removeEventListener("keydown",j),se.removeEventListener("touchstart",Q),se.removeEventListener("wheel",F)}},[l,Es]);const ml=k.useCallback(se=>{pr.current=se},[]),es=k.useCallback(se=>{wt(se),O?.(Y,se)},[O,Y]),Wi=k.useCallback(se=>{const T=SE(se);if(!T)return;const j=It!==null;pr.current?.sendSequence(T,{consumeModifier:j})},[It]),Mi=k.useCallback(se=>{const T=yE(se);if(T.length===0)return;const j=It!==null;pr.current?.sendSequence(D2(T[0]),{consumeModifier:j});for(let Q=1;Q<T.length;Q+=1){const F=T[Q];window.setTimeout(()=>{pr.current?.sendSequence(D2(F))},bE*Q)}},[It]),Gi=k.useCallback(()=>{pr.current?.pasteClipboardText()},[]),gs=k.useCallback(se=>{jt.current!==null&&(window.clearTimeout(jt.current),jt.current=null),yt(se),(se==="inserted"||se==="failed")&&(jt.current=window.setTimeout(()=>{jt.current=null,yt("idle")},1400))},[]),Ws=k.useCallback(()=>{gs("idle"),Rt(0),Bn.current?.click()},[gs]),Bl=k.useCallback(()=>{Vr(!0)},[]),Vi=k.useCallback(se=>{const T=se.currentTarget.files?.[0];if(se.currentTarget.value="",!T)return;const j=Y;Sr(null),fr(null),dr(null),Rt(0),gs("uploading");const Q=ir&&T.type.startsWith("video/")?{maxHeight:Mn,videoBitrate:Xr,onProgress:Rt}:null,F=je&&sN(T)?{maxDimension:st,quality:bt}:null;let ge=Q?"视频压缩":F?"图片压缩":"文件上传";(async()=>{const Se=Q?await(await Oc(async()=>{const{compressVideoLocally:Oe}=await import("./videoCompression-CuDMhYU3.js");return{compressVideoLocally:Oe}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(T,Q):F?await(await Oc(async()=>{const{compressImageLocally:Oe}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Oe}},[])).compressImageLocally(T,F):T;ge="文件上传",await JE(Se,(Oe,Xe)=>N0(Oe,Xe,void 0,Rt),Oe=>(ge="插入终端",$2(c1(Oe,null),j,()=>vt.current&&!tr.current&&Lr.current===j&&Yr.getState().activeSessionId===j))),(Q||F)&&dr({file:Se,kind:Q?"video":"image",originalSize:T.size,uploadedSize:Se.size,originalRetained:Se===T})})().then(()=>gs("inserted"),Se=>{Se instanceof vf&&Sr({path:Se.uploaded.path,sessionId:j});const Oe=Se instanceof vf?Se.uploaded.path:W2(Se);fr({stage:ge,detail:Oe}),Vr(!0),gs("failed"),ka("warn","MOBILE_MEDIA_UPLOAD failed",{stage:ge,detail:Oe})})},[Xr,ir,Mn,je,st,bt,Y,gs]),qi=k.useCallback(async()=>{const se=Yt;if(!se||se.sessionId!==Y)return;Vr(!1),await new Promise(j=>window.requestAnimationFrame(()=>j())),gs("uploading"),await $2(c1(se.path,null),se.sessionId,()=>vt.current&&!tr.current&&Lr.current===se.sessionId&&Yr.getState().activeSessionId===se.sessionId)?(Sr(null),fr(null),gs("inserted")):(Vr(!0),gs("failed"))},[Yt,Y,gs]);k.useEffect(()=>{if(!Br||!ir)return;let se=!0;return on(null),qr({phase:"checking-cache"}),Oc(async()=>{const{prepareLocalVideoCompression:T}=await import("./videoCompression-CuDMhYU3.js");return{prepareLocalVideoCompression:T}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:T})=>{if(se)return T(j=>{se&&qr(j)})}).catch(T=>{se&&on(W2(T))}),()=>{se=!1}},[Br,ir]);const fn=Dr||Nt!==null;tr.current=fn;const ma=k.useRef(Jr);fn||(ma.current=Jr);const Yi=fn?ma.current:Jr,Na=k.useMemo(()=>vE(Yi,ln),[Yi,ln]),ji=k.useMemo(()=>Q2(ln,qt),[qt,ln]),Di=!Pe&&qt!=="auto"&&ji.id!=="default"&&ji.showOnDesktop!==!0?"auto":qt,ri=Di==="auto"?Na:Di,ws=k.useMemo(()=>Q2(ln,ri),[ri,ln]),Gs=k.useMemo(()=>ws.actions.filter(se=>se.sequence.trim().length>0).map((se,T)=>({...se,label:o1(se,T)})),[ws.actions]),Bi=k.useMemo(()=>K3(Jr),[Jr]),Ra=ws.label,ni=k.useMemo(()=>Di!=="auto"?`Manual preset: ${ws.label}`:Bi?`Auto preset · ${ws.label} (${Bi})`:"Auto preset",[Bi,Di,ws.label]),ys=k.useCallback(se=>{tt(se)},[]),Za=k.useCallback(()=>{nr(se=>se==="copy"?"arrows":"copy"),_t("idle")},[]),Ka=k.useCallback(()=>{typeof window>"u"||(hr.current!==null&&window.clearTimeout(hr.current),hr.current=window.setTimeout(()=>{hr.current=null,_t("idle")},1200))},[]),As=k.useCallback(se=>{hr.current!==null&&typeof window<"u"&&(window.clearTimeout(hr.current),hr.current=null),_t(se?"copied":"failed"),Ka()},[Ka]),Xa=k.useCallback(se=>{ut(se)},[]),Ql=k.useMemo(()=>Pe?wE(ln):AE(ln),[Pe,ln]),Ho=k.useMemo(()=>w8(a),[a]);k.useEffect(()=>{if(!Qr||!H||!Qt||!en)return;const se=MC(Ho);se&&we.sendInput(en,se).catch(T=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",T)})},[Qr,H,Qt,en,we,Ho]);const Co=k.useMemo(()=>`terminal::${Y}`,[Y]);k.useEffect(()=>{_e?.({isConnecting:Dr,isRestarting:Cn,hasError:!!Nt,sessionId:en})},[Dr,Cn,Nt,en,_e]);const ga=!en||Dr||Cn,Ma=k.useCallback((se,T)=>{if(ga)return;const j=Math.max(1,Math.min(Math.floor(T)||1,40));js(se,j)},[js,ga]);k.useEffect(()=>{if(!l||!Pe)return;pr.current?.requestRefresh("resize",{skipScrollToBottom:!Kt,force:!0})},[l,Pe,Kt,Ot,Y]),k.useEffect(()=>{if(!l||!Pe)return;const se=T=>{const j=T.detail;pr.current?.requestRefresh("resize",{skipScrollToBottom:j?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",se),()=>{document.removeEventListener("termdock:viewport-keyboard-change",se)}},[l,Pe,Y]);const Wo=!Z&&(Pe||ws.id==="default"||ws.showOnDesktop===!0),xa=l,cs=Pe&&!be?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Go=Pe&&!be?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,Zi=s.jsx(CE,{visible:Wo,interactive:xa,presentation:Pe?"mobile":"desktop-actions",activeModifier:It,lockedModifier:Ve,disabled:ga,defaultShowExtended:q,presetLabel:Ra,presetModeLabel:ni,presetMode:Di,presetOptions:Ql,includeAlt:ws.includeAlt,presetRowLayout:ws.rowLayout,extraActions:Gs,onKeyPress:Wi,onTextPress:Mi,onPastePress:Pe?Gi:void 0,onFilePress:Pe?Ws:void 0,onFileLongPress:Pe?Bl:void 0,fileUploadState:$t,fileUploadProgress:xt,longPressMode:De,copyFeedback:Ke,onLongPressModeToggle:Za,onModifierToggle:Ri,onPresetSelect:ys,onExpandedChange:Xa}),gl=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:cs,children:[s.jsx("input",{ref:Bn,type:"file",className:"hidden",onChange:Vi}),Br&&Xs.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:()=>Vr(!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:()=>Vr(!1),children:ze("common.close")})]}),Ct&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[Ct.stage,"失败。",Ct.stage.endsWith("压缩")?"原文件未上传。":Ct.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:Ct.detail})]}),Yt&&s.jsx("button",{type:"button",onClick:()=>{qi()},disabled:$t==="uploading"||Yt.sessionId!==Y,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:ze("common.retry")})]}),pt&&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:Gr.showResultToast,onChange:se=>ot({showResultToast:se.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:je,onChange:se=>ot({imageEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),je&&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:st,onChange:se=>ot({imageMaxDimension:Number(se.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:sv.map(se=>s.jsxs("option",{value:se,children:[se," px",se===640?" · 最省流量":se===2048?" · 推荐":se===4096?" · 保留更多细节":""]},se))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片画质:",Math.round(bt*100),"%",s.jsx("input",{type:"range",min:l0.min,max:l0.max,step:l0.step,value:bt,onChange:se=>ot({imageQuality:Number(se.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:ir,onChange:se=>ot({videoEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),ir&&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:Mn,onChange:se=>ot({videoMaxHeight:Number(se.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(se=>s.jsxs("option",{value:se,children:[se," px",se===240?" · 最省流量":se===720?" · 推荐":se>=1440?" · 手机处理较慢":""]},se))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",Xr/1e6," Mbps",s.jsx("input",{type:"range",min:c0.min,max:c0.max,step:c0.step,value:Xr,onChange:se=>ot({videoBitrate:Number(se.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?"本地转码器准备失败,请关闭开关后重试。":iN(Cr)}),Cr?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),mn&&s.jsx("p",{className:"text-[11px] text-destructive",children:mn})]})]})]}),document.body),Vn&&s.jsx(_E,{isMobile:Pe,isInputFocused:nt,isIOS:oe,isConnecting:Dr,connectionError:Nt,terminalSessionId:en}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Ho.background,...Go},children:[s.jsx("div",{ref:Ea,className:"h-full w-full box-border",children:s.jsx(A8,{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(lE,{ref:ml,sessionKey:Co,sessionId:Y,isLayoutVisible:m,chunks:ks,onInput:fl,onResize:pl,onFlowControl:Dl,onTmuxScroll:Qr?Ma:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Pe?()=>{pr.current?.sendSequence(" ")}:void 0,onInputFocusChange:zo,onMobileLongPressCopyResult:As,onReadyChange:es,onSizeSynchronizedChange:Gt,onWritesSettled:Wa,onWriteProgress:zi,onCursorPositionChange:da,onDirectoryLinkActivate:xn,terminalSettings:Fe,theme:Ho,enableTouchScroll:Pe,mobileLongPressMode:De,autoFocus:!Ee&&!Pe&&!gl,cursorVisible:!Ee&&zt,suppressSmoothScroll:!Ye||!St,className:Ee||!zt?"terminal-focus-suspended":void 0},Co)})}),s.jsx(tN,{result:pn,onDismiss:me}),s.jsx(LE,{connectionError:Nt,isFatalError:jr,isRestarting:Cn,isConnecting:Dr,onHardRestart:Uo})]}),le?Z?null:Xs.createPortal(Zi,le):Zi]})};function lN({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=Ur(),c=Yr(l=>{const d=l.sessions.get(e.id);return il(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($o,{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($f,{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($y,{size:14})})]})}const cN="termdock:startup:";function Mu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${cN}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function G2(e,t){e||Xs.flushSync(t)}const u1="horizontal";function Pu(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function Zh(e,t){if(!Array.isArray(e)||e.length!==t)return Pu(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return Pu(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?Pu(t):r.map(a=>a/n)}function uN(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 dN(e){return e==="horizontal"||e==="vertical"||e==="grid"}function hN(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 p=uN(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:dN(c.layout)?c.layout:u1,ratios:Zh(c.ratios,d.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:Zh(c.gridColumnRatios,p.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:Zh(c.gridRowRatios,p.rows)}:{}})}return n}function fN(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?Zh(n.ratios,a.length):Pu(a.length)}]})}function A0(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function rm(e,t,r){if(!t||!r||t===r)return e;const n=A0(e,t),a=A0(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===u1)?"grid":n?.layout??u1,ratios:Pu(l.length)},p=new Set([n?.id,a?.id].filter(Boolean)),m=e.filter(y=>!p.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 pN(e,t){const r=A0(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:Pu(n.length)}:a)}function mN(e,t){const r=A0(e,t);return r?e.filter(n=>n.id!==r.id):e}function gN(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 xN(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 d1=320,ov=1,bN=d1+120,h1="termdock:split-workspaces:v2",lv="termdock:split-workspace:v1",yN=.1,vN=.9;function nm(){if(typeof window>"u")return{mobile:!1,landscape:!1};const e=wy();return{mobile:e,landscape:e&&window.innerWidth>window.innerHeight}}function wN(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(h1);if(e)return hN(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(lv)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(vN,Math.max(yN,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 AN(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 p=d.sessionIds.flatMap(m=>{const x=r.get(m);return x?[x]:[]});p.length>=2&&c.push({key:d.id,sessions:p,workspace:d})}return c}function V2(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function wh(e,t){const r=wf(e,t);if(r===null)return;const n=e.wrapperEl;V2(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),V2(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 f1(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 wf(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function TN(e,t){const r=f1(e),n=wf(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=ov}function SN(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 cv(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function uv(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 CN(e,t){const r=cv(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function q2(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...uv(n),history:a?.history}})}function Y2(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function Z2(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 K2(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function _N(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 kN(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 LN=({terminalSettings:e=X1(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:c="shell",defaultTmuxSessionName:l="",connectionPrioritySessionId:d=null,connectionPriorityReady:p=!0,desktopRightSidebarEnabled:m=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopPinnedLeftSidebarWidth:w=0,desktopViewportWidth:v=0,onStatusChange:S,onSessionDataUpdate:L,onInitialViewportReady:E,onInitialRecoveryRequired:R})=>{const{t:B}=Ur(),z=b.useMemo(()=>Fu("session"),[]),O=b.useMemo(()=>Fu("terminal"),[]),[$,V]=b.useState([]),[Z,le]=b.useState(null),be=b.useRef(0),pe=b.useRef(0),ee=Kn(W=>W.activePaneId);b.useEffect(()=>{Kn.getState().setActivePane(Z)},[Z]);const[_e,ze]=b.useState(null),[Y,ce]=b.useState(!0),[qe,we]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[ye,Le]=b.useState(()=>new Set),[Be,ne]=b.useState(()=>({token:0,completed:new Set})),[Fe,ke]=b.useState(0),[Ee,Pe]=b.useState(()=>new Set),[Ne,oe]=b.useState(()=>new Set),We=b.useRef(new Map),[nt,gt]=b.useState(()=>new Set),ue=b.useRef(!1),Ze=b.useRef(null),at=b.useRef({}),[Ie,Ge]=b.useState(null),[Ce,H]=b.useState(()=>wN()),[ae,Ae]=b.useState(!1),Ye=b.useCallback(W=>{be.current+=1,Ae(W)},[]),et=b.useRef(null),St=b.useRef(ae);St.current=ae,Gc(et,ae&&!!Z,()=>Ye(!1));const[Gt,Qt]=b.useState(null),[wt,zt]=b.useState(null),Vt=b.useRef(new Set),[Kt,Ot]=b.useState(null),[It,xe]=b.useState(null),[Ve,ht]=b.useState(!1),[q,ut]=b.useState(()=>nm().mobile),[qt,tt]=b.useState(()=>nm().landscape),[De,nr]=b.useState(null),[Ke,_t]=b.useState(null),$t=b.useRef(a),yt=b.useRef(!1),xt=b.useRef(!1),Rt=b.useRef(null),Ct=b.useRef(null),fr=b.useRef(q),Yt=b.useRef(null),Sr=b.useCallback(W=>{W!==Yt.current&&(be.current+=1),Yt.current=W,le(W)},[]);b.useEffect(()=>Wt.subscribe((W,N)=>{(W.rightOpen!==N.rightOpen||W.rightTab!==N.rightTab)&&(be.current+=1)}),[]);const pn=b.useRef(0),dr=b.useRef([]),me=b.useRef(0),Gr=b.useRef(null),ot=b.useRef(!1),pt=b.useRef(!0),ir=b.useRef(null),Mn=b.useRef(""),Xr=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const W=()=>{const N=nm();fr.current=N.mobile,ut(N.mobile),tt(N.landscape)};return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const{sessions:je,inventory:st,activeSessionId:bt,isLoading:Br,openSession:Vr,setActiveSession:Cr,removeSession:qr,renameSession:mn,resetSessionCustomName:on,reorderSessions:zr,restoreSessions:un}=T8(),Er=st?.tmuxRecovery??null;b.useEffect(()=>{Er&&R?.()},[Er,R]),b.useEffect(()=>{xe(null),Ot(null)},[Er?.id]);const re=b.useCallback(async()=>{Ot("restore"),xe(null);try{const W=await S8();await un(),W.failed>0&&xe(B("tab.tmuxRecoveryPartial",{restored:W.restored,failed:W.failed}))}catch{xe(B("tab.tmuxRecoveryFailed"))}finally{Ot(null)}},[un,B]),mt=b.useCallback(async()=>{Ot("dismiss"),xe(null);try{await C8(),await un()}catch{xe(B("tab.tmuxRecoveryDismissFailed"))}finally{Ot(null)}},[un,B]),Mt=Wt(W=>W.groupByFolder),rr=df(W=>W.collaborationGroups),Ar=Wt(W=>W.leftOpen||W.rightOpen),Fr=Wt(W=>W.rightSidebarWidthContextKey),Xt=Wt(W=>W.rightSidebarWidth),Zr=Wt(W=>W.rightPinned),[Jt,Pr]=b.useState(()=>K2(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(W=>{const N=K2(W.sessions);Pr(U=>_N(U,N)?U:N)}),[]);const{arranged:Hr}=b.useMemo(()=>cf($,W=>Jt.get(W.id)??null,Mt,"",Ce,rr),[$,Jt,Mt,Ce,rr]),ps=b.useRef(Hr);ps.current=Hr;const Mr=b.useMemo(()=>AN(Hr,Ce),[Hr,Ce]),jn=b.useRef(Mr);jn.current=Mr;const Tr=b.useMemo(()=>A0(Ce,Z),[Z,Ce]),Jr=b.useMemo(()=>{const W=Mr.find(N=>N.sessions.some(U=>U.id===Z));return new Set(W?.sessions.map(N=>N.id)??[])},[Z,Mr]),ln=b.useMemo(()=>{const W=new Map;if(!m||v<=0)return W;for(const N of Mr){const U=N.sessions[0];if(!U)continue;const K=_8(U.id,Jt.get(U.id)??null,N.workspace?.id??null);if(!(K===Fr?Zr:k8(U.id,Jt.get(U.id)??null,N.workspace?.id??null)))continue;const Qe=K===Fr?Xt:L8(U.id,Jt.get(U.id)??null,N.workspace?.id??null),ve=Oh(Qe,v,w);W.set(N.key,ve+Ay)}return W},[Jt,w,m,Zr,Fr,Xt,v,Mr]),Qr=b.useMemo(()=>em($.map(W=>({id:W.id,backendSessionId:W.sessionId})),d),[d,$]),ks=b.useMemo(()=>Y2(je,bt),[bt,je]),Dr=yh({prioritySessionId:Qr,activeSessionId:_e??Z,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null}),en=b.useMemo(()=>qE(Mr.flatMap(W=>W.sessions.map(N=>N.id)),Jr),[Jr,Mr]),xn=Dr!==null&&ye.has(Dr),X=b.useMemo(()=>{const W=new Set(Jr);return _e&&W.add(_e),!W.size&&Dr&&W.add(Dr),W},[Jr,_e,Dr]),He=Be.token===qe.token&&HE(X,Be.completed),Nt=He||Fe===qe.token?qe.token:-1;b.useEffect(()=>{if(!qe.token||He)return;const W=window.setTimeout(()=>ke(qe.token),ME);return()=>window.clearTimeout(W)},[qe.token,He]);const Et=b.useCallback((W,N)=>{Le(U=>{if(U.has(W)===N)return U;const fe=new Set(U);return N?fe.add(W):fe.delete(W),fe})},[]),tr=b.useCallback(W=>{const N=pn.current;ne(K=>{if(K.token===N&&K.completed.has(W))return K;const fe=new Set(K.token===N?K.completed:[]);return fe.add(W),{token:N,completed:fe}});const U=Qr??_e??Yt.current;W===U&&Mu("foreground-stream-connected")},[_e,Qr]),jr=b.useCallback((W,N)=>{Pe(U=>{if(U.has(W)===N)return U;const K=new Set(U);return N?K.add(W):K.delete(W),K})},[]),cr=b.useCallback((W,N)=>{oe(U=>{if(U.has(W)===N)return U;const K=new Set(U);return N?K.add(W):K.delete(W),K})},[]);b.useEffect(()=>{for(const[W,N]of We.current){const U=$.find(K=>K.id===W);if(!U||U.sessionId!==N.backendSessionId){We.current.delete(W);continue}!ye.has(W)||!Ee.has(W)||!Ne.has(W)||(We.current.delete(W),vy(N.backendSessionId,`${N.command}\r`).catch(K=>{console.error("[Session] Failed to send startup command:",K)}))}},[$,ye,Ee,Ne]);const Cn=Dr!==null&&Ee.has(Dr),Ls=Dr!==null&&Ne.has(Dr);b.useEffect(()=>{Cn&&Mu("foreground-viewport-ready")},[Cn]),b.useEffect(()=>{Ls&&Mu("foreground-content-ready")},[Ls]),b.useEffect(()=>{if(!E)return;if(!Y&&$.length===0){E();return}if(!Cn||!xn||!Ls)return;const W=[...Jr].every(Qe=>Ee.has(Qe)&&ye.has(Qe)&&Ne.has(Qe));let N=0,U=0;const K=()=>{N=requestAnimationFrame(()=>{U=requestAnimationFrame(()=>{Mu("initial-viewport-presented"),E()})})};W&&K();const fe=W?void 0:window.setTimeout(K,8e3);return()=>{cancelAnimationFrame(N),cancelAnimationFrame(U),clearTimeout(fe)}},[xn,Ls,Cn,Y,E,$.length,Jr,Ee,ye,Ne]);const Xn=b.useMemo(()=>q?BE({slides:Mr.map(W=>W.sessions.map(N=>N.id)),visibleSessionIds:Jr,foregroundSessionId:Dr}):nt,[q,Mr,Jr,Dr,nt]);b.useEffect(()=>{if(q||Jr.size===0)return;const W=new Set(Jr),N=Mr.findIndex(U=>U.sessions.some(K=>Jr.has(K.id)));for(let U=-2;U<=2;U+=1)U!==0&&Mr[N+U]?.sessions.forEach(K=>W.add(K.id));gt(U=>{let K=!1;const fe=new Set(U);for(const Qe of W)fe.has(Qe)||(fe.add(Qe),K=!0);return K?fe:U})},[q,Jr,Mr]);const cn=mC(Xn);b.useEffect(()=>{if(!_e)return;if(!$.some(N=>N.id===_e)){ze(null);return}if(!Ee.has(_e)||!ye.has(_e)||!Ne.has(_e))return;const W=window.setTimeout(()=>{ze(N=>N===_e?null:N),$t.current&&!fr.current&&Ge({sessionId:_e,token:Date.now()})},80);return()=>window.clearTimeout(W)},[Ne,_e,ye,$,Ee]),b.useEffect(()=>{typeof window>"u"||(Ce.length>0?(window.localStorage.setItem(h1,JSON.stringify(Ce)),window.localStorage.removeItem(lv)):window.localStorage.removeItem(h1))},[Ce]),b.useEffect(()=>{Br||Y||Ce.length===0||H(W=>fN(W,$.map(N=>N.id)))},[Br,Y,$,Ce.length]),b.useEffect(()=>{if(!Gt)return;const W=window.setTimeout(()=>Qt(null),3200);return()=>window.clearTimeout(W)},[Gt]),Yt.current=Z,pn.current=qe.token,dr.current=$,Gr.current=bt,ot.current=Br,pt.current=Y,$t.current=a;const dn=b.useCallback((W=Ze.current)=>{const N=me.current,U=typeof window<"u"?window.visualViewport:null,K=W?f1(W):null,fe=W?wf(W,N):null;return{sessionsLength:dr.current.length,workspaceSlidesLength:jn.current.length,sessionIds:dr.current.map(Qe=>Qe.id),activeSessionId:Yt.current,activeSessionIndex:N,persistedActiveId:Gr.current,isLoading:ot.current,isRestoring:pt.current,activeIndex:W?.activeIndex??null,previousIndex:W?.previousIndex??null,animating:W?.animating??null,allowTouchMove:W?.allowTouchMove??null,width:W?.width??null,translate:K,targetTranslate:fe,translateDelta:K!==null&&fe!==null?K-fe:null,snapGridLength:W?.snapGrid?.length??null,targetSnap:W?.snapGrid?.[N]??null,visualViewport:U?{width:Math.round(U.width),height:Math.round(U.height),offsetTop:Math.round(U.offsetTop)}:null}},[]),_r=b.useCallback((W,N)=>{z(W,{...dn(),...N})},[z,dn]);b.useEffect(()=>{Br||Y||Z!==bt&&Cr(Z)},[Z,Br,Y,bt,Cr]);const Or=b.useMemo(()=>{if(Hr.length===0||!Z)return 0;const W=Mr.findIndex(N=>N.sessions.some(U=>U.id===Z));return W>=0?W:0},[Mr,Z]);me.current=Or;const Gn=b.useCallback(()=>{Rt.current&&(clearTimeout(Rt.current),Rt.current=null)},[]),Vn=b.useCallback(W=>{Gn(),Rt.current=setTimeout(()=>{Rt.current=null,yt.current=!1,_r("[swiper:touch-guard-clear]",{reason:W})},bN)},[Gn,_r]),gn=b.useCallback((W,N={})=>{const U=Ze.current,K=me.current,fe=jn.current;if(!U||fe.length===0||K<0||K>=fe.length)return;if(yt.current){_r("[swiper:sync-skip-touch]",{reason:W});return}if(U.animating){_r("[swiper:sync-skip-animating]",{reason:W});return}const Qe=f1(U),ve=wf(U,K),lt=Qe!==null&&ve!==null&&Math.abs(Qe-ve)<=ov,vt=U.activeIndex===K;if(_r("[swiper:sync-check]",{reason:W,activeIndexAligned:vt,translateAligned:lt,immediate:N.immediate===!0}),!(vt&&lt)){if(vt){wh(U,K),_r("[swiper:sync-forced-active]",{reason:W,translateAligned:lt,immediate:N.immediate===!0});return}N.immediate?(wh(U,K),U.slideTo(K,0,!1),wh(U,K)):U.slideTo(K,d1,!1),_r("[swiper:sync-applied]",{reason:W,activeIndexAligned:vt,translateAligned:lt,immediate:N.immediate===!0})}},[_r]);b.useEffect(()=>{const W=N=>{const U=N;Ze.current&&(Ze.current.allowTouchMove=!U.detail.locked),_r("[swiper:gesture-lock]",{locked:U.detail.locked})};return document.addEventListener("termdock:gesture-lock",W),()=>document.removeEventListener("termdock:gesture-lock",W)},[_r]),b.useEffect(()=>{if($.length===0){Z!==null&&Sr(null);return}if(!Z){if(!p)return;Sr(yh({prioritySessionId:Qr,activeSessionId:null,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null}));return}$.some(N=>N.id===Z)||Sr($[0].id)},[$,Z,p,Qr,ks]);const Jn=b.useCallback((W,N)=>{if(N&&Date.now()<Xr.current){at.current[W]=!1;return}at.current[W]=N,_t(U=>N?W:U===W?null:U)},[]),kr=b.useCallback(W=>{if(!yt.current&&W.activeIndex!==me.current){_r("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:W.activeIndex,expectedActiveIndex:me.current}),requestAnimationFrame(()=>gn("ignored-layout-slide-change",{immediate:!0}));return}const N=jn.current[W.activeIndex],U=N?.sessions.some(Qe=>Qe.id===Z)?Z:N?.sessions[0]?.id;if(_r("[swiper:slide-change]",{nextSessionId:U??null,instanceActiveIndex:W.activeIndex}),!U||U===Z)return;const K=!!Z&&at.current[Z]===!0,fe=$t.current&&(!fr.current||K);if(Ct.current=U,Sr(U),fe){Ge({sessionId:U,token:Date.now()});return}Ge(null)},[$,Z,_r,gn]);b.useLayoutEffect(()=>{if(Ct.current===Z){_r("[swiper:sync-skip-swiper-driven]",{activeSessionId:Z}),Ct.current=null;return}gn("active-session-index",{immediate:!0})},[Z,Or,$.length,gn,_r]),b.useEffect(()=>{const W=Ze.current;if(!W)return;const N=Mr.length>1&&!Ar&&!ae;W.allowTouchMove!==N&&(W.allowTouchMove=N,_r("[swiper:allow-touch-sync]",{nextAllow:N,sidebarOverlayOpen:Ar}))},[Mr.length,_r,Ar,ae]);const Lr=b.useCallback(W=>{const N=Ze.current;if(!N)return;const U=N.el;if(_r("[swiper:layout-before]",{reason:W,scrollLeft:U?.scrollLeft??null}),U&&(U.scrollLeft=0),N.updateSize(),N.updateSlides(),N.updateProgress(),N.updateSlidesClasses(),U&&(U.scrollLeft=0),_r("[swiper:layout-after]",{reason:W,scrollLeft:U?.scrollLeft??null}),yt.current||N.animating){_r("[swiper:layout-skip-sync-motion]",{reason:W});return}gn(`layout:${W}`,{immediate:!0}),requestAnimationFrame(()=>{const K=Ze.current;K&&(yt.current||K.animating||wh(K,me.current))})},[_r,gn]);b.useEffect(()=>()=>Gn(),[Gn]);const pr=Mr.map(W=>W.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Lr("group-change"))},[Mt,pr,Lr]),b.useEffect(()=>{let W=null,N="mount";const U=lt=>{N=lt,W===null&&(W=requestAnimationFrame(()=>{W=null,Lr(`viewport-change:${N}`)}))},K=()=>U("window-resize"),fe=()=>U("visual-viewport-resize"),Qe=()=>U("visual-viewport-scroll"),ve=lt=>{U(`measured:${lt.detail?.source??"unknown"}`)};return window.addEventListener("resize",K),window.visualViewport?.addEventListener("resize",fe),window.visualViewport?.addEventListener("scroll",Qe),document.addEventListener(ix,ve),U("mount"),()=>{window.removeEventListener("resize",K),window.visualViewport?.removeEventListener("resize",fe),window.visualViewport?.removeEventListener("scroll",Qe),document.removeEventListener(ix,ve),W!==null&&cancelAnimationFrame(W)}},[Lr]),b.useEffect(()=>{if(typeof document>"u")return;let W=null,N=null;const U=vt=>{if(vt!=="online"&&document.hidden)return;const br=performance.now();if(!WE(N,br))return;N=br;const Lt=vt==="bfcache"||vt==="online"?vt:"visibility",rn=GE();Ap(),ka("info","PWA_RESUME scheduled",{source:vt,forceForegroundReconnect:rn,activeSessionId:Yt.current}),we(yn=>({token:yn.token+1,reason:Lt,forceForegroundReconnect:rn})),requestAnimationFrame(()=>Lr(`resume:${vt}:raf`)),W&&clearTimeout(W),W=setTimeout(()=>{W=null,Lr(`resume:${vt}:settled`)},320)},K=()=>{if(document.hidden){Ap();return}U("visibility")},fe=()=>{Ap()},Qe=vt=>{U(vt.persisted?"bfcache":"pageshow")},ve=()=>U("online"),lt=()=>U("focus");return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",fe),window.addEventListener("pageshow",Qe),window.addEventListener("online",ve),window.addEventListener("focus",lt),()=>{document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",fe),window.removeEventListener("pageshow",Qe),window.removeEventListener("online",ve),window.removeEventListener("focus",lt),W&&clearTimeout(W)}},[Lr]),b.useLayoutEffect(()=>{if(!UE(Y))return;const W=SN($),N=JSON.stringify(W);W.length>0&&N!==Mn.current?(Mn.current=N,console.warn("[session-invariant] duplicate mapping detected",W)):W.length===0&&Mn.current&&(Mn.current=""),L?.({sessions:$.map(U=>({id:U.id,name:U.name,customName:U.customName,mode:U.mode,tmuxSessionName:U.tmuxSessionName})),activeSessionId:Z,splitWorkspaces:Ce.map(({id:U,name:K,sessionIds:fe,layout:Qe})=>({id:U,...K?{name:K}:{},sessionIds:fe,layout:Qe}))})},[$,Z,Ce,L,Y]),b.useEffect(()=>{if(Br||ue.current)return;ue.current=!0;const W=em(je.map(Qe=>({id:Qe.sessionId,backendSessionId:Qe.backendSessionId??null})),d),N=Y2(je,bt),U=yh({prioritySessionId:p?W:null,activeSessionId:null,persistedActiveSessionId:N,firstSessionId:je[0]?.sessionId??null}),K=cv(je.map(uv));if(z("[Session] Restoring",K.length,"persisted sessions (one-shot)"),_r("[swiper:restore-start]",{persistedSessionIds:je.map(Qe=>Qe.sessionId),nextActiveSessionId:U}),K.length>0){const Qe=Yr.getState();K.forEach(lt=>{lt.sessionId&&Qe.setTerminalSession(lt.id,{sessionId:lt.sessionId,cols:80,rows:24,mode:lt.mode,tmuxSessionName:lt.tmuxSessionName,history:lt.history})}),je.forEach(lt=>{lt.agent!==void 0&&Qe.setSessionAgentIdentity(lt.sessionId,lt.agent),lt.activeProgram!=null&&Qe.setSessionActiveProgram(lt.sessionId,lt.activeProgram),lt.cwd!=null&&Qe.setSessionCwd(lt.sessionId,lt.cwd),lt.shellTitle!=null&&Qe.setSessionShellTitle(lt.sessionId,lt.shellTitle)}),V(K);const ve=U||K[0]?.id||null;Sr(ve),_r("[swiper:restore-complete]",{restoredSessionIds:K.map(lt=>lt.id),nextActiveSessionId:ve})}(async()=>(K.length===0&&await ir.current?.({createIfEmpty:!0}),ce(!1),requestAnimationFrame(()=>gn("restore-finished",{immediate:!0}))))()},[Br,je,bt,z,_r,gn,p,d]),b.useEffect(()=>{if(!p||Y||$.length===0)return;const W=em($.map(U=>({id:U.id,backendSessionId:U.sessionId})),d),N=yh({prioritySessionId:W,activeSessionId:Yt.current,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null});N&&N!==Yt.current&&Sr(N)},[p,d,Y,ks,$]);const ns=b.useRef([]),Un=b.useRef(!1);Yt.current=Z,b.useEffect(()=>{if(Y)return;const W=ns.current,N=je,U=new Map(W.map(Lt=>[Lt.sessionId,Lt])),K=Yr.getState();for(const Lt of N){const rn=U.get(Lt.sessionId),yn=Yr.getState().sessions.get(Lt.sessionId);Lt.agent!==void 0&&JSON.stringify(Lt.agent)!==JSON.stringify(yn?.agent)&&(yn?.agent==null||JSON.stringify(Lt.agent)!==JSON.stringify(rn?.agent))&&K.setSessionAgentIdentity(Lt.sessionId,Lt.agent),Lt.activeProgram!=null&&Lt.activeProgram!==yn?.activeProgram&&(yn?.activeProgram==null||Lt.activeProgram!==rn?.activeProgram)&&K.setSessionActiveProgram(Lt.sessionId,Lt.activeProgram),Lt.cwd!=null&&Lt.cwd!==yn?.cwd&&(yn?.cwd==null||Lt.cwd!==rn?.cwd)&&K.setSessionCwd(Lt.sessionId,Lt.cwd),Lt.shellTitle!=null&&Lt.shellTitle!==yn?.shellTitle&&(yn?.shellTitle==null||Lt.shellTitle!==rn?.shellTitle)&&K.setSessionShellTitle(Lt.sessionId,Lt.shellTitle)}if(!Un.current){V(Lt=>q2(Lt,N)),ns.current=N,Un.current=!0;return}const fe=new Set(W.map(Lt=>Lt.sessionId)),Qe=new Set(N.map(Lt=>Lt.sessionId)),ve=new Map(W.map(Lt=>[Lt.sessionId,Lt.name]));ns.current=N,V(Lt=>{const rn=q2(Lt,N);return(!Yt.current||!rn.some(yn=>yn.id===Yt.current))&&Sr(rn[0]?.id??null),rn});const lt=N.filter(Lt=>!fe.has(Lt.sessionId)),vt=[...fe].filter(Lt=>!Qe.has(Lt)),br=N.filter(Lt=>fe.has(Lt.sessionId)&&ve.get(Lt.sessionId)!==Lt.name);(lt.length>0||vt.length>0||br.length>0)&&z("[Session] Synced persisted sessions:",{newSessionIds:lt.map(Lt=>Lt.sessionId),removedSessionIds:vt,renamedSessionIds:br.map(Lt=>Lt.sessionId),currentSessionIds:N.map(Lt=>Lt.sessionId)});for(const Lt of N){if(!Lt.backendSessionId)continue;Yr.getState().setTerminalSession(Lt.sessionId,{sessionId:Lt.backendSessionId,cols:80,rows:24,mode:Lt.mode,tmuxSessionName:Lt.tmuxSessionName})}},[je,Y,z]);const En=b.useCallback(async W=>{const N=++pe.current,U=be.current,K=()=>N===pe.current&&U===be.current&&(W?.shouldActivate?.()??!0);try{const fe=Wt.getState(),Qe=Z?{rightOpen:fe.rightOpen,rightPinned:fe.rightPinned,rightSidebarWidth:fe.rightSidebarWidth,rightTab:fe.rightTab}:null,ve=W?.mode==="tmux"||W?.mode==="shell"?W.mode:c,lt=(W?.tmuxSessionName||"").trim(),vt=l.trim(),br=ve==="tmux"?lt||vt||kN():null,Lt=typeof W?.cwd=="string"?W.cwd:null,rn=Z?Yr.getState().sessions.get(Z)?.cwd??null:null,yn=typeof Lt=="string"&&Lt.trim().length>0?Lt:typeof rn=="string"&&rn.trim().length>0?rn:void 0,hn=await Vr({preferredFrontendSessionId:W?.preferredFrontendSessionId,requireExisting:W?.requireExisting===!0,mode:ve,tmuxSessionName:br,cwd:yn,termType:"xterm-256color",createIfEmpty:W?.createIfEmpty===!0},{shouldActivate:K});if(hn.discarded)return W?.onResult?.({ok:!1,error:"unknown"}),null;const Dn=hn.session,zn=hn.terminalSession;!hn.reused&&Qe&&Wt.getState().initializeRightSidebarForSession(Dn.sessionId,zn.cwd??yn??null,Qe);const hr={id:Dn.sessionId,name:Dn.name,customName:Dn.customName===!0,sessionId:zn.sessionId,mode:zn.mode??Dn.mode,tmuxSessionName:zn.tmuxSessionName??Dn.tmuxSessionName},jt=W?.command?.trim();return jt&&We.current.set(hr.id,{backendSessionId:zn.sessionId,command:jt}),V(qn=>CN(qn,hr)),K()&&Sr(hr.id),Yr.getState().setTerminalSession(hr.id,{sessionId:zn.sessionId,cols:80,rows:24,mode:hr.mode,tmuxSessionName:hr.tmuxSessionName,activeProgram:zn.activeProgram,activeProgramRaw:zn.activeProgramRaw,activeProgramSource:zn.activeProgramSource,cwd:zn.cwd}),z("[Session] Inventory opened session:",{frontendSessionId:hr.id,backendSessionId:zn.sessionId,reused:hn.reused,mode:hr.mode,tmuxSessionName:hr.tmuxSessionName}),W?.onResult?.({ok:!0,sessionId:hr.id}),hr.id}catch(fe){return console.error("[Session] Failed to create new session:",fe),W?.onResult?.({ok:!1,error:nC(fe)}),null}},[c,l,Z,Vr,z]);ir.current=En;const kn=b.useCallback((W,N={})=>{be.current+=1,Kn.getState().setActivePane(W);const U=Yt.current,K=!!U&&at.current[U]===!0;if(Sr(W),fr.current&&N.preserveMobileKeyboard===!1){Xr.current=Date.now()+600,U&&(at.current[U]=!1),_t(null),Ge(null);const fe=document.activeElement;fe instanceof HTMLTextAreaElement&&fe.closest(".terminal-viewport-container")&&fe.blur();return}K&&fr.current&&_t(W),$t.current&&(!fr.current||K)&&Ge({sessionId:W,token:Date.now()})},[]),ss=b.useCallback(W=>{Sr(W),Ye(!0),Qt(null)},[]),Wr=b.useCallback(W=>{const N=Yt.current;!N||N===W||(H(U=>rm(U,N,W)),Ye(!1),kn(N,{preserveMobileKeyboard:!1}))},[kn]),tn=b.useCallback(async()=>{const W=Yt.current;if(!W||Ve)return;const N=be.current;ht(!0);const U=Yr.getState().sessions.get(W)?.cwd??void 0,K=await En({cwd:U||void 0,mode:c,shouldActivate:()=>!1});if(ht(!1),!K){Qt(B("common.error"));return}!St.current||N!==be.current||!dr.current.some(fe=>fe.id===W)||(H(fe=>rm(fe,W,K)),Ye(!1),kn(W,{preserveMobileKeyboard:!1}))},[kn,c,En,Ve,B]),G=b.useCallback(W=>{H(N=>mN(N,W)),W&&kn(W,{preserveMobileKeyboard:!1})},[kn]),Me=b.useCallback(W=>{H(N=>pN(N,W)),kn(W,{preserveMobileKeyboard:!1})},[kn]),$e=b.useCallback(W=>{if($.find(U=>U.id===W)){if(be.current+=1,Kn.getState().setActivePane(W),W===Yt.current)return;if(Sr(W),!OE({isMobile:fr.current,viewportReady:Ee.has(W),streamReady:ye.has(W),contentReady:Ne.has(W)})){ze(null),$t.current&&Ge({sessionId:W,token:Date.now()}),z("[Session] Switched to session:",W);return}gt(K=>{if(K.has(W))return K;const fe=new Set(K);return fe.add(W),fe}),ze(W),z("[Session] Switched to session:",W)}},[Ne,z,ye,$,Ee]),Je=b.useCallback((W,N)=>{N.trim()&&(V(U=>U.map(K=>K.id===W?{...K,name:N.trim(),customName:!0}:K)),mn(W,N.trim()))},[mn]),it=b.useCallback(W=>{V(N=>N.map(U=>U.id===W?{...U,customName:!1}:U)),on(W)},[on]),Tt=b.useCallback(W=>{V(N=>{const U=new Map(N.map(ve=>[ve.id,ve])),K=W.map(ve=>U.get(ve)).filter(ve=>ve!==void 0),fe=new Set(W),Qe=N.filter(ve=>!fe.has(ve.id));return[...K,...Qe]}),zr(W),z("[Session] Reordered sessions:",W),requestAnimationFrame(()=>{Ze.current?.update()})},[zr,z]),kt=b.useCallback(async W=>{const N=typeof W=="string"?W:W.sessionId,U=typeof W=="string"?"auto":W.closeMode??"auto",K=$.find(lt=>lt.id===N);if(!K||Vt.current.has(N))return;Vt.current.add(N),be.current+=1;const fe=ax(Hr,N,lt=>lt.id);try{U==="destroy"&&K.mode==="tmux"&&K.tmuxSessionName?(await Ty(K.tmuxSessionName),z("[Session] Destroyed tmux session:",{frontendSessionId:K.id,tmuxSessionName:K.tmuxSessionName})):K.sessionId&&(await yy(K.sessionId),z("[Session] Closed backend terminal:",K.sessionId))}catch(lt){console.error("[Session] Failed to close backend terminal:",lt),zt({sessionId:N,closeMode:U});return}finally{Vt.current.delete(N)}zt(lt=>lt?.sessionId===N?null:lt);const ve=dr.current.filter(lt=>lt.id!==N).some(lt=>lt.id===fe)?fe:ax(dr.current,N,lt=>lt.id);Yt.current===N&&Sr(ve),V(lt=>lt.filter(vt=>vt.id!==N)),qr(N,ve),delete at.current[N],z("[Session] Closed session:",{sessionId:N,closeMode:U})},[$,Hr,qr,z]),Dt=b.useCallback(W=>{if(!W)return;const N=$.filter(U=>U.sessionId===W);if(N.length!==0){N.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:W,frontendSessionIds:N.map(U=>U.id)}),V(U=>{const K=U.filter(fe=>fe.sessionId!==W);return K.length!==U.length&&!K.some(Qe=>Qe.id===Z)&&Sr(K.length>0?K[0].id:null),K});for(const U of N)qr(U.id),delete at.current[U.id];z("[Session] Backend gone, dropped local session(s):",N.map(U=>U.id))}},[$,Z,qr,z]);b.useEffect(()=>{const W=hr=>{En(hr.detail)},N=hr=>{$e(hr.detail)},U=()=>{const hr=Yt.current;!hr||fr.current||Ge({sessionId:hr,token:Date.now()})},K=hr=>{const jt=hr;jt.detail&&ss(jt.detail)},fe=hr=>{const jt=hr.detail;G(jt??Yt.current??void 0)},Qe=hr=>{const jt=hr.detail;jt&&Me(jt)},ve=hr=>{const jt=hr.detail,Bn=typeof jt=="string"?jt:jt?.layout,qn=typeof jt=="string"?Yt.current:jt?.sessionId;Bn!=="horizontal"&&Bn!=="vertical"&&Bn!=="grid"||H(Wa=>Wa.map(Qn=>Qn.sessionIds.includes(qn??"")?{...Qn,layout:Bn}:Qn))},lt=hr=>{const Bn=hr.detail?.direction;if(Bn!=="prev"&&Bn!=="next")return;const qn=ps.current;if(qn.length<=1)return;const Wa=Yt.current,Qn=Wa?qn.findIndex(Ga=>Ga.id===Wa):-1,da=((Qn>=0?Qn:0)+(Bn==="next"?1:-1)+qn.length)%qn.length,bs=qn[da]?.id;bs&&bs!==Wa&&$e(bs)},vt=hr=>{kt(hr.detail)},br=hr=>{Dt(hr.detail)},Lt=hr=>{const jt=hr;!jt.detail?.sessionId||!jt.detail?.name||Je(jt.detail.sessionId,jt.detail.name)},rn=hr=>{const jt=hr;jt.detail?.sessionId&&it(jt.detail.sessionId)},yn=hr=>{const jt=hr;jt.detail?.sessionIds&&Tt(jt.detail.sessionIds)},hn=hr=>{const jt=hr.detail;!jt?.workspaceId||!Array.isArray(jt.sessionIds)||H(Bn=>gN(Bn,jt.workspaceId,jt.sessionIds))},Dn=hr=>{const jt=hr.detail;!jt?.workspaceId||typeof jt.name!="string"||H(Bn=>xN(Bn,jt.workspaceId,jt.name))},zn=hr=>{const jt=hr.detail;!jt?.primaryId||!jt.secondaryId||jt.primaryId===jt.secondaryId||(H(Bn=>rm(Bn,jt.primaryId,jt.secondaryId)),kn(jt.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",W),window.addEventListener("switch-terminal-session",N),window.addEventListener("focus-active-terminal-session",U),window.addEventListener("open-terminal-split-chooser",K),window.addEventListener("close-terminal-split",fe),window.addEventListener("remove-terminal-split-pane",Qe),window.addEventListener("set-terminal-split-direction",ve),window.addEventListener("cycle-terminal-session",lt),window.addEventListener("close-terminal-session",vt),window.addEventListener("close-terminal-session-by-backend",br),window.addEventListener("rename-terminal-session",Lt),window.addEventListener("reset-terminal-session-name",rn),window.addEventListener("reorder-terminal-session",yn),window.addEventListener("reorder-terminal-split-workspace",hn),window.addEventListener("rename-terminal-split-workspace",Dn),window.addEventListener("combine-terminal-split-sessions",zn),()=>{window.removeEventListener("new-terminal-session",W),window.removeEventListener("switch-terminal-session",N),window.removeEventListener("focus-active-terminal-session",U),window.removeEventListener("open-terminal-split-chooser",K),window.removeEventListener("close-terminal-split",fe),window.removeEventListener("remove-terminal-split-pane",Qe),window.removeEventListener("set-terminal-split-direction",ve),window.removeEventListener("cycle-terminal-session",lt),window.removeEventListener("close-terminal-session",vt),window.removeEventListener("close-terminal-session-by-backend",br),window.removeEventListener("rename-terminal-session",Lt),window.removeEventListener("reset-terminal-session-name",rn),window.removeEventListener("reorder-terminal-session",yn),window.removeEventListener("reorder-terminal-split-workspace",hn),window.removeEventListener("rename-terminal-split-workspace",Dn),window.removeEventListener("combine-terminal-split-sessions",zn)}},[kn,En,$e,ss,G,Me,kt,Dt,Je,it,Tt]),b.useEffect(()=>{if(!Tr||q)return;const W=N=>{if(!gC(N,B1())||!(N.ctrlKey||N.metaKey)||!N.shiftKey)return;if(Tr.layout==="horizontal"?N.key==="ArrowLeft"||N.key==="ArrowRight":Tr.layout==="vertical"?N.key==="ArrowUp"||N.key==="ArrowDown":N.key.startsWith("Arrow")){N.preventDefault(),N.stopPropagation();const K=Tr.sessionIds.indexOf(Yt.current??""),fe=N.key==="ArrowLeft"||N.key==="ArrowUp"?-1:1,Qe=(Math.max(0,K)+fe+Tr.sessionIds.length)%Tr.sessionIds.length,ve=Tr.sessionIds[Qe];if(!ve)return;kn(ve);return}N.key==="Backspace"&&(N.preventDefault(),N.stopPropagation(),G(Yt.current??void 0))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[kn,Tr,G,q]);const ft=W=>{const N=Yr.getState().sessions.get(W.id);return il(W,N?.activeProgram??null,N?.cwd??null,void 0,N?.shellTitle??null,N?.promptState??null)},Bt=(W,N={})=>{const U=W.id===Z&&!ee?.startsWith("@collaboration:"),K=Jr.has(W.id)&&!N.hidden,fe=p&&PE({sessionId:W.id,foregroundSessionId:Dr,visibleSessionIds:Jr,deferredViewportSessionIds:q?cn:Xn}),Qe=QE({sessionId:W.id,foregroundSessionId:Dr,foregroundReady:xn,isVisible:K})&&p,ve=zE({sessionId:W.id,foregroundSessionId:Dr,requestToken:qe.token,foregroundCompletedToken:Nt,isVisible:X.has(W.id)})&&p,lt=K||W.id===Dr||Xn.has(W.id)?0:en.get(W.id)??qh;return s.jsxs("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${N.hidden?"invisible pointer-events-none":""}`,style:N.containerStyle,"aria-hidden":N.hidden||void 0,onPointerDownCapture:()=>{K&&G2(U,()=>kn(W.id))},onWheelCapture:()=>{G2(U,()=>kn(W.id))},children:[N.showPaneTitle&&s.jsx(lN,{session:W,active:U,onActivate:()=>kn(W.id),onToggleRightSidebar:U?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:fe&&s.jsx(oN,{sessionId:W.id,mode:W.mode,tmuxSessionName:W.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:U,focusSuspended:_e!==null,deferCursorUntilPositioned:_e===W.id||W.mode==="tmux"&&!Ne.has(W.id),isLayoutVisible:K,initialConnectEnabled:Qe&&ve,resumeRequestEnabled:ve,suppressKeyboard:N.suppressKeyboard,keyboardPortalTarget:N.keyboardPortalTarget,sharedMobileKeyboardLayout:N.sharedMobileKeyboardLayout,suppressPageFlipRefresh:N.suppressPageFlipRefresh,focusRequestToken:Ie?.sessionId===W.id?Ie.token:0,resumeRequestToken:qe.token,resumeRequestReason:qe.reason,forceResumeReconnect:qe.forceForegroundReconnect&&X.has(W.id),resumeRequestDelayMs:X.has(W.id)?0:N.hidden?qh:en.get(W.id)??qh,initialConnectDelayMs:lt,onStreamReadyChange:Et,onStreamConnected:tr,onViewportReadyChange:jr,onContentReadyChange:cr,onKeyboardVisibilityChange:Jn,showDebug:n,onStatusChange:U?S:void 0})})]},W.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[wt&&$.some(W=>W.id===wt.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:B("tab.closeFailed",{name:$.find(W=>W.id===wt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{kt(wt)},children:B("common.retry")}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-1 hover:bg-surface-2","aria-label":B("common.close"),onClick:()=>zt(null),children:s.jsx(In,{size:16})})]}),Er&&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(P1,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:B("tab.tmuxRecoveryTitle",{count:Er.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:Er.sessions.map(W=>W.name).join(" · ")}),It&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:It}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Kt!==null,onClick:()=>{re()},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(Uy,{size:13,className:Kt==="restore"?"animate-spin":""}),B(Kt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:Kt!==null,onClick:()=>{mt()},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:B("tab.tmuxRecoveryDismiss")})]})]})]})}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(dA,{onSwiper:W=>{Ze.current=W,W.allowTouchMove=Mr.length>1&&!Ar&&!ae,_r("[swiper:on-swiper]",{allowTouchMove:W.allowTouchMove}),requestAnimationFrame(()=>Lr("on-swiper"))},onSlideChange:kr,onTouchStart:(W,N)=>{const U=Z2(N),K=U==="touch"||U==="pen"||U==="unknown";O("[swipe:touch-start]",{pointerType:U,allowed:K}),_r("[swiper:touch-start]",{pointerType:U,allowed:K}),K&&(Gn(),xt.current=!0,yt.current=!0)},onTouchEnd:(W,N)=>{const U=Z2(N),K=U==="touch"||U==="pen"||U==="unknown";O("[swipe:touch-end]",{pointerType:U,allowed:K}),_r("[swiper:touch-end]",{pointerType:U,allowed:K}),K&&(xt.current=!1,Vn("touch-end"))},onTransitionEnd:()=>{const W=Ze.current;if(xt.current){_r("[swiper:transition-end-during-touch]");return}if(yt.current&&W&&!TN(W,me.current)){_r("[swiper:transition-end-deferred]");return}Gn(),yt.current=!1,_r("[swiper:transition-end]")},initialSlide:Math.max(0,Or),speed:d1,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:Mr.map(W=>{const N=W.workspace,U=!!N&&W.sessions.length>=2,K=q?qt?"horizontal":"vertical":N?.layout??"horizontal",fe=q&&Ke?W.sessions.some(ve=>ve.id===Ke):!1,Qe=W.sessions.some(ve=>ve.id===Z)?Z:W.sessions[0]?.id;return s.jsx(hA,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":ln.get(W.key)??0,style:{paddingRight:ln.get(W.key)??0,paddingTop:y&&!U?"2.5rem":void 0},children:U?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:q?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[s.jsx(vx,{layoutId:W.key,preset:N?.layout??"horizontal",initialTree:cC(W.sessions.map(ve=>ve.id),K,N?.ratios,N?.gridColumnRatios,N?.gridRowRatios),mobile:q,focusId:fe?Ke:null,panes:W.sessions.map(ve=>({id:ve.id,content:Bt(ve,{showPaneTitle:!q,suppressKeyboard:q&&ve.id!==Qe,keyboardPortalTarget:q?De:null,sharedMobileKeyboardLayout:q,suppressPageFlipRefresh:!0})}))}),q&&s.jsx("div",{ref:nr,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(vx,{layoutId:W.key,preset:N?.layout??"horizontal",mobile:q,panes:[{id:W.sessions[0].id,content:Bt(W.sessions[0])}]})})},W.key)})})}),ae&&Z&&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:()=>Ye(!1),"aria-label":B("common.close")}),s.jsxs("section",{ref:et,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":B("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(Il,{size:17})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:B("tab.splitTitle")}),s.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:B("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:()=>Ye(!1),"aria-label":B("common.close"),children:s.jsx(In,{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:Ve,onClick:()=>{tn()},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(zs,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:B("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:B("tab.splitNewHint")})]})]}),Ce.filter(W=>W.id!==Tr?.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:B("tab.splitExistingGroups")}),Ce.filter(W=>W.id!==Tr?.id).map((W,N)=>{const U=W.sessionIds.flatMap(Qe=>{const ve=$.find(lt=>lt.id===Qe);return ve?[ve]:[]});if(U.length<2)return null;const K=W.name||`${B("tab.splitWorkspace")} ${N+1}`,fe=U.map(Qe=>ft(Qe).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>Wr(U[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(Il,{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:K}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:B("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[B("tab.sessionCount",{count:U.length})," · ",fe]})]}),s.jsx(pi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},W.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitAvailableSessions")}),$.filter(W=>!Ce.some(N=>N.sessionIds.includes(W.id))&&W.id!==Z).length===0&&Ce.filter(W=>W.id!==Tr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:B("tab.splitNoOtherSessions")}):$.filter(W=>!Ce.some(N=>N.sessionIds.includes(W.id))&&W.id!==Z).map(W=>{const N=Jt.get(W.id)??null,U=ft(W);return s.jsxs("button",{type:"button",onClick:()=>Wr(W.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:N?s.jsx(Vc,{size:15}):s.jsx(Il,{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:U.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:N?Ku(N)??N:W.name})]}),s.jsx(pi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},W.id)})]})]})]}),Gt&&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:Gt})]})},IN={sm:"h-4 w-7",md:"h-6 w-10"},EN={sm:"h-3 w-3",md:"h-5 w-5"},NN={sm:"translate-x-3",md:"translate-x-4"};function ll({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 ${IN[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 ${EN[r]} ${e?NN[r]:""}`})})}function la(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 RN=typeof Symbol=="function"&&Symbol.observable||"@@observable",X2=RN,J2=()=>Math.random().toString(36).substring(7).split("").join("."),MN={INIT:`@@redux/INIT${J2()}`,REPLACE:`@@redux/REPLACE${J2()}`},e5=MN;function jN(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 dv(e,t,r){if(typeof e!="function")throw new Error(la(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(la(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(la(1));return r(dv)(e,t)}let n=e,a=t,c=new Map,l=c,d=0,p=!1;function m(){l===c&&(l=new Map,c.forEach((E,R)=>{l.set(R,E)}))}function x(){if(p)throw new Error(la(3));return a}function y(E){if(typeof E!="function")throw new Error(la(4));if(p)throw new Error(la(5));let R=!0;m();const B=d++;return l.set(B,E),function(){if(R){if(p)throw new Error(la(6));R=!1,m(),l.delete(B),c=null}}}function w(E){if(!jN(E))throw new Error(la(7));if(typeof E.type>"u")throw new Error(la(8));if(typeof E.type!="string")throw new Error(la(17));if(p)throw new Error(la(9));try{p=!0,a=n(a,E)}finally{p=!1}return(c=l).forEach(B=>{B()}),E}function v(E){if(typeof E!="function")throw new Error(la(10));n=E,w({type:e5.REPLACE})}function S(){const E=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(la(11));function B(){const O=R;O.next&&O.next(x())}return B(),{unsubscribe:E(B)}},[X2](){return this}}}return w({type:e5.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[X2]:S}}function t5(e,t){return function(...r){return t(e.apply(this,r))}}function r5(e,t){if(typeof e=="function")return t5(e,t);if(typeof e!="object"||e===null)throw new Error(la(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=t5(a,t))}return r}function hv(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function DN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(la(15))};const l={getState:a.getState,dispatch:(p,...m)=>c(p,...m)},d=e.map(p=>p(l));return c=hv(...d)(a.dispatch),{...a,dispatch:c}}}var sm={exports:{}},im={};var n5;function BN(){if(n5)return im;n5=1;var e=SA();function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&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 im.useSyncExternalStoreWithSelector=function(p,m,x,y,w){var v=a(null);if(v.current===null){var S={hasValue:!1,value:null};v.current=S}else S=v.current;v=l(function(){function E($){if(!R){if(R=!0,B=$,$=y($),w!==void 0&&S.hasValue){var V=S.value;if(w(V,$))return z=V}return z=$}if(V=z,r(B,$))return V;var Z=y($);return w!==void 0&&w(V,Z)?(B=$,V):(B=$,z=Z)}var R=!1,B,z,O=x===void 0?null:x;return[function(){return E(m())},O===null?void 0:function(){return E(O())}]},[m,x,y,w]);var L=n(p,v[0],v[1]);return c(function(){S.hasValue=!0,S.value=L},[L]),d(L),L},im}var s5;function QN(){return s5||(s5=1,sm.exports=BN()),sm.exports}QN();var PN=b.version.startsWith("19"),ON=Symbol.for(PN?"react.transitional.element":"react.element"),FN=Symbol.for("react.portal"),$N=Symbol.for("react.fragment"),UN=Symbol.for("react.strict_mode"),zN=Symbol.for("react.profiler"),HN=Symbol.for("react.consumer"),WN=Symbol.for("react.context"),fv=Symbol.for("react.forward_ref"),GN=Symbol.for("react.suspense"),VN=Symbol.for("react.suspense_list"),ng=Symbol.for("react.memo"),qN=Symbol.for("react.lazy"),YN=fv,ZN=ng;function KN(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case ON:switch(e=e.type,e){case $N:case zN:case UN:case GN:case VN:return e;default:switch(e=e&&e.$$typeof,e){case WN:case fv:case qN:case ng:return e;case HN:return e;default:return t}}case FN:return t}}}function XN(e){return KN(e)===ng}function JN(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let d=!1,p,m,x,y,w;function v(B,z){return p=B,m=z,x=e(p,m),y=t(n,m),w=r(x,y,m),d=!0,w}function S(){return x=e(p,m),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function L(){return e.dependsOnOwnProps&&(x=e(p,m)),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function E(){const B=e(p,m),z=!l(B,x);return x=B,z&&(w=r(x,y,m)),w}function R(B,z){const O=!c(z,m),$=!a(B,p,z,m);return p=B,m=z,O&&$?S():O?L():$?E():w}return function(z,O){return d?R(z,O):v(z,O)}}function eR(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),d=n(e,a);return JN(c,l,d,e,a)}function tR(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 p1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function i5(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function pv(e,t){return function(n,{displayName:a}){const c=function(d,p){return c.dependsOnOwnProps?c.mapToProps(d,p):c.mapToProps(d,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(d,p){c.mapToProps=e,c.dependsOnOwnProps=i5(e);let m=c(d,p);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=i5(m),m=c(d,p)),m},c}}function sg(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function rR(e){return e&&typeof e=="object"?p1(t=>tR(e,t)):e?typeof e=="function"?pv(e):sg(e,"mapDispatchToProps"):p1(t=>({dispatch:t}))}function nR(e){return e?typeof e=="function"?pv(e):sg(e,"mapStateToProps"):p1(()=>({}))}function sR(e,t,r){return{...r,...e,...t}}function iR(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let c=!1,l;return function(p,m,x){const y=e(p,m,x);return c?a(y,l)||(l=y):(c=!0,l=y),l}}}function aR(e){return e?typeof e=="function"?iR(e):sg(e,"mergeProps"):()=>sR}function oR(e){e()}function lR(){let e=null,t=null;return{clear(){e=null,t=null},notify(){oR(()=>{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 a5={notify(){},get:()=>[]};function mv(e,t){let r,n=a5,a=0,c=!1;function l(L){x();const E=n.subscribe(L);let R=!1;return()=>{R||(R=!0,E(),y())}}function d(){n.notify()}function p(){S.onStateChange&&S.onStateChange()}function m(){return c}function x(){a++,r||(r=t?t.addNestedSub(p):e.subscribe(p),n=lR())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=a5)}function w(){c||(c=!0,x())}function v(){c&&(c=!1,y())}const S={addNestedSub:l,notifyNestedSubs:d,handleChangeWrapper:p,isSubscribed:m,trySubscribe:w,tryUnsubscribe:v,getListeners:()=>n};return S}var cR=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",uR=cR(),dR=()=>typeof navigator<"u"&&navigator.product==="ReactNative",hR=dR(),fR=()=>uR||hR?b.useLayoutEffect:b.useEffect,Af=fR();function o5(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function am(e,t){if(o5(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])||!o5(e[r[a]],t[r[a]]))return!1;return!0}var pR={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},gR={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},gv={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},xR={[YN]:gR,[ZN]:gv};function l5(e){return XN(e)?gv:xR[e.$$typeof]||pR}var bR=Object.defineProperty,yR=Object.getOwnPropertyNames,c5=Object.getOwnPropertySymbols,vR=Object.getOwnPropertyDescriptor,wR=Object.getPrototypeOf,u5=Object.prototype;function m1(e,t){if(typeof t!="string"){if(u5){const c=wR(t);c&&c!==u5&&m1(e,c)}let r=yR(t);c5&&(r=r.concat(c5(t)));const n=l5(e),a=l5(t);for(let c=0;c<r.length;++c){const l=r[c];if(!mR[l]&&!(a&&a[l])&&!(n&&n[l])){const d=vR(t,l);try{bR(e,l,d)}catch{}}}}return e}var AR=Symbol.for("react-redux-context"),TR=typeof globalThis<"u"?globalThis:{};function SR(){if(!b.createContext)return{};const e=TR[AR]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var xv=SR(),CR=[null,null];function _R(e,t,r){Af(()=>e(...t),r)}function kR(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function LR(e,t,r,n,a,c,l,d,p,m,x){if(!e)return()=>{};let y=!1,w=null;const v=()=>{if(y||!d.current)return;const L=t.getState();let E,R;try{E=n(L,a.current)}catch(B){R=B,w=B}R||(w=null),E===c.current?l.current||m():(c.current=E,p.current=E,l.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,w)throw w}}function IR(e,t){return e===t}function ER(e,t,r,{pure:n,areStatesEqual:a=IR,areOwnPropsEqual:c=am,areStatePropsEqual:l=am,areMergedPropsEqual:d=am,forwardRef:p=!1,context:m=xv}={}){const x=m,y=nR(e),w=rR(t),v=aR(r),S=!!e;return E=>{const R=E.displayName||E.name||"Component",B=`Connect(${R})`,z={shouldHandleStateChanges:S,displayName:B,wrappedComponentName:R,WrappedComponent:E,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:d};function O(Z){const[le,be,pe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ze,...at}=Z;return[Z.context,Ze,at]},[Z]),ee=b.useMemo(()=>{let Ze=x;return le?.Consumer,Ze},[le,x]),_e=b.useContext(ee),ze=!!Z.store&&!!Z.store.getState&&!!Z.store.dispatch,Y=!!_e&&!!_e.store,ce=ze?Z.store:_e.store,qe=Y?_e.getServerState:ce.getState,we=b.useMemo(()=>eR(ce.dispatch,z),[ce]),[ye,Le]=b.useMemo(()=>{if(!S)return CR;const Ze=mv(ce,ze?void 0:_e.subscription),at=Ze.notifyNestedSubs.bind(Ze);return[Ze,at]},[ce,ze,_e]),Be=b.useMemo(()=>ze?_e:{..._e,subscription:ye},[ze,_e,ye]),ne=b.useRef(void 0),Fe=b.useRef(pe),ke=b.useRef(void 0),Ee=b.useRef(!1),Pe=b.useRef(!1),Ne=b.useRef(void 0);Af(()=>(Pe.current=!0,()=>{Pe.current=!1}),[]);const oe=b.useMemo(()=>()=>ke.current&&pe===Fe.current?ke.current:we(ce.getState(),pe),[ce,pe]),We=b.useMemo(()=>at=>ye?LR(S,ce,ye,we,Fe,ne,Ee,Pe,ke,Le,at):()=>{},[ye]);_R(kR,[Fe,ne,Ee,pe,ke,Le]);let nt;try{nt=b.useSyncExternalStore(We,oe,qe?()=>we(qe(),pe):oe)}catch(Ze){throw Ne.current&&(Ze.message+=`
78
+ The error may be correlated with this previous error:
79
+ ${Ne.current.stack}
80
+
81
+ `),Ze}Af(()=>{Ne.current=void 0,ke.current=void 0,ne.current=nt});const gt=b.useMemo(()=>b.createElement(E,{...nt,ref:be}),[be,E,nt]);return b.useMemo(()=>S?b.createElement(ee.Provider,{value:Be},gt):gt,[ee,gt,Be])}const V=b.memo(O);if(V.WrappedComponent=E,V.displayName=O.displayName=B,p){const le=b.forwardRef(function(pe,ee){return b.createElement(V,{...pe,reactReduxForwardedRef:ee})});return le.displayName=B,le.WrappedComponent=E,m1(le,E)}return m1(V,E)}}var bv=ER;function NR(e){const{children:t,context:r,serverState:n,store:a}=e,c=b.useMemo(()=>{const p=mv(a);return{store:a,subscription:p,getServerState:n?()=>n:void 0}},[a,n]),l=b.useMemo(()=>a.getState(),[a]);Af(()=>{const{subscription:p}=c;return p.onStateChange=p.notifyNestedSubs,p.trySubscribe(),l!==a.getState()&&p.notifyNestedSubs(),()=>{p.tryUnsubscribe(),p.onStateChange=void 0}},[c,l]);const d=r||xv;return b.createElement(d.Provider,{value:c},t)}var RR=NR,MR="Invariant failed";function jR(e,t){throw new Error(MR)}var Fo=function(t){var r=t.top,n=t.right,a=t.bottom,c=t.left,l=n-c,d=a-r,p={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 p},ig=function(t,r){return{top:t.top-r.top,left:t.left-r.left,bottom:t.bottom+r.bottom,right:t.right+r.right}},d5=function(t,r){return{top:t.top+r.top,left:t.left+r.left,bottom:t.bottom-r.bottom,right:t.right-r.right}},DR=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},om={top:0,right:0,bottom:0,left:0},ag=function(t){var r=t.borderBox,n=t.margin,a=n===void 0?om:n,c=t.border,l=c===void 0?om:c,d=t.padding,p=d===void 0?om:d,m=Fo(ig(r,a)),x=Fo(d5(r,l)),y=Fo(d5(x,p));return{marginBox:m,borderBox:Fo(r),paddingBox:x,contentBox:y,margin:a,border:l,padding:p}},fo=function(t){var r=t.slice(0,-2),n=t.slice(-2);if(n!=="px")return 0;var a=Number(r);return isNaN(a)&&jR(),a},BR=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Tf=function(t,r){var n=t.borderBox,a=t.border,c=t.margin,l=t.padding,d=DR(n,r);return ag({borderBox:d,border:a,margin:c,padding:l})},Sf=function(t,r){return r===void 0&&(r=BR()),Tf(t,r)},yv=function(t,r){var n={top:fo(r.marginTop),right:fo(r.marginRight),bottom:fo(r.marginBottom),left:fo(r.marginLeft)},a={top:fo(r.paddingTop),right:fo(r.paddingRight),bottom:fo(r.paddingBottom),left:fo(r.paddingLeft)},c={top:fo(r.borderTopWidth),right:fo(r.borderRightWidth),bottom:fo(r.borderBottomWidth),left:fo(r.borderLeftWidth)};return ag({borderBox:t,margin:n,padding:a,border:c})},vv=function(t){var r=t.getBoundingClientRect(),n=window.getComputedStyle(t);return yv(r,n)},T0=function(t){var r=[],n=null,a=function(){for(var l=arguments.length,d=new Array(l),p=0;p<l;p++)d[p]=arguments[p];r=d,!n&&(n=requestAnimationFrame(function(){n=null,t.apply(void 0,r)}))};return a.cancel=function(){n&&(cancelAnimationFrame(n),n=null)},a};function Cf(){return Cf=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},Cf.apply(null,arguments)}function wv(e,t){}wv.bind(null,"warn");wv.bind(null,"error");function oc(){}function QR(e,t){return{...e,...t}}function wo(e,t,r){const n=t.map(a=>{const c=QR(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 PR="Invariant failed";class _f extends Error{}_f.prototype.toString=function(){return this.message};function Pt(e,t){throw new _f(PR)}class OR extends k.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=oc,this.onWindowError=r=>{const n=this.getCallbacks();n.isDragging()&&n.tryAbort(),r.error instanceof _f&&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=wo(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof _f){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const FR=`
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
+ `,kf=e=>e+1,$R=e=>`
86
+ You have lifted an item in position ${kf(e.source.index)}
87
+ `,Av=(e,t)=>{const r=e.droppableId===t.droppableId,n=kf(e.index),a=kf(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
+ `},Tv=(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
+ `,UR=e=>{const t=e.destination;if(t)return Av(e.source,t);const r=e.combine;return r?Tv(e.draggableId,e.source,r):"You are over an area that cannot be dropped on"},h5=e=>`
103
+ The item has returned to its starting position
104
+ of ${kf(e.index)}
105
+ `,zR=e=>{if(e.reason==="CANCEL")return`
106
+ Movement cancelled.
107
+ ${h5(e.source)}
108
+ `;const t=e.destination,r=e.combine;return t?`
109
+ You have dropped the item.
110
+ ${Av(e.source,t)}
111
+ `:r?`
112
+ You have dropped the item.
113
+ ${Tv(e.draggableId,e.source,r)}
114
+ `:`
115
+ The item has been dropped while not over a drop area.
116
+ ${h5(e.source)}
117
+ `},Kh={dragHandleUsageInstructions:FR,onDragStart:$R,onDragUpdate:UR,onDragEnd:zR};function HR(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function Sv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!HR(e[r],t[r]))return!1;return!0}function Sn(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&&Sv(t,a.current.inputs))?a.current:{inputs:t,result:e()};return b.useEffect(()=>{n.current=!1,a.current=l},[l]),l.result}function wr(e,t){return Sn(()=>e,t)}const gi={x:0,y:0},Ni=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),$a=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lc=(e,t)=>e.x===t.x&&e.y===t.y,td=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Zc=(e,t,r=0)=>e==="x"?{x:t,y:r}:{x:r,y:t},S0=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),f5=(e,t)=>Math.min(...t.map(r=>S0(e,r))),Cv=e=>t=>({x:e(t.x),y:e(t.y)});var WR=(e,t)=>{const r=Fo({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 B0=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),p5=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}],GR={top:0,right:0,bottom:0,left:0},VR=(e,t)=>t?B0(e,t.scroll.diff.displacement):e,qR=(e,t,r)=>r&&r.increasedBy?{...e,[t.end]:e[t.end]+r.increasedBy[t.line]}:e,YR=(e,t)=>t&&t.shouldClipSubject?WR(t.pageMarginBox,e):Fo(e);var Gu=({page:e,withPlaceholder:t,axis:r,frame:n})=>{const a=VR(e.marginBox,n),c=qR(a,r,t),l=YR(c,n);return{page:e,withPlaceholder:t,active:l}},og=(e,t)=>{e.frame||Pt();const r=e.frame,n=$a(t,r.scroll.initial),a=td(n),c={...r,scroll:{initial:r.scroll.initial,current:t,diff:{value:n,displacement:a},max:r.scroll.max}},l=Gu({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:c});return{...e,frame:c,subject:l}};function mi(e,t=Sv){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 _v=mi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),kv=mi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),Gf=mi(e=>Object.values(e)),ZR=mi(e=>Object.values(e));var rd=mi((e,t)=>ZR(t).filter(n=>e===n.descriptor.droppableId).sort((n,a)=>n.descriptor.index-a.descriptor.index));function lg(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Vf(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var qf=mi((e,t)=>t.filter(r=>r.descriptor.id!==e.descriptor.id)),KR=({isMovingForward:e,draggable:t,destination:r,insideDestination:n,previousImpact:a})=>{if(!r.isCombineEnabled||!lg(a))return null;function l(v){const S={type:"COMBINE",combine:{draggableId:v,droppableId:r.descriptor.id}};return{...a,at:S}}const d=a.displaced.all,p=d.length?d[0]:null;if(e)return p?l(p):null;const m=qf(t,n);if(!p){if(!m.length)return null;const v=m[m.length-1];return l(v.descriptor.id)}const x=m.findIndex(v=>v.descriptor.id===p);x===-1&&Pt();const y=x-1;if(y<0)return null;const w=m[y];return l(w.descriptor.id)},nd=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Lv={point:gi,value:0},C0={invisible:{},visible:{},all:[]},XR={displaced:C0,displacedBy:Lv,at:null};var Ao=(e,t)=>r=>e<=r&&r<=t,Iv=e=>{const t=Ao(e.top,e.bottom),r=Ao(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 p=n.top<e.top&&n.bottom>e.bottom,m=n.left<e.left&&n.right>e.right;return p&&m?!0:p&&l||m&&c}},JR=e=>{const t=Ao(e.top,e.bottom),r=Ao(e.left,e.right);return n=>t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right)};const cg={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},Ev={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var eM=e=>t=>{const r=Ao(t.top,t.bottom),n=Ao(t.left,t.right);return a=>e===cg?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)};const tM=(e,t)=>{const r=t.frame?t.frame.scroll.diff.displacement:gi;return B0(e,r)},rM=(e,t,r)=>t.subject.active?r(t.subject.active)(e):!1,nM=(e,t,r)=>r(t)(e),ug=({target:e,destination:t,viewport:r,withDroppableDisplacement:n,isVisibleThroughFrameFn:a})=>{const c=n?tM(e,t):e;return rM(c,t,a)&&nM(c,r,a)},sM=e=>ug({...e,isVisibleThroughFrameFn:Iv}),Nv=e=>ug({...e,isVisibleThroughFrameFn:JR}),iM=e=>ug({...e,isVisibleThroughFrameFn:eM(e.destination.axis)}),aM=(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 oM(e,t){const r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return Fo(ig(r,n))}function _0({afterDragging:e,destination:t,displacedBy:r,viewport:n,forceShouldAnimate:a,last:c}){return e.reduce(function(d,p){const m=oM(p,r),x=p.descriptor.id;if(d.all.push(x),!sM({target:m,destination:t,viewport:n,withDroppableDisplacement:!0}))return d.invisible[p.descriptor.id]=!0,d;const w=aM(x,c,a),v={draggableId:x,shouldAnimate:w};return d.visible[x]=v,d},{all:[],visible:{},invisible:{}})}function lM(e,t){if(!e.length)return 0;const r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function m5({insideDestination:e,inHomeList:t,displacedBy:r,destination:n}){const a=lM(e,{inHomeList:t});return{displaced:C0,displacedBy:r,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function Lf({draggable:e,insideDestination:t,destination:r,viewport:n,displacedBy:a,last:c,index:l,forceShouldAnimate:d}){const p=nd(e,r);if(l==null)return m5({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const m=t.find(S=>S.descriptor.index===l);if(!m)return m5({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const x=qf(e,t),y=t.indexOf(m),w=x.slice(y);return{displaced:_0({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 dc(e,t){return!!t.effected[e]}var cM=({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 dc(c,a)?e?d:d-1:e?d+1:d},uM=({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,p=t?d:d+1;return c<l||c>p?null:c},dM=({isMovingForward:e,isInHomeList:t,draggable:r,draggables:n,destination:a,insideDestination:c,previousImpact:l,viewport:d,afterCritical:p})=>{const m=l.at;if(m||Pt(),m.type==="REORDER"){const y=uM({isMovingForward:e,isInHomeList:t,location:m.destination,insideDestination:c});return y==null?null:Lf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:y})}const x=cM({isMovingForward:e,destination:a,displaced:l.displaced,draggables:n,combine:m.combine,afterCritical:p});return x==null?null:Lf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:x})},hM=({displaced:e,afterCritical:t,combineWith:r,displacedBy:n})=>{const a=!!(e.visible[r]||e.invisible[r]);return dc(r,t)?a?gi:td(n.point):a?n.point:gi},fM=({afterCritical:e,impact:t,draggables:r})=>{const n=Vf(t);n||Pt();const a=n.draggableId,c=r[a].page.borderBox.center,l=hM({displaced:t.displaced,afterCritical:e,combineWith:a,displacedBy:t.displacedBy});return Ni(c,l)};const Rv=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,pM=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,dg=(e,t,r)=>t[e.crossAxisStart]+r.margin[e.crossAxisStart]+r.borderBox[e.crossAxisSize]/2,g5=({axis:e,moveRelativeTo:t,isMoving:r})=>Zc(e.line,t.marginBox[e.end]+Rv(e,r),dg(e,t.marginBox,r)),x5=({axis:e,moveRelativeTo:t,isMoving:r})=>Zc(e.line,t.marginBox[e.start]-pM(e,r),dg(e,t.marginBox,r)),mM=({axis:e,moveInto:t,isMoving:r})=>Zc(e.line,t.contentBox[e.start]+Rv(e,r),dg(e,t.contentBox,r));var gM=({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:a})=>{const c=rd(n.descriptor.id,r),l=t.page,d=n.axis;if(!c.length)return mM({axis:d,moveInto:n.page,isMoving:l});const{displaced:p,displacedBy:m}=e,x=p.all[0];if(x){const w=r[x];if(dc(x,a))return x5({axis:d,moveRelativeTo:w.page,isMoving:l});const v=Tf(w.page,m.point);return x5({axis:d,moveRelativeTo:v,isMoving:l})}const y=c[c.length-1];if(y.descriptor.id===t.descriptor.id)return l.borderBox.center;if(dc(y.descriptor.id,a)){const w=Tf(y.page,td(a.displacedBy.point));return g5({axis:d,moveRelativeTo:w,isMoving:l})}return g5({axis:d,moveRelativeTo:y.page,isMoving:l})},g1=(e,t)=>{const r=e.frame;return r?Ni(t,r.scroll.diff.displacement):t};const xM=({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"?gM({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:a}):fM({impact:e,draggables:n,afterCritical:a})};var Yf=e=>{const t=xM(e),r=e.droppable;return r?g1(r,t):t},Mv=(e,t)=>{const r=$a(t,e.scroll.initial),n=td(r);return{frame:Fo({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 b5(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 yM=({impact:e,viewport:t,destination:r,draggables:n,maxScrollChange:a})=>{const c=Mv(t,Ni(t.scroll.current,a)),l=r.frame?og(r,Ni(r.frame.scroll.current,a)):r,d=e.displaced,p=_0({afterDragging:b5(d.all,n),destination:r,displacedBy:e.displacedBy,viewport:c.frame,last:d,forceShouldAnimate:!1}),m=_0({afterDragging:b5(d.all,n),destination:l,displacedBy:e.displacedBy,viewport:t.frame,last:d,forceShouldAnimate:!1}),x={},y={},w=[d,p,m];return d.all.forEach(S=>{const L=bM(S,w);if(L){y[S]=L;return}x[S]=!0}),{...e,displaced:{all:d.all,invisible:x,visible:y}}},vM=(e,t)=>Ni(e.scroll.diff.displacement,t),hg=({pageBorderBoxCenter:e,draggable:t,viewport:r})=>{const n=vM(r,e),a=$a(n,t.page.borderBox.center);return Ni(t.client.borderBox.center,a)},jv=({draggable:e,destination:t,newPageBorderBoxCenter:r,viewport:n,withDroppableDisplacement:a,onlyOnMainAxis:c=!1})=>{const l=$a(r,e.page.borderBox.center),p={target:B0(e.page.borderBox,l),destination:t,withDroppableDisplacement:a,viewport:n};return c?iM(p):Nv(p)},wM=({isMovingForward:e,draggable:t,destination:r,draggables:n,previousImpact:a,viewport:c,previousPageBorderBoxCenter:l,previousClientSelection:d,afterCritical:p})=>{if(!r.isEnabled)return null;const m=rd(r.descriptor.id,n),x=nd(t,r),y=KR({isMovingForward:e,draggable:t,destination:r,insideDestination:m,previousImpact:a})||dM({isMovingForward:e,isInHomeList:x,draggable:t,draggables:n,destination:r,insideDestination:m,previousImpact:a,viewport:c,afterCritical:p});if(!y)return null;const w=Yf({impact:y,draggable:t,droppable:r,draggables:n,afterCritical:p});if(jv({draggable:t,destination:r,newPageBorderBoxCenter:w,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:hg({pageBorderBoxCenter:w,draggable:t,viewport:c}),impact:y,scrollJumpRequest:null};const S=$a(w,l),L=yM({impact:y,viewport:c,destination:r,draggables:n,maxScrollChange:S});return{clientSelection:d,impact:L,scrollJumpRequest:S}};const ia=e=>{const t=e.subject.active;return t||Pt(),t};var AM=({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:n,viewport:a})=>{const c=r.subject.active;if(!c)return null;const l=r.axis,d=Ao(c[l.start],c[l.end]),p=Gf(n).filter(x=>x!==r).filter(x=>x.isEnabled).filter(x=>!!x.subject.active).filter(x=>Iv(a.frame)(ia(x))).filter(x=>{const y=ia(x);return e?c[l.crossAxisEnd]<y[l.crossAxisEnd]:y[l.crossAxisStart]<c[l.crossAxisStart]}).filter(x=>{const y=ia(x),w=Ao(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=ia(x)[l.crossAxisStart],v=ia(y)[l.crossAxisStart];return e?w-v:v-w}).filter((x,y,w)=>ia(x)[l.crossAxisStart]===ia(w[0])[l.crossAxisStart]);if(!p.length)return null;if(p.length===1)return p[0];const m=p.filter(x=>Ao(ia(x)[l.start],ia(x)[l.end])(t[l.line]));return m.length===1?m[0]:m.length>1?m.sort((x,y)=>ia(x)[l.start]-ia(y)[l.start])[0]:p.sort((x,y)=>{const w=f5(t,p5(ia(x))),v=f5(t,p5(ia(y)));return w!==v?w-v:ia(x)[l.start]-ia(y)[l.start]})[0]};const y5=(e,t)=>{const r=e.page.borderBox.center;return dc(e.descriptor.id,t)?$a(r,t.displacedBy.point):r},TM=(e,t)=>{const r=e.page.borderBox;return dc(e.descriptor.id,t)?B0(r,td(t.displacedBy.point)):r};var SM=({pageBorderBoxCenter:e,viewport:t,destination:r,insideDestination:n,afterCritical:a})=>n.filter(l=>Nv({target:TM(l,a),destination:r,viewport:t.frame,withDroppableDisplacement:!0})).sort((l,d)=>{const p=S0(e,g1(r,y5(l,a))),m=S0(e,g1(r,y5(d,a)));return p<m?-1:m<p?1:l.descriptor.index-d.descriptor.index})[0]||null,Q0=mi(function(t,r){const n=r[t.line];return{value:n,point:Zc(t.line,n)}});const CM=(e,t,r)=>{const n=e.axis;if(e.descriptor.mode==="virtual")return Zc(n.line,t[n.line]);const a=e.subject.page.contentBox[n.size],p=rd(e.descriptor.id,r).reduce((m,x)=>m+x.client.marginBox[n.size],0)+t[n.line]-a;return p<=0?null:Zc(n.line,p)},Dv=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),Bv=(e,t,r)=>{const n=e.frame;nd(t,e)&&Pt(),e.subject.withPlaceholder&&Pt();const a=Q0(e.axis,t.displaceBy).point,c=CM(e,a,r),l={placeholderSize:a,increasedBy:c,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!n){const x=Gu({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:e.frame});return{...e,subject:x}}const d=c?Ni(n.scroll.max,c):n.scroll.max,p=Dv(n,d),m=Gu({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:p});return{...e,subject:m,frame:p}},_M=e=>{const t=e.subject.withPlaceholder;t||Pt();const r=e.frame;if(!r){const l=Gu({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:l}}const n=t.oldFrameMaxScroll;n||Pt();const a=Dv(r,n),c=Gu({page:e.subject.page,axis:e.axis,frame:a,withPlaceholder:null});return{...e,subject:c,frame:a}};var kM=({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:C0,displacedBy:Lv,at:{type:"REORDER",destination:{droppableId:c.descriptor.id,index:0}}},w=Yf({impact:y,draggable:n,droppable:c,draggables:a,afterCritical:d}),v=nd(n,c)?c:Bv(c,n,a);return jv({draggable:n,destination:v,newPageBorderBoxCenter:w,viewport:l.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?y:null}const p=e[c.axis.line]<=t.page.borderBox.center[c.axis.line],m=(()=>{const y=t.descriptor.index;return t.descriptor.id===n.descriptor.id||p?y:y+1})(),x=Q0(c.axis,n.displaceBy);return Lf({draggable:n,insideDestination:r,destination:c,viewport:l,displacedBy:x,last:C0,index:m})},LM=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:r,isOver:n,draggables:a,droppables:c,viewport:l,afterCritical:d})=>{const p=AM({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:c,viewport:l});if(!p)return null;const m=rd(p.descriptor.id,a),x=SM({pageBorderBoxCenter:t,viewport:l,destination:p,insideDestination:m,afterCritical:d}),y=kM({previousPageBorderBoxCenter:t,destination:p,draggable:r,draggables:a,moveRelativeTo:x,insideDestination:m,viewport:l,afterCritical:d});if(!y)return null;const w=Yf({impact:y,draggable:r,droppable:p,draggables:a,afterCritical:d});return{clientSelection:hg({pageBorderBoxCenter:w,draggable:r,viewport:l}),impact:y,scrollJumpRequest:null}},za=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const IM=(e,t)=>{const r=za(e);return r?t[r]:null};var EM=({state:e,type:t})=>{const r=IM(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 p=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?wM({isMovingForward:p,previousPageBorderBoxCenter:x,draggable:m,destination:c,draggables:y,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):LM({isMovingForward:p,previousPageBorderBoxCenter:x,draggable:m,isOver:c,draggables:y,droppables:w,viewport:e.viewport,afterCritical:e.afterCritical})};function Mc(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function Qv(e){const t=Ao(e.top,e.bottom),r=Ao(e.left,e.right);return function(a){return t(a.y)&&r(a.x)}}function NM(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function RM({pageBorderBox:e,draggable:t,candidates:r}){const n=t.page.borderBox.center,a=r.map(c=>{const l=c.axis,d=Zc(c.axis.line,e.center[l.line],c.page.borderBox.center[l.crossAxisLine]);return{id:c.descriptor.id,distance:S0(n,d)}}).sort((c,l)=>l.distance-c.distance);return a[0]?a[0].id:null}function MM({pageBorderBox:e,draggable:t,droppables:r}){const n=Gf(r).filter(a=>{if(!a.isEnabled)return!1;const c=a.subject.active;if(!c||!NM(e,c))return!1;if(Qv(c)(e.center))return!0;const l=a.axis,d=c.center[l.crossAxisLine],p=e[l.crossAxisStart],m=e[l.crossAxisEnd],x=Ao(c[l.crossAxisStart],c[l.crossAxisEnd]),y=x(p),w=x(m);return!y&&!w?!0:y?p<d:m>d});return n.length?n.length===1?n[0].descriptor.id:RM({pageBorderBox:e,draggable:t,candidates:n}):null}const Pv=(e,t)=>Fo(B0(e,t));var jM=(e,t)=>{const r=e.frame;return r?Pv(t,r.scroll.diff.value):t};function Ov({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function DM({draggable:e,closest:t,inHomeList:r}){return t?r&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var BM=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:r,insideDestination:n,last:a,viewport:c,afterCritical:l})=>{const d=r.axis,p=Q0(r.axis,t.displaceBy),m=p.value,x=e[d.start],y=e[d.end],v=qf(t,n).find(L=>{const E=L.descriptor.id,R=L.page.borderBox.center[d.line],B=dc(E,l),z=Ov({displaced:a,id:E});return B?z?y<=R:x<R-m:z?y<=R+m:x<R})||null,S=DM({draggable:t,closest:v,inHomeList:nd(t,r)});return Lf({draggable:t,insideDestination:n,destination:r,viewport:c,last:a,displacedBy:p,index:S})};const QM=4;var PM=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:r,destination:n,insideDestination:a,afterCritical:c})=>{if(!n.isCombineEnabled)return null;const l=n.axis,d=Q0(n.axis,e.displaceBy),p=d.value,m=t[l.start],x=t[l.end],w=qf(e,a).find(S=>{const L=S.descriptor.id,E=S.page.borderBox,B=E[l.size]/QM,z=dc(L,c),O=Ov({displaced:r.displaced,id:L});return z?O?x>E[l.start]+B&&x<E[l.end]-B:m>E[l.start]-p+B&&m<E[l.end]-p-B:O?x>E[l.start]+p+B&&x<E[l.end]+p-B:m>E[l.start]+B&&m<E[l.end]-B});return w?{displacedBy:d,displaced:r.displaced,at:{type:"COMBINE",combine:{draggableId:w.descriptor.id,droppableId:n.descriptor.id}}}:null},Fv=({pageOffset:e,draggable:t,draggables:r,droppables:n,previousImpact:a,viewport:c,afterCritical:l})=>{const d=Pv(t.page.borderBox,e),p=MM({pageBorderBox:d,draggable:t,droppables:n});if(!p)return XR;const m=n[p],x=rd(m.descriptor.id,r),y=jM(m,d);return PM({pageBorderBoxWithDroppableScroll:y,draggable:t,previousImpact:a,destination:m,insideDestination:x,afterCritical:l})||BM({pageBorderBoxWithDroppableScroll:y,draggable:t,destination:m,insideDestination:x,last:a.displaced,viewport:c,afterCritical:l})},fg=(e,t)=>({...e,[t.descriptor.id]:t});const OM=({previousImpact:e,impact:t,droppables:r})=>{const n=za(e),a=za(t);if(!n||n===a)return r;const c=r[n];if(!c.subject.withPlaceholder)return r;const l=_M(c);return fg(r,l)};var FM=({draggable:e,draggables:t,droppables:r,previousImpact:n,impact:a})=>{const c=OM({previousImpact:n,impact:a,droppables:r}),l=za(a);if(!l)return c;const d=r[l];if(nd(e,d)||d.subject.withPlaceholder)return c;const p=Bv(d,e,t);return fg(c,p)},u0=({state:e,clientSelection:t,dimensions:r,viewport:n,impact:a,scrollJumpRequest:c})=>{const l=n||e.viewport,d=r||e.dimensions,p=t||e.current.client.selection,m=$a(p,e.initial.client.selection),x={offset:m,selection:p,borderBoxCenter:Ni(e.initial.client.borderBoxCenter,m)},y={selection:Ni(x.selection,l.scroll.current),borderBoxCenter:Ni(x.borderBoxCenter,l.scroll.current),offset:Ni(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],S=a||Fv({pageOffset:y.offset,draggable:v,draggables:d.draggables,droppables:d.droppables,previousImpact:e.impact,viewport:l,afterCritical:e.afterCritical}),L=FM({draggable:v,impact:S,previousImpact:e.impact,draggables:d.draggables,droppables:d.droppables});return{...e,current:w,dimensions:{draggables:d.draggables,droppables:L},impact:S,viewport:l,scrollJumpRequest:c||null,forceShouldAnimate:c?!1:null}};function $M(e,t){return e.map(r=>t[r])}var $v=({impact:e,viewport:t,draggables:r,destination:n,forceShouldAnimate:a})=>{const c=e.displaced,l=$M(c.all,r),d=_0({afterDragging:l,destination:n,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:a,last:c});return{...e,displaced:d}},Uv=({impact:e,draggable:t,droppable:r,draggables:n,viewport:a,afterCritical:c})=>{const l=Yf({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:c});return hg({pageBorderBoxCenter:l,draggable:t,viewport:a})},zv=({state:e,dimensions:t,viewport:r})=>{e.movementMode!=="SNAP"&&Pt();const n=e.impact,a=r||e.viewport,c=t||e.dimensions,{draggables:l,droppables:d}=c,p=l[e.critical.draggable.id],m=za(n);m||Pt();const x=d[m],y=$v({impact:n,viewport:a,destination:x,draggables:l}),w=Uv({impact:y,draggable:p,droppable:x,draggables:l,viewport:a,afterCritical:e.afterCritical});return u0({impact:y,clientSelection:w,state:e,dimensions:c,viewport:a})},UM=e=>({index:e.index,droppableId:e.droppableId}),Hv=({draggable:e,home:t,draggables:r,viewport:n})=>{const a=Q0(t.axis,e.displaceBy),c=rd(t.descriptor.id,r),l=c.indexOf(e);l===-1&&Pt();const d=c.slice(l+1),p=d.reduce((w,v)=>(w[v.descriptor.id]=!0,w),{}),m={inVirtualList:t.descriptor.mode==="virtual",displacedBy:a,effected:p};return{impact:{displaced:_0({afterDragging:d,destination:t,displacedBy:a,last:null,viewport:n.frame,forceShouldAnimate:!1}),displacedBy:a,at:{type:"REORDER",destination:UM(e.descriptor)}},afterCritical:m}},zM=(e,t)=>({draggables:e.draggables,droppables:fg(e.droppables,t)}),HM=({draggable:e,offset:t,initialWindowScroll:r})=>{const n=Tf(e.client,t),a=Sf(n,r);return{...e,placeholder:{...e.placeholder,client:n},client:n,page:a}},WM=e=>{const t=e.frame;return t||Pt(),t},GM=({additions:e,updatedDroppables:t,viewport:r})=>{const n=r.scroll.diff.value;return e.map(a=>{const c=a.descriptor.droppableId,l=t[c],p=WM(l).scroll.diff.value,m=Ni(n,p);return HM({draggable:a,offset:m,initialWindowScroll:r.scroll.initial})})},VM=({state:e,published:t})=>{const r=t.modified.map(R=>{const B=e.dimensions.droppables[R.droppableId];return og(B,R.scroll)}),n={...e.dimensions.droppables,..._v(r)},a=kv(GM({additions:t.additions,updatedDroppables:n,viewport:e.viewport})),c={...e.dimensions.draggables,...a};t.removals.forEach(R=>{delete c[R]});const l={droppables:n,draggables:c},d=za(e.impact),p=d?l.droppables[d]:null,m=l.draggables[e.critical.draggable.id],x=l.droppables[e.critical.droppable.id],{impact:y,afterCritical:w}=Hv({draggable:m,home:x,draggables:c,viewport:e.viewport}),v=p&&p.isCombineEnabled?e.impact:y,S=Fv({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}),L={...e,phase:"DRAGGING",impact:S,onLiftImpact:y,dimensions:l,afterCritical:w,forceShouldAnimate:!1};return e.phase==="COLLECTING"?L:{...L,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const x1=e=>e.movementMode==="SNAP",lm=(e,t,r)=>{const n=zM(e.dimensions,t);return!x1(e)||r?u0({state:e,dimensions:n}):zv({state:e,dimensions:n})};function cm(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const v5={phase:"IDLE",completed:null,shouldFlush:!1};var qM=(e=v5,t)=>{if(t.type==="FLUSH")return{...v5,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&Pt();const{critical:r,clientSelection:n,viewport:a,dimensions:c,movementMode:l}=t.payload,d=c.draggables[r.draggable.id],p=c.droppables[r.droppable.id],m={selection:n,borderBoxCenter:d.client.borderBox.center,offset:gi},x={client:m,page:{selection:Ni(m.selection,a.scroll.initial),borderBoxCenter:Ni(m.selection,a.scroll.initial),offset:Ni(m.selection,a.scroll.diff.value)}},y=Gf(c.droppables).every(L=>!L.isFixedOnPage),{impact:w,afterCritical:v}=Hv({draggable:d,home:p,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"&&Pt(),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||Pt(),VM({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Pt();const{client:r}=t.payload;return lc(r,e.current.client.selection)?e:u0({state:e,clientSelection:r,impact:x1(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return cm(e);Mc(e)||Pt();const{id:r,newScroll:n}=t.payload,a=e.dimensions.droppables[r];if(!a)return e;const c=og(a,n);return lm(e,c,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Pt();const{id:r,isEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Pt(),a.isEnabled===n&&Pt();const c={...a,isEnabled:n};return lm(e,c,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Pt();const{id:r,isCombineEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Pt(),a.isCombineEnabled===n&&Pt();const c={...a,isCombineEnabled:n};return lm(e,c,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;Mc(e)||Pt(),e.isWindowScrollAllowed||Pt();const r=t.payload.newScroll;if(lc(e.viewport.scroll.current,r))return cm(e);const n=Mv(e.viewport,r);return x1(e)?zv({state:e,viewport:n}):u0({state:e,viewport:n})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!Mc(e))return e;const r=t.payload.maxScroll;if(lc(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"&&Pt();const r=EM({state:e,type:t.type});return r?u0({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"&&Pt(),{...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"||Pt(),{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 $n(e,t){return e instanceof Object&&"type"in e&&e.type===t}const YM=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),ZM=e=>({type:"LIFT",payload:e}),KM=e=>({type:"INITIAL_PUBLISH",payload:e}),XM=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),JM=()=>({type:"COLLECTION_STARTING",payload:null}),ej=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),tj=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),rj=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Wv=e=>({type:"MOVE",payload:e}),nj=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),sj=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),ij=()=>({type:"MOVE_UP",payload:null}),aj=()=>({type:"MOVE_DOWN",payload:null}),oj=()=>({type:"MOVE_RIGHT",payload:null}),lj=()=>({type:"MOVE_LEFT",payload:null}),pg=()=>({type:"FLUSH",payload:null}),cj=e=>({type:"DROP_ANIMATE",payload:e}),mg=e=>({type:"DROP_COMPLETE",payload:e}),Gv=e=>({type:"DROP",payload:e}),uj=e=>({type:"DROP_PENDING",payload:e}),Vv=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var dj=e=>({getState:t,dispatch:r})=>n=>a=>{if(!$n(a,"LIFT")){n(a);return}const{id:c,clientSelection:l,movementMode:d}=a.payload,p=t();p.phase==="DROP_ANIMATING"&&r(mg({completed:p.completed})),t().phase!=="IDLE"&&Pt(),r(pg()),r(YM({draggableId:c,movementMode:d}));const x={draggableId:c,scrollOptions:{shouldPublishImmediately:d==="SNAP"}},{critical:y,dimensions:w,viewport:v}=e.startPublishing(x);r(KM({critical:y,dimensions:w,clientSelection:l,movementMode:d,viewport:v}))},hj=e=>()=>t=>r=>{$n(r,"INITIAL_PUBLISH")&&e.dragging(),$n(r,"DROP_ANIMATE")&&e.dropping(r.payload.completed.result.reason),($n(r,"FLUSH")||$n(r,"DROP_COMPLETE"))&&e.resting(),t(r)};const gg={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},k0={opacity:{drop:0,combining:.7},scale:{drop:.75}},qv={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},Rc=`${qv.outOfTheWay}s ${gg.outOfTheWay}`,d0={fluid:`opacity ${Rc}`,snap:`transform ${Rc}, opacity ${Rc}`,drop:e=>{const t=`${e}s ${gg.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${Rc}`,placeholder:`height ${Rc}, width ${Rc}, margin ${Rc}`},w5=e=>lc(e,gi)?void 0:`translate(${e.x}px, ${e.y}px)`,b1={moveTo:w5,drop:(e,t)=>{const r=w5(e);if(r)return t?`${r} scale(${k0.scale.drop})`:r}},{minDropTime:y1,maxDropTime:Yv}=qv,fj=Yv-y1,A5=1500,pj=.6;var mj=({current:e,destination:t,reason:r})=>{const n=S0(e,t);if(n<=0)return y1;if(n>=A5)return Yv;const a=n/A5,c=y1+fj*a,l=r==="CANCEL"?c*pj:c;return Number(l.toFixed(2))},gj=({impact:e,draggable:t,dimensions:r,viewport:n,afterCritical:a})=>{const{draggables:c,droppables:l}=r,d=za(e),p=d?l[d]:null,m=l[t.descriptor.droppableId],x=Uv({impact:e,draggable:t,draggables:c,afterCritical:a,droppable:p||m,viewport:n});return $a(x,t.client.borderBox.center)},xj=({draggables:e,reason:t,lastImpact:r,home:n,viewport:a,onLiftImpact:c})=>!r.at||t!=="DROP"?{impact:$v({draggables:e,impact:c,destination:n,viewport:a,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:r.at.type==="REORDER"?{impact:r,didDropInsideDroppable:!0}:{impact:{...r,displaced:C0},didDropInsideDroppable:!0};const bj=({getState:e,dispatch:t})=>r=>n=>{if(!$n(n,"DROP")){r(n);return}const a=e(),c=n.payload.reason;if(a.phase==="COLLECTING"){t(uj({reason:c}));return}if(a.phase==="IDLE")return;a.phase==="DROP_PENDING"&&a.isWaiting&&Pt(),a.phase==="DRAGGING"||a.phase==="DROP_PENDING"||Pt();const d=a.critical,p=a.dimensions,m=p.draggables[a.critical.draggable.id],{impact:x,didDropInsideDroppable:y}=xj({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?lg(x):null,v=y?Vf(x):null,S={index:d.draggable.index,droppableId:d.droppable.id},L={draggableId:m.descriptor.id,type:m.descriptor.type,source:S,reason:c,mode:a.movementMode,destination:w,combine:v},E=gj({impact:x,draggable:m,dimensions:p,viewport:a.viewport,afterCritical:a.afterCritical}),R={critical:a.critical,afterCritical:a.afterCritical,result:L,impact:x};if(!(!lc(a.current.client.offset,E)||!!L.combine)){t(mg({completed:R}));return}const z=mj({current:a.current.client.offset,destination:E,reason:c});t(cj({newHomeClientOffset:E,dropDuration:z,completed:R}))};var Zv=()=>({x:window.pageXOffset,y:window.pageYOffset});function yj(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function vj({onWindowScroll:e}){function t(){e(Zv())}const r=T0(t),n=yj(r);let a=oc;function c(){return a!==oc}function l(){c()&&Pt(),a=wo(window,[n])}function d(){c()||Pt(),r.cancel(),a(),a=oc}return{start:l,stop:d,isActive:c}}const wj=e=>$n(e,"DROP_COMPLETE")||$n(e,"DROP_ANIMATE")||$n(e,"FLUSH"),Aj=e=>{const t=vj({onWindowScroll:r=>{e.dispatch(nj({newScroll:r}))}});return r=>n=>{!t.isActive()&&$n(n,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&wj(n)&&t.stop(),r(n)}};var Tj=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},Sj=()=>{const e=[],t=a=>{const c=e.findIndex(d=>d.timerId===a);c===-1&&Pt();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 Cj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,_j=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,kj=(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},Md=(e,t)=>{t()},Ah=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function um(e,t,r,n){if(!e){r(n(t));return}const a=Tj(r);e(t,{announce:a}),a.wasCalled()||r(n(t))}var Lj=(e,t)=>{const r=Sj();let n=null;const a=(y,w)=>{n&&Pt(),Md("onBeforeCapture",()=>{const v=e().onBeforeCapture;v&&v({draggableId:y,mode:w})})},c=(y,w)=>{n&&Pt(),Md("onBeforeDragStart",()=>{const v=e().onBeforeDragStart;v&&v(Ah(y,w))})},l=(y,w)=>{n&&Pt();const v=Ah(y,w);n={mode:w,lastCritical:y,lastLocation:v.source,lastCombine:null},r.add(()=>{Md("onDragStart",()=>um(e().onDragStart,v,t,Kh.onDragStart))})},d=(y,w)=>{const v=lg(w),S=Vf(w);n||Pt();const L=!kj(y,n.lastCritical);L&&(n.lastCritical=y);const E=!Cj(n.lastLocation,v);E&&(n.lastLocation=v);const R=!_j(n.lastCombine,S);if(R&&(n.lastCombine=S),!L&&!E&&!R)return;const B={...Ah(y,n.mode),combine:S,destination:v};r.add(()=>{Md("onDragUpdate",()=>um(e().onDragUpdate,B,t,Kh.onDragUpdate))})},p=()=>{n||Pt(),r.flush()},m=y=>{n||Pt(),n=null,Md("onDragEnd",()=>um(e().onDragEnd,y,t,Kh.onDragEnd))};return{beforeCapture:a,beforeStart:c,start:l,update:d,flush:p,drop:m,abort:()=>{if(!n)return;const y={...Ah(n.lastCritical,n.mode),combine:null,destination:null,reason:"CANCEL"};m(y)}}},Ij=(e,t)=>{const r=Lj(e,t);return n=>a=>c=>{if($n(c,"BEFORE_INITIAL_CAPTURE")){r.beforeCapture(c.payload.draggableId,c.payload.movementMode);return}if($n(c,"INITIAL_PUBLISH")){const d=c.payload.critical;r.beforeStart(d,c.payload.movementMode),a(c),r.start(d,c.payload.movementMode);return}if($n(c,"DROP_COMPLETE")){const d=c.payload.completed.result;r.flush(),a(c),r.drop(d);return}if(a(c),$n(c,"FLUSH")){r.abort();return}const l=n.getState();l.phase==="DRAGGING"&&r.update(l.critical,l.impact)}};const Ej=e=>t=>r=>{if(!$n(r,"DROP_ANIMATION_FINISHED")){t(r);return}const n=e.getState();n.phase!=="DROP_ANIMATING"&&Pt(),e.dispatch(mg({completed:n.completed}))},Nj=e=>{let t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return a=>c=>{if(($n(c,"FLUSH")||$n(c,"DROP_COMPLETE")||$n(c,"DROP_ANIMATION_FINISHED"))&&n(),a(c),!$n(c,"DROP_ANIMATE"))return;const l={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(Vv())}};r=requestAnimationFrame(()=>{r=null,t=wo(window,[l])})}};var Rj=e=>()=>t=>r=>{($n(r,"DROP_COMPLETE")||$n(r,"FLUSH")||$n(r,"DROP_ANIMATE"))&&e.stopPublishing(),t(r)},Mj=e=>{let t=!1;return()=>r=>n=>{if($n(n,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if($n(n,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if($n(n,"DROP_COMPLETE")){t=!1;const a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const jj=e=>$n(e,"DROP_COMPLETE")||$n(e,"DROP_ANIMATE")||$n(e,"FLUSH");var Dj=e=>t=>r=>n=>{if(jj(n)){e.stop(),r(n);return}if($n(n,"INITIAL_PUBLISH")){r(n);const a=t.getState();a.phase!=="DRAGGING"&&Pt(),e.start(a);return}r(n),e.scroll(t.getState())};const Bj=e=>t=>r=>{if(t(r),!$n(r,"PUBLISH_WHILE_DRAGGING"))return;const n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch(Gv({reason:n.reason})))},Qj=hv;var Pj=({dimensionMarshal:e,focusMarshal:t,styleMarshal:r,getResponders:n,announce:a,autoScroller:c})=>dv(qM,Qj(DN(hj(r),Rj(e),dj(e),bj,Ej,Nj,Bj,Dj(c),Aj,Mj(t),Ij(n,a))));const dm=()=>({additions:{},removals:{},modified:{}});function Oj({registry:e,callbacks:t}){let r=dm(),n=null;const a=()=>{n||(t.collectionStarting(),n=requestAnimationFrame(()=>{n=null;const{additions:p,removals:m,modified:x}=r,y=Object.keys(p).map(S=>e.draggable.getById(S).getDimension(gi)).sort((S,L)=>S.descriptor.index-L.descriptor.index),w=Object.keys(x).map(S=>{const E=e.droppable.getById(S).callbacks.getScrollWhileDragging();return{droppableId:S,scroll:E}}),v={additions:y,removals:Object.keys(m),modified:w};r=dm(),t.publish(v)}))};return{add:p=>{const m=p.descriptor.id;r.additions[m]=p,r.modified[p.descriptor.droppableId]=!0,r.removals[m]&&delete r.removals[m],a()},remove:p=>{const m=p.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=dm())}}}var Kv=({scrollHeight:e,scrollWidth:t,height:r,width:n})=>{const a=$a({x:t,y:e},{x:n,y:r});return{x:Math.max(0,a.x),y:Math.max(0,a.y)}},Xv=()=>{const e=document.documentElement;return e||Pt(),e},Jv=()=>{const e=Xv();return Kv({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},Fj=()=>{const e=Zv(),t=Jv(),r=e.y,n=e.x,a=Xv(),c=a.clientWidth,l=a.clientHeight,d=n+c,p=r+l;return{frame:Fo({top:r,left:n,right:d,bottom:p}),scroll:{initial:e,current:e,max:t,diff:{value:gi,displacement:gi}}}},$j=({critical:e,scrollOptions:t,registry:r})=>{const n=Fj(),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:kv(d),droppables:_v(l)},critical:e,viewport:n}};function T5(e,t,r){return!(r.descriptor.id===t.id||r.descriptor.type!==t.type||e.droppable.getById(r.descriptor.droppableId).descriptor.mode!=="virtual")}var Uj=(e,t)=>{let r=null;const n=Oj({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=(w,v)=>{e.droppable.exists(w)||Pt(),r&&t.updateDroppableIsEnabled({id:w,isEnabled:v})},c=(w,v)=>{r&&(e.droppable.exists(w)||Pt(),t.updateDroppableIsCombineEnabled({id:w,isCombineEnabled:v}))},l=(w,v)=>{r&&(e.droppable.exists(w)||Pt(),t.updateDroppableScroll({id:w,newScroll:v}))},d=(w,v)=>{r&&e.droppable.getById(w).callbacks.scroll(v)},p=()=>{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||Pt();const v=r.critical.draggable;w.type==="ADDITION"&&T5(e,v,w.value)&&n.add(w.value),w.type==="REMOVAL"&&T5(e,v,w.value)&&n.remove(w.value)};return{updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:c,scrollDroppable:d,updateDroppableScroll:l,startPublishing:w=>{r&&Pt();const v=e.draggable.getById(w.draggableId),S=e.droppable.getById(v.descriptor.droppableId),L={draggable:v.descriptor,droppable:S.descriptor},E=e.subscribe(m);return r={critical:L,unsubscribe:E},$j({critical:L,registry:e,scrollOptions:w.scrollOptions})},stopPublishing:p}},e6=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",zj=e=>{window.scrollBy(e.x,e.y)};const Hj=mi(e=>Gf(e).filter(t=>!(!t.isEnabled||!t.frame))),Wj=(e,t)=>Hj(t).find(n=>(n.frame||Pt(),Qv(n.frame.pageMarginBox)(e)))||null;var Gj=({center:e,destination:t,droppables:r})=>{if(t){const a=r[t];return a.frame?a:null}return Wj(e,r)};const L0={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var Vj=(e,t,r=()=>L0)=>{const n=r(),a=e[t.size]*n.startFromPercentage,c=e[t.size]*n.maxScrollAtPercentage;return{startScrollingFrom:a,maxScrollValueAt:c}},t6=({startOfRange:e,endOfRange:t,current:r})=>{const n=t-e;return n===0?0:(r-e)/n},xg=1,qj=(e,t,r=()=>L0)=>{const n=r();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return n.maxPixelScroll;if(e===t.startScrollingFrom)return xg;const c=1-t6({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),l=n.maxPixelScroll*n.ease(c);return Math.ceil(l)},Yj=(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 xg;const x=t6({startOfRange:a,endOfRange:d,current:m}),y=e*n.ease(x);return Math.ceil(y)},S5=({distanceToEdge:e,thresholds:t,dragStartTime:r,shouldUseTimeDampening:n,getAutoScrollerOptions:a})=>{const c=qj(e,t,a);return c===0?0:n?Math.max(Yj(c,r,a),xg):c},C5=({container:e,distanceToEdges:t,dragStartTime:r,axis:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=Vj(e,n,c);return t[n.end]<t[n.start]?S5({distanceToEdge:t[n.end],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c}):-1*S5({distanceToEdge:t[n.start],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c})},Zj=({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 Kj=Cv(e=>e===0?0:e);var r6=({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=C5({container:t,distanceToEdges:l,dragStartTime:e,axis:cg,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),p=C5({container:t,distanceToEdges:l,dragStartTime:e,axis:Ev,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),m=Kj({x:p,y:d});if(lc(m,gi))return null;const x=Zj({container:t,subject:r,proposedScroll:m});return x?lc(x,gi)?null:x:null};const Xj=Cv(e=>e===0?0:e>0?1:-1),bg=(()=>{const e=(t,r)=>t<0?t:t>r?t-r:0;return({current:t,max:r,change:n})=>{const a=Ni(t,n),c={x:e(a.x,r.x),y:e(a.y,r.y)};return lc(c,gi)?null:c}})(),n6=({max:e,current:t,change:r})=>{const n={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},a=Xj(r),c=bg({max:n,current:t,change:a});return!c||a.x!==0&&c.x===0||a.y!==0&&c.y===0},yg=(e,t)=>n6({current:e.scroll.current,max:e.scroll.max,change:t}),Jj=(e,t)=>{if(!yg(e,t))return null;const r=e.scroll.max,n=e.scroll.current;return bg({current:n,max:r,change:t})},vg=(e,t)=>{const r=e.frame;return r?n6({current:r.scroll.current,max:r.scroll.max,change:t}):!1},eD=(e,t)=>{const r=e.frame;return!r||!vg(e,t)?null:bg({current:r.scroll.current,max:r.scroll.max,change:t})};var tD=({viewport:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=r6({dragStartTime:n,container:e.frame,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return l&&yg(e,l)?l:null},rD=({droppable:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=e.frame;if(!l)return null;const d=r6({dragStartTime:n,container:l.pageMarginBox,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return d&&vg(e,d)?d:null},_5=({state:e,dragStartTime:t,shouldUseTimeDampening:r,scrollWindow:n,scrollDroppable:a,getAutoScrollerOptions:c})=>{const l=e.current.page.borderBoxCenter,p=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const y=e.viewport,w=tD({dragStartTime:t,viewport:y,subject:p,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});if(w){n(w);return}}const m=Gj({center:l,destination:za(e.impact),droppables:e.dimensions.droppables});if(!m)return;const x=rD({dragStartTime:t,droppable:m,subject:p,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});x&&a(m.descriptor.id,x)},nD=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r=()=>L0})=>{const n=T0(e),a=T0(t);let c=null;const l=m=>{c||Pt();const{shouldUseTimeDampening:x,dragStartTime:y}=c;_5({state:m,scrollWindow:n,scrollDroppable:a,dragStartTime:y,shouldUseTimeDampening:x,getAutoScrollerOptions:r})};return{start:m=>{c&&Pt();const x=Date.now();let y=!1;const w=()=>{y=!0};_5({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}},sD=({move:e,scrollDroppable:t,scrollWindow:r})=>{const n=(d,p)=>{const m=Ni(d.current.client.selection,p);e({client:m})},a=(d,p)=>{if(!vg(d,p))return p;const m=eD(d,p);if(!m)return t(d.descriptor.id,p),null;const x=$a(p,m);return t(d.descriptor.id,x),$a(p,x)},c=(d,p,m)=>{if(!d||!yg(p,m))return m;const x=Jj(p,m);if(!x)return r(m),null;const y=$a(m,x);return r(y),$a(m,y)};return d=>{const p=d.scrollJumpRequest;if(!p)return;const m=za(d.impact);m||Pt();const x=a(d.dimensions.droppables[m],p);if(!x)return;const y=d.viewport,w=c(d.isWindowScrollAllowed,y,x);w&&n(d,w)}},iD=({scrollDroppable:e,scrollWindow:t,move:r,getAutoScrollerOptions:n})=>{const a=nD({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n}),c=sD({move:r,scrollWindow:t,scrollDroppable:e});return{scroll:p=>{if(!(n().disabled||p.phase!=="DRAGGING")){if(p.movementMode==="FLUID"){a.scroll(p);return}p.scrollJumpRequest&&c(p)}},start:a.start,stop:a.stop}};const Vu="data-rfd",qu=(()=>{const e=`${Vu}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),v1=(()=>{const e=`${Vu}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),aD=(()=>{const e=`${Vu}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),k5={contextId:`${Vu}-scroll-container-context-id`},oD=e=>t=>`[${t}="${e}"]`,jd=(e,t)=>e.map(r=>{const n=r.styles[t];return n?`${r.selector} { ${n} }`:""}).join(" "),lD="pointer-events: none;";var cD=e=>{const t=oD(e),r=(()=>{const d=`
118
+ cursor: -webkit-grab;
119
+ cursor: grab;
120
+ `;return{selector:t(qu.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:lD,dropAnimating:d}}})(),n=(()=>{const d=`
125
+ transition: ${d0.outOfTheWay};
126
+ `;return{selector:t(v1.contextId),styles:{dragging:d,dropAnimating:d,userCancel:d}}})(),a={selector:t(aD.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:jd(l,"always"),resting:jd(l,"resting"),dragging:jd(l,"dragging"),dropAnimating:jd(l,"dropAnimating"),userCancel:jd(l,"userCancel")}};const Ha=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,hm=()=>{const e=document.querySelector("head");return e||Pt(),e},L5=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function uD(e,t){const r=Sn(()=>cD(e),[e]),n=b.useRef(null),a=b.useRef(null),c=wr(mi(y=>{const w=a.current;w||Pt(),w.textContent=y}),[]),l=wr(y=>{const w=n.current;w||Pt(),w.textContent=y},[]);Ha(()=>{!n.current&&!a.current||Pt();const y=L5(t),w=L5(t);return n.current=y,a.current=w,y.setAttribute(`${Vu}-always`,e),w.setAttribute(`${Vu}-dynamic`,e),hm().appendChild(y),hm().appendChild(w),l(r.always),c(r.resting),()=>{const v=S=>{const L=S.current;L||Pt(),hm().removeChild(L),S.current=null};v(n),v(a)}},[t,l,c,r.always,r.resting,e]);const d=wr(()=>c(r.dragging),[c,r.dragging]),p=wr(y=>{if(y==="DROP"){c(r.dropAnimating);return}c(r.userCancel)},[c,r.dropAnimating,r.userCancel]),m=wr(()=>{a.current&&c(r.resting)},[c,r.resting]);return Sn(()=>({dragging:d,dropping:p,resting:m}),[d,p,m])}function s6(e,t){return Array.from(e.querySelectorAll(t))}var i6=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Zf(e){return e instanceof i6(e).HTMLElement}function dD(e,t){const r=`[${qu.contextId}="${e}"]`,n=s6(document,r);if(!n.length)return null;const a=n.find(c=>c.getAttribute(qu.draggableId)===t);return!a||!Zf(a)?null:a}function hD(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),c=wr(function(w,v){const S={id:w,focus:v};return t.current[w]=S,function(){const E=t.current;E[w]!==S&&delete E[w]}},[]),l=wr(function(w){const v=dD(e,w);v&&v!==document.activeElement&&v.focus()},[e]),d=wr(function(w,v){r.current===w&&(r.current=v)},[]),p=wr(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const w=r.current;w&&l(w)}))},[l]),m=wr(function(w){r.current=null;const v=document.activeElement;v&&v.getAttribute(qu.draggableId)===w&&(r.current=w)},[]);return Ha(()=>(a.current=!0,function(){a.current=!1;const w=n.current;w&&cancelAnimationFrame(w)}),[]),Sn(()=>({register:c,tryRecordFocus:m,tryRestoreFocusRecorded:p,tryShiftRecord:d}),[c,m,p,d])}function fD(){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||Pt(),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 p(y){const w=d(y);return w||Pt(),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:p,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 pD(){const e=Sn(fD,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var wg=k.createContext(null),If=()=>{const e=document.body;return e||Pt(),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%)"},gD=e=>`rfd-announcement-${e}`;function xD(e){const t=Sn(()=>gD(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"),Cf(c.style,mD),If().appendChild(c),function(){setTimeout(function(){const p=If();p.contains(c)&&p.removeChild(c),c===r.current&&(r.current=null)})}},[t]),wr(a=>{const c=r.current;if(c){c.textContent=a;return}},[])}const bD={separator:"::"};function Ag(e,t=bD){const r=k.useId();return Sn(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function yD({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function vD({contextId:e,text:t}){const r=Ag("hidden-text",{separator:"-"}),n=Sn(()=>yD({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",If().appendChild(c),function(){const d=If();d.contains(c)&&d.removeChild(c)}},[n,t]),n}var Kf=k.createContext(null);function a6(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function wD(){let e=null;function t(){return!!e}function r(l){return l===e}function n(l){e&&Pt();const d={abandon:l};return e=d,d}function a(){e||Pt(),e=null}function c(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:c}}function I0(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const AD=9,TD=13,Tg=27,o6=32,SD=33,CD=34,_D=35,kD=36,LD=37,ID=38,ED=39,ND=40,RD={[TD]:!0,[AD]:!0};var l6=e=>{RD[e.keyCode]&&e.preventDefault()};const Xf=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),c6=0,I5=5;function MD(e,t){return Math.abs(t.x-e.x)>=I5||Math.abs(t.y-e.y)>=I5}const E5={type:"IDLE"};function jD({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:c,clientX:l,clientY:d}=a;if(c!==c6)return;const p={x:l,y:d},m=r();if(m.type==="DRAGGING"){a.preventDefault(),m.actions.move(p);return}m.type!=="PENDING"&&Pt();const x=m.point;if(!MD(x,p))return;a.preventDefault();const y=m.actions.fluidLift(p);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===Tg){a.preventDefault(),e();return}l6(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"&&Pt(),c.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:Xf,fn:e}]}function DD(e){const t=b.useRef(E5),r=b.useRef(oc),n=Sn(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==c6||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 S={x:y.clientX,y:y.clientY};r.current(),m(v,S)}}),[e]),a=Sn(()=>({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=wr(function(){const y={passive:!1,capture:!0};r.current=wo(window,[a,n],y)},[a,n]),l=wr(()=>{t.current.type!=="IDLE"&&(t.current=E5,r.current(),c())},[c]),d=wr(()=>{const x=t.current;l(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[l]),p=wr(function(){const y={capture:!0,passive:!1},w=jD({cancel:d,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=wo(window,w,y)},[d,l]),m=wr(function(y,w){t.current.type!=="IDLE"&&Pt(),t.current={type:"PENDING",point:w,actions:y},p()},[p]);Ha(function(){return c(),function(){r.current()}},[c])}function BD(){}const QD={[CD]:!0,[SD]:!0,[kD]:!0,[_D]:!0};function PD(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===Tg){a.preventDefault(),r();return}if(a.keyCode===o6){a.preventDefault(),n();return}if(a.keyCode===ND){a.preventDefault(),e.moveDown();return}if(a.keyCode===ID){a.preventDefault(),e.moveUp();return}if(a.keyCode===ED){a.preventDefault(),e.moveRight();return}if(a.keyCode===LD){a.preventDefault(),e.moveLeft();return}if(QD[a.keyCode]){a.preventDefault();return}l6(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:Xf,fn:r}]}function OD(e){const t=b.useRef(BD),r=Sn(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==o6)return;const l=e.findClosestDraggableId(c);if(!l)return;const d=e.tryGetLock(l,x,{sourceEvent:c});if(!d)return;c.preventDefault();let p=!0;const m=d.snapLift();t.current();function x(){p||Pt(),p=!1,t.current(),n()}t.current=wo(window,PD(m,x),{capture:!0,passive:!1})}}),[e]),n=wr(function(){const c={passive:!1,capture:!0};t.current=wo(window,[r],c)},[r]);Ha(function(){return n(),function(){t.current()}},[n])}const fm={type:"IDLE"},FD=120,$D=.15;function UD({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===Tg&&r.preventDefault(),e()}},{eventName:Xf,fn:e}]}function zD({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"&&Pt();const c=n.touches[0];if(!c||!(c.force>=$D))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:Xf,fn:e}]}function HD(e){const t=b.useRef(fm),r=b.useRef(oc),n=wr(function(){return t.current},[]),a=wr(function(v){t.current=v},[]),c=Sn(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const S=e.findClosestDraggableId(v);if(!S)return;const L=e.tryGetLock(S,d,{sourceEvent:v});if(!L)return;const E=v.touches[0],{clientX:R,clientY:B}=E,z={x:R,y:B};r.current(),y(L,z)}}),[e]),l=wr(function(){const v={capture:!0,passive:!1};r.current=wo(window,[c],v)},[c]),d=wr(()=>{const w=t.current;w.type!=="IDLE"&&(w.type==="PENDING"&&clearTimeout(w.longPressTimerId),a(fm),r.current(),l())},[l,a]),p=wr(()=>{const w=t.current;d(),w.type==="DRAGGING"&&w.actions.cancel({shouldBlockNextClick:!0}),w.type==="PENDING"&&w.actions.abort()},[d]),m=wr(function(){const v={capture:!0,passive:!1},S={cancel:p,completed:d,getPhase:n},L=wo(window,zD(S),v),E=wo(window,UD(S),v);r.current=function(){L(),E()}},[p,n,d]),x=wr(function(){const v=n();v.type!=="PENDING"&&Pt();const S=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:S,hasMoved:!1})},[n,a]),y=wr(function(v,S){n().type!=="IDLE"&&Pt();const L=setTimeout(x,FD);a({type:"PENDING",point:S,actions:v,longPressTimerId:L}),m()},[m,n,a,x]);Ha(function(){return l(),function(){r.current();const S=n();S.type==="PENDING"&&(clearTimeout(S.longPressTimerId),a(fm))}},[n,l,a]),Ha(function(){return wo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const WD=["input","button","textarea","select","option","optgroup","video","audio"];function u6(e,t){if(t==null)return!1;if(WD.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:u6(e,t.parentElement)}function GD(e,t){const r=t.target;return Zf(r)?u6(e,r):!1}var VD=e=>Fo(e.getBoundingClientRect()).center;function qD(e){return e instanceof i6(e).Element}const YD=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function d6(e,t){return e==null?null:e[YD](t)?e:d6(e.parentElement,t)}function ZD(e,t){return e.closest?e.closest(t):d6(e,t)}function KD(e){return`[${qu.contextId}="${e}"]`}function XD(e,t){const r=t.target;if(!qD(r))return null;const n=KD(e),a=ZD(r,n);return!a||!Zf(a)?null:a}function JD(e,t){const r=XD(e,t);return r?r.getAttribute(qu.draggableId):null}function eB(e,t){const r=`[${v1.contextId}="${e}"]`,a=s6(document,r).find(c=>c.getAttribute(v1.id)===t);return!a||!Zf(a)?null:a}function tB(e){e.preventDefault()}function Th({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function h6({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!e6(t.getState(),n))}function rB({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:c,sourceEvent:l}){if(!h6({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const p=n.draggable.getById(a),m=eB(t,p.descriptor.id);if(!m||l&&!p.options.canDragInteractiveElements&&GD(m,l))return null;const x=e.claim(c||oc);let y="PRE_DRAG";function w(){return p.options.shouldRespectForcePress}function v(){return e.isActive(x)}function S($,V){Th({expected:$,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(V())}const L=S.bind(null,"DRAGGING");function E($){function V(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(V(),Pt()),r.dispatch(ZM($.liftActionArgs)),y="DRAGGING";function Z(le,be={shouldBlockNextClick:!1}){if($.cleanup(),be.shouldBlockNextClick){const pe=wo(window,[{eventName:"click",fn:tB,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(pe)}V(),r.dispatch(Gv({reason:le}))}return{isActive:()=>Th({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,drop:le=>Z("DROP",le),cancel:le=>Z("CANCEL",le),...$.actions}}function R($){const V=T0(le=>{L(()=>Wv({client:le}))});return{...E({liftActionArgs:{id:a,clientSelection:$,movementMode:"FLUID"},cleanup:()=>V.cancel(),actions:{move:V}}),move:V}}function B(){const $={moveUp:()=>L(ij),moveRight:()=>L(oj),moveDown:()=>L(aj),moveLeft:()=>L(lj)};return E({liftActionArgs:{id:a,clientSelection:VD(m),movementMode:"SNAP"},cleanup:oc,actions:$})}function z(){Th({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>Th({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,fluidLift:R,snapLift:B,abort:z}}const nB=[DD,OD,HD];function sB({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const c=[...a?nB:[],...n||[]],l=b.useState(()=>wD())[0],d=wr(function(E,R){I0(E)&&!I0(R)&&l.tryAbandon()},[l]);Ha(function(){let E=t.getState();return t.subscribe(()=>{const B=t.getState();d(E,B),E=B})},[l,t,d]),Ha(()=>l.tryAbandon,[l.tryAbandon]);const p=wr(L=>h6({lockAPI:l,registry:r,store:t,draggableId:L}),[l,r,t]),m=wr((L,E,R)=>rB({lockAPI:l,registry:r,contextId:e,store:t,draggableId:L,forceSensorStop:E||null,sourceEvent:R&&R.sourceEvent?R.sourceEvent:null}),[e,l,r,t]),x=wr(L=>JD(e,L),[e]),y=wr(L=>{const E=r.draggable.findById(L);return E?E.options:null},[r.draggable]),w=wr(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(pg()))},[l,t]),v=wr(()=>l.isClaimed(),[l]),S=Sn(()=>({canGetLock:p,tryGetLock:m,findClosestDraggableId:x,findOptionsForDraggable:y,tryReleaseLock:w,isLockClaimed:v}),[p,m,x,y,w,v]);for(let L=0;L<c.length;L++)c[L](S)}const iB=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};Xs.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),aB=e=>({...L0,...e.autoScrollerOptions,durationDampening:{...L0.durationDampening,...e.autoScrollerOptions}});function Dd(e){return e.current||Pt(),e.current}function oB(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:c}=e,l=b.useRef(null),d=a6(e),p=wr(()=>iB(d.current),[d]),m=wr(()=>aB(d.current),[d]),x=xD(t),y=vD({contextId:t,text:c}),w=uD(t,a),v=wr(pe=>{Dd(l).dispatch(pe)},[]),S=Sn(()=>r5({publishWhileDragging:XM,updateDroppableScroll:ej,updateDroppableIsEnabled:tj,updateDroppableIsCombineEnabled:rj,collectionStarting:JM},v),[v]),L=pD(),E=Sn(()=>Uj(L,S),[L,S]),R=Sn(()=>iD({scrollWindow:zj,scrollDroppable:E.scrollDroppable,getAutoScrollerOptions:m,...r5({move:Wv},v)}),[E.scrollDroppable,v,m]),B=hD(t),z=Sn(()=>Pj({announce:x,autoScroller:R,dimensionMarshal:E,focusMarshal:B,getResponders:p,styleMarshal:w}),[x,R,E,B,p,w]);l.current=z;const O=wr(()=>{const pe=Dd(l);pe.getState().phase!=="IDLE"&&pe.dispatch(pg())},[]),$=wr(()=>{const pe=Dd(l).getState();return pe.phase==="DROP_ANIMATING"?!0:pe.phase==="IDLE"?!1:pe.isDragging},[]),V=Sn(()=>({isDragging:$,tryAbort:O}),[$,O]);r(V);const Z=wr(pe=>e6(Dd(l).getState(),pe),[]),le=wr(()=>Mc(Dd(l).getState()),[]),be=Sn(()=>({marshal:E,focus:B,contextId:t,canLift:Z,isMovementAllowed:le,dragHandleUsageInstructionsId:y,registry:L}),[t,E,y,B,Z,le,L]);return sB({contextId:t,store:z,registry:L,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>O,[O]),k.createElement(Kf.Provider,{value:be},k.createElement(RR,{context:wg,store:z},e.children))}function lB(){return k.useId()}function h0(e){const t=lB(),r=e.dragHandleUsageInstructions||Kh.dragHandleUsageInstructions;return k.createElement(OR,null,n=>k.createElement(oB,{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 N5={dragging:5e3,dropAnimating:4500},cB=(e,t)=>t?d0.drop(t.duration):e?d0.snap:d0.fluid,uB=(e,t)=>{if(e)return t?k0.opacity.drop:k0.opacity.combining},dB=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function hB(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:c}=e,l=!!a,d=dB(e),p=!!c,m=p?b1.drop(n,l):b1.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:cB(d,c),transform:m,opacity:uB(l,p),zIndex:p?N5.dropAnimating:N5.dragging,pointerEvents:"none"}}function fB(e){return{transform:b1.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function pB(e){return e.type==="DRAGGING"?hB(e):fB(e)}function mB(e,t,r=gi){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),c=yv(a,n),l=Sf(c,r),d={client:c,tagName:t.tagName.toLowerCase(),display:n.display},p={x:c.marginBox.width,y:c.marginBox.height};return{descriptor:e,placeholder:d,displaceBy:p,client:c,page:l}}function gB(e){const t=Ag("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}=e,p=Sn(()=>({canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}),[c,d,l]),m=wr(v=>{const S=a();return S||Pt(),mB(r,S,v)},[r,a]),x=Sn(()=>({uniqueId:t,descriptor:r,options:p,getDimension:m}),[r,m,p,t]),y=b.useRef(x),w=b.useRef(!0);Ha(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),Ha(()=>{if(w.current){w.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var Sg=k.createContext(null);function Ef(e){const t=b.useContext(e);return t||Pt(),t}function xB(e){e.preventDefault()}const bB=e=>{const t=b.useRef(null),r=wr((V=null)=>{t.current=V},[]),n=wr(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:c,registry:l}=Ef(Kf),{type:d,droppableId:p}=Ef(Sg),m=Sn(()=>({id:e.draggableId,index:e.index,type:d,droppableId:p}),[e.draggableId,e.index,d,p]),{children:x,draggableId:y,isEnabled:w,shouldRespectForcePress:v,canDragInteractiveElements:S,isClone:L,mapped:E,dropAnimationFinished:R}=e;if(!L){const V=Sn(()=>({descriptor:m,registry:l,getDraggableRef:n,canDragInteractiveElements:S,shouldRespectForcePress:v,isEnabled:w}),[m,l,n,S,v,w]);gB(V)}const B=Sn(()=>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:xB}:null,[a,c,y,w]),z=wr(V=>{E.type==="DRAGGING"&&E.dropping&&V.propertyName==="transform"&&Xs.flushSync(R)},[R,E]),O=Sn(()=>{const V=pB(E),Z=E.type==="DRAGGING"&&E.dropping?z:void 0;return{innerRef:r,draggableProps:{"data-rfd-draggable-context-id":a,"data-rfd-draggable-id":y,style:V,onTransitionEnd:Z},dragHandleProps:B}},[a,B,y,E,z,r]),$=Sn(()=>({draggableId:m.id,type:m.type,source:{index:m.index,droppableId:m.droppableId}}),[m.droppableId,m.id,m.index,m.type]);return k.createElement(k.Fragment,null,x(O,E.snapshot,$))};var f6=(e,t)=>e===t,p6=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const yB=e=>e.combine?e.combine.draggableId:null,vB=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function wB(){const e=mi((a,c)=>({x:a,y:c})),t=mi((a,c,l=null,d=null,p=null)=>({isDragging:!0,isClone:c,isDropAnimating:!!p,dropAnimation:p,mode:a,draggingOver:l,combineWith:d,combineTargetFor:null})),r=mi((a,c,l,d,p=null,m=null,x=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:p,combineWith:m,mode:c,offset:a,dimension:l,forceShouldAnimate:x,snapshot:t(c,d,p,m,null)}}));return(a,c)=>{if(I0(a)){if(a.critical.draggable.id!==c.draggableId)return null;const l=a.current.client.offset,d=a.dimensions.draggables[c.draggableId],p=za(a.impact),m=vB(a.impact),x=a.forceShouldAnimate;return r(e(l.x,l.y),a.movementMode,d,c.isClone,p,m,x)}if(a.phase==="DROP_ANIMATING"){const l=a.completed;if(l.result.draggableId!==c.draggableId)return null;const d=c.isClone,p=a.dimensions.draggables[c.draggableId],m=l.result,x=m.mode,y=p6(m),w=yB(m),S={duration:a.dropDuration,curve:gg.drop,moveTo:a.newHomeClientOffset,opacity:w?k0.opacity.drop:null,scale:w?k0.scale.drop:null};return{mapped:{type:"DRAGGING",offset:a.newHomeClientOffset,dimension:p,dropping:S,draggingOver:y,combineWith:w,mode:x,forceShouldAnimate:null,snapshot:t(x,d,y,w,S)}}}return null}}function m6(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const AB={mapped:{type:"SECONDARY",offset:gi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:m6(null)}};function TB(){const e=mi((l,d)=>({x:l,y:d})),t=mi(m6),r=mi((l,d=null,p)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:d,shouldAnimateDisplacement:p,snapshot:t(d)}})),n=l=>l?r(gi,l,!0):null,a=(l,d,p,m)=>{const x=p.displaced.visible[l],y=!!(m.inVirtualList&&m.effected[l]),w=Vf(p),v=w&&w.draggableId===l?d:null;if(!x){if(!y)return n(v);if(p.displaced.invisible[l])return null;const E=td(m.displacedBy.point),R=e(E.x,E.y);return r(R,v,!0)}if(y)return n(v);const S=p.displacedBy.point,L=e(S.x,S.y);return r(L,v,x.shouldAnimate)};return(l,d)=>{if(I0(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 p=l.completed;return p.result.draggableId===d.draggableId?null:a(d.draggableId,p.result.draggableId,p.impact,p.afterCritical)}return null}}const SB=()=>{const e=wB(),t=TB();return(n,a)=>e(n,a)||t(n,a)||AB},CB={dropAnimationFinished:Vv},_B=bv(SB,CB,null,{context:wg,areStatePropsEqual:f6})(bB);function g6(e){return Ef(Sg).isUsingCloneFor===e.draggableId&&!e.isClone?null:k.createElement(_B,e)}function kl(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return k.createElement(g6,Cf({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const x6=e=>t=>e===t,kB=x6("scroll"),LB=x6("auto"),R5=(e,t)=>t(e.overflowX)||t(e.overflowY),IB=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return R5(r,kB)||R5(r,LB)},EB=()=>!1,b6=e=>e==null?null:e===document.body?EB()?e:null:e===document.documentElement?null:IB(e)?e:b6(e.parentElement);var w1=e=>({x:e.scrollLeft,y:e.scrollTop});const y6=e=>e?window.getComputedStyle(e).position==="fixed"?!0:y6(e.parentElement):!1;var NB=e=>{const t=b6(e),r=y6(e);return{closestScrollable:t,isFixedOnPage:r}},RB=({descriptor:e,isEnabled:t,isCombineEnabled:r,isFixedOnPage:n,direction:a,client:c,page:l,closest:d})=>{const p=(()=>{if(!d)return null;const{scrollSize:w,client:v}=d,S=Kv({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:S,diff:{value:gi,displacement:gi}}}})(),m=a==="vertical"?cg:Ev,x=Gu({page:l,withPlaceholder:null,axis:m,frame:p});return{descriptor:e,isCombineEnabled:r,isFixedOnPage:n,axis:m,isEnabled:t,client:c,page:l,frame:p,subject:x}};const MB=(e,t)=>{const r=vv(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,p=ig({top:n,right:l,bottom:c,left:a},r.border);return ag({borderBox:p,margin:r.margin,border:r.border,padding:r.padding})};var jB=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:c,isCombineEnabled:l,shouldClipSubject:d})=>{const p=r.closestScrollable,m=MB(e,p),x=Sf(m,n),y=(()=>{if(!p)return null;const v=vv(p),S={scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth};return{client:v,page:Sf(v,n),scroll:w1(p),scrollSize:S,shouldClipSubject:d}})();return RB({descriptor:t,isEnabled:!c,isCombineEnabled:l,isFixedOnPage:r.isFixedOnPage,direction:a,client:m,page:x,closest:y})};const DB={passive:!1},BB={passive:!0};var M5=e=>e.shouldPublishImmediately?DB:BB;const Sh=e=>e&&e.env.closestScrollable||null;function QB(e){const t=b.useRef(null),r=Ef(Kf),n=Ag("droppable"),{registry:a,marshal:c}=r,l=a6(e),d=Sn(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),p=b.useRef(d),m=Sn(()=>mi((O,$)=>{t.current||Pt();const V={x:O,y:$};c.updateDroppableScroll(d.id,V)}),[d.id,c]),x=wr(()=>{const O=t.current;return!O||!O.env.closestScrollable?gi:w1(O.env.closestScrollable)},[]),y=wr(()=>{const O=x();m(O.x,O.y)},[x,m]),w=Sn(()=>T0(y),[y]),v=wr(()=>{const O=t.current,$=Sh(O);if(O&&$||Pt(),O.scrollOptions.shouldPublishImmediately){y();return}w()},[w,y]),S=wr((O,$)=>{t.current&&Pt();const V=l.current,Z=V.getDroppableRef();Z||Pt();const le=NB(Z),be={ref:Z,descriptor:d,env:le,scrollOptions:$};t.current=be;const pe=jB({ref:Z,descriptor:d,env:le,windowScroll:O,direction:V.direction,isDropDisabled:V.isDropDisabled,isCombineEnabled:V.isCombineEnabled,shouldClipSubject:!V.ignoreContainerClipping}),ee=le.closestScrollable;return ee&&(ee.setAttribute(k5.contextId,r.contextId),ee.addEventListener("scroll",v,M5(be.scrollOptions))),pe},[r.contextId,d,v,l]),L=wr(()=>{const O=t.current,$=Sh(O);return O&&$||Pt(),w1($)},[]),E=wr(()=>{const O=t.current;O||Pt();const $=Sh(O);t.current=null,$&&(w.cancel(),$.removeAttribute(k5.contextId),$.removeEventListener("scroll",v,M5(O.scrollOptions)))},[v,w]),R=wr(O=>{const $=t.current;$||Pt();const V=Sh($);V||Pt(),V.scrollTop+=O.y,V.scrollLeft+=O.x},[]),B=Sn(()=>({getDimensionAndWatchScroll:S,getScrollWhileDragging:L,dragStopped:E,scroll:R}),[E,S,L,R]),z=Sn(()=>({uniqueId:n,descriptor:d,callbacks:B}),[B,d,n]);Ha(()=>(p.current=z.descriptor,a.droppable.register(z),()=>{t.current&&E(),a.droppable.unregister(z)}),[B,d,E,z,c,a.droppable]),Ha(()=>{t.current&&c.updateDroppableIsEnabled(p.current.id,!e.isDropDisabled)},[e.isDropDisabled,c]),Ha(()=>{t.current&&c.updateDroppableIsCombineEnabled(p.current.id,e.isCombineEnabled)},[e.isCombineEnabled,c])}function pm(){}const j5={width:0,height:0,margin:GR},PB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?j5:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},OB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=PB({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"?d0.placeholder:null}},FB=e=>{const t=b.useRef(null),r=wr(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:n,onTransitionEnd:a,onClose:c,contextId:l}=e,[d,p]=b.useState(e.animate==="open");b.useEffect(()=>d?n!=="open"?(r(),p(!1),pm):t.current?pm:(t.current=setTimeout(()=>{t.current=null,p(!1)}),r):pm,[n,d,r]);const m=wr(y=>{y.propertyName==="height"&&(a(),n==="close"&&c())},[n,c,a]),x=OB({isAnimatingOpenOnMount:d,animate:e.animate,placeholder:e.placeholder});return k.createElement(e.placeholder.tagName,{style:x,"data-rfd-placeholder-context-id":l,onTransitionEnd:m,ref:e.innerRef})};var $B=k.memo(FB);class UB extends k.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 zB=e=>{const t=b.useContext(Kf);t||Pt();const{contextId:r,isMovementAllowed:n}=t,a=b.useRef(null),c=b.useRef(null),{children:l,droppableId:d,type:p,mode:m,direction:x,ignoreContainerClipping:y,isDropDisabled:w,isCombineEnabled:v,snapshot:S,useClone:L,updateViewportMaxScroll:E,getContainerForClone:R}=e,B=wr(()=>a.current,[]),z=wr((ee=null)=>{a.current=ee},[]);wr(()=>c.current,[]);const O=wr((ee=null)=>{c.current=ee},[]),$=wr(()=>{n()&&E({maxScroll:Jv()})},[n,E]);QB({droppableId:d,type:p,mode:m,direction:x,isDropDisabled:w,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:B});const V=Sn(()=>k.createElement(UB,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:ee,data:_e,animate:ze})=>k.createElement($B,{placeholder:_e,onClose:ee,innerRef:O,animate:ze,contextId:r,onTransitionEnd:$})),[r,$,e.placeholder,e.shouldAnimatePlaceholder,O]),Z=Sn(()=>({innerRef:z,placeholder:V,droppableProps:{"data-rfd-droppable-id":d,"data-rfd-droppable-context-id":r}}),[r,d,V,z]),le=L?L.dragging.draggableId:null,be=Sn(()=>({droppableId:d,type:p,isUsingCloneFor:le}),[d,le,p]);function pe(){if(!L)return null;const{dragging:ee,render:_e}=L,ze=k.createElement(g6,{draggableId:ee.draggableId,index:ee.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(Y,ce)=>_e(Y,ce,ee));return uA.createPortal(ze,R())}return k.createElement(Sg.Provider,{value:be},l(Z,S),pe())};function HB(){return document.body||Pt(),document.body}const D5={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:HB},v6=e=>{let t={...e},r;for(r in D5)e[r]===void 0&&(t={...t,[r]:D5[r]});return t},mm=(e,t)=>e===t.droppable.type,B5=(e,t)=>t.draggables[e.draggable.id],WB=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=mi(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),n=mi((c,l,d,p,m,x)=>{const y=m.descriptor.id;if(m.descriptor.droppableId===c){const S=x?{render:x,dragging:r(m.descriptor)}:null,L={isDraggingOver:d,draggingOverWith:d?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!1,snapshot:L,useClone:S}}if(!l)return t;if(!p)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=v6(l),p=d.droppableId,m=d.type,x=!d.isDropDisabled,y=d.renderClone;if(I0(c)){const w=c.critical;if(!mm(m,w))return t;const v=B5(w,c.dimensions),S=za(c.impact)===p;return n(p,x,S,S,v,y)}if(c.phase==="DROP_ANIMATING"){const w=c.completed;if(!mm(m,w.critical))return t;const v=B5(w.critical,c.dimensions);return n(p,x,p6(w.result)===p,za(w.impact)===p,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const w=c.completed;if(!mm(m,w.critical))return t;const v=za(w.impact)===p,S=!!(w.impact.at&&w.impact.at.type==="COMBINE"),L=w.critical.droppable.id===p;return v?S?e:t:L?e:t}return t}},GB={updateViewportMaxScroll:sj},Ll=bv(WB,GB,(e,t,r)=>({...v6(r),...e,...t}),{context:wg,areStatePropsEqual:f6})(zB);function VB(){if(typeof window>"u")return Qu(void 0);try{const e=window.localStorage.getItem(i1);return Qu(e?JSON.parse(e):void 0)}catch{return Qu(void 0)}}function gm(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(i1),r=t?JSON.parse(t):{},n=Qu({...r,...e});window.localStorage.setItem(i1,JSON.stringify(n))}catch{}}function qB(){const[e,t]=k.useState(VB);k.useEffect(()=>{gm(e)},[e]);const r=k.useCallback(a=>{t(c=>{const l=Qu({...c,...a});return gm(l),l})},[]),n=k.useCallback(()=>{const a=Qu(void 0);t(a),gm(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const A1="termdock-settings";function YB(e){return e==="shell"||e==="tmux"}function ZB(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(A1);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&YB(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 Q5(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(A1),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(A1,JSON.stringify(n))}catch{}}function KB(){const[e,t]=k.useState(ZB),r=k.useCallback((a,c)=>{const l=c?.userInitiated!==!1;t(d=>({...d,mode:a,userSelectedMode:l?a:d.userSelectedMode})),l&&Q5({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=k.useCallback(a=>{t(c=>({...c,tmuxName:a})),Q5({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const XB=550,JB=10;function Cg(){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(p=>({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,p())},XB))},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)>JB&&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 P5({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 eQ(e,t,r){return!!(e&&t===e&&!r)}function tQ({groupId:e,version:t,onRestore:r}){const[n,a]=b.useState([]),[c,l]=b.useState(null),[d,p]=b.useState(""),m=b.useRef(!1);b.useEffect(()=>{let y=!0;const w=async()=>{try{const S=await I8();y&&a(S.entries.filter(L=>L.groups.some(E=>E.id===e)))}catch{}};w();const v=setInterval(()=>{document.hidden||w()},1e4);return()=>{y=!1,clearInterval(v)}},[e,t]);const x=async y=>{if(!m.current){m.current=!0,l(y.sessionId),p("");try{const w=await E8(y.sessionId);await r(w.session),a(v=>v.filter(S=>S.sessionId!==y.sessionId))}catch(w){p(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(My,{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(bn,{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 O5(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 Nf={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function w6(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(p=>!/^#{1,6}\s/.test(p)).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:Nf[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function Jf(e){if(e.status!=="open")return[];const t=w6(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 rQ(e){return Jf(e)[0]??null}function Kc(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=rQ(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?Nf[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 Ui(e){return e.purpose!=="automation"&&e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(Kc(e))}const Lu=hc(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await Sy();e({tasks:r.filter(Ui),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function F5(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 $5({sessionIds:e}){const t=N8(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=Ur();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 nQ(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 A6(e){const t=nQ(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 sQ(e,t,r){return Math.max(t,Math.min(e,r))}const fs={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 U5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function z5(e,t,r,n=.15){return n===0?sQ(e,t,r):e<t?-U5(t-e,r-t,n)+t:e>r?+U5(e-r,r-t,n)+r:e}function iQ(e,[t,r],[n,a]){const[[c,l],[d,p]]=e;return[z5(t,c,l,n),z5(r,d,p,a)]}function aQ(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 oQ(e){var t=aQ(e,"string");return typeof t=="symbol"?t:String(t)}function Os(e,t,r){return t=oQ(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function H5(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 vs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?H5(Object(r),!0).forEach(function(n){Os(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const T6={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 W5(e){return e?e[0].toUpperCase()+e.slice(1):""}const lQ=["enter","leave"];function cQ(e=!1,t){return e&&!lQ.includes(t)}function uQ(e,t="",r=!1){const n=T6[e],a=n&&n[t]||t;return"on"+W5(e)+W5(a)+(cQ(r,a)?"Capture":"")}const dQ=["gotpointercapture","lostpointercapture"];function hQ(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=dQ.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function fQ(e,t=""){const r=T6[e],n=r&&r[t]||t;return e+n}function ep(e){return"touches"in e}function S6(e){return ep(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function pQ(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 mQ(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function C6(e){return ep(e)?mQ(e)[0]:e}function T1(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 gQ(e){return pQ(e).map(t=>t.identifier)}function G5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return T1(r,n)}function xm(e){const t=C6(e);return ep(e)?t.identifier:t.pointerId}function Yu(e){const t=C6(e);return[t.clientX,t.clientY]}const V5=40,q5=800;function _6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=V5,r*=V5):n===2&&(t*=q5,r*=q5),[t,r]}function xQ(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 bQ(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 Rf(e,...t){return typeof e=="function"?e(...t):e}function yQ(){}function vQ(...e){return e.length===0?yQ:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function Y5(e,t){return Object.assign({},t,e||{})}const wQ=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?Rf(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,bQ(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 V=r._delta.map(Math.abs);fs.addTo(r._distance,V)}this.axisIntent&&this.axisIntent(t);const[l,d]=r._movement,[p,m]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(l)>=p&&y[0]),x[1]===!1&&(x[1]=Math.abs(d)>=m&&y[1])):(x[0]===!1&&(x[0]=Math.abs(l)>=p&&Math.sign(l)*p),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[V,Z]=y;w[0]=x[0]!==!1?V-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,S=r._active&&!r._blocked||r.active;S&&(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=Rf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[L,E]=r.offset,[[R,B],[z,O]]=r._bounds;r.overflow=[L<R?-1:L>B?1:0,E<z?-1:E>O?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 $=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=iQ(r._bounds,r.offset,$),r.delta=fs.sub(r.offset,v),this.computeMovement(),S&&(!r.last||c>wQ)){r.delta=fs.sub(r.offset,v);const V=r.delta.map(Math.abs);fs.addTo(r.distance,V),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&c>0&&(r.velocity=[V[0]/c,V[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(vs(vs(vs({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function AQ([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 P0 extends k6{constructor(...t){super(...t),Os(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=fs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=fs.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[S6(t)]:n.axisThreshold;r.axis=AQ(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 TQ=e=>e,Z5=.15,L6={enabled(e=!0){return e},eventOptions(e,t,r){return vs(vs({},r.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[Z5,Z5];case!1:return[0,0];default:return fs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return fs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||TQ},threshold(e){return fs.toVector(e,0)}},SQ=0,Jc=vs(vs({},L6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=SQ){return e},bounds(e={}){if(typeof e=="function")return c=>Jc.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]]}}),K5={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 CQ extends P0{constructor(...t){super(...t),Os(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=Jc.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=xm(t),n._pointerActive=!0,this.computeValues(Yu(t)),this.computeInitial(),r.preventScrollAxis&&S6(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=xm(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const c=Yu(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=fs.sub(c,r._values),this.computeValues(c)),fs.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=xm(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,p]=r._delta,[m,x]=r._movement,[y,w]=n.swipe.velocity,[v,S]=n.swipe.distance,L=n.swipe.duration;if(r.elapsedTime<L){const E=Math.abs(d/r.timeDelta),R=Math.abs(p/r.timeDelta);E>y&&Math.abs(m)>v&&(r.swipe[0]=Math.sign(d)),R>w&&Math.abs(x)>S&&(r.swipe[1]=Math.sign(p))}}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,_Q(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=K5[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,fs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in K5&&(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 _Q(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const O0=typeof window<"u"&&window.document&&window.document.createElement;function I6(){return O0&&"ontouchstart"in window}function kQ(){return I6()||O0&&window.navigator.maxTouchPoints>1}function LQ(){return O0&&"onpointerdown"in window}function IQ(){return O0&&"exitPointerLock"in window.document}function EQ(){try{return"constructor"in GestureEvent}catch{return!1}}const yo={isBrowser:O0,gesture:EQ(),touch:I6(),touchscreen:kQ(),pointer:LQ(),pointerLock:IQ()},NQ=250,RQ=180,MQ=.5,jQ=50,DQ=250,BQ=10,X5={mouse:0,touch:0,pen:8},QQ=vs(vs({},Jc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&yo.pointerLock,yo.touch&&r?"touch":this.pointerLock?"mouse":yo.pointer&&!a?"pointer":yo.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?NQ:void 0,!(!yo.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=fs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=MQ,distance:t=jQ,duration:r=DQ}={}){return{velocity:this.transform(fs.toVector(e)),distance:this.transform(fs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return RQ;case!1:return 0;default:return e}},axisThreshold(e){return e?vs(vs({},X5),e):X5},keyboardDisplacement(e=BQ){return e}});function E6(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 PQ=30,OQ=100;class FQ extends k6{constructor(...t){super(...t),Os(this,"ingKey","pinching"),Os(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=fs.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)*PQ-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=G5(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=T1(...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=G5(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=T1(...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=fs.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=[-_6(t)[1]/OQ*n.offset[0],0],fs.addTo(n._movement,n._delta),E6(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 $Q=vs(vs({},L6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!yo.touch&&yo.gesture)return"gesture";if(yo.touch&&n)return"touch";if(yo.touchscreen){if(yo.pointer)return"pointer";if(yo.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const d=Y5(Rf(r,l),{min:-1/0,max:1/0});return[d.min,d.max]},c=l=>{const d=Y5(Rf(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",fs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class UQ extends P0{constructor(...t){super(...t),Os(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(Yu(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=Yu(t),n=this.state;n._delta=fs.sub(r,n._values),fs.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 zQ=vs(vs({},Jc),{},{mouseOnly:(e=!0)=>e});class HQ extends P0{constructor(...t){super(...t),Os(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=xQ(t);r._delta=fs.sub(n,r._values),fs.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 WQ=Jc;class GQ extends P0{constructor(...t){super(...t),Os(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=_6(t),fs.addTo(r._movement,r._delta),E6(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 VQ=Jc;class qQ extends P0{constructor(...t){super(...t),Os(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Yu(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=Yu(t);r._movement=r._delta=fs.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 YQ=vs(vs({},Jc),{},{mouseOnly:(e=!0)=>e}),_g=new Map,S1=new Map;function N6(e){_g.set(e.key,e.engine),S1.set(e.key,e.resolver)}const R6={key:"drag",engine:CQ,resolver:QQ},ZQ={key:"hover",engine:qQ,resolver:YQ},KQ={key:"move",engine:UQ,resolver:zQ},XQ={key:"pinch",engine:FQ,resolver:$Q},JQ={key:"scroll",engine:HQ,resolver:WQ},eP={key:"wheel",engine:GQ,resolver:VQ};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 rP(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 nP={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=yo.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},sP=["target","eventOptions","window","enabled","transform"];function Xh(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]=Xh(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function iP(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:d,transform:p}=n,m=rP(n,sP);if(r.shared=Xh({target:a,eventOptions:c,window:l,enabled:d,transform:p},nP),t){const x=S1.get(t);r[t]=Xh(vs({shared:r.shared},m),x)}else for(const x in m){const y=S1.get(x);y&&(r[x]=Xh(vs({shared:r.shared},m[x]),y))}return r}class M6{constructor(t,r){Os(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,d=fQ(r,n),p=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=vs(vs({},p),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 aP{constructor(){Os(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 oP{constructor(t){Os(this,"gestures",new Set),Os(this,"_targetEventStore",new M6(this)),Os(this,"gestureEventStores",{}),Os(this,"gestureTimeoutStores",{}),Os(this,"handlers",{}),Os(this,"config",{}),Os(this,"pointerIds",new Set),Os(this,"touchIds",new Set),Os(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),lP(this,t)}setEventIds(t){if(ep(t))return this.touchIds=new Set(gQ(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=iP(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],p=J5(n,d.eventOptions,!!a);if(d.enabled){const m=_g.get(l);new m(this,t,l).bind(p)}}const c=J5(n,r.eventOptions,!!a);for(const l in this.nativeHandlers)c(l,"",d=>this.nativeHandlers[l](vs(vs({},this.state.shared),{},{event:d,args:t})),void 0,!0)}for(const c in n)n[c]=vQ(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:d,passive:p}=hQ(c);this._targetEventStore.add(a,l,"",n[c],{capture:d,passive:p})}}}}function wu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new M6(e,t),e.gestureTimeoutStores[t]=new aP}function lP(e,t){t.drag&&wu(e,"drag"),t.wheel&&wu(e,"wheel"),t.scroll&&wu(e,"scroll"),t.move&&wu(e,"move"),t.pinch&&wu(e,"pinch"),t.hover&&wu(e,"hover")}const J5=(e,t,r)=>(n,a,c,l={},d=!1)=>{var p,m;const x=(p=l.capture)!==null&&p!==void 0?p:t.capture,y=(m=l.passive)!==null&&m!==void 0?m:t.passive;let w=d?n:uQ(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},cP=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function uP(e){const t={},r={},n=new Set;for(let a in e)cP.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function Au(e,t,r,n,a,c){if(!e.has(r)||!_g.has(n))return;const l=r+"Start",d=r+"End",p=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]=p,c[n]=c[n]||{}}function dP(e,t){const[r,n,a]=uP(e),c={};return Au(a,r,"onDrag","drag",c,t),Au(a,r,"onWheel","wheel",c,t),Au(a,r,"onScroll","scroll",c,t),Au(a,r,"onPinch","pinch",c,t),Au(a,r,"onMove","move",c,t),Au(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function j6(e,t={},r,n){const a=k.useMemo(()=>new oP(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),k.useEffect(a.effect.bind(a)),k.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function eb(e,t){return N6(R6),j6({drag:e},t||{},"drag")}function hP(e){return e.forEach(N6),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=dP(r,n||{});return j6(a,l,void 0,c)}}function DU(e,t){return hP([R6,XQ,JQ,eP,KQ,ZQ])(e,t||{})}const tb={dampingRatio:.8,response:.3},fP=.998;function pP(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,S=l+a*c;return{value:L=>n+(v+S*L)*Math.exp(-a*L),velocity:L=>(S-a*(v+S*L))*Math.exp(-a*L)}}if(d<1){const v=a*Math.sqrt(1-d*d),S=c,L=(l+d*a*c)/v;return{value:E=>n+Math.exp(-d*a*E)*(S*Math.cos(v*E)+L*Math.sin(v*E)),velocity:E=>Math.exp(-d*a*E)*((L*v-d*a*S)*Math.cos(v*E)-(S*v+d*a*L)*Math.sin(v*E))}}const p=a*Math.sqrt(d*d-1),m=-d*a+p,x=-d*a-p,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 mP(e,t=fP){return e/1e3*(t/(1-t))}function rb(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function gP(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const xP=.1,bP=5;function yP(e,t,r,n,a){const c=pP(e,t,r,n),l=1e3/60,d=240,p=[];for(let m=0;m<d;m++){const x=m*l/1e3,y=c.value(x),w=c.velocity(x);if(p.push(a?a(y):y),m>0&&Math.abs(y-n)<xP&&Math.abs(w)<bP)break}return p.push(a?a(n):n),{frames:p,durationMs:(p.length-1)*l,solver:c}}const vP='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function wP(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(vP)&&e.blur()}const AP=18,nb=8,sb={touch:nb,pen:nb},TP=500,bm=200,ib=50,SP=`[${fA}]`;function ym(e,t,r){return Math.min(r,Math.max(t,e))}function ab(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 ob(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(SP)}function Bd(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const D6=k.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:d=!1},p){const{t:m}=Ur(),x=t==="left",y=x?-n:n,w=b.useRef(null),v=b.useRef(null),S=b.useRef(r?0:y),L=b.useRef(null),E=b.useRef(null),R=b.useRef(0),B=b.useRef(null),z=b.useRef(null),O=b.useRef(!1),$=b.useRef(null),V=b.useRef(!1),Z=b.useRef([]),le=b.useRef(null),be=b.useRef(S.current),pe=b.useRef(r?1:0),ee=b.useRef(r);ee.current=r;const _e=b.useRef(y);_e.current=y;const ze=b.useRef(n);ze.current=n;const Y=b.useRef(x);Y.current=x;const ce=b.useRef(a);ce.current=a;const qe=b.useRef(c);qe.current=c;const we=b.useCallback(ae=>{w.current=ae,typeof p=="function"?p(ae):p&&(p.current=ae)},[p]),ye=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),L.current=null},[]),Le=b.useCallback(ae=>{const Ae=ze.current;return Y.current?(ae+Ae)/Ae:(Ae-ae)/Ae},[]),Be=b.useCallback(ae=>{const Ae=v.current;Ae&&(Ae.style.opacity=String(ym(Le(ae),0,1)))},[Le]),ne=b.useCallback(ae=>{S.current=ae;const Ae=w.current;Ae&&(Ae.style.transform=`translateX(${ae}px)`,Be(ae))},[Be]),Fe=b.useCallback(ae=>{L.current=ae,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const Ae=L.current;L.current=null,Ae!==null&&ne(Ae)}))},[ne]),ke=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null);const ae=L.current;L.current=null,ae!==null&&ne(ae)},[ne]),Ee=b.useCallback(ae=>{const Ae=_e.current;return ym(ae,Math.min(0,Ae),Math.max(0,Ae))},[]),Pe=b.useCallback(()=>{const ae=B.current;if(!ae)return null;B.current=null;const Ae=(performance.now()-ae.startTime)/1e3,Ye={value:ae.solver.value(Ae),velocity:ae.solver.velocity(Ae)};return ae.animations.forEach(et=>et.cancel()),Ye},[]),Ne=b.useCallback(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),oe=b.useCallback(()=>{le.current?.(),le.current=null},[]),We=b.useCallback(()=>{ke(),Ne();const ae=Pe();ae&&ne(Ee(ae.value));const Ae=w.current,Ye=v.current;Ae?.getAnimations().forEach(et=>et.cancel()),Ae&&(Ae.style.transition="none",Ae.style.opacity="1"),Ye?.getAnimations().forEach(et=>et.cancel()),Ye&&(Ye.style.transition="none")},[ne,Ne,Ee,ke,Pe]),nt=b.useCallback((ae,Ae)=>{ke(),Ne();const Ye=w.current,et=v.current,St=ae?0:_e.current;et&&(et.style.pointerEvents=ae?"auto":"none");const Gt=Pe(),Qt=Gt?Ee(Gt.value):S.current,wt=Ae?.velocity??Gt?.velocity??0;if(gP())return S.current=St,Ye&&(Ye.style.transition=`opacity ${bm}ms ease`,Ye.style.opacity=ae?"1":"0",Ye.style.transform=`translateX(${St}px)`),et&&(et.style.transition=`opacity ${bm}ms ease`,et.style.opacity=ae?"1":"0"),bm;Ye&&(Ye.style.transition="none",Ye.style.opacity="1"),et&&(et.style.transition="none");const zt=Math.abs(Ae?.velocity??0)>TP,{frames:Vt,durationMs:Kt,solver:Ot}=yP({dampingRatio:zt?tb.dampingRatio:1,response:tb.response},Qt,wt,St,Ee);if(!Ye||Math.abs(Qt-St)<.5&&Math.abs(wt)<5)return ne(St),0;const It=Ye.animate(Vt.map(Ve=>({transform:`translateX(${Ve}px)`})),{duration:Kt,easing:"linear",fill:"forwards"}),xe=[It];return et&&xe.push(et.animate(Vt.map(Ve=>({opacity:String(ym(Le(Ve),0,1))})),{duration:Kt,easing:"linear",fill:"forwards"})),B.current={solver:Ot,startTime:performance.now(),target:St,animations:xe},Bd("spring start",{startX:Qt,startVelocity:wt,targetX:St,frames:Vt.length,durationMs:Kt}),It.onfinish=()=>{const Ve=B.current;!Ve||!Ve.animations.includes(It)||(B.current=null,ne(St),Ve.animations.forEach(ht=>ht.cancel()),Bd("spring finish",{targetX:St}))},Kt},[ne,Ne,Ee,ke,Le,Pe]),gt=b.useCallback(ae=>{ke();const Ae=ae,Ye=0,et=_e.current,St=S.current+mP(Ae),Gt=Math.abs(St-Ye)<=Math.abs(St-et);Bd("decideSnap",{velocity:Ae,currentX:S.current,projected:St,shouldOpen:Gt});const Qt=nt(Gt,{velocity:Ae});return Gt&&!ee.current?z.current=window.setTimeout(()=>{z.current=null,qe.current?.()},Qt+ib):!Gt&&ee.current&&(z.current=window.setTimeout(()=>{z.current=null,ce.current()},Qt+ib)),Gt},[nt,ke]),ue=b.useCallback(ae=>{const Ae=_e.current,Ye=Math.min(0,Ae),et=Math.max(0,Ae),St=ze.current;return ae<Ye?Ye-rb(Ye-ae,St):ae>et?et+rb(ae-et,St):ae},[]),Ze=b.useCallback(ae=>{const Ae=Z.current,Ye=performance.now();Ae.push({t:Ye,x:ae});const et=Ye-120;for(;Ae.length>0&&Ae[0].t<et;)Ae.shift()},[]),at=b.useCallback(()=>{const ae=Z.current;if(ae.length<2)return 0;const Ae=ae[ae.length-1];if(performance.now()-Ae.t>60)return 0;const Ye=ae[0],et=(Ae.t-Ye.t)/1e3;return et<.016?0:(Ae.x-Ye.x)/et},[]);b.useEffect(()=>{Ne();const ae=B.current,Ae=r?0:_e.current;ae&&ae.target===Ae||nt(r)},[r,nt,Ne]),b.useEffect(()=>{We(),Fe(ee.current?0:y)},[y,We,Fe]),b.useEffect(()=>()=>{ye(),Ne(),Pe(),oe()},[Ne,ye,oe,Pe]);const Ie=eb(({active:ae,cancel:Ae,first:Ye,last:et,movement:[St],event:Gt})=>{if(Bd("bindPanel",{active:ae,first:Ye,last:et,mx:St}),!ab(Gt)){Ae();return}if(Ye){if(oe(),O.current=!1,$.current=null,Z.current=[],ob(Gt)){Ae();return}const Qt=w.current,wt=Qt?pA(Gt.target,Qt):null;if(!wt||mA()){Ae();return}const zt=gA(wt,St,Y.current?-1:1);if(Bd("arbitrate",{owner:zt.kind,mx:St}),zt.kind==="swiper"){le.current=xA(zt.instance),Ae();return}if(zt.kind==="scroller"){const Vt=bA(zt.element);if(Vt)$.current=Vt;else{Ae();return}}$.current||(O.current=!0,We(),R.current=S.current)}if(!ae){$.current=null,O.current&&(O.current=!1,gt(at()));return}if($.current){yA($.current,St);return}if(O.current){const Qt=ue(R.current+St);Ze(Qt),Fe(Qt)}},{axis:"x",axisThreshold:sb,filterTaps:!0,pointer:{touch:!0}}),Ge=eb(({active:ae,cancel:Ae,first:Ye,movement:[et],event:St})=>{if(!ab(St)){Ae();return}if(ee.current){Ae();return}if(Ye&&(V.current=!0,Z.current=[],We(),R.current=S.current),!ae){V.current&&(V.current=!1,gt(at())&&wP());return}if(V.current){const Gt=ue(R.current+et);Ze(Gt),Fe(Gt)}},{axis:"x",axisThreshold:sb,filterTaps:!0,pointer:{touch:!0}}),Ce=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),ee.current||qe.current?.()},[]);if(d)return s.jsx("aside",{ref:we,"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 H=Ie();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...Ge(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:AP,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:Ce,"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",{...H,onClickCapture:ae=>{ob(ae)||H.onClickCapture?.(ae)},ref:we,"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(${be.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})]})}),CP={activeKey:"root",items:[]},_P=()=>()=>{},kP=()=>CP;function LP(e){const t=Po(),r=b.useSyncExternalStore(t?.subscribe??_P,t?.snapshot??kP),n=R8(),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 IP({groups:e,currentKey:t,onClose:r}){const{t:n}=Ur(),a=b.useId(),c=b.useRef(null),l=b.useRef(null),d=b.useRef(r);d.current=r;const p=b.useRef(!0),[m,x]=b.useState(""),y=e.reduce((S,L)=>S+L.reviewCount,0);b.useEffect(()=>{const S=document.activeElement;l.current?.focus({preventScroll:!0});const L=E=>{if(E.key==="Escape"&&(E.preventDefault(),E.stopImmediatePropagation(),d.current()),E.key!=="Tab")return;const R=Array.from(c.current?.querySelectorAll("button:not(:disabled)")??[]),B=R[0],z=R[R.length-1],O=!c.current?.contains(document.activeElement);E.shiftKey&&(document.activeElement===B||O)?(E.preventDefault(),z?.focus()):!E.shiftKey&&(document.activeElement===z||O)&&(E.preventDefault(),B?.focus())};return document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("keydown",L,!0),p.current&&S?.isConnected&&!S.closest("[inert]")&&S.focus({preventScroll:!0})}},[]);const w=(S,L)=>{const E=Po(),R=E?.snapshot().items.find(z=>z.key===S.key);if(!R?.reviewCount||L&&!R.attentionSessions?.some(z=>z.id===L)){x(n("serviceAttention.changed"));return}p.current=!1;let B=!1;L&&S.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:L})),B=!0):L&&R.service?.targetPeerId?B=E?.focusSession(R.service.targetPeerId,L)??!1:R.service&&(B=E?.activate(R.service,!0)??!1),B?r():(p.current=!0,x(n("serviceAttention.unavailable")))},v=S=>S.phase==="offline"?n("serviceAttention.offline"):S.phase==="login"?n("serviceAttention.login"):S.phase==="connecting"||S.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:S=>S.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(cc,{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(In,{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(S=>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:S.service?.label,children:S.service?.label||n("serviceAttention.currentService")}),S.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:S.reviewCount})]}),v(S)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(S)}),S.attentionSessions?.length?S.attentionSessions.map(L=>s.jsxs("button",{type:"button",onClick:()=>w(S,L.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:L.label,children:L.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:L.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(Ks,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},L.id)):s.jsx("button",{type:"button",onClick:()=>w(S),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")})]},S.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 EP(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 NP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function RP(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,p=e[d];if(p&&r(p))return p.sessionId}return null}function MP(e,t,r="next"){return RP(e,t,NP,r)}const Ua=42,Mf=20,jP=10;function C1(e,t,r){return Math.min(r,Math.max(t,e))}function tp(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+Mf,d=Math.max(l,e.width-r-Mf-Ua),p=Math.max(t+12,52),m=Math.max(p,e.height-n-c-Ua);return{minX:l,maxX:d,minY:p,maxY:m}}function lb(e,t){const r=tp(e),n=C1(t.yRatio,0,1);return{x:t.side==="left"?r.minX:r.maxX,y:r.minY+(r.maxY-r.minY)*n}}function Hc(e,t){const r=tp(e);return{x:C1(t.x,r.minX,r.maxX),y:C1(t.y,r.minY,r.maxY)}}function cb(e,t){const r=tp(e),n=Hc(e,t),a=(r.minX+r.maxX+Ua)/2,c=n.x+Ua/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 ub(e,t,r){const n=Hc(e,t),a=Ua+jP,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=>Hc(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=tp(e);return[{...n,x:d.minX},{...n,x:d.maxX}].map(m=>Hc(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.x-n.x)-Math.abs(x.x-n.x))[0]??n}const vm="var(--warning)",DP="var(--success)",db="var(--tmux)",hb="termdock:mobile-attention-position:v1",fb="termdock:running-session-position:v1",BP={side:"right",yRatio:.68},QP={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 PP(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ch(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 OP(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(Ch("--safe-top-inset"),(d?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(Ch("--safe-right-inset"),(d?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(Ch("--safe-bottom-inset"),(d?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(Ch("--safe-left-inset"),(d?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?Mf:72}}function B6(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=MP(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 mb(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function Q6(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 FP({indicator:e,tone:t,size:r}){const n=Q6(t);switch(e){case"spinner":return s.jsx(_n,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(of,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx($o,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(WA,{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 Wc({agent:e,size:t=12}){const r=t-4,n=EP(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(R0,{size:r,className:"text-white"})})}function $P({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Wc,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(qc,{size:r,className:"shrink-0"}):s.jsx($o,{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(FP,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(_n,{size:r,className:"shrink-0 animate-spin",style:{color:DP}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(of,{size:r,className:"shrink-0 animate-bounce-y",style:{color:vm}})}):t?.agentStatus==="done"&&t.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:vm}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:vm}})}):t?.inCopyMode?e==="tmux"?s.jsx(qc,{size:r,className:"shrink-0 animate-pulse",style:{color:db}}):s.jsx($o,{size:r,className:"shrink-0 animate-pulse",style:{color:db}}):n}function UP({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=Ur();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:Q6(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 P6({count:e,tone:t,title:r}){const{t:n}=Ur();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:B6,children:[s.jsx(cc,{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 zP({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 HP=380,gb=10,_h=10,wm=52,WP=104;function GP(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=Mf,p=e.x+Ua/2>=n+(a-n)/2,m=p?e.x-_h-n-d:a-d-e.x-Ua-_h,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*WP))),y=p?e.x-_h-x:e.x+Ua+_h,w=Math.min(Math.max(y,n+d),Math.max(n+d,a-d-x)),v=e.y+Ua/2-wm/2,S=Math.min(Math.max(v,c+d),Math.max(c+d,l-d-wm));return{left:w,top:S,width:x,height:wm,itemWidth:x/Math.max(1,r),side:p?"left":"right"}}function xb(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 VP(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 qP({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:d}){const{t:p}=Ur(),m=Wt(Ie=>Ie.leftOpen),x=Wt(Ie=>Ie.rightOpen),{isOpen:y}=rv({enabled:!c}),w=c||!m&&!x&&!y,v=LP(e),[S,L]=k.useState(!1);k.useEffect(()=>{(!v.active||!w)&&L(!1)},[v.active,w]);const E=a&&v.total>0&&w,R=t.length>1||t.length===1&&t[0]?.id!==r,B=n&&t.length>0&&R&&w,z=Math.max(0,d?.top??0),O=Math.max(0,d?.right??0),$=Math.max(0,d?.bottom??0),V=Math.max(0,d?.left??0),Z=k.useCallback(()=>OP(c,l,{top:z,right:O,bottom:$,left:V}),[l,c,$,V,O,z]),le=k.useRef({attention:pb(hb,BP),running:pb(fb,QP)}),be=k.useCallback(()=>{const Ie=Z(),Ge=lb(Ie,le.current.attention),Ce=lb(Ie,le.current.running);return{attention:Ge,running:E&&B?ub(Ie,Ce,Ge):Ce}},[E,Z,B]),[pe,ee]=k.useState(()=>be()),_e=k.useRef(pe);_e.current=pe;const[ze,Y]=k.useState(null),ce=k.useRef(null),[qe,we]=k.useState("idle"),[ye,Le]=k.useState(null),Be=k.useRef(null),ne=k.useRef({attention:!1,running:!1});k.useEffect(()=>()=>{const Ie=Be.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie)},[]),k.useEffect(()=>{if(B)return;const Ie=Be.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie),Be.current=null,we("idle"),Le(null)},[B]),k.useLayoutEffect(()=>{const Ie=()=>{const Ce=be();_e.current=Ce,ee(Ce)};Ie(),window.addEventListener("resize",Ie),window.addEventListener("orientationchange",Ie),window.visualViewport?.addEventListener("resize",Ie);const Ge=typeof ResizeObserver>"u"?null:new ResizeObserver(Ie);return l&&Ge?.observe(l),()=>{window.removeEventListener("resize",Ie),window.removeEventListener("orientationchange",Ie),window.visualViewport?.removeEventListener("resize",Ie),Ge?.disconnect()}},[l,be]);const Fe=k.useCallback(Ie=>Ie==="attention"?B:E,[E,B]),ke=k.useCallback((Ie,Ge)=>{if(!Fe(Ie))return Ge;const Ce=Ie==="attention"?"running":"attention";return ub(Z(),Ge,_e.current[Ce])},[Z,Fe]),Ee=k.useCallback((Ie,Ge,Ce,H)=>{const ae=Z(),Ae=Ge.moved?Hc(ae,{x:Ge.startX+(Ce-Ge.originX),y:Ge.startY+(H-Ge.originY)}):_e.current[Ie],Ye=cb(ae,Ae),et=ke(Ie,Ye.position),St=cb(ae,et);le.current[Ie]=St.preference,PP(Ie==="attention"?hb:fb,St.preference);const Gt={..._e.current,[Ie]:St.position};_e.current=Gt,ee(Gt)},[ke,Z]),Pe=k.useCallback(Ie=>{ne.current[Ie]=!0,window.setTimeout(()=>{ne.current[Ie]=!1},0)},[]),Ne=k.useCallback(Ie=>{const Ge=ce.current;!Ge||Ge.kind!=="attention"||Ge.pointerId!==Ie.pointerId||(ce.current=null,Y(null),Ee("attention",Ge,Ie.clientX,Ie.clientY),Ge.moved&&Pe("attention"))},[Ee,Pe]),oe={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId),ce.current={kind:"attention",pointerId:Ie.pointerId,originX:Ie.clientX,originY:Ie.clientY,startX:pe.attention.x,startY:pe.attention.y,moved:!1}},onPointerMove:Ie=>{const Ge=ce.current;if(!Ge||Ge.kind!=="attention"||Ge.pointerId!==Ie.pointerId)return;const Ce=Ie.clientX-Ge.originX,H=Ie.clientY-Ge.originY;if(!Ge.moved&&Math.hypot(Ce,H)<5)return;Ge.moved=!0,Y("attention");const ae=Z(),Ae=ke("attention",Hc(ae,{x:Ge.startX+Ce,y:Ge.startY+H})),Ye={..._e.current,attention:Ae};_e.current=Ye,ee(Ye)},onPointerUp:Ne,onPointerCancel:Ne},We=l?GP(pe.running,Z(),t.length):null,nt=Ie=>{Ie.longPressTimer!==null&&(window.clearTimeout(Ie.longPressTimer),Ie.longPressTimer=null)},gt={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId);const Ge=Ie.pointerId,Ce={pointerId:Ge,originX:Ie.clientX,originY:Ie.clientY,startX:pe.running.x,startY:pe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};Ce.longPressTimer=window.setTimeout(()=>{const H=Be.current;!H||H.pointerId!==Ge||H.mode!=="pressing"||(H.longPressTimer=null,H.mode="dragging",ne.current.running=!0,we("dragging"))},HP),Be.current=Ce,we("pressing"),Le(null)},onPointerMove:Ie=>{const Ge=Be.current;if(!Ge||Ge.pointerId!==Ie.pointerId)return;const Ce=Ie.clientX-Ge.originX,H=Ie.clientY-Ge.originY;if(Ge.mode==="pressing")if(Math.abs(Ce)>=gb&&Math.abs(Ce)>=Math.abs(H))nt(Ge),Ge.mode="selecting",ne.current.running=!0,we("selecting");else if(Math.hypot(Ce,H)>=gb){nt(Ge),Ge.mode="cancelled",ne.current.running=!0,we("idle");return}else return;if(Ge.mode==="selecting"){const et=We?xb(We,Ie.clientX,Ie.clientY,t.length):null;Ge.selectedIndex=et,Le(et);return}if(Ge.mode!=="dragging"||!Ge.moved&&Math.hypot(Ce,H)<5)return;Ge.moved=!0;const ae=Z(),Ae=ke("running",Hc(ae,{x:Ge.startX+Ce,y:Ge.startY+H})),Ye={..._e.current,running:Ae};_e.current=Ye,ee(Ye)},onPointerUp:Ie=>{const Ge=Be.current;if(!Ge||Ge.pointerId!==Ie.pointerId)return;nt(Ge);const Ce=Ge.mode;if(Ce==="selecting"){const H=We?xb(We,Ie.clientX,Ie.clientY,t.length):Ge.selectedIndex,ae=H===null?null:t[H]?.id;ae&&mb(ae)}else Ce==="dragging"&&Ee("running",Ge,Ie.clientX,Ie.clientY);Be.current=null,we("idle"),Le(null),Ce!=="pressing"&&Pe("running")},onPointerCancel:Ie=>{const Ge=Be.current;!Ge||Ge.pointerId!==Ie.pointerId||(nt(Ge),Be.current=null,we("idle"),Le(null),Pe("running"))}},ue=(Ie,Ge)=>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)] ${Ge==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Ie>9?"9+":Ie}),Ze=()=>{const Ie=v.hasOtherAttention?p("serviceAttention.title"):p("agent.jumpToNext"),Ge=pe.attention,Ce=ze==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...oe,onClick:H=>{H.stopPropagation(),!ne.current.attention&&(v.hasOtherAttention?L(!0):B6())},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 ${Ce?"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:S?"none":void 0,left:Ge.x,top:Ge.y,width:Ua,height:Ua,touchAction:"none"},"aria-label":`${Ie}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:Ie,children:[s.jsx(cc,{size:17,className:"shrink-0"}),ue(v.total,"attention")]},"attention")},at=()=>{const Ie=t.length,Ge=pe.running,Ce=qe==="selecting",H=qe==="dragging";return s.jsxs(k.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":qe,...gt,onClick:ae=>{if(ae.stopPropagation(),ne.current.running)return;const Ae=VP(t,r);Ae&&mb(Ae)},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 ${H?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":Ce?"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:Ge.x,top:Ge.y,width:Ua,height:Ua,touchAction:"none"},"aria-label":`${p("agent.jumpToNextRunning")}: ${Ie}`,title:p("agent.runningSessionGestureHint"),children:[s.jsx(_n,{size:18,className:"shrink-0 animate-spin"}),ue(Ie,"running")]}),Ce&&We&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":We.side,"aria-label":p("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:We.left,top:We.top,width:We.width,height:We.height},children:t.map((ae,Ae)=>{const Ye=Ae===ye,et=ae.id===r,St=`${ae.label}${ae.detail?` · ${ae.detail}`:""}${et?` · ${p("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":Ye,"data-running-session-option":ae.id,"data-selected":Ye?"true":"false",title:St,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 ${Ye?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":et?"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 ${Ye?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:Ae+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:ae.label})]},ae.id)})})]},"running")};return!E&&!B&&!S||l===null||typeof document>"u"?null:s.jsxs(M8,{children:[E&&Ze(),B&&!S&&at(),S&&v.active&&w&&s.jsx(IP,{groups:v.groups,currentKey:v.currentKey,onClose:()=>L(!1)})]})}function YP(){const{t:e}=Ur();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 ZP=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"]),bb=120,yb=120,KP=new Set,XP=[],JP={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 kg(e,t){if(t==="directory")return null;if(B8(e))return s.jsx(DA,{size:14});if(Q8(e))return s.jsx(Wy,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return ZP.has(r)?s.jsx(lT,{size:14}):s.jsx(Qy,{size:14})}function O6({path:e}){const r=Wt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=JP[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 Zu(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 Lg(e){return Zu(e)}const eO=b.memo(function({path:t}){const{t:r}=Ur(),[n,a]=b.useState("idle"),[c,l]=b.useState(null),d=b.useCallback(async p=>{if(p.stopPropagation(),n!=="pending"){a("pending"),l(null);try{await Cy(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:p=>{d(p)},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 ${Zu(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(_n,{size:12,className:"animate-spin"}):s.jsx(g0,{size:12})})});function F6(){const{t:e}=Ur(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await Cy(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 _1(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 $6(e){return e.button===2||e.ctrlKey}const tO=176,rO=160,Qd=8;function vb(e,t,r,n){const a=window.visualViewport,c=a?.offsetLeft??0,l=a?.offsetTop??0,d=c+(a?.width??window.innerWidth),p=l+(a?.height??window.innerHeight),m=c+Qd,x=l+Qd,y=Math.max(m,d-r-Qd),w=Math.max(x,p-n-Qd),v=t+n<=p-Qd?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 U6(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(vb(c,l,tO,rO))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=vb(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 z6(e,t){return t&&typeof document<"u"?Xs.createPortal(e,document.body):e}function nO(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function Ig(e,t,r){if(!t||nO(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>Ig(a,t,r)):!1}function k1(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 L1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const sO=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:p,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:S,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:z,onDirectoryDropFiles:O,onFileDeleteRequest:$,deletingFilePath:V,revealedDirectoryPath:Z,gitIgnoreRoot:le}){const{t:be}=Ur(),pe=Wt(xt=>xt.expandedPaths.has(t.path)),ee=Wt(xt=>xt.directoryCache.get(t.path)),_e=Wt(xt=>xt.showHiddenFiles),ze=Wt(xt=>xt.toggleExpanded),Y=Wt(xt=>xt.setDirectoryCache),ce=Wt(xt=>xt.fileSortModes[t.path]??"name"),qe=Wt(xt=>xt.setDirectorySortMode),[we,ye]=b.useState(!1),[Le,Be]=b.useState(!1),{position:ne,menuRef:Fe,openAt:ke,clearPosition:Ee}=U6(Le),[Pe,Ne]=b.useState(!1),oe=b.useRef(0),We=b.useRef(null),nt=`file-tree-reference:${b.useId()}:${t.path}`;Gc(Fe,Le&&!!l,()=>Be(!1));const gt=b.useRef(null),ue=t.path===B||t.path===Z,Ze=t.type==="directory"&&(pe||!!z),at=t.type==="directory",Ie=R.has(t.path),Ge=!at&&!!S,Ce=!!(E&&L),H=`path:${t.path}`,ae=m===H||!!l?.paths.has(t.path),Ae=x===H,Ye=d?.(t.path)??t.path,et=O1(p,!!l),{state:St,run:Gt}=F6(),Qt=V===t.path,wt=at&&!a&&!!(y||w||v||Ce),zt=b.useMemo(()=>{if(!ee)return;if(!z)return ee;const xt=Wt.getState().directoryCache;return ee.filter(Rt=>(!a||Rt.type==="directory")&&Ig(Rt,z,xt))},[ee,a,z]),Vt=b.useCallback(async()=>{if(!Wt.getState().directoryCache.has(t.path)&&!we){const Rt=l?nt:`file-tree:${t.path}`;We.current?.abort(),Fm(Rt);const Ct=new AbortController;We.current=Ct,ye(!0);try{const fr=await D1(t.path,Ct.signal,_e,"expand_directory",Rt,ce,le);if(Ct.signal.aborted)return;const Yt=k1(fr.entries);Y(t.path,Yt)}catch(fr){_1(fr)}finally{We.current===Ct&&(We.current=null),ye(!1)}}},[t.path,we,Y,_e,ce,le,!!l,nt]),Kt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const xt=!Wt.getState().expandedPaths.has(t.path);ze(t.path),xt&&await Vt()},[a,t.path,t.type,Vt,y,ze,n]);b.useEffect(()=>{t.type==="directory"&&pe&&!ee&&!we&&Vt()},[ee,pe,Vt,we,t.type]);const Ot=b.useCallback(xt=>{xt.stopPropagation(),c?.(t.path,H)},[c,t.path,H]),It=b.useCallback(xt=>{xt.stopPropagation(),y?.(t.path),Be(!1)},[t.path,y]),xe=b.useCallback(xt=>{xt.stopPropagation(),w?.(t.path),Be(!1)},[t.path,w]),Ve=b.useCallback(xt=>{xt.stopPropagation(),v?.(t.path),Be(!1)},[t.path,v]),ht=b.useCallback(xt=>{xt.stopPropagation(),qe(t.path,ce==="modified"?"name":"modified"),Be(!1)},[t.path,qe,ce]),q=b.useCallback(xt=>{xt.stopPropagation(),S?.(t.path),Be(!1)},[t.path,S]),ut=b.useCallback(xt=>{xt.stopPropagation(),Be(!1),Gt(t.path)},[t.path,Gt]),qt=b.useCallback(xt=>{xt.stopPropagation(),Be(!1),$(t)},[t,$]),tt=b.useCallback(xt=>{xt.stopPropagation(),L?.(t.path),Be(!1)},[t.path,L]),De=b.useCallback(xt=>{!at||!O||!xt.dataTransfer.types.includes("Files")||(xt.preventDefault(),xt.stopPropagation(),oe.current+=1,Ne(!0))},[at,O]),nr=b.useCallback(xt=>{!at||!O||!xt.dataTransfer.types.includes("Files")||(xt.preventDefault(),xt.stopPropagation(),xt.dataTransfer.dropEffect="copy",Ne(!0))},[at,O]),Ke=b.useCallback(xt=>{!at||!O||(xt.preventDefault(),xt.stopPropagation(),oe.current-=1,oe.current<=0&&(oe.current=0,Ne(!1)))},[at,O]),_t=b.useCallback(xt=>{if(!at||!O)return;xt.preventDefault(),xt.stopPropagation(),oe.current=0,Ne(!1);const Rt=Array.from(xt.dataTransfer.files);Rt.length>0&&O(t.path,Rt)},[at,t.path,O]),$t=b.useCallback(xt=>{xt.stopPropagation(),l?ke(xt.clientX,xt.clientY):Ee(),Be(Rt=>!Rt)},[Ee,ke,!!l]),yt=b.useCallback(xt=>{!wt||!$6(xt)||(xt.preventDefault(),xt.stopPropagation(),ke(xt.clientX,xt.clientY),Be(!0))},[wt,ke]);return b.useEffect(()=>{if(!Le)return;const xt=Ct=>{const fr=Ct.target;fr instanceof Node&&(gt.current?.contains(fr)||Fe.current?.contains(fr))||Be(!1)},Rt=Ct=>{Ct.key==="Escape"&&Be(!1)};return document.addEventListener("pointerdown",xt),document.addEventListener("keydown",Rt),()=>{document.removeEventListener("pointerdown",xt),document.removeEventListener("keydown",Rt)}},[Le,Fe]),b.useEffect(()=>()=>{We.current?.abort()},[]),s.jsxs("div",{style:!Ze&&!Le?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:gt,className:"relative",children:[et.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":ce,role:"button",tabIndex:0,onClick:()=>{jf()||Kt()},onContextMenu:yt,onKeyDown:xt=>{xt.target!==xt.currentTarget||xt.key!=="Enter"&&xt.key!==" "||(xt.preventDefault(),Kt())},onDragEnter:De,onDragOver:nr,onDragLeave:Ke,onDrop:_t,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Pe?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":ue?"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`}}),Pe&&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:be("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Ze?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(Ks,{size:14,className:"shrink-0 text-muted-foreground/80"}),Ze?s.jsx(Du,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(Vc,{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:ue?"text-primary":"text-muted-foreground/80",children:kg(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${ue?"font-medium":""}`,children:[t.name,ce==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:be("fileTree.sortedByModified"),"aria-label":be("fileTree.sortedByModified"),children:s.jsx(m0,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:be("fileTree.symbolicLink"),children:s.jsx(Uu,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${ue?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:xt=>xt.stopPropagation(),children:[we&&s.jsx(_n,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(O6,{path:t.path}),wt&&s.jsx("button",{type:"button",onClick:$t,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 ${Zu(Le)} ${Le?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":be("fileTree.moreDirActions"),"aria-expanded":Le,title:be("fileTree.moreDirActions"),children:s.jsx(To,{size:13})}),!at&&!l&&s.jsx("button",{type:"button",onClick:$t,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 ${Zu(Le||St.status==="pending"||Qt||Ie)} ${Le?"bg-surface-elevated text-foreground":Ie?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":be("fileTree.moreFileActions"),"aria-expanded":Le,title:St.status==="error"?St.message??be("rightSidebar.downloadFailed"):be("fileTree.moreFileActions"),children:St.status==="pending"||Qt?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(To,{size:13})}),c&&s.jsx("button",{type:"button",onClick:Ot,...et(Ye,H),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":Lg(ae||Ae)} ${ae||Ae?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:be(Ae?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?ae:void 0,disabled:!!l?.disabled&&!ae,title:l?`${l.label}: ${t.name}`:be(Ae?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:Ae||ae?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})}),wt&&Le&&z6(s.jsxs("div",{ref:Fe,className:`${ne?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:ne?{left:ne.left,top:ne.top}:void 0,children:[Ce&&s.jsxs("button",{type:"button",onClick:tt,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:be("fileTree.openInFileBrowserTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:It,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:be("fileTree.openDirRootTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("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:be("fileTree.searchFromDirTitle"),children:[s.jsx(F1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Ve,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:be(Ie?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ie?s.jsx(b0,{size:13,className:"shrink-0"}):s.jsx(x0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(Ie?"fileTree.unpinDir":"fileTree.pinDir")})]}),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]",children:[ce==="modified"?s.jsx(LA,{size:13,className:"shrink-0"}):s.jsx(m0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(ce==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!ne),!at&&!l&&Le&&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:[Ce&&s.jsxs("button",{type:"button",onClick:tt,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:be("fileTree.openInFileBrowserTitle"),children:[s.jsx(Qy,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:ut,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:be("rightSidebar.downloadFile"),children:[s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("rightSidebar.downloadFile")})]}),Ge&&s.jsxs("button",{type:"button",onClick:q,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:be(Ie?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ie?s.jsx(b0,{size:13,className:"shrink-0"}):s.jsx(x0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(Ie?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:qt,disabled:Qt,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:be("fileTree.deleteFile"),children:[Qt?s.jsx(_n,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Rs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.deleteFile")})]})]})]})]})]}),Ze&&zt&&zt.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:zt.map(xt=>s.jsx(e,{node:xt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:p,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:S,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:z,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:O,onFileDeleteRequest:$,deletingFilePath:V,gitIgnoreRoot:le,revealedDirectoryPath:Z},xt.path))})]})}),iO=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,referenceSelection:c,getReferenceText:l,onReferenceCopied:d,insertedReferenceKey:p,copiedReferenceKey:m,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:w,onFilePinToggle:v,pinnedPaths:S,selectedFilePath:L,onFileDeleteRequest:E,deletingFilePath:R}){const{t:B}=Ur(),z=t.path===L,O=t.type==="directory",$=S.has(t.path),V=!O&&!!v,Z=`path:${t.path}`,le=p===Z||!!c?.paths.has(t.path),be=m===Z,pe=l?.(t.path)??t.path,ee=O1(d,!!c),{state:_e,run:ze}=F6(),[Y,ce]=b.useState(!1),{position:qe,menuRef:we,openAt:ye,clearPosition:Le}=U6(Y);Gc(we,Y&&!!c,()=>ce(!1));const Be=b.useRef(null),ne=R===t.path,Fe=O&&!!(x||y||w),ke=b.useCallback(()=>{jf()||(t.type==="directory"?x?.(t.path):n(t.path))},[t.path,t.type,x,n]),Ee=b.useCallback(ue=>{ue.stopPropagation(),a?.(t.path,Z)},[a,t.path,Z]),Pe=b.useCallback(ue=>{ue.stopPropagation(),w?.(t.path),ce(!1)},[t.path,w]),Ne=b.useCallback(ue=>{ue.stopPropagation(),v?.(t.path),ce(!1)},[t.path,v]),oe=b.useCallback(ue=>{ue.stopPropagation(),ce(!1),ze(t.path)},[t.path,ze]),We=b.useCallback(ue=>{ue.stopPropagation(),ce(!1),E(t)},[t,E]),nt=b.useCallback(ue=>{ue.stopPropagation(),c?ye(ue.clientX,ue.clientY):Le(),ce(Ze=>!Ze)},[Le,ye,!!c]),gt=b.useCallback(ue=>{!Fe||!$6(ue)||(ue.preventDefault(),ue.stopPropagation(),ye(ue.clientX,ue.clientY),ce(!0))},[Fe,ye]);return b.useEffect(()=>{if(!Y)return;const ue=at=>{const Ie=at.target;Ie instanceof Node&&(Be.current?.contains(Ie)||we.current?.contains(Ie))||ce(!1)},Ze=at=>{at.key==="Escape"&&ce(!1)};return document.addEventListener("pointerdown",ue),document.addEventListener("keydown",Ze),()=>{document.removeEventListener("pointerdown",ue),document.removeEventListener("keydown",Ze)}},[Y,we]),s.jsxs("div",{ref:Be,className:"relative border-b border-border/10 last:border-b-0",children:[ee.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:ke,onContextMenu:gt,onKeyDown:ue=>{ue.target!==ue.currentTarget||ue.key!=="Enter"&&ue.key!==" "||(ue.preventDefault(),ke())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${z?"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(Vc,{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:z?"text-primary":"text-muted-foreground/80",children:kg(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 ${z?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:B("fileTree.symbolicLink"),children:s.jsx(Uu,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:L1(r,t.path)})]}),s.jsx(O6,{path:t.path}),t.type==="directory"&&(w||y)&&s.jsx("button",{type:"button",onClick:nt,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 ${Zu(Y)} ${Y?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreDirActions"),"aria-expanded":Y,title:B("fileTree.moreDirActions"),children:s.jsx(To,{size:13})}),!O&&!c&&s.jsx("button",{type:"button",onClick:nt,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 ${Zu(Y||_e.status==="pending"||ne||$)} ${Y?"bg-surface-elevated text-foreground":$?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreFileActions"),"aria-expanded":Y,title:_e.status==="error"?_e.message??B("rightSidebar.downloadFailed"):B("fileTree.moreFileActions"),children:_e.status==="pending"||ne?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(To,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Ee,...ee(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":Lg(le||be)} ${le||be?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:B(be?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?le:void 0,disabled:!!c?.disabled&&!le,title:c?`${c.label}: ${t.name}`:B(be?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:be||le?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})})]}),Fe&&Y&&z6(s.jsxs("div",{ref:we,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:ue=>{ue.stopPropagation(),x(t.path),ce(!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:B("fileTree.openDirRootTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:ue=>{ue.stopPropagation(),y(t.path),ce(!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(F1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.searchFromDir")})]}),w&&s.jsxs("button",{type:"button",onClick:Pe,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] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B($?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[$?s.jsx(b0,{size:13,className:"shrink-0"}):s.jsx(x0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B($?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!qe),!O&&!c&&Y&&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:oe,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:B("rightSidebar.downloadFile"),children:[s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("rightSidebar.downloadFile")})]}),V&&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] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B($?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[$?s.jsx(b0,{size:13,className:"shrink-0"}):s.jsx(x0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B($?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:We,disabled:ne,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:B("fileTree.deleteFile"),children:[ne?s.jsx(_n,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Rs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.deleteFile")})]})]})]})}),aO=60,wb=60,oO=20;function Ab({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=Ur();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(F1,{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(_n,{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 lO(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 cO=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:c,onPathReference:l,referenceSelection:d,getReferenceText:p,onReferenceCopied:m,insertedReferenceKey:x,copiedReferenceKey:y}){const{t:w}=Ur(),[v,S]=b.useState(!0),L=t.path===n,E=v?t.matches.slice(0,oO):[],R=t.matches.length-E.length,B=`path:${t.path}`,z=x===B||!!d?.paths.has(t.path),O=y===B,$=p?.(t.path)??t.path,V=O1(m,!!d);return s.jsxs("div",{className:"border-b border-border/10 last:border-b-0",children:[V.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{jf()||S(Z=>!Z)},onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),S(le=>!le))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[v?s.jsx(ul,{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:L?"text-primary":"text-muted-foreground/80",children:kg(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:L1(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(eO,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),l(t.path,B)},...V($,B),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":Lg(z||O)} ${z||O?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":d?`${d.label}: ${t.name}`:w(O?"rightSidebar.copied":z?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":d?z:void 0,disabled:!!d?.disabled&&!z,title:d?`${d.label}: ${t.name}`:w(O?"rightSidebar.copied":z?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:O||z?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[E.map((Z,le)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{jf()||c?.(t.path,Z.line)},onKeyDown:be=>{be.target!==be.currentTarget||be.key!=="Enter"&&be.key!==" "||(be.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:`${L1(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:lO(Z.text,a)})]},`${Z.line}-${le}`)),R>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:R})})]})]})});function uO({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:p,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:S=!1,pinnedPaths:L=KP,selectedFilePath:E,query:R="",searchRootPath:B,searchOptions:z={},searchMode:O="name",onContentMatchSelect:$,onDirectoryDropFiles:V,revealDirectory:Z}){const{t:le}=Ur(),be=b.useId(),pe=a?`file-tree-reference-root:${be}:${e}`:`file-tree-root:${e}`,ee=Wt(tt=>e?tt.directoryCache.get(e):void 0),_e=Wt(tt=>tt.setDirectoryCache),ze=Wt(tt=>tt.showHiddenFiles),Y=Wt(tt=>tt.fileSortModesHydrated),ce=Wt(tt=>tt.fileSortModes[e]??"name"),qe=Wt(tt=>tt.hydrateFileSortModes),we=Wt(tt=>tt.hydrateHideGitIgnoredRoots),ye=Wt(tt=>!!tt.hideGitIgnoredRoots[e]),Le=Wt(tt=>tt.hideGitIgnoredRootsHydrated),Be=Wt(tt=>JSON.stringify(tt.gitIgnoreExceptions[e]??[])),ne=Wt(tt=>tt.invalidateDirectoryCache),Fe=`${e}:${ye}:${Be}`,[ke,Ee]=b.useState("");b.useLayoutEffect(()=>{e&&ne(e,!0),Ee(Fe)},[e,ye,Be,ne,Fe]);const[Pe,Ne]=b.useState(!1),[oe,We]=b.useState(null),[nt,gt]=b.useState(!1),[ue,Ze]=b.useState(!1),[at,Ie]=b.useState(null),[Ge,Ce]=b.useState(Y&&Le),H=Y&&Le||Ge;b.useEffect(()=>{let tt=!1;return Promise.all([qe(),we()]).catch(()=>{}).finally(()=>{tt||Ce(!0)}),()=>{tt=!0}},[qe,we]);const[ae,Ae]=b.useState([]),[Ye,et]=b.useState(null),[St,Gt]=b.useState(bb),[Qt,wt]=b.useState([]),[zt,Vt]=b.useState(null),Kt=b.useRef(null),Ot=b.useRef(0),It=R.trim().toLowerCase(),xe=O==="content",Ve=B||e,ht=z.excludePatterns??XP,q=ht.join(`
137
+ `);b.useEffect(()=>{const tt=Z?.path;if(!tt||!tt.startsWith(`${e}/`)&&tt!==e)return;const De=tt.slice(e.length).replace(/^\/+/,""),nr=De?De.split("/"):[],Ke=nr.map((fr,Yt)=>`${e}/${nr.slice(0,Yt+1).join("/")}`),_t=Wt.getState(),$t=Ke.filter(fr=>!_t.expandedPaths.has(fr));$t.length>0&&Wt.setState(fr=>({expandedPaths:new Set([...fr.expandedPaths,...$t])}));let yt=!1,xt=0;const Rt=()=>{if(yt)return;const fr=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(Yt=>Yt.dataset.fileTreePath===tt);if(fr){fr.scrollIntoView({block:"center",behavior:"smooth"});return}xt+=1,xt<80&&window.setTimeout(Rt,50)},Ct=window.requestAnimationFrame(Rt);return()=>{yt=!0,window.cancelAnimationFrame(Ct)}},[Z?.nonce,Z?.path,e]);const ut=b.useCallback(async tt=>{if(!(zt||tt.type==="directory")&&window.confirm(le("fileTree.deleteFileConfirm",{name:tt.name}))){Vt(tt.path);try{await j8(tt.path),Wt.getState().applyFileWatchEvents([{type:"deleted",path:tt.path}]),Ae(De=>De.filter(nr=>nr.path!==tt.path)),wt(De=>De.filter(nr=>nr.path!==tt.path)),L.has(tt.path)&&w?.(tt.path)}catch(De){const nr=De instanceof Error?De.message:String(De);window.alert(le("fileTree.deleteFileFailed",{message:nr}))}finally{Vt(null)}}},[zt,w,L,le]);b.useEffect(()=>{if(!e||!H||ke!==Fe)return;if(It){Ne(!1);return}if(Wt.getState().directoryCache.has(e)){Ne(!1);return}let tt=!1;const De=new AbortController;return Ne(!0),We(null),D1(e,De.signal,ze,"load_file_tree_root",pe,ce,e).then(nr=>{if(tt)return;const Ke=k1(nr.entries);gt(!!nr.truncated),_e(e,Ke)}).catch(nr=>{tt||_1(nr)||We(nr instanceof Error?nr.message:"Failed to load directory")}).finally(()=>{tt||Ne(!1)}),()=>{tt=!0,De.abort(),Fm(pe)}},[It,ee,e,ce,_e,ze,H,ye,Be,pe,ke,Fe]),b.useEffect(()=>{if(!Ve||!It){Ze(!1),Ie(null),Ae([]),wt([]),et(null);return}let tt=!1;const De=new AbortController,nr=new Set;Ze(!0),Ie(null),Ae([]),wt([]),Gt(xe?aO:bb),et({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const Ke=`file-search:${a?be+":":""}${Ve}:${++Ot.current}`;return D8(Ve,R.trim(),_t=>{if(!tt){if(_t.engine&&et($t=>({truncated:$t?.truncated??!1,total:$t?.total??0,engine:_t.engine,limited:_t.limited??$t?.limited??!1,done:$t?.done??!1})),_t.entries?.length){const $t=_t.entries.filter(yt=>nr.has(yt.path)?!1:(nr.add(yt.path),!0));$t.length>0&&(Ae(yt=>[...yt,...k1($t)]),et(yt=>yt?{...yt,total:nr.size}:{truncated:!1,total:nr.size,engine:"rg",limited:!1,done:!1}))}if(_t.contentEntries?.length){const $t=_t.contentEntries.filter(yt=>nr.has(yt.path)?!1:(nr.add(yt.path),!0));$t.length>0&&(wt(yt=>[...yt,...$t]),et(yt=>yt?{...yt,total:nr.size}:{truncated:!1,total:nr.size,engine:"rg",limited:!1,done:!1}))}_t.done&&et($t=>({truncated:!!_t.truncated,total:typeof _t.total=="number"?_t.total:nr.size,engine:_t.engine??$t?.engine??"rg",limited:!!_t.limited,done:!0}))}},De.signal,ze,O,Ke,{excludePatterns:ht,caseSensitive:z.caseSensitive,wholeWord:z.wholeWord,regex:z.regex}).catch(_t=>{tt||_1(_t)||(Ie(_t instanceof Error?_t.message:"Failed to search files"),Ae([]),wt([]),et(null))}).finally(()=>{tt||Ze(!1)}),()=>{tt=!0,De.abort(),Fm(Ke)}},[Ve,q,xe,R,It,O,z.caseSensitive,z.regex,z.wholeWord,ze,!!a,be]),b.useEffect(()=>{if(!It)return;const tt=Kt.current;if(!tt)return;const De=xe?Qt.length:ae.length,nr=xe?wb:yb,Ke=new IntersectionObserver(_t=>{_t.some($t=>$t.isIntersecting)&&Gt($t=>Math.min($t+nr,De))},{rootMargin:"160px 0px"});return Ke.observe(tt),()=>Ke.disconnect()},[It,ae.length,Qt.length,xe]);const qt=b.useMemo(()=>{if(!ee)return;if(!It)return r?ee.filter(De=>De.type==="directory"):ee;const tt=Wt.getState().directoryCache;return ee.filter(De=>(!r||De.type==="directory")&&Ig(De,It,tt))},[r,It,ee]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noWorkingDir")});if(Pe||!H)return s.jsx(YP,{});if(It&&xe){const tt=Ye?.total??Qt.length,De=Qt.slice(0,St),nr=St<Qt.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Ab,{count:tt,loading:ue,engine:Ye?.engine,limited:Ye?.limited,scope:Ve,content:!0}),at?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:[le("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:at})]}):ue&&Qt.length===0?s.jsx(p0,{label:le("fileTree.searching"),className:"py-8"}):Qt.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:le("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[Ye?.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:le("fileTree.searchTruncatedHint",{count:Ye.total})}),De.map(Ke=>s.jsx(cO,{entry:Ke,rootPath:Ve,selectedFilePath:E,query:R.trim(),onContentMatchSelect:$,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:p},Ke.path)),s.jsx("div",{ref:Kt,className:"py-2 text-center text-[11px] text-muted-foreground",children:nr?s.jsx("button",{type:"button",onClick:()=>Gt(Ke=>Math.min(Ke+wb,Qt.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:De.length,total:Qt.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(_n,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:De.length,total:tt})}):null})]})]})}if(It){const tt=Ye?.total??ae.length,De=ae.slice(0,St),nr=St<ae.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Ab,{count:tt,loading:ue,engine:Ye?.engine,limited:Ye?.limited,scope:Ve,content:!1}),ue&&ae.length===0?s.jsx(p0,{label:le("fileTree.searching"),className:"py-8"}):at?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:at}):ae.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:le("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[Ye?.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:le("fileTree.searchTruncatedHint",{count:Ye.total})}),De.map(Ke=>s.jsx(iO,{node:Ke,rootPath:Ve,onFileSelect:t,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,pinnedPaths:L,selectedFilePath:E,insertedReferenceKey:d,copiedReferenceKey:p,onFileDeleteRequest:ut,deletingFilePath:zt},Ke.path)),s.jsx("div",{ref:Kt,className:"py-2 text-center text-[11px] text-muted-foreground",children:nr?s.jsx("button",{type:"button",onClick:()=>Gt(Ke=>Math.min(Ke+yb,ae.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:De.length,total:ae.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(_n,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:De.length,total:tt})}):null})]})]})}return oe?s.jsx("div",{role:a?"alert":void 0,className:"px-4 py-4 text-sm text-destructive",children:oe}):!ee||ee.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.emptyDir")}):!qt||qt.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:le("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[nt&&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:le("fileTree.truncatedHint")}),qt.map(tt=>s.jsx(sO,{node:tt,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:S,pinnedPaths:L,selectedFilePath:E,queryLower:It,insertedReferenceKey:d,copiedReferenceKey:p,onDirectoryDropFiles:V,onFileDeleteRequest:ut,deletingFilePath:zt,revealedDirectoryPath:Z?.path},tt.path))]})}function I1(e){return e.trim().replace(/\/+$/,"")||"/"}function dO(e){const t=I1(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function rp({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:c}){const{t:l}=Ur(),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")},p=b.useRef(null);Gc(p,e,a);const[m,x]=b.useState(()=>I1(t));return b.useEffect(()=>{e&&x(I1(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?Xs.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:p,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(mT,{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(In,{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(dO(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(jy,{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(uO,{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(pi,{size:13}),d.confirm]})]})]})]}),document.body):null}const hO=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:rp},Symbol.toStringTag,{value:"Module"})),E1="termdock:new-session-commands:v1",ac="__saved_command__:";function kh(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(ac)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function Pd(){try{const e=JSON.parse(localStorage.getItem(E1)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function fO({directories:e,tmuxAvailable:t,options:r,agents:n,selectedAgent:a,detecting:c,resumeHistory:l,resumeHistoryLoading:d,resumeHistoryPendingId:p,resumeHistoryError:m,onRefreshAgents:x,onSelectAgent:y,onLaunchAgent:w,onResumeHistory:v,onRemoveResumeHistory:S,onClose:L,onOptionsChange:E,additionalContent:R,footerActions:B,launchPending:z=!1,launchError:O}){const{t:$,locale:V}=Ur(),Z=b.useRef(null);Gc(Z,!0,L,()=>document.querySelector('[aria-controls="sidebar-launch-options"]'));const[le,be]=b.useState(a),[pe,ee]=b.useState(!1),[_e,ze]=b.useState(!1),[Y,ce]=b.useState(Pd),[qe,we]=b.useState(()=>kh(Pd())),[ye,Le]=b.useState(null),[Be,ne]=b.useState("idle"),Fe=_e?"__custom__":le?.slug??"__terminal__",ke=le?.command??"",Ee=_e?Y.__custom__??Y.__terminal__??"":le?Y[Fe]??ke:"",Pe=()=>{const Ce=Ee.trim()||ke;if(!(_e&&!Ce))try{const H={...Pd(),[Fe]:Ce};if(_e){for(const ae of kh(Pd()))H[ac+ae]=ae;H[ac+Ce]=Ce}localStorage.setItem(E1,JSON.stringify(H)),we(kh(H)),_e&&Le(Ce),ne("saved")}catch{ne("error")}},Ne=()=>{if(ye)try{const Ce=Pd();for(const[H,ae]of Object.entries(Ce))(H.startsWith(ac)||H==="__custom__"||H==="__terminal__")&&ae.trim()===ye&&delete Ce[H];localStorage.setItem(E1,JSON.stringify(Ce)),we(kh(Ce)),ce(H=>({...H,__custom__:""})),Le(null),ne("idle")}catch{ne("error")}},oe=()=>{const Ce=Ee.trim()||ke;z||_e&&!Ce||(Pe(),w(le,Ce))},We=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),nt=_e?ye?ac+ye:"__custom__":le?.slug??"__terminal__",gt=Ce=>{ne("idle");const H=Ce.startsWith(ac)?Ce.slice(ac.length):null;Le(H),ze(Ce==="__custom__"||H!==null),(H!==null||Ce==="__custom__")&&ce(ae=>({...ae,__custom__:H??""})),be(n.find(ae=>ae.slug===Ce)??null)},ue=_e?ye??$("sidebar.customStartupCommand"):le?.displayName??"Terminal",Ze=a?.displayName??"Terminal",at=!_e&&(le===null?a===null:a?.slug===le.slug);b.useEffect(()=>{if(pe)return;const Ce=H=>{H.target instanceof Node&&(Z.current?.contains(H.target)||H.target instanceof Element&&H.target.closest("[data-sidebar-composer-popover]")?.getAttribute("data-sidebar-composer-popover")===Z.current?.id||H.target instanceof Element&&H.target.closest('[aria-controls="sidebar-launch-options"]')||L())};return document.addEventListener("pointerdown",Ce,!0),()=>document.removeEventListener("pointerdown",Ce,!0)},[pe,L]);const Ie=Ce=>{E({...r,cwd:Ce}),ee(!1)},Ge=Ce=>new Intl.DateTimeFormat(V==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(Ce));return s.jsxs("section",{ref:Z,tabIndex:-1,"aria-busy":z,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 ${B?"max-h-[min(70svh,42rem,calc(100%_-_4.5rem))]":"max-h-[min(56svh,36rem,calc(100%_-_4.5rem))]"}`,"aria-label":$("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($o,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:$("sidebar.newSessionComposerTitle")})})]}),s.jsx("button",{type:"button",onClick:L,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":$("common.close"),children:s.jsx(In,{size:14})})]}),s.jsxs("fieldset",{disabled:z,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:$("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(Ce=>s.jsx("button",{type:"button",disabled:Ce==="tmux"&&!t,onClick:()=>E({...r,mode:Ce}),"aria-pressed":r.mode===Ce,title:Ce==="tmux"?$(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===Ce?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:$(Ce==="shell"?"sidebar.newShell":"sidebar.newTmux")},Ce))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:$("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:$("sidebar.detectAgents"),"aria-label":$("sidebar.detectAgents"),children:s.jsx(bn,{size:12,className:c?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":$("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(Ce=>{const H=!_e&&le?.slug===Ce.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>gt(Ce.slug),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${H?"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(Wc,{agent:Ce,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:Ce.displayName}),a?.slug===Ce.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:$("sidebar.defaultAgent")})]},Ce.slug)}),qe.map(Ce=>{const H=_e&&ye===Ce;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>gt(ac+Ce),title:Ce,className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 transition ${H?"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(Qc,{size:10,className:"shrink-0"}),s.jsx("span",{className:"max-w-[9rem] truncate font-mono text-[10px]",children:Ce})]},Ce)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":nt==="__terminal__",onClick:()=>gt("__terminal__"),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${nt==="__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($o,{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:$("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":nt==="__custom__",onClick:()=>gt("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${nt==="__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(zs,{size:10,className:"shrink-0"}),s.jsx("span",{children:$("sidebar.addStartupCommand")})]})]}),!at&&!_e&&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:$("sidebar.currentDefaultAgent",{name:Ze})}),s.jsx("button",{type:"button",onClick:()=>y(le),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:$("sidebar.makeDefault")})]}),Be==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:$("sidebar.saveStartupCommandFailed")}),(le||_e)&&s.jsxs("details",{open:_e&&!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:[$(_e&&!ye?"sidebar.customStartupCommand":"sidebar.changeStartupCommand"),s.jsx(ul,{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:$("sidebar.startupCommand")}),le&&Ee!==ke&&s.jsx("button",{type:"button",onClick:()=>{ce(Ce=>({...Ce,[Fe]:ke})),ne("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:$("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:Ee,onChange:Ce=>{ce(H=>({...H,[Fe]:Ce.target.value})),ne("idle")},placeholder:ke||$("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:[_e&&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":$("sidebar.deleteStartupCommand"),children:[s.jsx(Rs,{size:11}),$("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:Pe,disabled:Be==="saved"||_e&&!Ee.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:$(Be==="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:$(le?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},ye??Fe),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:$("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>ee(!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(Vc,{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||$("sidebar.directoryPlaceholder")})]}),We.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":$("sidebar.recentDirectories"),children:We.map(Ce=>s.jsx("button",{type:"button",onClick:()=>Ie(Ce),title:Ce,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:Ku(Ce)||Ce},Ce))}),(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(Qc,{size:11}),s.jsx("span",{className:"flex-1",children:$("sidebar.resumeHistory")}),d&&s.jsx(_n,{size:10,className:"animate-spin"}),l.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:$("sidebar.resumeHistoryCount",{n:l.length})}),s.jsx(ul,{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(Ce=>{const H=p===Ce.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:p!==null,onClick:()=>v(Ce),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":$("sidebar.resumeHistoryAction",{title:Ce.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:H?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(Wc,{agent:Ce.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:Ce.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[Ce.agent.displayName," · ",Ge(Ce.closedAt)]})]}),s.jsx(Uy,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>S(Ce.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":$("sidebar.resumeHistoryRemove",{title:Ce.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(Rs,{size:12})]})]},Ce.id)})}),m&&s.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:m})]}),R]}),s.jsxs("div",{className:"shrink-0 bg-surface px-3 pb-3 pt-2",children:[O&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:O}),s.jsxs("button",{type:"button",onClick:oe,disabled:z||_e&&!Ee.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":$("sidebar.launchSessionWith",{name:ue}),children:[z?s.jsx(_n,{size:14}):le?s.jsx(Wc,{agent:le,size:15}):s.jsx($o,{size:14}),s.jsx("span",{className:"truncate",children:z?$("sidebar.sessionCreating"):$("sidebar.launchSessionWith",{name:ue})})]}),B]}),s.jsx(rp,{open:pe,initialPath:r.cwd?.trim()||We[0]||"/",title:$("sidebar.chooseDirectory"),onCancel:()=>ee(!1),onConfirm:Ie})]})}const H6="termdock:new-session-agent:v1";function pO(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(H6)||"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 Am(e){if(!(typeof window>"u"))try{window.localStorage.setItem(H6,JSON.stringify(e))}catch{}}function mO(e,t){return e?t.find(r=>r.slug===e)??null:null}function gO(){const[e,t]=b.useState(pO),[r,n]=b.useState([]),[a,c]=b.useState(!0),l=b.useCallback(async()=>{c(!0);try{const[p,m]=await Promise.all([fc(),_y()]),x=mO(p.newSessionAgentSlug,m);n(m),t(x),Am(x)}finally{c(!1)}},[]);b.useEffect(()=>{const p=()=>{l().catch(()=>{})};if(performance.getEntriesByName("termdock:startup:initial-viewport-presented").length>0){p();return}return window.addEventListener("termdock:initial-viewport-presented",p,{once:!0}),()=>window.removeEventListener("termdock:initial-viewport-presented",p)},[l]);const d=b.useCallback(async p=>{const m=e;t(p),Am(p);try{await La({newSessionAgentSlug:p?.slug??null})}catch(x){throw t(m),Am(m),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:l,selectAgent:d}}function xO({groups:e,sessions:t,busy:r,onOpen:n,onSettings:a,onCreate:c}){const[l,d]=b.useState(""),p=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(zs,{size:14}),"新建协作组"]})]}),(e.length>5||l)&&s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"搜索协作组"}),s.jsx(jl,{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:[p.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=>Iu(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(Xu,{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(_T,{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(ju,{size:14})})]})]},m.id)}),!p.length&&s.jsx("p",{className:"px-3 py-6 text-xs text-muted-foreground",children:"没有匹配的协作组,试试其他名称。"})]})]})}const jc="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",Lh="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-xs disabled:opacity-40",Ih=e=>({profiles:e.launchProfiles??[],defaultId:e.defaultLaunchProfileId??"",group:e}),Tm=new Map,Od=e=>JSON.stringify(e.profiles)!==JSON.stringify(e.group.launchProfiles??[])||e.defaultId!==(e.group.defaultLaunchProfileId??"");function bO({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:jc,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 yO({group:e,agents:t,busy:r,setBusy:n,refresh:a}){const c=`${window.location.origin}:${e.id}`,[l,d]=b.useState(()=>Tm.get(c)??Ih(e)),p=b.useRef(l);p.current=l;const[m,x]=b.useState(l.profiles[0]?.id??""),[y,w]=b.useState(null),[v,S]=b.useState(""),L=($,V=!0)=>{p.current=$,d($),Od($)?Tm.set(c,$):Tm.delete(c),V&&S("")};b.useEffect(()=>{!Od(p.current)&&e.updatedAt>=p.current.group.updatedAt&&L(Ih(e),!1)},[e.updatedAt]);const E=l.profiles.find($=>$.id===m),R=$=>L({...l,profiles:l.profiles.map(V=>V.id===m?{...V,...$}:V)}),B=l.profiles.every($=>$.name.trim()&&$.agentSlug&&$.command.trim()&&!/[\x00-\x1f\x7f]/.test($.command)),z=()=>{const $=t[0],V={id:`profile-${crypto.randomUUID()}`,name:"",agentSlug:$?.slug??"",command:$?.command??"",notes:""};L({...l,profiles:[...l.profiles,V]}),x(V.id)},O=async()=>{if(!(r||!B||!Od(l))){n("launch-profiles"),w(null),S("");try{const{group:$}=await Ml({id:e.id,name:l.group.name,sessionIds:l.group.sessionIds,expectedUpdatedAt:l.group.updatedAt,launchProfiles:l.profiles,defaultLaunchProfileId:l.defaultId||null});L(Ih($)),S("启动方案已保存。新会话使用所选方案,正在运行的成员保持原配置。"),await a()}catch($){w($ instanceof Error?$.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," 个",Od(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:jc,value:l.defaultId,onChange:$=>L({...l,defaultId:$.target.value}),children:[s.jsx("option",{value:"",children:"使用 Agent 默认命令"}),l.profiles.map($=>s.jsx("option",{value:$.id,children:$.name||"未命名方案"},$.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:`${jc} mt-1`,value:m,onChange:$=>x($.target.value),children:[s.jsx("option",{value:"",children:"选择方案"}),l.profiles.map($=>s.jsx("option",{value:$.id,children:$.name||"未命名方案"},$.id))]})]}),s.jsxs("button",{type:"button",className:`${Lh} self-end bg-surface text-foreground`,disabled:l.profiles.length>=20,onClick:z,children:[s.jsx(zs,{size:14}),"新增方案"]})]}),E?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:jc,value:E.name,maxLength:100,onChange:$=>R({name:$.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:jc,value:E.agentSlug,onChange:$=>R({agentSlug:$.target.value,command:t.find(V=>V.slug===$.target.value)?.command??""}),children:[!t.some($=>$.slug===E.agentSlug)&&s.jsxs("option",{value:E.agentSlug,children:[E.agentSlug||"选择 Agent","(当前不可用)"]}),t.map($=>s.jsx("option",{value:$.slug,children:$.displayName},$.slug))]})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动命令",s.jsx("input",{className:`${jc} font-mono`,value:E.command,maxLength:4096,onChange:$=>R({command:$.target.value}),placeholder:"填写完整命令,包括模型和启动参数"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["使用备注",s.jsx("textarea",{"aria-label":"使用备注",className:`${jc} min-h-24 resize-y`,value:E.notes,maxLength:2e3,onChange:$=>R({notes:$.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:E.id})]}),s.jsxs("button",{type:"button",className:`${Lh} text-destructive hover:bg-destructive/10`,onClick:()=>{const $=l.profiles.filter(V=>V.id!==m);L({...l,profiles:$,defaultId:l.defaultId===m?"":l.defaultId}),x($[0]?.id??"")},children:[s.jsx(Rs,{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:`${Lh} bg-surface text-muted-foreground`,disabled:!!r,onClick:()=>{L(Ih(e)),x(e.launchProfiles?.[0]?.id??""),w(null)},children:"重新载入(放弃方案草稿)"}),s.jsx("button",{type:"button",disabled:!!r||!B||!Od(l),className:`${Lh} bg-primary text-primary-foreground`,onClick:()=>{O()},children:r==="launch-profiles"?"保存中…":"保存启动方案"})]})]})]})}function vO(e,t){const r=t.events.filter(p=>p.kind==="retry"&&!e.events.some(m=>m.id===p.id)).at(-1),n=new Set(e.deliveries.filter(p=>p.status==="delivered").map(p=>p.id)),a=new Set(e.outbox.filter(p=>!n.has(p.id)).map(p=>p.id)),c=r&&t.deliveries.some(p=>a.has(p.id)&&p.status==="delivered"&&p.deliveredAt!==null&&p.deliveredAt>=r.createdAt);let l=c?"重试请求已保存,匹配本次请求的投递已写入终端。":"重试请求已保存,服务将重新检查现有投递与协调条件。";!t.outbox.length&&!c&&(l+=" 当前没有待重试的投递记录。"),t.workflow?.paused&&(l+=" 后续自动安排仍已暂停。");const d=t.attempts.find(p=>p.id===t.activeAttemptId)?.report;return d&&["blocked","failed"].includes(d.status)&&(l+=" 成员原报告仍保留;请补齐条件并通知成员,收到新的明确回复后更新报告。"),l}function wO(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 Tb(e){return new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function Df({task:e,now:t,compact:r=!1}){const n=w6(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:Tb(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():wO(e.updatedAt,t),children:Tb(e.updatedAt)})]}):"记录更新时间未提供"})]})}function W6(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 Jh({inputKey:e,paneKey:t,label:r,value:n,onChange:a,active:c=!0,disabled:l=!1,required:d,autoFocus:p,placeholder:m,className:x,onUploadChange:y}){const w=b.useId(),v=b.useRef(null),S=b.useRef(null),L=b.useRef({value:n,onChange:a,onUploadChange:y});L.current={value:n,onChange:a,onUploadChange:y};const[E,R]=b.useState(0),[B,z]=b.useState(""),O=b.useRef(Promise.resolve());b.useEffect(()=>{const ee=v.current;ee&&ee.setSelectionRange(ee.value.length,ee.value.length)},[e]);const $=()=>({value:L.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),V=(ee,_e=$())=>{L.current.onChange(ze=>ze!==_e.value?ze+(ze&&!/\s$/.test(ze)?`
138
+ `:"")+ee:ze.slice(0,_e.start)+ee+ze.slice(_e.end))};b.useEffect(()=>{if(!c)return;const ee=ky(_e=>V(_e.replace(/\r\n?/g,`
139
+ `)),e,!!t,t);return t||s0(e),ee},[c,e,t]);const Z=()=>{const ee=f0();return`${location.origin}:${ee?.targetPeerId??""}:${ee?.serviceOrigin??""}`},le=ee=>{const _e=$(),ze=Z(),Y=L.current.onUploadChange;z(""),R(ce=>ce+1),Y?.(1),O.current=O.current.then(async()=>{try{if(ze!==Z())throw new Error("目标服务已切换,请重新添加附件");const ce=await ee();if(ze!==Z())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(ce)?V(ce.map(Dc).join(" ")+" ",_e):ce&&V(ce,_e)}catch(ce){const qe=ce instanceof Error?ce.message:"附件准备失败,请重试";z(qe.includes("Upload did not return")?"附件上传未返回完整路径,请重试":qe)}finally{R(ce=>ce-1),Y?.(-1)}})},be=async ee=>ee.length===1&&ee[0].type.startsWith("image/")?[await a3(ee[0])]:c3(ee),pe=ee=>{const _e=ee.clipboardData.files.length?Array.from(ee.clipboardData.files):Array.from(ee.clipboardData.items??[]).filter(ce=>ce.kind==="file").map(ce=>ce.getAsFile()).filter(ce=>ce!==null),ze=ee.clipboardData.getData("text/plain"),Y=vo();!Y?.readClipboardFiles&&!_e.length&&ze||!Y&&!_e.length&&typeof navigator.clipboard?.read!="function"||(ee.preventDefault(),le(async()=>{const ce=Z();let qe;if(Y?.readClipboardFiles)try{const we=await l3();if(we.paths.length||we.files.length)return[...we.paths,...await be(we.files)]}catch(we){if(we instanceof o0)throw we;qe=we}if(ce!==Z())throw new Error("目标服务已切换,请重新粘贴");if(_e.length)return be(_e);if(ze)return ze;if(typeof navigator.clipboard?.read=="function"){const we=await navigator.clipboard.read(),ye={read:async()=>we},Le=await o3(ye);if(Le.length)return be(Le);const Be=await ff(ye);if(Be)return be([Be]);for(const ne of we)if(ne.types.includes("text/plain"))return(await ne.getType("text/plain")).text()}else{const we=await ff();if(we)return be([we])}if(qe)throw qe;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>s0(e),onPointerDownCapture:()=>s0(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:p,"aria-describedby":E||B?`${w}-status`:void 0,placeholder:m,className:x,onChange:ee=>a(ee.target.value),onPaste:pe,onDragOver:ee=>{!l&&ee.dataTransfer.types.includes("Files")&&ee.preventDefault()},onDrop:ee=>{const _e=Array.from(ee.dataTransfer.files);!_e.length||l||(ee.preventDefault(),ee.stopPropagation(),le(()=>be(_e)))}}),s.jsxs("div",{className:"flex min-h-9 items-center gap-2",children:[s.jsx("input",{ref:S,type:"file",multiple:!0,hidden:!0,"aria-label":`选择附件:${r}`,onChange:ee=>{const _e=Array.from(ee.target.files??[]);ee.target.value="",_e.length&&le(()=>be(_e))}}),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:()=>S.current?.click(),children:[s.jsx(ZT,{size:14}),"附件"]}),E>0?s.jsxs("span",{id:`${w}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(bn,{size:12,className:"animate-spin"}),"正在准备附件…"]}):B?s.jsx("span",{id:`${w}-status`,role:"alert",className:"break-words text-xs text-destructive",children:B}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function Sb(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 p=[];let m=d;for(;;){const x=p.findIndex(w=>w.id===m.id);if(x!==-1)return p.slice(x).sort((w,v)=>w.id.localeCompare(v.id))[0];p.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 p=t||r.trim()?[]:e.filter(y=>y.id!==d.id&&l.get(y.id)===d.id&&y.status!=="closed"),m=d.status==="open"&&!Ui(d)?p.find(y=>y.decisions.some(w=>w.status==="pending"))??p.find(y=>Ui(y)||y.workflow?.paused):void 0,x=p.filter(y=>Ui(y)||y.workflow?.paused).length;return{task:d,children:p,attention:m,attentionCount:x,rootId:l.get(d.id)}})}function G6(e,t=[]){const r=Kc(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!Ui(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function AO({task:e,children:t,onSelect:r}){const n=new Map(t.map(m=>[m.id,m])),a=(t.length?t:e.children??[]).filter(m=>m.status!=="closed");if(!a.length)return null;const c=(m,x)=>{const y=n.get(m);return y&&(Ui(y)||y.workflow?.paused)?0:x?2:1},l=[...a].sort((m,x)=>c(m.id,m.status==="accepted")-c(x.id,x.status==="accepted")||(n.get(x.id)?.updatedAt??0)-(n.get(m.id)?.updatedAt??0)),d=a.filter(m=>m.status==="accepted").length,p=m=>{const x=n.get(m.id),y=m.status==="accepted",w=x&&(Ui(x)||x.workflow?.paused),v=x?G6(x):y?m.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",S=y?zu:Hu;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(m.id),children:[s.jsx(S,{size:14,className:`mt-0.5 shrink-0 ${y||w?"text-primary":"text-muted-foreground"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{title:m.title,className:"block line-clamp-2 break-words text-xs leading-5 text-foreground",children:m.title}),s.jsx("span",{className:`block text-[11px] leading-5 ${w?"text-primary":"text-muted-foreground"}`,children:v})]}),s.jsx(Ks,{size:12,className:"mt-1 shrink-0 text-muted-foreground"})]},m.id)};return s.jsxs("section",{"aria-label":"执行事项",className:"mx-4 border-t border-border/15 py-2",children:[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:[d,"/",a.length," 项已完成"]})]}),l.slice(0,3).map(p),l.length>3&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[11px] text-muted-foreground",children:["展开其余 ",l.length-3," 项"]}),l.slice(3).map(p)]})]})}function Cb(e){return e.status!=="open"?"done":Ui(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Sl=[{id:"backlog",label:"待开始",icon:Hu,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:lf,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:Xu,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:zu,hint:"验收后的结果会保留在这里"}];function TO({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:c,navigation:l,settings:d}){const p=b.useRef(null),m=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),w=b.useRef(null),[v,S]=b.useState(Date.now);b.useEffect(()=>{const H=setInterval(()=>S(Date.now()),3e4);return()=>clearInterval(H)},[]);const[L,E]=b.useState(!1);b.useEffect(()=>{const H=new ResizeObserver(ae=>{const Ae=ae[0].contentRect.width;E(Ae>=760),Ae!==y.current&&Ae<760&&m.current&&(m.current.scrollLeft=Sl.findIndex(Ye=>Ye.id===x.current)*m.current.clientWidth),y.current=Ae});return p.current&&H.observe(p.current),()=>H.disconnect()},[]);const[R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[B,z]=b.useState(()=>{if(Sl.some(Ae=>Ae.id===R?.lane))return R.lane;const ae=Sb(e,R?.showSteps===!0,R?.query??"").map(Ae=>Ae.attention?"attention":Cb(Ae.task));return ae.includes("attention")?"attention":ae.includes("running")?"running":ae.includes("backlog")?"backlog":"done"});x.current=B;function O(H,ae=!0){z(H);const Ae=m.current;if(!Ae||!Ae.clientWidth)return;w.current=H;const Ye=Sl.findIndex(St=>St.id===H)*Ae.clientWidth,et=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Ae.scrollTo?Ae.scrollTo({left:Ye,behavior:ae&&!et?"smooth":"auto"}):Ae.scrollLeft=Ye}b.useEffect(()=>{L||O(x.current,!1)},[L]);const[$,V]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[Z,le]=b.useState(typeof R?.query=="string"?R.query:""),[be,pe]=b.useState(R?.closed===!0),[ee,_e]=b.useState(R?.showSteps===!0),[ze,Y]=b.useState(!!R?.query),[ce,qe]=b.useState(!1),[we,ye]=b.useState(!1),Le=b.useRef(null),Be=b.useRef(null);b.useEffect(()=>{if(!we)return;Le.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const H=Ae=>{Le.current?.contains(Ae.target)||ye(!1)},ae=Ae=>{Ae.key==="Escape"&&(Ae.preventDefault(),Ae.stopPropagation(),ye(!1),Be.current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[we]);const ne=b.useRef(null),Fe=b.useRef(null),ke=b.useRef(null),Ee=b.useRef(null);b.useEffect(()=>{ze&&ne.current?.focus()},[ze]),b.useEffect(()=>{if(!ce)return;ke.current?.querySelector("select")?.focus();const H=Ae=>{ke.current?.contains(Ae.target)||qe(!1)},ae=Ae=>{Ae.key==="Escape"&&(Ae.preventDefault(),Ae.stopPropagation(),qe(!1),(L?Ee:Be).current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[ce]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:B,scope:$,query:Z,closed:be,showSteps:ee}))}catch{}},[a,B,$,Z,be,ee]);const Pe=e.filter(H=>H.workflow?.kind==="goal"),Ne=Sb(e,ee,Z),oe=new Map(Ne.map(H=>[H.task.id,H])),We=H=>oe.get(H.id)?.attention?"attention":Cb(H),nt=t?Ne.find(H=>H.task.id===t||H.children.some(ae=>ae.id===t)):void 0,gt=nt?We(nt.task):void 0;b.useEffect(()=>{gt&&O(gt,!1)},[t,gt]);const ue=Ne.map(H=>H.task).filter(H=>(be||H.status!=="closed")&&($==="all"||H.id===$||oe.get(H.id)?.rootId===$)&&(!Z.trim()||`${H.title} ${H.spec} ${H.attempts.map(ae=>n(H,ae.assignee)).join(" ")}`.toLocaleLowerCase().includes(Z.trim().toLocaleLowerCase()))),Ze=+($!=="all")+Number(be)+Number(ee),at="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",Ie="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",Ge=s.jsxs("div",{className:`relative flex min-w-0 items-center ${L?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(jl,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:ne,"aria-label":"搜索任务",type:"search",value:Z,onChange:H=>le(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),Z?le(""):(Y(!1),requestAnimationFrame(()=>(L?Fe:Be).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:()=>{le(""),Y(!1),requestAnimationFrame(()=>(L?Fe:Be).current?.focus())},children:s.jsx(In,{size:14})})]}),Ce=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:$,onChange:H=>V(H.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:"所有目标"}),Pe.map(H=>s.jsx("option",{value:H.id,children:H.title},H.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:be,onChange:H=>pe(H.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:ee,onChange:H=>_e(H.target.checked)}),"显示执行子任务"]}),Ze>0&&s.jsx("button",{type:"button",className:"min-h-11 w-full rounded-lg text-xs text-primary hover:bg-surface-2",onClick:()=>{V("all"),pe(!1),_e(!1)},children:"清除筛选"})]});return s.jsxs("div",{ref:p,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:L?void 0:ke,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:L?s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:l}),ze?Ge:s.jsx("button",{ref:Fe,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${at} ${l?"":"ml-auto"}`,onClick:()=>Y(!0),children:s.jsx(jl,{size:16})}),s.jsxs("div",{ref:ke,className:"relative shrink-0",children:[s.jsxs("button",{ref:Ee,type:"button","aria-label":Ze?`筛选任务,${Ze} 项已启用`:"筛选任务","aria-expanded":ce,className:`${at} ${Ze?"text-primary":""}`,onClick:()=>qe(H=>!H),children:[s.jsx(Um,{size:15}),s.jsx("span",{children:"筛选"}),Ze>0&&s.jsx("span",{className:"tabular-nums text-primary",children:Ze})]}),ce&&Ce]}),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:Le,className:"relative shrink-0",children:[s.jsxs("button",{ref:Be,type:"button","aria-label":"更多看板操作","aria-expanded":we,className:`${at} ${we?"bg-surface-2 text-foreground":Ze||Z.trim()?"text-primary":""}`,onClick:()=>{ye(H=>!H),qe(!1)},children:[s.jsx(To,{size:18}),Ze>0&&s.jsx("span",{className:"text-[10px]",children:Ze})]}),we&&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:Fe,type:"button","aria-label":"搜索任务",className:Ie,onClick:()=>Y(!0),children:[s.jsx(jl,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Ee,type:"button","aria-label":Ze?`筛选任务,${Ze} 项已启用`:"筛选任务",className:Ie,onClick:()=>qe(!0),children:[s.jsx(Um,{size:18,className:"shrink-0 text-muted-foreground"}),"筛选任务",Ze>0&&s.jsx("span",{className:"ml-auto rounded bg-primary/10 px-1.5 text-xs tabular-nums text-primary",children:Ze})]}),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&&Ge,ce&&Ce]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:ee?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),s.jsx("nav",{hidden:L,"aria-label":"看板阶段",className:`${L?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:Sl.map(H=>s.jsxs("button",{type:"button","aria-pressed":B===H.id,className:`min-h-11 rounded-lg px-1 text-xs ${B===H.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>O(H.id),children:[H.label,s.jsx("span",{className:"ml-1 tabular-nums",children:ue.filter(ae=>We(ae)===H.id).length})]},H.id))}),s.jsxs("div",{ref:L?void 0:m,"data-kanban-scroll":!0,onPointerDown:()=>{w.current=null},onWheel:()=>{w.current=null},"aria-label":L?void 0:"可左右滑动的任务看板",onScroll:L?void 0:H=>{if(H.target!==H.currentTarget||!H.currentTarget.clientWidth)return;const ae=w.current;if(ae){const Ye=Sl.findIndex(et=>et.id===ae)*H.currentTarget.clientWidth;if(Math.abs(H.currentTarget.scrollLeft-Ye)>2)return;w.current=null}const Ae=Math.max(0,Math.min(Sl.length-1,Math.round(H.currentTarget.scrollLeft/H.currentTarget.clientWidth)));z(Sl[Ae].id)},className:L?"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:[L&&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:Sl.map(H=>{const ae=H.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${H.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(ae,{size:15}),H.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:ue.filter(Ae=>We(Ae)===H.id).length})]},H.id)})}),s.jsx("div",{className:L?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:Sl.map(H=>{const ae=ue.filter(Ae=>We(Ae)===H.id).sort((Ae,Ye)=>Ye.updatedAt-Ae.updatedAt);return s.jsx("section",{"aria-label":`${H.label}任务`,"aria-hidden":!L&&B!==H.id?!0:void 0,ref:Ae=>{Ae&&(Ae.inert=!L&&B!==H.id)},style:L?void 0:{width:"100%"},className:L?"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:[ae.map(Ae=>{const Ye=oe.get(Ae.id),et=Ye.attention??Ae,St=et.attempts.find(tt=>tt.id===et.activeAttemptId),Gt=et.decisions.find(tt=>tt.status==="pending"),Qt=Kc(et),wt=G6(et,Ye.children),zt=Jf(et),Vt=zt[0],Kt=zt.find(tt=>tt.source==="system"),Ot=zt.find(tt=>tt.source==="unknown"),It=Kt?.content,xe=H.id==="attention",Ve=Gt?"回答问题":Ot?"查看详情核对记录":Vt?.source==="member"&&Kt?"查看条件与异常处理":Vt?.source==="member"?"查看阻塞并补充条件":It?"查看原因与处理":Qt==="等待你验收"?"查看结果并验收":Qt==="需要你确认方案"?"查看并确认方案":"查看任务并处理",ht=et.artifacts.filter(tt=>tt.kind==="result"&&tt.attemptId===et.activeAttemptId).at(-1),q=et.events.filter(tt=>tt.kind==="revise"&&tt.source==="user"&&tt.attemptId===et.activeAttemptId&&(!ht||tt.createdAt>=ht.createdAt)).at(-1),ut=Gt?Gt.question||"成员提出了一个问题,打开后可查看并回答。":Vt?.summary||q?.content||ht?.summary||(St?.report?.content?W6(St.report.content).summary:St?.report?.summary||""),qt=e.find(tt=>tt.id===Ae.parentTaskId);return s.jsxs("article",{"aria-label":Ae.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===Ae.id?"border-primary/60":It?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":Ae.id,"aria-pressed":t===Ae.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(et.id),children:[qt&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:qt.title}),s.jsx("span",{title:Ae.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:Ae.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${It&&Vt?.source!=="member"?"text-destructive":xe?"text-primary":"text-muted-foreground"}`,children:[It&&Vt?.source!=="member"&&s.jsx(P1,{size:13,className:"shrink-0"}),wt]}),Ye.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",Ye.attention.title]}),Ye.attention&&Ye.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",Ye.attentionCount," 项执行需要你处理"]}),ut&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:ut}),Kt&&Vt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Kt.label,":",Kt.summary]}),Ot&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[Ot.label,":",Ot.summary]}),xe&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${It?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[Ve,s.jsx($m,{size:14})]}),!xe&&(Ae.status==="accepted"||Ae.artifacts.some(tt=>tt.kind==="result"&&tt.attemptId===Ae.activeAttemptId))&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:[q?"查看跟进":"查看结果",s.jsx($m,{size:14})]})]}),s.jsx(AO,{task:Ae,children:Ye.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:[Ye.attention?"待处理任务负责人:":Ae.workflow?.kind==="goal"?"协调者:":"负责人:",St?n(et,St.assignee):et.scheduledAssignee?n(et,et.scheduledAssignee):"未分派"]}),s.jsx(Df,{task:et,now:v,compact:!0})]})]},Ae.id)}),!ae.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Z||$!=="all"?"没有匹配的任务":e.length?"暂无任务":H.hint})]})},H.id)})})]})]})}const Rl=hc((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 Eh(e,t){return r=>Rl.getState().update(e,t,r)}function Sm(e,t){return r=>Rl.getState().updateDetail(e,t,r)}const SO=b.lazy(()=>Oc(()=>Promise.resolve().then(()=>hO),void 0).then(e=>({default:e.DirectoryPickerDialog}))),CO=b.lazy(()=>Oc(()=>import("./CollaborationTaskContent-BwHxwcOP.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),ca="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",Ps="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",cl=`${ca} bg-primary text-primary-foreground`,ai=`${ca} bg-surface-2 text-foreground hover:bg-surface-2/80`,_O={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:"请求重新检查"},Ou=e=>`${e.serviceId}:${e.sessionId}`,Sa=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function go(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 Fi(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const t0={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]},_b="__new_coordinator__";function kO(e){const t={...t0,...go(e,t0)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(t0).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?t0:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function V6(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 LO({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:c,board:l=!1,boardNavigation:d,boardSettings:p,paneKey:m,agents:x=[],defaultCwd:y,onTeamReady:w}){const v=`termdock:tasks:${location.origin}:${e.id}`,[S,L]=b.useState([]),E=b.useRef(S);E.current=S;const[R,B]=b.useState(null),[z]=b.useState(()=>Rl.getState().ensure(v,{draft:kO(`${v}:draft`),selectedId:go(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:O,mobileDetail:$,creating:V,draft:Z}=Rl(re=>re.views[v]??z),le=Eh(v,"selectedId"),be=Eh(v,"mobileDetail"),pe=Eh(v,"creating"),ee=Eh(v,"draft"),[_e,ze]=b.useState(!1),[Y,ce]=b.useState(!1),qe=b.useRef(null),we=b.useRef(null),ye=b.useRef(!1),Le=b.useCallback(re=>{!re&&we.current===document.activeElement&&(ye.current=!0),we.current=re,re&&ye.current&&(ye.current=!1,re.focus())},[]);b.useEffect(()=>{const re=qe.current;if(!re)return;const mt=new ResizeObserver(Mt=>ze(Mt[0].contentRect.width>=(l?1100:760)));return mt.observe(re),()=>mt.disconnect()},[l]);const[Be,ne]=b.useState(!1),[Fe,ke]=b.useState(null),Ee=Ly(),[Pe,Ne]=b.useState(0),[oe,We]=b.useState(null),[nt,gt]=b.useState(!1),[ue,Ze]=b.useState(0),at=re=>Ze(mt=>Math.max(0,mt+re)),[Ie,Ge]=b.useState("");b.useEffect(()=>{if(!Ie)return;const re=setTimeout(()=>Ge(""),5e3);return()=>clearTimeout(re)},[Ie]);const[Ce,H]=b.useState("open"),[ae,Ae]=b.useState(""),Ye=b.useRef(!1),et=b.useRef(!0),St=b.useRef(new Map),Gt=b.useRef(!1),Qt=e.sessionIds.flatMap(re=>{const mt=t.find(Mt=>Mt.sessionId===re);return mt?[mt]:[]}),wt=Qt.map(re=>({...re,name:Iu(re,Qt)})),zt=Z.coordinator===_b,Vt=Z.coordinator||go(`${v}:lead`,""),Kt=wt.find(re=>re.sessionId===Z.coordinator&&re.agent),Ot=!!Z.coordinator&&!zt&&!Kt,It=zt||Ot?"":Kt?.sessionId||wt.find(re=>re.sessionId===Vt&&re.agent)?.sessionId||wt.find(re=>re.agent)?.sessionId||"",xe=wt.filter(re=>re.sessionId!==It&&re.agent).map(re=>re.sessionId),[Ve,ht]=b.useState(!1),[q,ut]=b.useState(!1),[qt,tt]=b.useState(()=>go(`${v}:agent`,"")),[De,nr]=b.useState(()=>go(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ke=e.launchProfiles?.find(re=>re.id===De),_t=wt.flatMap(re=>re.agent&&x.some(mt=>mt.slug===re.agent.slug)?[re.agent.slug]:[]),$t=[...new Set(_t)].sort((re,mt)=>_t.filter(Mt=>Mt===mt).length-_t.filter(Mt=>Mt===re).length)[0],yt=x.find(re=>re.slug===Kt?.agent?.slug)?.slug??$t??x[0]?.slug??"",xt=Ke?.agentSlug??(qt||yt),[Rt,Ct]=b.useState(()=>go(`${v}:cwd`,wt[0]?.cwd??y??"")),fr=!wt.find(re=>re.sessionId===It)?.agent||!xe.length,[Yt,Sr]=b.useState(null),pn=!!Z.spec.trim()&&(!!Yt||!Ot&&(!fr||!e.federated&&(!De||!!Ke)&&!!x.find(re=>re.slug===xt)&&!!Rt.trim())),dr=S.find(re=>re.id===O)??null,me=R?.id===O?R:null;b.useEffect(()=>(et.current=!0,()=>{et.current=!1}),[]),b.useEffect(()=>{Fi(`${v}:draft`,Z)},[v,Z]),b.useEffect(()=>{Fi(`${v}:selected`,O)},[v,O]),b.useEffect(()=>{const re=Mt=>{const rr=Mt.detail;rr?.groupId===e.id&&(Fi(`${v}:open-task`,null),le(rr.taskId),be(!0),pe(!1),H("all"),Gr())};window.addEventListener("open-collaboration-task",re);const mt=go(`${v}:open-task`,null);return mt&&(le(mt),be(!0),H("all"),Fi(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",re)},[e.id]),b.useEffect(()=>{if(!r||!dr||R?.id===dr.id&&R.revision===dr.revision)return;let re=!1;return P8(dr.id).then(mt=>{re||(B(mt.task),ke(null))}).catch(mt=>{re||ke(mt instanceof Error?mt.message:"任务详情加载失败")}),()=>{re=!0}},[r,dr?.id,dr?.revision,R?.id,R?.revision,Pe]);const Gr=async()=>{if(!Gt.current){Gt.current=!0;try{const re=await Sy(e.id);et.current&&(L(re.tasks),ne(!0),ke(null),Ne(mt=>mt+1))}catch(re){et.current&&ke(re instanceof Error?re.message:"任务加载失败")}finally{Gt.current=!1}}};b.useEffect(()=>{if(!r)return;Gr();const re=()=>{!document.hidden&&navigator.onLine!==!1&&Gr()},mt=setInterval(re,2500);return document.addEventListener("visibilitychange",re),window.addEventListener(sf,re),window.addEventListener("pageshow",re),()=>{clearInterval(mt),document.removeEventListener("visibilitychange",re),window.removeEventListener(sf,re),window.removeEventListener("pageshow",re)}},[r,e.id]);const ot=re=>{const mt=JSON.stringify(re),Mt=go(`${v}:request`,null);let rr=St.current.get(mt)??(Mt?.fingerprint===mt?Mt.key:void 0);return rr||(rr=crypto.randomUUID(),St.current.set(mt,rr)),Fi(`${v}:request`,{fingerprint:mt,key:rr}),rr},pt=re=>{St.current.delete(JSON.stringify(re)),Fi(`${v}:request`,null)},ir=async(re,mt)=>{if(nt||Ye.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};Ye.current=!0,gt(!0),We(null),Ge("");let Mt={...mt,expectedRevision:re.revision};if(["comment","revise"].includes(mt.kind)){const rr=go(`${v}:request`,null);try{const[Ar,Fr]=JSON.parse(rr?.fingerprint??"null"),{expectedRevision:Xt,...Zr}=Fr;Ar===re.id&&JSON.stringify(Zr)===JSON.stringify(mt)&&(Mt=Fr)}catch{}}try{const rr=await $8(re.id,{...Mt,idempotencyKey:ot([re.id,Mt])});if(pt([re.id,Mt]),Lu.getState().refresh(),et.current){const Ar=E.current.find(Jt=>Jt.id===rr.task.id),Fr=Ar&&Ar.revision>rr.task.revision?Ar:rr.task;L(Jt=>Jt.map(Pr=>Pr.id===rr.task.id&&Pr.revision<=rr.task.revision?rr.task:Pr)),B(Jt=>Jt?.id===rr.task.id&&Jt.revision>rr.task.revision?Jt:rr.task);const Xt=V6(Fr,E.current),Zr=`${mt.kind==="answer"?"回答已保存":"方案确认已保存"},${Xt?Xt.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;Ge(["comment","revise"].includes(mt.kind)?"":mt.kind==="retry"?vO(re,rr.task):["answer","approve-plan"].includes(mt.kind)?Zr:mt.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(rr){const Ar=rr instanceof Error?rr.message:"操作失败";return Ar.includes("任务已更新")&&pt([re.id,Mt]),et.current&&(We(["comment","revise"].includes(mt.kind)?null:Ar),Gr()),{ok:!1,error:Ar}}finally{Ye.current=!1,et.current&&gt(!1)}},Mn=async re=>{if(re.preventDefault(),nt||ue>0||(Z.mode==="goal"?!pn:!Z.title.trim()||!Z.spec.trim())||Ye.current)return;Ye.current=!0,gt(!0),We(null);const mt=Z.mode==="goal",Mt={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:mt?void 0:Z.assignee||void 0,coordinatorSessionId:mt?It:Z.coordinator||void 0,parentTaskId:mt?void 0:Z.parent||void 0,dependsOn:mt?[]:Z.dependencies,managed:mt,isolated:Z.isolated,reviewerSessionIds:mt?xe:void 0};try{if(mt&&(fr||Yt)){ut(!0);const Ar=zt?go(`${v}:team-request`,"")||crypto.randomUUID():void 0;Ar&&Fi(`${v}:team-request`,Ar);const Fr=Yt??await O8(e.id,{agentSlug:xt,...De?{launchProfileId:De}:e.launchProfiles?.length?{launchProfileId:""}:{},cwd:Rt.trim(),...zt?{coordinatorSessionId:null,coordinatorCreationKey:Ar}:It?{coordinatorSessionId:It}:{}});ut(!1),Sr(Fr),Mt.coordinatorSessionId=Fr.coordinatorSessionId,Mt.reviewerSessionIds=Fr.reviewerSessionIds,Fi(`${v}:agent`,qt),Fi(`${v}:cwd`,Rt.trim()),Fi(`${v}:launch-profile`,De)}const{task:rr}=await F8({...Mt,idempotencyKey:ot(Mt)});pt(Mt),et.current&&(L(Ar=>[rr,...Ar.filter(Fr=>Fr.id!==rr.id)]),le(rr.id),be(!0),B(rr),mt&&Fi(`${v}:lead`,Mt.coordinatorSessionId),Fi(`${v}:team-request`,null),Sr(null),w?.(),ee(t0),pe(!1),H("open"),Ae(""),Ge(mt?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(rr){et.current&&We(rr instanceof Error?rr.message:"创建失败")}finally{Ye.current=!1,et.current&&(gt(!1),ut(!1))}},Xr=(re,mt)=>{if(!mt)return"用户";const Mt=re.memberSessions[Ou(mt)];return wt.find(rr=>rr.sessionId===Mt)?.name??t.find(rr=>rr.sessionId===Mt)?.name??"暂不可用的成员"},je=S.filter(re=>(Ce==="all"?!0:Ce==="archive"?re.status!=="open":re.status==="open")&&(Ce==="all"||Ce==="attention"||re.workflow?.kind!=="step")&&(Ce!=="attention"||Ui(re))&&(!ae.trim()||`${re.title} ${re.spec} ${re.attempts.map(mt=>Xr(re,mt.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase()))),st=S.filter(Ui).length;b.useEffect(()=>{a?.(st)},[st,a]);const bt=!!dr&&(l?$:_e||$),Br=()=>{pe(!1),requestAnimationFrame(()=>we.current?.focus())},Vr=re=>{Rl.getState().updateDetail(`${v}:${re}`,"view","overview"),le(re),be(!0),Ge("")},Cr=S.filter(Ui).filter(re=>!ae.trim()||`${re.title} ${re.spec} ${re.attempts.map(mt=>Xr(re,mt.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase())),qr=(re,mt=!1)=>{const Mt=re.attempts.find(Jt=>Jt.id===re.activeAttemptId),rr=re.children?.filter(Jt=>Jt.status==="accepted").length??0,Ar=re.children?.filter(Jt=>Jt.status!=="closed").length??0,Fr=Jf(re),Xt=Fr.length>1?Fr.find(Jt=>Jt.source!=="member"):null,Zr=(mt?re.decisions.find(Jt=>Jt.status==="pending")?.question:"")||Fr[0]?.summary||Mt?.report?.summary||Mt?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":O===re.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 ${O===re.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>Vr(re.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${mt||re.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:mt?s.jsx(Xu,{size:16}):re.status==="accepted"?s.jsx(zu,{size:16}):s.jsx(Hu,{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:re.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${mt?"text-primary":"text-muted-foreground"}`,children:Kc(re)}),Zr&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:Zr}),Xt&&s.jsxs("span",{className:`mt-1 block line-clamp-2 break-words text-xs leading-5 ${Xt.source==="system"?"text-destructive":"text-muted-foreground"}`,children:[Xt.label,":",Xt.summary]}),Ar>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:(re.children??[]).filter(Jt=>Jt.status!=="closed").slice(0,8).map(Jt=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${Jt.status==="accepted"?"bg-primary":"bg-border/30"}`},Jt.id))}),rr,"/",Ar," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"block truncate",children:Mt?Xr(re,Mt.assignee):"尚未分派"}),s.jsx(Df,{task:re})]})]}),s.jsx(Ks,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},re.id)},mn=[],on=new Set([O]);let zr=dr?.parentTaskId;for(;zr&&!on.has(zr);){on.add(zr);const re=S.find(mt=>mt.id===zr);if(!re)break;mn.unshift(re),zr=re.parentTaskId}const un=()=>{const re=Array.from(qe.current?.querySelectorAll("button[data-task-id]")??[]).find(mt=>mt.dataset.taskId===O);be(!1),requestAnimationFrame(()=>{re&&!re.closest("[hidden]")?re.focus():we.current?.focus()})},Er=V||!l&&Be&&S.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&&(Er||!Be)&&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:p})]}),(oe||Fe&&Ee==="ready"&&!af(Fe))&&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:[oe||Fe,!oe&&Be?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:ca,onClick:()=>oe?We(null):void Gr(),children:[s.jsx(bn,{size:14}),oe?"关闭提示":"重试"]})]}),Fe&&af(Fe)&&!l&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"正在恢复任务同步,现有记录和草稿已保留"}),Ie&&s.jsx("p",{role:"status",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-primary",children:Ie}),Er?s.jsxs("form",{onSubmit:re=>{Mn(re)},className:`mx-auto w-full max-w-xl space-y-4 ${l?"overflow-auto px-1 py-5":""}`,onKeyDown:re=>{re.key==="Escape"&&V&&!re.defaultPrevented&&!re.nativeEvent.isComposing&&j1(re.currentTarget)&&(re.preventDefault(),re.stopPropagation(),nt||Br())},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"?"交给协调者拆分,你在这里看交付、回答问题。":"选择负责人,保留分派和验收记录。"})]}),(S.length>0||l)&&s.jsx("button",{type:"button","aria-label":"取消创建,保留草稿",className:`${ca} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:nt,onClick:Br,children:s.jsx(In,{size:16})})]}),Z.mode==="task"&&s.jsx(mo,{label:"任务标题",children:s.jsx("input",{className:Ps,required:!0,maxLength:200,value:Z.title,onChange:re=>ee(mt=>({...mt,title:re.target.value})),placeholder:"要完成什么?"})}),s.jsx(Jh,{paneKey:m,inputKey:`${v}:spec`,active:r&&Er,label:Z.mode==="goal"?"协作目标":"目标与交付要求",className:`${Ps} ${fr&&Z.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:V,required:!0,disabled:nt,value:Z.spec,onUploadChange:at,onChange:re=>ee(mt=>({...mt,spec:typeof re=="function"?re(mt.spec):re})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),Z.mode==="goal"&&Yt&&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:ai,disabled:nt,onClick:()=>{w?.(),c()},children:"查看已准备的成员"})]}),Z.mode==="goal"&&s.jsxs(mo,{label:"协调者",children:[s.jsxs("select",{"aria-label":"协调者",className:Ps,disabled:nt||!!Yt,value:Z.coordinator,onChange:re=>{Fi(`${v}:team-request`,null),ee(mt=>({...mt,coordinator:re.target.value}))},children:[s.jsx("option",{value:"",children:"自动选择(优先复用组内 Agent)"}),s.jsx("option",{value:_b,disabled:!!e.federated,children:"新建协调者"}),Ot&&s.jsx("option",{value:Z.coordinator,disabled:!0,children:"原协调者已不可用,请重新选择"}),wt.map(re=>s.jsxs("option",{value:re.sessionId,disabled:!re.agent,children:[re.name,re.agent?` · ${re.agent.displayName}`:"(需要启动 Agent)"]},re.sessionId))]}),Ot&&!Yt&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"所选协调者已离组或未运行 Agent,请重新选择。"})]}),Z.mode==="goal"&&(fr||Yt)?s.jsxs("fieldset",{disabled:nt||!!Yt,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:Yt?"已用于准备成员的配置":"首次开始时配置 Agent"}),(!!e.launchProfiles?.length||!!De)&&s.jsxs(mo,{label:"启动方案",children:[s.jsxs("select",{"aria-label":"协作启动方案",className:Ps,value:De,onChange:re=>nr(re.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(re=>s.jsxs("option",{value:re.id,children:[re.name," · ",x.find(mt=>mt.slug===re.agentSlug)?.displayName??re.agentSlug]},re.id))]}),Ke&&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:Ke.notes||"查看启动命令与使用备注"})}),s.jsx("p",{"aria-label":"完整使用备注",className:"whitespace-pre-wrap break-words",children:Ke.notes}),s.jsx("code",{className:"mt-1 block break-all",children:Ke.command})]}),De&&!Ke&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]}),!Ke&&s.jsx(mo,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Ps,disabled:!!Ke,value:xt,onChange:re=>tt(re.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(re=>s.jsx("option",{value:re.slug,children:re.displayName},re.slug))]})}),s.jsxs(mo,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Ps} min-w-0 flex-1`,value:Rt,onChange:re=>Ct(re.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:ai,onClick:()=>ht(!0),children:"浏览目录"})]}),Ve&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(SO,{open:!0,initialPath:Rt.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>ht(!1),onConfirm:re=>{Ct(re),ht(!1)}})})]}),!Yt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:zt?"开始时新建协调者,并补齐执行/评审成员。":"保留所选协调者,开始时补齐执行/评审成员;自动选择会优先复用组内 Agent。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",c&&s.jsx("button",{type:"button",className:ai,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:ai,onClick:c,children:"管理成员"})]})]}):Z.mode==="task"&&s.jsx(mo,{label:"分派给",children:s.jsxs("select",{className:Ps,value:Z.assignee,onChange:re=>ee(mt=>({...mt,assignee:re.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),wt.map(re=>s.jsx("option",{value:re.sessionId,children:re.name},re.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:[s.jsx(mo,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Ps} min-h-20 resize-y`,value:Z.acceptance,onChange:re=>ee(mt=>({...mt,acceptance:re.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(mo,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Ps} min-h-20 resize-y`,value:Z.constraints,onChange:re=>ee(mt=>({...mt,constraints:re.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:re=>ee(mt=>({...mt,isolated:re.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(mo,{label:"协调者",children:s.jsxs("select",{className:Ps,value:Z.coordinator,onChange:re=>ee(mt=>({...mt,coordinator:re.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),wt.map(re=>s.jsx("option",{value:re.sessionId,children:re.name},re.sessionId))]})}),s.jsx(mo,{label:"父任务",children:s.jsxs("select",{className:Ps,value:Z.parent,onChange:re=>ee(mt=>({...mt,parent:re.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),S.filter(re=>!re.workflow).map(re=>s.jsx("option",{value:re.id,children:re.title},re.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),S.filter(re=>re.status!=="closed").map(re=>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(re.id),onChange:mt=>ee(Mt=>({...Mt,dependencies:mt.target.checked?[...Mt.dependencies,re.id]:Mt.dependencies.filter(rr=>rr!==re.id)}))}),re.title]},re.id))]})]}),s.jsx("button",{type:"button",className:`${ca} text-muted-foreground hover:bg-surface-2`,onClick:()=>ee(re=>({...re,mode:re.mode==="goal"?"task":"goal"})),children:Z.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${cl} w-full`,disabled:nt||ue>0||(Z.mode==="goal"?!pn:!Z.title.trim()||!Z.spec.trim()),children:[nt?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(i0,{size:14}),nt?q?"正在准备成员…":"提交中…":Z.mode==="goal"?Yt?"重试提交目标":"开始协作":Z.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:Z.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):l&&Be?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:bt,className:`${bt?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(TO,{navigation:d,settings:p,action:s.jsxs("button",{ref:Le,type:"button",className:cl,disabled:nt,onClick:()=>pe(!0),children:[s.jsx(zs,{size:14}),"新目标"]}),storage:v,tasks:S,selectedId:bt?O:null,name:Xr,onSelect:Vr})}),bt&&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:`${ca} px-2 hover:bg-surface-2`,onClick:un,children:"看板"})}),mn.map(re=>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":`查看${re.workflow?.kind==="goal"?"目标":"父任务"}:${re.title}`,title:`查看${re.workflow?.kind==="goal"?"目标":"父任务"}:${re.title}`,className:`${ca} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>Vr(re.id),children:s.jsxs("span",{className:"truncate",children:[re.workflow?.kind==="goal"?"目标":"父任务",":",re.title]})})]},re.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:dr?.parentTaskId?"子任务详情":dr?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:me?s.jsx(kb,{reader:!0,paneKey:m,active:r,task:me,tasks:S,members:wt,busy:nt,name:re=>Xr(me,re),act:re=>ir(me,re),storage:v,onSelectTask:Vr,onOpenSession:async re=>{const mt=t.find(Mt=>Mt.sessionId===me.memberSessions[Ou(re)]);if(!mt){We("成员会话暂不可用,任务历史已保留。");return}try{await n(mt)}catch(Mt){We(Mt instanceof Error?Mt.message:"无法打开终端")}}},me.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!Be&&!S.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:Fe?"任务暂时无法加载,请重试。":"正在加载目标…"}),!Fe&&[0,1,2].map(re=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},re))]}):s.jsxs(s.Fragment,{children:[(!bt||_e)&&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:[S.filter(re=>re.status==="open"&&re.workflow?.kind!=="step").length," 个进行中 · ",S.filter(re=>re.status==="accepted"&&re.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:Le,type:"button",className:cl,disabled:nt,onClick:()=>pe(!0),children:[s.jsx(zs,{size:14}),"新目标"]})]}),s.jsxs("div",{className:_e&&bt?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!bt||_e)&&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:`${Ps} min-w-0 flex-1 border-transparent bg-transparent`,value:Ce,onChange:re=>H(re.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",st,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":Y,className:`${ca} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{ce(re=>!re),Ae("")},children:s.jsx(jl,{size:16})})]}),Y&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Ps,value:ae,onChange:re=>Ae(re.target.value),placeholder:"搜索目标、内容或负责人"}),Ce==="open"&&Cr.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:Cr.length})]}),Cr.map(re=>qr(re,!0))]}),(Ce!=="open"||je.some(re=>!Ui(re))||je.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:Ce==="attention"?"需要你处理":Ce==="archive"?"已归档":Ce==="all"?"全部任务":"当前目标"}),je.filter(re=>Ce!=="open"||!Ui(re)).map(re=>qr(re,Ce==="attention")),!je.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[ae.trim()?"没有匹配的任务。":Ce==="attention"?"目前没有需要你处理的任务。":Ce==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(Ce!=="all"||ae)&&s.jsx("button",{type:"button",className:`${ca} mt-2 text-primary`,onClick:()=>{H("all"),Ae("")},children:"查看全部任务"})]})]})]}),bt&&s.jsxs("div",{className:"min-w-0",children:[!_e&&s.jsxs("button",{type:"button",className:`${ca} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>be(!1),children:[s.jsx(Iy,{size:14}),"全部目标"]}),me?s.jsx(kb,{paneKey:m,active:r,task:me,tasks:S,members:wt,busy:nt,name:re=>Xr(me,re),act:re=>ir(me,re),storage:v,onSelectTask:Vr,onOpenSession:async re=>{const mt=t.find(Mt=>Mt.sessionId===me.memberSessions[Ou(re)]);if(!mt){We("成员会话暂不可用,任务历史已保留。");return}try{await n(mt)}catch(Mt){We(Mt instanceof Error?Mt.message:"无法打开终端")}}},me.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function mo({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:p,storage:m,onOpenSession:x,onSelectTask:y}){const[w,v]=b.useState(""),[S,L]=b.useState(""),[E,R]=b.useState(""),[B,z]=b.useState(!1),[O,$]=b.useState(null),V=b.useRef(!1),Z=b.useRef(!0);b.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const le=b.useRef(null),be=b.useRef(null);b.useEffect(()=>{!e&&O&&O.state!=="pending"&&t&&requestAnimationFrame(()=>be.current?.scrollIntoView({block:"nearest"}))},[O]);const pe=b.useRef(null),[ee,_e]=b.useState(0),ze=q=>_e(ut=>Math.max(0,ut+q)),Y=b.useRef(null);b.useEffect(()=>{Y.current?.focus()},[]);const ce=`${m}:${n.id}`,[qe]=b.useState(()=>Rl.getState().ensureDetail(ce,{feedback:go(`${ce}:feedback`,""),answers:go(`${ce}:answers`,{}),view:"overview"})),{feedback:we,answers:ye,view:Le}=Rl(q=>q.details[ce]??qe),Be=Sm(ce,"feedback"),ne=Sm(ce,"answers"),Fe=Sm(ce,"view");b.useEffect(()=>{pe.current&&(pe.current.scrollTop=0)},[Le]),b.useEffect(()=>Fi(`${m}:${n.id}:answers`,ye),[m,n.id,ye]),b.useEffect(()=>Fi(`${m}:${n.id}:feedback`,we),[m,n.id,we]);const ke=n.attempts.find(q=>q.id===n.activeAttemptId),Ee=n.status==="open",Pe=V6(n,a),Ne=n.artifacts.filter(q=>q.kind==="result"&&q.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{O?.state==="saved"&&Ne?.id!==O.resultId&&$(null)},[Ne?.id,O]);const oe=n.artifacts.filter(q=>q.kind==="plan"&&q.attemptId===n.activeAttemptId).at(-1),We=n.events.filter(q=>q.kind==="revise"&&q.source==="user"&&q.attemptId===n.activeAttemptId).at(-1),nt=Ne&&n.events.some(q=>q.kind==="revise"&&q.attemptId===n.activeAttemptId&&q.createdAt>=Ne.createdAt),gt=e&&Ee&&!!nt,ue=O?.state==="saved"&&O.kind==="revise"&&O.resultId===Ne?.id,Ze=n.decisions.filter(q=>q.status==="pending"&&q.attemptId===n.activeAttemptId),at=n.dependsOn.some(q=>a.find(ut=>ut.id===q)?.status!=="accepted"),Ie=!n.workflow||n.artifacts.filter(q=>q.kind==="review"&&q.reviewsArtifactId===Ne?.id).at(-1)?.verdict==="pass",Ge=n.children??[],Ce=n.workflow?.kind==="goal"&&Ge.some(q=>!["accepted","closed"].includes(q.status)),H=`任务:${n.title}
141
+ 任务 ID:${n.id}
142
+ ${n.spec}
143
+ 约束:${n.constraints||"未补充"}
144
+ 验收标准:${n.acceptance||"由用户决定"}
145
+ ${ke?`当前尝试:${ke.id}
146
+ 负责人:${l(ke.assignee)}
147
+ `:""}${n.artifacts.filter(q=>q.attemptId===n.activeAttemptId).map(q=>`${q.kind} · 版本 ${q.id} · ${Sa(q.createdAt)}
148
+ ${q.summary?`结果摘要:${q.summary}
149
+ `:""}${q.content}`).join(`
150
+
151
+ `)}
152
+ ${Ze.map(q=>`待回答:${q.question}`).join(`
153
+ `)}`,ae=()=>{const q=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),ut=document.createElement("a");ut.href=q,ut.download=`termdock-task-${n.id}.json`,ut.click(),setTimeout(()=>URL.revokeObjectURL(q),1e3)},Ae=n.events.filter(q=>q.kind==="coordinate"&&(!q.attemptId||q.attemptId===n.activeAttemptId)).at(-1),Ye=Le==="results"?n.artifacts.slice().reverse():n.artifacts.filter(q=>q.id===Ne?.id||q.id===oe?.id&&n.approvedPlanArtifactId!==q.id||q.kind==="review"&&q.reviewsArtifactId===Ne?.id).sort((q,ut)=>(q.kind==="result"?-1:1)-(ut.kind==="result"?-1:1)||ut.createdAt-q.createdAt),et=Ge.filter(q=>q.status==="accepted").length,St=Ge.filter(q=>q.status!=="closed"),Gt=St.filter(q=>q.status!=="accepted"),Qt=Ae&&(!We||Ae.createdAt>=We.createdAt)?Ae:void 0,wt=ke?.report&&(!We||ke.report.createdAt>=We.createdAt)?ke.report:void 0,zt=nt?"等待新结果通过评审后可验收。":Ze.length?"回答当前问题后可验收。":at?"依赖任务验收后可验收。":Ie?Ce?"子任务完成并通过评审后可验收。":null:"独立评审通过后可验收。",Vt=()=>{Fe("overview"),z(!0),requestAnimationFrame(()=>{le.current?.scrollIntoView({block:"nearest"}),le.current?.querySelector("textarea")?.focus()})},Kt=Jf(n),Ot=Kt[0],It=Kt.some(q=>q.source==="member"),xe=async q=>{if(d||ee||!we.trim()||V.current)return;const ut=we;V.current=!0,$({kind:q,state:"pending",content:ut,resultId:Ne?.id});const qt=await p({kind:q,content:ut});if(V.current=!1,qt.ok){if(Be(tt=>tt===ut?"":tt),Fi(`${ce}:feedback`,Rl.getState().details[ce]?.feedback??""),!Z.current)return;$({kind:q,state:"saved",content:ut,resultId:Ne?.id}),e&&Rl.getState().details[ce]?.feedback===""&&z(!1)}else Z.current&&$({kind:q,state:"error",content:ut,error:qt.error,resultId:Ne?.id})},Ve=q=>s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:q}),children:s.jsx(CO,{content:q})}),ht=q=>{const ut=W6(q.content,q.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:q.kind==="result"?nt&&q.id===Ne?.id?"上一版结果":"交付结果":q.kind==="plan"?n.approvedPlanArtifactId===q.id?"已确认的方案":"方案":"独立评审"}),q.verdict&&s.jsx("span",{className:`rounded-md px-2 py-1 text-[11px] ${q.verdict==="pass"?"bg-primary/10 text-primary":"bg-surface-2 text-foreground"}`,children:q.verdict==="pass"?"通过":q.verdict==="changes"?"需要修改":"受阻"}),n.acceptedArtifactId===q.id&&s.jsx("span",{className:"text-xs text-primary",children:n.completionMode==="reviewed"?"评审通过":"已验收"}),n.approvedPlanArtifactId===q.id&&s.jsx("span",{className:"text-xs text-primary",children:"方案已确认"})]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[l(q.actor)," · ",Sa(q.createdAt),q.attemptId!==n.activeAttemptId&&q.kind!=="review"?" · 历史分派":""]}),q.kind==="result"&&ut.condensed?s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-label":"结果结论",className:"text-base leading-7",children:Ve(!ut.explicit&&!ut.summary.includes(`
154
+ `)?ut.summary.replace(/([。;])\s*(?=\S)/g,`$1
155
+
156
+ `):ut.summary)}),ut.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:"适用范围与限制"}),Ve(ut.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:Ve(q.content)})]})]}):Ve(q.content),q.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(q.evidence,null,2)})]}),Ee&&q.attemptId===n.activeAttemptId&&q.kind!=="review"&&(!e||q.kind==="plan"||!n.workflow)&&s.jsxs("div",{className:"space-y-2 border-t border-border/15 pt-3",children:[!e&&Ne?.id===q.id&&n.workflow?.kind!=="step"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`${cl} w-full`,disabled:d||!!zt,onClick:()=>{p({kind:"accept",artifactId:q.id})},children:[s.jsx(pi,{size:14}),"验收此结果"]}),zt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:zt})]}),oe?.id===q.id&&n.approvedPlanArtifactId!==q.id&&s.jsxs("button",{type:"button",className:`${cl} w-full`,disabled:d,onClick:()=>{p({kind:"approve-plan",artifactId:q.id})},children:[s.jsx(pi,{size:14}),Pe?"确认方案":"确认方案并继续"]}),!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:Ps,value:S,onChange:qt=>L(qt.target.value),children:[s.jsx("option",{value:"",children:"选择独立评审成员"}),c.filter(qt=>qt.sessionId!==n.memberSessions[Ou(q.actor)]).map(qt=>s.jsx("option",{value:qt.sessionId,children:qt.name},qt.sessionId))]}),s.jsx("button",{type:"button",className:ai,disabled:d||!S||S===n.memberSessions[Ou(q.actor)],onClick:()=>{p({kind:"request-review",artifactId:q.id,assigneeSessionId:S})},children:"请求评审"})]})]})]})]},q.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:`${ca} -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(q=>q.id===n.parentTaskId)?.title??"查看父任务"]}),s.jsx($m,{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:Y,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 ${Ui(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"}),Kc(n)]})]}),!Ze.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)}`:ke?`负责人 · ${l(ke.assignee)}`:"尚未分派"}),ke&&s.jsxs("button",{type:"button",className:`${ca} px-2 text-muted-foreground hover:bg-surface-2 hover:text-primary`,onClick:()=>{x(ke.assignee)},children:[s.jsx(Fc,{size:13}),"打开终端"]})]}),!e&&s.jsx(Df,{task:n}),n.replica&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"此记录由来源服务同步,回答与决定会送回来源服务。"})]}),Pe&&Ee&&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:Pe.workflow?.kind==="goal"?"目标仍暂停。回答和方案确认会保存,恢复目标后才能投递;已投递的终端工作继续保留。":"任务仍暂停。回答和方案确认会保存,继续安排后才能投递;已投递的终端工作继续保留。"}),Pe.id!==n.id&&s.jsx("button",{type:"button",className:ai,onClick:()=>y(Pe.id),children:"查看目标并恢复安排"})]}),s.jsx("nav",{"aria-label":"任务详情",className:"flex gap-4 border-b border-border/20",children:[["overview",gt?"进展":e&&Ne?"结果":"概览"],["results",e?"历史交付":`交付${n.artifacts.length?` ${n.artifacts.length}`:""}`],["activity","动态"]].map(([q,ut])=>s.jsx("button",{type:"button","aria-pressed":Le===q,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 ${Le===q?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,onClick:()=>Fe(q),children:ut},q))}),Le==="overview"&&s.jsxs(s.Fragment,{children:[(()=>{const q=We;if(!q)return null;const ut=n.deliveries.find(De=>De.id===q.deliveryId),qt=n.outbox.find(De=>De.id===q.deliveryId),tt=Ne&&Ne.createdAt>q.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:gt?"本次跟进要求":tt?Ie?"新结果已通过独立评审":"新结果已交付,等待独立评审":"已要求继续跟进,等待新结果"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:q.content}),s.jsxs("p",{className:"text-muted-foreground",children:[Sa(q.createdAt),ut?.status==="delivered"?e?" · 已写入成员终端":` · 已写入${q.target?l(q.target):"成员"}终端${ut.deliveredAt?` · ${Sa(ut.deliveredAt)}`:""}`:["failed","expired"].includes(ut?.status??"")||ut?.error||qt?.lastError?" · 投递未成功,服务端继续重试":q.deliveryId?" · 等待写入终端":" · 要求已保存"]})]})})(),Ze.map(q=>s.jsxs("form",{className:"space-y-3 rounded-xl border border-border/30 bg-surface-2/40 p-4",onSubmit:ut=>{ut.preventDefault(),!d&&!ee&&ye[q.id]?.trim()&&p({kind:"answer",decisionId:q.id,content:ye[q.id]})},children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-primary",children:[s.jsx(Xu,{size:14}),"需要你的决定"]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:q.question}),!!q.options.length&&s.jsx("div",{className:"flex flex-col gap-2",children:q.options.map((ut,qt)=>s.jsxs("button",{type:"button","aria-pressed":ye[q.id]===ut,disabled:d,className:`${ca} justify-start text-left ${ye[q.id]===ut?"bg-primary/15 text-primary":"bg-surface-2 text-foreground"}`,onClick:()=>ne(tt=>({...tt,[q.id]:ut})),children:[ye[q.id]===ut?s.jsx(pi,{size:14,className:"shrink-0"}):s.jsx(Hu,{size:14,className:"shrink-0"}),s.jsx("span",{className:"break-words",children:ut})]},qt))}),s.jsx(Jh,{paneKey:r,inputKey:`${ce}:answer:${q.id}`,active:t,label:"你的回答",className:`${Ps} min-h-20 resize-y`,required:!0,disabled:d,value:ye[q.id]??"",onUploadChange:ze,onChange:ut=>ne(qt=>({...qt,[q.id]:typeof ut=="function"?ut(qt[q.id]??""):ut})),placeholder:"选择建议,或写下你的决定…"}),s.jsxs("button",{className:`${cl} w-full`,disabled:d||ee>0||!ye[q.id]?.trim(),children:[s.jsx(i0,{size:14}),Pe?"保存回答":"回复并继续"]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[Sa(q.createdAt)," · 回答会保存在任务记录中"]})]},q.id)),Kt.map(q=>s.jsxs("section",{"aria-label":q.source==="member"?"成员阻塞报告":q.source==="unknown"?"待核对服务记录":"服务异常",role:q.source==="system"?"alert":"status",className:`space-y-3 rounded-xl p-4 ${q.source==="member"?"bg-primary/10":q.source==="unknown"?"bg-surface-2":"bg-destructive/10"}`,children:[s.jsx("h4",{className:`text-sm font-medium ${q.source==="member"?"text-primary":q.source==="unknown"?"text-muted-foreground":"text-destructive"}`,children:q.label}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:q.summary}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:q.source==="member"?`负责人:${l(ke?.assignee??null)}。先补齐报告中缺少的条件,再发送说明;需要登录时,请在对应服务完成授权。`:q.source==="unknown"?"此摘要未提供原报告正文和记录来源,请打开完整详情核对;确认前不提供服务异常重试。":"重试只请求服务重新检查现有投递与协调条件,保留原报告和执行尝试;成员新的明确回复才会更新报告。"}),q.source==="member"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:ai,disabled:d,onClick:Vt,children:"补充条件并通知成员"}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整阻塞报告"}),q.content?Ve(q.content):s.jsx("p",{className:"text-xs text-muted-foreground",children:"原始报告正文未提供。"})]})]}):q.source==="system"?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:ai,disabled:d||!n.workflow,onClick:()=>{p({kind:"retry"})},children:[s.jsx(bn,{size:13}),n.outbox.length?"重试现有投递":q.content.startsWith("消息投递")?"重新检查投递记录":"重新检查自动安排"]}),!n.workflow&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"此任务未启用自动安排,请检查投递记录或成员终端。"})]}):null]},q.source)),n.workflow?.paused&&Ee&&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:ai,disabled:d,onClick:()=>{p({kind:"resume"})},children:"继续安排"})]}),gt&&Ye.filter(q=>q.kind==="plan").map(ht),gt&&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:Gt.length?`${Gt.length} 项执行尚未完成交付与评审`:"收到新的交付结果后,会在这里展示供你验收。"})]}),!!Gt.length&&s.jsx("ul",{className:"space-y-1",children:Gt.map(q=>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(q.id),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:q.title}),s.jsx(Ks,{size:14,className:"shrink-0"})]})},q.id))}),Qt||wt?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:Qt?"协调者最近的更新":"成员最近的报告"}),s.jsx("span",{className:"ml-auto shrink-0",children:Sa((Qt??wt).createdAt)})]}),s.jsx("div",{className:"pb-3",children:Ve((Qt??wt).content)})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到这次跟进后的明确更新。"})]}),gt?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:Sa(Ne.createdAt)})]}),s.jsx("div",{className:"space-y-3 pb-3",children:Ye.filter(q=>q.kind!=="plan").map(ht)})]}):s.jsx(s.Fragment,{children:Ye.map(q=>q.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:["独立评审 · ",q.verdict==="pass"?"通过":q.verdict==="changes"?"要求修改":"受阻"," · ",l(q.actor)]}),ht(q)]},q.id):ht(q))}),Ae&&!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:Sa(Ae.createdAt)})]}),s.jsx("div",{className:"rounded-xl bg-surface-2/50 p-3",children:Ve(Ae.content)})]}),!Ot&&!Ae&&ke?.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:Sa(ke.report.createdAt)})]}),Ve(ke.report.content)]}),!!Ge.length&&s.jsxs("details",{className:"space-y-3",open:Ge.some(q=>{const ut=a.find(qt=>qt.id===q.id);return ut&&Ui(ut)})||void 0,children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:["执行过程",s.jsxs("span",{className:"ml-3 text-[11px] font-normal text-muted-foreground",children:[et,"/",St.length," 项交付已评审"]})]}),s.jsx("div",{className:"divide-y divide-border/15",children:Ge.map(q=>{const ut=a.find(tt=>tt.id===q.id),qt=ut&&Ui(ut);return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-3 rounded-lg px-1 py-3 text-left transition hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>y(q.id),children:[q.status==="accepted"?s.jsx(zu,{size:16,className:"mt-0.5 shrink-0 text-primary"}):s.jsx(Hu,{size:16,className:"mt-0.5 shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm leading-5 text-foreground",children:q.title}),s.jsx("span",{className:`mt-1 block text-[11px] ${qt?"text-primary":"text-muted-foreground"}`,children:ut?Kc(ut):q.status==="accepted"?q.completionMode==="reviewed"?"独立评审通过":"已验收":q.status==="closed"?"已关闭":"等待报告"})]}),s.jsx(Ks,{size:14,className:"mt-1 shrink-0 text-muted-foreground"})]},q.id)})})]}),!!n.dependsOn.length&&s.jsxs("section",{children:[s.jsx("h4",{className:"mb-2 text-xs font-medium text-foreground",children:"依赖任务"}),n.dependsOn.map(q=>s.jsxs("button",{type:"button",className:`${ca} w-full justify-start text-left text-muted-foreground hover:bg-surface-2`,onClick:()=>y(q),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:a.find(ut=>ut.id===q)?.title??q}),s.jsx("span",{className:"shrink-0 text-[11px]",children:a.find(ut=>ut.id===q)?.status==="accepted"?"已验收":"待验收"})]},q))]}),Ee&&!ke&&!n.scheduledAssignee&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2/50 p-4",children:[s.jsx(mo,{label:"分派给",children:s.jsxs("select",{className:Ps,value:w,onChange:q=>v(q.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(q=>s.jsx("option",{value:q.sessionId,children:q.name},q.sessionId))]})}),s.jsx("button",{type:"button",className:`${cl} w-full`,disabled:d||!w||at,onClick:()=>{p({kind:"assign",assigneeSessionId:w})},children:"分派任务"}),at&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"依赖任务验收后可分派。"})]}),!Ot&&!Ze.length&&!Ae&&!ke?.report&&!Ye.length&&!Ge.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:Ee?"等待第一条更新":"任务记录已保留"}),s.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:Ee?"成员明确回复后,报告、问题和交付会出现在这里。":"可在动态中查看分派与决定。"})]})]}),Le==="results"&&s.jsx("div",{className:"space-y-4",children:Ye.length?Ye.map(ht):s.jsx("p",{className:"py-8 text-center text-xs leading-5 text-muted-foreground",children:"还没有交付。方案、结果和独立评审会保存在这里。"})}),Le==="activity"&&s.jsxs("section",{"aria-label":"任务动态",children:[s.jsx("ol",{className:"space-y-5",children:n.events.slice().reverse().map(q=>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:[_O[q.kind]??q.kind,q.reportStatus?` · ${Nf[q.reportStatus]}`:""]}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[q.source==="system"?"服务自动接续":q.source==="integration"?`外部接入 ${q.origin?.integrationId??""}`:l(q.actor)," · ",Sa(q.createdAt),q.attemptId&&q.attemptId!==n.activeAttemptId?" · 历史分派":""]}),s.jsx("div",{className:"mt-2",children:Ve(q.content)}),q.target&&s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["接收人:",l(q.target)]})]},q.id))}),!n.events.length&&s.jsx("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"还没有动态记录。"})]}),Ee&&Le!=="activity"&&(!e||!Ne)&&s.jsxs("section",{ref:le,className:"space-y-2 border-t border-border/20 pt-4",children:[s.jsx(Jh,{paneKey:r,inputKey:`${ce}:feedback`,active:t,label:It?"补充处理说明":"补充说明或修改要求",className:`${Ps} min-h-20 resize-y text-sm leading-6`,disabled:d,value:we,onUploadChange:ze,onChange:Be,placeholder:It?"说明已补齐的条件,或调整本次检查范围…":"补充上下文,或写下需要修改的地方…"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",className:ai,disabled:d||ee>0||!we.trim(),onClick:()=>{xe("comment")},children:[O?.state==="pending"&&O.kind==="comment"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(i0,{size:13}),O?.state==="pending"&&O.kind==="comment"?"正在发送…":It?"发送条件说明":"发送补充"]}),!It&&s.jsxs("button",{type:"button",className:ai,disabled:d||ee>0||!ke||!we.trim(),onClick:()=>{xe("revise")},children:[O?.state==="pending"&&O.kind==="revise"&&s.jsx(bn,{size:13,className:"animate-spin"}),O?.state==="pending"&&O.kind==="revise"?"正在提交…":"要求修改"]})]}),O&&s.jsx("div",{ref:be,role:O.state==="error"?"alert":"status",className:`rounded-lg px-3 py-2 text-xs leading-5 ${O.state==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:O.state==="pending"?"正在保存,请稍候…":O.state==="error"?`未确认保存:${O.error}。内容已保留,可重试。`:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:O.kind==="comment"?It?"补充已保存,投递结果可在任务管理中查看凭证;成员原报告仍保留,等待新的明确回复。":"补充已保存,投递结果可在任务管理中查看凭证。":"修改要求已保存,等待新结果后可验收。"}),s.jsx("p",{className:"mt-1 line-clamp-2 whitespace-pre-wrap break-words text-foreground/80",children:O.content}),s.jsx("button",{type:"button",className:"mt-1 min-h-11 text-primary underline underline-offset-4",onClick:()=>Fe("activity"),children:"查看任务动态"})]})}),!O&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:It?"说明会发送给本次负责人,成员明确回复后状态更新。":"发送补充会保留当前结果;需要更新结果时,请选择“要求修改”。"})]}),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(Df,{task:n}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整目标与验收标准"}),Ve(n.spec),n.acceptance&&Ve(n.acceptance),n.constraints&&Ve(n.constraints)]}),n.workflow&&Ee&&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:ai,disabled:d,onClick:()=>{p({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:"基于已提交代码创建;合并到原分支或发布需另行操作。"})]}),Ee&&s.jsxs(s.Fragment,{children:[ke&&n.workflow?.kind!=="goal"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"任务负责人",className:Ps,value:w,onChange:q=>v(q.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(q=>s.jsx("option",{value:q.sessionId,children:q.name},q.sessionId))]}),s.jsx("button",{type:"button",className:ai,disabled:d||!w||at,onClick:()=>{p({kind:"assign",assigneeSessionId:w,content:we||void 0})},children:"开始新一轮分派"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:at?"依赖任务验收后可分派。":"新分派保留旧记录,并结束旧问题的回答入口。"})]}),s.jsx(mo,{label:"协调者",children:s.jsxs("select",{className:Ps,disabled:d||n.workflow?.kind==="step",value:n.coordinator?n.memberSessions[Ou(n.coordinator)]??"":"",onChange:q=>{p({kind:"coordinator",coordinatorSessionId:q.target.value||null})},children:[!n.workflow&&s.jsx("option",{value:"",children:"由用户协调"}),c.map(q=>s.jsx("option",{value:q.sessionId,children:q.name},q.sessionId))]})}),s.jsx("button",{type:"button",className:`${ca} text-muted-foreground hover:bg-surface-2`,disabled:d,onClick:()=>{p({kind:"close",content:we||void 0})},children:"关闭此任务"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"关闭会保留历史和成员的终端工作。"})]}),!Ee&&s.jsx("button",{type:"button",className:ai,disabled:d,onClick:()=>{p({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(q=>s.jsxs("p",{className:"break-words",children:[q.lastError?`等待重试:${q.lastError}`:"已保存 · 等待投递",q.messageId?` · 消息 ${q.messageId}`:""]},q.id)),n.attempts.map(q=>s.jsxs("div",{children:[s.jsxs("p",{children:[q.id===n.activeAttemptId?"当前分派":"历史分派"," · ",l(q.assignee)," · ",Sa(q.createdAt)]}),s.jsxs("p",{className:"mt-1 break-all font-mono text-[11px]",children:["尝试 ID:",q.id]}),s.jsxs("p",{className:"mt-1",children:[q.deliveryStatus==="delivered"?`已写入终端 · ${q.deliveredAt?Sa(q.deliveredAt):""}`:q.deliveryStatus==="failed"||q.deliveryStatus==="expired"?"本次消息投递未成功":"等待写入终端",q.report?` · ${Nf[q.report.status]}(${Sa(q.report.createdAt)})`:""]})]},q.id)),n.deliveries.filter(q=>q.kind!=="task").map(q=>s.jsxs("p",{className:"break-all",children:["后续消息 ",q.messageId," · ",q.status==="delivered"?"已写入终端":"等待投递",q.deliveredAt?` · ${Sa(q.deliveredAt)}`:""]},q.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:ai,onClick:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(H)).then(()=>R("任务上下文已复制。")).catch(()=>R("复制失败,可导出任务记录。"))},children:"复制上下文"}),s.jsx("button",{type:"button",className:ai,onClick:ae,children:"导出记录"}),E&&s.jsx("span",{role:"status",className:"self-center text-[11px] text-muted-foreground",children:E})]})]})]})]}),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:[B?s.jsxs("div",{ref:le,className:"space-y-2",children:[s.jsx(Jh,{paneKey:r,inputKey:`${ce}:feedback`,active:t,label:"跟进要求",className:`${Ps} min-h-20 max-h-32 resize-none text-sm leading-6`,disabled:d,value:we,onUploadChange:ze,onChange:Be,placeholder:"说明哪里不满意,或写下接下来要完成的事…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:ai,disabled:d||ee>0,onClick:()=>z(!1),children:"取消,保留草稿"}),s.jsxs("button",{type:"button",className:`${cl} ml-auto`,disabled:d||ee>0||!ke||!we.trim(),onClick:()=>{xe("revise")},children:[O?.state==="pending"?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(i0,{size:14}),O?.state==="pending"?"正在发送…":"发送并继续跟进"]})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:`${ai} flex-1 sm:flex-none`,disabled:d,onClick:Vt,children:we.trim()?"继续跟进 · 有草稿":"继续跟进"}),Le!=="overview"?s.jsx("button",{type:"button",className:`${cl} ml-auto flex-1 sm:flex-none`,onClick:()=>Fe("overview"),children:gt?"返回当前进展":"返回当前结果"}):(gt||ue)&&Ee?s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"等待新结果后可验收"}):Ee&&n.workflow?.kind!=="step"?s.jsxs("button",{type:"button",className:`${cl} ml-auto flex-1 sm:flex-none`,disabled:d||ee>0||!!zt||O?.state==="saved"&&O.kind==="revise"&&O.resultId===Ne.id,onClick:()=>{p({kind:"accept",artifactId:Ne.id})},children:[s.jsx(pi,{size:14}),"验收此结果"]}):s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:n.status==="accepted"?n.completionMode==="reviewed"?"已通过独立评审":"已验收":"由独立评审验收"})]}),O&&s.jsx("div",{role:O.state==="error"?"alert":"status",className:`text-xs leading-5 ${O.state==="error"?"text-destructive":"text-primary"}`,children:O.state==="pending"?"正在保存跟进要求…":O.state==="error"?`未确认保存:${O.error}。内容已保留,可重试。`:"跟进要求已保存,等待新结果。"}),!B&&!gt&&Ee&&zt&&O?.state!=="saved"&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:zt})]})]})}const Bf=new Map,q6=e=>`termdock-group-settings:${window.location.origin}:${e}`;function Qf(e){return e.name!==e.savedName||e.rules!==e.savedRules}function Eg(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 IO(e,t){return{...Eg(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 EO(e,t){const r=Eg(e,t),n=q6(e.id);if(Bf.has(n))return Bf.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:Qf(c)?c:r}catch{return r}}function NO(e,t){const r=q6(e);try{Qf(t)?sessionStorage.setItem(r,JSON.stringify(t)):sessionStorage.removeItem(r),Bf.delete(r)}catch{Bf.set(r,Qf(t)?t:null)}}function Y6(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 ef(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 RO(){const e=ef("tab");return e==="automation"||e==="search"?e:"collaboration"}const $s="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",N1="inline-flex min-h-7 items-center justify-center rounded-md border px-2 py-1 text-[11px] leading-4 font-medium transition",vr="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",tf=new WeakMap;function Lb(e){const[t,r]=b.useState(null),[n,a]=b.useState(!1),c=Ei(m=>m.drafts),l=b.useCallback(m=>{const x=Ei.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(Ei.getState().drafts[m])===JSON.stringify(x))return;const w={...x};y&&tf.set(w,y),Ei.getState().setDraft(m,w)},[]),p={drafts:c,loadDrafts:l,updateDraft:d};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(Ib,{...e,...p,overlayObscured:!!t,onOpenOverlay:r,onClose:()=>{t?a(!0):e.onClose()}}),t&&s.jsx(Ib,{...e,...p,overlayOnly:!0,initialFloating:t==="floating",onFloatingChange:void 0,onOpenOverlay:r,onClose:()=>{r(null),n&&e.onClose()}})]})}function Ib({activeSessionId:e,initialCollaborationGroupId:t=null,initialFloating:r=!1,onFloatingChange:n,onEnterGroup:a,visible:c=!0,defaultSessionMode:l="shell",onClose:d,onNewSession:p,overlayOnly:m=!1,overlayObscured:x=!1,onOpenOverlay:y,drafts:w,loadDrafts:v,updateDraft:S}){const L=!!t,[E,R]=b.useState(r);b.useEffect(()=>{R(r)},[r]);const[B,z]=b.useState(!1),[O,$]=b.useState(t),V=Kn(je=>je.docks[t??"workbench"]),Z=Kn(je=>je.hosts[t??"workbench"]),[le,be]=b.useState("docked"),[pe,ee]=b.useState(null),[_e,ze]=b.useState({x:16,y:80}),Y=b.useRef(null),ce=b.useRef(null);b.useEffect(()=>{const je=Y.current;je&&(x?(je.contains(document.activeElement)&&(ce.current=document.activeElement),je.inert=!0):(je.inert=!1,ce.current?.isConnected&&ce.current.focus({preventScroll:!0}),ce.current=null))},[x]),b.useEffect(()=>{if(!m||E)return;const je=Y.current;je?.querySelector('button[aria-label="收起展开视图"]')?.focus({preventScroll:!0});const st=bt=>{if(bt.key!=="Tab"||bt.defaultPrevented||!je)return;const Br=Array.from(je.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),Vr=Br[0],Cr=Br.at(-1),qr=!je.contains(document.activeElement);bt.shiftKey&&(document.activeElement===Vr||qr)?(bt.preventDefault(),Cr?.focus()):!bt.shiftKey&&(document.activeElement===Cr||qr)&&(bt.preventDefault(),Vr?.focus())};return document.addEventListener("keydown",st),()=>document.removeEventListener("keydown",st)},[m,E]);const[qe]=b.useState(()=>document.createElement("div")),we=b.useRef({x:.5,y:.5}),[ye,Le]=b.useState(null),[Be,ne]=b.useState(null);b.useEffect(()=>{let je=!1;return fc().then(st=>{if(je)return;const bt=t3(st.collaborationPanels?.[Uf()],t);bt.position&&(we.current=bt.position),bt.size&&ee(bt.size),v(bt.drafts??{}),m||be(bt.mode??"docked"),Le(bt)}).catch(()=>{je||ne("面板草稿加载失败,请重新打开面板重试")}),()=>{je=!0}},[]);const[Fe,ke]=b.useState(null);b.useEffect(()=>{const je=st=>ne(String(st.detail));return window.addEventListener("termdock-panel-save-error",je),()=>{window.removeEventListener("termdock-panel-save-error",je),m||Kn.getState().setDock(t??"workbench",null)}},[]);const Ee=!m&&E&&le==="docked"&&!!Z;b.useLayoutEffect(()=>(qe.className=Ee?"h-full min-h-0 w-full min-w-0":"contents",(Ee?Z:document.body)?.appendChild(qe),()=>qe.remove()),[qe,Ee,Z]),b.useEffect(()=>{!m&&!E&&Kn.getState().setDock(t??"workbench",null)},[E]);const Pe=async je=>{if(m||B||je==="docked"&&!e)return;const st={sessionId:e,side:"right"};z(!0);try{await Fa({mode:je,...je==="docked"?{dock:st}:{}},t),be(je),Kn.getState().setDock(t??"workbench",je==="docked"?{...st,...L?{preferredWidth:360}:{}}:null)}catch{ne("面板布局保存失败,请重试")}finally{z(!1)}},Ne=b.useRef(!1),oe=b.useRef(null),We=b.useCallback((je,st)=>{const bt=Y.current?.getBoundingClientRect(),Br=window.visualViewport,Vr=(Br?.offsetLeft??0)+12,Cr=(Br?.offsetTop??0)+12;return{x:Math.max(Vr,Math.min(je,Vr+(Br?.width??window.innerWidth)-(bt?.width??440)-24)),y:Math.max(Cr,Math.min(st,Cr+(Br?.height??window.innerHeight)-(bt?.height??340)-24))}},[]),[nt,gt]=b.useState(()=>t?"collaboration":RO()),[ue,Ze]=b.useState(()=>new Set([nt])),at=je=>{gt(je),Ze(st=>new Set([...st,je])),Vt(null),Ot(null),!t&&!m&&ef("tab",je)},[Ie,Ge]=b.useState([]),[Ce,H]=b.useState([]),[ae,Ae]=b.useState([]),[Ye,et]=b.useState([]),[St,Gt]=b.useState([]),[Qt,wt]=b.useState(null),[zt,Vt]=b.useState(null),[Kt,Ot]=b.useState(null);b.useEffect(()=>{if(!Kt)return;const je=setTimeout(()=>Ot(null),5e3);return()=>clearTimeout(je)},[Kt]);const[It,xe]=b.useState("loading"),[Ve,ht]=b.useState("loading"),[q,ut]=b.useState(null),[qt,tt]=b.useState(null),[De,nr]=b.useState(),[Ke,_t]=b.useState(null),$t=b.useRef(null),yt=b.useRef(null),xt=b.useRef(null),Rt=t?Ye.find(je=>je.id===t)??null:null,Ct=b.useRef(!1);b.useEffect(()=>{if(t||It!=="loaded"||Ct.current)return;Ct.current=!0;const je=ef("group"),st=Ye.find(bt=>bt.id===je)??Ye.find(bt=>e&&bt.sessionIds.includes(e))??Ye[0];$(bt=>bt??st?.id??null)},[t,It,Ye,e]),b.useEffect(()=>{!t&&!m&&O&&Ye.some(je=>je.id===O)&&ef("group",O)},[O,Ye,t,m]);const fr=O?Ye.find(je=>je.id===O)??null:Ye[0]??null,Yt=!!t&&It==="loaded"&&!Rt,Sr=!!ye||!!Be,pn=!m&&E&&le==="docked"&&!!(V??ye?.dock)&&!Z,dr=c&&Sr&&!pn&&!!e&&(!t||!!Z||!!fr?.sessionIds.includes(e)||!!t&&(It!=="loading"&&!Rt||!!Be));b.useLayoutEffect(()=>{if(!E||Ee||!dr)return;const je=()=>{const bt=window.visualViewport;ke(bt?.height??window.innerHeight);const Br=Y.current?.getBoundingClientRect();!Br?.width||!Br.height||Ne.current||ze(We((bt?.offsetLeft??0)+12+Math.max(0,(bt?.width??window.innerWidth)-Br.width-24)*we.current.x,(bt?.offsetTop??0)+12+Math.max(0,(bt?.height??window.innerHeight)-Br.height-24)*we.current.y))},st=new ResizeObserver(je);return Y.current&&st.observe(Y.current),window.addEventListener("resize",je),window.visualViewport?.addEventListener("resize",je),je(),()=>{st.disconnect(),window.removeEventListener("resize",je),window.visualViewport?.removeEventListener("resize",je)}},[E,Ee,dr,We,ye,pe]),b.useLayoutEffect(()=>{if(m)return;const je=t??"workbench",st=Kn.getState();if(Yt)st.docks[je]&&st.setDock(je,null);else if(Sr&&E&&le==="docked"&&e&&(!t||Rt)){const bt=st.docks[je],Br=!t||Rt?.sessionIds.includes(e)?e:St.find(qr=>Rt?.sessionIds.includes(qr.sessionId)&&!$u(qr.sessionId))?.sessionId??e,Vr=bt??ye?.dock??{sessionId:Br,side:window.innerWidth<640?"bottom":"right"},Cr={...Vr,sessionId:Rt?.sessionIds.includes(e)?e:Vr.sessionId,...L?{preferredWidth:bt?.preferredWidth??360}:{}};(!bt||Cr.sessionId!==bt.sessionId||Cr.preferredWidth!==bt.preferredWidth)&&st.setDock(je,Cr),L&&bt&&Cr.sessionId!==bt.sessionId&&Fa({dock:{sessionId:Cr.sessionId,side:Cr.side}},t).catch(()=>ne("协作位置保存失败,当前面板仍可使用"))}},[Yt,Rt,E,le,ye,Sr,e,t,V,St]);const me=async(je,st=!1)=>{if(!(B||je&&!fr)){if(!m&&!je&&!st&&V){y("full");return}if(m){st?d():(R(je),y(je?"floating":"full"));return}z(!0);try{await n?.(je?fr.id:null),R(je),je&&le==="docked"&&e&&Kn.getState().setDock(t??"workbench",{sessionId:e,side:V?.side??ye?.dock?.side??"right"}),st&&d()}catch(bt){Vt(`常驻浮窗状态保存失败,请重试:${bt instanceof Error?bt.message:"连接失败"}`)}finally{z(!1)}}},Gr=b.useCallback(je=>{et(je.groups),Gt(je.sessions),nr(je.peers),tt(null),xe("loaded")},[]);b.useEffect(()=>Ny(Gr),[Gr]);const ot=b.useCallback(async(je={})=>{je.silent||Vt(null),!L&&!yt.current&&(yt.current=H8().then(st=>{Ge(st.automations),H(st.runs),ht("loaded"),ut(null)}).catch(st=>{ht("error"),ut(st instanceof Error?st.message:"自动任务加载失败")}).finally(()=>{yt.current=null})),xt.current||(xt.current=_y().then(st=>{Ae(st),_t(null)}).catch(()=>{_t("Agent 命令检测失败;已有会话可继续协作。")}).finally(()=>{xt.current=null})),$t.current||(xe(st=>st==="error"?"loading":st),$t.current=Q1().then(Gr).catch(st=>{xe("error"),tt(`协作会话加载失败:${st instanceof Error?st.message:"请重试"}`)}).finally(()=>{$t.current=null})),await Promise.all([$t.current,yt.current])},[Gr,L]);b.useEffect(()=>{ot();const je=window.setInterval(()=>{ot({silent:!0})},1e4);return()=>window.clearInterval(je)},[ot]),b.useEffect(()=>{const je=st=>{st.key==="Escape"&&!st.defaultPrevented&&!E&&d()};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[d,E]);const pt=je=>{L&&je&&je!==t&&Ye.some(st=>st.id===je)&&a?a(je).catch(st=>Vt(st instanceof Error?st.message:"无法打开工作区")):$(je)},ir=async je=>{await UO(je)},Mn=!E&&!L&&nt==="collaboration",Xr=async(je,st)=>{if(!Qt){wt(`open-group:${je}`),Vt(null);try{await a?.(je),Ei.getState().open(je,st),d()}catch(bt){Vt(bt instanceof Error?bt.message:"无法打开协作组,请重试")}finally{wt(null)}}};return Xs.createPortal(s.jsxs(s.Fragment,{children:[!E&&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:je=>{Ee&&je.stopPropagation()},ref:Y,role:m&&!E?"dialog":void 0,"aria-modal":m&&!E?!0:void 0,"aria-hidden":x||void 0,"aria-label":Ee?"工作组消息分屏":E?"工作组消息浮窗":"Agent 工作台",style:c?E&&!Ee?{display:dr?void 0:"none",left:_e.x,top:_e.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:Fe?Fe-24:"calc(100dvh - 24px)"}:void 0:{display:"none"},className:Ee?"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface":E?"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))] ${Mn?"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 ${L?"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)] ${Mn?"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":Ee?"true":void 0,"data-panel-drag-title":Ee?"true":void 0,onDragStart:je=>je.preventDefault(),className:`flex items-center gap-2 border-b border-border/15 ${Ee?"min-h-9 shrink-0 cursor-grab select-none bg-[var(--chrome-bg)] px-3 active:cursor-grabbing":E?"px-3 py-2 cursor-move touch-none select-none":"px-4 py-3"}`,onPointerDown:je=>{!E||Ee||je.button!==0||je.target.closest("button, summary")||(oe.current={x:je.clientX,y:je.clientY,left:_e.x,top:_e.y},je.currentTarget.setPointerCapture?.(je.pointerId))},onPointerMove:je=>{oe.current&&ze(We(oe.current.left+je.clientX-oe.current.x,oe.current.top+je.clientY-oe.current.y))},onPointerUp:()=>{if(!oe.current)return;oe.current=null;const je=Y.current?.getBoundingClientRect(),st=window.visualViewport;je&&(we.current=bx(_e.x,_e.y,(st?.offsetLeft??0)+12,(st?.offsetTop??0)+12,(st?.width??window.innerWidth)-je.width-24,(st?.height??window.innerHeight)-je.height-24),Fa({position:we.current},t).catch(()=>ne("浮窗位置保存失败,请重新拖动重试")))},onPointerCancel:()=>{oe.current=null},children:[s.jsx(R0,{size:Ee?13:17,className:"shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:`${E?"truncate text-[12px]":"text-[14px]"} font-semibold text-foreground`,title:Ee?"拖动标题移动面板;放在边缘拆分,中央交换":Rt?.name,children:Rt?Rt.name:t?"协作工作区":"Agent 工作台"}),!Ee&&!L&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:E?"引用、文件路径和粘贴优先加入此处":Rt?"分派任务、回答问题、审阅与验收结果":"自动任务、会话协作与历史搜索"})]}),!Ee&&!m&&L&&nt==="collaboration"&&Ye.length>0&&s.jsx("button",{className:`${vr} shrink-0 text-primary hover:bg-primary/10`,disabled:B,onClick:()=>{me(!E)},children:E?"展开":"放到终端旁"}),L&&Rt&&s.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[Rt.sessionIds.length," 人"]}),Ee&&!a&&s.jsx("button",{type:"button","aria-label":"展开协作工作区",title:"展开查看目标与交付",disabled:B,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(AA,{size:15})}),Ee&&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(To,{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:B,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:je=>{je.currentTarget.closest("details")?.removeAttribute("open"),Pe("floating")},children:[s.jsx(Fc,{size:14}),"小浮窗"]})})]}),s.jsx("button",{className:`${Ee?"min-h-8 rounded px-2":"rounded-lg p-2"} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,disabled:B,onClick:()=>{E?me(!1,!0):d()},"aria-label":m?"收起展开视图":"关闭",children:s.jsx(In,{size:16})})]}),E&&!Ee&&!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:B,"aria-pressed":le==="floating",className:`${N1} ${le==="floating"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Pe("floating")},children:"浮窗"}),s.jsx("button",{type:"button",disabled:B||!e||Yt,"aria-pressed":le==="docked",className:`${N1} ${le==="docked"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Pe("docked")},children:"放到终端旁"})]}),!L&&(!E||Ee)&&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",Uu,"协作组"],["automation",m0,"自动任务"],["search",jl,"历史搜索"]].map(([je,st,bt])=>s.jsxs("button",{type:"button","aria-pressed":nt===je,"aria-controls":`workbench-${je}`,onClick:()=>at(je),className:`${vr} ${nt===je?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(st,{size:14}),bt]},je))}),nt==="collaboration"&&qt&&s.jsxs("div",{role:"alert",className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[qt,s.jsx("button",{className:`${vr} ml-2`,onClick:()=>{ot()},children:"重新加载会话"})]}),!L&&nt!=="search"&&Ke&&s.jsx("div",{className:"mx-4 mt-3 text-[11px] text-muted-foreground",children:Ke}),zt&&s.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:zt}),Kt&&(!E||Ee)&&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(pi,{size:13}),Kt]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[ue.has("automation")&&s.jsx("div",{id:"workbench-automation",className:nt==="automation"?"h-full min-h-0 p-4":"hidden",children:s.jsx(MO,{automations:Ie,runs:Ce,agents:ae,sessions:St.filter(je=>!$u(je.sessionId)),activeSessionId:e,loading:Ve==="loading",loadError:q,busy:Qt,setBusy:wt,setError:Vt,setNotice:Ot,refresh:ot,onClose:d})}),ue.has("collaboration")&&s.jsxs("div",{id:"workbench-collaboration",className:nt==="collaboration"?`flex-1 min-h-0 overflow-x-hidden overflow-y-auto overscroll-y-contain ${E?"p-3":"p-4"}`:"hidden",children:[!ye&&!Be&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息面板…"}),t&&!Rt&&s.jsxs("div",{role:"status",className:"space-y-2 text-[11px] text-muted-foreground",children:[s.jsx("p",{children:It==="loading"?"正在加载协作组…":It==="error"?"协作组加载失败,恢复连接后可重试。":"此协作组暂不可用,已释放分屏位置。草稿和布局偏好仍保留。"}),It!=="loading"&&s.jsx("button",{className:vr,onClick:()=>{ot()},children:"重新加载"})]}),Be&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:Be}),ye&&(!t||Rt)&&s.jsx(DO,{active:nt==="collaboration",notice:Kt,initialDrafts:w,onDraftChange:S,docked:Ee,inputKeySuffix:m?":overlay":"",selectedGroupId:O,setSelectedGroupId:pt,floatingVisible:dr,floating:E,sessionsState:It,groups:Ye,sessions:St,agents:ae,activeSessionId:e,initialGroupId:t,onOpenSession:async je=>{await ir(je),E||d()},onOpenTaskSession:ir,onEnterGroup:a,onOpenGroup:Xr,defaultSessionMode:l,busy:Qt,setBusy:wt,setError:Vt,setNotice:Ot,refresh:ot}),!L&&De&&s.jsx(QO,{peers:De,currentGroupId:O==="new"?void 0:fr?.id,busy:Qt,setBusy:wt,setError:Vt,setNotice:Ot,onSelectGroup:je=>{Xr(je,"messages")}})]}),ue.has("search")&&s.jsx("div",{id:"workbench-search",className:nt==="search"?"h-full min-h-0 overflow-y-auto overscroll-y-contain p-4":"hidden",children:s.jsx(VO,{active:nt==="search",onClose:d,onNewSession:p,setError:Vt})})]}),E&&!Ee&&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:je=>{je.preventDefault(),Ne.current=!0,je.currentTarget.setPointerCapture(je.pointerId)},onPointerMove:je=>{if(!je.currentTarget.hasPointerCapture(je.pointerId))return;const st=window.visualViewport,bt=st?.width??window.innerWidth,Br=st?.height??window.innerHeight;ee({width:Math.min(1,Math.max(280,je.clientX-_e.x)/bt),height:Math.min(1,Math.max(220,je.clientY-_e.y)/Br)})},onPointerUp:()=>{Ne.current=!1;const je=Y.current?.getBoundingClientRect(),st=window.visualViewport;je&&(we.current=bx(_e.x,_e.y,(st?.offsetLeft??0)+12,(st?.offsetTop??0)+12,(st?.width??window.innerWidth)-je.width-24,(st?.height??window.innerHeight)-je.height-24)),pe&&Fa({size:pe,position:we.current},t).catch(()=>ne("浮窗大小保存失败,请重新调整重试"))},onPointerCancel:()=>{Ne.current=!1},onKeyDown:je=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(je.key))return;je.preventDefault();const st=Y.current?.getBoundingClientRect(),bt={width:Math.max(.15,Math.min(1,(pe?.width??(st?.width??400)/window.innerWidth)+(je.key==="ArrowRight"?.03:je.key==="ArrowLeft"?-.03:0))),height:Math.max(.15,Math.min(1,(pe?.height??(st?.height??300)/window.innerHeight)+(je.key==="ArrowDown"?.03:je.key==="ArrowUp"?-.03:0)))};ee(bt),Fa({size:bt},t).catch(()=>ne("浮窗大小保存失败,请重试"))},children:s.jsx("span",{"aria-hidden":"true",children:"⌟"})})]})]}),qe)}function MO({automations:e,runs:t,agents:r,sessions:n,activeSessionId:a,loading:c,loadError:l,busy:d,setBusy:p,setError:m,setNotice:x,refresh:y,onClose:w}){const[v,S]=b.useState(null),[L,E]=b.useState(!1),[R,B]=b.useState(null),z=async(O,$,V)=>{p(O),m(null),x(null);try{await $(),await y(),x(V)}catch(Z){m(Z instanceof Error?Z.message:"操作失败")}finally{p(null)}};return L?s.jsx(jO,{agents:r,sessions:n,activeSessionId:a,initial:v,onCancel:()=>{S(null),E(!1),m(null)},onSaved:async(O,$)=>{S(null),E(!1),await y(),x(v?`“${O}”已更新`:$?`“${O}”已创建,将按计划自动运行`:`“${O}”已创建,当前未启用`)},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:vr,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:"定时发送任务,打开运行会话查看输出。"})]}),!L&&e.length>0&&s.jsxs("button",{className:`${vr} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{S(null),E(!0),x(null)},children:[s.jsx(zs,{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(OA,{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:`${vr} mt-4 bg-primary text-primary-foreground`,onClick:()=>E(!0),children:[s.jsx(zs,{size:13}),"创建第一个任务"]})]}),s.jsx("div",{className:"space-y-2",children:e.map(O=>{const $=t.filter(Z=>Z.automationId===O.id).sort((Z,le)=>le.startedAt-Z.startedAt)[0],V=r.find(Z=>Z.command===O.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:O.name}),s.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${O.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:O.enabled?"已启用":"已停用"}),O.lastRunStatus&&s.jsx("span",{className:`text-[10px] ${XO(O.lastRunStatus)}`,children:KO(O.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(m0,{size:11}),YO(O)]}),s.jsx("span",{children:O.enabled&&O.nextRunAt?`下次 ${Of(O.nextRunAt)}`:"不会自动运行"})]}),s.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:O.targetSessionId?`发送到 ${n.find(Z=>Z.sessionId===O.targetSessionId)?.name??"指定会话"}`:`新建 ${V?.displayName??"Agent"} 会话 · ${O.cwd}`}),s.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:O.prompt}),O.lastRunAt&&s.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",Of(O.lastRunAt),O.lastRunMessage?` · ${O.lastRunMessage}`:""]})]}),s.jsx("button",{"aria-label":`编辑 ${O.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{S(O),E(!0),x(null)},children:s.jsx(ju,{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:R===O.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),s.jsx("button",{className:`${vr} bg-surface-elevated text-foreground`,onClick:()=>B(null),children:"取消"}),s.jsxs("button",{disabled:d!==null,className:`${vr} bg-destructive text-destructive-foreground`,onClick:()=>{z(`delete:${O.id}`,()=>V8(O.id),`“${O.name}”已删除`).then(()=>B(null))},children:[d===`delete:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(Rs,{size:13}),"确认删除"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`${vr} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>B(O.id),children:[s.jsx(Rs,{size:13}),"删除"]}),s.jsxs("button",{disabled:d!==null,className:`${vr} ${O.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{z(`toggle:${O.id}`,()=>q8(O.id,!O.enabled),O.enabled?`“${O.name}”已暂停,不会自动运行`:`“${O.name}”已恢复,将按原计划运行`)},children:[d===`toggle:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):O.enabled?s.jsx(XT,{size:13}):s.jsx(lf,{size:13}),O.enabled?"暂停":"恢复"]}),$?.frontendSessionId&&s.jsxs("button",{className:`${vr} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:$.frontendSessionId})),w()},children:[s.jsx(Fc,{size:13}),"打开上次会话"]}),s.jsxs("button",{disabled:d!==null,className:`${vr} bg-primary/15 text-primary`,onClick:()=>{z(`run:${O.id}`,()=>Y8(O.id),`“${O.name}”已投递,可打开会话查看进度`)},children:[d===`run:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(lf,{size:13}),"立即运行"]})]})})]},O.id)})})]})}function jO({agents:e,sessions:t,activeSessionId:r,initial:n,onCancel:a,onSaved:c,setError:l}){const[d,p]=b.useState(n?.name??""),m=t.find(H=>H.sessionId===r),x=n?.cwd??m?.cwd??t[0]?.cwd??"",[y,w]=b.useState(x),v=b.useRef(!1),[S,L]=b.useState(!1),[E,R]=b.useState(()=>e.find(H=>H.command===n?.command)?.slug??""),[B,z]=b.useState(n?.prompt??""),[O,$]=b.useState(n?.targetSessionId??""),[V,Z]=b.useState(n?.targetSessionId?"existing":"new"),[le,be]=b.useState(n?.schedule.kind??"interval"),[pe,ee]=b.useState(n?.schedule.kind==="interval"?n.schedule.everyMinutes:60),[_e,ze]=b.useState(n?.schedule.kind==="daily"?n.schedule.time:"09:00"),[Y,ce]=b.useState(n?.schedule.kind==="daily"?n.schedule.weekdays:[1,2,3,4,5]),[qe,we]=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,Le]=b.useState(!1),[Be,ne]=b.useState(n?.enabled??!0),[Fe,ke]=b.useState(!1),Ee=e.find(H=>H.slug===E)??null,Pe=Ee?.command??n?.command??"";b.useEffect(()=>{if(!E){const H=n?e.find(ae=>ae.command===n.command):e[0];H&&R(H.slug)}},[e,n,E]),b.useEffect(()=>{!n&&!v.current&&x&&w(x)},[n,x]);const Ne=d.trim()||Array.from(B.trim().split(`
157
+ `)[0].trim()).slice(0,40).join(""),oe=t.find(H=>H.sessionId===O),We=qe?`custom-${le}`:le==="interval"?String(pe):Y.length===7?"daily":"workdays",nt=H=>{we(H.startsWith("custom-")),["15","60","1440","custom-interval"].includes(H)?(be("interval"),H!=="custom-interval"&&ee(Number(H))):(be("daily"),H==="daily"&&ce([0,1,2,3,4,5,6]),H==="workdays"&&ce([1,2,3,4,5]))},gt=async()=>{if(!(Fe||!Ce)){ke(!0),l(null);try{await t9({id:n?.id,name:Ne,cwd:y,command:V==="new"?Pe:"",prompt:B,targetSessionId:V==="existing"&&O||null,enabled:Be,schedule:le==="interval"?{kind:le,everyMinutes:pe}:{kind:le,time:_e,weekdays:Y}}),await c(Ne,Be)}catch(H){l(H instanceof Error?H.message:"保存失败")}finally{ke(!1)}}},ue=le==="interval"?{kind:le,everyMinutes:pe}:{kind:le,time:_e,weekdays:Y},[Ze,at]=_e.split(":"),Ie=(H,ae)=>ze(`${H}:${ae}`),Ge=B.trim()?V==="existing"&&!t.some(H=>H.sessionId===O)?"请选择当前服务的可用会话":V==="new"&&!Pe?"请选择可启动的 Agent":le==="interval"&&(!Number.isInteger(pe)||pe<1||pe>43200)?"间隔需要是 1–43200 分钟的整数":le==="daily"&&!Y.length?"至少选择一天":"":"请填写任务内容",Ce=!Ge;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:Fe,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(In,{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:Fe,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:`${$s} min-h-24 resize-y`,rows:3,value:B,onChange:H=>z(H.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:$s,value:We,onChange:H=>nt(H.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:"自定义星期"})]})]}),le==="interval"&&qe&&s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["每隔多少分钟",s.jsx("input",{className:`${$s} min-w-0 flex-1`,type:"number",min:1,max:43200,value:pe,onChange:H=>ee(Number(H.target.value))})]}),le==="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(m0,{size:14,className:"mr-2 shrink-0 text-primary"}),s.jsx(Eb,{label:"小时",value:Ze,options:24,onChange:H=>Ie(H,at)}),s.jsx("span",{"aria-hidden":"true",className:"px-2 text-[16px] text-muted-foreground",children:":"}),s.jsx(Eb,{label:"分钟",value:at,options:60,onChange:H=>Ie(Ze,H)}),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((H,ae)=>{const Ae=Y.includes(ae);return s.jsx("button",{type:"button","aria-pressed":Ae,"aria-label":`星期${H}`,className:`rounded-lg py-2.5 text-[11px] transition ${Ae?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>ce(Ye=>Ae?Ye.filter(et=>et!==ae):[...Ye,ae].sort()),children:H},ae)})}),Y.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(R0,{size:13,className:"shrink-0"}),V==="new"?`每次新建会话 · ${Ee?.displayName??(n?.command?"原 Agent":"暂无可用 Agent")}`:`发送到现有会话 · ${oe?.name??"目标会话不可用"}`]}),s.jsx("p",{className:"break-all pl-[19px] text-[10px]",children:V==="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:`${vr} -ml-2 px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>Le(H=>!H),children:[s.jsx(ul,{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:$s,value:d,onChange:H=>p(H.target.value),placeholder:Ne||"留空则从任务内容自动生成"})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["运行方式",s.jsxs("select",{className:$s,value:V,onChange:H=>{const ae=H.target.value;Z(ae),ae==="existing"&&!O&&$(m?.sessionId??t[0]?.sessionId??"")},children:[s.jsx("option",{value:"new",children:"每次新建会话"}),s.jsx("option",{value:"existing",disabled:t.length===0,children:"发送到现有会话"})]})]}),V==="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:$s,value:E,onChange:H=>R(H.target.value),children:[n&&!e.some(H=>H.command===n.command)&&s.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(H=>s.jsxs("option",{value:H.slug,children:[H.displayName,H.isPlugin?" · Plugin":""]},H.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:`${$s} min-w-0`,value:y,onChange:H=>{v.current=!0,w(H.target.value)},placeholder:"默认使用当前目录"}),s.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${vr} shrink-0 bg-surface-2 text-foreground`,onClick:()=>L(!0),children:[s.jsx(Du,{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:$s,value:O,onChange:H=>$(H.target.value),children:[!oe&&s.jsx("option",{value:O,children:O?"原目标会话不可用,请重新选择":"请选择会话"}),t.map(H=>s.jsxs("option",{value:H.sessionId,children:[H.name," · ",rf(H)]},H.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:Be,onChange:H=>ne(H.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:Ge||(Be?`${n?"下次运行":"首次运行"}:${Of(ZO(ue,Date.now(),n?.createdAt))}`:"保存后暂停,不会自动运行")}),s.jsx("button",{disabled:Fe,className:`${vr} bg-surface-2 text-foreground`,onClick:a,children:"取消"}),s.jsx("button",{title:Ge||void 0,disabled:Fe||!Ce,className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{gt()},children:Fe?"保存中…":n?"保存修改":"创建任务"})]}),s.jsx(rp,{open:S,initialPath:y||x||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>L(!1),onConfirm:H=>{v.current=!0,w(H),L(!1)}})]})}function Eb({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(ul,{"aria-hidden":"true",size:13,className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground"})]})}function DO({fullWorkspace:e=!1,initialView:t="tasks",onOpenGroup:r,active:n,notice:a,initialDrafts:c,onDraftChange:l,docked:d,inputKeySuffix:p,selectedGroupId:m,setSelectedGroupId:x,floatingVisible:y,floating:w,sessionsState:v,groups:S,sessions:L,agents:E,activeSessionId:R,initialGroupId:B,onOpenSession:z,onOpenTaskSession:O,onEnterGroup:$,onDockMessages:V,defaultSessionMode:Z,busy:le,setBusy:be,setError:pe,setNotice:ee,refresh:_e}){const ze=w&&!!B&&!!$&&!e,[Y,ce]=b.useState(()=>ze?"messages":t);b.useEffect(()=>{e&&ce(t)},[t,e]);const[qe,we]=b.useState(!1),[ye,Le]=b.useState(0);b.useEffect(()=>Le(0),[m]);const[Be,ne]=b.useState(""),[Fe,ke]=b.useState(()=>new Set),[Ee,Pe]=b.useState(""),[Ne,oe]=b.useState(()=>new Set),[We,nt]=b.useState(!1),[gt,ue]=b.useState(),[Ze,at]=b.useState([]),[Ie,Ge]=b.useState(!1),[Ce,H]=b.useState(null),ae=Ly(),[Ae,Ye]=b.useState(null),[et,St]=b.useState(""),[Gt,Qt]=b.useState(!1),[wt,zt]=b.useState(!1),Vt=b.useRef(null),Kt=b.useRef(null),Ot=b.useRef(null),It=()=>{Ot.current=null,zt(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>{Kt.current?.isConnected&&Kt.current.getClientRects().length?Kt.current.focus():Array.from(Vt.current?.querySelectorAll('button[aria-label="组设置"], button[aria-label="更多看板操作"], summary[aria-label="更多协作操作"]')??[]).find(X=>X.getClientRects().length)?.focus()}))},[xe,Ve]=b.useState(null),[ht,q]=b.useState(new Set),[ut,qt]=b.useState(),[tt,De]=b.useState({}),[nr,Ke]=b.useState(!1),[_t,$t]=b.useState(""),[yt,xt]=b.useState(""),[Rt,Ct]=b.useState(""),[fr,Yt]=b.useState(""),[Sr,pn]=b.useState(""),dr=b.useRef(null),me=d,Gr=(m??S[0]?.id??"")+p,ot=b.useRef(!1),pt=m==="new"?null:(m?S.find(X=>X.id===m):S[0])??null,ir=pt?.sessionIds.flatMap(X=>{const He=L.find(Nt=>Nt.sessionId===X);return He?[He]:[]})??[],[Mn,Xr]=b.useState(0),je=b.useRef(new Map(Object.entries(c??{}))),[st]=b.useState(()=>({})),bt=b.useRef(void 0),Br=b.useRef(!1),Vr=b.useRef(Ae);Vr.current=Ae;const Cr=b.useRef(et);Cr.current=et,b.useLayoutEffect(()=>{if(bt.current===pt?.id)return;if(bt.current){const He={content:Cr.current,targets:Ae};je.current.set(bt.current,He),Fa({drafts:{[bt.current]:He}}).catch(()=>pe("草稿保存失败,请返回该组重试"))}bt.current=pt?.id,Br.current=!0;const X=je.current.get(pt?.id??"");St(X?.content??""),Ye(X?.targets??null)},[pt?.id]),b.useEffect(()=>{Ve(null)},[pt?.id]);const qr=b.useRef(null),mn=b.useRef(c);b.useLayoutEffect(()=>{if(mn.current===c)return;mn.current=c;for(const[He,Nt]of Object.entries(c??{}))tf.get(Nt)!==st&&je.current.set(He,Nt);const X=c?.[pt?.id??""];!X||tf.get(X)===st||X.content===Cr.current&&JSON.stringify(X.targets)===JSON.stringify(Vr.current)||(Br.current=!0,qr.current=null,St(X.content),Ye(X.targets))},[c,pt?.id]);const on=b.useCallback(X=>{Fa(X).catch(()=>pe("草稿保存失败,请保持面板打开,修改内容后重试"))},[pe]);b.useLayoutEffect(()=>{if(Br.current){Br.current=!1;return}if(!pt||bt.current!==pt.id)return;const X={drafts:{[pt.id]:{content:et,targets:Ae}}};tf.set(X.drafts[pt.id],st),l(pt.id,X.drafts[pt.id],st),qr.current=X;const He=setTimeout(()=>{qr.current=null,on(X)},400);return()=>{clearTimeout(He)}},[pt?.id,et,Ae,on]),b.useEffect(()=>{const X=()=>{qr.current&&(on(qr.current),qr.current=null)},He=()=>{document.visibilityState==="hidden"&&X()};return document.addEventListener("visibilitychange",He),window.addEventListener("pagehide",X),()=>{document.removeEventListener("visibilitychange",He),window.removeEventListener("pagehide",X),X()}},[on]),b.useEffect(()=>{if(!(!(w||e)||!n||!y||!pt||wt||Y!=="messages"))return ky(X=>{ce("messages"),St(He=>He+(He&&!/\s$/.test(He)?`
158
+ `:"")+X.replace(/\r\n?/g,`
159
+ `))},Gr,me)},[w,e,n,y,pt?.id,me,Gr,Y,wt]),b.useEffect(()=>{const X=dr.current;if(!w||!X)return;const He=Nt=>pe(String(Nt.detail));return X.addEventListener("termdock:file-drop-error",He),()=>X.removeEventListener("termdock:file-drop-error",He)},[w,pt?.id,pe]);const zr=async X=>{const He=pt?.id;pe(null),Xr(Nt=>Nt+1);try{const Nt=await N0("/tmp",X);if(Nt.files.length!==X.length||Nt.files.some(tr=>!tr.path))throw new Error("文件路径准备失败,请重试");const Et=Nt.files.map(tr=>Dc(tr.path)).join(" ")+" ";if(bt.current===He)St(tr=>tr+(tr&&!/\s$/.test(tr)?`
160
+ `:"")+Et);else if(He){const tr=je.current.get(He)??{content:"",targets:null},jr={...tr,content:tr.content+`
161
+ `+Et};je.current.set(He,jr),on({drafts:{[He]:jr}})}}catch(Nt){pe(Nt instanceof Error?Nt.message:"文件上传失败")}finally{Xr(Nt=>Nt-1)}},un=new Set(L.filter(Cm).map(X=>X.sessionId)),Er=Fe.size,re=[...Fe].filter(X=>!un.has(X)),mt=FO(pt,L),Mt=Ee.trim().toLocaleLowerCase(),rr=L.filter(X=>!Mt||[Iu(X,L),X.name,X.serviceLabel??"",X.cwd,km(X.currentTask)].some(He=>He.toLocaleLowerCase().includes(Mt))),Ar=Nb(rr),Fr=Nb(mt),Xt=X=>!Mt&&Ne.has(X),Zr=X=>oe(He=>{const Nt=new Set(He);return Nt.has(X)?Nt.delete(X):Nt.add(X),Nt});b.useEffect(()=>{Qt(!1),Ot.current!==pt?.id&&zt(!1),Ot.current=null,we(!1),Ke(!1),nt(!1),De({}),q(new Set(pt?.sessionIds??[])),xt(pt?.defaultLaunchProfileId??"")},[pt?.id]),b.useEffect(()=>{!_t&&E[0]&&$t(E[0].slug)},[E,_t]),b.useEffect(()=>{at([]),H(null)},[pt?.id]),b.useEffect(()=>{if(!B||!n||w&&!y||!pt){Ge(!1);return}Ge(!0);let X=!1,He=0,Nt=!1;const Et=()=>{if(X||Nt||document.hidden||navigator.onLine===!1)return;Nt=!0;const jr=++He;ox(pt.id).then(cr=>{!X&&jr===He&&(at(cr.messages),H(null))}).catch(cr=>{!X&&jr===He&&H(cr instanceof Error?cr.message:"消息加载失败")}).finally(()=>{Nt=!1,!X&&jr===He&&Ge(!1)})};Et();const tr=window.setInterval(Et,3e3);return document.addEventListener("visibilitychange",Et),window.addEventListener(sf,Et),window.addEventListener("pageshow",Et),()=>{X=!0,window.clearInterval(tr),document.removeEventListener("visibilitychange",Et),window.removeEventListener(sf,Et),window.removeEventListener("pageshow",Et)}},[pt?.id,n,w,y]),b.useEffect(()=>{!B||pt?.id!==B||ot.current||(ot.current=!0,Y==="messages"&&dr.current?.scrollIntoView?.({block:"nearest"}))},[B,pt?.id]);const Jt=async()=>{be("create-group"),pe(null),ee(null);try{if(re.length)throw new Error("所选会话已变化,请先清除不可用选择");const X=await Ml({name:Be,sessionIds:[...Fe]});ne(""),Pe(""),x(X.group.id),await _e(),ee(`“${X.group.name}”已创建。`),r?await r(X.group.id,"messages"):$&&await $(X.group.id)}catch(X){pe(X instanceof Error?X.message:"创建失败")}finally{be(null)}},Pr=pt?.sessionIds.filter(X=>Ae===null||Ae.includes(X))??[],Hr=async()=>{if(!pt||le||Mn||!et.trim()||!Pr.length)return;const X=et,He=pt.id;be("send-message"),pe(null),ee(null);try{const Nt=await U8(pt.id,{fromSessionId:null,toSessionIds:Ae===null?void 0:Pr,kind:"message",content:et});if(bt.current===He){const cr=Cr.current,Cn=cr===X?"":cr.startsWith(X)?cr.slice(X.length).replace(/^\n/,""):cr;St(Cn),on({drafts:{[He]:{content:Cn,targets:Vr.current}}})}else{const cr=je.current.get(He);if(cr){const Cn={...cr,content:cr.content===X?"":cr.content.startsWith(X)?cr.content.slice(X.length).replace(/^\n/,""):cr.content};je.current.set(He,Cn),on({drafts:{[He]:Cn}})}}const Et=await ox(He).catch(()=>null);Et&&bt.current===He&&at(Et.messages);const tr=Nt.deliveries?.filter(cr=>cr.serviceUnavailable).length??0,jr=Nt.deliveries?.filter(cr=>cr.pending>0).length??0;ee(tr>0?`已保存消息;${tr} 个接收成员的服务不可达,尚未送达,等待重连`:jr>0?`已保存消息;${jr} 个成员等待投递确认`:`消息已送达 ${Nt.messages.length} 个会话`)}catch(Nt){pe(Nt instanceof Error?Nt.message:"发送失败")}finally{be(null)}},ps=async()=>{if(!pt)return;be(`delete:${pt.id}`),pe(null),ee(null);const X=pt.name;try{await Ey(pt.id,gt),x(null),nt(!1),await _e(),ee(`“${X}”已删除`)}catch(He){pe(He instanceof Error?He.message:"删除失败")}finally{be(null)}},Mr=async()=>{if(!pt)return;const X=[...ht];be("save-members"),pe(null),ee(null);try{const He=await Ml({id:pt.id,name:pt.name,sessionIds:X,expectedUpdatedAt:ut});x(He.group.id),Qt(!1),await _e(),ee(`“${pt.name}”成员已更新,共 ${X.length} 个会话`)}catch(He){pe(He instanceof Error?He.message:"成员更新失败")}finally{be(null)}},jn=async X=>{if(!pt||!pt.sessionIds.includes(X)){Ve(null);return}const He=L.find(Et=>Et.sessionId===X)?.name??X,Nt=pt.name;be(`remove-member:${X}`),pe(null),ee(null);try{await Ml({id:pt.id,name:Nt,sessionIds:pt.sessionIds.filter(Et=>Et!==X),expectedUpdatedAt:pt.updatedAt}),Ve(null),q(Et=>new Set([...Et].filter(tr=>tr!==X))),De(Et=>Object.fromEntries(Object.entries(Et).filter(([tr])=>tr!==X))),await _e(),ee(`已把“${He}”移出“${Nt}”`)}catch(Et){pe(Et instanceof Error?Et.message:"移出成员失败")}finally{be(null)}},Tr=async X=>{if(!pt)return;const He=tt[X]??"";be(`role:${X}`),pe(null),ee(null);try{await G8(pt.id,X,He.trim()||null),await _e(),ee(He.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(Nt){pe(Nt instanceof Error?Nt.message:"定位保存失败")}finally{be(null)}},Jr=()=>{xt(pt?.defaultLaunchProfileId??"");const X=L.find(He=>He.sessionId===R)?.cwd??L.find(He=>pt?.sessionIds.includes(He.sessionId))?.cwd??"";Yt(X),Ct(""),pn(""),Ke(!0),Qt(!1)},ln=async()=>{if(!(!pt||!_t||yt&&!pt.launchProfiles?.some(X=>X.id===yt))){be("spawn-agent"),pe(null),ee(null);try{const X=await z8(pt.id,{agentSlug:pt.launchProfiles?.find(He=>He.id===yt)?.agentSlug??_t,...yt||pt.launchProfiles?.length?{launchProfileId:yt}:{},name:Rt.trim()||void 0,cwd:fr.trim()||void 0,task:Sr.trim()||void 0,mode:Z});Ke(!1),await _e(),ee(`“${X.session.name}”已创建并加入“${X.group.name}”`)}catch(X){pe(X instanceof Error?X.message:"Agent Session 创建失败")}finally{be(null)}}},Qr=WO(Ze,L),ks=X=>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:!Cm(X),checked:Fe.has(X.sessionId),onChange:()=>ke(He=>{const Nt=new Set(He);return Nt.has(X.sessionId)?Nt.delete(X.sessionId):Nt.add(X.sessionId),Nt})}),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:Iu(X,L)}),s.jsx(_m,{session:X}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:rf(X)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:X.currentTask?`${km(X.currentTask)} · ${X.cwd}`:X.cwd||X.capability||"终端会话"})]})]},X.sessionId),Dr=X=>{const He=tt[X.sessionId]??"",Nt=pt?.roles?.[X.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:!pt?.sessionIds.includes(X.sessionId)&&!Cm(X),checked:ht.has(X.sessionId),onChange:()=>q(Et=>{const tr=new Set(Et);return tr.has(X.sessionId)?tr.delete(X.sessionId):tr.add(X.sessionId),tr})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] text-foreground",children:X.name}),s.jsx(_m,{session:X}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[rf(X)," · ",X.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":`${X.name} 的定位`,className:`${$s} min-h-8 py-1 text-[10px]`,value:He,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:Et=>De(tr=>({...tr,[X.sessionId]:Et.target.value}))}),s.jsx("button",{"aria-label":`保存 ${X.name} 的定位`,title:He.trim()===Nt?"定位未变化":"保存此成员的定位",disabled:le!==null||He.trim()===Nt,className:`${vr} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{Tr(X.sessionId)},children:le===`role:${X.sessionId}`?s.jsx(bn,{size:12,className:"animate-spin"}):s.jsx(pi,{size:12})})]})]},X.sessionId)},en=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e||ze?"看板":"目标"],["messages","成员与消息"]].map(([X,He])=>s.jsxs("button",{type:"button","aria-label":He,"aria-pressed":Y===X,className:`${vr} min-h-11 ${Y===X?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:Nt=>{if(ze&&X==="tasks"){$?.(pt.id).catch(jr=>pe(jr instanceof Error?jr.message:"无法打开看板"));return}const Et=Nt.currentTarget.closest("[data-collaboration-views]"),tr=Nt.currentTarget;ce(X),requestAnimationFrame(()=>{const jr=document.activeElement;jr!==tr&&jr!==document.body&&jr?.isConnected&&!jr.closest("[hidden]")||Array.from(Et?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(cr=>cr.getAttribute("aria-pressed")==="true"&&!cr.closest("[hidden]"))?.focus()})},children:[e&&X==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:He})]}):He,!e&&X==="tasks"&&ye>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[ye," 待处理"]})]},X))}),xn=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":wt,className:`${vr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:X=>{Kt.current=X.currentTarget,zt(He=>!He),pe(null),ee(null)},children:[s.jsx(ju,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{ref:Vt,className:e?"flex min-h-0 flex-1 flex-col gap-3":ze?void 0:"space-y-3",children:[Ce&&ae==="ready"&&!af(Ce)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",Ce]}),Ce&&af(Ce)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?wt?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[!B&&m!=="new"&&S.length>0&&s.jsx("div",{hidden:wt,children:s.jsx(xO,{groups:S,sessions:L,busy:le!==null,onOpen:(X,He)=>{r?.(X,He)},onSettings:(X,He)=>{Ot.current=X,x(X),Kt.current=He,zt(!0),pe(null),ee(null)},onCreate:()=>{x("new"),nt(!1),ee(null)}})}),!B&&(m==="new"||wt)&&S.length>0&&s.jsx("button",{type:"button",className:`${vr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{wt?It():x(S[0].id)},children:"返回协作组"}),wt&&pt&&s.jsx(BO,{group:pt,agents:E,activeSessionId:R,sessions:L,busy:le,setBusy:be,setError:pe,setNotice:ee,refresh:_e,onClose:It},pt.id),!B&&v!=="loaded"&&!S.length&&s.jsx("p",{role:"status",className:"py-5 text-xs text-muted-foreground",children:v==="loading"?"正在加载协作组与会话…":"会话加载失败,请重试"}),!pt&&(B||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] ${Er>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",Er," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:$s,value:Be,onChange:X=>ne(X.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:["复用已有会话(选填) · 已选 ",Er," 个"]}),L.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(jl,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${$s} pl-8`,value:Ee,onChange:X=>Pe(X.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:[Ar.length<=1?rr.map(ks):Ar.map(X=>{const He=Xt(X.key);return s.jsxs("div",{children:[s.jsx(Rb,{label:X.label,count:X.sessions.length,collapsed:He,onToggle:()=>Zr(X.key)}),!He&&s.jsx("div",{className:"divide-y divide-border/10",children:X.sessions.map(ks)})]},X.key)}),L.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:v==="loading"?"正在加载会话…":v==="error"?"会话加载失败,请重试":"没有现有会话也可以创建,开始目标时会启动 Agent"}),L.length>0&&rr.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),re.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",re.length," 个所选会话暂不可用。",s.jsx("button",{className:vr,onClick:()=>ke(X=>new Set([...X].filter(He=>un.has(He)))),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] ${Er<2?"text-muted-foreground":"text-primary"}`,children:Be.trim()?"创建后进入成员消息,看板可随时使用":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[S.length>0&&s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>x(S[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:le!==null||!Be.trim()||re.length>0,className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{Jt()},children:[le==="create-group"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(zs,{size:13}),"创建协作组"]})]})]})]})]}),pt&&B&&s.jsxs("div",{"data-collaboration-views":!0,hidden:wt,className:e?`${wt?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:ze?void 0:"space-y-3",children:[!ze&&(!e||Y==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[en,s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e&&Y==="messages"&&s.jsxs("button",{type:"button","aria-label":"放到终端旁",title:V?"在当前终端分屏中使用成员与消息":"先打开一个终端,再嵌入消息面板",disabled:!V||le!==null,className:`${vr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{be("dock-messages"),pe(null),V?.().catch(X=>pe(X instanceof Error?X.message:"消息面板打开失败,草稿已保留")).finally(()=>be(null))},children:[s.jsx(Fc,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"放到终端旁"})]}),xn]})]}),!ze&&Y==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:ir.map(X=>s.jsx("button",{type:"button","aria-pressed":X.sessionId===R,title:`${X.name} · ${X.cwd||"终端会话"}`,className:`${vr} min-h-9 shrink-0 ${X.sessionId===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{O(X).catch(He=>pe(He instanceof Error?He.message:"无法打开终端"))},children:Iu(X,ir)},X.sessionId))}),!ze&&s.jsx("div",{hidden:Y!=="tasks",className:e?`${Y==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(LO,{paneKey:d?Gr:void 0,boardNavigation:e?en:void 0,boardSettings:e?xn:void 0,board:e,group:pt,sessions:L,agents:E,defaultCwd:L.find(X=>X.sessionId===R)?.cwd??void 0,onTeamReady:_e,active:n&&!wt&&Y==="tasks"&&(!w||y),onAttentionChange:Le,onManageMembers:()=>ce("messages"),onOpenSession:O},pt.id)}),s.jsxs("div",{hidden:Y!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>s0(Gr),onPointerDownCapture:()=>s0(Gr),"data-termdock-terminal-dropzone":w?R??"collaboration-composer":void 0,onDragOver:X=>{w&&X.preventDefault()},onDrop:X=>{if(!w)return;const He=Array.from(X.dataTransfer.files);if(!(He.length&&vo()))if(X.preventDefault(),X.stopPropagation(),He.length)zr(He);else{const Nt=X.dataTransfer.getData("text/plain")||X.dataTransfer.getData("text/uri-list");Nt&&St(Et=>Et+(Et?`
162
+ `:"")+Nt)}},ref:dr,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:[pt.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:X=>{X.key==="Escape"&&(X.currentTarget.removeAttribute("open"),X.currentTarget.querySelector("summary")?.focus(),X.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(To,{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:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:X=>{X.currentTarget.closest("details")?.removeAttribute("open"),$?.(pt.id).catch(He=>pe(He instanceof Error?He.message:"无法打开看板"))},children:[s.jsx(Fc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":qe,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:X=>{X.currentTarget.closest("details")?.removeAttribute("open"),we(He=>!He)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":wt,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:X=>{X.currentTarget.closest("details")?.removeAttribute("open"),Kt.current=X.currentTarget,zt(!0),pe(null),ee(null)},children:[s.jsx(ju,{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:"全组成员"},...pt.sessionIds.map(X=>({id:X,label:(()=>{const He=ir.find(Nt=>Nt.sessionId===X);return He?Iu(He,ir):void 0})()??`${X.slice(0,8)}(离线)`}))].map(({id:X,label:He})=>{const Nt=X==="*"?Ae===null:Ae?.includes(X)??!1,Et=L.find(tr=>tr.sessionId===X);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":Nt,onClick:()=>Ye(tr=>X==="*"?null:tr?.includes(X)?tr.filter(jr=>jr!==X):[...tr??[],X]),className:`${N1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Nt?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Nt&&s.jsx(pi,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:He})]}),Et&&s.jsx("button",{type:"button","aria-label":`打开 ${He} 的终端`,title:`打开 ${He} 的终端`,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:()=>{z(Et).catch(tr=>pe(tr instanceof Error?tr.message:"无法打开会话"))},children:s.jsx(Fc,{size:12})})]},X)})})]})]}),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:X=>{X.key==="Enter"&&(X.metaKey||X.ctrlKey)&&!X.nativeEvent.isComposing&&X.keyCode!==229&&(X.preventDefault(),Hr())},onPaste:X=>{const He=Array.from(X.clipboardData.files);He.length&&(X.preventDefault(),zr(He))},className:`${$s} min-h-16 max-h-48 resize-y`,value:et,onChange:X=>St(X.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:Mn>0?"正在准备文件路径…":w&&a?a:pt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:le!==null||Mn>0||!et.trim()||!Pr.length,className:`${vr} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Hr()},children:[le==="send-message"?s.jsx(bn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:ze&&!qe,open:ze?qe:void 0,onToggle:X=>{ze&&we(X.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:["管理成员、角色与删除 · ",pt.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:pt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[pt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:Y6(pt.id)})]})]}),We?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${vr} bg-surface-2 px-2 text-foreground`,onClick:()=>nt(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${vr} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{ps()},children:[le===`delete:${pt.id}`?s.jsx(bn,{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:`${vr} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{q(new Set(pt.sessionIds)),qt(pt.updatedAt);const X=!Gt;Qt(X),X&&De(Object.fromEntries(pt.sessionIds.map(He=>[He,pt.roles?.[He]??""]))),Ke(!1)},children:[s.jsx(ju,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${vr} px-2 text-primary hover:bg-primary/10`,onClick:Jr,children:[s.jsx(zs,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${pt.name}`,title:"删除协作组",disabled:le!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{ue(pt.updatedAt),nt(!0)},children:s.jsx(Rs,{size:14})})]})]}),We&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",pt.name,"”协作组及其协作记录,",pt.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:pt.sessionIds.map(X=>{const He=L.find(tr=>tr.sessionId===X),Nt=pt.roles?.[X],Et=He?.name??X;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${xe===X?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!He,onClick:()=>He&&void z(He).catch(tr=>pe(tr instanceof Error?tr.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 ${He&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(He.status)&&He.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:Et}),He&&s.jsx(_m,{session:He}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:He?rf(He):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Nt?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Nt]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,He?s.jsx("span",{className:"min-w-0 truncate",children:km(He.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${Et} 移出协作组`,"aria-expanded":xe===X,title:"移出协作组",disabled:le!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${xe===X?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>Ve(xe===X?null:X),children:s.jsx(Rs,{size:13})})]},X)})}),xe&&pt.sessionIds.includes(xe)&&(()=>{const X=L.find(Nt=>Nt.sessionId===xe)?.name??xe,He=le===`remove-member:${xe}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${X}`,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:`把“${X}”移出“${pt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${vr} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Ve(null),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${vr} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{jn(xe)},children:[He?s.jsx(bn,{size:12,className:"animate-spin"}):s.jsx(Rs,{size:12}),"移出"]})]})]})})(),Gt&&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:["已选 ",ht.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Fr.length<=1?mt.map(Dr):Fr.map(X=>{const He=Xt(X.key);return s.jsxs("div",{children:[s.jsx(Rb,{label:X.label,count:X.sessions.length,collapsed:He,onToggle:()=>Zr(X.key)}),!He&&s.jsx("div",{className:"divide-y divide-border/10",children:X.sessions.map(Dr)})]},X.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>{Qt(!1),De({})},children:"取消"}),s.jsxs("button",{disabled:le!==null||v!=="loaded",className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{Mr()},children:[le==="save-members"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(pi,{size:13}),"保存成员"]})]})]}),nr&&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(bO,{group:pt,value:yt,onChange:xt,disabled:le!==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:$s,disabled:!!yt,value:pt.launchProfiles?.find(X=>X.id===yt)?.agentSlug??_t,onChange:X=>$t(X.target.value),children:E.map(X=>s.jsxs("option",{value:X.slug,children:[X.displayName,X.isPlugin?" · Plugin":""]},X.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:$s,value:Rt,onChange:X=>Ct(X.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:$s,value:fr,onChange:X=>Yt(X.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:`${$s} min-h-16 resize-y`,value:Sr,onChange:X=>pn(X.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>Ke(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null||!_t||!!yt&&!pt.launchProfiles?.some(X=>X.id===yt),className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{ln()},children:[le==="spawn-agent"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(R0,{size:13}),"创建并加入"]})]})]})]})]},pt.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:[Qr.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[Qr.map(X=>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:X.responseKind==="ack"?"收到确认":X.responseKind==="progress"?"进展":X.responseKind==="result"?"结果":HO(X.kind)}),s.jsx("span",{children:X.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:X.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(X.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:X.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:X.status==="pending"?"已入队 · 等待投递":X.status==="failed"?"投递失败":X.status==="expired"?"消息已过期,未继续投递":X.status==="stored"?"答复已持久保存 · 供后台接收":"已写入接收方终端 · 等待接手确认"}),(X.task||X.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(X.task??{failure_reason:X.failureReason},null,2)})]})]},X.key)),Qr.length===0&&s.jsx(JO,{text:Ie?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function BO({group:e,agents:t,activeSessionId:r,sessions:n,busy:a,setBusy:c,setError:l,setNotice:d,refresh:p,onClose:m}){const x=n.filter(Y=>e.sessionIds.includes(Y.sessionId)&&!$u(Y.sessionId)),[y,w]=b.useState(()=>EO(e,r&&x.some(Y=>Y.sessionId===r)?r:"")),v=b.useRef(y),[S,L]=b.useState(null),E=Y=>{const ce={...v.current,...Y};v.current=ce,NO(e.id,ce),w(ce)},{name:R,rules:B,savedName:z,savedRules:O,rulesVersion:$,rulesMemberId:V}=y,Z=Qf(y),le=new TextEncoder().encode(B).length,be=x.some(Y=>Y.sessionId===V),pe=async()=>{if(!(a||!R.trim())){c("group-name"),l(null),d(null);try{const Y=await Ml({id:e.id,name:R.trim(),sessionIds:y.sessionIds??e.sessionIds,expectedUpdatedAt:y.updatedAt});L(null),E({savedName:Y.group.name,name:Y.group.name,updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,...B===O?{rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}:{}}),await p(),d("协作组名称已更新")}catch(Y){L(null),l(Y instanceof n0&&Y.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"改名失败")}finally{c(null)}}},ee=async()=>{if(!(a||!be||le>8192)){c("group-rules"),l(null),d(null);try{const Y=await W8(e.id,{sessionId:V,text:B,expectedVersion:$});L(null),E({savedName:Y.group.name,...R===z?{name:Y.group.name}:{},updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}),await p(),d(B.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(Y){L(null),l(Y instanceof n0&&Y.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"群规保存失败")}finally{c(null)}}},_e=()=>{E(Eg(e,V)),L(null),l(null)},ze=async()=>{if(!a){c("group-latest"),l(null),d(null),L(null);try{const ce=(await Q1()).groups.find(qe=>qe.id===e.id);if(!ce)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");L(ce)}catch(Y){l(Y instanceof Error?Y.message:"最新状态读取失败;草稿仍保留,请重试。")}finally{c(null)}}};return s.jsxs("section",{"aria-label":"协作组设置",onKeyDown:Y=>{Y.key!=="Escape"||Y.defaultPrevented||Y.nativeEvent.isComposing||(Y.preventDefault(),Y.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(In,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:$s,value:R,maxLength:240,disabled:!!a,onChange:Y=>E({name:Y.target.value})})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!a||!!S||!R.trim()||R.trim()===z,className:`${vr} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{pe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(yO,{group:e,agents:t,busy:a,setBusy:c,refresh:p}),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:$s,value:V,disabled:!!a||!x.length,onChange:Y=>E({rulesMemberId:Y.target.value}),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!x.some(Y=>Y.sessionId===V)&&V&&s.jsx("option",{value:V,children:"原成员已不在组内,请重新选择"}),x.map(Y=>s.jsx("option",{value:Y.sessionId,children:Y.name},Y.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${$s} min-h-24 resize-y`,value:B,maxLength:8192,disabled:!!a,onChange:Y=>E({rules:Y.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!be&&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] ${le>8192?"text-destructive":"text-muted-foreground"}`,children:le>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!S||!be||le>8192||B===O,className:`${vr} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{ee()},children:a==="group-rules"?"保存中…":B.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:`${vr} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{ze()},children:a==="group-latest"?"读取中…":"查看最新状态并保留草稿"}),S&&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:["当前名称:",S.name]}),s.jsxs("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:["当前群规:",S.instructions?.text||"未设置"]}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前成员(",S.sessionIds.length,"):",S.sessionIds.map(Y=>n.find(ce=>ce.sessionId===Y)?.name??Y6(Y)).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:`${vr} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{E(IO(v.current,S)),L(null),l(null),d("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${vr} min-h-11 text-muted-foreground`,onClick:()=>L(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:`${vr} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:_e,children:[s.jsx(bn,{size:12}),"重新载入",Z&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${vr} min-h-9 bg-surface text-foreground`,onClick:m,children:Z?"关闭并保留草稿":"关闭"})]})]})}function QO({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:c,onSelectGroup:l}){const[d,p]=b.useState(null),[m,x]=b.useState(!1),y=e.services??[],w=e.removedServices??[],v=y.filter(E=>!E.connected),S=v.some(E=>E.groups?.some(R=>R.id===t)),L=async(E,R)=>{if(!r){n(`peer:${E}`),a(null),c(null);try{R?await K8(E):await X8(E),p(null),x(!1),c(R?"协作连接已恢复,正在连接服务":"协作连接已移除,不会再自动重连;已有会话和消息保留")}catch(B){a(B instanceof Error?B.message:R?"重新连接失败":"移除连接失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-4 shrink-0 rounded-lg border border-border/15",open:S||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:S?"当前协作组的部分服务不可达,消息会保留并等待重连。":"其他服务暂时离线;当前服务内的协作可以继续。不再使用的连接可移除。"}),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(E=>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:[uc({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${E.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:E.connected?"已连接":E.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx(PO,{service:E})]}),E.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${E.origin}`,className:`${vr} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>p(d===E.serviceId?null:E.serviceId),children:[s.jsx(Rs,{size:12}),"移除"]})]}),!!E.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:"用于"}),E.groups.map(R=>s.jsx("button",{type:"button",className:"rounded px-1.5 py-1 text-primary hover:bg-primary/10",onClick:()=>l(R.id),children:R.name},R.id))]}),!E.connected&&E.error&&E.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:GO(E.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:E.error})]}),d===E.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:E.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${vr} min-h-9 text-muted-foreground`,onClick:()=>p(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!E.groups?.length,className:`${vr} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{L(E.serviceId,!1)},children:r===`peer:${E.serviceId}`?"正在移除…":"确认移除"})]})]})]},E.serviceId||E.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:`${vr} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:Z8,children:[s.jsx(bn,{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:`${vr} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(E=>!E),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(E=>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:[uc({serviceLabel:E.label,serviceOrigin:E.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:E.accessUrl||E.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!E.serviceId,className:`${vr} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{L(E.serviceId,!0)},children:r===`peer:${E.serviceId}`?"恢复中…":"恢复连接"})]},E.serviceId||E.origin))})]})]})]})]},S?"affected":"other")}function PO({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 Cm(e){return!$u(e.sessionId)||e.serviceConnected!==!1}function OO(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:$u(e.sessionId)?.origin??""}function Nb(e){const t=new Map;for(const r of e){const n=OO(r),a=t.get(n)??{key:n,label:n?uc(r):"本机服务",sessions:[]};n&&a.label==="远端服务"&&(a.label=uc(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 Rb({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(ul,{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 FO(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,...$u(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function _m({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(Fc,{size:9}),s.jsx("span",{className:"truncate",children:uc(e)})]})}function rf(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":zO(e.status)}function $O(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:")?uc(e):"本机服务";return r?`${e.name} · ${n}`:e.name}async function UO(e){e.sessionId.startsWith("remote:")?await A6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function zO(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function km(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return Pf(t.prompt)||"暂无任务摘要"}catch{}return Pf(e)||"暂无任务摘要"}function HO(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function WO(e,t){const r=new Map(t.map(a=>[a.sessionId,$O(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);const p={failed:-2,expired:-1,pending:0,delivered:1,read:2,stored:3};p[a.status]<p[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})}return[...n.values()].sort((a,c)=>c.createdAt-a.createdAt)}function GO(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 Lm({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 VO({active:e,onClose:t,onNewSession:r,setError:n}){const[a,c]=b.useState(""),[l,d]=b.useState([]),[p,m]=b.useState(0),[x,y]=b.useState(),[w,v]=b.useState(50),[S,L]=b.useState(0),[E,R]=b.useState(!1),[B,z]=b.useState(null),[O,$]=b.useState(null),V=b.useRef(null),Z=b.useRef(0);b.useEffect(()=>{e&&V.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const pe=++Z.current,ee=new AbortController;let _e;z(null),R(!0);const ze=async()=>{try{const Y=await J8(a.trim(),w,ee.signal);if(pe!==Z.current)return;d(Y.results),m(Y.total??Y.results.length),y(Y.index),Y.index?.building&&(_e=window.setTimeout(()=>{ze()},2500))}catch(Y){pe===Z.current&&!ee.signal.aborted&&z(Y instanceof Error?Y.message:"搜索失败")}finally{pe===Z.current&&R(!1)}};return _e=window.setTimeout(()=>{ze()},a.trim()?250:0),()=>{window.clearTimeout(_e),ee.abort(),++Z.current}},[e,a,w,S]);const le=pe=>{n(null),c(pe),d([]),m(0),v(50)},be=async pe=>{if(!O){if(pe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:pe.sessionId})),t();return}if(!(!pe.nativeKey&&!pe.resumeHistoryId)){$(pe.sessionId),n(null);try{const ee=pe.nativeKey?await e9(pe.nativeKey):await Ry(pe.resumeHistoryId);if("sessionId"in ee&&ee.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:ee.sessionId}));else if(ee.command)r({mode:"shell",cwd:ee.cwd,command:ee.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(ee){n(ee instanceof Error?ee.message:"恢复失败")}finally{$(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(jl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:V,maxLength:512,className:`${$s} pl-9 pr-9`,value:a,onChange:pe=>le(pe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),E?s.jsx(bn,{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:()=>le(""),children:s.jsx(In,{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()?`找到 ${p} 个会话`:"最近的会话",p>l.length?` · 显示 ${l.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:E,className:`${vr} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>L(pe=>pe+1),children:[s.jsx(bn,{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 ee=pe.live||!!(pe.nativeKey||pe.resumeHistoryId),_e=O===pe.sessionId?"正在恢复…":pe.live?"打开会话":ee?"恢复会话":"仅供查阅",ze=pe.source==="codex"||pe.source==="claude"?pe.snippet:qO(pe),Y=pe.source==="codex"?"Codex 历史":pe.source==="claude"?"Claude 历史":"终端记录",ce=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(Lm,{value:pe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(Lm,{value:pe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${pe.live?"text-[var(--success)]":ee?"text-primary":"text-muted-foreground"}`,children:_e})]}),ze&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(Lm,{value:ze,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Y," · ",Of(pe.updatedAt),a.trim()?` · ${pe.matchCount>=999?"999+":pe.matchCount} 处匹配`:"",ee?"":" · 没有可恢复记录"]}),pe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:pe.agentNativeSessionId})]});return ee?s.jsx("button",{disabled:!!O,onClick:()=>{be(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:ce},pe.nativeKey||pe.sessionId):s.jsx("article",{className:"px-2 py-3",children:ce},pe.sessionId)})}),p>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:E,className:`${vr} w-full bg-surface-2 text-foreground`,onClick:()=>v(pe=>pe+50),children:E?"正在加载…":"加载更多会话"}),B&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",B,s.jsx("button",{type:"button",className:`${vr} ml-2`,onClick:()=>L(pe=>pe+1),children:"重试"})]}),!E&&!B&&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:`${vr} mt-3 bg-surface-2 text-foreground`,onClick:()=>le(""),children:"查看最近会话"})]})]})}function Pf(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 qO(e){let t=Pf(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return Pf(t)}function YO(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 ZO(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 Of(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function KO(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function XO(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function JO({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})}function eF({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=Ur(),[a,c]=b.useState(!1),l=b.useRef(null),d=b.useRef(null),p=b.useRef(null),m=b.useId();return b.useLayoutEffect(()=>{if(!a)return;const x=l.current,y=p.current;if(!x||!y)return;const w=window.visualViewport,v=()=>{const L=x.getBoundingClientRect(),E=(w?.offsetLeft??0)+8,R=(w?.offsetTop??0)+8,B=(w?.width??window.innerWidth)-16,z=(w?.offsetTop??0)+(w?.height??window.innerHeight)-8,O=Math.max(0,Math.min(256,B)),$=Math.max(0,L.top-R-4),V=Math.max(0,z-L.bottom-4),Z=$>=180||$>=V;Object.assign(y.style,{width:`${O}px`,left:`${Math.max(E,Math.min(L.right-O,E+B-O))}px`,top:`${Z?L.top-4:L.bottom+4}px`,maxHeight:`${Z?$:V}px`,transform:Z?"translateY(-100%)":"none"})};v();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return S?.observe(x),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),w?.addEventListener("resize",v),w?.addEventListener("scroll",v),()=>{S?.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),w?.removeEventListener("resize",v),w?.removeEventListener("scroll",v)}},[a]),b.useEffect(()=>{if(!a)return;p.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const x=y=>{y.target instanceof Node&&!l.current?.contains(y.target)&&!p.current?.contains(y.target)&&c(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[a]),s.jsxs("div",{ref:l,role:"group","data-sidebar-gesture-ignore":!0,"aria-label":n("sidebar.moreActions"),className:"relative z-20 mt-2 flex items-center justify-between gap-2",onKeyDown:x=>{a&&x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),c(!1),d.current?.focus({preventScroll:!0}))},children:[s.jsxs("button",{type:"button",onClick:e,title:t?n("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(bS,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:n("sidebar.settings")})]}),s.jsxs("button",{ref:d,type:"button","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?m:void 0,onClick:()=>c(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),c(!0))},className:`inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${a?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(To,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&Xs.createPortal(s.jsx("div",{ref:p,id:m,role:"menu","data-sidebar-gesture-ignore":!0,"data-sidebar-composer-popover":"sidebar-launch-options","aria-label":n("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:x=>{const y=[...x.currentTarget.querySelectorAll('[role="menuitem"]')],w=y.indexOf(document.activeElement);let v;if(x.key==="ArrowDown")v=(w+1)%y.length;else if(x.key==="ArrowUp")v=(w-1+y.length)%y.length;else if(x.key==="Home")v=0;else if(x.key==="End")v=y.length-1;else if(x.key==="Tab"){c(!1);return}else return;x.preventDefault(),y[v]?.focus({preventScroll:!0})},children:r.map(({label:x,icon:y,onSelect:w,separated:v})=>s.jsxs("div",{role:"none",children:[v&&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:()=>{c(!1),w()},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(y,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{children:x})]})]},x))}),document.body)]})}const Fd=64,Mb=10,tF=120;function rF({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:c,compact:l}){const d=b.useRef(null),p=b.useRef(null),m=b.useRef(0),[x,y]=b.useState(null),w=x??(t?Fd:0);return b.useEffect(()=>{if(!t)return;const v=S=>{S.target instanceof Node&&!d.current?.contains(S.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){p.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(p.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?Fd:0,offset:t?Fd:0,horizontal:!1})}},onPointerMove:v=>{const S=p.current;if(!S||S.pointerId!==v.pointerId)return;const L=v.clientX-S.x,E=v.clientY-S.y;if(!S.horizontal){if(v.defaultPrevented||Date.now()-S.startedAt>=tF||Math.abs(E)>Mb){p.current=null;return}if(Math.abs(L)<=Mb)return;if(Math.abs(L)<Math.abs(E)*1.5||!t&&L<0){p.current=null;return}S.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),S.offset=Math.max(0,Math.min(Fd,S.initialOffset+L)),y(S.offset)},onPointerUp:v=>{const S=p.current;!S||S.pointerId!==v.pointerId||(p.current=null,S.horizontal&&(m.current=Date.now()+600,r(S.offset>=Fd/2),y(null)))},onPointerCancel:()=>{p.current?.horizontal&&(m.current=Date.now()+600),p.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(Rs,{size:14}),a]})}),e]})}const jb="recoverable-tmux";function nF({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=Ur(),d=Wt(R=>R.collapsedGroups.has(jb)),p=Wt(R=>R.toggleGroupCollapsed),[m,x]=b.useState(null),[y,w]=b.useState(null),[v,S]=b.useState(null),L=b.useRef(!1),E=async R=>{if(!(!c||L.current)){L.current=!0,w(R),S(null);try{await c(R),x(null)}catch(B){S(B instanceof Error?B.message:l("sidebar.closeRecoverableSessionFailed"))}finally{L.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:()=>p(jb),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(Qc,{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(bn,{size:11,className:t?"animate-spin":""})})]}),!d&&s.jsx("div",{className:"space-y-0.5",children:e.map(R=>{const B=R.friendlyName?.trim()||R.label?.trim()||R.name,z=Ku(R.cwd??null),O=r===R.name,$=m===R.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||$,onClick:()=>a(R),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:B}),title:R.cwd||R.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:O?s.jsx(_n,{size:12,className:"animate-spin"}):s.jsx(qc,{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:B}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[R.program,z].filter(Boolean).join(" · ")||`tmux:${R.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:l(O?"sidebar.restoringRecoverableSession":"sidebar.restore")})]}),c&&s.jsx("button",{type:"button",disabled:r!==null||y!==null,onClick:()=>{x(R.name),S(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:B}),title:l("sidebar.closeSession",{name:B}),children:s.jsx(In,{size:12})})]}),$&&s.jsxs("div",{role:"group","aria-label":l("sidebar.closeSession",{name:B}),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:B})}),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),S(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:()=>{E(R.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===R.name?l("common.loading"):l("sidebar.endRecoverableSession")})]})]})]},R.name)})})]})}const $d="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",Db="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 sF({group:e,collapsed:t,onOpen:r,onMessages:n,onToggleCollapsed:a,onChanged:c,children:l}){const[d,p]=b.useState(null),[m,x]=b.useState(null),[y,w]=b.useState(""),[v,S]=b.useState(!1),L=b.useRef(!1),[E,R]=b.useState(""),B=b.useRef(null),z=b.useRef(null),O=b.useRef(null),$=b.useRef(null),V=b.useRef(null),Z=b.useId(),le=Cg(),be=()=>V.current?.isConnected?V.current:z.current,pe=()=>{L.current||(x(null),R(""))};Gc(O,!!d,()=>p(null),be),Gc($,!!m,pe,be);const ee=ce=>{V.current=document.activeElement instanceof HTMLElement&&B.current?.contains(document.activeElement)?document.activeElement:z.current;const qe=z.current?.getBoundingClientRect();p(ce??{x:qe?.left??8,y:qe?.bottom??8})};b.useEffect(()=>{d&&O.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0})},[d]),b.useEffect(()=>{if(!d)return;const ce=we=>{we.target instanceof Node&&!O.current?.contains(we.target)&&!B.current?.contains(we.target)&&p(null)},qe=we=>{we.target instanceof Node&&O.current?.contains(we.target)||p(null)};return document.addEventListener("pointerdown",ce),window.addEventListener("resize",qe),window.addEventListener("scroll",qe,!0),()=>{document.removeEventListener("pointerdown",ce),window.removeEventListener("resize",qe),window.removeEventListener("scroll",qe,!0)}},[d]),b.useLayoutEffect(()=>{if(!d||!O.current)return;const ce=window.visualViewport,qe=(ce?.offsetLeft??0)+8,we=(ce?.offsetTop??0)+8,ye=Math.min(240,(ce?.width??innerWidth)-16),Le=we+(ce?.height??innerHeight)-16;Object.assign(O.current.style,{width:`${ye}px`,maxHeight:`${Le-we}px`,left:`${Math.max(qe,Math.min(d.x,qe+(ce?.width??innerWidth)-16-ye))}px`,top:`${Math.max(we,Math.min(d.y,Le-O.current.offsetHeight))}px`})},[d]);const _e=ce=>{p(null),ce()},ze=ce=>{R(""),w(e.name),x({kind:ce,group:e})},Y=async()=>{if(!(!m||L.current||m.kind==="rename"&&!y.trim())){L.current=!0,S(!0),R("");try{const ce=m.group,qe=m.kind==="delete"?(await Ey(ce.id,ce.updatedAt),null):(await Ml({id:ce.id,name:y.trim(),sessionIds:ce.sessionIds,expectedUpdatedAt:ce.updatedAt})).group;x(null),c(qe)}catch(ce){const qe=ce instanceof Error?ce.message:"操作失败,请重试";R(qe.includes("协作组已变化")?"协作组刚刚发生变化,请取消后重新打开操作。":qe)}finally{L.current=!1,S(!1)}}};return s.jsxs("div",{ref:B,className:"flex min-w-0 items-center","data-sidebar-gesture-ignore":!0,...le(()=>ee()),onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),ee({x:ce.clientX,y:ce.clientY})},onKeyDown:ce=>{(ce.key==="ContextMenu"||ce.shiftKey&&ce.key==="F10")&&(ce.preventDefault(),ce.stopPropagation(),ee())},children:[l,s.jsx("button",{ref:z,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:ce=>{ce.stopPropagation(),d?p(null):ee()},children:s.jsx(To,{size:14})}),d&&Xs.createPortal(s.jsxs("div",{ref:O,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:ce=>{const qe=Array.from(ce.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)')),we=qe.indexOf(document.activeElement),ye=ce.key==="ArrowDown"?(we+1)%qe.length:ce.key==="ArrowUp"?(we-1+qe.length)%qe.length:ce.key==="Home"?0:ce.key==="End"?qe.length-1:null;ye!==null&&(ce.preventDefault(),ce.stopPropagation(),qe[ye]?.focus({preventScroll:!0})),ce.key==="Tab"&&(ce.preventDefault(),p(null))},children:[s.jsxs("button",{role:"menuitem",tabIndex:-1,className:$d,onClick:()=>_e(r),children:[s.jsx(qc,{size:15}),"打开看板"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,disabled:!n,className:`${$d} disabled:opacity-40`,onClick:()=>_e(()=>n?.()),children:[s.jsx(Xu,{size:15}),"成员与消息"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:$d,onClick:()=>_e(a),children:[s.jsx(Ks,{size:15,className:t?"":"rotate-90"}),t?"展开成员会话":"收起成员会话"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:$d,onClick:()=>_e(()=>ze("rename")),children:[s.jsx(ju,{size:15}),"重命名协作组"]}),s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:`${$d} text-destructive`,onClick:()=>_e(()=>ze("delete")),children:[s.jsx(Rs,{size:15}),"删除协作组"]})]}),document.body),m&&Xs.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:$,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"?"删除协作组":"重命名协作组"}),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(In,{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&&"删除会同步到其他服务。"]}):"修改协作组的名称。"}),s.jsxs("form",{onSubmit:ce=>{ce.preventDefault(),Y()},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:ce=>w(ce.target.value)})]}),E&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs leading-5 text-destructive",children:E}),s.jsxs("footer",{className:"mt-4 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:v,className:`${Db} bg-surface-2`,onClick:pe,children:"取消"}),s.jsxs("button",{type:"submit",disabled:v||m.kind==="rename"&&!y.trim(),className:`${Db} inline-flex items-center gap-2 ${m.kind==="delete"?"bg-destructive text-destructive-foreground":"bg-primary text-primary-foreground"}`,children:[v&&s.jsx(bn,{size:14,className:"animate-spin"}),v?m.kind==="delete"?"正在删除…":"正在保存…":m.kind==="delete"?"确认删除":"保存名称"]})]})]})]})]}),document.body)]})}function iF(e,t){return qy(e,t)}function Ud(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 zd(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,p=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 S=y.sessionIds.flatMap(L=>{const E=r.get(L);return E?[E]:[]});m.push({kind:"collaboration",id:`collaboration:${y.id}`,group:y,members:S,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(p.has(w.id))continue;p.add(w.id);const v=w.sessionIds.flatMap(S=>{const L=r.get(S);return L?[L]:[]});m.push({kind:"workspace",id:`workspace:${w.id}`,workspace:w,members:v,sessionIds:w.sessionIds})}return m}function Bb(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 aF({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(UP,{status:e,detail:t,needsReview:r,inCopyMode:n})}function Qb({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:c,sessionStates:l,onJumpToNextAttention:d,onNewSession:p,onCloseSession:m,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:w,splitWorkspaces:v,onSetSplitLayout:S,onReorderSplitWorkspace:L,onCombineSplitSessions:E,onReorderSessions:R,onSessionMenu:B,onOpenSettings:z,onOpenQuota:O,updateState:$,updateActionPending:V=!1,onConfirmUpdateRestart:Z,onRetryUpdate:le,serverHealthState:be,tmuxAvailable:pe=!0,defaultSessionMode:ee="shell",push:_e,pinned:ze,onTogglePinned:Y,recoverableTmuxSessions:ce=[],recoverableTmuxSessionsLoading:qe=!1,onRefreshRecoverableTmuxSessions:we,onCloseRecoverableTmuxSession:ye}){const{t:Le}=Ur(),[,Be]=b.useState(0),[ne,Fe]=b.useState(null),[ke,Ee]=b.useState(!1),[Pe,Ne]=b.useState(!1),[oe,We]=b.useState(null),nt=b.useRef(!1),gt=b.useRef(0),ue=b.useCallback(G=>{G||(gt.current+=1),Ee(G)},[]),[Ze,at]=b.useState(!1),Ie=Ei(G=>G.groupId),[Ge,Ce]=b.useState({}),H=Ze||Object.keys(Ge).length>0,ae=b.useRef(!1),Ae=b.useRef(!1),[Ye,et]=b.useState(null);b.useEffect(()=>{let G=!1;return fc().then(Me=>{G||ae.current||Ce(Object.fromEntries(r3(Me.collaborationPanels?.[Uf()]).map($e=>[$e,!0])))}).catch(()=>{}),()=>{G=!0}},[]);const St=async(G,Me)=>{ae.current=!0,await Fa({floatingGroupId:Me},G),Ce($e=>({...$e,[G]:Me!==null}))},[Gt,Qt]=b.useState([]),[wt,zt]=b.useState(!1),[Vt,Kt]=b.useState(null),[Ot,It]=b.useState(null),[xe,Ve]=b.useState(null),[ht,q]=b.useState(null),ut=Lu(G=>G.tasks),qt=Lu(G=>G.allTasks),[tt,De]=b.useState(0),[nr,Ke]=b.useState(null),_t=b.useRef(!1),[$t,yt]=b.useState({}),xt=Lu(G=>G.error),[Rt,Ct]=b.useState(!1);b.useEffect(()=>{const G=()=>{document.hidden||Lu.getState().refresh()};G();const Me=window.setInterval(G,5e3);return document.addEventListener("visibilitychange",G),()=>{clearInterval(Me),document.removeEventListener("visibilitychange",G)}},[]);const fr=async G=>(ue(!1),ae.current=!0,G?(Ei.getState().open(G),Qr(),!0):(at(!0),Qr(),!0)),Yt=df(G=>G.collaborationGroups),Sr=df(G=>G.setCollaborationGroups),[pn,dr]=b.useState({mode:ee}),{preference:me,agents:Gr,detecting:ot,refresh:pt,selectAgent:ir}=gO(),Mn=b.useRef(null),Xr=!!($?.latestVersion&&["installing","ready","restarting","error"].includes($.status)),je=!!be?.attention,st=[Le("sidebar.moreActions"),je?Le("sidebar.serverAttention"):null,Xr&&$?.latestVersion?Le("sidebar.updateAvailable",{version:$.latestVersion}):null].filter(Boolean).join(": "),bt=Wt(G=>G.groupByFolder),Br=Wt(G=>G.collapsedGroups),Vr=Wt(G=>G.toggleGroupCollapsed),Cr=b.useRef(null),qr=b.useRef(null),mn=b.useRef(null),on=b.useRef(0),zr=b.useRef(!1),un=b.useRef(null),Er=b.useRef(null),[re,mt]=b.useState(!1),Mt=b.useRef([]),rr=b.useRef(null),Ar=b.useRef(null),Fr=b.useRef(new Set),Xt=b.useRef(null),Zr=b.useMemo(()=>new Set(v.flatMap(G=>G.sessionIds)),[v]),Jt=b.useMemo(()=>new Map(a.map(G=>[G.id,G])),[a]),Pr=b.useMemo(()=>iF(Yt,new Set(Jt.keys())),[Yt,Jt]),Hr=b.useCallback(async()=>{const G=++on.current;try{const Me=await Q1();if(G!==on.current)return;Sr(Array.isArray(Me.groups)?Me.groups:[])}catch{}},[]);b.useEffect(()=>Ny(G=>Sr(G.groups)),[]),b.useEffect(()=>{Hr();const G=window.setInterval(()=>{Hr()},1e4),Me=()=>{Hr()};return window.addEventListener("focus",Me),()=>{on.current+=1,window.clearInterval(G),window.removeEventListener("focus",Me)}},[Hr]),b.useEffect(()=>{(e||!H)&&Hr()},[H,e,Hr]);const ps=b.useCallback(()=>{Mt.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(G=>{const Me=G.dataset.collaborationMember??"",$e=G.hasAttribute("data-collaboration-background"),Je=G.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!Me&&!$e||!Je)return[];const it=[];for(let Tt=G.parentElement;Tt;Tt=Tt.parentElement)it.push({element:Tt,top:Tt.scrollTop,left:Tt.scrollLeft});return[{element:G,sessionId:Me,groupId:Je,background:$e,rect:G.getBoundingClientRect(),scrollParents:it}]})},[]),Mr=b.useCallback((G,Me)=>{if(!zr.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(K=>K.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(K=>K.removeAttribute("data-drop-active"));const Je=document.elementsFromPoint(G,Me).map(K=>K.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(Je?.dataset.collaborationGroup){Je.dataset.dropActive="true",Ar.current={kind:"collaboration",groupId:Je.dataset.collaborationGroup,background:!0};return}const it=Mt.current.find(K=>{if(K.sessionId===Er.current||!K.element.isConnected)return!1;const fe=K.scrollParents.reduce((ve,lt)=>ve+lt.element.scrollLeft-lt.left,0),Qe=K.scrollParents.reduce((ve,lt)=>ve+lt.element.scrollTop-lt.top,0);return G>=K.rect.left-fe&&G<=K.rect.right-fe&&Me>=K.rect.top-Qe+K.rect.height*.25&&Me<=K.rect.bottom-Qe-K.rect.height*.25});if(it?.background){it.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),Ar.current={kind:"collaboration",groupId:it.groupId,background:!0};return}if(it&&!v.find(fe=>fe.sessionIds.includes(it.sessionId))?.sessionIds.includes(Er.current??"")){it.element.dataset.dropActive="true",Ar.current={kind:"split",sessionId:it.sessionId,groupId:it.groupId};return}const Tt=document.elementsFromPoint(G,Me).filter(K=>{const fe=K.closest("[data-rfd-draggable-id]");return!fe||!["session:","split-member:","collaboration-member:"].some(Qe=>fe.dataset.rfdDraggableId===`${Qe}${Er.current}`)}),kt=Tt.map(K=>K.closest("[data-collaboration-group]")).find(K=>K?.dataset.collaborationGroup);if(kt?.dataset.collaborationGroup){const K=kt.dataset.collaborationGroup,fe=Tt.map(vt=>vt.closest("[data-collaboration-split]")).find(Boolean),Qe=Tt.map(vt=>vt.closest("[data-collaboration-member]")).find(Boolean),ve=Qe?.dataset.collaborationMember??fe?.dataset.splitAnchor,lt=K===un.current&&v.some(vt=>vt.sessionIds.includes(ve??"")&&vt.sessionIds.includes(Er.current??""));if(ve&&!lt&&(K!==un.current||!Qe&&fe)){kt.dataset.dropActive="true";const vt=Qe??fe;vt&&(vt.dataset.dropActive="true"),Ar.current={kind:"split",sessionId:ve,groupId:K}}else{const vt=Tt.some(br=>br.closest("[data-collaboration-background]"));(K!==un.current||vt)&&(kt.dataset.dropActive="true"),Ar.current={kind:"collaboration",groupId:K,background:vt}}return}const ft=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(K=>K.dataset.sidebarEntityListId===rr.current).find(K=>{const fe=K.getBoundingClientRect();return G>=fe.left&&G<=fe.right&&Me>=fe.top-8&&Me<=fe.bottom+8});if(!ft){Ar.current=null;return}const Bt=Array.from(ft.children).filter(K=>K instanceof HTMLElement&&K.hasAttribute("data-sidebar-entity-index")),W=Bt.findIndex(K=>{const fe=K.getBoundingClientRect();return Me<fe.top+fe.height/2}),N=W<0?Bt.length:W;Ar.current={kind:"list",listId:ft.dataset.sidebarEntityListId??"",index:N};const U=Array.from(ft.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(K=>K.dataset.splitExitDropIndex===String(N));U instanceof HTMLElement&&(U.dataset.active="true")},[v]);b.useEffect(()=>{const G=$e=>Mr($e.clientX,$e.clientY),Me=$e=>{const Je=$e.touches[0];Je&&Mr(Je.clientX,Je.clientY)};return window.addEventListener("pointermove",G),window.addEventListener("touchmove",Me,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("touchmove",Me)}},[Mr]);const jn=b.useCallback((G,Me)=>{try{G(Me)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach($e=>{delete $e.dataset.sidebarDragging}),zr.current=!1,Mt.current=[],mt(!1),un.current=null,Er.current=null,rr.current=null,Ar.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach($e=>$e.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach($e=>$e.removeAttribute("data-drop-active"))}},[]),Tr=b.useMemo(()=>a.filter(G=>!Zr.has(G.id)),[a,Zr]),Jr=b.useMemo(()=>{let G=0;for(const Me of a)l.get(Me.id)?.agentStatus==="working"&&(G+=1);return G},[a,l]);b.useLayoutEffect(()=>{const G=Cr.current,Me=qr.current;if(!e||!G||!Me){mn.current=null;return}const $e=Me.getBoundingClientRect(),Je=G.getBoundingClientRect(),it={item:G,top:Math.round(Je.top-$e.top+Me.scrollTop),height:Math.round(Je.height),viewportHeight:Me.clientHeight},Tt=mn.current;if(mn.current=it,Tt?.item===it.item&&Tt.top===it.top&&Tt.height===it.height&&Tt.viewportHeight===it.viewportHeight||zr.current||Me.clientHeight===0)return;const kt=8,Dt=Je.top-$e.top,ft=Je.bottom-$e.top;Dt<kt?Me.scrollTop+=Dt-kt:ft>Me.clientHeight-kt&&(Me.scrollTop+=ft-Me.clientHeight+kt)});const ln=b.useMemo(()=>{if(!bt||!c)return null;const G=l.get(c)?.cwd??null;return HS(G)},[bt,c,l]);b.useEffect(()=>{if(!bt){Xt.current=null,Fr.current.clear();return}if(!c){Xt.current=null;return}const G=Wt.getState(),Me=Fr.current,$e=Xt.current,Je=ln;$e!==null&&$e!==Je&&Me.has($e)&&(G.collapsedGroups.has($e)||G.toggleGroupCollapsed($e),Me.delete($e)),Je!==null&&Je!==""&&G.collapsedGroups.has(Je)&&(G.toggleGroupCollapsed(Je),Me.add(Je)),Xt.current=Je},[bt,c,ln]),b.useEffect(()=>{e||ue(!1)},[e]),b.useEffect(()=>{dr(G=>({...G,command:me?.command}))},[me]),b.useEffect(()=>{if(!ke)return;let G=!1;return zt(!0),It(null),lx().then(Me=>{G||Qt(Me)}).catch(()=>{G||It(Le("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{G||zt(!1)}),()=>{G=!0}},[ke,Le]),b.useEffect(()=>{if(!ne)return;const G=Me=>{Me instanceof KeyboardEvent&&Me.key!=="Escape"||Me instanceof PointerEvent&&Me.target instanceof Node&&Mn.current?.contains(Me.target)||Fe(null)};return window.addEventListener("pointerdown",G),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",G),window.removeEventListener("keydown",G)}},[ne]);const Qr=()=>{!_e&&!ze&&r()};b.useEffect(()=>{const G=Me=>{ue(!1);const{groupId:$e,dock:Je}=Me.detail;ae.current=!0,Kn.getState().setDock($e,{...Je,preferredWidth:360}),Ce(it=>({...it,[$e]:!0})),Ei.getState().terminal(),Qr()};return window.addEventListener("termdock:open-collaboration-messages",G),()=>window.removeEventListener("termdock:open-collaboration-messages",G)},[Qr]);const ks=ee==="tmux"&&!pe?"shell":ee,Dr=(G,Me=!1)=>{if(nt.current)return;nt.current=!0,Ne(!0),We(null);const $e=gt.current;p({...G,shouldActivate:()=>$e===gt.current&&(G.shouldActivate?.()??!0),onResult:Je=>{if(nt.current=!1,Ne(!1),!Je.ok){We(Je.error);return}$e===gt.current&&(Me&&ue(!1),Qr())}})},en=()=>{Dr({mode:ks})},xn=()=>{me&&Dr({mode:ks,command:me.command})},X=G=>{ue(!1),Ve(G.name),p({mode:"tmux",tmuxSessionName:G.name,cwd:G.cwd??void 0}),Qr()};b.useEffect(()=>{xe&&(ce.some(G=>G.name===xe)||Ve(null))},[xe,ce]);const He=(G,Me)=>{Dr({...pn,cwd:pn.cwd?.trim()||void 0,command:Me??G?.command},!0)},Nt=async G=>{Kt(G.id),It(null);try{const Me=await Ry(G.id);Dr({mode:"shell",cwd:Me.cwd,command:Me.command},!0)}catch(Me){const $e=Me&&typeof Me=="object"&&"code"in Me?String(Me.code??""):"";It(Le($e==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Kt(null)}},Et=async G=>{Qt(Me=>Me.filter($e=>$e.id!==G));try{await u9(G)}catch{It(Le("sidebar.resumeHistoryRemoveFailed")),lx().then(Qt).catch(()=>{})}},tr=()=>{if(ke){ue(!1);return}nt.current||(gt.current+=1,nt.current||We(null),dr({mode:ee==="tmux"&&!pe?"shell":ee,cwd:c?l.get(c)?.cwd??void 0:void 0,command:me?.command}),ue(!0))},jr=b.useCallback(G=>{const Me=l.get(G);return Me?.agentStatus==="waiting"||Me?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Me?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Me?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),cr=Cg(),[Cn,Ls]=b.useState(null);b.useEffect(()=>{e||Ls(null)},[e]);const Xn=b.useCallback((G,Me,$e,Je,it)=>{const Tt=!Ie&&G.id===c,kt=Zr.has(G.id),Dt=!!($e&&kt),ft=l.get(G.id),Bt=Ku(ft?.cwd??null),W=ft?.shellTitle??r9(G.id),N=W===ft?.cwd||W===Bt?null:W,U=n9(G,ft?.activeProgram??null,null,s9,N,ft?.promptState??null),K=!!(ft?.tuiProgress&&ft.tuiProgress.state!=="remove"),Qe=ft?.promptState==="running"||ft?.agentStatus==="working"||K?"bg-[var(--success)]":ft?.agentStatus==="waiting"||ft?.agentNeedsReview?"bg-[var(--warning)]":ft?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(rF,{open:Cn===G.id,onOpenChange:ve=>Ls(lt=>ve?G.id:lt===G.id?null:lt),onClose:ve=>m(G.id,ve,{skipConfirmation:!0}),closeLabel:Le("common.close"),closeTitle:Le("sidebar.closeSession",{name:U}),compact:$e,children:[s.jsxs("button",{ref:Tt?Cr:null,type:"button",...Me??{},onContextMenu:ve=>{B&&(ve.preventDefault(),B(G.id,{x:ve.clientX,y:ve.clientY}))},onClick:()=>{ue(!1),Ei.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:G.id})),Qr()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${Me?"cursor-grab active:cursor-grabbing ":""}${$e?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ft?.cwd??G.name,children:[Tt&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${Qe}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${$e?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${Tt?G.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":G.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[ft?.isConnecting||K&&!ft?.agentStatus?s.jsx(_n,{size:$e?10:11,className:"animate-spin"}):ft?.agent??cx(G.id)?s.jsx(Wc,{agent:ft?.agent??cx(G.id),size:$e?13:15}):G.mode==="tmux"?s.jsx(qc,{size:$e?10:11}):s.jsx($o,{size:$e?10:11}),s.jsx(aF,{status:ft?.agentStatus??null,detail:ft?.agentStatusDetail,needsReview:ft?.agentNeedsReview,inCopyMode:ft?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${$e?"text-[11px]":"text-[12px]"} ${Tt?"font-medium text-foreground":""} ${ft?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:U}),s.jsx($5,{sessionIds:[G.id]})]}),Je,s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),Dt?w(G.id):kt?y(G.id):x(G.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 ${$e?"h-6 w-6":"h-[26px] w-[26px]"} ${kt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${Le(Dt?"tab.splitRemovePane":kt?"tab.splitClose":"tab.split")} ${U}`,title:Le(Dt?"tab.splitRemovePane":kt?"tab.splitClose":"tab.split"),children:Dt?s.jsx(MS,{size:11}):s.jsx(Il,{size:12})}),it??s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),m(G.id,ve)},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 ${$e?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":Le("sidebar.closeSession",{name:U}),title:Le("common.close"),children:s.jsx(In,{size:$e?11:12})})]})},[c,Zr,l,m,x,y,w,B,Le,Cn]),cn=b.useMemo(()=>cf(a,G=>l.get(G.id)?.cwd??null,bt,Le("sidebar.ungrouped"),v,Pr).groups,[Pr,bt,a,l,v,Le]),dn=b.useMemo(()=>zd(a,v,Jt,Pr),[Pr,a,Jt,v]),_r=b.useCallback(G=>{mt(G.draggableId.startsWith("collaboration:")||G.draggableId.startsWith("workspace:"));const Me=G.draggableId.replace(/^split-member:/,"");Er.current=G.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const $e=G.type==="split-member"?v.find(Dt=>Dt.sessionIds.includes(Me)):null,Je=G.type==="collaboration-member"?G.source.droppableId.replace(/^collaboration-members:/,""):null,it=Je?Pr.find(Dt=>Dt.id===Je):null;zr.current=!!($e||it||G.type==="session"&&G.draggableId.startsWith("session:")),zr.current&&document.querySelectorAll("[data-collaboration-group]").forEach(Dt=>{Dt.dataset.sidebarDragging="true"}),un.current=it?.id??null;const Tt=$e?.sessionIds??it?.sessionIds??[],kt=Tt.length>0?cn.find(Dt=>Tt.every(ft=>Dt.sessions.some(Bt=>Bt.id===ft))):null;rr.current=bt?kt?`group-sessions:${kt.key}`:null:Tt.length>0?"sidebar-entities":null,Ar.current=null},[Pr,cn,bt,v]),Or=b.useCallback((G,Me,$e)=>{if(Me===$e)return;const Je=Me?Yt.find(ft=>ft.id===Me):null,it=$e?Yt.find(ft=>ft.id===$e):null;if($e&&!it)return;if(it){const ft=a.map(W=>W.id).filter(W=>W!==G);let Bt=-1;ft.forEach((W,N)=>{it.sessionIds.includes(W)&&(Bt=N)}),Bt>=0&&(ft.splice(Bt+1,0,G),R(ft))}const Tt=Je?.sessionIds.filter(ft=>ft!==G)??[],kt=it?[...it.sessionIds.filter(ft=>ft!==G),G]:[];Sr(ft=>ft.flatMap(Bt=>Bt.id===Me?[{...Bt,sessionIds:Tt}]:Bt.id===$e?[{...Bt,sessionIds:kt}]:[Bt])),q(null),(Je&&it?i9({sourceGroupId:Je.id,targetGroupId:it.id,sessionId:G,expectedSourceUpdatedAt:Je.updatedAt,expectedTargetUpdatedAt:it.updatedAt}):Je?Ml({id:Je.id,name:Je.name,sessionIds:Tt,expectedUpdatedAt:Je.updatedAt}):it?Ml({id:it.id,name:it.name,sessionIds:kt,expectedUpdatedAt:it.updatedAt}):Promise.resolve()).then(()=>Hr(),ft=>(q(ft instanceof Error?ft.message:"协作成员移动失败"),Hr()))},[Yt,Hr,a,R]),Gn=b.useCallback((G,Me,$e,Je=!1)=>{const it=Yt.find(fe=>fe.id===G);if(!it||Me===$e)return;const Tt=it.sessionIds.filter(fe=>!fe.startsWith("remote:")),kt=Ud(Tt,v).flatMap(fe=>fe.sessionIds),Dt=O5(qt,it.id),ft=Je&&!$t[it.id]?kt.filter(fe=>!Dt.has(fe)||fe===c||Zr.has(fe)):kt.slice(),Bt=new Set(ft),[W]=ft.splice(Me,1);if(!W)return;ft.splice($e,0,W);let N=0;const U=kt.map(fe=>Bt.has(fe)?ft[N++]:fe),K=v.find(fe=>fe.sessionIds.includes(W));if(K&&K.sessionIds.every(fe=>it.sessionIds.includes(fe))){const fe=U.filter(Qe=>K.sessionIds.includes(Qe));L(K.id,fe)}U.push(...it.sessionIds.filter(fe=>fe.startsWith("remote:"))),Sr(fe=>fe.map(Qe=>Qe.id===G?{...Qe,sessionIds:U}:Qe)),q(null),Ml({id:it.id,name:it.name,sessionIds:U,expectedUpdatedAt:it.updatedAt}).then(()=>Hr(),fe=>(q(fe instanceof Error?fe.message:"成员排序失败"),Hr()))},[Yt,Hr,v,L,qt,$t,c,Zr]);b.useEffect(()=>{const G=Me=>{const{sourceId:$e,targetId:Je}=Me.detail;if(!$e||!Je||$e===Je)return;const it=cf(a,ve=>l.get(ve.id)?.cwd??null,bt,"",v,Pr).arranged.map(ve=>ve.id),Tt=it.indexOf($e),kt=it.indexOf(Je);if(Tt<0||kt<0)return;const Dt=Pr.find(ve=>ve.sessionIds.includes($e));if(Dt?.sessionIds.includes(Je)){const ve=Ud(Dt.sessionIds,v).flatMap(lt=>lt.sessionIds);Gn(Dt.id,ve.indexOf($e),ve.indexOf(Je));return}const ft=v.filter(ve=>ve.sessionIds.length>=2&&ve.sessionIds.every(lt=>Jt.has(lt))&&!Pr.some(lt=>ve.sessionIds.some(vt=>lt.sessionIds.includes(vt)))),Bt=ft.find(ve=>ve.sessionIds.includes($e));if(Bt?.sessionIds.includes(Je)){const ve=[...Bt.sessionIds];ve.splice(ve.indexOf($e),1),ve.splice(Bt.sessionIds.indexOf(Je),0,$e),L(Bt.id,ve);return}const W=ve=>Pr.find(lt=>lt.sessionIds.includes(ve))?.sessionIds??ft.find(lt=>lt.sessionIds.includes(ve))?.sessionIds??[ve],N=new Set(W($e)),U=new Set(W(Je)),K=it.filter(ve=>!N.has(ve)),fe=K.flatMap((ve,lt)=>U.has(ve)?[lt]:[]),Qe=Tt<kt?Math.max(...fe)+1:Math.min(...fe);K.splice(Qe,0,...it.filter(ve=>N.has(ve))),R(K)};return window.addEventListener("reorder-navigation-session",G),()=>window.removeEventListener("reorder-navigation-session",G)},[a,l,bt,v,Pr,Jt,Gn,L,R]);const Vn=b.useCallback(G=>{if(G.type!=="collaboration-member")return!1;if(G.reason==="CANCEL")return!0;const Me=G.source.droppableId.replace(/^collaboration-members:/,""),$e=G.draggableId.replace(/^collaboration-member:/,""),Je=Ar.current;if(Je?.kind==="split")return Or($e,Me,Je.groupId),E(Je.sessionId,$e),!0;if(Je?.kind==="collaboration"&&Je.groupId!==Me)return Or($e,Me,Je.groupId),!0;if(Je?.kind==="collaboration"&&Je.background)return Zr.has($e)&&w($e),!0;if(G.destination&&G.destination.droppableId!==G.source.droppableId){const it=G.destination.droppableId.replace(/^collaboration-members:/,"");if(Pr.some(Tt=>Tt.id===it))return Or($e,Me,it),!0}if(G.combine){const it=G.combine.droppableId.replace(/^collaboration-members:/,"");it!==Me&&Or($e,Me,it);const Tt=G.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(Dt=>Dt.sessionIds.includes($e))?.sessionIds.includes(Tt)){const Dt=Pr.find(Bt=>Bt.id===Me),ft=Dt?Ud(Dt.sessionIds,v).flatMap(Bt=>Bt.sessionIds).indexOf(Tt):-1;ft>=0&&Dt&&Gn(Me,Ud(Dt.sessionIds,v).flatMap(Bt=>Bt.sessionIds).indexOf($e),ft)}else Jt.has(Tt)&&E(Tt,$e);return!0}if(G.destination?.droppableId===G.source.droppableId)return Gn(Me,G.source.index,G.destination.index,!0),!0;if(Je?.kind!=="list")return!0;if(Je?.kind==="list"){const it=cn.find(kt=>`group-sessions:${kt.key}`===Je.listId),Tt=Je.listId==="sidebar-entities"?dn:it?zd(it.sessions,v,Jt,Pr):null;if(Tt){const kt=Bb(Tt,$e,Je.index);Je.listId==="sidebar-entities"?R(kt):it&&R(cn.flatMap(Dt=>Dt.key===it.key?kt:Dt.sessions.map(ft=>ft.id)))}}return Or($e,Me,null),!0},[Pr,dn,cn,Or,R,Gn,Jt,v,Zr,w,E]),gn=b.useCallback(G=>{if(G.type!=="split-member")return!1;if(G.reason==="CANCEL")return!0;const Me=G.draggableId.replace(/^split-member:/,""),$e=v.find(ft=>ft.sessionIds.includes(Me));if(!$e?.sessionIds.includes(Me))return!0;const Je=$e.id,it=Ar.current;if(it?.kind==="split")return Or(Me,null,it.groupId),E(it.sessionId,Me),!0;if(it?.kind==="collaboration")return Or(Me,null,it.groupId),!0;if(!G.destination&&it?.kind==="list"){const ft=cn.find(N=>`group-sessions:${N.key}`===it.listId),Bt=it.listId==="sidebar-entities"?dn:ft?zd(ft.sessions,v,Jt,Pr):null;if(!Bt)return!0;const W=Bb(Bt,Me,it.index);return w(Me),it.listId==="sidebar-entities"?R(W):ft&&R(cn.flatMap(N=>N.key===ft.key?W:N.sessions.map(U=>U.id))),!0}if(!G.destination)return!0;const Tt=G.destination.droppableId.replace(/^split-members:/,"");if(Tt!==Je){const Bt=v.find(W=>W.id===Tt)?.sessionIds[0];return Bt&&E(Bt,Me),!0}if(G.source.index===G.destination.index)return!0;const kt=[...$e.sessionIds],[Dt]=kt.splice(G.source.index,1);return Dt&&(kt.splice(G.destination.index,0,Dt),L(Je,kt)),!0},[Pr,dn,cn,Or,E,w,R,L,Jt,v]),Jn=(G,Me="top")=>s.jsx("div",{"data-split-exit-drop-index":G,className:`group/split-exit pointer-events-none absolute inset-x-0 z-10 h-2 ${Me==="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"})}),kr=b.useCallback((G,Me,$e)=>{if(Vn(G)||gn(G)||G.reason==="CANCEL")return;const Je=Me.find(ft=>ft.id===G.draggableId);if(!Je)return;const it=Ar.current;if(it?.kind==="split"&&Je.kind==="session"){Or(Je.session.id,null,it.groupId),E(it.sessionId,Je.session.id);return}if(it?.kind==="collaboration"&&Je.kind==="session"){Or(Je.session.id,null,it.groupId);return}if(G.combine&&Je.kind!=="session"){const ft=Me.findIndex(Bt=>Bt.id===G.combine?.draggableId);if(ft<0)return;G={...G,combine:null,destination:{...G.source,index:ft}}}if(G.combine){const ft=Me.find(K=>K.id===G.combine?.draggableId);if(!ft)return;const Bt=ft.kind==="workspace"?ft:Je.kind==="workspace"?Je:ft,W=Bt===Je?ft:Je,N=Bt.sessionIds[0],U=W.sessionIds[0];N&&U&&N!==U&&E(N,U);return}if(!G.destination||G.source.index===G.destination.index)return;const Tt=[...Me],[kt]=Tt.splice(G.source.index,1);if(!kt)return;Tt.splice(G.destination.index,0,kt);const Dt=Tt.flatMap(ft=>ft.sessionIds);if($e===void 0){R(Dt);return}R(cn.flatMap(ft=>ft.key===$e?Dt:ft.sessions.map(Bt=>Bt.id)))},[cn,Vn,gn,Or,E,R]),Lr=b.useCallback(G=>{if(G.reason==="CANCEL"||Vn(G)||gn(G))return;if(G.type==="group"){if(!G.destination||G.source.index===G.destination.index)return;R(Vy(cn,G.source.index,G.destination.index));return}const Me=G.source.droppableId.replace(/^group-sessions:/,""),$e=cn.find(it=>it.key===Me);if(!$e)return;const Je=zd($e.sessions,v,Jt,Pr);if(G.combine||Ar.current?.kind==="collaboration"||Ar.current?.kind==="split"){kr(G,Je,Me);return}!G.destination||G.destination.droppableId!==G.source.droppableId||kr(G,Je,Me)},[Pr,cn,Jt,v,Vn,kr,gn,R]),pr=G=>{const Me=ne===G.id,$e=[{layout:"horizontal",label:Le("tab.splitHorizontal"),icon:Il},{layout:"vertical",label:Le("tab.splitVertical"),icon:px},...G.sessionIds.length>=3||G.layout==="grid"?[{layout:"grid",label:Le("tab.splitGrid"),icon:fx}]:[]],Je=G.layout==="vertical"?px:G.layout==="grid"?fx:Il,it=$e.find(Tt=>Tt.layout===G.layout)?.label??Le("tab.splitHorizontal");return s.jsxs("div",{ref:Me?Mn:void 0,className:"relative shrink-0",onPointerDown:Tt=>Tt.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 ${Me?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${Le("tab.splitLayout")}: ${it}`,"aria-haspopup":"menu","aria-expanded":Me,title:Le("tab.splitLayout"),onClick:Tt=>{Tt.stopPropagation(),Fe(kt=>kt===G.id?null:G.id)},children:s.jsx(Je,{size:12})}),Me&&s.jsx("div",{role:"menu","aria-label":Le("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:$e.map(Tt=>{const kt=Tt.icon,Dt=Tt.layout===G.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Dt,"aria-label":Tt.label,title:Tt.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${Dt?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:ft=>{ft.stopPropagation(),S(G.sessionIds[0],Tt.layout),Fe(null)},children:s.jsx(kt,{size:13})},Tt.layout)})})]})},ns=(G,Me)=>Me&&s.jsx("button",{type:"button",...Me,"aria-label":G,title:G,onClick:$e=>$e.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($f,{size:10})}),Un=(G,Me,$e=!1,Je=!1,it)=>{if(Me.length<2)return null;const Tt=Me.some(N=>N.id===c),kt=[],Dt=[],ft=[];for(const N of Me){const U=l.get(N.id);U?.agentStatus==="waiting"||U?.agentNeedsReview?kt.push(N):U?.agentStatus==="working"?Dt.push(N):U?.inCopyMode&&ft.push(N)}const Bt=G.name?.trim()||`${Le("tab.splitWorkspace")} ${v.findIndex(N=>N.id===G.id)+1}`,W=ne===G.id;return s.jsxs("section",{"data-split-workspace":G.id,"aria-label":Bt,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 ${Je?"bg-primary/15 ring-1 ring-primary/40":$e?"bg-surface-elevated opacity-90 shadow-lg":kt.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Dt.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":ft.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":Tt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[ns(`移动分屏组 ${Bt}`,it),s.jsx(Ll,{droppableId:`split-members:${G.id}`,type:"split-member",direction:"vertical",children:(N,U)=>s.jsxs("div",{ref:N.innerRef,...N.droppableProps,"data-split-members":!0,className:U.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[Me.map((K,fe)=>s.jsx(kl,{draggableId:`split-member:${K.id}`,index:fe,disableInteractiveElementBlocking:!0,children:(Qe,ve)=>s.jsx("div",{ref:Qe.innerRef,...Qe.draggableProps,...B?cr(()=>B(K.id)):{},className:`${fe===0&&W?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${ve.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${jr(K.id)??(K.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Xn(K,Qe.dragHandleProps,!0,fe===0?pr(G):void 0)})},K.id)),N.placeholder]})})]})},En=(G,Me)=>{const $e=c??Me;Ae.current||!$e||(ue(!1),Ae.current=!0,et(G),q(null),dC(G,$e).catch(Je=>q(Je instanceof Error?Je.message:"消息面板打开失败,请重试")).finally(()=>{Ae.current=!1,et(null)}))},kn=(G,Me)=>{on.current+=1,Sr($e=>Me?$e.map(Je=>Je.id===G?Me:Je):$e.filter(Je=>Je.id!==G)),Me||(Ei.getState().groupId===G&&Ei.getState().terminal(),Kn.getState().setDock(G,null),Ce($e=>{const Je={...$e};return delete Je[G],Je}),requestAnimationFrame(()=>Cr.current?.focus({preventScroll:!0})),Fa({floatingGroupId:null},G).catch(()=>q("协作组已删除,面板布局保存失败,请刷新后检查。"))),Hr()},ss=(G,Me,$e,Je=!1,it=!1)=>{const Tt=`collaboration:${G.id}`,kt=Br.has(Tt),Dt=`collaboration-members-${G.id}`,ft=Ie===G.id||!Ie&&Me.some(ve=>ve.id===c),Bt=O5(qt,G.id),W=G.sessionIds.filter(ve=>Bt.has(ve)&&ve!==c&&!Zr.has(ve)),N=$t[G.id]===!0,U=N?G.sessionIds:G.sessionIds.filter(ve=>!W.includes(ve)),K=Ud(U,v),fe=K.flatMap(ve=>ve.sessionIds),Qe=K.length===1?K[0]?.workspace:void 0;return s.jsxs("section",{"data-collaboration-group":G.id,"data-collaboration-group-name":G.name,"aria-label":`Agent 工作组:${G.name}`,className:`group/collaboration relative rounded-md ${kt?"":"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 ${it?"bg-primary/15 ring-1 ring-primary/40":Je?"bg-surface-elevated opacity-90 shadow-lg":ft?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[ns(`移动工作组 ${G.name}`,$e),s.jsxs(sF,{group:Yt.find(ve=>ve.id===G.id)??G,collapsed:kt,onOpen:()=>{fr(G.id)},onMessages:Ye===null&&(c||Me.length)?()=>En(G.id,Me[0]?.id):void 0,onToggleCollapsed:()=>Vr(Tt),onChanged:ve=>kn(G.id,ve),children:[s.jsx("button",{type:"button","aria-label":`${kt?"展开":"收起"} ${G.name} 的成员会话`,"aria-expanded":!kt,"aria-controls":Dt,title:`${kt?"展开":"收起"}成员会话`,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:ve=>{ve.stopPropagation(),Vr(Tt)},children:s.jsx(Ks,{size:14,className:kt?"":"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:`打开 ${G.name} 的协作工作区`,"aria-label":`打开协作工作区:${G.name}`,"aria-current":Ie===G.id?"page":void 0,onClick:ve=>{ve.stopPropagation(),fr(G.id)},children:[s.jsx(nh,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),ut.some(ve=>ve.groupId===G.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[ut.filter(ve=>ve.groupId===G.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${G.name}`,title:"在终端旁打开成员与消息",disabled:Ye!==null||!c&&!Me.length,"aria-busy":Ye===G.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:ve=>{ve.stopPropagation(),En(G.id,Me[0]?.id)},children:Ye===G.id?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(Xu,{size:14})})]}),s.jsx("div",{id:Dt,children:!kt&&s.jsxs(s.Fragment,{children:[W.length>0&&s.jsxs("button",{type:"button","aria-expanded":N,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:()=>yt(ve=>({...ve,[G.id]:!N})),children:[s.jsx(Ks,{size:12,className:N?"rotate-90":""}),"已完成的执行会话 · ",W.length]}),s.jsx(Ll,{droppableId:`collaboration-members:${G.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(ve,lt)=>s.jsxs("div",{ref:ve.innerRef,...ve.droppableProps,"data-collaboration-members":!0,className:`${lt.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[K.map(vt=>s.jsx("div",{"data-collaboration-split":vt.workspace?.id,"data-split-anchor":vt.workspace?.sessionIds[0],role:vt.workspace?"region":void 0,"aria-label":vt.workspace?`${Le("tab.splitWorkspace")} · ${vt.sessionIds.length}`:void 0,className:vt.workspace&&!Qe?`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 ${vt.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:vt.sessionIds.map(br=>{const Lt=Jt.get(br);return Lt?s.jsx(kl,{draggableId:`collaboration-member:${Lt.id}`,index:fe.indexOf(Lt.id),disableInteractiveElementBlocking:!0,children:(rn,yn)=>s.jsxs("div",{ref:rn.innerRef,...rn.draggableProps,"data-collaboration-member":Lt.id,"data-split-member":Zr.has(Lt.id)?"true":void 0,...B?cr(()=>B(Lt.id)):{},className:`${vt.workspace&&br===vt.sessionIds[0]&&ne===vt.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 ":""}${jr(Lt.id)??(Lt.id===c?"bg-surface-elevated/80 text-foreground":Zr.has(Lt.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Xn(Lt,rn.dragHandleProps,!0,vt.workspace&&br===vt.sessionIds[0]?pr(vt.workspace):void 0,Bt.has(br)?s.jsxs("button",{type:"button","aria-label":`归档 ${Lt.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:nr!==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:hn=>{hn.stopPropagation(),!_t.current&&(_t.current=!0,Ke(br),q(null),c9(br).then(async()=>{De(Dn=>Dn+1),await Hr()}).catch(Dn=>q(Dn instanceof Error?Dn.message:"归档失败,终端已保留")).finally(()=>{_t.current=!1,Ke(null)}))},children:[nr===br?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(My,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!vt.workspace&&Zr.has(Lt.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(hn=>hn.sessionIds.includes(Lt.id))?.sessionIds.filter(hn=>hn!==Lt.id).map(hn=>Jt.get(hn)?.name??hn).join("、")} 分屏`,"aria-label":`查看 ${Lt.name} 的跨组分屏`,onClick:()=>{ue(!1),Ei.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Lt.id})),Qr()},children:s.jsx(Il,{size:10})})]})},Lt.id):null})},vt.workspace?.id??vt.sessionIds[0])),ve.placeholder]})}),s.jsx(tQ,{groupId:G.id,version:tt,onRestore:async ve=>{ue(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:ve.cwd,preferredFrontendSessionId:ve.sessionId,requireExisting:!0}})),await Hr(),Ei.getState().terminal(),Qr()}}),G.remoteSessions?.map(ve=>s.jsxs("button",{type:"button",title:`${uc(ve)} · ${ve.serviceConnected===!1?"服务不可达,消息尚未送达":ve.status}`,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:()=>{ue(!1),A6(ve.sessionId).catch(()=>{fr(G.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ve.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ve.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:uc(ve)}),ve.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},ve.sessionId))]})}),s.jsx("div",{"data-collaboration-background":!0,className:kt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},Wr=(G,Me,$e)=>s.jsx(h0,{onBeforeCapture:ps,onDragStart:_r,onDragEnd:Je=>jn(it=>kr(it,G,$e),Je),children:s.jsx(Ll,{droppableId:Me,direction:"vertical",isCombineEnabled:!re,children:Je=>s.jsxs("div",{ref:Je.innerRef,...Je.droppableProps,"data-sidebar-entity-list-id":Me,className:"flex-1 space-y-0.5",children:[G.map((it,Tt)=>s.jsx(kl,{draggableId:it.id,index:Tt,disableInteractiveElementBlocking:!0,children:(kt,Dt)=>s.jsxs("div",{ref:kt.innerRef,...kt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":Tt,className:"relative",children:[Jn(Tt),Tt===G.length-1&&Jn(G.length,"bottom"),it.kind==="workspace"?Un(it.workspace,it.members,Dt.isDragging,!!Dt.combineTargetFor,kt.dragHandleProps):it.kind==="collaboration"?ss(it.group,it.members,kt.dragHandleProps,Dt.isDragging,!!Dt.combineTargetFor):s.jsx("div",{...B?cr(()=>B(it.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":jr(it.session.id)??(!Ie&&it.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(it.session,kt.dragHandleProps)})]})},it.id)),Je.placeholder]})})}),tn=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{"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 w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:Le("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),Jr>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(P6,{count:Jr,tone:"running",title:Le("agent.aiRunning")})})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:()=>{ue(!1),fr(null)},className:"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","aria-label":"Agent 工作台",title:"Agent 工作台",children:s.jsx(nh,{size:16})}),(!_e||ze)&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:r,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":Le("common.close"),children:s.jsx(In,{size:16})})]})]})]}),ht&&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:ht}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>q(null),children:s.jsx(In,{size:14})})]}),s.jsxs("div",{ref:qr,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:[(ut.length>0||xt)&&s.jsxs("section",{className:"mb-2 rounded-lg border border-primary/20 bg-primary/5","aria-label":"协作待处理事项",children:[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":Rt,onClick:()=>Ct(G=>!G),children:[s.jsx(nh,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:ut.length}),s.jsx(Ks,{size:12,className:Rt?"rotate-90":""})]}),Rt&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[xt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[xt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{Lu.getState().refresh()},children:"重试"})]}),ut.map(G=>s.jsxs("button",{type:"button",className:"min-h-11 w-full rounded-md px-2 py-2 text-left hover:bg-surface-2",onClick:()=>{F5(G.groupId,G.id),fr(G.groupId).then(Me=>{Me&&F5(G.groupId,G.id)})},children:[s.jsx("span",{className:"block truncate text-xs text-foreground",children:G.title}),s.jsxs("span",{className:"mt-1 block truncate text-[10px] text-muted-foreground",children:[Yt.find(Me=>Me.id===G.groupId)?.name??"协作组"," · ",Kc(G)]})]},G.id))]})]}),s.jsx(nF,{sessions:ce,loading:qe,attachingName:xe,onRefresh:we,onRestore:X,onClose:ye}),Pr.filter(G=>!G.sessionIds.length).map(G=>s.jsx(h0,{onDragEnd:()=>{},children:ss(G,[])},G.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx($o,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:Le("sidebar.noSessions")})]}):Tr.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:Le("sidebar.noMatchingSessions")})}):bt?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(h0,{onBeforeCapture:ps,onDragStart:_r,onDragEnd:G=>jn(Lr,G),children:s.jsx(Ll,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:G=>s.jsxs("div",{ref:G.innerRef,...G.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[cn.map((Me,$e)=>{const Je=Br.has(Me.key),it=!Je&&$e===cn.length-1,Tt=zd(Me.sessions,v,Jt,Pr);let kt=0,Dt=0;for(const Bt of Me.sessions){const W=l.get(Bt.id);W?.agentStatus==="working"&&(kt+=1),(W?.agentStatus==="waiting"||W?.agentNeedsReview)&&(Dt+=1)}const ft=Me.key==="";return s.jsx(kl,{draggableId:`sidebar-group:${Me.key||"__ungrouped__"}`,index:$e,isDragDisabled:ft,disableInteractiveElementBlocking:!0,children:(Bt,W)=>s.jsxs("div",{ref:Bt.innerRef,...Bt.draggableProps,className:`shrink-0 rounded-md transition-colors ${it?"flex flex-1 flex-col ":""}${W.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ft?{}:Bt.dragHandleProps,onClick:()=>{Vr(Me.key),Fr.current.delete(Me.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 ${ft?"":"cursor-grab active:cursor-grabbing"}`,title:Me.key||Me.label,children:[s.jsx(Ks,{size:13,className:`shrink-0 transition-transform ${Je?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Me.label}),kt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Dt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx($5,{sessionIds:Me.sessions.map(N=>N.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Me.sessions.length})]}),!Je&&s.jsx("div",{className:`mt-0.5 pl-2 ${it?"flex flex-1 flex-col":""}`,children:s.jsx(Ll,{droppableId:`group-sessions:${Me.key}`,type:"session",direction:"vertical",isCombineEnabled:!re,children:N=>s.jsxs("div",{ref:N.innerRef,...N.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${Me.key}`,className:`${it?"flex-1 ":""}space-y-0.5`,children:[Tt.map((U,K)=>s.jsx(kl,{draggableId:U.id,index:K,disableInteractiveElementBlocking:!0,children:(fe,Qe)=>s.jsxs("div",{ref:fe.innerRef,...fe.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":K,className:"relative",children:[Jn(K),K===Tt.length-1&&Jn(Tt.length,"bottom"),U.kind==="workspace"?Un(U.workspace,U.members,Qe.isDragging,!!Qe.combineTargetFor,fe.dragHandleProps):U.kind==="collaboration"?ss(U.group,U.members,fe.dragHandleProps,Qe.isDragging,!!Qe.combineTargetFor):s.jsx("div",{...B?cr(()=>B(U.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${Qe.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":Qe.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":jr(U.session.id)??(!Ie&&U.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(U.session,fe.dragHandleProps)})]})},U.id)),N.placeholder]})})})]})},Me.key||"__ungrouped__")}),G.placeholder]})})})}):Wr(dn,"sidebar-entities")]}),s.jsx(a9,{onReselect:()=>{d&&(mn.current=null,Be(G=>G+1),d())}}),ke&&s.jsx(fO,{directories:a.flatMap(G=>{const Me=l.get(G.id)?.cwd;return Me?[Me]:[]}),tmuxAvailable:pe,options:pn,launchPending:Pe,launchError:oe?Le(zm(oe)):null,agents:Gr,selectedAgent:me,detecting:ot,resumeHistory:Gt,resumeHistoryLoading:wt,resumeHistoryPendingId:Vt,resumeHistoryError:Ot,onRefreshAgents:()=>{pt().catch(()=>{})},onSelectAgent:G=>{ir(G).catch(()=>{})},onLaunchAgent:He,onResumeHistory:G=>{Nt(G)},onRemoveResumeHistory:G=>{Et(G)},onClose:()=>ue(!1),onOptionsChange:dr,additionalContent:Xr&&$?.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(bn,{size:13,className:$.status==="installing"||$.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:Le("sidebar.updateAvailable",{version:$.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:$.status==="installing"?Le("sidebar.updateInstalling"):$.status==="ready"?Le("sidebar.updateReady"):$.status==="restarting"?Le("sidebar.updateRestarting"):Le("sidebar.updateFailed")})]})]}),$.status==="ready"&&Z&&s.jsx("button",{type:"button",disabled:V,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:Le("sidebar.updateRestart")}),$.status==="error"&&le&&s.jsx("button",{type:"button",disabled:V,onClick:le,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:Le("sidebar.updateRetry")})]}),footerActions:s.jsx(eF,{serverAttention:je,onOpenSettings:()=>{ue(!1),z()},actions:[...O?[{label:Le("sidebar.subscriptionQuota"),icon:zA,onSelect:()=>{ue(!1),O()}}]:[],{label:"Agent 工作台",icon:nh,onSelect:()=>{ue(!1),fr(null)}},{label:"服务与设备",icon:o9,onSelect:()=>{ue(!1),l9()}},...Y?[{label:Le(ze?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:ze?b0:x0,separated:!0,onSelect:()=>{ue(!1),Y()}}]:[]]})}),Ze&&s.jsx(Lb,{onEnterGroup:async G=>{if(!await fr(G))throw new Error("协作组已保存,打开工作区失败,请重试");at(!1)},onFloatingChange:async G=>{if(G){if(!await fr(G))throw new Error("打开协作工作区失败");at(!1)}},activeSessionId:c,defaultSessionMode:ee,onClose:()=>at(!1),onNewSession:G=>p(G)}),Object.entries(Ge).map(([G,Me])=>s.jsx(Lb,{activeSessionId:c,initialCollaborationGroupId:G,initialFloating:Me,visible:!Ie,onEnterGroup:async $e=>{if($e===G){await fr($e);return}if(!await fr($e))throw new Error("协作组已保存,打开工作区失败,请重试");await Fa({floatingGroupId:null},G),Ce(Je=>{const it={...Je};return delete it[G],it})},onFloatingChange:$e=>St(G,$e),defaultSessionMode:ee,onClose:()=>{ae.current=!0,Ce($e=>{const Je={...$e};return delete Je[G],Je})},onNewSession:$e=>p($e)},G)),!ke&&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:[oe&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:Le(zm(oe))}),s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${me?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:en,disabled:Pe,"aria-busy":Pe,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] ${me?"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:Le("sidebar.newSession"),"aria-label":Le("sidebar.newSession"),children:[s.jsx($o,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Pe?Le("sidebar.sessionCreating"):"Terminal"})]}),me&&s.jsxs("button",{type:"button",onClick:xn,disabled:Pe,"aria-busy":Pe,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:Le("sidebar.newSessionWithAgent",{agent:me.displayName}),"aria-label":Le("sidebar.newSessionWithAgent",{agent:me.displayName}),children:[s.jsx(Wc,{agent:me,size:15}),s.jsx("span",{className:"truncate",children:me.displayName})]}),s.jsxs("button",{type:"button",onClick:tr,disabled:Pe,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:st,"aria-label":st,"aria-expanded":ke,"aria-controls":"sidebar-launch-options",children:[s.jsx(To,{size:15}),je&&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"}),Xr&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${je?"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:tn}):s.jsx(D6,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:_e,children:tn})}function oF(){const{t:e}=Ur();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 lF({slow:e=!1}){const{t}=Ur();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 Z6=()=>Oc(()=>import("./RightSidebar-CXykcIPb.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})),cF=b.lazy(Z6);function Pb(e){const t=b.useRef(!1);b.useEffect(()=>{const p=navigator.connection;if(!(p?.saveData||/2g|3g/.test(p?.effectiveType??"")))return U1(()=>{Z6().catch(()=>{})},3e3)},[]);const{t:r}=Ur(),n=Wt(p=>p.rootPath),a=Wt(p=>p.rightTab),c=Wt(p=>p.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const d=s.jsx(D6,{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:[jl,rS,To].map((p,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(p,{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(In,{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",TA,"rightSidebar.tabGit"],["diff",CA,"rightSidebar.tabChanges"],["files",Vc,"rightSidebar.tabFiles"],["architecture",$T,"architecture.tab"],["computer",d9,"rightSidebar.tabComputer"]].map(([p,m,x])=>s.jsxs("button",{type:"button",onClick:()=>c(p),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===p?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(m,{size:12}),r(x)]},p))}),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(lF,{}):s.jsx(oF,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:d,children:s.jsx(cF,{...e})}):d}const Ob=hc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function uF(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 dF=hc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=n3(),a=Date.now(),c=t().sessions,l=uF(c),d={id:n,cwd:r,sessionId:null,name:l,customName:!1,createdAt:a,lastActivity:a};return e(p=>{const m=new Map(p.sessions);return m.set(n,d),{sessions:m,activeSessionId:p.activeSessionId??n,nextSessionNumber:p.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})}})),hF=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class fF{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 hF[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 p=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<p)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function eu(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 pF(){return eu("/api/android/devices")}async function mF(e){return eu("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const Ff=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],E0=Ff[1];function R1(e){if(!e||typeof e!="object")return E0;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=Ff.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return E0;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 gF(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 Fb(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 xF(e){return eu(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function bF(e){return eu("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function yF(e){return eu(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function vF(e,t){return eu(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function wF(e){return eu(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const AF=0,TF=1,SF=2,CF=3,_F=4,kF=5,LF=7,IF=10,EF=11,NF=16,$b=17,Ub=0,Im=1,RF=2,zb=3,Em=0,Hb=1,Wb=1,Tu=0xffffffffffffffffn,Nh=0xfffffffffffffffen,Hd={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function K6(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 MF(e,t,r,n,a,c){const l=new Uint8Array(32),d=new DataView(l.buffer);return d.setUint8(0,SF),d.setUint8(1,e),d.setBigUint64(2,t),K6(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 Nm(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,AF),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function jF(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,CF),K6(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 DF(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,TF),a.setUint32(1,r.length),n.set(r,5),n}function BF(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]=NF,r[1]=t.length,r.set(t,2),r}function Wd(e){return new Uint8Array([e])}function Gb(e){return new Uint8Array([_F,e])}function QF(e){return new Uint8Array([IF,e?1:0])}function PF(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function OF(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 Rm(e){return e.toString(16).padStart(2,"0")}function X6(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 p=l+1;for(;p+2<e.length&&!(e[p]===0&&e[p+1]===0&&(e[p+2]===1||e[p+2]===0&&e[p+3]===1));)p++;return e.subarray(l,Math.min(e.length,p))}return null}function FF(e){const t=e?X6(e,7,!1):null;return t&&t.length>=4?`avc1.${Rm(t[1])}${Rm(t[2])}${Rm(t[3])}`:"avc1.42e01e"}function $F(e){const t=e?X6(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 UF{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=h9(gF(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(Wd($b)))},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:PF(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=OF(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(Wd($b))}})}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=[FF(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,d,p)=>p.indexOf(l)===d),r.avc={format:"annexb"}):t==="h265"?(n=[$F(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===Im||t===zb,l=c?0:1,d=a===Tu&&!c?Wb:0,p=(t===Ub||t===Im)&&a===Tu?Wb:0;this.sendControl(MF(t,a,this.pointerPoint(r,n),l,p,d))}pointerDown(t,r,n){this.touch(Ub,t,r,n==="mouse"?Tu:Nh)}pointerMove(t,r,n){this.touch(RF,t,r,n==="mouse"?Tu:Nh)}pointerUp(t,r,n){this.touch(Im,t,r,n==="mouse"?Tu:Nh)}pointerCancel(t,r,n){this.touch(zb,t,r,n==="mouse"?Tu:Nh)}scroll(t,r,n,a){this.sendControl(jF(this.pointerPoint(t,r),n,a))}key(t,r=Em){this.sendControl(Nm(r,t))}tapKey(t){this.sendControl(Nm(Em,t)),this.sendControl(Nm(Hb,t))}back(){this.sendControl(Gb(Em)),this.sendControl(Gb(Hb))}home(){this.tapKey(Hd.HOME)}recents(){this.tapKey(Hd.APP_SWITCH)}power(){this.tapKey(Hd.POWER)}volumeUp(){this.tapKey(Hd.VOLUME_UP)}volumeDown(){this.tapKey(Hd.VOLUME_DOWN)}rotate(){this.sendControl(Wd(EF))}expandNotifications(){this.sendControl(Wd(kF))}collapsePanels(){this.sendControl(Wd(LF))}setDisplayPower(t){this.sendControl(QF(t))}sendText(t){this.sendControl(DF(t))}startApp(t){this.sendControl(BF(t))}}function zF(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function HF(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${zF()}.png`}function Vb(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 WF(e,t=HF()){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 J6(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 qb(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:J6({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 e4(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),c=p=>{window.clearTimeout(d),window.removeEventListener("termdock-insert-reference-ack",l),p?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},l=p=>{const m=p.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 Yb(e,t){return e4(c1(e,null),t)}const Mm=hc(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 GF({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=Ur(),[c,l]=b.useState(!1),[d,p]=b.useState(!1),[m,x]=b.useState(!1),[y,w]=b.useState(!1),[v,S]=b.useState(null),L=b.useRef(!1),E=b.useRef(null),R=async()=>{if(!L.current){L.current=!0,p(!0),w(!0);try{await wF(e.id),n()}catch(z){S(z instanceof Error?z.message:String(z))}finally{L.current=!1,p(!1),w(!1)}}};b.useEffect(()=>{if(c)return;E.current?.focus();const z=O=>{if(O.stopPropagation(),O.key==="Escape"&&O.preventDefault(),O.key!=="Tab")return;const $=Array.from(E.current?.querySelectorAll("button:not(:disabled)")??[]),V=$[0],Z=$.at(-1);O.shiftKey&&(document.activeElement===V||document.activeElement===E.current)?(O.preventDefault(),Z?.focus()):!O.shiftKey&&document.activeElement===Z&&(O.preventDefault(),V?.focus())};return document.addEventListener("keydown",z,!0),()=>document.removeEventListener("keydown",z,!0)},[c]);const B=async z=>{if(!L.current){L.current=!0,p(!0),x(z!==void 0),l(!1),S(null);try{const O=await vF(e.id,z);z===void 0&&await r(O.path),n()}catch(O){S(O instanceof Error?O.message:String(O))}finally{L.current=!1,p(!1)}}};return c?s.jsx(rp,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:z=>{B(z)}}):Xs.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:E,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(_n,{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:()=>{B()},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:()=>{R()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const r0="android-mirror",Gd=r0,t4="termdock:android:quality:v1",jm=176,VF=204,_l=1,nf=8,Zb=[1,1.25,1.5,2,2.5,3,4,6,8],qF=e=>Math.max(_l,Math.min(nf,e));function YF(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function Rh(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 ZF(e,t){try{e.setPointerCapture?.(t)}catch{}}function Kb(e,t){try{e.releasePointerCapture?.(t)}catch{}}const Xb=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Mh=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},Dm={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},KF=()=>{try{const e=localStorage.getItem(t4);return e?R1(JSON.parse(e)):E0}catch{return E0}},Vd=e=>{try{localStorage.setItem(t4,JSON.stringify(e))}catch{}};function XF({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=Ur(),d=Ob(N=>N.overlay),p=Ob(N=>N.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(KF,[]),v=b.useRef(w),S=b.useRef(null),L=b.useRef(null),[E,R]=b.useState(4e6),B=b.useRef(null),z=b.useRef(new Map),O=b.useRef(null),$=b.useRef(!1),[V,Z]=b.useState(_l),le=b.useRef(V),be=b.useRef({x:0,y:0}),pe=b.useRef(null),ee=b.useRef(0),_e=b.useRef(0),ze=b.useRef(null),Y=b.useRef(0),[ce,qe]=b.useState(null),[we,ye]=b.useState(null),[Le,Be]=b.useState(!0),[ne,Fe]=b.useState(""),[ke,Ee]=b.useState(w.id),[Pe,Ne]=b.useState([]),[oe,We]=b.useState(null),[nt,gt]=b.useState(""),[ue,Ze]=b.useState(!0),[at,Ie]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[Ge,Ce]=b.useState("idle"),[H,ae]=b.useState(null),[Ae,Ye]=b.useState(null),[et,St]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Gt,Qt]=b.useState(null),[wt,zt]=b.useState(null),[Vt,Kt]=b.useState(!1),[Ot,It]=b.useState([]),[xe,Ve]=b.useState(null),[ht,q]=b.useState([]),[ut,qt]=b.useState(!1),tt=b.useRef(null),De=b.useRef(0),nr=b.useRef([]),[Ke,_t]=b.useState(!1),[$t,yt]=b.useState(""),[xt,Rt]=b.useState(!1),[Ct,fr]=b.useState(!1),[Yt,Sr]=b.useState(""),[pn,dr]=b.useState(null),[me,Gr]=b.useState(null),[ot,pt]=b.useState(!1),[ir,Mn]=b.useState(0),Xr=b.useRef(null),[je,st]=b.useState(!1),bt=b.useRef(!1),Br=b.useRef(new Set),Vr=b.useRef(null),Cr=b.useRef(null),qr=b.useRef(!1),[mn,on]=b.useState(!1),zr=b.useRef(a);zr.current=a;const[un,Er]=b.useState(!1),[re,mt]=b.useState(null),Mt=b.useRef(null),rr=b.useRef(null),Ar=dF(N=>N.activeSessionId??N.sessions.keys().next().value??null),Fr=e??Ar,Xt=Kn(N=>!!N.docks[Gd]),Zr=Kn(N=>N.hosts[Gd]),Jt=Kn(N=>N.setDock),Pr=b.useCallback(async()=>{Be(!0);try{const N=await pF();qe(N),ye(null)}catch(N){ye(N instanceof Error?N.message:"ADB_UNAVAILABLE")}finally{Be(!1)}},[]);b.useEffect(()=>{Pr()},[Pr]);const Hr=ce?.devices??[],ps=Hr.find(N=>N.serial===ne)??null,Mr=!!(we&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(we)),jn=!!(ce?.adbAvailable&&!ce.scrcpyVersion),Tr=b.useCallback(()=>{const N=B.current,U=[...z.current.keys()];B.current=null,z.current.clear(),O.current=null,$.current=!1,tt.current=null,Mh(ee.current),ee.current=0,N&&x.current?.pointerCancel(N.x,N.y,N.type);const K=m.current;if(K)for(const fe of U)Kb(K,fe);Ve(null),qt(!1),q([]),Z(le.current)},[]);b.useEffect(()=>{const N=fe=>{z.current.has(fe.pointerId)&&(fe.type==="pointercancel"||fe.target!==m.current)&&Tr()},U=()=>Tr(),K=()=>{document.hidden&&Tr()};return window.addEventListener("pointerup",N,!0),window.addEventListener("pointercancel",N,!0),window.addEventListener("blur",U),document.addEventListener("visibilitychange",K),()=>{window.removeEventListener("pointerup",N,!0),window.removeEventListener("pointercancel",N,!0),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",K),Tr()}},[Tr]);const Jr=b.useCallback(()=>{Tr(),x.current?.disconnect(),x.current=null,Ce("idle"),ae(null),Ye(null)},[Tr]),ln=b.useCallback((N,U=!1)=>{const K=m.current;if(!K||!N)return;Tr(),x.current?.disconnect(),ae(null),!U&&y.current!==N&&Ye(null),y.current=N,zt(null),Qt(null);const fe=new UF(K,{onBitrateSupport:(ve,lt)=>{x.current!==fe||v.current.id!=="auto"||Qt(ve?null:lt??"BITRATE_REASON_UNAVAILABLE")},onState:(ve,lt)=>{x.current===fe&&(Ce(ve),ae(lt??null))},onHeader:ve=>{x.current===fe&&Ye(ve)},onStats:ve=>{x.current===fe&&St(ve)},onWarning:ve=>{x.current===fe&&zt(ve)}});x.current=fe;let Qe=v.current;Qe.id==="auto"?(S.current?.serial!==N&&(S.current={serial:N,policy:new fF}),S.current.policy.connected(performance.now()),Qe=S.current.policy.quality,R(Qe.bitRate)):S.current=null,L.current=Qe,fe.connect(N,Qe)},[Tr]);b.useEffect(()=>{if(ke!=="auto"||v.current.id!=="auto"||Ge!=="streaming"||!et.adaptation||document.hidden)return;const N=S.current,U=x.current;if(!N||N.serial!==ne||!U?.canSetBitrate)return;const K=m.current,fe=K?Math.max(K.clientWidth,K.clientHeight)*(window.devicePixelRatio||1)*le.current:1600,Qe=N.policy.sample(et.adaptation,performance.now(),fe||1600);Qe&&U.setBitrate(Qe.bitRate).then(ve=>{ve&&x.current===U&&(L.current=Qe,R(Qe.bitRate))})},[et,ke,Ge,ne,ln]);const Qr=b.useCallback(N=>{const U={...N.quality?{quality:{id:N.quality.id,maxSize:N.quality.maxSize,bitRate:N.quality.bitRate,maxFps:N.quality.maxFps}}:{},...N.activePresetId!==void 0?{activePresetId:N.activePresetId}:{},...N.presets!==void 0?{presets:N.presets}:{},...N.docked!==void 0?{docked:N.docked}:{},...N.deviceSerial!==void 0?{deviceSerial:N.deviceSerial}:{}};La({androidPanel:U}).catch(()=>{})},[]);b.useEffect(()=>{let N=!1;return fc().then(U=>{if(N)return;const K=U.androidPanel;if(K?.quality){const fe=R1(K.quality);v.current=fe,Ee(fe.id),Ie({maxSize:fe.maxSize,bitRate:fe.bitRate,maxFps:fe.maxFps}),Vd(fe)}Ne(K?.presets??[]),We(K?.activePresetId??null),K?.deviceSerial&&(ze.current=K.deviceSerial,Fe(K.deviceSerial))}).catch(()=>{}),()=>{N=!0}},[]);const ks=b.useCallback(N=>{const U=++De.current;It(fe=>[...fe,{id:U,left:N.left,top:N.top}]);const K=window.setTimeout(()=>{It(fe=>fe.filter(Qe=>Qe.id!==U)),nr.current=nr.current.filter(fe=>fe!==K)},300);nr.current.push(K)},[]),Dr=b.useCallback((N,U)=>{const K=x.current,fe=L.current;K?.supportsLiveBitrate&&y.current===N&&fe&&fe.maxSize===U.maxSize&&fe.maxFps===U.maxFps?K.setBitrate(U.bitRate).then(Qe=>{x.current===K&&(Qe?(L.current=U,Qt(null)):Qt(K.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):ln(N)},[ln,l]),en=b.useCallback(N=>{if(S.current=null,N.startsWith("user:")){const K=Pe.find(Qe=>Qe.id===N.slice(5));if(!K)return;const fe={id:"custom",maxSize:K.maxSize,bitRate:K.bitRate,maxFps:K.maxFps};v.current=fe,Ee("custom"),We(K.id),Ie({maxSize:K.maxSize,bitRate:K.bitRate,maxFps:K.maxFps}),Ze(!0),Vd(fe),Qr({quality:fe,activePresetId:K.id}),ne&&ln(ne);return}if(N==="custom"){const K=v.current;Ee("custom"),We(null),Ie({maxSize:K.maxSize,bitRate:K.bitRate,maxFps:K.maxFps}),Ze(!0);return}const U=N==="auto"?R1({id:"auto"}):Ff.find(K=>K.id===N)??E0;v.current=U,Ee(U.id),We(null),Vd(U),Qr({quality:U,activePresetId:null}),ne&&ln(ne)},[ln,ne,Pe,Qr]),xn=b.useCallback(()=>{const N={id:"custom",maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps};v.current=N,Vd(N),Qr({quality:N,activePresetId:null}),Ee("custom"),We(null),ne&&Dr(ne,N)},[Dr,ne,at,Qr]),X=b.useCallback(()=>{const N=nt.trim();if(!N)return;const U=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,K={id:U,name:N,maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps},fe=[...Pe.filter(ve=>ve.name!==N),K].slice(-12),Qe={id:"custom",maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps};Ne(fe),gt(""),We(U),Ee("custom"),v.current=Qe,Vd(Qe),Qr({quality:Qe,activePresetId:U,presets:fe}),ne&&Dr(ne,Qe)},[nt,at,Pe,ne,Dr,Qr]),He=b.useCallback(()=>{if(!oe)return;const N=Pe.filter(U=>U.id!==oe);Ne(N),We(null),Qr({activePresetId:null,presets:N})},[oe,Pe,Qr]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const N of nr.current)window.clearTimeout(N);nr.current=[]},[]),b.useEffect(()=>{if(d==="off")return;const N=U=>{U.key==="Escape"&&p("off")};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[d,p]),b.useEffect(()=>{const N=Hr.filter(K=>K.state==="device");if(ne||N.length!==1)return;const U=N[0].serial;ze.current!==U&&(ze.current=U,Fe(U))},[Hr,ne]),b.useEffect(()=>{ne&&ln(ne)},[ne,ln]),b.useEffect(()=>{if(Ge==="streaming"){Y.current=0,Kt(!1);return}if(Ge!=="error"||!ne||!e$(H??""))return;const N=Math.min(8e3,700*2**Y.current);Y.current+=1,Kt(!0);const U=window.setTimeout(()=>{Kt(!1),ln(ne)},N);return()=>window.clearTimeout(U)},[Ge,H,ne,ln]);const Nt=b.useCallback((N,U,K)=>{const fe=m.current,Qe=K??(fe?Rh(fe):null);return!fe||!Qe?{x:0,y:0}:J6(N,U,Qe)},[]),Et=b.useCallback(()=>{const N=m.current;if(!N)return;const{x:U,y:K}=be.current,fe=le.current,Qe=fe===_l&&U===0&&K===0?"":`translate3d(${U}px, ${K}px, 0) scale(${fe})`;N.style.transform!==Qe&&(N.style.transform=Qe);const ve=pe.current;ve&&(ve.textContent=fe>_l?YF(fe):"")},[]),tr=b.useCallback((N,U,K=!0)=>{const fe=m.current,Qe=le.current,ve=qF(N);if(!fe||ve===Qe)return;const lt=Rh(fe);if(!lt)return;const vt=U??{x:lt.cx,y:lt.cy},br=qb({zoom:Qe,pan:be.current},lt,vt,vt,ve/Qe);le.current=br.zoom,be.current=br.pan,K&&Et()},[Et]),jr=b.useCallback(()=>{const N=le.current;Z(U=>U<=_l+.01==N<=_l+.01&&U>=nf-.01==N>=nf-.01?U:N)},[]);b.useEffect(()=>()=>{Mh(ee.current),Mh(_e.current)},[]);const cr=()=>{let N=0,U=0;for(const fe of z.current.values())N+=fe.x,U+=fe.y;const K=z.current.size;return K?{x:N/K,y:U/K}:null},Cn=()=>{const[N,U]=Array.from(z.current.values());return N&&U?Math.hypot(N.x-U.x,N.y-U.y):0},Ls=()=>{const N=cr(),U=m.current?Rh(m.current):null;!N||!U||(O.current={startCentroid:N,startDistance:Cn(),box:U})},Xn=b.useCallback(()=>{const N=O.current,U=cr();if(!N||!U)return;const K=Cn(),fe=N.startDistance>0&&K>0?K/N.startDistance:1,Qe=qb({zoom:le.current,pan:be.current},N.box,N.startCentroid,U,fe);le.current=Qe.zoom,be.current=Qe.pan,N.startCentroid=U,N.startDistance=K},[]),cn=b.useCallback(()=>{ee.current||(ee.current=Xb(()=>{ee.current=0,Xn(),Et()}))},[Xn,Et]),dn=b.useCallback(()=>{ee.current&&(Mh(ee.current),ee.current=0,Xn(),Et())},[Xn,Et]);b.useEffect(()=>{const N=m.current;if(!N)return;const U=N.parentElement;if(!U)return;const K=Qe=>{if(Qe.ctrlKey||Qe.metaKey){if(Qe.preventDefault(),!Qe.deltaY||O.current)return;const vt=Qe.deltaMode===1?16:Qe.deltaMode===2?N.parentElement?.clientHeight||600:1,br=Math.max(-600,Math.min(600,Qe.deltaY*vt));tr(le.current*Math.exp(-br*.002),{x:Qe.clientX,y:Qe.clientY},!1),_e.current||(_e.current=Xb(()=>{_e.current=0,Et(),jr()}));return}const ve=x.current;if(!ve||Qe.target!==N)return;Qe.preventDefault();const lt=Dh(N,Qe.clientX,Qe.clientY);ve.scroll(lt.x,lt.y,Qe.deltaX,Qe.deltaY)},fe=Qe=>Qe.preventDefault();return U.addEventListener("wheel",K,{passive:!1}),U.addEventListener("gesturestart",fe,{passive:!1}),U.addEventListener("gesturechange",fe,{passive:!1}),()=>{U.removeEventListener("wheel",K),U.removeEventListener("gesturestart",fe),U.removeEventListener("gesturechange",fe)}},[tr,Et,jr]),b.useEffect(()=>{const N=m.current,U=N?.parentElement;if(!N||!U||typeof ResizeObserver>"u")return;const K=new ResizeObserver(()=>{O.current&&(O.current.box=Rh(N));const fe=Nt(be.current,le.current);fe.x===be.current.x&&fe.y===be.current.y||(be.current=fe,Et())});return K.observe(N),K.observe(U),()=>K.disconnect()},[Nt,Et]),b.useLayoutEffect(()=>{Et()});const _r=N=>{const U=x.current,K=m.current;if(!U||!K)return;if(N.pointerType==="mouse"&&N.button!==0){N.preventDefault(),N.button===2?U.back():N.button===1&&U.home();return}N.preventDefault(),K.closest(".android-mirror-panel")?.focus({preventScroll:!0}),Et(),jr(),dn(),ZF(K,N.pointerId),z.current.set(N.pointerId,{x:N.clientX,y:N.clientY});const fe=N.pointerType==="mouse"&&N.altKey;if(z.current.size>=2||fe){const lt=B.current;lt&&(U.pointerCancel(lt.x,lt.y,lt.type),B.current=null,tt.current=null,Ve(null),qt(!1),q([])),$.current=!0,Ls();return}if($.current)return;const Qe=Dh(K,N.clientX,N.clientY);B.current={id:N.pointerId,type:N.pointerType,x:Qe.x,y:Qe.y},U.pointerDown(Qe.x,Qe.y,N.pointerType);const ve=ny(K,N.clientX,N.clientY);ve&&(tt.current={left:ve.left,top:ve.top},q([]),qt(!1),Ve(ve))},Or=N=>{const U=x.current,K=m.current;if(!K||!z.current.has(N.pointerId))return;if(N.pointerType==="mouse"){const vt=K.getBoundingClientRect(),br=K.parentElement?.getBoundingClientRect()??vt;if(!(N.buttons&1)||N.clientX<Math.max(vt.left,br.left)||N.clientX>=Math.min(vt.right,br.right)||N.clientY<Math.max(vt.top,br.top)||N.clientY>=Math.min(vt.bottom,br.bottom)){Tr();return}}if(N.preventDefault(),z.current.set(N.pointerId,{x:N.clientX,y:N.clientY}),O.current){cn();return}const fe=B.current;if(!U||!fe||fe.id!==N.pointerId)return;const Qe=Dh(K,N.clientX,N.clientY);fe.x=Qe.x,fe.y=Qe.y,U.pointerMove(Qe.x,Qe.y,fe.type);const ve=ny(K,N.clientX,N.clientY),lt=tt.current;!ve||!lt||(Ve(ve),Math.hypot(ve.left-lt.left,ve.top-lt.top)>=6&&(qt(!0),q(vt=>{const br=vt[vt.length-1];if(br&&Math.hypot(ve.left-br.x,ve.top-br.y)<4)return vt;const Lt=[...vt,{x:ve.left,y:ve.top}];return Lt.length>12?Lt.slice(Lt.length-12):Lt})))},Gn=N=>{const U=x.current,K=m.current;if(!K||!z.current.has(N.pointerId))return;if(dn(),z.current.delete(N.pointerId),Kb(K,N.pointerId),z.current.size===0&&($.current=!1),O.current){z.current.size===0?(O.current=null,Z(le.current)):Ls();return}const fe=B.current;if(!fe||fe.id!==N.pointerId)return;const Qe=Dh(K,N.clientX,N.clientY);U?.pointerUp(Qe.x,Qe.y,fe.type),xe&&ks(xe),Ve(null),qt(!1),window.setTimeout(()=>q([]),200),B.current=null,tt.current=null},Vn=N=>{if(un||Ke||Ct)return;const U=x.current;U&&(N.key==="Backspace"?(N.preventDefault(),U.key(67)):N.key==="Escape"?(N.preventDefault(),U.back()):N.key==="Enter"&&(N.preventDefault(),U.key(66)))},gn=async()=>{const N=$t.trim();if(N){Rt(!0);try{const U=await mF(N);yt(""),_t(!1),await Pr(),Fe(U.serial)}catch(U){ye(U instanceof Error?U.message:"ADB_CONNECT_FAILED")}finally{Rt(!1)}}},Jn=()=>{const N=x.current,U=Yt;!N||!U||(N.sendText(U),Sr(""))},kr=b.useCallback(N=>{dr(N),Cr.current!==null&&window.clearTimeout(Cr.current),Cr.current=window.setTimeout(()=>{Cr.current=null,dr(null)},2500)},[]),Lr=b.useCallback(N=>{const U=le.current,K=N==="in"?Zb.find(fe=>fe>U+.01):[...Zb].reverse().find(fe=>fe<U-.01);K!==void 0&&(U<=_l&&K>_l&&kr(l("android.zoomPanHint")),dn(),tr(K),Z(K))},[tr,dn,kr,l]),pr=N=>{Promise.resolve().then(()=>r?.(N)).catch(U=>{Gr(U instanceof Error?U.message:String(U))})},ns=b.useCallback(async(N,U)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(N),kr(U)}catch(K){Gr(l("android.captureFailed")+(K instanceof Error?`:${K.message}`:""))}},[n,kr,l]),Un=async()=>{const N=m.current;if(!(!N||qr.current)){qr.current=!0,on(!0),Gr(null);try{const U=await WF(N);await ns(U,l("android.captureInserted"))}catch(U){Gr(U instanceof Error?U.message:String(U))}finally{qr.current=!1,on(!1)}}},En=b.useCallback(N=>{(N.status==="ready"||N.status==="error")&&zr.current&&!Br.current.has(N.id)&&(Br.current.add(N.id),zr.current?.(N))},[]),kn=b.useCallback(async N=>{const U=Xr.current;if(!(!U||bt.current)){bt.current=!0,st(!0),Gr(null);try{const K=await yF(U.id);Xr.current=null,pt(!1),En(K)}catch(K){Gr(K instanceof Error?K.message:String(K))}finally{bt.current=!1,st(!1)}}},[En]),ss=async()=>{if(!(!ne||bt.current||Xr.current)){bt.current=!0,st(!0),Gr(null);try{const N=await bF(ne);N.status==="recording"||N.status==="starting"||N.status==="stopping"?(Xr.current=N,pt(!0),Mn(Math.max(0,Date.now()-N.startedAt))):En(N)}catch(N){Gr(N instanceof Error?N.message:String(N))}finally{bt.current=!1,st(!1)}}};b.useEffect(()=>{let N=!1,U=!1;Xr.current=null,pt(!1);const K=async()=>{if(!(!ne||U||bt.current)){U=!0;try{const{recordings:Qe}=await xF(ne);if(N||bt.current)return;const ve=Qe.find(lt=>["starting","recording","stopping"].includes(lt.status));Xr.current=ve??null,pt(!!ve);for(const lt of Qe)En(lt)}catch{}finally{U=!1}}};K();const fe=window.setInterval(()=>{K()},2e3);return Vr.current=window.setInterval(()=>{Xr.current&&Mn(Math.max(0,Date.now()-Xr.current.startedAt))},500),()=>{N=!0,window.clearInterval(fe),Vr.current!==null&&window.clearInterval(Vr.current)}},[ne,En]),b.useEffect(()=>{if(!un)return;const N=()=>Er(!1),U=fe=>{const Qe=fe.target;Qe instanceof Node&&(Mt.current?.contains(Qe)||rr.current?.contains(Qe)||N())},K=fe=>{fe.key==="Escape"&&(fe.preventDefault(),fe.stopPropagation(),N())};return document.addEventListener("pointerdown",U,!0),document.addEventListener("keydown",K,!0),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",U,!0),document.removeEventListener("keydown",K,!0),window.removeEventListener("resize",N)}},[un]),b.useEffect(()=>()=>{Cr.current!==null&&window.clearTimeout(Cr.current)},[]);const Wr=Ge==="streaming",tn=Xt,G=tn?"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",Me=ps?(ps.model||ps.serial)+sy(ps,l):Hr.length?l("android.selectDevice"):l("android.noDevices"),Je=(oe?Pe.find(N=>N.id===oe):null)?.name??(ke==="auto"?`${l("android.qualityAuto")} · ${E/1e6} Mbps`:l(Dm[ke])),it=tn?"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",Tt=tn?"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",kt="absolute inset-0 h-full w-full cursor-pointer opacity-0",Dt=()=>{const N=Mt.current?.getBoundingClientRect();N&&mt({left:Math.max(8,Math.min(N.right-jm,window.innerWidth-jm-8)),top:Math.min(N.bottom+4,Math.max(8,window.innerHeight-VF-8))}),Er(!0)},ft=()=>{if(Xt){Jt(Gd,null),Qr({docked:null});return}if(!Fr)return;const N={sessionId:Fr,side:"right"};Jt(Gd,N),Qr({docked:N})},Bt=Ke||Xt||d!=="off",W=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:Vn,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":Xt?"true":void 0,className:tn?"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:[Xt&&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($f,{size:12})}),s.jsx(f9,{size:tn?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${it} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Tt} w-full`,children:Me}),s.jsxs("select",{value:ne,onChange:N=>{const U=N.target.value;Fe(U),ze.current=U,U&&Qr({deviceSerial:U})},className:kt,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:Hr.length?l("android.selectDevice"):l("android.noDevices")}),Hr.map(N=>s.jsx("option",{value:N.serial,children:(N.model||N.serial)+sy(N,l)},N.serial))]})]}),s.jsxs("div",{className:`${it} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Tt,children:Je}),s.jsxs("select",{value:oe?`user:${oe}`:ke,onChange:N=>en(N.target.value),className:kt,title:l(ke==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),ke==="auto"?` · ${E/1e6} Mbps`:""]}),Ff.map(N=>s.jsx("option",{value:N.id,children:l(Dm[N.id])},N.id)),Pe.map(N=>s.jsx("option",{value:`user:${N.id}`,children:N.name},N.id)),s.jsx("option",{value:"custom",children:l(Dm.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{Pr()},className:`${G} text-muted-foreground`,title:l("android.refresh"),children:Le?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(bn,{size:13})}),Wr?s.jsx("button",{type:"button",onClick:Jr,className:`${G} text-destructive`,title:l("android.disconnect"),children:s.jsx(Hy,{size:13})}):s.jsx("button",{type:"button",onClick:()=>ne&&ln(ne),disabled:!ne,className:`${G} text-primary`,title:l("android.connect"),children:s.jsx(oS,{size:13})}),(Wr||ot)&&s.jsx("button",{type:"button",onClick:()=>{Un()},disabled:!n||mn,className:`${G} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:mn?s.jsx(_n,{size:tn?12:13,className:"animate-spin"}):s.jsx($A,{size:tn?12:13})}),(Wr||ot)&&s.jsx("button",{type:"button",onClick:()=>{ot?kn("manual"):ss()},disabled:je||!ot&&!a,className:`${G} ${ot?"text-destructive":"text-muted-foreground"}`,title:l(ot?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(ot?"android.recordingStop":"android.recordingStart"),children:je?s.jsx(_n,{className:"animate-spin",size:13}):ot?s.jsx(zy,{size:tn?10:11,fill:"currentColor"}):s.jsx(Wy,{size:tn?12:13})}),s.jsx("button",{ref:Mt,type:"button",onClick:()=>un?Er(!1):Dt(),"aria-haspopup":"menu","aria-expanded":un,className:`${G} ${Bt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx(To,{size:tn?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{Er(!1),p("off"),c()},className:`${G} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(In,{size:14})})]}),un&&re&&Xs.createPortal(s.jsxs("div",{ref:rr,role:"menu","aria-label":l("android.more"),style:{left:re.left,top:re.top,width:jm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(jh,{icon:s.jsx(ul,{size:13}),label:l("android.addDevice"),active:Ke,onSelect:()=>{_t(N=>!N),Er(!1)}}),s.jsx(jh,{icon:Xt?s.jsx(In,{size:13}):s.jsx(Il,{size:13}),label:l(Xt?"android.splitClose":"android.splitOpen"),active:Xt,disabled:!Xt&&!Fr,onSelect:()=>{ft(),Er(!1)}}),s.jsx(jh,{icon:d==="window"?s.jsx(MT,{size:13}):s.jsx(IT,{size:13}),label:l(d==="window"?"android.exitFullscreen":"android.fullscreen"),active:d==="window",onSelect:()=>{p(d==="window"?"off":"window"),Er(!1)}}),!t&&s.jsx(jh,{icon:d==="sidebar"?s.jsx(zT,{size:13}):s.jsx(VT,{size:13}),label:l(d==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:d==="sidebar",onSelect:()=>{p(d==="sidebar"?"off":"sidebar"),Er(!1)}}),Ae&&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:`${et.fps} fps · ${et.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${et.width}×${et.height}`})]})]}),document.body),(ke==="custom"||oe)&&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:()=>Ze(N=>!N),"aria-expanded":ue,className:"flex w-full items-center gap-1 rounded text-muted-foreground hover:text-foreground",children:[s.jsx(ul,{size:12,className:`transition-transform ${ue?"":"-rotate-90"}`}),s.jsxs("span",{children:[l("android.quality"),oe?` · ${Pe.find(N=>N.id===oe)?.name??""}`:""]})]}),ue&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(ry,{label:l("android.qualityResolution"),display:`${at.maxSize}px`,min:360,max:2160,step:8,value:at.maxSize,onChange:N=>Ie(U=>({...U,maxSize:N}))}),s.jsx(ry,{label:l("android.qualityBitRate"),display:`${(at.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:at.bitRate/1e6,onChange:N=>Ie(U=>({...U,bitRate:Math.round(N*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(N=>s.jsx("button",{type:"button",onClick:()=>Ie(U=>({...U,maxFps:N})),className:`rounded px-2 py-0.5 ${at.maxFps===N?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:N},N)),s.jsx("button",{type:"button",onClick:()=>Ie(N=>({...N,maxFps:0})),className:`rounded px-2 py-0.5 ${at.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:xn,disabled:!ne,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:nt,onChange:N=>gt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&X()},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:X,disabled:!nt.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:l("android.presetSave")}),oe&&s.jsx("button",{type:"button",onClick:He,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),Ke&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:$t,onChange:N=>yt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&gn()},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:()=>{gn()},disabled:xt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:xt?s.jsx(_n,{size:12,className:"animate-spin"}):l("android.connect")})]}),Mr&&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(ey,{label:l("android.insertFixPrompt"),onClick:()=>pr(ty("adb",we??"")),enabled:!!r})]}),!Mr&&jn&&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(ey,{label:l("android.insertFixPrompt"),onClick:()=>pr(ty("scrcpy","")),enabled:!!r})]}),ps&&ps.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:t$(ps,l)}),we&&!Mr&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Fb(we)}),Gt&&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(Gt.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Gt.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Gt.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Gt.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Gt.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Gt.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Gt})]}),wt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:wt}),me&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:me}),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:Wr||Ae?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:_r,onPointerMove:Or,onPointerUp:Gn,onPointerCancel:()=>Tr(),onLostPointerCapture:N=>{z.current.has(N.pointerId)&&Tr()},onPointerLeave:N=>{z.current.has(N.pointerId)&&!N.currentTarget.hasPointerCapture?.(N.pointerId)&&Tr()},onContextMenu:N=>N.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}}),ht.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:ut?1:0,transition:"opacity 160ms linear"},children:ht.slice(1).map((N,U)=>{const K=ht[U],fe=(U+1)/(ht.length-1);return s.jsx("line",{x1:K.x,y1:K.y,x2:N.x,y2:N.y,stroke:"var(--primary)",strokeWidth:1+1.6*fe,strokeLinecap:"round",opacity:.06+.45*fe},U)})}),Ot.map(N=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:N.left,top:N.top}},N.id)),!Wr&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[Ge==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(_n,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),Ge==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(Hu,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Vt?l("android.reconnecting"):Fb(H||"")}),ne&&s.jsx("button",{type:"button",onClick:()=>{Y.current=0,ln(ne)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),Ge==="idle"&&!Mr&&!jn&&s.jsxs(s.Fragment,{children:[s.jsx(DT,{size:22,className:"opacity-60"}),s.jsx("span",{children:Hr.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${tn?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Bo,{compact:tn,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!Wr,children:s.jsx(Iy,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!Wr,children:s.jsx(AT,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!Wr,children:s.jsx(Oy,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!Wr,children:s.jsx(Dy,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!Wr,children:s.jsx(fS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!Wr,children:s.jsx(QS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!Wr,children:s.jsx(OS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!Wr,children:s.jsx(cS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.inputText"),active:Ct,onClick:()=>fr(N=>!N),disabled:!Wr,children:s.jsx(Py,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.zoomIn"),onClick:()=>Lr("in"),disabled:!Wr||V>=nf-.01,children:s.jsx(zs,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.zoomOut"),onClick:()=>Lr("out"),disabled:!Wr||V<=_l+.01,children:s.jsx(Fy,{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":ot||!!pn||mn,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${ot||pn||mn?"invisible":""}`,children:Ae?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(JF,{recording:ot,elapsed:ir,status:mn?l("android.captureInserting"):pn,stopLabel:l("android.recordingStop"),onStop:()=>{kn("manual")}})})]})]}),Ct&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:Yt,onChange:N=>Sr(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&(N.preventDefault(),Jn())},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:Jn,disabled:!Yt,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(i0,{size:13})})]})]});return d==="window"?Xs.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:W}),document.body):t?Xt&&Zr?Xs.createPortal(W,Zr):null:Xt&&Zr?s.jsxs(s.Fragment,{children:[Xs.createPortal(W,Zr),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(Il,{size:18,className:"opacity-60"}),s.jsx("span",{children:l("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Jt(Gd,null),Qr({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):W}function jh({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(pi,{size:12,className:"shrink-0"})]})}function JF({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"}),Vb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${Vb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(zy,{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 Jb({sessionId:e}){const t=Kn(x=>x.docks[r0]),r=!!t,n=t?.sessionId??e??null,c=Mm(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await N0("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await Yb(w,n)},[n]),d=b.useCallback(x=>{Mm.getState().enqueue(x,n)},[n]),p=Kn(x=>!!x.hosts[r0]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,fc().then(x=>{const y=x.androidPanel?.docked;y&&(Kn.getState().docks[r0]||Kn.getState().setDock(r0,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&p&&s.jsx(XF,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>e4(x,n):void 0,onRecordingComplete:d}),c&&s.jsx(GF,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):Yb(x,c.sessionId),onDone:()=>Mm.getState().remove(c.file.id)},c.file.id)]})}function ey({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 ty(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 ry({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 Bo({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 ny(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 Dh(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 e$(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 sy(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 t$(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function r$(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function n$(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function s$(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,p=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 ${p}m`:p>0?y=`${p}m`:y="soon",`resets in ${y} (${m} ${x})`}function i$(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function a$({result:e}){const{t}=Ur(),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:i$(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 p=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:n$(d.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${p}%`,background:r$(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:s$(d.resetAt)})]},d.label)})}):c?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function o$({isOpen:e,onClose:t}){const{t:r}=Ur(),[n,a]=b.useState([]),[c,l]=b.useState(!1),d=async(x=!1)=>{l(!0);try{const y=x?await p9():await m9();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 p=n.filter(x=>!x.error),m=p.length>0?new Date(Math.max(...p.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(bn,{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(In,{size:17})})]})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:[c&&p.length===0?s.jsx(p0,{label:r("common.loading"),className:"py-12"}):p.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:p.map(x=>s.jsx(a$,{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~"}],l$=2,c$=20;function u$({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 d$({value:e,onChange:t,placeholder:r}){const{t:n}=Ur(),[a,c]=k.useState(""),l=y=>{const w=[];let v="",S=!1;const L=()=>{const R=v.trim();R&&w.push(R),v=""};for(let R=0;R<y.length;R+=1){const B=y[R];if(!S&&B==="/"&&v.trim().length===0){S=!0,v+=B;continue}if(S){if(v+=B,B==="/"&&y[R-1]!=="\\"&&v.length>1){for(;R+1<y.length&&/[gimsuy]/.test(y[R+1]??"");)R+=1,v+=y[R];L(),S=!1}continue}if(B===","||/\s/.test(B)){L();continue}v+=B}if(L(),w.length===0)return;const E=[...e];for(const R of w){const B=X3(R);B&&(E.includes(B)||E.push(B))}t(E),c("")},d=y=>{t(e.filter(w=>w!==y))},p=a.trim(),m=p.length>0&&j2(p),x=m&&!yf(p);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=j2(y),v=w&&!yf(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(In,{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 h$({value:e,min:t,max:r,onChange:n}){const{t:a}=Ur();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(Fy,{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(zs,{size:14})})]})}const f$=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:c,onResetDefaults:l})=>{const{t:d}=Ur(),p=e.find(R=>R.id===t)??e[0]??null,[m,x]=k.useState(null);if(!p)return null;const y=p.actions.length>0,w=[{id:"preview-auto",label:p.label,kind:"preset"},...p.includeAlt?[{id:"preview-alt",label:"Alt"}]:[],...y?p.actions.map((R,B)=>({id:R.id,label:o1(R,B)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(R=>({id:R,label:R}))],v=J3(w,p.rowLayout),S=(R,B)=>{n(p.id,z=>{const O=z.actions.findIndex(Z=>Z.id===R);if(O===-1)return z;const $=O+B;if($<0||$>=z.actions.length)return z;const V=[...z.actions];return[V[O],V[$]]=[V[$],V[O]],{...z,actions:V}})},L=p.rowLayout.reduce((R,B)=>R+B,0),E=1+(p.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:[p.actions.length," button",p.actions.length===1?"":"s"," · ",L," slot",L===1?"":"s"]})]}),s.jsx("div",{className:"space-y-1 rounded-2xl bg-surface-2/60 p-2",children:v.map((R,B)=>{const z=R.items[0]?.kind==="preset",O=Math.max(2,R.columns),$=z?`${ev}px repeat(${Math.max(1,O-1)}, minmax(0, 1fr))`:`repeat(${O}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:$},children:R.items.map(V=>V.kind==="preset"?s.jsx(tv,{mode:"auto",presetLabel:V.label,title:`Auto preset · ${V.label}`,disabled:!0},V.id):s.jsx(u$,{label:V.label},V.id))},`preview-row-${B}`)})}),p.actions.length>L-E&&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(zs,{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(bn,{size:14}),d("toolbarPresets.reset")]})]})]}),s.jsx("div",{className:"-mx-1 flex flex-wrap gap-1.5 px-1",children:e.map(R=>s.jsxs("button",{type:"button",onClick:()=>r(R.id),className:`rounded-full px-3 py-2 text-xs font-medium transition ${R.id===p.id?"bg-primary/20 text-primary ring-1 ring-primary/30":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,children:[R.label,R.actions.length>0&&s.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:R.actions.length})]},R.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:p.label,onChange:R=>n(p.id,B=>({...B,label:R.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"}),p.id!=="default"&&s.jsx("button",{type:"button",onClick:()=>c(p.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:p.label}),children:s.jsx(Rs,{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(d$,{value:p.programs,onChange:R=>n(p.id,B=>({...B,programs:R})),placeholder:d("toolbarPresets.programsPlaceholder")}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("toolbarPresets.programsHelp")})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,includeAlt:!R.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(ll,{checked:p.includeAlt})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,showOnDesktop:!R.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(ll,{checked:p.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(p.id,R=>({...R,rowLayout:[...J1(R.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(zs,{size:12}),d("toolbarPresets.addRow")]})]}),s.jsx("div",{className:"space-y-2",children:p.rowLayout.map((R,B)=>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:B+1})}),s.jsx("div",{className:"flex-1"}),s.jsx(h$,{value:R,min:l$,max:c$,onChange:z=>n(p.id,O=>({...O,rowLayout:O.rowLayout.map(($,V)=>V===B?z:$)}))}),p.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(p.id,z=>({...z,rowLayout:z.rowLayout.filter((O,$)=>$!==B)})),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:B+1}),children:d("toolbarPresets.del")})]},`row-${B}`))})]}),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 R=`${p.id}-action-${Date.now()}`;n(p.id,B=>({...B,actions:[...B.actions,{id:R,label:`Key ${B.actions.length+1}`,sequence:""}]})),x(R)},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(zs,{size:12}),d("toolbarPresets.addButton")]})]}),p.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")}),p.actions.map((R,B)=>{const z=m===R.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${z?"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:()=>S(R.id,-1),disabled:B===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(jy,{size:12})}),s.jsx("button",{type:"button",onClick:()=>S(R.id,1),disabled:B===p.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(EA,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(z?null:R.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:o1(R,B)}),s.jsxs("div",{className:"truncate text-[11px] text-muted-foreground",children:[R.sequence?R.sequence:d("toolbarPresets.noSequence"),R.doubleTapSequence&&s.jsxs("span",{className:"ml-1 text-accent/70",children:["· 2× ",R.doubleTapSequence]})]})]}),s.jsx("button",{type:"button",onClick:()=>n(p.id,O=>({...O,actions:O.actions.filter($=>$.id!==R.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:R.label}),children:s.jsx(Rs,{size:14})})]}),z&&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:R.label,onChange:O=>n(p.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,label:O.target.value}:V)})),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:R.sequence,onChange:O=>n(p.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,sequence:O.target.value}:V)})),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(O=>s.jsx("button",{type:"button",onClick:()=>n(p.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,sequence:O.sequence}:V)})),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:O.label},O.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")}),!R.doubleTapSequence&&s.jsx("button",{type:"button",onClick:()=>n(p.id,O=>({...O,actions:O.actions.map($=>$.id===R.id?{...$,doubleTapSequence:""}:$)})),className:"text-[10px] text-accent hover:text-accent/80",children:d("toolbarPresets.doubleTapAdd")})]}),R.doubleTapSequence!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:R.doubleTapSequence,onChange:O=>n(p.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:O.target.value}:V)})),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(O=>s.jsx("button",{type:"button",onClick:()=>n(p.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:(V.doubleTapSequence??"")+O.sequence}:V)})),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:O.label},O.label)),s.jsx("button",{type:"button",onClick:()=>n(p.id,O=>({...O,actions:O.actions.map($=>{if($.id!==R.id)return $;const{doubleTapSequence:V,...Z}=$;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")})]})]})]})]})]},R.id)})]})]})]})},p$={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function m$(){const{t:e}=Ur(),[t,r]=k.useState(null),[n,a]=k.useState(null),[c,l]=k.useState(null),[d,p]=k.useState(null),[m,x]=k.useState(!1),[y,w]=k.useState(!1),[v,S]=k.useState(""),[L,E]=k.useState(""),[R,B]=k.useState(null),[z,O]=k.useState([]),[$,V]=k.useState([]),[Z,le]=k.useState(null),[be,pe]=k.useState(new Set),[ee,_e]=k.useState(null),[ze,Y]=k.useState("auto"),[ce,qe]=k.useState({}),[we,ye]=k.useState(null),[Le,Be]=k.useState(null),[ne,Fe]=k.useState(10),[ke,Ee]=k.useState(""),[Pe,Ne]=k.useState(""),[oe,We]=k.useState(12e3),[nt,gt]=k.useState(null),[ue,Ze]=k.useState(null),at=k.useCallback(async()=>{const[xe,Ve,ht,q]=await Promise.allSettled([g9(),x9(),fc(),fd()]);if(r(xe.status==="fulfilled"?xe.value:[]),Ve.status==="fulfilled"){const ut=Ve.value;O(ut.plugins??[]),V(ut.errors??[])}else O([]),V([]);if(ht.status==="fulfilled"){const ut=ht.value;pe(new Set(ut.autoRenameAgents??[])),Y(ut.autoRenameNamer??"auto"),qe(ut.autoRenameModels??{}),Fe(ut.autoRenameIntervalMinutes??10),Ee(ut.autoRenamePromptPreference??""),Ne(ut.autoRenamePromptPreference??""),We(ut.autoRenamePromptPayloadChars??12e3)}else pe(new Set);ye(q.status==="fulfilled"?q.value:[])},[]);k.useEffect(()=>{at()},[at]);const Ie=async(xe,Ve)=>{a(xe),l(null);try{Ve==="install"?(await b9(xe)).devMode&&p(xe):(await y9(xe),d===xe&&p(null)),await at()}catch(ht){l(ht instanceof Error?ht.message:String(ht))}finally{a(null)}},Ge=xe=>e(xe==="installed"?"settings.agentHooksInstalled":xe==="outdated"?"settings.agentHooksOutdated":xe==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),Ce=async()=>{B(null);let xe;try{xe=JSON.parse(L)}catch{B("Invalid JSON");return}try{await C9(xe),E(""),x(!1),await at()}catch(Ve){if(Ve instanceof _9&&Ve.migration){V(ht=>[{slug:typeof xe.slug=="string"?xe.slug:"manifest.json",errors:Ve.message.split(`
164
+ `),code:Ve.code,migration:Ve.migration},...ht.filter(q=>q.slug!==xe.slug)]);return}B(Ve instanceof Error?Ve.message:String(Ve))}},H=async()=>{const xe=v.trim();if(xe){gt("install"),B(null);try{await v9(xe),S(""),w(!1),await at()}catch(Ve){B(Ve instanceof Error?Ve.message:String(Ve))}finally{gt(null)}}},ae=async xe=>{gt(`remove:${xe}`);try{await S9(xe),Ze(Ve=>Ve?.slug===xe?null:Ve),await at()}catch(Ve){l(Ve instanceof Error?Ve.message:String(Ve))}finally{gt(null)}},Ae=async xe=>{gt(`check:${xe}`),l(null);try{await T9(xe),await at()}catch(Ve){l(Ve instanceof Error?Ve.message:String(Ve))}finally{gt(null)}},Ye=async xe=>{gt(`update:${xe}`),l(null);try{const Ve=await A9(xe),ht=[Ve.hookWarning,Ve.titleWarning].filter(Boolean).join(" ");ht&&l(ht),Ze(q=>q?.slug===xe?null:q),await at()}catch(Ve){l(Ve instanceof Error?Ve.message:String(Ve))}finally{gt(null)}},et=async xe=>{gt(`doctor:${xe}`),l(null),Ze(null);try{const Ve=await w9(xe);Ze(Ve),ye(await fd())}catch(Ve){l(Ve instanceof Error?Ve.message:String(Ve))}finally{gt(null)}},St=async xe=>{const Ve=xe.migration?.aiPrompt??xe.errors.join(`
165
+ `);try{await navigator.clipboard.writeText(Ve),le(xe.slug),window.setTimeout(()=>le(ht=>ht===xe.slug?null:ht),1800)}catch{B(Ve)}},Gt=async xe=>{if(ee)return;const Ve=be,ht=new Set(Ve);ht.has(xe)?ht.delete(xe):ht.add(xe),pe(ht),_e(xe),l(null);try{const q=await La({autoRenameAgents:[...ht]});pe(new Set(q.autoRenameAgents??[])),ye(await fd(!0))}catch(q){pe(Ve),l(q instanceof Error?q.message:String(q))}finally{_e(null)}},Qt=async xe=>{const Ve=ze;Y(xe),Be("namer"),l(null);try{const ht=await La({autoRenameNamer:xe});Y(ht.autoRenameNamer??"auto"),ye(await fd(!0))}catch(ht){Y(Ve),l(ht instanceof Error?ht.message:String(ht))}finally{Be(null)}},wt=async(xe,Ve)=>{const ht=ce,q={...ht};Ve?q[xe]=Ve:delete q[xe],qe(q),Be(xe),l(null);try{const ut=await La({autoRenameModels:q});qe(ut.autoRenameModels??{})}catch(ut){qe(ht),l(ut instanceof Error?ut.message:String(ut))}finally{Be(null)}},zt=async xe=>{const Ve=ne;Fe(xe),Be("interval"),l(null);try{const ht=await La({autoRenameIntervalMinutes:xe});Fe(ht.autoRenameIntervalMinutes??10)}catch(ht){Fe(Ve),l(ht instanceof Error?ht.message:String(ht))}finally{Be(null)}},Vt=async()=>{const xe=ke.trim();if(xe!==Pe){Be("preference"),l(null);try{const ht=(await La({autoRenamePromptPreference:xe})).autoRenamePromptPreference??"";Ee(ht),Ne(ht)}catch(Ve){Ee(Pe),l(Ve instanceof Error?Ve.message:String(Ve))}finally{Be(null)}}},Kt=async xe=>{const Ve=Math.max(1e3,Math.min(64e3,Math.round(xe||12e3))),ht=oe;We(Ve),Be("payload-limit"),l(null);try{const q=await La({autoRenamePromptPayloadChars:Ve});We(q.autoRenamePromptPayloadChars??12e3)}catch(q){We(ht),l(q instanceof Error?q.message:String(q))}finally{Be(null)}},Ot=new Set(z.map(xe=>xe.slug)),It=ue?{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")}[ue.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:Le!==null,onChange:xe=>{Qt(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")}),we?.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:ne,disabled:Le!==null,onChange:xe=>{zt(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:ke,maxLength:2e3,rows:3,disabled:Le!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:xe=>Ee(xe.target.value),onBlur:()=>{Vt()},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:Le==="preference"?e("settings.saving"):`${ke.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:oe,disabled:Le!==null,onChange:xe=>We(Number(xe.target.value)),onBlur:xe=>{Kt(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 fd(!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(bn,{size:11,className:we===null?"animate-spin":""})})]}),we?.filter(xe=>xe.available).map(xe=>{const Ve=xe.models.find(ht=>ht.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:ce[xe.slug]??"",disabled:Le!==null,onChange:ht=>{wt(xe.slug,ht.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:Ve?`${e("settings.agentAutoRenameAutomatic")} · ${Ve.displayName}`:e("settings.agentAutoRenameCliDefault")}),xe.models.map(ht=>s.jsx("option",{value:ht.id,children:ht.displayName},ht.id))]})]},xe.slug)}),we?.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(_n,{size:12,className:"animate-spin"})," …"]}),t?.map(xe=>{const Ve=n===xe.slug,ht=xe.state!=="not-installed",q=Ot.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(Wc,{agent:{slug:xe.slug,displayName:xe.displayName,accentColor:xe.accentColor??"#878580",icon:xe.icon,isPlugin:q,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}),q&&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] ${p$[xe.state]}`,children:[xe.state==="installed"&&s.jsx(zu,{size:10,className:"mr-0.5 inline"}),(xe.state==="outdated"||xe.state==="needs-approval")&&s.jsx(P1,{size:10,className:"mr-0.5 inline"}),Ge(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:ee!==null,onClick:()=>{Gt(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":be.has(xe.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(ll,{checked:be.has(xe.slug),disabled:ee!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:Ve,onClick:()=>{Ie(xe.slug,ht?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${ht?"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:[Ve?s.jsx(_n,{size:11,className:"animate-spin"}):ht?s.jsx(Rs,{size:11}):xe.state==="outdated"?s.jsx(bn,{size:11}):s.jsx(g0,{size:11}),Ve?"…":ht?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(zs,{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=>S(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&H()},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()||nt!==null,onClick:()=>{H()},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:[nt==="install"?s.jsx(_n,{size:11,className:"animate-spin"}):s.jsx(g0,{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")})]}),z.map(xe=>{const Ve=xe.revision?.slice(0,8),ht=nt?.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"),Ve?` · ${Ve}`:""]})]}),s.jsxs("button",{type:"button",disabled:nt!==null,onClick:()=>{et(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:[nt===`doctor:${xe.slug}`?s.jsx(_n,{size:10,className:"animate-spin"}):s.jsx(_S,{size:10}),e("settings.agentPluginDoctor")]}),xe.updateSupported&&s.jsxs("button",{type:"button",disabled:nt!==null,onClick:()=>{xe.updateAvailable?Ye(xe.slug):Ae(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:[ht?s.jsx(_n,{size:10,className:"animate-spin"}):s.jsx(bn,{size:10}),xe.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:nt!==null,onClick:()=>{ae(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(Rs,{size:11})})]},xe.slug)}),ue&&s.jsxs("div",{className:`mt-2 rounded-lg px-3 py-2 text-[10px] ${ue.status==="ok"||ue.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:[ue.displayName,": ",It]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:ue.models.length>0?`${ue.models.length} ${e("settings.agentPluginDoctorModels")}${ue.recommendedModel?` · ${e("settings.agentPluginDoctorAutomatic")} ${ue.recommendedModel}`:""}`:e("settings.agentPluginDoctorCliDefault")}),ue.error&&s.jsx("div",{className:"mt-1 break-words",children:ue.error}),ue.warnings.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:ue.warnings.map(xe=>s.jsxs("div",{children:["• ",xe]},xe))}),ue.nextSteps.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:ue.nextSteps.map(xe=>s.jsxs("div",{children:["→ ",xe]},xe))})]}),$.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:()=>{St(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(zu,{size:10}):s.jsx(By,{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:L,onChange:xe=>E(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
+ }`}),R&&s.jsx("div",{className:"whitespace-pre-wrap break-words text-[10px] text-[color:var(--warning)]",children:R}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Ce()},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(tT,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),E(""),B(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function g$({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:d,onCheckDesktop:p,onInstallDesktop:m}){const{t:x}=Ur(),y=e?.status??"idle",w=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,S=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"),L=a?.currentVersion||l?.appVersion,E=a?.status??"idle",R=c||E==="checking"||E==="downloading"||E==="installing",B=E==="ready",z=a?.error||(E==="unsupported"?x("settings.desktopUpdateUnsupported"):E==="checking"?x("settings.desktopUpdateChecking"):E==="current"?x("settings.desktopUpdateCurrent"):E==="downloading"?x("settings.desktopUpdateDownloading"):E==="ready"?x("settings.desktopUpdateReady"):E==="installing"?x("settings.desktopUpdateInstalling"):E==="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(bn,{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:S}),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 ${B?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(bn,{size:15,className:R?"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?z:x(p?"settings.desktopStatusLoading":"settings.desktopUpdateUnsupported")}),s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:B&&a?.latestVersion?`${a.currentVersion} → ${a.latestVersion}`:L?`v${L}`:null})]})]}),B?s.jsx("button",{type:"button",disabled:R||!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||R||E==="unsupported"||!p,onClick:p,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(E==="installing"?"settings.updateInstallingShort":E==="downloading"?"settings.desktopUpdateDownloadingShort":E==="checking"?"settings.updateCheckingShort":E==="current"||E==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),d]})}function x$({quality:e}){const{locale:t}=Ur(),r=(d,p)=>t==="zh"?d:p,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(([p,m])=>s.jsxs(k.Fragment,{children:[s.jsx("dt",{children:p}),s.jsx("dd",{className:"text-right text-foreground break-all",children:m})]},p))}),l=(d,p)=>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}),p]});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 b$({backendSessionId:e}){const{locale:t}=Ur(),r=t==="zh",[n,a]=k.useState(null),[c,l]=k.useState(!1);k.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(k9(e));y();const w=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(w),document.removeEventListener("visibilitychange",y)}},[e,c]);const d=n?.diagnostics,p=n?.rtt,m=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":p==null?r?"测量中…":"Measuring…":`${p} ms · ${p<150?r?"流畅":"Low latency":p<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||p!=null&&p>=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(x$,{quality:n})]})]})]})}const ay={"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 y$(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 v$({state:e,onDismiss:t}){const{t:r}=Ur(),[n,a]=b.useState(!1),[c,l]=b.useState(!1),d=b.useRef(!1),p=b.useRef(!0);b.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(d.current=!1,a(!1),l(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const z=window.setTimeout(()=>{d.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(z)},[n]);const m=async()=>{if(!d.current){d.current=!0,l(!1),a(!0);try{await L9()}catch{if(!p.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,S=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",L=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):w?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),E=x?r(ay[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(ay[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",B=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:y$(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(vS,{size:15}):s.jsx(AS,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:L}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(S?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${E}${R?` · ${R}`:""}`:r("settings.serverHealthClean")}),x&&S&&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:B}),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 w$=()=>()=>{},A$=()=>1/0;function T$(){const{t:e}=Ur(),t=b.useId(),r=Po(),n=b.useSyncExternalStore(r?.subscribe??w$,r?.retentionLimit??A$);if(!r)return null;const a=I9+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 M1="mobile-session-destroy";function S$(e,t){return t&&e.type==="session"&&e.destination?.droppableId===M1}const Ca="termdock-program-rules-cache",Bh="termdock-toolbar-presets-cache",qd="termdock-settings-cache",oy="termdock-color-theme",ly="termdock:right-sidebar:file-preview-open-by-session:v2",Yd="termdock:running-session-button-enabled:v1",Zd="termdock:attention-button-enabled:v1",C$=60,cy=320,uy=420,Qo=8;function dy(e,t,r){return Math.min(Math.max(e,t),r)}function hy(e){if(typeof window>"u")return{left:Qo,top:Qo};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(Qo,window.innerWidth-cy-Qo),l=Math.max(Qo,window.innerHeight-uy-Qo);return{left:dy(n+Qo,Qo,c),top:dy(a+Qo,Qo,l),width:cy,maxHeight:`min(${uy}px, calc(100vh - ${Qo*2}px))`}}function _$(e){return e==="dark"||e==="light"}function k$(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 Bm(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,C$);return Object.fromEntries(t)}function L$(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 I$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function E$(e,t){const r=w0(),n=new Set(xE()),a=Array.isArray(e)?e:[],c=Ru(a),l=t<e0;if(c.length===0)return r;if(l){const p=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=p.get(w.id),S=m.get(w.id);return v?{...w,rowLayout:v.rowLayout,showOnDesktop:typeof S?.showOnDesktop=="boolean"?S.showOnDesktop:w.showOnDesktop}:w}),...x]}const d=new Set(c.map(p=>p.id));return[...c,...r.filter(p=>!d.has(p.id))]}function N$(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const R$={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},np="__termdockOverlay",sp="__termdockBaseAnchor",ip="__termdockBaseGuard",M$=3,fy=250,j$="termdock-notification-target-v1",py="/__termdock-notification-target",my=3e4;function D$(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 Su(e){if(!e||typeof e!="object")return null;const t=e[np];return D$(t)?t:null}function Ng(e){return e&&typeof e=="object"?{...e}:{}}function r4(e){const t=Ng(e);return delete t[np],t}function B$(e){const t=r4(e);return delete t[ip],{...t,[sp]:!0}}function Q$(){typeof window>"u"||window.history.pushState({...r4(window.history.state),[sp]:!0,[ip]:!0},"",window.location.href)}function n4(){for(let e=0;e<M$;e+=1)Q$()}function Qh(){typeof window>"u"||(window.history.replaceState(B$(window.history.state),"",window.location.href),n4())}function Kd(e){typeof window>"u"||window.history.pushState({...Ng(window.history.state),[sp]:!0,[np]:e,[ip]:!1},"",window.location.href)}function P$(e){typeof window>"u"||window.history.replaceState({...Ng(window.history.state),[sp]:!0,[np]:e,[ip]:!1},"",window.location.href)}const s4=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let _a=new Set(s4);function gy(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 O$(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 xy(e,t){return s.jsx($P,{sessionMode:e,state:t})}function F$(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 $$=k.lazy(()=>Oc(()=>import("./CollaborationMainWorkspace-BJzMdyZc.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function U$(){const{t:e,locale:t,setLocale:r}=Ur(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";E9();const c=k.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[l,d]=k.useState(!1),[p,m]=k.useState(()=>Tc(oy,_$)??"dark"),x=k.useRef(Tc(qd,N$)).current,[y,w]=k.useState(x?.preventSleep??!1),[v,S]=k.useState(x?.networkAvailable??!0),[L,E]=k.useState(N9),[R,B]=k.useState(R9),[z,O]=k.useState(M9),[$,V]=k.useState(j9),[Z,le]=k.useState(Tp),[be,pe]=k.useState(x?.localAccess??R$),[ee,_e]=k.useState(x?.localAccess?.name??""),[ze,Y]=k.useState(!1),[ce,qe]=k.useState(null),[we,ye]=k.useState(null),[Le,Be]=k.useState(null),[ne,Fe]=k.useState(!1),[ke,Ee]=k.useState(null),Pe=k.useMemo(()=>vo(),[]),Ne=!!(Pe?.desktopUpdateState&&Pe.checkDesktopUpdate&&Pe.installDesktopUpdate),[oe,We]=k.useState(null),[nt,gt]=k.useState(null),[ue,Ze]=k.useState(!1),[at,Ie]=k.useState(null),[Ge,Ce]=k.useState(!1),[H,ae]=k.useState(()=>Bm(Tc(ly,k$)??{})),[Ae,Ye]=k.useState(0),[et,St]=k.useState(!1),[Gt,Qt]=k.useState(0),[wt,zt]=k.useState(!1),[Vt,Kt]=k.useState(0),[Ot,It]=k.useState(!1),[xe,Ve]=k.useState(0),ht=k.useRef(null),[q,ut]=k.useState({}),{terminalSettings:qt,updateTerminalSettings:tt}=qB(),De=qt.fontSize,nr=qt.rendererMode,[Ke,_t]=k.useState(!1),$t=k.useRef(D9()).current,[yt,xt]=b.useState(()=>$t.sessions.map(C=>({id:C.sessionId,name:C.name,customName:C.customName,mode:C.mode,tmuxSessionName:C.tmuxSessionName}))),Rt=Ei(C=>C.groupId);k.useEffect(()=>{const C=()=>Ei.getState().terminal();return window.addEventListener("switch-terminal-session",C),()=>window.removeEventListener("switch-terminal-session",C)},[]);const[Ct,fr]=k.useState($t.activeSessionId),[Yt,Sr]=k.useState(!1);k.useEffect(()=>{Yt&&B9({rendered:!0})},[Yt]);const[pn,dr]=k.useState(null),[me,Gr]=k.useState(null),[ot,pt]=k.useState([]),[ir,Mn]=b.useState(()=>{const C=Yr.getState();return $t.sessions.forEach(P=>{P.backendSessionId&&C.setTerminalSession(P.sessionId,{sessionId:P.backendSessionId,cols:80,rows:24,mode:P.mode,tmuxSessionName:P.tmuxSessionName}),P.activeProgram!=null&&C.setSessionActiveProgram(P.sessionId,P.activeProgram),P.cwd!=null&&C.setSessionCwd(P.sessionId,P.cwd),P.shellTitle!=null&&C.setSessionShellTitle(P.sessionId,P.shellTitle)}),Mu("session-chrome-hydrated"),gy(Yr.getState().sessions)});b.useEffect(()=>{!Pe||!Ke||Promise.all([Pe.snapshot(),Pe.desktopUpdateState?.()??Promise.resolve(null)]).then(([C,P])=>{We(C),gt(P)}).catch(C=>Ie(C instanceof Error?C.message:String(C)))},[Pe,Ke]),b.useEffect(()=>{Pe?.onDesktopUpdateState&&Pe.onDesktopUpdateState(gt)},[Pe]),b.useEffect(()=>Yr.subscribe(C=>{const P=gy(C.sessions);Mn(de=>O$(de,P)?de:P)}),[]);const Xr=b.useCallback(async(C,P)=>{Gr(null),dr({sessionId:C,status:"submitting",error:null});try{await Q9(P),dr(de=>de?.sessionId===C?{...de,status:"waiting",error:null}:de)}catch(de){const At=(de&&typeof de=="object"&&"code"in de?String(de.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):de instanceof Error&&/busy/i.test(de.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");dr(Zt=>Zt?.sessionId===C?{...Zt,error:At}:Zt),Gr({tone:"error",message:At})}},[e]);b.useEffect(()=>{if(!pn||pn.status!=="waiting")return;const C=ir.get(pn.sessionId);if(!C||C.agentResumeRecovered||C.agentStatus===null&&!C.agent)return;const P=C.agent?.displayName??"Agent";dr(null),Gr({tone:"success",message:e("tab.resumeAgentSuccess",{agent:P})})},[pn,ir,e]),b.useEffect(()=>{if(!pn||pn.status!=="waiting"||pn.error)return;const C=pn.sessionId,P=window.setTimeout(()=>{const de=e("tab.resumeAgentTimeout");dr(rt=>rt?.sessionId===C&&rt.status==="waiting"?{...rt,error:de}:rt),Gr({tone:"error",message:de})},15e3);return()=>window.clearTimeout(P)},[pn,e]),b.useEffect(()=>{if(me?.tone!=="success")return;const C=window.setTimeout(()=>Gr(null),3200);return()=>window.clearTimeout(C)},[me]),b.useEffect(()=>{let C=!1;P9().then(de=>{C||Be(de)}).catch(()=>{}),O9().then(de=>{C||Ee(de)}).catch(()=>{});const P=ux(de=>{C||(de.type==="update-state"?Be(de.state):de.type==="server-health"&&Ee(de.state))});return()=>{C=!0,P()}},[]);const je=b.useCallback(async()=>{try{Ee(await F9())}catch(C){window.alert(C instanceof Error?C.message:String(C))}},[]),st=b.useCallback(async()=>{const C=Le?.latestVersion;if(!(!C||ne)&&window.confirm(e("sidebar.updateRestartConfirm",{version:C}))){Fe(!0);try{Be(await $9())}catch(P){window.alert(P instanceof Error?P.message:String(P))}finally{Fe(!1)}}},[Le?.latestVersion,e,ne]),bt=b.useCallback(async()=>{if(!ne){Fe(!0);try{Be(await U9())}catch(C){window.alert(C instanceof Error?C.message:String(C))}finally{Fe(!1)}}},[ne]),Br=b.useCallback(async()=>{if(!(!Pe?.checkDesktopUpdate||ue)){Ze(!0);try{gt(await Pe.checkDesktopUpdate())}catch(C){Ie(C instanceof Error?C.message:String(C))}finally{Ze(!1)}}},[Pe,ue]),Vr=b.useCallback(async()=>{if(!(!Pe?.installDesktopUpdate||ue||nt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ze(!0);try{gt(await Pe.installDesktopUpdate())}catch(C){Ie(C instanceof Error?C.message:String(C))}finally{Ze(!1)}}},[Pe,ue,nt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=p,z9(p),Fn(oy,p)},[p]),b.useEffect(()=>{Fn(ly,Bm(H))},[H]);const Cr=Wt(C=>C.leftOpen),qr=Wt(C=>C.rightOpen),mn=Wt(C=>C.leftPinned),on=Wt(C=>C.leftSidebarWidth),zr=Wt(C=>C.rightPinned),un=Wt(C=>C.rightSidebarWidth),Er=Wt(C=>C.rootPath),re=Wt(C=>C.contextKey),mt=Wt(C=>C.selectedFilePath),Mt=Wt(C=>C.groupByFolder),rr=df(C=>C.collaborationGroups),Ar=Wt(C=>C.collapsedGroups),Fr=Wt(C=>C.toggleGroupCollapsed),[Xt,Zr]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Jt,Pr]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[Hr,ps]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[Mr,jn]=b.useState([]),[Tr,Jr]=b.useState({available:!0,version:null,reason:null}),[ln,Qr]=b.useState(!1),[ks,Dr]=b.useState(null),[en,xn]=b.useState(null),[X,He]=b.useState(null),[Nt,Et]=b.useState(null),[tr,jr]=b.useState(null),[cr,Cn]=b.useState(null),[Ls,Xn]=b.useState(null),[,cn]=b.useState(0),[dn,_r]=b.useState(null),[Or,Gn]=b.useState(null),[Vn,gn]=b.useState(null),[Jn,kr]=b.useState(!1),[Lr,pr]=b.useState(()=>Tc(Yd,C=>typeof C=="boolean")??!1),ns=b.useCallback(async C=>{const P=Lr;pr(C),Fn(Yd,C);try{const de=await La({runningSessionButtonEnabled:C});pr(de.runningSessionButtonEnabled),Fn(Yd,de.runningSessionButtonEnabled)}catch{pr(P),Fn(Yd,P)}},[Lr]),[Un,En]=b.useState(()=>Tc(Zd,C=>typeof C=="boolean")??!0),kn=b.useCallback(async C=>{const P=Un;En(C),Fn(Zd,C);try{const de=await La({attentionButtonEnabled:C});En(de.attentionButtonEnabled),Fn(Zd,de.attentionButtonEnabled)}catch{En(P),Fn(Zd,P)}},[Un]),[ss,Wr]=b.useState(null),tn=b.useCallback(C=>{Wr(C)},[]),G=b.useRef(!1),[Me,$e]=b.useState(null),[Je,it]=b.useState(null),Tt=k.useRef(null),kt=k.useRef(!1),Dt=k.useRef(null),ft=k.useRef(!1),Bt=b.useCallback(()=>{Cn(null),Xn(null)},[]),W=k.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[N,U]=k.useState(W.current),[K,fe]=k.useState(!0),Qe=k.useRef(W.current),ve=k.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const C=window.matchMedia("(min-width: 1024px)"),P=()=>{Zr(C.matches),Pr(window.innerWidth)};return P(),C.addEventListener("change",P),window.addEventListener("resize",P),()=>{C.removeEventListener("change",P),window.removeEventListener("resize",P)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const C=window.matchMedia("(orientation: landscape)"),P=()=>ps(C.matches);return P(),C.addEventListener("change",P),()=>C.removeEventListener("change",P)},[]);const lt=k.useMemo(()=>Ct?ot.find(C=>C.sessionIds.includes(Ct))??null:null,[Ct,ot]),vt=lt?.id??null,br=lt?.sessionIds[0]??Ct,Lt=k.useRef([]);k.useLayoutEffect(()=>{const C=Lt.current;if(Lt.current=ot,C.length===0)return;const P=new Set(ot.flatMap(de=>de.sessionIds));for(const de of C){const rt=de.sessionIds.filter(At=>!P.has(At)).map(At=>({sessionId:At,rootPath:Yr.getState().sessions.get(At)?.cwd??null}));rt.length>0&&Wt.getState().inheritRightSidebarStateFromSplitWorkspace(de.id,rt)}},[ot]),k.useLayoutEffect(()=>((()=>{const P=br?Yr.getState().sessions.get(br)?.cwd??null:null;Wt.getState().setRootPath(P,br,vt)})(),Yr.subscribe((P,de)=>{const rt=br?P.sessions.get(br)?.cwd??null:null,At=br?de.sessions.get(br)?.cwd??null:null;rt!==At&&Wt.getState().setRootPath(rt,br,vt)})),[vt,br]);const rn=k.useRef(Xy(window.location.search)??rC(Sc()?.targetPeerId)),[yn,hn]=k.useState("");k.useEffect(()=>{const C=rn.current;if(!C)return;if(C.peerId&&C.peerId!==Sc()?.targetPeerId){const rt=H9().find(At=>At.targetPeerId===C.peerId);if(rt&&Po()){try{tC(C)}catch{hn(t==="zh"?"无法在此浏览器打开架构链接。":"Cannot open this architecture link in this browser.");return}if(W9(rt)){rn.current=null;const At=new URL(window.location.href);At.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",At);return}}hn(t==="zh"?`此架构属于 ${C.serviceName??C.peerId}。请先连接该 Termdock 服务,再打开链接。`:`This architecture belongs to ${C.serviceName??C.peerId}. Connect to that Termdock service, then open this link.`);return}hn("");try{sessionStorage.setItem(`termdock.architecture.selection:${C.root}`,C.file)}catch{}const P=Wt.getState();P.setRootPath(C.root,br,vt),P.setRightTab("architecture"),P.openRight();const de=new URL(window.location.href);de.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",de),br&&(rn.current=null)},[br,vt,t]);const Dn=Xt||Hr,zn=Jt*.95,hr=Dn?Math.min(Math.max(Jt*.22,280),340):Math.min(Jt*.86,380),jt=Ct&&Er?`${Ct}\0${Er}`:"",Bn=!!(jt&&mt&&H[jt]),qn=b.useCallback(C=>{jt&&(C&&!Wt.getState().selectedFilePath||ae(P=>{if(!!P[jt]===C)return P;if(C)return Bm({...P,[jt]:{updatedAt:Date.now()}});const rt={...P};return delete rt[jt],rt}))},[jt]);b.useEffect(()=>{eQ(jt,re,mt)&&ae(C=>{if(!C[jt])return C;const P={...C};return delete P[jt],P})},[jt,re,mt]);const Qn=Ot?"markdown-image-lightbox":wt?"markdown-outline":et?"right-sidebar-repo-picker":qr&&Bn?"right-sidebar-file-preview":Ke?"settings":qr&&!(zr&&Xt)?"right-sidebar":Cr&&!(mn&&Xt)?"left-sidebar":null,is=k.useRef(Qn),zi=k.useRef(Qn),da=k.useRef(!1),bs=k.useRef(!1),Ga=b.useCallback(()=>{if(typeof window>"u")return;const C=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!Xt||!C||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[Xt]),So=b.useCallback(C=>{if(C==="markdown-image-lightbox"){It(!1),Ve(P=>P+1);return}if(C==="markdown-outline"){zt(!1),Kt(P=>P+1);return}if(C==="right-sidebar-file-preview"){zt(!1),Kt(P=>P+1),qn(!1),Ye(P=>P+1);return}if(C==="right-sidebar-repo-picker"){St(!1),Qt(P=>P+1);return}if(C==="settings"){_t(!1),ws(!1),ni(!1),cs(!1);return}if(C==="left-sidebar"){Wt.getState().closeLeft();return}zt(!1),Kt(P=>P+1),St(!1),Qt(P=>P+1),It(!1),Ve(P=>P+1),Wt.getState().closeRight()},[qn]),Hn=b.useCallback(C=>{if(!c&&typeof window<"u"&&is.current===C&&Su(window.history.state)===C){window.history.back();return}So(C)},[So,c]),ha=b.useCallback(()=>{_t(!1);const C=Wt.getState();C.closeRight(),C.openLeft()},[]),ms=b.useCallback(()=>{_t(!1);const C=Wt.getState();C.closeLeft(),C.openRight()},[]),Ia=b.useCallback(()=>{_t(!1);const C=Wt.getState();C.closeLeft(),C.openRight(),C.setRightTab("files"),C.openRightSearch()},[]),as=b.useCallback(()=>{const C=Wt.getState();if(C.leftPinned){C.setLeftPinned(!1),C.closeLeft();return}if(Cr){Hn("left-sidebar");return}ha()},[ha,Hn,Cr]),Va=b.useCallback(()=>{const C=Wt.getState();C.leftPinned?(C.setLeftPinned(!1),C.openLeft()):(C.setLeftPinned(!0),C.openLeft())},[]),Js=b.useCallback(()=>{const C=Wt.getState();C.setLeftPinned(!1),C.closeLeft()},[]),ei=b.useCallback(()=>{const C=Wt.getState();C.rightPinned?(C.setRightPinned(!1),C.openRight()):(C.setRightPinned(!0),C.openRight())},[]),Hs=b.useCallback(()=>{const C=Wt.getState();C.setRightPinned(!1),C.closeRight()},[]),qa=b.useRef(0),Is=b.useRef(0),fa=b.useRef(null),dl=b.useCallback(C=>{C.preventDefault(),qa.current=C.clientX,Is.current=Wt.getState().leftSidebarWidth;const P=rt=>{fa.current===null&&(fa.current=requestAnimationFrame(()=>{fa.current=null;const At=rt.clientX-qa.current;Wt.getState().setLeftSidebarWidth(Is.current+At)}))},de=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",de),fa.current!==null&&(cancelAnimationFrame(fa.current),fa.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",P),window.addEventListener("mouseup",de)},[]),Ya=b.useRef(0),os=b.useRef(0),Ms=b.useRef(null),Hi=b.useCallback(C=>{C.preventDefault(),Ya.current=C.clientX;const P=Wt.getState(),de=P.leftPinned?P.leftSidebarWidth:0;os.current=Oh(P.rightSidebarWidth,window.innerWidth,de);const rt=Zt=>{Ms.current===null&&(Ms.current=requestAnimationFrame(()=>{Ms.current=null;const Nr=Ya.current-Zt.clientX,An=Wt.getState(),Nn=An.leftPinned?An.leftSidebarWidth:0;An.setRightSidebarWidth(Oh(os.current+Nr,window.innerWidth,Nn))}))},At=()=>{window.removeEventListener("mousemove",rt),window.removeEventListener("mouseup",At),Ms.current!==null&&(cancelAnimationFrame(Ms.current),Ms.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",rt),window.addEventListener("mouseup",At)},[]),xi=b.useCallback(()=>{const C=Wt.getState();if(C.rightPinned){C.setRightPinned(!1),C.closeRight();return}if(qr){Hn("right-sidebar");return}ms()},[ms,Hn,qr]),bi=b.useCallback(()=>{!Bn&&!c&&typeof window<"u"&&is.current==="right-sidebar"&&Su(window.history.state)==="right-sidebar"&&(Kd("right-sidebar-file-preview"),zi.current="right-sidebar-file-preview"),qn(!0)},[Bn,c,qn]),hl=b.useCallback(()=>{Hn("right-sidebar-file-preview")},[Hn]),ti=b.useCallback(()=>{!et&&!c&&typeof window<"u"&&is.current==="right-sidebar"&&Su(window.history.state)==="right-sidebar"&&(Kd("right-sidebar-repo-picker"),zi.current="right-sidebar-repo-picker"),St(!0)},[et,c]),Uo=b.useCallback(()=>{Hn("right-sidebar-repo-picker")},[Hn]),pa=b.useCallback(()=>{!wt&&!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&(Kd("markdown-outline"),zi.current="markdown-outline"),zt(!0)},[wt,c]),fl=b.useCallback(()=>{Hn("markdown-outline")},[Hn]),pl=b.useCallback(()=>{!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&(Kd("markdown-image-lightbox"),zi.current="markdown-image-lightbox"),It(!0)},[c]),ls=b.useCallback(()=>{Hn("markdown-image-lightbox")},[Hn]),js=b.useCallback(()=>{!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&(P$("settings"),zi.current="settings"),Wt.getState().closeAll(),_t(!0)},[c]),Ri=b.useCallback(()=>{Hn("settings")},[Hn]);b.useEffect(()=>{if(!Pe)return;const C=()=>js();return window.addEventListener("termdock:open-settings",C),()=>window.removeEventListener("termdock:open-settings",C)},[Pe,js]);const zo=b.useCallback(()=>{Ce(!0),ht.current!==null&&(window.clearTimeout(ht.current),ht.current=null)},[]),Dl=b.useCallback(()=>{ht.current!==null&&(window.clearTimeout(ht.current),ht.current=null),Ce(!1),bs.current=!0,Qh(),bs.current},[]);b.useEffect(()=>()=>{ht.current!==null&&window.clearTimeout(ht.current)},[]),b.useEffect(()=>{c||Qh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let C=null;const P=()=>{C!==null&&(window.clearTimeout(C),C=null)},de=An=>{if(is.current,bs.current,is.current){is.current;return}!An?.force&&bs.current||(An?.userActivated&&(bs.current=!0),Qh(),bs.current,void 0)},rt=()=>{P(),C=window.setTimeout(()=>{C=null,de({force:!0})},fy)},At=()=>{de({userActivated:!0})},Zt=()=>{rt()},Nr=()=>{document.visibilityState==="visible"&&rt()};return window.addEventListener("pointerdown",At,{capture:!0,passive:!0}),window.addEventListener("touchstart",At,{capture:!0,passive:!0}),window.addEventListener("keydown",At,{capture:!0}),window.addEventListener("pageshow",Zt),document.addEventListener("visibilitychange",Nr),()=>{P(),window.removeEventListener("pointerdown",At,{capture:!0}),window.removeEventListener("touchstart",At,{capture:!0}),window.removeEventListener("keydown",At,{capture:!0}),window.removeEventListener("pageshow",Zt),document.removeEventListener("visibilitychange",Nr)}},[c]),b.useEffect(()=>{is.current=Qn},[Qn]),b.useEffect(()=>{if(typeof window>"u"||Qn||c)return;const C=window.setTimeout(()=>{is.current?(is.current,void 0):Qh()},fy);return()=>window.clearTimeout(C)},[Qn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const C=zi.current;da.current,Qn&&Qn!==C&&!da.current&&Kd(Qn),!Qn&&C&&Ga(),zi.current=Qn,!Qn&&da.current&&window.setTimeout(()=>{da.current=!1},0)},[Qn,c,Ga]),b.useEffect(()=>{if(typeof window>"u"||c)return;const C=()=>{const P=is.current;if(bs.current,!P){bs.current=!1,bs.current,zo(),n4();return}da.current=!0,So(P)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[So,zo,c]),b.useEffect(()=>{const C=P=>{const de=P.metaKey||P.ctrlKey;if(de&&P.key==="b"&&!P.shiftKey&&(P.preventDefault(),as()),de&&P.shiftKey&&P.key==="E"&&(P.preventDefault(),xi()),de&&P.shiftKey&&P.key==="P"&&(P.preventDefault(),Ia()),de&&!P.shiftKey&&P.altKey&&(P.key==="ArrowLeft"||P.key==="ArrowRight")){P.preventDefault();const rt=P.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:rt}}));return}if(de&&P.shiftKey&&!P.altKey&&(P.code==="BracketLeft"||P.code==="BracketRight")){P.preventDefault();const rt=P.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:rt}}));return}};return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C)}},[as,xi,Ia]);const Es=b.useCallback(async()=>{Y(!0),qe(null);try{const C=await La({localAccess:{name:ee}});pe(C.localAccess),_e(C.localAccess.name),Fn(qd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){qe(C instanceof Error?C.message:"Failed to save local access name")}finally{Y(!1)}},[ee]),Ea=b.useCallback(async()=>{Y(!0),qe(null);try{const C=await La({localAccess:{reset:!0}});pe(C.localAccess),_e(C.localAccess.name),Fn(qd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){qe(C instanceof Error?C.message:"Failed to reset local access name")}finally{Y(!1)}},[]),ml=b.useCallback(async(C,P="url")=>{if(C)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(C);else{const de=document.createElement("textarea");de.value=C,de.style.position="fixed",de.style.left="-9999px",document.body.appendChild(de),de.focus(),de.select(),document.execCommand("copy"),document.body.removeChild(de)}ye(P),window.setTimeout(()=>ye(de=>de===P?null:de),1600)}catch{ye(null)}},[]),es=b.useCallback(C=>{const P=F$(yt,C);P.map(de=>de.id).join("\0")!==yt.map(de=>de.id).join("\0")&&(xt(P),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:P.map(de=>de.id)}})))},[yt]),Wi=b.useCallback(C=>{Xt||C.type!=="session"||(G.current=!1,kr(!1),gn(C.draggableId))},[Xt]),Mi=b.useCallback(C=>{if(Xt||C.type!=="session")return;const P=C.destination?.droppableId===M1;P!==G.current&&(G.current=P,kr(P),P&&navigator.vibrate?.(20))},[Xt]),Gi=b.useCallback(C=>{const P=S$(C,!Xt);if(G.current=!1,kr(!1),gn(null),!P)return!1;const de=yt.find(At=>At.id===C.draggableId),rt=de?ir.get(de.id):null;return de&&P5({mode:de.mode,activeProgram:rt?.activeProgram??null,promptState:rt?.promptState??null,shellNames:_a})?(it(null),$e(de.id),He(null)):de&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:de.id,source:"other",closeMode:de.mode==="tmux"?"destroy":"auto"}})),!0},[Xt,yt,ir]),{groups:gs,arranged:Ws}=k.useMemo(()=>cf(yt,C=>ir.get(C.id)?.cwd??null,Mt,e("sidebar.ungrouped"),ot,rr),[yt,ir,Mt,e,ot,rr]),Bl=b.useCallback(C=>{Gi(C)||!C.destination||C.source.index===C.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:Ws[C.source.index]?.id,targetId:Ws[C.destination.index]?.id}}))},[Gi,Ws]),Vi=b.useCallback((C,P)=>{const de=P.trim();de&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:C,name:de}}))},[]),qi=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:C}}))},[]),{newSessionMode:fn,newSessionTmuxName:ma,userSelectedNewSessionMode:Yi,setNewSessionMode:Na}=KB(),[ji,Di]=b.useState(null),[ri,ws]=k.useState(!1),[Gs,Bi]=k.useState(!1),[Ra,ni]=k.useState(!1),[ys,Za]=k.useState("idle"),Ka=k.useRef(Tc(Bh,I$)).current,[As,Xa]=k.useState(()=>{const C=Ka?.presets;if(C&&C.length>0){const P=Ru(C);if(P.length>0)return P}return w0()}),[Ql,Ho]=k.useState(!1),[Co,ga]=k.useState("default"),Ma=k.useRef(typeof Ka?.updatedAt=="number"?Ka.updatedAt:null),Wo=k.useRef(!1),[xa,cs]=k.useState(!1),[Go,Zi]=k.useState(!1),gl=k.useRef(Tc(Ca,L$)).current,[se,T]=k.useState(gl??[]),[j,Q]=k.useState(gl!==null),[F,ge]=k.useState(!1),Se=!Rt&&!Qn&&!Gs&&!Ra&&!ri&&!xa&&!Go&&!cr&&!Me&&!ji,Oe=k.useCallback(C=>{const P=typeof C.version=="number"?C.version:0,de=E$(Array.isArray(C.presets)?C.presets:[],P);Ma.current=typeof C.updatedAt=="number"?C.updatedAt:null,Xa(rt=>G9(rt,de)?rt:(Wo.current=!0,de)),Fn(Bh,{version:e0,presets:de,updatedAt:Ma.current??void 0})},[]);b.useEffect(()=>{const C=P=>{if(P.key!=="Escape"||P.defaultPrevented||P.isComposing||B1())return;if(Gs){P.preventDefault(),Bi(!1);return}if(Ra){P.preventDefault(),ni(!1);return}if(ri){P.preventDefault(),ws(!1);return}if(xa){P.preventDefault(),cs(!1);return}if(Go){P.preventDefault(),Zi(!1);return}if(cr){P.preventDefault(),Bt();return}if(dn){P.preventDefault(),jr(null),_r(null);return}if(Ke){P.preventDefault(),Ri();return}if(qr&&!(zr&&Xt)){P.preventDefault(),Hn("right-sidebar");return}Cr&&!(mn&&Xt)&&(P.preventDefault(),Hn("left-sidebar"))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[Gs,Ra,ri,xa,cr,Bt,Ke,qr,zr,Cr,mn,Xt,Ri,Hn]),b.useEffect(()=>{Q(!0)},[]);const[Xe,dt]=k.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:s4}),[,er]=k.useState(!1),or=k.useCallback(()=>V9().then(C=>{dt(C),_a=new Set(C.shellNames),er(!0)}).catch(()=>{}),[]);b.useEffect(()=>{or()},[or]),b.useEffect(()=>ux(C=>{if(C.type==="config-updated"){if(C.key==="toolbar-presets"){dx().then(P=>Oe(P)).catch(P=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",P)});return}C.key==="program-detection"&&or()}}),[Oe,or]),b.useEffect(()=>{let C=!1;return(async()=>{try{const P=await dx();if(C)return;Oe(P)}catch(P){console.warn("[toolbar-presets] Failed to load from server:",P)}finally{C||Ho(!0)}})(),()=>{C=!0}},[Oe]),b.useEffect(()=>{if(Ql){if(Wo.current){Wo.current=!1;return}Fn(Bh,{version:e0,presets:As,updatedAt:Ma.current??void 0}),q9({version:e0,presets:As,baseUpdatedAt:Ma.current??void 0}).then(C=>{Ma.current=typeof C.updatedAt=="number"?C.updatedAt:null,Fn(Bh,{version:e0,presets:As,updatedAt:Ma.current??void 0})}).catch(C=>{const P=C instanceof Error&&"current"in C?C.current:null;P&&typeof P=="object"&&Oe(P),console.warn("[toolbar-presets] Failed to save to server:",C)})}},[Oe,As,Ql]),b.useEffect(()=>{fc().then(C=>{w(P=>P===C.preventSleep?P:C.preventSleep),S(P=>P===C.networkAvailable?P:C.networkAvailable),pe(C.localAccess),_e(C.localAccess.name),pr(C.runningSessionButtonEnabled),Fn(Yd,C.runningSessionButtonEnabled),En(C.attentionButtonEnabled),Fn(Zd,C.attentionButtonEnabled),Fn(qd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!L)return;const C=Tp();le(C),C!=="granted"&&(E(!1),th(!1))},[L]),b.useEffect(()=>{if(!L)return;pd();const C=()=>{document.visibilityState==="visible"&&(pd(),oA())},P=window.setInterval(()=>{pd()},360*60*1e3);return document.addEventListener("visibilitychange",C),window.addEventListener("focus",C),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",C),window.removeEventListener("focus",C)}},[L]);const $r=b.useCallback(async()=>{if(L){E(!1),th(!1),Y9(),le(Tp());return}const C=await Z9();if(le(C),C!=="granted"){E(!1),th(!1);return}E(!0),th(!0),await pd(!0,!0),Za("idle")},[L]),nn=b.useCallback(async()=>{Za("checking"),await vo()?.prepareNotificationTest?.();const C=await K9({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Za(C?"delivered":"failed")},[e]),Pn=b.useCallback(C=>{B(C),X9(C),Sp()},[]),yr=b.useCallback(C=>{O(C),J9(C),Sp()},[]),wn=b.useCallback(C=>{V(C),eA(C),Sp()},[]);b.useEffect(()=>{As.some(C=>C.id===Co)||ga(As[0]?.id??"default")},[Co,As]),b.useEffect(()=>{if(!Tr.available&&fn==="tmux"){Na("shell",{userInitiated:!1});return}Tr.available&&Yi!=="shell"&&fn!=="tmux"&&Na("tmux",{userInitiated:!1})},[fn,Tr.available,Yi,Na]),b.useEffect(()=>{Di(null)},[Ke,fn,Tr.available]),b.useEffect(()=>{const C={};typeof navigator<"u"&&(C.userAgent=navigator.userAgent,C.platform=navigator.platform,C.maxTouchPoints=navigator.maxTouchPoints,C.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,C.vendor=navigator.vendor),typeof window<"u"&&(C.screenWidth=window.innerWidth,C.screenHeight=window.innerHeight,C.pixelRatio=window.devicePixelRatio,C.orientation=window.screen?.orientation?.type||"unknown",C.hasVisualViewport=!!window.visualViewport,C.visualViewportHeight=window.visualViewport?.height,C.visualViewportWidth=window.visualViewport?.width,C.location=window.location.href),C.timestamp=new Date().toISOString(),C.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,C.isAndroid=/Android/.test(navigator.userAgent),ut(C)},[]);const us=b.useCallback(C=>{if(Gi(C)||!C.destination)return;if(C.type==="group"){if(C.source.index===C.destination.index)return;es(Vy(gs,C.source.index,C.destination.index));return}if(C.source.droppableId!==C.destination.droppableId||C.source.index===C.destination.index)return;const P=C.source.droppableId.replace(/^group-sessions:/,""),de=gs.find(rt=>rt.key===P);de&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:de.sessions[C.source.index]?.id,targetId:de.sessions[C.destination.index]?.id}}))},[gs,es,Gi]),Ds=k.useMemo(()=>Ws.flatMap(C=>{const P=ir.get(C.id);if(P?.agentStatus!=="working")return[];const{primary:de,secondary:rt}=il(C,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null);return[{id:C.id,label:de,detail:rt}]}),[Ws,ir]),pc=Ct?Ws.findIndex(C=>C.id===Ct):-1,Vs=Ws.length>0&&pc>=0?`${pc+1}/${Ws.length}`:`${Ws.length}`,Ki=k.useMemo(()=>{let C=0;for(const P of yt){const de=ir.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&(C+=1)}return{running:Ds.length,review:C}},[Ds.length,yt,ir]),_o=k.useMemo(()=>Ws.flatMap(C=>{const P=ir.get(C.id);if(P?.agentStatus!=="waiting"&&!P?.agentNeedsReview)return[];const{primary:de}=il(C,P.activeProgram,P.cwd,_a,P.shellTitle,P.promptState);return[{id:P.terminalSessionId??C.id,label:de,waiting:P.agentStatus==="waiting"}]}),[Ws,ir]);tA(Ki.running,Ki.review,_o);const yi=Ct?yt.find(C=>C.id===Ct)??null:null,ko=yi?ir.get(yi.id):void 0,tu=!!(yi&&ko?.agentResumeRecovered&&ko.agentNativeSessionId&&ko.terminalSessionId),vi=yi&&pn?.sessionId===yi.id?pn:null;k.useLayoutEffect(()=>{if(!K)return;const C=Dt.current;if(!C)return;const P=!ft.current;C.scrollIntoView({inline:"nearest",block:"nearest",behavior:P?"auto":"smooth"}),ft.current=!0,P&&Mu("active-tab-positioned")},[Ct,K]),b.useEffect(()=>{tr&&Tt.current&&(Tt.current.scrollIntoView({block:"nearest",inline:"nearest"}),Tt.current.focus(),Tt.current.select()),tr||(kt.current=!1)},[tr]);const F0=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:C}))},[]),wi=b.useCallback((C,P)=>{Xn(P??null),Cn(C)},[]),sd=Cg(),Ja=b.useCallback(C=>{if(!C)return;U(C),ve.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:ve.current,requestedSessionId:C,activeSessionId:Ct,sessions:yt.map(de=>({id:de.id,terminalSessionId:ir.get(de.id)?.terminalSessionId??null}))}),rA(C);const P=yt.find(de=>de.id===C||ir.get(de.id)?.terminalSessionId===C);P?(Qe.current=null,ve.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:ve.current,requestedSessionId:C,targetSessionId:P.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):(Qe.current=C,ve.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:ve.current,requestedSessionId:C}))},[Ct,yt,ir]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let C=!1;const P=async()=>{if(window.parent!==window&&Po()){fe(!0);return}try{const rt=await caches.open(j$),At=await rt.match(py);if(!At)return;await rt.delete(py);const Zt=await At.json();if(C)return;const Nr=typeof Zt.sessionId=="string"?Zt.sessionId:null,An=typeof Zt.traceId=="string"?Zt.traceId:null,Nn=typeof Zt.clickedAt=="number"?Zt.clickedAt:0,Ln=Date.now()-Nn;ka("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:An,sessionId:Nr,ageMs:Ln,valid:!!(Nr&&Ln>=0&&Ln<=my),visibilityState:document.visibilityState}),Nr&&Ln>=0&&Ln<=my&&(ve.current=An,typeof Zt.targetPeerId=="string"&&Zt.targetPeerId!==Sc()?.targetPeerId?Po()?.focusSession(Zt.targetPeerId,Nr):Ja(Nr))}catch(rt){ka("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:rt instanceof Error?rt.message:String(rt)})}finally{C||fe(!0)}},de=()=>{document.visibilityState==="visible"&&P()};return P(),document.addEventListener("visibilitychange",de),window.addEventListener("pageshow",P),()=>{C=!0,document.removeEventListener("visibilitychange",de),window.removeEventListener("pageshow",P)}},[Ja]),b.useEffect(()=>{if(typeof window>"u")return;const C=new URLSearchParams(window.location.search),P=C.get("session");if(!P)return;ka("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:ve.current,targetSessionId:P,href:window.location.href,visibilityState:document.visibilityState});const de=C.get("service");de&&de!==Sc()?.targetPeerId?Po()?.focusSession(de,P):Qe.current=P,C.delete("service"),C.delete("session"),C.delete("_notifTrace");const rt=C.toString(),At=`${window.location.pathname}${rt?`?${rt}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",At)},[]),b.useEffect(()=>{if(typeof window>"u")return;const C=new URLSearchParams(window.location.search);if(C.get("_notif")!=="1")return;const P=C.get("session");C.delete("_notif");const de=C.toString(),rt=`${window.location.pathname}${de?`?${de}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",rt),window.parent!==window&&Po())return;const At=new BroadcastChannel("termdock:notif");let Zt=!1;const Nr=Nn=>{Nn.data?.type==="termdock:notif-pong"&&!Zt&&(Zt=!0,At.close(),window.close())};At.addEventListener("message",Nr),At.postMessage({type:"termdock:notif-ping",sessionId:P,targetPeerId:C.get("service")});const An=setTimeout(()=>{Zt||At.close()},500);return()=>{clearTimeout(An),Zt||At.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&Po())return;const C=new BroadcastChannel("termdock:notif"),P=de=>{de.data?.type==="termdock:notif-ping"&&(C.postMessage({type:"termdock:notif-pong"}),typeof de.data.sessionId=="string"&&(typeof de.data.targetPeerId=="string"&&de.data.targetPeerId!==Sc()?.targetPeerId?Po()?.focusSession(de.data.targetPeerId,de.data.sessionId):Ja(de.data.sessionId)))};return C.addEventListener("message",P),()=>C.close()},[Ja]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const C=P=>{const de=P.data;if(de&&de.type==="termdock:focus-session"&&typeof de.sessionId=="string"){if(typeof de.targetPeerId=="string"&&de.targetPeerId!==Sc()?.targetPeerId){Po()?.focusSession(de.targetPeerId,de.sessionId)&&P.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}P.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),Ja(de.sessionId)}else de?.type==="termdock:push-subscription-changed"?pd(!0):de?.type};return navigator.serviceWorker.addEventListener("message",C),()=>navigator.serviceWorker.removeEventListener("message",C)},[Ja]),b.useEffect(()=>{const C=P=>{const de=P.detail;typeof de=="string"&&Ja(de)};return window.addEventListener("termdock:focus-session",C),()=>window.removeEventListener("termdock:focus-session",C)},[Ja]),b.useEffect(()=>{const C=()=>{const P=lA(Sc()?.targetPeerId);P&&Ja(P)};return C(),window.addEventListener("termdock:workspace-session",C),()=>window.removeEventListener("termdock:workspace-session",C)},[Ja]),b.useEffect(()=>{const C=Qe.current;if(!C)return;const P=yt.find(de=>de.id===C||ir.get(de.id)?.terminalSessionId===C);P?(Qe.current=null,ve.current&&ka("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:ve.current,requestedSessionId:C,targetSessionId:P.id,activeSessionId:Ct}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):ve.current&&ka("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:ve.current,requestedSessionId:C,activeSessionId:Ct,sessions:yt.map(de=>({id:de.id,terminalSessionId:ir.get(de.id)?.terminalSessionId??null}))})},[Ct,yt,ir]);const ba=k.useMemo(()=>{const C=[];for(const P of yt){const de=ir.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&C.push(P.id)}return C},[yt,ir]),Pl=b.useCallback(()=>{if(ba.length===0)return;Ct&&Yr.getState().clearAgentNeedsReview(Ct);const C=Ct?yt.findIndex(de=>de.id===Ct):-1,P=ba.find(de=>yt.findIndex(rt=>rt.id===de)>C)??ba[0];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[ba,yt,Ct]),ru=b.useCallback(()=>{if(ba.length===0)return;Ct&&Yr.getState().clearAgentNeedsReview(Ct);const C=Ct?yt.findIndex(de=>de.id===Ct):yt.length,P=[...ba].reverse().find(de=>yt.findIndex(rt=>rt.id===de)<C)??ba[ba.length-1];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[ba,yt,Ct]);b.useEffect(()=>{const C=P=>{!P.altKey||!P.shiftKey||P.metaKey||P.ctrlKey||P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventDefault(),P.key==="ArrowUp"?ru():Pl())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Pl,ru]);const ap=b.useCallback(async C=>{const de=Yr.getState().sessions.get(C)?.cwd;if(de)try{await navigator.clipboard?.writeText(de),Gn(de),window.setTimeout(()=>{Gn(rt=>rt===de?null:rt)},1400)}catch{}},[]),op=b.useCallback(C=>{xt(C.sessions),fr(C.activeSessionId),pt(C.splitWorkspaces),Yr.getState().setActiveSessionId(C.activeSessionId)},[]),lp=b.useCallback(()=>{Sr(!0)},[]),cp=b.useCallback(()=>{Sr(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!N||!Ct)return;yt.find(P=>P.id===N||ir.get(P.id)?.terminalSessionId===N)?.id===Ct&&U(null)},[Ct,N,yt,ir]);const id=b.useRef(!1),[nu,$0]=b.useState(!1),ja=b.useCallback(C=>{const P=!C?.onResult;if(P&&id.current)return;P&&(id.current=!0,$0(!0));const de=C?.mode??fn,rt=de==="tmux"&&(C?.tmuxSessionName?.trim()||ma.trim())||void 0,At=C?.cwd||(Ct?Yr.getState().sessions.get(Ct)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:de,tmuxSessionName:rt,cwd:At,command:C?.command,shouldActivate:C?.shouldActivate,onResult:C?.onResult??(Zt=>{id.current=!1,$0(!1),Zt.ok||Gr({tone:"error",message:e(zm(Zt.error))})})}}))},[fn,ma,Ct,e]),Vo=b.useCallback(async()=>{Qr(!0);try{const C=await Qm();if(Jr(C),!C.available){jn([]);return}const P=await Pm();jn(P)}catch{Jr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),jn([])}finally{Qr(!1)}},[]),mc=b.useCallback(async C=>{const{cleanedSessions:P}=await Ty(C);for(const de of P)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:de}));await Vo()},[Vo]),su=b.useCallback(async C=>{xn(C),He(null);try{await mc(C),Dr(null)}catch(P){He(P instanceof Error?P.message:"Failed to kill tmux session")}finally{xn(null)}},[mc]);b.useEffect(()=>{if(!Nt)return;if(Mr.find(de=>de.name===Nt&&(de.connected||de.boundFrontendSessionId))){Et(null);return}const P=setTimeout(()=>Et(null),1e4);return()=>clearTimeout(P)},[Nt,Mr]);const gc=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:C}))},[]),iu=b.useCallback(C=>{const P=C??Ct;P&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:P}))},[Ct]),ad=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:C,layout:P}}))},[]),U0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:C,sessionIds:P}}))},[]),z0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:C,name:P}}))},[]),H0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:C,secondaryId:P}}))},[]),Ol=b.useCallback((C,P,de)=>{const rt=yt.find(Zt=>Zt.id===C);if(!rt)return;const At=ir.get(C);if(de?.skipConfirmation||!P5({mode:rt.mode,activeProgram:At?.activeProgram??null,promptState:At?.promptState??null,shellNames:_a})){gc({sessionId:C,source:"sidebar",closeMode:rt.mode==="tmux"?"destroy":"auto"});return}it(P?{x:P.clientX,y:P.clientY}:null),$e(C),He(null)},[yt,ir,gc]);b.useEffect(()=>{if(!Pe)return;const C=P=>{const de=P.detail;de==="new-session"?ja():de==="close-session"?Ct&&Ol(Ct):de==="previous-session"||de==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:de==="next-session"?"next":"prev"}})):de==="toggle-left-sidebar"?as():de==="toggle-right-sidebar"?xi():de==="previous-attention"?ru():de==="next-attention"&&Pl()};return window.addEventListener("termdock:native-command",C),()=>window.removeEventListener("termdock:native-command",C)},[Ct,Pe,ja,Ol,as,xi,Pl,ru]);const eo=k.useMemo(()=>yt.find(C=>C.id===Me)??null,[yt,Me]),od=b.useCallback(()=>{eo&&(gc({sessionId:eo.id,source:"sidebar",closeMode:"destroy"}),$e(null),it(null))},[eo,gc]);b.useEffect(()=>{if(!eo)return;const C=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopImmediatePropagation(),$e(null),it(null),He(null);return}P.key!=="Enter"||P.isComposing||P.keyCode===229||P.altKey||P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.stopImmediatePropagation(),P.repeat||od())};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[eo,od]);const W0=k.useMemo(()=>{if(!eo)return"";const C=ir.get(eo.id);return il(eo,C?.activeProgram??null,C?.cwd??null,_a,C?.shellTitle??null,C?.promptState??null).primary},[eo,ir]);b.useEffect(()=>{if(!Ke)return;let C=!1,P=!1;const de=async()=>{if(!P)try{const At=await Qm();if(C||Jr(At),!At.available){C||jn([]);return}const Zt=await Pm();C||jn(Zt)}catch{P=!0,C||(Jr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),jn([]))}};de();const rt=setInterval(()=>{de()},4e3);return()=>{C=!0,clearInterval(rt)}},[Ke]);const xc=ji??fn,Fl=xc==="shell",au=xc==="tmux"&&Tr.available,xl=k.useMemo(()=>Gy(Mr.map(C=>({...C,id:C.name})),C=>C.cwd??null,e("sidebar.ungrouped")),[Mr,e]),ld=k.useMemo(()=>Mr.filter(C=>C.recoveryCandidate===!0&&!C.connected&&!C.boundFrontendSessionId).sort((C,P)=>(P.lastActiveAt??P.createdAt??0)-(C.lastActiveAt??C.createdAt??0)),[Mr]);b.useEffect(()=>{!Cr&&!(mn&&Xt)||Vo()},[Cr,mn,Xt,yt.length,Vo]);const bc=(C,P,de,rt=!1)=>{const At=C.id===Ct,Zt=C.id===tr,Nr=ir.get(C.id),{primary:An,secondary:Nn}=il(C,Nr?.activeProgram??null,Nr?.cwd??null,_a,Nr?.shellTitle??null,Nr?.promptState??null),Ln=Ku(Nr?.cwd??null),Ai=P?Nn??(Ln&&Ln!==An?Ln:null):null,Tn=Nr?.gitStatus,Xi=`${Nr?.cwd||C.name}${Tn?`
186
+ ⎇ ${Tn.branch} +${Tn.added} −${Tn.removed}`:""}`,Io=!!(Nr?.tuiProgress&&Nr.tuiProgress.state!=="remove"),Eo=Nr?.agentStatus==="working"||Io?"var(--success)":Nr?.agentStatus==="waiting"||Nr?.agentNeedsReview?"var(--warning)":Nr?.inCopyMode?"var(--tmux)":null;if(Zt&&Xt&&!dn){const Ba=C.customName?C.name:An,Qi=(to,up)=>{const dd=up.trim();dd?dd!==Ba&&Vi(to,dd):qi(to),jr(null)};return s.jsx("input",{ref:to=>{Tt.current=to},type:"text",defaultValue:Ba,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(Ba.length,5)}ch`},onKeyDown:to=>{to.key==="Enter"?Qi(C.id,to.target.value):to.key==="Escape"&&jr(null)},onBlur:to=>Qi(C.id,to.target.value)})}return s.jsx("div",{ref:At?Dt:null,onContextMenu:Ba=>{Ba.preventDefault(),Xn({x:Ba.clientX,y:Ba.clientY}),Cn(C.id)},...sd(()=>wi(C.id)),className:rt?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${At?"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 ${At?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!rt&&At&&Eo?{boxShadow:`inset 2px 0 0 0 ${Eo}`}:!rt&&At?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:Xi,children:s.jsx("button",{type:"button",...de??{},onClick:()=>F0(C.id),className:`inline-flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left ${rt?"px-1":"py-1 pl-1 pr-1.5 sm:pl-1.5 sm:pr-2"} ${de?"cursor-grab active:cursor-grabbing":""}`,title:Xi,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:[xy(C.mode,Nr),Nr?.agentResumeRecovered&&s.jsx(Qc,{size:rt?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),Io&&!Nr?.agentStatus&&s.jsx(_n,{size:rt?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),Ai?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] ${Nr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:An}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:Ai})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Nr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:An})]})})})},cd=()=>s.jsx(Ll,{droppableId:M1,type:"session",isDropDisabled:Xt,children:(C,P)=>{const de=Jn||P.isDraggingOver;return s.jsxs("div",{ref:C.innerRef,...C.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":!Vn,"data-mobile-session-destroy-target":"","data-active":de?"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 ${Vn?de?"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(Rs,{size:28,strokeWidth:1.8}),s.jsx("span",{className:"px-2 text-center text-[11px] font-semibold leading-tight",children:e(de?"tab.releaseToClose":"tab.dragToClose")})]}),C.placeholder]})}}),ya=mn&&Xt,$l=zr&&Xt,ud=Oh(un,Jt,ya?on:0),yc=$l?ud+Ay:0,Ul=ya?yt.find(C=>C.id===Ct):null,Bs=Ul?ir.get(Ul.id):void 0,G0=Ul?il(Ul,Bs?.activeProgram??null,Bs?.cwd??null,_a,Bs?.shellTitle??null,Bs?.promptState??null).primary:"",Da=Xt?lt:null,Lo=ya&&!Da&&Bs?Bs.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Bs.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Bs.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Bs.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",zl=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[yn&&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:yn}),s.jsx("button",{type:"button",className:"min-h-11 px-2 text-primary",onClick:()=>hn(""),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(sC,{rightInset:yc,workspace:Rt&&s.jsx(k.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($$,{groupId:Rt,activeSessionId:Ct,defaultSessionMode:fn,onOpenSidebar:as,leftSidebarVisible:Cr||ya,onToggleRightSidebar:xi,rightSidebarOpen:qr||$l},Rt)}),children:[s.jsxs("div",{className:`${Xt?"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 ${ya?"flex justify-end":"flex justify-between"} ${Mt?"h-10 sm:h-10":"h-9 sm:h-10"} ${Lo}`,style:{position:Xt?"absolute":void 0,marginRight:yc||void 0,display:Da?"none":void 0},children:[!ya&&s.jsxs("button",{type:"button",onClick:as,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")}: ${Ki.running} · ${e("agent.needsReview")}: ${Ki.review}`,children:[s.jsx(WT,{size:14}),s.jsx(zP,{runningCount:Ki.running,reviewCount:Ki.review,className:"sm:hidden"})]}),ya?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:Ul?s.jsxs(s.Fragment,{children:[xy(Ul.mode,Bs),s.jsx("span",{className:`truncate text-[12px] font-medium ${Bs?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:G0}),Bs?.agentStatus==="working"&&s.jsx("span",{title:Bs?.agentMessage??void 0,children:s.jsx(_n,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Bs?.agentStatus==="waiting"&&s.jsx("span",{title:Bs?.agentMessage??void 0,children:s.jsx(of,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Bs?.agentStatus&&Bs?.agentNeedsReview&&s.jsx("span",{title:Bs?.agentMessage??void 0,children:s.jsx(cc,{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")})}):Mt?s.jsxs(h0,{onDragStart:Wi,onDragUpdate:Mi,onDragEnd:us,children:[cd(),s.jsx(Ll,{droppableId:"groups",type:"group",direction:"horizontal",children:C=>s.jsxs("div",{ref:C.innerRef,...C.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:[gs.map((P,de)=>{let rt=0,At=0;for(const Nn of P.sessions){const Ln=ir.get(Nn.id);Ln?.agentStatus==="working"&&(rt+=1),(Ln?.agentStatus==="waiting"||Ln?.agentNeedsReview)&&(At+=1)}const Zt=P.sessions.some(Nn=>Nn.id===Ct),Nr=Ar.has(P.key),An=P.key==="";return s.jsx(kl,{draggableId:`group-${P.key||"__ungrouped__"}`,index:de,isDragDisabled:An,disableInteractiveElementBlocking:!0,children:(Nn,Ln)=>s.jsxs("div",{ref:Nn.innerRef,...Nn.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${Ln.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":Zt?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...An?{}:Nn.dragHandleProps,onClick:()=>Fr(P.key),className:`flex ${Nr?"":P.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 ${An?"":"cursor-grab active:cursor-grabbing"} ${Zt?"text-primary/80":"text-muted-foreground/55"}`,title:P.key||P.label,children:[s.jsx(Ks,{size:9,className:`shrink-0 opacity-70 transition-transform ${Nr?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 truncate",children:P.label}),rt>0&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)]"}),At>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${rt>0?"":"ml-auto"}`})]}),Nr?s.jsx("span",{className:"flex h-5 items-center text-[10px] leading-none text-muted-foreground/50",children:e("tab.sessionCount",{count:P.sessions.length})}):s.jsx(Ll,{droppableId:`group-sessions:${P.key}`,type:"session",direction:"horizontal",children:Ai=>s.jsxs("div",{ref:Ai.innerRef,...Ai.droppableProps,className:"flex items-center gap-px",children:[P.sessions.map((Tn,Xi)=>s.jsx(kl,{draggableId:Tn.id,index:Xi,disableInteractiveElementBlocking:!0,children:(Io,Eo)=>s.jsx("div",{ref:Io.innerRef,...Io.draggableProps,className:`flex shrink-0 items-center ${Eo.isDragging?"opacity-70":""}`,children:bc(Tn,!1,Io.dragHandleProps,!0)})},Tn.id)),Ai.placeholder]})})]})},P.key||"__ungrouped__")}),C.placeholder,s.jsx("button",{type:"button",onClick:()=>ja(),disabled:nu,"aria-busy":nu,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(zs,{size:14})})]})})]}):s.jsxs(h0,{onDragStart:Wi,onDragUpdate:Mi,onDragEnd:Bl,children:[cd(),s.jsx(Ll,{droppableId:"tabs",type:"session",direction:"horizontal",children:C=>s.jsxs("div",{ref:C.innerRef,...C.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:[Ws.map((P,de)=>P.id===tr?s.jsx(k.Fragment,{children:s.jsx(kl,{draggableId:P.id,index:de,isDragDisabled:!0,children:At=>s.jsx("div",{ref:At.innerRef,...At.draggableProps,className:"flex h-full items-center",children:bc(P,!0)})})},P.id):s.jsx(k.Fragment,{children:s.jsx(kl,{draggableId:P.id,index:de,disableInteractiveElementBlocking:!0,children:(At,Zt)=>s.jsx("div",{ref:At.innerRef,...At.draggableProps,className:`flex h-full shrink-0 items-center ${Zt.isDragging?"opacity-70":""}`,children:bc(P,!0,At.dragHandleProps)})})},P.id)),s.jsx("button",{type:"button",onClick:()=>ja(),disabled:nu,"aria-busy":nu,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(zs,{size:14})}),C.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!ya&&Ki.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(P6,{count:Ki.running,tone:"running",title:e("agent.aiRunning")})}),!ya&&yt.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 ${pc+1} of ${yt.length}`,children:Vs}),!$l&&s.jsx("button",{type:"button",onClick:xi,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($y,{size:14})})]})]}),tu&&yi&&ko?.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:yc||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:!vi?.error&&(vi?.status==="submitting"||vi?.status==="waiting")?s.jsx(_n,{size:14,className:"animate-spin"}):s.jsx(Qc,{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:ko.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${vi?.error?"text-destructive":"text-muted-foreground"}`,children:vi?.error??(vi?.status==="submitting"?e("tab.resumeAgentSubmitting"):vi?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!vi?.error&&(vi?.status==="submitting"||vi?.status==="waiting"),onClick:()=>{Xr(yi.id,ko.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:vi?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Yr.getState().setAgentResumeRecovered(yi.id,!1),dr(C=>C?.sessionId===yi.id?null:C)},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(In,{size:13})})]}),s.jsx("div",{ref:tn,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(LN,{terminalSettings:qt,colorTheme:p,toolbarPresets:As,showDebug:l&&Xt,terminalFocusAvailable:Se,defaultSessionMode:fn,defaultTmuxSessionName:ma,connectionPrioritySessionId:N,connectionPriorityReady:K,desktopRightSidebarEnabled:Xt,onToggleRightSidebar:xi,desktopFloatingTitle:Xt,desktopPinnedLeftSidebarWidth:ya?on:0,desktopViewportWidth:Jt,onSessionDataUpdate:op,onInitialViewportReady:cp,onInitialRecoveryRequired:lp})})})]})}),!Rt&&s.jsx(qP,{reviewCount:Ki.review,runningSessions:Ds,activeSessionId:Ct,runningButtonEnabled:Lr,attentionButtonEnabled:Un,isDesktopLayout:Xt,containerElement:ss,occlusionInsets:{right:yc}}),Ke&&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:Ri,"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(Um,{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:Ri,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(In,{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:()=>tt({fontSize:Math.max(8,De-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:De,onChange:C=>tt({fontSize:parseInt(C.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>tt({fontSize:Math.min(32,De+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:[De,"px"]})]}),s.jsx(T$,{}),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.render")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["auto","webgl","canvas"].map(C=>{const P=nr===C;return s.jsx("button",{type:"button",onClick:()=>tt({rendererMode:C}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:e(C==="auto"?"settings.auto":C==="webgl"?"settings.webgl":"settings.canvas")},C)})})]})}),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",QT,e("settings.darkTheme")],["light",LS,e("settings.lightTheme")]].map(([C,P,de])=>{const rt=p===C;return s.jsxs("button",{type:"button",onClick:()=>m(C),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition ${rt?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:[s.jsx(P,{size:12}),s.jsx("span",{children:de})]},C)})})]})}),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(C=>{const P=fn===C,de=C==="tmux"&&!Tr.available;return s.jsx("button",{type:"button",disabled:de,onClick:()=>Na(C,{userInitiated:!0}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":de?"cursor-not-allowed text-muted-foreground/40":"text-muted-foreground hover:bg-surface-elevated"}`,title:de?Tr.reason||e("settings.installTmuxHint"):void 0,children:e(C==="shell"?"settings.shell":"settings.tmux")},C)})})]}),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(ll,{checked:l,size:"sm"})]}),s.jsxs("button",{type:"button",onClick:async()=>{const C=!y;w(C);try{const P=await La({preventSleep:C});w(P.preventSleep),S(P.networkAvailable),pe(P.localAccess),Fn(qd,{preventSleep:P.preventSleep,networkAvailable:P.networkAvailable,localAccess:P.localAccess})}catch{w(!C)}},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(ll,{checked:y,size:"sm"})]})]})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":Lr,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{ns(!Lr)},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(lf,{size:14,className:Lr?"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(ll,{checked:Lr,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":Un,"aria-label":e("sidebar.attentionButton"),onClick:()=>{kn(!Un)},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(cc,{size:14,className:Un?"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(ll,{checked:Un,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>ni(!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(Dy,{size:14,className:L?"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(L?R&&z?"settings.notificationsBothOnSummary":R?"settings.notificationsAiOnSummary":z?"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(L?"common.on":"common.off")}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>Bi(!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(g$,{state:Le,pending:ne,onCheck:()=>{bt()},onConfirmRestart:()=>{st()},desktopState:Ne?nt:void 0,desktopPending:ue,onCheckDesktop:Ne?()=>{Br()}:void 0,onInstallDesktop:()=>{Vr()},desktopSnapshot:oe,desktopActions:Pe?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:()=>{Pe.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(QA,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{Ie(null),Pe.revealDataDirectory().catch(C=>Ie(C instanceof Error?C.message:String(C)))},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(Du,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),at&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:at})]}):void 0}),s.jsx(b$,{backendSessionId:Ct?ir.get(Ct)?.terminalSessionId??null:null}),s.jsx(v$,{state:ke,onDismiss:()=>{je()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Di(null),ja({mode:"shell"}),Ri()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Fl?"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(ji==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(zs,{size:14,className:Fl?"shrink-0":"hidden"}),s.jsx($o,{size:12}),s.jsx("span",{className:Fl?"whitespace-nowrap":"hidden",children:e(ji==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Tr.available,onClick:()=>{Tr.available&&(Di(null),ja({mode:"tmux"}),Ri())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Tr.available?au?"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:Tr.available?e(ji==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Tr.reason||e("settings.installTmuxHint"),children:[s.jsx(zs,{size:14,className:au?"shrink-0":"hidden"}),s.jsx(qc,{size:12}),s.jsx("span",{className:au?"whitespace-nowrap":"hidden",children:e(ji==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Tr.available||Mr.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 ${Tr.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:Tr.available?e("settings.sessions",{n:Mr.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),Vo()},disabled:ln,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(bn,{size:12,className:ln?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Tr.available?Mr.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:[xl.map(C=>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(Vc,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"shrink-0 font-medium text-foreground/75",children:C.label}),s.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:e("settings.sessions",{n:C.sessions.length})}),C.key&&s.jsx("span",{className:"min-w-0 truncate text-muted-foreground/60",children:C.key})]}),C.sessions.map(P=>{const de=P.boundFrontendSessionId??null,rt=!!(P.connected||de),At=de?yt.find(Qi=>Qi.id===de)??null:null,Zt=P.friendlyName?.trim()||null,Nr=P.label&&P.label!==P.name?P.label:null,An=Zt||Nr||P.name,Nn=Zt||Nr?`tmux:${P.name}`:null,Ln=P.clientCount&&P.clientCount>0?t==="zh"?`网页连接 ${P.clientCount}`:`Web clients ${P.clientCount}`:null,Ai=P.attached>0?t==="zh"?`原生 tmux ${P.attached}`:`Native tmux ${P.attached}`:null,Tn=[Nn,rt?P.restorable?e("settings.restorable"):e("settings.attached"):null,Ln,Ai].filter(Qi=>!!Qi),Xi=[e("settings.windows",{n:P.windows}),P.createdAt?new Date(P.createdAt).toLocaleDateString():null].filter(Qi=>!!Qi),Io=ks===P.name,Eo=en===P.name,Ba=Nt===P.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${Io?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(qc,{size:13,className:rt?"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:An}),P.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"})]}),Tn.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:Tn.map(Qi=>s.jsx("span",{className:"max-w-full truncate",children:Qi},Qi))}),(P.program||P.cwd)&&s.jsxs("div",{className:"grid min-w-0 gap-0.5 text-[10px] text-muted-foreground",children:[P.program&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(yT,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate text-foreground/75",children:P.program})]}),P.cwd&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(Vc,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:P.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:Xi.map(Qi=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(JA,{size:10,className:"shrink-0 text-muted-foreground/60"}),Qi]},Qi))})]}),Io?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{su(P.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:Eo?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{Dr(null),He(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:()=>{At?F0(At.id):(Et(P.name),ja({mode:"tmux",tmuxSessionName:P.name}))},disabled:Ba,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${rt?"bg-surface text-foreground hover:bg-surface-elevated":Ba?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:Ba?s.jsxs(s.Fragment,{children:[s.jsx(_n,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(rt?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{He(null),Dr(P.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 ${P.name}`,children:s.jsx(Rs,{size:12})})]})]},P.name)})]},C.key||"__ungrouped_tmux__")),X&&s.jsx("p",{className:"px-2 text-[11px] text-destructive",children:X})]}):s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:Tr.reason||e("settings.installTmuxHint")})})]}),s.jsxs("button",{type:"button",onClick:()=>ws(!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(Py,{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:As.length})}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>cs(!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(R0,{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(C=>{const P=t===C.code;return s.jsx("button",{type:"button",onClick:()=>r(C.code),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:C.label},C.code)})})]}),s.jsxs("button",{type:"button",onClick:async()=>{try{await nA()}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(Hy,{size:14}),e("settings.signOut")]})]})]})})]}),eo&&s.jsxs(s.Fragment,{children:[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:()=>{$e(null),it(null),He(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 ${Je&&Xt?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:Je&&Xt?{...hy(Je),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:W0}),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",onClick:od,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(Rs,{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")})]})]}),X&&s.jsx("p",{className:"px-4 py-2 text-[11px] text-destructive",children:X})]}),s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:()=>{$e(null),it(null),He(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")})})]})]}),cr&&(()=>{const C=yt.find(Ln=>Ln.id===cr);if(!C)return null;const P=ir.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,_a),rt=Xt,At=rt?hy(Ls):{paddingBottom:a},Zt=rt?"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%]",Nr=rt?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",An=rt?"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",Nn=rt?"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 ${rt?"bg-transparent":"bg-[var(--app-backdrop-soft)] backdrop-blur-sm"}`,onClick:Bt,"aria-label":"Close menu"}),s.jsxs("div",{className:Zt,style:At,children:[s.jsxs("div",{className:Nr,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:de}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/80",children:P.cwd})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{const Ln=Ls;Bt(),_r(Ln),jr(C.id)},className:`${An} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Nn} bg-primary/15 text-primary`,children:s.jsx(eS,{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:!P?.cwd,onClick:()=>{ap(C.id),Bt()},className:`${An} ${P?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${Nn} bg-surface-2 text-muted-foreground`,children:s.jsx(Oy,{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")})]}),Or&&Or===P?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const Ln=Om(C.id),Ai=Ln??De;return s.jsxs("div",{className:`${An} text-foreground`,children:[s.jsx("span",{className:`${Nn} bg-surface-2 text-muted-foreground`,children:s.jsx(NS,{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:()=>{Ph(C.id,Ai-1),cn(Tn=>Tn+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:[Ai,"px"]}),s.jsx("button",{type:"button",onClick:()=>{Ph(C.id,Ai+1),cn(Tn=>Tn+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:"+"}),Ln!==null&&s.jsx("button",{type:"button",onClick:()=>{Ph(C.id,null),cn(Tn=>Tn+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")})]})]})})(),P?.agentNativeSessionId&&P.agentStatus!=="working"&&P.agentStatus!=="waiting"&&P.terminalSessionId&&s.jsxs("button",{type:"button",onClick:()=>{const Ln=P.terminalSessionId;Ln&&(Bt(),Xr(C.id,Ln))},className:`${An} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Nn} bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)]`,children:s.jsx(Qc,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block font-medium",children:[e("tab.resumeAgent"),P.agent?.displayName?` · ${P.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"}),C.mode==="tmux"?s.jsxs("button",{type:"button",onClick:()=>{Bt(),Ol(C.id)},className:`${An} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Nn} bg-destructive/15 text-destructive`,children:s.jsx(Rs,{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:()=>{Bt(),gc({sessionId:C.id,source:"tab-menu",closeMode:"auto"})},className:`${An} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Nn} bg-destructive/15 text-destructive`,children:s.jsx(In,{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")})]})]}),!rt&&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:()=>{Bt()},children:e("tab.longPressTip")})]}),!rt&&s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:Bt,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")})})]})]})})(),tr&&dn&&Xt&&(()=>{const C=yt.find(Tn=>Tn.id===tr);if(!C)return null;const P=ir.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null),rt=C.customName?C.name:de,At=Tn=>{const Xi=Tn.trim();Xi?Xi!==rt&&Vi(C.id,Xi):qi(C.id),jr(null),_r(null)},Zt=300,Nr=160,An=dn.x,Nn=dn.y,Ln=Math.min(Math.max(An-Zt/2,12),window.innerWidth-Zt-12),Ai=Nn+Nr+20>window.innerHeight?Math.max(Nn-Nr-12,12):Nn+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:()=>{jr(null),_r(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:`${Ln}px`,top:`${Ai}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:de}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",children:P.cwd})]}),s.jsxs("form",{className:"px-3 py-2.5",onSubmit:Tn=>{Tn.preventDefault();const Xi=new FormData(Tn.currentTarget).get("session-name");At(typeof Xi=="string"?Xi:"")},children:[s.jsx("input",{ref:Tn=>{Tt.current=Tn,Tn&&!kt.current&&(kt.current=!0,Tn.focus({preventScroll:!0}),Tn.select())},type:"text",name:"session-name",defaultValue:rt,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:Tn=>{Tn.key==="Escape"&&(Tn.stopPropagation(),jr(null),_r(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{jr(null),_r(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")})]})]})]})]})})(),tr&&!Xt&&(()=>{const C=yt.find(Zt=>Zt.id===tr);if(!C)return null;const P=ir.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null),rt=C.customName?C.name:de,At=Zt=>{const Nr=Zt.trim();Nr?Nr!==rt&&Vi(C.id,Nr):qi(C.id),jr(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:()=>jr(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:Zt=>{Zt.preventDefault();const Nr=new FormData(Zt.currentTarget).get("session-name");At(typeof Nr=="string"?Nr:"")},children:[s.jsx("input",{ref:Zt=>{Tt.current=Zt,Zt&&!kt.current&&(kt.current=!0,Zt.focus({preventScroll:!0}),Zt.select())},type:"text",name:"session-name",defaultValue:rt,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:Zt=>{Zt.key==="Escape"&&(Zt.stopPropagation(),jr(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>jr(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")})]})]})]})]})})(),Gs&&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:()=>Bi(!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:()=>Bi(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(In,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(iC,{state:be,onCopy:C=>{ml(C,"setup")},copied:we==="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:ee,onChange:C=>_e(C.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:()=>{Es()},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:()=>{Ea()},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:[be.url&&s.jsxs("button",{type:"button",onClick:()=>{ml(be.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: ",be.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:we==="lan"?"Copied":e("common.copy")})]}),be.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:be.interfaces.map(C=>{const P=C.url??`${be.httpsEnabled?"https":"http"}://${C.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:[C.label," (",C.name,")"]}),s.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:C.address}),C.qrDataUrl&&s.jsx("div",{className:"mt-2 inline-block rounded-lg bg-[var(--background)] p-1.5",children:s.jsx("img",{src:C.qrDataUrl,alt:`QR code for ${P}`,className:"h-28 w-28"})}),s.jsxs("button",{type:"button",onClick:()=>{ml(P,`ip-${C.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:P}),s.jsx("span",{className:"shrink-0 text-[10px]",children:we===`ip-${C.address}`?"Copied":e("common.copy")})]})]},`${C.name}-${C.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[be.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!be.caAvailable&&` · ${e("settings.caMissing")}`]}),be.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:be.reason}),ce&&s.jsx("div",{className:"text-destructive",children:ce})]})]})]})]}),Ra&&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:()=>ni(!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:()=>ni(!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(In,{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"):rh()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),rh()&&!sA()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{$r()},disabled:!rh()||Z==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":L,children:s.jsx(ll,{checked:L,disabled:!rh()||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"),": ",vo()?e("settings.notificationsPermissionSystem"):Z]}),s.jsx("button",{type:"button",disabled:!L||Z!=="granted"||ys==="checking",onClick:()=>{nn()},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(ys==="checking"?"settings.notificationsTestChecking":"settings.notificationsTest")}),vo()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{vo()?.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")})]}),ys!=="idle"&&ys!=="checking"&&s.jsx("div",{className:`mt-2 text-[11px] leading-relaxed ${ys==="delivered"?"text-primary":"text-[var(--warning)]"}`,children:e(ys==="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(([C,P,de])=>{const rt=$===C;return s.jsxs("button",{type:"button",disabled:!L,onClick:()=>wn(C),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${rt&&L?"bg-primary/15 text-primary":L?"text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"cursor-not-allowed text-muted-foreground/40"}`,title:de,children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold",children:P}),s.jsx("span",{className:"mt-0.5 block truncate text-[9px] opacity-80",children:de})]},C)})})]}),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:!L,onClick:()=>Pn(!R),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":R&&L,children:s.jsx(ll,{checked:R&&L,disabled:!L})})]}),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:!L,onClick:()=>yr(!z),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":z&&L,children:s.jsx(ll,{checked:z&&L,disabled:!L})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),ri&&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:()=>ws(!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:()=>ws(!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(In,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(f$,{presets:As,selectedPresetId:Co,onSelectPreset:ga,onUpdatePreset:(C,P)=>{Xa(de=>Ru(de.map(rt=>rt.id===C?P(rt):rt)))},onAddPreset:()=>{const C=`preset-${Date.now()}`;Xa(P=>Ru([...P,{id:C,label:`Preset ${P.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),ga(C)},onRemovePreset:C=>{Xa(P=>Ru(P.filter(de=>de.id!==C)))},onResetDefaults:()=>{Xa(w0()),ga("default")}})})]})]}),xa&&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:()=>cs(!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:()=>cs(!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(In,{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(m$,{}),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:yt.map(C=>{const P=ir.get(C.id),de=P?.activeProgramRaw??null,rt=P?.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:C.name}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-foreground",children:[s.jsx("span",{className:"text-muted-foreground",children:"display:"})," ",rt||"—"]}),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:"})," ",de||"—"]})]},`raw-${C.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:C,label:P,hint:de})=>s.jsxs("div",{children:[s.jsx("div",{className:"mb-0.5 text-[11px] font-medium text-foreground",children:P}),s.jsx("div",{className:"text-[10px] text-muted-foreground",children:de}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[Xe[C].map(rt=>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:[rt,s.jsx("button",{type:"button",onClick:()=>{const At={...Xe,[C]:Xe[C].filter(Zt=>Zt!==rt)};dt(At),C==="shellNames"&&(_a=new Set(At.shellNames)),hx(At).catch(()=>{})},className:"ml-0.5 text-muted-foreground hover:text-destructive",children:"×"})]},rt)),s.jsx("input",{placeholder:e("settings.addTag"),className:"w-16 rounded bg-surface px-1.5 py-0.5 text-[11px] font-mono",onKeyDown:rt=>{if(rt.key!=="Enter")return;const At=rt.target.value.trim().toLowerCase();if(!At||Xe[C].includes(At))return;const Zt={...Xe,[C]:[...Xe[C],At]};dt(Zt),C==="shellNames"&&(_a=new Set(Zt.shellNames)),rt.target.value="",hx(Zt).catch(()=>{})}})]})]},C)),s.jsx("button",{type:"button",onClick:()=>{iA().then(C=>{dt(C),_a=new Set(C.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")}),se.map((C,P)=>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:C.enabled!==!1,onChange:de=>{const rt=se.map((At,Zt)=>Zt===P?{...At,enabled:de.target.checked}:At);T(rt),Fn(Ca,rt),ge(!0),uu(rt).then(At=>{T(At),Fn(Ca,At)}).catch(()=>{}).finally(()=>ge(!1))}}),s.jsxs("select",{value:C.matchType,onChange:de=>{const rt=se.map((At,Zt)=>Zt===P?{...At,matchType:de.target.value}:At);T(rt),Fn(Ca,rt),ge(!0),uu(rt).then(At=>{T(At),Fn(Ca,At)}).catch(()=>{}).finally(()=>ge(!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:C.pattern,onChange:de=>{const rt=se.map((At,Zt)=>Zt===P?{...At,pattern:de.target.value}:At);T(rt),Fn(Ca,rt)},onBlur:()=>{ge(!0),uu(se).then(de=>{T(de),Fn(Ca,de)}).catch(()=>{}).finally(()=>ge(!1))},placeholder:"pattern",className:"min-w-[180px] flex-1 rounded bg-surface px-2 py-1 text-[11px] font-mono"}),s.jsx("input",{value:C.output,onChange:de=>{const rt=se.map((At,Zt)=>Zt===P?{...At,output:de.target.value}:At);T(rt),Fn(Ca,rt)},onBlur:()=>{ge(!0),uu(se).then(de=>{T(de),Fn(Ca,de)}).catch(()=>{}).finally(()=>ge(!1))},placeholder:"output",className:"w-28 rounded bg-surface px-2 py-1 text-[11px]"}),s.jsx("button",{type:"button",onClick:()=>{const de=se.filter((rt,At)=>At!==P);T(de),Fn(Ca,de),ge(!0),uu(de).then(rt=>{T(rt),Fn(Ca,rt)}).catch(()=>{}).finally(()=>ge(!1))},className:"rounded bg-surface px-2 py-1 text-[11px] text-muted-foreground hover:text-destructive",children:e("common.delete")})]})},C.id)),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{const C=[...se,{id:`rule-${Date.now()}`,enabled:!0,priority:100,matchType:"includes",pattern:"",output:""}];T(C),Fn(Ca,C),ge(!0),uu(C).then(P=>{T(P),Fn(Ca,P)}).catch(()=>{}).finally(()=>ge(!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:()=>{ge(!0),aA().then(C=>{T(C),Fn(Ca,C)}).catch(()=>{}).finally(()=>ge(!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:F?e("settings.saving"):j?`${se.length} rules`:"…"})]})]})]})]})]})]}),Go&&s.jsx(o$,{isOpen:Go,onClose:()=>Zi(!1)}),!ya&&s.jsx(Qb,{isOpen:Cr,drawerWidthPx:hr,onClose:()=>Hn("left-sidebar"),onOpen:ha,sessions:yt,activeSessionId:Ct,sessionStates:ir,onNewSession:C=>ja(C),recoverableTmuxSessions:ld,recoverableTmuxSessionsLoading:ln,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Ol,onSplitSession:iu,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:ot,onSetSplitLayout:ad,onReorderSplitWorkspace:U0,onRenameSplitWorkspace:z0,onCombineSplitSessions:H0,onReorderSessions:es,onSessionMenu:wi,onOpenSettings:js,onJumpToNextAttention:ba.length>0?Pl:void 0,onOpenQuota:()=>Zi(!0),updateState:Le,updateActionPending:ne,onConfirmUpdateRestart:st,onRetryUpdate:bt,serverHealthState:ke,tmuxAvailable:Tr.available,defaultSessionMode:fn,onTogglePinned:Xt?Va:void 0}),!$l&&s.jsx(Pb,{isOpen:qr,sessionId:Ct,drawerWidthPx:zn,onClose:()=>Hn("right-sidebar"),onOpen:ms,rightSidebarFilePreviewOpen:Bn,rightSidebarFilePreviewCloseSignal:Ae,onOpenRightSidebarFilePreview:bi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:et,rightSidebarRepoPickerCloseSignal:Gt,onOpenRightSidebarRepoPicker:ti,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:wt,markdownOutlineCloseSignal:Vt,onOpenMarkdownOutline:pa,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:Ot,markdownImageLightboxCloseSignal:xe,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:ls,onTogglePinned:Xt?ei:void 0}),Ge&&!c&&s.jsx("button",{type:"button",onClick:Dl,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"})]})}),me&&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 ${me.tone==="success"?"border-[rgb(var(--success-rgb)_/_0.24)] bg-surface-elevated text-foreground":"border-destructive/30 bg-surface-elevated text-destructive"}`,role:me.tone==="error"?"alert":"status",children:[me.tone==="success"?s.jsx(Qc,{size:14,className:"shrink-0 text-[color:var(--success)]"}):s.jsx(of,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:me.message}),s.jsx("button",{type:"button",onClick:()=>Gr(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(In,{size:12})})]}),l&&s.jsxs(s.Fragment,{children:[!Xt&&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(q,null,2)})]})]})]}),Hl=Yt?null:s.jsx(cA,{className:"z-modal-panel",status:"正在恢复终端…"});return Xt?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[ya&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:on,flexShrink:0,height:"100%"},children:s.jsx(Qb,{isOpen:Cr,drawerWidthPx:on,onClose:Js,onOpen:ha,sessions:yt,activeSessionId:Ct,sessionStates:ir,onNewSession:C=>ja(C),recoverableTmuxSessions:ld,recoverableTmuxSessionsLoading:ln,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Ol,onSplitSession:iu,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:ot,onSetSplitLayout:ad,onReorderSplitWorkspace:U0,onRenameSplitWorkspace:z0,onCombineSplitSessions:H0,onReorderSessions:es,onSessionMenu:wi,onOpenSettings:js,onJumpToNextAttention:ba.length>0?Pl:void 0,onOpenQuota:()=>Zi(!0),updateState:Le,updateActionPending:ne,onConfirmUpdateRestart:st,onRetryUpdate:bt,serverHealthState:ke,tmuxAvailable:Tr.available,defaultSessionMode:fn,pinned:!0,onTogglePinned:Va})}),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:dl})]}),s.jsxs("div",{className:"relative flex-1 min-w-0 h-full overflow-hidden",children:[zl,$l&&s.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex",style:{width:yc},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:Hi}),s.jsx("div",{style:{width:ud,flexShrink:0,height:"100%"},children:s.jsx(Pb,{isOpen:!0,sessionId:Ct,drawerWidthPx:ud,onClose:Hs,onOpen:ms,pinned:!0,onTogglePinned:ei,rightSidebarFilePreviewOpen:Bn,rightSidebarFilePreviewCloseSignal:Ae,onOpenRightSidebarFilePreview:bi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:et,rightSidebarRepoPickerCloseSignal:Gt,onOpenRightSidebarRepoPicker:ti,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:wt,markdownOutlineCloseSignal:Vt,onOpenMarkdownOutline:pa,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:Ot,markdownImageLightboxCloseSignal:xe,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:ls})})]})]}),s.jsx(Jb,{sessionId:Ct}),Hl]}):s.jsxs(s.Fragment,{children:[zl,s.jsx(Jb,{sessionId:Ct}),Hl]})}const BU=Object.freeze(Object.defineProperty({__proto__:null,default:U$},Symbol.toStringTag,{value:"Module"}));export{X$ as $,r0 as A,b0 as B,oF as C,YS as D,lf as E,Qy as F,lF as G,Qc as H,Uy as I,fS as J,Py as K,Oy as L,IT as M,$T as N,i0 as O,WT as P,D6 as Q,bn as R,jl as S,Um as T,LS as U,_I as V,Rs as W,Hy as X,OS as Y,nh as Z,JS as _,ZS as a,Z$ as a0,Ky as a1,eU as a2,tU as a3,J$ as a4,nv as a5,jU as a6,F2 as a7,c1 as a8,Uf as a9,Yb as aa,Zy as ab,Fh as ac,$1 as ad,dC as ae,UO as af,K$ as ag,$2 as ah,KE as ai,Ob as aj,Mm as ak,Ei as al,DU as am,n3 as an,uf as b,XF as c,BU as d,XS as e,My as f,EA as g,LA as h,jy as i,By as j,m0 as k,DO as l,sT as m,g0 as n,uO as o,Du as p,F1 as q,AT as r,MT as s,Fy as t,QT as u,$y as v,XT as w,eS as x,rS as y,x0 as z};