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.
- package/dist/client/assets/App-9yy2aYiT.js +186 -0
- package/dist/client/assets/App-9yy2aYiT.js.br +0 -0
- package/dist/client/assets/App-9yy2aYiT.js.gz +0 -0
- package/dist/client/assets/{ArchitecturePanel-CdgUQsVD.js → ArchitecturePanel-CHMjbrPM.js} +2 -2
- package/dist/client/assets/ArchitecturePanel-CHMjbrPM.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-CHMjbrPM.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-DHp5r1k9.js → ChangeWalkthroughPanel-B0JYVVwB.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-B0JYVVwB.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-B0JYVVwB.js.gz +0 -0
- package/dist/client/assets/{CollaborationMainWorkspace-P_jXjsT-.js → CollaborationMainWorkspace-BJzMdyZc.js} +1 -1
- package/dist/client/assets/CollaborationMainWorkspace-BJzMdyZc.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BJzMdyZc.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-BwHxwcOP.js +2 -0
- package/dist/client/assets/{ComputerControlView-B5Yng8Dt.js → ComputerControlView-CdMNRZsH.js} +2 -2
- package/dist/client/assets/ComputerControlView-CdMNRZsH.js.br +0 -0
- package/dist/client/assets/ComputerControlView-CdMNRZsH.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-rZE40fcL.js → DagPlayground-C1xEyYVK.js} +1 -1
- package/dist/client/assets/DagPlayground-C1xEyYVK.js.br +0 -0
- package/dist/client/assets/DagPlayground-C1xEyYVK.js.gz +0 -0
- package/dist/client/assets/{DiffLab-3sIn0W3p.js → DiffLab-DcCKWB7G.js} +1 -1
- package/dist/client/assets/DiffLab-DcCKWB7G.js.br +0 -0
- package/dist/client/assets/DiffLab-DcCKWB7G.js.gz +0 -0
- package/dist/client/assets/{DiffReview-CBf8-Tli.js → DiffReview-C1TyvrA9.js} +1 -1
- package/dist/client/assets/DiffReview-C1TyvrA9.js.br +0 -0
- package/dist/client/assets/DiffReview-C1TyvrA9.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-BXhskTlx.js → DiffReviewLab-D784yT2y.js} +1 -1
- package/dist/client/assets/DiffReviewLab-D784yT2y.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-D784yT2y.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-DZfgjOBh.js → DiffViewer-ByAlz2NG.js} +1 -1
- package/dist/client/assets/DiffViewer-ByAlz2NG.js.br +0 -0
- package/dist/client/assets/DiffViewer-ByAlz2NG.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-Bzdi_sPh.js → ModelPreview-DxMcmJZy.js} +1 -1
- package/dist/client/assets/ModelPreview-DxMcmJZy.js.br +0 -0
- package/dist/client/assets/ModelPreview-DxMcmJZy.js.gz +0 -0
- package/dist/client/assets/{RightSidebar-DaRdlJzn.js → RightSidebar-CXykcIPb.js} +3 -3
- package/dist/client/assets/RightSidebar-CXykcIPb.js.br +0 -0
- package/dist/client/assets/RightSidebar-CXykcIPb.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-CarKrfAf.js → abnfDiagram-VCTEODGH-DZZIayJV.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-DZZIayJV.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DZZIayJV.js.gz +0 -0
- package/dist/client/assets/{app-BCTEfclM.js → app-CI3Oh-41.js} +3 -3
- package/dist/client/assets/app-CI3Oh-41.js.br +0 -0
- package/dist/client/assets/app-CI3Oh-41.js.gz +0 -0
- package/dist/client/assets/{arc-B6Qdq2Vw.js → arc-CjpEX_Ug.js} +1 -1
- package/dist/client/assets/arc-CjpEX_Ug.js.br +0 -0
- package/dist/client/assets/arc-CjpEX_Ug.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-DgPJ0l9i.js → architectureDiagram-5GKGNRK7-DUx2_xyE.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DUx2_xyE.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DUx2_xyE.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-BsorvNo4.js → blockDiagram-I7D4REHJ-DP-lXaM3.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-DP-lXaM3.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-DP-lXaM3.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-Bbpi62ab.js → c4Diagram-7LVT6UL2-DomY5VR-.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-DomY5VR-.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DomY5VR-.js.gz +0 -0
- package/dist/client/assets/channel-DIO7oiN5.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-Cm7mDz66.js → chunk-2Q5K7J3B-BPtKxDa8.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-BMERXU_m.js → chunk-5VM5RSS4-CRCqW368.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-fe9Yw7OI.js → chunk-F27PBJKO-Bs1ITIOZ.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-Bs1ITIOZ.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-Bs1ITIOZ.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-QquKV9k-.js → chunk-IMKFNOWR-Cw7kOnvo.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-Cw7kOnvo.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Cw7kOnvo.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-CVe8_YO4.js → chunk-JWPE2WC7-DBNaGHE2.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-DT8PalJ4.js → chunk-POPQ4Y6H-B_OEr0FR.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-BUQulipE.js → chunk-SVP7TREG-Ct25uRBl.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-Ct25uRBl.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-Ct25uRBl.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-fubKwUCg.js → chunk-TICWLB2K-BVxQwSUB.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-BVxQwSUB.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-BVxQwSUB.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-CdwTi82y.js → chunk-XXDRQBXY-B6PLILau.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-DukHh254.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DukHh254.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DmEDc2ee.js → cose-bilkent-JH36ORCC-Df23Xlgg.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-Df23Xlgg.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-Df23Xlgg.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-C-mfarRX.js → cynefin-OW5HDTMX-Dxy4auKS.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-Dxy4auKS.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-Dxy4auKS.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CgVmp8od.js → cynefinDiagram-5FMLGOSQ-CRypsJyP.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CRypsJyP.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CRypsJyP.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-WU_d2fSU.js → dagre-GXQ25YYZ-B2XmJ6IF.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-B2XmJ6IF.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-B2XmJ6IF.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-Dtikk80Z.js → diagram-S7CK7UJ4-BQcwNDWz.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BQcwNDWz.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BQcwNDWz.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-DuTCB36P.js → diagram-UQ7AKVKN-B6LD6n6P.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-B6LD6n6P.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-B6LD6n6P.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-DSLAcWi6.js → diagram-VSXAHHWV-DDI4SMid.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-DDI4SMid.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DDI4SMid.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-DyQOu10m.js → diagram-VX7I27RA-CRq35BVZ.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-CRq35BVZ.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CRq35BVZ.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-CuMI1k1t.js → diagram-Z3DM3KII-Br2tE-aw.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-Br2tE-aw.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-Br2tE-aw.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-Di8RxhNL.js → ebnfDiagram-PWID7BFC-CLERVjPA.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CLERVjPA.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CLERVjPA.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-C1wPuBtH.js → erDiagram-RLTQ6QDP-CdjRSsSD.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-CdjRSsSD.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-CdjRSsSD.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-D0SIEpUy.js → flowDiagram-HODETNUW-CJcQ479Z.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-CJcQ479Z.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CJcQ479Z.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DgeD2fKd.js → ganttDiagram-EL5Y4UJY-CdDCSJ3h.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CdDCSJ3h.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CdDCSJ3h.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-Xl7awIrX.js → gestureArbiter-D6uN_O0i.js} +1 -1
- package/dist/client/assets/gestureArbiter-D6uN_O0i.js.br +0 -0
- package/dist/client/assets/gestureArbiter-D6uN_O0i.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CzFKSKK_.js → gitGraphDiagram-WWUBYQGX-tcLWvosg.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tcLWvosg.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tcLWvosg.js.gz +0 -0
- package/dist/client/assets/index-_7yzQpVq.css +1 -0
- package/dist/client/assets/index-_7yzQpVq.css.br +0 -0
- package/dist/client/assets/{index-BObjbh2R.css.gz → index-_7yzQpVq.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-C9mmJGhv.js → infoDiagram-27XIBGKW-D7ze39D4.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-D9uVb4Og.js → ishikawaDiagram-5VMMS53U-BmvDG55X.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BmvDG55X.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BmvDG55X.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-BMKNUyUx.js → journeyDiagram-3NMN7TZE-Ba2oQRdr.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Ba2oQRdr.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Ba2oQRdr.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-8i7nyqix.js → kanban-definition-UXKFOSKX-BGrEtfSU.js} +1 -1
- package/dist/client/assets/{kanban-definition-UXKFOSKX-8i7nyqix.js.br → kanban-definition-UXKFOSKX-BGrEtfSU.js.br} +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BGrEtfSU.js.gz +0 -0
- package/dist/client/assets/{layout-BS5SCHbc.js → layout-Df_WxQ7_.js} +1 -1
- package/dist/client/assets/layout-Df_WxQ7_.js.br +0 -0
- package/dist/client/assets/layout-Df_WxQ7_.js.gz +0 -0
- package/dist/client/assets/{linear-fo2zkK6T.js → linear-yjCZ1UPt.js} +1 -1
- package/dist/client/assets/{linear-fo2zkK6T.js.br → linear-yjCZ1UPt.js.br} +0 -0
- package/dist/client/assets/linear-yjCZ1UPt.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-B8k3pAmc.js → mermaid.core-wqB76PXA.js} +5 -5
- package/dist/client/assets/mermaid.core-wqB76PXA.js.br +0 -0
- package/dist/client/assets/mermaid.core-wqB76PXA.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-BwgQTj2Q.js → mindmap-definition-YA3MSWOX-BvFfuDI9.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFfuDI9.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFfuDI9.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-DvQk0qYt.js → passwordBootstrap-CeMHRTET.js} +1 -1
- package/dist/client/assets/passwordBootstrap-CeMHRTET.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-CeMHRTET.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-CumSoxLr.js → pegDiagram-XKGWAZYB-GFNFRFcn.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-GFNFRFcn.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-GFNFRFcn.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-Dc3txkBL.js → pieDiagram-E7YTZNPT-i_OnIQ5S.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-i_OnIQ5S.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-i_OnIQ5S.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-D92mwZnT.js → quadrantDiagram-AXDQQJYC-DgclfhW2.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DgclfhW2.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DgclfhW2.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-O1UOZ30Y.js → railroadDiagram-O6MQD6OU-Bta7NOF1.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Bta7NOF1.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Bta7NOF1.js.gz +0 -0
- package/dist/client/assets/{rdpSession-Dr_tPwzx.js → rdpSession-CVTDBhDb.js} +1 -1
- package/dist/client/assets/rdpSession-CVTDBhDb.js.br +0 -0
- package/dist/client/assets/rdpSession-CVTDBhDb.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-YuGU-PYw.js → referenceLongPress-C91ZK5h8.js} +1 -1
- package/dist/client/assets/referenceLongPress-C91ZK5h8.js.br +0 -0
- package/dist/client/assets/referenceLongPress-C91ZK5h8.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-uD1cgrxA.js → requirementDiagram-BXWQKSXE-CjVvykFZ.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CjVvykFZ.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CjVvykFZ.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CIJE4-pc.js → sankeyDiagram-P5KCCOFB-DkRiE5xj.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DkRiE5xj.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DkRiE5xj.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-BT6LG37W.js → sequenceDiagram-WJ2MYXX4-BW-TiTTz.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BW-TiTTz.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BW-TiTTz.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-DoYY94Rj.js → sizeCapture-INFHLROL-CknYHWYz.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-CknYHWYz.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-CknYHWYz.js.gz +0 -0
- package/dist/client/assets/{sparkles-DFYGpezN.js → sparkles-BhmNaa1u.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-C4xmgR_-.js → stateDiagram-D77RDMKH-do6p3u1y.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-do6p3u1y.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-do6p3u1y.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CBBKJJkB.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-mRdmZmAA.js → swimlanes-42K2YHIH-BloliwwH.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-BloliwwH.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-BloliwwH.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N--bexkZyM.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-BFFrD5kR.js → timeline-definition-24CTP7MA-DelADR0N.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-DelADR0N.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-DelADR0N.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-BwJ6Q_Y0.js → triangle-alert-B5d_l343.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-Dy59OxIM.js → vennDiagram-4TSXK5OY-BJhlRAwF.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-Dy59OxIM.js.br → vennDiagram-4TSXK5OY-BJhlRAwF.js.br} +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BJhlRAwF.js.gz +0 -0
- package/dist/client/assets/{videoCompression-DrQ47oZA.js → videoCompression-CuDMhYU3.js} +1 -1
- package/dist/client/assets/videoCompression-CuDMhYU3.js.br +0 -0
- package/dist/client/assets/videoCompression-CuDMhYU3.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-B-BKlX7o.js → wardleyDiagram-VM6X3IG4-3MDCa0Rt.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-3MDCa0Rt.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-3MDCa0Rt.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-79qktI_4.js → xychartDiagram-S5SC5T6Z-LWuDetCo.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-LWuDetCo.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-LWuDetCo.js.gz +0 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/agent/collaborationStore.js +83 -7
- package/dist/server/agent/collaborationTeam.js +11 -4
- package/dist/server/agent/integrationCli.js +49 -4
- package/dist/server/agent/integrationServer.js +14 -2
- package/dist/server/routes/terminal.js +12 -6
- package/docs/integrations.md +80 -4
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/dist/client/assets/App-BF_s1-_u.js +0 -186
- package/dist/client/assets/App-BF_s1-_u.js.br +0 -0
- package/dist/client/assets/App-BF_s1-_u.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-CdgUQsVD.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-CdgUQsVD.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DHp5r1k9.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DHp5r1k9.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-P_jXjsT-.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-P_jXjsT-.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-DSkxOlKQ.js +0 -2
- package/dist/client/assets/ComputerControlView-B5Yng8Dt.js.br +0 -0
- package/dist/client/assets/ComputerControlView-B5Yng8Dt.js.gz +0 -0
- package/dist/client/assets/DagPlayground-rZE40fcL.js.br +0 -0
- package/dist/client/assets/DagPlayground-rZE40fcL.js.gz +0 -0
- package/dist/client/assets/DiffLab-3sIn0W3p.js.br +0 -0
- package/dist/client/assets/DiffLab-3sIn0W3p.js.gz +0 -0
- package/dist/client/assets/DiffReview-CBf8-Tli.js.br +0 -0
- package/dist/client/assets/DiffReview-CBf8-Tli.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-BXhskTlx.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BXhskTlx.js.gz +0 -0
- package/dist/client/assets/DiffViewer-DZfgjOBh.js.br +0 -0
- package/dist/client/assets/DiffViewer-DZfgjOBh.js.gz +0 -0
- package/dist/client/assets/ModelPreview-Bzdi_sPh.js.br +0 -0
- package/dist/client/assets/ModelPreview-Bzdi_sPh.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DaRdlJzn.js.br +0 -0
- package/dist/client/assets/RightSidebar-DaRdlJzn.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CarKrfAf.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CarKrfAf.js.gz +0 -0
- package/dist/client/assets/app-BCTEfclM.js.br +0 -0
- package/dist/client/assets/app-BCTEfclM.js.gz +0 -0
- package/dist/client/assets/arc-B6Qdq2Vw.js.br +0 -0
- package/dist/client/assets/arc-B6Qdq2Vw.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DgPJ0l9i.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DgPJ0l9i.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BsorvNo4.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BsorvNo4.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Bbpi62ab.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Bbpi62ab.js.gz +0 -0
- package/dist/client/assets/channel-uZtI4GD8.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-fe9Yw7OI.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-fe9Yw7OI.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-QquKV9k-.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-QquKV9k-.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-BUQulipE.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-BUQulipE.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-fubKwUCg.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-fubKwUCg.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-CgJJ1J4J.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CgJJ1J4J.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-DmEDc2ee.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-DmEDc2ee.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-C-mfarRX.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-C-mfarRX.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CgVmp8od.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CgVmp8od.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-WU_d2fSU.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-WU_d2fSU.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Dtikk80Z.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Dtikk80Z.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DuTCB36P.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DuTCB36P.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DSLAcWi6.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DSLAcWi6.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DyQOu10m.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DyQOu10m.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CuMI1k1t.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CuMI1k1t.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Di8RxhNL.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Di8RxhNL.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-C1wPuBtH.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-C1wPuBtH.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-D0SIEpUy.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-D0SIEpUy.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DgeD2fKd.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DgeD2fKd.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-Xl7awIrX.js.br +0 -0
- package/dist/client/assets/gestureArbiter-Xl7awIrX.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CzFKSKK_.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CzFKSKK_.js.gz +0 -0
- package/dist/client/assets/index-BObjbh2R.css +0 -1
- package/dist/client/assets/index-BObjbh2R.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D9uVb4Og.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D9uVb4Og.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BMKNUyUx.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BMKNUyUx.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-8i7nyqix.js.gz +0 -0
- package/dist/client/assets/layout-BS5SCHbc.js.br +0 -0
- package/dist/client/assets/layout-BS5SCHbc.js.gz +0 -0
- package/dist/client/assets/linear-fo2zkK6T.js.gz +0 -0
- package/dist/client/assets/mermaid.core-B8k3pAmc.js.br +0 -0
- package/dist/client/assets/mermaid.core-B8k3pAmc.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BwgQTj2Q.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BwgQTj2Q.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-DvQk0qYt.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DvQk0qYt.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CumSoxLr.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CumSoxLr.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-Dc3txkBL.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-Dc3txkBL.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-D92mwZnT.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-D92mwZnT.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-O1UOZ30Y.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-O1UOZ30Y.js.gz +0 -0
- package/dist/client/assets/rdpSession-Dr_tPwzx.js.br +0 -0
- package/dist/client/assets/rdpSession-Dr_tPwzx.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-YuGU-PYw.js.br +0 -0
- package/dist/client/assets/referenceLongPress-YuGU-PYw.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-uD1cgrxA.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-uD1cgrxA.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CIJE4-pc.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CIJE4-pc.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BT6LG37W.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BT6LG37W.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DoYY94Rj.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DoYY94Rj.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-C4xmgR_-.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-C4xmgR_-.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BLHH60cg.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-mRdmZmAA.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-mRdmZmAA.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-D-lNPW5d.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-BFFrD5kR.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BFFrD5kR.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-Dy59OxIM.js.gz +0 -0
- package/dist/client/assets/videoCompression-DrQ47oZA.js.br +0 -0
- package/dist/client/assets/videoCompression-DrQ47oZA.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-BKlX7o.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-BKlX7o.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-79qktI_4.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-79qktI_4.js.gz +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-DrQ47oZA.js","assets/app-BCTEfclM.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-BObjbh2R.css","assets/CollaborationTaskContent-DSkxOlKQ.js","assets/RightSidebar-DaRdlJzn.js","assets/gestureArbiter-Xl7awIrX.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-CBf8-Tli.js","assets/sparkles-DFYGpezN.js","assets/DiffViewer-DZfgjOBh.js","assets/referenceLongPress-YuGU-PYw.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-BwJ6Q_Y0.js","assets/ChangeWalkthroughPanel-DHp5r1k9.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-P_jXjsT-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{ag as Ut,aN as Yu,by as s,ac as hc,da as zr,H as q8,dk as sl,d6 as ka,d8 as es,b1 as fc,a7 as J0,az as py,bp as M1,cN as Y8,d7 as L0,cy as u0,b6 as xo,j as d0,af as Qu,co as vp,cV as Z8,as as Dc,bx as Tu,g as K8,cI as Qh,Z as X8,bb as Bm,bI as Qm,cE as J8,ax as ew,ch as tw,a5 as my,cf as rw,cC as gy,aa as nw,ah as sw,L as Cn,C as hi,X as Rn,f as iw,d as ul,bg as aw,b0 as Pm,dc as ow,dh as Yr,bG as j1,dg as Gt,aD as lw,dq as cw,v as uw,bN as dw,c0 as hw,a4 as _a,bR as fw,cA as Jg,cB as e2,cD as t2,W as r2,b$ as pw,cO as mw,t as Jd,bo as D1,d5 as gw,_ as Oc,b9 as xw,i as bw,dj as xy,a_ as il,T as Fo,db as I0,df as yw,ci as vw,an as ww,aY as Aw,bZ as Tw,b_ as Sw,P as by,V as n2,bO as s2,bA as yy,n as Us,$ as Ph,cW as wp,bH as Cw,ck as _w,bF as vy,de as kw,bf as Bo,dm as Lw,B as cc,e as fi,u as Iw,ak as Ew,N as Om,cv as Nw,h as $o,bt as Rw,bu as Mw,ap as wy,aB as Ay,a6 as ku,m as e0,cs as ac,c2 as Ty,aw as t0,c as Fm,d9 as Sy,aJ as jw,S as nf,bm as sf,a as Cy,ar as Dw,ae as Bw,d3 as Qw,c3 as Pu,a8 as uc,bE as i2,cz as Pw,c7 as Ow,cS as Fw,cU as _y,bB as $w,bD as B1,cG as Uw,cH as zw,c4 as Hw,cF as Ww,cp as Gw,cm as Vw,cj as qw,c6 as Yw,cw as Zw,bQ as Kw,bP as ky,cr as Xw,bC as a2,aH as Jw,a$ as e9,D as t9,aG as o2,bK as r9,q as n9,p as s9,bM as i9,F as a9,c5 as o9,l as l9,cx as c9,r as u9,c1 as d9,au as h9,aA as f9,aC as p9,ba as ud,bk as m9,d0 as g9,bl as x9,ao as b9,d2 as y9,Q as v9,aj as w9,ad as A9,A as T9,b8 as S9,aq as C9,M as _9,di as k9,bT as Tc,b5 as L9,b2 as I9,b3 as E9,b4 as N9,aW as Ap,bU as R9,cb as M9,cl as j9,b7 as D9,aZ as B9,cT as l2,am as Q9,a9 as P9,Y as O9,c_ as F9,dn as On,cu as Sc,bS as $9,w as U9,cQ as z9,aV as H9,bc as c2,ca as W9,cM as eh,cZ as dd,d1 as G9,cc as V9,cR as q9,cJ as Y9,cY as Tp,cK as Z9,cL as K9,dd as X9,al as J9,bJ as eA,bw as th,bv as tA,c8 as u2,cd as rA,c9 as lu,ce as nA,a3 as sA,ab as iA,s as aA}from"./app-BCTEfclM.js";import{b,R as k,r as Ii,a as oA}from"./dnd-BCFAPC0L.js";import{b as lA,c as cA,F as Gc,S as uA,e as dA,h as hA,r as fA,y as pA,d as mA,u as gA}from"./gestureArbiter-Xl7awIrX.js";import{L as xA,l as bA}from"./terminal-C7X98Amf.js";import{T as Q1,L as Ou,C as Fu,M as yA,G as vA}from"./triangle-alert-BwJ6Q_Y0.js";import{r as wA}from"./react-XDCjal2T.js";import{u as P1,G as AA}from"./referenceLongPress-YuGU-PYw.js";const TA=[["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"}]],Ly=Ut("archive",TA);const SA=[["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"}]],CA=Ut("arrow-down-a-z",SA);const _A=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],kA=Ut("arrow-down",_A);const LA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Iy=Ut("arrow-up",LA);const IA=[["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"}]],Ey=Ut("bell",IA);const EA=[["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"}]],E0=Ut("bot",EA);const NA=[["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"}]],RA=Ut("box",NA);const MA=[["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"}]],jA=Ut("cable",MA);const DA=[["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"}]],BA=Ut("calendar-clock",DA);const QA=[["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"}]],PA=Ut("camera",QA);const OA=[["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"}]],FA=Ut("chart-bar",OA);const $A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],UA=Ut("circle-dot",$A);const zA=[["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"}]],af=Ut("circle-question-mark",zA);const HA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],$u=Ut("circle",HA);const WA=[["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"}]],GA=Ut("clipboard-paste",WA);const VA=[["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"}]],Ny=Ut("clipboard",VA);const qA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],h0=Ut("clock-3",qA);const YA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ZA=Ut("clock",YA);const KA=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],XA=Ut("code",KA);const JA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Il=Ut("columns-2",JA);const eT=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],tT=Ut("corner-down-left",eT);const rT=[["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"}]],f0=Ut("download",rT);const nT=[["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",nT);const sT=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],iT=Ut("file-code",sT);const aT=[["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"}]],oT=Ut("file-up",aT);const lT=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Ry=Ut("file",lT);const cT=[["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"}]],Ru=Ut("folder-open",cT);const uT=[["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"}]],O1=Ut("folder-search",uT);const dT=[["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"}]],hT=Ut("folder-tree",dT);const fT=[["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"}]],d2=Ut("grid-2x2",fT);const pT=[["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"}]],Ff=Ut("grip-vertical",pT);const mT=[["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"}]],gT=Ut("hash",mT);const xT=[["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",xT);const bT=[["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"}]],yT=Ut("house",bT);const vT=[["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"}]],My=Ut("keyboard",vT);const wT=[["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"}]],jy=Ut("layers",wT);const AT=[["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"}]],TT=Ut("layout-dashboard",AT);const ST=[["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"}]],Uu=Ut("layout-grid",ST);const CT=[["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"}]],_T=Ut("maximize",CT);const kT=[["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"}]],N0=Ut("message-circle",kT);const LT=[["path",{d:"M5 12h14",key:"1ays0h"}]],Dy=Ut("minus",LT);const IT=[["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"}]],ET=Ut("minimize",IT);const NT=[["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"}]],RT=Ut("monitor-smartphone",NT);const MT=[["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"}]],jT=Ut("moon",MT);const DT=[["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"}]],BT=Ut("move",DT);const QT=[["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"}]],PT=Ut("network",QT);const OT=[["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"}]],FT=Ut("panel-right-close",OT);const $T=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],UT=Ut("panel-left",$T);const zT=[["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"}]],HT=Ut("panel-right-open",zT);const WT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],By=Ut("panel-right",WT);const GT=[["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"}]],VT=Ut("paperclip",GT);const qT=[["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"}]],YT=Ut("pause",qT);const ZT=[["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"}]],KT=Ut("pen-line",ZT);const XT=[["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"}]],JT=Ut("pencil-line",XT);const eS=[["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"}]],p0=Ut("pin",eS);const tS=[["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"}]],m0=Ut("pin-off",tS);const rS=[["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"}]],of=Ut("play",rS);const nS=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],sS=Ut("plug",nS);const iS=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],aS=Ut("power",iS);const oS=[["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"}]],gn=Ut("refresh-cw",oS);const lS=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Qy=Ut("rotate-ccw",lS);const cS=[["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"}]],uS=Ut("rotate-cw",cS);const dS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],h2=Ut("rows-2",dS);const hS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ml=Ut("search",hS);const fS=[["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"}]],r0=Ut("send",fS);const pS=[["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"}]],mS=Ut("settings",pS);const gS=[["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"}]],xS=Ut("shield-alert",gS);const bS=[["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"}]],yS=Ut("shield-check",bS);const vS=[["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"}]],$m=Ut("sliders-horizontal",vS);const wS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Py=Ut("square",wS);const AS=[["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"}]],TS=Ut("stethoscope",AS);const SS=[["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"}]],CS=Ut("sun",SS);const _S=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zs=Ut("trash-2",_S);const kS=[["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"}]],LS=Ut("type",kS);const IS=[["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"}]],ES=Ut("unlink",IS);const NS=[["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"}]],Oy=Ut("unplug",NS);const RS=[["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"}]],Fy=Ut("video",RS);const MS=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],jS=Ut("volume-1",MS);const DS=[["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"}]],BS=Ut("volume-2",DS);const QS=[["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"}]],PS=Ut("wand-sparkles",QS);const OS=[["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"}]],rh=Ut("workflow",OS);function FS(e,t){return e==="webgl"&&t}function $y(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?Yu(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 $S(e){return e&&e.trim().length>0?e:""}function Uy(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 zy(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 lf(e,t,r,n,a=[],c=[]){const l=new Map(e.map(S=>[S.id,S])),d=zy(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 W of x)W.sessionIds.every(F=>L.has(F))&&W.sessionIds.forEach(F=>E.set(F,W.sessionIds));const R=new Set,B=S.sessionIds.flatMap(W=>{if(R.has(W))return[];const F=E.get(W)??[W];return F.forEach(U=>R.add(U)),F});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=$y(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 US(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function zS(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function HS(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function WS(e,t){return!e&&t}const cf=".termdock/architecture.json",Hy=".termdock/architectures",GS={kind:"project",target:"",paths:[],depth:"boundary",focus:""},VS=["description","diagram","context","constraint","concern","todo","note"],qS=/^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/;class YS extends Error{}function ds(){throw new YS("Invalid architecture document")}function Cl(e){return(!e||typeof e!="object"||Array.isArray(e))&&ds(),e}function ii(e,t=8e3){return(typeof e!="string"||e.length>t)&&ds(),e}function Cc(e){const t=ii(e,80);return qS.test(t)||ds(),t}function tc(e,t){return(!Array.isArray(e)||e.length>t)&&ds(),e}function f2(e){return Object.fromEntries(VS.filter(t=>e[t]!==void 0).map(t=>[t,ii(e[t],1e5)]))}function cu(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]=ii(t[n],n==="previousDiagram"?1e5:200));return t.updateCount!==void 0&&((!Number.isSafeInteger(t.updateCount)||t.updateCount<0)&&ds(),r.updateCount=t.updateCount),r}function Oh(e){return!!e&&!/[:\\\x00-\x1f]/.test(e)&&!e.startsWith("/")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function F1(e){(!["project","module","feature"].includes(e.kind)||!["boundary","dependencies"].includes(e.depth))&&ds();const t=e.kind==="project"?[]:[...new Set(tc(e.paths,20).map(a=>ii(a,1024).trim()))].sort();t.some(a=>!Oh(a))&&ds();const r=ii(e.target,1e3).trim(),n=ii(e.focus,2e3).trim();return(e.kind==="module"&&!t.length||e.kind==="feature"&&!r)&&ds(),{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 ZS(e){const t=F1(e);if(t.kind==="project")return cf;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`${Hy}/${t.kind}-${a}-${(n>>>0).toString(16).padStart(8,"0")}.json`}function Wy(e){return e===".omm"||e===cf||new RegExp(`^${Hy.replace(".","\\.")}/(?:module|feature)-[\\p{L}\\p{N}_-]{1,48}-[a-f0-9]{8}\\.json$`,"u").test(e)}function G$(e){return e.split("/").pop()?.replace(/^(module|feature)-/,"").replace(/-[a-f0-9]{8}\.json$/,"").replace(/-/g," ")??e}function V$(e){new TextEncoder().encode(e).byteLength>5e6&&ds();let t;try{t=JSON.parse(e)}catch{ds()}const r=Cl(t);r.version!==1&&ds();const n=ii(r.generatedAt,80);Number.isFinite(Date.parse(n))||ds();const a=tc(r.perspectives,12).map(d=>{const p=Cl(d),m=tc(p.nodes,200).map(w=>{const v=Cl(w),S=tc(v.files,40).map(E=>{const R=Cl(E),B=ii(R.path,1024);return Oh(B)||ds(),R.line!==void 0&&(!Number.isSafeInteger(R.line)||R.line<1)&&ds(),{path:B,...R.line!==void 0?{line:R.line}:{}}}),L=v.references===void 0?void 0:tc(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&&!Oh(ii(v.documentPath,1024))&&ds(),v.role!==void 0&&!["external","concern","entry","store"].includes(v.role)&&ds(),{id:Cc(v.id),title:ii(v.title,160),summary:ii(v.summary),files:S,...f2(v),...v.parentId!==void 0?{parentId:Cc(v.parentId)}:{},...v.documentPath!==void 0?{documentPath:ii(v.documentPath,1024)}:{},...cu(v.meta)?{meta:cu(v.meta)}:{},...L?{references:L}:{},...v.role!==void 0?{role:v.role}:{}}});m.length||ds();const x=new Map(m.map(w=>[w.id,w]));x.size!==m.length&&ds();for(const w of m){const v=new Set([w.id]);let S=w.parentId;for(;S;)(v.has(S)||!x.has(S))&&ds(),v.add(S),S=x.get(S)?.parentId}const y=tc(p.edges,600).map(w=>{const v=Cl(w),S=Cc(v.from),L=Cc(v.to);return(!x.has(S)||!x.has(L))&&ds(),{from:S,to:L,label:ii(v.label,200)}});return{id:Cc(p.id),title:ii(p.title,160),summary:ii(p.summary),nodes:m,edges:y,...f2(p),...cu(p.meta)?{meta:cu(p.meta)}:{}}});(!a.length||new Set(a.map(d=>d.id)).size!==a.length)&&ds();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))&&ds()}const c=r.analysis===void 0?void 0:F1(Cl(r.analysis));let l;if(r.details!==void 0){const d=Cl(r.details),p=tc(d.analyzedPaths,200).map(x=>{const y=ii(x,1024);return Oh(y)||ds(),y}),m=tc(d.limitations,30).map(x=>ii(x,2e3));l={analyzedPaths:p,limitations:m}}return r.origin!==void 0&&!["termdock","omm"].includes(r.origin)&&ds(),{version:1,generatedAt:n,summary:ii(r.summary),perspectives:a,...c?{analysis:c}:{},...l?{details:l}:{},...r.origin?{origin:r.origin}:{},...cu(r.meta)?{meta:cu(r.meta)}:{}}}function Gy(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 Sp(e){return e.slice(0,100).replace(/[&<>"\[\]{}|`#;\\\r\n]/g," ").trim()||"…"}function q$(e,t,r=0){const n=Gy(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}["${Sp(S.title)}"]`),m(S.id,v+1),d.push("end")):d.push(`${L}["${Sp(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(W=>W.id===R);for(;B?.parentId;){if(B.parentId===E)return!0;B=e.nodes.find(W=>W.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)} -->|"${Sp(w.label)}"| ${l.get(w.to)}`).join(`
|
|
4
|
-
`)}}function Y$(e,t,r=GS,n){const a=F1(r),c=n??ZS(a);if(c===".omm")return KS(e,t);(!Wy(c)||a.kind!=="project"&&c===cf||a.kind==="project"&&c!==cf)&&ds();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 KS(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 Z$(e,t){const r=Gy(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 Vy(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"||!Wy(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 qy=e=>`termdock-secure-architecture-link:${e}`;function XS(e){e.peerId&&sessionStorage.setItem(qy(e.peerId),JSON.stringify({link:e,at:Date.now()}))}function JS(e){if(!e)return null;try{const t=qy(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=Vy(`?architecture=${encodeURIComponent(JSON.stringify(n.link))}`);return a?.peerId===e?a:null}catch{return null}}function K$(e,t){const r=new URL("/",e);return r.searchParams.set("architecture",JSON.stringify(t)),r.href}function eC(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 Um=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function tC({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 la=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 rC({state:e,onCopy:t,copied:r}){const{t:n}=zr(),[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&&q8.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 uf=hc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function p2(){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 nC({onClose:e}){const[t,r]=k.useState(p2);return k.useEffect(()=>{const n=window.setInterval(()=>r(p2()),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 sC={x:0,y:0,width:1,height:1};function $c(e){return"id"in e?[e.id]:[...$c(e.first),...$c(e.second)]}function zm(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=zm(n.first,t+1,r),c=zm(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 g0(e,t){if("id"in e)return t.has(e.id)?e:null;const r=g0(e.first,t),n=g0(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function df(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:df(e.first,t,r,n),second:df(e.second,t,r,n)}}function iC(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 df(g0(e,new Set($c(e).filter(a=>a!==t))),r,t,n)}function Mu(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:Mu(e.slice(0,r),"horizontal"),second:Mu(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:Mu(e.slice(1),t)}}function Hm(e,t=sC,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=Hm(e.first,n,r+"0"),l=Hm(e.second,a,r+"1");return{panes:[...c.panes,...l.panes],dividers:[{path:r,node:e,rect:t},...c.dividers,...l.dividers]}}function n0(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:n0(e.first,t.slice(1),r)}:{...e,second:n0(e.second,t.slice(1),r)}:{...e,ratio:r}}function Yy(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 Cp(e,t,r){const n=Yy(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 aC(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 oC;function $f(){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 oC??=crypto.randomUUID()}}let m2=Promise.resolve();function bo(e,t){t&&(e={groups:{[t]:e}});const r=$f(),n=m2.catch(()=>{}).then(()=>ka({collaborationPanel:{clientId:r,state:e}}));return m2=n,n.then(()=>{})}function g2(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 Zy(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function Ky(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 lC(e,t){const r=la.getState(),n=r.groupId;r.drafts[e]&&await bo({drafts:{[e]:r.drafts[e]}});const a={sessionId:t,side:window.innerWidth<640?"bottom":"right"};if(await bo({floatingGroupId:e,mode:"docked",dock:a},e),la.getState().groupId!==n)throw new Error("布局已保存;页面已切换,请重新打开成员消息");window.dispatchEvent(new CustomEvent("termdock:open-collaboration-messages",{detail:{groupId:e,dock:a}}))}const cC=e=>e.startsWith("@collaboration:"),x2=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function uC({groupId:e}){const t=es(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||es.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 b2({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:c=!1}){const l=es(re=>re.docks),d=JSON.stringify(t.map(re=>re.id)),p=Object.entries(l).filter(([,re])=>t.some(Oe=>Oe.id===re.sessionId)),m=JSON.stringify(p),x=b.useRef(null),[y,w]=b.useState(()=>n??Mu(t.map(re=>re.id),c?"vertical":r)),v=b.useRef(y);v.current=y;const[S,L]=b.useState(!1),E=es(re=>re.activePaneId),[R,B]=b.useState(null),[W,F]=b.useState(null),[U,V]=b.useState(null),Z=b.useRef(r),ce=b.useRef(t.map(re=>re.id)),xe=b.useRef({}),pe=b.useRef(!1),te=()=>{pe.current&&(pe.current=!1,bo({layouts:{[e]:v.current}}).catch(()=>{pe.current=!0,B("布局保存失败,调整后重试")}))};b.useEffect(()=>{let re=!1;return fc().then(Oe=>{if(re)return;const Ce=Oe.collaborationPanels?.[$f()];for(const Be of Ky(Ce)){const Ne=Zy(Ce,Be);Ne.mode==="docked"&&Ne.dock&&t.some(le=>le.id===Ne.dock.sessionId)&&!es.getState().docks[Be]&&es.getState().setDock(Be,Ne.dock)}let Ee=zm(Ce?.layouts?.[e]);if(Ee&&Ce?.floatingGroupId){const Be=Ne=>"id"in Ne?{id:Ne.id==="@collaboration"?J0(Ce.floatingGroupId):Ne.id}:{...Ne,first:Be(Ne.first),second:Be(Ne.second)};Ee=Be(Ee)}Ee&&w(Ee),L(!0)}).catch(()=>{re||B("布局加载失败,请刷新重试")}),()=>{re=!0}},[e]);const ke=re=>{pe.current=!0,v.current=re,w(re)};b.useLayoutEffect(()=>{if(!S)return;const re=JSON.parse(d),Oe=Z.current!==r;Z.current=r;let Ce=Oe?Mu(re,r):v.current;const Ee=ce.current;if(!Oe&&Ee.length===re.length&&Ee.every(le=>re.includes(le))&&Ee.some((le,He)=>le!==re[He])){const le=new Map(Ee.map((rt,mt)=>[rt,re[mt]])),He=rt=>"id"in rt?{id:le.get(rt.id)??rt.id}:{...rt,first:He(rt.first),second:He(rt.second)};Ce=He(Ce)}ce.current=re;const Be=new Set([...re,...p.map(([le])=>J0(le))]);Ce=g0(Ce,Be)??Mu(re,r);for(const le of re)$c(Ce).includes(le)||(Ce={axis:"x",ratio:.5,first:Ce,second:{id:le}});const Ne={};for(const[le,He]of p){const rt=J0(le),mt=`${He.sessionId}:${He.side}`;if(Ne[le]=mt,(!$c(Ce).includes(rt)||xe.current[le]&&xe.current[le]!==mt)&&(Ce=g0(Ce,new Set([...Be].filter(ue=>ue!==rt))),Ce=df(Ce,He.sessionId,rt,He.side)),He.preferredWidth&&(He.side==="left"||He.side==="right")){const ue=(Ye,st)=>{if("id"in Ye)return Ye;const Ie="id"in Ye.first&&Ye.first.id===rt,We="id"in Ye.second&&Ye.second.id===rt;if(Ye.axis==="x"&&(Ie||We)&&Ye.ratio===.5){const oe=(x.current?.clientWidth||window.innerWidth)*st.width,be=Math.max(.1,Math.min(.45,He.preferredWidth/Math.max(1,oe)));return{...Ye,ratio:Ie?be:1-be}}const Te={...st},H={...st};return Ye.axis==="x"?(Te.width*=Ye.ratio,H.x+=Te.width,H.width-=Te.width):(Te.height*=Ye.ratio,H.y+=Te.height,H.height-=Te.height),{...Ye,first:ue(Ye.first,Te),second:ue(Ye.second,H)}};Ce=ue(Ce,{x:0,y:0,width:1,height:1})}}xe.current=Ne,JSON.stringify(Ce)!==JSON.stringify(v.current)&&(ke(Ce),te())},[S,d,r,m]),b.useEffect(()=>{const re=()=>te();return window.addEventListener("pagehide",re),()=>{window.removeEventListener("pagehide",re),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),re()}},[e]);const $e=Hm(y),Y=Yy(y),Ae=[...t,...p.map(([re])=>({id:J0(re),content:s.jsx(uC,{groupId:re})}))],lt=b.useRef(null),Se=b.useRef(U);Se.current=U;const ye=b.useRef(null);b.useEffect(()=>{const re=x.current;if(!re||!S)return;const Oe=Ee=>{if(Ee.button!==0||!(Ee.target instanceof Element))return;const Be=Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]"),Ne=Ee.target.closest("button, a, input, textarea, select, summary");if(!Be||Ne&&Ne!==Be)return;const le=Be.closest("[data-layout-pane]");if(!le||!re.contains(le))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const He=le.getBoundingClientRect();lt.current={id:le.dataset.layoutPane,x:Ee.clientX,y:Ee.clientY,moved:!1,originX:Ee.clientX-He.left,originY:Ee.clientY-He.top,scale:Math.min(.8,480/Math.max(1,He.width),320/Math.max(1,He.height))},re.setPointerCapture?.(Ee.pointerId)},Ce=Ee=>{const Be=Ee.target;if(!(Be instanceof Element))return;const Ne=Be.closest("[data-layout-pane]");if(!(!Ne||!re.contains(Ne))){if(Ee.type==="pointerdown"&&es.getState().activePaneId!==Ne.dataset.layoutPane){const le=document.activeElement;le instanceof HTMLElement&&le.closest("[data-layout-pane]")&&!Ne.contains(le)&&le.blur();const He=window.getSelection();He?.anchorNode&&!Ne.contains(He.anchorNode)&&He.removeAllRanges()}es.getState().setActivePane(Ne.dataset.layoutPane)}};return re.addEventListener("pointerdown",Ce,!0),re.addEventListener("focusin",Ce,!0),re.addEventListener("pointerdown",Oe,!0),()=>{re.removeEventListener("pointerdown",Oe,!0),re.removeEventListener("pointerdown",Ce,!0),re.removeEventListener("focusin",Ce,!0)}},[S]);const _e=(re,Oe)=>{const Ce=x.current?.getBoundingClientRect(),Ee=ye.current;if(!Ce||!Ee)return;const Be=Ee.axis==="x"?Ce.width*Ee.rect.width:Ce.height*Ee.rect.height,Ne=Ee.axis==="x"?Ce.left+Ce.width*Ee.rect.x:Ce.top+Ce.height*Ee.rect.y,le=Math.min(.45,(c?48:120)/Math.max(1,Be)),He=Math.max(le,Math.min(1-le,((Ee.axis==="x"?re:Oe)-Ne)/Math.max(1,Be)));ke(Ee.side?Cp(v.current,Ee.side,He):n0(v.current,Ee.path,He))},je=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(re=>({...re,rect:{x:0,y:0,width:1,height:1},path:void 0})):$e.dividers.map(re=>({key:re.path,path:re.path,side:void 0,axis:re.node.axis,rect:re.rect,x:re.rect.x+(re.node.axis==="x"?re.rect.width*re.node.ratio:0),y:re.rect.y+(re.node.axis==="y"?re.rect.height*re.node.ratio:0),length:re.node.axis==="x"?re.rect.height:re.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:re=>{if(ye.current){re.preventDefault(),_e(re.clientX,re.clientY);return}const Oe=lt.current,Ce=x.current?.getBoundingClientRect();if(!Oe||!Ce||!Oe.moved&&Math.hypot(re.clientX-Oe.x,re.clientY-Oe.y)<6)return;Oe.moved=!0,F({id:Oe.id,dx:re.clientX-Oe.x,dy:re.clientY-Oe.y,originX:Oe.originX,originY:Oe.originY,scale:Oe.scale});const Ee=(re.clientX-Ce.left)/Ce.width,Be=(re.clientY-Ce.top)/Ce.height,Ne=$e.panes.find(ue=>Ee>=ue.rect.x&&Ee<=ue.rect.x+ue.rect.width&&Be>=ue.rect.y&&Be<=ue.rect.y+ue.rect.height);if(!Ne||Ne.id===Oe.id){Se.current=null,V(null);return}const le=(Ee-Ne.rect.x)/Ne.rect.width,He=(Be-Ne.rect.y)/Ne.rect.height,rt=Math.min(le,1-le,He,1-He)>.25?"center":le<1-le&&le<=He&&le<=1-He?"left":1-le<=He&&1-le<=1-He?"right":He<1-He?"top":"bottom",mt={id:Ne.id,side:rt};Se.current=mt,V(mt)},onPointerUp:re=>{ye.current&&(ye.current=null,te()),lt.current?.moved&&Se.current&&(ke(iC(v.current,lt.current.id,Se.current.id,Se.current.side)),te()),lt.current=null,Se.current=null,V(null),F(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),re.currentTarget.hasPointerCapture?.(re.pointerId)&&re.currentTarget.releasePointerCapture(re.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,lt.current=null,Se.current=null,V(null),F(null),te()},onKeyDownCapture:re=>{re.key==="Escape"&&(lt.current=null,Se.current=null,V(null),F(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,lt.current=null,Se.current=null,V(null),F(null),te()},children:[W&&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:x2($e.panes.find(re=>re.id===W.id)?.rect??{x:0,y:0,width:0,height:0})}),Ae.map(re=>{const Oe=$e.panes.find(Ee=>Ee.id===re.id)?.rect,Ce=!Oe||!!a&&re.id!==a;return s.jsxs("div",{"data-layout-pane":re.id,"data-pane-active":E===re.id,className:`${E===re.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${W?.id===re.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...x2(a===re.id?{x:0,y:0,width:1,height:1}:Oe??{x:0,y:0,width:0,height:0}),padding:Ae.length>1?"0.5px":0,transition:"none",visibility:Ce?"hidden":void 0,...W?.id===re.id?{transform:`translate(${W.dx}px, ${W.dy}px) scale(${W.scale})`,transformOrigin:`${W.originX}px ${W.originY}px`}:{}},onDragStart:Ee=>{Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Ee.preventDefault()},children:[re.content,c&&Ae.length>1&&!cC(re.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(Ff,{size:14})}),U?.id===re.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:U.side==="bottom"?"50%":0,bottom:U.side==="top"?"50%":0,left:U.side==="right"?"50%":0,right:U.side==="left"?"50%":0}})]},re.id)}),!a&&je.map(re=>s.jsx("button",{type:"button",role:"separator","aria-label":re.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[re.side]}半段分隔线`:"调整分屏大小","aria-orientation":re.axis==="x"?"vertical":"horizontal",disabled:!S,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${re.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${re.x*100}%`,top:`${re.y*100}%`,...re.axis==="x"?{height:`${re.length*100}%`}:{width:`${re.length*100}%`}},onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ye.current=re,x.current?.setPointerCapture?.(Oe.pointerId)},onDoubleClick:()=>{ke(re.side?Cp(v.current,re.side,.5):n0(v.current,re.path,.5)),te()},onKeyDown:Oe=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Oe.key))return;Oe.preventDefault();const Ce=re.side?Y[re.side]:$e.dividers.find(Be=>Be.path===re.path).node.ratio,Ee=Math.max(.05,Math.min(.95,Ce+(["ArrowRight","ArrowDown"].includes(Oe.key)?.03:-.03)));ke(re.side?Cp(v.current,re.side,Ee):n0(v.current,re.path,Ee)),te()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${re.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},re.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 Wm=0,y2=!1,Lu=0;function dC(){if(y2||typeof window>"u")return;y2=!0;const e=()=>{Wm=performance.now()};window.addEventListener("pointerdown",()=>{Lu+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{Lu=Math.max(0,Lu-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{Lu=0,e()})}function $1(e,t=500){dC();let r=!1,n,a;const c=()=>{if(r)return;if(Lu>0||performance.now()-Wm<400){a=setTimeout(c,100);return}const l=()=>{if(!r){if(Lu>0||performance.now()-Wm<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 hC(e){const[t,r]=b.useState(e);return b.useEffect(()=>$1(()=>r(e),0),[e]),t}function fC(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 Gm(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 pC(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 R0=new Map;function mC(e,t,r){if(!r||!t||!M1(e))return null;const n=`owned-paste-${crypto.randomUUID()}`;return R0.set(n,{source:e,layer:py(),sessionId:t,text:r,token:{nonce:n}}),{nonce:n,text:r,sessionId:t,paste:!0,submitAfterPaste:!1,focus:!1,ownedPaste:!0}}function gC(e){R0.delete(e)}function U1(e){return e.layer===py()&&M1(e.source)}function xC(e,t){const r=e.nonce?R0.get(e.nonce):void 0;return r&&U1(r)&&e.ownedPaste===!0&&e.paste===!0&&e.submitAfterPaste===!1&&r.sessionId===t&&e.sessionId===t&&e.text===r.text?r.token:null}function bC(e,t,r){const n=R0.get(e.nonce);return!n||n.token!==e||n.consumed?!1:(n.consumed=!0,U1(n)&&n.sessionId===t&&r===Gm(n.text,!1))}function yC(e,t){const r=R0.get(e.nonce);return!!r&&r.token===e&&r.sessionId===t&&U1(r)}function vC(e,t,r){b.useEffect(()=>{e&&Y8(e,!0)},[e,r])}const Ci=[];for(let e=0;e<256;++e)Ci.push((e+256).toString(16).slice(1));function wC(e,t=0){return(Ci[e[t+0]]+Ci[e[t+1]]+Ci[e[t+2]]+Ci[e[t+3]]+"-"+Ci[e[t+4]]+Ci[e[t+5]]+"-"+Ci[e[t+6]]+Ci[e[t+7]]+"-"+Ci[e[t+8]]+Ci[e[t+9]]+"-"+Ci[e[t+10]]+Ci[e[t+11]]+Ci[e[t+12]]+Ci[e[t+13]]+Ci[e[t+14]]+Ci[e[t+15]]).toLowerCase()}let _p;const AC=new Uint8Array(16);function TC(){if(!_p){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");_p=crypto.getRandomValues.bind(crypto)}return _p(AC)}const SC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),v2={randomUUID:SC};function CC(e,t,r){e=e||{};const n=e.random??e.rng?.()??TC();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,wC(n)}function Xy(e,t,r){return v2.randomUUID&&!e?v2.randomUUID():CC(e)}const Jy="\x1B[?2026h",_C="\x1B[?2026l",e3="\x1Bc";function kC(e){return e.replace(/(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|(?:\x1b[P_X^]|[\x90\x98\x9e\x9f])[\s\S]*?(?:\x1b\\|\x9c|$)|(?:\x1b\[|\x9b)\?([\d;]+)([hl])|(?:\x1b\[|\x9b)[\d;]*!p|\x1bc/g,(t,r,n)=>{if(t===e3||t.endsWith("!p"))return t+Jy;if(r===void 0)return t;const a=r.split(";").filter(c=>Number(c)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function LC(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=kC(t.replace(/^(?:\x1bc)+/,""));return[`${e3}${Jy}${r}${_C}`]}function IC(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function EC(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 NC={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},RC={F1:"P",F2:"Q",F3:"R",F4:"S"},MC={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 jC(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=NC[r];if(p)return l!==1?`\x1B[1${d}${p}`:`\x1B${t?"O":"["}${p}`;const m=RC[r];if(m)return l!==1?`\x1B[1${d}${m}`:`\x1BO${m}`;if(r==="Insert"&&!a&&(n||c))return null;const x=MC[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 s0 extends Error{}async function t3(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 L0("/tmp",[r]);if(!n[0]?.path)throw new Error("Upload did not return an image path");return n[0].path}async function hf(e){const t=xo();if(t?.readClipboardImage){const r=await t.readClipboardImage();return r?.byteLength?new File([r],"clipboard.png",{type:"image/png"}):null}if(typeof e?.read!="function")return null;for(const r of await e.read()){const n=r.types.find(l=>l.startsWith("image/"));if(!n)continue;const a=await r.getType(n),c=n==="image/jpeg"?"jpg":n.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png";return new File([a],`termdock-clipboard-${Date.now()}.${c}`,{type:n})}return null}async function r3(e){if(typeof e?.read!="function")return[];const t=[],r={"video/mp4":"mp4","video/quicktime":"mov","video/x-m4v":"m4v","video/webm":"webm","video/ogg":"ogv","video/mpeg":"mpeg","video/x-msvideo":"avi","video/x-matroska":"mkv","video/3gpp":"3gp","video/3gpp2":"3g2"};for(const n of await e.read()){const a=n.types.find(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 n3(){const e=u0()?.targetPeerId;let t;try{t=await xo()?.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 s0(c.slice(d+l.length).trim());const p=c.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw p?new s0(p[1]):a}if(u0()?.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 s0("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");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 s3(e){if(!e.length)return[];const{files:t}=await L0("/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 DC(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function BC(...e){return Zs(()=>DC(e))}var i3=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()}},Zc=class{constructor(){this._store=new i3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Zc.None=Object.freeze({dispose(){}});var hd=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}},a3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),M0=a3?"node":navigator.userAgent,QC=a3?"node":navigator.platform,PC=M0.includes("Firefox");M0.includes("Chrome");var OC=M0.includes("Edge"),o3=/^((?!chrome|android).)*safari/i.test(M0);function FC(){if(!o3)return 0;let e=M0.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}QC.indexOf("Linux")>=0;var ai=0,oi=0,li=0,Cs=0,fo={css:"#00000000",rgba:0},ca;(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})(ca||={});var qd;(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;ai=v+Math.round((x-v)*Cs),oi=S+Math.round((y-S)*Cs),li=L+Math.round((w-L)*Cs);let E=ca.toCss(ai,oi,li),R=ca.toRgba(ai,oi,li);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 ca.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let m=(p.rgba|255)>>>0;return[ai,oi,li]=Uc.toChannels(m),{css:ca.toCss(ai,oi,li),rgba:m}}e.opaque=a;function c(p,m){return Cs=Math.round(m*255),[ai,oi,li]=Uc.toChannels(p.rgba),{css:ca.toCss(ai,oi,li,Cs),rgba:ca.toRgba(ai,oi,li,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})(qd||={});var $C;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return ai=parseInt(a.slice(1,2).repeat(2),16),oi=parseInt(a.slice(2,3).repeat(2),16),li=parseInt(a.slice(3,4).repeat(2),16),ca.toColor(ai,oi,li);case 5:return ai=parseInt(a.slice(1,2).repeat(2),16),oi=parseInt(a.slice(2,3).repeat(2),16),li=parseInt(a.slice(3,4).repeat(2),16),Cs=parseInt(a.slice(4,5).repeat(2),16),ca.toColor(ai,oi,li,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 ai=parseInt(c[1],10),oi=parseInt(c[2],10),li=parseInt(c[3],10),Cs=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ca.toColor(ai,oi,li,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),[ai,oi,li,Cs]=t.getImageData(0,0,1,1).data,Cs!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ca.toRgba(ai,oi,li,Cs),css:a}}e.toColor=n})($C||={});var sa;(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})(sa||={});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 ai=y+Math.round((p-y)*Cs),oi=w+Math.round((m-w)*Cs),li=v+Math.round((x-v)*Cs),ca.toRgba(ai,oi,li)}e.blend=t;function r(l,d,p){let m=sa.relativeLuminance(l>>8),x=sa.relativeLuminance(d>>8);if(yl(m,x)<p){if(x<m){let v=n(l,d,p),S=yl(m,sa.relativeLuminance(v>>8));if(S<p){let L=a(l,d,p),E=yl(m,sa.relativeLuminance(L>>8));return S>E?v:L}return v}let y=a(l,d,p),w=yl(m,sa.relativeLuminance(y>>8));if(w<p){let v=n(l,d,p),S=yl(m,sa.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(sa.relativeLuminance2(w,v,S),sa.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(sa.relativeLuminance2(w,v,S),sa.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(sa.relativeLuminance2(w,v,S),sa.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(sa.relativeLuminance2(w,v,S),sa.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 Os(e){if(!e)throw new Error("value must not be falsy");return e}function z1(e){return 57508<=e&&e<=57558}function UC(e){return 57520<=e&&e<=57527}function zC(e){return 57344<=e&&e<=63743}function HC(e){return 9472<=e&&e<=9631}function WC(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 GC(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!WC(e)&&!z1(e)&&!zC(e)}function l3(e){return z1(e)||HC(e)}function VC(){return{css:{canvas:nh(),cell:nh()},device:{canvas:nh(),cell:nh(),char:{width:0,height:0,left:0,top:0}}}}function nh(){return{width:0,height:0}}function qC(e,t,r=0){return(e-(Math.round(t)*2-r))%(Math.round(t)*2)}var Fe;(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})))(Fe||={});var YC={"─":{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},"":Fe.LINE_H,"":Fe.LINE_V,"":Fe.FADE_RIGHT,"":Fe.FADE_LEFT,"":Fe.FADE_DOWN,"":Fe.FADE_UP,"":Fe.CURVE_DOWN_RIGHT,"":Fe.CURVE_DOWN_LEFT,"":Fe.CURVE_UP_RIGHT,"":Fe.CURVE_UP_LEFT,"":[Fe.LINE_V,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_RIGHT],"":[Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_UP_LEFT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT],"":[Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT],"":[Fe.CURVE_DOWN_LEFT,Fe.CURVE_DOWN_RIGHT],"":[Fe.LINE_H,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_UP_RIGHT],"":[Fe.CURVE_UP_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_UP_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT,Fe.CURVE_DOWN_RIGHT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE],"":Fe.NODE_STROKE,"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_UP],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_UP],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"🬀":yr(1),"🬁":yr(2),"🬂":yr(3),"🬃":yr(4),"🬄":yr(5),"🬅":yr(6),"🬆":yr(7),"🬇":yr(8),"🬈":yr(9),"🬉":yr(10),"🬊":yr(11),"🬋":yr(12),"🬌":yr(13),"🬍":yr(14),"🬎":yr(15),"🬏":yr(16),"🬐":yr(17),"🬑":yr(18),"🬒":yr(19),"🬓":yr(20),"🬔":yr(22),"🬕":yr(23),"🬖":yr(24),"🬗":yr(25),"🬘":yr(26),"🬙":yr(27),"🬚":yr(28),"🬛":yr(29),"🬜":yr(30),"🬝":yr(31),"🬞":yr(32),"🬟":yr(33),"🬠":yr(34),"🬡":yr(35),"🬢":yr(36),"🬣":yr(37),"🬤":yr(38),"🬥":yr(39),"🬦":yr(40),"🬧":yr(41),"🬨":yr(43),"🬩":yr(44),"🬪":yr(45),"🬫":yr(46),"🬬":yr(47),"🬭":yr(48),"🬮":yr(49),"🬯":yr(50),"🬰":yr(51),"🬱":yr(52),"🬲":yr(53),"🬳":yr(54),"🬴":yr(55),"🬵":yr(56),"🬶":yr(57),"🬷":yr(58),"🬸":yr(59),"🬹":yr(60),"🬺":yr(61),"🬻":yr(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}]))},ZC=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function yr(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 Ai=0,ri=0,Zo=!1,vl=!1,sh=!1,va,fd=0,KC=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,ri=0,Ai=0,vl=!1,Zo=!1,sh=!1,va=this._themeService.colors,fd=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));fd=t*n%(Math.round(l)*2)}if(fd===0&&ZC.has(c)&&(fd=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",l=>{l.backgroundColorRGB&&(ri=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ai=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),sh=this._selectionRenderModel.isCellSelected(this._terminal,t,r),sh){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ri=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ri=(this.result.fg&16777215)<<8|255;break;default:ri=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ri=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ri=(this.result.bg&16777215)<<8|255;break}ri=Uc.blend(ri,(this._coreBrowserService.isFocused?va.selectionBackgroundOpaque:va.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ri=(this._coreBrowserService.isFocused?va.selectionBackgroundOpaque:va.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(vl=!0,va.selectionForeground&&(Ai=va.selectionForeground.rgba>>8&16777215,Zo=!0),l3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)Ai=(this._coreBrowserService.isFocused?va.selectionBackgroundOpaque:va.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Ai=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Ai=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Ai=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Ai=(this.result.fg&16777215)<<8|255;break;default:Ai=this._themeService.colors.foreground.rgba}Ai=Uc.blend(Ai,(this._coreBrowserService.isFocused?va.selectionBackgroundOpaque:va.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Zo=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",l=>{l.backgroundColorRGB&&(ri=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ai=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),vl&&(sh?ri=e.bg&-16777216&-134217729|ri|50331648:ri=e.bg&-16777216|ri|50331648),Zo&&(Ai=e.fg&-16777216&-67108865|Ai|50331648),this.result.fg&67108864&&(vl&&!Zo&&((this.result.bg&50331648)===0?Ai=this.result.fg&-134217728|va.background.rgba>>8&16777215&16777215|50331648:Ai=this.result.fg&-134217728|this.result.bg&67108863,Zo=!0),!vl&&Zo&&((this.result.fg&50331648)===0?ri=this.result.bg&-67108864|va.foreground.rgba>>8&16777215&16777215|50331648:ri=this.result.bg&-67108864|this.result.fg&67108863,vl=!0)),va=void 0,this.result.bg=vl?ri:this.result.bg,this.result.fg=Zo?Ai:this.result.fg,this.result.ext&=536870911,this.result.ext|=fd<<29&3758096384}},XC=.5,c3=PC||OC?"bottom":"ideographic";function JC(e,t,r,n,a,c,l,d,p,m,x,y,w=0){let v=YC[t];if(v){let S=Array.isArray(v)?v:[v];for(let L of S)e_(e,L,r,n,a,c,l,d,p,m,x,y,w);return!0}return!1}function e_(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(),l_(e,t.clipPath,L,E,v,S)),t.type){case 0:t_(e,t.data,L,E,v,S);break;case 1:a_(e,t.data,L,E,v,S,w);break;case 2:o_(e,t.data,L,E,v,S,m,x,t.strokeWidth);break;case 3:n_(e,t.data,L,E,v,S,m,t.strokeWidth);break;case 4:i_(e,t.data,L,E,v,S,m,y);break;case 5:c_(e,t.data,L,E,v,S,p,m,x);break;case 6:r_(e,t.data,L,E,v,S);break}t.clipPath&&e.restore()}function t_(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 w2=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function r_(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=w2[x*2],w=w2[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 n_(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,W=parseFloat(E[1])*c,F=parseFloat(E[2])*Math.PI/180,U=parseInt(E[3],10),V=parseInt(E[4],10),Z=r+parseFloat(E[5])*a,ce=n+parseFloat(E[6])*c;s_(e,m,x,B,W,F,U,V,Z,ce),m=Z,x=ce;continue}let R=E.map((B,W)=>{let F=parseFloat(B);return W%2===0?r+F*a:n+F*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,W;v==="Q"||v==="T"?(B=2*m-y,W=2*x-w):(B=m,W=x),e.quadraticCurveTo(B,W,R[0],R[1]),y=B,w=W,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 s_(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,W=L*L,F=B/E+W/R;if(F>1){let ye=Math.sqrt(F);n*=ye,a*=ye,E=n*n,R=a*a}let U=(E*R-E*W-R*B)/(E*W+R*B);U<0&&(U=0);let V=(l===d?-1:1)*Math.sqrt(U),Z=V*(n*L/a),ce=V*-(a*S/n),xe=x*Z-y*ce+(t+p)/2,pe=y*Z+x*ce+(r+m)/2,te=(S-Z)/n,ke=(L-ce)/a,$e=(-S-Z)/n,Y=(-L-ce)/a,Ae=Math.atan2(ke,te),lt=Math.atan2(Y,$e)-Ae;d===0&<>0?lt-=2*Math.PI:d===1&<<0&&(lt+=2*Math.PI);let Se=Ae+lt;e.ellipse(xe,pe,n,a,c,Ae,Se,d===0)}function i_(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 A2=new Map;function a_(e,t,r,n,a,c,l=0){let d=A2.get(t);d||(d=new Map,A2.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=Os(S.getContext("2d")),E=new ImageData(w,v),R,B,W,F;if(p.startsWith("#"))R=parseInt(p.slice(1,3),16),B=parseInt(p.slice(3,5),16),W=parseInt(p.slice(5,7),16),F=p.length>7&&parseInt(p.slice(7,9),16)||1;else if(p.startsWith("rgba"))[R,B,W,F]=p.substring(5,p.length-1).split(",").map(U=>parseFloat(U));else throw new Error(`Unexpected fillStyle color format "${p}" when drawing pattern glyph`);for(let U=0;U<v;U++)for(let V=0;V<w;V++)E.data[(U*w+V)*4]=R,E.data[(U*w+V)*4+1]=B,E.data[(U*w+V)*4+2]=W,E.data[(U*w+V)*4+3]=t[U][V]*(F*255);L.putImageData(E,0,0),m=Os(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 o_(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=u3[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,d3(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 l_(e,t,r,n,a,c){e.beginPath();for(let l of t.split(" ")){let d=l[0];if(d==="Z"){e.closePath();continue}let 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 c_(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=u3[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,d3(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 T2(e,t,r=0){return Math.max(Math.min(e,t),r)}var u3={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 d3(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?T2(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?T2(w,r,0):w}x[y]+=a}return x}var S2=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={}}},C2=class{constructor(){this._data=new S2}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new S2),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()}},h3=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()}},u_=class extends h3{_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())}}},d_=class extends h3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},h_="requestIdleCallback"in globalThis?d_:u_,Iu=class f3{constructor(){this.fg=0,this.bg=0,this.extended=new p3}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 f3;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}},p3=class m3{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 m3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Po=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 i3;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 _2={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}},pd=2,md,rc=class Su{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new C2,this._cacheMapCombined=new C2,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Iu,this._textureSize=512,this._onAddTextureAtlasCanvas=new Po,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Po,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=x3(t,this._config.deviceCellWidth*4+pd*2,this._config.deviceCellHeight+pd*2),this._tmpCtx=Os(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 h_(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(Su.maxAtlasPages&&this._pages.length>=Math.max(4,Su.maxAtlasPages)){let r=this._pages.filter(m=>m.canvas.width*2<=(Su.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 md=t.get(r,n,a,c),md||(md=this._drawToCache(r,n,a,c,l,d),t.set(r,n,a,c,md)),md}_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 fo;let c;switch(t){case 16777216:case 33554432:c=this._getColorFromAnsiIndex(r);break;case 50331648:let l=Iu.toColorRGB(r);c=ca.toColor(l[0],l[1],l[2]);break;default:n?c=qd.opaque(this._config.colors.foreground):c=this._config.colors.background;break}return this._config.allowTransparency||(c=qd.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=Iu.toColorRGB(l);w=ca.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=qd.opaque(w)),p&&(w=qd.multiplyOpacity(w,XC)),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=ca.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)+pd*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<p&&(this._tmpCanvas.width=p);let m=Math.min(this._config.deviceCellHeight+pd*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 _2;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(),W=this._workAttributeData.getBgColor(),F=this._workAttributeData.getBgColorMode();if(y){let je=R;R=W,W=je;let re=B;B=F,F=re}let U=this._getBackgroundColor(F,W,y,w);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=U.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=c3;let ce=d.length===1&&z1(d.charCodeAt(0)),xe=d.length===1&&UC(d.charCodeAt(0)),pe=this._getForegroundColor(r,F,W,n,B,R,y,w,x,l3(d.charCodeAt(0)));this._tmpCtx.fillStyle=pe.css;let te=xe?0:pd*2,ke=!1;if(this._config.customGlyphs!==!1){let je=this._workAttributeData.getUnderlineVariantOffset();ke=JC(this._tmpCtx,d,te,te,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,U.css,je)}let $e=!ce,Y;if(typeof t=="number"?Y=this._unicodeService.wcwidth(t):Y=this._unicodeService.getStringCellWidth(t),S){this._tmpCtx.save();let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),re=je%2===1?.5:0;if(this._tmpCtx.lineWidth=je,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())$e=!1,this._tmpCtx.strokeStyle=`rgb(${Iu.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{$e=!1;let He=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&He<8&&(He+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(He).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let Oe=te,Ce=Math.ceil(te+this._config.deviceCharHeight)-re-(c?je*2:0),Ee=Ce+je*2,Be=this._workAttributeData.getUnderlineVariantOffset(),Ne=0,le=0;for(let He=0;He<Y;He++){let rt=!1;this._tmpCtx.save(),Ne=Ce,le=Ee;let mt=Oe+He*this._config.deviceCellWidth,ue=Oe+(He+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(mt,Ce),this._tmpCtx.lineTo(ue,Ce),this._tmpCtx.moveTo(mt,Ee),this._tmpCtx.lineTo(ue,Ee);break;case 3:Ne=this._config.deviceCharHeight+1,le=Ne+3*this._config.devicePixelRatio;let Ye=new Path2D;Ye.rect(mt,Ne,this._config.deviceCellWidth,le-Ne),this._tmpCtx.clip(Ye);let st=this._config.deviceCellWidth,Ie=le-Ne,We=st/6,Te=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 vt of H){this._tmpCtx.beginPath();for(let Zt=0;Zt<vt.length;Zt+=2){let Pt=mt+vt[Zt]*We,Xt=le-vt[Zt+1]*Te;Zt===0?this._tmpCtx.moveTo(Pt,Xt):this._tmpCtx.lineTo(Pt,Xt)}this._tmpCtx.closePath(),this._tmpCtx.fill()}rt=!0;break;case 4:let oe=Be===0?0:Be>=je?je*2-Be:je-Be;Be>=je||oe===0?(this._tmpCtx.setLineDash([Math.round(je),Math.round(je)]),this._tmpCtx.moveTo(mt+oe,Ce),this._tmpCtx.lineTo(ue,Ce)):(this._tmpCtx.setLineDash([Math.round(je),Math.round(je)]),this._tmpCtx.moveTo(mt,Ce),this._tmpCtx.lineTo(mt+oe,Ce),this._tmpCtx.moveTo(mt+oe+je,Ce),this._tmpCtx.lineTo(ue,Ce)),Be=qC(ue-mt,je,Be);break;case 5:let be=.6,Ze=.3,Je=ue-mt,St=Math.floor(be*Je),Vt=Math.floor(Ze*Je),jt=Je-St-Vt;this._tmpCtx.setLineDash([St,Vt,jt]),this._tmpCtx.moveTo(mt,Ce),this._tmpCtx.lineTo(ue,Ce);break;default:this._tmpCtx.moveTo(mt,Ce),this._tmpCtx.lineTo(ue,Ce);break}rt||this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!ke&&this._config.fontSize>=12&&!this._config.allowTransparency&&d!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let He=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in He&&He.actualBoundingBoxDescent>0){this._tmpCtx.save();let rt=new Path2D;rt.rect(Oe,Ne-Math.ceil(je/2),this._config.deviceCellWidth*Y,le-Ne+Math.ceil(je/2)),this._tmpCtx.clip(rt),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=U.css,this._tmpCtx.strokeText(d,te,te+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(E){let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),re=je%2===1?.5:0;this._tmpCtx.lineWidth=je,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(te,te+re),this._tmpCtx.lineTo(te+this._config.deviceCharWidth*Y,te+re),this._tmpCtx.stroke()}if(ke||this._tmpCtx.fillText(d,te,te+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let je=kp(this._tmpCtx.getImageData(te,te,this._config.deviceCellWidth,this._config.deviceCellHeight),U,pe,$e);if(je)for(let re=1;re<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=U.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,te,te+this._config.deviceCharHeight-re),je=kp(this._tmpCtx.getImageData(te,te,this._config.deviceCellWidth,this._config.deviceCellHeight),U,pe,$e),!!je);re++);}if(L){let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),re=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=je,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(te,te+Math.floor(this._config.deviceCharHeight/2)-re),this._tmpCtx.lineTo(te+this._config.deviceCharWidth*Y,te+Math.floor(this._config.deviceCharHeight/2)-re),this._tmpCtx.stroke()}this._tmpCtx.restore();let Ae=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),lt;if(this._config.allowTransparency?lt=f_(Ae):lt=kp(Ae,U,pe,$e),lt)return _2;let Se=this._findGlyphBoundingBox(Ae,this._workBoundingBox,p,xe,ke,te),ye,_e;for(;;){if(this._activePages.length===0){let je=this._createNewPage();ye=je,_e=je.currentRow,_e.height=Se.size.y;break}ye=this._activePages[this._activePages.length-1],_e=ye.currentRow;for(let je of this._activePages)Se.size.y<=je.currentRow.height&&(ye=je,_e=je.currentRow);for(let je=this._activePages.length-1;je>=0;je--)for(let re of this._activePages[je].fixedRows)re.height<=_e.height&&Se.size.y<=re.height&&(ye=this._activePages[je],_e=re);if(Se.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,_e=this._overflowSizePage.currentRow,_e.x+Se.size.x>=ye.canvas.width&&(_e.x=0,_e.y+=_e.height,_e.height=0);break}if(_e.y+Se.size.y>=ye.canvas.height||_e.height>Se.size.y+2){let je=!1;if(ye.currentRow.y+ye.currentRow.height+Se.size.y>=ye.canvas.height){let re;for(let Oe of this._activePages)if(Oe.currentRow.y+Oe.currentRow.height+Se.size.y<Oe.canvas.height){re=Oe;break}if(re)ye=re;else if(Su.maxAtlasPages&&this._pages.length>=Su.maxAtlasPages&&_e.y+Se.size.y<=ye.canvas.height&&_e.height>=Se.size.y&&_e.x+Se.size.x<=ye.canvas.width)je=!0;else{let Oe=this._createNewPage();ye=Oe,_e=Oe.currentRow,_e.height=Se.size.y,je=!0}}je||(ye.currentRow.height>0&&ye.fixedRows.push(ye.currentRow),_e={x:0,y:ye.currentRow.y+ye.currentRow.height,height:Se.size.y},ye.fixedRows.push(_e),ye.currentRow={x:0,y:_e.y+_e.height,height:0})}if(_e.x+Se.size.x<=ye.canvas.width)break;_e===ye.currentRow?(_e.x=0,_e.y+=_e.height,_e.height=0):ye.fixedRows.splice(ye.fixedRows.indexOf(_e),1)}return Se.texturePage=this._pages.indexOf(ye),Se.texturePosition.x=_e.x,Se.texturePosition.y=_e.y,Se.texturePositionClipSpace.x=_e.x/ye.canvas.width,Se.texturePositionClipSpace.y=_e.y/ye.canvas.height,Se.sizeClipSpace.x/=ye.canvas.width,Se.sizeClipSpace.y/=ye.canvas.height,_e.height=Math.max(_e.height,Se.size.y),_e.x+=Se.size.x,ye.ctx.putImageData(Ae,Se.texturePosition.x-this._workBoundingBox.left,Se.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,Se.size.x,Se.size.y),ye.addGlyph(Se),ye.version=++kc.nextVersion,Se}_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)}}}},g3=class Vm{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++Vm.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=x3(t,r,r),this.ctx=Os(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=++Vm.nextVersion}};g3.nextVersion=0;var kc=g3;function kp(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 f_(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function x3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function p_(e,t,r,n,a,c,l,d,p=!0){let m={foreground:c.foreground,background:c.background,cursor:fo,cursorAccent:fo,selectionForeground:fo,selectionBackgroundTransparent:fo,selectionBackgroundOpaque:fo,selectionInactiveBackgroundTransparent:fo,selectionInactiveBackgroundOpaque:fo,overviewRulerBorder:fo,scrollbarSliderBackground:fo,scrollbarSliderHoverBackground:fo,scrollbarSliderActiveBackground:fo,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 k2(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 m_(e){return(e&50331648)===16777216||(e&50331648)===33554432}var mo=[];function b3(e,t,r,n,a,c,l,d,p,m=!0){let x=p_(n,a,c,l,t,r,d,p,m);for(let S=0;S<mo.length;S++){let L=mo[S],E=L.ownedBy.indexOf(e);if(E>=0){if(k2(L.config,x))return L.atlas;L.ownedBy.length===1?(L.atlas.dispose(),mo.splice(S,1)):L.ownedBy.splice(E,1);break}}for(let S=0;S<mo.length;S++){let L=mo[S];if(k2(L.config,x))return L.ownedBy.push(e),L.atlas}let y=e._core,w=y._logService,v={atlas:new rc(document,x,y.unicodeService,w),config:x,ownedBy:[e]};return mo.push(v),v.atlas}function L2(e){for(let t=0;t<mo.length;t++){let r=mo[t].ownedBy.indexOf(e);if(r!==-1){mo[t].ownedBy.length===1?(mo[t].atlas.dispose(),mo.splice(t,1)):mo[t].ownedBy.splice(r,1);break}}}var g_=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 I2(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 x_(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var b_=class y3 extends Iu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new p3,this.combinedData=""}static fromCharData(t){let r=new y3;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?x_(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())}},y_=class extends Zc{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)}},v3=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function w3(e,t,r,n){let a=Os(e.createProgram());if(e.attachShader(a,Os(E2(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,Os(E2(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 E2(e,t,r,n){let a=Os(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 v_(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 w_=class{constructor(t){this.texture=t,this.version=-1}},A_=`#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 T_(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,us,Lp=0,gd=0,S_=class extends Zc{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;rc.maxAtlasPages===void 0&&(rc.maxAtlasPages=Math.min(32,Os(l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS))),rc.maxTextureSize=Os(l.getParameter(l.MAX_TEXTURE_SIZE))),this._program=Os(w3(l,A_,T_(rc.maxAtlasPages),this._logService)),this._register(Zs(()=>l.deleteProgram(this._program))),this._projectionLocation=Os(l.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Os(l.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Os(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=Os(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(rc.maxAtlasPages);for(let v=0;v<rc.maxAtlasPages;v++)w[v]=v;l.uniform1iv(this._textureLocation,w),l.uniformMatrix4fv(this._projectionLocation,!1,v3),this._atlasTextures=[];for(let v=0;v<rc.maxAtlasPages;v++){let S=new w_(Os(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?us=this._atlas.getRasterizedGlyphCombinedChar(p,c,l,d,!1,this._terminal.element):us=this._atlas.getRasterizedGlyph(a,c,l,d,!1,this._terminal.element),Lp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),c!==x&&us.offset.x>Lp?(gd=us.offset.x-Lp,t[Ss]=-(us.offset.x-gd)+this._dimensions.device.char.left,t[Ss+1]=-us.offset.y+this._dimensions.device.char.top,t[Ss+2]=(us.size.x-gd)/this._dimensions.device.canvas.width,t[Ss+3]=us.size.y/this._dimensions.device.canvas.height,t[Ss+4]=us.texturePage,t[Ss+5]=us.texturePositionClipSpace.x+gd/this._atlas.pages[us.texturePage].canvas.width,t[Ss+6]=us.texturePositionClipSpace.y,t[Ss+7]=us.sizeClipSpace.x-gd/this._atlas.pages[us.texturePage].canvas.width,t[Ss+8]=us.sizeClipSpace.y):(t[Ss]=-us.offset.x+this._dimensions.device.char.left,t[Ss+1]=-us.offset.y+this._dimensions.device.char.top,t[Ss+2]=us.size.x/this._dimensions.device.canvas.width,t[Ss+3]=us.size.y/this._dimensions.device.canvas.height,t[Ss+4]=us.texturePage,t[Ss+5]=us.texturePositionClipSpace.x,t[Ss+6]=us.texturePositionClipSpace.y,t[Ss+7]=us.sizeClipSpace.x,t[Ss+8]=us.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&GC(a,m,us.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}},C_=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 __(){return new C_}var k_=2147483648,L_=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=__()}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)}},I_=`#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
|
-
}`,E_=`#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,Ip=al*Float32Array.BYTES_PER_ELEMENT,N_=20*al,N2=class{constructor(){this.attributes=new Float32Array(N_),this.count=0}},wl=0,R2=0,M2=0,j2=0,D2=0,B2=0,Q2=0,R_=class extends Zc{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 N2,this._verticesCursor=new N2;let l=this._gl;this._program=Os(w3(l,I_,E_,this._logService)),this._register(Zs(()=>l.deleteProgram(this._program))),this._projectionLocation=Os(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=Os(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,Ip,0),l.vertexAttribDivisor(0,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,Ip,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,4,l.FLOAT,!1,Ip,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,v3),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=v_(t.attributes,(this._terminal.rows*this._terminal.cols+1)*al)),R2=c*this._dimensions.device.cell.width,M2=d*this._dimensions.device.cell.height,j2=(wl>>24&255)/255,D2=(wl>>16&255)/255,B2=(wl>>8&255)/255,Q2=1,this._addRectangle(t.attributes,r,R2,M2,(l-c)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,j2,D2,B2,Q2)}_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])}},M_=class extends Zc{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=Os(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=b3(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=c3,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}`}},j_=class extends M_{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&&m_(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()}},D_=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 Ep(e,t,r,n){return new D_(e,t,r,n)}var B_=class extends Zc{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 hd),this._charAtlasDisposable=this._register(new hd),this._observerDisposable=this._register(new hd),this._model=new L_,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new b_,this._rectangleRenderer=this._register(new hd),this._glyphRenderer=this._register(new hd),this._onChangeTextureAtlas=this._register(new Po),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Po),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Po),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Po),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Po),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 KC(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new j_(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,d,this._themeService)],this.dimensions=VC(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(d.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new y_(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Ep(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(Ep(this._canvas,"webglcontextrestored",w=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,L2(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=I2(this._canvas,this._coreBrowserService.window,(w,v)=>this._setCanvasDevicePixelDimensions(w,v)),this._register(this._coreBrowserService.onWindowChange(w=>{this._observerDisposable.value=I2(this._canvas,w,(v,S)=>this._setCanvasDevicePixelDimensions(v,S))})),this._register(Ep(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),L2(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 R_(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new S_(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=b3(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=BC(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 g_(()=>{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,W,F;e=P2(e,r.rows-1,0),t=P2(t,r.rows-1,0);let U=this._coreService.decPrivateModes.cursorStyle??r.options.cursorStyle??"block",V=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,Z=V-r.buffer.ydisp,ce=Math.min(this._terminal.buffer.active.cursorX,r.cols-1),xe=-1,pe=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let te=!1;for(c=e;c<=t;c++){l=c+r.buffer.ydisp;let ke=r.buffer.lines.get(l);if(!ke){for(this._model.lineLengths[c]=0,W=0;W<r.cols;W++)F=(c*r.cols+W)*4,te=!0,this._nullModelCell(W,c,F,0,0,0);this._setRowBlinkState(c,!1);continue}d=ke;let $e=!1;for(this._model.lineLengths[c]=0,S=V===l,x=0,p=this._characterJoinerService.getJoinedCharacters(l),W=0;W<r.cols;W++){if(a=this._cellColorResolver.result.bg,d.loadCell(W,n),W===0&&(a=this._cellColorResolver.result.bg),m=!1,y=W>=x,w=W,p.length>0&&W===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||ce<v[0]||ce>=v[1],y?(m=!0,n=new Q_(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+W)*4,!$e&&n.isBlink()&&($e=!0),this._cellColorResolver.resolve(n,W,l,this.dimensions.device.cell.width,this.dimensions.device.cell.height),pe&&l===V&&(W===ce&&(this._model.cursor={x:ce,y:Z,width:n.getWidth(),style:this._coreBrowserService.isFocused?U:r.options.cursorInactiveStyle,cursorWidth:r.options.cursorWidth,dpr:this._devicePixelRatio},xe=ce+n.getWidth()-1),W>=ce&&W<=xe&&(this._coreBrowserService.isFocused&&U==="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]=W+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)&&(te=!0,L.length>1&&(E|=k_),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(W,c,E,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,L,R,a),m)){for(n=this._workCell,W++;W<=w;W++)F=(c*r.cols+W)*4,this._nullModelCell(W,c,F,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);W--}}this._setRowBlinkState(c,$e)}te&&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})}},Q_=class extends Iu{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 P2(e,t,r=0){return Math.max(Math.min(e,t),r)}var P_=class extends Zc{constructor(e){if(o3&&FC()<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 Po),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Po),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Po),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Po),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 B_(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 O_=class{constructor(t,r,n,a={}){this._terminal=t,this._regex=r,this._handler=n,this._options=a}provideLinks(t,r){let n=$_.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 F_(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 $_=class Fh{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]=Fh._getWindowedLineStrings(t-1,n),m=d.join(""),x,y=[];for(;x=l.exec(m);){let w=x[0];if(!F_(w))continue;let[v,S]=Fh._mapStrIdx(n,p,0,x.index),[L,E]=Fh._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]}},U_=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function z_(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 H_=class{constructor(t=z_,r={}){this._handler=t,this._options=r}activate(t){this._terminal=t;let r=this._options,n=r.urlRegex??U_;this._linkProvider=this._terminal.registerLinkProvider(new O_(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function O2(e){return{dispose:e}}var W_=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()}},G_=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return O2(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=O2(()=>{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)}},V_;(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 W_;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})(V_||={});var F2=class $h{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new G_,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=$h.extractWidth(d);$h.extractShouldJoin(d)&&(p-=$h.extractWidth(n)),r+=p,n=d}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},Np=[[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]],q_=[[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]],Rp=[[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]],Y_=[[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 $2(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 Z_=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<Np.length;++e)Al.fill(0,Np[e][0],Np[e][1]+1);for(let e=0;e<Rp.length;++e)Al.fill(2,Rp[e][0],Rp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Al[e]:$2(e,q_)?0:$2(e,Y_)?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let a=F2.extractWidth(t);a===0?n=!1:a>r&&(r=a)}return F2.createPropertyValue(0,r,n)}},K_=class{activate(e){e.unicode.register(new Z_)}dispose(){}};function Vc(e){return{dispose:e}}function Uh(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function X_(...e){return Vc(()=>Uh(e))}var A3=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()}},j0=class{constructor(){this._store=new A3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};j0.None=Object.freeze({dispose(){}});var ff=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}},qm=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Vc(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Vc(()=>{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)}},J_;(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 A3;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})(J_||={});function T3(e,t=0,r){let n=setTimeout(()=>{e()},t);return Vc(()=>{clearTimeout(n)})}var ek=class extends j0{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new ff),this._linesCacheDisposables=this._register(new ff),this._lastAccessTimestamp=0,this._register(Vc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=X_(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=T3(()=>{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]}},tk=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}},rk=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),W=this._stringLengthToBufferSize(c+L,R)-B+this._terminal.cols*(L-S);return{term:t,col:B,row:c+S,size:W}}}_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}},nk=class extends j0{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Vc(()=>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(){Uh(n)}}}clearHighlightDecorations(){Uh(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(()=>Uh(w))),p.push(y)}}return p.length===0?void 0:p}},sk=class extends j0{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new qm)}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()}},ik=class extends j0{constructor(t){super(),this._highlightTimeout=this._register(new ff),this._lineCache=this._register(new ff),this._state=new tk,this._resultTracker=this._register(new sk),this._onAfterSearch=this._register(new qm),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new qm),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 ek(t),this._engine=new rk(t,this._lineCache.value),this._decorationManager=new nk(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Vc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=T3(()=>{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 ci=0,ui=0,di=0,_s=0,Oi;(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})(Oi||={});var ak;(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;ci=v+Math.round((x-v)*_s),ui=S+Math.round((y-S)*_s),di=L+Math.round((w-L)*_s);let E=Oi.toCss(ci,ui,di),R=Oi.toRgba(ci,ui,di);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=zh.ensureContrastRatio(p.rgba,m.rgba,x);if(y)return Oi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let m=(p.rgba|255)>>>0;return[ci,ui,di]=zh.toChannels(m),{css:Oi.toCss(ci,ui,di),rgba:m}}e.opaque=a;function c(p,m){return _s=Math.round(m*255),[ci,ui,di]=zh.toChannels(p.rgba),{css:Oi.toCss(ci,ui,di,_s),rgba:Oi.toRgba(ci,ui,di,_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})(ak||={});var _i;(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 ci=parseInt(a.slice(1,2).repeat(2),16),ui=parseInt(a.slice(2,3).repeat(2),16),di=parseInt(a.slice(3,4).repeat(2),16),Oi.toColor(ci,ui,di);case 5:return ci=parseInt(a.slice(1,2).repeat(2),16),ui=parseInt(a.slice(2,3).repeat(2),16),di=parseInt(a.slice(3,4).repeat(2),16),_s=parseInt(a.slice(4,5).repeat(2),16),Oi.toColor(ci,ui,di,_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 ci=parseInt(c[1],10),ui=parseInt(c[2],10),di=parseInt(c[3],10),_s=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Oi.toColor(ci,ui,di,_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),[ci,ui,di,_s]=t.getImageData(0,0,1,1).data,_s!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Oi.toRgba(ci,ui,di,_s),css:a}}e.toColor=n})(_i||={});var ia;(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})(ia||={});var zh;(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 ci=y+Math.round((p-y)*_s),ui=w+Math.round((m-w)*_s),di=v+Math.round((x-v)*_s),Oi.toRgba(ci,ui,di)}e.blend=t;function r(l,d,p){let m=ia.relativeLuminance(l>>8),x=ia.relativeLuminance(d>>8);if(Tl(m,x)<p){if(x<m){let v=n(l,d,p),S=Tl(m,ia.relativeLuminance(v>>8));if(S<p){let L=a(l,d,p),E=Tl(m,ia.relativeLuminance(L>>8));return S>E?v:L}return v}let y=a(l,d,p),w=Tl(m,ia.relativeLuminance(y>>8));if(w<p){let v=n(l,d,p),S=Tl(m,ia.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(ia.relativeLuminance2(w,v,S),ia.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(ia.relativeLuminance2(w,v,S),ia.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(ia.relativeLuminance2(w,v,S),ia.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(ia.relativeLuminance2(w,v,S),ia.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})(zh||={});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 ok=Object.freeze((()=>{let e=[_i.toColor("#2e3436"),_i.toColor("#cc0000"),_i.toColor("#4e9a06"),_i.toColor("#c4a000"),_i.toColor("#3465a4"),_i.toColor("#75507b"),_i.toColor("#06989a"),_i.toColor("#d3d7cf"),_i.toColor("#555753"),_i.toColor("#ef2929"),_i.toColor("#8ae234"),_i.toColor("#fce94f"),_i.toColor("#729fcf"),_i.toColor("#ad7fa8"),_i.toColor("#34e2e2"),_i.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:Oi.toCss(n,a,c),rgba:Oi.toRgba(n,a,c)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:Oi.toCss(n,n,n),rgba:Oi.toRgba(n,n,n)})}return e})());function U2(e,t,r){return Math.max(t,Math.min(e,r))}function lk(e){switch(e){case"&":return"&";case"<":return"<"}return e}var S3=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 H1(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 C3(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 W1(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&C3(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 _3(e,t){let r=e;return typeof r.attributesEquals=="function"?r.attributesEquals(t):H1(e,t)&&ol(e,t)&&W1(e,t)}var ck=class extends S3{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(_3(t,r))return n;let a=!H1(t,r),c=!ol(t,r),l=!W1(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),C3(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}},uk=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,r,n){let a=r.length,c=n===void 0?a:U2(n+t.rows,0,a);return this._serializeBufferByRange(t,r,{start:a-c,end:a-1},!1)}_serializeBufferByRange(t,r,n,a){return new ck(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 dk(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:U2(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(){}},dk=class extends S3{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=ok}_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(_3(t,r))return;let a=!H1(t,r),c=!ol(t,r),l=!W1(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+=lk(t.getChars())}_serializeString(){return this._htmlContent}};var hk=class{constructor(e=new fk,t=new k3){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}},k3=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},fk=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 pk=Object.create,L3=Object.defineProperty,mk=Object.getOwnPropertyDescriptor,gk=Object.getOwnPropertyNames,xk=Object.getPrototypeOf,bk=Object.prototype.hasOwnProperty,Zu=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},yk=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of gk(t))!bk.call(e,a)&&a!==r&&L3(e,a,{get:()=>t[a],enumerable:!(n=mk(t,a))||n.enumerable});return e},Ku=(e,t,r)=>(r=e!=null?pk(xk(e)):{},yk(!e||!e.__esModule?L3(r,"default",{value:e,enumerable:!0}):r,e)),G1=Zu(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,W=-1;for(let F=0;F<S.length;++F){let U=L-S[F][0],V=E-S[F][1],Z=R-S[F][2],ce=U*U+V*V+Z*Z;if(!ce)return F;ce<B&&(B=ce,W=F)}return W}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)}),I3=Zu(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)}}),E3=Zu(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=I3(),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}),vk=Zu(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=I3(),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}),wk=Zu(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"}}),Ak=Zu(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=G1(),r=wk();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,W=E;B<R;++B,++W)this._chunk[B]=v.charCodeAt(W);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,W=this._lastOffset;this._realloc(W,v*6);for(let F=0;F<6;++F)this._canvas.set(this._pSrc.subarray(B*F,B*F+v),W+v*F)}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 W=0;W<6;++W)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 W=0;W<B;++W)S.set(this._pSrc.subarray(R*W,R*W+v),L+this.width*W)}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 Ym(e){return{dispose:e}}var N3=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()}},R3=class{constructor(){this._store=new N3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};R3.None=Object.freeze({dispose(){}});var Tk=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}},Sk=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Ym(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Ym(()=>{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)}},Ck;(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 N3;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})(Ck||={});var z2=Ku(G1()),zu=class nc extends R3{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new Tk),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(Ym(()=>{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=nc.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=nc.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=nc.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=nc.createCanvas(this.document,r,t),a=n.getContext("2d",{alpha:!1});if(!a)return;let c=nc.createImageData(a,r,t),l=new Uint32Array(c.data.buffer),d=(0,z2.toRGBA8888)(0,0,0),p=(0,z2.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=nc.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);nc.createImageBitmap(this._placeholder).then(y=>this._placeholderBitmap=y)}get document(){return this._terminal._core._coreBrowserService?.window.document}},El={width:7,height:14},Zm=class M3{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 M3(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},ih=new Zm,_k=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]??ih;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]??ih,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]??ih;if(n.imageId&&n.imageId!==-1){let a=this._images.get(n.imageId)?.orig;if(window.ImageBitmap&&a instanceof ImageBitmap){let c=zu.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]??ih;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 Zm(a.ext,a.urlId,r,n);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new Zm(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)}},kk=Ku(E3()),Lk=Ku(vk());function pf(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}function Mp(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 H2(e){let t=pf(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function Ik(e){if(typeof Buffer<"u")return Buffer.from(pf(e),"base64").toString();let t=atob(pf(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 W2={inline:Mp,size:Mp,name:Ik,width:H2,height:H2,preserveAspectRatio:Mp},G2=[70,105,108,101],V2=[77,117,108,116,105,112,97,114,116,70,105,108,101],jp=[70,105,108,101,80,97,114,116],Dp=[70,105,108,101,69,110,100],Bp=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],Qp=1024,Ek=class{constructor(){this.state=0,this._buffer=new Uint32Array(Qp),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===Dp.length){for(let t=0;t<Dp.length;++t)if(this._buffer[t]!==Dp[t])return this._a();return this.fields.type=4,this.state=4,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=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<G2.length;++m)if(l[m]!==G2[m])return this._a();if(this.fields.type=1,c===jp.length){for(;m<jp.length;++m)if(l[m]!==jp[m])return this._a();return this.fields.type=3,this.state=4,d+1}}else if(l[0]===77){for(let m=0;m<V2.length;++m)if(l[m]!==V2[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>=Qp)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>=Qp)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=pf(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]=W2[this._key]?W2[this._key](r):r}catch{return!1}return!0}return!1}},mf={mime:"unsupported",width:0,height:0};function Nk(e){if(e.length<24)return mf;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]=Rk(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]}:mf}function Rk(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 Pp={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},Mk=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._storage=r,this._coreTerminal=n,this._aborted=!1,this._hp=new Ek,this._header=Pp,this._metrics=mf,this._isMultipart=!1,this._abortMulti=!1;let a=Math.ceil(this._opts.iipSizeLimit*4/3),c=Math.min(1048576,a);this._dec=new kk.default(4194304,a,c),this._qoiDec=new Lk.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=mf,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({},Pp,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({},Pp,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=Nk(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=zu.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}},jk=Ku(E3());function q2(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 Y2=0,Dk=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=q2(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 jk.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,r))!==Y2&&(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()!==Y2&&(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=q2(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 xe=await createImageBitmap(r,n,a,m,x);r.close(),r=xe}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,W=R.y,F=R.ybase,U=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(L!==r.width||E!==r.height){let xe=await createImageBitmap(r,{resizeWidth:L,resizeHeight:E});r.close(),r=xe}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 xe=t.columns!==void 0?Math.round(v*y):r.width+V,pe=t.rows!==void 0?Math.round(S*w):r.height+Z,te=zu.createCanvas(window.document,xe,pe),ke=te.getContext("2d");if(!ke)throw new Error("Failed to create offset canvas context");ke.drawImage(r,V,Z);let $e=await createImageBitmap(te);if(te.width=te.height=0,r.close(),r=$e,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 ce=t.zIndex??0;if(this._kittyStorage.addImage(e.id,r,!0,U,ce),r=void 0,t.cursorMovement===1){let xe=R.ybase-F;R.x=B,R.y=Math.max(W-xe,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,W)=>{R.addEventListener("load",()=>{URL.revokeObjectURL(E);let F=zu.createCanvas(window.document,R.width,R.height);F.getContext("2d")?.drawImage(R,0,0),createImageBitmap(F).then(B).catch(W)}),R.addEventListener("error",()=>{URL.revokeObjectURL(E),W(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}},j3=class Km{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>=Km._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<=Km._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};j3._maxStoredImages=256;var Bk=j3,x0=Ku(G1()),Qk=Ku(Ak()),Pk=4194304,Xm=x0.PALETTE_ANSI_256;Xm.set(x0.PALETTE_VT340_COLOR);var Ok=class{constructor(e,t,r){this._opts=e,this._storage=t,this._coreTerminal=r,this._size=0,this._aborted=!1,(0,Qk.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:Xm,paletteLimit:this._opts.sixelPaletteLimit}).then(n=>this._dec=n)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Xm,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:Fk(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=zu.createCanvas(void 0,t,r);return n.getContext("2d")?.putImageData(new ImageData(this._dec.data8,t,r),0,0),this._dec.memoryUsage>Pk&&this._dec.release(),this._storage.addImage(n),!0}};function Fk(e,t){let r=0;if(!t)return r;if(e.isInverse())if(e.isFgDefault())r=ah(t.foreground.rgba);else if(e.isFgRGB()){let n=e.constructor.toColorRGB(e.getFgColor());r=(0,x0.toRGBA8888)(...n)}else r=ah(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())r=ah(t.background.rgba);else if(e.isBgRGB()){let n=e.constructor.toColorRGB(e.getBgColor());r=(0,x0.toRGBA8888)(...n)}else r=ah(t.ansi[e.getBgColor()].rgba);return r}function ah(e){return x0.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var $k=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()}}},Uk=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},Z2={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},K2=4096,zk=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new Sk,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},Z2,t),this._defaultOpts=Object.assign({},Z2,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 zu(t),this._storage=new _k(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 $k(this._storage,this._opts,this._renderer,t),n=new Ok(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 Uk(this._storage),n=new Mk(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 Bk(this._storage),n=new Dk(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]<=K2?(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;${K2}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 uu=new Map;function Cu(e){return{name:e,get hasSubscribers(){return(uu.get(e)?.size??0)>0},publish(t){const r=uu.get(e);if(r)for(const n of r)n(t,e)},subscribe(t){const r=uu.get(e)??new Set;r.add(t),uu.set(e,r)},unsubscribe(t){const r=uu.get(e);if(!r)return!1;const n=r.delete(t);return r.size===0&&uu.delete(e),n}}}function Hk(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},r={start:Cu(t.start),end:Cu(t.end),asyncStart:Cu(t.asyncStart),asyncEnd:Cu(t.asyncEnd),error:Cu(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 Wk=Object.create,V1=Object.defineProperty,Gk=Object.getOwnPropertyDescriptor,Vk=Object.getOwnPropertyNames,qk=Object.getPrototypeOf,Yk=Object.prototype.hasOwnProperty,D3=e=>{throw TypeError(e)},Zk=(e,t,r)=>t in e?V1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kk=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Xk=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Vk(t))!Yk.call(e,a)&&a!==r&&V1(e,a,{get:()=>t[a],enumerable:!(n=Gk(t,a))||n.enumerable});return e},Jk=(e,t,r)=>(r=e!=null?Wk(qk(e)):{},Xk(!e||!e.__esModule?V1(r,"default",{value:e,enumerable:!0}):r,e)),Ys=(e,t,r)=>Zk(e,typeof t!="symbol"?t+"":t,r),q1=(e,t,r)=>t.has(e)||D3("Cannot "+r),ae=(e,t,r)=>(q1(e,t,"read from private field"),r?r.call(e):t.get(e)),mn=(e,t,r)=>t.has(e)?D3("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Nr=(e,t,r,n)=>(q1(e,t,"write to private field"),t.set(e,r),r),Wt=(e,t,r)=>(q1(e,t,"access private method"),r),Op=(e,t,r,n)=>({set _(a){Nr(e,t,a)},get _(){return ae(e,t,n)}}),eL=Kk((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:()=>re,Font:()=>qg,Glyph:()=>gr,Path:()=>He,_parse:()=>it,load:()=>W8,loadSync:()=>G8,parse:()=>H8});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),W=new Uint8Array(30),F=new Uint16Array(30),U=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 ce(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 xe(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 te(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 ke(i){i.bitcount--||(i.tag=i.source[i.sourceIndex++],i.bitcount=7);var o=i.tag&1;return i.tag>>>=1,o}function $e(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 Ae(i,o,u){var h,f,g,A,_,I;for(h=$e(i,5,257),f=$e(i,5,1),g=$e(i,4,4),A=0;A<19;++A)Z[A]=0;for(A=0;A<g;++A){var D=$e(i,3,0);Z[U[A]]=D}for(te(V,Z,0,19),_=0;_<h+f;){var M=Y(i,V);switch(M){case 16:var J=Z[_-1];for(I=$e(i,2,3);I;--I)Z[_++]=J;break;case 17:for(I=$e(i,3,3);I;--I)Z[_++]=0;break;case 18:for(I=$e(i,7,11);I;--I)Z[_++]=0;break;default:Z[_++]=M;break}}te(o,Z,0,h),te(u,Z,h,f)}function lt(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=$e(i,R[h],B[h]),g=Y(i,u),A=i.destLen-$e(i,W[g],F[g]),_=A;_<A+f;++_)i.dest[i.destLen++]=i.dest[_]}}}function Se(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=ke(u),f=$e(u,2,0),f){case 0:g=Se(u);break;case 1:g=lt(u,L,E);break;case 2:Ae(u,u.ltree,u.dtree),g=lt(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}xe(L,E),ce(R,B,4,3),ce(W,F,2,1),R[28]=0,B[28]=258;function _e(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 je(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}je.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},je.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))},je.prototype.addX=function(i){this.addPoint(i,null)},je.prototype.addY=function(i){this.addPoint(null,i)},je.prototype.addBezier=function(i,o,u,h,f,g,A,_){let I=[i,o],D=[u,h],M=[f,g],J=[A,_];this.addPoint(i,o),this.addPoint(A,_);for(let X=0;X<=1;X++){let ve=6*I[X]-12*D[X]+6*M[X],he=-3*I[X]+9*D[X]-9*M[X]+3*J[X],Re=3*D[X]-3*I[X];if(he===0){if(ve===0)continue;let Dr=-Re/ve;0<Dr&&Dr<1&&(X===0&&this.addX(_e(I[X],D[X],M[X],J[X],Dr)),X===1&&this.addY(_e(I[X],D[X],M[X],J[X],Dr)));continue}let ut=Math.pow(ve,2)-4*Re*he;if(ut<0)continue;let xr=(-ve+Math.sqrt(ut))/(2*he);0<xr&&xr<1&&(X===0&&this.addX(_e(I[X],D[X],M[X],J[X],xr)),X===1&&this.addY(_e(I[X],D[X],M[X],J[X],xr)));let lr=(-ve-Math.sqrt(ut))/(2*he);0<lr&&lr<1&&(X===0&&this.addX(_e(I[X],D[X],M[X],J[X],lr)),X===1&&this.addY(_e(I[X],D[X],M[X],J[X],lr)))}},je.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 re=je;function Oe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var Ce={};function Ee(i,o){let u=Math.floor(i),h=i-u;if(Ce[o]||(Ce[o]={}),Ce[o][h]!==void 0){let g=Ce[o][h];return u+g}let f=+(Math.round(h+"e+"+o)+"e-"+o);return Ce[o][h]=f,u+f}function Be(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 le(i){return parseInt(i)===i&&(i={decimalPlaces:i,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},i)}Oe.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 ut=parseFloat(Re);return(o.decimalPlaces||o.decimalPlaces===0)&&(ut=Ee(ut,o.decimalPlaces)),ut})}function M(he){if(!this.commands.length)return he;let Re=this.commands[this.commands.length-1];for(let ut=0;ut<he.length;ut++)he[ut]+=Re[ut&1?"y":"x"];return he}function J(){if(A.type===void 0)return;let he=A.type.toUpperCase(),Re=he!=="Z"&&A.type.toUpperCase()!==A.type,ut=D(_);if(_=[""],!ut.length&&he!=="Z")return;Re&&he!=="H"&&he!=="V"&&(ut=M.apply(this,[ut]));let xr=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(...ut);break;case"L":this.lineTo(...ut);break;case"V":for(let Dr=0;Dr<ut.length;Dr++){let en=0;Re&&(en=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(xr,ut[Dr]+en)}break;case"H":for(let Dr=0;Dr<ut.length;Dr++){let en=0;Re&&(en=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(ut[Dr]+en,lr)}break;case"C":this.bezierCurveTo(...ut);break;case"Q":this.quadraticCurveTo(...ut);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let Dr in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Dr]===void 0&&(this.commands[this.commands.length-1][Dr]=0)}for(let he=0;he<i.length;he++){let Re=i.charAt(he),ut=_[_.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||ut.indexOf("-")>0?I=!0:ut.length?_.push("-"):_[_.length-1]=Re;else if(!A.type||ut.length>0)I=!0;else continue;else if(h.indexOf(Re)>-1)A.type?(J.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||ut.indexOf(Re)>-1?I=!0:_[_.length-1]+=Re:I=!0}if(I)throw new Error("Unexpected character: "+Re+" at offset "+he)}J.apply(this),o.optimize&&(this.commands=Be(this.commands));let X=o.flipY,ve=o.flipYBase;if(X===!0&&o.flipYBase===void 0){let he=this.getBoundingBox();ve=he.y1+he.y2}for(let he in this.commands){let Re=this.commands[he];for(let ut in Re)["x","x1","x2"].includes(ut)?this.commands[he][ut]=o.x+Re[ut]*o.scale:["y","y1","y2"].includes(ut)&&(this.commands[he][ut]=o.y+(X?ve-Re[ut]:Re[ut])*o.scale)}return this},Oe.fromSVG=function(i,o){return new Oe().fromSVG(i,o)},Oe.prototype.moveTo=function(i,o){this.commands.push({type:"M",x:i,y:o})},Oe.prototype.lineTo=function(i,o){this.commands.push({type:"L",x:i,y:o})},Oe.prototype.curveTo=Oe.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})},Oe.prototype.quadTo=Oe.prototype.quadraticCurveTo=function(i,o,u,h){this.commands.push({type:"Q",x1:i,y1:o,x:u,y:h})},Oe.prototype.close=Oe.prototype.closePath=function(){this.commands.push({type:"Z"})},Oe.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof re){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)},Oe.prototype.getBoundingBox=function(){let i=new re,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},Oe.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())},Oe.prototype.toPathData=function(i){i=le(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=Be(h));let f=i.flipY,g=i.flipYBase;if(f===!0&&g===void 0){let _=new Oe;_.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},Oe.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},Oe.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 He=Oe;function rt(i){throw new Error(i)}function mt(i,o){i||rt(o)}var ue={fail:rt,argument:mt,assert:mt},Ye=32768,st=2147483648,Ie=-32768,We=32767+1/65536,Te={},H={},oe={};function be(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]},oe.BYTE=be(1),H.CHAR=function(i){return[i.charCodeAt(0)]},oe.CHAR=be(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},oe.CHARARRAY=function(i){return typeof i>"u"?0:i.length},H.USHORT=function(i){return[i>>8&255,i&255]},oe.USHORT=be(2),H.SHORT=function(i){return i>=Ye&&(i=-(2*Ye-i)),[i>>8&255,i&255]},oe.SHORT=be(2),H.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},oe.UINT24=be(3),H.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},oe.ULONG=be(4),H.LONG=function(i){return i>=st&&(i=-(2*st-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},oe.LONG=be(4),H.FLOAT=function(i){if(i>We||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)},oe.FLOAT=oe.ULONG,H.FIXED=H.ULONG,oe.FIXED=oe.ULONG,H.FWORD=H.SHORT,oe.FWORD=oe.SHORT,H.UFWORD=H.USHORT,oe.UFWORD=oe.USHORT,H.F2DOT14=function(i){return H.USHORT(i*16384)},oe.F2DOT14=oe.USHORT,H.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},oe.LONGDATETIME=be(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)]},oe.TAG=be(4),H.Card8=H.BYTE,oe.Card8=oe.BYTE,H.Card16=H.USHORT,oe.Card16=oe.USHORT,H.OffSize=H.BYTE,oe.OffSize=oe.BYTE,H.SID=H.USHORT,oe.SID=oe.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)},oe.NUMBER=function(i){return H.NUMBER(i).length},H.NUMBER16=function(i){return[28,i>>8&255,i&255]},oe.NUMBER16=be(3),H.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},oe.NUMBER32=be(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},oe.REAL=function(i){return H.REAL(i).length},H.NAME=H.CHARARRAY,oe.NAME=oe.CHARARRAY,H.STRING=H.CHARARRAY,oe.STRING=oe.CHARARRAY,Te.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)},Te.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},oe.UTF16=function(i){return i.length*2};var Ze={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Te.MACSTRING=function(i,o,u,h){let f=Ze[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 Je=typeof WeakMap=="function"&&new WeakMap,St,Vt=function(i){if(!St){St={};for(let f in Ze)St[f]=new String(f)}let o=St[i];if(o===void 0)return;if(Je){let f=Je.get(o);if(f!==void 0)return f}let u=Ze[i];if(u===void 0)return;let h={};for(let f=0;f<u.length;f++)h[u.charCodeAt(f)]=f+128;return Je&&Je.set(o,h),h};H.MACSTRING=function(i,o){let u=Vt(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},oe.MACSTRING=function(i,o){let u=H.MACSTRING(i,o);return u!==void 0?u.length:0};function jt(i){return i>=-128&&i<=127}function vt(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(!jt(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 Pt(i,o,u){let h=0,f=i.length,g=o;for(;g<f&&h<64;){let A=i[g];if(A===0||jt(A)&&g+1<f&&jt(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=vt(i,o,u):h>=-128&&h<=127?o=Zt(i,o,u):o=Pt(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)},oe.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},oe.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,oe.OP=oe.BYTE;var Xt=typeof WeakMap=="function"&&new WeakMap;H.CHARSTRING=function(i){if(Xt){let h=Xt.get(i);if(h!==void 0)return h}let o=[],u=i.length;for(let h=0;h<u;h+=1){let f=i[h],g=H[f.type](f.value);for(let A=0;A<g.length;A++)o.push(g[A])}return Xt&&Xt.set(i,o),o},oe.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)},oe.OBJECT=function(i){let o=oe[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},oe.TABLE=function(i){let o=0,u=(i.fields||[]).length;for(let h=0;h<u;h+=1){let f=i.fields[h],g=oe[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,oe.RECORD=oe.TABLE,H.LITERAL=function(i){return i},oe.LITERAL=function(i){return i.length};function zt(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)}}}zt.prototype.encode=function(){return H.TABLE(this)},zt.prototype.sizeOf=function(){return oe.TABLE(this)};function Lt(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 me(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 Ge(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 pt(i){i.format===1?zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Lt("glyph",i.glyphs))):i.format===2?zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Ge("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.")}pt.prototype=Object.create(zt.prototype),pt.prototype.constructor=pt;function q(i){zt.call(this,"scriptListTable",Ge("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 zt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new zt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:f.reqFeatureIndex}].concat(Lt("featureIndex",f.featureIndexes)))}].concat(Ge("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 zt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:_.reqFeatureIndex}].concat(Lt("featureIndex",_.featureIndexes)))}]})))}]}))}q.prototype=Object.create(zt.prototype),q.prototype.constructor=q;function at(i){zt.call(this,"featureListTable",Ge("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 zt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Lt("lookupListIndex",h.lookupListIndexes)))}]}))}at.prototype=Object.create(zt.prototype),at.prototype.constructor=at;function qt(i,o){zt.call(this,"lookupListTable",me("lookup",i,function(u){let h=o[u.lookupType];return ue.assert(!!h,"Unable to write GSUB lookup type "+u.lookupType+" tables."),new zt("lookupTable",[{name:"lookupType",type:"USHORT",value:u.lookupType},{name:"lookupFlag",type:"USHORT",value:u.lookupFlag}].concat(me("subtable",u.subtables,h)))}))}qt.prototype=Object.create(zt.prototype),qt.prototype.constructor=qt;function Ve(i){i.format===1?zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:i.startGlyph}].concat(Lt("glyph",i.classes))):i.format===2?zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Ge("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.")}Ve.prototype=Object.create(zt.prototype),Ve.prototype.constructor=Ve;var De={Table:zt,Record:zt,Coverage:pt,ClassDef:Ve,ScriptList:q,FeatureList:at,LookupList:qt,ushortList:Lt,tableList:me,recordList:Ge};function er(i,o){return i.getUint8(o)}function et(i,o){return i.getUint16(o,!1)}function Ct(i,o){return i.getInt16(o,!1)}function Nt(i,o){return(i.getUint16(o)<<8)+i.getUint8(o+2)}function gt(i,o){return i.getUint32(o,!1)}function bt(i,o){return i.getInt32(o,!1)}function It(i,o){let u=i.getInt16(o,!1),h=i.getUint16(o+2,!1);return u+h/65535}function yt(i,o){let u="";for(let h=o;h<o+4;h+=1)u+=String.fromCharCode(i.getInt8(h));return u}function pr(i,o,u){let h=0;for(let f=0;f<u;f+=1)h<<=8,h+=i.getUint8(o+f);return h}function nr(i,o,u){let h=[];for(let f=o;f<u;f+=1)h.push(i.getUint8(f));return h}function Cr(i){let o="";for(let u=0;u<i.length;u+=1)o+=String.fromCharCode(i[u]);return o}var cn={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},Lr={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 ge(i,o){this.data=i,this.offset=o,this.relativeOffset=0}ge.prototype.parseByte=function(){let i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},ge.prototype.parseChar=function(){let i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},ge.prototype.parseCard8=ge.prototype.parseByte,ge.prototype.parseUShort=function(){let i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},ge.prototype.parseCard16=ge.prototype.parseUShort,ge.prototype.parseSID=ge.prototype.parseUShort,ge.prototype.parseOffset16=ge.prototype.parseUShort,ge.prototype.parseShort=function(){let i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},ge.prototype.parseF2Dot14=function(){let i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},ge.prototype.parseUInt24=function(){let i=Nt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,i},ge.prototype.parseULong=function(){let i=gt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},ge.prototype.parseLong=function(){let i=bt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},ge.prototype.parseOffset32=ge.prototype.parseULong,ge.prototype.parseFixed=function(){let i=It(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},ge.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},ge.prototype.parseTag=function(){return this.parseString(4)},ge.prototype.parseLongDateTime=function(){let i=gt(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},ge.prototype.parseVersion=function(i){let o=et(this.data,this.offset+this.relativeOffset),u=et(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),o+u/i/10},ge.prototype.skip=function(i,o){o===void 0&&(o=1),this.relativeOffset+=cn[i]*o},ge.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},ge.prototype.parseOffset16List=ge.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},ge.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},ge.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},ge.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},ge.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},ge.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},ge.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},ge.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},ge.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}},ge.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},ge.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},ge.prototype.parsePointer=function(i){let o=this.parseOffset16();if(o>0)return new ge(this.data,this.offset+o).parseStruct(i)},ge.prototype.parsePointer32=function(i){let o=this.parseOffset32();if(o>0)return new ge(this.data,this.offset+o).parseStruct(i)},ge.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},ge.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.")},ge.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:ge.uShort,end:ge.uShort,classId:ge.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})},ge.list=function(i,o){return function(){return this.parseList(i,o)}},ge.list32=function(i,o){return function(){return this.parseList32(i,o)}},ge.recordList=function(i,o){return function(){return this.parseRecordList(i,o)}},ge.recordList32=function(i,o){return function(){return this.parseRecordList32(i,o)}},ge.pointer=function(i){return function(){return this.parsePointer(i)}},ge.pointer32=function(i){return function(){return this.parsePointer32(i)}},ge.tag=ge.prototype.parseTag,ge.byte=ge.prototype.parseByte,ge.uShort=ge.offset16=ge.prototype.parseUShort,ge.uShortList=ge.prototype.parseUShortList,ge.uInt24=ge.prototype.parseUInt24,ge.uLong=ge.offset32=ge.prototype.parseULong,ge.uLongList=ge.prototype.parseULongList,ge.fixed=ge.prototype.parseFixed,ge.f2Dot14=ge.prototype.parseF2Dot14,ge.struct=ge.prototype.parseStruct,ge.coverage=ge.prototype.parseCoverage,ge.classDef=ge.prototype.parseClassDef;var Vr={reserved:ge.uShort,reqFeatureIndex:ge.uShort,featureIndexes:ge.uShortList};ge.prototype.parseScriptList=function(){return this.parsePointer(ge.recordList({tag:ge.tag,script:ge.pointer({defaultLangSys:ge.pointer(Vr),langSysRecords:ge.recordList({tag:ge.tag,langSys:ge.pointer(Vr)})})}))||[]},ge.prototype.parseFeatureList=function(){return this.parsePointer(ge.recordList({tag:ge.tag,feature:ge.pointer({featureParams:ge.offset16,lookupListIndexes:ge.uShortList})}))||[]},ge.prototype.parseLookupList=function(i){return this.parsePointer(ge.list(ge.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(ge.pointer(i[o])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},ge.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:ge.offset32,featureTableSubstitutionOffset:ge.offset32})})||[]},ge.prototype.parseVariationStore=function(){let i=this.relativeOffset,o=this.parseUShort(),u={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=i+o+2,u},ge.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},ge.prototype.parseVariationRegionList=function(){let i=this.parseUShort(),o=this.parseUShort();return this.parseRecordList(o,{regionAxes:ge.recordList(i,{startCoord:ge.f2Dot14,peakCoord:ge.f2Dot14,endCoord:ge.f2Dot14})})},ge.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):[]}},ge.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&Lr.INNER_INDEX_BIT_COUNT_MASK)+1,g=((o&Lr.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}},ge.prototype.parseDeltaSets=function(i,o,u){let h=Array.from({length:i},()=>[]),f=o&Lr.LONG_WORDS,g=o&Lr.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},ge.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 J=D-I;_[M]=J?this.parseTupleVariationStore(g+I,i,o,u,M):void 0,I=D}return _},ge.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&Lr.SHARED_POINT_NUMBERS),I=A&Lr.COUNT_MASK,D=this.parseOffset16(),M=[],J=[];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),_&&(J=this.parsePackedPointNumbers());let X=this.relativeOffset;for(let he=0;he<I;he++){let Re=M[he];Re.privatePoints=[],this.relativeOffset=X,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 ut=this.offset,xr=this.relativeOffset,lr=Dr=>{let en,Pn,qn=()=>{let Yn=0;if(u==="gvar"){if(Yn=Re.privatePoints.length||J.length,!Yn){let Bs=h.get(f);Bs.path,Yn=Bs.points.length,Yn+=4}}else u==="cvar"&&(Yn=h.length);this.offset=ut,this.relativeOffset=xr,en=this.parsePackedDeltas(Yn),u==="gvar"&&(Pn=this.parsePackedDeltas(Yn))};return{configurable:!0,get:function(){return en===void 0&&qn(),Dr==="deltasY"?Pn:en},set:function(Yn){en===void 0&&qn(),Dr==="deltasY"?Pn=Yn:en=Yn}}};Object.defineProperty(Re,"deltas",lr.call(this,"deltas")),u==="gvar"&&Object.defineProperty(Re,"deltasY",lr.call(this,"deltasY")),X+=Re.variationDataSize,delete Re.variationDataSize}this.relativeOffset=g;let ve={headers:M};return ve.sharedPoints=J,ve},ge.prototype.parseTupleVariationHeader=function(i,o){let u=this.parseUShort(),h=this.parseUShort(),f=!!(h&Lr.EMBEDDED_PEAK_TUPLE),g=!!(h&Lr.INTERMEDIATE_REGION),A=!!(h&Lr.PRIVATE_POINT_NUMBERS),_=f?void 0:h&Lr.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,J={variationDataSize:u,peakTuple:I,intermediateStartTuple:D,intermediateEndTuple:M,flags:{embeddedPeakTuple:f,intermediateRegion:g,privatePointNumbers:A}};return o==="gvar"&&(J.sharedTupleRecordsIndex=_),J},ge.prototype.parsePackedPointNumbers=function(){let i=this.parseByte(),o=[],u=i;if(i>=128){let f=this.parseByte();u=(i&Lr.POINT_RUN_COUNT_MASK)<<8|f}let h=0;for(;o.length<u;){let f=this.parseByte(),g=!!(f&Lr.POINTS_ARE_WORDS),A=(f&Lr.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},ge.prototype.parsePackedDeltas=function(i){let o=[];for(;o.length<i;){let u=this.parseByte(),h=!!(u&Lr.DELTAS_ARE_ZERO),f=!!(u&Lr.DELTAS_ARE_WORDS),g=(u&Lr.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 it={getByte:er,getCard8:er,getUShort:et,getCard16:et,getShort:Ct,getUInt24:Nt,getULong:gt,getFixed:It,getTag:yt,getOffset:pr,getBytes:nr,bytesToString:Cr,Parser:ge},dt=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],sr={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"},xn={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},an={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 Me(i,o,u){switch(i){case 0:if(o===65535)return"und";if(u)return u[o];break;case 1:return sr[o];case 3:return an[o]}}var nt="utf-16",wt={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"},Rr={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 rn(i,o,u){switch(i){case 0:return nt;case 1:return Rr[u]||wt[o];case 3:if(o===1||o===10)return nt;break}}var Ir={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function ne(i){return Ir[i]}function ht(i,o,u){let h={},f=new it.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(),J=f.parseUShort(),X=f.parseUShort(),ve=dt[X]||X,he=f.parseUShort(),Re=f.parseUShort(),ut=Me(D,J,u),xr=rn(D,M,J),lr=ne(D);if(xr!==void 0&&ut!==void 0&&lr!==void 0){let Dr;if(xr===nt?Dr=Te.UTF16(i,_+Re,he):Dr=Te.MACSTRING(i,_+Re,he,xr),Dr){let en=h[lr];en===void 0&&(en=h[lr]={});let Pn=en[ve];Pn===void 0&&(Pn=en[ve]={}),Pn[ut]=Dr}}}return g===1&&f.parseUShort(),h}function Ht(i){let o={};for(let u in i)o[i[u]]=parseInt(u);return o}function Ot(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 Tr(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 mr(i,o){let u=Tr(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 Hr(i,o){let u=Ht(Ir),h=Ht(sr),f=Ht(an),g=[],A=[];for(let I in i){let D,M=[],J={},X=Ht(dt),ve=u[I];for(let he in i[I]){let Re=X[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.');J[D]=i[I][he],M.push(D)}for(let he=0;he<M.length;he++){D=M[he];let Re=J[D];for(let ut in Re){let xr=Re[ut];if(ve===1||ve===0){let lr=h[ut],Dr=xn[lr],en=rn(ve,Dr,lr),Pn=H.MACSTRING(xr,en);if(ve===0&&(lr=o.indexOf(ut),lr<0&&(lr=o.length,o.push(ut)),Dr=4,Pn=H.UTF16(xr)),Pn!==void 0){let qn=mr(Pn,A);g.push(Ot(ve,Dr,lr,D,Pn.length,qn))}}if(ve===3){let lr=f[ut];if(lr!==void 0){let Dr=H.UTF16(xr),en=mr(Dr,A);g.push(Ot(3,1,lr,D,Dr.length,en))}}}}}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 _n(i,o,u=[]){if(o<256&&o in dt){if(u.length&&!u.includes(parseInt(o)))return;o=dt[o]}for(let h in i)for(let f in i[h])if(f===o||parseInt(f)===o)return i[h][f]}var dr={parse:ht,make:Hr,getNameByID:_n};function bn(i,o,u,h){i.length=o.parseUShort(),i.language=o.parseUShort()-1;let f=o.parseByteList(i.length),g=Object.assign({},f),A=rn(u,h,i.language),_=Ze[A];for(let I=0;I<_.length;I++)g[_.charCodeAt(I)]=f[128+I];i.glyphIndexMap=g}function hn(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 Tn(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 it.Parser(u,h+f+14),_=new it.Parser(u,h+f+16+g*2),I=new it.Parser(u,h+f+16+g*4),D=new it.Parser(u,h+f+16+g*6),M=h+f+16+g*8;for(let J=0;J<g-1;J+=1){let X,ve=A.parseUShort(),he=_.parseUShort(),Re=I.parseShort(),ut=D.parseUShort();for(let xr=he;xr<=ve;xr+=1)ut!==0?(M=D.offset+D.relativeOffset-2,M+=ut,M+=(xr-he)*2,X=it.getUShort(u,M),X!==0&&(X=X+Re&65535)):X=xr+Re&65535,i.glyphIndexMap[xr]=X}}function ir(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={},J=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let X=0;X<J.length;X+=1)M[J[X].unicodeValue]=J[X];return M}})),u[g]=A,o.relativeOffset=D}i.varSelectorList=u}function pn(i,o){let u={};u.version=it.getUShort(i,o),ue.argument(u.version===0,"cmap table version should be 0."),u.numTables=it.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 J=u.numTables-1;J>=0;J-=1)if(A=it.getUShort(i,o+4+J*8),_=it.getUShort(i,o+4+J*8+2),A===3&&D.includes(_)||A===0&&I.includes(_)||A===1&&_===0){if(g>0)continue;if(g=it.getULong(i,o+4+J*8+4),h)break}else if(A===0&&_===5){if(f=it.getULong(i,o+4+J*8+4),h=new it.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 it.Parser(i,o+g);if(u.format=M.parseUShort(),u.format===0)bn(u,M,A,_);else if(u.format===12||u.format===13)hn(u,M,u.format);else if(u.format===4)Tn(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&&ir(u,h),u}function Pr(i,o,u){i.segments.push({end:o,start:o,delta:-(o-u),offset:0,glyphIndex:u})}function qr(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function Wr(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 fs(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 ve=i.get(u);for(let he=0;he<ve.unicodes.length;he+=1)Pr(f,ve.unicodes[he],u)}f.segments.sort(function(ve,he){return ve.start-he.start}),f.segments=Wr(f.segments),qr(f);let g=f.segments.length,A=0,_=[],I=[],D=[],M=[],J=[],X=[];for(u=0;u<g;u+=1){let ve=f.segments[u];ve.end<=65535&&ve.start<=65535?(_.push({name:"end_"+u,type:"USHORT",value:ve.end}),I.push({name:"start_"+u,type:"USHORT",value:ve.start}),D.push({name:"idDelta_"+u,type:"SHORT",value:ve.delta}),M.push({name:"idRangeOffset_"+u,type:"USHORT",value:ve.offset}),ve.glyphId!==void 0&&J.push({name:"glyph_"+u,type:"USHORT",value:ve.glyphId})):A+=1,!o&&ve.glyphIndex!==void 0&&(X.push({name:"cmap12Start_"+u,type:"ULONG",value:ve.start}),X.push({name:"cmap12End_"+u,type:"ULONG",value:ve.end}),X.push({name:"cmap12Glyph_"+u,type:"ULONG",value:ve.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 ve=0;ve<_.length;ve++)f.fields.push(_[ve]);f.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let ve=0;ve<I.length;ve++)f.fields.push(I[ve]);for(let ve=0;ve<D.length;ve++)f.fields.push(D[ve]);for(let ve=0;ve<M.length;ve++)f.fields.push(M[ve]);for(let ve=0;ve<J.length;ve++)f.fields.push(J[ve]);if(f.cmap4Length=14+_.length*2+2+I.length*2+D.length*2+M.length*2+J.length*2,!o){let ve=16+X.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:ve},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:X.length/3});for(let he=0;he<X.length;he++)f.fields.push(X[he])}return f}var Br={parse:pn,make:fs},Mn=[".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"],Sr=[".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"],Kr=[".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"],nn=[".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"],Fr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Or=[".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 Xr(i){this.font=i}Xr.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 fn(i){this.cmap=i}fn.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function K(i,o){this.encoding=i,this.charset=o}K.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.encoding[o];return this.charset.indexOf(u)};function Ue(i){switch(i.version){case 1:this.names=Or.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)i.glyphNameIndex[o]<Or.length?this.names[o]=Or[i.glyphNameIndex[o]]:this.names[o]=i.names[i.glyphNameIndex[o]-Or.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)this.names[o]=Or[o+i.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}Ue.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},Ue.prototype.glyphIndexToName=function(i){return this.names[i]};function Et(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 kt(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?kt(i):Et(i)}function Qr(i,o,u,h,f){i.beginPath(),i.moveTo(o,u),i.lineTo(h,f),i.stroke()}var cr={line:Qr};function Sn(i,o){let u=new ge(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 Zn(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 sn(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=Zn(f.colorRecords[g]);return h==="bgra"?A:un(A,h)}function on(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 $r(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 Wn(i){return parseInt(`0x${on(i.b)}${on(i.g)}${on(i.r)}${on(i.a*255)}`,16)}function Gn(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 Wn(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=un(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=$r({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 un(i,o)}function un(i,o="hexa"){if(i==="currentColor")return i;if(Number.isInteger(i)){if(o=="raw"||o=="cpal")return i;i=Zn(i)}else typeof i!="object"&&(i=Gn(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`#${on(i.r)}${on(i.g)}${on(i.b)}`;case"hexa":case"hex8":case"hex-8":return`#${on(i.r)}${on(i.g)}${on(i.b)}${on(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 Wn(i);default:throw new Error("Unknown color format: "+o)}}var Kn={parse:Sn,make:Ls,getPaletteColor:sn,parseColor:Gn,formatColor:un};function kr(i,o){let u=o||new He;return{configurable:!0,get:function(){return typeof u=="function"&&(u=u()),u},set:function(h){u=h}}}function Er(i){this.bindConstructorValues(i)}Er.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))},Er.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},Er.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Er.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 J=new He;if(h.drawSVG){let X=this.getSvgImage(f);if(X){let ve=new He;return ve._image={image:X.image,x:i+X.leftSideBearing*D,y:o-X.baseline*D,width:X.image.width*D,height:X.image.height*D},J._layers=[ve],J}}if(h.drawLayers){let X=this.getLayers(f);if(X&&X.length){J._layers=[];for(let ve=0;ve<X.length;ve+=1){let he=X[ve],Re=sn(f,he.paletteIndex,h.usePalette);Re==="currentColor"?Re=h.fill||"black":Re=un(Re,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:Re}),J._layers.push(this.getPath.call(he.glyph,i,o,u,h,f))}return J}}J.fill=h.fill||this.path.fill,J.stroke=this.path.stroke,J.strokeWidth=this.path.strokeWidth*D;for(let X=0;X<g.length;X+=1){let ve=g[X];ve.type==="M"?J.moveTo(i+ve.x*_,o+-ve.y*I):ve.type==="L"?J.lineTo(i+ve.x*_,o+-ve.y*I):ve.type==="Q"?J.quadraticCurveTo(i+ve.x1*_,o+-ve.y1*I,i+ve.x*_,o+-ve.y*I):ve.type==="C"?J.curveTo(i+ve.x1*_,o+-ve.y1*I,i+ve.x2*_,o+-ve.y2*I,i+ve.x*_,o+-ve.y*I):ve.type==="Z"&&J.stroke&&J.strokeWidth&&J.closePath()}return J},Er.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)},Er.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)},Er.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},Er.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},Er.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)},Er.prototype.drawPoints=function(i,o,u,h,f,g){if(f=Object.assign({},g&&g.defaultRenderOptions,f),f.drawLayers){let J=this.getLayers(g);if(J&&J.length){for(let X=0;X<J.length;X+=1)J[X].glyph.index!==this.index&&this.drawPoints.call(J[X].glyph,i,o,u,h);return}}function A(J,X,ve,he){i.beginPath();for(let Re=0;Re<J.length;Re+=1)i.moveTo(X+J[Re].x*he,ve+J[Re].y*he),i.arc(X+J[Re].x*he,ve+J[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 J=0;J<M.length;J+=1){let X=M[J];X.x!==void 0&&I.push({x:X.x,y:-X.y}),X.x1!==void 0&&D.push({x:X.x1,y:-X.y1}),X.x2!==void 0&&D.push({x:X.x2,y:-X.y2})}i.fillStyle="blue",A(I,o,u,_),i.fillStyle="red",A(D,o,u,_)},Er.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)},Er.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)},Er.prototype.fromSVG=function(i,o={}){return this.path.fromSVG(i,o)},Er.prototype.toSVG=function(i,o){let u=this.toPathData.apply(this,[i,o]);return this.path.toSVG(i,u)},Er.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 gr=Er;function rs(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 $n(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&&($n.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)}}),$n.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]},$n.prototype.push=function(i,o){this.glyphs[i]=o,this.length++};function kn(i,o){return new gr({index:o,font:i})}function Ln(i,o,u,h,f,g){return function(){let A=new gr({index:o,font:i});return A.path=function(){u(A,h,f);let _=g(i.glyphs,A);return _.unitsPerEm=i.unitsPerEm,_},rs(A,"numberOfContours","_numberOfContours"),rs(A,"xMin","_xMin"),rs(A,"xMax","_xMax"),rs(A,"yMin","_yMin"),rs(A,"yMax","_yMax"),rs(A,"points","_points"),A}}function ps(i,o,u,h,f){return function(){let g=new gr({index:o,font:i});return g.path=function(){let A=u(i,g,h,f);return A.unitsPerEm=i.unitsPerEm,A},g}}var G={GlyphSet:$n,glyphLoader:kn,ttfGlyphLoader:Ln,cffGlyphLoader:ps};function Le(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(!Le(i[u],o[u]))return!1;return!0}else return!1}var Ke=10;function ct(i){let o;return i.length<1240?o=107:i.length<33900?o=1131:o=32768,o}function qe(i,o,u,h){let f=[],g=[],A=h>1?it.getULong(i,o):it.getCard16(i,o),_=h>1?4:2,I,D;if(A!==0){let M=it.getByte(i,o+_);I=o+(A+1)*M+_;let J=o+_+1;for(let X=0;X<A+1;X+=1)f.push(it.getOffset(i,J,M)),J+=M;D=I+f[A]}else D=o+_;for(let M=0;M<f.length-1;M+=1){let J=it.getBytes(i,I+f[M],I+f[M+1]);u&&(J=u(J,i,o,h)),g.push(J)}return{objects:g,startOffset:o,endOffset:D}}function At(i,o,u){let h=[],f=u>1?it.getULong(i,o):it.getCard16(i,o),g=u>1?4:2,A,_;if(f!==0){let I=it.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(it.getOffset(i,D,I)),D+=I;_=A+h[f]}else _=o+g;return{offsets:h,startOffset:o,endOffset:_}}function Rt(i,o,u,h,f,g){let A=g>1?it.getULong(u,h):it.getCard16(u,h),_=g>1?4:2,I=0;if(A!==0){let M=it.getByte(u,h+_);I=h+(A+1)*M+_}let D=it.getBytes(u,I+o[i],I+o[i+1]);return f&&(D=f(D)),D}function Bt(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 ot(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 Bt(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 Ft(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 hr(i,o,u,h){o=o!==void 0?o:0;let f=new it.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){ns(A);continue}g.push([I,A]),A=[]}else A.push(ot(f,I,h))}return Ft(g)}function Kt(i,o){return o<=390?o=Mn[o]:i?o=i[o-391]:o=void 0,o}function z(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=Kt(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=Kt(u,f)),h[A.name]=f}return h}function N(i,o){let u={};if(u.formatMajor=it.getCard8(i,o),u.formatMinor=it.getCard8(i,o+1),u.formatMajor>2)throw new Error(`Unsupported CFF table version ${u.formatMajor}.${u.formatMinor}`);return u.size=it.getCard8(i,o+2),u.formatMajor<2?(u.offsetSize=it.getCard8(i,o+3),u.startOffset=o,u.endOffset=o+4):(u.topDictLength=it.getCard16(i,o+3),u.endOffset=o+8),u}var $=[{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"}],ee=[{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"}],ie=[{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"}],ze=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function xt(i,o,u,h){let f=hr(i,o,i.byteLength,h);return z(f,h>1?ee:$,u)}function _t(i,o,u,h,f){let g=hr(i,o,u,f);return z(g,f>1?Qe:ie,h)}function Mr(i,o,u){let h=hr(i,o,void 0,u);return z(h,ze)}function Dt(i,o,u){let h=[];for(let f=0;f<u.length;f++){let g=new DataView(new Uint8Array(u[f]).buffer),A=Mr(g,0,2),_=A.private[0],I=A.private[1];if(_!==0&&I!==0){let D=_t(i,I+o,_,[],2);if(D.subrs){let M=I+D.subrs,J=qe(i,M+o,void 0,2);A._subrs=J.objects,A._subrsBias=ct(A._subrs)}A._privateDict=D}h.push(A)}return h}function Gr(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=xt(_,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 J=_t(i,M+o,D,h,f);if(I._defaultWidthX=J.defaultWidthX,I._nominalWidthX=J.nominalWidthX,J.subrs!==0){let X=M+J.subrs,ve=qe(i,X+o,void 0,f);I._subrs=ve.objects,I._subrsBias=ct(I._subrs)}I._privateDict=J}g.push(I)}return g}function dn(i,o,u,h,f){let g,A,_=new it.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(Kt(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(Kt(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(Kt(h,g)||g),g+=1}else throw new Error("Unknown charset format "+D);return I}function jn(i,o){let u,h={},f=new it.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 ns(i){let o=i.pop();for(;i.length>o;)i.pop()}function Un(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 fr(i,o,u,h,f){let g,A,_,I,D=new He,M=[],J=0,X=!1,ve=!1,he=0,Re=0,ut,xr,lr,Dr,en=0,Pn=[],qn,Yn=0,Bs=i.tables.cff2||i.tables.cff;if(lr=Bs.topDict._defaultWidthX,Dr=Bs.topDict._nominalWidthX,f=f||i.variation&&i.variation.get(),o.getBlendPath||(o.getBlendPath=function(rr){return fr(i,o,u,h,rr)}),i.isCIDFont||h>1){let rr=Bs.topDict._fdSelect?Bs.topDict._fdSelect[o.index]:0,ar=Bs.topDict._fdArray[rr];ut=ar._subrs,xr=ar._subrsBias,h>1?(Pn=Bs.topDict._vstore.itemVariationStore,en=ar._privateDict.vsindex):(lr=ar._defaultWidthX,Dr=ar._nominalWidthX)}else ut=Bs.topDict._subrs,xr=Bs.topDict._subrsBias;let Io=Un(i,D),tn=lr;function Qa(rr,ar){ve&&Io!==2&&D.closePath(),D.moveTo(rr,ar),ve=!0}function Xi(){let rr;rr=(M.length&1)!==0,rr&&!X&&(tn=M.shift()+Dr),J+=M.length>>1,M.length=0,X=!0}function br(rr){let ar,Qi,Zl,Z0,wc,Eo,Ji,ro,Pi,Pa,ea,ta,Ns=0;for(;Ns<rr.length;){let so=rr[Ns];switch(Ns+=1,so){case 1:Xi();break;case 3:Xi();break;case 4:M.length>1&&!X&&(tn=M.shift()+Dr,X=!0),Re+=M.pop(),Qa(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()+xr,Eo=ut[wc],Eo){if(Yn>=Ke){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Yn++,br(Eo),Yn--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(so=rr[Ns],Ns+=1,so){case 35:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),Ji=_+M.shift(),ro=I+M.shift(),Pi=Ji+M.shift(),Pa=ro+M.shift(),ea=Pi+M.shift(),ta=Pa+M.shift(),he=ea+M.shift(),Re=ta+M.shift(),M.shift(),D.curveTo(g,A,_,I,Ji,ro),D.curveTo(Pi,Pa,ea,ta,he,Re);break;case 34:g=he+M.shift(),A=Re,_=g+M.shift(),I=A+M.shift(),Ji=_+M.shift(),ro=I,Pi=Ji+M.shift(),Pa=I,ea=Pi+M.shift(),ta=Re,he=ea+M.shift(),D.curveTo(g,A,_,I,Ji,ro),D.curveTo(Pi,Pa,ea,ta,he,Re);break;case 36:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),Ji=_+M.shift(),ro=I,Pi=Ji+M.shift(),Pa=I,ea=Pi+M.shift(),ta=Pa+M.shift(),he=ea+M.shift(),D.curveTo(g,A,_,I,Ji,ro),D.curveTo(Pi,Pa,ea,ta,he,Re);break;case 37:g=he+M.shift(),A=Re+M.shift(),_=g+M.shift(),I=A+M.shift(),Ji=_+M.shift(),ro=I+M.shift(),Pi=Ji+M.shift(),Pa=ro+M.shift(),ea=Pi+M.shift(),ta=Pa+M.shift(),Math.abs(ea-he)>Math.abs(ta-Re)?he=ea+M.shift():Re=ta+M.shift(),D.curveTo(g,A,_,I,Ji,ro),D.curveTo(Pi,Pa,ea,ta,he,Re);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+so),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=Fr[M.pop()],ou=Fr[M.pop()],K0=M.pop(),X0=M.pop();if(Ac&&ou){o.isComposite=!0,o.components=[];let Kg=i.cffEncoding.charset.indexOf(Ac),Xg=i.cffEncoding.charset.indexOf(ou);o.components.push({glyphIndex:Xg,dx:0,dy:0}),o.components.push({glyphIndex:Kg,dx:X0,dy:K0}),D.extend(i.glyphs.get(Xg).path);let V8=i.glyphs.get(Kg),bp=JSON.parse(JSON.stringify(V8.path.commands));for(let yp=0;yp<bp.length;yp+=1){let qo=bp[yp];qo.type!=="Z"&&(qo.x+=X0,qo.y+=K0),(qo.type==="Q"||qo.type==="C")&&(qo.x1+=X0,qo.y1+=K0),qo.type==="C"&&(qo.x2+=X0,qo.y2+=K0)}D.extend(bp)}}else M.length>0&&!X&&(tn=M.shift()+Dr,X=!0);ve&&Io!==2&&(D.closePath(),ve=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}en=M.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}qn||(qn=i.variation&&f&&i.variation.process.getBlendVector(Pn,en,f));var Jn=M.pop(),ya=qn?qn.length:Pn.itemVariationSubtables[en].regionIndexes.length,no=Jn*ya,No=M.length-no,bl=No-Jn;if(qn)for(let Ac=0;Ac<Jn;Ac++){var Zg=M[bl+Ac];for(let ou=0;ou<ya;ou++)Zg+=qn[ou]*M[No++];M[bl+Ac]=Zg}for(;no--;)M.pop();break;case 18:Xi();break;case 19:case 20:Xi(),Ns+=J+7>>3;break;case 21:M.length>2&&!X&&(tn=M.shift()+Dr,X=!0),Re+=M.pop(),he+=M.pop(),Qa(he,Re);break;case 22:M.length>1&&!X&&(tn=M.shift()+Dr,X=!0),he+=M.pop(),Qa(he,Re);break;case 23:Xi();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=rr[Ns],Qi=rr[Ns+1],M.push((ar<<24|Qi<<16)>>16),Ns+=2;break;case 29:if(wc=M.pop()+i.gsubrsBias,Eo=i.gsubrs[wc],Eo){if(Yn>=Ke){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Yn++,br(Eo),Yn--}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:so<32?console.log("Glyph "+o.index+": unknown operator "+so):so<247?M.push(so-139):so<251?(ar=rr[Ns],Ns+=1,M.push((so-247)*256+ar+108)):so<255?(ar=rr[Ns],Ns+=1,M.push(-(so-251)*256-ar-108)):(ar=rr[Ns],Qi=rr[Ns+1],Zl=rr[Ns+2],Z0=rr[Ns+3],Ns+=4,M.push((ar<<24|Qi<<16|Zl<<8|Z0)/65536))}}}return br(u),i.variation&&f&&(D.commands=D.commands.map(rr=>{let ar=Object.keys(rr);for(let Qi=0;Qi<ar.length;Qi++){let Zl=ar[Qi];Zl!=="type"&&(rr[Zl]=Math.round(rr[Zl]))}return rr})),X&&(o.advanceWidth=tn),D}function Mt(i,o,u,h,f){let g=[],A,_=new it.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 J;for(let X=0;X<D;X++){if(A=I===4?_.parseUShort():_.parseCard8(),J=I===4?_.parseULong():_.parseCard16(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");if(J>u)throw new Error(`CFF Table CID Font FDSelect format ${f} range has bad GID ${J}`);for(;M<J;M++)g.push(A);M=J}if(J!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+J)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+I);return g}function Dn(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:qe(i,g.endOffset,it.bytesToString),_=g.formatMajor>1?null:qe(i,A.endOffset),I=g.formatMajor>1?null:qe(i,_.endOffset,it.bytesToString),D=qe(i,g.formatMajor>1?o+g.size+g.topDictLength:I.endOffset,void 0,g.formatMajor);u.gsubrs=D.objects,u.gsubrsBias=ct(u.gsubrs);let M;if(g.formatMajor>1){let X=o+g.size,ve=it.getBytes(i,X,X+g.topDictLength);M=Gr(i,0,[ve],void 0,g.formatMajor)[0]}else{let X=Gr(i,o,_.objects,I.objects,g.formatMajor);if(X.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+X.length);M=X[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 X=M.fdArray,ve=M.fdSelect;if(!X)throw new Error("This is a CFF2 font, but FDArray information is missing");let he=qe(i,o+X,null,g.formatMajor),Re=Dt(i,o,he.objects);M._fdArray=Re,ve&&(M._fdSelect=Mt(i,o+ve,u.numGlyphs,Re.length,g.formatMajor))}else if(u.isCIDFont){let X=M.fdArray,ve=M.fdSelect;if(X===0||ve===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");X+=o;let he=qe(i,X),Re=Gr(i,o,he.objects,I.objects,g.formatMajor);M._fdArray=Re,ve+=o,M._fdSelect=Mt(i,ve,u.numGlyphs,Re.length,g.formatMajor)}if(g.formatMajor<2){let X=o+M.private[1],ve=_t(i,X,M.private[0],I.objects,g.formatMajor);if(u.defaultWidthX=ve.defaultWidthX,u.nominalWidthX=ve.nominalWidthX,ve.subrs!==0){let he=X+ve.subrs,Re=qe(i,he);u.subrs=Re.objects,u.subrsBias=ct(u.subrs)}else u.subrs=[],u.subrsBias=0}let J;if(h.lowMemory?(J=At(i,o+M.charStrings,g.formatMajor),u.nGlyphs=J.offsets.length-(g.formatMajor>1?1:0)):(J=qe(i,o+M.charStrings,null,g.formatMajor),u.nGlyphs=J.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 X=[],ve=[];M.charset===0?X=Sr:M.charset===1?X=Kr:M.charset===2?X=nn:X=dn(i,o+M.charset,u.nGlyphs,I.objects,u.isCIDFont),M.encoding===0?ve=Fr:M.encoding===1?ve=ks:ve=jn(i,o+M.encoding),u.cffEncoding=new K(ve,X),u.encoding=u.encoding||u.cffEncoding}if(u.glyphs=new G.GlyphSet(u),h.lowMemory)u._push=function(X){let ve=Rt(X,J.offsets,i,o+M.charStrings,void 0,g.formatMajor);u.glyphs.push(X,G.cffGlyphLoader(u,X,fr,ve,g.formatMajor))};else for(let X=0;X<u.nGlyphs;X+=1){let ve=J.objects[X];u.glyphs.push(X,G.cffGlyphLoader(u,X,fr,ve,g.formatMajor))}if(M.vstore){let X=new it.Parser(i,o+M.vstore);M._vstore=X.parseVariationStore()}}function Vn(i,o){let u,h=Mn.indexOf(i);return h>=0&&(u=h),h=o.indexOf(i),h>=0?u=h+Mn.length:(u=Mn.length+o.length,o.push(i)),u}function Ha(){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 Bn(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 ss(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&&!Le(A,g.value)&&(g.type==="SID"&&(A=Vn(A,u)),h[g.op]={name:g.name,type:g.type,value:A})}return h}function $i(i,o,u){let h=new De.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=ss(u>1?ee:$,i,o),h}function ua(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 Wa(){return new De.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function wo(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=Vn(f,o);u.fields.push({name:"glyph_"+h,type:"SID",value:g})}return u}function zn(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,J=2/3;D={type:"C",x:D.x,y:D.y,x1:Math.round(M*f+J*D.x1),y1:Math.round(M*g+J*D.y1),x2:Math.round(M*D.x+J*D.x1),y2:Math.round(M*D.y+J*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),J=Math.round(D.y1-g),X=Math.round(D.x2-D.x1),ve=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:J}),u.push({name:"dx2",type:"NUMBER",value:X}),u.push({name:"dy2",type:"NUMBER",value:ve}),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 da(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=zn(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=ss(u>1?Qe:ie,i,o),h}function La(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 X=1;X<i.length;X+=1)I=i.get(X),_.push(I.name);let D=[];u.header=Ha(),u.nameIndex=Bn([o.postScriptName]);let M=$i(f,D);u.topDictIndex=ua(M),u.globalSubrIndex=Wa(),u.charsets=wo(_,D),u.charStringsIndex=da(i,1),u.privateDict=ms(A,D),u.stringIndex=bs(D);let J=u.header.sizeOf()+u.nameIndex.sizeOf()+u.topDictIndex.sizeOf()+u.stringIndex.sizeOf()+u.globalSubrIndex.sizeOf();return f.charset=J,f.encoding=0,f.charStrings=f.charset+u.charsets.sizeOf(),f.private[1]=f.charStrings+u.charStringsIndex.sizeOf(),M=$i(f,D),u.topDictIndex=ua(M),u}var is={parse:Dn,make:La};function Ga(i,o){let u={},h=new it.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 Ks(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 Xs={parse:Ga,make:Ks};function Hs(i,o){let u={},h=new it.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 Va(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:Va};function ha(i,o,u,h,f){let g,A,_=new it.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 it.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 qa(i,o,u,h,f,g,A){A.lowMemory?dl(i,o,u,h,f):ha(o,u,h,f,g)}function as(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 Rs={parse:qa,make:as};function Ui(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 gi(i,o){let u=new it.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 xi={make:Ui,parse:gi};function hl(i,o){let u={},h=new it.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 Js(i){return new De.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}var Uo={parse:hl,make:Js},fa=[{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<fa.length;o+=1){let u=fa[o];if(i>=u.begin&&i<u.end)return o}return-1}function pl(i,o){let u={},h=new it.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 os(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 Ms={parse:pl,make:os,unicodeRanges:fa,getUnicodeRange:fl};function Ni(i,o){let u={},h=new it.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=Or.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]>=Or.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 jl={parse:Ni,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(ge.coverage),deltaGlyphId:this.parseShort()};if(o===2)return{substFormat:2,coverage:this.parsePointer(ge.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(ge.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(ge.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(ge.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ia={sequenceIndex:ge.uShort,lookupListIndex:ge.uShort};Es[5]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:o,coverage:this.parsePointer(ge.coverage),ruleSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{input:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,Ia)}})};if(o===2)return{substFormat:o,coverage:this.parsePointer(ge.coverage),classDef:this.parsePointer(ge.classDef),classSets:this.parseListOfLists(function(){let u=this.parseUShort(),h=this.parseUShort();return{classes:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(h,Ia)}})};if(o===3){let u=this.parseUShort(),h=this.parseUShort();return{substFormat:o,coverages:this.parseList(u,ge.pointer(ge.coverage)),lookupRecords:this.parseRecordList(h,Ia)}}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(ge.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ia)}})};if(o===2)return{substFormat:2,coverage:this.parsePointer(ge.coverage),backtrackClassDef:this.parsePointer(ge.classDef),inputClassDef:this.parsePointer(ge.classDef),lookaheadClassDef:this.parsePointer(ge.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ia)}})};if(o===3)return{substFormat:3,backtrackCoverage:this.parseList(ge.pointer(ge.coverage)),inputCoverage:this.parseList(ge.pointer(ge.coverage)),lookaheadCoverage:this.parseList(ge.pointer(ge.coverage)),lookupRecords:this.parseRecordList(Ia)};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 ge(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(ge.coverage),backtrackCoverage:this.parseList(ge.pointer(ge.coverage)),lookaheadCoverage:this.parseList(ge.pointer(ge.coverage)),substitutes:this.parseUShortList()}};function ml(i,o){o=o||0;let u=new ge(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 Xn=new Array(9);Xn[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.")},Xn[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))})))},Xn[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))})))},Xn[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)))}))})))},Xn[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.")},Xn[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 zi(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,Xn)}])}var Ri={parse:ml,make:zi};function Hi(i,o){let u=new it.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=Te.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:Hi,make:gs};function Dl(i,o){let u=new ge(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:ge.uShort,firstLayerIndex:ge.uShort,numLayers:ge.uShort});u.relativeOffset=A;let D=u.parseRecordList(_,{glyphID:ge.uShort,paletteIndex:ge.uShort});return{version:h,baseGlyphRecords:I,layerRecords:D}}function Wi({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 Gi={parse:Dl,make:Wi};function ln(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 pa(i,o,u){let h={},f=new it.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=_n(u,g),h}function Vi(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 Ea(i,o,u,h,f){let g={},A=new it.Parser(i,o),_=A.parseUShort();g.subfamilyNameID=_,g.name=_n(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?_n(h,I,[6]):"",g}function Mi(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(ln(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(Vi(f,i.instances[f],i.axes,h));return u}function ji(i,o,u){let h=new it.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 ve=0;ve<A;ve++)M.push(pa(i,o+g+ve*_,u));let J=[],X=o+g+A*_;for(let ve=0;ve<I;ve++)J.push(Ea(i,X+ve*D,M,u,D));return{axes:M,instances:J}}var ei={make:Mi,parse:ji},ws={tag:ge.tag,nameID:ge.uShort,ordering:ge.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 Di(){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 Na(i,o,u){o||(o=0);let h=new it.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(),J=h.parseOffset32(),X=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 ve=[];for(let ut=0;ut<I;ut++)h.offset=o+D,h.relativeOffset=ut*_,ve.push(h.parseStruct(ws));h.offset=o,h.relativeOffset=J;let he=h.parseUShortList(M),Re=[];for(let ut=0;ut<M;ut++)h.offset=o+J,h.relativeOffset=he[ut],Re.push(Di.apply(h));return{version:A,axes:ve,values:Re,elidedFallbackNameID:X}}var ti=new Array(5);ti[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}]},ti[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}]},ti[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}]},ti[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 Ya(i,o){let u=o.format,h=ti[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 Za(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=Ya(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:Za,parse:Na};function Ka(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 Bl(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=Ka(`${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=Bl(h,i.axisSegmentMaps[h]);u.fields=u.fields.concat(f.fields)}return u}function Ao(i,o,u){o||(o=0);let h=new ge(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 J=0;J<M;J++){let X=h.parseF2Dot14(),ve=h.parseF2Dot14();D.push({fromCoordinate:X,toCoordinate:ve})}_.push({axisValueMaps:D})}return{version:[f,g],axisSegmentMaps:_}}var ma={make:Ho,parse:Ao};function Ra(i,o,u,h){let f=new it.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 ga={make:Wo,parse:Ra};function ls(i,o,u,h){let f=new it.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 qi={make:Go,parse:ls};function gl(i,o){let u={},h=new it.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 ge(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(),J=g+f.parseOffset32(),X=f.parseULong(),ve=_.get(J);ve===void 0&&(ve=new Uint8Array(h,J,X),_.set(J,ve));for(let he=D;he<=M;he++)u.set(he,ve)}return u}function Q(i){let o=Array.from(i.keys()).sort(),u=[],h=[],f=new Map,g=0,A={endGlyphID:null};for(let X=0,ve=o.length;X<ve;X++){let he=o[X],Re=i.get(he),ut=f.get(Re);ut===void 0&&(ut=g,h.push(Re),f.set(Re,ut),g+=Re.byteLength),he-1===A.endGlyphID&&ut===A.svgDocOffset?A.endGlyphID=he:(A={startGlyphID:he,endGlyphID:he,svgDocOffset:ut,svgDocLength:Re.byteLength},u.push(A))}let _=u.length,I=h.length,D=2+_*12,M=new Array(4+_*4+I),J=0;M[J++]={name:"version",type:"USHORT",value:0},M[J++]={name:"svgDocumentListOffset",type:"ULONG",value:10},M[J++]={name:"reserved",type:"ULONG",value:0},M[J++]={name:"numEntries",type:"USHORT",value:_};for(let X=0;X<_;X++){let ve="documentRecord_"+X,{startGlyphID:he,endGlyphID:Re,svgDocOffset:ut,svgDocLength:xr}=u[X];M[J++]={name:ve+"_startGlyphID",type:"USHORT",value:he},M[J++]={name:ve+"_endGlyphID",type:"USHORT",value:Re},M[J++]={name:ve+"_svgDocOffset",type:"ULONG",value:D+ut},M[J++]={name:ve+"_svgDocLength",type:"ULONG",value:xr}}for(let X=0;X<I;X++)M[J++]={name:"svgDoc_"+X,type:"LITERAL",value:h[X]};return new De.Table("SVG ",M)}var O={make:Q,parse:j};function fe(i){return Math.log(i)/Math.log(2)|0}function we(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 Pe(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,fe(o.numTables));o.searchRange=16*u,o.entrySelector=fe(u),o.rangeShift=o.numTables*16-o.searchRange;let h=[],f=[],g=o.sizeOf()+Pe().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=Pe(_.tableName,we(_.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 ft(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 Jt(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,J=0,X=0,ve=0;for(let Jn=0;Jn<i.glyphs.length;Jn+=1){let ya=i.glyphs.get(Jn),no=ya.unicode|0;if(isNaN(ya.advanceWidth))throw new Error("Glyph "+ya.name+" ("+Jn+"): advanceWidth is not a number.");(I>no||I===void 0)&&no>0&&(I=no),D<no&&(D=no);let No=Ms.getUnicodeRange(no);if(No<32)M|=1<<No;else if(No<64)J|=1<<No-32;else if(No<96)X|=1<<No-64;else if(No<123)ve|=1<<No-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(ya.name===".notdef")continue;let bl=ya.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(ya.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:Jt(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 ut=Xs.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}),xr=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),Dr=Ms.make(Object.assign({xAvgCharWidth:Math.round(he.advanceWidthAvg),usFirstCharIndex:I,usLastCharIndex:D,ulUnicodeRange1:M,ulUnicodeRange2:J,ulUnicodeRange3:X,ulUnicodeRange4:ve,sTypoAscender:he.ascender,sTypoDescender:he.descender,sTypoLineGap:0,usWinAscent:he.yMax,usWinDescent:Math.abs(he.yMin),ulCodePageRange1:1,sxHeight:ft(i,"xyvw",{yMax:Math.round(he.ascender/2)}).yMax,sCapHeight:ft(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",he).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0},i.tables.os2)),en=Rs.make(i.glyphs),Pn=Br.make(i.glyphs),qn=i.getEnglishName("fontFamily"),Yn=i.getEnglishName("fontSubfamily"),Bs=qn+" "+Yn,Io=i.getEnglishName("postScriptName");Io||(Io=qn.replace(/\s/g,"")+"-"+Yn);let tn={};for(let Jn in i.names)tn[Jn]=i.names[Jn];tn.unicode=tn.unicode||{},tn.macintosh=tn.macintosh||{},tn.windows=tn.windows||{};let Qa=i.names.unicode||{},Xi=i.names.macintosh||{},br=i.names.windows||{};for(let Jn in tn){if(tn[Jn]=tn[Jn]||{},!tn[Jn].uniqueID){let ya=i.getEnglishName("manufacturer")||"";tn[Jn].uniqueID={en:`${ya}: ${Bs}`}}tn[Jn].postScriptName||(tn[Jn].postScriptName={en:Io})}tn.unicode.preferredFamily||(tn.unicode.preferredFamily=Qa.fontFamily||Xi.fontFamily||br.fontFamily),tn.macintosh.preferredFamily||(tn.macintosh.preferredFamily=Xi.fontFamily||Qa.fontFamily||br.fontFamily),tn.windows.preferredFamily||(tn.windows.preferredFamily=br.fontFamily||Qa.fontFamily||Xi.fontFamily),tn.unicode.preferredSubfamily||(tn.unicode.preferredSubfamily=Qa.fontSubfamily||Xi.fontSubfamily||br.fontSubfamily),tn.macintosh.preferredSubfamily||(tn.macintosh.preferredSubfamily=Xi.fontSubfamily||Qa.fontSubfamily||br.fontSubfamily),tn.windows.preferredSubfamily||(tn.windows.preferredSubfamily=br.fontSubfamily||Qa.fontSubfamily||Xi.fontSubfamily);let rr=[],ar=dr.make(tn,rr),Qi=rr.length>0?xi.make(rr):void 0,Zl=jl.make(i),Z0=is.make(i.glyphs,{version:i.getEnglishName("version"),fullName:Bs,familyName:qn,weightName:Yn,postScriptName:Io,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,Eo=[ut,xr,lr,Dr,ar,Pn,Zl,Z0,en];Qi&&Eo.push(Qi);let Ji={gsub:Ri,cpal:Kn,colr:Gi,stat:As,avar:ma,cvar:ga,fvar:ei,gvar:qi,gasp:T,svg:O},ro={avar:[i.tables.fvar],fvar:[i.names]};for(let Jn in Ji){let ya=i.tables[Jn];if(ya){let no=Ji[Jn].make.call(i,ya,...ro[Jn]||[]);no&&Eo.push(no)}}wc&&Eo.push(wc);let Pi=Xe(Eo),Pa=Pi.encode(),ea=we(Pa),ta=Pi.fields,Ns=!1;for(let Jn=0;Jn<ta.length;Jn+=1)if(ta[Jn].name==="head table"){ta[Jn].value.checkSumAdjustment=2981146554-ea,Ns=!0;break}if(!Ns)throw new Error("Could not find head table with checkSum to adjust.");return Pi}var Ur={make:Xe,fontToTable:or,computeCheckSum:we};function Jr(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 Qn(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 vr(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 yn(i,o){this.font=i,this.tableName=o}yn.prototype={searchTag:Jr,binSearch:Qn,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=Jr(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=Jr(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=vr(i.ranges,o);return u?u.classId:0}}},getCoverageIndex:function(i,o){switch(i.format){case 1:{let u=Qn(i.glyphs,o);return u>=0?u:-1}case 2:{let u=vr(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 cs=yn;function js(i){cs.call(this,i,"gpos")}js.prototype=cs.prototype,js.prototype.init=function(){let i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},js.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},js.prototype.getKerningTables=function(i,o){if(this.font.tables.gpos)return this.getLookupTables(i,o,"kern",2)};var pc=js;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 Yi(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 To(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 bi(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 So(i){return i[0]===31&&i[1]===139&&i[2]===8}function Jc(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 yi(i){return{x:i.x,y:i.y,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour}}function O0(i){return{glyphIndex:i.glyphIndex,xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:i.dx,dy:i.dy}}function vi(i){cs.call(this,i,"gsub")}function td(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}vi.prototype=cs.prototype,vi.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},vi.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 J=I.deltaGlyphId;for(M=0;M<D.length;M++){let X=D[M];h.push({sub:X,by:X+J})}}else{let J=I.substitute;for(M=0;M<D.length;M++)h.push({sub:D[M],by:J[M]})}}}return h},vi.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 J=D[M],X=I.sequences[M];h.push({sub:J,by:X})}}}return h},vi.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 J=0;J<D.length;J++)h.push({sub:D[J],by:M[J]})}}return h},vi.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 J=0;J<D.length;J++){let X=D[J],ve=M[J];for(let he=0;he<ve.length;he++){let Re=ve[he];h.push({sub:[X].concat(Re.components),by:Re.ligGlyph})}}}}return h},vi.prototype.addSingle=function(i,o,u,h){let f=this.getLookupTables(u,h,i,1,!0)[0],g=td(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},vi.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=td(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},vi.prototype.addAlternate=function(i,o,u,h){let f=this.getLookupTables(u,h,i,3,!0)[0],g=td(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},vi.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 J=0;J<M.length;J++)if(Vs(M[J].components,_))return;M.push(I)}else D=-1-D,g.coverage.glyphs.splice(D,0,A),g.ligatureSets.splice(D,0,[I])},vi.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)}},vi.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 Xa=vi,xa=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(un(u.colorRecords[A],i||"hexa"));o.push(g)}return o}toCPALcolor(i){return Array.isArray(i)?i.map(o=>Gn(o,"raw")):Gn(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 sn(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 J=0;J<h.length;J++)if(o>i&&o<=i+h[J].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)}},Ql=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=Yi(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=To(u.baseGlyphRecords,"glyphID",i);if(h===-1){let I={glyphID:i,firstLayerIndex:u.layerRecords.length,numLayers:0};h=bi(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+=_)}}},eu=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=ip(u),this.cache.set(u,h));let f=h.images.get(i);return f===void 0&&(f=ap(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 ip(i){return{template:op(i).then(tu),images:new Map}}function ap(i,o,u){return{promise:o.then(h=>{let f;typeof h=="string"?f=h:(h[4]=u,f=h.join(""));let g=F0(f,i.unitsPerEm);return g.image.decode().then(()=>g)}),image:void 0}}var op=typeof DecompressionStream=="function"?rd:lp;function lp(i){try{return Promise.resolve(new TextDecoder().decode(So(i)?Jc(i):i))}catch(o){return Promise.reject(o)}}function rd(i){if(So(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 tu(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 F0(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,J=(h.y-D.y)*_,X=D.width*A,ve=D.height*_;u.setAttribute("viewBox",[D.x,D.y,D.width,D.height].join(" ")),A!==1&&u.setAttribute("width",X),_!==1&&u.setAttribute("height",ve);let he=new Image(X,ve);return he.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u.outerHTML),{leftSideBearing:M,baseline:J,image:he}}var Ma=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 it.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 X=0;X<_;X+=1)g=f[X],D={},D.onCurve=!!(g&1),D.lastPointOfContour=A.indexOf(X)>=0,I.push(D);let M=0;for(let X=0;X<_;X+=1)g=f[X],D=I[X],D.x=Vo(h,g,M,2,16),M=D.x;let J=0;for(let X=0;X<_;X+=1)g=f[X],D=I[X],D.y=Vo(h,g,J,4,32),J=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 ru(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 nu(i){let o=new He;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 nd(i,o){if(o.isComposite){Ma.has(i)||Ma.set(i,new Set);let u=Ma.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=ru(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=ru([I],D)[0],D.dx=_.x-I.x,D.dy=_.y-I.y,A=ru(g.points,D)}o.points=o.points.concat(A)}}}finally{u.delete(o.index)}}return nu(o.points)}function $0(i,o,u,h){let f=new G.GlyphSet(h);for(let g=0;g<u.length-1;g+=1){let A=u[g],_=u[g+1];A!==_?f.push(g,G.ttfGlyphLoader(h,g,mc,i,o+A,nd)):f.push(g,G.glyphLoader(h,g))}return f}function U0(i,o,u,h){let f=new G.GlyphSet(h);return h._push=function(g){let A=u[g],_=u[g+1];A!==_?f.push(g,G.ttfGlyphLoader(h,g,mc,i,o+A,nd)):f.push(g,G.glyphLoader(h,g))},f}function z0(i,o,u,h,f){return f.lowMemory?U0(i,o,u,h):$0(i,o,u,h)}var Pl={getPath:nu,parse:z0},Ja=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],J=f[h][D],X=g[u][D],ve=g[h][D];if(M!==J||X===ve){let he=M===J?0:(ve-X)/(J-M);for(let Re=i;Re<=o;Re++){let ut=f[Re][D];ut<=M?ut+=X-M:ut>=J?ut+=ve-J:ut=X+(ut-M)*he,g[Re][D]=ut}}}}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=O0(I),J=h.indexOf(_);J>-1&&(M.dx+=Math.round(f.deltas[J]*g),M.dy+=Math.round(f.deltasY[J]*g));let X=ru(this.getTransform(D,u).points,M);o.splice(A,X.length,...X),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(yi):h==="cvar"&&(D=[...o]);for(let M=0;M<A.length;M++){let J=A[M],X=1;for(let he=0;he<I;he++){let Re=[0];switch(h){case"gvar":Re=J.peakTuple?J.peakTuple:this.gvar().sharedTuples[J.sharedTupleRecordsIndex];break;case"cvar":Re=J.peakTuple;break}if(Re[he]!==0){if(g[he]===0){X=0;break}if(J.intermediateStartTuple)if(g[he]<J.intermediateStartTuple[he]||g[he]>J.intermediateEndTuple[he]){X=0;break}else g[he]<Re[he]?X=X*(g[he]-J.intermediateStartTuple[he]+Number.EPSILON)/(Re[he]-J.intermediateStartTuple[he]+Number.EPSILON):X=X*(J.intermediateEndTuple[he]-g[he]+Number.EPSILON)/(J.intermediateEndTuple[he]-Re[he]+Number.EPSILON);else{if(g[he]<Math.min(0,Re[he])||g[he]>Math.max(0,Re[he])){X=0;break}X=(X*g[he]+Number.EPSILON)/(Re[he]+Number.EPSILON)}}}if(X===0)continue;let ve=J.privatePoints.length?J.privatePoints:_;if(h==="gvar"&&f.glyph&&f.glyph.isComposite)this.transformComponents(f.glyph,D,u,ve,J,X);else if(ve.length===0)for(let he=0;he<D.length;he++){let Re=D[he];h==="gvar"?D[he]={x:Math.round(Re.x+J.deltas[he]*X),y:Math.round(Re.y+J.deltasY[he]*X),onCurve:Re.onCurve,lastPointOfContour:Re.lastPointOfContour}:h==="cvar"&&(D[he]=Math.round(Re+J.deltas[he]*X))}else{let he;h==="gvar"?he=D.map(yi):h==="cvar"&&(he=D);let Re=Array(o.length).fill(!1);for(let ut=0;ut<ve.length;ut++){let xr=ve[ut];if(xr<o.length){let lr=he[xr];h==="gvar"?(Re[xr]=!0,lr.x+=J.deltas[ut]*X,lr.y+=J.deltasY[ut]*X):h==="cvar"&&(D[xr]=Math.round(lr+J.deltas[ut]*X))}}if(h==="gvar"){this.interpolatePoints(he,D,Re);for(let ut=0;ut<o.length;ut++){let xr=he[ut].x-D[ut].x,lr=he[ut].y-D[ut].y;D[ut].x=Math.round(D[ut].x+xr),D[ut].y=Math.round(D[ut].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 gr(Object.assign({},i,{points:_,path:nu(_)}))}}else if(u){let g=i.getBlendPath(o);f=new gr(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 J=D[M],X;J.startCoord>J.peakCoord||J.peakCoord>J.endCoord||J.startCoord<0&&J.endCoord>0&&J.peakCoord!==0||J.peakCoord===0?X=1:f[M]<J.startCoord||f[M]>J.endCoord?X=0:f[M]===J.peakCoord?X=1:f[M]<J.peakCoord?X=(f[M]-J.startCoord+Number.EPSILON)/(J.peakCoord-J.startCoord+Number.EPSILON):X=(J.endCoord-f[M]+Number.EPSILON)/(J.endCoord-J.peakCoord+Number.EPSILON),_*=X}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}},sd=class{constructor(i){this.font=i,this.process=new Ja(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}},H0=1e6,xc=64,Ol=1e4,su,xl,id,bc;function ad(i){this.font=i,this.getCommands=function(o){return Pl.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ba(i){return i}function Fl(i){return Math.sign(i)*Math.round(Math.abs(i))}function od(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 $l(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function Ds(i){return Math.sign(i)*Math.floor(Math.abs(i))}var W0=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},ja={x:1,y:0,axis:"x",distance:function(i,o,u,h){return(u?i.xo:i.x)-(h?o.xo:o.x)},interpolate:function(i,o,u,h){let 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){ja.setRelative(i,i,(I+D)/2,h,!0);return}ja.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}},Co={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){Co.setRelative(i,i,(I+D)/2,h,!0);return}Co.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(ja),Object.freeze(Co);function Ul(i,o){this.x=i,this.y=o,this.axis=void 0,this.slope=o/i,this.normalSlope=-i/o,Object.freeze(this)}Ul.prototype.distance=function(i,o,u,h){return this.x*ja.distance(i,o,u,h)+this.y*Co.distance(i,o,u,h)},Ul.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)},Ul.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,J=i.x,X=i.y;i.x=(M*J-D*_+I-X)/(M-D),i.y=M*(i.x-J)+X},Ul.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function zl(i,o){let u=Math.sqrt(i*i+o*o);return i/=u,o/=u,i===1&&o===0?ja:i===0&&o===1?Co:new Ul(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 tt(i,o){switch(this.env=i,this.stack=[],this.prog=o,i){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=ja,this.round=Fl}}ad.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){tt.prototype=de,f=this._fpgmState=new tt("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}}tt.prototype=f,h=this._prepState=new tt("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 id(i,h)}catch(f){this._errorState<1&&(console.log("Hinting error:"+f),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},id=function(i,o){let u=o.ppem/o.font.unitsPerEm,h=u,f=i.components,g,A,_;if(tt.prototype=o,!f)_=new tt("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],J=I.glyphs.get(M.glyphIndex);_=new tt("glyf",J.instructions),_.instructionCount=0,_.callDepth=0,bc(J,_,u,h);let X=Math.round(M.dx*u),ve=Math.round(M.dy*h),he=_.gZone,Re=_.contours;for(let xr=0;xr<he.length;xr++){let lr=he[xr];lr.xTouched=lr.yTouched=!1,lr.xo=lr.x=lr.x+X,lr.yo=lr.y=lr.y+ve}let ut=A.length;A.push.apply(A,he);for(let xr=0;xr<Re.length;xr++)g.push(Re[xr]+ut)}i.instructions&&!_.inhibitGridFit&&(_=new tt("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 J=0;J<g;J++)I=f[J],A[J]=new C(I.x*u,I.y*h,I.lastPointOfContour,I.onCurve);let D,M;for(let J=0;J<g;J++)I=A[J],D||(D=I,_.push(J)),I.lastPointOfContour?(I.nextPointOnContour=D,D.prevPointOnContour=I,D=void 0):(M=A[J+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>H0)throw new Error("Hinting instructions exceeded maximum of "+H0);if(h=su[o[i.ip]],!h)throw new Error("unknown instruction: 0x"+Number(o[i.ip]).toString(16));h(i)}};function Tt(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 Yt(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 jr(i,o){o.fv=o.pv=o.dpv=i}function vn(i,o){o.pv=o.dpv=i}function En(i,o){o.fv=i}function In(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=zl(_,I)}function wi(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=zl(_,I)}function wn(i){let o=i.stack,u=o.pop(),h=o.pop();i.pv=i.dpv=zl(h,u)}function Zi(i){let o=i.stack,u=o.pop(),h=o.pop();i.fv=zl(h,u)}function _o(i){let o=i.stack,u=i.pv;o.push(u.x*16384),o.push(u.y*16384)}function ko(i){let o=i.stack,u=i.fv;o.push(u.x*16384),o.push(u.y*16384)}function Da(i){i.fv=i.pv}function Bi(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],J=I[f],X=I[g],ve=i.z2[A],he=D.x,Re=D.y,ut=M.x,xr=M.y,lr=J.x,Dr=J.y,en=X.x,Pn=X.y,qn=(he-ut)*(Dr-Pn)-(Re-xr)*(lr-en),Yn=he*xr-Re*ut,Bs=lr*Pn-Dr*en;ve.x=(Yn*(lr-en)-Bs*(he-ut))/qn,ve.y=(Yn*(Dr-Pn)-Bs*(Re-xr))/qn}function eo(i){i.rp0=i.stack.pop()}function cp(i){i.rp1=i.stack.pop()}function ld(i){i.rp2=i.stack.pop()}function t4(i){let o=i.stack.pop();switch(i.zp0=o,o){case 0:i.tZone||Tt(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function r4(i){let o=i.stack.pop();switch(i.zp1=o,o){case 0:i.tZone||Tt(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function n4(i){let o=i.stack.pop();switch(i.zp2=o,o){case 0:i.tZone||Tt(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function s4(i){let o=i.stack.pop();switch(i.zp0=i.zp1=i.zp2=o,o){case 0:i.tZone||Tt(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 i4(i){i.loop=i.stack.pop(),i.loop>Ol&&(i.loop=Ol)}function a4(i){i.round=Fl}function o4(i){i.round=yc}function l4(i){let o=i.stack.pop();i.minDis=o/64}function c4(i){Yt(i,!1)}function u4(i){let o=i.stack.pop();i.ip+=o-1}function d4(i){let o=i.stack.pop();i.cvCutIn=o/64}function h4(i){let o=i.stack;o.push(o[o.length-1])}function up(i){i.stack.pop()}function f4(i){i.stack.length=0}function p4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u),o.push(h)}function m4(i){let o=i.stack;o.push(o.length)}function g4(i){let o=i.stack,u=o.pop(),h=o.pop();if(h>Ol&&(h=Ol),++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 x4(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 b4(i){let o=i.stack,u=o.pop();o.push(o[o.length-u])}function y4(i){let o=i.stack,u=o.pop();o.push(o.splice(o.length-u,1)[0])}function v4(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 Eg(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 Ng(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 Rg(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],J=A.distance(f,f,!1,!0);g.setRelative(M,M,J,A),g.touch(M)}o.loop=1}function Mg(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 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,_=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),J=I.length-2;for(let X=0;X<J;X++)D=I[X],g.setRelative(D,D,M,A)}function w4(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 A4(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(),J=D[M];_.interpolate(J,g,A,I),_.touch(J)}i.loop=1}function Dg(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 T4(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 S4(i){i.round=od}function Bg(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 C4(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 _4(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 k4(i){let o=i.stack,u=i.store;u||(u=i.store=[]);let h=o.pop(),f=o.pop();u[f]=h}function L4(i){let o=i.stack,u=i.store,h=o.pop(),f=u&&u[h]||0;o.push(f)}function I4(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u/64}function E4(i){let o=i.stack,u=o.pop();o.push(i.cvt[u]*64)}function Qg(i,o){let u=o.stack,h=u.pop(),f=o.z2[h];u.push(o.dpv.distance(f,P,i,!1)*64)}function Pg(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 N4(i){i.stack.push(i.ppem)}function R4(i){i.autoFlip=!0}function M4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<u?1:0)}function j4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<=u?1:0)}function D4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>u?1:0)}function B4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>=u?1:0)}function Q4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u===h?1:0)}function P4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u!==h?1:0)}function O4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?1:0)}function F4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?0:1)}function $4(i){let o=i.stack.pop(),u;o||Yt(i,!0)}function U4(i){}function z4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u&&h?1:0)}function H4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u||h?1:0)}function W4(i){let o=i.stack,u=o.pop();o.push(u?0:1)}function dp(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 J=u.pop(),X=u.pop();if(_+((X&240)>>4)!==A)continue;let ve=(X&15)-8;ve>=0&&ve++;let he=D[J];f.setRelative(he,he,ve*I,g)}}function G4(i){let o=i.stack.pop();i.deltaBase=o}function V4(i){let o=i.stack.pop();i.deltaShift=Math.pow(.5,o)}function q4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h+u)}function Y4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h-u)}function Z4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*64/u)}function K4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*u/64)}function X4(i){let o=i.stack,u=o.pop();o.push(Math.abs(u))}function J4(i){let o=i.stack,u=o.pop();o.push(-u)}function e7(i){let o=i.stack,u=o.pop();o.push(Math.floor(u/64)*64)}function t7(i){let o=i.stack,u=o.pop();o.push(Math.ceil(u/64)*64)}function G0(i,o){let u=o.stack,h=u.pop();u.push(o.round(h/64)*64)}function r7(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u*i.ppem/i.font.unitsPerEm}function hp(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 J=M*A;o.cvt[I]+=J}}function n7(i){let o=i.stack.pop();i.round=W0;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 s7(i){let o=i.stack.pop();i.round=W0;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 i7(i){i.round=ba}function a7(i){i.round=$l}function o7(i){i.round=Ds}function l7(i){let o=i.stack.pop()}function Og(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=zl(_,I)}function c7(i){let o=i.stack,u=o.pop(),h=0;u&1&&(h=35),u&32&&(h|=4096),o.push(h)}function u7(i){let o=i.stack,u=o.pop(),h=o.pop(),f=o.pop();o.push(h),o.push(u),o.push(f)}function d7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.max(h,u))}function h7(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.min(h,u))}function f7(i){let o=i.stack.pop()}function p7(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 Hl(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 Wl(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],J=g.z1[I],X=g.minDis,ve=g.fv,he=g.dpv,Re,ut,xr,lr;ut=Re=he.distance(J,M,!0,!0),xr=ut>=0?1:-1,ut=Math.abs(ut),i&&(lr=g.cvt[_],h&&Math.abs(ut-lr)<g.cvCutIn&&(ut=lr)),u&&ut<X&&(ut=X),h&&(ut=g.round(ut)),ve.setRelative(J,M,xr*ut,he),ve.touch(J),g.rp1=g.rp0,g.rp2=I,o&&(g.rp0=I)}su=[jr.bind(void 0,Co),jr.bind(void 0,ja),vn.bind(void 0,Co),vn.bind(void 0,ja),En.bind(void 0,Co),En.bind(void 0,ja),In.bind(void 0,0),In.bind(void 0,1),wi.bind(void 0,0),wi.bind(void 0,1),wn,Zi,_o,ko,Da,Bi,eo,cp,ld,t4,r4,n4,s4,i4,a4,o4,l4,c4,u4,d4,void 0,void 0,h4,up,f4,p4,m4,b4,y4,void 0,void 0,void 0,g4,x4,v4,void 0,Eg.bind(void 0,0),Eg.bind(void 0,1),Ng.bind(void 0,Co),Ng.bind(void 0,ja),Rg.bind(void 0,0),Rg.bind(void 0,1),Mg.bind(void 0,0),Mg.bind(void 0,1),jg.bind(void 0,0),jg.bind(void 0,1),w4,A4,Dg.bind(void 0,0),Dg.bind(void 0,1),T4,S4,Bg.bind(void 0,0),Bg.bind(void 0,1),C4,_4,k4,L4,I4,E4,Qg.bind(void 0,0),Qg.bind(void 0,1),void 0,Pg.bind(void 0,0),Pg.bind(void 0,1),N4,void 0,R4,void 0,void 0,M4,j4,D4,B4,Q4,P4,O4,F4,$4,U4,z4,H4,W4,dp.bind(void 0,1),G4,V4,q4,Y4,Z4,K4,X4,J4,e7,t7,G0.bind(void 0,0),G0.bind(void 0,1),G0.bind(void 0,2),G0.bind(void 0,3),void 0,void 0,void 0,void 0,r7,dp.bind(void 0,2),dp.bind(void 0,3),hp.bind(void 0,1),hp.bind(void 0,2),hp.bind(void 0,3),n7,s7,void 0,void 0,i7,void 0,a7,o7,up,up,void 0,void 0,void 0,void 0,void 0,l7,Og.bind(void 0,0),Og.bind(void 0,1),c7,void 0,u7,d7,h7,f7,p7,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,Hl.bind(void 0,1),Hl.bind(void 0,2),Hl.bind(void 0,3),Hl.bind(void 0,4),Hl.bind(void 0,5),Hl.bind(void 0,6),Hl.bind(void 0,7),Hl.bind(void 0,8),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),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 m7=ad;function iu(i){this.char=i,this.state={},this.activeState=null}function fp(i,o,u){this.contextName=u,this.startIndex=i,this.endOffset=o}function g7(i,o,u){this.contextName=i,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=u}function Ki(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 V0(i){this.eventId=i,this.subscribers=[]}function x7(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 V0(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=[],x7.call(this,i)}iu.prototype.setState=function(i,o){return this.state[i]=o,this.activeState={key:i,value:this.state[i]},this.activeState},iu.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 iu);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 iu){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 iu)?(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)},V0.prototype.subscribe=function(i){return typeof i=="function"?this.subscribers.push(i)-1:{FAIL:`invalid '${this.eventId}' event handler`}},V0.prototype.unsubscribe=function(i){this.subscribers.splice(i,1)},Ki.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)},Ki.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 fp)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 V0)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 g7(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 Ki(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 fp(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 fp(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 Ki(o,u);this.dispatch("next",[f]),this.runContextCheck(f);let g=new iu(h);this.tokens.push(g),this.dispatch("newToken",[g,f])}return this.dispatch("end",[this.tokens]),this.tokens};var b7=Ts;function Gl(i){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(i)}function Fg(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 Vl(i){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(i)}function q0(i){return/[\u0E00-\u0E7F]/.test(i)}function Y0(i){return/[A-z]/.test(i)}function y7(i){return/\s/.test(i)}function Ba(i){this.font=i,this.features={}}function ql(i){this.id=i.id,this.tag=i.tag,this.substitution=i.substitution}function Yl(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 v7(i,o){return Yl(i,o.coverage)===-1?null:i+o.deltaGlyphId}function w7(i,o){let u=Yl(i,o.coverage);return u===-1?null:o.substitute[u]}function pp(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=Yl(g,f);A!==-1&&u.push(A)}return u.length!==i.length?-1:u}function A7(i,o){let u=o.inputCoverage.length+o.lookaheadCoverage.length+o.backtrackCoverage.length;if(i.context.length<u)return[];let h=pp(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&&Vl(g[0].char);)g.shift();let A=new Ki(g,0),_=pp(o.lookaheadCoverage,A),I=[].concat(i.backtrack);for(I.reverse();I.length&&Vl(I[0].char);)I.shift();if(I.length<o.backtrackCoverage.length)return[];let D=new Ki(I,0),M=pp(o.backtrackCoverage,D),J=h.length===o.inputCoverage.length&&_.length===o.lookaheadCoverage.length&&M.length===o.backtrackCoverage.length,X=[];if(J)for(let ve=0;ve<o.lookupRecords.length;ve++){let he=o.lookupRecords[ve],Re=he.lookupListIndex,ut=this.getLookupByIndex(Re);for(let xr=0;xr<ut.subtables.length;xr++){let lr=ut.subtables[xr],Dr,en=this.getSubstitutionType(ut,lr);if(en==="71"?(en=this.getSubstitutionType(lr,lr.extension),Dr=this.getLookupMethod(lr,lr.extension),lr=lr.extension):Dr=this.getLookupMethod(ut,lr),en==="12"){let Pn=i.get(he.sequenceIndex),qn=Dr(Pn);qn&&X.push(qn)}else if(en==="21"){let Pn=i.get(he.sequenceIndex),qn=Dr(Pn);qn&&X.push(qn)}else throw new Error(`Substitution type ${en} is not supported in chaining substitution`)}}return X}function T7(i,o){let u=i.current,h=Yl(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 S7(i,o){let u=i.current;if(Yl(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:J}=D,{subtables:X}=this.getLookupByIndex(M);for(let ve of X)Yl(I[J],ve.coverage)!==-1&&(I[J]=ve.deltaGlyphId)};for(let I=0;I<f.lookupRecords.length;I++){let D=f.lookupRecords[I];_(A,D)}return A}}return null}function C7(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,Yl(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 J=i.get(f.sequenceIndex),X=D(J);X&&u.push(X)}else if(M==="21"){let J=i.get(f.sequenceIndex),X=D(J);X&&u.push(X)}}}return u}function _7(i,o){let u=Yl(i,o.coverage);return u===-1?null:o.sequences[u]}Ba.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[]},Ba.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()},Ba.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},Ba.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},Ba.prototype.getSubstitutionType=function(i,o){let u=i.lookupType.toString(),h=o.substFormat.toString();return u+h},Ba.prototype.getLookupMethod=function(i,o){let u=this.getSubstitutionType(i,o);switch(u){case"11":return h=>v7.apply(this,[h,o]);case"12":return h=>w7.apply(this,[h,o]);case"63":return h=>A7.apply(this,[h,o]);case"41":return h=>T7.apply(this,[h,o]);case"21":return h=>_7.apply(this,[h,o]);case"51":return h=>S7.apply(this,[h,o]);case"53":return h=>C7.apply(this,[h,o]);default:throw new Error(`substitutionType : ${u} lookupType: ${i.lookupType} - substFormat: ${o.substFormat} is not yet supported`)}},Ba.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],J=this.getSubstitutionType(_,M),X;J==="71"?(J=this.getSubstitutionType(M,M.extension),X=this.getLookupMethod(M,M.extension),M=M.extension):X=this.getLookupMethod(_,M);let ve;switch(J){case"11":ve=X(o.current),ve&&g.splice(u,1,new ql({id:11,tag:i.tag,substitution:ve}));break;case"12":ve=X(o.current),ve&&g.splice(u,1,new ql({id:12,tag:i.tag,substitution:ve}));break;case"63":ve=X(o),Array.isArray(ve)&&ve.length&&g.splice(u,1,new ql({id:63,tag:i.tag,substitution:ve}));break;case"41":ve=X(o),ve&&g.splice(u,1,new ql({id:41,tag:i.tag,substitution:ve}));break;case"21":ve=X(o.current),ve&&g.splice(u,1,new ql({id:21,tag:i.tag,substitution:ve}));break;case"51":case"53":ve=X(o),Array.isArray(ve)&&ve.length&&g.splice(u,1,new ql({id:parseInt(J),tag:i.tag,substitution:ve}));break}o=new Ki(g,u),!(Array.isArray(ve)&&!ve.length)&&(ve=null)}}return g.length?g:null},Ba.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},Ba.prototype.getLookupSubtables=function(i){return i.subtables||null},Ba.prototype.getLookupByIndex=function(i){return this.font.tables.gsub.lookups[i]||null},Ba.prototype.getFeatureLookups=function(i){return i.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Ba.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 k7=Ba;function L7(i){let o=i.current,u=i.get(-1);return u===null&&Gl(o)||!Gl(u)&&Gl(o)}function I7(i){let o=i.get(1);return o===null||!Gl(o)}var E7={startCheck:L7,endCheck:I7};function N7(i){let o=i.current,u=i.get(-1);return(Gl(o)||Vl(o))&&!Gl(u)}function R7(i){let o=i.get(1);switch(!0){case o===null:return!0;case(!Gl(o)&&!Vl(o)):{let u=y7(o);if(!u)return!0;if(u){let h=!1;if(h=i.lookahead.some(f=>Gl(f)||Vl(f)),!h)return!0}break}default:return!1}}var M7={startCheck:N7,endCheck:R7};function j7(i,o,u){o[u].setState(i.tag,i.substitution)}function D7(i,o,u){o[u].setState(i.tag,i.substitution)}function mp(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 B7(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 $g={11:j7,12:D7,63:mp,41:B7,51:mp,53:mp};function Q7(i,o,u){i instanceof ql&&$g[i.id]&&$g[i.id](i,o,u)}var vc=Q7;function P7(i){let o=[].concat(i.backtrack);for(let u=o.length-1;u>=0;u--){let h=o[u],f=Fg(h),g=Vl(h);if(!f&&!g)return!0;if(f)return!1}return!1}function O7(i){if(Fg(i.current))return!1;for(let o=0;o<i.lookahead.length;o++){let u=i.lookahead[o];if(!Vl(u))return!0}return!1}function F7(i){let o="arab",u=this.featuresTags[o],h=this.tokenizer.getRangeTokens(i);if(h.length===1)return;let f=new Ki(h.map(A=>A.getState("glyphIndex")),0),g=new Ki(h.map(A=>A.char),0);for(let A=0;A<h.length;A++){let _=h[A];if(Vl(_.char))continue;f.setCurrentIndex(A),g.setCurrentIndex(A);let I=0;P7(g)&&(I|=1),O7(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 J=0;J<M.length;J++){let X=M[J];X instanceof ql&&(vc(X,h,J),f.context[J]=X.substitution)}}}var $7=F7;function Ug(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function U7(i){let o="arab",u=this.tokenizer.getRangeTokens(i),h=Ug(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=Ug(u)}}}var z7=U7;function H7(i){return i.index===0&&i.context.length>1}function W7(i){return i.index===i.context.length-1}var G7={startCheck:H7,endCheck:W7};function zg(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function V7(i){let o="delf",u="ccmp",h=this.tokenizer.getRangeTokens(i),f=zg(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=zg(h)}}}var q7=V7;function Y7(i){let o=i.current,u=i.get(-1);return u===null&&Y0(o)||!Y0(u)&&Y0(o)}function Z7(i){let o=i.get(1);return o===null||!Y0(o)}var K7={startCheck:Y7,endCheck:Z7};function Hg(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function X7(i){let o="latn",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:"liga",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 J7=X7;function e8(i){let o=i.current,u=i.get(-1);return u===null&&q0(o)||!q0(u)&&q0(o)}function t8(i){let o=i.get(1);return o===null||!q0(o)}var r8={startCheck:e8,endCheck:t8};function Wg(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function n8(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Wg(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=Wg(u,f)}}}var s8=n8;function Gg(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function i8(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Gg(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=Gg(u,f)}}}var a8=i8;function Vg(i,o){let u=i.map(h=>h.activeState.value);return new Ki(u,o||0)}function o8(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:"rlig",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 l8=o8;function gp(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 c8(i){let o=i.current,u=i.get(1);return u===null&&gp(o)||gp(u)}function u8(i){let o=i.get(1);return o===null||!gp(o)}var d8={startCheck:c8,endCheck:u8};function h8(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 f8=h8;function to(i){this.baseDir=i||"ltr",this.tokenizer=new b7,this.featuresTags={}}to.prototype.setText=function(i){this.text=i},to.prototype.contextChecks={ccmpReplacementCheck:G7,latinWordCheck:K7,arabicWordCheck:E7,arabicSentenceCheck:M7,thaiWordCheck:r8,unicodeVariationSequenceCheck:d8};function au(i){let o=this.contextChecks[`${i}Check`];return this.tokenizer.registerContextChecker(i,o.startCheck,o.endCheck)}function p8(){return au.call(this,"ccmpReplacement"),au.call(this,"latinWord"),au.call(this,"arabicWord"),au.call(this,"arabicSentence"),au.call(this,"thaiWord"),au.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function m8(){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())}}to.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},to.prototype.applyFeatures=function(i,o){if(!i)throw new Error("No valid font was provided to apply features");this.query||(this.query=new k7(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)}},to.prototype.registerModifier=function(i,o,u){this.tokenizer.registerModifier(i,o,u)};function cd(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function g8(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;cd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];$7.call(this,u)}}function x8(){cd.call(this);let i=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<i.length;o++){let u=i[o];q7.call(this,u)}}function b8(){if(!this.hasFeatureEnabled("arab","rlig"))return;cd.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];z7.call(this,u)}}function y8(){if(!this.hasFeatureEnabled("latn","liga"))return;cd.call(this);let i=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<i.length;o++){let u=i[o];J7.call(this,u)}}function v8(){let i=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<i.length;o++){let u=i[o];f8.call(this,u)}}function w8(){cd.call(this);let i=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<i.length;o++){let u=i[o];this.hasFeatureEnabled("thai","liga")&&a8.call(this,u),this.hasFeatureEnabled("thai","rlig")&&l8.call(this,u),this.hasFeatureEnabled("thai","ccmp")&&s8.call(this,u)}}to.prototype.checkContextReady=function(i){return!!this.tokenizer.getContext(i)},to.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&x8.call(this),this.checkContextReady("arabicWord")&&(g8.call(this),b8.call(this)),this.checkContextReady("latinWord")&&y8.call(this),this.checkContextReady("arabicSentence")&&m8.call(this),this.checkContextReady("thaiWord")&&w8.call(this),this.checkContextReady("unicodeVariationSequence")&&v8.call(this)},to.prototype.hasFeatureEnabled=function(i,o){return(this.featuresTags[i]||[]).indexOf(o)!==-1},to.prototype.processText=function(i){(!this.text||this.text!==i)&&(this.setText(i),p8.call(this),this.applyFeaturesToContexts())},to.prototype.getBidiText=function(i){return this.processText(i),this.tokenizer.getText()},to.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 A8=to;function xp(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 Hn(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=xp(i),this.names.macintosh=xp(i),this.names.windows=xp(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 G.GlyphSet(this,i.glyphs||[]),this.encoding=new Xr(this),this.position=new pc(this),this.substitution=new Xa(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 sd(this)),!0)}),this.palettes=new xa(this),this.layers=new Ql(this),this.svgImages=new eu(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new m7(this):null}})}Hn.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)>0},Hn.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},Hn.prototype.charToGlyph=function(i){let o=this.charToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Hn.prototype.updateFeatures=function(i){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(u=>i[u])}:o)},Hn.prototype.stringToGlyphIndexes=function(i,o){let u=new A8,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)},Hn.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},Hn.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},Hn.prototype.nameToGlyph=function(i){let o=this.nameToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Hn.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},Hn.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},Hn.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},Hn.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 J=I?this.position.getKerningValue(I,M.index,_[D+1].index):this.getKerningValue(M,_[D+1]);o+=J*A}f.letterSpacing?o+=f.letterSpacing*h:f.tracking&&(o+=f.tracking/1e3*h)}return o},Hn.prototype.getPath=function(i,o,u,h,f){f=Object.assign({},this.defaultRenderOptions,f);let g=new He;if(g._layers=[],Un(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 J=M._layers;if(J&&J.length){for(let X=0;X<J.length;X++){let ve=J[X];g._layers.push(ve)}return}}g.extend(M)}),g},Hn.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},Hn.prototype.getAdvanceWidth=function(i,o,u){return u=Object.assign({},this.defaultRenderOptions,u),this.forEachGlyph(i,0,0,o,u,function(){})},Hn.prototype.draw=function(i,o,u,h,f,g){this.getPath(o,u,h,f,g).draw(i)},Hn.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)})},Hn.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)})},Hn.prototype.getEnglishName=function(i){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[i];if(o)return o.en},Hn.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},Hn.prototype.toTables=function(){return Ur.fontToTable(this)},Hn.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Hn.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},Hn.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Hn.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Hn.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Hn.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},Hn.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var qg=Hn;function T8(i,o){let u=new it.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 S8(){console.warn("Writing of hvar tables is not yet supported.")}var C8={make:S8,parse:T8},_8=function(){return{coverage:this.parsePointer(ge.coverage),attachPoints:this.parseList(ge.pointer(ge.uShortList))}},k8=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()}},L8=function(){return this.parseList(ge.pointer(k8))},I8=function(){return{coverage:this.parsePointer(ge.coverage),ligGlyphs:this.parseList(ge.pointer(L8))}},E8=function(){return this.parseUShort(),this.parseList(ge.pointer(ge.coverage))};function N8(i,o){o=o||0;let u=new ge(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(ge.classDef),attachList:u.parsePointer(_8),ligCaretList:u.parsePointer(I8),markAttachClassDef:u.parsePointer(ge.classDef)};return h>=1.2&&(f.markGlyphSets=u.parsePointer(E8)),f}var R8={parse:N8},Lo=new Array(10);Lo[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{posFormat:1,coverage:this.parsePointer(ge.coverage),value:this.parseValueRecord()};if(o===2)return{posFormat:2,coverage:this.parsePointer(ge.coverage),values:this.parseValueRecordList()};ue.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Lo[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(ge.coverage),h=this.parseUShort(),f=this.parseUShort();if(o===1)return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:f,pairSets:this.parseList(ge.pointer(ge.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(h),value2:this.parseValueRecord(f)}})))};if(o===2){let g=this.parsePointer(ge.classDef),A=this.parsePointer(ge.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(_,ge.list(I,function(){return{value1:this.parseValueRecord(h),value2:this.parseValueRecord(f)}}))}}},Lo[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Lo[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Lo[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Lo[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Lo[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Lo[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Lo[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function M8(i,o){o=o||0;let u=new ge(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(Lo)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(Lo),variations:u.parseFeatureVariationsList()}}var j8=new Array(10);function D8(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,j8)}])}var B8={parse:M8,make:D8};function Q8(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 P8(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 O8(i,o){let u=new it.Parser(i,o),h=u.parseUShort();if(h===0)return Q8(u);if(h===1)return P8(u);throw new Error("Unsupported kern table version ("+h+").")}var F8={parse:O8};function $8(i,o,u,h){let f=new it.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 U8={parse:$8};function Yg(i,o){let u=[],h=12;for(let f=0;f<o;f+=1){let g=it.getTag(i,h),A=it.getULong(i,h+4),_=it.getULong(i,h+8),I=it.getULong(i,h+12);u.push({tag:g,checksum:A,offset:_,length:I,compression:!1}),h+=16}return u}function z8(i,o){let u=[],h=44;for(let f=0;f<o;f+=1){let g=it.getTag(i,h),A=it.getULong(i,h+4),_=it.getULong(i,h+8),I=it.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 Nn(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 H8(i,o={}){let u,h,f=new qg({empty:!0});i.constructor!==ArrayBuffer&&(i=new Uint8Array(i).buffer);let g=new DataView(i,0),A,_=[],I=it.getTag(g,0);if(I==="\0\0\0"||I==="true"||I==="typ1")f.outlinesFormat="truetype",A=it.getUShort(g,4),_=Yg(g,A);else if(I==="OTTO")f.outlinesFormat="cff",A=it.getUShort(g,4),_=Yg(g,A);else if(I==="wOFF"){let br=it.getTag(g,4);if(br==="\0\0\0")f.outlinesFormat="truetype";else if(br==="OTTO")f.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+I);A=it.getUShort(g,12),_=z8(g,A)}else if(I==="wOF2"){let br="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+br)}else throw new Error("Unsupported OpenType signature "+I);let D,M,J,X,ve,he,Re,ut,xr,lr,Dr,en,Pn,qn,Yn,Bs,Io,tn;for(let br=0;br<A;br+=1){let rr=_[br],ar;switch(rr.tag){case"avar":Re=rr;break;case"cmap":ar=Nn(g,rr),f.tables.cmap=Br.parse(ar.data,ar.offset),f.encoding=new fn(f.tables.cmap);break;case"cvt ":ar=Nn(g,rr),tn=new it.Parser(ar.data,ar.offset),f.tables.cvt=tn.parseShortList(rr.length/2);break;case"fvar":J=rr;break;case"STAT":X=rr;break;case"gvar":ve=rr;break;case"cvar":he=rr;break;case"fpgm":ar=Nn(g,rr),tn=new it.Parser(ar.data,ar.offset),f.tables.fpgm=tn.parseByteList(rr.length);break;case"head":ar=Nn(g,rr),f.tables.head=Xs.parse(ar.data,ar.offset),f.unitsPerEm=f.tables.head.unitsPerEm,u=f.tables.head.indexToLocFormat;break;case"hhea":ar=Nn(g,rr),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":Pn=rr;break;case"hmtx":en=rr;break;case"ltag":ar=Nn(g,rr),h=xi.parse(ar.data,ar.offset);break;case"COLR":ar=Nn(g,rr),f.tables.colr=Gi.parse(ar.data,ar.offset);break;case"CPAL":ar=Nn(g,rr),f.tables.cpal=Kn.parse(ar.data,ar.offset);break;case"maxp":ar=Nn(g,rr),f.tables.maxp=Uo.parse(ar.data,ar.offset),f.numGlyphs=f.tables.maxp.numGlyphs;break;case"name":Bs=rr;break;case"OS/2":ar=Nn(g,rr),f.tables.os2=Ms.parse(ar.data,ar.offset);break;case"post":ar=Nn(g,rr),f.tables.post=jl.parse(ar.data,ar.offset),f.glyphNames=new Ue(f.tables.post);break;case"prep":ar=Nn(g,rr),tn=new it.Parser(ar.data,ar.offset),f.tables.prep=tn.parseByteList(rr.length);break;case"glyf":ut=rr;break;case"loca":Yn=rr;break;case"CFF ":D=rr;break;case"CFF2":M=rr;break;case"kern":qn=rr;break;case"GDEF":xr=rr;break;case"GPOS":lr=rr;break;case"GSUB":Dr=rr;break;case"meta":Io=rr;break;case"gasp":try{ar=Nn(g,rr),f.tables.gasp=T.parse(ar.data,ar.offset)}catch(Qi){console.warn("Failed to parse gasp table, skipping."),console.warn(Qi)}break;case"SVG ":ar=Nn(g,rr),f.tables.svg=O.parse(ar.data,ar.offset);break;default:break}}let Qa=Nn(g,Bs);if(f.tables.name=dr.parse(Qa.data,Qa.offset,h),f.names=f.tables.name,ut&&Yn){let br=u===0,rr=Nn(g,Yn),ar=U8.parse(rr.data,rr.offset,f.numGlyphs,br),Qi=Nn(g,ut);f.glyphs=Pl.parse(Qi.data,Qi.offset,ar,f,o)}else if(D){let br=Nn(g,D);is.parse(br.data,br.offset,f,o)}else if(M){let br=Nn(g,M);is.parse(br.data,br.offset,f,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let Xi=Nn(g,en);if(Rs.parse(f,Xi.data,Xi.offset,f.numberOfHMetrics,f.numGlyphs,f.glyphs,o),tr(f,o),qn){let br=Nn(g,qn);f.kerningPairs=F8.parse(br.data,br.offset)}else f.kerningPairs={};if(xr){let br=Nn(g,xr);f.tables.gdef=R8.parse(br.data,br.offset)}if(lr){let br=Nn(g,lr);f.tables.gpos=B8.parse(br.data,br.offset),f.position.init()}if(Dr){let br=Nn(g,Dr);f.tables.gsub=Ri.parse(br.data,br.offset)}if(J){let br=Nn(g,J);f.tables.fvar=ei.parse(br.data,br.offset,f.names)}if(X){let br=Nn(g,X);f.tables.stat=As.parse(br.data,br.offset,f.tables.fvar)}if(ve){J||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),ut||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let br=Nn(g,ve);f.tables.gvar=qi.parse(br.data,br.offset,f.tables.fvar,f.glyphs)}if(he){J||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."),ut||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let br=Nn(g,he);f.tables.cvar=ga.parse(br.data,br.offset,f.tables.fvar,f.tables.cvt||[])}if(Re){J||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let br=Nn(g,Re);f.tables.avar=ma.parse(br.data,br.offset,f.tables.fvar)}if(Pn){J||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),en||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let br=Nn(g,Pn);f.tables.hvar=C8.parse(br.data,br.offset,f.tables.fvar)}if(Io){let br=Nn(g,Io);f.tables.meta=Ws.parse(br.data,br.offset),f.metas=f.tables.meta}return f.palettes=new xa(f),f}function W8(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function G8(){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}))}),tL=Jk(eL()),ki=Cu("lru-cache:metrics"),Yd=Hk("lru-cache"),rL=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Fp=()=>ki.hasSubscribers||Yd.hasSubscribers,B3=new Set,X2=typeof process=="object"&&process?process:{},nL=(e,t,r,n)=>{typeof X2.emitWarning=="function"?X2.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},sL=e=>!B3.has(e),sc=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),Q3=e=>sc(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Hh:null:null,Hh=class extends Array{constructor(e){super(e),this.fill(0)}},Ic,xd,iL=(Ic=class{constructor(e,t){if(Ys(this,"heap"),Ys(this,"length"),!ae(Ic,xd))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=Q3(e);if(!t)return[];Nr(Ic,xd,!0);let r=new Ic(e,t);return Nr(Ic,xd,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},xd=new WeakMap,mn(Ic,xd,!1),Ic),J2,ex,Ro,io,Ko,du,Xo,bd,yd,Jo,ni,ao,qs,xs,Zr,wa,oo,ra,Ti,el,Si,tl,rl,lo,co,nl,vd,Aa,hu,$t,$p,fu,Kl,oh,uo,tx,pu,wd,lh,Xl,Jl,Up,mu,ch,rx,nx,uh,ts,zp,sx,ix,Ad,Hp,Td,ec,Wp,Gp,aL=(Gp=class{constructor(e){mn(this,$t),mn(this,Ro),mn(this,io),mn(this,Ko),mn(this,du),mn(this,Xo),mn(this,bd),mn(this,yd),mn(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"),mn(this,ni),mn(this,ao),mn(this,qs),mn(this,xs),mn(this,Zr),mn(this,wa),mn(this,oo),mn(this,ra),mn(this,Ti),mn(this,el),mn(this,Si),mn(this,tl),mn(this,rl),mn(this,lo),mn(this,co),mn(this,nl),mn(this,vd),mn(this,Aa),mn(this,hu),mn(this,fu,()=>{}),mn(this,Kl,()=>{}),mn(this,oh,()=>{}),mn(this,uo,()=>!1),mn(this,pu,pe=>{}),mn(this,wd,(pe,te,ke)=>{}),mn(this,lh,(pe,te,ke,$e)=>{if(ke||$e)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),Ys(this,J2,"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:W,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:U,ignoreFetchAbort:V,backgroundFetchSize:Z=1,perf:ce}=e;if(this.backgroundFetchSize=Z,ce!==void 0&&typeof ce?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(Nr(this,Jo,ce??rL),t!==0&&!sc(t))throw new TypeError("max option must be a nonnegative integer");let xe=t?Q3(t):Array;if(!xe)throw new Error("invalid max value: "+t);if(Nr(this,Ro,t),Nr(this,io,v),this.maxEntrySize=S||ae(this,io),this.sizeCalculation=L,this.sizeCalculation){if(!ae(this,io)&&!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(Nr(this,yd,R),E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(Nr(this,bd,E),Nr(this,vd,!!E),Nr(this,qs,new Map),Nr(this,xs,Array.from({length:t}).fill(void 0)),Nr(this,Zr,Array.from({length:t}).fill(void 0)),Nr(this,wa,new xe(t)),Nr(this,oo,new xe(t)),Nr(this,ra,0),Nr(this,Ti,0),Nr(this,el,iL.create(t)),Nr(this,ni,0),Nr(this,ao,0),typeof p=="function"&&Nr(this,Ko,p),typeof m=="function"&&Nr(this,du,m),typeof x=="function"?(Nr(this,Xo,x),Nr(this,Si,[])):(Nr(this,Xo,void 0),Nr(this,Si,void 0)),Nr(this,nl,!!ae(this,Ko)),Nr(this,hu,!!ae(this,du)),Nr(this,Aa,!!ae(this,Xo)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!U,this.ignoreFetchAbort=!!V,this.maxEntrySize!==0){if(ae(this,io)!==0&&!sc(ae(this,io)))throw new TypeError("maxSize must be a positive integer if specified");if(!sc(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Wt(this,$t,tx).call(this)}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!W,this.updateAgeOnGet=!!c,this.updateAgeOnHas=!!l,this.ttlResolution=sc(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!sc(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Wt(this,$t,$p).call(this)}if(ae(this,Ro)===0&&this.ttl===0&&ae(this,io)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ae(this,Ro)&&!ae(this,io)){let pe="LRU_CACHE_UNBOUNDED";sL(pe)&&(B3.add(pe),nL("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",pe,Gp))}}get perf(){return ae(this,Jo)}static unsafeExposeInternals(e){return{starts:ae(e,rl),ttls:ae(e,lo),autopurgeTimers:ae(e,co),sizes:ae(e,tl),keyMap:ae(e,qs),keyList:ae(e,xs),valList:ae(e,Zr),next:ae(e,wa),prev:ae(e,oo),get head(){return ae(e,ra)},get tail(){return ae(e,Ti)},free:ae(e,el),isBackgroundFetch:t=>{var r;return Wt(r=e,$t,ts).call(r,t)},backgroundFetch:(t,r,n,a)=>{var c;return Wt(c=e,$t,uh).call(c,t,r,n,a)},moveToTail:t=>{var r;return Wt(r=e,$t,Td).call(r,t)},indexes:t=>{var r;return Wt(r=e,$t,Xl).call(r,t)},rindexes:t=>{var r;return Wt(r=e,$t,Jl).call(r,t)},isStale:t=>{var r;return ae(r=e,uo).call(r,t)}}}get max(){return ae(this,Ro)}get maxSize(){return ae(this,io)}get calculatedSize(){return ae(this,ao)}get size(){return ae(this,ni)}get fetchMethod(){return ae(this,bd)}get memoMethod(){return ae(this,yd)}get dispose(){return ae(this,Ko)}get onInsert(){return ae(this,du)}get disposeAfter(){return ae(this,Xo)}getRemainingTTL(e){return ae(this,qs).has(e)?1/0:0}*entries(){for(let e of Wt(this,$t,Xl).call(this))ae(this,Zr)[e]!==void 0&&ae(this,xs)[e]!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield[ae(this,xs)[e],ae(this,Zr)[e]])}*rentries(){for(let e of Wt(this,$t,Jl).call(this))ae(this,Zr)[e]!==void 0&&ae(this,xs)[e]!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield[ae(this,xs)[e],ae(this,Zr)[e]])}*keys(){for(let e of Wt(this,$t,Xl).call(this)){let t=ae(this,xs)[e];t!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield t)}}*rkeys(){for(let e of Wt(this,$t,Jl).call(this)){let t=ae(this,xs)[e];t!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield t)}}*values(){for(let e of Wt(this,$t,Xl).call(this))ae(this,Zr)[e]!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield ae(this,Zr)[e])}*rvalues(){for(let e of Wt(this,$t,Jl).call(this))ae(this,Zr)[e]!==void 0&&!Wt(this,$t,ts).call(this,ae(this,Zr)[e])&&(yield ae(this,Zr)[e])}[(ex=Symbol.iterator,J2=Symbol.toStringTag,ex)](){return this.entries()}find(e,t={}){for(let r of Wt(this,$t,Xl).call(this)){let n=ae(this,Zr)[r],a=Wt(this,$t,ts).call(this,n)?n.__staleWhileFetching:n;if(a!==void 0&&e(a,ae(this,xs)[r],this))return Wt(this,$t,Ad).call(this,ae(this,xs)[r],t)}}forEach(e,t=this){for(let r of Wt(this,$t,Xl).call(this)){let n=ae(this,Zr)[r],a=Wt(this,$t,ts).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ae(this,xs)[r],this)}}rforEach(e,t=this){for(let r of Wt(this,$t,Jl).call(this)){let n=ae(this,Zr)[r],a=Wt(this,$t,ts).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ae(this,xs)[r],this)}}purgeStale(){let e=!1;for(let t of Wt(this,$t,Jl).call(this,{allowStale:!0}))ae(this,uo).call(this,t)&&(Wt(this,$t,ec).call(this,ae(this,xs)[t],"expire"),e=!0);return e}info(e){let t=ae(this,qs).get(e);if(t===void 0)return;let r=ae(this,Zr)[t],n=Wt(this,$t,ts).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let a={value:n};if(ae(this,lo)&&ae(this,rl)){let c=ae(this,lo)[t],l=ae(this,rl)[t];if(c&&l){let d=c-(ae(this,Jo).now()-l);a.ttl=d,a.start=Date.now()}}return ae(this,tl)&&(a.size=ae(this,tl)[t]),a}dump(){let e=[];for(let t of Wt(this,$t,Xl).call(this,{allowStale:!0})){let r=ae(this,xs)[t],n=ae(this,Zr)[t],a=Wt(this,$t,ts).call(this,n)?n.__staleWhileFetching:n;if(a===void 0||r===void 0)continue;let c={value:a};if(ae(this,lo)&&ae(this,rl)){c.ttl=ae(this,lo)[t];let l=ae(this,Jo).now()-ae(this,rl)[t];c.start=Math.floor(Date.now()-l)}ae(this,tl)&&(c.size=ae(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=ae(this,Jo).now()-n}Wt(this,$t,mu).call(this,t,r.value,r)}}set(e,t,r={}){let{status:n=ki.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=Wt(this,$t,mu).call(this,e,t,r);return n&&ki.hasSubscribers&&ki.publish(n),a}pop(){var e;try{for(;ae(this,ni);){let t=ae(this,Zr)[ae(this,ra)];if(Wt(this,$t,ch).call(this,!0),Wt(this,$t,ts).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(ae(this,Aa)&&ae(this,Si)){let t=ae(this,Si),r;for(;r=t?.shift();)(e=ae(this,Xo))==null||e.call(this,...r)}}}has(e,t={}){let{status:r=ki.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let n=Wt(this,$t,rx).call(this,e,t);return ki.hasSubscribers&&ki.publish(r),n}peek(e,t={}){let{status:r=Fp()?{}:void 0}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let n=Wt(this,$t,nx).call(this,e,t);return ki.hasSubscribers&&ki.publish(r),n}fetch(e,t={}){let r=Yd.hasSubscribers,{status:n=Fp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Wt(this,$t,zp).call(this,e,t);return n&&r&&(n.trace=!0,Yd.tracePromise(()=>a,n).catch(()=>{})),a}forceFetch(e,t={}){let r=Yd.hasSubscribers,{status:n=Fp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Wt(this,$t,sx).call(this,e,t);return n&&r&&(n.trace=!0,Yd.tracePromise(()=>a,n).catch(()=>{})),a}memo(e,t={}){let{status:r=ki.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=Wt(this,$t,ix).call(this,e,t);return r&&(r.value=n),ki.hasSubscribers&&ki.publish(r),n}get(e,t={}){let{status:r=ki.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let n=Wt(this,$t,Ad).call(this,e,t);return r&&(n!==void 0&&(r.value=n),ki.hasSubscribers&&ki.publish(r)),n}delete(e){return Wt(this,$t,ec).call(this,e,"delete")}clear(){return Wt(this,$t,Wp).call(this,"delete")}},Ro=new WeakMap,io=new WeakMap,Ko=new WeakMap,du=new WeakMap,Xo=new WeakMap,bd=new WeakMap,yd=new WeakMap,Jo=new WeakMap,ni=new WeakMap,ao=new WeakMap,qs=new WeakMap,xs=new WeakMap,Zr=new WeakMap,wa=new WeakMap,oo=new WeakMap,ra=new WeakMap,Ti=new WeakMap,el=new WeakMap,Si=new WeakMap,tl=new WeakMap,rl=new WeakMap,lo=new WeakMap,co=new WeakMap,nl=new WeakMap,vd=new WeakMap,Aa=new WeakMap,hu=new WeakMap,$t=new WeakSet,$p=function(){let e=new Hh(ae(this,Ro)),t=new Hh(ae(this,Ro));Nr(this,lo,e),Nr(this,rl,t);let r=this.ttlAutopurge?Array.from({length:ae(this,Ro)}):void 0;Nr(this,co,r),Nr(this,oh,(l,d,p=ae(this,Jo).now())=>{t[l]=d!==0?p:0,e[l]=d,n(l,d)}),Nr(this,fu,l=>{t[l]=e[l]!==0?ae(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(()=>{ae(this,uo).call(this,l)&&Wt(this,$t,ec).call(this,ae(this,xs)[l],"expire")},d+1);p.unref&&p.unref(),r[l]=p}}:()=>{};Nr(this,Kl,(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=ae(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=ae(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},Nr(this,uo,l=>{let d=t[l],p=e[l];return!!p&&!!d&&(a||c())-d>p})},fu=new WeakMap,Kl=new WeakMap,oh=new WeakMap,uo=new WeakMap,tx=function(){let e=new Hh(ae(this,Ro));Nr(this,ao,0),Nr(this,tl,e),Nr(this,pu,t=>{Nr(this,ao,ae(this,ao)-e[t]),e[t]=0}),Nr(this,lh,(t,r,n,a)=>{if(!sc(n)){if(Wt(this,$t,ts).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),!sc(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}),Nr(this,wd,(t,r,n)=>{if(e[t]=r,ae(this,io)){let a=ae(this,io)-e[t];for(;ae(this,ao)>a;)Wt(this,$t,ch).call(this,!0)}Nr(this,ao,ae(this,ao)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=ae(this,ao))})},pu=new WeakMap,wd=new WeakMap,lh=new WeakMap,Xl=function*({allowStale:e=this.allowStale}={}){if(ae(this,ni))for(let t=ae(this,Ti);Wt(this,$t,Up).call(this,t)&&((e||!ae(this,uo).call(this,t))&&(yield t),t!==ae(this,ra));)t=ae(this,oo)[t]},Jl=function*({allowStale:e=this.allowStale}={}){if(ae(this,ni))for(let t=ae(this,ra);Wt(this,$t,Up).call(this,t)&&((e||!ae(this,uo).call(this,t))&&(yield t),t!==ae(this,Ti));)t=ae(this,wa)[t]},Up=function(e){return e!==void 0&&ae(this,qs).get(ae(this,xs)[e])===e},mu=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=Wt(this,$t,ts).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=ae(this,lh).call(this,e,t,r.size||0,y,w);if(this.maxEntrySize&&L>this.maxEntrySize)return Wt(this,$t,ec).call(this,e,"set"),w&&(w.set="miss",w.maxEntrySizeExceeded=!0),this;let E=ae(this,ni)===0?void 0:ae(this,qs).get(e);if(E===void 0)E=ae(this,ni)===0?ae(this,Ti):ae(this,el).length!==0?ae(this,el).pop():ae(this,ni)===ae(this,Ro)?Wt(this,$t,ch).call(this,!1):ae(this,ni),ae(this,xs)[E]=e,ae(this,Zr)[E]=t,ae(this,qs).set(e,E),ae(this,wa)[ae(this,Ti)]=E,ae(this,oo)[E]=ae(this,Ti),Nr(this,Ti,E),Op(this,ni)._++,ae(this,wd).call(this,E,L,w),w&&(w.set="add"),S=!1,ae(this,hu)&&!v&&((a=ae(this,du))==null||a.call(this,t,e,"add"));else{Wt(this,$t,Td).call(this,E);let R=ae(this,Zr)[E];if(t!==R){if(!x)if(Wt(this,$t,ts).call(this,R)){R!==n&&R.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:B}=R;B!==void 0&&B!==t&&(ae(this,nl)&&((c=ae(this,Ko))==null||c.call(this,B,e,"set")),ae(this,Aa)&&ae(this,Si)?.push([B,e,"set"]))}else ae(this,nl)&&((l=ae(this,Ko))==null||l.call(this,R,e,"set")),ae(this,Aa)&&ae(this,Si)?.push([R,e,"set"]);if(ae(this,pu).call(this,E),ae(this,wd).call(this,E,L,w),ae(this,Zr)[E]=t,!v){let B=R&&Wt(this,$t,ts).call(this,R)?R.__staleWhileFetching:R,W=B===void 0?"add":t!==B?"replace":"update";w&&(w.set=W,B!==void 0&&(w.oldValue=B)),ae(this,hu)&&this.onInsert?.(t,e,W)}}else v||(w&&(w.set="update"),ae(this,hu)&&this.onInsert?.(t,e,"update"))}if(p!==0&&!ae(this,lo)&&Wt(this,$t,$p).call(this),ae(this,lo)&&(S||ae(this,oh).call(this,E,p,m),w&&ae(this,Kl).call(this,w,E)),!x&&ae(this,Aa)&&ae(this,Si)){let R=ae(this,Si),B;for(;B=R?.shift();)(d=ae(this,Xo))==null||d.call(this,...B)}return this},ch=function(e){var t;let r=ae(this,ra),n=ae(this,xs)[r],a=ae(this,Zr)[r],c=Wt(this,$t,ts).call(this,a);c&&a.__abortController.abort(new Error("evicted"));let l=c?a.__staleWhileFetching:a;return(ae(this,nl)||ae(this,Aa))&&l!==void 0&&(ae(this,nl)&&((t=ae(this,Ko))==null||t.call(this,l,n,"evict")),ae(this,Aa)&&ae(this,Si)?.push([l,n,"evict"])),ae(this,pu).call(this,r),ae(this,co)?.[r]&&(clearTimeout(ae(this,co)[r]),ae(this,co)[r]=void 0),e&&(ae(this,xs)[r]=void 0,ae(this,Zr)[r]=void 0,ae(this,el).push(r)),ae(this,ni)===1?(Nr(this,ra,Nr(this,Ti,0)),ae(this,el).length=0):Nr(this,ra,ae(this,wa)[r]),ae(this,qs).delete(n),Op(this,ni)._--,r},rx=function(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=ae(this,qs).get(e);if(a!==void 0){let c=ae(this,Zr)[a];if(Wt(this,$t,ts).call(this,c)&&c.__staleWhileFetching===void 0)return!1;if(ae(this,uo).call(this,a))n&&(n.has="stale",ae(this,Kl).call(this,n,a));else return r&&ae(this,fu).call(this,a),n&&(n.has="hit",ae(this,Kl).call(this,n,a)),!0}else n&&(n.has="miss");return!1},nx=function(e,t){let{status:r,allowStale:n=this.allowStale}=t,a=ae(this,qs).get(e);if(a===void 0||!n&&ae(this,uo).call(this,a)){r&&(r.peek=a===void 0?"miss":"stale");return}let c=ae(this,Zr)[a],l=Wt(this,$t,ts).call(this,c)?c.__staleWhileFetching:c;return r&&(l!==void 0?(r.peek="hit",r.value=l):r.peek="miss"),l},uh=function(e,t,r,n){let a=t===void 0?void 0:ae(this,Zr)[t];if(Wt(this,$t,ts).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 W=w,F=ae(this,Zr)[t];return(F===w||F===void 0&&R&&L)&&(S===void 0?W.__staleWhileFetching!==void 0?ae(this,Zr)[t]=W.__staleWhileFetching:Wt(this,$t,ec).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),Wt(this,$t,mu).call(this,e,S,d.options,W))),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,W=B||r.noDeleteOnFetchRejection,F=w;if(ae(this,Zr)[t]===w&&(!W||!L&&F.__staleWhileFetching===void 0?Wt(this,$t,ec).call(this,e,"fetch"):R||(ae(this,Zr)[t]=F.__staleWhileFetching)),B)return r.status&&F.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),F.__staleWhileFetching;if(F.__returned===F)throw S},y=(S,L)=>{var E;let R=(E=ae(this,bd))==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?(Wt(this,$t,mu).call(this,e,v,{...d.options,status:void 0}),t=ae(this,qs).get(e)):ae(this,Zr)[t]=v,v},ts=function(e){if(!ae(this,vd))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},zp=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),!ae(this,vd))return E&&(E.fetch="get"),Wt(this,$t,Ad).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},W=ae(this,qs).get(e);if(W===void 0){E&&(E.fetch="miss");let F=Wt(this,$t,uh).call(this,e,W,B,S);return F.__returned=F}else{let F=ae(this,Zr)[W];if(Wt(this,$t,ts).call(this,F)){let ce=r&&F.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",ce&&(E.returnedStale=!0)),ce?F.__staleWhileFetching:F.__returned=F}let U=ae(this,uo).call(this,W);if(!L&&!U)return E&&(E.fetch="hit"),Wt(this,$t,Td).call(this,W),n&&ae(this,fu).call(this,W),E&&ae(this,Kl).call(this,E,W),F;let V=Wt(this,$t,uh).call(this,e,W,B,S),Z=V.__staleWhileFetching!==void 0&&r;return E&&(E.fetch=U?"stale":"refresh",Z&&U&&(E.returnedStale=!0)),Z?V.__staleWhileFetching:V.__returned=V}},sx=async function(e,t={}){let r=await Wt(this,$t,zp).call(this,e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r},ix=function(e,t={}){let r=ae(this,yd);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=Wt(this,$t,Ad).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),Wt(this,$t,mu).call(this,e,m,l),m},Ad=function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:c}=t,l=ae(this,qs).get(e);if(l===void 0){c&&(c.get="miss");return}let d=ae(this,Zr)[l],p=Wt(this,$t,ts).call(this,d);return c&&ae(this,Kl).call(this,c,l),ae(this,uo).call(this,l)?p?(c&&(c.get="stale-fetching"),r&&d.__staleWhileFetching!==void 0?(c&&(c.returnedStale=!0),d.__staleWhileFetching):void 0):(a||Wt(this,$t,ec).call(this,e,"expire"),c&&(c.get="stale"),r?(c&&(c.returnedStale=!0),d):void 0):(c&&(c.get=p?"fetching":"hit"),Wt(this,$t,Td).call(this,l),n&&ae(this,fu).call(this,l),p?d.__staleWhileFetching:d)},Hp=function(e,t){ae(this,oo)[t]=e,ae(this,wa)[e]=t},Td=function(e){e!==ae(this,Ti)&&(e===ae(this,ra)?Nr(this,ra,ae(this,wa)[e]):Wt(this,$t,Hp).call(this,ae(this,oo)[e],ae(this,wa)[e]),Wt(this,$t,Hp).call(this,ae(this,Ti),e),Nr(this,Ti,e))},ec=function(e,t){var r,n;ki.hasSubscribers&&ki.publish({op:"delete",delete:t,key:e,cache:this});let a=!1;if(ae(this,ni)!==0){let c=ae(this,qs).get(e);if(c!==void 0)if(ae(this,co)?.[c]&&(clearTimeout(ae(this,co)?.[c]),ae(this,co)[c]=void 0),a=!0,ae(this,ni)===1)Wt(this,$t,Wp).call(this,t);else{ae(this,pu).call(this,c);let l=ae(this,Zr)[c];if(Wt(this,$t,ts).call(this,l)?l.__abortController.abort(new Error("deleted")):(ae(this,nl)||ae(this,Aa))&&(ae(this,nl)&&((r=ae(this,Ko))==null||r.call(this,l,e,t)),ae(this,Aa)&&ae(this,Si)?.push([l,e,t])),ae(this,qs).delete(e),ae(this,xs)[c]=void 0,ae(this,Zr)[c]=void 0,c===ae(this,Ti))Nr(this,Ti,ae(this,oo)[c]);else if(c===ae(this,ra))Nr(this,ra,ae(this,wa)[c]);else{let d=ae(this,oo)[c];ae(this,wa)[d]=ae(this,wa)[c];let p=ae(this,wa)[c];ae(this,oo)[p]=ae(this,oo)[c]}Op(this,ni)._--,ae(this,el).push(c)}}if(ae(this,Aa)&&ae(this,Si)?.length){let c=ae(this,Si),l;for(;l=c?.shift();)(n=ae(this,Xo))==null||n.call(this,...l)}return a},Wp=function(e){var t,r;for(let n of Wt(this,$t,Jl).call(this,{allowStale:!0})){let a=ae(this,Zr)[n];if(Wt(this,$t,ts).call(this,a))a.__abortController.abort(new Error("deleted"));else{let c=ae(this,xs)[n];ae(this,nl)&&((t=ae(this,Ko))==null||t.call(this,a,c,e)),ae(this,Aa)&&ae(this,Si)?.push([a,c,e])}}if(ae(this,qs).clear(),ae(this,Zr).fill(void 0),ae(this,xs).fill(void 0),ae(this,lo)&&ae(this,rl)){ae(this,lo).fill(0),ae(this,rl).fill(0);for(let n of ae(this,co)??[])n!==void 0&&clearTimeout(n);ae(this,co)?.fill(void 0)}if(ae(this,tl)&&ae(this,tl).fill(0),Nr(this,ra,0),Nr(this,Ti,0),ae(this,el).length=0,Nr(this,ao,0),Nr(this,ni,0),ae(this,Aa)&&ae(this,Si)){let n=ae(this,Si),a;for(;a=n?.shift();)(r=ae(this,Xo))==null||r.call(this,...a)}},Gp);function P3(e){let t={individual:{},range:[]},r=new WeakMap;for(let n of e)Jm(t,n,r);return t}function Jm(e,t,r){for(let[n,a]of Object.entries(t.individual))if(e.individual[n])gu(e.individual[n],a,r);else{let c=!1;for(let[l,{range:d,entry:p}]of e.range.entries()){let m=Vp(Number(n),d);if(m.both!==null){c=!0,e.individual[n]=a,gu(e.individual[n],Li(p),r),e.range.splice(l,1);for(let x of m.second)Array.isArray(x)?e.range.push({range:x,entry:Li(p)}):e.individual[x]=Li(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=oL(x,d);if(y.both===null)continue;e.range.splice(l,1),l--;let w=Li(p);Array.isArray(y.both)?e.range.push({range:y.both,entry:w}):e.individual[y.both]=w,gu(w,Li(a),r);for(let v of y.second)Array.isArray(v)?e.range.push({range:v,entry:Li(p)}):e.individual[v]=Li(p);c=y.first}else{let y=Vp(x,d);if(y.both===null)continue;e.individual[x]=Li(a),gu(e.individual[x],Li(p),r),e.range.splice(l,1),l--;for(let w of y.second)Array.isArray(w)?e.range.push({range:w,entry:Li(p)}):e.individual[w]=Li(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=Vp(Number(l),p);if(m.both===null)continue;gu(e.individual[l],Li(a),r),c.splice(d,1,...m.second);break}else if(Number(l)===p){gu(e.individual[l],Li(a),r);break}for(let l of c)Array.isArray(l)?e.range.push({range:l,entry:Li(a)}):e.individual[l]=Li(a)}}function gu(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?Jm(e.forward,t.forward,r):e.forward=t.forward),t.reverse&&(e.reverse?Jm(e.reverse,t.reverse,r):e.reverse=t.reverse))}function oL(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 Vp(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 Li(e,t=new Map){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=ax(e.forward,t)),e.reverse&&(r.reverse=ax(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 ax(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=Li(a,t);return{individual:r,range:e.range.map(({range:n,entry:a})=>({range:n.slice(),entry:Li(a,t)}))}}function e1(e,t,r,n){let a=t[n],c=e[a];if(!c)return;let l=c.lookup;if(c.reverse){let p=lL(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=e1(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 lL(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 ox(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 cL(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 uL(e,t){let r=t[0],n=t1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)t1(e,a)!==n&&(a-r<=1?c.set(r,n):c.set([r,a],n)),a++;return a-r<=1?c.set(r,n):c.set([r,a],n),c}function t1(e,t){let r=cL(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 Y1(e,t,r,n,a){let c=[];for(let l of r){l.entry.forward={individual:{},range:[]};for(let d of e)c.push(...Hf(l.entry.forward,n,a,t,d).map(({entry:p,substitution:m})=>({entry:p,substitutions:[...l.substitutions,m]})))}return c}function Uf(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 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.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 Hf(e,t,r,n,a){let c=[];if(!Array.isArray(a))e.individual[a]={},c.push({entry:e.individual[a],substitution:hL(t,r,n,a)});else{let l=dL(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 dL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=uL(c,n);if(!Array.from(l.values()).every(d=>d!==null))return l}return new Map([[n,null]])}function hL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=t1(c,n);if(l!==null)return l}return null}function fL(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=Hf(n,m.lookupRecords,t,0,c).map(({entry:y,substitution:w})=>({entry:y,substitutions:[w]}));for(let[y,w]of m.input.entries())x=Y1([w],y+1,x,m.lookupRecords,t);for(let y of m.lookahead)x=Uf([y],x);for(let y of m.backtrack)x=zf([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 pL(e,t){return e.format===2?Array.isArray(t)?mL(e,t):new Map([[t,r1(e,t)]]):new Map([[t,null]])}function mL(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){for(let r of e.ranges)if(r.start<=t&&r.end>=t)return r.classId;return null}function qp(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 gL(e,t,r){let n=[],a=Nl(e.coverage);for(let{glyphId:c}of a){let l=pL(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=Hf(w,y.lookupRecords,t,0,d).map(({entry:S,substitution:L})=>({entry:S,substitutions:[L]}));for(let[S,L]of y.input.entries())v=Y1(qp(e.inputClassDef,L),S+1,v,y.lookupRecords,t);for(let S of y.lookahead)v=Uf(qp(e.lookaheadClassDef,S),v);for(let S of y.backtrack)v=zf(qp(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 P3(n)}function xL(e,t,r){let n={individual:{},range:[]},a=Nl(e.inputCoverage[0]);for(let{glyphId:c}of a){let l=Hf(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=Y1(Nl(p).map(m=>m.glyphId),d+1,l,e.lookupRecords,t);for(let d of e.lookaheadCoverage)l=Uf(Nl(d).map(p=>p.glyphId),l);for(let d of e.backtrackCoverage)l=zf(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 bL(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=Uf(Nl(p).map(m=>m.glyphId),d);for(let p of e.backtrackCoverage)d=zf(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 n1(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=lx(a,t);for(let{range:n,entry:a}of e.range){let c=lx(a,t);for(let l=n[0];l<n[1];l++)r[l]=c}return r}function lx(e,t){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=n1(e.forward,t)),e.reverse&&(r.reverse=n1(e.reverse,t)),e.lookup&&(r.lookup=e.lookup),r}var yL=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new aL({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(fL(x,n,m));break;case 2:d.push(gL(x,n,m));break;case 3:d.push(xL(x,n,m));break}break;case 8:for(let[m,x]of l.subtables.entries())d.push(bL(x,m));break}let p=n1(P3(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=e1(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)}ox(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=e1(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)}ox(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 vL(e,t){let r=tL.parse(e);return new yL(r,{cacheSize:0,...t})}function wL(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+=AL(t,a);break;case",":r.push(n),n="";break;default:/\s/.test(a)||(t.offset--,n+=TL(t),r.push(n),n="")}}return r}function AL(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+=O3(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 TL(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+=O3(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 O3(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return Yp(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,Yp(t);t+=r}return Yp(t)}function Yp(e){return String.fromCodePoint(parseInt(e,16))}var Sd;async function SL(e,t){if(!Sd){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);Sd=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);Sd=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}Sd??=Promise.resolve({})}let r=await Sd;for(let n of wL(e)){if(CL.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 vL(c,{cacheSize:t})}return}}}var CL=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],_L=1e5;function kL(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;SL(p,_L).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]]):LL(l,t)})}function LL(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 IL=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=kL(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 cx(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 EL=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=cx(r[1]),a=cx(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 F3(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 ux(e,t){const r=F3(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 Wh(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 NL(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 gf(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 RL(e,t,r){const n=zc(e);if(!n)return null;const{start:a,end:c}=gf(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 ML(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=ce=>Math.max(c,Math.min(ce,d)),x=ce=>Math.max(l,Math.min(ce,p)),y=e.selection?F3(e.selection,{left:t,top:r,right:n,bottom:a}):null;if(!y){const ce=m(e.clientX-e.width/2),xe=e.clientY-e.height-e.fingerGap,pe=e.clientY+e.fingerGap,te=x(xe>=l?xe:pe);return{left:Math.round(ce),top:Math.round(te)}}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,W=e.preference?.vertical==="below"?E:R,F=[{left:c,top:l},{left:d,top:l},{left:c,top:p},{left:d,top:p}];e.preference&&F.sort((ce,xe)=>{const pe=te=>{const ke=te.left+e.width/2,$e=te.top+e.height/2;return Math.hypot(ke-e.preference.focusX,$e-e.preference.focusY)};return pe(xe)-pe(ce)});const U=[{left:S-e.width/2,top:B},{left:w-e.width/2,top:B},{left:S-e.width/2,top:W},{left:w-e.width/2,top:W},{left:y.left-e.width-e.fingerGap,top:v-e.height/2},{left:y.right+e.fingerGap,top:v-e.height/2},...F].map(ce=>({left:m(ce.left),top:x(ce.top)}));let V=U[0],Z=Number.POSITIVE_INFINITY;return U.forEach((ce,xe)=>{const pe={left:ce.left,top:ce.top,right:ce.left+e.width,bottom:ce.top+e.height},te=(e.avoid??[]).reduce(($e,Y)=>$e+ux(pe,Y),0),ke=(te>0?1e6:0)+te*100+ux(pe,y)*10+xe*.01;ke<Z&&(V=ce,Z=ke)}),{left:Math.round(V.left),top:Math.round(V.top)}}function jL(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 DL(e){let t=e.parentElement;for(;t;){if(jL(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function BL(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 QL(e,t){return t?.ownedPaste?Gm(e,!1):t?.paste&&/[\r\n]/.test(e)?Gm(e,t.submitAfterPaste??e.endsWith("\r")):e}const dx=2,PL=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function OL(e){const t=e.reason.replace(/^refresh:/,""),r=PL.has(t),n=Math.abs(e.proposedCols-e.currentCols),a=Math.abs(e.proposedRows-e.currentRows);return{accept:r?n>0||a>0:n>=dx||a>=dx,isRealResize:r,colsDelta:n,rowsDelta:a}}function FL(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 $L(e,t){return!e||t}function UL(e,t,r){return e!=="alternate"&&r>=t}function zL(e,t){return e?"none":t?"single":"settled"}function HL(e,t,r){return!r&&(e||t)}function WL(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 Zp(){return{confirmed:null,pending:null,nextSeq:1}}function hx(e,t){return e?.cols===t.cols&&e.rows===t.rows}function Z1(e,t,r){const n={...t,seq:e.nextSeq,attempt:r};return{state:{...e,pending:n,nextSeq:e.nextSeq+1},request:n}}function GL(e,t){return hx(e.pending,t)||!e.pending&&hx(e.confirmed,t)?{state:e,request:null}:Z1(e,t,0)}function VL(e,t){return Z1(e,t,0)}function qL(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 fx(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}:{...Z1(e,n,n.attempt+1),exhausted:!1}}function YL(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 ZL(e){return{...e,pending:null}}const KL=150;function px(e=0){return{lastPushAt:e}}function XL(e,t,r=KL){return t-e.lastPushAt>=r?(e.lastPushAt=t,{action:"send"}):{action:"hold",readyAt:e.lastPushAt+r}}function JL(e){return{lastPushAt:e}}const s1="termdock-settings",eI=6,tI=100,rI='"calt" on',nI=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function sI(){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 K1(){return{fontFamily:"var(--font-mono)",fontSize:sI(),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 dh(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function mx(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function ju(e){const t=K1(),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:dh(r.fontSize,eI,tI,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:mx(r.fontWeight,t.fontWeight),fontWeightBold:mx(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(dh(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:dh(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:dh(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 hh(e){return e.pointerType==="touch"||e.pointerType==="pen"}class iI{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(!hh(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(!hh(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(!hh(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(!hh(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 $3=new iI,aI=90,oI=80,lI=70,cI=(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,W=1.06,F=k.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),U=k.useRef(0),V=k.useRef(0),Z=k.useRef(0),ce=k.useRef(null),xe=k.useRef(0),pe=k.useRef(!1),te=k.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),ke=k.useCallback(()=>{ce.current=null,U.current!==0&&(v&&V.current>0&&Z.current>0?v(U.current,V.current,Z.current):w&&w(U.current),U.current=0,V.current=0,Z.current=0)},[w,v]),$e=k.useCallback(()=>{ce.current===null&&typeof window<"u"&&(ce.current=window.requestAnimationFrame(ke))},[ke]),Y=k.useCallback((Ne,le,He)=>{U.current+=Ne,le!==void 0&&He!==void 0&&(V.current=le,Z.current=He),$e()},[$e]),Ae=k.useCallback(Ne=>{if(!Ne||!w)return!1;const le=w(Ne);return le?xe.current=0:xe.current++,le},[w]),lt=k.useCallback(Ne=>{pe.current!==Ne&&(pe.current=Ne,E?.(Ne))},[E]),Se=k.useCallback(()=>{const Ne=F.current;Ne.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ne.rafId),Ne.rafId=null,ce.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(ce.current),ce.current=null,U.current=0},[]),ye=k.useRef(S);ye.current=S;const _e=k.useRef(L);_e.current=L;const je=k.useRef(x);je.current=x;const re=k.useCallback(()=>{const Ne=e.current;if(!Ne||!("PointerEvent"in window))return()=>{};const le=F.current,He={name:B,priority:lI,get container(){return e.current??void 0},onPointerDown:(ue,Ye)=>(ue.pointerType!=="touch"||(le.pointerId=ue.pointerId,le.startX=Ye.startX,le.startY=Ye.startY,le.didMove=!1,le.gestureAxis=null,le.lastY=ue.clientY,le.lastTime=te(),le.velocity=0,Se()),!1),onPointerMove:(ue,Ye)=>{if(ue.pointerType!=="touch"||le.pointerId!==ue.pointerId||!le.lastY||!le.lastTime)return"neutral";const st=ue.clientX,Ie=ue.clientY,We=te(),Te=We-le.lastTime,H=Ie-le.lastY;if(le.startX!==null&&le.startY!==null){const be=st-le.startX,Ze=Ie-le.startY;if(!le.didMove&&Math.hypot(be,Ze)>=R&&(le.didMove=!0),le.gestureAxis===null&&le.didMove){const Je=Math.abs(be),St=Math.abs(Ze);Je>St*W?le.gestureAxis="x":St>Je*W&&(le.gestureAxis="y")}if(le.gestureAxis==="x")return le.isCurrentlyScrolling=!1,lt(!1),le.lastY=Ie,le.lastTime=We,Ye?"release":"neutral";if(le.gestureAxis===null)return le.lastY=Ie,le.lastTime=We,"neutral"}if(le.gestureAxis==="y"&&!Ye&&!(y?.()??!0))return le.lastY=Ie,le.lastTime=We,lt(!1),"neutral";const oe=H/Math.max(Te,1);if(le.velocity=le.velocity*(1-c)+oe*c,le.velocity=Math.max(-l,Math.min(l,le.velocity)),Math.abs(H)>1){if(!Ye)return lt(!0),le.lastY=Ie,le.lastTime=We,"claim";le.isCurrentlyScrolling=!0;const be=r+Math.min(n,Math.abs(H)/a),Ze=-H*be;Y(Ze,st,Ie),lt(!0)}return le.lastY=Ie,le.lastTime=We,Ye?"claim":"neutral"},onPointerUp:ue=>{if(ue.pointerType!=="touch"||le.pointerId!==ue.pointerId)return;const Ye=le.isCurrentlyScrolling;le.isCurrentlyScrolling=!1,lt(!1);const st=le.rafId!==null||ce.current!==null;!le.didMove&&!st&&le.startX!==null&&le.startY!==null&&ye.current?.(le.startX,le.startY),!le.didMove&&!st&&le.startX!==null&&le.startY!==null&&_e.current?.(le.startX,le.startY),le.pointerId=null,le.startX=null,le.startY=null;const Ie=le.gestureAxis==="x";if(le.gestureAxis=null,m&&Ye&&!Ie&&Math.abs(le.velocity)>d&&le.didMove){const We=()=>{const Te=te(),H=Te-(le.lastTime||Te);if(le.lastTime=Te,le.velocity*=Math.pow(p,H),Math.abs(le.velocity)<d){le.velocity=0,Se();return}if(!Ae(-le.velocity*H)&&xe.current>2){le.velocity=0,Se();return}le.rafId=requestAnimationFrame(We)};le.rafId=requestAnimationFrame(We)}},onPointerCancel:ue=>{ue.pointerType!=="touch"||le.pointerId!==ue.pointerId||(le.isCurrentlyScrolling=!1,lt(!1),le.pointerId=null,le.startX=null,le.startY=null,le.gestureAxis=null,Se())}},rt=$3.register(He),mt=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{lt(!1),rt(),Ne.style.touchAction=mt,Se()}},[e,B,r,n,a,c,l,d,p,te,Se,Ae,Y,R,m,lt,y]),Oe=k.useCallback(()=>{const Ne=e.current;if(!Ne)return()=>{};const le=F.current,He=Ye=>{Ye.touches.length===1&&((x?.()??!0)&&Ye.cancelable&&Ye.preventDefault(),le.isCurrentlyScrolling=!1,le.gestureAxis=null,le.lastY=Ye.touches[0].clientY,le.startX=Ye.touches[0].clientX,le.startY=Ye.touches[0].clientY,le.didMove=!1,le.velocity=0,Se())},rt=Ye=>{if(Ye.touches.length!==1)return;const st=Ye.touches[0].clientX,Ie=Ye.touches[0].clientY;if(le.startX!==null&&le.startY!==null){const Te=st-le.startX,H=Ie-le.startY;if(!le.didMove&&Math.hypot(Te,H)>=R&&(le.didMove=!0),le.gestureAxis===null&&le.didMove){const oe=Math.abs(Te),be=Math.abs(H);oe>be*W?le.gestureAxis="x":be>oe*W&&(le.gestureAxis="y")}if(le.gestureAxis==="x"){le.isCurrentlyScrolling=!1,le.lastY=Ie;return}if(le.gestureAxis===null){(x?.()??!1)&&Ye.cancelable&&Ye.preventDefault(),le.lastY=Ie;return}}if(Ye.preventDefault(),!le.lastY){le.lastY=Ie;return}const We=Ie-le.lastY;if(Math.abs(We)>1){le.isCurrentlyScrolling=!0;const Te=r+Math.min(n,Math.abs(We)/a),H=-We*Te;Y(H,st,Ie)}le.lastY=Ie},mt=Ye=>{if(!Ye.changedTouches?.[0])return;const Ie=le.isCurrentlyScrolling;le.isCurrentlyScrolling=!1;const We=le.rafId!==null||ce.current!==null;!le.didMove&&!We&&S&&le.startX!==null&&le.startY!==null&&S(le.startX,le.startY),!le.didMove&&!We&&L&&le.startX!==null&&le.startY!==null&&L(le.startX,le.startY),le.startX=null,le.startY=null;const Te=le.gestureAxis==="x";if(le.gestureAxis=null,m&&Ie&&!Te&&le.didMove&&Math.abs(le.velocity)>d){const H=()=>{if(le.velocity*=Math.pow(p,16),Math.abs(le.velocity)<d){le.velocity=0,Se();return}if(!Ae(-le.velocity*16)&&xe.current>2){le.velocity=0,Se();return}le.rafId=requestAnimationFrame(H)};le.rafId=requestAnimationFrame(H)}};Ne.addEventListener("touchstart",He,{passive:!1}),Ne.addEventListener("touchmove",rt,{passive:!1}),Ne.addEventListener("touchend",mt,{passive:!1}),Ne.addEventListener("touchcancel",mt,{passive:!1});const ue=Ne.style.touchAction;return Ne.style.touchAction="none",()=>{Ne.removeEventListener("touchstart",He),Ne.removeEventListener("touchmove",rt),Ne.removeEventListener("touchend",mt),Ne.removeEventListener("touchcancel",mt),Ne.style.touchAction=ue,Se()}},[e,r,n,a,d,p,Se,Ae,Y,S,L,R,x,m]),Ce=k.useCallback(()=>{Se();const Ne=typeof window<"u"&&"PointerEvent"in window,le=Ne?re():()=>{},He=Ne?()=>{}:Oe();return()=>{le(),He(),Se()}},[re,Oe,Se]),Ee=k.useCallback(()=>F.current.isCurrentlyScrolling||F.current.rafId!==null||ce.current!==null,[]),Be=k.useCallback(()=>{Se();const Ne=F.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},[Se]);return{setupTouchScroll:Ce,isScrolling:Ee,stopAllScroll:Be}};function gx(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 $3.register(p)},[t,r])}var $s;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})($s||($s={}));$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;const uI=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",dI=()=>typeof document<"u"&&!!document.body,hI=()=>{if(dI())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{}},xx=e=>Array.isArray(e)?[...e]:[e],fI=e=>{if(uI()){try{const a=xx(e),c=a.length===1?a[0]:a;navigator.vibrate(c)}catch{}return}const t=xx(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(hI,n),n+=a+c},po=e=>fI(e);function U3({message:e}){const{t}=zr();return s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-4",children:s.jsx(d0,{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 pI(){const{t:e}=zr();return s.jsx(U3,{message:e("terminal.initializing")})}const mI=({message:e,onRetry:t})=>{const{t:r}=zr();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 Gh(e){return Array.from(e)}function bx(e,t,r){return Math.max(t,Math.min(r,e))}function gI(e,t,r,n){const a=Gh(e),c=Gh(t);let l=bx(r,0,a.length);const d=bx(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+=Gh(y).length)}return l>d?w.push({left:l-d}):l<d&&w.push({right:d-l}),l=d,{ops:w,cursor:l}}function yx(e){const t=e.value,r=e.selectionStart??t.length;return Gh(t.slice(0,r)).length}const xf=16,xI=10,vx=1.5,bI=1.8,wx=240,yI=125,vI=92;function wI(e,t,r){const n=Math.hypot(e,t),a=Math.abs(e),c=Math.abs(t),l=()=>a>=c*vx?e>0?"right":"left":c>=a*vx?t>0?"down":"up":"";if(r==="")return n>xf?l():"";if(n<xI)return"";if(n<=xf)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)*bI?d:r}function AI(e){const t=vI-xf,r=Math.min(Math.max((e-xf)/t,0),1);return wx-r*(wx-yI)}const TI="termdock-open-terminal-directory",i1=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?:,;!?。、“”‘’])+/gu,SI=new RegExp(`^( *)(${i1.source})`,"u"),CI=/[,;:!?]+$/u,_I=/^[a-z][a-z\d+.-]*:\/\//iu;function kI(e){return!e||e==="/"||_I.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function z3(e){const t=[];i1.lastIndex=0;let r;for(;(r=i1.exec(e))!==null;){const a=r[0].replace(CI,"");if(!kI(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 Kp(e){const t=[];for(const r of e.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return`/${t.join("/")}`}function LI(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function II(e,t){const r=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(r.startsWith("/"))return Kp(r);if(r==="~"||r.startsWith("~/")){const n=t?LI(t):null;return n?Kp(`${n}/${r.slice(2)}`):null}return t?.startsWith("/")?Kp(`${t}/${r}`):null}function fh(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=z3(a).at(-1),d=c.match(SI);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 EI(e,t){const r=e.buffer.active;let n=t-1;if(!r.getLine(n))return null;for(;n>0&&(r.getLine(n)?.isWrapped||fh(e,n)!==null);)n-=1;let a=t-1;for(;a+1<r.length&&(r.getLine(a+1)?.isWrapped||fh(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?fh(e,m)??0:0;let w=x.length;if(m<a&&fh(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 NI(e,t){return{provideLinks(r,n){const a=EI(e,r);if(!a){n(void 0);return}const c=z3(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 Ax(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 Tx(e,t=e.rows){const n=e._core?._bufferService?.buffers;return n?Ax(n.normal,t)+Ax(n.alt,t):0}function ph(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function RI(e,t,r){const n=ph(e.fontBoundingBoxAscent)+ph(e.fontBoundingBoxDescent),a=ph(e.actualBoundingBoxAscent)+ph(e.actualBoundingBoxDescent);return Math.max(1,Math.floor(Math.ceil(n||a||t)*r))}const Ec=8,mh=36,Sx=10,MI=1.08,jI=1.16,gh=6,DI=.94,BI=.08,QI=.12,PI=88,OI=36,FI=10,$I=14,UI=52;function Cd(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 zI=80,HI=8;function xh(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function WI(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function GI(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 VI(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=GI(m);x!==null&&navigator.clipboard?.writeText(x).catch(()=>{})}}r=c+l}return{cleaned:n,remainder:""}}function qI(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 YI=new Set(["visibility","bfcache","online"]),ZI=5e5,KI=1e5,_d=260,kd=140,Cx=80;function XI(e){return!e}let xu=null;const JI=[{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:"⏺⏸⏹✓✗"}],eE=()=>{if(xu)return xu;if(typeof document>"u"||!("fonts"in document))return xu=Promise.resolve(),xu;const e=document.fonts;return xu=Promise.allSettled(JI.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),xu},_x=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 kx(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 tE(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 Lx=new Map;function rE(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=Lx.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=RI(v,r,a);L>=1&&E>=1&&(p={cellWidth:L,cellHeight:E},Lx.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 Ix(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 nE(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 Ld(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 Xp(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 Ex(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function sE(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=Ex("--safe-top-inset"),y=Ex("--safe-bottom-inset"),w=n?RL(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}=gf(n.anchor,n.focus,n.terminal.cols),W=Wh(n.terminal,R),F=Wh(n.terminal,B);if(W&&v.push({left:W.x-24,top:W.y-48,right:W.x+24,bottom:W.y+4}),F&&E){const U=F.y+E.cellH;v.push({left:F.x-24,top:U-4,right:F.x+24,bottom:U+48})}if(w){const U=n.anchor.row*n.terminal.cols+n.anchor.col,V=n.focus.row*n.terminal.cols+n.focus.col,Z=U<=V,ce=w.right-w.left,pe=n.anchor.row===n.focus.row?Z?w.left+ce*.25:w.right-ce*.25:(w.left+w.right)/2,te=Wh(n.terminal,n.focus),ke=te&&E?te.y+E.cellH/2:t;S={vertical:n.focus.row<n.anchor.row?"below":"above",alignX:pe,focusX:te?.x??e,focusY:ke}}}const L=ML({clientX:e,clientY:t,viewport:{left:l,top:d+x,right:l+p,bottom:d+m-y},terminal:r,width:PI,height:OI,margin:FI,fingerGap:$I,selection:w,avoid:v,preference:S,selectionGap:UI});return{left:L.left-r.left,top:L.top-r.top}}const H3=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:W,theme:F,className:U,enableTouchScroll:V,mobileLongPressMode:Z="arrows",autoFocus:ce=!0,cursorVisible:xe=!0,suppressSmoothScroll:pe=!1},te)=>{const{t:ke}=zr(),$e=k.useRef(null),Y=k.useRef(null),Ae=k.useRef(null),lt=k.useRef(null),Se=k.useRef(null),ye=k.useRef(pe);ye.current=pe;const _e=k.useRef(null),je=k.useRef(a),re=k.useRef(c),Oe=k.useRef(x),Ce=k.useRef(l),Ee=k.useRef(v);Ee.current=v;const Be=k.useRef(S);Be.current=S;const Ne=k.useRef(L);Ne.current=L;const le=k.useRef(E);le.current=E;const He=k.useRef(R);He.current=R;const rt=k.useRef(B);rt.current=B;const mt=k.useRef(W.rendererMode),ue=k.useRef(""),Ye=k.useRef(0),st=k.useRef(!1),Ie=k.useRef(null),We=k.useRef(0),Te=k.useRef(0),H=k.useRef(!1),oe=k.useRef(null),be=k.useRef(null),Ze=k.useRef(null),Je=k.useRef(!1),St=k.useRef(null),Vt=k.useRef(()=>{}),jt=k.useRef(null),vt=k.useRef(null),Zt=k.useRef(void 0),Pt=k.useRef(null),Xt=k.useRef(!1),zt=k.useRef(0),Lt=k.useRef(""),me=k.useRef(null),Ge=k.useRef(null),pt=k.useRef(!1),q=k.useRef(typeof window<"u"?window.devicePixelRatio:1),at=k.useRef(!1),qt=k.useRef(!1),Ve=k.useRef(null),De=k.useRef(""),er=k.useRef(0),et=k.useRef(null),Ct=k.useRef(null),Nt=k.useRef(null),gt=k.useRef(0),bt=k.useRef(0),It=k.useRef(0),yt=k.useRef(null),pr=k.useRef(0),nr=k.useRef(0),Cr=k.useRef(!1),cn=k.useRef(0),[,Lr]=k.useReducer(T=>T+1,0),[ge,Vr]=k.useReducer(T=>T+1,0),[it,dt]=k.useState("loading"),[sr,xn]=k.useState(null),[an,Me]=k.useState(null);k.useEffect(()=>{const T=j=>{(j.target instanceof Element?j.target.closest("[data-termdock-terminal-dropzone]"):null)?.dataset.termdockTerminalDropzone===e&&Me(String(j.detail))};return window.addEventListener("termdock:file-drop-error",T),()=>window.removeEventListener("termdock:file-drop-error",T)},[e]);const nt=k.useMemo(()=>Qu("terminal"),[]),[wt,Rr]=k.useState(!0),[rn,Ir]=k.useState(!1);k.useEffect(()=>{if(!wt&&it!=="loading"){Ir(!1);return}const T=window.setTimeout(()=>Ir(!0),160);return()=>window.clearTimeout(T)},[wt,it]);const[ne,ht]=k.useState(!1),[Ht,Ot]=k.useState({visible:!1,activeDir:""}),[Tr,mr]=k.useState(null),Hr=k.useRef(null),_n=k.useRef(!1),dr=k.useRef({active:!1,anchor:null,focus:null,dragging:null}),[bn,hn]=k.useState(null),[Tn,ir]=k.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),pn=k.useRef(Tn);pn.current=Tn;const Pr=k.useRef(null),[qr,Wr]=k.useState({active:!1,text:""}),fs=k.useRef(null),Br=k.useRef(null);je.current=a,re.current=c,Oe.current=x,Ce.current=l,mt.current=W.rendererMode;const Mn=k.useRef(ce);Mn.current=ce;const Sr=k.useRef(xe);Sr.current=xe;const Kr=k.useRef(V);Kr.current=V;const nn=k.useRef(r);nn.current=r;const ks=XI(!!d),{rendererMode:Or,fontFamily:Xr,fontSize:fn,fontWeight:K,fontWeightBold:Ue,letterSpacing:Et,lineHeight:kt,minimumContrastRatio:tr,drawBoldTextInBrightColors:Qr,unicodeVersion:cr,customGlyphs:Sn,rescaleOverlappingGlyphs:Ls,fontLigatures:Zn,enableImages:sn,smoothScrolling:on}=W,_r=Or==="webgl",$r=k.useCallback(()=>{Hr.current!==null&&(clearTimeout(Hr.current),Hr.current=null),mr(null)},[]),Wn=k.useCallback((T,j)=>{Hr.current!==null&&(clearTimeout(Hr.current),Hr.current=null),_n.current=!1,mr(T),!j?.persistent&&(Hr.current=setTimeout(()=>{Hr.current=null,mr(null)},3e3))},[]);k.useEffect(()=>{if(!Tr)return;const T=()=>{dr.current.active||$r()},j=()=>$r();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)}},[$r,Tr]),k.useEffect(()=>()=>{Hr.current!==null&&(clearTimeout(Hr.current),Hr.current=null)},[]);const Gn=k.useCallback(()=>{const T=Ae.current,j=$e.current,Q=dr.current;if(!T||!j||!Q.active||!Q.anchor||!Q.focus){hn(null);return}const O=j.getBoundingClientRect(),fe=zc(T)?.cellH??16,{start:we,end:Pe}=gf(Q.anchor,Q.focus,T.cols),Xe=Q.dragging==="start"?Q.focus:Q.dragging==="end"?Q.anchor:we,ft=Q.dragging==="end"?Q.focus:Q.dragging==="start"?Q.anchor:Pe,Jt=(or,Ur)=>{const Jr=Wh(T,or);return Jr?{left:Jr.x-O.left,top:Ur?Jr.y-O.top:Jr.y+fe-O.top}:null};hn({start:Jt(Xe,!0),end:Jt(ft,!1)})},[]),un=k.useCallback(T=>{const j=Ae.current,Q=$e.current,O=dr.current;if(!j||!Q||!O.active||!O.anchor||!O.focus)return;if(O.dragging){$r();return}const fe=Q.getBoundingClientRect(),we={x:(fe.left+fe.right)/2,y:(fe.top+fe.bottom)/2};Wn(sE(T?.x??we.x,T?.y??we.y,fe,{terminal:j,anchor:O.anchor,focus:O.focus},T!==void 0),{persistent:!0})},[$r,Wn]),Kn=k.useCallback(()=>{const T=dr.current;T.active=!1,T.anchor=null,T.focus=null,T.dragging=null,hn(null),$r()},[$r]);k.useEffect(()=>{if(!bn)return;const T=Ae.current;if(!T)return;const j=T.onScroll(()=>{Gn(),un()}),Q=T.onResize(()=>Kn());return()=>{j.dispose(),Q.dispose()}},[bn,Gn,un,Kn]),k.useEffect(()=>{V||Oe.current?.(!1)},[V]);const kr=k.useCallback((T,j,Q)=>{const O=(Q.element?.offsetWidth||0)/Q.cols||8,fe=(Q.element?.offsetHeight||0)/Q.rows||16,we=Math.max(1,Math.min(Q.cols,Math.floor(T/O)+1)),Pe=Math.max(1,Math.min(Q.rows,Math.floor(j/fe)+1));return{x:we,y:Pe}},[]),Er=k.useCallback((T,j,Q)=>{const O=Ae.current;if(!O)return!1;const fe=T>0?-1:1;if(O.modes?.mouseTrackingMode!=="none"){let we,Pe;if(j!==void 0&&Q!==void 0){const Jt=kr(j,Q,O);we=Jt.x,Pe=Jt.y}else we=O.buffer.active.cursorX+1,Pe=O.buffer.active.cursorY+1;const ft=`\x1B[<${fe>0?64:65};${we};${Pe}M`;return je.current(ft),!0}if(O.buffer.active.type==="alternate"){const we=fe>0?"\x1B[A":"\x1B[B";return je.current(we),!0}return null},[kr]),gr=k.useCallback(T=>{const j=Ae.current;if(!j)return!1;const Q=Nc(Ae.current,fn,kt),O=zt.current+T,fe=Math.trunc(O/Q);return zt.current=O-fe*Q,fe!==0?(j.scrollLines(fe),!0):!1},[fn,kt]),rs=k.useCallback(T=>{if(!Ae.current)return!1;const O=Nc(Ae.current,fn,kt)/Math.max(.1,p),fe=zt.current+T;let we=Math.trunc(fe/O);if(zt.current=fe-we*O,we===0&&Math.abs(fe)>=O/3&&(we=fe>0?1:-1,zt.current=0),we===0)return!1;const Pe=we>0?"down":"up",Xe=Math.max(1,Math.min(Math.abs(we),10));return d(Pe,Xe),!0},[fn,kt,d,p]),$n=k.useRef(Er);$n.current=Er;const kn=k.useRef(gr);kn.current=gr;const Ln=k.useRef(rs);Ln.current=rs;const ps=k.useRef(d);ps.current=d;const G=k.useRef({pointerId:null,tmuxActiveAtDown:!1});k.useEffect(()=>{if(!V)return;const T=$e.current;if(!T)return;const j=O=>{O.pointerType==="touch"&&(G.current.pointerId=O.pointerId,G.current.tmuxActiveAtDown=!!ps.current)},Q=O=>{O.pointerType==="touch"&&G.current.pointerId===O.pointerId&&(G.current.pointerId=null,G.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 Le=k.useCallback(()=>{if(Cr.current)return!1;const T=G.current;return T.pointerId!==null?!T.tmuxActiveAtDown:!ps.current},[]),Ke=k.useCallback((T,j,Q)=>{const O=$n.current(T,j,Q);return O!==null?O:ps.current?Ln.current(T):kn.current(T)},[]),ct=k.useCallback((T,j)=>{if(performance.now()<=nr.current){nr.current=0;return}const Q=Ae.current;if(Q&&Q.modes?.mouseTrackingMode!=="none"){const O=kr(T,j,Q),fe=O.x,we=O.y,Pe=`\x1B[<0;${fe};${we}M`,Xe=`\x1B[<0;${fe};${we}m`;je.current(Pe),je.current(Xe)}},[kr]),qe=k.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),At=k.useCallback((T=700)=>{yt.current=null,pr.current=qe()+T},[qe]),Rt=k.useCallback(()=>Kr.current&&qe()<=pr.current,[qe]),Bt=k.useCallback(()=>{const T=vt.current;return!T||typeof document>"u"?!1:document.activeElement===T},[]),ot=k.useCallback(()=>{if(typeof window>"u")return!1;const T=Xe=>{if(typeof document>"u")return 0;const ft=Number.parseFloat(document.documentElement.style.getPropertyValue(Xe)||"0");return Number.isFinite(ft)?ft:0},j=T("--kb-height");if(j>0)return j>=Cx;const Q=window.visualViewport;if(!Q)return!1;const O=T("--app-base-vh")||window.innerHeight,fe=T("--safe-bottom-inset"),we=Q.height+Q.offsetTop;return Math.max(0,Math.round(O-we-fe))>=Cx},[]),Ft=k.useCallback(()=>{et.current!==null&&(clearTimeout(et.current),et.current=null),Ct.current=null},[]),hr=k.useCallback(T=>{const j=Ae.current;let Q="";for(const O of T)O.left&&(Q+=(j?xh(j,"D"):"\x1B[D").repeat(O.left)),O.right&&(Q+=(j?xh(j,"C"):"\x1B[C").repeat(O.right)),O.backspace&&(Q+="".repeat(O.backspace)),O.insert&&(Q+=O.insert);return Q},[]),Kt=k.useCallback(T=>{const j=T.value,Q=Cd(j),O=De.current;if(!(Kr.current&&!Q.includes("\r")&&!O.includes("\r"))){if(Q===O)return;let Jt=0;for(;Jt<O.length&&Jt<Q.length&&O[Jt]===Q[Jt];)Jt++;const or=O.length-Jt;or>0&&je.current("".repeat(or));const Ur=Q.slice(Jt);if(Ur){try{Ae.current?.clearSelection()}catch{}je.current(Ur)}De.current=Q,er.current=Array.from(Q).length;return}const we=yx(T),{ops:Pe,cursor:Xe}=gI(O,Q,er.current,we),ft=hr(Pe);if(ft){if(Pe.some(Jt=>Jt.insert))try{Ae.current?.clearSelection()}catch{}je.current(ft)}De.current=Q,er.current=Xe},[hr]),z=k.useCallback((T,j)=>{const Q=T.value,O=Cd(Q),fe=De.current;if(O===fe){Ft();return}let we=0;for(;we<fe.length&&we<O.length&&fe[we]===O[we];)we++;const Pe=fe.length-we;if(V&&!j?.immediate&&Pe>=HI){Ct.current=T,et.current!==null&&clearTimeout(et.current),et.current=setTimeout(()=>{et.current=null;const ft=Ct.current;Ct.current=null,ft&&Kt(ft)},zI);return}Ft(),Kt(T)},[Ft,V,Kt]),N=k.useCallback(T=>{z(T,{immediate:!0}),je.current("\r"),T.value="",De.current="",er.current=0},[z]),$=k.useCallback((T,j,Q)=>{if(!T)return;Ft();const O=j??vt.current;O&&(O.value=""),De.current="",er.current=0;try{Ae.current?.clearSelection()}catch{}Kn();const fe=QL(T,Q);return je.current(fe,{skipModifierTransform:!0,consumeModifier:Q?.consumeModifier,targeted:Q?.targeted,ownedPaste:Q?.ownedPaste})},[Ft]),ee=k.useCallback((T,j)=>{const Q=Cd(T);return Q?(Me(null),vp(Q)||($(Q,j,{paste:!0,submitAfterPaste:!1}),$r()),!0):!1},[$r,$]);k.useEffect(()=>Z8(T=>{if(T.sessionKey!==e||T.paths.length===0)return;const j=T.paths.map(Dc).join(" ");$(`${j} `);try{vt.current?.focus({preventScroll:!0})}catch{}}),[$,e]);const ie=k.useCallback(async(T,j)=>{Me(null);try{const Q=await t3(T);return vp(`${Dc(Q)} `)||($(`${Dc(Q)} `,j),$r()),!0}catch(Q){return Me(Q instanceof Error?Q.message:"Image upload failed"),!1}},[$r,$]),Qe=k.useCallback(async(T,j)=>{Me(null);try{const Q=await s3(T);if(!Q.length)return!1;const O=`${Q.map(Dc).join(" ")} `;return vp(O)||($(O,j),$r()),!0}catch(Q){return Me(Q instanceof Error?Q.message:"File upload failed"),!1}},[$r,$]),ze=k.useCallback(async(T,j)=>{Me(null);try{const Q=u0()?.targetPeerId;let O;if(xo()?.readClipboardFiles){try{const{files:Pe,paths:Xe}=await n3();if(Xe.length)return ee(`${Xe.map(Dc).join(" ")} `,T);if(Pe.length)return Qe(Pe,T)}catch(Pe){if(Pe instanceof s0)throw Pe;O=Pe}if(u0()?.targetPeerId!==Q)throw new Error("目标服务已切换,请重新粘贴")}if(j?.files.length){const Pe=j.files[0];return j.files.length===1&&Pe.type.startsWith("image/")?ie(Pe,T):Qe(j.files,T)}if(j?.text)return ee(j.text,T);if(!xo()?.readClipboardImage){if(typeof navigator.clipboard?.read=="function"){const Pe=await navigator.clipboard.read(),Xe=await r3({read:async()=>Pe});if(Xe.length)return Qe(Xe,T);const ft=await hf({read:async()=>Pe});if(ft)return ie(ft,T);for(const Jt of Pe){if(!Jt.types.includes("text/plain"))continue;const or=await(await Jt.getType("text/plain")).text();return ee(or,T)}return Me("剪贴板未提供可读取的文字、图片或视频;视频可通过文件按钮选择上传。"),!1}return navigator.clipboard?.readText?ee(await navigator.clipboard.readText(),T):!1}const fe=await hf(navigator.clipboard);if(fe)return ie(fe,T);if(!navigator.clipboard?.readText){if(O)throw O;return!1}const we=await navigator.clipboard.readText();if(!we&&O)throw O;return ee(we,T)}catch(Q){return Me(Q instanceof Error?Q.message:"Clipboard read failed"),!1}},[Qe,ie,ee]),xt=k.useCallback(T=>{if(Pr.current&&!T?.repositionFrozen)return null;const j=Ae.current;if(!j||!j.element)return null;const Q=zc(j),fe=j.element.querySelector(".xterm-screen")??j.element,we=fe.getBoundingClientRect(),Pe=Q?.cellW??(we.width>0&&j.cols>0?we.width/j.cols:8),Xe=Q?.cellH??(we.height>0&&j.rows>0?we.height/j.rows:17),ft=vt.current;let Jt=Zt.current;ft&&(Jt===void 0||Jt!==null&&(!Jt.isConnected||!Jt.contains(ft)))&&(Jt=DL(ft),Zt.current=Jt);const or=j.buffer.active,Ur=or.cursorX*Pe,Jr=or.cursorY*Xe,Qn=BL(fe,Jt??null,Ur,Jr),vr=Math.round(Qn.x),yn=Math.round(Qn.y),cs={x:vr,y:yn,cellW:Pe,cellH:Xe,cursorX:or.cursorX};return pn.current=cs,Pr.current&&T?.repositionFrozen&&(Pr.current={...cs}),ir(js=>Math.abs(js.x-vr)<.5&&Math.abs(js.y-yn)<.5&&Math.abs(js.cellW-Pe)<.5&&Math.abs(js.cellH-Xe)<.5&&js.cursorX===or.cursorX?js:cs),cs},[]),_t=k.useRef(xt);_t.current=xt,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,_t.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 Mr=k.useCallback(T=>{let j=0;for(const Q of T){const O=Q.codePointAt(0)??0,fe=O>=4352&&O<=4447||O>=11904&&O<=12350||O>=12353&&O<=13311||O>=13312&&O<=19903||O>=19968&&O<=40959||O>=40960&&O<=42191||O>=44032&&O<=55203||O>=63744&&O<=64255||O>=65072&&O<=65103||O>=65280&&O<=65376||O>=65504&&O<=65510||O>=127744&&O<=129791;j+=fe?2:1}return j},[]),Dt=k.useCallback(T=>{const j=Ae.current,{cellW:Q,cellH:O}=Tn;if(!j||!T)return{width:Math.max(1,Math.round(Q)),height:Math.max(1,Math.round(O)),whiteSpace:"pre"};const we=Pr.current?.cursorX??j.buffer.active.cursorX,Pe=Math.max(1,j.cols),Xe=Math.max(1,Mr(T)),ft=Math.max(1,Pe-we);if(Xe<=ft)return{width:Math.max(1,Math.round(Xe*Q)),height:Math.max(1,Math.round(O)),whiteSpace:"pre"};const Jt=Xe-ft,Ur=1+Math.ceil(Jt/Pe);return{width:Math.max(1,Math.round(ft*Q)),height:Math.max(1,Math.round(Ur*O)),whiteSpace:"pre-wrap"}},[Tn,Mr]),Gr=k.useCallback(()=>{Zt.current=void 0;const T=_t.current();Pr.current={...T??pn.current}},[]),dn=k.useCallback(()=>{Pr.current=null},[]),jn=k.useCallback(T=>{if(!at.current&&Pr.current===null)return!1;if(at.current=!1,Pr.current=null,Ft(),Ve.current!==null&&(clearTimeout(Ve.current),Ve.current=null),qt.current=!1,T){T.value=De.current;try{T.setSelectionRange(T.value.length,T.value.length)}catch{}}return Wr(j=>j.active||j.text?{active:!1,text:""}:j),!0},[Ft]),ns=k.useCallback((T,j)=>{const Q=vt.current;if(Q)try{Q.removeAttribute("readonly");const fe=typeof document<"u"&&document.activeElement===Q&&!ot(),we=qe(),Pe=we-cn.current;cn.current=we,fe&&Pe>600?(Q.blur(),Q.removeAttribute("readonly"),Q.focus(),cn.current=qe()):Q.focus()}catch{}},[ot,qe]),Un=k.useCallback(T=>{bt.current=qe()+T},[qe]),fr=k.useCallback(()=>V?qe()<=bt.current:!1,[V,qe]),Mt=k.useCallback(T=>{Un(T),It.current=qe()},[Un,qe]),Dn=k.useCallback(()=>{V&&vt.current?.removeAttribute("readonly")},[V]),Vn=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),[]),Ha=k.useCallback(T=>{if(Dn(),Mt(_d),!V||T.pointerType!=="touch"){yt.current=null;return}const j=T.target;if(Vn(j)){At();return}Tr&&!(j instanceof HTMLElement&&j.closest('[data-terminal-copy-popover="true"]'))&&$r(),yt.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,moved:!1}},[$r,V,Mt,Vn,Tr,Dn,At]),Bn=k.useCallback(T=>{Mt(_d);const j=yt.current;!j||j.pointerId!==T.pointerId||Math.hypot(T.clientX-j.startX,T.clientY-j.startY)>12&&(j.moved=!0)},[Mt]),ss=k.useCallback(T=>{Mt(kd);const j=yt.current;yt.current=null,!(!V||T.pointerType!=="touch")&&(!j||j.pointerId!==T.pointerId||j.moved||Rt()||ns(T.clientX,T.clientY))},[V,Mt,ns,Rt]),$i=k.useCallback(()=>{yt.current=null,Mt(kd)},[Mt]),ua=k.useMemo(()=>({enableKinetic:!0}),[]),bs=k.useRef(()=>!1),Wa=k.useRef(ns);Wa.current=ns;const wo=k.useCallback((T,j)=>{Rt()||Wa.current(T,j)},[Rt]),zn=k.useRef(m);zn.current=m;const da=k.useRef(y);da.current=y;const ms=k.useRef(w);ms.current=w;const La=k.useCallback(()=>{if(_n.current)return;_n.current=!0,At();const T=Ae.current,j=T?.hasSelection()?T.getSelection():"";try{T?.clearSelection()}catch{}Ii.flushSync(()=>{Kn()}),(async()=>{const Q=await Ix(j);da.current?.(Q)})()},[Kn,At]),is=k.useCallback(T=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:T}}))},[]),{setupTouchScroll:Ga,stopAllScroll:Ks}=cI($e,{...ua,shouldCaptureTouch:bs.current,canStartScrollGesture:Le,onScroll:Ke,onScrollWithCoords:Ke,onClickWithCoords:ct,onTap:wo,onClaimChange:is,tapThreshold:12,gestureName:`normal-scroll:${e}`});k.useEffect(()=>{if(!V)return;vt.current?.setAttribute("readonly","");const T=Ga();return()=>{T()}},[V,Ga]),k.useEffect(()=>{if(!V)return;let T=ot();const j=()=>{const Q=ot();if(T&&!Q){const O=vt.current;O&&typeof document<"u"&&document.activeElement===O&&(O.setAttribute("readonly",""),O.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,ot]),k.useEffect(()=>{if(!V)return;const T=$e.current;if(!T)return;const j=O=>{const we=O.sourceCapabilities?.firesTouchEvents===!0,Pe=qe()-It.current<=1200;return!we&&!Pe?!1:T.contains(O.target)},Q=O=>{j(O)&&(O.cancelable&&O.preventDefault(),O.stopImmediatePropagation(),O.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,qe]);const Xs=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=Xs.current;T.rafId!==null&&(cancelAnimationFrame(T.rafId),T.rafId=null)},[]),Va=k.useCallback((T,j,Q)=>{const O=Ae.current;if(!O||!O.element||!O.cols||!O.rows)return null;const fe=Xs.current,we=O.element.getBoundingClientRect(),Pe=j??fe.lastX??we.left+we.width/2,Xe=Q??fe.lastY??we.top+we.height/2,ft=Pe-we.left,Jt=Xe-we.top,or=O.element.offsetWidth/O.cols||8,Ur=O.element.offsetHeight/O.rows||16,Jr=Math.max(1,Math.min(O.cols,Math.floor(ft/or)+1)),Qn=Math.max(1,Math.min(O.rows,Math.floor(Jt/Ur)+1));return`\x1B[<${T==="up"?64:65};${Jr};${Qn}M`},[]),Is=k.useCallback((T,j,Q,O)=>{if(j<=0)return;const fe=Va(T,Q,O);fe&&je.current(j===1?fe:fe.repeat(j))},[Va]),ha=k.useRef(Is);ha.current=Is;const dl=k.useRef(()=>{}),qa=k.useCallback(()=>{const j=Nc(Ae.current,fn,kt)/Math.max(.1,p),Q=1+Xs.current.instantSpeed*.1;return j/Math.min(6,Q)},[fn,kt,p]),as=k.useCallback(()=>{const T=Xs.current;T.rafId=null;const j=qa();let Q=0,O=0;for(;Q+O<gh&&T.remainder>=j;)T.remainder-=j,O++;for(;Q+O<gh&&T.remainder<=-j;)T.remainder+=j,Q++;if(O>0&&Is("down",O),Q>0&&Is("up",Q),Q+O>0)T.rafId=requestAnimationFrame(as);else if(T.pointerId!==null&&Math.abs(T.remainder)>=j/3){const we=T.remainder>0?"down":"up";T.remainder=0,Is(we,1),T.rafId=requestAnimationFrame(as)}},[qa,Is]),Rs=k.useCallback(()=>{const T=Xs.current;T.rafId===null&&typeof requestAnimationFrame<"u"&&(T.rafId=requestAnimationFrame(as))},[as]),Ui=k.useCallback(T=>{if(T.pointerType!=="touch")return!1;Hs();const j=Xs.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]),gi=k.useCallback((T,j)=>{if(Cr.current)return j?"release":"neutral";if(performance.now()<=nr.current)return"neutral";const Q=Xs.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 we=Math.abs(T.clientX-Q.startX),Pe=Math.abs(T.clientY-Q.startY);if(we>Sx||Pe>Sx){if(we>Pe*MI)return Q.gestureAxis="x","release";Pe>we*jI&&(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 O=T.clientY-Q.lastY;Q.lastX=T.clientX,Q.lastY=T.clientY;const fe=-O;if(Q.remainder+=fe,Q.instantSpeed=Math.abs(fe),Q.velocity=Q.velocity*.45+fe*.55,j){const Pe=Nc(Ae.current,fn,kt)/Math.max(.1,p);Math.abs(Q.remainder)>=Pe/3&&(Q.didScroll=!0,Rs())}return"claim"},[fn,kt,p,Rs]),xi=k.useCallback(T=>{const j=Xs.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 O=Nc(Ae.current,fn,kt)/Math.max(.1,p);if(j.didScroll&&Math.abs(j.velocity)>O*BI){const fe=()=>{j.velocity*=DI,j.remainder+=j.velocity;const we=1+Math.abs(j.velocity)*.1,Pe=O/Math.min(6,we);if(Math.abs(j.velocity)<O*QI){if(Math.abs(j.remainder)>=Pe/3){const Jt=j.remainder>0?"down":"up";Is(Jt,1),j.remainder=0}j.velocity=0,j.rafId=null;return}let Xe=0,ft=0;for(;Xe+ft<gh&&j.remainder>=Pe;)j.remainder-=Pe,ft++;for(;Xe+ft<gh&&j.remainder<=-Pe;)j.remainder+=Pe,Xe++;ft>0&&Is("down",ft),Xe>0&&Is("up",Xe),j.rafId=requestAnimationFrame(fe)};j.rafId=requestAnimationFrame(fe)}else Math.abs(j.remainder)>=O/3&&Rs();j.didScroll&&T.stopImmediatePropagation()},[Hs,Is,Rs,p,fn,kt]),hl=k.useCallback(T=>{const j=Xs.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]);gx({name:`tmux-scroll:${e}`,priority:oI,container:()=>$e.current,onPointerDown:V&&d?Ui:void 0,onPointerMove:V&&d?gi:void 0,onPointerUp:V&&d?xi:void 0,onPointerCancel:V&&d?hl:void 0});const Js=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=$e.current;const fa=Uo,fl=je,pl=k.useRef(Z);pl.current=Z;const os=k.useCallback(T=>{const j=Js.current;j.gestureLocked!==T&&(j.gestureLocked=T,is(T))},[is]),Ms=k.useCallback(()=>{const T=Js.current;T.edgeScrollTimer!==null&&(clearInterval(T.edgeScrollTimer),T.edgeScrollTimer=null),T.edgeScrollDir=0},[]),Ni=k.useCallback(T=>{const j=Ae.current,Q=Js.current;if(j){if(Q.mode==="copy"&&Q.copyStart){Q.copyDidSelect=Xp(j,Q.copyStart,T)||Q.copyDidSelect;return}if(Q.mode==="adjust"){const O=dr.current;if(!O.active||!O.anchor)return;O.focus=NL(j,T),Xp(j,O.anchor,O.focus),Gn()}}},[Gn]),zo=k.useCallback((T,j)=>{const Q=Ae.current,O=Js.current;if(!Q)return;const fe=zc(Q);if(!fe)return;const we=fe.originTop,Pe=fe.originTop+Q.rows*fe.cellH,Xe=Math.max(28,fe.cellH*1.5),ft=j-we,Jt=Pe-j;let or=0,Ur=0;if(ft<Xe?(or=-1,Ur=Math.min(1,(Xe-ft)/Xe)):Jt<Xe&&(or=1,Ur=Math.min(1,(Xe-Jt)/Xe)),O.edgeClientX=T,O.edgeClientY=j,or===0){Ms();return}O.edgeScrollDir=or,O.edgeScrollLines=1+Math.round(Ur*5),O.edgeScrollTimer===null&&(O.edgeScrollTimer=setInterval(()=>{const Jr=Ae.current,Qn=Js.current;if(!Jr||Qn.edgeScrollDir===0)return;if(Qn.mode!=="copy"&&Qn.mode!=="adjust"){Ms();return}Jr.scrollLines(Qn.edgeScrollDir*Qn.edgeScrollLines);const vr=Ld(Jr,Qn.edgeClientX,Qn.edgeClientY-mh);vr&&Ni(vr)},60))},[Ni,Ms]),jl=k.useCallback(T=>{if(T.pointerType!=="touch")return!1;const j=fa.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 O=Js.current;O.longPressMode=pl.current;const fe=dr.current;if(fe.active&&O.pointerId===null){const we=Q.closest("[data-selection-handle]");if(we instanceof HTMLElement){const Pe=Ae.current,Xe=we.dataset.selectionHandle==="start"?"start":"end";if(Pe&&fe.anchor&&fe.focus){const ft=gf(fe.anchor,fe.focus,Pe.cols);return fe.anchor=Xe==="start"?ft.end:ft.start,fe.focus=Xe==="start"?ft.start:ft.end,fe.dragging=Xe,$r(),O.pointerId=T.pointerId,O.tapStartX=T.clientX,O.tapStartY=T.clientY,O.tapDidMove=!1,O.mode="adjust",Cr.current=!0,At(1800),vt.current?.setAttribute("readonly",""),Ks(),Hs(),po(Ec),os(!0),!0}}if(!Q.closest("[data-terminal-copy-popover]")){Kn();try{Ae.current?.clearSelection()}catch{}}}if(O.pointerId!==null)return!0;if(Cr.current=!1,zn.current){const we=performance.now(),Pe=T.clientX,Xe=T.clientY;if(O.lastTapTime!==0&&we-O.lastTapTime<=300&&Math.hypot(Pe-O.lastTapX,Xe-O.lastTapY)<=25)return po(Ec),nr.current=performance.now()+500,zn.current?.(),ht(!0),Br.current&&clearTimeout(Br.current),Br.current=setTimeout(()=>ht(!1),400),O.lastTapTime=0,!0}return O.holdTimer!==null&&(clearTimeout(O.holdTimer),O.holdTimer=null),O.joystickRepeatTimer!==null&&(clearTimeout(O.joystickRepeatTimer),O.joystickRepeatTimer=null),O.joystickDir="",O.copyStart=null,O.copyDidSelect=!1,O.pointerId=T.pointerId,O.originX=T.clientX,O.originY=T.clientY,O.tapStartX=T.clientX,O.tapStartY=T.clientY,O.tapDidMove=!1,O.mode="holding",O.longPressMode==="copy"&&os(!0),O.holdTimer=setTimeout(()=>{if(O.holdTimer=null,O.mode==="holding"){if(O.longPressMode==="copy"){const we=Ae.current,Pe=we?Ld(we,O.tapStartX,O.tapStartY):null;if(!we||!Pe){O.mode="idle";return}O.mode="copy",Cr.current=!0,At(1800),vt.current?.setAttribute("readonly",""),O.copyStart=Pe,O.copyDidSelect=!1,Ks(),Hs(),we.clearSelection(),po(Ec),os(!0);return}O.mode="arrow",Cr.current=!0,At(1e3),Ks(),Hs(),po(Ec),os(!0),requestAnimationFrame(()=>{Ot({visible:!0,activeDir:""})})}},350),!0},[os,$r,Kn]),Es=k.useCallback((T,j)=>{if(T.pointerType!=="touch")return"neutral";const Q=Js.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 O=T.clientX-Q.tapStartX,fe=T.clientY-Q.tapStartY;if(Math.hypot(O,fe)>10&&(Q.tapDidMove=!0),Q.mode==="holding"){if(!j)return Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),os(!1),Cr.current=!1,Q.mode="idle","neutral";const we=T.clientX-Q.originX,Pe=T.clientY-Q.originY;return Q.longPressMode==="copy"&&Math.hypot(we,Pe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),os(!1),Cr.current=!1,Q.mode="idle","release"):Math.hypot(we,Pe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),os(!1),Q.mode="idle","release"):"claim"}if(Q.mode==="adjust"){if(!j)return"claim";Ks();const we=Ae.current,Pe=dr.current;if(!we||!Pe.active||!Pe.anchor||!Pe.focus)return"claim";const Xe=Ld(we,T.clientX,T.clientY-mh);return Xe&&(Ni(Xe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="copy"){if(!j)return"claim";Ks();const we=Ae.current;if(!we||!Q.copyStart)return"claim";const Pe=Ld(we,T.clientX,T.clientY-mh);return Pe&&(Ni(Pe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="arrow"){if(!j)return"claim";const we={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},Pe=T.clientX-Q.tapStartX,Xe=T.clientY-Q.tapStartY,ft=wI(Pe,Xe,Q.joystickDir);if(ft&&ft!==Q.joystickDir&&(Q.originX=T.clientX,Q.originY=T.clientY),ft){const Jt=T.clientX-Q.originX,or=T.clientY-Q.originY,Ur=Math.hypot(Jt,or);if(Q.repeatIntervalMs=AI(Ur),ft!==Q.joystickDir){Q.joystickRepeatTimer!==null&&clearTimeout(Q.joystickRepeatTimer);const Jr=Q.joystickDir==="";Q.joystickDir=ft,fl.current(we[ft]);const Qn=performance.now();Qn-Q.lastHapticTime>120&&(po(Ec),Q.lastHapticTime=Qn);const vr=Jr?400:300;Q.joystickRepeatTimer=setTimeout(function yn(){if(Q.joystickDir!==ft)return;fl.current(we[ft]);const cs=performance.now();cs-Q.lastHapticTime>120&&(po(Ec),Q.lastHapticTime=cs),Q.joystickRepeatTimer=setTimeout(yn,Q.repeatIntervalMs)},vr)}Ot({visible:!0,activeDir:ft})}else Q.joystickRepeatTimer!==null&&(clearTimeout(Q.joystickRepeatTimer),Q.joystickRepeatTimer=null),Q.joystickDir="",Ot({visible:!0,activeDir:""});return"claim"}return"neutral"},[os,Ni,zo]),Ia=k.useCallback(T=>{if(T.pointerType!=="touch"||T.pointerId!==Js.current.pointerId)return;const j=Js.current;if(j.mode==="copy"){Ks(),Hs(),Ms(),os(!1);const O=Ae.current;let fe=null;if(O&&j.copyStart&&(fe=Ld(O,T.clientX,T.clientY-mh),fe&&(j.copyDidSelect=Xp(O,j.copyStart,fe)||j.copyDidSelect)),O&&j.copyDidSelect&&O.hasSelection()&&j.copyStart){const we=dr.current;we.active=!0,we.anchor=j.copyStart,we.focus=fe??j.copyStart,we.dragging=null,Gn(),un({x:T.clientX,y:T.clientY}),At(1800),po(Ec)}else da.current?.(!1);j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle",Cr.current=!1;return}if(j.mode==="adjust"){Ks(),Hs(),Ms(),os(!1),dr.current.dragging=null,Gn(),un({x:T.clientX,y:T.clientY}),At(1800),j.pointerId=null,j.mode="idle",Cr.current=!1;return}if(j.mode==="arrow"){Ks(),Hs(),os(!1),Ot({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",Cr.current=!1;return}const Q=fa.current;if(Q&&!j.tapDidMove){const O=T.target;O instanceof HTMLElement&&Q.contains(O)&&!O.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="",os(!1),Cr.current=!1,j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle"},[os,Ks,At,Ms,Gn,un]),ml=k.useCallback(()=>{const T=Js.current;os(!1),Ms(),T.mode==="arrow"&&Ot({visible:!1,activeDir:""}),T.mode==="adjust"&&(dr.current.dragging=null,Gn(),un()),T.holdTimer!==null&&(clearTimeout(T.holdTimer),T.holdTimer=null),T.joystickRepeatTimer!==null&&(clearTimeout(T.joystickRepeatTimer),T.joystickRepeatTimer=null),T.joystickDir="",Cr.current=!1,T.copyStart=null,T.copyDidSelect=!1,T.pointerId=null,T.tapDidMove=!1,T.mode="idle"},[os,Ms,Gn,un]);gx({name:`long-press:${e}`,priority:aI,container:()=>$e.current,onPointerDown:V?jl:void 0,onPointerMove:V?Es:void 0,onPointerUp:V?Ia:void 0,onPointerCancel:V?ml:void 0});const Xn=k.useCallback((T={})=>{Te.current+=1,ue.current="",be.current=null,Ye.current=0,Je.current=!1,St.current=null,st.current&&(st.current=!1,T.notifyFlowResume===!0&&Ce.current?.(!1)),Ie.current=null,H.current=!1,oe.current=null,Lt.current=""},[]),zi=k.useCallback((T="unknown")=>{const j=_e.current,Q=Ae.current,O=$e.current;if(!j||!Q||!O||!Q.element||!Q.cols||!Q.rows)return;const fe=O.getBoundingClientRect();if(fe.width<24||fe.height<24){nt("skip fit: container too small",{reason:T,width:Math.round(fe.width),height:Math.round(fe.height)});return}try{const we={cols:Q.cols,rows:Q.rows},Pe=Q.buffer.active,Xe=UL(Pe.type,Pe.baseY,Pe.viewportY),ft=j.proposeDimensions();if(!ft||ft.cols<=0||ft.rows<=0)return;const Jt=Tx(Q,we.rows),or=OL({reason:T,currentCols:we.cols,currentRows:we.rows,proposedCols:ft.cols,proposedRows:ft.rows});let Ur=0;if(or.accept){ei.current&&ps.current&&(we.cols!==ft.cols||we.rows!==ft.rows)&&Se.current?.begin();const Qn=Q.options.smoothScrollDuration;try{Q.options.smoothScrollDuration=0,Q.resize(ft.cols,ft.rows),Ur=Tx(Q,ft.rows),Xe&&Q.scrollToBottom()}finally{Q.options.smoothScrollDuration=Qn}zt.current=0}(Jt>0||Ur>0)&&(Q.refresh(0,Math.max(0,Q.rows-1)),nt("xterm buffer invariant repaired",{reason:T,before:Jt,after:Ur,cols:Q.cols,rows:Q.rows}));const Jr={cols:Q.cols,rows:Q.rows};nt("fit",{reason:T,backend:"xterm",width:Math.round(fe.width),height:Math.round(fe.height),before:we,proposed:ft,next:Jr,hysteresis:or,changed:we.cols!==Jr.cols||we.rows!==Jr.rows})}catch{Se.current?.cancel()}},[nt]),Ri=k.useCallback(T=>{const j=Ae.current;if(j)try{j.refresh(0,Math.max(0,j.rows-1)),nt("terminal refreshed (sync)",{reason:T,cols:j.cols,rows:j.rows,hasWebgl:!!me.current})}catch(Q){nt("terminal refresh (sync) failed",{reason:T,error:Q})}},[nt]),Hi=k.useCallback(T=>{const j=Ge.current;if(j){try{j.dispose()}catch{}Ge.current=null}const Q=me.current;if(!Q)return!1;Se.current?.cancel();try{Q.dispose()}catch{}return me.current=null,nt("renderer disposed",{type:"webgl",reason:T}),!0},[nt]),gs=k.useCallback((T,j)=>{if(me.current)return!0;try{const Q=new P_({customGlyphs:Sn});return Ge.current=Q.onContextLoss(()=>{nt("webgl context loss",{reason:"onContextLoss"}),pt.current=!0,typeof window<"u"&&window.setTimeout(()=>{ls("webgl-context-loss",{forceRendererRecreate:!0})},0)}),Se.current?.cancel(),T.loadAddon(Q),me.current=Q,pt.current=!1,nt("renderer",{type:"webgl",reason:j,mobile:V,mode:mt.current}),Ri(`webgl-enabled:${j}`),zi(`webgl-enabled:${j}`),ji.current=!0,!0}catch(Q){return nt("webgl load failed, fallback to dom renderer",{reason:j,error:Q,mobile:V,mode:mt.current}),!1}},[nt,Sn,V,zi,Ri]),Ws=200,Dl=k.useRef(0),Wi=k.useRef(new Map),Gi=k.useRef(new Map),ln=k.useRef(Zp()),pa=k.useRef(null),Vi=k.useRef(null),Ea=k.useRef(-1),Mi=k.useRef(new Map),ji=k.useRef(!1),ei=k.useRef(!1),ws=k.useRef(px()),Gs=k.useRef(null),Di=k.useRef(null),Na=k.useCallback(()=>{Gs.current!==null&&(clearTimeout(Gs.current),Gs.current=null),Di.current=null},[]),ti=k.useCallback(()=>{const T=Wi.current;T.forEach(j=>cancelAnimationFrame(j)),T.clear(),Gi.current.clear()},[]),ys=k.useCallback(()=>{pa.current!==null&&(window.clearTimeout(pa.current),pa.current=null)},[]),Ya=k.useRef(()=>{}),Za=k.useCallback(T=>{ys(),Be.current?.(!1),re.current(T.cols,T.rows,T.seq),pa.current=window.setTimeout(()=>{pa.current=null;const j=fx(ln.current,T.seq);ln.current=j.state,j.request&&ei.current?(nt("resize ack timeout; retrying",{seq:T.seq,retrySeq:j.request.seq,cols:j.request.cols,rows:j.request.rows}),Ya.current(j.request)):j.exhausted&&(Se.current?.cancel(),nt("resize ack timeout; leaving size unconfirmed",{seq:T.seq,cols:T.cols,rows:T.rows}))},1200)},[ys,nt]);Ya.current=Za;const As=k.useCallback((T,j)=>{if(!ei.current)return;const Q=GL(ln.current,{cols:T,rows:j});ln.current=Q.state,Q.request&&Za(Q.request)},[Za]),Ka=k.useCallback((T,j)=>{const Q=XL(ws.current,Date.now());if(Q.action==="send"){Di.current=null,As(T,j);return}Di.current={cols:T,rows:j},Gs.current===null&&(Gs.current=setTimeout(()=>{Gs.current=null;const O=Di.current;Di.current=null,O&&(ws.current=JL(Date.now()),As(O.cols,O.rows))},Math.max(0,Q.readyAt-Date.now())))},[As]),Bl=1500,Ho=400,Ao=k.useRef(0),ma=k.useRef(0),Ra=k.useCallback((T,j,Q)=>{if(!Number.isFinite(T)||!Number.isFinite(j)||T<=0||j<=0)return;const O=Math.floor(T),fe=Math.floor(j);ln.current=YL(ln.current,{cols:O,rows:fe}),Ao.current=Date.now(),nt("pty-size broadcast received",{cols:O,rows:fe,source:Q??"unknown"})},[nt]),Wo=k.useCallback(T=>{const j=Ae.current;if(!j||!j.cols||!j.rows||!ei.current||typeof document<"u"&&(document.visibilityState!=="visible"||!Tu()))return;const Q=Date.now();if(Q-Ao.current<Bl||Q-ma.current<Ho)return;const O=j.cols,fe=j.rows,we=ln.current.confirmed;we&&we.cols===O&&we.rows===fe||(ma.current=Q,nt("ensureSizeMatches push",{reason:T,cols:O,rows:fe,lastServerSize:we}),As(O,fe))},[nt,As]),ga=k.useCallback((T,j)=>{const Q=Ae.current,O=_e.current;if(!Q||!O)return;if(!ji.current){nt("refresh skipped: renderer not ready",{reason:T});return}if(j.dedupeKey!==void 0){if(Mi.current.get(T)===j.dedupeKey){nt("refresh deduped",{reason:T,dedupeKey:j.dedupeKey});return}Mi.current.set(T,j.dedupeKey)}nt("refresh",{reason:T,options:j});const fe=j.forceRendererRecreate===!0||pt.current||_r&&!!me.current&&YI.has(T)&&/Android/i.test(navigator.userAgent);let we=!1;fe&&(pt.current=!1,_r?(Hi(`refresh:${T}`),gs(Q,`refresh:${T}`)||Ri(`refresh:${T}:webgl-fallback`),we=!0):(Ri(`refresh:${T}`),we=!0)),HL(j.forceRedraw===!0,T==="dpr-change",we)?Ri(`refresh:${T}`):we||nt("terminal redraw skipped: fit/write already repaints",{reason:T});const Pe={cols:Q.cols,rows:Q.rows};zi(`refresh:${T}`);const Xe={cols:Q.cols,rows:Q.rows};if(j.skipResizePush||FL({before:Pe,after:Xe,lastServerSize:ln.current.confirmed,reconcileServerSize:j.reconcileServerSize})&&Ka(Xe.cols,Xe.rows),!j.skipScrollToBottom&&T!=="resize"&&T!=="dpr-change"){const Jt=requestAnimationFrame(()=>{const Jr=Ae.current;if(Jr&&Jr.buffer.active.type!=="alternate")try{Jr.scrollToBottom()}catch{}}),or=Wi.current,Ur=or.get(T);Ur!==void 0&&cancelAnimationFrame(Ur),or.set(T,Jt)}},[nt,_r,Hi,gs,Ri,zi,Ka]),ls=k.useCallback((T,j={})=>{if(Ae.current,T==="session-key-change"&&(ln.current=Zp(),ys(),Na(),ws.current=px(),Mi.current.clear(),ti()),!j.force&&(T==="visibility"||T==="bfcache"||T==="online")){const O=Date.now();if(O-Dl.current<Ws){nt("refresh throttled",{reason:T});return}Dl.current=O}if(Gi.current.set(T,j),Wi.current.has(T))return;const Q=requestAnimationFrame(()=>{const O=Gi.current.get(T)??{};Wi.current.delete(T),Gi.current.delete(T),ga(T,O)});Wi.current.set(T,Q)},[nt,ti,ys,Na,ga]),Go=k.useCallback(T=>{const j=Wi.current.get(T);if(j===void 0)return;const Q=Gi.current.get(T)??{};cancelAnimationFrame(j),Wi.current.delete(T),Gi.current.delete(T),ga(T,Q)},[ga]);dl.current=()=>Go("resize"),k.useEffect(()=>()=>{ti(),Pt.current!==null&&(window.clearTimeout(Pt.current),Pt.current=null)},[e,ti]),k.useEffect(()=>{ln.current=Zp(),ys(),Mi.current.clear()},[e,ys]);const qi=k.useCallback(()=>{if(H.current)return;const T=Ae.current;if(!T){Xn();return}if(!ue.current)return;const j=ue.current,Q=j.length,O=be.current,fe=Je.current;ue.current="",be.current=null,Je.current=!1,H.current=!0;let we=null;fe&&(we=St.current??{depth:0},St.current=we,we.depth+=1);const Pe=Se.current,Xe=Pe?.generation;T.write(j,()=>{if(we&&(we.depth-=1),Xe!==void 0&&Pe?.written(Xe),H.current=!1,Ye.current-=Q,Ye.current<0&&(Ye.current=0),O!==null&&le.current?.(O),st.current&&Ye.current<KI&&(st.current=!1,Ce.current?.(!1)),ue.current){qi();return}const ft=++Te.current,Jt=()=>{if(ft!==Te.current||H.current||ue.current)return;const or=T.buffer.active;Ne.current?.({x:or.cursorX,y:or.cursorY,rows:T.rows,lastProcessedChunkId:oe.current})};typeof window>"u"?Jt():window.requestAnimationFrame(()=>{window.requestAnimationFrame(Jt)})})},[Xn]);Vt.current=qi;const gl=k.useCallback(()=>{if(Ie.current!==null)return;const T=++We.current;Ie.current=T,queueMicrotask(()=>{Ie.current===T&&(Ie.current=null,qi())})},[qi]),se=k.useCallback((T,j,Q=!1)=>{if(!T)return;Te.current+=1,ue.current+=T,be.current=j,Je.current=Je.current||Q,Ye.current+=T.length;const O=Ze.current;(O===null||j>O)&&(Ze.current=j),!st.current&&Ye.current>=ZI&&(st.current=!0,Ce.current?.(!0)),gl()},[gl]);return k.useEffect(()=>{let T=!1,j=null,Q=null,O=[];const fe=$e.current;return fe?(fe.tabIndex=V?-1:0,(async()=>{if(Ee.current?.(!1),dt("loading"),xn(null),Rr(!0),await eE(),!T)try{const Pe=rE(fe,_x(Xr),fn,Et,kt),Xe=new xA({...Pe?{cols:Pe.cols,rows:Pe.rows}:{},allowProposedApi:!0,fontFamily:_x(Xr),fontSize:fn,fontWeight:kx(K),fontWeightBold:kx(Ue),theme:tE(F),logLevel:"off",cursorBlink:!_r,cursorStyle:"block",cursorInactiveStyle:Sr.current?"bar":"none",scrollback:d?2e3:5e3,scrollbar:{showScrollbar:!1},allowTransparency:FS(Or,sn),convertEol:ks,drawBoldTextInBrightColors:Qr,rescaleOverlappingGlyphs:Ls,minimumContrastRatio:tr,letterSpacing:Et,lineHeight:kt,smoothScrollDuration:on&&!ye.current?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),ft=new bA;Xe.loadAddon(ft),Xe.loadAddon(new H_),Xe.registerLinkProvider(NI(Xe,(vr,yn)=>{rt.current?.(vr,yn)}));const Jt=new K_;Xe.loadAddon(Jt),Xe.unicode.activeVersion=cr,Xe.loadAddon(new ik({highlightLimit:1e3}));const or=new uk;Xe.loadAddon(or),lt.current=or,Xe.loadAddon(new EL);try{Xe.loadAddon(new hk(void 0,new k3))}catch(vr){nt("clipboard addon skipped",{error:vr})}j=Xe,Ae.current=Xe,_e.current=ft,q.current=typeof window<"u"?window.devicePixelRatio:1,Xe.open(fe),Se.current=WL(Xe),Zn&&Xe.loadAddon(new IL({fontFeatureSettings:rI,fallbackLigatures:nI}));try{const vr=Xe._core;vr?.coreService&&(vr.coreService.isCursorInitialized=!0),Xe.refresh(0,Xe.rows-1)}catch{}_r?(gs(Xe,"init"),ji.current=!0):(nt("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:V,mode:Or}),ji.current=!0),Rr(!1),Vr();const Ur=vr=>{if(vr.ctrlKey||vr.metaKey){vr.preventDefault();const yn=vr.deltaY>0?-1:1;Qh(t,fn+yn)}};if(Nt.current=Ur,fe.addEventListener("wheel",Ur,{passive:!1}),!V){let vr=0,yn=null,cs=null,js=null;const pc=()=>{js=null,dl.current();const Vs=Nc(Ae.current,fn,kt),Yi=gt.current+vr;vr=0;const To=Math.trunc(Yi/Vs);if(gt.current=Yi-To*Vs,To!==0){const bi=To>0?"down":"up",So=Ae.current,Jc=Math.max(3,Math.floor((So?.rows??24)/2)),yi=Math.abs(To);yi>Jc&&(gt.current=0),ha.current(bi,Math.min(yi,Jc),yn??void 0,cs??void 0)}};Xe.attachCustomWheelEventHandler(Vs=>{if(Vs.ctrlKey||Vs.metaKey||Vs.shiftKey)return!0;if(Vs.deltaY===0)return!1;if(!Ae.current||!ps.current)return!0;const To=Nc(Ae.current,fn,kt);let bi=Vs.deltaY;return Vs.deltaMode===1?bi=Vs.deltaY*To:Vs.deltaMode===2&&(bi=Vs.deltaY*(fe.clientHeight||To*20)),vr+=bi,yn=Vs.clientX,cs=Vs.clientY,js===null&&(js=requestAnimationFrame(pc)),Vs.preventDefault(),!1})}const Jr=qI(fe);if(Jr?(Jr.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Y.current=Jr,Lr()):Y.current=null,ls("mount",{skipResizePush:!0,skipScrollToBottom:!0}),Mn.current&&(V?Xe.focus():vt.current?.focus({preventScroll:!0})),V||_t.current(),O.push(Xe.onRender(()=>{const vr=Xe.buffer.active;He.current?.({x:vr.cursorX,y:vr.cursorY,rows:Xe.rows}),V||_t.current()})),!V){try{const vr=Xe.textarea;if(vr){vr.tabIndex=-1,vr.setAttribute("aria-hidden","true"),vr.setAttribute("readonly",""),vr.value="";const yn=()=>{vt.current?.focus({preventScroll:!0})};vr.addEventListener("focus",yn),O.push({dispose:()=>vr.removeEventListener("focus",yn)})}}catch{}try{O.push(Xe.onCursorMove(()=>_t.current())),O.push(Xe.onResize(()=>_t.current()))}catch{}}O.push(Xe.onData(vr=>{const yn=St.current;yn!==null&&yn.depth>0||je.current(vr)}));const Qn=vr=>{const yn=typeof window<"u"?window.devicePixelRatio:1,cs=Math.abs(yn-q.current)>.001;return cs&&(q.current=yn,nt("device pixel ratio changed",{value:yn,source:vr})),cs};if(Q=new ResizeObserver(vr=>{if(!$L(!!Kr.current,nn.current)){nt("resize observer skipped: hidden mobile session");return}Zt.current=void 0;const yn=vr[0];yn&&nt("resize observer",{width:Math.round(yn.contentRect.width),height:Math.round(yn.contentRect.height)});const cs=Qn("resize-observer");ls(cs?"dpr-change":"resize")}),Q.observe(fe),typeof window<"u"){const vr=()=>{Qn("window-resize")&&ls("dpr-change")};window.addEventListener("resize",vr),O.push({dispose:()=>window.removeEventListener("resize",vr)});const yn=window.visualViewport;if(yn){const cs=()=>{Qn("visual-viewport-resize")&&ls("dpr-change")};yn.addEventListener("resize",cs),O.push({dispose:()=>yn.removeEventListener("resize",cs)})}}zi("init-fit"),dt("ready"),Ee.current?.(!0)}catch(Pe){console.error("Failed to initialize terminal:",Pe),Rr(!1),dt("error"),xn(Pe instanceof Error?Pe.message:"Failed to load terminal")}})(),()=>{Ee.current?.(!1),T=!0,Oe.current?.(!1),jt.current?.(),jt.current=null,at.current=!1,Ve.current!==null&&(clearTimeout(Ve.current),Ve.current=null),qt.current=!1,Pr.current=null,Ft(),Wr({active:!1,text:""});for(const Pe of O)Pe.dispose();Q?.disconnect(),Nt.current&&(fe.removeEventListener("wheel",Nt.current),Nt.current=null),Se.current?.dispose(),Se.current=null,Hi("component-unmount"),j?.dispose(),Ae.current=null,_e.current=null,Y.current=null,Xn({notifyFlowResume:!0}),ys(),Na()}):void 0},[zi,Xr,fn,K,Ue,Et,kt,tr,Qr,cr,Sn,Ls,Zn,sn,on,F,Xn,Ft,V,gs,Hi,nt,ys,Na]),k.useEffect(()=>{const T=Ae.current;T&&(T.options.smoothScrollDuration=on&&!pe?125:0)},[on,pe,ge]),k.useEffect(()=>{const T=Ae.current;T&&(T.options.cursorInactiveStyle=xe?"bar":"none",xe||T.blur())},[xe,ge]),k.useEffect(()=>{const T=Ae.current;if(T){if(_r){if(T.options.cursorBlink=!1,gs(T,"renderer-mode-change")&&sn&&!Xt.current)try{T.loadAddon(new zk({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),Xt.current=!0}catch(Q){nt("image addon skipped",{error:Q})}return}T.options.cursorBlink=!0,Hi("renderer-mode-change")&&(Ri("renderer-mode-change:webgl-disabled"),zi("renderer-mode-change:webgl-disabled"))}},[_r,sn,gs,Hi,Ri,zi,nt]),k.useEffect(()=>{const T=Ae.current;T&&(oe.current!==null&&T.reset(),Xn(),De.current="",er.current=0,vt.current&&(vt.current.value=""),ls("session-reset",{skipScrollToBottom:!0}),Mn.current&&(Kr.current?T.focus():vt.current?.focus({preventScroll:!0})))},[e,ge,ls,Xn]),k.useEffect(()=>{if(!V||typeof document>"u")return;let T=null;const j=()=>{T=null;const O=vt.current;if(!O||document.activeElement!==O||at.current)return;const fe=De.current,we=Cd(O.value);if(we!==fe||we.includes("\r")||!ot())return;const Pe=Math.min(yx(O),Array.from(we).length),Xe=Pe-er.current;if(Xe===0)return;const ft=Ae.current,Jt=Xe<0?(ft?xh(ft,"D"):"\x1B[D").repeat(-Xe):(ft?xh(ft,"C"):"\x1B[C").repeat(Xe);je.current(Jt),er.current=Pe},Q=()=>{T===null&&(T=requestAnimationFrame(j))};return document.addEventListener("selectionchange",Q),()=>{document.removeEventListener("selectionchange",Q),T!==null&&cancelAnimationFrame(T)}},[V,ot]),k.useEffect(()=>{if(!V)return;const T=Ga();return jt.current=T,()=>{T(),jt.current=null}},[V,Ga]),k.useEffect(()=>{const T=Ae.current;if(T)try{T.options.scrollback=d?0:1e3}catch{}},[d,ge]),k.useEffect(()=>{const T=Ae.current;if(!T)return;if(n.length===0){oe.current!==null&&(T.reset(),Xn(),ls("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const j=oe.current;let Q,O=!1;if(j===null)Q=n;else{const fe=n.findIndex(we=>we.id===j);fe>=0?Q=n.slice(fe+1):(Q=n,O=!0)}if(Q.length>0){const fe=Q.map(or=>or.data).join(""),we=Lt.current+fe,{cleaned:Pe,remainder:Xe}=VI(we);Lt.current=Xe;const ft=Ze.current,Jt=ft!==null&&(Q[0].id<=ft||O);Pe?se(Pe,Q[Q.length-1].id,Jt):le.current?.(Q[Q.length-1].id)}oe.current=n[n.length-1].id},[n,ge,se,ls,Xn]),k.useImperativeHandle(te,()=>({serializeSnapshot:()=>Ae.current?lt.current?.serialize({scrollback:100})??null:null,focus:()=>{if(Kr.current){ns();return}vt.current?.focus({preventScroll:!0})},blur:()=>{const T=vt.current;jn(T),T&&typeof document<"u"&&document.activeElement===T&&T.blur(),Kr.current&&T?.setAttribute("readonly",""),Oe.current?.(!1)},clear:()=>{const T=Ae.current;T&&(T.reset(),Xn(),ls("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},prepareScreenReplacement:()=>{Xn({notifyFlowResume:!0})},copySelectionOrViewport:async()=>{const T=Ae.current;if(!T)return!1;const j=T.hasSelection()?T.getSelection():nE(T),Q=await Ix(j);return Q&&T.hasSelection()&&$r(),Q},pasteClipboardText:async()=>{At();const T=await ze(vt.current);return ms.current?.(T),T},sendSequence:(T,j)=>$(T,null,j),getDimensions:()=>{const T=Ae.current;return!T||!T.cols||!T.rows?null:{cols:T.cols,rows:T.rows}},requestRefresh:ls,setSessionReady:T=>{ei.current=T,T||(Se.current?.cancel(),ys(),ln.current=ZL(ln.current),Vi.current=null,Ea.current=-1,Be.current?.(!1))},acknowledgeResize:T=>{if(!T.ok&&typeof T.seq=="number"){const we=fx(ln.current,T.seq);if(!we.request&&!we.exhausted)return;ys(),ln.current=we.state,we.request&&ei.current?Ya.current(we.request):we.exhausted&&Se.current?.cancel();return}const j=qL(ln.current,T);if(!j.accepted)return;ys(),ln.current=j.state,nt("resize acknowledged",{seq:T.seq,ok:T.ok,cols:T.cols,rows:T.rows,screenSyncPending:T.screenSyncPending===!0,screenSyncGeneration:T.screenSyncGeneration});const Q=Ae.current,O=j.state.confirmed;if(!!!(Q&&O&&Q.cols===O.cols&&Q.rows===O.rows)){Be.current?.(!1);return}if(T.screenSyncPending&&typeof T.screenSyncGeneration=="number"){Vi.current=T.screenSyncGeneration;const we=Ea.current>=T.screenSyncGeneration;Be.current?.(we),we&&(Vi.current=null);return}Vi.current=null,Be.current?.(!0)},notifyScreenSynchronized:T=>{if(!Number.isFinite(T))return;Ea.current=Math.max(Ea.current,T);const j=Vi.current;if(j===null||T<j)return;Vi.current=null;const Q=Ae.current,O=ln.current.confirmed;Be.current?.(!!(Q&&O&&Q.cols===O.cols&&Q.rows===O.rows))},notifyServerSize:Ra,ensureSizeMatches:Wo,requestPtyRedraw:()=>{const T=Ae.current;if(!T||!ei.current||ln.current.pending||Vi.current!==null)return;const j=VL(ln.current,{cols:T.cols,rows:T.rows});ln.current=j.state,Ya.current(j.request)}}),[V,jn,ns,Xn,ze,$,ls,ys,nt,As,Ra,Wo]),s.jsxs("div",{ref:$e,"data-termdock-terminal-dropzone":e,className:`relative h-full w-full terminal-viewport-container ${U||""}`,style:{backgroundColor:F.background,touchAction:Ht.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:Ha,onPointerMoveCapture:Bn,onPointerUpCapture:ss,onPointerCancelCapture:$i,onTouchStartCapture:T=>{if(Vn(T.target)){At(),Mt(_d);return}Dn(),Mt(_d)},onTouchMoveCapture:()=>Mt(_d),onTouchEndCapture:()=>Mt(kd),onTouchCancelCapture:()=>Mt(kd),onMouseDown:T=>{V||T.button===0&&(Pt.current!==null&&(window.clearTimeout(Pt.current),Pt.current=null),requestAnimationFrame(()=>{try{vt.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:T=>{V||T.button===0&&(Pt.current!==null&&window.clearTimeout(Pt.current),Pt.current=window.setTimeout(()=>{Pt.current=null;try{vt.current?.focus({preventScroll:!0})}catch{}},0))},children:[an&&s.jsx("button",{type:"button",role:"alert",onClick:()=>Me(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:an}),Tr&&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:Tr.left,top:Tr.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:T=>{At(),T.stopPropagation()},onPointerUp:T=>{T.preventDefault(),T.stopPropagation(),La()},onTouchStart:T=>{At(),T.stopPropagation()},onTouchEnd:T=>{T.preventDefault(),T.stopPropagation(),La()},onClick:T=>{T.preventDefault(),T.stopPropagation(),La()},children:[s.jsx(K8,{size:14,strokeWidth:2.4}),s.jsx("span",{children:ke("common.copy")})]}),bn?.start&&s.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:bn.start.left,top:bn.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)]"})]})}),bn?.end&&s.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:bn.end.left,top:bn.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)]"})]})}),rn&&wt&&s.jsx(pI,{}),rn&&it==="loading"&&!wt&&s.jsx(U3,{}),it==="error"&&s.jsx(mI,{message:sr||void 0,onRetry:()=>{window.location.reload()}}),it==="ready"&&s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:vt,"aria-label":ke("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=Tn.x,j=Tn.y,Q={position:"fixed",left:T,top:j,pointerEvents:"none",touchAction:"auto",fontSize:`${fn}px`,fontFamily:Xr,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(Tn.cellW)),height:Math.max(1,Math.round(Tn.cellH))};if(!qr.active)return Q;const O=Dt(qr.text);return{...Q,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:O.width,height:O.height,whiteSpace:O.whiteSpace}})()},onContextMenu:T=>{T.preventDefault()},onFocus:()=>{nt("input anchor focus"),Zt.current=void 0,_t.current(),ls("focus",{skipResizePush:!0,skipScrollToBottom:!0}),Oe.current?.(!0)},onBlur:T=>{V||jn(T.currentTarget);const j=fr(),Q=typeof document<"u"?document.activeElement:null;if(nt("input anchor blur",{guarded:j,activeTag:Q?.tagName??null,activeClass:Q?.className??null}),!j){V&&vt.current?.setAttribute("readonly",""),Oe.current?.(!1);return}if(typeof window>"u"){Oe.current?.(!1);return}window.setTimeout(()=>{Bt()||ot()||(V&&vt.current?.setAttribute("readonly",""),Oe.current?.(!1))},kd)},onBeforeInput:T=>{if(at.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 O=ee(Q,T.currentTarget);V&&ms.current?.(O)}return}if(j.inputType==="insertLineBreak"){if(qt.current){qt.current=!1,Ve.current!==null&&(clearTimeout(Ve.current),Ve.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(),je.current("");return}if(j.inputType==="deleteContentBackward"&&T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),je.current("");return}return}}},onInput:T=>{if(at.current)return;const j=T.nativeEvent,Q=pC(De.current,Cd(T.currentTarget.value),j.inputType);if(Q){const O=ee(Q,T.currentTarget);V&&ms.current?.(O);return}z(T.currentTarget)},onPaste:T=>{const j=T.clipboardData.files.length?Array.from(T.clipboardData.files):Array.from(T.clipboardData.items).filter(we=>we.kind==="file").map(we=>we.getAsFile()).filter(we=>we!==null),Q=T.clipboardData.getData("text/plain");if(window.termdockDesktop?.readClipboardFiles){T.preventDefault(),ze(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 O=j[0];if(O){T.preventDefault(),ie(O,T.currentTarget);return}if(!Q){(window.termdockDesktop||typeof navigator.clipboard?.read=="function")&&(T.preventDefault(),ze(T.currentTarget));return}T.preventDefault();const fe=ee(Q,T.currentTarget);V&&ms.current?.(fe)},onKeyDown:T=>{const j=WI(T);if(!j&&!at.current){if(T.getModifierState("AltGraph"))return;const Q=Ae.current,O=T.metaKey,fe=T.ctrlKey,we=T.altKey,Pe=T.shiftKey,Xe=T.key;if(O&&!fe&&!we&&!Pe&&Xe==="Enter"){T.preventDefault(),N(T.currentTarget);return}if((O||fe)&&!we&&!Pe&&(Xe==="v"||Xe==="V"))return;if(O&&!fe&&!we&&!Pe&&(Xe==="c"||Xe==="C")){T.preventDefault();const Jt=Q?.hasSelection()?Q.getSelection():"";Jt&&navigator.clipboard?.writeText(Jt).catch(()=>{});return}if((O||fe)&&!we&&!Pe&&(Xe==="k"||Xe==="K")){T.preventDefault(),Q&&(Q.reset(),Xn(),ls("clear",{skipResizePush:!0,skipScrollToBottom:!0})),T.currentTarget.value="",De.current="",er.current=0;return}if(O&&!fe&&!we&&!Pe&&Xe==="Backspace"){T.preventDefault(),$("",T.currentTarget);return}if(O&&!fe&&!we&&!Pe&&Xe==="Delete"){T.preventDefault(),$("\v",T.currentTarget);return}if(O&&!fe&&!we&&!Pe&&Xe==="ArrowLeft"){T.preventDefault(),$("",T.currentTarget);return}if(O&&!fe&&!we&&!Pe&&Xe==="ArrowRight"){T.preventDefault(),$("",T.currentTarget);return}if(O)return;if(we&&!fe&&!O&&!Pe&&Xe==="Backspace"){T.preventDefault(),$("\x1B",T.currentTarget);return}if(we&&!fe&&!O&&!Pe&&Xe==="Delete"){T.preventDefault(),$("\x1Bd",T.currentTarget);return}if(we&&!fe&&!O&&!Pe&&Xe==="ArrowLeft"){T.preventDefault(),$("\x1Bb",T.currentTarget);return}if(we&&!fe&&!O&&!Pe&&Xe==="ArrowRight"){T.preventDefault(),$("\x1Bf",T.currentTarget);return}const ft=jC(T,Q?.modes?.applicationCursorKeysMode===!0);if(ft!==null){T.preventDefault(),$(ft,T.currentTarget);return}}if(T.key==="Enter"||T.key==="Go"||T.key==="done"||T.key==="send"){if(j||at.current){T.preventDefault();return}if(qt.current){qt.current=!1,Ve.current!==null&&(clearTimeout(Ve.current),Ve.current=null),T.preventDefault();return}T.preventDefault(),N(T.currentTarget);return}if(T.key==="Backspace"){if(j||at.current)return;if(!T.currentTarget.value){T.preventDefault(),je.current("");return}if(T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),je.current("");return}}},onCompositionStart:()=>{at.current=!0,Gr(),Wr({active:!0,text:""})},onCompositionUpdate:T=>{at.current=!0;const j=T.data??T.currentTarget.value;Wr(Q=>Q.active&&Q.text===j?Q:{active:!0,text:j})},onCompositionEnd:T=>{at.current=!1,qt.current=!0,Ve.current!==null&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>{qt.current=!1,Ve.current=null},50),Wr({active:!1,text:""}),z(T.currentTarget),dn()}}),qr.active&&(()=>{const T=Dt(qr.text);return s.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:Tn.x,top:Tn.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:T.width,height:T.height,margin:0,padding:0,color:F.foreground,background:F.background,boxShadow:`-1px 0 0 1px ${F.background}`,fontSize:`${fn}px`,fontFamily:Xr,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:F.foreground,wordBreak:"break-all",whiteSpace:T.whiteSpace,transition:"none"},children:qr.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:ne?1:0,transform:ne?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),s.jsx("div",{ref:fs,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:Ht.visible?1:0,transform:Ht.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:Ht.visible&&(()=>{const{activeDir:T}=Ht,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"})})})]})})()})]})]})});H3.displayName="TerminalViewport";const iE=H3,aE=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},oE=()=>({async createSession(e){return sw(e)},connect(e,t,r){const n=nw(e,t.onEvent,t.onError,{...aE(r),getDimensions:r?.getDimensions});return{close:()=>n()}},async sendInput(e,t){await gy(e,t)},async resize(e){await rw(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await my(e)},async restartSession(e,t){return tw(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await ew(e)},async tmuxAction(e,t){return J8(e,t)},async listTmuxSessions(){return Qm()},async getTmuxStatus(){return Bm()},async checkHealth(e){return X8(e)}}),lE="\x1B",cE=/\x1b\[[IO]/g,uE=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,dE=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function Nx(e,t,r){return e.lastIndex=r,e.exec(t)?e.lastIndex:-1}function hE(e){const t=e.replace(cE,"");if(t.length===0)return e.length>0;let r=0;for(;r<t.length;){let n=Nx(uE,t,r);if(n<0&&(n=Nx(dE,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 fE(e){return e===lE}function a1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const Zd=18;function pE(){return W3.map(e=>e.id)}const W3=[{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 b0(){return W3.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function X1(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 G3(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const J1=/^\/(.+)\/([gimsuy]*)$/;function Rx(e){return J1.test(e.trim())}function bf(e){const t=e.trim().match(J1);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function V3(e){if(typeof e!="string")return null;const t=e.trim();return t?J1.test(t)?bf(t)?t:null:t.toLowerCase():null}function Mx(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 jx="||",mE=120;function gE(e){return e.includes(jx)?e.split(jx).filter(t=>t.length>0):[e]}function Eu(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=>V3(p)).filter(p=>!!p):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:X1(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=b0()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function xE(e,t){const r=G3(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const c=bf(a);if(c){if(c.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function Dx(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??b0()[0]}function bE(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function yE(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function q3(e,t){const r=X1(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 Y3=28,Z3=({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(PS,{size:14}):(t.charAt(0)||"?").toUpperCase()}),vE={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Id=8;function wE(e,t){return vE[e]??null}const AE=({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:W="idle",fileUploadProgress:F=0,longPressMode:U="arrows",copyFeedback:V="idle",onLongPressModeToggle:Z,onModifierToggle:ce,onPresetSelect:xe,onExpandedChange:pe})=>{const{t:te}=zr(),[ke,$e]=k.useState(l),[Y,Ae]=k.useState(!1),lt=k.useRef(null),Se=r==="desktop-actions",ye=Se||ke,[_e,je]=k.useState(!1),[re,Oe]=k.useState(null),Ce=c||!e||!t,Ee=c||!e,Be=k.useRef(null),Ne=k.useRef(null),le=k.useRef(null),He=k.useRef(null),rt=k.useRef(null),mt=k.useRef(V),ue=k.useRef(null),Ye=k.useRef(0),st=k.useRef(null),Ie=k.useRef(!1),We=k.useCallback(et=>{if(Ce)return;const Ct=et.target;if(!(Ct instanceof Element))return;const Nt=Ct.closest("button"),gt=Nt?.hasAttribute("data-mobile-native-action")===!0;Nt&&!gt?(et.preventDefault(),po(Id)):Nt&&po(Id)},[Ce]),Te=k.useCallback(et=>{et.preventDefault()},[]),H=k.useCallback(et=>{const Ct=et.target;Ce||Ct instanceof HTMLElement&&Ct.closest("button")&&Ct.blur()},[Ce]);k.useEffect(()=>{$e(l)},[l]),k.useEffect(()=>{Se||pe?.(ke)},[Se,pe,ke]),k.useEffect(()=>{Ce&&(ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null),je(!1),Oe(null))},[Ce]),k.useEffect(()=>{e||(je(!1),Oe(null))},[e]),k.useEffect(()=>{if(!_e)return;const et=()=>{const Ct=Be.current?.getBoundingClientRect();Ct&&Oe({left:Math.max(8,Ct.left),top:Math.max(8,Ct.top-8)})};return et(),window.addEventListener("resize",et),window.addEventListener("scroll",et,!0),()=>{window.removeEventListener("resize",et),window.removeEventListener("scroll",et,!0)}},[_e]),k.useEffect(()=>{const et=mt.current;if(mt.current=V,V==="idle"||V===et)return;if(rt.current!==null&&window.clearTimeout(rt.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 Nt=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];le.current?.animate?.(Nt,{duration:760,easing:"ease-out"}),He.current?.animate?.(Nt,{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"});po(Id),V==="copied"&&(rt.current=window.setTimeout(()=>{po(Id),rt.current=null},90),U==="copy"&&Z?.())},[V,U,Z]),k.useEffect(()=>()=>{rt.current!==null&&window.clearTimeout(rt.current)},[]);const oe=k.useCallback((et,Ct)=>{Ce||(et.preventDefault(),S(Ct))},[S,Ce]),be=k.useCallback((et,Ct)=>{Ce||(et.preventDefault(),ce(Ct))},[ce,Ce]),Ze=k.useCallback(et=>{Ce||(et.preventDefault(),$e(Ct=>{const Nt=!Ct;return Nt&&(Ae(!0),lt.current!==null&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>{Ae(!1),lt.current=null},350)),Nt}))},[Ce]),Je=k.useCallback(()=>{const et=typeof performance<"u"?performance.now():Date.now();et-Ye.current<350||(Ye.current=et,E?.())},[E]),St=k.useCallback(et=>{Ce||(et.stopPropagation(),et.pointerType!=="touch"&&(et.preventDefault(),Je()))},[Ce,Je]),Vt=k.useCallback(et=>{Ce||(et.preventDefault(),et.stopPropagation(),Je())},[Ce,Je]),jt=k.useCallback(et=>{Ce||W==="uploading"||!R||(et.preventDefault(),et.stopPropagation(),Ie.current||R(),Ie.current=!1)},[W,R,Ce]),vt=k.useCallback(()=>{st.current!==null&&window.clearTimeout(st.current),st.current=null},[]),Zt=k.useCallback(et=>{et.stopPropagation(),!(Ce||W==="uploading"||!B)&&(Ie.current=!1,st.current=window.setTimeout(()=>{st.current=null,Ie.current=!0,po(Id),B()},500))},[W,B,Ce]);k.useEffect(()=>()=>vt(),[vt]);const Pt=k.useCallback(et=>{Ce||et.stopPropagation()},[Ce]),Xt=250,zt=k.useCallback(()=>{ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null)},[]);k.useEffect(()=>()=>{zt(),lt.current!==null&&(window.clearTimeout(lt.current),lt.current=null)},[zt]);const Lt=k.useCallback((et,Ct)=>{if(Ce)return;if(et.preventDefault(),!Ct.doubleTapSequence){L(Ct.sequence);return}const Nt=ue.current;if(Nt!==null&&Nt.actionId===Ct.id){window.clearTimeout(Nt.timer),ue.current=null,L(Ct.doubleTapSequence);return}zt();const gt=window.setTimeout(()=>{ue.current=null,L(Ct.sequence)},Xt);ue.current={actionId:Ct.id,timer:gt}},[zt,L,Ce]),me=k.useCallback(et=>{Ce||(et.preventDefault(),et.stopPropagation(),Z?.())},[Z,Ce]),Ge=k.useCallback(et=>{Ce||et.stopPropagation()},[Ce]),pt=k.useCallback(et=>{if(Ce)return;et.preventDefault();const Ct=et.currentTarget.getBoundingClientRect();Oe({left:Math.max(8,Ct.left),top:Math.max(8,Ct.top-8)}),je(Nt=>!Nt)},[Ce]),q=k.useCallback((et,Ct)=>{Ce||(et.preventDefault(),je(!1),Oe(null),xe(Ct))},[xe,Ce]),at=v.length>0,qt=k.useMemo(()=>{const et=[{id:"preset",kind:"preset"}];if(!Se&&y&&et.push({id:"alt",kind:"alt"}),at){const Ct=v.map(Nt=>({id:Nt.id,kind:"text",action:Nt}));return et.concat(Ct)}return Se?et.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"}]):et.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,at,y,Se]),Ve=k.useMemo(()=>q3(qt,Se&&!at?[6]:w),[qt,at,Se,w]),De=`${Se?"space-y-1":"mt-1 space-y-1"}${Y?" pointer-events-none":""}`,er=_e&&re?Ii.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:re.left,top:re.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(et=>s.jsx("button",{type:"button",onPointerDown:Ct=>q(Ct,et.id),tabIndex:-1,disabled:Ee,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${et.id===m?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:et.label},et.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[er,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?Se?"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:We,onPointerDownCapture:We,onContextMenuCapture:Te,onFocusCapture:H,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!Se&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:et=>oe(et,"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:et=>be(et,"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:et=>oe(et,"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:et=>oe(et,"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:vt,onPointerCancel:vt,onClick:jt,tabIndex:-1,disabled:Ee||!R||W==="uploading",title:W==="uploading"?`${te("rightSidebar.uploading")} ${Math.round(F)}%`:te(W==="inserted"?"rightSidebar.inserted":W==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":te("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 ${W==="inserted"?"bg-primary/15 text-primary":W==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[W==="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,F))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:W==="uploading"?s.jsx(Cn,{size:15,className:"animate-spin"}):W==="inserted"?s.jsx(hi,{size:15}):W==="failed"?s.jsx(Rn,{size:15}):s.jsx(oT,{size:15})}),W!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:W==="uploading"?`${te("rightSidebar.uploading")} ${Math.round(F)}%`:te(W==="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:et=>oe(et,"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(tT,{size:16})}),s.jsxs("button",{ref:Ne,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Ge,onTouchStart:Ge,onClick:me,tabIndex:-1,disabled:Ee,title:te(V==="copied"?"terminal.copied":V==="failed"?"terminal.copyFailed":U==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":te(U==="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":U==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:le,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:He,"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(hi,{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(Rn,{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(Ny,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&U==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(BT,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&U==="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"?`${te("terminal.copied")} · ${te("terminal.longPressSendsArrows")}`:`${te("terminal.copyFailed")} · ${te("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:St,onPointerUp:Pt,onTouchStart:Pt,onTouchEnd:Pt,onClick:Vt,tabIndex:-1,disabled:Ee,title:te("terminal.paste"),"aria-label":te("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(GA,{size:15})}),s.jsx("button",{type:"button",onPointerDown:Ze,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:ke?s.jsx(iw,{size:16}):s.jsx(ul,{size:16})})]}),ye&&s.jsx("div",{className:De,children:Ve.map((et,Ct)=>{const Nt=et.items[0]?.kind==="preset",gt=Math.max(2,et.columns),bt=Nt?`${Y3}px repeat(${Math.max(1,gt-1)}, minmax(0, 1fr))`:`repeat(${gt}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:bt},children:et.items.map(It=>It.kind==="preset"?s.jsx(Z3,{buttonRef:It.id==="preset"?Be:void 0,mode:m,presetLabel:d,title:p,disabled:Ee,onPointerDown:pt},It.id):It.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:yt=>be(yt,"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"})},It.id):It.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:yt=>Lt(yt,It.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:[It.action.label,It.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},It.id):s.jsx("button",{type:"button",onPointerDown:yt=>oe(yt,It.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:It.keyName==="esc"?"Esc":It.keyName==="ctrl-c"?"Ctrl-C":It.keyName==="ctrl-d"?"Ctrl-D":It.keyName==="home"?"Home":"End"},It.id))},`row-${Ct}`)})})]})})]})},TE=({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"})})]})},SE=/^Reconnecting/i,CE=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:c}=zr(),l=!!e&&SE.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(d0,{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},_E=120,kE=80,LE=400;function Bx(){if(typeof window>"u"||document.visibilityState!=="visible"||!aw())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 K3(e){const{enabled:t,openThresholdPx:r=_E,closeThresholdPx:n=kE,settleDelayMs:a=LE}=e,c=k.useMemo(()=>Qu("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=Bx();let Z=l.current;if(V>=r?Z=!0:V<=n&&(Z=!1),l.current=Z,Z){const ce=Math.abs(V-p.current);p.current=V,ce>10&&(d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,x(xe=>xe.isSettled?xe:{...xe,isSettled:!0})},a))}else d.current!==null&&(clearTimeout(d.current),d.current=null);x(ce=>{const xe=Z?ce.isSettled:!1;return ce.isOpen===Z&&ce.keyboardHeight===V&&ce.isSettled===xe?ce:(c("sync",{keyboardHeight:V,isOpen:Z,isSettled:xe,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:xe,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 W=V=>{c("resume",{source:V,keyboardHeight:Bx(),hidden:document.hidden}),v(`${V}:now`),window.setTimeout(()=>v(`${V}:50ms`),50),window.setTimeout(()=>v(`${V}:200ms`),200)},F=()=>{document.hidden||W("visibilitychange")},U=()=>W("pageshow");return document.addEventListener("visibilitychange",F),window.addEventListener("pageshow",U),()=>{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",F),window.removeEventListener("pageshow",U),y!==null&&window.cancelAnimationFrame(y),d.current!==null&&(clearTimeout(d.current),d.current=null)}},[c,t,r,n,a]),m}const Vh=300,IE=120,EE=2e3,NE=250,RE=6e4;function ME(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 Jp(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function bh(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function jE(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function DE(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function BE(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function QE(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function PE(e){return!e.initialConnectionPending}function OE(e){return!e}function FE(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function $E(e,t){return[...e].every(r=>t.has(r))}function UE(e,t){return e===null||t-e>=NE}function zE(e){return!1}function HE(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,RE-(e.now-e.reconnectStartedAt))}function WE(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,Vh+n*IE),n+=1}return r}const GE="Session not found on server",qh="Terminal session not found",VE="STALE_SESSION_RESTORE_REJECTED";function Qx(e){return o1(e)?!1:e?.message===GE||e?.status===404&&e.message===qh}function o1(e){return e?.code===VE}function qE(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function X3(e,t){return qE(e,t).replace(/ /g,"\\ ")}function l1(e,t){return`${X3(e,t)} `}function Px(e,t){return X3(e,t)}function EU(e,t,r){if(!r)return Px(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${Px(e,t)}:${n}`}const YE="/tmp";async function ZE(e,t,r){const a=(await t(YE,[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 yf(a)}if(!c)throw new yf(a);return a}class yf extends Error{constructor(t){super("File uploaded, but its reference was not accepted"),this.uploaded=t,this.name="UploadedReferenceRejectedError"}uploaded}function Ox(e,t,r,n,a){if(!e||!t||!r())return Promise.resolve(!1);const c=n?mC(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&&gC(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 J3=[640,960,1280,1600,2048,2560,3072,4096],ev=[240,360,480,540,720,1080,1440,2160],i0={min:.1,max:1,step:.01},a0={min:25e4,max:2e7,step:25e4},eg="termdock:mobile-media-compression-v1",bu={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function tv(){try{const e=JSON.parse(localStorage.getItem(eg)||"null");return!e||typeof e!="object"?bu:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:J3.includes(e.imageMaxDimension)?e.imageMaxDimension:bu.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=i0.min&&e.imageQuality<=i0.max?e.imageQuality:bu.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:ev.includes(e.videoMaxHeight)?e.videoMaxHeight:bu.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=a0.min&&e.videoBitrate<=a0.max?e.videoBitrate:bu.videoBitrate}}catch{return bu}}const tg=hc((e,t)=>({preferences:tv(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(eg,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===eg||e.key===null)&&tg.setState({preferences:tv(),saveFailed:!1})});function yh(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 KE({result:e,message:t,onClose:r}){const{locale:n}=zr(),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(Rn,{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 XE({result:e,onDismiss:t}){const{locale:r}=zr(),n=r==="zh",a=tg(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?`已尝试压缩 · 保留原图 ${yh(p.uploadedSize)},已上传`:`Compression tried · original ${yh(p.uploadedSize)} uploaded`:`${v} · ${yh(p.originalSize)} → ${yh(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(hi,{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&&Ii.createPortal(s.jsx(KE,{result:l.result,message:l.message,onClose:()=>d(null)}),document.body)]})}const JE=320,Fx="termdock:mobile-keyboard-expanded",$x="termdock:mobile-keyboard-preset-mode",Ux="termdock:mobile-long-press-mode",eN=80;function tN(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function zx(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 rN(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 em(){return xy()}const nN={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},sN=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=K1(),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:W,onViewportReadyChange:F,onContentReadyChange:U,onKeyboardVisibilityChange:V,suppressKeyboard:Z=!1,keyboardPortalTarget:ce=null,sharedMobileKeyboardLayout:xe=!1,suppressPageFlipRefresh:pe=!1,showDebug:te,onStatusChange:ke})=>{const{t:$e}=zr(),[Y]=k.useState(e||Xy()),[Ae,lt]=k.useState(()=>(e?Pm(e):null)??n.fontSize),Se=k.useMemo(()=>oE(),[]),ye=k.useMemo(()=>Qu("session"),[]),_e=k.useMemo(()=>Qu("keyboard"),[]),je=k.useRef(null),re=k.useRef(null);k.useEffect(()=>{Pm(Y)===null&<(n.fontSize)},[n.fontSize,Y]);const Oe=k.useMemo(()=>({...n,fontSize:Ae}),[n,Ae]),Ce=ow(),Ee=d||Ce,[Be,Ne]=k.useState(em),[le,He]=k.useState(!1),[rt,mt]=k.useState(!1),[ue,Ye]=k.useState(!1),[st,Ie]=k.useState(()=>typeof document>"u"?!0:!document.hidden&&Tu()),[We,Te]=k.useState(()=>typeof document>"u"?!0:document.hasFocus()),[H,oe]=k.useState(!1),be=k.useRef(H);be.current=H;const[Ze,Je]=k.useState(!1),[St,Vt]=k.useState(!1),[jt,vt]=k.useState(!1),[Zt,Pt]=k.useState(!0),{isOpen:Xt,keyboardHeight:zt}=K3({enabled:Be&&l}),[Lt,me]=k.useState(null),[Ge,pt]=k.useState(null),[q,at]=k.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(Fx)==="true"),[qt,Ve]=k.useState(()=>{if(typeof window>"u")return"auto";const se=window.localStorage.getItem($x);return se&&se.length>0?se:"auto"}),[De,er]=k.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(Ux)==="copy"?"copy":"arrows"),[et,Ct]=k.useState("idle"),[Nt,gt]=k.useState("idle"),[bt,It]=k.useState(0),[yt,pr]=k.useState(null),[nr,Cr]=k.useState(null),[cn,Lr]=k.useState(null),ge=k.useCallback(()=>Lr(null),[]),{preferences:Vr,update:it,saveFailed:dt}=tg(),{videoEnabled:sr,videoMaxHeight:xn,videoBitrate:an,imageEnabled:Me,imageMaxDimension:nt,imageQuality:wt}=Vr,[Rr,rn]=k.useState(!1),[Ir,ne]=k.useState(null),[ht,Ht]=k.useState(null),Ot=Yr(se=>se.sessions.get(Y)),{setTerminalSession:Tr,setConnecting:mr,appendToBuffer:Hr,replaceBuffer:_n,clearTerminalSession:dr,removeTerminalSession:bn,clearBuffer:hn,setSessionActiveProgram:Tn,setSessionCwd:ir,setSessionCopyMode:pn,setSessionAgentStatus:Pr,setSessionShellTitle:qr,setSessionPromptState:Wr,clearAgentNeedsReview:fs}=Yr.getState(),Br=k.useMemo(()=>`wt-${Y.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[Y]),Mn=Ot?.terminalSessionId??null,Sr=Ot?.mode??"shell",Kr=Ot?.activeProgram??null,nn=k.useMemo(()=>Eu(c),[c]),Fr=Sr==="tmux",ks=Ot?.bufferChunks??[],Or=Ot?.isConnecting??!1,Xr=Mn,fn=k.useCallback(async(se,T)=>{const j=II(se,Ot?.cwd||Ot?.directory);if(!j)return;let Q=j,O="directory";try{Q=(await j1(j)).path}catch(fe){if(!(fe instanceof Error)||fe.message!=="Path is not a directory")return;O="file"}try{const fe=Gt.getState();fe.setRightTab("files"),fe.openRight(),window.dispatchEvent(new CustomEvent(TI,{detail:{path:Q,kind:O,line:T}}))}catch{}},[Ot?.cwd,Ot?.directory]),K=t??Ot?.mode??"shell",Ue=K==="tmux"?r??Ot?.tmuxSessionName??null:null,[Et,kt]=k.useState(null),tr=k.useRef(!1),[Qr,cr]=k.useState(!1),[Sn,Ls]=k.useState(!1),[Zn,sn]=k.useState(null),[on,_r]=k.useState(0),[$r,Wn]=k.useState(null),Gn=te!==void 0?te:!1,un=k.useRef(null),Kn=k.useRef(null),kr=k.useRef(null),Er=k.useRef(null),gr=k.useRef(null),rs=k.useRef(!1),$n=k.useRef(null),kn=k.useRef([]),Ln=k.useRef(0),ps=k.useRef(!1),G=k.useRef(null),Le=k.useRef(null),Ke=k.useRef(-1),ct=k.useRef(null),qe=k.useRef(0),At=k.useRef(null),Rt=k.useRef(null),Bt=k.useRef(0),ot=k.useRef(0),Ft=k.useRef(!1),hr=k.useRef(null),Kt=k.useRef(null),z=k.useRef(!1),N=k.useRef(0),$=k.useRef(!1),ee=k.useRef(!1),ie=k.useRef(!1),Qe=k.useRef(null),ze=k.useRef(null),xt=k.useRef(null),_t=k.useRef(l);_t.current=l;const Mr=k.useRef(Ee);Mr.current=Ee;const Dt=k.useRef(d);Dt.current=d;const Gr=k.useRef(Be),dn=k.useRef(null),jn=k.useRef(null),ns=k.useRef(null),Un=k.useRef(null),fr=k.useRef(null),Mt=k.useRef(null),Dn=k.useRef(null),Vn=k.useCallback(()=>{const se=++N.current,T=()=>{se===N.current&&Je(!0)};if(typeof window>"u"){T();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(T))},[]),Ha=k.useCallback(se=>{if($.current){if(ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),se.x===0&&se.y>=se.rows-1){Pt(!1);return}ze.current=window.setTimeout(()=>{ze.current=null,Pt(!0)},eN)}},[]),Bn=k.useRef(null);k.useEffect(()=>()=>{Bn.current?.()},[]);const ss=k.useCallback(()=>{Bn.current||(Bn.current=$1(()=>{Bn.current=null;const se=Yr.getState(),T=kr.current,j=se.getTerminalSession(Y);if(!T||j?.mode!=="shell"||se.hasPendingBufferWrites(Y))return;const Q=lw(T),O=gr.current?.getDimensions();if(!Q||!O)return;const fe=gr.current?.serializeSnapshot();fe&&cw({id:T,version:1,...Q,...O,data:fe,savedAt:Date.now()})},2e3))},[Y]),$i=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)&&(uw(kr.current),ss()),!Ft.current||!QE({writtenChunkId:se,initialTargetChunkId:hr.current}))return;const Q=Kt.current;Kt.current=null,Q!==null&&gr.current?.notifyScreenSynchronized(Q),Ft.current=!1,hr.current=null,Vn()},[Vn,ss,Y]),ua=k.useCallback(se=>{if(!$.current)return;const T=Qe.current;T&&T.x===se.x&&T.y===se.y&&T.rows===se.rows||(Qe.current=se,ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),se.x===0&&se.y>=se.rows-1&&Pt(!1))},[]);k.useEffect(()=>{if(!p){ee.current=!1;return}ee.current||(ee.current=!0,ie.current=!1,$.current=!0,Qe.current=null,Pt(!1),ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),xt.current!==null&&window.clearTimeout(xt.current),xt.current=window.setTimeout(()=>{xt.current=null,ze.current!==null&&typeof window<"u"&&window.clearTimeout(ze.current),ze.current=null,$.current=!1,Pt(!0)},15e3))},[p]);const bs=k.useCallback(()=>{Un.current=null;const se=ns.current;ns.current=null,se&&qr(se.sessionId,se.title)},[qr]),Wa=k.useCallback((se,T)=>{if(ns.current={sessionId:se,title:T},Un.current===null){if(typeof window>"u"){bs();return}Un.current=window.requestAnimationFrame(bs)}},[bs]),wo=k.useCallback(()=>{Un.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Un.current),Un.current=null,ns.current=null},[]),zn=k.useCallback(async()=>{const se=K;return(await dw({preferredFrontendSessionId:Y,mode:se,tmuxSessionName:se==="tmux"?Ue||Br:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[K,Ue,Br,Y]),da=k.useRef(l);k.useEffect(()=>{if(!l){gr.current?.blur(),da.current=!1;return}if(da.current)return;da.current=!0;const se=zL(Be,pe);if(se==="single"){gr.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}se!=="none"&&gr.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[l,Be,pe,Xr]),k.useEffect(()=>{Gr.current=Be},[Be]);const ms=k.useCallback(()=>{!_t.current||Mr.current||gr.current?.focus()},[]);k.useLayoutEffect(()=>{Ee&&gr.current?.blur()},[Ee]),k.useEffect(()=>{if(!l||Ee||Zt||ie.current)return;ie.current=!0;const se=window.requestAnimationFrame(()=>{gr.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(se)},[Ee,l,Zt]);const La=k.useCallback(se=>{typeof window>"u"||typeof document>"u"||!_t.current||Mr.current||Gr.current||document.hidden||!Tu()||(dn.current!==null&&window.clearTimeout(dn.current),dn.current=window.setTimeout(()=>{if(dn.current=null,!_t.current||Mr.current||Gr.current||document.hidden||!Tu())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){_e("desktop resume focus skipped: editable active",{reason:se});return}_e("desktop resume focus",{reason:se}),gr.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),gr.current?.focus()},50))},[_e]);k.useEffect(()=>()=>{dn.current!==null&&typeof window<"u"&&window.clearTimeout(dn.current),dn.current=null,jn.current!==null&&typeof window<"u"&&window.clearTimeout(jn.current),jn.current=null,fr.current!==null&&typeof window<"u"&&window.clearTimeout(fr.current),fr.current=null,Mt.current!==null&&typeof window<"u"&&window.clearTimeout(Mt.current),Mt.current=null,xt.current!==null&&typeof window<"u"&&window.clearTimeout(xt.current),xt.current=null,ze.current!==null&&typeof window<"u"&&window.clearTimeout(ze.current),ze.current=null},[]),k.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const se=()=>{jn.current!==null&&window.clearTimeout(jn.current),jn.current=window.setTimeout(()=>{jn.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));HS({isActive:_t.current&&!Mr.current,isMobile:Gr.current,documentVisible:!document.hidden,activeElementIsEditable:Q})&&ms()},0)};return document.addEventListener("pointerup",se),()=>{document.removeEventListener("pointerup",se),jn.current!==null&&(window.clearTimeout(jn.current),jn.current=null)}},[ms]);const is=k.useCallback(()=>{Ui.current=!1,_r(se=>se+1)},[]),Ga=k.useCallback((se,T,j)=>{const Q=kr.current,O=Date.now();if(Q&&T&&hw(Q)){re.current={startedAt:O,strategy:"reconnect",reason:se},_a("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"reconnect",reason:se,active:_t.current});return}if(Q&&fw(Q,()=>{const fe=re.current;_a("info","PWA_RESUME terminal-responsive",{frontendSessionId:Y,backendSessionId:Q,durationMs:fe?Date.now()-fe.startedAt:null,strategy:fe?.strategy??"probe",reason:fe?.reason??se}),re.current=null,W?.(Y)},{visible:j})){re.current={startedAt:O,strategy:"probe",reason:se},_a("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"probe",reason:se,active:_t.current}),ye("[Terminal] resume probe sent",{reason:se,backendSessionId:Q,active:_t.current});return}if(ye("[Terminal] resume probe missing connection, restarting ensureSession",{reason:se,backendSessionId:Q,active:_t.current}),!PE({initialConnectionPending:z.current})){ye("[Terminal] resume probe deferred during initial websocket handshake",{reason:se,backendSessionId:Q});return}is()},[ye,W,is,Y]),Ks=k.useCallback((se,T)=>{const j=kr.current;j&&$n.current!==se&&($n.current=se,Jg(j,se,T),ye("[Terminal] flow-control state sent",{backendSessionId:j,paused:se,reason:T}))},[ye]),Xs=k.useCallback((se,T)=>{const j=kr.current;j&&At.current!==se&&(At.current=se,e2(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&&Rt.current!==se&&(Rt.current=se,t2(j,se,T),ye("[Terminal] viewing state sent",{backendSessionId:j,viewing:se,reason:T}))},[ye]),Va=US({isActive:l&&!Ee,viewportFocused:ue,documentVisible:st,windowFocused:We,streamReady:H}),Is=zS({isActive:l,documentVisible:st,windowFocused:We,streamReady:H,isDesktop:xo()!==null}),ha=k.useRef(Va),dl=k.useRef(Is);k.useEffect(()=>{ha.current=Va,Xs(Va,"logical-focus-change")},[Va,Xs,Xr]),k.useEffect(()=>{dl.current=Is,Hs(Is,"logical-viewing-change")},[Is,Hs,Xr]),vC(Xr,st,H),k.useEffect(()=>{const se=T=>{const j=T.detail;!j||j.sessionId!==Y||lt(j.fontSize??n.fontSize)};return window.addEventListener("termfontchange",se),()=>window.removeEventListener("termfontchange",se)},[Y,n.fontSize]),k.useEffect(()=>{const se=()=>{const O=!document.hidden&&Tu();Ie(O),O&&l&&La("visibility")},T=O=>{l&&La(O.persisted?"bfcache":"pageshow")},j=()=>{Te(!0),La("window-focus")},Q=()=>Te(!1);return document.addEventListener("visibilitychange",se),window.addEventListener(r2,se),window.addEventListener("pageshow",T),window.addEventListener("focus",j),window.addEventListener("blur",Q),()=>{document.removeEventListener("visibilitychange",se),window.removeEventListener(r2,se),window.removeEventListener("pageshow",T),window.removeEventListener("focus",j),window.removeEventListener("blur",Q)}},[l,La]),k.useEffect(()=>{if(!y||!R||!gi.current)return;const se=v,T=se<=0,j=je.current;if(j?.token===y&&(j.visible||!T))return;const Q=()=>{je.current={token:y,visible:T},gr.current?.requestRefresh(w,{skipScrollToBottom:!0}),Ga(se>0?"global-resume-background":"global-resume-visible",se<=0&&S,T)};if(se<=0){Q();return}const O=window.setTimeout(Q,se);return()=>window.clearTimeout(O)},[y,w,R,v,S,Ga]);const qa=k.useRef(0);k.useEffect(()=>{if(H){qa.current=0;return}if(!Qr||Et==="Authentication required"||Et===qh)return;const se=qa.current,T=Math.min(2e3*Math.pow(2,Math.min(se,4)),3e4),j=setTimeout(()=>{qa.current+=1,ye("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:qa.current,backendSessionId:kr.current}),kt("Reconnecting..."),cr(!1),is()},T);return()=>clearTimeout(j)},[Et,Qr,H,on,ye,is]),k.useEffect(()=>{if(typeof window>"u"){He(!1);return}const se=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;He(se)},[]),k.useEffect(()=>{(!l||!Be)&&mt(!1),l||Ye(!1)},[l,Be]),k.useEffect(()=>{kr.current=Xr,Ke.current=-1,Kt.current=null,At.current=null,Rt.current=null,$n.current=null},[Xr]),k.useEffect(()=>{B?.(Y,H)},[H,B,Y]),k.useEffect(()=>{U?.(Y,H&&Ze&&St)},[Ze,St,H,U,Y]),k.useEffect(()=>{Fr||(ps.current=!1,G.current=null,Le.current&&(clearTimeout(Le.current),Le.current=null))},[Fr]),k.useEffect(()=>{Xr&&gr.current?.requestRefresh("session-key-change",{force:!0})},[Xr]),k.useEffect(()=>{const se=l&&Be&&Xt;_e("visibility signal",{sessionId:Y,isActive:l,isMobile:Be,isInputFocused:rt,isViewportKeyboardOpen:Xt,viewportKeyboardHeight:zt,visible:se}),V?.(Y,se)},[V,Y,l,Be,Xt,zt,_e]),k.useEffect(()=>{l&&x&&x!==qe.current&&(qe.current=x,ms())},[x,ms,l]),k.useEffect(()=>{Er.current=Y},[Y]),k.useEffect(()=>{!Be&&(Lt!==null||Ge!==null)&&(me(null),pt(null),ct.current=null)},[Be,Lt,Ge]),k.useEffect(()=>{!Xr&&(Lt!==null||Ge!==null)&&(me(null),pt(null),ct.current=null)},[Xr,Lt,Ge]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Fx,q?"true":"false")},[q]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem($x,qt)},[qt]),k.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ux,De)},[De]),k.useEffect(()=>{Ne(em());const se=()=>{Ne(em())};return window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]);const as=k.useCallback(()=>{Bt.current+=1,ot.current+=1,bs(),wo();const se=un.current;un.current=null,Kn.current=null,z.current=!1,be.current=!1,oe(!1),gr.current?.setSessionReady(!1);const T=kr.current;T&&Jg(T,!1,"stream-disconnect"),rs.current=!1,$n.current=null,kn.current=[],se?.()},[wo,bs]),Rs=k.useCallback(async se=>{if(Kn.current===se){ye(`[startStream] Skipping - already connected to ${se}`);return}ye(`[startStream] Starting stream for frontendSessionId=${Y} backendSessionId=${se}`),sn(null),N.current+=1,Ft.current=!1,hr.current=null,Je(!1),Vt(!1),as();const T=Bt.current+1;Bt.current=T,z.current=!0;const j=Yr.getState().getTerminalSession(Y);if(j?.mode==="shell"&&!j.bufferChunks.length){const O=await Promise.race([pw(se),new Promise(fe=>window.setTimeout(()=>fe(null),75))]);if(Bt.current!==T||Er.current!==Y)return;if(O&&!Yr.getState().getTerminalSession(Y)?.bufferChunks.length){Yr.getState().replaceBuffer(Y,[O.data]);const fe=gr.current?.getDimensions();fe?.cols===O.cols&&fe.rows===O.rows&&mw(se,O.seq,O.epoch)}}const Q=Se.connect(se,{onEvent:O=>{if(Bt.current!==T)return;const fe=Y;if(fe)switch(O.type){case"connected":{ot.current+=1,z.current=!1;const we=re.current;we&&(_a("info","PWA_RESUME terminal-connected",{frontendSessionId:fe,backendSessionId:kr.current,durationMs:Date.now()-we.startedAt,strategy:we.strategy,reason:we.reason}),re.current=null),W?.(fe),(O.runtime||O.ptyBackend)&&ye(`[Terminal] connected frontendSessionId=${fe} backendSessionId=${kr.current} runtime=${O.runtime??"unknown"} pty=${O.ptyBackend??"unknown"} cwd=${O.cwd??"unknown"}`),mr(fe,!1),kt(null),cr(!1),sn(null),be.current=!0,oe(!0),kr.current&&(e2(kr.current,ha.current,"stream-connected"),t2(kr.current,dl.current,"stream-connected")),gr.current?.setSessionReady(!0),$n.current=null,Ks(rs.current,"stream-connected"),O.tuiProgress!==void 0&&Yr.getState().setSessionTuiProgress(fe,O.tuiProgress??null),O.shellTitle!==void 0&&Yr.getState().setSessionShellTitle(fe,O.shellTitle??null),O.promptState!==void 0&&O.promptState!==null&&Yr.getState().setSessionPromptState(fe,O.promptState);const Pe=Yr.getState().getTerminalSession(fe);if(Pe?.terminalSessionId&&O.mode&&Yr.getState().setTerminalSession(fe,{sessionId:Pe.terminalSessionId,cols:80,rows:24,mode:O.mode,tmuxSessionName:O.tmuxSessionName??null,cwd:O.cwd??null}),O.activeProgram!==void 0&&Tn(fe,O.activeProgram??null,O.activeProgramSource??null,O.activeProgramRaw??null),gr.current?.requestRefresh("connected",{force:!0,reconcileServerSize:_t.current}),O.mode!=="tmux"&&(Wn(null),pn(fe,!1)),ye("[Terminal] Connected event received:",{frontendSessionId:fe,backendSessionId:kr.current,storeHasState:!!Pe,storeTerminalId:Pe?.terminalSessionId,hasHistoryInStore:!!Pe?.history?.length,historyLength:Pe?.history?.length??0}),Pe?.history&&Pe.history.length>0){ye(`[Terminal] Restoring ${Pe.history.length} history chunks to frontend session ${fe}`);const Jt=Pe.history.reduce((Ur,Jr)=>Ur+Jr.length,0),or=Math.max(300,Math.min(2e3,Math.ceil(Jt/200)));Ln.current=Date.now()+or,Pe.history.forEach(Ur=>{Hr(fe,Ur,{markActivity:!1})}),Yr.getState().setSessionHistory(fe,[]),ye(`[Terminal] History restoration complete for ${fe}`)}else ye(`[Terminal] No history to restore for ${fe}`);const Xe=O.replayChunks,ft=!!Pe?.history?.length||!!Xe?.length;if(ft?Ft.current=!0:Vn(),Xe&&Xe.length>0){let Jt=null;if(O.replayOutOfWindow)ye(`[Terminal] Replay out-of-window, atomically replacing buffer (${Xe.length} chunks)`),Jt=_n(fe,LC(Xe));else{ye(`[Terminal] Replay incremental: ${Xe.length} chunks`);for(const Jr of Xe)Hr(fe,Jr)}const or=Xe.reduce((Jr,Qn)=>Jr+Qn.length,0),Ur=Math.max(200,Math.min(1500,Math.ceil(or/200)));Ln.current=Math.max(Ln.current,Date.now()+Ur),hr.current=Jt}ft&&hr.current===null&&(hr.current=Yr.getState().flushPendingBufferWrites(fe),hr.current===null&&(Ft.current=!1,Vn()));break}case"reconnecting":{be.current=!1,oe(!1),sn(we=>we??Date.now()),kt("Reconnecting..."),cr(!1);break}case"data":{O.data&&(rs.current?kn.current.push(O.data):Hr(fe,O.data));break}case"tmux-layout":{Wn(O.layout??null),O.layout&&pn(fe,O.layout.inCopyMode);break}case"tmux-screen-sync":{const we=O.generation??0;if(we<Ke.current)break;Ke.current=we,N.current+=1,Ft.current=!0,Je(!1),kn.current=[],gr.current?.prepareScreenReplacement(),Kt.current=we,hr.current=_n(fe,IC(O.chunks??[])),hr.current===null&&(Kt.current=null,gr.current?.notifyScreenSynchronized(we),Ft.current=!1,Vn()),typeof O.cols=="number"&&typeof O.rows=="number"&&gr.current?.notifyServerSize(O.cols,O.rows,"tmux-screen-sync");break}case"active-program":{Tn(fe,O.activeProgram??null,O.activeProgramSource??null,O.activeProgramRaw??null);break}case"cwd":{ir(fe,O.cwd??null);break}case"agent-status":{Pr(fe,{agentStatus:O.agentStatus??null,agentIndicator:O.agentIndicator??null,agentStatusDetail:O.agentStatusDetail??null,agent:O.agent??null,agentMessage:O.agentMessage??null,agentNativeSessionId:O.agentNativeSessionId??null,agentResumeRecovered:O.agentResumeRecovered===!0,agentRich:O.agentRich===!0,agentActivity:O.agentActivity??0,agentCwd:O.agentCwd??null,reviewed:O.reviewed??null});break}case"git-status":{Yr.getState().setSessionGitStatus(fe,O.gitStatus??null);break}case"focus-mode":{ye("[Terminal] focus tracking mode",{backendSessionId:kr.current,requested:O.focusTrackingRequested===!0});break}case"resize-ack":{gr.current?.acknowledgeResize({seq:O.seq,ok:O.ok!==!1,cols:O.cols,rows:O.rows,screenSyncPending:O.screenSyncPending,screenSyncGeneration:O.screenSyncGeneration});break}case"pty-size":{typeof O.cols=="number"&&typeof O.rows=="number"&&gr.current?.notifyServerSize(O.cols,O.rows,O.source);break}case"shell-title":{Wa(fe,O.title??null);break}case"prompt-state":{Wr(fe,O.state??"idle",O.exitCode??null);break}case"tui-progress":{Yr.getState().setSessionTuiProgress(fe,O.tuiProgress??null);break}case"exit":{const we=typeof O.exitCode=="number"?O.exitCode:null,Pe=typeof O.signal=="number"?O.signal:null;Hr(fe,`\r
|
|
76
|
-
[Process exited${we!==null?` with code ${we}`:""}${Pe!==null?` (signal ${Pe})`:""}]\r
|
|
77
|
-
`),dr(fe),mr(fe,!1),kt("Terminal session ended"),oe(!1),cr(!1),sn(null),Wn(null),pn(fe,!1),as();break}}},onError:(O,fe)=>{if(Bt.current!==T)return;const we=Y;if(!we)return;z.current=!1,be.current=!1,oe(!1);const Pe=fe&&O.message==="Authentication required",Xe=Qx(O),ft=Pe?O.message:Xe||fe?"Reconnecting...":O.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${fe}):`,ft),Xe&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:kr.current,frontendSessionId:we,isActive:l,isMobile:Be,fatal:fe,stack:new Error().stack}),kt(ft),cr(!!fe),fe&&(sn(null),mr(we,!1),as(),Xe&&(ye("[onError] Session lost, auto-recreating"),kt("Reconnecting..."),cr(!1),dr(we),hn(we),kr.current=null,Ui.current=!1,is()))}},{...nN,getDimensions:()=>gr.current?.getDimensions()??null});un.current=()=>{Q.close(),Bt.current===T&&(Kn.current=null)},Kn.current=se},[Hr,hn,dr,ye,as,Vn,W,Ks,is,Wa,mr,Tn,Pr,pn,ir,Wr,Se,Y]);k.useEffect(()=>{const se=HE({isActive:l,isStreamReady:H,reconnectStartedAt:Zn,now:Date.now()});if(se===null)return;const T=window.setTimeout(()=>{ye("[Terminal] visible reconnect watchdog expired",{backendSessionId:kr.current,reconnectStartedAt:Zn}),as(),mr(Y,!1),kt("Reconnecting..."),cr(!1),sn(Date.now()),is()},se);return()=>window.clearTimeout(T)},[ye,as,l,H,Zn,is,Y,mr]);const Ui=k.useRef(!1),gi=k.useRef(!1),xi=k.useRef(0);k.useEffect(()=>()=>{xi.current+=1,Ui.current=!1,as()},[as]);const hl=k.useRef(K),Js=k.useRef(Ue);k.useEffect(()=>{const se=hl.current,T=Js.current;hl.current=K,Js.current=Ue,Er.current===Y&&(se===K&&T===Ue||(Ui.current=!1,as(),_r(j=>j+1)))},[K,Ue,as,Y]),k.useEffect(()=>{if(Er.current!==Y&&(ye(`[useEffect] sessionId changed from ${Er.current} to ${Y}, allowing reinitialization`),Ui.current=!1,gi.current=!1),Ui.current&&Er.current===Y){ye(`[useEffect] Already initialized for sessionId=${Y}, skipping`);return}if(!jt)return;const se=async fe=>{if(ye(`[ensureSession] Starting for sessionId=${Y}, runId=${fe}`),!Er.current||Er.current!==Y){ye(`[ensureSession] SessionId mismatch or stale run (current=${Er.current}, target=${Y}), skipping`);return}if(fe!==xi.current){ye(`[ensureSession] Stale run detected (runId=${fe}, currentRunId=${xi.current}), skipping`);return}const we=Yr.getState(),Pe=we.getTerminalSession(Y),Xe=Pe?.mode??K;ye("[ensureSession] Current state from store:",{terminalSessionId:Pe?.terminalSessionId,mode:Pe?.mode,tmuxSessionName:Pe?.tmuxSessionName,isConnecting:Pe?.isConnecting});let ft=Pe?.terminalSessionId??null,Jt=!ft;if(ft&&Xe!==K?(ye(`[ensureSession] Store mode mismatch for ${ft}: current=${Xe} desired=${K}, will create new session`),Jt=!0,we.clearTerminalSession(Y),ft=null):ft&&K==="tmux"&&Ue&&Pe?.tmuxSessionName!==Ue&&(ye(`[ensureSession] Store tmux name mismatch for ${ft}: current=${Pe?.tmuxSessionName} desired=${Ue}, will create new session`),Jt=!0,we.clearTerminalSession(Y),ft=null),ft&&Se.checkHealth&&!_t.current){ye(`[ensureSession] Checking health of existing session ${ft}`);try{const or=await Se.checkHealth(ft);if(ye("[ensureSession] Health check result:",or),!or.healthy)ye(`[ensureSession] Session ${ft} is NOT healthy (healthy=${or.healthy}), will create new session`),ye("[ensureSession] Health check details:",or),Jt=!0,or.mode&&Pe?.terminalSessionId&&we.setTerminalSession(Y,{sessionId:Pe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),we.clearTerminalSession(Y),ye("[ensureSession] Cleared unhealthy session from store");else{ye(`[ensureSession] Session ${ft} is healthy, reusing it, cwd=${or.cwd}, clients=${or.clients}, lastActivity=${Date.now()-(or.lastActivity||0)}ms ago`),or.mode&&Pe?.terminalSessionId&&we.setTerminalSession(Y,{sessionId:Pe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),ye(`[ensureSession] Setting terminalIdRef to ${ft} and starting stream`),kr.current=ft,Rs(ft),ye(`[ensureSession] Successfully reused healthy session ${ft}, returning early`);return}}catch(or){ye(`[ensureSession] Failed to check health of session ${ft}:`,or),ye("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ye(`[ensureSession] Decision: shouldCreateNewSession=${Jt}, terminalId=${ft}`),Jt){ye(`[ensureSession] Creating new session, shouldCreateNewSession=${Jt}, runId=${fe}`),kt(null),cr(!1),we.setConnecting(Y,!0);const Ur=Yr.getState().getTerminalSession(Y),Qn=(Ur?.mode??K)===K&&(K!=="tmux"||!Ue||Ur?.tmuxSessionName===Ue);if(Ur?.terminalSessionId&&Qn)ye(`[ensureSession] Race condition avoided: another instance already created session ${Ur.terminalSessionId}`),we.setConnecting(Y,!1),ft=Ur.terminalSessionId,Jt=!1;else try{const vr=await zn();if(ye(`[ensureSession] Opened managed backend session ${vr.sessionId}`),fe!==xi.current){ye(`[ensureSession] Stale run after session creation (runId=${fe}, currentRunId=${xi.current}), leaving ${vr.sessionId} for sibling`);return}we.setTerminalSession(Y,vr),ye(`[ensureSession] Updated store with new session ${vr.sessionId}`),ft=vr.sessionId}catch(vr){if(fe!==xi.current){ye("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(vr instanceof Jd&&o1(vr)){ye("[ensureSession] Confirmed missing persisted session:",{sessionId:Y,error:vr.message}),we.clearTerminalSession(Y),kt(qh),cr(!0),we.setConnecting(Y,!1);return}kt("Reconnecting..."),cr(!0),we.setConnecting(Y,!1);return}}if(fe!==xi.current){ye(`[ensureSession] Stale run before starting stream (runId=${fe}, currentRunId=${xi.current}), skipping`);return}if(!ft){ye(`[ensureSession] No terminalId, terminalId=${ft}`);return}ye(`[ensureSession] Starting stream for session ${ft}`),kr.current=ft,Rs(ft),ye(`[ensureSession] ensureSession completed for sessionId=${Y}, terminalId=${ft}`)};let T=null,j=null;const Q=()=>{j=null,!(Ui.current&&Er.current===Y)&&(ye(`[useEffect] Running ensureSession for sessionId=${Y}, hasInitialized=${Ui.current}`),Ui.current=!0,gi.current=!0,T=++xi.current,se(T))};if(!E&&!gi.current){ye(`[useEffect] Holding background connection until the selected session is ready: ${Y}`);return}const O=gi.current?0:Math.max(0,L);return O>0?(ye(`[useEffect] Delaying initial connection for sessionId=${Y} by ${O}ms`),j=window.setTimeout(Q,O)):Q(),()=>{j!==null&&window.clearTimeout(j),ye(`[useEffect] Cleanup for sessionId=${Y}, runId=${T??"pending"}`)}},[Y,on,Rs,as,Se,ye,K,Ue,Br,L,E,jt]);const Uo=k.useCallback(async()=>{if(Y&&!Sn){Ls(!0),kt(null),cr(!1),sn(null),as();try{Se.forceKill&&await Se.forceKill({sessionId:Y})}catch{}bn(Y),hn(Y),gr.current?.clear(),await new Promise(se=>setTimeout(se,100));try{mr(Y,!0);const se=await zn();Tr(Y,se),kr.current=se.sessionId,Rs(se.sessionId)}catch(se){kt(se instanceof Jd&&o1(se)?qh:"Reconnecting..."),cr(!0),mr(Y,!1)}finally{Ls(!1)}}},[Y,Sn,as,Se,bn,hn,mr,Tr,Rs,zn]),fa=k.useCallback((se,T,j,Q)=>{if(!(kr.current!==T||ot.current!==j)){if(se instanceof Jd&&Qx(se)){ye("[Terminal] operation backend missing, recovering",{terminalId:T,sessionId:Y}),kt("Reconnecting..."),cr(!1),as(),dr(Y),kr.current=null,mr(Y,!0),is();return}kt(se instanceof Error?se.message:Q)}},[dr,ye,as,is,Y,mr]),fl=k.useCallback((se,T)=>{const j=T?.ownedPaste?bC(T.ownedPaste,Y,se):!1;if(T?.ownedPaste&&!j||Dt.current||(Mr.current||D1())&&!j)return Promise.resolve(!1);const Q=()=>!!T?.ownedPaste&&yC(T.ownedPaste,Y)&&_t.current&&!Dt.current&&be.current&&!tr.current&&!document.hidden&&navigator.onLine!==!1&&Tu();if(j&&!Q())return Promise.resolve(!1);if(!_t.current&&!T?.targeted||!se)return;const O=hE(se),fe=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(se);if(Fr&&fe&&(ps.current=!0),Date.now()<Ln.current)return;let we=se,Pe=T?.consumeModifier??!1;if(!T?.skipModifierTransform&&Lt&&se.length>0){const Ur=se[0];if(Ur.length===1&&/[a-zA-Z]/.test(Ur)){const Jr=Ur.toUpperCase();Lt==="ctrl"?(we=String.fromCharCode(Jr.charCodeAt(0)&31),Pe=!0):Lt==="alt"&&(we=`\x1B${se}`,Pe=!0)}Pe||(Lt==="alt"&&(we=`\x1B${se}`),Pe=!0)}const Xe=kr.current;if(!Xe)return;const ft=ot.current,or=(async()=>{try{if(Fr&&!O&&ps.current&&Se.tmuxAction){ps.current=!1;try{await Se.tmuxAction(Xe,{action:"copy-mode",enabled:!1})}catch{}if(kr.current!==Xe||ot.current!==ft)return!1;if(fE(we))return!0}return j&&(!Q()||kr.current!==Xe||ot.current!==ft)||(await Se.sendInput(Xe,we),j&&(!Q()||kr.current!==Xe||ot.current!==ft))?!1:(fs(Y),!0)}catch(Ur){return fa(Ur,Xe,ft,"Failed to send input"),!1}})();return Pe&&(Ge||me(null),ms()),or},[Lt,fs,ms,fa,Fr,Ge,Y,Se]);k.useEffect(()=>{const se=T=>{const j=T,Q=j.detail?.sessionId;if(Q?Q!==Y:!_t.current)return;const O=j.detail?.text;if(!O)return;const fe=j.detail?.nonce;if(tr.current||!gr.current){fe&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:fe,ok:!1}}));return}const we=xC(j.detail,Y),Pe=j.detail?.ownedPaste&&!we?Promise.resolve(!1):gr.current.sendSequence(O,{paste:j.detail?.paste,submitAfterPaste:j.detail?.submitAfterPaste,targeted:!!Q,ownedPaste:we??void 0});fe&&Promise.resolve(Pe).then(Xe=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:fe,ok:Xe===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:fe,ok:!1}}))}),WS(Gr.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){_e("xterm resize push skipped: no terminalId",{cols:se,rows:T});return}_e("xterm resize push",{cols:se,rows:T}),Se.resize({sessionId:Q,cols:se,rows:T,seq:j}).catch(O=>{gr.current?.acknowledgeResize({seq:j,ok:!1}),O&&/session not found/i.test(String(O.message||O))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Q,cols:se,rows:T,stack:new Error().stack})})},[Se,_e]),os=k.useCallback(async se=>{const T=kr.current;if(!T||!Se.tmuxAction)return;const j=ot.current;try{const Q=await Se.tmuxAction(T,se);if(kr.current!==T||ot.current!==j)return;Q.layout&&(Wn(Q.layout),se.action==="switch-session"&&(Tr(Y,{sessionId:T,cols:80,rows:24,mode:"tmux",tmuxSessionName:Q.layout.sessionName}),gw(Y,{tmuxSessionName:Q.layout.sessionName}).catch(O=>{console.warn("[Terminal] failed to update inventory after tmux switch",O)})))}catch(Q){fa(Q,T,j,"Failed to execute tmux action")}},[fa,Y,Tr,Se]);k.useEffect(()=>{if(!$r||!Xr)return;const T=$r.windows.find(j=>j.id===$r.activeWindowId)?.panes.find(j=>j.id===$r.activePaneId);T&&gr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${Xr}:${$r.sessionId}:${T.id}:${T.width}x${T.height}`})},[$r,Xr]);const Ms=k.useCallback((se,T=5)=>{const j=Math.max(1,Math.min(Math.floor(T)||1,40));ps.current=!0;const Q=G.current;if(Q&&Q.direction===se){Q.lines+=j;return}Q&&os({action:"scroll",direction:Q.direction,lines:Q.lines}).finally(()=>{ms()}),G.current={direction:se,lines:j},Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{const O=G.current;O&&(G.current=null,os({action:"scroll",direction:O.direction,lines:O.lines}).finally(()=>{ms()}))},0)},[ms,os]),Ni=k.useCallback(se=>{const T=Date.now(),j=ct.current,Q=j!==null&&j.modifier===se&&T-j.timestamp<=JE;if(ct.current={modifier:se,timestamp:T},Ge===se){pt(null),me(null);return}if(Q){pt(se),me(se);return}Ge!==null&&Ge!==se&&pt(null),me(O=>O===se?null:se)},[Ge]),zo=k.useCallback(se=>{if(Ye(se&&_t.current),_e("input focus changed",{focused:se,isActive:_t.current,isMobile:Gr.current}),!Gr.current||!_t.current){mt(!1);return}mt(T=>T===se?T:se)},[_e]),jl=k.useCallback(se=>{if(rs.current=se,Ks(se,"viewport-watermark"),!se&&kn.current.length>0){const T=Y;if(T){const j=kn.current;kn.current=[];for(const Q of j)Hr(T,Q)}}},[Hr,Ks,Y]),Es=k.useCallback(se=>{_t.current&&gr.current?.ensureSizeMatches(se)},[]),Ia=k.useRef(null);k.useEffect(()=>{if(!l)return;const se=Ia.current;if(!se)return;const T=()=>Es("pointerdown"),j=()=>Es("keydown"),Q=()=>Es("touchstart"),O=()=>Es("wheel");return se.addEventListener("pointerdown",T),se.addEventListener("keydown",j),se.addEventListener("touchstart",Q,{passive:!0}),se.addEventListener("wheel",O,{passive:!0}),()=>{se.removeEventListener("pointerdown",T),se.removeEventListener("keydown",j),se.removeEventListener("touchstart",Q),se.removeEventListener("wheel",O)}},[l,Es]);const ml=k.useCallback(se=>{gr.current=se},[]),Xn=k.useCallback(se=>{vt(se),F?.(Y,se)},[F,Y]),zi=k.useCallback(se=>{const T=wE(se);if(!T)return;const j=Lt!==null;gr.current?.sendSequence(T,{consumeModifier:j})},[Lt]),Ri=k.useCallback(se=>{const T=gE(se);if(T.length===0)return;const j=Lt!==null;gr.current?.sendSequence(Mx(T[0]),{consumeModifier:j});for(let Q=1;Q<T.length;Q+=1){const O=T[Q];window.setTimeout(()=>{gr.current?.sendSequence(Mx(O))},mE*Q)}},[Lt]),Hi=k.useCallback(()=>{gr.current?.pasteClipboardText()},[]),gs=k.useCallback(se=>{Mt.current!==null&&(window.clearTimeout(Mt.current),Mt.current=null),gt(se),(se==="inserted"||se==="failed")&&(Mt.current=window.setTimeout(()=>{Mt.current=null,gt("idle")},1400))},[]),Ws=k.useCallback(()=>{gs("idle"),It(0),Dn.current?.click()},[gs]),Dl=k.useCallback(()=>{rn(!0)},[]),Wi=k.useCallback(se=>{const T=se.currentTarget.files?.[0];if(se.currentTarget.value="",!T)return;const j=Y;Cr(null),pr(null),Lr(null),It(0),gs("uploading");const Q=sr&&T.type.startsWith("video/")?{maxHeight:xn,videoBitrate:an,onProgress:It}:null,O=Me&&tN(T)?{maxDimension:nt,quality:wt}:null;let fe=Q?"视频压缩":O?"图片压缩":"文件上传";(async()=>{const we=Q?await(await Oc(async()=>{const{compressVideoLocally:Pe}=await import("./videoCompression-DrQ47oZA.js");return{compressVideoLocally:Pe}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(T,Q):O?await(await Oc(async()=>{const{compressImageLocally:Pe}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Pe}},[])).compressImageLocally(T,O):T;fe="文件上传",await ZE(we,(Pe,Xe)=>L0(Pe,Xe,void 0,It),Pe=>(fe="插入终端",Ox(l1(Pe,null),j,()=>_t.current&&!tr.current&&Er.current===j&&Yr.getState().activeSessionId===j))),(Q||O)&&Lr({file:we,kind:Q?"video":"image",originalSize:T.size,uploadedSize:we.size,originalRetained:we===T})})().then(()=>gs("inserted"),we=>{we instanceof yf&&Cr({path:we.uploaded.path,sessionId:j});const Pe=we instanceof yf?we.uploaded.path:zx(we);pr({stage:fe,detail:Pe}),rn(!0),gs("failed"),_a("warn","MOBILE_MEDIA_UPLOAD failed",{stage:fe,detail:Pe})})},[an,sr,xn,Me,nt,wt,Y,gs]),Gi=k.useCallback(async()=>{const se=nr;if(!se||se.sessionId!==Y)return;rn(!1),await new Promise(j=>window.requestAnimationFrame(()=>j())),gs("uploading"),await Ox(l1(se.path,null),se.sessionId,()=>_t.current&&!tr.current&&Er.current===se.sessionId&&Yr.getState().activeSessionId===se.sessionId)?(Cr(null),pr(null),gs("inserted")):(rn(!0),gs("failed"))},[nr,Y,gs]);k.useEffect(()=>{if(!Rr||!sr)return;let se=!0;return Ht(null),ne({phase:"checking-cache"}),Oc(async()=>{const{prepareLocalVideoCompression:T}=await import("./videoCompression-DrQ47oZA.js");return{prepareLocalVideoCompression:T}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:T})=>{if(se)return T(j=>{se&&ne(j)})}).catch(T=>{se&&Ht(zx(T))}),()=>{se=!1}},[Rr,sr]);const ln=Or||Et!==null;tr.current=ln;const pa=k.useRef(Kr);ln||(pa.current=Kr);const Vi=ln?pa.current:Kr,Ea=k.useMemo(()=>xE(Vi,nn),[Vi,nn]),Mi=k.useMemo(()=>Dx(nn,qt),[qt,nn]),ji=!Be&&qt!=="auto"&&Mi.id!=="default"&&Mi.showOnDesktop!==!0?"auto":qt,ei=ji==="auto"?Ea:ji,ws=k.useMemo(()=>Dx(nn,ei),[ei,nn]),Gs=k.useMemo(()=>ws.actions.filter(se=>se.sequence.trim().length>0).map((se,T)=>({...se,label:a1(se,T)})),[ws.actions]),Di=k.useMemo(()=>G3(Kr),[Kr]),Na=ws.label,ti=k.useMemo(()=>ji!=="auto"?`Manual preset: ${ws.label}`:Di?`Auto preset · ${ws.label} (${Di})`:"Auto preset",[Di,ji,ws.label]),ys=k.useCallback(se=>{Ve(se)},[]),Ya=k.useCallback(()=>{er(se=>se==="copy"?"arrows":"copy"),Ct("idle")},[]),Za=k.useCallback(()=>{typeof window>"u"||(fr.current!==null&&window.clearTimeout(fr.current),fr.current=window.setTimeout(()=>{fr.current=null,Ct("idle")},1200))},[]),As=k.useCallback(se=>{fr.current!==null&&typeof window<"u"&&(window.clearTimeout(fr.current),fr.current=null),Ct(se?"copied":"failed"),Za()},[Za]),Ka=k.useCallback(se=>{at(se)},[]),Bl=k.useMemo(()=>Be?bE(nn):yE(nn),[Be,nn]),Ho=k.useMemo(()=>xw(a),[a]);k.useEffect(()=>{if(!Fr||!H||!jt||!Xr)return;const se=EC(Ho);se&&Se.sendInput(Xr,se).catch(T=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",T)})},[Fr,H,jt,Xr,Se,Ho]);const Ao=k.useMemo(()=>`terminal::${Y}`,[Y]);k.useEffect(()=>{ke?.({isConnecting:Or,isRestarting:Sn,hasError:!!Et,sessionId:Xr})},[Or,Sn,Et,Xr,ke]);const ma=!Xr||Or||Sn,Ra=k.useCallback((se,T)=>{if(ma)return;const j=Math.max(1,Math.min(Math.floor(T)||1,40));Ms(se,j)},[Ms,ma]);k.useEffect(()=>{if(!l||!Be)return;gr.current?.requestRefresh("resize",{skipScrollToBottom:!Xt,force:!0})},[l,Be,Xt,zt,Y]),k.useEffect(()=>{if(!l||!Be)return;const se=T=>{const j=T.detail;gr.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,Be,Y]);const Wo=!Z&&(Be||ws.id==="default"||ws.showOnDesktop===!0),ga=l,ls=Be&&!xe?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Go=Be&&!xe?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,qi=s.jsx(AE,{visible:Wo,interactive:ga,presentation:Be?"mobile":"desktop-actions",activeModifier:Lt,lockedModifier:Ge,disabled:ma,defaultShowExtended:q,presetLabel:Na,presetModeLabel:ti,presetMode:ji,presetOptions:Bl,includeAlt:ws.includeAlt,presetRowLayout:ws.rowLayout,extraActions:Gs,onKeyPress:zi,onTextPress:Ri,onPastePress:Be?Hi:void 0,onFilePress:Be?Ws:void 0,onFileLongPress:Be?Dl:void 0,fileUploadState:Nt,fileUploadProgress:bt,longPressMode:De,copyFeedback:et,onLongPressModeToggle:Ya,onModifierToggle:Ni,onPresetSelect:ys,onExpandedChange:Ka}),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:ls,children:[s.jsx("input",{ref:Dn,type:"file",className:"hidden",onChange:Wi}),Rr&&Ii.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:()=>rn(!1),"aria-label":$e("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:()=>rn(!1),children:$e("common.close")})]}),yt&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[yt.stage,"失败。",yt.stage.endsWith("压缩")?"原文件未上传。":yt.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:yt.detail})]}),nr&&s.jsx("button",{type:"button",onClick:()=>{Gi()},disabled:Nt==="uploading"||nr.sessionId!==Y,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:$e("common.retry")})]}),dt&&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:Vr.showResultToast,onChange:se=>it({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:Me,onChange:se=>it({imageEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),Me&&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:nt,onChange:se=>it({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:J3.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(wt*100),"%",s.jsx("input",{type:"range",min:i0.min,max:i0.max,step:i0.step,value:wt,onChange:se=>it({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:sr,onChange:se=>it({videoEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),sr&&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:xn,onChange:se=>it({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:ev.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:["目标视频码率:",an/1e6," Mbps",s.jsx("input",{type:"range",min:a0.min,max:a0.max,step:a0.step,value:an,onChange:se=>it({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:ht?"本地转码器准备失败,请关闭开关后重试。":rN(Ir)}),Ir?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),ht&&s.jsx("p",{className:"text-[11px] text-destructive",children:ht})]})]})]}),document.body),Gn&&s.jsx(TE,{isMobile:Be,isInputFocused:rt,isIOS:le,isConnecting:Or,connectionError:Et,terminalSessionId:Xr}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Ho.background,...Go},children:[s.jsx("div",{ref:Ia,className:"h-full w-full box-border",children:s.jsx(bw,{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:$e("terminal.componentFailed")})]})}),children:s.jsx(iE,{ref:ml,sessionKey:Ao,sessionId:Y,isLayoutVisible:m,chunks:ks,onInput:fl,onResize:pl,onFlowControl:jl,onTmuxScroll:Fr?Ra:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Be?()=>{gr.current?.sendSequence(" ")}:void 0,onInputFocusChange:zo,onMobileLongPressCopyResult:As,onReadyChange:Xn,onSizeSynchronizedChange:Vt,onWritesSettled:Ha,onWriteProgress:$i,onCursorPositionChange:ua,onDirectoryLinkActivate:fn,terminalSettings:Oe,theme:Ho,enableTouchScroll:Be,mobileLongPressMode:De,autoFocus:!Ee&&!Be&&!gl,cursorVisible:!Ee&&Zt,suppressSmoothScroll:!Ze||!St,className:Ee||!Zt?"terminal-focus-suspended":void 0},Ao)})}),s.jsx(XE,{result:cn,onDismiss:ge}),s.jsx(CE,{connectionError:Et,isFatalError:Qr,isRestarting:Sn,isConnecting:Or,onHardRestart:Uo})]}),ce?Z?null:Ii.createPortal(qi,ce):qi]})};function iN({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=zr(),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(Fo,{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(Ff,{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(By,{size:14})})]})}const aN="termdock:startup:";function Nu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${aN}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function Hx(e,t){e||Ii.flushSync(t)}const c1="horizontal";function Du(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function Yh(e,t){if(!Array.isArray(e)||e.length!==t)return Du(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return Du(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?Du(t):r.map(a=>a/n)}function oN(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 lN(e){return e==="horizontal"||e==="vertical"||e==="grid"}function cN(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=oN(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:lN(c.layout)?c.layout:c1,ratios:Yh(c.ratios,d.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:Yh(c.gridColumnRatios,p.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:Yh(c.gridRowRatios,p.rows)}:{}})}return n}function uN(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?Yh(n.ratios,a.length):Du(a.length)}]})}function y0(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function tm(e,t,r){if(!t||!r||t===r)return e;const n=y0(e,t),a=y0(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===c1)?"grid":n?.layout??c1,ratios:Du(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 dN(e,t){const r=y0(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:Du(n.length)}:a)}function hN(e,t){const r=y0(e,t);return r?e.filter(n=>n.id!==r.id):e}function fN(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 pN(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 u1=320,rv=1,mN=u1+120,d1="termdock:split-workspaces:v2",nv="termdock:split-workspace:v1",gN=.1,xN=.9;function rm(){if(typeof window>"u")return{mobile:!1,landscape:!1};const e=xy();return{mobile:e,landscape:e&&window.innerWidth>window.innerHeight}}function bN(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(d1);if(e)return cN(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(nv)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(xN,Math.max(gN,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 yN(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 Wx(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function vh(e,t){const r=vf(e,t);if(r===null)return;const n=e.wrapperEl;Wx(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),Wx(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 h1(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 vf(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function vN(e,t){const r=h1(e),n=vf(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=rv}function wN(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 sv(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function iv(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 AN(e,t){const r=sv(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function Gx(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...iv(n),history:a?.history}})}function Vx(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function qx(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 Yx(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function TN(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 SN(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 CN=({terminalSettings:e=K1(),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}=zr(),W=b.useMemo(()=>Qu("session"),[]),F=b.useMemo(()=>Qu("terminal"),[]),[U,V]=b.useState([]),[Z,ce]=b.useState(null),xe=b.useRef(0),pe=b.useRef(0),te=es(z=>z.activePaneId);b.useEffect(()=>{es.getState().setActivePane(Z)},[Z]);const[ke,$e]=b.useState(null),[Y,Ae]=b.useState(!0),[lt,Se]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[ye,_e]=b.useState(()=>new Set),[je,re]=b.useState(()=>({token:0,completed:new Set})),[Oe,Ce]=b.useState(0),[Ee,Be]=b.useState(()=>new Set),[Ne,le]=b.useState(()=>new Set),He=b.useRef(new Map),[rt,mt]=b.useState(()=>new Set),ue=b.useRef(!1),Ye=b.useRef(null),st=b.useRef({}),[Ie,We]=b.useState(null),[Te,H]=b.useState(()=>bN()),[oe,be]=b.useState(!1),Ze=b.useCallback(z=>{xe.current+=1,be(z)},[]),Je=b.useRef(null),St=b.useRef(oe);St.current=oe,I0(Je,oe&&!!Z,()=>Ze(!1));const[Vt,jt]=b.useState(null),[vt,Zt]=b.useState(null),Pt=b.useRef(new Set),[Xt,zt]=b.useState(null),[Lt,me]=b.useState(null),[Ge,pt]=b.useState(!1),[q,at]=b.useState(()=>rm().mobile),[qt,Ve]=b.useState(()=>rm().landscape),[De,er]=b.useState(null),[et,Ct]=b.useState(null),Nt=b.useRef(a),gt=b.useRef(!1),bt=b.useRef(!1),It=b.useRef(null),yt=b.useRef(null),pr=b.useRef(q),nr=b.useRef(null),Cr=b.useCallback(z=>{z!==nr.current&&(xe.current+=1),nr.current=z,ce(z)},[]);b.useEffect(()=>Gt.subscribe((z,N)=>{(z.rightOpen!==N.rightOpen||z.rightTab!==N.rightTab)&&(xe.current+=1)}),[]);const cn=b.useRef(0),Lr=b.useRef([]),ge=b.useRef(0),Vr=b.useRef(null),it=b.useRef(!1),dt=b.useRef(!0),sr=b.useRef(null),xn=b.useRef(""),an=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const z=()=>{const N=rm();pr.current=N.mobile,at(N.mobile),Ve(N.landscape)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[]);const{sessions:Me,inventory:nt,activeSessionId:wt,isLoading:Rr,openSession:rn,setActiveSession:Ir,removeSession:ne,renameSession:ht,resetSessionCustomName:Ht,reorderSessions:Ot,restoreSessions:Tr}=yw(),mr=nt?.tmuxRecovery??null;b.useEffect(()=>{mr&&R?.()},[mr,R]),b.useEffect(()=>{me(null),zt(null)},[mr?.id]);const Hr=b.useCallback(async()=>{zt("restore"),me(null);try{const z=await vw();await Tr(),z.failed>0&&me(B("tab.tmuxRecoveryPartial",{restored:z.restored,failed:z.failed}))}catch{me(B("tab.tmuxRecoveryFailed"))}finally{zt(null)}},[Tr,B]),_n=b.useCallback(async()=>{zt("dismiss"),me(null);try{await ww(),await Tr()}catch{me(B("tab.tmuxRecoveryDismissFailed"))}finally{zt(null)}},[Tr,B]),dr=Gt(z=>z.groupByFolder),bn=uf(z=>z.collaborationGroups),hn=Gt(z=>z.leftOpen||z.rightOpen),Tn=Gt(z=>z.rightSidebarWidthContextKey),ir=Gt(z=>z.rightSidebarWidth),pn=Gt(z=>z.rightPinned),[Pr,qr]=b.useState(()=>Yx(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(z=>{const N=Yx(z.sessions);qr($=>TN($,N)?$:N)}),[]);const{arranged:Wr}=b.useMemo(()=>lf(U,z=>Pr.get(z.id)??null,dr,"",Te,bn),[U,Pr,dr,Te,bn]),fs=b.useRef(Wr);fs.current=Wr;const Br=b.useMemo(()=>yN(Wr,Te),[Wr,Te]),Mn=b.useRef(Br);Mn.current=Br;const Sr=b.useMemo(()=>y0(Te,Z),[Z,Te]),Kr=b.useMemo(()=>{const z=Br.find(N=>N.sessions.some($=>$.id===Z));return new Set(z?.sessions.map(N=>N.id)??[])},[Z,Br]),nn=b.useMemo(()=>{const z=new Map;if(!m||v<=0)return z;for(const N of Br){const $=N.sessions[0];if(!$)continue;const ee=Aw($.id,Pr.get($.id)??null,N.workspace?.id??null);if(!(ee===Tn?pn:Tw($.id,Pr.get($.id)??null,N.workspace?.id??null)))continue;const Qe=ee===Tn?ir:Sw($.id,Pr.get($.id)??null,N.workspace?.id??null),ze=Ph(Qe,v,w);z.set(N.key,ze+by)}return z},[Pr,w,m,pn,Tn,ir,v,Br]),Fr=b.useMemo(()=>Jp(U.map(z=>({id:z.id,backendSessionId:z.sessionId})),d),[d,U]),ks=b.useMemo(()=>Vx(Me,wt),[wt,Me]),Or=bh({prioritySessionId:Fr,activeSessionId:ke??Z,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}),Xr=b.useMemo(()=>WE(Br.flatMap(z=>z.sessions.map(N=>N.id)),Kr),[Kr,Br]),fn=Or!==null&&ye.has(Or),K=b.useMemo(()=>{const z=new Set(Kr);return ke&&z.add(ke),!z.size&&Or&&z.add(Or),z},[Kr,ke,Or]),Ue=je.token===lt.token&&$E(K,je.completed),Et=Ue||Oe===lt.token?lt.token:-1;b.useEffect(()=>{if(!lt.token||Ue)return;const z=window.setTimeout(()=>Ce(lt.token),EE);return()=>window.clearTimeout(z)},[lt.token,Ue]);const kt=b.useCallback((z,N)=>{_e($=>{if($.has(z)===N)return $;const ie=new Set($);return N?ie.add(z):ie.delete(z),ie})},[]),tr=b.useCallback(z=>{const N=cn.current;re(ee=>{if(ee.token===N&&ee.completed.has(z))return ee;const ie=new Set(ee.token===N?ee.completed:[]);return ie.add(z),{token:N,completed:ie}});const $=Fr??ke??nr.current;z===$&&Nu("foreground-stream-connected")},[ke,Fr]),Qr=b.useCallback((z,N)=>{Be($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]),cr=b.useCallback((z,N)=>{le($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]);b.useEffect(()=>{for(const[z,N]of He.current){const $=U.find(ee=>ee.id===z);if(!$||$.sessionId!==N.backendSessionId){He.current.delete(z);continue}!ye.has(z)||!Ee.has(z)||!Ne.has(z)||(He.current.delete(z),gy(N.backendSessionId,`${N.command}\r`).catch(ee=>{console.error("[Session] Failed to send startup command:",ee)}))}},[U,ye,Ee,Ne]);const Sn=Or!==null&&Ee.has(Or),Ls=Or!==null&&Ne.has(Or);b.useEffect(()=>{Sn&&Nu("foreground-viewport-ready")},[Sn]),b.useEffect(()=>{Ls&&Nu("foreground-content-ready")},[Ls]),b.useEffect(()=>{if(!E)return;if(!Y&&U.length===0){E();return}if(!Sn||!fn||!Ls)return;const z=[...Kr].every(Qe=>Ee.has(Qe)&&ye.has(Qe)&&Ne.has(Qe));let N=0,$=0;const ee=()=>{N=requestAnimationFrame(()=>{$=requestAnimationFrame(()=>{Nu("initial-viewport-presented"),E()})})};z&&ee();const ie=z?void 0:window.setTimeout(ee,8e3);return()=>{cancelAnimationFrame(N),cancelAnimationFrame($),clearTimeout(ie)}},[fn,Ls,Sn,Y,E,U.length,Kr,Ee,ye,Ne]);const Zn=b.useMemo(()=>q?ME({slides:Br.map(z=>z.sessions.map(N=>N.id)),visibleSessionIds:Kr,foregroundSessionId:Or}):rt,[q,Br,Kr,Or,rt]);b.useEffect(()=>{if(q||Kr.size===0)return;const z=new Set(Kr),N=Br.findIndex($=>$.sessions.some(ee=>Kr.has(ee.id)));for(let $=-2;$<=2;$+=1)$!==0&&Br[N+$]?.sessions.forEach(ee=>z.add(ee.id));mt($=>{let ee=!1;const ie=new Set($);for(const Qe of z)ie.has(Qe)||(ie.add(Qe),ee=!0);return ee?ie:$})},[q,Kr,Br]);const sn=hC(Zn);b.useEffect(()=>{if(!ke)return;if(!U.some(N=>N.id===ke)){$e(null);return}if(!Ee.has(ke)||!ye.has(ke)||!Ne.has(ke))return;const z=window.setTimeout(()=>{$e(N=>N===ke?null:N),Nt.current&&!pr.current&&We({sessionId:ke,token:Date.now()})},80);return()=>window.clearTimeout(z)},[Ne,ke,ye,U,Ee]),b.useEffect(()=>{typeof window>"u"||(Te.length>0?(window.localStorage.setItem(d1,JSON.stringify(Te)),window.localStorage.removeItem(nv)):window.localStorage.removeItem(d1))},[Te]),b.useEffect(()=>{Rr||Y||Te.length===0||H(z=>uN(z,U.map(N=>N.id)))},[Rr,Y,U,Te.length]),b.useEffect(()=>{if(!Vt)return;const z=window.setTimeout(()=>jt(null),3200);return()=>window.clearTimeout(z)},[Vt]),nr.current=Z,cn.current=lt.token,Lr.current=U,Vr.current=wt,it.current=Rr,dt.current=Y,Nt.current=a;const on=b.useCallback((z=Ye.current)=>{const N=ge.current,$=typeof window<"u"?window.visualViewport:null,ee=z?h1(z):null,ie=z?vf(z,N):null;return{sessionsLength:Lr.current.length,workspaceSlidesLength:Mn.current.length,sessionIds:Lr.current.map(Qe=>Qe.id),activeSessionId:nr.current,activeSessionIndex:N,persistedActiveId:Vr.current,isLoading:it.current,isRestoring:dt.current,activeIndex:z?.activeIndex??null,previousIndex:z?.previousIndex??null,animating:z?.animating??null,allowTouchMove:z?.allowTouchMove??null,width:z?.width??null,translate:ee,targetTranslate:ie,translateDelta:ee!==null&&ie!==null?ee-ie:null,snapGridLength:z?.snapGrid?.length??null,targetSnap:z?.snapGrid?.[N]??null,visualViewport:$?{width:Math.round($.width),height:Math.round($.height),offsetTop:Math.round($.offsetTop)}:null}},[]),_r=b.useCallback((z,N)=>{W(z,{...on(),...N})},[W,on]);b.useEffect(()=>{Rr||Y||Z!==wt&&Ir(Z)},[Z,Rr,Y,wt,Ir]);const $r=b.useMemo(()=>{if(Wr.length===0||!Z)return 0;const z=Br.findIndex(N=>N.sessions.some($=>$.id===Z));return z>=0?z:0},[Br,Z]);ge.current=$r;const Wn=b.useCallback(()=>{It.current&&(clearTimeout(It.current),It.current=null)},[]),Gn=b.useCallback(z=>{Wn(),It.current=setTimeout(()=>{It.current=null,gt.current=!1,_r("[swiper:touch-guard-clear]",{reason:z})},mN)},[Wn,_r]),un=b.useCallback((z,N={})=>{const $=Ye.current,ee=ge.current,ie=Mn.current;if(!$||ie.length===0||ee<0||ee>=ie.length)return;if(gt.current){_r("[swiper:sync-skip-touch]",{reason:z});return}if($.animating){_r("[swiper:sync-skip-animating]",{reason:z});return}const Qe=h1($),ze=vf($,ee),xt=Qe!==null&&ze!==null&&Math.abs(Qe-ze)<=rv,_t=$.activeIndex===ee;if(_r("[swiper:sync-check]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0}),!(_t&&xt)){if(_t){vh($,ee),_r("[swiper:sync-forced-active]",{reason:z,translateAligned:xt,immediate:N.immediate===!0});return}N.immediate?(vh($,ee),$.slideTo(ee,0,!1),vh($,ee)):$.slideTo(ee,u1,!1),_r("[swiper:sync-applied]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0})}},[_r]);b.useEffect(()=>{const z=N=>{const $=N;Ye.current&&(Ye.current.allowTouchMove=!$.detail.locked),_r("[swiper:gesture-lock]",{locked:$.detail.locked})};return document.addEventListener("termdock:gesture-lock",z),()=>document.removeEventListener("termdock:gesture-lock",z)},[_r]),b.useEffect(()=>{if(U.length===0){Z!==null&&Cr(null);return}if(!Z){if(!p)return;Cr(bh({prioritySessionId:Fr,activeSessionId:null,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}));return}U.some(N=>N.id===Z)||Cr(U[0].id)},[U,Z,p,Fr,ks]);const Kn=b.useCallback((z,N)=>{if(N&&Date.now()<an.current){st.current[z]=!1;return}st.current[z]=N,Ct($=>N?z:$===z?null:$)},[]),kr=b.useCallback(z=>{if(!gt.current&&z.activeIndex!==ge.current){_r("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:z.activeIndex,expectedActiveIndex:ge.current}),requestAnimationFrame(()=>un("ignored-layout-slide-change",{immediate:!0}));return}const N=Mn.current[z.activeIndex],$=N?.sessions.some(Qe=>Qe.id===Z)?Z:N?.sessions[0]?.id;if(_r("[swiper:slide-change]",{nextSessionId:$??null,instanceActiveIndex:z.activeIndex}),!$||$===Z)return;const ee=!!Z&&st.current[Z]===!0,ie=Nt.current&&(!pr.current||ee);if(yt.current=$,Cr($),ie){We({sessionId:$,token:Date.now()});return}We(null)},[U,Z,_r,un]);b.useLayoutEffect(()=>{if(yt.current===Z){_r("[swiper:sync-skip-swiper-driven]",{activeSessionId:Z}),yt.current=null;return}un("active-session-index",{immediate:!0})},[Z,$r,U.length,un,_r]),b.useEffect(()=>{const z=Ye.current;if(!z)return;const N=Br.length>1&&!hn&&!oe;z.allowTouchMove!==N&&(z.allowTouchMove=N,_r("[swiper:allow-touch-sync]",{nextAllow:N,sidebarOverlayOpen:hn}))},[Br.length,_r,hn,oe]);const Er=b.useCallback(z=>{const N=Ye.current;if(!N)return;const $=N.el;if(_r("[swiper:layout-before]",{reason:z,scrollLeft:$?.scrollLeft??null}),$&&($.scrollLeft=0),N.updateSize(),N.updateSlides(),N.updateProgress(),N.updateSlidesClasses(),$&&($.scrollLeft=0),_r("[swiper:layout-after]",{reason:z,scrollLeft:$?.scrollLeft??null}),gt.current||N.animating){_r("[swiper:layout-skip-sync-motion]",{reason:z});return}un(`layout:${z}`,{immediate:!0}),requestAnimationFrame(()=>{const ee=Ye.current;ee&&(gt.current||ee.animating||vh(ee,ge.current))})},[_r,un]);b.useEffect(()=>()=>Wn(),[Wn]);const gr=Br.map(z=>z.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Er("group-change"))},[dr,gr,Er]),b.useEffect(()=>{let z=null,N="mount";const $=xt=>{N=xt,z===null&&(z=requestAnimationFrame(()=>{z=null,Er(`viewport-change:${N}`)}))},ee=()=>$("window-resize"),ie=()=>$("visual-viewport-resize"),Qe=()=>$("visual-viewport-scroll"),ze=xt=>{$(`measured:${xt.detail?.source??"unknown"}`)};return window.addEventListener("resize",ee),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",Qe),document.addEventListener(n2,ze),$("mount"),()=>{window.removeEventListener("resize",ee),window.visualViewport?.removeEventListener("resize",ie),window.visualViewport?.removeEventListener("scroll",Qe),document.removeEventListener(n2,ze),z!==null&&cancelAnimationFrame(z)}},[Er]),b.useEffect(()=>{if(typeof document>"u")return;let z=null,N=null;const $=_t=>{if(_t!=="online"&&document.hidden)return;const Mr=performance.now();if(!UE(N,Mr))return;N=Mr;const Dt=_t==="bfcache"||_t==="online"?_t:"visibility",Gr=zE();wp(),_a("info","PWA_RESUME scheduled",{source:_t,forceForegroundReconnect:Gr,activeSessionId:nr.current}),Se(dn=>({token:dn.token+1,reason:Dt,forceForegroundReconnect:Gr})),requestAnimationFrame(()=>Er(`resume:${_t}:raf`)),z&&clearTimeout(z),z=setTimeout(()=>{z=null,Er(`resume:${_t}:settled`)},320)},ee=()=>{if(document.hidden){wp();return}$("visibility")},ie=()=>{wp()},Qe=_t=>{$(_t.persisted?"bfcache":"pageshow")},ze=()=>$("online"),xt=()=>$("focus");return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",ie),window.addEventListener("pageshow",Qe),window.addEventListener("online",ze),window.addEventListener("focus",xt),()=>{document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",ie),window.removeEventListener("pageshow",Qe),window.removeEventListener("online",ze),window.removeEventListener("focus",xt),z&&clearTimeout(z)}},[Er]),b.useLayoutEffect(()=>{if(!OE(Y))return;const z=wN(U),N=JSON.stringify(z);z.length>0&&N!==xn.current?(xn.current=N,console.warn("[session-invariant] duplicate mapping detected",z)):z.length===0&&xn.current&&(xn.current=""),L?.({sessions:U.map($=>({id:$.id,name:$.name,customName:$.customName,mode:$.mode,tmuxSessionName:$.tmuxSessionName})),activeSessionId:Z,splitWorkspaces:Te.map(({id:$,name:ee,sessionIds:ie,layout:Qe})=>({id:$,...ee?{name:ee}:{},sessionIds:ie,layout:Qe}))})},[U,Z,Te,L,Y]),b.useEffect(()=>{if(Rr||ue.current)return;ue.current=!0;const z=Jp(Me.map(Qe=>({id:Qe.sessionId,backendSessionId:Qe.backendSessionId??null})),d),N=Vx(Me,wt),$=bh({prioritySessionId:p?z:null,activeSessionId:null,persistedActiveSessionId:N,firstSessionId:Me[0]?.sessionId??null}),ee=sv(Me.map(iv));if(W("[Session] Restoring",ee.length,"persisted sessions (one-shot)"),_r("[swiper:restore-start]",{persistedSessionIds:Me.map(Qe=>Qe.sessionId),nextActiveSessionId:$}),ee.length>0){const Qe=Yr.getState();ee.forEach(xt=>{xt.sessionId&&Qe.setTerminalSession(xt.id,{sessionId:xt.sessionId,cols:80,rows:24,mode:xt.mode,tmuxSessionName:xt.tmuxSessionName,history:xt.history})}),Me.forEach(xt=>{xt.agent!==void 0&&Qe.setSessionAgentIdentity(xt.sessionId,xt.agent),xt.activeProgram!=null&&Qe.setSessionActiveProgram(xt.sessionId,xt.activeProgram),xt.cwd!=null&&Qe.setSessionCwd(xt.sessionId,xt.cwd),xt.shellTitle!=null&&Qe.setSessionShellTitle(xt.sessionId,xt.shellTitle)}),V(ee);const ze=$||ee[0]?.id||null;Cr(ze),_r("[swiper:restore-complete]",{restoredSessionIds:ee.map(xt=>xt.id),nextActiveSessionId:ze})}(async()=>(ee.length===0&&await sr.current?.({createIfEmpty:!0}),Ae(!1),requestAnimationFrame(()=>un("restore-finished",{immediate:!0}))))()},[Rr,Me,wt,W,_r,un,p,d]),b.useEffect(()=>{if(!p||Y||U.length===0)return;const z=Jp(U.map($=>({id:$.id,backendSessionId:$.sessionId})),d),N=bh({prioritySessionId:z,activeSessionId:nr.current,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null});N&&N!==nr.current&&Cr(N)},[p,d,Y,ks,U]);const rs=b.useRef([]),$n=b.useRef(!1);nr.current=Z,b.useEffect(()=>{if(Y)return;const z=rs.current,N=Me,$=new Map(z.map(Dt=>[Dt.sessionId,Dt])),ee=Yr.getState();for(const Dt of N){const Gr=$.get(Dt.sessionId),dn=Yr.getState().sessions.get(Dt.sessionId);Dt.agent!==void 0&&JSON.stringify(Dt.agent)!==JSON.stringify(dn?.agent)&&(dn?.agent==null||JSON.stringify(Dt.agent)!==JSON.stringify(Gr?.agent))&&ee.setSessionAgentIdentity(Dt.sessionId,Dt.agent),Dt.activeProgram!=null&&Dt.activeProgram!==dn?.activeProgram&&(dn?.activeProgram==null||Dt.activeProgram!==Gr?.activeProgram)&&ee.setSessionActiveProgram(Dt.sessionId,Dt.activeProgram),Dt.cwd!=null&&Dt.cwd!==dn?.cwd&&(dn?.cwd==null||Dt.cwd!==Gr?.cwd)&&ee.setSessionCwd(Dt.sessionId,Dt.cwd),Dt.shellTitle!=null&&Dt.shellTitle!==dn?.shellTitle&&(dn?.shellTitle==null||Dt.shellTitle!==Gr?.shellTitle)&&ee.setSessionShellTitle(Dt.sessionId,Dt.shellTitle)}if(!$n.current){V(Dt=>Gx(Dt,N)),rs.current=N,$n.current=!0;return}const ie=new Set(z.map(Dt=>Dt.sessionId)),Qe=new Set(N.map(Dt=>Dt.sessionId)),ze=new Map(z.map(Dt=>[Dt.sessionId,Dt.name]));rs.current=N,V(Dt=>{const Gr=Gx(Dt,N);return(!nr.current||!Gr.some(dn=>dn.id===nr.current))&&Cr(Gr[0]?.id??null),Gr});const xt=N.filter(Dt=>!ie.has(Dt.sessionId)),_t=[...ie].filter(Dt=>!Qe.has(Dt)),Mr=N.filter(Dt=>ie.has(Dt.sessionId)&&ze.get(Dt.sessionId)!==Dt.name);(xt.length>0||_t.length>0||Mr.length>0)&&W("[Session] Synced persisted sessions:",{newSessionIds:xt.map(Dt=>Dt.sessionId),removedSessionIds:_t,renamedSessionIds:Mr.map(Dt=>Dt.sessionId),currentSessionIds:N.map(Dt=>Dt.sessionId)});for(const Dt of N){if(!Dt.backendSessionId)continue;Yr.getState().setTerminalSession(Dt.sessionId,{sessionId:Dt.backendSessionId,cols:80,rows:24,mode:Dt.mode,tmuxSessionName:Dt.tmuxSessionName})}},[Me,Y,W]);const kn=b.useCallback(async z=>{const N=++pe.current,$=xe.current,ee=()=>N===pe.current&&$===xe.current&&(z?.shouldActivate?.()??!0);try{const ie=Gt.getState(),Qe=Z?{rightOpen:ie.rightOpen,rightPinned:ie.rightPinned,rightSidebarWidth:ie.rightSidebarWidth,rightTab:ie.rightTab}:null,ze=z?.mode==="tmux"||z?.mode==="shell"?z.mode:c,xt=(z?.tmuxSessionName||"").trim(),_t=l.trim(),Mr=ze==="tmux"?xt||_t||SN():null,Dt=typeof z?.cwd=="string"?z.cwd:null,Gr=Z?Yr.getState().sessions.get(Z)?.cwd??null:null,dn=typeof Dt=="string"&&Dt.trim().length>0?Dt:typeof Gr=="string"&&Gr.trim().length>0?Gr:void 0,jn=await rn({preferredFrontendSessionId:z?.preferredFrontendSessionId,requireExisting:z?.requireExisting===!0,mode:ze,tmuxSessionName:Mr,cwd:dn,termType:"xterm-256color",createIfEmpty:z?.createIfEmpty===!0},{shouldActivate:ee});if(jn.discarded)return z?.onResult?.({ok:!1,error:"unknown"}),null;const ns=jn.session,Un=jn.terminalSession;!jn.reused&&Qe&&Gt.getState().initializeRightSidebarForSession(ns.sessionId,Un.cwd??dn??null,Qe);const fr={id:ns.sessionId,name:ns.name,customName:ns.customName===!0,sessionId:Un.sessionId,mode:Un.mode??ns.mode,tmuxSessionName:Un.tmuxSessionName??ns.tmuxSessionName},Mt=z?.command?.trim();return Mt&&He.current.set(fr.id,{backendSessionId:Un.sessionId,command:Mt}),V(Vn=>AN(Vn,fr)),ee()&&Cr(fr.id),Yr.getState().setTerminalSession(fr.id,{sessionId:Un.sessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName,activeProgram:Un.activeProgram,activeProgramRaw:Un.activeProgramRaw,activeProgramSource:Un.activeProgramSource,cwd:Un.cwd}),W("[Session] Inventory opened session:",{frontendSessionId:fr.id,backendSessionId:Un.sessionId,reused:jn.reused,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName}),z?.onResult?.({ok:!0,sessionId:fr.id}),fr.id}catch(ie){return console.error("[Session] Failed to create new session:",ie),z?.onResult?.({ok:!1,error:eC(ie)}),null}},[c,l,Z,rn,W]);sr.current=kn;const Ln=b.useCallback((z,N={})=>{xe.current+=1,es.getState().setActivePane(z);const $=nr.current,ee=!!$&&st.current[$]===!0;if(Cr(z),pr.current&&N.preserveMobileKeyboard===!1){an.current=Date.now()+600,$&&(st.current[$]=!1),Ct(null),We(null);const ie=document.activeElement;ie instanceof HTMLTextAreaElement&&ie.closest(".terminal-viewport-container")&&ie.blur();return}ee&&pr.current&&Ct(z),Nt.current&&(!pr.current||ee)&&We({sessionId:z,token:Date.now()})},[]),ps=b.useCallback(z=>{Cr(z),Ze(!0),jt(null)},[]),G=b.useCallback(z=>{const N=nr.current;!N||N===z||(H($=>tm($,N,z)),Ze(!1),Ln(N,{preserveMobileKeyboard:!1}))},[Ln]),Le=b.useCallback(async()=>{const z=nr.current;if(!z||Ge)return;const N=xe.current;pt(!0);const $=Yr.getState().sessions.get(z)?.cwd??void 0,ee=await kn({cwd:$||void 0,mode:c,shouldActivate:()=>!1});if(pt(!1),!ee){jt(B("common.error"));return}!St.current||N!==xe.current||!Lr.current.some(ie=>ie.id===z)||(H(ie=>tm(ie,z,ee)),Ze(!1),Ln(z,{preserveMobileKeyboard:!1}))},[Ln,c,kn,Ge,B]),Ke=b.useCallback(z=>{H(N=>hN(N,z)),z&&Ln(z,{preserveMobileKeyboard:!1})},[Ln]),ct=b.useCallback(z=>{H(N=>dN(N,z)),Ln(z,{preserveMobileKeyboard:!1})},[Ln]),qe=b.useCallback(z=>{if(U.find($=>$.id===z)){if(xe.current+=1,es.getState().setActivePane(z),z===nr.current)return;if(Cr(z),!BE({isMobile:pr.current,viewportReady:Ee.has(z),streamReady:ye.has(z),contentReady:Ne.has(z)})){$e(null),Nt.current&&We({sessionId:z,token:Date.now()}),W("[Session] Switched to session:",z);return}mt(ee=>{if(ee.has(z))return ee;const ie=new Set(ee);return ie.add(z),ie}),$e(z),W("[Session] Switched to session:",z)}},[Ne,W,ye,U,Ee]),At=b.useCallback((z,N)=>{N.trim()&&(V($=>$.map(ee=>ee.id===z?{...ee,name:N.trim(),customName:!0}:ee)),ht(z,N.trim()))},[ht]),Rt=b.useCallback(z=>{V(N=>N.map($=>$.id===z?{...$,customName:!1}:$)),Ht(z)},[Ht]),Bt=b.useCallback(z=>{V(N=>{const $=new Map(N.map(ze=>[ze.id,ze])),ee=z.map(ze=>$.get(ze)).filter(ze=>ze!==void 0),ie=new Set(z),Qe=N.filter(ze=>!ie.has(ze.id));return[...ee,...Qe]}),Ot(z),W("[Session] Reordered sessions:",z),requestAnimationFrame(()=>{Ye.current?.update()})},[Ot,W]),ot=b.useCallback(async z=>{const N=typeof z=="string"?z:z.sessionId,$=typeof z=="string"?"auto":z.closeMode??"auto",ee=U.find(xt=>xt.id===N);if(!ee||Pt.current.has(N))return;Pt.current.add(N),xe.current+=1;const ie=s2(Wr,N,xt=>xt.id);try{$==="destroy"&&ee.mode==="tmux"&&ee.tmuxSessionName?(await yy(ee.tmuxSessionName),W("[Session] Destroyed tmux session:",{frontendSessionId:ee.id,tmuxSessionName:ee.tmuxSessionName})):ee.sessionId&&(await my(ee.sessionId),W("[Session] Closed backend terminal:",ee.sessionId))}catch(xt){console.error("[Session] Failed to close backend terminal:",xt),Zt({sessionId:N,closeMode:$});return}finally{Pt.current.delete(N)}Zt(xt=>xt?.sessionId===N?null:xt);const ze=Lr.current.filter(xt=>xt.id!==N).some(xt=>xt.id===ie)?ie:s2(Lr.current,N,xt=>xt.id);nr.current===N&&Cr(ze),V(xt=>xt.filter(_t=>_t.id!==N)),ne(N,ze),delete st.current[N],W("[Session] Closed session:",{sessionId:N,closeMode:$})},[U,Wr,ne,W]),Ft=b.useCallback(z=>{if(!z)return;const N=U.filter($=>$.sessionId===z);if(N.length!==0){N.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:z,frontendSessionIds:N.map($=>$.id)}),V($=>{const ee=$.filter(ie=>ie.sessionId!==z);return ee.length!==$.length&&!ee.some(Qe=>Qe.id===Z)&&Cr(ee.length>0?ee[0].id:null),ee});for(const $ of N)ne($.id),delete st.current[$.id];W("[Session] Backend gone, dropped local session(s):",N.map($=>$.id))}},[U,Z,ne,W]);b.useEffect(()=>{const z=fr=>{kn(fr.detail)},N=fr=>{qe(fr.detail)},$=()=>{const fr=nr.current;!fr||pr.current||We({sessionId:fr,token:Date.now()})},ee=fr=>{const Mt=fr;Mt.detail&&ps(Mt.detail)},ie=fr=>{const Mt=fr.detail;Ke(Mt??nr.current??void 0)},Qe=fr=>{const Mt=fr.detail;Mt&&ct(Mt)},ze=fr=>{const Mt=fr.detail,Dn=typeof Mt=="string"?Mt:Mt?.layout,Vn=typeof Mt=="string"?nr.current:Mt?.sessionId;Dn!=="horizontal"&&Dn!=="vertical"&&Dn!=="grid"||H(Ha=>Ha.map(Bn=>Bn.sessionIds.includes(Vn??"")?{...Bn,layout:Dn}:Bn))},xt=fr=>{const Dn=fr.detail?.direction;if(Dn!=="prev"&&Dn!=="next")return;const Vn=fs.current;if(Vn.length<=1)return;const Ha=nr.current,Bn=Ha?Vn.findIndex(Wa=>Wa.id===Ha):-1,ua=((Bn>=0?Bn:0)+(Dn==="next"?1:-1)+Vn.length)%Vn.length,bs=Vn[ua]?.id;bs&&bs!==Ha&&qe(bs)},_t=fr=>{ot(fr.detail)},Mr=fr=>{Ft(fr.detail)},Dt=fr=>{const Mt=fr;!Mt.detail?.sessionId||!Mt.detail?.name||At(Mt.detail.sessionId,Mt.detail.name)},Gr=fr=>{const Mt=fr;Mt.detail?.sessionId&&Rt(Mt.detail.sessionId)},dn=fr=>{const Mt=fr;Mt.detail?.sessionIds&&Bt(Mt.detail.sessionIds)},jn=fr=>{const Mt=fr.detail;!Mt?.workspaceId||!Array.isArray(Mt.sessionIds)||H(Dn=>fN(Dn,Mt.workspaceId,Mt.sessionIds))},ns=fr=>{const Mt=fr.detail;!Mt?.workspaceId||typeof Mt.name!="string"||H(Dn=>pN(Dn,Mt.workspaceId,Mt.name))},Un=fr=>{const Mt=fr.detail;!Mt?.primaryId||!Mt.secondaryId||Mt.primaryId===Mt.secondaryId||(H(Dn=>tm(Dn,Mt.primaryId,Mt.secondaryId)),Ln(Mt.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",z),window.addEventListener("switch-terminal-session",N),window.addEventListener("focus-active-terminal-session",$),window.addEventListener("open-terminal-split-chooser",ee),window.addEventListener("close-terminal-split",ie),window.addEventListener("remove-terminal-split-pane",Qe),window.addEventListener("set-terminal-split-direction",ze),window.addEventListener("cycle-terminal-session",xt),window.addEventListener("close-terminal-session",_t),window.addEventListener("close-terminal-session-by-backend",Mr),window.addEventListener("rename-terminal-session",Dt),window.addEventListener("reset-terminal-session-name",Gr),window.addEventListener("reorder-terminal-session",dn),window.addEventListener("reorder-terminal-split-workspace",jn),window.addEventListener("rename-terminal-split-workspace",ns),window.addEventListener("combine-terminal-split-sessions",Un),()=>{window.removeEventListener("new-terminal-session",z),window.removeEventListener("switch-terminal-session",N),window.removeEventListener("focus-active-terminal-session",$),window.removeEventListener("open-terminal-split-chooser",ee),window.removeEventListener("close-terminal-split",ie),window.removeEventListener("remove-terminal-split-pane",Qe),window.removeEventListener("set-terminal-split-direction",ze),window.removeEventListener("cycle-terminal-session",xt),window.removeEventListener("close-terminal-session",_t),window.removeEventListener("close-terminal-session-by-backend",Mr),window.removeEventListener("rename-terminal-session",Dt),window.removeEventListener("reset-terminal-session-name",Gr),window.removeEventListener("reorder-terminal-session",dn),window.removeEventListener("reorder-terminal-split-workspace",jn),window.removeEventListener("rename-terminal-split-workspace",ns),window.removeEventListener("combine-terminal-split-sessions",Un)}},[Ln,kn,qe,ps,Ke,ct,ot,Ft,At,Rt,Bt]),b.useEffect(()=>{if(!Sr||q)return;const z=N=>{if(!fC(N,D1())||!(N.ctrlKey||N.metaKey)||!N.shiftKey)return;if(Sr.layout==="horizontal"?N.key==="ArrowLeft"||N.key==="ArrowRight":Sr.layout==="vertical"?N.key==="ArrowUp"||N.key==="ArrowDown":N.key.startsWith("Arrow")){N.preventDefault(),N.stopPropagation();const ee=Sr.sessionIds.indexOf(nr.current??""),ie=N.key==="ArrowLeft"||N.key==="ArrowUp"?-1:1,Qe=(Math.max(0,ee)+ie+Sr.sessionIds.length)%Sr.sessionIds.length,ze=Sr.sessionIds[Qe];if(!ze)return;Ln(ze);return}N.key==="Backspace"&&(N.preventDefault(),N.stopPropagation(),Ke(nr.current??void 0))};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[Ln,Sr,Ke,q]);const hr=z=>{const N=Yr.getState().sessions.get(z.id);return il(z,N?.activeProgram??null,N?.cwd??null,void 0,N?.shellTitle??null,N?.promptState??null)},Kt=(z,N={})=>{const $=z.id===Z&&!te?.startsWith("@collaboration:"),ee=Kr.has(z.id)&&!N.hidden,ie=p&&DE({sessionId:z.id,foregroundSessionId:Or,visibleSessionIds:Kr,deferredViewportSessionIds:q?sn:Zn}),Qe=jE({sessionId:z.id,foregroundSessionId:Or,foregroundReady:fn,isVisible:ee})&&p,ze=FE({sessionId:z.id,foregroundSessionId:Or,requestToken:lt.token,foregroundCompletedToken:Et,isVisible:K.has(z.id)})&&p,xt=ee||z.id===Or||Zn.has(z.id)?0:Xr.get(z.id)??Vh;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:()=>{ee&&Hx($,()=>Ln(z.id))},onWheelCapture:()=>{Hx($,()=>Ln(z.id))},children:[N.showPaneTitle&&s.jsx(iN,{session:z,active:$,onActivate:()=>Ln(z.id),onToggleRightSidebar:$?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:ie&&s.jsx(sN,{sessionId:z.id,mode:z.mode,tmuxSessionName:z.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:$,focusSuspended:ke!==null,deferCursorUntilPositioned:ke===z.id||z.mode==="tmux"&&!Ne.has(z.id),isLayoutVisible:ee,initialConnectEnabled:Qe&&ze,resumeRequestEnabled:ze,suppressKeyboard:N.suppressKeyboard,keyboardPortalTarget:N.keyboardPortalTarget,sharedMobileKeyboardLayout:N.sharedMobileKeyboardLayout,suppressPageFlipRefresh:N.suppressPageFlipRefresh,focusRequestToken:Ie?.sessionId===z.id?Ie.token:0,resumeRequestToken:lt.token,resumeRequestReason:lt.reason,forceResumeReconnect:lt.forceForegroundReconnect&&K.has(z.id),resumeRequestDelayMs:K.has(z.id)?0:N.hidden?Vh:Xr.get(z.id)??Vh,initialConnectDelayMs:xt,onStreamReadyChange:kt,onStreamConnected:tr,onViewportReadyChange:Qr,onContentReadyChange:cr,onKeyboardVisibilityChange:Kn,showDebug:n,onStatusChange:$?S:void 0})})]},z.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[vt&&U.some(z=>z.id===vt.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:U.find(z=>z.id===vt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{ot(vt)},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(Rn,{size:16})})]}),mr&&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(Q1,{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:mr.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:mr.sessions.map(z=>z.name).join(" · ")}),Lt&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:Lt}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Xt!==null,onClick:()=>{Hr()},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(Qy,{size:13,className:Xt==="restore"?"animate-spin":""}),B(Xt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:Xt!==null,onClick:()=>{_n()},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(lA,{onSwiper:z=>{Ye.current=z,z.allowTouchMove=Br.length>1&&!hn&&!oe,_r("[swiper:on-swiper]",{allowTouchMove:z.allowTouchMove}),requestAnimationFrame(()=>Er("on-swiper"))},onSlideChange:kr,onTouchStart:(z,N)=>{const $=qx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-start]",{pointerType:$,allowed:ee}),_r("[swiper:touch-start]",{pointerType:$,allowed:ee}),ee&&(Wn(),bt.current=!0,gt.current=!0)},onTouchEnd:(z,N)=>{const $=qx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-end]",{pointerType:$,allowed:ee}),_r("[swiper:touch-end]",{pointerType:$,allowed:ee}),ee&&(bt.current=!1,Gn("touch-end"))},onTransitionEnd:()=>{const z=Ye.current;if(bt.current){_r("[swiper:transition-end-during-touch]");return}if(gt.current&&z&&!vN(z,ge.current)){_r("[swiper:transition-end-deferred]");return}Wn(),gt.current=!1,_r("[swiper:transition-end]")},initialSlide:Math.max(0,$r),speed:u1,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:Br.map(z=>{const N=z.workspace,$=!!N&&z.sessions.length>=2,ee=q?qt?"horizontal":"vertical":N?.layout??"horizontal",ie=q&&et?z.sessions.some(ze=>ze.id===et):!1,Qe=z.sessions.some(ze=>ze.id===Z)?Z:z.sessions[0]?.id;return s.jsx(cA,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":nn.get(z.key)??0,style:{paddingRight:nn.get(z.key)??0,paddingTop:y&&!$?"2.5rem":void 0},children:$?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(b2,{layoutId:z.key,preset:N?.layout??"horizontal",initialTree:aC(z.sessions.map(ze=>ze.id),ee,N?.ratios,N?.gridColumnRatios,N?.gridRowRatios),mobile:q,focusId:ie?et:null,panes:z.sessions.map(ze=>({id:ze.id,content:Kt(ze,{showPaneTitle:!q,suppressKeyboard:q&&ze.id!==Qe,keyboardPortalTarget:q?De:null,sharedMobileKeyboardLayout:q,suppressPageFlipRefresh:!0})}))}),q&&s.jsx("div",{ref:er,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(b2,{layoutId:z.key,preset:N?.layout??"horizontal",mobile:q,panes:[{id:z.sessions[0].id,content:Kt(z.sessions[0])}]})})},z.key)})})}),oe&&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:()=>Ze(!1),"aria-label":B("common.close")}),s.jsxs("section",{ref:Je,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:()=>Ze(!1),"aria-label":B("common.close"),children:s.jsx(Rn,{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:Ge,onClick:()=>{Le()},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(Us,{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")})]})]}),Te.filter(z=>z.id!==Sr?.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")}),Te.filter(z=>z.id!==Sr?.id).map((z,N)=>{const $=z.sessionIds.flatMap(Qe=>{const ze=U.find(xt=>xt.id===Qe);return ze?[ze]:[]});if($.length<2)return null;const ee=z.name||`${B("tab.splitWorkspace")} ${N+1}`,ie=$.map(Qe=>hr(Qe).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>G($[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:ee}),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:$.length})," · ",ie]})]}),s.jsx(hi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.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")}),U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).length===0&&Te.filter(z=>z.id!==Sr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:B("tab.splitNoOtherSessions")}):U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).map(z=>{const N=Pr.get(z.id)??null,$=hr(z);return s.jsxs("button",{type:"button",onClick:()=>G(z.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(Gc,{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:$.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:N?Yu(N)??N:z.name})]}),s.jsx(hi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.id)})]})]})]}),Vt&&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:Vt})]})},_N={sm:"h-4 w-7",md:"h-6 w-10"},kN={sm:"h-3 w-3",md:"h-5 w-5"},LN={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 ${_N[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 ${kN[r]} ${e?LN[r]:""}`})})}function aa(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var IN=typeof Symbol=="function"&&Symbol.observable||"@@observable",Zx=IN,Kx=()=>Math.random().toString(36).substring(7).split("").join("."),EN={INIT:`@@redux/INIT${Kx()}`,REPLACE:`@@redux/REPLACE${Kx()}`},Xx=EN;function NN(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 av(e,t,r){if(typeof e!="function")throw new Error(aa(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(aa(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(aa(1));return r(av)(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(aa(3));return a}function y(E){if(typeof E!="function")throw new Error(aa(4));if(p)throw new Error(aa(5));let R=!0;m();const B=d++;return l.set(B,E),function(){if(R){if(p)throw new Error(aa(6));R=!1,m(),l.delete(B),c=null}}}function w(E){if(!NN(E))throw new Error(aa(7));if(typeof E.type>"u")throw new Error(aa(8));if(typeof E.type!="string")throw new Error(aa(17));if(p)throw new Error(aa(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(aa(10));n=E,w({type:Xx.REPLACE})}function S(){const E=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(aa(11));function B(){const F=R;F.next&&F.next(x())}return B(),{unsubscribe:E(B)}},[Zx](){return this}}}return w({type:Xx.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[Zx]:S}}function Jx(e,t){return function(...r){return t(e.apply(this,r))}}function e5(e,t){if(typeof e=="function")return Jx(e,t);if(typeof e!="object"||e===null)throw new Error(aa(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=Jx(a,t))}return r}function ov(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function RN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(aa(15))};const l={getState:a.getState,dispatch:(p,...m)=>c(p,...m)},d=e.map(p=>p(l));return c=ov(...d)(a.dispatch),{...a,dispatch:c}}}var nm={exports:{}},sm={};var t5;function MN(){if(t5)return sm;t5=1;var e=wA();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 sm.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(U){if(!R){if(R=!0,B=U,U=y(U),w!==void 0&&S.hasValue){var V=S.value;if(w(V,U))return W=V}return W=U}if(V=W,r(B,U))return V;var Z=y(U);return w!==void 0&&w(V,Z)?(B=U,V):(B=U,W=Z)}var R=!1,B,W,F=x===void 0?null:x;return[function(){return E(m())},F===null?void 0:function(){return E(F())}]},[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},sm}var r5;function jN(){return r5||(r5=1,nm.exports=MN()),nm.exports}jN();var DN=b.version.startsWith("19"),BN=Symbol.for(DN?"react.transitional.element":"react.element"),QN=Symbol.for("react.portal"),PN=Symbol.for("react.fragment"),ON=Symbol.for("react.strict_mode"),FN=Symbol.for("react.profiler"),$N=Symbol.for("react.consumer"),UN=Symbol.for("react.context"),lv=Symbol.for("react.forward_ref"),zN=Symbol.for("react.suspense"),HN=Symbol.for("react.suspense_list"),rg=Symbol.for("react.memo"),WN=Symbol.for("react.lazy"),GN=lv,VN=rg;function qN(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case BN:switch(e=e.type,e){case PN:case FN:case ON:case zN:case HN:return e;default:switch(e=e&&e.$$typeof,e){case UN:case lv:case WN:case rg:return e;case $N:return e;default:return t}}case QN:return t}}}function YN(e){return qN(e)===rg}function ZN(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let d=!1,p,m,x,y,w;function v(B,W){return p=B,m=W,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),W=!l(B,x);return x=B,W&&(w=r(x,y,m)),w}function R(B,W){const F=!c(W,m),U=!a(B,p,W,m);return p=B,m=W,F&&U?S():F?L():U?E():w}return function(W,F){return d?R(W,F):v(W,F)}}function KN(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),d=n(e,a);return ZN(c,l,d,e,a)}function XN(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 f1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function n5(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function cv(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=n5(e);let m=c(d,p);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=n5(m),m=c(d,p)),m},c}}function ng(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function JN(e){return e&&typeof e=="object"?f1(t=>XN(e,t)):e?typeof e=="function"?cv(e):ng(e,"mapDispatchToProps"):f1(t=>({dispatch:t}))}function eR(e){return e?typeof e=="function"?cv(e):ng(e,"mapStateToProps"):f1(()=>({}))}function tR(e,t,r){return{...r,...e,...t}}function rR(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 nR(e){return e?typeof e=="function"?rR(e):ng(e,"mergeProps"):()=>tR}function sR(e){e()}function iR(){let e=null,t=null;return{clear(){e=null,t=null},notify(){sR(()=>{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 s5={notify(){},get:()=>[]};function uv(e,t){let r,n=s5,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=iR())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=s5)}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 aR=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",oR=aR(),lR=()=>typeof navigator<"u"&&navigator.product==="ReactNative",cR=lR(),uR=()=>oR||cR?b.useLayoutEffect:b.useEffect,wf=uR();function i5(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function im(e,t){if(i5(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(t,r[a])||!i5(e[r[a]],t[r[a]]))return!1;return!0}var dR={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},hR={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},fR={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},dv={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},pR={[GN]:fR,[VN]:dv};function a5(e){return YN(e)?dv:pR[e.$$typeof]||dR}var mR=Object.defineProperty,gR=Object.getOwnPropertyNames,o5=Object.getOwnPropertySymbols,xR=Object.getOwnPropertyDescriptor,bR=Object.getPrototypeOf,l5=Object.prototype;function p1(e,t){if(typeof t!="string"){if(l5){const c=bR(t);c&&c!==l5&&p1(e,c)}let r=gR(t);o5&&(r=r.concat(o5(t)));const n=a5(e),a=a5(t);for(let c=0;c<r.length;++c){const l=r[c];if(!hR[l]&&!(a&&a[l])&&!(n&&n[l])){const d=xR(t,l);try{mR(e,l,d)}catch{}}}}return e}var yR=Symbol.for("react-redux-context"),vR=typeof globalThis<"u"?globalThis:{};function wR(){if(!b.createContext)return{};const e=vR[yR]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var hv=wR(),AR=[null,null];function TR(e,t,r){wf(()=>e(...t),r)}function SR(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function CR(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 _R(e,t){return e===t}function kR(e,t,r,{pure:n,areStatesEqual:a=_R,areOwnPropsEqual:c=im,areStatePropsEqual:l=im,areMergedPropsEqual:d=im,forwardRef:p=!1,context:m=hv}={}){const x=m,y=eR(e),w=JN(t),v=nR(r),S=!!e;return E=>{const R=E.displayName||E.name||"Component",B=`Connect(${R})`,W={shouldHandleStateChanges:S,displayName:B,wrappedComponentName:R,WrappedComponent:E,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:d};function F(Z){const[ce,xe,pe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ye,...st}=Z;return[Z.context,Ye,st]},[Z]),te=b.useMemo(()=>{let Ye=x;return ce?.Consumer,Ye},[ce,x]),ke=b.useContext(te),$e=!!Z.store&&!!Z.store.getState&&!!Z.store.dispatch,Y=!!ke&&!!ke.store,Ae=$e?Z.store:ke.store,lt=Y?ke.getServerState:Ae.getState,Se=b.useMemo(()=>KN(Ae.dispatch,W),[Ae]),[ye,_e]=b.useMemo(()=>{if(!S)return AR;const Ye=uv(Ae,$e?void 0:ke.subscription),st=Ye.notifyNestedSubs.bind(Ye);return[Ye,st]},[Ae,$e,ke]),je=b.useMemo(()=>$e?ke:{...ke,subscription:ye},[$e,ke,ye]),re=b.useRef(void 0),Oe=b.useRef(pe),Ce=b.useRef(void 0),Ee=b.useRef(!1),Be=b.useRef(!1),Ne=b.useRef(void 0);wf(()=>(Be.current=!0,()=>{Be.current=!1}),[]);const le=b.useMemo(()=>()=>Ce.current&&pe===Oe.current?Ce.current:Se(Ae.getState(),pe),[Ae,pe]),He=b.useMemo(()=>st=>ye?CR(S,Ae,ye,Se,Oe,re,Ee,Be,Ce,_e,st):()=>{},[ye]);TR(SR,[Oe,re,Ee,pe,Ce,_e]);let rt;try{rt=b.useSyncExternalStore(He,le,lt?()=>Se(lt(),pe):le)}catch(Ye){throw Ne.current&&(Ye.message+=`
|
|
78
|
-
The error may be correlated with this previous error:
|
|
79
|
-
${Ne.current.stack}
|
|
80
|
-
|
|
81
|
-
`),Ye}wf(()=>{Ne.current=void 0,Ce.current=void 0,re.current=rt});const mt=b.useMemo(()=>b.createElement(E,{...rt,ref:xe}),[xe,E,rt]);return b.useMemo(()=>S?b.createElement(te.Provider,{value:je},mt):mt,[te,mt,je])}const V=b.memo(F);if(V.WrappedComponent=E,V.displayName=F.displayName=B,p){const ce=b.forwardRef(function(pe,te){return b.createElement(V,{...pe,reactReduxForwardedRef:te})});return ce.displayName=B,ce.WrappedComponent=E,p1(ce,E)}return p1(V,E)}}var fv=kR;function LR(e){const{children:t,context:r,serverState:n,store:a}=e,c=b.useMemo(()=>{const p=uv(a);return{store:a,subscription:p,getServerState:n?()=>n:void 0}},[a,n]),l=b.useMemo(()=>a.getState(),[a]);wf(()=>{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||hv;return b.createElement(d.Provider,{value:c},t)}var IR=LR,ER="Invariant failed";function NR(e,t){throw new Error(ER)}var Oo=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},sg=function(t,r){return{top:t.top-r.top,left:t.left-r.left,bottom:t.bottom+r.bottom,right:t.right+r.right}},c5=function(t,r){return{top:t.top+r.top,left:t.left+r.left,bottom:t.bottom-r.bottom,right:t.right-r.right}},RR=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},am={top:0,right:0,bottom:0,left:0},ig=function(t){var r=t.borderBox,n=t.margin,a=n===void 0?am:n,c=t.border,l=c===void 0?am:c,d=t.padding,p=d===void 0?am:d,m=Oo(sg(r,a)),x=Oo(c5(r,l)),y=Oo(c5(x,p));return{marginBox:m,borderBox:Oo(r),paddingBox:x,contentBox:y,margin:a,border:l,padding:p}},ho=function(t){var r=t.slice(0,-2),n=t.slice(-2);if(n!=="px")return 0;var a=Number(r);return isNaN(a)&&NR(),a},MR=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Af=function(t,r){var n=t.borderBox,a=t.border,c=t.margin,l=t.padding,d=RR(n,r);return ig({borderBox:d,border:a,margin:c,padding:l})},Tf=function(t,r){return r===void 0&&(r=MR()),Af(t,r)},pv=function(t,r){var n={top:ho(r.marginTop),right:ho(r.marginRight),bottom:ho(r.marginBottom),left:ho(r.marginLeft)},a={top:ho(r.paddingTop),right:ho(r.paddingRight),bottom:ho(r.paddingBottom),left:ho(r.paddingLeft)},c={top:ho(r.borderTopWidth),right:ho(r.borderRightWidth),bottom:ho(r.borderBottomWidth),left:ho(r.borderLeftWidth)};return ig({borderBox:t,margin:n,padding:a,border:c})},mv=function(t){var r=t.getBoundingClientRect(),n=window.getComputedStyle(t);return pv(r,n)},v0=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 Sf(){return Sf=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},Sf.apply(null,arguments)}function gv(e,t){}gv.bind(null,"warn");gv.bind(null,"error");function oc(){}function jR(e,t){return{...e,...t}}function yo(e,t,r){const n=t.map(a=>{const c=jR(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 DR="Invariant failed";class Cf extends Error{}Cf.prototype.toString=function(){return this.message};function Qt(e,t){throw new Cf(DR)}class BR 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 Cf&&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=yo(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Cf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const QR=`
|
|
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
|
-
`,_f=e=>e+1,PR=e=>`
|
|
86
|
-
You have lifted an item in position ${_f(e.source.index)}
|
|
87
|
-
`,xv=(e,t)=>{const r=e.droppableId===t.droppableId,n=_f(e.index),a=_f(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
|
-
`},bv=(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
|
-
`,OR=e=>{const t=e.destination;if(t)return xv(e.source,t);const r=e.combine;return r?bv(e.draggableId,e.source,r):"You are over an area that cannot be dropped on"},u5=e=>`
|
|
103
|
-
The item has returned to its starting position
|
|
104
|
-
of ${_f(e.index)}
|
|
105
|
-
`,FR=e=>{if(e.reason==="CANCEL")return`
|
|
106
|
-
Movement cancelled.
|
|
107
|
-
${u5(e.source)}
|
|
108
|
-
`;const t=e.destination,r=e.combine;return t?`
|
|
109
|
-
You have dropped the item.
|
|
110
|
-
${xv(e.source,t)}
|
|
111
|
-
`:r?`
|
|
112
|
-
You have dropped the item.
|
|
113
|
-
${bv(e.draggableId,e.source,r)}
|
|
114
|
-
`:`
|
|
115
|
-
The item has been dropped while not over a drop area.
|
|
116
|
-
${u5(e.source)}
|
|
117
|
-
`},Zh={dragHandleUsageInstructions:QR,onDragStart:PR,onDragUpdate:OR,onDragEnd:FR};function $R(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function yv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!$R(e[r],t[r]))return!1;return!0}function An(e,t){const r=b.useState(()=>({inputs:t,result:e()}))[0],n=b.useRef(!0),a=b.useRef(r),l=n.current||!!(t&&a.current.inputs&&yv(t,a.current.inputs))?a.current:{inputs:t,result:e()};return b.useEffect(()=>{n.current=!1,a.current=l},[l]),l.result}function Ar(e,t){return An(()=>e,t)}const mi={x:0,y:0},Ei=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Fa=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lc=(e,t)=>e.x===t.x&&e.y===t.y,Xu=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),qc=(e,t,r=0)=>e==="x"?{x:t,y:r}:{x:r,y:t},w0=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),d5=(e,t)=>Math.min(...t.map(r=>w0(e,r))),vv=e=>t=>({x:e(t.x),y:e(t.y)});var UR=(e,t)=>{const r=Oo({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 D0=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),h5=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}],zR={top:0,right:0,bottom:0,left:0},HR=(e,t)=>t?D0(e,t.scroll.diff.displacement):e,WR=(e,t,r)=>r&&r.increasedBy?{...e,[t.end]:e[t.end]+r.increasedBy[t.line]}:e,GR=(e,t)=>t&&t.shouldClipSubject?UR(t.pageMarginBox,e):Oo(e);var Hu=({page:e,withPlaceholder:t,axis:r,frame:n})=>{const a=HR(e.marginBox,n),c=WR(a,r,t),l=GR(c,n);return{page:e,withPlaceholder:t,active:l}},ag=(e,t)=>{e.frame||Qt();const r=e.frame,n=Fa(t,r.scroll.initial),a=Xu(n),c={...r,scroll:{initial:r.scroll.initial,current:t,diff:{value:n,displacement:a},max:r.scroll.max}},l=Hu({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:c});return{...e,frame:c,subject:l}};function pi(e,t=yv){let r=null;function n(...a){if(r&&r.lastThis===this&&t(a,r.lastArgs))return r.lastResult;const c=e.apply(this,a);return r={lastResult:c,lastArgs:a,lastThis:this},c}return n.clear=function(){r=null},n}const wv=pi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),Av=pi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),Wf=pi(e=>Object.values(e)),VR=pi(e=>Object.values(e));var Ju=pi((e,t)=>VR(t).filter(n=>e===n.descriptor.droppableId).sort((n,a)=>n.descriptor.index-a.descriptor.index));function og(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Gf(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var Vf=pi((e,t)=>t.filter(r=>r.descriptor.id!==e.descriptor.id)),qR=({isMovingForward:e,draggable:t,destination:r,insideDestination:n,previousImpact:a})=>{if(!r.isCombineEnabled||!og(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=Vf(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&&Qt();const y=x-1;if(y<0)return null;const w=m[y];return l(w.descriptor.id)},ed=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Tv={point:mi,value:0},A0={invisible:{},visible:{},all:[]},YR={displaced:A0,displacedBy:Tv,at:null};var vo=(e,t)=>r=>e<=r&&r<=t,Sv=e=>{const t=vo(e.top,e.bottom),r=vo(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}},ZR=e=>{const t=vo(e.top,e.bottom),r=vo(e.left,e.right);return n=>t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right)};const lg={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},Cv={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var KR=e=>t=>{const r=vo(t.top,t.bottom),n=vo(t.left,t.right);return a=>e===lg?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)};const XR=(e,t)=>{const r=t.frame?t.frame.scroll.diff.displacement:mi;return D0(e,r)},JR=(e,t,r)=>t.subject.active?r(t.subject.active)(e):!1,eM=(e,t,r)=>r(t)(e),cg=({target:e,destination:t,viewport:r,withDroppableDisplacement:n,isVisibleThroughFrameFn:a})=>{const c=n?XR(e,t):e;return JR(c,t,a)&&eM(c,r,a)},tM=e=>cg({...e,isVisibleThroughFrameFn:Sv}),_v=e=>cg({...e,isVisibleThroughFrameFn:ZR}),rM=e=>cg({...e,isVisibleThroughFrameFn:KR(e.destination.axis)}),nM=(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 sM(e,t){const r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return Oo(sg(r,n))}function T0({afterDragging:e,destination:t,displacedBy:r,viewport:n,forceShouldAnimate:a,last:c}){return e.reduce(function(d,p){const m=sM(p,r),x=p.descriptor.id;if(d.all.push(x),!tM({target:m,destination:t,viewport:n,withDroppableDisplacement:!0}))return d.invisible[p.descriptor.id]=!0,d;const w=nM(x,c,a),v={draggableId:x,shouldAnimate:w};return d.visible[x]=v,d},{all:[],visible:{},invisible:{}})}function iM(e,t){if(!e.length)return 0;const r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function f5({insideDestination:e,inHomeList:t,displacedBy:r,destination:n}){const a=iM(e,{inHomeList:t});return{displaced:A0,displacedBy:r,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function kf({draggable:e,insideDestination:t,destination:r,viewport:n,displacedBy:a,last:c,index:l,forceShouldAnimate:d}){const p=ed(e,r);if(l==null)return f5({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const m=t.find(S=>S.descriptor.index===l);if(!m)return f5({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const x=Vf(e,t),y=t.indexOf(m),w=x.slice(y);return{displaced:T0({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 aM=({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},oM=({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},lM=({isMovingForward:e,isInHomeList:t,draggable:r,draggables:n,destination:a,insideDestination:c,previousImpact:l,viewport:d,afterCritical:p})=>{const m=l.at;if(m||Qt(),m.type==="REORDER"){const y=oM({isMovingForward:e,isInHomeList:t,location:m.destination,insideDestination:c});return y==null?null:kf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:y})}const x=aM({isMovingForward:e,destination:a,displaced:l.displaced,draggables:n,combine:m.combine,afterCritical:p});return x==null?null:kf({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:x})},cM=({displaced:e,afterCritical:t,combineWith:r,displacedBy:n})=>{const a=!!(e.visible[r]||e.invisible[r]);return dc(r,t)?a?mi:Xu(n.point):a?n.point:mi},uM=({afterCritical:e,impact:t,draggables:r})=>{const n=Gf(t);n||Qt();const a=n.draggableId,c=r[a].page.borderBox.center,l=cM({displaced:t.displaced,afterCritical:e,combineWith:a,displacedBy:t.displacedBy});return Ei(c,l)};const kv=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,dM=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,ug=(e,t,r)=>t[e.crossAxisStart]+r.margin[e.crossAxisStart]+r.borderBox[e.crossAxisSize]/2,p5=({axis:e,moveRelativeTo:t,isMoving:r})=>qc(e.line,t.marginBox[e.end]+kv(e,r),ug(e,t.marginBox,r)),m5=({axis:e,moveRelativeTo:t,isMoving:r})=>qc(e.line,t.marginBox[e.start]-dM(e,r),ug(e,t.marginBox,r)),hM=({axis:e,moveInto:t,isMoving:r})=>qc(e.line,t.contentBox[e.start]+kv(e,r),ug(e,t.contentBox,r));var fM=({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:a})=>{const c=Ju(n.descriptor.id,r),l=t.page,d=n.axis;if(!c.length)return hM({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 m5({axis:d,moveRelativeTo:w.page,isMoving:l});const v=Af(w.page,m.point);return m5({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=Af(y.page,Xu(a.displacedBy.point));return p5({axis:d,moveRelativeTo:w,isMoving:l})}return p5({axis:d,moveRelativeTo:y.page,isMoving:l})},m1=(e,t)=>{const r=e.frame;return r?Ei(t,r.scroll.diff.displacement):t};const pM=({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"?fM({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:a}):uM({impact:e,draggables:n,afterCritical:a})};var qf=e=>{const t=pM(e),r=e.droppable;return r?m1(r,t):t},Lv=(e,t)=>{const r=Fa(t,e.scroll.initial),n=Xu(r);return{frame:Oo({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 g5(e,t){return e.map(r=>t[r])}function mM(e,t){for(let r=0;r<t.length;r++){const n=t[r].visible[e];if(n)return n}return null}var gM=({impact:e,viewport:t,destination:r,draggables:n,maxScrollChange:a})=>{const c=Lv(t,Ei(t.scroll.current,a)),l=r.frame?ag(r,Ei(r.frame.scroll.current,a)):r,d=e.displaced,p=T0({afterDragging:g5(d.all,n),destination:r,displacedBy:e.displacedBy,viewport:c.frame,last:d,forceShouldAnimate:!1}),m=T0({afterDragging:g5(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=mM(S,w);if(L){y[S]=L;return}x[S]=!0}),{...e,displaced:{all:d.all,invisible:x,visible:y}}},xM=(e,t)=>Ei(e.scroll.diff.displacement,t),dg=({pageBorderBoxCenter:e,draggable:t,viewport:r})=>{const n=xM(r,e),a=Fa(n,t.page.borderBox.center);return Ei(t.client.borderBox.center,a)},Iv=({draggable:e,destination:t,newPageBorderBoxCenter:r,viewport:n,withDroppableDisplacement:a,onlyOnMainAxis:c=!1})=>{const l=Fa(r,e.page.borderBox.center),p={target:D0(e.page.borderBox,l),destination:t,withDroppableDisplacement:a,viewport:n};return c?rM(p):_v(p)},bM=({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=Ju(r.descriptor.id,n),x=ed(t,r),y=qR({isMovingForward:e,draggable:t,destination:r,insideDestination:m,previousImpact:a})||lM({isMovingForward:e,isInHomeList:x,draggable:t,draggables:n,destination:r,insideDestination:m,previousImpact:a,viewport:c,afterCritical:p});if(!y)return null;const w=qf({impact:y,draggable:t,droppable:r,draggables:n,afterCritical:p});if(Iv({draggable:t,destination:r,newPageBorderBoxCenter:w,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:dg({pageBorderBoxCenter:w,draggable:t,viewport:c}),impact:y,scrollJumpRequest:null};const S=Fa(w,l),L=gM({impact:y,viewport:c,destination:r,draggables:n,maxScrollChange:S});return{clientSelection:d,impact:L,scrollJumpRequest:S}};const na=e=>{const t=e.subject.active;return t||Qt(),t};var yM=({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:n,viewport:a})=>{const c=r.subject.active;if(!c)return null;const l=r.axis,d=vo(c[l.start],c[l.end]),p=Wf(n).filter(x=>x!==r).filter(x=>x.isEnabled).filter(x=>!!x.subject.active).filter(x=>Sv(a.frame)(na(x))).filter(x=>{const y=na(x);return e?c[l.crossAxisEnd]<y[l.crossAxisEnd]:y[l.crossAxisStart]<c[l.crossAxisStart]}).filter(x=>{const y=na(x),w=vo(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=na(x)[l.crossAxisStart],v=na(y)[l.crossAxisStart];return e?w-v:v-w}).filter((x,y,w)=>na(x)[l.crossAxisStart]===na(w[0])[l.crossAxisStart]);if(!p.length)return null;if(p.length===1)return p[0];const m=p.filter(x=>vo(na(x)[l.start],na(x)[l.end])(t[l.line]));return m.length===1?m[0]:m.length>1?m.sort((x,y)=>na(x)[l.start]-na(y)[l.start])[0]:p.sort((x,y)=>{const w=d5(t,h5(na(x))),v=d5(t,h5(na(y)));return w!==v?w-v:na(x)[l.start]-na(y)[l.start]})[0]};const x5=(e,t)=>{const r=e.page.borderBox.center;return dc(e.descriptor.id,t)?Fa(r,t.displacedBy.point):r},vM=(e,t)=>{const r=e.page.borderBox;return dc(e.descriptor.id,t)?D0(r,Xu(t.displacedBy.point)):r};var wM=({pageBorderBoxCenter:e,viewport:t,destination:r,insideDestination:n,afterCritical:a})=>n.filter(l=>_v({target:vM(l,a),destination:r,viewport:t.frame,withDroppableDisplacement:!0})).sort((l,d)=>{const p=w0(e,m1(r,x5(l,a))),m=w0(e,m1(r,x5(d,a)));return p<m?-1:m<p?1:l.descriptor.index-d.descriptor.index})[0]||null,B0=pi(function(t,r){const n=r[t.line];return{value:n,point:qc(t.line,n)}});const AM=(e,t,r)=>{const n=e.axis;if(e.descriptor.mode==="virtual")return qc(n.line,t[n.line]);const a=e.subject.page.contentBox[n.size],p=Ju(e.descriptor.id,r).reduce((m,x)=>m+x.client.marginBox[n.size],0)+t[n.line]-a;return p<=0?null:qc(n.line,p)},Ev=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),Nv=(e,t,r)=>{const n=e.frame;ed(t,e)&&Qt(),e.subject.withPlaceholder&&Qt();const a=B0(e.axis,t.displaceBy).point,c=AM(e,a,r),l={placeholderSize:a,increasedBy:c,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!n){const x=Hu({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:e.frame});return{...e,subject:x}}const d=c?Ei(n.scroll.max,c):n.scroll.max,p=Ev(n,d),m=Hu({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:p});return{...e,subject:m,frame:p}},TM=e=>{const t=e.subject.withPlaceholder;t||Qt();const r=e.frame;if(!r){const l=Hu({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:l}}const n=t.oldFrameMaxScroll;n||Qt();const a=Ev(r,n),c=Hu({page:e.subject.page,axis:e.axis,frame:a,withPlaceholder:null});return{...e,subject:c,frame:a}};var SM=({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:A0,displacedBy:Tv,at:{type:"REORDER",destination:{droppableId:c.descriptor.id,index:0}}},w=qf({impact:y,draggable:n,droppable:c,draggables:a,afterCritical:d}),v=ed(n,c)?c:Nv(c,n,a);return Iv({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=B0(c.axis,n.displaceBy);return kf({draggable:n,insideDestination:r,destination:c,viewport:l,displacedBy:x,last:A0,index:m})},CM=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:r,isOver:n,draggables:a,droppables:c,viewport:l,afterCritical:d})=>{const p=yM({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:c,viewport:l});if(!p)return null;const m=Ju(p.descriptor.id,a),x=wM({pageBorderBoxCenter:t,viewport:l,destination:p,insideDestination:m,afterCritical:d}),y=SM({previousPageBorderBoxCenter:t,destination:p,draggable:r,draggables:a,moveRelativeTo:x,insideDestination:m,viewport:l,afterCritical:d});if(!y)return null;const w=qf({impact:y,draggable:r,droppable:p,draggables:a,afterCritical:d});return{clientSelection:dg({pageBorderBoxCenter:w,draggable:r,viewport:l}),impact:y,scrollJumpRequest:null}},Ua=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const _M=(e,t)=>{const r=Ua(e);return r?t[r]:null};var kM=({state:e,type:t})=>{const r=_M(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?bM({isMovingForward:p,previousPageBorderBoxCenter:x,draggable:m,destination:c,draggables:y,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):CM({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 Rv(e){const t=vo(e.top,e.bottom),r=vo(e.left,e.right);return function(a){return t(a.y)&&r(a.x)}}function LM(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function IM({pageBorderBox:e,draggable:t,candidates:r}){const n=t.page.borderBox.center,a=r.map(c=>{const l=c.axis,d=qc(c.axis.line,e.center[l.line],c.page.borderBox.center[l.crossAxisLine]);return{id:c.descriptor.id,distance:w0(n,d)}}).sort((c,l)=>l.distance-c.distance);return a[0]?a[0].id:null}function EM({pageBorderBox:e,draggable:t,droppables:r}){const n=Wf(r).filter(a=>{if(!a.isEnabled)return!1;const c=a.subject.active;if(!c||!LM(e,c))return!1;if(Rv(c)(e.center))return!0;const l=a.axis,d=c.center[l.crossAxisLine],p=e[l.crossAxisStart],m=e[l.crossAxisEnd],x=vo(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:IM({pageBorderBox:e,draggable:t,candidates:n}):null}const Mv=(e,t)=>Oo(D0(e,t));var NM=(e,t)=>{const r=e.frame;return r?Mv(t,r.scroll.diff.value):t};function jv({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function RM({draggable:e,closest:t,inHomeList:r}){return t?r&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var MM=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:r,insideDestination:n,last:a,viewport:c,afterCritical:l})=>{const d=r.axis,p=B0(r.axis,t.displaceBy),m=p.value,x=e[d.start],y=e[d.end],v=Vf(t,n).find(L=>{const E=L.descriptor.id,R=L.page.borderBox.center[d.line],B=dc(E,l),W=jv({displaced:a,id:E});return B?W?y<=R:x<R-m:W?y<=R+m:x<R})||null,S=RM({draggable:t,closest:v,inHomeList:ed(t,r)});return kf({draggable:t,insideDestination:n,destination:r,viewport:c,last:a,displacedBy:p,index:S})};const jM=4;var DM=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:r,destination:n,insideDestination:a,afterCritical:c})=>{if(!n.isCombineEnabled)return null;const l=n.axis,d=B0(n.axis,e.displaceBy),p=d.value,m=t[l.start],x=t[l.end],w=Vf(e,a).find(S=>{const L=S.descriptor.id,E=S.page.borderBox,B=E[l.size]/jM,W=dc(L,c),F=jv({displaced:r.displaced,id:L});return W?F?x>E[l.start]+B&&x<E[l.end]-B:m>E[l.start]-p+B&&m<E[l.end]-p-B:F?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},Dv=({pageOffset:e,draggable:t,draggables:r,droppables:n,previousImpact:a,viewport:c,afterCritical:l})=>{const d=Mv(t.page.borderBox,e),p=EM({pageBorderBox:d,draggable:t,droppables:n});if(!p)return YR;const m=n[p],x=Ju(m.descriptor.id,r),y=NM(m,d);return DM({pageBorderBoxWithDroppableScroll:y,draggable:t,previousImpact:a,destination:m,insideDestination:x,afterCritical:l})||MM({pageBorderBoxWithDroppableScroll:y,draggable:t,destination:m,insideDestination:x,last:a.displaced,viewport:c,afterCritical:l})},hg=(e,t)=>({...e,[t.descriptor.id]:t});const BM=({previousImpact:e,impact:t,droppables:r})=>{const n=Ua(e),a=Ua(t);if(!n||n===a)return r;const c=r[n];if(!c.subject.withPlaceholder)return r;const l=TM(c);return hg(r,l)};var QM=({draggable:e,draggables:t,droppables:r,previousImpact:n,impact:a})=>{const c=BM({previousImpact:n,impact:a,droppables:r}),l=Ua(a);if(!l)return c;const d=r[l];if(ed(e,d)||d.subject.withPlaceholder)return c;const p=Nv(d,e,t);return hg(c,p)},o0=({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=Fa(p,e.initial.client.selection),x={offset:m,selection:p,borderBoxCenter:Ei(e.initial.client.borderBoxCenter,m)},y={selection:Ei(x.selection,l.scroll.current),borderBoxCenter:Ei(x.borderBoxCenter,l.scroll.current),offset:Ei(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||Dv({pageOffset:y.offset,draggable:v,draggables:d.draggables,droppables:d.droppables,previousImpact:e.impact,viewport:l,afterCritical:e.afterCritical}),L=QM({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 PM(e,t){return e.map(r=>t[r])}var Bv=({impact:e,viewport:t,draggables:r,destination:n,forceShouldAnimate:a})=>{const c=e.displaced,l=PM(c.all,r),d=T0({afterDragging:l,destination:n,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:a,last:c});return{...e,displaced:d}},Qv=({impact:e,draggable:t,droppable:r,draggables:n,viewport:a,afterCritical:c})=>{const l=qf({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:c});return dg({pageBorderBoxCenter:l,draggable:t,viewport:a})},Pv=({state:e,dimensions:t,viewport:r})=>{e.movementMode!=="SNAP"&&Qt();const n=e.impact,a=r||e.viewport,c=t||e.dimensions,{draggables:l,droppables:d}=c,p=l[e.critical.draggable.id],m=Ua(n);m||Qt();const x=d[m],y=Bv({impact:n,viewport:a,destination:x,draggables:l}),w=Qv({impact:y,draggable:p,droppable:x,draggables:l,viewport:a,afterCritical:e.afterCritical});return o0({impact:y,clientSelection:w,state:e,dimensions:c,viewport:a})},OM=e=>({index:e.index,droppableId:e.droppableId}),Ov=({draggable:e,home:t,draggables:r,viewport:n})=>{const a=B0(t.axis,e.displaceBy),c=Ju(t.descriptor.id,r),l=c.indexOf(e);l===-1&&Qt();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:T0({afterDragging:d,destination:t,displacedBy:a,last:null,viewport:n.frame,forceShouldAnimate:!1}),displacedBy:a,at:{type:"REORDER",destination:OM(e.descriptor)}},afterCritical:m}},FM=(e,t)=>({draggables:e.draggables,droppables:hg(e.droppables,t)}),$M=({draggable:e,offset:t,initialWindowScroll:r})=>{const n=Af(e.client,t),a=Tf(n,r);return{...e,placeholder:{...e.placeholder,client:n},client:n,page:a}},UM=e=>{const t=e.frame;return t||Qt(),t},zM=({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=UM(l).scroll.diff.value,m=Ei(n,p);return $M({draggable:a,offset:m,initialWindowScroll:r.scroll.initial})})},HM=({state:e,published:t})=>{const r=t.modified.map(R=>{const B=e.dimensions.droppables[R.droppableId];return ag(B,R.scroll)}),n={...e.dimensions.droppables,...wv(r)},a=Av(zM({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=Ua(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}=Ov({draggable:m,home:x,draggables:c,viewport:e.viewport}),v=p&&p.isCombineEnabled?e.impact:y,S=Dv({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 g1=e=>e.movementMode==="SNAP",om=(e,t,r)=>{const n=FM(e.dimensions,t);return!g1(e)||r?o0({state:e,dimensions:n}):Pv({state:e,dimensions:n})};function lm(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const b5={phase:"IDLE",completed:null,shouldFlush:!1};var WM=(e=b5,t)=>{if(t.type==="FLUSH")return{...b5,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&Qt();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:mi},x={client:m,page:{selection:Ei(m.selection,a.scroll.initial),borderBoxCenter:Ei(m.selection,a.scroll.initial),offset:Ei(m.selection,a.scroll.diff.value)}},y=Wf(c.droppables).every(L=>!L.isFixedOnPage),{impact:w,afterCritical:v}=Ov({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"&&Qt(),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||Qt(),HM({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Qt();const{client:r}=t.payload;return lc(r,e.current.client.selection)?e:o0({state:e,clientSelection:r,impact:g1(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return lm(e);Mc(e)||Qt();const{id:r,newScroll:n}=t.payload,a=e.dimensions.droppables[r];if(!a)return e;const c=ag(a,n);return om(e,c,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Qt();const{id:r,isEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Qt(),a.isEnabled===n&&Qt();const c={...a,isEnabled:n};return om(e,c,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Qt();const{id:r,isCombineEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Qt(),a.isCombineEnabled===n&&Qt();const c={...a,isCombineEnabled:n};return om(e,c,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;Mc(e)||Qt(),e.isWindowScrollAllowed||Qt();const r=t.payload.newScroll;if(lc(e.viewport.scroll.current,r))return lm(e);const n=Lv(e.viewport,r);return g1(e)?Pv({state:e,viewport:n}):o0({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"&&Qt();const r=kM({state:e,type:t.type});return r?o0({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"&&Qt(),{...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"||Qt(),{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 Fn(e,t){return e instanceof Object&&"type"in e&&e.type===t}const GM=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),VM=e=>({type:"LIFT",payload:e}),qM=e=>({type:"INITIAL_PUBLISH",payload:e}),YM=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),ZM=()=>({type:"COLLECTION_STARTING",payload:null}),KM=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),XM=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),JM=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Fv=e=>({type:"MOVE",payload:e}),ej=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),tj=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),rj=()=>({type:"MOVE_UP",payload:null}),nj=()=>({type:"MOVE_DOWN",payload:null}),sj=()=>({type:"MOVE_RIGHT",payload:null}),ij=()=>({type:"MOVE_LEFT",payload:null}),fg=()=>({type:"FLUSH",payload:null}),aj=e=>({type:"DROP_ANIMATE",payload:e}),pg=e=>({type:"DROP_COMPLETE",payload:e}),$v=e=>({type:"DROP",payload:e}),oj=e=>({type:"DROP_PENDING",payload:e}),Uv=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var lj=e=>({getState:t,dispatch:r})=>n=>a=>{if(!Fn(a,"LIFT")){n(a);return}const{id:c,clientSelection:l,movementMode:d}=a.payload,p=t();p.phase==="DROP_ANIMATING"&&r(pg({completed:p.completed})),t().phase!=="IDLE"&&Qt(),r(fg()),r(GM({draggableId:c,movementMode:d}));const x={draggableId:c,scrollOptions:{shouldPublishImmediately:d==="SNAP"}},{critical:y,dimensions:w,viewport:v}=e.startPublishing(x);r(qM({critical:y,dimensions:w,clientSelection:l,movementMode:d,viewport:v}))},cj=e=>()=>t=>r=>{Fn(r,"INITIAL_PUBLISH")&&e.dragging(),Fn(r,"DROP_ANIMATE")&&e.dropping(r.payload.completed.result.reason),(Fn(r,"FLUSH")||Fn(r,"DROP_COMPLETE"))&&e.resting(),t(r)};const mg={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},S0={opacity:{drop:0,combining:.7},scale:{drop:.75}},zv={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},Rc=`${zv.outOfTheWay}s ${mg.outOfTheWay}`,l0={fluid:`opacity ${Rc}`,snap:`transform ${Rc}, opacity ${Rc}`,drop:e=>{const t=`${e}s ${mg.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${Rc}`,placeholder:`height ${Rc}, width ${Rc}, margin ${Rc}`},y5=e=>lc(e,mi)?void 0:`translate(${e.x}px, ${e.y}px)`,x1={moveTo:y5,drop:(e,t)=>{const r=y5(e);if(r)return t?`${r} scale(${S0.scale.drop})`:r}},{minDropTime:b1,maxDropTime:Hv}=zv,uj=Hv-b1,v5=1500,dj=.6;var hj=({current:e,destination:t,reason:r})=>{const n=w0(e,t);if(n<=0)return b1;if(n>=v5)return Hv;const a=n/v5,c=b1+uj*a,l=r==="CANCEL"?c*dj:c;return Number(l.toFixed(2))},fj=({impact:e,draggable:t,dimensions:r,viewport:n,afterCritical:a})=>{const{draggables:c,droppables:l}=r,d=Ua(e),p=d?l[d]:null,m=l[t.descriptor.droppableId],x=Qv({impact:e,draggable:t,draggables:c,afterCritical:a,droppable:p||m,viewport:n});return Fa(x,t.client.borderBox.center)},pj=({draggables:e,reason:t,lastImpact:r,home:n,viewport:a,onLiftImpact:c})=>!r.at||t!=="DROP"?{impact:Bv({draggables:e,impact:c,destination:n,viewport:a,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:r.at.type==="REORDER"?{impact:r,didDropInsideDroppable:!0}:{impact:{...r,displaced:A0},didDropInsideDroppable:!0};const mj=({getState:e,dispatch:t})=>r=>n=>{if(!Fn(n,"DROP")){r(n);return}const a=e(),c=n.payload.reason;if(a.phase==="COLLECTING"){t(oj({reason:c}));return}if(a.phase==="IDLE")return;a.phase==="DROP_PENDING"&&a.isWaiting&&Qt(),a.phase==="DRAGGING"||a.phase==="DROP_PENDING"||Qt();const d=a.critical,p=a.dimensions,m=p.draggables[a.critical.draggable.id],{impact:x,didDropInsideDroppable:y}=pj({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?og(x):null,v=y?Gf(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=fj({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(pg({completed:R}));return}const W=hj({current:a.current.client.offset,destination:E,reason:c});t(aj({newHomeClientOffset:E,dropDuration:W,completed:R}))};var Wv=()=>({x:window.pageXOffset,y:window.pageYOffset});function gj(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function xj({onWindowScroll:e}){function t(){e(Wv())}const r=v0(t),n=gj(r);let a=oc;function c(){return a!==oc}function l(){c()&&Qt(),a=yo(window,[n])}function d(){c()||Qt(),r.cancel(),a(),a=oc}return{start:l,stop:d,isActive:c}}const bj=e=>Fn(e,"DROP_COMPLETE")||Fn(e,"DROP_ANIMATE")||Fn(e,"FLUSH"),yj=e=>{const t=xj({onWindowScroll:r=>{e.dispatch(ej({newScroll:r}))}});return r=>n=>{!t.isActive()&&Fn(n,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&bj(n)&&t.stop(),r(n)}};var vj=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},wj=()=>{const e=[],t=a=>{const c=e.findIndex(d=>d.timerId===a);c===-1&&Qt();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 Aj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,Tj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,Sj=(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},Ed=(e,t)=>{t()},wh=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function cm(e,t,r,n){if(!e){r(n(t));return}const a=vj(r);e(t,{announce:a}),a.wasCalled()||r(n(t))}var Cj=(e,t)=>{const r=wj();let n=null;const a=(y,w)=>{n&&Qt(),Ed("onBeforeCapture",()=>{const v=e().onBeforeCapture;v&&v({draggableId:y,mode:w})})},c=(y,w)=>{n&&Qt(),Ed("onBeforeDragStart",()=>{const v=e().onBeforeDragStart;v&&v(wh(y,w))})},l=(y,w)=>{n&&Qt();const v=wh(y,w);n={mode:w,lastCritical:y,lastLocation:v.source,lastCombine:null},r.add(()=>{Ed("onDragStart",()=>cm(e().onDragStart,v,t,Zh.onDragStart))})},d=(y,w)=>{const v=og(w),S=Gf(w);n||Qt();const L=!Sj(y,n.lastCritical);L&&(n.lastCritical=y);const E=!Aj(n.lastLocation,v);E&&(n.lastLocation=v);const R=!Tj(n.lastCombine,S);if(R&&(n.lastCombine=S),!L&&!E&&!R)return;const B={...wh(y,n.mode),combine:S,destination:v};r.add(()=>{Ed("onDragUpdate",()=>cm(e().onDragUpdate,B,t,Zh.onDragUpdate))})},p=()=>{n||Qt(),r.flush()},m=y=>{n||Qt(),n=null,Ed("onDragEnd",()=>cm(e().onDragEnd,y,t,Zh.onDragEnd))};return{beforeCapture:a,beforeStart:c,start:l,update:d,flush:p,drop:m,abort:()=>{if(!n)return;const y={...wh(n.lastCritical,n.mode),combine:null,destination:null,reason:"CANCEL"};m(y)}}},_j=(e,t)=>{const r=Cj(e,t);return n=>a=>c=>{if(Fn(c,"BEFORE_INITIAL_CAPTURE")){r.beforeCapture(c.payload.draggableId,c.payload.movementMode);return}if(Fn(c,"INITIAL_PUBLISH")){const d=c.payload.critical;r.beforeStart(d,c.payload.movementMode),a(c),r.start(d,c.payload.movementMode);return}if(Fn(c,"DROP_COMPLETE")){const d=c.payload.completed.result;r.flush(),a(c),r.drop(d);return}if(a(c),Fn(c,"FLUSH")){r.abort();return}const l=n.getState();l.phase==="DRAGGING"&&r.update(l.critical,l.impact)}};const kj=e=>t=>r=>{if(!Fn(r,"DROP_ANIMATION_FINISHED")){t(r);return}const n=e.getState();n.phase!=="DROP_ANIMATING"&&Qt(),e.dispatch(pg({completed:n.completed}))},Lj=e=>{let t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return a=>c=>{if((Fn(c,"FLUSH")||Fn(c,"DROP_COMPLETE")||Fn(c,"DROP_ANIMATION_FINISHED"))&&n(),a(c),!Fn(c,"DROP_ANIMATE"))return;const l={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(Uv())}};r=requestAnimationFrame(()=>{r=null,t=yo(window,[l])})}};var Ij=e=>()=>t=>r=>{(Fn(r,"DROP_COMPLETE")||Fn(r,"FLUSH")||Fn(r,"DROP_ANIMATE"))&&e.stopPublishing(),t(r)},Ej=e=>{let t=!1;return()=>r=>n=>{if(Fn(n,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if(Fn(n,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(Fn(n,"DROP_COMPLETE")){t=!1;const a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const Nj=e=>Fn(e,"DROP_COMPLETE")||Fn(e,"DROP_ANIMATE")||Fn(e,"FLUSH");var Rj=e=>t=>r=>n=>{if(Nj(n)){e.stop(),r(n);return}if(Fn(n,"INITIAL_PUBLISH")){r(n);const a=t.getState();a.phase!=="DRAGGING"&&Qt(),e.start(a);return}r(n),e.scroll(t.getState())};const Mj=e=>t=>r=>{if(t(r),!Fn(r,"PUBLISH_WHILE_DRAGGING"))return;const n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch($v({reason:n.reason})))},jj=ov;var Dj=({dimensionMarshal:e,focusMarshal:t,styleMarshal:r,getResponders:n,announce:a,autoScroller:c})=>av(WM,jj(RN(cj(r),Ij(e),lj(e),mj,kj,Lj,Mj,Rj(c),yj,Ej(t),_j(n,a))));const um=()=>({additions:{},removals:{},modified:{}});function Bj({registry:e,callbacks:t}){let r=um(),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(mi)).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=um(),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=um())}}}var Gv=({scrollHeight:e,scrollWidth:t,height:r,width:n})=>{const a=Fa({x:t,y:e},{x:n,y:r});return{x:Math.max(0,a.x),y:Math.max(0,a.y)}},Vv=()=>{const e=document.documentElement;return e||Qt(),e},qv=()=>{const e=Vv();return Gv({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},Qj=()=>{const e=Wv(),t=qv(),r=e.y,n=e.x,a=Vv(),c=a.clientWidth,l=a.clientHeight,d=n+c,p=r+l;return{frame:Oo({top:r,left:n,right:d,bottom:p}),scroll:{initial:e,current:e,max:t,diff:{value:mi,displacement:mi}}}},Pj=({critical:e,scrollOptions:t,registry:r})=>{const n=Qj(),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:Av(d),droppables:wv(l)},critical:e,viewport:n}};function w5(e,t,r){return!(r.descriptor.id===t.id||r.descriptor.type!==t.type||e.droppable.getById(r.descriptor.droppableId).descriptor.mode!=="virtual")}var Oj=(e,t)=>{let r=null;const n=Bj({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=(w,v)=>{e.droppable.exists(w)||Qt(),r&&t.updateDroppableIsEnabled({id:w,isEnabled:v})},c=(w,v)=>{r&&(e.droppable.exists(w)||Qt(),t.updateDroppableIsCombineEnabled({id:w,isCombineEnabled:v}))},l=(w,v)=>{r&&(e.droppable.exists(w)||Qt(),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||Qt();const v=r.critical.draggable;w.type==="ADDITION"&&w5(e,v,w.value)&&n.add(w.value),w.type==="REMOVAL"&&w5(e,v,w.value)&&n.remove(w.value)};return{updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:c,scrollDroppable:d,updateDroppableScroll:l,startPublishing:w=>{r&&Qt();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},Pj({critical:L,registry:e,scrollOptions:w.scrollOptions})},stopPublishing:p}},Yv=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",Fj=e=>{window.scrollBy(e.x,e.y)};const $j=pi(e=>Wf(e).filter(t=>!(!t.isEnabled||!t.frame))),Uj=(e,t)=>$j(t).find(n=>(n.frame||Qt(),Rv(n.frame.pageMarginBox)(e)))||null;var zj=({center:e,destination:t,droppables:r})=>{if(t){const a=r[t];return a.frame?a:null}return Uj(e,r)};const C0={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var Hj=(e,t,r=()=>C0)=>{const n=r(),a=e[t.size]*n.startFromPercentage,c=e[t.size]*n.maxScrollAtPercentage;return{startScrollingFrom:a,maxScrollValueAt:c}},Zv=({startOfRange:e,endOfRange:t,current:r})=>{const n=t-e;return n===0?0:(r-e)/n},gg=1,Wj=(e,t,r=()=>C0)=>{const n=r();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return n.maxPixelScroll;if(e===t.startScrollingFrom)return gg;const c=1-Zv({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),l=n.maxPixelScroll*n.ease(c);return Math.ceil(l)},Gj=(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 gg;const x=Zv({startOfRange:a,endOfRange:d,current:m}),y=e*n.ease(x);return Math.ceil(y)},A5=({distanceToEdge:e,thresholds:t,dragStartTime:r,shouldUseTimeDampening:n,getAutoScrollerOptions:a})=>{const c=Wj(e,t,a);return c===0?0:n?Math.max(Gj(c,r,a),gg):c},T5=({container:e,distanceToEdges:t,dragStartTime:r,axis:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=Hj(e,n,c);return t[n.end]<t[n.start]?A5({distanceToEdge:t[n.end],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c}):-1*A5({distanceToEdge:t[n.start],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c})},Vj=({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 qj=vv(e=>e===0?0:e);var Kv=({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=T5({container:t,distanceToEdges:l,dragStartTime:e,axis:lg,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),p=T5({container:t,distanceToEdges:l,dragStartTime:e,axis:Cv,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),m=qj({x:p,y:d});if(lc(m,mi))return null;const x=Vj({container:t,subject:r,proposedScroll:m});return x?lc(x,mi)?null:x:null};const Yj=vv(e=>e===0?0:e>0?1:-1),xg=(()=>{const e=(t,r)=>t<0?t:t>r?t-r:0;return({current:t,max:r,change:n})=>{const a=Ei(t,n),c={x:e(a.x,r.x),y:e(a.y,r.y)};return lc(c,mi)?null:c}})(),Xv=({max:e,current:t,change:r})=>{const n={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},a=Yj(r),c=xg({max:n,current:t,change:a});return!c||a.x!==0&&c.x===0||a.y!==0&&c.y===0},bg=(e,t)=>Xv({current:e.scroll.current,max:e.scroll.max,change:t}),Zj=(e,t)=>{if(!bg(e,t))return null;const r=e.scroll.max,n=e.scroll.current;return xg({current:n,max:r,change:t})},yg=(e,t)=>{const r=e.frame;return r?Xv({current:r.scroll.current,max:r.scroll.max,change:t}):!1},Kj=(e,t)=>{const r=e.frame;return!r||!yg(e,t)?null:xg({current:r.scroll.current,max:r.scroll.max,change:t})};var Xj=({viewport:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=Kv({dragStartTime:n,container:e.frame,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return l&&bg(e,l)?l:null},Jj=({droppable:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=e.frame;if(!l)return null;const d=Kv({dragStartTime:n,container:l.pageMarginBox,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return d&&yg(e,d)?d:null},S5=({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=Xj({dragStartTime:t,viewport:y,subject:p,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});if(w){n(w);return}}const m=zj({center:l,destination:Ua(e.impact),droppables:e.dimensions.droppables});if(!m)return;const x=Jj({dragStartTime:t,droppable:m,subject:p,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});x&&a(m.descriptor.id,x)},eD=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r=()=>C0})=>{const n=v0(e),a=v0(t);let c=null;const l=m=>{c||Qt();const{shouldUseTimeDampening:x,dragStartTime:y}=c;S5({state:m,scrollWindow:n,scrollDroppable:a,dragStartTime:y,shouldUseTimeDampening:x,getAutoScrollerOptions:r})};return{start:m=>{c&&Qt();const x=Date.now();let y=!1;const w=()=>{y=!0};S5({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}},tD=({move:e,scrollDroppable:t,scrollWindow:r})=>{const n=(d,p)=>{const m=Ei(d.current.client.selection,p);e({client:m})},a=(d,p)=>{if(!yg(d,p))return p;const m=Kj(d,p);if(!m)return t(d.descriptor.id,p),null;const x=Fa(p,m);return t(d.descriptor.id,x),Fa(p,x)},c=(d,p,m)=>{if(!d||!bg(p,m))return m;const x=Zj(p,m);if(!x)return r(m),null;const y=Fa(m,x);return r(y),Fa(m,y)};return d=>{const p=d.scrollJumpRequest;if(!p)return;const m=Ua(d.impact);m||Qt();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)}},rD=({scrollDroppable:e,scrollWindow:t,move:r,getAutoScrollerOptions:n})=>{const a=eD({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n}),c=tD({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 Wu="data-rfd",Gu=(()=>{const e=`${Wu}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),y1=(()=>{const e=`${Wu}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),nD=(()=>{const e=`${Wu}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),C5={contextId:`${Wu}-scroll-container-context-id`},sD=e=>t=>`[${t}="${e}"]`,Nd=(e,t)=>e.map(r=>{const n=r.styles[t];return n?`${r.selector} { ${n} }`:""}).join(" "),iD="pointer-events: none;";var aD=e=>{const t=sD(e),r=(()=>{const d=`
|
|
118
|
-
cursor: -webkit-grab;
|
|
119
|
-
cursor: grab;
|
|
120
|
-
`;return{selector:t(Gu.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:iD,dropAnimating:d}}})(),n=(()=>{const d=`
|
|
125
|
-
transition: ${l0.outOfTheWay};
|
|
126
|
-
`;return{selector:t(y1.contextId),styles:{dragging:d,dropAnimating:d,userCancel:d}}})(),a={selector:t(nD.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:Nd(l,"always"),resting:Nd(l,"resting"),dragging:Nd(l,"dragging"),dropAnimating:Nd(l,"dropAnimating"),userCancel:Nd(l,"userCancel")}};const za=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,dm=()=>{const e=document.querySelector("head");return e||Qt(),e},_5=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function oD(e,t){const r=An(()=>aD(e),[e]),n=b.useRef(null),a=b.useRef(null),c=Ar(pi(y=>{const w=a.current;w||Qt(),w.textContent=y}),[]),l=Ar(y=>{const w=n.current;w||Qt(),w.textContent=y},[]);za(()=>{!n.current&&!a.current||Qt();const y=_5(t),w=_5(t);return n.current=y,a.current=w,y.setAttribute(`${Wu}-always`,e),w.setAttribute(`${Wu}-dynamic`,e),dm().appendChild(y),dm().appendChild(w),l(r.always),c(r.resting),()=>{const v=S=>{const L=S.current;L||Qt(),dm().removeChild(L),S.current=null};v(n),v(a)}},[t,l,c,r.always,r.resting,e]);const d=Ar(()=>c(r.dragging),[c,r.dragging]),p=Ar(y=>{if(y==="DROP"){c(r.dropAnimating);return}c(r.userCancel)},[c,r.dropAnimating,r.userCancel]),m=Ar(()=>{a.current&&c(r.resting)},[c,r.resting]);return An(()=>({dragging:d,dropping:p,resting:m}),[d,p,m])}function Jv(e,t){return Array.from(e.querySelectorAll(t))}var e6=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Yf(e){return e instanceof e6(e).HTMLElement}function lD(e,t){const r=`[${Gu.contextId}="${e}"]`,n=Jv(document,r);if(!n.length)return null;const a=n.find(c=>c.getAttribute(Gu.draggableId)===t);return!a||!Yf(a)?null:a}function cD(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),c=Ar(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=Ar(function(w){const v=lD(e,w);v&&v!==document.activeElement&&v.focus()},[e]),d=Ar(function(w,v){r.current===w&&(r.current=v)},[]),p=Ar(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const w=r.current;w&&l(w)}))},[l]),m=Ar(function(w){r.current=null;const v=document.activeElement;v&&v.getAttribute(Gu.draggableId)===w&&(r.current=w)},[]);return za(()=>(a.current=!0,function(){a.current=!1;const w=n.current;w&&cancelAnimationFrame(w)}),[]),An(()=>({register:c,tryRecordFocus:m,tryRestoreFocusRecorded:p,tryShiftRecord:d}),[c,m,p,d])}function uD(){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||Qt(),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||Qt(),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 dD(){const e=An(uD,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var vg=k.createContext(null),Lf=()=>{const e=document.body;return e||Qt(),e};const hD={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},fD=e=>`rfd-announcement-${e}`;function pD(e){const t=An(()=>fD(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"),Sf(c.style,hD),Lf().appendChild(c),function(){setTimeout(function(){const p=Lf();p.contains(c)&&p.removeChild(c),c===r.current&&(r.current=null)})}},[t]),Ar(a=>{const c=r.current;if(c){c.textContent=a;return}},[])}const mD={separator:"::"};function wg(e,t=mD){const r=k.useId();return An(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function gD({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function xD({contextId:e,text:t}){const r=wg("hidden-text",{separator:"-"}),n=An(()=>gD({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",Lf().appendChild(c),function(){const d=Lf();d.contains(c)&&d.removeChild(c)}},[n,t]),n}var Zf=k.createContext(null);function t6(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function bD(){let e=null;function t(){return!!e}function r(l){return l===e}function n(l){e&&Qt();const d={abandon:l};return e=d,d}function a(){e||Qt(),e=null}function c(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:c}}function _0(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const yD=9,vD=13,Ag=27,r6=32,wD=33,AD=34,TD=35,SD=36,CD=37,_D=38,kD=39,LD=40,ID={[vD]:!0,[yD]:!0};var n6=e=>{ID[e.keyCode]&&e.preventDefault()};const Kf=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),s6=0,k5=5;function ED(e,t){return Math.abs(t.x-e.x)>=k5||Math.abs(t.y-e.y)>=k5}const L5={type:"IDLE"};function ND({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:c,clientX:l,clientY:d}=a;if(c!==s6)return;const p={x:l,y:d},m=r();if(m.type==="DRAGGING"){a.preventDefault(),m.actions.move(p);return}m.type!=="PENDING"&&Qt();const x=m.point;if(!ED(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===Ag){a.preventDefault(),e();return}n6(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"&&Qt(),c.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:Kf,fn:e}]}function RD(e){const t=b.useRef(L5),r=b.useRef(oc),n=An(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==s6||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=An(()=>({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=Ar(function(){const y={passive:!1,capture:!0};r.current=yo(window,[a,n],y)},[a,n]),l=Ar(()=>{t.current.type!=="IDLE"&&(t.current=L5,r.current(),c())},[c]),d=Ar(()=>{const x=t.current;l(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[l]),p=Ar(function(){const y={capture:!0,passive:!1},w=ND({cancel:d,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=yo(window,w,y)},[d,l]),m=Ar(function(y,w){t.current.type!=="IDLE"&&Qt(),t.current={type:"PENDING",point:w,actions:y},p()},[p]);za(function(){return c(),function(){r.current()}},[c])}function MD(){}const jD={[AD]:!0,[wD]:!0,[SD]:!0,[TD]:!0};function DD(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===Ag){a.preventDefault(),r();return}if(a.keyCode===r6){a.preventDefault(),n();return}if(a.keyCode===LD){a.preventDefault(),e.moveDown();return}if(a.keyCode===_D){a.preventDefault(),e.moveUp();return}if(a.keyCode===kD){a.preventDefault(),e.moveRight();return}if(a.keyCode===CD){a.preventDefault(),e.moveLeft();return}if(jD[a.keyCode]){a.preventDefault();return}n6(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:Kf,fn:r}]}function BD(e){const t=b.useRef(MD),r=An(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==r6)return;const l=e.findClosestDraggableId(c);if(!l)return;const d=e.tryGetLock(l,x,{sourceEvent:c});if(!d)return;c.preventDefault();let p=!0;const m=d.snapLift();t.current();function x(){p||Qt(),p=!1,t.current(),n()}t.current=yo(window,DD(m,x),{capture:!0,passive:!1})}}),[e]),n=Ar(function(){const c={passive:!1,capture:!0};t.current=yo(window,[r],c)},[r]);za(function(){return n(),function(){t.current()}},[n])}const hm={type:"IDLE"},QD=120,PD=.15;function OD({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===Ag&&r.preventDefault(),e()}},{eventName:Kf,fn:e}]}function FD({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"&&Qt();const c=n.touches[0];if(!c||!(c.force>=PD))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:Kf,fn:e}]}function $D(e){const t=b.useRef(hm),r=b.useRef(oc),n=Ar(function(){return t.current},[]),a=Ar(function(v){t.current=v},[]),c=An(()=>({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,W={x:R,y:B};r.current(),y(L,W)}}),[e]),l=Ar(function(){const v={capture:!0,passive:!1};r.current=yo(window,[c],v)},[c]),d=Ar(()=>{const w=t.current;w.type!=="IDLE"&&(w.type==="PENDING"&&clearTimeout(w.longPressTimerId),a(hm),r.current(),l())},[l,a]),p=Ar(()=>{const w=t.current;d(),w.type==="DRAGGING"&&w.actions.cancel({shouldBlockNextClick:!0}),w.type==="PENDING"&&w.actions.abort()},[d]),m=Ar(function(){const v={capture:!0,passive:!1},S={cancel:p,completed:d,getPhase:n},L=yo(window,FD(S),v),E=yo(window,OD(S),v);r.current=function(){L(),E()}},[p,n,d]),x=Ar(function(){const v=n();v.type!=="PENDING"&&Qt();const S=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:S,hasMoved:!1})},[n,a]),y=Ar(function(v,S){n().type!=="IDLE"&&Qt();const L=setTimeout(x,QD);a({type:"PENDING",point:S,actions:v,longPressTimerId:L}),m()},[m,n,a,x]);za(function(){return l(),function(){r.current();const S=n();S.type==="PENDING"&&(clearTimeout(S.longPressTimerId),a(hm))}},[n,l,a]),za(function(){return yo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const UD=["input","button","textarea","select","option","optgroup","video","audio"];function i6(e,t){if(t==null)return!1;if(UD.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:i6(e,t.parentElement)}function zD(e,t){const r=t.target;return Yf(r)?i6(e,r):!1}var HD=e=>Oo(e.getBoundingClientRect()).center;function WD(e){return e instanceof e6(e).Element}const GD=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function a6(e,t){return e==null?null:e[GD](t)?e:a6(e.parentElement,t)}function VD(e,t){return e.closest?e.closest(t):a6(e,t)}function qD(e){return`[${Gu.contextId}="${e}"]`}function YD(e,t){const r=t.target;if(!WD(r))return null;const n=qD(e),a=VD(r,n);return!a||!Yf(a)?null:a}function ZD(e,t){const r=YD(e,t);return r?r.getAttribute(Gu.draggableId):null}function KD(e,t){const r=`[${y1.contextId}="${e}"]`,a=Jv(document,r).find(c=>c.getAttribute(y1.id)===t);return!a||!Yf(a)?null:a}function XD(e){e.preventDefault()}function Ah({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function o6({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!Yv(t.getState(),n))}function JD({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:c,sourceEvent:l}){if(!o6({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const p=n.draggable.getById(a),m=KD(t,p.descriptor.id);if(!m||l&&!p.options.canDragInteractiveElements&&zD(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(U,V){Ah({expected:U,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(V())}const L=S.bind(null,"DRAGGING");function E(U){function V(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(V(),Qt()),r.dispatch(VM(U.liftActionArgs)),y="DRAGGING";function Z(ce,xe={shouldBlockNextClick:!1}){if(U.cleanup(),xe.shouldBlockNextClick){const pe=yo(window,[{eventName:"click",fn:XD,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(pe)}V(),r.dispatch($v({reason:ce}))}return{isActive:()=>Ah({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,drop:ce=>Z("DROP",ce),cancel:ce=>Z("CANCEL",ce),...U.actions}}function R(U){const V=v0(ce=>{L(()=>Fv({client:ce}))});return{...E({liftActionArgs:{id:a,clientSelection:U,movementMode:"FLUID"},cleanup:()=>V.cancel(),actions:{move:V}}),move:V}}function B(){const U={moveUp:()=>L(rj),moveRight:()=>L(sj),moveDown:()=>L(nj),moveLeft:()=>L(ij)};return E({liftActionArgs:{id:a,clientSelection:HD(m),movementMode:"SNAP"},cleanup:oc,actions:U})}function W(){Ah({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>Ah({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,fluidLift:R,snapLift:B,abort:W}}const eB=[RD,BD,$D];function tB({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const c=[...a?eB:[],...n||[]],l=b.useState(()=>bD())[0],d=Ar(function(E,R){_0(E)&&!_0(R)&&l.tryAbandon()},[l]);za(function(){let E=t.getState();return t.subscribe(()=>{const B=t.getState();d(E,B),E=B})},[l,t,d]),za(()=>l.tryAbandon,[l.tryAbandon]);const p=Ar(L=>o6({lockAPI:l,registry:r,store:t,draggableId:L}),[l,r,t]),m=Ar((L,E,R)=>JD({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=Ar(L=>ZD(e,L),[e]),y=Ar(L=>{const E=r.draggable.findById(L);return E?E.options:null},[r.draggable]),w=Ar(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(fg()))},[l,t]),v=Ar(()=>l.isClaimed(),[l]),S=An(()=>({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 rB=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};Ii.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),nB=e=>({...C0,...e.autoScrollerOptions,durationDampening:{...C0.durationDampening,...e.autoScrollerOptions}});function Rd(e){return e.current||Qt(),e.current}function sB(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:c}=e,l=b.useRef(null),d=t6(e),p=Ar(()=>rB(d.current),[d]),m=Ar(()=>nB(d.current),[d]),x=pD(t),y=xD({contextId:t,text:c}),w=oD(t,a),v=Ar(pe=>{Rd(l).dispatch(pe)},[]),S=An(()=>e5({publishWhileDragging:YM,updateDroppableScroll:KM,updateDroppableIsEnabled:XM,updateDroppableIsCombineEnabled:JM,collectionStarting:ZM},v),[v]),L=dD(),E=An(()=>Oj(L,S),[L,S]),R=An(()=>rD({scrollWindow:Fj,scrollDroppable:E.scrollDroppable,getAutoScrollerOptions:m,...e5({move:Fv},v)}),[E.scrollDroppable,v,m]),B=cD(t),W=An(()=>Dj({announce:x,autoScroller:R,dimensionMarshal:E,focusMarshal:B,getResponders:p,styleMarshal:w}),[x,R,E,B,p,w]);l.current=W;const F=Ar(()=>{const pe=Rd(l);pe.getState().phase!=="IDLE"&&pe.dispatch(fg())},[]),U=Ar(()=>{const pe=Rd(l).getState();return pe.phase==="DROP_ANIMATING"?!0:pe.phase==="IDLE"?!1:pe.isDragging},[]),V=An(()=>({isDragging:U,tryAbort:F}),[U,F]);r(V);const Z=Ar(pe=>Yv(Rd(l).getState(),pe),[]),ce=Ar(()=>Mc(Rd(l).getState()),[]),xe=An(()=>({marshal:E,focus:B,contextId:t,canLift:Z,isMovementAllowed:ce,dragHandleUsageInstructionsId:y,registry:L}),[t,E,y,B,Z,ce,L]);return tB({contextId:t,store:W,registry:L,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>F,[F]),k.createElement(Zf.Provider,{value:xe},k.createElement(IR,{context:vg,store:W},e.children))}function iB(){return k.useId()}function c0(e){const t=iB(),r=e.dragHandleUsageInstructions||Zh.dragHandleUsageInstructions;return k.createElement(BR,null,n=>k.createElement(sB,{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 I5={dragging:5e3,dropAnimating:4500},aB=(e,t)=>t?l0.drop(t.duration):e?l0.snap:l0.fluid,oB=(e,t)=>{if(e)return t?S0.opacity.drop:S0.opacity.combining},lB=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function cB(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:c}=e,l=!!a,d=lB(e),p=!!c,m=p?x1.drop(n,l):x1.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:aB(d,c),transform:m,opacity:oB(l,p),zIndex:p?I5.dropAnimating:I5.dragging,pointerEvents:"none"}}function uB(e){return{transform:x1.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function dB(e){return e.type==="DRAGGING"?cB(e):uB(e)}function hB(e,t,r=mi){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),c=pv(a,n),l=Tf(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 fB(e){const t=wg("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}=e,p=An(()=>({canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}),[c,d,l]),m=Ar(v=>{const S=a();return S||Qt(),hB(r,S,v)},[r,a]),x=An(()=>({uniqueId:t,descriptor:r,options:p,getDimension:m}),[r,m,p,t]),y=b.useRef(x),w=b.useRef(!0);za(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),za(()=>{if(w.current){w.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var Tg=k.createContext(null);function If(e){const t=b.useContext(e);return t||Qt(),t}function pB(e){e.preventDefault()}const mB=e=>{const t=b.useRef(null),r=Ar((V=null)=>{t.current=V},[]),n=Ar(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:c,registry:l}=If(Zf),{type:d,droppableId:p}=If(Tg),m=An(()=>({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=An(()=>({descriptor:m,registry:l,getDraggableRef:n,canDragInteractiveElements:S,shouldRespectForcePress:v,isEnabled:w}),[m,l,n,S,v,w]);fB(V)}const B=An(()=>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:pB}:null,[a,c,y,w]),W=Ar(V=>{E.type==="DRAGGING"&&E.dropping&&V.propertyName==="transform"&&Ii.flushSync(R)},[R,E]),F=An(()=>{const V=dB(E),Z=E.type==="DRAGGING"&&E.dropping?W: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,W,r]),U=An(()=>({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(F,E.snapshot,U))};var l6=(e,t)=>e===t,c6=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const gB=e=>e.combine?e.combine.draggableId:null,xB=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function bB(){const e=pi((a,c)=>({x:a,y:c})),t=pi((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=pi((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(_0(a)){if(a.critical.draggable.id!==c.draggableId)return null;const l=a.current.client.offset,d=a.dimensions.draggables[c.draggableId],p=Ua(a.impact),m=xB(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=c6(m),w=gB(m),S={duration:a.dropDuration,curve:mg.drop,moveTo:a.newHomeClientOffset,opacity:w?S0.opacity.drop:null,scale:w?S0.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 u6(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const yB={mapped:{type:"SECONDARY",offset:mi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:u6(null)}};function vB(){const e=pi((l,d)=>({x:l,y:d})),t=pi(u6),r=pi((l,d=null,p)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:d,shouldAnimateDisplacement:p,snapshot:t(d)}})),n=l=>l?r(mi,l,!0):null,a=(l,d,p,m)=>{const x=p.displaced.visible[l],y=!!(m.inVirtualList&&m.effected[l]),w=Gf(p),v=w&&w.draggableId===l?d:null;if(!x){if(!y)return n(v);if(p.displaced.invisible[l])return null;const E=Xu(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(_0(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 wB=()=>{const e=bB(),t=vB();return(n,a)=>e(n,a)||t(n,a)||yB},AB={dropAnimationFinished:Uv},TB=fv(wB,AB,null,{context:vg,areStatePropsEqual:l6})(mB);function d6(e){return If(Tg).isUsingCloneFor===e.draggableId&&!e.isClone?null:k.createElement(TB,e)}function kl(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return k.createElement(d6,Sf({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const h6=e=>t=>e===t,SB=h6("scroll"),CB=h6("auto"),E5=(e,t)=>t(e.overflowX)||t(e.overflowY),_B=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return E5(r,SB)||E5(r,CB)},kB=()=>!1,f6=e=>e==null?null:e===document.body?kB()?e:null:e===document.documentElement?null:_B(e)?e:f6(e.parentElement);var v1=e=>({x:e.scrollLeft,y:e.scrollTop});const p6=e=>e?window.getComputedStyle(e).position==="fixed"?!0:p6(e.parentElement):!1;var LB=e=>{const t=f6(e),r=p6(e);return{closestScrollable:t,isFixedOnPage:r}},IB=({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=Gv({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:mi,displacement:mi}}}})(),m=a==="vertical"?lg:Cv,x=Hu({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 EB=(e,t)=>{const r=mv(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=sg({top:n,right:l,bottom:c,left:a},r.border);return ig({borderBox:p,margin:r.margin,border:r.border,padding:r.padding})};var NB=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:c,isCombineEnabled:l,shouldClipSubject:d})=>{const p=r.closestScrollable,m=EB(e,p),x=Tf(m,n),y=(()=>{if(!p)return null;const v=mv(p),S={scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth};return{client:v,page:Tf(v,n),scroll:v1(p),scrollSize:S,shouldClipSubject:d}})();return IB({descriptor:t,isEnabled:!c,isCombineEnabled:l,isFixedOnPage:r.isFixedOnPage,direction:a,client:m,page:x,closest:y})};const RB={passive:!1},MB={passive:!0};var N5=e=>e.shouldPublishImmediately?RB:MB;const Th=e=>e&&e.env.closestScrollable||null;function jB(e){const t=b.useRef(null),r=If(Zf),n=wg("droppable"),{registry:a,marshal:c}=r,l=t6(e),d=An(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),p=b.useRef(d),m=An(()=>pi((F,U)=>{t.current||Qt();const V={x:F,y:U};c.updateDroppableScroll(d.id,V)}),[d.id,c]),x=Ar(()=>{const F=t.current;return!F||!F.env.closestScrollable?mi:v1(F.env.closestScrollable)},[]),y=Ar(()=>{const F=x();m(F.x,F.y)},[x,m]),w=An(()=>v0(y),[y]),v=Ar(()=>{const F=t.current,U=Th(F);if(F&&U||Qt(),F.scrollOptions.shouldPublishImmediately){y();return}w()},[w,y]),S=Ar((F,U)=>{t.current&&Qt();const V=l.current,Z=V.getDroppableRef();Z||Qt();const ce=LB(Z),xe={ref:Z,descriptor:d,env:ce,scrollOptions:U};t.current=xe;const pe=NB({ref:Z,descriptor:d,env:ce,windowScroll:F,direction:V.direction,isDropDisabled:V.isDropDisabled,isCombineEnabled:V.isCombineEnabled,shouldClipSubject:!V.ignoreContainerClipping}),te=ce.closestScrollable;return te&&(te.setAttribute(C5.contextId,r.contextId),te.addEventListener("scroll",v,N5(xe.scrollOptions))),pe},[r.contextId,d,v,l]),L=Ar(()=>{const F=t.current,U=Th(F);return F&&U||Qt(),v1(U)},[]),E=Ar(()=>{const F=t.current;F||Qt();const U=Th(F);t.current=null,U&&(w.cancel(),U.removeAttribute(C5.contextId),U.removeEventListener("scroll",v,N5(F.scrollOptions)))},[v,w]),R=Ar(F=>{const U=t.current;U||Qt();const V=Th(U);V||Qt(),V.scrollTop+=F.y,V.scrollLeft+=F.x},[]),B=An(()=>({getDimensionAndWatchScroll:S,getScrollWhileDragging:L,dragStopped:E,scroll:R}),[E,S,L,R]),W=An(()=>({uniqueId:n,descriptor:d,callbacks:B}),[B,d,n]);za(()=>(p.current=W.descriptor,a.droppable.register(W),()=>{t.current&&E(),a.droppable.unregister(W)}),[B,d,E,W,c,a.droppable]),za(()=>{t.current&&c.updateDroppableIsEnabled(p.current.id,!e.isDropDisabled)},[e.isDropDisabled,c]),za(()=>{t.current&&c.updateDroppableIsCombineEnabled(p.current.id,e.isCombineEnabled)},[e.isCombineEnabled,c])}function fm(){}const R5={width:0,height:0,margin:zR},DB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?R5:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},BB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=DB({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"?l0.placeholder:null}},QB=e=>{const t=b.useRef(null),r=Ar(()=>{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),fm):t.current?fm:(t.current=setTimeout(()=>{t.current=null,p(!1)}),r):fm,[n,d,r]);const m=Ar(y=>{y.propertyName==="height"&&(a(),n==="close"&&c())},[n,c,a]),x=BB({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 PB=k.memo(QB);class OB 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 FB=e=>{const t=b.useContext(Zf);t||Qt();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=Ar(()=>a.current,[]),W=Ar((te=null)=>{a.current=te},[]);Ar(()=>c.current,[]);const F=Ar((te=null)=>{c.current=te},[]),U=Ar(()=>{n()&&E({maxScroll:qv()})},[n,E]);jB({droppableId:d,type:p,mode:m,direction:x,isDropDisabled:w,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:B});const V=An(()=>k.createElement(OB,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:te,data:ke,animate:$e})=>k.createElement(PB,{placeholder:ke,onClose:te,innerRef:F,animate:$e,contextId:r,onTransitionEnd:U})),[r,U,e.placeholder,e.shouldAnimatePlaceholder,F]),Z=An(()=>({innerRef:W,placeholder:V,droppableProps:{"data-rfd-droppable-id":d,"data-rfd-droppable-context-id":r}}),[r,d,V,W]),ce=L?L.dragging.draggableId:null,xe=An(()=>({droppableId:d,type:p,isUsingCloneFor:ce}),[d,ce,p]);function pe(){if(!L)return null;const{dragging:te,render:ke}=L,$e=k.createElement(d6,{draggableId:te.draggableId,index:te.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(Y,Ae)=>ke(Y,Ae,te));return oA.createPortal($e,R())}return k.createElement(Tg.Provider,{value:xe},l(Z,S),pe())};function $B(){return document.body||Qt(),document.body}const M5={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:$B},m6=e=>{let t={...e},r;for(r in M5)e[r]===void 0&&(t={...t,[r]:M5[r]});return t},pm=(e,t)=>e===t.droppable.type,j5=(e,t)=>t.draggables[e.draggable.id],UB=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=pi(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),n=pi((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=m6(l),p=d.droppableId,m=d.type,x=!d.isDropDisabled,y=d.renderClone;if(_0(c)){const w=c.critical;if(!pm(m,w))return t;const v=j5(w,c.dimensions),S=Ua(c.impact)===p;return n(p,x,S,S,v,y)}if(c.phase==="DROP_ANIMATING"){const w=c.completed;if(!pm(m,w.critical))return t;const v=j5(w.critical,c.dimensions);return n(p,x,c6(w.result)===p,Ua(w.impact)===p,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const w=c.completed;if(!pm(m,w.critical))return t;const v=Ua(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}},zB={updateViewportMaxScroll:tj},Ll=fv(UB,zB,(e,t,r)=>({...m6(r),...e,...t}),{context:vg,areStatePropsEqual:l6})(FB);function HB(){if(typeof window>"u")return ju(void 0);try{const e=window.localStorage.getItem(s1);return ju(e?JSON.parse(e):void 0)}catch{return ju(void 0)}}function mm(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(s1),r=t?JSON.parse(t):{},n=ju({...r,...e});window.localStorage.setItem(s1,JSON.stringify(n))}catch{}}function WB(){const[e,t]=k.useState(HB);k.useEffect(()=>{mm(e)},[e]);const r=k.useCallback(a=>{t(c=>{const l=ju({...c,...a});return mm(l),l})},[]),n=k.useCallback(()=>{const a=ju(void 0);t(a),mm(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const w1="termdock-settings";function GB(e){return e==="shell"||e==="tmux"}function VB(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(w1);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&GB(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 D5(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(w1),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(w1,JSON.stringify(n))}catch{}}function qB(){const[e,t]=k.useState(VB),r=k.useCallback((a,c)=>{const l=c?.userInitiated!==!1;t(d=>({...d,mode:a,userSelectedMode:l?a:d.userSelectedMode})),l&&D5({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=k.useCallback(a=>{t(c=>({...c,tmuxName:a})),D5({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const YB=550,ZB=10;function g6(){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())},YB))},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)>ZB&&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 B5({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 KB(e,t,r){return!!(e&&t===e&&!r)}function XB({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 Cw();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 _w(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(Ly,{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(gn,{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 Q5(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 Ef={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function x6(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:Ef[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function Xf(e){if(e.status!=="open")return[];const t=x6(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 JB(e){return Xf(e)[0]??null}function Yc(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=JB(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?Ef[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 Fi(e){return e.purpose!=="automation"&&e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(Yc(e))}const _u=hc(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await vy();e({tasks:r.filter(Fi),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function P5(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 O5({sessionIds:e}){const t=kw(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=zr();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 eQ(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 b6(e){const t=eQ(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 tQ(e,t,r){return Math.max(t,Math.min(e,r))}const hs={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 F5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function $5(e,t,r,n=.15){return n===0?tQ(e,t,r):e<t?-F5(t-e,r-t,n)+t:e>r?+F5(e-r,r-t,n)+r:e}function rQ(e,[t,r],[n,a]){const[[c,l],[d,p]]=e;return[$5(t,c,l,n),$5(r,d,p,a)]}function nQ(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 sQ(e){var t=nQ(e,"string");return typeof t=="symbol"?t:String(t)}function Ps(e,t,r){return t=sQ(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U5(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?U5(Object(r),!0).forEach(function(n){Ps(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const y6={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 z5(e){return e?e[0].toUpperCase()+e.slice(1):""}const iQ=["enter","leave"];function aQ(e=!1,t){return e&&!iQ.includes(t)}function oQ(e,t="",r=!1){const n=y6[e],a=n&&n[t]||t;return"on"+z5(e)+z5(a)+(aQ(r,a)?"Capture":"")}const lQ=["gotpointercapture","lostpointercapture"];function cQ(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=lQ.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function uQ(e,t=""){const r=y6[e],n=r&&r[t]||t;return e+n}function Jf(e){return"touches"in e}function v6(e){return Jf(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function dQ(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 hQ(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function w6(e){return Jf(e)?hQ(e)[0]:e}function A1(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 fQ(e){return dQ(e).map(t=>t.identifier)}function H5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return A1(r,n)}function gm(e){const t=w6(e);return Jf(e)?t.identifier:t.pointerId}function Vu(e){const t=w6(e);return[t.clientX,t.clientY]}const W5=40,G5=800;function A6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=W5,r*=W5):n===2&&(t*=G5,r*=G5),[t,r]}function pQ(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 mQ(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 Nf(e,...t){return typeof e=="function"?e(...t):e}function gQ(){}function xQ(...e){return e.length===0?gQ:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function V5(e,t){return Object.assign({},t,e||{})}const bQ=32;class T6{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?Nf(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,mQ(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);hs.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=Nf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[L,E]=r.offset,[[R,B],[W,F]]=r._bounds;r.overflow=[L<R?-1:L>B?1:0,E<W?-1:E>F?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 U=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=rQ(r._bounds,r.offset,U),r.delta=hs.sub(r.offset,v),this.computeMovement(),S&&(!r.last||c>bQ)){r.delta=hs.sub(r.offset,v);const V=r.delta.map(Math.abs);hs.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 yQ([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 Q0 extends T6{constructor(...t){super(...t),Ps(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=hs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=hs.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[v6(t)]:n.axisThreshold;r.axis=yQ(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 vQ=e=>e,q5=.15,S6={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[q5,q5];case!1:return[0,0];default:return hs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return hs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||vQ},threshold(e){return hs.toVector(e,0)}},wQ=0,Kc=vs(vs({},S6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=wQ){return e},bounds(e={}){if(typeof e=="function")return c=>Kc.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]]}}),Y5={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 AQ extends Q0{constructor(...t){super(...t),Ps(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=Kc.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=gm(t),n._pointerActive=!0,this.computeValues(Vu(t)),this.computeInitial(),r.preventScrollAxis&&v6(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=gm(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const c=Vu(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=hs.sub(c,r._values),this.computeValues(c)),hs.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=gm(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,TQ(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=Y5[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,hs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Y5&&(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 TQ(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const P0=typeof window<"u"&&window.document&&window.document.createElement;function C6(){return P0&&"ontouchstart"in window}function SQ(){return C6()||P0&&window.navigator.maxTouchPoints>1}function CQ(){return P0&&"onpointerdown"in window}function _Q(){return P0&&"exitPointerLock"in window.document}function kQ(){try{return"constructor"in GestureEvent}catch{return!1}}const go={isBrowser:P0,gesture:kQ(),touch:C6(),touchscreen:SQ(),pointer:CQ(),pointerLock:_Q()},LQ=250,IQ=180,EQ=.5,NQ=50,RQ=250,MQ=10,Z5={mouse:0,touch:0,pen:8},jQ=vs(vs({},Kc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&go.pointerLock,go.touch&&r?"touch":this.pointerLock?"mouse":go.pointer&&!a?"pointer":go.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?LQ:void 0,!(!go.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=hs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=EQ,distance:t=NQ,duration:r=RQ}={}){return{velocity:this.transform(hs.toVector(e)),distance:this.transform(hs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return IQ;case!1:return 0;default:return e}},axisThreshold(e){return e?vs(vs({},Z5),e):Z5},keyboardDisplacement(e=MQ){return e}});function _6(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 DQ=30,BQ=100;class QQ extends T6{constructor(...t){super(...t),Ps(this,"ingKey","pinching"),Ps(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=hs.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)*DQ-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=H5(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=A1(...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=H5(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=A1(...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=hs.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=[-A6(t)[1]/BQ*n.offset[0],0],hs.addTo(n._movement,n._delta),_6(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 PQ=vs(vs({},S6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!go.touch&&go.gesture)return"gesture";if(go.touch&&n)return"touch";if(go.touchscreen){if(go.pointer)return"pointer";if(go.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const d=V5(Nf(r,l),{min:-1/0,max:1/0});return[d.min,d.max]},c=l=>{const d=V5(Nf(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",hs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class OQ extends Q0{constructor(...t){super(...t),Ps(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(Vu(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=Vu(t),n=this.state;n._delta=hs.sub(r,n._values),hs.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 FQ=vs(vs({},Kc),{},{mouseOnly:(e=!0)=>e});class $Q extends Q0{constructor(...t){super(...t),Ps(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=pQ(t);r._delta=hs.sub(n,r._values),hs.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 UQ=Kc;class zQ extends Q0{constructor(...t){super(...t),Ps(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=A6(t),hs.addTo(r._movement,r._delta),_6(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 HQ=Kc;class WQ extends Q0{constructor(...t){super(...t),Ps(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Vu(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=Vu(t);r._movement=r._delta=hs.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 GQ=vs(vs({},Kc),{},{mouseOnly:(e=!0)=>e}),Sg=new Map,T1=new Map;function k6(e){Sg.set(e.key,e.engine),T1.set(e.key,e.resolver)}const L6={key:"drag",engine:AQ,resolver:jQ},VQ={key:"hover",engine:WQ,resolver:GQ},qQ={key:"move",engine:OQ,resolver:FQ},YQ={key:"pinch",engine:QQ,resolver:PQ},ZQ={key:"scroll",engine:$Q,resolver:UQ},KQ={key:"wheel",engine:zQ,resolver:HQ};function XQ(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 JQ(e,t){if(e==null)return{};var r=XQ(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 eP={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=go.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},tP=["target","eventOptions","window","enabled","transform"];function Kh(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]=Kh(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function rP(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:d,transform:p}=n,m=JQ(n,tP);if(r.shared=Kh({target:a,eventOptions:c,window:l,enabled:d,transform:p},eP),t){const x=T1.get(t);r[t]=Kh(vs({shared:r.shared},m),x)}else for(const x in m){const y=T1.get(x);y&&(r[x]=Kh(vs({shared:r.shared},m[x]),y))}return r}class I6{constructor(t,r){Ps(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,d=uQ(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 nP{constructor(){Ps(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 sP{constructor(t){Ps(this,"gestures",new Set),Ps(this,"_targetEventStore",new I6(this)),Ps(this,"gestureEventStores",{}),Ps(this,"gestureTimeoutStores",{}),Ps(this,"handlers",{}),Ps(this,"config",{}),Ps(this,"pointerIds",new Set),Ps(this,"touchIds",new Set),Ps(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),iP(this,t)}setEventIds(t){if(Jf(t))return this.touchIds=new Set(fQ(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=rP(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=K5(n,d.eventOptions,!!a);if(d.enabled){const m=Sg.get(l);new m(this,t,l).bind(p)}}const c=K5(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]=xQ(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:d,passive:p}=cQ(c);this._targetEventStore.add(a,l,"",n[c],{capture:d,passive:p})}}}}function yu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new I6(e,t),e.gestureTimeoutStores[t]=new nP}function iP(e,t){t.drag&&yu(e,"drag"),t.wheel&&yu(e,"wheel"),t.scroll&&yu(e,"scroll"),t.move&&yu(e,"move"),t.pinch&&yu(e,"pinch"),t.hover&&yu(e,"hover")}const K5=(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:oQ(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},aP=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function oP(e){const t={},r={},n=new Set;for(let a in e)aP.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function vu(e,t,r,n,a,c){if(!e.has(r)||!Sg.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 lP(e,t){const[r,n,a]=oP(e),c={};return vu(a,r,"onDrag","drag",c,t),vu(a,r,"onWheel","wheel",c,t),vu(a,r,"onScroll","scroll",c,t),vu(a,r,"onPinch","pinch",c,t),vu(a,r,"onMove","move",c,t),vu(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function E6(e,t={},r,n){const a=k.useMemo(()=>new sP(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 X5(e,t){return k6(L6),E6({drag:e},t||{},"drag")}function cP(e){return e.forEach(k6),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=lP(r,n||{});return E6(a,l,void 0,c)}}function NU(e,t){return cP([L6,YQ,ZQ,KQ,qQ,VQ])(e,t||{})}const J5={dampingRatio:.8,response:.3},uP=.998;function dP(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 hP(e,t=uP){return e/1e3*(t/(1-t))}function eb(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function fP(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const pP=.1,mP=5;function gP(e,t,r,n,a){const c=dP(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)<pP&&Math.abs(w)<mP)break}return p.push(a?a(n):n),{frames:p,durationMs:(p.length-1)*l,solver:c}}const xP='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function bP(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(xP)&&e.blur()}const yP=18,tb=8,rb={touch:tb,pen:tb},vP=500,xm=200,nb=50,wP=`[${uA}]`;function bm(e,t,r){return Math.min(r,Math.max(t,e))}function sb(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 ib(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(wP)}function Md(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const N6=k.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:d=!1},p){const{t:m}=zr(),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),W=b.useRef(null),F=b.useRef(!1),U=b.useRef(null),V=b.useRef(!1),Z=b.useRef([]),ce=b.useRef(null),xe=b.useRef(S.current),pe=b.useRef(r?1:0),te=b.useRef(r);te.current=r;const ke=b.useRef(y);ke.current=y;const $e=b.useRef(n);$e.current=n;const Y=b.useRef(x);Y.current=x;const Ae=b.useRef(a);Ae.current=a;const lt=b.useRef(c);lt.current=c;const Se=b.useCallback(oe=>{w.current=oe,typeof p=="function"?p(oe):p&&(p.current=oe)},[p]),ye=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),L.current=null},[]),_e=b.useCallback(oe=>{const be=$e.current;return Y.current?(oe+be)/be:(be-oe)/be},[]),je=b.useCallback(oe=>{const be=v.current;be&&(be.style.opacity=String(bm(_e(oe),0,1)))},[_e]),re=b.useCallback(oe=>{S.current=oe;const be=w.current;be&&(be.style.transform=`translateX(${oe}px)`,je(oe))},[je]),Oe=b.useCallback(oe=>{L.current=oe,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const be=L.current;L.current=null,be!==null&&re(be)}))},[re]),Ce=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null);const oe=L.current;L.current=null,oe!==null&&re(oe)},[re]),Ee=b.useCallback(oe=>{const be=ke.current;return bm(oe,Math.min(0,be),Math.max(0,be))},[]),Be=b.useCallback(()=>{const oe=B.current;if(!oe)return null;B.current=null;const be=(performance.now()-oe.startTime)/1e3,Ze={value:oe.solver.value(be),velocity:oe.solver.velocity(be)};return oe.animations.forEach(Je=>Je.cancel()),Ze},[]),Ne=b.useCallback(()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[]),le=b.useCallback(()=>{ce.current?.(),ce.current=null},[]),He=b.useCallback(()=>{Ce(),Ne();const oe=Be();oe&&re(Ee(oe.value));const be=w.current,Ze=v.current;be?.getAnimations().forEach(Je=>Je.cancel()),be&&(be.style.transition="none",be.style.opacity="1"),Ze?.getAnimations().forEach(Je=>Je.cancel()),Ze&&(Ze.style.transition="none")},[re,Ne,Ee,Ce,Be]),rt=b.useCallback((oe,be)=>{Ce(),Ne();const Ze=w.current,Je=v.current,St=oe?0:ke.current;Je&&(Je.style.pointerEvents=oe?"auto":"none");const Vt=Be(),jt=Vt?Ee(Vt.value):S.current,vt=be?.velocity??Vt?.velocity??0;if(fP())return S.current=St,Ze&&(Ze.style.transition=`opacity ${xm}ms ease`,Ze.style.opacity=oe?"1":"0",Ze.style.transform=`translateX(${St}px)`),Je&&(Je.style.transition=`opacity ${xm}ms ease`,Je.style.opacity=oe?"1":"0"),xm;Ze&&(Ze.style.transition="none",Ze.style.opacity="1"),Je&&(Je.style.transition="none");const Zt=Math.abs(be?.velocity??0)>vP,{frames:Pt,durationMs:Xt,solver:zt}=gP({dampingRatio:Zt?J5.dampingRatio:1,response:J5.response},jt,vt,St,Ee);if(!Ze||Math.abs(jt-St)<.5&&Math.abs(vt)<5)return re(St),0;const Lt=Ze.animate(Pt.map(Ge=>({transform:`translateX(${Ge}px)`})),{duration:Xt,easing:"linear",fill:"forwards"}),me=[Lt];return Je&&me.push(Je.animate(Pt.map(Ge=>({opacity:String(bm(_e(Ge),0,1))})),{duration:Xt,easing:"linear",fill:"forwards"})),B.current={solver:zt,startTime:performance.now(),target:St,animations:me},Md("spring start",{startX:jt,startVelocity:vt,targetX:St,frames:Pt.length,durationMs:Xt}),Lt.onfinish=()=>{const Ge=B.current;!Ge||!Ge.animations.includes(Lt)||(B.current=null,re(St),Ge.animations.forEach(pt=>pt.cancel()),Md("spring finish",{targetX:St}))},Xt},[re,Ne,Ee,Ce,_e,Be]),mt=b.useCallback(oe=>{Ce();const be=oe,Ze=0,Je=ke.current,St=S.current+hP(be),Vt=Math.abs(St-Ze)<=Math.abs(St-Je);Md("decideSnap",{velocity:be,currentX:S.current,projected:St,shouldOpen:Vt});const jt=rt(Vt,{velocity:be});return Vt&&!te.current?W.current=window.setTimeout(()=>{W.current=null,lt.current?.()},jt+nb):!Vt&&te.current&&(W.current=window.setTimeout(()=>{W.current=null,Ae.current()},jt+nb)),Vt},[rt,Ce]),ue=b.useCallback(oe=>{const be=ke.current,Ze=Math.min(0,be),Je=Math.max(0,be),St=$e.current;return oe<Ze?Ze-eb(Ze-oe,St):oe>Je?Je+eb(oe-Je,St):oe},[]),Ye=b.useCallback(oe=>{const be=Z.current,Ze=performance.now();be.push({t:Ze,x:oe});const Je=Ze-120;for(;be.length>0&&be[0].t<Je;)be.shift()},[]),st=b.useCallback(()=>{const oe=Z.current;if(oe.length<2)return 0;const be=oe[oe.length-1];if(performance.now()-be.t>60)return 0;const Ze=oe[0],Je=(be.t-Ze.t)/1e3;return Je<.016?0:(be.x-Ze.x)/Je},[]);b.useEffect(()=>{Ne();const oe=B.current,be=r?0:ke.current;oe&&oe.target===be||rt(r)},[r,rt,Ne]),b.useEffect(()=>{He(),Oe(te.current?0:y)},[y,He,Oe]),b.useEffect(()=>()=>{ye(),Ne(),Be(),le()},[Ne,ye,le,Be]);const Ie=X5(({active:oe,cancel:be,first:Ze,last:Je,movement:[St],event:Vt})=>{if(Md("bindPanel",{active:oe,first:Ze,last:Je,mx:St}),!sb(Vt)){be();return}if(Ze){if(le(),F.current=!1,U.current=null,Z.current=[],ib(Vt)){be();return}const jt=w.current,vt=jt?dA(Vt.target,jt):null;if(!vt||hA()){be();return}const Zt=fA(vt,St,Y.current?-1:1);if(Md("arbitrate",{owner:Zt.kind,mx:St}),Zt.kind==="swiper"){ce.current=pA(Zt.instance),be();return}if(Zt.kind==="scroller"){const Pt=mA(Zt.element);if(Pt)U.current=Pt;else{be();return}}U.current||(F.current=!0,He(),R.current=S.current)}if(!oe){U.current=null,F.current&&(F.current=!1,mt(st()));return}if(U.current){gA(U.current,St);return}if(F.current){const jt=ue(R.current+St);Ye(jt),Oe(jt)}},{axis:"x",axisThreshold:rb,filterTaps:!0,pointer:{touch:!0}}),We=X5(({active:oe,cancel:be,first:Ze,movement:[Je],event:St})=>{if(!sb(St)){be();return}if(te.current){be();return}if(Ze&&(V.current=!0,Z.current=[],He(),R.current=S.current),!oe){V.current&&(V.current=!1,mt(st())&&bP());return}if(V.current){const Vt=ue(R.current+Je);Ye(Vt),Oe(Vt)}},{axis:"x",axisThreshold:rb,filterTaps:!0,pointer:{touch:!0}}),Te=b.useCallback(oe=>{oe.preventDefault(),oe.stopPropagation(),te.current||lt.current?.()},[]);if(d)return s.jsx("aside",{ref:Se,"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",{...We(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:yP,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:Te,"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:oe=>{ib(oe)||H.onClickCapture?.(oe)},ref:Se,"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(${xe.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})]})}),AP={activeKey:"root",items:[]},TP=()=>()=>{},SP=()=>AP;function CP(e){const t=Bo(),r=b.useSyncExternalStore(t?.subscribe??TP,t?.snapshot??SP),n=Lw(),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 _P({groups:e,currentKey:t,onClose:r}){const{t:n}=zr(),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],W=R[R.length-1],F=!c.current?.contains(document.activeElement);E.shiftKey&&(document.activeElement===B||F)?(E.preventDefault(),W?.focus()):!E.shiftKey&&(document.activeElement===W||F)&&(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=Bo(),R=E?.snapshot().items.find(W=>W.key===S.key);if(!R?.reviewCount||L&&!R.attentionSessions?.some(W=>W.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(Rn,{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(fi,{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 kP(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 LP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function IP(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 EP(e,t,r="next"){return IP(e,t,LP,r)}const $a=42,Rf=20,NP=10;function S1(e,t,r){return Math.min(r,Math.max(t,e))}function ep(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+Rf,d=Math.max(l,e.width-r-Rf-$a),p=Math.max(t+12,52),m=Math.max(p,e.height-n-c-$a);return{minX:l,maxX:d,minY:p,maxY:m}}function ab(e,t){const r=ep(e),n=S1(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=ep(e);return{x:S1(t.x,r.minX,r.maxX),y:S1(t.y,r.minY,r.maxY)}}function ob(e,t){const r=ep(e),n=Hc(e,t),a=(r.minX+r.maxX+$a)/2,c=n.x+$a/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 lb(e,t,r){const n=Hc(e,t),a=$a+NP,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=ep(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 ym="var(--warning)",RP="var(--success)",cb="var(--tmux)",ub="termdock:mobile-attention-position:v1",db="termdock:running-session-position:v1",MP={side:"right",yRatio:.68},jP={side:"right",yRatio:.54};function hb(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 DP(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Sh(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 BP(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(Sh("--safe-top-inset"),(d?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(Sh("--safe-right-inset"),(d?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(Sh("--safe-bottom-inset"),(d?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(Sh("--safe-left-inset"),(d?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?Rf:72}}function R6(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=EP(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 fb(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function M6(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 QP({indicator:e,tone:t,size:r}){const n=M6(t);switch(e){case"spinner":return s.jsx(Cn,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(af,{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(Fo,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(UA,{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=kP(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(E0,{size:r,className:"text-white"})})}function PP({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Wc,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(Uu,{size:r,className:"shrink-0"}):s.jsx(Fo,{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(QP,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(Cn,{size:r,className:"shrink-0 animate-spin",style:{color:RP}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(af,{size:r,className:"shrink-0 animate-bounce-y",style:{color:ym}})}):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:ym}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:ym}})}):t?.inCopyMode?e==="tmux"?s.jsx(Uu,{size:r,className:"shrink-0 animate-pulse",style:{color:cb}}):s.jsx(Fo,{size:r,className:"shrink-0 animate-pulse",style:{color:cb}}):n}function OP({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=zr();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:M6(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 j6({count:e,tone:t,title:r}){const{t:n}=zr();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:R6,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 FP({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 $P=380,pb=10,Ch=10,vm=52,UP=104;function zP(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=Rf,p=e.x+$a/2>=n+(a-n)/2,m=p?e.x-Ch-n-d:a-d-e.x-$a-Ch,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*UP))),y=p?e.x-Ch-x:e.x+$a+Ch,w=Math.min(Math.max(y,n+d),Math.max(n+d,a-d-x)),v=e.y+$a/2-vm/2,S=Math.min(Math.max(v,c+d),Math.max(c+d,l-d-vm));return{left:w,top:S,width:x,height:vm,itemWidth:x/Math.max(1,r),side:p?"left":"right"}}function mb(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 HP(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 WP({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:d}){const{t:p}=zr(),m=Gt(Ie=>Ie.leftOpen),x=Gt(Ie=>Ie.rightOpen),{isOpen:y}=K3({enabled:!c}),w=c||!m&&!x&&!y,v=CP(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,W=Math.max(0,d?.top??0),F=Math.max(0,d?.right??0),U=Math.max(0,d?.bottom??0),V=Math.max(0,d?.left??0),Z=k.useCallback(()=>BP(c,l,{top:W,right:F,bottom:U,left:V}),[l,c,U,V,F,W]),ce=k.useRef({attention:hb(ub,MP),running:hb(db,jP)}),xe=k.useCallback(()=>{const Ie=Z(),We=ab(Ie,ce.current.attention),Te=ab(Ie,ce.current.running);return{attention:We,running:E&&B?lb(Ie,Te,We):Te}},[E,Z,B]),[pe,te]=k.useState(()=>xe()),ke=k.useRef(pe);ke.current=pe;const[$e,Y]=k.useState(null),Ae=k.useRef(null),[lt,Se]=k.useState("idle"),[ye,_e]=k.useState(null),je=k.useRef(null),re=k.useRef({attention:!1,running:!1});k.useEffect(()=>()=>{const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie)},[]),k.useEffect(()=>{if(B)return;const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie),je.current=null,Se("idle"),_e(null)},[B]),k.useLayoutEffect(()=>{const Ie=()=>{const Te=xe();ke.current=Te,te(Te)};Ie(),window.addEventListener("resize",Ie),window.addEventListener("orientationchange",Ie),window.visualViewport?.addEventListener("resize",Ie);const We=typeof ResizeObserver>"u"?null:new ResizeObserver(Ie);return l&&We?.observe(l),()=>{window.removeEventListener("resize",Ie),window.removeEventListener("orientationchange",Ie),window.visualViewport?.removeEventListener("resize",Ie),We?.disconnect()}},[l,xe]);const Oe=k.useCallback(Ie=>Ie==="attention"?B:E,[E,B]),Ce=k.useCallback((Ie,We)=>{if(!Oe(Ie))return We;const Te=Ie==="attention"?"running":"attention";return lb(Z(),We,ke.current[Te])},[Z,Oe]),Ee=k.useCallback((Ie,We,Te,H)=>{const oe=Z(),be=We.moved?Hc(oe,{x:We.startX+(Te-We.originX),y:We.startY+(H-We.originY)}):ke.current[Ie],Ze=ob(oe,be),Je=Ce(Ie,Ze.position),St=ob(oe,Je);ce.current[Ie]=St.preference,DP(Ie==="attention"?ub:db,St.preference);const Vt={...ke.current,[Ie]:St.position};ke.current=Vt,te(Vt)},[Ce,Z]),Be=k.useCallback(Ie=>{re.current[Ie]=!0,window.setTimeout(()=>{re.current[Ie]=!1},0)},[]),Ne=k.useCallback(Ie=>{const We=Ae.current;!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId||(Ae.current=null,Y(null),Ee("attention",We,Ie.clientX,Ie.clientY),We.moved&&Be("attention"))},[Ee,Be]),le={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId),Ae.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 We=Ae.current;if(!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0,Y("attention");const oe=Z(),be=Ce("attention",Hc(oe,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,attention:be};ke.current=Ze,te(Ze)},onPointerUp:Ne,onPointerCancel:Ne},He=l?zP(pe.running,Z(),t.length):null,rt=Ie=>{Ie.longPressTimer!==null&&(window.clearTimeout(Ie.longPressTimer),Ie.longPressTimer=null)},mt={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId);const We=Ie.pointerId,Te={pointerId:We,originX:Ie.clientX,originY:Ie.clientY,startX:pe.running.x,startY:pe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};Te.longPressTimer=window.setTimeout(()=>{const H=je.current;!H||H.pointerId!==We||H.mode!=="pressing"||(H.longPressTimer=null,H.mode="dragging",re.current.running=!0,Se("dragging"))},$P),je.current=Te,Se("pressing"),_e(null)},onPointerMove:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(We.mode==="pressing")if(Math.abs(Te)>=pb&&Math.abs(Te)>=Math.abs(H))rt(We),We.mode="selecting",re.current.running=!0,Se("selecting");else if(Math.hypot(Te,H)>=pb){rt(We),We.mode="cancelled",re.current.running=!0,Se("idle");return}else return;if(We.mode==="selecting"){const Je=He?mb(He,Ie.clientX,Ie.clientY,t.length):null;We.selectedIndex=Je,_e(Je);return}if(We.mode!=="dragging"||!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0;const oe=Z(),be=Ce("running",Hc(oe,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,running:be};ke.current=Ze,te(Ze)},onPointerUp:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;rt(We);const Te=We.mode;if(Te==="selecting"){const H=He?mb(He,Ie.clientX,Ie.clientY,t.length):We.selectedIndex,oe=H===null?null:t[H]?.id;oe&&fb(oe)}else Te==="dragging"&&Ee("running",We,Ie.clientX,Ie.clientY);je.current=null,Se("idle"),_e(null),Te!=="pressing"&&Be("running")},onPointerCancel:Ie=>{const We=je.current;!We||We.pointerId!==Ie.pointerId||(rt(We),je.current=null,Se("idle"),_e(null),Be("running"))}},ue=(Ie,We)=>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)] ${We==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Ie>9?"9+":Ie}),Ye=()=>{const Ie=v.hasOtherAttention?p("serviceAttention.title"):p("agent.jumpToNext"),We=pe.attention,Te=$e==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...le,onClick:H=>{H.stopPropagation(),!re.current.attention&&(v.hasOtherAttention?L(!0):R6())},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 ${Te?"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:We.x,top:We.y,width:$a,height:$a,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")},st=()=>{const Ie=t.length,We=pe.running,Te=lt==="selecting",H=lt==="dragging";return s.jsxs(k.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":lt,...mt,onClick:oe=>{if(oe.stopPropagation(),re.current.running)return;const be=HP(t,r);be&&fb(be)},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)]":Te?"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:We.x,top:We.y,width:$a,height:$a,touchAction:"none"},"aria-label":`${p("agent.jumpToNextRunning")}: ${Ie}`,title:p("agent.runningSessionGestureHint"),children:[s.jsx(Cn,{size:18,className:"shrink-0 animate-spin"}),ue(Ie,"running")]}),Te&&He&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":He.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:He.left,top:He.top,width:He.width,height:He.height},children:t.map((oe,be)=>{const Ze=be===ye,Je=oe.id===r,St=`${oe.label}${oe.detail?` · ${oe.detail}`:""}${Je?` · ${p("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":Ze,"data-running-session-option":oe.id,"data-selected":Ze?"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 ${Ze?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":Je?"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 ${Ze?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:be+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:oe.label})]},oe.id)})})]},"running")};return!E&&!B&&!S||l===null||typeof document>"u"?null:s.jsxs(Iw,{children:[E&&Ye(),B&&!S&&st(),S&&v.active&&w&&s.jsx(_P,{groups:v.groups,currentKey:v.currentKey,onClose:()=>L(!1)})]})}function GP(){const{t:e}=zr();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 VP=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"]),gb=120,xb=120,qP=new Set,YP=[],ZP={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 Cg(e,t){if(t==="directory")return null;if(Rw(e))return s.jsx(RA,{size:14});if(Mw(e))return s.jsx(Fy,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return VP.has(r)?s.jsx(iT,{size:14}):s.jsx(Ry,{size:14})}function D6({path:e}){const r=Gt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=ZP[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 qu(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 _g(e){return qu(e)}const KP=b.memo(function({path:t}){const{t:r}=zr(),[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 wy(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 ${qu(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(Cn,{size:12,className:"animate-spin"}):s.jsx(f0,{size:12})})});function B6(){const{t:e}=zr(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await wy(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 C1(e){return e instanceof DOMException&&e.name==="AbortError"}function Mf(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function Q6(e){return e.button===2||e.ctrlKey}const XP=176,JP=160,jd=8;function bb(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+jd,x=l+jd,y=Math.max(m,d-r-jd),w=Math.max(x,p-n-jd),v=t+n<=p-jd?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 P6(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(bb(c,l,XP,JP))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=bb(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 O6(e,t){return t&&typeof document<"u"?Ii.createPortal(e,document.body):e}function eO(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function kg(e,t,r){if(!t||eO(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>kg(a,t,r)):!1}function _1(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 k1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const tO=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:W,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,revealedDirectoryPath:Z,gitIgnoreRoot:ce}){const{t:xe}=zr(),pe=Gt(bt=>bt.expandedPaths.has(t.path)),te=Gt(bt=>bt.directoryCache.get(t.path)),ke=Gt(bt=>bt.showHiddenFiles),$e=Gt(bt=>bt.toggleExpanded),Y=Gt(bt=>bt.setDirectoryCache),Ae=Gt(bt=>bt.fileSortModes[t.path]??"name"),lt=Gt(bt=>bt.setDirectorySortMode),[Se,ye]=b.useState(!1),[_e,je]=b.useState(!1),{position:re,menuRef:Oe,openAt:Ce,clearPosition:Ee}=P6(_e),[Be,Ne]=b.useState(!1),le=b.useRef(0),He=b.useRef(null),rt=`file-tree-reference:${b.useId()}:${t.path}`;I0(Oe,_e&&!!l,()=>je(!1));const mt=b.useRef(null),ue=t.path===B||t.path===Z,Ye=t.type==="directory"&&(pe||!!W),st=t.type==="directory",Ie=R.has(t.path),We=!st&&!!S,Te=!!(E&&L),H=`path:${t.path}`,oe=m===H||!!l?.paths.has(t.path),be=x===H,Ze=d?.(t.path)??t.path,Je=P1(p,!!l),{state:St,run:Vt}=B6(),jt=V===t.path,vt=st&&!a&&!!(y||w||v||Te),Zt=b.useMemo(()=>{if(!te)return;if(!W)return te;const bt=Gt.getState().directoryCache;return te.filter(It=>(!a||It.type==="directory")&&kg(It,W,bt))},[te,a,W]),Pt=b.useCallback(async()=>{if(!Gt.getState().directoryCache.has(t.path)&&!Se){const It=l?rt:`file-tree:${t.path}`;He.current?.abort(),Om(It);const yt=new AbortController;He.current=yt,ye(!0);try{const pr=await j1(t.path,yt.signal,ke,"expand_directory",It,Ae,ce);if(yt.signal.aborted)return;const nr=_1(pr.entries);Y(t.path,nr)}catch(pr){C1(pr)}finally{He.current===yt&&(He.current=null),ye(!1)}}},[t.path,Se,Y,ke,Ae,ce,!!l,rt]),Xt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const bt=!Gt.getState().expandedPaths.has(t.path);$e(t.path),bt&&await Pt()},[a,t.path,t.type,Pt,y,$e,n]);b.useEffect(()=>{t.type==="directory"&&pe&&!te&&!Se&&Pt()},[te,pe,Pt,Se,t.type]);const zt=b.useCallback(bt=>{bt.stopPropagation(),c?.(t.path,H)},[c,t.path,H]),Lt=b.useCallback(bt=>{bt.stopPropagation(),y?.(t.path),je(!1)},[t.path,y]),me=b.useCallback(bt=>{bt.stopPropagation(),w?.(t.path),je(!1)},[t.path,w]),Ge=b.useCallback(bt=>{bt.stopPropagation(),v?.(t.path),je(!1)},[t.path,v]),pt=b.useCallback(bt=>{bt.stopPropagation(),lt(t.path,Ae==="modified"?"name":"modified"),je(!1)},[t.path,lt,Ae]),q=b.useCallback(bt=>{bt.stopPropagation(),S?.(t.path),je(!1)},[t.path,S]),at=b.useCallback(bt=>{bt.stopPropagation(),je(!1),Vt(t.path)},[t.path,Vt]),qt=b.useCallback(bt=>{bt.stopPropagation(),je(!1),U(t)},[t,U]),Ve=b.useCallback(bt=>{bt.stopPropagation(),L?.(t.path),je(!1)},[t.path,L]),De=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),le.current+=1,Ne(!0))},[st,F]),er=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),bt.dataTransfer.dropEffect="copy",Ne(!0))},[st,F]),et=b.useCallback(bt=>{!st||!F||(bt.preventDefault(),bt.stopPropagation(),le.current-=1,le.current<=0&&(le.current=0,Ne(!1)))},[st,F]),Ct=b.useCallback(bt=>{if(!st||!F)return;bt.preventDefault(),bt.stopPropagation(),le.current=0,Ne(!1);const It=Array.from(bt.dataTransfer.files);It.length>0&&F(t.path,It)},[st,t.path,F]),Nt=b.useCallback(bt=>{bt.stopPropagation(),l?Ce(bt.clientX,bt.clientY):Ee(),je(It=>!It)},[Ee,Ce,!!l]),gt=b.useCallback(bt=>{!vt||!Q6(bt)||(bt.preventDefault(),bt.stopPropagation(),Ce(bt.clientX,bt.clientY),je(!0))},[vt,Ce]);return b.useEffect(()=>{if(!_e)return;const bt=yt=>{const pr=yt.target;pr instanceof Node&&(mt.current?.contains(pr)||Oe.current?.contains(pr))||je(!1)},It=yt=>{yt.key==="Escape"&&je(!1)};return document.addEventListener("pointerdown",bt),document.addEventListener("keydown",It),()=>{document.removeEventListener("pointerdown",bt),document.removeEventListener("keydown",It)}},[_e,Oe]),b.useEffect(()=>()=>{He.current?.abort()},[]),s.jsxs("div",{style:!Ye&&!_e?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:mt,className:"relative",children:[Je.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":Ae,role:"button",tabIndex:0,onClick:()=>{Mf()||Xt()},onContextMenu:gt,onKeyDown:bt=>{bt.target!==bt.currentTarget||bt.key!=="Enter"&&bt.key!==" "||(bt.preventDefault(),Xt())},onDragEnter:De,onDragOver:er,onDragLeave:et,onDrop:Ct,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Be?"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`}}),Be&&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:xe("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Ye?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(fi,{size:14,className:"shrink-0 text-muted-foreground/80"}),Ye?s.jsx(Ru,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(Gc,{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:Cg(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${ue?"font-medium":""}`,children:[t.name,Ae==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:xe("fileTree.sortedByModified"),"aria-label":xe("fileTree.sortedByModified"),children:s.jsx(h0,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:xe("fileTree.symbolicLink"),children:s.jsx(Ou,{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:bt=>bt.stopPropagation(),children:[Se&&s.jsx(Cn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(D6,{path:t.path}),vt&&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 ${qu(_e)} ${_e?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreDirActions"),"aria-expanded":_e,title:xe("fileTree.moreDirActions"),children:s.jsx($o,{size:13})}),!st&&!l&&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 ${qu(_e||St.status==="pending"||jt||Ie)} ${_e?"bg-surface-elevated text-foreground":Ie?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreFileActions"),"aria-expanded":_e,title:St.status==="error"?St.message??xe("rightSidebar.downloadFailed"):xe("fileTree.moreFileActions"),children:St.status==="pending"||jt?s.jsx(Cn,{size:13,className:"animate-spin"}):s.jsx($o,{size:13})}),c&&s.jsx("button",{type:"button",onClick:zt,...Je(Ze,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":_g(oe||be)} ${oe||be?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":oe?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?oe:void 0,disabled:!!l?.disabled&&!oe,title:l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":oe?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:be||oe?s.jsx(hi,{size:12}):s.jsx(Ou,{size:12})}),vt&&_e&&O6(s.jsxs("div",{ref:Oe,className:`${re?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:re?{left:re.left,top:re.top}:void 0,children:[Te&&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 text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(Ru,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:Lt,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:xe("fileTree.openDirRootTitle"),children:[s.jsx(Ru,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openDirRoot")})]}),w&&s.jsxs("button",{type:"button",onClick:me,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:xe("fileTree.searchFromDirTitle"),children:[s.jsx(O1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Ge,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:xe(Ie?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ie?s.jsx(m0,{size:13,className:"shrink-0"}):s.jsx(p0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:pt,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:[Ae==="modified"?s.jsx(CA,{size:13,className:"shrink-0"}):s.jsx(h0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ae==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!re),!st&&!l&&_e&&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:[Te&&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 text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(Ry,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:at,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:xe("rightSidebar.downloadFile"),children:[s.jsx(f0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("rightSidebar.downloadFile")})]}),We&&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:xe(Ie?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ie?s.jsx(m0,{size:13,className:"shrink-0"}):s.jsx(p0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:qt,disabled:jt,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:xe("fileTree.deleteFile"),children:[jt?s.jsx(Cn,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.deleteFile")})]})]})]})]})]}),Ye&&Zt&&Zt.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:Zt.map(bt=>s.jsx(e,{node:bt,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:W,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,gitIgnoreRoot:ce,revealedDirectoryPath:Z},bt.path))})]})}),rO=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}=zr(),W=t.path===L,F=t.type==="directory",U=S.has(t.path),V=!F&&!!v,Z=`path:${t.path}`,ce=p===Z||!!c?.paths.has(t.path),xe=m===Z,pe=l?.(t.path)??t.path,te=P1(d,!!c),{state:ke,run:$e}=B6(),[Y,Ae]=b.useState(!1),{position:lt,menuRef:Se,openAt:ye,clearPosition:_e}=P6(Y);I0(Se,Y&&!!c,()=>Ae(!1));const je=b.useRef(null),re=R===t.path,Oe=F&&!!(x||y||w),Ce=b.useCallback(()=>{Mf()||(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]),Be=b.useCallback(ue=>{ue.stopPropagation(),w?.(t.path),Ae(!1)},[t.path,w]),Ne=b.useCallback(ue=>{ue.stopPropagation(),v?.(t.path),Ae(!1)},[t.path,v]),le=b.useCallback(ue=>{ue.stopPropagation(),Ae(!1),$e(t.path)},[t.path,$e]),He=b.useCallback(ue=>{ue.stopPropagation(),Ae(!1),E(t)},[t,E]),rt=b.useCallback(ue=>{ue.stopPropagation(),c?ye(ue.clientX,ue.clientY):_e(),Ae(Ye=>!Ye)},[_e,ye,!!c]),mt=b.useCallback(ue=>{!Oe||!Q6(ue)||(ue.preventDefault(),ue.stopPropagation(),ye(ue.clientX,ue.clientY),Ae(!0))},[Oe,ye]);return b.useEffect(()=>{if(!Y)return;const ue=st=>{const Ie=st.target;Ie instanceof Node&&(je.current?.contains(Ie)||Se.current?.contains(Ie))||Ae(!1)},Ye=st=>{st.key==="Escape"&&Ae(!1)};return document.addEventListener("pointerdown",ue),document.addEventListener("keydown",Ye),()=>{document.removeEventListener("pointerdown",ue),document.removeEventListener("keydown",Ye)}},[Y,Se]),s.jsxs("div",{ref:je,className:"relative border-b border-border/10 last:border-b-0",children:[te.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:Ce,onContextMenu:mt,onKeyDown:ue=>{ue.target!==ue.currentTarget||ue.key!=="Enter"&&ue.key!==" "||(ue.preventDefault(),Ce())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${W?"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(Gc,{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:W?"text-primary":"text-muted-foreground/80",children:Cg(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 ${W?"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(Ou,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:k1(r,t.path)})]}),s.jsx(D6,{path:t.path}),t.type==="directory"&&(w||y)&&s.jsx("button",{type:"button",onClick:rt,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 ${qu(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($o,{size:13})}),!F&&!c&&s.jsx("button",{type:"button",onClick:rt,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 ${qu(Y||ke.status==="pending"||re||U)} ${Y?"bg-surface-elevated text-foreground":U?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreFileActions"),"aria-expanded":Y,title:ke.status==="error"?ke.message??B("rightSidebar.downloadFailed"):B("fileTree.moreFileActions"),children:ke.status==="pending"||re?s.jsx(Cn,{size:13,className:"animate-spin"}):s.jsx($o,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Ee,...te(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":_g(ce||xe)} ${ce||xe?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":ce?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?ce:void 0,disabled:!!c?.disabled&&!ce,title:c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":ce?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:xe||ce?s.jsx(hi,{size:12}):s.jsx(Ou,{size:12})})]}),Oe&&Y&&O6(s.jsxs("div",{ref:Se,className:`${lt?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:lt?{left:lt.left,top:lt.top}:void 0,children:[x&&s.jsxs("button",{type:"button",onClick:ue=>{ue.stopPropagation(),x(t.path),Ae(!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(Ru,{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),Ae(!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(O1,{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:Be,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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[U?s.jsx(m0,{size:13,className:"shrink-0"}):s.jsx(p0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!lt),!F&&!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:le,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(f0,{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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[U?s.jsx(m0,{size:13,className:"shrink-0"}):s.jsx(p0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:He,disabled:re,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:[re?s.jsx(Cn,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.deleteFile")})]})]})]})}),nO=60,yb=60,sO=20;function vb({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=zr();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(O1,{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(Cn,{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 iO(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 aO=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}=zr(),[v,S]=b.useState(!0),L=t.path===n,E=v?t.matches.slice(0,sO):[],R=t.matches.length-E.length,B=`path:${t.path}`,W=x===B||!!d?.paths.has(t.path),F=y===B,U=p?.(t.path)??t.path,V=P1(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:()=>{Mf()||S(Z=>!Z)},onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),S(ce=>!ce))},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(fi,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:Cg(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:k1(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(KP,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),l(t.path,B)},...V(U,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":_g(W||F)} ${W||F?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":d?`${d.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":d?W:void 0,disabled:!!d?.disabled&&!W,title:d?`${d.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:F||W?s.jsx(hi,{size:12}):s.jsx(Ou,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[E.map((Z,ce)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Mf()||c?.(t.path,Z.line)},onKeyDown:xe=>{xe.target!==xe.currentTarget||xe.key!=="Enter"&&xe.key!==" "||(xe.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:`${k1(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:iO(Z.text,a)})]},`${Z.line}-${ce}`)),R>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:R})})]})]})});function oO({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=qP,selectedFilePath:E,query:R="",searchRootPath:B,searchOptions:W={},searchMode:F="name",onContentMatchSelect:U,onDirectoryDropFiles:V,revealDirectory:Z}){const{t:ce}=zr(),xe=b.useId(),pe=a?`file-tree-reference-root:${xe}:${e}`:`file-tree-root:${e}`,te=Gt(Ve=>e?Ve.directoryCache.get(e):void 0),ke=Gt(Ve=>Ve.setDirectoryCache),$e=Gt(Ve=>Ve.showHiddenFiles),Y=Gt(Ve=>Ve.fileSortModesHydrated),Ae=Gt(Ve=>Ve.fileSortModes[e]??"name"),lt=Gt(Ve=>Ve.hydrateFileSortModes),Se=Gt(Ve=>Ve.hydrateHideGitIgnoredRoots),ye=Gt(Ve=>!!Ve.hideGitIgnoredRoots[e]),_e=Gt(Ve=>Ve.hideGitIgnoredRootsHydrated),je=Gt(Ve=>JSON.stringify(Ve.gitIgnoreExceptions[e]??[])),re=Gt(Ve=>Ve.invalidateDirectoryCache),Oe=`${e}:${ye}:${je}`,[Ce,Ee]=b.useState("");b.useLayoutEffect(()=>{e&&re(e,!0),Ee(Oe)},[e,ye,je,re,Oe]);const[Be,Ne]=b.useState(!1),[le,He]=b.useState(null),[rt,mt]=b.useState(!1),[ue,Ye]=b.useState(!1),[st,Ie]=b.useState(null),[We,Te]=b.useState(Y&&_e),H=Y&&_e||We;b.useEffect(()=>{let Ve=!1;return Promise.all([lt(),Se()]).catch(()=>{}).finally(()=>{Ve||Te(!0)}),()=>{Ve=!0}},[lt,Se]);const[oe,be]=b.useState([]),[Ze,Je]=b.useState(null),[St,Vt]=b.useState(gb),[jt,vt]=b.useState([]),[Zt,Pt]=b.useState(null),Xt=b.useRef(null),zt=b.useRef(0),Lt=R.trim().toLowerCase(),me=F==="content",Ge=B||e,pt=W.excludePatterns??YP,q=pt.join(`
|
|
137
|
-
`);b.useEffect(()=>{const Ve=Z?.path;if(!Ve||!Ve.startsWith(`${e}/`)&&Ve!==e)return;const De=Ve.slice(e.length).replace(/^\/+/,""),er=De?De.split("/"):[],et=er.map((pr,nr)=>`${e}/${er.slice(0,nr+1).join("/")}`),Ct=Gt.getState(),Nt=et.filter(pr=>!Ct.expandedPaths.has(pr));Nt.length>0&&Gt.setState(pr=>({expandedPaths:new Set([...pr.expandedPaths,...Nt])}));let gt=!1,bt=0;const It=()=>{if(gt)return;const pr=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(nr=>nr.dataset.fileTreePath===Ve);if(pr){pr.scrollIntoView({block:"center",behavior:"smooth"});return}bt+=1,bt<80&&window.setTimeout(It,50)},yt=window.requestAnimationFrame(It);return()=>{gt=!0,window.cancelAnimationFrame(yt)}},[Z?.nonce,Z?.path,e]);const at=b.useCallback(async Ve=>{if(!(Zt||Ve.type==="directory")&&window.confirm(ce("fileTree.deleteFileConfirm",{name:Ve.name}))){Pt(Ve.path);try{await Ew(Ve.path),Gt.getState().applyFileWatchEvents([{type:"deleted",path:Ve.path}]),be(De=>De.filter(er=>er.path!==Ve.path)),vt(De=>De.filter(er=>er.path!==Ve.path)),L.has(Ve.path)&&w?.(Ve.path)}catch(De){const er=De instanceof Error?De.message:String(De);window.alert(ce("fileTree.deleteFileFailed",{message:er}))}finally{Pt(null)}}},[Zt,w,L,ce]);b.useEffect(()=>{if(!e||!H||Ce!==Oe)return;if(Lt){Ne(!1);return}if(Gt.getState().directoryCache.has(e)){Ne(!1);return}let Ve=!1;const De=new AbortController;return Ne(!0),He(null),j1(e,De.signal,$e,"load_file_tree_root",pe,Ae,e).then(er=>{if(Ve)return;const et=_1(er.entries);mt(!!er.truncated),ke(e,et)}).catch(er=>{Ve||C1(er)||He(er instanceof Error?er.message:"Failed to load directory")}).finally(()=>{Ve||Ne(!1)}),()=>{Ve=!0,De.abort(),Om(pe)}},[Lt,te,e,Ae,ke,$e,H,ye,je,pe,Ce,Oe]),b.useEffect(()=>{if(!Ge||!Lt){Ye(!1),Ie(null),be([]),vt([]),Je(null);return}let Ve=!1;const De=new AbortController,er=new Set;Ye(!0),Ie(null),be([]),vt([]),Vt(me?nO:gb),Je({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const et=`file-search:${a?xe+":":""}${Ge}:${++zt.current}`;return Nw(Ge,R.trim(),Ct=>{if(!Ve){if(Ct.engine&&Je(Nt=>({truncated:Nt?.truncated??!1,total:Nt?.total??0,engine:Ct.engine,limited:Ct.limited??Nt?.limited??!1,done:Nt?.done??!1})),Ct.entries?.length){const Nt=Ct.entries.filter(gt=>er.has(gt.path)?!1:(er.add(gt.path),!0));Nt.length>0&&(be(gt=>[...gt,..._1(Nt)]),Je(gt=>gt?{...gt,total:er.size}:{truncated:!1,total:er.size,engine:"rg",limited:!1,done:!1}))}if(Ct.contentEntries?.length){const Nt=Ct.contentEntries.filter(gt=>er.has(gt.path)?!1:(er.add(gt.path),!0));Nt.length>0&&(vt(gt=>[...gt,...Nt]),Je(gt=>gt?{...gt,total:er.size}:{truncated:!1,total:er.size,engine:"rg",limited:!1,done:!1}))}Ct.done&&Je(Nt=>({truncated:!!Ct.truncated,total:typeof Ct.total=="number"?Ct.total:er.size,engine:Ct.engine??Nt?.engine??"rg",limited:!!Ct.limited,done:!0}))}},De.signal,$e,F,et,{excludePatterns:pt,caseSensitive:W.caseSensitive,wholeWord:W.wholeWord,regex:W.regex}).catch(Ct=>{Ve||C1(Ct)||(Ie(Ct instanceof Error?Ct.message:"Failed to search files"),be([]),vt([]),Je(null))}).finally(()=>{Ve||Ye(!1)}),()=>{Ve=!0,De.abort(),Om(et)}},[Ge,q,me,R,Lt,F,W.caseSensitive,W.regex,W.wholeWord,$e,!!a,xe]),b.useEffect(()=>{if(!Lt)return;const Ve=Xt.current;if(!Ve)return;const De=me?jt.length:oe.length,er=me?yb:xb,et=new IntersectionObserver(Ct=>{Ct.some(Nt=>Nt.isIntersecting)&&Vt(Nt=>Math.min(Nt+er,De))},{rootMargin:"160px 0px"});return et.observe(Ve),()=>et.disconnect()},[Lt,oe.length,jt.length,me]);const qt=b.useMemo(()=>{if(!te)return;if(!Lt)return r?te.filter(De=>De.type==="directory"):te;const Ve=Gt.getState().directoryCache;return te.filter(De=>(!r||De.type==="directory")&&kg(De,Lt,Ve))},[r,Lt,te]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:ce("fileTree.noWorkingDir")});if(Be||!H)return s.jsx(GP,{});if(Lt&&me){const Ve=Ze?.total??jt.length,De=jt.slice(0,St),er=St<jt.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(vb,{count:Ve,loading:ue,engine:Ze?.engine,limited:Ze?.limited,scope:Ge,content:!0}),st?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:[ce("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:st})]}):ue&&jt.length===0?s.jsx(d0,{label:ce("fileTree.searching"),className:"py-8"}):jt.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:ce("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[Ze?.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:ce("fileTree.searchTruncatedHint",{count:Ze.total})}),De.map(et=>s.jsx(aO,{entry:et,rootPath:Ge,selectedFilePath:E,query:R.trim(),onContentMatchSelect:U,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:p},et.path)),s.jsx("div",{ref:Xt,className:"py-2 text-center text-[11px] text-muted-foreground",children:er?s.jsx("button",{type:"button",onClick:()=>Vt(et=>Math.min(et+yb,jt.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:ce("fileTree.loadMoreSearchResults",{shown:De.length,total:jt.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Cn,{size:10,className:"animate-spin"}),ce("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:ce("fileTree.showingSearchResults",{shown:De.length,total:Ve})}):null})]})]})}if(Lt){const Ve=Ze?.total??oe.length,De=oe.slice(0,St),er=St<oe.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(vb,{count:Ve,loading:ue,engine:Ze?.engine,limited:Ze?.limited,scope:Ge,content:!1}),ue&&oe.length===0?s.jsx(d0,{label:ce("fileTree.searching"),className:"py-8"}):st?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:st}):oe.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:ce("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[Ze?.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:ce("fileTree.searchTruncatedHint",{count:Ze.total})}),De.map(et=>s.jsx(rO,{node:et,rootPath:Ge,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:at,deletingFilePath:Zt},et.path)),s.jsx("div",{ref:Xt,className:"py-2 text-center text-[11px] text-muted-foreground",children:er?s.jsx("button",{type:"button",onClick:()=>Vt(et=>Math.min(et+xb,oe.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:ce("fileTree.loadMoreSearchResults",{shown:De.length,total:oe.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Cn,{size:10,className:"animate-spin"}),ce("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:ce("fileTree.showingSearchResults",{shown:De.length,total:Ve})}):null})]})]})}return le?s.jsx("div",{role:a?"alert":void 0,className:"px-4 py-4 text-sm text-destructive",children:le}):!te||te.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:ce("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:ce("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[rt&&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:ce("fileTree.truncatedHint")}),qt.map(Ve=>s.jsx(tO,{node:Ve,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:Lt,insertedReferenceKey:d,copiedReferenceKey:p,onDirectoryDropFiles:V,onFileDeleteRequest:at,deletingFilePath:Zt,revealedDirectoryPath:Z?.path},Ve.path))]})}function L1(e){return e.trim().replace(/\/+$/,"")||"/"}function lO(e){const t=L1(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function tp({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:c}){const{t:l}=zr(),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);I0(p,e,a);const[m,x]=b.useState(()=>L1(t));return b.useEffect(()=>{e&&x(L1(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?Ii.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(hT,{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(Rn,{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(lO(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(Iy,{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(oO,{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(hi,{size:13}),d.confirm]})]})]})]}),document.body):null}const cO=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:tp},Symbol.toStringTag,{value:"Module"})),I1="termdock:new-session-commands:v1",ic="__saved_command__:";function _h(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(ic)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function Dd(){try{const e=JSON.parse(localStorage.getItem(I1)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function uO({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:W=!1,launchError:F}){const{t:U,locale:V}=zr(),Z=b.useRef(null);I0(Z,!0,L,()=>document.querySelector('[aria-controls="sidebar-launch-options"]'));const[ce,xe]=b.useState(a),[pe,te]=b.useState(!1),[ke,$e]=b.useState(!1),[Y,Ae]=b.useState(Dd),[lt,Se]=b.useState(()=>_h(Dd())),[ye,_e]=b.useState(null),[je,re]=b.useState("idle"),Oe=ke?"__custom__":ce?.slug??"__terminal__",Ce=ce?.command??"",Ee=ke?Y.__custom__??Y.__terminal__??"":ce?Y[Oe]??Ce:"",Be=()=>{const Te=Ee.trim()||Ce;if(!(ke&&!Te))try{const H={...Dd(),[Oe]:Te};if(ke){for(const oe of _h(Dd()))H[ic+oe]=oe;H[ic+Te]=Te}localStorage.setItem(I1,JSON.stringify(H)),Se(_h(H)),ke&&_e(Te),re("saved")}catch{re("error")}},Ne=()=>{if(ye)try{const Te=Dd();for(const[H,oe]of Object.entries(Te))(H.startsWith(ic)||H==="__custom__"||H==="__terminal__")&&oe.trim()===ye&&delete Te[H];localStorage.setItem(I1,JSON.stringify(Te)),Se(_h(Te)),Ae(H=>({...H,__custom__:""})),_e(null),re("idle")}catch{re("error")}},le=()=>{const Te=Ee.trim()||Ce;W||ke&&!Te||(Be(),w(ce,Te))},He=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),rt=ke?ye?ic+ye:"__custom__":ce?.slug??"__terminal__",mt=Te=>{re("idle");const H=Te.startsWith(ic)?Te.slice(ic.length):null;_e(H),$e(Te==="__custom__"||H!==null),(H!==null||Te==="__custom__")&&Ae(oe=>({...oe,__custom__:H??""})),xe(n.find(oe=>oe.slug===Te)??null)},ue=ke?ye??U("sidebar.customStartupCommand"):ce?.displayName??"Terminal",Ye=a?.displayName??"Terminal",st=!ke&&(ce===null?a===null:a?.slug===ce.slug);b.useEffect(()=>{if(pe)return;const Te=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",Te,!0),()=>document.removeEventListener("pointerdown",Te,!0)},[pe,L]);const Ie=Te=>{E({...r,cwd:Te}),te(!1)},We=Te=>new Intl.DateTimeFormat(V==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(Te));return s.jsxs("section",{ref:Z,tabIndex:-1,"aria-busy":W,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":U("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(Fo,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:U("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":U("common.close"),children:s.jsx(Rn,{size:14})})]}),s.jsxs("fieldset",{disabled:W,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:U("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(Te=>s.jsx("button",{type:"button",disabled:Te==="tmux"&&!t,onClick:()=>E({...r,mode:Te}),"aria-pressed":r.mode===Te,title:Te==="tmux"?U(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===Te?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:U(Te==="shell"?"sidebar.newShell":"sidebar.newTmux")},Te))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:U("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:U("sidebar.detectAgents"),"aria-label":U("sidebar.detectAgents"),children:s.jsx(gn,{size:12,className:c?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":U("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(Te=>{const H=!ke&&ce?.slug===Te.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>mt(Te.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:Te,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:Te.displayName}),a?.slug===Te.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:U("sidebar.defaultAgent")})]},Te.slug)}),lt.map(Te=>{const H=ke&&ye===Te;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>mt(ic+Te),title:Te,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:Te})]},Te)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__terminal__",onClick:()=>mt("__terminal__"),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${rt==="__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(Fo,{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:U("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__custom__",onClick:()=>mt("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${rt==="__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(Us,{size:10,className:"shrink-0"}),s.jsx("span",{children:U("sidebar.addStartupCommand")})]})]}),!st&&!ke&&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:U("sidebar.currentDefaultAgent",{name:Ye})}),s.jsx("button",{type:"button",onClick:()=>y(ce),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:U("sidebar.makeDefault")})]}),je==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:U("sidebar.saveStartupCommandFailed")}),(ce||ke)&&s.jsxs("details",{open:ke&&!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:[U(ke&&!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:U("sidebar.startupCommand")}),ce&&Ee!==Ce&&s.jsx("button",{type:"button",onClick:()=>{Ae(Te=>({...Te,[Oe]:Ce})),re("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:U("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:Ee,onChange:Te=>{Ae(H=>({...H,[Oe]:Te.target.value})),re("idle")},placeholder:Ce||U("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:[ke&&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":U("sidebar.deleteStartupCommand"),children:[s.jsx(zs,{size:11}),U("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:Be,disabled:je==="saved"||ke&&!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:U(je==="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:U(ce?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},ye??Oe),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:U("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>te(!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(Gc,{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||U("sidebar.directoryPlaceholder")})]}),He.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":U("sidebar.recentDirectories"),children:He.map(Te=>s.jsx("button",{type:"button",onClick:()=>Ie(Te),title:Te,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:Yu(Te)||Te},Te))}),(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:U("sidebar.resumeHistory")}),d&&s.jsx(Cn,{size:10,className:"animate-spin"}),l.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:U("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(Te=>{const H=p===Te.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(Te),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":U("sidebar.resumeHistoryAction",{title:Te.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(Cn,{size:13,className:"animate-spin"}):s.jsx(Wc,{agent:Te.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:Te.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[Te.agent.displayName," · ",We(Te.closedAt)]})]}),s.jsx(Qy,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>S(Te.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":U("sidebar.resumeHistoryRemove",{title:Te.title}),children:[s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),s.jsx(zs,{size:12})]})]},Te.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:[F&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:F}),s.jsxs("button",{type:"button",onClick:le,disabled:W||ke&&!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":U("sidebar.launchSessionWith",{name:ue}),children:[W?s.jsx(Cn,{size:14}):ce?s.jsx(Wc,{agent:ce,size:15}):s.jsx(Fo,{size:14}),s.jsx("span",{className:"truncate",children:W?U("sidebar.sessionCreating"):U("sidebar.launchSessionWith",{name:ue})})]}),B]}),s.jsx(tp,{open:pe,initialPath:r.cwd?.trim()||He[0]||"/",title:U("sidebar.chooseDirectory"),onCancel:()=>te(!1),onConfirm:Ie})]})}const F6="termdock:new-session-agent:v1";function dO(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(F6)||"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 wm(e){if(!(typeof window>"u"))try{window.localStorage.setItem(F6,JSON.stringify(e))}catch{}}function hO(e,t){return e?t.find(r=>r.slug===e)??null:null}function fO(){const[e,t]=b.useState(dO),[r,n]=b.useState([]),[a,c]=b.useState(!0),l=b.useCallback(async()=>{c(!0);try{const[p,m]=await Promise.all([fc(),Ay()]),x=hO(p.newSessionAgentSlug,m);n(m),t(x),wm(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),wm(p);try{await ka({newSessionAgentSlug:p?.slug??null})}catch(x){throw t(m),wm(m),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:l,selectAgent:d}}function pO({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(Us,{size:14}),"新建协作组"]})]}),(e.length>5||l)&&s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"搜索协作组"}),s.jsx(Ml,{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=>ku(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(N0,{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(TT,{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(e0,{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",kh="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-xs disabled:opacity-40",Lh=e=>({profiles:e.launchProfiles??[],defaultId:e.defaultLaunchProfileId??"",group:e}),Am=new Map,Bd=e=>JSON.stringify(e.profiles)!==JSON.stringify(e.group.launchProfiles??[])||e.defaultId!==(e.group.defaultLaunchProfileId??"");function mO({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 gO({group:e,agents:t,busy:r,setBusy:n,refresh:a}){const c=`${window.location.origin}:${e.id}`,[l,d]=b.useState(()=>Am.get(c)??Lh(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=(U,V=!0)=>{p.current=U,d(U),Bd(U)?Am.set(c,U):Am.delete(c),V&&S("")};b.useEffect(()=>{!Bd(p.current)&&e.updatedAt>=p.current.group.updatedAt&&L(Lh(e),!1)},[e.updatedAt]);const E=l.profiles.find(U=>U.id===m),R=U=>L({...l,profiles:l.profiles.map(V=>V.id===m?{...V,...U}:V)}),B=l.profiles.every(U=>U.name.trim()&&U.agentSlug&&U.command.trim()&&!/[\x00-\x1f\x7f]/.test(U.command)),W=()=>{const U=t[0],V={id:`profile-${crypto.randomUUID()}`,name:"",agentSlug:U?.slug??"",command:U?.command??"",notes:""};L({...l,profiles:[...l.profiles,V]}),x(V.id)},F=async()=>{if(!(r||!B||!Bd(l))){n("launch-profiles"),w(null),S("");try{const{group:U}=await ac({id:e.id,name:l.group.name,sessionIds:l.group.sessionIds,expectedUpdatedAt:l.group.updatedAt,launchProfiles:l.profiles,defaultLaunchProfileId:l.defaultId||null});L(Lh(U)),S("启动方案已保存。新会话使用所选方案,正在运行的成员保持原配置。"),await a()}catch(U){w(U instanceof Error?U.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," 个",Bd(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:U=>L({...l,defaultId:U.target.value}),children:[s.jsx("option",{value:"",children:"使用 Agent 默认命令"}),l.profiles.map(U=>s.jsx("option",{value:U.id,children:U.name||"未命名方案"},U.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:U=>x(U.target.value),children:[s.jsx("option",{value:"",children:"选择方案"}),l.profiles.map(U=>s.jsx("option",{value:U.id,children:U.name||"未命名方案"},U.id))]})]}),s.jsxs("button",{type:"button",className:`${kh} self-end bg-surface text-foreground`,disabled:l.profiles.length>=20,onClick:W,children:[s.jsx(Us,{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:U=>R({name:U.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:U=>R({agentSlug:U.target.value,command:t.find(V=>V.slug===U.target.value)?.command??""}),children:[!t.some(U=>U.slug===E.agentSlug)&&s.jsxs("option",{value:E.agentSlug,children:[E.agentSlug||"选择 Agent","(当前不可用)"]}),t.map(U=>s.jsx("option",{value:U.slug,children:U.displayName},U.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:U=>R({command:U.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:U=>R({notes:U.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:`${kh} text-destructive hover:bg-destructive/10`,onClick:()=>{const U=l.profiles.filter(V=>V.id!==m);L({...l,profiles:U,defaultId:l.defaultId===m?"":l.defaultId}),x(U[0]?.id??"")},children:[s.jsx(zs,{size:14}),"移除方案(保存后生效)"]})]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:"尚未选择方案。新增后可填写模型、参数和备注。"})]}),y&&s.jsxs("p",{role:"alert",className:"text-xs leading-5 text-destructive",children:[y,"。草稿已保留;重新载入会放弃草稿。"]}),v&&s.jsx("p",{role:"status",className:"text-xs leading-5 text-primary",children:v}),s.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[s.jsx("button",{type:"button",className:`${kh} bg-surface text-muted-foreground`,disabled:!!r,onClick:()=>{L(Lh(e)),x(e.launchProfiles?.[0]?.id??""),w(null)},children:"重新载入(放弃方案草稿)"}),s.jsx("button",{type:"button",disabled:!!r||!B||!Bd(l),className:`${kh} bg-primary text-primary-foreground`,onClick:()=>{F()},children:r==="launch-profiles"?"保存中…":"保存启动方案"})]})]})]})}function xO(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 bO(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 wb(e){return new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function jf({task:e,now:t,compact:r=!1}){const n=x6(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:wb(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():bO(e.updatedAt,t),children:wb(e.updatedAt)})]}):"记录更新时间未提供"})]})}function $6(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 Xh({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,W]=b.useState(""),F=b.useRef(Promise.resolve());b.useEffect(()=>{const te=v.current;te&&te.setSelectionRange(te.value.length,te.value.length)},[e]);const U=()=>({value:L.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),V=(te,ke=U())=>{L.current.onChange($e=>$e!==ke.value?$e+($e&&!/\s$/.test($e)?`
|
|
138
|
-
`:"")+te:$e.slice(0,ke.start)+te+$e.slice(ke.end))};b.useEffect(()=>{if(!c)return;const te=Ty(ke=>V(ke.replace(/\r\n?/g,`
|
|
139
|
-
`)),e,!!t,t);return t||t0(e),te},[c,e,t]);const Z=()=>{const te=u0();return`${location.origin}:${te?.targetPeerId??""}:${te?.serviceOrigin??""}`},ce=te=>{const ke=U(),$e=Z(),Y=L.current.onUploadChange;W(""),R(Ae=>Ae+1),Y?.(1),F.current=F.current.then(async()=>{try{if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");const Ae=await te();if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(Ae)?V(Ae.map(Dc).join(" ")+" ",ke):Ae&&V(Ae,ke)}catch(Ae){const lt=Ae instanceof Error?Ae.message:"附件准备失败,请重试";W(lt.includes("Upload did not return")?"附件上传未返回完整路径,请重试":lt)}finally{R(Ae=>Ae-1),Y?.(-1)}})},xe=async te=>te.length===1&&te[0].type.startsWith("image/")?[await t3(te[0])]:s3(te),pe=te=>{const ke=te.clipboardData.files.length?Array.from(te.clipboardData.files):Array.from(te.clipboardData.items??[]).filter(Ae=>Ae.kind==="file").map(Ae=>Ae.getAsFile()).filter(Ae=>Ae!==null),$e=te.clipboardData.getData("text/plain"),Y=xo();!Y?.readClipboardFiles&&!ke.length&&$e||!Y&&!ke.length&&typeof navigator.clipboard?.read!="function"||(te.preventDefault(),ce(async()=>{const Ae=Z();let lt;if(Y?.readClipboardFiles)try{const Se=await n3();if(Se.paths.length||Se.files.length)return[...Se.paths,...await xe(Se.files)]}catch(Se){if(Se instanceof s0)throw Se;lt=Se}if(Ae!==Z())throw new Error("目标服务已切换,请重新粘贴");if(ke.length)return xe(ke);if($e)return $e;if(typeof navigator.clipboard?.read=="function"){const Se=await navigator.clipboard.read(),ye={read:async()=>Se},_e=await r3(ye);if(_e.length)return xe(_e);const je=await hf(ye);if(je)return xe([je]);for(const re of Se)if(re.types.includes("text/plain"))return(await re.getType("text/plain")).text()}else{const Se=await hf();if(Se)return xe([Se])}if(lt)throw lt;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>t0(e),onPointerDownCapture:()=>t0(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:te=>a(te.target.value),onPaste:pe,onDragOver:te=>{!l&&te.dataTransfer.types.includes("Files")&&te.preventDefault()},onDrop:te=>{const ke=Array.from(te.dataTransfer.files);!ke.length||l||(te.preventDefault(),te.stopPropagation(),ce(()=>xe(ke)))}}),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:te=>{const ke=Array.from(te.target.files??[]);te.target.value="",ke.length&&ce(()=>xe(ke))}}),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(VT,{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(gn,{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 Ab(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"&&!Fi(d)?p.find(y=>y.decisions.some(w=>w.status==="pending"))??p.find(y=>Fi(y)||y.workflow?.paused):void 0,x=p.filter(y=>Fi(y)||y.workflow?.paused).length;return{task:d,children:p,attention:m,attentionCount:x,rootId:l.get(d.id)}})}function U6(e,t=[]){const r=Yc(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!Fi(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function yO({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&&(Fi(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&&(Fi(x)||x.workflow?.paused),v=x?U6(x):y?m.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",S=y?Fu:$u;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(fi,{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 Tb(e){return e.status!=="open"?"done":Fi(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Sl=[{id:"backlog",label:"待开始",icon:$u,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:of,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:N0,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:Fu,hint:"验收后的结果会保留在这里"}];function vO({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(oe=>{const be=oe[0].contentRect.width;E(be>=760),be!==y.current&&be<760&&m.current&&(m.current.scrollLeft=Sl.findIndex(Ze=>Ze.id===x.current)*m.current.clientWidth),y.current=be});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,W]=b.useState(()=>{if(Sl.some(be=>be.id===R?.lane))return R.lane;const oe=Ab(e,R?.showSteps===!0,R?.query??"").map(be=>be.attention?"attention":Tb(be.task));return oe.includes("attention")?"attention":oe.includes("running")?"running":oe.includes("backlog")?"backlog":"done"});x.current=B;function F(H,oe=!0){W(H);const be=m.current;if(!be||!be.clientWidth)return;w.current=H;const Ze=Sl.findIndex(St=>St.id===H)*be.clientWidth,Je=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;be.scrollTo?be.scrollTo({left:Ze,behavior:oe&&!Je?"smooth":"auto"}):be.scrollLeft=Ze}b.useEffect(()=>{L||F(x.current,!1)},[L]);const[U,V]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[Z,ce]=b.useState(typeof R?.query=="string"?R.query:""),[xe,pe]=b.useState(R?.closed===!0),[te,ke]=b.useState(R?.showSteps===!0),[$e,Y]=b.useState(!!R?.query),[Ae,lt]=b.useState(!1),[Se,ye]=b.useState(!1),_e=b.useRef(null),je=b.useRef(null);b.useEffect(()=>{if(!Se)return;_e.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const H=be=>{_e.current?.contains(be.target)||ye(!1)},oe=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),ye(!1),je.current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",oe),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",oe)}},[Se]);const re=b.useRef(null),Oe=b.useRef(null),Ce=b.useRef(null),Ee=b.useRef(null);b.useEffect(()=>{$e&&re.current?.focus()},[$e]),b.useEffect(()=>{if(!Ae)return;Ce.current?.querySelector("select")?.focus();const H=be=>{Ce.current?.contains(be.target)||lt(!1)},oe=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),lt(!1),(L?Ee:je).current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",oe),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",oe)}},[Ae]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:B,scope:U,query:Z,closed:xe,showSteps:te}))}catch{}},[a,B,U,Z,xe,te]);const Be=e.filter(H=>H.workflow?.kind==="goal"),Ne=Ab(e,te,Z),le=new Map(Ne.map(H=>[H.task.id,H])),He=H=>le.get(H.id)?.attention?"attention":Tb(H),rt=t?Ne.find(H=>H.task.id===t||H.children.some(oe=>oe.id===t)):void 0,mt=rt?He(rt.task):void 0;b.useEffect(()=>{mt&&F(mt,!1)},[t,mt]);const ue=Ne.map(H=>H.task).filter(H=>(xe||H.status!=="closed")&&(U==="all"||H.id===U||le.get(H.id)?.rootId===U)&&(!Z.trim()||`${H.title} ${H.spec} ${H.attempts.map(oe=>n(H,oe.assignee)).join(" ")}`.toLocaleLowerCase().includes(Z.trim().toLocaleLowerCase()))),Ye=+(U!=="all")+Number(xe)+Number(te),st="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",We=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(Ml,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:re,"aria-label":"搜索任务",type:"search",value:Z,onChange:H=>ce(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),Z?ce(""):(Y(!1),requestAnimationFrame(()=>(L?Oe:je).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:()=>{ce(""),Y(!1),requestAnimationFrame(()=>(L?Oe:je).current?.focus())},children:s.jsx(Rn,{size:14})})]}),Te=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:U,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:"所有目标"}),Be.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:xe,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:te,onChange:H=>ke(H.target.checked)}),"显示执行子任务"]}),Ye>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),ke(!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:Ce,"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}),$e?We:s.jsx("button",{ref:Oe,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${st} ${l?"":"ml-auto"}`,onClick:()=>Y(!0),children:s.jsx(Ml,{size:16})}),s.jsxs("div",{ref:Ce,className:"relative shrink-0",children:[s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务","aria-expanded":Ae,className:`${st} ${Ye?"text-primary":""}`,onClick:()=>lt(H=>!H),children:[s.jsx($m,{size:15}),s.jsx("span",{children:"筛选"}),Ye>0&&s.jsx("span",{className:"tabular-nums text-primary",children:Ye})]}),Ae&&Te]}),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:_e,className:"relative shrink-0",children:[s.jsxs("button",{ref:je,type:"button","aria-label":"更多看板操作","aria-expanded":Se,className:`${st} ${Se?"bg-surface-2 text-foreground":Ye||Z.trim()?"text-primary":""}`,onClick:()=>{ye(H=>!H),lt(!1)},children:[s.jsx($o,{size:18}),Ye>0&&s.jsx("span",{className:"text-[10px]",children:Ye})]}),Se&&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:Oe,type:"button","aria-label":"搜索任务",className:Ie,onClick:()=>Y(!0),children:[s.jsx(Ml,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务",className:Ie,onClick:()=>lt(!0),children:[s.jsx($m,{size:18,className:"shrink-0 text-muted-foreground"}),"筛选任务",Ye>0&&s.jsx("span",{className:"ml-auto rounded bg-primary/10 px-1.5 text-xs tabular-nums text-primary",children:Ye})]}),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})]})]}),$e&&We,Ae&&Te]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:te?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),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:()=>F(H.id),children:[H.label,s.jsx("span",{className:"ml-1 tabular-nums",children:ue.filter(oe=>He(oe)===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 oe=w.current;if(oe){const Ze=Sl.findIndex(Je=>Je.id===oe)*H.currentTarget.clientWidth;if(Math.abs(H.currentTarget.scrollLeft-Ze)>2)return;w.current=null}const be=Math.max(0,Math.min(Sl.length-1,Math.round(H.currentTarget.scrollLeft/H.currentTarget.clientWidth)));W(Sl[be].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 oe=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(oe,{size:15}),H.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:ue.filter(be=>He(be)===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 oe=ue.filter(be=>He(be)===H.id).sort((be,Ze)=>Ze.updatedAt-be.updatedAt);return s.jsx("section",{"aria-label":`${H.label}任务`,"aria-hidden":!L&&B!==H.id?!0:void 0,ref:be=>{be&&(be.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:[oe.map(be=>{const Ze=le.get(be.id),Je=Ze.attention??be,St=Je.attempts.find(Ve=>Ve.id===Je.activeAttemptId),Vt=Je.decisions.find(Ve=>Ve.status==="pending"),jt=Yc(Je),vt=U6(Je,Ze.children),Zt=Xf(Je),Pt=Zt[0],Xt=Zt.find(Ve=>Ve.source==="system"),zt=Zt.find(Ve=>Ve.source==="unknown"),Lt=Xt?.content,me=H.id==="attention",Ge=Vt?"回答问题":zt?"查看详情核对记录":Pt?.source==="member"&&Xt?"查看条件与异常处理":Pt?.source==="member"?"查看阻塞并补充条件":Lt?"查看原因与处理":jt==="等待你验收"?"查看结果并验收":jt==="需要你确认方案"?"查看并确认方案":"查看任务并处理",pt=Je.artifacts.filter(Ve=>Ve.kind==="result"&&Ve.attemptId===Je.activeAttemptId).at(-1),q=Je.events.filter(Ve=>Ve.kind==="revise"&&Ve.source==="user"&&Ve.attemptId===Je.activeAttemptId&&(!pt||Ve.createdAt>=pt.createdAt)).at(-1),at=Vt?Vt.question||"成员提出了一个问题,打开后可查看并回答。":Pt?.summary||q?.content||pt?.summary||(St?.report?.content?$6(St.report.content).summary:St?.report?.summary||""),qt=e.find(Ve=>Ve.id===be.parentTaskId);return s.jsxs("article",{"aria-label":be.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===be.id?"border-primary/60":Lt?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":be.id,"aria-pressed":t===be.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(Je.id),children:[qt&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:qt.title}),s.jsx("span",{title:be.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:be.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${Lt&&Pt?.source!=="member"?"text-destructive":me?"text-primary":"text-muted-foreground"}`,children:[Lt&&Pt?.source!=="member"&&s.jsx(Q1,{size:13,className:"shrink-0"}),vt]}),Ze.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",Ze.attention.title]}),Ze.attention&&Ze.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",Ze.attentionCount," 项执行需要你处理"]}),at&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:at}),Xt&&Pt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Xt.label,":",Xt.summary]}),zt&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[zt.label,":",zt.summary]}),me&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${Lt?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[Ge,s.jsx(Fm,{size:14})]}),!me&&(be.status==="accepted"||be.artifacts.some(Ve=>Ve.kind==="result"&&Ve.attemptId===be.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(Fm,{size:14})]})]}),s.jsx(yO,{task:be,children:Ze.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:[Ze.attention?"待处理任务负责人:":be.workflow?.kind==="goal"?"协调者:":"负责人:",St?n(Je,St.assignee):Je.scheduledAssignee?n(Je,Je.scheduledAssignee):"未分派"]}),s.jsx(jf,{task:Je,now:v,compact:!0})]})]},be.id)}),!oe.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Z||U!=="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 Ih(e,t){return r=>Rl.getState().update(e,t,r)}function Tm(e,t){return r=>Rl.getState().updateDetail(e,t,r)}const wO=b.lazy(()=>Oc(()=>Promise.resolve().then(()=>cO),void 0).then(e=>({default:e.DirectoryPickerDialog}))),AO=b.lazy(()=>Oc(()=>import("./CollaborationTaskContent-DSkxOlKQ.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),oa="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",Qs="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=`${oa} bg-primary text-primary-foreground`,si=`${oa} bg-surface-2 text-foreground hover:bg-surface-2/80`,TO={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:"请求重新检查"},Bu=e=>`${e.serviceId}:${e.sessionId}`,Ta=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function Qo(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 Oa(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const Kd={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]};function SO(e){const t={...Kd,...Qo(e,Kd)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(Kd).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?Kd:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function z6(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 CO({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),[W]=b.useState(()=>Rl.getState().ensure(v,{draft:SO(`${v}:draft`),selectedId:Qo(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:F,mobileDetail:U,creating:V,draft:Z}=Rl(ne=>ne.views[v]??W),ce=Ih(v,"selectedId"),xe=Ih(v,"mobileDetail"),pe=Ih(v,"creating"),te=Ih(v,"draft"),[ke,$e]=b.useState(!1),[Y,Ae]=b.useState(!1),lt=b.useRef(null),Se=b.useRef(null),ye=b.useRef(!1),_e=b.useCallback(ne=>{!ne&&Se.current===document.activeElement&&(ye.current=!0),Se.current=ne,ne&&ye.current&&(ye.current=!1,ne.focus())},[]);b.useEffect(()=>{const ne=lt.current;if(!ne)return;const ht=new ResizeObserver(Ht=>$e(Ht[0].contentRect.width>=(l?1100:760)));return ht.observe(ne),()=>ht.disconnect()},[l]);const[je,re]=b.useState(!1),[Oe,Ce]=b.useState(null),Ee=Sy(),[Be,Ne]=b.useState(0),[le,He]=b.useState(null),[rt,mt]=b.useState(!1),[ue,Ye]=b.useState(0),st=ne=>Ye(ht=>Math.max(0,ht+ne)),[Ie,We]=b.useState("");b.useEffect(()=>{if(!Ie)return;const ne=setTimeout(()=>We(""),5e3);return()=>clearTimeout(ne)},[Ie]);const[Te,H]=b.useState("open"),[oe,be]=b.useState(""),Ze=b.useRef(!1),Je=b.useRef(!0),St=b.useRef(new Map),Vt=b.useRef(!1),jt=e.sessionIds.flatMap(ne=>{const ht=t.find(Ht=>Ht.sessionId===ne);return ht?[ht]:[]}),vt=jt.map(ne=>({...ne,name:ku(ne,jt)})),Zt=Z.coordinator||Qo(`${v}:lead`,""),Pt=vt.find(ne=>ne.sessionId===Zt)?.sessionId||vt.find(ne=>ne.agent)?.sessionId||vt[0]?.sessionId||"",Xt=vt.filter(ne=>ne.sessionId!==Pt&&ne.agent).map(ne=>ne.sessionId),[zt,Lt]=b.useState(!1),[me,Ge]=b.useState(!1),[pt,q]=b.useState(()=>Qo(`${v}:agent`,x[0]?.slug??"")),[at,qt]=b.useState(()=>Qo(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ve=e.launchProfiles?.find(ne=>ne.id===at),De=Ve?.agentSlug??pt,[er,et]=b.useState(()=>Qo(`${v}:cwd`,vt[0]?.cwd??y??""));b.useEffect(()=>{!pt&&x[0]&&q(x[0].slug)},[x,pt]);const Ct=!vt.find(ne=>ne.sessionId===Pt)?.agent||!Xt.length,[Nt,gt]=b.useState(null),bt=!!Z.spec.trim()&&(!!Nt||!Ct||!e.federated&&(!at||!!Ve)&&!!x.find(ne=>ne.slug===De)&&!!er.trim()),It=S.find(ne=>ne.id===F)??null,yt=R?.id===F?R:null;b.useEffect(()=>(Je.current=!0,()=>{Je.current=!1}),[]),b.useEffect(()=>{Oa(`${v}:draft`,Z)},[v,Z]),b.useEffect(()=>{Oa(`${v}:selected`,F)},[v,F]),b.useEffect(()=>{const ne=Ht=>{const Ot=Ht.detail;Ot?.groupId===e.id&&(Oa(`${v}:open-task`,null),ce(Ot.taskId),xe(!0),pe(!1),H("all"),pr())};window.addEventListener("open-collaboration-task",ne);const ht=Qo(`${v}:open-task`,null);return ht&&(ce(ht),xe(!0),H("all"),Oa(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",ne)},[e.id]),b.useEffect(()=>{if(!r||!It||R?.id===It.id&&R.revision===It.revision)return;let ne=!1;return jw(It.id).then(ht=>{ne||(B(ht.task),Ce(null))}).catch(ht=>{ne||Ce(ht instanceof Error?ht.message:"任务详情加载失败")}),()=>{ne=!0}},[r,It?.id,It?.revision,R?.id,R?.revision,Be]);const pr=async()=>{if(!Vt.current){Vt.current=!0;try{const ne=await vy(e.id);Je.current&&(L(ne.tasks),re(!0),Ce(null),Ne(ht=>ht+1))}catch(ne){Je.current&&Ce(ne instanceof Error?ne.message:"任务加载失败")}finally{Vt.current=!1}}};b.useEffect(()=>{if(!r)return;pr();const ne=()=>{!document.hidden&&navigator.onLine!==!1&&pr()},ht=setInterval(ne,2500);return document.addEventListener("visibilitychange",ne),window.addEventListener(nf,ne),window.addEventListener("pageshow",ne),()=>{clearInterval(ht),document.removeEventListener("visibilitychange",ne),window.removeEventListener(nf,ne),window.removeEventListener("pageshow",ne)}},[r,e.id]);const nr=ne=>{const ht=JSON.stringify(ne),Ht=Qo(`${v}:request`,null);let Ot=St.current.get(ht)??(Ht?.fingerprint===ht?Ht.key:void 0);return Ot||(Ot=crypto.randomUUID(),St.current.set(ht,Ot)),Oa(`${v}:request`,{fingerprint:ht,key:Ot}),Ot},Cr=ne=>{St.current.delete(JSON.stringify(ne)),Oa(`${v}:request`,null)},cn=async(ne,ht)=>{if(rt||Ze.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};Ze.current=!0,mt(!0),He(null),We("");let Ht={...ht,expectedRevision:ne.revision};if(["comment","revise"].includes(ht.kind)){const Ot=Qo(`${v}:request`,null);try{const[Tr,mr]=JSON.parse(Ot?.fingerprint??"null"),{expectedRevision:Hr,..._n}=mr;Tr===ne.id&&JSON.stringify(_n)===JSON.stringify(ht)&&(Ht=mr)}catch{}}try{const Ot=await Qw(ne.id,{...Ht,idempotencyKey:nr([ne.id,Ht])});if(Cr([ne.id,Ht]),_u.getState().refresh(),Je.current){const Tr=E.current.find(dr=>dr.id===Ot.task.id),mr=Tr&&Tr.revision>Ot.task.revision?Tr:Ot.task;L(dr=>dr.map(bn=>bn.id===Ot.task.id&&bn.revision<=Ot.task.revision?Ot.task:bn)),B(dr=>dr?.id===Ot.task.id&&dr.revision>Ot.task.revision?dr:Ot.task);const Hr=z6(mr,E.current),_n=`${ht.kind==="answer"?"回答已保存":"方案确认已保存"},${Hr?Hr.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;We(["comment","revise"].includes(ht.kind)?"":ht.kind==="retry"?xO(ne,Ot.task):["answer","approve-plan"].includes(ht.kind)?_n:ht.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(Ot){const Tr=Ot instanceof Error?Ot.message:"操作失败";return Tr.includes("任务已更新")&&Cr([ne.id,Ht]),Je.current&&(He(["comment","revise"].includes(ht.kind)?null:Tr),pr()),{ok:!1,error:Tr}}finally{Ze.current=!1,Je.current&&mt(!1)}},Lr=async ne=>{if(ne.preventDefault(),rt||ue>0||(Z.mode==="goal"?!bt:!Z.title.trim()||!Z.spec.trim())||Ze.current)return;Ze.current=!0,mt(!0),He(null);const ht=Z.mode==="goal",Ht={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:ht?void 0:Z.assignee||void 0,coordinatorSessionId:ht?Pt:Z.coordinator||void 0,parentTaskId:ht?void 0:Z.parent||void 0,dependsOn:ht?[]:Z.dependencies,managed:ht,isolated:Z.isolated,reviewerSessionIds:ht?Xt:void 0};try{if(ht&&(Ct||Nt)){Ge(!0);const Tr=Nt??await Dw(e.id,{agentSlug:De,...at?{launchProfileId:at}:e.launchProfiles?.length?{launchProfileId:""}:{},cwd:er.trim()});Ge(!1),gt(Tr),Ht.coordinatorSessionId=Tr.coordinatorSessionId,Ht.reviewerSessionIds=Tr.reviewerSessionIds,Oa(`${v}:agent`,pt),Oa(`${v}:cwd`,er.trim()),Oa(`${v}:launch-profile`,at)}const{task:Ot}=await Bw({...Ht,idempotencyKey:nr(Ht)});Cr(Ht),Je.current&&(L(Tr=>[Ot,...Tr.filter(mr=>mr.id!==Ot.id)]),ce(Ot.id),xe(!0),B(Ot),ht&&Oa(`${v}:lead`,Ht.coordinatorSessionId),gt(null),w?.(),te(Kd),pe(!1),H("open"),be(""),We(ht?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(Ot){Je.current&&He(Ot instanceof Error?Ot.message:"创建失败")}finally{Ze.current=!1,Je.current&&(mt(!1),Ge(!1))}},ge=(ne,ht)=>{if(!ht)return"用户";const Ht=ne.memberSessions[Bu(ht)];return vt.find(Ot=>Ot.sessionId===Ht)?.name??t.find(Ot=>Ot.sessionId===Ht)?.name??"暂不可用的成员"},Vr=S.filter(ne=>(Te==="all"?!0:Te==="archive"?ne.status!=="open":ne.status==="open")&&(Te==="all"||Te==="attention"||ne.workflow?.kind!=="step")&&(Te!=="attention"||Fi(ne))&&(!oe.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(ht=>ge(ne,ht.assignee)).join(" ")}`.toLowerCase().includes(oe.trim().toLowerCase()))),it=S.filter(Fi).length;b.useEffect(()=>{a?.(it)},[it,a]);const dt=!!It&&(l?U:ke||U),sr=()=>{pe(!1),requestAnimationFrame(()=>Se.current?.focus())},xn=ne=>{Rl.getState().updateDetail(`${v}:${ne}`,"view","overview"),ce(ne),xe(!0),We("")},an=S.filter(Fi).filter(ne=>!oe.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(ht=>ge(ne,ht.assignee)).join(" ")}`.toLowerCase().includes(oe.trim().toLowerCase())),Me=(ne,ht=!1)=>{const Ht=ne.attempts.find(dr=>dr.id===ne.activeAttemptId),Ot=ne.children?.filter(dr=>dr.status==="accepted").length??0,Tr=ne.children?.filter(dr=>dr.status!=="closed").length??0,mr=Xf(ne),Hr=mr.length>1?mr.find(dr=>dr.source!=="member"):null,_n=(ht?ne.decisions.find(dr=>dr.status==="pending")?.question:"")||mr[0]?.summary||Ht?.report?.summary||Ht?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":F===ne.id,className:`group flex min-h-11 w-full items-start gap-3 rounded-xl p-3 text-left transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${F===ne.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>xn(ne.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${ht||ne.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:ht?s.jsx(N0,{size:16}):ne.status==="accepted"?s.jsx(Fu,{size:16}):s.jsx($u,{size:16})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:ne.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${ht?"text-primary":"text-muted-foreground"}`,children:Yc(ne)}),_n&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:_n}),Hr&&s.jsxs("span",{className:`mt-1 block line-clamp-2 break-words text-xs leading-5 ${Hr.source==="system"?"text-destructive":"text-muted-foreground"}`,children:[Hr.label,":",Hr.summary]}),Tr>0&&s.jsxs("span",{className:"mt-2 flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"flex gap-1","aria-hidden":"true",children:(ne.children??[]).filter(dr=>dr.status!=="closed").slice(0,8).map(dr=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${dr.status==="accepted"?"bg-primary":"bg-border/30"}`},dr.id))}),Ot,"/",Tr," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"block truncate",children:Ht?ge(ne,Ht.assignee):"尚未分派"}),s.jsx(jf,{task:ne})]})]}),s.jsx(fi,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},ne.id)},nt=[],wt=new Set([F]);let Rr=It?.parentTaskId;for(;Rr&&!wt.has(Rr);){wt.add(Rr);const ne=S.find(ht=>ht.id===Rr);if(!ne)break;nt.unshift(ne),Rr=ne.parentTaskId}const rn=()=>{const ne=Array.from(lt.current?.querySelectorAll("button[data-task-id]")??[]).find(ht=>ht.dataset.taskId===F);xe(!1),requestAnimationFrame(()=>{ne&&!ne.closest("[hidden]")?ne.focus():Se.current?.focus()})},Ir=V||!l&&je&&S.length===0;return s.jsxs("section",{ref:lt,"aria-label":"协作任务",className:l?"relative flex h-full min-h-0 min-w-0 flex-col gap-2":"space-y-5",children:[l&&(Ir||!je)&&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})]}),(le||Oe&&Ee==="ready"&&!sf(Oe))&&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:[le||Oe,!le&&je?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:oa,onClick:()=>le?He(null):void pr(),children:[s.jsx(gn,{size:14}),le?"关闭提示":"重试"]})]}),Oe&&sf(Oe)&&!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}),Ir?s.jsxs("form",{onSubmit:ne=>{Lr(ne)},className:`mx-auto w-full max-w-xl space-y-4 ${l?"overflow-auto px-1 py-5":""}`,onKeyDown:ne=>{ne.key==="Escape"&&V&&!ne.defaultPrevented&&!ne.nativeEvent.isComposing&&M1(ne.currentTarget)&&(ne.preventDefault(),ne.stopPropagation(),rt||sr())},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:`${oa} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:rt,onClick:sr,children:s.jsx(Rn,{size:16})})]}),Z.mode==="task"&&s.jsx(Do,{label:"任务标题",children:s.jsx("input",{className:Qs,required:!0,maxLength:200,value:Z.title,onChange:ne=>te(ht=>({...ht,title:ne.target.value})),placeholder:"要完成什么?"})}),s.jsx(Xh,{paneKey:m,inputKey:`${v}:spec`,active:r&&Ir,label:Z.mode==="goal"?"协作目标":"目标与交付要求",className:`${Qs} ${Ct&&Z.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:V,required:!0,disabled:rt,value:Z.spec,onUploadChange:st,onChange:ne=>te(ht=>({...ht,spec:typeof ne=="function"?ne(ht.spec):ne})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),Z.mode==="goal"&&Nt&&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:si,disabled:rt,onClick:()=>{w?.(),c()},children:"查看已准备的成员"})]}),Z.mode==="goal"&&(Ct||Nt)?s.jsxs("fieldset",{disabled:rt||!!Nt,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:Nt?"已用于准备成员的配置":"首次开始时配置 Agent"}),(!!e.launchProfiles?.length||!!at)&&s.jsxs(Do,{label:"启动方案",children:[s.jsxs("select",{"aria-label":"协作启动方案",className:Qs,value:at,onChange:ne=>qt(ne.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(ne=>s.jsxs("option",{value:ne.id,children:[ne.name," · ",x.find(ht=>ht.slug===ne.agentSlug)?.displayName??ne.agentSlug]},ne.id))]}),Ve&&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:Ve.notes||"查看启动命令与使用备注"})}),s.jsx("p",{"aria-label":"完整使用备注",className:"whitespace-pre-wrap break-words",children:Ve.notes}),s.jsx("code",{className:"mt-1 block break-all",children:Ve.command})]}),at&&!Ve&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]}),!Ve&&s.jsx(Do,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Qs,disabled:!!Ve,value:De,onChange:ne=>q(ne.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(ne=>s.jsx("option",{value:ne.slug,children:ne.displayName},ne.slug))]})}),s.jsxs(Do,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Qs} min-w-0 flex-1`,value:er,onChange:ne=>et(ne.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:si,onClick:()=>Lt(!0),children:"浏览目录"})]}),zt&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(wO,{open:!0,initialPath:er.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>Lt(!1),onConfirm:ne=>{et(ne),Lt(!1)}})})]}),!Nt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"开始时配置协调者与执行/评审成员,后续目标复用。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",c&&s.jsx("button",{type:"button",className:si,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:si,onClick:c,children:"管理成员"})]})]}):Z.mode==="goal"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"协调者"}),s.jsx("select",{"aria-label":"协调者",className:`${Qs} min-w-0 flex-1`,value:Pt,onChange:ne=>te(ht=>({...ht,coordinator:ne.target.value})),children:vt.map(ne=>s.jsxs("option",{value:ne.sessionId,disabled:!ne.agent,children:[ne.name,ne.agent?"":"(需要启动 Agent)"]},ne.sessionId))})]}):s.jsx(Do,{label:"分派给",children:s.jsxs("select",{className:Qs,value:Z.assignee,onChange:ne=>te(ht=>({...ht,assignee:ne.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),vt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsxs("details",{className:"border-y border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:["验收标准与更多设置",(Z.acceptance||Z.constraints)&&s.jsx("span",{className:"text-primary",children:"已补充"})]}),s.jsxs("div",{className:"space-y-3 pb-4",children:[s.jsx(Do,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Qs} min-h-20 resize-y`,value:Z.acceptance,onChange:ne=>te(ht=>({...ht,acceptance:ne.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(Do,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Qs} min-h-20 resize-y`,value:Z.constraints,onChange:ne=>te(ht=>({...ht,constraints:ne.target.value})),placeholder:"必须保留什么?哪些操作需要先问你?"})}),Z.mode==="goal"?s.jsxs("label",{className:"flex min-h-11 items-start gap-2 text-xs leading-5 text-muted-foreground",children:[s.jsx("input",{type:"checkbox",className:"mt-1",checked:Z.isolated,onChange:ne=>te(ht=>({...ht,isolated:ne.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Do,{label:"协调者",children:s.jsxs("select",{className:Qs,value:Z.coordinator,onChange:ne=>te(ht=>({...ht,coordinator:ne.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),vt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsx(Do,{label:"父任务",children:s.jsxs("select",{className:Qs,value:Z.parent,onChange:ne=>te(ht=>({...ht,parent:ne.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),S.filter(ne=>!ne.workflow).map(ne=>s.jsx("option",{value:ne.id,children:ne.title},ne.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),S.filter(ne=>ne.status!=="closed").map(ne=>s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Z.dependencies.includes(ne.id),onChange:ht=>te(Ht=>({...Ht,dependencies:ht.target.checked?[...Ht.dependencies,ne.id]:Ht.dependencies.filter(Ot=>Ot!==ne.id)}))}),ne.title]},ne.id))]})]}),s.jsx("button",{type:"button",className:`${oa} text-muted-foreground hover:bg-surface-2`,onClick:()=>te(ne=>({...ne,mode:ne.mode==="goal"?"task":"goal"})),children:Z.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${cl} w-full`,disabled:rt||ue>0||(Z.mode==="goal"?!bt:!Z.title.trim()||!Z.spec.trim()),children:[rt?s.jsx(gn,{size:14,className:"animate-spin"}):s.jsx(r0,{size:14}),rt?me?"正在准备成员…":"提交中…":Z.mode==="goal"?Nt?"重试提交目标":"开始协作":Z.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:Z.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):l&&je?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:dt,className:`${dt?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(vO,{navigation:d,settings:p,action:s.jsxs("button",{ref:_e,type:"button",className:cl,disabled:rt,onClick:()=>pe(!0),children:[s.jsx(Us,{size:14}),"新目标"]}),storage:v,tasks:S,selectedId:dt?F:null,name:ge,onSelect:xn})}),dt&&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:`${oa} px-2 hover:bg-surface-2`,onClick:rn,children:"看板"})}),nt.map(ne=>s.jsxs("li",{className:"flex min-w-0 flex-1 items-center gap-1 sm:max-w-xs sm:flex-none",children:[s.jsx(fi,{"aria-hidden":"true",size:12,className:"shrink-0"}),s.jsx("button",{type:"button","aria-label":`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,title:`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,className:`${oa} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>xn(ne.id),children:s.jsxs("span",{className:"truncate",children:[ne.workflow?.kind==="goal"?"目标":"父任务",":",ne.title]})})]},ne.id)),s.jsxs("li",{"aria-current":"page",className:"flex shrink-0 items-center gap-1",children:[s.jsx(fi,{"aria-hidden":"true",size:12}),s.jsx("span",{className:"px-2",children:It?.parentTaskId?"子任务详情":It?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:yt?s.jsx(Sb,{reader:!0,paneKey:m,active:r,task:yt,tasks:S,members:vt,busy:rt,name:ne=>ge(yt,ne),act:ne=>cn(yt,ne),storage:v,onSelectTask:xn,onOpenSession:async ne=>{const ht=t.find(Ht=>Ht.sessionId===yt.memberSessions[Bu(ne)]);if(!ht){He("成员会话暂不可用,任务历史已保留。");return}try{await n(ht)}catch(Ht){He(Ht instanceof Error?Ht.message:"无法打开终端")}}},yt.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!je&&!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:Oe?"任务暂时无法加载,请重试。":"正在加载目标…"}),!Oe&&[0,1,2].map(ne=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},ne))]}):s.jsxs(s.Fragment,{children:[(!dt||ke)&&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(ne=>ne.status==="open"&&ne.workflow?.kind!=="step").length," 个进行中 · ",S.filter(ne=>ne.status==="accepted"&&ne.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:_e,type:"button",className:cl,disabled:rt,onClick:()=>pe(!0),children:[s.jsx(Us,{size:14}),"新目标"]})]}),s.jsxs("div",{className:ke&&dt?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!dt||ke)&&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:`${Qs} min-w-0 flex-1 border-transparent bg-transparent`,value:Te,onChange:ne=>H(ne.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",it,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":Y,className:`${oa} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{Ae(ne=>!ne),be("")},children:s.jsx(Ml,{size:16})})]}),Y&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Qs,value:oe,onChange:ne=>be(ne.target.value),placeholder:"搜索目标、内容或负责人"}),Te==="open"&&an.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:an.length})]}),an.map(ne=>Me(ne,!0))]}),(Te!=="open"||Vr.some(ne=>!Fi(ne))||Vr.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:Te==="attention"?"需要你处理":Te==="archive"?"已归档":Te==="all"?"全部任务":"当前目标"}),Vr.filter(ne=>Te!=="open"||!Fi(ne)).map(ne=>Me(ne,Te==="attention")),!Vr.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[oe.trim()?"没有匹配的任务。":Te==="attention"?"目前没有需要你处理的任务。":Te==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(Te!=="all"||oe)&&s.jsx("button",{type:"button",className:`${oa} mt-2 text-primary`,onClick:()=>{H("all"),be("")},children:"查看全部任务"})]})]})]}),dt&&s.jsxs("div",{className:"min-w-0",children:[!ke&&s.jsxs("button",{type:"button",className:`${oa} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>xe(!1),children:[s.jsx(Cy,{size:14}),"全部目标"]}),yt?s.jsx(Sb,{paneKey:m,active:r,task:yt,tasks:S,members:vt,busy:rt,name:ne=>ge(yt,ne),act:ne=>cn(yt,ne),storage:v,onSelectTask:xn,onOpenSession:async ne=>{const ht=t.find(Ht=>Ht.sessionId===yt.memberSessions[Bu(ne)]);if(!ht){He("成员会话暂不可用,任务历史已保留。");return}try{await n(ht)}catch(Ht){He(Ht instanceof Error?Ht.message:"无法打开终端")}}},yt.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function Do({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 Sb({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,W]=b.useState(!1),[F,U]=b.useState(null),V=b.useRef(!1),Z=b.useRef(!0);b.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const ce=b.useRef(null),xe=b.useRef(null);b.useEffect(()=>{!e&&F&&F.state!=="pending"&&t&&requestAnimationFrame(()=>xe.current?.scrollIntoView({block:"nearest"}))},[F]);const pe=b.useRef(null),[te,ke]=b.useState(0),$e=q=>ke(at=>Math.max(0,at+q)),Y=b.useRef(null);b.useEffect(()=>{Y.current?.focus()},[]);const Ae=`${m}:${n.id}`,[lt]=b.useState(()=>Rl.getState().ensureDetail(Ae,{feedback:Qo(`${Ae}:feedback`,""),answers:Qo(`${Ae}:answers`,{}),view:"overview"})),{feedback:Se,answers:ye,view:_e}=Rl(q=>q.details[Ae]??lt),je=Tm(Ae,"feedback"),re=Tm(Ae,"answers"),Oe=Tm(Ae,"view");b.useEffect(()=>{pe.current&&(pe.current.scrollTop=0)},[_e]),b.useEffect(()=>Oa(`${m}:${n.id}:answers`,ye),[m,n.id,ye]),b.useEffect(()=>Oa(`${m}:${n.id}:feedback`,Se),[m,n.id,Se]);const Ce=n.attempts.find(q=>q.id===n.activeAttemptId),Ee=n.status==="open",Be=z6(n,a),Ne=n.artifacts.filter(q=>q.kind==="result"&&q.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{F?.state==="saved"&&Ne?.id!==F.resultId&&U(null)},[Ne?.id,F]);const le=n.artifacts.filter(q=>q.kind==="plan"&&q.attemptId===n.activeAttemptId).at(-1),He=n.events.filter(q=>q.kind==="revise"&&q.source==="user"&&q.attemptId===n.activeAttemptId).at(-1),rt=Ne&&n.events.some(q=>q.kind==="revise"&&q.attemptId===n.activeAttemptId&&q.createdAt>=Ne.createdAt),mt=e&&Ee&&!!rt,ue=F?.state==="saved"&&F.kind==="revise"&&F.resultId===Ne?.id,Ye=n.decisions.filter(q=>q.status==="pending"&&q.attemptId===n.activeAttemptId),st=n.dependsOn.some(q=>a.find(at=>at.id===q)?.status!=="accepted"),Ie=!n.workflow||n.artifacts.filter(q=>q.kind==="review"&&q.reviewsArtifactId===Ne?.id).at(-1)?.verdict==="pass",We=n.children??[],Te=n.workflow?.kind==="goal"&&We.some(q=>!["accepted","closed"].includes(q.status)),H=`任务:${n.title}
|
|
141
|
-
任务 ID:${n.id}
|
|
142
|
-
${n.spec}
|
|
143
|
-
约束:${n.constraints||"未补充"}
|
|
144
|
-
验收标准:${n.acceptance||"由用户决定"}
|
|
145
|
-
${Ce?`当前尝试:${Ce.id}
|
|
146
|
-
负责人:${l(Ce.assignee)}
|
|
147
|
-
`:""}${n.artifacts.filter(q=>q.attemptId===n.activeAttemptId).map(q=>`${q.kind} · 版本 ${q.id} · ${Ta(q.createdAt)}
|
|
148
|
-
${q.summary?`结果摘要:${q.summary}
|
|
149
|
-
`:""}${q.content}`).join(`
|
|
150
|
-
|
|
151
|
-
`)}
|
|
152
|
-
${Ye.map(q=>`待回答:${q.question}`).join(`
|
|
153
|
-
`)}`,oe=()=>{const q=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),at=document.createElement("a");at.href=q,at.download=`termdock-task-${n.id}.json`,at.click(),setTimeout(()=>URL.revokeObjectURL(q),1e3)},be=n.events.filter(q=>q.kind==="coordinate"&&(!q.attemptId||q.attemptId===n.activeAttemptId)).at(-1),Ze=_e==="results"?n.artifacts.slice().reverse():n.artifacts.filter(q=>q.id===Ne?.id||q.id===le?.id&&n.approvedPlanArtifactId!==q.id||q.kind==="review"&&q.reviewsArtifactId===Ne?.id).sort((q,at)=>(q.kind==="result"?-1:1)-(at.kind==="result"?-1:1)||at.createdAt-q.createdAt),Je=We.filter(q=>q.status==="accepted").length,St=We.filter(q=>q.status!=="closed"),Vt=St.filter(q=>q.status!=="accepted"),jt=be&&(!He||be.createdAt>=He.createdAt)?be:void 0,vt=Ce?.report&&(!He||Ce.report.createdAt>=He.createdAt)?Ce.report:void 0,Zt=rt?"等待新结果通过评审后可验收。":Ye.length?"回答当前问题后可验收。":st?"依赖任务验收后可验收。":Ie?Te?"子任务完成并通过评审后可验收。":null:"独立评审通过后可验收。",Pt=()=>{Oe("overview"),W(!0),requestAnimationFrame(()=>{ce.current?.scrollIntoView({block:"nearest"}),ce.current?.querySelector("textarea")?.focus()})},Xt=Xf(n),zt=Xt[0],Lt=Xt.some(q=>q.source==="member"),me=async q=>{if(d||te||!Se.trim()||V.current)return;const at=Se;V.current=!0,U({kind:q,state:"pending",content:at,resultId:Ne?.id});const qt=await p({kind:q,content:at});if(V.current=!1,qt.ok){if(je(Ve=>Ve===at?"":Ve),Oa(`${Ae}:feedback`,Rl.getState().details[Ae]?.feedback??""),!Z.current)return;U({kind:q,state:"saved",content:at,resultId:Ne?.id}),e&&Rl.getState().details[Ae]?.feedback===""&&W(!1)}else Z.current&&U({kind:q,state:"error",content:at,error:qt.error,resultId:Ne?.id})},Ge=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(AO,{content:q})}),pt=q=>{const at=$6(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"?rt&&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)," · ",Ta(q.createdAt),q.attemptId!==n.activeAttemptId&&q.kind!=="review"?" · 历史分派":""]}),q.kind==="result"&&at.condensed?s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-label":"结果结论",className:"text-base leading-7",children:Ge(!at.explicit&&!at.summary.includes(`
|
|
154
|
-
`)?at.summary.replace(/([。;])\s*(?=\S)/g,`$1
|
|
155
|
-
|
|
156
|
-
`):at.summary)}),at.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:"适用范围与限制"}),Ge(at.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:Ge(q.content)})]})]}):Ge(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(hi,{size:14}),"验收此结果"]}),Zt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Zt})]}),le?.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(hi,{size:14}),Be?"确认方案":"确认方案并继续"]}),!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:Qs,value:S,onChange:qt=>L(qt.target.value),children:[s.jsx("option",{value:"",children:"选择独立评审成员"}),c.filter(qt=>qt.sessionId!==n.memberSessions[Bu(q.actor)]).map(qt=>s.jsx("option",{value:qt.sessionId,children:qt.name},qt.sessionId))]}),s.jsx("button",{type:"button",className:si,disabled:d||!S||S===n.memberSessions[Bu(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:`${oa} -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(Fm,{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 ${Fi(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"}),Yc(n)]})]}),!Ye.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)}`:Ce?`负责人 · ${l(Ce.assignee)}`:"尚未分派"}),Ce&&s.jsxs("button",{type:"button",className:`${oa} px-2 text-muted-foreground hover:bg-surface-2 hover:text-primary`,onClick:()=>{x(Ce.assignee)},children:[s.jsx(Fc,{size:13}),"打开终端"]})]}),!e&&s.jsx(jf,{task:n}),n.replica&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"此记录由来源服务同步,回答与决定会送回来源服务。"})]}),Be&&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:Be.workflow?.kind==="goal"?"目标仍暂停。回答和方案确认会保存,恢复目标后才能投递;已投递的终端工作继续保留。":"任务仍暂停。回答和方案确认会保存,继续安排后才能投递;已投递的终端工作继续保留。"}),Be.id!==n.id&&s.jsx("button",{type:"button",className:si,onClick:()=>y(Be.id),children:"查看目标并恢复安排"})]}),s.jsx("nav",{"aria-label":"任务详情",className:"flex gap-4 border-b border-border/20",children:[["overview",mt?"进展":e&&Ne?"结果":"概览"],["results",e?"历史交付":`交付${n.artifacts.length?` ${n.artifacts.length}`:""}`],["activity","动态"]].map(([q,at])=>s.jsx("button",{type:"button","aria-pressed":_e===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 ${_e===q?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,onClick:()=>Oe(q),children:at},q))}),_e==="overview"&&s.jsxs(s.Fragment,{children:[(()=>{const q=He;if(!q)return null;const at=n.deliveries.find(De=>De.id===q.deliveryId),qt=n.outbox.find(De=>De.id===q.deliveryId),Ve=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:mt?"本次跟进要求":Ve?Ie?"新结果已通过独立评审":"新结果已交付,等待独立评审":"已要求继续跟进,等待新结果"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:q.content}),s.jsxs("p",{className:"text-muted-foreground",children:[Ta(q.createdAt),at?.status==="delivered"?e?" · 已写入成员终端":` · 已写入${q.target?l(q.target):"成员"}终端${at.deliveredAt?` · ${Ta(at.deliveredAt)}`:""}`:["failed","expired"].includes(at?.status??"")||at?.error||qt?.lastError?" · 投递未成功,服务端继续重试":q.deliveryId?" · 等待写入终端":" · 要求已保存"]})]})})(),Ye.map(q=>s.jsxs("form",{className:"space-y-3 rounded-xl border border-border/30 bg-surface-2/40 p-4",onSubmit:at=>{at.preventDefault(),!d&&!te&&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(N0,{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((at,qt)=>s.jsxs("button",{type:"button","aria-pressed":ye[q.id]===at,disabled:d,className:`${oa} justify-start text-left ${ye[q.id]===at?"bg-primary/15 text-primary":"bg-surface-2 text-foreground"}`,onClick:()=>re(Ve=>({...Ve,[q.id]:at})),children:[ye[q.id]===at?s.jsx(hi,{size:14,className:"shrink-0"}):s.jsx($u,{size:14,className:"shrink-0"}),s.jsx("span",{className:"break-words",children:at})]},qt))}),s.jsx(Xh,{paneKey:r,inputKey:`${Ae}:answer:${q.id}`,active:t,label:"你的回答",className:`${Qs} min-h-20 resize-y`,required:!0,disabled:d,value:ye[q.id]??"",onUploadChange:$e,onChange:at=>re(qt=>({...qt,[q.id]:typeof at=="function"?at(qt[q.id]??""):at})),placeholder:"选择建议,或写下你的决定…"}),s.jsxs("button",{className:`${cl} w-full`,disabled:d||te>0||!ye[q.id]?.trim(),children:[s.jsx(r0,{size:14}),Be?"保存回答":"回复并继续"]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[Ta(q.createdAt)," · 回答会保存在任务记录中"]})]},q.id)),Xt.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(Ce?.assignee??null)}。先补齐报告中缺少的条件,再发送说明;需要登录时,请在对应服务完成授权。`:q.source==="unknown"?"此摘要未提供原报告正文和记录来源,请打开完整详情核对;确认前不提供服务异常重试。":"重试只请求服务重新检查现有投递与协调条件,保留原报告和执行尝试;成员新的明确回复才会更新报告。"}),q.source==="member"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:si,disabled:d,onClick:Pt,children:"补充条件并通知成员"}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整阻塞报告"}),q.content?Ge(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:si,disabled:d||!n.workflow,onClick:()=>{p({kind:"retry"})},children:[s.jsx(gn,{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:si,disabled:d,onClick:()=>{p({kind:"resume"})},children:"继续安排"})]}),mt&&Ze.filter(q=>q.kind==="plan").map(pt),mt&&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:Vt.length?`${Vt.length} 项执行尚未完成交付与评审`:"收到新的交付结果后,会在这里展示供你验收。"})]}),!!Vt.length&&s.jsx("ul",{className:"space-y-1",children:Vt.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(fi,{size:14,className:"shrink-0"})]})},q.id))}),jt||vt?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(fi,{size:13,className:"shrink-0 transition-transform group-open/record:rotate-90"}),s.jsx("span",{children:jt?"协调者最近的更新":"成员最近的报告"}),s.jsx("span",{className:"ml-auto shrink-0",children:Ta((jt??vt).createdAt)})]}),s.jsx("div",{className:"pb-3",children:Ge((jt??vt).content)})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到这次跟进后的明确更新。"})]}),mt?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(fi,{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:Ta(Ne.createdAt)})]}),s.jsx("div",{className:"space-y-3 pb-3",children:Ze.filter(q=>q.kind!=="plan").map(pt)})]}):s.jsx(s.Fragment,{children:Ze.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)]}),pt(q)]},q.id):pt(q))}),be&&!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:Ta(be.createdAt)})]}),s.jsx("div",{className:"rounded-xl bg-surface-2/50 p-3",children:Ge(be.content)})]}),!zt&&!be&&Ce?.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:Ta(Ce.report.createdAt)})]}),Ge(Ce.report.content)]}),!!We.length&&s.jsxs("details",{className:"space-y-3",open:We.some(q=>{const at=a.find(qt=>qt.id===q.id);return at&&Fi(at)})||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:[Je,"/",St.length," 项交付已评审"]})]}),s.jsx("div",{className:"divide-y divide-border/15",children:We.map(q=>{const at=a.find(Ve=>Ve.id===q.id),qt=at&&Fi(at);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(Fu,{size:16,className:"mt-0.5 shrink-0 text-primary"}):s.jsx($u,{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:at?Yc(at):q.status==="accepted"?q.completionMode==="reviewed"?"独立评审通过":"已验收":q.status==="closed"?"已关闭":"等待报告"})]}),s.jsx(fi,{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:`${oa} 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(at=>at.id===q)?.title??q}),s.jsx("span",{className:"shrink-0 text-[11px]",children:a.find(at=>at.id===q)?.status==="accepted"?"已验收":"待验收"})]},q))]}),Ee&&!Ce&&!n.scheduledAssignee&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2/50 p-4",children:[s.jsx(Do,{label:"分派给",children:s.jsxs("select",{className:Qs,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||st,onClick:()=>{p({kind:"assign",assigneeSessionId:w})},children:"分派任务"}),st&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"依赖任务验收后可分派。"})]}),!zt&&!Ye.length&&!be&&!Ce?.report&&!Ze.length&&!We.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?"成员明确回复后,报告、问题和交付会出现在这里。":"可在动态中查看分派与决定。"})]})]}),_e==="results"&&s.jsx("div",{className:"space-y-4",children:Ze.length?Ze.map(pt):s.jsx("p",{className:"py-8 text-center text-xs leading-5 text-muted-foreground",children:"还没有交付。方案、结果和独立评审会保存在这里。"})}),_e==="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:[TO[q.kind]??q.kind,q.reportStatus?` · ${Ef[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)," · ",Ta(q.createdAt),q.attemptId&&q.attemptId!==n.activeAttemptId?" · 历史分派":""]}),s.jsx("div",{className:"mt-2",children:Ge(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&&_e!=="activity"&&(!e||!Ne)&&s.jsxs("section",{ref:ce,className:"space-y-2 border-t border-border/20 pt-4",children:[s.jsx(Xh,{paneKey:r,inputKey:`${Ae}:feedback`,active:t,label:Lt?"补充处理说明":"补充说明或修改要求",className:`${Qs} min-h-20 resize-y text-sm leading-6`,disabled:d,value:Se,onUploadChange:$e,onChange:je,placeholder:Lt?"说明已补齐的条件,或调整本次检查范围…":"补充上下文,或写下需要修改的地方…"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",className:si,disabled:d||te>0||!Se.trim(),onClick:()=>{me("comment")},children:[F?.state==="pending"&&F.kind==="comment"?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(r0,{size:13}),F?.state==="pending"&&F.kind==="comment"?"正在发送…":Lt?"发送条件说明":"发送补充"]}),!Lt&&s.jsxs("button",{type:"button",className:si,disabled:d||te>0||!Ce||!Se.trim(),onClick:()=>{me("revise")},children:[F?.state==="pending"&&F.kind==="revise"&&s.jsx(gn,{size:13,className:"animate-spin"}),F?.state==="pending"&&F.kind==="revise"?"正在提交…":"要求修改"]})]}),F&&s.jsx("div",{ref:xe,role:F.state==="error"?"alert":"status",className:`rounded-lg px-3 py-2 text-xs leading-5 ${F.state==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:F.state==="pending"?"正在保存,请稍候…":F.state==="error"?`未确认保存:${F.error}。内容已保留,可重试。`:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:F.kind==="comment"?Lt?"补充已保存,投递结果可在任务管理中查看凭证;成员原报告仍保留,等待新的明确回复。":"补充已保存,投递结果可在任务管理中查看凭证。":"修改要求已保存,等待新结果后可验收。"}),s.jsx("p",{className:"mt-1 line-clamp-2 whitespace-pre-wrap break-words text-foreground/80",children:F.content}),s.jsx("button",{type:"button",className:"mt-1 min-h-11 text-primary underline underline-offset-4",onClick:()=>Oe("activity"),children:"查看任务动态"})]})}),!F&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:Lt?"说明会发送给本次负责人,成员明确回复后状态更新。":"发送补充会保留当前结果;需要更新结果时,请选择“要求修改”。"})]}),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(jf,{task:n}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整目标与验收标准"}),Ge(n.spec),n.acceptance&&Ge(n.acceptance),n.constraints&&Ge(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:si,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:[Ce&&n.workflow?.kind!=="goal"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"任务负责人",className:Qs,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:si,disabled:d||!w||st,onClick:()=>{p({kind:"assign",assigneeSessionId:w,content:Se||void 0})},children:"开始新一轮分派"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:st?"依赖任务验收后可分派。":"新分派保留旧记录,并结束旧问题的回答入口。"})]}),s.jsx(Do,{label:"协调者",children:s.jsxs("select",{className:Qs,disabled:d||n.workflow?.kind==="step",value:n.coordinator?n.memberSessions[Bu(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:`${oa} text-muted-foreground hover:bg-surface-2`,disabled:d,onClick:()=>{p({kind:"close",content:Se||void 0})},children:"关闭此任务"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"关闭会保留历史和成员的终端工作。"})]}),!Ee&&s.jsx("button",{type:"button",className:si,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)," · ",Ta(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?Ta(q.deliveredAt):""}`:q.deliveryStatus==="failed"||q.deliveryStatus==="expired"?"本次消息投递未成功":"等待写入终端",q.report?` · ${Ef[q.report.status]}(${Ta(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?` · ${Ta(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:si,onClick:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(H)).then(()=>R("任务上下文已复制。")).catch(()=>R("复制失败,可导出任务记录。"))},children:"复制上下文"}),s.jsx("button",{type:"button",className:si,onClick:oe,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:ce,className:"space-y-2",children:[s.jsx(Xh,{paneKey:r,inputKey:`${Ae}:feedback`,active:t,label:"跟进要求",className:`${Qs} min-h-20 max-h-32 resize-none text-sm leading-6`,disabled:d,value:Se,onUploadChange:$e,onChange:je,placeholder:"说明哪里不满意,或写下接下来要完成的事…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:si,disabled:d||te>0,onClick:()=>W(!1),children:"取消,保留草稿"}),s.jsxs("button",{type:"button",className:`${cl} ml-auto`,disabled:d||te>0||!Ce||!Se.trim(),onClick:()=>{me("revise")},children:[F?.state==="pending"?s.jsx(gn,{size:14,className:"animate-spin"}):s.jsx(r0,{size:14}),F?.state==="pending"?"正在发送…":"发送并继续跟进"]})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:`${si} flex-1 sm:flex-none`,disabled:d,onClick:Pt,children:Se.trim()?"继续跟进 · 有草稿":"继续跟进"}),_e!=="overview"?s.jsx("button",{type:"button",className:`${cl} ml-auto flex-1 sm:flex-none`,onClick:()=>Oe("overview"),children:mt?"返回当前进展":"返回当前结果"}):(mt||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||te>0||!!Zt||F?.state==="saved"&&F.kind==="revise"&&F.resultId===Ne.id,onClick:()=>{p({kind:"accept",artifactId:Ne.id})},children:[s.jsx(hi,{size:14}),"验收此结果"]}):s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:n.status==="accepted"?n.completionMode==="reviewed"?"已通过独立评审":"已验收":"由独立评审验收"})]}),F&&s.jsx("div",{role:F.state==="error"?"alert":"status",className:`text-xs leading-5 ${F.state==="error"?"text-destructive":"text-primary"}`,children:F.state==="pending"?"正在保存跟进要求…":F.state==="error"?`未确认保存:${F.error}。内容已保留,可重试。`:"跟进要求已保存,等待新结果。"}),!B&&!mt&&Ee&&Zt&&F?.state!=="saved"&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Zt})]})]})}const Df=new Map,H6=e=>`termdock-group-settings:${window.location.origin}:${e}`;function Bf(e){return e.name!==e.savedName||e.rules!==e.savedRules}function Lg(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 _O(e,t){return{...Lg(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 kO(e,t){const r=Lg(e,t),n=H6(e.id);if(Df.has(n))return Df.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:Bf(c)?c:r}catch{return r}}function LO(e,t){const r=H6(e);try{Bf(t)?sessionStorage.setItem(r,JSON.stringify(t)):sessionStorage.removeItem(r),Df.delete(r)}catch{Df.set(r,Bf(t)?t:null)}}function W6(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 Jh(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 IO(){const e=Jh("tab");return e==="automation"||e==="search"?e:"collaboration"}const Fs="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",E1="inline-flex min-h-7 items-center justify-center rounded-md border px-2 py-1 text-[11px] leading-4 font-medium transition",wr="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",ef=new WeakMap;function Cb(e){const[t,r]=b.useState(null),[n,a]=b.useState(!1),c=la(m=>m.drafts),l=b.useCallback(m=>{const x=la.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(la.getState().drafts[m])===JSON.stringify(x))return;const w={...x};y&&ef.set(w,y),la.getState().setDraft(m,w)},[]),p={drafts:c,loadDrafts:l,updateDraft:d};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(_b,{...e,...p,overlayObscured:!!t,onOpenOverlay:r,onClose:()=>{t?a(!0):e.onClose()}}),t&&s.jsx(_b,{...e,...p,overlayOnly:!0,initialFloating:t==="floating",onFloatingChange:void 0,onOpenOverlay:r,onClose:()=>{r(null),n&&e.onClose()}})]})}function _b({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,W]=b.useState(!1),[F,U]=b.useState(t),V=es(Me=>Me.docks[t??"workbench"]),Z=es(Me=>Me.hosts[t??"workbench"]),[ce,xe]=b.useState("docked"),[pe,te]=b.useState(null),[ke,$e]=b.useState({x:16,y:80}),Y=b.useRef(null),Ae=b.useRef(null);b.useEffect(()=>{const Me=Y.current;Me&&(x?(Me.contains(document.activeElement)&&(Ae.current=document.activeElement),Me.inert=!0):(Me.inert=!1,Ae.current?.isConnected&&Ae.current.focus({preventScroll:!0}),Ae.current=null))},[x]),b.useEffect(()=>{if(!m||E)return;const Me=Y.current;Me?.querySelector('button[aria-label="收起展开视图"]')?.focus({preventScroll:!0});const nt=wt=>{if(wt.key!=="Tab"||wt.defaultPrevented||!Me)return;const Rr=Array.from(Me.querySelectorAll('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], summary, [tabindex="0"]')).filter(ht=>!ht.closest("[hidden], [inert]")&&ht.getClientRects().length>0),rn=Rr[0],Ir=Rr.at(-1),ne=!Me.contains(document.activeElement);wt.shiftKey&&(document.activeElement===rn||ne)?(wt.preventDefault(),Ir?.focus()):!wt.shiftKey&&(document.activeElement===Ir||ne)&&(wt.preventDefault(),rn?.focus())};return document.addEventListener("keydown",nt),()=>document.removeEventListener("keydown",nt)},[m,E]);const[lt]=b.useState(()=>document.createElement("div")),Se=b.useRef({x:.5,y:.5}),[ye,_e]=b.useState(null),[je,re]=b.useState(null);b.useEffect(()=>{let Me=!1;return fc().then(nt=>{if(Me)return;const wt=Zy(nt.collaborationPanels?.[$f()],t);wt.position&&(Se.current=wt.position),wt.size&&te(wt.size),v(wt.drafts??{}),m||xe(wt.mode??"docked"),_e(wt)}).catch(()=>{Me||re("面板草稿加载失败,请重新打开面板重试")}),()=>{Me=!0}},[]);const[Oe,Ce]=b.useState(null);b.useEffect(()=>{const Me=nt=>re(String(nt.detail));return window.addEventListener("termdock-panel-save-error",Me),()=>{window.removeEventListener("termdock-panel-save-error",Me),m||es.getState().setDock(t??"workbench",null)}},[]);const Ee=!m&&E&&ce==="docked"&&!!Z;b.useLayoutEffect(()=>(lt.className=Ee?"h-full min-h-0 w-full min-w-0":"contents",(Ee?Z:document.body)?.appendChild(lt),()=>lt.remove()),[lt,Ee,Z]),b.useEffect(()=>{!m&&!E&&es.getState().setDock(t??"workbench",null)},[E]);const Be=async Me=>{if(m||B||Me==="docked"&&!e)return;const nt={sessionId:e,side:"right"};W(!0);try{await bo({mode:Me,...Me==="docked"?{dock:nt}:{}},t),xe(Me),es.getState().setDock(t??"workbench",Me==="docked"?{...nt,...L?{preferredWidth:360}:{}}:null)}catch{re("面板布局保存失败,请重试")}finally{W(!1)}},Ne=b.useRef(!1),le=b.useRef(null),He=b.useCallback((Me,nt)=>{const wt=Y.current?.getBoundingClientRect(),Rr=window.visualViewport,rn=(Rr?.offsetLeft??0)+12,Ir=(Rr?.offsetTop??0)+12;return{x:Math.max(rn,Math.min(Me,rn+(Rr?.width??window.innerWidth)-(wt?.width??440)-24)),y:Math.max(Ir,Math.min(nt,Ir+(Rr?.height??window.innerHeight)-(wt?.height??340)-24))}},[]),[rt,mt]=b.useState(()=>t?"collaboration":IO()),[ue,Ye]=b.useState(()=>new Set([rt])),st=Me=>{mt(Me),Ye(nt=>new Set([...nt,Me])),Pt(null),zt(null),!t&&!m&&Jh("tab",Me)},[Ie,We]=b.useState([]),[Te,H]=b.useState([]),[oe,be]=b.useState([]),[Ze,Je]=b.useState([]),[St,Vt]=b.useState([]),[jt,vt]=b.useState(null),[Zt,Pt]=b.useState(null),[Xt,zt]=b.useState(null);b.useEffect(()=>{if(!Xt)return;const Me=setTimeout(()=>zt(null),5e3);return()=>clearTimeout(Me)},[Xt]);const[Lt,me]=b.useState("loading"),[Ge,pt]=b.useState("loading"),[q,at]=b.useState(null),[qt,Ve]=b.useState(null),[De,er]=b.useState(),[et,Ct]=b.useState(null),Nt=b.useRef(null),gt=b.useRef(null),bt=b.useRef(null),It=t?Ze.find(Me=>Me.id===t)??null:null,yt=b.useRef(!1);b.useEffect(()=>{if(t||Lt!=="loaded"||yt.current)return;yt.current=!0;const Me=Jh("group"),nt=Ze.find(wt=>wt.id===Me)??Ze.find(wt=>e&&wt.sessionIds.includes(e))??Ze[0];U(wt=>wt??nt?.id??null)},[t,Lt,Ze,e]),b.useEffect(()=>{!t&&!m&&F&&Ze.some(Me=>Me.id===F)&&Jh("group",F)},[F,Ze,t,m]);const pr=F?Ze.find(Me=>Me.id===F)??null:Ze[0]??null,nr=!!t&&Lt==="loaded"&&!It,Cr=!!ye||!!je,cn=!m&&E&&ce==="docked"&&!!(V??ye?.dock)&&!Z,Lr=c&&Cr&&!cn&&!!e&&(!t||!!Z||!!pr?.sessionIds.includes(e)||!!t&&(Lt!=="loading"&&!It||!!je));b.useLayoutEffect(()=>{if(!E||Ee||!Lr)return;const Me=()=>{const wt=window.visualViewport;Ce(wt?.height??window.innerHeight);const Rr=Y.current?.getBoundingClientRect();!Rr?.width||!Rr.height||Ne.current||$e(He((wt?.offsetLeft??0)+12+Math.max(0,(wt?.width??window.innerWidth)-Rr.width-24)*Se.current.x,(wt?.offsetTop??0)+12+Math.max(0,(wt?.height??window.innerHeight)-Rr.height-24)*Se.current.y))},nt=new ResizeObserver(Me);return Y.current&&nt.observe(Y.current),window.addEventListener("resize",Me),window.visualViewport?.addEventListener("resize",Me),Me(),()=>{nt.disconnect(),window.removeEventListener("resize",Me),window.visualViewport?.removeEventListener("resize",Me)}},[E,Ee,Lr,He,ye,pe]),b.useLayoutEffect(()=>{if(m)return;const Me=t??"workbench",nt=es.getState();if(nr)nt.docks[Me]&&nt.setDock(Me,null);else if(Cr&&E&&ce==="docked"&&e&&(!t||It)){const wt=nt.docks[Me],Rr=!t||It?.sessionIds.includes(e)?e:St.find(ne=>It?.sessionIds.includes(ne.sessionId)&&!Pu(ne.sessionId))?.sessionId??e,rn=wt??ye?.dock??{sessionId:Rr,side:window.innerWidth<640?"bottom":"right"},Ir={...rn,sessionId:It?.sessionIds.includes(e)?e:rn.sessionId,...L?{preferredWidth:wt?.preferredWidth??360}:{}};(!wt||Ir.sessionId!==wt.sessionId||Ir.preferredWidth!==wt.preferredWidth)&&nt.setDock(Me,Ir),L&&wt&&Ir.sessionId!==wt.sessionId&&bo({dock:{sessionId:Ir.sessionId,side:Ir.side}},t).catch(()=>re("协作位置保存失败,当前面板仍可使用"))}},[nr,It,E,ce,ye,Cr,e,t,V,St]);const ge=async(Me,nt=!1)=>{if(!(B||Me&&!pr)){if(!m&&!Me&&!nt&&V){y("full");return}if(m){nt?d():(R(Me),y(Me?"floating":"full"));return}W(!0);try{await n?.(Me?pr.id:null),R(Me),Me&&ce==="docked"&&e&&es.getState().setDock(t??"workbench",{sessionId:e,side:V?.side??ye?.dock?.side??"right"}),nt&&d()}catch(wt){Pt(`常驻浮窗状态保存失败,请重试:${wt instanceof Error?wt.message:"连接失败"}`)}finally{W(!1)}}},Vr=b.useCallback(Me=>{Je(Me.groups),Vt(Me.sessions),er(Me.peers),Ve(null),me("loaded")},[]);b.useEffect(()=>_y(Vr),[Vr]);const it=b.useCallback(async(Me={})=>{Me.silent||Pt(null),!L&&!gt.current&&(gt.current=$w().then(nt=>{We(nt.automations),H(nt.runs),pt("loaded"),at(null)}).catch(nt=>{pt("error"),at(nt instanceof Error?nt.message:"自动任务加载失败")}).finally(()=>{gt.current=null})),bt.current||(bt.current=Ay().then(nt=>{be(nt),Ct(null)}).catch(()=>{Ct("Agent 命令检测失败;已有会话可继续协作。")}).finally(()=>{bt.current=null})),Nt.current||(me(nt=>nt==="error"?"loading":nt),Nt.current=B1().then(Vr).catch(nt=>{me("error"),Ve(`协作会话加载失败:${nt instanceof Error?nt.message:"请重试"}`)}).finally(()=>{Nt.current=null})),await Promise.all([Nt.current,gt.current])},[Vr,L]);b.useEffect(()=>{it();const Me=window.setInterval(()=>{it({silent:!0})},1e4);return()=>window.clearInterval(Me)},[it]),b.useEffect(()=>{const Me=nt=>{nt.key==="Escape"&&!nt.defaultPrevented&&!E&&d()};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},[d,E]);const dt=Me=>{L&&Me&&Me!==t&&Ze.some(nt=>nt.id===Me)&&a?a(Me).catch(nt=>Pt(nt instanceof Error?nt.message:"无法打开工作区")):U(Me)},sr=async Me=>{await OO(Me)},xn=!E&&!L&&rt==="collaboration",an=async(Me,nt)=>{if(!jt){vt(`open-group:${Me}`),Pt(null);try{await a?.(Me),la.getState().open(Me,nt),d()}catch(wt){Pt(wt instanceof Error?wt.message:"无法打开协作组,请重试")}finally{vt(null)}}};return Ii.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:Me=>{Ee&&Me.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:Lr?void 0:"none",left:ke.x,top:ke.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:Oe?Oe-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))] ${xn?"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)] ${xn?"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:Me=>Me.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:Me=>{!E||Ee||Me.button!==0||Me.target.closest("button, summary")||(le.current={x:Me.clientX,y:Me.clientY,left:ke.x,top:ke.y},Me.currentTarget.setPointerCapture?.(Me.pointerId))},onPointerMove:Me=>{le.current&&$e(He(le.current.left+Me.clientX-le.current.x,le.current.top+Me.clientY-le.current.y))},onPointerUp:()=>{if(!le.current)return;le.current=null;const Me=Y.current?.getBoundingClientRect(),nt=window.visualViewport;Me&&(Se.current=g2(ke.x,ke.y,(nt?.offsetLeft??0)+12,(nt?.offsetTop??0)+12,(nt?.width??window.innerWidth)-Me.width-24,(nt?.height??window.innerHeight)-Me.height-24),bo({position:Se.current},t).catch(()=>re("浮窗位置保存失败,请重新拖动重试")))},onPointerCancel:()=>{le.current=null},children:[s.jsx(E0,{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?"拖动标题移动面板;放在边缘拆分,中央交换":It?.name,children:It?It.name:t?"协作工作区":"Agent 工作台"}),!Ee&&!L&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:E?"引用、文件路径和粘贴优先加入此处":It?"分派任务、回答问题、审阅与验收结果":"自动任务、会话协作与历史搜索"})]}),!Ee&&!m&&L&&rt==="collaboration"&&Ze.length>0&&s.jsx("button",{className:`${wr} shrink-0 text-primary hover:bg-primary/10`,disabled:B,onClick:()=>{ge(!E)},children:E?"展开":"放到终端旁"}),L&&It&&s.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[It.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(yA,{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($o,{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:`${wr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Me=>{Me.currentTarget.closest("details")?.removeAttribute("open"),Be("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?ge(!1,!0):d()},"aria-label":m?"收起展开视图":"关闭",children:s.jsx(Rn,{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":ce==="floating",className:`${E1} ${ce==="floating"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Be("floating")},children:"浮窗"}),s.jsx("button",{type:"button",disabled:B||!e||nr,"aria-pressed":ce==="docked",className:`${E1} ${ce==="docked"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Be("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",Ou,"协作组"],["automation",h0,"自动任务"],["search",Ml,"历史搜索"]].map(([Me,nt,wt])=>s.jsxs("button",{type:"button","aria-pressed":rt===Me,"aria-controls":`workbench-${Me}`,onClick:()=>st(Me),className:`${wr} ${rt===Me?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(nt,{size:14}),wt]},Me))}),rt==="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:`${wr} ml-2`,onClick:()=>{it()},children:"重新加载会话"})]}),!L&&rt!=="search"&&et&&s.jsx("div",{className:"mx-4 mt-3 text-[11px] text-muted-foreground",children:et}),Zt&&s.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:Zt}),Xt&&(!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(hi,{size:13}),Xt]}),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:rt==="automation"?"h-full min-h-0 p-4":"hidden",children:s.jsx(EO,{automations:Ie,runs:Te,agents:oe,sessions:St.filter(Me=>!Pu(Me.sessionId)),activeSessionId:e,loading:Ge==="loading",loadError:q,busy:jt,setBusy:vt,setError:Pt,setNotice:zt,refresh:it,onClose:d})}),ue.has("collaboration")&&s.jsxs("div",{id:"workbench-collaboration",className:rt==="collaboration"?`flex-1 min-h-0 overflow-x-hidden overflow-y-auto overscroll-y-contain ${E?"p-3":"p-4"}`:"hidden",children:[!ye&&!je&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息面板…"}),t&&!It&&s.jsxs("div",{role:"status",className:"space-y-2 text-[11px] text-muted-foreground",children:[s.jsx("p",{children:Lt==="loading"?"正在加载协作组…":Lt==="error"?"协作组加载失败,恢复连接后可重试。":"此协作组暂不可用,已释放分屏位置。草稿和布局偏好仍保留。"}),Lt!=="loading"&&s.jsx("button",{className:wr,onClick:()=>{it()},children:"重新加载"})]}),je&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:je}),ye&&(!t||It)&&s.jsx(RO,{active:rt==="collaboration",notice:Xt,initialDrafts:w,onDraftChange:S,docked:Ee,inputKeySuffix:m?":overlay":"",selectedGroupId:F,setSelectedGroupId:dt,floatingVisible:Lr,floating:E,sessionsState:Lt,groups:Ze,sessions:St,agents:oe,activeSessionId:e,initialGroupId:t,onOpenSession:async Me=>{await sr(Me),E||d()},onOpenTaskSession:sr,onEnterGroup:a,onOpenGroup:an,defaultSessionMode:l,busy:jt,setBusy:vt,setError:Pt,setNotice:zt,refresh:it}),!L&&De&&s.jsx(jO,{peers:De,currentGroupId:F==="new"?void 0:pr?.id,busy:jt,setBusy:vt,setError:Pt,setNotice:zt,onSelectGroup:Me=>{an(Me,"messages")}})]}),ue.has("search")&&s.jsx("div",{id:"workbench-search",className:rt==="search"?"h-full min-h-0 overflow-y-auto overscroll-y-contain p-4":"hidden",children:s.jsx(HO,{active:rt==="search",onClose:d,onNewSession:p,setError:Pt})})]}),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:Me=>{Me.preventDefault(),Ne.current=!0,Me.currentTarget.setPointerCapture(Me.pointerId)},onPointerMove:Me=>{if(!Me.currentTarget.hasPointerCapture(Me.pointerId))return;const nt=window.visualViewport,wt=nt?.width??window.innerWidth,Rr=nt?.height??window.innerHeight;te({width:Math.min(1,Math.max(280,Me.clientX-ke.x)/wt),height:Math.min(1,Math.max(220,Me.clientY-ke.y)/Rr)})},onPointerUp:()=>{Ne.current=!1;const Me=Y.current?.getBoundingClientRect(),nt=window.visualViewport;Me&&(Se.current=g2(ke.x,ke.y,(nt?.offsetLeft??0)+12,(nt?.offsetTop??0)+12,(nt?.width??window.innerWidth)-Me.width-24,(nt?.height??window.innerHeight)-Me.height-24)),pe&&bo({size:pe,position:Se.current},t).catch(()=>re("浮窗大小保存失败,请重新调整重试"))},onPointerCancel:()=>{Ne.current=!1},onKeyDown:Me=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Me.key))return;Me.preventDefault();const nt=Y.current?.getBoundingClientRect(),wt={width:Math.max(.15,Math.min(1,(pe?.width??(nt?.width??400)/window.innerWidth)+(Me.key==="ArrowRight"?.03:Me.key==="ArrowLeft"?-.03:0))),height:Math.max(.15,Math.min(1,(pe?.height??(nt?.height??300)/window.innerHeight)+(Me.key==="ArrowDown"?.03:Me.key==="ArrowUp"?-.03:0)))};te(wt),bo({size:wt},t).catch(()=>re("浮窗大小保存失败,请重试"))},children:s.jsx("span",{"aria-hidden":"true",children:"⌟"})})]})]}),lt)}function EO({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),W=async(F,U,V)=>{p(F),m(null),x(null);try{await U(),await y(),x(V)}catch(Z){m(Z instanceof Error?Z.message:"操作失败")}finally{p(null)}};return L?s.jsx(NO,{agents:r,sessions:n,activeSessionId:a,initial:v,onCancel:()=>{S(null),E(!1),m(null)},onSaved:async(F,U)=>{S(null),E(!1),await y(),x(v?`“${F}”已更新`:U?`“${F}”已创建,将按计划自动运行`:`“${F}”已创建,当前未启用`)},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:wr,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:`${wr} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{S(null),E(!0),x(null)},children:[s.jsx(Us,{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(BA,{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:`${wr} mt-4 bg-primary text-primary-foreground`,onClick:()=>E(!0),children:[s.jsx(Us,{size:13}),"创建第一个任务"]})]}),s.jsx("div",{className:"space-y-2",children:e.map(F=>{const U=t.filter(Z=>Z.automationId===F.id).sort((Z,ce)=>ce.startedAt-Z.startedAt)[0],V=r.find(Z=>Z.command===F.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:F.name}),s.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${F.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:F.enabled?"已启用":"已停用"}),F.lastRunStatus&&s.jsx("span",{className:`text-[10px] ${YO(F.lastRunStatus)}`,children:qO(F.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(h0,{size:11}),GO(F)]}),s.jsx("span",{children:F.enabled&&F.nextRunAt?`下次 ${Pf(F.nextRunAt)}`:"不会自动运行"})]}),s.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:F.targetSessionId?`发送到 ${n.find(Z=>Z.sessionId===F.targetSessionId)?.name??"指定会话"}`:`新建 ${V?.displayName??"Agent"} 会话 · ${F.cwd}`}),s.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:F.prompt}),F.lastRunAt&&s.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",Pf(F.lastRunAt),F.lastRunMessage?` · ${F.lastRunMessage}`:""]})]}),s.jsx("button",{"aria-label":`编辑 ${F.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{S(F),E(!0),x(null)},children:s.jsx(e0,{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===F.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),s.jsx("button",{className:`${wr} bg-surface-elevated text-foreground`,onClick:()=>B(null),children:"取消"}),s.jsxs("button",{disabled:d!==null,className:`${wr} bg-destructive text-destructive-foreground`,onClick:()=>{W(`delete:${F.id}`,()=>Hw(F.id),`“${F.name}”已删除`).then(()=>B(null))},children:[d===`delete:${F.id}`?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(zs,{size:13}),"确认删除"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`${wr} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>B(F.id),children:[s.jsx(zs,{size:13}),"删除"]}),s.jsxs("button",{disabled:d!==null,className:`${wr} ${F.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{W(`toggle:${F.id}`,()=>Ww(F.id,!F.enabled),F.enabled?`“${F.name}”已暂停,不会自动运行`:`“${F.name}”已恢复,将按原计划运行`)},children:[d===`toggle:${F.id}`?s.jsx(gn,{size:13,className:"animate-spin"}):F.enabled?s.jsx(YT,{size:13}):s.jsx(of,{size:13}),F.enabled?"暂停":"恢复"]}),U?.frontendSessionId&&s.jsxs("button",{className:`${wr} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:U.frontendSessionId})),w()},children:[s.jsx(Fc,{size:13}),"打开上次会话"]}),s.jsxs("button",{disabled:d!==null,className:`${wr} bg-primary/15 text-primary`,onClick:()=>{W(`run:${F.id}`,()=>Gw(F.id),`“${F.name}”已投递,可打开会话查看进度`)},children:[d===`run:${F.id}`?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(of,{size:13}),"立即运行"]})]})})]},F.id)})})]})}function NO({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,W]=b.useState(n?.prompt??""),[F,U]=b.useState(n?.targetSessionId??""),[V,Z]=b.useState(n?.targetSessionId?"existing":"new"),[ce,xe]=b.useState(n?.schedule.kind??"interval"),[pe,te]=b.useState(n?.schedule.kind==="interval"?n.schedule.everyMinutes:60),[ke,$e]=b.useState(n?.schedule.kind==="daily"?n.schedule.time:"09:00"),[Y,Ae]=b.useState(n?.schedule.kind==="daily"?n.schedule.weekdays:[1,2,3,4,5]),[lt,Se]=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,_e]=b.useState(!1),[je,re]=b.useState(n?.enabled??!0),[Oe,Ce]=b.useState(!1),Ee=e.find(H=>H.slug===E)??null,Be=Ee?.command??n?.command??"";b.useEffect(()=>{if(!E){const H=n?e.find(oe=>oe.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(""),le=t.find(H=>H.sessionId===F),He=lt?`custom-${ce}`:ce==="interval"?String(pe):Y.length===7?"daily":"workdays",rt=H=>{Se(H.startsWith("custom-")),["15","60","1440","custom-interval"].includes(H)?(xe("interval"),H!=="custom-interval"&&te(Number(H))):(xe("daily"),H==="daily"&&Ae([0,1,2,3,4,5,6]),H==="workdays"&&Ae([1,2,3,4,5]))},mt=async()=>{if(!(Oe||!Te)){Ce(!0),l(null);try{await Xw({id:n?.id,name:Ne,cwd:y,command:V==="new"?Be:"",prompt:B,targetSessionId:V==="existing"&&F||null,enabled:je,schedule:ce==="interval"?{kind:ce,everyMinutes:pe}:{kind:ce,time:ke,weekdays:Y}}),await c(Ne,je)}catch(H){l(H instanceof Error?H.message:"保存失败")}finally{Ce(!1)}}},ue=ce==="interval"?{kind:ce,everyMinutes:pe}:{kind:ce,time:ke,weekdays:Y},[Ye,st]=ke.split(":"),Ie=(H,oe)=>$e(`${H}:${oe}`),We=B.trim()?V==="existing"&&!t.some(H=>H.sessionId===F)?"请选择当前服务的可用会话":V==="new"&&!Be?"请选择可启动的 Agent":ce==="interval"&&(!Number.isInteger(pe)||pe<1||pe>43200)?"间隔需要是 1–43200 分钟的整数":ce==="daily"&&!Y.length?"至少选择一天":"":"请填写任务内容",Te=!We;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:Oe,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(Rn,{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:Oe,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:`${Fs} min-h-24 resize-y`,rows:3,value:B,onChange:H=>W(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:Fs,value:He,onChange:H=>rt(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:"自定义星期"})]})]}),ce==="interval"&<&&s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["每隔多少分钟",s.jsx("input",{className:`${Fs} min-w-0 flex-1`,type:"number",min:1,max:43200,value:pe,onChange:H=>te(Number(H.target.value))})]}),ce==="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(h0,{size:14,className:"mr-2 shrink-0 text-primary"}),s.jsx(kb,{label:"小时",value:Ye,options:24,onChange:H=>Ie(H,st)}),s.jsx("span",{"aria-hidden":"true",className:"px-2 text-[16px] text-muted-foreground",children:":"}),s.jsx(kb,{label:"分钟",value:st,options:60,onChange:H=>Ie(Ye,H)}),s.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:"24 小时制"})]}),lt&&s.jsx("div",{className:"grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((H,oe)=>{const be=Y.includes(oe);return s.jsx("button",{type:"button","aria-pressed":be,"aria-label":`星期${H}`,className:`rounded-lg py-2.5 text-[11px] transition ${be?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>Ae(Ze=>be?Ze.filter(Je=>Je!==oe):[...Ze,oe].sort()),children:H},oe)})}),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(E0,{size:13,className:"shrink-0"}),V==="new"?`每次新建会话 · ${Ee?.displayName??(n?.command?"原 Agent":"暂无可用 Agent")}`:`发送到现有会话 · ${le?.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:`${wr} -ml-2 px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>_e(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:Fs,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:Fs,value:V,onChange:H=>{const oe=H.target.value;Z(oe),oe==="existing"&&!F&&U(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:Fs,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:`${Fs} min-w-0`,value:y,onChange:H=>{v.current=!0,w(H.target.value)},placeholder:"默认使用当前目录"}),s.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${wr} shrink-0 bg-surface-2 text-foreground`,onClick:()=>L(!0),children:[s.jsx(Ru,{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:Fs,value:F,onChange:H=>U(H.target.value),children:[!le&&s.jsx("option",{value:F,children:F?"原目标会话不可用,请重新选择":"请选择会话"}),t.map(H=>s.jsxs("option",{value:H.sessionId,children:[H.name," · ",tf(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:je,onChange:H=>re(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:We||(je?`${n?"下次运行":"首次运行"}:${Pf(VO(ue,Date.now(),n?.createdAt))}`:"保存后暂停,不会自动运行")}),s.jsx("button",{disabled:Oe,className:`${wr} bg-surface-2 text-foreground`,onClick:a,children:"取消"}),s.jsx("button",{title:We||void 0,disabled:Oe||!Te,className:`${wr} bg-primary text-primary-foreground`,onClick:()=>{mt()},children:Oe?"保存中…":n?"保存修改":"创建任务"})]}),s.jsx(tp,{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 kb({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 RO({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:W,onOpenTaskSession:F,onEnterGroup:U,onDockMessages:V,defaultSessionMode:Z,busy:ce,setBusy:xe,setError:pe,setNotice:te,refresh:ke}){const $e=w&&!!B&&!!U&&!e,[Y,Ae]=b.useState(()=>$e?"messages":t);b.useEffect(()=>{e&&Ae(t)},[t,e]);const[lt,Se]=b.useState(!1),[ye,_e]=b.useState(0);b.useEffect(()=>_e(0),[m]);const[je,re]=b.useState(""),[Oe,Ce]=b.useState(()=>new Set),[Ee,Be]=b.useState(""),[Ne,le]=b.useState(()=>new Set),[He,rt]=b.useState(!1),[mt,ue]=b.useState(),[Ye,st]=b.useState([]),[Ie,We]=b.useState(!1),[Te,H]=b.useState(null),oe=Sy(),[be,Ze]=b.useState(null),[Je,St]=b.useState(""),[Vt,jt]=b.useState(!1),[vt,Zt]=b.useState(!1),Pt=b.useRef(null),Xt=b.useRef(null),zt=b.useRef(null),Lt=()=>{zt.current=null,Zt(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>{Xt.current?.isConnected&&Xt.current.getClientRects().length?Xt.current.focus():Array.from(Pt.current?.querySelectorAll('button[aria-label="组设置"], button[aria-label="更多看板操作"], summary[aria-label="更多协作操作"]')??[]).find(K=>K.getClientRects().length)?.focus()}))},[me,Ge]=b.useState(null),[pt,q]=b.useState(new Set),[at,qt]=b.useState(),[Ve,De]=b.useState({}),[er,et]=b.useState(!1),[Ct,Nt]=b.useState(""),[gt,bt]=b.useState(""),[It,yt]=b.useState(""),[pr,nr]=b.useState(""),[Cr,cn]=b.useState(""),Lr=b.useRef(null),ge=d,Vr=(m??S[0]?.id??"")+p,it=b.useRef(!1),dt=m==="new"?null:(m?S.find(K=>K.id===m):S[0])??null,sr=dt?.sessionIds.flatMap(K=>{const Ue=L.find(Et=>Et.sessionId===K);return Ue?[Ue]:[]})??[],[xn,an]=b.useState(0),Me=b.useRef(new Map(Object.entries(c??{}))),[nt]=b.useState(()=>({})),wt=b.useRef(void 0),Rr=b.useRef(!1),rn=b.useRef(be);rn.current=be;const Ir=b.useRef(Je);Ir.current=Je,b.useLayoutEffect(()=>{if(wt.current===dt?.id)return;if(wt.current){const Ue={content:Ir.current,targets:be};Me.current.set(wt.current,Ue),bo({drafts:{[wt.current]:Ue}}).catch(()=>pe("草稿保存失败,请返回该组重试"))}wt.current=dt?.id,Rr.current=!0;const K=Me.current.get(dt?.id??"");St(K?.content??""),Ze(K?.targets??null)},[dt?.id]),b.useEffect(()=>{Ge(null)},[dt?.id]);const ne=b.useRef(null),ht=b.useRef(c);b.useLayoutEffect(()=>{if(ht.current===c)return;ht.current=c;for(const[Ue,Et]of Object.entries(c??{}))ef.get(Et)!==nt&&Me.current.set(Ue,Et);const K=c?.[dt?.id??""];!K||ef.get(K)===nt||K.content===Ir.current&&JSON.stringify(K.targets)===JSON.stringify(rn.current)||(Rr.current=!0,ne.current=null,St(K.content),Ze(K.targets))},[c,dt?.id]);const Ht=b.useCallback(K=>{bo(K).catch(()=>pe("草稿保存失败,请保持面板打开,修改内容后重试"))},[pe]);b.useLayoutEffect(()=>{if(Rr.current){Rr.current=!1;return}if(!dt||wt.current!==dt.id)return;const K={drafts:{[dt.id]:{content:Je,targets:be}}};ef.set(K.drafts[dt.id],nt),l(dt.id,K.drafts[dt.id],nt),ne.current=K;const Ue=setTimeout(()=>{ne.current=null,Ht(K)},400);return()=>{clearTimeout(Ue)}},[dt?.id,Je,be,Ht]),b.useEffect(()=>{const K=()=>{ne.current&&(Ht(ne.current),ne.current=null)},Ue=()=>{document.visibilityState==="hidden"&&K()};return document.addEventListener("visibilitychange",Ue),window.addEventListener("pagehide",K),()=>{document.removeEventListener("visibilitychange",Ue),window.removeEventListener("pagehide",K),K()}},[Ht]),b.useEffect(()=>{if(!(!(w||e)||!n||!y||!dt||vt||Y!=="messages"))return Ty(K=>{Ae("messages"),St(Ue=>Ue+(Ue&&!/\s$/.test(Ue)?`
|
|
158
|
-
`:"")+K.replace(/\r\n?/g,`
|
|
159
|
-
`))},Vr,ge)},[w,e,n,y,dt?.id,ge,Vr,Y,vt]),b.useEffect(()=>{const K=Lr.current;if(!w||!K)return;const Ue=Et=>pe(String(Et.detail));return K.addEventListener("termdock:file-drop-error",Ue),()=>K.removeEventListener("termdock:file-drop-error",Ue)},[w,dt?.id,pe]);const Ot=async K=>{const Ue=dt?.id;pe(null),an(Et=>Et+1);try{const Et=await L0("/tmp",K);if(Et.files.length!==K.length||Et.files.some(tr=>!tr.path))throw new Error("文件路径准备失败,请重试");const kt=Et.files.map(tr=>Dc(tr.path)).join(" ")+" ";if(wt.current===Ue)St(tr=>tr+(tr&&!/\s$/.test(tr)?`
|
|
160
|
-
`:"")+kt);else if(Ue){const tr=Me.current.get(Ue)??{content:"",targets:null},Qr={...tr,content:tr.content+`
|
|
161
|
-
`+kt};Me.current.set(Ue,Qr),Ht({drafts:{[Ue]:Qr}})}}catch(Et){pe(Et instanceof Error?Et.message:"文件上传失败")}finally{an(Et=>Et-1)}},Tr=new Set(L.filter(Sm).map(K=>K.sessionId)),mr=Oe.size,Hr=[...Oe].filter(K=>!Tr.has(K)),_n=QO(dt,L),dr=Ee.trim().toLocaleLowerCase(),bn=L.filter(K=>!dr||[ku(K,L),K.name,K.serviceLabel??"",K.cwd,_m(K.currentTask)].some(Ue=>Ue.toLocaleLowerCase().includes(dr))),hn=Lb(bn),Tn=Lb(_n),ir=K=>!dr&&Ne.has(K),pn=K=>le(Ue=>{const Et=new Set(Ue);return Et.has(K)?Et.delete(K):Et.add(K),Et});b.useEffect(()=>{jt(!1),zt.current!==dt?.id&&Zt(!1),zt.current=null,Se(!1),et(!1),rt(!1),De({}),q(new Set(dt?.sessionIds??[])),bt(dt?.defaultLaunchProfileId??"")},[dt?.id]),b.useEffect(()=>{!Ct&&E[0]&&Nt(E[0].slug)},[E,Ct]),b.useEffect(()=>{st([]),H(null)},[dt?.id]),b.useEffect(()=>{if(!B||!n||w&&!y||!dt){We(!1);return}We(!0);let K=!1,Ue=0,Et=!1;const kt=()=>{if(K||Et||document.hidden||navigator.onLine===!1)return;Et=!0;const Qr=++Ue;i2(dt.id).then(cr=>{!K&&Qr===Ue&&(st(cr.messages),H(null))}).catch(cr=>{!K&&Qr===Ue&&H(cr instanceof Error?cr.message:"消息加载失败")}).finally(()=>{Et=!1,!K&&Qr===Ue&&We(!1)})};kt();const tr=window.setInterval(kt,3e3);return document.addEventListener("visibilitychange",kt),window.addEventListener(nf,kt),window.addEventListener("pageshow",kt),()=>{K=!0,window.clearInterval(tr),document.removeEventListener("visibilitychange",kt),window.removeEventListener(nf,kt),window.removeEventListener("pageshow",kt)}},[dt?.id,n,w,y]),b.useEffect(()=>{!B||dt?.id!==B||it.current||(it.current=!0,Y==="messages"&&Lr.current?.scrollIntoView?.({block:"nearest"}))},[B,dt?.id]);const Pr=async()=>{xe("create-group"),pe(null),te(null);try{if(Hr.length)throw new Error("所选会话已变化,请先清除不可用选择");const K=await ac({name:je,sessionIds:[...Oe]});re(""),Be(""),x(K.group.id),await ke(),te(`“${K.group.name}”已创建。`),r?await r(K.group.id,"messages"):U&&await U(K.group.id)}catch(K){pe(K instanceof Error?K.message:"创建失败")}finally{xe(null)}},qr=dt?.sessionIds.filter(K=>be===null||be.includes(K))??[],Wr=async()=>{if(!dt||ce||xn||!Je.trim()||!qr.length)return;const K=Je,Ue=dt.id;xe("send-message"),pe(null),te(null);try{const Et=await Pw(dt.id,{fromSessionId:null,toSessionIds:be===null?void 0:qr,kind:"message",content:Je});if(wt.current===Ue){const cr=Ir.current,Sn=cr===K?"":cr.startsWith(K)?cr.slice(K.length).replace(/^\n/,""):cr;St(Sn),Ht({drafts:{[Ue]:{content:Sn,targets:rn.current}}})}else{const cr=Me.current.get(Ue);if(cr){const Sn={...cr,content:cr.content===K?"":cr.content.startsWith(K)?cr.content.slice(K.length).replace(/^\n/,""):cr.content};Me.current.set(Ue,Sn),Ht({drafts:{[Ue]:Sn}})}}const kt=await i2(Ue).catch(()=>null);kt&&wt.current===Ue&&st(kt.messages);const tr=Et.deliveries?.filter(cr=>cr.serviceUnavailable).length??0,Qr=Et.deliveries?.filter(cr=>cr.pending>0).length??0;te(tr>0?`已保存消息;${tr} 个接收成员的服务不可达,尚未送达,等待重连`:Qr>0?`已保存消息;${Qr} 个成员等待投递确认`:`消息已送达 ${Et.messages.length} 个会话`)}catch(Et){pe(Et instanceof Error?Et.message:"发送失败")}finally{xe(null)}},fs=async()=>{if(!dt)return;xe(`delete:${dt.id}`),pe(null),te(null);const K=dt.name;try{await Ow(dt.id,mt),x(null),rt(!1),await ke(),te(`“${K}”已删除`)}catch(Ue){pe(Ue instanceof Error?Ue.message:"删除失败")}finally{xe(null)}},Br=async()=>{if(!dt)return;const K=[...pt];xe("save-members"),pe(null),te(null);try{const Ue=await ac({id:dt.id,name:dt.name,sessionIds:K,expectedUpdatedAt:at});x(Ue.group.id),jt(!1),await ke(),te(`“${dt.name}”成员已更新,共 ${K.length} 个会话`)}catch(Ue){pe(Ue instanceof Error?Ue.message:"成员更新失败")}finally{xe(null)}},Mn=async K=>{if(!dt||!dt.sessionIds.includes(K)){Ge(null);return}const Ue=L.find(kt=>kt.sessionId===K)?.name??K,Et=dt.name;xe(`remove-member:${K}`),pe(null),te(null);try{await ac({id:dt.id,name:Et,sessionIds:dt.sessionIds.filter(kt=>kt!==K),expectedUpdatedAt:dt.updatedAt}),Ge(null),q(kt=>new Set([...kt].filter(tr=>tr!==K))),De(kt=>Object.fromEntries(Object.entries(kt).filter(([tr])=>tr!==K))),await ke(),te(`已把“${Ue}”移出“${Et}”`)}catch(kt){pe(kt instanceof Error?kt.message:"移出成员失败")}finally{xe(null)}},Sr=async K=>{if(!dt)return;const Ue=Ve[K]??"";xe(`role:${K}`),pe(null),te(null);try{await zw(dt.id,K,Ue.trim()||null),await ke(),te(Ue.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(Et){pe(Et instanceof Error?Et.message:"定位保存失败")}finally{xe(null)}},Kr=()=>{bt(dt?.defaultLaunchProfileId??"");const K=L.find(Ue=>Ue.sessionId===R)?.cwd??L.find(Ue=>dt?.sessionIds.includes(Ue.sessionId))?.cwd??"";nr(K),yt(""),cn(""),et(!0),jt(!1)},nn=async()=>{if(!(!dt||!Ct||gt&&!dt.launchProfiles?.some(K=>K.id===gt))){xe("spawn-agent"),pe(null),te(null);try{const K=await Fw(dt.id,{agentSlug:dt.launchProfiles?.find(Ue=>Ue.id===gt)?.agentSlug??Ct,...gt||dt.launchProfiles?.length?{launchProfileId:gt}:{},name:It.trim()||void 0,cwd:pr.trim()||void 0,task:Cr.trim()||void 0,mode:Z});et(!1),await ke(),te(`“${K.session.name}”已创建并加入“${K.group.name}”`)}catch(K){pe(K instanceof Error?K.message:"Agent Session 创建失败")}finally{xe(null)}}},Fr=UO(Ye,L),ks=K=>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:!Sm(K),checked:Oe.has(K.sessionId),onChange:()=>Ce(Ue=>{const Et=new Set(Ue);return Et.has(K.sessionId)?Et.delete(K.sessionId):Et.add(K.sessionId),Et})}),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:ku(K,L)}),s.jsx(Cm,{session:K}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:tf(K)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:K.currentTask?`${_m(K.currentTask)} · ${K.cwd}`:K.cwd||K.capability||"终端会话"})]})]},K.sessionId),Or=K=>{const Ue=Ve[K.sessionId]??"",Et=dt?.roles?.[K.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:!dt?.sessionIds.includes(K.sessionId)&&!Sm(K),checked:pt.has(K.sessionId),onChange:()=>q(kt=>{const tr=new Set(kt);return tr.has(K.sessionId)?tr.delete(K.sessionId):tr.add(K.sessionId),tr})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] text-foreground",children:K.name}),s.jsx(Cm,{session:K}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[tf(K)," · ",K.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":`${K.name} 的定位`,className:`${Fs} min-h-8 py-1 text-[10px]`,value:Ue,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:kt=>De(tr=>({...tr,[K.sessionId]:kt.target.value}))}),s.jsx("button",{"aria-label":`保存 ${K.name} 的定位`,title:Ue.trim()===Et?"定位未变化":"保存此成员的定位",disabled:ce!==null||Ue.trim()===Et,className:`${wr} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{Sr(K.sessionId)},children:ce===`role:${K.sessionId}`?s.jsx(gn,{size:12,className:"animate-spin"}):s.jsx(hi,{size:12})})]})]},K.sessionId)},Xr=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e||$e?"看板":"目标"],["messages","成员与消息"]].map(([K,Ue])=>s.jsxs("button",{type:"button","aria-label":Ue,"aria-pressed":Y===K,className:`${wr} min-h-11 ${Y===K?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:Et=>{if($e&&K==="tasks"){U?.(dt.id).catch(Qr=>pe(Qr instanceof Error?Qr.message:"无法打开看板"));return}const kt=Et.currentTarget.closest("[data-collaboration-views]"),tr=Et.currentTarget;Ae(K),requestAnimationFrame(()=>{const Qr=document.activeElement;Qr!==tr&&Qr!==document.body&&Qr?.isConnected&&!Qr.closest("[hidden]")||Array.from(kt?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(cr=>cr.getAttribute("aria-pressed")==="true"&&!cr.closest("[hidden]"))?.focus()})},children:[e&&K==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:Ue})]}):Ue,!e&&K==="tasks"&&ye>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[ye," 待处理"]})]},K))}),fn=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":vt,className:`${wr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:K=>{Xt.current=K.currentTarget,Zt(Ue=>!Ue),pe(null),te(null)},children:[s.jsx(e0,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{ref:Pt,className:e?"flex min-h-0 flex-1 flex-col gap-3":$e?void 0:"space-y-3",children:[Te&&oe==="ready"&&!sf(Te)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",Te]}),Te&&sf(Te)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?vt?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[!B&&m!=="new"&&S.length>0&&s.jsx("div",{hidden:vt,children:s.jsx(pO,{groups:S,sessions:L,busy:ce!==null,onOpen:(K,Ue)=>{r?.(K,Ue)},onSettings:(K,Ue)=>{zt.current=K,x(K),Xt.current=Ue,Zt(!0),pe(null),te(null)},onCreate:()=>{x("new"),rt(!1),te(null)}})}),!B&&(m==="new"||vt)&&S.length>0&&s.jsx("button",{type:"button",className:`${wr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{vt?Lt():x(S[0].id)},children:"返回协作组"}),vt&&dt&&s.jsx(MO,{group:dt,agents:E,activeSessionId:R,sessions:L,busy:ce,setBusy:xe,setError:pe,setNotice:te,refresh:ke,onClose:Lt},dt.id),!B&&v!=="loaded"&&!S.length&&s.jsx("p",{role:"status",className:"py-5 text-xs text-muted-foreground",children:v==="loading"?"正在加载协作组与会话…":"会话加载失败,请重试"}),!dt&&(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] ${mr>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",mr," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:Fs,value:je,onChange:K=>re(K.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:["复用已有会话(选填) · 已选 ",mr," 个"]}),L.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(Ml,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${Fs} pl-8`,value:Ee,onChange:K=>Be(K.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:[hn.length<=1?bn.map(ks):hn.map(K=>{const Ue=ir(K.key);return s.jsxs("div",{children:[s.jsx(Ib,{label:K.label,count:K.sessions.length,collapsed:Ue,onToggle:()=>pn(K.key)}),!Ue&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(ks)})]},K.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&&bn.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),Hr.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",Hr.length," 个所选会话暂不可用。",s.jsx("button",{className:wr,onClick:()=>Ce(K=>new Set([...K].filter(Ue=>Tr.has(Ue)))),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] ${mr<2?"text-muted-foreground":"text-primary"}`,children:je.trim()?"创建后进入成员消息,看板可随时使用":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[S.length>0&&s.jsx("button",{className:`${wr} bg-surface-2 text-foreground`,onClick:()=>x(S[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:ce!==null||!je.trim()||Hr.length>0,className:`${wr} bg-primary text-primary-foreground`,onClick:()=>{Pr()},children:[ce==="create-group"?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(Us,{size:13}),"创建协作组"]})]})]})]})]}),dt&&B&&s.jsxs("div",{"data-collaboration-views":!0,hidden:vt,className:e?`${vt?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:$e?void 0:"space-y-3",children:[!$e&&(!e||Y==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[Xr,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||ce!==null,className:`${wr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{xe("dock-messages"),pe(null),V?.().catch(K=>pe(K instanceof Error?K.message:"消息面板打开失败,草稿已保留")).finally(()=>xe(null))},children:[s.jsx(Fc,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"放到终端旁"})]}),fn]})]}),!$e&&Y==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:sr.map(K=>s.jsx("button",{type:"button","aria-pressed":K.sessionId===R,title:`${K.name} · ${K.cwd||"终端会话"}`,className:`${wr} min-h-9 shrink-0 ${K.sessionId===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{F(K).catch(Ue=>pe(Ue instanceof Error?Ue.message:"无法打开终端"))},children:ku(K,sr)},K.sessionId))}),!$e&&s.jsx("div",{hidden:Y!=="tasks",className:e?`${Y==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(CO,{paneKey:d?Vr:void 0,boardNavigation:e?Xr:void 0,boardSettings:e?fn:void 0,board:e,group:dt,sessions:L,agents:E,defaultCwd:L.find(K=>K.sessionId===R)?.cwd??void 0,onTeamReady:ke,active:n&&!vt&&Y==="tasks"&&(!w||y),onAttentionChange:_e,onManageMembers:()=>Ae("messages"),onOpenSession:F},dt.id)}),s.jsxs("div",{hidden:Y!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>t0(Vr),onPointerDownCapture:()=>t0(Vr),"data-termdock-terminal-dropzone":w?R??"collaboration-composer":void 0,onDragOver:K=>{w&&K.preventDefault()},onDrop:K=>{if(!w)return;const Ue=Array.from(K.dataTransfer.files);if(!(Ue.length&&xo()))if(K.preventDefault(),K.stopPropagation(),Ue.length)Ot(Ue);else{const Et=K.dataTransfer.getData("text/plain")||K.dataTransfer.getData("text/uri-list");Et&&St(kt=>kt+(kt?`
|
|
162
|
-
`:"")+Et)}},ref:Lr,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:[dt.name," · 发送给成员"]}),s.jsxs("div",{className:w?"space-y-2":"mt-2 space-y-2",children:[$e&&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:K=>{K.key==="Escape"&&(K.currentTarget.removeAttribute("open"),K.currentTarget.querySelector("summary")?.focus(),K.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($o,{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:`${wr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),U?.(dt.id).catch(Ue=>pe(Ue instanceof Error?Ue.message:"无法打开看板"))},children:[s.jsx(Fc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":lt,className:`${wr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Se(Ue=>!Ue)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":vt,className:`${wr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Xt.current=K.currentTarget,Zt(!0),pe(null),te(null)},children:[s.jsx(e0,{size:14}),"组设置"]})]})]})]}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:$e?"sr-only":"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...dt.sessionIds.map(K=>({id:K,label:(()=>{const Ue=sr.find(Et=>Et.sessionId===K);return Ue?ku(Ue,sr):void 0})()??`${K.slice(0,8)}(离线)`}))].map(({id:K,label:Ue})=>{const Et=K==="*"?be===null:be?.includes(K)??!1,kt=L.find(tr=>tr.sessionId===K);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":Et,onClick:()=>Ze(tr=>K==="*"?null:tr?.includes(K)?tr.filter(Qr=>Qr!==K):[...tr??[],K]),className:`${E1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Et?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Et&&s.jsx(hi,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:Ue})]}),kt&&s.jsx("button",{type:"button","aria-label":`打开 ${Ue} 的终端`,title:`打开 ${Ue} 的终端`,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:()=>{W(kt).catch(tr=>pe(tr instanceof Error?tr.message:"无法打开会话"))},children:s.jsx(Fc,{size:12})})]},K)})})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:$e?"sr-only":void 0,children:"内容"}),s.jsx("textarea",{onKeyDown:K=>{K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&!K.nativeEvent.isComposing&&K.keyCode!==229&&(K.preventDefault(),Wr())},onPaste:K=>{const Ue=Array.from(K.clipboardData.files);Ue.length&&(K.preventDefault(),Ot(Ue))},className:`${Fs} min-h-16 max-h-48 resize-y`,value:Je,onChange:K=>St(K.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:xn>0?"正在准备文件路径…":w&&a?a:dt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:ce!==null||xn>0||!Je.trim()||!qr.length,className:`${wr} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Wr()},children:[ce==="send-message"?s.jsx(gn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:$e&&!lt,open:$e?lt:void 0,onToggle:K=>{$e&&Se(K.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:["管理成员、角色与删除 · ",dt.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:dt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[dt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:W6(dt.id)})]})]}),He?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${wr} bg-surface-2 px-2 text-foreground`,onClick:()=>rt(!1),children:"取消"}),s.jsxs("button",{disabled:ce!==null,className:`${wr} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{fs()},children:[ce===`delete:${dt.id}`?s.jsx(gn,{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:`${wr} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{q(new Set(dt.sessionIds)),qt(dt.updatedAt);const K=!Vt;jt(K),K&&De(Object.fromEntries(dt.sessionIds.map(Ue=>[Ue,dt.roles?.[Ue]??""]))),et(!1)},children:[s.jsx(e0,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${wr} px-2 text-primary hover:bg-primary/10`,onClick:Kr,children:[s.jsx(Us,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${dt.name}`,title:"删除协作组",disabled:ce!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{ue(dt.updatedAt),rt(!0)},children:s.jsx(zs,{size:14})})]})]}),He&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",dt.name,"”协作组及其协作记录,",dt.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:dt.sessionIds.map(K=>{const Ue=L.find(tr=>tr.sessionId===K),Et=dt.roles?.[K],kt=Ue?.name??K;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${me===K?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!Ue,onClick:()=>Ue&&void W(Ue).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 ${Ue&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(Ue.status)&&Ue.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:kt}),Ue&&s.jsx(Cm,{session:Ue}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:Ue?tf(Ue):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Et?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Et]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,Ue?s.jsx("span",{className:"min-w-0 truncate",children:_m(Ue.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${kt} 移出协作组`,"aria-expanded":me===K,title:"移出协作组",disabled:ce!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${me===K?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>Ge(me===K?null:K),children:s.jsx(zs,{size:13})})]},K)})}),me&&dt.sessionIds.includes(me)&&(()=>{const K=L.find(Et=>Et.sessionId===me)?.name??me,Ue=ce===`remove-member:${me}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${K}`,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:`把“${K}”移出“${dt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${wr} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Ge(null),children:"取消"}),s.jsxs("button",{disabled:ce!==null,className:`${wr} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{Mn(me)},children:[Ue?s.jsx(gn,{size:12,className:"animate-spin"}):s.jsx(zs,{size:12}),"移出"]})]})]})})(),Vt&&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:["已选 ",pt.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Tn.length<=1?_n.map(Or):Tn.map(K=>{const Ue=ir(K.key);return s.jsxs("div",{children:[s.jsx(Ib,{label:K.label,count:K.sessions.length,collapsed:Ue,onToggle:()=>pn(K.key)}),!Ue&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(Or)})]},K.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${wr} bg-surface-2 text-foreground`,onClick:()=>{jt(!1),De({})},children:"取消"}),s.jsxs("button",{disabled:ce!==null||v!=="loaded",className:`${wr} bg-primary text-primary-foreground`,onClick:()=>{Br()},children:[ce==="save-members"?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(hi,{size:13}),"保存成员"]})]})]}),er&&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(mO,{group:dt,value:gt,onChange:bt,disabled:ce!==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:Fs,disabled:!!gt,value:dt.launchProfiles?.find(K=>K.id===gt)?.agentSlug??Ct,onChange:K=>Nt(K.target.value),children:E.map(K=>s.jsxs("option",{value:K.slug,children:[K.displayName,K.isPlugin?" · Plugin":""]},K.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:Fs,value:It,onChange:K=>yt(K.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:Fs,value:pr,onChange:K=>nr(K.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:`${Fs} min-h-16 resize-y`,value:Cr,onChange:K=>cn(K.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${wr} bg-surface-2 text-foreground`,onClick:()=>et(!1),children:"取消"}),s.jsxs("button",{disabled:ce!==null||!Ct||!!gt&&!dt.launchProfiles?.some(K=>K.id===gt),className:`${wr} bg-primary text-primary-foreground`,onClick:()=>{nn()},children:[ce==="spawn-agent"?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(E0,{size:13}),"创建并加入"]})]})]})]})]},dt.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:[Fr.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[Fr.map(K=>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:K.responseKind==="ack"?"收到确认":K.responseKind==="progress"?"进展":K.responseKind==="result"?"结果":$O(K.kind)}),s.jsx("span",{children:K.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:K.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(K.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:K.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:K.status==="pending"?"已入队 · 等待投递":K.status==="failed"?"投递失败":K.status==="expired"?"消息已过期,未继续投递":K.status==="stored"?"答复已持久保存 · 供后台接收":"已写入接收方终端 · 等待接手确认"}),(K.task||K.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(K.task??{failure_reason:K.failureReason},null,2)})]})]},K.key)),Fr.length===0&&s.jsx(ZO,{text:Ie?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function MO({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)&&!Pu(Y.sessionId)),[y,w]=b.useState(()=>kO(e,r&&x.some(Y=>Y.sessionId===r)?r:"")),v=b.useRef(y),[S,L]=b.useState(null),E=Y=>{const Ae={...v.current,...Y};v.current=Ae,LO(e.id,Ae),w(Ae)},{name:R,rules:B,savedName:W,savedRules:F,rulesVersion:U,rulesMemberId:V}=y,Z=Bf(y),ce=new TextEncoder().encode(B).length,xe=x.some(Y=>Y.sessionId===V),pe=async()=>{if(!(a||!R.trim())){c("group-name"),l(null),d(null);try{const Y=await ac({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===F?{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 Jd&&Y.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"改名失败")}finally{c(null)}}},te=async()=>{if(!(a||!xe||ce>8192)){c("group-rules"),l(null),d(null);try{const Y=await Uw(e.id,{sessionId:V,text:B,expectedVersion:U});L(null),E({savedName:Y.group.name,...R===W?{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 Jd&&Y.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"群规保存失败")}finally{c(null)}}},ke=()=>{E(Lg(e,V)),L(null),l(null)},$e=async()=>{if(!a){c("group-latest"),l(null),d(null),L(null);try{const Ae=(await B1()).groups.find(lt=>lt.id===e.id);if(!Ae)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");L(Ae)}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(Rn,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:Fs,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()===W,className:`${wr} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{pe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(gO,{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:Fs,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:`${Fs} min-h-24 resize-y`,value:B,maxLength:8192,disabled:!!a,onChange:Y=>E({rules:Y.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!xe&&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] ${ce>8192?"text-destructive":"text-muted-foreground"}`,children:ce>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!S||!xe||ce>8192||B===F,className:`${wr} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{te()},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:`${wr} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{$e()},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(Ae=>Ae.sessionId===Y)?.name??W6(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:`${wr} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{E(_O(v.current,S)),L(null),l(null),d("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${wr} 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:`${wr} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:ke,children:[s.jsx(gn,{size:12}),"重新载入",Z&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${wr} min-h-9 bg-surface text-foreground`,onClick:m,children:Z?"关闭并保留草稿":"关闭"})]})]})}function jO({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 qw(E):await Yw(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(DO,{service:E})]}),E.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${E.origin}`,className:`${wr} 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(zs,{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:zO(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:`${wr} min-h-9 text-muted-foreground`,onClick:()=>p(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!E.groups?.length,className:`${wr} 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:`${wr} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:Vw,children:[s.jsx(gn,{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:`${wr} 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:`${wr} 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 DO({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 Sm(e){return!Pu(e.sessionId)||e.serviceConnected!==!1}function BO(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:Pu(e.sessionId)?.origin??""}function Lb(e){const t=new Map;for(const r of e){const n=BO(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 Ib({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 QO(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,...Pu(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function Cm({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 tf(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":FO(e.status)}function PO(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 OO(e){e.sessionId.startsWith("remote:")?await b6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function FO(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function _m(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return Qf(t.prompt)||"暂无任务摘要"}catch{}return Qf(e)||"暂无任务摘要"}function $O(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function UO(e,t){const r=new Map(t.map(a=>[a.sessionId,PO(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 zO(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 km({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 HO({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,W]=b.useState(null),[F,U]=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,te=new AbortController;let ke;W(null),R(!0);const $e=async()=>{try{const Y=await Zw(a.trim(),w,te.signal);if(pe!==Z.current)return;d(Y.results),m(Y.total??Y.results.length),y(Y.index),Y.index?.building&&(ke=window.setTimeout(()=>{$e()},2500))}catch(Y){pe===Z.current&&!te.signal.aborted&&W(Y instanceof Error?Y.message:"搜索失败")}finally{pe===Z.current&&R(!1)}};return ke=window.setTimeout(()=>{$e()},a.trim()?250:0),()=>{window.clearTimeout(ke),te.abort(),++Z.current}},[e,a,w,S]);const ce=pe=>{n(null),c(pe),d([]),m(0),v(50)},xe=async pe=>{if(!F){if(pe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:pe.sessionId})),t();return}if(!(!pe.nativeKey&&!pe.resumeHistoryId)){U(pe.sessionId),n(null);try{const te=pe.nativeKey?await Kw(pe.nativeKey):await ky(pe.resumeHistoryId);if("sessionId"in te&&te.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:te.sessionId}));else if(te.command)r({mode:"shell",cwd:te.cwd,command:te.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(te){n(te instanceof Error?te.message:"恢复失败")}finally{U(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(Ml,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:V,maxLength:512,className:`${Fs} pl-9 pr-9`,value:a,onChange:pe=>ce(pe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),E?s.jsx(gn,{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:()=>ce(""),children:s.jsx(Rn,{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:`${wr} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>L(pe=>pe+1),children:[s.jsx(gn,{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 te=pe.live||!!(pe.nativeKey||pe.resumeHistoryId),ke=F===pe.sessionId?"正在恢复…":pe.live?"打开会话":te?"恢复会话":"仅供查阅",$e=pe.source==="codex"||pe.source==="claude"?pe.snippet:WO(pe),Y=pe.source==="codex"?"Codex 历史":pe.source==="claude"?"Claude 历史":"终端记录",Ae=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(km,{value:pe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(km,{value:pe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${pe.live?"text-[var(--success)]":te?"text-primary":"text-muted-foreground"}`,children:ke})]}),$e&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(km,{value:$e,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Y," · ",Pf(pe.updatedAt),a.trim()?` · ${pe.matchCount>=999?"999+":pe.matchCount} 处匹配`:"",te?"":" · 没有可恢复记录"]}),pe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:pe.agentNativeSessionId})]});return te?s.jsx("button",{disabled:!!F,onClick:()=>{xe(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:Ae},pe.nativeKey||pe.sessionId):s.jsx("article",{className:"px-2 py-3",children:Ae},pe.sessionId)})}),p>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:E,className:`${wr} 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:`${wr} 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:`${wr} mt-3 bg-surface-2 text-foreground`,onClick:()=>ce(""),children:"查看最近会话"})]})]})}function Qf(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 WO(e){let t=Qf(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return Qf(t)}function GO(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 VO(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 Pf(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function qO(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function YO(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function ZO({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 KO({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=zr(),[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,W=(w?.offsetTop??0)+(w?.height??window.innerHeight)-8,F=Math.max(0,Math.min(256,B)),U=Math.max(0,L.top-R-4),V=Math.max(0,W-L.bottom-4),Z=U>=180||U>=V;Object.assign(y.style,{width:`${F}px`,left:`${Math.max(E,Math.min(L.right-F,E+B-F))}px`,top:`${Z?L.top-4:L.bottom+4}px`,maxHeight:`${Z?U: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(mS,{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($o,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&Ii.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 Qd=64,Eb=10,XO=120;function JO({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?Qd: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?Qd:0,offset:t?Qd: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>=XO||Math.abs(E)>Eb){p.current=null;return}if(Math.abs(L)<=Eb)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(Qd,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>=Qd/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(zs,{size:14}),a]})}),e]})}const Nb="recoverable-tmux";function eF({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=zr(),d=Gt(R=>R.collapsedGroups.has(Nb)),p=Gt(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(Nb),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(fi,{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(gn,{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,W=Yu(R.cwd??null),F=r===R.name,U=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||U,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:F?s.jsx(Cn,{size:12,className:"animate-spin"}):s.jsx(Uu,{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,W].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(F?"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(Rn,{size:12})})]}),U&&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)})})]})}function tF(e,t){return zy(e,t)}function Pd(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 Od(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 Rb(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 rF({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(OP,{status:e,detail:t,needsReview:r,inCopyMode:n})}function Mb({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:W,onOpenQuota:F,updateState:U,updateActionPending:V=!1,onConfirmUpdateRestart:Z,onRetryUpdate:ce,serverHealthState:xe,tmuxAvailable:pe=!0,defaultSessionMode:te="shell",push:ke,pinned:$e,onTogglePinned:Y,recoverableTmuxSessions:Ae=[],recoverableTmuxSessionsLoading:lt=!1,onRefreshRecoverableTmuxSessions:Se,onCloseRecoverableTmuxSession:ye}){const{t:_e}=zr(),[,je]=b.useState(0),[re,Oe]=b.useState(null),[Ce,Ee]=b.useState(!1),[Be,Ne]=b.useState(!1),[le,He]=b.useState(null),rt=b.useRef(!1),mt=b.useRef(0),ue=b.useCallback(G=>{G||(mt.current+=1),Ee(G)},[]),[Ye,st]=b.useState(!1),Ie=la(G=>G.groupId),[We,Te]=b.useState({}),H=Ye||Object.keys(We).length>0,oe=b.useRef(!1),be=b.useRef(!1),[Ze,Je]=b.useState(null);b.useEffect(()=>{let G=!1;return fc().then(Le=>{G||oe.current||Te(Object.fromEntries(Ky(Le.collaborationPanels?.[$f()]).map(Ke=>[Ke,!0])))}).catch(()=>{}),()=>{G=!0}},[]);const St=async(G,Le)=>{oe.current=!0,await bo({floatingGroupId:Le},G),Te(Ke=>({...Ke,[G]:Le!==null}))},[Vt,jt]=b.useState([]),[vt,Zt]=b.useState(!1),[Pt,Xt]=b.useState(null),[zt,Lt]=b.useState(null),[me,Ge]=b.useState(null),[pt,q]=b.useState(null),at=_u(G=>G.tasks),qt=_u(G=>G.allTasks),[Ve,De]=b.useState(0),[er,et]=b.useState(null),Ct=b.useRef(!1),[Nt,gt]=b.useState({}),bt=_u(G=>G.error),[It,yt]=b.useState(!1);b.useEffect(()=>{const G=()=>{document.hidden||_u.getState().refresh()};G();const Le=window.setInterval(G,5e3);return document.addEventListener("visibilitychange",G),()=>{clearInterval(Le),document.removeEventListener("visibilitychange",G)}},[]);const pr=async G=>(ue(!1),oe.current=!0,G?(la.getState().open(G),Fr(),!0):(st(!0),Fr(),!0)),nr=uf(G=>G.collaborationGroups),Cr=uf(G=>G.setCollaborationGroups),[cn,Lr]=b.useState({mode:te}),{preference:ge,agents:Vr,detecting:it,refresh:dt,selectAgent:sr}=fO(),xn=b.useRef(null),an=!!(U?.latestVersion&&["installing","ready","restarting","error"].includes(U.status)),Me=!!xe?.attention,nt=[_e("sidebar.moreActions"),Me?_e("sidebar.serverAttention"):null,an&&U?.latestVersion?_e("sidebar.updateAvailable",{version:U.latestVersion}):null].filter(Boolean).join(": "),wt=Gt(G=>G.groupByFolder),Rr=Gt(G=>G.collapsedGroups),rn=Gt(G=>G.toggleGroupCollapsed),Ir=b.useRef(null),ne=b.useRef(null),ht=b.useRef(null),Ht=b.useRef(0),Ot=b.useRef(!1),Tr=b.useRef(null),mr=b.useRef(null),[Hr,_n]=b.useState(!1),dr=b.useRef([]),bn=b.useRef(null),hn=b.useRef(null),Tn=b.useRef(new Set),ir=b.useRef(null),pn=b.useMemo(()=>new Set(v.flatMap(G=>G.sessionIds)),[v]),Pr=b.useMemo(()=>new Map(a.map(G=>[G.id,G])),[a]),qr=b.useMemo(()=>tF(nr,new Set(Pr.keys())),[nr,Pr]),Wr=b.useCallback(async()=>{const G=++Ht.current;try{const Le=await B1();if(G!==Ht.current)return;Cr(Array.isArray(Le.groups)?Le.groups:[])}catch{}},[]);b.useEffect(()=>_y(G=>Cr(G.groups)),[]),b.useEffect(()=>{Wr();const G=window.setInterval(()=>{Wr()},1e4),Le=()=>{Wr()};return window.addEventListener("focus",Le),()=>{Ht.current+=1,window.clearInterval(G),window.removeEventListener("focus",Le)}},[Wr]),b.useEffect(()=>{(e||!H)&&Wr()},[H,e,Wr]);const fs=b.useCallback(()=>{dr.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(G=>{const Le=G.dataset.collaborationMember??"",Ke=G.hasAttribute("data-collaboration-background"),ct=G.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!Le&&!Ke||!ct)return[];const qe=[];for(let At=G.parentElement;At;At=At.parentElement)qe.push({element:At,top:At.scrollTop,left:At.scrollLeft});return[{element:G,sessionId:Le,groupId:ct,background:Ke,rect:G.getBoundingClientRect(),scrollParents:qe}]})},[]),Br=b.useCallback((G,Le)=>{if(!Ot.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(N=>N.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(N=>N.removeAttribute("data-drop-active"));const ct=document.elementsFromPoint(G,Le).map(N=>N.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(ct?.dataset.collaborationGroup){ct.dataset.dropActive="true",hn.current={kind:"collaboration",groupId:ct.dataset.collaborationGroup,background:!0};return}const qe=dr.current.find(N=>{if(N.sessionId===mr.current||!N.element.isConnected)return!1;const $=N.scrollParents.reduce((ie,Qe)=>ie+Qe.element.scrollLeft-Qe.left,0),ee=N.scrollParents.reduce((ie,Qe)=>ie+Qe.element.scrollTop-Qe.top,0);return G>=N.rect.left-$&&G<=N.rect.right-$&&Le>=N.rect.top-ee+N.rect.height*.25&&Le<=N.rect.bottom-ee-N.rect.height*.25});if(qe?.background){qe.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),hn.current={kind:"collaboration",groupId:qe.groupId,background:!0};return}if(qe&&!v.find($=>$.sessionIds.includes(qe.sessionId))?.sessionIds.includes(mr.current??"")){qe.element.dataset.dropActive="true",hn.current={kind:"split",sessionId:qe.sessionId,groupId:qe.groupId};return}const At=document.elementsFromPoint(G,Le).filter(N=>{const $=N.closest("[data-rfd-draggable-id]");return!$||!["session:","split-member:","collaboration-member:"].some(ee=>$.dataset.rfdDraggableId===`${ee}${mr.current}`)}),Rt=At.map(N=>N.closest("[data-collaboration-group]")).find(N=>N?.dataset.collaborationGroup);if(Rt?.dataset.collaborationGroup){const N=Rt.dataset.collaborationGroup,$=At.map(ze=>ze.closest("[data-collaboration-split]")).find(Boolean),ee=At.map(ze=>ze.closest("[data-collaboration-member]")).find(Boolean),ie=ee?.dataset.collaborationMember??$?.dataset.splitAnchor,Qe=N===Tr.current&&v.some(ze=>ze.sessionIds.includes(ie??"")&&ze.sessionIds.includes(mr.current??""));if(ie&&!Qe&&(N!==Tr.current||!ee&&$)){Rt.dataset.dropActive="true";const ze=ee??$;ze&&(ze.dataset.dropActive="true"),hn.current={kind:"split",sessionId:ie,groupId:N}}else{const ze=At.some(xt=>xt.closest("[data-collaboration-background]"));(N!==Tr.current||ze)&&(Rt.dataset.dropActive="true"),hn.current={kind:"collaboration",groupId:N,background:ze}}return}const ot=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(N=>N.dataset.sidebarEntityListId===bn.current).find(N=>{const $=N.getBoundingClientRect();return G>=$.left&&G<=$.right&&Le>=$.top-8&&Le<=$.bottom+8});if(!ot){hn.current=null;return}const Ft=Array.from(ot.children).filter(N=>N instanceof HTMLElement&&N.hasAttribute("data-sidebar-entity-index")),hr=Ft.findIndex(N=>{const $=N.getBoundingClientRect();return Le<$.top+$.height/2}),Kt=hr<0?Ft.length:hr;hn.current={kind:"list",listId:ot.dataset.sidebarEntityListId??"",index:Kt};const z=Array.from(ot.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(N=>N.dataset.splitExitDropIndex===String(Kt));z instanceof HTMLElement&&(z.dataset.active="true")},[v]);b.useEffect(()=>{const G=Ke=>Br(Ke.clientX,Ke.clientY),Le=Ke=>{const ct=Ke.touches[0];ct&&Br(ct.clientX,ct.clientY)};return window.addEventListener("pointermove",G),window.addEventListener("touchmove",Le,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("touchmove",Le)}},[Br]);const Mn=b.useCallback((G,Le)=>{try{G(Le)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach(Ke=>{delete Ke.dataset.sidebarDragging}),Ot.current=!1,dr.current=[],_n(!1),Tr.current=null,mr.current=null,bn.current=null,hn.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ke=>Ke.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ke=>Ke.removeAttribute("data-drop-active"))}},[]),Sr=b.useMemo(()=>a.filter(G=>!pn.has(G.id)),[a,pn]),Kr=b.useMemo(()=>{let G=0;for(const Le of a)l.get(Le.id)?.agentStatus==="working"&&(G+=1);return G},[a,l]);b.useLayoutEffect(()=>{const G=Ir.current,Le=ne.current;if(!e||!G||!Le){ht.current=null;return}const Ke=Le.getBoundingClientRect(),ct=G.getBoundingClientRect(),qe={item:G,top:Math.round(ct.top-Ke.top+Le.scrollTop),height:Math.round(ct.height),viewportHeight:Le.clientHeight},At=ht.current;if(ht.current=qe,At?.item===qe.item&&At.top===qe.top&&At.height===qe.height&&At.viewportHeight===qe.viewportHeight||Ot.current||Le.clientHeight===0)return;const Rt=8,Bt=ct.top-Ke.top,ot=ct.bottom-Ke.top;Bt<Rt?Le.scrollTop+=Bt-Rt:ot>Le.clientHeight-Rt&&(Le.scrollTop+=ot-Le.clientHeight+Rt)});const nn=b.useMemo(()=>{if(!wt||!c)return null;const G=l.get(c)?.cwd??null;return $S(G)},[wt,c,l]);b.useEffect(()=>{if(!wt){ir.current=null,Tn.current.clear();return}if(!c){ir.current=null;return}const G=Gt.getState(),Le=Tn.current,Ke=ir.current,ct=nn;Ke!==null&&Ke!==ct&&Le.has(Ke)&&(G.collapsedGroups.has(Ke)||G.toggleGroupCollapsed(Ke),Le.delete(Ke)),ct!==null&&ct!==""&&G.collapsedGroups.has(ct)&&(G.toggleGroupCollapsed(ct),Le.add(ct)),ir.current=ct},[wt,c,nn]),b.useEffect(()=>{e||ue(!1)},[e]),b.useEffect(()=>{Lr(G=>({...G,command:ge?.command}))},[ge]),b.useEffect(()=>{if(!Ce)return;let G=!1;return Zt(!0),Lt(null),a2().then(Le=>{G||jt(Le)}).catch(()=>{G||Lt(_e("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{G||Zt(!1)}),()=>{G=!0}},[Ce,_e]),b.useEffect(()=>{if(!re)return;const G=Le=>{Le instanceof KeyboardEvent&&Le.key!=="Escape"||Le instanceof PointerEvent&&Le.target instanceof Node&&xn.current?.contains(Le.target)||Oe(null)};return window.addEventListener("pointerdown",G),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",G),window.removeEventListener("keydown",G)}},[re]);const Fr=()=>{!ke&&!$e&&r()};b.useEffect(()=>{const G=Le=>{ue(!1);const{groupId:Ke,dock:ct}=Le.detail;oe.current=!0,es.getState().setDock(Ke,{...ct,preferredWidth:360}),Te(qe=>({...qe,[Ke]:!0})),la.getState().terminal(),Fr()};return window.addEventListener("termdock:open-collaboration-messages",G),()=>window.removeEventListener("termdock:open-collaboration-messages",G)},[Fr]);const ks=te==="tmux"&&!pe?"shell":te,Or=(G,Le=!1)=>{if(rt.current)return;rt.current=!0,Ne(!0),He(null);const Ke=mt.current;p({...G,shouldActivate:()=>Ke===mt.current&&(G.shouldActivate?.()??!0),onResult:ct=>{if(rt.current=!1,Ne(!1),!ct.ok){He(ct.error);return}Ke===mt.current&&(Le&&ue(!1),Fr())}})},Xr=()=>{Or({mode:ks})},fn=()=>{ge&&Or({mode:ks,command:ge.command})},K=G=>{ue(!1),Ge(G.name),p({mode:"tmux",tmuxSessionName:G.name,cwd:G.cwd??void 0}),Fr()};b.useEffect(()=>{me&&(Ae.some(G=>G.name===me)||Ge(null))},[me,Ae]);const Ue=(G,Le)=>{Or({...cn,cwd:cn.cwd?.trim()||void 0,command:Le??G?.command},!0)},Et=async G=>{Xt(G.id),Lt(null);try{const Le=await ky(G.id);Or({mode:"shell",cwd:Le.cwd,command:Le.command},!0)}catch(Le){const Ke=Le&&typeof Le=="object"&&"code"in Le?String(Le.code??""):"";Lt(_e(Ke==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Xt(null)}},kt=async G=>{jt(Le=>Le.filter(Ke=>Ke.id!==G));try{await o9(G)}catch{Lt(_e("sidebar.resumeHistoryRemoveFailed")),a2().then(jt).catch(()=>{})}},tr=()=>{if(Ce){ue(!1);return}rt.current||(mt.current+=1,rt.current||He(null),Lr({mode:te==="tmux"&&!pe?"shell":te,cwd:c?l.get(c)?.cwd??void 0:void 0,command:ge?.command}),ue(!0))},Qr=b.useCallback(G=>{const Le=l.get(G);return Le?.agentStatus==="waiting"||Le?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Le?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Le?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),cr=g6(),[Sn,Ls]=b.useState(null);b.useEffect(()=>{e||Ls(null)},[e]);const Zn=b.useCallback((G,Le,Ke,ct,qe)=>{const At=!Ie&&G.id===c,Rt=pn.has(G.id),Bt=!!(Ke&&Rt),ot=l.get(G.id),Ft=Yu(ot?.cwd??null),hr=ot?.shellTitle??Jw(G.id),Kt=hr===ot?.cwd||hr===Ft?null:hr,z=e9(G,ot?.activeProgram??null,null,t9,Kt,ot?.promptState??null),N=!!(ot?.tuiProgress&&ot.tuiProgress.state!=="remove"),ee=ot?.promptState==="running"||ot?.agentStatus==="working"||N?"bg-[var(--success)]":ot?.agentStatus==="waiting"||ot?.agentNeedsReview?"bg-[var(--warning)]":ot?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(JO,{open:Sn===G.id,onOpenChange:ie=>Ls(Qe=>ie?G.id:Qe===G.id?null:Qe),onClose:ie=>m(G.id,ie,{skipConfirmation:!0}),closeLabel:_e("common.close"),closeTitle:_e("sidebar.closeSession",{name:z}),compact:Ke,children:[s.jsxs("button",{ref:At?Ir:null,type:"button",...Le??{},onContextMenu:ie=>{B&&(ie.preventDefault(),B(G.id,{x:ie.clientX,y:ie.clientY}))},onClick:()=>{ue(!1),la.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:G.id})),Fr()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${Le?"cursor-grab active:cursor-grabbing ":""}${Ke?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ot?.cwd??G.name,children:[At&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${ee}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${Ke?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${At?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:[ot?.isConnecting||N&&!ot?.agentStatus?s.jsx(Cn,{size:Ke?10:11,className:"animate-spin"}):ot?.agent??o2(G.id)?s.jsx(Wc,{agent:ot?.agent??o2(G.id),size:Ke?13:15}):G.mode==="tmux"?s.jsx(Uu,{size:Ke?10:11}):s.jsx(Fo,{size:Ke?10:11}),s.jsx(rF,{status:ot?.agentStatus??null,detail:ot?.agentStatusDetail,needsReview:ot?.agentNeedsReview,inCopyMode:ot?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${Ke?"text-[11px]":"text-[12px]"} ${At?"font-medium text-foreground":""} ${ot?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:z}),s.jsx(O5,{sessionIds:[G.id]})]}),ct,s.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),Bt?w(G.id):Rt?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 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"} ${Rt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${_e(Bt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split")} ${z}`,title:_e(Bt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split"),children:Bt?s.jsx(ES,{size:11}):s.jsx(Il,{size:12})}),qe??s.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),m(G.id,ie)},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 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":_e("sidebar.closeSession",{name:z}),title:_e("common.close"),children:s.jsx(Rn,{size:Ke?11:12})})]})},[c,pn,l,m,x,y,w,B,_e,Sn]),sn=b.useMemo(()=>lf(a,G=>l.get(G.id)?.cwd??null,wt,_e("sidebar.ungrouped"),v,qr).groups,[qr,wt,a,l,v,_e]),on=b.useMemo(()=>Od(a,v,Pr,qr),[qr,a,Pr,v]),_r=b.useCallback(G=>{_n(G.draggableId.startsWith("collaboration:")||G.draggableId.startsWith("workspace:"));const Le=G.draggableId.replace(/^split-member:/,"");mr.current=G.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const Ke=G.type==="split-member"?v.find(Bt=>Bt.sessionIds.includes(Le)):null,ct=G.type==="collaboration-member"?G.source.droppableId.replace(/^collaboration-members:/,""):null,qe=ct?qr.find(Bt=>Bt.id===ct):null;Ot.current=!!(Ke||qe||G.type==="session"&&G.draggableId.startsWith("session:")),Ot.current&&document.querySelectorAll("[data-collaboration-group]").forEach(Bt=>{Bt.dataset.sidebarDragging="true"}),Tr.current=qe?.id??null;const At=Ke?.sessionIds??qe?.sessionIds??[],Rt=At.length>0?sn.find(Bt=>At.every(ot=>Bt.sessions.some(Ft=>Ft.id===ot))):null;bn.current=wt?Rt?`group-sessions:${Rt.key}`:null:At.length>0?"sidebar-entities":null,hn.current=null},[qr,sn,wt,v]),$r=b.useCallback((G,Le,Ke)=>{if(Le===Ke)return;const ct=Le?nr.find(ot=>ot.id===Le):null,qe=Ke?nr.find(ot=>ot.id===Ke):null;if(Ke&&!qe)return;if(qe){const ot=a.map(hr=>hr.id).filter(hr=>hr!==G);let Ft=-1;ot.forEach((hr,Kt)=>{qe.sessionIds.includes(hr)&&(Ft=Kt)}),Ft>=0&&(ot.splice(Ft+1,0,G),R(ot))}const At=ct?.sessionIds.filter(ot=>ot!==G)??[],Rt=qe?[...qe.sessionIds.filter(ot=>ot!==G),G]:[];Cr(ot=>ot.flatMap(Ft=>Ft.id===Le?[{...Ft,sessionIds:At}]:Ft.id===Ke?[{...Ft,sessionIds:Rt}]:[Ft])),q(null),(ct&&qe?r9({sourceGroupId:ct.id,targetGroupId:qe.id,sessionId:G,expectedSourceUpdatedAt:ct.updatedAt,expectedTargetUpdatedAt:qe.updatedAt}):ct?ac({id:ct.id,name:ct.name,sessionIds:At,expectedUpdatedAt:ct.updatedAt}):qe?ac({id:qe.id,name:qe.name,sessionIds:Rt,expectedUpdatedAt:qe.updatedAt}):Promise.resolve()).then(()=>Wr(),ot=>(q(ot instanceof Error?ot.message:"协作成员移动失败"),Wr()))},[nr,Wr,a,R]),Wn=b.useCallback((G,Le,Ke,ct=!1)=>{const qe=nr.find($=>$.id===G);if(!qe||Le===Ke)return;const At=qe.sessionIds.filter($=>!$.startsWith("remote:")),Rt=Pd(At,v).flatMap($=>$.sessionIds),Bt=Q5(qt,qe.id),ot=ct&&!Nt[qe.id]?Rt.filter($=>!Bt.has($)||$===c||pn.has($)):Rt.slice(),Ft=new Set(ot),[hr]=ot.splice(Le,1);if(!hr)return;ot.splice(Ke,0,hr);let Kt=0;const z=Rt.map($=>Ft.has($)?ot[Kt++]:$),N=v.find($=>$.sessionIds.includes(hr));if(N&&N.sessionIds.every($=>qe.sessionIds.includes($))){const $=z.filter(ee=>N.sessionIds.includes(ee));L(N.id,$)}z.push(...qe.sessionIds.filter($=>$.startsWith("remote:"))),Cr($=>$.map(ee=>ee.id===G?{...ee,sessionIds:z}:ee)),q(null),ac({id:qe.id,name:qe.name,sessionIds:z,expectedUpdatedAt:qe.updatedAt}).then(()=>Wr(),$=>(q($ instanceof Error?$.message:"成员排序失败"),Wr()))},[nr,Wr,v,L,qt,Nt,c,pn]);b.useEffect(()=>{const G=Le=>{const{sourceId:Ke,targetId:ct}=Le.detail;if(!Ke||!ct||Ke===ct)return;const qe=lf(a,ie=>l.get(ie.id)?.cwd??null,wt,"",v,qr).arranged.map(ie=>ie.id),At=qe.indexOf(Ke),Rt=qe.indexOf(ct);if(At<0||Rt<0)return;const Bt=qr.find(ie=>ie.sessionIds.includes(Ke));if(Bt?.sessionIds.includes(ct)){const ie=Pd(Bt.sessionIds,v).flatMap(Qe=>Qe.sessionIds);Wn(Bt.id,ie.indexOf(Ke),ie.indexOf(ct));return}const ot=v.filter(ie=>ie.sessionIds.length>=2&&ie.sessionIds.every(Qe=>Pr.has(Qe))&&!qr.some(Qe=>ie.sessionIds.some(ze=>Qe.sessionIds.includes(ze)))),Ft=ot.find(ie=>ie.sessionIds.includes(Ke));if(Ft?.sessionIds.includes(ct)){const ie=[...Ft.sessionIds];ie.splice(ie.indexOf(Ke),1),ie.splice(Ft.sessionIds.indexOf(ct),0,Ke),L(Ft.id,ie);return}const hr=ie=>qr.find(Qe=>Qe.sessionIds.includes(ie))?.sessionIds??ot.find(Qe=>Qe.sessionIds.includes(ie))?.sessionIds??[ie],Kt=new Set(hr(Ke)),z=new Set(hr(ct)),N=qe.filter(ie=>!Kt.has(ie)),$=N.flatMap((ie,Qe)=>z.has(ie)?[Qe]:[]),ee=At<Rt?Math.max(...$)+1:Math.min(...$);N.splice(ee,0,...qe.filter(ie=>Kt.has(ie))),R(N)};return window.addEventListener("reorder-navigation-session",G),()=>window.removeEventListener("reorder-navigation-session",G)},[a,l,wt,v,qr,Pr,Wn,L,R]);const Gn=b.useCallback(G=>{if(G.type!=="collaboration-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.source.droppableId.replace(/^collaboration-members:/,""),Ke=G.draggableId.replace(/^collaboration-member:/,""),ct=hn.current;if(ct?.kind==="split")return $r(Ke,Le,ct.groupId),E(ct.sessionId,Ke),!0;if(ct?.kind==="collaboration"&&ct.groupId!==Le)return $r(Ke,Le,ct.groupId),!0;if(ct?.kind==="collaboration"&&ct.background)return pn.has(Ke)&&w(Ke),!0;if(G.destination&&G.destination.droppableId!==G.source.droppableId){const qe=G.destination.droppableId.replace(/^collaboration-members:/,"");if(qr.some(At=>At.id===qe))return $r(Ke,Le,qe),!0}if(G.combine){const qe=G.combine.droppableId.replace(/^collaboration-members:/,"");qe!==Le&&$r(Ke,Le,qe);const At=G.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(Bt=>Bt.sessionIds.includes(Ke))?.sessionIds.includes(At)){const Bt=qr.find(Ft=>Ft.id===Le),ot=Bt?Pd(Bt.sessionIds,v).flatMap(Ft=>Ft.sessionIds).indexOf(At):-1;ot>=0&&Bt&&Wn(Le,Pd(Bt.sessionIds,v).flatMap(Ft=>Ft.sessionIds).indexOf(Ke),ot)}else Pr.has(At)&&E(At,Ke);return!0}if(G.destination?.droppableId===G.source.droppableId)return Wn(Le,G.source.index,G.destination.index,!0),!0;if(ct?.kind!=="list")return!0;if(ct?.kind==="list"){const qe=sn.find(Rt=>`group-sessions:${Rt.key}`===ct.listId),At=ct.listId==="sidebar-entities"?on:qe?Od(qe.sessions,v,Pr,qr):null;if(At){const Rt=Rb(At,Ke,ct.index);ct.listId==="sidebar-entities"?R(Rt):qe&&R(sn.flatMap(Bt=>Bt.key===qe.key?Rt:Bt.sessions.map(ot=>ot.id)))}}return $r(Ke,Le,null),!0},[qr,on,sn,$r,R,Wn,Pr,v,pn,w,E]),un=b.useCallback(G=>{if(G.type!=="split-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.draggableId.replace(/^split-member:/,""),Ke=v.find(ot=>ot.sessionIds.includes(Le));if(!Ke?.sessionIds.includes(Le))return!0;const ct=Ke.id,qe=hn.current;if(qe?.kind==="split")return $r(Le,null,qe.groupId),E(qe.sessionId,Le),!0;if(qe?.kind==="collaboration")return $r(Le,null,qe.groupId),!0;if(!G.destination&&qe?.kind==="list"){const ot=sn.find(Kt=>`group-sessions:${Kt.key}`===qe.listId),Ft=qe.listId==="sidebar-entities"?on:ot?Od(ot.sessions,v,Pr,qr):null;if(!Ft)return!0;const hr=Rb(Ft,Le,qe.index);return w(Le),qe.listId==="sidebar-entities"?R(hr):ot&&R(sn.flatMap(Kt=>Kt.key===ot.key?hr:Kt.sessions.map(z=>z.id))),!0}if(!G.destination)return!0;const At=G.destination.droppableId.replace(/^split-members:/,"");if(At!==ct){const Ft=v.find(hr=>hr.id===At)?.sessionIds[0];return Ft&&E(Ft,Le),!0}if(G.source.index===G.destination.index)return!0;const Rt=[...Ke.sessionIds],[Bt]=Rt.splice(G.source.index,1);return Bt&&(Rt.splice(G.destination.index,0,Bt),L(ct,Rt)),!0},[qr,on,sn,$r,E,w,R,L,Pr,v]),Kn=(G,Le="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 ${Le==="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,Le,Ke)=>{if(Gn(G)||un(G)||G.reason==="CANCEL")return;const ct=Le.find(ot=>ot.id===G.draggableId);if(!ct)return;const qe=hn.current;if(qe?.kind==="split"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId),E(qe.sessionId,ct.session.id);return}if(qe?.kind==="collaboration"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId);return}if(G.combine&&ct.kind!=="session"){const ot=Le.findIndex(Ft=>Ft.id===G.combine?.draggableId);if(ot<0)return;G={...G,combine:null,destination:{...G.source,index:ot}}}if(G.combine){const ot=Le.find(N=>N.id===G.combine?.draggableId);if(!ot)return;const Ft=ot.kind==="workspace"?ot:ct.kind==="workspace"?ct:ot,hr=Ft===ct?ot:ct,Kt=Ft.sessionIds[0],z=hr.sessionIds[0];Kt&&z&&Kt!==z&&E(Kt,z);return}if(!G.destination||G.source.index===G.destination.index)return;const At=[...Le],[Rt]=At.splice(G.source.index,1);if(!Rt)return;At.splice(G.destination.index,0,Rt);const Bt=At.flatMap(ot=>ot.sessionIds);if(Ke===void 0){R(Bt);return}R(sn.flatMap(ot=>ot.key===Ke?Bt:ot.sessions.map(Ft=>Ft.id)))},[sn,Gn,un,$r,E,R]),Er=b.useCallback(G=>{if(G.reason==="CANCEL"||Gn(G)||un(G))return;if(G.type==="group"){if(!G.destination||G.source.index===G.destination.index)return;R(Uy(sn,G.source.index,G.destination.index));return}const Le=G.source.droppableId.replace(/^group-sessions:/,""),Ke=sn.find(qe=>qe.key===Le);if(!Ke)return;const ct=Od(Ke.sessions,v,Pr,qr);if(G.combine||hn.current?.kind==="collaboration"||hn.current?.kind==="split"){kr(G,ct,Le);return}!G.destination||G.destination.droppableId!==G.source.droppableId||kr(G,ct,Le)},[qr,sn,Pr,v,Gn,kr,un,R]),gr=G=>{const Le=re===G.id,Ke=[{layout:"horizontal",label:_e("tab.splitHorizontal"),icon:Il},{layout:"vertical",label:_e("tab.splitVertical"),icon:h2},...G.sessionIds.length>=3||G.layout==="grid"?[{layout:"grid",label:_e("tab.splitGrid"),icon:d2}]:[]],ct=G.layout==="vertical"?h2:G.layout==="grid"?d2:Il,qe=Ke.find(At=>At.layout===G.layout)?.label??_e("tab.splitHorizontal");return s.jsxs("div",{ref:Le?xn:void 0,className:"relative shrink-0",onPointerDown:At=>At.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 ${Le?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${_e("tab.splitLayout")}: ${qe}`,"aria-haspopup":"menu","aria-expanded":Le,title:_e("tab.splitLayout"),onClick:At=>{At.stopPropagation(),Oe(Rt=>Rt===G.id?null:G.id)},children:s.jsx(ct,{size:12})}),Le&&s.jsx("div",{role:"menu","aria-label":_e("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:Ke.map(At=>{const Rt=At.icon,Bt=At.layout===G.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Bt,"aria-label":At.label,title:At.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${Bt?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:ot=>{ot.stopPropagation(),S(G.sessionIds[0],At.layout),Oe(null)},children:s.jsx(Rt,{size:13})},At.layout)})})]})},rs=(G,Le)=>Le&&s.jsx("button",{type:"button",...Le,"aria-label":G,title:G,onClick:Ke=>Ke.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(Ff,{size:10})}),$n=(G,Le,Ke=!1,ct=!1,qe)=>{if(Le.length<2)return null;const At=Le.some(Kt=>Kt.id===c),Rt=[],Bt=[],ot=[];for(const Kt of Le){const z=l.get(Kt.id);z?.agentStatus==="waiting"||z?.agentNeedsReview?Rt.push(Kt):z?.agentStatus==="working"?Bt.push(Kt):z?.inCopyMode&&ot.push(Kt)}const Ft=G.name?.trim()||`${_e("tab.splitWorkspace")} ${v.findIndex(Kt=>Kt.id===G.id)+1}`,hr=re===G.id;return s.jsxs("section",{"data-split-workspace":G.id,"aria-label":Ft,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 ${ct?"bg-primary/15 ring-1 ring-primary/40":Ke?"bg-surface-elevated opacity-90 shadow-lg":Rt.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Bt.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":ot.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":At?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[rs(`移动分屏组 ${Ft}`,qe),s.jsx(Ll,{droppableId:`split-members:${G.id}`,type:"split-member",direction:"vertical",children:(Kt,z)=>s.jsxs("div",{ref:Kt.innerRef,...Kt.droppableProps,"data-split-members":!0,className:z.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[Le.map((N,$)=>s.jsx(kl,{draggableId:`split-member:${N.id}`,index:$,disableInteractiveElementBlocking:!0,children:(ee,ie)=>s.jsx("div",{ref:ee.innerRef,...ee.draggableProps,...B?cr(()=>B(N.id)):{},className:`${$===0&&hr?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${ie.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Qr(N.id)??(N.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Zn(N,ee.dragHandleProps,!0,$===0?gr(G):void 0)})},N.id)),Kt.placeholder]})})]})},kn=(G,Le,Ke,ct=!1,qe=!1)=>{const At=`collaboration:${G.id}`,Rt=Rr.has(At),Bt=`collaboration-members-${G.id}`,ot=Ie===G.id||!Ie&&Le.some(ie=>ie.id===c),Ft=Q5(qt,G.id),hr=G.sessionIds.filter(ie=>Ft.has(ie)&&ie!==c&&!pn.has(ie)),Kt=Nt[G.id]===!0,z=Kt?G.sessionIds:G.sessionIds.filter(ie=>!hr.includes(ie)),N=Pd(z,v),$=N.flatMap(ie=>ie.sessionIds),ee=N.length===1?N[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 ${Rt?"":"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 ${qe?"bg-primary/15 ring-1 ring-primary/40":ct?"bg-surface-elevated opacity-90 shadow-lg":ot?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[rs(`移动工作组 ${G.name}`,Ke),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button","aria-label":`${Rt?"展开":"收起"} ${G.name} 的成员会话`,"aria-expanded":!Rt,"aria-controls":Bt,title:`${Rt?"展开":"收起"}成员会话`,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:ie=>{ie.stopPropagation(),rn(At)},children:s.jsx(fi,{size:14,className:Rt?"":"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:ie=>{ie.stopPropagation(),pr(G.id)},children:[s.jsx(rh,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),at.some(ie=>ie.groupId===G.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[at.filter(ie=>ie.groupId===G.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${G.name}`,title:"在终端旁打开成员与消息",disabled:Ze!==null||!c&&!Le.length,"aria-busy":Ze===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:ie=>{ie.stopPropagation(),!be.current&&(ue(!1),be.current=!0,Je(G.id),q(null),lC(G.id,c??Le[0].id).catch(Qe=>q(Qe instanceof Error?Qe.message:"消息面板打开失败,请重试")).finally(()=>{be.current=!1,Je(null)}))},children:Ze===G.id?s.jsx(gn,{size:14,className:"animate-spin"}):s.jsx(N0,{size:14})})]}),s.jsx("div",{id:Bt,children:!Rt&&s.jsxs(s.Fragment,{children:[hr.length>0&&s.jsxs("button",{type:"button","aria-expanded":Kt,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:()=>gt(ie=>({...ie,[G.id]:!Kt})),children:[s.jsx(fi,{size:12,className:Kt?"rotate-90":""}),"已完成的执行会话 · ",hr.length]}),s.jsx(Ll,{droppableId:`collaboration-members:${G.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(ie,Qe)=>s.jsxs("div",{ref:ie.innerRef,...ie.droppableProps,"data-collaboration-members":!0,className:`${Qe.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[N.map(ze=>s.jsx("div",{"data-collaboration-split":ze.workspace?.id,"data-split-anchor":ze.workspace?.sessionIds[0],role:ze.workspace?"region":void 0,"aria-label":ze.workspace?`${_e("tab.splitWorkspace")} · ${ze.sessionIds.length}`:void 0,className:ze.workspace&&!ee?`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 ${ze.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:ze.sessionIds.map(xt=>{const _t=Pr.get(xt);return _t?s.jsx(kl,{draggableId:`collaboration-member:${_t.id}`,index:$.indexOf(_t.id),disableInteractiveElementBlocking:!0,children:(Mr,Dt)=>s.jsxs("div",{ref:Mr.innerRef,...Mr.draggableProps,"data-collaboration-member":_t.id,"data-split-member":pn.has(_t.id)?"true":void 0,...B?cr(()=>B(_t.id)):{},className:`${ze.workspace&&xt===ze.sessionIds[0]&&re===ze.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 ${Dt.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":Dt.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Qr(_t.id)??(_t.id===c?"bg-surface-elevated/80 text-foreground":pn.has(_t.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Zn(_t,Mr.dragHandleProps,!0,ze.workspace&&xt===ze.sessionIds[0]?gr(ze.workspace):void 0,Ft.has(xt)?s.jsxs("button",{type:"button","aria-label":`归档 ${_t.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:er!==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:Gr=>{Gr.stopPropagation(),!Ct.current&&(Ct.current=!0,et(xt),q(null),a9(xt).then(async()=>{De(dn=>dn+1),await Wr()}).catch(dn=>q(dn instanceof Error?dn.message:"归档失败,终端已保留")).finally(()=>{Ct.current=!1,et(null)}))},children:[er===xt?s.jsx(gn,{size:13,className:"animate-spin"}):s.jsx(Ly,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!ze.workspace&&pn.has(_t.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(Gr=>Gr.sessionIds.includes(_t.id))?.sessionIds.filter(Gr=>Gr!==_t.id).map(Gr=>Pr.get(Gr)?.name??Gr).join("、")} 分屏`,"aria-label":`查看 ${_t.name} 的跨组分屏`,onClick:()=>{ue(!1),la.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_t.id})),Fr()},children:s.jsx(Il,{size:10})})]})},_t.id):null})},ze.workspace?.id??ze.sessionIds[0])),ie.placeholder]})}),s.jsx(XB,{groupId:G.id,version:Ve,onRestore:async ie=>{ue(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:ie.cwd,preferredFrontendSessionId:ie.sessionId,requireExisting:!0}})),await Wr(),la.getState().terminal(),Fr()}}),G.remoteSessions?.map(ie=>s.jsxs("button",{type:"button",title:`${uc(ie)} · ${ie.serviceConnected===!1?"服务不可达,消息尚未送达":ie.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),b6(ie.sessionId).catch(()=>{pr(G.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ie.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ie.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:uc(ie)}),ie.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},ie.sessionId))]})}),s.jsx("div",{"data-collaboration-background":!0,className:Rt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},Ln=(G,Le,Ke)=>s.jsx(c0,{onBeforeCapture:fs,onDragStart:_r,onDragEnd:ct=>Mn(qe=>kr(qe,G,Ke),ct),children:s.jsx(Ll,{droppableId:Le,direction:"vertical",isCombineEnabled:!Hr,children:ct=>s.jsxs("div",{ref:ct.innerRef,...ct.droppableProps,"data-sidebar-entity-list-id":Le,className:"flex-1 space-y-0.5",children:[G.map((qe,At)=>s.jsx(kl,{draggableId:qe.id,index:At,disableInteractiveElementBlocking:!0,children:(Rt,Bt)=>s.jsxs("div",{ref:Rt.innerRef,...Rt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":At,className:"relative",children:[Kn(At),At===G.length-1&&Kn(G.length,"bottom"),qe.kind==="workspace"?$n(qe.workspace,qe.members,Bt.isDragging,!!Bt.combineTargetFor,Rt.dragHandleProps):qe.kind==="collaboration"?kn(qe.group,qe.members,Rt.dragHandleProps,Bt.isDragging,!!Bt.combineTargetFor):s.jsx("div",{...B?cr(()=>B(qe.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${Bt.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":Bt.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Qr(qe.session.id)??(!Ie&&qe.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(qe.session,Rt.dragHandleProps)})]})},qe.id)),ct.placeholder]})})}),ps=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:_e("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),Kr>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(j6,{count:Kr,tone:"running",title:_e("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),pr(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(rh,{size:16})}),(!ke||$e)&&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":_e("common.close"),children:s.jsx(Rn,{size:16})})]})]})]}),pt&&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:pt}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>q(null),children:s.jsx(Rn,{size:14})})]}),s.jsxs("div",{ref:ne,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:[(at.length>0||bt)&&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":It,onClick:()=>yt(G=>!G),children:[s.jsx(rh,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:at.length}),s.jsx(fi,{size:12,className:It?"rotate-90":""})]}),It&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[bt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[bt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{_u.getState().refresh()},children:"重试"})]}),at.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:()=>{P5(G.groupId,G.id),pr(G.groupId).then(Le=>{Le&&P5(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:[nr.find(Le=>Le.id===G.groupId)?.name??"协作组"," · ",Yc(G)]})]},G.id))]})]}),s.jsx(eF,{sessions:Ae,loading:lt,attachingName:me,onRefresh:Se,onRestore:K,onClose:ye}),qr.filter(G=>!G.sessionIds.length).map(G=>s.jsx(c0,{onDragEnd:()=>{},children:kn(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(Fo,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:_e("sidebar.noSessions")})]}):Sr.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:_e("sidebar.noMatchingSessions")})}):wt?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(c0,{onBeforeCapture:fs,onDragStart:_r,onDragEnd:G=>Mn(Er,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:[sn.map((Le,Ke)=>{const ct=Rr.has(Le.key),qe=!ct&&Ke===sn.length-1,At=Od(Le.sessions,v,Pr,qr);let Rt=0,Bt=0;for(const Ft of Le.sessions){const hr=l.get(Ft.id);hr?.agentStatus==="working"&&(Rt+=1),(hr?.agentStatus==="waiting"||hr?.agentNeedsReview)&&(Bt+=1)}const ot=Le.key==="";return s.jsx(kl,{draggableId:`sidebar-group:${Le.key||"__ungrouped__"}`,index:Ke,isDragDisabled:ot,disableInteractiveElementBlocking:!0,children:(Ft,hr)=>s.jsxs("div",{ref:Ft.innerRef,...Ft.draggableProps,className:`shrink-0 rounded-md transition-colors ${qe?"flex flex-1 flex-col ":""}${hr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ot?{}:Ft.dragHandleProps,onClick:()=>{rn(Le.key),Tn.current.delete(Le.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 ${ot?"":"cursor-grab active:cursor-grabbing"}`,title:Le.key||Le.label,children:[s.jsx(fi,{size:13,className:`shrink-0 transition-transform ${ct?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Le.label}),Rt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Bt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx(O5,{sessionIds:Le.sessions.map(Kt=>Kt.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Le.sessions.length})]}),!ct&&s.jsx("div",{className:`mt-0.5 pl-2 ${qe?"flex flex-1 flex-col":""}`,children:s.jsx(Ll,{droppableId:`group-sessions:${Le.key}`,type:"session",direction:"vertical",isCombineEnabled:!Hr,children:Kt=>s.jsxs("div",{ref:Kt.innerRef,...Kt.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${Le.key}`,className:`${qe?"flex-1 ":""}space-y-0.5`,children:[At.map((z,N)=>s.jsx(kl,{draggableId:z.id,index:N,disableInteractiveElementBlocking:!0,children:($,ee)=>s.jsxs("div",{ref:$.innerRef,...$.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":N,className:"relative",children:[Kn(N),N===At.length-1&&Kn(At.length,"bottom"),z.kind==="workspace"?$n(z.workspace,z.members,ee.isDragging,!!ee.combineTargetFor,$.dragHandleProps):z.kind==="collaboration"?kn(z.group,z.members,$.dragHandleProps,ee.isDragging,!!ee.combineTargetFor):s.jsx("div",{...B?cr(()=>B(z.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${ee.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":ee.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Qr(z.session.id)??(!Ie&&z.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(z.session,$.dragHandleProps)})]})},z.id)),Kt.placeholder]})})})]})},Le.key||"__ungrouped__")}),G.placeholder]})})})}):Ln(on,"sidebar-entities")]}),s.jsx(n9,{onReselect:()=>{d&&(ht.current=null,je(G=>G+1),d())}}),Ce&&s.jsx(uO,{directories:a.flatMap(G=>{const Le=l.get(G.id)?.cwd;return Le?[Le]:[]}),tmuxAvailable:pe,options:cn,launchPending:Be,launchError:le?_e(Um(le)):null,agents:Vr,selectedAgent:ge,detecting:it,resumeHistory:Vt,resumeHistoryLoading:vt,resumeHistoryPendingId:Pt,resumeHistoryError:zt,onRefreshAgents:()=>{dt().catch(()=>{})},onSelectAgent:G=>{sr(G).catch(()=>{})},onLaunchAgent:Ue,onResumeHistory:G=>{Et(G)},onRemoveResumeHistory:G=>{kt(G)},onClose:()=>ue(!1),onOptionsChange:Lr,additionalContent:an&&U?.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(gn,{size:13,className:U.status==="installing"||U.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:_e("sidebar.updateAvailable",{version:U.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:U.status==="installing"?_e("sidebar.updateInstalling"):U.status==="ready"?_e("sidebar.updateReady"):U.status==="restarting"?_e("sidebar.updateRestarting"):_e("sidebar.updateFailed")})]})]}),U.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:_e("sidebar.updateRestart")}),U.status==="error"&&ce&&s.jsx("button",{type:"button",disabled:V,onClick:ce,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:_e("sidebar.updateRetry")})]}),footerActions:s.jsx(KO,{serverAttention:Me,onOpenSettings:()=>{ue(!1),W()},actions:[...F?[{label:_e("sidebar.subscriptionQuota"),icon:FA,onSelect:()=>{ue(!1),F()}}]:[],{label:"Agent 工作台",icon:rh,onSelect:()=>{ue(!1),pr(null)}},{label:"服务与设备",icon:s9,onSelect:()=>{ue(!1),i9()}},...Y?[{label:_e($e?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:$e?m0:p0,separated:!0,onSelect:()=>{ue(!1),Y()}}]:[]]})}),Ye&&s.jsx(Cb,{onEnterGroup:async G=>{if(!await pr(G))throw new Error("协作组已保存,打开工作区失败,请重试");st(!1)},onFloatingChange:async G=>{if(G){if(!await pr(G))throw new Error("打开协作工作区失败");st(!1)}},activeSessionId:c,defaultSessionMode:te,onClose:()=>st(!1),onNewSession:G=>p(G)}),Object.entries(We).map(([G,Le])=>s.jsx(Cb,{activeSessionId:c,initialCollaborationGroupId:G,initialFloating:Le,visible:!Ie,onEnterGroup:async Ke=>{if(Ke===G){await pr(Ke);return}if(!await pr(Ke))throw new Error("协作组已保存,打开工作区失败,请重试");await bo({floatingGroupId:null},G),Te(ct=>{const qe={...ct};return delete qe[G],qe})},onFloatingChange:Ke=>St(G,Ke),defaultSessionMode:te,onClose:()=>{oe.current=!0,Te(Ke=>{const ct={...Ke};return delete ct[G],ct})},onNewSession:Ke=>p(Ke)},G)),!Ce&&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:[le&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:_e(Um(le))}),s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${ge?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:Xr,disabled:Be,"aria-busy":Be,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] ${ge?"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:_e("sidebar.newSession"),"aria-label":_e("sidebar.newSession"),children:[s.jsx(Fo,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Be?_e("sidebar.sessionCreating"):"Terminal"})]}),ge&&s.jsxs("button",{type:"button",onClick:fn,disabled:Be,"aria-busy":Be,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:_e("sidebar.newSessionWithAgent",{agent:ge.displayName}),"aria-label":_e("sidebar.newSessionWithAgent",{agent:ge.displayName}),children:[s.jsx(Wc,{agent:ge,size:15}),s.jsx("span",{className:"truncate",children:ge.displayName})]}),s.jsxs("button",{type:"button",onClick:tr,disabled:Be,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:nt,"aria-label":nt,"aria-expanded":Ce,"aria-controls":"sidebar-launch-options",children:[s.jsx($o,{size:15}),Me&&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"}),an&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${Me?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})]})]});return $e?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:ps}):s.jsx(N6,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:ke,children:ps})}function nF(){const{t:e}=zr();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 sF({slow:e=!1}){const{t}=zr();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 G6=()=>Oc(()=>import("./RightSidebar-DaRdlJzn.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})),iF=b.lazy(G6);function jb(e){const t=b.useRef(!1);b.useEffect(()=>{const p=navigator.connection;if(!(p?.saveData||/2g|3g/.test(p?.effectiveType??"")))return $1(()=>{G6().catch(()=>{})},3e3)},[]);const{t:r}=zr(),n=Gt(p=>p.rootPath),a=Gt(p=>p.rightTab),c=Gt(p=>p.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const d=s.jsx(N6,{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:[Ml,JT,$o].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(Rn,{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",vA,"rightSidebar.tabGit"],["diff",AA,"rightSidebar.tabChanges"],["files",Gc,"rightSidebar.tabFiles"],["architecture",PT,"architecture.tab"],["computer",l9,"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(sF,{}):s.jsx(nF,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:d,children:s.jsx(iF,{...e})}):d}const Db=hc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function aF(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 oF=hc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=Xy(),a=Date.now(),c=t().sessions,l=aF(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})}})),lF=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class cF{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 lF[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 Xc(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 uF(){return Xc("/api/android/devices")}async function dF(e){return Xc("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const Of=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],k0=Of[1];function N1(e){if(!e||typeof e!="object")return k0;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=Of.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return k0;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 hF(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 Bb(e){const t={ADB_UNAVAILABLE:"本机没有可用的 adb,请先安装 Android platform-tools。",ADB_NOT_FOUND:"找不到 adb 可执行文件,可用 TERMDOCK_ADB_BIN 指定路径。",SCRCPY_NOT_FOUND:"本机没有 scrcpy,请先安装(含 scrcpy-server)。",SCRCPY_SERVER_NOT_FOUND:"找不到 scrcpy-server,可用 TERMDOCK_SCRCPY_SERVER 指定路径。",SCRCPY_VERSION_UNKNOWN:"无法读取 scrcpy 版本,请确认 scrcpy --version 可执行。",SCRCPY_CONNECT_TIMEOUT:"设备连接超时,请确认已授权 USB 调试并保持解锁。",SCRCPY_UNSUPPORTED_CODEC:"设备返回了不支持的视频编码。",INVALID_ADDRESS:"地址格式不正确,应为 ip:port。",API_NOT_ALLOWED:"当前设备权限不足:投屏需要全权服务授权。"};for(const[r,n]of Object.entries(t))if(e.includes(r))return n;return e}function fF(e){return Xc(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function pF(e){return Xc("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function mF(e){return Xc(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function gF(e,t){return Xc(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function xF(e){return Xc(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const bF=0,yF=1,vF=2,wF=3,AF=4,TF=5,SF=7,CF=10,_F=11,kF=16,Qb=17,Pb=0,Lm=1,LF=2,Ob=3,Im=0,Fb=1,$b=1,wu=0xffffffffffffffffn,Eh=0xfffffffffffffffen,Fd={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function V6(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 IF(e,t,r,n,a,c){const l=new Uint8Array(32),d=new DataView(l.buffer);return d.setUint8(0,vF),d.setUint8(1,e),d.setBigUint64(2,t),V6(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 Em(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,bF),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function EF(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,wF),V6(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 NF(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,yF),a.setUint32(1,r.length),n.set(r,5),n}function RF(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]=kF,r[1]=t.length,r.set(t,2),r}function $d(e){return new Uint8Array([e])}function Ub(e){return new Uint8Array([AF,e])}function MF(e){return new Uint8Array([CF,e?1:0])}function jF(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function DF(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 Nm(e){return e.toString(16).padStart(2,"0")}function q6(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 BF(e){const t=e?q6(e,7,!1):null;return t&&t.length>=4?`avc1.${Nm(t[1])}${Nm(t[2])}${Nm(t[3])}`:"avc1.42e01e"}function QF(e){const t=e?q6(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 PF{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=c9(hF(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($d(Qb)))},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:jF(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=DF(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($d(Qb))}})}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=[BF(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,d,p)=>p.indexOf(l)===d),r.avc={format:"annexb"}):t==="h265"?(n=[QF(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===Lm||t===Ob,l=c?0:1,d=a===wu&&!c?$b:0,p=(t===Pb||t===Lm)&&a===wu?$b:0;this.sendControl(IF(t,a,this.pointerPoint(r,n),l,p,d))}pointerDown(t,r,n){this.touch(Pb,t,r,n==="mouse"?wu:Eh)}pointerMove(t,r,n){this.touch(LF,t,r,n==="mouse"?wu:Eh)}pointerUp(t,r,n){this.touch(Lm,t,r,n==="mouse"?wu:Eh)}pointerCancel(t,r,n){this.touch(Ob,t,r,n==="mouse"?wu:Eh)}scroll(t,r,n,a){this.sendControl(EF(this.pointerPoint(t,r),n,a))}key(t,r=Im){this.sendControl(Em(r,t))}tapKey(t){this.sendControl(Em(Im,t)),this.sendControl(Em(Fb,t))}back(){this.sendControl(Ub(Im)),this.sendControl(Ub(Fb))}home(){this.tapKey(Fd.HOME)}recents(){this.tapKey(Fd.APP_SWITCH)}power(){this.tapKey(Fd.POWER)}volumeUp(){this.tapKey(Fd.VOLUME_UP)}volumeDown(){this.tapKey(Fd.VOLUME_DOWN)}rotate(){this.sendControl($d(_F))}expandNotifications(){this.sendControl($d(TF))}collapsePanels(){this.sendControl($d(SF))}setDisplayPower(t){this.sendControl(MF(t))}sendText(t){this.sendControl(NF(t))}startApp(t){this.sendControl(RF(t))}}function OF(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function FF(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${OF()}.png`}function zb(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 $F(e,t=FF()){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 Y6(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 Hb(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:Y6({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 Z6(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 Wb(e,t){return Z6(l1(e,null),t)}const Rm=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 UF({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=zr(),[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 xF(e.id),n()}catch(W){S(W instanceof Error?W.message:String(W))}finally{L.current=!1,p(!1),w(!1)}}};b.useEffect(()=>{if(c)return;E.current?.focus();const W=F=>{if(F.stopPropagation(),F.key==="Escape"&&F.preventDefault(),F.key!=="Tab")return;const U=Array.from(E.current?.querySelectorAll("button:not(:disabled)")??[]),V=U[0],Z=U.at(-1);F.shiftKey&&(document.activeElement===V||document.activeElement===E.current)?(F.preventDefault(),Z?.focus()):!F.shiftKey&&document.activeElement===Z&&(F.preventDefault(),V?.focus())};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[c]);const B=async W=>{if(!L.current){L.current=!0,p(!0),x(W!==void 0),l(!1),S(null);try{const F=await gF(e.id,W);W===void 0&&await r(F.path),n()}catch(F){S(F instanceof Error?F.message:String(F))}finally{L.current=!1,p(!1)}}};return c?s.jsx(tp,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:W=>{B(W)}}):Ii.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(Cn,{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 Xd="android-mirror",Ud=Xd,K6="termdock:android:quality:v1",Mm=176,zF=204,_l=1,rf=8,Gb=[1,1.25,1.5,2,2.5,3,4,6,8],HF=e=>Math.max(_l,Math.min(rf,e));function WF(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function Nh(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 GF(e,t){try{e.setPointerCapture?.(t)}catch{}}function Vb(e,t){try{e.releasePointerCapture?.(t)}catch{}}const qb=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Rh=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},jm={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},VF=()=>{try{const e=localStorage.getItem(K6);return e?N1(JSON.parse(e)):k0}catch{return k0}},zd=e=>{try{localStorage.setItem(K6,JSON.stringify(e))}catch{}};function qF({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=zr(),d=Db(N=>N.overlay),p=Db(N=>N.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(VF,[]),v=b.useRef(w),S=b.useRef(null),L=b.useRef(null),[E,R]=b.useState(4e6),B=b.useRef(null),W=b.useRef(new Map),F=b.useRef(null),U=b.useRef(!1),[V,Z]=b.useState(_l),ce=b.useRef(V),xe=b.useRef({x:0,y:0}),pe=b.useRef(null),te=b.useRef(0),ke=b.useRef(0),$e=b.useRef(null),Y=b.useRef(0),[Ae,lt]=b.useState(null),[Se,ye]=b.useState(null),[_e,je]=b.useState(!0),[re,Oe]=b.useState(""),[Ce,Ee]=b.useState(w.id),[Be,Ne]=b.useState([]),[le,He]=b.useState(null),[rt,mt]=b.useState(""),[ue,Ye]=b.useState(!0),[st,Ie]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[We,Te]=b.useState("idle"),[H,oe]=b.useState(null),[be,Ze]=b.useState(null),[Je,St]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Vt,jt]=b.useState(null),[vt,Zt]=b.useState(null),[Pt,Xt]=b.useState(!1),[zt,Lt]=b.useState([]),[me,Ge]=b.useState(null),[pt,q]=b.useState([]),[at,qt]=b.useState(!1),Ve=b.useRef(null),De=b.useRef(0),er=b.useRef([]),[et,Ct]=b.useState(!1),[Nt,gt]=b.useState(""),[bt,It]=b.useState(!1),[yt,pr]=b.useState(!1),[nr,Cr]=b.useState(""),[cn,Lr]=b.useState(null),[ge,Vr]=b.useState(null),[it,dt]=b.useState(!1),[sr,xn]=b.useState(0),an=b.useRef(null),[Me,nt]=b.useState(!1),wt=b.useRef(!1),Rr=b.useRef(new Set),rn=b.useRef(null),Ir=b.useRef(null),ne=b.useRef(!1),[ht,Ht]=b.useState(!1),Ot=b.useRef(a);Ot.current=a;const[Tr,mr]=b.useState(!1),[Hr,_n]=b.useState(null),dr=b.useRef(null),bn=b.useRef(null),hn=oF(N=>N.activeSessionId??N.sessions.keys().next().value??null),Tn=e??hn,ir=es(N=>!!N.docks[Ud]),pn=es(N=>N.hosts[Ud]),Pr=es(N=>N.setDock),qr=b.useCallback(async()=>{je(!0);try{const N=await uF();lt(N),ye(null)}catch(N){ye(N instanceof Error?N.message:"ADB_UNAVAILABLE")}finally{je(!1)}},[]);b.useEffect(()=>{qr()},[qr]);const Wr=Ae?.devices??[],fs=Wr.find(N=>N.serial===re)??null,Br=!!(Se&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(Se)),Mn=!!(Ae?.adbAvailable&&!Ae.scrcpyVersion),Sr=b.useCallback(()=>{const N=B.current,$=[...W.current.keys()];B.current=null,W.current.clear(),F.current=null,U.current=!1,Ve.current=null,Rh(te.current),te.current=0,N&&x.current?.pointerCancel(N.x,N.y,N.type);const ee=m.current;if(ee)for(const ie of $)Vb(ee,ie);Ge(null),qt(!1),q([]),Z(ce.current)},[]);b.useEffect(()=>{const N=ie=>{W.current.has(ie.pointerId)&&(ie.type==="pointercancel"||ie.target!==m.current)&&Sr()},$=()=>Sr(),ee=()=>{document.hidden&&Sr()};return window.addEventListener("pointerup",N,!0),window.addEventListener("pointercancel",N,!0),window.addEventListener("blur",$),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("pointerup",N,!0),window.removeEventListener("pointercancel",N,!0),window.removeEventListener("blur",$),document.removeEventListener("visibilitychange",ee),Sr()}},[Sr]);const Kr=b.useCallback(()=>{Sr(),x.current?.disconnect(),x.current=null,Te("idle"),oe(null),Ze(null)},[Sr]),nn=b.useCallback((N,$=!1)=>{const ee=m.current;if(!ee||!N)return;Sr(),x.current?.disconnect(),oe(null),!$&&y.current!==N&&Ze(null),y.current=N,Zt(null),jt(null);const ie=new PF(ee,{onBitrateSupport:(ze,xt)=>{x.current!==ie||v.current.id!=="auto"||jt(ze?null:xt??"BITRATE_REASON_UNAVAILABLE")},onState:(ze,xt)=>{x.current===ie&&(Te(ze),oe(xt??null))},onHeader:ze=>{x.current===ie&&Ze(ze)},onStats:ze=>{x.current===ie&&St(ze)},onWarning:ze=>{x.current===ie&&Zt(ze)}});x.current=ie;let Qe=v.current;Qe.id==="auto"?(S.current?.serial!==N&&(S.current={serial:N,policy:new cF}),S.current.policy.connected(performance.now()),Qe=S.current.policy.quality,R(Qe.bitRate)):S.current=null,L.current=Qe,ie.connect(N,Qe)},[Sr]);b.useEffect(()=>{if(Ce!=="auto"||v.current.id!=="auto"||We!=="streaming"||!Je.adaptation||document.hidden)return;const N=S.current,$=x.current;if(!N||N.serial!==re||!$?.canSetBitrate)return;const ee=m.current,ie=ee?Math.max(ee.clientWidth,ee.clientHeight)*(window.devicePixelRatio||1)*ce.current:1600,Qe=N.policy.sample(Je.adaptation,performance.now(),ie||1600);Qe&&$.setBitrate(Qe.bitRate).then(ze=>{ze&&x.current===$&&(L.current=Qe,R(Qe.bitRate))})},[Je,Ce,We,re,nn]);const Fr=b.useCallback(N=>{const $={...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}:{}};ka({androidPanel:$}).catch(()=>{})},[]);b.useEffect(()=>{let N=!1;return fc().then($=>{if(N)return;const ee=$.androidPanel;if(ee?.quality){const ie=N1(ee.quality);v.current=ie,Ee(ie.id),Ie({maxSize:ie.maxSize,bitRate:ie.bitRate,maxFps:ie.maxFps}),zd(ie)}Ne(ee?.presets??[]),He(ee?.activePresetId??null),ee?.deviceSerial&&($e.current=ee.deviceSerial,Oe(ee.deviceSerial))}).catch(()=>{}),()=>{N=!0}},[]);const ks=b.useCallback(N=>{const $=++De.current;Lt(ie=>[...ie,{id:$,left:N.left,top:N.top}]);const ee=window.setTimeout(()=>{Lt(ie=>ie.filter(Qe=>Qe.id!==$)),er.current=er.current.filter(ie=>ie!==ee)},300);er.current.push(ee)},[]),Or=b.useCallback((N,$)=>{const ee=x.current,ie=L.current;ee?.supportsLiveBitrate&&y.current===N&&ie&&ie.maxSize===$.maxSize&&ie.maxFps===$.maxFps?ee.setBitrate($.bitRate).then(Qe=>{x.current===ee&&(Qe?(L.current=$,jt(null)):jt(ee.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):nn(N)},[nn,l]),Xr=b.useCallback(N=>{if(S.current=null,N.startsWith("user:")){const ee=Be.find(Qe=>Qe.id===N.slice(5));if(!ee)return;const ie={id:"custom",maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps};v.current=ie,Ee("custom"),He(ee.id),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0),zd(ie),Fr({quality:ie,activePresetId:ee.id}),re&&nn(re);return}if(N==="custom"){const ee=v.current;Ee("custom"),He(null),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0);return}const $=N==="auto"?N1({id:"auto"}):Of.find(ee=>ee.id===N)??k0;v.current=$,Ee($.id),He(null),zd($),Fr({quality:$,activePresetId:null}),re&&nn(re)},[nn,re,Be,Fr]),fn=b.useCallback(()=>{const N={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};v.current=N,zd(N),Fr({quality:N,activePresetId:null}),Ee("custom"),He(null),re&&Or(re,N)},[Or,re,st,Fr]),K=b.useCallback(()=>{const N=rt.trim();if(!N)return;const $=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,ee={id:$,name:N,maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps},ie=[...Be.filter(ze=>ze.name!==N),ee].slice(-12),Qe={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};Ne(ie),mt(""),He($),Ee("custom"),v.current=Qe,zd(Qe),Fr({quality:Qe,activePresetId:$,presets:ie}),re&&Or(re,Qe)},[rt,st,Be,re,Or,Fr]),Ue=b.useCallback(()=>{if(!le)return;const N=Be.filter($=>$.id!==le);Ne(N),He(null),Fr({activePresetId:null,presets:N})},[le,Be,Fr]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const N of er.current)window.clearTimeout(N);er.current=[]},[]),b.useEffect(()=>{if(d==="off")return;const N=$=>{$.key==="Escape"&&p("off")};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[d,p]),b.useEffect(()=>{const N=Wr.filter(ee=>ee.state==="device");if(re||N.length!==1)return;const $=N[0].serial;$e.current!==$&&($e.current=$,Oe($))},[Wr,re]),b.useEffect(()=>{re&&nn(re)},[re,nn]),b.useEffect(()=>{if(We==="streaming"){Y.current=0,Xt(!1);return}if(We!=="error"||!re||!ZF(H??""))return;const N=Math.min(8e3,700*2**Y.current);Y.current+=1,Xt(!0);const $=window.setTimeout(()=>{Xt(!1),nn(re)},N);return()=>window.clearTimeout($)},[We,H,re,nn]);const Et=b.useCallback((N,$,ee)=>{const ie=m.current,Qe=ee??(ie?Nh(ie):null);return!ie||!Qe?{x:0,y:0}:Y6(N,$,Qe)},[]),kt=b.useCallback(()=>{const N=m.current;if(!N)return;const{x:$,y:ee}=xe.current,ie=ce.current,Qe=ie===_l&&$===0&&ee===0?"":`translate3d(${$}px, ${ee}px, 0) scale(${ie})`;N.style.transform!==Qe&&(N.style.transform=Qe);const ze=pe.current;ze&&(ze.textContent=ie>_l?WF(ie):"")},[]),tr=b.useCallback((N,$,ee=!0)=>{const ie=m.current,Qe=ce.current,ze=HF(N);if(!ie||ze===Qe)return;const xt=Nh(ie);if(!xt)return;const _t=$??{x:xt.cx,y:xt.cy},Mr=Hb({zoom:Qe,pan:xe.current},xt,_t,_t,ze/Qe);ce.current=Mr.zoom,xe.current=Mr.pan,ee&&kt()},[kt]),Qr=b.useCallback(()=>{const N=ce.current;Z($=>$<=_l+.01==N<=_l+.01&&$>=rf-.01==N>=rf-.01?$:N)},[]);b.useEffect(()=>()=>{Rh(te.current),Rh(ke.current)},[]);const cr=()=>{let N=0,$=0;for(const ie of W.current.values())N+=ie.x,$+=ie.y;const ee=W.current.size;return ee?{x:N/ee,y:$/ee}:null},Sn=()=>{const[N,$]=Array.from(W.current.values());return N&&$?Math.hypot(N.x-$.x,N.y-$.y):0},Ls=()=>{const N=cr(),$=m.current?Nh(m.current):null;!N||!$||(F.current={startCentroid:N,startDistance:Sn(),box:$})},Zn=b.useCallback(()=>{const N=F.current,$=cr();if(!N||!$)return;const ee=Sn(),ie=N.startDistance>0&&ee>0?ee/N.startDistance:1,Qe=Hb({zoom:ce.current,pan:xe.current},N.box,N.startCentroid,$,ie);ce.current=Qe.zoom,xe.current=Qe.pan,N.startCentroid=$,N.startDistance=ee},[]),sn=b.useCallback(()=>{te.current||(te.current=qb(()=>{te.current=0,Zn(),kt()}))},[Zn,kt]),on=b.useCallback(()=>{te.current&&(Rh(te.current),te.current=0,Zn(),kt())},[Zn,kt]);b.useEffect(()=>{const N=m.current;if(!N)return;const $=N.parentElement;if(!$)return;const ee=Qe=>{if(Qe.ctrlKey||Qe.metaKey){if(Qe.preventDefault(),!Qe.deltaY||F.current)return;const _t=Qe.deltaMode===1?16:Qe.deltaMode===2?N.parentElement?.clientHeight||600:1,Mr=Math.max(-600,Math.min(600,Qe.deltaY*_t));tr(ce.current*Math.exp(-Mr*.002),{x:Qe.clientX,y:Qe.clientY},!1),ke.current||(ke.current=qb(()=>{ke.current=0,kt(),Qr()}));return}const ze=x.current;if(!ze||Qe.target!==N)return;Qe.preventDefault();const xt=jh(N,Qe.clientX,Qe.clientY);ze.scroll(xt.x,xt.y,Qe.deltaX,Qe.deltaY)},ie=Qe=>Qe.preventDefault();return $.addEventListener("wheel",ee,{passive:!1}),$.addEventListener("gesturestart",ie,{passive:!1}),$.addEventListener("gesturechange",ie,{passive:!1}),()=>{$.removeEventListener("wheel",ee),$.removeEventListener("gesturestart",ie),$.removeEventListener("gesturechange",ie)}},[tr,kt,Qr]),b.useEffect(()=>{const N=m.current,$=N?.parentElement;if(!N||!$||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(()=>{F.current&&(F.current.box=Nh(N));const ie=Et(xe.current,ce.current);ie.x===xe.current.x&&ie.y===xe.current.y||(xe.current=ie,kt())});return ee.observe(N),ee.observe($),()=>ee.disconnect()},[Et,kt]),b.useLayoutEffect(()=>{kt()});const _r=N=>{const $=x.current,ee=m.current;if(!$||!ee)return;if(N.pointerType==="mouse"&&N.button!==0){N.preventDefault(),N.button===2?$.back():N.button===1&&$.home();return}N.preventDefault(),ee.closest(".android-mirror-panel")?.focus({preventScroll:!0}),kt(),Qr(),on(),GF(ee,N.pointerId),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY});const ie=N.pointerType==="mouse"&&N.altKey;if(W.current.size>=2||ie){const xt=B.current;xt&&($.pointerCancel(xt.x,xt.y,xt.type),B.current=null,Ve.current=null,Ge(null),qt(!1),q([])),U.current=!0,Ls();return}if(U.current)return;const Qe=jh(ee,N.clientX,N.clientY);B.current={id:N.pointerId,type:N.pointerType,x:Qe.x,y:Qe.y},$.pointerDown(Qe.x,Qe.y,N.pointerType);const ze=Jb(ee,N.clientX,N.clientY);ze&&(Ve.current={left:ze.left,top:ze.top},q([]),qt(!1),Ge(ze))},$r=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(N.pointerType==="mouse"){const _t=ee.getBoundingClientRect(),Mr=ee.parentElement?.getBoundingClientRect()??_t;if(!(N.buttons&1)||N.clientX<Math.max(_t.left,Mr.left)||N.clientX>=Math.min(_t.right,Mr.right)||N.clientY<Math.max(_t.top,Mr.top)||N.clientY>=Math.min(_t.bottom,Mr.bottom)){Sr();return}}if(N.preventDefault(),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY}),F.current){sn();return}const ie=B.current;if(!$||!ie||ie.id!==N.pointerId)return;const Qe=jh(ee,N.clientX,N.clientY);ie.x=Qe.x,ie.y=Qe.y,$.pointerMove(Qe.x,Qe.y,ie.type);const ze=Jb(ee,N.clientX,N.clientY),xt=Ve.current;!ze||!xt||(Ge(ze),Math.hypot(ze.left-xt.left,ze.top-xt.top)>=6&&(qt(!0),q(_t=>{const Mr=_t[_t.length-1];if(Mr&&Math.hypot(ze.left-Mr.x,ze.top-Mr.y)<4)return _t;const Dt=[..._t,{x:ze.left,y:ze.top}];return Dt.length>12?Dt.slice(Dt.length-12):Dt})))},Wn=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(on(),W.current.delete(N.pointerId),Vb(ee,N.pointerId),W.current.size===0&&(U.current=!1),F.current){W.current.size===0?(F.current=null,Z(ce.current)):Ls();return}const ie=B.current;if(!ie||ie.id!==N.pointerId)return;const Qe=jh(ee,N.clientX,N.clientY);$?.pointerUp(Qe.x,Qe.y,ie.type),me&&ks(me),Ge(null),qt(!1),window.setTimeout(()=>q([]),200),B.current=null,Ve.current=null},Gn=N=>{if(Tr||et||yt)return;const $=x.current;$&&(N.key==="Backspace"?(N.preventDefault(),$.key(67)):N.key==="Escape"?(N.preventDefault(),$.back()):N.key==="Enter"&&(N.preventDefault(),$.key(66)))},un=async()=>{const N=Nt.trim();if(N){It(!0);try{const $=await dF(N);gt(""),Ct(!1),await qr(),Oe($.serial)}catch($){ye($ instanceof Error?$.message:"ADB_CONNECT_FAILED")}finally{It(!1)}}},Kn=()=>{const N=x.current,$=nr;!N||!$||(N.sendText($),Cr(""))},kr=b.useCallback(N=>{Lr(N),Ir.current!==null&&window.clearTimeout(Ir.current),Ir.current=window.setTimeout(()=>{Ir.current=null,Lr(null)},2500)},[]),Er=b.useCallback(N=>{const $=ce.current,ee=N==="in"?Gb.find(ie=>ie>$+.01):[...Gb].reverse().find(ie=>ie<$-.01);ee!==void 0&&($<=_l&&ee>_l&&kr(l("android.zoomPanHint")),on(),tr(ee),Z(ee))},[tr,on,kr,l]),gr=N=>{Promise.resolve().then(()=>r?.(N)).catch($=>{Vr($ instanceof Error?$.message:String($))})},rs=b.useCallback(async(N,$)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(N),kr($)}catch(ee){Vr(l("android.captureFailed")+(ee instanceof Error?`:${ee.message}`:""))}},[n,kr,l]),$n=async()=>{const N=m.current;if(!(!N||ne.current)){ne.current=!0,Ht(!0),Vr(null);try{const $=await $F(N);await rs($,l("android.captureInserted"))}catch($){Vr($ instanceof Error?$.message:String($))}finally{ne.current=!1,Ht(!1)}}},kn=b.useCallback(N=>{(N.status==="ready"||N.status==="error")&&Ot.current&&!Rr.current.has(N.id)&&(Rr.current.add(N.id),Ot.current?.(N))},[]),Ln=b.useCallback(async N=>{const $=an.current;if(!(!$||wt.current)){wt.current=!0,nt(!0),Vr(null);try{const ee=await mF($.id);an.current=null,dt(!1),kn(ee)}catch(ee){Vr(ee instanceof Error?ee.message:String(ee))}finally{wt.current=!1,nt(!1)}}},[kn]),ps=async()=>{if(!(!re||wt.current||an.current)){wt.current=!0,nt(!0),Vr(null);try{const N=await pF(re);N.status==="recording"||N.status==="starting"||N.status==="stopping"?(an.current=N,dt(!0),xn(Math.max(0,Date.now()-N.startedAt))):kn(N)}catch(N){Vr(N instanceof Error?N.message:String(N))}finally{wt.current=!1,nt(!1)}}};b.useEffect(()=>{let N=!1,$=!1;an.current=null,dt(!1);const ee=async()=>{if(!(!re||$||wt.current)){$=!0;try{const{recordings:Qe}=await fF(re);if(N||wt.current)return;const ze=Qe.find(xt=>["starting","recording","stopping"].includes(xt.status));an.current=ze??null,dt(!!ze);for(const xt of Qe)kn(xt)}catch{}finally{$=!1}}};ee();const ie=window.setInterval(()=>{ee()},2e3);return rn.current=window.setInterval(()=>{an.current&&xn(Math.max(0,Date.now()-an.current.startedAt))},500),()=>{N=!0,window.clearInterval(ie),rn.current!==null&&window.clearInterval(rn.current)}},[re,kn]),b.useEffect(()=>{if(!Tr)return;const N=()=>mr(!1),$=ie=>{const Qe=ie.target;Qe instanceof Node&&(dr.current?.contains(Qe)||bn.current?.contains(Qe)||N())},ee=ie=>{ie.key==="Escape"&&(ie.preventDefault(),ie.stopPropagation(),N())};return document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",ee,!0),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",ee,!0),window.removeEventListener("resize",N)}},[Tr]),b.useEffect(()=>()=>{Ir.current!==null&&window.clearTimeout(Ir.current)},[]);const G=We==="streaming",Le=ir,Ke=Le?"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",ct=fs?(fs.model||fs.serial)+ey(fs,l):Wr.length?l("android.selectDevice"):l("android.noDevices"),At=(le?Be.find(N=>N.id===le):null)?.name??(Ce==="auto"?`${l("android.qualityAuto")} · ${E/1e6} Mbps`:l(jm[Ce])),Rt=Le?"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",Bt=Le?"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",ot="absolute inset-0 h-full w-full cursor-pointer opacity-0",Ft=()=>{const N=dr.current?.getBoundingClientRect();N&&_n({left:Math.max(8,Math.min(N.right-Mm,window.innerWidth-Mm-8)),top:Math.min(N.bottom+4,Math.max(8,window.innerHeight-zF-8))}),mr(!0)},hr=()=>{if(ir){Pr(Ud,null),Fr({docked:null});return}if(!Tn)return;const N={sessionId:Tn,side:"right"};Pr(Ud,N),Fr({docked:N})},Kt=et||ir||d!=="off",z=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:Gn,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":ir?"true":void 0,className:Le?"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:[ir&&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(Ff,{size:12})}),s.jsx(u9,{size:Le?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${Rt} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Bt} w-full`,children:ct}),s.jsxs("select",{value:re,onChange:N=>{const $=N.target.value;Oe($),$e.current=$,$&&Fr({deviceSerial:$})},className:ot,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:Wr.length?l("android.selectDevice"):l("android.noDevices")}),Wr.map(N=>s.jsx("option",{value:N.serial,children:(N.model||N.serial)+ey(N,l)},N.serial))]})]}),s.jsxs("div",{className:`${Rt} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Bt,children:At}),s.jsxs("select",{value:le?`user:${le}`:Ce,onChange:N=>Xr(N.target.value),className:ot,title:l(Ce==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),Ce==="auto"?` · ${E/1e6} Mbps`:""]}),Of.map(N=>s.jsx("option",{value:N.id,children:l(jm[N.id])},N.id)),Be.map(N=>s.jsx("option",{value:`user:${N.id}`,children:N.name},N.id)),s.jsx("option",{value:"custom",children:l(jm.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{qr()},className:`${Ke} text-muted-foreground`,title:l("android.refresh"),children:_e?s.jsx(Cn,{size:13,className:"animate-spin"}):s.jsx(gn,{size:13})}),G?s.jsx("button",{type:"button",onClick:Kr,className:`${Ke} text-destructive`,title:l("android.disconnect"),children:s.jsx(Oy,{size:13})}):s.jsx("button",{type:"button",onClick:()=>re&&nn(re),disabled:!re,className:`${Ke} text-primary`,title:l("android.connect"),children:s.jsx(sS,{size:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{$n()},disabled:!n||ht,className:`${Ke} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:ht?s.jsx(Cn,{size:Le?12:13,className:"animate-spin"}):s.jsx(PA,{size:Le?12:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{it?Ln("manual"):ps()},disabled:Me||!it&&!a,className:`${Ke} ${it?"text-destructive":"text-muted-foreground"}`,title:l(it?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(it?"android.recordingStop":"android.recordingStart"),children:Me?s.jsx(Cn,{className:"animate-spin",size:13}):it?s.jsx(Py,{size:Le?10:11,fill:"currentColor"}):s.jsx(Fy,{size:Le?12:13})}),s.jsx("button",{ref:dr,type:"button",onClick:()=>Tr?mr(!1):Ft(),"aria-haspopup":"menu","aria-expanded":Tr,className:`${Ke} ${Kt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx($o,{size:Le?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{mr(!1),p("off"),c()},className:`${Ke} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(Rn,{size:14})})]}),Tr&&Hr&&Ii.createPortal(s.jsxs("div",{ref:bn,role:"menu","aria-label":l("android.more"),style:{left:Hr.left,top:Hr.top,width:Mm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(Mh,{icon:s.jsx(ul,{size:13}),label:l("android.addDevice"),active:et,onSelect:()=>{Ct(N=>!N),mr(!1)}}),s.jsx(Mh,{icon:ir?s.jsx(Rn,{size:13}):s.jsx(Il,{size:13}),label:l(ir?"android.splitClose":"android.splitOpen"),active:ir,disabled:!ir&&!Tn,onSelect:()=>{hr(),mr(!1)}}),s.jsx(Mh,{icon:d==="window"?s.jsx(ET,{size:13}):s.jsx(_T,{size:13}),label:l(d==="window"?"android.exitFullscreen":"android.fullscreen"),active:d==="window",onSelect:()=>{p(d==="window"?"off":"window"),mr(!1)}}),!t&&s.jsx(Mh,{icon:d==="sidebar"?s.jsx(FT,{size:13}):s.jsx(HT,{size:13}),label:l(d==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:d==="sidebar",onSelect:()=>{p(d==="sidebar"?"off":"sidebar"),mr(!1)}}),be&&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:`${Je.fps} fps · ${Je.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${Je.width}×${Je.height}`})]})]}),document.body),(Ce==="custom"||le)&&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:()=>Ye(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"),le?` · ${Be.find(N=>N.id===le)?.name??""}`:""]})]}),ue&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(Xb,{label:l("android.qualityResolution"),display:`${st.maxSize}px`,min:360,max:2160,step:8,value:st.maxSize,onChange:N=>Ie($=>({...$,maxSize:N}))}),s.jsx(Xb,{label:l("android.qualityBitRate"),display:`${(st.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:st.bitRate/1e6,onChange:N=>Ie($=>({...$,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($=>({...$,maxFps:N})),className:`rounded px-2 py-0.5 ${st.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 ${st.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:fn,disabled:!re,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:rt,onChange:N=>mt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&K()},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:K,disabled:!rt.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:l("android.presetSave")}),le&&s.jsx("button",{type:"button",onClick:Ue,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),et&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:Nt,onChange:N=>gt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&un()},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:()=>{un()},disabled:bt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:bt?s.jsx(Cn,{size:12,className:"animate-spin"}):l("android.connect")})]}),Br&&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(Zb,{label:l("android.insertFixPrompt"),onClick:()=>gr(Kb("adb",Se??"")),enabled:!!r})]}),!Br&&Mn&&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(Zb,{label:l("android.insertFixPrompt"),onClick:()=>gr(Kb("scrcpy","")),enabled:!!r})]}),fs&&fs.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:KF(fs,l)}),Se&&!Br&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Bb(Se)}),Vt&&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(Vt.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Vt.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Vt.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Vt.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Vt.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Vt.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Vt})]}),vt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:vt}),ge&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ge}),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:G||be?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:_r,onPointerMove:$r,onPointerUp:Wn,onPointerCancel:()=>Sr(),onLostPointerCapture:N=>{W.current.has(N.pointerId)&&Sr()},onPointerLeave:N=>{W.current.has(N.pointerId)&&!N.currentTarget.hasPointerCapture?.(N.pointerId)&&Sr()},onContextMenu:N=>N.preventDefault()}),me&&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:me.left,top:me.top}}),pt.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:at?1:0,transition:"opacity 160ms linear"},children:pt.slice(1).map((N,$)=>{const ee=pt[$],ie=($+1)/(pt.length-1);return s.jsx("line",{x1:ee.x,y1:ee.y,x2:N.x,y2:N.y,stroke:"var(--primary)",strokeWidth:1+1.6*ie,strokeLinecap:"round",opacity:.06+.45*ie},$)})}),zt.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)),!G&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[We==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(Cn,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),We==="error"&&s.jsxs(s.Fragment,{children:[s.jsx($u,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Pt?l("android.reconnecting"):Bb(H||"")}),re&&s.jsx("button",{type:"button",onClick:()=>{Y.current=0,nn(re)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),We==="idle"&&!Br&&!Mn&&s.jsxs(s.Fragment,{children:[s.jsx(RT,{size:22,className:"opacity-60"}),s.jsx("span",{children:Wr.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${Le?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Mo,{compact:Le,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!G,children:s.jsx(Cy,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!G,children:s.jsx(yT,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!G,children:s.jsx(jy,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!G,children:s.jsx(Ey,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!G,children:s.jsx(uS,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!G,children:s.jsx(jS,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!G,children:s.jsx(BS,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!G,children:s.jsx(aS,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.inputText"),active:yt,onClick:()=>pr(N=>!N),disabled:!G,children:s.jsx(My,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.zoomIn"),onClick:()=>Er("in"),disabled:!G||V>=rf-.01,children:s.jsx(Us,{size:14})}),s.jsx(Mo,{compact:Le,label:l("android.zoomOut"),onClick:()=>Er("out"),disabled:!G||V<=_l+.01,children:s.jsx(Dy,{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":it||!!cn||ht,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${it||cn||ht?"invisible":""}`,children:be?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(YF,{recording:it,elapsed:sr,status:ht?l("android.captureInserting"):cn,stopLabel:l("android.recordingStop"),onStop:()=>{Ln("manual")}})})]})]}),yt&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:nr,onChange:N=>Cr(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&(N.preventDefault(),Kn())},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:Kn,disabled:!nr,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(r0,{size:13})})]})]});return d==="window"?Ii.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:z}),document.body):t?ir&&pn?Ii.createPortal(z,pn):null:ir&&pn?s.jsxs(s.Fragment,{children:[Ii.createPortal(z,pn),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:()=>{Pr(Ud,null),Fr({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):z}function Mh({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(hi,{size:12,className:"shrink-0"})]})}function YF({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"}),zb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${zb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(Py,{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 Yb({sessionId:e}){const t=es(x=>x.docks[Xd]),r=!!t,n=t?.sessionId??e??null,c=Rm(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await L0("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await Wb(w,n)},[n]),d=b.useCallback(x=>{Rm.getState().enqueue(x,n)},[n]),p=es(x=>!!x.hosts[Xd]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,fc().then(x=>{const y=x.androidPanel?.docked;y&&(es.getState().docks[Xd]||es.getState().setDock(Xd,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&p&&s.jsx(qF,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>Z6(x,n):void 0,onRecordingComplete:d}),c&&s.jsx(UF,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):Wb(x,c.sessionId),onDone:()=>Rm.getState().remove(c.file.id)},c.file.id)]})}function Zb({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 Kb(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 Xb({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 Mo({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 Jb(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 jh(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 ZF(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 ey(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 KF(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function XF(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function JF(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function e$(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 t$(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function r$({result:e}){const{t}=zr(),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:t$(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:JF(d.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${p}%`,background:XF(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:e$(d.resetAt)})]},d.label)})}):c?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function n$({isOpen:e,onClose:t}){const{t:r}=zr(),[n,a]=b.useState([]),[c,l]=b.useState(!1),d=async(x=!1)=>{l(!0);try{const y=x?await d9():await h9();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(gn,{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(Rn,{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(d0,{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(r$,{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 ty=[{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~"}],s$=2,i$=20;function a$({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 o$({value:e,onChange:t,placeholder:r}){const{t:n}=zr(),[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=V3(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&&Rx(p),x=m&&!bf(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=Rx(y),v=w&&!bf(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(Rn,{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 l$({value:e,min:t,max:r,onChange:n}){const{t:a}=zr();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(Dy,{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(Us,{size:14})})]})}const c$=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:c,onResetDefaults:l})=>{const{t:d}=zr(),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:a1(R,B)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(R=>({id:R,label:R}))],v=q3(w,p.rowLayout),S=(R,B)=>{n(p.id,W=>{const F=W.actions.findIndex(Z=>Z.id===R);if(F===-1)return W;const U=F+B;if(U<0||U>=W.actions.length)return W;const V=[...W.actions];return[V[F],V[U]]=[V[U],V[F]],{...W,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 W=R.items[0]?.kind==="preset",F=Math.max(2,R.columns),U=W?`${Y3}px repeat(${Math.max(1,F-1)}, minmax(0, 1fr))`:`repeat(${F}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:U},children:R.items.map(V=>V.kind==="preset"?s.jsx(Z3,{mode:"auto",presetLabel:V.label,title:`Auto preset · ${V.label}`,disabled:!0},V.id):s.jsx(a$,{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(Us,{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(gn,{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(zs,{size:14})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.matchPrograms")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:d("toolbarPresets.typeEnterHint")})]}),s.jsx(o$,{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:[...X1(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(Us,{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(l$,{value:R,min:s$,max:i$,onChange:W=>n(p.id,F=>({...F,rowLayout:F.rowLayout.map((U,V)=>V===B?W:U)}))}),p.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(p.id,W=>({...W,rowLayout:W.rowLayout.filter((F,U)=>U!==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(Us,{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 W=m===R.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${W?"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(Iy,{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(kA,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(W?null:R.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:a1(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,F=>({...F,actions:F.actions.filter(U=>U.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(zs,{size:14})})]}),W&&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:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,label:F.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:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,sequence:F.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:ty.map(F=>s.jsx("button",{type:"button",onClick:()=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,sequence:F.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:F.label},F.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,F=>({...F,actions:F.actions.map(U=>U.id===R.id?{...U,doubleTapSequence:""}:U)})),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:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:F.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:[ty.map(F=>s.jsx("button",{type:"button",onClick:()=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:(V.doubleTapSequence??"")+F.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:F.label},F.label)),s.jsx("button",{type:"button",onClick:()=>n(p.id,F=>({...F,actions:F.actions.map(U=>{if(U.id!==R.id)return U;const{doubleTapSequence:V,...Z}=U;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)})]})]})]})},u$={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function d$(){const{t:e}=zr(),[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),[W,F]=k.useState([]),[U,V]=k.useState([]),[Z,ce]=k.useState(null),[xe,pe]=k.useState(new Set),[te,ke]=k.useState(null),[$e,Y]=k.useState("auto"),[Ae,lt]=k.useState({}),[Se,ye]=k.useState(null),[_e,je]=k.useState(null),[re,Oe]=k.useState(10),[Ce,Ee]=k.useState(""),[Be,Ne]=k.useState(""),[le,He]=k.useState(12e3),[rt,mt]=k.useState(null),[ue,Ye]=k.useState(null),st=k.useCallback(async()=>{const[me,Ge,pt,q]=await Promise.allSettled([f9(),p9(),fc(),ud()]);if(r(me.status==="fulfilled"?me.value:[]),Ge.status==="fulfilled"){const at=Ge.value;F(at.plugins??[]),V(at.errors??[])}else F([]),V([]);if(pt.status==="fulfilled"){const at=pt.value;pe(new Set(at.autoRenameAgents??[])),Y(at.autoRenameNamer??"auto"),lt(at.autoRenameModels??{}),Oe(at.autoRenameIntervalMinutes??10),Ee(at.autoRenamePromptPreference??""),Ne(at.autoRenamePromptPreference??""),He(at.autoRenamePromptPayloadChars??12e3)}else pe(new Set);ye(q.status==="fulfilled"?q.value:[])},[]);k.useEffect(()=>{st()},[st]);const Ie=async(me,Ge)=>{a(me),l(null);try{Ge==="install"?(await m9(me)).devMode&&p(me):(await g9(me),d===me&&p(null)),await st()}catch(pt){l(pt instanceof Error?pt.message:String(pt))}finally{a(null)}},We=me=>e(me==="installed"?"settings.agentHooksInstalled":me==="outdated"?"settings.agentHooksOutdated":me==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),Te=async()=>{B(null);let me;try{me=JSON.parse(L)}catch{B("Invalid JSON");return}try{await A9(me),E(""),x(!1),await st()}catch(Ge){if(Ge instanceof T9&&Ge.migration){V(pt=>[{slug:typeof me.slug=="string"?me.slug:"manifest.json",errors:Ge.message.split(`
|
|
164
|
-
`),code:Ge.code,migration:Ge.migration},...pt.filter(q=>q.slug!==me.slug)]);return}B(Ge instanceof Error?Ge.message:String(Ge))}},H=async()=>{const me=v.trim();if(me){mt("install"),B(null);try{await x9(me),S(""),w(!1),await st()}catch(Ge){B(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}}},oe=async me=>{mt(`remove:${me}`);try{await w9(me),Ye(Ge=>Ge?.slug===me?null:Ge),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},be=async me=>{mt(`check:${me}`),l(null);try{await v9(me),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},Ze=async me=>{mt(`update:${me}`),l(null);try{const Ge=await y9(me),pt=[Ge.hookWarning,Ge.titleWarning].filter(Boolean).join(" ");pt&&l(pt),Ye(q=>q?.slug===me?null:q),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},Je=async me=>{mt(`doctor:${me}`),l(null),Ye(null);try{const Ge=await b9(me);Ye(Ge),ye(await ud())}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},St=async me=>{const Ge=me.migration?.aiPrompt??me.errors.join(`
|
|
165
|
-
`);try{await navigator.clipboard.writeText(Ge),ce(me.slug),window.setTimeout(()=>ce(pt=>pt===me.slug?null:pt),1800)}catch{B(Ge)}},Vt=async me=>{if(te)return;const Ge=xe,pt=new Set(Ge);pt.has(me)?pt.delete(me):pt.add(me),pe(pt),ke(me),l(null);try{const q=await ka({autoRenameAgents:[...pt]});pe(new Set(q.autoRenameAgents??[])),ye(await ud(!0))}catch(q){pe(Ge),l(q instanceof Error?q.message:String(q))}finally{ke(null)}},jt=async me=>{const Ge=$e;Y(me),je("namer"),l(null);try{const pt=await ka({autoRenameNamer:me});Y(pt.autoRenameNamer??"auto"),ye(await ud(!0))}catch(pt){Y(Ge),l(pt instanceof Error?pt.message:String(pt))}finally{je(null)}},vt=async(me,Ge)=>{const pt=Ae,q={...pt};Ge?q[me]=Ge:delete q[me],lt(q),je(me),l(null);try{const at=await ka({autoRenameModels:q});lt(at.autoRenameModels??{})}catch(at){lt(pt),l(at instanceof Error?at.message:String(at))}finally{je(null)}},Zt=async me=>{const Ge=re;Oe(me),je("interval"),l(null);try{const pt=await ka({autoRenameIntervalMinutes:me});Oe(pt.autoRenameIntervalMinutes??10)}catch(pt){Oe(Ge),l(pt instanceof Error?pt.message:String(pt))}finally{je(null)}},Pt=async()=>{const me=Ce.trim();if(me!==Be){je("preference"),l(null);try{const pt=(await ka({autoRenamePromptPreference:me})).autoRenamePromptPreference??"";Ee(pt),Ne(pt)}catch(Ge){Ee(Be),l(Ge instanceof Error?Ge.message:String(Ge))}finally{je(null)}}},Xt=async me=>{const Ge=Math.max(1e3,Math.min(64e3,Math.round(me||12e3))),pt=le;He(Ge),je("payload-limit"),l(null);try{const q=await ka({autoRenamePromptPayloadChars:Ge});He(q.autoRenamePromptPayloadChars??12e3)}catch(q){He(pt),l(q instanceof Error?q.message:String(q))}finally{je(null)}},zt=new Set(W.map(me=>me.slug)),Lt=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:$e,disabled:_e!==null,onChange:me=>{jt(me.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")}),Se?.filter(me=>me.available).map(me=>s.jsx("option",{value:me.slug,children:me.displayName},me.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:re,disabled:_e!==null,onChange:me=>{Zt(Number(me.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(me=>s.jsxs("option",{value:me,children:[me," ",e("settings.agentAutoRenameMinutes")]},me))})]}),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:Ce,maxLength:2e3,rows:3,disabled:_e!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:me=>Ee(me.target.value),onBlur:()=>{Pt()},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:_e==="preference"?e("settings.saving"):`${Ce.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:le,disabled:_e!==null,onChange:me=>He(Number(me.target.value)),onBlur:me=>{Xt(Number(me.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 ud(!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(gn,{size:11,className:Se===null?"animate-spin":""})})]}),Se?.filter(me=>me.available).map(me=>{const Ge=me.models.find(pt=>pt.id===me.recommendedModel);return s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:me.displayName}),s.jsxs("select",{value:Ae[me.slug]??"",disabled:_e!==null,onChange:pt=>{vt(me.slug,pt.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:Ge?`${e("settings.agentAutoRenameAutomatic")} · ${Ge.displayName}`:e("settings.agentAutoRenameCliDefault")}),me.models.map(pt=>s.jsx("option",{value:pt.id,children:pt.displayName},pt.id))]})]},me.slug)}),Se?.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(Cn,{size:12,className:"animate-spin"})," …"]}),t?.map(me=>{const Ge=n===me.slug,pt=me.state!=="not-installed",q=zt.has(me.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:me.slug,displayName:me.displayName,accentColor:me.accentColor??"#878580",icon:me.icon,isPlugin:q,iconMode:me.iconMode,iconVersion:me.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:me.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] ${u$[me.state]}`,children:[me.state==="installed"&&s.jsx(Fu,{size:10,className:"mr-0.5 inline"}),(me.state==="outdated"||me.state==="needs-approval")&&s.jsx(Q1,{size:10,className:"mr-0.5 inline"}),We(me.state)]})]}),s.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",title:me.targetDisplay,children:[e("settings.agentHooksTarget")," ",me.targetDisplay]}),d===me.slug&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksDevMode")}),me.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:te!==null,onClick:()=>{Vt(me.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":xe.has(me.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(ll,{checked:xe.has(me.slug),disabled:te!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:Ge,onClick:()=>{Ie(me.slug,pt?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${pt?"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:[Ge?s.jsx(Cn,{size:11,className:"animate-spin"}):pt?s.jsx(zs,{size:11}):me.state==="outdated"?s.jsx(gn,{size:11}):s.jsx(f0,{size:11}),Ge?"…":pt?e("settings.agentHooksUninstall"):me.state==="outdated"?e("settings.agentHooksReinstall"):e("settings.agentHooksInstall")]})]})]},me.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(Us,{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:me=>S(me.target.value),onKeyDown:me=>{me.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()||rt!==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:[rt==="install"?s.jsx(Cn,{size:11,className:"animate-spin"}):s.jsx(f0,{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")})]}),W.map(me=>{const Ge=me.revision?.slice(0,8),pt=rt?.endsWith(`:${me.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:me.displayName}),me.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:me.source??void 0,children:[me.source??e("settings.agentPluginManualSource"),Ge?` · ${Ge}`:""]})]}),s.jsxs("button",{type:"button",disabled:rt!==null,onClick:()=>{Je(me.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:[rt===`doctor:${me.slug}`?s.jsx(Cn,{size:10,className:"animate-spin"}):s.jsx(TS,{size:10}),e("settings.agentPluginDoctor")]}),me.updateSupported&&s.jsxs("button",{type:"button",disabled:rt!==null,onClick:()=>{me.updateAvailable?Ze(me.slug):be(me.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:[pt?s.jsx(Cn,{size:10,className:"animate-spin"}):s.jsx(gn,{size:10}),me.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:rt!==null,onClick:()=>{oe(me.slug)},className:"rounded-full p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-[color:var(--warning)] disabled:opacity-50",title:e("settings.agentPluginDelete"),children:s.jsx(zs,{size:11})})]},me.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,": ",Lt]}),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(me=>s.jsxs("div",{children:["• ",me]},me))}),ue.nextSteps.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:ue.nextSteps.map(me=>s.jsxs("div",{children:["→ ",me]},me))})]}),U.map(me=>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:[me.slug,": ",me.code??e("settings.agentPluginInvalid")]}),s.jsxs("button",{type:"button",onClick:()=>{St(me)},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===me.slug?s.jsx(Fu,{size:10}):s.jsx(Ny,{size:10}),Z===me.slug?e("settings.agentPluginCopied"):e("settings.agentPluginCopyAiPrompt")]})]}),s.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-muted-foreground",children:me.errors.join(`
|
|
166
|
-
`)}),me.migration?.guideCommand&&s.jsx("code",{className:"mt-1 block select-all text-foreground",children:me.migration.guideCommand})]},me.slug)),y&&m&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsx("textarea",{value:L,onChange:me=>E(me.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:()=>{Te()},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(XA,{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 h$({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:d,onCheckDesktop:p,onInstallDesktop:m}){const{t:x}=zr(),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",W=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(gn,{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(gn,{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?W: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 f$({quality:e}){const{locale:t}=zr(),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 p$({backendSessionId:e}){const{locale:t}=zr(),r=t==="zh",[n,a]=k.useState(null),[c,l]=k.useState(!1);k.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(S9(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(f$,{quality:n})]})]})]})}const ry={"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 m$(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 g$({state:e,onDismiss:t}){const{t:r}=zr(),[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 W=window.setTimeout(()=>{d.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(W)},[n]);const m=async()=>{if(!d.current){d.current=!0,l(!1),a(!0);try{await C9()}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(ry[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(ry[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",B=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:m$(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(xS,{size:15}):s.jsx(yS,{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 x$=()=>()=>{},b$=()=>1/0;function y$(){const{t:e}=zr(),t=b.useId(),r=Bo(),n=b.useSyncExternalStore(r?.subscribe??x$,r?.retentionLimit??b$);if(!r)return null;const a=_9+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 R1="mobile-session-destroy";function v$(e,t){return t&&e.type==="session"&&e.destination?.droppableId===R1}const Sa="termdock-program-rules-cache",Dh="termdock-toolbar-presets-cache",Hd="termdock-settings-cache",ny="termdock-color-theme",sy="termdock:right-sidebar:file-preview-open-by-session:v2",Wd="termdock:running-session-button-enabled:v1",Gd="termdock:attention-button-enabled:v1",w$=60,iy=320,ay=420,jo=8;function oy(e,t,r){return Math.min(Math.max(e,t),r)}function ly(e){if(typeof window>"u")return{left:jo,top:jo};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(jo,window.innerWidth-iy-jo),l=Math.max(jo,window.innerHeight-ay-jo);return{left:oy(n+jo,jo,c),top:oy(a+jo,jo,l),width:iy,maxHeight:`min(${ay}px, calc(100vh - ${jo*2}px))`}}function A$(e){return e==="dark"||e==="light"}function T$(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 Dm(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,w$);return Object.fromEntries(t)}function S$(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 C$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function _$(e,t){const r=b0(),n=new Set(pE()),a=Array.isArray(e)?e:[],c=Eu(a),l=t<Zd;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 k$(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const L$={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},rp="__termdockOverlay",np="__termdockBaseAnchor",sp="__termdockBaseGuard",I$=3,cy=250,E$="termdock-notification-target-v1",uy="/__termdock-notification-target",dy=3e4;function N$(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 Au(e){if(!e||typeof e!="object")return null;const t=e[rp];return N$(t)?t:null}function Ig(e){return e&&typeof e=="object"?{...e}:{}}function X6(e){const t=Ig(e);return delete t[rp],t}function R$(e){const t=X6(e);return delete t[sp],{...t,[np]:!0}}function M$(){typeof window>"u"||window.history.pushState({...X6(window.history.state),[np]:!0,[sp]:!0},"",window.location.href)}function J6(){for(let e=0;e<I$;e+=1)M$()}function Bh(){typeof window>"u"||(window.history.replaceState(R$(window.history.state),"",window.location.href),J6())}function Vd(e){typeof window>"u"||window.history.pushState({...Ig(window.history.state),[np]:!0,[rp]:e,[sp]:!1},"",window.location.href)}function j$(e){typeof window>"u"||window.history.replaceState({...Ig(window.history.state),[np]:!0,[rp]:e,[sp]:!1},"",window.location.href)}const e4=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let Ca=new Set(e4);function hy(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 D$(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 fy(e,t){return s.jsx(PP,{sessionMode:e,state:t})}function B$(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 Q$=k.lazy(()=>Oc(()=>import("./CollaborationMainWorkspace-P_jXjsT-.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function P$(){const{t:e,locale:t,setLocale:r}=zr(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";k9();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(ny,A$)??"dark"),x=k.useRef(Tc(Hd,k$)).current,[y,w]=k.useState(x?.preventSleep??!1),[v,S]=k.useState(x?.networkAvailable??!0),[L,E]=k.useState(L9),[R,B]=k.useState(I9),[W,F]=k.useState(E9),[U,V]=k.useState(N9),[Z,ce]=k.useState(Ap),[xe,pe]=k.useState(x?.localAccess??L$),[te,ke]=k.useState(x?.localAccess?.name??""),[$e,Y]=k.useState(!1),[Ae,lt]=k.useState(null),[Se,ye]=k.useState(null),[_e,je]=k.useState(null),[re,Oe]=k.useState(!1),[Ce,Ee]=k.useState(null),Be=k.useMemo(()=>xo(),[]),Ne=!!(Be?.desktopUpdateState&&Be.checkDesktopUpdate&&Be.installDesktopUpdate),[le,He]=k.useState(null),[rt,mt]=k.useState(null),[ue,Ye]=k.useState(!1),[st,Ie]=k.useState(null),[We,Te]=k.useState(!1),[H,oe]=k.useState(()=>Dm(Tc(sy,T$)??{})),[be,Ze]=k.useState(0),[Je,St]=k.useState(!1),[Vt,jt]=k.useState(0),[vt,Zt]=k.useState(!1),[Pt,Xt]=k.useState(0),[zt,Lt]=k.useState(!1),[me,Ge]=k.useState(0),pt=k.useRef(null),[q,at]=k.useState({}),{terminalSettings:qt,updateTerminalSettings:Ve}=WB(),De=qt.fontSize,er=qt.rendererMode,[et,Ct]=k.useState(!1),Nt=k.useRef(R9()).current,[gt,bt]=b.useState(()=>Nt.sessions.map(C=>({id:C.sessionId,name:C.name,customName:C.customName,mode:C.mode,tmuxSessionName:C.tmuxSessionName}))),It=la(C=>C.groupId);k.useEffect(()=>{const C=()=>la.getState().terminal();return window.addEventListener("switch-terminal-session",C),()=>window.removeEventListener("switch-terminal-session",C)},[]);const[yt,pr]=k.useState(Nt.activeSessionId),[nr,Cr]=k.useState(!1);k.useEffect(()=>{nr&&M9({rendered:!0})},[nr]);const[cn,Lr]=k.useState(null),[ge,Vr]=k.useState(null),[it,dt]=k.useState([]),[sr,xn]=b.useState(()=>{const C=Yr.getState();return Nt.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)}),Nu("session-chrome-hydrated"),hy(Yr.getState().sessions)});b.useEffect(()=>{!Be||!et||Promise.all([Be.snapshot(),Be.desktopUpdateState?.()??Promise.resolve(null)]).then(([C,P])=>{He(C),mt(P)}).catch(C=>Ie(C instanceof Error?C.message:String(C)))},[Be,et]),b.useEffect(()=>{Be?.onDesktopUpdateState&&Be.onDesktopUpdateState(mt)},[Be]),b.useEffect(()=>Yr.subscribe(C=>{const P=hy(C.sessions);xn(de=>D$(de,P)?de:P)}),[]);const an=b.useCallback(async(C,P)=>{Vr(null),Lr({sessionId:C,status:"submitting",error:null});try{await j9(P),Lr(de=>de?.sessionId===C?{...de,status:"waiting",error:null}:de)}catch(de){const Tt=(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");Lr(Yt=>Yt?.sessionId===C?{...Yt,error:Tt}:Yt),Vr({tone:"error",message:Tt})}},[e]);b.useEffect(()=>{if(!cn||cn.status!=="waiting")return;const C=sr.get(cn.sessionId);if(!C||C.agentResumeRecovered||C.agentStatus===null&&!C.agent)return;const P=C.agent?.displayName??"Agent";Lr(null),Vr({tone:"success",message:e("tab.resumeAgentSuccess",{agent:P})})},[cn,sr,e]),b.useEffect(()=>{if(!cn||cn.status!=="waiting"||cn.error)return;const C=cn.sessionId,P=window.setTimeout(()=>{const de=e("tab.resumeAgentTimeout");Lr(tt=>tt?.sessionId===C&&tt.status==="waiting"?{...tt,error:de}:tt),Vr({tone:"error",message:de})},15e3);return()=>window.clearTimeout(P)},[cn,e]),b.useEffect(()=>{if(ge?.tone!=="success")return;const C=window.setTimeout(()=>Vr(null),3200);return()=>window.clearTimeout(C)},[ge]),b.useEffect(()=>{let C=!1;D9().then(de=>{C||je(de)}).catch(()=>{}),B9().then(de=>{C||Ee(de)}).catch(()=>{});const P=l2(de=>{C||(de.type==="update-state"?je(de.state):de.type==="server-health"&&Ee(de.state))});return()=>{C=!0,P()}},[]);const Me=b.useCallback(async()=>{try{Ee(await Q9())}catch(C){window.alert(C instanceof Error?C.message:String(C))}},[]),nt=b.useCallback(async()=>{const C=_e?.latestVersion;if(!(!C||re)&&window.confirm(e("sidebar.updateRestartConfirm",{version:C}))){Oe(!0);try{je(await P9())}catch(P){window.alert(P instanceof Error?P.message:String(P))}finally{Oe(!1)}}},[_e?.latestVersion,e,re]),wt=b.useCallback(async()=>{if(!re){Oe(!0);try{je(await O9())}catch(C){window.alert(C instanceof Error?C.message:String(C))}finally{Oe(!1)}}},[re]),Rr=b.useCallback(async()=>{if(!(!Be?.checkDesktopUpdate||ue)){Ye(!0);try{mt(await Be.checkDesktopUpdate())}catch(C){Ie(C instanceof Error?C.message:String(C))}finally{Ye(!1)}}},[Be,ue]),rn=b.useCallback(async()=>{if(!(!Be?.installDesktopUpdate||ue||rt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ye(!0);try{mt(await Be.installDesktopUpdate())}catch(C){Ie(C instanceof Error?C.message:String(C))}finally{Ye(!1)}}},[Be,ue,rt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=p,F9(p),On(ny,p)},[p]),b.useEffect(()=>{On(sy,Dm(H))},[H]);const Ir=Gt(C=>C.leftOpen),ne=Gt(C=>C.rightOpen),ht=Gt(C=>C.leftPinned),Ht=Gt(C=>C.leftSidebarWidth),Ot=Gt(C=>C.rightPinned),Tr=Gt(C=>C.rightSidebarWidth),mr=Gt(C=>C.rootPath),Hr=Gt(C=>C.contextKey),_n=Gt(C=>C.selectedFilePath),dr=Gt(C=>C.groupByFolder),bn=uf(C=>C.collaborationGroups),hn=Gt(C=>C.collapsedGroups),Tn=Gt(C=>C.toggleGroupCollapsed),[ir,pn]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Pr,qr]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[Wr,fs]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[Br,Mn]=b.useState([]),[Sr,Kr]=b.useState({available:!0,version:null,reason:null}),[nn,Fr]=b.useState(!1),[ks,Or]=b.useState(null),[Xr,fn]=b.useState(null),[K,Ue]=b.useState(null),[Et,kt]=b.useState(null),[tr,Qr]=b.useState(null),[cr,Sn]=b.useState(null),[Ls,Zn]=b.useState(null),[,sn]=b.useState(0),[on,_r]=b.useState(null),[$r,Wn]=b.useState(null),[Gn,un]=b.useState(null),[Kn,kr]=b.useState(!1),[Er,gr]=b.useState(()=>Tc(Wd,C=>typeof C=="boolean")??!1),rs=b.useCallback(async C=>{const P=Er;gr(C),On(Wd,C);try{const de=await ka({runningSessionButtonEnabled:C});gr(de.runningSessionButtonEnabled),On(Wd,de.runningSessionButtonEnabled)}catch{gr(P),On(Wd,P)}},[Er]),[$n,kn]=b.useState(()=>Tc(Gd,C=>typeof C=="boolean")??!0),Ln=b.useCallback(async C=>{const P=$n;kn(C),On(Gd,C);try{const de=await ka({attentionButtonEnabled:C});kn(de.attentionButtonEnabled),On(Gd,de.attentionButtonEnabled)}catch{kn(P),On(Gd,P)}},[$n]),[ps,G]=b.useState(null),Le=b.useCallback(C=>{G(C)},[]),Ke=b.useRef(!1),[ct,qe]=b.useState(null),[At,Rt]=b.useState(null),Bt=k.useRef(null),ot=k.useRef(!1),Ft=k.useRef(null),hr=k.useRef(!1),Kt=b.useCallback(()=>{Sn(null),Zn(null)},[]),z=k.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[N,$]=k.useState(z.current),[ee,ie]=k.useState(!0),Qe=k.useRef(z.current),ze=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=()=>{pn(C.matches),qr(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=()=>fs(C.matches);return P(),C.addEventListener("change",P),()=>C.removeEventListener("change",P)},[]);const xt=k.useMemo(()=>yt?it.find(C=>C.sessionIds.includes(yt))??null:null,[yt,it]),_t=xt?.id??null,Mr=xt?.sessionIds[0]??yt,Dt=k.useRef([]);k.useLayoutEffect(()=>{const C=Dt.current;if(Dt.current=it,C.length===0)return;const P=new Set(it.flatMap(de=>de.sessionIds));for(const de of C){const tt=de.sessionIds.filter(Tt=>!P.has(Tt)).map(Tt=>({sessionId:Tt,rootPath:Yr.getState().sessions.get(Tt)?.cwd??null}));tt.length>0&&Gt.getState().inheritRightSidebarStateFromSplitWorkspace(de.id,tt)}},[it]),k.useLayoutEffect(()=>((()=>{const P=Mr?Yr.getState().sessions.get(Mr)?.cwd??null:null;Gt.getState().setRootPath(P,Mr,_t)})(),Yr.subscribe((P,de)=>{const tt=Mr?P.sessions.get(Mr)?.cwd??null:null,Tt=Mr?de.sessions.get(Mr)?.cwd??null:null;tt!==Tt&&Gt.getState().setRootPath(tt,Mr,_t)})),[_t,Mr]);const Gr=k.useRef(Vy(window.location.search)??JS(Sc()?.targetPeerId)),[dn,jn]=k.useState("");k.useEffect(()=>{const C=Gr.current;if(!C)return;if(C.peerId&&C.peerId!==Sc()?.targetPeerId){const tt=$9().find(Tt=>Tt.targetPeerId===C.peerId);if(tt&&Bo()){try{XS(C)}catch{jn(t==="zh"?"无法在此浏览器打开架构链接。":"Cannot open this architecture link in this browser.");return}if(U9(tt)){Gr.current=null;const Tt=new URL(window.location.href);Tt.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",Tt);return}}jn(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}jn("");try{sessionStorage.setItem(`termdock.architecture.selection:${C.root}`,C.file)}catch{}const P=Gt.getState();P.setRootPath(C.root,Mr,_t),P.setRightTab("architecture"),P.openRight();const de=new URL(window.location.href);de.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",de),Mr&&(Gr.current=null)},[Mr,_t,t]);const ns=ir||Wr,Un=Pr*.95,fr=ns?Math.min(Math.max(Pr*.22,280),340):Math.min(Pr*.86,380),Mt=yt&&mr?`${yt}\0${mr}`:"",Dn=!!(Mt&&_n&&H[Mt]),Vn=b.useCallback(C=>{Mt&&(C&&!Gt.getState().selectedFilePath||oe(P=>{if(!!P[Mt]===C)return P;if(C)return Dm({...P,[Mt]:{updatedAt:Date.now()}});const tt={...P};return delete tt[Mt],tt}))},[Mt]);b.useEffect(()=>{KB(Mt,Hr,_n)&&oe(C=>{if(!C[Mt])return C;const P={...C};return delete P[Mt],P})},[Mt,Hr,_n]);const Bn=zt?"markdown-image-lightbox":vt?"markdown-outline":Je?"right-sidebar-repo-picker":ne&&Dn?"right-sidebar-file-preview":et?"settings":ne&&!(Ot&&ir)?"right-sidebar":Ir&&!(ht&&ir)?"left-sidebar":null,ss=k.useRef(Bn),$i=k.useRef(Bn),ua=k.useRef(!1),bs=k.useRef(!1),Wa=b.useCallback(()=>{if(typeof window>"u")return;const C=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!ir||!C||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[ir]),wo=b.useCallback(C=>{if(C==="markdown-image-lightbox"){Lt(!1),Ge(P=>P+1);return}if(C==="markdown-outline"){Zt(!1),Xt(P=>P+1);return}if(C==="right-sidebar-file-preview"){Zt(!1),Xt(P=>P+1),Vn(!1),Ze(P=>P+1);return}if(C==="right-sidebar-repo-picker"){St(!1),jt(P=>P+1);return}if(C==="settings"){Ct(!1),ws(!1),ti(!1),ls(!1);return}if(C==="left-sidebar"){Gt.getState().closeLeft();return}Zt(!1),Xt(P=>P+1),St(!1),jt(P=>P+1),Lt(!1),Ge(P=>P+1),Gt.getState().closeRight()},[Vn]),zn=b.useCallback(C=>{if(!c&&typeof window<"u"&&ss.current===C&&Au(window.history.state)===C){window.history.back();return}wo(C)},[wo,c]),da=b.useCallback(()=>{Ct(!1);const C=Gt.getState();C.closeRight(),C.openLeft()},[]),ms=b.useCallback(()=>{Ct(!1);const C=Gt.getState();C.closeLeft(),C.openRight()},[]),La=b.useCallback(()=>{Ct(!1);const C=Gt.getState();C.closeLeft(),C.openRight(),C.setRightTab("files"),C.openRightSearch()},[]),is=b.useCallback(()=>{const C=Gt.getState();if(C.leftPinned){C.setLeftPinned(!1),C.closeLeft();return}if(Ir){zn("left-sidebar");return}da()},[da,zn,Ir]),Ga=b.useCallback(()=>{const C=Gt.getState();C.leftPinned?(C.setLeftPinned(!1),C.openLeft()):(C.setLeftPinned(!0),C.openLeft())},[]),Ks=b.useCallback(()=>{const C=Gt.getState();C.setLeftPinned(!1),C.closeLeft()},[]),Xs=b.useCallback(()=>{const C=Gt.getState();C.rightPinned?(C.setRightPinned(!1),C.openRight()):(C.setRightPinned(!0),C.openRight())},[]),Hs=b.useCallback(()=>{const C=Gt.getState();C.setRightPinned(!1),C.closeRight()},[]),Va=b.useRef(0),Is=b.useRef(0),ha=b.useRef(null),dl=b.useCallback(C=>{C.preventDefault(),Va.current=C.clientX,Is.current=Gt.getState().leftSidebarWidth;const P=tt=>{ha.current===null&&(ha.current=requestAnimationFrame(()=>{ha.current=null;const Tt=tt.clientX-Va.current;Gt.getState().setLeftSidebarWidth(Is.current+Tt)}))},de=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",de),ha.current!==null&&(cancelAnimationFrame(ha.current),ha.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)},[]),qa=b.useRef(0),as=b.useRef(0),Rs=b.useRef(null),Ui=b.useCallback(C=>{C.preventDefault(),qa.current=C.clientX;const P=Gt.getState(),de=P.leftPinned?P.leftSidebarWidth:0;as.current=Ph(P.rightSidebarWidth,window.innerWidth,de);const tt=Yt=>{Rs.current===null&&(Rs.current=requestAnimationFrame(()=>{Rs.current=null;const jr=qa.current-Yt.clientX,vn=Gt.getState(),En=vn.leftPinned?vn.leftSidebarWidth:0;vn.setRightSidebarWidth(Ph(as.current+jr,window.innerWidth,En))}))},Tt=()=>{window.removeEventListener("mousemove",tt),window.removeEventListener("mouseup",Tt),Rs.current!==null&&(cancelAnimationFrame(Rs.current),Rs.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",tt),window.addEventListener("mouseup",Tt)},[]),gi=b.useCallback(()=>{const C=Gt.getState();if(C.rightPinned){C.setRightPinned(!1),C.closeRight();return}if(ne){zn("right-sidebar");return}ms()},[ms,zn,ne]),xi=b.useCallback(()=>{!Dn&&!c&&typeof window<"u"&&ss.current==="right-sidebar"&&Au(window.history.state)==="right-sidebar"&&(Vd("right-sidebar-file-preview"),$i.current="right-sidebar-file-preview"),Vn(!0)},[Dn,c,Vn]),hl=b.useCallback(()=>{zn("right-sidebar-file-preview")},[zn]),Js=b.useCallback(()=>{!Je&&!c&&typeof window<"u"&&ss.current==="right-sidebar"&&Au(window.history.state)==="right-sidebar"&&(Vd("right-sidebar-repo-picker"),$i.current="right-sidebar-repo-picker"),St(!0)},[Je,c]),Uo=b.useCallback(()=>{zn("right-sidebar-repo-picker")},[zn]),fa=b.useCallback(()=>{!vt&&!c&&typeof window<"u"&&ss.current&&Au(window.history.state)===ss.current&&(Vd("markdown-outline"),$i.current="markdown-outline"),Zt(!0)},[vt,c]),fl=b.useCallback(()=>{zn("markdown-outline")},[zn]),pl=b.useCallback(()=>{!c&&typeof window<"u"&&ss.current&&Au(window.history.state)===ss.current&&(Vd("markdown-image-lightbox"),$i.current="markdown-image-lightbox"),Lt(!0)},[c]),os=b.useCallback(()=>{zn("markdown-image-lightbox")},[zn]),Ms=b.useCallback(()=>{!c&&typeof window<"u"&&ss.current&&Au(window.history.state)===ss.current&&(j$("settings"),$i.current="settings"),Gt.getState().closeAll(),Ct(!0)},[c]),Ni=b.useCallback(()=>{zn("settings")},[zn]);b.useEffect(()=>{if(!Be)return;const C=()=>Ms();return window.addEventListener("termdock:open-settings",C),()=>window.removeEventListener("termdock:open-settings",C)},[Be,Ms]);const zo=b.useCallback(()=>{Te(!0),pt.current!==null&&(window.clearTimeout(pt.current),pt.current=null)},[]),jl=b.useCallback(()=>{pt.current!==null&&(window.clearTimeout(pt.current),pt.current=null),Te(!1),bs.current=!0,Bh(),bs.current},[]);b.useEffect(()=>()=>{pt.current!==null&&window.clearTimeout(pt.current)},[]),b.useEffect(()=>{c||Bh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let C=null;const P=()=>{C!==null&&(window.clearTimeout(C),C=null)},de=vn=>{if(ss.current,bs.current,ss.current){ss.current;return}!vn?.force&&bs.current||(vn?.userActivated&&(bs.current=!0),Bh(),bs.current,void 0)},tt=()=>{P(),C=window.setTimeout(()=>{C=null,de({force:!0})},cy)},Tt=()=>{de({userActivated:!0})},Yt=()=>{tt()},jr=()=>{document.visibilityState==="visible"&&tt()};return window.addEventListener("pointerdown",Tt,{capture:!0,passive:!0}),window.addEventListener("touchstart",Tt,{capture:!0,passive:!0}),window.addEventListener("keydown",Tt,{capture:!0}),window.addEventListener("pageshow",Yt),document.addEventListener("visibilitychange",jr),()=>{P(),window.removeEventListener("pointerdown",Tt,{capture:!0}),window.removeEventListener("touchstart",Tt,{capture:!0}),window.removeEventListener("keydown",Tt,{capture:!0}),window.removeEventListener("pageshow",Yt),document.removeEventListener("visibilitychange",jr)}},[c]),b.useEffect(()=>{ss.current=Bn},[Bn]),b.useEffect(()=>{if(typeof window>"u"||Bn||c)return;const C=window.setTimeout(()=>{ss.current?(ss.current,void 0):Bh()},cy);return()=>window.clearTimeout(C)},[Bn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const C=$i.current;ua.current,Bn&&Bn!==C&&!ua.current&&Vd(Bn),!Bn&&C&&Wa(),$i.current=Bn,!Bn&&ua.current&&window.setTimeout(()=>{ua.current=!1},0)},[Bn,c,Wa]),b.useEffect(()=>{if(typeof window>"u"||c)return;const C=()=>{const P=ss.current;if(bs.current,!P){bs.current=!1,bs.current,zo(),J6();return}ua.current=!0,wo(P)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[wo,zo,c]),b.useEffect(()=>{const C=P=>{const de=P.metaKey||P.ctrlKey;if(de&&P.key==="b"&&!P.shiftKey&&(P.preventDefault(),is()),de&&P.shiftKey&&P.key==="E"&&(P.preventDefault(),gi()),de&&P.shiftKey&&P.key==="P"&&(P.preventDefault(),La()),de&&!P.shiftKey&&P.altKey&&(P.key==="ArrowLeft"||P.key==="ArrowRight")){P.preventDefault();const tt=P.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}if(de&&P.shiftKey&&!P.altKey&&(P.code==="BracketLeft"||P.code==="BracketRight")){P.preventDefault();const tt=P.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}};return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C)}},[is,gi,La]);const Es=b.useCallback(async()=>{Y(!0),lt(null);try{const C=await ka({localAccess:{name:te}});pe(C.localAccess),ke(C.localAccess.name),On(Hd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){lt(C instanceof Error?C.message:"Failed to save local access name")}finally{Y(!1)}},[te]),Ia=b.useCallback(async()=>{Y(!0),lt(null);try{const C=await ka({localAccess:{reset:!0}});pe(C.localAccess),ke(C.localAccess.name),On(Hd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){lt(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)}},[]),Xn=b.useCallback(C=>{const P=B$(gt,C);P.map(de=>de.id).join("\0")!==gt.map(de=>de.id).join("\0")&&(bt(P),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:P.map(de=>de.id)}})))},[gt]),zi=b.useCallback(C=>{ir||C.type!=="session"||(Ke.current=!1,kr(!1),un(C.draggableId))},[ir]),Ri=b.useCallback(C=>{if(ir||C.type!=="session")return;const P=C.destination?.droppableId===R1;P!==Ke.current&&(Ke.current=P,kr(P),P&&navigator.vibrate?.(20))},[ir]),Hi=b.useCallback(C=>{const P=v$(C,!ir);if(Ke.current=!1,kr(!1),un(null),!P)return!1;const de=gt.find(Tt=>Tt.id===C.draggableId),tt=de?sr.get(de.id):null;return de&&B5({mode:de.mode,activeProgram:tt?.activeProgram??null,promptState:tt?.promptState??null,shellNames:Ca})?(Rt(null),qe(de.id),Ue(null)):de&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:de.id,source:"other",closeMode:de.mode==="tmux"?"destroy":"auto"}})),!0},[ir,gt,sr]),{groups:gs,arranged:Ws}=k.useMemo(()=>lf(gt,C=>sr.get(C.id)?.cwd??null,dr,e("sidebar.ungrouped"),it,bn),[gt,sr,dr,e,it,bn]),Dl=b.useCallback(C=>{Hi(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}}))},[Hi,Ws]),Wi=b.useCallback((C,P)=>{const de=P.trim();de&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:C,name:de}}))},[]),Gi=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:C}}))},[]),{newSessionMode:ln,newSessionTmuxName:pa,userSelectedNewSessionMode:Vi,setNewSessionMode:Ea}=qB(),[Mi,ji]=b.useState(null),[ei,ws]=k.useState(!1),[Gs,Di]=k.useState(!1),[Na,ti]=k.useState(!1),[ys,Ya]=k.useState("idle"),Za=k.useRef(Tc(Dh,C$)).current,[As,Ka]=k.useState(()=>{const C=Za?.presets;if(C&&C.length>0){const P=Eu(C);if(P.length>0)return P}return b0()}),[Bl,Ho]=k.useState(!1),[Ao,ma]=k.useState("default"),Ra=k.useRef(typeof Za?.updatedAt=="number"?Za.updatedAt:null),Wo=k.useRef(!1),[ga,ls]=k.useState(!1),[Go,qi]=k.useState(!1),gl=k.useRef(Tc(Sa,S$)).current,[se,T]=k.useState(gl??[]),[j,Q]=k.useState(gl!==null),[O,fe]=k.useState(!1),we=!It&&!Bn&&!Gs&&!Na&&!ei&&!ga&&!Go&&!cr&&!ct&&!Mi,Pe=k.useCallback(C=>{const P=typeof C.version=="number"?C.version:0,de=_$(Array.isArray(C.presets)?C.presets:[],P);Ra.current=typeof C.updatedAt=="number"?C.updatedAt:null,Ka(tt=>z9(tt,de)?tt:(Wo.current=!0,de)),On(Dh,{version:Zd,presets:de,updatedAt:Ra.current??void 0})},[]);b.useEffect(()=>{const C=P=>{if(P.key!=="Escape"||P.defaultPrevented||P.isComposing||D1())return;if(Gs){P.preventDefault(),Di(!1);return}if(Na){P.preventDefault(),ti(!1);return}if(ei){P.preventDefault(),ws(!1);return}if(ga){P.preventDefault(),ls(!1);return}if(Go){P.preventDefault(),qi(!1);return}if(cr){P.preventDefault(),Kt();return}if(on){P.preventDefault(),Qr(null),_r(null);return}if(et){P.preventDefault(),Ni();return}if(ne&&!(Ot&&ir)){P.preventDefault(),zn("right-sidebar");return}Ir&&!(ht&&ir)&&(P.preventDefault(),zn("left-sidebar"))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[Gs,Na,ei,ga,cr,Kt,et,ne,Ot,Ir,ht,ir,Ni,zn]),b.useEffect(()=>{Q(!0)},[]);const[Xe,ft]=k.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:e4}),[,Jt]=k.useState(!1),or=k.useCallback(()=>H9().then(C=>{ft(C),Ca=new Set(C.shellNames),Jt(!0)}).catch(()=>{}),[]);b.useEffect(()=>{or()},[or]),b.useEffect(()=>l2(C=>{if(C.type==="config-updated"){if(C.key==="toolbar-presets"){c2().then(P=>Pe(P)).catch(P=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",P)});return}C.key==="program-detection"&&or()}}),[Pe,or]),b.useEffect(()=>{let C=!1;return(async()=>{try{const P=await c2();if(C)return;Pe(P)}catch(P){console.warn("[toolbar-presets] Failed to load from server:",P)}finally{C||Ho(!0)}})(),()=>{C=!0}},[Pe]),b.useEffect(()=>{if(Bl){if(Wo.current){Wo.current=!1;return}On(Dh,{version:Zd,presets:As,updatedAt:Ra.current??void 0}),W9({version:Zd,presets:As,baseUpdatedAt:Ra.current??void 0}).then(C=>{Ra.current=typeof C.updatedAt=="number"?C.updatedAt:null,On(Dh,{version:Zd,presets:As,updatedAt:Ra.current??void 0})}).catch(C=>{const P=C instanceof Error&&"current"in C?C.current:null;P&&typeof P=="object"&&Pe(P),console.warn("[toolbar-presets] Failed to save to server:",C)})}},[Pe,As,Bl]),b.useEffect(()=>{fc().then(C=>{w(P=>P===C.preventSleep?P:C.preventSleep),S(P=>P===C.networkAvailable?P:C.networkAvailable),pe(C.localAccess),ke(C.localAccess.name),gr(C.runningSessionButtonEnabled),On(Wd,C.runningSessionButtonEnabled),kn(C.attentionButtonEnabled),On(Gd,C.attentionButtonEnabled),On(Hd,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!L)return;const C=Ap();ce(C),C!=="granted"&&(E(!1),eh(!1))},[L]),b.useEffect(()=>{if(!L)return;dd();const C=()=>{document.visibilityState==="visible"&&(dd(),sA())},P=window.setInterval(()=>{dd()},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 Ur=b.useCallback(async()=>{if(L){E(!1),eh(!1),G9(),ce(Ap());return}const C=await V9();if(ce(C),C!=="granted"){E(!1),eh(!1);return}E(!0),eh(!0),await dd(!0,!0),Ya("idle")},[L]),Jr=b.useCallback(async()=>{Ya("checking"),await xo()?.prepareNotificationTest?.();const C=await q9({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Ya(C?"delivered":"failed")},[e]),Qn=b.useCallback(C=>{B(C),Y9(C),Tp()},[]),vr=b.useCallback(C=>{F(C),Z9(C),Tp()},[]),yn=b.useCallback(C=>{V(C),K9(C),Tp()},[]);b.useEffect(()=>{As.some(C=>C.id===Ao)||ma(As[0]?.id??"default")},[Ao,As]),b.useEffect(()=>{if(!Sr.available&&ln==="tmux"){Ea("shell",{userInitiated:!1});return}Sr.available&&Vi!=="shell"&&ln!=="tmux"&&Ea("tmux",{userInitiated:!1})},[ln,Sr.available,Vi,Ea]),b.useEffect(()=>{ji(null)},[et,ln,Sr.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),at(C)},[]);const cs=b.useCallback(C=>{if(Hi(C)||!C.destination)return;if(C.type==="group"){if(C.source.index===C.destination.index)return;Xn(Uy(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(tt=>tt.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,Xn,Hi]),js=k.useMemo(()=>Ws.flatMap(C=>{const P=sr.get(C.id);if(P?.agentStatus!=="working")return[];const{primary:de,secondary:tt}=il(C,P?.activeProgram??null,P?.cwd??null,Ca,P?.shellTitle??null,P?.promptState??null);return[{id:C.id,label:de,detail:tt}]}),[Ws,sr]),pc=yt?Ws.findIndex(C=>C.id===yt):-1,Vs=Ws.length>0&&pc>=0?`${pc+1}/${Ws.length}`:`${Ws.length}`,Yi=k.useMemo(()=>{let C=0;for(const P of gt){const de=sr.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&(C+=1)}return{running:js.length,review:C}},[js.length,gt,sr]),To=k.useMemo(()=>Ws.flatMap(C=>{const P=sr.get(C.id);if(P?.agentStatus!=="waiting"&&!P?.agentNeedsReview)return[];const{primary:de}=il(C,P.activeProgram,P.cwd,Ca,P.shellTitle,P.promptState);return[{id:P.terminalSessionId??C.id,label:de,waiting:P.agentStatus==="waiting"}]}),[Ws,sr]);X9(Yi.running,Yi.review,To);const bi=yt?gt.find(C=>C.id===yt)??null:null,So=bi?sr.get(bi.id):void 0,Jc=!!(bi&&So?.agentResumeRecovered&&So.agentNativeSessionId&&So.terminalSessionId),yi=bi&&cn?.sessionId===bi.id?cn:null;k.useLayoutEffect(()=>{if(!ee)return;const C=Ft.current;if(!C)return;const P=!hr.current;C.scrollIntoView({inline:"nearest",block:"nearest",behavior:P?"auto":"smooth"}),hr.current=!0,P&&Nu("active-tab-positioned")},[yt,ee]),b.useEffect(()=>{tr&&Bt.current&&(Bt.current.scrollIntoView({block:"nearest",inline:"nearest"}),Bt.current.focus(),Bt.current.select()),tr||(ot.current=!1)},[tr]);const O0=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:C}))},[]),vi=b.useCallback((C,P)=>{Zn(P??null),Sn(C)},[]),td=g6(),Xa=b.useCallback(C=>{if(!C)return;$(C),ze.current&&_a("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:ze.current,requestedSessionId:C,activeSessionId:yt,sessions:gt.map(de=>({id:de.id,terminalSessionId:sr.get(de.id)?.terminalSessionId??null}))}),J9(C);const P=gt.find(de=>de.id===C||sr.get(de.id)?.terminalSessionId===C);P?(Qe.current=null,ze.current&&_a("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:ze.current,requestedSessionId:C,targetSessionId:P.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):(Qe.current=C,ze.current&&_a("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:ze.current,requestedSessionId:C}))},[yt,gt,sr]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let C=!1;const P=async()=>{if(window.parent!==window&&Bo()){ie(!0);return}try{const tt=await caches.open(E$),Tt=await tt.match(uy);if(!Tt)return;await tt.delete(uy);const Yt=await Tt.json();if(C)return;const jr=typeof Yt.sessionId=="string"?Yt.sessionId:null,vn=typeof Yt.traceId=="string"?Yt.traceId:null,En=typeof Yt.clickedAt=="number"?Yt.clickedAt:0,In=Date.now()-En;_a("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:vn,sessionId:jr,ageMs:In,valid:!!(jr&&In>=0&&In<=dy),visibilityState:document.visibilityState}),jr&&In>=0&&In<=dy&&(ze.current=vn,typeof Yt.targetPeerId=="string"&&Yt.targetPeerId!==Sc()?.targetPeerId?Bo()?.focusSession(Yt.targetPeerId,jr):Xa(jr))}catch(tt){_a("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:tt instanceof Error?tt.message:String(tt)})}finally{C||ie(!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)}},[Xa]),b.useEffect(()=>{if(typeof window>"u")return;const C=new URLSearchParams(window.location.search),P=C.get("session");if(!P)return;_a("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:ze.current,targetSessionId:P,href:window.location.href,visibilityState:document.visibilityState});const de=C.get("service");de&&de!==Sc()?.targetPeerId?Bo()?.focusSession(de,P):Qe.current=P,C.delete("service"),C.delete("session"),C.delete("_notifTrace");const tt=C.toString(),Tt=`${window.location.pathname}${tt?`?${tt}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",Tt)},[]),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(),tt=`${window.location.pathname}${de?`?${de}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",tt),window.parent!==window&&Bo())return;const Tt=new BroadcastChannel("termdock:notif");let Yt=!1;const jr=En=>{En.data?.type==="termdock:notif-pong"&&!Yt&&(Yt=!0,Tt.close(),window.close())};Tt.addEventListener("message",jr),Tt.postMessage({type:"termdock:notif-ping",sessionId:P,targetPeerId:C.get("service")});const vn=setTimeout(()=>{Yt||Tt.close()},500);return()=>{clearTimeout(vn),Yt||Tt.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&Bo())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?Bo()?.focusSession(de.data.targetPeerId,de.data.sessionId):Xa(de.data.sessionId)))};return C.addEventListener("message",P),()=>C.close()},[Xa]),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){Bo()?.focusSession(de.targetPeerId,de.sessionId)&&P.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}P.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),Xa(de.sessionId)}else de?.type==="termdock:push-subscription-changed"?dd(!0):de?.type};return navigator.serviceWorker.addEventListener("message",C),()=>navigator.serviceWorker.removeEventListener("message",C)},[Xa]),b.useEffect(()=>{const C=P=>{const de=P.detail;typeof de=="string"&&Xa(de)};return window.addEventListener("termdock:focus-session",C),()=>window.removeEventListener("termdock:focus-session",C)},[Xa]),b.useEffect(()=>{const C=()=>{const P=iA(Sc()?.targetPeerId);P&&Xa(P)};return C(),window.addEventListener("termdock:workspace-session",C),()=>window.removeEventListener("termdock:workspace-session",C)},[Xa]),b.useEffect(()=>{const C=Qe.current;if(!C)return;const P=gt.find(de=>de.id===C||sr.get(de.id)?.terminalSessionId===C);P?(Qe.current=null,ze.current&&_a("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:ze.current,requestedSessionId:C,targetSessionId:P.id,activeSessionId:yt}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):ze.current&&_a("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:ze.current,requestedSessionId:C,activeSessionId:yt,sessions:gt.map(de=>({id:de.id,terminalSessionId:sr.get(de.id)?.terminalSessionId??null}))})},[yt,gt,sr]);const xa=k.useMemo(()=>{const C=[];for(const P of gt){const de=sr.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&C.push(P.id)}return C},[gt,sr]),Ql=b.useCallback(()=>{if(xa.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const C=yt?gt.findIndex(de=>de.id===yt):-1,P=xa.find(de=>gt.findIndex(tt=>tt.id===de)>C)??xa[0];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[xa,gt,yt]),eu=b.useCallback(()=>{if(xa.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const C=yt?gt.findIndex(de=>de.id===yt):gt.length,P=[...xa].reverse().find(de=>gt.findIndex(tt=>tt.id===de)<C)??xa[xa.length-1];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[xa,gt,yt]);b.useEffect(()=>{const C=P=>{!P.altKey||!P.shiftKey||P.metaKey||P.ctrlKey||P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventDefault(),P.key==="ArrowUp"?eu():Ql())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Ql,eu]);const ip=b.useCallback(async C=>{const de=Yr.getState().sessions.get(C)?.cwd;if(de)try{await navigator.clipboard?.writeText(de),Wn(de),window.setTimeout(()=>{Wn(tt=>tt===de?null:tt)},1400)}catch{}},[]),ap=b.useCallback(C=>{bt(C.sessions),pr(C.activeSessionId),dt(C.splitWorkspaces),Yr.getState().setActiveSessionId(C.activeSessionId)},[]),op=b.useCallback(()=>{Cr(!0)},[]),lp=b.useCallback(()=>{Cr(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!N||!yt)return;gt.find(P=>P.id===N||sr.get(P.id)?.terminalSessionId===N)?.id===yt&&$(null)},[yt,N,gt,sr]);const rd=b.useRef(!1),[tu,F0]=b.useState(!1),Ma=b.useCallback(C=>{const P=!C?.onResult;if(P&&rd.current)return;P&&(rd.current=!0,F0(!0));const de=C?.mode??ln,tt=de==="tmux"&&(C?.tmuxSessionName?.trim()||pa.trim())||void 0,Tt=C?.cwd||(yt?Yr.getState().sessions.get(yt)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:de,tmuxSessionName:tt,cwd:Tt,command:C?.command,shouldActivate:C?.shouldActivate,onResult:C?.onResult??(Yt=>{rd.current=!1,F0(!1),Yt.ok||Vr({tone:"error",message:e(Um(Yt.error))})})}}))},[ln,pa,yt,e]),Vo=b.useCallback(async()=>{Fr(!0);try{const C=await Bm();if(Kr(C),!C.available){Mn([]);return}const P=await Qm();Mn(P)}catch{Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Mn([])}finally{Fr(!1)}},[]),mc=b.useCallback(async C=>{const{cleanedSessions:P}=await yy(C);for(const de of P)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:de}));await Vo()},[Vo]),ru=b.useCallback(async C=>{fn(C),Ue(null);try{await mc(C),Or(null)}catch(P){Ue(P instanceof Error?P.message:"Failed to kill tmux session")}finally{fn(null)}},[mc]);b.useEffect(()=>{if(!Et)return;if(Br.find(de=>de.name===Et&&(de.connected||de.boundFrontendSessionId))){kt(null);return}const P=setTimeout(()=>kt(null),1e4);return()=>clearTimeout(P)},[Et,Br]);const gc=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:C}))},[]),nu=b.useCallback(C=>{const P=C??yt;P&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:P}))},[yt]),nd=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:C,layout:P}}))},[]),$0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:C,sessionIds:P}}))},[]),U0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:C,name:P}}))},[]),z0=b.useCallback((C,P)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:C,secondaryId:P}}))},[]),Pl=b.useCallback((C,P,de)=>{const tt=gt.find(Yt=>Yt.id===C);if(!tt)return;const Tt=sr.get(C);if(de?.skipConfirmation||!B5({mode:tt.mode,activeProgram:Tt?.activeProgram??null,promptState:Tt?.promptState??null,shellNames:Ca})){gc({sessionId:C,source:"sidebar",closeMode:tt.mode==="tmux"?"destroy":"auto"});return}Rt(P?{x:P.clientX,y:P.clientY}:null),qe(C),Ue(null)},[gt,sr,gc]);b.useEffect(()=>{if(!Be)return;const C=P=>{const de=P.detail;de==="new-session"?Ma():de==="close-session"?yt&&Pl(yt):de==="previous-session"||de==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:de==="next-session"?"next":"prev"}})):de==="toggle-left-sidebar"?is():de==="toggle-right-sidebar"?gi():de==="previous-attention"?eu():de==="next-attention"&&Ql()};return window.addEventListener("termdock:native-command",C),()=>window.removeEventListener("termdock:native-command",C)},[yt,Be,Ma,Pl,is,gi,Ql,eu]);const Ja=k.useMemo(()=>gt.find(C=>C.id===ct)??null,[gt,ct]),sd=b.useCallback(()=>{Ja&&(gc({sessionId:Ja.id,source:"sidebar",closeMode:"destroy"}),qe(null),Rt(null))},[Ja,gc]);b.useEffect(()=>{if(!Ja)return;const C=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopImmediatePropagation(),qe(null),Rt(null),Ue(null);return}P.key!=="Enter"||P.isComposing||P.keyCode===229||P.altKey||P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.stopImmediatePropagation(),P.repeat||sd())};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[Ja,sd]);const H0=k.useMemo(()=>{if(!Ja)return"";const C=sr.get(Ja.id);return il(Ja,C?.activeProgram??null,C?.cwd??null,Ca,C?.shellTitle??null,C?.promptState??null).primary},[Ja,sr]);b.useEffect(()=>{if(!et)return;let C=!1,P=!1;const de=async()=>{if(!P)try{const Tt=await Bm();if(C||Kr(Tt),!Tt.available){C||Mn([]);return}const Yt=await Qm();C||Mn(Yt)}catch{P=!0,C||(Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Mn([]))}};de();const tt=setInterval(()=>{de()},4e3);return()=>{C=!0,clearInterval(tt)}},[et]);const xc=Mi??ln,Ol=xc==="shell",su=xc==="tmux"&&Sr.available,xl=k.useMemo(()=>$y(Br.map(C=>({...C,id:C.name})),C=>C.cwd??null,e("sidebar.ungrouped")),[Br,e]),id=k.useMemo(()=>Br.filter(C=>C.recoveryCandidate===!0&&!C.connected&&!C.boundFrontendSessionId).sort((C,P)=>(P.lastActiveAt??P.createdAt??0)-(C.lastActiveAt??C.createdAt??0)),[Br]);b.useEffect(()=>{!Ir&&!(ht&&ir)||Vo()},[Ir,ht,ir,gt.length,Vo]);const bc=(C,P,de,tt=!1)=>{const Tt=C.id===yt,Yt=C.id===tr,jr=sr.get(C.id),{primary:vn,secondary:En}=il(C,jr?.activeProgram??null,jr?.cwd??null,Ca,jr?.shellTitle??null,jr?.promptState??null),In=Yu(jr?.cwd??null),wi=P?En??(In&&In!==vn?In:null):null,wn=jr?.gitStatus,Zi=`${jr?.cwd||C.name}${wn?`
|
|
186
|
-
⎇ ${wn.branch} +${wn.added} −${wn.removed}`:""}`,_o=!!(jr?.tuiProgress&&jr.tuiProgress.state!=="remove"),ko=jr?.agentStatus==="working"||_o?"var(--success)":jr?.agentStatus==="waiting"||jr?.agentNeedsReview?"var(--warning)":jr?.inCopyMode?"var(--tmux)":null;if(Yt&&ir&&!on){const Da=C.customName?C.name:vn,Bi=(eo,cp)=>{const ld=cp.trim();ld?ld!==Da&&Wi(eo,ld):Gi(eo),Qr(null)};return s.jsx("input",{ref:eo=>{Bt.current=eo},type:"text",defaultValue:Da,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(Da.length,5)}ch`},onKeyDown:eo=>{eo.key==="Enter"?Bi(C.id,eo.target.value):eo.key==="Escape"&&Qr(null)},onBlur:eo=>Bi(C.id,eo.target.value)})}return s.jsx("div",{ref:Tt?Ft:null,onContextMenu:Da=>{Da.preventDefault(),Zn({x:Da.clientX,y:Da.clientY}),Sn(C.id)},...td(()=>vi(C.id)),className:tt?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${Tt?"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 ${Tt?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!tt&&Tt&&ko?{boxShadow:`inset 2px 0 0 0 ${ko}`}:!tt&&Tt?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:Zi,children:s.jsx("button",{type:"button",...de??{},onClick:()=>O0(C.id),className:`inline-flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left ${tt?"px-1":"py-1 pl-1 pr-1.5 sm:pl-1.5 sm:pr-2"} ${de?"cursor-grab active:cursor-grabbing":""}`,title:Zi,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:[fy(C.mode,jr),jr?.agentResumeRecovered&&s.jsx(Qc,{size:tt?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),_o&&!jr?.agentStatus&&s.jsx(Cn,{size:tt?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),wi?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] ${jr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:vn}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:wi})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${jr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:vn})]})})})},ad=()=>s.jsx(Ll,{droppableId:R1,type:"session",isDropDisabled:ir,children:(C,P)=>{const de=Kn||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":!Gn,"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 ${Gn?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(zs,{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]})}}),ba=ht&&ir,Fl=Ot&&ir,od=Ph(Tr,Pr,ba?Ht:0),yc=Fl?od+by:0,$l=ba?gt.find(C=>C.id===yt):null,Ds=$l?sr.get($l.id):void 0,W0=$l?il($l,Ds?.activeProgram??null,Ds?.cwd??null,Ca,Ds?.shellTitle??null,Ds?.promptState??null).primary:"",ja=ir?xt:null,Co=ba&&!ja&&Ds?Ds.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Ds.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Ds.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Ds.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",Ul=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[dn&&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:dn}),s.jsx("button",{type:"button",className:"min-h-11 px-2 text-primary",onClick:()=>jn(""),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(tC,{rightInset:yc,workspace:It&&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(Q$,{groupId:It,activeSessionId:yt,defaultSessionMode:ln,onOpenSidebar:is,leftSidebarVisible:Ir||ba,onToggleRightSidebar:gi,rightSidebarOpen:ne||Fl},It)}),children:[s.jsxs("div",{className:`${ir?"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 ${ba?"flex justify-end":"flex justify-between"} ${dr?"h-10 sm:h-10":"h-9 sm:h-10"} ${Co}`,style:{position:ir?"absolute":void 0,marginRight:yc||void 0,display:ja?"none":void 0},children:[!ba&&s.jsxs("button",{type:"button",onClick:is,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")}: ${Yi.running} · ${e("agent.needsReview")}: ${Yi.review}`,children:[s.jsx(UT,{size:14}),s.jsx(FP,{runningCount:Yi.running,reviewCount:Yi.review,className:"sm:hidden"})]}),ba?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:$l?s.jsxs(s.Fragment,{children:[fy($l.mode,Ds),s.jsx("span",{className:`truncate text-[12px] font-medium ${Ds?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:W0}),Ds?.agentStatus==="working"&&s.jsx("span",{title:Ds?.agentMessage??void 0,children:s.jsx(Cn,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Ds?.agentStatus==="waiting"&&s.jsx("span",{title:Ds?.agentMessage??void 0,children:s.jsx(af,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Ds?.agentStatus&&Ds?.agentNeedsReview&&s.jsx("span",{title:Ds?.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")})}):dr?s.jsxs(c0,{onDragStart:zi,onDragUpdate:Ri,onDragEnd:cs,children:[ad(),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 tt=0,Tt=0;for(const En of P.sessions){const In=sr.get(En.id);In?.agentStatus==="working"&&(tt+=1),(In?.agentStatus==="waiting"||In?.agentNeedsReview)&&(Tt+=1)}const Yt=P.sessions.some(En=>En.id===yt),jr=hn.has(P.key),vn=P.key==="";return s.jsx(kl,{draggableId:`group-${P.key||"__ungrouped__"}`,index:de,isDragDisabled:vn,disableInteractiveElementBlocking:!0,children:(En,In)=>s.jsxs("div",{ref:En.innerRef,...En.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${In.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":Yt?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...vn?{}:En.dragHandleProps,onClick:()=>Tn(P.key),className:`flex ${jr?"":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 ${vn?"":"cursor-grab active:cursor-grabbing"} ${Yt?"text-primary/80":"text-muted-foreground/55"}`,title:P.key||P.label,children:[s.jsx(fi,{size:9,className:`shrink-0 opacity-70 transition-transform ${jr?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 truncate",children:P.label}),tt>0&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)]"}),Tt>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${tt>0?"":"ml-auto"}`})]}),jr?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:wi=>s.jsxs("div",{ref:wi.innerRef,...wi.droppableProps,className:"flex items-center gap-px",children:[P.sessions.map((wn,Zi)=>s.jsx(kl,{draggableId:wn.id,index:Zi,disableInteractiveElementBlocking:!0,children:(_o,ko)=>s.jsx("div",{ref:_o.innerRef,..._o.draggableProps,className:`flex shrink-0 items-center ${ko.isDragging?"opacity-70":""}`,children:bc(wn,!1,_o.dragHandleProps,!0)})},wn.id)),wi.placeholder]})})]})},P.key||"__ungrouped__")}),C.placeholder,s.jsx("button",{type:"button",onClick:()=>Ma(),disabled:tu,"aria-busy":tu,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(Us,{size:14})})]})})]}):s.jsxs(c0,{onDragStart:zi,onDragUpdate:Ri,onDragEnd:Dl,children:[ad(),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:Tt=>s.jsx("div",{ref:Tt.innerRef,...Tt.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:(Tt,Yt)=>s.jsx("div",{ref:Tt.innerRef,...Tt.draggableProps,className:`flex h-full shrink-0 items-center ${Yt.isDragging?"opacity-70":""}`,children:bc(P,!0,Tt.dragHandleProps)})})},P.id)),s.jsx("button",{type:"button",onClick:()=>Ma(),disabled:tu,"aria-busy":tu,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(Us,{size:14})}),C.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!ba&&Yi.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(j6,{count:Yi.running,tone:"running",title:e("agent.aiRunning")})}),!ba&>.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 ${gt.length}`,children:Vs}),!Fl&&s.jsx("button",{type:"button",onClick:gi,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(By,{size:14})})]})]}),Jc&&bi&&So?.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:!yi?.error&&(yi?.status==="submitting"||yi?.status==="waiting")?s.jsx(Cn,{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:So.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${yi?.error?"text-destructive":"text-muted-foreground"}`,children:yi?.error??(yi?.status==="submitting"?e("tab.resumeAgentSubmitting"):yi?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!yi?.error&&(yi?.status==="submitting"||yi?.status==="waiting"),onClick:()=>{an(bi.id,So.terminalSessionId)},className:"shrink-0 rounded-full bg-primary px-3 py-1.5 text-[11px] font-semibold text-primary-foreground transition hover:opacity-90 active:scale-95 disabled:cursor-wait disabled:opacity-60 sm:text-[12px]",children:yi?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Yr.getState().setAgentResumeRecovered(bi.id,!1),Lr(C=>C?.sessionId===bi.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(Rn,{size:13})})]}),s.jsx("div",{ref:Le,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(CN,{terminalSettings:qt,colorTheme:p,toolbarPresets:As,showDebug:l&&ir,terminalFocusAvailable:we,defaultSessionMode:ln,defaultTmuxSessionName:pa,connectionPrioritySessionId:N,connectionPriorityReady:ee,desktopRightSidebarEnabled:ir,onToggleRightSidebar:gi,desktopFloatingTitle:ir,desktopPinnedLeftSidebarWidth:ba?Ht:0,desktopViewportWidth:Pr,onSessionDataUpdate:ap,onInitialViewportReady:lp,onInitialRecoveryRequired:op})})})]})}),!It&&s.jsx(WP,{reviewCount:Yi.review,runningSessions:js,activeSessionId:yt,runningButtonEnabled:Er,attentionButtonEnabled:$n,isDesktopLayout:ir,containerElement:ps,occlusionInsets:{right:yc}}),et&&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:Ni,"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($m,{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:Ni,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(Rn,{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:()=>Ve({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=>Ve({fontSize:parseInt(C.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>Ve({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(y$,{}),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=er===C;return s.jsx("button",{type:"button",onClick:()=>Ve({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",jT,e("settings.darkTheme")],["light",CS,e("settings.lightTheme")]].map(([C,P,de])=>{const tt=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 ${tt?"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=ln===C,de=C==="tmux"&&!Sr.available;return s.jsx("button",{type:"button",disabled:de,onClick:()=>Ea(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?Sr.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 ka({preventSleep:C});w(P.preventSleep),S(P.networkAvailable),pe(P.localAccess),On(Hd,{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":Er,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{rs(!Er)},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(of,{size:14,className:Er?"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:Er,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":$n,"aria-label":e("sidebar.attentionButton"),onClick:()=>{Ln(!$n)},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:$n?"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:$n,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>ti(!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(Ey,{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&&W?"settings.notificationsBothOnSummary":R?"settings.notificationsAiOnSummary":W?"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:()=>Di(!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(fi,{size:16,className:"shrink-0 text-muted-foreground"})]}),s.jsx(h$,{state:_e,pending:re,onCheck:()=>{wt()},onConfirmRestart:()=>{nt()},desktopState:Ne?rt:void 0,desktopPending:ue,onCheckDesktop:Ne?()=>{Rr()}:void 0,onInstallDesktop:()=>{rn()},desktopSnapshot:le,desktopActions:Be?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:()=>{Be.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(jA,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{Ie(null),Be.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(Ru,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),st&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:st})]}):void 0}),s.jsx(p$,{backendSessionId:yt?sr.get(yt)?.terminalSessionId??null:null}),s.jsx(g$,{state:Ce,onDismiss:()=>{Me()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{ji(null),Ma({mode:"shell"}),Ni()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Ol?"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(Mi==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(Us,{size:14,className:Ol?"shrink-0":"hidden"}),s.jsx(Fo,{size:12}),s.jsx("span",{className:Ol?"whitespace-nowrap":"hidden",children:e(Mi==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Sr.available,onClick:()=>{Sr.available&&(ji(null),Ma({mode:"tmux"}),Ni())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Sr.available?su?"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:Sr.available?e(Mi==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Sr.reason||e("settings.installTmuxHint"),children:[s.jsx(Us,{size:14,className:su?"shrink-0":"hidden"}),s.jsx(Uu,{size:12}),s.jsx("span",{className:su?"whitespace-nowrap":"hidden",children:e(Mi==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Sr.available||Br.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 ${Sr.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:Sr.available?e("settings.sessions",{n:Br.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),Vo()},disabled:nn,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(gn,{size:12,className:nn?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Sr.available?Br.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(Gc,{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,tt=!!(P.connected||de),Tt=de?gt.find(Bi=>Bi.id===de)??null:null,Yt=P.friendlyName?.trim()||null,jr=P.label&&P.label!==P.name?P.label:null,vn=Yt||jr||P.name,En=Yt||jr?`tmux:${P.name}`:null,In=P.clientCount&&P.clientCount>0?t==="zh"?`网页连接 ${P.clientCount}`:`Web clients ${P.clientCount}`:null,wi=P.attached>0?t==="zh"?`原生 tmux ${P.attached}`:`Native tmux ${P.attached}`:null,wn=[En,tt?P.restorable?e("settings.restorable"):e("settings.attached"):null,In,wi].filter(Bi=>!!Bi),Zi=[e("settings.windows",{n:P.windows}),P.createdAt?new Date(P.createdAt).toLocaleDateString():null].filter(Bi=>!!Bi),_o=ks===P.name,ko=Xr===P.name,Da=Et===P.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${_o?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(Uu,{size:13,className:tt?"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:vn}),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"})]}),wn.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:wn.map(Bi=>s.jsx("span",{className:"max-w-full truncate",children:Bi},Bi))}),(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(gT,{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(Gc,{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:Zi.map(Bi=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(ZA,{size:10,className:"shrink-0 text-muted-foreground/60"}),Bi]},Bi))})]}),_o?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:ko,onClick:()=>{ru(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:ko?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:ko,onClick:()=>{Or(null),Ue(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:()=>{Tt?O0(Tt.id):(kt(P.name),Ma({mode:"tmux",tmuxSessionName:P.name}))},disabled:Da,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${tt?"bg-surface text-foreground hover:bg-surface-elevated":Da?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:Da?s.jsxs(s.Fragment,{children:[s.jsx(Cn,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(tt?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:ko,onClick:()=>{Ue(null),Or(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(zs,{size:12})})]})]},P.name)})]},C.key||"__ungrouped_tmux__")),K&&s.jsx("p",{className:"px-2 text-[11px] text-destructive",children:K})]}):s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:Sr.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(My,{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:()=>ls(!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(E0,{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 eA()}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(Oy,{size:14}),e("settings.signOut")]})]})]})})]}),Ja&&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:()=>{qe(null),Rt(null),Ue(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 ${At&&ir?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:At&&ir?{...ly(At),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:H0}),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:sd,className:"flex items-center gap-3 px-4 py-3 text-left text-[13px] text-destructive transition hover:bg-destructive/10",children:[s.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.confirmDestroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}),K&&s.jsx("p",{className:"px-4 py-2 text-[11px] text-destructive",children:K})]}),s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:()=>{qe(null),Rt(null),Ue(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=gt.find(In=>In.id===cr);if(!C)return null;const P=sr.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,Ca),tt=ir,Tt=tt?ly(Ls):{paddingBottom:a},Yt=tt?"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%]",jr=tt?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",vn=tt?"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",En=tt?"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 ${tt?"bg-transparent":"bg-[var(--app-backdrop-soft)] backdrop-blur-sm"}`,onClick:Kt,"aria-label":"Close menu"}),s.jsxs("div",{className:Yt,style:Tt,children:[s.jsxs("div",{className:jr,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 In=Ls;Kt(),_r(In),Qr(C.id)},className:`${vn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${En} bg-primary/15 text-primary`,children:s.jsx(KT,{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:()=>{ip(C.id),Kt()},className:`${vn} ${P?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${En} bg-surface-2 text-muted-foreground`,children:s.jsx(jy,{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")})]}),$r&&$r===P?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const In=Pm(C.id),wi=In??De;return s.jsxs("div",{className:`${vn} text-foreground`,children:[s.jsx("span",{className:`${En} bg-surface-2 text-muted-foreground`,children:s.jsx(LS,{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:()=>{Qh(C.id,wi-1),sn(wn=>wn+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:[wi,"px"]}),s.jsx("button",{type:"button",onClick:()=>{Qh(C.id,wi+1),sn(wn=>wn+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:"+"}),In!==null&&s.jsx("button",{type:"button",onClick:()=>{Qh(C.id,null),sn(wn=>wn+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 In=P.terminalSessionId;In&&(Kt(),an(C.id,In))},className:`${vn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${En} 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:()=>{Kt(),Pl(C.id)},className:`${vn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${En} bg-destructive/15 text-destructive`,children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.destroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}):s.jsxs("button",{type:"button",onClick:()=>{Kt(),gc({sessionId:C.id,source:"tab-menu",closeMode:"auto"})},className:`${vn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${En} bg-destructive/15 text-destructive`,children:s.jsx(Rn,{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")})]})]}),!tt&&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:()=>{Kt()},children:e("tab.longPressTip")})]}),!tt&&s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:Kt,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&&on&&ir&&(()=>{const C=gt.find(wn=>wn.id===tr);if(!C)return null;const P=sr.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,Ca,P?.shellTitle??null,P?.promptState??null),tt=C.customName?C.name:de,Tt=wn=>{const Zi=wn.trim();Zi?Zi!==tt&&Wi(C.id,Zi):Gi(C.id),Qr(null),_r(null)},Yt=300,jr=160,vn=on.x,En=on.y,In=Math.min(Math.max(vn-Yt/2,12),window.innerWidth-Yt-12),wi=En+jr+20>window.innerHeight?Math.max(En-jr-12,12):En+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:()=>{Qr(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:`${In}px`,top:`${wi}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:wn=>{wn.preventDefault();const Zi=new FormData(wn.currentTarget).get("session-name");Tt(typeof Zi=="string"?Zi:"")},children:[s.jsx("input",{ref:wn=>{Bt.current=wn,wn&&!ot.current&&(ot.current=!0,wn.focus({preventScroll:!0}),wn.select())},type:"text",name:"session-name",defaultValue:tt,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:wn=>{wn.key==="Escape"&&(wn.stopPropagation(),Qr(null),_r(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{Qr(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&&!ir&&(()=>{const C=gt.find(Yt=>Yt.id===tr);if(!C)return null;const P=sr.get(C.id),{primary:de}=il(C,P?.activeProgram??null,P?.cwd??null,Ca,P?.shellTitle??null,P?.promptState??null),tt=C.customName?C.name:de,Tt=Yt=>{const jr=Yt.trim();jr?jr!==tt&&Wi(C.id,jr):Gi(C.id),Qr(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:()=>Qr(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:Yt=>{Yt.preventDefault();const jr=new FormData(Yt.currentTarget).get("session-name");Tt(typeof jr=="string"?jr:"")},children:[s.jsx("input",{ref:Yt=>{Bt.current=Yt,Yt&&!ot.current&&(ot.current=!0,Yt.focus({preventScroll:!0}),Yt.select())},type:"text",name:"session-name",defaultValue:tt,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:Yt=>{Yt.key==="Escape"&&(Yt.stopPropagation(),Qr(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>Qr(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:()=>Di(!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:()=>Di(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(Rn,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(rC,{state:xe,onCopy:C=>{ml(C,"setup")},copied:Se==="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:te,onChange:C=>ke(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:$e,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($e?"settings.saving":"common.save")}),s.jsx("button",{type:"button",disabled:$e,onClick:()=>{Ia()},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:[xe.url&&s.jsxs("button",{type:"button",onClick:()=>{ml(xe.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: ",xe.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:Se==="lan"?"Copied":e("common.copy")})]}),xe.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:xe.interfaces.map(C=>{const P=C.url??`${xe.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:Se===`ip-${C.address}`?"Copied":e("common.copy")})]})]},`${C.name}-${C.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[xe.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!xe.caAvailable&&` · ${e("settings.caMissing")}`]}),xe.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:xe.reason}),Ae&&s.jsx("div",{className:"text-destructive",children:Ae})]})]})]})]}),Na&&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:()=>ti(!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:()=>ti(!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(Rn,{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"):th()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),th()&&!tA()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{Ur()},disabled:!th()||Z==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":L,children:s.jsx(ll,{checked:L,disabled:!th()||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"),": ",xo()?e("settings.notificationsPermissionSystem"):Z]}),s.jsx("button",{type:"button",disabled:!L||Z!=="granted"||ys==="checking",onClick:()=>{Jr()},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")}),xo()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{xo()?.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 tt=U===C;return s.jsxs("button",{type:"button",disabled:!L,onClick:()=>yn(C),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${tt&&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:()=>Qn(!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:()=>vr(!W),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":W&&L,children:s.jsx(ll,{checked:W&&L,disabled:!L})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),ei&&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(Rn,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(c$,{presets:As,selectedPresetId:Ao,onSelectPreset:ma,onUpdatePreset:(C,P)=>{Ka(de=>Eu(de.map(tt=>tt.id===C?P(tt):tt)))},onAddPreset:()=>{const C=`preset-${Date.now()}`;Ka(P=>Eu([...P,{id:C,label:`Preset ${P.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),ma(C)},onRemovePreset:C=>{Ka(P=>Eu(P.filter(de=>de.id!==C)))},onResetDefaults:()=>{Ka(b0()),ma("default")}})})]})]}),ga&&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:()=>ls(!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:()=>ls(!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(Rn,{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(d$,{}),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:gt.map(C=>{const P=sr.get(C.id),de=P?.activeProgramRaw??null,tt=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:"})," ",tt||"—"]}),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(tt=>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:[tt,s.jsx("button",{type:"button",onClick:()=>{const Tt={...Xe,[C]:Xe[C].filter(Yt=>Yt!==tt)};ft(Tt),C==="shellNames"&&(Ca=new Set(Tt.shellNames)),u2(Tt).catch(()=>{})},className:"ml-0.5 text-muted-foreground hover:text-destructive",children:"×"})]},tt)),s.jsx("input",{placeholder:e("settings.addTag"),className:"w-16 rounded bg-surface px-1.5 py-0.5 text-[11px] font-mono",onKeyDown:tt=>{if(tt.key!=="Enter")return;const Tt=tt.target.value.trim().toLowerCase();if(!Tt||Xe[C].includes(Tt))return;const Yt={...Xe,[C]:[...Xe[C],Tt]};ft(Yt),C==="shellNames"&&(Ca=new Set(Yt.shellNames)),tt.target.value="",u2(Yt).catch(()=>{})}})]})]},C)),s.jsx("button",{type:"button",onClick:()=>{rA().then(C=>{ft(C),Ca=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 tt=se.map((Tt,Yt)=>Yt===P?{...Tt,enabled:de.target.checked}:Tt);T(tt),On(Sa,tt),fe(!0),lu(tt).then(Tt=>{T(Tt),On(Sa,Tt)}).catch(()=>{}).finally(()=>fe(!1))}}),s.jsxs("select",{value:C.matchType,onChange:de=>{const tt=se.map((Tt,Yt)=>Yt===P?{...Tt,matchType:de.target.value}:Tt);T(tt),On(Sa,tt),fe(!0),lu(tt).then(Tt=>{T(Tt),On(Sa,Tt)}).catch(()=>{}).finally(()=>fe(!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 tt=se.map((Tt,Yt)=>Yt===P?{...Tt,pattern:de.target.value}:Tt);T(tt),On(Sa,tt)},onBlur:()=>{fe(!0),lu(se).then(de=>{T(de),On(Sa,de)}).catch(()=>{}).finally(()=>fe(!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 tt=se.map((Tt,Yt)=>Yt===P?{...Tt,output:de.target.value}:Tt);T(tt),On(Sa,tt)},onBlur:()=>{fe(!0),lu(se).then(de=>{T(de),On(Sa,de)}).catch(()=>{}).finally(()=>fe(!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((tt,Tt)=>Tt!==P);T(de),On(Sa,de),fe(!0),lu(de).then(tt=>{T(tt),On(Sa,tt)}).catch(()=>{}).finally(()=>fe(!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),On(Sa,C),fe(!0),lu(C).then(P=>{T(P),On(Sa,P)}).catch(()=>{}).finally(()=>fe(!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:()=>{fe(!0),nA().then(C=>{T(C),On(Sa,C)}).catch(()=>{}).finally(()=>fe(!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:O?e("settings.saving"):j?`${se.length} rules`:"…"})]})]})]})]})]})]}),Go&&s.jsx(n$,{isOpen:Go,onClose:()=>qi(!1)}),!ba&&s.jsx(Mb,{isOpen:Ir,drawerWidthPx:fr,onClose:()=>zn("left-sidebar"),onOpen:da,sessions:gt,activeSessionId:yt,sessionStates:sr,onNewSession:C=>Ma(C),recoverableTmuxSessions:id,recoverableTmuxSessionsLoading:nn,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Pl,onSplitSession:nu,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:it,onSetSplitLayout:nd,onReorderSplitWorkspace:$0,onRenameSplitWorkspace:U0,onCombineSplitSessions:z0,onReorderSessions:Xn,onSessionMenu:vi,onOpenSettings:Ms,onJumpToNextAttention:xa.length>0?Ql:void 0,onOpenQuota:()=>qi(!0),updateState:_e,updateActionPending:re,onConfirmUpdateRestart:nt,onRetryUpdate:wt,serverHealthState:Ce,tmuxAvailable:Sr.available,defaultSessionMode:ln,onTogglePinned:ir?Ga:void 0}),!Fl&&s.jsx(jb,{isOpen:ne,sessionId:yt,drawerWidthPx:Un,onClose:()=>zn("right-sidebar"),onOpen:ms,rightSidebarFilePreviewOpen:Dn,rightSidebarFilePreviewCloseSignal:be,onOpenRightSidebarFilePreview:xi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Vt,onOpenRightSidebarRepoPicker:Js,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:vt,markdownOutlineCloseSignal:Pt,onOpenMarkdownOutline:fa,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:zt,markdownImageLightboxCloseSignal:me,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:os,onTogglePinned:ir?Xs:void 0}),We&&!c&&s.jsx("button",{type:"button",onClick:jl,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"})]})}),ge&&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 ${ge.tone==="success"?"border-[rgb(var(--success-rgb)_/_0.24)] bg-surface-elevated text-foreground":"border-destructive/30 bg-surface-elevated text-destructive"}`,role:ge.tone==="error"?"alert":"status",children:[ge.tone==="success"?s.jsx(Qc,{size:14,className:"shrink-0 text-[color:var(--success)]"}):s.jsx(af,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:ge.message}),s.jsx("button",{type:"button",onClick:()=>Vr(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(Rn,{size:12})})]}),l&&s.jsxs(s.Fragment,{children:[!ir&&s.jsx(nC,{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)})]})]})]}),zl=nr?null:s.jsx(aA,{className:"z-modal-panel",status:"正在恢复终端…"});return ir?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[ba&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:Ht,flexShrink:0,height:"100%"},children:s.jsx(Mb,{isOpen:Ir,drawerWidthPx:Ht,onClose:Ks,onOpen:da,sessions:gt,activeSessionId:yt,sessionStates:sr,onNewSession:C=>Ma(C),recoverableTmuxSessions:id,recoverableTmuxSessionsLoading:nn,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Pl,onSplitSession:nu,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:it,onSetSplitLayout:nd,onReorderSplitWorkspace:$0,onRenameSplitWorkspace:U0,onCombineSplitSessions:z0,onReorderSessions:Xn,onSessionMenu:vi,onOpenSettings:Ms,onJumpToNextAttention:xa.length>0?Ql:void 0,onOpenQuota:()=>qi(!0),updateState:_e,updateActionPending:re,onConfirmUpdateRestart:nt,onRetryUpdate:wt,serverHealthState:Ce,tmuxAvailable:Sr.available,defaultSessionMode:ln,pinned:!0,onTogglePinned:Ga})}),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:[Ul,Fl&&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:Ui}),s.jsx("div",{style:{width:od,flexShrink:0,height:"100%"},children:s.jsx(jb,{isOpen:!0,sessionId:yt,drawerWidthPx:od,onClose:Hs,onOpen:ms,pinned:!0,onTogglePinned:Xs,rightSidebarFilePreviewOpen:Dn,rightSidebarFilePreviewCloseSignal:be,onOpenRightSidebarFilePreview:xi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Vt,onOpenRightSidebarRepoPicker:Js,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:vt,markdownOutlineCloseSignal:Pt,onOpenMarkdownOutline:fa,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:zt,markdownImageLightboxCloseSignal:me,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:os})})]})]}),s.jsx(Yb,{sessionId:yt}),zl]}):s.jsxs(s.Fragment,{children:[Ul,s.jsx(Yb,{sessionId:yt}),zl]})}const RU=Object.freeze(Object.defineProperty({__proto__:null,default:P$},Symbol.toStringTag,{value:"Module"}));export{q$ as $,Xd as A,m0 as B,nF as C,GS as D,of as E,Ry as F,sF as G,Qc as H,Qy as I,uS as J,My as K,jy as L,_T as M,PT as N,r0 as O,UT as P,N6 as Q,gn as R,Ml as S,$m as T,CS as U,TI as V,zs as W,Oy as X,BS as Y,rh as Z,ZS as _,VS as a,G$ as a0,Gy as a1,Z$ as a2,K$ as a3,Y$ as a4,X3 as a5,EU as a6,Px as a7,l1 as a8,$f as a9,Wb as aa,Wy as ab,Oh as ac,F1 as ad,lC as ae,OO as af,V$ as ag,Ox as ah,qE as ai,Db as aj,Rm as ak,la as al,NU as am,Xy as an,cf as b,qF as c,RU as d,YS as e,Ly as f,kA as g,CA as h,Iy as i,Ny as j,h0 as k,RO as l,tT as m,f0 as n,oO as o,Ru as p,O1 as q,yT as r,ET as s,Dy as t,jT as u,By as v,YT as w,KT as x,JT as y,p0 as z};
|