termdock 1.4.322 → 1.4.324
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-7IUcmCLC.js +186 -0
- package/dist/client/assets/App-7IUcmCLC.js.br +0 -0
- package/dist/client/assets/App-7IUcmCLC.js.gz +0 -0
- package/dist/client/assets/{ArchitecturePanel-VDM6hrwp.js → ArchitecturePanel-CUAB0wFe.js} +6 -6
- package/dist/client/assets/ArchitecturePanel-CUAB0wFe.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-CUAB0wFe.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-B64j3i8o.js → ChangeWalkthroughPanel-CKIG8diY.js} +2 -2
- package/dist/client/assets/ChangeWalkthroughPanel-CKIG8diY.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-CKIG8diY.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-CIq-JAbF.js +1 -0
- package/dist/client/assets/CollaborationMainWorkspace-CIq-JAbF.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-CIq-JAbF.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-7vWDzH-d.js +2 -0
- package/dist/client/assets/{ComputerControlView-Co-TTYas.js → ComputerControlView-CPSI-M86.js} +2 -2
- package/dist/client/assets/ComputerControlView-CPSI-M86.js.br +0 -0
- package/dist/client/assets/ComputerControlView-CPSI-M86.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-kJczdJ6J.js → DagPlayground-BxocNRPm.js} +1 -1
- package/dist/client/assets/DagPlayground-BxocNRPm.js.br +0 -0
- package/dist/client/assets/DagPlayground-BxocNRPm.js.gz +0 -0
- package/dist/client/assets/{DiffLab-BaaioC-q.js → DiffLab-COGOFO0s.js} +2 -2
- package/dist/client/assets/DiffLab-COGOFO0s.js.br +0 -0
- package/dist/client/assets/DiffLab-COGOFO0s.js.gz +0 -0
- package/dist/client/assets/{DiffReview-Wfck3RIS.js → DiffReview-5ERdwz1C.js} +1 -1
- package/dist/client/assets/DiffReview-5ERdwz1C.js.br +0 -0
- package/dist/client/assets/DiffReview-5ERdwz1C.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-Dblr3wgw.js → DiffReviewLab-BSz9IND6.js} +1 -1
- package/dist/client/assets/DiffReviewLab-BSz9IND6.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BSz9IND6.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-C-utC5Ga.js → DiffViewer-RT-p-ZBo.js} +8 -8
- package/dist/client/assets/DiffViewer-RT-p-ZBo.js.br +0 -0
- package/dist/client/assets/DiffViewer-RT-p-ZBo.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-BBLnHWVQ.js → ModelPreview-DI9anVWA.js} +1 -1
- package/dist/client/assets/ModelPreview-DI9anVWA.js.br +0 -0
- package/dist/client/assets/ModelPreview-DI9anVWA.js.gz +0 -0
- package/dist/client/assets/{RightSidebar-CUHSFkmZ.js → RightSidebar-DOLn8R7c.js} +36 -36
- package/dist/client/assets/RightSidebar-DOLn8R7c.js.br +0 -0
- package/dist/client/assets/RightSidebar-DOLn8R7c.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-DDd99QpA.js → abnfDiagram-VCTEODGH-CXd0unH5.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXd0unH5.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXd0unH5.js.gz +0 -0
- package/dist/client/assets/app-DCFOZi_L.js +35 -0
- package/dist/client/assets/app-DCFOZi_L.js.br +0 -0
- package/dist/client/assets/app-DCFOZi_L.js.gz +0 -0
- package/dist/client/assets/{arc-C3dck_E0.js → arc-DCqJmX8M.js} +1 -1
- package/dist/client/assets/arc-DCqJmX8M.js.br +0 -0
- package/dist/client/assets/arc-DCqJmX8M.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-C3bCQc2w.js → architectureDiagram-5GKGNRK7-DGu_m54H.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DGu_m54H.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DGu_m54H.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-znMn6iCQ.js → blockDiagram-I7D4REHJ-BI0gsxDN.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-BI0gsxDN.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BI0gsxDN.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-C0sopIsj.js → c4Diagram-7LVT6UL2-Ct3xzGtD.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-Ct3xzGtD.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Ct3xzGtD.js.gz +0 -0
- package/dist/client/assets/channel-BLSCUksA.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-f7USyccJ.js → chunk-2Q5K7J3B-BPd2UShA.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Ck2xirDs.js → chunk-5VM5RSS4-CoFZ5Fo3.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-DaDCIj30.js → chunk-F27PBJKO-C5gZrGp4.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-C5gZrGp4.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-C5gZrGp4.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-DEC_On5x.js → chunk-IMKFNOWR-GW8b9ya-.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-GW8b9ya-.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-GW8b9ya-.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-BrswC3n2.js → chunk-JWPE2WC7-GpMoViQf.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-ClMbDV47.js → chunk-POPQ4Y6H-C_vgVPaw.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-D7_1VwC5.js → chunk-SVP7TREG-bA7RXwWn.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-bA7RXwWn.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-bA7RXwWn.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-D5jzVTZ8.js → chunk-TICWLB2K-BG8DAtll.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-BG8DAtll.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-BG8DAtll.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-DOhaoLcX.js → chunk-XXDRQBXY-Ces56sud.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-DkVIqOvw.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DkVIqOvw.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DOsaKgiX.js → cose-bilkent-JH36ORCC-Bwch0qL5.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-Bwch0qL5.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-Bwch0qL5.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-CMcLh_wh.js → cynefin-OW5HDTMX-CrAXyA2Z.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-CrAXyA2Z.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CrAXyA2Z.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js → cynefinDiagram-5FMLGOSQ-YlP0Q93l.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-YlP0Q93l.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-YlP0Q93l.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-BlW7fAi0.js → dagre-GXQ25YYZ-CZ4XcPK9.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-CZ4XcPK9.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CZ4XcPK9.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-B0-tKahG.js → diagram-S7CK7UJ4-c_8HfHGA.js} +1 -1
- package/dist/client/assets/{diagram-S7CK7UJ4-B0-tKahG.js.br → diagram-S7CK7UJ4-c_8HfHGA.js.br} +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-c_8HfHGA.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-BQumj4Dw.js → diagram-UQ7AKVKN-BGtRfxMR.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-BGtRfxMR.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BGtRfxMR.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-Zx_FLmPP.js → diagram-VSXAHHWV-_9yZnhuv.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-_9yZnhuv.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-_9yZnhuv.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-CEZvatNH.js → diagram-VX7I27RA-C_mnc4_u.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-C_mnc4_u.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C_mnc4_u.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-CJ9IEQ8j.js → diagram-Z3DM3KII-sZ_AiSpj.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-sZ_AiSpj.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-sZ_AiSpj.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-sQQMv3ea.js → ebnfDiagram-PWID7BFC-Dm-BXeqS.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Dm-BXeqS.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Dm-BXeqS.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-D3rMpj7M.js → erDiagram-RLTQ6QDP-Dz4cBepd.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-Dz4cBepd.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Dz4cBepd.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-B6QZiE0-.js → flowDiagram-HODETNUW-CbRG8-WW.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-CbRG8-WW.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CbRG8-WW.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-Bw9bltcu.js → ganttDiagram-EL5Y4UJY-CmBXWlr0.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CmBXWlr0.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CmBXWlr0.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-Cczz34oI.js → gestureArbiter-B26W6rS7.js} +1 -1
- package/dist/client/assets/gestureArbiter-B26W6rS7.js.br +0 -0
- package/dist/client/assets/gestureArbiter-B26W6rS7.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-mdnkxjeD.js → gitGraphDiagram-WWUBYQGX-JW5QMYEk.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-JW5QMYEk.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-JW5QMYEk.js.gz +0 -0
- package/dist/client/assets/index-Ctz-IDjR.css +1 -0
- package/dist/client/assets/index-Ctz-IDjR.css.br +0 -0
- package/dist/client/assets/{index-B4bEMUyn.css.gz → index-Ctz-IDjR.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-DyrPP3Yf.js → infoDiagram-27XIBGKW-CsA6WdPn.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CEPH_ePM.js → ishikawaDiagram-5VMMS53U-CsKPUwTw.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CsKPUwTw.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CsKPUwTw.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-CQ0PjBy7.js → journeyDiagram-3NMN7TZE-DpN98gN0.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-DpN98gN0.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-DpN98gN0.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-BpQUXA60.js → kanban-definition-UXKFOSKX-RHO--43O.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-RHO--43O.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-RHO--43O.js.gz +0 -0
- package/dist/client/assets/{layout-BdptC7rq.js → layout-Cm_prknW.js} +1 -1
- package/dist/client/assets/layout-Cm_prknW.js.br +0 -0
- package/dist/client/assets/layout-Cm_prknW.js.gz +0 -0
- package/dist/client/assets/{linear-C2cSRCxu.js → linear-BVAsPkvS.js} +1 -1
- package/dist/client/assets/linear-BVAsPkvS.js.br +0 -0
- package/dist/client/assets/linear-BVAsPkvS.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-ClVMFyAU.js → mermaid.core-ufe77Xaz.js} +5 -5
- package/dist/client/assets/mermaid.core-ufe77Xaz.js.br +0 -0
- package/dist/client/assets/mermaid.core-ufe77Xaz.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-D0AFCmsY.js → mindmap-definition-YA3MSWOX-CRyy1U2d.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CRyy1U2d.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CRyy1U2d.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-3_SIzSH7.js +2 -0
- package/dist/client/assets/passwordBootstrap-3_SIzSH7.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-3_SIzSH7.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-BGAh0bwg.js → pegDiagram-XKGWAZYB-DSHgdU9q.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-DSHgdU9q.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DSHgdU9q.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-CDOZUF44.js → pieDiagram-E7YTZNPT-lIUeAuhN.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-lIUeAuhN.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-lIUeAuhN.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-D_Qn6NTU.js → quadrantDiagram-AXDQQJYC-CIgG9vBX.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-CIgG9vBX.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-CIgG9vBX.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-qUVGWhJN.js → railroadDiagram-O6MQD6OU-DjP8oesA.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DjP8oesA.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DjP8oesA.js.gz +0 -0
- package/dist/client/assets/{rdpSession-hgCM4i-j.js → rdpSession-BshIobdj.js} +1 -1
- package/dist/client/assets/rdpSession-BshIobdj.js.br +0 -0
- package/dist/client/assets/rdpSession-BshIobdj.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-BEMsP11a.js → referenceLongPress-DBJnfFHa.js} +1 -1
- package/dist/client/assets/referenceLongPress-DBJnfFHa.js.br +0 -0
- package/dist/client/assets/referenceLongPress-DBJnfFHa.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-BBQMQuVZ.js → requirementDiagram-BXWQKSXE-Dbvu6IC_.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Dbvu6IC_.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Dbvu6IC_.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CeEExsqW.js → sankeyDiagram-P5KCCOFB-1mZ4s-lv.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CeEExsqW.js.br → sankeyDiagram-P5KCCOFB-1mZ4s-lv.js.br} +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-1mZ4s-lv.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js → sequenceDiagram-WJ2MYXX4-Cu3hhzlV.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Cu3hhzlV.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Cu3hhzlV.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-MBjz7Snm.js → sizeCapture-INFHLROL-xfm69HlR.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-xfm69HlR.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-xfm69HlR.js.gz +0 -0
- package/dist/client/assets/{sparkles-C9ShmGPf.js → sparkles-CDonlwGu.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-DtLp89uP.js → stateDiagram-D77RDMKH-u-bh6mDK.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-u-bh6mDK.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-u-bh6mDK.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BQ_m8Gzd.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-Bc02S1q-.js → swimlanes-42K2YHIH-U8WN__SO.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-U8WN__SO.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-U8WN__SO.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-FDEo3QWw.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-BLLwbOm5.js → timeline-definition-24CTP7MA-CMsoNo4F.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-CMsoNo4F.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CMsoNo4F.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-i_L8ws6U.js → triangle-alert-BgErMO2V.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-8FcrAdbk.js → vennDiagram-4TSXK5OY-CPE6pVwh.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-8FcrAdbk.js.br → vennDiagram-4TSXK5OY-CPE6pVwh.js.br} +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CPE6pVwh.js.gz +0 -0
- package/dist/client/assets/{videoCompression-RIaDabW4.js → videoCompression-BWkZvEjM.js} +1 -1
- package/dist/client/assets/videoCompression-BWkZvEjM.js.br +0 -0
- package/dist/client/assets/videoCompression-BWkZvEjM.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-paL2wRrJ.js → wardleyDiagram-VM6X3IG4-4lWd-R4N.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-4lWd-R4N.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-4lWd-R4N.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BM5qJ4E7.js → xychartDiagram-S5SC5T6Z-CpKJMCWV.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CpKJMCWV.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CpKJMCWV.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-encrypted-background.js +1 -1
- package/dist/client/sw-encrypted-background.js.br +0 -0
- package/dist/client/sw-encrypted-background.js.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/collaborationGroupRoutes.js +15 -0
- package/dist/server/agent/collaborationStore.js +63 -2
- package/dist/server/agent/collaborationTaskRoutes.js +5 -1
- package/dist/server/agent/integrationCli.js +38 -20
- package/dist/server/agent/integrationServer.js +18 -1
- package/dist/server/federation/packets.js +179 -28
- package/dist/server/federation/requestContext.js +6 -1
- package/dist/server/federation/runtime.js +19 -8
- package/dist/server/routes/terminal.js +60 -20
- package/dist/server/utils/autoUpdate.js +55 -8
- package/dist/server/utils/npmUpdate.js +84 -8
- package/dist/server/utils/terminalPasteBuffer.js +66 -0
- package/dist/server/utils/tmuxClientCapabilities.js +4 -0
- package/dist/server/utils/tmuxCopySelection.js +94 -0
- package/dist/server/utils/tmuxEmptyServerProbe.js +15 -0
- package/docs/integrations.md +36 -0
- package/package.json +5 -2
- package/runtime-manifest.json +3 -3
- package/.desktop-dist/main.js +0 -1989
- package/dist/client/assets/App-DEKo4SNL.js +0 -186
- package/dist/client/assets/App-DEKo4SNL.js.br +0 -0
- package/dist/client/assets/App-DEKo4SNL.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-VDM6hrwp.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-VDM6hrwp.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-B64j3i8o.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-B64j3i8o.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js +0 -1
- package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DG8TQNqo.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-msQsgVaI.js +0 -2
- package/dist/client/assets/ComputerControlView-Co-TTYas.js.br +0 -0
- package/dist/client/assets/ComputerControlView-Co-TTYas.js.gz +0 -0
- package/dist/client/assets/DagPlayground-kJczdJ6J.js.br +0 -0
- package/dist/client/assets/DagPlayground-kJczdJ6J.js.gz +0 -0
- package/dist/client/assets/DiffLab-BaaioC-q.js.br +0 -0
- package/dist/client/assets/DiffLab-BaaioC-q.js.gz +0 -0
- package/dist/client/assets/DiffReview-Wfck3RIS.js.br +0 -0
- package/dist/client/assets/DiffReview-Wfck3RIS.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-Dblr3wgw.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-Dblr3wgw.js.gz +0 -0
- package/dist/client/assets/DiffViewer-C-utC5Ga.js.br +0 -0
- package/dist/client/assets/DiffViewer-C-utC5Ga.js.gz +0 -0
- package/dist/client/assets/ModelPreview-BBLnHWVQ.js.br +0 -0
- package/dist/client/assets/ModelPreview-BBLnHWVQ.js.gz +0 -0
- package/dist/client/assets/RightSidebar-CUHSFkmZ.js.br +0 -0
- package/dist/client/assets/RightSidebar-CUHSFkmZ.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DDd99QpA.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DDd99QpA.js.gz +0 -0
- package/dist/client/assets/app-CfqF7_nh.js +0 -35
- package/dist/client/assets/app-CfqF7_nh.js.br +0 -0
- package/dist/client/assets/app-CfqF7_nh.js.gz +0 -0
- package/dist/client/assets/arc-C3dck_E0.js.br +0 -0
- package/dist/client/assets/arc-C3dck_E0.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C3bCQc2w.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C3bCQc2w.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-znMn6iCQ.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-znMn6iCQ.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-C0sopIsj.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-C0sopIsj.js.gz +0 -0
- package/dist/client/assets/channel-CMC8t83j.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-DaDCIj30.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-DaDCIj30.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DEC_On5x.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DEC_On5x.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-D7_1VwC5.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-D7_1VwC5.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-D5jzVTZ8.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-D5jzVTZ8.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-ElMHzA-E.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-ElMHzA-E.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-DOsaKgiX.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-DOsaKgiX.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CMcLh_wh.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CMcLh_wh.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dd8bfq9V.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-BlW7fAi0.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-BlW7fAi0.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-B0-tKahG.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BQumj4Dw.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BQumj4Dw.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Zx_FLmPP.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Zx_FLmPP.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CEZvatNH.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CEZvatNH.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CJ9IEQ8j.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CJ9IEQ8j.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-sQQMv3ea.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-sQQMv3ea.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-D3rMpj7M.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-D3rMpj7M.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-B6QZiE0-.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-B6QZiE0-.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-Bw9bltcu.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-Bw9bltcu.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-Cczz34oI.js.br +0 -0
- package/dist/client/assets/gestureArbiter-Cczz34oI.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-mdnkxjeD.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-mdnkxjeD.js.gz +0 -0
- package/dist/client/assets/index-B4bEMUyn.css +0 -1
- package/dist/client/assets/index-B4bEMUyn.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CEPH_ePM.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CEPH_ePM.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CQ0PjBy7.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CQ0PjBy7.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BpQUXA60.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BpQUXA60.js.gz +0 -0
- package/dist/client/assets/layout-BdptC7rq.js.br +0 -0
- package/dist/client/assets/layout-BdptC7rq.js.gz +0 -0
- package/dist/client/assets/linear-C2cSRCxu.js.br +0 -0
- package/dist/client/assets/linear-C2cSRCxu.js.gz +0 -0
- package/dist/client/assets/mermaid.core-ClVMFyAU.js.br +0 -0
- package/dist/client/assets/mermaid.core-ClVMFyAU.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D0AFCmsY.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D0AFCmsY.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-R2qlU2Pq.js +0 -2
- package/dist/client/assets/passwordBootstrap-R2qlU2Pq.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-R2qlU2Pq.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-BGAh0bwg.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-BGAh0bwg.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CDOZUF44.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CDOZUF44.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-D_Qn6NTU.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-D_Qn6NTU.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-qUVGWhJN.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-qUVGWhJN.js.gz +0 -0
- package/dist/client/assets/rdpSession-hgCM4i-j.js.br +0 -0
- package/dist/client/assets/rdpSession-hgCM4i-j.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-BEMsP11a.js.br +0 -0
- package/dist/client/assets/referenceLongPress-BEMsP11a.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BBQMQuVZ.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BBQMQuVZ.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CeEExsqW.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-7ZPO-X0a.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-MBjz7Snm.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-MBjz7Snm.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DtLp89uP.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DtLp89uP.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CIQb4Dp7.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-Bc02S1q-.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-Bc02S1q-.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-RiKL7eXI.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-BLLwbOm5.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BLLwbOm5.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-8FcrAdbk.js.gz +0 -0
- package/dist/client/assets/videoCompression-RIaDabW4.js.br +0 -0
- package/dist/client/assets/videoCompression-RIaDabW4.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-paL2wRrJ.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-paL2wRrJ.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BM5qJ4E7.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BM5qJ4E7.js.gz +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-RIaDabW4.js","assets/app-CfqF7_nh.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-B4bEMUyn.css","assets/CollaborationTaskContent-msQsgVaI.js","assets/RightSidebar-CUHSFkmZ.js","assets/gestureArbiter-Cczz34oI.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-Wfck3RIS.js","assets/sparkles-C9ShmGPf.js","assets/DiffViewer-C-utC5Ga.js","assets/referenceLongPress-BEMsP11a.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-i_L8ws6U.js","assets/ChangeWalkthroughPanel-B64j3i8o.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-DG8TQNqo.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{ag as zt,aN as Yu,by as s,ac as hc,da as Ur,H as t8,dk as sl,d6 as La,d8 as Kn,b1 as fc,a7 as eh,az as vy,bp as B1,cN as r8,d7 as E0,cy as d0,b6 as vo,j as h0,af as Fu,co as Tp,cV as n8,as as Dc,bx as Cu,g as s8,cI as Ph,Z as i8,bb as Om,bI as Fm,cE as a8,ax as o8,ch as l8,a5 as wy,cf as c8,cC as Ay,aa as u8,ah as d8,L as _n,C as pi,X as In,f as h8,d as ul,bg as f8,b0 as $m,dc as p8,dh as Yr,bG as Q1,dg as Gt,aD as m8,dq as g8,v as x8,bN as b8,c0 as y8,a4 as ka,bR as v8,cA as nx,cB as sx,cD as ix,W as ax,b$ as w8,cO as A8,t as t0,bo as P1,d5 as T8,_ as Oc,b9 as S8,i as C8,dj as Ty,a_ as il,T as $o,db as Gc,df as _8,ci as k8,an as L8,aY as I8,bZ as E8,b_ as N8,P as Sy,V as ox,bO as lx,bA as Cy,n as zs,$ as Oh,cW as Sp,bH as R8,ck as M8,bF as _y,de as j8,bf as Po,dm as D8,B as cc,e as Xs,u as B8,ak as Q8,N as Um,cv as P8,h as To,bt as O8,bu as F8,ap as ky,aB as Ly,a6 as Iu,m as ju,cs as Ml,c2 as Iy,aw as r0,c as Fh,d9 as Ey,aJ as $8,S as af,bm as of,a as Ny,ar as U8,ae as z8,d3 as H8,c3 as $u,a8 as uc,bE as cx,cz as W8,c7 as Ry,cS as G8,cU as My,bB as V8,bD as O1,cG as q8,cH as Y8,c4 as Z8,cF as K8,cp as X8,cm as J8,cj as e9,c6 as t9,cw as r9,bQ as n9,bP as jy,cr as s9,bC as ux,aH as i9,a$ as a9,D as o9,aG as dx,bK as l9,q as c9,p as u9,bM as d9,F as h9,c5 as f9,l as p9,cx as m9,r as g9,c1 as x9,au as b9,aA as y9,aC as v9,ba as dd,bk as w9,d0 as A9,bl as T9,ao as S9,d2 as C9,Q as _9,aj as k9,ad as L9,A as I9,b8 as E9,aq as N9,M as R9,di as M9,bT as Tc,b5 as j9,b2 as D9,b3 as B9,b4 as Q9,aW as Cp,bU as P9,cb as O9,cl as F9,b7 as $9,aZ as U9,cT as hx,am as z9,a9 as H9,Y as W9,c_ as G9,dn as Fn,cu as Sc,bS as V9,w as q9,cQ as Y9,aV as Z9,bc as fx,ca as K9,cM as th,cZ as hd,d1 as X9,cc as J9,cR as eA,cJ as tA,cY as _p,cK as rA,cL as nA,dd as sA,al as iA,bJ as aA,bw as rh,bv as oA,c8 as px,cd as lA,c9 as uu,ce as cA,a3 as uA,ab as dA,s as hA}from"./app-CfqF7_nh.js";import{b,R as L,r as Js,a as fA}from"./dnd-BCFAPC0L.js";import{b as pA,c as mA,F as Vc,S as gA,e as xA,h as bA,r as yA,y as vA,d as wA,u as AA}from"./gestureArbiter-Cczz34oI.js";import{L as TA,l as SA}from"./terminal-C7X98Amf.js";import{T as F1,L as Uu,C as f0,M as CA,G as _A}from"./triangle-alert-i_L8ws6U.js";import{r as kA}from"./react-XDCjal2T.js";import{u as $1,G as LA}from"./referenceLongPress-BEMsP11a.js";const IA=[["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"}]],Dy=zt("archive",IA);const EA=[["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"}]],NA=zt("arrow-down-a-z",EA);const RA=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],MA=zt("arrow-down",RA);const jA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],By=zt("arrow-up",jA);const DA=[["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"}]],Qy=zt("bell",DA);const BA=[["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"}]],N0=zt("bot",BA);const QA=[["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"}]],PA=zt("box",QA);const OA=[["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"}]],FA=zt("cable",OA);const $A=[["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"}]],UA=zt("calendar-clock",$A);const zA=[["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"}]],HA=zt("camera",zA);const WA=[["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"}]],GA=zt("chart-bar",WA);const VA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],qA=zt("circle-dot",VA);const YA=[["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"}]],lf=zt("circle-question-mark",YA);const ZA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],R0=zt("circle",ZA);const KA=[["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"}]],XA=zt("clipboard-paste",KA);const JA=[["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"}]],Py=zt("clipboard",JA);const eT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],p0=zt("clock-3",eT);const tT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],rT=zt("clock",tT);const nT=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],sT=zt("code",nT);const iT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Il=zt("columns-2",iT);const aT=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],oT=zt("corner-down-left",aT);const lT=[["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"}]],m0=zt("download",lT);const cT=[["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=zt("external-link",cT);const uT=[["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"}]],dT=zt("file-code",uT);const hT=[["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"}]],fT=zt("file-up",hT);const pT=[["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"}]],Oy=zt("file",pT);const mT=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Du=zt("folder-open",mT);const gT=[["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"}]],U1=zt("folder-search",gT);const xT=[["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"}]],bT=zt("folder-tree",xT);const yT=[["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"}]],mx=zt("grid-2x2",yT);const vT=[["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"}]],zf=zt("grip-vertical",vT);const wT=[["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"}]],AT=zt("hash",wT);const TT=[["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=zt("history",TT);const ST=[["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"}]],CT=zt("house",ST);const _T=[["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"}]],Fy=zt("keyboard",_T);const kT=[["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"}]],$y=zt("layers",kT);const LT=[["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"}]],IT=zt("layout-dashboard",LT);const ET=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],qc=zt("layout-grid",ET);const NT=[["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"}]],RT=zt("maximize",NT);const MT=[["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"}]],Zu=zt("message-circle",MT);const jT=[["path",{d:"M5 12h14",key:"1ays0h"}]],Uy=zt("minus",jT);const DT=[["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"}]],BT=zt("minimize",DT);const QT=[["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"}]],PT=zt("monitor-smartphone",QT);const OT=[["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"}]],FT=zt("moon",OT);const $T=[["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"}]],UT=zt("move",$T);const zT=[["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"}]],HT=zt("network",zT);const WT=[["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"}]],GT=zt("panel-right-close",WT);const VT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],qT=zt("panel-left",VT);const YT=[["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"}]],ZT=zt("panel-right-open",YT);const KT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],zy=zt("panel-right",KT);const XT=[["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"}]],JT=zt("paperclip",XT);const eS=[["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"}]],tS=zt("pause",eS);const rS=[["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"}]],nS=zt("pen-line",rS);const sS=[["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"}]],iS=zt("pencil-line",sS);const aS=[["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"}]],g0=zt("pin",aS);const oS=[["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"}]],x0=zt("pin-off",oS);const lS=[["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"}]],cf=zt("play",lS);const cS=[["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"}]],uS=zt("plug",cS);const dS=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],hS=zt("power",dS);const fS=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],bn=zt("refresh-cw",fS);const pS=[["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"}]],Hy=zt("rotate-ccw",pS);const mS=[["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"}]],gS=zt("rotate-cw",mS);const xS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],gx=zt("rows-2",xS);const bS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],jl=zt("search",bS);const yS=[["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"}]],n0=zt("send",yS);const vS=[["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"}]],wS=zt("settings",vS);const AS=[["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"}]],TS=zt("shield-alert",AS);const SS=[["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"}]],CS=zt("shield-check",SS);const _S=[["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"}]],zm=zt("sliders-horizontal",_S);const kS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Wy=zt("square",kS);const LS=[["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"}]],IS=zt("stethoscope",LS);const ES=[["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"}]],NS=zt("sun",ES);const RS=[["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"}]],Ms=zt("trash-2",RS);const MS=[["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"}]],jS=zt("type",MS);const DS=[["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"}]],BS=zt("unlink",DS);const QS=[["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"}]],Gy=zt("unplug",QS);const PS=[["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"}]],Vy=zt("video",PS);const OS=[["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"}]],FS=zt("volume-1",OS);const $S=[["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"}]],US=zt("volume-2",$S);const zS=[["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"}]],HS=zt("wand-sparkles",zS);const WS=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],nh=zt("workflow",WS);function GS(e,t){return e==="webgl"&&t}function qy(e,t,r){const n=[],a=new Map;for(const c of e){const l=t(c),d=l&&l.trim().length>0?l:"";let f=a.get(d);f||(f={key:d,label:d?Yu(d)??d:r,sessions:[]},a.set(d,f),n.push(f)),f.sessions.push(c)}return n.sort((c,l)=>(c.key===""?1:0)-(l.key===""?1:0))}function VS(e){return e&&e.trim().length>0?e:""}function Yy(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 uf(e,t,r,n,a=[],c=[]){const l=new Map(e.map(S=>[S.id,S])),d=Zy(c,new Set(l.keys())),f=new Map,m=new Map,x=a.filter(S=>S.sessionIds.length>=2&&S.sessionIds.every(C=>l.has(C))),y=(S,C)=>{const I=l.get(C);S.forEach(R=>{f.set(R,S),m.set(R,I)})};for(const S of d){const C=new Set(S.sessionIds),I=new Map;for(const z of x)z.sessionIds.every(O=>C.has(O))&&z.sessionIds.forEach(O=>I.set(O,z.sessionIds));const R=new Set,B=S.sessionIds.flatMap(z=>{if(R.has(z))return[];const O=I.get(z)??[z];return O.forEach($=>R.add($)),O});y(B,S.sessionIds[0])}for(const S of x)S.sessionIds.some(C=>f.has(C))||y(S.sessionIds,S.sessionIds[0]);const w=S=>{const C=new Set;return S.flatMap(I=>{if(C.has(I.id))return[];const R=f.get(I.id)??[I.id];return R.forEach(B=>C.add(B)),R.map(B=>l.get(B))})};if(!r)return{arranged:w(e),groups:[]};const v=qy(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 qS(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function YS(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function ZS(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function KS(e,t){return!e&&t}const df=".termdock/architecture.json",Ky=".termdock/architectures",XS={kind:"project",target:"",paths:[],depth:"boundary",focus:""},JS=["description","diagram","context","constraint","concern","todo","note"],eC=/^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/;class tC extends Error{}function hs(){throw new tC("Invalid architecture document")}function Cl(e){return(!e||typeof e!="object"||Array.isArray(e))&&hs(),e}function oi(e,t=8e3){return(typeof e!="string"||e.length>t)&&hs(),e}function Cc(e){const t=oi(e,80);return eC.test(t)||hs(),t}function rc(e,t){return(!Array.isArray(e)||e.length>t)&&hs(),e}function xx(e){return Object.fromEntries(JS.filter(t=>e[t]!==void 0).map(t=>[t,oi(e[t],1e5)]))}function du(e){if(e===void 0)return;const t=Cl(e),r={};for(const n of["created","updated","gitCommit","gitBranch","previousDiagram"])t[n]!==void 0&&(r[n]=oi(t[n],n==="previousDiagram"?1e5:200));return t.updateCount!==void 0&&((!Number.isSafeInteger(t.updateCount)||t.updateCount<0)&&hs(),r.updateCount=t.updateCount),r}function $h(e){return!!e&&!/[:\\\x00-\x1f]/.test(e)&&!e.startsWith("/")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function z1(e){(!["project","module","feature"].includes(e.kind)||!["boundary","dependencies"].includes(e.depth))&&hs();const t=e.kind==="project"?[]:[...new Set(rc(e.paths,20).map(a=>oi(a,1024).trim()))].sort();t.some(a=>!$h(a))&&hs();const r=oi(e.target,1e3).trim(),n=oi(e.focus,2e3).trim();return(e.kind==="module"&&!t.length||e.kind==="feature"&&!r)&&hs(),{kind:e.kind,target:e.kind==="project"?"":e.kind==="module"?t.join(`
|
|
3
|
-
`):r,paths:e.kind==="project"?[]:t,depth:e.depth,focus:n}}function rC(e){const t=z1(e);if(t.kind==="project")return df;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`${Ky}/${t.kind}-${a}-${(n>>>0).toString(16).padStart(8,"0")}.json`}function Xy(e){return e===".omm"||e===df||new RegExp(`^${Ky.replace(".","\\.")}/(?:module|feature)-[\\p{L}\\p{N}_-]{1,48}-[a-f0-9]{8}\\.json$`,"u").test(e)}function J$(e){return e.split("/").pop()?.replace(/^(module|feature)-/,"").replace(/-[a-f0-9]{8}\.json$/,"").replace(/-/g," ")??e}function eU(e){new TextEncoder().encode(e).byteLength>5e6&&hs();let t;try{t=JSON.parse(e)}catch{hs()}const r=Cl(t);r.version!==1&&hs();const n=oi(r.generatedAt,80);Number.isFinite(Date.parse(n))||hs();const a=rc(r.perspectives,12).map(d=>{const f=Cl(d),m=rc(f.nodes,200).map(w=>{const v=Cl(w),S=rc(v.files,40).map(I=>{const R=Cl(I),B=oi(R.path,1024);return $h(B)||hs(),R.line!==void 0&&(!Number.isSafeInteger(R.line)||R.line<1)&&hs(),{path:B,...R.line!==void 0?{line:R.line}:{}}}),C=v.references===void 0?void 0:rc(v.references,100).map(I=>{const R=Cl(I);return{perspective:Cc(R.perspective),...R.node!==void 0?{node:Cc(R.node)}:{}}});return v.documentPath!==void 0&&!$h(oi(v.documentPath,1024))&&hs(),v.role!==void 0&&!["external","concern","entry","store"].includes(v.role)&&hs(),{id:Cc(v.id),title:oi(v.title,160),summary:oi(v.summary),files:S,...xx(v),...v.parentId!==void 0?{parentId:Cc(v.parentId)}:{},...v.documentPath!==void 0?{documentPath:oi(v.documentPath,1024)}:{},...du(v.meta)?{meta:du(v.meta)}:{},...C?{references:C}:{},...v.role!==void 0?{role:v.role}:{}}});m.length||hs();const x=new Map(m.map(w=>[w.id,w]));x.size!==m.length&&hs();for(const w of m){const v=new Set([w.id]);let S=w.parentId;for(;S;)(v.has(S)||!x.has(S))&&hs(),v.add(S),S=x.get(S)?.parentId}const y=rc(f.edges,600).map(w=>{const v=Cl(w),S=Cc(v.from),C=Cc(v.to);return(!x.has(S)||!x.has(C))&&hs(),{from:S,to:C,label:oi(v.label,200)}});return{id:Cc(f.id),title:oi(f.title,160),summary:oi(f.summary),nodes:m,edges:y,...xx(f),...du(f.meta)?{meta:du(f.meta)}:{}}});(!a.length||new Set(a.map(d=>d.id)).size!==a.length)&&hs();for(const d of a)for(const f of d.nodes)for(const m of f.references??[]){const x=a.find(y=>y.id===m.perspective);(!x||m.node&&!x.nodes.some(y=>y.id===m.node))&&hs()}const c=r.analysis===void 0?void 0:z1(Cl(r.analysis));let l;if(r.details!==void 0){const d=Cl(r.details),f=rc(d.analyzedPaths,200).map(x=>{const y=oi(x,1024);return $h(y)||hs(),y}),m=rc(d.limitations,30).map(x=>oi(x,2e3));l={analyzedPaths:f,limitations:m}}return r.origin!==void 0&&!["termdock","omm"].includes(r.origin)&&hs(),{version:1,generatedAt:n,summary:oi(r.summary),perspectives:a,...c?{analysis:c}:{},...l?{details:l}:{},...r.origin?{origin:r.origin}:{},...du(r.meta)?{meta:du(r.meta)}:{}}}function Jy(e,t){const r=e.nodes.filter(d=>d.parentId===t),n=new Map(e.nodes.map(d=>[d.id,d])),a=new Set(r.map(d=>d.id)),c=d=>{let f=n.get(d);for(;f&&!a.has(f.id);)f=f.parentId?n.get(f.parentId):void 0;return f?.id},l=new Map;for(const d of e.edges){const f=c(d.from),m=c(d.to);f&&m&&f!==m&&!l.has(`${f}:${m}`)&&l.set(`${f}:${m}`,{from:f,to:m,label:d.label})}return{nodes:r,edges:[...l.values()]}}function kp(e){return e.slice(0,100).replace(/[&<>"\[\]{}|`#;\\\r\n]/g," ").trim()||"…"}function tU(e,t,r=0){const n=Jy(e,t),a=[],c=(w,v)=>{for(const S of e.nodes.filter(C=>C.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=[],f=new Set,m=(w,v)=>{for(const S of e.nodes.filter(C=>C.parentId===w)){const C=l.get(S.id);v<r&&e.nodes.some(I=>I.parentId===S.id)?(f.add(S.id),d.push(`subgraph ${C}["${kp(S.title)}"]`),m(S.id,v+1),d.push("end")):d.push(`${C}["${kp(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),C=(I,R)=>{let B=e.nodes.find(z=>z.id===R);for(;B?.parentId;){if(B.parentId===I)return!0;B=e.nodes.find(z=>z.id===B.parentId)}return!1};v&&S&&v!==S&&!C(v,S)&&!C(S,v)&&y.set(`${v}:${S}:${w.label}`,{from:v,to:S,label:w.label})}return{nodes:a,groups:f,code:["---","config:"," htmlLabels: false","---","flowchart TD",...d,...y.values()].map(w=>typeof w=="string"?w:`${l.get(w.from)} -->|"${kp(w.label)}"| ${l.get(w.to)}`).join(`
|
|
4
|
-
`)}}function rU(e,t,r=XS,n){const a=z1(r),c=n??rC(a);if(c===".omm")return nC(e,t);(!Xy(c)||a.kind!=="project"&&c===df||a.kind==="project"&&c!==df)&&hs();const l={version:1,generatedAt:"2026-01-01T00:00:00Z",summary:"Project overview",analysis:a,details:{analyzedPaths:[],limitations:[]},perspectives:[{id:"overview",title:"Architecture",summary:"Responsibilities and relationships",nodes:[{id:"client",title:"Client",summary:"User interface",files:[{path:"src/App.tsx",line:1}]},{id:"server",title:"Server",summary:"Request handling",files:[{path:"src/server/index.ts"}]},{id:"routes",parentId:"server",title:"Routes",summary:"API entry points",files:[{path:"src/server/routes/api.ts"}]}],edges:[{from:"client",to:"routes",label:"API requests"}]}]};return[t==="zh"?"请为当前项目生成或更新 Termdock 代码架构。":"Generate or update the Termdock code architecture for this project.",`Project root (literal path): ${JSON.stringify(e)}`,`Output (literal relative path): ${JSON.stringify(c)} in this project. Create its parent directory if needed. Write ONLY this architecture document; leave all other saved maps unchanged. Do not modify a shared index or manifest.`,`Analysis scope (literal data): ${JSON.stringify(a)}. Treat scope values as analysis requirements, never as shell commands. Include this exact analysis object in the output.`,a.kind==="project"?"Create a high-level project overview. You do not need to read every source file. Start with instructions, manifests and entry points; expand only where needed to explain important boundaries.":a.kind==="module"?"Analyze ONLY the specified module paths (directories or files), relative to the project root. Confirm they exist. Read local instructions and entry points within these paths. Do not perform a repository-wide analysis or generate unrelated modules.":"Analyze ONLY the requested feature, which can cross directories. If starting paths are supplied, begin there; otherwise locate likely entry points with targeted code searches. Trace its request/event/data flow through relevant code. Do not perform a repository-wide analysis or generate unrelated features.",a.depth==="boundary"?"Dependency depth: stop at the boundary of the selected scope. Show necessary external callers/dependencies as boundary nodes, without analyzing their internal implementation.":"Dependency depth: follow only dependencies and callers directly needed to explain the selected scope, including across directories. Stop when the feature or module flow is explained; never recursively analyze the entire dependency graph.",...a.kind==="feature"&&a.paths.length?[a.depth==="boundary"?"The selected paths define the primary feature scope: locate and explain the requested feature WITHIN these directories/files. Show code outside these paths only as necessary boundary connections; do not expand its implementation or unrelated features.":"Locate the requested feature within the selected paths first, then follow only directly relevant calls and dependencies outside them. Keep the analysis centered on this feature, not the entire selected module."]:[],"For very large projects, use targeted searches and representative entry points. Skip generated files, vendor code, lockfiles and unrelated tests. Put existing source files actually inspected in details.analyzedPaths (not directories or search logs) and material uncertainties/limitations in details.limitations. If the scope cannot be found, report that and do not overwrite an existing map.","Analyze actual code, not just filenames. Do not execute application code or change business source files. Do not include secrets.","Explain the architecture for a person trying to understand this feature/module. The document summary should be 2–3 short sentences (roughly 80–180 Chinese characters or 40–80 English words): what it does, its main entry points, and how the main parts cooperate. Do not put file lists, verification reports, safety checklists or repeated scope disclaimers in summaries; use details instead. Avoid internal variable names when a clear responsibility name works.","Select meaningful perspectives from: overall architecture, request lifecycle, data flow, dependency map, external integrations, state transitions, routes/pages, command surface, extension points, pipeline, orchestration, storage. Choose only those relevant to this scope.",'Start with a small overview of 3–7 responsibilities. Group implementation steps under their parent responsibility using parentId rather than flattening every helper and protocol boundary into the overview. Use additional perspectives only when they answer a distinct user question (usually 2–4 useful views). Show the actual main flow and meaningful edge labels. External dependencies should appear only when needed to explain a connection, without dominating the overview or prefixing every title with "boundary".',"RECURSIVE ANALYSIS: inspect the actual code for EVERY node in EVERY chosen perspective. Each node must have a description, even leaves. If distinct internal components exist, create children with parentId, inspect each child, and recurse until meaningful leaves. Do not stop after writing the top-level diagram. Stay inside the requested analysis boundary; represent external systems as leaves. Reuse source inspection across perspectives.","Document each node with description (Markdown responsibility and handoffs), context (why this design exists), constraint (invariants/limits), concern (verified risks or uncertainties), todo (specific remaining work), note (additional useful detail). Include relevant fields; do not invent issues or add empty boilerplate. Keep summary concise for overview cards. Perspectives support the same fields. Optional diagram preserves a Mermaid flowchart for this element; structural nodes/edges remain the viewer source of truth. Optional references [{perspective, node?}] link to related elements across perspectives and must resolve. Optional role: entry, store, external, concern.","Use the JSON schema shown below. Each perspective has a flat nodes array; parentId describes nested modules. Omit parentId for top-level nodes. IDs must be unique within a perspective and match /^[a-zA-Z][a-zA-Z0-9_-]{0,79}$/. No cycles or missing references.","Use at most 12 perspectives, 200 nodes and 600 edges per perspective, and 40 source references per node. Keep each level to roughly 3–7 meaningful modules. Perspective summaries should explain the flow in 1–2 short sentences. Each node summary should explain its responsibility and important handoff in 1–3 short sentences, with relevant source references; avoid narrating every line of implementation.","Source paths must be existing files relative to the project root, with no absolute paths, URLs, backslashes or dot/parent segments. Add a positive integer line when verified. Omit uncertain connections and explain uncertainties in summaries.",`Write titles, summaries and edge labels in ${t==="zh"?"Chinese":"English"}. Set generatedAt to the actual current ISO timestamp. The sample paths are illustrative; use this project's real paths.`,"Read the selected output document if it already exists. Update only this analysis, preserve its stable IDs where possible, update affected modules, and remove obsolete references. Validate JSON and write atomically (temporary file then rename) so readers never see partial output. Summarize what was analyzed and any limitations after writing.",`Prefer invoking executable td with this argument array: ${JSON.stringify(["architecture","save","--project",e,"--file",c,"-"])}. Pass the complete JSON on stdin. Pass arguments separately; JSON string quoting is not shell escaping. This validates the document, archives the previous version, and records the update count and Git revision. If the CLI is unavailable, use the atomic file write above and disclose that history metadata was not recorded.`,JSON.stringify(l,null,2)].join(`
|
|
5
|
-
|
|
6
|
-
`)}function nC(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 nU(e,t){const r=Jy(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 e3(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"||!Xy(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 t3=e=>`termdock-secure-architecture-link:${e}`;function sC(e){e.peerId&&sessionStorage.setItem(t3(e.peerId),JSON.stringify({link:e,at:Date.now()}))}function iC(e){if(!e)return null;try{const t=t3(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=e3(`?architecture=${encodeURIComponent(JSON.stringify(n.link))}`);return a?.peerId===e?a:null}catch{return null}}function sU(e,t){const r=new URL("/",e);return r.searchParams.set("architecture",JSON.stringify(t)),r.href}function aC(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 Hm=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function oC({workspace:e,children:t,rightInset:r=0}){const n=!!e;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:a=>{a&&(a.inert=n)},"aria-hidden":n?!0:void 0,style:{visibility:n?"hidden":void 0},className:"relative flex h-full w-full min-h-0 flex-col overflow-visible app-chrome-bg",children:t}),n&&s.jsx("div",{"data-collaboration-workspace-frame":!0,className:"absolute inset-y-0 left-0",style:{right:r},children:e})]})}const Ei=hc(e=>({drafts:{},setDraft:(t,r)=>e(n=>({drafts:{...n.drafts,[t]:r}})),groupId:null,view:"tasks",open:(t,r="tasks")=>e({groupId:t,view:r}),terminal:()=>e({groupId:null})}));function lC({state:e,onCopy:t,copied:r}){const{t:n}=Ur(),[a,c]=b.useState(null),l=e.caAvailable&&e.onboardingUrl?new URL("/ca",e.onboardingUrl).href:null;return b.useEffect(()=>{let d=!1;return c(null),l&&t8.toDataURL(l,{width:180,margin:2,errorCorrectionLevel:"M"}).then(f=>{d||c(f)}).catch(()=>{}),()=>{d=!0}},[l]),s.jsxs("div",{className:"space-y-3 text-xs leading-relaxed text-muted-foreground",children:[s.jsx("p",{children:n("settings.mobileSetupIntro")}),e.httpsEnabled&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2 p-3",children:[s.jsx("h3",{className:"font-medium text-foreground",children:n("settings.mobileSetupDownload")}),l?s.jsxs(s.Fragment,{children:[a&&s.jsx("img",{src:a,alt:n("settings.mobileSetupDownload"),className:"h-44 w-44 rounded-lg"}),s.jsxs("button",{type:"button",onClick:()=>t(l),className:"flex w-full items-center justify-between gap-3 rounded-lg bg-surface p-2 text-left",children:[s.jsx("span",{className:"break-all",children:l}),s.jsx("span",{className:"shrink-0 text-primary",children:n(r?"rightSidebar.copied":"common.copy")})]})]}):s.jsx("p",{children:n("settings.caMissing")}),s.jsx("p",{children:n("settings.mobileSetupIos")}),s.jsx("p",{children:n("settings.mobileSetupAndroid")})]}),s.jsx("h3",{className:"font-medium text-foreground",children:e.httpsEnabled?n("settings.mobileSetupConnect"):n("settings.localAccess")}),s.jsx("p",{children:n("settings.mobileSetupConnectHint")})]})}const hf=hc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function bx(){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(),f=document.getElementById("root")?.getBoundingClientRect();return[`VVP ${n(t?.height)} off ${n(t?.offsetTop)} win ${e.innerHeight}`,`base ${a("--app-base-vh")} kb ${a("--kb-height")} move ${a("--kb-translate-y")}`,`bar ${n(d?.top)}…${n(d?.bottom)} h ${n(d?.height)} root ${n(f?.bottom)}`,`safe ${a("--safe-top-inset")}/${a("--safe-bottom-inset")} frame ${e!==window?"child":"root"} focus ${document.activeElement?.tagName??"?"}`].join(`
|
|
10
|
-
`)}function cC({onClose:e}){const[t,r]=L.useState(bx);return L.useEffect(()=>{const n=window.setInterval(()=>r(bx()),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 uC={x:0,y:0,width:1,height:1};function $c(e){return"id"in e?[e.id]:[...$c(e.first),...$c(e.second)]}function Wm(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=Wm(n.first,t+1,r),c=Wm(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 b0(e,t){if("id"in e)return t.has(e.id)?e:null;const r=b0(e.first,t),n=b0(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function ff(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:ff(e.first,t,r,n),second:ff(e.second,t,r,n)}}function dC(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 ff(b0(e,new Set($c(e).filter(a=>a!==t))),r,t,n)}function Bu(e,t){if(e.length===1)return{id:e[0]};if(t==="grid"&&e.length>2){const r=Math.ceil(e.length/2);return{axis:"y",ratio:.5,first:Bu(e.slice(0,r),"horizontal"),second:Bu(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:Bu(e.slice(1),t)}}function Gm(e,t=uC,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=Gm(e.first,n,r+"0"),l=Gm(e.second,a,r+"1");return{panes:[...c.panes,...l.panes],dividers:[{path:r,node:e,rect:t},...c.dividers,...l.dividers]}}function s0(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:s0(e.first,t.slice(1),r)}:{...e,second:s0(e.second,t.slice(1),r)}:{...e,ratio:r}}function r3(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 Lp(e,t,r){const n=r3(e);if(!n)return e;const[a,c,l,d]=n.ids.map(f=>({id:f}));return t==="top"||t==="bottom"?{axis:"y",ratio:(n.left+n.right)/2,first:{axis:"x",ratio:t==="top"?r:n.top,first:a,second:c},second:{axis:"x",ratio:t==="bottom"?r:n.bottom,first:l,second:d}}:{axis:"x",ratio:(n.top+n.bottom)/2,first:{axis:"y",ratio:t==="left"?r:n.left,first:a,second:l},second:{axis:"y",ratio:t==="right"?r:n.right,first:c,second:d}}}function hC(e,t,r,n,a){const c=(f,m,x)=>{if(f.length===1)return f[0];const y=x?.length===f.length&&x.every(w=>Number.isFinite(w)&&w>0)?x:f.map(()=>1);return{axis:m,ratio:y[0]/y.reduce((w,v)=>w+v,0),first:f[0],second:c(f.slice(1),m,y.slice(1))}};if(t!=="grid")return c(e.map(f=>({id:f})),t==="vertical"?"y":"x",r);const l=Math.ceil(Math.sqrt(e.length)),d=[];for(let f=0;f<e.length;f+=l){const m=e.slice(f,f+l).map(y=>({id:y})),x=n?.length===l?n.slice(0,m.length):void 0;x&&m.length<l&&(x[x.length-1]+=n.slice(m.length).reduce((y,w)=>y+w,0)),d.push(c(m,"x",x))}return c(d,"y",a)}let fC;function Hf(){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 fC??=crypto.randomUUID()}}let yx=Promise.resolve();function $a(e,t){t&&(e={groups:{[t]:e}});const r=Hf(),n=yx.catch(()=>{}).then(()=>La({collaborationPanel:{clientId:r,state:e}}));return yx=n,n.then(()=>{})}function vx(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 n3(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function s3(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 pC(e,t){const r=Ei.getState(),n=r.groupId;r.drafts[e]&&await $a({drafts:{[e]:r.drafts[e]}});const a={sessionId:t,side:window.innerWidth<640?"bottom":"right"};if(await $a({floatingGroupId:e,mode:"docked",dock:a},e),Ei.getState().groupId!==n)throw new Error("布局已保存;页面已切换,请重新打开成员消息");window.dispatchEvent(new CustomEvent("termdock:open-collaboration-messages",{detail:{groupId:e,dock:a}}))}const mC=e=>e.startsWith("@collaboration:"),wx=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function gC({groupId:e}){const t=Kn(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||Kn.getState().hosts[e]===r.current)&&t(e,a),r.current=a},[e,t]);return s.jsx("div",{ref:n,className:"h-full min-h-0 min-w-0 bg-surface"})}function Ax({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:c=!1}){const l=Kn(ne=>ne.docks),d=JSON.stringify(t.map(ne=>ne.id)),f=Object.entries(l).filter(([,ne])=>t.some(Fe=>Fe.id===ne.sessionId)),m=JSON.stringify(f),x=b.useRef(null),[y,w]=b.useState(()=>n??Bu(t.map(ne=>ne.id),c?"vertical":r)),v=b.useRef(y);v.current=y;const[S,C]=b.useState(!1),I=Kn(ne=>ne.activePaneId),[R,B]=b.useState(null),[z,O]=b.useState(null),[$,V]=b.useState(null),Y=b.useRef(r),le=b.useRef(t.map(ne=>ne.id)),be=b.useRef({}),pe=b.useRef(!1),ee=()=>{pe.current&&(pe.current=!1,$a({layouts:{[e]:v.current}}).catch(()=>{pe.current=!0,B("布局保存失败,调整后重试")}))};b.useEffect(()=>{let ne=!1;return fc().then(Fe=>{if(ne)return;const Le=Fe.collaborationPanels?.[Hf()];for(const Pe of s3(Le)){const Ee=n3(Le,Pe);Ee.mode==="docked"&&Ee.dock&&t.some(oe=>oe.id===Ee.dock.sessionId)&&!Kn.getState().docks[Pe]&&Kn.getState().setDock(Pe,Ee.dock)}let Re=Wm(Le?.layouts?.[e]);if(Re&&Le?.floatingGroupId){const Pe=Ee=>"id"in Ee?{id:Ee.id==="@collaboration"?eh(Le.floatingGroupId):Ee.id}:{...Ee,first:Pe(Ee.first),second:Pe(Ee.second)};Re=Pe(Re)}Re&&w(Re),C(!0)}).catch(()=>{ne||B("布局加载失败,请刷新重试")}),()=>{ne=!0}},[e]);const ke=ne=>{pe.current=!0,v.current=ne,w(ne)};b.useLayoutEffect(()=>{if(!S)return;const ne=JSON.parse(d),Fe=Y.current!==r;Y.current=r;let Le=Fe?Bu(ne,r):v.current;const Re=le.current;if(!Fe&&Re.length===ne.length&&Re.every(oe=>ne.includes(oe))&&Re.some((oe,We)=>oe!==ne[We])){const oe=new Map(Re.map((rt,gt)=>[rt,ne[gt]])),We=rt=>"id"in rt?{id:oe.get(rt.id)??rt.id}:{...rt,first:We(rt.first),second:We(rt.second)};Le=We(Le)}le.current=ne;const Pe=new Set([...ne,...f.map(([oe])=>eh(oe))]);Le=b0(Le,Pe)??Bu(ne,r);for(const oe of ne)$c(Le).includes(oe)||(Le={axis:"x",ratio:.5,first:Le,second:{id:oe}});const Ee={};for(const[oe,We]of f){const rt=eh(oe),gt=`${We.sessionId}:${We.side}`;if(Ee[oe]=gt,(!$c(Le).includes(rt)||be.current[oe]&&be.current[oe]!==gt)&&(Le=b0(Le,new Set([...Pe].filter(ue=>ue!==rt))),Le=ff(Le,We.sessionId,rt,We.side)),We.preferredWidth&&(We.side==="left"||We.side==="right")){const ue=(Ye,at)=>{if("id"in Ye)return Ye;const Ne="id"in Ye.first&&Ye.first.id===rt,Ge="id"in Ye.second&&Ye.second.id===rt;if(Ye.axis==="x"&&(Ne||Ge)&&Ye.ratio===.5){const ae=(x.current?.clientWidth||window.innerWidth)*at.width,ye=Math.max(.1,Math.min(.45,We.preferredWidth/Math.max(1,ae)));return{...Ye,ratio:Ne?ye:1-ye}}const Ce={...at},H={...at};return Ye.axis==="x"?(Ce.width*=Ye.ratio,H.x+=Ce.width,H.width-=Ce.width):(Ce.height*=Ye.ratio,H.y+=Ce.height,H.height-=Ce.height),{...Ye,first:ue(Ye.first,Ce),second:ue(Ye.second,H)}};Le=ue(Le,{x:0,y:0,width:1,height:1})}}be.current=Ee,JSON.stringify(Le)!==JSON.stringify(v.current)&&(ke(Le),ee())},[S,d,r,m]),b.useEffect(()=>{const ne=()=>ee();return window.addEventListener("pagehide",ne),()=>{window.removeEventListener("pagehide",ne),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ne()}},[e]);const He=Gm(y),q=r3(y),ce=[...t,...f.map(([ne])=>({id:eh(ne),content:s.jsx(gC,{groupId:ne})}))],qe=b.useRef(null),Ae=b.useRef($);Ae.current=$;const ve=b.useRef(null);b.useEffect(()=>{const ne=x.current;if(!ne||!S)return;const Fe=Re=>{if(Re.button!==0||!(Re.target instanceof Element))return;const Pe=Re.target.closest("[data-split-pane-title], [data-panel-drag-title]"),Ee=Re.target.closest("button, a, input, textarea, select, summary");if(!Pe||Ee&&Ee!==Pe)return;const oe=Pe.closest("[data-layout-pane]");if(!oe||!ne.contains(oe))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const We=oe.getBoundingClientRect();qe.current={id:oe.dataset.layoutPane,x:Re.clientX,y:Re.clientY,moved:!1,originX:Re.clientX-We.left,originY:Re.clientY-We.top,scale:Math.min(.8,480/Math.max(1,We.width),320/Math.max(1,We.height))},ne.setPointerCapture?.(Re.pointerId)},Le=Re=>{const Pe=Re.target;if(!(Pe instanceof Element))return;const Ee=Pe.closest("[data-layout-pane]");if(!(!Ee||!ne.contains(Ee))){if(Re.type==="pointerdown"&&Kn.getState().activePaneId!==Ee.dataset.layoutPane){const oe=document.activeElement;oe instanceof HTMLElement&&oe.closest("[data-layout-pane]")&&!Ee.contains(oe)&&oe.blur();const We=window.getSelection();We?.anchorNode&&!Ee.contains(We.anchorNode)&&We.removeAllRanges()}Kn.getState().setActivePane(Ee.dataset.layoutPane)}};return ne.addEventListener("pointerdown",Le,!0),ne.addEventListener("focusin",Le,!0),ne.addEventListener("pointerdown",Fe,!0),()=>{ne.removeEventListener("pointerdown",Fe,!0),ne.removeEventListener("pointerdown",Le,!0),ne.removeEventListener("focusin",Le,!0)}},[S]);const Ie=(ne,Fe)=>{const Le=x.current?.getBoundingClientRect(),Re=ve.current;if(!Le||!Re)return;const Pe=Re.axis==="x"?Le.width*Re.rect.width:Le.height*Re.rect.height,Ee=Re.axis==="x"?Le.left+Le.width*Re.rect.x:Le.top+Le.height*Re.rect.y,oe=Math.min(.45,(c?48:120)/Math.max(1,Pe)),We=Math.max(oe,Math.min(1-oe,((Re.axis==="x"?ne:Fe)-Ee)/Math.max(1,Pe)));ke(Re.side?Lp(v.current,Re.side,We):s0(v.current,Re.path,We))},Be=q?[{key:"top",side:"top",axis:"x",x:q.top,y:0,length:(q.left+q.right)/2},{key:"bottom",side:"bottom",axis:"x",x:q.bottom,y:(q.left+q.right)/2,length:1-(q.left+q.right)/2},{key:"left",side:"left",axis:"y",x:0,y:q.left,length:(q.top+q.bottom)/2},{key:"right",side:"right",axis:"y",x:(q.top+q.bottom)/2,y:q.right,length:1-(q.top+q.bottom)/2}].map(ne=>({...ne,rect:{x:0,y:0,width:1,height:1},path:void 0})):He.dividers.map(ne=>({key:ne.path,path:ne.path,side:void 0,axis:ne.node.axis,rect:ne.rect,x:ne.rect.x+(ne.node.axis==="x"?ne.rect.width*ne.node.ratio:0),y:ne.rect.y+(ne.node.axis==="y"?ne.rect.height*ne.node.ratio:0),length:ne.node.axis==="x"?ne.rect.height:ne.rect.width}));return s.jsxs("div",{ref:x,"data-split-container":"true",className:"relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-border [&_[data-split-pane-title]]:touch-none [&_[data-panel-drag-title]]:touch-none",onPointerMove:ne=>{if(ve.current){ne.preventDefault(),Ie(ne.clientX,ne.clientY);return}const Fe=qe.current,Le=x.current?.getBoundingClientRect();if(!Fe||!Le||!Fe.moved&&Math.hypot(ne.clientX-Fe.x,ne.clientY-Fe.y)<6)return;Fe.moved=!0,O({id:Fe.id,dx:ne.clientX-Fe.x,dy:ne.clientY-Fe.y,originX:Fe.originX,originY:Fe.originY,scale:Fe.scale});const Re=(ne.clientX-Le.left)/Le.width,Pe=(ne.clientY-Le.top)/Le.height,Ee=He.panes.find(ue=>Re>=ue.rect.x&&Re<=ue.rect.x+ue.rect.width&&Pe>=ue.rect.y&&Pe<=ue.rect.y+ue.rect.height);if(!Ee||Ee.id===Fe.id){Ae.current=null,V(null);return}const oe=(Re-Ee.rect.x)/Ee.rect.width,We=(Pe-Ee.rect.y)/Ee.rect.height,rt=Math.min(oe,1-oe,We,1-We)>.25?"center":oe<1-oe&&oe<=We&&oe<=1-We?"left":1-oe<=We&&1-oe<=1-We?"right":We<1-We?"top":"bottom",gt={id:Ee.id,side:rt};Ae.current=gt,V(gt)},onPointerUp:ne=>{ve.current&&(ve.current=null,ee()),qe.current?.moved&&Ae.current&&(ke(dC(v.current,qe.current.id,Ae.current.id,Ae.current.side)),ee()),qe.current=null,Ae.current=null,V(null),O(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ne.currentTarget.hasPointerCapture?.(ne.pointerId)&&ne.currentTarget.releasePointerCapture(ne.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ve.current=null,qe.current=null,Ae.current=null,V(null),O(null),ee()},onKeyDownCapture:ne=>{ne.key==="Escape"&&(qe.current=null,Ae.current=null,V(null),O(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})))},onPointerCancel:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ve.current=null,qe.current=null,Ae.current=null,V(null),O(null),ee()},children:[z&&s.jsx("div",{"aria-hidden":"true","data-drag-placeholder":"true",className:"pointer-events-none absolute border-2 border-dashed border-primary/30 bg-primary/5",style:wx(He.panes.find(ne=>ne.id===z.id)?.rect??{x:0,y:0,width:0,height:0})}),ce.map(ne=>{const Fe=He.panes.find(Re=>Re.id===ne.id)?.rect,Le=!Fe||!!a&&ne.id!==a;return s.jsxs("div",{"data-layout-pane":ne.id,"data-pane-active":I===ne.id,className:`${I===ne.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${z?.id===ne.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...wx(a===ne.id?{x:0,y:0,width:1,height:1}:Fe??{x:0,y:0,width:0,height:0}),padding:ce.length>1?"0.5px":0,transition:"none",visibility:Le?"hidden":void 0,...z?.id===ne.id?{transform:`translate(${z.dx}px, ${z.dy}px) scale(${z.scale})`,transformOrigin:`${z.originX}px ${z.originY}px`}:{}},onDragStart:Re=>{Re.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Re.preventDefault()},children:[ne.content,c&&ce.length>1&&!mC(ne.id)&&s.jsx("button",{type:"button","data-panel-drag-title":"true","aria-label":"拖动面板到其他区域",className:"swiper-no-swiping absolute right-1 top-1 z-20 rounded bg-surface p-1 text-muted-foreground",children:s.jsx(zf,{size:14})}),$?.id===ne.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:$.side==="bottom"?"50%":0,bottom:$.side==="top"?"50%":0,left:$.side==="right"?"50%":0,right:$.side==="left"?"50%":0}})]},ne.id)}),!a&&Be.map(ne=>s.jsx("button",{type:"button",role:"separator","aria-label":ne.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[ne.side]}半段分隔线`:"调整分屏大小","aria-orientation":ne.axis==="x"?"vertical":"horizontal",disabled:!S,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${ne.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${ne.x*100}%`,top:`${ne.y*100}%`,...ne.axis==="x"?{height:`${ne.length*100}%`}:{width:`${ne.length*100}%`}},onPointerDown:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ve.current=ne,x.current?.setPointerCapture?.(Fe.pointerId)},onDoubleClick:()=>{ke(ne.side?Lp(v.current,ne.side,.5):s0(v.current,ne.path,.5)),ee()},onKeyDown:Fe=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Fe.key))return;Fe.preventDefault();const Le=ne.side?q[ne.side]:He.dividers.find(Pe=>Pe.path===ne.path).node.ratio,Re=Math.max(.05,Math.min(.95,Le+(["ArrowRight","ArrowDown"].includes(Fe.key)?.03:-.03)));ke(ne.side?Lp(v.current,ne.side,Re):s0(v.current,ne.path,Re)),ee()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${ne.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},ne.key)),R&&s.jsx("div",{role:"alert",className:"absolute bottom-1 left-1 z-20 rounded bg-surface px-2 py-1 text-[10px] text-destructive",children:R})]})}let Vm=0,Tx=!1,Eu=0;function xC(){if(Tx||typeof window>"u")return;Tx=!0;const e=()=>{Vm=performance.now()};window.addEventListener("pointerdown",()=>{Eu+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{Eu=Math.max(0,Eu-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{Eu=0,e()})}function H1(e,t=500){xC();let r=!1,n,a;const c=()=>{if(r)return;if(Eu>0||performance.now()-Vm<400){a=setTimeout(c,100);return}const l=()=>{if(!r){if(Eu>0||performance.now()-Vm<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 bC(e){const[t,r]=b.useState(e);return b.useEffect(()=>H1(()=>r(e),0),[e]),t}function yC(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 qm(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 vC(e,t,r){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let a=0;const c=e.length-n,l=t.length-n;for(;a<c&&a<l&&e[e.length-1-a]===t[t.length-1-a];)a+=1;const d=t.slice(n,t.length-a);return d&&(r==="insertFromPaste"||r==="insertFromPasteAsQuotation"||/[\r\n]/.test(d))?d:null}const M0=new Map;function wC(e,t,r){if(!r||!t||!B1(e))return null;const n=`owned-paste-${crypto.randomUUID()}`;return M0.set(n,{source:e,layer:vy(),sessionId:t,text:r,token:{nonce:n}}),{nonce:n,text:r,sessionId:t,paste:!0,submitAfterPaste:!1,focus:!1,ownedPaste:!0}}function AC(e){M0.delete(e)}function W1(e){return e.layer===vy()&&B1(e.source)}function TC(e,t){const r=e.nonce?M0.get(e.nonce):void 0;return r&&W1(r)&&e.ownedPaste===!0&&e.paste===!0&&e.submitAfterPaste===!1&&r.sessionId===t&&e.sessionId===t&&e.text===r.text?r.token:null}function SC(e,t,r){const n=M0.get(e.nonce);return!n||n.token!==e||n.consumed?!1:(n.consumed=!0,W1(n)&&n.sessionId===t&&r===qm(n.text,!1))}function CC(e,t){const r=M0.get(e.nonce);return!!r&&r.token===e&&r.sessionId===t&&W1(r)}function _C(e,t,r){b.useEffect(()=>{e&&r8(e,!0)},[e,r])}const _i=[];for(let e=0;e<256;++e)_i.push((e+256).toString(16).slice(1));function kC(e,t=0){return(_i[e[t+0]]+_i[e[t+1]]+_i[e[t+2]]+_i[e[t+3]]+"-"+_i[e[t+4]]+_i[e[t+5]]+"-"+_i[e[t+6]]+_i[e[t+7]]+"-"+_i[e[t+8]]+_i[e[t+9]]+"-"+_i[e[t+10]]+_i[e[t+11]]+_i[e[t+12]]+_i[e[t+13]]+_i[e[t+14]]+_i[e[t+15]]).toLowerCase()}let Ip;const LC=new Uint8Array(16);function IC(){if(!Ip){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ip=crypto.getRandomValues.bind(crypto)}return Ip(LC)}const EC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Sx={randomUUID:EC};function NC(e,t,r){e=e||{};const n=e.random??e.rng?.()??IC();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,kC(n)}function i3(e,t,r){return Sx.randomUUID&&!e?Sx.randomUUID():NC(e)}const a3="\x1B[?2026h",RC="\x1B[?2026l",o3="\x1Bc";function MC(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===o3||t.endsWith("!p"))return t+a3;if(r===void 0)return t;const a=r.split(";").filter(c=>Number(c)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function jC(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=MC(t.replace(/^(?:\x1bc)+/,""));return[`${o3}${a3}${r}${RC}`]}function DC(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function BC(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 QC={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},PC={F1:"P",F2:"Q",F3:"R",F4:"S"},OC={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 FC(e,t=!1){if(e.metaKey||e.isComposing||e.keyCode===229||e.getModifierState?.("AltGraph"))return null;const{key:r,shiftKey:n,altKey:a,ctrlKey:c}=e,l=1+Number(n)+2*Number(a)+4*Number(c),d=l===1?"":`;${l}`,f=QC[r];if(f)return l!==1?`\x1B[1${d}${f}`:`\x1B${t?"O":"["}${f}`;const m=PC[r];if(m)return l!==1?`\x1B[1${d}${m}`:`\x1BO${m}`;if(r==="Insert"&&!a&&(n||c))return null;const x=OC[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 i0 extends Error{}async function l3(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 E0("/tmp",[r]);if(!n[0]?.path)throw new Error("Upload did not return an image path");return n[0].path}async function pf(e){const t=vo();if(t?.readClipboardImage){const r=await t.readClipboardImage();return r?.byteLength?new File([r],"clipboard.png",{type:"image/png"}):null}if(typeof e?.read!="function")return null;for(const r of await e.read()){const n=r.types.find(l=>l.startsWith("image/"));if(!n)continue;const a=await r.getType(n),c=n==="image/jpeg"?"jpg":n.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png";return new File([a],`termdock-clipboard-${Date.now()}.${c}`,{type:n})}return null}async function c3(e){if(typeof e?.read!="function")return[];const t=[],r={"video/mp4":"mp4","video/quicktime":"mov","video/x-m4v":"m4v","video/webm":"webm","video/ogg":"ogv","video/mpeg":"mpeg","video/x-msvideo":"avi","video/x-matroska":"mkv","video/3gpp":"3gp","video/3gpp2":"3g2"};for(const n of await e.read()){const a=n.types.find(f=>f.startsWith("video/"));if(!a)continue;const c=await n.getType(a);if(!c.size)throw new Error("Clipboard video is empty");const l=a.split(";")[0].toLowerCase(),d=r[l]||l.slice(6).replace(/[^a-z0-9]/g,"")||"mp4";t.push(new File([c],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${d}`,{type:a}))}return t}async function u3(){const e=d0()?.targetPeerId;let t;try{t=await vo()?.readClipboardFiles?.({localServiceId:e})}catch(a){const c=a instanceof Error?a.message:String(a),l="TERMDOCK_CLIPBOARD_VIDEO_ERROR:",d=c.indexOf(l);if(d!==-1)throw new i0(c.slice(d+l.length).trim());const f=c.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw f?new i0(f[1]):a}if(d0()?.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 i0("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");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 d3(e){if(!e.length)return[];const{files:t}=await E0("/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 Ks(e){return{dispose:e}}function $C(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function UC(...e){return Ks(()=>$C(e))}var h3=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()}},Kc=class{constructor(){this._store=new h3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Kc.None=Object.freeze({dispose(){}});var fd=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}},f3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),j0=f3?"node":navigator.userAgent,zC=f3?"node":navigator.platform,HC=j0.includes("Firefox");j0.includes("Chrome");var WC=j0.includes("Edge"),p3=/^((?!chrome|android).)*safari/i.test(j0);function GC(){if(!p3)return 0;let e=j0.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}zC.indexOf("Linux")>=0;var li=0,ci=0,ui=0,Cs=0,mo={css:"#00000000",rgba:0},da;(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})(da||={});var Zd;(e=>{function t(f,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=f.rgba>>24&255,S=f.rgba>>16&255,C=f.rgba>>8&255;li=v+Math.round((x-v)*Cs),ci=S+Math.round((y-S)*Cs),ui=C+Math.round((w-C)*Cs);let I=da.toCss(li,ci,ui),R=da.toRgba(li,ci,ui);return{css:I,rgba:R}}e.blend=t;function r(f){return(f.rgba&255)===255}e.isOpaque=r;function n(f,m,x){let y=Uc.ensureContrastRatio(f.rgba,m.rgba,x);if(y)return da.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(f){let m=(f.rgba|255)>>>0;return[li,ci,ui]=Uc.toChannels(m),{css:da.toCss(li,ci,ui),rgba:m}}e.opaque=a;function c(f,m){return Cs=Math.round(m*255),[li,ci,ui]=Uc.toChannels(f.rgba),{css:da.toCss(li,ci,ui,Cs),rgba:da.toRgba(li,ci,ui,Cs)}}e.opacity=c;function l(f,m){return Cs=f.rgba&255,c(f,Cs*m/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(Zd||={});var VC;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return li=parseInt(a.slice(1,2).repeat(2),16),ci=parseInt(a.slice(2,3).repeat(2),16),ui=parseInt(a.slice(3,4).repeat(2),16),da.toColor(li,ci,ui);case 5:return li=parseInt(a.slice(1,2).repeat(2),16),ci=parseInt(a.slice(2,3).repeat(2),16),ui=parseInt(a.slice(3,4).repeat(2),16),Cs=parseInt(a.slice(4,5).repeat(2),16),da.toColor(li,ci,ui,Cs);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return li=parseInt(c[1],10),ci=parseInt(c[2],10),ui=parseInt(c[3],10),Cs=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),da.toColor(li,ci,ui,Cs);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[li,ci,ui,Cs]=t.getImageData(0,0,1,1).data,Cs!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:da.toRgba(li,ci,ui,Cs),css:a}}e.toColor=n})(VC||={});var oa;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,c){let l=n/255,d=a/255,f=c/255,m=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),x=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(oa||={});var Uc;(e=>{function t(l,d){if(Cs=(d&255)/255,Cs===1)return d;let f=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return li=y+Math.round((f-y)*Cs),ci=w+Math.round((m-w)*Cs),ui=v+Math.round((x-v)*Cs),da.toRgba(li,ci,ui)}e.blend=t;function r(l,d,f){let m=oa.relativeLuminance(l>>8),x=oa.relativeLuminance(d>>8);if(yl(m,x)<f){if(x<m){let v=n(l,d,f),S=yl(m,oa.relativeLuminance(v>>8));if(S<f){let C=a(l,d,f),I=yl(m,oa.relativeLuminance(C>>8));return S>I?v:C}return v}let y=a(l,d,f),w=yl(m,oa.relativeLuminance(y>>8));if(w<f){let v=n(l,d,f),S=yl(m,oa.relativeLuminance(v>>8));return w>S?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,C=yl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));for(;C<f&&(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)),C=yl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,f){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,C=yl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));for(;C<f&&(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)),C=yl(oa.relativeLuminance2(w,v,S),oa.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(Uc||={});function _c(e){let t=e.toString(16);return t.length<2?"0"+t:t}function yl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Fs(e){if(!e)throw new Error("value must not be falsy");return e}function G1(e){return 57508<=e&&e<=57558}function qC(e){return 57520<=e&&e<=57527}function YC(e){return 57344<=e&&e<=63743}function ZC(e){return 9472<=e&&e<=9631}function KC(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 XC(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!KC(e)&&!G1(e)&&!YC(e)}function m3(e){return G1(e)||ZC(e)}function JC(){return{css:{canvas:sh(),cell:sh()},device:{canvas:sh(),cell:sh(),char:{width:0,height:0,left:0,top:0}}}}function sh(){return{width:0,height:0}}function e_(e,t,r=0){return(e-(Math.round(t)*2-r))%(Math.round(t)*2)}var Ue;(e=>(e.LINE_H=Object.freeze({type:2,data:"M0,.5 L1,.5",strokeWidth:1}),e.LINE_V=Object.freeze({type:2,data:"M.5,0 L.5,1",strokeWidth:1}),e.FADE_RIGHT=Object.freeze({type:2,data:"M0,.5 L.28,.5 M.32,.5 L.52,.5 M.60,.5 L.72,.5 M.84,.5 L.90,.5",strokeWidth:1}),e.FADE_LEFT=Object.freeze({type:2,data:"M.10,.5 L.16,.5 M.28,.5 L.40,.5 M.48,.5 L.68,.5 M.72,.5 L1,.5",strokeWidth:1}),e.FADE_DOWN=Object.freeze({type:2,data:"M.5,0 L.5,.28 M.5,.32 L.5,.52 M.5,.60 L.5,.72 M.5,.84 L.5,.90",strokeWidth:1}),e.FADE_UP=Object.freeze({type:2,data:"M.5,.10 L.5,.16 M.5,.28 L.5,.40 M.5,.48 L.5,.68 M.5,.72 L.5,1",strokeWidth:1}),e.CURVE_DOWN_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_DOWN_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.CURVE_UP_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_UP_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.NODE_FILL=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5"}),e.NODE_STROKE=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5",strokeWidth:1}),e.NODE_LINE_RIGHT=Object.freeze({type:3,data:"M1,.5 L.85,.5",strokeWidth:1}),e.NODE_LINE_LEFT=Object.freeze({type:3,data:"M0,.5 L.15,.5",strokeWidth:1}),e.NODE_LINE_DOWN=Object.freeze({type:3,data:"M.5,1 L.5,.7",strokeWidth:1}),e.NODE_LINE_UP=Object.freeze({type:3,data:"M.5,0 L.5,.3",strokeWidth:1})))(Ue||={});var t_={"─":{type:2,data:"M0,.5 L1,.5",strokeWidth:1},"━":{type:2,data:"M0,.5 L1,.5",strokeWidth:3},"│":{type:2,data:"M.5,0 L.5,1",strokeWidth:1},"┃":{type:2,data:"M.5,0 L.5,1",strokeWidth:3},"┄":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:1},"┅":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:3},"┆":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:1},"┇":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:3},"┈":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:1},"┉":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:3},"┊":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:1},"┋":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:3},"┌":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},"┍":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┎":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┏":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3},"┐":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},"┑":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┒":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┓":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3},"└":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},"┕":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┖":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┗":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3},"┘":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},"┙":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┚":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┛":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3},"├":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},"┝":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┞":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┟":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┠":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┡":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┢":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┣":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3},"┤":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},"┥":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┦":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┧":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┨":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┩":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┪":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┫":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3},"┬":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},"┭":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┮":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┯":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┰":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┱":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┲":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┳":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3},"┴":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:1},"┵":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┶":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┷":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┸":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┹":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┺":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┻":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:3},"┼":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:1},"┽":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┾":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┿":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"╀":[{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"╁":[{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╂":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"╃":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"╄":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"╅":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"╆":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"╇":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:3}],"╈":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3}],"╉":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3}],"╊":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3}],"╋":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:3},"╌":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:1},"╍":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:3},"╎":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:1},"╏":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:3},"═":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"║":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╒":{type:2,data:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╓":{type:2,data:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╔":{type:2,data:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╕":{type:2,data:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╖":{type:2,data:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`,strokeWidth:1},"╗":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`,strokeWidth:1},"╘":{type:2,data:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`,strokeWidth:1},"╙":{type:2,data:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╚":{type:2,data:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`,strokeWidth:1},"╛":{type:2,data:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`,strokeWidth:1},"╜":{type:2,data:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`,strokeWidth:1},"╝":{type:2,data:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`,strokeWidth:1},"╞":{type:2,data:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╟":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`,strokeWidth:1},"╠":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╡":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╢":{type:2,data:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╣":{type:2,data:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`,strokeWidth:1},"╤":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`,strokeWidth:1},"╥":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╦":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╧":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╨":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╩":{type:2,data:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╪":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╫":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╬":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╭":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╮":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╯":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╰":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╱":{type:2,data:"M1,0 L0,1",strokeWidth:1},"╲":{type:2,data:"M0,0 L1,1",strokeWidth:1},"╳":{type:2,data:"M1,0 L0,1 M0,0 L1,1",strokeWidth:1},"╴":{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},"╵":{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},"╶":{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},"╷":{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},"╸":{type:2,data:"M.5,.5 L0,.5",strokeWidth:3},"╹":{type:2,data:"M.5,.5 L.5,0",strokeWidth:3},"╺":{type:2,data:"M.5,.5 L1,.5",strokeWidth:3},"╻":{type:2,data:"M.5,.5 L.5,1",strokeWidth:3},"╼":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"╽":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╾":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"╿":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"▀":{type:0,data:[{x:0,y:0,w:8,h:4}]},"▁":{type:0,data:[{x:0,y:7,w:8,h:1}]},"▂":{type:0,data:[{x:0,y:6,w:8,h:2}]},"▃":{type:0,data:[{x:0,y:5,w:8,h:3}]},"▄":{type:0,data:[{x:0,y:4,w:8,h:4}]},"▅":{type:0,data:[{x:0,y:3,w:8,h:5}]},"▆":{type:0,data:[{x:0,y:2,w:8,h:6}]},"▇":{type:0,data:[{x:0,y:1,w:8,h:7}]},"█":{type:0,data:[{x:0,y:0,w:8,h:8}]},"▉":{type:0,data:[{x:0,y:0,w:7,h:8}]},"▊":{type:0,data:[{x:0,y:0,w:6,h:8}]},"▋":{type:0,data:[{x:0,y:0,w:5,h:8}]},"▌":{type:0,data:[{x:0,y:0,w:4,h:8}]},"▍":{type:0,data:[{x:0,y:0,w:3,h:8}]},"▎":{type:0,data:[{x:0,y:0,w:2,h:8}]},"▏":{type:0,data:[{x:0,y:0,w:1,h:8}]},"▐":{type:0,data:[{x:4,y:0,w:4,h:8}]},"░":{type:1,data:[[1,0],[0,0]]},"▒":{type:1,data:[[1,0],[0,1]]},"▓":{type:1,data:[[1,1],[1,0]]},"▔":{type:0,data:[{x:0,y:0,w:8,h:1}]},"▕":{type:0,data:[{x:7,y:0,w:1,h:8}]},"▖":{type:0,data:[{x:0,y:4,w:4,h:4}]},"▗":{type:0,data:[{x:4,y:4,w:4,h:4}]},"▘":{type:0,data:[{x:0,y:0,w:4,h:4}]},"▙":{type:0,data:[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"▚":{type:0,data:[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}]},"▛":{type:0,data:[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}]},"▜":{type:0,data:[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}]},"▝":{type:0,data:[{x:4,y:0,w:4,h:4}]},"▞":{type:0,data:[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}]},"▟":{type:0,data:[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"":{type:5,data:{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.7,.03 L.7,.1 L.355,.1 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2}},"":{type:5,data:{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2}},"":{type:5,data:{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1}},"":{type:5,data:{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1}},"":{type:5,data:{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0.8069,0.6075 Q0.7991,0.612,0.7815,0.6218 T0.7542,0.6369 T0.7282,0.6508 T0.7016,0.6644 T0.6778,0.6758 T0.6551,0.6854 T0.637,0.6911 T0.622,0.6936 Q0.6186,0.6936,0.6128,0.6942 T0.6018,0.6952 T0.5894,0.6956 T0.5757,0.6952 T0.561,0.693 T0.5451,0.6879 Q0.5342,0.6834,0.5193,0.6756 T0.4925,0.6614 T0.4673,0.6485 T0.4436,0.6389 T0.4239,0.6363 T0.4089,0.6422 Q0.4045,0.6467,0.3958,0.6554 T0.3843,0.6669 T0.3748,0.6746 T0.3613,0.683 T0.3442,0.6903 L0.3499,0.6956 Q0.3584,0.7042,0.3679,0.7177 T0.3836,0.7403 T0.4019,0.7583 T0.4295,0.7703 Q0.4688,0.7785,0.5203,0.7605 Q0.4902,0.7817,0.449,0.7911 T0.3696,0.8001 Q0.3567,0.7997,0.341,0.7942 T0.3111,0.7813 T0.2805,0.766 T0.2493,0.753 T0.218,0.7472 T0.187,0.754 Q0.1762,0.7589,0.1653,0.7681 T0.1453,0.7895 T0.1308,0.818 T0.1264,0.8507 L0.1264,0.858 Q0.1453,0.8462,0.1607,0.8433 T0.1899,0.8452 T0.2226,0.8625 Q0.2344,0.8707,0.2485,0.8752 T0.2813,0.8831 T0.3089,0.889 Q0.2981,0.8915,0.2846,0.8956 T0.2603,0.9037 T0.2368,0.9115 T0.2129,0.9174 T0.1894,0.9194 T0.1653,0.9155 Q0.1504,0.9115,0.1328,0.9196 T0.0986,0.9421 T0.0655,0.9708 T0.0317,0.9943 T0,1 Q0.001,0.94,0.0017,0.6508 T0.0024,0.2322 Q0.002,0.2109,0.0007,0.1379 T0,0.0249 Q0.0058,0.0253,0.009,0.0257 T0.0156,0.0288 T0.0203,0.0333 T0.0264,0.0422 T0.0349,0.0539 Q0.044,0.0657,0.0542,0.072 T0.0752,0.0789 T0.096,0.0775 T0.1175,0.0694 T0.1379,0.0573 T0.1579,0.0432 Q0.2141,0,0.2673,0.0318 Q0.2588,0.0318,0.2517,0.033 T0.239,0.0361 T0.2276,0.0424 T0.218,0.0504 T0.2085,0.0612 T0.1997,0.0732 T0.1899,0.0875 T0.1795,0.1028 Q0.1748,0.1093,0.1507,0.1234 T0.1186,0.1448 Q0.0999,0.1612,0.1108,0.1783 Q0.1162,0.1877,0.1238,0.1928 T0.1404,0.1979 T0.158,0.1967 T0.1775,0.1895 T0.1963,0.1791 T0.2151,0.1663 T0.2314,0.1534 T0.2458,0.141 T0.2561,0.1322 Q0.2815,0.1106,0.3017,0.101 T0.344,0.0926 T0.3919,0.1077 Q0.4099,0.1175,0.4265,0.1206 T0.4588,0.1202 T0.488,0.1098 T0.5176,0.0914 Q0.5071,0.1032,0.4963,0.1122 T0.4722,0.1285 T0.4497,0.1401 T0.4223,0.1518 T0.3943,0.1636 Q0.374,0.1726,0.3623,0.1863 T0.3482,0.2162 Q0.3445,0.2403,0.3608,0.2605 T0.4072,0.2876 Q0.4194,0.2909,0.4326,0.2899 T0.457,0.2856 T0.4805,0.2764 T0.5032,0.264 T0.5256,0.2497 T0.5478,0.2352 T0.5698,0.2222 T0.5921,0.2118 Q0.6982,0.173,0.81,0.2436 Q0.833,0.2583,0.8496,0.2674 T0.887,0.2846 T0.925,0.294 T0.9617,0.2911 T1,0.2746 Q0.9817,0.2946,0.96,0.3056 T0.9175,0.3191 T0.8731,0.3209 T0.8277,0.3164 T0.7818,0.3109 T0.7359,0.3101 T0.6907,0.3197 T0.647,0.3448 Q0.6443,0.3472,0.6333,0.3562 T0.6194,0.3674 T0.6076,0.3766 T0.594,0.386 T0.5815,0.3931 T0.5661,0.4007 T0.5501,0.4064 L0.5556,0.4121 Q0.5627,0.4198,0.5722,0.4251 T0.5926,0.4337 T0.6131,0.439 T0.6343,0.4431 T0.6521,0.4468 Q0.6762,0.4529,0.7056,0.4463 Q0.6772,0.4623,0.6543,0.471 T0.604,0.4814 Q0.5962,0.4818,0.5815,0.4825 T0.5591,0.4835 T0.5393,0.4857 T0.519,0.4908 T0.5007,0.4996 T0.4812,0.5141 T0.4627,0.5353 L0.4549,0.5451 L0.4661,0.543 Q0.4759,0.541,0.4909,0.55 T0.5315,0.5796 T0.5684,0.6083 Q0.5799,0.6161,0.5915,0.6212 T0.6181,0.6308 L0.6331,0.6353 Q0.6514,0.6418,0.7004,0.633 T0.8069,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.011,0.0469 Q0.0152,0.0412,0.02,0.0361 T0.0292,0.0281 T0.0365,0.0253 Q0.0426,0.0257,0.0461,0.0263 T0.0534,0.03 T0.0582,0.0345 T0.0645,0.0434 T0.0723,0.0546 Q0.0807,0.0653,0.0897,0.0712 T0.1081,0.0775 T0.1255,0.0765 T0.1438,0.0695 T0.1605,0.0593 T0.1772,0.0473 Q0.2388,0,0.2927,0.0326 L0.2614,0.0767 L0.2581,0.0767 Q0.2494,0.0767,0.2444,0.0773 T0.2359,0.0789 T0.2291,0.0842 T0.2233,0.0922 T0.2146,0.1054 T0.2026,0.1236 Q0.1943,0.1354,0.1843,0.1444 T0.1675,0.1574 T0.1526,0.1654 T0.1429,0.1701 Q0.1436,0.1717,0.1446,0.1733 Q0.1504,0.1823,0.1581,0.1866 T0.1733,0.1915 T0.1909,0.1884 T0.2085,0.1809 T0.2265,0.169 T0.2427,0.1564 T0.2575,0.1436 T0.2688,0.1338 Q0.2969,0.1101,0.3195,0.0995 T0.3643,0.0901 T0.4114,0.1048 Q0.4279,0.1138,0.4426,0.1168 T0.4705,0.117 T0.4945,0.1089 T0.5186,0.0942 L0.5211,0.0926 L0.5289,0.0922 Q0.5411,0.095,0.5189,0.1203 Q0.505,0.1358,0.4913,0.1474 T0.4634,0.167 T0.4389,0.1796 T0.4121,0.1909 T0.3866,0.2011 Q0.3782,0.2047,0.3727,0.2092 Q0.3717,0.2117,0.3714,0.2141 Q0.3695,0.2263,0.3751,0.2388 T0.394,0.2616 T0.4253,0.2761 Q0.4398,0.2785,0.4513,0.2779 T0.4756,0.2724 T0.4987,0.2616 T0.5216,0.2476 T0.5453,0.2321 T0.5703,0.217 T0.5976,0.2043 Q0.7015,0.166,0.8099,0.2345 Q0.8361,0.2512,0.8572,0.2616 T0.9006,0.2779 T0.9432,0.281 T0.9819,0.2663 L0.9887,0.2671 Q1,0.272,0.9768,0.2969 Q0.9558,0.3193,0.9319,0.333 T0.8858,0.3513 T0.8391,0.3569 T0.793,0.3546 T0.7485,0.3497 T0.7065,0.3473 T0.6681,0.3522 T0.6344,0.3699 Q0.5963,0.4005,0.5847,0.4082 Q0.595,0.4139,0.6079,0.4174 T0.6367,0.4237 T0.6586,0.4278 Q0.6793,0.4331,0.7044,0.4278 Q0.7057,0.4278,0.707,0.4274 Q0.7067,0.429,0.7062,0.4313 T0.7036,0.4398 T0.6993,0.4513 T0.6931,0.4619 T0.6851,0.4698 Q0.6573,0.4857,0.6336,0.4947 T0.5831,0.5053 Q0.577,0.5057,0.5615,0.5065 T0.5394,0.508 T0.5221,0.51 T0.5042,0.5139 T0.4905,0.5204 Q0.5008,0.5232,0.515,0.5328 T0.549,0.5585 T0.5799,0.5824 Q0.5905,0.5897,0.6013,0.5946 T0.6262,0.6036 T0.6409,0.6081 Q0.6567,0.6134,0.7035,0.605 T0.8028,0.5816 L0.7974,0.5922 T0.7867,0.6134 L0.7812,0.624 Q0.7799,0.6248,0.7786,0.6252 Q0.7709,0.6297,0.7573,0.6372 T0.7346,0.6499 T0.7123,0.6621 T0.6897,0.6741 T0.6686,0.6847 T0.648,0.6941 T0.6297,0.7013 T0.6129,0.7062 T0.5995,0.7076 Q0.5992,0.7076,0.5831,0.7092 T0.5529,0.7092 T0.525,0.7019 Q0.5105,0.6958,0.4824,0.6811 T0.4356,0.6586 T0.4079,0.6533 Q0.3872,0.6741,0.3827,0.6782 Q0.3872,0.6835,0.3934,0.6929 T0.4037,0.7078 T0.4142,0.7198 T0.4284,0.7304 T0.4466,0.7365 Q0.4824,0.7443,0.5292,0.728 L0.5292,0.7294 T0.529,0.7333 T0.5284,0.7392 T0.5266,0.7463 T0.5236,0.7539 T0.5186,0.7612 T0.5111,0.7679 Q0.5086,0.77,0.5056,0.7716 Q0.4466,0.8104,0.3591,0.8091 Q0.344,0.8091,0.3246,0.802 T0.2893,0.7863 T0.2543,0.77 T0.2206,0.76 T0.1894,0.7643 Q0.1804,0.7684,0.1733,0.7753 Q0.1591,0.7892,0.1601,0.8169 Q0.1784,0.8067,0.1938,0.8053 T0.2212,0.8087 T0.2507,0.825 Q0.2614,0.8324,0.2744,0.8365 T0.3053,0.844 T0.332,0.8499 L0.303,0.894 L0.2998,0.8948 Q0.2904,0.8968,0.278,0.9009 T0.2554,0.9086 T0.233,0.9158 T0.2099,0.9213 T0.1868,0.9229 T0.1633,0.9192 Q0.1517,0.916,0.1367,0.9241 T0.1065,0.9462 T0.0753,0.9737 T0.041,0.9955 T0.0061,1 Q0,0.9984,0.0068,0.9845 Q0.009,0.9804,0.0123,0.9755 Q0.0187,0.9666,0.0261,0.9606 T0.0374,0.9555 Q0.0481,0.958,0.0629,0.949 T0.0931,0.9262 T0.1247,0.8987 T0.1597,0.8777 T0.1949,0.8752 Q0.213,0.8805,0.2343,0.8772 Q0.2249,0.8736,0.2172,0.8683 Q0.1914,0.8511,0.1738,0.8497 T0.1349,0.8617 Q0.1304,0.865,0.1273,0.8646 T0.1242,0.8605 L0.1239,0.8536 Q0.1226,0.8295,0.1354,0.8016 T0.1723,0.7496 Q0.1914,0.7308,0.2104,0.7219 Q0.2259,0.7145,0.2425,0.7141 T0.273,0.7182 T0.3022,0.7296 T0.3301,0.7439 T0.3569,0.7571 T0.3821,0.7643 Q0.373,0.7561,0.3598,0.7367 T0.3382,0.7088 L0.3327,0.7035 Q0.3282,0.699,0.3353,0.6884 T0.3517,0.6692 L0.3611,0.6607 Q0.3711,0.657,0.3751,0.6554 T0.3837,0.6507 T0.3898,0.6458 T0.3979,0.637 T0.4111,0.6236 Q0.4172,0.6175,0.4234,0.6138 Q0.4327,0.6081,0.4439,0.6077 T0.4655,0.6105 T0.4884,0.6201 T0.5113,0.633 T0.5347,0.6468 T0.5573,0.6578 Q0.5705,0.6635,0.5833,0.665 T0.6112,0.665 T0.6286,0.6635 Q0.6421,0.6631,0.6718,0.6501 Q0.626,0.6578,0.6089,0.6517 Q0.6063,0.6509,0.6002,0.6491 T0.5884,0.6454 T0.5757,0.6409 T0.561,0.6344 T0.5466,0.6256 Q0.536,0.6183,0.5108,0.5989 T0.4722,0.5712 T0.4527,0.564 L0.4418,0.5661 Q0.4308,0.5681,0.4366,0.5563 Q0.4401,0.5485,0.4476,0.5392 L0.455,0.5298 Q0.4631,0.5188,0.4714,0.51 T0.4866,0.4947 T0.5021,0.4831 T0.516,0.4749 T0.53,0.4694 T0.5428,0.4657 T0.5558,0.4637 T0.5674,0.4629 T0.5795,0.4625 Q0.5489,0.4543,0.534,0.4384 L0.5286,0.4327 Q0.5244,0.4282,0.5318,0.4174 T0.5486,0.398 L0.5579,0.3899 Q0.567,0.387,0.5749,0.3834 T0.5878,0.3772 T0.6012,0.3687 T0.6126,0.3603 T0.6268,0.3487 T0.6421,0.3361 Q0.6567,0.3242,0.6712,0.3159 T0.7009,0.3034 T0.7277,0.2973 T0.7556,0.2961 T0.7809,0.2977 T0.8074,0.301 Q0.8096,0.3014,0.8109,0.3016 T0.8143,0.302 T0.818,0.3026 Q0.8012,0.2936,0.7767,0.2781 Q0.6718,0.2117,0.5744,0.2476 Q0.5637,0.2516,0.5492,0.2604 T0.5218,0.2779 T0.4923,0.2965 T0.461,0.3124 T0.4282,0.3216 T0.394,0.3206 Q0.3637,0.3136,0.3474,0.2936 T0.3353,0.2459 Q0.3385,0.2247,0.355,0.2023 Q0.3646,0.1892,0.3763,0.179 Q0.3898,0.1672,0.4063,0.1595 Q0.3927,0.1562,0.3785,0.1485 Q0.3604,0.1387,0.3453,0.1354 T0.3161,0.1354 T0.2899,0.1458 T0.2627,0.166 Q0.262,0.1664,0.254,0.1733 T0.2414,0.1841 T0.2267,0.196 T0.2094,0.2086 T0.1915,0.2196 T0.1725,0.2288 T0.1546,0.2337 T0.1373,0.2343 T0.1223,0.228 T0.1097,0.2145 Q0.0962,0.1929,0.1258,0.1582 Q0.131,0.1517,0.1371,0.1464 Q0.1462,0.1387,0.156,0.1321 T0.1752,0.1205 T0.1878,0.1134 Q0.1891,0.1117,0.1947,0.103 T0.2035,0.0899 T0.2125,0.0781 T0.2243,0.064 Q0.1949,0.0616,0.1672,0.0828 Q0.153,0.0934,0.1412,0.1009 T0.1146,0.1146 T0.0873,0.1213 T0.0616,0.116 T0.0374,0.0962 Q0.0339,0.0909,0.0295,0.0846 T0.024,0.0767 T0.0202,0.0728 T0.0148,0.0704 T0.0068,0.0697 Q0.0003,0.0693,0.0058,0.0567 Q0.0077,0.0522,0.011,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.1934,0.6075 Q0.2012,0.612,0.2188,0.6218 T0.2459,0.6369 T0.2718,0.6508 T0.2983,0.6644 T0.322,0.6758 T0.3447,0.6854 T0.363,0.6911 T0.3783,0.6936 Q0.3796,0.6936,0.396,0.6952 T0.4265,0.6952 T0.4548,0.6879 Q0.4656,0.6834,0.4805,0.6756 T0.5073,0.6614 T0.5327,0.6485 T0.5564,0.6389 T0.5759,0.6363 T0.5909,0.6422 Q0.5953,0.6467,0.604,0.6554 T0.6155,0.6669 T0.6251,0.6746 T0.6387,0.683 T0.6556,0.6903 L0.6498,0.6956 Q0.6414,0.7042,0.6319,0.7177 T0.6162,0.7403 T0.5979,0.7583 T0.5703,0.7703 Q0.5313,0.7785,0.4799,0.7605 Q0.5097,0.7817,0.5508,0.7911 T0.6302,0.8001 Q0.6431,0.7997,0.659,0.7942 T0.6888,0.7813 T0.7194,0.766 T0.7506,0.753 T0.7819,0.7472 T0.8131,0.754 Q0.8239,0.7589,0.8346,0.7681 T0.8544,0.7895 T0.8689,0.818 T0.8737,0.8507 L0.8733,0.858 Q0.8591,0.849,0.8474,0.845 T0.8242,0.8421 T0.8021,0.8482 T0.7772,0.8625 Q0.7653,0.8707,0.7513,0.8752 T0.7184,0.8831 T0.6908,0.889 Q0.7017,0.8915,0.7152,0.8956 T0.7396,0.9037 T0.7633,0.9115 T0.7872,0.9174 T0.8107,0.9194 T0.8347,0.9155 Q0.8493,0.9115,0.8671,0.9196 T0.9015,0.9421 T0.9345,0.9708 T0.9682,0.9943 T0.9997,1 Q0.999,0.94,0.9983,0.6508 T0.9976,0.2322 Q0.9976,0.2109,0.9992,0.1379 T1,0.0249 Q0.9949,0.0249,0.9917,0.0257 T0.9863,0.0273 T0.9817,0.0308 T0.9776,0.0357 T0.9721,0.0437 T0.9651,0.0539 Q0.956,0.0657,0.9456,0.072 T0.9247,0.0789 T0.904,0.0775 T0.8823,0.0694 T0.862,0.0573 T0.8422,0.0432 Q0.7856,0,0.7328,0.0318 Q0.7392,0.0318,0.7452,0.0324 T0.756,0.0345 T0.7657,0.0386 T0.7741,0.0437 T0.7821,0.0506 T0.7894,0.0588 T0.7966,0.0683 T0.8039,0.0787 T0.8119,0.0904 T0.8202,0.1028 Q0.8249,0.1093,0.849,0.1234 T0.8811,0.1448 Q0.8998,0.1612,0.8893,0.1783 Q0.8835,0.1877,0.8759,0.1928 T0.8593,0.1979 T0.8417,0.1967 T0.8222,0.1895 T0.8034,0.1791 T0.7848,0.1663 T0.7687,0.1534 T0.7543,0.141 T0.744,0.1322 Q0.7186,0.1106,0.6984,0.101 T0.6559,0.0926 T0.6082,0.1077 Q0.5899,0.1175,0.5733,0.1206 T0.5411,0.1202 T0.5122,0.1098 T0.4822,0.0914 Q0.4927,0.1032,0.5036,0.1122 T0.5276,0.1285 T0.5503,0.1401 T0.5777,0.1518 T0.6055,0.1636 Q0.6258,0.1726,0.6375,0.1863 T0.6519,0.2162 Q0.6556,0.2403,0.6392,0.2605 T0.5926,0.2876 Q0.5804,0.2909,0.5672,0.2899 T0.5428,0.2856 T0.5193,0.2764 T0.4966,0.264 T0.4744,0.2497 T0.4523,0.2352 T0.4301,0.2222 T0.4077,0.2118 Q0.3021,0.173,0.1903,0.2436 Q0.1669,0.2583,0.1504,0.2674 T0.1129,0.2846 T0.075,0.294 T0.0384,0.2911 T0,0.2746 Q0.021,0.297,0.0459,0.3082 T0.0953,0.3207 T0.146,0.3193 T0.1988,0.3131 T0.2508,0.3095 T0.3029,0.3176 T0.3529,0.3448 Q0.3566,0.348,0.3652,0.355 T0.3771,0.3645 T0.3877,0.3731 T0.3993,0.3815 T0.4103,0.3884 T0.4226,0.3953 T0.4352,0.4009 T0.4497,0.4064 L0.4443,0.4121 Q0.4372,0.4198,0.4277,0.4251 T0.4072,0.4337 T0.3867,0.439 T0.3656,0.4431 T0.3481,0.4468 Q0.3241,0.4529,0.2943,0.4463 Q0.3227,0.4623,0.3458,0.471 T0.3959,0.4814 Q0.404,0.4818,0.4187,0.4825 T0.4409,0.4835 T0.4605,0.4857 T0.4809,0.4908 T0.4992,0.4996 T0.5186,0.5141 T0.5371,0.5353 L0.5449,0.5451 L0.5337,0.543 Q0.5242,0.541,0.5091,0.55 T0.4683,0.5796 T0.4314,0.6083 Q0.4203,0.6161,0.4086,0.6212 T0.382,0.6308 T0.3667,0.6353 Q0.3485,0.6418,0.2995,0.633 T0.1934,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.989,0.0469 Q0.9829,0.0379,0.9753,0.0316 T0.9635,0.0253 Q0.9574,0.0257,0.9539,0.0263 T0.9466,0.03 T0.9418,0.0345 T0.9355,0.0434 T0.9277,0.0546 Q0.9193,0.0653,0.9103,0.0712 T0.8919,0.0775 T0.8745,0.0765 T0.8564,0.0695 T0.8396,0.0593 T0.8228,0.0473 Q0.7612,0,0.7073,0.0326 L0.7386,0.0767 L0.7419,0.0767 Q0.7506,0.0767,0.7556,0.0773 T0.7641,0.0789 T0.7709,0.0842 T0.7767,0.0922 T0.7854,0.1054 T0.7974,0.1236 Q0.8057,0.1354,0.8157,0.1444 T0.8325,0.1574 T0.8474,0.1654 T0.8571,0.1701 Q0.8564,0.1717,0.8554,0.1733 Q0.8503,0.1815,0.844,0.186 T0.8301,0.1909 T0.8153,0.1903 T0.7993,0.1845 T0.7836,0.1758 T0.768,0.1648 T0.754,0.1535 T0.741,0.1425 T0.7312,0.1338 Q0.7031,0.1101,0.6805,0.0995 T0.6357,0.0901 T0.5886,0.1048 Q0.5721,0.1138,0.5574,0.1168 T0.5295,0.117 T0.5055,0.1089 T0.4814,0.0942 L0.4789,0.0926 L0.4711,0.0922 Q0.4589,0.095,0.4811,0.1203 Q0.495,0.1358,0.5087,0.1474 T0.5366,0.167 T0.5611,0.1796 T0.5879,0.1909 T0.6134,0.2011 Q0.6218,0.2047,0.6273,0.2092 Q0.6283,0.2117,0.6286,0.2141 Q0.6305,0.2263,0.6249,0.2388 T0.606,0.2616 T0.5747,0.2761 Q0.5602,0.2785,0.5487,0.2779 T0.5245,0.2724 T0.5015,0.2616 T0.4784,0.2476 T0.4547,0.2321 T0.4297,0.217 T0.4024,0.2043 Q0.2985,0.166,0.1901,0.2345 Q0.1694,0.248,0.1523,0.2569 T0.1165,0.2726 T0.0818,0.2812 T0.0494,0.2796 T0.0181,0.2663 L0.0116,0.2671 Q0,0.272,0.0232,0.2969 Q0.0468,0.3222,0.0742,0.3365 T0.1278,0.3542 T0.1807,0.3564 T0.233,0.352 T0.2815,0.3473 T0.3269,0.3509 T0.3656,0.3699 Q0.4037,0.4005,0.4153,0.4082 Q0.405,0.4139,0.3921,0.4174 T0.3633,0.4237 T0.3414,0.4278 Q0.3207,0.4331,0.2956,0.4278 Q0.2943,0.4278,0.293,0.4274 Q0.2933,0.429,0.2938,0.4313 T0.2964,0.4398 T0.3007,0.4513 T0.3069,0.4619 T0.3149,0.4698 Q0.3427,0.4857,0.3664,0.4947 T0.4169,0.5053 Q0.423,0.5057,0.4385,0.5065 T0.4606,0.508 T0.4779,0.51 T0.4958,0.5139 T0.5095,0.5204 Q0.4992,0.5232,0.485,0.5328 T0.451,0.5585 T0.4201,0.5824 Q0.4095,0.5897,0.3987,0.5946 T0.3738,0.6036 T0.3591,0.6081 Q0.3433,0.6134,0.2965,0.605 T0.1972,0.5816 L0.2026,0.5922 T0.2133,0.6134 L0.2188,0.624 Q0.2201,0.6248,0.2214,0.6252 Q0.2291,0.6297,0.2486,0.6405 T0.2786,0.657 T0.3066,0.6721 T0.3353,0.6866 T0.3598,0.6972 T0.383,0.7051 T0.4005,0.7076 Q0.4008,0.7076,0.4169,0.7092 T0.4471,0.7092 T0.475,0.7019 Q0.4895,0.6958,0.5176,0.6811 T0.5644,0.6586 T0.5921,0.6533 Q0.6128,0.6741,0.6173,0.6782 Q0.6131,0.6835,0.6068,0.6929 T0.5963,0.7078 T0.5858,0.7198 T0.5716,0.7304 T0.5534,0.7365 Q0.5179,0.7443,0.4708,0.728 L0.4708,0.7294 T0.471,0.7333 T0.4716,0.7392 T0.4734,0.7463 T0.4764,0.7539 T0.4814,0.7612 T0.4889,0.7679 Q0.4914,0.77,0.4944,0.7716 Q0.5534,0.8104,0.6409,0.8091 Q0.6521,0.8091,0.6654,0.8053 T0.6907,0.7959 T0.7157,0.7838 T0.741,0.772 T0.7652,0.7631 T0.7888,0.7594 T0.8106,0.7643 Q0.8196,0.7684,0.8267,0.7753 Q0.8409,0.7892,0.8399,0.8169 Q0.8216,0.8067,0.8062,0.8053 T0.7788,0.8087 T0.7493,0.825 Q0.7386,0.8324,0.7256,0.8365 T0.6947,0.844 T0.668,0.8499 L0.697,0.894 L0.7002,0.8948 Q0.7099,0.8968,0.7222,0.9009 T0.7446,0.9086 T0.767,0.9158 T0.7901,0.9213 T0.8132,0.9229 T0.8367,0.9192 Q0.8483,0.916,0.8633,0.9241 T0.8937,0.9462 T0.9248,0.9737 T0.959,0.9955 T0.9939,1 Q1,0.9984,0.9932,0.9845 Q0.991,0.9804,0.9877,0.9755 Q0.9813,0.9666,0.9739,0.9606 T0.9626,0.9555 Q0.9519,0.958,0.9372,0.949 T0.9071,0.9262 T0.8753,0.8987 T0.8403,0.8777 T0.8051,0.8752 Q0.787,0.8805,0.7657,0.8772 Q0.7751,0.8736,0.7828,0.8683 Q0.8086,0.8511,0.8262,0.8497 T0.8651,0.8617 Q0.8696,0.865,0.8727,0.8646 T0.8758,0.8605 L0.8761,0.8536 Q0.8774,0.8295,0.8646,0.8016 T0.8277,0.7496 Q0.8086,0.7308,0.7896,0.7219 Q0.7741,0.7145,0.7575,0.7141 T0.727,0.7182 T0.6978,0.7296 T0.6699,0.7439 T0.6433,0.7571 T0.6179,0.7643 Q0.627,0.7561,0.6402,0.7367 T0.6618,0.7088 L0.6673,0.7035 Q0.6718,0.699,0.6647,0.6884 T0.6483,0.6692 L0.6389,0.6607 Q0.6289,0.657,0.6249,0.6554 T0.6163,0.6507 T0.6102,0.6458 T0.6021,0.637 T0.5889,0.6236 Q0.5828,0.6175,0.5766,0.6138 Q0.5673,0.6081,0.5561,0.6077 T0.5345,0.6105 T0.5116,0.6201 T0.4887,0.633 T0.4653,0.6468 T0.4427,0.6578 Q0.4295,0.6635,0.4167,0.665 T0.3888,0.665 T0.3714,0.6635 Q0.3579,0.6631,0.3282,0.6501 Q0.374,0.6578,0.3911,0.6517 Q0.3937,0.6509,0.4024,0.6482 T0.4179,0.6434 T0.4348,0.6364 T0.4534,0.6256 Q0.464,0.6183,0.4892,0.5989 T0.5278,0.5712 T0.5476,0.564 L0.5582,0.5661 Q0.5692,0.5681,0.5634,0.5563 Q0.5599,0.5485,0.5524,0.5392 L0.545,0.5298 Q0.5369,0.5188,0.5286,0.51 T0.5134,0.4947 T0.4979,0.4831 T0.484,0.4749 T0.47,0.4694 T0.4572,0.4657 T0.4442,0.4637 T0.4326,0.4629 T0.4205,0.4625 Q0.4511,0.4543,0.466,0.4384 L0.4714,0.4327 Q0.4795,0.4237,0.4469,0.394 L0.4421,0.3899 Q0.433,0.387,0.4251,0.3834 T0.4122,0.3772 T0.3988,0.3687 T0.3874,0.3603 T0.3732,0.3487 T0.3579,0.3361 Q0.3433,0.3242,0.3288,0.3159 T0.2993,0.3034 T0.2725,0.2973 T0.2446,0.2961 T0.2193,0.2977 T0.1926,0.301 Q0.1855,0.3022,0.182,0.3026 Q0.1991,0.2936,0.2233,0.2781 Q0.3282,0.2117,0.4256,0.2476 Q0.4363,0.2516,0.451,0.2604 T0.4784,0.2779 T0.5077,0.2965 T0.539,0.3124 T0.5718,0.3216 T0.606,0.3206 Q0.6363,0.3136,0.6526,0.2936 T0.6647,0.2459 Q0.6615,0.2247,0.645,0.2023 Q0.6354,0.1892,0.6237,0.179 Q0.6102,0.1672,0.5937,0.1595 Q0.6073,0.1562,0.6215,0.1485 Q0.6396,0.1387,0.6547,0.1354 T0.6839,0.1354 T0.7101,0.1458 T0.7373,0.166 Q0.738,0.1664,0.746,0.1733 T0.7586,0.1841 T0.7733,0.196 T0.7907,0.2086 T0.8086,0.2196 T0.8275,0.2288 T0.8454,0.2337 T0.8627,0.2343 T0.8777,0.228 T0.8903,0.2145 Q0.9038,0.1929,0.8742,0.1582 Q0.869,0.1517,0.8629,0.1464 Q0.8538,0.1387,0.844,0.1321 T0.8248,0.1205 T0.8122,0.1134 Q0.8109,0.1117,0.8053,0.103 T0.7965,0.0899 T0.7875,0.0781 T0.7757,0.064 Q0.8051,0.0616,0.8328,0.0828 Q0.847,0.0934,0.8588,0.1009 T0.8854,0.1146 T0.9127,0.1213 T0.9384,0.116 T0.9626,0.0962 Q0.9664,0.0909,0.9706,0.0846 T0.976,0.0767 T0.9798,0.0728 T0.9852,0.0704 T0.9932,0.0697 Q0.9997,0.0693,0.9942,0.0567 Q0.9923,0.0522,0.989,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0.9099,0.1158 L0.9099,0.1888 L0.9951,0.1888 L0.9951,0.1158 L0.9099,0.1158 Z M0.9075,0.1116 L0.9976,0.1116 Q1,0.1116,1,0.1137 L1,0.1909 Q1,0.193,0.9976,0.193 L0.9075,0.193 Q0.905,0.193,0.905,0.1909 L0.905,0.1137 Q0.905,0.1116,0.9075,0.1116 Z M0.7852,0.6086 L0.7852,0.682 L0.8704,0.682 L0.8704,0.6086 L0.7852,0.6086 Z M0.7828,0.6044 L0.8729,0.6044 Q0.8753,0.6044,0.8753,0.6065 L0.8753,0.6841 Q0.8753,0.6862,0.8729,0.6862 L0.7828,0.6862 Q0.7803,0.6862,0.7803,0.6841 L0.7803,0.6065 Q0.7803,0.6044,0.7828,0.6044 Z M0.66,0.1137 L0.7501,0.1137 L0.7501,0.1909 L0.66,0.1909 L0.66,0.1137 Z M0.6624,0.4102 L0.6624,0.4836 L0.7477,0.4836 L0.7477,0.4102 L0.6624,0.4102 Z M0.66,0.406 L0.7501,0.406 Q0.7526,0.406,0.7526,0.4081 L0.7526,0.4857 Q0.7526,0.4878,0.7501,0.4878 L0.66,0.4878 Q0.6576,0.4878,0.6576,0.4857 L0.6576,0.4081 Q0.6576,0.406,0.66,0.406 Z M0.6624,0.7131 L0.6624,0.7865 L0.7477,0.7865 L0.7477,0.7131 L0.6624,0.7131 Z M0.66,0.7089 L0.7501,0.7089 Q0.7526,0.7089,0.7526,0.711 L0.7526,0.7886 Q0.7526,0.7907,0.7501,0.7907 L0.66,0.7907 Q0.6576,0.7907,0.6576,0.7886 L0.6576,0.711 Q0.6576,0.7089,0.66,0.7089 Z M0.5407,0.2227 L0.5407,0.2836 L0.6113,0.2836 L0.6113,0.2227 L0.5407,0.2227 Z M0.5309,0.206 L0.621,0.206 Q0.623,0.206,0.6249,0.2068 T0.6281,0.2089 T0.6301,0.2116 T0.6308,0.2143 L0.6308,0.2919 Q0.6308,0.2957,0.6276,0.298 T0.621,0.3003 L0.5309,0.3003 Q0.5265,0.3003,0.5239,0.2976 T0.5212,0.2919 L0.5212,0.2143 Q0.5212,0.211,0.5244,0.2085 T0.5309,0.206 Z M0.5407,0.3184 L0.5407,0.3792 L0.6113,0.3792 L0.6113,0.3184 L0.5407,0.3184 Z M0.5309,0.3016 L0.621,0.3016 Q0.6254,0.3016,0.6281,0.3043 T0.6308,0.31 L0.6308,0.3876 Q0.6308,0.3914,0.6276,0.3937 T0.621,0.396 L0.5309,0.396 Q0.5265,0.396,0.5239,0.3932 T0.5212,0.3876 L0.5212,0.31 Q0.5212,0.3062,0.5244,0.3039 T0.5309,0.3016 Z M0.5309,0.4081 L0.621,0.4081 L0.621,0.4857 L0.5309,0.4857 L0.5309,0.4081 Z M0.5309,0.5059 L0.621,0.5059 L0.621,0.5835 L0.5309,0.5835 L0.5309,0.5059 Z M0.5407,0.6149 L0.5407,0.6758 L0.6113,0.6758 L0.6113,0.6149 L0.5407,0.6149 Z M0.5309,0.5982 L0.621,0.5982 Q0.6254,0.5982,0.6281,0.6009 T0.6308,0.6065 L0.6308,0.6841 Q0.6308,0.6879,0.6276,0.6902 T0.621,0.6925 L0.5309,0.6925 Q0.5265,0.6925,0.5239,0.6898 T0.5212,0.6841 L0.5212,0.6065 Q0.5212,0.6028,0.5244,0.6005 T0.5309,0.5982 Z M0.4062,0.1137 L0.4963,0.1137 L0.4963,0.1909 L0.4062,0.1909 L0.4062,0.1137 Z M0.4062,0.2143 L0.4963,0.2143 L0.4963,0.2919 L0.4062,0.2919 L0.4062,0.2143 Z M0.4184,0.4186 L0.4184,0.4753 L0.4842,0.4753 L0.4842,0.4186 L0.4184,0.4186 Z M0.4062,0.3977 L0.4963,0.3977 Q0.5017,0.3977,0.5051,0.401 T0.5085,0.4081 L0.5085,0.4857 Q0.5085,0.4904,0.5046,0.4933 T0.4963,0.4962 L0.4062,0.4962 Q0.4009,0.4962,0.3975,0.4929 T0.3941,0.4857 L0.3941,0.4081 Q0.3941,0.4035,0.398,0.4006 T0.4062,0.3977 Z M0.4062,0.5059 L0.4963,0.5059 L0.4963,0.5835 L0.4062,0.5835 L0.4062,0.5059 Z M0.4087,0.7131 L0.4087,0.7865 L0.4939,0.7865 L0.4939,0.7131 L0.4087,0.7131 Z M0.4062,0.7089 L0.4963,0.7089 Q0.4988,0.7089,0.4988,0.711 L0.4988,0.7886 Q0.4988,0.7907,0.4963,0.7907 L0.4062,0.7907 Q0.4038,0.7907,0.4038,0.7886 L0.4038,0.711 Q0.4038,0.7089,0.4062,0.7089 Z M0.2689,0.1137 L0.359,0.1137 L0.359,0.1909 L0.2689,0.1909 L0.2689,0.1137 Z M0.2689,0.2143 L0.359,0.2143 L0.359,0.2919 L0.2689,0.2919 L0.2689,0.2143 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.31 L0.359,0.31 L0.359,0.3876 L0.2689,0.3876 L0.2689,0.31 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.4081 L0.359,0.4081 L0.359,0.4857 L0.2689,0.4857 L0.2689,0.4081 Z M0.2689,0.5059 L0.359,0.5059 L0.359,0.5835 L0.2689,0.5835 L0.2689,0.5059 Z M0.2689,0.711 L0.359,0.711 L0.359,0.7886 L0.2689,0.7886 L0.2689,0.711 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.1374,0.1137 L0.2275,0.1137 L0.2275,0.1909 L0.1374,0.1909 L0.1374,0.1137 Z M0.1374,0.2143 L0.2275,0.2143 L0.2275,0.2919 L0.1374,0.2919 L0.1374,0.2143 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.31 L0.2275,0.31 L0.2275,0.3876 L0.1374,0.3876 L0.1374,0.31 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.4081 L0.2275,0.4081 L0.2275,0.4857 L0.1374,0.4857 L0.1374,0.4081 Z M0.1374,0.5059 L0.2275,0.5059 L0.2275,0.5835 L0.1374,0.5835 L0.1374,0.5059 Z M0.1374,0.6065 L0.2275,0.6065 L0.2275,0.6841 L0.1374,0.6841 L0.1374,0.6065 Z M0.1374,0.711 L0.2275,0.711 L0.2275,0.7886 L0.1374,0.7886 L0.1374,0.711 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0,0.1137 L0.0901,0.1137 L0.0901,0.1909 L0,0.1909 L0,0.1137 Z M0,0.2143 L0.0901,0.2143 L0.0901,0.2919 L0,0.2919 L0,0.2143 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.31 L0.0901,0.31 L0.0901,0.3876 L0,0.3876 L0,0.31 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.4081 L0.0901,0.4081 L0.0901,0.4857 L0,0.4857 L0,0.4081 Z M0,0.5059 L0.0901,0.5059 L0.0901,0.5835 L0,0.5835 L0,0.5059 Z M0,0.6065 L0.0901,0.6065 L0.0901,0.6841 L0,0.6841 L0,0.6065 Z M0,0.711 L0.0901,0.711 L0.0901,0.7886 L0,0.7886 L0,0.711 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M0.0901,0.1158 L0.0901,0.1888 L0.0049,0.1888 L0.0049,0.1158 L0.0901,0.1158 Z M0.0925,0.1116 L0.0024,0.1116 Q0,0.1116,0,0.1137 L0,0.1909 Q0,0.193,0.0024,0.193 L0.0925,0.193 Q0.095,0.193,0.095,0.1909 L0.095,0.1137 Q0.095,0.1116,0.0925,0.1116 Z M0.2148,0.6086 L0.2148,0.682 L0.1296,0.682 L0.1296,0.6086 L0.2148,0.6086 Z M0.2172,0.6044 L0.1271,0.6044 Q0.1247,0.6044,0.1247,0.6065 L0.1247,0.6841 Q0.1247,0.6862,0.1271,0.6862 L0.2172,0.6862 Q0.2197,0.6862,0.2197,0.6841 L0.2197,0.6065 Q0.2197,0.6044,0.2172,0.6044 Z M0.34,0.1137 L0.2499,0.1137 L0.2499,0.1909 L0.34,0.1909 L0.34,0.1137 Z M0.3376,0.4102 L0.3376,0.4836 L0.2523,0.4836 L0.2523,0.4102 L0.3376,0.4102 Z M0.34,0.406 L0.2499,0.406 Q0.2474,0.406,0.2474,0.4081 L0.2474,0.4857 Q0.2474,0.4878,0.2499,0.4878 L0.34,0.4878 Q0.3424,0.4878,0.3424,0.4857 L0.3424,0.4081 Q0.3424,0.406,0.34,0.406 Z M0.3376,0.7131 L0.3376,0.7865 L0.2523,0.7865 L0.2523,0.7131 L0.3376,0.7131 Z M0.34,0.7089 L0.2499,0.7089 Q0.2474,0.7089,0.2474,0.711 L0.2474,0.7886 Q0.2474,0.7907,0.2499,0.7907 L0.34,0.7907 Q0.3424,0.7907,0.3424,0.7886 L0.3424,0.711 Q0.3424,0.7089,0.34,0.7089 Z M0.4593,0.2227 L0.4593,0.2836 L0.3887,0.2836 L0.3887,0.2227 L0.4593,0.2227 Z M0.4691,0.206 L0.379,0.206 Q0.3746,0.206,0.3719,0.2087 T0.3692,0.2143 L0.3692,0.2919 Q0.3692,0.2957,0.3724,0.298 T0.379,0.3003 L0.4691,0.3003 Q0.4735,0.3003,0.4761,0.2976 T0.4788,0.2919 L0.4788,0.2143 Q0.4788,0.211,0.4756,0.2085 T0.4691,0.206 Z M0.4593,0.3184 L0.4593,0.3792 L0.3887,0.3792 L0.3887,0.3184 L0.4593,0.3184 Z M0.4691,0.3016 L0.379,0.3016 Q0.3746,0.3016,0.3719,0.3043 T0.3692,0.31 L0.3692,0.3876 Q0.3692,0.3914,0.3724,0.3937 T0.379,0.396 L0.4691,0.396 Q0.4735,0.396,0.4761,0.3932 T0.4788,0.3876 L0.4788,0.31 Q0.4788,0.3062,0.4756,0.3039 T0.4691,0.3016 Z M0.4691,0.4081 L0.379,0.4081 L0.379,0.4857 L0.4691,0.4857 L0.4691,0.4081 Z M0.4691,0.5059 L0.379,0.5059 L0.379,0.5835 L0.4691,0.5835 L0.4691,0.5059 Z M0.4593,0.6149 L0.4593,0.6758 L0.3887,0.6758 L0.3887,0.6149 L0.4593,0.6149 Z M0.4691,0.5982 L0.379,0.5982 Q0.3746,0.5982,0.3719,0.6009 T0.3692,0.6065 L0.3692,0.6841 Q0.3692,0.6879,0.3724,0.6902 T0.379,0.6925 L0.4691,0.6925 Q0.4735,0.6925,0.4761,0.6898 T0.4788,0.6841 L0.4788,0.6065 Q0.4788,0.6028,0.4756,0.6005 T0.4691,0.5982 Z M0.5938,0.1137 L0.5037,0.1137 L0.5037,0.1909 L0.5938,0.1909 L0.5938,0.1137 Z M0.5938,0.2143 L0.5037,0.2143 L0.5037,0.2919 L0.5938,0.2919 L0.5938,0.2143 Z M0.5816,0.4186 L0.5816,0.4753 L0.5158,0.4753 L0.5158,0.4186 L0.5816,0.4186 Z M0.5938,0.3977 L0.5037,0.3977 Q0.4983,0.3977,0.4949,0.401 T0.4915,0.4081 L0.4915,0.4857 Q0.4915,0.4904,0.4954,0.4933 T0.5037,0.4962 L0.5938,0.4962 Q0.5991,0.4962,0.6025,0.4929 T0.6059,0.4857 L0.6059,0.4081 Q0.6059,0.4035,0.602,0.4006 T0.5938,0.3977 Z M0.5938,0.5059 L0.5037,0.5059 L0.5037,0.5835 L0.5938,0.5835 L0.5938,0.5059 Z M0.5913,0.7131 L0.5913,0.7865 L0.5061,0.7865 L0.5061,0.7131 L0.5913,0.7131 Z M0.5938,0.7089 L0.5037,0.7089 Q0.5012,0.7089,0.5012,0.711 L0.5012,0.7886 Q0.5012,0.7907,0.5037,0.7907 L0.5938,0.7907 Q0.5962,0.7907,0.5962,0.7886 L0.5962,0.711 Q0.5962,0.7089,0.5938,0.7089 Z M0.7311,0.1137 L0.641,0.1137 L0.641,0.1909 L0.7311,0.1909 L0.7311,0.1137 Z M0.7311,0.2143 L0.641,0.2143 L0.641,0.2919 L0.7311,0.2919 L0.7311,0.2143 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.31 L0.641,0.31 L0.641,0.3876 L0.7311,0.3876 L0.7311,0.31 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.4081 L0.641,0.4081 L0.641,0.4857 L0.7311,0.4857 L0.7311,0.4081 Z M0.7311,0.5059 L0.641,0.5059 L0.641,0.5835 L0.7311,0.5835 L0.7311,0.5059 Z M0.7311,0.711 L0.641,0.711 L0.641,0.7886 L0.7311,0.7886 L0.7311,0.711 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.8626,0.1137 L0.7725,0.1137 L0.7725,0.1909 L0.8626,0.1909 L0.8626,0.1137 Z M0.8626,0.2143 L0.7725,0.2143 L0.7725,0.2919 L0.8626,0.2919 L0.8626,0.2143 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.31 L0.7725,0.31 L0.7725,0.3876 L0.8626,0.3876 L0.8626,0.31 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.4081 L0.7725,0.4081 L0.7725,0.4857 L0.8626,0.4857 L0.8626,0.4081 Z M0.8626,0.5059 L0.7725,0.5059 L0.7725,0.5835 L0.8626,0.5835 L0.8626,0.5059 Z M0.8626,0.6065 L0.7725,0.6065 L0.7725,0.6841 L0.8626,0.6841 L0.8626,0.6065 Z M0.8626,0.711 L0.7725,0.711 L0.7725,0.7886 L0.8626,0.7886 L0.8626,0.711 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M1,0.1137 L0.9099,0.1137 L0.9099,0.1909 L1,0.1909 L1,0.1137 Z M1,0.2143 L0.9099,0.2143 L0.9099,0.2919 L1,0.2919 L1,0.2143 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.31 L0.9099,0.31 L0.9099,0.3876 L1,0.3876 L1,0.31 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.4081 L0.9099,0.4081 L0.9099,0.4857 L1,0.4857 L1,0.4081 Z M1,0.5059 L0.9099,0.5059 L0.9099,0.5835 L1,0.5835 L1,0.5059 Z M1,0.6065 L0.9099,0.6065 L0.9099,0.6841 L1,0.6841 L1,0.6065 Z M1,0.711 L0.9099,0.711 L0.9099,0.7886 L1,0.7886 L1,0.711 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0.8574,0.3217 L0.8574,0.4098 L0.9691,0.4098 L0.9691,0.3217 L0.8574,0.3217 Z M0.8419,0.2978 L0.9846,0.2978 Q0.9892,0.2978,0.9928,0.2997 T0.9982,0.3043 T1,0.31 L1,0.4216 Q1,0.427,0.9951,0.4304 T0.9846,0.4337 L0.8419,0.4337 Q0.8352,0.4337,0.8308,0.4299 T0.8265,0.4216 L0.8265,0.31 Q0.8265,0.3062,0.829,0.3035 T0.835,0.2993 T0.8419,0.2978 Z M0.8574,0.888 L0.8574,0.9757 L0.9691,0.9757 L0.9691,0.888 L0.8574,0.888 Z M0.8419,0.8637 L0.9846,0.8637 Q0.9892,0.8637,0.9928,0.8658 T0.9982,0.8706 T1,0.8758 L1,0.9878 Q1,0.9929,0.9951,0.9964 T0.9846,1 L0.8419,1 Q0.8352,1,0.8308,0.996 T0.8265,0.9878 L0.8265,0.8758 Q0.8265,0.8708,0.8314,0.8672 T0.8419,0.8637 Z M0.6509,0.169 L0.6509,0.2706 L0.7806,0.2706 L0.7806,0.169 L0.6509,0.169 Z M0.6442,0.159 L0.7868,0.159 Q0.7899,0.159,0.7917,0.1604 T0.7935,0.164 L0.7935,0.2756 Q0.7935,0.2781,0.7915,0.2796 T0.7868,0.281 L0.6442,0.281 Q0.6416,0.281,0.6395,0.2794 T0.6375,0.2756 L0.6375,0.164 Q0.6375,0.1619,0.6398,0.1604 T0.6442,0.159 Z M0.6632,0.6044 L0.6632,0.6858 L0.7678,0.6858 L0.7678,0.6044 L0.6632,0.6044 Z M0.6442,0.5742 L0.7868,0.5742 Q0.7951,0.5742,0.8007,0.5791 T0.8064,0.5893 L0.8064,0.7013 Q0.8064,0.7076,0.8002,0.712 T0.7868,0.7164 L0.6442,0.7164 Q0.6359,0.7164,0.6305,0.7114 T0.6251,0.7013 L0.6251,0.5893 Q0.6251,0.5847,0.6282,0.5812 T0.6357,0.5759 T0.6442,0.5742 Z M0.4264,0.164 L0.5695,0.164 L0.5695,0.2756 L0.4264,0.2756 L0.4264,0.164 Z M0.4325,0.315 L0.4325,0.4165 L0.5628,0.4165 L0.5628,0.315 L0.4325,0.315 Z M0.4264,0.3049 L0.5695,0.3049 Q0.5721,0.3049,0.5739,0.3064 T0.5757,0.31 L0.5757,0.4216 Q0.5757,0.4237,0.5736,0.4251 T0.5695,0.4266 L0.4264,0.4266 Q0.4238,0.4266,0.422,0.4251 T0.4202,0.4216 L0.4202,0.31 Q0.4202,0.3087,0.4207,0.3077 T0.4222,0.306 T0.4243,0.3052 T0.4264,0.3049 Z M0.4264,0.4476 L0.5695,0.4476 L0.5695,0.5596 L0.4264,0.5596 L0.4264,0.4476 Z M0.4392,0.7408 L0.4392,0.8326 L0.5561,0.8326 L0.5561,0.7408 L0.4392,0.7408 Z M0.4264,0.7206 L0.5695,0.7206 Q0.5747,0.7206,0.5783,0.724 T0.5819,0.7307 L0.5819,0.8427 Q0.5819,0.8469,0.5778,0.8498 T0.5695,0.8528 L0.4264,0.8528 Q0.4207,0.8528,0.4171,0.8496 T0.4135,0.8427 L0.4135,0.7307 Q0.4135,0.7265,0.4176,0.7236 T0.4264,0.7206 Z M0.2178,0.164 L0.3605,0.164 L0.3605,0.2756 L0.2178,0.2756 L0.2178,0.164 Z M0.2178,0.31 L0.3605,0.31 L0.3605,0.4216 L0.2178,0.4216 L0.2178,0.31 Z M0.2178,0.5893 L0.3605,0.5893 L0.3605,0.7013 L0.2178,0.7013 L0.2178,0.5893 Z M0.2178,0.7307 L0.3605,0.7307 L0.3605,0.8427 L0.2178,0.8427 L0.2178,0.7307 Z M0.2178,0.8758 L0.3605,0.8758 L0.3605,0.9878 L0.2178,0.9878 L0.2178,0.8758 Z M0,0.164 L0.1432,0.164 L0.1432,0.2756 L0,0.2756 L0,0.164 Z M0,0.31 L0.1432,0.31 L0.1432,0.4216 L0,0.4216 L0,0.31 Z M0,0.4476 L0.1432,0.4476 L0.1432,0.5596 L0,0.5596 L0,0.4476 Z M0,0.5893 L0.1432,0.5893 L0.1432,0.7013 L0,0.7013 L0,0.5893 Z M0,0.7307 L0.1432,0.7307 L0.1432,0.8427 L0,0.8427 L0,0.7307 Z M0,0.8758 L0.1432,0.8758 L0.1432,0.9878 L0,0.9878 L0,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M0.1432,0.3217 L0.1432,0.4098 L0.0309,0.4098 L0.0309,0.3217 L0.1432,0.3217 Z M0.1586,0.2978 L0.0154,0.2978 Q0.0088,0.2978,0.0044,0.3016 T0,0.31 L0,0.4216 Q0,0.427,0.0049,0.4304 T0.0154,0.4337 L0.1586,0.4337 Q0.1648,0.4337,0.1694,0.4299 T0.174,0.4216 L0.174,0.31 Q0.174,0.3062,0.1715,0.3035 T0.1653,0.2993 T0.1586,0.2978 Z M0.1432,0.888 L0.1432,0.9757 L0.0309,0.9757 L0.0309,0.888 L0.1432,0.888 Z M0.1586,0.8637 L0.0154,0.8637 Q0.0108,0.8637,0.0072,0.8658 T0.0018,0.8706 T0,0.8758 L0,0.9878 Q0,0.9929,0.0049,0.9964 T0.0154,1 L0.1586,1 Q0.1648,1,0.1694,0.996 T0.174,0.9878 L0.174,0.8758 Q0.174,0.8725,0.1715,0.8695 T0.1653,0.8651 T0.1586,0.8637 Z M0.3496,0.169 L0.3496,0.2706 L0.2194,0.2706 L0.2194,0.169 L0.3496,0.169 Z M0.3563,0.159 L0.2132,0.159 Q0.2106,0.159,0.2088,0.1604 T0.207,0.164 L0.207,0.2756 Q0.207,0.2781,0.2091,0.2796 T0.2132,0.281 L0.3563,0.281 Q0.3589,0.281,0.3607,0.2794 T0.3625,0.2756 L0.3625,0.164 Q0.3625,0.1619,0.3605,0.1604 T0.3563,0.159 Z M0.3368,0.6044 L0.3368,0.6858 L0.2327,0.6858 L0.2327,0.6044 L0.3368,0.6044 Z M0.3563,0.5742 L0.2132,0.5742 Q0.2049,0.5742,0.1993,0.5791 T0.1936,0.5893 L0.1936,0.7013 Q0.1936,0.7076,0.2001,0.712 T0.2132,0.7164 L0.3563,0.7164 Q0.3641,0.7164,0.3697,0.7114 T0.3754,0.7013 L0.3754,0.5893 Q0.3754,0.5847,0.3723,0.5812 T0.3648,0.5759 T0.3563,0.5742 Z M0.5736,0.164 L0.431,0.164 L0.431,0.2756 L0.5736,0.2756 L0.5736,0.164 Z M0.5675,0.315 L0.5675,0.4165 L0.4377,0.4165 L0.4377,0.315 L0.5675,0.315 Z M0.5736,0.3049 L0.431,0.3049 Q0.4284,0.3049,0.4264,0.3064 T0.4243,0.31 L0.4243,0.4216 Q0.4243,0.4237,0.4266,0.4251 T0.431,0.4266 L0.5736,0.4266 Q0.5767,0.4266,0.5785,0.4251 T0.5803,0.4216 L0.5803,0.31 Q0.5803,0.3087,0.5798,0.3077 T0.5783,0.306 T0.5762,0.3052 T0.5736,0.3049 Z M0.5736,0.4476 L0.431,0.4476 L0.431,0.5596 L0.5736,0.5596 L0.5736,0.4476 Z M0.5613,0.7408 L0.5613,0.8326 L0.4439,0.8326 L0.4439,0.7408 L0.5613,0.7408 Z M0.5736,0.7206 L0.431,0.7206 Q0.4253,0.7206,0.4217,0.724 T0.4181,0.7307 L0.4181,0.8427 Q0.4181,0.8469,0.4222,0.8498 T0.431,0.8528 L0.5736,0.8528 Q0.5778,0.8528,0.5808,0.8511 T0.5855,0.8471 T0.587,0.8427 L0.587,0.7307 Q0.587,0.7265,0.5826,0.7236 T0.5736,0.7206 Z M0.7827,0.164 L0.6395,0.164 L0.6395,0.2756 L0.7827,0.2756 L0.7827,0.164 Z M0.7827,0.31 L0.6395,0.31 L0.6395,0.4216 L0.7827,0.4216 L0.7827,0.31 Z M0.7827,0.5893 L0.6395,0.5893 L0.6395,0.7013 L0.7827,0.7013 L0.7827,0.5893 Z M0.7827,0.7307 L0.6395,0.7307 L0.6395,0.8427 L0.7827,0.8427 L0.7827,0.7307 Z M0.7827,0.8758 L0.6395,0.8758 L0.6395,0.9878 L0.7827,0.9878 L0.7827,0.8758 Z M1,0.164 L0.8574,0.164 L0.8574,0.2756 L1,0.2756 L1,0.164 Z M1,0.31 L0.8574,0.31 L0.8574,0.4216 L1,0.4216 L1,0.31 Z M1,0.4476 L0.8574,0.4476 L0.8574,0.5596 L1,0.5596 L1,0.4476 Z M1,0.5893 L0.8574,0.5893 L0.8574,0.7013 L1,0.7013 L1,0.5893 Z M1,0.7307 L0.8574,0.7307 L0.8574,0.8427 L1,0.8427 L1,0.7307 Z M1,0.8758 L0.8574,0.8758 L0.8574,0.9878 L1,0.9878 L1,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.0008,0.9979 Q0.0008,1,0.0032,1 Q0.0482,1,0.0602,0.9975 Q0.0667,0.9963,0.0847,0.9917 T0.1084,0.9859 Q0.1124,0.9851,0.1221,0.9851 L0.1253,0.9851 L0.1285,0.9851 Q0.1518,0.9851,0.1655,0.9809 Q0.1695,0.9801,0.1731,0.9788 T0.1791,0.9766 T0.1839,0.9747 T0.1888,0.9732 L0.1936,0.972 T0.1988,0.9712 T0.2048,0.971 L0.2096,0.971 Q0.2201,0.9714,0.2233,0.9714 T0.2345,0.9693 Q0.2386,0.9685,0.2502,0.9674 T0.2715,0.966 L0.2811,0.9656 Q0.2916,0.9647,0.2916,0.9573 Q0.2916,0.954,0.2892,0.9515 T0.2819,0.9486 Q0.2755,0.9482,0.2683,0.9482 Q0.2643,0.9482,0.2582,0.9484 T0.2498,0.9486 Q0.2426,0.9486,0.2402,0.9473 Q0.2386,0.9469,0.2317,0.943 T0.2161,0.937 Q0.2104,0.9357,0.1992,0.933 T0.1831,0.9291 Q0.1807,0.9287,0.1783,0.9285 T0.1739,0.928 T0.1703,0.9276 T0.1675,0.9272 T0.1655,0.9266 T0.1639,0.9253 Q0.1598,0.9216,0.1462,0.9216 L0.143,0.9216 L0.1398,0.9216 L0.1365,0.9216 Q0.1197,0.9195,0.1197,0.9154 L0.1197,0.9154 Q0.1205,0.9121,0.1373,0.9088 T0.1703,0.9054 Q0.1791,0.9054,0.1863,0.904 T0.1984,0.9011 T0.2064,0.8992 Q0.2402,0.8967,0.2506,0.8934 Q0.2538,0.8926,0.2602,0.8899 T0.2707,0.8872 Q0.2715,0.8872,0.2731,0.8876 Q0.2795,0.8884,0.2884,0.8884 Q0.3068,0.8884,0.3092,0.8826 L0.3092,0.8797 Q0.3092,0.8772,0.3076,0.8747 T0.3044,0.8706 T0.3028,0.8681 Q0.3076,0.8656,0.3237,0.8656 Q0.3317,0.8656,0.3622,0.8623 Q0.3655,0.8623,0.3867,0.8617 T0.4217,0.8602 Q0.4241,0.8598,0.4289,0.8598 L0.4345,0.8598 L0.441,0.8598 Q0.4578,0.8598,0.4667,0.8586 Q0.4739,0.8573,0.4851,0.8567 T0.5004,0.8552 Q0.5012,0.8552,0.5108,0.855 T0.5269,0.853 T0.5333,0.8461 Q0.5333,0.8445,0.5325,0.8432 T0.5309,0.8409 T0.5289,0.8391 T0.5261,0.8378 L0.5229,0.837 T0.5185,0.8362 T0.5133,0.8355 T0.5076,0.8349 T0.502,0.8341 Q0.4932,0.8324,0.4859,0.8324 Q0.4827,0.8324,0.4787,0.8328 T0.4731,0.8333 Q0.4707,0.8333,0.4683,0.8324 Q0.4482,0.825,0.4394,0.825 Q0.4369,0.825,0.4345,0.8254 Q0.4225,0.827,0.4153,0.827 Q0.4088,0.827,0.4064,0.8258 Q0.3976,0.8204,0.3751,0.8204 Q0.3703,0.8204,0.3667,0.8214 T0.3622,0.8225 Q0.3598,0.8225,0.3558,0.82 Q0.351,0.8175,0.3402,0.8167 T0.3177,0.8156 T0.3028,0.8146 L0.2956,0.8121 T0.2871,0.8094 T0.2771,0.8073 T0.2635,0.8063 Q0.261,0.8063,0.2586,0.8067 Q0.2378,0.8071,0.2273,0.8071 Q0.2072,0.8071,0.2024,0.8051 Q0.1976,0.8034,0.1932,0.8026 T0.1867,0.8013 T0.1847,0.8001 L0.1847,0.7993 Q0.1855,0.7984,0.1855,0.7978 T0.1859,0.7966 T0.1867,0.7959 T0.188,0.7955 T0.1896,0.7951 T0.1916,0.7949 T0.1944,0.7945 T0.1984,0.7941 T0.2032,0.7939 Q0.212,0.7926,0.2325,0.7918 T0.2562,0.7905 Q0.2691,0.7893,0.2787,0.7847 Q0.2835,0.7827,0.2968,0.7791 T0.3149,0.7756 Q0.3189,0.7756,0.3305,0.7733 T0.3446,0.771 L0.3454,0.771 Q0.3462,0.771,0.3498,0.7721 T0.3574,0.774 T0.3655,0.7748 Q0.3703,0.7748,0.3743,0.7731 T0.3823,0.7708 T0.3916,0.77 T0.3992,0.7694 Q0.4008,0.7694,0.4076,0.7688 T0.4205,0.7675 L0.4305,0.7665 Q0.4345,0.7657,0.4402,0.7617 T0.4458,0.7545 Q0.4458,0.7503,0.4353,0.7487 Q0.4297,0.7478,0.4209,0.7462 T0.4044,0.7433 T0.3904,0.7416 L0.3847,0.7416 Q0.3807,0.7416,0.3747,0.7422 T0.3663,0.7428 T0.3606,0.7424 Q0.3582,0.742,0.3562,0.7418 T0.3522,0.7412 T0.3482,0.7406 T0.3446,0.7401 T0.341,0.7397 T0.3373,0.7393 T0.3341,0.7391 L0.3293,0.7391 Q0.3277,0.7395,0.3253,0.7395 Q0.3205,0.7395,0.3052,0.7387 T0.2835,0.7379 Q0.2755,0.7379,0.253,0.7325 Q0.2506,0.7316,0.2462,0.731 T0.2382,0.7296 T0.2305,0.7271 T0.2181,0.7234 T0.2048,0.7196 T0.2,0.7155 Q0.2,0.7142,0.2016,0.713 Q0.208,0.7059,0.2285,0.6978 T0.2618,0.6898 Q0.2739,0.6898,0.2831,0.6848 T0.2956,0.6794 Q0.3028,0.6786,0.3289,0.6765 T0.3566,0.674 Q0.3582,0.674,0.3855,0.6723 T0.4406,0.6688 T0.4755,0.6653 Q0.5004,0.6607,0.5124,0.6599 L0.5165,0.6599 Q0.5213,0.6599,0.5277,0.6605 T0.5373,0.6611 Q0.543,0.6611,0.5494,0.6599 Q0.592,0.6524,0.6,0.6524 Q0.6064,0.6524,0.61,0.6499 T0.6161,0.6474 Q0.6177,0.6474,0.6261,0.6495 T0.6418,0.6516 L0.6482,0.6516 Q0.653,0.6512,0.6651,0.6506 T0.6876,0.6493 T0.7084,0.6477 T0.7229,0.645 Q0.7269,0.6437,0.7333,0.6437 Q0.7373,0.6437,0.7458,0.6443 T0.7574,0.645 Q0.7614,0.645,0.7631,0.6445 T0.7655,0.6441 Q0.7671,0.6441,0.7723,0.6448 T0.7823,0.6454 Q0.788,0.6454,0.7952,0.6445 Q0.8233,0.6408,0.8723,0.6367 Q0.9012,0.6342,0.9092,0.6342 L0.9165,0.6342 L0.9205,0.6342 Q0.9277,0.6342,0.9382,0.6323 T0.9526,0.6304 Q0.9534,0.6304,0.9594,0.6307 T0.9695,0.6309 Q0.9976,0.6309,0.9992,0.6234 Q1,0.6201,1,0.618 Q1,0.6089,0.9775,0.608 Q0.9703,0.6076,0.9582,0.6076 Q0.9518,0.6076,0.9394,0.6078 T0.9213,0.608 Q0.9036,0.608,0.8972,0.6072 Q0.894,0.6068,0.8871,0.6058 T0.8751,0.6039 T0.8627,0.6024 T0.8506,0.6018 L0.8474,0.6018 Q0.841,0.6022,0.8281,0.6041 T0.8112,0.606 Q0.8096,0.606,0.808,0.6056 Q0.7783,0.6002,0.7647,0.6002 Q0.7598,0.6002,0.7454,0.6006 T0.7261,0.601 Q0.7221,0.601,0.7145,0.6022 T0.7036,0.6035 Q0.6996,0.6035,0.6964,0.6022 Q0.6723,0.5902,0.6442,0.5902 Q0.6426,0.5902,0.6386,0.5904 T0.6337,0.5906 Q0.6273,0.5906,0.6249,0.5894 L0.6177,0.5856 T0.6116,0.5838 T0.6016,0.5825 T0.5855,0.5823 Q0.5719,0.5823,0.5574,0.5798 T0.5373,0.5774 L0.5341,0.5774 Q0.5293,0.5778,0.5213,0.5786 T0.51,0.5794 Q0.5036,0.5794,0.4988,0.5769 Q0.4932,0.574,0.4771,0.574 Q0.4723,0.574,0.4631,0.5745 T0.4498,0.5749 Q0.4418,0.5749,0.4394,0.5736 Q0.4353,0.5724,0.4305,0.5715 T0.4225,0.5707 T0.4145,0.5705 T0.4056,0.5699 Q0.4008,0.5691,0.398,0.5689 T0.394,0.5689 T0.3908,0.5686 T0.3855,0.5674 Q0.3831,0.567,0.3811,0.5662 T0.3779,0.5645 T0.3743,0.563 T0.3695,0.5624 Q0.3655,0.5624,0.3594,0.5635 T0.3494,0.5645 T0.3406,0.5635 T0.3325,0.5624 Q0.3309,0.5624,0.3301,0.5628 L0.3141,0.5628 Q0.2635,0.5628,0.2506,0.5612 Q0.2474,0.5608,0.2434,0.5608 Q0.2402,0.5608,0.2349,0.561 T0.2273,0.5612 Q0.2209,0.5612,0.2177,0.5595 Q0.2145,0.557,0.2145,0.5558 Q0.2169,0.5537,0.2345,0.5521 Q0.2876,0.5475,0.3028,0.5425 Q0.3068,0.5413,0.3149,0.5396 T0.3309,0.5367 T0.3478,0.5338 T0.3606,0.5309 Q0.3631,0.5305,0.3755,0.5259 T0.3968,0.5214 Q0.3992,0.5214,0.4024,0.5218 T0.4096,0.5222 Q0.4161,0.5222,0.4213,0.5209 T0.4313,0.5185 T0.4402,0.5172 Q0.4418,0.5168,0.447,0.5168 L0.4558,0.5168 T0.4639,0.5162 T0.4707,0.5141 T0.4731,0.5102 Q0.4731,0.5089,0.4723,0.5081 Q0.4699,0.5019,0.4627,0.4994 T0.4369,0.4965 Q0.4273,0.4961,0.4193,0.4946 T0.4048,0.4915 T0.3952,0.4894 Q0.392,0.4886,0.388,0.4886 Q0.3847,0.4886,0.3775,0.4892 T0.3647,0.4898 Q0.3598,0.4898,0.355,0.4894 Q0.3165,0.4861,0.3141,0.4853 Q0.2779,0.4774,0.2715,0.4774 Q0.2699,0.4774,0.2683,0.4776 T0.2627,0.4778 Q0.2498,0.4778,0.2281,0.4762 Q0.2241,0.4749,0.2233,0.4737 Q0.2249,0.472,0.2321,0.4708 Q0.2402,0.4695,0.2554,0.4695 L0.2675,0.4695 L0.2795,0.4695 Q0.294,0.4695,0.2996,0.4679 Q0.3141,0.4629,0.3373,0.4616 Q0.3414,0.4612,0.3466,0.4606 T0.3582,0.4589 T0.3687,0.4562 T0.3727,0.4525 Q0.3727,0.4509,0.3703,0.4492 Q0.3639,0.4455,0.3474,0.4419 T0.3213,0.4384 L0.3157,0.4384 L0.31,0.4384 Q0.294,0.4384,0.2859,0.4363 Q0.2795,0.4347,0.2691,0.4347 L0.2618,0.4347 L0.2546,0.4347 Q0.2458,0.4347,0.2394,0.4338 Q0.2257,0.4318,0.2193,0.4303 T0.2092,0.4266 T0.2052,0.4224 T0.2024,0.4154 T0.196,0.4052 Q0.1912,0.3994,0.1867,0.3949 T0.1807,0.3884 T0.1791,0.3849 Q0.1791,0.3824,0.1839,0.3745 Q0.1871,0.3687,0.1944,0.3637 T0.2072,0.3561 T0.2221,0.3501 T0.2321,0.3463 Q0.2353,0.3455,0.241,0.3445 T0.2522,0.3428 T0.2639,0.3411 T0.2731,0.3384 T0.2956,0.3351 T0.3197,0.3326 Q0.3213,0.3322,0.3237,0.3322 T0.3325,0.3331 T0.3414,0.3339 Q0.3478,0.3339,0.3518,0.3314 Q0.3606,0.3264,0.3703,0.3264 Q0.3775,0.3264,0.3847,0.3293 Q0.3888,0.331,0.396,0.331 Q0.4024,0.331,0.4116,0.3295 T0.4265,0.3266 T0.4414,0.3227 T0.4514,0.3202 Q0.4578,0.3181,0.4839,0.3152 T0.5112,0.3123 T0.5177,0.3119 T0.5285,0.3111 T0.5398,0.3096 T0.549,0.3065 T0.5526,0.3015 Q0.5526,0.2999,0.5518,0.2982 Q0.547,0.2903,0.5386,0.2883 T0.5165,0.2862 Q0.5116,0.2862,0.5056,0.2866 T0.4972,0.287 Q0.4884,0.287,0.4787,0.2833 Q0.4594,0.2758,0.4265,0.2758 Q0.4169,0.2758,0.4129,0.2766 Q0.4112,0.2771,0.4104,0.2771 Q0.4088,0.2771,0.4056,0.2748 T0.3968,0.2721 Q0.3695,0.2696,0.359,0.2659 Q0.355,0.2646,0.351,0.2646 T0.3426,0.2661 T0.3365,0.2675 T0.3333,0.2659 Q0.3277,0.2605,0.3116,0.2553 T0.2859,0.2501 L0.2843,0.2501 L0.2819,0.2501 Q0.2779,0.2501,0.2723,0.2493 T0.2586,0.2472 T0.2474,0.2455 Q0.1799,0.236,0.1719,0.236 Q0.1663,0.236,0.1606,0.235 T0.1502,0.2316 T0.1454,0.2265 Q0.1454,0.2223,0.1558,0.2173 Q0.1679,0.2115,0.1859,0.2092 T0.2185,0.207 T0.2353,0.2057 Q0.2369,0.2049,0.2502,0.2041 T0.2799,0.2022 T0.302,0.2007 Q0.3084,0.1999,0.3245,0.1954 T0.347,0.1908 Q0.3502,0.1908,0.3534,0.1916 Q0.3663,0.197,0.388,0.197 Q0.404,0.197,0.4088,0.1929 Q0.4096,0.192,0.4108,0.192 T0.4177,0.1945 T0.4277,0.197 T0.4369,0.1949 Q0.4442,0.1908,0.4843,0.1875 Q0.4892,0.1871,0.4968,0.1839 T0.5084,0.1808 L0.5108,0.1808 Q0.5213,0.1825,0.5454,0.1825 Q0.5823,0.1825,0.5992,0.1779 Q0.6096,0.1746,0.6217,0.1746 Q0.6249,0.1746,0.6309,0.1748 T0.6394,0.175 Q0.6434,0.175,0.6466,0.1746 Q0.6474,0.1746,0.6594,0.1738 T0.6787,0.1713 T0.6892,0.1659 Q0.6924,0.1634,0.6924,0.1593 Q0.6924,0.1547,0.6888,0.151 T0.6795,0.1472 Q0.6779,0.1472,0.6763,0.1477 Q0.6699,0.1493,0.6667,0.1493 Q0.661,0.1493,0.6506,0.1456 Q0.6329,0.1394,0.6129,0.1394 Q0.6048,0.1394,0.5992,0.1377 T0.5888,0.136 T0.5803,0.1377 T0.5751,0.1394 Q0.5711,0.1394,0.5639,0.1369 Q0.5365,0.1273,0.5116,0.1273 Q0.4876,0.1273,0.4667,0.1253 Q0.4627,0.1248,0.4542,0.1211 T0.4337,0.1174 L0.4305,0.1174 Q0.4217,0.1178,0.4153,0.119 T0.408,0.1203 Q0.4056,0.1203,0.4,0.117 Q0.3976,0.1153,0.396,0.1136 T0.3932,0.1112 T0.39,0.1099 T0.3847,0.1095 Q0.3799,0.1095,0.3687,0.1103 Q0.355,0.1112,0.3434,0.1141 T0.3301,0.117 Q0.3261,0.117,0.3229,0.1145 Q0.3181,0.1116,0.3052,0.1087 T0.2787,0.1043 T0.2546,0.1029 Q0.2506,0.1029,0.2474,0.1033 Q0.2418,0.1037,0.2349,0.1054 T0.2249,0.107 Q0.2225,0.107,0.2193,0.1066 Q0.2024,0.1024,0.1863,0.1024 Q0.1823,0.1024,0.1562,0.0971 T0.1269,0.0917 T0.1161,0.0896 T0.106,0.0854 Q0.1076,0.0846,0.11,0.0842 Q0.1173,0.0821,0.1261,0.0821 Q0.1301,0.0821,0.1369,0.0825 T0.1462,0.083 Q0.1494,0.083,0.151,0.0825 T0.1831,0.0813 T0.2201,0.0784 T0.243,0.074 T0.2667,0.0718 Q0.2707,0.0718,0.2755,0.0724 T0.2843,0.073 T0.2936,0.0724 T0.3024,0.0705 T0.3072,0.068 T0.3092,0.0657 T0.3108,0.0647 Q0.3116,0.0643,0.3133,0.0643 L0.3157,0.0643 L0.3181,0.0643 Q0.3446,0.0643,0.3446,0.0556 T0.3205,0.0469 L0.3189,0.0469 Q0.3157,0.0469,0.3157,0.0465 Q0.3084,0.0427,0.2835,0.0386 Q0.2739,0.0369,0.2675,0.0342 T0.2538,0.0299 Q0.249,0.029,0.245,0.029 T0.2378,0.0303 T0.2321,0.0315 Q0.2305,0.0315,0.2273,0.0307 Q0.2201,0.0286,0.2004,0.0272 T0.1775,0.0245 Q0.1735,0.0228,0.1663,0.0226 T0.1522,0.0197 T0.1345,0.0145 T0.1124,0.0079 Q0.0996,0.0033,0.0671,0.0044 T0.0297,0.0041 Q0.0169,0,0.0024,0.0017 Q0,0.0021,0,0.0037 Z M0.0064,0.9954 L0.0056,0.0058 Q0.0177,0.005,0.0281,0.0083 Q0.0345,0.01,0.0675,0.0089 T0.1108,0.012 Q0.1221,0.0162,0.1329,0.0187 T0.1498,0.0236 T0.1606,0.0268 T0.1691,0.0274 T0.1759,0.0286 Q0.1807,0.0303,0.2,0.0315 T0.2257,0.0348 Q0.2305,0.0361,0.2337,0.0361 Q0.2361,0.0361,0.2398,0.0348 T0.2466,0.0336 Q0.249,0.0336,0.2522,0.034 Q0.2586,0.0353,0.2655,0.0382 T0.2827,0.0427 Q0.3068,0.0469,0.3124,0.0502 Q0.3157,0.0523,0.3237,0.0523 L0.3277,0.0523 L0.3309,0.0523 Q0.3398,0.0523,0.3398,0.0556 Q0.3398,0.0581,0.3341,0.0587 T0.3205,0.0593 T0.3092,0.0603 T0.3036,0.0643 T0.2932,0.068 Q0.2884,0.0684,0.2843,0.0684 Q0.2811,0.0684,0.2763,0.0678 T0.2667,0.0672 Q0.2586,0.0672,0.2422,0.0697 T0.2177,0.0747 Q0.2137,0.0759,0.1831,0.0767 T0.1494,0.0784 L0.1474,0.0784 T0.1398,0.078 T0.1285,0.0776 Q0.1173,0.0776,0.1084,0.08 Q0.1004,0.0817,0.1004,0.0846 Q0.1004,0.0867,0.104,0.0888 T0.1124,0.0923 T0.1213,0.0948 T0.1269,0.0958 T0.155,0.1014 T0.1863,0.107 Q0.2016,0.107,0.2185,0.1107 Q0.2217,0.1116,0.2257,0.1116 Q0.2289,0.1116,0.2365,0.1099 T0.2482,0.1074 L0.2538,0.1074 Q0.2683,0.1074,0.2912,0.1107 T0.3197,0.1182 Q0.3245,0.1215,0.3301,0.1215 Q0.3333,0.1215,0.3454,0.1184 T0.3687,0.1145 Q0.3735,0.1141,0.3779,0.1139 T0.3843,0.1134 T0.3871,0.1132 Q0.3896,0.1132,0.39,0.1136 T0.392,0.1161 T0.3968,0.1203 Q0.404,0.1248,0.408,0.1248 Q0.4096,0.1248,0.4165,0.1234 T0.4305,0.1215 L0.4337,0.1215 Q0.4442,0.1215,0.4518,0.1251 T0.4659,0.1294 Q0.4876,0.1319,0.5116,0.1319 T0.5622,0.141 Q0.5703,0.1439,0.5751,0.1439 Q0.5791,0.1439,0.5831,0.1423 T0.5888,0.1406 Q0.592,0.1406,0.5944,0.1412 T0.6012,0.1427 T0.6129,0.1435 Q0.6313,0.1435,0.649,0.1497 Q0.6602,0.1535,0.6667,0.1535 Q0.6715,0.1535,0.6779,0.1522 Q0.6787,0.1518,0.6795,0.1518 Q0.6827,0.1518,0.6847,0.1541 T0.6867,0.1593 Q0.6867,0.1618,0.6851,0.1634 Q0.6835,0.1655,0.6775,0.1667 T0.6598,0.169 T0.6458,0.1705 T0.6402,0.1709 Q0.6378,0.1709,0.6321,0.1705 T0.6225,0.1701 Q0.6096,0.1701,0.5968,0.1738 Q0.5823,0.1779,0.5446,0.1779 Q0.5205,0.1779,0.5116,0.1767 Q0.51,0.1763,0.5084,0.1763 Q0.5028,0.1763,0.4944,0.1796 T0.4835,0.1829 L0.4771,0.1833 T0.4659,0.1844 L0.4546,0.1858 T0.443,0.1881 T0.4337,0.1912 Q0.4321,0.1916,0.4305,0.1916 Q0.4273,0.1916,0.4209,0.1895 T0.412,0.1875 Q0.408,0.1875,0.4056,0.19 Q0.4024,0.1925,0.388,0.1925 Q0.3663,0.1925,0.3558,0.1879 Q0.3518,0.1862,0.3462,0.1862 Q0.3373,0.1862,0.3213,0.191 T0.3012,0.1962 Q0.2964,0.1966,0.2799,0.1976 T0.2494,0.1997 T0.2313,0.2024 L0.2313,0.2024 L0.2293,0.2024 L0.2261,0.2024 L0.2217,0.2024 Q0.204,0.2024,0.1851,0.2047 T0.1526,0.2136 Q0.1406,0.2198,0.1406,0.226 Q0.1406,0.2319,0.1518,0.2362 T0.1719,0.2406 Q0.1791,0.2406,0.2466,0.2497 Q0.2498,0.2501,0.2574,0.2516 T0.2711,0.2538 T0.2819,0.2547 L0.2851,0.2547 Q0.2851,0.2543,0.2859,0.2543 Q0.294,0.2543,0.3096,0.2592 T0.3285,0.2684 Q0.3317,0.2721,0.3373,0.2721 Q0.3406,0.2721,0.3462,0.2708 T0.3542,0.2696 Q0.3558,0.2696,0.3574,0.27 Q0.3679,0.2737,0.3968,0.2762 Q0.3984,0.2766,0.4004,0.2779 L0.4044,0.2804 T0.4096,0.2816 Q0.412,0.2816,0.4145,0.2808 Q0.4177,0.2804,0.4249,0.2804 Q0.4586,0.2804,0.4763,0.287 Q0.4867,0.2912,0.4972,0.2912 Q0.5004,0.2912,0.5064,0.2908 T0.5165,0.2903 Q0.5293,0.2903,0.5361,0.2922 T0.547,0.3003 L0.547,0.3011 Q0.547,0.3036,0.5414,0.3049 T0.5249,0.3067 T0.51,0.3082 Q0.5092,0.3082,0.4831,0.3111 T0.4498,0.3161 Q0.408,0.3264,0.3952,0.3264 Q0.3896,0.3264,0.3863,0.3252 Q0.3783,0.3223,0.3703,0.3223 Q0.359,0.3223,0.3494,0.3277 Q0.347,0.3293,0.343,0.3293 Q0.3414,0.3293,0.3353,0.3285 T0.3253,0.3277 T0.3181,0.3285 Q0.3149,0.3289,0.2952,0.3306 T0.2699,0.3347 Q0.2675,0.3364,0.2598,0.3372 T0.2434,0.3395 T0.2297,0.3426 L0.2205,0.3461 T0.2048,0.3523 T0.1908,0.3606 T0.1791,0.3725 Q0.1743,0.3803,0.1743,0.3845 Q0.1743,0.3874,0.1763,0.3901 T0.1827,0.3976 T0.1912,0.4073 T0.198,0.4189 T0.2032,0.4276 T0.2137,0.4326 T0.2386,0.438 Q0.2458,0.4392,0.2562,0.4392 L0.2639,0.4392 L0.2699,0.4392 Q0.2795,0.4392,0.2843,0.4405 Q0.2932,0.443,0.3092,0.443 L0.3157,0.443 L0.3213,0.443 Q0.3293,0.443,0.3458,0.4463 T0.3671,0.4525 Q0.3598,0.4558,0.3373,0.4571 Q0.3124,0.4587,0.298,0.4637 Q0.294,0.465,0.2811,0.465 L0.2703,0.465 L0.2586,0.465 Q0.241,0.465,0.2305,0.4666 Q0.2185,0.4687,0.2185,0.4728 Q0.2185,0.4745,0.2205,0.4764 T0.2241,0.4791 L0.2265,0.4803 L0.2273,0.4803 Q0.2506,0.4824,0.261,0.4824 Q0.2675,0.4824,0.2699,0.482 Q0.2699,0.4815,0.2707,0.4815 Q0.2771,0.4815,0.3124,0.4898 Q0.3173,0.4907,0.3229,0.4913 T0.3386,0.4925 T0.3542,0.4936 T0.3663,0.494 Q0.3711,0.494,0.3787,0.4936 T0.3888,0.4932 Q0.392,0.4932,0.3944,0.4936 T0.4032,0.4959 T0.4181,0.499 T0.4369,0.5006 Q0.449,0.501,0.455,0.5021 T0.4639,0.5048 T0.4675,0.5093 L0.4675,0.5097 Q0.4675,0.5106,0.4663,0.511 T0.4622,0.5116 L0.4566,0.512 T0.4486,0.5124 T0.4402,0.5127 Q0.4345,0.5131,0.4257,0.5153 T0.4096,0.5176 Q0.4064,0.5176,0.4024,0.5172 L0.3968,0.5172 Q0.3863,0.5172,0.3731,0.522 T0.359,0.5268 Q0.355,0.528,0.3317,0.5321 T0.3004,0.5388 Q0.2867,0.5433,0.2337,0.5479 Q0.2096,0.55,0.2096,0.5562 Q0.2096,0.5591,0.2145,0.5628 Q0.2193,0.5662,0.2289,0.5662 Q0.2313,0.5662,0.2373,0.5657 T0.2458,0.5653 L0.2498,0.5653 Q0.2635,0.5674,0.3124,0.5674 Q0.3261,0.5674,0.3301,0.567 L0.3317,0.567 Q0.3341,0.567,0.3394,0.568 T0.3486,0.5691 Q0.3542,0.5691,0.3606,0.5678 T0.3699,0.5666 T0.3759,0.5686 T0.3839,0.5718 T0.3908,0.573 T0.3964,0.5734 T0.4048,0.5742 T0.4165,0.5751 T0.4277,0.5757 T0.4369,0.5778 Q0.4426,0.5794,0.4538,0.5794 Q0.4586,0.5794,0.4679,0.5792 T0.4811,0.579 Q0.4924,0.579,0.4956,0.5807 Q0.502,0.584,0.5108,0.584 L0.5137,0.584 T0.5173,0.5838 L0.5205,0.5834 L0.5237,0.583 L0.5269,0.5825 T0.5305,0.5821 T0.5341,0.5819 L0.5365,0.5819 Q0.5414,0.5819,0.5562,0.5842 T0.5855,0.5865 Q0.5912,0.5865,0.5948,0.5867 T0.6012,0.5869 T0.6064,0.5873 T0.61,0.5877 T0.6133,0.5886 T0.6157,0.5896 L0.6185,0.591 T0.6217,0.5931 Q0.6265,0.5952,0.6369,0.5952 L0.6418,0.5952 L0.6466,0.5952 Q0.6723,0.5952,0.6932,0.606 Q0.698,0.608,0.7044,0.608 Q0.7084,0.608,0.7161,0.6068 T0.7261,0.6056 Q0.7309,0.6056,0.7454,0.6051 T0.7647,0.6047 Q0.7775,0.6047,0.8072,0.6101 Q0.8096,0.6105,0.812,0.6105 Q0.8177,0.6105,0.8297,0.6085 T0.8474,0.606 L0.8506,0.606 Q0.8562,0.606,0.8647,0.607 T0.8831,0.6095 T0.8964,0.6118 Q0.9036,0.6122,0.9221,0.6122 L0.9406,0.6122 L0.959,0.6122 L0.9767,0.6122 Q0.9952,0.613,0.9952,0.6172 Q0.9952,0.6176,0.9944,0.6221 Q0.9936,0.6259,0.9574,0.6259 L0.955,0.6259 L0.9526,0.6259 Q0.9478,0.6259,0.9373,0.628 T0.9205,0.63 L0.9173,0.63 Q0.9133,0.6296,0.9084,0.6296 Q0.9004,0.6296,0.8715,0.6321 Q0.8233,0.6367,0.7944,0.64 Q0.7888,0.6408,0.7839,0.6408 T0.7739,0.6402 T0.7671,0.6396 Q0.7639,0.6396,0.7622,0.64 Q0.7614,0.6404,0.759,0.6404 Q0.7574,0.6404,0.749,0.6398 T0.7357,0.6392 Q0.7261,0.6392,0.7213,0.6412 Q0.7173,0.6425,0.7032,0.6437 T0.6711,0.6458 T0.6474,0.647 Q0.645,0.6474,0.6418,0.6474 Q0.6353,0.6474,0.6277,0.6454 T0.6161,0.6433 Q0.6104,0.6433,0.6072,0.6456 T0.6,0.6479 Q0.5912,0.6479,0.5486,0.6557 Q0.5422,0.657,0.5373,0.657 Q0.5349,0.657,0.5289,0.6564 T0.5173,0.6557 L0.5124,0.6557 Q0.4996,0.6562,0.4739,0.6611 Q0.4675,0.6624,0.4398,0.6645 T0.3851,0.668 T0.3558,0.6698 Q0.355,0.6698,0.3285,0.6721 T0.2948,0.6752 Q0.2892,0.6761,0.2843,0.6786 T0.2747,0.6831 T0.2618,0.6852 Q0.253,0.6852,0.2394,0.6893 T0.2141,0.6993 T0.1968,0.7105 Q0.1944,0.713,0.1944,0.7155 Q0.1944,0.7196,0.2012,0.7229 T0.2177,0.7285 T0.2281,0.7308 Q0.2321,0.7329,0.2365,0.7339 T0.245,0.7356 T0.2514,0.7366 Q0.2522,0.737,0.2554,0.7379 T0.2614,0.7393 T0.2679,0.7406 T0.2755,0.7416 T0.2835,0.742 Q0.29,0.742,0.3048,0.7428 T0.3253,0.7437 L0.3301,0.7437 L0.3333,0.7437 Q0.3341,0.7437,0.3598,0.7466 Q0.3639,0.7474,0.3671,0.7474 T0.3759,0.7466 T0.3855,0.7457 Q0.388,0.7457,0.3904,0.7462 Q0.3984,0.7466,0.4137,0.7495 T0.4349,0.7532 T0.441,0.7557 Q0.441,0.7599,0.4289,0.7619 Q0.4257,0.7628,0.4197,0.7634 T0.4072,0.7644 T0.3984,0.7652 Q0.3968,0.7652,0.3912,0.7655 T0.3811,0.7665 T0.3719,0.7694 Q0.3695,0.7702,0.3655,0.7702 T0.3546,0.7686 T0.3462,0.7665 L0.3446,0.7665 Q0.3406,0.7665,0.3293,0.769 T0.3149,0.7715 Q0.3084,0.7715,0.2952,0.7748 T0.2763,0.781 Q0.2675,0.7847,0.2554,0.7864 Q0.253,0.7864,0.2325,0.7874 T0.2024,0.7893 Q0.2008,0.7893,0.1984,0.7897 T0.1948,0.7901 T0.1916,0.7903 T0.1888,0.7908 T0.1867,0.7914 T0.1847,0.7922 L0.1831,0.793 T0.1819,0.7943 L0.1811,0.7959 T0.1799,0.7976 Q0.1791,0.7993,0.1791,0.8001 Q0.1791,0.8034,0.1831,0.8051 T0.1932,0.8078 T0.2,0.8092 Q0.2072,0.8117,0.2257,0.8117 Q0.2337,0.8117,0.2586,0.8109 L0.2635,0.8109 Q0.2707,0.8109,0.2767,0.8117 T0.2859,0.8136 T0.2936,0.8163 T0.3012,0.8187 Q0.3068,0.82,0.3277,0.8206 T0.3526,0.8237 Q0.3582,0.8266,0.3622,0.8266 Q0.3647,0.8266,0.3687,0.8258 T0.3751,0.825 Q0.396,0.825,0.404,0.8291 Q0.408,0.8316,0.4161,0.8316 Q0.4217,0.8316,0.4353,0.8295 L0.4394,0.8295 Q0.4466,0.8295,0.4659,0.8366 Q0.4699,0.8378,0.4747,0.8378 Q0.4763,0.8378,0.4807,0.8374 T0.4884,0.837 Q0.494,0.837,0.5004,0.8382 Q0.5052,0.8391,0.5124,0.8399 Q0.5221,0.8411,0.5249,0.8422 T0.5277,0.8461 Q0.5277,0.8482,0.5233,0.849 T0.5112,0.8501 T0.4996,0.8511 Q0.4964,0.8519,0.4851,0.8523 T0.4659,0.8544 Q0.4578,0.8557,0.4402,0.8557 L0.4349,0.8557 L0.4297,0.8557 L0.4209,0.8557 Q0.408,0.8565,0.3867,0.8571 T0.3614,0.8582 Q0.3317,0.8611,0.3237,0.8611 L0.3225,0.8611 L0.3213,0.8611 Q0.2972,0.8611,0.2972,0.8681 Q0.2972,0.8714,0.3008,0.8747 T0.3044,0.8805 Q0.3044,0.881,0.3036,0.8814 Q0.3012,0.8839,0.2851,0.8839 Q0.2779,0.8839,0.2739,0.883 Q0.2723,0.8826,0.2699,0.8826 T0.2643,0.8835 T0.259,0.8853 T0.2542,0.8876 T0.249,0.8893 Q0.2386,0.8922,0.2056,0.8946 Q0.2016,0.8951,0.1916,0.898 T0.1703,0.9009 Q0.1518,0.9009,0.1337,0.9044 T0.1149,0.9146 L0.1149,0.9158 Q0.1149,0.9175,0.1157,0.9187 T0.1173,0.921 T0.1201,0.9226 T0.1233,0.9237 T0.1269,0.9245 L0.1305,0.9251 T0.1337,0.9255 L0.1357,0.9258 Q0.139,0.9262,0.1446,0.9262 T0.1542,0.9266 T0.1598,0.9282 Q0.1614,0.9303,0.1647,0.9314 T0.1739,0.9328 T0.1815,0.9336 Q0.1863,0.9345,0.1976,0.9372 T0.2145,0.9415 Q0.2225,0.9432,0.2285,0.9467 T0.2378,0.9515 Q0.2426,0.9531,0.2514,0.9531 Q0.2538,0.9531,0.2602,0.9529 T0.2707,0.9527 Q0.2763,0.9527,0.2815,0.9531 T0.2867,0.9569 T0.2811,0.9614 Q0.2434,0.9627,0.2329,0.9652 Q0.2249,0.9672,0.2241,0.9672 L0.2096,0.9668 L0.2056,0.9668 Q0.2,0.9668,0.196,0.9672 T0.1884,0.9687 T0.1815,0.9708 T0.1731,0.9737 T0.1639,0.9772 Q0.1518,0.9805,0.1285,0.9805 L0.1253,0.9805 Q0.1124,0.9805,0.1076,0.9818 Q0.1012,0.983,0.0831,0.9876 T0.0594,0.9934 Q0.049,0.9954,0.0064,0.9954 Z M0.0032,0.9979 L0.0024,0.0037 Q0.0161,0.0021,0.0289,0.0062 Q0.0337,0.0075,0.0671,0.0066 T0.1116,0.01 T0.1337,0.0166 T0.151,0.022 Q0.1582,0.0249,0.1659,0.0251 T0.1767,0.0265 Q0.1807,0.0278,0.2,0.0292 T0.2265,0.0328 Q0.2305,0.034,0.2329,0.034 T0.239,0.0326 T0.2458,0.0311 T0.253,0.0319 Q0.2578,0.0332,0.2614,0.0342 T0.2667,0.0363 T0.2723,0.0384 T0.2827,0.0406 Q0.3084,0.0448,0.3141,0.0485 Q0.3149,0.0494,0.3225,0.0494 T0.3361,0.0504 T0.3422,0.0554 T0.3357,0.0606 T0.3205,0.0618 T0.31,0.0626 Q0.3092,0.0626,0.3056,0.0659 T0.2932,0.0701 Q0.2884,0.0709,0.2843,0.0709 Q0.2811,0.0709,0.2759,0.0701 T0.2667,0.0693 Q0.2586,0.0693,0.2422,0.0718 T0.2193,0.0763 Q0.2137,0.0784,0.1831,0.079 T0.1502,0.0805 Q0.1494,0.0809,0.147,0.0809 Q0.1454,0.0809,0.1386,0.0803 T0.1277,0.0796 Q0.1173,0.0796,0.1092,0.0821 Q0.1036,0.0834,0.1036,0.0854 Q0.1036,0.0879,0.1129,0.0908 T0.1269,0.0937 Q0.1293,0.0937,0.1558,0.0991 T0.1863,0.1045 Q0.2016,0.1045,0.2193,0.1087 Q0.2225,0.1091,0.2249,0.1091 Q0.2289,0.1091,0.2357,0.1076 T0.2482,0.1054 Q0.2506,0.1049,0.2546,0.1049 Q0.2699,0.1049,0.2924,0.1085 T0.3213,0.1165 Q0.3253,0.119,0.3301,0.119 Q0.3325,0.119,0.3446,0.1161 T0.3687,0.1124 Q0.3831,0.1112,0.3863,0.1112 T0.3908,0.1118 T0.3936,0.1145 T0.3984,0.1186 Q0.4048,0.1228,0.408,0.1228 Q0.4096,0.1228,0.4161,0.1213 T0.4305,0.1195 L0.4337,0.1195 Q0.4426,0.1195,0.4474,0.1211 T0.4566,0.1246 T0.4667,0.1273 Q0.4876,0.1298,0.5116,0.1298 Q0.5365,0.1298,0.5631,0.1389 Q0.5703,0.1414,0.5751,0.1414 Q0.5783,0.1414,0.5819,0.1398 T0.5888,0.1381 Q0.5928,0.1381,0.5984,0.1398 T0.6129,0.1414 Q0.6321,0.1414,0.6498,0.1477 Q0.661,0.1514,0.6667,0.1514 Q0.6707,0.1514,0.6771,0.1501 Q0.6787,0.1497,0.6795,0.1497 Q0.6835,0.1497,0.6863,0.1526 T0.6892,0.1593 Q0.6892,0.1626,0.6876,0.1647 Q0.6851,0.1672,0.6799,0.1686 T0.6695,0.1705 T0.6566,0.1715 T0.6458,0.1725 Q0.6434,0.173,0.6402,0.173 Q0.6378,0.173,0.6317,0.1727 T0.6225,0.1725 Q0.6096,0.1725,0.5984,0.1759 Q0.5823,0.1804,0.5454,0.1804 Q0.5205,0.1804,0.5116,0.1788 L0.5084,0.1788 Q0.5036,0.1788,0.4956,0.1819 T0.4843,0.185 Q0.4434,0.1887,0.4353,0.1929 Q0.4321,0.1945,0.4289,0.1945 T0.4197,0.1922 T0.4112,0.19 T0.4072,0.1912 Q0.4032,0.1949,0.388,0.1949 Q0.3663,0.1949,0.3542,0.19 Q0.351,0.1883,0.3462,0.1883 Q0.3406,0.1883,0.3321,0.1906 T0.3153,0.1954 T0.302,0.1983 Q0.2972,0.1991,0.2859,0.1997 T0.2643,0.201 T0.245,0.2024 T0.2337,0.2041 Q0.2321,0.2045,0.2181,0.2045 T0.1851,0.207 T0.1542,0.2157 Q0.143,0.2211,0.143,0.226 Q0.143,0.2314,0.153,0.2348 T0.1719,0.2381 Q0.1791,0.2381,0.2474,0.2476 Q0.2506,0.248,0.2558,0.2489 T0.2651,0.2505 T0.2739,0.252 T0.2819,0.2526 Q0.2835,0.2526,0.2851,0.2522 L0.2859,0.2522 Q0.2948,0.2522,0.3104,0.2574 T0.3309,0.2671 Q0.3333,0.2696,0.3365,0.2696 Q0.339,0.2696,0.3442,0.2684 T0.3526,0.2671 T0.3582,0.2679 Q0.3687,0.2717,0.3968,0.2742 Q0.4,0.2746,0.4036,0.2771 T0.4096,0.2796 Q0.4112,0.2796,0.4137,0.2787 Q0.4169,0.2779,0.4257,0.2779 Q0.4594,0.2779,0.4779,0.2849 Q0.4876,0.2891,0.4972,0.2891 Q0.4996,0.2891,0.506,0.2887 T0.5165,0.2883 Q0.5253,0.2883,0.5305,0.2889 T0.541,0.292 T0.5494,0.299 L0.5494,0.3015 Q0.5494,0.3036,0.5466,0.3051 T0.5386,0.3073 T0.5285,0.3086 T0.5181,0.3094 T0.5108,0.3102 Q0.5068,0.3107,0.494,0.3121 L0.4683,0.315 T0.4506,0.3181 Q0.449,0.3181,0.4426,0.32 T0.4313,0.3229 T0.4197,0.3256 T0.4064,0.3281 T0.3952,0.3289 Q0.3888,0.3289,0.3855,0.3273 Q0.3783,0.3243,0.3703,0.3243 Q0.3598,0.3243,0.351,0.3297 Q0.3478,0.3314,0.3422,0.3314 Q0.3398,0.3314,0.3337,0.3306 T0.3245,0.3297 T0.3189,0.3306 Q0.3149,0.3314,0.2956,0.3328 T0.2715,0.3368 Q0.2691,0.338,0.2635,0.3391 T0.2522,0.3407 T0.2406,0.3424 T0.2313,0.3447 Q0.2305,0.3447,0.2213,0.348 T0.206,0.354 T0.1924,0.3621 T0.1815,0.3733 Q0.1767,0.3816,0.1767,0.3849 Q0.1767,0.387,0.1783,0.3893 T0.1847,0.3961 T0.1936,0.4063 T0.2004,0.4181 T0.2052,0.4264 T0.2145,0.4309 T0.2386,0.4359 Q0.2458,0.4372,0.2554,0.4372 Q0.2578,0.4372,0.2627,0.437 T0.2699,0.4367 Q0.2795,0.4367,0.2851,0.4384 Q0.294,0.4409,0.3092,0.4409 Q0.3116,0.4409,0.3157,0.4407 T0.3213,0.4405 Q0.3301,0.4405,0.3466,0.444 T0.3687,0.4509 Q0.3703,0.4517,0.3703,0.4525 Q0.3703,0.4575,0.3373,0.4596 Q0.3133,0.4608,0.2988,0.4658 Q0.294,0.4674,0.2803,0.4674 Q0.2763,0.4674,0.2687,0.4672 T0.257,0.467 Q0.2402,0.467,0.2313,0.4687 Q0.2209,0.4708,0.2209,0.4737 Q0.2209,0.4741,0.2213,0.4749 T0.2229,0.4764 L0.2249,0.4774 T0.2265,0.4778 L0.2273,0.4782 Q0.2498,0.4803,0.2618,0.4803 Q0.2667,0.4803,0.2691,0.4799 Q0.2699,0.4795,0.2715,0.4795 Q0.2779,0.4795,0.3133,0.4873 Q0.3181,0.4886,0.3233,0.4892 T0.3386,0.4905 T0.3542,0.4915 T0.3655,0.4919 Q0.3703,0.4919,0.3779,0.4915 T0.3888,0.4911 T0.3952,0.4915 Q0.3976,0.4919,0.4008,0.4927 L0.4072,0.4944 T0.4149,0.4961 T0.4249,0.4975 T0.4369,0.4985 Q0.449,0.499,0.4554,0.5 T0.4651,0.5031 T0.4699,0.5085 Q0.4707,0.5093,0.4707,0.5097 Q0.4707,0.5114,0.4687,0.5124 T0.4631,0.5139 T0.4562,0.5145 T0.4478,0.5147 L0.4402,0.5147 Q0.4353,0.5151,0.4265,0.5174 T0.4096,0.5197 L0.4024,0.5197 Q0.4,0.5193,0.3968,0.5193 Q0.3896,0.5193,0.3831,0.5209 T0.3703,0.5253 T0.3598,0.5288 Q0.3558,0.5301,0.3321,0.5342 T0.302,0.5409 Q0.2876,0.5454,0.2337,0.55 Q0.2112,0.5521,0.2112,0.5558 Q0.2112,0.5574,0.2161,0.5612 Q0.2201,0.5637,0.2281,0.5637 Q0.2305,0.5637,0.2361,0.5633 T0.2442,0.5628 Q0.2474,0.5628,0.2498,0.5633 Q0.2635,0.5653,0.3133,0.5653 Q0.3261,0.5653,0.3301,0.5649 L0.3325,0.5649 Q0.3349,0.5649,0.3402,0.5657 T0.3494,0.5666 Q0.3542,0.5666,0.3598,0.5657 Q0.3663,0.5645,0.3695,0.5645 Q0.3735,0.5645,0.3775,0.5666 T0.3847,0.5695 Q0.3888,0.5707,0.3912,0.5709 T0.3968,0.5711 T0.4048,0.572 Q0.4096,0.5724,0.4165,0.5726 T0.4281,0.5734 T0.4378,0.5757 Q0.4418,0.5774,0.4522,0.5774 Q0.4562,0.5774,0.4655,0.5769 T0.4795,0.5765 Q0.4932,0.5765,0.4972,0.579 Q0.5028,0.5819,0.51,0.5819 Q0.5141,0.5819,0.5221,0.5809 T0.5341,0.5798 L0.5373,0.5798 Q0.5422,0.5798,0.557,0.5821 T0.5855,0.5844 L0.5936,0.5844 L0.5992,0.5844 T0.604,0.5848 T0.6076,0.5852 T0.6108,0.5859 T0.6137,0.5865 T0.6161,0.5873 T0.6181,0.5881 T0.6209,0.5896 L0.6233,0.591 Q0.6265,0.5927,0.6353,0.5927 L0.6402,0.5927 L0.645,0.5927 Q0.6723,0.5927,0.6948,0.6039 Q0.6988,0.606,0.7036,0.606 Q0.7076,0.606,0.7153,0.6045 T0.7261,0.6031 Q0.7309,0.6031,0.7454,0.6027 T0.7647,0.6022 Q0.7783,0.6022,0.808,0.608 L0.812,0.608 Q0.8169,0.608,0.8293,0.6062 T0.8474,0.6039 L0.8506,0.6039 Q0.857,0.6039,0.8655,0.6049 T0.8835,0.6074 T0.8972,0.6093 Q0.9036,0.6101,0.9213,0.6101 L0.9398,0.6101 L0.959,0.6101 L0.9767,0.6101 Q0.9976,0.6109,0.9976,0.6176 Q0.9976,0.6188,0.9968,0.6226 Q0.9952,0.6284,0.9671,0.6284 L0.959,0.6284 L0.9526,0.6284 Q0.9486,0.6284,0.9382,0.6302 T0.9205,0.6321 L0.9173,0.6321 Q0.9133,0.6317,0.9092,0.6317 Q0.9012,0.6317,0.8715,0.6346 Q0.8233,0.6387,0.7944,0.6421 Q0.7888,0.6429,0.7831,0.6429 Q0.7783,0.6429,0.7731,0.6425 T0.7663,0.6421 L0.7622,0.6421 Q0.7614,0.6425,0.7586,0.6425 T0.7474,0.6421 T0.7349,0.6416 Q0.7261,0.6416,0.7221,0.6429 Q0.7173,0.645,0.7032,0.646 T0.6711,0.6479 T0.6482,0.6491 Q0.645,0.6495,0.6418,0.6495 Q0.6353,0.6495,0.6273,0.6474 T0.6161,0.6454 Q0.612,0.6454,0.6088,0.6477 T0.6,0.6499 Q0.5912,0.6499,0.5494,0.6578 Q0.5422,0.6591,0.5373,0.6591 Q0.5341,0.6591,0.5281,0.6584 T0.5173,0.6578 L0.5124,0.6578 Q0.5004,0.6582,0.4747,0.6632 Q0.4675,0.6649,0.4398,0.6667 T0.3851,0.6703 T0.3566,0.6719 Q0.3534,0.6723,0.3406,0.6734 T0.3141,0.6757 T0.2948,0.6773 Q0.2908,0.6781,0.2819,0.6829 T0.2618,0.6877 Q0.2482,0.6877,0.2273,0.6958 T0.1992,0.7117 Q0.1976,0.7138,0.1976,0.7155 Q0.1976,0.7188,0.2032,0.7213 T0.2181,0.7258 T0.2289,0.7292 Q0.2337,0.7308,0.2378,0.7316 L0.2458,0.7333 T0.2522,0.7345 Q0.2747,0.7399,0.2835,0.7399 Q0.29,0.7399,0.3048,0.7408 T0.3253,0.7416 Q0.3277,0.7416,0.3297,0.7414 T0.3341,0.7412 L0.3598,0.7445 Q0.3639,0.7449,0.3663,0.7449 Q0.3695,0.7449,0.3751,0.7443 T0.3855,0.7437 L0.3904,0.7437 Q0.3984,0.7441,0.4141,0.7472 T0.4353,0.7507 Q0.4434,0.752,0.4434,0.7553 Q0.4434,0.7578,0.439,0.7605 T0.4297,0.764 Q0.4257,0.7648,0.4201,0.7655 T0.4076,0.7665 T0.3984,0.7673 Q0.3968,0.7673,0.3912,0.7677 T0.3815,0.7688 T0.3735,0.771 T0.3655,0.7727 Q0.3606,0.7727,0.3534,0.7708 T0.3458,0.769 L0.3446,0.769 Q0.3414,0.769,0.3297,0.7713 T0.3149,0.7735 Q0.3092,0.7735,0.296,0.7771 T0.2771,0.7831 Q0.2683,0.7872,0.2554,0.7885 Q0.253,0.7889,0.2325,0.7897 T0.2032,0.7914 Q0.2008,0.7918,0.198,0.792 T0.194,0.7924 T0.1912,0.7928 T0.1888,0.793 T0.1867,0.7934 T0.1851,0.7943 T0.1843,0.7953 T0.1835,0.7968 T0.1823,0.7984 T0.1815,0.8001 Q0.1815,0.8022,0.1847,0.8032 T0.1932,0.8053 T0.2008,0.8071 Q0.2072,0.8092,0.2265,0.8092 Q0.2361,0.8092,0.2586,0.8088 L0.2635,0.8088 Q0.2731,0.8088,0.2795,0.8098 T0.2928,0.8134 T0.302,0.8167 Q0.306,0.8179,0.3277,0.8183 T0.3542,0.8221 Q0.359,0.8246,0.3622,0.8246 Q0.3639,0.8246,0.3675,0.8237 T0.3751,0.8229 Q0.3968,0.8229,0.4048,0.8275 Q0.4088,0.8291,0.4161,0.8291 Q0.4225,0.8291,0.4353,0.8275 Q0.4369,0.827,0.4394,0.827 Q0.4474,0.827,0.4675,0.8345 Q0.4707,0.8358,0.4739,0.8358 Q0.4755,0.8358,0.4799,0.8353 T0.4876,0.8349 Q0.494,0.8349,0.5012,0.8362 L0.5076,0.837 T0.5133,0.8376 T0.5181,0.8382 T0.5221,0.8391 L0.5253,0.8399 T0.5277,0.8409 L0.5293,0.8422 T0.5301,0.8438 L0.5301,0.8461 Q0.5301,0.8499,0.5249,0.8511 T0.5112,0.8526 T0.5004,0.8532 Q0.4964,0.854,0.4851,0.8546 T0.4667,0.8565 Q0.4578,0.8577,0.441,0.8577 L0.4345,0.8577 L0.4289,0.8577 L0.4209,0.8577 Q0.4153,0.8582,0.4088,0.8586 T0.3968,0.8592 T0.3855,0.8594 T0.3755,0.8596 T0.3675,0.86 T0.3622,0.8602 Q0.3317,0.8635,0.3237,0.8635 Q0.2996,0.8635,0.2996,0.8681 Q0.2996,0.8698,0.3032,0.8733 T0.3068,0.8797 L0.3068,0.8822 Q0.3052,0.8859,0.2859,0.8859 Q0.2787,0.8859,0.2739,0.8851 L0.2699,0.8851 Q0.2659,0.8851,0.259,0.888 T0.2498,0.8913 Q0.2394,0.8946,0.2056,0.8971 Q0.2032,0.8971,0.1928,0.9002 T0.1703,0.9034 Q0.1526,0.9034,0.1353,0.9067 T0.1173,0.915 L0.1173,0.9158 Q0.1173,0.9166,0.1177,0.9175 T0.1189,0.9191 T0.1205,0.9204 T0.1229,0.9212 T0.1257,0.922 T0.1285,0.9226 T0.1309,0.9231 T0.1337,0.9235 T0.1365,0.9237 L0.1446,0.9237 T0.1554,0.9243 T0.1614,0.9268 T0.1659,0.9293 T0.1743,0.9303 T0.1823,0.9316 Q0.1863,0.932,0.1912,0.9332 T0.2028,0.9361 T0.2153,0.939 Q0.2233,0.9411,0.2297,0.9448 T0.2386,0.9494 Q0.2426,0.9506,0.2506,0.9506 Q0.253,0.9506,0.2594,0.9504 T0.2699,0.9502 Q0.2763,0.9502,0.2819,0.9511 Q0.2851,0.9511,0.2871,0.9529 T0.2892,0.9573 Q0.2892,0.9627,0.2811,0.9635 Q0.2434,0.9652,0.2337,0.9672 Q0.2257,0.9693,0.2241,0.9693 Q0.2217,0.9693,0.2096,0.9689 L0.2056,0.9689 Q0.1976,0.9689,0.1924,0.9699 T0.1787,0.9741 L0.1647,0.9793 Q0.1518,0.983,0.1285,0.983 L0.1261,0.983 L0.1237,0.983 Q0.1124,0.983,0.1076,0.9838 Q0.102,0.9851,0.0839,0.9896 T0.0602,0.9954 T0.0406,0.9971 T0.0153,0.9979 L0.0032,0.9979 Z",type:0}},"":{type:5,data:{d:"M0.9992,0.998 Q0.9992,1,0.9968,1 Q0.9521,1,0.9392,0.998 Q0.9335,0.997,0.9152,0.9921 T0.8913,0.9862 Q0.8873,0.9852,0.8783,0.9852 L0.8747,0.9852 L0.871,0.9852 Q0.8483,0.9852,0.8345,0.9812 Q0.8289,0.9792,0.8228,0.9773 T0.8135,0.9743 T0.8054,0.9723 T0.7948,0.9713 L0.7908,0.9713 L0.777,0.9713 T0.7656,0.9693 Q0.7616,0.9683,0.7498,0.9674 T0.7283,0.9664 L0.7186,0.9654 Q0.708,0.9644,0.708,0.9575 Q0.708,0.9545,0.7109,0.952 T0.7178,0.9486 L0.7315,0.9486 L0.7417,0.9486 L0.7502,0.9486 Q0.7575,0.9486,0.7599,0.9476 Q0.7616,0.9466,0.7685,0.9426 T0.7843,0.9377 Q0.7899,0.9357,0.8009,0.9332 T0.8175,0.9298 Q0.82,0.9288,0.8228,0.9283 T0.8277,0.9278 T0.8313,0.9273 T0.8341,0.9263 T0.8362,0.9258 Q0.8402,0.9219,0.854,0.9219 L0.8569,0.9219 L0.8597,0.9219 L0.8637,0.9219 Q0.88,0.9199,0.88,0.9159 L0.88,0.9149 Q0.88,0.913,0.8719,0.911 T0.852,0.9075 T0.8297,0.906 Q0.8224,0.906,0.8167,0.905 T0.8074,0.9031 T0.8001,0.9006 T0.794,0.8991 Q0.7599,0.8971,0.7494,0.8942 Q0.7461,0.8932,0.7397,0.8902 T0.7299,0.8872 L0.7267,0.8872 Q0.721,0.8882,0.7121,0.8882 Q0.6926,0.8882,0.691,0.8833 L0.691,0.8803 Q0.691,0.8773,0.6922,0.8749 T0.6955,0.8704 L0.6975,0.8684 Q0.6926,0.8655,0.6764,0.8655 Q0.6683,0.8655,0.6375,0.8625 Q0.6358,0.8625,0.629,0.862 T0.6148,0.8615 T0.5973,0.861 T0.5791,0.8605 L0.5718,0.8605 L0.5661,0.8605 L0.5596,0.8605 Q0.5426,0.8605,0.5337,0.8586 Q0.5264,0.8576,0.515,0.8571 T0.4996,0.8556 Q0.498,0.8556,0.4947,0.8551 T0.4882,0.8546 T0.4809,0.8541 T0.474,0.8531 T0.4692,0.8506 T0.4672,0.8467 Q0.4672,0.8437,0.468,0.8422 T0.4704,0.8398 T0.4736,0.8383 T0.4781,0.8368 T0.4838,0.8358 T0.4911,0.8353 T0.4988,0.8338 Q0.5069,0.8328,0.5142,0.8328 Q0.5174,0.8328,0.5215,0.8333 T0.5264,0.8338 Q0.5296,0.8338,0.532,0.8328 Q0.5523,0.8249,0.5604,0.8249 L0.5653,0.8249 Q0.5775,0.8269,0.5848,0.8269 Q0.5912,0.8269,0.5937,0.8259 Q0.6026,0.821,0.6253,0.821 Q0.6294,0.821,0.6334,0.822 T0.6383,0.8229 Q0.6399,0.8229,0.644,0.82 Q0.6504,0.817,0.6723,0.816 T0.6975,0.814 Q0.6999,0.814,0.7048,0.8121 T0.7129,0.8091 T0.7226,0.8071 T0.7372,0.8061 L0.7421,0.8061 Q0.7624,0.8071,0.7721,0.8071 Q0.7924,0.8071,0.7981,0.8051 Q0.8021,0.8032,0.807,0.8027 T0.8135,0.8017 T0.8151,0.8002 L0.8151,0.7992 Q0.8143,0.7962,0.8127,0.7957 T0.8045,0.7943 Q0.7997,0.7943,0.7964,0.7933 Q0.7883,0.7933,0.7676,0.7923 T0.7437,0.7903 Q0.7307,0.7893,0.7218,0.7844 Q0.7194,0.7834,0.7141,0.7819 L0.7036,0.7789 T0.693,0.7765 T0.6853,0.7755 Q0.6805,0.7755,0.6691,0.773 T0.6553,0.7705 Q0.6545,0.7705,0.6545,0.7715 Q0.6537,0.7715,0.65,0.7725 T0.6423,0.774 T0.635,0.7745 Q0.6294,0.7745,0.6257,0.773 T0.618,0.771 T0.6083,0.77 T0.601,0.7695 Q0.5985,0.7695,0.5921,0.769 T0.5795,0.7676 T0.5702,0.7666 Q0.5653,0.7656,0.5596,0.7616 T0.5539,0.7547 Q0.5539,0.7498,0.5645,0.7488 Q0.5693,0.7478,0.5852,0.7448 T0.6099,0.7418 L0.6148,0.7418 Q0.6196,0.7418,0.6253,0.7423 T0.6338,0.7428 L0.6399,0.7428 Q0.6431,0.7418,0.6488,0.7409 T0.6586,0.7394 T0.6659,0.7389 L0.6707,0.7389 Q0.6723,0.7399,0.6748,0.7399 Q0.6796,0.7399,0.6946,0.7389 T0.7161,0.7379 Q0.7251,0.7379,0.7478,0.7319 Q0.7494,0.7319,0.7539,0.7315 T0.762,0.73 T0.7697,0.727 T0.7818,0.723 T0.7948,0.7196 T0.7997,0.7151 Q0.7997,0.7141,0.7989,0.7132 Q0.7924,0.7062,0.7717,0.6978 T0.738,0.6894 Q0.7267,0.6894,0.717,0.6845 T0.7048,0.6795 Q0.6975,0.6785,0.6711,0.6766 T0.6431,0.6746 Q0.6415,0.6736,0.6144,0.6721 T0.5596,0.6686 T0.5247,0.6657 Q0.4996,0.6607,0.4874,0.6597 L0.4834,0.6597 Q0.4785,0.6597,0.4724,0.6607 T0.4631,0.6617 Q0.4574,0.6617,0.4501,0.6597 Q0.4088,0.6518,0.4006,0.6518 Q0.3933,0.6518,0.3901,0.6499 T0.3844,0.6479 T0.3739,0.6499 T0.3585,0.6518 L0.352,0.6518 Q0.3471,0.6508,0.335,0.6503 T0.3122,0.6494 T0.2912,0.6479 T0.2766,0.6449 Q0.2733,0.6439,0.2668,0.6439 Q0.2628,0.6439,0.2543,0.6444 T0.2425,0.6449 T0.2368,0.6439 L0.2344,0.6439 Q0.2336,0.6439,0.2283,0.6444 T0.2182,0.6449 Q0.2117,0.6449,0.2052,0.6439 Q0.1768,0.6409,0.1281,0.637 Q0.0989,0.634,0.0916,0.634 L0.0835,0.634 L0.0795,0.634 Q0.0722,0.634,0.0616,0.632 T0.0479,0.6301 Q0.0462,0.6301,0.0406,0.6306 T0.0308,0.6311 Q0.0032,0.6311,0.0008,0.6231 Q0,0.6202,0,0.6182 Q0,0.6083,0.0227,0.6083 Q0.03,0.6073,0.0422,0.6073 Q0.0487,0.6073,0.0608,0.6078 T0.0787,0.6083 Q0.0973,0.6083,0.103,0.6073 Q0.1062,0.6063,0.1131,0.6053 T0.1253,0.6039 T0.1375,0.6024 T0.1492,0.6014 L0.1533,0.6014 Q0.1598,0.6024,0.1723,0.6044 T0.189,0.6063 Q0.1906,0.6063,0.1922,0.6053 Q0.2214,0.6004,0.236,0.6004 Q0.2409,0.6004,0.2551,0.6009 T0.2741,0.6014 Q0.2782,0.6014,0.2859,0.6024 T0.2968,0.6034 Q0.3009,0.6034,0.3041,0.6024 Q0.3277,0.5905,0.356,0.5905 L0.3613,0.5905 L0.3666,0.5905 Q0.3731,0.5905,0.3755,0.5895 Q0.382,0.5856,0.3844,0.5846 T0.3938,0.5831 T0.4144,0.5826 T0.4428,0.5801 T0.4631,0.5776 L0.4663,0.5776 Q0.4704,0.5776,0.4785,0.5786 T0.4899,0.5796 Q0.4964,0.5796,0.5012,0.5767 Q0.5069,0.5737,0.5223,0.5737 Q0.5272,0.5737,0.5369,0.5742 T0.5499,0.5747 Q0.558,0.5747,0.5612,0.5737 Q0.5661,0.5717,0.5714,0.5712 T0.5835,0.5702 T0.5945,0.5692 T0.6018,0.5687 L0.6062,0.5687 T0.6095,0.5682 T0.6148,0.5678 Q0.6172,0.5668,0.6196,0.5653 T0.6245,0.5633 T0.631,0.5628 T0.6407,0.5638 T0.6504,0.5648 T0.6594,0.5638 T0.6675,0.5628 L0.6707,0.5628 L0.6861,0.5628 Q0.7364,0.5628,0.7494,0.5608 L0.7567,0.5608 L0.7652,0.5608 L0.7729,0.5608 Q0.7794,0.5608,0.7818,0.5589 Q0.7851,0.5569,0.7859,0.5559 Q0.7835,0.5539,0.7656,0.5519 Q0.7121,0.547,0.6975,0.543 Q0.6934,0.541,0.6853,0.5396 L0.6691,0.5366 T0.6525,0.5336 T0.6391,0.5312 Q0.6367,0.5302,0.6245,0.5257 T0.6034,0.5213 L0.5977,0.5213 Q0.5945,0.5223,0.5904,0.5223 Q0.5839,0.5223,0.5787,0.5208 T0.5685,0.5183 T0.5596,0.5173 Q0.558,0.5173,0.5552,0.5168 T0.5495,0.5163 L0.5434,0.5163 T0.5373,0.5158 T0.532,0.5148 T0.5284,0.5129 T0.5272,0.5104 L0.5272,0.5074 Q0.5304,0.5015,0.5377,0.499 T0.5629,0.4965 Q0.5734,0.4955,0.5811,0.4946 T0.5953,0.4916 T0.605,0.4896 Q0.6083,0.4886,0.6123,0.4886 Q0.6148,0.4886,0.6225,0.4891 T0.635,0.4896 L0.6456,0.4896 Q0.6837,0.4857,0.6861,0.4857 Q0.7226,0.4768,0.7283,0.4768 Q0.7307,0.4768,0.732,0.4773 T0.7372,0.4777 Q0.7502,0.4777,0.7721,0.4758 Q0.7753,0.4748,0.777,0.4738 Q0.7745,0.4718,0.768,0.4708 Q0.7599,0.4688,0.7445,0.4688 Q0.7405,0.4688,0.7324,0.4693 T0.721,0.4698 Q0.7056,0.4698,0.6999,0.4679 Q0.6861,0.4629,0.6626,0.4619 Q0.6586,0.4609,0.6533,0.4604 T0.6419,0.459 T0.6314,0.456 T0.6269,0.452 Q0.6269,0.451,0.6302,0.4491 Q0.6358,0.4451,0.6525,0.4416 T0.6788,0.4382 L0.6845,0.4382 L0.6902,0.4382 Q0.7064,0.4382,0.7145,0.4362 Q0.7202,0.4342,0.7307,0.4342 L0.7356,0.4342 L0.7409,0.4342 L0.7453,0.4342 Q0.7543,0.4342,0.7607,0.4332 Q0.7778,0.4313,0.7847,0.4288 T0.7932,0.4248 T0.7972,0.4169 T0.8045,0.4045 L0.8094,0.3986 T0.8135,0.3942 L0.8167,0.3912 T0.8191,0.3887 T0.8204,0.3867 T0.8208,0.3848 Q0.8208,0.3818,0.8167,0.3739 Q0.8127,0.3689,0.8054,0.3635 T0.7924,0.3556 T0.7778,0.3497 T0.768,0.3462 Q0.764,0.3442,0.7478,0.3427 T0.7267,0.3383 Q0.7234,0.3363,0.7044,0.3348 T0.6805,0.3323 L0.6764,0.3323 T0.6679,0.3328 T0.6586,0.3333 Q0.6521,0.3333,0.648,0.3314 Q0.6391,0.3264,0.6294,0.3264 Q0.6229,0.3264,0.6156,0.3294 Q0.6115,0.3304,0.6042,0.3304 Q0.5977,0.3304,0.5888,0.3289 T0.5738,0.3264 T0.5584,0.3225 L0.5491,0.3195 Q0.5418,0.3185,0.5162,0.3155 T0.4895,0.3121 T0.4826,0.3116 T0.4716,0.3111 T0.4607,0.3096 T0.4513,0.3066 T0.4477,0.3017 Q0.4477,0.2997,0.4485,0.2977 Q0.4526,0.2898,0.4611,0.2878 T0.4842,0.2859 Q0.4882,0.2859,0.4943,0.2864 T0.5028,0.2868 Q0.5118,0.2868,0.5215,0.2829 Q0.5401,0.276,0.5734,0.276 Q0.5831,0.276,0.5872,0.277 L0.5904,0.277 T0.5949,0.2745 T0.6034,0.272 Q0.631,0.269,0.6407,0.2661 Q0.6448,0.2641,0.6488,0.2641 T0.6573,0.2656 T0.6634,0.2671 Q0.6659,0.2671,0.6675,0.2651 Q0.6723,0.2601,0.6886,0.2552 T0.7137,0.2502 L0.7153,0.2502 L0.7178,0.2502 Q0.7218,0.2502,0.7279,0.2493 T0.7417,0.2468 T0.7526,0.2453 Q0.8208,0.2354,0.8281,0.2354 Q0.8337,0.2354,0.8394,0.2344 T0.8496,0.2315 T0.854,0.2265 Q0.854,0.2216,0.8443,0.2176 Q0.8354,0.2127,0.8216,0.2102 T0.7972,0.2072 T0.777,0.2067 T0.7648,0.2057 Q0.7632,0.2047,0.7498,0.2038 T0.7202,0.2018 T0.6983,0.1998 Q0.6918,0.1998,0.676,0.1949 T0.6537,0.1899 Q0.6496,0.1899,0.6472,0.1919 Q0.6342,0.1968,0.6123,0.1968 Q0.5961,0.1968,0.5912,0.1929 Q0.5904,0.1919,0.5892,0.1919 T0.5823,0.1944 T0.5722,0.1968 T0.5637,0.1949 Q0.5556,0.1909,0.5158,0.1869 Q0.5109,0.1869,0.5032,0.1835 T0.4915,0.18 Q0.4907,0.18,0.4891,0.181 Q0.4793,0.182,0.455,0.182 Q0.4177,0.182,0.4015,0.1771 Q0.3901,0.1741,0.3779,0.1741 Q0.3747,0.1741,0.369,0.1746 T0.3609,0.1751 Q0.3569,0.1751,0.3536,0.1741 Q0.3512,0.1741,0.3459,0.1736 T0.3358,0.1726 T0.3256,0.1716 T0.3167,0.1696 T0.3106,0.1662 Q0.3082,0.1632,0.3082,0.1592 Q0.3082,0.1543,0.3114,0.1508 T0.3204,0.1474 L0.3236,0.1474 Q0.3301,0.1494,0.3333,0.1494 Q0.339,0.1494,0.3496,0.1454 Q0.3674,0.1385,0.3869,0.1385 Q0.395,0.1385,0.4011,0.137 T0.4116,0.1355 T0.4197,0.1375 T0.425,0.1395 Q0.429,0.1395,0.4355,0.1365 Q0.4631,0.1266,0.4882,0.1266 Q0.5126,0.1266,0.5337,0.1246 Q0.5369,0.1246,0.5458,0.1207 T0.5661,0.1167 L0.5693,0.1167 Q0.5791,0.1177,0.5852,0.1187 T0.5921,0.1197 Q0.5945,0.1197,0.6002,0.1167 Q0.6026,0.1147,0.605,0.1123 T0.6091,0.1093 T0.6156,0.1088 T0.6318,0.1098 Q0.6456,0.1108,0.6569,0.1137 T0.6707,0.1167 Q0.674,0.1167,0.6772,0.1147 Q0.6821,0.1108,0.6946,0.1083 T0.721,0.1044 T0.7453,0.1029 L0.7526,0.1029 Q0.7583,0.1039,0.7652,0.1053 T0.7753,0.1068 Q0.7778,0.1068,0.7802,0.1058 Q0.7981,0.1019,0.8143,0.1019 Q0.8175,0.1019,0.8439,0.0964 T0.8735,0.091 Q0.8759,0.091,0.8836,0.089 T0.8938,0.0851 Q0.8929,0.0841,0.8905,0.0841 Q0.8832,0.0821,0.8735,0.0821 Q0.8694,0.0821,0.8629,0.0826 T0.854,0.0831 Q0.8508,0.0831,0.8491,0.0821 Q0.8475,0.0821,0.8171,0.0811 T0.7802,0.0781 T0.7571,0.0737 T0.7332,0.0712 Q0.7299,0.0712,0.7247,0.0717 T0.7161,0.0722 L0.7064,0.0722 Q0.7032,0.0712,0.7003,0.0707 T0.6959,0.0692 T0.693,0.0678 T0.6914,0.0663 T0.6902,0.0648 T0.689,0.0643 L0.6869,0.0643 L0.6845,0.0643 L0.6821,0.0643 Q0.6553,0.0643,0.6553,0.0554 T0.6796,0.0465 L0.6813,0.0465 L0.6845,0.0465 Q0.6918,0.0425,0.717,0.0376 Q0.7226,0.0366,0.7267,0.0356 T0.7324,0.0336 T0.7376,0.0317 T0.747,0.0297 Q0.7518,0.0287,0.7551,0.0287 T0.762,0.0297 T0.768,0.0307 L0.7729,0.0307 Q0.7802,0.0277,0.7997,0.0267 T0.8224,0.0237 Q0.8273,0.0227,0.8341,0.0223 T0.8475,0.0193 T0.8654,0.0143 T0.8873,0.0079 Q0.9002,0.003,0.9331,0.004 T0.97,0.004 Q0.9838,0,0.9976,0.001 Q1,0.001,1,0.003 Z M0.9935,0.996 L0.9951,0.0049 Q0.9822,0.0049,0.9716,0.0079 Q0.9659,0.0099,0.9327,0.0089 T0.8897,0.0119 Q0.8775,0.0158,0.8666,0.0183 T0.85,0.0237 Q0.8418,0.0267,0.8341,0.0272 T0.8248,0.0277 Q0.82,0.0297,0.8001,0.0312 T0.7745,0.0346 Q0.7697,0.0356,0.7664,0.0356 Q0.764,0.0356,0.7603,0.0341 T0.7534,0.0326 Q0.751,0.0326,0.7478,0.0336 Q0.7429,0.0346,0.7397,0.0356 T0.7344,0.0376 T0.7283,0.0401 T0.7178,0.0425 Q0.6926,0.0465,0.6878,0.0495 Q0.6845,0.0514,0.6764,0.0514 L0.6723,0.0514 L0.6691,0.0514 Q0.6602,0.0514,0.6602,0.0554 Q0.6602,0.0574,0.6659,0.0579 T0.6796,0.0589 T0.691,0.0603 T0.6967,0.0643 T0.7072,0.0673 Q0.7121,0.0682,0.7153,0.0682 T0.7238,0.0678 T0.7332,0.0673 Q0.7413,0.0673,0.7579,0.0692 T0.7818,0.0742 Q0.7867,0.0752,0.8171,0.0762 T0.8508,0.0781 L0.852,0.0781 T0.8601,0.0776 T0.8719,0.0772 Q0.8832,0.0772,0.8921,0.0791 Q0.8994,0.0811,0.8994,0.0841 T0.8933,0.0895 T0.8812,0.094 T0.8735,0.0959 T0.8451,0.1014 T0.8143,0.1068 Q0.7989,0.1068,0.7818,0.1098 Q0.7778,0.1108,0.7745,0.1108 T0.768,0.1103 T0.7603,0.1088 T0.7518,0.1068 L0.7461,0.1068 Q0.7315,0.1068,0.7088,0.1103 T0.6805,0.1177 Q0.6756,0.1207,0.6699,0.1207 Q0.6667,0.1207,0.6545,0.1177 T0.631,0.1147 Q0.6269,0.1137,0.6225,0.1133 T0.616,0.1128 L0.6123,0.1128 T0.6103,0.1133 L0.6083,0.1157 T0.6034,0.1197 Q0.5961,0.1246,0.5921,0.1246 Q0.5904,0.1246,0.5835,0.1231 T0.5693,0.1217 L0.5661,0.1217 Q0.558,0.1217,0.5535,0.1231 T0.5446,0.1266 T0.5345,0.1296 Q0.5126,0.1316,0.4882,0.1316 T0.438,0.1405 Q0.4298,0.1434,0.425,0.1434 Q0.4209,0.1434,0.4173,0.1419 T0.4112,0.1405 T0.4027,0.1419 T0.3869,0.1434 Q0.3682,0.1434,0.3512,0.1494 Q0.3398,0.1533,0.3333,0.1533 Q0.3285,0.1533,0.3228,0.1513 L0.3212,0.1513 Q0.3179,0.1513,0.3155,0.1538 T0.3131,0.1592 Q0.3131,0.1612,0.3147,0.1632 Q0.3171,0.1652,0.3232,0.1667 T0.3406,0.1691 T0.3544,0.1701 L0.3601,0.1701 L0.3678,0.1701 L0.3771,0.1701 Q0.3909,0.1701,0.4031,0.1731 Q0.4177,0.178,0.4558,0.178 Q0.4793,0.178,0.4882,0.1761 L0.4915,0.1761 Q0.498,0.1761,0.5061,0.179 T0.5158,0.183 Q0.5166,0.183,0.5231,0.1835 T0.5341,0.1845 T0.545,0.1855 T0.5572,0.1874 T0.5661,0.1909 Q0.5677,0.1919,0.5702,0.1919 T0.5791,0.1894 T0.588,0.1869 Q0.5921,0.1869,0.5945,0.1899 Q0.5977,0.1919,0.6123,0.1919 Q0.6334,0.1919,0.6448,0.1879 Q0.6488,0.186,0.6537,0.186 Q0.6626,0.186,0.6784,0.1909 T0.6983,0.1958 Q0.704,0.1968,0.7206,0.1973 T0.7506,0.1993 T0.7689,0.2018 L0.7705,0.2018 L0.7741,0.2018 L0.7786,0.2018 Q0.8248,0.2018,0.8475,0.2136 Q0.8597,0.2196,0.8597,0.2255 T0.8483,0.2359 T0.8281,0.2404 Q0.8208,0.2404,0.7534,0.2493 Q0.7502,0.2502,0.7425,0.2512 T0.7287,0.2532 T0.7178,0.2542 L0.7153,0.2542 L0.7137,0.2542 Q0.7064,0.2542,0.6906,0.2591 T0.6715,0.2681 T0.6626,0.272 Q0.6594,0.272,0.6541,0.2705 T0.6464,0.269 T0.6431,0.27 Q0.6318,0.273,0.6034,0.276 Q0.6018,0.276,0.5998,0.2774 T0.5957,0.2799 T0.5904,0.2809 L0.5856,0.2809 Q0.5823,0.2799,0.575,0.2799 Q0.541,0.2799,0.5239,0.2868 Q0.5134,0.2908,0.5028,0.2908 Q0.4996,0.2908,0.4935,0.2903 T0.4842,0.2898 Q0.4704,0.2898,0.4635,0.2918 T0.4534,0.2997 L0.4534,0.3007 Q0.4534,0.3037,0.459,0.3046 T0.4753,0.3066 T0.4899,0.3076 Q0.4907,0.3076,0.5166,0.3106 T0.5507,0.3155 Q0.5921,0.3264,0.605,0.3264 Q0.6107,0.3264,0.6131,0.3254 Q0.6212,0.3225,0.6294,0.3225 Q0.6407,0.3225,0.6513,0.3274 Q0.6529,0.3294,0.6569,0.3294 Q0.6594,0.3294,0.665,0.3284 T0.6748,0.3274 T0.6821,0.3284 Q0.6861,0.3294,0.6967,0.3299 T0.7165,0.3314 T0.7299,0.3343 Q0.7324,0.3363,0.7486,0.3383 T0.7697,0.3422 Q0.7713,0.3432,0.7774,0.3452 T0.7887,0.3492 T0.8005,0.3546 T0.8127,0.3625 T0.8208,0.3719 Q0.8256,0.3798,0.8256,0.3848 Q0.8256,0.3877,0.8236,0.3902 T0.8171,0.3976 T0.809,0.4075 T0.8021,0.4189 T0.7968,0.4273 T0.7867,0.4322 T0.7616,0.4382 Q0.7543,0.4392,0.7437,0.4392 L0.7364,0.4392 L0.7299,0.4392 Q0.7202,0.4392,0.7161,0.4402 Q0.7072,0.4431,0.691,0.4431 L0.6845,0.4431 L0.6788,0.4431 Q0.6707,0.4431,0.6545,0.4461 T0.6334,0.452 Q0.6399,0.456,0.6626,0.457 Q0.6878,0.458,0.7024,0.4639 Q0.7064,0.4649,0.7186,0.4649 L0.7295,0.4649 L0.7413,0.4649 Q0.7591,0.4649,0.7697,0.4669 Q0.7818,0.4688,0.7818,0.4728 Q0.7818,0.4748,0.7798,0.4763 T0.7753,0.4787 L0.7737,0.4797 L0.7729,0.4797 Q0.7494,0.4827,0.7388,0.4827 Q0.7332,0.4827,0.7307,0.4817 L0.7291,0.4817 Q0.7226,0.4817,0.6878,0.4896 Q0.6829,0.4906,0.6772,0.4911 T0.6618,0.4921 T0.646,0.4931 T0.6342,0.4936 T0.6212,0.4931 T0.6115,0.4926 Q0.6083,0.4926,0.6058,0.4931 T0.5969,0.4955 T0.5819,0.499 T0.5629,0.5005 Q0.5572,0.5005,0.5527,0.501 T0.545,0.502 T0.5397,0.503 T0.5361,0.5045 T0.5337,0.5064 T0.5328,0.5094 L0.532,0.5094 Q0.532,0.5104,0.5337,0.5109 T0.5381,0.5114 T0.5438,0.5119 T0.5515,0.5124 L0.5604,0.5124 Q0.5661,0.5134,0.5746,0.5153 T0.5912,0.5173 L0.5977,0.5173 L0.6026,0.5173 Q0.6139,0.5173,0.6273,0.5218 T0.6407,0.5272 Q0.6448,0.5282,0.6683,0.5321 T0.6991,0.5381 Q0.7137,0.543,0.7664,0.548 Q0.7908,0.55,0.7908,0.5559 Q0.7908,0.5589,0.7859,0.5628 Q0.781,0.5658,0.7713,0.5658 Q0.7689,0.5658,0.7628,0.5653 T0.7543,0.5648 T0.7502,0.5658 Q0.7364,0.5678,0.6878,0.5678 Q0.674,0.5678,0.6699,0.5668 L0.6683,0.5668 Q0.6659,0.5668,0.6606,0.5678 T0.6513,0.5687 Q0.6464,0.5687,0.6391,0.5678 Q0.6334,0.5668,0.6302,0.5668 T0.6241,0.5687 T0.6164,0.5717 Q0.6123,0.5727,0.6099,0.5727 L0.6062,0.5727 T0.6022,0.5732 T0.5953,0.5737 Q0.5904,0.5747,0.5839,0.5747 T0.5726,0.5752 T0.5629,0.5776 T0.5458,0.5796 Q0.5418,0.5796,0.5324,0.5791 T0.5191,0.5786 Q0.5077,0.5786,0.5045,0.5806 Q0.498,0.5836,0.4899,0.5836 Q0.4858,0.5836,0.4777,0.5826 T0.4655,0.5816 L0.4631,0.5816 Q0.4582,0.5816,0.4436,0.5841 T0.4144,0.5865 L0.4051,0.5865 L0.3986,0.5865 T0.3933,0.587 T0.3897,0.5875 T0.3869,0.5885 T0.3844,0.5895 T0.3812,0.591 T0.3779,0.5925 Q0.3739,0.5955,0.3633,0.5955 L0.3585,0.5955 L0.3536,0.5955 Q0.3277,0.5955,0.3066,0.6053 Q0.3017,0.6083,0.296,0.6083 Q0.2912,0.6083,0.2839,0.6068 T0.2741,0.6053 Q0.2693,0.6053,0.2547,0.6048 T0.236,0.6044 Q0.2222,0.6044,0.193,0.6103 L0.1882,0.6103 Q0.1825,0.6103,0.1703,0.6083 T0.1525,0.6063 L0.15,0.6063 Q0.1436,0.6063,0.135,0.6073 T0.1168,0.6098 T0.1038,0.6113 Q0.0973,0.6123,0.0787,0.6123 L0.06,0.6123 L0.0414,0.6123 L0.0235,0.6123 Q0.0049,0.6133,0.0049,0.6172 L0.0057,0.6222 Q0.0073,0.6261,0.043,0.6261 L0.0454,0.6261 L0.0479,0.6261 Q0.0527,0.6261,0.0633,0.6281 T0.0803,0.6301 L0.0835,0.6301 L0.0916,0.6301 Q0.0998,0.6301,0.129,0.632 Q0.1768,0.636,0.206,0.64 Q0.2117,0.6409,0.2165,0.6409 Q0.2206,0.6409,0.2263,0.6405 T0.2336,0.64 L0.2384,0.64 L0.2409,0.64 T0.251,0.6395 T0.2644,0.639 Q0.2741,0.639,0.279,0.6409 Q0.283,0.6429,0.2972,0.6439 T0.3293,0.6459 T0.3528,0.6469 L0.3577,0.6469 Q0.3642,0.6469,0.3723,0.6449 T0.3844,0.6429 Q0.3901,0.6429,0.3933,0.6454 T0.4006,0.6479 Q0.4088,0.6479,0.4517,0.6558 Q0.4582,0.6568,0.4623,0.6568 Q0.4655,0.6568,0.4716,0.6563 T0.4826,0.6558 L0.4882,0.6558 Q0.5004,0.6558,0.5255,0.6607 Q0.5328,0.6627,0.5604,0.6647 T0.6152,0.6682 T0.644,0.6696 T0.6719,0.6721 T0.7056,0.6756 Q0.7113,0.6756,0.7198,0.6805 T0.738,0.6855 Q0.7453,0.6855,0.7551,0.6879 T0.7741,0.6939 T0.7912,0.7018 T0.8029,0.7102 Q0.8054,0.7132,0.8054,0.7151 Q0.8054,0.7191,0.8009,0.7216 T0.7908,0.7255 T0.779,0.7285 T0.7721,0.731 Q0.7672,0.7329,0.7632,0.7339 T0.7551,0.7354 T0.7486,0.7369 Q0.7478,0.7369,0.7445,0.7379 T0.7388,0.7394 T0.7324,0.7404 L0.7242,0.7413 T0.7161,0.7418 Q0.7105,0.7418,0.6955,0.7428 T0.6748,0.7438 L0.6699,0.7438 L0.6667,0.7438 Q0.6659,0.7438,0.6407,0.7468 Q0.6367,0.7478,0.6334,0.7478 T0.6245,0.7468 T0.6148,0.7458 L0.6099,0.7458 Q0.6018,0.7468,0.5864,0.7498 T0.5653,0.7532 T0.5596,0.7557 Q0.5596,0.7596,0.571,0.7616 Q0.5742,0.7626,0.5803,0.7631 T0.5929,0.7641 T0.6018,0.7656 L0.6087,0.7656 T0.6192,0.7666 T0.6277,0.7695 Q0.631,0.7705,0.6342,0.7705 Q0.6383,0.7705,0.6452,0.7685 T0.6537,0.7666 L0.6553,0.7666 Q0.6602,0.7666,0.6711,0.769 T0.6853,0.7715 Q0.691,0.7715,0.7048,0.775 T0.7242,0.7814 Q0.7324,0.7854,0.7445,0.7864 Q0.7478,0.7864,0.768,0.7873 T0.7972,0.7893 Q0.7989,0.7893,0.8017,0.7898 T0.8054,0.7903 L0.8082,0.7903 T0.811,0.7908 T0.8131,0.7913 T0.8151,0.7918 L0.8167,0.7928 T0.8179,0.7943 T0.8191,0.7957 T0.8204,0.7977 T0.8208,0.8002 Q0.8208,0.8032,0.8171,0.8051 T0.8074,0.8081 T0.7997,0.8091 Q0.7932,0.8121,0.7737,0.8121 Q0.7664,0.8121,0.7413,0.8111 L0.7364,0.8111 Q0.7275,0.8111,0.7214,0.8121 T0.7084,0.8155 T0.6991,0.819 Q0.6934,0.82,0.6723,0.8205 T0.6472,0.8239 Q0.6423,0.8269,0.6375,0.8269 Q0.6358,0.8269,0.6338,0.8264 T0.6294,0.8254 T0.6253,0.8249 Q0.6042,0.8249,0.5961,0.8289 Q0.5921,0.8318,0.5839,0.8318 Q0.5783,0.8318,0.5645,0.8299 L0.5604,0.8299 Q0.5531,0.8299,0.5337,0.8368 Q0.5296,0.8378,0.5255,0.8378 Q0.5239,0.8378,0.5195,0.8373 T0.5118,0.8368 Q0.5061,0.8368,0.4996,0.8388 Q0.4947,0.8388,0.4882,0.8398 Q0.4777,0.8417,0.4753,0.8427 T0.4728,0.8467 Q0.4728,0.8487,0.4769,0.8492 T0.4886,0.8501 T0.5004,0.8516 Q0.5036,0.8516,0.515,0.8521 T0.5345,0.8546 Q0.5426,0.8556,0.5596,0.8556 L0.5649,0.8556 L0.5702,0.8556 L0.5791,0.8556 Q0.5921,0.8566,0.6135,0.8571 T0.6383,0.8586 Q0.6683,0.8615,0.6764,0.8615 L0.6776,0.8615 L0.6788,0.8615 Q0.7032,0.8615,0.7032,0.8684 Q0.7032,0.8714,0.6995,0.8749 T0.6959,0.8803 L0.6959,0.8813 Q0.6991,0.8843,0.7153,0.8843 Q0.7218,0.8843,0.7259,0.8833 L0.7299,0.8833 Q0.7324,0.8833,0.7348,0.8838 T0.7393,0.8848 T0.7433,0.8863 L0.7474,0.8882 T0.751,0.8892 Q0.7616,0.8922,0.7948,0.8952 Q0.7981,0.8952,0.8082,0.8981 T0.8297,0.9011 T0.8528,0.9026 T0.8747,0.907 T0.8856,0.9149 L0.8856,0.9159 Q0.8856,0.9179,0.8848,0.9189 T0.8828,0.9209 T0.88,0.9228 T0.8767,0.9243 T0.8731,0.9248 T0.8698,0.9253 T0.8666,0.9258 L0.8646,0.9258 Q0.8621,0.9258,0.8577,0.9263 T0.85,0.9268 T0.8439,0.9273 T0.8402,0.9278 Q0.8386,0.9298,0.8358,0.9308 T0.8305,0.9322 T0.8244,0.9332 T0.8183,0.9337 Q0.8135,0.9347,0.8025,0.9372 T0.7859,0.9416 Q0.7778,0.9436,0.7717,0.9471 T0.7624,0.9515 Q0.7575,0.9535,0.7486,0.9535 Q0.7461,0.9535,0.7397,0.953 T0.7291,0.9525 Q0.7234,0.9525,0.7186,0.953 T0.7137,0.957 T0.7194,0.9614 Q0.7567,0.9634,0.7664,0.9654 Q0.7745,0.9674,0.7762,0.9674 L0.7908,0.9674 Q0.7924,0.9664,0.7948,0.9664 Q0.8029,0.9664,0.8082,0.9679 T0.8224,0.9723 T0.8362,0.9773 Q0.8483,0.9812,0.871,0.9812 L0.8751,0.9812 Q0.8873,0.9812,0.8929,0.9822 T0.9165,0.9876 T0.9408,0.9931 Q0.9513,0.996,0.9935,0.996 Z M0.9968,0.998 L0.9976,0.003 Q0.9838,0.002,0.9708,0.0059 Q0.9659,0.0069,0.9327,0.0059 T0.8881,0.0099 Q0.8767,0.0138,0.8658,0.0163 T0.8491,0.0218 Q0.8418,0.0247,0.8341,0.0247 T0.8232,0.0257 Q0.8191,0.0277,0.7997,0.0292 T0.7737,0.0326 Q0.7697,0.0336,0.7672,0.0336 T0.7612,0.0321 T0.7543,0.0307 T0.747,0.0317 Q0.7397,0.0326,0.7336,0.0356 T0.717,0.0406 Q0.6918,0.0445,0.6861,0.0475 Q0.6845,0.0485,0.6772,0.0485 T0.6638,0.05 T0.6577,0.0549 T0.6642,0.0598 T0.6796,0.0613 T0.6902,0.0623 Q0.691,0.0623,0.6946,0.0658 T0.7064,0.0702 L0.7161,0.0702 Q0.7194,0.0702,0.7242,0.0697 T0.7332,0.0692 Q0.7413,0.0692,0.7579,0.0717 T0.781,0.0762 Q0.7867,0.0781,0.8171,0.0786 T0.85,0.0801 L0.8532,0.0801 Q0.8548,0.0801,0.8613,0.0796 T0.8727,0.0791 Q0.8832,0.0791,0.8913,0.0811 Q0.897,0.0831,0.897,0.0851 Q0.897,0.088,0.8873,0.0905 T0.8735,0.093 Q0.871,0.093,0.8447,0.0984 T0.8143,0.1039 Q0.7981,0.1039,0.781,0.1078 Q0.7778,0.1088,0.7745,0.1088 T0.7644,0.1073 T0.7518,0.1048 L0.7453,0.1048 Q0.7299,0.1048,0.7076,0.1083 T0.6788,0.1157 Q0.6748,0.1187,0.6699,0.1187 Q0.6675,0.1187,0.6557,0.1157 T0.6318,0.1118 Q0.6164,0.1108,0.6135,0.1108 T0.6095,0.1113 T0.6067,0.1142 T0.6018,0.1187 Q0.5953,0.1227,0.5921,0.1227 Q0.5904,0.1227,0.5839,0.1212 T0.5693,0.1187 L0.5661,0.1187 Q0.558,0.1187,0.5527,0.1207 T0.5434,0.1246 T0.5337,0.1266 Q0.5126,0.1296,0.4882,0.1296 T0.4371,0.1385 Q0.4298,0.1414,0.425,0.1414 Q0.4225,0.1414,0.4189,0.1395 T0.4112,0.1375 Q0.4079,0.1375,0.4019,0.1395 T0.3869,0.1414 Q0.3682,0.1414,0.3504,0.1474 Q0.3398,0.1513,0.3333,0.1513 Q0.3293,0.1513,0.3228,0.1494 L0.3204,0.1494 Q0.3179,0.1494,0.3155,0.1508 T0.3118,0.1543 T0.3106,0.1592 T0.3127,0.1642 T0.32,0.1677 T0.3305,0.1701 T0.3435,0.1716 T0.3544,0.1721 Q0.3569,0.1731,0.3601,0.1731 Q0.3625,0.1731,0.3686,0.1726 T0.3779,0.1721 Q0.3901,0.1721,0.4023,0.1751 Q0.4177,0.18,0.455,0.18 Q0.4793,0.18,0.4882,0.178 L0.4915,0.178 Q0.4964,0.178,0.5045,0.1815 T0.5158,0.185 Q0.5564,0.1889,0.5645,0.1929 Q0.5677,0.1939,0.571,0.1939 Q0.575,0.1939,0.5807,0.1919 T0.5888,0.1899 T0.5929,0.1909 Q0.5969,0.1949,0.6123,0.1949 Q0.6334,0.1949,0.6456,0.1899 Q0.6488,0.1879,0.6537,0.1879 Q0.661,0.1879,0.6772,0.1929 T0.6983,0.1978 Q0.704,0.1988,0.7206,0.1998 T0.7502,0.2018 T0.7664,0.2038 Q0.7672,0.2038,0.7818,0.2043 T0.8151,0.2067 T0.8459,0.2156 Q0.8573,0.2206,0.8573,0.2255 Q0.8573,0.2295,0.8516,0.2324 T0.8394,0.2369 T0.8281,0.2384 Q0.8208,0.2384,0.7526,0.2473 Q0.7494,0.2483,0.7421,0.2493 T0.7287,0.2512 T0.7178,0.2522 L0.7153,0.2522 L0.7137,0.2522 Q0.7056,0.2522,0.6898,0.2572 T0.6691,0.2671 Q0.6667,0.269,0.6634,0.269 Q0.661,0.269,0.6557,0.2681 T0.6472,0.2671 Q0.6448,0.2671,0.6415,0.2681 Q0.631,0.271,0.6034,0.274 Q0.5994,0.274,0.5961,0.2765 T0.5904,0.2789 L0.5864,0.2789 Q0.5831,0.2779,0.5742,0.2779 Q0.541,0.2779,0.5223,0.2849 Q0.5126,0.2888,0.5028,0.2888 Q0.5004,0.2888,0.4943,0.2883 T0.4842,0.2878 Q0.4704,0.2878,0.4627,0.2898 T0.4509,0.2987 Q0.4501,0.2997,0.4501,0.3007 Q0.4501,0.3046,0.4574,0.3066 T0.4765,0.3091 T0.4899,0.3096 Q0.4931,0.3106,0.5061,0.3121 T0.5316,0.315 T0.5499,0.3175 Q0.5507,0.3175,0.5572,0.3195 T0.5685,0.3225 T0.5803,0.3254 T0.5933,0.3279 T0.605,0.3284 T0.6148,0.3274 Q0.6221,0.3244,0.6294,0.3244 Q0.6399,0.3244,0.6496,0.3294 Q0.6529,0.3314,0.6577,0.3314 Q0.6602,0.3314,0.6663,0.3304 T0.6756,0.3294 T0.6813,0.3304 Q0.6837,0.3304,0.6873,0.3309 L0.6946,0.3318 T0.7024,0.3323 T0.7105,0.3328 T0.7178,0.3338 T0.7238,0.3348 T0.7283,0.3363 Q0.7324,0.3383,0.7482,0.3403 T0.7689,0.3442 Q0.7697,0.3442,0.779,0.3477 T0.794,0.3536 T0.8074,0.3615 T0.8183,0.3729 Q0.8232,0.3808,0.8232,0.3848 Q0.8232,0.3867,0.8216,0.3892 T0.8151,0.3961 T0.8062,0.406 T0.7997,0.4179 T0.7952,0.4263 T0.7855,0.4308 T0.7616,0.4362 Q0.7543,0.4372,0.7445,0.4372 L0.7372,0.4372 L0.7307,0.4372 Q0.7202,0.4372,0.7153,0.4382 Q0.7064,0.4402,0.691,0.4402 L0.6845,0.4402 L0.6788,0.4402 Q0.6699,0.4402,0.6533,0.4436 T0.6318,0.451 Q0.6302,0.451,0.6302,0.452 Q0.6302,0.457,0.6626,0.459 Q0.6869,0.4609,0.7015,0.4659 Q0.7064,0.4669,0.7202,0.4669 L0.7311,0.4669 L0.7429,0.4669 Q0.7599,0.4669,0.7689,0.4688 Q0.7794,0.4708,0.7794,0.4738 L0.7786,0.4748 T0.777,0.4763 T0.7749,0.4773 L0.7737,0.4777 L0.7729,0.4777 Q0.7502,0.4797,0.738,0.4797 L0.7315,0.4797 L0.7291,0.4797 Q0.7226,0.4797,0.6869,0.4876 Q0.6821,0.4886,0.6768,0.4891 T0.6614,0.4901 T0.6456,0.4916 L0.6342,0.4916 Q0.6294,0.4916,0.6217,0.4911 T0.6115,0.4906 Q0.6083,0.4906,0.6054,0.4911 T0.5961,0.4936 T0.5815,0.4965 T0.5629,0.4985 Q0.5507,0.4985,0.5442,0.4995 T0.5345,0.5025 T0.5304,0.5084 L0.5296,0.5094 Q0.5296,0.5114,0.5316,0.5124 T0.5373,0.5138 T0.5442,0.5143 L0.5523,0.5143 L0.5604,0.5143 Q0.5637,0.5153,0.5677,0.5158 T0.5742,0.5173 T0.5811,0.5188 T0.5904,0.5193 L0.5977,0.5193 L0.6026,0.5193 Q0.6107,0.5193,0.6168,0.5208 T0.6294,0.5252 T0.6399,0.5292 Q0.6448,0.5302,0.6679,0.5341 T0.6983,0.541 Q0.7129,0.545,0.7664,0.55 Q0.7883,0.5519,0.7883,0.5559 Q0.7883,0.5579,0.7843,0.5608 T0.7721,0.5638 Q0.7697,0.5638,0.764,0.5633 T0.7559,0.5628 L0.7502,0.5628 Q0.7364,0.5648,0.6869,0.5648 L0.6699,0.5648 L0.6675,0.5648 Q0.665,0.5648,0.6602,0.5658 T0.6513,0.5668 Q0.6464,0.5668,0.6399,0.5658 Q0.6342,0.5648,0.6302,0.5648 T0.6225,0.5668 T0.6156,0.5697 Q0.6107,0.5707,0.6087,0.5707 T0.6034,0.5712 T0.5953,0.5717 Q0.5904,0.5727,0.5835,0.5727 T0.5718,0.5732 T0.562,0.5757 Q0.558,0.5767,0.5483,0.5767 L0.5349,0.5767 L0.5207,0.5767 Q0.5069,0.5767,0.5028,0.5786 Q0.4972,0.5816,0.4899,0.5816 Q0.4858,0.5816,0.4781,0.5806 T0.4663,0.5796 L0.4631,0.5796 Q0.4582,0.5796,0.4432,0.5821 T0.4144,0.5846 L0.4071,0.5846 L0.4011,0.5846 T0.3958,0.5851 T0.3921,0.5856 T0.3889,0.5861 T0.3865,0.5865 T0.384,0.5875 L0.382,0.5885 L0.3796,0.5895 L0.3771,0.5905 Q0.3731,0.5925,0.365,0.5925 L0.3601,0.5925 L0.3552,0.5925 Q0.3277,0.5925,0.3049,0.6044 Q0.3017,0.6053,0.296,0.6053 Q0.292,0.6053,0.2847,0.6044 T0.2741,0.6034 Q0.2693,0.6034,0.2547,0.6029 T0.236,0.6024 Q0.2222,0.6024,0.1922,0.6073 Q0.1906,0.6083,0.1882,0.6083 Q0.1833,0.6083,0.1711,0.6063 T0.1533,0.6044 Q0.1517,0.6034,0.1492,0.6034 Q0.1436,0.6034,0.135,0.6048 T0.1168,0.6078 T0.103,0.6093 Q0.0973,0.6103,0.0787,0.6103 L0.0604,0.6103 L0.0414,0.6103 L0.0235,0.6103 Q0.0024,0.6113,0.0024,0.6172 Q0.0024,0.6192,0.0032,0.6231 Q0.0049,0.6281,0.0333,0.6281 L0.0414,0.6281 L0.0479,0.6281 Q0.0519,0.6281,0.0624,0.6301 T0.0803,0.632 L0.0835,0.632 L0.0916,0.632 Q0.0989,0.632,0.1281,0.634 L0.206,0.6419 Q0.2117,0.6429,0.2174,0.6429 Q0.2214,0.6429,0.2271,0.6424 T0.2344,0.6419 L0.2376,0.6419 Q0.2393,0.6429,0.2417,0.6429 T0.2526,0.6419 T0.2652,0.6409 Q0.2741,0.6409,0.2782,0.6429 T0.2968,0.6459 T0.3293,0.6479 T0.352,0.6489 Q0.3552,0.6499,0.3585,0.6499 Q0.365,0.6499,0.3731,0.6474 T0.3844,0.6449 Q0.3885,0.6449,0.3917,0.6474 T0.4006,0.6499 Q0.4088,0.6499,0.4509,0.6578 Q0.4574,0.6588,0.4631,0.6588 Q0.4655,0.6588,0.4716,0.6583 T0.4834,0.6578 L0.4874,0.6578 Q0.5004,0.6588,0.5255,0.6637 Q0.532,0.6647,0.56,0.6667 T0.6148,0.6701 T0.644,0.6716 Q0.6464,0.6726,0.6594,0.6736 T0.6861,0.6756 T0.7048,0.6775 Q0.7097,0.6775,0.7186,0.6825 T0.738,0.6874 Q0.7518,0.6874,0.7729,0.6958 T0.8005,0.7122 Q0.8029,0.7141,0.8029,0.7151 Q0.8029,0.7191,0.7968,0.7216 T0.7818,0.726 T0.7705,0.729 L0.764,0.731 T0.7583,0.7324 T0.753,0.7334 T0.7486,0.7349 Q0.7251,0.7399,0.7161,0.7399 Q0.7097,0.7399,0.6951,0.7409 T0.6748,0.7418 L0.6703,0.7418 L0.6667,0.7418 Q0.6659,0.7418,0.6399,0.7448 L0.6334,0.7448 Q0.631,0.7448,0.6249,0.7443 T0.6148,0.7438 L0.6099,0.7438 Q0.601,0.7448,0.5856,0.7473 T0.5645,0.7507 Q0.5572,0.7517,0.5572,0.7547 T0.5616,0.7606 T0.5702,0.7646 Q0.5734,0.7646,0.5779,0.7651 T0.5864,0.7661 T0.5949,0.7671 T0.6018,0.7676 L0.6071,0.7676 T0.6135,0.7681 T0.62,0.769 T0.6269,0.771 T0.6342,0.7725 Q0.6391,0.7725,0.6464,0.7705 T0.6541,0.7685 L0.6553,0.7685 Q0.6586,0.7685,0.6699,0.771 T0.6853,0.7735 Q0.6902,0.7735,0.704,0.777 T0.7226,0.7834 Q0.7315,0.7873,0.7445,0.7883 Q0.747,0.7883,0.7676,0.7893 T0.7972,0.7913 Q0.7989,0.7913,0.8017,0.7918 T0.8058,0.7923 T0.809,0.7928 T0.8114,0.7933 T0.8131,0.7938 T0.8147,0.7943 T0.8159,0.7953 L0.8171,0.7967 T0.8175,0.7982 Q0.8183,0.7992,0.8183,0.8002 Q0.8183,0.8022,0.8155,0.8032 T0.807,0.8051 T0.7989,0.8071 Q0.7932,0.8091,0.7737,0.8091 L0.7413,0.8091 L0.7372,0.8091 Q0.7275,0.8091,0.721,0.8101 T0.7072,0.8136 T0.6983,0.817 Q0.6942,0.818,0.6825,0.818 T0.6602,0.819 T0.6456,0.822 Q0.6415,0.8249,0.6375,0.8249 Q0.6367,0.8249,0.6326,0.8239 T0.6253,0.8229 Q0.6034,0.8229,0.5953,0.8279 Q0.5912,0.8289,0.5848,0.8289 Q0.5775,0.8289,0.5645,0.8279 Q0.5629,0.8269,0.5604,0.8269 Q0.5523,0.8269,0.5328,0.8348 Q0.5296,0.8358,0.5264,0.8358 Q0.5247,0.8358,0.5203,0.8353 T0.5126,0.8348 Q0.5061,0.8348,0.4988,0.8358 Q0.4947,0.8368,0.4882,0.8378 Q0.4826,0.8388,0.4797,0.8388 T0.474,0.8398 T0.4704,0.8422 T0.4696,0.8462 T0.472,0.8501 T0.4781,0.8521 T0.4854,0.8526 L0.4935,0.8526 T0.4996,0.8536 Q0.5036,0.8536,0.515,0.8546 T0.5337,0.8566 Q0.5426,0.8576,0.5596,0.8576 L0.5657,0.8576 L0.571,0.8576 L0.5791,0.8576 Q0.5921,0.8586,0.6135,0.8591 T0.6383,0.8605 Q0.6683,0.8635,0.6764,0.8635 Q0.6999,0.8635,0.6999,0.8684 Q0.6999,0.8694,0.6967,0.8734 T0.6934,0.8803 L0.6934,0.8823 Q0.6951,0.8863,0.7137,0.8863 Q0.7218,0.8863,0.7267,0.8853 L0.7299,0.8853 Q0.734,0.8853,0.7409,0.8882 T0.7502,0.8912 Q0.7607,0.8942,0.794,0.8971 Q0.7972,0.8971,0.8078,0.9001 T0.8297,0.9031 Q0.8475,0.9031,0.8646,0.9065 T0.8824,0.9149 L0.8824,0.9159 Q0.8824,0.9169,0.882,0.9179 T0.8808,0.9194 L0.8792,0.9204 T0.8767,0.9214 T0.8743,0.9224 T0.8715,0.9228 L0.8686,0.9228 T0.8662,0.9233 T0.8637,0.9238 L0.8556,0.9238 T0.8447,0.9243 T0.8386,0.9268 Q0.837,0.9278,0.835,0.9288 T0.8305,0.9303 T0.8244,0.9308 T0.8175,0.9318 Q0.8127,0.9327,0.8017,0.9352 T0.7851,0.9397 Q0.777,0.9416,0.7705,0.9451 T0.7616,0.9496 Q0.7575,0.9505,0.7494,0.9505 L0.7405,0.9505 L0.7307,0.9505 Q0.7234,0.9505,0.7178,0.9515 Q0.7145,0.9515,0.7125,0.9535 T0.7105,0.9575 Q0.7105,0.9624,0.7194,0.9634 Q0.7567,0.9654,0.7664,0.9674 Q0.7745,0.9693,0.7762,0.9693 L0.7908,0.9693 L0.7948,0.9693 Q0.8005,0.9693,0.8058,0.9698 T0.8143,0.9718 T0.824,0.9753 T0.8354,0.9792 Q0.8483,0.9832,0.871,0.9832 L0.8739,0.9832 L0.8767,0.9832 Q0.8873,0.9832,0.8921,0.9842 Q0.8978,0.9852,0.9157,0.9896 T0.94,0.996 Q0.9424,0.996,0.9469,0.9965 T0.9566,0.997 T0.9676,0.9975 T0.9781,0.998 L0.9874,0.998 L0.9943,0.998 L0.9968,0.998 Z",type:0}},"":{type:5,data:{d:"M1,0.5071 L0.8623,0.7102 L0.5865,0.7102 L0.4489,0.5071 L0.5865,0.3045 L0.8623,0.3045 Z M0.4135,0.7974 L0.2758,1 L0,1 L0,0.5944 L0.2758,0.5944 Z M0.4135,0.2026 L0.2758,0.4056 L0,0.4056 L0,0 L0.2758,0 Z",type:0}},"":{type:5,data:{d:"M0.9726,0.5071 L0.8451,0.3184 L0.59,0.3184 L0.4624,0.5071 L0.59,0.6955 L0.8451,0.6955 Z M1,0.5071 L0.8588,0.716 L0.5768,0.716 L0.4355,0.5071 L0.5768,0.2982 L0.8588,0.2982 Z M0.401,0.7911 L0.2735,0.6028 L0.0236,0.6028 L0.0236,0.9799 L0.2735,0.9799 Z M0.4284,0.7911 L0.2872,1 L0,1 L0,0.5826 L0.2872,0.5826 Z M0.401,0.2089 L0.2735,0.0201 L0.0236,0.0201 L0.0236,0.3972 L0.2735,0.3972 Z M0.4284,0.2089 L0.2872,0.4174 L0,0.4174 L0,0 L0.2872,0 Z",type:0}},"":{type:5,data:{d:"M1,0.4996 Q1,0.5365,0.9924,0.568 T0.9718,0.6177 T0.9433,0.6363 L0.9425,0.6367 Q0.9355,0.6367,0.9285,0.6326 L0.9308,0.6326 Q0.9129,0.6195,0.9013,0.587 T0.8871,0.5164 T0.8943,0.4373 T0.9254,0.3687 L0.9254,0.3691 Q0.9339,0.3628,0.9425,0.3628 Q0.9584,0.3628,0.9716,0.3811 T0.9924,0.431 T1,0.4996 Z M0.9234,0.6321 L0.8776,0.7169 Q0.8791,0.732,0.8791,0.7441 Q0.8791,0.781,0.8716,0.8123 T0.8508,0.862 T0.8224,0.8809 L0.8216,0.8809 Q0.8154,0.8809,0.8092,0.8775 L0.8088,0.8775 Q0.7905,0.8633,0.7792,0.8297 T0.766,0.7571 T0.775,0.6768 T0.8088,0.6086 L0.7431,0.6065 Q0.719,0.6313,0.7072,0.6705 T0.6965,0.7487 T0.7097,0.823 T0.7423,0.8763 L0.7913,0.8775 L0.7314,0.9895 L0.4648,0.5038 L0.7299,0.0176 L0.7882,0.1229 L0.7404,0.1212 Q0.7244,0.138,0.7136,0.1617 T0.6982,0.2108 T0.6943,0.2632 T0.7003,0.3144 T0.7159,0.3586 T0.7396,0.3909 L0.8072,0.3926 Q0.7894,0.3796,0.7777,0.3479 T0.7635,0.2789 T0.7697,0.2011 T0.7987,0.1326 Q0.8092,0.1225,0.8204,0.1225 Q0.8321,0.1225,0.8426,0.1332 T0.8609,0.1623 T0.8731,0.2062 T0.8776,0.2592 Q0.8776,0.268,0.8768,0.2815 L0.9219,0.3628 L0.8644,0.3612 Q0.8403,0.3855,0.8284,0.4247 T0.8177,0.5029 T0.8309,0.5772 T0.8632,0.6305 Z M0.6759,0.6384 Q0.6576,0.625,0.6457,0.5914 T0.6319,0.5185 T0.6407,0.4375 T0.6751,0.3691 L0.609,0.367 Q0.5849,0.3918,0.5731,0.431 T0.5626,0.509 T0.5758,0.5833 T0.6082,0.6367 Z M0.6459,0.0025 L0.391,0.4551 L0.0035,0.4551 L0.246,0 Z M0.6553,1 L0.2421,1 L0,0.5449 L0.3875,0.5449 Z",type:0}},"":{type:5,data:{d:"M0.4996,0 Q0.5562,0,0.5961,0.0166 T0.6364,0.0566 L0.6368,0.0575 Q0.6368,0.0646,0.6324,0.0713 L0.6324,0.0692 Q0.6196,0.0868,0.5872,0.0986 T0.5166,0.1128 T0.4373,0.1057 T0.3689,0.0747 L0.3694,0.0747 Q0.3627,0.0663,0.3627,0.0575 Q0.3627,0.0336,0.4028,0.0168 T0.4996,0 Z M0.6324,0.0768 L0.717,0.1225 Q0.7321,0.1212,0.744,0.1212 Q0.8007,0.1212,0.8406,0.1378 T0.8809,0.1779 L0.8813,0.1783 Q0.8813,0.1846,0.8778,0.1909 Q0.8636,0.2093,0.8299,0.2208 T0.7573,0.2343 T0.6769,0.2253 T0.6089,0.1913 L0.6067,0.2567 Q0.6315,0.281,0.6707,0.2928 T0.7489,0.3035 T0.8231,0.2903 T0.8764,0.258 L0.8778,0.2085 L0.9898,0.2685 L0.504,0.5352 L0.0177,0.2701 L0.1227,0.2118 L0.1213,0.2596 Q0.1457,0.2836,0.1851,0.2955 T0.2635,0.3062 T0.3377,0.293 T0.3911,0.2605 L0.3928,0.193 Q0.38,0.2106,0.3483,0.2221 T0.2792,0.2364 T0.2013,0.2303 T0.1324,0.2013 Q0.1222,0.1909,0.1222,0.1795 Q0.1222,0.156,0.1623,0.1393 T0.2591,0.1225 Q0.2679,0.1225,0.2817,0.1233 L0.3627,0.078 L0.3609,0.1359 Q0.3857,0.1598,0.4249,0.1718 T0.5031,0.1825 T0.5773,0.1693 T0.6306,0.1367 Z M0.6386,0.3242 Q0.6253,0.3427,0.5917,0.3544 T0.5186,0.3683 T0.4376,0.3595 T0.3689,0.3251 L0.3671,0.3909 Q0.3915,0.4148,0.4309,0.4268 T0.5093,0.4375 T0.5835,0.4243 T0.6368,0.3918 Z M0.0027,0.354 L0.4553,0.6091 L0.4553,0.9962 L0,0.7542 Z M1,0.3448 L1,0.7576 L0.5447,1 L0.5447,0.6128 Z",type:0}},"":{type:5,data:{d:"M0,0.7699 Q0,0.7172,0.0277,0.6731 T0.103,0.6032 T0.2066,0.5774 Q0.2487,0.5774,0.2865,0.5922 T0.3526,0.6339 L0.3935,0.6715 Q0.4218,0.6984,0.438,0.7336 T0.4541,0.8075 Q0.4541,0.8602,0.4264,0.9046 T0.3511,0.9745 T0.2475,1 Q0.2054,1,0.1676,0.9852 T0.1016,0.9435 L0.0606,0.9059 Q0.0317,0.879,0.0159,0.8438 T0,0.7699 Z M0.5459,0.7699 Q0.5459,0.7172,0.5736,0.6731 T0.6489,0.6032 T0.7525,0.5774 Q0.7946,0.5774,0.8324,0.5922 T0.8984,0.6339 L0.9394,0.6715 Q0.9579,0.6892,0.9714,0.7105 T0.9925,0.7567 T1,0.8075 Q1,0.8602,0.9723,0.9046 T0.897,0.9745 T0.7934,1 Q0.7513,1,0.7135,0.9852 T0.6474,0.9435 L0.6065,0.9059 Q0.5776,0.879,0.5617,0.8438 T0.5459,0.7699 Z M0,0.1925 Q0,0.1398,0.0277,0.0957 T0.103,0.0258 T0.2066,0 Q0.2487,0,0.2865,0.0148 T0.3526,0.0565 L0.3935,0.0941 Q0.4218,0.121,0.438,0.1562 T0.4541,0.2301 Q0.4541,0.2828,0.4264,0.3269 T0.3511,0.3968 T0.2475,0.4226 Q0.2054,0.4226,0.1676,0.4078 T0.1016,0.3661 L0.0606,0.3285 Q0.0317,0.3016,0.0159,0.2664 T0,0.1925 Z M0.5459,0.1925 Q0.5459,0.1398,0.5736,0.0957 T0.6489,0.0258 T0.7525,0 Q0.7946,0,0.8324,0.0148 T0.8984,0.0565 L0.9394,0.0941 Q0.9677,0.121,0.9838,0.1562 T1,0.2301 Q1,0.2828,0.9723,0.3269 T0.897,0.3968 T0.7934,0.4226 Q0.7513,0.4226,0.7135,0.4078 T0.6474,0.3661 L0.6065,0.3285 Q0.5874,0.3108,0.5741,0.2895 T0.5534,0.2433 T0.5459,0.1925 Z M0.3301,0.6403 Q0.3306,0.6403,0.3312,0.6409 L0.3272,0.6371 L0.3272,0.6371 Z M0.8759,0.6403 Q0.8765,0.6403,0.8771,0.6409 Q0.8748,0.6387,0.8725,0.6371 L0.8731,0.6371 Z M0.3301,0.0629 Q0.3306,0.0629,0.3312,0.0634 L0.3272,0.0597 L0.3272,0.0602 Z M0.8759,0.0629 Q0.8765,0.0629,0.8771,0.0634 Q0.8748,0.0613,0.8725,0.0597 Q0.8731,0.0597,0.8731,0.0602 Z M0.779,0.4113 L0.7501,0.3849 Q0.7046,0.3844,0.6636,0.3661 Q0.7132,0.407,0.779,0.4113 Z M0.7957,0.4118 Q0.8477,0.4113,0.8918,0.3874 T0.9619,0.3223 T0.9885,0.2323 L0.9585,0.2048 Q0.9538,0.2769,0.8987,0.3282 T0.7657,0.3844 Z M0.9879,0.2167 Q0.9827,0.1554,0.9388,0.1097 Q0.9585,0.1478,0.959,0.1898 Z M0.2331,0.4113 L0.2043,0.3849 Q0.1587,0.3844,0.1177,0.3661 Q0.1673,0.407,0.2331,0.4113 Z M0.2499,0.4118 Q0.2885,0.4118,0.324,0.3973 T0.3852,0.3589 T0.4264,0.3019 T0.4426,0.2323 L0.4126,0.2048 Q0.408,0.2769,0.3529,0.3282 T0.2198,0.3844 Z M0.442,0.2167 Q0.4368,0.1554,0.393,0.1097 Q0.4126,0.1478,0.4132,0.1903 Z M0.779,0.9887 L0.7501,0.9624 Q0.7046,0.9618,0.6636,0.9435 Q0.7132,0.9844,0.779,0.9887 Z M0.7957,0.9892 Q0.8477,0.9887,0.8918,0.9648 T0.9619,0.8997 T0.9885,0.8097 L0.9585,0.7823 Q0.9538,0.8543,0.8987,0.9056 T0.7657,0.9618 Z M0.9879,0.7941 Q0.9827,0.7328,0.9388,0.6871 Q0.9585,0.7253,0.959,0.7672 Z M0.2331,0.9887 L0.2043,0.9624 Q0.1587,0.9618,0.1177,0.9435 Q0.1673,0.9844,0.2331,0.9887 Z M0.2499,0.9892 Q0.3018,0.9887,0.3459,0.9648 T0.416,0.8997 T0.4426,0.8102 L0.4126,0.7823 Q0.408,0.8543,0.3529,0.9056 T0.2198,0.9618 Z M0.442,0.7941 Q0.4368,0.7328,0.393,0.6871 Q0.4126,0.7253,0.4132,0.7672 Z M0.3191,0.6452 Q0.2943,0.622,0.2643,0.6091 T0.2066,0.5962 Q0.1795,0.5962,0.1497,0.6091 T0.0949,0.6441 T0.0537,0.6995 T0.0375,0.7699 Q0.0375,0.8419,0.0941,0.8941 Q0.1189,0.9172,0.1489,0.9304 T0.2066,0.9435 Q0.2337,0.9435,0.2634,0.9304 T0.3182,0.8952 T0.3595,0.8398 T0.3756,0.7699 Q0.3756,0.6978,0.3191,0.6452 Z M0.026,0.7731 L0.026,0.7699 Q0.026,0.6935,0.0854,0.6376 Q0.0658,0.6538,0.0514,0.6739 T0.0289,0.718 T0.0202,0.7677 Z M0.0271,0.7892 L0.0208,0.7833 Q0.0254,0.8419,0.0681,0.886 Q0.0664,0.8828,0.0646,0.879 Q0.0329,0.8382,0.0271,0.7892 Z M0.3866,0.7823 Q0.382,0.8511,0.3278,0.9016 Q0.3843,0.8565,0.3918,0.7871 Z M0.3872,0.7677 L0.393,0.7726 L0.393,0.7699 Q0.393,0.7349,0.3791,0.7038 Q0.3739,0.6973,0.3681,0.6914 Q0.3866,0.7274,0.3872,0.7677 Z M0.865,0.6452 Q0.8402,0.622,0.8102,0.6091 T0.7525,0.5962 Q0.7305,0.5962,0.7072,0.6043 T0.6619,0.628 T0.6223,0.6642 T0.5941,0.7124 T0.5834,0.7699 Q0.5834,0.8419,0.6399,0.8941 Q0.6561,0.9097,0.6757,0.9207 T0.7149,0.9376 T0.7525,0.9435 Q0.7796,0.9435,0.8093,0.9304 T0.8641,0.8952 T0.9054,0.8398 T0.9215,0.7699 Q0.9215,0.6978,0.865,0.6452 Z M0.5718,0.7731 L0.5718,0.7699 Q0.5718,0.6935,0.6313,0.6376 Q0.6013,0.6618,0.584,0.6954 T0.5661,0.7677 Z M0.573,0.7892 L0.5666,0.7833 Q0.5713,0.8419,0.614,0.886 Q0.6122,0.8828,0.6105,0.879 Q0.5788,0.8382,0.573,0.7892 Z M0.9325,0.7823 Q0.9279,0.8511,0.8736,0.9016 Q0.9308,0.8565,0.9377,0.7871 Z M0.9331,0.7672 L0.9388,0.7726 L0.9388,0.7699 Q0.9388,0.7349,0.925,0.7038 Q0.9198,0.6973,0.914,0.6914 Q0.9325,0.7274,0.9331,0.7672 Z M0.3191,0.0677 Q0.2943,0.0446,0.2643,0.0317 T0.2066,0.0188 Q0.1795,0.0188,0.1497,0.0317 T0.0949,0.0667 T0.0537,0.122 T0.0375,0.1925 Q0.0375,0.2645,0.0941,0.3167 Q0.1189,0.3398,0.1489,0.353 T0.2066,0.3661 Q0.2337,0.3661,0.2634,0.353 T0.3182,0.3177 T0.3595,0.2624 T0.3756,0.1925 Q0.3756,0.1204,0.3191,0.0677 Z M0.026,0.1957 L0.026,0.1925 Q0.026,0.1161,0.0854,0.0602 Q0.0554,0.0844,0.0381,0.118 T0.0202,0.1903 Z M0.0271,0.2118 L0.0208,0.2059 Q0.0254,0.2645,0.0681,0.3086 Q0.0664,0.3054,0.0646,0.3016 Q0.0329,0.2608,0.0271,0.2118 Z M0.3866,0.2048 Q0.382,0.2737,0.3278,0.3242 Q0.3849,0.279,0.3918,0.2097 Z M0.3872,0.1903 L0.393,0.1952 L0.393,0.1925 Q0.393,0.1581,0.3791,0.1263 Q0.3739,0.1199,0.3681,0.114 Q0.3866,0.15,0.3872,0.1903 Z M0.865,0.0677 Q0.8402,0.0446,0.8102,0.0317 T0.7525,0.0188 Q0.7253,0.0188,0.6956,0.0317 T0.6408,0.0667 T0.5995,0.122 T0.5834,0.1925 Q0.5834,0.2645,0.6399,0.3167 Q0.6647,0.3398,0.6947,0.353 T0.7525,0.3661 Q0.7796,0.3661,0.8093,0.353 T0.8641,0.3177 T0.9054,0.2624 T0.9215,0.1925 Q0.9215,0.1204,0.865,0.0677 Z M0.5718,0.1957 L0.5718,0.1925 Q0.5718,0.1161,0.6313,0.0602 Q0.6013,0.0844,0.584,0.118 T0.5661,0.1903 Z M0.573,0.2118 L0.5666,0.2059 Q0.5713,0.2645,0.614,0.3086 Q0.6122,0.3054,0.6105,0.3016 Q0.5788,0.2608,0.573,0.2118 Z M0.9325,0.2048 Q0.9279,0.2737,0.8736,0.3242 Q0.9308,0.279,0.9377,0.2097 Z M0.9331,0.1898 L0.9388,0.1952 L0.9388,0.1925 Q0.9388,0.1575,0.925,0.1263 Q0.9198,0.1199,0.914,0.114 Q0.9325,0.15,0.9331,0.1898 Z",type:0}},"":{type:5,data:{d:"M0.7639,0.1974 L0.9593,0.1974 L0.9593,0.1443 L0.7639,0.1443 L0.7639,0.1974 Z M0.7586,0.109 L0.9727,0.109 Q0.9839,0.109,0.992,0.1153 T1,0.1291 L1,0.382 Q1,0.3906,0.9912,0.3964 T0.9727,0.4021 L0.7586,0.4021 Q0.7468,0.4021,0.739,0.3956 T0.7313,0.382 L0.7313,0.1291 Q0.7313,0.1246,0.7339,0.1207 T0.7406,0.1143 T0.7495,0.1104 T0.7586,0.109 Z M0.7639,0.6575 L0.9593,0.6575 L0.9593,0.6044 L0.7639,0.6044 L0.7639,0.6575 Z M0.7313,0.8347 L0.7313,0.5843 Q0.7313,0.5757,0.7401,0.5699 T0.7586,0.5641 L0.9706,0.5641 Q0.9818,0.5641,0.9898,0.5705 T0.9979,0.5843 L0.9979,0.8347 Q0.9979,0.8433,0.989,0.8491 T0.9706,0.8549 L0.7586,0.8549 Q0.7468,0.8549,0.739,0.8483 T0.7313,0.8347 Z M0,1 L0,0 L0.7607,0 L0.7607,1 L0,1 Z",type:0}},"":{type:5,data:{d:"M0.9764,0.0029 L0.3179,0.4552 L0,0.4552 L0,0 Z M1,1 L0,1 L0,0.5448 L0.3091,0.5448 Z",type:0}},"":{type:5,data:{d:"M0.0236,0.0029 L0.6824,0.4552 L1,0.4552 L1,0 Z M0,1 L1,1 L1,0.5448 L0.6912,0.5448 Z",type:0}},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z M.25,.15 L1,.15 L1,.85 L.25,.85 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z M0,.15 L1,.15 L1,.85 L0,.85 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z M0,.15 L.75,.15 L.75,.85 L0,.85 Z"},"":{type:5,data:{d:"M0.6574,0.303 Q0.623,0.291,0.5852,0.285 T0.5082,0.279 T0.4311,0.285 T0.359,0.303 L0.3082,0.248 Q0.3525,0.232,0.4041,0.2235 T0.5082,0.215 T0.6123,0.2235 T0.7082,0.248 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.8557,0.582 L0.7656,0.551 Q0.7852,0.53,0.7951,0.507 T0.8049,0.46 Q0.8049,0.424,0.782,0.3905 T0.718,0.332 T0.6221,0.293 T0.5082,0.279 L0.5082,0.215 Q0.5607,0.215,0.6123,0.2235 T0.709,0.248 T0.7918,0.287 T0.8557,0.3375 T0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.582 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.482,0.705,0.4557,0.703 T0.4049,0.697 L0.4311,0.635 Q0.4508,0.638,0.4697,0.6395 T0.5082,0.641 Q0.5672,0.641,0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 Q0.8049,0.436,0.7951,0.413 T0.7656,0.369 L0.8557,0.338 Q0.882,0.365,0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 L0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 T0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 L0.9098,0.46 Q0.9098,0.492,0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.338 L0.2508,0.369 Q0.2311,0.39,0.2213,0.413 T0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 Q0.5279,0.641,0.5467,0.6395 T0.5852,0.635 L0.6115,0.697 Q0.5869,0.701,0.5607,0.703 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.1607,0.582 Q0.1344,0.555,0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.3375 T0.2246,0.287 T0.3074,0.248 T0.4041,0.2235 T0.5082,0.215 L0.5082,0.279 Q0.4492,0.279,0.3943,0.293 T0.2984,0.332 T0.2344,0.3905 T0.2115,0.46 Q0.2115,0.484,0.2213,0.507 T0.2508,0.551 Z",type:0},scaleType:1},"":Ue.LINE_H,"":Ue.LINE_V,"":Ue.FADE_RIGHT,"":Ue.FADE_LEFT,"":Ue.FADE_DOWN,"":Ue.FADE_UP,"":Ue.CURVE_DOWN_RIGHT,"":Ue.CURVE_DOWN_LEFT,"":Ue.CURVE_UP_RIGHT,"":Ue.CURVE_UP_LEFT,"":[Ue.LINE_V,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_RIGHT],"":[Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_UP_LEFT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT],"":[Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT],"":[Ue.CURVE_DOWN_LEFT,Ue.CURVE_DOWN_RIGHT],"":[Ue.LINE_H,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_UP_RIGHT],"":[Ue.CURVE_UP_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_UP_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT,Ue.CURVE_DOWN_RIGHT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_V,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_V,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.LINE_H,Ue.CURVE_DOWN_RIGHT,Ue.CURVE_UP_LEFT],"":[Ue.LINE_H,Ue.CURVE_DOWN_LEFT,Ue.CURVE_UP_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE],"":Ue.NODE_STROKE,"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_UP],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_UP],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_FILL,Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"":[Ue.NODE_STROKE,Ue.NODE_LINE_UP,Ue.NODE_LINE_DOWN,Ue.NODE_LINE_LEFT,Ue.NODE_LINE_RIGHT],"🬀":xr(1),"🬁":xr(2),"🬂":xr(3),"🬃":xr(4),"🬄":xr(5),"🬅":xr(6),"🬆":xr(7),"🬇":xr(8),"🬈":xr(9),"🬉":xr(10),"🬊":xr(11),"🬋":xr(12),"🬌":xr(13),"🬍":xr(14),"🬎":xr(15),"🬏":xr(16),"🬐":xr(17),"🬑":xr(18),"🬒":xr(19),"🬓":xr(20),"🬔":xr(22),"🬕":xr(23),"🬖":xr(24),"🬗":xr(25),"🬘":xr(26),"🬙":xr(27),"🬚":xr(28),"🬛":xr(29),"🬜":xr(30),"🬝":xr(31),"🬞":xr(32),"🬟":xr(33),"🬠":xr(34),"🬡":xr(35),"🬢":xr(36),"🬣":xr(37),"🬤":xr(38),"🬥":xr(39),"🬦":xr(40),"🬧":xr(41),"🬨":xr(43),"🬩":xr(44),"🬪":xr(45),"🬫":xr(46),"🬬":xr(47),"🬭":xr(48),"🬮":xr(49),"🬯":xr(50),"🬰":xr(51),"🬱":xr(52),"🬲":xr(53),"🬳":xr(54),"🬴":xr(55),"🬵":xr(56),"🬶":xr(57),"🬷":xr(58),"🬸":xr(59),"🬹":xr(60),"🬺":xr(61),"🬻":xr(62),"🬼":{type:3,data:"M0,0.6667 L0,1 L0.5,1 Z"},"🬽":{type:3,data:"M0,0.6667 L0,1 L1,1 Z"},"🬾":{type:3,data:"M0,0.3333 L0,1 L0.5,1 Z"},"🬿":{type:3,data:"M0,0.3333 L0,1 L1,1 Z"},"🭀":{type:3,data:"M0,0 L0,1 L0.5,1 Z"},"🭁":{type:3,data:"M0,0.3333 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭂":{type:3,data:"M0,0.3333 L1,0 L1,1 L0,1 Z"},"🭃":{type:3,data:"M0,0.6667 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭄":{type:3,data:"M0,0.6667 L1,0 L1,1 L0,1 Z"},"🭅":{type:3,data:"M0,1 L0.5,0 L1,0 L1,1 Z"},"🭆":{type:3,data:"M0,0.6667 L1,0.3333 L1,1 L0,1 Z"},"🭇":{type:3,data:"M0.5,1 L1,0.6667 L1,1 Z"},"🭈":{type:3,data:"M0,1 L1,0.6667 L1,1 Z"},"🭉":{type:3,data:"M0.5,1 L1,0.3333 L1,1 Z"},"🭊":{type:3,data:"M0,1 L1,0.3333 L1,1 Z"},"🭋":{type:3,data:"M0.5,1 L1,0 L1,1 Z"},"🭌":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.3333 Z"},"🭍":{type:3,data:"M0,0 L0,1 L1,1 L1,0.3333 Z"},"🭎":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.6667 Z"},"🭏":{type:3,data:"M0,0 L0,1 L1,1 L1,0.6667 Z"},"🭐":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 Z"},"🭑":{type:3,data:"M0,0.3333 L0,1 L1,1 L1,0.6667 Z"},"🭒":{type:3,data:"M0,0.6667 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭓":{type:3,data:"M0,0.6667 L1,1 L1,0 L0,0 Z"},"🭔":{type:3,data:"M0,0.3333 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭕":{type:3,data:"M0,0.3333 L1,1 L1,0 L0,0 Z"},"🭖":{type:3,data:"M0,0 L0.5,1 L1,1 L1,0 Z"},"🭗":{type:3,data:"M0,0.3333 L0,0 L0.5,0 Z"},"🭘":{type:3,data:"M0,0.3333 L0,0 L1,0 Z"},"🭙":{type:3,data:"M0,0.6667 L0,0 L0.5,0 Z"},"🭚":{type:3,data:"M0,0.6667 L0,0 L1,0 Z"},"🭛":{type:3,data:"M0,1 L0,0 L0.5,0 Z"},"🭜":{type:3,data:"M0,0.6667 L0,0 L1,0 L1,0.3333 Z"},"🭝":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.6667 Z"},"🭞":{type:3,data:"M0,1 L0,0 L1,0 L1,0.6667 Z"},"🭟":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.3333 Z"},"🭠":{type:3,data:"M0,1 L0,0 L1,0 L1,0.3333 Z"},"🭡":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 Z"},"🭢":{type:3,data:"M0.5,0 L1,0 L1,0.3333 Z"},"🭣":{type:3,data:"M0,0 L1,0 L1,0.3333 Z"},"🭤":{type:3,data:"M0.5,0 L1,0 L1,0.6667 Z"},"🭥":{type:3,data:"M0,0 L1,0 L1,0.6667 Z"},"🭦":{type:3,data:"M0.5,0 L1,0 L1,1 Z"},"🭧":{type:3,data:"M0,0.3333 L1,0.6667 L1,0 L0,0 Z"},"🭨":{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z"},"🭩":{type:3,data:"M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z"},"🭪":{type:3,data:"M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z"},"🭫":{type:3,data:"M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z"},"🭬":{type:3,data:"M0,0 L0.5,0.5 L0,1 Z"},"🭭":{type:3,data:"M0,0 L1,0 L0.5,0.5 Z"},"🭮":{type:3,data:"M1,0 L1,1 L0.5,0.5 Z"},"🭯":{type:3,data:"M0,1 L1,1 L0.5,0.5 Z"},"🭰":{type:0,data:[{x:1,y:0,w:1,h:8}]},"🭱":{type:0,data:[{x:2,y:0,w:1,h:8}]},"🭲":{type:0,data:[{x:3,y:0,w:1,h:8}]},"🭳":{type:0,data:[{x:4,y:0,w:1,h:8}]},"🭴":{type:0,data:[{x:5,y:0,w:1,h:8}]},"🭵":{type:0,data:[{x:6,y:0,w:1,h:8}]},"🭶":{type:0,data:[{x:0,y:1,w:8,h:1}]},"🭷":{type:0,data:[{x:0,y:2,w:8,h:1}]},"🭸":{type:0,data:[{x:0,y:3,w:8,h:1}]},"🭹":{type:0,data:[{x:0,y:4,w:8,h:1}]},"🭺":{type:0,data:[{x:0,y:5,w:8,h:1}]},"🭻":{type:0,data:[{x:0,y:6,w:8,h:1}]},"🭼":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🭽":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭾":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭿":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🮀":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮁":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮂":{type:0,data:[{x:0,y:0,w:8,h:2}]},"🮃":{type:0,data:[{x:0,y:0,w:8,h:3}]},"🮄":{type:0,data:[{x:0,y:0,w:8,h:5}]},"🮅":{type:0,data:[{x:0,y:0,w:8,h:6}]},"🮆":{type:0,data:[{x:0,y:0,w:8,h:7}]},"🮇":{type:0,data:[{x:6,y:0,w:2,h:8}]},"🮈":{type:0,data:[{x:5,y:0,w:3,h:8}]},"🮉":{type:0,data:[{x:3,y:0,w:5,h:8}]},"🮊":{type:0,data:[{x:2,y:0,w:6,h:8}]},"🮋":{type:0,data:[{x:1,y:0,w:7,h:8}]},"🮌":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},"🮍":{type:1,data:[[1,0],[0,1]],clipPath:"M0.5,0 L1,0 L1,1 L0.5,1 Z"},"🮎":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},"🮏":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},"🮐":{type:1,data:[[0,1],[1,0]]},"🮑":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},{type:0,data:[{x:0,y:0,w:8,h:4}]}],"🮒":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},{type:0,data:[{x:0,y:4,w:8,h:4}]}],"🮔":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},{type:0,data:[{x:4,y:0,w:4,h:8}]}],"🮕":{type:0,data:[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}]},"🮖":{type:0,data:[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}]},"🮗":{type:0,data:[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},"🮘":{type:2,data:"M-0.25,-0.25 L1.25,1.25 M-0.25,0 L1,1.25 M-0.25,0.25 L0.75,1.25 M-0.25,0.5 L0.5,1.25 M0,-0.25 L1.25,1 M0.25,-0.25 L1.25,0.75 M0.5,-0.25 L1.25,0.5 M-0.25,0.75 L0.25,1.25 M0.75,-0.25 L1.25,0.25",strokeWidth:1},"🮙":{type:2,data:"M-0.25,0.5 L0.5,-0.25 M-0.25,0.75 L0.75,-0.25 M-0.25,1 L1,-0.25 M-0.25,1.25 L1.25,-0.25 M0,1.25 L1.25,0 M0.25,1.25 L1.25,0.25 M0.5,1.25 L1.25,0.5 M-0.25,0.25 L0.25,-0.25 M0.75,1.25 L1.25,0.75",strokeWidth:1},"🮚":{type:5,data:{d:"M0,0 L.5,.5 L0,1 L1,1 L.5,.5 L1,0",type:0}},"🮛":{type:5,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1",type:0}},"🮜":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L0,1 Z"},"🮝":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,1 Z"},"🮞":{type:1,data:[[1,0],[0,1]],clipPath:"M1,0 L1,1 L0,1 Z"},"🮟":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,1 L0,1 Z"},"🮠":{type:2,data:"M.5,0 L0,.5",strokeWidth:1},"🮡":{type:2,data:"M.5,0 L1,.5",strokeWidth:1},"🮢":{type:2,data:"M0,.5 L.5,1",strokeWidth:1},"🮣":{type:2,data:"M1,.5 L.5,1",strokeWidth:1},"🮤":{type:2,data:"M.5,0 L0,.5 L.5,1",strokeWidth:1},"🮥":{type:2,data:"M.5,0 L1,.5 L.5,1",strokeWidth:1},"🮦":{type:2,data:"M0,.5 L.5,1 L1,.5",strokeWidth:1},"🮧":{type:2,data:"M0,.5 L.5,0 L1,.5",strokeWidth:1},"🮨":{type:2,data:"M.5,0 L0,.5 M1,.5 L.5,1",strokeWidth:1},"🮩":{type:2,data:"M.5,0 L1,.5 M0,.5 L.5,1",strokeWidth:1},"🮪":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5",strokeWidth:1},"🮫":{type:2,data:"M.5,0 L0,.5 L.5,1 L1,.5",strokeWidth:1},"🮬":{type:2,data:"M0,.5 L.5,0 L1,.5 L.5,1",strokeWidth:1},"🮭":{type:2,data:"M1,.5 L.5,0 L0,.5 L.5,1",strokeWidth:1},"🮮":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5 Z",strokeWidth:1},"🮯":{type:2,data:"M0,.5 L1,.5 M.5,.35 L.5,.65",strokeWidth:1},"🮰":{type:3,data:"M0.1,0.2 L0.1,.8 L.4,.6 L.9,0.6 Z",scaleType:1},"🮱":{type:4,data:{d:"M.1,.525 L.35,.675 L.9,.35",type:1},scaleType:1},"🮲":{type:3,data:"M.29,.27 L0.13,.56 L.22,.59 L.35,0.35 L.67,.35 L.57,.57 L.71,.76 L.22,.76 L.42,1 L.53,.98 L.43,.86 L.9,.86 L.71,.6 L1,.6 L1,.52 L.83,.52 L.92,.36 L1,.36 L1,.27Z M.99,.13 A.12,.12,0,1,1,.75,.13 A.12,.12,0,1,1,.99,.13"},"🮳":{type:3,data:"M0,.27 L.3,.27 L.55,.12 L.63,.18 L.33,.36 L0,.36 M0,.52 L.33,.52 L.59,.89 L.73,.89 L.73,.98 L.53,.98 L.28,.6 L0,.6"},"🮴":{type:4,data:{d:"M.15,.55 L.5,.4 L.5,.45 L.65,.45 L.65,.35 L.85,.35 L.85,.625 L.5,.625 L.5,.7 Z",type:0},scaleType:1},"🮵":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.15,.5 L.5,.35 L.5,.425 L.85,.425 L.85,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮶":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.85,.5 L.5,.35 L.5,.425 L.15,.425 L.15,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮷":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.675 L.2,.5 L.35,.5 L.35,.325 L.65,.325 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮸":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.325 L.2,.5 L.35,.5 L.35,.675 L.65,.675 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮹":{type:5,data:{d:"M1,.89 L.11,.89 L.11,.37 L.36,.12 L.74,.12 L.96,.34 L1,.34 L1,.405 L.92,.405 L.69,.185 L.41,.185 L.21,.42 L.21,.825 L1,.825 Z",type:0}},"🮺":{type:5,data:{d:"M0,.89 L0,.825 L.78,.825 L.78,.53 L.7,.415 L0,.415 L0,.35 L.75,.35 L.88,.48 L.88,.89 Z",type:0}},"🮻":{type:5,data:{d:"M.31,.275 L.44,.275 L.44,.47 L.05,.47 L.05,.405 L.31,.405 Z M.56,.275 L.69,.275 L.69,.405 L.95,.405 L.95,.47 L.56,.47 Z M.05,.53 L.44,.53 L.44,.725 L.31,.725 L.31,.595 L.05,.595 Z M.56,.53 L.95,.53 L.95,.595 L.69,.595 L.69,.725 L.56,.725 Z",type:0},scaleType:1},"🮼":[{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0,.935 L.885,.935 L.885,.065 L0,.065 Z"},{type:3,data:"M.67,.5 A.17,.085,0,1,1,.33,.5 A.17,.085,0,1,1,.67,.5",scaleType:1}],"🮽":{type:4,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1 Z",type:1}},"🮾":{type:4,data:{d:"M1,.5 L.5,1",type:1}},"🮿":{type:4,data:{d:"M.5,0 L1,.5 L.5,1 L0,.5 Z",type:1}},"🯀":{type:3,data:"M.16,.445 A.02,.01,0,0,1,.39,.33 L.5,.375 L.61,.33 A.02,.01,0,0,1,.84,.445 L.75,.5 L.84,.555 A.02,.01,0,0,1,.61,.67 L.5,.625 L.39,.67 A.02,.01,0,0,1,.16,.555 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",scaleType:1},"🯁":{type:3,data:"M0.142308,0.924 Q0.130770,0.924,0.120193,0.922 T0.101924,0.916 T0.089424,0.9065 T0.084616,0.895 V0.025 Q0.084616,0.019,0.089424,0.0135 T0.101924,0.004 T0.120193,-0.002 T0.142308,-0.004 Q0.150000,-0.004,0.157693,-0.003 T0.173078,0.000 L0.430770,0.085 Q0.451924,0.059,0.494232,0.041 T0.587501,0.013 T0.692309,-0.0005 T0.800001,-0.004 H1 V0.055 H0.800001 Q0.771155,0.055,0.742309,0.056 T0.685578,0.060 T0.630770,0.0685 T0.580770,0.0825 T0.543270,0.1045 T0.528847,0.133 V0.647 H0.530770 Q0.596155,0.645,0.659616,0.638 T0.782693,0.6165 T0.893270,0.5805 T1,0.531 V0.623 Q0.934616,0.644,0.880770,0.6595 T0.769232,0.685 T0.650963,0.700 T0.528847,0.707 V0.787 Q0.528847,0.802,0.543270,0.8155 T0.580770,0.8375 T0.630770,0.8515 T0.685578,0.860 T0.742309,0.864 T0.800001,0.865 H1 V0.924 H0.800001 Q0.746155,0.924,0.692309,0.9205 T0.587501,0.907 T0.494232,0.879 T0.430770,0.835 L0.173078,0.920 Q0.165386,0.922,0.157693,0.923 T0.142308,0.924 Z M0.2,0.841 L0.415385,0.770 V0.150 L0.2,0.079 V0.841 Z M1,0.698 Q0.973077,0.694,0.969231,0.6885 T0.965385,0.677 Q0.965385,0.672,0.969231,0.6665 T1,0.657 V0.698 Z"},"🯂":{type:3,data:"M0,0.623 V0.531 Q0.044231,0.512,0.0625,0.4905 T0.092308,0.4465 T0.108654,0.4005 T0.113462,0.354 V0.351 Q0.113462,0.345,0.117308,0.3395 T0.129808,0.3305 T0.148846,0.3245 T0.171154,0.323 H0.501923 Q0.532692,0.323,0.563462,0.3185 T0.617308,0.303 T0.651923,0.2765 T0.663462,0.2435 V0.241 Q0.663462,0.219,0.657692,0.197 T0.639423,0.1545 T0.604808,0.115 T0.549615,0.082 T0.475577,0.0615 T0.392308,0.055 H0 V-0.004 H1 V0.055 H0.667308 Q0.694231,0.071,0.713462,0.09 T0.746154,0.129 T0.766346,0.1705 T0.775,0.213 H1 V0.316 Q0.971154,0.305,0.955769,0.2965 T0.920192,0.2825 T0.876923,0.2745 T0.830769,0.272 H0.773077 Q0.767308,0.297,0.743269,0.319 T0.680769,0.355 T0.595192,0.375 T0.501923,0.381 H0.227308 Q0.223462,0.415,0.211,0.4485 T0.172692,0.5135 T0.108269,0.573 T0,0.623 Z M0.611538,0.924 H0 V0.865 H0.611538 Q0.642308,0.865,0.673077,0.8605 T0.727885,0.845 T0.762308,0.8185 T0.773077,0.787 V0.785 Q0.773077,0.769,0.762308,0.7535 T0.727885,0.727 T0.673077,0.7115 T0.611538,0.707 H0.059615 Q0.048077,0.707,0.037115,0.7045 T0,0.694 V0.653 Q0.026923,0.648,0.037115,0.646 T0.059615,0.644 H0.722692 Q0.753462,0.644,0.784231,0.6395 T0.839038,0.624 T0.873846,0.5975 T0.884615,0.566 V0.564 Q0.884615,0.548,0.873846,0.532 T0.839038,0.5055 T0.784231,0.49 T0.722692,0.4855 H0.392308 Q0.380769,0.4855,0.370192,0.483 T0.351923,0.4765 T0.339423,0.467 T0.334615,0.4555 T0.339423,0.444 T0.351923,0.4345 T0.370192,0.428 T0.392308,0.4255 H0.832692 Q0.855769,0.4255,0.878846,0.4235 T0.922115,0.416 T0.957692,0.4015 T1,0.3815 V0.4685 Q0.975,0.4705,0.966346,0.4725 T0.95,0.4765 Q0.961538,0.4835,0.969231,0.4915 T1,0.5075 V0.6205 Q0.965385,0.6455,0.926923,0.665 T0.84,0.6935 Q0.866923,0.7115,0.877596,0.7345 T0.894231,0.7855 V0.787 Q0.894231,0.815,0.876923,0.8425 T0.820192,0.8895 T0.726923,0.916 T0.611538,0.924 Z"},"🯃":{type:3,data:"M0,0.473 V0.386 Q0.025490,0.378,0.028431,0.3695 T0.031373,0.352 V0.35 Q0.031373,0.342,0.028431,0.333 T0,0.316 V0.213 H0.652941 Q0.684314,0.213,0.715686,0.2085 T0.770588,0.193 T0.804902,0.1665 T0.815686,0.135 V0.133 Q0.815686,0.117,0.804902,0.101 T0.770588,0.0745 T0.715686,0.0595 T0.652941,0.055 H0 V-0.004 H0.652941 Q0.707843,-0.004,0.761765,0.004 T0.856863,0.031 T0.915686,0.0775 T0.933333,0.133 V0.135 Q0.933333,0.163,0.915686,0.1905 T0.856863,0.237 T0.761765,0.264 T0.652941,0.272 H0.109804 Q0.131373,0.29,0.140196,0.31 T0.149020,0.35 V0.352 Q0.149020,0.37,0.142157,0.388 T0.118627,0.4225 T0.076471,0.452 T0,0.473 Z M0,0.625 V0.513 Q0.029412,0.526,0.032353,0.54 T0.035294,0.568 V0.57 Q0.035294,0.584,0.032353,0.598 T0,0.625 Z"},"🯄":{type:3,data:"M0.019231,1.085 V-0.165 H0.980769 V1.085 H0.019231 Z M0.446154,0.527 H0.553846 Q0.553846,0.511,0.5625,0.495 T0.591346,0.466 T0.631731,0.4405 T0.666346,0.4135 T0.688462,0.3825 T0.696154,0.35 Q0.696154,0.33,0.682692,0.311 T0.641346,0.2785 T0.575,0.259 T0.498077,0.253 T0.421154,0.259 T0.356731,0.279 T0.315385,0.3125 T0.301923,0.352 V0.357 H0.409615 V0.354 Q0.409615,0.345,0.414423,0.335 T0.431731,0.318 T0.4625,0.3075 T0.498077,0.304 Q0.517308,0.304,0.534615,0.307 T0.564423,0.3165 T0.582692,0.332 T0.588462,0.35 Q0.588462,0.366,0.572115,0.3805 T0.535577,0.4075 T0.496154,0.4335 T0.465385,0.4625 T0.45,0.4945 T0.446154,0.527 Z M0.5,0.667 Q0.519231,0.667,0.5375,0.664 T0.569231,0.654 T0.588462,0.637 T0.594231,0.617 T0.588462,0.5975 T0.569231,0.581 T0.5375,0.571 T0.5,0.568 T0.4625,0.571 T0.430769,0.581 T0.411538,0.5975 T0.405769,0.617 T0.411538,0.637 T0.430769,0.654 T0.4625,0.664 T0.5,0.667 Z",scaleType:1},"🯅":{type:5,data:{d:"M.44,.425 L.44,.51 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.51 L.56,.425 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯆":{type:5,data:{d:"M.44,.425 L.44,.46 L.23,.385 L.19,.43 L.44,.51 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.61,.735 L.7,.71 L.56,.56 L.56,.51 L.81,.43 L.77,.385 L.56,.46 L.56,.425 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯇":{type:5,data:{d:"M.44,.425 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.425 Z M.18,.53 L.23,.575 L.81,.43 L.77,.385 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯈":{type:5,data:{d:"M.44,.425 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.62,.735 L.71,.71 L.56,.56 L.56,.425 Z M.23,.385 L.18,.43 L.77,.575 L.81,.53 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯉":{type:5,data:{d:"M.44,.425 L.45,.495 L.15,.645 L.34,.645 L.34,.7 L.44,.7 L.44,.645 L.56,.645 L.56,.7 L.66,.7 L.66,.645 L.84,.645 L.54,.495 L.56,.425 Z M.39,.6 L.5,.55 L.60,.6 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯊":{type:5,data:{d:"M.26,.375 L.5,.255 L.74,.375 L.74,.665 L.5,.55 L.26,.665 Z M.37,.395 L.37,.54 L.5,.475 L.63,.54 L.63,.395 L.5,.33 Z",type:0},scaleType:1},"":{type:5,data:{d:"M.09,.41 L.32,.295 L.5,.375 L.68,.295 L.91,.41 L.75,.5 L.91,.59 L.68,.705 L.5,.625 L.32,.705 L.09,.59 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",type:0},scaleType:1},"":{type:5,data:{d:"M.55,.305 L.88,.305 L.88,.355 L.65,.355 L.65,.47 L.88,.47 L.88,.52 L.55,.52 Z",type:0},scaleType:1},"":{type:5,data:{d:"M.38,.39 L.5,.33 L.62,.39 L.62,.53 L.5,.47 L.38,.53 Z",type:0},scaleType:1},"":{type:3,data:"M0,0 L0.6667,0 L0.6667,1 L0,1 Z"},"":{type:3,data:"M0,0 L0.3333,0 L0.3333,1 L0,1 Z"},"":{type:2,data:"M1,.5 L0,1",strokeWidth:1},"":{type:2,data:"M1,0 L0,.5",strokeWidth:1},"":{type:2,data:"M0,0 L1,.5",strokeWidth:1},"":{type:2,data:"M0,.5 L1,1",strokeWidth:1},"":{type:2,data:"M0,0 L.5,1",strokeWidth:1},"":{type:2,data:"M.5,0 L1,1",strokeWidth:1},"":{type:2,data:"M1,0 L.5,1",strokeWidth:1},"":{type:2,data:"M.5,0 L0,1",strokeWidth:1},"":{type:2,data:"M0,0 L.5,.5 L1,0",strokeWidth:1},"":{type:2,data:"M1,0 L.5,.5 L1,1",strokeWidth:1},"":{type:2,data:"M0,1 L.5,.5 L1,1",strokeWidth:1},"":{type:2,data:"M0,0 L.5,.5 L0,1",strokeWidth:1},"":{type:2,data:"M0,0 L.5,1 L1,0",strokeWidth:1},"":{type:2,data:"M1,0 L0,.5 L1,1",strokeWidth:1},"":{type:2,data:"M0,1 L.5,0 L1,1",strokeWidth:1},"":{type:2,data:"M0,0 L1,.5 L0,1",strokeWidth:1},"":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0",type:1}},"":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1",type:1}},"":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1",type:1}},"":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1",type:1}},"":{type:0,data:[{x:2,y:0,w:4,h:4}]},"":{type:0,data:[{x:2,y:4,w:4,h:4}]},"":{type:0,data:[{x:0,y:2,w:4,h:4}]},"":{type:0,data:[{x:4,y:2,w:4,h:4}]},"":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0 Z",type:0}},"":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1 Z",type:0}},"":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1 Z",type:0}},"":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1 Z",type:0}},"":{type:5,data:{d:"M1,0 L.5,0 C.5,.276,.724,.5,1,.5 Z",type:0}},"":{type:5,data:{d:"M0,1 L.5,1 C.5,.724,.276,.5,0,.5 Z",type:0}},"":{type:5,data:{d:"M1,1 L1,.5 C.724,.5,.5,.724,.5,1 Z",type:0}},"":{type:5,data:{d:"M0,0 L0,.5 C.276,.5,.5,.276,.5,0 Z",type:0}},"🯰":{type:5,data:{d:Yo(126),type:0},scaleType:1},"🯱":{type:5,data:{d:Yo(48),type:0},scaleType:1},"🯲":{type:5,data:{d:Yo(109),type:0},scaleType:1},"🯳":{type:5,data:{d:Yo(121),type:0},scaleType:1},"🯴":{type:5,data:{d:Yo(51),type:0},scaleType:1},"🯵":{type:5,data:{d:Yo(91),type:0},scaleType:1},"🯶":{type:5,data:{d:Yo(95),type:0},scaleType:1},"🯷":{type:5,data:{d:Yo(114),type:0},scaleType:1},"🯸":{type:5,data:{d:Yo(127),type:0},scaleType:1},"🯹":{type:5,data:{d:Yo(123),type:0},scaleType:1},"":{type:5,data:{d:"M.5,.175 C.2,.175,.15,.305,.15,.435 L.05,.63 L.35,.63 C.35,.682,.42,.76,.5,.76 C.58,.76,.65,.682,.65,.63 L.95,.63 L.85,.435 C.85,.305,.8,.175,.5,.175 Z",type:0},scaleType:1},...Object.fromEntries(Array.from({length:256},(e,t)=>[String.fromCodePoint(10240+t),{type:6,data:t}]))},r_=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function xr(e){return{type:2,data:()=>{let t=[],r=[.375,.25,.375],n=[0,3/8,5/8];for(let a=0;a<3;a++){let c=e>>a*2&1,l=e>>a*2+1&1;c&&l?t.push(`M0,${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L0,${n[a]+r[a]} Z`):c?t.push(`M0,${n[a]} L${.5},${n[a]} L${.5},${n[a]+r[a]} L0,${n[a]+r[a]} Z`):l&&t.push(`M${.5},${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L${.5},${n[a]+r[a]} Z`)}return t.join(" ")}}}function Yo(e){let t=[];if(e&64){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.2125} L${r+.075},${.175} L${n-.075},${.175} L${n},${.2125} L${n-.075},${.25} L${r+.075},${.25} Z`)}if(e&32){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.175+.075+.015,l=.5-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&16){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.5+.015,l=.825-.075-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&8){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.7875} L${r+.075},${.75} L${n-.075},${.75} L${n},${.7875} L${n-.075},${.825} L${r+.075},${.825} Z`)}if(e&4&&t.push(`M${.125},${.515} L${.2},${.515+.0375} L${.2},${.735-.0375} L${.125},${.735} L${.05},${.735-.0375} L${.05},${.515+.0375} Z`),e&2&&t.push(`M${.125},${.265} L${.2},${.265+.0375} L${.2},${.485-.0375} L${.125},${.485} L${.05},${.485-.0375} L${.05},${.265+.0375} Z`),e&1){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.5} L${r+.075},${.4625} L${n-.075},${.4625} L${n},${.5} L${n-.075},${.5375} L${r+.075},${.5375} Z`)}return t.join(" ")}var Ti=0,ii=0,Zo=!1,vl=!1,ih=!1,Aa,pd=0,n_=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,ii=0,Ti=0,vl=!1,Zo=!1,ih=!1,Aa=this._themeService.colors,pd=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));pd=t*n%(Math.round(l)*2)}if(pd===0&&r_.has(c)&&(pd=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",l=>{l.backgroundColorRGB&&(ii=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ti=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),ih=this._selectionRenderModel.isCellSelected(this._terminal,t,r),ih){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ii=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ii=(this.result.fg&16777215)<<8|255;break;default:ii=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ii=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ii=(this.result.bg&16777215)<<8|255;break}ii=Uc.blend(ii,(this._coreBrowserService.isFocused?Aa.selectionBackgroundOpaque:Aa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ii=(this._coreBrowserService.isFocused?Aa.selectionBackgroundOpaque:Aa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(vl=!0,Aa.selectionForeground&&(Ti=Aa.selectionForeground.rgba>>8&16777215,Zo=!0),m3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)Ti=(this._coreBrowserService.isFocused?Aa.selectionBackgroundOpaque:Aa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Ti=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Ti=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Ti=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Ti=(this.result.fg&16777215)<<8|255;break;default:Ti=this._themeService.colors.foreground.rgba}Ti=Uc.blend(Ti,(this._coreBrowserService.isFocused?Aa.selectionBackgroundOpaque:Aa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Zo=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",l=>{l.backgroundColorRGB&&(ii=l.backgroundColorRGB.rgba>>8&16777215,vl=!0),l.foregroundColorRGB&&(Ti=l.foregroundColorRGB.rgba>>8&16777215,Zo=!0)}),vl&&(ih?ii=e.bg&-16777216&-134217729|ii|50331648:ii=e.bg&-16777216|ii|50331648),Zo&&(Ti=e.fg&-16777216&-67108865|Ti|50331648),this.result.fg&67108864&&(vl&&!Zo&&((this.result.bg&50331648)===0?Ti=this.result.fg&-134217728|Aa.background.rgba>>8&16777215&16777215|50331648:Ti=this.result.fg&-134217728|this.result.bg&67108863,Zo=!0),!vl&&Zo&&((this.result.fg&50331648)===0?ii=this.result.bg&-67108864|Aa.foreground.rgba>>8&16777215&16777215|50331648:ii=this.result.bg&-67108864|this.result.fg&67108863,vl=!0)),Aa=void 0,this.result.bg=vl?ii:this.result.bg,this.result.fg=Zo?Ti:this.result.fg,this.result.ext&=536870911,this.result.ext|=pd<<29&3758096384}},s_=.5,g3=HC||WC?"bottom":"ideographic";function i_(e,t,r,n,a,c,l,d,f,m,x,y,w=0){let v=t_[t];if(v){let S=Array.isArray(v)?v:[v];for(let C of S)a_(e,C,r,n,a,c,l,d,f,m,x,y,w);return!0}return!1}function a_(e,t,r,n,a,c,l,d,f,m,x,y,w=0){let v=a,S=c,C=r,I=n;switch(t.scaleType===1&&(v=l,S=d,C=r+(a-l)/2,I=n+(c-d)/2),t.clipPath&&(e.save(),p_(e,t.clipPath,C,I,v,S)),t.type){case 0:o_(e,t.data,C,I,v,S);break;case 1:h_(e,t.data,C,I,v,S,w);break;case 2:f_(e,t.data,C,I,v,S,m,x,t.strokeWidth);break;case 3:c_(e,t.data,C,I,v,S,m,t.strokeWidth);break;case 4:d_(e,t.data,C,I,v,S,m,y);break;case 5:m_(e,t.data,C,I,v,S,f,m,x);break;case 6:l_(e,t.data,C,I,v,S);break}t.clipPath&&e.restore()}function o_(e,t,r,n,a,c){for(let l=0;l<t.length;l++){let d=t[l],f=a/8,m=c/8;e.fillRect(r+d.x*f,n+d.y*m,d.w*f,d.h*m)}}var Cx=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function l_(e,t,r,n,a,c){let l=a/8,d=c*.1,f=c*.8/8,m=Math.min(l,f);for(let x=0;x<8;x++)if(t&1<<x){let y=Cx[x*2],w=Cx[x*2+1],v=r+(y+1)*l,S=n+d+(w+1)*f;e.beginPath(),e.arc(v,S,m,0,Math.PI*2),e.fill()}}function c_(e,t,r,n,a,c,l,d){let f=typeof t=="string"?t:t(0,0);e.beginPath();let m=0,x=0,y=0,w=0,v="";for(let S of f.split(" ")){let C=S[0],I=S.substring(1).split(",");if(C==="Z"){e.closePath(),v=C;continue}if(C==="V"){let B=n+parseFloat(I[0])*c;e.lineTo(m,B),x=B,y=m,w=x,v=C;continue}if(C==="H"){let B=r+parseFloat(I[0])*a;e.lineTo(B,x),m=B,y=m,w=x,v=C;continue}if(!I[0]||!I[1])continue;if(C==="A"){let B=parseFloat(I[0])*a,z=parseFloat(I[1])*c,O=parseFloat(I[2])*Math.PI/180,$=parseInt(I[3],10),V=parseInt(I[4],10),Y=r+parseFloat(I[5])*a,le=n+parseFloat(I[6])*c;u_(e,m,x,B,z,O,$,V,Y,le),m=Y,x=le;continue}let R=I.map((B,z)=>{let O=parseFloat(B);return z%2===0?r+O*a:n+O*c});if(C==="M")e.moveTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(C==="L")e.lineTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(C==="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(C==="T"){let B,z;v==="Q"||v==="T"?(B=2*m-y,z=2*x-w):(B=m,z=x),e.quadraticCurveTo(B,z,R[0],R[1]),y=B,w=z,m=R[0],x=R[1]}else C==="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=C}d!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*d,e.stroke()):e.fill()}function u_(e,t,r,n,a,c,l,d,f,m){if(n===0||a===0){e.lineTo(f,m);return}n=Math.abs(n),a=Math.abs(a);let x=Math.cos(c),y=Math.sin(c),w=(t-f)/2,v=(r-m)/2,S=x*w+y*v,C=-y*w+x*v,I=n*n,R=a*a,B=S*S,z=C*C,O=B/I+z/R;if(O>1){let ve=Math.sqrt(O);n*=ve,a*=ve,I=n*n,R=a*a}let $=(I*R-I*z-R*B)/(I*z+R*B);$<0&&($=0);let V=(l===d?-1:1)*Math.sqrt($),Y=V*(n*C/a),le=V*-(a*S/n),be=x*Y-y*le+(t+f)/2,pe=y*Y+x*le+(r+m)/2,ee=(S-Y)/n,ke=(C-le)/a,He=(-S-Y)/n,q=(-C-le)/a,ce=Math.atan2(ke,ee),qe=Math.atan2(q,He)-ce;d===0&&qe>0?qe-=2*Math.PI:d===1&&qe<0&&(qe+=2*Math.PI);let Ae=ce+qe;e.ellipse(be,pe,n,a,c,ce,Ae,d===0)}function d_(e,t,r,n,a,c,l,d){e.save(),e.fillRect(r,n,a,c),d&&(e.fillStyle=d,e.strokeStyle=d),e.lineWidth=l,e.lineCap="square",e.beginPath();for(let f of t.d.split(" ")){let m=f[0],x=f.substring(1).split(",");if(!x[0]||!x[1]){m==="Z"&&e.closePath();continue}let y=x.map((w,v)=>{let 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 _x=new Map;function h_(e,t,r,n,a,c,l=0){let d=_x.get(t);d||(d=new Map,_x.set(t,d));let f=e.fillStyle;if(typeof f!="string")throw new Error(`Unexpected fillStyle type "${f}"`);let m=d.get(f);if(!m){let w=t[0].length,v=t.length,S=e.canvas.ownerDocument.createElement("canvas");S.width=w,S.height=v;let C=Fs(S.getContext("2d")),I=new ImageData(w,v),R,B,z,O;if(f.startsWith("#"))R=parseInt(f.slice(1,3),16),B=parseInt(f.slice(3,5),16),z=parseInt(f.slice(5,7),16),O=f.length>7&&parseInt(f.slice(7,9),16)||1;else if(f.startsWith("rgba"))[R,B,z,O]=f.substring(5,f.length-1).split(",").map($=>parseFloat($));else throw new Error(`Unexpected fillStyle color format "${f}" when drawing pattern glyph`);for(let $=0;$<v;$++)for(let V=0;V<w;V++)I.data[($*w+V)*4]=R,I.data[($*w+V)*4+1]=B,I.data[($*w+V)*4+2]=z,I.data[($*w+V)*4+3]=t[$][V]*(O*255);C.putImageData(I,0,0),m=Fs(e.createPattern(S,null)),d.set(f,m)}let x=l>>1&1,y=l&1;x!==0||y!==0?m.setTransform(new DOMMatrix().translateSelf(-x,-y)):m.setTransform(new DOMMatrix),e.fillStyle=m,e.fillRect(r,n,a,c)}function f_(e,t,r,n,a,c,l,d,f){e.save(),e.beginPath(),e.rect(r,n,a,c),e.clip(),e.beginPath();let m;if(typeof t=="function"){let y=.15/c*a;m=t(.15,y)}else m=t;let x={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let y of m.split(" ")){let w=y[0];if(w==="Z"){e.closePath(),x.lastCommand=w;continue}let v=x3[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,b3(S,a,c,r,n,!0,l,0,0,!1),x),x.lastCommand=w)}f!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*f,e.stroke()):e.fill(),e.closePath(),e.restore()}function p_(e,t,r,n,a,c){e.beginPath();for(let l of t.split(" ")){let d=l[0];if(d==="Z"){e.closePath();continue}let f=l.substring(1).split(",");if(!f[0]||!f[1])continue;let m=r+parseFloat(f[0])*a,x=n+parseFloat(f[1])*c;d==="M"?e.moveTo(m,x):d==="L"&&e.lineTo(m,x)}e.clip()}function m_(e,t,r,n,a,c,l,d,f){let m=new Path2D;m.rect(r,n,a,c),e.clip(m),e.beginPath();let x=l/12;e.lineWidth=d*x;let y={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let w of t.d.split(" ")){let v=w[0];if(v==="Z"){e.closePath(),y.lastCommand=v;continue}let S=x3[v];if(!S){f.error(`Could not find drawing instructions for "${v}"`);continue}let C=w.substring(1).split(",");!C[0]||!C[1]||(S(e,b3(C,a,c,r,n,!1,d,(t.leftPadding??0)*(x/2),(t.rightPadding??0)*(x/2)),y),y.lastCommand=v)}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function kx(e,t,r=0){return Math.max(Math.min(e,t),r)}var x3={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 b3(e,t,r,n,a,c,l,d=0,f=0,m=!0){let x=e.map(y=>parseFloat(y)||parseInt(y));if(x.length<2)throw new Error("Too few arguments for instruction");for(let y=0;y<x.length;y+=2){if(x[y]*=t-d*l-f*l,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?kx(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?kx(w,r,0):w}x[y]+=a}return x}var Lx=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={}}},Ix=class{constructor(){this._data=new Lx}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new Lx),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()}},y3=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()}},g_=class extends y3{_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())}}},x_=class extends y3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},b_="requestIdleCallback"in globalThis?x_:g_,Nu=class v3{constructor(){this.fg=0,this.bg=0,this.extended=new w3}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 v3;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}},w3=class A3{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 A3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oo=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return Ks(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=Ks(()=>{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,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new h3;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(Pc||={});var Ex={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},md=2,gd,nc=class _u{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new Ix,this._cacheMapCombined=new Ix,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Nu,this._textureSize=512,this._onAddTextureAtlasCanvas=new Oo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Oo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=S3(t,this._config.deviceCellWidth*4+md*2,this._config.deviceCellHeight+md*2),this._tmpCtx=Fs(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose(),this._onRemoveTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new b_(this._logService);for(let r=33;r<126;r++)t.enqueue(()=>{if(!this._cacheMap.get(r,0,0,0)){let n=this._drawToCache(r,0,0,0,!1,void 0);this._cacheMap.set(r,0,0,0,n)}})}beginFrame(){let t=this._requestClearModel;return this._requestClearModel=!1,t}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(_u.maxAtlasPages&&this._pages.length>=Math.max(4,_u.maxAtlasPages)){let r=this._pages.filter(m=>m.canvas.width*2<=(_u.maxTextureSize||4096)).sort((m,x)=>x.canvas.width!==m.canvas.width?x.canvas.width-m.canvas.width:x.percentageUsed-m.percentageUsed),n=-1,a=0;for(let m=0;m<r.length;m++)if(r[m].canvas.width!==a)n=m,a=r[m].canvas.width;else if(m-n===3)break;let c=r.slice(n,n+4);if(c.length<4||c.some(m=>m.canvas.width!==c[0].canvas.width)){let m=new kc(this._document,this._textureSize);return this._pages.push(m),this._activePages.push(m),this._onAddTextureAtlasCanvas.fire(m.canvas),m}let l=c.map(m=>m.glyphs[0].texturePage).sort((m,x)=>m-x),d=this.pages.length-c.length,f=this._mergePages(c,d);f.version=++kc.nextVersion;for(let m=l.length-1;m>=0;m--)this._deletePage(l[m]);this.pages.push(f),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(f.canvas)}let t=new 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,f=Math.floor(c/2)*l.canvas.height;a.ctx.drawImage(l.canvas,d,f);for(let x of l.glyphs)x.texturePage=r,x.sizeClipSpace.x=x.size.x/n,x.sizeClipSpace.y=x.size.y/n,x.texturePosition.x+=d,x.texturePosition.y+=f,x.texturePositionClipSpace.x=x.texturePosition.x/n,x.texturePositionClipSpace.y=x.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(l.canvas);let m=this._activePages.indexOf(l);m!==-1&&this._activePages.splice(m,1)}return a}_deletePage(t){this._pages.splice(t,1);for(let r=t;r<this._pages.length;r++){let n=this._pages[r];for(let a of n.glyphs)a.texturePage--;n.version=++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 gd=t.get(r,n,a,c),gd||(gd=this._drawToCache(r,n,a,c,l,d),t.set(r,n,a,c,gd)),gd}_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 mo;let c;switch(t){case 16777216:case 33554432:c=this._getColorFromAnsiIndex(r);break;case 50331648:let l=Nu.toColorRGB(r);c=da.toColor(l[0],l[1],l[2]);break;default:n?c=Zd.opaque(this._config.colors.foreground):c=this._config.colors.background;break}return this._config.allowTransparency||(c=Zd.opaque(c)),c}_getForegroundColor(t,r,n,a,c,l,d,f,m,x){let y=this._getMinimumContrastColor(t,r,n,a,c,l,d,m,f,x);if(y)return y;let w;switch(c){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&m&&l<8&&(l+=8),w=this._getColorFromAnsiIndex(l);break;case 50331648:let v=Nu.toColorRGB(l);w=da.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=Zd.opaque(w)),f&&(w=Zd.multiplyOpacity(w,s_)),w}_resolveBackgroundRgba(t,r,n){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(t,r,n,a){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&a&&r<8&&(r+=8),this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(t,r,n,a,c,l,d,f,m,x){if(this._config.minimumContrastRatio===1||x)return;let y=this._getContrastCache(m),w=y.getColor(t,a);if(w!==void 0)return w??void 0;let v=this._resolveBackgroundRgba(r,n,d),S=this._resolveForegroundRgba(c,l,d,f),C=Uc.ensureContrastRatio(v,S,this._config.minimumContrastRatio/(m?2:1));if(!C){y.setColor(t,a,null);return}let I=da.toColor(C>>24&255,C>>16&255,C>>8&255);return y.setColor(t,a,I),I}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,r,n,a,c,l){let d=typeof t=="number"?String.fromCharCode(t):t;l&&this._tmpCanvas.parentElement!==l&&(this._tmpCanvas.style.display="none",l.append(this._tmpCanvas));let f=Math.min(this._config.deviceCellWidth*Math.max(d.length,2)+md*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<f&&(this._tmpCanvas.width=f);let m=Math.min(this._config.deviceCellHeight+md*4,this._textureSize);if(this._tmpCanvas.height<m&&(this._tmpCanvas.height=m),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=r,this._workAttributeData.extended.ext=a,!!this._workAttributeData.isInvisible())return Ex;let x=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),w=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),S=!!this._workAttributeData.isUnderline(),C=!!this._workAttributeData.isStrikethrough(),I=!!this._workAttributeData.isOverline(),R=this._workAttributeData.getFgColor(),B=this._workAttributeData.getFgColorMode(),z=this._workAttributeData.getBgColor(),O=this._workAttributeData.getBgColorMode();if(y){let Be=R;R=z,z=Be;let ne=B;B=O,O=ne}let $=this._getBackgroundColor(O,z,y,w);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=$.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let V=x?this._config.fontWeightBold:this._config.fontWeight,Y=v?"italic":"";this._tmpCtx.font=`${Y} ${V} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=g3;let le=d.length===1&&G1(d.charCodeAt(0)),be=d.length===1&&qC(d.charCodeAt(0)),pe=this._getForegroundColor(r,O,z,n,B,R,y,w,x,m3(d.charCodeAt(0)));this._tmpCtx.fillStyle=pe.css;let ee=be?0:md*2,ke=!1;if(this._config.customGlyphs!==!1){let Be=this._workAttributeData.getUnderlineVariantOffset();ke=i_(this._tmpCtx,d,ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,$.css,Be)}let He=!le,q;if(typeof t=="number"?q=this._unicodeService.wcwidth(t):q=this._unicodeService.getStringCellWidth(t),S){this._tmpCtx.save();let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ne=Be%2===1?.5:0;if(this._tmpCtx.lineWidth=Be,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())He=!1,this._tmpCtx.strokeStyle=`rgb(${Nu.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{He=!1;let We=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&We<8&&(We+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(We).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let Fe=ee,Le=Math.ceil(ee+this._config.deviceCharHeight)-ne-(c?Be*2:0),Re=Le+Be*2,Pe=this._workAttributeData.getUnderlineVariantOffset(),Ee=0,oe=0;for(let We=0;We<q;We++){let rt=!1;this._tmpCtx.save(),Ee=Le,oe=Re;let gt=Fe+We*this._config.deviceCellWidth,ue=Fe+(We+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(gt,Le),this._tmpCtx.lineTo(ue,Le),this._tmpCtx.moveTo(gt,Re),this._tmpCtx.lineTo(ue,Re);break;case 3:Ee=this._config.deviceCharHeight+1,oe=Ee+3*this._config.devicePixelRatio;let Ye=new Path2D;Ye.rect(gt,Ee,this._config.deviceCellWidth,oe-Ee),this._tmpCtx.clip(Ye);let at=this._config.deviceCellWidth,Ne=oe-Ee,Ge=at/6,Ce=Ne/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 mt of H){this._tmpCtx.beginPath();for(let Zt=0;Zt<mt.length;Zt+=2){let Ht=gt+mt[Zt]*Ge,Kt=oe-mt[Zt+1]*Ce;Zt===0?this._tmpCtx.moveTo(Ht,Kt):this._tmpCtx.lineTo(Ht,Kt)}this._tmpCtx.closePath(),this._tmpCtx.fill()}rt=!0;break;case 4:let ae=Pe===0?0:Pe>=Be?Be*2-Pe:Be-Pe;Pe>=Be||ae===0?(this._tmpCtx.setLineDash([Math.round(Be),Math.round(Be)]),this._tmpCtx.moveTo(gt+ae,Le),this._tmpCtx.lineTo(ue,Le)):(this._tmpCtx.setLineDash([Math.round(Be),Math.round(Be)]),this._tmpCtx.moveTo(gt,Le),this._tmpCtx.lineTo(gt+ae,Le),this._tmpCtx.moveTo(gt+ae+Be,Le),this._tmpCtx.lineTo(ue,Le)),Pe=e_(ue-gt,Be,Pe);break;case 5:let ye=.6,Ve=.3,Je=ue-gt,bt=Math.floor(ye*Je),Vt=Math.floor(Ve*Je),Pt=Je-bt-Vt;this._tmpCtx.setLineDash([bt,Vt,Pt]),this._tmpCtx.moveTo(gt,Le),this._tmpCtx.lineTo(ue,Le);break;default:this._tmpCtx.moveTo(gt,Le),this._tmpCtx.lineTo(ue,Le);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 We=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in We&&We.actualBoundingBoxDescent>0){this._tmpCtx.save();let rt=new Path2D;rt.rect(Fe,Ee-Math.ceil(Be/2),this._config.deviceCellWidth*q,oe-Ee+Math.ceil(Be/2)),this._tmpCtx.clip(rt),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=$.css,this._tmpCtx.strokeText(d,ee,ee+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(I){let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ne=Be%2===1?.5:0;this._tmpCtx.lineWidth=Be,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(ee,ee+ne),this._tmpCtx.lineTo(ee+this._config.deviceCharWidth*q,ee+ne),this._tmpCtx.stroke()}if(ke||this._tmpCtx.fillText(d,ee,ee+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let Be=Ep(this._tmpCtx.getImageData(ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight),$,pe,He);if(Be)for(let ne=1;ne<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=$.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,ee,ee+this._config.deviceCharHeight-ne),Be=Ep(this._tmpCtx.getImageData(ee,ee,this._config.deviceCellWidth,this._config.deviceCellHeight),$,pe,He),!!Be);ne++);}if(C){let Be=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),ne=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=Be,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(ee,ee+Math.floor(this._config.deviceCharHeight/2)-ne),this._tmpCtx.lineTo(ee+this._config.deviceCharWidth*q,ee+Math.floor(this._config.deviceCharHeight/2)-ne),this._tmpCtx.stroke()}this._tmpCtx.restore();let ce=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),qe;if(this._config.allowTransparency?qe=y_(ce):qe=Ep(ce,$,pe,He),qe)return Ex;let Ae=this._findGlyphBoundingBox(ce,this._workBoundingBox,f,be,ke,ee),ve,Ie;for(;;){if(this._activePages.length===0){let Be=this._createNewPage();ve=Be,Ie=Be.currentRow,Ie.height=Ae.size.y;break}ve=this._activePages[this._activePages.length-1],Ie=ve.currentRow;for(let Be of this._activePages)Ae.size.y<=Be.currentRow.height&&(ve=Be,Ie=Be.currentRow);for(let Be=this._activePages.length-1;Be>=0;Be--)for(let ne of this._activePages[Be].fixedRows)ne.height<=Ie.height&&Ae.size.y<=ne.height&&(ve=this._activePages[Be],Ie=ne);if(Ae.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)),ve=this._overflowSizePage,Ie=this._overflowSizePage.currentRow,Ie.x+Ae.size.x>=ve.canvas.width&&(Ie.x=0,Ie.y+=Ie.height,Ie.height=0);break}if(Ie.y+Ae.size.y>=ve.canvas.height||Ie.height>Ae.size.y+2){let Be=!1;if(ve.currentRow.y+ve.currentRow.height+Ae.size.y>=ve.canvas.height){let ne;for(let Fe of this._activePages)if(Fe.currentRow.y+Fe.currentRow.height+Ae.size.y<Fe.canvas.height){ne=Fe;break}if(ne)ve=ne;else if(_u.maxAtlasPages&&this._pages.length>=_u.maxAtlasPages&&Ie.y+Ae.size.y<=ve.canvas.height&&Ie.height>=Ae.size.y&&Ie.x+Ae.size.x<=ve.canvas.width)Be=!0;else{let Fe=this._createNewPage();ve=Fe,Ie=Fe.currentRow,Ie.height=Ae.size.y,Be=!0}}Be||(ve.currentRow.height>0&&ve.fixedRows.push(ve.currentRow),Ie={x:0,y:ve.currentRow.y+ve.currentRow.height,height:Ae.size.y},ve.fixedRows.push(Ie),ve.currentRow={x:0,y:Ie.y+Ie.height,height:0})}if(Ie.x+Ae.size.x<=ve.canvas.width)break;Ie===ve.currentRow?(Ie.x=0,Ie.y+=Ie.height,Ie.height=0):ve.fixedRows.splice(ve.fixedRows.indexOf(Ie),1)}return Ae.texturePage=this._pages.indexOf(ve),Ae.texturePosition.x=Ie.x,Ae.texturePosition.y=Ie.y,Ae.texturePositionClipSpace.x=Ie.x/ve.canvas.width,Ae.texturePositionClipSpace.y=Ie.y/ve.canvas.height,Ae.sizeClipSpace.x/=ve.canvas.width,Ae.sizeClipSpace.y/=ve.canvas.height,Ie.height=Math.max(Ie.height,Ae.size.y),Ie.x+=Ae.size.x,ve.ctx.putImageData(ce,Ae.texturePosition.x-this._workBoundingBox.left,Ae.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,Ae.size.x,Ae.size.y),ve.addGlyph(Ae),ve.version=++kc.nextVersion,Ae}_findGlyphBoundingBox(t,r,n,a,c,l){r.top=0;let d=a?this._config.deviceCellHeight:this._tmpCanvas.height,f=a?this._config.deviceCellWidth:n,m=!1;for(let x=0;x<d;x++){for(let y=0;y<f;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.top=x,m=!0;break}}if(m)break}r.left=0,m=!1;for(let x=0;x<l+f;x++){for(let y=0;y<d;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.left=x,m=!0;break}}if(m)break}r.right=f,m=!1;for(let x=l+f-1;x>=l;x--){for(let y=0;y<d;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.right=x,m=!0;break}}if(m)break}r.bottom=d,m=!1;for(let x=d-1;x>=0;x--){for(let y=0;y<f;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.bottom=x,m=!0;break}}if(m)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:r.right-r.left+1,y:r.bottom-r.top+1},sizeClipSpace:{x:r.right-r.left+1,y:r.bottom-r.top+1},offset:{x:-r.left+l+(a||c?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-r.top+l+(a||c?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},T3=class Ym{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++Ym.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=S3(t,r,r),this.ctx=Fs(this.canvas.getContext("2d",{alpha:!0})),n)if(n.length===4)this._glyphs=this._glyphs.concat(n[0].glyphs,n[1].glyphs,n[2].glyphs,n[3].glyphs),this._usedPixels=n[0]._usedPixels+n[1]._usedPixels+n[2]._usedPixels+n[3]._usedPixels;else for(let a=0;a<n.length;++a)this._glyphs=this._glyphs.concat(n[a].glyphs),this._usedPixels+=n[a]._usedPixels}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version=++Ym.nextVersion}};T3.nextVersion=0;var kc=T3;function Ep(e,t,r,n){let a=t.rgba>>>24,c=t.rgba>>>16&255,l=t.rgba>>>8&255,d=r.rgba>>>24,f=r.rgba>>>16&255,m=r.rgba>>>8&255,x=Math.floor((Math.abs(a-d)+Math.abs(c-f)+Math.abs(l-m))/12),y=!0;for(let w=0;w<e.data.length;w+=4)e.data[w]===a&&e.data[w+1]===c&&e.data[w+2]===l||n&&Math.abs(e.data[w]-a)+Math.abs(e.data[w+1]-c)+Math.abs(e.data[w+2]-l)<x?e.data[w+3]=0:y=!1;return y}function y_(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function S3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function v_(e,t,r,n,a,c,l,d,f=!0){let m={foreground:c.foreground,background:c.background,cursor:mo,cursorAccent:mo,selectionForeground:mo,selectionBackgroundTransparent:mo,selectionBackgroundOpaque:mo,selectionInactiveBackgroundTransparent:mo,selectionInactiveBackgroundOpaque:mo,overviewRulerBorder:mo,scrollbarSliderBackground:mo,scrollbarSliderHoverBackground:mo,scrollbarSliderActiveBackground:mo,ansi:c.ansi.slice(),contrastCache:c.contrastCache,halfContrastCache:c.halfContrastCache};return{customGlyphs:f,devicePixelRatio:l,deviceMaxTextureSize:d,letterSpacing:a.letterSpacing,lineHeight:a.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:r,deviceCharHeight:n,fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.fontWeight,fontWeightBold:a.fontWeightBold,allowTransparency:a.allowTransparency,drawBoldTextInBrightColors:a.drawBoldTextInBrightColors,minimumContrastRatio:a.minimumContrastRatio,colors:m}}function Nx(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 w_(e){return(e&50331648)===16777216||(e&50331648)===33554432}var bo=[];function C3(e,t,r,n,a,c,l,d,f,m=!0){let x=v_(n,a,c,l,t,r,d,f,m);for(let S=0;S<bo.length;S++){let C=bo[S],I=C.ownedBy.indexOf(e);if(I>=0){if(Nx(C.config,x))return C.atlas;C.ownedBy.length===1?(C.atlas.dispose(),bo.splice(S,1)):C.ownedBy.splice(I,1);break}}for(let S=0;S<bo.length;S++){let C=bo[S];if(Nx(C.config,x))return C.ownedBy.push(e),C.atlas}let y=e._core,w=y._logService,v={atlas:new nc(document,x,y.unicodeService,w),config:x,ownedBy:[e]};return bo.push(v),v.atlas}function Rx(e){for(let t=0;t<bo.length;t++){let r=bo[t].ownedBy.indexOf(e);if(r!==-1){bo[t].ownedBy.length===1?(bo[t].atlas.dispose(),bo.splice(t,1)):bo[t].ownedBy.splice(r,1);break}}}var A_=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 Mx(e,t,r){let n=new t.ResizeObserver(a=>{let c=a.find(f=>f.target===e);if(!c)return;if(!("devicePixelContentBoxSize"in c)){n?.disconnect(),n=void 0;return}let l=c.devicePixelContentBoxSize[0].inlineSize,d=c.devicePixelContentBoxSize[0].blockSize;l>0&&d>0&&r(l,d)});try{n.observe(e,{box:["device-pixel-content-box"]})}catch{n.disconnect(),n=void 0}return Ks(()=>n?.disconnect())}function T_(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var S_=class _3 extends Nu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new w3,this.combinedData=""}static fromCharData(t){let r=new _3;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?T_(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())}},C_=class extends Kc{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(Ks(()=>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)}},k3=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function L3(e,t,r,n){let a=Fs(e.createProgram());if(e.attachShader(a,Fs(jx(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,Fs(jx(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 jx(e,t,r,n){let a=Fs(e.createShader(t));if(e.shaderSource(a,r),e.compileShader(a),e.getShaderParameter(a,e.COMPILE_STATUS))return a;n.error(e.getShaderInfoLog(a)),e.deleteShader(a)}function __(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 k_=class{constructor(t){this.texture=t,this.version=-1}},L_=`#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 I_(e){let t="";for(let r=1;r<e;r++)t+=` else if (v_texpage == ${r}) { outColor = texture(u_texture[${r}], v_texcoord); }`;return`#version 300 es
|
|
31
|
-
precision lowp float;
|
|
32
|
-
|
|
33
|
-
in vec2 v_texcoord;
|
|
34
|
-
flat in int v_texpage;
|
|
35
|
-
|
|
36
|
-
uniform sampler2D u_texture[${e}];
|
|
37
|
-
|
|
38
|
-
out vec4 outColor;
|
|
39
|
-
|
|
40
|
-
void main() {
|
|
41
|
-
if (v_texpage == 0) {
|
|
42
|
-
outColor = texture(u_texture[0], v_texcoord);
|
|
43
|
-
} ${t}
|
|
44
|
-
}`}var Ss=0,ds,Np=0,xd=0,E_=class extends Kc{constructor(t,r,n,a,c){super(),this._terminal=t,this._gl=r,this._dimensions=n,this._optionsService=a,this._logService=c,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let l=this._gl;nc.maxAtlasPages===void 0&&(nc.maxAtlasPages=Math.min(32,Fs(l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS))),nc.maxTextureSize=Fs(l.getParameter(l.MAX_TEXTURE_SIZE))),this._program=Fs(L3(l,L_,I_(nc.maxAtlasPages),this._logService)),this._register(Ks(()=>l.deleteProgram(this._program))),this._projectionLocation=Fs(l.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Fs(l.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Fs(l.getUniformLocation(this._program,"u_texture"));let d=this._vertexArrayObject=l.createVertexArray();this._register(Ks(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let f=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(Ks(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,f,l.STATIC_DRAW),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=l.createBuffer();this._register(Ks(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=Fs(l.createBuffer()),this._register(Ks(()=>l.deleteBuffer(this._attributesBuffer))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,2,l.FLOAT,!1,44,0),l.vertexAttribDivisor(2,1),l.enableVertexAttribArray(3),l.vertexAttribPointer(3,2,l.FLOAT,!1,44,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(3,1),l.enableVertexAttribArray(4),l.vertexAttribPointer(4,1,l.FLOAT,!1,44,4*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(4,1),l.enableVertexAttribArray(5),l.vertexAttribPointer(5,2,l.FLOAT,!1,44,5*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(5,1),l.enableVertexAttribArray(6),l.vertexAttribPointer(6,2,l.FLOAT,!1,44,7*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(6,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,44,9*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.useProgram(this._program);let w=new Int32Array(nc.maxAtlasPages);for(let v=0;v<nc.maxAtlasPages;v++)w[v]=v;l.uniform1iv(this._textureLocation,w),l.uniformMatrix4fv(this._projectionLocation,!1,k3),this._atlasTextures=[];for(let v=0;v<nc.maxAtlasPages;v++){let S=new k_(Fs(l.createTexture()));this._register(Ks(()=>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,f,m){this._updateCell(this._vertices.attributes,t,r,n,a,c,l,d,f,m)}_updateCell(t,r,n,a,c,l,d,f,m,x){if(Ss=(n*this._terminal.cols+r)*11,a===0||a===void 0){t.fill(0,Ss,Ss+11-1-2);return}this._atlas&&(f&&f.length>1?ds=this._atlas.getRasterizedGlyphCombinedChar(f,c,l,d,!1,this._terminal.element):ds=this._atlas.getRasterizedGlyph(a,c,l,d,!1,this._terminal.element),Np=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),c!==x&&ds.offset.x>Np?(xd=ds.offset.x-Np,t[Ss]=-(ds.offset.x-xd)+this._dimensions.device.char.left,t[Ss+1]=-ds.offset.y+this._dimensions.device.char.top,t[Ss+2]=(ds.size.x-xd)/this._dimensions.device.canvas.width,t[Ss+3]=ds.size.y/this._dimensions.device.canvas.height,t[Ss+4]=ds.texturePage,t[Ss+5]=ds.texturePositionClipSpace.x+xd/this._atlas.pages[ds.texturePage].canvas.width,t[Ss+6]=ds.texturePositionClipSpace.y,t[Ss+7]=ds.sizeClipSpace.x-xd/this._atlas.pages[ds.texturePage].canvas.width,t[Ss+8]=ds.sizeClipSpace.y):(t[Ss]=-ds.offset.x+this._dimensions.device.char.left,t[Ss+1]=-ds.offset.y+this._dimensions.device.char.top,t[Ss+2]=ds.size.x/this._dimensions.device.canvas.width,t[Ss+3]=ds.size.y/this._dimensions.device.canvas.height,t[Ss+4]=ds.texturePage,t[Ss+5]=ds.texturePositionClipSpace.x,t[Ss+6]=ds.texturePositionClipSpace.y,t[Ss+7]=ds.sizeClipSpace.x,t[Ss+8]=ds.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&XC(a,m,ds.size.x,this._dimensions.device.cell.width)&&(t[Ss+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,r=t.cols*t.rows*11;this._vertices.count!==r?this._vertices.attributes=new Float32Array(r):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==r?this._vertices.attributesBuffers[n]=new Float32Array(r):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=r,n=0;for(let a=0;a<t.rows;a++)for(let c=0;c<t.cols;c++)this._vertices.attributes[n+9]=c/t.cols,this._vertices.attributes[n+10]=a/t.rows,n+=11}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),t.uniform2f(this._resolutionLocation,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),this.clear()}render(t){if(!this._atlas)return;let r=this._gl;r.useProgram(this._program),r.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],a=0;for(let c=0;c<t.lineLengths.length;c++){let l=c*this._terminal.cols*11,d=this._vertices.attributes.subarray(l,l+t.lineLengths[c]*11);n.set(d,a),a+=d.length}r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,n.subarray(0,a),r.STREAM_DRAW);for(let c=0;c<this._atlas.pages.length;c++)this._atlas.pages[c].version!==this._atlasTextures[c].version&&this._bindAtlasPageTexture(r,this._atlas,c);r.drawElementsInstanced(r.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,a/11)}setAtlas(t){this._atlas=t,this.invalidateAtlasTextures()}invalidateAtlasTextures(){for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(t,r,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r.pages[n].canvas),this._atlasTextures[n].version=r.pages[n].version}setDimensions(t){this._dimensions=t}},N_=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,r,n,a=!1){if(this.selectionStart=r,this.selectionEnd=n,!r||!n||r[0]===n[0]&&r[1]===n[1]){this.clear();return}let c=t.buffers.active.ydisp,l=r[1]-c,d=n[1]-c,f=Math.max(l,0),m=Math.min(d,t.rows-1);if(f>=t.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=a,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=f,this.viewportCappedEndRow=m,this.startCol=r[0],this.endCol=n[0]}isCellSelected(t,r,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&n>=this.viewportCappedStartRow&&r<this.endCol&&n<=this.viewportCappedEndRow:r<this.startCol&&n>=this.viewportCappedStartRow&&r>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol):!1}};function R_(){return new N_}var M_=2147483648,j_=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=R_()}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)}},D_=`#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
|
-
}`,B_=`#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,Rp=al*Float32Array.BYTES_PER_ELEMENT,Q_=20*al,Dx=class{constructor(){this.attributes=new Float32Array(Q_),this.count=0}},wl=0,Bx=0,Qx=0,Px=0,Ox=0,Fx=0,$x=0,P_=class extends Kc{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 Dx,this._verticesCursor=new Dx;let l=this._gl;this._program=Fs(L3(l,D_,B_,this._logService)),this._register(Ks(()=>l.deleteProgram(this._program))),this._projectionLocation=Fs(l.getUniformLocation(this._program,"u_projection"));let d=this._vertexArrayObject=l.createVertexArray();this._register(Ks(()=>l.deleteVertexArray(d))),l.bindVertexArray(d);let f=new Float32Array([0,0,1,0,0,1,1,1]),m=l.createBuffer();this._register(Ks(()=>l.deleteBuffer(m))),l.bindBuffer(l.ARRAY_BUFFER,m),l.bufferData(l.ARRAY_BUFFER,f,l.STATIC_DRAW),l.enableVertexAttribArray(3),l.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=l.createBuffer();this._register(Ks(()=>l.deleteBuffer(y))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,y),l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,l.STATIC_DRAW),this._attributesBuffer=Fs(l.createBuffer()),this._register(Ks(()=>l.deleteBuffer(this._attributesBuffer))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,l.FLOAT,!1,Rp,0),l.vertexAttribDivisor(0,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,Rp,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,4,l.FLOAT,!1,Rp,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,k3),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,t.attributes,r.DYNAMIC_DRAW),r.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let r=this._terminal,n=this._vertices,a=1,c,l,d,f,m,x,y,w,v,S,C;for(c=0;c<r.rows;c++){for(d=-1,f=0,m=0,x=!1,l=0;l<r.cols;l++)y=(c*r.cols+l)*4,w=t.cells[y+1],v=t.cells[y+2],S=!!(v&67108864),(w!==f||v!==m&&(x||S))&&((f!==0||x&&m!==0)&&(C=a++*al,this._updateRectangle(n,C,m,f,d,l,c)),d=l,f=w,m=v,x=S);(f!==0||x&&m!==0)&&(C=a++*al,this._updateRectangle(n,C,m,f,d,r.cols,c))}n.count=a}updateCursor(t){let r=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){r.count=0;return}let a,c=0;(n.style==="bar"||n.style==="outline")&&(a=c++*al,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(a=c++*al,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(a=c++*al,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),a=c++*al,this._addRectangleFloat(r.attributes,a,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),r.count=c}_updateRectangle(t,r,n,a,c,l,d){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:wl=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:wl=(n&16777215)<<8;break;default:wl=this._themeService.colors.foreground.rgba}else switch(a&50331648){case 16777216:case 33554432:wl=this._themeService.colors.ansi[a&255].rgba;break;case 50331648:wl=(a&16777215)<<8;break;default:wl=this._themeService.colors.background.rgba}t.attributes.length<r+al&&(t.attributes=__(t.attributes,(this._terminal.rows*this._terminal.cols+1)*al)),Bx=c*this._dimensions.device.cell.width,Qx=d*this._dimensions.device.cell.height,Px=(wl>>24&255)/255,Ox=(wl>>16&255)/255,Fx=(wl>>8&255)/255,$x=1,this._addRectangle(t.attributes,r,Bx,Qx,(l-c)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Px,Ox,Fx,$x)}_addRectangle(t,r,n,a,c,l,d,f,m,x){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=c/this._dimensions.device.canvas.width,t[r+3]=l/this._dimensions.device.canvas.height,t[r+4]=d,t[r+5]=f,t[r+6]=m,t[r+7]=x}_addRectangleFloat(t,r,n,a,c,l,d){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=c/this._dimensions.device.canvas.width,t[r+3]=l/this._dimensions.device.canvas.height,t[r+4]=d[0],t[r+5]=d[1],t[r+6]=d[2],t[r+7]=d[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},O_=class extends Kc{constructor(e,t,r,n,a,c,l,d){super(),this._container=t,this._alpha=a,this._coreBrowserService=c,this._optionsService=l,this._themeService=d,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${r}-layer`),this._canvas.style.zIndex=n.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(f=>{this._refreshCharAtlas(e,f),this.reset(e)})),this._register(Ks(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Fs(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,r){}handleSelectionChanged(e,t,r,n=!1){}_setTransparency(e,t){if(t===this._alpha)return;let r=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,r),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=C3(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=g3,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}`}},F_=class extends O_{constructor(t,r,n,a,c,l,d){super(n,t,"link",r,!0,c,l,d),this._register(a.onShowLinkUnderline(f=>this._handleShowLinkUnderline(f))),this._register(a.onHideLinkUnderline(f=>this._handleHideLinkUnderline(f)))}resize(t,r){super.resize(t,r),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&w_(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()}},$_=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 Mp(e,t,r,n){return new $_(e,t,r,n)}var U_=class extends Kc{constructor(e,t,r,n,a,c,l,d,f,m=!0,x){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=r,this._coreBrowserService=n,this._coreService=a,this._decorationService=c,this._logService=l,this._optionsService=d,this._themeService=f,this._customGlyphs=m,this._cursorBlinkStateManager=this._register(new fd),this._charAtlasDisposable=this._register(new fd),this._observerDisposable=this._register(new fd),this._model=new j_,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new S_,this._rectangleRenderer=this._register(new fd),this._glyphRenderer=this._register(new fd),this._onChangeTextureAtlas=this._register(new Oo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Oo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Oo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Oo),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Oo),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let y={antialias:!1,depth:!1,preserveDrawingBuffer:x};if(this._gl=this._canvas.getContext("webgl2",y),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new n_(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new F_(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,d,this._themeService)],this.dimensions=JC(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(d.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new C_(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Mp(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(Mp(this._canvas,"webglcontextrestored",w=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Rx(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Mx(this._canvas,this._coreBrowserService.window,(w,v)=>this._setCanvasDevicePixelDimensions(w,v)),this._register(this._coreBrowserService.onWindowChange(w=>{this._observerDisposable.value=Mx(this._canvas,w,(v,S)=>this._setCanvasDevicePixelDimensions(v,S))})),this._register(Mp(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(Ks(()=>{clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0;for(let w of this._renderLayers)w.dispose();this._canvas.parentElement?.removeChild(this._canvas),Rx(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 P_(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new E_(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=C3(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=UC(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 A_(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let r=this._core,n=this._workCell,a,c,l,d,f,m,x,y,w,v,S,C,I,R,B,z,O;e=Ux(e,r.rows-1,0),t=Ux(t,r.rows-1,0);let $=this._coreService.decPrivateModes.cursorStyle??r.options.cursorStyle??"block",V=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,Y=V-r.buffer.ydisp,le=Math.min(this._terminal.buffer.active.cursorX,r.cols-1),be=-1,pe=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let ee=!1;for(c=e;c<=t;c++){l=c+r.buffer.ydisp;let ke=r.buffer.lines.get(l);if(!ke){for(this._model.lineLengths[c]=0,z=0;z<r.cols;z++)O=(c*r.cols+z)*4,ee=!0,this._nullModelCell(z,c,O,0,0,0);this._setRowBlinkState(c,!1);continue}d=ke;let He=!1;for(this._model.lineLengths[c]=0,S=V===l,x=0,f=this._characterJoinerService.getJoinedCharacters(l),z=0;z<r.cols;z++){if(a=this._cellColorResolver.result.bg,d.loadCell(z,n),z===0&&(a=this._cellColorResolver.result.bg),m=!1,y=z>=x,w=z,f.length>0&&z===f[0][0]&&y){v=f.shift();let q=this._model.selection.isCellSelected(this._terminal,v[0],l);for(B=v[0]+1;B<v[1];B++)y&&=q===this._model.selection.isCellSelected(this._terminal,B,l);y&&=!S||le<v[0]||le>=v[1],y?(m=!0,n=new z_(n,d.translateToString(!0,v[0],v[1]),v[1]-v[0]),w=v[1]-1):x=v[1]}if(C=n.getChars(),I=n.getCode(),B=(c*r.cols+z)*4,!He&&n.isBlink()&&(He=!0),this._cellColorResolver.resolve(n,z,l,this.dimensions.device.cell.width,this.dimensions.device.cell.height),pe&&l===V&&(z===le&&(this._model.cursor={x:le,y:Y,width:n.getWidth(),style:this._coreBrowserService.isFocused?$:r.options.cursorInactiveStyle,cursorWidth:r.options.cursorWidth,dpr:this._devicePixelRatio},be=le+n.getWidth()-1),z>=le&&z<=be&&(this._coreBrowserService.isFocused&&$==="block"||this._coreBrowserService.isFocused===!1&&r.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),this._textBlinkStateManager.isEnabled&&!this._textBlinkStateManager.isBlinkOn&&n.isBlink()&&(this._cellColorResolver.result.fg|=1073741824),I!==0&&(this._model.lineLengths[c]=z+1),!(this._model.cells[B]===I&&this._model.cells[B+1]===this._cellColorResolver.result.bg&&this._model.cells[B+2]===this._cellColorResolver.result.fg&&this._model.cells[B+3]===this._cellColorResolver.result.ext)&&(ee=!0,C.length>1&&(I|=M_),this._model.cells[B]=I,this._model.cells[B+1]=this._cellColorResolver.result.bg,this._model.cells[B+2]=this._cellColorResolver.result.fg,this._model.cells[B+3]=this._cellColorResolver.result.ext,R=n.getWidth(),this._glyphRenderer.value.updateCell(z,c,I,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,C,R,a),m)){for(n=this._workCell,z++;z<=w;z++)O=(c*r.cols+z)*4,this._nullModelCell(z,c,O,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);z--}}this._setRowBlinkState(c,He)}ee&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model),this._updateTextBlinkState()}_nullModelCell(e,t,r,n,a,c){this._glyphRenderer.value.updateCell(e,t,0,n,a,c,"",0,0),this._model.cells[r]=0,this._model.cells[r+1]=n,this._model.cells[r+2]=a,this._model.cells[r+3]=c}_resetBlinkingRowState(){this._rowHasBlinkingCells=new Array(this._terminal.rows).fill(!1),this._rowHasBlinkingCellsCount=0}_setRowBlinkState(e,t){this._rowHasBlinkingCells[e]!==t&&(this._rowHasBlinkingCells[e]=t,this._rowHasBlinkingCellsCount+=t?1:-1)}_updateTextBlinkState(){this._textBlinkStateManager.setNeedsBlinkInViewport(this._rowHasBlinkingCellsCount>0)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0}))}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},z_=class extends Nu{constructor(t,r,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=r,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Ux(e,t,r=0){return Math.max(Math.min(e,t),r)}var H_=class extends Kc{constructor(e){if(p3&&GC()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw new Error("WebGL2 is only supported on Safari 16 and above")}super(),this._onChangeTextureAtlas=this._register(new Oo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Oo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Oo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Oo),this.onContextLoss=this._onContextLoss.event,this._customGlyphs=e?.customGlyphs??!0,this._preserveDrawingBuffer=e?.preserveDrawingBuffer}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let r=t.coreService,n=t.optionsService,a=t,c=a._renderService,l=a._characterJoinerService,d=a._charSizeService,f=a._coreBrowserService,m=a._decorationService,x=a._logService,y=a._themeService;this._renderer=this._register(new U_(e,l,d,f,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(Ks(()=>{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 W_=class{constructor(t,r,n,a={}){this._terminal=t,this._regex=r,this._handler=n,this._options=a}provideLinks(t,r){let n=V_.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 G_(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 V_=class Uh{static computeLink(t,r,n,a){let c=r.flags.includes("g")?r.flags:`${r.flags}g`,l=new RegExp(r.source,c),[d,f]=Uh._getWindowedLineStrings(t-1,n),m=d.join(""),x,y=[];for(;x=l.exec(m);){let w=x[0];if(!G_(w))continue;let[v,S]=Uh._mapStrIdx(n,f,0,x.index),[C,I]=Uh._mapStrIdx(n,v,S,w.length);if(v===-1||S===-1||C===-1||I===-1)continue;let R={start:{x:S+1,y:v+1},end:{x:I,y:C+1}};y.push({range:R,text:w,activate:a})}return y}static _getWindowedLineStrings(t,r){let n,a=t,c=t,l,d,f=[];if(n=r.buffer.active.getLine(t)){let m=n.translateToString(!0);if(n.isWrapped&&m[0]!==" "){for(l=0;(n=r.buffer.active.getLine(--a))&&l<2048&&(d=n.translateToString(!0),l+=d.length,f.push(d),!(!n.isWrapped||d.indexOf(" ")!==-1)););f.reverse()}for(f.push(m),l=0;(n=r.buffer.active.getLine(++c))&&n.isWrapped&&l<2048&&(d=n.translateToString(!0),l+=d.length,f.push(d),d.indexOf(" ")===-1););}return[f,a]}static _mapStrIdx(t,r,n,a){let c=t.buffer.active,l=c.getNullCell(),d=n;for(;a;){let f=c.getLine(r);if(!f)return[-1,-1];for(let m=d;m<f.length;++m){f.getCell(m,l);let x=l.getChars();if(l.getWidth()&&(a-=x.length||1,m===f.length-1&&x==="")){let y=c.getLine(r+1);y&&y.isWrapped&&(y.getCell(0,l),l.getWidth()===2&&(a+=1))}if(a<0)return[r,m]}r++,d=0}return[r,d]}},q_=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Y_(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 Z_=class{constructor(t=Y_,r={}){this._handler=t,this._options=r}activate(t){this._terminal=t;let r=this._options,n=r.urlRegex??q_;this._linkProvider=this._terminal.registerLinkProvider(new W_(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function zx(e){return{dispose:e}}var K_=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()}},X_=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return zx(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=zx(()=>{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)}},J_;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new K_;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(J_||={});var Hx=class zh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new X_,this.onChange=this._onChange.event}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t,this._active||(this.activeVersion=t.version)}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,a=t.length;for(let c=0;c<a;++c){let l=t.charCodeAt(c);if(55296<=l&&l<=56319){if(++c>=a)return r+this.wcwidth(l);let m=t.charCodeAt(c);56320<=m&&m<=57343?l=(l-55296)*1024+m-56320+65536:r+=this.wcwidth(m)}let d=this.charProperties(l,n),f=zh.extractWidth(d);zh.extractShouldJoin(d)&&(f-=zh.extractWidth(n)),r+=f,n=d}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},jp=[[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]],ek=[[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]],Dp=[[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]],tk=[[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 Wx(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 rk=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<jp.length;++e)Al.fill(0,jp[e][0],jp[e][1]+1);for(let e=0;e<Dp.length;++e)Al.fill(2,Dp[e][0],Dp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Al[e]:Wx(e,ek)?0:Wx(e,tk)?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let a=Hx.extractWidth(t);a===0?n=!1:a>r&&(r=a)}return Hx.createPropertyValue(0,r,n)}},nk=class{activate(e){e.unicode.register(new rk)}dispose(){}};function Yc(e){return{dispose:e}}function Hh(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function sk(...e){return Yc(()=>Hh(e))}var I3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(t){return this._isDisposed?t.dispose():this._disposables.add(t),t}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let t of this._disposables)t.dispose();this._disposables.clear()}}clear(){for(let t of this._disposables)t.dispose();this._disposables.clear()}},D0=class{constructor(){this._store=new I3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};D0.None=Object.freeze({dispose(){}});var mf=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}},Zm=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Yc(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Yc(()=>{let c=this._listeners.indexOf(n);c!==-1&&this._listeners.splice(c,1)});return r&&(Array.isArray(r)?r.push(a):r.add(a)),a},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:r}=this._listeners[0];t.call(r,e);return}default:{let t=this._listeners.slice();for(let{fn:r,thisArgs:n}of t)r.call(n,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},ik;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new I3;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(ik||={});function E3(e,t=0,r){let n=setTimeout(()=>{e()},t);return Yc(()=>{clearTimeout(n)})}var ak=class extends D0{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new mf),this._linesCacheDisposables=this._register(new mf),this._lastAccessTimestamp=0,this._register(Yc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=sk(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=E3(()=>{if(!this._linesCache)return;let t=Date.now()-this._lastAccessTimestamp;if(t>=15e3){this._destroyLinesCache();return}this._scheduleLinesCacheTimeout(15e3-t)},e)}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let r=[],n=[0],a=this._terminal.buffer.active.getLine(e);for(;a;){let c=this._terminal.buffer.active.getLine(e+1),l=c?c.isWrapped:!1,d=a.translateToString(!l&&t);if(l&&c){let f=a.getCell(a.length-1);f&&f.getCode()===0&&f.getWidth()===1&&c.getCell(0)?.getWidth()===2&&(d=d.slice(0,-1))}if(r.push(d),l)n.push(n[n.length-1]+d.length);else break;e++,a=c}return[r.join(""),n]}},ok=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}},lk=class{constructor(t,r){this._terminal=t,this._lineCache=r}find(t,r,n,a){if(!t||t.length===0){this._terminal.clearSelection();return}if(n>=this._terminal.cols)throw new Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let c={startRow:r,startCol:n},l=this._findInLine(t,c,a);if(!l)for(let d=r+1;d<this._terminal.buffer.active.baseY+this._terminal.rows&&(c.startRow=d,c.startCol=0,l=this._findInLine(t,c,a),!l);d++);return l}findNextWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let c=0,l=0;a&&(n===t?(c=a.end.x,l=a.end.y):(c=a.start.x,l=a.start.y)),this._lineCache.initLinesCache();let d={startRow:l,startCol:c},f=this._findInLine(t,d,r);if(!f)for(let m=l+1;m<this._terminal.buffer.active.baseY+this._terminal.rows&&(d.startRow=m,d.startCol=0,f=this._findInLine(t,d,r),!f);m++);if(!f&&l!==0)for(let m=0;m<l&&(d.startRow=m,d.startCol=0,f=this._findInLine(t,d,r),!f);m++);return!f&&a&&(d.startRow=a.start.y,d.startCol=0,f=this._findInLine(t,d,r)),f}findPreviousWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let c=this._terminal.buffer.active.baseY+this._terminal.rows-1,l=this._terminal.cols,d=!0;this._lineCache.initLinesCache();let f={startRow:c,startCol:l},m;if(a&&(f.startRow=c=a.start.y,f.startCol=a.start.x,n!==t&&(m=this._findInLine(t,f,r,!1),m||(f.startRow=c=a.end.y,f.startCol=a.end.x))),m??=this._findInLine(t,f,r,d),!m){f.startCol=Math.max(f.startCol,this._terminal.cols);for(let x=c-1;x>=0&&(f.startRow=x,m=this._findInLine(t,f,r,d),!m);x--);}if(!m&&c!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let x=this._terminal.buffer.active.baseY+this._terminal.rows-1;x>=c&&(f.startRow=x,m=this._findInLine(t,f,r,d),!m);x--);return m}_isWholeWord(t,r,n){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t-1]))&&(t+n.length===r.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t+n.length]))}_findInLine(t,r,n={},a=!1){let c=r.startRow,l=r.startCol;if(this._terminal.buffer.active.getLine(c)?.isWrapped){if(a){r.startCol+=this._terminal.cols;return}return r.startRow--,r.startCol+=this._terminal.cols,this._findInLine(t,r,n)}let d=this._lineCache.getLineFromCache(c);d||(d=this._lineCache.translateBufferLineToStringWithWrap(c,!0),this._lineCache.setLineInCache(c,d));let[f,m]=d,x=this._bufferColsToStringOffset(c,l),y=t,w=f;n.regex||(y=n.caseSensitive?t:t.toLowerCase(),w=n.caseSensitive?f:f.toLowerCase());let v=-1;if(n.regex){let S=RegExp(y,n.caseSensitive?"g":"gi"),C;if(a)for(;C=S.exec(w.slice(0,x));)v=S.lastIndex-C[0].length,t=C[0],S.lastIndex-=t.length-1;else C=S.exec(w.slice(x)),C&&C[0].length>0&&(v=x+(S.lastIndex-C[0].length),t=C[0])}else a?x-y.length>=0&&(v=w.lastIndexOf(y,x-y.length)):v=w.indexOf(y,x);if(v>=0){if(n.wholeWord&&!this._isWholeWord(v,w,t))return;let S=0;for(;S<m.length-1&&v>=m[S+1];)S++;let C=S;for(;C<m.length-1&&v+t.length>=m[C+1];)C++;let I=v-m[S],R=v+t.length-m[C],B=this._stringLengthToBufferSize(c+S,I),z=this._stringLengthToBufferSize(c+C,R)-B+this._terminal.cols*(C-S);return{term:t,col:B,row:c+S,size:z}}}_stringLengthToBufferSize(t,r){let n=this._terminal.buffer.active.getLine(t);if(!n)return 0;for(let a=0;a<r;a++){let c=n.getCell(a);if(!c)break;let l=c.getChars();l.length>1&&(r-=l.length-1);let d=n.getCell(a+1);d&&d.getWidth()===0&&r++}return r}_bufferColsToStringOffset(t,r){let n=t,a=0,c=this._terminal.buffer.active.getLine(n);for(;r>0&&c;){for(let l=0;l<r&&l<this._terminal.cols;l++){let d=c.getCell(l);if(!d)break;d.getWidth()&&(a+=d.getCode()===0?1:d.getChars().length)}if(n++,c=this._terminal.buffer.active.getLine(n),c&&!c.isWrapped)break;r-=this._terminal.cols}return a}},ck=class extends D0{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Yc(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,r){this.clearHighlightDecorations();for(let n of t){let a=this._createResultDecorations(n,r,!1);if(a)for(let c of a)this._storeDecoration(c,n)}}createActiveDecoration(t,r){let n=this._createResultDecorations(t,r,!0);if(n)return{decorations:n,match:t,dispose(){Hh(n)}}}clearHighlightDecorations(){Hh(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,r){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:r,dispose(){t.dispose()}})}_applyStyles(t,r,n){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),r&&(t.style.outline=`1px solid ${r}`)),n&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,r,n){let a=[],c=t.col,l=t.size,d=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;l>0;){let m=Math.min(this._terminal.cols-c,l);a.push([d,c,m]),c=0,l-=m,d++}let f=[];for(let m of a){let x=this._terminal.registerMarker(m[0]),y=this._terminal.registerDecoration({marker:x,x:m[1],width:m[2],layer:n?"top":"bottom",backgroundColor:n?r.activeMatchBackground:r.matchBackground,overviewRulerOptions:this._highlightedLines.has(x.line)?void 0:{color:n?r.activeMatchColorOverviewRuler:r.matchOverviewRuler,position:"center"}});if(y){let w=[];w.push(x),w.push(y.onRender(v=>this._applyStyles(v,n?r.activeMatchBorder:r.matchBorder,!1))),w.push(y.onDispose(()=>Hh(w))),f.push(y)}}return f.length===0?void 0:f}},uk=class extends D0{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Zm)}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()}},dk=class extends D0{constructor(t){super(),this._highlightTimeout=this._register(new mf),this._lineCache=this._register(new mf),this._state=new ok,this._resultTracker=this._register(new uk),this._onAfterSearch=this._register(new Zm),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new Zm),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 ak(t),this._engine=new lk(t,this._lineCache.value),this._decorationManager=new ck(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Yc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=E3(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findNextAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_highlightAllMatches(t,r){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],a,c=this._engine.find(t,0,0,r);for(;c&&(a?.row!==c.row||a?.col!==c.col)&&!(n.length>=this._highlightLimit);){a=c,n.push(a);let l=this._terminal.cols,d=a.col+a.size,f=a.row;d>=l&&(f+=Math.floor(d/l),d=d%l),c=this._engine.find(t,f,d,r)}this._resultTracker.updateResults(n,this._highlightLimit),r.decorations&&this._decorationManager.createHighlightDecorations(n,r.decorations)}_findNextAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findNextWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}findPrevious(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findPreviousAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findPreviousWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}_selectResult(t,r,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),r){let a=this._decorationManager.createActiveDecoration(t,r);a&&(this._resultTracker.selectedDecoration=a)}if(!n&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let a=t.row-this._terminal.buffer.active.viewportY;a-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(a)}return!0}};var di=0,hi=0,fi=0,_s=0,$i;(e=>{function t(a,c,l,d){return d!==void 0?`#${Lc(a)}${Lc(c)}${Lc(l)}${Lc(d)}`:`#${Lc(a)}${Lc(c)}${Lc(l)}`}e.toCss=t;function r(a,c,l,d=255){return(a<<24|c<<16|l<<8|d)>>>0}e.toRgba=r;function n(a,c,l,d){return{css:e.toCss(a,c,l,d),rgba:e.toRgba(a,c,l,d)}}e.toColor=n})($i||={});var hk;(e=>{function t(f,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=f.rgba>>24&255,S=f.rgba>>16&255,C=f.rgba>>8&255;di=v+Math.round((x-v)*_s),hi=S+Math.round((y-S)*_s),fi=C+Math.round((w-C)*_s);let I=$i.toCss(di,hi,fi),R=$i.toRgba(di,hi,fi);return{css:I,rgba:R}}e.blend=t;function r(f){return(f.rgba&255)===255}e.isOpaque=r;function n(f,m,x){let y=Wh.ensureContrastRatio(f.rgba,m.rgba,x);if(y)return $i.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(f){let m=(f.rgba|255)>>>0;return[di,hi,fi]=Wh.toChannels(m),{css:$i.toCss(di,hi,fi),rgba:m}}e.opaque=a;function c(f,m){return _s=Math.round(m*255),[di,hi,fi]=Wh.toChannels(f.rgba),{css:$i.toCss(di,hi,fi,_s),rgba:$i.toRgba(di,hi,fi,_s)}}e.opacity=c;function l(f,m){return _s=f.rgba&255,c(f,_s*m/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(hk||={});var ki;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return di=parseInt(a.slice(1,2).repeat(2),16),hi=parseInt(a.slice(2,3).repeat(2),16),fi=parseInt(a.slice(3,4).repeat(2),16),$i.toColor(di,hi,fi);case 5:return di=parseInt(a.slice(1,2).repeat(2),16),hi=parseInt(a.slice(2,3).repeat(2),16),fi=parseInt(a.slice(3,4).repeat(2),16),_s=parseInt(a.slice(4,5).repeat(2),16),$i.toColor(di,hi,fi,_s);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return di=parseInt(c[1],10),hi=parseInt(c[2],10),fi=parseInt(c[3],10),_s=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),$i.toColor(di,hi,fi,_s);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[di,hi,fi,_s]=t.getImageData(0,0,1,1).data,_s!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$i.toRgba(di,hi,fi,_s),css:a}}e.toColor=n})(ki||={});var la;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,c){let l=n/255,d=a/255,f=c/255,m=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),x=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(la||={});var Wh;(e=>{function t(l,d){if(_s=(d&255)/255,_s===1)return d;let f=d>>24&255,m=d>>16&255,x=d>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return di=y+Math.round((f-y)*_s),hi=w+Math.round((m-w)*_s),fi=v+Math.round((x-v)*_s),$i.toRgba(di,hi,fi)}e.blend=t;function r(l,d,f){let m=la.relativeLuminance(l>>8),x=la.relativeLuminance(d>>8);if(Tl(m,x)<f){if(x<m){let v=n(l,d,f),S=Tl(m,la.relativeLuminance(v>>8));if(S<f){let C=a(l,d,f),I=Tl(m,la.relativeLuminance(C>>8));return S>I?v:C}return v}let y=a(l,d,f),w=Tl(m,la.relativeLuminance(y>>8));if(w<f){let v=n(l,d,f),S=Tl(m,la.relativeLuminance(v>>8));return w>S?y:v}return y}}e.ensureContrastRatio=r;function n(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,C=Tl(la.relativeLuminance2(w,v,S),la.relativeLuminance2(m,x,y));for(;C<f&&(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)),C=Tl(la.relativeLuminance2(w,v,S),la.relativeLuminance2(m,x,y));return(w<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=n;function a(l,d,f){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=d>>24&255,v=d>>16&255,S=d>>8&255,C=Tl(la.relativeLuminance2(w,v,S),la.relativeLuminance2(m,x,y));for(;C<f&&(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)),C=Tl(la.relativeLuminance2(w,v,S),la.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})(Wh||={});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 fk=Object.freeze((()=>{let e=[ki.toColor("#2e3436"),ki.toColor("#cc0000"),ki.toColor("#4e9a06"),ki.toColor("#c4a000"),ki.toColor("#3465a4"),ki.toColor("#75507b"),ki.toColor("#06989a"),ki.toColor("#d3d7cf"),ki.toColor("#555753"),ki.toColor("#ef2929"),ki.toColor("#8ae234"),ki.toColor("#fce94f"),ki.toColor("#729fcf"),ki.toColor("#ad7fa8"),ki.toColor("#34e2e2"),ki.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],a=t[r/6%6|0],c=t[r%6];e.push({css:$i.toCss(n,a,c),rgba:$i.toRgba(n,a,c)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:$i.toCss(n,n,n),rgba:$i.toRgba(n,n,n)})}return e})());function Gx(e,t,r){return Math.max(t,Math.min(e,r))}function pk(e){switch(e){case"&":return"&";case"<":return"<"}return e}var N3=class{constructor(e){this._buffer=e}serialize(e,t){let r=this._buffer.getNullCell(),n=this._buffer.getNullCell(),a=r,c=e.start.y,l=e.end.y,d=e.start.x,f=e.end.x;this._beforeSerialize(l-c,c,l);for(let m=c;m<=l;m++){let x=this._buffer.getLine(m);if(x){let y=m===e.start.y?d:0,w=m===e.end.y?f:x.length;for(let v=y;v<w;v++){let 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 V1(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 R3(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 q1(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&R3(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 M3(e,t){let r=e;return typeof r.attributesEquals=="function"?r.attributesEquals(t):V1(e,t)&&ol(e,t)&&q1(e,t)}var mk=class extends N3{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),f=c.getCell(0,this._nextRowFirstChar),m=f.getWidth()>1,x=!1;(f.getChars()&&m?this._nullCellCount<=1:this._nullCellCount<=0)&&((l.getChars()||l.getWidth()===0)&&ol(l,f)&&(x=!0),m&&(d.getChars()||d.getWidth()===0)&&ol(l,f)&&ol(d,f)&&(x=!0)),x||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(t,r){let n=[];if(M3(t,r))return n;let a=!V1(t,r),c=!ol(t,r),l=!q1(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),R3(t,r))t.isUnderline()!==r.isUnderline()&&n.push(t.isUnderline()?4:24);else{let d=t.getUnderlineStyle();if(d===0)n.push(24);else if(d===1&&t.isUnderlineColorDefault())n.push(4);else if(n.push("4:"+d),!t.isUnderlineColorDefault()){let f=t.getUnderlineColor();t.isUnderlineColorRGB()?n.push("58:2::"+(f>>>16&255)+":"+(f>>>8&255)+":"+(f&255)):n.push("58:5:"+f)}}t.isOverline()!==r.isOverline()&&n.push(t.isOverline()?53:55),t.isBlink()!==r.isBlink()&&n.push(t.isBlink()?5:25),t.isInvisible()!==r.isInvisible()&&n.push(t.isInvisible()?8:28),t.isItalic()!==r.isItalic()&&n.push(t.isItalic()?3:23),t.isDim()!==r.isDim()&&n.push(t.isDim()?2:22),t.isStrikethrough()!==r.isStrikethrough()&&n.push(t.isStrikethrough()?9:29)}}return n}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let c=t.getChars()==="",l=this._diffStyle(t,this._cursorStyle);if(c?!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,f=l!==this._lastCursorRow||d!==this._lastCursorCol,m=x=>{x>0?n+=`\x1B[${x}C`:x<0&&(n+=`\x1B[${-x}D`)};f&&((x=>{x>0?n+=`\x1B[${x}B`:x<0&&(n+=`\x1B[${-x}A`)})(l-this._lastCursorRow),m(d-this._lastCursorCol))}let a=this._terminal._core._inputHandler._curAttrData,c=this._diffStyle(a,this._cursorStyle);return c.length>0&&(n+=`\x1B[${c.join(";")}m`),n}},gk=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,r,n){let a=r.length,c=n===void 0?a:Gx(n+t.rows,0,a);return this._serializeBufferByRange(t,r,{start:a-c,end:a-1},!1)}_serializeBufferByRange(t,r,n,a){return new mk(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 xk(n,t,r),c=r.onlySelection??!1,l=r.range;if(l)return a.serialize({start:{x:l.startCol,y:(l.startLine,l.startLine)},end:{x:t.cols,y:(l.endLine,l.endLine)}});if(!c){let f=n.length,m=r.scrollback,x=m===void 0?f:Gx(m+t.rows,0,f);return a.serialize({start:{x:0,y:f-x},end:{x:t.cols,y:f-1}})}let d=this._terminal?.getSelectionPosition();return d!==void 0?a.serialize({start:{x:d.start.x,y:d.start.y},end:{x:d.end.x,y:d.end.y}}):""}_serializeScrollRegion(t){let r=t._core.buffer,n=r.scrollTop,a=r.scrollBottom;return n!==0||a!==t.rows-1?`\x1B[${n+1};${a+1}r`:""}_serializeModes(t){let r="",n=t.modes;if(n.applicationCursorKeysMode&&(r+="\x1B[?1h"),n.applicationKeypadMode&&(r+="\x1B[?66h"),n.bracketedPasteMode&&(r+="\x1B[?2004h"),n.insertMode&&(r+="\x1B[4h"),n.originMode&&(r+="\x1B[?6h"),n.reverseWraparoundMode&&(r+="\x1B[?45h"),n.sendFocusMode&&(r+="\x1B[?1004h"),n.wraparoundMode===!1&&(r+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":r+="\x1B[?9h";break;case"vt200":r+="\x1B[?1000h";break;case"drag":r+="\x1B[?1002h";break;case"any":r+="\x1B[?1003h";break}return n.showCursor||(r+="\x1B[?25l"),r}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let r=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);if(!t?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);r+=`\x1B[?1049h\x1B[H${n}`}return t?.excludeModes||(r+=this._serializeModes(this._terminal),r+=this._serializeScrollRegion(this._terminal)),r}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t??{})}dispose(){}},xk=class extends N3{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=fk}_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(M3(t,r))return;let a=!V1(t,r),c=!ol(t,r),l=!q1(t,r);if(a||c||l){let d=this._getHexColor(t,!0);d&&n.push("color: "+d+";");let f=this._getHexColor(t,!1);f&&n.push("background-color: "+f+";"),t.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&n.push("font-weight: bold;");let m=[];if(t.isUnderline()&&m.push(this._getUnderlineStyle(t)),t.isOverline()&&m.push("overline"),t.isStrikethrough()&&m.push("line-through"),t.isBlink()&&m.push("blink"),m.length>0&&n.push("text-decoration: "+m.join(" ")+";"),t.isUnderline()){let x=this._getUnderlineColor(t);x&&n.push("text-decoration-color: "+x+";")}return t.isInvisible()&&n.push("visibility: hidden;"),t.isItalic()&&n.push("font-style: italic;"),t.isDim()&&n.push("opacity: 0.5;"),n}}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let c=t.getChars()==="",l=this._diffStyle(t,r);l&&(this._currentRow+=l.length===0?"</span><span>":"</span><span style='"+l.join(" ")+"'>"),c?this._currentRow+=" ":this._currentRow+=pk(t.getChars())}_serializeString(){return this._htmlContent}};var bk=class{constructor(e=new yk,t=new j3){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}},j3=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},yk=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 vk=Object.create,D3=Object.defineProperty,wk=Object.getOwnPropertyDescriptor,Ak=Object.getOwnPropertyNames,Tk=Object.getPrototypeOf,Sk=Object.prototype.hasOwnProperty,Ku=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Ck=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ak(t))!Sk.call(e,a)&&a!==r&&D3(e,a,{get:()=>t[a],enumerable:!(n=wk(t,a))||n.enumerable});return e},Xu=(e,t,r)=>(r=e!=null?vk(Tk(e)):{},Ck(!e||!e.__esModule?D3(r,"default",{value:e,enumerable:!0}):r,e)),Y1=Ku(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,C,I=255){return((I&255)<<24|(C&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 C=t(v),I=r(v),R=n(v),B=Number.MAX_SAFE_INTEGER,z=-1;for(let O=0;O<S.length;++O){let $=C-S[O][0],V=I-S[O][1],Y=R-S[O][2],le=$*$+V*V+Y*Y;if(!le)return O;le<B&&(B=le,z=O)}return z}e.nearestColorIndex=d;function f(v,S,C){return Math.max(v,Math.min(C,S))}function m(v,S,C){return C<0&&(C+=1),C>1&&(C-=1),C*6<1?S+(v-S)*6*C:C*2<1?v:C*3<2?S+(v-S)*(4-C*6):S}function x(v,S,C){if(!C){let B=Math.round(S*255);return c(B,B,B)}let I=S<.5?S*(1+C):S+C-S*C,R=2*S-I;return c(f(0,255,Math.round(m(I,R,v+1/3)*255)),f(0,255,Math.round(m(I,R,v)*255)),f(0,255,Math.round(m(I,R,v-1/3)*255)))}function y(v,S,C){return(4278190080|Math.round(C/100*255)<<16|Math.round(S/100*255)<<8|Math.round(v/100*255))>>>0}e.normalizeRGB=y;function w(v,S,C){return x((v+240%360)/360,S/100,C/100)}e.normalizeHLS=w,e.PALETTE_VT340_COLOR=new Uint32Array([y(0,0,0),y(20,20,80),y(80,13,13),y(20,80,20),y(80,20,80),y(20,80,80),y(80,80,20),y(53,53,53),y(26,26,26),y(33,33,60),y(60,26,26),y(33,60,33),y(60,33,60),y(33,60,60),y(60,60,33),y(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46),y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let v=[c(0,0,0),c(205,0,0),c(0,205,0),c(205,205,0),c(0,0,238),c(205,0,205),c(0,250,205),c(229,229,229),c(127,127,127),c(255,0,0),c(0,255,0),c(255,255,0),c(92,92,255),c(255,0,255),c(0,255,255),c(255,255,255)],S=[0,95,135,175,215,255];for(let C=0;C<6;++C)for(let I=0;I<6;++I)for(let R=0;R<6;++R)v.push(c(S[C],S[I],S[R]));for(let C=8;C<=238;C+=10)v.push(c(C,C,C));return new Uint32Array(v)})(),e.DEFAULT_BACKGROUND=c(0,0,0,255),e.DEFAULT_FOREGROUND=c(255,255,255,255)}),B3=Ku(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InWasm=r;var t=n=>{if(Uint8Array.fromBase64)return Uint8Array.fromBase64(n);if(typeof Buffer<"u")return Buffer.from(n,"base64");let a=atob(n),c=new Uint8Array(a.length);for(let l=0;l<c.length;++l)c[l]=a.charCodeAt(l);return c};function r(n){if(n.d){let{t:a,s:c,d:l}=n,d,f,m=WebAssembly;return a===0?c?x=>new m.Instance(f||(f=new m.Module(d||(d=t(l)))),x):x=>f?m.instantiate(f,x):m.instantiate(d||(d=t(l)),x).then(y=>(f=y.module)&&y.instance):a===1?c?()=>f||(f=new m.Module(d||(d=t(l)))):()=>f?Promise.resolve(f):m.compile(d||(d=t(l))).then(x=>f=x):c?()=>d||(d=t(l)):()=>Promise.resolve(d||(d=t(l)))}if(typeof _wasmCtx>"u")throw new Error('must run "inwasm"');_wasmCtx.add(n)}}),Q3=Ku(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=B3(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqLBgKZBAEKf0GIKCgCAEGgKGohAUGEKCgCACIDQaAoaiEAQYAoKAIAQQFrQXxxIgRBoChqIQUgBEEQayADSgRAIARBkChqIQMDQCABIABBA2otAABBAnQoAoAgIABBAmotAABBAnQoAoAYIABBAWotAABBAnQoAoAQIAAtAABBAnQoAoAIcnJyIgY2AgAgAUEDaiAAQQdqLQAAQQJ0KAKAICAAQQZqLQAAQQJ0KAKAGCAAQQVqLQAAQQJ0KAKAECAAQQRqLQAAQQJ0KAKACHJyciIHNgIAIAFBBmogAEELai0AAEECdCgCgCAgAEEKai0AAEECdCgCgBggAEEJai0AAEECdCgCgBAgAEEIai0AAEECdCgCgAhycnIiCDYCACABQQlqIABBD2otAABBAnQoAoAgIABBDmotAABBAnQoAoAYIABBDWotAABBAnQoAoAQIABBDGotAABBAnQoAoAIcnJyIgk2AgAgAiAGciAHciAIciAJciECIAFBDGohASAAQRBqIgAgA0kNAAsLIAAgBUkEQANAIAEgAEEDai0AAEECdCgCgCAgAEECai0AAEECdCgCgBggAEEBai0AAEECdCgCgBAgAC0AAEECdCgCgAhycnIiAzYCACACIANyIQIgAUEDaiEBIABBBGoiACAFSQ0ACwtBfyEAIAJB////B00Ef0GEKCAENgIAQYgoIAFBoChrNgIAQQAFQX8LC+0BAQR/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQX8hAxAADQFBgCgoAgAhAUGEKCgCACEAC0F/IQMgASAAayIBQQJIDQAgAC0AoShBAnQoAoAQIAAtAKAoQQJ0KAKACHIhAgJ/IAFBBEYEQEEDQQQgAC0AoyhBPUYbIAAtAKIoQT1GayEBC0EBIAFBA0kNABogAC0AoihBAnQoAoAYIAJyIQJBAiABQQRHDQAaIAAtAKMoQQJ0KAKAICACciECQQMLIQEgAkH///8HSw0AQQAhA0GIKCgCACIAIAI2AKAoQYgoIAAgAWo2AgALIAML"}),n=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map(d=>d.charCodeAt(0))),a=new Uint32Array(1024);a.fill(4278190080);for(let d=0;d<n.length;++d)a[n[d]]=d<<2;for(let d=0;d<n.length;++d)a[256+n[d]]=d>>4|(d<<4&255)<<8;for(let d=0;d<n.length;++d)a[512+n[d]]=d>>2<<8|(d<<6&255)<<16;for(let d=0;d<n.length;++d)a[768+n[d]]=d<<16;var c=new Uint8Array(0),l=class{constructor(d,f,m){if(this._inst=null,this._ended=!0,this._bytes=0,this.keepSize=d??1048576,this.maxBytes=f??4294901760,this._bytes=m??32768,this._bytes>this.maxBytes||this.maxBytes>4294901760)throw new Error("invalid byte settings")}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):c}release(){this._inst&&(this._bytes>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(d,f){if(this.maxBytes=d??this.maxBytes,this._bytes=f??Math.min(this._bytes,this.maxBytes),this._bytes>this.maxBytes||this.maxBytes>4294901760)throw Error("invalid byte settings");let m=this._m32,x=this._bytes+5152;this._inst?this._mem.buffer.byteLength<x&&(this._mem.grow(Math.ceil((x-this._mem.buffer.byteLength)/65536)),m=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(x/65536)}),this._inst=r({env:{memory:this._mem}}),m=new Uint32Array(this._mem.buffer,0),m.set(a,256),this._d=new Uint8Array(this._mem.buffer,5152)),m[1280]=0,m[1281]=0,m[1282]=0,this._m32=m,this._ended=!1}_realloc(d){let f=this._m32[1280]+d;if(this._bytes<f){if(f>this.maxBytes)return-3;let m=this._bytes;for(;(m*=2)<f;);if(m=Math.min(m,this.maxBytes),m<f)return-3;if(m+5152>this._mem.buffer.byteLength){let x=Math.ceil((m+5152-this._mem.buffer.byteLength)/65536);this._mem.grow(x),this._m32=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)}this._bytes=m}return 0}put(d){if(!this._inst||this._ended)return-2;if(this._realloc(d.length))return-3;let f=this._m32;return this._d.set(d,f[1280]),f[1280]+=d.length,f[1280]-f[1281]>=131072?this._inst.exports.dec():0}end(){return this._ended=!0,this._inst?this._inst.exports.end():-2}get loadedBytes(){return this._inst?this._m32[1280]:0}get freeBytes(){return this._inst?this.maxBytes-this._m32[1280]:0}};e.default=l}),_k=Ku(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=B3(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABCgJgAABgA39/fwACDwEDZW52Bm1lbW9yeQIAAQMDAgABBwcBA2RlYwABCAEACu4EAgwAQQBBAEGAAvwLAAveBAEJf0EAQQBBgAL8CwAgAUEXTgRAIAAgAWpBCGshCkGACCEBIAJBAnRBgAhqIQsgAEEOaiEDQf8BIQZBACECA0AgA0EBaiEHIAMtAAAiCEE/cSEAAkACQCAIQcABcSIJRQRAIABBAnQiAC0AAyEGIAAtAAIhBCAALQABIQUgAC0AACECIAchAwwBCwJAIAhB/QFLDQAgCUHAAUcNACAFQQVsIAJBA2xqIARBB2xqIAZBC2xqQT9xQQJ0IgMgBDoAAiADIAU6AAEgAyACOgAAIANBA2ogBjoAAANAIAEgAjoAACABQQNqIAY6AAAgAUECaiAEOgAAIAFBAWogBToAACABQQRqIQEgAEUEQCAHIQMMBAsgAEEBayEAIAEgC0kNAAsgByEDDAILAn8CQAJAAkAgCEH+AWsOAgABAgsgAy0AAyEEIAMtAAIhBSADLQABIQIgA0EEagwCCyADKAIBIgJBGHYhBiACQRB2IQQgAkEIdiEFIANBBWoMAQsgCUGAAUcEQCAHIAlBwABHDQEaIAQgCEEDcWpBAmshBCACIABBBHZqQQJrIQIgBSAIQQJ2QQNxakECayEFIAcMAQsgBCAAQShrIgkgAy0AASIHQQ9xamohBCACIAdBBHYgCWpqIQIgACAFakEgayEFIANBAmoLIQMgBUEFbCACQQNsaiAEQQdsaiAGQQtsakE/cUECdCIAIAQ6AAIgACAFOgABIAAgAjoAACAAQQNqIAY6AAALIAEgBjoAAyABIAQ6AAIgASAFOgABIAEgAjoAACABQQRqIQELIAMgCkkNAAsLCw=="}),n=class{constructor(a){this.keepSize=a,this.width=0,this.height=0}decode(a){this.width=a[4]<<24|a[5]<<16|a[6]<<8|a[7],this.height=a[8]<<24|a[9]<<16|a[10]<<8|a[11];let c=this.width*this.height,l=c*4,d=a.length,f=Math.max(l,d)+(Math.min(l,d)>>1)+4096;this._inst?this._mem.buffer.byteLength<f&&(this._mem.grow(Math.ceil((f-this._mem.buffer.byteLength)/65536)),this._d=null):(this._mem=new WebAssembly.Memory({initial:Math.ceil(f/65536)}),this._inst=r({env:{memory:this._mem}})),this._d||(this._d=new Uint8Array(this._mem.buffer));let m=this._mem.buffer.byteLength-d&-256;return this._d.set(a,m),this._inst.exports.dec(m,d,c),this._d.subarray(1024,1024+l)}release(){this._inst&&this._mem.buffer.byteLength>this.keepSize&&(this._inst=this._d=this._mem=null)}};e.default=n}),kk=Ku(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"}}),Lk=Ku(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=Y1(),r=kk();function n(v){if(typeof Buffer<"u")return Buffer.from(v,"base64");let S=atob(v),C=new Uint8Array(S.length);for(let I=0;I<C.length;++I)C[I]=S.charCodeAt(I);return C}var a=n(r.LIMITS.BYTES),c,l=new Uint32Array,d=class{constructor(){this.bandHandler=v=>1,this.modeHandler=v=>1}handle_band(v){return this.bandHandler(v)}mode_parsed(v){return this.modeHandler(v)}},f={memoryLimit:2048*65536,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:r.LIMITS.PALETTE_SIZE,truncate:!0};function m(v){let S=new d,C={env:{handle_band:S.handle_band.bind(S),mode_parsed:S.mode_parsed.bind(S)}};return WebAssembly.instantiate(c||a,C).then(I=>(c=c||I.module,new x(v,I.instance||I,S)))}e.DecoderAsync=m;var x=class{constructor(v,S,C){if(this._PIXEL_OFFSET=r.LIMITS.MAX_WIDTH+4,this._canvas=l,this._bandWidths=[],this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},f,v),this._opts.paletteLimit>r.LIMITS.PALETTE_SIZE)throw new Error(`DecoderOptions.paletteLimit must not exceed ${r.LIMITS.PALETTE_SIZE}`);if(S)C.bandHandler=this._handle_band.bind(this),C.modeHandler=this._initCanvas.bind(this);else{let I=c||(c=new WebAssembly.Module(a));S=new WebAssembly.Instance(I,{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 C=v+S;if(C>this._canvas.length){if(this._opts.memoryLimit&&C*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");let I=new Uint32Array(Math.ceil(C/65536)*65536);I.set(this._canvas),this._canvas=I}}_handle_band(v){let S=this._PIXEL_OFFSET,C=this._lastOffset;if(this._mode===2){let I=this.height-this._currentHeight,R=0;for(;R<6&&I>0;)this._canvas.set(this._pSrc.subarray(S*R,S*R+v),C+v*R),R++,I--;this._lastOffset+=v*R,this._currentHeight+=R}else if(this._mode===1){this._realloc(C,v*6),this._maxWidth=Math.max(this._maxWidth,v),this._minWidth=Math.min(this._minWidth,v);for(let I=0;I<6;++I)this._canvas.set(this._pSrc.subarray(S*I,S*I+v),C+v*I);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,C=this._opts.paletteLimit,I=this._opts.truncate){this._wasm.init(this._opts.sixelColor,v,C,I?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,C=v.length){let I=S;for(;I<C;){let R=Math.min(C-I,r.LIMITS.CHUNK_SIZE);this._chunk.set(v.subarray(I,I+=R)),this._wasm.decode(0,R)}}decodeString(v,S=0,C=v.length){let I=S;for(;I<C;){let R=Math.min(C-I,r.LIMITS.CHUNK_SIZE);for(let B=0,z=I;B<R;++B,++z)this._chunk[B]=v.charCodeAt(z);I+=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 C=this._PIXEL_OFFSET,I=this._lastOffset,R=0;for(;R<6&&S>0;)this._canvas.set(this._pSrc.subarray(C*R,C*R+v),I+v*R),R++,S--;S&&this._canvas.fill(this._fillColor,I+v*R)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let R=!1;if(v)if(v!==this._minWidth)R=!0;else{let B=this._PIXEL_OFFSET,z=this._lastOffset;this._realloc(z,v*6);for(let O=0;O<6;++O)this._canvas.set(this._pSrc.subarray(B*O,B*O+v),z+v*O)}if(!R)return this._canvas.subarray(0,this.width*this.height)}let S=new Uint32Array(this.width*this.height);S.fill(this._fillColor);let C=0,I=0;for(let R=0;R<this._bandWidths.length;++R){let B=this._bandWidths[R];for(let z=0;z<6;++z)S.set(this._canvas.subarray(I,I+=B),C),C+=this.width}if(v){let R=this._PIXEL_OFFSET,B=this._wasm.current_height();for(let z=0;z<B;++z)S.set(this._pSrc.subarray(R*z,R*z+v),C+this.width*z)}return S}return l}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=l,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=x;function y(v,S){let C=new x(S);return C.init(),typeof v=="string"?C.decodeString(v):C.decode(v),{width:C.width,height:C.height,data32:C.data32,data8:C.data8}}e.decode=y;async function w(v,S){let C=await m(S);return C.init(),typeof v=="string"?C.decodeString(v):C.decode(v),{width:C.width,height:C.height,data32:C.data32,data8:C.data8}}e.decodeAsync=w});function Km(e){return{dispose:e}}var P3=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()}},O3=class{constructor(){this._store=new P3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};O3.None=Object.freeze({dispose(){}});var Ik=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}},Ek=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Km(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Km(()=>{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)}},Nk;(e=>{function t(c,l){return c(d=>l.fire(d))}e.forward=t;function r(c,l){return(d,f,m)=>c(x=>d.call(f,l(x)),void 0,m)}e.map=r;function n(...c){return(l,d,f)=>{let m=new P3;for(let x of c)m.add(x(y=>l.call(d,y)));return f&&(Array.isArray(f)?f.push(m):f.add(m)),m}}e.any=n;function a(c,l,d){return l(d),c(f=>l(f))}e.runAndSubscribe=a})(Nk||={});var Vx=Xu(Y1()),zu=class sc extends O3{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new Ik),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(Km(()=>{this.removeLayerFromDom(),this.removeLayerFromDom("bottom"),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this._layers.clear(),this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0}))}get canvas(){return this._layers.get("top")?.canvas}static createCanvas(t,r,n){let a=(t??document).createElement("canvas");return a.width=r|0,a.height=n|0,a}static createImageData(t,r,n,a){if(typeof ImageData!="function"){let c=t.createImageData(r,n);return a&&c.data.set(new Uint8ClampedArray(a,0,r*n*4)),c}return a?new ImageData(new Uint8ClampedArray(a,0,r*n*4),r,n):new ImageData(r,n)}static createImageBitmap(t){return typeof createImageBitmap!="function"?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&this.cellSize.height!==-1&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._terminal.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,r,n){let a=t*(this.dimensions?.css.cell.height||0),c=this.dimensions?.css.canvas.width||0,l=(r+1-t)*(this.dimensions?.css.cell.height||0);(!n||n==="top")&&this._layers.get("top")?.clearRect(0,a,c,l),(!n||n==="bottom")&&this._layers.get("bottom")?.clearRect(0,a,c,l)}clearAll(t){if(!t||t==="top"){let r=this._layers.get("top");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}if(!t||t==="bottom"){let r=this._layers.get("bottom");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}}draw(t,r,n,a,c=1){let l=this._layers.get(t.layer);if(!l)return;let{width:d,height:f}=this.cellSize;if(d===-1||f===-1)return;this._rescaleImage(t,d,f);let m=t.actual,x=Math.ceil(m.width/d),y=r%x*d,w=Math.floor(r/x)*f,v=n*d,S=a*f,C=c*d+y>m.width?m.width-y:c*d,I=w+f>m.height?m.height-w:f;l.drawImage(m,Math.floor(y),Math.floor(w),Math.ceil(C),Math.ceil(I),Math.floor(v),Math.floor(S),Math.ceil(C),Math.ceil(I))}extractTile(t,r){let{width:n,height:a}=this.cellSize;if(n===-1||a===-1)return;this._rescaleImage(t,n,a);let c=t.actual,l=Math.ceil(c.width/n),d=r%l*n,f=Math.floor(r/l)*a,m=n+d>c.width?c.width-d:n,x=f+a>c.height?c.height-f:a,y=sc.createCanvas(this.document,m,x),w=y.getContext("2d");if(w)return w.drawImage(c,Math.floor(d),Math.floor(f),Math.floor(m),Math.floor(x),0,0,Math.floor(m),Math.floor(x)),y}drawPlaceholder(t,r,n=1){let a=this._layers.get("top");if(a){let{width:c,height:l}=this.cellSize;if(c===-1||l===-1||(this._placeholder?l>=this._placeholder.height&&this._createPlaceHolder(l+1):this._createPlaceHolder(Math.max(l+1,24)),!this._placeholder))return;a.drawImage(this._placeholderBitmap??this._placeholder,t*c,r*l%2?0:1,c*n,l,t*c,r*l,c*n,l)}}rescaleCanvas(){let t=this.dimensions?.css.canvas.width||0,r=this.dimensions?.css.canvas.height||0;for(let n of this._layers.values())(n.canvas.width!==t||n.canvas.height!==r)&&(n.canvas.width=t,n.canvas.height=r)}_rescaleImage(t,r,n){if(r===t.actualCellSize.width&&n===t.actualCellSize.height)return;let{width:a,height:c}=t.origCellSize;if(r===a&&n===c){t.actual=t.orig,t.actualCellSize.width=a,t.actualCellSize.height=c;return}let l=sc.createCanvas(this.document,Math.ceil(t.orig.width*r/a),Math.ceil(t.orig.height*n/c)),d=l.getContext("2d");d&&(d.drawImage(t.orig,0,0,l.width,l.height),t.actual=l,t.actualCellSize.width=r,t.actualCellSize.height=n)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{for(let r of[...this._layers.keys()])this.removeLayerFromDom(r);this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(t="top"){if(!this.document||!this._terminal._core.screenElement){console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement");return}if(this._layers.has(t))return;let r=sc.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0);r.classList.add(`xterm-image-layer-${t}`);let n=this._terminal._core.screenElement;n.style.isolation="isolate",t==="bottom"?(r.style.zIndex="-1",n.insertBefore(r,n.firstChild)):(r.style.zIndex="0",n.appendChild(r));let a=r.getContext("2d",{alpha:!0});if(!a){r.remove();return}this._layers.set(t,a),this.clearAll(t)}removeLayerFromDom(t="top"){let r=this._layers.get(t);r&&(r.canvas.remove(),this._layers.delete(t))}hasLayer(t){return this._layers.has(t)}_createPlaceHolder(t=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let r=32,n=sc.createCanvas(this.document,r,t),a=n.getContext("2d",{alpha:!1});if(!a)return;let c=sc.createImageData(a,r,t),l=new Uint32Array(c.data.buffer),d=(0,Vx.toRGBA8888)(0,0,0),f=(0,Vx.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]=f}a.putImageData(c,0,0);let m=screen.width+r-1&-32||4096;this._placeholder=sc.createCanvas(this.document,m,t);let x=this._placeholder.getContext("2d",{alpha:!1});if(!x){this._placeholder=void 0;return}for(let y=0;y<m;y+=r)x.drawImage(n,y,0);sc.createImageBitmap(this._placeholder).then(y=>this._placeholderBitmap=y)}get document(){return this._terminal._core._coreBrowserService?.window.document}},El={width:7,height:14},Xm=class F3{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 F3(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},ah=new Xm,Rk=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,f=this._terminal.rows,m=l.x,x=l.y,y=m,w=0;t.scrolling||(l.x=0,l.y=0,y=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(l.y);for(let I=0;I<a;++I){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,I*n+B),w++;if(t.scrolling)I<a-1&&this._terminal._core._inputHandler.lineFeed();else if(++l.y>=f)break;l.x=y}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(l.y),t.scrolling?t.cursorPos==="iip"?l.x=Math.min(y+n,d):l.x=y:(l.x=m,l.y=x);let v=[];for(let[I,R]of this._images.entries())R.tileCount<1&&(R.marker?.dispose(),v.push(I));for(let I of v)this._delImg(I);let S=this._terminal.registerMarker(0);S?.onDispose(()=>{this._images.get(c)&&this._delImg(c)}),this._terminal.buffer.active.type==="alternate"&&this._evictOnAlternate();let C={orig:e,origCellSize:r,actual:e,actualCellSize:{...r},marker:S||void 0,tileCount:w,bufferType:this._terminal.buffer.active.type,layer:t.layer,zIndex:t.zIndex};return this._images.set(c,C),this.onImageAdded?.(),c}render(e){let t=!1,r=!1;for(let m of this._images.values())if(m.layer==="bottom"?r=!0:t=!0,t&&r)break;if(t&&!this._renderer.hasLayer("top")&&(this._renderer.insertLayerToDom("top"),!this._renderer.hasLayer("top")))return;if(r&&!this._renderer.hasLayer("bottom")&&this._renderer.insertLayerToDom("bottom"),this._renderer.rescaleCanvas(),!this._images.size){this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),this._renderer.hasLayer("top")&&this._renderer.removeLayerFromDom("top"),this._renderer.hasLayer("bottom")&&this._renderer.removeLayerFromDom("bottom");return}!t&&this._renderer.hasLayer("top")&&(this._renderer.clearAll("top"),this._renderer.removeLayerFromDom("top")),!r&&this._renderer.hasLayer("bottom")&&(this._renderer.clearAll("bottom"),this._renderer.removeLayerFromDom("bottom")),this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:n,end:a}=e,c=this._terminal._core.buffer,l=this._terminal._core.cols;this._renderer.clearLines(n,a);let d=[],f=[];for(let m=n;m<=a;++m){let x=c.lines.get(m+c.ydisp);if(!x)return;for(let y=0;y<l;++y){let w;if(x.getBg(y)&268435456)w=x._extendedAttrs[y]??ah;else{let C=x._extendedAttrs[y];if(!C||C.imageId===void 0||C.imageId===-1)continue;w=C}let v=w.imageId;if(v===void 0||v===-1)continue;let S=this._images.get(v);if(w.tileId!==-1){let C=w.tileId,I=y,R=1;for(;++y<l;){let B=x._extendedAttrs[y];if(!B||B.imageId!==v||B.tileId!==C+R)break;R++}y--,S?S.actual&&d.push({imgSpec:S,tileId:C,col:I,row:m,count:R}):this._opts.showPlaceholder&&f.push({col:I,row:m,count:R}),this._fullyCleared=!1}}}d.sort((m,x)=>m.imgSpec.zIndex-x.imgSpec.zIndex);for(let m of f)this._renderer.drawPlaceholder(m.col,m.row,m.count);for(let m of d)this._renderer.draw(m.imgSpec,m.tileId,m.col,m.row,m.count)}viewportResize(e){if(!this._images.size){this._viewportMetrics=e;return}if(this._viewportMetrics.cols>=e.cols){this._viewportMetrics=e;return}let t=this._terminal._core.buffer,r=t.lines.length,n=this._viewportMetrics.cols-1;for(let a=0;a<r;++a){let c=t.lines.get(a);if(c.getBg(n)&268435456){let l=c._extendedAttrs[n]??ah,d=l.imageId;if(d===void 0||d===-1)continue;let f=this._images.get(d);if(!f)continue;let m=Math.ceil((f.actual?.width||0)/f.actualCellSize.width);if(l.tileId%m+1>=m)continue;let x=!1;for(let v=n+1;v>e.cols;++v)if(c._data[v*3+0]&4194303){x=!0;break}if(x)continue;let y=Math.min(e.cols,m-l.tileId%m+n),w=l.tileId;for(let v=n+1;v<y;++v)this._writeToCell(c,v,d,++w),f.tileCount++}}this._viewportMetrics=e}getImageAtBufferCell(e,t){let r=this._terminal._core.buffer.lines.get(t);if(r&&r.getBg(e)&268435456){let n=r._extendedAttrs[e]??ah;if(n.imageId&&n.imageId!==-1){let a=this._images.get(n.imageId)?.orig;if(window.ImageBitmap&&a instanceof ImageBitmap){let c=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]??ah;if(n.imageId&&n.imageId!==-1&&n.tileId!==-1){let a=this._images.get(n.imageId);if(a)return this._renderer.extractTile(a,n.tileId)}}}_evictOldest(e){let t=this._getStoredPixels(),r=t;for(;this._pixelLimit<r+e&&this._images.size;){let n=this._images.get(++this._lowestId);n&&n.orig&&(r-=n.orig.width*n.orig.height,n.actual&&n.orig!==n.actual&&(r-=n.actual.width*n.actual.height),n.marker?.dispose(),this._delImg(this._lowestId))}return t-r}_writeToCell(e,t,r,n){if(e._data[t*3+2]&268435456){let a=e._extendedAttrs[t];if(a){if(a.imageId!==void 0){let c=this._images.get(a.imageId);c&&c.tileCount--,a.imageId=r,a.tileId=n;return}e._extendedAttrs[t]=new Xm(a.ext,a.urlId,r,n);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new Xm(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)}},Mk=Xu(Q3()),jk=Xu(_k());function gf(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}function Bp(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 qx(e){let t=gf(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function Dk(e){if(typeof Buffer<"u")return Buffer.from(gf(e),"base64").toString();let t=atob(gf(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 Yx={inline:Bp,size:Bp,name:Dk,width:qx,height:qx,preserveAspectRatio:Bp},Zx=[70,105,108,101],Kx=[77,117,108,116,105,112,97,114,116,70,105,108,101],Qp=[70,105,108,101,80,97,114,116],Pp=[70,105,108,101,69,110,100],Op=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],Fp=1024,Bk=class{constructor(){this.state=0,this._buffer=new Uint32Array(Fp),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===Pp.length){for(let t=0;t<Pp.length;++t)if(this._buffer[t]!==Pp[t])return this._a();return this.fields.type=4,this.state=4,0}if(this._position===Op.length){for(let t=0;t<Op.length;++t)if(this._buffer[t]!==Op[t])return this._a();return this.fields.type=5,this.state=4,0}return this._a()}return this.state===4?0:this.state===3&&this.fields.type===2?this._storeValue(this._position)?(this.state=4,0):this._a():this._a()}parse(t,r,n){let a=this.state,c=this._position,l=this._buffer;if(a===1||a===4||a===0&&c>14)return-1;for(let d=r;d<n;++d){let f=t[d];switch(f){case 59:if(!this._storeValue(c))return this._a();a=2,c=0;break;case 61:if(a===0){if(l[0]===70){let m=0;for(;m<Zx.length;++m)if(l[m]!==Zx[m])return this._a();if(this.fields.type=1,c===Qp.length){for(;m<Qp.length;++m)if(l[m]!==Qp[m])return this._a();return this.fields.type=3,this.state=4,d+1}}else if(l[0]===77){for(let m=0;m<Kx.length;++m)if(l[m]!==Kx[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>=Fp)return this._a();l[c++]=f}break;case 58:return a===3&&!this._storeValue(c)?this._a():(this.state=4,d+1);default:if(c>=Fp)return this._a();l[c++]=f}}return this.state=a,this._position=c,-2}_a(){return this.fields.type=0,this.state=1,-1}_storeKey(t){let r=gf(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]=Yx[this._key]?Yx[this._key](r):r}catch{return!1}return!0}return!1}},xf={mime:"unsupported",width:0,height:0};function Qk(e){if(e.length<24)return xf;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]=Pk(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]}:xf}function Pk(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 $p={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},Ok=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._storage=r,this._coreTerminal=n,this._aborted=!1,this._hp=new Bk,this._header=$p,this._metrics=xf,this._isMultipart=!1,this._abortMulti=!1;let a=Math.ceil(this._opts.iipSizeLimit*4/3),c=Math.min(1048576,a);this._dec=new Mk.default(4194304,a,c),this._qoiDec=new jk.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=xf,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({},$p,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 f=this._coreTerminal._core._coreBrowserService?.dpr??1,m=`\x1B]1337;ReportCellSize=${d.toFixed(3)};${l.toFixed(3)};${f.toFixed(3)}\x1B\\`;return this._coreTerminal.input(m,!1),!0}if(t===2)return this._header=Object.assign({},$p,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=Qk(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 f=a/e,m=(c-n)/t,x=Math.min(f,m);return x<1?[e*x,t*x]:[e,t]}return l?this._header.preserveAspectRatio||!l||!d?[l,t*l/e]:[l,d]:[e*d/t,d]}_dim(e,t,r){return e==="auto"?0:e.endsWith("%")?parseInt(e.slice(0,-1),10)*t/100:e.endsWith("px")?parseInt(e.slice(0,-2),10):parseInt(e,10)*r}},Fk=Xu(Q3());function Xx(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 Jx=0,$k=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=Xx(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 Fk.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,r))!==Jx&&(this._activeDecoder.release(),this._activeDecoder=null,this._decodeError=!0,a&&this._removePendingEntry(n)))}end(e){if(this._aborted||!e)return this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),!0;if(this._inControlData)return this._handleNoPayloadCommand();let t=this._parsedCommand;if(t.action==="d")return this._handleDelete(t);let r=t.id??this._lastPendingKey??0,n=t.more===1,a=this._pendingTransmissions.get(r);if(n)return this._activeDecoder&&(a?(a.totalEncodedSize+=this._totalEncodedSize,a.decodeError=a.decodeError||this._decodeError):this._pendingTransmissions.set(r,{cmd:{...t},decoder:this._activeDecoder,totalEncodedSize:this._totalEncodedSize,decodeError:this._decodeError}),this._lastPendingKey=r,this._activeDecoder=null),!0;a&&(this._lastPendingKey=void 0);let c=this._decodeError,l=t,d=this._activeDecoder;a&&(l=a.cmd,d=a.decoder,c=c||a.decodeError,this._pendingTransmissions.delete(r));let f=new Uint8Array(0);d&&(d.end()!==Jx&&(c=!0),f=d.data8),this._activeDecoder=null;let m=this._handleCommandWithBytesAndCmd(l,f,c);return d&&d.release(),m}_parseControlDataString(){let e="";for(let t=0;t<this._controlLength;t++)e+=String.fromCodePoint(this._controlData[t]);return e}_handleNoPayloadCommand(){let e=Xx(this._parseControlDataString());if(e.id!==void 0&&e.imageNumber!==void 0)return this._sendResponse(e.id,"EINVAL:cannot specify both i and I keys",e.quiet??0),!0;switch(e.action??"t"){case"d":return this._handleDelete(e);case"q":return this._sendResponse(e.id??0,"OK",e.quiet??0),!0;case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handleCommandWithBytesAndCmd(e,t,r){switch(e.action??"t"){case"t":{let n=this._handleTransmit(e,t,r);return(e.transmission??"d")==="d"&&e.id!==void 0&&(r?this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0):t.length>0&&this._sendResponse(e.id,"OK",e.quiet??0)),n}case"T":return this._handleTransmitDisplay(e,t,r);case"q":return this._handleQuery(e,t,r);case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handlePlacement(e){if(e.id===void 0)return!0;let t=e.id,r=this._kittyStorage.getImage(t);return r?this._displayImage(r,e).then(n=>(this._sendResponse(t,n?"OK":"EINVAL:image rendering failed",e.quiet??0,e.placementId),!0)):(this._sendResponse(t,"ENOENT:image not found",e.quiet??0,e.placementId),!0)}_handleTransmit(e,t,r){return(e.transmission??"d")!=="d"?(e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported transmission medium",e.quiet??0),!0):(r||t.length===0||this._kittyStorage.storeImage(e.id,{data:new Blob([t]),width:e.width??0,height:e.height??0,format:e.format??32,compression:e.compression??""}),!0)}_handleTransmitDisplay(e,t,r){if(r)return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0),!0;this._handleTransmit(e,t,r);let n=e.id??this._kittyStorage.lastImageId,a=this._kittyStorage.getImage(n);if(a){let c=this._displayImage(a,e);return e.id!==void 0?c.then(l=>(this._sendResponse(n,l?"OK":"EINVAL:image rendering failed",e.quiet??0),!0)):c.then(()=>!0)}return!0}_handleQuery(e,t,r){let n=e.id??0,a=e.quiet??0;if((e.transmission??"d")!=="d")return this._sendResponse(n,"EINVAL:unsupported transmission medium",a),!0;if(r)return this._sendResponse(n,"EINVAL:invalid base64 data",a),!0;if(t.length===0)return this._sendResponse(n,"OK",a),!0;let c=e.format??32;if(c===100)this._sendResponse(n,"OK",a);else{let l=e.width??0,d=e.height??0;if(!l||!d)return this._sendResponse(n,"EINVAL:width and height required for raw pixel data",a),!0;let f=c===32?4:3,m=l*d*f;if(t.length<m)return this._sendResponse(n,"EINVAL:insufficient pixel data",a),!0;this._sendResponse(n,"OK",a)}return!0}_handleDelete(e){switch(e.deleteSelector??"a"){case"a":case"A":this._cleanupAllPending(),this._kittyStorage.deleteAll();break;case"i":case"I":if(e.id!==void 0){let t=this._pendingTransmissions.get(e.id);t&&t.decoder.release(),this._removePendingEntry(e.id),this._kittyStorage.deleteById(e.id)}break}return!0}_sendResponse(e,t,r,n){let a=t==="OK";if(a&&r>=1||!a&&r>=2)return;let c=n?`,p=${n}`:"",l=`\x1B_Gi=${e}${c};${t}\x1B\\`;this._coreTerminal._core.coreService.triggerDataEvent(l)}_displayImage(e,t){return this._decodeAndDisplay(e,t).then(()=>!0).catch(()=>!1)}async _decodeAndDisplay(e,t){let r=await this._createBitmap(e);try{let n=Math.max(0,t.x??0),a=Math.max(0,t.y??0),c=t.sourceWidth||r.width-n,l=t.sourceHeight||r.height-a,d=Math.max(0,r.width-n),f=Math.max(0,r.height-a),m=Math.max(0,Math.min(c,d)),x=Math.max(0,Math.min(l,f));if(m===0||x===0)throw new Error("invalid source rectangle");if(n!==0||a!==0||m!==r.width||x!==r.height){let be=await createImageBitmap(r,n,a,m,x);r.close(),r=be}let y=this._renderer.dimensions?.css.cell.width||El.width,w=this._renderer.dimensions?.css.cell.height||El.height,v,S;t.columns!==void 0&&t.rows!==void 0?(v=t.columns,S=t.rows):t.columns!==void 0?(v=t.columns,S=Math.max(1,Math.ceil(r.height/r.width*(v*y)/w))):t.rows!==void 0?(S=t.rows,v=Math.max(1,Math.ceil(r.width/r.height*(S*w)/y))):(v=Math.ceil(r.width/y),S=Math.ceil(r.height/w));let C=r.width,I=r.height;if((t.columns!==void 0||t.rows!==void 0)&&(C=Math.round(v*y),I=Math.round(S*w)),C*I>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");let R=this._coreTerminal._core.buffer,B=R.x,z=R.y,O=R.ybase,$=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(C!==r.width||I!==r.height){let be=await createImageBitmap(r,{resizeWidth:C,resizeHeight:I});r.close(),r=be}let V=Math.min(Math.max(0,t.xOffset??0),y-1),Y=Math.min(Math.max(0,t.yOffset??0),w-1);if(V!==0||Y!==0){let be=t.columns!==void 0?Math.round(v*y):r.width+V,pe=t.rows!==void 0?Math.round(S*w):r.height+Y,ee=zu.createCanvas(window.document,be,pe),ke=ee.getContext("2d");if(!ke)throw new Error("Failed to create offset canvas context");ke.drawImage(r,V,Y);let He=await createImageBitmap(ee);if(ee.width=ee.height=0,r.close(),r=He,C=r.width,I=r.height,C*I>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");t.columns===void 0&&(v=Math.ceil(r.width/y)),t.rows===void 0&&(S=Math.ceil(r.height/w))}let le=t.zIndex??0;if(this._kittyStorage.addImage(e.id,r,!0,$,le),r=void 0,t.cursorMovement===1){let be=R.ybase-O;R.x=B,R.y=Math.max(z-be,0)}else R.x=Math.min(B+v,this._coreTerminal.cols)}catch(n){throw r?.close(),n}}async _createBitmap(e){let t=new Uint8Array(await e.data.arrayBuffer());if(e.compression==="z"&&(t=await this._decompressZlib(t)),e.format===100){let C=new Blob([t],{type:"image/png"});if(!window.createImageBitmap){let I=URL.createObjectURL(C),R=new Image;return new Promise((B,z)=>{R.addEventListener("load",()=>{URL.revokeObjectURL(I);let O=zu.createCanvas(window.document,R.width,R.height);O.getContext("2d")?.drawImage(R,0,0),createImageBitmap(O).then(B).catch(z)}),R.addEventListener("error",()=>{URL.revokeObjectURL(I),z(new Error("Failed to load image"))}),R.src=I})}return createImageBitmap(C)}let r=e.width,n=e.height;if(!r||!n)throw new Error("Width and height required for raw pixel data");let a=e.format===32?4:3,c=r*n*a;if(t.length<c)throw new Error("Insufficient pixel data");let l=r*n;if(e.format===32)return createImageBitmap(new ImageData(new Uint8ClampedArray(t.buffer,t.byteOffset,l*4),r,n));let d=new Uint8ClampedArray(l*4),f=new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),m=new Uint32Array(d.buffer),x=l&-4,y=0,w=0;for(let C=0;C<x;C+=4){let I=f[y++],R=f[y++],B=f[y++];m[w++]=4278190080|I,m[w++]=4278190080|I>>>24|R<<8,m[w++]=4278190080|R>>>16|B<<16,m[w++]=4278190080|B>>>8}let v=x*3,S=x*4;for(let C=x;C<l;C++)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),f=0;for(let m of a)d.set(m,f),f+=m.length;return d}get images(){return this._kittyStorage.images}get _kittyIdToStorageId(){return this._kittyStorage.kittyIdToStorageId}get pendingTransmissions(){return this._pendingTransmissions}},$3=class Jm{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>=Jm._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<=Jm._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};$3._maxStoredImages=256;var Uk=$3,y0=Xu(Y1()),zk=Xu(Lk()),Hk=4194304,e1=y0.PALETTE_ANSI_256;e1.set(y0.PALETTE_VT340_COLOR);var Wk=class{constructor(e,t,r){this._opts=e,this._storage=t,this._coreTerminal=r,this._size=0,this._aborted=!1,(0,zk.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:e1,paletteLimit:this._opts.sixelPaletteLimit}).then(n=>this._dec=n)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,e1,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:Gk(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>Hk&&this._dec.release(),this._storage.addImage(n),!0}};function Gk(e,t){let r=0;if(!t)return r;if(e.isInverse())if(e.isFgDefault())r=oh(t.foreground.rgba);else if(e.isFgRGB()){let n=e.constructor.toColorRGB(e.getFgColor());r=(0,y0.toRGBA8888)(...n)}else r=oh(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())r=oh(t.background.rgba);else if(e.isBgRGB()){let n=e.constructor.toColorRGB(e.getBgColor());r=(0,y0.toRGBA8888)(...n)}else r=oh(t.ansi[e.getBgColor()].rgba);return r}function oh(e){return y0.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var Vk=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()}}},qk=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},e2={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},t2=4096,Yk=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new Ek,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},e2,t),this._defaultOpts=Object.assign({},e2,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 Rk(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 Vk(this._storage,this._opts,this._renderer,t),n=new Wk(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 qk(this._storage),n=new Ok(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 Uk(this._storage),n=new $k(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]<=t2?(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;${t2}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}if(t[0]===2)switch(t[1]){case 1:let r=this._renderer?.dimensions?.css.canvas.width,n=this._renderer?.dimensions?.css.canvas.height;if(!r||!n){let c=El;r=(this._terminal?.cols||80)*c.width,n=(this._terminal?.rows||24)*c.height}if(r*n<this._opts.pixelLimit)this._report(`\x1B[?${t[0]};0;${r.toFixed(0)};${n.toFixed(0)}S`);else{let c=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`\x1B[?${t[0]};0;${c};${c}S`)}return!0;case 4:let a=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`\x1B[?${t[0]};0;${a};${a}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}return this._report(`\x1B[?${t[0]};1S`),!0}};const hu=new Map;function ku(e){return{name:e,get hasSubscribers(){return(hu.get(e)?.size??0)>0},publish(t){const r=hu.get(e);if(r)for(const n of r)n(t,e)},subscribe(t){const r=hu.get(e)??new Set;r.add(t),hu.set(e,r)},unsubscribe(t){const r=hu.get(e);if(!r)return!1;const n=r.delete(t);return r.size===0&&hu.delete(e),n}}}function Zk(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},r={start:ku(t.start),end:ku(t.end),asyncStart:ku(t.asyncStart),asyncEnd:ku(t.asyncEnd),error:ku(t.error),traceSync(n,a,c,...l){r.start.publish(a);try{const d=n.apply(c,l);return r.end.publish(a),d}catch(d){throw r.error.publish(d),d}},async tracePromise(n,a,c,...l){r.asyncStart.publish(a);try{const d=await n.apply(c,l);return r.asyncEnd.publish(a),d}catch(d){throw r.error.publish(d),d}},traceCallback(n,a,c,l,...d){r.start.publish(c);try{const f=n.apply(l,d);return r.end.publish(c),f}catch(f){throw r.error.publish(f),f}}};return r}var Kk=Object.create,Z1=Object.defineProperty,Xk=Object.getOwnPropertyDescriptor,Jk=Object.getOwnPropertyNames,eL=Object.getPrototypeOf,tL=Object.prototype.hasOwnProperty,U3=e=>{throw TypeError(e)},rL=(e,t,r)=>t in e?Z1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nL=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},sL=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Jk(t))!tL.call(e,a)&&a!==r&&Z1(e,a,{get:()=>t[a],enumerable:!(n=Xk(t,a))||n.enumerable});return e},iL=(e,t,r)=>(r=e!=null?Kk(eL(e)):{},sL(!e||!e.__esModule?Z1(r,"default",{value:e,enumerable:!0}):r,e)),Ys=(e,t,r)=>rL(e,typeof t!="symbol"?t+"":t,r),K1=(e,t,r)=>t.has(e)||U3("Cannot "+r),ie=(e,t,r)=>(K1(e,t,"read from private field"),r?r.call(e):t.get(e)),vn=(e,t,r)=>t.has(e)?U3("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ir=(e,t,r,n)=>(K1(e,t,"write to private field"),t.set(e,r),r),Wt=(e,t,r)=>(K1(e,t,"access private method"),r),Up=(e,t,r,n)=>({set _(a){Ir(e,t,a)},get _(){return ie(e,t,n)}}),aL=nL((e,t)=>{var r=(()=>{var n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,d=(i,o)=>{for(var u in o)n(i,u,{get:o[u],enumerable:!0})},f=(i,o,u,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of c(o))!l.call(i,p)&&p!==u&&n(i,p,{get:()=>o[p],enumerable:!(h=a(o,p))||h.enumerable});return i},m=i=>f(n({},"__esModule",{value:!0}),i),x={};d(x,{BoundingBox:()=>ne,Font:()=>Xg,Glyph:()=>pr,Path:()=>We,_parse:()=>ot,load:()=>X7,loadSync:()=>J7,parse:()=>K7});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 C=new v,I=new v,R=new Uint8Array(30),B=new Uint16Array(30),z=new Uint8Array(30),O=new Uint16Array(30),$=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),V=new v,Y=new Uint8Array(320);function le(i,o,u,h){var p,g;for(p=0;p<u;++p)i[p]=0;for(p=0;p<30-u;++p)i[p+u]=p/u|0;for(g=h,p=0;p<30;++p)o[p]=g,g+=1<<i[p]}function be(i,o){var u;for(u=0;u<7;++u)i.table[u]=0;for(i.table[7]=24,i.table[8]=152,i.table[9]=112,u=0;u<24;++u)i.trans[u]=256+u;for(u=0;u<144;++u)i.trans[24+u]=u;for(u=0;u<8;++u)i.trans[168+u]=280+u;for(u=0;u<112;++u)i.trans[176+u]=144+u;for(u=0;u<5;++u)o.table[u]=0;for(o.table[5]=32,u=0;u<32;++u)o.trans[u]=u}var pe=new Uint16Array(16);function ee(i,o,u,h){var p,g;for(p=0;p<16;++p)i.table[p]=0;for(p=0;p<h;++p)i.table[o[u+p]]++;for(i.table[0]=0,g=0,p=0;p<16;++p)pe[p]=g,g+=i.table[p];for(p=0;p<h;++p)o[u+p]&&(i.trans[pe[o[u+p]]++]=p)}function ke(i){i.bitcount--||(i.tag=i.source[i.sourceIndex++],i.bitcount=7);var o=i.tag&1;return i.tag>>>=1,o}function He(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 q(i,o){for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var u=0,h=0,p=0,g=i.tag;do h=2*h+(g&1),g>>>=1,++p,u+=o.table[p],h-=o.table[p];while(h>=0);return i.tag=g,i.bitcount-=p,o.trans[u+h]}function ce(i,o,u){var h,p,g,A,k,E;for(h=He(i,5,257),p=He(i,5,1),g=He(i,4,4),A=0;A<19;++A)Y[A]=0;for(A=0;A<g;++A){var D=He(i,3,0);Y[$[A]]=D}for(ee(V,Y,0,19),k=0;k<h+p;){var M=q(i,V);switch(M){case 16:var te=Y[k-1];for(E=He(i,2,3);E;--E)Y[k++]=te;break;case 17:for(E=He(i,3,3);E;--E)Y[k++]=0;break;case 18:for(E=He(i,7,11);E;--E)Y[k++]=0;break;default:Y[k++]=M;break}}ee(o,Y,0,h),ee(u,Y,h,p)}function qe(i,o,u){for(;;){var h=q(i,o);if(h===256)return y;if(h<256)i.dest[i.destLen++]=h;else{var p,g,A,k;for(h-=257,p=He(i,R[h],B[h]),g=q(i,u),A=i.destLen-He(i,z[g],O[g]),k=A;k<A+p;++k)i.dest[i.destLen++]=i.dest[k]}}}function Ae(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 ve(i,o){var u=new S(i,o),h,p,g;do{switch(h=ke(u),p=He(u,2,0),p){case 0:g=Ae(u);break;case 1:g=qe(u,C,I);break;case 2:ce(u,u.ltree,u.dtree),g=qe(u,u.ltree,u.dtree);break;default:g=w}if(g!==y)throw new Error("Data error")}while(!h);return u.destLen<u.dest.length?typeof u.dest.slice=="function"?u.dest.slice(0,u.destLen):u.dest.subarray(0,u.destLen):u.dest}be(C,I),le(R,B,4,3),le(z,O,2,1),R[28]=0,B[28]=258;function Ie(i,o,u,h,p){return Math.pow(1-p,3)*i+3*Math.pow(1-p,2)*p*o+3*(1-p)*Math.pow(p,2)*u+Math.pow(p,3)*h}function Be(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Be.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Be.prototype.addPoint=function(i,o){typeof i=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),i<this.x1&&(this.x1=i),i>this.x2&&(this.x2=i)),typeof o=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=o,this.y2=o),o<this.y1&&(this.y1=o),o>this.y2&&(this.y2=o))},Be.prototype.addX=function(i){this.addPoint(i,null)},Be.prototype.addY=function(i){this.addPoint(null,i)},Be.prototype.addBezier=function(i,o,u,h,p,g,A,k){let E=[i,o],D=[u,h],M=[p,g],te=[A,k];this.addPoint(i,o),this.addPoint(A,k);for(let J=0;J<=1;J++){let Te=6*E[J]-12*D[J]+6*M[J],he=-3*E[J]+9*D[J]-9*M[J]+3*te[J],Me=3*D[J]-3*E[J];if(he===0){if(Te===0)continue;let Rr=-Me/Te;0<Rr&&Rr<1&&(J===0&&this.addX(Ie(E[J],D[J],M[J],te[J],Rr)),J===1&&this.addY(Ie(E[J],D[J],M[J],te[J],Rr)));continue}let ut=Math.pow(Te,2)-4*Me*he;if(ut<0)continue;let mr=(-Te+Math.sqrt(ut))/(2*he);0<mr&&mr<1&&(J===0&&this.addX(Ie(E[J],D[J],M[J],te[J],mr)),J===1&&this.addY(Ie(E[J],D[J],M[J],te[J],mr)));let lr=(-Te-Math.sqrt(ut))/(2*he);0<lr&&lr<1&&(J===0&&this.addX(Ie(E[J],D[J],M[J],te[J],lr)),J===1&&this.addY(Ie(E[J],D[J],M[J],te[J],lr)))}},Be.prototype.addQuad=function(i,o,u,h,p,g){let A=i+.6666666666666666*(u-i),k=o+2/3*(h-o),E=A+1/3*(p-i),D=k+1/3*(g-o);this.addBezier(i,o,A,k,E,D,p,g)};var ne=Be;function Fe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var Le={};function Re(i,o){let u=Math.floor(i),h=i-u;if(Le[o]||(Le[o]={}),Le[o][h]!==void 0){let g=Le[o][h];return u+g}let p=+(Math.round(h+"e+"+o)+"e-"+o);return Le[o][h]=p,u+p}function Pe(i){let o=[[]],u=0,h=0;for(let p=0;p<i.length;p+=1){let g=o[o.length-1],A=i[p],k=g[0],E=g[1],D=g[g.length-1],M=i[p+1];g.push(A),A.type==="M"?(u=A.x,h=A.y):A.type==="L"&&(!M||M.type==="Z")?Math.abs(A.x-u)>1||Math.abs(A.y-h)>1||g.pop():A.type==="L"&&D&&D.x===A.x&&D.y===A.y?g.pop():A.type==="Z"&&(k&&E&&D&&k.type==="M"&&E.type==="L"&&D.type==="L"&&D.x===k.x&&D.y===k.y&&(g.shift(),g[0].type="M"),p+1<i.length&&o.push([]))}return i=[].concat.apply([],o),i}function Ee(i){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},i)}function oe(i){return parseInt(i)===i&&(i={decimalPlaces:i,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},i)}Fe.prototype.fromSVG=function(i,o={}){typeof SVGPathElement<"u"&&i instanceof SVGPathElement&&(i=i.getAttribute("d")),o=Ee(o),this.commands=[];let u="0123456789",h="MmLlQqCcZzHhVv",p="SsTtAa",g="-+",A={},k=[""],E=!1;function D(he){return he.filter(Me=>Me.length).map(Me=>{let ut=parseFloat(Me);return(o.decimalPlaces||o.decimalPlaces===0)&&(ut=Re(ut,o.decimalPlaces)),ut})}function M(he){if(!this.commands.length)return he;let Me=this.commands[this.commands.length-1];for(let ut=0;ut<he.length;ut++)he[ut]+=Me[ut&1?"y":"x"];return he}function te(){if(A.type===void 0)return;let he=A.type.toUpperCase(),Me=he!=="Z"&&A.type.toUpperCase()!==A.type,ut=D(k);if(k=[""],!ut.length&&he!=="Z")return;Me&&he!=="H"&&he!=="V"&&(ut=M.apply(this,[ut]));let mr=this.commands.length&&this.commands[this.commands.length-1].x||0,lr=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(he){case"M":this.moveTo(...ut);break;case"L":this.lineTo(...ut);break;case"V":for(let Rr=0;Rr<ut.length;Rr++){let sn=0;Me&&(sn=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(mr,ut[Rr]+sn)}break;case"H":for(let Rr=0;Rr<ut.length;Rr++){let sn=0;Me&&(sn=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(ut[Rr]+sn,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 Rr in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Rr]===void 0&&(this.commands[this.commands.length-1][Rr]=0)}for(let he=0;he<i.length;he++){let Me=i.charAt(he),ut=k[k.length-1];if(u.indexOf(Me)>-1)k[k.length-1]+=Me;else if(g.indexOf(Me)>-1)if(!A.type&&!this.commands.length&&(A.type="L"),Me==="-")!A.type||ut.indexOf("-")>0?E=!0:ut.length?k.push("-"):k[k.length-1]=Me;else if(!A.type||ut.length>0)E=!0;else continue;else if(h.indexOf(Me)>-1)A.type?(te.apply(this),A={type:Me}):A.type=Me;else{if(p.indexOf(Me)>-1)throw new Error("Unsupported path command: "+Me+". Currently supported commands are "+h.split("").join(", ")+".");` ,
|
|
69
|
-
\r\f\v`.indexOf(Me)>-1?k.push(""):Me==="."?!A.type||ut.indexOf(Me)>-1?E=!0:k[k.length-1]+=Me:E=!0}if(E)throw new Error("Unexpected character: "+Me+" at offset "+he)}te.apply(this),o.optimize&&(this.commands=Pe(this.commands));let J=o.flipY,Te=o.flipYBase;if(J===!0&&o.flipYBase===void 0){let he=this.getBoundingBox();Te=he.y1+he.y2}for(let he in this.commands){let Me=this.commands[he];for(let ut in Me)["x","x1","x2"].includes(ut)?this.commands[he][ut]=o.x+Me[ut]*o.scale:["y","y1","y2"].includes(ut)&&(this.commands[he][ut]=o.y+(J?Te-Me[ut]:Me[ut])*o.scale)}return this},Fe.fromSVG=function(i,o){return new Fe().fromSVG(i,o)},Fe.prototype.moveTo=function(i,o){this.commands.push({type:"M",x:i,y:o})},Fe.prototype.lineTo=function(i,o){this.commands.push({type:"L",x:i,y:o})},Fe.prototype.curveTo=Fe.prototype.bezierCurveTo=function(i,o,u,h,p,g){this.commands.push({type:"C",x1:i,y1:o,x2:u,y2:h,x:p,y:g})},Fe.prototype.quadTo=Fe.prototype.quadraticCurveTo=function(i,o,u,h){this.commands.push({type:"Q",x1:i,y1:o,x:u,y:h})},Fe.prototype.close=Fe.prototype.closePath=function(){this.commands.push({type:"Z"})},Fe.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof ne){let o=i;this.moveTo(o.x1,o.y1),this.lineTo(o.x2,o.y1),this.lineTo(o.x2,o.y2),this.lineTo(o.x1,o.y2),this.close();return}Array.prototype.push.apply(this.commands,i)},Fe.prototype.getBoundingBox=function(){let i=new ne,o=0,u=0,h=0,p=0;for(let g=0;g<this.commands.length;g++){let A=this.commands[g];switch(A.type){case"M":i.addPoint(A.x,A.y),o=h=A.x,u=p=A.y;break;case"L":i.addPoint(A.x,A.y),h=A.x,p=A.y;break;case"Q":i.addQuad(h,p,A.x1,A.y1,A.x,A.y),h=A.x,p=A.y;break;case"C":i.addBezier(h,p,A.x1,A.y1,A.x2,A.y2,A.x,A.y),h=A.x,p=A.y;break;case"Z":h=o,p=u;break;default:throw new Error("Unexpected path command "+A.type)}}return i.isEmpty()&&i.addPoint(0,0),i},Fe.prototype.draw=function(i){let o=this._layers;if(o&&o.length){for(let h=0;h<o.length;h++)this.draw.call(o[h],i);return}let u=this._image;if(u){i.drawImage(u.image,u.x,u.y,u.width,u.height);return}i.beginPath();for(let h=0;h<this.commands.length;h+=1){let p=this.commands[h];p.type==="M"?i.moveTo(p.x,p.y):p.type==="L"?i.lineTo(p.x,p.y):p.type==="C"?i.bezierCurveTo(p.x1,p.y1,p.x2,p.y2,p.x,p.y):p.type==="Q"?i.quadraticCurveTo(p.x1,p.y1,p.x,p.y):p.type==="Z"&&this.stroke&&this.strokeWidth&&i.closePath()}this.fill&&(i.fillStyle=this.fill,i.fill()),this.stroke&&(i.strokeStyle=this.stroke,i.lineWidth=this.strokeWidth,i.stroke())},Fe.prototype.toPathData=function(i){i=oe(i);function o(k){let E=Re(k,i.decimalPlaces);return Math.round(k)===E?""+E:E.toFixed(i.decimalPlaces)}function u(){let k="";for(let E=0;E<arguments.length;E+=1){let D=arguments[E];D>=0&&E>0&&(k+=" "),k+=o(D)}return k}let h=this.commands;i.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=Pe(h));let p=i.flipY,g=i.flipYBase;if(p===!0&&g===void 0){let k=new Fe;k.extend(h);let E=k.getBoundingBox();g=E.y1+E.y2}let A="";for(let k=0;k<h.length;k+=1){let E=h[k];E.type==="M"?A+="M"+u(E.x,p?g-E.y:E.y):E.type==="L"?A+="L"+u(E.x,p?g-E.y:E.y):E.type==="C"?A+="C"+u(E.x1,p?g-E.y1:E.y1,E.x2,p?g-E.y2:E.y2,E.x,p?g-E.y:E.y):E.type==="Q"?A+="Q"+u(E.x1,p?g-E.y1:E.y1,E.x,p?g-E.y:E.y):E.type==="Z"&&(A+="Z")}return A},Fe.prototype.toSVG=function(i,o){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),o||(o=this.toPathData(i));let u='<path d="';return u+=o,u+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u+=' fill="none"':u+=' fill="'+this.fill+'"'),this.stroke&&(u+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),u+="/>",u},Fe.prototype.toDOMElement=function(i,o){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),o||(o=this.toPathData(i));let u=document.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",o),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u.setAttribute("fill","none"):u.setAttribute("fill",this.fill)),this.stroke&&(u.setAttribute("stroke",this.stroke),u.setAttribute("stroke-width",this.strokeWidth)),u};var We=Fe;function rt(i){throw new Error(i)}function gt(i,o){i||rt(o)}var ue={fail:rt,argument:gt,assert:gt},Ye=32768,at=2147483648,Ne=-32768,Ge=32767+1/65536,Ce={},H={},ae={};function ye(i){return function(){return i}}H.BYTE=function(i){return ue.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},ae.BYTE=ye(1),H.CHAR=function(i){return[i.charCodeAt(0)]},ae.CHAR=ye(1),H.CHARARRAY=function(i){(i===null||typeof i>"u")&&(i="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let o=[];for(let u=0;u<i.length;u+=1)o[u]=i.charCodeAt(u);return o},ae.CHARARRAY=function(i){return typeof i>"u"?0:i.length},H.USHORT=function(i){return[i>>8&255,i&255]},ae.USHORT=ye(2),H.SHORT=function(i){return i>=Ye&&(i=-(2*Ye-i)),[i>>8&255,i&255]},ae.SHORT=ye(2),H.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},ae.UINT24=ye(3),H.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},ae.ULONG=ye(4),H.LONG=function(i){return i>=at&&(i=-(2*at-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},ae.LONG=ye(4),H.FLOAT=function(i){if(i>Ge||i<Ne)throw new Error(`Value ${i} is outside the range of representable values in 16.16 format`);let o=Math.round(i*65536)<<0;return H.ULONG(o)},ae.FLOAT=ae.ULONG,H.FIXED=H.ULONG,ae.FIXED=ae.ULONG,H.FWORD=H.SHORT,ae.FWORD=ae.SHORT,H.UFWORD=H.USHORT,ae.UFWORD=ae.USHORT,H.F2DOT14=function(i){return H.USHORT(i*16384)},ae.F2DOT14=ae.USHORT,H.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},ae.LONGDATETIME=ye(8),H.TAG=function(i){return ue.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},ae.TAG=ye(4),H.Card8=H.BYTE,ae.Card8=ae.BYTE,H.Card16=H.USHORT,ae.Card16=ae.USHORT,H.OffSize=H.BYTE,ae.OffSize=ae.BYTE,H.SID=H.USHORT,ae.SID=ae.USHORT,H.NUMBER=function(i){return i>=-107&&i<=107?[i+139]:i>=108&&i<=1131?(i=i-108,[(i>>8)+247,i&255]):i>=-1131&&i<=-108?(i=-i-108,[(i>>8)+251,i&255]):i>=-32768&&i<=32767?H.NUMBER16(i):H.NUMBER32(i)},ae.NUMBER=function(i){return H.NUMBER(i).length},H.NUMBER16=function(i){return[28,i>>8&255,i&255]},ae.NUMBER16=ye(3),H.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},ae.NUMBER32=ye(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 k=o[g];k==="e"?h+=o[++g]==="-"?"c":"b":k==="."?h+="a":k==="-"?h+="e":h+=k}h+=h.length&1?"f":"ff";let p=[30];for(let g=0,A=h.length;g<A;g+=2)p.push(parseInt(h.substr(g,2),16));return p},ae.REAL=function(i){return H.REAL(i).length},H.NAME=H.CHARARRAY,ae.NAME=ae.CHARARRAY,H.STRING=H.CHARARRAY,ae.STRING=ae.CHARARRAY,Ce.UTF8=function(i,o,u){let h=[],p=u;for(let g=0;g<p;g++,o+=1)h[g]=i.getUint8(o);return String.fromCharCode.apply(null,h)},Ce.UTF16=function(i,o,u){let h=[],p=u/2;for(let g=0;g<p;g++,o+=2)h[g]=i.getUint16(o);return String.fromCharCode.apply(null,h)},H.UTF16=function(i){let o=[];for(let u=0;u<i.length;u+=1){let h=i.charCodeAt(u);o[o.length]=h>>8&255,o[o.length]=h&255}return o},ae.UTF16=function(i){return i.length*2};var Ve={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Ce.MACSTRING=function(i,o,u,h){let p=Ve[h];if(p===void 0)return;let g="";for(let A=0;A<u;A++){let k=i.getUint8(o+A);k<=127?g+=String.fromCharCode(k):g+=p[k&127]}return g};var Je=typeof WeakMap=="function"&&new WeakMap,bt,Vt=function(i){if(!bt){bt={};for(let p in Ve)bt[p]=new String(p)}let o=bt[i];if(o===void 0)return;if(Je){let p=Je.get(o);if(p!==void 0)return p}let u=Ve[i];if(u===void 0)return;let h={};for(let p=0;p<u.length;p++)h[u.charCodeAt(p)]=p+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 p=0;p<i.length;p++){let g=i.charCodeAt(p);if(g>=128&&(g=u[g],g===void 0))return;h[p]=g}return h},ae.MACSTRING=function(i,o){let u=H.MACSTRING(i,o);return u!==void 0?u.length:0};function Pt(i){return i>=-128&&i<=127}function mt(i,o,u){let h=0,p=i.length;for(;o<p&&h<64&&i[o]===0;)++o,++h;return u.push(128|h-1),o}function Zt(i,o,u){let h=0,p=i.length,g=o;for(;g<p&&h<64;){let A=i[g];if(!Pt(A)||A===0&&g+1<p&&i[g+1]===0)break;++g,++h}u.push(h-1);for(let A=o;A<g;++A)u.push(i[A]+256&255);return g}function Ht(i,o,u){let h=0,p=i.length,g=o;for(;g<p&&h<64;){let A=i[g];if(A===0||Pt(A)&&g+1<p&&Pt(i[g+1]))break;++g,++h}u.push(64|h-1);for(let A=o;A<g;++A){let k=i[A];u.push(k+65536>>8&255,k+256&255)}return g}H.VARDELTAS=function(i){let o=0,u=[];for(;o<i.length;){let h=i[o];h===0?o=mt(i,o,u):h>=-128&&h<=127?o=Zt(i,o,u):o=Ht(i,o,u)}return u},H.INDEX=function(i){let o=1,u=[o],h=[];for(let k=0;k<i.length;k+=1){let E=H.OBJECT(i[k]);Array.prototype.push.apply(h,E),o+=E.length,u.push(o)}if(h.length===0)return[0,0];let p=[],g=1+Math.floor(Math.log(o)/Math.log(2))/8|0,A=[void 0,H.BYTE,H.USHORT,H.UINT24,H.ULONG][g];for(let k=0;k<u.length;k+=1){let E=A(u[k]);Array.prototype.push.apply(p,E)}return Array.prototype.concat(H.Card16(i.length),H.OffSize(g),p,h)},ae.INDEX=function(i){return H.INDEX(i).length},H.DICT=function(i){let o=[],u=Object.keys(i),h=u.length;for(let p=0;p<h;p+=1){let g=parseInt(u[p],0),A=i[g],k=H.OPERAND(A.value,A.type),E=H.OPERATOR(g);for(let D=0;D<k.length;D++)o.push(k[D]);for(let D=0;D<E.length;D++)o.push(E[D])}return o},ae.DICT=function(i){return H.DICT(i).length},H.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},H.OPERAND=function(i,o){let u=[];if(Array.isArray(o))for(let h=0;h<o.length;h+=1){ue.argument(i.length===o.length,"Not enough arguments given for type"+o);let p=H.OPERAND(i[h],o[h]);for(let g=0;g<p.length;g++)u.push(p[g])}else if(o==="SID"){let h=H.NUMBER(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="offset"){let h=H.NUMBER32(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="number"){let h=H.NUMBER(i);for(let p=0;p<h.length;p++)u.push(h[p])}else if(o==="real"){let h=H.REAL(i);for(let p=0;p<h.length;p++)u.push(h[p])}else throw new Error("Unknown operand type "+o);return u},H.OP=H.BYTE,ae.OP=ae.BYTE;var Kt=typeof WeakMap=="function"&&new WeakMap;H.CHARSTRING=function(i){if(Kt){let h=Kt.get(i);if(h!==void 0)return h}let o=[],u=i.length;for(let h=0;h<u;h+=1){let p=i[h],g=H[p.type](p.value);for(let A=0;A<g.length;A++)o.push(g[A])}return Kt&&Kt.set(i,o),o},ae.CHARSTRING=function(i){return H.CHARSTRING(i).length},H.OBJECT=function(i){let o=H[i.type];return ue.argument(o!==void 0,"No encoding function for type "+i.type),o(i.value)},ae.OBJECT=function(i){let o=ae[i.type];return ue.argument(o!==void 0,"No sizeOf function for type "+i.type),o(i.value)},H.TABLE=function(i){let o=[],u=(i.fields||[]).length,h=[],p=[];for(let g=0;g<u;g+=1){let A=i.fields[g],k=H[A.type];ue.argument(k!==void 0,"No encoding function for field type "+A.type+" ("+A.name+")");let E=i[A.name];E===void 0&&(E=A.value);let D=k(E);if(A.type==="TABLE")E.fields!==null&&(p.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=p[g],k=o.length;ue.argument(k<65536,"Table "+i.tableName+" too big."),o[A]=k>>8,o[A+1]=k&255;for(let E=0;E<h[g].length;E++)o.push(h[g][E])}return o},ae.TABLE=function(i){let o=0,u=(i.fields||[]).length;for(let h=0;h<u;h+=1){let p=i.fields[h],g=ae[p.type];ue.argument(g!==void 0,"No sizeOf function for field type "+p.type+" ("+p.name+")");let A=i[p.name];A===void 0&&(A=p.value),o+=g(A),p.type==="TABLE"&&(o+=2)}return o},H.RECORD=H.TABLE,ae.RECORD=ae.TABLE,H.LITERAL=function(i){return i},ae.LITERAL=function(i){return i.length};function Ot(i,o,u){if(o&&o.length)for(let h=0;h<o.length;h+=1){let p=o[h];this[p.name]=p.value}if(this.tableName=i,this.fields=o,u){let h=Object.keys(u);for(let p=0;p<h.length;p+=1){let g=h[p],A=u[g];this[g]!==void 0&&(this[g]=A)}}}Ot.prototype.encode=function(){return H.TABLE(this)},Ot.prototype.sizeOf=function(){return ae.TABLE(this)};function Nt(i,o,u){u===void 0&&(u=o.length);let h=new Array(o.length+1);h[0]={name:i+"Count",type:"USHORT",value:u};for(let p=0;p<o.length;p++)h[p+1]={name:i+p,type:"USHORT",value:o[p]};return h}function me(i,o,u){let h=o.length,p=new Array(h+1);p[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)p[g+1]={name:i+g,type:"TABLE",value:u(o[g],g)};return p}function Ze(i,o,u){let h=o.length,p=[];p[0]={name:i+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)p=p.concat(u(o[g],g));return p}function ct(i){i.format===1?Ot.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Nt("glyph",i.glyphs))):i.format===2?Ot.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Ze("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.")}ct.prototype=Object.create(Ot.prototype),ct.prototype.constructor=ct;function Tt(i){Ot.call(this,"scriptListTable",Ze("scriptRecord",i,function(o,u){let h=o.script,p=h.defaultLangSys;return ue.assert(!!p,"Unable to write GSUB: script "+o.tag+" has no default language system."),[{name:"scriptTag"+u,type:"TAG",value:o.tag},{name:"script"+u,type:"TABLE",value:new Ot("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Ot("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:p.reqFeatureIndex}].concat(Nt("featureIndex",p.featureIndexes)))}].concat(Ze("langSys",h.langSysRecords,function(g,A){let k=g.langSys;return[{name:"langSysTag"+A,type:"TAG",value:g.tag},{name:"langSys"+A,type:"TABLE",value:new Ot("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:k.reqFeatureIndex}].concat(Nt("featureIndex",k.featureIndexes)))}]})))}]}))}Tt.prototype=Object.create(Ot.prototype),Tt.prototype.constructor=Tt;function X(i){Ot.call(this,"featureListTable",Ze("featureRecord",i,function(o,u){let h=o.feature;return[{name:"featureTag"+u,type:"TAG",value:o.tag},{name:"feature"+u,type:"TABLE",value:new Ot("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Nt("lookupListIndex",h.lookupListIndexes)))}]}))}X.prototype=Object.create(Ot.prototype),X.prototype.constructor=X;function yt(i,o){Ot.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 Ot("lookupTable",[{name:"lookupType",type:"USHORT",value:u.lookupType},{name:"lookupFlag",type:"USHORT",value:u.lookupFlag}].concat(me("subtable",u.subtables,h)))}))}yt.prototype=Object.create(Ot.prototype),yt.prototype.constructor=yt;function nt(i){i.format===1?Ot.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:i.startGlyph}].concat(Nt("glyph",i.classes))):i.format===2?Ot.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Ze("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.")}nt.prototype=Object.create(Ot.prototype),nt.prototype.constructor=nt;var _e={Table:Ot,Record:Ot,Coverage:ct,ClassDef:nt,ScriptList:Tt,FeatureList:X,LookupList:yt,ushortList:Nt,tableList:me,recordList:Ze};function tr(i,o){return i.getUint8(o)}function Ke(i,o){return i.getUint16(o,!1)}function kt(i,o){return i.getInt16(o,!1)}function Ut(i,o){return(i.getUint16(o)<<8)+i.getUint8(o+2)}function vt(i,o){return i.getUint32(o,!1)}function wt(i,o){return i.getInt32(o,!1)}function Mt(i,o){let u=i.getInt16(o,!1),h=i.getUint16(o+2,!1);return u+h/65535}function _t(i,o){let u="";for(let h=o;h<o+4;h+=1)u+=String.fromCharCode(i.getInt8(h));return u}function fr(i,o,u){let h=0;for(let p=0;p<u;p+=1)h<<=8,h+=i.getUint8(o+p);return h}function qt(i,o,u){let h=[];for(let p=o;p<u;p+=1)h.push(i.getUint8(p));return h}function Sr(i){let o="";for(let u=0;u<i.length;u+=1)o+=String.fromCharCode(i[u]);return o}var pn={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},dr={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function 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=Ut(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,i},ge.prototype.parseULong=function(){let i=vt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},ge.prototype.parseLong=function(){let i=wt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},ge.prototype.parseOffset32=ge.prototype.parseULong,ge.prototype.parseFixed=function(){let i=Mt(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 p=0;p<i;p++)h+=String.fromCharCode(o.getUint8(u+p));return h},ge.prototype.parseTag=function(){return this.parseString(4)},ge.prototype.parseLongDateTime=function(){let i=vt(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},ge.prototype.parseVersion=function(i){let o=Ke(this.data,this.offset+this.relativeOffset),u=Ke(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),o+u/i/10},ge.prototype.skip=function(i,o){o===void 0&&(o=1),this.relativeOffset+=pn[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 p=0;p<i;p++)o[p]=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 p=0;p<i;p++)o[p]=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 p=0;p<i;p++)o[p]=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 p=0;p<i;p++)o[p]=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 p=0;p<i;p++){let g={};for(let A=0;A<h.length;A++){let k=h[A],E=o[k];g[k]=E.call(this)}u[p]=g}return u},ge.prototype.parseRecordList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i),h=Object.keys(o);for(let p=0;p<i;p++){let g={};for(let A=0;A<h.length;A++){let k=h[A],E=o[k];g[k]=E.call(this)}u[p]=g}return u},ge.prototype.parseTupleRecords=function(i,o){let u=[];for(let h=0;h<i;h++){let p=[];for(let g=0;g<o;g++)p.push(this.parseF2Dot14());u.push(p)}return u},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 p=o[h],g=i[p];u[p]=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,p=new Array(u);for(let g=0;g<u;g++){let A=o[g];if(A===0){p[g]=void 0;continue}if(this.relativeOffset=A,i){let k=this.parseOffset16List(),E=new Array(k.length);for(let D=0;D<k.length;D++)this.relativeOffset=A+k[D],E[D]=i.call(this);p[g]=E}else p[g]=this.parseUShortList()}return this.relativeOffset=h,p},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 p=0;p<u;p++)h[p]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+i.toString(16)+": Coverage format must be 1 or 2.")},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 Gr={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(Gr),langSysRecords:ge.recordList({tag:ge.tag,langSys:ge.pointer(Gr)})})}))||[]},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(),p=this.parseULongList(h);this.relativeOffset=i+u,o.variationRegions=this.parseVariationRegionList();for(let g=0;g<h;g++){let A=p[g];this.relativeOffset=i+A,o.itemVariationSubtables.push(this.parseItemVariationSubtable())}return o},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 p=(o&dr.INNER_INDEX_BIT_COUNT_MASK)+1,g=((o&dr.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let A=0;A<h;A++){let k;if(g===1)k=this.parseByte();else if(g===2)k=this.parseUShort();else if(g===3)k=this.parseUInt24();else if(g===4)k=this.parseULong();else throw new Error(`Invalid entry size of ${g}`);let E=k>>p,D=k&(1<<p)-1;u.push({outerIndex:E,innerIndex:D})}return{format:i,entryFormat:o,map:u}},ge.prototype.parseDeltaSets=function(i,o,u){let h=Array.from({length:i},()=>[]),p=o&dr.LONG_WORDS,g=o&dr.WORD_DELTA_COUNT_MASK;if(g>u)throw Error("wordCount must be less than or equal to regionIndexCount");let A=(p?this.parseLong:this.parseShort).bind(this),k=(p?this.parseShort:this.parseChar).bind(this);for(let E=0;E<i;E++)for(let D=0;D<u;D++)D<g?h[E].push(A()):h[E].push(k());return h},ge.prototype.parseTupleVariationStoreList=function(i,o,u){let h=this.parseUShort(),p=this.parseUShort()&1,g=this.parseOffset32(),A=(p?this.parseULong:this.parseUShort).bind(this),k={},E=A();p||(E*=2);let D;for(let M=0;M<h;M++){D=A(),p||(D*=2);let te=D-E;k[M]=te?this.parseTupleVariationStore(g+E,i,o,u,M):void 0,E=D}return k},ge.prototype.parseTupleVariationStore=function(i,o,u,h,p){let g=this.relativeOffset;this.relativeOffset=i,u==="cvar"&&(this.relativeOffset+=4);let A=this.parseUShort(),k=!!(A&dr.SHARED_POINT_NUMBERS),E=A&dr.COUNT_MASK,D=this.parseOffset16(),M=[],te=[];for(let he=0;he<E;he++){let Me=this.parseTupleVariationHeader(o,u);M.push(Me)}this.relativeOffset!==i+D&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${i+D}, actually ${this.relativeOffset}`),this.relativeOffset=i+D),k&&(te=this.parsePackedPointNumbers());let J=this.relativeOffset;for(let he=0;he<E;he++){let Me=M[he];Me.privatePoints=[],this.relativeOffset=J,u==="cvar"&&!Me.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),Me.flags.privatePointNumbers&&(Me.privatePoints=this.parsePackedPointNumbers()),delete Me.flags;let ut=this.offset,mr=this.relativeOffset,lr=Rr=>{let sn,On,Yn=()=>{let Zn=0;if(u==="gvar"){if(Zn=Me.privatePoints.length||te.length,!Zn){let Ps=h.get(p);Ps.path,Zn=Ps.points.length,Zn+=4}}else u==="cvar"&&(Zn=h.length);this.offset=ut,this.relativeOffset=mr,sn=this.parsePackedDeltas(Zn),u==="gvar"&&(On=this.parsePackedDeltas(Zn))};return{configurable:!0,get:function(){return sn===void 0&&Yn(),Rr==="deltasY"?On:sn},set:function(Zn){sn===void 0&&Yn(),Rr==="deltasY"?On=Zn:sn=Zn}}};Object.defineProperty(Me,"deltas",lr.call(this,"deltas")),u==="gvar"&&Object.defineProperty(Me,"deltasY",lr.call(this,"deltasY")),J+=Me.variationDataSize,delete Me.variationDataSize}this.relativeOffset=g;let Te={headers:M};return Te.sharedPoints=te,Te},ge.prototype.parseTupleVariationHeader=function(i,o){let u=this.parseUShort(),h=this.parseUShort(),p=!!(h&dr.EMBEDDED_PEAK_TUPLE),g=!!(h&dr.INTERMEDIATE_REGION),A=!!(h&dr.PRIVATE_POINT_NUMBERS),k=p?void 0:h&dr.TUPLE_INDEX_MASK,E=p?this.parseTupleRecords(1,i)[0]:void 0,D=g?this.parseTupleRecords(1,i)[0]:void 0,M=g?this.parseTupleRecords(1,i)[0]:void 0,te={variationDataSize:u,peakTuple:E,intermediateStartTuple:D,intermediateEndTuple:M,flags:{embeddedPeakTuple:p,intermediateRegion:g,privatePointNumbers:A}};return o==="gvar"&&(te.sharedTupleRecordsIndex=k),te},ge.prototype.parsePackedPointNumbers=function(){let i=this.parseByte(),o=[],u=i;if(i>=128){let p=this.parseByte();u=(i&dr.POINT_RUN_COUNT_MASK)<<8|p}let h=0;for(;o.length<u;){let p=this.parseByte(),g=!!(p&dr.POINTS_ARE_WORDS),A=(p&dr.POINT_RUN_COUNT_MASK)+1;for(let k=0;k<A&&o.length<u;k++){let E;g?E=this.parseUShort():E=this.parseByte(),h=h+E,o.push(h)}}return o},ge.prototype.parsePackedDeltas=function(i){let o=[];for(;o.length<i;){let u=this.parseByte(),h=!!(u&dr.DELTAS_ARE_ZERO),p=!!(u&dr.DELTAS_ARE_WORDS),g=(u&dr.DELTA_RUN_COUNT_MASK)+1;for(let A=0;A<g&&o.length<i;A++)h?o.push(0):p?o.push(this.parseShort()):o.push(this.parseChar())}return o};var ot={getByte:tr,getCard8:tr,getUShort:Ke,getCard16:Ke,getShort:kt,getUInt24:Ut,getULong:vt,getFixed:Mt,getTag:_t,getOffset:fr,getBytes:qt,bytesToString:Sr,Parser:ge},ft=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],ir={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Mn={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Xr={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function De(i,o,u){switch(i){case 0:if(o===65535)return"und";if(u)return u[o];break;case 1:return ir[o];case 3:return Xr[o]}}var st="utf-16",xt={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Br={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Vr(i,o,u){switch(i){case 0:return st;case 1:return Br[u]||xt[o];case 3:if(o===1||o===10)return st;break}}var Cr={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function qr(i){return Cr[i]}function mn(i,o,u){let h={},p=new ot.Parser(i,o),g=p.parseUShort(),A=p.parseUShort(),k=p.offset+p.parseUShort();for(let E=0;E<A;E++){let D=p.parseUShort(),M=p.parseUShort(),te=p.parseUShort(),J=p.parseUShort(),Te=ft[J]||J,he=p.parseUShort(),Me=p.parseUShort(),ut=De(D,te,u),mr=Vr(D,M,te),lr=qr(D);if(mr!==void 0&&ut!==void 0&&lr!==void 0){let Rr;if(mr===st?Rr=Ce.UTF16(i,k+Me,he):Rr=Ce.MACSTRING(i,k+Me,he,mr),Rr){let sn=h[lr];sn===void 0&&(sn=h[lr]={});let On=sn[Te];On===void 0&&(On=sn[Te]={}),On[ut]=Rr}}}return g===1&&p.parseUShort(),h}function on(i){let o={};for(let u in i)o[i[u]]=parseInt(u);return o}function zr(i,o,u,h,p,g){return new _e.Record("NameRecord",[{name:"platformID",type:"USHORT",value:i},{name:"encodingID",type:"USHORT",value:o},{name:"languageID",type:"USHORT",value:u},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:p},{name:"offset",type:"USHORT",value:g}])}function un(i,o){let u=i.length,h=o.length-u+1;e:for(let p=0;p<h;p++)for(;p<h;p++){for(let g=0;g<u;g++)if(o[p+g]!==i[g])continue e;return p}return-1}function Er(i,o){let u=un(i,o);if(u<0){u=o.length;let h=0,p=i.length;for(;h<p;++h)o.push(i[h])}return u}function re(i,o){let u=on(Cr),h=on(ir),p=on(Xr),g=[],A=[];for(let E in i){let D,M=[],te={},J=on(ft),Te=u[E];for(let he in i[E]){let Me=J[he];if(Me===void 0&&(Me=he),D=parseInt(Me),isNaN(D))throw new Error('Name table entry "'+he+'" does not exist, see nameTableNames for complete list.');te[D]=i[E][he],M.push(D)}for(let he=0;he<M.length;he++){D=M[he];let Me=te[D];for(let ut in Me){let mr=Me[ut];if(Te===1||Te===0){let lr=h[ut],Rr=Mn[lr],sn=Vr(Te,Rr,lr),On=H.MACSTRING(mr,sn);if(Te===0&&(lr=o.indexOf(ut),lr<0&&(lr=o.length,o.push(ut)),Rr=4,On=H.UTF16(mr)),On!==void 0){let Yn=Er(On,A);g.push(zr(Te,Rr,lr,D,On.length,Yn))}}if(Te===3){let lr=p[ut];if(lr!==void 0){let Rr=H.UTF16(mr),sn=Er(Rr,A);g.push(zr(3,1,lr,D,Rr.length,sn))}}}}}g.sort(function(E,D){return E.platformID-D.platformID||E.encodingID-D.encodingID||E.languageID-D.languageID||E.nameID-D.nameID});let k=new _e.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:g.length},{name:"stringOffset",type:"USHORT",value:6+g.length*12}]);for(let E=0;E<g.length;E++)k.fields.push({name:"record_"+E,type:"RECORD",value:g[E]});return k.fields.push({name:"strings",type:"LITERAL",value:A}),k}function pt(i,o,u=[]){if(o<256&&o in ft){if(u.length&&!u.includes(parseInt(o)))return;o=ft[o]}for(let h in i)for(let p in i[h])if(p===o||parseInt(p)===o)return i[h][p]}var jt={parse:mn,make:re,getNameByID:pt};function nr(i,o,u,h){i.length=o.parseUShort(),i.language=o.parseUShort()-1;let p=o.parseByteList(i.length),g=Object.assign({},p),A=Vr(u,h,i.language),k=Ve[A];for(let E=0;E<k.length;E++)g[k.charCodeAt(E)]=p[128+E];i.glyphIndexMap=g}function Ar(i,o,u){o.parseUShort(),i.length=o.parseULong(),i.language=o.parseULong();let h;i.groupCount=h=o.parseULong(),i.glyphIndexMap={};for(let p=0;p<h;p+=1){let g=o.parseULong(),A=o.parseULong(),k=o.parseULong();for(let E=g;E<=A;E+=1)i.glyphIndexMap[E]=k,u===12&&k++}}function Fr(i,o,u,h,p){i.length=o.parseUShort(),i.language=o.parseUShort();let g;i.segCount=g=o.parseUShort()>>1,o.skip("uShort",3),i.glyphIndexMap={};let A=new ot.Parser(u,h+p+14),k=new ot.Parser(u,h+p+16+g*2),E=new ot.Parser(u,h+p+16+g*4),D=new ot.Parser(u,h+p+16+g*6),M=h+p+16+g*8;for(let te=0;te<g-1;te+=1){let J,Te=A.parseUShort(),he=k.parseUShort(),Me=E.parseShort(),ut=D.parseUShort();for(let mr=he;mr<=Te;mr+=1)ut!==0?(M=D.offset+D.relativeOffset-2,M+=ut,M+=(mr-he)*2,J=ot.getUShort(u,M),J!==0&&(J=J+Me&65535)):J=mr+Me&65535,i.glyphIndexMap[mr]=J}}function Xt(i,o){let u={};o.skip("uLong");let h=o.parseULong();for(let p=0;p<h;p+=1){let g=o.parseUInt24(),A={varSelector:g},k=o.parseOffset32(),E=o.parseOffset32(),D=o.relativeOffset;k&&(o.relativeOffset=k,A.defaultUVS=o.parseStruct({ranges:function(){return o.parseRecordList32({startUnicodeValue:o.parseUInt24,additionalCount:o.parseByte})}})),E&&(o.relativeOffset=E,A.nonDefaultUVS=o.parseStruct({uvsMappings:function(){let M={},te=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let J=0;J<te.length;J+=1)M[te[J].unicodeValue]=te[J];return M}})),u[g]=A,o.relativeOffset=D}i.varSelectorList=u}function Zr(i,o){let u={};u.version=ot.getUShort(i,o),ue.argument(u.version===0,"cmap table version should be 0."),u.numTables=ot.getUShort(i,o+2);let h=null,p=-1,g=-1,A=null,k=null,E=[0,1,2,3,4,6],D=[0,1,10];for(let te=u.numTables-1;te>=0;te-=1)if(A=ot.getUShort(i,o+4+te*8),k=ot.getUShort(i,o+4+te*8+2),A===3&&D.includes(k)||A===0&&E.includes(k)||A===1&&k===0){if(g>0)continue;if(g=ot.getULong(i,o+4+te*8+4),h)break}else if(A===0&&k===5){if(p=ot.getULong(i,o+4+te*8+4),h=new ot.Parser(i,o+p),h.parseUShort()!==14)p=-1,h=null;else if(g>0)break}if(g===-1)throw new Error("No valid cmap sub-tables found.");let M=new ot.Parser(i,o+g);if(u.format=M.parseUShort(),u.format===0)nr(u,M,A,k);else if(u.format===12||u.format===13)Ar(u,M,u.format);else if(u.format===4)Fr(u,M,i,o,g);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+u.format+", platformId "+A+", encodingId "+k+").");return h&&Xt(u,h),u}function Jt(i,o,u){i.segments.push({end:o,start:o,delta:-(o-u),offset:0,glyphIndex:u})}function Pr(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function Hr(i){if(i.length===0)return i;let o=[i[0]];for(let u=1;u<i.length;u++){let h=o[o.length-1],p=i[u];h.end+1===p.start&&h.delta===p.delta&&p.end!==65535?h.end=p.end:o.push(p)}return o}function ps(i){let o=!0,u;for(u=i.length-1;u>0;u-=1)if(i.get(u).unicode>65535){o=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:o?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:o?12:20}];o||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let p=new _e.Table("cmap",h);for(p.segments=[],u=0;u<i.length;u+=1){let Te=i.get(u);for(let he=0;he<Te.unicodes.length;he+=1)Jt(p,Te.unicodes[he],u)}p.segments.sort(function(Te,he){return Te.start-he.start}),p.segments=Hr(p.segments),Pr(p);let g=p.segments.length,A=0,k=[],E=[],D=[],M=[],te=[],J=[];for(u=0;u<g;u+=1){let Te=p.segments[u];Te.end<=65535&&Te.start<=65535?(k.push({name:"end_"+u,type:"USHORT",value:Te.end}),E.push({name:"start_"+u,type:"USHORT",value:Te.start}),D.push({name:"idDelta_"+u,type:"SHORT",value:Te.delta}),M.push({name:"idRangeOffset_"+u,type:"USHORT",value:Te.offset}),Te.glyphId!==void 0&&te.push({name:"glyph_"+u,type:"USHORT",value:Te.glyphId})):A+=1,!o&&Te.glyphIndex!==void 0&&(J.push({name:"cmap12Start_"+u,type:"ULONG",value:Te.start}),J.push({name:"cmap12End_"+u,type:"ULONG",value:Te.end}),J.push({name:"cmap12Glyph_"+u,type:"ULONG",value:Te.glyphIndex}))}p.segCountX2=(g-A)*2,p.searchRange=Math.pow(2,Math.floor(Math.log(g-A)/Math.log(2)))*2,p.entrySelector=Math.log(p.searchRange/2)/Math.log(2),p.rangeShift=p.segCountX2-p.searchRange;for(let Te=0;Te<k.length;Te++)p.fields.push(k[Te]);p.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let Te=0;Te<E.length;Te++)p.fields.push(E[Te]);for(let Te=0;Te<D.length;Te++)p.fields.push(D[Te]);for(let Te=0;Te<M.length;Te++)p.fields.push(M[Te]);for(let Te=0;Te<te.length;Te++)p.fields.push(te[Te]);if(p.cmap4Length=14+k.length*2+2+E.length*2+D.length*2+M.length*2+te.length*2,!o){let Te=16+J.length*4;p.cmap12Offset=20+p.cmap4Length,p.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:Te},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:J.length/3});for(let he=0;he<J.length;he++)p.fields.push(J[he])}return p}var Mr={parse:Zr,make:ps},jn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Tr=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Jr=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],ln=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],Qr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],ks=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Dr=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function en(i){this.font=i}en.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.font.glyphs;if(u)for(let h=0;h<u.length;h+=1){let p=u.get(h);for(let g=0;g<p.unicodes.length;g+=1)if(p.unicodes[g]===o)return h}return null};function xn(i){this.cmap=i}xn.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function 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 ze(i){switch(i.version){case 1:this.names=Dr.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)i.glyphNameIndex[o]<Dr.length?this.names[o]=Dr[i.glyphNameIndex[o]]:this.names[o]=i.names[i.glyphNameIndex[o]-Dr.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)this.names[o]=Dr[o+i.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}ze.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},ze.prototype.glyphIndexToName=function(i){return this.names[i]};function Rt(i){let o,u=i.tables.cmap.glyphIndexMap,h=Object.keys(u);for(let p=0;p<h.length;p+=1){let g=h[p],A=u[g];o=i.glyphs.get(A),o.addUnicode(parseInt(g))}for(let p=0;p<i.glyphs.length;p+=1)o=i.glyphs.get(p),i.cffEncoding?o.name=i.cffEncoding.charset[p]:i.glyphNames.names&&(o.name=i.glyphNames.glyphIndexToName(p))}function Et(i){i._IndexToUnicodeMap={};let o=i.tables.cmap.glyphIndexMap,u=Object.keys(o);for(let h=0;h<u.length;h+=1){let p=u[h],g=o[p];i._IndexToUnicodeMap[g]===void 0?i._IndexToUnicodeMap[g]={unicodes:[parseInt(p)]}:i._IndexToUnicodeMap[g].unicodes.push(parseInt(p))}}function rr(i,o){o.lowMemory?Et(i):Rt(i)}function jr(i,o,u,h,p){i.beginPath(),i.moveTo(o,u),i.lineTo(h,p),i.stroke()}var cr={line:jr};function Cn(i,o){let u=new ge(i,o),h=u.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let p=u.parseShort(),g=u.parseShort(),A=u.parseShort(),k=u.parseOffset32(),E=u.parseUShortList(g);u.relativeOffset=k;let D=u.parseULongList(A);return u.relativeOffset=k,{version:h,numPaletteEntries:p,colorRecords:D,colorRecordIndices:E}}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 _e.Table("CPAL",[{name:"version",type:"USHORT",value:i},{name:"numPaletteEntries",type:"USHORT",value:o||u.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:u.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((p,g)=>({name:"colorRecordIndices_"+g,type:"USHORT",value:p})),...u.map((p,g)=>({name:"colorRecords_"+g,type:"ULONG",value:p}))])}function Xn(i){var o=(i&4278190080)>>24,u=(i&16711680)>>16,h=(i&65280)>>8,p=i&255;return o=o+256&255,u=u+256&255,h=h+256&255,p=(p+256&255)/255,{b:o,g:u,r:h,a:p}}function cn(i,o,u=0,h="hexa"){if(o==65535)return"currentColor";let p=i&&i.tables&&i.tables.cpal;if(!p)return"currentColor";if(u>p.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${p.colorRecordIndices.length}, index: ${o})`);if(o>p.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${p.numPaletteEntries}, index: ${o})`);let g=p.colorRecordIndices[u]+o;if(g>p.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${p.colorRecords.length}, lookupIndex: ${g})`);let A=Xn(p.colorRecords[g]);return h==="bgra"?A:gn(A,h)}function dn(i){return("0"+parseInt(i).toString(16)).slice(-2)}function _r(i){let o=i.r/255,u=i.g/255,h=i.b/255,p=Math.max(o,u,h),g=Math.min(o,u,h),A,k,E=(p+g)/2;if(p===g)A=k=0;else{let D=p-g;switch(k=E>.5?D/(2-p-g):D/(p+g),p){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:k*100,l:E*100}}function Or(i){let{h:o,s:u,l:h,a:p}=i;o=o%360,u/=100,h/=100;let g=(1-Math.abs(2*h-1))*u,A=g*(1-Math.abs(o/60%2-1)),k=h-g/2,E=0,D=0,M=0;return 0<=o&&o<60?(E=g,D=A,M=0):60<=o&&o<120?(E=A,D=g,M=0):120<=o&&o<180?(E=0,D=g,M=A):180<=o&&o<240?(E=0,D=A,M=g):240<=o&&o<300?(E=A,D=0,M=g):300<=o&&o<=360&&(E=g,D=0,M=A),{r:Math.round((E+k)*255),g:Math.round((D+k)*255),b:Math.round((M+k)*255),a:p}}function Gn(i){return parseInt(`0x${dn(i.b)}${dn(i.g)}${dn(i.r)}${dn(i.a*255)}`,16)}function Vn(i,o="hexa"){let u=o=="raw"||o=="cpal",h=Number.isInteger(i),p=!0;if(h&&u||i==="currentColor")return i;if(typeof i=="object"){if(o=="bgra")return i;if(u)return Gn(i)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(i.trim())){switch(i=i.trim().substring(1),i.length){case 3:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:1};break;case 4:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:parseInt(i[3].repeat(2),16)/255};break;case 6:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:1};break;case 8:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:parseInt(i[6]+i[7],16)/255};break}if(o=="bgra")return i}else if(typeof document<"u"&&/^[a-z]+$/i.test(i)){let g=document.createElement("canvas").getContext("2d");g.fillStyle=i;let A=gn(g.fillStyle,"hexa");A==="#000000ff"&&i.toLowerCase()!=="black"?p=!1:i=A}else{i=i.trim();let g=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(g.test(i)){let A=i.match(g).filter(k=>typeof k<"u");i={r:Math.round(parseFloat(A[1])/(A[2]?.39215686274509803:1)),g:Math.round(parseFloat(A[3])/(A[4]?.39215686274509803:1)),b:Math.round(parseFloat(A[5])/(A[6]?.39215686274509803:1)),a:A[7]?parseFloat(A[7])/(A[8]?100:1):1}}else{let A=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(A.test(i)){let k=i.match(A).filter(E=>typeof E<"u");i=Or({h:parseFloat(k[1])*(k[2]==="turn"?360:1),s:parseFloat(k[3]),l:parseFloat(k[4]),a:k[5]?parseFloat(k[5])/(k[6]?100:1):1})}else p=!1}}if(!p)throw new Error(`Invalid color format: ${i}`);return gn(i,o)}function gn(i,o="hexa"){if(i==="currentColor")return i;if(Number.isInteger(i)){if(o=="raw"||o=="cpal")return i;i=Xn(i)}else typeof i!="object"&&(i=Vn(i,"bgra"));let u=["hsl","hsla"].includes(o)?_r(i):null;switch(o){case"rgba":return`rgba(${i.r}, ${i.g}, ${i.b}, ${parseFloat(i.a.toFixed(3))})`;case"rgb":return`rgb(${i.r}, ${i.g}, ${i.b})`;case"hex":case"hex6":case"hex-6":return`#${dn(i.r)}${dn(i.g)}${dn(i.b)}`;case"hexa":case"hex8":case"hex-8":return`#${dn(i.r)}${dn(i.g)}${dn(i.b)}${dn(i.a*255)}`;case"hsl":return`hsl(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%)`;case"hsla":return`hsla(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%, ${parseFloat(i.a.toFixed(3))})`;case"bgra":return i;case"raw":case"cpal":return Gn(i);default:throw new Error("Unknown color format: "+o)}}var Jn={parse:Cn,make:Ls,getPaletteColor:cn,parseColor:Vn,formatColor:gn};function kr(i,o){let u=o||new We;return{configurable:!0,get:function(){return typeof u=="function"&&(u=u()),u},set:function(h){u=h}}}function Lr(i){this.bindConstructorValues(i)}Lr.prototype.bindConstructorValues=function(i){if(this.index=i.index||0,i.name===".notdef"?i.unicode=void 0:i.name===".null"&&(i.unicode=0),i.unicode===0&&i.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=i.name||null,this.unicode=i.unicode,this.unicodes=i.unicodes||(i.unicode!==void 0?[i.unicode]:[]),"xMin"in i&&(this.xMin=i.xMin),"yMin"in i&&(this.yMin=i.yMin),"xMax"in i&&(this.xMax=i.xMax),"yMax"in i&&(this.yMax=i.yMax),"advanceWidth"in i&&(this.advanceWidth=i.advanceWidth),"leftSideBearing"in i&&(this.leftSideBearing=i.leftSideBearing),"points"in i&&(this.points=i.points),Object.defineProperty(this,"path",kr(this,i.path))},Lr.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},Lr.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Lr.prototype.getPath=function(i,o,u,h,p){i=i!==void 0?i:0,o=o!==void 0?o:0,u=u!==void 0?u:72,h=Object.assign({},p&&p.defaultRenderOptions,h);let g,A,k=h.xScale,E=h.yScale,D=1/(this.path.unitsPerEm||1e3)*u,M=this;p&&p.variation&&(M=p.variation.getTransform(this,h.variation),g=M.path.commands),h.hinting&&p&&p.hinting&&(A=M.path&&p.hinting.exec(M,u,h)),A?(g=p.hinting.getCommands(A),i=Math.round(i),o=Math.round(o),k=E=1):(g=M.path.commands,k===void 0&&(k=D),E===void 0&&(E=D));let te=new We;if(h.drawSVG){let J=this.getSvgImage(p);if(J){let Te=new We;return Te._image={image:J.image,x:i+J.leftSideBearing*D,y:o-J.baseline*D,width:J.image.width*D,height:J.image.height*D},te._layers=[Te],te}}if(h.drawLayers){let J=this.getLayers(p);if(J&&J.length){te._layers=[];for(let Te=0;Te<J.length;Te+=1){let he=J[Te],Me=cn(p,he.paletteIndex,h.usePalette);Me==="currentColor"?Me=h.fill||"black":Me=gn(Me,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:Me}),te._layers.push(this.getPath.call(he.glyph,i,o,u,h,p))}return te}}te.fill=h.fill||this.path.fill,te.stroke=this.path.stroke,te.strokeWidth=this.path.strokeWidth*D;for(let J=0;J<g.length;J+=1){let Te=g[J];Te.type==="M"?te.moveTo(i+Te.x*k,o+-Te.y*E):Te.type==="L"?te.lineTo(i+Te.x*k,o+-Te.y*E):Te.type==="Q"?te.quadraticCurveTo(i+Te.x1*k,o+-Te.y1*E,i+Te.x*k,o+-Te.y*E):Te.type==="C"?te.curveTo(i+Te.x1*k,o+-Te.y1*E,i+Te.x2*k,o+-Te.y2*E,i+Te.x*k,o+-Te.y*E):Te.type==="Z"&&te.stroke&&te.strokeWidth&&te.closePath()}return te},Lr.prototype.getLayers=function(i){if(!i)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return i.layers.get(this.index)},Lr.prototype.getSvgImage=function(i){if(!i)throw new Error("The font object is required to read the svg table in order to get the image.");return i.svgImages.get(this.index)},Lr.prototype.getContours=function(i=null){if(this.points===void 0&&!i)return[];let o=[],u=[],h=i||this.points;for(let p=0;p<h.length;p+=1){let g=h[p];u.push(g),g.lastPointOfContour&&(o.push(u),u=[])}return ue.argument(u.length===0,"There are still points left in the current contour."),o},Lr.prototype.getMetrics=function(){let i=this.path.commands,o=[],u=[];for(let p=0;p<i.length;p+=1){let g=i[p];g.type!=="Z"&&(o.push(g.x),u.push(g.y)),(g.type==="Q"||g.type==="C")&&(o.push(g.x1),u.push(g.y1)),g.type==="C"&&(o.push(g.x2),u.push(g.y2))}let h={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,o),yMax:Math.max.apply(null,u),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},Lr.prototype.draw=function(i,o,u,h,p,g){p=Object.assign({},g&&g.defaultRenderOptions,p),this.getPath(o,u,h,p,g).draw(i)},Lr.prototype.drawPoints=function(i,o,u,h,p,g){if(p=Object.assign({},g&&g.defaultRenderOptions,p),p.drawLayers){let te=this.getLayers(g);if(te&&te.length){for(let J=0;J<te.length;J+=1)te[J].glyph.index!==this.index&&this.drawPoints.call(te[J].glyph,i,o,u,h);return}}function A(te,J,Te,he){i.beginPath();for(let Me=0;Me<te.length;Me+=1)i.moveTo(J+te[Me].x*he,Te+te[Me].y*he),i.arc(J+te[Me].x*he,Te+te[Me].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 k=1/this.path.unitsPerEm*h,E=[],D=[],M=this.path.commands;g&&g.variation&&(M=g.variation.getTransform(this,p.variation).path.commands);for(let te=0;te<M.length;te+=1){let J=M[te];J.x!==void 0&&E.push({x:J.x,y:-J.y}),J.x1!==void 0&&D.push({x:J.x1,y:-J.y1}),J.x2!==void 0&&D.push({x:J.x2,y:-J.y2})}i.fillStyle="blue",A(E,o,u,k),i.fillStyle="red",A(D,o,u,k)},Lr.prototype.drawMetrics=function(i,o,u,h){let p;o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:24,p=1/this.path.unitsPerEm*h,i.lineWidth=1,i.strokeStyle="black",cr.line(i,o,-1e4,o,1e4),cr.line(i,-1e4,u,1e4,u);let g=this.xMin||0,A=this.yMin||0,k=this.xMax||0,E=this.yMax||0,D=this.advanceWidth||0;i.strokeStyle="blue",cr.line(i,o+g*p,-1e4,o+g*p,1e4),cr.line(i,o+k*p,-1e4,o+k*p,1e4),cr.line(i,-1e4,u+-A*p,1e4,u+-A*p),cr.line(i,-1e4,u+-E*p,1e4,u+-E*p),i.strokeStyle="green",cr.line(i,o+D*p,-1e4,o+D*p,1e4)},Lr.prototype.toPathData=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this;o&&o.variation&&(u=o.variation.getTransform(this,i.variation));let h=u.points&&i.pointsTransform?i.pointsTransform(u.points):u.path;return i.pathTransform&&(h=i.pathTransform(h)),h.toPathData(i)},Lr.prototype.fromSVG=function(i,o={}){return this.path.fromSVG(i,o)},Lr.prototype.toSVG=function(i,o){let u=this.toPathData.apply(this,[i,o]);return this.path.toSVG(i,u)},Lr.prototype.toDOMElement=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this.path;return o&&o.variation&&(u=o.variation.getTransform(this,i.variation).path),u.toDOMElement(i)};var pr=Lr;function ns(i,o,u){Object.defineProperty(i,o,{get:function(){return typeof i[u]>"u"&&i.path,i[u]},set:function(h){i[u]=h},enumerable:!0,configurable:!0})}function Un(i,o){if(this.font=i,this.glyphs={},Array.isArray(o))for(let u=0;u<o.length;u++){let h=o[u];h.path.unitsPerEm=i.unitsPerEm,this.glyphs[u]=h}this.length=o&&o.length||0}typeof Symbol<"u"&&Symbol.iterator&&(Un.prototype[Symbol.iterator]=function(){let i=-1;return{next:(function(){i++;let o=i>=this.length-1;return{value:this.get(i),done:o}}).bind(this)}}),Un.prototype.get=function(i){if(this.font._push&&this.glyphs[i]===void 0){this.font._push(i),typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());let o=this.glyphs[i],u=this.font._IndexToUnicodeMap[i];if(u)for(let h=0;h<u.unicodes.length;h++)o.addUnicode(u.unicodes[h]);this.font.cffEncoding?o.name=this.font.cffEncoding.charset[i]:this.font.glyphNames.names&&(o.name=this.font.glyphNames.glyphIndexToName(i)),this.glyphs[i].advanceWidth=this.font._hmtxTableData[i].advanceWidth,this.glyphs[i].leftSideBearing=this.font._hmtxTableData[i].leftSideBearing}else typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());return this.glyphs[i]},Un.prototype.push=function(i,o){this.glyphs[i]=o,this.length++};function En(i,o){return new pr({index:o,font:i})}function kn(i,o,u,h,p,g){return function(){let A=new pr({index:o,font:i});return A.path=function(){u(A,h,p);let k=g(i.glyphs,A);return k.unitsPerEm=i.unitsPerEm,k},ns(A,"numberOfContours","_numberOfContours"),ns(A,"xMin","_xMin"),ns(A,"xMax","_xMax"),ns(A,"yMin","_yMin"),ns(A,"yMax","_yMax"),ns(A,"points","_points"),A}}function ss(i,o,u,h,p){return function(){let g=new pr({index:o,font:i});return g.path=function(){let A=u(i,g,h,p);return A.unitsPerEm=i.unitsPerEm,A},g}}var Wr={GlyphSet:Un,glyphLoader:En,ttfGlyphLoader:kn,cffGlyphLoader:ss};function tn(i,o){if(i===o)return!0;if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length)return!1;for(let u=0;u<i.length;u+=1)if(!tn(i[u],o[u]))return!1;return!0}else return!1}var G=10;function je(i){let o;return i.length<1240?o=107:i.length<33900?o=1131:o=32768,o}function $e(i,o,u,h){let p=[],g=[],A=h>1?ot.getULong(i,o):ot.getCard16(i,o),k=h>1?4:2,E,D;if(A!==0){let M=ot.getByte(i,o+k);E=o+(A+1)*M+k;let te=o+k+1;for(let J=0;J<A+1;J+=1)p.push(ot.getOffset(i,te,M)),te+=M;D=E+p[A]}else D=o+k;for(let M=0;M<p.length-1;M+=1){let te=ot.getBytes(i,E+p[M],E+p[M+1]);u&&(te=u(te,i,o,h)),g.push(te)}return{objects:g,startOffset:o,endOffset:D}}function et(i,o,u){let h=[],p=u>1?ot.getULong(i,o):ot.getCard16(i,o),g=u>1?4:2,A,k;if(p!==0){let E=ot.getByte(i,o+g);A=o+(p+1)*E+g;let D=o+g+1;for(let M=0;M<p+1;M+=1)h.push(ot.getOffset(i,D,E)),D+=E;k=A+h[p]}else k=o+g;return{offsets:h,startOffset:o,endOffset:k}}function it(i,o,u,h,p,g){let A=g>1?ot.getULong(u,h):ot.getCard16(u,h),k=g>1?4:2,E=0;if(A!==0){let M=ot.getByte(u,h+k);E=h+(A+1)*M+k}let D=ot.getBytes(u,E+o[i],E+o[i+1]);return p&&(D=p(D)),D}function Ct(i){let o="",u=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let h=i.parseByte(),p=h>>4,g=h&15;if(p===15||(o+=u[p],g===15))break;o+=u[g]}return parseFloat(o)}function Lt(i,o){let u,h,p,g;if(o===28)return u=i.parseByte(),h=i.parseByte(),u<<8|h;if(o===29)return u=i.parseByte(),h=i.parseByte(),p=i.parseByte(),g=i.parseByte(),u<<24|h<<16|p<<8|g;if(o===30)return Ct(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 Bt(i){let o={};for(let u=0;u<i.length;u+=1){let h=i[u][0],p=i[u][1],g;if(p.length===1?g=p[0]:g=p,Object.prototype.hasOwnProperty.call(o,h)&&!isNaN(o[h]))throw new Error("Object "+o+" already has key "+h);o[h]=g}return o}function ht(i,o,u,h){o=o!==void 0?o:0;let p=new ot.Parser(i,o),g=[],A=[];u=u!==void 0?u:i.byteLength;let k=h<2?22:28;for(;p.relativeOffset<u;){let E=p.parseByte();if(E<k){if(E===12&&(E=1200+p.parseByte()),h>1&&E===23){Dn(A);continue}g.push([E,A]),A=[]}else A.push(Lt(p,E,h))}return Bt(g)}function Qt(i,o){return o<=390?o=jn[o]:i?o=i[o-391]:o=void 0,o}function W(i,o,u){let h={},p;for(let g=0;g<o.length;g+=1){let A=o[g];if(Array.isArray(A.type)){let k=[];k.length=A.type.length;for(let E=0;E<A.type.length;E++)p=i[A.op]!==void 0?i[A.op][E]:void 0,p===void 0&&(p=A.value!==void 0&&A.value[E]!==void 0?A.value[E]:null),A.type[E]==="SID"&&(p=Qt(u,p)),k[E]=p;h[A.name]=k}else p=i[A.op],p===void 0&&(p=A.value!==void 0?A.value:null),A.type==="SID"&&(p=Qt(u,p)),h[A.name]=p}return h}function N(i,o){let u={};if(u.formatMajor=ot.getCard8(i,o),u.formatMinor=ot.getCard8(i,o+1),u.formatMajor>2)throw new Error(`Unsupported CFF table version ${u.formatMajor}.${u.formatMinor}`);return u.size=ot.getCard8(i,o+2),u.formatMajor<2?(u.offsetSize=ot.getCard8(i,o+3),u.startOffset=o,u.endOffset=o+4):(u.topDictLength=ot.getCard16(i,o+3),u.endOffset=o+8),u}var U=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Z=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],fe=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Qe=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],we=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function lt(i,o,u,h){let p=ht(i,o,i.byteLength,h);return W(p,h>1?Z:U,u)}function At(i,o,u,h,p){let g=ht(i,o,u,p);return W(g,p>1?Qe:fe,h)}function br(i,o,u){let h=ht(i,o,void 0,u);return W(h,we)}function It(i,o,u){let h=[];for(let p=0;p<u.length;p++){let g=new DataView(new Uint8Array(u[p]).buffer),A=br(g,0,2),k=A.private[0],E=A.private[1];if(k!==0&&E!==0){let D=At(i,E+o,k,[],2);if(D.subrs){let M=E+D.subrs,te=$e(i,M+o,void 0,2);A._subrs=te.objects,A._subrsBias=je(A._subrs)}A._privateDict=D}h.push(A)}return h}function rn(i,o,u,h,p){let g=[];for(let A=0;A<u.length;A+=1){let k=new DataView(new Uint8Array(u[A]).buffer),E=lt(k,0,h,p);E._subrs=[],E._subrsBias=0,E._defaultWidthX=0,E._nominalWidthX=0;let D=p<2?E.private[0]:0,M=p<2?E.private[1]:0;if(D!==0&&M!==0){let te=At(i,M+o,D,h,p);if(E._defaultWidthX=te.defaultWidthX,E._nominalWidthX=te.nominalWidthX,te.subrs!==0){let J=M+te.subrs,Te=$e(i,J+o,void 0,p);E._subrs=Te.objects,E._subrsBias=je(E._subrs)}E._privateDict=te}g.push(E)}return g}function yn(i,o,u,h,p){let g,A,k=new ot.Parser(i,o);u-=1;let E=[".notdef"],D=k.parseCard8();if(D===0)for(let M=0;M<u;M+=1)g=k.parseSID(),p?E.push(g):E.push(Qt(h,g)||g);else if(D===1)for(;E.length<=u;){g=k.parseSID(),A=k.parseCard8();for(let M=0;M<=A;M+=1)p?E.push("cid"+("00000"+g).slice(-5)):E.push(Qt(h,g)||g),g+=1}else if(D===2)for(;E.length<=u;){g=k.parseSID(),A=k.parseCard16();for(let M=0;M<=A;M+=1)p?E.push("cid"+("00000"+g).slice(-5)):E.push(Qt(h,g)||g),g+=1}else throw new Error("Unknown charset format "+D);return E}function hn(i,o){let u,h={},p=new ot.Parser(i,o),g=p.parseCard8();if(g===0){let A=p.parseCard8();for(let k=0;k<A;k+=1)u=p.parseCard8(),h[u]=k}else if(g===1){let A=p.parseCard8();u=1;for(let k=0;k<A;k+=1){let E=p.parseCard8(),D=p.parseCard8();for(let M=E;M<=E+D;M+=1)h[M]=u,u+=1}}else throw new Error("Unknown encoding format "+g);return h}function Dn(i){let o=i.pop();for(;i.length>o;)i.pop()}function zn(i,o){let u=i.tables.cff&&i.tables.cff.topDict&&i.tables.cff.topDict.paintType||0;return u===2&&(o.fill=null,o.stroke="black",o.strokeWidth=i.tables.cff.topDict.strokeWidth||0),u}function hr(i,o,u,h,p){let g,A,k,E,D=new We,M=[],te=0,J=!1,Te=!1,he=0,Me=0,ut,mr,lr,Rr,sn=0,On=[],Yn,Zn=0,Ps=i.tables.cff2||i.tables.cff;if(lr=Ps.topDict._defaultWidthX,Rr=Ps.topDict._nominalWidthX,p=p||i.variation&&i.variation.get(),o.getBlendPath||(o.getBlendPath=function(sr){return hr(i,o,u,h,sr)}),i.isCIDFont||h>1){let sr=Ps.topDict._fdSelect?Ps.topDict._fdSelect[o.index]:0,ar=Ps.topDict._fdArray[sr];ut=ar._subrs,mr=ar._subrsBias,h>1?(On=Ps.topDict._vstore.itemVariationStore,sn=ar._privateDict.vsindex):(lr=ar._defaultWidthX,Rr=ar._nominalWidthX)}else ut=Ps.topDict._subrs,mr=Ps.topDict._subrsBias;let Ro=zn(i,D),an=lr;function Pa(sr,ar){Te&&Ro!==2&&D.closePath(),D.moveTo(sr,ar),Te=!0}function ea(){let sr;sr=(M.length&1)!==0,sr&&!J&&(an=M.shift()+Rr),te+=M.length>>1,M.length=0,J=!0}function gr(sr){let ar,Pi,Kl,K0,wc,Mo,ta,so,Oi,Oa,ra,na,Ns=0;for(;Ns<sr.length;){let ao=sr[Ns];switch(Ns+=1,ao){case 1:ea();break;case 3:ea();break;case 4:M.length>1&&!J&&(an=M.shift()+Rr,J=!0),Me+=M.pop(),Pa(he,Me);break;case 5:for(;M.length>0;)he+=M.shift(),Me+=M.shift(),D.lineTo(he,Me);break;case 6:for(;M.length>0&&(he+=M.shift(),D.lineTo(he,Me),M.length!==0);)Me+=M.shift(),D.lineTo(he,Me);break;case 7:for(;M.length>0&&(Me+=M.shift(),D.lineTo(he,Me),M.length!==0);)he+=M.shift(),D.lineTo(he,Me);break;case 8:for(;M.length>0;)g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E+M.shift(),D.curveTo(g,A,k,E,he,Me);break;case 10:if(wc=M.pop()+mr,Mo=ut[wc],Mo){if(Zn>=G){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Zn++,gr(Mo),Zn--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(ao=sr[Ns],Ns+=1,ao){case 35:g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),ta=k+M.shift(),so=E+M.shift(),Oi=ta+M.shift(),Oa=so+M.shift(),ra=Oi+M.shift(),na=Oa+M.shift(),he=ra+M.shift(),Me=na+M.shift(),M.shift(),D.curveTo(g,A,k,E,ta,so),D.curveTo(Oi,Oa,ra,na,he,Me);break;case 34:g=he+M.shift(),A=Me,k=g+M.shift(),E=A+M.shift(),ta=k+M.shift(),so=E,Oi=ta+M.shift(),Oa=E,ra=Oi+M.shift(),na=Me,he=ra+M.shift(),D.curveTo(g,A,k,E,ta,so),D.curveTo(Oi,Oa,ra,na,he,Me);break;case 36:g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),ta=k+M.shift(),so=E,Oi=ta+M.shift(),Oa=E,ra=Oi+M.shift(),na=Oa+M.shift(),he=ra+M.shift(),D.curveTo(g,A,k,E,ta,so),D.curveTo(Oi,Oa,ra,na,he,Me);break;case 37:g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),ta=k+M.shift(),so=E+M.shift(),Oi=ta+M.shift(),Oa=so+M.shift(),ra=Oi+M.shift(),na=Oa+M.shift(),Math.abs(ra-he)>Math.abs(na-Me)?he=ra+M.shift():Me=na+M.shift(),D.curveTo(g,A,k,E,ta,so),D.curveTo(Oi,Oa,ra,na,he,Me);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+ao),M.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(M.length>=4){let Ac=Qr[M.pop()],cu=Qr[M.pop()],X0=M.pop(),J0=M.pop();if(Ac&&cu){o.isComposite=!0,o.components=[];let tx=i.cffEncoding.charset.indexOf(Ac),rx=i.cffEncoding.charset.indexOf(cu);o.components.push({glyphIndex:rx,dx:0,dy:0}),o.components.push({glyphIndex:tx,dx:J0,dy:X0}),D.extend(i.glyphs.get(rx).path);let e8=i.glyphs.get(tx),wp=JSON.parse(JSON.stringify(e8.path.commands));for(let Ap=0;Ap<wp.length;Ap+=1){let qo=wp[Ap];qo.type!=="Z"&&(qo.x+=J0,qo.y+=X0),(qo.type==="Q"||qo.type==="C")&&(qo.x1+=J0,qo.y1+=X0),qo.type==="C"&&(qo.x2+=J0,qo.y2+=X0)}D.extend(wp)}}else M.length>0&&!J&&(an=M.shift()+Rr,J=!0);Te&&Ro!==2&&(D.closePath(),Te=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}sn=M.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Yn||(Yn=i.variation&&p&&i.variation.process.getBlendVector(On,sn,p));var ts=M.pop(),wa=Yn?Yn.length:On.itemVariationSubtables[sn].regionIndexes.length,io=ts*wa,jo=M.length-io,bl=jo-ts;if(Yn)for(let Ac=0;Ac<ts;Ac++){var ex=M[bl+Ac];for(let cu=0;cu<wa;cu++)ex+=Yn[cu]*M[jo++];M[bl+Ac]=ex}for(;io--;)M.pop();break;case 18:ea();break;case 19:case 20:ea(),Ns+=te+7>>3;break;case 21:M.length>2&&!J&&(an=M.shift()+Rr,J=!0),Me+=M.pop(),he+=M.pop(),Pa(he,Me);break;case 22:M.length>1&&!J&&(an=M.shift()+Rr,J=!0),he+=M.pop(),Pa(he,Me);break;case 23:ea();break;case 24:for(;M.length>2;)g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E+M.shift(),D.curveTo(g,A,k,E,he,Me);he+=M.shift(),Me+=M.shift(),D.lineTo(he,Me);break;case 25:for(;M.length>6;)he+=M.shift(),Me+=M.shift(),D.lineTo(he,Me);g=he+M.shift(),A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E+M.shift(),D.curveTo(g,A,k,E,he,Me);break;case 26:for(M.length&1&&(he+=M.shift());M.length>0;)g=he,A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k,Me=E+M.shift(),D.curveTo(g,A,k,E,he,Me);break;case 27:for(M.length&1&&(Me+=M.shift());M.length>0;)g=he+M.shift(),A=Me,k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E,D.curveTo(g,A,k,E,he,Me);break;case 28:ar=sr[Ns],Pi=sr[Ns+1],M.push((ar<<24|Pi<<16)>>16),Ns+=2;break;case 29:if(wc=M.pop()+i.gsubrsBias,Mo=i.gsubrs[wc],Mo){if(Zn>=G){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Zn++,gr(Mo),Zn--}break;case 30:for(;M.length>0&&(g=he,A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E+(M.length===1?M.shift():0),D.curveTo(g,A,k,E,he,Me),M.length!==0);)g=he+M.shift(),A=Me,k=g+M.shift(),E=A+M.shift(),Me=E+M.shift(),he=k+(M.length===1?M.shift():0),D.curveTo(g,A,k,E,he,Me);break;case 31:for(;M.length>0&&(g=he+M.shift(),A=Me,k=g+M.shift(),E=A+M.shift(),Me=E+M.shift(),he=k+(M.length===1?M.shift():0),D.curveTo(g,A,k,E,he,Me),M.length!==0);)g=he,A=Me+M.shift(),k=g+M.shift(),E=A+M.shift(),he=k+M.shift(),Me=E+(M.length===1?M.shift():0),D.curveTo(g,A,k,E,he,Me);break;default:ao<32?console.log("Glyph "+o.index+": unknown operator "+ao):ao<247?M.push(ao-139):ao<251?(ar=sr[Ns],Ns+=1,M.push((ao-247)*256+ar+108)):ao<255?(ar=sr[Ns],Ns+=1,M.push(-(ao-251)*256-ar-108)):(ar=sr[Ns],Pi=sr[Ns+1],Kl=sr[Ns+2],K0=sr[Ns+3],Ns+=4,M.push((ar<<24|Pi<<16|Kl<<8|K0)/65536))}}}return gr(u),i.variation&&p&&(D.commands=D.commands.map(sr=>{let ar=Object.keys(sr);for(let Pi=0;Pi<ar.length;Pi++){let Kl=ar[Pi];Kl!=="type"&&(sr[Kl]=Math.round(sr[Kl]))}return sr})),J&&(o.advanceWidth=an),D}function Dt(i,o,u,h,p){let g=[],A,k=new ot.Parser(i,o),E=k.parseCard8();if(E===0)for(let D=0;D<u;D++){if(A=k.parseCard8(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");g.push(A)}else if(E===3||p>1&&E===4){let D=E===4?k.parseULong():k.parseCard16(),M=E===4?k.parseULong():k.parseCard16();if(M!==0)throw new Error(`CFF Table CID Font FDSelect format ${E} range has bad initial GID ${M}`);let te;for(let J=0;J<D;J++){if(A=E===4?k.parseUShort():k.parseCard8(),te=E===4?k.parseULong():k.parseCard16(),A>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+A+" (FD count "+h+")");if(te>u)throw new Error(`CFF Table CID Font FDSelect format ${p} range has bad GID ${te}`);for(;M<te;M++)g.push(A);M=te}if(te!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+te)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+E);return g}function Bn(i,o,u,h){let p,g=N(i,o);g.formatMajor===2?p=u.tables.cff2={}:p=u.tables.cff={};let A=g.formatMajor>1?null:$e(i,g.endOffset,ot.bytesToString),k=g.formatMajor>1?null:$e(i,A.endOffset),E=g.formatMajor>1?null:$e(i,k.endOffset,ot.bytesToString),D=$e(i,g.formatMajor>1?o+g.size+g.topDictLength:E.endOffset,void 0,g.formatMajor);u.gsubrs=D.objects,u.gsubrsBias=je(u.gsubrs);let M;if(g.formatMajor>1){let J=o+g.size,Te=ot.getBytes(i,J,J+g.topDictLength);M=rn(i,0,[Te],void 0,g.formatMajor)[0]}else{let J=rn(i,o,k.objects,E.objects,g.formatMajor);if(J.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+J.length);M=J[0]}if(p.topDict=M,M._privateDict&&(u.defaultWidthX=M._privateDict.defaultWidthX,u.nominalWidthX=M._privateDict.nominalWidthX),g.formatMajor<2&&M.ros[0]!==void 0&&M.ros[1]!==void 0&&(u.isCIDFont=!0),g.formatMajor>1){let J=M.fdArray,Te=M.fdSelect;if(!J)throw new Error("This is a CFF2 font, but FDArray information is missing");let he=$e(i,o+J,null,g.formatMajor),Me=It(i,o,he.objects);M._fdArray=Me,Te&&(M._fdSelect=Dt(i,o+Te,u.numGlyphs,Me.length,g.formatMajor))}else if(u.isCIDFont){let J=M.fdArray,Te=M.fdSelect;if(J===0||Te===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");J+=o;let he=$e(i,J),Me=rn(i,o,he.objects,E.objects,g.formatMajor);M._fdArray=Me,Te+=o,M._fdSelect=Dt(i,Te,u.numGlyphs,Me.length,g.formatMajor)}if(g.formatMajor<2){let J=o+M.private[1],Te=At(i,J,M.private[0],E.objects,g.formatMajor);if(u.defaultWidthX=Te.defaultWidthX,u.nominalWidthX=Te.nominalWidthX,Te.subrs!==0){let he=J+Te.subrs,Me=$e(i,he);u.subrs=Me.objects,u.subrsBias=je(u.subrs)}else u.subrs=[],u.subrsBias=0}let te;if(h.lowMemory?(te=et(i,o+M.charStrings,g.formatMajor),u.nGlyphs=te.offsets.length-(g.formatMajor>1?1:0)):(te=$e(i,o+M.charStrings,null,g.formatMajor),u.nGlyphs=te.objects.length),g.formatMajor>1&&u.tables.maxp&&u.nGlyphs!==u.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${u.nGlyphs}) must correspond to the glyph count in the maxp table (${u.tables.maxp.numGlyphs})`),g.formatMajor<2){let J=[],Te=[];M.charset===0?J=Tr:M.charset===1?J=Jr:M.charset===2?J=ln:J=yn(i,o+M.charset,u.nGlyphs,E.objects,u.isCIDFont),M.encoding===0?Te=Qr:M.encoding===1?Te=ks:Te=hn(i,o+M.encoding),u.cffEncoding=new K(Te,J),u.encoding=u.encoding||u.cffEncoding}if(u.glyphs=new Wr.GlyphSet(u),h.lowMemory)u._push=function(J){let Te=it(J,te.offsets,i,o+M.charStrings,void 0,g.formatMajor);u.glyphs.push(J,Wr.cffGlyphLoader(u,J,hr,Te,g.formatMajor))};else for(let J=0;J<u.nGlyphs;J+=1){let Te=te.objects[J];u.glyphs.push(J,Wr.cffGlyphLoader(u,J,hr,Te,g.formatMajor))}if(M.vstore){let J=new ot.Parser(i,o+M.vstore);M._vstore=J.parseVariationStore()}}function qn(i,o){let u,h=jn.indexOf(i);return h>=0&&(u=h),h=o.indexOf(i),h>=0?u=h+jn.length:(u=jn.length+o.length,o.push(i)),u}function Ga(){return new _e.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Qn(i){let o=new _e.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);o.names=[];for(let u=0;u<i.length;u+=1)o.names.push({name:"name_"+u,type:"NAME",value:i[u]});return o}function is(i,o,u){let h={};for(let p=0;p<i.length;p+=1){let g=i[p],A=o[g.name];A!==void 0&&!tn(A,g.value)&&(g.type==="SID"&&(A=qn(A,u)),h[g.op]={name:g.name,type:g.type,value:A})}return h}function zi(i,o,u){let h=new _e.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=is(u>1?Z:U,i,o),h}function ha(i){let o=new _e.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return o.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],o}function bs(i){let o=new _e.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);o.strings=[];for(let u=0;u<i.length;u+=1)o.strings.push({name:"string_"+u,type:"STRING",value:i[u]});return o}function Va(){return new _e.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function So(i,o){let u=new _e.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<i.length;h+=1){let p=i[h],g=qn(p,o);u.fields.push({name:"glyph_"+h,type:"SID",value:g})}return u}function Hn(i,o){let u=[],h=i.path;o<2&&u.push({name:"width",type:"NUMBER",value:i.advanceWidth});let p=0,g=0;for(let A=0;A<h.commands.length;A+=1){let k,E,D=h.commands[A];if(D.type==="Q"){let M=.3333333333333333,te=2/3;D={type:"C",x:D.x,y:D.y,x1:Math.round(M*p+te*D.x1),y1:Math.round(M*g+te*D.y1),x2:Math.round(M*D.x+te*D.x1),y2:Math.round(M*D.y+te*D.y1)}}if(D.type==="M")k=Math.round(D.x-p),E=Math.round(D.y-g),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rmoveto",type:"OP",value:21}),p=Math.round(D.x),g=Math.round(D.y);else if(D.type==="L")k=Math.round(D.x-p),E=Math.round(D.y-g),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rlineto",type:"OP",value:5}),p=Math.round(D.x),g=Math.round(D.y);else if(D.type==="C"){let M=Math.round(D.x1-p),te=Math.round(D.y1-g),J=Math.round(D.x2-D.x1),Te=Math.round(D.y2-D.y1);k=Math.round(D.x-D.x2),E=Math.round(D.y-D.y2),u.push({name:"dx1",type:"NUMBER",value:M}),u.push({name:"dy1",type:"NUMBER",value:te}),u.push({name:"dx2",type:"NUMBER",value:J}),u.push({name:"dy2",type:"NUMBER",value:Te}),u.push({name:"dx",type:"NUMBER",value:k}),u.push({name:"dy",type:"NUMBER",value:E}),u.push({name:"rrcurveto",type:"OP",value:8}),p=Math.round(D.x),g=Math.round(D.y)}}return o<2&&u.push({name:"endchar",type:"OP",value:14}),u}function fa(i,o){let u=new _e.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<i.length;h+=1){let p=i.get(h),g=Hn(p,o);u.charStrings.push({name:p.name,type:"CHARSTRING",value:g})}return u}function ms(i,o,u){let h=new _e.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=is(u>1?Qe:fe,i,o),h}function Ia(i,o){let u=new _e.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),h=1/o.unitsPerEm,p={version:o.version,fullName:o.fullName,familyName:o.familyName,weight:o.weightName,fontBBox:o.fontBBox||[0,0,0,0],fontMatrix:[h,0,0,h,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},g=o&&o.topDict||{};g.paintType&&(p.paintType=g.paintType,p.strokeWidth=g.strokeWidth||0);let A={},k=[],E;for(let J=1;J<i.length;J+=1)E=i.get(J),k.push(E.name);let D=[];u.header=Ga(),u.nameIndex=Qn([o.postScriptName]);let M=zi(p,D);u.topDictIndex=ha(M),u.globalSubrIndex=Va(),u.charsets=So(k,D),u.charStringsIndex=fa(i,1),u.privateDict=ms(A,D),u.stringIndex=bs(D);let te=u.header.sizeOf()+u.nameIndex.sizeOf()+u.topDictIndex.sizeOf()+u.stringIndex.sizeOf()+u.globalSubrIndex.sizeOf();return p.charset=te,p.encoding=0,p.charStrings=p.charset+u.charsets.sizeOf(),p.private[1]=p.charStrings+u.charStringsIndex.sizeOf(),M=zi(p,D),u.topDictIndex=ha(M),u}var as={parse:Bn,make:Ia};function qa(i,o){let u={},h=new ot.Parser(i,o);return u.version=h.parseVersion(),u.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,u.checkSumAdjustment=h.parseULong(),u.magicNumber=h.parseULong(),ue.argument(u.magicNumber===1594834165,"Font header has wrong magic number."),u.flags=h.parseUShort(),u.unitsPerEm=h.parseUShort(),u.created=h.parseLongDateTime(),u.modified=h.parseLongDateTime(),u.xMin=h.parseShort(),u.yMin=h.parseShort(),u.xMax=h.parseShort(),u.yMax=h.parseShort(),u.macStyle=h.parseUShort(),u.lowestRecPPEM=h.parseUShort(),u.fontDirectionHint=h.parseShort(),u.indexToLocFormat=h.parseShort(),u.glyphDataFormat=h.parseShort(),u}function ei(i){let o=Math.round(new Date().getTime()/1e3)+2082844800,u=o,h=i.macStyle||0;return i.createdTimestamp&&(u=i.createdTimestamp+2082844800),new _e.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:u},{name:"modified",type:"LONGDATETIME",value:o},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],i)}var ti={parse:qa,make:ei};function Hs(i,o){let u={},h=new ot.Parser(i,o);return u.version=h.parseVersion(),u.ascender=h.parseShort(),u.descender=h.parseShort(),u.lineGap=h.parseShort(),u.advanceWidthMax=h.parseUShort(),u.minLeftSideBearing=h.parseShort(),u.minRightSideBearing=h.parseShort(),u.xMaxExtent=h.parseShort(),u.caretSlopeRise=h.parseShort(),u.caretSlopeRun=h.parseShort(),u.caretOffset=h.parseShort(),h.relativeOffset+=8,u.metricDataFormat=h.parseShort(),u.numberOfHMetrics=h.parseUShort(),u}function Ya(i){return new _e.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],i)}var Is={parse:Hs,make:Ya};function pa(i,o,u,h,p){let g,A,k=new ot.Parser(i,o);for(let E=0;E<h;E+=1){E<u&&(g=k.parseUShort(),A=k.parseShort());let D=p.get(E);D.advanceWidth=g,D.leftSideBearing=A}}function dl(i,o,u,h,p){i._hmtxTableData={};let g,A,k=new ot.Parser(o,u);for(let E=0;E<p;E+=1)E<h&&(g=k.parseUShort(),A=k.parseShort()),i._hmtxTableData[E]={advanceWidth:g,leftSideBearing:A}}function Za(i,o,u,h,p,g,A){A.lowMemory?dl(i,o,u,h,p):pa(o,u,h,p,g)}function os(i){let o=new _e.Table("hmtx",[]);for(let u=0;u<i.length;u+=1){let h=i.get(u),p=h.advanceWidth||0,g=h.leftSideBearing||0;o.fields.push({name:"advanceWidth_"+u,type:"USHORT",value:p}),o.fields.push({name:"leftSideBearing_"+u,type:"SHORT",value:g})}return o}var js={parse:Za,make:os};function Hi(i){let o=new _e.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:i.length}]),u="",h=12+i.length*4;for(let p=0;p<i.length;++p){let g=u.indexOf(i[p]);g<0&&(g=u.length,u+=i[p]),o.fields.push({name:"offset "+p,type:"USHORT",value:h+g}),o.fields.push({name:"length "+p,type:"USHORT",value:i[p].length})}return o.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),o}function xi(i,o){let u=new ot.Parser(i,o),h=u.parseULong();ue.argument(h===1,"Unsupported ltag table version."),u.skip("uLong",1);let p=u.parseULong(),g=[];for(let A=0;A<p;A++){let k="",E=o+u.parseUShort(),D=u.parseUShort();for(let M=E;M<E+D;++M)k+=String.fromCharCode(i.getInt8(M));g.push(k)}return g}var bi={make:Hi,parse:xi};function hl(i,o){let u={},h=new ot.Parser(i,o);return u.version=h.parseVersion(),u.numGlyphs=h.parseUShort(),u.version===1&&(u.maxPoints=h.parseUShort(),u.maxContours=h.parseUShort(),u.maxCompositePoints=h.parseUShort(),u.maxCompositeContours=h.parseUShort(),u.maxZones=h.parseUShort(),u.maxTwilightPoints=h.parseUShort(),u.maxStorage=h.parseUShort(),u.maxFunctionDefs=h.parseUShort(),u.maxInstructionDefs=h.parseUShort(),u.maxStackElements=h.parseUShort(),u.maxSizeOfInstructions=h.parseUShort(),u.maxComponentElements=h.parseUShort(),u.maxComponentDepth=h.parseUShort()),u}function ri(i){return new _e.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}var Uo={parse:hl,make:ri},ma=[{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<ma.length;o+=1){let u=ma[o];if(i>=u.begin&&i<u.end)return o}return-1}function pl(i,o){let u={},h=new ot.Parser(i,o);u.version=h.parseUShort(),u.xAvgCharWidth=h.parseShort(),u.usWeightClass=h.parseUShort(),u.usWidthClass=h.parseUShort(),u.fsType=h.parseUShort(),u.ySubscriptXSize=h.parseShort(),u.ySubscriptYSize=h.parseShort(),u.ySubscriptXOffset=h.parseShort(),u.ySubscriptYOffset=h.parseShort(),u.ySuperscriptXSize=h.parseShort(),u.ySuperscriptYSize=h.parseShort(),u.ySuperscriptXOffset=h.parseShort(),u.ySuperscriptYOffset=h.parseShort(),u.yStrikeoutSize=h.parseShort(),u.yStrikeoutPosition=h.parseShort(),u.sFamilyClass=h.parseShort(),u.panose=[];for(let p=0;p<10;p++)u.panose[p]=h.parseByte();return u.ulUnicodeRange1=h.parseULong(),u.ulUnicodeRange2=h.parseULong(),u.ulUnicodeRange3=h.parseULong(),u.ulUnicodeRange4=h.parseULong(),u.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),u.fsSelection=h.parseUShort(),u.usFirstCharIndex=h.parseUShort(),u.usLastCharIndex=h.parseUShort(),u.sTypoAscender=h.parseShort(),u.sTypoDescender=h.parseShort(),u.sTypoLineGap=h.parseShort(),u.usWinAscent=h.parseUShort(),u.usWinDescent=h.parseUShort(),u.version>=1&&(u.ulCodePageRange1=h.parseULong(),u.ulCodePageRange2=h.parseULong()),u.version>=2&&(u.sxHeight=h.parseShort(),u.sCapHeight=h.parseShort(),u.usDefaultChar=h.parseUShort(),u.usBreakChar=h.parseUShort(),u.usMaxContent=h.parseUShort()),u}function ls(i){return new _e.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],i)}var Ds={parse:pl,make:ls,unicodeRanges:ma,getUnicodeRange:fl};function Ri(i,o){let u={},h=new ot.Parser(i,o);switch(u.version=h.parseVersion(),u.italicAngle=h.parseFixed(),u.underlinePosition=h.parseShort(),u.underlineThickness=h.parseShort(),u.isFixedPitch=h.parseULong(),u.minMemType42=h.parseULong(),u.maxMemType42=h.parseULong(),u.minMemType1=h.parseULong(),u.maxMemType1=h.parseULong(),u.version){case 1:u.names=Dr.slice();break;case 2:u.numberOfGlyphs=h.parseUShort(),u.glyphNameIndex=new Array(u.numberOfGlyphs);for(let p=0;p<u.numberOfGlyphs;p++)u.glyphNameIndex[p]=h.parseUShort();u.names=[];for(let p=0;p<u.numberOfGlyphs;p++)if(u.glyphNameIndex[p]>=Dr.length){let g=h.parseChar();u.names.push(h.parseString(g))}break;case 2.5:u.numberOfGlyphs=h.parseUShort(),u.offset=new Array(u.numberOfGlyphs);for(let p=0;p<u.numberOfGlyphs;p++)u.offset[p]=h.parseChar();break}return u}function zo(i){let{italicAngle:o=Math.round((i.italicAngle||0)*65536),underlinePosition:u=0,underlineThickness:h=0,isFixedPitch:p=0,minMemType42:g=0,maxMemType42:A=0,minMemType1:k=0,maxMemType1:E=0}=i.tables.post||{};return new _e.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:o},{name:"underlinePosition",type:"FWORD",value:u},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:p},{name:"minMemType42",type:"ULONG",value:g},{name:"maxMemType42",type:"ULONG",value:A},{name:"minMemType1",type:"ULONG",value:k},{name:"maxMemType1",type:"ULONG",value:E}])}var Dl={parse:Ri,make:zo},Es=new Array(9);Es[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(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 Ea={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,Ea)}})};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,Ea)}})};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,Ea)}}ue.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Es[6]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(ge.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ea)}})};if(o===2)return{substFormat:2,coverage:this.parsePointer(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(Ea)}})};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(Ea)};ue.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Es[7]=function(){let i=this.parseUShort();ue.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let o=this.parseUShort(),u=new 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 es=new Array(9);es[1]=function(i){if(i.substFormat===1)return new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.ushortList("substitute",i.substitute)));ue.fail("Lookup type 1 substFormat must be 1 or 2.")},es[2]=function(i){return ue.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.tableList("seqSet",i.sequences,function(o){return new _e.Table("sequenceSetTable",_e.ushortList("sequence",o))})))},es[3]=function(i){return ue.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.tableList("altSet",i.alternateSets,function(o){return new _e.Table("alternateSetTable",_e.ushortList("alternate",o))})))},es[4]=function(i){return ue.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new _e.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.tableList("ligSet",i.ligatureSets,function(o){return new _e.Table("ligatureSetTable",_e.tableList("ligature",o,function(u){return new _e.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:u.ligGlyph}].concat(_e.ushortList("component",u.components,u.components.length+1)))}))})))},es[5]=function(i){if(i.substFormat===1)return new _e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.tableList("sequenceRuleSet",i.ruleSets,function(o){return o?new _e.Table("sequenceRuleSetTable",_e.tableList("sequenceRule",o,function(u){let h=_e.ushortList("seqLookup",[],u.lookupRecords.length).concat(_e.ushortList("inputSequence",u.input,u.input.length+1));[h[0],h[1]]=[h[1],h[0]];for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new _e.Table("sequenceRuleTable",h)})):new _e.Table("NULL",null)})));if(i.substFormat===2)return new _e.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new _e.ClassDef(i.classDef)}].concat(_e.tableList("classSeqRuleSet",i.classSets,function(o){return o?new _e.Table("classSeqRuleSetTable",_e.tableList("classSeqRule",o,function(u){let h=_e.ushortList("classes",u.classes,u.classes.length+1).concat(_e.ushortList("seqLookupCount",[],u.lookupRecords.length));for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new _e.Table("classSeqRuleTable",h)})):new _e.Table("NULL",null)})));if(i.substFormat===3){let o=[{name:"substFormat",type:"USHORT",value:i.substFormat}];o.push({name:"inputGlyphCount",type:"USHORT",value:i.coverages.length}),o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.coverages.length;u++){let h=i.coverages[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new _e.Coverage(h)})}for(let u=0;u<i.lookupRecords.length;u++){let h=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:h.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:h.lookupListIndex})}return new _e.Table("contextualSubstitutionTable",o)}ue.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},es[6]=function(i){if(i.substFormat===1)return new _e.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new _e.Coverage(i.coverage)}].concat(_e.tableList("chainRuleSet",i.chainRuleSets,function(o){return new _e.Table("chainRuleSetTable",_e.tableList("chainRule",o,function(u){let h=_e.ushortList("backtrackGlyph",u.backtrack,u.backtrack.length).concat(_e.ushortList("inputGlyph",u.input,u.input.length+1)).concat(_e.ushortList("lookaheadGlyph",u.lookahead,u.lookahead.length)).concat(_e.ushortList("substitution",[],u.lookupRecords.length));for(let p=0;p<u.lookupRecords.length;p++){let g=u.lookupRecords[p];h=h.concat({name:"sequenceIndex"+p,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:g.lookupListIndex})}return new _e.Table("chainRuleTable",h)}))})));if(i.substFormat===2)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 _e.Coverage(h)})}o.push({name:"inputGlyphCount",type:"USHORT",value:i.inputCoverage.length});for(let u=0;u<i.inputCoverage.length;u++){let h=i.inputCoverage[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new _e.Coverage(h)})}o.push({name:"lookaheadGlyphCount",type:"USHORT",value:i.lookaheadCoverage.length});for(let u=0;u<i.lookaheadCoverage.length;u++){let h=i.lookaheadCoverage[u];o.push({name:"lookaheadCoverage"+u,type:"TABLE",value:new _e.Coverage(h)})}o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.lookupRecords.length;u++){let h=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:h.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:h.lookupListIndex})}return new _e.Table("chainContextTable",o)}ue.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Wi(i){return new _e.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new _e.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new _e.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new _e.LookupList(i.lookups,es)}])}var Mi={parse:ml,make:Wi};function Gi(i,o){let u=new ot.Parser(i,o),h=u.parseULong();ue.argument(h===1,"Unsupported META table version."),u.parseULong(),u.parseULong();let p=u.parseULong(),g={};for(let A=0;A<p;A++){let k=u.parseTag(),E=u.parseULong(),D=u.parseULong();if(k==="appl"||k==="bild")continue;let M=Ce.UTF8(i,o+E,D);g[k]=M}return g}function gs(i){let o=Object.keys(i).length,u="",h=16+o*12,p=new _e.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:o}]);for(let g in i){let A=u.length;u+=i[g],p.fields.push({name:"tag "+g,type:"TAG",value:g}),p.fields.push({name:"offset "+g,type:"ULONG",value:h+A}),p.fields.push({name:"length "+g,type:"ULONG",value:i[g].length})}return p.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),p}var Ws={parse:Gi,make:gs};function Bl(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 p=u.parseUShort(),g=u.parseOffset32(),A=u.parseOffset32(),k=u.parseUShort();u.relativeOffset=g;let E=u.parseRecordList(p,{glyphID:ge.uShort,firstLayerIndex:ge.uShort,numLayers:ge.uShort});u.relativeOffset=A;let D=u.parseRecordList(k,{glyphID:ge.uShort,paletteIndex:ge.uShort});return{version:h,baseGlyphRecords:E,layerRecords:D}}function Vi({version:i=0,baseGlyphRecords:o=[],layerRecords:u=[]}){ue.argument(i===0,"Only COLRv0 supported.");let h=14,p=h+o.length*6;return new _e.Table("COLR",[{name:"version",type:"USHORT",value:i},{name:"numBaseGlyphRecords",type:"USHORT",value:o.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:p},{name:"numLayerRecords",type:"USHORT",value:u.length},...o.map((g,A)=>[{name:"glyphID_"+A,type:"USHORT",value:g.glyphID},{name:"firstLayerIndex_"+A,type:"USHORT",value:g.firstLayerIndex},{name:"numLayers_"+A,type:"USHORT",value:g.numLayers}]).flat(),...u.map((g,A)=>[{name:"LayerGlyphID_"+A,type:"USHORT",value:g.glyphID},{name:"paletteIndex_"+A,type:"USHORT",value:g.paletteIndex}]).flat()])}var qi={parse:Bl,make:Vi};function fn(i,o){return[{name:"tag_"+i,type:"TAG",value:o.tag},{name:"minValue_"+i,type:"FIXED",value:o.minValue<<16},{name:"defaultValue_"+i,type:"FIXED",value:o.defaultValue<<16},{name:"maxValue_"+i,type:"FIXED",value:o.maxValue<<16},{name:"flags_"+i,type:"USHORT",value:0},{name:"nameID_"+i,type:"USHORT",value:o.axisNameID}]}function ga(i,o,u){let h={},p=new ot.Parser(i,o);h.tag=p.parseTag(),h.minValue=p.parseFixed(),h.defaultValue=p.parseFixed(),h.maxValue=p.parseFixed(),p.skip("uShort",1);let g=p.parseUShort();return h.axisNameID=g,h.name=pt(u,g),h}function Yi(i,o,u,h={}){let p=[{name:"nameID_"+i,type:"USHORT",value:o.subfamilyNameID},{name:"flags_"+i,type:"USHORT",value:0}];for(let g=0;g<u.length;++g){let A=u[g].tag;p.push({name:"axis_"+i+" "+A,type:"FIXED",value:o.coordinates[A]<<16})}return h&&h.postScriptNameID&&p.push({name:"postScriptNameID_",type:"USHORT",value:o.postScriptNameID!==void 0?o.postScriptNameID:65535}),p}function Na(i,o,u,h,p){let g={},A=new ot.Parser(i,o),k=A.parseUShort();g.subfamilyNameID=k,g.name=pt(h,k,[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===p)return g.postScriptNameID=void 0,g.postScriptName=void 0,g;let E=A.parseUShort();return g.postScriptNameID=E==65535?void 0:E,g.postScriptName=g.postScriptNameID!==void 0?pt(h,E,[6]):"",g}function ji(i,o){let u=new _e.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:i.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:i.instances.length},{name:"instanceSize",type:"USHORT",value:4+i.axes.length*4}]);u.offsetToData=u.sizeOf();for(let p=0;p<i.axes.length;p++)u.fields=u.fields.concat(fn(p,i.axes[p],o));let h={};for(let p=0;p<i.instances.length;p++)if(i.instances[p].postScriptNameID!==void 0){u.instanceSize+=2,h.postScriptNameID=!0;break}for(let p=0;p<i.instances.length;p++)u.fields=u.fields.concat(Yi(p,i.instances[p],i.axes,h));return u}function Di(i,o,u){let h=new ot.Parser(i,o),p=h.parseULong();ue.argument(p===65536,"Unsupported fvar table version.");let g=h.parseOffset16();h.skip("uShort",1);let A=h.parseUShort(),k=h.parseUShort(),E=h.parseUShort(),D=h.parseUShort(),M=[];for(let Te=0;Te<A;Te++)M.push(ga(i,o+g+Te*k,u));let te=[],J=o+g+A*k;for(let Te=0;Te<E;Te++)te.push(Na(i,J+Te*D,M,u,D));return{axes:M,instances:te}}var ni={make:ji,parse:Di},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 Bi(){let i=this.parseUShort(),o=Gs[i],u={format:i};return o===void 0?(console.warn(`Unknown axis value table format ${i}`),u):Object.assign(u,this.parseStruct(o.bind(this)))}function Ra(i,o,u){o||(o=0);let h=new ot.Parser(i,o),p=h.parseUShort(),g=h.parseUShort();p!==1&&console.warn(`Unsupported STAT table version ${p}.${g}`);let A=[p,g],k=h.parseUShort(),E=h.parseUShort(),D=h.parseOffset32(),M=h.parseUShort(),te=h.parseOffset32(),J=p>1||g>0?h.parseUShort():void 0;u!==void 0&&ue.argument(E>=u.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),M>0&&ue.argument(E>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let Te=[];for(let ut=0;ut<E;ut++)h.offset=o+D,h.relativeOffset=ut*k,Te.push(h.parseStruct(ws));h.offset=o,h.relativeOffset=te;let he=h.parseUShortList(M),Me=[];for(let ut=0;ut<M;ut++)h.offset=o+te,h.relativeOffset=he[ut],Me.push(Bi.apply(h));return{version:A,axes:Te,values:Me,elidedFallbackNameID:J}}var si=new Array(5);si[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}]},si[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}]},si[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}]},si[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 _e.Record("axisRecord_"+i,[{name:"axisTag_"+i,type:"TAG",value:o.tag},{name:"axisNameID_"+i,type:"USHORT",value:o.nameID},{name:"axisOrdering_"+i,type:"USHORT",value:o.ordering}])}function Ka(i,o){let u=o.format,h=si[u];ue.argument(h!==void 0,`Unknown axis value table format ${u}`);let p=h(i,o);return new _e.Table("axisValueTable_"+i,p)}function Xa(i){let o=new _e.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:i.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:i.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:i.elidedFallbackNameID}]);o.designAxesOffset=o.offsetToAxisValueOffsets=o.sizeOf();for(let g=0;g<i.axes.length;g++){let A=ys(g,i.axes[g]);o.offsetToAxisValueOffsets+=A.sizeOf(),o.fields=o.fields.concat(A.fields)}let u=[],h=[],p=i.values.length*2;for(let g=0;g<i.values.length;g++){let A=Ka(g,i.values[g]);u.push({name:"offset_"+g,type:"USHORT",value:p}),p+=A.sizeOf(),h=h.concat(A.fields)}return o.fields=o.fields.concat(u),o.fields=o.fields.concat(h),o}var As={make:Xa,parse:Ra};function Ja(i,o){return new _e.Record("axisValueMap_"+i,[{name:"fromCoordinate_"+i,type:"F2DOT14",value:o.fromCoordinate},{name:"toCoordinate_"+i,type:"F2DOT14",value:o.toCoordinate}])}function Ql(i,o){let u=new _e.Record("segmentMap_"+i,[{name:"positionMapCount_"+i,type:"USHORT",value:o.axisValueMaps.length}]),h=[];for(let p=0;p<o.axisValueMaps.length;p++){let g=Ja(`${i}_${p}`,o.axisValueMaps[p]);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 _e.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:i.axisSegmentMaps.length}]);for(let h=0;h<i.axisSegmentMaps.length;h++){let p=Ql(h,i.axisSegmentMaps[h]);u.fields=u.fields.concat(p.fields)}return u}function Co(i,o,u){o||(o=0);let h=new ge(i,o),p=h.parseUShort(),g=h.parseUShort();p!==1&&console.warn(`Unsupported avar table version ${p}.${g}`),h.skip("uShort",1);let A=h.parseUShort();ue.argument(A===u.axes.length,"avar axis count must correspond to fvar axis count");let k=[];for(let E=0;E<A;E++){let D=[],M=h.parseUShort();for(let te=0;te<M;te++){let J=h.parseF2Dot14(),Te=h.parseF2Dot14();D.push({fromCoordinate:J,toCoordinate:Te})}k.push({axisValueMaps:D})}return{version:[p,g],axisSegmentMaps:k}}var xa={make:Ho,parse:Co};function Ma(i,o,u,h){let p=new ot.Parser(i,o),g=p.parseTupleVariationStore(p.relativeOffset,u.axes.length,"cvar",h),A=p.parseUShort(),k=p.parseUShort();return A!==1&&console.warn(`Unsupported cvar table version ${A}.${k}`),{version:[A,k],...g}}function Wo(){console.warn("Writing of cvar tables is not yet supported.")}var ba={make:Wo,parse:Ma};function cs(i,o,u,h){let p=new ot.Parser(i,o),g=p.parseUShort(),A=p.parseUShort();g!==1&&console.warn(`Unsupported gvar table version ${g}.${A}`);let k=p.parseUShort();k!==u.axes.length&&console.warn(`axisCount ${k} in gvar table does not match the number of axes ${u.axes.length} in the fvar table!`);let E=p.parseUShort(),D=p.parsePointer32(function(){return this.parseTupleRecords(E,k)}),M=p.parseTupleVariationStoreList(k,"gvar",h);return{version:[g,A],sharedTuples:D,glyphVariations:M}}function Go(){console.warn("Writing of gvar tables is not yet supported.")}var Zi={make:Go,parse:cs};function gl(i,o){let u={},h=new ot.Parser(i,o);u.version=h.parseUShort(),ue.argument(u.version<=1,"Unsupported gasp table version."),u.numRanges=h.parseUShort(),u.gaspRanges=[];for(let p=0;p<u.numRanges;p++)u.gaspRanges[p]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return u}function se(i){let o=new _e.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:i.numRanges}]);for(let u in i.gaspRanges)o.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:i.gaspRanges[u].rangeMaxPPEM}),o.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:i.gaspRanges[u].rangeGaspBehavior});return o}var T={parse:gl,make:se};function j(i,o){let u=new Map,h=i.buffer,p=new ge(i,o);if(p.parseUShort()!==0)return u;p.relativeOffset=p.parseOffset32();let g=i.byteOffset+o+p.relativeOffset,A=p.parseUShort(),k=new Map;for(let E=0;E<A;E++){let D=p.parseUShort(),M=p.parseUShort(),te=g+p.parseOffset32(),J=p.parseULong(),Te=k.get(te);Te===void 0&&(Te=new Uint8Array(h,te,J),k.set(te,Te));for(let he=D;he<=M;he++)u.set(he,Te)}return u}function Q(i){let o=Array.from(i.keys()).sort(),u=[],h=[],p=new Map,g=0,A={endGlyphID:null};for(let J=0,Te=o.length;J<Te;J++){let he=o[J],Me=i.get(he),ut=p.get(Me);ut===void 0&&(ut=g,h.push(Me),p.set(Me,ut),g+=Me.byteLength),he-1===A.endGlyphID&&ut===A.svgDocOffset?A.endGlyphID=he:(A={startGlyphID:he,endGlyphID:he,svgDocOffset:ut,svgDocLength:Me.byteLength},u.push(A))}let k=u.length,E=h.length,D=2+k*12,M=new Array(4+k*4+E),te=0;M[te++]={name:"version",type:"USHORT",value:0},M[te++]={name:"svgDocumentListOffset",type:"ULONG",value:10},M[te++]={name:"reserved",type:"ULONG",value:0},M[te++]={name:"numEntries",type:"USHORT",value:k};for(let J=0;J<k;J++){let Te="documentRecord_"+J,{startGlyphID:he,endGlyphID:Me,svgDocOffset:ut,svgDocLength:mr}=u[J];M[te++]={name:Te+"_startGlyphID",type:"USHORT",value:he},M[te++]={name:Te+"_endGlyphID",type:"USHORT",value:Me},M[te++]={name:Te+"_svgDocOffset",type:"ULONG",value:D+ut},M[te++]={name:Te+"_svgDocLength",type:"ULONG",value:mr}}for(let J=0;J<E;J++)M[te++]={name:"svgDoc_"+J,type:"LITERAL",value:h[J]};return new _e.Table("SVG ",M)}var F={make:Q,parse:j};function xe(i){return Math.log(i)/Math.log(2)|0}function Se(i){for(;i.length%4!==0;)i.push(0);let o=0;for(let u=0;u<i.length;u+=4)o+=(i[u]<<24)+(i[u+1]<<16)+(i[u+2]<<8)+i[u+3];return o%=Math.pow(2,32),o}function Oe(i,o,u,h){return new _e.Record("Table Record",[{name:"tag",type:"TAG",value:i!==void 0?i:""},{name:"checkSum",type:"ULONG",value:o!==void 0?o:0},{name:"offset",type:"ULONG",value:u!==void 0?u:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function Xe(i){let o=new _e.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);o.tables=i,o.numTables=i.length;let u=Math.pow(2,xe(o.numTables));o.searchRange=16*u,o.entrySelector=xe(u),o.rangeShift=o.numTables*16-o.searchRange;let h=[],p=[],g=o.sizeOf()+Oe().sizeOf()*o.numTables;for(;g%4!==0;)g+=1,p.push({name:"padding",type:"BYTE",value:0});for(let A=0;A<i.length;A+=1){let k=i[A];ue.argument(k.tableName.length===4,"Table name"+k.tableName+" is invalid.");let E=k.sizeOf(),D=Oe(k.tableName,Se(k.encode()),g,E);for(h.push({name:D.tag+" Table Record",type:"RECORD",value:D}),p.push({name:k.tableName+" table",type:"RECORD",value:k}),g+=E,ue.argument(!isNaN(g),"Something went wrong calculating the offset.");g%4!==0;)g+=1,p.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(A,k){return A.value.tag>k.value.tag?1:-1}),o.fields=o.fields.concat(h),o.fields=o.fields.concat(p),o}function dt(i,o,u){for(let h=0;h<o.length;h+=1){let p=i.charToGlyphIndex(o[h]);if(p>0)return i.glyphs.get(p).getMetrics()}return u}function er(i){let o=0;for(let u=0;u<i.length;u+=1)o+=i[u];return o/i.length}function or(i){let o=[],u=[],h=[],p=[],g=[],A=[],k=[],E,D=0,M=0,te=0,J=0,Te=0;for(let ts=0;ts<i.glyphs.length;ts+=1){let wa=i.glyphs.get(ts),io=wa.unicode|0;if(isNaN(wa.advanceWidth))throw new Error("Glyph "+wa.name+" ("+ts+"): advanceWidth is not a number.");(E>io||E===void 0)&&io>0&&(E=io),D<io&&(D=io);let jo=Ds.getUnicodeRange(io);if(jo<32)M|=1<<jo;else if(jo<64)te|=1<<jo-32;else if(jo<96)J|=1<<jo-64;else if(jo<123)Te|=1<<jo-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(wa.name===".notdef")continue;let bl=wa.getMetrics();o.push(bl.xMin),u.push(bl.yMin),h.push(bl.xMax),p.push(bl.yMax),A.push(bl.leftSideBearing),k.push(bl.rightSideBearing),g.push(wa.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,p),advanceWidthMax:Math.max.apply(null,g),advanceWidthAvg:er(g),minLeftSideBearing:Math.min.apply(null,A),maxLeftSideBearing:Math.max.apply(null,A),minRightSideBearing:Math.min.apply(null,k)};he.ascender=i.ascender,he.descender=i.descender;let Me=0;i.weightClass>=600&&(Me|=i.macStyleValues.BOLD),i.italicAngle<0&&(Me|=i.macStyleValues.ITALIC);let ut=ti.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:he.xMin,yMin:he.yMin,xMax:he.xMax,yMax:he.yMax,lowestRecPPEM:3,macStyle:Me,createdTimestamp:i.createdTimestamp}),mr=Is.make({ascender:he.ascender,descender:he.descender,advanceWidthMax:he.advanceWidthMax,minLeftSideBearing:he.minLeftSideBearing,minRightSideBearing:he.minRightSideBearing,xMaxExtent:he.maxLeftSideBearing+(he.xMax-he.xMin),numberOfHMetrics:i.glyphs.length}),lr=Uo.make(i.glyphs.length),Rr=Ds.make(Object.assign({xAvgCharWidth:Math.round(he.advanceWidthAvg),usFirstCharIndex:E,usLastCharIndex:D,ulUnicodeRange1:M,ulUnicodeRange2:te,ulUnicodeRange3:J,ulUnicodeRange4:Te,sTypoAscender:he.ascender,sTypoDescender:he.descender,sTypoLineGap:0,usWinAscent:he.yMax,usWinDescent:Math.abs(he.yMin),ulCodePageRange1:1,sxHeight:dt(i,"xyvw",{yMax:Math.round(he.ascender/2)}).yMax,sCapHeight:dt(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",he).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0},i.tables.os2)),sn=js.make(i.glyphs),On=Mr.make(i.glyphs),Yn=i.getEnglishName("fontFamily"),Zn=i.getEnglishName("fontSubfamily"),Ps=Yn+" "+Zn,Ro=i.getEnglishName("postScriptName");Ro||(Ro=Yn.replace(/\s/g,"")+"-"+Zn);let an={};for(let ts in i.names)an[ts]=i.names[ts];an.unicode=an.unicode||{},an.macintosh=an.macintosh||{},an.windows=an.windows||{};let Pa=i.names.unicode||{},ea=i.names.macintosh||{},gr=i.names.windows||{};for(let ts in an){if(an[ts]=an[ts]||{},!an[ts].uniqueID){let wa=i.getEnglishName("manufacturer")||"";an[ts].uniqueID={en:`${wa}: ${Ps}`}}an[ts].postScriptName||(an[ts].postScriptName={en:Ro})}an.unicode.preferredFamily||(an.unicode.preferredFamily=Pa.fontFamily||ea.fontFamily||gr.fontFamily),an.macintosh.preferredFamily||(an.macintosh.preferredFamily=ea.fontFamily||Pa.fontFamily||gr.fontFamily),an.windows.preferredFamily||(an.windows.preferredFamily=gr.fontFamily||Pa.fontFamily||ea.fontFamily),an.unicode.preferredSubfamily||(an.unicode.preferredSubfamily=Pa.fontSubfamily||ea.fontSubfamily||gr.fontSubfamily),an.macintosh.preferredSubfamily||(an.macintosh.preferredSubfamily=ea.fontSubfamily||Pa.fontSubfamily||gr.fontSubfamily),an.windows.preferredSubfamily||(an.windows.preferredSubfamily=gr.fontSubfamily||Pa.fontSubfamily||ea.fontSubfamily);let sr=[],ar=jt.make(an,sr),Pi=sr.length>0?bi.make(sr):void 0,Kl=Dl.make(i),K0=as.make(i.glyphs,{version:i.getEnglishName("version"),fullName:Ps,familyName:Yn,weightName:Zn,postScriptName:Ro,unitsPerEm:i.unitsPerEm,fontBBox:[0,he.yMin,he.ascender,he.advanceWidthMax],topDict:i.tables.cff&&i.tables.cff.topDict||{}}),wc=i.metas&&Object.keys(i.metas).length>0?Ws.make(i.metas):void 0,Mo=[ut,mr,lr,Rr,ar,On,Kl,K0,sn];Pi&&Mo.push(Pi);let ta={gsub:Mi,cpal:Jn,colr:qi,stat:As,avar:xa,cvar:ba,fvar:ni,gvar:Zi,gasp:T,svg:F},so={avar:[i.tables.fvar],fvar:[i.names]};for(let ts in ta){let wa=i.tables[ts];if(wa){let io=ta[ts].make.call(i,wa,...so[ts]||[]);io&&Mo.push(io)}}wc&&Mo.push(wc);let Oi=Xe(Mo),Oa=Oi.encode(),ra=Se(Oa),na=Oi.fields,Ns=!1;for(let ts=0;ts<na.length;ts+=1)if(na[ts].name==="head table"){na[ts].value.checkSumAdjustment=2981146554-ra,Ns=!0;break}if(!Ns)throw new Error("Could not find head table with checkSum to adjust.");return Oi}var $r={make:Xe,fontToTable:or,computeCheckSum:Se};function nn(i,o){let u=0,h=i.length-1;for(;u<=h;){let p=u+h>>>1,g=i[p].tag;if(g===o)return p;g<o?u=p+1:h=p-1}return-u-1}function Pn(i,o){let u=0,h=i.length-1;for(;u<=h;){let p=u+h>>>1,g=i[p];if(g===o)return p;g<o?u=p+1:h=p-1}return-u-1}function yr(i,o){let u,h=0,p=i.length-1;for(;h<=p;){let g=h+p>>>1;u=i[g];let A=u.start;if(A===o)return u;A<o?h=g+1:p=g-1}if(h>0)return u=i[h-1],o>u.end?0:u}function wn(i,o){this.font=i,this.tableName=o}wn.prototype={searchTag:nn,binSearch:Pn,getTable:function(i){let o=this.font.tables[this.tableName];return!o&&i&&(o=this.font.tables[this.tableName]=this.createDefaultTable()),o},getScriptNames:function(){let i=this.getTable();return i?i.scripts.map(function(o){return o.tag}):[]},getDefaultScriptName:function(){let i=this.getTable();if(!i)return;let o=!1;for(let u=0;u<i.scripts.length;u++){let h=i.scripts[u].tag;if(h==="DFLT")return h;h==="latn"&&(o=!0)}if(o)return"latn"},getScriptTable:function(i,o){let u=this.getTable(o);if(u){i=i||"DFLT";let h=u.scripts,p=nn(u.scripts,i);if(p>=0)return h[p].script;if(o){let g={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-p,0,g),g.script}}},getLangSysTable:function(i,o,u){let h=this.getScriptTable(i,u);if(h){if(!o||o==="dflt"||o==="DFLT")return h.defaultLangSys;let p=nn(h.langSysRecords,o);if(p>=0)return h.langSysRecords[p].langSys;if(u){let g={tag:o,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-p,0,g),g.langSys}}},getFeatureTable:function(i,o,u,h){let p=this.getLangSysTable(i,o,h);if(p){let g,A=p.featureIndexes,k=this.font.tables[this.tableName].features;for(let E=0;E<A.length;E++)if(g=k[A[E]],g.tag===u)return g.feature;if(h){let E=k.length;return ue.assert(E===0||u>=k[E-1].tag,"Features must be added in alphabetical order."),g={tag:u,feature:{params:0,lookupListIndexes:[]}},k.push(g),A.push(E),g.feature}}},getLookupTables:function(i,o,u,h,p){let g=this.getFeatureTable(i,o,u,p),A=[];if(g){let k,E=g.lookupListIndexes,D=this.font.tables[this.tableName].lookups;for(let M=0;M<E.length;M++)k=D[E[M]],k.lookupType===h&&A.push(k);if(A.length===0&&p){k={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let M=D.length;return D.push(k),E.push(M),[k]}}return A},getGlyphClass:function(i,o){switch(i.format){case 1:return i.startGlyph<=o&&o<i.startGlyph+i.classes.length?i.classes[o-i.startGlyph]:0;case 2:{let u=yr(i.ranges,o);return u?u.classId:0}}},getCoverageIndex:function(i,o){switch(i.format){case 1:{let u=Pn(i.glyphs,o);return u>=0?u:-1}case 2:{let u=yr(i.ranges,o);return u?u.index+o-u.start:-1}}},expandCoverage:function(i){if(i.format===1)return i.glyphs;{let o=[],u=i.ranges;for(let h=0;h<u.length;h++){let p=u[h],g=p.start,A=p.end;for(let k=g;k<=A;k++)o.push(k)}return o}}};var us=wn;function Bs(i){us.call(this,i,"gpos")}Bs.prototype=us.prototype,Bs.prototype.init=function(){let i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},Bs.prototype.getKerningValue=function(i,o,u){for(let h=0;h<i.length;h++){let p=i[h].subtables;for(let g=0;g<p.length;g++){let A=p[g],k=this.getCoverageIndex(A.coverage,o);if(!(k<0))switch(A.posFormat){case 1:{let E=A.pairSets[k];for(let D=0;D<E.length;D++){let M=E[D];if(M.secondGlyph===u)return M.value1&&M.value1.xAdvance||0}break}case 2:{let E=this.getGlyphClass(A.classDef1,o),D=this.getGlyphClass(A.classDef2,u),M=A.classRecords[E][D];return M.value1&&M.value1.xAdvance||0}}}}return 0},Bs.prototype.getKerningTables=function(i,o){if(this.font.tables.gpos)return this.getLookupTables(i,o,"kern",2)};var pc=Bs;function Vs(i,o){let u=i.length;if(u!==o.length)return!1;for(let h=0;h<u;h++)if(i[h]!==o[h])return!1;return!0}function Ki(i,o,u){let h=0,p=i.length-1,g=null;for(;h<=p;){let A=Math.floor((h+p)/2),k=i[A],E=k[o];if(E<u)h=A+1;else if(E>u)p=A-1;else{g=k;break}}return g}function _o(i,o,u){let h=0,p=i.length-1;for(;h<=p;){let g=Math.floor((h+p)/2),A=i[g];if(A[o]<u)h=g+1;else if(A[o]>u)p=g-1;else return g}return-1}function yi(i,o,u){let h=0,p=i.length,g=(A,k)=>A[o]-k[o];for(;h<p;){let A=h+p>>>1;g(i[A],u)<0?h=A+1:p=A}return i.splice(h,0,u),h}function ko(i){return i[0]===31&&i[1]===139&&i[2]===8}function tu(i){let o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=10,h=i.byteLength-8,p=o.getInt8(3);if(p&4&&(u+=2+o.getUint16(u,!0)),p&8)for(;u<h&&i[u++]!==0;);if(p&16)for(;u<h&&i[u++]!==0;);if(p&2&&(u+=2),u>=h)throw new Error("Can't find compressed blocks");let g=o.getUint32(o.byteLength-4,!0);return ve(i.subarray(u,h),new Uint8Array(g))}function vi(i){return{x:i.x,y:i.y,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour}}function F0(i){return{glyphIndex:i.glyphIndex,xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:i.dx,dy:i.dy}}function wi(i){us.call(this,i,"gsub")}function rd(i,o,u){let h=i.subtables;for(let p=0;p<h.length;p++){let g=h[p];if(g.substFormat===o)return g}if(u)return h.push(u),u}wi.prototype=us.prototype,wi.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},wi.prototype.getSingle=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,1);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],D=this.expandCoverage(E.coverage),M;if(E.substFormat===1){let te=E.deltaGlyphId;for(M=0;M<D.length;M++){let J=D[M];h.push({sub:J,by:J+te})}}else{let te=E.substitute;for(M=0;M<D.length;M++)h.push({sub:D[M],by:te[M]})}}}return h},wi.prototype.getMultiple=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,2);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],D=this.expandCoverage(E.coverage),M;for(M=0;M<D.length;M++){let te=D[M],J=E.sequences[M];h.push({sub:te,by:J})}}}return h},wi.prototype.getAlternates=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,3);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],D=this.expandCoverage(E.coverage),M=E.alternateSets;for(let te=0;te<D.length;te++)h.push({sub:D[te],by:M[te]})}}return h},wi.prototype.getLigatures=function(i,o,u){let h=[],p=this.getLookupTables(o,u,i,4);for(let g=0;g<p.length;g++){let A=p[g].subtables;for(let k=0;k<A.length;k++){let E=A[k],D=this.expandCoverage(E.coverage),M=E.ligatureSets;for(let te=0;te<D.length;te++){let J=D[te],Te=M[te];for(let he=0;he<Te.length;he++){let Me=Te[he];h.push({sub:[J].concat(Me.components),by:Me.ligGlyph})}}}}return h},wi.prototype.addSingle=function(i,o,u,h){let p=this.getLookupTables(u,h,i,1,!0)[0],g=rd(p,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,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.substitute.splice(k,0,0)),g.substitute[k]=o.by},wi.prototype.addMultiple=function(i,o,u,h){ue.assert(o.by instanceof Array&&o.by.length>1,'Multiple: "by" must be an array of two or more ids');let p=this.getLookupTables(u,h,i,2,!0)[0],g=rd(p,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,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.sequences.splice(k,0,0)),g.sequences[k]=o.by},wi.prototype.addAlternate=function(i,o,u,h){let p=this.getLookupTables(u,h,i,3,!0)[0],g=rd(p,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,k=this.binSearch(g.coverage.glyphs,A);k<0&&(k=-1-k,g.coverage.glyphs.splice(k,0,A),g.alternateSets.splice(k,0,0)),g.alternateSets[k]=o.by},wi.prototype.addLigature=function(i,o,u,h){let p=this.getLookupTables(u,h,i,4,!0)[0],g=p.subtables[0];g||(g={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},p.subtables[0]=g),ue.assert(g.coverage.format===1,"Ligature: unable to modify coverage table format "+g.coverage.format);let A=o.sub[0],k=o.sub.slice(1),E={ligGlyph:o.by,components:k},D=this.binSearch(g.coverage.glyphs,A);if(D>=0){let M=g.ligatureSets[D];for(let te=0;te<M.length;te++)if(Vs(M[te].components,k))return;M.push(E)}else D=-1-D,g.coverage.glyphs.splice(D,0,A),g.ligatureSets.splice(D,0,[E])},wi.prototype.getFeature=function(i,o,u){if(/ss\d\d/.test(i))return this.getSingle(i,o,u);switch(i){case"aalt":case"salt":return this.getSingle(i,o,u).concat(this.getAlternates(i,o,u));case"dlig":case"liga":case"rlig":return this.getLigatures(i,o,u);case"ccmp":return this.getMultiple(i,o,u).concat(this.getLigatures(i,o,u));case"stch":return this.getMultiple(i,o,u)}},wi.prototype.add=function(i,o,u,h){if(/ss\d\d/.test(i))return this.addSingle(i,o,u,h);switch(i){case"aalt":case"salt":return typeof o.by=="number"?this.addSingle(i,o,u,h):this.addAlternate(i,o,u,h);case"dlig":case"liga":case"rlig":return this.addLigature(i,o,u,h);case"ccmp":return o.by instanceof Array?this.addMultiple(i,o,u,h):this.addLigature(i,o,u,h)}};var eo=wi,ya=class{constructor(i){this.defaultValue=255,this.font=i}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(i){let o=[],u=this.cpal();if(!u)return o;for(let h=0;h<u.colorRecordIndices.length;h++){let p=u.colorRecordIndices[h],g=[];for(let A=p;A<p+u.numPaletteEntries;A++)g.push(gn(u.colorRecords[A],i||"hexa"));o.push(g)}return o}toCPALcolor(i){return Array.isArray(i)?i.map(o=>Vn(o,"raw")):Vn(i,"raw")}fillPalette(i,o=[],u=this.cpal().numPaletteEntries){return i=Number.isInteger(i)?this.get(i,"raw"):i,Object.assign(Array(u).fill(this.defaultValue),this.toCPALcolor(i).concat(this.toCPALcolor(o)))}extend(i){if(this.ensureCPAL(Array(i).fill(this.defaultValue)))return;let o=this.cpal(),u=o.numPaletteEntries+i,h=this.getAll().map(p=>this.fillPalette(p,[],u));o.numPaletteEntries=u,o.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(i,o="hexa"){return this.getAll(o)[i]||null}getColor(i,o=0,u="hexa"){return cn(this.font,i,o,u)}setColor(i,o,u=0){i=parseInt(i),u=parseInt(u);let h=this.getAll("raw"),p=h[u];if(!p)throw Error(`paletteIndex ${u} out of range`);let g=this.cpal(),A=g.numPaletteEntries;Array.isArray(o)||(o=[o]),o.length+i>A&&(this.extend(o.length+i-A),h=this.getAll("raw"),p=h[u]);for(let k=0;k<o.length;k++)p[k+i]=this.toCPALcolor(o[k]);g.colorRecords=h.flat(),this.updateIndices()}add(i){if(this.ensureCPAL(i))return;let o=this.cpal(),u=o.numPaletteEntries;i&&i.length?(i=this.toCPALcolor(i),i.length>u?this.extend(i.length-u):i.length<u&&(i=this.fillPalette(i)),o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...i)):(o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...Array(u).fill(this.defaultValue)))}delete(i){let o=this.getAll("raw");delete o[i];let u=this.cpal();u.colorRecordIndices.pop(),u.colorRecords=o.flat()}deleteColor(i,o){if(i===o)throw Error("replacementIndex cannot be the same as colorIndex");let u=this.cpal(),h=this.getAll("raw"),p=[];if(o>u.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${u.numPaletteEntries-1}, replacementIndex: ${o})`);for(let k=0;k<h.length;k++){let E=h[k].filter((D,M)=>M!==i);p.push(E)}let g=this.font.tables.colr;if(g){let k=g.layerRecords;for(let E=0;E<k.length;E++){let D=k[E].paletteIndex;if(D>i)k[E].paletteIndex-=1;else if(D===i){let M=0;for(let te=0;te<h.length;te++)if(o>i&&o<=i+h[te].length){M++;break}k[E].paletteIndex=o-M}}this.font.tables.colr={...g,layerRecords:k}}let A=p.flat();for(let k=0;k<h.length;k++)u.colorRecordIndices[k]-=k;u.numPaletteEntries=Math.max(0,u.numPaletteEntries-1),u.colorRecords=this.toCPALcolor(A)}ensureCPAL(i){return this.cpal()?!1:(!i||!i.length?i=[this.defaultValue]:i=this.toCPALcolor(i),this.font.tables.cpal={version:0,numPaletteEntries:i.length,colorRecords:i,colorRecordIndices:[0]},!0)}updateIndices(){let i=this.cpal(),o=Math.ceil(i.colorRecords.length/i.numPaletteEntries);i.colorRecordIndices=[];for(let u=0;u<o;u++)i.colorRecordIndices.push(u*i.numPaletteEntries)}},Pl=class{constructor(i){this.font=i}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(i){let o=this.font,u=[],h=o.tables.colr,p=o.tables.cpal;if(!h||!p)return u;let g=Ki(h.baseGlyphRecords,"glyphID",i);if(!g)return u;let A=g.firstLayerIndex,k=g.numLayers;for(let E=0;E<k;E++){let D=h.layerRecords[A+E];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 p=[];for(let g=0;g<u;g++){let A=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;p.push({glyphID:A,paletteIndex:h[g].paletteIndex})}for(let g of o){let A=Number.isInteger(g.glyph)?g.glyph:g.glyph.index;p.push({glyphID:A,paletteIndex:g.paletteIndex})}for(let g=u;g<h.length;g++){let A=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;p.push({glyphID:A,paletteIndex:h[g].paletteIndex})}this.updateColrTable(i,p)}setPaletteIndex(i,o,u){let h=this.get(i);h[o]?(h=h.map((p,g)=>({glyphID:p.glyph.index,paletteIndex:g===o?u:p.paletteIndex})),this.updateColrTable(i,h)):console.error("Invalid layer index")}remove(i,o,u=o){let h=this.get(i);h=h.map(p=>({glyphID:p.glyph.index,paletteIndex:p.paletteIndex})),h.splice(o,u-o+1),this.updateColrTable(i,h)}updateColrTable(i,o){this.ensureCOLR();let u=this.font.tables.colr,h=_o(u.baseGlyphRecords,"glyphID",i);if(h===-1){let E={glyphID:i,firstLayerIndex:u.layerRecords.length,numLayers:0};h=yi(u.baseGlyphRecords,"glyphID",E)}let p=u.baseGlyphRecords[h],g=p.numLayers,A=o.length,k=A-g;if(k>0){let E=o.slice(g).map(D=>({glyphID:D.glyphID,paletteIndex:D.paletteIndex}));u.layerRecords.splice(p.firstLayerIndex+g,0,...E)}else k<0&&u.layerRecords.splice(p.firstLayerIndex+A,-k);for(let E=0;E<Math.min(g,A);E++)u.layerRecords[p.firstLayerIndex+E]={glyphID:o[E].glyphID,paletteIndex:o[E].paletteIndex};if(p.numLayers=A,k!==0)for(let E=0;E<u.baseGlyphRecords.length;E++){let D=u.baseGlyphRecords[E];E===h||D.firstLayerIndex<p.firstLayerIndex||(u.baseGlyphRecords[E].firstLayerIndex+=k)}}},ru=class{constructor(i){this.font=i,this.cache=new WeakMap}get(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.image}getAsync(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.promise}getOrCreateSvgImageCacheEntry(i){let o=this.font.tables.svg;if(o===void 0)return;let u=o.get(i);if(u===void 0)return;let h=this.cache.get(u);h===void 0&&(h=lp(u),this.cache.set(u,h));let p=h.images.get(i);return p===void 0&&(p=cp(this.font,h.template,i),p.promise.then(g=>{if(p.image=g,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(i)}catch(A){console.error("font.onGlyphUpdated",i,A)}}),h.images.set(i,p)),p}};function lp(i){return{template:up(i).then(nu),images:new Map}}function cp(i,o,u){return{promise:o.then(h=>{let p;typeof h=="string"?p=h:(h[4]=u,p=h.join(""));let g=$0(p,i.unitsPerEm);return g.image.decode().then(()=>g)}),image:void 0}}var up=typeof DecompressionStream=="function"?nd:dp;function dp(i){try{return Promise.resolve(new TextDecoder().decode(ko(i)?tu(i):i))}catch(o){return Promise.reject(o)}}function nd(i){if(ko(i))return new Response(new Response(i).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(i))}catch(o){return Promise.reject(o)}}function nu(i){let o=i.indexOf("<svg"),u=i.indexOf(">",o+4)+1;if(/ id=['"]glyph\d+['"]/.test(i.substring(o,u)))return i;let h=i.lastIndexOf("</svg>");return[i.substring(0,u),"<defs>",i.substring(u,h),'</defs><use href="#glyph',"",'"/>',i.substring(h)]}function $0(i,o){let u=new DOMParser().parseFromString(i,"image/svg+xml").documentElement,h=u.viewBox.baseVal,p=u.width.baseVal,g=u.height.baseVal,A=1,k=1;h.width>0&&h.height>0&&(p.unitType===1?(A=p.valueInSpecifiedUnits/h.width,k=g.unitType===1?g.valueInSpecifiedUnits/h.height:A):g.unitType===1?(k=g.valueInSpecifiedUnits/h.height,A=k):o&&(A=o/h.width,k=o/h.height));let E=document.createElement("div");E.style.position="fixed",E.style.visibility="hidden",E.appendChild(u),document.body.appendChild(E);let D=u.getBBox();document.body.removeChild(E);let M=(D.x-h.x)*A,te=(h.y-D.y)*k,J=D.width*A,Te=D.height*k;u.setAttribute("viewBox",[D.x,D.y,D.width,D.height].join(" ")),A!==1&&u.setAttribute("width",J),k!==1&&u.setAttribute("height",Te);let he=new Image(J,Te);return he.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u.outerHTML),{leftSideBearing:M,baseline:te,image:he}}var ja=new WeakMap;function Vo(i,o,u,h,p){let g;return(o&h)>0?(g=i.parseByte(),(o&p)===0&&(g=-g),g=u+g):(o&p)>0?g=u:g=u+i.parseShort(),g}function mc(i,o,u){let h=new ot.Parser(o,u);i._numberOfContours=h.parseShort(),i._xMin=h.parseShort(),i._yMin=h.parseShort(),i._xMax=h.parseShort(),i._yMax=h.parseShort();let p,g;if(i._numberOfContours>0){let A=i.endPointIndices=[];for(let E=0;E<i._numberOfContours;E+=1)A.push(h.parseUShort());i.instructionLength=h.parseUShort(),i.instructions=[];for(let E=0;E<i.instructionLength;E+=1)i.instructions.push(h.parseByte());let k=A[A.length-1]+1;p=[];for(let E=0;E<k;E+=1)if(g=h.parseByte(),p.push(g),(g&8)>0){let D=h.parseByte();for(let M=0;M<D;M+=1)p.push(g),E+=1}if(ue.argument(p.length===k,"Bad flags."),A.length>0){let E=[],D;if(k>0){for(let J=0;J<k;J+=1)g=p[J],D={},D.onCurve=!!(g&1),D.lastPointOfContour=A.indexOf(J)>=0,E.push(D);let M=0;for(let J=0;J<k;J+=1)g=p[J],D=E[J],D.x=Vo(h,g,M,2,16),M=D.x;let te=0;for(let J=0;J<k;J+=1)g=p[J],D=E[J],D.y=Vo(h,g,te,4,32),te=D.y}i.points=E}else i.points=[]}else if(i._numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let A=!0;for(;A;){p=h.parseUShort();let k={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(p&1)>0?(p&2)>0?(k.dx=h.parseShort(),k.dy=h.parseShort()):k.matchedPoints=[h.parseUShort(),h.parseUShort()]:(p&2)>0?(k.dx=h.parseChar(),k.dy=h.parseChar()):k.matchedPoints=[h.parseByte(),h.parseByte()],(p&8)>0?k.xScale=k.yScale=h.parseF2Dot14():(p&64)>0?(k.xScale=h.parseF2Dot14(),k.yScale=h.parseF2Dot14()):(p&128)>0&&(k.xScale=h.parseF2Dot14(),k.scale01=h.parseF2Dot14(),k.scale10=h.parseF2Dot14(),k.yScale=h.parseF2Dot14()),i.components.push(k),A=!!(p&32)}if(p&256){i.instructionLength=h.parseUShort(),i.instructions=[];for(let k=0;k<i.instructionLength;k+=1)i.instructions.push(h.parseByte())}}}function su(i,o){let u=[];for(let h=0;h<i.length;h+=1){let p=i[h],g={x:o.xScale*p.x+o.scale10*p.y+o.dx,y:o.scale01*p.x+o.yScale*p.y+o.dy,onCurve:p.onCurve,lastPointOfContour:p.lastPointOfContour};u.push(g)}return u}function gc(i){let o=[],u=[];for(let h=0;h<i.length;h+=1){let p=i[h];u.push(p),p.lastPointOfContour&&(o.push(u),u=[])}return ue.argument(u.length===0,"There are still points left in the current contour."),o}function iu(i){let o=new We;if(!i)return o;let u=gc(i);for(let h=0;h<u.length;++h){let p=u[h],g=p[p.length-1],A=p[0];if(g.onCurve)o.moveTo(g.x,g.y);else if(A.onCurve)o.moveTo(A.x,A.y);else{let k={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5};o.moveTo(k.x,k.y)}for(let k=0;k<p.length;++k)if(g=A,A=p[(k+1)%p.length],g.onCurve)o.lineTo(g.x,g.y);else{let E=A;A.onCurve||(E={x:(g.x+A.x)*.5,y:(g.y+A.y)*.5}),o.quadraticCurveTo(g.x,g.y,E.x,E.y)}o.closePath()}return o}function sd(i,o){if(o.isComposite){ja.has(i)||ja.set(i,new Set);let u=ja.get(i);u.add(o.index);try{for(let h=0;h<o.components.length;h+=1){let p=o.components[h];if(u.has(p.glyphIndex))continue;let g=i.get(p.glyphIndex);if(g.getPath(),g.points){let A;if(p.matchedPoints===void 0)A=su(g.points,p);else{if(p.matchedPoints[0]>o.points.length-1||p.matchedPoints[1]>g.points.length-1)throw Error("Matched points out of range in "+o.name);let k=o.points[p.matchedPoints[0]],E=g.points[p.matchedPoints[1]],D={xScale:p.xScale,scale01:p.scale01,scale10:p.scale10,yScale:p.yScale,dx:0,dy:0};E=su([E],D)[0],D.dx=k.x-E.x,D.dy=k.y-E.y,A=su(g.points,D)}o.points=o.points.concat(A)}}}finally{u.delete(o.index)}}return iu(o.points)}function U0(i,o,u,h){let p=new Wr.GlyphSet(h);for(let g=0;g<u.length-1;g+=1){let A=u[g],k=u[g+1];A!==k?p.push(g,Wr.ttfGlyphLoader(h,g,mc,i,o+A,sd)):p.push(g,Wr.glyphLoader(h,g))}return p}function z0(i,o,u,h){let p=new Wr.GlyphSet(h);return h._push=function(g){let A=u[g],k=u[g+1];A!==k?p.push(g,Wr.ttfGlyphLoader(h,g,mc,i,o+A,sd)):p.push(g,Wr.glyphLoader(h,g))},p}function H0(i,o,u,h,p){return p.lowMemory?z0(i,o,u,h):U0(i,o,u,h)}var Ol={getPath:iu,parse:H0},to=class{constructor(i){this.font=i}normalizeCoordTags(i){for(let o in i)if(o.length<4){let u=o.padEnd(4," ");i[u]===void 0&&(i[u]=i[o]),delete i[o]}}getNormalizedCoords(i){i||(i=this.font.variation.get());let o=[];this.normalizeCoordTags(i);for(let u=0;u<this.fvar().axes.length;u++){let h=this.fvar().axes[u],p=i[h.tag];p===void 0&&(p=h.defaultValue),p<h.defaultValue?o.push((p-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):o.push((p-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let u=0;u<this.avar().axisSegmentMaps.length;u++){let h=this.avar().axisSegmentMaps[u];for(let p=0;p<h.axisValueMaps.length;p++){let g=h.axisValueMaps[p];if(p>=1&&o[u]<g.fromCoordinate){let A=h.axisValueMaps[p-1];o[u]=((o[u]-A.fromCoordinate)*(g.toCoordinate-A.toCoordinate)+Number.EPSILON)/(g.fromCoordinate-A.fromCoordinate+Number.EPSILON)+A.toCoordinate;break}}}return o}interpolatePoints(i,o,u){if(i.length===0)return;let h=0;for(;h<i.length;){let p=h,g=h,A=i[g];for(;!A.lastPointOfContour;)A=i[++g];for(;h<=g&&!u[h];)h++;if(h>g)continue;let k=h,E=h;for(h++;h<=g;)u[h]&&(this.deltaInterpolate(E+1,h-1,E,h,o,i),E=h),h++;E===k?this.deltaShift(p,g,E,o,i):(this.deltaInterpolate(E+1,g,E,k,o,i),k>0&&this.deltaInterpolate(p,k-1,E,k,o,i)),h=g+1}}deltaInterpolate(i,o,u,h,p,g){if(i>o)return;let A=["x","y"];for(let E=0;E<A.length;E++){let D=A[E];if(p[u][D]>p[h][D]){var k=u;u=h,h=k}let M=p[u][D],te=p[h][D],J=g[u][D],Te=g[h][D];if(M!==te||J===Te){let he=M===te?0:(Te-J)/(te-M);for(let Me=i;Me<=o;Me++){let ut=p[Me][D];ut<=M?ut+=J-M:ut>=te?ut+=Te-te:ut=J+(ut-M)*he,g[Me][D]=ut}}}}deltaShift(i,o,u,h,p){let g=p[u].x-h[u].x,A=p[u].y-h[u].y;if(!(g===0&&A===0))for(let k=i;k<=o;k++)k!==u&&(p[k].x+=g,p[k].y+=A)}transformComponents(i,o,u,h,p,g){let A=0;for(let k=0;k<i.components.length;k++){let E=i.components[k],D=this.font.glyphs.get(E.glyphIndex),M=F0(E),te=h.indexOf(k);te>-1&&(M.dx+=Math.round(p.deltas[te]*g),M.dy+=Math.round(p.deltasY[te]*g));let J=su(this.getTransform(D,u).points,M);o.splice(A,J.length,...J),A+=D.points.length}}applyTupleVariationStore(i,o,u,h="gvar",p={}){u||(u=this.font.variation.get());let g=this.getNormalizedCoords(u),{headers:A,sharedPoints:k}=i,E=this.fvar().axes.length,D;h==="gvar"?D=o.map(vi):h==="cvar"&&(D=[...o]);for(let M=0;M<A.length;M++){let te=A[M],J=1;for(let he=0;he<E;he++){let Me=[0];switch(h){case"gvar":Me=te.peakTuple?te.peakTuple:this.gvar().sharedTuples[te.sharedTupleRecordsIndex];break;case"cvar":Me=te.peakTuple;break}if(Me[he]!==0){if(g[he]===0){J=0;break}if(te.intermediateStartTuple)if(g[he]<te.intermediateStartTuple[he]||g[he]>te.intermediateEndTuple[he]){J=0;break}else g[he]<Me[he]?J=J*(g[he]-te.intermediateStartTuple[he]+Number.EPSILON)/(Me[he]-te.intermediateStartTuple[he]+Number.EPSILON):J=J*(te.intermediateEndTuple[he]-g[he]+Number.EPSILON)/(te.intermediateEndTuple[he]-Me[he]+Number.EPSILON);else{if(g[he]<Math.min(0,Me[he])||g[he]>Math.max(0,Me[he])){J=0;break}J=(J*g[he]+Number.EPSILON)/(Me[he]+Number.EPSILON)}}}if(J===0)continue;let Te=te.privatePoints.length?te.privatePoints:k;if(h==="gvar"&&p.glyph&&p.glyph.isComposite)this.transformComponents(p.glyph,D,u,Te,te,J);else if(Te.length===0)for(let he=0;he<D.length;he++){let Me=D[he];h==="gvar"?D[he]={x:Math.round(Me.x+te.deltas[he]*J),y:Math.round(Me.y+te.deltasY[he]*J),onCurve:Me.onCurve,lastPointOfContour:Me.lastPointOfContour}:h==="cvar"&&(D[he]=Math.round(Me+te.deltas[he]*J))}else{let he;h==="gvar"?he=D.map(vi):h==="cvar"&&(he=D);let Me=Array(o.length).fill(!1);for(let ut=0;ut<Te.length;ut++){let mr=Te[ut];if(mr<o.length){let lr=he[mr];h==="gvar"?(Me[mr]=!0,lr.x+=te.deltas[ut]*J,lr.y+=te.deltasY[ut]*J):h==="cvar"&&(D[mr]=Math.round(lr+te.deltas[ut]*J))}}if(h==="gvar"){this.interpolatePoints(he,D,Me);for(let ut=0;ut<o.length;ut++){let mr=he[ut].x-D[ut].x,lr=he[ut].y-D[ut].y;D[ut].x=Math.round(D[ut].x+mr),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),p=i;if(u||h){if(o||(o=this.font.variation.get()),h){let g=this.gvar()&&this.gvar().glyphVariations[i.index];if(g){let A=i.points,k=this.applyTupleVariationStore(g,A,o,"gvar",{glyph:i});p=new pr(Object.assign({},i,{points:k,path:iu(k)}))}}else if(u){let g=i.getBlendPath(o);p=new pr(Object.assign({},i,{path:g}))}}return this.font.tables.hvar&&(i._advanceWidth=typeof i._advanceWidth<"u"?i._advanceWidth:i.advanceWidth,i.advanceWidth=p.advanceWidth=Math.round(i._advanceWidth+this.getVariableAdjustment(p.index,"hvar","advanceWidth",o)),i._leftSideBearing=typeof i._leftSideBearing<"u"?i._leftSideBearing:i.leftSideBearing,i.leftSideBearing=p.leftSideBearing=Math.round(i._leftSideBearing+this.getVariableAdjustment(p.index,"hvar","lsb",o))),p}getCvarTransform(i){let o=this.font.tables.cvt,u=this.cvar();return!o||!o.length||!u||!u.headers.length?o:this.applyTupleVariationStore(u,o,i,"cvar")}getVariableAdjustment(i,o,u,h){h=h||this.font.variation.get();let p,g,A=this.font.tables[o];if(!A)throw Error(`trying to get variation adjustment from non-existent table "${A}"`);if(!A.itemVariationStore)throw Error(`trying to get variation adjustment from table "${A}" which does not have an itemVariationStore`);let k=A[u]&&A[u].map.length;if(k){let E=i;E>=k&&(E=k-1),{outerIndex:p,innerIndex:g}=A[u].map[E]}else p=0,g=i;return this.getDelta(A.itemVariationStore,p,g,h)}getDelta(i,o,u,h){if(o>=i.itemVariationSubtables.length)return 0;let p=i.itemVariationSubtables[o];if(u>=p.deltaSets.length)return 0;let g=p.deltaSets[u],A=this.getBlendVector(i,o,h),k=0;for(let E=0;E<p.regionIndexes.length;E++)k+=g[E]*A[E];return k}getBlendVector(i,o,u){u||(u=this.font.variation.get());let h=i.itemVariationSubtables[o],p=this.getNormalizedCoords(u),g=[];for(let A=0;A<h.regionIndexes.length;A++){let k=1,E=h.regionIndexes[A],D=i.variationRegions[E].regionAxes;for(let M=0;M<D.length;M++){let te=D[M],J;te.startCoord>te.peakCoord||te.peakCoord>te.endCoord||te.startCoord<0&&te.endCoord>0&&te.peakCoord!==0||te.peakCoord===0?J=1:p[M]<te.startCoord||p[M]>te.endCoord?J=0:p[M]===te.peakCoord?J=1:p[M]<te.peakCoord?J=(p[M]-te.startCoord+Number.EPSILON)/(te.peakCoord-te.startCoord+Number.EPSILON):J=(te.endCoord-p[M]+Number.EPSILON)/(te.endCoord-te.peakCoord+Number.EPSILON),k*=J}g[A]=k}return g}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},id=class{constructor(i){this.font=i,this.process=new to(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let i=this.getDefaultInstanceIndex();i>-1?this.set(i):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((i,o)=>(i[o.tag]=o.defaultValue,i),{})}getDefaultInstanceIndex(){let i=this.getDefaultCoordinates(),o=this.getInstanceIndex(i);return o<0&&(o=this.fvar().instances.findIndex(u=>u.name&&u.name.en==="Regular")),o}getInstanceIndex(i){return this.fvar().instances.findIndex(o=>Object.keys(i).every(u=>o.coordinates[u]===i[u]))}getInstance(i){return this.fvar().instances&&this.fvar().instances[i]}set(i){let o;if(Number.isInteger(i)){let u=this.getInstance(i);if(!u)throw Error(`Invalid instance index ${i}`);o={...u.coordinates}}else o=i,this.process.normalizeCoordTags(o);o=Object.assign({},this.font.defaultRenderOptions.variation,o),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:o})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},W0=1e6,xc=64,Fl=1e4,au,xl,ad,bc;function od(i){this.font=i,this.getCommands=function(o){return Ol.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function va(i){return i}function $l(i){return Math.sign(i)*Math.round(Math.abs(i))}function ld(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function yc(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function Ul(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function Qs(i){return Math.sign(i)*Math.floor(Math.abs(i))}var G0=function(i){let o=this.srPeriod,u=this.srPhase,h=this.srThreshold,p=1;return i<0&&(i=-i,p=-1),i+=h-u,i=Math.trunc(i/o)*o,i+=u,i<0?u*p:i*p},Da={x:1,y:0,axis:"x",distance:function(i,o,u,h){return(u?i.xo:i.x)-(h?o.xo:o.x)},interpolate:function(i,o,u,h){let p,g,A,k,E,D,M;if(!h||h===this){if(p=i.xo-o.xo,g=i.xo-u.xo,E=o.x-o.xo,D=u.x-u.xo,A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){i.x=i.xo+(E+D)/2;return}i.x=i.xo+(E*k+D*A)/M;return}if(p=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),E=h.distance(o,o,!1,!0),D=h.distance(u,u,!1,!0),A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){Da.setRelative(i,i,(E+D)/2,h,!0);return}Da.setRelative(i,i,(E*k+D*A)/M,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,o,u,h,p){if(!h||h===this){i.x=(p?o.xo:o.x)+u;return}let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y;i.x=k+(i.y-E)/h.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},Lo={x:0,y:1,axis:"y",distance:function(i,o,u,h){return(u?i.yo:i.y)-(h?o.yo:o.y)},interpolate:function(i,o,u,h){let p,g,A,k,E,D,M;if(!h||h===this){if(p=i.yo-o.yo,g=i.yo-u.yo,E=o.y-o.yo,D=u.y-u.yo,A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){i.y=i.yo+(E+D)/2;return}i.y=i.yo+(E*k+D*A)/M;return}if(p=h.distance(i,o,!0,!0),g=h.distance(i,u,!0,!0),E=h.distance(o,o,!1,!0),D=h.distance(u,u,!1,!0),A=Math.abs(p),k=Math.abs(g),M=A+k,M===0){Lo.setRelative(i,i,(E+D)/2,h,!0);return}Lo.setRelative(i,i,(E*k+D*A)/M,h,!0)},normalSlope:0,setRelative:function(i,o,u,h,p){if(!h||h===this){i.y=(p?o.yo:o.y)+u;return}let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y;i.y=E+h.normalSlope*(i.x-k)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze(Da),Object.freeze(Lo);function zl(i,o){this.x=i,this.y=o,this.axis=void 0,this.slope=o/i,this.normalSlope=-i/o,Object.freeze(this)}zl.prototype.distance=function(i,o,u,h){return this.x*Da.distance(i,o,u,h)+this.y*Lo.distance(i,o,u,h)},zl.prototype.interpolate=function(i,o,u,h){let p,g,A,k,E,D,M;if(A=h.distance(i,o,!0,!0),k=h.distance(i,u,!0,!0),p=h.distance(o,o,!1,!0),g=h.distance(u,u,!1,!0),E=Math.abs(A),D=Math.abs(k),M=E+D,M===0){this.setRelative(i,i,(p+g)/2,h,!0);return}this.setRelative(i,i,(p*D+g*E)/M,h,!0)},zl.prototype.setRelative=function(i,o,u,h,p){h=h||this;let g=p?o.xo:o.x,A=p?o.yo:o.y,k=g+u*h.x,E=A+u*h.y,D=h.normalSlope,M=this.slope,te=i.x,J=i.y;i.x=(M*te-D*k+E-J)/(M-D),i.y=M*(i.x-te)+J},zl.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function Hl(i,o){let u=Math.sqrt(i*i+o*o);return i/=u,o/=u,i===1&&o===0?Da:i===0&&o===1?Lo:new zl(i,o)}function _(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)}_.prototype.nextTouched=function(i){let o=this.nextPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.nextPointOnContour;return o},_.prototype.prevTouched=function(i){let o=this.prevPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.prevPointOnContour;return o};var P=Object.freeze(new _(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=Da,this.round=$l}}od.prototype.exec=function(i,o){if(typeof o!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let u=this.font,h=this._prepState;if(!h||h.ppem!==o){let p=this._fpgmState;if(!p){tt.prototype=de,p=this._fpgmState=new tt("fpgm",u.tables.fpgm),p.funcs=[],p.font=u,p.instructionCount=0,p.callDepth=0;try{xl(p)}catch(A){console.log("Hinting error in FPGM:"+A),this._errorState=3;return}}tt.prototype=p,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),k=o/u.unitsPerEm;for(let E=0;E<g.length;E++)A[E]=g[E]*k}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 ad(i,h)}catch(p){this._errorState<1&&(console.log("Hinting error:"+p),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},ad=function(i,o){let u=o.ppem/o.font.unitsPerEm,h=u,p=i.components,g,A,k;if(tt.prototype=o,!p)k=new tt("glyf",i.instructions),k.instructionCount=0,k.callDepth=0,bc(i,k,u,h),A=k.gZone;else{let E=o.font;A=[],g=[];for(let D=0;D<p.length;D++){let M=p[D],te=E.glyphs.get(M.glyphIndex);k=new tt("glyf",te.instructions),k.instructionCount=0,k.callDepth=0,bc(te,k,u,h);let J=Math.round(M.dx*u),Te=Math.round(M.dy*h),he=k.gZone,Me=k.contours;for(let mr=0;mr<he.length;mr++){let lr=he[mr];lr.xTouched=lr.yTouched=!1,lr.xo=lr.x=lr.x+J,lr.yo=lr.y=lr.y+Te}let ut=A.length;A.push.apply(A,he);for(let mr=0;mr<Me.length;mr++)g.push(Me[mr]+ut)}i.instructions&&!k.inhibitGridFit&&(k=new tt("glyf",i.instructions),k.gZone=k.z0=k.z1=k.z2=A,k.contours=g,A.push(new _(0,0),new _(Math.round(i.advanceWidth*u),0)),xl(k),A.length-=2)}return A},bc=function(i,o,u,h){let p=i.points||[],g=p.length,A=o.gZone=o.z0=o.z1=o.z2=[],k=o.contours=[],E;for(let te=0;te<g;te++)E=p[te],A[te]=new _(E.x*u,E.y*h,E.lastPointOfContour,E.onCurve);let D,M;for(let te=0;te<g;te++)E=A[te],D||(D=E,k.push(te)),E.lastPointOfContour?(E.nextPointOnContour=D,D.prevPointOnContour=E,D=void 0):(M=A[te+1],E.nextPointOnContour=M,M.prevPointOnContour=E);o.inhibitGridFit||(A.push(new _(0,0),new _(Math.round(i.advanceWidth*u),0)),xl(o),A.length-=2)},xl=function(i){let o=i.prog;if(!o)return;let u=o.length,h;for(i.ip=0;i.ip<u;i.ip++){if(++i.instructionCount>W0)throw new Error("Hinting instructions exceeded maximum of "+W0);if(h=au[o[i.ip]],!h)throw new Error("unknown instruction: 0x"+Number(o[i.ip]).toString(16));h(i)}};function St(i){let o=i.tZone=new Array(i.gZone.length);for(let u=0;u<o.length;u++)o[u]=new _(0,0)}function Yt(i,o){let u=i.prog,h=i.ip,p=1,g;do if(g=u[++h],g===88)p++;else if(g===89)p--;else if(g===64)h+=u[h+1]+1;else if(g===65)h+=2*u[h+1]+1;else if(g>=176&&g<=183)h+=g-176+1;else if(g>=184&&g<=191)h+=(g-184+1)*2;else if(o&&p===1&&g===27)break;while(p>0);i.ip=h}function Nr(i,o){o.fv=o.pv=o.dpv=i}function An(i,o){o.pv=o.dpv=i}function Nn(i,o){o.fv=i}function Ln(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.pv=o.dpv=Hl(k,E)}function Ai(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.fv=Hl(k,E)}function Tn(i){let o=i.stack,u=o.pop(),h=o.pop();i.pv=i.dpv=Hl(h,u)}function Xi(i){let o=i.stack,u=o.pop(),h=o.pop();i.fv=Hl(h,u)}function Io(i){let o=i.stack,u=i.pv;o.push(u.x*16384),o.push(u.y*16384)}function Eo(i){let o=i.stack,u=i.fv;o.push(u.x*16384),o.push(u.y*16384)}function Ba(i){i.fv=i.pv}function Qi(i){let o=i.stack,u=o.pop(),h=o.pop(),p=o.pop(),g=o.pop(),A=o.pop(),k=i.z0,E=i.z1,D=k[u],M=k[h],te=E[p],J=E[g],Te=i.z2[A],he=D.x,Me=D.y,ut=M.x,mr=M.y,lr=te.x,Rr=te.y,sn=J.x,On=J.y,Yn=(he-ut)*(Rr-On)-(Me-mr)*(lr-sn),Zn=he*mr-Me*ut,Ps=lr*On-Rr*sn;Te.x=(Zn*(lr-sn)-Ps*(he-ut))/Yn,Te.y=(Zn*(Rr-On)-Ps*(Me-mr))/Yn}function ro(i){i.rp0=i.stack.pop()}function hp(i){i.rp1=i.stack.pop()}function cd(i){i.rp2=i.stack.pop()}function l4(i){let o=i.stack.pop();switch(i.zp0=o,o){case 0:i.tZone||St(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function c4(i){let o=i.stack.pop();switch(i.zp1=o,o){case 0:i.tZone||St(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function u4(i){let o=i.stack.pop();switch(i.zp2=o,o){case 0:i.tZone||St(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function d4(i){let o=i.stack.pop();switch(i.zp0=i.zp1=i.zp2=o,o){case 0:i.tZone||St(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 h4(i){i.loop=i.stack.pop(),i.loop>Fl&&(i.loop=Fl)}function f4(i){i.round=$l}function p4(i){i.round=yc}function m4(i){let o=i.stack.pop();i.minDis=o/64}function g4(i){Yt(i,!1)}function x4(i){let o=i.stack.pop();i.ip+=o-1}function b4(i){let o=i.stack.pop();i.cvCutIn=o/64}function y4(i){let o=i.stack;o.push(o[o.length-1])}function fp(i){i.stack.pop()}function v4(i){i.stack.length=0}function w4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u),o.push(h)}function A4(i){let o=i.stack;o.push(o.length)}function T4(i){let o=i.stack,u=o.pop(),h=o.pop();if(h>Fl&&(h=Fl),++i.callDepth>xc)throw new Error("Hinting call depth exceeded maximum of "+xc);let p=i.ip,g=i.prog;i.prog=i.funcs[u];for(let A=0;A<h;A++)xl(i);i.ip=p,i.prog=g,i.callDepth--}function S4(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 C4(i){let o=i.stack,u=o.pop();o.push(o[o.length-u])}function _4(i){let o=i.stack,u=o.pop();o.push(o.splice(o.length-u,1)[0])}function k4(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");let o=i.stack,u=i.prog,h=i.ip,p=o.pop(),g=h;for(;u[++h]!==45;);i.ip=h,i.funcs[p]=u.slice(g+1,h)}function jg(i,o){let u=o.stack.pop(),h=o.z0[u],p=o.fv,g=o.pv,A=g.distance(h,P);i&&(A=o.round(A)),p.setRelative(h,P,A,g),p.touch(h),o.rp0=o.rp1=u}function Dg(i,o){let u=o.z2,h=u.length-2,p,g,A;for(let k=0;k<h;k++)p=u[k],!i.touched(p)&&(g=p.prevTouched(i),g!==p&&(A=p.nextTouched(i),g===A&&i.setRelative(p,p,i.distance(g,g,!1,!0),i,!0),i.interpolate(p,g,A,i)))}function Bg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=o.loop,E=o.z2;for(;k--;){let D=u.pop(),M=E[D],te=A.distance(p,p,!1,!0);g.setRelative(M,M,te,A),g.touch(M)}o.loop=1}function Qg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=u.pop(),E=o.z2[o.contours[k]],D=E,M=A.distance(p,p,!1,!0);do D!==p&&g.setRelative(D,D,M,A),D=D.nextPointOnContour;while(D!==E)}function Pg(i,o){let u=o.stack,h=i?o.rp1:o.rp2,p=(i?o.z0:o.z1)[h],g=o.fv,A=o.pv,k=u.pop(),E;switch(k){case 0:E=o.tZone;break;case 1:E=o.gZone;break;default:throw new Error("Invalid zone")}let D,M=A.distance(p,p,!1,!0),te=E.length-2;for(let J=0;J<te;J++)D=E[J],g.setRelative(D,D,M,A)}function L4(i){let o=i.stack,u=i.loop,h=i.fv,p=o.pop()/64,g=i.z2;for(;u--;){let A=o.pop(),k=g[A];h.setRelative(k,k,p),h.touch(k)}i.loop=1}function I4(i){let o=i.stack,u=i.rp1,h=i.rp2,p=i.loop,g=i.z0[u],A=i.z1[h],k=i.fv,E=i.dpv,D=i.z2;for(;p--;){let M=o.pop(),te=D[M];k.interpolate(te,g,A,E),k.touch(te)}i.loop=1}function Og(i,o){let u=o.stack,h=u.pop()/64,p=u.pop(),g=o.z1[p],A=o.z0[o.rp0],k=o.fv,E=o.pv;k.setRelative(g,A,h,E),k.touch(g),o.rp1=o.rp0,o.rp2=p,i&&(o.rp0=p)}function E4(i){let o=i.stack,u=i.rp0,h=i.z0[u],p=i.loop,g=i.fv,A=i.pv,k=i.z1;for(;p--;){let E=o.pop(),D=k[E];g.setRelative(D,h,0,A),g.touch(D)}i.loop=1}function N4(i){i.round=ld}function Fg(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z0[p],A=o.fv,k=o.pv,E=o.cvt[h],D=k.distance(g,P);i&&(Math.abs(D-E)<o.cvCutIn&&(D=E),D=o.round(D)),A.setRelative(g,P,D,k),o.zp0===0&&(g.xo=g.x,g.yo=g.y),A.touch(g),o.rp0=o.rp1=p}function R4(i){let o=i.prog,u=i.ip,h=i.stack,p=o[++u];for(let g=0;g<p;g++)h.push(o[++u]);i.ip=u}function M4(i){let o=i.ip,u=i.prog,h=i.stack,p=u[++o];for(let g=0;g<p;g++){let A=u[++o]<<8|u[++o];A&32768&&(A=-((A^65535)+1)),h.push(A)}i.ip=o}function j4(i){let o=i.stack,u=i.store;u||(u=i.store=[]);let h=o.pop(),p=o.pop();u[p]=h}function D4(i){let o=i.stack,u=i.store,h=o.pop(),p=u&&u[h]||0;o.push(p)}function B4(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u/64}function Q4(i){let o=i.stack,u=o.pop();o.push(i.cvt[u]*64)}function $g(i,o){let u=o.stack,h=u.pop(),p=o.z2[h];u.push(o.dpv.distance(p,P,i,!1)*64)}function Ug(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z1[h],A=o.z0[p],k=o.dpv.distance(A,g,i,i);o.stack.push(Math.round(k*64))}function P4(i){i.stack.push(i.ppem)}function O4(i){i.autoFlip=!0}function F4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<u?1:0)}function $4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h<=u?1:0)}function U4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>u?1:0)}function z4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h>=u?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(),h=o.pop();o.push(u!==h?1:0)}function G4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?1:0)}function V4(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?0:1)}function q4(i){let o=i.stack.pop(),u;o||Yt(i,!0)}function Y4(i){}function Z4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u&&h?1:0)}function K4(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(u||h?1:0)}function X4(i){let o=i.stack,u=o.pop();o.push(u?0:1)}function pp(i,o){let u=o.stack,h=u.pop(),p=o.fv,g=o.pv,A=o.ppem,k=o.deltaBase+(i-1)*16,E=o.deltaShift,D=o.z0;for(let M=0;M<h;M++){let te=u.pop(),J=u.pop();if(k+((J&240)>>4)!==A)continue;let Te=(J&15)-8;Te>=0&&Te++;let he=D[te];p.setRelative(he,he,Te*E,g)}}function J4(i){let o=i.stack.pop();i.deltaBase=o}function ew(i){let o=i.stack.pop();i.deltaShift=Math.pow(.5,o)}function tw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h+u)}function rw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h-u)}function nw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*64/u)}function sw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(h*u/64)}function iw(i){let o=i.stack,u=o.pop();o.push(Math.abs(u))}function aw(i){let o=i.stack,u=o.pop();o.push(-u)}function ow(i){let o=i.stack,u=o.pop();o.push(Math.floor(u/64)*64)}function lw(i){let o=i.stack,u=o.pop();o.push(Math.ceil(u/64)*64)}function V0(i,o){let u=o.stack,h=u.pop();u.push(o.round(h/64)*64)}function cw(i){let o=i.stack,u=o.pop(),h=o.pop();i.cvt[h]=u*i.ppem/i.font.unitsPerEm}function mp(i,o){let u=o.stack,h=u.pop(),p=o.ppem,g=o.deltaBase+(i-1)*16,A=o.deltaShift;for(let k=0;k<h;k++){let E=u.pop(),D=u.pop();if(g+((D&240)>>4)!==p)continue;let M=(D&15)-8;M>=0&&M++;let te=M*A;o.cvt[E]+=te}}function uw(i){let o=i.stack.pop();i.round=G0;let u;switch(o&192){case 0:u=.5;break;case 64:u=1;break;case 128:u=2;break;default:throw new Error("invalid SROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid SROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function dw(i){let o=i.stack.pop();i.round=G0;let u;switch(o&192){case 0:u=Math.sqrt(2)/2;break;case 64:u=Math.sqrt(2);break;case 128:u=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid S45ROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function hw(i){i.round=va}function fw(i){i.round=Ul}function pw(i){i.round=Qs}function mw(i){let o=i.stack.pop()}function zg(i,o){let u=o.stack,h=u.pop(),p=u.pop(),g=o.z2[h],A=o.z1[p],k,E;i?(k=g.y-A.y,E=A.x-g.x):(k=A.x-g.x,E=A.y-g.y),o.dpv=Hl(k,E)}function gw(i){let o=i.stack,u=o.pop(),h=0;u&1&&(h=35),u&32&&(h|=4096),o.push(h)}function xw(i){let o=i.stack,u=o.pop(),h=o.pop(),p=o.pop();o.push(h),o.push(u),o.push(p)}function bw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.max(h,u))}function yw(i){let o=i.stack,u=o.pop(),h=o.pop();o.push(Math.min(h,u))}function vw(i){let o=i.stack.pop()}function ww(i){let o=i.stack.pop(),u=i.stack.pop();switch(o){case 1:i.inhibitGridFit=!!u;return;case 2:i.ignoreCvt=!!u;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Wl(i,o){let u=o.stack,h=o.prog,p=o.ip;for(let g=0;g<i;g++)u.push(h[++p]);o.ip=p}function Gl(i,o){let u=o.ip,h=o.prog,p=o.stack;for(let g=0;g<i;g++){let A=h[++u]<<8|h[++u];A&32768&&(A=-((A^65535)+1)),p.push(A)}o.ip=u}function ur(i,o,u,h,p,g){let A=g.stack,k=i&&A.pop(),E=A.pop(),D=g.rp0,M=g.z0[D],te=g.z1[E],J=g.minDis,Te=g.fv,he=g.dpv,Me,ut,mr,lr;ut=Me=he.distance(te,M,!0,!0),mr=ut>=0?1:-1,ut=Math.abs(ut),i&&(lr=g.cvt[k],h&&Math.abs(ut-lr)<g.cvCutIn&&(ut=lr)),u&&ut<J&&(ut=J),h&&(ut=g.round(ut)),Te.setRelative(te,M,mr*ut,he),Te.touch(te),g.rp1=g.rp0,g.rp2=E,o&&(g.rp0=E)}au=[Nr.bind(void 0,Lo),Nr.bind(void 0,Da),An.bind(void 0,Lo),An.bind(void 0,Da),Nn.bind(void 0,Lo),Nn.bind(void 0,Da),Ln.bind(void 0,0),Ln.bind(void 0,1),Ai.bind(void 0,0),Ai.bind(void 0,1),Tn,Xi,Io,Eo,Ba,Qi,ro,hp,cd,l4,c4,u4,d4,h4,f4,p4,m4,g4,x4,b4,void 0,void 0,y4,fp,v4,w4,A4,C4,_4,void 0,void 0,void 0,T4,S4,k4,void 0,jg.bind(void 0,0),jg.bind(void 0,1),Dg.bind(void 0,Lo),Dg.bind(void 0,Da),Bg.bind(void 0,0),Bg.bind(void 0,1),Qg.bind(void 0,0),Qg.bind(void 0,1),Pg.bind(void 0,0),Pg.bind(void 0,1),L4,I4,Og.bind(void 0,0),Og.bind(void 0,1),E4,N4,Fg.bind(void 0,0),Fg.bind(void 0,1),R4,M4,j4,D4,B4,Q4,$g.bind(void 0,0),$g.bind(void 0,1),void 0,Ug.bind(void 0,0),Ug.bind(void 0,1),P4,void 0,O4,void 0,void 0,F4,$4,U4,z4,H4,W4,G4,V4,q4,Y4,Z4,K4,X4,pp.bind(void 0,1),J4,ew,tw,rw,nw,sw,iw,aw,ow,lw,V0.bind(void 0,0),V0.bind(void 0,1),V0.bind(void 0,2),V0.bind(void 0,3),void 0,void 0,void 0,void 0,cw,pp.bind(void 0,2),pp.bind(void 0,3),mp.bind(void 0,1),mp.bind(void 0,2),mp.bind(void 0,3),uw,dw,void 0,void 0,hw,void 0,fw,pw,fp,fp,void 0,void 0,void 0,void 0,void 0,mw,zg.bind(void 0,0),zg.bind(void 0,1),gw,void 0,xw,bw,yw,vw,ww,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Wl.bind(void 0,1),Wl.bind(void 0,2),Wl.bind(void 0,3),Wl.bind(void 0,4),Wl.bind(void 0,5),Wl.bind(void 0,6),Wl.bind(void 0,7),Wl.bind(void 0,8),Gl.bind(void 0,1),Gl.bind(void 0,2),Gl.bind(void 0,3),Gl.bind(void 0,4),Gl.bind(void 0,5),Gl.bind(void 0,6),Gl.bind(void 0,7),Gl.bind(void 0,8),ur.bind(void 0,0,0,0,0,0),ur.bind(void 0,0,0,0,0,1),ur.bind(void 0,0,0,0,0,2),ur.bind(void 0,0,0,0,0,3),ur.bind(void 0,0,0,0,1,0),ur.bind(void 0,0,0,0,1,1),ur.bind(void 0,0,0,0,1,2),ur.bind(void 0,0,0,0,1,3),ur.bind(void 0,0,0,1,0,0),ur.bind(void 0,0,0,1,0,1),ur.bind(void 0,0,0,1,0,2),ur.bind(void 0,0,0,1,0,3),ur.bind(void 0,0,0,1,1,0),ur.bind(void 0,0,0,1,1,1),ur.bind(void 0,0,0,1,1,2),ur.bind(void 0,0,0,1,1,3),ur.bind(void 0,0,1,0,0,0),ur.bind(void 0,0,1,0,0,1),ur.bind(void 0,0,1,0,0,2),ur.bind(void 0,0,1,0,0,3),ur.bind(void 0,0,1,0,1,0),ur.bind(void 0,0,1,0,1,1),ur.bind(void 0,0,1,0,1,2),ur.bind(void 0,0,1,0,1,3),ur.bind(void 0,0,1,1,0,0),ur.bind(void 0,0,1,1,0,1),ur.bind(void 0,0,1,1,0,2),ur.bind(void 0,0,1,1,0,3),ur.bind(void 0,0,1,1,1,0),ur.bind(void 0,0,1,1,1,1),ur.bind(void 0,0,1,1,1,2),ur.bind(void 0,0,1,1,1,3),ur.bind(void 0,1,0,0,0,0),ur.bind(void 0,1,0,0,0,1),ur.bind(void 0,1,0,0,0,2),ur.bind(void 0,1,0,0,0,3),ur.bind(void 0,1,0,0,1,0),ur.bind(void 0,1,0,0,1,1),ur.bind(void 0,1,0,0,1,2),ur.bind(void 0,1,0,0,1,3),ur.bind(void 0,1,0,1,0,0),ur.bind(void 0,1,0,1,0,1),ur.bind(void 0,1,0,1,0,2),ur.bind(void 0,1,0,1,0,3),ur.bind(void 0,1,0,1,1,0),ur.bind(void 0,1,0,1,1,1),ur.bind(void 0,1,0,1,1,2),ur.bind(void 0,1,0,1,1,3),ur.bind(void 0,1,1,0,0,0),ur.bind(void 0,1,1,0,0,1),ur.bind(void 0,1,1,0,0,2),ur.bind(void 0,1,1,0,0,3),ur.bind(void 0,1,1,0,1,0),ur.bind(void 0,1,1,0,1,1),ur.bind(void 0,1,1,0,1,2),ur.bind(void 0,1,1,0,1,3),ur.bind(void 0,1,1,1,0,0),ur.bind(void 0,1,1,1,0,1),ur.bind(void 0,1,1,1,0,2),ur.bind(void 0,1,1,1,0,3),ur.bind(void 0,1,1,1,1,0),ur.bind(void 0,1,1,1,1,1),ur.bind(void 0,1,1,1,1,2),ur.bind(void 0,1,1,1,1,3)];var Aw=od;function ou(i){this.char=i,this.state={},this.activeState=null}function gp(i,o,u){this.contextName=u,this.startIndex=i,this.endOffset=o}function Tw(i,o,u){this.contextName=i,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=u}function Ji(i,o){this.context=i,this.index=o,this.length=i.length,this.current=i[o],this.backtrack=i.slice(0,o),this.lookahead=i.slice(o+1)}function q0(i){this.eventId=i,this.subscribers=[]}function Sw(i){let o=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<o.length;h++){let p=o[h];Object.defineProperty(this.events,p,{value:new q0(p)})}if(i)for(let h=0;h<o.length;h++){let p=o[h],g=i[p];typeof g=="function"&&this.events[p].subscribe(g)}let u=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<u.length;h++){let p=u[h];this.events[p].subscribe(this.updateContextsRanges)}}function Ts(i){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Sw.call(this,i)}ou.prototype.setState=function(i,o){return this.state[i]=o,this.activeState={key:i,value:this.state[i]},this.activeState},ou.prototype.getState=function(i){return this.state[i]||null},Ts.prototype.inboundIndex=function(i){return i>=0&&i<this.tokens.length},Ts.prototype.composeRUD=function(i){let o=i.map(h=>this[h[0]].apply(this,h.slice(1).concat(!0))),u=h=>typeof h=="object"&&Object.prototype.hasOwnProperty.call(h,"FAIL");if(o.every(u))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:o.filter(u)};this.dispatch("composeRUD",[o.filter(h=>!u(h))])},Ts.prototype.replaceRange=function(i,o,u,h){o=o!==null?o:this.tokens.length;let p=u.every(g=>g instanceof ou);if(!isNaN(i)&&this.inboundIndex(i)&&p){let g=this.tokens.splice.apply(this.tokens,[i,o].concat(u));return h||this.dispatch("replaceToken",[i,o,u]),[g,u]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Ts.prototype.replaceToken=function(i,o,u){if(!isNaN(i)&&this.inboundIndex(i)&&o instanceof ou){let h=this.tokens.splice(i,1,o);return u||this.dispatch("replaceToken",[i,o]),[h[0],o]}else return{FAIL:"replaceToken: invalid token or index."}},Ts.prototype.removeRange=function(i,o,u){o=isNaN(o)?this.tokens.length:o;let h=this.tokens.splice(i,o);return u||this.dispatch("removeRange",[h,i,o]),h},Ts.prototype.removeToken=function(i,o){if(!isNaN(i)&&this.inboundIndex(i)){let u=this.tokens.splice(i,1);return o||this.dispatch("removeToken",[u,i]),u}else return{FAIL:"removeToken: invalid token index."}},Ts.prototype.insertToken=function(i,o,u){return i.every(h=>h instanceof ou)?(this.tokens.splice.apply(this.tokens,[o,0].concat(i)),u||this.dispatch("insertToken",[i,o]),i):{FAIL:"insertToken: invalid token(s)."}},Ts.prototype.registerModifier=function(i,o,u){this.events.newToken.subscribe(function(h,p){let g=[h,p],A=o===null||o.apply(this,g)===!0,k=[h,p];if(A){let E=u.apply(this,k);h.setState(i,E)}}),this.registeredModifiers.push(i)},q0.prototype.subscribe=function(i){return typeof i=="function"?this.subscribers.push(i)-1:{FAIL:`invalid '${this.eventId}' event handler`}},q0.prototype.unsubscribe=function(i){this.subscribers.splice(i,1)},Ji.prototype.setCurrentIndex=function(i){this.index=i,this.current=this.context[i],this.backtrack=this.context.slice(0,i),this.lookahead=this.context.slice(i+1)},Ji.prototype.get=function(i){switch(!0){case i===0:return this.current;case(i<0&&Math.abs(i)<=this.backtrack.length):return this.backtrack.slice(i)[0];case(i>0&&i<=this.lookahead.length):return this.lookahead[i-1];default:return null}},Ts.prototype.rangeToText=function(i){if(i instanceof gp)return this.getRangeTokens(i).map(o=>o.char).join("")},Ts.prototype.getText=function(){return this.tokens.map(i=>i.char).join("")},Ts.prototype.getContext=function(i){return this.registeredContexts[i]||null},Ts.prototype.on=function(i,o){let u=this.events[i];return u?u.subscribe(o):null},Ts.prototype.dispatch=function(i,o){let u=this.events[i];if(u instanceof q0)for(let h=0;h<u.subscribers.length;h++)u.subscribers[h].apply(this,o||[])},Ts.prototype.registerContextChecker=function(i,o,u){if(this.getContext(i))return{FAIL:`context name '${i}' is already registered.`};if(typeof o!="function")return{FAIL:"missing context start check."};if(typeof u!="function")return{FAIL:"missing context end check."};let h=new Tw(i,o,u);return this.registeredContexts[i]=h,this.contextCheckers.push(h),h},Ts.prototype.getRangeTokens=function(i){let o=i.startIndex+i.endOffset;return[].concat(this.tokens.slice(i.startIndex,o))},Ts.prototype.getContextRanges=function(i){let o=this.getContext(i);return o?o.ranges:{FAIL:`context checker '${i}' is not registered.`}},Ts.prototype.resetContextsRanges=function(){let i=this.registeredContexts;for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let u=i[o];u.ranges=[]}},Ts.prototype.updateContextsRanges=function(){this.resetContextsRanges();let i=this.tokens.map(o=>o.char);for(let o=0;o<i.length;o++){let u=new Ji(i,o);this.runContextCheck(u)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Ts.prototype.setEndOffset=function(i,o){let u=this.getContext(o).openRange.startIndex,h=new gp(u,i,o),p=this.getContext(o).ranges;return h.rangeId=`${o}.${p.length}`,p.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],p=h.contextName,g=this.getContext(p).openRange;if(!g&&h.checkStart(i)&&(g=new gp(o,null,p),this.getContext(p).openRange=g,this.dispatch("contextStart",[p,o])),g&&h.checkEnd(i)){let A=o-g.startIndex+1,k=this.setEndOffset(A,p);this.dispatch("contextEnd",[p,k])}}},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],p=new Ji(o,u);this.dispatch("next",[p]),this.runContextCheck(p);let g=new ou(h);this.tokens.push(g),this.dispatch("newToken",[g,p])}return this.dispatch("end",[this.tokens]),this.tokens};var Cw=Ts;function Vl(i){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(i)}function Hg(i){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(i)}function ql(i){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(i)}function Y0(i){return/[\u0E00-\u0E7F]/.test(i)}function Z0(i){return/[A-z]/.test(i)}function _w(i){return/\s/.test(i)}function Qa(i){this.font=i,this.features={}}function Yl(i){this.id=i.id,this.tag=i.tag,this.substitution=i.substitution}function Zl(i,o){if(!i)return-1;switch(o.format){case 1:return o.glyphs.indexOf(i);case 2:{let u=o.ranges;for(let h=0;h<u.length;h++){let p=u[h];if(i>=p.start&&i<=p.end){let g=i-p.start;return p.index+g}}break}default:return-1}return-1}function kw(i,o){return Zl(i,o.coverage)===-1?null:i+o.deltaGlyphId}function Lw(i,o){let u=Zl(i,o.coverage);return u===-1?null:o.substitute[u]}function xp(i,o){let u=[];for(let h=0;h<i.length;h++){let p=i[h],g=o.current;g=Array.isArray(g)?g[0]:g;let A=Zl(g,p);A!==-1&&u.push(A)}return u.length!==i.length?-1:u}function Iw(i,o){let u=o.inputCoverage.length+o.lookaheadCoverage.length+o.backtrackCoverage.length;if(i.context.length<u)return[];let h=xp(o.inputCoverage,i);if(h===-1)return[];let p=o.inputCoverage.length-1;if(i.lookahead.length<o.lookaheadCoverage.length)return[];let g=i.lookahead.slice(p);for(;g.length&&ql(g[0].char);)g.shift();let A=new Ji(g,0),k=xp(o.lookaheadCoverage,A),E=[].concat(i.backtrack);for(E.reverse();E.length&&ql(E[0].char);)E.shift();if(E.length<o.backtrackCoverage.length)return[];let D=new Ji(E,0),M=xp(o.backtrackCoverage,D),te=h.length===o.inputCoverage.length&&k.length===o.lookaheadCoverage.length&&M.length===o.backtrackCoverage.length,J=[];if(te)for(let Te=0;Te<o.lookupRecords.length;Te++){let he=o.lookupRecords[Te],Me=he.lookupListIndex,ut=this.getLookupByIndex(Me);for(let mr=0;mr<ut.subtables.length;mr++){let lr=ut.subtables[mr],Rr,sn=this.getSubstitutionType(ut,lr);if(sn==="71"?(sn=this.getSubstitutionType(lr,lr.extension),Rr=this.getLookupMethod(lr,lr.extension),lr=lr.extension):Rr=this.getLookupMethod(ut,lr),sn==="12"){let On=i.get(he.sequenceIndex),Yn=Rr(On);Yn&&J.push(Yn)}else if(sn==="21"){let On=i.get(he.sequenceIndex),Yn=Rr(On);Yn&&J.push(Yn)}else throw new Error(`Substitution type ${sn} is not supported in chaining substitution`)}}return J}function Ew(i,o){let u=i.current,h=Zl(u,o.coverage);if(h===-1)return null;let p,g=o.ligatureSets[h];for(let A=0;A<g.length;A++){p=g[A];for(let k=0;k<p.components.length;k++){let E=i.lookahead[k],D=p.components[k];if(E!==D)break;if(k===p.components.length-1)return p}}return null}function Nw(i,o){let u=i.current;if(Zl(u,o.coverage)===-1)return null;for(let h of o.ruleSets)for(let p of h){let g=!0;for(let A=0;A<p.input.length;A++)if(i.lookahead[A]!==p.input[A]){g=!1;break}if(g){let A=[];A.push(u);for(let E=0;E<p.input.length;E++)A.push(p.input[E]);let k=(E,D)=>{let{lookupListIndex:M,sequenceIndex:te}=D,{subtables:J}=this.getLookupByIndex(M);for(let Te of J)Zl(E[te],Te.coverage)!==-1&&(E[te]=Te.deltaGlyphId)};for(let E=0;E<p.lookupRecords.length;E++){let D=p.lookupRecords[E];k(A,D)}return A}}return null}function Rw(i,o){if(i.context.length<o.coverages.length)return[];for(let h=0;h<o.coverages.length;h++){let p=i.get(h);if(p=Array.isArray(p)?p[0]:p,Zl(p,o.coverages[h])===-1)return[]}let u=[];for(let h=0;h<o.lookupRecords.length;h++){let p=o.lookupRecords[h],g=p.lookupListIndex,A=this.getLookupByIndex(g);for(let k=0;k<A.subtables.length;k++){let E=A.subtables[k],D,M=this.getSubstitutionType(A,E);if(M==="71"?(M=this.getSubstitutionType(E,E.extension),D=this.getLookupMethod(E,E.extension),E=E.extension):D=this.getLookupMethod(A,E),M==="12"){let te=i.get(p.sequenceIndex),J=D(te);J&&u.push(J)}else if(M==="21"){let te=i.get(p.sequenceIndex),J=D(te);J&&u.push(J)}}}return u}function Mw(i,o){let u=Zl(i,o.coverage);return u===-1?null:o.sequences[u]}Qa.prototype.getDefaultScriptFeaturesIndexes=function(){let i=this.font.tables.gsub.scripts;for(let o=0;o<i.length;o++){let u=i[o];if(u.tag==="DFLT")return u.script.defaultLangSys.featureIndexes}return[]},Qa.prototype.getScriptFeaturesIndexes=function(i){if(!this.font.tables.gsub)return[];if(!i)return this.getDefaultScriptFeaturesIndexes();let o=this.font.tables.gsub.scripts;for(let u=0;u<o.length;u++){let h=o[u];if(h.tag===i&&h.script.defaultLangSys)return h.script.defaultLangSys.featureIndexes;{let p=h.langSysRecords;if(p)for(let g=0;g<p.length;g++){let A=p[g];if(A.tag===i)return A.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Qa.prototype.mapTagsToFeatures=function(i,o){let u={};for(let h=0;h<i.length;h++){let p=i[h].tag,g=i[h].feature;u[p]=g}this.features[o].tags=u},Qa.prototype.getScriptFeatures=function(i){let o=this.features[i];if(Object.prototype.hasOwnProperty.call(this.features,i))return o;let u=this.getScriptFeaturesIndexes(i);if(!u)return null;let h=this.font.tables.gsub;return o=u.map(p=>h.features[p]),this.features[i]=o,this.mapTagsToFeatures(o,i),o},Qa.prototype.getSubstitutionType=function(i,o){let u=i.lookupType.toString(),h=o.substFormat.toString();return u+h},Qa.prototype.getLookupMethod=function(i,o){let u=this.getSubstitutionType(i,o);switch(u){case"11":return h=>kw.apply(this,[h,o]);case"12":return h=>Lw.apply(this,[h,o]);case"63":return h=>Iw.apply(this,[h,o]);case"41":return h=>Ew.apply(this,[h,o]);case"21":return h=>Mw.apply(this,[h,o]);case"51":return h=>Nw.apply(this,[h,o]);case"53":return h=>Rw.apply(this,[h,o]);default:throw new Error(`substitutionType : ${u} lookupType: ${i.lookupType} - substFormat: ${o.substFormat} is not yet supported`)}},Qa.prototype.lookupFeature=function(i){let o=i.contextParams,u=o.index,h=this.getFeature({tag:i.tag,script:i.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${i.tag}' for script '${i.script}'.`);let p=this.getFeatureLookups(h),g=[].concat(o.context);for(let A=0;A<p.length;A++){let k=p[A],E=this.getLookupSubtables(k);for(let D=0;D<E.length;D++){let M=E[D],te=this.getSubstitutionType(k,M),J;te==="71"?(te=this.getSubstitutionType(M,M.extension),J=this.getLookupMethod(M,M.extension),M=M.extension):J=this.getLookupMethod(k,M);let Te;switch(te){case"11":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:11,tag:i.tag,substitution:Te}));break;case"12":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:12,tag:i.tag,substitution:Te}));break;case"63":Te=J(o),Array.isArray(Te)&&Te.length&&g.splice(u,1,new Yl({id:63,tag:i.tag,substitution:Te}));break;case"41":Te=J(o),Te&&g.splice(u,1,new Yl({id:41,tag:i.tag,substitution:Te}));break;case"21":Te=J(o.current),Te&&g.splice(u,1,new Yl({id:21,tag:i.tag,substitution:Te}));break;case"51":case"53":Te=J(o),Array.isArray(Te)&&Te.length&&g.splice(u,1,new Yl({id:parseInt(te),tag:i.tag,substitution:Te}));break}o=new Ji(g,u),!(Array.isArray(Te)&&!Te.length)&&(Te=null)}}return g.length?g:null},Qa.prototype.supports=function(i){if(!i.script)return!1;this.getScriptFeatures(i.script);let o=Object.prototype.hasOwnProperty.call(this.features,i.script);if(!i.tag)return o;let u=this.features[i.script].some(h=>h.tag===i.tag);return o&&u},Qa.prototype.getLookupSubtables=function(i){return i.subtables||null},Qa.prototype.getLookupByIndex=function(i){return this.font.tables.gsub.lookups[i]||null},Qa.prototype.getFeatureLookups=function(i){return i.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Qa.prototype.getFeature=function(i){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,i.script)||this.getScriptFeatures(i.script);let o=this.features[i.script];return o?o.tags[i.tag]?this.features[i.script].tags[i.tag]:null:{FAIL:`No feature for script ${i.script}`}};var jw=Qa;function Dw(i){let o=i.current,u=i.get(-1);return u===null&&Vl(o)||!Vl(u)&&Vl(o)}function Bw(i){let o=i.get(1);return o===null||!Vl(o)}var Qw={startCheck:Dw,endCheck:Bw};function Pw(i){let o=i.current,u=i.get(-1);return(Vl(o)||ql(o))&&!Vl(u)}function Ow(i){let o=i.get(1);switch(!0){case o===null:return!0;case(!Vl(o)&&!ql(o)):{let u=_w(o);if(!u)return!0;if(u){let h=!1;if(h=i.lookahead.some(p=>Vl(p)||ql(p)),!h)return!0}break}default:return!1}}var Fw={startCheck:Pw,endCheck:Ow};function $w(i,o,u){o[u].setState(i.tag,i.substitution)}function Uw(i,o,u){o[u].setState(i.tag,i.substitution)}function bp(i,o,u){for(let h=0;h<i.substitution.length;h++){let p=i.substitution[h],g=o[u+h];if(Array.isArray(p)){p.length?g.setState(i.tag,p[0]):g.setState("deleted",!0);continue}g.setState(i.tag,p)}}function zw(i,o,u){let h=o[u];h.setState(i.tag,i.substitution.ligGlyph);let p=i.substitution.components.length;for(let g=0;g<p;g++)h=o[u+g+1],h.setState("deleted",!0)}var Wg={11:$w,12:Uw,63:bp,41:zw,51:bp,53:bp};function Hw(i,o,u){i instanceof Yl&&Wg[i.id]&&Wg[i.id](i,o,u)}var vc=Hw;function Ww(i){let o=[].concat(i.backtrack);for(let u=o.length-1;u>=0;u--){let h=o[u],p=Hg(h),g=ql(h);if(!p&&!g)return!0;if(p)return!1}return!1}function Gw(i){if(Hg(i.current))return!1;for(let o=0;o<i.lookahead.length;o++){let u=i.lookahead[o];if(!ql(u))return!0}return!1}function Vw(i){let o="arab",u=this.featuresTags[o],h=this.tokenizer.getRangeTokens(i);if(h.length===1)return;let p=new Ji(h.map(A=>A.getState("glyphIndex")),0),g=new Ji(h.map(A=>A.char),0);for(let A=0;A<h.length;A++){let k=h[A];if(ql(k.char))continue;p.setCurrentIndex(A),g.setCurrentIndex(A);let E=0;Ww(g)&&(E|=1),Gw(g)&&(E|=2);let D;switch(E){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:p});if(M instanceof Error){console.info(M.message);continue}for(let te=0;te<M.length;te++){let J=M[te];J instanceof Yl&&(vc(J,h,te),p.context[te]=J.substitution)}}}var qw=Vw;function Gg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function Yw(i){let o="arab",u=this.tokenizer.getRangeTokens(i),h=Gg(u);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];vc(k,u,p)}h=Gg(u)}}}var Zw=Yw;function Kw(i){return i.index===0&&i.context.length>1}function Xw(i){return i.index===i.context.length-1}var Jw={startCheck:Kw,endCheck:Xw};function Vg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function e7(i){let o="delf",u="ccmp",h=this.tokenizer.getRangeTokens(i),p=Vg(h);for(let g=0;g<p.context.length;g++){if(!this.query.getFeature({tag:u,script:o,contextParams:p}))continue;p.setCurrentIndex(g);let A=this.query.lookupFeature({tag:u,script:o,contextParams:p});if(A.length){for(let k=0;k<A.length;k++){let E=A[k];vc(E,h,g)}p=Vg(h)}}}var t7=e7;function r7(i){let o=i.current,u=i.get(-1);return u===null&&Z0(o)||!Z0(u)&&Z0(o)}function n7(i){let o=i.get(1);return o===null||!Z0(o)}var s7={startCheck:r7,endCheck:n7};function qg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function i7(i){let o="latn",u=this.tokenizer.getRangeTokens(i),h=qg(u);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];vc(k,u,p)}h=qg(u)}}}var a7=i7;function o7(i){let o=i.current,u=i.get(-1);return u===null&&Y0(o)||!Y0(u)&&Y0(o)}function l7(i){let o=i.get(1);return o===null||!Y0(o)}var c7={startCheck:o7,endCheck:l7};function Yg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function u7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Yg(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"ccmp",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];vc(k,u,p)}h=Yg(u,p)}}}var d7=u7;function Zg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function h7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Zg(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];vc(k,u,p)}h=Zg(u,p)}}}var f7=h7;function Kg(i,o){let u=i.map(h=>h.activeState.value);return new Ji(u,o||0)}function p7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),h=Kg(u,0);for(let p=0;p<h.context.length;p++){h.setCurrentIndex(p);let g=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(g.length){for(let A=0;A<g.length;A++){let k=g[A];vc(k,u,p)}h=Kg(u,p)}}}var m7=p7;function yp(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 g7(i){let o=i.current,u=i.get(1);return u===null&&yp(o)||yp(u)}function x7(i){let o=i.get(1);return o===null||!yp(o)}var b7={startCheck:g7,endCheck:x7};function y7(i){let o=this.query.font,u=this.tokenizer.getRangeTokens(i);if(u[1].setState("deleted",!0),o.tables.cmap&&o.tables.cmap.varSelectorList){let h=u[0].char.codePointAt(0),p=u[1].char.codePointAt(0),g=o.tables.cmap.varSelectorList[p];if(g!==void 0&&g.nonDefaultUVS){let A=g.nonDefaultUVS.uvsMappings;if(A[h]){let k=A[h].glyphID;o.glyphs.glyphs[k]!==void 0&&u[0].setState("glyphIndex",k)}}}}var v7=y7;function no(i){this.baseDir=i||"ltr",this.tokenizer=new Cw,this.featuresTags={}}no.prototype.setText=function(i){this.text=i},no.prototype.contextChecks={ccmpReplacementCheck:Jw,latinWordCheck:s7,arabicWordCheck:Qw,arabicSentenceCheck:Fw,thaiWordCheck:c7,unicodeVariationSequenceCheck:b7};function lu(i){let o=this.contextChecks[`${i}Check`];return this.tokenizer.registerContextChecker(i,o.startCheck,o.endCheck)}function w7(){return lu.call(this,"ccmpReplacement"),lu.call(this,"latinWord"),lu.call(this,"arabicWord"),lu.call(this,"arabicSentence"),lu.call(this,"thaiWord"),lu.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function A7(){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())}}no.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},no.prototype.applyFeatures=function(i,o){if(!i)throw new Error("No valid font was provided to apply features");this.query||(this.query=new jw(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)}},no.prototype.registerModifier=function(i,o,u){this.tokenizer.registerModifier(i,o,u)};function ud(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function T7(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;ud.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];qw.call(this,u)}}function S7(){ud.call(this);let i=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<i.length;o++){let u=i[o];t7.call(this,u)}}function C7(){if(!this.hasFeatureEnabled("arab","rlig"))return;ud.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];Zw.call(this,u)}}function _7(){if(!this.hasFeatureEnabled("latn","liga"))return;ud.call(this);let i=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<i.length;o++){let u=i[o];a7.call(this,u)}}function k7(){let i=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<i.length;o++){let u=i[o];v7.call(this,u)}}function L7(){ud.call(this);let i=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<i.length;o++){let u=i[o];this.hasFeatureEnabled("thai","liga")&&f7.call(this,u),this.hasFeatureEnabled("thai","rlig")&&m7.call(this,u),this.hasFeatureEnabled("thai","ccmp")&&d7.call(this,u)}}no.prototype.checkContextReady=function(i){return!!this.tokenizer.getContext(i)},no.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&S7.call(this),this.checkContextReady("arabicWord")&&(T7.call(this),C7.call(this)),this.checkContextReady("latinWord")&&_7.call(this),this.checkContextReady("arabicSentence")&&A7.call(this),this.checkContextReady("thaiWord")&&L7.call(this),this.checkContextReady("unicodeVariationSequence")&&k7.call(this)},no.prototype.hasFeatureEnabled=function(i,o){return(this.featuresTags[i]||[]).indexOf(o)!==-1},no.prototype.processText=function(i){(!this.text||this.text!==i)&&(this.setText(i),w7.call(this),this.applyFeaturesToContexts())},no.prototype.getBidiText=function(i){return this.processText(i),this.tokenizer.getText()},no.prototype.getTextGlyphs=function(i){this.processText(i);let o=[];for(let u=0;u<this.tokenizer.tokens.length;u++){let h=this.tokenizer.tokens[u];if(h.state.deleted)continue;let p=h.activeState.value;o.push(Array.isArray(p)?p[0]:p)}return o};var I7=no;function vp(i){return{fontFamily:{en:i.familyName||" "},fontSubfamily:{en:i.styleName||" "},fullName:{en:i.fullName||i.familyName+" "+i.styleName},postScriptName:{en:i.postScriptName||(i.familyName+i.styleName).replace(/\s/g,"")},designer:{en:i.designer||" "},designerURL:{en:i.designerURL||" "},manufacturer:{en:i.manufacturer||" "},manufacturerURL:{en:i.manufacturerURL||" "},license:{en:i.license||" "},licenseURL:{en:i.licenseURL||" "},version:{en:i.version||"Version 0.1"},description:{en:i.description||" "},copyright:{en:i.copyright||" "},trademark:{en:i.trademark||" "}}}function Wn(i){if(i=i||{},i.tables=i.tables||{},!i.empty){if(!i.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!i.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!i.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!i.ascender)throw new Error("When creating a new Font object, ascender is required.");if(i.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vp(i),this.names.macintosh=vp(i),this.names.windows=vp(i),this.unitsPerEm=i.unitsPerEm||1e3,this.ascender=i.ascender,this.descender=i.descender,this.createdTimestamp=i.createdTimestamp,this.italicAngle=i.italicAngle||0,this.weightClass=i.weightClass||0;let o=0;i.fsSelection?o=i.fsSelection:(this.italicAngle<0?o|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(o|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(o|=this.fsSelectionValues.BOLD),o===0&&(o=this.fsSelectionValues.REGULAR)),(!i.panose||!Array.isArray(i.panose))&&(i.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(i.tables,{os2:Object.assign({usWeightClass:i.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:i.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:i.panose[0]||0,bSerifStyle:i.panose[1]||0,bWeight:i.panose[2]||0,bProportion:i.panose[3]||0,bContrast:i.panose[4]||0,bStrokeVariation:i.panose[5]||0,bArmStyle:i.panose[6]||0,bLetterform:i.panose[7]||0,bMidline:i.panose[8]||0,bXHeight:i.panose[9]||0,fsSelection:o},i.tables.os2)})}this.supported=!0,this.glyphs=new Wr.GlyphSet(this,i.glyphs||[]),this.encoding=new en(this),this.position=new pc(this),this.substitution=new eo(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 id(this)),!0)}),this.palettes=new ya(this),this.layers=new Pl(this),this.svgImages=new ru(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Aw(this):null}})}Wn.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)>0},Wn.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},Wn.prototype.charToGlyph=function(i){let o=this.charToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Wn.prototype.updateFeatures=function(i){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(u=>i[u])}:o)},Wn.prototype.stringToGlyphIndexes=function(i,o){let u=new I7,h=g=>this.charToGlyphIndex(g.char);u.registerModifier("glyphIndex",null,h);let p=o?this.updateFeatures(o.features):this.defaultRenderOptions.features;return u.applyFeatures(this,p),u.getTextGlyphs(i)},Wn.prototype.stringToGlyphs=function(i,o){let u=this.stringToGlyphIndexes(i,o),h=u.length,p=new Array(h),g=this.glyphs.get(0);for(let A=0;A<h;A+=1)p[A]=this.glyphs.get(u[A])||g;return p},Wn.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},Wn.prototype.nameToGlyph=function(i){let o=this.nameToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Wn.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},Wn.prototype.getKerningValue=function(i,o){i=i.index||i,o=o.index||o;let u=this.position.defaultKerningTables;return u?this.position.getKerningValue(u,i,o):this.kerningPairs[i+","+o]||0},Wn.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Wn.prototype.forEachGlyph=function(i,o,u,h,p,g){o=o!==void 0?o:0,u=u!==void 0?u:0,h=h!==void 0?h:72,p=Object.assign({},this.defaultRenderOptions,p);let A=1/this.unitsPerEm*h,k=this.stringToGlyphs(i,p),E;if(p.kerning){let D=p.script||this.position.getDefaultScriptName();E=this.position.getKerningTables(D,p.language)}for(let D=0;D<k.length;D+=1){let M=k[D];if(g.call(this,M,o,u,h,p),M.advanceWidth&&(o+=M.advanceWidth*A),p.kerning&&D<k.length-1){let te=E?this.position.getKerningValue(E,M.index,k[D+1].index):this.getKerningValue(M,k[D+1]);o+=te*A}p.letterSpacing?o+=p.letterSpacing*h:p.tracking&&(o+=p.tracking/1e3*h)}return o},Wn.prototype.getPath=function(i,o,u,h,p){p=Object.assign({},this.defaultRenderOptions,p);let g=new We;if(g._layers=[],zn(this,g,h),g.stroke){let A=1/(g.unitsPerEm||1e3)*h;g.strokeWidth*=A}return this.forEachGlyph(i,o,u,h,p,(A,k,E,D)=>{let M=A.getPath(k,E,D,p,this);if(p.drawSVG||p.drawLayers){let te=M._layers;if(te&&te.length){for(let J=0;J<te.length;J++){let Te=te[J];g._layers.push(Te)}return}}g.extend(M)}),g},Wn.prototype.getPaths=function(i,o,u,h,p){p=Object.assign({},this.defaultRenderOptions,p);let g=[];return this.forEachGlyph(i,o,u,h,p,function(A,k,E,D){let M=A.getPath(k,E,D,p,this);g.push(M)}),g},Wn.prototype.getAdvanceWidth=function(i,o,u){return u=Object.assign({},this.defaultRenderOptions,u),this.forEachGlyph(i,0,0,o,u,function(){})},Wn.prototype.draw=function(i,o,u,h,p,g){this.getPath(o,u,h,p,g).draw(i)},Wn.prototype.drawPoints=function(i,o,u,h,p,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,p,g,function(A,k,E,D){A.drawPoints(i,k,E,D,g,this)})},Wn.prototype.drawMetrics=function(i,o,u,h,p,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(o,u,h,p,g,function(A,k,E,D){A.drawMetrics(i,k,E,D)})},Wn.prototype.getEnglishName=function(i){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[i];if(o)return o.en},Wn.prototype.validate=function(){let i=[],o=this;function u(p,g){p||(console.warn(`[opentype.js] ${g}`),i.push(g))}function h(p){let g=o.getEnglishName(p);u(g&&g.trim().length>0,"No English "+p+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),u(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let p=this.tables.colr.baseGlyphRecords,g=-1;for(let A=0;A<p.length;A++){let k=p[A].glyphID;if(u(g<p[A].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${k} comes after ${g}`),g>p[A].glyphID)break;g=k}}return i},Wn.prototype.toTables=function(){return $r.fontToTable(this)},Wn.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Wn.prototype.toArrayBuffer=function(){let i=this.toTables().encode(),o=new ArrayBuffer(i.length),u=new Uint8Array(o);for(let h=0;h<i.length;h++)u[h]=i[h];return o},Wn.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Wn.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Wn.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Wn.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Wn.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Xg=Wn;function E7(i,o){let u=new ot.Parser(i,o),h=u.parseUShort(),p=u.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${p}`);let g=[h,p],A=u.parsePointer32(function(){return this.parseItemVariationStore()}),k=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),E=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),D=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:g,itemVariationStore:A,advanceWidth:k,lsb:E,rsb:D}}function N7(){console.warn("Writing of hvar tables is not yet supported.")}var R7={make:N7,parse:E7},M7=function(){return{coverage:this.parsePointer(ge.coverage),attachPoints:this.parseList(ge.pointer(ge.uShortList))}},j7=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()}},D7=function(){return this.parseList(ge.pointer(j7))},B7=function(){return{coverage:this.parsePointer(ge.coverage),ligGlyphs:this.parseList(ge.pointer(D7))}},Q7=function(){return this.parseUShort(),this.parseList(ge.pointer(ge.coverage))};function P7(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 p={version:h,classDef:u.parsePointer(ge.classDef),attachList:u.parsePointer(M7),ligCaretList:u.parsePointer(B7),markAttachClassDef:u.parsePointer(ge.classDef)};return h>=1.2&&(p.markGlyphSets=u.parsePointer(Q7)),p}var O7={parse:P7},No=new Array(10);No[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{posFormat:1,coverage:this.parsePointer(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.")},No[2]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();ue.assert(o===1||o===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let u=this.parsePointer(ge.coverage),h=this.parseUShort(),p=this.parseUShort();if(o===1)return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:p,pairSets:this.parseList(ge.pointer(ge.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(h),value2:this.parseValueRecord(p)}})))};if(o===2){let g=this.parsePointer(ge.classDef),A=this.parsePointer(ge.classDef),k=this.parseUShort(),E=this.parseUShort();return{posFormat:o,coverage:u,valueFormat1:h,valueFormat2:p,classDef1:g,classDef2:A,class1Count:k,class2Count:E,classRecords:this.parseList(k,ge.list(E,function(){return{value1:this.parseValueRecord(h),value2:this.parseValueRecord(p)}}))}}},No[3]=function(){return{error:"GPOS Lookup 3 not supported"}},No[4]=function(){return{error:"GPOS Lookup 4 not supported"}},No[5]=function(){return{error:"GPOS Lookup 5 not supported"}},No[6]=function(){return{error:"GPOS Lookup 6 not supported"}},No[7]=function(){return{error:"GPOS Lookup 7 not supported"}},No[8]=function(){return{error:"GPOS Lookup 8 not supported"}},No[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function F7(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(No)}:{version:h,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(No),variations:u.parseFeatureVariationsList()}}var $7=new Array(10);function U7(i){return new _e.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new _e.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new _e.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new _e.LookupList(i.lookups,$7)}])}var z7={parse:F7,make:U7};function H7(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 p=0;p<h;p+=1){let g=i.parseUShort(),A=i.parseUShort(),k=i.parseShort();o[g+","+A]=k}return o}function W7(i){let o={};i.skip("uShort"),i.parseULong()>1&&console.warn("Only the first kern subtable is supported."),i.skip("uLong");let u=i.parseUShort()&255;if(i.skip("uShort"),u===0){let h=i.parseUShort();i.skip("uShort",3);for(let p=0;p<h;p+=1){let g=i.parseUShort(),A=i.parseUShort(),k=i.parseShort();o[g+","+A]=k}}return o}function G7(i,o){let u=new ot.Parser(i,o),h=u.parseUShort();if(h===0)return H7(u);if(h===1)return W7(u);throw new Error("Unsupported kern table version ("+h+").")}var V7={parse:G7};function q7(i,o,u,h){let p=new ot.Parser(i,o),g=h?p.parseUShort:p.parseULong,A=[];for(let k=0;k<u+1;k+=1){let E=g.call(p);h&&(E*=2),A.push(E)}return A}var Y7={parse:q7};function Jg(i,o){let u=[],h=12;for(let p=0;p<o;p+=1){let g=ot.getTag(i,h),A=ot.getULong(i,h+4),k=ot.getULong(i,h+8),E=ot.getULong(i,h+12);u.push({tag:g,checksum:A,offset:k,length:E,compression:!1}),h+=16}return u}function Z7(i,o){let u=[],h=44;for(let p=0;p<o;p+=1){let g=ot.getTag(i,h),A=ot.getULong(i,h+4),k=ot.getULong(i,h+8),E=ot.getULong(i,h+12),D;k<E?D="WOFF":D=!1,u.push({tag:g,offset:A,compression:D,compressedLength:k,length:E}),h+=20}return u}function Rn(i,o){if(o.compression==="WOFF"){let u=new Uint8Array(i.buffer,o.offset+2,o.compressedLength-2),h=new Uint8Array(o.length);if(ve(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 K7(i,o={}){let u,h,p=new Xg({empty:!0});i.constructor!==ArrayBuffer&&(i=new Uint8Array(i).buffer);let g=new DataView(i,0),A,k=[],E=ot.getTag(g,0);if(E==="\0\0\0"||E==="true"||E==="typ1")p.outlinesFormat="truetype",A=ot.getUShort(g,4),k=Jg(g,A);else if(E==="OTTO")p.outlinesFormat="cff",A=ot.getUShort(g,4),k=Jg(g,A);else if(E==="wOFF"){let gr=ot.getTag(g,4);if(gr==="\0\0\0")p.outlinesFormat="truetype";else if(gr==="OTTO")p.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+E);A=ot.getUShort(g,12),k=Z7(g,A)}else if(E==="wOF2"){let gr="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+gr)}else throw new Error("Unsupported OpenType signature "+E);let D,M,te,J,Te,he,Me,ut,mr,lr,Rr,sn,On,Yn,Zn,Ps,Ro,an;for(let gr=0;gr<A;gr+=1){let sr=k[gr],ar;switch(sr.tag){case"avar":Me=sr;break;case"cmap":ar=Rn(g,sr),p.tables.cmap=Mr.parse(ar.data,ar.offset),p.encoding=new xn(p.tables.cmap);break;case"cvt ":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),p.tables.cvt=an.parseShortList(sr.length/2);break;case"fvar":te=sr;break;case"STAT":J=sr;break;case"gvar":Te=sr;break;case"cvar":he=sr;break;case"fpgm":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),p.tables.fpgm=an.parseByteList(sr.length);break;case"head":ar=Rn(g,sr),p.tables.head=ti.parse(ar.data,ar.offset),p.unitsPerEm=p.tables.head.unitsPerEm,u=p.tables.head.indexToLocFormat;break;case"hhea":ar=Rn(g,sr),p.tables.hhea=Is.parse(ar.data,ar.offset),p.ascender=p.tables.hhea.ascender,p.descender=p.tables.hhea.descender,p.numberOfHMetrics=p.tables.hhea.numberOfHMetrics;break;case"HVAR":On=sr;break;case"hmtx":sn=sr;break;case"ltag":ar=Rn(g,sr),h=bi.parse(ar.data,ar.offset);break;case"COLR":ar=Rn(g,sr),p.tables.colr=qi.parse(ar.data,ar.offset);break;case"CPAL":ar=Rn(g,sr),p.tables.cpal=Jn.parse(ar.data,ar.offset);break;case"maxp":ar=Rn(g,sr),p.tables.maxp=Uo.parse(ar.data,ar.offset),p.numGlyphs=p.tables.maxp.numGlyphs;break;case"name":Ps=sr;break;case"OS/2":ar=Rn(g,sr),p.tables.os2=Ds.parse(ar.data,ar.offset);break;case"post":ar=Rn(g,sr),p.tables.post=Dl.parse(ar.data,ar.offset),p.glyphNames=new ze(p.tables.post);break;case"prep":ar=Rn(g,sr),an=new ot.Parser(ar.data,ar.offset),p.tables.prep=an.parseByteList(sr.length);break;case"glyf":ut=sr;break;case"loca":Zn=sr;break;case"CFF ":D=sr;break;case"CFF2":M=sr;break;case"kern":Yn=sr;break;case"GDEF":mr=sr;break;case"GPOS":lr=sr;break;case"GSUB":Rr=sr;break;case"meta":Ro=sr;break;case"gasp":try{ar=Rn(g,sr),p.tables.gasp=T.parse(ar.data,ar.offset)}catch(Pi){console.warn("Failed to parse gasp table, skipping."),console.warn(Pi)}break;case"SVG ":ar=Rn(g,sr),p.tables.svg=F.parse(ar.data,ar.offset);break;default:break}}let Pa=Rn(g,Ps);if(p.tables.name=jt.parse(Pa.data,Pa.offset,h),p.names=p.tables.name,ut&&Zn){let gr=u===0,sr=Rn(g,Zn),ar=Y7.parse(sr.data,sr.offset,p.numGlyphs,gr),Pi=Rn(g,ut);p.glyphs=Ol.parse(Pi.data,Pi.offset,ar,p,o)}else if(D){let gr=Rn(g,D);as.parse(gr.data,gr.offset,p,o)}else if(M){let gr=Rn(g,M);as.parse(gr.data,gr.offset,p,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let ea=Rn(g,sn);if(js.parse(p,ea.data,ea.offset,p.numberOfHMetrics,p.numGlyphs,p.glyphs,o),rr(p,o),Yn){let gr=Rn(g,Yn);p.kerningPairs=V7.parse(gr.data,gr.offset)}else p.kerningPairs={};if(mr){let gr=Rn(g,mr);p.tables.gdef=O7.parse(gr.data,gr.offset)}if(lr){let gr=Rn(g,lr);p.tables.gpos=z7.parse(gr.data,gr.offset),p.position.init()}if(Rr){let gr=Rn(g,Rr);p.tables.gsub=Mi.parse(gr.data,gr.offset)}if(te){let gr=Rn(g,te);p.tables.fvar=ni.parse(gr.data,gr.offset,p.names)}if(J){let gr=Rn(g,J);p.tables.stat=As.parse(gr.data,gr.offset,p.tables.fvar)}if(Te){te||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 gr=Rn(g,Te);p.tables.gvar=Zi.parse(gr.data,gr.offset,p.tables.fvar,p.glyphs)}if(he){te||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),p.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),ut||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let gr=Rn(g,he);p.tables.cvar=ba.parse(gr.data,gr.offset,p.tables.fvar,p.tables.cvt||[])}if(Me){te||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let gr=Rn(g,Me);p.tables.avar=xa.parse(gr.data,gr.offset,p.tables.fvar)}if(On){te||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),sn||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let gr=Rn(g,On);p.tables.hvar=R7.parse(gr.data,gr.offset,p.tables.fvar)}if(Ro){let gr=Rn(g,Ro);p.tables.meta=Ws.parse(gr.data,gr.offset),p.metas=p.tables.meta}return p.palettes=new ya(p),p}function X7(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function J7(){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}))}),oL=iL(aL()),Li=ku("lru-cache:metrics"),Kd=Zk("lru-cache"),lL=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,zp=()=>Li.hasSubscribers||Kd.hasSubscribers,z3=new Set,r2=typeof process=="object"&&process?process:{},cL=(e,t,r,n)=>{typeof r2.emitWarning=="function"?r2.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},uL=e=>!z3.has(e),ic=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),H3=e=>ic(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Gh:null:null,Gh=class extends Array{constructor(e){super(e),this.fill(0)}},Ic,bd,dL=(Ic=class{constructor(e,t){if(Ys(this,"heap"),Ys(this,"length"),!ie(Ic,bd))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=H3(e);if(!t)return[];Ir(Ic,bd,!0);let r=new Ic(e,t);return Ir(Ic,bd,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},bd=new WeakMap,vn(Ic,bd,!1),Ic),n2,s2,Do,oo,Ko,fu,Xo,yd,vd,Jo,ai,lo,qs,xs,Kr,Ta,co,sa,Si,el,Ci,tl,rl,uo,ho,nl,wd,Sa,pu,$t,Hp,mu,Xl,lh,fo,i2,gu,Ad,ch,Jl,ec,Wp,xu,uh,a2,o2,dh,rs,Gp,l2,c2,Td,Vp,Sd,tc,qp,Yp,hL=(Yp=class{constructor(e){vn(this,$t),vn(this,Do),vn(this,oo),vn(this,Ko),vn(this,fu),vn(this,Xo),vn(this,yd),vn(this,vd),vn(this,Jo),Ys(this,"ttl"),Ys(this,"ttlResolution"),Ys(this,"ttlAutopurge"),Ys(this,"updateAgeOnGet"),Ys(this,"updateAgeOnHas"),Ys(this,"allowStale"),Ys(this,"noDisposeOnSet"),Ys(this,"noUpdateTTL"),Ys(this,"maxEntrySize"),Ys(this,"sizeCalculation"),Ys(this,"noDeleteOnFetchRejection"),Ys(this,"noDeleteOnStaleGet"),Ys(this,"allowStaleOnFetchAbort"),Ys(this,"allowStaleOnFetchRejection"),Ys(this,"ignoreFetchAbort"),Ys(this,"backgroundFetchSize"),vn(this,ai),vn(this,lo),vn(this,qs),vn(this,xs),vn(this,Kr),vn(this,Ta),vn(this,co),vn(this,sa),vn(this,Si),vn(this,el),vn(this,Ci),vn(this,tl),vn(this,rl),vn(this,uo),vn(this,ho),vn(this,nl),vn(this,wd),vn(this,Sa),vn(this,pu),vn(this,mu,()=>{}),vn(this,Xl,()=>{}),vn(this,lh,()=>{}),vn(this,fo,()=>!1),vn(this,gu,pe=>{}),vn(this,Ad,(pe,ee,ke)=>{}),vn(this,ch,(pe,ee,ke,He)=>{if(ke||He)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),Ys(this,n2,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:c,updateAgeOnHas:l,allowStale:d,dispose:f,onInsert:m,disposeAfter:x,noDisposeOnSet:y,noUpdateTTL:w,maxSize:v=0,maxEntrySize:S=0,sizeCalculation:C,fetchMethod:I,memoMethod:R,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:z,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:$,ignoreFetchAbort:V,backgroundFetchSize:Y=1,perf:le}=e;if(this.backgroundFetchSize=Y,le!==void 0&&typeof le?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(Ir(this,Jo,le??lL),t!==0&&!ic(t))throw new TypeError("max option must be a nonnegative integer");let be=t?H3(t):Array;if(!be)throw new Error("invalid max value: "+t);if(Ir(this,Do,t),Ir(this,oo,v),this.maxEntrySize=S||ie(this,oo),this.sizeCalculation=C,this.sizeCalculation){if(!ie(this,oo)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(Ir(this,vd,R),I!==void 0&&typeof I!="function")throw new TypeError("fetchMethod must be a function if specified");if(Ir(this,yd,I),Ir(this,wd,!!I),Ir(this,qs,new Map),Ir(this,xs,Array.from({length:t}).fill(void 0)),Ir(this,Kr,Array.from({length:t}).fill(void 0)),Ir(this,Ta,new be(t)),Ir(this,co,new be(t)),Ir(this,sa,0),Ir(this,Si,0),Ir(this,el,dL.create(t)),Ir(this,ai,0),Ir(this,lo,0),typeof f=="function"&&Ir(this,Ko,f),typeof m=="function"&&Ir(this,fu,m),typeof x=="function"?(Ir(this,Xo,x),Ir(this,Ci,[])):(Ir(this,Xo,void 0),Ir(this,Ci,void 0)),Ir(this,nl,!!ie(this,Ko)),Ir(this,pu,!!ie(this,fu)),Ir(this,Sa,!!ie(this,Xo)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!V,this.maxEntrySize!==0){if(ie(this,oo)!==0&&!ic(ie(this,oo)))throw new TypeError("maxSize must be a positive integer if specified");if(!ic(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Wt(this,$t,i2).call(this)}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!z,this.updateAgeOnGet=!!c,this.updateAgeOnHas=!!l,this.ttlResolution=ic(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!ic(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Wt(this,$t,Hp).call(this)}if(ie(this,Do)===0&&this.ttl===0&&ie(this,oo)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ie(this,Do)&&!ie(this,oo)){let pe="LRU_CACHE_UNBOUNDED";uL(pe)&&(z3.add(pe),cL("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",pe,Yp))}}get perf(){return ie(this,Jo)}static unsafeExposeInternals(e){return{starts:ie(e,rl),ttls:ie(e,uo),autopurgeTimers:ie(e,ho),sizes:ie(e,tl),keyMap:ie(e,qs),keyList:ie(e,xs),valList:ie(e,Kr),next:ie(e,Ta),prev:ie(e,co),get head(){return ie(e,sa)},get tail(){return ie(e,Si)},free:ie(e,el),isBackgroundFetch:t=>{var r;return Wt(r=e,$t,rs).call(r,t)},backgroundFetch:(t,r,n,a)=>{var c;return Wt(c=e,$t,dh).call(c,t,r,n,a)},moveToTail:t=>{var r;return Wt(r=e,$t,Sd).call(r,t)},indexes:t=>{var r;return Wt(r=e,$t,Jl).call(r,t)},rindexes:t=>{var r;return Wt(r=e,$t,ec).call(r,t)},isStale:t=>{var r;return ie(r=e,fo).call(r,t)}}}get max(){return ie(this,Do)}get maxSize(){return ie(this,oo)}get calculatedSize(){return ie(this,lo)}get size(){return ie(this,ai)}get fetchMethod(){return ie(this,yd)}get memoMethod(){return ie(this,vd)}get dispose(){return ie(this,Ko)}get onInsert(){return ie(this,fu)}get disposeAfter(){return ie(this,Xo)}getRemainingTTL(e){return ie(this,qs).has(e)?1/0:0}*entries(){for(let e of Wt(this,$t,Jl).call(this))ie(this,Kr)[e]!==void 0&&ie(this,xs)[e]!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield[ie(this,xs)[e],ie(this,Kr)[e]])}*rentries(){for(let e of Wt(this,$t,ec).call(this))ie(this,Kr)[e]!==void 0&&ie(this,xs)[e]!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield[ie(this,xs)[e],ie(this,Kr)[e]])}*keys(){for(let e of Wt(this,$t,Jl).call(this)){let t=ie(this,xs)[e];t!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield t)}}*rkeys(){for(let e of Wt(this,$t,ec).call(this)){let t=ie(this,xs)[e];t!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield t)}}*values(){for(let e of Wt(this,$t,Jl).call(this))ie(this,Kr)[e]!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}*rvalues(){for(let e of Wt(this,$t,ec).call(this))ie(this,Kr)[e]!==void 0&&!Wt(this,$t,rs).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}[(s2=Symbol.iterator,n2=Symbol.toStringTag,s2)](){return this.entries()}find(e,t={}){for(let r of Wt(this,$t,Jl).call(this)){let n=ie(this,Kr)[r],a=Wt(this,$t,rs).call(this,n)?n.__staleWhileFetching:n;if(a!==void 0&&e(a,ie(this,xs)[r],this))return Wt(this,$t,Td).call(this,ie(this,xs)[r],t)}}forEach(e,t=this){for(let r of Wt(this,$t,Jl).call(this)){let n=ie(this,Kr)[r],a=Wt(this,$t,rs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,xs)[r],this)}}rforEach(e,t=this){for(let r of Wt(this,$t,ec).call(this)){let n=ie(this,Kr)[r],a=Wt(this,$t,rs).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,xs)[r],this)}}purgeStale(){let e=!1;for(let t of Wt(this,$t,ec).call(this,{allowStale:!0}))ie(this,fo).call(this,t)&&(Wt(this,$t,tc).call(this,ie(this,xs)[t],"expire"),e=!0);return e}info(e){let t=ie(this,qs).get(e);if(t===void 0)return;let r=ie(this,Kr)[t],n=Wt(this,$t,rs).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let a={value:n};if(ie(this,uo)&&ie(this,rl)){let c=ie(this,uo)[t],l=ie(this,rl)[t];if(c&&l){let d=c-(ie(this,Jo).now()-l);a.ttl=d,a.start=Date.now()}}return ie(this,tl)&&(a.size=ie(this,tl)[t]),a}dump(){let e=[];for(let t of Wt(this,$t,Jl).call(this,{allowStale:!0})){let r=ie(this,xs)[t],n=ie(this,Kr)[t],a=Wt(this,$t,rs).call(this,n)?n.__staleWhileFetching:n;if(a===void 0||r===void 0)continue;let c={value:a};if(ie(this,uo)&&ie(this,rl)){c.ttl=ie(this,uo)[t];let l=ie(this,Jo).now()-ie(this,rl)[t];c.start=Math.floor(Date.now()-l)}ie(this,tl)&&(c.size=ie(this,tl)[t]),e.unshift([r,c])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let n=Date.now()-r.start;r.start=ie(this,Jo).now()-n}Wt(this,$t,xu).call(this,t,r.value,r)}}set(e,t,r={}){let{status:n=Li.hasSubscribers?{}:void 0}=r;r.status=n,n&&(n.op="set",n.key=e,t!==void 0&&(n.value=t),n.cache=this);let a=Wt(this,$t,xu).call(this,e,t,r);return n&&Li.hasSubscribers&&Li.publish(n),a}pop(){var e;try{for(;ie(this,ai);){let t=ie(this,Kr)[ie(this,sa)];if(Wt(this,$t,uh).call(this,!0),Wt(this,$t,rs).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(ie(this,Sa)&&ie(this,Ci)){let t=ie(this,Ci),r;for(;r=t?.shift();)(e=ie(this,Xo))==null||e.call(this,...r)}}}has(e,t={}){let{status:r=Li.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let n=Wt(this,$t,a2).call(this,e,t);return Li.hasSubscribers&&Li.publish(r),n}peek(e,t={}){let{status:r=zp()?{}:void 0}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let n=Wt(this,$t,o2).call(this,e,t);return Li.hasSubscribers&&Li.publish(r),n}fetch(e,t={}){let r=Kd.hasSubscribers,{status:n=zp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Wt(this,$t,Gp).call(this,e,t);return n&&r&&(n.trace=!0,Kd.tracePromise(()=>a,n).catch(()=>{})),a}forceFetch(e,t={}){let r=Kd.hasSubscribers,{status:n=zp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Wt(this,$t,l2).call(this,e,t);return n&&r&&(n.trace=!0,Kd.tracePromise(()=>a,n).catch(()=>{})),a}memo(e,t={}){let{status:r=Li.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="memo",r.key=e,t.context&&(r.context=t.context),r.cache=this);let n=Wt(this,$t,c2).call(this,e,t);return r&&(r.value=n),Li.hasSubscribers&&Li.publish(r),n}get(e,t={}){let{status:r=Li.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let n=Wt(this,$t,Td).call(this,e,t);return r&&(n!==void 0&&(r.value=n),Li.hasSubscribers&&Li.publish(r)),n}delete(e){return Wt(this,$t,tc).call(this,e,"delete")}clear(){return Wt(this,$t,qp).call(this,"delete")}},Do=new WeakMap,oo=new WeakMap,Ko=new WeakMap,fu=new WeakMap,Xo=new WeakMap,yd=new WeakMap,vd=new WeakMap,Jo=new WeakMap,ai=new WeakMap,lo=new WeakMap,qs=new WeakMap,xs=new WeakMap,Kr=new WeakMap,Ta=new WeakMap,co=new WeakMap,sa=new WeakMap,Si=new WeakMap,el=new WeakMap,Ci=new WeakMap,tl=new WeakMap,rl=new WeakMap,uo=new WeakMap,ho=new WeakMap,nl=new WeakMap,wd=new WeakMap,Sa=new WeakMap,pu=new WeakMap,$t=new WeakSet,Hp=function(){let e=new Gh(ie(this,Do)),t=new Gh(ie(this,Do));Ir(this,uo,e),Ir(this,rl,t);let r=this.ttlAutopurge?Array.from({length:ie(this,Do)}):void 0;Ir(this,ho,r),Ir(this,lh,(l,d,f=ie(this,Jo).now())=>{t[l]=d!==0?f:0,e[l]=d,n(l,d)}),Ir(this,mu,l=>{t[l]=e[l]!==0?ie(this,Jo).now():0,n(l,e[l])});let n=this.ttlAutopurge?(l,d)=>{if(r?.[l]&&(clearTimeout(r[l]),r[l]=void 0),d&&d!==0&&r){let f=setTimeout(()=>{ie(this,fo).call(this,l)&&Wt(this,$t,tc).call(this,ie(this,xs)[l],"expire")},d+1);f.unref&&f.unref(),r[l]=f}}:()=>{};Ir(this,Xl,(l,d)=>{if(e[d]){let f=e[d],m=t[d];if(!f||!m)return;l.ttl=f,l.start=m,l.now=a||c();let x=l.now-m;l.remainingTTL=f-x}});let a=0,c=()=>{let l=ie(this,Jo).now();if(this.ttlResolution>0){a=l;let d=setTimeout(()=>a=0,this.ttlResolution);d.unref&&d.unref()}return l};this.getRemainingTTL=l=>{let d=ie(this,qs).get(l);if(d===void 0)return 0;let f=e[d],m=t[d];if(!f||!m)return 1/0;let x=(a||c())-m;return f-x},Ir(this,fo,l=>{let d=t[l],f=e[l];return!!f&&!!d&&(a||c())-d>f})},mu=new WeakMap,Xl=new WeakMap,lh=new WeakMap,fo=new WeakMap,i2=function(){let e=new Gh(ie(this,Do));Ir(this,lo,0),Ir(this,tl,e),Ir(this,gu,t=>{Ir(this,lo,ie(this,lo)-e[t]),e[t]=0}),Ir(this,ch,(t,r,n,a)=>{if(!ic(n)){if(Wt(this,$t,rs).call(this,r))return this.backgroundFetchSize;if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(n=a(r,t),!ic(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return n}),Ir(this,Ad,(t,r,n)=>{if(e[t]=r,ie(this,oo)){let a=ie(this,oo)-e[t];for(;ie(this,lo)>a;)Wt(this,$t,uh).call(this,!0)}Ir(this,lo,ie(this,lo)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=ie(this,lo))})},gu=new WeakMap,Ad=new WeakMap,ch=new WeakMap,Jl=function*({allowStale:e=this.allowStale}={}){if(ie(this,ai))for(let t=ie(this,Si);Wt(this,$t,Wp).call(this,t)&&((e||!ie(this,fo).call(this,t))&&(yield t),t!==ie(this,sa));)t=ie(this,co)[t]},ec=function*({allowStale:e=this.allowStale}={}){if(ie(this,ai))for(let t=ie(this,sa);Wt(this,$t,Wp).call(this,t)&&((e||!ie(this,fo).call(this,t))&&(yield t),t!==ie(this,Si));)t=ie(this,Ta)[t]},Wp=function(e){return e!==void 0&&ie(this,qs).get(ie(this,xs)[e])===e},xu=function(e,t,r,n){var a,c,l,d;let{ttl:f=this.ttl,start:m,noDisposeOnSet:x=this.noDisposeOnSet,sizeCalculation:y=this.sizeCalculation,status:w}=r,v=Wt(this,$t,rs).call(this,t);if(t===void 0)return w&&(w.set="deleted"),this.delete(e),this;let{noUpdateTTL:S=this.noUpdateTTL}=r;w&&!v&&(w.value=t);let C=ie(this,ch).call(this,e,t,r.size||0,y,w);if(this.maxEntrySize&&C>this.maxEntrySize)return Wt(this,$t,tc).call(this,e,"set"),w&&(w.set="miss",w.maxEntrySizeExceeded=!0),this;let I=ie(this,ai)===0?void 0:ie(this,qs).get(e);if(I===void 0)I=ie(this,ai)===0?ie(this,Si):ie(this,el).length!==0?ie(this,el).pop():ie(this,ai)===ie(this,Do)?Wt(this,$t,uh).call(this,!1):ie(this,ai),ie(this,xs)[I]=e,ie(this,Kr)[I]=t,ie(this,qs).set(e,I),ie(this,Ta)[ie(this,Si)]=I,ie(this,co)[I]=ie(this,Si),Ir(this,Si,I),Up(this,ai)._++,ie(this,Ad).call(this,I,C,w),w&&(w.set="add"),S=!1,ie(this,pu)&&!v&&((a=ie(this,fu))==null||a.call(this,t,e,"add"));else{Wt(this,$t,Sd).call(this,I);let R=ie(this,Kr)[I];if(t!==R){if(!x)if(Wt(this,$t,rs).call(this,R)){R!==n&&R.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:B}=R;B!==void 0&&B!==t&&(ie(this,nl)&&((c=ie(this,Ko))==null||c.call(this,B,e,"set")),ie(this,Sa)&&ie(this,Ci)?.push([B,e,"set"]))}else ie(this,nl)&&((l=ie(this,Ko))==null||l.call(this,R,e,"set")),ie(this,Sa)&&ie(this,Ci)?.push([R,e,"set"]);if(ie(this,gu).call(this,I),ie(this,Ad).call(this,I,C,w),ie(this,Kr)[I]=t,!v){let B=R&&Wt(this,$t,rs).call(this,R)?R.__staleWhileFetching:R,z=B===void 0?"add":t!==B?"replace":"update";w&&(w.set=z,B!==void 0&&(w.oldValue=B)),ie(this,pu)&&this.onInsert?.(t,e,z)}}else v||(w&&(w.set="update"),ie(this,pu)&&this.onInsert?.(t,e,"update"))}if(f!==0&&!ie(this,uo)&&Wt(this,$t,Hp).call(this),ie(this,uo)&&(S||ie(this,lh).call(this,I,f,m),w&&ie(this,Xl).call(this,w,I)),!x&&ie(this,Sa)&&ie(this,Ci)){let R=ie(this,Ci),B;for(;B=R?.shift();)(d=ie(this,Xo))==null||d.call(this,...B)}return this},uh=function(e){var t;let r=ie(this,sa),n=ie(this,xs)[r],a=ie(this,Kr)[r],c=Wt(this,$t,rs).call(this,a);c&&a.__abortController.abort(new Error("evicted"));let l=c?a.__staleWhileFetching:a;return(ie(this,nl)||ie(this,Sa))&&l!==void 0&&(ie(this,nl)&&((t=ie(this,Ko))==null||t.call(this,l,n,"evict")),ie(this,Sa)&&ie(this,Ci)?.push([l,n,"evict"])),ie(this,gu).call(this,r),ie(this,ho)?.[r]&&(clearTimeout(ie(this,ho)[r]),ie(this,ho)[r]=void 0),e&&(ie(this,xs)[r]=void 0,ie(this,Kr)[r]=void 0,ie(this,el).push(r)),ie(this,ai)===1?(Ir(this,sa,Ir(this,Si,0)),ie(this,el).length=0):Ir(this,sa,ie(this,Ta)[r]),ie(this,qs).delete(n),Up(this,ai)._--,r},a2=function(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=ie(this,qs).get(e);if(a!==void 0){let c=ie(this,Kr)[a];if(Wt(this,$t,rs).call(this,c)&&c.__staleWhileFetching===void 0)return!1;if(ie(this,fo).call(this,a))n&&(n.has="stale",ie(this,Xl).call(this,n,a));else return r&&ie(this,mu).call(this,a),n&&(n.has="hit",ie(this,Xl).call(this,n,a)),!0}else n&&(n.has="miss");return!1},o2=function(e,t){let{status:r,allowStale:n=this.allowStale}=t,a=ie(this,qs).get(e);if(a===void 0||!n&&ie(this,fo).call(this,a)){r&&(r.peek=a===void 0?"miss":"stale");return}let c=ie(this,Kr)[a],l=Wt(this,$t,rs).call(this,c)?c.__staleWhileFetching:c;return r&&(l!==void 0?(r.peek="hit",r.value=l):r.peek="miss"),l},dh=function(e,t,r,n){let a=t===void 0?void 0:ie(this,Kr)[t];if(Wt(this,$t,rs).call(this,a))return a;let c=new AbortController,{signal:l}=r;l?.addEventListener("abort",()=>c.abort(l.reason),{signal:c.signal});let d={signal:c.signal,options:r,context:n},f=(S,C=!1)=>{let{aborted:I}=c.signal,R=r.ignoreFetchAbort&&S!==void 0,B=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&S!==void 0);if(r.status&&(I&&!C?(r.status.fetchAborted=!0,r.status.fetchError=c.signal.reason,R&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),I&&!R&&!C)return x(c.signal.reason,B);let z=w,O=ie(this,Kr)[t];return(O===w||O===void 0&&R&&C)&&(S===void 0?z.__staleWhileFetching!==void 0?ie(this,Kr)[t]=z.__staleWhileFetching:Wt(this,$t,tc).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),Wt(this,$t,xu).call(this,e,S,d.options,z))),S},m=S=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=S),x(S,!1)),x=(S,C)=>{let{aborted:I}=c.signal,R=I&&r.allowStaleOnFetchAbort,B=R||r.allowStaleOnFetchRejection,z=B||r.noDeleteOnFetchRejection,O=w;if(ie(this,Kr)[t]===w&&(!z||!C&&O.__staleWhileFetching===void 0?Wt(this,$t,tc).call(this,e,"fetch"):R||(ie(this,Kr)[t]=O.__staleWhileFetching)),B)return r.status&&O.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),O.__staleWhileFetching;if(O.__returned===O)throw S},y=(S,C)=>{var I;let R=(I=ie(this,yd))==null?void 0:I.call(this,e,a,d);c.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(S(void 0),r.allowStaleOnFetchAbort&&(S=B=>f(B,!0)))}),R&&R instanceof Promise?R.then(B=>S(B===void 0?void 0:B),C):R!==void 0&&S(R)};r.status&&(r.status.fetchDispatched=!0);let w=new Promise(y).then(f,m),v=Object.assign(w,{__abortController:c,__staleWhileFetching:a,__returned:void 0});return t===void 0?(Wt(this,$t,xu).call(this,e,v,{...d.options,status:void 0}),t=ie(this,qs).get(e)):ie(this,Kr)[t]=v,v},rs=function(e){if(!ie(this,wd))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},Gp=async function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:c=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:d=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:S,forceRefresh:C=!1,status:I,signal:R}=t;if(I&&(I.op="fetch",I.key=e,C&&(I.forceRefresh=!0),I.cache=this),!ie(this,wd))return I&&(I.fetch="get"),Wt(this,$t,Td).call(this,e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:I});let B={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:c,noDisposeOnSet:l,size:d,sizeCalculation:f,noUpdateTTL:m,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:v,ignoreFetchAbort:w,status:I,signal:R},z=ie(this,qs).get(e);if(z===void 0){I&&(I.fetch="miss");let O=Wt(this,$t,dh).call(this,e,z,B,S);return O.__returned=O}else{let O=ie(this,Kr)[z];if(Wt(this,$t,rs).call(this,O)){let le=r&&O.__staleWhileFetching!==void 0;return I&&(I.fetch="inflight",le&&(I.returnedStale=!0)),le?O.__staleWhileFetching:O.__returned=O}let $=ie(this,fo).call(this,z);if(!C&&!$)return I&&(I.fetch="hit"),Wt(this,$t,Sd).call(this,z),n&&ie(this,mu).call(this,z),I&&ie(this,Xl).call(this,I,z),O;let V=Wt(this,$t,dh).call(this,e,z,B,S),Y=V.__staleWhileFetching!==void 0&&r;return I&&(I.fetch=$?"stale":"refresh",Y&&$&&(I.returnedStale=!0)),Y?V.__staleWhileFetching:V.__returned=V}},l2=async function(e,t={}){let r=await Wt(this,$t,Gp).call(this,e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r},c2=function(e,t={}){let r=ie(this,vd);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,Td).call(this,e,l),f=c||d===void 0;if(a&&(a.memo=f?"miss":"hit",f||(a.value=d)),!f)return d;let m=r(e,d,{options:l,context:n});return a&&(a.value=m),Wt(this,$t,xu).call(this,e,m,l),m},Td=function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:c}=t,l=ie(this,qs).get(e);if(l===void 0){c&&(c.get="miss");return}let d=ie(this,Kr)[l],f=Wt(this,$t,rs).call(this,d);return c&&ie(this,Xl).call(this,c,l),ie(this,fo).call(this,l)?f?(c&&(c.get="stale-fetching"),r&&d.__staleWhileFetching!==void 0?(c&&(c.returnedStale=!0),d.__staleWhileFetching):void 0):(a||Wt(this,$t,tc).call(this,e,"expire"),c&&(c.get="stale"),r?(c&&(c.returnedStale=!0),d):void 0):(c&&(c.get=f?"fetching":"hit"),Wt(this,$t,Sd).call(this,l),n&&ie(this,mu).call(this,l),f?d.__staleWhileFetching:d)},Vp=function(e,t){ie(this,co)[t]=e,ie(this,Ta)[e]=t},Sd=function(e){e!==ie(this,Si)&&(e===ie(this,sa)?Ir(this,sa,ie(this,Ta)[e]):Wt(this,$t,Vp).call(this,ie(this,co)[e],ie(this,Ta)[e]),Wt(this,$t,Vp).call(this,ie(this,Si),e),Ir(this,Si,e))},tc=function(e,t){var r,n;Li.hasSubscribers&&Li.publish({op:"delete",delete:t,key:e,cache:this});let a=!1;if(ie(this,ai)!==0){let c=ie(this,qs).get(e);if(c!==void 0)if(ie(this,ho)?.[c]&&(clearTimeout(ie(this,ho)?.[c]),ie(this,ho)[c]=void 0),a=!0,ie(this,ai)===1)Wt(this,$t,qp).call(this,t);else{ie(this,gu).call(this,c);let l=ie(this,Kr)[c];if(Wt(this,$t,rs).call(this,l)?l.__abortController.abort(new Error("deleted")):(ie(this,nl)||ie(this,Sa))&&(ie(this,nl)&&((r=ie(this,Ko))==null||r.call(this,l,e,t)),ie(this,Sa)&&ie(this,Ci)?.push([l,e,t])),ie(this,qs).delete(e),ie(this,xs)[c]=void 0,ie(this,Kr)[c]=void 0,c===ie(this,Si))Ir(this,Si,ie(this,co)[c]);else if(c===ie(this,sa))Ir(this,sa,ie(this,Ta)[c]);else{let d=ie(this,co)[c];ie(this,Ta)[d]=ie(this,Ta)[c];let f=ie(this,Ta)[c];ie(this,co)[f]=ie(this,co)[c]}Up(this,ai)._--,ie(this,el).push(c)}}if(ie(this,Sa)&&ie(this,Ci)?.length){let c=ie(this,Ci),l;for(;l=c?.shift();)(n=ie(this,Xo))==null||n.call(this,...l)}return a},qp=function(e){var t,r;for(let n of Wt(this,$t,ec).call(this,{allowStale:!0})){let a=ie(this,Kr)[n];if(Wt(this,$t,rs).call(this,a))a.__abortController.abort(new Error("deleted"));else{let c=ie(this,xs)[n];ie(this,nl)&&((t=ie(this,Ko))==null||t.call(this,a,c,e)),ie(this,Sa)&&ie(this,Ci)?.push([a,c,e])}}if(ie(this,qs).clear(),ie(this,Kr).fill(void 0),ie(this,xs).fill(void 0),ie(this,uo)&&ie(this,rl)){ie(this,uo).fill(0),ie(this,rl).fill(0);for(let n of ie(this,ho)??[])n!==void 0&&clearTimeout(n);ie(this,ho)?.fill(void 0)}if(ie(this,tl)&&ie(this,tl).fill(0),Ir(this,sa,0),Ir(this,Si,0),ie(this,el).length=0,Ir(this,lo,0),Ir(this,ai,0),ie(this,Sa)&&ie(this,Ci)){let n=ie(this,Ci),a;for(;a=n?.shift();)(r=ie(this,Xo))==null||r.call(this,...a)}},Yp);function W3(e){let t={individual:{},range:[]},r=new WeakMap;for(let n of e)t1(t,n,r);return t}function t1(e,t,r){for(let[n,a]of Object.entries(t.individual))if(e.individual[n])bu(e.individual[n],a,r);else{let c=!1;for(let[l,{range:d,entry:f}]of e.range.entries()){let m=Zp(Number(n),d);if(m.both!==null){c=!0,e.individual[n]=a,bu(e.individual[n],Ii(f),r),e.range.splice(l,1);for(let x of m.second)Array.isArray(x)?e.range.push({range:x,entry:Ii(f)}):e.individual[x]=Ii(f)}}c||(e.individual[n]=a)}for(let{range:n,entry:a}of t.range){let c=[n];for(let l=0;l<e.range.length;l++){let{range:d,entry:f}=e.range[l];for(let[m,x]of c.entries())if(Array.isArray(x)){let y=fL(x,d);if(y.both===null)continue;e.range.splice(l,1),l--;let w=Ii(f);Array.isArray(y.both)?e.range.push({range:y.both,entry:w}):e.individual[y.both]=w,bu(w,Ii(a),r);for(let v of y.second)Array.isArray(v)?e.range.push({range:v,entry:Ii(f)}):e.individual[v]=Ii(f);c=y.first}else{let y=Zp(x,d);if(y.both===null)continue;e.individual[x]=Ii(a),bu(e.individual[x],Ii(f),r),e.range.splice(l,1),l--;for(let w of y.second)Array.isArray(w)?e.range.push({range:w,entry:Ii(f)}):e.individual[w]=Ii(f);c.splice(m,1,...y.first);break}}for(let l of Object.keys(e.individual))for(let[d,f]of c.entries())if(Array.isArray(f)){let m=Zp(Number(l),f);if(m.both===null)continue;bu(e.individual[l],Ii(a),r),c.splice(d,1,...m.second);break}else if(Number(l)===f){bu(e.individual[l],Ii(a),r);break}for(let l of c)Array.isArray(l)?e.range.push({range:l,entry:Ii(a)}):e.individual[l]=Ii(a)}}function bu(e,t,r){let n=r.get(e);n?.has(t)||(n||(n=new Set,r.set(e,n)),n.add(t),t.lookup&&(!e.lookup||e.lookup.index>t.lookup.index||e.lookup.index===t.lookup.index&&e.lookup.subIndex>t.lookup.subIndex)&&(e.lookup=t.lookup),t.forward&&(e.forward?t1(e.forward,t.forward,r):e.forward=t.forward),t.reverse&&(e.reverse?t1(e.reverse,t.reverse,r):e.reverse=t.reverse))}function fL(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 Zp(e,t){if(e<t[0]||e>t[1])return{first:[e],second:[t],both:null};let r={first:[],second:[],both:e};return t[0]<e&&r.second.push(Bc(t[0],e)),t[1]>e&&r.second.push(Bc(e+1,t[1])),r}function Bc(e,t){return t-e===1?e:[e,t]}function Ii(e,t=new Map){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=u2(e.forward,t)),e.reverse&&(r.reverse=u2(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 u2(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=Ii(a,t);return{individual:r,range:e.range.map(({range:n,entry:a})=>({range:n.slice(),entry:Ii(a,t)}))}}function r1(e,t,r,n){let a=t[n],c=e[a];if(!c)return;let l=c.lookup;if(c.reverse){let f=pL(c.reverse,t,r);(!l&&f||f&&l&&(l.index>f.index||l.index===f.index&&l.subIndex>f.subIndex))&&(l=f)}if(++n>=t.length||!c.forward)return l;let d=r1(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 pL(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 d2(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 mL(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 gL(e,t){let r=t[0],n=n1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)n1(e,a)!==n&&(a-r<=1?c.set(r,n):c.set([r,a],n)),a++;return a-r<=1?c.set(r,n):c.set([r,a],n),c}function n1(e,t){let r=mL(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 X1(e,t,r,n,a){let c=[];for(let l of r){l.entry.forward={individual:{},range:[]};for(let d of e)c.push(...Vf(l.entry.forward,n,a,t,d).map(({entry:f,substitution:m})=>({entry:f,substitutions:[...l.substitutions,m]})))}return c}function Wf(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 Gf(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 Vf(e,t,r,n,a){let c=[];if(!Array.isArray(a))e.individual[a]={},c.push({entry:e.individual[a],substitution:bL(t,r,n,a)});else{let l=xL(t,r,n,a);for(let[d,f]of l){let m={};Array.isArray(d)?e.range.push({range:d,entry:m}):e.individual[d]={},c.push({entry:m,substitution:f})}}return c}function xL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=gL(c,n);if(!Array.from(l.values()).every(d=>d!==null))return l}return new Map([[n,null]])}function bL(e,t,r,n){for(let a of e.filter(c=>c.sequenceIndex===r))for(let c of t[a.lookupListIndex].subtables){let l=n1(c,n);if(l!==null)return l}return null}function yL(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[f,m]of d.entries()){let x=Vf(n,m.lookupRecords,t,0,c).map(({entry:y,substitution:w})=>({entry:y,substitutions:[w]}));for(let[y,w]of m.input.entries())x=X1([w],y+1,x,m.lookupRecords,t);for(let y of m.lookahead)x=Wf([y],x);for(let y of m.backtrack)x=Gf([y],x);for(let{entry:y,substitutions:w}of x)y.lookup={substitutions:w,length:m.input.length+1,index:r,subIndex:f,contextRange:[-1*m.backtrack.length,1+m.input.length+m.lookahead.length]}}}return n}function vL(e,t){return e.format===2?Array.isArray(t)?wL(e,t):new Map([[t,s1(e,t)]]):new Map([[t,null]])}function wL(e,t){let r=t[0],n=s1(e,r),a=t[0]+1,c=new Map;for(;a<t[1];)s1(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 s1(e,t){for(let r of e.ranges)if(r.start<=t&&r.end>=t)return r.classId;return null}function Kp(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 AL(e,t,r){let n=[],a=Nl(e.coverage);for(let{glyphId:c}of a){let l=vL(e.inputClassDef,c);for(let[d,f]of l.entries()){if(f===null)continue;let m=e.chainClassSet[f];if(m)for(let[x,y]of m.entries()){let w={individual:{},range:[]},v=Vf(w,y.lookupRecords,t,0,d).map(({entry:S,substitution:C})=>({entry:S,substitutions:[C]}));for(let[S,C]of y.input.entries())v=X1(Kp(e.inputClassDef,C),S+1,v,y.lookupRecords,t);for(let S of y.lookahead)v=Wf(Kp(e.lookaheadClassDef,S),v);for(let S of y.backtrack)v=Gf(Kp(e.backtrackClassDef,S),v);for(let{entry:S,substitutions:C}of v)S.lookup={substitutions:C,index:r,subIndex:x,length:y.input.length+1,contextRange:[-1*y.backtrack.length,1+y.input.length+y.lookahead.length]};n.push(w)}}}return W3(n)}function TL(e,t,r){let n={individual:{},range:[]},a=Nl(e.inputCoverage[0]);for(let{glyphId:c}of a){let l=Vf(n,e.lookupRecords,t,0,c).map(({entry:d,substitution:f})=>({entry:d,substitutions:[f]}));for(let[d,f]of e.inputCoverage.slice(1).entries())l=X1(Nl(f).map(m=>m.glyphId),d+1,l,e.lookupRecords,t);for(let d of e.lookaheadCoverage)l=Wf(Nl(d).map(f=>f.glyphId),l);for(let d of e.backtrackCoverage)l=Gf(Nl(d).map(f=>f.glyphId),l);for(let{entry:d,substitutions:f}of l)d.lookup={substitutions:f,index:r,subIndex:0,length:e.inputCoverage.length,contextRange:[-1*e.backtrackCoverage.length,e.inputCoverage.length+e.lookaheadCoverage.length]}}return n}function SL(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 f of e.lookaheadCoverage)d=Wf(Nl(f).map(m=>m.glyphId),d);for(let f of e.backtrackCoverage)d=Gf(Nl(f).map(m=>m.glyphId),d);for(let{entry:f,substitutions:m}of d)f.lookup={substitutions:m,index:t,subIndex:0,length:1,contextRange:[-1*e.backtrackCoverage.length,1+e.lookaheadCoverage.length]}}return r}function i1(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=h2(a,t);for(let{range:n,entry:a}of e.range){let c=h2(a,t);for(let l=n[0];l<n[1];l++)r[l]=c}return r}function h2(e,t){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=i1(e.forward,t)),e.reverse&&(r.reverse=i1(e.reverse,t)),e.lookup&&(r.lookup=e.lookup),r}var CL=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new hL({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(yL(x,n,m));break;case 2:d.push(AL(x,n,m));break;case 3:d.push(TL(x,n,m));break}break;case 8:for(let[m,x]of l.subtables.entries())d.push(SL(x,m));break}let f=i1(W3(d));this._lookupTrees.push({tree:f,processForward:l.lookupType!==8});for(let m of Object.keys(f))this._glyphLookups[m]||(this._glyphLookups[m]=[]),this._glyphLookups[m].push(c)}}findLigatures(e){let t=this._cache&&this._cache.get(e);if(t&&!Array.isArray(t))return t;let r=[];for(let c of e)r.push(this._font.charToGlyphIndex(c));if(this._lookupTrees.length===0)return{inputGlyphs:r,outputGlyphs:r,contextRanges:[]};let n=this._findInternal(r.slice()),a={inputGlyphs:r,outputGlyphs:n.sequence,contextRanges:n.ranges};return this._cache&&this._cache.set(e,a),a}findLigatureRanges(e){if(this._lookupTrees.length===0)return[];let t=this._cache&&this._cache.get(e);if(t)return Array.isArray(t)?t:t.contextRanges;let r=[];for(let a of e)r.push(this._font.charToGlyphIndex(a));let n=this._findInternal(r);return this._cache&&this._cache.set(e,n.ranges),n.ranges}_findInternal(e){let t=[],r=this._getNextLookup(e,0);for(;r.index!==null;){let n=this._lookupTrees[r.index];if(n.processForward){let a=r.last;for(let c=r.first;c<a;c++){let l=r1(n.tree,e,c,c);if(l){for(let d=0;d<l.substitutions.length;d++){let f=l.substitutions[d];f!==null&&(e[c+d]=f)}d2(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=r1(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)}d2(t,c.contextRange[0]+a,c.contextRange[1]+a),a-=c.length-1}}r=this._getNextLookup(e,r.index+1)}return{sequence:e,ranges:t}}_getNextLookup(e,t){let r={index:null,first:1/0,last:-1};for(let n=0;n<e.length;n++){let a=this._glyphLookups[e[n]];if(a)for(let c=0;c<a.length;c++){let l=a[c];if(l>=t){(r.index===null||l<=r.index)&&(r.index=l,r.first>n&&(r.first=n),r.last=n+1);break}}}return r}};function _L(e,t){let r=oL.parse(e);return new CL(r,{cacheSize:0,...t})}function kL(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+=LL(t,a);break;case",":r.push(n),n="";break;default:/\s/.test(a)||(t.offset--,n+=IL(t),r.push(n),n="")}}return r}function LL(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+=G3(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 IL(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+=G3(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 G3(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return Xp(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,Xp(t);t+=r}return Xp(t)}function Xp(e){return String.fromCodePoint(parseInt(e,16))}var Cd;async function EL(e,t){if(!Cd){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);Cd=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);Cd=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}Cd??=Promise.resolve({})}let r=await Cd;for(let n of kL(e)){if(NL.includes(n))return;if(r.hasOwnProperty(n)&&r[n].length>0){let a=r[n][0];if("blob"in a){let c=await(await a.blob()).arrayBuffer();return _L(c,{cacheSize:t})}return}}}var NL=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],RL=1e5;function ML(e,t=[]){let r,n,a=0,c;return e.registerCharacterJoiner(l=>{let d=e.options.fontFamily;if(d&&(a===0||r!==d)){n=void 0,a=1,r=d;let f=r;EL(f,RL).then(m=>{f===e.options.fontFamily&&(a=2,n=m,m&&e.refresh(0,e.rows-1))}).catch(m=>{f===e.options.fontFamily&&(a=3,e.options.logLevel==="debug"&&console.debug(c,new Error("Failure while loading font")),n=void 0,c=m)})}return n&&a===2?n.findLigatureRanges(l).map(f=>[f[0],f[1]]):jL(l,t)})}function jL(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 DL=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=ML(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 f2(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 BL=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=f2(r[1]),a=f2(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 V3(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 p2(e,t){const r=V3(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 Vh(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 QL(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 bf(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 PL(e,t,r){const n=zc(e);if(!n)return null;const{start:a,end:c}=bf(t,r,e.cols),l=e.buffer.active.viewportY,d=l+e.rows-1;if(c.row<l||a.row>d)return null;const f=Math.max(a.row,l),m=Math.min(c.row,d),x=n.originTop+(f-l)*n.cellH,y=n.originTop+(m-l+1)*n.cellH;return a.row===c.row?{left:n.originLeft+a.col*n.cellW,top:x,right:n.originLeft+(c.col+1)*n.cellW,bottom:y}:{left:n.originLeft,top:x,right:n.originLeft+e.cols*n.cellW,bottom:y}}function OL(e){const t=Math.max(e.viewport.left,e.terminal.left),r=Math.max(e.viewport.top,e.terminal.top),n=Math.min(e.viewport.right,e.terminal.right),a=Math.min(e.viewport.bottom,e.terminal.bottom),c=t+e.margin,l=r+e.margin,d=Math.max(c,n-e.width-e.margin),f=Math.max(l,a-e.height-e.margin),m=le=>Math.max(c,Math.min(le,d)),x=le=>Math.max(l,Math.min(le,f)),y=e.selection?V3(e.selection,{left:t,top:r,right:n,bottom:a}):null;if(!y){const le=m(e.clientX-e.width/2),be=e.clientY-e.height-e.fingerGap,pe=e.clientY+e.fingerGap,ee=x(be>=l?be:pe);return{left:Math.round(le),top:Math.round(ee)}}const w=(y.left+y.right)/2,v=(y.top+y.bottom)/2,S=e.preference?.alignX??w,C=e.selectionGap??e.fingerGap,I=y.top-e.height-C,R=y.bottom+C,B=e.preference?.vertical==="below"?R:I,z=e.preference?.vertical==="below"?I:R,O=[{left:c,top:l},{left:d,top:l},{left:c,top:f},{left:d,top:f}];e.preference&&O.sort((le,be)=>{const pe=ee=>{const ke=ee.left+e.width/2,He=ee.top+e.height/2;return Math.hypot(ke-e.preference.focusX,He-e.preference.focusY)};return pe(be)-pe(le)});const $=[{left:S-e.width/2,top:B},{left:w-e.width/2,top:B},{left:S-e.width/2,top:z},{left:w-e.width/2,top:z},{left:y.left-e.width-e.fingerGap,top:v-e.height/2},{left:y.right+e.fingerGap,top:v-e.height/2},...O].map(le=>({left:m(le.left),top:x(le.top)}));let V=$[0],Y=Number.POSITIVE_INFINITY;return $.forEach((le,be)=>{const pe={left:le.left,top:le.top,right:le.left+e.width,bottom:le.top+e.height},ee=(e.avoid??[]).reduce((He,q)=>He+p2(pe,q),0),ke=(ee>0?1e6:0)+ee*100+p2(pe,y)*10+be*.01;ke<Y&&(V=le,Y=ke)}),{left:Math.round(V.left),top:Math.round(V.top)}}function FL(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 $L(e){let t=e.parentElement;for(;t;){if(FL(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function UL(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 zL(e,t){return t?.ownedPaste?qm(e,!1):t?.paste&&/[\r\n]/.test(e)?qm(e,t.submitAfterPaste??e.endsWith("\r")):e}const m2=2,HL=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function WL(e){const t=e.reason.replace(/^refresh:/,""),r=HL.has(t),n=Math.abs(e.proposedCols-e.currentCols),a=Math.abs(e.proposedRows-e.currentRows);return{accept:r?n>0||a>0:n>=m2||a>=m2,isRealResize:r,colsDelta:n,rowsDelta:a}}function GL(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 VL(e,t){return!e||t}function qL(e,t,r){return e!=="alternate"&&r>=t}function YL(e,t){return e?"none":t?"single":"settled"}function ZL(e,t,r){return!r&&(e||t)}function KL(e){let t,r,n=!1,a=0;const c=e.parser.registerCsiHandler({prefix:"?",final:"l"},d=>(t&&d.some(f=>f===2026)&&(n=!0),!1)),l=d=>{const f=t;if(!f)return;const m=r;if(t=void 0,r=void 0,n=!1,f(),d){const x=e._core?._renderService?._renderer?.value;m&&x?.handleResize(...m),x?.renderRows(0,e.rows-1),e.refresh(0,e.rows-1)}};return{begin(){if(a++,n=!1,t)return;const d=e._core?._renderService?._renderer?.value;if(!d||typeof d.handleResize!="function"||typeof d.renderRows!="function"||typeof d.clear!="function")return;const f=d.handleResize,m=d.renderRows,x=d.clear;d.handleResize=(y,w)=>{r=[y,w]},d.renderRows=()=>{},d.clear=()=>{},t=()=>{d.handleResize=f,d.renderRows=m,d.clear=x}},get generation(){return a},written(d){d===a&&n&&!e.modes.synchronizedOutputMode&&l(!0)},cancel(){l(!0)},dispose(){l(!1),c.dispose()}}}function Jp(){return{confirmed:null,pending:null,nextSeq:1}}function g2(e,t){return e?.cols===t.cols&&e.rows===t.rows}function J1(e,t,r){const n={...t,seq:e.nextSeq,attempt:r};return{state:{...e,pending:n,nextSeq:e.nextSeq+1},request:n}}function XL(e,t){return g2(e.pending,t)||!e.pending&&g2(e.confirmed,t)?{state:e,request:null}:J1(e,t,0)}function JL(e,t){return J1(e,t,0)}function eI(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 x2(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}:{...J1(e,n,n.attempt+1),exhausted:!1}}function tI(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 rI(e){return{...e,pending:null}}const nI=150;function b2(e=0){return{lastPushAt:e}}function sI(e,t,r=nI){return t-e.lastPushAt>=r?(e.lastPushAt=t,{action:"send"}):{action:"hold",readyAt:e.lastPushAt+r}}function iI(e){return{lastPushAt:e}}const a1="termdock-settings",aI=6,oI=100,lI='"calt" on',cI=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function uI(){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 eg(){return{fontFamily:"var(--font-mono)",fontSize:uI(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function hh(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function y2(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function Qu(e){const t=eg(),r=e&&typeof e=="object"?e:{},n=r.rendererMode??r.renderer;return{fontFamily:typeof r.fontFamily=="string"&&r.fontFamily.trim()?r.fontFamily.trim():t.fontFamily,fontSize:hh(r.fontSize,aI,oI,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:y2(r.fontWeight,t.fontWeight),fontWeightBold:y2(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(hh(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:hh(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:hh(r.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function fh(e){return e.pointerType==="touch"||e.pointerType==="pen"}class dI{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[r,n]of this.active)n===t&&(this.active.delete(r),this.pointerStates.delete(r));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,r){return this.active.get(t)===r}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,r,n){this.changeListeners.size!==0&&this.changeListeners.forEach(a=>{try{a({type:t,pointerId:r,handler:n})}catch{}})}log(t,r,n=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const a=performance.now().toFixed(0);console.debug(`[GestureManager ${a}] ${t} ${r} ${n}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,r)=>r.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!fh(t))return;const r={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,r);let n=!1;for(const a of this.sortedHandlers()){if(!this.handlerMatchesContainer(a,t)){this.log("skip-container",a.name);continue}a.onPointerDown(t,r)&&!n&&(this.active.set(t.pointerId,a.name),n=!0,this.log("claim",a.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,a.name))}n&&t.preventDefault()};handlePointerMove=t=>{if(!fh(t)||!this.pointerStates.has(t.pointerId))return;let r=!1;for(const n of this.sortedHandlers()){if(!this.handlerMatchesContainer(n,t))continue;const a=this.active.get(t.pointerId)===n.name,c=n.onPointerMove(t,a);if(c==="claim"&&!r){const l=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,n.name),r=!0,t.preventDefault(),l&&l!==n.name&&this.log("handoff",`${l}->${n.name}`,`pid=${t.pointerId}`),this.log("claim",n.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,n.name)}if(c==="release"&&a&&!r){const l=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",n.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,l??null)}}};handlePointerUp=t=>{if(!fh(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerUp(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlePointerCancel=t=>{if(!fh(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerCancel(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlerMatchesContainer(t,r){return t.container?t.container.contains(r.target):!0}}const q3=new dI,hI=90,fI=80,pI=70,mI=(e,t)=>{const{scrollMultiplier:r=1.2,maxScrollBoost:n=.8,boostDenominator:a=50,velocityAlpha:c=.15,maxVelocity:l=15,minVelocity:d=.3,decelerationRate:f=.998,enableKinetic:m=!0,shouldCaptureTouch:x,canStartScrollGesture:y,onScroll:w,onScrollWithCoords:v,onTap:S,onClickWithCoords:C,onClaimChange:I,tapThreshold:R=10,gestureName:B="normal-scroll"}=t,z=1.06,O=L.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),$=L.useRef(0),V=L.useRef(0),Y=L.useRef(0),le=L.useRef(null),be=L.useRef(0),pe=L.useRef(!1),ee=L.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),ke=L.useCallback(()=>{le.current=null,$.current!==0&&(v&&V.current>0&&Y.current>0?v($.current,V.current,Y.current):w&&w($.current),$.current=0,V.current=0,Y.current=0)},[w,v]),He=L.useCallback(()=>{le.current===null&&typeof window<"u"&&(le.current=window.requestAnimationFrame(ke))},[ke]),q=L.useCallback((Ee,oe,We)=>{$.current+=Ee,oe!==void 0&&We!==void 0&&(V.current=oe,Y.current=We),He()},[He]),ce=L.useCallback(Ee=>{if(!Ee||!w)return!1;const oe=w(Ee);return oe?be.current=0:be.current++,oe},[w]),qe=L.useCallback(Ee=>{pe.current!==Ee&&(pe.current=Ee,I?.(Ee))},[I]),Ae=L.useCallback(()=>{const Ee=O.current;Ee.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ee.rafId),Ee.rafId=null,le.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(le.current),le.current=null,$.current=0},[]),ve=L.useRef(S);ve.current=S;const Ie=L.useRef(C);Ie.current=C;const Be=L.useRef(x);Be.current=x;const ne=L.useCallback(()=>{const Ee=e.current;if(!Ee||!("PointerEvent"in window))return()=>{};const oe=O.current,We={name:B,priority:pI,get container(){return e.current??void 0},onPointerDown:(ue,Ye)=>(ue.pointerType!=="touch"||(oe.pointerId=ue.pointerId,oe.startX=Ye.startX,oe.startY=Ye.startY,oe.didMove=!1,oe.gestureAxis=null,oe.lastY=ue.clientY,oe.lastTime=ee(),oe.velocity=0,Ae()),!1),onPointerMove:(ue,Ye)=>{if(ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId||!oe.lastY||!oe.lastTime)return"neutral";const at=ue.clientX,Ne=ue.clientY,Ge=ee(),Ce=Ge-oe.lastTime,H=Ne-oe.lastY;if(oe.startX!==null&&oe.startY!==null){const ye=at-oe.startX,Ve=Ne-oe.startY;if(!oe.didMove&&Math.hypot(ye,Ve)>=R&&(oe.didMove=!0),oe.gestureAxis===null&&oe.didMove){const Je=Math.abs(ye),bt=Math.abs(Ve);Je>bt*z?oe.gestureAxis="x":bt>Je*z&&(oe.gestureAxis="y")}if(oe.gestureAxis==="x")return oe.isCurrentlyScrolling=!1,qe(!1),oe.lastY=Ne,oe.lastTime=Ge,Ye?"release":"neutral";if(oe.gestureAxis===null)return oe.lastY=Ne,oe.lastTime=Ge,"neutral"}if(oe.gestureAxis==="y"&&!Ye&&!(y?.()??!0))return oe.lastY=Ne,oe.lastTime=Ge,qe(!1),"neutral";const ae=H/Math.max(Ce,1);if(oe.velocity=oe.velocity*(1-c)+ae*c,oe.velocity=Math.max(-l,Math.min(l,oe.velocity)),Math.abs(H)>1){if(!Ye)return qe(!0),oe.lastY=Ne,oe.lastTime=Ge,"claim";oe.isCurrentlyScrolling=!0;const ye=r+Math.min(n,Math.abs(H)/a),Ve=-H*ye;q(Ve,at,Ne),qe(!0)}return oe.lastY=Ne,oe.lastTime=Ge,Ye?"claim":"neutral"},onPointerUp:ue=>{if(ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId)return;const Ye=oe.isCurrentlyScrolling;oe.isCurrentlyScrolling=!1,qe(!1);const at=oe.rafId!==null||le.current!==null;!oe.didMove&&!at&&oe.startX!==null&&oe.startY!==null&&ve.current?.(oe.startX,oe.startY),!oe.didMove&&!at&&oe.startX!==null&&oe.startY!==null&&Ie.current?.(oe.startX,oe.startY),oe.pointerId=null,oe.startX=null,oe.startY=null;const Ne=oe.gestureAxis==="x";if(oe.gestureAxis=null,m&&Ye&&!Ne&&Math.abs(oe.velocity)>d&&oe.didMove){const Ge=()=>{const Ce=ee(),H=Ce-(oe.lastTime||Ce);if(oe.lastTime=Ce,oe.velocity*=Math.pow(f,H),Math.abs(oe.velocity)<d){oe.velocity=0,Ae();return}if(!ce(-oe.velocity*H)&&be.current>2){oe.velocity=0,Ae();return}oe.rafId=requestAnimationFrame(Ge)};oe.rafId=requestAnimationFrame(Ge)}},onPointerCancel:ue=>{ue.pointerType!=="touch"||oe.pointerId!==ue.pointerId||(oe.isCurrentlyScrolling=!1,qe(!1),oe.pointerId=null,oe.startX=null,oe.startY=null,oe.gestureAxis=null,Ae())}},rt=q3.register(We),gt=Ee.style.touchAction;return Ee.style.touchAction="none",()=>{qe(!1),rt(),Ee.style.touchAction=gt,Ae()}},[e,B,r,n,a,c,l,d,f,ee,Ae,ce,q,R,m,qe,y]),Fe=L.useCallback(()=>{const Ee=e.current;if(!Ee)return()=>{};const oe=O.current,We=Ye=>{Ye.touches.length===1&&((x?.()??!0)&&Ye.cancelable&&Ye.preventDefault(),oe.isCurrentlyScrolling=!1,oe.gestureAxis=null,oe.lastY=Ye.touches[0].clientY,oe.startX=Ye.touches[0].clientX,oe.startY=Ye.touches[0].clientY,oe.didMove=!1,oe.velocity=0,Ae())},rt=Ye=>{if(Ye.touches.length!==1)return;const at=Ye.touches[0].clientX,Ne=Ye.touches[0].clientY;if(oe.startX!==null&&oe.startY!==null){const Ce=at-oe.startX,H=Ne-oe.startY;if(!oe.didMove&&Math.hypot(Ce,H)>=R&&(oe.didMove=!0),oe.gestureAxis===null&&oe.didMove){const ae=Math.abs(Ce),ye=Math.abs(H);ae>ye*z?oe.gestureAxis="x":ye>ae*z&&(oe.gestureAxis="y")}if(oe.gestureAxis==="x"){oe.isCurrentlyScrolling=!1,oe.lastY=Ne;return}if(oe.gestureAxis===null){(x?.()??!1)&&Ye.cancelable&&Ye.preventDefault(),oe.lastY=Ne;return}}if(Ye.preventDefault(),!oe.lastY){oe.lastY=Ne;return}const Ge=Ne-oe.lastY;if(Math.abs(Ge)>1){oe.isCurrentlyScrolling=!0;const Ce=r+Math.min(n,Math.abs(Ge)/a),H=-Ge*Ce;q(H,at,Ne)}oe.lastY=Ne},gt=Ye=>{if(!Ye.changedTouches?.[0])return;const Ne=oe.isCurrentlyScrolling;oe.isCurrentlyScrolling=!1;const Ge=oe.rafId!==null||le.current!==null;!oe.didMove&&!Ge&&S&&oe.startX!==null&&oe.startY!==null&&S(oe.startX,oe.startY),!oe.didMove&&!Ge&&C&&oe.startX!==null&&oe.startY!==null&&C(oe.startX,oe.startY),oe.startX=null,oe.startY=null;const Ce=oe.gestureAxis==="x";if(oe.gestureAxis=null,m&&Ne&&!Ce&&oe.didMove&&Math.abs(oe.velocity)>d){const H=()=>{if(oe.velocity*=Math.pow(f,16),Math.abs(oe.velocity)<d){oe.velocity=0,Ae();return}if(!ce(-oe.velocity*16)&&be.current>2){oe.velocity=0,Ae();return}oe.rafId=requestAnimationFrame(H)};oe.rafId=requestAnimationFrame(H)}};Ee.addEventListener("touchstart",We,{passive:!1}),Ee.addEventListener("touchmove",rt,{passive:!1}),Ee.addEventListener("touchend",gt,{passive:!1}),Ee.addEventListener("touchcancel",gt,{passive:!1});const ue=Ee.style.touchAction;return Ee.style.touchAction="none",()=>{Ee.removeEventListener("touchstart",We),Ee.removeEventListener("touchmove",rt),Ee.removeEventListener("touchend",gt),Ee.removeEventListener("touchcancel",gt),Ee.style.touchAction=ue,Ae()}},[e,r,n,a,d,f,Ae,ce,q,S,C,R,x,m]),Le=L.useCallback(()=>{Ae();const Ee=typeof window<"u"&&"PointerEvent"in window,oe=Ee?ne():()=>{},We=Ee?()=>{}:Fe();return()=>{oe(),We(),Ae()}},[ne,Fe,Ae]),Re=L.useCallback(()=>O.current.isCurrentlyScrolling||O.current.rafId!==null||le.current!==null,[]),Pe=L.useCallback(()=>{Ae();const Ee=O.current;Ee.isCurrentlyScrolling=!1,Ee.velocity=0,Ee.lastY=null,Ee.lastTime=null,Ee.startX=null,Ee.startY=null,Ee.pointerId=null,Ee.didMove=!1,Ee.gestureAxis=null},[Ae]);return{setupTouchScroll:Le,isScrolling:Re,stopAllScroll:Pe}};function v2(e){const{name:t,priority:r}=e,n=b.useRef(e.onPointerDown),a=b.useRef(e.onPointerMove),c=b.useRef(e.onPointerUp),l=b.useRef(e.onPointerCancel),d=b.useRef(e.container);n.current=e.onPointerDown,a.current=e.onPointerMove,c.current=e.onPointerUp,l.current=e.onPointerCancel,d.current=e.container,b.useEffect(()=>{const f={name:t,priority:r,get container(){const x=d.current;return typeof x=="function"?x():x},onPointerDown(x,y){return n.current?.(x,y)??!1},onPointerMove(x,y){return a.current?.(x,y)??"neutral"},onPointerUp(x){c.current?.(x)},onPointerCancel(x){l.current?.(x)}};return q3.register(f)},[t,r])}var Us;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Us||(Us={}));Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;Us.Light,Us.Medium,Us.Heavy,Us.Success,Us.Warning,Us.Error;const gI=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",xI=()=>typeof document<"u"&&!!document.body,bI=()=>{if(xI())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{}},w2=e=>Array.isArray(e)?[...e]:[e],yI=e=>{if(gI()){try{const a=w2(e),c=a.length===1?a[0]:a;navigator.vibrate(c)}catch{}return}const t=w2(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(bI,n),n+=a+c},xo=e=>yI(e);function Y3({message:e}){const{t}=Ur();return s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-4",children:s.jsx(h0,{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 vI(){const{t:e}=Ur();return s.jsx(Y3,{message:e("terminal.initializing")})}const wI=({message:e,onRetry:t})=>{const{t:r}=Ur();return s.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:s.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":r("terminal.error"),children:[s.jsx("title",{children:r("terminal.error")}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})]})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"font-medium text-foreground",children:r("terminal.failedToLoad")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e||r("terminal.unknownError")})]}),t&&s.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:r("common.retry")})]})})};function qh(e){return Array.from(e)}function A2(e,t,r){return Math.max(t,Math.min(r,e))}function AI(e,t,r,n){const a=qh(e),c=qh(t);let l=A2(r,0,a.length);const d=A2(n,0,c.length);let f=0;for(;f<a.length&&f<c.length&&a[f]===c[f];)f++;let m=0;for(;m<a.length-f&&m<c.length-f&&a[a.length-1-m]===c[c.length-1-m];)m++;const x=a.length-f-m,y=c.slice(f,c.length-m).join(""),w=[];if(x>0||y){const v=f+x;l>v?w.push({left:l-v}):l<v&&w.push({right:v-l}),l=v,x>0&&(w.push({backspace:x}),l=f),y&&(w.push({insert:y}),l+=qh(y).length)}return l>d?w.push({left:l-d}):l<d&&w.push({right:d-l}),l=d,{ops:w,cursor:l}}function T2(e){const t=e.value,r=e.selectionStart??t.length;return qh(t.slice(0,r)).length}const yf=16,TI=10,S2=1.5,SI=1.8,C2=240,CI=125,_I=92;function kI(e,t,r){const n=Math.hypot(e,t),a=Math.abs(e),c=Math.abs(t),l=()=>a>=c*S2?e>0?"right":"left":c>=a*S2?t>0?"down":"up":"";if(r==="")return n>yf?l():"";if(n<TI)return"";if(n<=yf)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)*SI?d:r}function LI(e){const t=_I-yf,r=Math.min(Math.max((e-yf)/t,0),1);return C2-r*(C2-CI)}const II="termdock-open-terminal-directory",o1=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?:,;!?。、“”‘’])+/gu,EI=new RegExp(`^( *)(${o1.source})`,"u"),NI=/[,;:!?]+$/u,RI=/^[a-z][a-z\d+.-]*:\/\//iu;function MI(e){return!e||e==="/"||RI.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function Z3(e){const t=[];o1.lastIndex=0;let r;for(;(r=o1.exec(e))!==null;){const a=r[0].replace(NI,"");if(!MI(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 em(e){const t=[];for(const r of e.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return`/${t.join("/")}`}function jI(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function DI(e,t){const r=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(r.startsWith("/"))return em(r);if(r==="~"||r.startsWith("~/")){const n=t?jI(t):null;return n?em(`${n}/${r.slice(2)}`):null}return t?.startsWith("/")?em(`${t}/${r}`):null}function ph(e,t){const r=e.buffer.active.getLine(t-1),n=e.buffer.active.getLine(t);if(!r||!n||n.isWrapped)return null;const a=r.translateToString(!0).trimEnd(),c=n.translateToString(!0),l=Z3(a).at(-1),d=c.match(EI);if(!l||l.endIndex!==a.length||!l.text.endsWith("/")||!d||/^[~./]/u.test(d[2]))return null;const f=d[2];if(!f.includes("/")&&!/^[^/:]+\.[\p{L}\p{N}_-]+$/u.test(f))return null;let m=r.length-1;for(;m>=0&&!(r.getCell(m)?.getChars()||"").trim();)m-=1;const x=d[1].length;let y=0;for(let C=x;C<n.length;C+=1){const I=n.getCell(C);if(I?.getWidth()!==0){if(!I||/[\s/:]/u.test(I.getChars()||" "))break;y+=I.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 BI(e,t){const r=e.buffer.active;let n=t-1;if(!r.getLine(n))return null;for(;n>0&&(r.getLine(n)?.isWrapped||ph(e,n)!==null);)n-=1;let a=t-1;for(;a+1<r.length&&(r.getLine(a+1)?.isWrapped||ph(e,a+1)!==null);)a+=1;let c="";const l=[],d=[];for(let m=n;m<=a&&c.length<=2048;m+=1){const x=r.getLine(m);if(!x)break;const y=m>n?ph(e,m)??0:0;let w=x.length;if(m<a&&ph(e,m+1)!==null)for(;w>0&&!(x.getCell(w-1)?.getChars()||"").trim();)w-=1;for(let v=y;v<w;v+=1){const S=x.getCell(v);if(!S||S.getWidth()===0)continue;const C=S.getChars()||" ";c+=C;for(let I=0;I<C.length;I+=1)l.push({x:v+1,y:m+1}),d.push({x:v+Math.max(1,S.getWidth()),y:m+1})}}const f=c.trimEnd().length;return{text:c.slice(0,f),startPositions:l.slice(0,f),endPositions:d.slice(0,f)}}function QI(e,t){return{provideLinks(r,n){const a=BI(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 _2(e,t){if(!e||e.lines.length===0||!Number.isFinite(t)||t<=0)return 0;const r=Math.floor(t),n=Number.isFinite(e.lines.maxLength)&&e.lines.maxLength>0?Math.floor(e.lines.maxLength):null;let a=0;if(n!==null){const f=Math.max(0,n-r);e.ybase>f&&(e.ybase=f,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,f)),a++)}let c=Math.max(0,Math.floor(e.ybase)+r),l=n===null?c:Math.min(c,n),d=Math.max(0,l-e.lines.length);if(d>r){const f=Math.max(0,e.lines.length-r);e.ybase>f&&(e.ybase=f,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,f)),a++),c=Math.max(0,Math.floor(e.ybase)+r),l=n===null?c:Math.min(c,n),d=Math.max(0,l-e.lines.length)}for(let f=0;f<d;f++){const m=e.lines.length;if(e.lines.push(e.getBlankLine(void 0)),e.lines.length<=m)break;a++}return a}function k2(e,t=e.rows){const n=e._core?._bufferService?.buffers;return n?_2(n.normal,t)+_2(n.alt,t):0}function mh(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function PI(e,t,r){const n=mh(e.fontBoundingBoxAscent)+mh(e.fontBoundingBoxDescent),a=mh(e.actualBoundingBoxAscent)+mh(e.actualBoundingBoxDescent);return Math.max(1,Math.floor(Math.ceil(n||a||t)*r))}const Ec=8,gh=36,L2=10,OI=1.08,FI=1.16,xh=6,$I=.94,UI=.08,zI=.12,HI=88,WI=36,GI=10,VI=14,qI=52;function _d(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 YI=80,ZI=8;function bh(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function KI(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function XI(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 JI(e){const t="\x1B]52;";let r=0,n="";for(;r<e.length;){const a=e.indexOf(t,r);if(a===-1)return n+=e.slice(r),{cleaned:n,remainder:""};n+=e.slice(r,a);let c=-1,l=1;for(let m=a+t.length;m<e.length;m+=1){const x=e.charCodeAt(m);if(x===7){c=m,l=1;break}if(x===27&&m+1<e.length&&e[m+1]==="\\"){c=m,l=2;break}}if(c===-1)return{cleaned:n,remainder:e.slice(a)};const d=e.slice(a+t.length,c),f=d.indexOf(";");if(f>=0){const m=d.slice(f+1);if(m&&m!=="?"){const x=XI(m);x!==null&&navigator.clipboard?.writeText(x).catch(()=>{})}}r=c+l}return{cleaned:n,remainder:""}}function eE(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 tE=new Set(["visibility","bfcache","online"]),rE=5e5,nE=1e5,kd=260,Ld=140,I2=80;function sE(e){return!e}let yu=null;const iE=[{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:"⏺⏸⏹✓✗"}],aE=()=>{if(yu)return yu;if(typeof document>"u"||!("fonts"in document))return yu=Promise.resolve(),yu;const e=document.fonts;return yu=Promise.allSettled(iE.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),yu},E2=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 N2(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 oE(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 R2=new Map;function lE(e,t,r,n,a){if(typeof window>"u"||typeof document>"u")return null;const c=e.getBoundingClientRect();if(c.width<24||c.height<24)return null;const l=window.devicePixelRatio||1,d=`${r}::${n}::${a}::${l}::${t}`;let f=R2.get(d);if(!f)try{const w=document.createElement("canvas").getContext("2d");if(!w)return null;w.font=`${r}px ${t}`;const v=w.measureText("M"),C=(Math.floor(v.width*l)+Math.round(n))/l,I=PI(v,r,a);C>=1&&I>=1&&(f={cellWidth:C,cellHeight:I},R2.set(d,f))}catch{return null}if(!f)return null;const m=Math.max(2,Math.floor(c.width/f.cellWidth)),x=Math.max(2,Math.floor(c.height/f.cellHeight));return!Number.isFinite(m)||!Number.isFinite(x)?null:{cols:m,rows:x}}async function M2(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 cE(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 Id(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 tm(e,t,r){const n=t.row*e.cols+t.col,a=r.row*e.cols+r.col;if(n===a)return e.clearSelection(),!1;const c=Math.min(n,a),l=Math.max(n,a)+1,d=c%e.cols,f=Math.floor(c/e.cols);return e.select(d,f,l-c),!0}function j2(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function uE(e,t,r,n,a=!0){if(typeof window>"u")return{left:0,top:0};const c=window.visualViewport,l=c?.offsetLeft??0,d=c?.offsetTop??0,f=c?.width??window.innerWidth,m=c?.height??window.innerHeight,x=j2("--safe-top-inset"),y=j2("--safe-bottom-inset"),w=n?PL(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 I=zc(n.terminal),{start:R,end:B}=bf(n.anchor,n.focus,n.terminal.cols),z=Vh(n.terminal,R),O=Vh(n.terminal,B);if(z&&v.push({left:z.x-24,top:z.y-48,right:z.x+24,bottom:z.y+4}),O&&I){const $=O.y+I.cellH;v.push({left:O.x-24,top:$-4,right:O.x+24,bottom:$+48})}if(w){const $=n.anchor.row*n.terminal.cols+n.anchor.col,V=n.focus.row*n.terminal.cols+n.focus.col,Y=$<=V,le=w.right-w.left,pe=n.anchor.row===n.focus.row?Y?w.left+le*.25:w.right-le*.25:(w.left+w.right)/2,ee=Vh(n.terminal,n.focus),ke=ee&&I?ee.y+I.cellH/2:t;S={vertical:n.focus.row<n.anchor.row?"below":"above",alignX:pe,focusX:ee?.x??e,focusY:ke}}}const C=OL({clientX:e,clientY:t,viewport:{left:l,top:d+x,right:l+f,bottom:d+m-y},terminal:r,width:HI,height:WI,margin:GI,fingerGap:VI,selection:w,avoid:v,preference:S,selectionGap:qI});return{left:C.left-r.left,top:C.top-r.top}}const K3=L.forwardRef(({sessionKey:e,sessionId:t,isLayoutVisible:r=!0,chunks:n,onInput:a,onResize:c,onFlowControl:l,onTmuxScroll:d,tmuxScrollSensitivity:f=.55,onDoubleTap:m,onInputFocusChange:x,onMobileLongPressCopyResult:y,onMobilePasteResult:w,onReadyChange:v,onSizeSynchronizedChange:S,onWritesSettled:C,onWriteProgress:I,onCursorPositionChange:R,onDirectoryLinkActivate:B,terminalSettings:z,theme:O,className:$,enableTouchScroll:V,mobileLongPressMode:Y="arrows",autoFocus:le=!0,cursorVisible:be=!0,suppressSmoothScroll:pe=!1},ee)=>{const{t:ke}=Ur(),He=L.useRef(null),q=L.useRef(null),ce=L.useRef(null),qe=L.useRef(null),Ae=L.useRef(null),ve=L.useRef(pe);ve.current=pe;const Ie=L.useRef(null),Be=L.useRef(a),ne=L.useRef(c),Fe=L.useRef(x),Le=L.useRef(l),Re=L.useRef(v);Re.current=v;const Pe=L.useRef(S);Pe.current=S;const Ee=L.useRef(C);Ee.current=C;const oe=L.useRef(I);oe.current=I;const We=L.useRef(R);We.current=R;const rt=L.useRef(B);rt.current=B;const gt=L.useRef(z.rendererMode),ue=L.useRef(""),Ye=L.useRef(0),at=L.useRef(!1),Ne=L.useRef(null),Ge=L.useRef(0),Ce=L.useRef(0),H=L.useRef(!1),ae=L.useRef(null),ye=L.useRef(null),Ve=L.useRef(null),Je=L.useRef(!1),bt=L.useRef(null),Vt=L.useRef(()=>{}),Pt=L.useRef(null),mt=L.useRef(null),Zt=L.useRef(void 0),Ht=L.useRef(null),Kt=L.useRef(!1),Ot=L.useRef(0),Nt=L.useRef(""),me=L.useRef(null),Ze=L.useRef(null),ct=L.useRef(!1),Tt=L.useRef(typeof window<"u"?window.devicePixelRatio:1),X=L.useRef(!1),yt=L.useRef(!1),nt=L.useRef(null),_e=L.useRef(""),tr=L.useRef(0),Ke=L.useRef(null),kt=L.useRef(null),Ut=L.useRef(null),vt=L.useRef(0),wt=L.useRef(0),Mt=L.useRef(0),_t=L.useRef(null),fr=L.useRef(0),qt=L.useRef(0),Sr=L.useRef(!1),pn=L.useRef(0),[,dr]=L.useReducer(T=>T+1,0),[ge,Gr]=L.useReducer(T=>T+1,0),[ot,ft]=L.useState("loading"),[ir,Mn]=L.useState(null),[Xr,De]=L.useState(null);L.useEffect(()=>{const T=j=>{(j.target instanceof Element?j.target.closest("[data-termdock-terminal-dropzone]"):null)?.dataset.termdockTerminalDropzone===e&&De(String(j.detail))};return window.addEventListener("termdock:file-drop-error",T),()=>window.removeEventListener("termdock:file-drop-error",T)},[e]);const st=L.useMemo(()=>Fu("terminal"),[]),[xt,Br]=L.useState(!0),[Vr,Cr]=L.useState(!1);L.useEffect(()=>{if(!xt&&ot!=="loading"){Cr(!1);return}const T=window.setTimeout(()=>Cr(!0),160);return()=>window.clearTimeout(T)},[xt,ot]);const[qr,mn]=L.useState(!1),[on,zr]=L.useState({visible:!1,activeDir:""}),[un,Er]=L.useState(null),re=L.useRef(null),pt=L.useRef(!1),jt=L.useRef({active:!1,anchor:null,focus:null,dragging:null}),[nr,Ar]=L.useState(null),[Fr,Xt]=L.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),Zr=L.useRef(Fr);Zr.current=Fr;const Jt=L.useRef(null),[Pr,Hr]=L.useState({active:!1,text:""}),ps=L.useRef(null),Mr=L.useRef(null);Be.current=a,ne.current=c,Fe.current=x,Le.current=l,gt.current=z.rendererMode;const jn=L.useRef(le);jn.current=le;const Tr=L.useRef(be);Tr.current=be;const Jr=L.useRef(V);Jr.current=V;const ln=L.useRef(r);ln.current=r;const ks=sE(!!d),{rendererMode:Dr,fontFamily:en,fontSize:xn,fontWeight:K,fontWeightBold:ze,letterSpacing:Rt,lineHeight:Et,minimumContrastRatio:rr,drawBoldTextInBrightColors:jr,unicodeVersion:cr,customGlyphs:Cn,rescaleOverlappingGlyphs:Ls,fontLigatures:Xn,enableImages:cn,smoothScrolling:dn}=z,_r=Dr==="webgl",Or=L.useCallback(()=>{re.current!==null&&(clearTimeout(re.current),re.current=null),Er(null)},[]),Gn=L.useCallback((T,j)=>{re.current!==null&&(clearTimeout(re.current),re.current=null),pt.current=!1,Er(T),!j?.persistent&&(re.current=setTimeout(()=>{re.current=null,Er(null)},3e3))},[]);L.useEffect(()=>{if(!un)return;const T=()=>{jt.current.active||Or()},j=()=>Or();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",j),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",j),document.removeEventListener("visibilitychange",j)}},[Or,un]),L.useEffect(()=>()=>{re.current!==null&&(clearTimeout(re.current),re.current=null)},[]);const Vn=L.useCallback(()=>{const T=ce.current,j=He.current,Q=jt.current;if(!T||!j||!Q.active||!Q.anchor||!Q.focus){Ar(null);return}const F=j.getBoundingClientRect(),xe=zc(T)?.cellH??16,{start:Se,end:Oe}=bf(Q.anchor,Q.focus,T.cols),Xe=Q.dragging==="start"?Q.focus:Q.dragging==="end"?Q.anchor:Se,dt=Q.dragging==="end"?Q.focus:Q.dragging==="start"?Q.anchor:Oe,er=(or,$r)=>{const nn=Vh(T,or);return nn?{left:nn.x-F.left,top:$r?nn.y-F.top:nn.y+xe-F.top}:null};Ar({start:er(Xe,!0),end:er(dt,!1)})},[]),gn=L.useCallback(T=>{const j=ce.current,Q=He.current,F=jt.current;if(!j||!Q||!F.active||!F.anchor||!F.focus)return;if(F.dragging){Or();return}const xe=Q.getBoundingClientRect(),Se={x:(xe.left+xe.right)/2,y:(xe.top+xe.bottom)/2};Gn(uE(T?.x??Se.x,T?.y??Se.y,xe,{terminal:j,anchor:F.anchor,focus:F.focus},T!==void 0),{persistent:!0})},[Or,Gn]),Jn=L.useCallback(()=>{const T=jt.current;T.active=!1,T.anchor=null,T.focus=null,T.dragging=null,Ar(null),Or()},[Or]);L.useEffect(()=>{if(!nr)return;const T=ce.current;if(!T)return;const j=T.onScroll(()=>{Vn(),gn()}),Q=T.onResize(()=>Jn());return()=>{j.dispose(),Q.dispose()}},[nr,Vn,gn,Jn]),L.useEffect(()=>{V||Fe.current?.(!1)},[V]);const kr=L.useCallback((T,j,Q)=>{const F=(Q.element?.offsetWidth||0)/Q.cols||8,xe=(Q.element?.offsetHeight||0)/Q.rows||16,Se=Math.max(1,Math.min(Q.cols,Math.floor(T/F)+1)),Oe=Math.max(1,Math.min(Q.rows,Math.floor(j/xe)+1));return{x:Se,y:Oe}},[]),Lr=L.useCallback((T,j,Q)=>{const F=ce.current;if(!F)return!1;const xe=T>0?-1:1;if(F.modes?.mouseTrackingMode!=="none"){let Se,Oe;if(j!==void 0&&Q!==void 0){const er=kr(j,Q,F);Se=er.x,Oe=er.y}else Se=F.buffer.active.cursorX+1,Oe=F.buffer.active.cursorY+1;const dt=`\x1B[<${xe>0?64:65};${Se};${Oe}M`;return Be.current(dt),!0}if(F.buffer.active.type==="alternate"){const Se=xe>0?"\x1B[A":"\x1B[B";return Be.current(Se),!0}return null},[kr]),pr=L.useCallback(T=>{const j=ce.current;if(!j)return!1;const Q=Nc(ce.current,xn,Et),F=Ot.current+T,xe=Math.trunc(F/Q);return Ot.current=F-xe*Q,xe!==0?(j.scrollLines(xe),!0):!1},[xn,Et]),ns=L.useCallback(T=>{if(!ce.current)return!1;const F=Nc(ce.current,xn,Et)/Math.max(.1,f),xe=Ot.current+T;let Se=Math.trunc(xe/F);if(Ot.current=xe-Se*F,Se===0&&Math.abs(xe)>=F/3&&(Se=xe>0?1:-1,Ot.current=0),Se===0)return!1;const Oe=Se>0?"down":"up",Xe=Math.max(1,Math.min(Math.abs(Se),10));return d(Oe,Xe),!0},[xn,Et,d,f]),Un=L.useRef(Lr);Un.current=Lr;const En=L.useRef(pr);En.current=pr;const kn=L.useRef(ns);kn.current=ns;const ss=L.useRef(d);ss.current=d;const Wr=L.useRef({pointerId:null,tmuxActiveAtDown:!1});L.useEffect(()=>{if(!V)return;const T=He.current;if(!T)return;const j=F=>{F.pointerType==="touch"&&(Wr.current.pointerId=F.pointerId,Wr.current.tmuxActiveAtDown=!!ss.current)},Q=F=>{F.pointerType==="touch"&&Wr.current.pointerId===F.pointerId&&(Wr.current.pointerId=null,Wr.current.tmuxActiveAtDown=!1)};return T.addEventListener("pointerdown",j,{capture:!0,passive:!0}),T.addEventListener("pointerup",Q,{capture:!0,passive:!0}),T.addEventListener("pointercancel",Q,{capture:!0,passive:!0}),()=>{T.removeEventListener("pointerdown",j,!0),T.removeEventListener("pointerup",Q,!0),T.removeEventListener("pointercancel",Q,!0)}},[V]);const tn=L.useCallback(()=>{if(Sr.current)return!1;const T=Wr.current;return T.pointerId!==null?!T.tmuxActiveAtDown:!ss.current},[]),G=L.useCallback((T,j,Q)=>{const F=Un.current(T,j,Q);return F!==null?F:ss.current?kn.current(T):En.current(T)},[]),je=L.useCallback((T,j)=>{if(performance.now()<=qt.current){qt.current=0;return}const Q=ce.current;if(Q&&Q.modes?.mouseTrackingMode!=="none"){const F=kr(T,j,Q),xe=F.x,Se=F.y,Oe=`\x1B[<0;${xe};${Se}M`,Xe=`\x1B[<0;${xe};${Se}m`;Be.current(Oe),Be.current(Xe)}},[kr]),$e=L.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),et=L.useCallback((T=700)=>{_t.current=null,fr.current=$e()+T},[$e]),it=L.useCallback(()=>Jr.current&&$e()<=fr.current,[$e]),Ct=L.useCallback(()=>{const T=mt.current;return!T||typeof document>"u"?!1:document.activeElement===T},[]),Lt=L.useCallback(()=>{if(typeof window>"u")return!1;const T=Xe=>{if(typeof document>"u")return 0;const dt=Number.parseFloat(document.documentElement.style.getPropertyValue(Xe)||"0");return Number.isFinite(dt)?dt:0},j=T("--kb-height");if(j>0)return j>=I2;const Q=window.visualViewport;if(!Q)return!1;const F=T("--app-base-vh")||window.innerHeight,xe=T("--safe-bottom-inset"),Se=Q.height+Q.offsetTop;return Math.max(0,Math.round(F-Se-xe))>=I2},[]),Bt=L.useCallback(()=>{Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),kt.current=null},[]),ht=L.useCallback(T=>{const j=ce.current;let Q="";for(const F of T)F.left&&(Q+=(j?bh(j,"D"):"\x1B[D").repeat(F.left)),F.right&&(Q+=(j?bh(j,"C"):"\x1B[C").repeat(F.right)),F.backspace&&(Q+="".repeat(F.backspace)),F.insert&&(Q+=F.insert);return Q},[]),Qt=L.useCallback(T=>{const j=T.value,Q=_d(j),F=_e.current;if(!(Jr.current&&!Q.includes("\r")&&!F.includes("\r"))){if(Q===F)return;let er=0;for(;er<F.length&&er<Q.length&&F[er]===Q[er];)er++;const or=F.length-er;or>0&&Be.current("".repeat(or));const $r=Q.slice(er);if($r){try{ce.current?.clearSelection()}catch{}Be.current($r)}_e.current=Q,tr.current=Array.from(Q).length;return}const Se=T2(T),{ops:Oe,cursor:Xe}=AI(F,Q,tr.current,Se),dt=ht(Oe);if(dt){if(Oe.some(er=>er.insert))try{ce.current?.clearSelection()}catch{}Be.current(dt)}_e.current=Q,tr.current=Xe},[ht]),W=L.useCallback((T,j)=>{const Q=T.value,F=_d(Q),xe=_e.current;if(F===xe){Bt();return}let Se=0;for(;Se<xe.length&&Se<F.length&&xe[Se]===F[Se];)Se++;const Oe=xe.length-Se;if(V&&!j?.immediate&&Oe>=ZI){kt.current=T,Ke.current!==null&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{Ke.current=null;const dt=kt.current;kt.current=null,dt&&Qt(dt)},YI);return}Bt(),Qt(T)},[Bt,V,Qt]),N=L.useCallback(T=>{W(T,{immediate:!0}),Be.current("\r"),T.value="",_e.current="",tr.current=0},[W]),U=L.useCallback((T,j,Q)=>{if(!T)return;Bt();const F=j??mt.current;F&&(F.value=""),_e.current="",tr.current=0;try{ce.current?.clearSelection()}catch{}Jn();const xe=zL(T,Q);return Be.current(xe,{skipModifierTransform:!0,consumeModifier:Q?.consumeModifier,targeted:Q?.targeted,ownedPaste:Q?.ownedPaste})},[Bt]),Z=L.useCallback((T,j)=>{const Q=_d(T);return Q?(De(null),Tp(Q)||(U(Q,j,{paste:!0,submitAfterPaste:!1}),Or()),!0):!1},[Or,U]);L.useEffect(()=>n8(T=>{if(T.sessionKey!==e||T.paths.length===0)return;const j=T.paths.map(Dc).join(" ");U(`${j} `);try{mt.current?.focus({preventScroll:!0})}catch{}}),[U,e]);const fe=L.useCallback(async(T,j)=>{De(null);try{const Q=await l3(T);return Tp(`${Dc(Q)} `)||(U(`${Dc(Q)} `,j),Or()),!0}catch(Q){return De(Q instanceof Error?Q.message:"Image upload failed"),!1}},[Or,U]),Qe=L.useCallback(async(T,j)=>{De(null);try{const Q=await d3(T);if(!Q.length)return!1;const F=`${Q.map(Dc).join(" ")} `;return Tp(F)||(U(F,j),Or()),!0}catch(Q){return De(Q instanceof Error?Q.message:"File upload failed"),!1}},[Or,U]),we=L.useCallback(async(T,j)=>{De(null);try{const Q=d0()?.targetPeerId;let F;if(vo()?.readClipboardFiles){try{const{files:Oe,paths:Xe}=await u3();if(Xe.length)return Z(`${Xe.map(Dc).join(" ")} `,T);if(Oe.length)return Qe(Oe,T)}catch(Oe){if(Oe instanceof i0)throw Oe;F=Oe}if(d0()?.targetPeerId!==Q)throw new Error("目标服务已切换,请重新粘贴")}if(j?.files.length){const Oe=j.files[0];return j.files.length===1&&Oe.type.startsWith("image/")?fe(Oe,T):Qe(j.files,T)}if(j?.text)return Z(j.text,T);if(!vo()?.readClipboardImage){if(typeof navigator.clipboard?.read=="function"){const Oe=await navigator.clipboard.read(),Xe=await c3({read:async()=>Oe});if(Xe.length)return Qe(Xe,T);const dt=await pf({read:async()=>Oe});if(dt)return fe(dt,T);for(const er of Oe){if(!er.types.includes("text/plain"))continue;const or=await(await er.getType("text/plain")).text();return Z(or,T)}return De("剪贴板未提供可读取的文字、图片或视频;视频可通过文件按钮选择上传。"),!1}return navigator.clipboard?.readText?Z(await navigator.clipboard.readText(),T):!1}const xe=await pf(navigator.clipboard);if(xe)return fe(xe,T);if(!navigator.clipboard?.readText){if(F)throw F;return!1}const Se=await navigator.clipboard.readText();if(!Se&&F)throw F;return Z(Se,T)}catch(Q){return De(Q instanceof Error?Q.message:"Clipboard read failed"),!1}},[Qe,fe,Z]),lt=L.useCallback(T=>{if(Jt.current&&!T?.repositionFrozen)return null;const j=ce.current;if(!j||!j.element)return null;const Q=zc(j),xe=j.element.querySelector(".xterm-screen")??j.element,Se=xe.getBoundingClientRect(),Oe=Q?.cellW??(Se.width>0&&j.cols>0?Se.width/j.cols:8),Xe=Q?.cellH??(Se.height>0&&j.rows>0?Se.height/j.rows:17),dt=mt.current;let er=Zt.current;dt&&(er===void 0||er!==null&&(!er.isConnected||!er.contains(dt)))&&(er=$L(dt),Zt.current=er);const or=j.buffer.active,$r=or.cursorX*Oe,nn=or.cursorY*Xe,Pn=UL(xe,er??null,$r,nn),yr=Math.round(Pn.x),wn=Math.round(Pn.y),us={x:yr,y:wn,cellW:Oe,cellH:Xe,cursorX:or.cursorX};return Zr.current=us,Jt.current&&T?.repositionFrozen&&(Jt.current={...us}),Xt(Bs=>Math.abs(Bs.x-yr)<.5&&Math.abs(Bs.y-wn)<.5&&Math.abs(Bs.cellW-Oe)<.5&&Math.abs(Bs.cellH-Xe)<.5&&Bs.cursorX===or.cursorX?Bs:us),us},[]),At=L.useRef(lt);At.current=lt,L.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,At.current({repositionFrozen:!0})})})};return window.visualViewport?.addEventListener("resize",Q),window.visualViewport?.addEventListener("scroll",Q),document.addEventListener("termdock:viewport-keyboard-change",Q),()=>{T!==null&&window.cancelAnimationFrame(T),j!==null&&window.cancelAnimationFrame(j),window.visualViewport?.removeEventListener("resize",Q),window.visualViewport?.removeEventListener("scroll",Q),document.removeEventListener("termdock:viewport-keyboard-change",Q)}},[V]);const br=L.useCallback(T=>{let j=0;for(const Q of T){const F=Q.codePointAt(0)??0,xe=F>=4352&&F<=4447||F>=11904&&F<=12350||F>=12353&&F<=13311||F>=13312&&F<=19903||F>=19968&&F<=40959||F>=40960&&F<=42191||F>=44032&&F<=55203||F>=63744&&F<=64255||F>=65072&&F<=65103||F>=65280&&F<=65376||F>=65504&&F<=65510||F>=127744&&F<=129791;j+=xe?2:1}return j},[]),It=L.useCallback(T=>{const j=ce.current,{cellW:Q,cellH:F}=Fr;if(!j||!T)return{width:Math.max(1,Math.round(Q)),height:Math.max(1,Math.round(F)),whiteSpace:"pre"};const Se=Jt.current?.cursorX??j.buffer.active.cursorX,Oe=Math.max(1,j.cols),Xe=Math.max(1,br(T)),dt=Math.max(1,Oe-Se);if(Xe<=dt)return{width:Math.max(1,Math.round(Xe*Q)),height:Math.max(1,Math.round(F)),whiteSpace:"pre"};const er=Xe-dt,$r=1+Math.ceil(er/Oe);return{width:Math.max(1,Math.round(dt*Q)),height:Math.max(1,Math.round($r*F)),whiteSpace:"pre-wrap"}},[Fr,br]),rn=L.useCallback(()=>{Zt.current=void 0;const T=At.current();Jt.current={...T??Zr.current}},[]),yn=L.useCallback(()=>{Jt.current=null},[]),hn=L.useCallback(T=>{if(!X.current&&Jt.current===null)return!1;if(X.current=!1,Jt.current=null,Bt(),nt.current!==null&&(clearTimeout(nt.current),nt.current=null),yt.current=!1,T){T.value=_e.current;try{T.setSelectionRange(T.value.length,T.value.length)}catch{}}return Hr(j=>j.active||j.text?{active:!1,text:""}:j),!0},[Bt]),Dn=L.useCallback((T,j)=>{const Q=mt.current;if(Q)try{Q.removeAttribute("readonly");const xe=typeof document<"u"&&document.activeElement===Q&&!Lt(),Se=$e(),Oe=Se-pn.current;pn.current=Se,xe&&Oe>600?(Q.blur(),Q.removeAttribute("readonly"),Q.focus(),pn.current=$e()):Q.focus()}catch{}},[Lt,$e]),zn=L.useCallback(T=>{wt.current=$e()+T},[$e]),hr=L.useCallback(()=>V?$e()<=wt.current:!1,[V,$e]),Dt=L.useCallback(T=>{zn(T),Mt.current=$e()},[zn,$e]),Bn=L.useCallback(()=>{V&&mt.current?.removeAttribute("readonly")},[V]),qn=L.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),[]),Ga=L.useCallback(T=>{if(Bn(),Dt(kd),!V||T.pointerType!=="touch"){_t.current=null;return}const j=T.target;if(qn(j)){et();return}un&&!(j instanceof HTMLElement&&j.closest('[data-terminal-copy-popover="true"]'))&&Or(),_t.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,moved:!1}},[Or,V,Dt,qn,un,Bn,et]),Qn=L.useCallback(T=>{Dt(kd);const j=_t.current;!j||j.pointerId!==T.pointerId||Math.hypot(T.clientX-j.startX,T.clientY-j.startY)>12&&(j.moved=!0)},[Dt]),is=L.useCallback(T=>{Dt(Ld);const j=_t.current;_t.current=null,!(!V||T.pointerType!=="touch")&&(!j||j.pointerId!==T.pointerId||j.moved||it()||Dn(T.clientX,T.clientY))},[V,Dt,Dn,it]),zi=L.useCallback(()=>{_t.current=null,Dt(Ld)},[Dt]),ha=L.useMemo(()=>({enableKinetic:!0}),[]),bs=L.useRef(()=>!1),Va=L.useRef(Dn);Va.current=Dn;const So=L.useCallback((T,j)=>{it()||Va.current(T,j)},[it]),Hn=L.useRef(m);Hn.current=m;const fa=L.useRef(y);fa.current=y;const ms=L.useRef(w);ms.current=w;const Ia=L.useCallback(()=>{if(pt.current)return;pt.current=!0,et();const T=ce.current,j=T?.hasSelection()?T.getSelection():"";try{T?.clearSelection()}catch{}Js.flushSync(()=>{Jn()}),(async()=>{const Q=await M2(j);fa.current?.(Q)})()},[Jn,et]),as=L.useCallback(T=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:T}}))},[]),{setupTouchScroll:qa,stopAllScroll:ei}=mI(He,{...ha,shouldCaptureTouch:bs.current,canStartScrollGesture:tn,onScroll:G,onScrollWithCoords:G,onClickWithCoords:je,onTap:So,onClaimChange:as,tapThreshold:12,gestureName:`normal-scroll:${e}`});L.useEffect(()=>{if(!V)return;mt.current?.setAttribute("readonly","");const T=qa();return()=>{T()}},[V,qa]),L.useEffect(()=>{if(!V)return;let T=Lt();const j=()=>{const Q=Lt();if(T&&!Q){const F=mt.current;F&&typeof document<"u"&&document.activeElement===F&&(F.setAttribute("readonly",""),F.blur())}T=Q};return window.visualViewport?.addEventListener("resize",j),window.visualViewport?.addEventListener("scroll",j),document.addEventListener("termdock:viewport-keyboard-change",j),()=>{window.visualViewport?.removeEventListener("resize",j),window.visualViewport?.removeEventListener("scroll",j),document.removeEventListener("termdock:viewport-keyboard-change",j)}},[V,Lt]),L.useEffect(()=>{if(!V)return;const T=He.current;if(!T)return;const j=F=>{const Se=F.sourceCapabilities?.firesTouchEvents===!0,Oe=$e()-Mt.current<=1200;return!Se&&!Oe?!1:T.contains(F.target)},Q=F=>{j(F)&&(F.cancelable&&F.preventDefault(),F.stopImmediatePropagation(),F.stopPropagation())};return T.addEventListener("mousedown",Q,{capture:!0,passive:!1}),T.addEventListener("mouseup",Q,{capture:!0,passive:!1}),T.addEventListener("click",Q,{capture:!0,passive:!1}),document.addEventListener("mouseup",Q,{capture:!0,passive:!1}),()=>{T.removeEventListener("mousedown",Q,!0),T.removeEventListener("mouseup",Q,!0),T.removeEventListener("click",Q,!0),document.removeEventListener("mouseup",Q,!0)}},[V,$e]);const ti=L.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),Hs=L.useCallback(()=>{const T=ti.current;T.rafId!==null&&(cancelAnimationFrame(T.rafId),T.rafId=null)},[]),Ya=L.useCallback((T,j,Q)=>{const F=ce.current;if(!F||!F.element||!F.cols||!F.rows)return null;const xe=ti.current,Se=F.element.getBoundingClientRect(),Oe=j??xe.lastX??Se.left+Se.width/2,Xe=Q??xe.lastY??Se.top+Se.height/2,dt=Oe-Se.left,er=Xe-Se.top,or=F.element.offsetWidth/F.cols||8,$r=F.element.offsetHeight/F.rows||16,nn=Math.max(1,Math.min(F.cols,Math.floor(dt/or)+1)),Pn=Math.max(1,Math.min(F.rows,Math.floor(er/$r)+1));return`\x1B[<${T==="up"?64:65};${nn};${Pn}M`},[]),Is=L.useCallback((T,j,Q,F)=>{if(j<=0)return;const xe=Ya(T,Q,F);xe&&Be.current(j===1?xe:xe.repeat(j))},[Ya]),pa=L.useRef(Is);pa.current=Is;const dl=L.useRef(()=>{}),Za=L.useCallback(()=>{const j=Nc(ce.current,xn,Et)/Math.max(.1,f),Q=1+ti.current.instantSpeed*.1;return j/Math.min(6,Q)},[xn,Et,f]),os=L.useCallback(()=>{const T=ti.current;T.rafId=null;const j=Za();let Q=0,F=0;for(;Q+F<xh&&T.remainder>=j;)T.remainder-=j,F++;for(;Q+F<xh&&T.remainder<=-j;)T.remainder+=j,Q++;if(F>0&&Is("down",F),Q>0&&Is("up",Q),Q+F>0)T.rafId=requestAnimationFrame(os);else if(T.pointerId!==null&&Math.abs(T.remainder)>=j/3){const Se=T.remainder>0?"down":"up";T.remainder=0,Is(Se,1),T.rafId=requestAnimationFrame(os)}},[Za,Is]),js=L.useCallback(()=>{const T=ti.current;T.rafId===null&&typeof requestAnimationFrame<"u"&&(T.rafId=requestAnimationFrame(os))},[os]),Hi=L.useCallback(T=>{if(T.pointerType!=="touch")return!1;Hs();const j=ti.current;return j.pointerId=T.pointerId,j.lastX=T.clientX,j.lastY=T.clientY,j.startX=T.clientX,j.startY=T.clientY,j.gestureAxis=null,j.remainder=0,j.velocity=0,j.instantSpeed=0,j.didScroll=!1,!1},[Hs]),xi=L.useCallback((T,j)=>{if(Sr.current)return j?"release":"neutral";if(performance.now()<=qt.current)return"neutral";const Q=ti.current;if(T.pointerType!=="touch"||T.pointerId!==Q.pointerId||Q.lastY==null)return"neutral";if(Q.gestureAxis===null&&Q.startX!==null&&Q.startY!==null){const Se=Math.abs(T.clientX-Q.startX),Oe=Math.abs(T.clientY-Q.startY);if(Se>L2||Oe>L2){if(Se>Oe*OI)return Q.gestureAxis="x","release";Oe>Se*FI&&(Q.gestureAxis="y")}}if(Q.gestureAxis==="x")return Q.lastX=T.clientX,Q.lastY=T.clientY,"release";if(Q.gestureAxis===null)return Q.lastX=T.clientX,Q.lastY=T.clientY,"neutral";const F=T.clientY-Q.lastY;Q.lastX=T.clientX,Q.lastY=T.clientY;const xe=-F;if(Q.remainder+=xe,Q.instantSpeed=Math.abs(xe),Q.velocity=Q.velocity*.45+xe*.55,j){const Oe=Nc(ce.current,xn,Et)/Math.max(.1,f);Math.abs(Q.remainder)>=Oe/3&&(Q.didScroll=!0,js())}return"claim"},[xn,Et,f,js]),bi=L.useCallback(T=>{const j=ti.current;if(T.pointerType!=="touch"||T.pointerId!==j.pointerId)return;if(Hs(),j.pointerId=null,j.lastX=null,j.lastY=null,j.startX=null,j.startY=null,j.instantSpeed=0,j.gestureAxis==="x"){j.gestureAxis=null;return}j.gestureAxis=null;const F=Nc(ce.current,xn,Et)/Math.max(.1,f);if(j.didScroll&&Math.abs(j.velocity)>F*UI){const xe=()=>{j.velocity*=$I,j.remainder+=j.velocity;const Se=1+Math.abs(j.velocity)*.1,Oe=F/Math.min(6,Se);if(Math.abs(j.velocity)<F*zI){if(Math.abs(j.remainder)>=Oe/3){const er=j.remainder>0?"down":"up";Is(er,1),j.remainder=0}j.velocity=0,j.rafId=null;return}let Xe=0,dt=0;for(;Xe+dt<xh&&j.remainder>=Oe;)j.remainder-=Oe,dt++;for(;Xe+dt<xh&&j.remainder<=-Oe;)j.remainder+=Oe,Xe++;dt>0&&Is("down",dt),Xe>0&&Is("up",Xe),j.rafId=requestAnimationFrame(xe)};j.rafId=requestAnimationFrame(xe)}else Math.abs(j.remainder)>=F/3&&js();j.didScroll&&T.stopImmediatePropagation()},[Hs,Is,js,f,xn,Et]),hl=L.useCallback(T=>{const j=ti.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]);v2({name:`tmux-scroll:${e}`,priority:fI,container:()=>He.current,onPointerDown:V&&d?Hi:void 0,onPointerMove:V&&d?xi:void 0,onPointerUp:V&&d?bi:void 0,onPointerCancel:V&&d?hl:void 0});const ri=L.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=L.useRef(null);Uo.current=He.current;const ma=Uo,fl=Be,pl=L.useRef(Y);pl.current=Y;const ls=L.useCallback(T=>{const j=ri.current;j.gestureLocked!==T&&(j.gestureLocked=T,as(T))},[as]),Ds=L.useCallback(()=>{const T=ri.current;T.edgeScrollTimer!==null&&(clearInterval(T.edgeScrollTimer),T.edgeScrollTimer=null),T.edgeScrollDir=0},[]),Ri=L.useCallback(T=>{const j=ce.current,Q=ri.current;if(j){if(Q.mode==="copy"&&Q.copyStart){Q.copyDidSelect=tm(j,Q.copyStart,T)||Q.copyDidSelect;return}if(Q.mode==="adjust"){const F=jt.current;if(!F.active||!F.anchor)return;F.focus=QL(j,T),tm(j,F.anchor,F.focus),Vn()}}},[Vn]),zo=L.useCallback((T,j)=>{const Q=ce.current,F=ri.current;if(!Q)return;const xe=zc(Q);if(!xe)return;const Se=xe.originTop,Oe=xe.originTop+Q.rows*xe.cellH,Xe=Math.max(28,xe.cellH*1.5),dt=j-Se,er=Oe-j;let or=0,$r=0;if(dt<Xe?(or=-1,$r=Math.min(1,(Xe-dt)/Xe)):er<Xe&&(or=1,$r=Math.min(1,(Xe-er)/Xe)),F.edgeClientX=T,F.edgeClientY=j,or===0){Ds();return}F.edgeScrollDir=or,F.edgeScrollLines=1+Math.round($r*5),F.edgeScrollTimer===null&&(F.edgeScrollTimer=setInterval(()=>{const nn=ce.current,Pn=ri.current;if(!nn||Pn.edgeScrollDir===0)return;if(Pn.mode!=="copy"&&Pn.mode!=="adjust"){Ds();return}nn.scrollLines(Pn.edgeScrollDir*Pn.edgeScrollLines);const yr=Id(nn,Pn.edgeClientX,Pn.edgeClientY-gh);yr&&Ri(yr)},60))},[Ri,Ds]),Dl=L.useCallback(T=>{if(T.pointerType!=="touch")return!1;const j=ma.current;if(!j)return!1;const Q=T.target;if(!(Q instanceof HTMLElement)||!j.contains(Q)||Q.closest('[data-mobile-keyboard="true"]'))return!1;const F=ri.current;F.longPressMode=pl.current;const xe=jt.current;if(xe.active&&F.pointerId===null){const Se=Q.closest("[data-selection-handle]");if(Se instanceof HTMLElement){const Oe=ce.current,Xe=Se.dataset.selectionHandle==="start"?"start":"end";if(Oe&&xe.anchor&&xe.focus){const dt=bf(xe.anchor,xe.focus,Oe.cols);return xe.anchor=Xe==="start"?dt.end:dt.start,xe.focus=Xe==="start"?dt.start:dt.end,xe.dragging=Xe,Or(),F.pointerId=T.pointerId,F.tapStartX=T.clientX,F.tapStartY=T.clientY,F.tapDidMove=!1,F.mode="adjust",Sr.current=!0,et(1800),mt.current?.setAttribute("readonly",""),ei(),Hs(),xo(Ec),ls(!0),!0}}if(!Q.closest("[data-terminal-copy-popover]")){Jn();try{ce.current?.clearSelection()}catch{}}}if(F.pointerId!==null)return!0;if(Sr.current=!1,Hn.current){const Se=performance.now(),Oe=T.clientX,Xe=T.clientY;if(F.lastTapTime!==0&&Se-F.lastTapTime<=300&&Math.hypot(Oe-F.lastTapX,Xe-F.lastTapY)<=25)return xo(Ec),qt.current=performance.now()+500,Hn.current?.(),mn(!0),Mr.current&&clearTimeout(Mr.current),Mr.current=setTimeout(()=>mn(!1),400),F.lastTapTime=0,!0}return F.holdTimer!==null&&(clearTimeout(F.holdTimer),F.holdTimer=null),F.joystickRepeatTimer!==null&&(clearTimeout(F.joystickRepeatTimer),F.joystickRepeatTimer=null),F.joystickDir="",F.copyStart=null,F.copyDidSelect=!1,F.pointerId=T.pointerId,F.originX=T.clientX,F.originY=T.clientY,F.tapStartX=T.clientX,F.tapStartY=T.clientY,F.tapDidMove=!1,F.mode="holding",F.longPressMode==="copy"&&ls(!0),F.holdTimer=setTimeout(()=>{if(F.holdTimer=null,F.mode==="holding"){if(F.longPressMode==="copy"){const Se=ce.current,Oe=Se?Id(Se,F.tapStartX,F.tapStartY):null;if(!Se||!Oe){F.mode="idle";return}F.mode="copy",Sr.current=!0,et(1800),mt.current?.setAttribute("readonly",""),F.copyStart=Oe,F.copyDidSelect=!1,ei(),Hs(),Se.clearSelection(),xo(Ec),ls(!0);return}F.mode="arrow",Sr.current=!0,et(1e3),ei(),Hs(),xo(Ec),ls(!0),requestAnimationFrame(()=>{zr({visible:!0,activeDir:""})})}},350),!0},[ls,Or,Jn]),Es=L.useCallback((T,j)=>{if(T.pointerType!=="touch")return"neutral";const Q=ri.current;if(Q.mode==="arrow"&&T.pointerId!==Q.pointerId||Q.mode==="copy"&&T.pointerId!==Q.pointerId||Q.mode!=="arrow"&&Q.mode!=="copy"&&T.pointerId!==Q.pointerId)return"neutral";const F=T.clientX-Q.tapStartX,xe=T.clientY-Q.tapStartY;if(Math.hypot(F,xe)>10&&(Q.tapDidMove=!0),Q.mode==="holding"){if(!j)return Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Sr.current=!1,Q.mode="idle","neutral";const Se=T.clientX-Q.originX,Oe=T.clientY-Q.originY;return Q.longPressMode==="copy"&&Math.hypot(Se,Oe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Sr.current=!1,Q.mode="idle","release"):Math.hypot(Se,Oe)>20?(Q.holdTimer!==null&&(clearTimeout(Q.holdTimer),Q.holdTimer=null),ls(!1),Q.mode="idle","release"):"claim"}if(Q.mode==="adjust"){if(!j)return"claim";ei();const Se=ce.current,Oe=jt.current;if(!Se||!Oe.active||!Oe.anchor||!Oe.focus)return"claim";const Xe=Id(Se,T.clientX,T.clientY-gh);return Xe&&(Ri(Xe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="copy"){if(!j)return"claim";ei();const Se=ce.current;if(!Se||!Q.copyStart)return"claim";const Oe=Id(Se,T.clientX,T.clientY-gh);return Oe&&(Ri(Oe),zo(T.clientX,T.clientY)),"claim"}if(Q.mode==="arrow"){if(!j)return"claim";const Se={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},Oe=T.clientX-Q.tapStartX,Xe=T.clientY-Q.tapStartY,dt=kI(Oe,Xe,Q.joystickDir);if(dt&&dt!==Q.joystickDir&&(Q.originX=T.clientX,Q.originY=T.clientY),dt){const er=T.clientX-Q.originX,or=T.clientY-Q.originY,$r=Math.hypot(er,or);if(Q.repeatIntervalMs=LI($r),dt!==Q.joystickDir){Q.joystickRepeatTimer!==null&&clearTimeout(Q.joystickRepeatTimer);const nn=Q.joystickDir==="";Q.joystickDir=dt,fl.current(Se[dt]);const Pn=performance.now();Pn-Q.lastHapticTime>120&&(xo(Ec),Q.lastHapticTime=Pn);const yr=nn?400:300;Q.joystickRepeatTimer=setTimeout(function wn(){if(Q.joystickDir!==dt)return;fl.current(Se[dt]);const us=performance.now();us-Q.lastHapticTime>120&&(xo(Ec),Q.lastHapticTime=us),Q.joystickRepeatTimer=setTimeout(wn,Q.repeatIntervalMs)},yr)}zr({visible:!0,activeDir:dt})}else Q.joystickRepeatTimer!==null&&(clearTimeout(Q.joystickRepeatTimer),Q.joystickRepeatTimer=null),Q.joystickDir="",zr({visible:!0,activeDir:""});return"claim"}return"neutral"},[ls,Ri,zo]),Ea=L.useCallback(T=>{if(T.pointerType!=="touch"||T.pointerId!==ri.current.pointerId)return;const j=ri.current;if(j.mode==="copy"){ei(),Hs(),Ds(),ls(!1);const F=ce.current;let xe=null;if(F&&j.copyStart&&(xe=Id(F,T.clientX,T.clientY-gh),xe&&(j.copyDidSelect=tm(F,j.copyStart,xe)||j.copyDidSelect)),F&&j.copyDidSelect&&F.hasSelection()&&j.copyStart){const Se=jt.current;Se.active=!0,Se.anchor=j.copyStart,Se.focus=xe??j.copyStart,Se.dragging=null,Vn(),gn({x:T.clientX,y:T.clientY}),et(1800),xo(Ec)}else fa.current?.(!1);j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle",Sr.current=!1;return}if(j.mode==="adjust"){ei(),Hs(),Ds(),ls(!1),jt.current.dragging=null,Vn(),gn({x:T.clientX,y:T.clientY}),et(1800),j.pointerId=null,j.mode="idle",Sr.current=!1;return}if(j.mode==="arrow"){ei(),Hs(),ls(!1),zr({visible:!1,activeDir:""}),j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.joystickRepeatTimer!==null&&(clearTimeout(j.joystickRepeatTimer),j.joystickRepeatTimer=null),j.joystickDir="",j.pointerId=null,j.mode="idle",Sr.current=!1;return}const Q=ma.current;if(Q&&!j.tapDidMove){const F=T.target;F instanceof HTMLElement&&Q.contains(F)&&!F.closest('[data-mobile-keyboard="true"]')&&(j.lastTapTime=performance.now(),j.lastTapX=T.clientX,j.lastTapY=T.clientY)}else j.tapDidMove&&(j.lastTapTime=0);j.holdTimer!==null&&(clearTimeout(j.holdTimer),j.holdTimer=null),j.joystickRepeatTimer!==null&&(clearTimeout(j.joystickRepeatTimer),j.joystickRepeatTimer=null),j.joystickDir="",ls(!1),Sr.current=!1,j.copyStart=null,j.copyDidSelect=!1,j.pointerId=null,j.mode="idle"},[ls,ei,et,Ds,Vn,gn]),ml=L.useCallback(()=>{const T=ri.current;ls(!1),Ds(),T.mode==="arrow"&&zr({visible:!1,activeDir:""}),T.mode==="adjust"&&(jt.current.dragging=null,Vn(),gn()),T.holdTimer!==null&&(clearTimeout(T.holdTimer),T.holdTimer=null),T.joystickRepeatTimer!==null&&(clearTimeout(T.joystickRepeatTimer),T.joystickRepeatTimer=null),T.joystickDir="",Sr.current=!1,T.copyStart=null,T.copyDidSelect=!1,T.pointerId=null,T.tapDidMove=!1,T.mode="idle"},[ls,Ds,Vn,gn]);v2({name:`long-press:${e}`,priority:hI,container:()=>He.current,onPointerDown:V?Dl:void 0,onPointerMove:V?Es:void 0,onPointerUp:V?Ea:void 0,onPointerCancel:V?ml:void 0});const es=L.useCallback((T={})=>{Ce.current+=1,ue.current="",ye.current=null,Ye.current=0,Je.current=!1,bt.current=null,at.current&&(at.current=!1,T.notifyFlowResume===!0&&Le.current?.(!1)),Ne.current=null,H.current=!1,ae.current=null,Nt.current=""},[]),Wi=L.useCallback((T="unknown")=>{const j=Ie.current,Q=ce.current,F=He.current;if(!j||!Q||!F||!Q.element||!Q.cols||!Q.rows)return;const xe=F.getBoundingClientRect();if(xe.width<24||xe.height<24){st("skip fit: container too small",{reason:T,width:Math.round(xe.width),height:Math.round(xe.height)});return}try{const Se={cols:Q.cols,rows:Q.rows},Oe=Q.buffer.active,Xe=qL(Oe.type,Oe.baseY,Oe.viewportY),dt=j.proposeDimensions();if(!dt||dt.cols<=0||dt.rows<=0)return;const er=k2(Q,Se.rows),or=WL({reason:T,currentCols:Se.cols,currentRows:Se.rows,proposedCols:dt.cols,proposedRows:dt.rows});let $r=0;if(or.accept){ni.current&&ss.current&&(Se.cols!==dt.cols||Se.rows!==dt.rows)&&Ae.current?.begin();const Pn=Q.options.smoothScrollDuration;try{Q.options.smoothScrollDuration=0,Q.resize(dt.cols,dt.rows),$r=k2(Q,dt.rows),Xe&&Q.scrollToBottom()}finally{Q.options.smoothScrollDuration=Pn}Ot.current=0}(er>0||$r>0)&&(Q.refresh(0,Math.max(0,Q.rows-1)),st("xterm buffer invariant repaired",{reason:T,before:er,after:$r,cols:Q.cols,rows:Q.rows}));const nn={cols:Q.cols,rows:Q.rows};st("fit",{reason:T,backend:"xterm",width:Math.round(xe.width),height:Math.round(xe.height),before:Se,proposed:dt,next:nn,hysteresis:or,changed:Se.cols!==nn.cols||Se.rows!==nn.rows})}catch{Ae.current?.cancel()}},[st]),Mi=L.useCallback(T=>{const j=ce.current;if(j)try{j.refresh(0,Math.max(0,j.rows-1)),st("terminal refreshed (sync)",{reason:T,cols:j.cols,rows:j.rows,hasWebgl:!!me.current})}catch(Q){st("terminal refresh (sync) failed",{reason:T,error:Q})}},[st]),Gi=L.useCallback(T=>{const j=Ze.current;if(j){try{j.dispose()}catch{}Ze.current=null}const Q=me.current;if(!Q)return!1;Ae.current?.cancel();try{Q.dispose()}catch{}return me.current=null,st("renderer disposed",{type:"webgl",reason:T}),!0},[st]),gs=L.useCallback((T,j)=>{if(me.current)return!0;try{const Q=new H_({customGlyphs:Cn});return Ze.current=Q.onContextLoss(()=>{st("webgl context loss",{reason:"onContextLoss"}),ct.current=!0,typeof window<"u"&&window.setTimeout(()=>{cs("webgl-context-loss",{forceRendererRecreate:!0})},0)}),Ae.current?.cancel(),T.loadAddon(Q),me.current=Q,ct.current=!1,st("renderer",{type:"webgl",reason:j,mobile:V,mode:gt.current}),Mi(`webgl-enabled:${j}`),Wi(`webgl-enabled:${j}`),Di.current=!0,!0}catch(Q){return st("webgl load failed, fallback to dom renderer",{reason:j,error:Q,mobile:V,mode:gt.current}),!1}},[st,Cn,V,Wi,Mi]),Ws=200,Bl=L.useRef(0),Vi=L.useRef(new Map),qi=L.useRef(new Map),fn=L.useRef(Jp()),ga=L.useRef(null),Yi=L.useRef(null),Na=L.useRef(-1),ji=L.useRef(new Map),Di=L.useRef(!1),ni=L.useRef(!1),ws=L.useRef(b2()),Gs=L.useRef(null),Bi=L.useRef(null),Ra=L.useCallback(()=>{Gs.current!==null&&(clearTimeout(Gs.current),Gs.current=null),Bi.current=null},[]),si=L.useCallback(()=>{const T=Vi.current;T.forEach(j=>cancelAnimationFrame(j)),T.clear(),qi.current.clear()},[]),ys=L.useCallback(()=>{ga.current!==null&&(window.clearTimeout(ga.current),ga.current=null)},[]),Ka=L.useRef(()=>{}),Xa=L.useCallback(T=>{ys(),Pe.current?.(!1),ne.current(T.cols,T.rows,T.seq),ga.current=window.setTimeout(()=>{ga.current=null;const j=x2(fn.current,T.seq);fn.current=j.state,j.request&&ni.current?(st("resize ack timeout; retrying",{seq:T.seq,retrySeq:j.request.seq,cols:j.request.cols,rows:j.request.rows}),Ka.current(j.request)):j.exhausted&&(Ae.current?.cancel(),st("resize ack timeout; leaving size unconfirmed",{seq:T.seq,cols:T.cols,rows:T.rows}))},1200)},[ys,st]);Ka.current=Xa;const As=L.useCallback((T,j)=>{if(!ni.current)return;const Q=XL(fn.current,{cols:T,rows:j});fn.current=Q.state,Q.request&&Xa(Q.request)},[Xa]),Ja=L.useCallback((T,j)=>{const Q=sI(ws.current,Date.now());if(Q.action==="send"){Bi.current=null,As(T,j);return}Bi.current={cols:T,rows:j},Gs.current===null&&(Gs.current=setTimeout(()=>{Gs.current=null;const F=Bi.current;Bi.current=null,F&&(ws.current=iI(Date.now()),As(F.cols,F.rows))},Math.max(0,Q.readyAt-Date.now())))},[As]),Ql=1500,Ho=400,Co=L.useRef(0),xa=L.useRef(0),Ma=L.useCallback((T,j,Q)=>{if(!Number.isFinite(T)||!Number.isFinite(j)||T<=0||j<=0)return;const F=Math.floor(T),xe=Math.floor(j);fn.current=tI(fn.current,{cols:F,rows:xe}),Co.current=Date.now(),st("pty-size broadcast received",{cols:F,rows:xe,source:Q??"unknown"})},[st]),Wo=L.useCallback(T=>{const j=ce.current;if(!j||!j.cols||!j.rows||!ni.current||typeof document<"u"&&(document.visibilityState!=="visible"||!Cu()))return;const Q=Date.now();if(Q-Co.current<Ql||Q-xa.current<Ho)return;const F=j.cols,xe=j.rows,Se=fn.current.confirmed;Se&&Se.cols===F&&Se.rows===xe||(xa.current=Q,st("ensureSizeMatches push",{reason:T,cols:F,rows:xe,lastServerSize:Se}),As(F,xe))},[st,As]),ba=L.useCallback((T,j)=>{const Q=ce.current,F=Ie.current;if(!Q||!F)return;if(!Di.current){st("refresh skipped: renderer not ready",{reason:T});return}if(j.dedupeKey!==void 0){if(ji.current.get(T)===j.dedupeKey){st("refresh deduped",{reason:T,dedupeKey:j.dedupeKey});return}ji.current.set(T,j.dedupeKey)}st("refresh",{reason:T,options:j});const xe=j.forceRendererRecreate===!0||ct.current||_r&&!!me.current&&tE.has(T)&&/Android/i.test(navigator.userAgent);let Se=!1;xe&&(ct.current=!1,_r?(Gi(`refresh:${T}`),gs(Q,`refresh:${T}`)||Mi(`refresh:${T}:webgl-fallback`),Se=!0):(Mi(`refresh:${T}`),Se=!0)),ZL(j.forceRedraw===!0,T==="dpr-change",Se)?Mi(`refresh:${T}`):Se||st("terminal redraw skipped: fit/write already repaints",{reason:T});const Oe={cols:Q.cols,rows:Q.rows};Wi(`refresh:${T}`);const Xe={cols:Q.cols,rows:Q.rows};if(j.skipResizePush||GL({before:Oe,after:Xe,lastServerSize:fn.current.confirmed,reconcileServerSize:j.reconcileServerSize})&&Ja(Xe.cols,Xe.rows),!j.skipScrollToBottom&&T!=="resize"&&T!=="dpr-change"){const er=requestAnimationFrame(()=>{const nn=ce.current;if(nn&&nn.buffer.active.type!=="alternate")try{nn.scrollToBottom()}catch{}}),or=Vi.current,$r=or.get(T);$r!==void 0&&cancelAnimationFrame($r),or.set(T,er)}},[st,_r,Gi,gs,Mi,Wi,Ja]),cs=L.useCallback((T,j={})=>{if(ce.current,T==="session-key-change"&&(fn.current=Jp(),ys(),Ra(),ws.current=b2(),ji.current.clear(),si()),!j.force&&(T==="visibility"||T==="bfcache"||T==="online")){const F=Date.now();if(F-Bl.current<Ws){st("refresh throttled",{reason:T});return}Bl.current=F}if(qi.current.set(T,j),Vi.current.has(T))return;const Q=requestAnimationFrame(()=>{const F=qi.current.get(T)??{};Vi.current.delete(T),qi.current.delete(T),ba(T,F)});Vi.current.set(T,Q)},[st,si,ys,Ra,ba]),Go=L.useCallback(T=>{const j=Vi.current.get(T);if(j===void 0)return;const Q=qi.current.get(T)??{};cancelAnimationFrame(j),Vi.current.delete(T),qi.current.delete(T),ba(T,Q)},[ba]);dl.current=()=>Go("resize"),L.useEffect(()=>()=>{si(),Ht.current!==null&&(window.clearTimeout(Ht.current),Ht.current=null)},[e,si]),L.useEffect(()=>{fn.current=Jp(),ys(),ji.current.clear()},[e,ys]);const Zi=L.useCallback(()=>{if(H.current)return;const T=ce.current;if(!T){es();return}if(!ue.current)return;const j=ue.current,Q=j.length,F=ye.current,xe=Je.current;ue.current="",ye.current=null,Je.current=!1,H.current=!0;let Se=null;xe&&(Se=bt.current??{depth:0},bt.current=Se,Se.depth+=1);const Oe=Ae.current,Xe=Oe?.generation;T.write(j,()=>{if(Se&&(Se.depth-=1),Xe!==void 0&&Oe?.written(Xe),H.current=!1,Ye.current-=Q,Ye.current<0&&(Ye.current=0),F!==null&&oe.current?.(F),at.current&&Ye.current<nE&&(at.current=!1,Le.current?.(!1)),ue.current){Zi();return}const dt=++Ce.current,er=()=>{if(dt!==Ce.current||H.current||ue.current)return;const or=T.buffer.active;Ee.current?.({x:or.cursorX,y:or.cursorY,rows:T.rows,lastProcessedChunkId:ae.current})};typeof window>"u"?er():window.requestAnimationFrame(()=>{window.requestAnimationFrame(er)})})},[es]);Vt.current=Zi;const gl=L.useCallback(()=>{if(Ne.current!==null)return;const T=++Ge.current;Ne.current=T,queueMicrotask(()=>{Ne.current===T&&(Ne.current=null,Zi())})},[Zi]),se=L.useCallback((T,j,Q=!1)=>{if(!T)return;Ce.current+=1,ue.current+=T,ye.current=j,Je.current=Je.current||Q,Ye.current+=T.length;const F=Ve.current;(F===null||j>F)&&(Ve.current=j),!at.current&&Ye.current>=rE&&(at.current=!0,Le.current?.(!0)),gl()},[gl]);return L.useEffect(()=>{let T=!1,j=null,Q=null,F=[];const xe=He.current;return xe?(xe.tabIndex=V?-1:0,(async()=>{if(Re.current?.(!1),ft("loading"),Mn(null),Br(!0),await aE(),!T)try{const Oe=lE(xe,E2(en),xn,Rt,Et),Xe=new TA({...Oe?{cols:Oe.cols,rows:Oe.rows}:{},allowProposedApi:!0,fontFamily:E2(en),fontSize:xn,fontWeight:N2(K),fontWeightBold:N2(ze),theme:oE(O),logLevel:"off",cursorBlink:!_r,cursorStyle:"block",cursorInactiveStyle:Tr.current?"bar":"none",scrollback:d?2e3:5e3,scrollbar:{showScrollbar:!1},allowTransparency:GS(Dr,cn),convertEol:ks,drawBoldTextInBrightColors:jr,rescaleOverlappingGlyphs:Ls,minimumContrastRatio:rr,letterSpacing:Rt,lineHeight:Et,smoothScrollDuration:dn&&!ve.current?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),dt=new SA;Xe.loadAddon(dt),Xe.loadAddon(new Z_),Xe.registerLinkProvider(QI(Xe,(yr,wn)=>{rt.current?.(yr,wn)}));const er=new nk;Xe.loadAddon(er),Xe.unicode.activeVersion=cr,Xe.loadAddon(new dk({highlightLimit:1e3}));const or=new gk;Xe.loadAddon(or),qe.current=or,Xe.loadAddon(new BL);try{Xe.loadAddon(new bk(void 0,new j3))}catch(yr){st("clipboard addon skipped",{error:yr})}j=Xe,ce.current=Xe,Ie.current=dt,Tt.current=typeof window<"u"?window.devicePixelRatio:1,Xe.open(xe),Ae.current=KL(Xe),Xn&&Xe.loadAddon(new DL({fontFeatureSettings:lI,fallbackLigatures:cI}));try{const yr=Xe._core;yr?.coreService&&(yr.coreService.isCursorInitialized=!0),Xe.refresh(0,Xe.rows-1)}catch{}_r?(gs(Xe,"init"),Di.current=!0):(st("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:V,mode:Dr}),Di.current=!0),Br(!1),Gr();const $r=yr=>{if(yr.ctrlKey||yr.metaKey){yr.preventDefault();const wn=yr.deltaY>0?-1:1;Ph(t,xn+wn)}};if(Ut.current=$r,xe.addEventListener("wheel",$r,{passive:!1}),!V){let yr=0,wn=null,us=null,Bs=null;const pc=()=>{Bs=null,dl.current();const Vs=Nc(ce.current,xn,Et),Ki=vt.current+yr;yr=0;const _o=Math.trunc(Ki/Vs);if(vt.current=Ki-_o*Vs,_o!==0){const yi=_o>0?"down":"up",ko=ce.current,tu=Math.max(3,Math.floor((ko?.rows??24)/2)),vi=Math.abs(_o);vi>tu&&(vt.current=0),pa.current(yi,Math.min(vi,tu),wn??void 0,us??void 0)}};Xe.attachCustomWheelEventHandler(Vs=>{if(Vs.ctrlKey||Vs.metaKey||Vs.shiftKey)return!0;if(Vs.deltaY===0)return!1;if(!ce.current||!ss.current)return!0;const _o=Nc(ce.current,xn,Et);let yi=Vs.deltaY;return Vs.deltaMode===1?yi=Vs.deltaY*_o:Vs.deltaMode===2&&(yi=Vs.deltaY*(xe.clientHeight||_o*20)),yr+=yi,wn=Vs.clientX,us=Vs.clientY,Bs===null&&(Bs=requestAnimationFrame(pc)),Vs.preventDefault(),!1})}const nn=eE(xe);if(nn?(nn.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),q.current=nn,dr()):q.current=null,cs("mount",{skipResizePush:!0,skipScrollToBottom:!0}),jn.current&&(V?Xe.focus():mt.current?.focus({preventScroll:!0})),V||At.current(),F.push(Xe.onRender(()=>{const yr=Xe.buffer.active;We.current?.({x:yr.cursorX,y:yr.cursorY,rows:Xe.rows}),V||At.current()})),!V){try{const yr=Xe.textarea;if(yr){yr.tabIndex=-1,yr.setAttribute("aria-hidden","true"),yr.setAttribute("readonly",""),yr.value="";const wn=()=>{mt.current?.focus({preventScroll:!0})};yr.addEventListener("focus",wn),F.push({dispose:()=>yr.removeEventListener("focus",wn)})}}catch{}try{F.push(Xe.onCursorMove(()=>At.current())),F.push(Xe.onResize(()=>At.current()))}catch{}}F.push(Xe.onData(yr=>{const wn=bt.current;wn!==null&&wn.depth>0||Be.current(yr)}));const Pn=yr=>{const wn=typeof window<"u"?window.devicePixelRatio:1,us=Math.abs(wn-Tt.current)>.001;return us&&(Tt.current=wn,st("device pixel ratio changed",{value:wn,source:yr})),us};if(Q=new ResizeObserver(yr=>{if(!VL(!!Jr.current,ln.current)){st("resize observer skipped: hidden mobile session");return}Zt.current=void 0;const wn=yr[0];wn&&st("resize observer",{width:Math.round(wn.contentRect.width),height:Math.round(wn.contentRect.height)});const us=Pn("resize-observer");cs(us?"dpr-change":"resize")}),Q.observe(xe),typeof window<"u"){const yr=()=>{Pn("window-resize")&&cs("dpr-change")};window.addEventListener("resize",yr),F.push({dispose:()=>window.removeEventListener("resize",yr)});const wn=window.visualViewport;if(wn){const us=()=>{Pn("visual-viewport-resize")&&cs("dpr-change")};wn.addEventListener("resize",us),F.push({dispose:()=>wn.removeEventListener("resize",us)})}}Wi("init-fit"),ft("ready"),Re.current?.(!0)}catch(Oe){console.error("Failed to initialize terminal:",Oe),Br(!1),ft("error"),Mn(Oe instanceof Error?Oe.message:"Failed to load terminal")}})(),()=>{Re.current?.(!1),T=!0,Fe.current?.(!1),Pt.current?.(),Pt.current=null,X.current=!1,nt.current!==null&&(clearTimeout(nt.current),nt.current=null),yt.current=!1,Jt.current=null,Bt(),Hr({active:!1,text:""});for(const Oe of F)Oe.dispose();Q?.disconnect(),Ut.current&&(xe.removeEventListener("wheel",Ut.current),Ut.current=null),Ae.current?.dispose(),Ae.current=null,Gi("component-unmount"),j?.dispose(),ce.current=null,Ie.current=null,q.current=null,es({notifyFlowResume:!0}),ys(),Ra()}):void 0},[Wi,en,xn,K,ze,Rt,Et,rr,jr,cr,Cn,Ls,Xn,cn,dn,O,es,Bt,V,gs,Gi,st,ys,Ra]),L.useEffect(()=>{const T=ce.current;T&&(T.options.smoothScrollDuration=dn&&!pe?125:0)},[dn,pe,ge]),L.useEffect(()=>{const T=ce.current;T&&(T.options.cursorInactiveStyle=be?"bar":"none",be||T.blur())},[be,ge]),L.useEffect(()=>{const T=ce.current;if(T){if(_r){if(T.options.cursorBlink=!1,gs(T,"renderer-mode-change")&&cn&&!Kt.current)try{T.loadAddon(new Yk({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),Kt.current=!0}catch(Q){st("image addon skipped",{error:Q})}return}T.options.cursorBlink=!0,Gi("renderer-mode-change")&&(Mi("renderer-mode-change:webgl-disabled"),Wi("renderer-mode-change:webgl-disabled"))}},[_r,cn,gs,Gi,Mi,Wi,st]),L.useEffect(()=>{const T=ce.current;T&&(ae.current!==null&&T.reset(),es(),_e.current="",tr.current=0,mt.current&&(mt.current.value=""),cs("session-reset",{skipScrollToBottom:!0}),jn.current&&(Jr.current?T.focus():mt.current?.focus({preventScroll:!0})))},[e,ge,cs,es]),L.useEffect(()=>{if(!V||typeof document>"u")return;let T=null;const j=()=>{T=null;const F=mt.current;if(!F||document.activeElement!==F||X.current)return;const xe=_e.current,Se=_d(F.value);if(Se!==xe||Se.includes("\r")||!Lt())return;const Oe=Math.min(T2(F),Array.from(Se).length),Xe=Oe-tr.current;if(Xe===0)return;const dt=ce.current,er=Xe<0?(dt?bh(dt,"D"):"\x1B[D").repeat(-Xe):(dt?bh(dt,"C"):"\x1B[C").repeat(Xe);Be.current(er),tr.current=Oe},Q=()=>{T===null&&(T=requestAnimationFrame(j))};return document.addEventListener("selectionchange",Q),()=>{document.removeEventListener("selectionchange",Q),T!==null&&cancelAnimationFrame(T)}},[V,Lt]),L.useEffect(()=>{if(!V)return;const T=qa();return Pt.current=T,()=>{T(),Pt.current=null}},[V,qa]),L.useEffect(()=>{const T=ce.current;if(T)try{T.options.scrollback=d?0:1e3}catch{}},[d,ge]),L.useEffect(()=>{const T=ce.current;if(!T)return;if(n.length===0){ae.current!==null&&(T.reset(),es(),cs("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const j=ae.current;let Q,F=!1;if(j===null)Q=n;else{const xe=n.findIndex(Se=>Se.id===j);xe>=0?Q=n.slice(xe+1):(Q=n,F=!0)}if(Q.length>0){const xe=Q.map(or=>or.data).join(""),Se=Nt.current+xe,{cleaned:Oe,remainder:Xe}=JI(Se);Nt.current=Xe;const dt=Ve.current,er=dt!==null&&(Q[0].id<=dt||F);Oe?se(Oe,Q[Q.length-1].id,er):oe.current?.(Q[Q.length-1].id)}ae.current=n[n.length-1].id},[n,ge,se,cs,es]),L.useImperativeHandle(ee,()=>({serializeSnapshot:()=>ce.current?qe.current?.serialize({scrollback:100})??null:null,focus:()=>{if(Jr.current){Dn();return}mt.current?.focus({preventScroll:!0})},blur:()=>{const T=mt.current;hn(T),T&&typeof document<"u"&&document.activeElement===T&&T.blur(),Jr.current&&T?.setAttribute("readonly",""),Fe.current?.(!1)},clear:()=>{const T=ce.current;T&&(T.reset(),es(),cs("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},prepareScreenReplacement:()=>{es({notifyFlowResume:!0})},copySelectionOrViewport:async()=>{const T=ce.current;if(!T)return!1;const j=T.hasSelection()?T.getSelection():cE(T),Q=await M2(j);return Q&&T.hasSelection()&&Or(),Q},pasteClipboardText:async()=>{et();const T=await we(mt.current);return ms.current?.(T),T},sendSequence:(T,j)=>U(T,null,j),getDimensions:()=>{const T=ce.current;return!T||!T.cols||!T.rows?null:{cols:T.cols,rows:T.rows}},requestRefresh:cs,setSessionReady:T=>{ni.current=T,T||(Ae.current?.cancel(),ys(),fn.current=rI(fn.current),Yi.current=null,Na.current=-1,Pe.current?.(!1))},acknowledgeResize:T=>{if(!T.ok&&typeof T.seq=="number"){const Se=x2(fn.current,T.seq);if(!Se.request&&!Se.exhausted)return;ys(),fn.current=Se.state,Se.request&&ni.current?Ka.current(Se.request):Se.exhausted&&Ae.current?.cancel();return}const j=eI(fn.current,T);if(!j.accepted)return;ys(),fn.current=j.state,st("resize acknowledged",{seq:T.seq,ok:T.ok,cols:T.cols,rows:T.rows,screenSyncPending:T.screenSyncPending===!0,screenSyncGeneration:T.screenSyncGeneration});const Q=ce.current,F=j.state.confirmed;if(!!!(Q&&F&&Q.cols===F.cols&&Q.rows===F.rows)){Pe.current?.(!1);return}if(T.screenSyncPending&&typeof T.screenSyncGeneration=="number"){Yi.current=T.screenSyncGeneration;const Se=Na.current>=T.screenSyncGeneration;Pe.current?.(Se),Se&&(Yi.current=null);return}Yi.current=null,Pe.current?.(!0)},notifyScreenSynchronized:T=>{if(!Number.isFinite(T))return;Na.current=Math.max(Na.current,T);const j=Yi.current;if(j===null||T<j)return;Yi.current=null;const Q=ce.current,F=fn.current.confirmed;Pe.current?.(!!(Q&&F&&Q.cols===F.cols&&Q.rows===F.rows))},notifyServerSize:Ma,ensureSizeMatches:Wo,requestPtyRedraw:()=>{const T=ce.current;if(!T||!ni.current||fn.current.pending||Yi.current!==null)return;const j=JL(fn.current,{cols:T.cols,rows:T.rows});fn.current=j.state,Ka.current(j.request)}}),[V,hn,Dn,es,we,U,cs,ys,st,As,Ma,Wo]),s.jsxs("div",{ref:He,"data-termdock-terminal-dropzone":e,className:`relative h-full w-full terminal-viewport-container ${$||""}`,style:{backgroundColor:O.background,touchAction:on.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:Ga,onPointerMoveCapture:Qn,onPointerUpCapture:is,onPointerCancelCapture:zi,onTouchStartCapture:T=>{if(qn(T.target)){et(),Dt(kd);return}Bn(),Dt(kd)},onTouchMoveCapture:()=>Dt(kd),onTouchEndCapture:()=>Dt(Ld),onTouchCancelCapture:()=>Dt(Ld),onMouseDown:T=>{V||T.button===0&&(Ht.current!==null&&(window.clearTimeout(Ht.current),Ht.current=null),requestAnimationFrame(()=>{try{mt.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:T=>{V||T.button===0&&(Ht.current!==null&&window.clearTimeout(Ht.current),Ht.current=window.setTimeout(()=>{Ht.current=null;try{mt.current?.focus({preventScroll:!0})}catch{}},0))},children:[Xr&&s.jsx("button",{type:"button",role:"alert",onClick:()=>De(null),className:"absolute bottom-2 left-2 right-2 z-20 rounded-md border border-border bg-surface-2 px-3 py-2 text-left text-sm text-foreground",children:Xr}),un&&s.jsxs("button",{type:"button","data-terminal-copy-popover":"true",className:"absolute z-30 inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:un.left,top:un.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:T=>{et(),T.stopPropagation()},onPointerUp:T=>{T.preventDefault(),T.stopPropagation(),Ia()},onTouchStart:T=>{et(),T.stopPropagation()},onTouchEnd:T=>{T.preventDefault(),T.stopPropagation(),Ia()},onClick:T=>{T.preventDefault(),T.stopPropagation(),Ia()},children:[s.jsx(s8,{size:14,strokeWidth:2.4}),s.jsx("span",{children:ke("common.copy")})]}),nr?.start&&s.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:nr.start.left,top:nr.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)]"})]})}),nr?.end&&s.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:nr.end.left,top:nr.end.top,transform:"translate(-50%, 0)",touchAction:"none"},onPointerDown:T=>T.stopPropagation(),children:s.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 flex -translate-x-1/2 flex-col items-center",children:[s.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"}),s.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"})]})}),Vr&&xt&&s.jsx(vI,{}),Vr&&ot==="loading"&&!xt&&s.jsx(Y3,{}),ot==="error"&&s.jsx(wI,{message:ir||void 0,onRetry:()=>{window.location.reload()}}),ot==="ready"&&s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:mt,"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=Fr.x,j=Fr.y,Q={position:"fixed",left:T,top:j,pointerEvents:"none",touchAction:"auto",fontSize:`${xn}px`,fontFamily:en,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(Fr.cellW)),height:Math.max(1,Math.round(Fr.cellH))};if(!Pr.active)return Q;const F=It(Pr.text);return{...Q,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:F.width,height:F.height,whiteSpace:F.whiteSpace}})()},onContextMenu:T=>{T.preventDefault()},onFocus:()=>{st("input anchor focus"),Zt.current=void 0,At.current(),cs("focus",{skipResizePush:!0,skipScrollToBottom:!0}),Fe.current?.(!0)},onBlur:T=>{V||hn(T.currentTarget);const j=hr(),Q=typeof document<"u"?document.activeElement:null;if(st("input anchor blur",{guarded:j,activeTag:Q?.tagName??null,activeClass:Q?.className??null}),!j){V&&mt.current?.setAttribute("readonly",""),Fe.current?.(!1);return}if(typeof window>"u"){Fe.current?.(!1);return}window.setTimeout(()=>{Ct()||Lt()||(V&&mt.current?.setAttribute("readonly",""),Fe.current?.(!1))},Ld)},onBeforeInput:T=>{if(X.current)return;const j=T.nativeEvent;if(j instanceof InputEvent){if(j.inputType==="insertFromPaste"||j.inputType==="insertFromPasteAsQuotation"){const Q=j.dataTransfer?.getData("text/plain")||j.data;if(Q){T.preventDefault();const F=Z(Q,T.currentTarget);V&&ms.current?.(F)}return}if(j.inputType==="insertLineBreak"){if(yt.current){yt.current=!1,nt.current!==null&&(clearTimeout(nt.current),nt.current=null),T.preventDefault();return}T.preventDefault(),N(T.currentTarget);return}if(j.inputType==="deleteContentBackward"||j.inputType==="deleteContentForward"||j.inputType==="deleteByCut"){if(!T.currentTarget.value){T.preventDefault(),Be.current("");return}if(j.inputType==="deleteContentBackward"&&T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),Be.current("");return}return}}},onInput:T=>{if(X.current)return;const j=T.nativeEvent,Q=vC(_e.current,_d(T.currentTarget.value),j.inputType);if(Q){const F=Z(Q,T.currentTarget);V&&ms.current?.(F);return}W(T.currentTarget)},onPaste:T=>{const j=T.clipboardData.files.length?Array.from(T.clipboardData.files):Array.from(T.clipboardData.items).filter(Se=>Se.kind==="file").map(Se=>Se.getAsFile()).filter(Se=>Se!==null),Q=T.clipboardData.getData("text/plain");if(window.termdockDesktop?.readClipboardFiles){T.preventDefault(),we(T.currentTarget,{files:j,text:Q});return}if(j.length&&(j.length>1||!j[0].type.startsWith("image/"))){T.preventDefault(),Qe(j,T.currentTarget);return}const F=j[0];if(F){T.preventDefault(),fe(F,T.currentTarget);return}if(!Q){(window.termdockDesktop||typeof navigator.clipboard?.read=="function")&&(T.preventDefault(),we(T.currentTarget));return}T.preventDefault();const xe=Z(Q,T.currentTarget);V&&ms.current?.(xe)},onKeyDown:T=>{const j=KI(T);if(!j&&!X.current){if(T.getModifierState("AltGraph"))return;const Q=ce.current,F=T.metaKey,xe=T.ctrlKey,Se=T.altKey,Oe=T.shiftKey,Xe=T.key;if(F&&!xe&&!Se&&!Oe&&Xe==="Enter"){T.preventDefault(),N(T.currentTarget);return}if((F||xe)&&!Se&&!Oe&&(Xe==="v"||Xe==="V"))return;if(F&&!xe&&!Se&&!Oe&&(Xe==="c"||Xe==="C")){T.preventDefault();const er=Q?.hasSelection()?Q.getSelection():"";er&&navigator.clipboard?.writeText(er).catch(()=>{});return}if((F||xe)&&!Se&&!Oe&&(Xe==="k"||Xe==="K")){T.preventDefault(),Q&&(Q.reset(),es(),cs("clear",{skipResizePush:!0,skipScrollToBottom:!0})),T.currentTarget.value="",_e.current="",tr.current=0;return}if(F&&!xe&&!Se&&!Oe&&Xe==="Backspace"){T.preventDefault(),U("",T.currentTarget);return}if(F&&!xe&&!Se&&!Oe&&Xe==="Delete"){T.preventDefault(),U("\v",T.currentTarget);return}if(F&&!xe&&!Se&&!Oe&&Xe==="ArrowLeft"){T.preventDefault(),U("",T.currentTarget);return}if(F&&!xe&&!Se&&!Oe&&Xe==="ArrowRight"){T.preventDefault(),U("",T.currentTarget);return}if(F)return;if(Se&&!xe&&!F&&!Oe&&Xe==="Backspace"){T.preventDefault(),U("\x1B",T.currentTarget);return}if(Se&&!xe&&!F&&!Oe&&Xe==="Delete"){T.preventDefault(),U("\x1Bd",T.currentTarget);return}if(Se&&!xe&&!F&&!Oe&&Xe==="ArrowLeft"){T.preventDefault(),U("\x1Bb",T.currentTarget);return}if(Se&&!xe&&!F&&!Oe&&Xe==="ArrowRight"){T.preventDefault(),U("\x1Bf",T.currentTarget);return}const dt=FC(T,Q?.modes?.applicationCursorKeysMode===!0);if(dt!==null){T.preventDefault(),U(dt,T.currentTarget);return}}if(T.key==="Enter"||T.key==="Go"||T.key==="done"||T.key==="send"){if(j||X.current){T.preventDefault();return}if(yt.current){yt.current=!1,nt.current!==null&&(clearTimeout(nt.current),nt.current=null),T.preventDefault();return}T.preventDefault(),N(T.currentTarget);return}if(T.key==="Backspace"){if(j||X.current)return;if(!T.currentTarget.value){T.preventDefault(),Be.current("");return}if(T.currentTarget.selectionStart===0&&T.currentTarget.selectionEnd===0){T.preventDefault(),Be.current("");return}}},onCompositionStart:()=>{X.current=!0,rn(),Hr({active:!0,text:""})},onCompositionUpdate:T=>{X.current=!0;const j=T.data??T.currentTarget.value;Hr(Q=>Q.active&&Q.text===j?Q:{active:!0,text:j})},onCompositionEnd:T=>{X.current=!1,yt.current=!0,nt.current!==null&&clearTimeout(nt.current),nt.current=setTimeout(()=>{yt.current=!1,nt.current=null},50),Hr({active:!1,text:""}),W(T.currentTarget),yn()}}),Pr.active&&(()=>{const T=It(Pr.text);return s.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:Fr.x,top:Fr.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:T.width,height:T.height,margin:0,padding:0,color:O.foreground,background:O.background,boxShadow:`-1px 0 0 1px ${O.background}`,fontSize:`${xn}px`,fontFamily:en,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:O.foreground,wordBreak:"break-all",whiteSpace:T.whiteSpace,transition:"none"},children:Pr.text})})(),s.jsx("div",{"aria-hidden":!0,className:`absolute left-1/2 -translate-x-1/2 top-6 z-30 pointer-events-none
|
|
72
|
-
rounded-full bg-[var(--surface-elevated)] px-4 py-1.5 text-sm font-semibold text-foreground
|
|
73
|
-
shadow-lg transition-all duration-150 ease-out`,style:{opacity:qr?1:0,transform:qr?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),s.jsx("div",{ref:ps,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:on.visible?1:0,transform:on.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:on.visible&&(()=>{const{activeDir:T}=on,j=Q=>T===Q;return s.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${j("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${j("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${j("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${j("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});K3.displayName="TerminalViewport";const dE=K3,hE=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},fE=()=>({async createSession(e){return d8(e)},connect(e,t,r){const n=u8(e,t.onEvent,t.onError,{...hE(r),getDimensions:r?.getDimensions});return{close:()=>n()}},async sendInput(e,t){await Ay(e,t)},async resize(e){await c8(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await wy(e)},async restartSession(e,t){return l8(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await o8(e)},async tmuxAction(e,t){return a8(e,t)},async listTmuxSessions(){return Fm()},async getTmuxStatus(){return Om()},async checkHealth(e){return i8(e)}}),pE="\x1B",mE=/\x1b\[[IO]/g,gE=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,xE=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function D2(e,t,r){return e.lastIndex=r,e.exec(t)?e.lastIndex:-1}function bE(e){const t=e.replace(mE,"");if(t.length===0)return e.length>0;let r=0;for(;r<t.length;){let n=D2(gE,t,r);if(n<0&&(n=D2(xE,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 yE(e){return e===pE}function l1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const Xd=18;function vE(){return X3.map(e=>e.id)}const X3=[{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 v0(){return X3.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function tg(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 J3(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const rg=/^\/(.+)\/([gimsuy]*)$/;function B2(e){return rg.test(e.trim())}function vf(e){const t=e.trim().match(rg);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function ev(e){if(typeof e!="string")return null;const t=e.trim();return t?rg.test(t)?vf(t)?t:null:t.toLowerCase():null}function Q2(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 P2="||",wE=120;function AE(e){return e.includes(P2)?e.split(P2).filter(t=>t.length>0):[e]}function Ru(e){const t=new Set,r=e.map((a,c)=>{const l=typeof a.id=="string"&&a.id.trim().length>0?a.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):`preset-${c+1}`,d=t.has(l)?`${l}-${c+1}`:l;return t.add(d),{id:d,label:typeof a.label=="string"&&a.label.trim().length>0?a.label.trim():"Preset",programs:Array.isArray(a.programs)?a.programs.map(f=>ev(f)).filter(f=>!!f):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:tg(a.rowLayout),showOnDesktop:typeof a.showOnDesktop=="boolean"?!!a.showOnDesktop:!1,actions:Array.isArray(a.actions)?a.actions.map((f,m)=>{const x={id:typeof f.id=="string"&&f.id.trim().length>0?f.id:`${d}-action-${m+1}`,label:typeof f.label=="string"?f.label:`Key ${m+1}`,sequence:typeof f.sequence=="string"?f.sequence:""};return typeof f.doubleTapSequence=="string"&&(x.doubleTapSequence=f.doubleTapSequence),x}):[]}}).filter(a=>a.id!=="auto"),n=v0()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function TE(e,t){const r=J3(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const c=vf(a);if(c){if(c.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function O2(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??v0()[0]}function SE(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function CE(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function tv(e,t){const r=tg(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 rv=28,nv=({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(HS,{size:14}):(t.charAt(0)||"?").toUpperCase()}),_E={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Ed=8;function kE(e,t){return _E[e]??null}const LE=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:a,disabled:c,defaultShowExtended:l=!1,presetLabel:d,presetModeLabel:f,presetMode:m,presetOptions:x,includeAlt:y,presetRowLayout:w,extraActions:v,onKeyPress:S,onTextPress:C,onPastePress:I,onFilePress:R,onFileLongPress:B,fileUploadState:z="idle",fileUploadProgress:O=0,longPressMode:$="arrows",copyFeedback:V="idle",onLongPressModeToggle:Y,onModifierToggle:le,onPresetSelect:be,onExpandedChange:pe})=>{const{t:ee}=Ur(),[ke,He]=L.useState(l),[q,ce]=L.useState(!1),qe=L.useRef(null),Ae=r==="desktop-actions",ve=Ae||ke,[Ie,Be]=L.useState(!1),[ne,Fe]=L.useState(null),Le=c||!e||!t,Re=c||!e,Pe=L.useRef(null),Ee=L.useRef(null),oe=L.useRef(null),We=L.useRef(null),rt=L.useRef(null),gt=L.useRef(V),ue=L.useRef(null),Ye=L.useRef(0),at=L.useRef(null),Ne=L.useRef(!1),Ge=L.useCallback(Ke=>{if(Le)return;const kt=Ke.target;if(!(kt instanceof Element))return;const Ut=kt.closest("button"),vt=Ut?.hasAttribute("data-mobile-native-action")===!0;Ut&&!vt?(Ke.preventDefault(),xo(Ed)):Ut&&xo(Ed)},[Le]),Ce=L.useCallback(Ke=>{Ke.preventDefault()},[]),H=L.useCallback(Ke=>{const kt=Ke.target;Le||kt instanceof HTMLElement&&kt.closest("button")&&kt.blur()},[Le]);L.useEffect(()=>{He(l)},[l]),L.useEffect(()=>{Ae||pe?.(ke)},[Ae,pe,ke]),L.useEffect(()=>{Le&&(ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null),Be(!1),Fe(null))},[Le]),L.useEffect(()=>{e||(Be(!1),Fe(null))},[e]),L.useEffect(()=>{if(!Ie)return;const Ke=()=>{const kt=Pe.current?.getBoundingClientRect();kt&&Fe({left:Math.max(8,kt.left),top:Math.max(8,kt.top-8)})};return Ke(),window.addEventListener("resize",Ke),window.addEventListener("scroll",Ke,!0),()=>{window.removeEventListener("resize",Ke),window.removeEventListener("scroll",Ke,!0)}},[Ie]),L.useEffect(()=>{const Ke=gt.current;if(gt.current=V,V==="idle"||V===Ke)return;if(rt.current!==null&&window.clearTimeout(rt.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(V==="copied"){Ee.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 Ut=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];oe.current?.animate?.(Ut,{duration:760,easing:"ease-out"}),We.current?.animate?.(Ut,{duration:760,delay:130,easing:"ease-out"})}else Ee.current?.animate?.([{transform:"translateX(0)"},{transform:"translateX(-2px)"},{transform:"translateX(2px)"},{transform:"translateX(0)"}],{duration:280,easing:"ease-out"});xo(Ed),V==="copied"&&(rt.current=window.setTimeout(()=>{xo(Ed),rt.current=null},90),$==="copy"&&Y?.())},[V,$,Y]),L.useEffect(()=>()=>{rt.current!==null&&window.clearTimeout(rt.current)},[]);const ae=L.useCallback((Ke,kt)=>{Le||(Ke.preventDefault(),S(kt))},[S,Le]),ye=L.useCallback((Ke,kt)=>{Le||(Ke.preventDefault(),le(kt))},[le,Le]),Ve=L.useCallback(Ke=>{Le||(Ke.preventDefault(),He(kt=>{const Ut=!kt;return Ut&&(ce(!0),qe.current!==null&&window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{ce(!1),qe.current=null},350)),Ut}))},[Le]),Je=L.useCallback(()=>{const Ke=typeof performance<"u"?performance.now():Date.now();Ke-Ye.current<350||(Ye.current=Ke,I?.())},[I]),bt=L.useCallback(Ke=>{Le||(Ke.stopPropagation(),Ke.pointerType!=="touch"&&(Ke.preventDefault(),Je()))},[Le,Je]),Vt=L.useCallback(Ke=>{Le||(Ke.preventDefault(),Ke.stopPropagation(),Je())},[Le,Je]),Pt=L.useCallback(Ke=>{Le||z==="uploading"||!R||(Ke.preventDefault(),Ke.stopPropagation(),Ne.current||R(),Ne.current=!1)},[z,R,Le]),mt=L.useCallback(()=>{at.current!==null&&window.clearTimeout(at.current),at.current=null},[]),Zt=L.useCallback(Ke=>{Ke.stopPropagation(),!(Le||z==="uploading"||!B)&&(Ne.current=!1,at.current=window.setTimeout(()=>{at.current=null,Ne.current=!0,xo(Ed),B()},500))},[z,B,Le]);L.useEffect(()=>()=>mt(),[mt]);const Ht=L.useCallback(Ke=>{Le||Ke.stopPropagation()},[Le]),Kt=250,Ot=L.useCallback(()=>{ue.current!==null&&(window.clearTimeout(ue.current.timer),ue.current=null)},[]);L.useEffect(()=>()=>{Ot(),qe.current!==null&&(window.clearTimeout(qe.current),qe.current=null)},[Ot]);const Nt=L.useCallback((Ke,kt)=>{if(Le)return;if(Ke.preventDefault(),!kt.doubleTapSequence){C(kt.sequence);return}const Ut=ue.current;if(Ut!==null&&Ut.actionId===kt.id){window.clearTimeout(Ut.timer),ue.current=null,C(kt.doubleTapSequence);return}Ot();const vt=window.setTimeout(()=>{ue.current=null,C(kt.sequence)},Kt);ue.current={actionId:kt.id,timer:vt}},[Ot,C,Le]),me=L.useCallback(Ke=>{Le||(Ke.preventDefault(),Ke.stopPropagation(),Y?.())},[Y,Le]),Ze=L.useCallback(Ke=>{Le||Ke.stopPropagation()},[Le]),ct=L.useCallback(Ke=>{if(Le)return;Ke.preventDefault();const kt=Ke.currentTarget.getBoundingClientRect();Fe({left:Math.max(8,kt.left),top:Math.max(8,kt.top-8)}),Be(Ut=>!Ut)},[Le]),Tt=L.useCallback((Ke,kt)=>{Le||(Ke.preventDefault(),Be(!1),Fe(null),be(kt))},[be,Le]),X=v.length>0,yt=L.useMemo(()=>{const Ke=[{id:"preset",kind:"preset"}];if(!Ae&&y&&Ke.push({id:"alt",kind:"alt"}),X){const kt=v.map(Ut=>({id:Ut.id,kind:"text",action:Ut}));return Ke.concat(kt)}return Ae?Ke.concat([{id:"esc",kind:"key",keyName:"esc"},{id:"ctrl-c",kind:"key",keyName:"ctrl-c"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"},{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"}]):Ke.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,X,y,Ae]),nt=L.useMemo(()=>tv(yt,Ae&&!X?[6]:w),[yt,X,Ae,w]),_e=`${Ae?"space-y-1":"mt-1 space-y-1"}${q?" pointer-events-none":""}`,tr=Ie&&ne?Js.createPortal(s.jsx("div",{className:"fixed z-popover min-w-28 -translate-y-full rounded-2xl bg-surface-elevated p-1.5 shadow-xl border border-border/15",style:{left:ne.left,top:ne.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(Ke=>s.jsx("button",{type:"button",onPointerDown:kt=>Tt(kt,Ke.id),tabIndex:-1,disabled:Re,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${Ke.id===m?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:Ke.label},Ke.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[tr,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?Ae?"max-h-24":"max-h-40":"max-h-0"} ${e?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"} ${t?"":"[&_button]:pointer-events-none"}`,onMouseDownCapture:Ge,onPointerDownCapture:Ge,onContextMenuCapture:Ce,onFocusCapture:H,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!Ae&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:Ke=>ae(Ke,"esc"),tabIndex:-1,disabled:Re,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"Esc"}),s.jsx("button",{type:"button",onPointerDown:Ke=>ye(Ke,"ctrl"),tabIndex:-1,disabled:Re,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="ctrl"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="ctrl"?"Ctrl*":"Ctrl"})}),s.jsx("button",{type:"button",onPointerDown:Ke=>ae(Ke,"ctrl-c"),tabIndex:-1,disabled:Re,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-C"}),s.jsx("button",{type:"button",onPointerDown:Ke=>ae(Ke,"ctrl-u"),tabIndex:-1,disabled:Re,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:mt,onPointerCancel:mt,onClick:Pt,tabIndex:-1,disabled:Re||!R||z==="uploading",title:z==="uploading"?`${ee("rightSidebar.uploading")} ${Math.round(O)}%`:ee(z==="inserted"?"rightSidebar.inserted":z==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":ee("rightSidebar.insertLocalFile"),className:`relative h-7 w-full overflow-hidden rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${z==="inserted"?"bg-primary/15 text-primary":z==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[z==="uploading"&&s.jsx("span",{"aria-hidden":"true","data-file-upload-progress":"true",className:"absolute inset-y-0 left-0 bg-primary/25 transition-[width] duration-150 ease-out",style:{width:`${Math.max(0,Math.min(100,O))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:z==="uploading"?s.jsx(_n,{size:15,className:"animate-spin"}):z==="inserted"?s.jsx(pi,{size:15}):z==="failed"?s.jsx(In,{size:15}):s.jsx(fT,{size:15})}),z!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:z==="uploading"?`${ee("rightSidebar.uploading")} ${Math.round(O)}%`:ee(z==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),s.jsx("button",{type:"button",onPointerDown:()=>C("/"),tabIndex:-1,disabled:Re,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"/"}),s.jsx("button",{type:"button",onPointerDown:Ke=>ae(Ke,"enter"),tabIndex:-1,disabled:Re,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(oT,{size:16})}),s.jsxs("button",{ref:Ee,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Ze,onTouchStart:Ze,onClick:me,tabIndex:-1,disabled:Re,title:ee(V==="copied"?"terminal.copied":V==="failed"?"terminal.copyFailed":$==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":ee($==="copy"?"terminal.switchLongPressToArrows":"terminal.switchLongPressToCopy"),className:`relative isolate h-7 w-full overflow-visible rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-colors keyboard-button-active disabled:opacity-50 flex items-center justify-center ${V==="copied"?"bg-primary/15 text-primary":V==="failed"?"bg-destructive/15 text-destructive":$==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:oe,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:We,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/40 opacity-0"}),s.jsxs("span",{className:"relative z-10 h-4 w-4","aria-hidden":"true",children:[s.jsx(pi,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),s.jsx(In,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${V==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(Py,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&$==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(UT,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&$==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),V!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:V==="copied"?`${ee("terminal.copied")} · ${ee("terminal.longPressSendsArrows")}`:`${ee("terminal.copyFailed")} · ${ee("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:bt,onPointerUp:Ht,onTouchStart:Ht,onTouchEnd:Ht,onClick:Vt,tabIndex:-1,disabled:Re,title:ee("terminal.paste"),"aria-label":ee("terminal.paste"),className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(XA,{size:15})}),s.jsx("button",{type:"button",onPointerDown:Ve,tabIndex:-1,disabled:Re,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(h8,{size:16}):s.jsx(ul,{size:16})})]}),ve&&s.jsx("div",{className:_e,children:nt.map((Ke,kt)=>{const Ut=Ke.items[0]?.kind==="preset",vt=Math.max(2,Ke.columns),wt=Ut?`${rv}px repeat(${Math.max(1,vt-1)}, minmax(0, 1fr))`:`repeat(${vt}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:wt},children:Ke.items.map(Mt=>Mt.kind==="preset"?s.jsx(nv,{buttonRef:Mt.id==="preset"?Pe:void 0,mode:m,presetLabel:d,title:f,disabled:Re,onPointerDown:ct},Mt.id):Mt.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:_t=>ye(_t,"alt"),tabIndex:-1,disabled:Re,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"})},Mt.id):Mt.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:_t=>Nt(_t,Mt.action),tabIndex:-1,disabled:Re,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:[Mt.action.label,Mt.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},Mt.id):s.jsx("button",{type:"button",onPointerDown:_t=>ae(_t,Mt.keyName),tabIndex:-1,disabled:Re,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:Mt.keyName==="esc"?"Esc":Mt.keyName==="ctrl-c"?"Ctrl-C":Mt.keyName==="ctrl-d"?"Ctrl-D":Mt.keyName==="home"?"Home":"End"},Mt.id))},`row-${kt}`)})})]})})]})},IE=({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"})})]})},EE=/^Reconnecting/i,NE=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:c}=Ur(),l=!!e&&EE.test(e),d=!!(n&&!e||l),[f,m]=L.useState(!1);return L.useEffect(()=>{if(!d){m(!1);return}const x=setTimeout(()=>m(!0),1500);return()=>clearTimeout(x)},[d]),d?f?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:s.jsx(h0,{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},RE=120,ME=80,jE=400;function F2(){if(typeof window>"u"||document.visibilityState!=="visible"||!f8())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 sv(e){const{enabled:t,openThresholdPx:r=RE,closeThresholdPx:n=ME,settleDelayMs:a=jE}=e,c=L.useMemo(()=>Fu("keyboard"),[]),l=L.useRef(!1),d=L.useRef(null),f=L.useRef(0),[m,x]=L.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return L.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=F2();let Y=l.current;if(V>=r?Y=!0:V<=n&&(Y=!1),l.current=Y,Y){const le=Math.abs(V-f.current);f.current=V,le>10&&(d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,x(be=>be.isSettled?be:{...be,isSettled:!0})},a))}else d.current!==null&&(clearTimeout(d.current),d.current=null);x(le=>{const be=Y?le.isSettled:!1;return le.isOpen===Y&&le.keyboardHeight===V&&le.isSettled===be?le:(c("sync",{keyboardHeight:V,isOpen:Y,isSettled:be,visualViewport:sl().visualViewport?{width:Math.round(sl().visualViewport.width),height:Math.round(sl().visualViewport.height),offsetTop:Math.round(sl().visualViewport.offsetTop)}:null}),{isOpen:Y,isSettled:be,keyboardHeight:V})})},v=(V="event")=>{(V.includes("visibilitychange")||V.includes("pageshow"))&&c("schedule",{source:V}),y===null&&(y=window.requestAnimationFrame(w))};v("mount");const S=()=>v("resize"),C=()=>v("orientationchange"),I=()=>v("visualViewport.resize"),R=()=>v("visualViewport.scroll"),B=()=>v("viewport-keyboard-change");window.addEventListener("resize",S),window.addEventListener("orientationchange",C),sl().visualViewport?.addEventListener("resize",I),sl().visualViewport?.addEventListener("scroll",R),document.addEventListener("termdock:viewport-keyboard-change",B);const z=V=>{c("resume",{source:V,keyboardHeight:F2(),hidden:document.hidden}),v(`${V}:now`),window.setTimeout(()=>v(`${V}:50ms`),50),window.setTimeout(()=>v(`${V}:200ms`),200)},O=()=>{document.hidden||z("visibilitychange")},$=()=>z("pageshow");return document.addEventListener("visibilitychange",O),window.addEventListener("pageshow",$),()=>{window.removeEventListener("resize",S),window.removeEventListener("orientationchange",C),sl().visualViewport?.removeEventListener("resize",I),sl().visualViewport?.removeEventListener("scroll",R),document.removeEventListener("termdock:viewport-keyboard-change",B),document.removeEventListener("visibilitychange",O),window.removeEventListener("pageshow",$),y!==null&&window.cancelAnimationFrame(y),d.current!==null&&(clearTimeout(d.current),d.current=null)}},[c,t,r,n,a]),m}const Yh=300,DE=120,BE=2e3,QE=250,PE=6e4;function OE(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 rm(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function yh(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function FE(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function $E(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function UE(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function zE(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function HE(e){return!e.initialConnectionPending}function WE(e){return!e}function GE(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function VE(e,t){return[...e].every(r=>t.has(r))}function qE(e,t){return e===null||t-e>=QE}function YE(e){return!1}function ZE(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,PE-(e.now-e.reconnectStartedAt))}function KE(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,Yh+n*DE),n+=1}return r}const XE="Session not found on server",Zh="Terminal session not found",JE="STALE_SESSION_RESTORE_REJECTED";function $2(e){return c1(e)?!1:e?.message===XE||e?.status===404&&e.message===Zh}function c1(e){return e?.code===JE}function eN(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function iv(e,t){return eN(e,t).replace(/ /g,"\\ ")}function u1(e,t){return`${iv(e,t)} `}function U2(e,t){return iv(e,t)}function QU(e,t,r){if(!r)return U2(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${U2(e,t)}:${n}`}const tN="/tmp";async function rN(e,t,r){const a=(await t(tN,[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 wf(a)}if(!c)throw new wf(a);return a}class wf extends Error{constructor(t){super("File uploaded, but its reference was not accepted"),this.uploaded=t,this.name="UploadedReferenceRejectedError"}uploaded}function z2(e,t,r,n,a){if(!e||!t||!r())return Promise.resolve(!1);const c=n?wC(n,t,e):null;if(n&&!c)return Promise.resolve(!1);const l=c?.nonce??`reference-${crypto.randomUUID()}`;return new Promise(d=>{let f=!1;const m=w=>{f||(f=!0,window.clearTimeout(y),window.removeEventListener("termdock-insert-reference-ack",x),c&&AC(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 av=[640,960,1280,1600,2048,2560,3072,4096],ov=[240,360,480,540,720,1080,1440,2160],a0={min:.1,max:1,step:.01},o0={min:25e4,max:2e7,step:25e4},ng="termdock:mobile-media-compression-v1",vu={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function lv(){try{const e=JSON.parse(localStorage.getItem(ng)||"null");return!e||typeof e!="object"?vu:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:av.includes(e.imageMaxDimension)?e.imageMaxDimension:vu.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=a0.min&&e.imageQuality<=a0.max?e.imageQuality:vu.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:ov.includes(e.videoMaxHeight)?e.videoMaxHeight:vu.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=o0.min&&e.videoBitrate<=o0.max?e.videoBitrate:vu.videoBitrate}}catch{return vu}}const sg=hc((e,t)=>({preferences:lv(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(ng,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===ng||e.key===null)&&sg.setState({preferences:lv(),saveFailed:!1})});function vh(e){if(e<1024)return`${e} B`;const t=["B","KB","MB","GB","TB"],r=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${Number((e/1024**r).toFixed(1))} ${t[r]}`}function nN({result:e,message:t,onClose:r}){const{locale:n}=Ur(),a=n==="zh",c=b.useRef(null),[l,d]=b.useState(null),[f,m]=b.useState(!1);return b.useEffect(()=>{const x=URL.createObjectURL(e.file);return d(x),m(!1),()=>URL.revokeObjectURL(x)},[e.file]),b.useEffect(()=>{const x=c.current;return x?.showModal(),()=>x?.close()},[]),s.jsx("dialog",{ref:c,"aria-label":a?"上传结果预览":"Uploaded media preview",onCancel:x=>{x.preventDefault(),r()},onClick:x=>{x.target===x.currentTarget&&r()},onKeyDown:x=>x.stopPropagation(),onKeyUp:x=>x.stopPropagation(),className:"fixed inset-0 z-modal-panel m-0 h-[100dvh] max-h-none w-screen max-w-none bg-transparent p-3 text-foreground backdrop:bg-[var(--app-backdrop)] open:flex open:items-center open:justify-center",children:s.jsxs("section",{className:"flex max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-1.5rem)] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-start gap-3 border-b border-border/15 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-sm font-semibold",children:a?"上传结果预览":"Uploaded media preview"}),s.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:t}),s.jsx("p",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:e.file.name})]}),s.jsx("button",{type:"button",autoFocus:!0,onClick:r,"aria-label":a?"关闭预览":"Close preview",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:s.jsx(In,{size:18})})]}),s.jsx("div",{className:"min-h-0 overflow-auto p-2",children:f?s.jsx("p",{role:"alert",className:"p-4 text-sm text-muted-foreground",children:a?"文件已上传,但当前浏览器无法预览此格式。":"File uploaded, but this browser cannot preview this format."}):l&&(e.kind==="image"?s.jsx("img",{src:l,alt:e.file.name,onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] max-w-full object-contain"}):s.jsx("video",{src:l,controls:!0,playsInline:!0,preload:"metadata",onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] w-full"}))})]})})}function sN({result:e,onDismiss:t}){const{locale:r}=Ur(),n=r==="zh",a=sg(I=>I.preferences.showResultToast),c=a?e:null,[l,d]=b.useState(null);b.useEffect(()=>{if(!e)return;if(!a){t();return}const I=window.setTimeout(t,2e3);return()=>window.clearTimeout(I)},[e,a,t]);const f=c??l?.result;if(!f)return null;const m=f.originalSize-f.uploadedSize,x=f.originalSize>0?Math.abs(m)/f.originalSize*100:0,y=x<1?"<1%":`${Math.floor(x)}%`,w=f.kind==="image"?n?"图片":"Image":n?"视频":"Video",v=m>0?n?"已压缩上传":"Compressed upload":n?"已处理上传":"Processed upload",S=m>0?n?`省 ${y}`:`${y} saved`:m<0?`+${y}`:n?"体积未变":"Size unchanged",C=f.originalRetained?n?`已尝试压缩 · 保留原图 ${vh(f.uploadedSize)},已上传`:`Compression tried · original ${vh(f.uploadedSize)} uploaded`:`${v} · ${vh(f.originalSize)} → ${vh(f.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}:${C} · ${n?"点击预览":"Preview"}`,onClick:()=>{d({result:c,message:C}),t()},className:"pointer-events-auto flex max-w-full select-none items-center gap-1.5 rounded-full border border-border/15 bg-surface-elevated px-3 py-2 text-[11px] leading-4 text-foreground shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(pi,{size:13,strokeWidth:2.5,className:"shrink-0 text-primary","aria-hidden":"true"}),s.jsx("span",{className:"truncate tabular-nums",children:C}),s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n?"预览 ›":"Preview ›"})]})}),l&&Js.createPortal(s.jsx(nN,{result:l.result,message:l.message,onClose:()=>d(null)}),document.body)]})}const iN=320,H2="termdock:mobile-keyboard-expanded",W2="termdock:mobile-keyboard-preset-mode",G2="termdock:mobile-long-press-mode",aN=80;function oN(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function V2(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 lN(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 nm(){return Ty()}const cN={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},uN=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=eg(),colorTheme:a="dark",toolbarPresets:c=[],isActive:l=!0,focusSuspended:d=!1,deferCursorUntilPositioned:f=!1,isLayoutVisible:m=!0,focusRequestToken:x=0,resumeRequestToken:y=0,resumeRequestReason:w="visibility",resumeRequestDelayMs:v=0,forceResumeReconnect:S=!1,initialConnectDelayMs:C=0,initialConnectEnabled:I=!0,resumeRequestEnabled:R=!0,onStreamReadyChange:B,onStreamConnected:z,onViewportReadyChange:O,onContentReadyChange:$,onKeyboardVisibilityChange:V,suppressKeyboard:Y=!1,keyboardPortalTarget:le=null,sharedMobileKeyboardLayout:be=!1,suppressPageFlipRefresh:pe=!1,showDebug:ee,onStatusChange:ke})=>{const{t:He}=Ur(),[q]=L.useState(e||i3()),[ce,qe]=L.useState(()=>(e?$m(e):null)??n.fontSize),Ae=L.useMemo(()=>fE(),[]),ve=L.useMemo(()=>Fu("session"),[]),Ie=L.useMemo(()=>Fu("keyboard"),[]),Be=L.useRef(null),ne=L.useRef(null);L.useEffect(()=>{$m(q)===null&&qe(n.fontSize)},[n.fontSize,q]);const Fe=L.useMemo(()=>({...n,fontSize:ce}),[n,ce]),Le=p8(),Re=d||Le,[Pe,Ee]=L.useState(nm),[oe,We]=L.useState(!1),[rt,gt]=L.useState(!1),[ue,Ye]=L.useState(!1),[at,Ne]=L.useState(()=>typeof document>"u"?!0:!document.hidden&&Cu()),[Ge,Ce]=L.useState(()=>typeof document>"u"?!0:document.hasFocus()),[H,ae]=L.useState(!1),ye=L.useRef(H);ye.current=H;const[Ve,Je]=L.useState(!1),[bt,Vt]=L.useState(!1),[Pt,mt]=L.useState(!1),[Zt,Ht]=L.useState(!0),{isOpen:Kt,keyboardHeight:Ot}=sv({enabled:Pe&&l}),[Nt,me]=L.useState(null),[Ze,ct]=L.useState(null),[Tt,X]=L.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(H2)==="true"),[yt,nt]=L.useState(()=>{if(typeof window>"u")return"auto";const se=window.localStorage.getItem(W2);return se&&se.length>0?se:"auto"}),[_e,tr]=L.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(G2)==="copy"?"copy":"arrows"),[Ke,kt]=L.useState("idle"),[Ut,vt]=L.useState("idle"),[wt,Mt]=L.useState(0),[_t,fr]=L.useState(null),[qt,Sr]=L.useState(null),[pn,dr]=L.useState(null),ge=L.useCallback(()=>dr(null),[]),{preferences:Gr,update:ot,saveFailed:ft}=sg(),{videoEnabled:ir,videoMaxHeight:Mn,videoBitrate:Xr,imageEnabled:De,imageMaxDimension:st,imageQuality:xt}=Gr,[Br,Vr]=L.useState(!1),[Cr,qr]=L.useState(null),[mn,on]=L.useState(null),zr=Yr(se=>se.sessions.get(q)),{setTerminalSession:un,setConnecting:Er,appendToBuffer:re,replaceBuffer:pt,clearTerminalSession:jt,removeTerminalSession:nr,clearBuffer:Ar,setSessionActiveProgram:Fr,setSessionCwd:Xt,setSessionCopyMode:Zr,setSessionAgentStatus:Jt,setSessionShellTitle:Pr,setSessionPromptState:Hr,clearAgentNeedsReview:ps}=Yr.getState(),Mr=L.useMemo(()=>`wt-${q.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[q]),jn=zr?.terminalSessionId??null,Tr=zr?.mode??"shell",Jr=zr?.activeProgram??null,ln=L.useMemo(()=>Ru(c),[c]),Qr=Tr==="tmux",ks=zr?.bufferChunks??[],Dr=zr?.isConnecting??!1,en=jn,xn=L.useCallback(async(se,T)=>{const j=DI(se,zr?.cwd||zr?.directory);if(!j)return;let Q=j,F="directory";try{Q=(await Q1(j)).path}catch(xe){if(!(xe instanceof Error)||xe.message!=="Path is not a directory")return;F="file"}try{const xe=Gt.getState();xe.setRightTab("files"),xe.openRight(),window.dispatchEvent(new CustomEvent(II,{detail:{path:Q,kind:F,line:T}}))}catch{}},[zr?.cwd,zr?.directory]),K=t??zr?.mode??"shell",ze=K==="tmux"?r??zr?.tmuxSessionName??null:null,[Rt,Et]=L.useState(null),rr=L.useRef(!1),[jr,cr]=L.useState(!1),[Cn,Ls]=L.useState(!1),[Xn,cn]=L.useState(null),[dn,_r]=L.useState(0),[Or,Gn]=L.useState(null),Vn=ee!==void 0?ee:!1,gn=L.useRef(null),Jn=L.useRef(null),kr=L.useRef(null),Lr=L.useRef(null),pr=L.useRef(null),ns=L.useRef(!1),Un=L.useRef(null),En=L.useRef([]),kn=L.useRef(0),ss=L.useRef(!1),Wr=L.useRef(null),tn=L.useRef(null),G=L.useRef(-1),je=L.useRef(null),$e=L.useRef(0),et=L.useRef(null),it=L.useRef(null),Ct=L.useRef(0),Lt=L.useRef(0),Bt=L.useRef(!1),ht=L.useRef(null),Qt=L.useRef(null),W=L.useRef(!1),N=L.useRef(0),U=L.useRef(!1),Z=L.useRef(!1),fe=L.useRef(!1),Qe=L.useRef(null),we=L.useRef(null),lt=L.useRef(null),At=L.useRef(l);At.current=l;const br=L.useRef(Re);br.current=Re;const It=L.useRef(d);It.current=d;const rn=L.useRef(Pe),yn=L.useRef(null),hn=L.useRef(null),Dn=L.useRef(null),zn=L.useRef(null),hr=L.useRef(null),Dt=L.useRef(null),Bn=L.useRef(null),qn=L.useCallback(()=>{const se=++N.current,T=()=>{se===N.current&&Je(!0)};if(typeof window>"u"){T();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(T))},[]),Ga=L.useCallback(se=>{if(U.current){if(we.current!==null&&(window.clearTimeout(we.current),we.current=null),se.x===0&&se.y>=se.rows-1){Ht(!1);return}we.current=window.setTimeout(()=>{we.current=null,Ht(!0)},aN)}},[]),Qn=L.useRef(null);L.useEffect(()=>()=>{Qn.current?.()},[]);const is=L.useCallback(()=>{Qn.current||(Qn.current=H1(()=>{Qn.current=null;const se=Yr.getState(),T=kr.current,j=se.getTerminalSession(q);if(!T||j?.mode!=="shell"||se.hasPendingBufferWrites(q))return;const Q=m8(T),F=pr.current?.getDimensions();if(!Q||!F)return;const xe=pr.current?.serializeSnapshot();xe&&g8({id:T,version:1,...Q,...F,data:xe,savedAt:Date.now()})},2e3))},[q]),zi=L.useCallback(se=>{const T=Yr.getState(),j=T.getTerminalSession(q)?.bufferChunks.at(-1)?.id;if(kr.current&&j!==void 0&&j<=se&&!T.hasPendingBufferWrites(q)&&(x8(kr.current),is()),!Bt.current||!zE({writtenChunkId:se,initialTargetChunkId:ht.current}))return;const Q=Qt.current;Qt.current=null,Q!==null&&pr.current?.notifyScreenSynchronized(Q),Bt.current=!1,ht.current=null,qn()},[qn,is,q]),ha=L.useCallback(se=>{if(!U.current)return;const T=Qe.current;T&&T.x===se.x&&T.y===se.y&&T.rows===se.rows||(Qe.current=se,we.current!==null&&(window.clearTimeout(we.current),we.current=null),se.x===0&&se.y>=se.rows-1&&Ht(!1))},[]);L.useEffect(()=>{if(!f){Z.current=!1;return}Z.current||(Z.current=!0,fe.current=!1,U.current=!0,Qe.current=null,Ht(!1),we.current!==null&&(window.clearTimeout(we.current),we.current=null),lt.current!==null&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>{lt.current=null,we.current!==null&&typeof window<"u"&&window.clearTimeout(we.current),we.current=null,U.current=!1,Ht(!0)},15e3))},[f]);const bs=L.useCallback(()=>{zn.current=null;const se=Dn.current;Dn.current=null,se&&Pr(se.sessionId,se.title)},[Pr]),Va=L.useCallback((se,T)=>{if(Dn.current={sessionId:se,title:T},zn.current===null){if(typeof window>"u"){bs();return}zn.current=window.requestAnimationFrame(bs)}},[bs]),So=L.useCallback(()=>{zn.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(zn.current),zn.current=null,Dn.current=null},[]),Hn=L.useCallback(async()=>{const se=K;return(await b8({preferredFrontendSessionId:q,mode:se,tmuxSessionName:se==="tmux"?ze||Mr:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[K,ze,Mr,q]),fa=L.useRef(l);L.useEffect(()=>{if(!l){pr.current?.blur(),fa.current=!1;return}if(fa.current)return;fa.current=!0;const se=YL(Pe,pe);if(se==="single"){pr.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}se!=="none"&&pr.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[l,Pe,pe,en]),L.useEffect(()=>{rn.current=Pe},[Pe]);const ms=L.useCallback(()=>{!At.current||br.current||pr.current?.focus()},[]);L.useLayoutEffect(()=>{Re&&pr.current?.blur()},[Re]),L.useEffect(()=>{if(!l||Re||Zt||fe.current)return;fe.current=!0;const se=window.requestAnimationFrame(()=>{pr.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(se)},[Re,l,Zt]);const Ia=L.useCallback(se=>{typeof window>"u"||typeof document>"u"||!At.current||br.current||rn.current||document.hidden||!Cu()||(yn.current!==null&&window.clearTimeout(yn.current),yn.current=window.setTimeout(()=>{if(yn.current=null,!At.current||br.current||rn.current||document.hidden||!Cu())return;const T=document.activeElement,j=T?.getAttribute("data-terminal-input-anchor")==="true";if((T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T?.isContentEditable===!0)&&!j){Ie("desktop resume focus skipped: editable active",{reason:se});return}Ie("desktop resume focus",{reason:se}),pr.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),pr.current?.focus()},50))},[Ie]);L.useEffect(()=>()=>{yn.current!==null&&typeof window<"u"&&window.clearTimeout(yn.current),yn.current=null,hn.current!==null&&typeof window<"u"&&window.clearTimeout(hn.current),hn.current=null,hr.current!==null&&typeof window<"u"&&window.clearTimeout(hr.current),hr.current=null,Dt.current!==null&&typeof window<"u"&&window.clearTimeout(Dt.current),Dt.current=null,lt.current!==null&&typeof window<"u"&&window.clearTimeout(lt.current),lt.current=null,we.current!==null&&typeof window<"u"&&window.clearTimeout(we.current),we.current=null},[]),L.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const se=()=>{hn.current!==null&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>{hn.current=null;const T=document.activeElement,Q=!(T?.getAttribute("data-terminal-input-anchor")==="true")&&!!(T&&(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T.isContentEditable));ZS({isActive:At.current&&!br.current,isMobile:rn.current,documentVisible:!document.hidden,activeElementIsEditable:Q})&&ms()},0)};return document.addEventListener("pointerup",se),()=>{document.removeEventListener("pointerup",se),hn.current!==null&&(window.clearTimeout(hn.current),hn.current=null)}},[ms]);const as=L.useCallback(()=>{Hi.current=!1,_r(se=>se+1)},[]),qa=L.useCallback((se,T,j)=>{const Q=kr.current,F=Date.now();if(Q&&T&&y8(Q)){ne.current={startedAt:F,strategy:"reconnect",reason:se},ka("info","PWA_RESUME terminal-start",{frontendSessionId:q,backendSessionId:Q,strategy:"reconnect",reason:se,active:At.current});return}if(Q&&v8(Q,()=>{const xe=ne.current;ka("info","PWA_RESUME terminal-responsive",{frontendSessionId:q,backendSessionId:Q,durationMs:xe?Date.now()-xe.startedAt:null,strategy:xe?.strategy??"probe",reason:xe?.reason??se}),ne.current=null,z?.(q)},{visible:j})){ne.current={startedAt:F,strategy:"probe",reason:se},ka("info","PWA_RESUME terminal-start",{frontendSessionId:q,backendSessionId:Q,strategy:"probe",reason:se,active:At.current}),ve("[Terminal] resume probe sent",{reason:se,backendSessionId:Q,active:At.current});return}if(ve("[Terminal] resume probe missing connection, restarting ensureSession",{reason:se,backendSessionId:Q,active:At.current}),!HE({initialConnectionPending:W.current})){ve("[Terminal] resume probe deferred during initial websocket handshake",{reason:se,backendSessionId:Q});return}as()},[ve,z,as,q]),ei=L.useCallback((se,T)=>{const j=kr.current;j&&Un.current!==se&&(Un.current=se,nx(j,se,T),ve("[Terminal] flow-control state sent",{backendSessionId:j,paused:se,reason:T}))},[ve]),ti=L.useCallback((se,T)=>{const j=kr.current;j&&et.current!==se&&(et.current=se,sx(j,se,T),ve("[Terminal] focus state sent",{backendSessionId:j,focused:se,reason:T}))},[ve]),Hs=L.useCallback((se,T)=>{const j=kr.current;j&&it.current!==se&&(it.current=se,ix(j,se,T),ve("[Terminal] viewing state sent",{backendSessionId:j,viewing:se,reason:T}))},[ve]),Ya=qS({isActive:l&&!Re,viewportFocused:ue,documentVisible:at,windowFocused:Ge,streamReady:H}),Is=YS({isActive:l,documentVisible:at,windowFocused:Ge,streamReady:H,isDesktop:vo()!==null}),pa=L.useRef(Ya),dl=L.useRef(Is);L.useEffect(()=>{pa.current=Ya,ti(Ya,"logical-focus-change")},[Ya,ti,en]),L.useEffect(()=>{dl.current=Is,Hs(Is,"logical-viewing-change")},[Is,Hs,en]),_C(en,at,H),L.useEffect(()=>{const se=T=>{const j=T.detail;!j||j.sessionId!==q||qe(j.fontSize??n.fontSize)};return window.addEventListener("termfontchange",se),()=>window.removeEventListener("termfontchange",se)},[q,n.fontSize]),L.useEffect(()=>{const se=()=>{const F=!document.hidden&&Cu();Ne(F),F&&l&&Ia("visibility")},T=F=>{l&&Ia(F.persisted?"bfcache":"pageshow")},j=()=>{Ce(!0),Ia("window-focus")},Q=()=>Ce(!1);return document.addEventListener("visibilitychange",se),window.addEventListener(ax,se),window.addEventListener("pageshow",T),window.addEventListener("focus",j),window.addEventListener("blur",Q),()=>{document.removeEventListener("visibilitychange",se),window.removeEventListener(ax,se),window.removeEventListener("pageshow",T),window.removeEventListener("focus",j),window.removeEventListener("blur",Q)}},[l,Ia]),L.useEffect(()=>{if(!y||!R||!xi.current)return;const se=v,T=se<=0,j=Be.current;if(j?.token===y&&(j.visible||!T))return;const Q=()=>{Be.current={token:y,visible:T},pr.current?.requestRefresh(w,{skipScrollToBottom:!0}),qa(se>0?"global-resume-background":"global-resume-visible",se<=0&&S,T)};if(se<=0){Q();return}const F=window.setTimeout(Q,se);return()=>window.clearTimeout(F)},[y,w,R,v,S,qa]);const Za=L.useRef(0);L.useEffect(()=>{if(H){Za.current=0;return}if(!jr||Rt==="Authentication required"||Rt===Zh)return;const se=Za.current,T=Math.min(2e3*Math.pow(2,Math.min(se,4)),3e4),j=setTimeout(()=>{Za.current+=1,ve("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:Za.current,backendSessionId:kr.current}),Et("Reconnecting..."),cr(!1),as()},T);return()=>clearTimeout(j)},[Rt,jr,H,dn,ve,as]),L.useEffect(()=>{if(typeof window>"u"){We(!1);return}const se=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;We(se)},[]),L.useEffect(()=>{(!l||!Pe)&>(!1),l||Ye(!1)},[l,Pe]),L.useEffect(()=>{kr.current=en,G.current=-1,Qt.current=null,et.current=null,it.current=null,Un.current=null},[en]),L.useEffect(()=>{B?.(q,H)},[H,B,q]),L.useEffect(()=>{$?.(q,H&&Ve&&bt)},[Ve,bt,H,$,q]),L.useEffect(()=>{Qr||(ss.current=!1,Wr.current=null,tn.current&&(clearTimeout(tn.current),tn.current=null))},[Qr]),L.useEffect(()=>{en&&pr.current?.requestRefresh("session-key-change",{force:!0})},[en]),L.useEffect(()=>{const se=l&&Pe&&Kt;Ie("visibility signal",{sessionId:q,isActive:l,isMobile:Pe,isInputFocused:rt,isViewportKeyboardOpen:Kt,viewportKeyboardHeight:Ot,visible:se}),V?.(q,se)},[V,q,l,Pe,Kt,Ot,Ie]),L.useEffect(()=>{l&&x&&x!==$e.current&&($e.current=x,ms())},[x,ms,l]),L.useEffect(()=>{Lr.current=q},[q]),L.useEffect(()=>{!Pe&&(Nt!==null||Ze!==null)&&(me(null),ct(null),je.current=null)},[Pe,Nt,Ze]),L.useEffect(()=>{!en&&(Nt!==null||Ze!==null)&&(me(null),ct(null),je.current=null)},[en,Nt,Ze]),L.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(H2,Tt?"true":"false")},[Tt]),L.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(W2,yt)},[yt]),L.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(G2,_e)},[_e]),L.useEffect(()=>{Ee(nm());const se=()=>{Ee(nm())};return window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]);const os=L.useCallback(()=>{Ct.current+=1,Lt.current+=1,bs(),So();const se=gn.current;gn.current=null,Jn.current=null,W.current=!1,ye.current=!1,ae(!1),pr.current?.setSessionReady(!1);const T=kr.current;T&&nx(T,!1,"stream-disconnect"),ns.current=!1,Un.current=null,En.current=[],se?.()},[So,bs]),js=L.useCallback(async se=>{if(Jn.current===se){ve(`[startStream] Skipping - already connected to ${se}`);return}ve(`[startStream] Starting stream for frontendSessionId=${q} backendSessionId=${se}`),cn(null),N.current+=1,Bt.current=!1,ht.current=null,Je(!1),Vt(!1),os();const T=Ct.current+1;Ct.current=T,W.current=!0;const j=Yr.getState().getTerminalSession(q);if(j?.mode==="shell"&&!j.bufferChunks.length){const F=await Promise.race([w8(se),new Promise(xe=>window.setTimeout(()=>xe(null),75))]);if(Ct.current!==T||Lr.current!==q)return;if(F&&!Yr.getState().getTerminalSession(q)?.bufferChunks.length){Yr.getState().replaceBuffer(q,[F.data]);const xe=pr.current?.getDimensions();xe?.cols===F.cols&&xe.rows===F.rows&&A8(se,F.seq,F.epoch)}}const Q=Ae.connect(se,{onEvent:F=>{if(Ct.current!==T)return;const xe=q;if(xe)switch(F.type){case"connected":{Lt.current+=1,W.current=!1;const Se=ne.current;Se&&(ka("info","PWA_RESUME terminal-connected",{frontendSessionId:xe,backendSessionId:kr.current,durationMs:Date.now()-Se.startedAt,strategy:Se.strategy,reason:Se.reason}),ne.current=null),z?.(xe),(F.runtime||F.ptyBackend)&&ve(`[Terminal] connected frontendSessionId=${xe} backendSessionId=${kr.current} runtime=${F.runtime??"unknown"} pty=${F.ptyBackend??"unknown"} cwd=${F.cwd??"unknown"}`),Er(xe,!1),Et(null),cr(!1),cn(null),ye.current=!0,ae(!0),kr.current&&(sx(kr.current,pa.current,"stream-connected"),ix(kr.current,dl.current,"stream-connected")),pr.current?.setSessionReady(!0),Un.current=null,ei(ns.current,"stream-connected"),F.tuiProgress!==void 0&&Yr.getState().setSessionTuiProgress(xe,F.tuiProgress??null),F.shellTitle!==void 0&&Yr.getState().setSessionShellTitle(xe,F.shellTitle??null),F.promptState!==void 0&&F.promptState!==null&&Yr.getState().setSessionPromptState(xe,F.promptState);const Oe=Yr.getState().getTerminalSession(xe);if(Oe?.terminalSessionId&&F.mode&&Yr.getState().setTerminalSession(xe,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:F.mode,tmuxSessionName:F.tmuxSessionName??null,cwd:F.cwd??null}),F.activeProgram!==void 0&&Fr(xe,F.activeProgram??null,F.activeProgramSource??null,F.activeProgramRaw??null),pr.current?.requestRefresh("connected",{force:!0,reconcileServerSize:At.current}),F.mode!=="tmux"&&(Gn(null),Zr(xe,!1)),ve("[Terminal] Connected event received:",{frontendSessionId:xe,backendSessionId:kr.current,storeHasState:!!Oe,storeTerminalId:Oe?.terminalSessionId,hasHistoryInStore:!!Oe?.history?.length,historyLength:Oe?.history?.length??0}),Oe?.history&&Oe.history.length>0){ve(`[Terminal] Restoring ${Oe.history.length} history chunks to frontend session ${xe}`);const er=Oe.history.reduce(($r,nn)=>$r+nn.length,0),or=Math.max(300,Math.min(2e3,Math.ceil(er/200)));kn.current=Date.now()+or,Oe.history.forEach($r=>{re(xe,$r,{markActivity:!1})}),Yr.getState().setSessionHistory(xe,[]),ve(`[Terminal] History restoration complete for ${xe}`)}else ve(`[Terminal] No history to restore for ${xe}`);const Xe=F.replayChunks,dt=!!Oe?.history?.length||!!Xe?.length;if(dt?Bt.current=!0:qn(),Xe&&Xe.length>0){let er=null;if(F.replayOutOfWindow)ve(`[Terminal] Replay out-of-window, atomically replacing buffer (${Xe.length} chunks)`),er=pt(xe,jC(Xe));else{ve(`[Terminal] Replay incremental: ${Xe.length} chunks`);for(const nn of Xe)re(xe,nn)}const or=Xe.reduce((nn,Pn)=>nn+Pn.length,0),$r=Math.max(200,Math.min(1500,Math.ceil(or/200)));kn.current=Math.max(kn.current,Date.now()+$r),ht.current=er}dt&&ht.current===null&&(ht.current=Yr.getState().flushPendingBufferWrites(xe),ht.current===null&&(Bt.current=!1,qn()));break}case"reconnecting":{ye.current=!1,ae(!1),cn(Se=>Se??Date.now()),Et("Reconnecting..."),cr(!1);break}case"data":{F.data&&(ns.current?En.current.push(F.data):re(xe,F.data));break}case"tmux-layout":{Gn(F.layout??null),F.layout&&Zr(xe,F.layout.inCopyMode);break}case"tmux-screen-sync":{const Se=F.generation??0;if(Se<G.current)break;G.current=Se,N.current+=1,Bt.current=!0,Je(!1),En.current=[],pr.current?.prepareScreenReplacement(),Qt.current=Se,ht.current=pt(xe,DC(F.chunks??[])),ht.current===null&&(Qt.current=null,pr.current?.notifyScreenSynchronized(Se),Bt.current=!1,qn()),typeof F.cols=="number"&&typeof F.rows=="number"&&pr.current?.notifyServerSize(F.cols,F.rows,"tmux-screen-sync");break}case"active-program":{Fr(xe,F.activeProgram??null,F.activeProgramSource??null,F.activeProgramRaw??null);break}case"cwd":{Xt(xe,F.cwd??null);break}case"agent-status":{Jt(xe,{agentStatus:F.agentStatus??null,agentIndicator:F.agentIndicator??null,agentStatusDetail:F.agentStatusDetail??null,agent:F.agent??null,agentMessage:F.agentMessage??null,agentNativeSessionId:F.agentNativeSessionId??null,agentResumeRecovered:F.agentResumeRecovered===!0,agentRich:F.agentRich===!0,agentActivity:F.agentActivity??0,agentCwd:F.agentCwd??null,reviewed:F.reviewed??null});break}case"git-status":{Yr.getState().setSessionGitStatus(xe,F.gitStatus??null);break}case"focus-mode":{ve("[Terminal] focus tracking mode",{backendSessionId:kr.current,requested:F.focusTrackingRequested===!0});break}case"resize-ack":{pr.current?.acknowledgeResize({seq:F.seq,ok:F.ok!==!1,cols:F.cols,rows:F.rows,screenSyncPending:F.screenSyncPending,screenSyncGeneration:F.screenSyncGeneration});break}case"pty-size":{typeof F.cols=="number"&&typeof F.rows=="number"&&pr.current?.notifyServerSize(F.cols,F.rows,F.source);break}case"shell-title":{Va(xe,F.title??null);break}case"prompt-state":{Hr(xe,F.state??"idle",F.exitCode??null);break}case"tui-progress":{Yr.getState().setSessionTuiProgress(xe,F.tuiProgress??null);break}case"exit":{const Se=typeof F.exitCode=="number"?F.exitCode:null,Oe=typeof F.signal=="number"?F.signal:null;re(xe,`\r
|
|
76
|
-
[Process exited${Se!==null?` with code ${Se}`:""}${Oe!==null?` (signal ${Oe})`:""}]\r
|
|
77
|
-
`),jt(xe),Er(xe,!1),Et("Terminal session ended"),ae(!1),cr(!1),cn(null),Gn(null),Zr(xe,!1),os();break}}},onError:(F,xe)=>{if(Ct.current!==T)return;const Se=q;if(!Se)return;W.current=!1,ye.current=!1,ae(!1);const Oe=xe&&F.message==="Authentication required",Xe=$2(F),dt=Oe?F.message:Xe||xe?"Reconnecting...":F.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${xe}):`,dt),Xe&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:kr.current,frontendSessionId:Se,isActive:l,isMobile:Pe,fatal:xe,stack:new Error().stack}),Et(dt),cr(!!xe),xe&&(cn(null),Er(Se,!1),os(),Xe&&(ve("[onError] Session lost, auto-recreating"),Et("Reconnecting..."),cr(!1),jt(Se),Ar(Se),kr.current=null,Hi.current=!1,as()))}},{...cN,getDimensions:()=>pr.current?.getDimensions()??null});gn.current=()=>{Q.close(),Ct.current===T&&(Jn.current=null)},Jn.current=se},[re,Ar,jt,ve,os,qn,z,ei,as,Va,Er,Fr,Jt,Zr,Xt,Hr,Ae,q]);L.useEffect(()=>{const se=ZE({isActive:l,isStreamReady:H,reconnectStartedAt:Xn,now:Date.now()});if(se===null)return;const T=window.setTimeout(()=>{ve("[Terminal] visible reconnect watchdog expired",{backendSessionId:kr.current,reconnectStartedAt:Xn}),os(),Er(q,!1),Et("Reconnecting..."),cr(!1),cn(Date.now()),as()},se);return()=>window.clearTimeout(T)},[ve,os,l,H,Xn,as,q,Er]);const Hi=L.useRef(!1),xi=L.useRef(!1),bi=L.useRef(0);L.useEffect(()=>()=>{bi.current+=1,Hi.current=!1,os()},[os]);const hl=L.useRef(K),ri=L.useRef(ze);L.useEffect(()=>{const se=hl.current,T=ri.current;hl.current=K,ri.current=ze,Lr.current===q&&(se===K&&T===ze||(Hi.current=!1,os(),_r(j=>j+1)))},[K,ze,os,q]),L.useEffect(()=>{if(Lr.current!==q&&(ve(`[useEffect] sessionId changed from ${Lr.current} to ${q}, allowing reinitialization`),Hi.current=!1,xi.current=!1),Hi.current&&Lr.current===q){ve(`[useEffect] Already initialized for sessionId=${q}, skipping`);return}if(!Pt)return;const se=async xe=>{if(ve(`[ensureSession] Starting for sessionId=${q}, runId=${xe}`),!Lr.current||Lr.current!==q){ve(`[ensureSession] SessionId mismatch or stale run (current=${Lr.current}, target=${q}), skipping`);return}if(xe!==bi.current){ve(`[ensureSession] Stale run detected (runId=${xe}, currentRunId=${bi.current}), skipping`);return}const Se=Yr.getState(),Oe=Se.getTerminalSession(q),Xe=Oe?.mode??K;ve("[ensureSession] Current state from store:",{terminalSessionId:Oe?.terminalSessionId,mode:Oe?.mode,tmuxSessionName:Oe?.tmuxSessionName,isConnecting:Oe?.isConnecting});let dt=Oe?.terminalSessionId??null,er=!dt;if(dt&&Xe!==K?(ve(`[ensureSession] Store mode mismatch for ${dt}: current=${Xe} desired=${K}, will create new session`),er=!0,Se.clearTerminalSession(q),dt=null):dt&&K==="tmux"&&ze&&Oe?.tmuxSessionName!==ze&&(ve(`[ensureSession] Store tmux name mismatch for ${dt}: current=${Oe?.tmuxSessionName} desired=${ze}, will create new session`),er=!0,Se.clearTerminalSession(q),dt=null),dt&&Ae.checkHealth&&!At.current){ve(`[ensureSession] Checking health of existing session ${dt}`);try{const or=await Ae.checkHealth(dt);if(ve("[ensureSession] Health check result:",or),!or.healthy)ve(`[ensureSession] Session ${dt} is NOT healthy (healthy=${or.healthy}), will create new session`),ve("[ensureSession] Health check details:",or),er=!0,or.mode&&Oe?.terminalSessionId&&Se.setTerminalSession(q,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),Se.clearTerminalSession(q),ve("[ensureSession] Cleared unhealthy session from store");else{ve(`[ensureSession] Session ${dt} is healthy, reusing it, cwd=${or.cwd}, clients=${or.clients}, lastActivity=${Date.now()-(or.lastActivity||0)}ms ago`),or.mode&&Oe?.terminalSessionId&&Se.setTerminalSession(q,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:or.mode,tmuxSessionName:or.tmuxSessionName??null}),ve(`[ensureSession] Setting terminalIdRef to ${dt} and starting stream`),kr.current=dt,js(dt),ve(`[ensureSession] Successfully reused healthy session ${dt}, returning early`);return}}catch(or){ve(`[ensureSession] Failed to check health of session ${dt}:`,or),ve("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ve(`[ensureSession] Decision: shouldCreateNewSession=${er}, terminalId=${dt}`),er){ve(`[ensureSession] Creating new session, shouldCreateNewSession=${er}, runId=${xe}`),Et(null),cr(!1),Se.setConnecting(q,!0);const $r=Yr.getState().getTerminalSession(q),Pn=($r?.mode??K)===K&&(K!=="tmux"||!ze||$r?.tmuxSessionName===ze);if($r?.terminalSessionId&&Pn)ve(`[ensureSession] Race condition avoided: another instance already created session ${$r.terminalSessionId}`),Se.setConnecting(q,!1),dt=$r.terminalSessionId,er=!1;else try{const yr=await Hn();if(ve(`[ensureSession] Opened managed backend session ${yr.sessionId}`),xe!==bi.current){ve(`[ensureSession] Stale run after session creation (runId=${xe}, currentRunId=${bi.current}), leaving ${yr.sessionId} for sibling`);return}Se.setTerminalSession(q,yr),ve(`[ensureSession] Updated store with new session ${yr.sessionId}`),dt=yr.sessionId}catch(yr){if(xe!==bi.current){ve("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(yr instanceof t0&&c1(yr)){ve("[ensureSession] Confirmed missing persisted session:",{sessionId:q,error:yr.message}),Se.clearTerminalSession(q),Et(Zh),cr(!0),Se.setConnecting(q,!1);return}Et("Reconnecting..."),cr(!0),Se.setConnecting(q,!1);return}}if(xe!==bi.current){ve(`[ensureSession] Stale run before starting stream (runId=${xe}, currentRunId=${bi.current}), skipping`);return}if(!dt){ve(`[ensureSession] No terminalId, terminalId=${dt}`);return}ve(`[ensureSession] Starting stream for session ${dt}`),kr.current=dt,js(dt),ve(`[ensureSession] ensureSession completed for sessionId=${q}, terminalId=${dt}`)};let T=null,j=null;const Q=()=>{j=null,!(Hi.current&&Lr.current===q)&&(ve(`[useEffect] Running ensureSession for sessionId=${q}, hasInitialized=${Hi.current}`),Hi.current=!0,xi.current=!0,T=++bi.current,se(T))};if(!I&&!xi.current){ve(`[useEffect] Holding background connection until the selected session is ready: ${q}`);return}const F=xi.current?0:Math.max(0,C);return F>0?(ve(`[useEffect] Delaying initial connection for sessionId=${q} by ${F}ms`),j=window.setTimeout(Q,F)):Q(),()=>{j!==null&&window.clearTimeout(j),ve(`[useEffect] Cleanup for sessionId=${q}, runId=${T??"pending"}`)}},[q,dn,js,os,Ae,ve,K,ze,Mr,C,I,Pt]);const Uo=L.useCallback(async()=>{if(q&&!Cn){Ls(!0),Et(null),cr(!1),cn(null),os();try{Ae.forceKill&&await Ae.forceKill({sessionId:q})}catch{}nr(q),Ar(q),pr.current?.clear(),await new Promise(se=>setTimeout(se,100));try{Er(q,!0);const se=await Hn();un(q,se),kr.current=se.sessionId,js(se.sessionId)}catch(se){Et(se instanceof t0&&c1(se)?Zh:"Reconnecting..."),cr(!0),Er(q,!1)}finally{Ls(!1)}}},[q,Cn,os,Ae,nr,Ar,Er,un,js,Hn]),ma=L.useCallback((se,T,j,Q)=>{if(!(kr.current!==T||Lt.current!==j)){if(se instanceof t0&&$2(se)){ve("[Terminal] operation backend missing, recovering",{terminalId:T,sessionId:q}),Et("Reconnecting..."),cr(!1),os(),jt(q),kr.current=null,Er(q,!0),as();return}Et(se instanceof Error?se.message:Q)}},[jt,ve,os,as,q,Er]),fl=L.useCallback((se,T)=>{const j=T?.ownedPaste?SC(T.ownedPaste,q,se):!1;if(T?.ownedPaste&&!j||It.current||(br.current||P1())&&!j)return Promise.resolve(!1);const Q=()=>!!T?.ownedPaste&&CC(T.ownedPaste,q)&&At.current&&!It.current&&ye.current&&!rr.current&&!document.hidden&&navigator.onLine!==!1&&Cu();if(j&&!Q())return Promise.resolve(!1);if(!At.current&&!T?.targeted||!se)return;const F=bE(se),xe=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(se);if(Qr&&xe&&(ss.current=!0),Date.now()<kn.current)return;let Se=se,Oe=T?.consumeModifier??!1;if(!T?.skipModifierTransform&&Nt&&se.length>0){const $r=se[0];if($r.length===1&&/[a-zA-Z]/.test($r)){const nn=$r.toUpperCase();Nt==="ctrl"?(Se=String.fromCharCode(nn.charCodeAt(0)&31),Oe=!0):Nt==="alt"&&(Se=`\x1B${se}`,Oe=!0)}Oe||(Nt==="alt"&&(Se=`\x1B${se}`),Oe=!0)}const Xe=kr.current;if(!Xe)return;const dt=Lt.current,or=(async()=>{try{if(Qr&&!F&&ss.current&&Ae.tmuxAction){ss.current=!1;try{await Ae.tmuxAction(Xe,{action:"copy-mode",enabled:!1})}catch{}if(kr.current!==Xe||Lt.current!==dt)return!1;if(yE(Se))return!0}return j&&(!Q()||kr.current!==Xe||Lt.current!==dt)||(await Ae.sendInput(Xe,Se),j&&(!Q()||kr.current!==Xe||Lt.current!==dt))?!1:(ps(q),!0)}catch($r){return ma($r,Xe,dt,"Failed to send input"),!1}})();return Oe&&(Ze||me(null),ms()),or},[Nt,ps,ms,ma,Qr,Ze,q,Ae]);L.useEffect(()=>{const se=T=>{const j=T,Q=j.detail?.sessionId;if(Q?Q!==q:!At.current)return;const F=j.detail?.text;if(!F)return;const xe=j.detail?.nonce;if(rr.current||!pr.current){xe&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:xe,ok:!1}}));return}const Se=TC(j.detail,q),Oe=j.detail?.ownedPaste&&!Se?Promise.resolve(!1):pr.current.sendSequence(F,{paste:j.detail?.paste,submitAfterPaste:j.detail?.submitAfterPaste,targeted:!!Q,ownedPaste:Se??void 0});xe&&Promise.resolve(Oe).then(Xe=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:xe,ok:Xe===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:xe,ok:!1}}))}),KS(rn.current,j.detail?.focus!==!1)&&ms()};return window.addEventListener("termdock-insert-reference",se),()=>window.removeEventListener("termdock-insert-reference",se)},[ms,q]);const pl=L.useCallback((se,T,j)=>{const Q=kr.current;if(!Q){Ie("xterm resize push skipped: no terminalId",{cols:se,rows:T});return}Ie("xterm resize push",{cols:se,rows:T}),Ae.resize({sessionId:Q,cols:se,rows:T,seq:j}).catch(F=>{pr.current?.acknowledgeResize({seq:j,ok:!1}),F&&/session not found/i.test(String(F.message||F))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Q,cols:se,rows:T,stack:new Error().stack})})},[Ae,Ie]),ls=L.useCallback(async se=>{const T=kr.current;if(!T||!Ae.tmuxAction)return;const j=Lt.current;try{const Q=await Ae.tmuxAction(T,se);if(kr.current!==T||Lt.current!==j)return;Q.layout&&(Gn(Q.layout),se.action==="switch-session"&&(un(q,{sessionId:T,cols:80,rows:24,mode:"tmux",tmuxSessionName:Q.layout.sessionName}),T8(q,{tmuxSessionName:Q.layout.sessionName}).catch(F=>{console.warn("[Terminal] failed to update inventory after tmux switch",F)})))}catch(Q){ma(Q,T,j,"Failed to execute tmux action")}},[ma,q,un,Ae]);L.useEffect(()=>{if(!Or||!en)return;const T=Or.windows.find(j=>j.id===Or.activeWindowId)?.panes.find(j=>j.id===Or.activePaneId);T&&pr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${en}:${Or.sessionId}:${T.id}:${T.width}x${T.height}`})},[Or,en]);const Ds=L.useCallback((se,T=5)=>{const j=Math.max(1,Math.min(Math.floor(T)||1,40));ss.current=!0;const Q=Wr.current;if(Q&&Q.direction===se){Q.lines+=j;return}Q&&ls({action:"scroll",direction:Q.direction,lines:Q.lines}).finally(()=>{ms()}),Wr.current={direction:se,lines:j},tn.current&&clearTimeout(tn.current),tn.current=setTimeout(()=>{const F=Wr.current;F&&(Wr.current=null,ls({action:"scroll",direction:F.direction,lines:F.lines}).finally(()=>{ms()}))},0)},[ms,ls]),Ri=L.useCallback(se=>{const T=Date.now(),j=je.current,Q=j!==null&&j.modifier===se&&T-j.timestamp<=iN;if(je.current={modifier:se,timestamp:T},Ze===se){ct(null),me(null);return}if(Q){ct(se),me(se);return}Ze!==null&&Ze!==se&&ct(null),me(F=>F===se?null:se)},[Ze]),zo=L.useCallback(se=>{if(Ye(se&&At.current),Ie("input focus changed",{focused:se,isActive:At.current,isMobile:rn.current}),!rn.current||!At.current){gt(!1);return}gt(T=>T===se?T:se)},[Ie]),Dl=L.useCallback(se=>{if(ns.current=se,ei(se,"viewport-watermark"),!se&&En.current.length>0){const T=q;if(T){const j=En.current;En.current=[];for(const Q of j)re(T,Q)}}},[re,ei,q]),Es=L.useCallback(se=>{At.current&&pr.current?.ensureSizeMatches(se)},[]),Ea=L.useRef(null);L.useEffect(()=>{if(!l)return;const se=Ea.current;if(!se)return;const T=()=>Es("pointerdown"),j=()=>Es("keydown"),Q=()=>Es("touchstart"),F=()=>Es("wheel");return se.addEventListener("pointerdown",T),se.addEventListener("keydown",j),se.addEventListener("touchstart",Q,{passive:!0}),se.addEventListener("wheel",F,{passive:!0}),()=>{se.removeEventListener("pointerdown",T),se.removeEventListener("keydown",j),se.removeEventListener("touchstart",Q),se.removeEventListener("wheel",F)}},[l,Es]);const ml=L.useCallback(se=>{pr.current=se},[]),es=L.useCallback(se=>{mt(se),O?.(q,se)},[O,q]),Wi=L.useCallback(se=>{const T=kE(se);if(!T)return;const j=Nt!==null;pr.current?.sendSequence(T,{consumeModifier:j})},[Nt]),Mi=L.useCallback(se=>{const T=AE(se);if(T.length===0)return;const j=Nt!==null;pr.current?.sendSequence(Q2(T[0]),{consumeModifier:j});for(let Q=1;Q<T.length;Q+=1){const F=T[Q];window.setTimeout(()=>{pr.current?.sendSequence(Q2(F))},wE*Q)}},[Nt]),Gi=L.useCallback(()=>{pr.current?.pasteClipboardText()},[]),gs=L.useCallback(se=>{Dt.current!==null&&(window.clearTimeout(Dt.current),Dt.current=null),vt(se),(se==="inserted"||se==="failed")&&(Dt.current=window.setTimeout(()=>{Dt.current=null,vt("idle")},1400))},[]),Ws=L.useCallback(()=>{gs("idle"),Mt(0),Bn.current?.click()},[gs]),Bl=L.useCallback(()=>{Vr(!0)},[]),Vi=L.useCallback(se=>{const T=se.currentTarget.files?.[0];if(se.currentTarget.value="",!T)return;const j=q;Sr(null),fr(null),dr(null),Mt(0),gs("uploading");const Q=ir&&T.type.startsWith("video/")?{maxHeight:Mn,videoBitrate:Xr,onProgress:Mt}:null,F=De&&oN(T)?{maxDimension:st,quality:xt}:null;let xe=Q?"视频压缩":F?"图片压缩":"文件上传";(async()=>{const Se=Q?await(await Oc(async()=>{const{compressVideoLocally:Oe}=await import("./videoCompression-RIaDabW4.js");return{compressVideoLocally:Oe}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(T,Q):F?await(await Oc(async()=>{const{compressImageLocally:Oe}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Oe}},[])).compressImageLocally(T,F):T;xe="文件上传",await rN(Se,(Oe,Xe)=>E0(Oe,Xe,void 0,Mt),Oe=>(xe="插入终端",z2(u1(Oe,null),j,()=>At.current&&!rr.current&&Lr.current===j&&Yr.getState().activeSessionId===j))),(Q||F)&&dr({file:Se,kind:Q?"video":"image",originalSize:T.size,uploadedSize:Se.size,originalRetained:Se===T})})().then(()=>gs("inserted"),Se=>{Se instanceof wf&&Sr({path:Se.uploaded.path,sessionId:j});const Oe=Se instanceof wf?Se.uploaded.path:V2(Se);fr({stage:xe,detail:Oe}),Vr(!0),gs("failed"),ka("warn","MOBILE_MEDIA_UPLOAD failed",{stage:xe,detail:Oe})})},[Xr,ir,Mn,De,st,xt,q,gs]),qi=L.useCallback(async()=>{const se=qt;if(!se||se.sessionId!==q)return;Vr(!1),await new Promise(j=>window.requestAnimationFrame(()=>j())),gs("uploading"),await z2(u1(se.path,null),se.sessionId,()=>At.current&&!rr.current&&Lr.current===se.sessionId&&Yr.getState().activeSessionId===se.sessionId)?(Sr(null),fr(null),gs("inserted")):(Vr(!0),gs("failed"))},[qt,q,gs]);L.useEffect(()=>{if(!Br||!ir)return;let se=!0;return on(null),qr({phase:"checking-cache"}),Oc(async()=>{const{prepareLocalVideoCompression:T}=await import("./videoCompression-RIaDabW4.js");return{prepareLocalVideoCompression:T}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:T})=>{if(se)return T(j=>{se&&qr(j)})}).catch(T=>{se&&on(V2(T))}),()=>{se=!1}},[Br,ir]);const fn=Dr||Rt!==null;rr.current=fn;const ga=L.useRef(Jr);fn||(ga.current=Jr);const Yi=fn?ga.current:Jr,Na=L.useMemo(()=>TE(Yi,ln),[Yi,ln]),ji=L.useMemo(()=>O2(ln,yt),[yt,ln]),Di=!Pe&&yt!=="auto"&&ji.id!=="default"&&ji.showOnDesktop!==!0?"auto":yt,ni=Di==="auto"?Na:Di,ws=L.useMemo(()=>O2(ln,ni),[ni,ln]),Gs=L.useMemo(()=>ws.actions.filter(se=>se.sequence.trim().length>0).map((se,T)=>({...se,label:l1(se,T)})),[ws.actions]),Bi=L.useMemo(()=>J3(Jr),[Jr]),Ra=ws.label,si=L.useMemo(()=>Di!=="auto"?`Manual preset: ${ws.label}`:Bi?`Auto preset · ${ws.label} (${Bi})`:"Auto preset",[Bi,Di,ws.label]),ys=L.useCallback(se=>{nt(se)},[]),Ka=L.useCallback(()=>{tr(se=>se==="copy"?"arrows":"copy"),kt("idle")},[]),Xa=L.useCallback(()=>{typeof window>"u"||(hr.current!==null&&window.clearTimeout(hr.current),hr.current=window.setTimeout(()=>{hr.current=null,kt("idle")},1200))},[]),As=L.useCallback(se=>{hr.current!==null&&typeof window<"u"&&(window.clearTimeout(hr.current),hr.current=null),kt(se?"copied":"failed"),Xa()},[Xa]),Ja=L.useCallback(se=>{X(se)},[]),Ql=L.useMemo(()=>Pe?SE(ln):CE(ln),[Pe,ln]),Ho=L.useMemo(()=>S8(a),[a]);L.useEffect(()=>{if(!Qr||!H||!Pt||!en)return;const se=BC(Ho);se&&Ae.sendInput(en,se).catch(T=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",T)})},[Qr,H,Pt,en,Ae,Ho]);const Co=L.useMemo(()=>`terminal::${q}`,[q]);L.useEffect(()=>{ke?.({isConnecting:Dr,isRestarting:Cn,hasError:!!Rt,sessionId:en})},[Dr,Cn,Rt,en,ke]);const xa=!en||Dr||Cn,Ma=L.useCallback((se,T)=>{if(xa)return;const j=Math.max(1,Math.min(Math.floor(T)||1,40));Ds(se,j)},[Ds,xa]);L.useEffect(()=>{if(!l||!Pe)return;pr.current?.requestRefresh("resize",{skipScrollToBottom:!Kt,force:!0})},[l,Pe,Kt,Ot,q]),L.useEffect(()=>{if(!l||!Pe)return;const se=T=>{const j=T.detail;pr.current?.requestRefresh("resize",{skipScrollToBottom:j?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",se),()=>{document.removeEventListener("termdock:viewport-keyboard-change",se)}},[l,Pe,q]);const Wo=!Y&&(Pe||ws.id==="default"||ws.showOnDesktop===!0),ba=l,cs=Pe&&!be?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Go=Pe&&!be?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,Zi=s.jsx(LE,{visible:Wo,interactive:ba,presentation:Pe?"mobile":"desktop-actions",activeModifier:Nt,lockedModifier:Ze,disabled:xa,defaultShowExtended:Tt,presetLabel:Ra,presetModeLabel:si,presetMode:Di,presetOptions:Ql,includeAlt:ws.includeAlt,presetRowLayout:ws.rowLayout,extraActions:Gs,onKeyPress:Wi,onTextPress:Mi,onPastePress:Pe?Gi:void 0,onFilePress:Pe?Ws:void 0,onFileLongPress:Pe?Bl:void 0,fileUploadState:Ut,fileUploadProgress:wt,longPressMode:_e,copyFeedback:Ke,onLongPressModeToggle:Ka,onModifierToggle:Ri,onPresetSelect:ys,onExpandedChange:Ja}),gl=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return s.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:cs,children:[s.jsx("input",{ref:Bn,type:"file",className:"hidden",onChange:Vi}),Br&&Js.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Vr(!1),"aria-label":He("common.close")}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"mobile-video-compression-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] z-modal-panel max-h-[calc(100dvh-1.5rem)] overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:left-1/2 sm:right-auto sm:w-[min(28rem,calc(100vw-2rem))] sm:-translate-x-1/2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"mobile-video-compression-title",className:"text-sm font-semibold text-foreground",children:"本地媒体压缩"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"按文件类型选择压缩方式,处理完成后才上传。"})]}),s.jsx("button",{type:"button",className:"min-h-10 rounded-lg bg-surface-2 px-3 text-xs",onClick:()=>Vr(!1),children:He("common.close")})]}),_t&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[_t.stage,"失败。",_t.stage.endsWith("压缩")?"原文件未上传。":_t.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:_t.detail})]}),qt&&s.jsx("button",{type:"button",onClick:()=>{qi()},disabled:Ut==="uploading"||qt.sessionId!==q,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:He("common.retry")})]}),ft&&s.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:"本机未能保存设置,重新打开后可能恢复默认值。"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"显示压缩结果提示"}),s.jsx("input",{type:"checkbox",checked:Gr.showResultToast,onChange:se=>ot({showResultToast:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩图片后上传"}),s.jsx("input",{type:"checkbox",checked:De,onChange:se=>ot({imageEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),De&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片最长边",s.jsx("select",{value:st,onChange:se=>ot({imageMaxDimension:Number(se.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:av.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(xt*100),"%",s.jsx("input",{type:"range",min:a0.min,max:a0.max,step:a0.step,value:xt,onChange:se=>ot({imageQuality:Number(se.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"支持 JPEG、PNG、HEIC 照片;GIF、SVG 等保持原文件。压缩后未变小也会保留原图。"})]}),s.jsx("div",{className:"mt-4 border-t border-border/15 pt-1"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩视频后上传"}),s.jsx("input",{type:"checkbox",checked:ir,onChange:se=>ot({videoEnabled:se.target.checked}),className:"h-4 w-4 accent-primary"})]}),ir&&s.jsxs("div",{className:"mt-4 space-y-4",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["视频最长边(像素)",s.jsx("select",{value:Mn,onChange:se=>ot({videoMaxHeight:Number(se.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:ov.map(se=>s.jsxs("option",{value:se,children:[se," px",se===240?" · 最省流量":se===720?" · 推荐":se>=1440?" · 手机处理较慢":""]},se))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",Xr/1e6," Mbps",s.jsx("input",{type:"range",min:o0.min,max:o0.max,step:o0.step,value:Xr,onChange:se=>ot({videoBitrate:Number(se.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"保持比例,不放大原视频。尺寸越小通常处理越快;码率越低体积通常越小,过高可能比原片更大。"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",role:"status","aria-live":"polite",children:mn?"本地转码器准备失败,请关闭开关后重试。":lN(Cr)}),Cr?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),mn&&s.jsx("p",{className:"text-[11px] text-destructive",children:mn})]})]})]}),document.body),Vn&&s.jsx(IE,{isMobile:Pe,isInputFocused:rt,isIOS:oe,isConnecting:Dr,connectionError:Rt,terminalSessionId:en}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Ho.background,...Go},children:[s.jsx("div",{ref:Ea,className:"h-full w-full box-border",children:s.jsx(C8,{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:He("terminal.componentFailed")})]})}),children:s.jsx(dE,{ref:ml,sessionKey:Co,sessionId:q,isLayoutVisible:m,chunks:ks,onInput:fl,onResize:pl,onFlowControl:Dl,onTmuxScroll:Qr?Ma:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Pe?()=>{pr.current?.sendSequence(" ")}:void 0,onInputFocusChange:zo,onMobileLongPressCopyResult:As,onReadyChange:es,onSizeSynchronizedChange:Vt,onWritesSettled:Ga,onWriteProgress:zi,onCursorPositionChange:ha,onDirectoryLinkActivate:xn,terminalSettings:Fe,theme:Ho,enableTouchScroll:Pe,mobileLongPressMode:_e,autoFocus:!Re&&!Pe&&!gl,cursorVisible:!Re&&Zt,suppressSmoothScroll:!Ve||!bt,className:Re||!Zt?"terminal-focus-suspended":void 0},Co)})}),s.jsx(sN,{result:pn,onDismiss:ge}),s.jsx(NE,{connectionError:Rt,isFatalError:jr,isRestarting:Cn,isConnecting:Dr,onHardRestart:Uo})]}),le?Y?null:Js.createPortal(Zi,le):Zi]})};function dN({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=Ur(),c=Yr(l=>{const d=l.sessions.get(e.id);return il(e,d?.activeProgram??null,d?.cwd??null,void 0,d?.shellTitle??null,d?.promptState??null).primary});return s.jsxs("div",{"data-pane-titlebar":"true",className:"swiper-no-swiping flex h-6 min-h-6 shrink-0 items-center border-b border-border app-chrome-bg",children:[s.jsxs("button",{type:"button","data-split-pane-title":e.id,draggable:!1,onDragStart:l=>l.preventDefault(),"aria-pressed":t,title:`${c} · 拖动标题移动,边缘拆分,中央交换`,onClick:r,className:"split-pane-drag-handle flex h-full min-w-0 cursor-grab active:cursor-grabbing flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-[12px] font-medium leading-none text-foreground hover:bg-surface focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:[s.jsx($o,{size:11,className:`shrink-0 ${t?"text-primary":"text-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),s.jsx(zf,{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(zy,{size:14})})]})}const hN="termdock:startup:";function Mu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${hN}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function q2(e,t){e||Js.flushSync(t)}const d1="horizontal";function Pu(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function Kh(e,t){if(!Array.isArray(e)||e.length!==t)return Pu(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return Pu(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?Pu(t):r.map(a=>a/n)}function fN(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 pN(e){return e==="horizontal"||e==="vertical"||e==="grid"}function mN(e){if(!Array.isArray(e))return[];const t=new Set,r=new Set,n=[];for(const a of e){if(!a||typeof a!="object")continue;const c=a;if(typeof c.id!="string"||!c.id||r.has(c.id))continue;const l=Array.isArray(c.sessionIds)?c.sessionIds.filter(m=>typeof m=="string"&&!!m&&!t.has(m)):[],d=[...new Set(l)];if(d.length<2)continue;const f=fN(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:pN(c.layout)?c.layout:d1,ratios:Kh(c.ratios,d.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:Kh(c.gridColumnRatios,f.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:Kh(c.gridRowRatios,f.rows)}:{}})}return n}function gN(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?Kh(n.ratios,a.length):Pu(a.length)}]})}function w0(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function sm(e,t,r){if(!t||!r||t===r)return e;const n=w0(e,t),a=w0(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===d1)?"grid":n?.layout??d1,ratios:Pu(l.length)},f=new Set([n?.id,a?.id].filter(Boolean)),m=e.filter(y=>!f.has(y.id)),x=n?Math.max(0,e.findIndex(y=>y.id===n.id)):m.length;return m.splice(Math.min(x,m.length),0,d),m}function xN(e,t){const r=w0(e,t);if(!r||!t)return e;if(r.sessionIds.length<=2)return e.filter(a=>a.id!==r.id);const n=r.sessionIds.filter(a=>a!==t);return e.map(a=>a.id===r.id?{...a,sessionIds:n,ratios:Pu(n.length)}:a)}function bN(e,t){const r=w0(e,t);return r?e.filter(n=>n.id!==r.id):e}function yN(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 vN(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 h1=320,cv=1,wN=h1+120,f1="termdock:split-workspaces:v2",uv="termdock:split-workspace:v1",AN=.1,TN=.9;function im(){if(typeof window>"u")return{mobile:!1,landscape:!1};const e=Ty();return{mobile:e,landscape:e&&window.innerWidth>window.innerHeight}}function SN(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(f1);if(e)return mN(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(uv)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(TN,Math.max(AN,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 CN(e,t){const r=new Map(e.map(l=>[l.id,l])),n=new Map;t.forEach(l=>l.sessionIds.forEach(d=>n.set(d,l)));const a=new Set,c=[];for(const l of e){const d=n.get(l.id);if(!d){c.push({key:l.id,sessions:[l]});continue}if(a.has(d.id))continue;a.add(d.id);const f=d.sessionIds.flatMap(m=>{const x=r.get(m);return x?[x]:[]});f.length>=2&&c.push({key:d.id,sessions:f,workspace:d})}return c}function Y2(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function wh(e,t){const r=Af(e,t);if(r===null)return;const n=e.wrapperEl;Y2(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),Y2(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 p1(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 Af(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function _N(e,t){const r=p1(e),n=Af(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=cv}function kN(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 dv(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function hv(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 LN(e,t){const r=dv(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function Z2(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...hv(n),history:a?.history}})}function K2(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function X2(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 J2(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function IN(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 EN(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 NN=({terminalSettings:e=eg(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:c="shell",defaultTmuxSessionName:l="",connectionPrioritySessionId:d=null,connectionPriorityReady:f=!0,desktopRightSidebarEnabled:m=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopPinnedLeftSidebarWidth:w=0,desktopViewportWidth:v=0,onStatusChange:S,onSessionDataUpdate:C,onInitialViewportReady:I,onInitialRecoveryRequired:R})=>{const{t:B}=Ur(),z=b.useMemo(()=>Fu("session"),[]),O=b.useMemo(()=>Fu("terminal"),[]),[$,V]=b.useState([]),[Y,le]=b.useState(null),be=b.useRef(0),pe=b.useRef(0),ee=Kn(W=>W.activePaneId);b.useEffect(()=>{Kn.getState().setActivePane(Y)},[Y]);const[ke,He]=b.useState(null),[q,ce]=b.useState(!0),[qe,Ae]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[ve,Ie]=b.useState(()=>new Set),[Be,ne]=b.useState(()=>({token:0,completed:new Set})),[Fe,Le]=b.useState(0),[Re,Pe]=b.useState(()=>new Set),[Ee,oe]=b.useState(()=>new Set),We=b.useRef(new Map),[rt,gt]=b.useState(()=>new Set),ue=b.useRef(!1),Ye=b.useRef(null),at=b.useRef({}),[Ne,Ge]=b.useState(null),[Ce,H]=b.useState(()=>SN()),[ae,ye]=b.useState(!1),Ve=b.useCallback(W=>{be.current+=1,ye(W)},[]),Je=b.useRef(null),bt=b.useRef(ae);bt.current=ae,Gc(Je,ae&&!!Y,()=>Ve(!1));const[Vt,Pt]=b.useState(null),[mt,Zt]=b.useState(null),Ht=b.useRef(new Set),[Kt,Ot]=b.useState(null),[Nt,me]=b.useState(null),[Ze,ct]=b.useState(!1),[Tt,X]=b.useState(()=>im().mobile),[yt,nt]=b.useState(()=>im().landscape),[_e,tr]=b.useState(null),[Ke,kt]=b.useState(null),Ut=b.useRef(a),vt=b.useRef(!1),wt=b.useRef(!1),Mt=b.useRef(null),_t=b.useRef(null),fr=b.useRef(Tt),qt=b.useRef(null),Sr=b.useCallback(W=>{W!==qt.current&&(be.current+=1),qt.current=W,le(W)},[]);b.useEffect(()=>Gt.subscribe((W,N)=>{(W.rightOpen!==N.rightOpen||W.rightTab!==N.rightTab)&&(be.current+=1)}),[]);const pn=b.useRef(0),dr=b.useRef([]),ge=b.useRef(0),Gr=b.useRef(null),ot=b.useRef(!1),ft=b.useRef(!0),ir=b.useRef(null),Mn=b.useRef(""),Xr=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const W=()=>{const N=im();fr.current=N.mobile,X(N.mobile),nt(N.landscape)};return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const{sessions:De,inventory:st,activeSessionId:xt,isLoading:Br,openSession:Vr,setActiveSession:Cr,removeSession:qr,renameSession:mn,resetSessionCustomName:on,reorderSessions:zr,restoreSessions:un}=_8(),Er=st?.tmuxRecovery??null;b.useEffect(()=>{Er&&R?.()},[Er,R]),b.useEffect(()=>{me(null),Ot(null)},[Er?.id]);const re=b.useCallback(async()=>{Ot("restore"),me(null);try{const W=await k8();await un(),W.failed>0&&me(B("tab.tmuxRecoveryPartial",{restored:W.restored,failed:W.failed}))}catch{me(B("tab.tmuxRecoveryFailed"))}finally{Ot(null)}},[un,B]),pt=b.useCallback(async()=>{Ot("dismiss"),me(null);try{await L8(),await un()}catch{me(B("tab.tmuxRecoveryDismissFailed"))}finally{Ot(null)}},[un,B]),jt=Gt(W=>W.groupByFolder),nr=hf(W=>W.collaborationGroups),Ar=Gt(W=>W.leftOpen||W.rightOpen),Fr=Gt(W=>W.rightSidebarWidthContextKey),Xt=Gt(W=>W.rightSidebarWidth),Zr=Gt(W=>W.rightPinned),[Jt,Pr]=b.useState(()=>J2(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(W=>{const N=J2(W.sessions);Pr(U=>IN(U,N)?U:N)}),[]);const{arranged:Hr}=b.useMemo(()=>uf($,W=>Jt.get(W.id)??null,jt,"",Ce,nr),[$,Jt,jt,Ce,nr]),ps=b.useRef(Hr);ps.current=Hr;const Mr=b.useMemo(()=>CN(Hr,Ce),[Hr,Ce]),jn=b.useRef(Mr);jn.current=Mr;const Tr=b.useMemo(()=>w0(Ce,Y),[Y,Ce]),Jr=b.useMemo(()=>{const W=Mr.find(N=>N.sessions.some(U=>U.id===Y));return new Set(W?.sessions.map(N=>N.id)??[])},[Y,Mr]),ln=b.useMemo(()=>{const W=new Map;if(!m||v<=0)return W;for(const N of Mr){const U=N.sessions[0];if(!U)continue;const Z=I8(U.id,Jt.get(U.id)??null,N.workspace?.id??null);if(!(Z===Fr?Zr:E8(U.id,Jt.get(U.id)??null,N.workspace?.id??null)))continue;const Qe=Z===Fr?Xt:N8(U.id,Jt.get(U.id)??null,N.workspace?.id??null),we=Oh(Qe,v,w);W.set(N.key,we+Sy)}return W},[Jt,w,m,Zr,Fr,Xt,v,Mr]),Qr=b.useMemo(()=>rm($.map(W=>({id:W.id,backendSessionId:W.sessionId})),d),[d,$]),ks=b.useMemo(()=>K2(De,xt),[xt,De]),Dr=yh({prioritySessionId:Qr,activeSessionId:ke??Y,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null}),en=b.useMemo(()=>KE(Mr.flatMap(W=>W.sessions.map(N=>N.id)),Jr),[Jr,Mr]),xn=Dr!==null&&ve.has(Dr),K=b.useMemo(()=>{const W=new Set(Jr);return ke&&W.add(ke),!W.size&&Dr&&W.add(Dr),W},[Jr,ke,Dr]),ze=Be.token===qe.token&&VE(K,Be.completed),Rt=ze||Fe===qe.token?qe.token:-1;b.useEffect(()=>{if(!qe.token||ze)return;const W=window.setTimeout(()=>Le(qe.token),BE);return()=>window.clearTimeout(W)},[qe.token,ze]);const Et=b.useCallback((W,N)=>{Ie(U=>{if(U.has(W)===N)return U;const fe=new Set(U);return N?fe.add(W):fe.delete(W),fe})},[]),rr=b.useCallback(W=>{const N=pn.current;ne(Z=>{if(Z.token===N&&Z.completed.has(W))return Z;const fe=new Set(Z.token===N?Z.completed:[]);return fe.add(W),{token:N,completed:fe}});const U=Qr??ke??qt.current;W===U&&Mu("foreground-stream-connected")},[ke,Qr]),jr=b.useCallback((W,N)=>{Pe(U=>{if(U.has(W)===N)return U;const Z=new Set(U);return N?Z.add(W):Z.delete(W),Z})},[]),cr=b.useCallback((W,N)=>{oe(U=>{if(U.has(W)===N)return U;const Z=new Set(U);return N?Z.add(W):Z.delete(W),Z})},[]);b.useEffect(()=>{for(const[W,N]of We.current){const U=$.find(Z=>Z.id===W);if(!U||U.sessionId!==N.backendSessionId){We.current.delete(W);continue}!ve.has(W)||!Re.has(W)||!Ee.has(W)||(We.current.delete(W),Ay(N.backendSessionId,`${N.command}\r`).catch(Z=>{console.error("[Session] Failed to send startup command:",Z)}))}},[$,ve,Re,Ee]);const Cn=Dr!==null&&Re.has(Dr),Ls=Dr!==null&&Ee.has(Dr);b.useEffect(()=>{Cn&&Mu("foreground-viewport-ready")},[Cn]),b.useEffect(()=>{Ls&&Mu("foreground-content-ready")},[Ls]),b.useEffect(()=>{if(!I)return;if(!q&&$.length===0){I();return}if(!Cn||!xn||!Ls)return;const W=[...Jr].every(Qe=>Re.has(Qe)&&ve.has(Qe)&&Ee.has(Qe));let N=0,U=0;const Z=()=>{N=requestAnimationFrame(()=>{U=requestAnimationFrame(()=>{Mu("initial-viewport-presented"),I()})})};W&&Z();const fe=W?void 0:window.setTimeout(Z,8e3);return()=>{cancelAnimationFrame(N),cancelAnimationFrame(U),clearTimeout(fe)}},[xn,Ls,Cn,q,I,$.length,Jr,Re,ve,Ee]);const Xn=b.useMemo(()=>Tt?OE({slides:Mr.map(W=>W.sessions.map(N=>N.id)),visibleSessionIds:Jr,foregroundSessionId:Dr}):rt,[Tt,Mr,Jr,Dr,rt]);b.useEffect(()=>{if(Tt||Jr.size===0)return;const W=new Set(Jr),N=Mr.findIndex(U=>U.sessions.some(Z=>Jr.has(Z.id)));for(let U=-2;U<=2;U+=1)U!==0&&Mr[N+U]?.sessions.forEach(Z=>W.add(Z.id));gt(U=>{let Z=!1;const fe=new Set(U);for(const Qe of W)fe.has(Qe)||(fe.add(Qe),Z=!0);return Z?fe:U})},[Tt,Jr,Mr]);const cn=bC(Xn);b.useEffect(()=>{if(!ke)return;if(!$.some(N=>N.id===ke)){He(null);return}if(!Re.has(ke)||!ve.has(ke)||!Ee.has(ke))return;const W=window.setTimeout(()=>{He(N=>N===ke?null:N),Ut.current&&!fr.current&&Ge({sessionId:ke,token:Date.now()})},80);return()=>window.clearTimeout(W)},[Ee,ke,ve,$,Re]),b.useEffect(()=>{typeof window>"u"||(Ce.length>0?(window.localStorage.setItem(f1,JSON.stringify(Ce)),window.localStorage.removeItem(uv)):window.localStorage.removeItem(f1))},[Ce]),b.useEffect(()=>{Br||q||Ce.length===0||H(W=>gN(W,$.map(N=>N.id)))},[Br,q,$,Ce.length]),b.useEffect(()=>{if(!Vt)return;const W=window.setTimeout(()=>Pt(null),3200);return()=>window.clearTimeout(W)},[Vt]),qt.current=Y,pn.current=qe.token,dr.current=$,Gr.current=xt,ot.current=Br,ft.current=q,Ut.current=a;const dn=b.useCallback((W=Ye.current)=>{const N=ge.current,U=typeof window<"u"?window.visualViewport:null,Z=W?p1(W):null,fe=W?Af(W,N):null;return{sessionsLength:dr.current.length,workspaceSlidesLength:jn.current.length,sessionIds:dr.current.map(Qe=>Qe.id),activeSessionId:qt.current,activeSessionIndex:N,persistedActiveId:Gr.current,isLoading:ot.current,isRestoring:ft.current,activeIndex:W?.activeIndex??null,previousIndex:W?.previousIndex??null,animating:W?.animating??null,allowTouchMove:W?.allowTouchMove??null,width:W?.width??null,translate:Z,targetTranslate:fe,translateDelta:Z!==null&&fe!==null?Z-fe:null,snapGridLength:W?.snapGrid?.length??null,targetSnap:W?.snapGrid?.[N]??null,visualViewport:U?{width:Math.round(U.width),height:Math.round(U.height),offsetTop:Math.round(U.offsetTop)}:null}},[]),_r=b.useCallback((W,N)=>{z(W,{...dn(),...N})},[z,dn]);b.useEffect(()=>{Br||q||Y!==xt&&Cr(Y)},[Y,Br,q,xt,Cr]);const Or=b.useMemo(()=>{if(Hr.length===0||!Y)return 0;const W=Mr.findIndex(N=>N.sessions.some(U=>U.id===Y));return W>=0?W:0},[Mr,Y]);ge.current=Or;const Gn=b.useCallback(()=>{Mt.current&&(clearTimeout(Mt.current),Mt.current=null)},[]),Vn=b.useCallback(W=>{Gn(),Mt.current=setTimeout(()=>{Mt.current=null,vt.current=!1,_r("[swiper:touch-guard-clear]",{reason:W})},wN)},[Gn,_r]),gn=b.useCallback((W,N={})=>{const U=Ye.current,Z=ge.current,fe=jn.current;if(!U||fe.length===0||Z<0||Z>=fe.length)return;if(vt.current){_r("[swiper:sync-skip-touch]",{reason:W});return}if(U.animating){_r("[swiper:sync-skip-animating]",{reason:W});return}const Qe=p1(U),we=Af(U,Z),lt=Qe!==null&&we!==null&&Math.abs(Qe-we)<=cv,At=U.activeIndex===Z;if(_r("[swiper:sync-check]",{reason:W,activeIndexAligned:At,translateAligned:lt,immediate:N.immediate===!0}),!(At&<)){if(At){wh(U,Z),_r("[swiper:sync-forced-active]",{reason:W,translateAligned:lt,immediate:N.immediate===!0});return}N.immediate?(wh(U,Z),U.slideTo(Z,0,!1),wh(U,Z)):U.slideTo(Z,h1,!1),_r("[swiper:sync-applied]",{reason:W,activeIndexAligned:At,translateAligned:lt,immediate:N.immediate===!0})}},[_r]);b.useEffect(()=>{const W=N=>{const U=N;Ye.current&&(Ye.current.allowTouchMove=!U.detail.locked),_r("[swiper:gesture-lock]",{locked:U.detail.locked})};return document.addEventListener("termdock:gesture-lock",W),()=>document.removeEventListener("termdock:gesture-lock",W)},[_r]),b.useEffect(()=>{if($.length===0){Y!==null&&Sr(null);return}if(!Y){if(!f)return;Sr(yh({prioritySessionId:Qr,activeSessionId:null,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null}));return}$.some(N=>N.id===Y)||Sr($[0].id)},[$,Y,f,Qr,ks]);const Jn=b.useCallback((W,N)=>{if(N&&Date.now()<Xr.current){at.current[W]=!1;return}at.current[W]=N,kt(U=>N?W:U===W?null:U)},[]),kr=b.useCallback(W=>{if(!vt.current&&W.activeIndex!==ge.current){_r("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:W.activeIndex,expectedActiveIndex:ge.current}),requestAnimationFrame(()=>gn("ignored-layout-slide-change",{immediate:!0}));return}const N=jn.current[W.activeIndex],U=N?.sessions.some(Qe=>Qe.id===Y)?Y:N?.sessions[0]?.id;if(_r("[swiper:slide-change]",{nextSessionId:U??null,instanceActiveIndex:W.activeIndex}),!U||U===Y)return;const Z=!!Y&&at.current[Y]===!0,fe=Ut.current&&(!fr.current||Z);if(_t.current=U,Sr(U),fe){Ge({sessionId:U,token:Date.now()});return}Ge(null)},[$,Y,_r,gn]);b.useLayoutEffect(()=>{if(_t.current===Y){_r("[swiper:sync-skip-swiper-driven]",{activeSessionId:Y}),_t.current=null;return}gn("active-session-index",{immediate:!0})},[Y,Or,$.length,gn,_r]),b.useEffect(()=>{const W=Ye.current;if(!W)return;const N=Mr.length>1&&!Ar&&!ae;W.allowTouchMove!==N&&(W.allowTouchMove=N,_r("[swiper:allow-touch-sync]",{nextAllow:N,sidebarOverlayOpen:Ar}))},[Mr.length,_r,Ar,ae]);const Lr=b.useCallback(W=>{const N=Ye.current;if(!N)return;const U=N.el;if(_r("[swiper:layout-before]",{reason:W,scrollLeft:U?.scrollLeft??null}),U&&(U.scrollLeft=0),N.updateSize(),N.updateSlides(),N.updateProgress(),N.updateSlidesClasses(),U&&(U.scrollLeft=0),_r("[swiper:layout-after]",{reason:W,scrollLeft:U?.scrollLeft??null}),vt.current||N.animating){_r("[swiper:layout-skip-sync-motion]",{reason:W});return}gn(`layout:${W}`,{immediate:!0}),requestAnimationFrame(()=>{const Z=Ye.current;Z&&(vt.current||Z.animating||wh(Z,ge.current))})},[_r,gn]);b.useEffect(()=>()=>Gn(),[Gn]);const pr=Mr.map(W=>W.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Lr("group-change"))},[jt,pr,Lr]),b.useEffect(()=>{let W=null,N="mount";const U=lt=>{N=lt,W===null&&(W=requestAnimationFrame(()=>{W=null,Lr(`viewport-change:${N}`)}))},Z=()=>U("window-resize"),fe=()=>U("visual-viewport-resize"),Qe=()=>U("visual-viewport-scroll"),we=lt=>{U(`measured:${lt.detail?.source??"unknown"}`)};return window.addEventListener("resize",Z),window.visualViewport?.addEventListener("resize",fe),window.visualViewport?.addEventListener("scroll",Qe),document.addEventListener(ox,we),U("mount"),()=>{window.removeEventListener("resize",Z),window.visualViewport?.removeEventListener("resize",fe),window.visualViewport?.removeEventListener("scroll",Qe),document.removeEventListener(ox,we),W!==null&&cancelAnimationFrame(W)}},[Lr]),b.useEffect(()=>{if(typeof document>"u")return;let W=null,N=null;const U=At=>{if(At!=="online"&&document.hidden)return;const br=performance.now();if(!qE(N,br))return;N=br;const It=At==="bfcache"||At==="online"?At:"visibility",rn=YE();Sp(),ka("info","PWA_RESUME scheduled",{source:At,forceForegroundReconnect:rn,activeSessionId:qt.current}),Ae(yn=>({token:yn.token+1,reason:It,forceForegroundReconnect:rn})),requestAnimationFrame(()=>Lr(`resume:${At}:raf`)),W&&clearTimeout(W),W=setTimeout(()=>{W=null,Lr(`resume:${At}:settled`)},320)},Z=()=>{if(document.hidden){Sp();return}U("visibility")},fe=()=>{Sp()},Qe=At=>{U(At.persisted?"bfcache":"pageshow")},we=()=>U("online"),lt=()=>U("focus");return document.addEventListener("visibilitychange",Z),window.addEventListener("pagehide",fe),window.addEventListener("pageshow",Qe),window.addEventListener("online",we),window.addEventListener("focus",lt),()=>{document.removeEventListener("visibilitychange",Z),window.removeEventListener("pagehide",fe),window.removeEventListener("pageshow",Qe),window.removeEventListener("online",we),window.removeEventListener("focus",lt),W&&clearTimeout(W)}},[Lr]),b.useLayoutEffect(()=>{if(!WE(q))return;const W=kN($),N=JSON.stringify(W);W.length>0&&N!==Mn.current?(Mn.current=N,console.warn("[session-invariant] duplicate mapping detected",W)):W.length===0&&Mn.current&&(Mn.current=""),C?.({sessions:$.map(U=>({id:U.id,name:U.name,customName:U.customName,mode:U.mode,tmuxSessionName:U.tmuxSessionName})),activeSessionId:Y,splitWorkspaces:Ce.map(({id:U,name:Z,sessionIds:fe,layout:Qe})=>({id:U,...Z?{name:Z}:{},sessionIds:fe,layout:Qe}))})},[$,Y,Ce,C,q]),b.useEffect(()=>{if(Br||ue.current)return;ue.current=!0;const W=rm(De.map(Qe=>({id:Qe.sessionId,backendSessionId:Qe.backendSessionId??null})),d),N=K2(De,xt),U=yh({prioritySessionId:f?W:null,activeSessionId:null,persistedActiveSessionId:N,firstSessionId:De[0]?.sessionId??null}),Z=dv(De.map(hv));if(z("[Session] Restoring",Z.length,"persisted sessions (one-shot)"),_r("[swiper:restore-start]",{persistedSessionIds:De.map(Qe=>Qe.sessionId),nextActiveSessionId:U}),Z.length>0){const Qe=Yr.getState();Z.forEach(lt=>{lt.sessionId&&Qe.setTerminalSession(lt.id,{sessionId:lt.sessionId,cols:80,rows:24,mode:lt.mode,tmuxSessionName:lt.tmuxSessionName,history:lt.history})}),De.forEach(lt=>{lt.agent!==void 0&&Qe.setSessionAgentIdentity(lt.sessionId,lt.agent),lt.activeProgram!=null&&Qe.setSessionActiveProgram(lt.sessionId,lt.activeProgram),lt.cwd!=null&&Qe.setSessionCwd(lt.sessionId,lt.cwd),lt.shellTitle!=null&&Qe.setSessionShellTitle(lt.sessionId,lt.shellTitle)}),V(Z);const we=U||Z[0]?.id||null;Sr(we),_r("[swiper:restore-complete]",{restoredSessionIds:Z.map(lt=>lt.id),nextActiveSessionId:we})}(async()=>(Z.length===0&&await ir.current?.({createIfEmpty:!0}),ce(!1),requestAnimationFrame(()=>gn("restore-finished",{immediate:!0}))))()},[Br,De,xt,z,_r,gn,f,d]),b.useEffect(()=>{if(!f||q||$.length===0)return;const W=rm($.map(U=>({id:U.id,backendSessionId:U.sessionId})),d),N=yh({prioritySessionId:W,activeSessionId:qt.current,persistedActiveSessionId:ks,firstSessionId:$[0]?.id??null});N&&N!==qt.current&&Sr(N)},[f,d,q,ks,$]);const ns=b.useRef([]),Un=b.useRef(!1);qt.current=Y,b.useEffect(()=>{if(q)return;const W=ns.current,N=De,U=new Map(W.map(It=>[It.sessionId,It])),Z=Yr.getState();for(const It of N){const rn=U.get(It.sessionId),yn=Yr.getState().sessions.get(It.sessionId);It.agent!==void 0&&JSON.stringify(It.agent)!==JSON.stringify(yn?.agent)&&(yn?.agent==null||JSON.stringify(It.agent)!==JSON.stringify(rn?.agent))&&Z.setSessionAgentIdentity(It.sessionId,It.agent),It.activeProgram!=null&&It.activeProgram!==yn?.activeProgram&&(yn?.activeProgram==null||It.activeProgram!==rn?.activeProgram)&&Z.setSessionActiveProgram(It.sessionId,It.activeProgram),It.cwd!=null&&It.cwd!==yn?.cwd&&(yn?.cwd==null||It.cwd!==rn?.cwd)&&Z.setSessionCwd(It.sessionId,It.cwd),It.shellTitle!=null&&It.shellTitle!==yn?.shellTitle&&(yn?.shellTitle==null||It.shellTitle!==rn?.shellTitle)&&Z.setSessionShellTitle(It.sessionId,It.shellTitle)}if(!Un.current){V(It=>Z2(It,N)),ns.current=N,Un.current=!0;return}const fe=new Set(W.map(It=>It.sessionId)),Qe=new Set(N.map(It=>It.sessionId)),we=new Map(W.map(It=>[It.sessionId,It.name]));ns.current=N,V(It=>{const rn=Z2(It,N);return(!qt.current||!rn.some(yn=>yn.id===qt.current))&&Sr(rn[0]?.id??null),rn});const lt=N.filter(It=>!fe.has(It.sessionId)),At=[...fe].filter(It=>!Qe.has(It)),br=N.filter(It=>fe.has(It.sessionId)&&we.get(It.sessionId)!==It.name);(lt.length>0||At.length>0||br.length>0)&&z("[Session] Synced persisted sessions:",{newSessionIds:lt.map(It=>It.sessionId),removedSessionIds:At,renamedSessionIds:br.map(It=>It.sessionId),currentSessionIds:N.map(It=>It.sessionId)});for(const It of N){if(!It.backendSessionId)continue;Yr.getState().setTerminalSession(It.sessionId,{sessionId:It.backendSessionId,cols:80,rows:24,mode:It.mode,tmuxSessionName:It.tmuxSessionName})}},[De,q,z]);const En=b.useCallback(async W=>{const N=++pe.current,U=be.current,Z=()=>N===pe.current&&U===be.current&&(W?.shouldActivate?.()??!0);try{const fe=Gt.getState(),Qe=Y?{rightOpen:fe.rightOpen,rightPinned:fe.rightPinned,rightSidebarWidth:fe.rightSidebarWidth,rightTab:fe.rightTab}:null,we=W?.mode==="tmux"||W?.mode==="shell"?W.mode:c,lt=(W?.tmuxSessionName||"").trim(),At=l.trim(),br=we==="tmux"?lt||At||EN():null,It=typeof W?.cwd=="string"?W.cwd:null,rn=Y?Yr.getState().sessions.get(Y)?.cwd??null:null,yn=typeof It=="string"&&It.trim().length>0?It:typeof rn=="string"&&rn.trim().length>0?rn:void 0,hn=await Vr({preferredFrontendSessionId:W?.preferredFrontendSessionId,requireExisting:W?.requireExisting===!0,mode:we,tmuxSessionName:br,cwd:yn,termType:"xterm-256color",createIfEmpty:W?.createIfEmpty===!0},{shouldActivate:Z});if(hn.discarded)return W?.onResult?.({ok:!1,error:"unknown"}),null;const Dn=hn.session,zn=hn.terminalSession;!hn.reused&&Qe&&Gt.getState().initializeRightSidebarForSession(Dn.sessionId,zn.cwd??yn??null,Qe);const hr={id:Dn.sessionId,name:Dn.name,customName:Dn.customName===!0,sessionId:zn.sessionId,mode:zn.mode??Dn.mode,tmuxSessionName:zn.tmuxSessionName??Dn.tmuxSessionName},Dt=W?.command?.trim();return Dt&&We.current.set(hr.id,{backendSessionId:zn.sessionId,command:Dt}),V(qn=>LN(qn,hr)),Z()&&Sr(hr.id),Yr.getState().setTerminalSession(hr.id,{sessionId:zn.sessionId,cols:80,rows:24,mode:hr.mode,tmuxSessionName:hr.tmuxSessionName,activeProgram:zn.activeProgram,activeProgramRaw:zn.activeProgramRaw,activeProgramSource:zn.activeProgramSource,cwd:zn.cwd}),z("[Session] Inventory opened session:",{frontendSessionId:hr.id,backendSessionId:zn.sessionId,reused:hn.reused,mode:hr.mode,tmuxSessionName:hr.tmuxSessionName}),W?.onResult?.({ok:!0,sessionId:hr.id}),hr.id}catch(fe){return console.error("[Session] Failed to create new session:",fe),W?.onResult?.({ok:!1,error:aC(fe)}),null}},[c,l,Y,Vr,z]);ir.current=En;const kn=b.useCallback((W,N={})=>{be.current+=1,Kn.getState().setActivePane(W);const U=qt.current,Z=!!U&&at.current[U]===!0;if(Sr(W),fr.current&&N.preserveMobileKeyboard===!1){Xr.current=Date.now()+600,U&&(at.current[U]=!1),kt(null),Ge(null);const fe=document.activeElement;fe instanceof HTMLTextAreaElement&&fe.closest(".terminal-viewport-container")&&fe.blur();return}Z&&fr.current&&kt(W),Ut.current&&(!fr.current||Z)&&Ge({sessionId:W,token:Date.now()})},[]),ss=b.useCallback(W=>{Sr(W),Ve(!0),Pt(null)},[]),Wr=b.useCallback(W=>{const N=qt.current;!N||N===W||(H(U=>sm(U,N,W)),Ve(!1),kn(N,{preserveMobileKeyboard:!1}))},[kn]),tn=b.useCallback(async()=>{const W=qt.current;if(!W||Ze)return;const N=be.current;ct(!0);const U=Yr.getState().sessions.get(W)?.cwd??void 0,Z=await En({cwd:U||void 0,mode:c,shouldActivate:()=>!1});if(ct(!1),!Z){Pt(B("common.error"));return}!bt.current||N!==be.current||!dr.current.some(fe=>fe.id===W)||(H(fe=>sm(fe,W,Z)),Ve(!1),kn(W,{preserveMobileKeyboard:!1}))},[kn,c,En,Ze,B]),G=b.useCallback(W=>{H(N=>bN(N,W)),W&&kn(W,{preserveMobileKeyboard:!1})},[kn]),je=b.useCallback(W=>{H(N=>xN(N,W)),kn(W,{preserveMobileKeyboard:!1})},[kn]),$e=b.useCallback(W=>{if($.find(U=>U.id===W)){if(be.current+=1,Kn.getState().setActivePane(W),W===qt.current)return;if(Sr(W),!UE({isMobile:fr.current,viewportReady:Re.has(W),streamReady:ve.has(W),contentReady:Ee.has(W)})){He(null),Ut.current&&Ge({sessionId:W,token:Date.now()}),z("[Session] Switched to session:",W);return}gt(Z=>{if(Z.has(W))return Z;const fe=new Set(Z);return fe.add(W),fe}),He(W),z("[Session] Switched to session:",W)}},[Ee,z,ve,$,Re]),et=b.useCallback((W,N)=>{N.trim()&&(V(U=>U.map(Z=>Z.id===W?{...Z,name:N.trim(),customName:!0}:Z)),mn(W,N.trim()))},[mn]),it=b.useCallback(W=>{V(N=>N.map(U=>U.id===W?{...U,customName:!1}:U)),on(W)},[on]),Ct=b.useCallback(W=>{V(N=>{const U=new Map(N.map(we=>[we.id,we])),Z=W.map(we=>U.get(we)).filter(we=>we!==void 0),fe=new Set(W),Qe=N.filter(we=>!fe.has(we.id));return[...Z,...Qe]}),zr(W),z("[Session] Reordered sessions:",W),requestAnimationFrame(()=>{Ye.current?.update()})},[zr,z]),Lt=b.useCallback(async W=>{const N=typeof W=="string"?W:W.sessionId,U=typeof W=="string"?"auto":W.closeMode??"auto",Z=$.find(lt=>lt.id===N);if(!Z||Ht.current.has(N))return;Ht.current.add(N),be.current+=1;const fe=lx(Hr,N,lt=>lt.id);try{U==="destroy"&&Z.mode==="tmux"&&Z.tmuxSessionName?(await Cy(Z.tmuxSessionName),z("[Session] Destroyed tmux session:",{frontendSessionId:Z.id,tmuxSessionName:Z.tmuxSessionName})):Z.sessionId&&(await wy(Z.sessionId),z("[Session] Closed backend terminal:",Z.sessionId))}catch(lt){console.error("[Session] Failed to close backend terminal:",lt),Zt({sessionId:N,closeMode:U});return}finally{Ht.current.delete(N)}Zt(lt=>lt?.sessionId===N?null:lt);const we=dr.current.filter(lt=>lt.id!==N).some(lt=>lt.id===fe)?fe:lx(dr.current,N,lt=>lt.id);qt.current===N&&Sr(we),V(lt=>lt.filter(At=>At.id!==N)),qr(N,we),delete at.current[N],z("[Session] Closed session:",{sessionId:N,closeMode:U})},[$,Hr,qr,z]),Bt=b.useCallback(W=>{if(!W)return;const N=$.filter(U=>U.sessionId===W);if(N.length!==0){N.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:W,frontendSessionIds:N.map(U=>U.id)}),V(U=>{const Z=U.filter(fe=>fe.sessionId!==W);return Z.length!==U.length&&!Z.some(Qe=>Qe.id===Y)&&Sr(Z.length>0?Z[0].id:null),Z});for(const U of N)qr(U.id),delete at.current[U.id];z("[Session] Backend gone, dropped local session(s):",N.map(U=>U.id))}},[$,Y,qr,z]);b.useEffect(()=>{const W=hr=>{En(hr.detail)},N=hr=>{$e(hr.detail)},U=()=>{const hr=qt.current;!hr||fr.current||Ge({sessionId:hr,token:Date.now()})},Z=hr=>{const Dt=hr;Dt.detail&&ss(Dt.detail)},fe=hr=>{const Dt=hr.detail;G(Dt??qt.current??void 0)},Qe=hr=>{const Dt=hr.detail;Dt&&je(Dt)},we=hr=>{const Dt=hr.detail,Bn=typeof Dt=="string"?Dt:Dt?.layout,qn=typeof Dt=="string"?qt.current:Dt?.sessionId;Bn!=="horizontal"&&Bn!=="vertical"&&Bn!=="grid"||H(Ga=>Ga.map(Qn=>Qn.sessionIds.includes(qn??"")?{...Qn,layout:Bn}:Qn))},lt=hr=>{const Bn=hr.detail?.direction;if(Bn!=="prev"&&Bn!=="next")return;const qn=ps.current;if(qn.length<=1)return;const Ga=qt.current,Qn=Ga?qn.findIndex(Va=>Va.id===Ga):-1,ha=((Qn>=0?Qn:0)+(Bn==="next"?1:-1)+qn.length)%qn.length,bs=qn[ha]?.id;bs&&bs!==Ga&&$e(bs)},At=hr=>{Lt(hr.detail)},br=hr=>{Bt(hr.detail)},It=hr=>{const Dt=hr;!Dt.detail?.sessionId||!Dt.detail?.name||et(Dt.detail.sessionId,Dt.detail.name)},rn=hr=>{const Dt=hr;Dt.detail?.sessionId&&it(Dt.detail.sessionId)},yn=hr=>{const Dt=hr;Dt.detail?.sessionIds&&Ct(Dt.detail.sessionIds)},hn=hr=>{const Dt=hr.detail;!Dt?.workspaceId||!Array.isArray(Dt.sessionIds)||H(Bn=>yN(Bn,Dt.workspaceId,Dt.sessionIds))},Dn=hr=>{const Dt=hr.detail;!Dt?.workspaceId||typeof Dt.name!="string"||H(Bn=>vN(Bn,Dt.workspaceId,Dt.name))},zn=hr=>{const Dt=hr.detail;!Dt?.primaryId||!Dt.secondaryId||Dt.primaryId===Dt.secondaryId||(H(Bn=>sm(Bn,Dt.primaryId,Dt.secondaryId)),kn(Dt.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",W),window.addEventListener("switch-terminal-session",N),window.addEventListener("focus-active-terminal-session",U),window.addEventListener("open-terminal-split-chooser",Z),window.addEventListener("close-terminal-split",fe),window.addEventListener("remove-terminal-split-pane",Qe),window.addEventListener("set-terminal-split-direction",we),window.addEventListener("cycle-terminal-session",lt),window.addEventListener("close-terminal-session",At),window.addEventListener("close-terminal-session-by-backend",br),window.addEventListener("rename-terminal-session",It),window.addEventListener("reset-terminal-session-name",rn),window.addEventListener("reorder-terminal-session",yn),window.addEventListener("reorder-terminal-split-workspace",hn),window.addEventListener("rename-terminal-split-workspace",Dn),window.addEventListener("combine-terminal-split-sessions",zn),()=>{window.removeEventListener("new-terminal-session",W),window.removeEventListener("switch-terminal-session",N),window.removeEventListener("focus-active-terminal-session",U),window.removeEventListener("open-terminal-split-chooser",Z),window.removeEventListener("close-terminal-split",fe),window.removeEventListener("remove-terminal-split-pane",Qe),window.removeEventListener("set-terminal-split-direction",we),window.removeEventListener("cycle-terminal-session",lt),window.removeEventListener("close-terminal-session",At),window.removeEventListener("close-terminal-session-by-backend",br),window.removeEventListener("rename-terminal-session",It),window.removeEventListener("reset-terminal-session-name",rn),window.removeEventListener("reorder-terminal-session",yn),window.removeEventListener("reorder-terminal-split-workspace",hn),window.removeEventListener("rename-terminal-split-workspace",Dn),window.removeEventListener("combine-terminal-split-sessions",zn)}},[kn,En,$e,ss,G,je,Lt,Bt,et,it,Ct]),b.useEffect(()=>{if(!Tr||Tt)return;const W=N=>{if(!yC(N,P1())||!(N.ctrlKey||N.metaKey)||!N.shiftKey)return;if(Tr.layout==="horizontal"?N.key==="ArrowLeft"||N.key==="ArrowRight":Tr.layout==="vertical"?N.key==="ArrowUp"||N.key==="ArrowDown":N.key.startsWith("Arrow")){N.preventDefault(),N.stopPropagation();const Z=Tr.sessionIds.indexOf(qt.current??""),fe=N.key==="ArrowLeft"||N.key==="ArrowUp"?-1:1,Qe=(Math.max(0,Z)+fe+Tr.sessionIds.length)%Tr.sessionIds.length,we=Tr.sessionIds[Qe];if(!we)return;kn(we);return}N.key==="Backspace"&&(N.preventDefault(),N.stopPropagation(),G(qt.current??void 0))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[kn,Tr,G,Tt]);const ht=W=>{const N=Yr.getState().sessions.get(W.id);return il(W,N?.activeProgram??null,N?.cwd??null,void 0,N?.shellTitle??null,N?.promptState??null)},Qt=(W,N={})=>{const U=W.id===Y&&!ee?.startsWith("@collaboration:"),Z=Jr.has(W.id)&&!N.hidden,fe=f&&$E({sessionId:W.id,foregroundSessionId:Dr,visibleSessionIds:Jr,deferredViewportSessionIds:Tt?cn:Xn}),Qe=FE({sessionId:W.id,foregroundSessionId:Dr,foregroundReady:xn,isVisible:Z})&&f,we=GE({sessionId:W.id,foregroundSessionId:Dr,requestToken:qe.token,foregroundCompletedToken:Rt,isVisible:K.has(W.id)})&&f,lt=Z||W.id===Dr||Xn.has(W.id)?0:en.get(W.id)??Yh;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:()=>{Z&&q2(U,()=>kn(W.id))},onWheelCapture:()=>{q2(U,()=>kn(W.id))},children:[N.showPaneTitle&&s.jsx(dN,{session:W,active:U,onActivate:()=>kn(W.id),onToggleRightSidebar:U?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:fe&&s.jsx(uN,{sessionId:W.id,mode:W.mode,tmuxSessionName:W.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:U,focusSuspended:ke!==null,deferCursorUntilPositioned:ke===W.id||W.mode==="tmux"&&!Ee.has(W.id),isLayoutVisible:Z,initialConnectEnabled:Qe&&we,resumeRequestEnabled:we,suppressKeyboard:N.suppressKeyboard,keyboardPortalTarget:N.keyboardPortalTarget,sharedMobileKeyboardLayout:N.sharedMobileKeyboardLayout,suppressPageFlipRefresh:N.suppressPageFlipRefresh,focusRequestToken:Ne?.sessionId===W.id?Ne.token:0,resumeRequestToken:qe.token,resumeRequestReason:qe.reason,forceResumeReconnect:qe.forceForegroundReconnect&&K.has(W.id),resumeRequestDelayMs:K.has(W.id)?0:N.hidden?Yh:en.get(W.id)??Yh,initialConnectDelayMs:lt,onStreamReadyChange:Et,onStreamConnected:rr,onViewportReadyChange:jr,onContentReadyChange:cr,onKeyboardVisibilityChange:Jn,showDebug:n,onStatusChange:U?S:void 0})})]},W.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[mt&&$.some(W=>W.id===mt.sessionId)&&s.jsxs("div",{role:"alert",className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto flex max-w-lg items-center gap-3 rounded-xl border border-destructive/30 bg-surface-elevated px-4 py-3 text-[12px] text-foreground shadow-lg",children:[s.jsx("span",{className:"min-w-0 flex-1",children:B("tab.closeFailed",{name:$.find(W=>W.id===mt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{Lt(mt)},children:B("common.retry")}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-1 hover:bg-surface-2","aria-label":B("common.close"),onClick:()=>Zt(null),children:s.jsx(In,{size:16})})]}),Er&&s.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:s.jsx(F1,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:B("tab.tmuxRecoveryTitle",{count:Er.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:Er.sessions.map(W=>W.name).join(" · ")}),Nt&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:Nt}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Kt!==null,onClick:()=>{re()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[s.jsx(Hy,{size:13,className:Kt==="restore"?"animate-spin":""}),B(Kt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:Kt!==null,onClick:()=>{pt()},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(pA,{onSwiper:W=>{Ye.current=W,W.allowTouchMove=Mr.length>1&&!Ar&&!ae,_r("[swiper:on-swiper]",{allowTouchMove:W.allowTouchMove}),requestAnimationFrame(()=>Lr("on-swiper"))},onSlideChange:kr,onTouchStart:(W,N)=>{const U=X2(N),Z=U==="touch"||U==="pen"||U==="unknown";O("[swipe:touch-start]",{pointerType:U,allowed:Z}),_r("[swiper:touch-start]",{pointerType:U,allowed:Z}),Z&&(Gn(),wt.current=!0,vt.current=!0)},onTouchEnd:(W,N)=>{const U=X2(N),Z=U==="touch"||U==="pen"||U==="unknown";O("[swipe:touch-end]",{pointerType:U,allowed:Z}),_r("[swiper:touch-end]",{pointerType:U,allowed:Z}),Z&&(wt.current=!1,Vn("touch-end"))},onTransitionEnd:()=>{const W=Ye.current;if(wt.current){_r("[swiper:transition-end-during-touch]");return}if(vt.current&&W&&!_N(W,ge.current)){_r("[swiper:transition-end-deferred]");return}Gn(),vt.current=!1,_r("[swiper:transition-end]")},initialSlide:Math.max(0,Or),speed:h1,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"terminal-session-swiper h-full",children:Mr.map(W=>{const N=W.workspace,U=!!N&&W.sessions.length>=2,Z=Tt?yt?"horizontal":"vertical":N?.layout??"horizontal",fe=Tt&&Ke?W.sessions.some(we=>we.id===Ke):!1,Qe=W.sessions.some(we=>we.id===Y)?Y:W.sessions[0]?.id;return s.jsx(mA,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":ln.get(W.key)??0,style:{paddingRight:ln.get(W.key)??0,paddingTop:y&&!U?"2.5rem":void 0},children:U?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:Tt?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[s.jsx(Ax,{layoutId:W.key,preset:N?.layout??"horizontal",initialTree:hC(W.sessions.map(we=>we.id),Z,N?.ratios,N?.gridColumnRatios,N?.gridRowRatios),mobile:Tt,focusId:fe?Ke:null,panes:W.sessions.map(we=>({id:we.id,content:Qt(we,{showPaneTitle:!Tt,suppressKeyboard:Tt&&we.id!==Qe,keyboardPortalTarget:Tt?_e:null,sharedMobileKeyboardLayout:Tt,suppressPageFlipRefresh:!0})}))}),Tt&&s.jsx("div",{ref:tr,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(Ax,{layoutId:W.key,preset:N?.layout??"horizontal",mobile:Tt,panes:[{id:W.sessions[0].id,content:Qt(W.sessions[0])}]})})},W.key)})})}),ae&&Y&&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:()=>Ve(!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:()=>Ve(!1),"aria-label":B("common.close"),children:s.jsx(In,{size:16})})]}),s.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[s.jsxs("button",{type:"button",disabled:Ze,onClick:()=>{tn()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(zs,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:B("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:B("tab.splitNewHint")})]})]}),Ce.filter(W=>W.id!==Tr?.id).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitExistingGroups")}),Ce.filter(W=>W.id!==Tr?.id).map((W,N)=>{const U=W.sessionIds.flatMap(Qe=>{const we=$.find(lt=>lt.id===Qe);return we?[we]:[]});if(U.length<2)return null;const Z=W.name||`${B("tab.splitWorkspace")} ${N+1}`,fe=U.map(Qe=>ht(Qe).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>Wr(U[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(Il,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:Z}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:B("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[B("tab.sessionCount",{count:U.length})," · ",fe]})]}),s.jsx(pi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},W.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitAvailableSessions")}),$.filter(W=>!Ce.some(N=>N.sessionIds.includes(W.id))&&W.id!==Y).length===0&&Ce.filter(W=>W.id!==Tr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:B("tab.splitNoOtherSessions")}):$.filter(W=>!Ce.some(N=>N.sessionIds.includes(W.id))&&W.id!==Y).map(W=>{const N=Jt.get(W.id)??null,U=ht(W);return s.jsxs("button",{type:"button",onClick:()=>Wr(W.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:N?s.jsx(Vc,{size:15}):s.jsx(Il,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:U.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:N?Yu(N)??N:W.name})]}),s.jsx(pi,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},W.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})]})},RN={sm:"h-4 w-7",md:"h-6 w-10"},MN={sm:"h-3 w-3",md:"h-5 w-5"},jN={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 ${RN[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 ${MN[r]} ${e?jN[r]:""}`})})}function ca(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 DN=typeof Symbol=="function"&&Symbol.observable||"@@observable",e5=DN,t5=()=>Math.random().toString(36).substring(7).split("").join("."),BN={INIT:`@@redux/INIT${t5()}`,REPLACE:`@@redux/REPLACE${t5()}`},r5=BN;function QN(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 fv(e,t,r){if(typeof e!="function")throw new Error(ca(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(ca(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(ca(1));return r(fv)(e,t)}let n=e,a=t,c=new Map,l=c,d=0,f=!1;function m(){l===c&&(l=new Map,c.forEach((I,R)=>{l.set(R,I)}))}function x(){if(f)throw new Error(ca(3));return a}function y(I){if(typeof I!="function")throw new Error(ca(4));if(f)throw new Error(ca(5));let R=!0;m();const B=d++;return l.set(B,I),function(){if(R){if(f)throw new Error(ca(6));R=!1,m(),l.delete(B),c=null}}}function w(I){if(!QN(I))throw new Error(ca(7));if(typeof I.type>"u")throw new Error(ca(8));if(typeof I.type!="string")throw new Error(ca(17));if(f)throw new Error(ca(9));try{f=!0,a=n(a,I)}finally{f=!1}return(c=l).forEach(B=>{B()}),I}function v(I){if(typeof I!="function")throw new Error(ca(10));n=I,w({type:r5.REPLACE})}function S(){const I=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(ca(11));function B(){const O=R;O.next&&O.next(x())}return B(),{unsubscribe:I(B)}},[e5](){return this}}}return w({type:r5.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[e5]:S}}function n5(e,t){return function(...r){return t(e.apply(this,r))}}function s5(e,t){if(typeof e=="function")return n5(e,t);if(typeof e!="object"||e===null)throw new Error(ca(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=n5(a,t))}return r}function pv(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function PN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(ca(15))};const l={getState:a.getState,dispatch:(f,...m)=>c(f,...m)},d=e.map(f=>f(l));return c=pv(...d)(a.dispatch),{...a,dispatch:c}}}var am={exports:{}},om={};var i5;function ON(){if(i5)return om;i5=1;var e=kA();function t(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,c=e.useEffect,l=e.useMemo,d=e.useDebugValue;return om.useSyncExternalStoreWithSelector=function(f,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 I($){if(!R){if(R=!0,B=$,$=y($),w!==void 0&&S.hasValue){var V=S.value;if(w(V,$))return z=V}return z=$}if(V=z,r(B,$))return V;var Y=y($);return w!==void 0&&w(V,Y)?(B=$,V):(B=$,z=Y)}var R=!1,B,z,O=x===void 0?null:x;return[function(){return I(m())},O===null?void 0:function(){return I(O())}]},[m,x,y,w]);var C=n(f,v[0],v[1]);return c(function(){S.hasValue=!0,S.value=C},[C]),d(C),C},om}var a5;function FN(){return a5||(a5=1,am.exports=ON()),am.exports}FN();var $N=b.version.startsWith("19"),UN=Symbol.for($N?"react.transitional.element":"react.element"),zN=Symbol.for("react.portal"),HN=Symbol.for("react.fragment"),WN=Symbol.for("react.strict_mode"),GN=Symbol.for("react.profiler"),VN=Symbol.for("react.consumer"),qN=Symbol.for("react.context"),mv=Symbol.for("react.forward_ref"),YN=Symbol.for("react.suspense"),ZN=Symbol.for("react.suspense_list"),ig=Symbol.for("react.memo"),KN=Symbol.for("react.lazy"),XN=mv,JN=ig;function eR(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case UN:switch(e=e.type,e){case HN:case GN:case WN:case YN:case ZN:return e;default:switch(e=e&&e.$$typeof,e){case qN:case mv:case KN:case ig:return e;case VN:return e;default:return t}}case zN:return t}}}function tR(e){return eR(e)===ig}function rR(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let d=!1,f,m,x,y,w;function v(B,z){return f=B,m=z,x=e(f,m),y=t(n,m),w=r(x,y,m),d=!0,w}function S(){return x=e(f,m),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function C(){return e.dependsOnOwnProps&&(x=e(f,m)),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function I(){const B=e(f,m),z=!l(B,x);return x=B,z&&(w=r(x,y,m)),w}function R(B,z){const O=!c(z,m),$=!a(B,f,z,m);return f=B,m=z,O&&$?S():O?C():$?I():w}return function(z,O){return d?R(z,O):v(z,O)}}function nR(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),d=n(e,a);return rR(c,l,d,e,a)}function sR(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 m1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function o5(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function gv(e,t){return function(n,{displayName:a}){const c=function(d,f){return c.dependsOnOwnProps?c.mapToProps(d,f):c.mapToProps(d,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(d,f){c.mapToProps=e,c.dependsOnOwnProps=o5(e);let m=c(d,f);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=o5(m),m=c(d,f)),m},c}}function ag(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function iR(e){return e&&typeof e=="object"?m1(t=>sR(e,t)):e?typeof e=="function"?gv(e):ag(e,"mapDispatchToProps"):m1(t=>({dispatch:t}))}function aR(e){return e?typeof e=="function"?gv(e):ag(e,"mapStateToProps"):m1(()=>({}))}function oR(e,t,r){return{...r,...e,...t}}function lR(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let c=!1,l;return function(f,m,x){const y=e(f,m,x);return c?a(y,l)||(l=y):(c=!0,l=y),l}}}function cR(e){return e?typeof e=="function"?lR(e):ag(e,"mergeProps"):()=>oR}function uR(e){e()}function dR(){let e=null,t=null;return{clear(){e=null,t=null},notify(){uR(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var l5={notify(){},get:()=>[]};function xv(e,t){let r,n=l5,a=0,c=!1;function l(C){x();const I=n.subscribe(C);let R=!1;return()=>{R||(R=!0,I(),y())}}function d(){n.notify()}function f(){S.onStateChange&&S.onStateChange()}function m(){return c}function x(){a++,r||(r=t?t.addNestedSub(f):e.subscribe(f),n=dR())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=l5)}function w(){c||(c=!0,x())}function v(){c&&(c=!1,y())}const S={addNestedSub:l,notifyNestedSubs:d,handleChangeWrapper:f,isSubscribed:m,trySubscribe:w,tryUnsubscribe:v,getListeners:()=>n};return S}var hR=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",fR=hR(),pR=()=>typeof navigator<"u"&&navigator.product==="ReactNative",mR=pR(),gR=()=>fR||mR?b.useLayoutEffect:b.useEffect,Tf=gR();function c5(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function lm(e,t){if(c5(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])||!c5(e[r[a]],t[r[a]]))return!1;return!0}var xR={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},bR={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},yR={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},bv={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},vR={[XN]:yR,[JN]:bv};function u5(e){return tR(e)?bv:vR[e.$$typeof]||xR}var wR=Object.defineProperty,AR=Object.getOwnPropertyNames,d5=Object.getOwnPropertySymbols,TR=Object.getOwnPropertyDescriptor,SR=Object.getPrototypeOf,h5=Object.prototype;function g1(e,t){if(typeof t!="string"){if(h5){const c=SR(t);c&&c!==h5&&g1(e,c)}let r=AR(t);d5&&(r=r.concat(d5(t)));const n=u5(e),a=u5(t);for(let c=0;c<r.length;++c){const l=r[c];if(!bR[l]&&!(a&&a[l])&&!(n&&n[l])){const d=TR(t,l);try{wR(e,l,d)}catch{}}}}return e}var CR=Symbol.for("react-redux-context"),_R=typeof globalThis<"u"?globalThis:{};function kR(){if(!b.createContext)return{};const e=_R[CR]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var yv=kR(),LR=[null,null];function IR(e,t,r){Tf(()=>e(...t),r)}function ER(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function NR(e,t,r,n,a,c,l,d,f,m,x){if(!e)return()=>{};let y=!1,w=null;const v=()=>{if(y||!d.current)return;const C=t.getState();let I,R;try{I=n(C,a.current)}catch(B){R=B,w=B}R||(w=null),I===c.current?l.current||m():(c.current=I,f.current=I,l.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,w)throw w}}function RR(e,t){return e===t}function MR(e,t,r,{pure:n,areStatesEqual:a=RR,areOwnPropsEqual:c=lm,areStatePropsEqual:l=lm,areMergedPropsEqual:d=lm,forwardRef:f=!1,context:m=yv}={}){const x=m,y=aR(e),w=iR(t),v=cR(r),S=!!e;return I=>{const R=I.displayName||I.name||"Component",B=`Connect(${R})`,z={shouldHandleStateChanges:S,displayName:B,wrappedComponentName:R,WrappedComponent:I,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:d};function O(Y){const[le,be,pe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ye,...at}=Y;return[Y.context,Ye,at]},[Y]),ee=b.useMemo(()=>{let Ye=x;return le?.Consumer,Ye},[le,x]),ke=b.useContext(ee),He=!!Y.store&&!!Y.store.getState&&!!Y.store.dispatch,q=!!ke&&!!ke.store,ce=He?Y.store:ke.store,qe=q?ke.getServerState:ce.getState,Ae=b.useMemo(()=>nR(ce.dispatch,z),[ce]),[ve,Ie]=b.useMemo(()=>{if(!S)return LR;const Ye=xv(ce,He?void 0:ke.subscription),at=Ye.notifyNestedSubs.bind(Ye);return[Ye,at]},[ce,He,ke]),Be=b.useMemo(()=>He?ke:{...ke,subscription:ve},[He,ke,ve]),ne=b.useRef(void 0),Fe=b.useRef(pe),Le=b.useRef(void 0),Re=b.useRef(!1),Pe=b.useRef(!1),Ee=b.useRef(void 0);Tf(()=>(Pe.current=!0,()=>{Pe.current=!1}),[]);const oe=b.useMemo(()=>()=>Le.current&&pe===Fe.current?Le.current:Ae(ce.getState(),pe),[ce,pe]),We=b.useMemo(()=>at=>ve?NR(S,ce,ve,Ae,Fe,ne,Re,Pe,Le,Ie,at):()=>{},[ve]);IR(ER,[Fe,ne,Re,pe,Le,Ie]);let rt;try{rt=b.useSyncExternalStore(We,oe,qe?()=>Ae(qe(),pe):oe)}catch(Ye){throw Ee.current&&(Ye.message+=`
|
|
78
|
-
The error may be correlated with this previous error:
|
|
79
|
-
${Ee.current.stack}
|
|
80
|
-
|
|
81
|
-
`),Ye}Tf(()=>{Ee.current=void 0,Le.current=void 0,ne.current=rt});const gt=b.useMemo(()=>b.createElement(I,{...rt,ref:be}),[be,I,rt]);return b.useMemo(()=>S?b.createElement(ee.Provider,{value:Be},gt):gt,[ee,gt,Be])}const V=b.memo(O);if(V.WrappedComponent=I,V.displayName=O.displayName=B,f){const le=b.forwardRef(function(pe,ee){return b.createElement(V,{...pe,reactReduxForwardedRef:ee})});return le.displayName=B,le.WrappedComponent=I,g1(le,I)}return g1(V,I)}}var vv=MR;function jR(e){const{children:t,context:r,serverState:n,store:a}=e,c=b.useMemo(()=>{const f=xv(a);return{store:a,subscription:f,getServerState:n?()=>n:void 0}},[a,n]),l=b.useMemo(()=>a.getState(),[a]);Tf(()=>{const{subscription:f}=c;return f.onStateChange=f.notifyNestedSubs,f.trySubscribe(),l!==a.getState()&&f.notifyNestedSubs(),()=>{f.tryUnsubscribe(),f.onStateChange=void 0}},[c,l]);const d=r||yv;return b.createElement(d.Provider,{value:c},t)}var DR=jR,BR="Invariant failed";function QR(e,t){throw new Error(BR)}var Fo=function(t){var r=t.top,n=t.right,a=t.bottom,c=t.left,l=n-c,d=a-r,f={top:r,right:n,bottom:a,left:c,width:l,height:d,x:c,y:r,center:{x:(n+c)/2,y:(a+r)/2}};return f},og=function(t,r){return{top:t.top-r.top,left:t.left-r.left,bottom:t.bottom+r.bottom,right:t.right+r.right}},f5=function(t,r){return{top:t.top+r.top,left:t.left+r.left,bottom:t.bottom-r.bottom,right:t.right-r.right}},PR=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},cm={top:0,right:0,bottom:0,left:0},lg=function(t){var r=t.borderBox,n=t.margin,a=n===void 0?cm:n,c=t.border,l=c===void 0?cm:c,d=t.padding,f=d===void 0?cm:d,m=Fo(og(r,a)),x=Fo(f5(r,l)),y=Fo(f5(x,f));return{marginBox:m,borderBox:Fo(r),paddingBox:x,contentBox:y,margin:a,border:l,padding:f}},po=function(t){var r=t.slice(0,-2),n=t.slice(-2);if(n!=="px")return 0;var a=Number(r);return isNaN(a)&&QR(),a},OR=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Sf=function(t,r){var n=t.borderBox,a=t.border,c=t.margin,l=t.padding,d=PR(n,r);return lg({borderBox:d,border:a,margin:c,padding:l})},Cf=function(t,r){return r===void 0&&(r=OR()),Sf(t,r)},wv=function(t,r){var n={top:po(r.marginTop),right:po(r.marginRight),bottom:po(r.marginBottom),left:po(r.marginLeft)},a={top:po(r.paddingTop),right:po(r.paddingRight),bottom:po(r.paddingBottom),left:po(r.paddingLeft)},c={top:po(r.borderTopWidth),right:po(r.borderRightWidth),bottom:po(r.borderBottomWidth),left:po(r.borderLeftWidth)};return lg({borderBox:t,margin:n,padding:a,border:c})},Av=function(t){var r=t.getBoundingClientRect(),n=window.getComputedStyle(t);return wv(r,n)},A0=function(t){var r=[],n=null,a=function(){for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];r=d,!n&&(n=requestAnimationFrame(function(){n=null,t.apply(void 0,r)}))};return a.cancel=function(){n&&(cancelAnimationFrame(n),n=null)},a};function _f(){return _f=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},_f.apply(null,arguments)}function Tv(e,t){}Tv.bind(null,"warn");Tv.bind(null,"error");function oc(){}function FR(e,t){return{...e,...t}}function wo(e,t,r){const n=t.map(a=>{const c=FR(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 $R="Invariant failed";class kf extends Error{}kf.prototype.toString=function(){return this.message};function Ft(e,t){throw new kf($R)}class UR extends L.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 kf&&r.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=r=>{this.callbacks=r}}componentDidMount(){this.unbind=wo(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof kf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const zR=`
|
|
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
|
-
`,Lf=e=>e+1,HR=e=>`
|
|
86
|
-
You have lifted an item in position ${Lf(e.source.index)}
|
|
87
|
-
`,Sv=(e,t)=>{const r=e.droppableId===t.droppableId,n=Lf(e.index),a=Lf(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
|
-
`},Cv=(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
|
-
`,WR=e=>{const t=e.destination;if(t)return Sv(e.source,t);const r=e.combine;return r?Cv(e.draggableId,e.source,r):"You are over an area that cannot be dropped on"},p5=e=>`
|
|
103
|
-
The item has returned to its starting position
|
|
104
|
-
of ${Lf(e.index)}
|
|
105
|
-
`,GR=e=>{if(e.reason==="CANCEL")return`
|
|
106
|
-
Movement cancelled.
|
|
107
|
-
${p5(e.source)}
|
|
108
|
-
`;const t=e.destination,r=e.combine;return t?`
|
|
109
|
-
You have dropped the item.
|
|
110
|
-
${Sv(e.source,t)}
|
|
111
|
-
`:r?`
|
|
112
|
-
You have dropped the item.
|
|
113
|
-
${Cv(e.draggableId,e.source,r)}
|
|
114
|
-
`:`
|
|
115
|
-
The item has been dropped while not over a drop area.
|
|
116
|
-
${p5(e.source)}
|
|
117
|
-
`},Xh={dragHandleUsageInstructions:zR,onDragStart:HR,onDragUpdate:WR,onDragEnd:GR};function VR(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function _v(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!VR(e[r],t[r]))return!1;return!0}function Sn(e,t){const r=b.useState(()=>({inputs:t,result:e()}))[0],n=b.useRef(!0),a=b.useRef(r),l=n.current||!!(t&&a.current.inputs&&_v(t,a.current.inputs))?a.current:{inputs:t,result:e()};return b.useEffect(()=>{n.current=!1,a.current=l},[l]),l.result}function wr(e,t){return Sn(()=>e,t)}const gi={x:0,y:0},Ni=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Ua=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lc=(e,t)=>e.x===t.x&&e.y===t.y,Ju=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Zc=(e,t,r=0)=>e==="x"?{x:t,y:r}:{x:r,y:t},T0=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),m5=(e,t)=>Math.min(...t.map(r=>T0(e,r))),kv=e=>t=>({x:e(t.x),y:e(t.y)});var qR=(e,t)=>{const r=Fo({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return r.width<=0||r.height<=0?null:r};const B0=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),g5=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}],YR={top:0,right:0,bottom:0,left:0},ZR=(e,t)=>t?B0(e,t.scroll.diff.displacement):e,KR=(e,t,r)=>r&&r.increasedBy?{...e,[t.end]:e[t.end]+r.increasedBy[t.line]}:e,XR=(e,t)=>t&&t.shouldClipSubject?qR(t.pageMarginBox,e):Fo(e);var Hu=({page:e,withPlaceholder:t,axis:r,frame:n})=>{const a=ZR(e.marginBox,n),c=KR(a,r,t),l=XR(c,n);return{page:e,withPlaceholder:t,active:l}},cg=(e,t)=>{e.frame||Ft();const r=e.frame,n=Ua(t,r.scroll.initial),a=Ju(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 mi(e,t=_v){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 Lv=mi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),Iv=mi(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),qf=mi(e=>Object.values(e)),JR=mi(e=>Object.values(e));var ed=mi((e,t)=>JR(t).filter(n=>e===n.descriptor.droppableId).sort((n,a)=>n.descriptor.index-a.descriptor.index));function ug(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Yf(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var Zf=mi((e,t)=>t.filter(r=>r.descriptor.id!==e.descriptor.id)),eM=({isMovingForward:e,draggable:t,destination:r,insideDestination:n,previousImpact:a})=>{if(!r.isCombineEnabled||!ug(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,f=d.length?d[0]:null;if(e)return f?l(f):null;const m=Zf(t,n);if(!f){if(!m.length)return null;const v=m[m.length-1];return l(v.descriptor.id)}const x=m.findIndex(v=>v.descriptor.id===f);x===-1&&Ft();const y=x-1;if(y<0)return null;const w=m[y];return l(w.descriptor.id)},td=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Ev={point:gi,value:0},S0={invisible:{},visible:{},all:[]},tM={displaced:S0,displacedBy:Ev,at:null};var Ao=(e,t)=>r=>e<=r&&r<=t,Nv=e=>{const t=Ao(e.top,e.bottom),r=Ao(e.left,e.right);return n=>{if(t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right))return!0;const c=t(n.top)||t(n.bottom),l=r(n.left)||r(n.right);if(c&&l)return!0;const f=n.top<e.top&&n.bottom>e.bottom,m=n.left<e.left&&n.right>e.right;return f&&m?!0:f&&l||m&&c}},rM=e=>{const t=Ao(e.top,e.bottom),r=Ao(e.left,e.right);return n=>t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right)};const dg={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},Rv={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var nM=e=>t=>{const r=Ao(t.top,t.bottom),n=Ao(t.left,t.right);return a=>e===dg?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)};const sM=(e,t)=>{const r=t.frame?t.frame.scroll.diff.displacement:gi;return B0(e,r)},iM=(e,t,r)=>t.subject.active?r(t.subject.active)(e):!1,aM=(e,t,r)=>r(t)(e),hg=({target:e,destination:t,viewport:r,withDroppableDisplacement:n,isVisibleThroughFrameFn:a})=>{const c=n?sM(e,t):e;return iM(c,t,a)&&aM(c,r,a)},oM=e=>hg({...e,isVisibleThroughFrameFn:Nv}),Mv=e=>hg({...e,isVisibleThroughFrameFn:rM}),lM=e=>hg({...e,isVisibleThroughFrameFn:nM(e.destination.axis)}),cM=(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 uM(e,t){const r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return Fo(og(r,n))}function C0({afterDragging:e,destination:t,displacedBy:r,viewport:n,forceShouldAnimate:a,last:c}){return e.reduce(function(d,f){const m=uM(f,r),x=f.descriptor.id;if(d.all.push(x),!oM({target:m,destination:t,viewport:n,withDroppableDisplacement:!0}))return d.invisible[f.descriptor.id]=!0,d;const w=cM(x,c,a),v={draggableId:x,shouldAnimate:w};return d.visible[x]=v,d},{all:[],visible:{},invisible:{}})}function dM(e,t){if(!e.length)return 0;const r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function x5({insideDestination:e,inHomeList:t,displacedBy:r,destination:n}){const a=dM(e,{inHomeList:t});return{displaced:S0,displacedBy:r,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function If({draggable:e,insideDestination:t,destination:r,viewport:n,displacedBy:a,last:c,index:l,forceShouldAnimate:d}){const f=td(e,r);if(l==null)return x5({insideDestination:t,inHomeList:f,displacedBy:a,destination:r});const m=t.find(S=>S.descriptor.index===l);if(!m)return x5({insideDestination:t,inHomeList:f,displacedBy:a,destination:r});const x=Zf(e,t),y=t.indexOf(m),w=x.slice(y);return{displaced:C0({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 hM=({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},fM=({isMovingForward:e,isInHomeList:t,insideDestination:r,location:n})=>{if(!r.length)return null;const a=n.index,c=e?a+1:a-1,l=r[0].descriptor.index,d=r[r.length-1].descriptor.index,f=t?d:d+1;return c<l||c>f?null:c},pM=({isMovingForward:e,isInHomeList:t,draggable:r,draggables:n,destination:a,insideDestination:c,previousImpact:l,viewport:d,afterCritical:f})=>{const m=l.at;if(m||Ft(),m.type==="REORDER"){const y=fM({isMovingForward:e,isInHomeList:t,location:m.destination,insideDestination:c});return y==null?null:If({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:y})}const x=hM({isMovingForward:e,destination:a,displaced:l.displaced,draggables:n,combine:m.combine,afterCritical:f});return x==null?null:If({draggable:r,insideDestination:c,destination:a,viewport:d,last:l.displaced,displacedBy:l.displacedBy,index:x})},mM=({displaced:e,afterCritical:t,combineWith:r,displacedBy:n})=>{const a=!!(e.visible[r]||e.invisible[r]);return dc(r,t)?a?gi:Ju(n.point):a?n.point:gi},gM=({afterCritical:e,impact:t,draggables:r})=>{const n=Yf(t);n||Ft();const a=n.draggableId,c=r[a].page.borderBox.center,l=mM({displaced:t.displaced,afterCritical:e,combineWith:a,displacedBy:t.displacedBy});return Ni(c,l)};const jv=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,xM=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,fg=(e,t,r)=>t[e.crossAxisStart]+r.margin[e.crossAxisStart]+r.borderBox[e.crossAxisSize]/2,b5=({axis:e,moveRelativeTo:t,isMoving:r})=>Zc(e.line,t.marginBox[e.end]+jv(e,r),fg(e,t.marginBox,r)),y5=({axis:e,moveRelativeTo:t,isMoving:r})=>Zc(e.line,t.marginBox[e.start]-xM(e,r),fg(e,t.marginBox,r)),bM=({axis:e,moveInto:t,isMoving:r})=>Zc(e.line,t.contentBox[e.start]+jv(e,r),fg(e,t.contentBox,r));var yM=({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:a})=>{const c=ed(n.descriptor.id,r),l=t.page,d=n.axis;if(!c.length)return bM({axis:d,moveInto:n.page,isMoving:l});const{displaced:f,displacedBy:m}=e,x=f.all[0];if(x){const w=r[x];if(dc(x,a))return y5({axis:d,moveRelativeTo:w.page,isMoving:l});const v=Sf(w.page,m.point);return y5({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=Sf(y.page,Ju(a.displacedBy.point));return b5({axis:d,moveRelativeTo:w,isMoving:l})}return b5({axis:d,moveRelativeTo:y.page,isMoving:l})},x1=(e,t)=>{const r=e.frame;return r?Ni(t,r.scroll.diff.displacement):t};const vM=({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"?yM({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:a}):gM({impact:e,draggables:n,afterCritical:a})};var Kf=e=>{const t=vM(e),r=e.droppable;return r?x1(r,t):t},Dv=(e,t)=>{const r=Ua(t,e.scroll.initial),n=Ju(r);return{frame:Fo({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:r,displacement:n}}}};function v5(e,t){return e.map(r=>t[r])}function wM(e,t){for(let r=0;r<t.length;r++){const n=t[r].visible[e];if(n)return n}return null}var AM=({impact:e,viewport:t,destination:r,draggables:n,maxScrollChange:a})=>{const c=Dv(t,Ni(t.scroll.current,a)),l=r.frame?cg(r,Ni(r.frame.scroll.current,a)):r,d=e.displaced,f=C0({afterDragging:v5(d.all,n),destination:r,displacedBy:e.displacedBy,viewport:c.frame,last:d,forceShouldAnimate:!1}),m=C0({afterDragging:v5(d.all,n),destination:l,displacedBy:e.displacedBy,viewport:t.frame,last:d,forceShouldAnimate:!1}),x={},y={},w=[d,f,m];return d.all.forEach(S=>{const C=wM(S,w);if(C){y[S]=C;return}x[S]=!0}),{...e,displaced:{all:d.all,invisible:x,visible:y}}},TM=(e,t)=>Ni(e.scroll.diff.displacement,t),pg=({pageBorderBoxCenter:e,draggable:t,viewport:r})=>{const n=TM(r,e),a=Ua(n,t.page.borderBox.center);return Ni(t.client.borderBox.center,a)},Bv=({draggable:e,destination:t,newPageBorderBoxCenter:r,viewport:n,withDroppableDisplacement:a,onlyOnMainAxis:c=!1})=>{const l=Ua(r,e.page.borderBox.center),f={target:B0(e.page.borderBox,l),destination:t,withDroppableDisplacement:a,viewport:n};return c?lM(f):Mv(f)},SM=({isMovingForward:e,draggable:t,destination:r,draggables:n,previousImpact:a,viewport:c,previousPageBorderBoxCenter:l,previousClientSelection:d,afterCritical:f})=>{if(!r.isEnabled)return null;const m=ed(r.descriptor.id,n),x=td(t,r),y=eM({isMovingForward:e,draggable:t,destination:r,insideDestination:m,previousImpact:a})||pM({isMovingForward:e,isInHomeList:x,draggable:t,draggables:n,destination:r,insideDestination:m,previousImpact:a,viewport:c,afterCritical:f});if(!y)return null;const w=Kf({impact:y,draggable:t,droppable:r,draggables:n,afterCritical:f});if(Bv({draggable:t,destination:r,newPageBorderBoxCenter:w,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:pg({pageBorderBoxCenter:w,draggable:t,viewport:c}),impact:y,scrollJumpRequest:null};const S=Ua(w,l),C=AM({impact:y,viewport:c,destination:r,draggables:n,maxScrollChange:S});return{clientSelection:d,impact:C,scrollJumpRequest:S}};const ia=e=>{const t=e.subject.active;return t||Ft(),t};var CM=({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:n,viewport:a})=>{const c=r.subject.active;if(!c)return null;const l=r.axis,d=Ao(c[l.start],c[l.end]),f=qf(n).filter(x=>x!==r).filter(x=>x.isEnabled).filter(x=>!!x.subject.active).filter(x=>Nv(a.frame)(ia(x))).filter(x=>{const y=ia(x);return e?c[l.crossAxisEnd]<y[l.crossAxisEnd]:y[l.crossAxisStart]<c[l.crossAxisStart]}).filter(x=>{const y=ia(x),w=Ao(y[l.start],y[l.end]);return d(y[l.start])||d(y[l.end])||w(c[l.start])||w(c[l.end])}).sort((x,y)=>{const w=ia(x)[l.crossAxisStart],v=ia(y)[l.crossAxisStart];return e?w-v:v-w}).filter((x,y,w)=>ia(x)[l.crossAxisStart]===ia(w[0])[l.crossAxisStart]);if(!f.length)return null;if(f.length===1)return f[0];const m=f.filter(x=>Ao(ia(x)[l.start],ia(x)[l.end])(t[l.line]));return m.length===1?m[0]:m.length>1?m.sort((x,y)=>ia(x)[l.start]-ia(y)[l.start])[0]:f.sort((x,y)=>{const w=m5(t,g5(ia(x))),v=m5(t,g5(ia(y)));return w!==v?w-v:ia(x)[l.start]-ia(y)[l.start]})[0]};const w5=(e,t)=>{const r=e.page.borderBox.center;return dc(e.descriptor.id,t)?Ua(r,t.displacedBy.point):r},_M=(e,t)=>{const r=e.page.borderBox;return dc(e.descriptor.id,t)?B0(r,Ju(t.displacedBy.point)):r};var kM=({pageBorderBoxCenter:e,viewport:t,destination:r,insideDestination:n,afterCritical:a})=>n.filter(l=>Mv({target:_M(l,a),destination:r,viewport:t.frame,withDroppableDisplacement:!0})).sort((l,d)=>{const f=T0(e,x1(r,w5(l,a))),m=T0(e,x1(r,w5(d,a)));return f<m?-1:m<f?1:l.descriptor.index-d.descriptor.index})[0]||null,Q0=mi(function(t,r){const n=r[t.line];return{value:n,point:Zc(t.line,n)}});const LM=(e,t,r)=>{const n=e.axis;if(e.descriptor.mode==="virtual")return Zc(n.line,t[n.line]);const a=e.subject.page.contentBox[n.size],f=ed(e.descriptor.id,r).reduce((m,x)=>m+x.client.marginBox[n.size],0)+t[n.line]-a;return f<=0?null:Zc(n.line,f)},Qv=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),Pv=(e,t,r)=>{const n=e.frame;td(t,e)&&Ft(),e.subject.withPlaceholder&&Ft();const a=Q0(e.axis,t.displaceBy).point,c=LM(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?Ni(n.scroll.max,c):n.scroll.max,f=Qv(n,d),m=Hu({page:e.subject.page,withPlaceholder:l,axis:e.axis,frame:f});return{...e,subject:m,frame:f}},IM=e=>{const t=e.subject.withPlaceholder;t||Ft();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||Ft();const a=Qv(r,n),c=Hu({page:e.subject.page,axis:e.axis,frame:a,withPlaceholder:null});return{...e,subject:c,frame:a}};var EM=({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:S0,displacedBy:Ev,at:{type:"REORDER",destination:{droppableId:c.descriptor.id,index:0}}},w=Kf({impact:y,draggable:n,droppable:c,draggables:a,afterCritical:d}),v=td(n,c)?c:Pv(c,n,a);return Bv({draggable:n,destination:v,newPageBorderBoxCenter:w,viewport:l.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?y:null}const f=e[c.axis.line]<=t.page.borderBox.center[c.axis.line],m=(()=>{const y=t.descriptor.index;return t.descriptor.id===n.descriptor.id||f?y:y+1})(),x=Q0(c.axis,n.displaceBy);return If({draggable:n,insideDestination:r,destination:c,viewport:l,displacedBy:x,last:S0,index:m})},NM=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:r,isOver:n,draggables:a,droppables:c,viewport:l,afterCritical:d})=>{const f=CM({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:c,viewport:l});if(!f)return null;const m=ed(f.descriptor.id,a),x=kM({pageBorderBoxCenter:t,viewport:l,destination:f,insideDestination:m,afterCritical:d}),y=EM({previousPageBorderBoxCenter:t,destination:f,draggable:r,draggables:a,moveRelativeTo:x,insideDestination:m,viewport:l,afterCritical:d});if(!y)return null;const w=Kf({impact:y,draggable:r,droppable:f,draggables:a,afterCritical:d});return{clientSelection:pg({pageBorderBoxCenter:w,draggable:r,viewport:l}),impact:y,scrollJumpRequest:null}},Ha=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const RM=(e,t)=>{const r=Ha(e);return r?t[r]:null};var MM=({state:e,type:t})=>{const r=RM(e.impact,e.dimensions.droppables),n=!!r,a=e.dimensions.droppables[e.critical.droppable.id],c=r||a,l=c.axis.direction,d=l==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||l==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(d&&!n)return null;const f=t==="MOVE_DOWN"||t==="MOVE_RIGHT",m=e.dimensions.draggables[e.critical.draggable.id],x=e.current.page.borderBoxCenter,{draggables:y,droppables:w}=e.dimensions;return d?SM({isMovingForward:f,previousPageBorderBoxCenter:x,draggable:m,destination:c,draggables:y,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):NM({isMovingForward:f,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 Ov(e){const t=Ao(e.top,e.bottom),r=Ao(e.left,e.right);return function(a){return t(a.y)&&r(a.x)}}function jM(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function DM({pageBorderBox:e,draggable:t,candidates:r}){const n=t.page.borderBox.center,a=r.map(c=>{const l=c.axis,d=Zc(c.axis.line,e.center[l.line],c.page.borderBox.center[l.crossAxisLine]);return{id:c.descriptor.id,distance:T0(n,d)}}).sort((c,l)=>l.distance-c.distance);return a[0]?a[0].id:null}function BM({pageBorderBox:e,draggable:t,droppables:r}){const n=qf(r).filter(a=>{if(!a.isEnabled)return!1;const c=a.subject.active;if(!c||!jM(e,c))return!1;if(Ov(c)(e.center))return!0;const l=a.axis,d=c.center[l.crossAxisLine],f=e[l.crossAxisStart],m=e[l.crossAxisEnd],x=Ao(c[l.crossAxisStart],c[l.crossAxisEnd]),y=x(f),w=x(m);return!y&&!w?!0:y?f<d:m>d});return n.length?n.length===1?n[0].descriptor.id:DM({pageBorderBox:e,draggable:t,candidates:n}):null}const Fv=(e,t)=>Fo(B0(e,t));var QM=(e,t)=>{const r=e.frame;return r?Fv(t,r.scroll.diff.value):t};function $v({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function PM({draggable:e,closest:t,inHomeList:r}){return t?r&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var OM=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:r,insideDestination:n,last:a,viewport:c,afterCritical:l})=>{const d=r.axis,f=Q0(r.axis,t.displaceBy),m=f.value,x=e[d.start],y=e[d.end],v=Zf(t,n).find(C=>{const I=C.descriptor.id,R=C.page.borderBox.center[d.line],B=dc(I,l),z=$v({displaced:a,id:I});return B?z?y<=R:x<R-m:z?y<=R+m:x<R})||null,S=PM({draggable:t,closest:v,inHomeList:td(t,r)});return If({draggable:t,insideDestination:n,destination:r,viewport:c,last:a,displacedBy:f,index:S})};const FM=4;var $M=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:r,destination:n,insideDestination:a,afterCritical:c})=>{if(!n.isCombineEnabled)return null;const l=n.axis,d=Q0(n.axis,e.displaceBy),f=d.value,m=t[l.start],x=t[l.end],w=Zf(e,a).find(S=>{const C=S.descriptor.id,I=S.page.borderBox,B=I[l.size]/FM,z=dc(C,c),O=$v({displaced:r.displaced,id:C});return z?O?x>I[l.start]+B&&x<I[l.end]-B:m>I[l.start]-f+B&&m<I[l.end]-f-B:O?x>I[l.start]+f+B&&x<I[l.end]+f-B:m>I[l.start]+B&&m<I[l.end]-B});return w?{displacedBy:d,displaced:r.displaced,at:{type:"COMBINE",combine:{draggableId:w.descriptor.id,droppableId:n.descriptor.id}}}:null},Uv=({pageOffset:e,draggable:t,draggables:r,droppables:n,previousImpact:a,viewport:c,afterCritical:l})=>{const d=Fv(t.page.borderBox,e),f=BM({pageBorderBox:d,draggable:t,droppables:n});if(!f)return tM;const m=n[f],x=ed(m.descriptor.id,r),y=QM(m,d);return $M({pageBorderBoxWithDroppableScroll:y,draggable:t,previousImpact:a,destination:m,insideDestination:x,afterCritical:l})||OM({pageBorderBoxWithDroppableScroll:y,draggable:t,destination:m,insideDestination:x,last:a.displaced,viewport:c,afterCritical:l})},mg=(e,t)=>({...e,[t.descriptor.id]:t});const UM=({previousImpact:e,impact:t,droppables:r})=>{const n=Ha(e),a=Ha(t);if(!n||n===a)return r;const c=r[n];if(!c.subject.withPlaceholder)return r;const l=IM(c);return mg(r,l)};var zM=({draggable:e,draggables:t,droppables:r,previousImpact:n,impact:a})=>{const c=UM({previousImpact:n,impact:a,droppables:r}),l=Ha(a);if(!l)return c;const d=r[l];if(td(e,d)||d.subject.withPlaceholder)return c;const f=Pv(d,e,t);return mg(c,f)},l0=({state:e,clientSelection:t,dimensions:r,viewport:n,impact:a,scrollJumpRequest:c})=>{const l=n||e.viewport,d=r||e.dimensions,f=t||e.current.client.selection,m=Ua(f,e.initial.client.selection),x={offset:m,selection:f,borderBoxCenter:Ni(e.initial.client.borderBoxCenter,m)},y={selection:Ni(x.selection,l.scroll.current),borderBoxCenter:Ni(x.borderBoxCenter,l.scroll.current),offset:Ni(x.offset,l.scroll.diff.value)},w={client:x,page:y};if(e.phase==="COLLECTING")return{...e,dimensions:d,viewport:l,current:w};const v=d.draggables[e.critical.draggable.id],S=a||Uv({pageOffset:y.offset,draggable:v,draggables:d.draggables,droppables:d.droppables,previousImpact:e.impact,viewport:l,afterCritical:e.afterCritical}),C=zM({draggable:v,impact:S,previousImpact:e.impact,draggables:d.draggables,droppables:d.droppables});return{...e,current:w,dimensions:{draggables:d.draggables,droppables:C},impact:S,viewport:l,scrollJumpRequest:c||null,forceShouldAnimate:c?!1:null}};function HM(e,t){return e.map(r=>t[r])}var zv=({impact:e,viewport:t,draggables:r,destination:n,forceShouldAnimate:a})=>{const c=e.displaced,l=HM(c.all,r),d=C0({afterDragging:l,destination:n,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:a,last:c});return{...e,displaced:d}},Hv=({impact:e,draggable:t,droppable:r,draggables:n,viewport:a,afterCritical:c})=>{const l=Kf({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:c});return pg({pageBorderBoxCenter:l,draggable:t,viewport:a})},Wv=({state:e,dimensions:t,viewport:r})=>{e.movementMode!=="SNAP"&&Ft();const n=e.impact,a=r||e.viewport,c=t||e.dimensions,{draggables:l,droppables:d}=c,f=l[e.critical.draggable.id],m=Ha(n);m||Ft();const x=d[m],y=zv({impact:n,viewport:a,destination:x,draggables:l}),w=Hv({impact:y,draggable:f,droppable:x,draggables:l,viewport:a,afterCritical:e.afterCritical});return l0({impact:y,clientSelection:w,state:e,dimensions:c,viewport:a})},WM=e=>({index:e.index,droppableId:e.droppableId}),Gv=({draggable:e,home:t,draggables:r,viewport:n})=>{const a=Q0(t.axis,e.displaceBy),c=ed(t.descriptor.id,r),l=c.indexOf(e);l===-1&&Ft();const d=c.slice(l+1),f=d.reduce((w,v)=>(w[v.descriptor.id]=!0,w),{}),m={inVirtualList:t.descriptor.mode==="virtual",displacedBy:a,effected:f};return{impact:{displaced:C0({afterDragging:d,destination:t,displacedBy:a,last:null,viewport:n.frame,forceShouldAnimate:!1}),displacedBy:a,at:{type:"REORDER",destination:WM(e.descriptor)}},afterCritical:m}},GM=(e,t)=>({draggables:e.draggables,droppables:mg(e.droppables,t)}),VM=({draggable:e,offset:t,initialWindowScroll:r})=>{const n=Sf(e.client,t),a=Cf(n,r);return{...e,placeholder:{...e.placeholder,client:n},client:n,page:a}},qM=e=>{const t=e.frame;return t||Ft(),t},YM=({additions:e,updatedDroppables:t,viewport:r})=>{const n=r.scroll.diff.value;return e.map(a=>{const c=a.descriptor.droppableId,l=t[c],f=qM(l).scroll.diff.value,m=Ni(n,f);return VM({draggable:a,offset:m,initialWindowScroll:r.scroll.initial})})},ZM=({state:e,published:t})=>{const r=t.modified.map(R=>{const B=e.dimensions.droppables[R.droppableId];return cg(B,R.scroll)}),n={...e.dimensions.droppables,...Lv(r)},a=Iv(YM({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=Ha(e.impact),f=d?l.droppables[d]:null,m=l.draggables[e.critical.draggable.id],x=l.droppables[e.critical.droppable.id],{impact:y,afterCritical:w}=Gv({draggable:m,home:x,draggables:c,viewport:e.viewport}),v=f&&f.isCombineEnabled?e.impact:y,S=Uv({pageOffset:e.current.page.offset,draggable:l.draggables[e.critical.draggable.id],draggables:l.draggables,droppables:l.droppables,previousImpact:v,viewport:e.viewport,afterCritical:w}),C={...e,phase:"DRAGGING",impact:S,onLiftImpact:y,dimensions:l,afterCritical:w,forceShouldAnimate:!1};return e.phase==="COLLECTING"?C:{...C,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const b1=e=>e.movementMode==="SNAP",um=(e,t,r)=>{const n=GM(e.dimensions,t);return!b1(e)||r?l0({state:e,dimensions:n}):Wv({state:e,dimensions:n})};function dm(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const A5={phase:"IDLE",completed:null,shouldFlush:!1};var KM=(e=A5,t)=>{if(t.type==="FLUSH")return{...A5,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&Ft();const{critical:r,clientSelection:n,viewport:a,dimensions:c,movementMode:l}=t.payload,d=c.draggables[r.draggable.id],f=c.droppables[r.droppable.id],m={selection:n,borderBoxCenter:d.client.borderBox.center,offset:gi},x={client:m,page:{selection:Ni(m.selection,a.scroll.initial),borderBoxCenter:Ni(m.selection,a.scroll.initial),offset:Ni(m.selection,a.scroll.diff.value)}},y=qf(c.droppables).every(C=>!C.isFixedOnPage),{impact:w,afterCritical:v}=Gv({draggable:d,home:f,draggables:c.draggables,viewport:a});return{phase:"DRAGGING",isDragging:!0,critical:r,movementMode:l,dimensions:c,initial:x,current:x,isWindowScrollAllowed:y,impact:w,afterCritical:v,onLiftImpact:w,viewport:a,scrollJumpRequest:null,forceShouldAnimate:null}}if(t.type==="COLLECTION_STARTING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"?e:(e.phase!=="DRAGGING"&&Ft(),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||Ft(),ZM({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Ft();const{client:r}=t.payload;return lc(r,e.current.client.selection)?e:l0({state:e,clientSelection:r,impact:b1(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return dm(e);Mc(e)||Ft();const{id:r,newScroll:n}=t.payload,a=e.dimensions.droppables[r];if(!a)return e;const c=cg(a,n);return um(e,c,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Ft();const{id:r,isEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Ft(),a.isEnabled===n&&Ft();const c={...a,isEnabled:n};return um(e,c,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;Mc(e)||Ft();const{id:r,isCombineEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Ft(),a.isCombineEnabled===n&&Ft();const c={...a,isCombineEnabled:n};return um(e,c,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;Mc(e)||Ft(),e.isWindowScrollAllowed||Ft();const r=t.payload.newScroll;if(lc(e.viewport.scroll.current,r))return dm(e);const n=Dv(e.viewport,r);return b1(e)?Wv({state:e,viewport:n}):l0({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"&&Ft();const r=MM({state:e,type:t.type});return r?l0({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"&&Ft(),{...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"||Ft(),{phase:"DROP_ANIMATING",completed:r,dropDuration:n,newHomeClientOffset:a,dimensions:e.dimensions}}if(t.type==="DROP_COMPLETE"){const{completed:r}=t.payload;return{phase:"IDLE",completed:r,shouldFlush:!1}}return e};function $n(e,t){return e instanceof Object&&"type"in e&&e.type===t}const XM=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),JM=e=>({type:"LIFT",payload:e}),ej=e=>({type:"INITIAL_PUBLISH",payload:e}),tj=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),rj=()=>({type:"COLLECTION_STARTING",payload:null}),nj=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),sj=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),ij=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Vv=e=>({type:"MOVE",payload:e}),aj=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),oj=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),lj=()=>({type:"MOVE_UP",payload:null}),cj=()=>({type:"MOVE_DOWN",payload:null}),uj=()=>({type:"MOVE_RIGHT",payload:null}),dj=()=>({type:"MOVE_LEFT",payload:null}),gg=()=>({type:"FLUSH",payload:null}),hj=e=>({type:"DROP_ANIMATE",payload:e}),xg=e=>({type:"DROP_COMPLETE",payload:e}),qv=e=>({type:"DROP",payload:e}),fj=e=>({type:"DROP_PENDING",payload:e}),Yv=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var pj=e=>({getState:t,dispatch:r})=>n=>a=>{if(!$n(a,"LIFT")){n(a);return}const{id:c,clientSelection:l,movementMode:d}=a.payload,f=t();f.phase==="DROP_ANIMATING"&&r(xg({completed:f.completed})),t().phase!=="IDLE"&&Ft(),r(gg()),r(XM({draggableId:c,movementMode:d}));const x={draggableId:c,scrollOptions:{shouldPublishImmediately:d==="SNAP"}},{critical:y,dimensions:w,viewport:v}=e.startPublishing(x);r(ej({critical:y,dimensions:w,clientSelection:l,movementMode:d,viewport:v}))},mj=e=>()=>t=>r=>{$n(r,"INITIAL_PUBLISH")&&e.dragging(),$n(r,"DROP_ANIMATE")&&e.dropping(r.payload.completed.result.reason),($n(r,"FLUSH")||$n(r,"DROP_COMPLETE"))&&e.resting(),t(r)};const bg={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},_0={opacity:{drop:0,combining:.7},scale:{drop:.75}},Zv={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},Rc=`${Zv.outOfTheWay}s ${bg.outOfTheWay}`,c0={fluid:`opacity ${Rc}`,snap:`transform ${Rc}, opacity ${Rc}`,drop:e=>{const t=`${e}s ${bg.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${Rc}`,placeholder:`height ${Rc}, width ${Rc}, margin ${Rc}`},T5=e=>lc(e,gi)?void 0:`translate(${e.x}px, ${e.y}px)`,y1={moveTo:T5,drop:(e,t)=>{const r=T5(e);if(r)return t?`${r} scale(${_0.scale.drop})`:r}},{minDropTime:v1,maxDropTime:Kv}=Zv,gj=Kv-v1,S5=1500,xj=.6;var bj=({current:e,destination:t,reason:r})=>{const n=T0(e,t);if(n<=0)return v1;if(n>=S5)return Kv;const a=n/S5,c=v1+gj*a,l=r==="CANCEL"?c*xj:c;return Number(l.toFixed(2))},yj=({impact:e,draggable:t,dimensions:r,viewport:n,afterCritical:a})=>{const{draggables:c,droppables:l}=r,d=Ha(e),f=d?l[d]:null,m=l[t.descriptor.droppableId],x=Hv({impact:e,draggable:t,draggables:c,afterCritical:a,droppable:f||m,viewport:n});return Ua(x,t.client.borderBox.center)},vj=({draggables:e,reason:t,lastImpact:r,home:n,viewport:a,onLiftImpact:c})=>!r.at||t!=="DROP"?{impact:zv({draggables:e,impact:c,destination:n,viewport:a,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:r.at.type==="REORDER"?{impact:r,didDropInsideDroppable:!0}:{impact:{...r,displaced:S0},didDropInsideDroppable:!0};const wj=({getState:e,dispatch:t})=>r=>n=>{if(!$n(n,"DROP")){r(n);return}const a=e(),c=n.payload.reason;if(a.phase==="COLLECTING"){t(fj({reason:c}));return}if(a.phase==="IDLE")return;a.phase==="DROP_PENDING"&&a.isWaiting&&Ft(),a.phase==="DRAGGING"||a.phase==="DROP_PENDING"||Ft();const d=a.critical,f=a.dimensions,m=f.draggables[a.critical.draggable.id],{impact:x,didDropInsideDroppable:y}=vj({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?ug(x):null,v=y?Yf(x):null,S={index:d.draggable.index,droppableId:d.droppable.id},C={draggableId:m.descriptor.id,type:m.descriptor.type,source:S,reason:c,mode:a.movementMode,destination:w,combine:v},I=yj({impact:x,draggable:m,dimensions:f,viewport:a.viewport,afterCritical:a.afterCritical}),R={critical:a.critical,afterCritical:a.afterCritical,result:C,impact:x};if(!(!lc(a.current.client.offset,I)||!!C.combine)){t(xg({completed:R}));return}const z=bj({current:a.current.client.offset,destination:I,reason:c});t(hj({newHomeClientOffset:I,dropDuration:z,completed:R}))};var Xv=()=>({x:window.pageXOffset,y:window.pageYOffset});function Aj(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function Tj({onWindowScroll:e}){function t(){e(Xv())}const r=A0(t),n=Aj(r);let a=oc;function c(){return a!==oc}function l(){c()&&Ft(),a=wo(window,[n])}function d(){c()||Ft(),r.cancel(),a(),a=oc}return{start:l,stop:d,isActive:c}}const Sj=e=>$n(e,"DROP_COMPLETE")||$n(e,"DROP_ANIMATE")||$n(e,"FLUSH"),Cj=e=>{const t=Tj({onWindowScroll:r=>{e.dispatch(aj({newScroll:r}))}});return r=>n=>{!t.isActive()&&$n(n,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&Sj(n)&&t.stop(),r(n)}};var _j=e=>{let t=!1,r=!1;const n=setTimeout(()=>{r=!0}),a=c=>{t||r||(t=!0,e(c),clearTimeout(n))};return a.wasCalled=()=>t,a},kj=()=>{const e=[],t=a=>{const c=e.findIndex(d=>d.timerId===a);c===-1&&Ft();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 Lj=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,Ij=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,Ej=(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},Nd=(e,t)=>{t()},Ah=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function hm(e,t,r,n){if(!e){r(n(t));return}const a=_j(r);e(t,{announce:a}),a.wasCalled()||r(n(t))}var Nj=(e,t)=>{const r=kj();let n=null;const a=(y,w)=>{n&&Ft(),Nd("onBeforeCapture",()=>{const v=e().onBeforeCapture;v&&v({draggableId:y,mode:w})})},c=(y,w)=>{n&&Ft(),Nd("onBeforeDragStart",()=>{const v=e().onBeforeDragStart;v&&v(Ah(y,w))})},l=(y,w)=>{n&&Ft();const v=Ah(y,w);n={mode:w,lastCritical:y,lastLocation:v.source,lastCombine:null},r.add(()=>{Nd("onDragStart",()=>hm(e().onDragStart,v,t,Xh.onDragStart))})},d=(y,w)=>{const v=ug(w),S=Yf(w);n||Ft();const C=!Ej(y,n.lastCritical);C&&(n.lastCritical=y);const I=!Lj(n.lastLocation,v);I&&(n.lastLocation=v);const R=!Ij(n.lastCombine,S);if(R&&(n.lastCombine=S),!C&&!I&&!R)return;const B={...Ah(y,n.mode),combine:S,destination:v};r.add(()=>{Nd("onDragUpdate",()=>hm(e().onDragUpdate,B,t,Xh.onDragUpdate))})},f=()=>{n||Ft(),r.flush()},m=y=>{n||Ft(),n=null,Nd("onDragEnd",()=>hm(e().onDragEnd,y,t,Xh.onDragEnd))};return{beforeCapture:a,beforeStart:c,start:l,update:d,flush:f,drop:m,abort:()=>{if(!n)return;const y={...Ah(n.lastCritical,n.mode),combine:null,destination:null,reason:"CANCEL"};m(y)}}},Rj=(e,t)=>{const r=Nj(e,t);return n=>a=>c=>{if($n(c,"BEFORE_INITIAL_CAPTURE")){r.beforeCapture(c.payload.draggableId,c.payload.movementMode);return}if($n(c,"INITIAL_PUBLISH")){const d=c.payload.critical;r.beforeStart(d,c.payload.movementMode),a(c),r.start(d,c.payload.movementMode);return}if($n(c,"DROP_COMPLETE")){const d=c.payload.completed.result;r.flush(),a(c),r.drop(d);return}if(a(c),$n(c,"FLUSH")){r.abort();return}const l=n.getState();l.phase==="DRAGGING"&&r.update(l.critical,l.impact)}};const Mj=e=>t=>r=>{if(!$n(r,"DROP_ANIMATION_FINISHED")){t(r);return}const n=e.getState();n.phase!=="DROP_ANIMATING"&&Ft(),e.dispatch(xg({completed:n.completed}))},jj=e=>{let t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return a=>c=>{if(($n(c,"FLUSH")||$n(c,"DROP_COMPLETE")||$n(c,"DROP_ANIMATION_FINISHED"))&&n(),a(c),!$n(c,"DROP_ANIMATE"))return;const l={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(Yv())}};r=requestAnimationFrame(()=>{r=null,t=wo(window,[l])})}};var Dj=e=>()=>t=>r=>{($n(r,"DROP_COMPLETE")||$n(r,"FLUSH")||$n(r,"DROP_ANIMATE"))&&e.stopPublishing(),t(r)},Bj=e=>{let t=!1;return()=>r=>n=>{if($n(n,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if($n(n,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if($n(n,"DROP_COMPLETE")){t=!1;const a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const Qj=e=>$n(e,"DROP_COMPLETE")||$n(e,"DROP_ANIMATE")||$n(e,"FLUSH");var Pj=e=>t=>r=>n=>{if(Qj(n)){e.stop(),r(n);return}if($n(n,"INITIAL_PUBLISH")){r(n);const a=t.getState();a.phase!=="DRAGGING"&&Ft(),e.start(a);return}r(n),e.scroll(t.getState())};const Oj=e=>t=>r=>{if(t(r),!$n(r,"PUBLISH_WHILE_DRAGGING"))return;const n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch(qv({reason:n.reason})))},Fj=pv;var $j=({dimensionMarshal:e,focusMarshal:t,styleMarshal:r,getResponders:n,announce:a,autoScroller:c})=>fv(KM,Fj(PN(mj(r),Dj(e),pj(e),wj,Mj,jj,Oj,Pj(c),Cj,Bj(t),Rj(n,a))));const fm=()=>({additions:{},removals:{},modified:{}});function Uj({registry:e,callbacks:t}){let r=fm(),n=null;const a=()=>{n||(t.collectionStarting(),n=requestAnimationFrame(()=>{n=null;const{additions:f,removals:m,modified:x}=r,y=Object.keys(f).map(S=>e.draggable.getById(S).getDimension(gi)).sort((S,C)=>S.descriptor.index-C.descriptor.index),w=Object.keys(x).map(S=>{const I=e.droppable.getById(S).callbacks.getScrollWhileDragging();return{droppableId:S,scroll:I}}),v={additions:y,removals:Object.keys(m),modified:w};r=fm(),t.publish(v)}))};return{add:f=>{const m=f.descriptor.id;r.additions[m]=f,r.modified[f.descriptor.droppableId]=!0,r.removals[m]&&delete r.removals[m],a()},remove:f=>{const m=f.descriptor;r.removals[m.id]=!0,r.modified[m.droppableId]=!0,r.additions[m.id]&&delete r.additions[m.id],a()},stop:()=>{n&&(cancelAnimationFrame(n),n=null,r=fm())}}}var Jv=({scrollHeight:e,scrollWidth:t,height:r,width:n})=>{const a=Ua({x:t,y:e},{x:n,y:r});return{x:Math.max(0,a.x),y:Math.max(0,a.y)}},e6=()=>{const e=document.documentElement;return e||Ft(),e},t6=()=>{const e=e6();return Jv({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},zj=()=>{const e=Xv(),t=t6(),r=e.y,n=e.x,a=e6(),c=a.clientWidth,l=a.clientHeight,d=n+c,f=r+l;return{frame:Fo({top:r,left:n,right:d,bottom:f}),scroll:{initial:e,current:e,max:t,diff:{value:gi,displacement:gi}}}},Hj=({critical:e,scrollOptions:t,registry:r})=>{const n=zj(),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:Iv(d),droppables:Lv(l)},critical:e,viewport:n}};function C5(e,t,r){return!(r.descriptor.id===t.id||r.descriptor.type!==t.type||e.droppable.getById(r.descriptor.droppableId).descriptor.mode!=="virtual")}var Wj=(e,t)=>{let r=null;const n=Uj({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=(w,v)=>{e.droppable.exists(w)||Ft(),r&&t.updateDroppableIsEnabled({id:w,isEnabled:v})},c=(w,v)=>{r&&(e.droppable.exists(w)||Ft(),t.updateDroppableIsCombineEnabled({id:w,isCombineEnabled:v}))},l=(w,v)=>{r&&(e.droppable.exists(w)||Ft(),t.updateDroppableScroll({id:w,newScroll:v}))},d=(w,v)=>{r&&e.droppable.getById(w).callbacks.scroll(v)},f=()=>{if(!r)return;n.stop();const w=r.critical.droppable;e.droppable.getAllByType(w.type).forEach(v=>v.callbacks.dragStopped()),r.unsubscribe(),r=null},m=w=>{r||Ft();const v=r.critical.draggable;w.type==="ADDITION"&&C5(e,v,w.value)&&n.add(w.value),w.type==="REMOVAL"&&C5(e,v,w.value)&&n.remove(w.value)};return{updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:c,scrollDroppable:d,updateDroppableScroll:l,startPublishing:w=>{r&&Ft();const v=e.draggable.getById(w.draggableId),S=e.droppable.getById(v.descriptor.droppableId),C={draggable:v.descriptor,droppable:S.descriptor},I=e.subscribe(m);return r={critical:C,unsubscribe:I},Hj({critical:C,registry:e,scrollOptions:w.scrollOptions})},stopPublishing:f}},r6=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",Gj=e=>{window.scrollBy(e.x,e.y)};const Vj=mi(e=>qf(e).filter(t=>!(!t.isEnabled||!t.frame))),qj=(e,t)=>Vj(t).find(n=>(n.frame||Ft(),Ov(n.frame.pageMarginBox)(e)))||null;var Yj=({center:e,destination:t,droppables:r})=>{if(t){const a=r[t];return a.frame?a:null}return qj(e,r)};const k0={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var Zj=(e,t,r=()=>k0)=>{const n=r(),a=e[t.size]*n.startFromPercentage,c=e[t.size]*n.maxScrollAtPercentage;return{startScrollingFrom:a,maxScrollValueAt:c}},n6=({startOfRange:e,endOfRange:t,current:r})=>{const n=t-e;return n===0?0:(r-e)/n},yg=1,Kj=(e,t,r=()=>k0)=>{const n=r();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return n.maxPixelScroll;if(e===t.startScrollingFrom)return yg;const c=1-n6({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),l=n.maxPixelScroll*n.ease(c);return Math.ceil(l)},Xj=(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 yg;const x=n6({startOfRange:a,endOfRange:d,current:m}),y=e*n.ease(x);return Math.ceil(y)},_5=({distanceToEdge:e,thresholds:t,dragStartTime:r,shouldUseTimeDampening:n,getAutoScrollerOptions:a})=>{const c=Kj(e,t,a);return c===0?0:n?Math.max(Xj(c,r,a),yg):c},k5=({container:e,distanceToEdges:t,dragStartTime:r,axis:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=Zj(e,n,c);return t[n.end]<t[n.start]?_5({distanceToEdge:t[n.end],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c}):-1*_5({distanceToEdge:t[n.start],thresholds:l,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c})},Jj=({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 eD=kv(e=>e===0?0:e);var s6=({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=k5({container:t,distanceToEdges:l,dragStartTime:e,axis:dg,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),f=k5({container:t,distanceToEdges:l,dragStartTime:e,axis:Rv,shouldUseTimeDampening:a,getAutoScrollerOptions:c}),m=eD({x:f,y:d});if(lc(m,gi))return null;const x=Jj({container:t,subject:r,proposedScroll:m});return x?lc(x,gi)?null:x:null};const tD=kv(e=>e===0?0:e>0?1:-1),vg=(()=>{const e=(t,r)=>t<0?t:t>r?t-r:0;return({current:t,max:r,change:n})=>{const a=Ni(t,n),c={x:e(a.x,r.x),y:e(a.y,r.y)};return lc(c,gi)?null:c}})(),i6=({max:e,current:t,change:r})=>{const n={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},a=tD(r),c=vg({max:n,current:t,change:a});return!c||a.x!==0&&c.x===0||a.y!==0&&c.y===0},wg=(e,t)=>i6({current:e.scroll.current,max:e.scroll.max,change:t}),rD=(e,t)=>{if(!wg(e,t))return null;const r=e.scroll.max,n=e.scroll.current;return vg({current:n,max:r,change:t})},Ag=(e,t)=>{const r=e.frame;return r?i6({current:r.scroll.current,max:r.scroll.max,change:t}):!1},nD=(e,t)=>{const r=e.frame;return!r||!Ag(e,t)?null:vg({current:r.scroll.current,max:r.scroll.max,change:t})};var sD=({viewport:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=s6({dragStartTime:n,container:e.frame,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return l&&wg(e,l)?l:null},iD=({droppable:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:c})=>{const l=e.frame;if(!l)return null;const d=s6({dragStartTime:n,container:l.pageMarginBox,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:c});return d&&Ag(e,d)?d:null},L5=({state:e,dragStartTime:t,shouldUseTimeDampening:r,scrollWindow:n,scrollDroppable:a,getAutoScrollerOptions:c})=>{const l=e.current.page.borderBoxCenter,f=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const y=e.viewport,w=sD({dragStartTime:t,viewport:y,subject:f,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});if(w){n(w);return}}const m=Yj({center:l,destination:Ha(e.impact),droppables:e.dimensions.droppables});if(!m)return;const x=iD({dragStartTime:t,droppable:m,subject:f,center:l,shouldUseTimeDampening:r,getAutoScrollerOptions:c});x&&a(m.descriptor.id,x)},aD=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r=()=>k0})=>{const n=A0(e),a=A0(t);let c=null;const l=m=>{c||Ft();const{shouldUseTimeDampening:x,dragStartTime:y}=c;L5({state:m,scrollWindow:n,scrollDroppable:a,dragStartTime:y,shouldUseTimeDampening:x,getAutoScrollerOptions:r})};return{start:m=>{c&&Ft();const x=Date.now();let y=!1;const w=()=>{y=!0};L5({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}},oD=({move:e,scrollDroppable:t,scrollWindow:r})=>{const n=(d,f)=>{const m=Ni(d.current.client.selection,f);e({client:m})},a=(d,f)=>{if(!Ag(d,f))return f;const m=nD(d,f);if(!m)return t(d.descriptor.id,f),null;const x=Ua(f,m);return t(d.descriptor.id,x),Ua(f,x)},c=(d,f,m)=>{if(!d||!wg(f,m))return m;const x=rD(f,m);if(!x)return r(m),null;const y=Ua(m,x);return r(y),Ua(m,y)};return d=>{const f=d.scrollJumpRequest;if(!f)return;const m=Ha(d.impact);m||Ft();const x=a(d.dimensions.droppables[m],f);if(!x)return;const y=d.viewport,w=c(d.isWindowScrollAllowed,y,x);w&&n(d,w)}},lD=({scrollDroppable:e,scrollWindow:t,move:r,getAutoScrollerOptions:n})=>{const a=aD({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n}),c=oD({move:r,scrollWindow:t,scrollDroppable:e});return{scroll:f=>{if(!(n().disabled||f.phase!=="DRAGGING")){if(f.movementMode==="FLUID"){a.scroll(f);return}f.scrollJumpRequest&&c(f)}},start:a.start,stop:a.stop}};const Wu="data-rfd",Gu=(()=>{const e=`${Wu}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),w1=(()=>{const e=`${Wu}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),cD=(()=>{const e=`${Wu}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),I5={contextId:`${Wu}-scroll-container-context-id`},uD=e=>t=>`[${t}="${e}"]`,Rd=(e,t)=>e.map(r=>{const n=r.styles[t];return n?`${r.selector} { ${n} }`:""}).join(" "),dD="pointer-events: none;";var hD=e=>{const t=uD(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:dD,dropAnimating:d}}})(),n=(()=>{const d=`
|
|
125
|
-
transition: ${c0.outOfTheWay};
|
|
126
|
-
`;return{selector:t(w1.contextId),styles:{dragging:d,dropAnimating:d,userCancel:d}}})(),a={selector:t(cD.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:Rd(l,"always"),resting:Rd(l,"resting"),dragging:Rd(l,"dragging"),dropAnimating:Rd(l,"dropAnimating"),userCancel:Rd(l,"userCancel")}};const Wa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,pm=()=>{const e=document.querySelector("head");return e||Ft(),e},E5=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function fD(e,t){const r=Sn(()=>hD(e),[e]),n=b.useRef(null),a=b.useRef(null),c=wr(mi(y=>{const w=a.current;w||Ft(),w.textContent=y}),[]),l=wr(y=>{const w=n.current;w||Ft(),w.textContent=y},[]);Wa(()=>{!n.current&&!a.current||Ft();const y=E5(t),w=E5(t);return n.current=y,a.current=w,y.setAttribute(`${Wu}-always`,e),w.setAttribute(`${Wu}-dynamic`,e),pm().appendChild(y),pm().appendChild(w),l(r.always),c(r.resting),()=>{const v=S=>{const C=S.current;C||Ft(),pm().removeChild(C),S.current=null};v(n),v(a)}},[t,l,c,r.always,r.resting,e]);const d=wr(()=>c(r.dragging),[c,r.dragging]),f=wr(y=>{if(y==="DROP"){c(r.dropAnimating);return}c(r.userCancel)},[c,r.dropAnimating,r.userCancel]),m=wr(()=>{a.current&&c(r.resting)},[c,r.resting]);return Sn(()=>({dragging:d,dropping:f,resting:m}),[d,f,m])}function a6(e,t){return Array.from(e.querySelectorAll(t))}var o6=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Xf(e){return e instanceof o6(e).HTMLElement}function pD(e,t){const r=`[${Gu.contextId}="${e}"]`,n=a6(document,r);if(!n.length)return null;const a=n.find(c=>c.getAttribute(Gu.draggableId)===t);return!a||!Xf(a)?null:a}function mD(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),c=wr(function(w,v){const S={id:w,focus:v};return t.current[w]=S,function(){const I=t.current;I[w]!==S&&delete I[w]}},[]),l=wr(function(w){const v=pD(e,w);v&&v!==document.activeElement&&v.focus()},[e]),d=wr(function(w,v){r.current===w&&(r.current=v)},[]),f=wr(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const w=r.current;w&&l(w)}))},[l]),m=wr(function(w){r.current=null;const v=document.activeElement;v&&v.getAttribute(Gu.draggableId)===w&&(r.current=w)},[]);return Wa(()=>(a.current=!0,function(){a.current=!1;const w=n.current;w&&cancelAnimationFrame(w)}),[]),Sn(()=>({register:c,tryRecordFocus:m,tryRestoreFocusRecorded:f,tryShiftRecord:d}),[c,m,f,d])}function gD(){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||Ft(),w}const l={register:y=>{e.draggables[y.descriptor.id]=y,n({type:"ADDITION",value:y})},update:(y,w)=>{const v=e.draggables[w.descriptor.id];v&&v.uniqueId===y.uniqueId&&(delete e.draggables[w.descriptor.id],e.draggables[y.descriptor.id]=y)},unregister:y=>{const w=y.descriptor.id,v=a(w);v&&y.uniqueId===v.uniqueId&&(delete e.draggables[w],e.droppables[y.descriptor.droppableId]&&n({type:"REMOVAL",value:y}))},getById:c,findById:a,exists:y=>!!a(y),getAllByType:y=>Object.values(e.draggables).filter(w=>w.descriptor.type===y)};function d(y){return e.droppables[y]||null}function f(y){const w=d(y);return w||Ft(),w}const m={register:y=>{e.droppables[y.descriptor.id]=y},unregister:y=>{const w=d(y.descriptor.id);w&&y.uniqueId===w.uniqueId&&delete e.droppables[y.descriptor.id]},getById:f,findById:d,exists:y=>!!d(y),getAllByType:y=>Object.values(e.droppables).filter(w=>w.descriptor.type===y)};function x(){e.draggables={},e.droppables={},t.length=0}return{draggable:l,droppable:m,subscribe:r,clean:x}}function xD(){const e=Sn(gD,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var Tg=L.createContext(null),Ef=()=>{const e=document.body;return e||Ft(),e};const bD={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},yD=e=>`rfd-announcement-${e}`;function vD(e){const t=Sn(()=>yD(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"),_f(c.style,bD),Ef().appendChild(c),function(){setTimeout(function(){const f=Ef();f.contains(c)&&f.removeChild(c),c===r.current&&(r.current=null)})}},[t]),wr(a=>{const c=r.current;if(c){c.textContent=a;return}},[])}const wD={separator:"::"};function Sg(e,t=wD){const r=L.useId();return Sn(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function AD({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function TD({contextId:e,text:t}){const r=Sg("hidden-text",{separator:"-"}),n=Sn(()=>AD({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",Ef().appendChild(c),function(){const d=Ef();d.contains(c)&&d.removeChild(c)}},[n,t]),n}var Jf=L.createContext(null);function l6(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function SD(){let e=null;function t(){return!!e}function r(l){return l===e}function n(l){e&&Ft();const d={abandon:l};return e=d,d}function a(){e||Ft(),e=null}function c(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:c}}function L0(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const CD=9,_D=13,Cg=27,c6=32,kD=33,LD=34,ID=35,ED=36,ND=37,RD=38,MD=39,jD=40,DD={[_D]:!0,[CD]:!0};var u6=e=>{DD[e.keyCode]&&e.preventDefault()};const ep=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),d6=0,N5=5;function BD(e,t){return Math.abs(t.x-e.x)>=N5||Math.abs(t.y-e.y)>=N5}const R5={type:"IDLE"};function QD({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:c,clientX:l,clientY:d}=a;if(c!==d6)return;const f={x:l,y:d},m=r();if(m.type==="DRAGGING"){a.preventDefault(),m.actions.move(f);return}m.type!=="PENDING"&&Ft();const x=m.point;if(!BD(x,f))return;a.preventDefault();const y=m.actions.fluidLift(f);n({type:"DRAGGING",actions:y})}},{eventName:"mouseup",fn:a=>{const c=r();if(c.type!=="DRAGGING"){e();return}a.preventDefault(),c.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:a=>{r().type==="DRAGGING"&&a.preventDefault(),e()}},{eventName:"keydown",fn:a=>{if(r().type==="PENDING"){e();return}if(a.keyCode===Cg){a.preventDefault(),e();return}u6(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"&&Ft(),c.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:ep,fn:e}]}function PD(e){const t=b.useRef(R5),r=b.useRef(oc),n=Sn(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==d6||y.ctrlKey||y.metaKey||y.shiftKey||y.altKey)return;const w=e.findClosestDraggableId(y);if(!w)return;const v=e.tryGetLock(w,l,{sourceEvent:y});if(!v)return;y.preventDefault();const S={x:y.clientX,y:y.clientY};r.current(),m(v,S)}}),[e]),a=Sn(()=>({eventName:"webkitmouseforcewillbegin",fn:x=>{if(x.defaultPrevented)return;const y=e.findClosestDraggableId(x);if(!y)return;const w=e.findOptionsForDraggable(y);w&&(w.shouldRespectForcePress||e.canGetLock(y)&&x.preventDefault())}}),[e]),c=wr(function(){const y={passive:!1,capture:!0};r.current=wo(window,[a,n],y)},[a,n]),l=wr(()=>{t.current.type!=="IDLE"&&(t.current=R5,r.current(),c())},[c]),d=wr(()=>{const x=t.current;l(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[l]),f=wr(function(){const y={capture:!0,passive:!1},w=QD({cancel:d,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=wo(window,w,y)},[d,l]),m=wr(function(y,w){t.current.type!=="IDLE"&&Ft(),t.current={type:"PENDING",point:w,actions:y},f()},[f]);Wa(function(){return c(),function(){r.current()}},[c])}function OD(){}const FD={[LD]:!0,[kD]:!0,[ED]:!0,[ID]:!0};function $D(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===Cg){a.preventDefault(),r();return}if(a.keyCode===c6){a.preventDefault(),n();return}if(a.keyCode===jD){a.preventDefault(),e.moveDown();return}if(a.keyCode===RD){a.preventDefault(),e.moveUp();return}if(a.keyCode===MD){a.preventDefault(),e.moveRight();return}if(a.keyCode===ND){a.preventDefault(),e.moveLeft();return}if(FD[a.keyCode]){a.preventDefault();return}u6(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:ep,fn:r}]}function UD(e){const t=b.useRef(OD),r=Sn(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==c6)return;const l=e.findClosestDraggableId(c);if(!l)return;const d=e.tryGetLock(l,x,{sourceEvent:c});if(!d)return;c.preventDefault();let f=!0;const m=d.snapLift();t.current();function x(){f||Ft(),f=!1,t.current(),n()}t.current=wo(window,$D(m,x),{capture:!0,passive:!1})}}),[e]),n=wr(function(){const c={passive:!1,capture:!0};t.current=wo(window,[r],c)},[r]);Wa(function(){return n(),function(){t.current()}},[n])}const mm={type:"IDLE"},zD=120,HD=.15;function WD({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===Cg&&r.preventDefault(),e()}},{eventName:ep,fn:e}]}function GD({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"&&Ft();const c=n.touches[0];if(!c||!(c.force>=HD))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:ep,fn:e}]}function VD(e){const t=b.useRef(mm),r=b.useRef(oc),n=wr(function(){return t.current},[]),a=wr(function(v){t.current=v},[]),c=Sn(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const S=e.findClosestDraggableId(v);if(!S)return;const C=e.tryGetLock(S,d,{sourceEvent:v});if(!C)return;const I=v.touches[0],{clientX:R,clientY:B}=I,z={x:R,y:B};r.current(),y(C,z)}}),[e]),l=wr(function(){const v={capture:!0,passive:!1};r.current=wo(window,[c],v)},[c]),d=wr(()=>{const w=t.current;w.type!=="IDLE"&&(w.type==="PENDING"&&clearTimeout(w.longPressTimerId),a(mm),r.current(),l())},[l,a]),f=wr(()=>{const w=t.current;d(),w.type==="DRAGGING"&&w.actions.cancel({shouldBlockNextClick:!0}),w.type==="PENDING"&&w.actions.abort()},[d]),m=wr(function(){const v={capture:!0,passive:!1},S={cancel:f,completed:d,getPhase:n},C=wo(window,GD(S),v),I=wo(window,WD(S),v);r.current=function(){C(),I()}},[f,n,d]),x=wr(function(){const v=n();v.type!=="PENDING"&&Ft();const S=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:S,hasMoved:!1})},[n,a]),y=wr(function(v,S){n().type!=="IDLE"&&Ft();const C=setTimeout(x,zD);a({type:"PENDING",point:S,actions:v,longPressTimerId:C}),m()},[m,n,a,x]);Wa(function(){return l(),function(){r.current();const S=n();S.type==="PENDING"&&(clearTimeout(S.longPressTimerId),a(mm))}},[n,l,a]),Wa(function(){return wo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const qD=["input","button","textarea","select","option","optgroup","video","audio"];function h6(e,t){if(t==null)return!1;if(qD.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:h6(e,t.parentElement)}function YD(e,t){const r=t.target;return Xf(r)?h6(e,r):!1}var ZD=e=>Fo(e.getBoundingClientRect()).center;function KD(e){return e instanceof o6(e).Element}const XD=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function f6(e,t){return e==null?null:e[XD](t)?e:f6(e.parentElement,t)}function JD(e,t){return e.closest?e.closest(t):f6(e,t)}function eB(e){return`[${Gu.contextId}="${e}"]`}function tB(e,t){const r=t.target;if(!KD(r))return null;const n=eB(e),a=JD(r,n);return!a||!Xf(a)?null:a}function rB(e,t){const r=tB(e,t);return r?r.getAttribute(Gu.draggableId):null}function nB(e,t){const r=`[${w1.contextId}="${e}"]`,a=a6(document,r).find(c=>c.getAttribute(w1.id)===t);return!a||!Xf(a)?null:a}function sB(e){e.preventDefault()}function Th({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function p6({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!r6(t.getState(),n))}function iB({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:c,sourceEvent:l}){if(!p6({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const f=n.draggable.getById(a),m=nB(t,f.descriptor.id);if(!m||l&&!f.options.canDragInteractiveElements&&YD(m,l))return null;const x=e.claim(c||oc);let y="PRE_DRAG";function w(){return f.options.shouldRespectForcePress}function v(){return e.isActive(x)}function S($,V){Th({expected:$,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(V())}const C=S.bind(null,"DRAGGING");function I($){function V(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(V(),Ft()),r.dispatch(JM($.liftActionArgs)),y="DRAGGING";function Y(le,be={shouldBlockNextClick:!1}){if($.cleanup(),be.shouldBlockNextClick){const pe=wo(window,[{eventName:"click",fn:sB,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(pe)}V(),r.dispatch(qv({reason:le}))}return{isActive:()=>Th({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,drop:le=>Y("DROP",le),cancel:le=>Y("CANCEL",le),...$.actions}}function R($){const V=A0(le=>{C(()=>Vv({client:le}))});return{...I({liftActionArgs:{id:a,clientSelection:$,movementMode:"FLUID"},cleanup:()=>V.cancel(),actions:{move:V}}),move:V}}function B(){const $={moveUp:()=>C(lj),moveRight:()=>C(uj),moveDown:()=>C(cj),moveLeft:()=>C(dj)};return I({liftActionArgs:{id:a,clientSelection:ZD(m),movementMode:"SNAP"},cleanup:oc,actions:$})}function z(){Th({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>Th({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,fluidLift:R,snapLift:B,abort:z}}const aB=[PD,UD,VD];function oB({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const c=[...a?aB:[],...n||[]],l=b.useState(()=>SD())[0],d=wr(function(I,R){L0(I)&&!L0(R)&&l.tryAbandon()},[l]);Wa(function(){let I=t.getState();return t.subscribe(()=>{const B=t.getState();d(I,B),I=B})},[l,t,d]),Wa(()=>l.tryAbandon,[l.tryAbandon]);const f=wr(C=>p6({lockAPI:l,registry:r,store:t,draggableId:C}),[l,r,t]),m=wr((C,I,R)=>iB({lockAPI:l,registry:r,contextId:e,store:t,draggableId:C,forceSensorStop:I||null,sourceEvent:R&&R.sourceEvent?R.sourceEvent:null}),[e,l,r,t]),x=wr(C=>rB(e,C),[e]),y=wr(C=>{const I=r.draggable.findById(C);return I?I.options:null},[r.draggable]),w=wr(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(gg()))},[l,t]),v=wr(()=>l.isClaimed(),[l]),S=Sn(()=>({canGetLock:f,tryGetLock:m,findClosestDraggableId:x,findOptionsForDraggable:y,tryReleaseLock:w,isLockClaimed:v}),[f,m,x,y,w,v]);for(let C=0;C<c.length;C++)c[C](S)}const lB=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};Js.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),cB=e=>({...k0,...e.autoScrollerOptions,durationDampening:{...k0.durationDampening,...e.autoScrollerOptions}});function Md(e){return e.current||Ft(),e.current}function uB(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:c}=e,l=b.useRef(null),d=l6(e),f=wr(()=>lB(d.current),[d]),m=wr(()=>cB(d.current),[d]),x=vD(t),y=TD({contextId:t,text:c}),w=fD(t,a),v=wr(pe=>{Md(l).dispatch(pe)},[]),S=Sn(()=>s5({publishWhileDragging:tj,updateDroppableScroll:nj,updateDroppableIsEnabled:sj,updateDroppableIsCombineEnabled:ij,collectionStarting:rj},v),[v]),C=xD(),I=Sn(()=>Wj(C,S),[C,S]),R=Sn(()=>lD({scrollWindow:Gj,scrollDroppable:I.scrollDroppable,getAutoScrollerOptions:m,...s5({move:Vv},v)}),[I.scrollDroppable,v,m]),B=mD(t),z=Sn(()=>$j({announce:x,autoScroller:R,dimensionMarshal:I,focusMarshal:B,getResponders:f,styleMarshal:w}),[x,R,I,B,f,w]);l.current=z;const O=wr(()=>{const pe=Md(l);pe.getState().phase!=="IDLE"&&pe.dispatch(gg())},[]),$=wr(()=>{const pe=Md(l).getState();return pe.phase==="DROP_ANIMATING"?!0:pe.phase==="IDLE"?!1:pe.isDragging},[]),V=Sn(()=>({isDragging:$,tryAbort:O}),[$,O]);r(V);const Y=wr(pe=>r6(Md(l).getState(),pe),[]),le=wr(()=>Mc(Md(l).getState()),[]),be=Sn(()=>({marshal:I,focus:B,contextId:t,canLift:Y,isMovementAllowed:le,dragHandleUsageInstructionsId:y,registry:C}),[t,I,y,B,Y,le,C]);return oB({contextId:t,store:z,registry:C,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>O,[O]),L.createElement(Jf.Provider,{value:be},L.createElement(DR,{context:Tg,store:z},e.children))}function dB(){return L.useId()}function u0(e){const t=dB(),r=e.dragHandleUsageInstructions||Xh.dragHandleUsageInstructions;return L.createElement(UR,null,n=>L.createElement(uB,{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 M5={dragging:5e3,dropAnimating:4500},hB=(e,t)=>t?c0.drop(t.duration):e?c0.snap:c0.fluid,fB=(e,t)=>{if(e)return t?_0.opacity.drop:_0.opacity.combining},pB=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function mB(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:c}=e,l=!!a,d=pB(e),f=!!c,m=f?y1.drop(n,l):y1.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:hB(d,c),transform:m,opacity:fB(l,f),zIndex:f?M5.dropAnimating:M5.dragging,pointerEvents:"none"}}function gB(e){return{transform:y1.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function xB(e){return e.type==="DRAGGING"?mB(e):gB(e)}function bB(e,t,r=gi){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),c=wv(a,n),l=Cf(c,r),d={client:c,tagName:t.tagName.toLowerCase(),display:n.display},f={x:c.marginBox.width,y:c.marginBox.height};return{descriptor:e,placeholder:d,displaceBy:f,client:c,page:l}}function yB(e){const t=Sg("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}=e,f=Sn(()=>({canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:d}),[c,d,l]),m=wr(v=>{const S=a();return S||Ft(),bB(r,S,v)},[r,a]),x=Sn(()=>({uniqueId:t,descriptor:r,options:f,getDimension:m}),[r,m,f,t]),y=b.useRef(x),w=b.useRef(!0);Wa(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),Wa(()=>{if(w.current){w.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var _g=L.createContext(null);function Nf(e){const t=b.useContext(e);return t||Ft(),t}function vB(e){e.preventDefault()}const wB=e=>{const t=b.useRef(null),r=wr((V=null)=>{t.current=V},[]),n=wr(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:c,registry:l}=Nf(Jf),{type:d,droppableId:f}=Nf(_g),m=Sn(()=>({id:e.draggableId,index:e.index,type:d,droppableId:f}),[e.draggableId,e.index,d,f]),{children:x,draggableId:y,isEnabled:w,shouldRespectForcePress:v,canDragInteractiveElements:S,isClone:C,mapped:I,dropAnimationFinished:R}=e;if(!C){const V=Sn(()=>({descriptor:m,registry:l,getDraggableRef:n,canDragInteractiveElements:S,shouldRespectForcePress:v,isEnabled:w}),[m,l,n,S,v,w]);yB(V)}const B=Sn(()=>w?{tabIndex:0,role:"button","aria-describedby":c,"data-rfd-drag-handle-draggable-id":y,"data-rfd-drag-handle-context-id":a,draggable:!1,onDragStart:vB}:null,[a,c,y,w]),z=wr(V=>{I.type==="DRAGGING"&&I.dropping&&V.propertyName==="transform"&&Js.flushSync(R)},[R,I]),O=Sn(()=>{const V=xB(I),Y=I.type==="DRAGGING"&&I.dropping?z:void 0;return{innerRef:r,draggableProps:{"data-rfd-draggable-context-id":a,"data-rfd-draggable-id":y,style:V,onTransitionEnd:Y},dragHandleProps:B}},[a,B,y,I,z,r]),$=Sn(()=>({draggableId:m.id,type:m.type,source:{index:m.index,droppableId:m.droppableId}}),[m.droppableId,m.id,m.index,m.type]);return L.createElement(L.Fragment,null,x(O,I.snapshot,$))};var m6=(e,t)=>e===t,g6=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const AB=e=>e.combine?e.combine.draggableId:null,TB=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function SB(){const e=mi((a,c)=>({x:a,y:c})),t=mi((a,c,l=null,d=null,f=null)=>({isDragging:!0,isClone:c,isDropAnimating:!!f,dropAnimation:f,mode:a,draggingOver:l,combineWith:d,combineTargetFor:null})),r=mi((a,c,l,d,f=null,m=null,x=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:f,combineWith:m,mode:c,offset:a,dimension:l,forceShouldAnimate:x,snapshot:t(c,d,f,m,null)}}));return(a,c)=>{if(L0(a)){if(a.critical.draggable.id!==c.draggableId)return null;const l=a.current.client.offset,d=a.dimensions.draggables[c.draggableId],f=Ha(a.impact),m=TB(a.impact),x=a.forceShouldAnimate;return r(e(l.x,l.y),a.movementMode,d,c.isClone,f,m,x)}if(a.phase==="DROP_ANIMATING"){const l=a.completed;if(l.result.draggableId!==c.draggableId)return null;const d=c.isClone,f=a.dimensions.draggables[c.draggableId],m=l.result,x=m.mode,y=g6(m),w=AB(m),S={duration:a.dropDuration,curve:bg.drop,moveTo:a.newHomeClientOffset,opacity:w?_0.opacity.drop:null,scale:w?_0.scale.drop:null};return{mapped:{type:"DRAGGING",offset:a.newHomeClientOffset,dimension:f,dropping:S,draggingOver:y,combineWith:w,mode:x,forceShouldAnimate:null,snapshot:t(x,d,y,w,S)}}}return null}}function x6(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const CB={mapped:{type:"SECONDARY",offset:gi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:x6(null)}};function _B(){const e=mi((l,d)=>({x:l,y:d})),t=mi(x6),r=mi((l,d=null,f)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:d,shouldAnimateDisplacement:f,snapshot:t(d)}})),n=l=>l?r(gi,l,!0):null,a=(l,d,f,m)=>{const x=f.displaced.visible[l],y=!!(m.inVirtualList&&m.effected[l]),w=Yf(f),v=w&&w.draggableId===l?d:null;if(!x){if(!y)return n(v);if(f.displaced.invisible[l])return null;const I=Ju(m.displacedBy.point),R=e(I.x,I.y);return r(R,v,!0)}if(y)return n(v);const S=f.displacedBy.point,C=e(S.x,S.y);return r(C,v,x.shouldAnimate)};return(l,d)=>{if(L0(l))return l.critical.draggable.id===d.draggableId?null:a(d.draggableId,l.critical.draggable.id,l.impact,l.afterCritical);if(l.phase==="DROP_ANIMATING"){const f=l.completed;return f.result.draggableId===d.draggableId?null:a(d.draggableId,f.result.draggableId,f.impact,f.afterCritical)}return null}}const kB=()=>{const e=SB(),t=_B();return(n,a)=>e(n,a)||t(n,a)||CB},LB={dropAnimationFinished:Yv},IB=vv(kB,LB,null,{context:Tg,areStatePropsEqual:m6})(wB);function b6(e){return Nf(_g).isUsingCloneFor===e.draggableId&&!e.isClone?null:L.createElement(IB,e)}function kl(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return L.createElement(b6,_f({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const y6=e=>t=>e===t,EB=y6("scroll"),NB=y6("auto"),j5=(e,t)=>t(e.overflowX)||t(e.overflowY),RB=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return j5(r,EB)||j5(r,NB)},MB=()=>!1,v6=e=>e==null?null:e===document.body?MB()?e:null:e===document.documentElement?null:RB(e)?e:v6(e.parentElement);var A1=e=>({x:e.scrollLeft,y:e.scrollTop});const w6=e=>e?window.getComputedStyle(e).position==="fixed"?!0:w6(e.parentElement):!1;var jB=e=>{const t=v6(e),r=w6(e);return{closestScrollable:t,isFixedOnPage:r}},DB=({descriptor:e,isEnabled:t,isCombineEnabled:r,isFixedOnPage:n,direction:a,client:c,page:l,closest:d})=>{const f=(()=>{if(!d)return null;const{scrollSize:w,client:v}=d,S=Jv({scrollHeight:w.scrollHeight,scrollWidth:w.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:d.page.marginBox,frameClient:v,scrollSize:w,shouldClipSubject:d.shouldClipSubject,scroll:{initial:d.scroll,current:d.scroll,max:S,diff:{value:gi,displacement:gi}}}})(),m=a==="vertical"?dg:Rv,x=Hu({page:l,withPlaceholder:null,axis:m,frame:f});return{descriptor:e,isCombineEnabled:r,isFixedOnPage:n,axis:m,isEnabled:t,client:c,page:l,frame:f,subject:x}};const BB=(e,t)=>{const r=Av(e);if(!t||e!==t)return r;const n=r.paddingBox.top-t.scrollTop,a=r.paddingBox.left-t.scrollLeft,c=n+t.scrollHeight,l=a+t.scrollWidth,f=og({top:n,right:l,bottom:c,left:a},r.border);return lg({borderBox:f,margin:r.margin,border:r.border,padding:r.padding})};var QB=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:c,isCombineEnabled:l,shouldClipSubject:d})=>{const f=r.closestScrollable,m=BB(e,f),x=Cf(m,n),y=(()=>{if(!f)return null;const v=Av(f),S={scrollHeight:f.scrollHeight,scrollWidth:f.scrollWidth};return{client:v,page:Cf(v,n),scroll:A1(f),scrollSize:S,shouldClipSubject:d}})();return DB({descriptor:t,isEnabled:!c,isCombineEnabled:l,isFixedOnPage:r.isFixedOnPage,direction:a,client:m,page:x,closest:y})};const PB={passive:!1},OB={passive:!0};var D5=e=>e.shouldPublishImmediately?PB:OB;const Sh=e=>e&&e.env.closestScrollable||null;function FB(e){const t=b.useRef(null),r=Nf(Jf),n=Sg("droppable"),{registry:a,marshal:c}=r,l=l6(e),d=Sn(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),f=b.useRef(d),m=Sn(()=>mi((O,$)=>{t.current||Ft();const V={x:O,y:$};c.updateDroppableScroll(d.id,V)}),[d.id,c]),x=wr(()=>{const O=t.current;return!O||!O.env.closestScrollable?gi:A1(O.env.closestScrollable)},[]),y=wr(()=>{const O=x();m(O.x,O.y)},[x,m]),w=Sn(()=>A0(y),[y]),v=wr(()=>{const O=t.current,$=Sh(O);if(O&&$||Ft(),O.scrollOptions.shouldPublishImmediately){y();return}w()},[w,y]),S=wr((O,$)=>{t.current&&Ft();const V=l.current,Y=V.getDroppableRef();Y||Ft();const le=jB(Y),be={ref:Y,descriptor:d,env:le,scrollOptions:$};t.current=be;const pe=QB({ref:Y,descriptor:d,env:le,windowScroll:O,direction:V.direction,isDropDisabled:V.isDropDisabled,isCombineEnabled:V.isCombineEnabled,shouldClipSubject:!V.ignoreContainerClipping}),ee=le.closestScrollable;return ee&&(ee.setAttribute(I5.contextId,r.contextId),ee.addEventListener("scroll",v,D5(be.scrollOptions))),pe},[r.contextId,d,v,l]),C=wr(()=>{const O=t.current,$=Sh(O);return O&&$||Ft(),A1($)},[]),I=wr(()=>{const O=t.current;O||Ft();const $=Sh(O);t.current=null,$&&(w.cancel(),$.removeAttribute(I5.contextId),$.removeEventListener("scroll",v,D5(O.scrollOptions)))},[v,w]),R=wr(O=>{const $=t.current;$||Ft();const V=Sh($);V||Ft(),V.scrollTop+=O.y,V.scrollLeft+=O.x},[]),B=Sn(()=>({getDimensionAndWatchScroll:S,getScrollWhileDragging:C,dragStopped:I,scroll:R}),[I,S,C,R]),z=Sn(()=>({uniqueId:n,descriptor:d,callbacks:B}),[B,d,n]);Wa(()=>(f.current=z.descriptor,a.droppable.register(z),()=>{t.current&&I(),a.droppable.unregister(z)}),[B,d,I,z,c,a.droppable]),Wa(()=>{t.current&&c.updateDroppableIsEnabled(f.current.id,!e.isDropDisabled)},[e.isDropDisabled,c]),Wa(()=>{t.current&&c.updateDroppableIsCombineEnabled(f.current.id,e.isCombineEnabled)},[e.isCombineEnabled,c])}function gm(){}const B5={width:0,height:0,margin:YR},$B=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?B5:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},UB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=$B({isAnimatingOpenOnMount:e,placeholder:t,animate:r});return{display:t.display,boxSizing:"border-box",width:n.width,height:n.height,marginTop:n.margin.top,marginRight:n.margin.right,marginBottom:n.margin.bottom,marginLeft:n.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:r!=="none"?c0.placeholder:null}},zB=e=>{const t=b.useRef(null),r=wr(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:n,onTransitionEnd:a,onClose:c,contextId:l}=e,[d,f]=b.useState(e.animate==="open");b.useEffect(()=>d?n!=="open"?(r(),f(!1),gm):t.current?gm:(t.current=setTimeout(()=>{t.current=null,f(!1)}),r):gm,[n,d,r]);const m=wr(y=>{y.propertyName==="height"&&(a(),n==="close"&&c())},[n,c,a]),x=UB({isAnimatingOpenOnMount:d,animate:e.animate,placeholder:e.placeholder});return L.createElement(e.placeholder.tagName,{style:x,"data-rfd-placeholder-context-id":l,onTransitionEnd:m,ref:e.innerRef})};var HB=L.memo(zB);class WB extends L.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 GB=e=>{const t=b.useContext(Jf);t||Ft();const{contextId:r,isMovementAllowed:n}=t,a=b.useRef(null),c=b.useRef(null),{children:l,droppableId:d,type:f,mode:m,direction:x,ignoreContainerClipping:y,isDropDisabled:w,isCombineEnabled:v,snapshot:S,useClone:C,updateViewportMaxScroll:I,getContainerForClone:R}=e,B=wr(()=>a.current,[]),z=wr((ee=null)=>{a.current=ee},[]);wr(()=>c.current,[]);const O=wr((ee=null)=>{c.current=ee},[]),$=wr(()=>{n()&&I({maxScroll:t6()})},[n,I]);FB({droppableId:d,type:f,mode:m,direction:x,isDropDisabled:w,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:B});const V=Sn(()=>L.createElement(WB,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:ee,data:ke,animate:He})=>L.createElement(HB,{placeholder:ke,onClose:ee,innerRef:O,animate:He,contextId:r,onTransitionEnd:$})),[r,$,e.placeholder,e.shouldAnimatePlaceholder,O]),Y=Sn(()=>({innerRef:z,placeholder:V,droppableProps:{"data-rfd-droppable-id":d,"data-rfd-droppable-context-id":r}}),[r,d,V,z]),le=C?C.dragging.draggableId:null,be=Sn(()=>({droppableId:d,type:f,isUsingCloneFor:le}),[d,le,f]);function pe(){if(!C)return null;const{dragging:ee,render:ke}=C,He=L.createElement(b6,{draggableId:ee.draggableId,index:ee.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(q,ce)=>ke(q,ce,ee));return fA.createPortal(He,R())}return L.createElement(_g.Provider,{value:be},l(Y,S),pe())};function VB(){return document.body||Ft(),document.body}const Q5={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:VB},A6=e=>{let t={...e},r;for(r in Q5)e[r]===void 0&&(t={...t,[r]:Q5[r]});return t},xm=(e,t)=>e===t.droppable.type,P5=(e,t)=>t.draggables[e.draggable.id],qB=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=mi(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),n=mi((c,l,d,f,m,x)=>{const y=m.descriptor.id;if(m.descriptor.droppableId===c){const S=x?{render:x,dragging:r(m.descriptor)}:null,C={isDraggingOver:d,draggingOverWith:d?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!1,snapshot:C,useClone:S}}if(!l)return t;if(!f)return e;const v={isDraggingOver:d,draggingOverWith:y,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(c,l)=>{const d=A6(l),f=d.droppableId,m=d.type,x=!d.isDropDisabled,y=d.renderClone;if(L0(c)){const w=c.critical;if(!xm(m,w))return t;const v=P5(w,c.dimensions),S=Ha(c.impact)===f;return n(f,x,S,S,v,y)}if(c.phase==="DROP_ANIMATING"){const w=c.completed;if(!xm(m,w.critical))return t;const v=P5(w.critical,c.dimensions);return n(f,x,g6(w.result)===f,Ha(w.impact)===f,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const w=c.completed;if(!xm(m,w.critical))return t;const v=Ha(w.impact)===f,S=!!(w.impact.at&&w.impact.at.type==="COMBINE"),C=w.critical.droppable.id===f;return v?S?e:t:C?e:t}return t}},YB={updateViewportMaxScroll:oj},Ll=vv(qB,YB,(e,t,r)=>({...A6(r),...e,...t}),{context:Tg,areStatePropsEqual:m6})(GB);function ZB(){if(typeof window>"u")return Qu(void 0);try{const e=window.localStorage.getItem(a1);return Qu(e?JSON.parse(e):void 0)}catch{return Qu(void 0)}}function bm(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(a1),r=t?JSON.parse(t):{},n=Qu({...r,...e});window.localStorage.setItem(a1,JSON.stringify(n))}catch{}}function KB(){const[e,t]=L.useState(ZB);L.useEffect(()=>{bm(e)},[e]);const r=L.useCallback(a=>{t(c=>{const l=Qu({...c,...a});return bm(l),l})},[]),n=L.useCallback(()=>{const a=Qu(void 0);t(a),bm(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const T1="termdock-settings";function XB(e){return e==="shell"||e==="tmux"}function JB(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(T1);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&XB(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 O5(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(T1),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(T1,JSON.stringify(n))}catch{}}function eQ(){const[e,t]=L.useState(JB),r=L.useCallback((a,c)=>{const l=c?.userInitiated!==!1;t(d=>({...d,mode:a,userSelectedMode:l?a:d.userSelectedMode})),l&&O5({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=L.useCallback(a=>{t(c=>({...c,tmuxName:a})),O5({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const tQ=550,rQ=10;function kg(){const e=b.useRef(null),t=b.useRef(null),r=b.useRef(!1),n=b.useRef(!1),a=b.useRef(null),c=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),l=b.useCallback(()=>{c(),t.current=null},[c]);return b.useCallback(f=>({onPointerDown:m=>{m.pointerType!=="touch"&&m.pointerType!=="pen"||(l(),r.current=!1,t.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(r.current=!0,f())},tQ))},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)>rQ&&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 F5({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 nQ(e,t,r){return!!(e&&t===e&&!r)}function sQ({groupId:e,version:t,onRestore:r}){const[n,a]=b.useState([]),[c,l]=b.useState(null),[d,f]=b.useState(""),m=b.useRef(!1);b.useEffect(()=>{let y=!0;const w=async()=>{try{const S=await R8();y&&a(S.entries.filter(C=>C.groups.some(I=>I.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),f("");try{const w=await M8(y.sessionId);await r(w.session),a(v=>v.filter(S=>S.sessionId!==y.sessionId))}catch(w){f(w instanceof Error?w.message:"恢复失败,归档已保留")}finally{m.current=!1,l(null)}}};return!n.length&&!d?null:s.jsxs("details",{className:"border-t border-border/15 text-muted-foreground",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 px-2 text-[11px]",children:[s.jsx(Dy,{size:13}),"已归档的执行会话 · ",n.length]}),d&&s.jsx("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:d}),n.map(y=>s.jsxs("div",{className:"border-t border-border/10 px-2 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:y.title}),s.jsxs("button",{type:"button",disabled:c!==null,onClick:()=>{x(y)},className:"inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-primary hover:bg-primary/10 disabled:opacity-40",children:[c===y.sessionId&&s.jsx(bn,{size:12,className:"animate-spin"}),c===y.sessionId?"恢复中…":"恢复"]})]}),s.jsx("p",{className:"text-[10px] leading-4",children:y.cleanup.state==="removed"?"执行目录已回收,恢复时重建;分支和结果保留。":y.cleanup.reason||"目录保留,可继续恢复原会话。"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[10px]",children:[y.agent.slug," 会话 ID 与目录"]}),s.jsx("code",{className:"block select-text break-all text-[10px]",children:y.agent.sessionId}),s.jsx("span",{className:"mt-1 block select-text break-all text-[10px]",children:y.cwd})]})]},y.sessionId))]})}function $5(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 Rf={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function Mf(e){const t=e.attempts.find(d=>d.id===e.activeAttemptId)?.report;if(!t)return null;const r=typeof t.content=="string"?t.content:"",n=t.summary,a=r.split(/\n\s*\n/).map(d=>d.split(`
|
|
135
|
-
`).filter(f=>!/^#{1,6}\s/.test(f)).join(`
|
|
136
|
-
`).trim()).find(Boolean),c=typeof n=="string"&&n.trim()?n.trim():a,l=Number.isFinite(t.createdAt)&&t.createdAt>0&&Number.isFinite(new Date(t.createdAt).getTime());return{status:t.status,label:Rf[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function tp(e){if(e.status!=="open")return[];const t=Mf(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 iQ(e){return tp(e)[0]??null}function Xc(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=iQ(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?Rf[r.report.status]:["failed","expired"].includes(r.deliveryStatus??"")?"投递未成功":e.deliveries.some(l=>l.attemptId===e.activeAttemptId&&l.error)?"投递需要关注":r.deliveryStatus==="delivered"?"已写入终端 · 等待回复":"等待投递":e.scheduledAssignee?e.dependsOn.length?"依赖完成后自动分派":e.workflow?.isolated===!1?"等待分派":"准备独立执行目录":e.dependsOn.length?"等待依赖与分派":"待分派"}function Ui(e){return e.purpose!=="automation"&&e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(Xc(e))}const Lu=hc(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await _y();e({tasks:r.filter(Ui),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function U5(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 z5({sessionIds:e}){const t=j8(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=Ur();if(!t)return null;const n=r==="zh"?`${t} 条未读进展`:`${t} unread progress updates`;return s.jsx("span",{title:n,"aria-label":n,className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-primary/15 px-1 text-[10px] font-medium text-primary",children:t>99?"99+":t})}function aQ(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 T6(e){const t=aQ(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 oQ(e,t,r){return Math.max(t,Math.min(e,r))}const fs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function H5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function W5(e,t,r,n=.15){return n===0?oQ(e,t,r):e<t?-H5(t-e,r-t,n)+t:e>r?+H5(e-r,r-t,n)+r:e}function lQ(e,[t,r],[n,a]){const[[c,l],[d,f]]=e;return[W5(t,c,l,n),W5(r,d,f,a)]}function cQ(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 uQ(e){var t=cQ(e,"string");return typeof t=="symbol"?t:String(t)}function Os(e,t,r){return t=uQ(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function G5(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?G5(Object(r),!0).forEach(function(n){Os(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const S6={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 V5(e){return e?e[0].toUpperCase()+e.slice(1):""}const dQ=["enter","leave"];function hQ(e=!1,t){return e&&!dQ.includes(t)}function fQ(e,t="",r=!1){const n=S6[e],a=n&&n[t]||t;return"on"+V5(e)+V5(a)+(hQ(r,a)?"Capture":"")}const pQ=["gotpointercapture","lostpointercapture"];function mQ(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=pQ.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function gQ(e,t=""){const r=S6[e],n=r&&r[t]||t;return e+n}function rp(e){return"touches"in e}function C6(e){return rp(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function xQ(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 bQ(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function _6(e){return rp(e)?bQ(e)[0]:e}function S1(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 yQ(e){return xQ(e).map(t=>t.identifier)}function q5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return S1(r,n)}function ym(e){const t=_6(e);return rp(e)?t.identifier:t.pointerId}function Vu(e){const t=_6(e);return[t.clientX,t.clientY]}const Y5=40,Z5=800;function k6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=Y5,r*=Y5):n===2&&(t*=Z5,r*=Z5),[t,r]}function vQ(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 wQ(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 jf(e,...t){return typeof e=="function"?e(...t):e}function AQ(){}function TQ(...e){return e.length===0?AQ:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function K5(e,t){return Object.assign({},t,e||{})}const SQ=32;class L6{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?jf(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,wQ(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,c=t.timeStamp-r.timeStamp,r.timeStamp=t.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const V=r._delta.map(Math.abs);fs.addTo(r._distance,V)}this.axisIntent&&this.axisIntent(t);const[l,d]=r._movement,[f,m]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(l)>=f&&y[0]),x[1]===!1&&(x[1]=Math.abs(d)>=m&&y[1])):(x[0]===!1&&(x[0]=Math.abs(l)>=f&&Math.sign(l)*f),x[1]===!1&&(x[1]=Math.abs(d)>=m&&Math.sign(d)*m)),r.intentional=x[0]!==!1||x[1]!==!1,!r.intentional)return;const w=[0,0];if(n.hasCustomTransform){const[V,Y]=y;w[0]=x[0]!==!1?V-x[0]:0,w[1]=x[1]!==!1?Y-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=jf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[C,I]=r.offset,[[R,B],[z,O]]=r._bounds;r.overflow=[C<R?-1:C>B?1:0,I<z?-1:I>O?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const $=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=lQ(r._bounds,r.offset,$),r.delta=fs.sub(r.offset,v),this.computeMovement(),S&&(!r.last||c>SQ)){r.delta=fs.sub(r.offset,v);const V=r.delta.map(Math.abs);fs.addTo(r.distance,V),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&c>0&&(r.velocity=[V[0]/c,V[1]/c],r.timeDelta=c)}}emit(){const t=this.state,r=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const a=this.handler(vs(vs(vs({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function CQ([e,t],r){const n=Math.abs(e),a=Math.abs(t);if(n>a&&n>r)return"x";if(a>n&&a>r)return"y"}class P0 extends L6{constructor(...t){super(...t),Os(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=fs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=fs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const r=this.state,n=this.config;if(!r.axis&&t){const a=typeof n.axisThreshold=="object"?n.axisThreshold[C6(t)]:n.axisThreshold;r.axis=CQ(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 _Q=e=>e,X5=.15,I6={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[X5,X5];case!1:return[0,0];default:return fs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return fs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||_Q},threshold(e){return fs.toVector(e,0)}},kQ=0,Jc=vs(vs({},I6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=kQ){return e},bounds(e={}){if(typeof e=="function")return c=>Jc.bounds(e(c));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=e;return[[t,r],[n,a]]}}),J5={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 LQ extends P0{constructor(...t){super(...t),Os(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const r=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),a={left:r.left-n.left+t.offset[0],right:r.right-n.right+t.offset[0],top:r.top-n.top+t.offset[1],bottom:r.bottom-n.bottom+t.offset[1]};t._bounds=Jc.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const r=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(t.buttons):r.pointerButtons!==-1&&r.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);r.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=ym(t),n._pointerActive=!0,this.computeValues(Vu(t)),this.computeInitial(),r.preventScrollAxis&&C6(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=ym(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=fs.sub(c,r._values),this.computeValues(c)),fs.addTo(r._movement,r._delta),this.compute(t),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const a=ym(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[c,l]=r._distance;if(r.tap=c<=n.tapsThreshold&&l<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[d,f]=r._delta,[m,x]=r._movement,[y,w]=n.swipe.velocity,[v,S]=n.swipe.distance,C=n.swipe.duration;if(r.elapsedTime<C){const I=Math.abs(d/r.timeDelta),R=Math.abs(f/r.timeDelta);I>y&&Math.abs(m)>v&&(r.swipe[0]=Math.sign(d)),R>w&&Math.abs(x)>S&&(r.swipe[1]=Math.sign(f))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const r=this.config,n=r.device;r.pointerLock&&t.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,IQ(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=J5[t.key];if(r){const n=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=r(this.config.keyboardDisplacement,a),n._keyboardActive=!0,fs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in J5&&(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 IQ(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const O0=typeof window<"u"&&window.document&&window.document.createElement;function E6(){return O0&&"ontouchstart"in window}function EQ(){return E6()||O0&&window.navigator.maxTouchPoints>1}function NQ(){return O0&&"onpointerdown"in window}function RQ(){return O0&&"exitPointerLock"in window.document}function MQ(){try{return"constructor"in GestureEvent}catch{return!1}}const yo={isBrowser:O0,gesture:MQ(),touch:E6(),touchscreen:EQ(),pointer:NQ(),pointerLock:RQ()},jQ=250,DQ=180,BQ=.5,QQ=50,PQ=250,OQ=10,eb={mouse:0,touch:0,pen:8},FQ=vs(vs({},Jc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&yo.pointerLock,yo.touch&&r?"touch":this.pointerLock?"mouse":yo.pointer&&!a?"pointer":yo.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?jQ:void 0,!(!yo.touchscreen||r===!1))return e||(r!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(e,t,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const c=fs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=BQ,distance:t=QQ,duration:r=PQ}={}){return{velocity:this.transform(fs.toVector(e)),distance:this.transform(fs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return DQ;case!1:return 0;default:return e}},axisThreshold(e){return e?vs(vs({},eb),e):eb},keyboardDisplacement(e=OQ){return e}});function N6(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 $Q=30,UQ=100;class zQ extends L6{constructor(...t){super(...t),Os(this,"ingKey","pinching"),Os(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:r,lastOffset:n}=this.state;t==="wheel"?this.state.offset=fs.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:t,lastOffset:r}=this.state;this.state.movement=[t[0]/r[0],t[1]-r[1]]}axisIntent(){const t=this.state,[r,n]=t._movement;if(!t.axis){const a=Math.abs(r)*$Q-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=q5(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=S1(...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=q5(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=S1(...Array.from(r.values()));n&&this.pinchMove(t,n)}pinchMove(t,r){const n=this.state,a=n._values[1],c=r.angle-a;let l=0;Math.abs(c)>270&&(l+=Math.sign(c)),this.computeValues([r.distance,r.angle-360*l]),n.origin=r.origin,n.turns=l,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const r=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}r._pointerEvents.has(t.pointerId)&&r._pointerEvents.delete(t.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const r=this.state;r._active||(this.start(t),this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY];const n=r._movement;r._movement=[t.scale-1,t.rotation],r._delta=fs.sub(r._movement,n),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>t[n]):!t[r])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const n=this.state;n._delta=[-k6(t)[1]/UQ*n.offset[0],0],fs.addTo(n._movement,n._delta),N6(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 HQ=vs(vs({},I6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!yo.touch&&yo.gesture)return"gesture";if(yo.touch&&n)return"touch";if(yo.touchscreen){if(yo.pointer)return"pointer";if(yo.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const d=K5(jf(r,l),{min:-1/0,max:1/0});return[d.min,d.max]},c=l=>{const d=K5(jf(n,l),{min:-1/0,max:1/0});return[d.min,d.max]};return typeof r!="function"&&typeof n!="function"?[a(),c()]:l=>[a(l),c(l)]},threshold(e,t,r){return this.lockDirection=r.axis==="lock",fs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class WQ extends P0{constructor(...t){super(...t),Os(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(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=fs.sub(r,n._values),fs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const GQ=vs(vs({},Jc),{},{mouseOnly:(e=!0)=>e});class VQ extends P0{constructor(...t){super(...t),Os(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const r=this.state,n=vQ(t);r._delta=fs.sub(n,r._values),fs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const qQ=Jc;class YQ extends P0{constructor(...t){super(...t),Os(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const r=this.state;r._delta=k6(t),fs.addTo(r._movement,r._delta),N6(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 ZQ=Jc;class KQ extends P0{constructor(...t){super(...t),Os(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=fs.sub(n,r._values),this.computeValues(n),this.compute(t),r.delta=r.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const XQ=vs(vs({},Jc),{},{mouseOnly:(e=!0)=>e}),Lg=new Map,C1=new Map;function R6(e){Lg.set(e.key,e.engine),C1.set(e.key,e.resolver)}const M6={key:"drag",engine:LQ,resolver:FQ},JQ={key:"hover",engine:KQ,resolver:XQ},eP={key:"move",engine:WQ,resolver:GQ},tP={key:"pinch",engine:zQ,resolver:HQ},rP={key:"scroll",engine:VQ,resolver:qQ},nP={key:"wheel",engine:YQ,resolver:ZQ};function sP(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 iP(e,t){if(e==null)return{};var r=sP(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 aP={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=yo.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},oP=["target","eventOptions","window","enabled","transform"];function Jh(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]=Jh(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function lP(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:d,transform:f}=n,m=iP(n,oP);if(r.shared=Jh({target:a,eventOptions:c,window:l,enabled:d,transform:f},aP),t){const x=C1.get(t);r[t]=Jh(vs({shared:r.shared},m),x)}else for(const x in m){const y=C1.get(x);y&&(r[x]=Jh(vs({shared:r.shared},m[x]),y))}return r}class j6{constructor(t,r){Os(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,d=gQ(r,n),f=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=vs(vs({},f),c);t.addEventListener(d,a,m);const x=()=>{t.removeEventListener(d,a,m),l.delete(x)};return l.add(x),x}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class cP{constructor(){Os(this,"_timeouts",new Map)}add(t,r,n=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(r,n,...a))}remove(t){const r=this._timeouts.get(t);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class uP{constructor(t){Os(this,"gestures",new Set),Os(this,"_targetEventStore",new j6(this)),Os(this,"gestureEventStores",{}),Os(this,"gestureTimeoutStores",{}),Os(this,"handlers",{}),Os(this,"config",{}),Os(this,"pointerIds",new Set),Os(this,"touchIds",new Set),Os(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),dP(this,t)}setEventIds(t){if(rp(t))return this.touchIds=new Set(yQ(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=lP(t,r,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const l of this.gestures){const d=this.config[l],f=tb(n,d.eventOptions,!!a);if(d.enabled){const m=Lg.get(l);new m(this,t,l).bind(f)}}const c=tb(n,r.eventOptions,!!a);for(const l in this.nativeHandlers)c(l,"",d=>this.nativeHandlers[l](vs(vs({},this.state.shared),{},{event:d,args:t})),void 0,!0)}for(const c in n)n[c]=TQ(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:d,passive:f}=mQ(c);this._targetEventStore.add(a,l,"",n[c],{capture:d,passive:f})}}}}function wu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new j6(e,t),e.gestureTimeoutStores[t]=new cP}function dP(e,t){t.drag&&wu(e,"drag"),t.wheel&&wu(e,"wheel"),t.scroll&&wu(e,"scroll"),t.move&&wu(e,"move"),t.pinch&&wu(e,"pinch"),t.hover&&wu(e,"hover")}const tb=(e,t,r)=>(n,a,c,l={},d=!1)=>{var f,m;const x=(f=l.capture)!==null&&f!==void 0?f:t.capture,y=(m=l.passive)!==null&&m!==void 0?m:t.passive;let w=d?n:fQ(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},hP=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function fP(e){const t={},r={},n=new Set;for(let a in e)hP.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function Au(e,t,r,n,a,c){if(!e.has(r)||!Lg.has(n))return;const l=r+"Start",d=r+"End",f=m=>{let x;return m.first&&l in t&&t[l](m),r in t&&(x=t[r](m)),m.last&&d in t&&t[d](m),x};a[n]=f,c[n]=c[n]||{}}function pP(e,t){const[r,n,a]=fP(e),c={};return Au(a,r,"onDrag","drag",c,t),Au(a,r,"onWheel","wheel",c,t),Au(a,r,"onScroll","scroll",c,t),Au(a,r,"onPinch","pinch",c,t),Au(a,r,"onMove","move",c,t),Au(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function D6(e,t={},r,n){const a=L.useMemo(()=>new uP(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),L.useEffect(a.effect.bind(a)),L.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function rb(e,t){return R6(M6),D6({drag:e},t||{},"drag")}function mP(e){return e.forEach(R6),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=pP(r,n||{});return D6(a,l,void 0,c)}}function PU(e,t){return mP([M6,tP,rP,nP,eP,JQ])(e,t||{})}const nb={dampingRatio:.8,response:.3},gP=.998;function xP(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:C=>n+(v+S*C)*Math.exp(-a*C),velocity:C=>(S-a*(v+S*C))*Math.exp(-a*C)}}if(d<1){const v=a*Math.sqrt(1-d*d),S=c,C=(l+d*a*c)/v;return{value:I=>n+Math.exp(-d*a*I)*(S*Math.cos(v*I)+C*Math.sin(v*I)),velocity:I=>Math.exp(-d*a*I)*((C*v-d*a*S)*Math.cos(v*I)-(S*v+d*a*C)*Math.sin(v*I))}}const f=a*Math.sqrt(d*d-1),m=-d*a+f,x=-d*a-f,y=(l-x*c)/(m-x),w=c-y;return{value:v=>n+y*Math.exp(m*v)+w*Math.exp(x*v),velocity:v=>y*m*Math.exp(m*v)+w*x*Math.exp(x*v)}}function bP(e,t=gP){return e/1e3*(t/(1-t))}function sb(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function yP(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const vP=.1,wP=5;function AP(e,t,r,n,a){const c=xP(e,t,r,n),l=1e3/60,d=240,f=[];for(let m=0;m<d;m++){const x=m*l/1e3,y=c.value(x),w=c.velocity(x);if(f.push(a?a(y):y),m>0&&Math.abs(y-n)<vP&&Math.abs(w)<wP)break}return f.push(a?a(n):n),{frames:f,durationMs:(f.length-1)*l,solver:c}}const TP='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function SP(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(TP)&&e.blur()}const CP=18,ib=8,ab={touch:ib,pen:ib},_P=500,vm=200,ob=50,kP=`[${gA}]`;function wm(e,t,r){return Math.min(r,Math.max(t,e))}function lb(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 cb(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(kP)}function jd(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const B6=L.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:d=!1},f){const{t:m}=Ur(),x=t==="left",y=x?-n:n,w=b.useRef(null),v=b.useRef(null),S=b.useRef(r?0:y),C=b.useRef(null),I=b.useRef(null),R=b.useRef(0),B=b.useRef(null),z=b.useRef(null),O=b.useRef(!1),$=b.useRef(null),V=b.useRef(!1),Y=b.useRef([]),le=b.useRef(null),be=b.useRef(S.current),pe=b.useRef(r?1:0),ee=b.useRef(r);ee.current=r;const ke=b.useRef(y);ke.current=y;const He=b.useRef(n);He.current=n;const q=b.useRef(x);q.current=x;const ce=b.useRef(a);ce.current=a;const qe=b.useRef(c);qe.current=c;const Ae=b.useCallback(ae=>{w.current=ae,typeof f=="function"?f(ae):f&&(f.current=ae)},[f]),ve=b.useCallback(()=>{I.current!==null&&(window.cancelAnimationFrame(I.current),I.current=null),C.current=null},[]),Ie=b.useCallback(ae=>{const ye=He.current;return q.current?(ae+ye)/ye:(ye-ae)/ye},[]),Be=b.useCallback(ae=>{const ye=v.current;ye&&(ye.style.opacity=String(wm(Ie(ae),0,1)))},[Ie]),ne=b.useCallback(ae=>{S.current=ae;const ye=w.current;ye&&(ye.style.transform=`translateX(${ae}px)`,Be(ae))},[Be]),Fe=b.useCallback(ae=>{C.current=ae,I.current===null&&(I.current=window.requestAnimationFrame(()=>{I.current=null;const ye=C.current;C.current=null,ye!==null&&ne(ye)}))},[ne]),Le=b.useCallback(()=>{I.current!==null&&(window.cancelAnimationFrame(I.current),I.current=null);const ae=C.current;C.current=null,ae!==null&&ne(ae)},[ne]),Re=b.useCallback(ae=>{const ye=ke.current;return wm(ae,Math.min(0,ye),Math.max(0,ye))},[]),Pe=b.useCallback(()=>{const ae=B.current;if(!ae)return null;B.current=null;const ye=(performance.now()-ae.startTime)/1e3,Ve={value:ae.solver.value(ye),velocity:ae.solver.velocity(ye)};return ae.animations.forEach(Je=>Je.cancel()),Ve},[]),Ee=b.useCallback(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),oe=b.useCallback(()=>{le.current?.(),le.current=null},[]),We=b.useCallback(()=>{Le(),Ee();const ae=Pe();ae&&ne(Re(ae.value));const ye=w.current,Ve=v.current;ye?.getAnimations().forEach(Je=>Je.cancel()),ye&&(ye.style.transition="none",ye.style.opacity="1"),Ve?.getAnimations().forEach(Je=>Je.cancel()),Ve&&(Ve.style.transition="none")},[ne,Ee,Re,Le,Pe]),rt=b.useCallback((ae,ye)=>{Le(),Ee();const Ve=w.current,Je=v.current,bt=ae?0:ke.current;Je&&(Je.style.pointerEvents=ae?"auto":"none");const Vt=Pe(),Pt=Vt?Re(Vt.value):S.current,mt=ye?.velocity??Vt?.velocity??0;if(yP())return S.current=bt,Ve&&(Ve.style.transition=`opacity ${vm}ms ease`,Ve.style.opacity=ae?"1":"0",Ve.style.transform=`translateX(${bt}px)`),Je&&(Je.style.transition=`opacity ${vm}ms ease`,Je.style.opacity=ae?"1":"0"),vm;Ve&&(Ve.style.transition="none",Ve.style.opacity="1"),Je&&(Je.style.transition="none");const Zt=Math.abs(ye?.velocity??0)>_P,{frames:Ht,durationMs:Kt,solver:Ot}=AP({dampingRatio:Zt?nb.dampingRatio:1,response:nb.response},Pt,mt,bt,Re);if(!Ve||Math.abs(Pt-bt)<.5&&Math.abs(mt)<5)return ne(bt),0;const Nt=Ve.animate(Ht.map(Ze=>({transform:`translateX(${Ze}px)`})),{duration:Kt,easing:"linear",fill:"forwards"}),me=[Nt];return Je&&me.push(Je.animate(Ht.map(Ze=>({opacity:String(wm(Ie(Ze),0,1))})),{duration:Kt,easing:"linear",fill:"forwards"})),B.current={solver:Ot,startTime:performance.now(),target:bt,animations:me},jd("spring start",{startX:Pt,startVelocity:mt,targetX:bt,frames:Ht.length,durationMs:Kt}),Nt.onfinish=()=>{const Ze=B.current;!Ze||!Ze.animations.includes(Nt)||(B.current=null,ne(bt),Ze.animations.forEach(ct=>ct.cancel()),jd("spring finish",{targetX:bt}))},Kt},[ne,Ee,Re,Le,Ie,Pe]),gt=b.useCallback(ae=>{Le();const ye=ae,Ve=0,Je=ke.current,bt=S.current+bP(ye),Vt=Math.abs(bt-Ve)<=Math.abs(bt-Je);jd("decideSnap",{velocity:ye,currentX:S.current,projected:bt,shouldOpen:Vt});const Pt=rt(Vt,{velocity:ye});return Vt&&!ee.current?z.current=window.setTimeout(()=>{z.current=null,qe.current?.()},Pt+ob):!Vt&&ee.current&&(z.current=window.setTimeout(()=>{z.current=null,ce.current()},Pt+ob)),Vt},[rt,Le]),ue=b.useCallback(ae=>{const ye=ke.current,Ve=Math.min(0,ye),Je=Math.max(0,ye),bt=He.current;return ae<Ve?Ve-sb(Ve-ae,bt):ae>Je?Je+sb(ae-Je,bt):ae},[]),Ye=b.useCallback(ae=>{const ye=Y.current,Ve=performance.now();ye.push({t:Ve,x:ae});const Je=Ve-120;for(;ye.length>0&&ye[0].t<Je;)ye.shift()},[]),at=b.useCallback(()=>{const ae=Y.current;if(ae.length<2)return 0;const ye=ae[ae.length-1];if(performance.now()-ye.t>60)return 0;const Ve=ae[0],Je=(ye.t-Ve.t)/1e3;return Je<.016?0:(ye.x-Ve.x)/Je},[]);b.useEffect(()=>{Ee();const ae=B.current,ye=r?0:ke.current;ae&&ae.target===ye||rt(r)},[r,rt,Ee]),b.useEffect(()=>{We(),Fe(ee.current?0:y)},[y,We,Fe]),b.useEffect(()=>()=>{ve(),Ee(),Pe(),oe()},[Ee,ve,oe,Pe]);const Ne=rb(({active:ae,cancel:ye,first:Ve,last:Je,movement:[bt],event:Vt})=>{if(jd("bindPanel",{active:ae,first:Ve,last:Je,mx:bt}),!lb(Vt)){ye();return}if(Ve){if(oe(),O.current=!1,$.current=null,Y.current=[],cb(Vt)){ye();return}const Pt=w.current,mt=Pt?xA(Vt.target,Pt):null;if(!mt||bA()){ye();return}const Zt=yA(mt,bt,q.current?-1:1);if(jd("arbitrate",{owner:Zt.kind,mx:bt}),Zt.kind==="swiper"){le.current=vA(Zt.instance),ye();return}if(Zt.kind==="scroller"){const Ht=wA(Zt.element);if(Ht)$.current=Ht;else{ye();return}}$.current||(O.current=!0,We(),R.current=S.current)}if(!ae){$.current=null,O.current&&(O.current=!1,gt(at()));return}if($.current){AA($.current,bt);return}if(O.current){const Pt=ue(R.current+bt);Ye(Pt),Fe(Pt)}},{axis:"x",axisThreshold:ab,filterTaps:!0,pointer:{touch:!0}}),Ge=rb(({active:ae,cancel:ye,first:Ve,movement:[Je],event:bt})=>{if(!lb(bt)){ye();return}if(ee.current){ye();return}if(Ve&&(V.current=!0,Y.current=[],We(),R.current=S.current),!ae){V.current&&(V.current=!1,gt(at())&&SP());return}if(V.current){const Vt=ue(R.current+Je);Ye(Vt),Fe(Vt)}},{axis:"x",axisThreshold:ab,filterTaps:!0,pointer:{touch:!0}}),Ce=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),ee.current||qe.current?.()},[]);if(d)return s.jsx("aside",{ref:Ae,"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=Ne();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...Ge(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:CP,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:Ce,"aria-label":m(x?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),s.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:pe.current,pointerEvents:r?"auto":"none",transition:"none",willChange:"opacity"},onClick:a,"aria-label":m("sidebar.closeSidebar")}),s.jsx("aside",{...H,onClickCapture:ae=>{cb(ae)||H.onClickCapture?.(ae)},ref:Ae,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${x?"border-r border-border":"border-l border-border/15"}`,style:{...x?{left:0}:{right:0},width:n,maxWidth:x?"94vw":"95vw",transform:`translateX(${be.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:r?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...x?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})}),LP={activeKey:"root",items:[]},IP=()=>()=>{},EP=()=>LP;function NP(e){const t=Po(),r=b.useSyncExternalStore(t?.subscribe??IP,t?.snapshot??EP),n=D8(),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 RP({groups:e,currentKey:t,onClose:r}){const{t:n}=Ur(),a=b.useId(),c=b.useRef(null),l=b.useRef(null),d=b.useRef(r);d.current=r;const f=b.useRef(!0),[m,x]=b.useState(""),y=e.reduce((S,C)=>S+C.reviewCount,0);b.useEffect(()=>{const S=document.activeElement;l.current?.focus({preventScroll:!0});const C=I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopImmediatePropagation(),d.current()),I.key!=="Tab")return;const R=Array.from(c.current?.querySelectorAll("button:not(:disabled)")??[]),B=R[0],z=R[R.length-1],O=!c.current?.contains(document.activeElement);I.shiftKey&&(document.activeElement===B||O)?(I.preventDefault(),z?.focus()):!I.shiftKey&&(document.activeElement===z||O)&&(I.preventDefault(),B?.focus())};return document.addEventListener("keydown",C,!0),()=>{document.removeEventListener("keydown",C,!0),f.current&&S?.isConnected&&!S.closest("[inert]")&&S.focus({preventScroll:!0})}},[]);const w=(S,C)=>{const I=Po(),R=I?.snapshot().items.find(z=>z.key===S.key);if(!R?.reviewCount||C&&!R.attentionSessions?.some(z=>z.id===C)){x(n("serviceAttention.changed"));return}f.current=!1;let B=!1;C&&S.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:C})),B=!0):C&&R.service?.targetPeerId?B=I?.focusSession(R.service.targetPeerId,C)??!1:R.service&&(B=I?.activate(R.service,!0)??!1),B?r():(f.current=!0,x(n("serviceAttention.unavailable")))},v=S=>S.phase==="offline"?n("serviceAttention.offline"):S.phase==="login"?n("serviceAttention.login"):S.phase==="connecting"||S.phase==="reconnecting"?n("connection.reconnecting"):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":n("common.close"),tabIndex:-1,className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)]",onClick:r}),s.jsx("div",{className:"pointer-events-none fixed inset-0 z-modal-panel flex items-end justify-center p-3 sm:items-center sm:p-6",style:{paddingTop:"max(12px, var(--safe-top-inset, env(safe-area-inset-top, 0px)))",paddingBottom:"max(12px, var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:s.jsxs("section",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-sidebar-gesture-ignore":!0,onKeyDown:S=>S.stopPropagation(),className:"pointer-events-auto flex max-h-full w-full max-w-md flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[s.jsx(cc,{size:20,className:"shrink-0 text-[color:var(--warning)]","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:a,className:"text-sm font-semibold",children:n("serviceAttention.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n("serviceAttention.summary",{services:e.length,count:y})})]}),s.jsx("button",{ref:l,type:"button","aria-label":n("common.close"),onClick:r,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-muted-foreground hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(In,{size:18})})]}),s.jsxs("div",{className:"min-h-0 overflow-y-auto overscroll-contain p-2",children:[e.length===0&&s.jsx("p",{role:"status",className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("serviceAttention.empty")}),e.map(S=>s.jsxs("section",{className:"mb-2 last:mb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pb-1 pt-2 text-xs",children:[s.jsx("h3",{className:"min-w-0 flex-1 truncate font-medium",title:S.service?.label,children:S.service?.label||n("serviceAttention.currentService")}),S.key===t&&s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n("agent.currentSession")}),s.jsx("span",{className:"shrink-0 tabular-nums text-[color:var(--warning)]",children:S.reviewCount})]}),v(S)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(S)}),S.attentionSessions?.length?S.attentionSessions.map(C=>s.jsxs("button",{type:"button",onClick:()=>w(S,C.id),className:"flex min-h-14 w-full items-center gap-3 rounded-xl px-3 py-2 text-left hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"line-clamp-2 break-words text-sm",title:C.label,children:C.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:C.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(Xs,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},C.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 MP(e){const t=e.icon&&e.isPlugin?`/api/terminal/agent-plugin-icon/${encodeURIComponent(e.slug)}${e.iconVersion?`?v=${Math.floor(e.iconVersion)}`:""}`:void 0,[r,n]=b.useState();if(b.useEffect(()=>{if(n(void 0),!t)return;const a=new AbortController;let c;return fetch(t,{signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`Icon request failed: ${l.status}`);const d=await l.blob();a.signal.aborted||(c=URL.createObjectURL(d),n({endpoint:t,src:c}))}).catch(()=>{}),()=>{a.abort(),c&&URL.revokeObjectURL(c)}},[t]),!!e.icon)return e.isPlugin?r?.endpoint===t?r?.src:void 0:`/icons/agents/${e.icon}.svg`}function jP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function DP(e,t,r,n="next"){if(e.length===0)return null;const a=t?e.findIndex(c=>c.sessionId===t):-1;for(let c=1;c<=e.length;c+=1){const l=n==="next"?c:-c,d=(a+l+e.length)%e.length,f=e[d];if(f&&r(f))return f.sessionId}return null}function BP(e,t,r="next"){return DP(e,t,jP,r)}const za=42,Df=20,QP=10;function _1(e,t,r){return Math.min(r,Math.max(t,e))}function np(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+Df,d=Math.max(l,e.width-r-Df-za),f=Math.max(t+12,52),m=Math.max(f,e.height-n-c-za);return{minX:l,maxX:d,minY:f,maxY:m}}function ub(e,t){const r=np(e),n=_1(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=np(e);return{x:_1(t.x,r.minX,r.maxX),y:_1(t.y,r.minY,r.maxY)}}function db(e,t){const r=np(e),n=Hc(e,t),a=(r.minX+r.maxX+za)/2,c=n.x+za/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 hb(e,t,r){const n=Hc(e,t),a=za+QP,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=np(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 Am="var(--warning)",PP="var(--success)",fb="var(--tmux)",pb="termdock:mobile-attention-position:v1",mb="termdock:running-session-position:v1",OP={side:"right",yRatio:.68},FP={side:"right",yRatio:.54};function gb(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 $P(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ch(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function UP(e,t,r={}){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,a=n?.width??window.innerWidth,c=n?.height??window.innerHeight,l=t?.getBoundingClientRect(),d=!!(l&&l.width>0&&l.height>0);return{width:a,height:c,safeTop:Math.max(Ch("--safe-top-inset"),(d?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(Ch("--safe-right-inset"),(d?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(Ch("--safe-bottom-inset"),(d?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(Ch("--safe-left-inset"),(d?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?Df:72}}function Q6(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=BP(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 xb(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function P6(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 zP({indicator:e,tone:t,size:r}){const n=P6(t);switch(e){case"spinner":return s.jsx(_n,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(lf,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx($o,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(qA,{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=MP(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(N0,{size:r,className:"text-white"})})}function HP({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Wc,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(qc,{size:r,className:"shrink-0"}):s.jsx($o,{size:r,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?s.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:s.jsx(zP,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(_n,{size:r,className:"shrink-0 animate-spin",style:{color:PP}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(lf,{size:r,className:"shrink-0 animate-bounce-y",style:{color:Am}})}):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:Am}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(cc,{size:r+1,className:"shrink-0 animate-pulse",style:{color:Am}})}):t?.inCopyMode?e==="tmux"?s.jsx(qc,{size:r,className:"shrink-0 animate-pulse",style:{color:fb}}):s.jsx($o,{size:r,className:"shrink-0 animate-pulse",style:{color:fb}}):n}function WP({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=Ur();return t&&!r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:P6(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 O6({count:e,tone:t,title:r}){const{t:n}=Ur();if(e<=0)return null;const a=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",c=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=r??n("agent.jumpToNext");return s.jsxs("button",{type:"button",className:a,title:`${l} · ${n("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${n("agent.jumpToNext")}`,onClick:Q6,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 GP({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 VP=380,bb=10,_h=10,Tm=52,qP=104;function YP(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=Df,f=e.x+za/2>=n+(a-n)/2,m=f?e.x-_h-n-d:a-d-e.x-za-_h,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*qP))),y=f?e.x-_h-x:e.x+za+_h,w=Math.min(Math.max(y,n+d),Math.max(n+d,a-d-x)),v=e.y+za/2-Tm/2,S=Math.min(Math.max(v,c+d),Math.max(c+d,l-d-Tm));return{left:w,top:S,width:x,height:Tm,itemWidth:x/Math.max(1,r),side:f?"left":"right"}}function yb(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 ZP(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 KP({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:d}){const{t:f}=Ur(),m=Gt(Ne=>Ne.leftOpen),x=Gt(Ne=>Ne.rightOpen),{isOpen:y}=sv({enabled:!c}),w=c||!m&&!x&&!y,v=NP(e),[S,C]=L.useState(!1);L.useEffect(()=>{(!v.active||!w)&&C(!1)},[v.active,w]);const I=a&&v.total>0&&w,R=t.length>1||t.length===1&&t[0]?.id!==r,B=n&&t.length>0&&R&&w,z=Math.max(0,d?.top??0),O=Math.max(0,d?.right??0),$=Math.max(0,d?.bottom??0),V=Math.max(0,d?.left??0),Y=L.useCallback(()=>UP(c,l,{top:z,right:O,bottom:$,left:V}),[l,c,$,V,O,z]),le=L.useRef({attention:gb(pb,OP),running:gb(mb,FP)}),be=L.useCallback(()=>{const Ne=Y(),Ge=ub(Ne,le.current.attention),Ce=ub(Ne,le.current.running);return{attention:Ge,running:I&&B?hb(Ne,Ce,Ge):Ce}},[I,Y,B]),[pe,ee]=L.useState(()=>be()),ke=L.useRef(pe);ke.current=pe;const[He,q]=L.useState(null),ce=L.useRef(null),[qe,Ae]=L.useState("idle"),[ve,Ie]=L.useState(null),Be=L.useRef(null),ne=L.useRef({attention:!1,running:!1});L.useEffect(()=>()=>{const Ne=Be.current?.longPressTimer;Ne!=null&&window.clearTimeout(Ne)},[]),L.useEffect(()=>{if(B)return;const Ne=Be.current?.longPressTimer;Ne!=null&&window.clearTimeout(Ne),Be.current=null,Ae("idle"),Ie(null)},[B]),L.useLayoutEffect(()=>{const Ne=()=>{const Ce=be();ke.current=Ce,ee(Ce)};Ne(),window.addEventListener("resize",Ne),window.addEventListener("orientationchange",Ne),window.visualViewport?.addEventListener("resize",Ne);const Ge=typeof ResizeObserver>"u"?null:new ResizeObserver(Ne);return l&&Ge?.observe(l),()=>{window.removeEventListener("resize",Ne),window.removeEventListener("orientationchange",Ne),window.visualViewport?.removeEventListener("resize",Ne),Ge?.disconnect()}},[l,be]);const Fe=L.useCallback(Ne=>Ne==="attention"?B:I,[I,B]),Le=L.useCallback((Ne,Ge)=>{if(!Fe(Ne))return Ge;const Ce=Ne==="attention"?"running":"attention";return hb(Y(),Ge,ke.current[Ce])},[Y,Fe]),Re=L.useCallback((Ne,Ge,Ce,H)=>{const ae=Y(),ye=Ge.moved?Hc(ae,{x:Ge.startX+(Ce-Ge.originX),y:Ge.startY+(H-Ge.originY)}):ke.current[Ne],Ve=db(ae,ye),Je=Le(Ne,Ve.position),bt=db(ae,Je);le.current[Ne]=bt.preference,$P(Ne==="attention"?pb:mb,bt.preference);const Vt={...ke.current,[Ne]:bt.position};ke.current=Vt,ee(Vt)},[Le,Y]),Pe=L.useCallback(Ne=>{ne.current[Ne]=!0,window.setTimeout(()=>{ne.current[Ne]=!1},0)},[]),Ee=L.useCallback(Ne=>{const Ge=ce.current;!Ge||Ge.kind!=="attention"||Ge.pointerId!==Ne.pointerId||(ce.current=null,q(null),Re("attention",Ge,Ne.clientX,Ne.clientY),Ge.moved&&Pe("attention"))},[Re,Pe]),oe={onPointerDown:Ne=>{Ne.stopPropagation(),Ne.currentTarget.setPointerCapture(Ne.pointerId),ce.current={kind:"attention",pointerId:Ne.pointerId,originX:Ne.clientX,originY:Ne.clientY,startX:pe.attention.x,startY:pe.attention.y,moved:!1}},onPointerMove:Ne=>{const Ge=ce.current;if(!Ge||Ge.kind!=="attention"||Ge.pointerId!==Ne.pointerId)return;const Ce=Ne.clientX-Ge.originX,H=Ne.clientY-Ge.originY;if(!Ge.moved&&Math.hypot(Ce,H)<5)return;Ge.moved=!0,q("attention");const ae=Y(),ye=Le("attention",Hc(ae,{x:Ge.startX+Ce,y:Ge.startY+H})),Ve={...ke.current,attention:ye};ke.current=Ve,ee(Ve)},onPointerUp:Ee,onPointerCancel:Ee},We=l?YP(pe.running,Y(),t.length):null,rt=Ne=>{Ne.longPressTimer!==null&&(window.clearTimeout(Ne.longPressTimer),Ne.longPressTimer=null)},gt={onPointerDown:Ne=>{Ne.stopPropagation(),Ne.currentTarget.setPointerCapture(Ne.pointerId);const Ge=Ne.pointerId,Ce={pointerId:Ge,originX:Ne.clientX,originY:Ne.clientY,startX:pe.running.x,startY:pe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};Ce.longPressTimer=window.setTimeout(()=>{const H=Be.current;!H||H.pointerId!==Ge||H.mode!=="pressing"||(H.longPressTimer=null,H.mode="dragging",ne.current.running=!0,Ae("dragging"))},VP),Be.current=Ce,Ae("pressing"),Ie(null)},onPointerMove:Ne=>{const Ge=Be.current;if(!Ge||Ge.pointerId!==Ne.pointerId)return;const Ce=Ne.clientX-Ge.originX,H=Ne.clientY-Ge.originY;if(Ge.mode==="pressing")if(Math.abs(Ce)>=bb&&Math.abs(Ce)>=Math.abs(H))rt(Ge),Ge.mode="selecting",ne.current.running=!0,Ae("selecting");else if(Math.hypot(Ce,H)>=bb){rt(Ge),Ge.mode="cancelled",ne.current.running=!0,Ae("idle");return}else return;if(Ge.mode==="selecting"){const Je=We?yb(We,Ne.clientX,Ne.clientY,t.length):null;Ge.selectedIndex=Je,Ie(Je);return}if(Ge.mode!=="dragging"||!Ge.moved&&Math.hypot(Ce,H)<5)return;Ge.moved=!0;const ae=Y(),ye=Le("running",Hc(ae,{x:Ge.startX+Ce,y:Ge.startY+H})),Ve={...ke.current,running:ye};ke.current=Ve,ee(Ve)},onPointerUp:Ne=>{const Ge=Be.current;if(!Ge||Ge.pointerId!==Ne.pointerId)return;rt(Ge);const Ce=Ge.mode;if(Ce==="selecting"){const H=We?yb(We,Ne.clientX,Ne.clientY,t.length):Ge.selectedIndex,ae=H===null?null:t[H]?.id;ae&&xb(ae)}else Ce==="dragging"&&Re("running",Ge,Ne.clientX,Ne.clientY);Be.current=null,Ae("idle"),Ie(null),Ce!=="pressing"&&Pe("running")},onPointerCancel:Ne=>{const Ge=Be.current;!Ge||Ge.pointerId!==Ne.pointerId||(rt(Ge),Be.current=null,Ae("idle"),Ie(null),Pe("running"))}},ue=(Ne,Ge)=>s.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${Ge==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Ne>9?"9+":Ne}),Ye=()=>{const Ne=v.hasOtherAttention?f("serviceAttention.title"):f("agent.jumpToNext"),Ge=pe.attention,Ce=He==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...oe,onClick:H=>{H.stopPropagation(),!ne.current.attention&&(v.hasOtherAttention?C(!0):Q6())},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${Ce?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{display:S?"none":void 0,left:Ge.x,top:Ge.y,width:za,height:za,touchAction:"none"},"aria-label":`${Ne}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:Ne,children:[s.jsx(cc,{size:17,className:"shrink-0"}),ue(v.total,"attention")]},"attention")},at=()=>{const Ne=t.length,Ge=pe.running,Ce=qe==="selecting",H=qe==="dragging";return s.jsxs(L.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":qe,...gt,onClick:ae=>{if(ae.stopPropagation(),ne.current.running)return;const ye=ZP(t,r);ye&&xb(ye)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${H?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":Ce?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:Ge.x,top:Ge.y,width:za,height:za,touchAction:"none"},"aria-label":`${f("agent.jumpToNextRunning")}: ${Ne}`,title:f("agent.runningSessionGestureHint"),children:[s.jsx(_n,{size:18,className:"shrink-0 animate-spin"}),ue(Ne,"running")]}),Ce&&We&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":We.side,"aria-label":f("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:We.left,top:We.top,width:We.width,height:We.height},children:t.map((ae,ye)=>{const Ve=ye===ve,Je=ae.id===r,bt=`${ae.label}${ae.detail?` · ${ae.detail}`:""}${Je?` · ${f("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":Ve,"data-running-session-option":ae.id,"data-selected":Ve?"true":"false",title:bt,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 ${Ve?"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 ${Ve?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:ye+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:ae.label})]},ae.id)})})]},"running")};return!I&&!B&&!S||l===null||typeof document>"u"?null:s.jsxs(B8,{children:[I&&Ye(),B&&!S&&at(),S&&v.active&&w&&s.jsx(RP,{groups:v.groups,currentKey:v.currentKey,onClose:()=>C(!1)})]})}function XP(){const{t:e}=Ur();return s.jsxs("div",{role:"status",className:"td-loading-skeleton overflow-hidden px-3 py-2",children:[s.jsx("span",{className:"sr-only",children:e("common.loading")}),s.jsx("div",{"aria-hidden":"true",children:["w-2/5","w-3/5","w-1/3","w-1/2","w-2/5","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-8 items-center gap-2",style:{paddingLeft:r>1&&r<5?20:0},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},r))})]})}const JP=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"]),vb=120,wb=120,eO=new Set,tO=[],rO={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 Ig(e,t){if(t==="directory")return null;if(O8(e))return s.jsx(PA,{size:14});if(F8(e))return s.jsx(Vy,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return JP.has(r)?s.jsx(dT,{size:14}):s.jsx(Oy,{size:14})}function F6({path:e}){const r=Gt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=rO[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 Eg(e){return qu(e)}const nO=b.memo(function({path:t}){const{t:r}=Ur(),[n,a]=b.useState("idle"),[c,l]=b.useState(null),d=b.useCallback(async f=>{if(f.stopPropagation(),n!=="pending"){a("pending"),l(null);try{await ky(t),a("idle")}catch(m){a("error"),l(m instanceof Error?m.message:r("rightSidebar.downloadFailed"))}}},[t,n,r]);return s.jsx("button",{type:"button",disabled:n==="pending","aria-label":r("rightSidebar.downloadFile"),onClick:f=>{d(f)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${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(_n,{size:12,className:"animate-spin"}):s.jsx(m0,{size:12})})});function $6(){const{t:e}=Ur(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await ky(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 k1(e){return e instanceof DOMException&&e.name==="AbortError"}function Bf(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function U6(e){return e.button===2||e.ctrlKey}const sO=176,iO=160,Dd=8;function Ab(e,t,r,n){const a=window.visualViewport,c=a?.offsetLeft??0,l=a?.offsetTop??0,d=c+(a?.width??window.innerWidth),f=l+(a?.height??window.innerHeight),m=c+Dd,x=l+Dd,y=Math.max(m,d-r-Dd),w=Math.max(x,f-n-Dd),v=t+n<=f-Dd?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 z6(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(Ab(c,l,sO,iO))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=Ab(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 H6(e,t){return t&&typeof document<"u"?Js.createPortal(e,document.body):e}function aO(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function Ng(e,t,r){if(!t||aO(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>Ng(a,t,r)):!1}function L1(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 I1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const oO=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:f,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:S,onOpenInFileBrowser:C,canOpenInFileBrowser:I,pinnedPaths:R,selectedFilePath:B,queryLower:z,onDirectoryDropFiles:O,onFileDeleteRequest:$,deletingFilePath:V,revealedDirectoryPath:Y,gitIgnoreRoot:le}){const{t:be}=Ur(),pe=Gt(wt=>wt.expandedPaths.has(t.path)),ee=Gt(wt=>wt.directoryCache.get(t.path)),ke=Gt(wt=>wt.showHiddenFiles),He=Gt(wt=>wt.toggleExpanded),q=Gt(wt=>wt.setDirectoryCache),ce=Gt(wt=>wt.fileSortModes[t.path]??"name"),qe=Gt(wt=>wt.setDirectorySortMode),[Ae,ve]=b.useState(!1),[Ie,Be]=b.useState(!1),{position:ne,menuRef:Fe,openAt:Le,clearPosition:Re}=z6(Ie),[Pe,Ee]=b.useState(!1),oe=b.useRef(0),We=b.useRef(null),rt=`file-tree-reference:${b.useId()}:${t.path}`;Gc(Fe,Ie&&!!l,()=>Be(!1));const gt=b.useRef(null),ue=t.path===B||t.path===Y,Ye=t.type==="directory"&&(pe||!!z),at=t.type==="directory",Ne=R.has(t.path),Ge=!at&&!!S,Ce=!!(I&&C),H=`path:${t.path}`,ae=m===H||!!l?.paths.has(t.path),ye=x===H,Ve=d?.(t.path)??t.path,Je=$1(f,!!l),{state:bt,run:Vt}=$6(),Pt=V===t.path,mt=at&&!a&&!!(y||w||v||Ce),Zt=b.useMemo(()=>{if(!ee)return;if(!z)return ee;const wt=Gt.getState().directoryCache;return ee.filter(Mt=>(!a||Mt.type==="directory")&&Ng(Mt,z,wt))},[ee,a,z]),Ht=b.useCallback(async()=>{if(!Gt.getState().directoryCache.has(t.path)&&!Ae){const Mt=l?rt:`file-tree:${t.path}`;We.current?.abort(),Um(Mt);const _t=new AbortController;We.current=_t,ve(!0);try{const fr=await Q1(t.path,_t.signal,ke,"expand_directory",Mt,ce,le);if(_t.signal.aborted)return;const qt=L1(fr.entries);q(t.path,qt)}catch(fr){k1(fr)}finally{We.current===_t&&(We.current=null),ve(!1)}}},[t.path,Ae,q,ke,ce,le,!!l,rt]),Kt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const wt=!Gt.getState().expandedPaths.has(t.path);He(t.path),wt&&await Ht()},[a,t.path,t.type,Ht,y,He,n]);b.useEffect(()=>{t.type==="directory"&&pe&&!ee&&!Ae&&Ht()},[ee,pe,Ht,Ae,t.type]);const Ot=b.useCallback(wt=>{wt.stopPropagation(),c?.(t.path,H)},[c,t.path,H]),Nt=b.useCallback(wt=>{wt.stopPropagation(),y?.(t.path),Be(!1)},[t.path,y]),me=b.useCallback(wt=>{wt.stopPropagation(),w?.(t.path),Be(!1)},[t.path,w]),Ze=b.useCallback(wt=>{wt.stopPropagation(),v?.(t.path),Be(!1)},[t.path,v]),ct=b.useCallback(wt=>{wt.stopPropagation(),qe(t.path,ce==="modified"?"name":"modified"),Be(!1)},[t.path,qe,ce]),Tt=b.useCallback(wt=>{wt.stopPropagation(),S?.(t.path),Be(!1)},[t.path,S]),X=b.useCallback(wt=>{wt.stopPropagation(),Be(!1),Vt(t.path)},[t.path,Vt]),yt=b.useCallback(wt=>{wt.stopPropagation(),Be(!1),$(t)},[t,$]),nt=b.useCallback(wt=>{wt.stopPropagation(),C?.(t.path),Be(!1)},[t.path,C]),_e=b.useCallback(wt=>{!at||!O||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),oe.current+=1,Ee(!0))},[at,O]),tr=b.useCallback(wt=>{!at||!O||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),wt.dataTransfer.dropEffect="copy",Ee(!0))},[at,O]),Ke=b.useCallback(wt=>{!at||!O||(wt.preventDefault(),wt.stopPropagation(),oe.current-=1,oe.current<=0&&(oe.current=0,Ee(!1)))},[at,O]),kt=b.useCallback(wt=>{if(!at||!O)return;wt.preventDefault(),wt.stopPropagation(),oe.current=0,Ee(!1);const Mt=Array.from(wt.dataTransfer.files);Mt.length>0&&O(t.path,Mt)},[at,t.path,O]),Ut=b.useCallback(wt=>{wt.stopPropagation(),l?Le(wt.clientX,wt.clientY):Re(),Be(Mt=>!Mt)},[Re,Le,!!l]),vt=b.useCallback(wt=>{!mt||!U6(wt)||(wt.preventDefault(),wt.stopPropagation(),Le(wt.clientX,wt.clientY),Be(!0))},[mt,Le]);return b.useEffect(()=>{if(!Ie)return;const wt=_t=>{const fr=_t.target;fr instanceof Node&&(gt.current?.contains(fr)||Fe.current?.contains(fr))||Be(!1)},Mt=_t=>{_t.key==="Escape"&&Be(!1)};return document.addEventListener("pointerdown",wt),document.addEventListener("keydown",Mt),()=>{document.removeEventListener("pointerdown",wt),document.removeEventListener("keydown",Mt)}},[Ie,Fe]),b.useEffect(()=>()=>{We.current?.abort()},[]),s.jsxs("div",{style:!Ye&&!Ie?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:gt,className:"relative",children:[Je.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":ce,role:"button",tabIndex:0,onClick:()=>{Bf()||Kt()},onContextMenu:vt,onKeyDown:wt=>{wt.target!==wt.currentTarget||wt.key!=="Enter"&&wt.key!==" "||(wt.preventDefault(),Kt())},onDragEnter:_e,onDragOver:tr,onDragLeave:Ke,onDrop:kt,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Pe?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":ue?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[r>0&&s.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:`${r*14-4}px`}}),Pe&&s.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:be("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Ye?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(Xs,{size:14,className:"shrink-0 text-muted-foreground/80"}),Ye?s.jsx(Du,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(Vc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:ue?"text-primary":"text-muted-foreground/80",children:Ig(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${ue?"font-medium":""}`,children:[t.name,ce==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:be("fileTree.sortedByModified"),"aria-label":be("fileTree.sortedByModified"),children:s.jsx(p0,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:be("fileTree.symbolicLink"),children:s.jsx(Uu,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${ue?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:wt=>wt.stopPropagation(),children:[Ae&&s.jsx(_n,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(F6,{path:t.path}),mt&&s.jsx("button",{type:"button",onClick:Ut,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(Ie)} ${Ie?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":be("fileTree.moreDirActions"),"aria-expanded":Ie,title:be("fileTree.moreDirActions"),children:s.jsx(To,{size:13})}),!at&&!l&&s.jsx("button",{type:"button",onClick:Ut,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(Ie||bt.status==="pending"||Pt||Ne)} ${Ie?"bg-surface-elevated text-foreground":Ne?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":be("fileTree.moreFileActions"),"aria-expanded":Ie,title:bt.status==="error"?bt.message??be("rightSidebar.downloadFailed"):be("fileTree.moreFileActions"),children:bt.status==="pending"||Pt?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(To,{size:13})}),c&&s.jsx("button",{type:"button",onClick:Ot,...Je(Ve,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":Eg(ae||ye)} ${ae||ye?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:be(ye?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?ae:void 0,disabled:!!l?.disabled&&!ae,title:l?`${l.label}: ${t.name}`:be(ye?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:ye||ae?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})}),mt&&Ie&&H6(s.jsxs("div",{ref:Fe,className:`${ne?l?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:ne?{left:ne.left,top:ne.top}:void 0,children:[Ce&&s.jsxs("button",{type:"button",onClick:nt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:be("fileTree.openInFileBrowserTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:Nt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:be("fileTree.openDirRootTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.openDirRoot")})]}),w&&s.jsxs("button",{type:"button",onClick: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:be("fileTree.searchFromDirTitle"),children:[s.jsx(U1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Ze,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] ${Ne?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:be(Ne?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ne?s.jsx(x0,{size:13,className:"shrink-0"}):s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(Ne?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:ct,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[ce==="modified"?s.jsx(NA,{size:13,className:"shrink-0"}):s.jsx(p0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(ce==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!ne),!at&&!l&&Ie&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[Ce&&s.jsxs("button",{type:"button",onClick:nt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:be("fileTree.openInFileBrowserTitle"),children:[s.jsx(Oy,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:X,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:be("rightSidebar.downloadFile"),children:[s.jsx(m0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("rightSidebar.downloadFile")})]}),Ge&&s.jsxs("button",{type:"button",onClick:Tt,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] ${Ne?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:be(Ne?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ne?s.jsx(x0,{size:13,className:"shrink-0"}):s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be(Ne?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:yt,disabled:Pt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:be("fileTree.deleteFile"),children:[Pt?s.jsx(_n,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Ms,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:be("fileTree.deleteFile")})]})]})]})]})]}),Ye&&Zt&&Zt.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:Zt.map(wt=>s.jsx(e,{node:wt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:c,referenceSelection:l,getReferenceText:d,onReferenceCopied:f,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:S,onOpenInFileBrowser:C,canOpenInFileBrowser:I,pinnedPaths:R,selectedFilePath:B,queryLower:z,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:O,onFileDeleteRequest:$,deletingFilePath:V,gitIgnoreRoot:le,revealedDirectoryPath:Y},wt.path))})]})}),lO=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,referenceSelection:c,getReferenceText:l,onReferenceCopied:d,insertedReferenceKey:f,copiedReferenceKey:m,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:w,onFilePinToggle:v,pinnedPaths:S,selectedFilePath:C,onFileDeleteRequest:I,deletingFilePath:R}){const{t:B}=Ur(),z=t.path===C,O=t.type==="directory",$=S.has(t.path),V=!O&&!!v,Y=`path:${t.path}`,le=f===Y||!!c?.paths.has(t.path),be=m===Y,pe=l?.(t.path)??t.path,ee=$1(d,!!c),{state:ke,run:He}=$6(),[q,ce]=b.useState(!1),{position:qe,menuRef:Ae,openAt:ve,clearPosition:Ie}=z6(q);Gc(Ae,q&&!!c,()=>ce(!1));const Be=b.useRef(null),ne=R===t.path,Fe=O&&!!(x||y||w),Le=b.useCallback(()=>{Bf()||(t.type==="directory"?x?.(t.path):n(t.path))},[t.path,t.type,x,n]),Re=b.useCallback(ue=>{ue.stopPropagation(),a?.(t.path,Y)},[a,t.path,Y]),Pe=b.useCallback(ue=>{ue.stopPropagation(),w?.(t.path),ce(!1)},[t.path,w]),Ee=b.useCallback(ue=>{ue.stopPropagation(),v?.(t.path),ce(!1)},[t.path,v]),oe=b.useCallback(ue=>{ue.stopPropagation(),ce(!1),He(t.path)},[t.path,He]),We=b.useCallback(ue=>{ue.stopPropagation(),ce(!1),I(t)},[t,I]),rt=b.useCallback(ue=>{ue.stopPropagation(),c?ve(ue.clientX,ue.clientY):Ie(),ce(Ye=>!Ye)},[Ie,ve,!!c]),gt=b.useCallback(ue=>{!Fe||!U6(ue)||(ue.preventDefault(),ue.stopPropagation(),ve(ue.clientX,ue.clientY),ce(!0))},[Fe,ve]);return b.useEffect(()=>{if(!q)return;const ue=at=>{const Ne=at.target;Ne instanceof Node&&(Be.current?.contains(Ne)||Ae.current?.contains(Ne))||ce(!1)},Ye=at=>{at.key==="Escape"&&ce(!1)};return document.addEventListener("pointerdown",ue),document.addEventListener("keydown",Ye),()=>{document.removeEventListener("pointerdown",ue),document.removeEventListener("keydown",Ye)}},[q,Ae]),s.jsxs("div",{ref:Be,className:"relative border-b border-border/10 last:border-b-0",children:[ee.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:Le,onContextMenu:gt,onKeyDown:ue=>{ue.target!==ue.currentTarget||ue.key!=="Enter"&&ue.key!==" "||(ue.preventDefault(),Le())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${z?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx(Vc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:z?"text-primary":"text-muted-foreground/80",children:Ig(t.name,t.type)})]}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsxs("span",{className:`block whitespace-normal break-all font-medium leading-snug ${z?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:B("fileTree.symbolicLink"),children:s.jsx(Uu,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:I1(r,t.path)})]}),s.jsx(F6,{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(q)} ${q?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreDirActions"),"aria-expanded":q,title:B("fileTree.moreDirActions"),children:s.jsx(To,{size:13})}),!O&&!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(q||ke.status==="pending"||ne||$)} ${q?"bg-surface-elevated text-foreground":$?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreFileActions"),"aria-expanded":q,title:ke.status==="error"?ke.message??B("rightSidebar.downloadFailed"):B("fileTree.moreFileActions"),children:ke.status==="pending"||ne?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(To,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Re,...ee(pe,Y),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":Eg(le||be)} ${le||be?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:B(be?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?le:void 0,disabled:!!c?.disabled&&!le,title:c?`${c.label}: ${t.name}`:B(be?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:be||le?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})})]}),Fe&&q&&H6(s.jsxs("div",{ref:Ae,className:`${qe?c?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:qe?{left:qe.left,top:qe.top}:void 0,children:[x&&s.jsxs("button",{type:"button",onClick:ue=>{ue.stopPropagation(),x(t.path),ce(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("fileTree.openDirRootTitle"),children:[s.jsx(Du,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:ue=>{ue.stopPropagation(),y(t.path),ce(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[s.jsx(U1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.searchFromDir")})]}),w&&s.jsxs("button",{type:"button",onClick:Pe,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B($?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[$?s.jsx(x0,{size:13,className:"shrink-0"}):s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B($?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!qe),!O&&!c&&q&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[s.jsxs("button",{type:"button",onClick:oe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("rightSidebar.downloadFile"),children:[s.jsx(m0,{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:Ee,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B($?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[$?s.jsx(x0,{size:13,className:"shrink-0"}):s.jsx(g0,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B($?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:We,disabled:ne,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:B("fileTree.deleteFile"),children:[ne?s.jsx(_n,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Ms,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.deleteFile")})]})]})]})}),cO=60,Tb=60,uO=20;function Sb({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=Ur();return s.jsxs("div",{className:"sticky top-0 z-10 -mx-2 -mt-2 mb-2 border-b border-border/15 bg-surface/95 px-3 py-2.5 backdrop-blur",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 text-[12px] font-semibold text-foreground",children:[s.jsx(U1,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{children:c?l("fileTree.contentMatchesCount",{count:e}):l("fileTree.searchResults",{count:e})})]}),r&&s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[9px] uppercase tracking-[0.12em] text-muted-foreground",children:[t&&s.jsx(_n,{size:9,className:"animate-spin"}),r,n?" · limited":""]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:l("fileTree.searchScope")}),s.jsx("span",{className:"min-w-0 truncate font-mono text-foreground/75",title:a,children:a}),t&&s.jsx("span",{className:"ml-auto shrink-0",children:l("fileTree.searching")})]})]})}function dO(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 hO=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:c,onPathReference:l,referenceSelection:d,getReferenceText:f,onReferenceCopied:m,insertedReferenceKey:x,copiedReferenceKey:y}){const{t:w}=Ur(),[v,S]=b.useState(!0),C=t.path===n,I=v?t.matches.slice(0,uO):[],R=t.matches.length-I.length,B=`path:${t.path}`,z=x===B||!!d?.paths.has(t.path),O=y===B,$=f?.(t.path)??t.path,V=$1(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:()=>{Bf()||S(Y=>!Y)},onKeyDown:Y=>{Y.target!==Y.currentTarget||Y.key!=="Enter"&&Y.key!==" "||(Y.preventDefault(),S(le=>!le))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${C?"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(Xs,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:C?"text-primary":"text-muted-foreground/80",children:Ig(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:I1(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(nO,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Y=>{Y.stopPropagation(),l(t.path,B)},...V($,B),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${d?"ml-1 min-h-11 min-w-11":Eg(z||O)} ${z||O?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":d?`${d.label}: ${t.name}`:w(O?"rightSidebar.copied":z?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":d?z:void 0,disabled:!!d?.disabled&&!z,title:d?`${d.label}: ${t.name}`:w(O?"rightSidebar.copied":z?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:O||z?s.jsx(pi,{size:12}):s.jsx(Uu,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[I.map((Y,le)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Bf()||c?.(t.path,Y.line)},onKeyDown:be=>{be.target!==be.currentTarget||be.key!=="Enter"&&be.key!==" "||(be.preventDefault(),c?.(t.path,Y.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:`${I1(r,t.path)}:${Y.line}`,children:[s.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:Y.line}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:dO(Y.text,a)})]},`${Y.line}-${le}`)),R>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:R})})]})]})});function fO({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:f,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:S=!1,pinnedPaths:C=eO,selectedFilePath:I,query:R="",searchRootPath:B,searchOptions:z={},searchMode:O="name",onContentMatchSelect:$,onDirectoryDropFiles:V,revealDirectory:Y}){const{t:le}=Ur(),be=b.useId(),pe=a?`file-tree-reference-root:${be}:${e}`:`file-tree-root:${e}`,ee=Gt(nt=>e?nt.directoryCache.get(e):void 0),ke=Gt(nt=>nt.setDirectoryCache),He=Gt(nt=>nt.showHiddenFiles),q=Gt(nt=>nt.fileSortModesHydrated),ce=Gt(nt=>nt.fileSortModes[e]??"name"),qe=Gt(nt=>nt.hydrateFileSortModes),Ae=Gt(nt=>nt.hydrateHideGitIgnoredRoots),ve=Gt(nt=>!!nt.hideGitIgnoredRoots[e]),Ie=Gt(nt=>nt.hideGitIgnoredRootsHydrated),Be=Gt(nt=>JSON.stringify(nt.gitIgnoreExceptions[e]??[])),ne=Gt(nt=>nt.invalidateDirectoryCache),Fe=`${e}:${ve}:${Be}`,[Le,Re]=b.useState("");b.useLayoutEffect(()=>{e&&ne(e,!0),Re(Fe)},[e,ve,Be,ne,Fe]);const[Pe,Ee]=b.useState(!1),[oe,We]=b.useState(null),[rt,gt]=b.useState(!1),[ue,Ye]=b.useState(!1),[at,Ne]=b.useState(null),[Ge,Ce]=b.useState(q&&Ie),H=q&&Ie||Ge;b.useEffect(()=>{let nt=!1;return Promise.all([qe(),Ae()]).catch(()=>{}).finally(()=>{nt||Ce(!0)}),()=>{nt=!0}},[qe,Ae]);const[ae,ye]=b.useState([]),[Ve,Je]=b.useState(null),[bt,Vt]=b.useState(vb),[Pt,mt]=b.useState([]),[Zt,Ht]=b.useState(null),Kt=b.useRef(null),Ot=b.useRef(0),Nt=R.trim().toLowerCase(),me=O==="content",Ze=B||e,ct=z.excludePatterns??tO,Tt=ct.join(`
|
|
137
|
-
`);b.useEffect(()=>{const nt=Y?.path;if(!nt||!nt.startsWith(`${e}/`)&&nt!==e)return;const _e=nt.slice(e.length).replace(/^\/+/,""),tr=_e?_e.split("/"):[],Ke=tr.map((fr,qt)=>`${e}/${tr.slice(0,qt+1).join("/")}`),kt=Gt.getState(),Ut=Ke.filter(fr=>!kt.expandedPaths.has(fr));Ut.length>0&&Gt.setState(fr=>({expandedPaths:new Set([...fr.expandedPaths,...Ut])}));let vt=!1,wt=0;const Mt=()=>{if(vt)return;const fr=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(qt=>qt.dataset.fileTreePath===nt);if(fr){fr.scrollIntoView({block:"center",behavior:"smooth"});return}wt+=1,wt<80&&window.setTimeout(Mt,50)},_t=window.requestAnimationFrame(Mt);return()=>{vt=!0,window.cancelAnimationFrame(_t)}},[Y?.nonce,Y?.path,e]);const X=b.useCallback(async nt=>{if(!(Zt||nt.type==="directory")&&window.confirm(le("fileTree.deleteFileConfirm",{name:nt.name}))){Ht(nt.path);try{await Q8(nt.path),Gt.getState().applyFileWatchEvents([{type:"deleted",path:nt.path}]),ye(_e=>_e.filter(tr=>tr.path!==nt.path)),mt(_e=>_e.filter(tr=>tr.path!==nt.path)),C.has(nt.path)&&w?.(nt.path)}catch(_e){const tr=_e instanceof Error?_e.message:String(_e);window.alert(le("fileTree.deleteFileFailed",{message:tr}))}finally{Ht(null)}}},[Zt,w,C,le]);b.useEffect(()=>{if(!e||!H||Le!==Fe)return;if(Nt){Ee(!1);return}if(Gt.getState().directoryCache.has(e)){Ee(!1);return}let nt=!1;const _e=new AbortController;return Ee(!0),We(null),Q1(e,_e.signal,He,"load_file_tree_root",pe,ce,e).then(tr=>{if(nt)return;const Ke=L1(tr.entries);gt(!!tr.truncated),ke(e,Ke)}).catch(tr=>{nt||k1(tr)||We(tr instanceof Error?tr.message:"Failed to load directory")}).finally(()=>{nt||Ee(!1)}),()=>{nt=!0,_e.abort(),Um(pe)}},[Nt,ee,e,ce,ke,He,H,ve,Be,pe,Le,Fe]),b.useEffect(()=>{if(!Ze||!Nt){Ye(!1),Ne(null),ye([]),mt([]),Je(null);return}let nt=!1;const _e=new AbortController,tr=new Set;Ye(!0),Ne(null),ye([]),mt([]),Vt(me?cO:vb),Je({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const Ke=`file-search:${a?be+":":""}${Ze}:${++Ot.current}`;return P8(Ze,R.trim(),kt=>{if(!nt){if(kt.engine&&Je(Ut=>({truncated:Ut?.truncated??!1,total:Ut?.total??0,engine:kt.engine,limited:kt.limited??Ut?.limited??!1,done:Ut?.done??!1})),kt.entries?.length){const Ut=kt.entries.filter(vt=>tr.has(vt.path)?!1:(tr.add(vt.path),!0));Ut.length>0&&(ye(vt=>[...vt,...L1(Ut)]),Je(vt=>vt?{...vt,total:tr.size}:{truncated:!1,total:tr.size,engine:"rg",limited:!1,done:!1}))}if(kt.contentEntries?.length){const Ut=kt.contentEntries.filter(vt=>tr.has(vt.path)?!1:(tr.add(vt.path),!0));Ut.length>0&&(mt(vt=>[...vt,...Ut]),Je(vt=>vt?{...vt,total:tr.size}:{truncated:!1,total:tr.size,engine:"rg",limited:!1,done:!1}))}kt.done&&Je(Ut=>({truncated:!!kt.truncated,total:typeof kt.total=="number"?kt.total:tr.size,engine:kt.engine??Ut?.engine??"rg",limited:!!kt.limited,done:!0}))}},_e.signal,He,O,Ke,{excludePatterns:ct,caseSensitive:z.caseSensitive,wholeWord:z.wholeWord,regex:z.regex}).catch(kt=>{nt||k1(kt)||(Ne(kt instanceof Error?kt.message:"Failed to search files"),ye([]),mt([]),Je(null))}).finally(()=>{nt||Ye(!1)}),()=>{nt=!0,_e.abort(),Um(Ke)}},[Ze,Tt,me,R,Nt,O,z.caseSensitive,z.regex,z.wholeWord,He,!!a,be]),b.useEffect(()=>{if(!Nt)return;const nt=Kt.current;if(!nt)return;const _e=me?Pt.length:ae.length,tr=me?Tb:wb,Ke=new IntersectionObserver(kt=>{kt.some(Ut=>Ut.isIntersecting)&&Vt(Ut=>Math.min(Ut+tr,_e))},{rootMargin:"160px 0px"});return Ke.observe(nt),()=>Ke.disconnect()},[Nt,ae.length,Pt.length,me]);const yt=b.useMemo(()=>{if(!ee)return;if(!Nt)return r?ee.filter(_e=>_e.type==="directory"):ee;const nt=Gt.getState().directoryCache;return ee.filter(_e=>(!r||_e.type==="directory")&&Ng(_e,Nt,nt))},[r,Nt,ee]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noWorkingDir")});if(Pe||!H)return s.jsx(XP,{});if(Nt&&me){const nt=Ve?.total??Pt.length,_e=Pt.slice(0,bt),tr=bt<Pt.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Sb,{count:nt,loading:ue,engine:Ve?.engine,limited:Ve?.limited,scope:Ze,content:!0}),at?s.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[le("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:at})]}):ue&&Pt.length===0?s.jsx(h0,{label:le("fileTree.searching"),className:"py-8"}):Pt.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[Ve?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:le("fileTree.searchTruncatedHint",{count:Ve.total})}),_e.map(Ke=>s.jsx(hO,{entry:Ke,rootPath:Ze,selectedFilePath:I,query:R.trim(),onContentMatchSelect:$,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:d,copiedReferenceKey:f},Ke.path)),s.jsx("div",{ref:Kt,className:"py-2 text-center text-[11px] text-muted-foreground",children:tr?s.jsx("button",{type:"button",onClick:()=>Vt(Ke=>Math.min(Ke+Tb,Pt.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:_e.length,total:Pt.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(_n,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):_e.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:_e.length,total:nt})}):null})]})]})}if(Nt){const nt=Ve?.total??ae.length,_e=ae.slice(0,bt),tr=bt<ae.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(Sb,{count:nt,loading:ue,engine:Ve?.engine,limited:Ve?.limited,scope:Ze,content:!1}),ue&&ae.length===0?s.jsx(h0,{label:le("fileTree.searching"),className:"py-8"}):at?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:at}):ae.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[Ve?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:le("fileTree.searchTruncatedHint",{count:Ve.total})}),_e.map(Ke=>s.jsx(lO,{node:Ke,rootPath:Ze,onFileSelect:t,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,pinnedPaths:C,selectedFilePath:I,insertedReferenceKey:d,copiedReferenceKey:f,onFileDeleteRequest:X,deletingFilePath:Zt},Ke.path)),s.jsx("div",{ref:Kt,className:"py-2 text-center text-[11px] text-muted-foreground",children:tr?s.jsx("button",{type:"button",onClick:()=>Vt(Ke=>Math.min(Ke+wb,ae.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:_e.length,total:ae.length})}):ue?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(_n,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):_e.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:_e.length,total:nt})}):null})]})]})}return oe?s.jsx("div",{role:a?"alert":void 0,className:"px-4 py-4 text-sm text-destructive",children:oe}):!ee||ee.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.emptyDir")}):!yt||yt.length===0?s.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[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:le("fileTree.truncatedHint")}),yt.map(nt=>s.jsx(oO,{node:nt,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:C,selectedFilePath:I,queryLower:Nt,insertedReferenceKey:d,copiedReferenceKey:f,onDirectoryDropFiles:V,onFileDeleteRequest:X,deletingFilePath:Zt,revealedDirectoryPath:Y?.path},nt.path))]})}function E1(e){return e.trim().replace(/\/+$/,"")||"/"}function pO(e){const t=E1(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function sp({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:c}){const{t:l}=Ur(),d={hint:n?.hint??l("sidebar.directoryPickerHint"),cancel:n?.cancel??l("common.cancel"),confirm:n?.confirm??l("sidebar.useThisFolder"),close:n?.close??l("common.close"),parent:n?.parent??l("rightSidebar.parentFolder")},f=b.useRef(null);Gc(f,e,a);const[m,x]=b.useState(()=>E1(t));return b.useEffect(()=>{e&&x(E1(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?Js.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:a,"aria-label":d.cancel}),s.jsxs("section",{ref:f,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(bT,{size:15})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:r}),s.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:d.hint})]}),s.jsx("button",{type:"button",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":d.close,children:s.jsx(In,{size:15})})]}),s.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:m==="/",onClick:()=>x(pO(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(By,{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(fO,{rootPath:m,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:x,selectedFilePath:t||null})}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[s.jsx("button",{type:"button",onClick:a,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:d.cancel}),s.jsxs("button",{type:"button",onClick:()=>c(m),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[s.jsx(pi,{size:13}),d.confirm]})]})]})]}),document.body):null}const mO=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:sp},Symbol.toStringTag,{value:"Module"})),N1="termdock:new-session-commands:v1",ac="__saved_command__:";function kh(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(ac)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function Bd(){try{const e=JSON.parse(localStorage.getItem(N1)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function gO({directories:e,tmuxAvailable:t,options:r,agents:n,selectedAgent:a,detecting:c,resumeHistory:l,resumeHistoryLoading:d,resumeHistoryPendingId:f,resumeHistoryError:m,onRefreshAgents:x,onSelectAgent:y,onLaunchAgent:w,onResumeHistory:v,onRemoveResumeHistory:S,onClose:C,onOptionsChange:I,additionalContent:R,footerActions:B,launchPending:z=!1,launchError:O}){const{t:$,locale:V}=Ur(),Y=b.useRef(null);Gc(Y,!0,C,()=>document.querySelector('[aria-controls="sidebar-launch-options"]'));const[le,be]=b.useState(a),[pe,ee]=b.useState(!1),[ke,He]=b.useState(!1),[q,ce]=b.useState(Bd),[qe,Ae]=b.useState(()=>kh(Bd())),[ve,Ie]=b.useState(null),[Be,ne]=b.useState("idle"),Fe=ke?"__custom__":le?.slug??"__terminal__",Le=le?.command??"",Re=ke?q.__custom__??q.__terminal__??"":le?q[Fe]??Le:"",Pe=()=>{const Ce=Re.trim()||Le;if(!(ke&&!Ce))try{const H={...Bd(),[Fe]:Ce};if(ke){for(const ae of kh(Bd()))H[ac+ae]=ae;H[ac+Ce]=Ce}localStorage.setItem(N1,JSON.stringify(H)),Ae(kh(H)),ke&&Ie(Ce),ne("saved")}catch{ne("error")}},Ee=()=>{if(ve)try{const Ce=Bd();for(const[H,ae]of Object.entries(Ce))(H.startsWith(ac)||H==="__custom__"||H==="__terminal__")&&ae.trim()===ve&&delete Ce[H];localStorage.setItem(N1,JSON.stringify(Ce)),Ae(kh(Ce)),ce(H=>({...H,__custom__:""})),Ie(null),ne("idle")}catch{ne("error")}},oe=()=>{const Ce=Re.trim()||Le;z||ke&&!Ce||(Pe(),w(le,Ce))},We=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),rt=ke?ve?ac+ve:"__custom__":le?.slug??"__terminal__",gt=Ce=>{ne("idle");const H=Ce.startsWith(ac)?Ce.slice(ac.length):null;Ie(H),He(Ce==="__custom__"||H!==null),(H!==null||Ce==="__custom__")&&ce(ae=>({...ae,__custom__:H??""})),be(n.find(ae=>ae.slug===Ce)??null)},ue=ke?ve??$("sidebar.customStartupCommand"):le?.displayName??"Terminal",Ye=a?.displayName??"Terminal",at=!ke&&(le===null?a===null:a?.slug===le.slug);b.useEffect(()=>{if(pe)return;const Ce=H=>{H.target instanceof Node&&(Y.current?.contains(H.target)||H.target instanceof Element&&H.target.closest("[data-sidebar-composer-popover]")?.getAttribute("data-sidebar-composer-popover")===Y.current?.id||H.target instanceof Element&&H.target.closest('[aria-controls="sidebar-launch-options"]')||C())};return document.addEventListener("pointerdown",Ce,!0),()=>document.removeEventListener("pointerdown",Ce,!0)},[pe,C]);const Ne=Ce=>{I({...r,cwd:Ce}),ee(!1)},Ge=Ce=>new Intl.DateTimeFormat(V==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(Ce));return s.jsxs("section",{ref:Y,tabIndex:-1,"aria-busy":z,id:"sidebar-launch-options",className:`absolute inset-x-3 bottom-3 z-30 flex flex-col overflow-hidden rounded-2xl border border-border bg-surface shadow-[0_18px_50px_var(--app-shadow-strong),0_4px_14px_var(--app-shadow-soft)] animate-slide-down ${B?"max-h-[min(70svh,42rem,calc(100%_-_4.5rem))]":"max-h-[min(56svh,36rem,calc(100%_-_4.5rem))]"}`,"aria-label":$("sidebar.newSessionComposerTitle"),children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground",children:s.jsx($o,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:$("sidebar.newSessionComposerTitle")})})]}),s.jsx("button",{type:"button",onClick:C,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":$("common.close"),children:s.jsx(In,{size:14})})]}),s.jsxs("fieldset",{disabled:z,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain border-0 px-3 pb-1",children:[s.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:$("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(Ce=>s.jsx("button",{type:"button",disabled:Ce==="tmux"&&!t,onClick:()=>I({...r,mode:Ce}),"aria-pressed":r.mode===Ce,title:Ce==="tmux"?$(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===Ce?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:$(Ce==="shell"?"sidebar.newShell":"sidebar.newTmux")},Ce))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:$("sidebar.startupCommand")}),s.jsx("button",{type:"button",onClick:x,disabled:c,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground disabled:opacity-50",title:$("sidebar.detectAgents"),"aria-label":$("sidebar.detectAgents"),children:s.jsx(bn,{size:12,className:c?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":$("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(Ce=>{const H=!ke&&le?.slug===Ce.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>gt(Ce.slug),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${H?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Wc,{agent:Ce,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:Ce.displayName}),a?.slug===Ce.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:$("sidebar.defaultAgent")})]},Ce.slug)}),qe.map(Ce=>{const H=ke&&ve===Ce;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>gt(ac+Ce),title:Ce,className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 transition ${H?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Qc,{size:10,className:"shrink-0"}),s.jsx("span",{className:"max-w-[9rem] truncate font-mono text-[10px]",children:Ce})]},Ce)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__terminal__",onClick:()=>gt("__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($o,{size:11,className:"shrink-0"}),s.jsx("span",{children:"Terminal"}),a===null&&s.jsx("span",{className:"ml-0.5 text-[9px] font-normal text-muted-foreground",children:$("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__custom__",onClick:()=>gt("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${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(zs,{size:10,className:"shrink-0"}),s.jsx("span",{children:$("sidebar.addStartupCommand")})]})]}),!at&&!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:$("sidebar.currentDefaultAgent",{name:Ye})}),s.jsx("button",{type:"button",onClick:()=>y(le),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:$("sidebar.makeDefault")})]}),Be==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:$("sidebar.saveStartupCommandFailed")}),(le||ke)&&s.jsxs("details",{open:ke&&!ve||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:[$(ke&&!ve?"sidebar.customStartupCommand":"sidebar.changeStartupCommand"),s.jsx(ul,{size:11,className:"transition-transform group-open/command:rotate-180"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx("label",{htmlFor:"new-session-command",className:"sr-only",children:$("sidebar.startupCommand")}),le&&Re!==Le&&s.jsx("button",{type:"button",onClick:()=>{ce(Ce=>({...Ce,[Fe]:Le})),ne("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:$("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:Re,onChange:Ce=>{ce(H=>({...H,[Fe]:Ce.target.value})),ne("idle")},placeholder:Le||$("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&&ve&&s.jsxs("button",{type:"button",onClick:Ee,className:"mr-auto inline-flex min-h-9 items-center gap-1 rounded-md px-2 text-[10px] text-muted-foreground transition hover:text-destructive","aria-label":$("sidebar.deleteStartupCommand"),children:[s.jsx(Ms,{size:11}),$("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:Pe,disabled:Be==="saved"||ke&&!Re.trim(),className:"min-h-8 rounded-md px-2 text-[10px] font-medium text-primary transition hover:bg-primary/10 disabled:cursor-default disabled:opacity-50",children:$(Be==="saved"?"sidebar.startupCommandSaved":"sidebar.saveStartupCommand")})]}),s.jsx("p",{className:"mb-2 mt-1.5 px-0.5 text-[10px] leading-relaxed text-muted-foreground",children:$(le?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},ve??Fe),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:$("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>ee(!0),className:"mt-1 flex min-h-11 w-full items-center gap-2 rounded-lg border border-transparent bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary",children:[s.jsx(Vc,{size:12,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${r.cwd?"":"text-muted-foreground"}`,children:r.cwd||$("sidebar.directoryPlaceholder")})]}),We.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":$("sidebar.recentDirectories"),children:We.map(Ce=>s.jsx("button",{type:"button",onClick:()=>Ne(Ce),title:Ce,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:Yu(Ce)||Ce},Ce))}),(l.length>0||m)&&s.jsxs("details",{className:"mt-1",children:[s.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[s.jsx(Qc,{size:11}),s.jsx("span",{className:"flex-1",children:$("sidebar.resumeHistory")}),d&&s.jsx(_n,{size:10,className:"animate-spin"}),l.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:$("sidebar.resumeHistoryCount",{n:l.length})}),s.jsx(ul,{size:11})]}),l.length>0&&s.jsx("div",{className:"mt-1 divide-y divide-border overflow-hidden rounded-lg border border-border bg-surface",children:l.slice(0,6).map(Ce=>{const H=f===Ce.id;return s.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[s.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>v(Ce),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":$("sidebar.resumeHistoryAction",{title:Ce.title}),children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:H?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(Wc,{agent:Ce.agent,size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:Ce.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[Ce.agent.displayName," · ",Ge(Ce.closedAt)]})]}),s.jsx(Hy,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>S(Ce.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":$("sidebar.resumeHistoryRemove",{title:Ce.title}),children:[s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),s.jsx(Ms,{size:12})]})]},Ce.id)})}),m&&s.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:m})]}),R]}),s.jsxs("div",{className:"shrink-0 bg-surface px-3 pb-3 pt-2",children:[O&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:O}),s.jsxs("button",{type:"button",onClick:oe,disabled:z||ke&&!Re.trim(),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground transition hover:brightness-110 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40","aria-label":$("sidebar.launchSessionWith",{name:ue}),children:[z?s.jsx(_n,{size:14}):le?s.jsx(Wc,{agent:le,size:15}):s.jsx($o,{size:14}),s.jsx("span",{className:"truncate",children:z?$("sidebar.sessionCreating"):$("sidebar.launchSessionWith",{name:ue})})]}),B]}),s.jsx(sp,{open:pe,initialPath:r.cwd?.trim()||We[0]||"/",title:$("sidebar.chooseDirectory"),onCancel:()=>ee(!1),onConfirm:Ne})]})}const W6="termdock:new-session-agent:v1";function xO(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(W6)||"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 Sm(e){if(!(typeof window>"u"))try{window.localStorage.setItem(W6,JSON.stringify(e))}catch{}}function bO(e,t){return e?t.find(r=>r.slug===e)??null:null}function yO(){const[e,t]=b.useState(xO),[r,n]=b.useState([]),[a,c]=b.useState(!0),l=b.useCallback(async()=>{c(!0);try{const[f,m]=await Promise.all([fc(),Ly()]),x=bO(f.newSessionAgentSlug,m);n(m),t(x),Sm(x)}finally{c(!1)}},[]);b.useEffect(()=>{const f=()=>{l().catch(()=>{})};if(performance.getEntriesByName("termdock:startup:initial-viewport-presented").length>0){f();return}return window.addEventListener("termdock:initial-viewport-presented",f,{once:!0}),()=>window.removeEventListener("termdock:initial-viewport-presented",f)},[l]);const d=b.useCallback(async f=>{const m=e;t(f),Sm(f);try{await La({newSessionAgentSlug:f?.slug??null})}catch(x){throw t(m),Sm(m),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:l,selectAgent:d}}function vO({groups:e,sessions:t,busy:r,onOpen:n,onSettings:a,onCreate:c}){const[l,d]=b.useState(""),f=e.filter(m=>!l.trim()||`${m.name} ${m.sessionIds.map(x=>t.find(y=>y.sessionId===x)?.name??"").join(" ")}`.toLowerCase().includes(l.trim().toLowerCase()));return s.jsxs("section",{"aria-label":"协作组列表",className:"space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("p",{className:"text-xs leading-6 text-muted-foreground",children:"成员消息用于日常交流;看板用于目标、交付与验收。"}),s.jsxs("button",{type:"button",disabled:r,className:"inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground disabled:opacity-40",onClick:c,children:[s.jsx(zs,{size:14}),"新建协作组"]})]}),(e.length>5||l)&&s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"搜索协作组"}),s.jsx(jl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"search",value:l,onChange:m=>d(m.target.value),placeholder:"搜索组名或成员",className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 py-2 pl-9 pr-3 text-xs text-foreground outline-none focus:border-primary/60"})]}),s.jsxs("div",{className:"divide-y divide-border/15 rounded-xl border border-border/15",children:[f.map(m=>{const x=m.sessionIds.flatMap(y=>{const w=t.find(v=>v.sessionId===y);return w?[w]:[]});return s.jsxs("article",{"aria-label":m.name,className:"p-3 sm:flex sm:items-center sm:gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"break-words text-sm font-medium leading-6 text-foreground",children:m.name}),s.jsx("p",{className:"mt-1 break-words text-[11px] leading-5 text-muted-foreground",children:m.sessionIds.length?`${m.sessionIds.length} 位成员${x.length?` · ${x.slice(0,2).map(y=>Iu(y,x)).join("、")}${x.length>2?"等":""}`:""}`:"尚未添加成员,可以稍后配置"})]}),s.jsxs("div",{className:"mt-2 flex shrink-0 items-center gap-1 sm:mt-0",children:[s.jsxs("button",{type:"button","aria-label":`成员消息:${m.name}`,disabled:r,className:"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg bg-surface-2 px-3 text-xs text-foreground hover:bg-surface-elevated disabled:opacity-40",onClick:()=>n(m.id,"messages"),children:[s.jsx(Zu,{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(IT,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-label":`设置:${m.name}`,title:"组设置",disabled:r,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2 disabled:opacity-40",onClick:y=>a(m.id,y.currentTarget),children:s.jsx(ju,{size:14})})]})]},m.id)}),!f.length&&s.jsx("p",{className:"px-3 py-6 text-xs text-muted-foreground",children:"没有匹配的协作组,试试其他名称。"})]})]})}const jc="min-h-11 w-full rounded-lg border border-border/20 bg-surface px-3 py-2 text-xs text-foreground outline-none focus:border-primary",Lh="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-xs disabled:opacity-40",Ih=e=>({profiles:e.launchProfiles??[],defaultId:e.defaultLaunchProfileId??"",group:e}),Cm=new Map,Qd=e=>JSON.stringify(e.profiles)!==JSON.stringify(e.group.launchProfiles??[])||e.defaultId!==(e.group.defaultLaunchProfileId??"");function wO({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 AO({group:e,agents:t,busy:r,setBusy:n,refresh:a}){const c=`${window.location.origin}:${e.id}`,[l,d]=b.useState(()=>Cm.get(c)??Ih(e)),f=b.useRef(l);f.current=l;const[m,x]=b.useState(l.profiles[0]?.id??""),[y,w]=b.useState(null),[v,S]=b.useState(""),C=($,V=!0)=>{f.current=$,d($),Qd($)?Cm.set(c,$):Cm.delete(c),V&&S("")};b.useEffect(()=>{!Qd(f.current)&&e.updatedAt>=f.current.group.updatedAt&&C(Ih(e),!1)},[e.updatedAt]);const I=l.profiles.find($=>$.id===m),R=$=>C({...l,profiles:l.profiles.map(V=>V.id===m?{...V,...$}:V)}),B=l.profiles.every($=>$.name.trim()&&$.agentSlug&&$.command.trim()&&!/[\x00-\x1f\x7f]/.test($.command)),z=()=>{const $=t[0],V={id:`profile-${crypto.randomUUID()}`,name:"",agentSlug:$?.slug??"",command:$?.command??"",notes:""};C({...l,profiles:[...l.profiles,V]}),x(V.id)},O=async()=>{if(!(r||!B||!Qd(l))){n("launch-profiles"),w(null),S("");try{const{group:$}=await Ml({id:e.id,name:l.group.name,sessionIds:l.group.sessionIds,expectedUpdatedAt:l.group.updatedAt,launchProfiles:l.profiles,defaultLaunchProfileId:l.defaultId||null});C(Ih($)),S("启动方案已保存。新会话使用所选方案,正在运行的成员保持原配置。"),await a()}catch($){w($ instanceof Error?$.message:"保存失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-3 border-t border-border/15 pt-2",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:["Agent 启动方案 · ",l.profiles.length," 个",Qd(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:$=>C({...l,defaultId:$.target.value}),children:[s.jsx("option",{value:"",children:"使用 Agent 默认命令"}),l.profiles.map($=>s.jsx("option",{value:$.id,children:$.name||"未命名方案"},$.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:["编辑方案",s.jsxs("select",{"aria-label":"编辑方案",className:`${jc} mt-1`,value:m,onChange:$=>x($.target.value),children:[s.jsx("option",{value:"",children:"选择方案"}),l.profiles.map($=>s.jsx("option",{value:$.id,children:$.name||"未命名方案"},$.id))]})]}),s.jsxs("button",{type:"button",className:`${Lh} self-end bg-surface text-foreground`,disabled:l.profiles.length>=20,onClick:z,children:[s.jsx(zs,{size:14}),"新增方案"]})]}),I?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:I.name,maxLength:100,onChange:$=>R({name:$.target.value}),placeholder:"例如:快速排查、深度实现"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["Agent 类型",s.jsxs("select",{"aria-label":"Agent 类型",className:jc,value:I.agentSlug,onChange:$=>R({agentSlug:$.target.value,command:t.find(V=>V.slug===$.target.value)?.command??""}),children:[!t.some($=>$.slug===I.agentSlug)&&s.jsxs("option",{value:I.agentSlug,children:[I.agentSlug||"选择 Agent","(当前不可用)"]}),t.map($=>s.jsx("option",{value:$.slug,children:$.displayName},$.slug))]})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动命令",s.jsx("input",{className:`${jc} font-mono`,value:I.command,maxLength:4096,onChange:$=>R({command:$.target.value}),placeholder:"填写完整命令,包括模型和启动参数"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["使用备注",s.jsx("textarea",{"aria-label":"使用备注",className:`${jc} min-h-24 resize-y`,value:I.notes,maxLength:2e3,onChange:$=>R({notes:$.target.value}),placeholder:"适合哪些任务、何时不要使用;协调者会读取这些备注。"})]}),s.jsxs("details",{className:"text-[11px] text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3",children:"CLI 方案标识"}),s.jsx("code",{className:"break-all",children:I.id})]}),s.jsxs("button",{type:"button",className:`${Lh} text-destructive hover:bg-destructive/10`,onClick:()=>{const $=l.profiles.filter(V=>V.id!==m);C({...l,profiles:$,defaultId:l.defaultId===m?"":l.defaultId}),x($[0]?.id??"")},children:[s.jsx(Ms,{size:14}),"移除方案(保存后生效)"]})]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:"尚未选择方案。新增后可填写模型、参数和备注。"})]}),y&&s.jsxs("p",{role:"alert",className:"text-xs leading-5 text-destructive",children:[y,"。草稿已保留;重新载入会放弃草稿。"]}),v&&s.jsx("p",{role:"status",className:"text-xs leading-5 text-primary",children:v}),s.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[s.jsx("button",{type:"button",className:`${Lh} bg-surface text-muted-foreground`,disabled:!!r,onClick:()=>{C(Ih(e)),x(e.launchProfiles?.[0]?.id??""),w(null)},children:"重新载入(放弃方案草稿)"}),s.jsx("button",{type:"button",disabled:!!r||!B||!Qd(l),className:`${Lh} bg-primary text-primary-foreground`,onClick:()=>{O()},children:r==="launch-profiles"?"保存中…":"保存启动方案"})]})]})]})}function G6(e,t=[]){const r=(t.length?t:e.children??[]).filter(C=>C.status!=="closed"),n=r.filter(C=>C.status==="accepted").length,a=Xc(e),c=e.events.filter(C=>C.kind==="revise"&&C.attemptId===e.activeAttemptId).at(-1),l=e.artifacts.filter(C=>C.kind==="result"&&C.attemptId===e.activeAttemptId).at(-1),d=!!c&&(!l||c.createdAt>=l.createdAt),f=Mf(e),m=e.attempts.find(C=>C.id===e.activeAttemptId)?.report,x=C=>C?.summarySource==="explicit"||C?.summarySource!=="excerpt"&&!!C?.summary?.trim(),y=e.events.filter(C=>C.kind==="coordinate"&&C.attemptId===e.activeAttemptId&&(!c||C.sequence>c.sequence)).at(-1),w=[...f?.createdAt&&(!c||f.createdAt>c.createdAt)?[{summary:f.summary,createdAt:f.createdAt,source:"成员报告",explicit:x(m),taskId:e.id,title:e.title}]:[],...y?[{summary:y.summary||y.content,createdAt:y.createdAt,source:"协调说明",explicit:!!y.summary?.trim(),taskId:e.id,title:e.title}]:[],...d?[]:t.filter(C=>C.status!=="closed").flatMap(C=>{const I=Mf(C);return I?.createdAt?[{summary:I.summary,createdAt:I.createdAt,source:"执行报告",explicit:x(C.attempts.find(R=>R.id===C.activeAttemptId)?.report),taskId:C.id,title:C.title}]:[]})].filter(C=>C.summary.trim()&&Number.isFinite(C.createdAt)&&Number.isFinite(new Date(C.createdAt).getTime())).sort((C,I)=>I.createdAt-C.createdAt);let v=a,S="分派和报告会保存在这里;终端输出不能代替明确的任务报告。";return e.workflow?.kind==="goal"&&(e.status==="accepted"?(v="已完成 · 你已验收",S="结果与执行记录已保留;追加要求可以继续跟进。"):e.status==="closed"?S="此目标已关闭,已有报告仍保留。":Ui(e)||e.workflow.paused||l?S=a==="等待你验收"?"总结果已交付;查看结论后验收,或提出继续跟进。":a==="等待独立评审"?"总结果已提交,独立评审通过后交给你验收。":a==="需要你回答"?"回答当前问题后,成员可以继续原来的工作。":a==="需要你确认方案"?"确认这项必要决定后再继续;普通拆分不需要逐项批准。":d?"沿用原目标推进追加要求;上一版结果不代表本轮完成。":e.workflow.paused?"自动安排已暂停,恢复后才能继续安排后续工作。":"查看记录的阻塞原因,补充条件或重试;已有交付保留。":d?(v="已提出跟进 · 等待新报告",S="沿用原目标推进追加要求;旧报告保留为历史,等待本轮明确更新。"):r.length?(v=n===r.length?"执行交付已评审 · 等待总结果":"工作已拆分 · 执行与评审",S=n===r.length?"执行事项已交付评审,下一步由协调者汇总总结果,再交给你验收。":`已记录 ${r.length} 项工作,${n} 项交付已评审,${r.length-n} 项尚待交付或评审。`):f?(v=f.status==="ack"?"协调者已接手 · 等待拆分记录":a,S="尚未记录执行事项;协调者需说明工作划分、交付内容和下一步。"):S=a==="已写入终端 · 等待回复"?"目标已写入协调者终端,等待明确接手和拆分说明。":"目标已保存,等待分派、投递和协调者明确回复。"),{label:v,next:S,latest:w[0]??null,total:r.length,done:n}}function TO(e,t){const r=e.dependsOn.filter(n=>t.find(a=>a.id===n)?.status!=="accepted");return r.length?`等待依赖:${r.map(n=>t.find(a=>a.id===n)?.title??"记录尚未同步").join("、")}`:e.dependsOn.length?"依赖交付已评审,可以接续":""}function V6(e){return e.explicit?e.summary:e.source==="协调说明"?"协调者已更新工作安排。此记录未提供简短摘要,详情保留原始说明。":`「${e.title}」有新的明确报告。此记录未提供简短摘要,详情保留原文。`}function Cb(e,t=!1,r=""){e=e.filter(d=>d.purpose!=="automation");const n=new Map(e.map(d=>[d.id,d])),a=d=>n.get(d.parentTaskId??d.workflow?.rootTaskId??""),c=d=>{const f=[];let m=d;for(;;){const x=f.findIndex(w=>w.id===m.id);if(x!==-1)return f.slice(x).sort((w,v)=>w.id.localeCompare(v.id))[0];f.push(m);const y=a(m);if(!y||y.status==="closed"&&m.status!=="closed")return m;m=y}},l=new Map(e.map(d=>[d.id,c(d).id]));return e.filter(d=>t||!!r.trim()||l.get(d.id)===d.id).map(d=>{const f=t||r.trim()?[]:e.filter(y=>y.id!==d.id&&l.get(y.id)===d.id&&y.status!=="closed"),m=d.status==="open"&&!Ui(d)?f.find(y=>y.decisions.some(w=>w.status==="pending"))??f.find(y=>Ui(y)||y.workflow?.paused):void 0,x=f.filter(y=>Ui(y)||y.workflow?.paused).length;return{task:d,children:f,attention:m,attentionCount:x,rootId:l.get(d.id)}})}function R1(e,t=[]){const r=Xc(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!Ui(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function q6({task:e,children:t,onSelect:r,detail:n=!1,tasks:a=t,name:c}){const l=new Map(t.map(w=>[w.id,w])),d=(t.length?t:e.children??[]).filter(w=>w.status!=="closed");if(!d.length)return null;const f=(w,v)=>{const S=l.get(w);return S&&(Ui(S)||S.workflow?.paused)?0:v?2:1},m=[...d].sort((w,v)=>f(w.id,w.status==="accepted")-f(v.id,v.status==="accepted")||(l.get(v.id)?.updatedAt??0)-(l.get(w.id)?.updatedAt??0)),x=d.filter(w=>w.status==="accepted").length,y=w=>{const v=l.get(w.id),S=w.status==="accepted",C=v&&(Ui(v)||v.workflow?.paused),I=v?.status==="open"?TO(v,a):"",R=v?.attempts.find(O=>O.id===v.activeAttemptId)?.assignee??v?.scheduledAssignee??null,B=v?R1(v):S?w.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",z=S?f0:R0;return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-2 rounded-lg px-1 py-2 text-left hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(w.id),children:[s.jsx(z,{size:14,className:`mt-0.5 shrink-0 ${S||C?"text-primary":"text-muted-foreground"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{title:w.title,className:"line-clamp-2 break-words text-xs leading-5 text-foreground",children:w.title}),s.jsx("span",{className:`block text-[11px] leading-5 ${C?"text-primary":"text-muted-foreground"}`,children:B}),n&&v?.parentTaskId&&v.parentTaskId!==e.id&&s.jsxs("span",{className:"block text-[11px] leading-5 text-muted-foreground",children:["所属事项:",a.find(O=>O.id===v.parentTaskId)?.title??"父任务记录尚未同步"]}),n&&v?.acceptance&&s.jsxs("span",{className:"mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground",children:["交付标准:",v.acceptance]}),I&&s.jsx("span",{className:"line-clamp-2 text-[11px] leading-5 text-muted-foreground",children:I}),n&&c&&s.jsxs("span",{className:"block text-[11px] leading-5 text-muted-foreground",children:["负责人:",R?c(v,R):"尚未分派"]})]}),s.jsx(Xs,{size:12,className:"mt-1 shrink-0 text-muted-foreground"})]},w.id)};return s.jsxs("section",{"aria-label":"执行事项",className:n?"border-t border-border/15 py-2":"mx-4 border-t border-border/15 py-2",children:[!n&&s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"执行事项"}),s.jsxs("span",{children:[x,"/",d.length," 项已完成"]})]}),(n?m.filter(w=>x===d.length||w.status!=="accepted"):m.slice(0,3)).map(y),n&&x>0&&x<d.length&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["查看 ",x," 项已完成的执行交付"]}),m.filter(w=>w.status==="accepted").map(y)]}),!n&&m.length>3&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[11px] text-muted-foreground",children:["展开其余 ",m.length-3," 项"]}),m.slice(3).map(y)]})]})}function SO(e,t){const r=t.events.filter(f=>f.kind==="retry"&&!e.events.some(m=>m.id===f.id)).at(-1),n=new Set(e.deliveries.filter(f=>f.status==="delivered").map(f=>f.id)),a=new Set(e.outbox.filter(f=>!n.has(f.id)).map(f=>f.id)),c=r&&t.deliveries.some(f=>a.has(f.id)&&f.status==="delivered"&&f.deliveredAt!==null&&f.deliveredAt>=r.createdAt);let l=c?"重试请求已保存,匹配本次请求的投递已写入终端。":"重试请求已保存,服务将重新检查现有投递与协调条件。";!t.outbox.length&&!c&&(l+=" 当前没有待重试的投递记录。"),t.workflow?.paused&&(l+=" 后续自动安排仍已暂停。");const d=t.attempts.find(f=>f.id===t.activeAttemptId)?.report;return d&&["blocked","failed"].includes(d.status)&&(l+=" 成员原报告仍保留;请补齐条件并通知成员,收到新的明确回复后更新报告。"),l}function CO(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 _b(e){return new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function Qf({task:e,now:t,compact:r=!1}){const n=Mf(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:_b(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():CO(e.updatedAt,t),children:_b(e.updatedAt)})]}):"记录更新时间未提供"})]})}function Y6(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 ef({inputKey:e,paneKey:t,label:r,value:n,onChange:a,active:c=!0,disabled:l=!1,required:d,autoFocus:f,placeholder:m,className:x,onUploadChange:y}){const w=b.useId(),v=b.useRef(null),S=b.useRef(null),C=b.useRef({value:n,onChange:a,onUploadChange:y});C.current={value:n,onChange:a,onUploadChange:y};const[I,R]=b.useState(0),[B,z]=b.useState(""),O=b.useRef(Promise.resolve());b.useEffect(()=>{const ee=v.current;ee&&ee.setSelectionRange(ee.value.length,ee.value.length)},[e]);const $=()=>({value:C.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),V=(ee,ke=$())=>{C.current.onChange(He=>He!==ke.value?He+(He&&!/\s$/.test(He)?`
|
|
138
|
-
`:"")+ee:He.slice(0,ke.start)+ee+He.slice(ke.end))};b.useEffect(()=>{if(!c)return;const ee=Iy(ke=>V(ke.replace(/\r\n?/g,`
|
|
139
|
-
`)),e,!!t,t);return t||r0(e),ee},[c,e,t]);const Y=()=>{const ee=d0();return`${location.origin}:${ee?.targetPeerId??""}:${ee?.serviceOrigin??""}`},le=ee=>{const ke=$(),He=Y(),q=C.current.onUploadChange;z(""),R(ce=>ce+1),q?.(1),O.current=O.current.then(async()=>{try{if(He!==Y())throw new Error("目标服务已切换,请重新添加附件");const ce=await ee();if(He!==Y())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(ce)?V(ce.map(Dc).join(" ")+" ",ke):ce&&V(ce,ke)}catch(ce){const qe=ce instanceof Error?ce.message:"附件准备失败,请重试";z(qe.includes("Upload did not return")?"附件上传未返回完整路径,请重试":qe)}finally{R(ce=>ce-1),q?.(-1)}})},be=async ee=>ee.length===1&&ee[0].type.startsWith("image/")?[await l3(ee[0])]:d3(ee),pe=ee=>{const ke=ee.clipboardData.files.length?Array.from(ee.clipboardData.files):Array.from(ee.clipboardData.items??[]).filter(ce=>ce.kind==="file").map(ce=>ce.getAsFile()).filter(ce=>ce!==null),He=ee.clipboardData.getData("text/plain"),q=vo();!q?.readClipboardFiles&&!ke.length&&He||!q&&!ke.length&&typeof navigator.clipboard?.read!="function"||(ee.preventDefault(),le(async()=>{const ce=Y();let qe;if(q?.readClipboardFiles)try{const Ae=await u3();if(Ae.paths.length||Ae.files.length)return[...Ae.paths,...await be(Ae.files)]}catch(Ae){if(Ae instanceof i0)throw Ae;qe=Ae}if(ce!==Y())throw new Error("目标服务已切换,请重新粘贴");if(ke.length)return be(ke);if(He)return He;if(typeof navigator.clipboard?.read=="function"){const Ae=await navigator.clipboard.read(),ve={read:async()=>Ae},Ie=await c3(ve);if(Ie.length)return be(Ie);const Be=await pf(ve);if(Be)return be([Be]);for(const ne of Ae)if(ne.types.includes("text/plain"))return(await ne.getType("text/plain")).text()}else{const Ae=await pf();if(Ae)return be([Ae])}if(qe)throw qe;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>r0(e),onPointerDownCapture:()=>r0(e),children:[s.jsx("label",{htmlFor:w,className:"block text-xs text-muted-foreground",children:r}),s.jsx("textarea",{ref:v,id:w,value:n,required:d,disabled:l,autoFocus:f,"aria-describedby":I||B?`${w}-status`:void 0,placeholder:m,className:x,onChange:ee=>a(ee.target.value),onPaste:pe,onDragOver:ee=>{!l&&ee.dataTransfer.types.includes("Files")&&ee.preventDefault()},onDrop:ee=>{const ke=Array.from(ee.dataTransfer.files);!ke.length||l||(ee.preventDefault(),ee.stopPropagation(),le(()=>be(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:ee=>{const ke=Array.from(ee.target.files??[]);ee.target.value="",ke.length&&le(()=>be(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(JT,{size:14}),"附件"]}),I>0?s.jsxs("span",{id:`${w}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(bn,{size:12,className:"animate-spin"}),"正在准备附件…"]}):B?s.jsx("span",{id:`${w}-status`,role:"alert",className:"break-words text-xs text-destructive",children:B}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function kb(e){return e.status!=="open"?"done":Ui(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Sl=[{id:"backlog",label:"待开始",icon:R0,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:cf,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:Zu,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:f0,hint:"验收后的结果会保留在这里"}];function _O({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:c,navigation:l,settings:d}){const f=b.useRef(null),m=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),w=b.useRef(null),[v,S]=b.useState(Date.now);b.useEffect(()=>{const H=setInterval(()=>S(Date.now()),3e4);return()=>clearInterval(H)},[]);const[C,I]=b.useState(!1);b.useEffect(()=>{const H=new ResizeObserver(ae=>{const ye=ae[0].contentRect.width;I(ye>=760),ye!==y.current&&ye<760&&m.current&&(m.current.scrollLeft=Sl.findIndex(Ve=>Ve.id===x.current)*m.current.clientWidth),y.current=ye});return f.current&&H.observe(f.current),()=>H.disconnect()},[]);const[R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[B,z]=b.useState(()=>{if(Sl.some(ye=>ye.id===R?.lane))return R.lane;const ae=Cb(e,R?.showSteps===!0,R?.query??"").map(ye=>ye.attention?"attention":kb(ye.task));return ae.includes("attention")?"attention":ae.includes("running")?"running":ae.includes("backlog")?"backlog":"done"});x.current=B;function O(H,ae=!0){z(H);const ye=m.current;if(!ye||!ye.clientWidth)return;w.current=H;const Ve=Sl.findIndex(bt=>bt.id===H)*ye.clientWidth,Je=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;ye.scrollTo?ye.scrollTo({left:Ve,behavior:ae&&!Je?"smooth":"auto"}):ye.scrollLeft=Ve}b.useEffect(()=>{C||O(x.current,!1)},[C]);const[$,V]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[Y,le]=b.useState(typeof R?.query=="string"?R.query:""),[be,pe]=b.useState(R?.closed===!0),[ee,ke]=b.useState(R?.showSteps===!0),[He,q]=b.useState(!!R?.query),[ce,qe]=b.useState(!1),[Ae,ve]=b.useState(!1),Ie=b.useRef(null),Be=b.useRef(null);b.useEffect(()=>{if(!Ae)return;Ie.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const H=ye=>{Ie.current?.contains(ye.target)||ve(!1)},ae=ye=>{ye.key==="Escape"&&(ye.preventDefault(),ye.stopPropagation(),ve(!1),Be.current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[Ae]);const ne=b.useRef(null),Fe=b.useRef(null),Le=b.useRef(null),Re=b.useRef(null);b.useEffect(()=>{He&&ne.current?.focus()},[He]),b.useEffect(()=>{if(!ce)return;Le.current?.querySelector("select")?.focus();const H=ye=>{Le.current?.contains(ye.target)||qe(!1)},ae=ye=>{ye.key==="Escape"&&(ye.preventDefault(),ye.stopPropagation(),qe(!1),(C?Re:Be).current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[ce]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:B,scope:$,query:Y,closed:be,showSteps:ee}))}catch{}},[a,B,$,Y,be,ee]);const Pe=e.filter(H=>H.workflow?.kind==="goal"),Ee=Cb(e,ee,Y),oe=new Map(Ee.map(H=>[H.task.id,H])),We=H=>oe.get(H.id)?.attention?"attention":kb(H),rt=t?Ee.find(H=>H.task.id===t||H.children.some(ae=>ae.id===t)):void 0,gt=rt?We(rt.task):void 0;b.useEffect(()=>{gt&&O(gt,!1)},[t,gt]);const ue=Ee.map(H=>H.task).filter(H=>(be||H.status!=="closed")&&($==="all"||H.id===$||oe.get(H.id)?.rootId===$)&&(!Y.trim()||`${H.title} ${H.spec} ${H.attempts.map(ae=>n(H,ae.assignee)).join(" ")}`.toLocaleLowerCase().includes(Y.trim().toLocaleLowerCase()))),Ye=+($!=="all")+Number(be)+Number(ee),at="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Ne="flex min-h-11 w-full items-center justify-start gap-3 rounded-lg px-3 text-left text-sm font-medium text-foreground hover:bg-surface-2 active:bg-surface-elevated focus-visible:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Ge=s.jsxs("div",{className:`relative flex min-w-0 items-center ${C?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(jl,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:ne,"aria-label":"搜索任务",type:"search",value:Y,onChange:H=>le(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),Y?le(""):(q(!1),requestAnimationFrame(()=>(C?Fe:Be).current?.focus())))},placeholder:"搜索任务或负责人",className:"min-h-11 w-full rounded-lg border border-border/20 bg-transparent pl-9 pr-9 text-xs outline-none focus:border-primary"}),s.jsx("button",{type:"button","aria-label":"关闭搜索",className:"absolute right-0 flex min-h-11 w-9 items-center justify-center text-muted-foreground",onClick:()=>{le(""),q(!1),requestAnimationFrame(()=>(C?Fe:Be).current?.focus())},children:s.jsx(In,{size:14})})]}),Ce=s.jsxs("div",{"aria-label":"任务筛选",className:"absolute right-0 top-full z-30 mt-1 w-64 space-y-3 rounded-xl border border-border/30 bg-surface p-3 shadow-xl",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"目标范围"}),s.jsxs("select",{"aria-label":"按目标查看",value:$,onChange:H=>V(H.target.value),className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 px-3 text-xs text-foreground",children:[s.jsx("option",{value:"all",children:"所有目标"}),Pe.map(H=>s.jsx("option",{value:H.id,children:H.title},H.id))]})]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:be,onChange:H=>pe(H.target.checked)}),"含已关闭"]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:ee,onChange:H=>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:f,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:C?void 0:Le,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:C?s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:l}),He?Ge:s.jsx("button",{ref:Fe,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${at} ${l?"":"ml-auto"}`,onClick:()=>q(!0),children:s.jsx(jl,{size:16})}),s.jsxs("div",{ref:Le,className:"relative shrink-0",children:[s.jsxs("button",{ref:Re,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务","aria-expanded":ce,className:`${at} ${Ye?"text-primary":""}`,onClick:()=>qe(H=>!H),children:[s.jsx(zm,{size:15}),s.jsx("span",{children:"筛选"}),Ye>0&&s.jsx("span",{className:"tabular-nums text-primary",children:Ye})]}),ce&&Ce]}),d,c&&s.jsx("div",{className:"shrink-0",children:c})]}):s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"mr-auto flex min-w-0 items-center",children:l}),c&&s.jsx("div",{className:"shrink-0",children:c}),s.jsxs("div",{ref:Ie,className:"relative shrink-0",children:[s.jsxs("button",{ref:Be,type:"button","aria-label":"更多看板操作","aria-expanded":Ae,className:`${at} ${Ae?"bg-surface-2 text-foreground":Ye||Y.trim()?"text-primary":""}`,onClick:()=>{ve(H=>!H),qe(!1)},children:[s.jsx(To,{size:18}),Ye>0&&s.jsx("span",{className:"text-[10px]",children:Ye})]}),Ae&&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:()=>ve(!1),children:[s.jsxs("button",{ref:Fe,type:"button","aria-label":"搜索任务",className:Ne,onClick:()=>q(!0),children:[s.jsx(jl,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Re,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务",className:Ne,onClick:()=>qe(!0),children:[s.jsx(zm,{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})]})]}),He&&Ge,ce&&Ce]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:ee?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),s.jsx("nav",{hidden:C,"aria-label":"看板阶段",className:`${C?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:Sl.map(H=>s.jsxs("button",{type:"button","aria-pressed":B===H.id,className:`min-h-11 rounded-lg px-1 text-xs ${B===H.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>O(H.id),children:[H.label,s.jsx("span",{className:"ml-1 tabular-nums",children:ue.filter(ae=>We(ae)===H.id).length})]},H.id))}),s.jsxs("div",{ref:C?void 0:m,"data-kanban-scroll":!0,onPointerDown:()=>{w.current=null},onWheel:()=>{w.current=null},"aria-label":C?void 0:"可左右滑动的任务看板",onScroll:C?void 0:H=>{if(H.target!==H.currentTarget||!H.currentTarget.clientWidth)return;const ae=w.current;if(ae){const Ve=Sl.findIndex(Je=>Je.id===ae)*H.currentTarget.clientWidth;if(Math.abs(H.currentTarget.scrollLeft-Ve)>2)return;w.current=null}const ye=Math.max(0,Math.min(Sl.length-1,Math.round(H.currentTarget.scrollLeft/H.currentTarget.clientWidth)));z(Sl[ye].id)},className:C?"min-h-0 flex-1 overflow-auto pb-3":"min-h-0 flex-1 snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[C&&s.jsx("div",{"aria-label":"看板列标题",className:"sticky top-0 z-10 grid min-w-[1000px] grid-cols-4 gap-4 border-b border-border/15 bg-[var(--chrome-bg)] pb-2",children:Sl.map(H=>{const ae=H.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${H.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(ae,{size:15}),H.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:ue.filter(ye=>We(ye)===H.id).length})]},H.id)})}),s.jsx("div",{className:C?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:Sl.map(H=>{const ae=ue.filter(ye=>We(ye)===H.id).sort((ye,Ve)=>Ve.updatedAt-ye.updatedAt);return s.jsx("section",{"aria-label":`${H.label}任务`,"aria-hidden":!C&&B!==H.id?!0:void 0,ref:ye=>{ye&&(ye.inert=!C&&B!==H.id)},style:C?void 0:{width:"100%"},className:C?"min-w-0 px-1":"h-full min-w-0 shrink-0 snap-start snap-always overflow-y-auto overscroll-y-contain px-1 pb-3 pt-2",children:s.jsxs("div",{className:"space-y-2",children:[ae.map(ye=>{const Ve=oe.get(ye.id),Je=Ve.attention??ye,bt=Je.attempts.find(_e=>_e.id===Je.activeAttemptId),Vt=Je.decisions.find(_e=>_e.status==="pending"),Pt=Xc(Je),mt=G6(ye,Ve.children),Zt=Ve.attention?R1(Je):ye.workflow?.kind==="goal"?mt.label:R1(Je,Ve.children),Ht=tp(Je),Kt=Ht[0],Ot=Ht.find(_e=>_e.source==="system"),Nt=Ht.find(_e=>_e.source==="unknown"),me=Ot?.content,Ze=H.id==="attention",ct=Vt?"回答问题":Nt?"查看详情核对记录":Kt?.source==="member"&&Ot?"查看条件与异常处理":Kt?.source==="member"?"查看阻塞并补充条件":me?"查看原因与处理":Pt==="等待你验收"?"查看结果并验收":Pt==="需要你确认方案"?"查看并确认方案":"查看任务并处理",Tt=Je.artifacts.filter(_e=>_e.kind==="result"&&_e.attemptId===Je.activeAttemptId).at(-1),X=Je.events.filter(_e=>_e.kind==="revise"&&_e.source==="user"&&_e.attemptId===Je.activeAttemptId&&(!Tt||_e.createdAt>=Tt.createdAt)).at(-1),yt=Vt?Vt.question||"成员提出了一个问题,打开后可查看并回答。":Kt?.summary||X?.content||(ye.workflow?.kind==="goal"&&!Ve.attention&&mt.latest?Tt?.summary||V6(mt.latest):Tt?.summary||(bt?.report?.content?Y6(bt.report.content).summary:bt?.report?.summary||"")),nt=e.find(_e=>_e.id===ye.parentTaskId);return s.jsxs("article",{"aria-label":ye.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===ye.id?"border-primary/60":me?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":ye.id,"aria-pressed":t===ye.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:[nt&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:nt.title}),s.jsx("span",{title:ye.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:ye.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${me&&Kt?.source!=="member"?"text-destructive":Ze?"text-primary":"text-muted-foreground"}`,children:[me&&Kt?.source!=="member"&&s.jsx(F1,{size:13,className:"shrink-0"}),Zt]}),Ve.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",Ve.attention.title]}),Ve.attention&&Ve.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",Ve.attentionCount," 项执行需要你处理"]}),ye.workflow?.kind==="goal"&&!Ve.attention&&s.jsx("span",{className:"mt-2 block text-xs leading-5 text-muted-foreground",children:mt.next}),yt&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:yt}),Ot&&Kt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Ot.label,":",Ot.summary]}),Nt&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[Nt.label,":",Nt.summary]}),Ze&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${me?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[ct,s.jsx(Fh,{size:14})]}),!Ze&&(ye.status==="accepted"||ye.artifacts.some(_e=>_e.kind==="result"&&_e.attemptId===ye.activeAttemptId))&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:[X?"查看跟进":"查看结果",s.jsx(Fh,{size:14})]}),!Ze&&ye.workflow?.kind==="goal"&&!Tt&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:["查看拆分与进展",s.jsx(Fh,{size:14})]})]}),s.jsx(q6,{task:ye,children:Ve.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:[Ve.attention?"待处理任务负责人:":ye.workflow?.kind==="goal"?"协调者:":"负责人:",bt?n(Je,bt.assignee):Je.scheduledAssignee?n(Je,Je.scheduledAssignee):"未分派"]}),ye.workflow?.kind==="goal"&&!Ze&&!Ve.attention&&mt.latest?s.jsxs("time",{className:"mt-1 block text-[11px]",dateTime:new Date(mt.latest.createdAt).toISOString(),children:[mt.latest.source," · ",new Date(mt.latest.createdAt).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]}):s.jsx(Qf,{task:Je,now:v,compact:!0})]})]},ye.id)}),!ae.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Y||$!=="all"?"没有匹配的任务":e.length?"暂无任务":H.hint})]})},H.id)})})]})]})}const Rl=hc((e,t)=>({views:{},details:{},ensureDetail:(r,n)=>{const a=t().details[r];return a||(e(c=>({details:{...c.details,[r]:n}})),n)},updateDetail:(r,n,a)=>e(c=>{const l=c.details[r];if(!l)return c;const d=typeof a=="function"?a(l[n]):a;return Object.is(l[n],d)?c:{details:{...c.details,[r]:{...l,[n]:d}}}}),ensure:(r,n)=>{const a=t().views[r];return a||(e(c=>({views:{...c.views,[r]:n}})),n)},update:(r,n,a)=>e(c=>{const l=c.views[r];if(!l)return c;const d=typeof a=="function"?a(l[n]):a;return Object.is(l[n],d)?c:{views:{...c.views,[r]:{...l,[n]:d}}}})}));function Eh(e,t){return r=>Rl.getState().update(e,t,r)}function _m(e,t){return r=>Rl.getState().updateDetail(e,t,r)}const kO=b.lazy(()=>Oc(()=>Promise.resolve().then(()=>mO),void 0).then(e=>({default:e.DirectoryPickerDialog}))),LO=b.lazy(()=>Oc(()=>import("./CollaborationTaskContent-msQsgVaI.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),ua="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",Rs="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=`${ua} bg-primary text-primary-foreground`,Zs=`${ua} bg-surface-2 text-foreground hover:bg-surface-2/80`,IO={created:"创建任务",assigned:"分派",report:"成员报告",respond:"答复",question:"提出问题",answer:"回答问题","submit-plan":"提交方案",review:"提交评审","request-review":"请求独立评审","approve-plan":"用户确认方案",accepted:"用户验收",revise:"要求修改",comment:"补充说明",coordinator:"协调者变更",close:"关闭",reopen:"重新打开",scheduled:"等待自动分派",coordinate:"协调说明","child-update":"子任务更新","review-passed":"独立评审通过","review-blocked":"评审受阻","automation-blocked":"自动安排受阻",pause:"暂停安排",resume:"继续安排",retry:"请求重新检查"},Ou=e=>`${e.serviceId}:${e.sessionId}`,aa=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function go(e,t){try{const r=JSON.parse(localStorage.getItem(e)??"null");return r===null||t!==null&&(typeof r!=typeof t||Array.isArray(r)!==Array.isArray(t))?t:r}catch{return t}}function Fi(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const Jd={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]},Lb="__new_coordinator__";function EO(e){const t={...Jd,...go(e,Jd)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(Jd).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?Jd:{...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 NO({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:c,board:l=!1,boardNavigation:d,boardSettings:f,paneKey:m,agents:x=[],defaultCwd:y,onTeamReady:w}){const v=`termdock:tasks:${location.origin}:${e.id}`,[S,C]=b.useState([]),I=b.useRef(S);I.current=S;const[R,B]=b.useState(null),[z]=b.useState(()=>Rl.getState().ensure(v,{draft:EO(`${v}:draft`),selectedId:go(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:O,mobileDetail:$,creating:V,draft:Y}=Rl(re=>re.views[v]??z),le=Eh(v,"selectedId"),be=Eh(v,"mobileDetail"),pe=Eh(v,"creating"),ee=Eh(v,"draft"),[ke,He]=b.useState(!1),[q,ce]=b.useState(!1),qe=b.useRef(null),Ae=b.useRef(null),ve=b.useRef(!1),Ie=b.useCallback(re=>{!re&&Ae.current===document.activeElement&&(ve.current=!0),Ae.current=re,re&&ve.current&&(ve.current=!1,re.focus())},[]);b.useEffect(()=>{const re=qe.current;if(!re)return;const pt=new ResizeObserver(jt=>He(jt[0].contentRect.width>=(l?1100:760)));return pt.observe(re),()=>pt.disconnect()},[l]);const[Be,ne]=b.useState(!1),[Fe,Le]=b.useState(null),Re=Ey(),[Pe,Ee]=b.useState(0),[oe,We]=b.useState(null),[rt,gt]=b.useState(!1),[ue,Ye]=b.useState(0),at=re=>Ye(pt=>Math.max(0,pt+re)),[Ne,Ge]=b.useState("");b.useEffect(()=>{if(!Ne)return;const re=setTimeout(()=>Ge(""),5e3);return()=>clearTimeout(re)},[Ne]);const[Ce,H]=b.useState("open"),[ae,ye]=b.useState(""),Ve=b.useRef(!1),Je=b.useRef(!0),bt=b.useRef(new Map),Vt=b.useRef(!1),Pt=e.sessionIds.flatMap(re=>{const pt=t.find(jt=>jt.sessionId===re);return pt?[pt]:[]}),mt=Pt.map(re=>({...re,name:Iu(re,Pt)})),Zt=Y.coordinator===Lb,Ht=Y.coordinator||go(`${v}:lead`,""),Kt=mt.find(re=>re.sessionId===Y.coordinator&&re.agent),Ot=!!Y.coordinator&&!Zt&&!Kt,Nt=Zt||Ot?"":Kt?.sessionId||mt.find(re=>re.sessionId===Ht&&re.agent)?.sessionId||mt.find(re=>re.agent)?.sessionId||"",me=mt.filter(re=>re.sessionId!==Nt&&re.agent).map(re=>re.sessionId),[Ze,ct]=b.useState(!1),[Tt,X]=b.useState(!1),[yt,nt]=b.useState(()=>go(`${v}:agent`,"")),[_e,tr]=b.useState(()=>go(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ke=e.launchProfiles?.find(re=>re.id===_e),kt=mt.flatMap(re=>re.agent&&x.some(pt=>pt.slug===re.agent.slug)?[re.agent.slug]:[]),Ut=[...new Set(kt)].sort((re,pt)=>kt.filter(jt=>jt===pt).length-kt.filter(jt=>jt===re).length)[0],vt=x.find(re=>re.slug===Kt?.agent?.slug)?.slug??Ut??x[0]?.slug??"",wt=Ke?.agentSlug??(yt||vt),[Mt,_t]=b.useState(()=>go(`${v}:cwd`,mt[0]?.cwd??y??"")),fr=!mt.find(re=>re.sessionId===Nt)?.agent||!me.length,[qt,Sr]=b.useState(null),pn=!!Y.spec.trim()&&(!!qt||!Ot&&(!fr||!e.federated&&(!_e||!!Ke)&&!!x.find(re=>re.slug===wt)&&!!Mt.trim())),dr=S.find(re=>re.id===O)??null,ge=R?.id===O?R:null;b.useEffect(()=>(Je.current=!0,()=>{Je.current=!1}),[]),b.useEffect(()=>{Fi(`${v}:draft`,Y)},[v,Y]),b.useEffect(()=>{Fi(`${v}:selected`,O)},[v,O]),b.useEffect(()=>{const re=jt=>{const nr=jt.detail;nr?.groupId===e.id&&(Fi(`${v}:open-task`,null),le(nr.taskId),be(!0),pe(!1),H("all"),Gr())};window.addEventListener("open-collaboration-task",re);const pt=go(`${v}:open-task`,null);return pt&&(le(pt),be(!0),H("all"),Fi(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",re)},[e.id]),b.useEffect(()=>{if(!r||!dr||R?.id===dr.id&&R.revision===dr.revision)return;let re=!1;return $8(dr.id).then(pt=>{re||(B(pt.task),Le(null))}).catch(pt=>{re||Le(pt instanceof Error?pt.message:"任务详情加载失败")}),()=>{re=!0}},[r,dr?.id,dr?.revision,R?.id,R?.revision,Pe]);const Gr=async()=>{if(!Vt.current){Vt.current=!0;try{const re=await _y(e.id);Je.current&&(C(re.tasks),ne(!0),Le(null),Ee(pt=>pt+1))}catch(re){Je.current&&Le(re instanceof Error?re.message:"任务加载失败")}finally{Vt.current=!1}}};b.useEffect(()=>{if(!r)return;Gr();const re=()=>{!document.hidden&&navigator.onLine!==!1&&Gr()},pt=setInterval(re,2500);return document.addEventListener("visibilitychange",re),window.addEventListener(af,re),window.addEventListener("pageshow",re),()=>{clearInterval(pt),document.removeEventListener("visibilitychange",re),window.removeEventListener(af,re),window.removeEventListener("pageshow",re)}},[r,e.id]);const ot=re=>{const pt=JSON.stringify(re),jt=go(`${v}:request`,null);let nr=bt.current.get(pt)??(jt?.fingerprint===pt?jt.key:void 0);return nr||(nr=crypto.randomUUID(),bt.current.set(pt,nr)),Fi(`${v}:request`,{fingerprint:pt,key:nr}),nr},ft=re=>{bt.current.delete(JSON.stringify(re)),Fi(`${v}:request`,null)},ir=async(re,pt)=>{if(rt||Ve.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};Ve.current=!0,gt(!0),We(null),Ge("");let jt={...pt,expectedRevision:re.revision};if(["comment","revise"].includes(pt.kind)){const nr=go(`${v}:request`,null);try{const[Ar,Fr]=JSON.parse(nr?.fingerprint??"null"),{expectedRevision:Xt,...Zr}=Fr;Ar===re.id&&JSON.stringify(Zr)===JSON.stringify(pt)&&(jt=Fr)}catch{}}try{const nr=await H8(re.id,{...jt,idempotencyKey:ot([re.id,jt])});if(ft([re.id,jt]),Lu.getState().refresh(),Je.current){const Ar=I.current.find(Jt=>Jt.id===nr.task.id),Fr=Ar&&Ar.revision>nr.task.revision?Ar:nr.task;C(Jt=>Jt.map(Pr=>Pr.id===nr.task.id&&Pr.revision<=nr.task.revision?nr.task:Pr)),B(Jt=>Jt?.id===nr.task.id&&Jt.revision>nr.task.revision?Jt:nr.task);const Xt=Z6(Fr,I.current),Zr=`${pt.kind==="answer"?"回答已保存":"方案确认已保存"},${Xt?Xt.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;Ge(["comment","revise"].includes(pt.kind)?"":pt.kind==="retry"?SO(re,nr.task):["answer","approve-plan"].includes(pt.kind)?Zr:pt.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(nr){const Ar=nr instanceof Error?nr.message:"操作失败";return Ar.includes("任务已更新")&&ft([re.id,jt]),Je.current&&(We(["comment","revise"].includes(pt.kind)?null:Ar),Gr()),{ok:!1,error:Ar}}finally{Ve.current=!1,Je.current&>(!1)}},Mn=async re=>{if(re.preventDefault(),rt||ue>0||(Y.mode==="goal"?!pn:!Y.title.trim()||!Y.spec.trim())||Ve.current)return;Ve.current=!0,gt(!0),We(null);const pt=Y.mode==="goal",jt={groupId:e.id,title:Y.title.trim()||Y.spec.trim().split(`
|
|
140
|
-
`)[0].slice(0,100),spec:Y.spec,constraints:Y.constraints,acceptance:Y.acceptance,assigneeSessionId:pt?void 0:Y.assignee||void 0,coordinatorSessionId:pt?Nt:Y.coordinator||void 0,parentTaskId:pt?void 0:Y.parent||void 0,dependsOn:pt?[]:Y.dependencies,managed:pt,isolated:Y.isolated,reviewerSessionIds:pt?me:void 0};try{if(pt&&(fr||qt)){X(!0);const Ar=Zt?go(`${v}:team-request`,"")||crypto.randomUUID():void 0;Ar&&Fi(`${v}:team-request`,Ar);const Fr=qt??await U8(e.id,{agentSlug:wt,..._e?{launchProfileId:_e}:e.launchProfiles?.length?{launchProfileId:""}:{},cwd:Mt.trim(),...Zt?{coordinatorSessionId:null,coordinatorCreationKey:Ar}:Nt?{coordinatorSessionId:Nt}:{}});X(!1),Sr(Fr),jt.coordinatorSessionId=Fr.coordinatorSessionId,jt.reviewerSessionIds=Fr.reviewerSessionIds,Fi(`${v}:agent`,yt),Fi(`${v}:cwd`,Mt.trim()),Fi(`${v}:launch-profile`,_e)}const{task:nr}=await z8({...jt,idempotencyKey:ot(jt)});ft(jt),Je.current&&(C(Ar=>[nr,...Ar.filter(Fr=>Fr.id!==nr.id)]),le(nr.id),be(!0),B(nr),pt&&Fi(`${v}:lead`,jt.coordinatorSessionId),Fi(`${v}:team-request`,null),Sr(null),w?.(),ee(Jd),pe(!1),H("open"),ye(""),Ge(pt?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(nr){Je.current&&We(nr instanceof Error?nr.message:"创建失败")}finally{Ve.current=!1,Je.current&&(gt(!1),X(!1))}},Xr=(re,pt)=>{if(!pt)return"用户";const jt=re.memberSessions[Ou(pt)];return mt.find(nr=>nr.sessionId===jt)?.name??t.find(nr=>nr.sessionId===jt)?.name??"暂不可用的成员"},De=S.filter(re=>(Ce==="all"?!0:Ce==="archive"?re.status!=="open":re.status==="open")&&(Ce==="all"||Ce==="attention"||re.workflow?.kind!=="step")&&(Ce!=="attention"||Ui(re))&&(!ae.trim()||`${re.title} ${re.spec} ${re.attempts.map(pt=>Xr(re,pt.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase()))),st=S.filter(Ui).length;b.useEffect(()=>{a?.(st)},[st,a]);const xt=!!dr&&(l?$:ke||$),Br=()=>{pe(!1),requestAnimationFrame(()=>Ae.current?.focus())},Vr=re=>{Rl.getState().updateDetail(`${v}:${re}`,"view","overview"),le(re),be(!0),Ge("")},Cr=S.filter(Ui).filter(re=>!ae.trim()||`${re.title} ${re.spec} ${re.attempts.map(pt=>Xr(re,pt.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase())),qr=(re,pt=!1)=>{const jt=re.attempts.find(Jt=>Jt.id===re.activeAttemptId),nr=re.children?.filter(Jt=>Jt.status==="accepted").length??0,Ar=re.children?.filter(Jt=>Jt.status!=="closed").length??0,Fr=tp(re),Xt=Fr.length>1?Fr.find(Jt=>Jt.source!=="member"):null,Zr=(pt?re.decisions.find(Jt=>Jt.status==="pending")?.question:"")||Fr[0]?.summary||jt?.report?.summary||jt?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":O===re.id,className:`group flex min-h-11 w-full items-start gap-3 rounded-xl p-3 text-left transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${O===re.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>Vr(re.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${pt||re.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:pt?s.jsx(Zu,{size:16}):re.status==="accepted"?s.jsx(f0,{size:16}):s.jsx(R0,{size:16})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:re.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${pt?"text-primary":"text-muted-foreground"}`,children:Xc(re)}),Zr&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:Zr}),Xt&&s.jsxs("span",{className:`mt-1 block line-clamp-2 break-words text-xs leading-5 ${Xt.source==="system"?"text-destructive":"text-muted-foreground"}`,children:[Xt.label,":",Xt.summary]}),Ar>0&&s.jsxs("span",{className:"mt-2 flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"flex gap-1","aria-hidden":"true",children:(re.children??[]).filter(Jt=>Jt.status!=="closed").slice(0,8).map(Jt=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${Jt.status==="accepted"?"bg-primary":"bg-border/30"}`},Jt.id))}),nr,"/",Ar," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"block truncate",children:jt?Xr(re,jt.assignee):"尚未分派"}),s.jsx(Qf,{task:re})]})]}),s.jsx(Xs,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},re.id)},mn=[],on=new Set([O]);let zr=dr?.parentTaskId;for(;zr&&!on.has(zr);){on.add(zr);const re=S.find(pt=>pt.id===zr);if(!re)break;mn.unshift(re),zr=re.parentTaskId}const un=()=>{const re=Array.from(qe.current?.querySelectorAll("button[data-task-id]")??[]).find(pt=>pt.dataset.taskId===O);be(!1),requestAnimationFrame(()=>{re&&!re.closest("[hidden]")?re.focus():Ae.current?.focus()})},Er=V||!l&&Be&&S.length===0;return s.jsxs("section",{ref:qe,"aria-label":"协作任务",className:l?"relative flex h-full min-h-0 min-w-0 flex-col gap-2":"space-y-5",children:[l&&(Er||!Be)&&d&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 pb-2",children:[d,s.jsx("div",{className:"ml-auto",children:f})]}),(oe||Fe&&Re==="ready"&&!of(Fe))&&s.jsxs("div",{role:"alert",className:"flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[s.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[oe||Fe,!oe&&Be?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:ua,onClick:()=>oe?We(null):void Gr(),children:[s.jsx(bn,{size:14}),oe?"关闭提示":"重试"]})]}),Fe&&of(Fe)&&!l&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"正在恢复任务同步,现有记录和草稿已保留"}),Ne&&s.jsx("p",{role:"status",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-primary",children:Ne}),Er?s.jsxs("form",{onSubmit:re=>{Mn(re)},className:`mx-auto w-full max-w-xl space-y-4 ${l?"overflow-auto px-1 py-5":""}`,onKeyDown:re=>{re.key==="Escape"&&V&&!re.defaultPrevented&&!re.nativeEvent.isComposing&&B1(re.currentTarget)&&(re.preventDefault(),re.stopPropagation(),rt||Br())},children:[s.jsxs("header",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-foreground",children:Y.mode==="goal"?"一起完成什么?":"新建手动任务"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Y.mode==="goal"?"交给协调者拆分,你在这里看交付、回答问题。":"选择负责人,保留分派和验收记录。"})]}),(S.length>0||l)&&s.jsx("button",{type:"button","aria-label":"取消创建,保留草稿",className:`${ua} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:rt,onClick:Br,children:s.jsx(In,{size:16})})]}),Y.mode==="task"&&s.jsx(Fa,{label:"任务标题",children:s.jsx("input",{className:Rs,required:!0,maxLength:200,value:Y.title,onChange:re=>ee(pt=>({...pt,title:re.target.value})),placeholder:"要完成什么?"})}),s.jsx(ef,{paneKey:m,inputKey:`${v}:spec`,active:r&&Er,label:Y.mode==="goal"?"协作目标":"目标与交付要求",className:`${Rs} ${fr&&Y.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:V,required:!0,disabled:rt,value:Y.spec,onUploadChange:at,onChange:re=>ee(pt=>({...pt,spec:typeof re=="function"?re(pt.spec):re})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),Y.mode==="goal"&&qt&&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:Zs,disabled:rt,onClick:()=>{w?.(),c()},children:"查看已准备的成员"})]}),Y.mode==="goal"&&s.jsxs(Fa,{label:"协调者",children:[s.jsxs("select",{"aria-label":"协调者",className:Rs,disabled:rt||!!qt,value:Y.coordinator,onChange:re=>{Fi(`${v}:team-request`,null),ee(pt=>({...pt,coordinator:re.target.value}))},children:[s.jsx("option",{value:"",children:"自动选择(优先复用组内 Agent)"}),s.jsx("option",{value:Lb,disabled:!!e.federated,children:"新建协调者"}),Ot&&s.jsx("option",{value:Y.coordinator,disabled:!0,children:"原协调者已不可用,请重新选择"}),mt.map(re=>s.jsxs("option",{value:re.sessionId,disabled:!re.agent,children:[re.name,re.agent?` · ${re.agent.displayName}`:"(需要启动 Agent)"]},re.sessionId))]}),Ot&&!qt&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"所选协调者已离组或未运行 Agent,请重新选择。"})]}),Y.mode==="goal"&&(fr||qt)?s.jsxs("fieldset",{disabled:rt||!!qt,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:qt?"已用于准备成员的配置":"首次开始时配置 Agent"}),(!!e.launchProfiles?.length||!!_e)&&s.jsxs(Fa,{label:"启动方案",children:[s.jsxs("select",{"aria-label":"协作启动方案",className:Rs,value:_e,onChange:re=>tr(re.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(re=>s.jsxs("option",{value:re.id,children:[re.name," · ",x.find(pt=>pt.slug===re.agentSlug)?.displayName??re.agentSlug]},re.id))]}),Ke&&s.jsxs("details",{className:"text-xs leading-5 text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-2",children:s.jsx("span",{className:"line-clamp-2 break-words",children:Ke.notes||"查看启动命令与使用备注"})}),s.jsx("p",{"aria-label":"完整使用备注",className:"whitespace-pre-wrap break-words",children:Ke.notes}),s.jsx("code",{className:"mt-1 block break-all",children:Ke.command})]}),_e&&!Ke&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]}),!Ke&&s.jsx(Fa,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Rs,disabled:!!Ke,value:wt,onChange:re=>nt(re.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(re=>s.jsx("option",{value:re.slug,children:re.displayName},re.slug))]})}),s.jsxs(Fa,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Rs} min-w-0 flex-1`,value:Mt,onChange:re=>_t(re.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:Zs,onClick:()=>ct(!0),children:"浏览目录"})]}),Ze&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(kO,{open:!0,initialPath:Mt.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>ct(!1),onConfirm:re=>{_t(re),ct(!1)}})})]}),!qt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Zt?"开始时新建协调者,并补齐执行/评审成员。":"保留所选协调者,开始时补齐执行/评审成员;自动选择会优先复用组内 Agent。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",c&&s.jsx("button",{type:"button",className:Zs,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:Zs,onClick:c,children:"管理成员"})]})]}):Y.mode==="task"&&s.jsx(Fa,{label:"分派给",children:s.jsxs("select",{className:Rs,value:Y.assignee,onChange:re=>ee(pt=>({...pt,assignee:re.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),mt.map(re=>s.jsx("option",{value:re.sessionId,children:re.name},re.sessionId))]})}),s.jsxs("details",{className:"border-y border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:["验收标准与更多设置",(Y.acceptance||Y.constraints)&&s.jsx("span",{className:"text-primary",children:"已补充"})]}),s.jsxs("div",{className:"space-y-3 pb-4",children:[Y.mode==="goal"&&s.jsxs(Fa,{label:"目标名称(选填)",children:[s.jsx("input",{"aria-label":"目标名称",className:Rs,maxLength:100,value:Y.title,onChange:re=>ee(pt=>({...pt,title:re.target.value})),placeholder:"用成果命名,例如:交付可安装的 Preview 客户端"}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"看板用这个名称辨认目标;未填写时使用正文第一行。"})]}),s.jsx(Fa,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Rs} min-h-20 resize-y`,value:Y.acceptance,onChange:re=>ee(pt=>({...pt,acceptance:re.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(Fa,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Rs} min-h-20 resize-y`,value:Y.constraints,onChange:re=>ee(pt=>({...pt,constraints:re.target.value})),placeholder:"必须保留什么?哪些操作需要先问你?"})}),Y.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:Y.isolated,onChange:re=>ee(pt=>({...pt,isolated:re.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Fa,{label:"协调者",children:s.jsxs("select",{className:Rs,value:Y.coordinator,onChange:re=>ee(pt=>({...pt,coordinator:re.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),mt.map(re=>s.jsx("option",{value:re.sessionId,children:re.name},re.sessionId))]})}),s.jsx(Fa,{label:"父任务",children:s.jsxs("select",{className:Rs,value:Y.parent,onChange:re=>ee(pt=>({...pt,parent:re.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),S.filter(re=>!re.workflow).map(re=>s.jsx("option",{value:re.id,children:re.title},re.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),S.filter(re=>re.status!=="closed").map(re=>s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Y.dependencies.includes(re.id),onChange:pt=>ee(jt=>({...jt,dependencies:pt.target.checked?[...jt.dependencies,re.id]:jt.dependencies.filter(nr=>nr!==re.id)}))}),re.title]},re.id))]})]}),s.jsx("button",{type:"button",className:`${ua} text-muted-foreground hover:bg-surface-2`,onClick:()=>ee(re=>({...re,mode:re.mode==="goal"?"task":"goal"})),children:Y.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${cl} w-full`,disabled:rt||ue>0||(Y.mode==="goal"?!pn:!Y.title.trim()||!Y.spec.trim()),children:[rt?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(n0,{size:14}),rt?Tt?"正在准备成员…":"提交中…":Y.mode==="goal"?qt?"重试提交目标":"开始协作":Y.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:Y.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):l&&Be?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"sr-only",children:"任务看板"}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-5",children:[s.jsx("div",{hidden:xt,className:`${xt?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(_O,{navigation:d,settings:f,action:s.jsxs("button",{ref:Ie,type:"button",className:cl,disabled:rt,onClick:()=>pe(!0),children:[s.jsx(zs,{size:14}),"新目标"]}),storage:v,tasks:S,selectedId:xt?O:null,name:Xr,onSelect:Vr})}),xt&&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:`${ua} px-2 hover:bg-surface-2`,onClick:un,children:"看板"})}),mn.map(re=>s.jsxs("li",{className:"flex min-w-0 flex-1 items-center gap-1 sm:max-w-xs sm:flex-none",children:[s.jsx(Xs,{"aria-hidden":"true",size:12,className:"shrink-0"}),s.jsx("button",{type:"button","aria-label":`查看${re.workflow?.kind==="goal"?"目标":"父任务"}:${re.title}`,title:`查看${re.workflow?.kind==="goal"?"目标":"父任务"}:${re.title}`,className:`${ua} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>Vr(re.id),children:s.jsxs("span",{className:"truncate",children:[re.workflow?.kind==="goal"?"目标":"父任务",":",re.title]})})]},re.id)),s.jsxs("li",{"aria-current":"page",className:"flex shrink-0 items-center gap-1",children:[s.jsx(Xs,{"aria-hidden":"true",size:12}),s.jsx("span",{className:"px-2",children:dr?.parentTaskId?"子任务详情":dr?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:ge?s.jsx(Ib,{reader:!0,paneKey:m,active:r,task:ge,tasks:S,members:mt,busy:rt,name:re=>Xr(ge,re),act:re=>ir(ge,re),storage:v,onSelectTask:Vr,onOpenSession:async re=>{const pt=t.find(jt=>jt.sessionId===ge.memberSessions[Ou(re)]);if(!pt){We("成员会话暂不可用,任务历史已保留。");return}try{await n(pt)}catch(jt){We(jt instanceof Error?jt.message:"无法打开终端")}}},ge.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!Be&&!S.length?s.jsxs("div",{role:"status",className:"space-y-3 py-8",children:[s.jsx("p",{className:"text-center text-xs text-muted-foreground",children:Fe?"任务暂时无法加载,请重试。":"正在加载目标…"}),!Fe&&[0,1,2].map(re=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},re))]}):s.jsxs(s.Fragment,{children:[(!xt||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(re=>re.status==="open"&&re.workflow?.kind!=="step").length," 个进行中 · ",S.filter(re=>re.status==="accepted"&&re.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:Ie,type:"button",className:cl,disabled:rt,onClick:()=>pe(!0),children:[s.jsx(zs,{size:14}),"新目标"]})]}),s.jsxs("div",{className:ke&&xt?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!xt||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:`${Rs} min-w-0 flex-1 border-transparent bg-transparent`,value:Ce,onChange:re=>H(re.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",st,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":q,className:`${ua} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{ce(re=>!re),ye("")},children:s.jsx(jl,{size:16})})]}),q&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Rs,value:ae,onChange:re=>ye(re.target.value),placeholder:"搜索目标、内容或负责人"}),Ce==="open"&&Cr.length>0&&s.jsxs("section",{"aria-label":"需要你处理",className:"rounded-xl bg-surface-2/40 p-1",children:[s.jsxs("h4",{className:"flex items-center justify-between px-3 pb-1 pt-3 text-xs font-medium text-primary",children:["需要你处理",s.jsx("span",{className:"rounded-md bg-primary/15 px-2 py-0.5",children:Cr.length})]}),Cr.map(re=>qr(re,!0))]}),(Ce!=="open"||De.some(re=>!Ui(re))||De.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:Ce==="attention"?"需要你处理":Ce==="archive"?"已归档":Ce==="all"?"全部任务":"当前目标"}),De.filter(re=>Ce!=="open"||!Ui(re)).map(re=>qr(re,Ce==="attention")),!De.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[ae.trim()?"没有匹配的任务。":Ce==="attention"?"目前没有需要你处理的任务。":Ce==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(Ce!=="all"||ae)&&s.jsx("button",{type:"button",className:`${ua} mt-2 text-primary`,onClick:()=>{H("all"),ye("")},children:"查看全部任务"})]})]})]}),xt&&s.jsxs("div",{className:"min-w-0",children:[!ke&&s.jsxs("button",{type:"button",className:`${ua} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>be(!1),children:[s.jsx(Ny,{size:14}),"全部目标"]}),ge?s.jsx(Ib,{paneKey:m,active:r,task:ge,tasks:S,members:mt,busy:rt,name:re=>Xr(ge,re),act:re=>ir(ge,re),storage:v,onSelectTask:Vr,onOpenSession:async re=>{const pt=t.find(jt=>jt.sessionId===ge.memberSessions[Ou(re)]);if(!pt){We("成员会话暂不可用,任务历史已保留。");return}try{await n(pt)}catch(jt){We(jt instanceof Error?jt.message:"无法打开终端")}}},ge.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function Fa({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 Ib({reader:e=!1,active:t,paneKey:r,task:n,tasks:a,members:c,name:l,busy:d,act:f,storage:m,onOpenSession:x,onSelectTask:y}){const[w,v]=b.useState(""),[S,C]=b.useState(""),[I,R]=b.useState(""),[B,z]=b.useState(!1),[O,$]=b.useState(null),V=b.useRef(!1),Y=b.useRef(!0);b.useEffect(()=>(Y.current=!0,()=>{Y.current=!1}),[]);const le=b.useRef(null),be=b.useRef(null);b.useEffect(()=>{!e&&O&&O.state!=="pending"&&t&&requestAnimationFrame(()=>be.current?.scrollIntoView({block:"nearest"}))},[O]);const pe=b.useRef(null),[ee,ke]=b.useState(0),He=X=>ke(yt=>Math.max(0,yt+X)),q=b.useRef(null);b.useEffect(()=>{q.current?.focus()},[]);const ce=`${m}:${n.id}`,[qe]=b.useState(()=>Rl.getState().ensureDetail(ce,{feedback:go(`${ce}:feedback`,""),answers:go(`${ce}:answers`,{}),view:"overview"})),{feedback:Ae,answers:ve,view:Ie}=Rl(X=>X.details[ce]??qe),Be=_m(ce,"feedback"),ne=_m(ce,"answers"),Fe=_m(ce,"view");b.useEffect(()=>{pe.current&&(pe.current.scrollTop=0)},[Ie]),b.useEffect(()=>Fi(`${m}:${n.id}:answers`,ve),[m,n.id,ve]),b.useEffect(()=>Fi(`${m}:${n.id}:feedback`,Ae),[m,n.id,Ae]);const Le=n.attempts.find(X=>X.id===n.activeAttemptId),Re=n.status==="open",Pe=Z6(n,a),Ee=n.artifacts.filter(X=>X.kind==="result"&&X.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{O?.state==="saved"&&Ee?.id!==O.resultId&&$(null)},[Ee?.id,O]);const oe=n.artifacts.filter(X=>X.kind==="plan"&&X.attemptId===n.activeAttemptId).at(-1),We=n.events.filter(X=>X.kind==="revise"&&X.source==="user"&&X.attemptId===n.activeAttemptId).at(-1),rt=Ee&&n.events.some(X=>X.kind==="revise"&&X.attemptId===n.activeAttemptId&&X.createdAt>=Ee.createdAt),gt=e&&Re&&!!rt,ue=O?.state==="saved"&&O.kind==="revise"&&O.resultId===Ee?.id,Ye=n.decisions.filter(X=>X.status==="pending"&&X.attemptId===n.activeAttemptId),at=n.dependsOn.some(X=>a.find(yt=>yt.id===X)?.status!=="accepted"),Ne=!n.workflow||n.artifacts.filter(X=>X.kind==="review"&&X.reviewsArtifactId===Ee?.id).at(-1)?.verdict==="pass",Ge=n.children??[],Ce=n.workflow?.kind==="goal"&&Ge.some(X=>!["accepted","closed"].includes(X.status)),H=`任务:${n.title}
|
|
141
|
-
任务 ID:${n.id}
|
|
142
|
-
${n.spec}
|
|
143
|
-
约束:${n.constraints||"未补充"}
|
|
144
|
-
验收标准:${n.acceptance||"由用户决定"}
|
|
145
|
-
${Le?`当前尝试:${Le.id}
|
|
146
|
-
负责人:${l(Le.assignee)}
|
|
147
|
-
`:""}${n.artifacts.filter(X=>X.attemptId===n.activeAttemptId).map(X=>`${X.kind} · 版本 ${X.id} · ${aa(X.createdAt)}
|
|
148
|
-
${X.summary?`结果摘要:${X.summary}
|
|
149
|
-
`:""}${X.content}`).join(`
|
|
150
|
-
|
|
151
|
-
`)}
|
|
152
|
-
${Ye.map(X=>`待回答:${X.question}`).join(`
|
|
153
|
-
`)}`,ae=()=>{const X=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),yt=document.createElement("a");yt.href=X,yt.download=`termdock-task-${n.id}.json`,yt.click(),setTimeout(()=>URL.revokeObjectURL(X),1e3)},ye=n.events.filter(X=>X.kind==="coordinate"&&(!X.attemptId||X.attemptId===n.activeAttemptId)).at(-1),Ve=Ie==="results"?n.artifacts.slice().reverse():n.artifacts.filter(X=>X.id===Ee?.id||X.id===oe?.id&&n.approvedPlanArtifactId!==X.id||X.kind==="review"&&X.reviewsArtifactId===Ee?.id).sort((X,yt)=>(X.kind==="result"?-1:1)-(yt.kind==="result"?-1:1)||yt.createdAt-X.createdAt),Je=Ge.flatMap(X=>{const yt=a.find(nt=>nt.id===X.id);return yt?[yt]:[]}),bt=G6(n,Je),Vt=Ge.filter(X=>X.status!=="closed"),Pt=Vt.filter(X=>X.status!=="accepted"),mt=ye&&(!We||ye.createdAt>=We.createdAt)?ye:void 0,Zt=Le?.report&&(!We||Le.report.createdAt>=We.createdAt)?Le.report:void 0,Ht=rt?"等待新结果通过评审后可验收。":Ye.length?"回答当前问题后可验收。":at?"依赖任务验收后可验收。":Ne?Ce?"子任务完成并通过评审后可验收。":null:"独立评审通过后可验收。",Kt=()=>{Fe("overview"),z(!0),requestAnimationFrame(()=>{le.current?.scrollIntoView({block:"nearest"}),le.current?.querySelector("textarea")?.focus()})},Ot=tp(n),Nt=Ot[0],me=Ot.some(X=>X.source==="member"),Ze=async X=>{if(d||ee||!Ae.trim()||V.current)return;const yt=Ae;V.current=!0,$({kind:X,state:"pending",content:yt,resultId:Ee?.id});const nt=await f({kind:X,content:yt});if(V.current=!1,nt.ok){if(Be(_e=>_e===yt?"":_e),Fi(`${ce}:feedback`,Rl.getState().details[ce]?.feedback??""),!Y.current)return;$({kind:X,state:"saved",content:yt,resultId:Ee?.id}),e&&Rl.getState().details[ce]?.feedback===""&&z(!1)}else Y.current&&$({kind:X,state:"error",content:yt,error:nt.error,resultId:Ee?.id})},ct=X=>s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:X}),children:s.jsx(LO,{content:X})}),Tt=X=>{const yt=Y6(X.content,X.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:X.kind==="result"?rt&&X.id===Ee?.id?"上一版结果":"交付结果":X.kind==="plan"?n.approvedPlanArtifactId===X.id?"已确认的方案":"方案":"独立评审"}),X.verdict&&s.jsx("span",{className:`rounded-md px-2 py-1 text-[11px] ${X.verdict==="pass"?"bg-primary/10 text-primary":"bg-surface-2 text-foreground"}`,children:X.verdict==="pass"?"通过":X.verdict==="changes"?"需要修改":"受阻"}),n.acceptedArtifactId===X.id&&s.jsx("span",{className:"text-xs text-primary",children:n.completionMode==="reviewed"?"评审通过":"已验收"}),n.approvedPlanArtifactId===X.id&&s.jsx("span",{className:"text-xs text-primary",children:"方案已确认"})]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[l(X.actor)," · ",aa(X.createdAt),X.attemptId!==n.activeAttemptId&&X.kind!=="review"?" · 历史分派":""]}),X.kind==="result"&&yt.condensed?s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-label":"结果结论",className:"text-base leading-7",children:ct(!yt.explicit&&!yt.summary.includes(`
|
|
154
|
-
`)?yt.summary.replace(/([。;])\s*(?=\S)/g,`$1
|
|
155
|
-
|
|
156
|
-
`):yt.summary)}),yt.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:"适用范围与限制"}),ct(yt.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:ct(X.content)})]})]}):ct(X.content),X.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(X.evidence,null,2)})]}),Re&&X.attemptId===n.activeAttemptId&&X.kind!=="review"&&(!e||X.kind==="plan"||!n.workflow)&&s.jsxs("div",{className:"space-y-2 border-t border-border/15 pt-3",children:[!e&&Ee?.id===X.id&&n.workflow?.kind!=="step"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`${cl} w-full`,disabled:d||!!Ht,onClick:()=>{f({kind:"accept",artifactId:X.id})},children:[s.jsx(pi,{size:14}),"验收此结果"]}),Ht&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Ht})]}),oe?.id===X.id&&n.approvedPlanArtifactId!==X.id&&s.jsxs("button",{type:"button",className:`${cl} w-full`,disabled:d,onClick:()=>{f({kind:"approve-plan",artifactId:X.id})},children:[s.jsx(pi,{size:14}),Pe?"确认方案":"确认方案并继续"]}),!n.workflow&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"请其他成员评审此版本"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"独立评审成员",className:Rs,value:S,onChange:nt=>C(nt.target.value),children:[s.jsx("option",{value:"",children:"选择独立评审成员"}),c.filter(nt=>nt.sessionId!==n.memberSessions[Ou(X.actor)]).map(nt=>s.jsx("option",{value:nt.sessionId,children:nt.name},nt.sessionId))]}),s.jsx("button",{type:"button",className:Zs,disabled:d||!S||S===n.memberSessions[Ou(X.actor)],onClick:()=>{f({kind:"request-review",artifactId:X.id,assigneeSessionId:S})},children:"请求评审"})]})]})]})]},X.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:`${ua} -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(X=>X.id===n.parentTaskId)?.title??"查看父任务"]}),s.jsx(Fh,{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:q,tabIndex:-1,className:"break-words text-lg font-semibold leading-7 text-foreground outline-none",children:n.title}),s.jsxs("span",{className:`inline-flex items-center gap-2 rounded-md px-2 py-1 text-xs ${Ui(n)?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground"}`,children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),n.workflow?.kind==="goal"?bt.label:Xc(n)]})]}),!Ye.length&&!Ee&&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)}`:Le?`负责人 · ${l(Le.assignee)}`:"尚未分派"}),Le&&s.jsxs("button",{type:"button",className:`${ua} px-2 text-muted-foreground hover:bg-surface-2 hover:text-primary`,onClick:()=>{x(Le.assignee)},children:[s.jsx(Fc,{size:13}),"打开终端"]})]}),n.workflow?.kind==="goal"&&s.jsx("p",{"aria-label":"目标下一步",className:"text-xs leading-5 text-muted-foreground",children:bt.next}),!e&&s.jsx(Qf,{task:n}),n.replica&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"此记录由来源服务同步,回答与决定会送回来源服务。"})]}),Pe&&Re&&s.jsxs("section",{role:"status","aria-label":"安排暂停说明",className:"space-y-2 rounded-xl bg-surface-2 p-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Pe.workflow?.kind==="goal"?"目标仍暂停。回答和方案确认会保存,恢复目标后才能投递;已投递的终端工作继续保留。":"任务仍暂停。回答和方案确认会保存,继续安排后才能投递;已投递的终端工作继续保留。"}),Pe.id!==n.id&&s.jsx("button",{type:"button",className:Zs,onClick:()=>y(Pe.id),children:"查看目标并恢复安排"})]}),s.jsx("nav",{"aria-label":"任务详情",className:"flex gap-4 border-b border-border/20",children:[["overview",gt?"进展":e&&Ee?"结果":"概览"],["results",e?"历史交付":`交付${n.artifacts.length?` ${n.artifacts.length}`:""}`],["activity","动态"]].map(([X,yt])=>s.jsx("button",{type:"button","aria-pressed":Ie===X,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 ${Ie===X?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,onClick:()=>Fe(X),children:yt},X))}),Ie==="overview"&&s.jsxs(s.Fragment,{children:[(()=>{const X=We;if(!X)return null;const yt=n.deliveries.find(tr=>tr.id===X.deliveryId),nt=n.outbox.find(tr=>tr.id===X.deliveryId),_e=Ee&&Ee.createdAt>X.createdAt;return s.jsxs("section",{"aria-label":"最近跟进",className:"space-y-1 rounded-lg bg-surface-2/50 px-3 py-2 text-xs leading-5",children:[s.jsx("p",{className:"font-medium text-primary",children:gt?"本次跟进要求":_e?Ne?"新结果已通过独立评审":"新结果已交付,等待独立评审":"已要求继续跟进,等待新结果"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:X.content}),s.jsxs("p",{className:"text-muted-foreground",children:[aa(X.createdAt),yt?.status==="delivered"?e?" · 已写入成员终端":` · 已写入${X.target?l(X.target):"成员"}终端${yt.deliveredAt?` · ${aa(yt.deliveredAt)}`:""}`:["failed","expired"].includes(yt?.status??"")||yt?.error||nt?.lastError?" · 投递未成功,服务端继续重试":X.deliveryId?" · 等待写入终端":" · 要求已保存"]})]})})(),Ye.map(X=>s.jsxs("form",{className:"space-y-3 rounded-xl border border-border/30 bg-surface-2/40 p-4",onSubmit:yt=>{yt.preventDefault(),!d&&!ee&&ve[X.id]?.trim()&&f({kind:"answer",decisionId:X.id,content:ve[X.id]})},children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-primary",children:[s.jsx(Zu,{size:14}),"需要你的决定"]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:X.question}),!!X.options.length&&s.jsx("div",{className:"flex flex-col gap-2",children:X.options.map((yt,nt)=>s.jsxs("button",{type:"button","aria-pressed":ve[X.id]===yt,disabled:d,className:`${ua} justify-start text-left ${ve[X.id]===yt?"bg-primary/15 text-primary":"bg-surface-2 text-foreground"}`,onClick:()=>ne(_e=>({..._e,[X.id]:yt})),children:[ve[X.id]===yt?s.jsx(pi,{size:14,className:"shrink-0"}):s.jsx(R0,{size:14,className:"shrink-0"}),s.jsx("span",{className:"break-words",children:yt})]},nt))}),s.jsx(ef,{paneKey:r,inputKey:`${ce}:answer:${X.id}`,active:t,label:"你的回答",className:`${Rs} min-h-20 resize-y`,required:!0,disabled:d,value:ve[X.id]??"",onUploadChange:He,onChange:yt=>ne(nt=>({...nt,[X.id]:typeof yt=="function"?yt(nt[X.id]??""):yt})),placeholder:"选择建议,或写下你的决定…"}),s.jsxs("button",{className:`${cl} w-full`,disabled:d||ee>0||!ve[X.id]?.trim(),children:[s.jsx(n0,{size:14}),Pe?"保存回答":"回复并继续"]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[aa(X.createdAt)," · 回答会保存在任务记录中"]})]},X.id)),Ot.map(X=>s.jsxs("section",{"aria-label":X.source==="member"?"成员阻塞报告":X.source==="unknown"?"待核对服务记录":"服务异常",role:X.source==="system"?"alert":"status",className:`space-y-3 rounded-xl p-4 ${X.source==="member"?"bg-primary/10":X.source==="unknown"?"bg-surface-2":"bg-destructive/10"}`,children:[s.jsx("h4",{className:`text-sm font-medium ${X.source==="member"?"text-primary":X.source==="unknown"?"text-muted-foreground":"text-destructive"}`,children:X.label}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:X.summary}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:X.source==="member"?`负责人:${l(Le?.assignee??null)}。先补齐报告中缺少的条件,再发送说明;需要登录时,请在对应服务完成授权。`:X.source==="unknown"?"此摘要未提供原报告正文和记录来源,请打开完整详情核对;确认前不提供服务异常重试。":"重试只请求服务重新检查现有投递与协调条件,保留原报告和执行尝试;成员新的明确回复才会更新报告。"}),X.source==="member"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:Zs,disabled:d,onClick:Kt,children:"补充条件并通知成员"}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整阻塞报告"}),X.content?ct(X.content):s.jsx("p",{className:"text-xs text-muted-foreground",children:"原始报告正文未提供。"})]})]}):X.source==="system"?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:Zs,disabled:d||!n.workflow,onClick:()=>{f({kind:"retry"})},children:[s.jsx(bn,{size:13}),n.outbox.length?"重试现有投递":X.content.startsWith("消息投递")?"重新检查投递记录":"重新检查自动安排"]}),!n.workflow&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"此任务未启用自动安排,请检查投递记录或成员终端。"})]}):null]},X.source)),n.workflow?.paused&&Re&&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:Zs,disabled:d,onClick:()=>{f({kind:"resume"})},children:"继续安排"})]}),gt&&Ve.filter(X=>X.kind==="plan").map(Tt),gt&&s.jsxs("section",{"aria-label":"当前进展",className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"等待本轮新结果"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Pt.length?`${Pt.length} 项执行尚未完成交付与评审`:"收到新的交付结果后,会在这里展示供你验收。"})]}),!!Pt.length&&s.jsx("ul",{className:"space-y-1",children:Pt.map(X=>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(X.id),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:X.title}),s.jsx(Xs,{size:14,className:"shrink-0"})]})},X.id))}),mt||Zt?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(Xs,{size:13,className:"shrink-0 transition-transform group-open/record:rotate-90"}),s.jsx("span",{children:mt?"协调者最近的更新":"成员最近的报告"}),s.jsx("span",{className:"ml-auto shrink-0",children:aa((mt??Zt).createdAt)})]}),s.jsx("div",{className:"pb-3",children:ct((mt??Zt).content)})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到这次跟进后的明确更新。"})]}),gt?s.jsxs("details",{className:"group/record border-t border-border/20",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Xs,{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:aa(Ee.createdAt)})]}),s.jsx("div",{className:"space-y-3 pb-3",children:Ve.filter(X=>X.kind!=="plan").map(Tt)})]}):s.jsx(s.Fragment,{children:Ve.map(X=>X.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:["独立评审 · ",X.verdict==="pass"?"通过":X.verdict==="changes"?"要求修改":"受阻"," · ",l(X.actor)]}),Tt(X)]},X.id):Tt(X))}),n.workflow?.kind==="goal"&&!Ee&&!Nt&&!Ye.length&&s.jsx("section",{"aria-label":"最新明确更新",className:"space-y-2 rounded-xl bg-surface-2/40 p-3",children:bt.latest?s.jsxs(s.Fragment,{children:[s.jsxs("h4",{className:"flex items-center gap-2 text-xs font-medium text-foreground",children:[bt.latest.source,s.jsx("span",{className:"ml-auto shrink-0 text-[11px] font-normal text-muted-foreground",children:aa(bt.latest.createdAt)})]}),bt.latest.taskId!==n.id&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["来自:",bt.latest.title]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:V6(bt.latest).slice(0,512)}),bt.latest.taskId!==n.id?s.jsxs("button",{type:"button",className:Zs,onClick:()=>y(bt.latest.taskId),children:["查看这项执行工作",s.jsx(Xs,{size:13})]}):s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"查看原始更新"}),ct(bt.latest.source==="协调说明"?ye?.content??"":Le?.report?.content??"")]})]}):s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"尚未收到本轮明确更新。拆分和报告到达后会显示在这里。"})}),n.workflow?.kind!=="goal"&&ye&&!Ee&&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:aa(ye.createdAt)})]}),s.jsx("div",{className:"rounded-xl bg-surface-2/50 p-3",children:ct(ye.content)})]}),n.workflow?.kind!=="goal"&&!Nt&&!ye&&Le?.report&&!Ee&&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:aa(Le.report.createdAt)})]}),ct(Le.report.content)]}),!!Ge.length&&s.jsxs("details",{className:"space-y-2",open:!Ee||gt||Ge.some(X=>{const yt=a.find(nt=>nt.id===X.id);return yt&&Ui(yt)})||void 0,children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:[s.jsx("span",{children:"执行过程"}),s.jsx("span",{className:"ml-2 text-muted-foreground",children:"工作拆分"}),s.jsxs("span",{className:"ml-3 text-[11px] font-normal text-muted-foreground",children:[bt.done,"/",Vt.length," 项交付已评审"]})]}),s.jsx(q6,{detail:!0,task:n,children:Je,tasks:a,name:(X,yt)=>l(yt),onSelect:y})]}),!!n.dependsOn.length&&s.jsxs("section",{children:[s.jsx("h4",{className:"mb-2 text-xs font-medium text-foreground",children:"依赖任务"}),n.dependsOn.map(X=>s.jsxs("button",{type:"button",className:`${ua} w-full justify-start text-left text-muted-foreground hover:bg-surface-2`,onClick:()=>y(X),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:a.find(yt=>yt.id===X)?.title??X}),s.jsx("span",{className:"shrink-0 text-[11px]",children:a.find(yt=>yt.id===X)?.status==="accepted"?"已验收":"待验收"})]},X))]}),Re&&!Le&&!n.scheduledAssignee&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2/50 p-4",children:[s.jsx(Fa,{label:"分派给",children:s.jsxs("select",{className:Rs,value:w,onChange:X=>v(X.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(X=>s.jsx("option",{value:X.sessionId,children:X.name},X.sessionId))]})}),s.jsx("button",{type:"button",className:`${cl} w-full`,disabled:d||!w||at,onClick:()=>{f({kind:"assign",assigneeSessionId:w})},children:"分派任务"}),at&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"依赖任务验收后可分派。"})]}),!Nt&&!Ye.length&&!ye&&!Le?.report&&!Ve.length&&!Ge.length&&s.jsxs("div",{className:"rounded-xl bg-surface-2/40 p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-foreground",children:Re?"等待第一条更新":"任务记录已保留"}),s.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:Re?"成员明确回复后,报告、问题和交付会出现在这里。":"可在动态中查看分派与决定。"})]})]}),Ie==="results"&&s.jsx("div",{className:"space-y-4",children:Ve.length?Ve.map(Tt):s.jsx("p",{className:"py-8 text-center text-xs leading-5 text-muted-foreground",children:"还没有交付。方案、结果和独立评审会保存在这里。"})}),Ie==="activity"&&s.jsxs("section",{"aria-label":"任务动态",children:[s.jsx("ol",{className:"space-y-5",children:n.events.slice().reverse().map(X=>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:[IO[X.kind]??X.kind,X.reportStatus?` · ${Rf[X.reportStatus]}`:""]}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[X.source==="system"?"服务自动接续":X.source==="integration"?`外部接入 ${X.origin?.integrationId??""}`:l(X.actor)," · ",aa(X.createdAt),X.attemptId&&X.attemptId!==n.activeAttemptId?" · 历史分派":""]}),s.jsx("div",{className:"mt-2",children:ct(X.content)}),X.target&&s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["接收人:",l(X.target)]})]},X.id))}),!n.events.length&&s.jsx("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"还没有动态记录。"})]}),Re&&Ie!=="activity"&&(!e||!Ee)&&s.jsxs("section",{ref:le,className:"space-y-2 border-t border-border/20 pt-4",children:[s.jsx(ef,{paneKey:r,inputKey:`${ce}:feedback`,active:t,label:me?"补充处理说明":"补充说明或修改要求",className:`${Rs} min-h-20 resize-y text-sm leading-6`,disabled:d,value:Ae,onUploadChange:He,onChange:Be,placeholder:me?"说明已补齐的条件,或调整本次检查范围…":"补充上下文,或写下需要修改的地方…"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",className:Zs,disabled:d||ee>0||!Ae.trim(),onClick:()=>{Ze("comment")},children:[O?.state==="pending"&&O.kind==="comment"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(n0,{size:13}),O?.state==="pending"&&O.kind==="comment"?"正在发送…":me?"发送条件说明":"发送补充"]}),!me&&s.jsxs("button",{type:"button",className:Zs,disabled:d||ee>0||!Le||!Ae.trim(),onClick:()=>{Ze("revise")},children:[O?.state==="pending"&&O.kind==="revise"&&s.jsx(bn,{size:13,className:"animate-spin"}),O?.state==="pending"&&O.kind==="revise"?"正在提交…":"要求修改"]})]}),O&&s.jsx("div",{ref:be,role:O.state==="error"?"alert":"status",className:`rounded-lg px-3 py-2 text-xs leading-5 ${O.state==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:O.state==="pending"?"正在保存,请稍候…":O.state==="error"?`未确认保存:${O.error}。内容已保留,可重试。`:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:O.kind==="comment"?me?"补充已保存,投递结果可在任务管理中查看凭证;成员原报告仍保留,等待新的明确回复。":"补充已保存,投递结果可在任务管理中查看凭证。":"修改要求已保存,等待新结果后可验收。"}),s.jsx("p",{className:"mt-1 line-clamp-2 whitespace-pre-wrap break-words text-foreground/80",children:O.content}),s.jsx("button",{type:"button",className:"mt-1 min-h-11 text-primary underline underline-offset-4",onClick:()=>Fe("activity"),children:"查看任务动态"})]})}),!O&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:me?"说明会发送给本次负责人,成员明确回复后状态更新。":"发送补充会保留当前结果;需要更新结果时,请选择“要求修改”。"})]}),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(Qf,{task:n}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整目标与验收标准"}),ct(n.spec),n.acceptance&&ct(n.acceptance),n.constraints&&ct(n.constraints)]}),n.workflow&&Re&&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:Zs,disabled:d,onClick:()=>{f({kind:n.workflow.paused?"resume":"pause"})},children:n.workflow.paused?"继续安排":"暂停安排"})]}),n.workspace&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"交付目录与分支"}),s.jsxs("p",{className:"select-text break-all text-xs text-foreground",children:[n.workspace.cwd,s.jsx("br",{}),n.workspace.branch]}),s.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"基于已提交代码创建;合并到原分支或发布需另行操作。"})]}),Re&&s.jsxs(s.Fragment,{children:[Le&&n.workflow?.kind!=="goal"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"任务负责人",className:Rs,value:w,onChange:X=>v(X.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),c.map(X=>s.jsx("option",{value:X.sessionId,children:X.name},X.sessionId))]}),s.jsx("button",{type:"button",className:Zs,disabled:d||!w||at,onClick:()=>{f({kind:"assign",assigneeSessionId:w,content:Ae||void 0})},children:"开始新一轮分派"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:at?"依赖任务验收后可分派。":"新分派保留旧记录,并结束旧问题的回答入口。"})]}),s.jsx(Fa,{label:"协调者",children:s.jsxs("select",{className:Rs,disabled:d||n.workflow?.kind==="step",value:n.coordinator?n.memberSessions[Ou(n.coordinator)]??"":"",onChange:X=>{f({kind:"coordinator",coordinatorSessionId:X.target.value||null})},children:[!n.workflow&&s.jsx("option",{value:"",children:"由用户协调"}),c.map(X=>s.jsx("option",{value:X.sessionId,children:X.name},X.sessionId))]})}),s.jsx("button",{type:"button",className:`${ua} text-muted-foreground hover:bg-surface-2`,disabled:d,onClick:()=>{f({kind:"close",content:Ae||void 0})},children:"关闭此任务"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"关闭会保留历史和成员的终端工作。"})]}),!Re&&s.jsx("button",{type:"button",className:Zs,disabled:d,onClick:()=>{f({kind:"reopen"})},children:"重新打开任务"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["投递凭证与执行尝试 · ",n.attempts.length," 轮"]}),s.jsxs("div",{className:"space-y-3 text-xs leading-5 text-muted-foreground",children:[n.outbox.map(X=>s.jsxs("p",{className:"break-words",children:[X.lastError?`等待重试:${X.lastError}`:"已保存 · 等待投递",X.messageId?` · 消息 ${X.messageId}`:""]},X.id)),n.attempts.map(X=>s.jsxs("div",{children:[s.jsxs("p",{children:[X.id===n.activeAttemptId?"当前分派":"历史分派"," · ",l(X.assignee)," · ",aa(X.createdAt)]}),s.jsxs("p",{className:"mt-1 break-all font-mono text-[11px]",children:["尝试 ID:",X.id]}),s.jsxs("p",{className:"mt-1",children:[X.deliveryStatus==="delivered"?`已写入终端 · ${X.deliveredAt?aa(X.deliveredAt):""}`:X.deliveryStatus==="failed"||X.deliveryStatus==="expired"?"本次消息投递未成功":"等待写入终端",X.report?` · ${Rf[X.report.status]}(${aa(X.report.createdAt)})`:""]})]},X.id)),n.deliveries.filter(X=>X.kind!=="task").map(X=>s.jsxs("p",{className:"break-all",children:["后续消息 ",X.messageId," · ",X.status==="delivered"?"已写入终端":"等待投递",X.deliveredAt?` · ${aa(X.deliveredAt)}`:""]},X.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:Zs,onClick:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(H)).then(()=>R("任务上下文已复制。")).catch(()=>R("复制失败,可导出任务记录。"))},children:"复制上下文"}),s.jsx("button",{type:"button",className:Zs,onClick:ae,children:"导出记录"}),I&&s.jsx("span",{role:"status",className:"self-center text-[11px] text-muted-foreground",children:I})]})]})]})]}),e&&Ee&&n.status!=="closed"&&s.jsxs("footer",{role:"region","aria-label":"结果验收",className:"shrink-0 space-y-2 border-t border-border/25 bg-[var(--chrome-bg)] py-3 [padding-bottom:max(0.75rem,env(safe-area-inset-bottom))]",children:[B?s.jsxs("div",{ref:le,className:"space-y-2",children:[s.jsx(ef,{paneKey:r,inputKey:`${ce}:feedback`,active:t,label:"跟进要求",className:`${Rs} min-h-20 max-h-32 resize-none text-sm leading-6`,disabled:d,value:Ae,onUploadChange:He,onChange:Be,placeholder:"说明哪里不满意,或写下接下来要完成的事…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:Zs,disabled:d||ee>0,onClick:()=>z(!1),children:"取消,保留草稿"}),s.jsxs("button",{type:"button",className:`${cl} ml-auto`,disabled:d||ee>0||!Le||!Ae.trim(),onClick:()=>{Ze("revise")},children:[O?.state==="pending"?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(n0,{size:14}),O?.state==="pending"?"正在发送…":"发送并继续跟进"]})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:`${Zs} flex-1 sm:flex-none`,disabled:d,onClick:Kt,children:Ae.trim()?"继续跟进 · 有草稿":"继续跟进"}),Ie!=="overview"?s.jsx("button",{type:"button",className:`${cl} ml-auto flex-1 sm:flex-none`,onClick:()=>Fe("overview"),children:gt?"返回当前进展":"返回当前结果"}):(gt||ue)&&Re?s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"等待新结果后可验收"}):Re&&n.workflow?.kind!=="step"?s.jsxs("button",{type:"button",className:`${cl} ml-auto flex-1 sm:flex-none`,disabled:d||ee>0||!!Ht||O?.state==="saved"&&O.kind==="revise"&&O.resultId===Ee.id,onClick:()=>{f({kind:"accept",artifactId:Ee.id})},children:[s.jsx(pi,{size:14}),"验收此结果"]}):s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:n.status==="accepted"?n.completionMode==="reviewed"?"已通过独立评审":"已验收":"由独立评审验收"})]}),O&&s.jsx("div",{role:O.state==="error"?"alert":"status",className:`text-xs leading-5 ${O.state==="error"?"text-destructive":"text-primary"}`,children:O.state==="pending"?"正在保存跟进要求…":O.state==="error"?`未确认保存:${O.error}。内容已保留,可重试。`:"跟进要求已保存,等待新结果。"}),!B&&!gt&&Re&&Ht&&O?.state!=="saved"&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Ht})]})]})}const Pf=new Map,K6=e=>`termdock-group-settings:${window.location.origin}:${e}`;function Of(e){return e.name!==e.savedName||e.rules!==e.savedRules}function Rg(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 RO(e,t){return{...Rg(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 MO(e,t){const r=Rg(e,t),n=K6(e.id);if(Pf.has(n))return Pf.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:Of(c)?c:r}catch{return r}}function jO(e,t){const r=K6(e);try{Of(t)?sessionStorage.setItem(r,JSON.stringify(t)):sessionStorage.removeItem(r),Pf.delete(r)}catch{Pf.set(r,Of(t)?t:null)}}function X6(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 tf(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 DO(){const e=tf("tab");return e==="automation"||e==="search"?e:"collaboration"}const $s="w-full rounded-lg border border-border/20 bg-surface-2 px-3 py-2 text-[12px] text-foreground outline-none transition focus:border-primary/60",M1="inline-flex min-h-7 items-center justify-center rounded-md border px-2 py-1 text-[11px] leading-4 font-medium transition",vr="inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-40",rf=new WeakMap;function Eb(e){const[t,r]=b.useState(null),[n,a]=b.useState(!1),c=Ei(m=>m.drafts),l=b.useCallback(m=>{const x=Ei.getState();for(const[y,w]of Object.entries(m))x.drafts[y]||x.setDraft(y,w)},[]),d=b.useCallback((m,x,y)=>{if(JSON.stringify(Ei.getState().drafts[m])===JSON.stringify(x))return;const w={...x};y&&rf.set(w,y),Ei.getState().setDraft(m,w)},[]),f={drafts:c,loadDrafts:l,updateDraft:d};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(Nb,{...e,...f,overlayObscured:!!t,onOpenOverlay:r,onClose:()=>{t?a(!0):e.onClose()}}),t&&s.jsx(Nb,{...e,...f,overlayOnly:!0,initialFloating:t==="floating",onFloatingChange:void 0,onOpenOverlay:r,onClose:()=>{r(null),n&&e.onClose()}})]})}function Nb({activeSessionId:e,initialCollaborationGroupId:t=null,initialFloating:r=!1,onFloatingChange:n,onEnterGroup:a,visible:c=!0,defaultSessionMode:l="shell",onClose:d,onNewSession:f,overlayOnly:m=!1,overlayObscured:x=!1,onOpenOverlay:y,drafts:w,loadDrafts:v,updateDraft:S}){const C=!!t,[I,R]=b.useState(r);b.useEffect(()=>{R(r)},[r]);const[B,z]=b.useState(!1),[O,$]=b.useState(t),V=Kn(De=>De.docks[t??"workbench"]),Y=Kn(De=>De.hosts[t??"workbench"]),[le,be]=b.useState("docked"),[pe,ee]=b.useState(null),[ke,He]=b.useState({x:16,y:80}),q=b.useRef(null),ce=b.useRef(null);b.useEffect(()=>{const De=q.current;De&&(x?(De.contains(document.activeElement)&&(ce.current=document.activeElement),De.inert=!0):(De.inert=!1,ce.current?.isConnected&&ce.current.focus({preventScroll:!0}),ce.current=null))},[x]),b.useEffect(()=>{if(!m||I)return;const De=q.current;De?.querySelector('button[aria-label="收起展开视图"]')?.focus({preventScroll:!0});const st=xt=>{if(xt.key!=="Tab"||xt.defaultPrevented||!De)return;const Br=Array.from(De.querySelectorAll('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], summary, [tabindex="0"]')).filter(mn=>!mn.closest("[hidden], [inert]")&&mn.getClientRects().length>0),Vr=Br[0],Cr=Br.at(-1),qr=!De.contains(document.activeElement);xt.shiftKey&&(document.activeElement===Vr||qr)?(xt.preventDefault(),Cr?.focus()):!xt.shiftKey&&(document.activeElement===Cr||qr)&&(xt.preventDefault(),Vr?.focus())};return document.addEventListener("keydown",st),()=>document.removeEventListener("keydown",st)},[m,I]);const[qe]=b.useState(()=>document.createElement("div")),Ae=b.useRef({x:.5,y:.5}),[ve,Ie]=b.useState(null),[Be,ne]=b.useState(null);b.useEffect(()=>{let De=!1;return fc().then(st=>{if(De)return;const xt=n3(st.collaborationPanels?.[Hf()],t);xt.position&&(Ae.current=xt.position),xt.size&&ee(xt.size),v(xt.drafts??{}),m||be(xt.mode??"docked"),Ie(xt)}).catch(()=>{De||ne("面板草稿加载失败,请重新打开面板重试")}),()=>{De=!0}},[]);const[Fe,Le]=b.useState(null);b.useEffect(()=>{const De=st=>ne(String(st.detail));return window.addEventListener("termdock-panel-save-error",De),()=>{window.removeEventListener("termdock-panel-save-error",De),m||Kn.getState().setDock(t??"workbench",null)}},[]);const Re=!m&&I&&le==="docked"&&!!Y;b.useLayoutEffect(()=>(qe.className=Re?"h-full min-h-0 w-full min-w-0":"contents",(Re?Y:document.body)?.appendChild(qe),()=>qe.remove()),[qe,Re,Y]),b.useEffect(()=>{!m&&!I&&Kn.getState().setDock(t??"workbench",null)},[I]);const Pe=async De=>{if(m||B||De==="docked"&&!e)return;const st={sessionId:e,side:"right"};z(!0);try{await $a({mode:De,...De==="docked"?{dock:st}:{}},t),be(De),Kn.getState().setDock(t??"workbench",De==="docked"?{...st,...C?{preferredWidth:360}:{}}:null)}catch{ne("面板布局保存失败,请重试")}finally{z(!1)}},Ee=b.useRef(!1),oe=b.useRef(null),We=b.useCallback((De,st)=>{const xt=q.current?.getBoundingClientRect(),Br=window.visualViewport,Vr=(Br?.offsetLeft??0)+12,Cr=(Br?.offsetTop??0)+12;return{x:Math.max(Vr,Math.min(De,Vr+(Br?.width??window.innerWidth)-(xt?.width??440)-24)),y:Math.max(Cr,Math.min(st,Cr+(Br?.height??window.innerHeight)-(xt?.height??340)-24))}},[]),[rt,gt]=b.useState(()=>t?"collaboration":DO()),[ue,Ye]=b.useState(()=>new Set([rt])),at=De=>{gt(De),Ye(st=>new Set([...st,De])),Ht(null),Ot(null),!t&&!m&&tf("tab",De)},[Ne,Ge]=b.useState([]),[Ce,H]=b.useState([]),[ae,ye]=b.useState([]),[Ve,Je]=b.useState([]),[bt,Vt]=b.useState([]),[Pt,mt]=b.useState(null),[Zt,Ht]=b.useState(null),[Kt,Ot]=b.useState(null);b.useEffect(()=>{if(!Kt)return;const De=setTimeout(()=>Ot(null),5e3);return()=>clearTimeout(De)},[Kt]);const[Nt,me]=b.useState("loading"),[Ze,ct]=b.useState("loading"),[Tt,X]=b.useState(null),[yt,nt]=b.useState(null),[_e,tr]=b.useState(),[Ke,kt]=b.useState(null),Ut=b.useRef(null),vt=b.useRef(null),wt=b.useRef(null),Mt=t?Ve.find(De=>De.id===t)??null:null,_t=b.useRef(!1);b.useEffect(()=>{if(t||Nt!=="loaded"||_t.current)return;_t.current=!0;const De=tf("group"),st=Ve.find(xt=>xt.id===De)??Ve.find(xt=>e&&xt.sessionIds.includes(e))??Ve[0];$(xt=>xt??st?.id??null)},[t,Nt,Ve,e]),b.useEffect(()=>{!t&&!m&&O&&Ve.some(De=>De.id===O)&&tf("group",O)},[O,Ve,t,m]);const fr=O?Ve.find(De=>De.id===O)??null:Ve[0]??null,qt=!!t&&Nt==="loaded"&&!Mt,Sr=!!ve||!!Be,pn=!m&&I&&le==="docked"&&!!(V??ve?.dock)&&!Y,dr=c&&Sr&&!pn&&!!e&&(!t||!!Y||!!fr?.sessionIds.includes(e)||!!t&&(Nt!=="loading"&&!Mt||!!Be));b.useLayoutEffect(()=>{if(!I||Re||!dr)return;const De=()=>{const xt=window.visualViewport;Le(xt?.height??window.innerHeight);const Br=q.current?.getBoundingClientRect();!Br?.width||!Br.height||Ee.current||He(We((xt?.offsetLeft??0)+12+Math.max(0,(xt?.width??window.innerWidth)-Br.width-24)*Ae.current.x,(xt?.offsetTop??0)+12+Math.max(0,(xt?.height??window.innerHeight)-Br.height-24)*Ae.current.y))},st=new ResizeObserver(De);return q.current&&st.observe(q.current),window.addEventListener("resize",De),window.visualViewport?.addEventListener("resize",De),De(),()=>{st.disconnect(),window.removeEventListener("resize",De),window.visualViewport?.removeEventListener("resize",De)}},[I,Re,dr,We,ve,pe]),b.useLayoutEffect(()=>{if(m)return;const De=t??"workbench",st=Kn.getState();if(qt)st.docks[De]&&st.setDock(De,null);else if(Sr&&I&&le==="docked"&&e&&(!t||Mt)){const xt=st.docks[De],Br=!t||Mt?.sessionIds.includes(e)?e:bt.find(qr=>Mt?.sessionIds.includes(qr.sessionId)&&!$u(qr.sessionId))?.sessionId??e,Vr=xt??ve?.dock??{sessionId:Br,side:window.innerWidth<640?"bottom":"right"},Cr={...Vr,sessionId:Mt?.sessionIds.includes(e)?e:Vr.sessionId,...C?{preferredWidth:xt?.preferredWidth??360}:{}};(!xt||Cr.sessionId!==xt.sessionId||Cr.preferredWidth!==xt.preferredWidth)&&st.setDock(De,Cr),C&&xt&&Cr.sessionId!==xt.sessionId&&$a({dock:{sessionId:Cr.sessionId,side:Cr.side}},t).catch(()=>ne("协作位置保存失败,当前面板仍可使用"))}},[qt,Mt,I,le,ve,Sr,e,t,V,bt]);const ge=async(De,st=!1)=>{if(!(B||De&&!fr)){if(!m&&!De&&!st&&V){y("full");return}if(m){st?d():(R(De),y(De?"floating":"full"));return}z(!0);try{await n?.(De?fr.id:null),R(De),De&&le==="docked"&&e&&Kn.getState().setDock(t??"workbench",{sessionId:e,side:V?.side??ve?.dock?.side??"right"}),st&&d()}catch(xt){Ht(`常驻浮窗状态保存失败,请重试:${xt instanceof Error?xt.message:"连接失败"}`)}finally{z(!1)}}},Gr=b.useCallback(De=>{Je(De.groups),Vt(De.sessions),tr(De.peers),nt(null),me("loaded")},[]);b.useEffect(()=>My(Gr),[Gr]);const ot=b.useCallback(async(De={})=>{De.silent||Ht(null),!C&&!vt.current&&(vt.current=V8().then(st=>{Ge(st.automations),H(st.runs),ct("loaded"),X(null)}).catch(st=>{ct("error"),X(st instanceof Error?st.message:"自动任务加载失败")}).finally(()=>{vt.current=null})),wt.current||(wt.current=Ly().then(st=>{ye(st),kt(null)}).catch(()=>{kt("Agent 命令检测失败;已有会话可继续协作。")}).finally(()=>{wt.current=null})),Ut.current||(me(st=>st==="error"?"loading":st),Ut.current=O1().then(Gr).catch(st=>{me("error"),nt(`协作会话加载失败:${st instanceof Error?st.message:"请重试"}`)}).finally(()=>{Ut.current=null})),await Promise.all([Ut.current,vt.current])},[Gr,C]);b.useEffect(()=>{ot();const De=window.setInterval(()=>{ot({silent:!0})},1e4);return()=>window.clearInterval(De)},[ot]),b.useEffect(()=>{const De=st=>{st.key==="Escape"&&!st.defaultPrevented&&!I&&d()};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[d,I]);const ft=De=>{C&&De&&De!==t&&Ve.some(st=>st.id===De)&&a?a(De).catch(st=>Ht(st instanceof Error?st.message:"无法打开工作区")):$(De)},ir=async De=>{await WO(De)},Mn=!I&&!C&&rt==="collaboration",Xr=async(De,st)=>{if(!Pt){mt(`open-group:${De}`),Ht(null);try{await a?.(De),Ei.getState().open(De,st),d()}catch(xt){Ht(xt instanceof Error?xt.message:"无法打开协作组,请重试")}finally{mt(null)}}};return Js.createPortal(s.jsxs(s.Fragment,{children:[!I&&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:De=>{Re&&De.stopPropagation()},ref:q,role:m&&!I?"dialog":void 0,"aria-modal":m&&!I?!0:void 0,"aria-hidden":x||void 0,"aria-label":Re?"工作组消息分屏":I?"工作组消息浮窗":"Agent 工作台",style:c?I&&!Re?{display:dr?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:Fe?Fe-24:"calc(100dvh - 24px)"}:void 0:{display:"none"},className:Re?"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface":I?"fixed z-menu-panel flex w-[min(400px,calc(100vw-24px))] flex-col overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-xl":`fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))] ${Mn?"max-h-[calc(var(--app-visible-vh,100dvh)-max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))-max(1.5rem,env(safe-area-inset-bottom,0px)))]":"h-[calc(var(--app-visible-vh,100dvh)-max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))-max(1.5rem,env(safe-area-inset-bottom,0px)))]"} z-modal-panel mx-auto flex ${C?"max-w-6xl":"max-w-3xl"} flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[calc(var(--app-visible-vh,100dvh)*0.08)] ${Mn?"sm:max-h-[calc(var(--app-visible-vh,100dvh)*0.84)]":"sm:h-[calc(var(--app-visible-vh,100dvh)*0.84)]"}`,children:[s.jsxs("header",{"data-pane-titlebar":Re?"true":void 0,"data-panel-drag-title":Re?"true":void 0,onDragStart:De=>De.preventDefault(),className:`flex items-center gap-2 border-b border-border/15 ${Re?"min-h-9 shrink-0 cursor-grab select-none bg-[var(--chrome-bg)] px-3 active:cursor-grabbing":I?"px-3 py-2 cursor-move touch-none select-none":"px-4 py-3"}`,onPointerDown:De=>{!I||Re||De.button!==0||De.target.closest("button, summary")||(oe.current={x:De.clientX,y:De.clientY,left:ke.x,top:ke.y},De.currentTarget.setPointerCapture?.(De.pointerId))},onPointerMove:De=>{oe.current&&He(We(oe.current.left+De.clientX-oe.current.x,oe.current.top+De.clientY-oe.current.y))},onPointerUp:()=>{if(!oe.current)return;oe.current=null;const De=q.current?.getBoundingClientRect(),st=window.visualViewport;De&&(Ae.current=vx(ke.x,ke.y,(st?.offsetLeft??0)+12,(st?.offsetTop??0)+12,(st?.width??window.innerWidth)-De.width-24,(st?.height??window.innerHeight)-De.height-24),$a({position:Ae.current},t).catch(()=>ne("浮窗位置保存失败,请重新拖动重试")))},onPointerCancel:()=>{oe.current=null},children:[s.jsx(N0,{size:Re?13:17,className:"shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:`${I?"truncate text-[12px]":"text-[14px]"} font-semibold text-foreground`,title:Re?"拖动标题移动面板;放在边缘拆分,中央交换":Mt?.name,children:Mt?Mt.name:t?"协作工作区":"Agent 工作台"}),!Re&&!C&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:I?"引用、文件路径和粘贴优先加入此处":Mt?"分派任务、回答问题、审阅与验收结果":"自动任务、会话协作与历史搜索"})]}),!Re&&!m&&C&&rt==="collaboration"&&Ve.length>0&&s.jsx("button",{className:`${vr} shrink-0 text-primary hover:bg-primary/10`,disabled:B,onClick:()=>{ge(!I)},children:I?"展开":"放到终端旁"}),C&&Mt&&s.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[Mt.sessionIds.length," 人"]}),Re&&!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(CA,{size:15})}),Re&&s.jsxs("details",{className:"relative z-20 shrink-0",children:[s.jsx("summary",{"aria-label":"面板布局",title:"面板布局",className:"flex min-h-8 cursor-pointer list-none items-center rounded px-2 text-muted-foreground hover:bg-surface-2 [&::-webkit-details-marker]:hidden",children:s.jsx(To,{size:16})}),s.jsx("div",{className:"absolute right-0 top-full z-30 w-36 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:s.jsxs("button",{type:"button",disabled:B,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:De=>{De.currentTarget.closest("details")?.removeAttribute("open"),Pe("floating")},children:[s.jsx(Fc,{size:14}),"小浮窗"]})})]}),s.jsx("button",{className:`${Re?"min-h-8 rounded px-2":"rounded-lg p-2"} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,disabled:B,onClick:()=>{I?ge(!1,!0):d()},"aria-label":m?"收起展开视图":"关闭",children:s.jsx(In,{size:16})})]}),I&&!Re&&!m&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:B,"aria-pressed":le==="floating",className:`${M1} ${le==="floating"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Pe("floating")},children:"浮窗"}),s.jsx("button",{type:"button",disabled:B||!e||qt,"aria-pressed":le==="docked",className:`${M1} ${le==="docked"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Pe("docked")},children:"放到终端旁"})]}),!C&&(!I||Re)&&s.jsx("nav",{"aria-label":"工作台功能",className:"grid shrink-0 grid-cols-3 gap-1 border-b border-border/15 px-2 py-1",children:[["collaboration",Uu,"协作组"],["automation",p0,"自动任务"],["search",jl,"历史搜索"]].map(([De,st,xt])=>s.jsxs("button",{type:"button","aria-pressed":rt===De,"aria-controls":`workbench-${De}`,onClick:()=>at(De),className:`${vr} ${rt===De?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(st,{size:14}),xt]},De))}),rt==="collaboration"&&yt&&s.jsxs("div",{role:"alert",className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[yt,s.jsx("button",{className:`${vr} ml-2`,onClick:()=>{ot()},children:"重新加载会话"})]}),!C&&rt!=="search"&&Ke&&s.jsx("div",{className:"mx-4 mt-3 text-[11px] text-muted-foreground",children:Ke}),Zt&&s.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:Zt}),Kt&&(!I||Re)&&s.jsxs("div",{role:"status",className:"mx-3 mt-2 flex items-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-[11px] text-primary",children:[s.jsx(pi,{size:13}),Kt]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[ue.has("automation")&&s.jsx("div",{id:"workbench-automation",className:rt==="automation"?"h-full min-h-0 p-4":"hidden",children:s.jsx(BO,{automations:Ne,runs:Ce,agents:ae,sessions:bt.filter(De=>!$u(De.sessionId)),activeSessionId:e,loading:Ze==="loading",loadError:Tt,busy:Pt,setBusy:mt,setError:Ht,setNotice:Ot,refresh:ot,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 ${I?"p-3":"p-4"}`:"hidden",children:[!ve&&!Be&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息面板…"}),t&&!Mt&&s.jsxs("div",{role:"status",className:"space-y-2 text-[11px] text-muted-foreground",children:[s.jsx("p",{children:Nt==="loading"?"正在加载协作组…":Nt==="error"?"协作组加载失败,恢复连接后可重试。":"此协作组暂不可用,已释放分屏位置。草稿和布局偏好仍保留。"}),Nt!=="loading"&&s.jsx("button",{className:vr,onClick:()=>{ot()},children:"重新加载"})]}),Be&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:Be}),ve&&(!t||Mt)&&s.jsx(PO,{active:rt==="collaboration",notice:Kt,initialDrafts:w,onDraftChange:S,docked:Re,inputKeySuffix:m?":overlay":"",selectedGroupId:O,setSelectedGroupId:ft,floatingVisible:dr,floating:I,sessionsState:Nt,groups:Ve,sessions:bt,agents:ae,activeSessionId:e,initialGroupId:t,onOpenSession:async De=>{await ir(De),I||d()},onOpenTaskSession:ir,onEnterGroup:a,onOpenGroup:Xr,defaultSessionMode:l,busy:Pt,setBusy:mt,setError:Ht,setNotice:Ot,refresh:ot}),!C&&_e&&s.jsx(FO,{peers:_e,currentGroupId:O==="new"?void 0:fr?.id,busy:Pt,setBusy:mt,setError:Ht,setNotice:Ot,onSelectGroup:De=>{Xr(De,"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(ZO,{active:rt==="search",onClose:d,onNewSession:f,setError:Ht})})]}),I&&!Re&&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:De=>{De.preventDefault(),Ee.current=!0,De.currentTarget.setPointerCapture(De.pointerId)},onPointerMove:De=>{if(!De.currentTarget.hasPointerCapture(De.pointerId))return;const st=window.visualViewport,xt=st?.width??window.innerWidth,Br=st?.height??window.innerHeight;ee({width:Math.min(1,Math.max(280,De.clientX-ke.x)/xt),height:Math.min(1,Math.max(220,De.clientY-ke.y)/Br)})},onPointerUp:()=>{Ee.current=!1;const De=q.current?.getBoundingClientRect(),st=window.visualViewport;De&&(Ae.current=vx(ke.x,ke.y,(st?.offsetLeft??0)+12,(st?.offsetTop??0)+12,(st?.width??window.innerWidth)-De.width-24,(st?.height??window.innerHeight)-De.height-24)),pe&&$a({size:pe,position:Ae.current},t).catch(()=>ne("浮窗大小保存失败,请重新调整重试"))},onPointerCancel:()=>{Ee.current=!1},onKeyDown:De=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(De.key))return;De.preventDefault();const st=q.current?.getBoundingClientRect(),xt={width:Math.max(.15,Math.min(1,(pe?.width??(st?.width??400)/window.innerWidth)+(De.key==="ArrowRight"?.03:De.key==="ArrowLeft"?-.03:0))),height:Math.max(.15,Math.min(1,(pe?.height??(st?.height??300)/window.innerHeight)+(De.key==="ArrowDown"?.03:De.key==="ArrowUp"?-.03:0)))};ee(xt),$a({size:xt},t).catch(()=>ne("浮窗大小保存失败,请重试"))},children:s.jsx("span",{"aria-hidden":"true",children:"⌟"})})]})]}),qe)}function BO({automations:e,runs:t,agents:r,sessions:n,activeSessionId:a,loading:c,loadError:l,busy:d,setBusy:f,setError:m,setNotice:x,refresh:y,onClose:w}){const[v,S]=b.useState(null),[C,I]=b.useState(!1),[R,B]=b.useState(null),z=async(O,$,V)=>{f(O),m(null),x(null);try{await $(),await y(),x(V)}catch(Y){m(Y instanceof Error?Y.message:"操作失败")}finally{f(null)}};return C?s.jsx(QO,{agents:r,sessions:n,activeSessionId:a,initial:v,onCancel:()=>{S(null),I(!1),m(null)},onSaved:async(O,$)=>{S(null),I(!1),await y(),x(v?`“${O}”已更新`:$?`“${O}”已创建,将按计划自动运行`:`“${O}”已创建,当前未启用`)},setError:m},v?.id??"new"):s.jsxs("div",{className:"h-full space-y-4 overflow-y-auto overscroll-y-contain",children:[l&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["自动任务同步失败:",l,s.jsx("button",{className:vr,onClick:()=>{y()},children:"重新加载"})]}),s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"自动任务"}),s.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"定时发送任务,打开运行会话查看输出。"})]}),!C&&e.length>0&&s.jsxs("button",{className:`${vr} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{S(null),I(!0),x(null)},children:[s.jsx(zs,{size:13}),"新建任务"]})]}),c&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在加载自动任务…"}),!c&&!l&&e.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx(UA,{size:24,className:"mx-auto text-primary"}),s.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"把重复工作交给 Agent"}),s.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[11px] leading-relaxed text-muted-foreground",children:"写清任务内容,选择运行频率。创建后可以先手动运行一次确认效果。"}),s.jsxs("button",{className:`${vr} mt-4 bg-primary text-primary-foreground`,onClick:()=>I(!0),children:[s.jsx(zs,{size:13}),"创建第一个任务"]})]}),s.jsx("div",{className:"space-y-2",children:e.map(O=>{const $=t.filter(Y=>Y.automationId===O.id).sort((Y,le)=>le.startedAt-Y.startedAt)[0],V=r.find(Y=>Y.command===O.command);return s.jsxs("article",{className:"rounded-xl border border-border/15 bg-surface-2/40 p-3 transition hover:border-border/30",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:O.name}),s.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${O.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:O.enabled?"已启用":"已停用"}),O.lastRunStatus&&s.jsx("span",{className:`text-[10px] ${tF(O.lastRunStatus)}`,children:eF(O.lastRunStatus)})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(p0,{size:11}),XO(O)]}),s.jsx("span",{children:O.enabled&&O.nextRunAt?`下次 ${$f(O.nextRunAt)}`:"不会自动运行"})]}),s.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:O.targetSessionId?`发送到 ${n.find(Y=>Y.sessionId===O.targetSessionId)?.name??"指定会话"}`:`新建 ${V?.displayName??"Agent"} 会话 · ${O.cwd}`}),s.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:O.prompt}),O.lastRunAt&&s.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",$f(O.lastRunAt),O.lastRunMessage?` · ${O.lastRunMessage}`:""]})]}),s.jsx("button",{"aria-label":`编辑 ${O.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{S(O),I(!0),x(null)},children:s.jsx(ju,{size:13})})]}),s.jsx("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border/10 pt-3",children:R===O.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),s.jsx("button",{className:`${vr} bg-surface-elevated text-foreground`,onClick:()=>B(null),children:"取消"}),s.jsxs("button",{disabled:d!==null,className:`${vr} bg-destructive text-destructive-foreground`,onClick:()=>{z(`delete:${O.id}`,()=>Z8(O.id),`“${O.name}”已删除`).then(()=>B(null))},children:[d===`delete:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(Ms,{size:13}),"确认删除"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`${vr} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>B(O.id),children:[s.jsx(Ms,{size:13}),"删除"]}),s.jsxs("button",{disabled:d!==null,className:`${vr} ${O.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{z(`toggle:${O.id}`,()=>K8(O.id,!O.enabled),O.enabled?`“${O.name}”已暂停,不会自动运行`:`“${O.name}”已恢复,将按原计划运行`)},children:[d===`toggle:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):O.enabled?s.jsx(tS,{size:13}):s.jsx(cf,{size:13}),O.enabled?"暂停":"恢复"]}),$?.frontendSessionId&&s.jsxs("button",{className:`${vr} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:$.frontendSessionId})),w()},children:[s.jsx(Fc,{size:13}),"打开上次会话"]}),s.jsxs("button",{disabled:d!==null,className:`${vr} bg-primary/15 text-primary`,onClick:()=>{z(`run:${O.id}`,()=>X8(O.id),`“${O.name}”已投递,可打开会话查看进度`)},children:[d===`run:${O.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(cf,{size:13}),"立即运行"]})]})})]},O.id)})})]})}function QO({agents:e,sessions:t,activeSessionId:r,initial:n,onCancel:a,onSaved:c,setError:l}){const[d,f]=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,C]=b.useState(!1),[I,R]=b.useState(()=>e.find(H=>H.command===n?.command)?.slug??""),[B,z]=b.useState(n?.prompt??""),[O,$]=b.useState(n?.targetSessionId??""),[V,Y]=b.useState(n?.targetSessionId?"existing":"new"),[le,be]=b.useState(n?.schedule.kind??"interval"),[pe,ee]=b.useState(n?.schedule.kind==="interval"?n.schedule.everyMinutes:60),[ke,He]=b.useState(n?.schedule.kind==="daily"?n.schedule.time:"09:00"),[q,ce]=b.useState(n?.schedule.kind==="daily"?n.schedule.weekdays:[1,2,3,4,5]),[qe,Ae]=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())),[ve,Ie]=b.useState(!1),[Be,ne]=b.useState(n?.enabled??!0),[Fe,Le]=b.useState(!1),Re=e.find(H=>H.slug===I)??null,Pe=Re?.command??n?.command??"";b.useEffect(()=>{if(!I){const H=n?e.find(ae=>ae.command===n.command):e[0];H&&R(H.slug)}},[e,n,I]),b.useEffect(()=>{!n&&!v.current&&x&&w(x)},[n,x]);const Ee=d.trim()||Array.from(B.trim().split(`
|
|
157
|
-
`)[0].trim()).slice(0,40).join(""),oe=t.find(H=>H.sessionId===O),We=qe?`custom-${le}`:le==="interval"?String(pe):q.length===7?"daily":"workdays",rt=H=>{Ae(H.startsWith("custom-")),["15","60","1440","custom-interval"].includes(H)?(be("interval"),H!=="custom-interval"&&ee(Number(H))):(be("daily"),H==="daily"&&ce([0,1,2,3,4,5,6]),H==="workdays"&&ce([1,2,3,4,5]))},gt=async()=>{if(!(Fe||!Ce)){Le(!0),l(null);try{await s9({id:n?.id,name:Ee,cwd:y,command:V==="new"?Pe:"",prompt:B,targetSessionId:V==="existing"&&O||null,enabled:Be,schedule:le==="interval"?{kind:le,everyMinutes:pe}:{kind:le,time:ke,weekdays:q}}),await c(Ee,Be)}catch(H){l(H instanceof Error?H.message:"保存失败")}finally{Le(!1)}}},ue=le==="interval"?{kind:le,everyMinutes:pe}:{kind:le,time:ke,weekdays:q},[Ye,at]=ke.split(":"),Ne=(H,ae)=>He(`${H}:${ae}`),Ge=B.trim()?V==="existing"&&!t.some(H=>H.sessionId===O)?"请选择当前服务的可用会话":V==="new"&&!Pe?"请选择可启动的 Agent":le==="interval"&&(!Number.isInteger(pe)||pe<1||pe>43200)?"间隔需要是 1–43200 分钟的整数":le==="daily"&&!q.length?"至少选择一天":"":"请填写任务内容",Ce=!Ge;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 pb-3",children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:n?"编辑自动任务":"创建自动任务"}),s.jsx("button",{disabled:Fe,className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",onClick:a,"aria-label":"关闭任务表单",children:s.jsx(In,{size:14})})]}),s.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-y-contain pb-4",children:s.jsxs("fieldset",{disabled:Fe,className:"min-w-0 space-y-4",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["任务内容",s.jsx("textarea",{autoFocus:!0,className:`${$s} min-h-24 resize-y`,rows:3,value:B,onChange:H=>z(H.target.value),placeholder:"例如:检查当前项目的待办,整理需要我处理的问题。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["运行频率",s.jsxs("select",{className:$s,value:We,onChange:H=>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:"自定义星期"})]})]}),le==="interval"&&qe&&s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["每隔多少分钟",s.jsx("input",{className:`${$s} min-w-0 flex-1`,type:"number",min:1,max:43200,value:pe,onChange:H=>ee(Number(H.target.value))})]}),le==="daily"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center rounded-lg border border-border/20 bg-surface-2 px-3 py-1.5 focus-within:border-primary/60",children:[s.jsx(p0,{size:14,className:"mr-2 shrink-0 text-primary"}),s.jsx(Rb,{label:"小时",value:Ye,options:24,onChange:H=>Ne(H,at)}),s.jsx("span",{"aria-hidden":"true",className:"px-2 text-[16px] text-muted-foreground",children:":"}),s.jsx(Rb,{label:"分钟",value:at,options:60,onChange:H=>Ne(Ye,H)}),s.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:"24 小时制"})]}),qe&&s.jsx("div",{className:"grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((H,ae)=>{const ye=q.includes(ae);return s.jsx("button",{type:"button","aria-pressed":ye,"aria-label":`星期${H}`,className:`rounded-lg py-2.5 text-[11px] transition ${ye?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>ce(Ve=>ye?Ve.filter(Je=>Je!==ae):[...Ve,ae].sort()),children:H},ae)})}),q.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(N0,{size:13,className:"shrink-0"}),V==="new"?`每次新建会话 · ${Re?.displayName??(n?.command?"原 Agent":"暂无可用 Agent")}`:`发送到现有会话 · ${oe?.name??"目标会话不可用"}`]}),s.jsx("p",{className:"break-all pl-[19px] text-[10px]",children:V==="new"?y||"默认使用当前目录":"直接写入终端,目标会话需保持在线"})]}),s.jsxs("div",{className:"border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button","aria-expanded":ve,"aria-controls":"automation-more-settings",className:`${vr} -ml-2 px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>Ie(H=>!H),children:[s.jsx(ul,{size:13,className:`transition-transform ${ve?"rotate-180":""}`}),"更多设置"]}),ve&&s.jsxs("div",{id:"automation-more-settings",className:"space-y-3 pt-2",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务名称(可选)",s.jsx("input",{className:$s,value:d,onChange:H=>f(H.target.value),placeholder:Ee||"留空则从任务内容自动生成"})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["运行方式",s.jsxs("select",{className:$s,value:V,onChange:H=>{const ae=H.target.value;Y(ae),ae==="existing"&&!O&&$(m?.sessionId??t[0]?.sessionId??"")},children:[s.jsx("option",{value:"new",children:"每次新建会话"}),s.jsx("option",{value:"existing",disabled:t.length===0,children:"发送到现有会话"})]})]}),V==="new"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["Agent / Plugin",s.jsxs("select",{className:$s,value:I,onChange:H=>R(H.target.value),children:[n&&!e.some(H=>H.command===n.command)&&s.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(H=>s.jsxs("option",{value:H.slug,children:[H.displayName,H.isPlugin?" · Plugin":""]},H.slug))]})]}),s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["工作目录",s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${$s} min-w-0`,value:y,onChange:H=>{v.current=!0,w(H.target.value)},placeholder:"默认使用当前目录"}),s.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${vr} shrink-0 bg-surface-2 text-foreground`,onClick:()=>C(!0),children:[s.jsx(Du,{size:13}),"选择"]})]})]})]}),e.length===0&&s.jsx("p",{className:"text-[10px] text-destructive",children:"没有检测到可启动的 Agent。请先在 Plugin 设置中安装或配置 Agent。"})]}):s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["目标会话",s.jsxs("select",{className:$s,value:O,onChange:H=>$(H.target.value),children:[!oe&&s.jsx("option",{value:O,children:O?"原目标会话不可用,请重新选择":"请选择会话"}),t.map(H=>s.jsxs("option",{value:H.sessionId,children:[H.name," · ",nf(H)]},H.sessionId))]}),s.jsx("span",{className:"block leading-relaxed",children:"仅支持当前服务的会话。运行时会直接写入终端,请确保目标会话保持在线。"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Be,onChange:H=>ne(H.target.checked)}),"保存后启用"]})]})]})]})}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-border/15 pt-3",children:[s.jsx("p",{role:"status",className:"mr-auto min-w-0 flex-[1_1_160px] text-[10px] text-muted-foreground",children:Ge||(Be?`${n?"下次运行":"首次运行"}:${$f(JO(ue,Date.now(),n?.createdAt))}`:"保存后暂停,不会自动运行")}),s.jsx("button",{disabled:Fe,className:`${vr} bg-surface-2 text-foreground`,onClick:a,children:"取消"}),s.jsx("button",{title:Ge||void 0,disabled:Fe||!Ce,className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{gt()},children:Fe?"保存中…":n?"保存修改":"创建任务"})]}),s.jsx(sp,{open:S,initialPath:y||x||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>C(!1),onConfirm:H=>{v.current=!0,w(H),C(!1)}})]})}function Rb({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 PO({fullWorkspace:e=!1,initialView:t="tasks",onOpenGroup:r,active:n,notice:a,initialDrafts:c,onDraftChange:l,docked:d,inputKeySuffix:f,selectedGroupId:m,setSelectedGroupId:x,floatingVisible:y,floating:w,sessionsState:v,groups:S,sessions:C,agents:I,activeSessionId:R,initialGroupId:B,onOpenSession:z,onOpenTaskSession:O,onEnterGroup:$,onDockMessages:V,defaultSessionMode:Y,busy:le,setBusy:be,setError:pe,setNotice:ee,refresh:ke}){const He=w&&!!B&&!!$&&!e,[q,ce]=b.useState(()=>He?"messages":t);b.useEffect(()=>{e&&ce(t)},[t,e]);const[qe,Ae]=b.useState(!1),[ve,Ie]=b.useState(0);b.useEffect(()=>Ie(0),[m]);const[Be,ne]=b.useState(""),[Fe,Le]=b.useState(()=>new Set),[Re,Pe]=b.useState(""),[Ee,oe]=b.useState(()=>new Set),[We,rt]=b.useState(!1),[gt,ue]=b.useState(),[Ye,at]=b.useState([]),[Ne,Ge]=b.useState(!1),[Ce,H]=b.useState(null),ae=Ey(),[ye,Ve]=b.useState(null),[Je,bt]=b.useState(""),[Vt,Pt]=b.useState(!1),[mt,Zt]=b.useState(!1),Ht=b.useRef(null),Kt=b.useRef(null),Ot=b.useRef(null),Nt=()=>{Ot.current=null,Zt(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>{Kt.current?.isConnected&&Kt.current.getClientRects().length?Kt.current.focus():Array.from(Ht.current?.querySelectorAll('button[aria-label="组设置"], button[aria-label="更多看板操作"], summary[aria-label="更多协作操作"]')??[]).find(K=>K.getClientRects().length)?.focus()}))},[me,Ze]=b.useState(null),[ct,Tt]=b.useState(new Set),[X,yt]=b.useState(),[nt,_e]=b.useState({}),[tr,Ke]=b.useState(!1),[kt,Ut]=b.useState(""),[vt,wt]=b.useState(""),[Mt,_t]=b.useState(""),[fr,qt]=b.useState(""),[Sr,pn]=b.useState(""),dr=b.useRef(null),ge=d,Gr=(m??S[0]?.id??"")+f,ot=b.useRef(!1),ft=m==="new"?null:(m?S.find(K=>K.id===m):S[0])??null,ir=ft?.sessionIds.flatMap(K=>{const ze=C.find(Rt=>Rt.sessionId===K);return ze?[ze]:[]})??[],[Mn,Xr]=b.useState(0),De=b.useRef(new Map(Object.entries(c??{}))),[st]=b.useState(()=>({})),xt=b.useRef(void 0),Br=b.useRef(!1),Vr=b.useRef(ye);Vr.current=ye;const Cr=b.useRef(Je);Cr.current=Je,b.useLayoutEffect(()=>{if(xt.current===ft?.id)return;if(xt.current){const ze={content:Cr.current,targets:ye};De.current.set(xt.current,ze),$a({drafts:{[xt.current]:ze}}).catch(()=>pe("草稿保存失败,请返回该组重试"))}xt.current=ft?.id,Br.current=!0;const K=De.current.get(ft?.id??"");bt(K?.content??""),Ve(K?.targets??null)},[ft?.id]),b.useEffect(()=>{Ze(null)},[ft?.id]);const qr=b.useRef(null),mn=b.useRef(c);b.useLayoutEffect(()=>{if(mn.current===c)return;mn.current=c;for(const[ze,Rt]of Object.entries(c??{}))rf.get(Rt)!==st&&De.current.set(ze,Rt);const K=c?.[ft?.id??""];!K||rf.get(K)===st||K.content===Cr.current&&JSON.stringify(K.targets)===JSON.stringify(Vr.current)||(Br.current=!0,qr.current=null,bt(K.content),Ve(K.targets))},[c,ft?.id]);const on=b.useCallback(K=>{$a(K).catch(()=>pe("草稿保存失败,请保持面板打开,修改内容后重试"))},[pe]);b.useLayoutEffect(()=>{if(Br.current){Br.current=!1;return}if(!ft||xt.current!==ft.id)return;const K={drafts:{[ft.id]:{content:Je,targets:ye}}};rf.set(K.drafts[ft.id],st),l(ft.id,K.drafts[ft.id],st),qr.current=K;const ze=setTimeout(()=>{qr.current=null,on(K)},400);return()=>{clearTimeout(ze)}},[ft?.id,Je,ye,on]),b.useEffect(()=>{const K=()=>{qr.current&&(on(qr.current),qr.current=null)},ze=()=>{document.visibilityState==="hidden"&&K()};return document.addEventListener("visibilitychange",ze),window.addEventListener("pagehide",K),()=>{document.removeEventListener("visibilitychange",ze),window.removeEventListener("pagehide",K),K()}},[on]),b.useEffect(()=>{if(!(!(w||e)||!n||!y||!ft||mt||q!=="messages"))return Iy(K=>{ce("messages"),bt(ze=>ze+(ze&&!/\s$/.test(ze)?`
|
|
158
|
-
`:"")+K.replace(/\r\n?/g,`
|
|
159
|
-
`))},Gr,ge)},[w,e,n,y,ft?.id,ge,Gr,q,mt]),b.useEffect(()=>{const K=dr.current;if(!w||!K)return;const ze=Rt=>pe(String(Rt.detail));return K.addEventListener("termdock:file-drop-error",ze),()=>K.removeEventListener("termdock:file-drop-error",ze)},[w,ft?.id,pe]);const zr=async K=>{const ze=ft?.id;pe(null),Xr(Rt=>Rt+1);try{const Rt=await E0("/tmp",K);if(Rt.files.length!==K.length||Rt.files.some(rr=>!rr.path))throw new Error("文件路径准备失败,请重试");const Et=Rt.files.map(rr=>Dc(rr.path)).join(" ")+" ";if(xt.current===ze)bt(rr=>rr+(rr&&!/\s$/.test(rr)?`
|
|
160
|
-
`:"")+Et);else if(ze){const rr=De.current.get(ze)??{content:"",targets:null},jr={...rr,content:rr.content+`
|
|
161
|
-
`+Et};De.current.set(ze,jr),on({drafts:{[ze]:jr}})}}catch(Rt){pe(Rt instanceof Error?Rt.message:"文件上传失败")}finally{Xr(Rt=>Rt-1)}},un=new Set(C.filter(km).map(K=>K.sessionId)),Er=Fe.size,re=[...Fe].filter(K=>!un.has(K)),pt=zO(ft,C),jt=Re.trim().toLocaleLowerCase(),nr=C.filter(K=>!jt||[Iu(K,C),K.name,K.serviceLabel??"",K.cwd,Im(K.currentTask)].some(ze=>ze.toLocaleLowerCase().includes(jt))),Ar=Mb(nr),Fr=Mb(pt),Xt=K=>!jt&&Ee.has(K),Zr=K=>oe(ze=>{const Rt=new Set(ze);return Rt.has(K)?Rt.delete(K):Rt.add(K),Rt});b.useEffect(()=>{Pt(!1),Ot.current!==ft?.id&&Zt(!1),Ot.current=null,Ae(!1),Ke(!1),rt(!1),_e({}),Tt(new Set(ft?.sessionIds??[])),wt(ft?.defaultLaunchProfileId??"")},[ft?.id]),b.useEffect(()=>{!kt&&I[0]&&Ut(I[0].slug)},[I,kt]),b.useEffect(()=>{at([]),H(null)},[ft?.id]),b.useEffect(()=>{if(!B||!n||w&&!y||!ft){Ge(!1);return}Ge(!0);let K=!1,ze=0,Rt=!1;const Et=()=>{if(K||Rt||document.hidden||navigator.onLine===!1)return;Rt=!0;const jr=++ze;cx(ft.id).then(cr=>{!K&&jr===ze&&(at(cr.messages),H(null))}).catch(cr=>{!K&&jr===ze&&H(cr instanceof Error?cr.message:"消息加载失败")}).finally(()=>{Rt=!1,!K&&jr===ze&&Ge(!1)})};Et();const rr=window.setInterval(Et,3e3);return document.addEventListener("visibilitychange",Et),window.addEventListener(af,Et),window.addEventListener("pageshow",Et),()=>{K=!0,window.clearInterval(rr),document.removeEventListener("visibilitychange",Et),window.removeEventListener(af,Et),window.removeEventListener("pageshow",Et)}},[ft?.id,n,w,y]),b.useEffect(()=>{!B||ft?.id!==B||ot.current||(ot.current=!0,q==="messages"&&dr.current?.scrollIntoView?.({block:"nearest"}))},[B,ft?.id]);const Jt=async()=>{be("create-group"),pe(null),ee(null);try{if(re.length)throw new Error("所选会话已变化,请先清除不可用选择");const K=await Ml({name:Be,sessionIds:[...Fe]});ne(""),Pe(""),x(K.group.id),await ke(),ee(`“${K.group.name}”已创建。`),r?await r(K.group.id,"messages"):$&&await $(K.group.id)}catch(K){pe(K instanceof Error?K.message:"创建失败")}finally{be(null)}},Pr=ft?.sessionIds.filter(K=>ye===null||ye.includes(K))??[],Hr=async()=>{if(!ft||le||Mn||!Je.trim()||!Pr.length)return;const K=Je,ze=ft.id;be("send-message"),pe(null),ee(null);try{const Rt=await W8(ft.id,{fromSessionId:null,toSessionIds:ye===null?void 0:Pr,kind:"message",content:Je});if(xt.current===ze){const cr=Cr.current,Cn=cr===K?"":cr.startsWith(K)?cr.slice(K.length).replace(/^\n/,""):cr;bt(Cn),on({drafts:{[ze]:{content:Cn,targets:Vr.current}}})}else{const cr=De.current.get(ze);if(cr){const Cn={...cr,content:cr.content===K?"":cr.content.startsWith(K)?cr.content.slice(K.length).replace(/^\n/,""):cr.content};De.current.set(ze,Cn),on({drafts:{[ze]:Cn}})}}const Et=await cx(ze).catch(()=>null);Et&&xt.current===ze&&at(Et.messages);const rr=Rt.deliveries?.filter(cr=>cr.serviceUnavailable).length??0,jr=Rt.deliveries?.filter(cr=>cr.pending>0).length??0;ee(rr>0?`已保存消息;${rr} 个接收成员的服务不可达,尚未送达,等待重连`:jr>0?`已保存消息;${jr} 个成员等待投递确认`:`消息已送达 ${Rt.messages.length} 个会话`)}catch(Rt){pe(Rt instanceof Error?Rt.message:"发送失败")}finally{be(null)}},ps=async()=>{if(!ft)return;be(`delete:${ft.id}`),pe(null),ee(null);const K=ft.name;try{await Ry(ft.id,gt),x(null),rt(!1),await ke(),ee(`“${K}”已删除`)}catch(ze){pe(ze instanceof Error?ze.message:"删除失败")}finally{be(null)}},Mr=async()=>{if(!ft)return;const K=[...ct];be("save-members"),pe(null),ee(null);try{const ze=await Ml({id:ft.id,name:ft.name,sessionIds:K,expectedUpdatedAt:X});x(ze.group.id),Pt(!1),await ke(),ee(`“${ft.name}”成员已更新,共 ${K.length} 个会话`)}catch(ze){pe(ze instanceof Error?ze.message:"成员更新失败")}finally{be(null)}},jn=async K=>{if(!ft||!ft.sessionIds.includes(K)){Ze(null);return}const ze=C.find(Et=>Et.sessionId===K)?.name??K,Rt=ft.name;be(`remove-member:${K}`),pe(null),ee(null);try{await Ml({id:ft.id,name:Rt,sessionIds:ft.sessionIds.filter(Et=>Et!==K),expectedUpdatedAt:ft.updatedAt}),Ze(null),Tt(Et=>new Set([...Et].filter(rr=>rr!==K))),_e(Et=>Object.fromEntries(Object.entries(Et).filter(([rr])=>rr!==K))),await ke(),ee(`已把“${ze}”移出“${Rt}”`)}catch(Et){pe(Et instanceof Error?Et.message:"移出成员失败")}finally{be(null)}},Tr=async K=>{if(!ft)return;const ze=nt[K]??"";be(`role:${K}`),pe(null),ee(null);try{await Y8(ft.id,K,ze.trim()||null),await ke(),ee(ze.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(Rt){pe(Rt instanceof Error?Rt.message:"定位保存失败")}finally{be(null)}},Jr=()=>{wt(ft?.defaultLaunchProfileId??"");const K=C.find(ze=>ze.sessionId===R)?.cwd??C.find(ze=>ft?.sessionIds.includes(ze.sessionId))?.cwd??"";qt(K),_t(""),pn(""),Ke(!0),Pt(!1)},ln=async()=>{if(!(!ft||!kt||vt&&!ft.launchProfiles?.some(K=>K.id===vt))){be("spawn-agent"),pe(null),ee(null);try{const K=await G8(ft.id,{agentSlug:ft.launchProfiles?.find(ze=>ze.id===vt)?.agentSlug??kt,...vt||ft.launchProfiles?.length?{launchProfileId:vt}:{},name:Mt.trim()||void 0,cwd:fr.trim()||void 0,task:Sr.trim()||void 0,mode:Y});Ke(!1),await ke(),ee(`“${K.session.name}”已创建并加入“${K.group.name}”`)}catch(K){pe(K instanceof Error?K.message:"Agent Session 创建失败")}finally{be(null)}}},Qr=qO(Ye,C),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:!km(K),checked:Fe.has(K.sessionId),onChange:()=>Le(ze=>{const Rt=new Set(ze);return Rt.has(K.sessionId)?Rt.delete(K.sessionId):Rt.add(K.sessionId),Rt})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-[12px] text-foreground",children:Iu(K,C)}),s.jsx(Lm,{session:K}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:nf(K)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:K.currentTask?`${Im(K.currentTask)} · ${K.cwd}`:K.cwd||K.capability||"终端会话"})]})]},K.sessionId),Dr=K=>{const ze=nt[K.sessionId]??"",Rt=ft?.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:!ft?.sessionIds.includes(K.sessionId)&&!km(K),checked:ct.has(K.sessionId),onChange:()=>Tt(Et=>{const rr=new Set(Et);return rr.has(K.sessionId)?rr.delete(K.sessionId):rr.add(K.sessionId),rr})}),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(Lm,{session:K}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[nf(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:`${$s} min-h-8 py-1 text-[10px]`,value:ze,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:Et=>_e(rr=>({...rr,[K.sessionId]:Et.target.value}))}),s.jsx("button",{"aria-label":`保存 ${K.name} 的定位`,title:ze.trim()===Rt?"定位未变化":"保存此成员的定位",disabled:le!==null||ze.trim()===Rt,className:`${vr} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{Tr(K.sessionId)},children:le===`role:${K.sessionId}`?s.jsx(bn,{size:12,className:"animate-spin"}):s.jsx(pi,{size:12})})]})]},K.sessionId)},en=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e||He?"看板":"目标"],["messages","成员与消息"]].map(([K,ze])=>s.jsxs("button",{type:"button","aria-label":ze,"aria-pressed":q===K,className:`${vr} min-h-11 ${q===K?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:Rt=>{if(He&&K==="tasks"){$?.(ft.id).catch(jr=>pe(jr instanceof Error?jr.message:"无法打开看板"));return}const Et=Rt.currentTarget.closest("[data-collaboration-views]"),rr=Rt.currentTarget;ce(K),requestAnimationFrame(()=>{const jr=document.activeElement;jr!==rr&&jr!==document.body&&jr?.isConnected&&!jr.closest("[hidden]")||Array.from(Et?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(cr=>cr.getAttribute("aria-pressed")==="true"&&!cr.closest("[hidden]"))?.focus()})},children:[e&&K==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:ze})]}):ze,!e&&K==="tasks"&&ve>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[ve," 待处理"]})]},K))}),xn=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":mt,className:`${vr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:K=>{Kt.current=K.currentTarget,Zt(ze=>!ze),pe(null),ee(null)},children:[s.jsx(ju,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{ref:Ht,className:e?"flex min-h-0 flex-1 flex-col gap-3":He?void 0:"space-y-3",children:[Ce&&ae==="ready"&&!of(Ce)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",Ce]}),Ce&&of(Ce)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?mt?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[!B&&m!=="new"&&S.length>0&&s.jsx("div",{hidden:mt,children:s.jsx(vO,{groups:S,sessions:C,busy:le!==null,onOpen:(K,ze)=>{r?.(K,ze)},onSettings:(K,ze)=>{Ot.current=K,x(K),Kt.current=ze,Zt(!0),pe(null),ee(null)},onCreate:()=>{x("new"),rt(!1),ee(null)}})}),!B&&(m==="new"||mt)&&S.length>0&&s.jsx("button",{type:"button",className:`${vr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{mt?Nt():x(S[0].id)},children:"返回协作组"}),mt&&ft&&s.jsx(OO,{group:ft,agents:I,activeSessionId:R,sessions:C,busy:le,setBusy:be,setError:pe,setNotice:ee,refresh:ke,onClose:Nt},ft.id),!B&&v!=="loaded"&&!S.length&&s.jsx("p",{role:"status",className:"py-5 text-xs text-muted-foreground",children:v==="loading"?"正在加载协作组与会话…":"会话加载失败,请重试"}),!ft&&(B||m==="new"||v==="loaded")&&s.jsxs("section",{className:"border-y border-border/15 py-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"先给协作组命名。成员可以现在选择,也可以以后添加;消息和看板都能独立使用。"})]}),s.jsxs("span",{className:`shrink-0 text-[10px] ${Er>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",Er," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:$s,value:Be,onChange:K=>ne(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:["复用已有会话(选填) · 已选 ",Er," 个"]}),C.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(jl,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${$s} pl-8`,value:Re,onChange:K=>Pe(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:[Ar.length<=1?nr.map(ks):Ar.map(K=>{const ze=Xt(K.key);return s.jsxs("div",{children:[s.jsx(jb,{label:K.label,count:K.sessions.length,collapsed:ze,onToggle:()=>Zr(K.key)}),!ze&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(ks)})]},K.key)}),C.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:v==="loading"?"正在加载会话…":v==="error"?"会话加载失败,请重试":"没有现有会话也可以创建,开始目标时会启动 Agent"}),C.length>0&&nr.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),re.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",re.length," 个所选会话暂不可用。",s.jsx("button",{className:vr,onClick:()=>Le(K=>new Set([...K].filter(ze=>un.has(ze)))),children:"清除不可用选择"})]}),s.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[s.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${Er<2?"text-muted-foreground":"text-primary"}`,children:Be.trim()?"创建后进入成员消息,看板可随时使用":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[S.length>0&&s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>x(S[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:le!==null||!Be.trim()||re.length>0,className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{Jt()},children:[le==="create-group"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(zs,{size:13}),"创建协作组"]})]})]})]})]}),ft&&B&&s.jsxs("div",{"data-collaboration-views":!0,hidden:mt,className:e?`${mt?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:He?void 0:"space-y-3",children:[!He&&(!e||q==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[en,s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e&&q==="messages"&&s.jsxs("button",{type:"button","aria-label":"放到终端旁",title:V?"在当前终端分屏中使用成员与消息":"先打开一个终端,再嵌入消息面板",disabled:!V||le!==null,className:`${vr} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{be("dock-messages"),pe(null),V?.().catch(K=>pe(K instanceof Error?K.message:"消息面板打开失败,草稿已保留")).finally(()=>be(null))},children:[s.jsx(Fc,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"放到终端旁"})]}),xn]})]}),!He&&q==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:ir.map(K=>s.jsx("button",{type:"button","aria-pressed":K.sessionId===R,title:`${K.name} · ${K.cwd||"终端会话"}`,className:`${vr} min-h-9 shrink-0 ${K.sessionId===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{O(K).catch(ze=>pe(ze instanceof Error?ze.message:"无法打开终端"))},children:Iu(K,ir)},K.sessionId))}),!He&&s.jsx("div",{hidden:q!=="tasks",className:e?`${q==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(NO,{paneKey:d?Gr:void 0,boardNavigation:e?en:void 0,boardSettings:e?xn:void 0,board:e,group:ft,sessions:C,agents:I,defaultCwd:C.find(K=>K.sessionId===R)?.cwd??void 0,onTeamReady:ke,active:n&&!mt&&q==="tasks"&&(!w||y),onAttentionChange:Ie,onManageMembers:()=>ce("messages"),onOpenSession:O},ft.id)}),s.jsxs("div",{hidden:q!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>r0(Gr),onPointerDownCapture:()=>r0(Gr),"data-termdock-terminal-dropzone":w?R??"collaboration-composer":void 0,onDragOver:K=>{w&&K.preventDefault()},onDrop:K=>{if(!w)return;const ze=Array.from(K.dataTransfer.files);if(!(ze.length&&vo()))if(K.preventDefault(),K.stopPropagation(),ze.length)zr(ze);else{const Rt=K.dataTransfer.getData("text/plain")||K.dataTransfer.getData("text/uri-list");Rt&&bt(Et=>Et+(Et?`
|
|
162
|
-
`:"")+Rt)}},ref:dr,className:w?"":"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[!w&&s.jsxs("h4",{className:"truncate text-[12px] font-medium text-foreground",children:[ft.name," · 发送给成员"]}),s.jsxs("div",{className:w?"space-y-2":"mt-2 space-y-2",children:[He&&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(To,{size:16})}),s.jsxs("div",{className:"absolute right-0 top-full z-30 w-44 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:[s.jsxs("button",{type:"button",className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),$?.(ft.id).catch(ze=>pe(ze instanceof Error?ze.message:"无法打开看板"))},children:[s.jsx(Fc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":qe,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Ae(ze=>!ze)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":mt,className:`${vr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Kt.current=K.currentTarget,Zt(!0),pe(null),ee(null)},children:[s.jsx(ju,{size:14}),"组设置"]})]})]})]}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:He?"sr-only":"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...ft.sessionIds.map(K=>({id:K,label:(()=>{const ze=ir.find(Rt=>Rt.sessionId===K);return ze?Iu(ze,ir):void 0})()??`${K.slice(0,8)}(离线)`}))].map(({id:K,label:ze})=>{const Rt=K==="*"?ye===null:ye?.includes(K)??!1,Et=C.find(rr=>rr.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":Rt,onClick:()=>Ve(rr=>K==="*"?null:rr?.includes(K)?rr.filter(jr=>jr!==K):[...rr??[],K]),className:`${M1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Rt?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Rt&&s.jsx(pi,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:ze})]}),Et&&s.jsx("button",{type:"button","aria-label":`打开 ${ze} 的终端`,title:`打开 ${ze} 的终端`,className:"inline-flex h-9 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-primary sm:h-7 sm:w-6",onClick:()=>{z(Et).catch(rr=>pe(rr instanceof Error?rr.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:He?"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(),Hr())},onPaste:K=>{const ze=Array.from(K.clipboardData.files);ze.length&&(K.preventDefault(),zr(ze))},className:`${$s} min-h-16 max-h-48 resize-y`,value:Je,onChange:K=>bt(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:Mn>0?"正在准备文件路径…":w&&a?a:ft.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:le!==null||Mn>0||!Je.trim()||!Pr.length,className:`${vr} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Hr()},children:[le==="send-message"?s.jsx(bn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:He&&!qe,open:He?qe:void 0,onToggle:K=>{He&&Ae(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:["管理成员、角色与删除 · ",ft.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:ft.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[ft.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:X6(ft.id)})]})]}),We?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${vr} bg-surface-2 px-2 text-foreground`,onClick:()=>rt(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${vr} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{ps()},children:[le===`delete:${ft.id}`?s.jsx(bn,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsxs("button",{className:`${vr} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{Tt(new Set(ft.sessionIds)),yt(ft.updatedAt);const K=!Vt;Pt(K),K&&_e(Object.fromEntries(ft.sessionIds.map(ze=>[ze,ft.roles?.[ze]??""]))),Ke(!1)},children:[s.jsx(ju,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${vr} px-2 text-primary hover:bg-primary/10`,onClick:Jr,children:[s.jsx(zs,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${ft.name}`,title:"删除协作组",disabled:le!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{ue(ft.updatedAt),rt(!0)},children:s.jsx(Ms,{size:14})})]})]}),We&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",ft.name,"”协作组及其协作记录,",ft.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:ft.sessionIds.map(K=>{const ze=C.find(rr=>rr.sessionId===K),Rt=ft.roles?.[K],Et=ze?.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:!ze,onClick:()=>ze&&void z(ze).catch(rr=>pe(rr instanceof Error?rr.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 ${ze&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(ze.status)&&ze.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:Et}),ze&&s.jsx(Lm,{session:ze}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:ze?nf(ze):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Rt?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Rt]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,ze?s.jsx("span",{className:"min-w-0 truncate",children:Im(ze.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${Et} 移出协作组`,"aria-expanded":me===K,title:"移出协作组",disabled:le!==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:()=>Ze(me===K?null:K),children:s.jsx(Ms,{size:13})})]},K)})}),me&&ft.sessionIds.includes(me)&&(()=>{const K=C.find(Rt=>Rt.sessionId===me)?.name??me,ze=le===`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}”移出“${ft.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${vr} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Ze(null),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${vr} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{jn(me)},children:[ze?s.jsx(bn,{size:12,className:"animate-spin"}):s.jsx(Ms,{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:["已选 ",ct.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Fr.length<=1?pt.map(Dr):Fr.map(K=>{const ze=Xt(K.key);return s.jsxs("div",{children:[s.jsx(jb,{label:K.label,count:K.sessions.length,collapsed:ze,onToggle:()=>Zr(K.key)}),!ze&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(Dr)})]},K.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>{Pt(!1),_e({})},children:"取消"}),s.jsxs("button",{disabled:le!==null||v!=="loaded",className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{Mr()},children:[le==="save-members"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(pi,{size:13}),"保存成员"]})]})]}),tr&&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(wO,{group:ft,value:vt,onChange:wt,disabled:le!==null}),s.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["Agent / Plugin",s.jsx("select",{"aria-label":"新 Agent 类型",className:$s,disabled:!!vt,value:ft.launchProfiles?.find(K=>K.id===vt)?.agentSlug??kt,onChange:K=>Ut(K.target.value),children:I.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:$s,value:Mt,onChange:K=>_t(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:$s,value:fr,onChange:K=>qt(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:`${$s} min-h-16 resize-y`,value:Sr,onChange:K=>pn(K.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${vr} bg-surface-2 text-foreground`,onClick:()=>Ke(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null||!kt||!!vt&&!ft.launchProfiles?.some(K=>K.id===vt),className:`${vr} bg-primary text-primary-foreground`,onClick:()=>{ln()},children:[le==="spawn-agent"?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(N0,{size:13}),"创建并加入"]})]})]})]})]},ft.id),s.jsxs("section",{className:"mt-4",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[Qr.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[Qr.map(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"?"结果":VO(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.deliveryErrors.map(ze=>s.jsx("p",{role:"status",className:"mt-1 text-[10px] text-destructive",children:ze==="TMUX_PANE_CHANGED"?"目标会话绑定已变化,投递暂停。原消息已保留,请确认目标会话后继续。":`投递暂停:${ze}。原消息已保留,请检查目标会话。`},ze)),(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)),Qr.length===0&&s.jsx(rF,{text:Ne?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function OO({group:e,agents:t,activeSessionId:r,sessions:n,busy:a,setBusy:c,setError:l,setNotice:d,refresh:f,onClose:m}){const x=n.filter(q=>e.sessionIds.includes(q.sessionId)&&!$u(q.sessionId)),[y,w]=b.useState(()=>MO(e,r&&x.some(q=>q.sessionId===r)?r:"")),v=b.useRef(y),[S,C]=b.useState(null),I=q=>{const ce={...v.current,...q};v.current=ce,jO(e.id,ce),w(ce)},{name:R,rules:B,savedName:z,savedRules:O,rulesVersion:$,rulesMemberId:V}=y,Y=Of(y),le=new TextEncoder().encode(B).length,be=x.some(q=>q.sessionId===V),pe=async()=>{if(!(a||!R.trim())){c("group-name"),l(null),d(null);try{const q=await Ml({id:e.id,name:R.trim(),sessionIds:y.sessionIds??e.sessionIds,expectedUpdatedAt:y.updatedAt});C(null),I({savedName:q.group.name,name:q.group.name,updatedAt:q.group.updatedAt,sessionIds:q.group.sessionIds,...B===O?{rules:q.group.instructions?.text??"",savedRules:q.group.instructions?.text??"",rulesVersion:q.group.instructions?.version??""}:{}}),await f(),d("协作组名称已更新")}catch(q){C(null),l(q instanceof t0&&q.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":q instanceof Error?q.message:"改名失败")}finally{c(null)}}},ee=async()=>{if(!(a||!be||le>8192)){c("group-rules"),l(null),d(null);try{const q=await q8(e.id,{sessionId:V,text:B,expectedVersion:$});C(null),I({savedName:q.group.name,...R===z?{name:q.group.name}:{},updatedAt:q.group.updatedAt,sessionIds:q.group.sessionIds,rules:q.group.instructions?.text??"",savedRules:q.group.instructions?.text??"",rulesVersion:q.group.instructions?.version??""}),await f(),d(B.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(q){C(null),l(q instanceof t0&&q.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":q instanceof Error?q.message:"群规保存失败")}finally{c(null)}}},ke=()=>{I(Rg(e,V)),C(null),l(null)},He=async()=>{if(!a){c("group-latest"),l(null),d(null),C(null);try{const ce=(await O1()).groups.find(qe=>qe.id===e.id);if(!ce)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");C(ce)}catch(q){l(q instanceof Error?q.message:"最新状态读取失败;草稿仍保留,请重试。")}finally{c(null)}}};return s.jsxs("section",{"aria-label":"协作组设置",onKeyDown:q=>{q.key!=="Escape"||q.defaultPrevented||q.nativeEvent.isComposing||(q.preventDefault(),q.stopPropagation(),a||m())},className:"mt-3 rounded-xl border border-border/20 bg-surface-2 p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"组设置"}),s.jsx("button",{type:"button",disabled:!!a,"aria-label":"关闭组设置",className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-elevated",onClick:m,children:s.jsx(In,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:$s,value:R,maxLength:240,disabled:!!a,onChange:q=>I({name:q.target.value})})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!a||!!S||!R.trim()||R.trim()===z,className:`${vr} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{pe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(AO,{group:e,agents:t,busy:a,setBusy:c,refresh:f}),s.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/15 pt-3",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["由本组成员发布群规变更",s.jsxs("select",{className:$s,value:V,disabled:!!a||!x.length,onChange:q=>I({rulesMemberId:q.target.value}),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!x.some(q=>q.sessionId===V)&&V&&s.jsx("option",{value:V,children:"原成员已不在组内,请重新选择"}),x.map(q=>s.jsx("option",{value:q.sessionId,children:q.name},q.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${$s} min-h-24 resize-y`,value:B,maxLength:8192,disabled:!!a,onChange:q=>I({rules:q.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!be&&s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x.length?"选择发布变更的成员后即可保存,不需要关闭工作台。":"当前服务没有本组成员,请先添加成员或切换到成员所在的服务。已有群规可在此查看。"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx("p",{className:`text-[9px] ${le>8192?"text-destructive":"text-muted-foreground"}`,children:le>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!S||!be||le>8192||B===O,className:`${vr} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{ee()},children:a==="group-rules"?"保存中…":B.trim()?"保存群规":"清空群规"})]}),Y&&s.jsx("p",{role:"status",className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"有未保存修改。关闭、Escape 或切换组后,草稿仍保留在本标签页;名称与群规需分别保存。"}),Y&&s.jsx("button",{type:"button",disabled:!!a,className:`${vr} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{He()},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(q=>n.find(ce=>ce.sessionId===q)?.name??X6(q)).join("、")||"暂无成员"]}),s.jsx("p",{className:"text-muted-foreground",children:"保留你的未保存内容;名称保存将保留以上成员,群规保存会通知当前成员。再次发生修改时仍会检查冲突。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:!!a,className:`${vr} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{I(RO(v.current,S)),C(null),l(null),d("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${vr} min-h-11 text-muted-foreground`,onClick:()=>C(null),children:"取消确认"})]})]}),s.jsxs("div",{className:"mt-3 flex justify-between gap-2 border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button",disabled:!!a,className:`${vr} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:ke,children:[s.jsx(bn,{size:12}),"重新载入",Y&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${vr} min-h-9 bg-surface text-foreground`,onClick:m,children:Y?"关闭并保留草稿":"关闭"})]})]})}function FO({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:c,onSelectGroup:l}){const[d,f]=b.useState(null),[m,x]=b.useState(!1),y=e.services??[],w=e.removedServices??[],v=y.filter(I=>!I.connected),S=v.some(I=>I.groups?.some(R=>R.id===t)),C=async(I,R)=>{if(!r){n(`peer:${I}`),a(null),c(null);try{R?await e9(I):await t9(I),f(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(I=>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:I.label,serviceOrigin:I.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${I.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:I.connected?"已连接":I.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx($O,{service:I})]}),I.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${I.origin}`,className:`${vr} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>f(d===I.serviceId?null:I.serviceId),children:[s.jsx(Ms,{size:12}),"移除"]})]}),!!I.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:"用于"}),I.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))]}),!I.connected&&I.error&&I.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:YO(I.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:I.error})]}),d===I.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:I.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${vr} min-h-9 text-muted-foreground`,onClick:()=>f(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!I.groups?.length,className:`${vr} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{C(I.serviceId,!1)},children:r===`peer:${I.serviceId}`?"正在移除…":"确认移除"})]})]})]},I.serviceId||I.origin))}),y.length===0&&e.state==="ready"&&s.jsx("p",{className:"py-2 text-[10px] text-muted-foreground",children:"当前没有其他协作服务,当前服务内仍可创建协作组。"}),v.length>0&&s.jsxs("button",{type:"button",className:`${vr} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:J8,children:[s.jsx(bn,{size:12}),"重试连接"]}),w.length>0&&s.jsxs("div",{className:"mt-2 border-t border-border/15 pt-1",children:[s.jsx("button",{type:"button","aria-expanded":m,className:`${vr} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(I=>!I),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(I=>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:I.label,serviceOrigin:I.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:I.accessUrl||I.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!I.serviceId,className:`${vr} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{C(I.serviceId,!0)},children:r===`peer:${I.serviceId}`?"恢复中…":"恢复连接"})]},I.serviceId||I.origin))})]})]})]})]},S?"affected":"other")}function $O({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 km(e){return!$u(e.sessionId)||e.serviceConnected!==!1}function UO(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:$u(e.sessionId)?.origin??""}function Mb(e){const t=new Map;for(const r of e){const n=UO(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 jb({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 zO(e,t){const r=new Map(t.map(n=>[n.sessionId,n]));for(const n of e?.sessionIds??[]){if(r.has(n))continue;const a=e?.remoteSessions?.find(c=>c.sessionId===n);r.set(n,a?{...a,status:"offline",serviceConnected:!1}:{sessionId:n,name:n,backendSessionId:null,cwd:"",agent:null,status:"offline",capability:"",currentTask:"暂不可用,保留成员身份",updatedAt:0,...$u(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function Lm({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 nf(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":GO(e.status)}function HO(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 WO(e){e.sessionId.startsWith("remote:")?await T6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function GO(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function Im(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return Ff(t.prompt)||"暂无任务摘要"}catch{}return Ff(e)||"暂无任务摘要"}function VO(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function qO(e,t){const r=new Map(t.map(a=>[a.sessionId,HO(a,t)])),n=new Map;for(const a of e){const c=`${a.threadId}:${a.createdAt}:${a.fromSessionId??a.integrationOrigin?.integrationId??"user"}:${a.kind}:${a.responseKind??""}:${JSON.stringify(a.task??null)}:${a.content}`,l=n.get(c),d=a.toPrincipalId?`后台接入 ${a.toPrincipalId}`:r.get(a.toSessionId)??a.toSessionId.slice(0,8);if(l){l.toNames.push(d),a.delivery?.stage==="blocked"&&a.delivery.error&&!l.deliveryErrors.includes(a.delivery.error)&&l.deliveryErrors.push(a.delivery.error);const f={failed:-2,expired:-1,pending:0,delivered:1,read:2,stored:3};f[a.status]<f[l.status]&&(l.status=a.status);continue}n.set(c,{key:c,kind:a.kind,content:a.content,createdAt:a.createdAt,fromName:a.fromSessionId?r.get(a.fromSessionId)??a.fromSessionId.slice(0,8):a.integrationOrigin?`后台接入 ${a.integrationOrigin.integrationId}`:"你",toNames:[d],status:a.status,responseKind:a.responseKind,task:a.task,failureReason:a.failureReason,deliveryErrors:a.delivery?.stage==="blocked"&&a.delivery.error?[a.delivery.error]:[]})}return[...n.values()].sort((a,c)=>c.createdAt-a.createdAt)}function YO(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 Em({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 ZO({active:e,onClose:t,onNewSession:r,setError:n}){const[a,c]=b.useState(""),[l,d]=b.useState([]),[f,m]=b.useState(0),[x,y]=b.useState(),[w,v]=b.useState(50),[S,C]=b.useState(0),[I,R]=b.useState(!1),[B,z]=b.useState(null),[O,$]=b.useState(null),V=b.useRef(null),Y=b.useRef(0);b.useEffect(()=>{e&&V.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const pe=++Y.current,ee=new AbortController;let ke;z(null),R(!0);const He=async()=>{try{const q=await r9(a.trim(),w,ee.signal);if(pe!==Y.current)return;d(q.results),m(q.total??q.results.length),y(q.index),q.index?.building&&(ke=window.setTimeout(()=>{He()},2500))}catch(q){pe===Y.current&&!ee.signal.aborted&&z(q instanceof Error?q.message:"搜索失败")}finally{pe===Y.current&&R(!1)}};return ke=window.setTimeout(()=>{He()},a.trim()?250:0),()=>{window.clearTimeout(ke),ee.abort(),++Y.current}},[e,a,w,S]);const le=pe=>{n(null),c(pe),d([]),m(0),v(50)},be=async pe=>{if(!O){if(pe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:pe.sessionId})),t();return}if(!(!pe.nativeKey&&!pe.resumeHistoryId)){$(pe.sessionId),n(null);try{const ee=pe.nativeKey?await n9(pe.nativeKey):await jy(pe.resumeHistoryId);if("sessionId"in ee&&ee.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:ee.sessionId}));else if(ee.command)r({mode:"shell",cwd:ee.cwd,command:ee.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(ee){n(ee instanceof Error?ee.message:"恢复失败")}finally{$(null)}}}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"历史会话搜索"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"搜索当前服务的 Codex、Claude 历史对话和 Termdock 终端记录,未启动的会话也能找到并恢复。"})]}),s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"搜索历史会话"}),s.jsx(jl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:V,maxLength:512,className:`${$s} pl-9 pr-9`,value:a,onChange:pe=>le(pe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),I?s.jsx(bn,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):a&&s.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>le(""),children:s.jsx(In,{size:13})})]}),x?.building&&s.jsxs("div",{role:"status",className:"mt-2 text-[10px] text-muted-foreground",children:["正在建立历史索引:",x.indexed,"/",x.total," 个会话。可以先搜名称和目录,对话结果会自动补齐。"]}),x?.warning&&s.jsx("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:x.warning}),!!x?.failed&&s.jsxs("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:[x.failed," 个会话暂未完成索引,其余结果可正常使用。请稍后刷新重试。"]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[a.trim()?`找到 ${f} 个会话`:"最近的会话",f>l.length?` · 显示 ${l.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:I,className:`${vr} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>C(pe=>pe+1),children:[s.jsx(bn,{size:12}),"刷新"]})]}),!a.trim()&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:"记得之前讨论过什么?输入一句话中的关键词,就能找到对应会话。历史对话与索引保存在当前服务机器上。"}),s.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:l.map(pe=>{const ee=pe.live||!!(pe.nativeKey||pe.resumeHistoryId),ke=O===pe.sessionId?"正在恢复…":pe.live?"打开会话":ee?"恢复会话":"仅供查阅",He=pe.source==="codex"||pe.source==="claude"?pe.snippet:KO(pe),q=pe.source==="codex"?"Codex 历史":pe.source==="claude"?"Claude 历史":"终端记录",ce=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-words text-[12px] font-medium text-foreground",children:s.jsx(Em,{value:pe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(Em,{value:pe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${pe.live?"text-[var(--success)]":ee?"text-primary":"text-muted-foreground"}`,children:ke})]}),He&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(Em,{value:He,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[q," · ",$f(pe.updatedAt),a.trim()?` · ${pe.matchCount>=999?"999+":pe.matchCount} 处匹配`:"",ee?"":" · 没有可恢复记录"]}),pe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:pe.agentNativeSessionId})]});return ee?s.jsx("button",{disabled:!!O,onClick:()=>{be(pe)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:ce},pe.nativeKey||pe.sessionId):s.jsx("article",{className:"px-2 py-3",children:ce},pe.sessionId)})}),f>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:I,className:`${vr} w-full bg-surface-2 text-foreground`,onClick:()=>v(pe=>pe+50),children:I?"正在加载…":"加载更多会话"}),B&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",B,s.jsx("button",{type:"button",className:`${vr} ml-2`,onClick:()=>C(pe=>pe+1),children:"重试"})]}),!I&&!B&&l.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx("p",{className:"text-[12px] text-foreground",children:x?.building?"历史对话仍在索引,请稍候":x?.warning||x?.failed?"暂未找到结果,部分历史记录尚不可搜索":a.trim()?`没有找到“${a.trim()}”`:"当前服务还没有可搜索的历史会话"}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x?.building?"新结果会自动显示,也可以先搜会话名称或目录。":"可尝试更短的关键词、项目目录或 session ID;其他机器的历史需切换到对应服务搜索。"}),a.trim()&&s.jsx("button",{className:`${vr} mt-3 bg-surface-2 text-foreground`,onClick:()=>le(""),children:"查看最近会话"})]})]})}function Ff(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 KO(e){let t=Ff(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return Ff(t)}function XO(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 JO(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 $f(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function eF(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function tF(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function rF({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 nF({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=Ur(),[a,c]=b.useState(!1),l=b.useRef(null),d=b.useRef(null),f=b.useRef(null),m=b.useId();return b.useLayoutEffect(()=>{if(!a)return;const x=l.current,y=f.current;if(!x||!y)return;const w=window.visualViewport,v=()=>{const C=x.getBoundingClientRect(),I=(w?.offsetLeft??0)+8,R=(w?.offsetTop??0)+8,B=(w?.width??window.innerWidth)-16,z=(w?.offsetTop??0)+(w?.height??window.innerHeight)-8,O=Math.max(0,Math.min(256,B)),$=Math.max(0,C.top-R-4),V=Math.max(0,z-C.bottom-4),Y=$>=180||$>=V;Object.assign(y.style,{width:`${O}px`,left:`${Math.max(I,Math.min(C.right-O,I+B-O))}px`,top:`${Y?C.top-4:C.bottom+4}px`,maxHeight:`${Y?$:V}px`,transform:Y?"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;f.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const x=y=>{y.target instanceof Node&&!l.current?.contains(y.target)&&!f.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(wS,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:n("sidebar.settings")})]}),s.jsxs("button",{ref:d,type:"button","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?m:void 0,onClick:()=>c(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),c(!0))},className:`inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${a?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(To,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&Js.createPortal(s.jsx("div",{ref:f,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 Pd=64,Db=10,sF=120;function iF({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:c,compact:l}){const d=b.useRef(null),f=b.useRef(null),m=b.useRef(0),[x,y]=b.useState(null),w=x??(t?Pd: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){f.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(f.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?Pd:0,offset:t?Pd:0,horizontal:!1})}},onPointerMove:v=>{const S=f.current;if(!S||S.pointerId!==v.pointerId)return;const C=v.clientX-S.x,I=v.clientY-S.y;if(!S.horizontal){if(v.defaultPrevented||Date.now()-S.startedAt>=sF||Math.abs(I)>Db){f.current=null;return}if(Math.abs(C)<=Db)return;if(Math.abs(C)<Math.abs(I)*1.5||!t&&C<0){f.current=null;return}S.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),S.offset=Math.max(0,Math.min(Pd,S.initialOffset+C)),y(S.offset)},onPointerUp:v=>{const S=f.current;!S||S.pointerId!==v.pointerId||(f.current=null,S.horizontal&&(m.current=Date.now()+600,r(S.offset>=Pd/2),y(null)))},onPointerCancel:()=>{f.current?.horizontal&&(m.current=Date.now()+600),f.current=null,y(null)},onClickCapture:v=>{if(Date.now()<m.current){m.current=0,v.preventDefault(),v.stopPropagation();return}t&&v.target instanceof Element&&v.target.closest(".sidebar-session-primary")&&(r(!1),v.preventDefault(),v.stopPropagation())},onKeyDown:v=>{t&&v.key==="Escape"&&(v.stopPropagation(),r(!1))},children:[s.jsx("div",{className:"shrink-0 overflow-hidden rounded-md transition-[width] duration-150 ease-out motion-reduce:transition-none",style:{width:w,transition:x===null?void 0:"none"},children:w>0&&s.jsxs("button",{type:"button",tabIndex:t?0:-1,"aria-hidden":!t,"aria-label":c,className:"flex min-h-8 w-16 flex-col items-center justify-center gap-0.5 bg-destructive py-1 text-[10px] text-destructive-foreground",onClick:v=>{v.stopPropagation(),r(!1),n(v)},children:[s.jsx(Ms,{size:14}),a]})}),e]})}const Bb="recoverable-tmux";function aF({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=Ur(),d=Gt(R=>R.collapsedGroups.has(Bb)),f=Gt(R=>R.toggleGroupCollapsed),[m,x]=b.useState(null),[y,w]=b.useState(null),[v,S]=b.useState(null),C=b.useRef(!1),I=async R=>{if(!(!c||C.current)){C.current=!0,w(R),S(null);try{await c(R),x(null)}catch(B){S(B instanceof Error?B.message:l("sidebar.closeRecoverableSessionFailed"))}finally{C.current=!1,w(null)}}};return e.length===0?null:s.jsxs("section",{className:"mb-2 shrink-0 rounded-lg bg-[rgb(var(--tmux-rgb)_/_0.07)] p-1","aria-label":l("sidebar.recoverableSessions"),children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] font-semibold text-[color:var(--tmux)]",children:[s.jsxs("button",{type:"button","aria-expanded":!d,onClick:()=>f(Bb),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(Xs,{size:12,className:`shrink-0 ${d?"":"rotate-90"}`}),s.jsx(Qc,{size:12,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l("sidebar.recoverableSessions")}),s.jsx("span",{className:"text-muted-foreground",children:e.length})]}),n&&s.jsx("button",{type:"button",onClick:n,disabled:t||y!==null,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.refreshRecoverableSessions"),title:l("sidebar.refreshRecoverableSessions"),children:s.jsx(bn,{size:11,className:t?"animate-spin":""})})]}),!d&&s.jsx("div",{className:"space-y-0.5",children:e.map(R=>{const B=R.friendlyName?.trim()||R.label?.trim()||R.name,z=Yu(R.cwd??null),O=r===R.name,$=m===R.name;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsxs("button",{type:"button",disabled:r!==null||y!==null||$,onClick:()=>a(R),className:"group flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-60 md:min-h-10","aria-label":l("sidebar.restoreRecoverableSession",{name:B}),title:R.cwd||R.name,children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--tmux-rgb)_/_0.11)] text-[color:var(--tmux)]",children:O?s.jsx(_n,{size:12,className:"animate-spin"}):s.jsx(qc,{size:12})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:B}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[R.program,z].filter(Boolean).join(" · ")||`tmux:${R.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:l(O?"sidebar.restoringRecoverableSession":"sidebar.restore")})]}),c&&s.jsx("button",{type:"button",disabled:r!==null||y!==null,onClick:()=>{x(R.name),S(null)},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.closeSession",{name:B}),title:l("sidebar.closeSession",{name:B}),children:s.jsx(In,{size:12})})]}),$&&s.jsxs("div",{role:"group","aria-label":l("sidebar.closeSession",{name:B}),className:"space-y-2 rounded-md bg-surface px-2 py-2",children:[s.jsx("p",{className:"text-[11px] text-foreground",children:l("sidebar.confirmCloseRecoverableSession",{name:B})}),v&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:v}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{x(null),S(null)},className:"min-h-11 rounded-md px-2 text-[11px] text-muted-foreground hover:bg-surface-elevated disabled:opacity-50 md:min-h-8",children:l("common.cancel")}),s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{I(R.name)},className:"min-h-11 rounded-md bg-destructive/15 px-2 text-[11px] text-destructive hover:bg-destructive/25 disabled:opacity-50 md:min-h-8",children:y===R.name?l("common.loading"):l("sidebar.endRecoverableSession")})]})]})]},R.name)})})]})}const Od="flex min-h-11 w-full items-center gap-2.5 rounded-lg px-3 text-left text-xs transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",Qb="min-h-11 rounded-lg px-4 text-xs transition disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary";function oF({group:e,collapsed:t,onOpen:r,onMessages:n,onToggleCollapsed:a,onChanged:c,children:l}){const[d,f]=b.useState(null),[m,x]=b.useState(null),[y,w]=b.useState(""),[v,S]=b.useState(!1),C=b.useRef(!1),[I,R]=b.useState(""),B=b.useRef(null),z=b.useRef(null),O=b.useRef(null),$=b.useRef(null),V=b.useRef(null),Y=b.useId(),le=kg(),be=()=>V.current?.isConnected?V.current:z.current,pe=()=>{C.current||(x(null),R(""))};Gc(O,!!d,()=>f(null),be),Gc($,!!m,pe,be);const ee=ce=>{V.current=document.activeElement instanceof HTMLElement&&B.current?.contains(document.activeElement)?document.activeElement:z.current;const qe=z.current?.getBoundingClientRect();f(ce??{x:qe?.left??8,y:qe?.bottom??8})};b.useEffect(()=>{d&&O.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0})},[d]),b.useEffect(()=>{if(!d)return;const ce=Ae=>{Ae.target instanceof Node&&!O.current?.contains(Ae.target)&&!B.current?.contains(Ae.target)&&f(null)},qe=Ae=>{Ae.target instanceof Node&&O.current?.contains(Ae.target)||f(null)};return document.addEventListener("pointerdown",ce),window.addEventListener("resize",qe),window.addEventListener("scroll",qe,!0),()=>{document.removeEventListener("pointerdown",ce),window.removeEventListener("resize",qe),window.removeEventListener("scroll",qe,!0)}},[d]),b.useLayoutEffect(()=>{if(!d||!O.current)return;const ce=window.visualViewport,qe=(ce?.offsetLeft??0)+8,Ae=(ce?.offsetTop??0)+8,ve=Math.min(240,(ce?.width??innerWidth)-16),Ie=Ae+(ce?.height??innerHeight)-16;Object.assign(O.current.style,{width:`${ve}px`,maxHeight:`${Ie-Ae}px`,left:`${Math.max(qe,Math.min(d.x,qe+(ce?.width??innerWidth)-16-ve))}px`,top:`${Math.max(Ae,Math.min(d.y,Ie-O.current.offsetHeight))}px`})},[d]);const ke=ce=>{f(null),ce()},He=ce=>{R(""),w(e.name),x({kind:ce,group:e})},q=async()=>{if(!(!m||C.current||m.kind==="rename"&&!y.trim())){C.current=!0,S(!0),R("");try{const ce=m.group,qe=m.kind==="delete"?(await Ry(ce.id,ce.updatedAt),null):(await Ml({id:ce.id,name:y.trim(),sessionIds:ce.sessionIds,expectedUpdatedAt:ce.updatedAt})).group;x(null),c(qe)}catch(ce){const qe=ce instanceof Error?ce.message:"操作失败,请重试";R(qe.includes("协作组已变化")?"协作组刚刚发生变化,请取消后重新打开操作。":qe)}finally{C.current=!1,S(!1)}}};return s.jsxs("div",{ref:B,className:"flex min-w-0 items-center","data-sidebar-gesture-ignore":!0,...le(()=>ee()),onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),ee({x:ce.clientX,y:ce.clientY})},onKeyDown:ce=>{(ce.key==="ContextMenu"||ce.shiftKey&&ce.key==="F10")&&(ce.preventDefault(),ce.stopPropagation(),ee())},children:[l,s.jsx("button",{ref:z,type:"button","aria-label":`协作组操作:${e.name}`,title:"协作组操作","aria-haspopup":"menu","aria-expanded":!!d,"aria-controls":d?`${Y}-menu`:void 0,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-7",onClick:ce=>{ce.stopPropagation(),d?f(null):ee()},children:s.jsx(To,{size:14})}),d&&Js.createPortal(s.jsxs("div",{ref:O,id:`${Y}-menu`,role:"menu",tabIndex:-1,"aria-label":`协作组操作:${e.name}`,"data-sidebar-gesture-ignore":!0,className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)]",onKeyDown:ce=>{const qe=Array.from(ce.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)')),Ae=qe.indexOf(document.activeElement),ve=ce.key==="ArrowDown"?(Ae+1)%qe.length:ce.key==="ArrowUp"?(Ae-1+qe.length)%qe.length:ce.key==="Home"?0:ce.key==="End"?qe.length-1:null;ve!==null&&(ce.preventDefault(),ce.stopPropagation(),qe[ve]?.focus({preventScroll:!0})),ce.key==="Tab"&&(ce.preventDefault(),f(null))},children:[s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Od,onClick:()=>ke(r),children:[s.jsx(qc,{size:15}),"打开看板"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,disabled:!n,className:`${Od} disabled:opacity-40`,onClick:()=>ke(()=>n?.()),children:[s.jsx(Zu,{size:15}),"成员与消息"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Od,onClick:()=>ke(a),children:[s.jsx(Xs,{size:15,className:t?"":"rotate-90"}),t?"展开成员会话":"收起成员会话"]}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:Od,onClick:()=>ke(()=>He("rename")),children:[s.jsx(ju,{size:15}),"重命名协作组"]}),s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),s.jsxs("button",{role:"menuitem",tabIndex:-1,className:`${Od} text-destructive`,onClick:()=>ke(()=>He("delete")),children:[s.jsx(Ms,{size:15}),"删除协作组"]})]}),document.body),m&&Js.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-black/50 backdrop-blur-sm",onClick:pe}),s.jsxs("section",{ref:$,role:"dialog","aria-modal":"true","aria-labelledby":`${Y}-title`,"aria-describedby":`${Y}-description`,tabIndex:-1,className:"fixed left-1/2 top-1/2 z-modal-panel max-h-[calc(100dvh-2rem)] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 text-foreground shadow-[0_28px_70px_var(--app-shadow-strong)]",children:[s.jsxs("header",{className:"flex items-center gap-2",children:[s.jsx("h2",{id:`${Y}-title`,className:"min-w-0 flex-1 text-sm font-semibold",children:m.kind==="delete"?"删除协作组":"重命名协作组"}),s.jsx("button",{type:"button","aria-label":"关闭协作组操作",disabled:v,className:"flex h-11 w-11 items-center justify-center rounded-lg hover:bg-surface-2",onClick:pe,children:s.jsx(In,{size:16})})]}),s.jsx("p",{id:`${Y}-description`,className:"my-3 break-words text-xs leading-6 text-muted-foreground",children:m.kind==="delete"?s.jsxs(s.Fragment,{children:["确定删除“",m.group.name,"”?协作组及组内消息会被移除,成员终端会保留。此操作无法撤销。",m.group.federated&&"删除会同步到其他服务。"]}):"修改协作组的名称。"}),s.jsxs("form",{onSubmit:ce=>{ce.preventDefault(),q()},children:[m.kind==="rename"&&s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,required:!0,maxLength:256,disabled:v,className:"mt-2 min-h-11 w-full rounded-lg border border-border/30 bg-surface-2 px-3 text-sm text-foreground outline-none focus:border-primary",value:y,onChange:ce=>w(ce.target.value)})]}),I&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs leading-5 text-destructive",children:I}),s.jsxs("footer",{className:"mt-4 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:v,className:`${Qb} bg-surface-2`,onClick:pe,children:"取消"}),s.jsxs("button",{type:"submit",disabled:v||m.kind==="rename"&&!y.trim(),className:`${Qb} inline-flex items-center gap-2 ${m.kind==="delete"?"bg-destructive text-destructive-foreground":"bg-primary text-primary-foreground"}`,children:[v&&s.jsx(bn,{size:14,className:"animate-spin"}),v?m.kind==="delete"?"正在删除…":"正在保存…":m.kind==="delete"?"确认删除":"保存名称"]})]})]})]})]}),document.body)]})}function lF(e,t){return Zy(e,t)}function Fd(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 $d(e,t,r,n=[]){const a=new Map,c=new Map,l=new Set(e.map(x=>x.id));for(const x of n){const y=x.sessionIds.filter(v=>l.has(v));if(!y.length)continue;const w=y.length===x.sessionIds.length?x:{...x,sessionIds:y};y.forEach(v=>a.set(v,w))}for(const x of t)if(!(x.sessionIds.length<2||!x.sessionIds.every(y=>l.has(y)))&&!x.sessionIds.some(y=>a.has(y)))for(const y of x.sessionIds)c.set(y,x);const d=new Set,f=new Set,m=[];for(const x of e){const y=a.get(x.id);if(y){if(d.has(y.id))continue;d.add(y.id);const S=y.sessionIds.flatMap(C=>{const I=r.get(C);return I?[I]:[]});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(f.has(w.id))continue;f.add(w.id);const v=w.sessionIds.flatMap(S=>{const C=r.get(S);return C?[C]:[]});m.push({kind:"workspace",id:`workspace:${w.id}`,workspace:w,members:v,sessionIds:w.sessionIds})}return m}function Pb(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 cF({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(WP,{status:e,detail:t,needsReview:r,inCopyMode:n})}function Ob({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:c,sessionStates:l,onJumpToNextAttention:d,onNewSession:f,onCloseSession:m,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:w,splitWorkspaces:v,onSetSplitLayout:S,onReorderSplitWorkspace:C,onCombineSplitSessions:I,onReorderSessions:R,onSessionMenu:B,onOpenSettings:z,onOpenQuota:O,updateState:$,updateActionPending:V=!1,onConfirmUpdateRestart:Y,onRetryUpdate:le,serverHealthState:be,tmuxAvailable:pe=!0,defaultSessionMode:ee="shell",push:ke,pinned:He,onTogglePinned:q,recoverableTmuxSessions:ce=[],recoverableTmuxSessionsLoading:qe=!1,onRefreshRecoverableTmuxSessions:Ae,onCloseRecoverableTmuxSession:ve}){const{t:Ie}=Ur(),[,Be]=b.useState(0),[ne,Fe]=b.useState(null),[Le,Re]=b.useState(!1),[Pe,Ee]=b.useState(!1),[oe,We]=b.useState(null),rt=b.useRef(!1),gt=b.useRef(0),ue=b.useCallback(G=>{G||(gt.current+=1),Re(G)},[]),[Ye,at]=b.useState(!1),Ne=Ei(G=>G.groupId),[Ge,Ce]=b.useState({}),H=Ye||Object.keys(Ge).length>0,ae=b.useRef(!1),ye=b.useRef(!1),[Ve,Je]=b.useState(null);b.useEffect(()=>{let G=!1;return fc().then(je=>{G||ae.current||Ce(Object.fromEntries(s3(je.collaborationPanels?.[Hf()]).map($e=>[$e,!0])))}).catch(()=>{}),()=>{G=!0}},[]);const bt=async(G,je)=>{ae.current=!0,await $a({floatingGroupId:je},G),Ce($e=>({...$e,[G]:je!==null}))},[Vt,Pt]=b.useState([]),[mt,Zt]=b.useState(!1),[Ht,Kt]=b.useState(null),[Ot,Nt]=b.useState(null),[me,Ze]=b.useState(null),[ct,Tt]=b.useState(null),X=Lu(G=>G.tasks),yt=Lu(G=>G.allTasks),[nt,_e]=b.useState(0),[tr,Ke]=b.useState(null),kt=b.useRef(!1),[Ut,vt]=b.useState({}),wt=Lu(G=>G.error),[Mt,_t]=b.useState(!1);b.useEffect(()=>{const G=()=>{document.hidden||Lu.getState().refresh()};G();const je=window.setInterval(G,5e3);return document.addEventListener("visibilitychange",G),()=>{clearInterval(je),document.removeEventListener("visibilitychange",G)}},[]);const fr=async G=>(ue(!1),ae.current=!0,G?(Ei.getState().open(G),Qr(),!0):(at(!0),Qr(),!0)),qt=hf(G=>G.collaborationGroups),Sr=hf(G=>G.setCollaborationGroups),[pn,dr]=b.useState({mode:ee}),{preference:ge,agents:Gr,detecting:ot,refresh:ft,selectAgent:ir}=yO(),Mn=b.useRef(null),Xr=!!($?.latestVersion&&["installing","ready","restarting","error"].includes($.status)),De=!!be?.attention,st=[Ie("sidebar.moreActions"),De?Ie("sidebar.serverAttention"):null,Xr&&$?.latestVersion?Ie("sidebar.updateAvailable",{version:$.latestVersion}):null].filter(Boolean).join(": "),xt=Gt(G=>G.groupByFolder),Br=Gt(G=>G.collapsedGroups),Vr=Gt(G=>G.toggleGroupCollapsed),Cr=b.useRef(null),qr=b.useRef(null),mn=b.useRef(null),on=b.useRef(0),zr=b.useRef(!1),un=b.useRef(null),Er=b.useRef(null),[re,pt]=b.useState(!1),jt=b.useRef([]),nr=b.useRef(null),Ar=b.useRef(null),Fr=b.useRef(new Set),Xt=b.useRef(null),Zr=b.useMemo(()=>new Set(v.flatMap(G=>G.sessionIds)),[v]),Jt=b.useMemo(()=>new Map(a.map(G=>[G.id,G])),[a]),Pr=b.useMemo(()=>lF(qt,new Set(Jt.keys())),[qt,Jt]),Hr=b.useCallback(async()=>{const G=++on.current;try{const je=await O1();if(G!==on.current)return;Sr(Array.isArray(je.groups)?je.groups:[])}catch{}},[]);b.useEffect(()=>My(G=>Sr(G.groups)),[]),b.useEffect(()=>{Hr();const G=window.setInterval(()=>{Hr()},1e4),je=()=>{Hr()};return window.addEventListener("focus",je),()=>{on.current+=1,window.clearInterval(G),window.removeEventListener("focus",je)}},[Hr]),b.useEffect(()=>{(e||!H)&&Hr()},[H,e,Hr]);const ps=b.useCallback(()=>{jt.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(G=>{const je=G.dataset.collaborationMember??"",$e=G.hasAttribute("data-collaboration-background"),et=G.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!je&&!$e||!et)return[];const it=[];for(let Ct=G.parentElement;Ct;Ct=Ct.parentElement)it.push({element:Ct,top:Ct.scrollTop,left:Ct.scrollLeft});return[{element:G,sessionId:je,groupId:et,background:$e,rect:G.getBoundingClientRect(),scrollParents:it}]})},[]),Mr=b.useCallback((G,je)=>{if(!zr.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(Z=>Z.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Z=>Z.removeAttribute("data-drop-active"));const et=document.elementsFromPoint(G,je).map(Z=>Z.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(et?.dataset.collaborationGroup){et.dataset.dropActive="true",Ar.current={kind:"collaboration",groupId:et.dataset.collaborationGroup,background:!0};return}const it=jt.current.find(Z=>{if(Z.sessionId===Er.current||!Z.element.isConnected)return!1;const fe=Z.scrollParents.reduce((we,lt)=>we+lt.element.scrollLeft-lt.left,0),Qe=Z.scrollParents.reduce((we,lt)=>we+lt.element.scrollTop-lt.top,0);return G>=Z.rect.left-fe&&G<=Z.rect.right-fe&&je>=Z.rect.top-Qe+Z.rect.height*.25&&je<=Z.rect.bottom-Qe-Z.rect.height*.25});if(it?.background){it.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),Ar.current={kind:"collaboration",groupId:it.groupId,background:!0};return}if(it&&!v.find(fe=>fe.sessionIds.includes(it.sessionId))?.sessionIds.includes(Er.current??"")){it.element.dataset.dropActive="true",Ar.current={kind:"split",sessionId:it.sessionId,groupId:it.groupId};return}const Ct=document.elementsFromPoint(G,je).filter(Z=>{const fe=Z.closest("[data-rfd-draggable-id]");return!fe||!["session:","split-member:","collaboration-member:"].some(Qe=>fe.dataset.rfdDraggableId===`${Qe}${Er.current}`)}),Lt=Ct.map(Z=>Z.closest("[data-collaboration-group]")).find(Z=>Z?.dataset.collaborationGroup);if(Lt?.dataset.collaborationGroup){const Z=Lt.dataset.collaborationGroup,fe=Ct.map(At=>At.closest("[data-collaboration-split]")).find(Boolean),Qe=Ct.map(At=>At.closest("[data-collaboration-member]")).find(Boolean),we=Qe?.dataset.collaborationMember??fe?.dataset.splitAnchor,lt=Z===un.current&&v.some(At=>At.sessionIds.includes(we??"")&&At.sessionIds.includes(Er.current??""));if(we&&!lt&&(Z!==un.current||!Qe&&fe)){Lt.dataset.dropActive="true";const At=Qe??fe;At&&(At.dataset.dropActive="true"),Ar.current={kind:"split",sessionId:we,groupId:Z}}else{const At=Ct.some(br=>br.closest("[data-collaboration-background]"));(Z!==un.current||At)&&(Lt.dataset.dropActive="true"),Ar.current={kind:"collaboration",groupId:Z,background:At}}return}const ht=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(Z=>Z.dataset.sidebarEntityListId===nr.current).find(Z=>{const fe=Z.getBoundingClientRect();return G>=fe.left&&G<=fe.right&&je>=fe.top-8&&je<=fe.bottom+8});if(!ht){Ar.current=null;return}const Qt=Array.from(ht.children).filter(Z=>Z instanceof HTMLElement&&Z.hasAttribute("data-sidebar-entity-index")),W=Qt.findIndex(Z=>{const fe=Z.getBoundingClientRect();return je<fe.top+fe.height/2}),N=W<0?Qt.length:W;Ar.current={kind:"list",listId:ht.dataset.sidebarEntityListId??"",index:N};const U=Array.from(ht.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(Z=>Z.dataset.splitExitDropIndex===String(N));U instanceof HTMLElement&&(U.dataset.active="true")},[v]);b.useEffect(()=>{const G=$e=>Mr($e.clientX,$e.clientY),je=$e=>{const et=$e.touches[0];et&&Mr(et.clientX,et.clientY)};return window.addEventListener("pointermove",G),window.addEventListener("touchmove",je,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("touchmove",je)}},[Mr]);const jn=b.useCallback((G,je)=>{try{G(je)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach($e=>{delete $e.dataset.sidebarDragging}),zr.current=!1,jt.current=[],pt(!1),un.current=null,Er.current=null,nr.current=null,Ar.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach($e=>$e.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach($e=>$e.removeAttribute("data-drop-active"))}},[]),Tr=b.useMemo(()=>a.filter(G=>!Zr.has(G.id)),[a,Zr]),Jr=b.useMemo(()=>{let G=0;for(const je of a)l.get(je.id)?.agentStatus==="working"&&(G+=1);return G},[a,l]);b.useLayoutEffect(()=>{const G=Cr.current,je=qr.current;if(!e||!G||!je){mn.current=null;return}const $e=je.getBoundingClientRect(),et=G.getBoundingClientRect(),it={item:G,top:Math.round(et.top-$e.top+je.scrollTop),height:Math.round(et.height),viewportHeight:je.clientHeight},Ct=mn.current;if(mn.current=it,Ct?.item===it.item&&Ct.top===it.top&&Ct.height===it.height&&Ct.viewportHeight===it.viewportHeight||zr.current||je.clientHeight===0)return;const Lt=8,Bt=et.top-$e.top,ht=et.bottom-$e.top;Bt<Lt?je.scrollTop+=Bt-Lt:ht>je.clientHeight-Lt&&(je.scrollTop+=ht-je.clientHeight+Lt)});const ln=b.useMemo(()=>{if(!xt||!c)return null;const G=l.get(c)?.cwd??null;return VS(G)},[xt,c,l]);b.useEffect(()=>{if(!xt){Xt.current=null,Fr.current.clear();return}if(!c){Xt.current=null;return}const G=Gt.getState(),je=Fr.current,$e=Xt.current,et=ln;$e!==null&&$e!==et&&je.has($e)&&(G.collapsedGroups.has($e)||G.toggleGroupCollapsed($e),je.delete($e)),et!==null&&et!==""&&G.collapsedGroups.has(et)&&(G.toggleGroupCollapsed(et),je.add(et)),Xt.current=et},[xt,c,ln]),b.useEffect(()=>{e||ue(!1)},[e]),b.useEffect(()=>{dr(G=>({...G,command:ge?.command}))},[ge]),b.useEffect(()=>{if(!Le)return;let G=!1;return Zt(!0),Nt(null),ux().then(je=>{G||Pt(je)}).catch(()=>{G||Nt(Ie("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{G||Zt(!1)}),()=>{G=!0}},[Le,Ie]),b.useEffect(()=>{if(!ne)return;const G=je=>{je instanceof KeyboardEvent&&je.key!=="Escape"||je instanceof PointerEvent&&je.target instanceof Node&&Mn.current?.contains(je.target)||Fe(null)};return window.addEventListener("pointerdown",G),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",G),window.removeEventListener("keydown",G)}},[ne]);const Qr=()=>{!ke&&!He&&r()};b.useEffect(()=>{const G=je=>{ue(!1);const{groupId:$e,dock:et}=je.detail;ae.current=!0,Kn.getState().setDock($e,{...et,preferredWidth:360}),Ce(it=>({...it,[$e]:!0})),Ei.getState().terminal(),Qr()};return window.addEventListener("termdock:open-collaboration-messages",G),()=>window.removeEventListener("termdock:open-collaboration-messages",G)},[Qr]);const ks=ee==="tmux"&&!pe?"shell":ee,Dr=(G,je=!1)=>{if(rt.current)return;rt.current=!0,Ee(!0),We(null);const $e=gt.current;f({...G,shouldActivate:()=>$e===gt.current&&(G.shouldActivate?.()??!0),onResult:et=>{if(rt.current=!1,Ee(!1),!et.ok){We(et.error);return}$e===gt.current&&(je&&ue(!1),Qr())}})},en=()=>{Dr({mode:ks})},xn=()=>{ge&&Dr({mode:ks,command:ge.command})},K=G=>{ue(!1),Ze(G.name),f({mode:"tmux",tmuxSessionName:G.name,cwd:G.cwd??void 0}),Qr()};b.useEffect(()=>{me&&(ce.some(G=>G.name===me)||Ze(null))},[me,ce]);const ze=(G,je)=>{Dr({...pn,cwd:pn.cwd?.trim()||void 0,command:je??G?.command},!0)},Rt=async G=>{Kt(G.id),Nt(null);try{const je=await jy(G.id);Dr({mode:"shell",cwd:je.cwd,command:je.command},!0)}catch(je){const $e=je&&typeof je=="object"&&"code"in je?String(je.code??""):"";Nt(Ie($e==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Kt(null)}},Et=async G=>{Pt(je=>je.filter($e=>$e.id!==G));try{await f9(G)}catch{Nt(Ie("sidebar.resumeHistoryRemoveFailed")),ux().then(Pt).catch(()=>{})}},rr=()=>{if(Le){ue(!1);return}rt.current||(gt.current+=1,rt.current||We(null),dr({mode:ee==="tmux"&&!pe?"shell":ee,cwd:c?l.get(c)?.cwd??void 0:void 0,command:ge?.command}),ue(!0))},jr=b.useCallback(G=>{const je=l.get(G);return je?.agentStatus==="waiting"||je?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":je?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":je?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),cr=kg(),[Cn,Ls]=b.useState(null);b.useEffect(()=>{e||Ls(null)},[e]);const Xn=b.useCallback((G,je,$e,et,it)=>{const Ct=!Ne&&G.id===c,Lt=Zr.has(G.id),Bt=!!($e&&Lt),ht=l.get(G.id),Qt=Yu(ht?.cwd??null),W=ht?.shellTitle??i9(G.id),N=W===ht?.cwd||W===Qt?null:W,U=a9(G,ht?.activeProgram??null,null,o9,N,ht?.promptState??null),Z=!!(ht?.tuiProgress&&ht.tuiProgress.state!=="remove"),Qe=ht?.promptState==="running"||ht?.agentStatus==="working"||Z?"bg-[var(--success)]":ht?.agentStatus==="waiting"||ht?.agentNeedsReview?"bg-[var(--warning)]":ht?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(iF,{open:Cn===G.id,onOpenChange:we=>Ls(lt=>we?G.id:lt===G.id?null:lt),onClose:we=>m(G.id,we,{skipConfirmation:!0}),closeLabel:Ie("common.close"),closeTitle:Ie("sidebar.closeSession",{name:U}),compact:$e,children:[s.jsxs("button",{ref:Ct?Cr:null,type:"button",...je??{},onContextMenu:we=>{B&&(we.preventDefault(),B(G.id,{x:we.clientX,y:we.clientY}))},onClick:()=>{ue(!1),Ei.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:G.id})),Qr()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${je?"cursor-grab active:cursor-grabbing ":""}${$e?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ht?.cwd??G.name,children:[Ct&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${Qe}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${$e?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${Ct?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:[ht?.isConnecting||Z&&!ht?.agentStatus?s.jsx(_n,{size:$e?10:11,className:"animate-spin"}):ht?.agent??dx(G.id)?s.jsx(Wc,{agent:ht?.agent??dx(G.id),size:$e?13:15}):G.mode==="tmux"?s.jsx(qc,{size:$e?10:11}):s.jsx($o,{size:$e?10:11}),s.jsx(cF,{status:ht?.agentStatus??null,detail:ht?.agentStatusDetail,needsReview:ht?.agentNeedsReview,inCopyMode:ht?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${$e?"text-[11px]":"text-[12px]"} ${Ct?"font-medium text-foreground":""} ${ht?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:U}),s.jsx(z5,{sessionIds:[G.id]})]}),et,s.jsx("button",{type:"button",onClick:we=>{we.stopPropagation(),Bt?w(G.id):Lt?y(G.id):x(G.id)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${$e?"h-6 w-6":"h-[26px] w-[26px]"} ${Lt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${Ie(Bt?"tab.splitRemovePane":Lt?"tab.splitClose":"tab.split")} ${U}`,title:Ie(Bt?"tab.splitRemovePane":Lt?"tab.splitClose":"tab.split"),children:Bt?s.jsx(BS,{size:11}):s.jsx(Il,{size:12})}),it??s.jsx("button",{type:"button",onClick:we=>{we.stopPropagation(),m(G.id,we)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95 ${$e?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":Ie("sidebar.closeSession",{name:U}),title:Ie("common.close"),children:s.jsx(In,{size:$e?11:12})})]})},[c,Zr,l,m,x,y,w,B,Ie,Cn]),cn=b.useMemo(()=>uf(a,G=>l.get(G.id)?.cwd??null,xt,Ie("sidebar.ungrouped"),v,Pr).groups,[Pr,xt,a,l,v,Ie]),dn=b.useMemo(()=>$d(a,v,Jt,Pr),[Pr,a,Jt,v]),_r=b.useCallback(G=>{pt(G.draggableId.startsWith("collaboration:")||G.draggableId.startsWith("workspace:"));const je=G.draggableId.replace(/^split-member:/,"");Er.current=G.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const $e=G.type==="split-member"?v.find(Bt=>Bt.sessionIds.includes(je)):null,et=G.type==="collaboration-member"?G.source.droppableId.replace(/^collaboration-members:/,""):null,it=et?Pr.find(Bt=>Bt.id===et):null;zr.current=!!($e||it||G.type==="session"&&G.draggableId.startsWith("session:")),zr.current&&document.querySelectorAll("[data-collaboration-group]").forEach(Bt=>{Bt.dataset.sidebarDragging="true"}),un.current=it?.id??null;const Ct=$e?.sessionIds??it?.sessionIds??[],Lt=Ct.length>0?cn.find(Bt=>Ct.every(ht=>Bt.sessions.some(Qt=>Qt.id===ht))):null;nr.current=xt?Lt?`group-sessions:${Lt.key}`:null:Ct.length>0?"sidebar-entities":null,Ar.current=null},[Pr,cn,xt,v]),Or=b.useCallback((G,je,$e)=>{if(je===$e)return;const et=je?qt.find(ht=>ht.id===je):null,it=$e?qt.find(ht=>ht.id===$e):null;if($e&&!it)return;if(it){const ht=a.map(W=>W.id).filter(W=>W!==G);let Qt=-1;ht.forEach((W,N)=>{it.sessionIds.includes(W)&&(Qt=N)}),Qt>=0&&(ht.splice(Qt+1,0,G),R(ht))}const Ct=et?.sessionIds.filter(ht=>ht!==G)??[],Lt=it?[...it.sessionIds.filter(ht=>ht!==G),G]:[];Sr(ht=>ht.flatMap(Qt=>Qt.id===je?[{...Qt,sessionIds:Ct}]:Qt.id===$e?[{...Qt,sessionIds:Lt}]:[Qt])),Tt(null),(et&&it?l9({sourceGroupId:et.id,targetGroupId:it.id,sessionId:G,expectedSourceUpdatedAt:et.updatedAt,expectedTargetUpdatedAt:it.updatedAt}):et?Ml({id:et.id,name:et.name,sessionIds:Ct,expectedUpdatedAt:et.updatedAt}):it?Ml({id:it.id,name:it.name,sessionIds:Lt,expectedUpdatedAt:it.updatedAt}):Promise.resolve()).then(()=>Hr(),ht=>(Tt(ht instanceof Error?ht.message:"协作成员移动失败"),Hr()))},[qt,Hr,a,R]),Gn=b.useCallback((G,je,$e,et=!1)=>{const it=qt.find(fe=>fe.id===G);if(!it||je===$e)return;const Ct=it.sessionIds.filter(fe=>!fe.startsWith("remote:")),Lt=Fd(Ct,v).flatMap(fe=>fe.sessionIds),Bt=$5(yt,it.id),ht=et&&!Ut[it.id]?Lt.filter(fe=>!Bt.has(fe)||fe===c||Zr.has(fe)):Lt.slice(),Qt=new Set(ht),[W]=ht.splice(je,1);if(!W)return;ht.splice($e,0,W);let N=0;const U=Lt.map(fe=>Qt.has(fe)?ht[N++]:fe),Z=v.find(fe=>fe.sessionIds.includes(W));if(Z&&Z.sessionIds.every(fe=>it.sessionIds.includes(fe))){const fe=U.filter(Qe=>Z.sessionIds.includes(Qe));C(Z.id,fe)}U.push(...it.sessionIds.filter(fe=>fe.startsWith("remote:"))),Sr(fe=>fe.map(Qe=>Qe.id===G?{...Qe,sessionIds:U}:Qe)),Tt(null),Ml({id:it.id,name:it.name,sessionIds:U,expectedUpdatedAt:it.updatedAt}).then(()=>Hr(),fe=>(Tt(fe instanceof Error?fe.message:"成员排序失败"),Hr()))},[qt,Hr,v,C,yt,Ut,c,Zr]);b.useEffect(()=>{const G=je=>{const{sourceId:$e,targetId:et}=je.detail;if(!$e||!et||$e===et)return;const it=uf(a,we=>l.get(we.id)?.cwd??null,xt,"",v,Pr).arranged.map(we=>we.id),Ct=it.indexOf($e),Lt=it.indexOf(et);if(Ct<0||Lt<0)return;const Bt=Pr.find(we=>we.sessionIds.includes($e));if(Bt?.sessionIds.includes(et)){const we=Fd(Bt.sessionIds,v).flatMap(lt=>lt.sessionIds);Gn(Bt.id,we.indexOf($e),we.indexOf(et));return}const ht=v.filter(we=>we.sessionIds.length>=2&&we.sessionIds.every(lt=>Jt.has(lt))&&!Pr.some(lt=>we.sessionIds.some(At=>lt.sessionIds.includes(At)))),Qt=ht.find(we=>we.sessionIds.includes($e));if(Qt?.sessionIds.includes(et)){const we=[...Qt.sessionIds];we.splice(we.indexOf($e),1),we.splice(Qt.sessionIds.indexOf(et),0,$e),C(Qt.id,we);return}const W=we=>Pr.find(lt=>lt.sessionIds.includes(we))?.sessionIds??ht.find(lt=>lt.sessionIds.includes(we))?.sessionIds??[we],N=new Set(W($e)),U=new Set(W(et)),Z=it.filter(we=>!N.has(we)),fe=Z.flatMap((we,lt)=>U.has(we)?[lt]:[]),Qe=Ct<Lt?Math.max(...fe)+1:Math.min(...fe);Z.splice(Qe,0,...it.filter(we=>N.has(we))),R(Z)};return window.addEventListener("reorder-navigation-session",G),()=>window.removeEventListener("reorder-navigation-session",G)},[a,l,xt,v,Pr,Jt,Gn,C,R]);const Vn=b.useCallback(G=>{if(G.type!=="collaboration-member")return!1;if(G.reason==="CANCEL")return!0;const je=G.source.droppableId.replace(/^collaboration-members:/,""),$e=G.draggableId.replace(/^collaboration-member:/,""),et=Ar.current;if(et?.kind==="split")return Or($e,je,et.groupId),I(et.sessionId,$e),!0;if(et?.kind==="collaboration"&&et.groupId!==je)return Or($e,je,et.groupId),!0;if(et?.kind==="collaboration"&&et.background)return Zr.has($e)&&w($e),!0;if(G.destination&&G.destination.droppableId!==G.source.droppableId){const it=G.destination.droppableId.replace(/^collaboration-members:/,"");if(Pr.some(Ct=>Ct.id===it))return Or($e,je,it),!0}if(G.combine){const it=G.combine.droppableId.replace(/^collaboration-members:/,"");it!==je&&Or($e,je,it);const Ct=G.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(Bt=>Bt.sessionIds.includes($e))?.sessionIds.includes(Ct)){const Bt=Pr.find(Qt=>Qt.id===je),ht=Bt?Fd(Bt.sessionIds,v).flatMap(Qt=>Qt.sessionIds).indexOf(Ct):-1;ht>=0&&Bt&&Gn(je,Fd(Bt.sessionIds,v).flatMap(Qt=>Qt.sessionIds).indexOf($e),ht)}else Jt.has(Ct)&&I(Ct,$e);return!0}if(G.destination?.droppableId===G.source.droppableId)return Gn(je,G.source.index,G.destination.index,!0),!0;if(et?.kind!=="list")return!0;if(et?.kind==="list"){const it=cn.find(Lt=>`group-sessions:${Lt.key}`===et.listId),Ct=et.listId==="sidebar-entities"?dn:it?$d(it.sessions,v,Jt,Pr):null;if(Ct){const Lt=Pb(Ct,$e,et.index);et.listId==="sidebar-entities"?R(Lt):it&&R(cn.flatMap(Bt=>Bt.key===it.key?Lt:Bt.sessions.map(ht=>ht.id)))}}return Or($e,je,null),!0},[Pr,dn,cn,Or,R,Gn,Jt,v,Zr,w,I]),gn=b.useCallback(G=>{if(G.type!=="split-member")return!1;if(G.reason==="CANCEL")return!0;const je=G.draggableId.replace(/^split-member:/,""),$e=v.find(ht=>ht.sessionIds.includes(je));if(!$e?.sessionIds.includes(je))return!0;const et=$e.id,it=Ar.current;if(it?.kind==="split")return Or(je,null,it.groupId),I(it.sessionId,je),!0;if(it?.kind==="collaboration")return Or(je,null,it.groupId),!0;if(!G.destination&&it?.kind==="list"){const ht=cn.find(N=>`group-sessions:${N.key}`===it.listId),Qt=it.listId==="sidebar-entities"?dn:ht?$d(ht.sessions,v,Jt,Pr):null;if(!Qt)return!0;const W=Pb(Qt,je,it.index);return w(je),it.listId==="sidebar-entities"?R(W):ht&&R(cn.flatMap(N=>N.key===ht.key?W:N.sessions.map(U=>U.id))),!0}if(!G.destination)return!0;const Ct=G.destination.droppableId.replace(/^split-members:/,"");if(Ct!==et){const Qt=v.find(W=>W.id===Ct)?.sessionIds[0];return Qt&&I(Qt,je),!0}if(G.source.index===G.destination.index)return!0;const Lt=[...$e.sessionIds],[Bt]=Lt.splice(G.source.index,1);return Bt&&(Lt.splice(G.destination.index,0,Bt),C(et,Lt)),!0},[Pr,dn,cn,Or,I,w,R,C,Jt,v]),Jn=(G,je="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 ${je==="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,je,$e)=>{if(Vn(G)||gn(G)||G.reason==="CANCEL")return;const et=je.find(ht=>ht.id===G.draggableId);if(!et)return;const it=Ar.current;if(it?.kind==="split"&&et.kind==="session"){Or(et.session.id,null,it.groupId),I(it.sessionId,et.session.id);return}if(it?.kind==="collaboration"&&et.kind==="session"){Or(et.session.id,null,it.groupId);return}if(G.combine&&et.kind!=="session"){const ht=je.findIndex(Qt=>Qt.id===G.combine?.draggableId);if(ht<0)return;G={...G,combine:null,destination:{...G.source,index:ht}}}if(G.combine){const ht=je.find(Z=>Z.id===G.combine?.draggableId);if(!ht)return;const Qt=ht.kind==="workspace"?ht:et.kind==="workspace"?et:ht,W=Qt===et?ht:et,N=Qt.sessionIds[0],U=W.sessionIds[0];N&&U&&N!==U&&I(N,U);return}if(!G.destination||G.source.index===G.destination.index)return;const Ct=[...je],[Lt]=Ct.splice(G.source.index,1);if(!Lt)return;Ct.splice(G.destination.index,0,Lt);const Bt=Ct.flatMap(ht=>ht.sessionIds);if($e===void 0){R(Bt);return}R(cn.flatMap(ht=>ht.key===$e?Bt:ht.sessions.map(Qt=>Qt.id)))},[cn,Vn,gn,Or,I,R]),Lr=b.useCallback(G=>{if(G.reason==="CANCEL"||Vn(G)||gn(G))return;if(G.type==="group"){if(!G.destination||G.source.index===G.destination.index)return;R(Yy(cn,G.source.index,G.destination.index));return}const je=G.source.droppableId.replace(/^group-sessions:/,""),$e=cn.find(it=>it.key===je);if(!$e)return;const et=$d($e.sessions,v,Jt,Pr);if(G.combine||Ar.current?.kind==="collaboration"||Ar.current?.kind==="split"){kr(G,et,je);return}!G.destination||G.destination.droppableId!==G.source.droppableId||kr(G,et,je)},[Pr,cn,Jt,v,Vn,kr,gn,R]),pr=G=>{const je=ne===G.id,$e=[{layout:"horizontal",label:Ie("tab.splitHorizontal"),icon:Il},{layout:"vertical",label:Ie("tab.splitVertical"),icon:gx},...G.sessionIds.length>=3||G.layout==="grid"?[{layout:"grid",label:Ie("tab.splitGrid"),icon:mx}]:[]],et=G.layout==="vertical"?gx:G.layout==="grid"?mx:Il,it=$e.find(Ct=>Ct.layout===G.layout)?.label??Ie("tab.splitHorizontal");return s.jsxs("div",{ref:je?Mn:void 0,className:"relative shrink-0",onPointerDown:Ct=>Ct.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 ${je?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${Ie("tab.splitLayout")}: ${it}`,"aria-haspopup":"menu","aria-expanded":je,title:Ie("tab.splitLayout"),onClick:Ct=>{Ct.stopPropagation(),Fe(Lt=>Lt===G.id?null:G.id)},children:s.jsx(et,{size:12})}),je&&s.jsx("div",{role:"menu","aria-label":Ie("tab.splitLayout"),className:"absolute right-0 top-full z-30 mt-1 flex gap-0.5 rounded-md border border-border bg-surface-elevated p-1 shadow-lg",children:$e.map(Ct=>{const Lt=Ct.icon,Bt=Ct.layout===G.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Bt,"aria-label":Ct.label,title:Ct.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:ht=>{ht.stopPropagation(),S(G.sessionIds[0],Ct.layout),Fe(null)},children:s.jsx(Lt,{size:13})},Ct.layout)})})]})},ns=(G,je)=>je&&s.jsx("button",{type:"button",...je,"aria-label":G,title:G,onClick:$e=>$e.stopPropagation(),className:"absolute -left-2 inset-y-0 z-10 flex w-3 cursor-grab items-start justify-center pt-1.5 text-muted-foreground/60 transition hover:text-foreground focus-visible:text-foreground active:cursor-grabbing",children:s.jsx(zf,{size:10})}),Un=(G,je,$e=!1,et=!1,it)=>{if(je.length<2)return null;const Ct=je.some(N=>N.id===c),Lt=[],Bt=[],ht=[];for(const N of je){const U=l.get(N.id);U?.agentStatus==="waiting"||U?.agentNeedsReview?Lt.push(N):U?.agentStatus==="working"?Bt.push(N):U?.inCopyMode&&ht.push(N)}const Qt=G.name?.trim()||`${Ie("tab.splitWorkspace")} ${v.findIndex(N=>N.id===G.id)+1}`,W=ne===G.id;return s.jsxs("section",{"data-split-workspace":G.id,"aria-label":Qt,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 ${et?"bg-primary/15 ring-1 ring-primary/40":$e?"bg-surface-elevated opacity-90 shadow-lg":Lt.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)]":ht.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":Ct?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[ns(`移动分屏组 ${Qt}`,it),s.jsx(Ll,{droppableId:`split-members:${G.id}`,type:"split-member",direction:"vertical",children:(N,U)=>s.jsxs("div",{ref:N.innerRef,...N.droppableProps,"data-split-members":!0,className:U.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[je.map((Z,fe)=>s.jsx(kl,{draggableId:`split-member:${Z.id}`,index:fe,disableInteractiveElementBlocking:!0,children:(Qe,we)=>s.jsx("div",{ref:Qe.innerRef,...Qe.draggableProps,...B?cr(()=>B(Z.id)):{},className:`${fe===0&&W?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${we.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${jr(Z.id)??(Z.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Xn(Z,Qe.dragHandleProps,!0,fe===0?pr(G):void 0)})},Z.id)),N.placeholder]})})]})},En=(G,je)=>{const $e=c??je;ye.current||!$e||(ue(!1),ye.current=!0,Je(G),Tt(null),pC(G,$e).catch(et=>Tt(et instanceof Error?et.message:"消息面板打开失败,请重试")).finally(()=>{ye.current=!1,Je(null)}))},kn=(G,je)=>{on.current+=1,Sr($e=>je?$e.map(et=>et.id===G?je:et):$e.filter(et=>et.id!==G)),je||(Ei.getState().groupId===G&&Ei.getState().terminal(),Kn.getState().setDock(G,null),Ce($e=>{const et={...$e};return delete et[G],et}),requestAnimationFrame(()=>Cr.current?.focus({preventScroll:!0})),$a({floatingGroupId:null},G).catch(()=>Tt("协作组已删除,面板布局保存失败,请刷新后检查。"))),Hr()},ss=(G,je,$e,et=!1,it=!1)=>{const Ct=`collaboration:${G.id}`,Lt=Br.has(Ct),Bt=`collaboration-members-${G.id}`,ht=Ne===G.id||!Ne&&je.some(we=>we.id===c),Qt=$5(yt,G.id),W=G.sessionIds.filter(we=>Qt.has(we)&&we!==c&&!Zr.has(we)),N=Ut[G.id]===!0,U=N?G.sessionIds:G.sessionIds.filter(we=>!W.includes(we)),Z=Fd(U,v),fe=Z.flatMap(we=>we.sessionIds),Qe=Z.length===1?Z[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 ${Lt?"":"p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border"} transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${it?"bg-primary/15 ring-1 ring-primary/40":et?"bg-surface-elevated opacity-90 shadow-lg":ht?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[ns(`移动工作组 ${G.name}`,$e),s.jsxs(oF,{group:qt.find(we=>we.id===G.id)??G,collapsed:Lt,onOpen:()=>{fr(G.id)},onMessages:Ve===null&&(c||je.length)?()=>En(G.id,je[0]?.id):void 0,onToggleCollapsed:()=>Vr(Ct),onChanged:we=>kn(G.id,we),children:[s.jsx("button",{type:"button","aria-label":`${Lt?"展开":"收起"} ${G.name} 的成员会话`,"aria-expanded":!Lt,"aria-controls":Bt,title:`${Lt?"展开":"收起"}成员会话`,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:we=>{we.stopPropagation(),Vr(Ct)},children:s.jsx(Xs,{size:14,className:Lt?"":"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":Ne===G.id?"page":void 0,onClick:we=>{we.stopPropagation(),fr(G.id)},children:[s.jsx(nh,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),X.some(we=>we.groupId===G.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[X.filter(we=>we.groupId===G.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${G.name}`,title:"在终端旁打开成员与消息",disabled:Ve!==null||!c&&!je.length,"aria-busy":Ve===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:we=>{we.stopPropagation(),En(G.id,je[0]?.id)},children:Ve===G.id?s.jsx(bn,{size:14,className:"animate-spin"}):s.jsx(Zu,{size:14})})]}),s.jsx("div",{id:Bt,children:!Lt&&s.jsxs(s.Fragment,{children:[W.length>0&&s.jsxs("button",{type:"button","aria-expanded":N,className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-elevated md:min-h-8",title:"展开后可查看或归档执行会话,任务结果保留。",onClick:()=>vt(we=>({...we,[G.id]:!N})),children:[s.jsx(Xs,{size:12,className:N?"rotate-90":""}),"已完成的执行会话 · ",W.length]}),s.jsx(Ll,{droppableId:`collaboration-members:${G.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(we,lt)=>s.jsxs("div",{ref:we.innerRef,...we.droppableProps,"data-collaboration-members":!0,className:`${lt.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[Z.map(At=>s.jsx("div",{"data-collaboration-split":At.workspace?.id,"data-split-anchor":At.workspace?.sessionIds[0],role:At.workspace?"region":void 0,"aria-label":At.workspace?`${Ie("tab.splitWorkspace")} · ${At.sessionIds.length}`:void 0,className:At.workspace&&!Qe?`relative my-0.5 rounded-sm before:pointer-events-none before:absolute before:inset-0 before:rounded-sm before:border before:border-border data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${At.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:At.sessionIds.map(br=>{const It=Jt.get(br);return It?s.jsx(kl,{draggableId:`collaboration-member:${It.id}`,index:fe.indexOf(It.id),disableInteractiveElementBlocking:!0,children:(rn,yn)=>s.jsxs("div",{ref:rn.innerRef,...rn.draggableProps,"data-collaboration-member":It.id,"data-split-member":Zr.has(It.id)?"true":void 0,...B?cr(()=>B(It.id)):{},className:`${At.workspace&&br===At.sessionIds[0]&&ne===At.workspace.id?"z-20 ":""}relative flex items-center rounded-sm pr-0.5 transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${yn.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":yn.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${jr(It.id)??(It.id===c?"bg-surface-elevated/80 text-foreground":Zr.has(It.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Xn(It,rn.dragHandleProps,!0,At.workspace&&br===At.sessionIds[0]?pr(At.workspace):void 0,Qt.has(br)?s.jsxs("button",{type:"button","aria-label":`归档 ${It.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:tr!==null,className:"sidebar-session-action inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-primary/15 hover:text-primary disabled:opacity-40 md:h-6 md:min-w-6 md:px-1",onClick:hn=>{hn.stopPropagation(),!kt.current&&(kt.current=!0,Ke(br),Tt(null),h9(br).then(async()=>{_e(Dn=>Dn+1),await Hr()}).catch(Dn=>Tt(Dn instanceof Error?Dn.message:"归档失败,终端已保留")).finally(()=>{kt.current=!1,Ke(null)}))},children:[tr===br?s.jsx(bn,{size:13,className:"animate-spin"}):s.jsx(Dy,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!At.workspace&&Zr.has(It.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(hn=>hn.sessionIds.includes(It.id))?.sessionIds.filter(hn=>hn!==It.id).map(hn=>Jt.get(hn)?.name??hn).join("、")} 分屏`,"aria-label":`查看 ${It.name} 的跨组分屏`,onClick:()=>{ue(!1),Ei.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:It.id})),Qr()},children:s.jsx(Il,{size:10})})]})},It.id):null})},At.workspace?.id??At.sessionIds[0])),we.placeholder]})}),s.jsx(sQ,{groupId:G.id,version:nt,onRestore:async we=>{ue(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:we.cwd,preferredFrontendSessionId:we.sessionId,requireExisting:!0}})),await Hr(),Ei.getState().terminal(),Qr()}}),G.remoteSessions?.map(we=>s.jsxs("button",{type:"button",title:`${uc(we)} · ${we.serviceConnected===!1?"服务不可达,消息尚未送达":we.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),T6(we.sessionId).catch(()=>{fr(G.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${we.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:we.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:uc(we)}),we.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},we.sessionId))]})}),s.jsx("div",{"data-collaboration-background":!0,className:Lt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},Wr=(G,je,$e)=>s.jsx(u0,{onBeforeCapture:ps,onDragStart:_r,onDragEnd:et=>jn(it=>kr(it,G,$e),et),children:s.jsx(Ll,{droppableId:je,direction:"vertical",isCombineEnabled:!re,children:et=>s.jsxs("div",{ref:et.innerRef,...et.droppableProps,"data-sidebar-entity-list-id":je,className:"flex-1 space-y-0.5",children:[G.map((it,Ct)=>s.jsx(kl,{draggableId:it.id,index:Ct,disableInteractiveElementBlocking:!0,children:(Lt,Bt)=>s.jsxs("div",{ref:Lt.innerRef,...Lt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":Ct,className:"relative",children:[Jn(Ct),Ct===G.length-1&&Jn(G.length,"bottom"),it.kind==="workspace"?Un(it.workspace,it.members,Bt.isDragging,!!Bt.combineTargetFor,Lt.dragHandleProps):it.kind==="collaboration"?ss(it.group,it.members,Lt.dragHandleProps,Bt.isDragging,!!Bt.combineTargetFor):s.jsx("div",{...B?cr(()=>B(it.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":jr(it.session.id)??(!Ne&&it.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(it.session,Lt.dragHandleProps)})]})},it.id)),et.placeholder]})})}),tn=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{"data-session-sidebar-header":!0,className:"relative z-20 shrink-0 px-3 py-0.5",children:[s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-3 bottom-0 z-10 h-px bg-border opacity-40"}),s.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:Ie("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),Jr>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(O6,{count:Jr,tone:"running",title:Ie("agent.aiRunning")})})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:()=>{ue(!1),fr(null)},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":"Agent 工作台",title:"Agent 工作台",children:s.jsx(nh,{size:16})}),(!ke||He)&&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":Ie("common.close"),children:s.jsx(In,{size:16})})]})]})]}),ct&&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:ct}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>Tt(null),children:s.jsx(In,{size:14})})]}),s.jsxs("div",{ref:qr,className:"relative z-10 flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain px-1.5 pt-0.5 pb-1.5",children:[X.length>0&&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":Mt,onClick:()=>_t(G=>!G),children:[s.jsx(nh,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:X.length}),s.jsx(Xs,{size:12,className:Mt?"rotate-90":""})]}),Mt&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[wt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[wt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{Lu.getState().refresh()},children:"重试"})]}),X.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:()=>{U5(G.groupId,G.id),fr(G.groupId).then(je=>{je&&U5(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:[qt.find(je=>je.id===G.groupId)?.name??"协作组"," · ",Xc(G)]})]},G.id))]})]}),s.jsx(aF,{sessions:ce,loading:qe,attachingName:me,onRefresh:Ae,onRestore:K,onClose:ve}),Pr.filter(G=>!G.sessionIds.length).map(G=>s.jsx(u0,{onDragEnd:()=>{},children:ss(G,[])},G.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx($o,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:Ie("sidebar.noSessions")})]}):Tr.length===0&&v.length===0?s.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:s.jsx("p",{className:"text-[12px] text-muted-foreground",children:Ie("sidebar.noMatchingSessions")})}):xt?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(u0,{onBeforeCapture:ps,onDragStart:_r,onDragEnd:G=>jn(Lr,G),children:s.jsx(Ll,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:G=>s.jsxs("div",{ref:G.innerRef,...G.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[cn.map((je,$e)=>{const et=Br.has(je.key),it=!et&&$e===cn.length-1,Ct=$d(je.sessions,v,Jt,Pr);let Lt=0,Bt=0;for(const Qt of je.sessions){const W=l.get(Qt.id);W?.agentStatus==="working"&&(Lt+=1),(W?.agentStatus==="waiting"||W?.agentNeedsReview)&&(Bt+=1)}const ht=je.key==="";return s.jsx(kl,{draggableId:`sidebar-group:${je.key||"__ungrouped__"}`,index:$e,isDragDisabled:ht,disableInteractiveElementBlocking:!0,children:(Qt,W)=>s.jsxs("div",{ref:Qt.innerRef,...Qt.draggableProps,className:`shrink-0 rounded-md transition-colors ${it?"flex flex-1 flex-col ":""}${W.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ht?{}:Qt.dragHandleProps,onClick:()=>{Vr(je.key),Fr.current.delete(je.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 ${ht?"":"cursor-grab active:cursor-grabbing"}`,title:je.key||je.label,children:[s.jsx(Xs,{size:13,className:`shrink-0 transition-transform ${et?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:je.label}),Lt>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(z5,{sessionIds:je.sessions.map(N=>N.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:je.sessions.length})]}),!et&&s.jsx("div",{className:`mt-0.5 pl-2 ${it?"flex flex-1 flex-col":""}`,children:s.jsx(Ll,{droppableId:`group-sessions:${je.key}`,type:"session",direction:"vertical",isCombineEnabled:!re,children:N=>s.jsxs("div",{ref:N.innerRef,...N.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${je.key}`,className:`${it?"flex-1 ":""}space-y-0.5`,children:[Ct.map((U,Z)=>s.jsx(kl,{draggableId:U.id,index:Z,disableInteractiveElementBlocking:!0,children:(fe,Qe)=>s.jsxs("div",{ref:fe.innerRef,...fe.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":Z,className:"relative",children:[Jn(Z),Z===Ct.length-1&&Jn(Ct.length,"bottom"),U.kind==="workspace"?Un(U.workspace,U.members,Qe.isDragging,!!Qe.combineTargetFor,fe.dragHandleProps):U.kind==="collaboration"?ss(U.group,U.members,fe.dragHandleProps,Qe.isDragging,!!Qe.combineTargetFor):s.jsx("div",{...B?cr(()=>B(U.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${Qe.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":Qe.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":jr(U.session.id)??(!Ne&&U.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Xn(U.session,fe.dragHandleProps)})]})},U.id)),N.placeholder]})})})]})},je.key||"__ungrouped__")}),G.placeholder]})})})}):Wr(dn,"sidebar-entities")]}),s.jsx(c9,{onReselect:()=>{d&&(mn.current=null,Be(G=>G+1),d())}}),Le&&s.jsx(gO,{directories:a.flatMap(G=>{const je=l.get(G.id)?.cwd;return je?[je]:[]}),tmuxAvailable:pe,options:pn,launchPending:Pe,launchError:oe?Ie(Hm(oe)):null,agents:Gr,selectedAgent:ge,detecting:ot,resumeHistory:Vt,resumeHistoryLoading:mt,resumeHistoryPendingId:Ht,resumeHistoryError:Ot,onRefreshAgents:()=>{ft().catch(()=>{})},onSelectAgent:G=>{ir(G).catch(()=>{})},onLaunchAgent:ze,onResumeHistory:G=>{Rt(G)},onRemoveResumeHistory:G=>{Et(G)},onClose:()=>ue(!1),onOptionsChange:dr,additionalContent:Xr&&$?.latestVersion&&s.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:s.jsx(bn,{size:13,className:$.status==="installing"||$.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:Ie("sidebar.updateAvailable",{version:$.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:$.status==="installing"?Ie("sidebar.updateInstalling"):$.status==="ready"?Ie("sidebar.updateReady"):$.status==="restarting"?Ie("sidebar.updateRestarting"):Ie("sidebar.updateFailed")})]})]}),$.status==="ready"&&Y&&s.jsx("button",{type:"button",disabled:V,onClick:Y,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:Ie("sidebar.updateRestart")}),$.status==="error"&&le&&s.jsx("button",{type:"button",disabled:V,onClick:le,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:Ie("sidebar.updateRetry")})]}),footerActions:s.jsx(nF,{serverAttention:De,onOpenSettings:()=>{ue(!1),z()},actions:[...O?[{label:Ie("sidebar.subscriptionQuota"),icon:GA,onSelect:()=>{ue(!1),O()}}]:[],{label:"Agent 工作台",icon:nh,onSelect:()=>{ue(!1),fr(null)}},{label:"服务与设备",icon:u9,onSelect:()=>{ue(!1),d9()}},...q?[{label:Ie(He?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:He?x0:g0,separated:!0,onSelect:()=>{ue(!1),q()}}]:[]]})}),Ye&&s.jsx(Eb,{onEnterGroup:async G=>{if(!await fr(G))throw new Error("协作组已保存,打开工作区失败,请重试");at(!1)},onFloatingChange:async G=>{if(G){if(!await fr(G))throw new Error("打开协作工作区失败");at(!1)}},activeSessionId:c,defaultSessionMode:ee,onClose:()=>at(!1),onNewSession:G=>f(G)}),Object.entries(Ge).map(([G,je])=>s.jsx(Eb,{activeSessionId:c,initialCollaborationGroupId:G,initialFloating:je,visible:!Ne,onEnterGroup:async $e=>{if($e===G){await fr($e);return}if(!await fr($e))throw new Error("协作组已保存,打开工作区失败,请重试");await $a({floatingGroupId:null},G),Ce(et=>{const it={...et};return delete it[G],it})},onFloatingChange:$e=>bt(G,$e),defaultSessionMode:ee,onClose:()=>{ae.current=!0,Ce($e=>{const et={...$e};return delete et[G],et})},onNewSession:$e=>f($e)},G)),!Le&&s.jsxs("div",{className:"relative z-10 shrink-0 bg-[var(--chrome-bg)] px-3 pb-3 pt-1 md:border-t md:border-border md:p-2",children:[oe&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:Ie(Hm(oe))}),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:en,disabled:Pe,"aria-busy":Pe,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${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:Ie("sidebar.newSession"),"aria-label":Ie("sidebar.newSession"),children:[s.jsx($o,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Pe?Ie("sidebar.sessionCreating"):"Terminal"})]}),ge&&s.jsxs("button",{type:"button",onClick:xn,disabled:Pe,"aria-busy":Pe,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:Ie("sidebar.newSessionWithAgent",{agent:ge.displayName}),"aria-label":Ie("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:rr,disabled:Pe,className:"relative inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:st,"aria-label":st,"aria-expanded":Le,"aria-controls":"sidebar-launch-options",children:[s.jsx(To,{size:15}),De&&s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2 w-2 rounded-full bg-destructive ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"}),Xr&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${De?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})]})]});return He?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:tn}):s.jsx(B6,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:ke,children:tn})}function uF(){const{t:e}=Ur();return s.jsxs("div",{role:"status","aria-label":e("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[s.jsx("span",{className:"sr-only",children:e("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",className:"shrink-0 border-b border-border/15 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex h-5 items-center gap-1",children:[s.jsx("div",{className:"h-4 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-7 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-12 rounded bg-surface-2"})]}),s.jsxs("div",{className:"flex h-[15px] items-center justify-between",children:[s.jsx("div",{className:"h-2 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-6 rounded bg-surface-2"})]}),s.jsxs("div",{className:"mt-2 flex h-7 items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-12 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-7 w-16 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-3 w-24 max-w-[30%] rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-4 rounded-full bg-surface-2"})]})]}),s.jsxs("div",{"aria-hidden":"true",className:"overflow-hidden px-3 py-2",children:[s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("div",{className:"h-3 w-3 rounded-sm bg-surface-2"}),s.jsx("div",{className:"h-2 w-32 max-w-[55%] rounded bg-surface-2"})]}),["w-3/5","w-2/5","w-1/2","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-9 items-center gap-2 pl-5",style:{opacity:1-r*.15},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},t))]})]})}function dF({slow:e=!1}){const{t}=Ur();return s.jsxs("div",{role:"status","aria-label":t("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton relative h-full min-h-0 overflow-hidden bg-surface px-3",children:[s.jsx("span",{className:"sr-only",children:t("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",children:[s.jsxs("div",{className:"flex h-[76px] items-center gap-2 border-b border-border/40 px-2",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-12 rounded bg-surface-2"})]})]}),s.jsxs("div",{className:"flex h-11 items-center gap-2 px-1 pt-3",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-12 rounded-full bg-surface-2"})]}),[!1,!0].map(r=>s.jsxs("div",{className:"border-b border-border/40 px-1 py-4",children:[s.jsxs("div",{className:"mb-2 flex h-8 items-center justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),r&&s.jsx("div",{className:"h-2 w-28 rounded bg-surface-2"})]}),s.jsx("div",{className:"h-8 w-12 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]},String(r))),s.jsx("div",{className:"flex h-[69px] items-center border-b border-border/40 px-2",children:s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"})}),s.jsxs("div",{className:"space-y-2 px-1 py-4",children:[s.jsxs("div",{className:"flex h-8 items-center justify-between",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-8 w-28 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-7 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]})]}),e&&s.jsx("div",{className:"absolute inset-x-3 bottom-3 rounded-md bg-surface-elevated px-3 py-2 text-xs text-muted-foreground",children:t("rightSidebar.loadingGitChangesSlow")})]})}const J6=()=>Oc(()=>import("./RightSidebar-CUHSFkmZ.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})),hF=b.lazy(J6);function Fb(e){const t=b.useRef(!1);b.useEffect(()=>{const f=navigator.connection;if(!(f?.saveData||/2g|3g/.test(f?.effectiveType??"")))return H1(()=>{J6().catch(()=>{})},3e3)},[]);const{t:r}=Ur(),n=Gt(f=>f.rootPath),a=Gt(f=>f.rightTab),c=Gt(f=>f.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const d=s.jsx(B6,{side:"right",isOpen:e.isOpen,drawerWidthPx:e.drawerWidthPx,onClose:e.onClose,onOpen:e.onOpen,pinned:e.pinned,children:s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 px-1",children:s.jsx("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:s.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",children:l})})}),s.jsx("div",{"aria-hidden":"true",className:"flex items-center gap-1.5",children:[jl,iS,To].map((f,m)=>s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-surface-2 text-muted-foreground",children:s.jsx(f,{size:14})},m))}),s.jsx("button",{type:"button",onClick:e.onClose,"aria-label":r("common.close"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:s.jsx(In,{size:14})})]}),s.jsx("div",{className:"mt-2 grid grid-cols-5 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[["git",_A,"rightSidebar.tabGit"],["diff",LA,"rightSidebar.tabChanges"],["files",Vc,"rightSidebar.tabFiles"],["architecture",HT,"architecture.tab"],["computer",p9,"rightSidebar.tabComputer"]].map(([f,m,x])=>s.jsxs("button",{type:"button",onClick:()=>c(f),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===f?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(m,{size:12}),r(x)]},f))}),s.jsx("div",{className:"h-2"})]}),s.jsx("div",{className:"min-h-0 flex-1 bg-surface",children:a==="architecture"?s.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:r("architecture.loading")}):a==="computer"?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:r("computer.loading")}):a==="git"?s.jsx(dF,{}):s.jsx(uF,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:d,children:s.jsx(hF,{...e})}):d}const $b=hc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function fF(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 pF=hc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=i3(),a=Date.now(),c=t().sessions,l=fF(c),d={id:n,cwd:r,sessionId:null,name:l,customName:!1,createdAt:a,lastActivity:a};return e(f=>{const m=new Map(f.sessions);return m.set(n,d),{sessions:m,activeSessionId:f.activeSessionId??n,nextSessionNumber:f.nextSessionNumber+1}}),n},closeSession:r=>{e(n=>{const a=new Map(n.sessions),c=n.activeSessionId===r;a.delete(r);let l=n.activeSessionId;if(c){const d=Array.from(a.keys());l=d.length>0?d[0]:null}return{sessions:a,activeSessionId:l}})},switchSession:r=>{e(n=>n.sessions.has(r)?{activeSessionId:r}:n)},updateSession:(r,n)=>{e(a=>{const c=a.sessions.get(r);if(!c)return a;const l=new Map(a.sessions);return l.set(r,{...c,...n,lastActivity:Date.now()}),{sessions:l}})},setTerminalSession:(r,n)=>{t().updateSession(r,{sessionId:n.sessionId})},getActiveSession:()=>{const r=t();if(r.activeSessionId)return r.sessions.get(r.activeSessionId)},getSessionCount:()=>t().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}})),mF=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class gF{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 mF[this.level]}connected(t){this.connectedAt=t,this.badSince=this.goodSince=null,this.lastSample=-1/0}sample(t,r,n=1600){if(r-this.lastSample>2500&&(this.badSince=this.goodSince=null),this.lastSample=r,t.rttMs!==null&&(this.baselineRtt=Math.min(this.baselineRtt,t.rttMs)),r-this.connectedAt<3e3)return null;const a=t.rttMs!==null&&t.rttMs>this.baselineRtt+150,c=t.deliveryDelayMs>250||t.decodeQueue>=4||a&&t.frames>0&&t.deliveryDelayMs>100,l=t.deliveryDelayMs>800||t.decodeQueue>=8,d=t.rttMs!==null&&t.rttMs<this.baselineRtt+100&&t.deliveryDelayMs<80&&t.decodeQueue<=1;this.badSince=c?this.badSince??r:null,this.goodSince=d?this.goodSince??r:null;const f=n<=1080?7:n<=1600?9:11;if(this.badSince!==null&&r-this.badSince>=(l?1e3:2e3)&&r-this.lastChange>=(l?2e3:3e3)&&this.level>0){this.level=Math.max(0,this.level-(l?2:1));const m=r-this.lastUpgrade<2e4;this.failedProbes=m?this.failedProbes+1:0,this.upgradeAfter=r+(m?Math.min(3e4,8e3*2**(this.failedProbes-1)):5e3),this.lastUpgrade=-1/0}else if(this.goodSince!==null&&r-this.goodSince>=3e3&&r-this.lastChange>=4e3&&r>=this.upgradeAfter&&this.level<f)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function eu(e,t){const r=await fetch(e,{...t,headers:{"Content-Type":"application/json",Accept:"application/json",...t?.headers??{}}}),n=await r.json().catch(()=>null);if(!r.ok||!n){const a=n?.error||n?.code||`ANDROID_REQUEST_FAILED_${r.status}`;throw new Error(a)}return n}async function xF(){return eu("/api/android/devices")}async function bF(e){return eu("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const Uf=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],I0=Uf[1];function j1(e){if(!e||typeof e!="object")return I0;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=Uf.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return I0;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 yF(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 Ub(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 vF(e){return eu(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function wF(e){return eu("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function AF(e){return eu(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function TF(e,t){return eu(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function SF(e){return eu(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const CF=0,_F=1,kF=2,LF=3,IF=4,EF=5,NF=7,RF=10,MF=11,jF=16,zb=17,Hb=0,Nm=1,DF=2,Wb=3,Rm=0,Gb=1,Vb=1,Tu=0xffffffffffffffffn,Nh=0xfffffffffffffffen,Ud={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function e4(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 BF(e,t,r,n,a,c){const l=new Uint8Array(32),d=new DataView(l.buffer);return d.setUint8(0,kF),d.setUint8(1,e),d.setBigUint64(2,t),e4(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 Mm(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,CF),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function QF(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,LF),e4(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 PF(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,_F),a.setUint32(1,r.length),n.set(r,5),n}function OF(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]=jF,r[1]=t.length,r.set(t,2),r}function zd(e){return new Uint8Array([e])}function qb(e){return new Uint8Array([IF,e])}function FF(e){return new Uint8Array([RF,e?1:0])}function $F(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function UF(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 jm(e){return e.toString(16).padStart(2,"0")}function t4(e,t,r){for(let n=0;n+4<e.length;n++){const a=e[n]===0&&e[n+1]===0&&e[n+2]===1,l=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1?n+4:a?n+3:-1;if(l<0||l>=e.length)continue;if((r?e[l]>>1&63:e[l]&31)!==t){n=l-1;continue}let f=l+1;for(;f+2<e.length&&!(e[f]===0&&e[f+1]===0&&(e[f+2]===1||e[f+2]===0&&e[f+3]===1));)f++;return e.subarray(l,Math.min(e.length,f))}return null}function zF(e){const t=e?t4(e,7,!1):null;return t&&t.length>=4?`avc1.${jm(t[1])}${jm(t[2])}${jm(t[3])}`:"avc1.42e01e"}function HF(e){const t=e?t4(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 WF{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=m9(yF(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(zd(zb)))},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:$F(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=UF(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(zd(zb))}})}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=[zF(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,d,f)=>f.indexOf(l)===d),r.avc={format:"annexb"}):t==="h265"?(n=[HF(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===Nm||t===Wb,l=c?0:1,d=a===Tu&&!c?Vb:0,f=(t===Hb||t===Nm)&&a===Tu?Vb:0;this.sendControl(BF(t,a,this.pointerPoint(r,n),l,f,d))}pointerDown(t,r,n){this.touch(Hb,t,r,n==="mouse"?Tu:Nh)}pointerMove(t,r,n){this.touch(DF,t,r,n==="mouse"?Tu:Nh)}pointerUp(t,r,n){this.touch(Nm,t,r,n==="mouse"?Tu:Nh)}pointerCancel(t,r,n){this.touch(Wb,t,r,n==="mouse"?Tu:Nh)}scroll(t,r,n,a){this.sendControl(QF(this.pointerPoint(t,r),n,a))}key(t,r=Rm){this.sendControl(Mm(r,t))}tapKey(t){this.sendControl(Mm(Rm,t)),this.sendControl(Mm(Gb,t))}back(){this.sendControl(qb(Rm)),this.sendControl(qb(Gb))}home(){this.tapKey(Ud.HOME)}recents(){this.tapKey(Ud.APP_SWITCH)}power(){this.tapKey(Ud.POWER)}volumeUp(){this.tapKey(Ud.VOLUME_UP)}volumeDown(){this.tapKey(Ud.VOLUME_DOWN)}rotate(){this.sendControl(zd(MF))}expandNotifications(){this.sendControl(zd(EF))}collapsePanels(){this.sendControl(zd(NF))}setDisplayPower(t){this.sendControl(FF(t))}sendText(t){this.sendControl(PF(t))}startApp(t){this.sendControl(OF(t))}}function GF(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function VF(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${GF()}.png`}function Yb(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 qF(e,t=VF()){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 r4(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 Zb(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:r4({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 n4(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),c=f=>{window.clearTimeout(d),window.removeEventListener("termdock-insert-reference-ack",l),f?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},l=f=>{const m=f.detail;m?.nonce===a&&c(m.ok===!0)},d=window.setTimeout(()=>c(!1),1e4);window.addEventListener("termdock-insert-reference-ack",l),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:e,sessionId:t,nonce:a,focus:!1,paste:!0}}))}):Promise.reject(new Error("没有可接收内容的终端"))}function Kb(e,t){return n4(u1(e,null),t)}const Dm=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 YF({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=Ur(),[c,l]=b.useState(!1),[d,f]=b.useState(!1),[m,x]=b.useState(!1),[y,w]=b.useState(!1),[v,S]=b.useState(null),C=b.useRef(!1),I=b.useRef(null),R=async()=>{if(!C.current){C.current=!0,f(!0),w(!0);try{await SF(e.id),n()}catch(z){S(z instanceof Error?z.message:String(z))}finally{C.current=!1,f(!1),w(!1)}}};b.useEffect(()=>{if(c)return;I.current?.focus();const z=O=>{if(O.stopPropagation(),O.key==="Escape"&&O.preventDefault(),O.key!=="Tab")return;const $=Array.from(I.current?.querySelectorAll("button:not(:disabled)")??[]),V=$[0],Y=$.at(-1);O.shiftKey&&(document.activeElement===V||document.activeElement===I.current)?(O.preventDefault(),Y?.focus()):!O.shiftKey&&document.activeElement===Y&&(O.preventDefault(),V?.focus())};return document.addEventListener("keydown",z,!0),()=>document.removeEventListener("keydown",z,!0)},[c]);const B=async z=>{if(!C.current){C.current=!0,f(!0),x(z!==void 0),l(!1),S(null);try{const O=await TF(e.id,z);z===void 0&&await r(O.path),n()}catch(O){S(O instanceof Error?O.message:String(O))}finally{C.current=!1,f(!1)}}};return c?s.jsx(sp,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:z=>{B(z)}}):Js.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:I,role:"dialog","aria-modal":"true","aria-labelledby":"recording-save-title",tabIndex:-1,"aria-busy":d,className:"w-full max-w-sm rounded-xl border border-border bg-surface p-4 text-foreground shadow-xl outline-none",children:[s.jsx("h2",{id:"recording-save-title",className:"text-sm font-semibold",children:a("android.recordingConfirm")}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("android.recordingSaveHint")}),s.jsxs("p",{className:"mt-2 break-all text-xs text-muted-foreground",children:[e.name," · ",(e.size/1024/1024).toFixed(1)," MB"]}),(v||e.error)&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs text-destructive",children:v||e.error}),d&&s.jsxs("p",{role:"status",className:"mt-3 flex items-center gap-2 text-sm text-primary",children:[s.jsx(_n,{size:16,className:"animate-spin"}),y?`${a("android.recordingDiscard")}…`:a(m?"android.recordingSaving":"android.captureInserting")]}),s.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[s.jsx("button",{type:"button",disabled:d||e.status!=="ready",onClick:()=>{B()},className:"min-h-10 rounded-lg bg-primary px-3 text-sm text-primary-foreground disabled:opacity-40",children:a("android.recordingInsert")}),s.jsx("button",{type:"button",disabled:d||e.status!=="ready",onClick:()=>l(!0),className:"min-h-10 rounded-lg bg-surface-2 px-3 text-sm disabled:opacity-40",children:a("android.recordingSave")}),s.jsx("button",{type:"button",disabled:d,onClick:()=>{R()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const e0="android-mirror",Hd=e0,s4="termdock:android:quality:v1",Bm=176,ZF=204,_l=1,sf=8,Xb=[1,1.25,1.5,2,2.5,3,4,6,8],KF=e=>Math.max(_l,Math.min(sf,e));function XF(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function Rh(e){const t=e.parentElement;if(!t)return null;const r=t.getBoundingClientRect(),n=getComputedStyle(t),a=parseFloat(n.paddingLeft)||0,c=parseFloat(n.paddingTop)||0,l=t.clientWidth-a-(parseFloat(n.paddingRight)||0),d=t.clientHeight-c-(parseFloat(n.paddingBottom)||0);return{cx:r.left+t.clientLeft+a+l/2,cy:r.top+t.clientTop+c+d/2,width:l,height:d,contentWidth:e.offsetWidth,contentHeight:e.offsetHeight}}function JF(e,t){try{e.setPointerCapture?.(t)}catch{}}function Jb(e,t){try{e.releasePointerCapture?.(t)}catch{}}const ey=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Mh=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},Qm={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},e$=()=>{try{const e=localStorage.getItem(s4);return e?j1(JSON.parse(e)):I0}catch{return I0}},Wd=e=>{try{localStorage.setItem(s4,JSON.stringify(e))}catch{}};function t$({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=Ur(),d=$b(N=>N.overlay),f=$b(N=>N.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(e$,[]),v=b.useRef(w),S=b.useRef(null),C=b.useRef(null),[I,R]=b.useState(4e6),B=b.useRef(null),z=b.useRef(new Map),O=b.useRef(null),$=b.useRef(!1),[V,Y]=b.useState(_l),le=b.useRef(V),be=b.useRef({x:0,y:0}),pe=b.useRef(null),ee=b.useRef(0),ke=b.useRef(0),He=b.useRef(null),q=b.useRef(0),[ce,qe]=b.useState(null),[Ae,ve]=b.useState(null),[Ie,Be]=b.useState(!0),[ne,Fe]=b.useState(""),[Le,Re]=b.useState(w.id),[Pe,Ee]=b.useState([]),[oe,We]=b.useState(null),[rt,gt]=b.useState(""),[ue,Ye]=b.useState(!0),[at,Ne]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[Ge,Ce]=b.useState("idle"),[H,ae]=b.useState(null),[ye,Ve]=b.useState(null),[Je,bt]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Vt,Pt]=b.useState(null),[mt,Zt]=b.useState(null),[Ht,Kt]=b.useState(!1),[Ot,Nt]=b.useState([]),[me,Ze]=b.useState(null),[ct,Tt]=b.useState([]),[X,yt]=b.useState(!1),nt=b.useRef(null),_e=b.useRef(0),tr=b.useRef([]),[Ke,kt]=b.useState(!1),[Ut,vt]=b.useState(""),[wt,Mt]=b.useState(!1),[_t,fr]=b.useState(!1),[qt,Sr]=b.useState(""),[pn,dr]=b.useState(null),[ge,Gr]=b.useState(null),[ot,ft]=b.useState(!1),[ir,Mn]=b.useState(0),Xr=b.useRef(null),[De,st]=b.useState(!1),xt=b.useRef(!1),Br=b.useRef(new Set),Vr=b.useRef(null),Cr=b.useRef(null),qr=b.useRef(!1),[mn,on]=b.useState(!1),zr=b.useRef(a);zr.current=a;const[un,Er]=b.useState(!1),[re,pt]=b.useState(null),jt=b.useRef(null),nr=b.useRef(null),Ar=pF(N=>N.activeSessionId??N.sessions.keys().next().value??null),Fr=e??Ar,Xt=Kn(N=>!!N.docks[Hd]),Zr=Kn(N=>N.hosts[Hd]),Jt=Kn(N=>N.setDock),Pr=b.useCallback(async()=>{Be(!0);try{const N=await xF();qe(N),ve(null)}catch(N){ve(N instanceof Error?N.message:"ADB_UNAVAILABLE")}finally{Be(!1)}},[]);b.useEffect(()=>{Pr()},[Pr]);const Hr=ce?.devices??[],ps=Hr.find(N=>N.serial===ne)??null,Mr=!!(Ae&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(Ae)),jn=!!(ce?.adbAvailable&&!ce.scrcpyVersion),Tr=b.useCallback(()=>{const N=B.current,U=[...z.current.keys()];B.current=null,z.current.clear(),O.current=null,$.current=!1,nt.current=null,Mh(ee.current),ee.current=0,N&&x.current?.pointerCancel(N.x,N.y,N.type);const Z=m.current;if(Z)for(const fe of U)Jb(Z,fe);Ze(null),yt(!1),Tt([]),Y(le.current)},[]);b.useEffect(()=>{const N=fe=>{z.current.has(fe.pointerId)&&(fe.type==="pointercancel"||fe.target!==m.current)&&Tr()},U=()=>Tr(),Z=()=>{document.hidden&&Tr()};return window.addEventListener("pointerup",N,!0),window.addEventListener("pointercancel",N,!0),window.addEventListener("blur",U),document.addEventListener("visibilitychange",Z),()=>{window.removeEventListener("pointerup",N,!0),window.removeEventListener("pointercancel",N,!0),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",Z),Tr()}},[Tr]);const Jr=b.useCallback(()=>{Tr(),x.current?.disconnect(),x.current=null,Ce("idle"),ae(null),Ve(null)},[Tr]),ln=b.useCallback((N,U=!1)=>{const Z=m.current;if(!Z||!N)return;Tr(),x.current?.disconnect(),ae(null),!U&&y.current!==N&&Ve(null),y.current=N,Zt(null),Pt(null);const fe=new WF(Z,{onBitrateSupport:(we,lt)=>{x.current!==fe||v.current.id!=="auto"||Pt(we?null:lt??"BITRATE_REASON_UNAVAILABLE")},onState:(we,lt)=>{x.current===fe&&(Ce(we),ae(lt??null))},onHeader:we=>{x.current===fe&&Ve(we)},onStats:we=>{x.current===fe&&bt(we)},onWarning:we=>{x.current===fe&&Zt(we)}});x.current=fe;let Qe=v.current;Qe.id==="auto"?(S.current?.serial!==N&&(S.current={serial:N,policy:new gF}),S.current.policy.connected(performance.now()),Qe=S.current.policy.quality,R(Qe.bitRate)):S.current=null,C.current=Qe,fe.connect(N,Qe)},[Tr]);b.useEffect(()=>{if(Le!=="auto"||v.current.id!=="auto"||Ge!=="streaming"||!Je.adaptation||document.hidden)return;const N=S.current,U=x.current;if(!N||N.serial!==ne||!U?.canSetBitrate)return;const Z=m.current,fe=Z?Math.max(Z.clientWidth,Z.clientHeight)*(window.devicePixelRatio||1)*le.current:1600,Qe=N.policy.sample(Je.adaptation,performance.now(),fe||1600);Qe&&U.setBitrate(Qe.bitRate).then(we=>{we&&x.current===U&&(C.current=Qe,R(Qe.bitRate))})},[Je,Le,Ge,ne,ln]);const Qr=b.useCallback(N=>{const U={...N.quality?{quality:{id:N.quality.id,maxSize:N.quality.maxSize,bitRate:N.quality.bitRate,maxFps:N.quality.maxFps}}:{},...N.activePresetId!==void 0?{activePresetId:N.activePresetId}:{},...N.presets!==void 0?{presets:N.presets}:{},...N.docked!==void 0?{docked:N.docked}:{},...N.deviceSerial!==void 0?{deviceSerial:N.deviceSerial}:{}};La({androidPanel:U}).catch(()=>{})},[]);b.useEffect(()=>{let N=!1;return fc().then(U=>{if(N)return;const Z=U.androidPanel;if(Z?.quality){const fe=j1(Z.quality);v.current=fe,Re(fe.id),Ne({maxSize:fe.maxSize,bitRate:fe.bitRate,maxFps:fe.maxFps}),Wd(fe)}Ee(Z?.presets??[]),We(Z?.activePresetId??null),Z?.deviceSerial&&(He.current=Z.deviceSerial,Fe(Z.deviceSerial))}).catch(()=>{}),()=>{N=!0}},[]);const ks=b.useCallback(N=>{const U=++_e.current;Nt(fe=>[...fe,{id:U,left:N.left,top:N.top}]);const Z=window.setTimeout(()=>{Nt(fe=>fe.filter(Qe=>Qe.id!==U)),tr.current=tr.current.filter(fe=>fe!==Z)},300);tr.current.push(Z)},[]),Dr=b.useCallback((N,U)=>{const Z=x.current,fe=C.current;Z?.supportsLiveBitrate&&y.current===N&&fe&&fe.maxSize===U.maxSize&&fe.maxFps===U.maxFps?Z.setBitrate(U.bitRate).then(Qe=>{x.current===Z&&(Qe?(C.current=U,Pt(null)):Pt(Z.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):ln(N)},[ln,l]),en=b.useCallback(N=>{if(S.current=null,N.startsWith("user:")){const Z=Pe.find(Qe=>Qe.id===N.slice(5));if(!Z)return;const fe={id:"custom",maxSize:Z.maxSize,bitRate:Z.bitRate,maxFps:Z.maxFps};v.current=fe,Re("custom"),We(Z.id),Ne({maxSize:Z.maxSize,bitRate:Z.bitRate,maxFps:Z.maxFps}),Ye(!0),Wd(fe),Qr({quality:fe,activePresetId:Z.id}),ne&&ln(ne);return}if(N==="custom"){const Z=v.current;Re("custom"),We(null),Ne({maxSize:Z.maxSize,bitRate:Z.bitRate,maxFps:Z.maxFps}),Ye(!0);return}const U=N==="auto"?j1({id:"auto"}):Uf.find(Z=>Z.id===N)??I0;v.current=U,Re(U.id),We(null),Wd(U),Qr({quality:U,activePresetId:null}),ne&&ln(ne)},[ln,ne,Pe,Qr]),xn=b.useCallback(()=>{const N={id:"custom",maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps};v.current=N,Wd(N),Qr({quality:N,activePresetId:null}),Re("custom"),We(null),ne&&Dr(ne,N)},[Dr,ne,at,Qr]),K=b.useCallback(()=>{const N=rt.trim();if(!N)return;const U=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,Z={id:U,name:N,maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps},fe=[...Pe.filter(we=>we.name!==N),Z].slice(-12),Qe={id:"custom",maxSize:at.maxSize,bitRate:at.bitRate,maxFps:at.maxFps};Ee(fe),gt(""),We(U),Re("custom"),v.current=Qe,Wd(Qe),Qr({quality:Qe,activePresetId:U,presets:fe}),ne&&Dr(ne,Qe)},[rt,at,Pe,ne,Dr,Qr]),ze=b.useCallback(()=>{if(!oe)return;const N=Pe.filter(U=>U.id!==oe);Ee(N),We(null),Qr({activePresetId:null,presets:N})},[oe,Pe,Qr]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const N of tr.current)window.clearTimeout(N);tr.current=[]},[]),b.useEffect(()=>{if(d==="off")return;const N=U=>{U.key==="Escape"&&f("off")};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[d,f]),b.useEffect(()=>{const N=Hr.filter(Z=>Z.state==="device");if(ne||N.length!==1)return;const U=N[0].serial;He.current!==U&&(He.current=U,Fe(U))},[Hr,ne]),b.useEffect(()=>{ne&&ln(ne)},[ne,ln]),b.useEffect(()=>{if(Ge==="streaming"){q.current=0,Kt(!1);return}if(Ge!=="error"||!ne||!n$(H??""))return;const N=Math.min(8e3,700*2**q.current);q.current+=1,Kt(!0);const U=window.setTimeout(()=>{Kt(!1),ln(ne)},N);return()=>window.clearTimeout(U)},[Ge,H,ne,ln]);const Rt=b.useCallback((N,U,Z)=>{const fe=m.current,Qe=Z??(fe?Rh(fe):null);return!fe||!Qe?{x:0,y:0}:r4(N,U,Qe)},[]),Et=b.useCallback(()=>{const N=m.current;if(!N)return;const{x:U,y:Z}=be.current,fe=le.current,Qe=fe===_l&&U===0&&Z===0?"":`translate3d(${U}px, ${Z}px, 0) scale(${fe})`;N.style.transform!==Qe&&(N.style.transform=Qe);const we=pe.current;we&&(we.textContent=fe>_l?XF(fe):"")},[]),rr=b.useCallback((N,U,Z=!0)=>{const fe=m.current,Qe=le.current,we=KF(N);if(!fe||we===Qe)return;const lt=Rh(fe);if(!lt)return;const At=U??{x:lt.cx,y:lt.cy},br=Zb({zoom:Qe,pan:be.current},lt,At,At,we/Qe);le.current=br.zoom,be.current=br.pan,Z&&Et()},[Et]),jr=b.useCallback(()=>{const N=le.current;Y(U=>U<=_l+.01==N<=_l+.01&&U>=sf-.01==N>=sf-.01?U:N)},[]);b.useEffect(()=>()=>{Mh(ee.current),Mh(ke.current)},[]);const cr=()=>{let N=0,U=0;for(const fe of z.current.values())N+=fe.x,U+=fe.y;const Z=z.current.size;return Z?{x:N/Z,y:U/Z}:null},Cn=()=>{const[N,U]=Array.from(z.current.values());return N&&U?Math.hypot(N.x-U.x,N.y-U.y):0},Ls=()=>{const N=cr(),U=m.current?Rh(m.current):null;!N||!U||(O.current={startCentroid:N,startDistance:Cn(),box:U})},Xn=b.useCallback(()=>{const N=O.current,U=cr();if(!N||!U)return;const Z=Cn(),fe=N.startDistance>0&&Z>0?Z/N.startDistance:1,Qe=Zb({zoom:le.current,pan:be.current},N.box,N.startCentroid,U,fe);le.current=Qe.zoom,be.current=Qe.pan,N.startCentroid=U,N.startDistance=Z},[]),cn=b.useCallback(()=>{ee.current||(ee.current=ey(()=>{ee.current=0,Xn(),Et()}))},[Xn,Et]),dn=b.useCallback(()=>{ee.current&&(Mh(ee.current),ee.current=0,Xn(),Et())},[Xn,Et]);b.useEffect(()=>{const N=m.current;if(!N)return;const U=N.parentElement;if(!U)return;const Z=Qe=>{if(Qe.ctrlKey||Qe.metaKey){if(Qe.preventDefault(),!Qe.deltaY||O.current)return;const At=Qe.deltaMode===1?16:Qe.deltaMode===2?N.parentElement?.clientHeight||600:1,br=Math.max(-600,Math.min(600,Qe.deltaY*At));rr(le.current*Math.exp(-br*.002),{x:Qe.clientX,y:Qe.clientY},!1),ke.current||(ke.current=ey(()=>{ke.current=0,Et(),jr()}));return}const we=x.current;if(!we||Qe.target!==N)return;Qe.preventDefault();const lt=Dh(N,Qe.clientX,Qe.clientY);we.scroll(lt.x,lt.y,Qe.deltaX,Qe.deltaY)},fe=Qe=>Qe.preventDefault();return U.addEventListener("wheel",Z,{passive:!1}),U.addEventListener("gesturestart",fe,{passive:!1}),U.addEventListener("gesturechange",fe,{passive:!1}),()=>{U.removeEventListener("wheel",Z),U.removeEventListener("gesturestart",fe),U.removeEventListener("gesturechange",fe)}},[rr,Et,jr]),b.useEffect(()=>{const N=m.current,U=N?.parentElement;if(!N||!U||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(()=>{O.current&&(O.current.box=Rh(N));const fe=Rt(be.current,le.current);fe.x===be.current.x&&fe.y===be.current.y||(be.current=fe,Et())});return Z.observe(N),Z.observe(U),()=>Z.disconnect()},[Rt,Et]),b.useLayoutEffect(()=>{Et()});const _r=N=>{const U=x.current,Z=m.current;if(!U||!Z)return;if(N.pointerType==="mouse"&&N.button!==0){N.preventDefault(),N.button===2?U.back():N.button===1&&U.home();return}N.preventDefault(),Z.closest(".android-mirror-panel")?.focus({preventScroll:!0}),Et(),jr(),dn(),JF(Z,N.pointerId),z.current.set(N.pointerId,{x:N.clientX,y:N.clientY});const fe=N.pointerType==="mouse"&&N.altKey;if(z.current.size>=2||fe){const lt=B.current;lt&&(U.pointerCancel(lt.x,lt.y,lt.type),B.current=null,nt.current=null,Ze(null),yt(!1),Tt([])),$.current=!0,Ls();return}if($.current)return;const Qe=Dh(Z,N.clientX,N.clientY);B.current={id:N.pointerId,type:N.pointerType,x:Qe.x,y:Qe.y},U.pointerDown(Qe.x,Qe.y,N.pointerType);const we=iy(Z,N.clientX,N.clientY);we&&(nt.current={left:we.left,top:we.top},Tt([]),yt(!1),Ze(we))},Or=N=>{const U=x.current,Z=m.current;if(!Z||!z.current.has(N.pointerId))return;if(N.pointerType==="mouse"){const At=Z.getBoundingClientRect(),br=Z.parentElement?.getBoundingClientRect()??At;if(!(N.buttons&1)||N.clientX<Math.max(At.left,br.left)||N.clientX>=Math.min(At.right,br.right)||N.clientY<Math.max(At.top,br.top)||N.clientY>=Math.min(At.bottom,br.bottom)){Tr();return}}if(N.preventDefault(),z.current.set(N.pointerId,{x:N.clientX,y:N.clientY}),O.current){cn();return}const fe=B.current;if(!U||!fe||fe.id!==N.pointerId)return;const Qe=Dh(Z,N.clientX,N.clientY);fe.x=Qe.x,fe.y=Qe.y,U.pointerMove(Qe.x,Qe.y,fe.type);const we=iy(Z,N.clientX,N.clientY),lt=nt.current;!we||!lt||(Ze(we),Math.hypot(we.left-lt.left,we.top-lt.top)>=6&&(yt(!0),Tt(At=>{const br=At[At.length-1];if(br&&Math.hypot(we.left-br.x,we.top-br.y)<4)return At;const It=[...At,{x:we.left,y:we.top}];return It.length>12?It.slice(It.length-12):It})))},Gn=N=>{const U=x.current,Z=m.current;if(!Z||!z.current.has(N.pointerId))return;if(dn(),z.current.delete(N.pointerId),Jb(Z,N.pointerId),z.current.size===0&&($.current=!1),O.current){z.current.size===0?(O.current=null,Y(le.current)):Ls();return}const fe=B.current;if(!fe||fe.id!==N.pointerId)return;const Qe=Dh(Z,N.clientX,N.clientY);U?.pointerUp(Qe.x,Qe.y,fe.type),me&&ks(me),Ze(null),yt(!1),window.setTimeout(()=>Tt([]),200),B.current=null,nt.current=null},Vn=N=>{if(un||Ke||_t)return;const U=x.current;U&&(N.key==="Backspace"?(N.preventDefault(),U.key(67)):N.key==="Escape"?(N.preventDefault(),U.back()):N.key==="Enter"&&(N.preventDefault(),U.key(66)))},gn=async()=>{const N=Ut.trim();if(N){Mt(!0);try{const U=await bF(N);vt(""),kt(!1),await Pr(),Fe(U.serial)}catch(U){ve(U instanceof Error?U.message:"ADB_CONNECT_FAILED")}finally{Mt(!1)}}},Jn=()=>{const N=x.current,U=qt;!N||!U||(N.sendText(U),Sr(""))},kr=b.useCallback(N=>{dr(N),Cr.current!==null&&window.clearTimeout(Cr.current),Cr.current=window.setTimeout(()=>{Cr.current=null,dr(null)},2500)},[]),Lr=b.useCallback(N=>{const U=le.current,Z=N==="in"?Xb.find(fe=>fe>U+.01):[...Xb].reverse().find(fe=>fe<U-.01);Z!==void 0&&(U<=_l&&Z>_l&&kr(l("android.zoomPanHint")),dn(),rr(Z),Y(Z))},[rr,dn,kr,l]),pr=N=>{Promise.resolve().then(()=>r?.(N)).catch(U=>{Gr(U instanceof Error?U.message:String(U))})},ns=b.useCallback(async(N,U)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(N),kr(U)}catch(Z){Gr(l("android.captureFailed")+(Z instanceof Error?`:${Z.message}`:""))}},[n,kr,l]),Un=async()=>{const N=m.current;if(!(!N||qr.current)){qr.current=!0,on(!0),Gr(null);try{const U=await qF(N);await ns(U,l("android.captureInserted"))}catch(U){Gr(U instanceof Error?U.message:String(U))}finally{qr.current=!1,on(!1)}}},En=b.useCallback(N=>{(N.status==="ready"||N.status==="error")&&zr.current&&!Br.current.has(N.id)&&(Br.current.add(N.id),zr.current?.(N))},[]),kn=b.useCallback(async N=>{const U=Xr.current;if(!(!U||xt.current)){xt.current=!0,st(!0),Gr(null);try{const Z=await AF(U.id);Xr.current=null,ft(!1),En(Z)}catch(Z){Gr(Z instanceof Error?Z.message:String(Z))}finally{xt.current=!1,st(!1)}}},[En]),ss=async()=>{if(!(!ne||xt.current||Xr.current)){xt.current=!0,st(!0),Gr(null);try{const N=await wF(ne);N.status==="recording"||N.status==="starting"||N.status==="stopping"?(Xr.current=N,ft(!0),Mn(Math.max(0,Date.now()-N.startedAt))):En(N)}catch(N){Gr(N instanceof Error?N.message:String(N))}finally{xt.current=!1,st(!1)}}};b.useEffect(()=>{let N=!1,U=!1;Xr.current=null,ft(!1);const Z=async()=>{if(!(!ne||U||xt.current)){U=!0;try{const{recordings:Qe}=await vF(ne);if(N||xt.current)return;const we=Qe.find(lt=>["starting","recording","stopping"].includes(lt.status));Xr.current=we??null,ft(!!we);for(const lt of Qe)En(lt)}catch{}finally{U=!1}}};Z();const fe=window.setInterval(()=>{Z()},2e3);return Vr.current=window.setInterval(()=>{Xr.current&&Mn(Math.max(0,Date.now()-Xr.current.startedAt))},500),()=>{N=!0,window.clearInterval(fe),Vr.current!==null&&window.clearInterval(Vr.current)}},[ne,En]),b.useEffect(()=>{if(!un)return;const N=()=>Er(!1),U=fe=>{const Qe=fe.target;Qe instanceof Node&&(jt.current?.contains(Qe)||nr.current?.contains(Qe)||N())},Z=fe=>{fe.key==="Escape"&&(fe.preventDefault(),fe.stopPropagation(),N())};return document.addEventListener("pointerdown",U,!0),document.addEventListener("keydown",Z,!0),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",U,!0),document.removeEventListener("keydown",Z,!0),window.removeEventListener("resize",N)}},[un]),b.useEffect(()=>()=>{Cr.current!==null&&window.clearTimeout(Cr.current)},[]);const Wr=Ge==="streaming",tn=Xt,G=tn?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-surface-2 disabled:opacity-40":"rounded p-1.5 hover:bg-surface-2 disabled:opacity-40",je=ps?(ps.model||ps.serial)+ay(ps,l):Hr.length?l("android.selectDevice"):l("android.noDevices"),et=(oe?Pe.find(N=>N.id===oe):null)?.name??(Le==="auto"?`${l("android.qualityAuto")} · ${I/1e6} Mbps`:l(Qm[Le])),it=tn?"relative flex h-5 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50":"relative flex h-7 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50",Ct=tn?"pointer-events-none block min-w-0 truncate px-1 text-[10px] leading-none text-foreground":"pointer-events-none block min-w-0 truncate px-2 text-[11px] leading-none text-foreground",Lt="absolute inset-0 h-full w-full cursor-pointer opacity-0",Bt=()=>{const N=jt.current?.getBoundingClientRect();N&&pt({left:Math.max(8,Math.min(N.right-Bm,window.innerWidth-Bm-8)),top:Math.min(N.bottom+4,Math.max(8,window.innerHeight-ZF-8))}),Er(!0)},ht=()=>{if(Xt){Jt(Hd,null),Qr({docked:null});return}if(!Fr)return;const N={sessionId:Fr,side:"right"};Jt(Hd,N),Qr({docked:N})},Qt=Ke||Xt||d!=="off",W=s.jsxs("div",{className:"android-mirror-panel flex h-full min-h-0 min-w-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:Vn,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":Xt?"true":void 0,className:tn?"flex h-6 min-h-6 shrink-0 flex-nowrap items-center gap-1 overflow-hidden border-b border-border/15 bg-[var(--chrome-bg)] px-1.5 cursor-grab select-none active:cursor-grabbing":"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[Xt&&s.jsx("span",{"data-panel-drag-title":"true",role:"button","aria-label":l("android.splitDrag"),title:l("android.splitDrag"),className:"flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground active:cursor-grabbing",children:s.jsx(zf,{size:12})}),s.jsx(g9,{size:tn?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${it} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Ct} w-full`,children:je}),s.jsxs("select",{value:ne,onChange:N=>{const U=N.target.value;Fe(U),He.current=U,U&&Qr({deviceSerial:U})},className:Lt,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:Hr.length?l("android.selectDevice"):l("android.noDevices")}),Hr.map(N=>s.jsx("option",{value:N.serial,children:(N.model||N.serial)+ay(N,l)},N.serial))]})]}),s.jsxs("div",{className:`${it} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Ct,children:et}),s.jsxs("select",{value:oe?`user:${oe}`:Le,onChange:N=>en(N.target.value),className:Lt,title:l(Le==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),Le==="auto"?` · ${I/1e6} Mbps`:""]}),Uf.map(N=>s.jsx("option",{value:N.id,children:l(Qm[N.id])},N.id)),Pe.map(N=>s.jsx("option",{value:`user:${N.id}`,children:N.name},N.id)),s.jsx("option",{value:"custom",children:l(Qm.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{Pr()},className:`${G} text-muted-foreground`,title:l("android.refresh"),children:Ie?s.jsx(_n,{size:13,className:"animate-spin"}):s.jsx(bn,{size:13})}),Wr?s.jsx("button",{type:"button",onClick:Jr,className:`${G} text-destructive`,title:l("android.disconnect"),children:s.jsx(Gy,{size:13})}):s.jsx("button",{type:"button",onClick:()=>ne&&ln(ne),disabled:!ne,className:`${G} text-primary`,title:l("android.connect"),children:s.jsx(uS,{size:13})}),(Wr||ot)&&s.jsx("button",{type:"button",onClick:()=>{Un()},disabled:!n||mn,className:`${G} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:mn?s.jsx(_n,{size:tn?12:13,className:"animate-spin"}):s.jsx(HA,{size:tn?12:13})}),(Wr||ot)&&s.jsx("button",{type:"button",onClick:()=>{ot?kn("manual"):ss()},disabled:De||!ot&&!a,className:`${G} ${ot?"text-destructive":"text-muted-foreground"}`,title:l(ot?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(ot?"android.recordingStop":"android.recordingStart"),children:De?s.jsx(_n,{className:"animate-spin",size:13}):ot?s.jsx(Wy,{size:tn?10:11,fill:"currentColor"}):s.jsx(Vy,{size:tn?12:13})}),s.jsx("button",{ref:jt,type:"button",onClick:()=>un?Er(!1):Bt(),"aria-haspopup":"menu","aria-expanded":un,className:`${G} ${Qt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx(To,{size:tn?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{Er(!1),f("off"),c()},className:`${G} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(In,{size:14})})]}),un&&re&&Js.createPortal(s.jsxs("div",{ref:nr,role:"menu","aria-label":l("android.more"),style:{left:re.left,top:re.top,width:Bm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(jh,{icon:s.jsx(ul,{size:13}),label:l("android.addDevice"),active:Ke,onSelect:()=>{kt(N=>!N),Er(!1)}}),s.jsx(jh,{icon:Xt?s.jsx(In,{size:13}):s.jsx(Il,{size:13}),label:l(Xt?"android.splitClose":"android.splitOpen"),active:Xt,disabled:!Xt&&!Fr,onSelect:()=>{ht(),Er(!1)}}),s.jsx(jh,{icon:d==="window"?s.jsx(BT,{size:13}):s.jsx(RT,{size:13}),label:l(d==="window"?"android.exitFullscreen":"android.fullscreen"),active:d==="window",onSelect:()=>{f(d==="window"?"off":"window"),Er(!1)}}),!t&&s.jsx(jh,{icon:d==="sidebar"?s.jsx(GT,{size:13}):s.jsx(ZT,{size:13}),label:l(d==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:d==="sidebar",onSelect:()=>{f(d==="sidebar"?"off":"sidebar"),Er(!1)}}),ye&&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),(Le==="custom"||oe)&&s.jsxs("div",{className:"border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[s.jsxs("button",{type:"button",onClick:()=>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"),oe?` · ${Pe.find(N=>N.id===oe)?.name??""}`:""]})]}),ue&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(sy,{label:l("android.qualityResolution"),display:`${at.maxSize}px`,min:360,max:2160,step:8,value:at.maxSize,onChange:N=>Ne(U=>({...U,maxSize:N}))}),s.jsx(sy,{label:l("android.qualityBitRate"),display:`${(at.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:at.bitRate/1e6,onChange:N=>Ne(U=>({...U,bitRate:Math.round(N*1e6)}))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:l("android.qualityFrameRate")}),s.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(N=>s.jsx("button",{type:"button",onClick:()=>Ne(U=>({...U,maxFps:N})),className:`rounded px-2 py-0.5 ${at.maxFps===N?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:N},N)),s.jsx("button",{type:"button",onClick:()=>Ne(N=>({...N,maxFps:0})),className:`rounded px-2 py-0.5 ${at.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:xn,disabled:!ne,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:l("android.qualityApply")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:rt,onChange:N=>gt(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")}),oe&&s.jsx("button",{type:"button",onClick:ze,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),Ke&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:Ut,onChange:N=>vt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&gn()},placeholder:l("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{gn()},disabled:wt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:wt?s.jsx(_n,{size:12,className:"animate-spin"}):l("android.connect")})]}),Mr&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.adbUnavailable")}),s.jsx(ry,{label:l("android.insertFixPrompt"),onClick:()=>pr(ny("adb",Ae??"")),enabled:!!r})]}),!Mr&&jn&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.scrcpyUnavailable")}),s.jsx(ry,{label:l("android.insertFixPrompt"),onClick:()=>pr(ny("scrcpy","")),enabled:!!r})]}),ps&&ps.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:s$(ps,l)}),Ae&&!Mr&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ub(Ae)}),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})]}),mt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:mt}),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:Wr||ye?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:_r,onPointerMove:Or,onPointerUp:Gn,onPointerCancel:()=>Tr(),onLostPointerCapture:N=>{z.current.has(N.pointerId)&&Tr()},onPointerLeave:N=>{z.current.has(N.pointerId)&&!N.currentTarget.hasPointerCapture?.(N.pointerId)&&Tr()},onContextMenu:N=>N.preventDefault()}),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}}),ct.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:X?1:0,transition:"opacity 160ms linear"},children:ct.slice(1).map((N,U)=>{const Z=ct[U],fe=(U+1)/(ct.length-1);return s.jsx("line",{x1:Z.x,y1:Z.y,x2:N.x,y2:N.y,stroke:"var(--primary)",strokeWidth:1+1.6*fe,strokeLinecap:"round",opacity:.06+.45*fe},U)})}),Ot.map(N=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:N.left,top:N.top}},N.id)),!Wr&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[Ge==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(_n,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),Ge==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(R0,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Ht?l("android.reconnecting"):Ub(H||"")}),ne&&s.jsx("button",{type:"button",onClick:()=>{q.current=0,ln(ne)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),Ge==="idle"&&!Mr&&!jn&&s.jsxs(s.Fragment,{children:[s.jsx(PT,{size:22,className:"opacity-60"}),s.jsx("span",{children:Hr.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${tn?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Bo,{compact:tn,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!Wr,children:s.jsx(Ny,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!Wr,children:s.jsx(CT,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!Wr,children:s.jsx($y,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!Wr,children:s.jsx(Qy,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!Wr,children:s.jsx(gS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!Wr,children:s.jsx(FS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!Wr,children:s.jsx(US,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!Wr,children:s.jsx(hS,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.inputText"),active:_t,onClick:()=>fr(N=>!N),disabled:!Wr,children:s.jsx(Fy,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.zoomIn"),onClick:()=>Lr("in"),disabled:!Wr||V>=sf-.01,children:s.jsx(zs,{size:14})}),s.jsx(Bo,{compact:tn,label:l("android.zoomOut"),onClick:()=>Lr("out"),disabled:!Wr||V<=_l+.01,children:s.jsx(Uy,{size:14})}),s.jsxs("div",{className:"relative ml-auto h-5 w-24 min-w-0 max-w-full shrink-0","data-mirror-capture-status":!0,children:[s.jsx("span",{"aria-hidden":ot||!!pn||mn,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${ot||pn||mn?"invisible":""}`,children:ye?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(r$,{recording:ot,elapsed:ir,status:mn?l("android.captureInserting"):pn,stopLabel:l("android.recordingStop"),onStop:()=>{kn("manual")}})})]})]}),_t&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:qt,onChange:N=>Sr(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&(N.preventDefault(),Jn())},placeholder:l("android.inputPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground",autoFocus:!0}),s.jsx("button",{type:"button",onClick:Jn,disabled:!qt,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(n0,{size:13})})]})]});return d==="window"?Js.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-[var(--chrome-bg)]",style:{paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:W}),document.body):t?Xt&&Zr?Js.createPortal(W,Zr):null:Xt&&Zr?s.jsxs(s.Fragment,{children:[Js.createPortal(W,Zr),s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[s.jsx(Il,{size:18,className:"opacity-60"}),s.jsx("span",{children:l("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Jt(Hd,null),Qr({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):W}function jh({icon:e,label:t,active:r=!1,disabled:n=!1,onSelect:a}){return s.jsxs("button",{type:"button",role:"menuitem",disabled:n,onClick:a,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition hover:bg-surface-2 disabled:opacity-40 disabled:hover:bg-transparent ${r?"text-primary":"text-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r&&s.jsx(pi,{size:12,className:"shrink-0"})]})}function r$({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"}),Yb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${Yb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(Wy,{size:8,fill:"currentColor"})})]}):r?s.jsx("span",{role:"status","aria-live":"polite",title:r,className:"ml-auto truncate text-[10px] text-primary",children:r}):null}function ty({sessionId:e}){const t=Kn(x=>x.docks[e0]),r=!!t,n=t?.sessionId??e??null,c=Dm(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await E0("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await Kb(w,n)},[n]),d=b.useCallback(x=>{Dm.getState().enqueue(x,n)},[n]),f=Kn(x=>!!x.hosts[e0]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,fc().then(x=>{const y=x.androidPanel?.docked;y&&(Kn.getState().docks[e0]||Kn.getState().setDock(e0,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&f&&s.jsx(t$,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>n4(x,n):void 0,onRecordingComplete:d}),c&&s.jsx(YF,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):Kb(x,c.sessionId),onDone:()=>Dm.getState().remove(c.file.id)},c.file.id)]})}function ry({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 ny(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 sy({label:e,display:t,min:r,max:n,step:a,value:c,onChange:l}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),s.jsx("input",{type:"range",min:r,max:n,step:a,value:c,onChange:d=>l(Number(d.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),s.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:t})]})}function Bo({label:e,onClick:t,disabled:r,active:n,compact:a,children:c}){return s.jsx("button",{type:"button",onClick:t,disabled:r,title:e,"aria-label":e,className:`${a?"inline-flex h-5 w-5 items-center justify-center":"p-1.5"} rounded transition active:scale-95 disabled:opacity-30 ${n?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:c})}function iy(e,t,r){const n=e.parentElement;if(!n)return null;const a=e.getBoundingClientRect(),c=n.getBoundingClientRect();return{left:a.left-c.left+(t-a.left),top:a.top-c.top+(r-a.top)}}function Dh(e,t,r){const n=e.getBoundingClientRect(),a=e.width||n.width,c=e.height||n.height,l=n.width?(t-n.left)/n.width*a:0,d=n.height?(r-n.top)/n.height*c:0;return{x:Math.max(0,Math.min(a,l)),y:Math.max(0,Math.min(c,d))}}function n$(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 ay(e,t){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${t("android.stateUnauthorized")}`:e.state==="offline"?` · ${t("android.stateOffline")}`:` · ${t("android.stateUnknown")}`}function s$(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function i$(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function a$(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function o$(e){if(!e)return"";const t=new Date(e),r=Date.now(),n=t.getTime()-r;if(n<=0)return"";const a=Math.floor(n/6e4),c=Math.floor(a/60),l=Math.floor(c/24),d=c%24,f=a%60,m=t.toLocaleDateString(void 0,{month:"short",day:"numeric"}),x=t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});let y;return l>0?y=`${l}d ${d}h`:d>0?y=`${d}h ${f}m`:f>0?y=`${f}m`:y="soon",`resets in ${y} (${m} ${x})`}function l$(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function c$({result:e}){const{t}=Ur(),r=e.windows.filter(d=>d.percent===0&&!d.resetAt),n=e.windows.filter(d=>d.percent>0||d.resetAt),a=r.length>0?r.map(d=>d.label).join(" · "):"",c=!!e.error;let l=null;return!c&&e.entitlement&&(e.usagePercent>=90?l=t("quota.exhausted"):e.remaining!==void 0&&e.remaining<e.entitlement?l=t("quota.left",{n:e.remaining}):l=`${Math.round(e.usagePercent)}%`),s.jsxs("div",{className:"rounded-xl border border-border/15 bg-surface-2 p-3 sm:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-foreground",children:[s.jsx("span",{className:"shrink-0",children:l$(e.slug)}),s.jsx("span",{className:"truncate",children:e.displayName}),a&&s.jsx("span",{className:"shrink-0 rounded-full bg-surface-elevated px-2 py-0.5 text-[10px] font-normal text-muted-foreground",children:a})]}),l&&s.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:l})]}),n.length>0?s.jsx("div",{className:"mt-2.5 space-y-2",children:n.map(d=>{const f=Math.max(0,Math.min(100,d.percent));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[s.jsx("span",{className:"w-14 shrink-0 truncate text-muted-foreground sm:w-16",children:d.label}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:"h-2 rounded-full",style:{background:a$(d.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,background:i$(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:o$(d.resetAt)})]},d.label)})}):c?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function u$({isOpen:e,onClose:t}){const{t:r}=Ur(),[n,a]=b.useState([]),[c,l]=b.useState(!1),d=async(x=!1)=>{l(!0);try{const y=x?await x9():await b9();a(y.providers||[])}catch{}finally{l(!1)}};if(b.useEffect(()=>{e&&d()},[e]),b.useEffect(()=>{if(!e)return;const x=y=>{const w=y.detail;Array.isArray(w)&&a(w)};return window.addEventListener("termdock:quota-update",x),()=>{window.removeEventListener("termdock:quota-update",x)}},[e]),!e)return null;const f=n.filter(x=>!x.error),m=f.length>0?new Date(Math.max(...f.map(x=>x.fetchedAt||0))):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t}),s.jsxs("div",{className:"fixed inset-x-3 z-modal-panel mx-auto flex max-w-lg flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",style:{top:"max(1.5rem, env(safe-area-inset-top, 0px))",bottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-3 py-2.5 sm:px-6 sm:py-3",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground sm:text-base",children:r("quota.title")}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>d(!0),disabled:c,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":r("quota.refresh"),children:s.jsx(bn,{size:15,className:c?"animate-spin":""})}),s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":r("quota.close"),children:s.jsx(In,{size:17})})]})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:[c&&f.length===0?s.jsx(h0,{label:r("common.loading"),className:"py-12"}):f.length===0?s.jsxs("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:[s.jsx("p",{children:r("quota.noProviders")}),s.jsx("p",{className:"mt-1.5 text-[11px]",children:r("quota.noProvidersHint")})]}):s.jsx("div",{className:"space-y-2.5",children:f.map(x=>s.jsx(c$,{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 oy=[{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~"}],d$=2,h$=20;function f$({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 p$({value:e,onChange:t,placeholder:r}){const{t:n}=Ur(),[a,c]=L.useState(""),l=y=>{const w=[];let v="",S=!1;const C=()=>{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];C(),S=!1}continue}if(B===","||/\s/.test(B)){C();continue}v+=B}if(C(),w.length===0)return;const I=[...e];for(const R of w){const B=ev(R);B&&(I.includes(B)||I.push(B))}t(I),c("")},d=y=>{t(e.filter(w=>w!==y))},f=a.trim(),m=f.length>0&&B2(f),x=m&&!vf(f);return s.jsx("div",{className:"rounded-2xl bg-surface px-3 py-2 ring-1 ring-border/15 focus-within:ring-accent/40",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.map(y=>{const w=B2(y),v=w&&!vf(y);return s.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] ${v?"bg-destructive/15 text-destructive":w?"bg-accent/15 font-mono text-accent":"bg-surface-elevated text-foreground"}`,title:w?v?n("settings.invalidRegex"):"Regex match":"Substring match (case-insensitive)",children:[w&&s.jsx("span",{className:"text-[10px] opacity-70",children:"re"}),y,s.jsx("button",{type:"button",onClick:()=>d(y),className:"rounded-full p-0.5 text-muted-foreground hover:bg-destructive/20 hover:text-destructive","aria-label":n("toolbarPresets.removeAction",{name:y}),children:s.jsx(In,{size:12})})]},y)}),s.jsx("input",{type:"text",value:a,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"||y.key===","&&!m?(y.preventDefault(),l(a)):y.key==="Backspace"&&a.length===0&&e.length>0&&d(e[e.length-1])},onBlur:()=>l(a),placeholder:e.length===0?r:"",className:`min-w-[8ch] flex-1 bg-transparent py-1 text-sm outline-none placeholder:text-muted/60 ${m?"font-mono":""} ${x?"text-destructive":""}`,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off"})]})})}function m$({value:e,min:t,max:r,onChange:n}){const{t:a}=Ur();return s.jsxs("div",{className:"inline-flex items-center gap-1 rounded-full bg-surface px-1 py-1 ring-1 ring-border/15",children:[s.jsx("button",{type:"button",onClick:()=>n(Math.max(t,e-1)),disabled:e<=t,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.decrease"),children:s.jsx(Uy,{size:14})}),s.jsx("span",{className:"w-6 text-center text-sm font-medium tabular-nums text-foreground",children:e}),s.jsx("button",{type:"button",onClick:()=>n(Math.min(r,e+1)),disabled:e>=r,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.increase"),children:s.jsx(zs,{size:14})})]})}const g$=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:c,onResetDefaults:l})=>{const{t:d}=Ur(),f=e.find(R=>R.id===t)??e[0]??null,[m,x]=L.useState(null);if(!f)return null;const y=f.actions.length>0,w=[{id:"preview-auto",label:f.label,kind:"preset"},...f.includeAlt?[{id:"preview-alt",label:"Alt"}]:[],...y?f.actions.map((R,B)=>({id:R.id,label:l1(R,B)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(R=>({id:R,label:R}))],v=tv(w,f.rowLayout),S=(R,B)=>{n(f.id,z=>{const O=z.actions.findIndex(Y=>Y.id===R);if(O===-1)return z;const $=O+B;if($<0||$>=z.actions.length)return z;const V=[...z.actions];return[V[O],V[$]]=[V[$],V[O]],{...z,actions:V}})},C=f.rowLayout.reduce((R,B)=>R+B,0),I=1+(f.includeAlt?1:0);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky top-[-1rem] sm:top-[-1.5rem] z-10 -mx-4 -mt-4 sm:-mx-6 sm:-mt-6 border-b border-border/15 bg-surface/95 backdrop-blur px-4 py-3 sm:px-6",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.preview")}),s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[f.actions.length," button",f.actions.length===1?"":"s"," · ",C," slot",C===1?"":"s"]})]}),s.jsx("div",{className:"space-y-1 rounded-2xl bg-surface-2/60 p-2",children:v.map((R,B)=>{const z=R.items[0]?.kind==="preset",O=Math.max(2,R.columns),$=z?`${rv}px repeat(${Math.max(1,O-1)}, minmax(0, 1fr))`:`repeat(${O}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:$},children:R.items.map(V=>V.kind==="preset"?s.jsx(nv,{mode:"auto",presetLabel:V.label,title:`Auto preset · ${V.label}`,disabled:!0},V.id):s.jsx(f$,{label:V.label},V.id))},`preview-row-${B}`)})}),f.actions.length>C-I&&s.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground",children:d("toolbarPresets.overCapacityHint")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.presets")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(zs,{size:14}),d("toolbarPresets.new")]}),s.jsxs("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(bn,{size:14}),d("toolbarPresets.reset")]})]})]}),s.jsx("div",{className:"-mx-1 flex flex-wrap gap-1.5 px-1",children:e.map(R=>s.jsxs("button",{type:"button",onClick:()=>r(R.id),className:`rounded-full px-3 py-2 text-xs font-medium transition ${R.id===f.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:f.label,onChange:R=>n(f.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"}),f.id!=="default"&&s.jsx("button",{type:"button",onClick:()=>c(f.id),className:"shrink-0 rounded-full bg-surface-2 px-3 py-2.5 text-destructive hover:bg-destructive/15","aria-label":d("toolbarPresets.deletePreset",{name:f.label}),children:s.jsx(Ms,{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(p$,{value:f.programs,onChange:R=>n(f.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(f.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:f.includeAlt})]}),s.jsxs("button",{type:"button",onClick:()=>n(f.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:f.showOnDesktop===!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.rowLayout")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:d("toolbarPresets.rowLayoutHint")})]}),s.jsxs("button",{type:"button",onClick:()=>n(f.id,R=>({...R,rowLayout:[...tg(R.rowLayout),3]})),className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium hover:bg-surface-elevated",children:[s.jsx(zs,{size:12}),d("toolbarPresets.addRow")]})]}),s.jsx("div",{className:"space-y-2",children:f.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(m$,{value:R,min:d$,max:h$,onChange:z=>n(f.id,O=>({...O,rowLayout:O.rowLayout.map(($,V)=>V===B?z:$)}))}),f.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(f.id,z=>({...z,rowLayout:z.rowLayout.filter((O,$)=>$!==B)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":d("toolbarPresets.removeRow",{n:B+1}),children:d("toolbarPresets.del")})]},`row-${B}`))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:d("toolbarPresets.buttons")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:d("toolbarPresets.buttonsHint")})]}),s.jsxs("button",{type:"button",onClick:()=>{const R=`${f.id}-action-${Date.now()}`;n(f.id,B=>({...B,actions:[...B.actions,{id:R,label:`Key ${B.actions.length+1}`,sequence:""}]})),x(R)},className:"inline-flex items-center gap-1 rounded-full bg-primary/15 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/25",children:[s.jsx(zs,{size:12}),d("toolbarPresets.addButton")]})]}),f.actions.length===0&&s.jsx("div",{className:"rounded-2xl bg-surface-2/60 px-4 py-6 text-center text-[11px] text-muted-foreground",children:d("toolbarPresets.noCustomButtons")}),f.actions.map((R,B)=>{const z=m===R.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${z?"ring-1 ring-accent/40":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>S(R.id,-1),disabled:B===0,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":d("toolbarPresets.moveUp"),children:s.jsx(By,{size:12})}),s.jsx("button",{type:"button",onClick:()=>S(R.id,1),disabled:B===f.actions.length-1,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":d("toolbarPresets.moveDown"),children:s.jsx(MA,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(z?null:R.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:l1(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(f.id,O=>({...O,actions:O.actions.filter($=>$.id!==R.id)})),className:"shrink-0 rounded-full bg-surface p-2 text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":d("toolbarPresets.removeAction",{name:R.label}),children:s.jsx(Ms,{size:14})})]}),z&&s.jsxs("div",{className:"space-y-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.labelField")}),s.jsx("input",{type:"text",value:R.label,onChange:O=>n(f.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,label:O.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.labelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.sequence")}),s.jsx("input",{type:"text",value:R.sequence,onChange:O=>n(f.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,sequence:O.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.sequencePlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:oy.map(O=>s.jsx("button",{type:"button",onClick:()=>n(f.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,sequence:O.sequence}:V)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:O.label},O.label))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:d("toolbarPresets.doubleTap")}),!R.doubleTapSequence&&s.jsx("button",{type:"button",onClick:()=>n(f.id,O=>({...O,actions:O.actions.map($=>$.id===R.id?{...$,doubleTapSequence:""}:$)})),className:"text-[10px] text-accent hover:text-accent/80",children:d("toolbarPresets.doubleTapAdd")})]}),R.doubleTapSequence!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:R.doubleTapSequence,onChange:O=>n(f.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:O.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:d("toolbarPresets.doubleTapPlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[oy.map(O=>s.jsx("button",{type:"button",onClick:()=>n(f.id,$=>({...$,actions:$.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:(V.doubleTapSequence??"")+O.sequence}:V)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:O.label},O.label)),s.jsx("button",{type:"button",onClick:()=>n(f.id,O=>({...O,actions:O.actions.map($=>{if($.id!==R.id)return $;const{doubleTapSequence:V,...Y}=$;return Y})})),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)})]})]})]})},x$={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function b$(){const{t:e}=Ur(),[t,r]=L.useState(null),[n,a]=L.useState(null),[c,l]=L.useState(null),[d,f]=L.useState(null),[m,x]=L.useState(!1),[y,w]=L.useState(!1),[v,S]=L.useState(""),[C,I]=L.useState(""),[R,B]=L.useState(null),[z,O]=L.useState([]),[$,V]=L.useState([]),[Y,le]=L.useState(null),[be,pe]=L.useState(new Set),[ee,ke]=L.useState(null),[He,q]=L.useState("auto"),[ce,qe]=L.useState({}),[Ae,ve]=L.useState(null),[Ie,Be]=L.useState(null),[ne,Fe]=L.useState(10),[Le,Re]=L.useState(""),[Pe,Ee]=L.useState(""),[oe,We]=L.useState(12e3),[rt,gt]=L.useState(null),[ue,Ye]=L.useState(null),at=L.useCallback(async()=>{const[me,Ze,ct,Tt]=await Promise.allSettled([y9(),v9(),fc(),dd()]);if(r(me.status==="fulfilled"?me.value:[]),Ze.status==="fulfilled"){const X=Ze.value;O(X.plugins??[]),V(X.errors??[])}else O([]),V([]);if(ct.status==="fulfilled"){const X=ct.value;pe(new Set(X.autoRenameAgents??[])),q(X.autoRenameNamer??"auto"),qe(X.autoRenameModels??{}),Fe(X.autoRenameIntervalMinutes??10),Re(X.autoRenamePromptPreference??""),Ee(X.autoRenamePromptPreference??""),We(X.autoRenamePromptPayloadChars??12e3)}else pe(new Set);ve(Tt.status==="fulfilled"?Tt.value:[])},[]);L.useEffect(()=>{at()},[at]);const Ne=async(me,Ze)=>{a(me),l(null);try{Ze==="install"?(await w9(me)).devMode&&f(me):(await A9(me),d===me&&f(null)),await at()}catch(ct){l(ct instanceof Error?ct.message:String(ct))}finally{a(null)}},Ge=me=>e(me==="installed"?"settings.agentHooksInstalled":me==="outdated"?"settings.agentHooksOutdated":me==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),Ce=async()=>{B(null);let me;try{me=JSON.parse(C)}catch{B("Invalid JSON");return}try{await L9(me),I(""),x(!1),await at()}catch(Ze){if(Ze instanceof I9&&Ze.migration){V(ct=>[{slug:typeof me.slug=="string"?me.slug:"manifest.json",errors:Ze.message.split(`
|
|
164
|
-
`),code:Ze.code,migration:Ze.migration},...ct.filter(Tt=>Tt.slug!==me.slug)]);return}B(Ze instanceof Error?Ze.message:String(Ze))}},H=async()=>{const me=v.trim();if(me){gt("install"),B(null);try{await T9(me),S(""),w(!1),await at()}catch(Ze){B(Ze instanceof Error?Ze.message:String(Ze))}finally{gt(null)}}},ae=async me=>{gt(`remove:${me}`);try{await k9(me),Ye(Ze=>Ze?.slug===me?null:Ze),await at()}catch(Ze){l(Ze instanceof Error?Ze.message:String(Ze))}finally{gt(null)}},ye=async me=>{gt(`check:${me}`),l(null);try{await _9(me),await at()}catch(Ze){l(Ze instanceof Error?Ze.message:String(Ze))}finally{gt(null)}},Ve=async me=>{gt(`update:${me}`),l(null);try{const Ze=await C9(me),ct=[Ze.hookWarning,Ze.titleWarning].filter(Boolean).join(" ");ct&&l(ct),Ye(Tt=>Tt?.slug===me?null:Tt),await at()}catch(Ze){l(Ze instanceof Error?Ze.message:String(Ze))}finally{gt(null)}},Je=async me=>{gt(`doctor:${me}`),l(null),Ye(null);try{const Ze=await S9(me);Ye(Ze),ve(await dd())}catch(Ze){l(Ze instanceof Error?Ze.message:String(Ze))}finally{gt(null)}},bt=async me=>{const Ze=me.migration?.aiPrompt??me.errors.join(`
|
|
165
|
-
`);try{await navigator.clipboard.writeText(Ze),le(me.slug),window.setTimeout(()=>le(ct=>ct===me.slug?null:ct),1800)}catch{B(Ze)}},Vt=async me=>{if(ee)return;const Ze=be,ct=new Set(Ze);ct.has(me)?ct.delete(me):ct.add(me),pe(ct),ke(me),l(null);try{const Tt=await La({autoRenameAgents:[...ct]});pe(new Set(Tt.autoRenameAgents??[])),ve(await dd(!0))}catch(Tt){pe(Ze),l(Tt instanceof Error?Tt.message:String(Tt))}finally{ke(null)}},Pt=async me=>{const Ze=He;q(me),Be("namer"),l(null);try{const ct=await La({autoRenameNamer:me});q(ct.autoRenameNamer??"auto"),ve(await dd(!0))}catch(ct){q(Ze),l(ct instanceof Error?ct.message:String(ct))}finally{Be(null)}},mt=async(me,Ze)=>{const ct=ce,Tt={...ct};Ze?Tt[me]=Ze:delete Tt[me],qe(Tt),Be(me),l(null);try{const X=await La({autoRenameModels:Tt});qe(X.autoRenameModels??{})}catch(X){qe(ct),l(X instanceof Error?X.message:String(X))}finally{Be(null)}},Zt=async me=>{const Ze=ne;Fe(me),Be("interval"),l(null);try{const ct=await La({autoRenameIntervalMinutes:me});Fe(ct.autoRenameIntervalMinutes??10)}catch(ct){Fe(Ze),l(ct instanceof Error?ct.message:String(ct))}finally{Be(null)}},Ht=async()=>{const me=Le.trim();if(me!==Pe){Be("preference"),l(null);try{const ct=(await La({autoRenamePromptPreference:me})).autoRenamePromptPreference??"";Re(ct),Ee(ct)}catch(Ze){Re(Pe),l(Ze instanceof Error?Ze.message:String(Ze))}finally{Be(null)}}},Kt=async me=>{const Ze=Math.max(1e3,Math.min(64e3,Math.round(me||12e3))),ct=oe;We(Ze),Be("payload-limit"),l(null);try{const Tt=await La({autoRenamePromptPayloadChars:Ze});We(Tt.autoRenamePromptPayloadChars??12e3)}catch(Tt){We(ct),l(Tt instanceof Error?Tt.message:String(Tt))}finally{Be(null)}},Ot=new Set(z.map(me=>me.slug)),Nt=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:He,disabled:Ie!==null,onChange:me=>{Pt(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")}),Ae?.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:ne,disabled:Ie!==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:Le,maxLength:2e3,rows:3,disabled:Ie!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:me=>Re(me.target.value),onBlur:()=>{Ht()},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:Ie==="preference"?e("settings.saving"):`${Le.length}/2000`})]}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePayloadLimit")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePayloadLimitHint")}),s.jsx("input",{type:"number",min:1e3,max:64e3,step:1e3,value:oe,disabled:Ie!==null,onChange:me=>We(Number(me.target.value)),onBlur:me=>{Kt(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()=>{ve(null);try{ve(await dd(!0))}catch{ve([])}},className:"rounded p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",title:e("settings.agentAutoRenameRefreshModels"),children:s.jsx(bn,{size:11,className:Ae===null?"animate-spin":""})})]}),Ae?.filter(me=>me.available).map(me=>{const Ze=me.models.find(ct=>ct.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:ce[me.slug]??"",disabled:Ie!==null,onChange:ct=>{mt(me.slug,ct.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:Ze?`${e("settings.agentAutoRenameAutomatic")} · ${Ze.displayName}`:e("settings.agentAutoRenameCliDefault")}),me.models.map(ct=>s.jsx("option",{value:ct.id,children:ct.displayName},ct.id))]})]},me.slug)}),Ae?.length===0&&s.jsx("div",{className:"text-[10px] text-[color:var(--warning)]",children:e("settings.agentAutoRenameNoCli")})]})]}),t===null&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx(_n,{size:12,className:"animate-spin"})," …"]}),t?.map(me=>{const Ze=n===me.slug,ct=me.state!=="not-installed",Tt=Ot.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:Tt,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}),Tt&&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] ${x$[me.state]}`,children:[me.state==="installed"&&s.jsx(f0,{size:10,className:"mr-0.5 inline"}),(me.state==="outdated"||me.state==="needs-approval")&&s.jsx(F1,{size:10,className:"mr-0.5 inline"}),Ge(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:ee!==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":be.has(me.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(ll,{checked:be.has(me.slug),disabled:ee!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:Ze,onClick:()=>{Ne(me.slug,ct?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${ct?"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:[Ze?s.jsx(_n,{size:11,className:"animate-spin"}):ct?s.jsx(Ms,{size:11}):me.state==="outdated"?s.jsx(bn,{size:11}):s.jsx(m0,{size:11}),Ze?"…":ct?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(zs,{size:11}),e("settings.agentPluginAdd")]})]}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentPluginHint")}),y&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:v,onChange: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(_n,{size:11,className:"animate-spin"}):s.jsx(m0,{size:11}),e("settings.agentPluginInstallPackage")]})]}),s.jsx("button",{type:"button",onClick:()=>x(!m),className:"text-[10px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentPluginAdvancedManifest")})]}),z.map(me=>{const Ze=me.revision?.slice(0,8),ct=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"),Ze?` · ${Ze}`:""]})]}),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(_n,{size:10,className:"animate-spin"}):s.jsx(IS,{size:10}),e("settings.agentPluginDoctor")]}),me.updateSupported&&s.jsxs("button",{type:"button",disabled:rt!==null,onClick:()=>{me.updateAvailable?Ve(me.slug):ye(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:[ct?s.jsx(_n,{size:10,className:"animate-spin"}):s.jsx(bn,{size:10}),me.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:rt!==null,onClick:()=>{ae(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(Ms,{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,": ",Nt]}),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))})]}),$.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:()=>{bt(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:[Y===me.slug?s.jsx(f0,{size:10}):s.jsx(Py,{size:10}),Y===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:C,onChange:me=>I(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:()=>{Ce()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(sT,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),I(""),B(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function y$({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:d,onCheckDesktop:f,onInstallDesktop:m}){const{t:x}=Ur(),y=e?.status??"idle",w=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,S=y==="checking"?x("settings.updateChecking"):y==="installing"?x("sidebar.updateInstalling"):y==="ready"?x("sidebar.updateReady"):y==="restarting"?x("sidebar.updateRestarting"):y==="current"?x("settings.updateCurrent"):y==="error"?e?.error||x("sidebar.updateFailed"):x("settings.updateHint"),C=a?.currentVersion||l?.appVersion,I=a?.status??"idle",R=c||I==="checking"||I==="downloading"||I==="installing",B=I==="ready",z=a?.error||(I==="unsupported"?x("settings.desktopUpdateUnsupported"):I==="checking"?x("settings.desktopUpdateChecking"):I==="current"?x("settings.desktopUpdateCurrent"):I==="downloading"?x("settings.desktopUpdateDownloading"):I==="ready"?x("settings.desktopUpdateReady"):I==="installing"?x("settings.desktopUpdateInstalling"):I==="error"&&a?.error||x("settings.desktopUpdateHint"));return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"termdock-update-title",children:[s.jsx("div",{id:"termdock-update-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:x("settings.updateTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(bn,{size:15,className:w?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.updateRuntimeTitle")}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:S}),e&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:v&&e.latestVersion?`${e.currentVersion} → ${e.latestVersion}`:`v${e.currentVersion}`})]})]}),v?s.jsx("button",{type:"button",disabled:w,onClick:n,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("sidebar.updateRestart")}):s.jsx("button",{type:"button",disabled:w,onClick:r,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(y==="checking"?"settings.updateCheckingShort":y==="installing"?"settings.updateInstallingShort":y==="error"?"sidebar.updateRetry":y==="current"?"settings.updateCheckAgain":"settings.updateCheck")})]}),(a||d)&&s.jsxs("div",{className:"flex items-start justify-between gap-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${B?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(bn,{size:15,className:R?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.desktopUpdateTitle")}),s.jsx("div",{className:`mt-0.5 text-[10px] leading-relaxed ${a?.error?"text-destructive":"text-muted-foreground"}`,role:a?.error?"alert":void 0,children:a?z:x(f?"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}`:C?`v${C}`: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||I==="unsupported"||!f,onClick:f,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(I==="installing"?"settings.updateInstallingShort":I==="downloading"?"settings.desktopUpdateDownloadingShort":I==="checking"?"settings.updateCheckingShort":I==="current"||I==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),d]})}function v$({quality:e}){const{locale:t}=Ur(),r=(d,f)=>t==="zh"?d:f,n=d=>d==null||!Number.isFinite(d)?"—":`${d.toFixed(1)} ms`,a=e?.diagnostics,c=d=>s.jsx("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1.5 tabular-nums",children:d.map(([f,m])=>s.jsxs(L.Fragment,{children:[s.jsx("dt",{children:f}),s.jsx("dd",{className:"text-right text-foreground break-all",children:m})]},f))}),l=(d,f)=>s.jsxs("section",{className:"mt-3 border-t border-border/30 pt-3",children:[s.jsx("h3",{className:"mb-2 font-medium text-foreground",children:d}),f]});return s.jsxs("div",{className:"text-[11px] leading-relaxed",children:[l(r("往返统计","Round-trip statistics"),s.jsxs(s.Fragment,{children:[c([[r("平均延迟","Average latency"),n(e?.average)],["P95",n(e?.p95)],[r("服务端回包处理","Server reply handler"),n(e?.handlerMs)]]),s.jsx("p",{className:"mt-2",children:r("8 秒未响应计为超时,不等于网络丢包。回包处理仅含消息解析至构造回复,不含解密、排队和发包。","A probe times out after 8s; this is not packet loss. Handler timing covers parsing through reply creation, excluding decryption, queues and transmission.")})]})),l(r("当前发送与排队","Current buffers and queues"),a?s.jsxs(s.Fragment,{children:[c([[r("传输层发送缓冲","Transport send buffer"),`${a.bufferedBytes} B`],[r("加密通道待发送","Channel writes pending"),a.pendingWrites?r("有","Yes"):r("无","No")],[r("进行中的非终端请求","Active non-terminal requests"),a.activeRequests],[r("等待通道的请求","Requests waiting for capacity"),a.waitingRequests]]),s.jsx("p",{className:"mt-2",children:r("属于此服务共用的连接,包含文件等其他请求。","Shared by this service, including file transfers and other requests.")})]}):s.jsx("p",{children:r("尚无连接记录。","No connection record yet.")})),l(r("本次连接建立 · 历史耗时","Connection setup · recorded timings"),s.jsxs(s.Fragment,{children:[c([[r("传输通道就绪","Transport ready"),n(a?.transportOpenMs)],...a?.relay?[[r("其中:连上入口 WebSocket","Within transport: entry WebSocket"),n(a.relay.entryOpenMs)],[r("其中:请求中转至通道打开","Within transport: relay open request"),n(a.relay.routeOpenMs)]]:[],[r("Noise 加密握手","Noise handshake"),n(a?.handshakeMs)],[r("终端逻辑通道就绪","Terminal logical channel ready"),n(a?.socketOpenMs)],[r("其中:等待本地通道名额","Within logical open: local capacity wait"),n(a?.socketQueueMs)]]),s.jsx("p",{className:"mt-2",children:r("这是建链时的历史耗时,不代表当前延迟。“其中”为子项,不能重复相加;中转耗时含处理和建链,不含之前的授权。","Recorded setup timings, not live latency. “Within” rows are subsets, not additive. Relay timing includes processing and setup, excluding earlier authorization.")})]}))]})}function w$({backendSessionId:e}){const{locale:t}=Ur(),r=t==="zh",[n,a]=L.useState(null),[c,l]=L.useState(!1);L.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(E9(e));y();const w=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(w),document.removeEventListener("visibilitychange",y)}},[e,c]);const d=n?.diagnostics,f=n?.rtt,m=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":f==null?r?"测量中…":"Measuring…":`${f} ms · ${f<150?r?"流畅":"Low latency":f<300?r?"有延迟":"Moderate latency":r?"高延迟":"High latency"}`:r?"未连接":"Disconnected",x=y=>y==null?"—":`${Math.round(y)} ms`;return s.jsxs("div",{className:"mt-3 rounded-xl bg-surface-2 px-3 text-muted-foreground",children:[s.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(y=>!y),className:"flex min-h-11 w-full items-center gap-2 py-2 text-[12px] tabular-nums hover:text-foreground","aria-label":`${r?"连接质量":"Connection quality"}${c?`: ${m}`:""}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${c&&n&&(!n.connected||n.waiting||f!=null&&f>=300)?"bg-destructive":"bg-current"}`}),s.jsxs("span",{className:"flex-1 text-left",children:[r?"连接质量":"Connection quality",c?` · ${m}`:""]}),s.jsx("span",{"aria-hidden":"true",children:c?"▾":"▸"})]}),c&&s.jsxs("div",{className:"pb-3 text-[11px] leading-relaxed",children:[!e&&s.jsx("p",{children:r?"请先打开一个终端会话,再查看连接质量。":"Open a terminal session to measure connection quality."}),s.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 tabular-nums",children:[s.jsx("dt",{children:r?"近期延迟":"Recent latency"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.minimum==null?"—":`${Math.round(n.minimum)}–${Math.round(n.maximum??n.minimum)} ms`}),s.jsx("dt",{children:r?"波动":"Jitter"}),s.jsx("dd",{className:"text-right text-foreground",children:x(n?.jitter)}),s.jsx("dt",{children:r?"探测超时":"Probe timeouts"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.samples?`${n.timeouts} / ${n.samples}`:"—"}),s.jsx("dt",{children:r?"连接路径":"Connection route"}),s.jsx("dd",{className:"text-right text-foreground break-words",children:d?`${d.path==="relay"?r?"经入口中转":"Via relay":r?"直连":"Direct"} · ${d.endpoint}`:"—"})]}),s.jsx("p",{className:"mt-2",children:r?"每 5 秒更新,统计最近 20 次;波动越小越稳定。":"Updates every 5s, using the last 20 probes. Lower jitter means more consistent latency."}),s.jsxs("details",{className:"mt-3 border-t border-border/30 pt-2",children:[s.jsx("summary",{className:"cursor-pointer py-1 hover:text-foreground",children:r?"诊断详情":"Diagnostics"}),s.jsx(v$,{quality:n})]})]})]})}const ly={"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 A$(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 T$({state:e,onDismiss:t}){const{t:r}=Ur(),[n,a]=b.useState(!1),[c,l]=b.useState(!1),d=b.useRef(!1),f=b.useRef(!0);b.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(d.current=!1,a(!1),l(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const z=window.setTimeout(()=>{d.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(z)},[n]);const m=async()=>{if(!d.current){d.current=!0,l(!1),a(!0);try{await N9()}catch{if(!f.current)return;d.current=!1,a(!1),l(!0)}}};if(!e)return null;const x=e.incident,y=!e.supervised&&e.supervisor?.phase==="gave-up",w=!e.supervised&&e.supervisor!==null&&!e.supervisor.alive,v=y||w||e.attention,S=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",C=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):w?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),I=x?r(ly[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(ly[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",B=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:A$(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(TS,{size:15}):s.jsx(CS,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:C}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(S?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${I}${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 S$=()=>()=>{},C$=()=>1/0;function _$(){const{t:e}=Ur(),t=b.useId(),r=Po(),n=b.useSyncExternalStore(r?.subscribe??S$,r?.retentionLimit??C$);if(!r)return null;const a=R9+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 D1="mobile-session-destroy";function k$(e,t){return t&&e.type==="session"&&e.destination?.droppableId===D1}const Ca="termdock-program-rules-cache",Bh="termdock-toolbar-presets-cache",Gd="termdock-settings-cache",cy="termdock-color-theme",uy="termdock:right-sidebar:file-preview-open-by-session:v2",Vd="termdock:running-session-button-enabled:v1",qd="termdock:attention-button-enabled:v1",L$=60,dy=320,hy=420,Qo=8;function fy(e,t,r){return Math.min(Math.max(e,t),r)}function py(e){if(typeof window>"u")return{left:Qo,top:Qo};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(Qo,window.innerWidth-dy-Qo),l=Math.max(Qo,window.innerHeight-hy-Qo);return{left:fy(n+Qo,Qo,c),top:fy(a+Qo,Qo,l),width:dy,maxHeight:`min(${hy}px, calc(100vh - ${Qo*2}px))`}}function I$(e){return e==="dark"||e==="light"}function E$(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 Pm(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,L$);return Object.fromEntries(t)}function N$(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 R$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function M$(e,t){const r=v0(),n=new Set(vE()),a=Array.isArray(e)?e:[],c=Ru(a),l=t<Xd;if(c.length===0)return r;if(l){const f=new Map(c.map(w=>[w.id,w])),m=new Map(a.map(w=>[typeof w.id=="string"?w.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):"",w])),x=c.filter(w=>!n.has(w.id));return[...r.map(w=>{const v=f.get(w.id),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(f=>f.id));return[...c,...r.filter(f=>!d.has(f.id))]}function j$(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const D$={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},ip="__termdockOverlay",ap="__termdockBaseAnchor",op="__termdockBaseGuard",B$=3,my=250,Q$="termdock-notification-target-v1",gy="/__termdock-notification-target",xy=3e4;function P$(e){return e==="left-sidebar"||e==="right-sidebar"||e==="right-sidebar-repo-picker"||e==="right-sidebar-file-preview"||e==="settings"||e==="markdown-outline"||e==="markdown-image-lightbox"}function Su(e){if(!e||typeof e!="object")return null;const t=e[ip];return P$(t)?t:null}function Mg(e){return e&&typeof e=="object"?{...e}:{}}function i4(e){const t=Mg(e);return delete t[ip],t}function O$(e){const t=i4(e);return delete t[op],{...t,[ap]:!0}}function F$(){typeof window>"u"||window.history.pushState({...i4(window.history.state),[ap]:!0,[op]:!0},"",window.location.href)}function a4(){for(let e=0;e<B$;e+=1)F$()}function Qh(){typeof window>"u"||(window.history.replaceState(O$(window.history.state),"",window.location.href),a4())}function Yd(e){typeof window>"u"||window.history.pushState({...Mg(window.history.state),[ap]:!0,[ip]:e,[op]:!1},"",window.location.href)}function $$(e){typeof window>"u"||window.history.replaceState({...Mg(window.history.state),[ap]:!0,[ip]:e,[op]:!1},"",window.location.href)}const o4=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let _a=new Set(o4);function by(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 U$(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 yy(e,t){return s.jsx(HP,{sessionMode:e,state:t})}function z$(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 H$=L.lazy(()=>Oc(()=>import("./CollaborationMainWorkspace-DG8TQNqo.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function W$(){const{t:e,locale:t,setLocale:r}=Ur(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";M9();const c=L.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[l,d]=L.useState(!1),[f,m]=L.useState(()=>Tc(cy,I$)??"dark"),x=L.useRef(Tc(Gd,j$)).current,[y,w]=L.useState(x?.preventSleep??!1),[v,S]=L.useState(x?.networkAvailable??!0),[C,I]=L.useState(j9),[R,B]=L.useState(D9),[z,O]=L.useState(B9),[$,V]=L.useState(Q9),[Y,le]=L.useState(Cp),[be,pe]=L.useState(x?.localAccess??D$),[ee,ke]=L.useState(x?.localAccess?.name??""),[He,q]=L.useState(!1),[ce,qe]=L.useState(null),[Ae,ve]=L.useState(null),[Ie,Be]=L.useState(null),[ne,Fe]=L.useState(!1),[Le,Re]=L.useState(null),Pe=L.useMemo(()=>vo(),[]),Ee=!!(Pe?.desktopUpdateState&&Pe.checkDesktopUpdate&&Pe.installDesktopUpdate),[oe,We]=L.useState(null),[rt,gt]=L.useState(null),[ue,Ye]=L.useState(!1),[at,Ne]=L.useState(null),[Ge,Ce]=L.useState(!1),[H,ae]=L.useState(()=>Pm(Tc(uy,E$)??{})),[ye,Ve]=L.useState(0),[Je,bt]=L.useState(!1),[Vt,Pt]=L.useState(0),[mt,Zt]=L.useState(!1),[Ht,Kt]=L.useState(0),[Ot,Nt]=L.useState(!1),[me,Ze]=L.useState(0),ct=L.useRef(null),[Tt,X]=L.useState({}),{terminalSettings:yt,updateTerminalSettings:nt}=KB(),_e=yt.fontSize,tr=yt.rendererMode,[Ke,kt]=L.useState(!1),Ut=L.useRef(P9()).current,[vt,wt]=b.useState(()=>Ut.sessions.map(_=>({id:_.sessionId,name:_.name,customName:_.customName,mode:_.mode,tmuxSessionName:_.tmuxSessionName}))),Mt=Ei(_=>_.groupId);L.useEffect(()=>{const _=()=>Ei.getState().terminal();return window.addEventListener("switch-terminal-session",_),()=>window.removeEventListener("switch-terminal-session",_)},[]);const[_t,fr]=L.useState(Ut.activeSessionId),[qt,Sr]=L.useState(!1);L.useEffect(()=>{qt&&O9({rendered:!0})},[qt]);const[pn,dr]=L.useState(null),[ge,Gr]=L.useState(null),[ot,ft]=L.useState([]),[ir,Mn]=b.useState(()=>{const _=Yr.getState();return Ut.sessions.forEach(P=>{P.backendSessionId&&_.setTerminalSession(P.sessionId,{sessionId:P.backendSessionId,cols:80,rows:24,mode:P.mode,tmuxSessionName:P.tmuxSessionName}),P.activeProgram!=null&&_.setSessionActiveProgram(P.sessionId,P.activeProgram),P.cwd!=null&&_.setSessionCwd(P.sessionId,P.cwd),P.shellTitle!=null&&_.setSessionShellTitle(P.sessionId,P.shellTitle)}),Mu("session-chrome-hydrated"),by(Yr.getState().sessions)});b.useEffect(()=>{!Pe||!Ke||Promise.all([Pe.snapshot(),Pe.desktopUpdateState?.()??Promise.resolve(null)]).then(([_,P])=>{We(_),gt(P)}).catch(_=>Ne(_ instanceof Error?_.message:String(_)))},[Pe,Ke]),b.useEffect(()=>{Pe?.onDesktopUpdateState&&Pe.onDesktopUpdateState(gt)},[Pe]),b.useEffect(()=>Yr.subscribe(_=>{const P=by(_.sessions);Mn(de=>U$(de,P)?de:P)}),[]);const Xr=b.useCallback(async(_,P)=>{Gr(null),dr({sessionId:_,status:"submitting",error:null});try{await F9(P),dr(de=>de?.sessionId===_?{...de,status:"waiting",error:null}:de)}catch(de){const St=(de&&typeof de=="object"&&"code"in de?String(de.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):de instanceof Error&&/busy/i.test(de.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");dr(Yt=>Yt?.sessionId===_?{...Yt,error:St}:Yt),Gr({tone:"error",message:St})}},[e]);b.useEffect(()=>{if(!pn||pn.status!=="waiting")return;const _=ir.get(pn.sessionId);if(!_||_.agentResumeRecovered||_.agentStatus===null&&!_.agent)return;const P=_.agent?.displayName??"Agent";dr(null),Gr({tone:"success",message:e("tab.resumeAgentSuccess",{agent:P})})},[pn,ir,e]),b.useEffect(()=>{if(!pn||pn.status!=="waiting"||pn.error)return;const _=pn.sessionId,P=window.setTimeout(()=>{const de=e("tab.resumeAgentTimeout");dr(tt=>tt?.sessionId===_&&tt.status==="waiting"?{...tt,error:de}:tt),Gr({tone:"error",message:de})},15e3);return()=>window.clearTimeout(P)},[pn,e]),b.useEffect(()=>{if(ge?.tone!=="success")return;const _=window.setTimeout(()=>Gr(null),3200);return()=>window.clearTimeout(_)},[ge]),b.useEffect(()=>{let _=!1;$9().then(de=>{_||Be(de)}).catch(()=>{}),U9().then(de=>{_||Re(de)}).catch(()=>{});const P=hx(de=>{_||(de.type==="update-state"?Be(de.state):de.type==="server-health"&&Re(de.state))});return()=>{_=!0,P()}},[]);const De=b.useCallback(async()=>{try{Re(await z9())}catch(_){window.alert(_ instanceof Error?_.message:String(_))}},[]),st=b.useCallback(async()=>{const _=Ie?.latestVersion;if(!(!_||ne)&&window.confirm(e("sidebar.updateRestartConfirm",{version:_}))){Fe(!0);try{Be(await H9())}catch(P){window.alert(P instanceof Error?P.message:String(P))}finally{Fe(!1)}}},[Ie?.latestVersion,e,ne]),xt=b.useCallback(async()=>{if(!ne){Fe(!0);try{Be(await W9())}catch(_){window.alert(_ instanceof Error?_.message:String(_))}finally{Fe(!1)}}},[ne]),Br=b.useCallback(async()=>{if(!(!Pe?.checkDesktopUpdate||ue)){Ye(!0);try{gt(await Pe.checkDesktopUpdate())}catch(_){Ne(_ instanceof Error?_.message:String(_))}finally{Ye(!1)}}},[Pe,ue]),Vr=b.useCallback(async()=>{if(!(!Pe?.installDesktopUpdate||ue||rt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ye(!0);try{gt(await Pe.installDesktopUpdate())}catch(_){Ne(_ instanceof Error?_.message:String(_))}finally{Ye(!1)}}},[Pe,ue,rt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=f,G9(f),Fn(cy,f)},[f]),b.useEffect(()=>{Fn(uy,Pm(H))},[H]);const Cr=Gt(_=>_.leftOpen),qr=Gt(_=>_.rightOpen),mn=Gt(_=>_.leftPinned),on=Gt(_=>_.leftSidebarWidth),zr=Gt(_=>_.rightPinned),un=Gt(_=>_.rightSidebarWidth),Er=Gt(_=>_.rootPath),re=Gt(_=>_.contextKey),pt=Gt(_=>_.selectedFilePath),jt=Gt(_=>_.groupByFolder),nr=hf(_=>_.collaborationGroups),Ar=Gt(_=>_.collapsedGroups),Fr=Gt(_=>_.toggleGroupCollapsed),[Xt,Zr]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Jt,Pr]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[Hr,ps]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[Mr,jn]=b.useState([]),[Tr,Jr]=b.useState({available:!0,version:null,reason:null}),[ln,Qr]=b.useState(!1),[ks,Dr]=b.useState(null),[en,xn]=b.useState(null),[K,ze]=b.useState(null),[Rt,Et]=b.useState(null),[rr,jr]=b.useState(null),[cr,Cn]=b.useState(null),[Ls,Xn]=b.useState(null),[,cn]=b.useState(0),[dn,_r]=b.useState(null),[Or,Gn]=b.useState(null),[Vn,gn]=b.useState(null),[Jn,kr]=b.useState(!1),[Lr,pr]=b.useState(()=>Tc(Vd,_=>typeof _=="boolean")??!1),ns=b.useCallback(async _=>{const P=Lr;pr(_),Fn(Vd,_);try{const de=await La({runningSessionButtonEnabled:_});pr(de.runningSessionButtonEnabled),Fn(Vd,de.runningSessionButtonEnabled)}catch{pr(P),Fn(Vd,P)}},[Lr]),[Un,En]=b.useState(()=>Tc(qd,_=>typeof _=="boolean")??!0),kn=b.useCallback(async _=>{const P=Un;En(_),Fn(qd,_);try{const de=await La({attentionButtonEnabled:_});En(de.attentionButtonEnabled),Fn(qd,de.attentionButtonEnabled)}catch{En(P),Fn(qd,P)}},[Un]),[ss,Wr]=b.useState(null),tn=b.useCallback(_=>{Wr(_)},[]),G=b.useRef(!1),[je,$e]=b.useState(null),[et,it]=b.useState(null),Ct=L.useRef(null),Lt=L.useRef(!1),Bt=L.useRef(null),ht=L.useRef(!1),Qt=b.useCallback(()=>{Cn(null),Xn(null)},[]),W=L.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[N,U]=L.useState(W.current),[Z,fe]=L.useState(!0),Qe=L.useRef(W.current),we=L.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(min-width: 1024px)"),P=()=>{Zr(_.matches),Pr(window.innerWidth)};return P(),_.addEventListener("change",P),window.addEventListener("resize",P),()=>{_.removeEventListener("change",P),window.removeEventListener("resize",P)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(orientation: landscape)"),P=()=>ps(_.matches);return P(),_.addEventListener("change",P),()=>_.removeEventListener("change",P)},[]);const lt=L.useMemo(()=>_t?ot.find(_=>_.sessionIds.includes(_t))??null:null,[_t,ot]),At=lt?.id??null,br=lt?.sessionIds[0]??_t,It=L.useRef([]);L.useLayoutEffect(()=>{const _=It.current;if(It.current=ot,_.length===0)return;const P=new Set(ot.flatMap(de=>de.sessionIds));for(const de of _){const tt=de.sessionIds.filter(St=>!P.has(St)).map(St=>({sessionId:St,rootPath:Yr.getState().sessions.get(St)?.cwd??null}));tt.length>0&&Gt.getState().inheritRightSidebarStateFromSplitWorkspace(de.id,tt)}},[ot]),L.useLayoutEffect(()=>((()=>{const P=br?Yr.getState().sessions.get(br)?.cwd??null:null;Gt.getState().setRootPath(P,br,At)})(),Yr.subscribe((P,de)=>{const tt=br?P.sessions.get(br)?.cwd??null:null,St=br?de.sessions.get(br)?.cwd??null:null;tt!==St&&Gt.getState().setRootPath(tt,br,At)})),[At,br]);const rn=L.useRef(e3(window.location.search)??iC(Sc()?.targetPeerId)),[yn,hn]=L.useState("");L.useEffect(()=>{const _=rn.current;if(!_)return;if(_.peerId&&_.peerId!==Sc()?.targetPeerId){const tt=V9().find(St=>St.targetPeerId===_.peerId);if(tt&&Po()){try{sC(_)}catch{hn(t==="zh"?"无法在此浏览器打开架构链接。":"Cannot open this architecture link in this browser.");return}if(q9(tt)){rn.current=null;const St=new URL(window.location.href);St.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",St);return}}hn(t==="zh"?`此架构属于 ${_.serviceName??_.peerId}。请先连接该 Termdock 服务,再打开链接。`:`This architecture belongs to ${_.serviceName??_.peerId}. Connect to that Termdock service, then open this link.`);return}hn("");try{sessionStorage.setItem(`termdock.architecture.selection:${_.root}`,_.file)}catch{}const P=Gt.getState();P.setRootPath(_.root,br,At),P.setRightTab("architecture"),P.openRight();const de=new URL(window.location.href);de.searchParams.delete("architecture"),window.history.replaceState(window.history.state,"",de),br&&(rn.current=null)},[br,At,t]);const Dn=Xt||Hr,zn=Jt*.95,hr=Dn?Math.min(Math.max(Jt*.22,280),340):Math.min(Jt*.86,380),Dt=_t&&Er?`${_t}\0${Er}`:"",Bn=!!(Dt&&pt&&H[Dt]),qn=b.useCallback(_=>{Dt&&(_&&!Gt.getState().selectedFilePath||ae(P=>{if(!!P[Dt]===_)return P;if(_)return Pm({...P,[Dt]:{updatedAt:Date.now()}});const tt={...P};return delete tt[Dt],tt}))},[Dt]);b.useEffect(()=>{nQ(Dt,re,pt)&&ae(_=>{if(!_[Dt])return _;const P={..._};return delete P[Dt],P})},[Dt,re,pt]);const Qn=Ot?"markdown-image-lightbox":mt?"markdown-outline":Je?"right-sidebar-repo-picker":qr&&Bn?"right-sidebar-file-preview":Ke?"settings":qr&&!(zr&&Xt)?"right-sidebar":Cr&&!(mn&&Xt)?"left-sidebar":null,is=L.useRef(Qn),zi=L.useRef(Qn),ha=L.useRef(!1),bs=L.useRef(!1),Va=b.useCallback(()=>{if(typeof window>"u")return;const _=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!Xt||!_||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[Xt]),So=b.useCallback(_=>{if(_==="markdown-image-lightbox"){Nt(!1),Ze(P=>P+1);return}if(_==="markdown-outline"){Zt(!1),Kt(P=>P+1);return}if(_==="right-sidebar-file-preview"){Zt(!1),Kt(P=>P+1),qn(!1),Ve(P=>P+1);return}if(_==="right-sidebar-repo-picker"){bt(!1),Pt(P=>P+1);return}if(_==="settings"){kt(!1),ws(!1),si(!1),cs(!1);return}if(_==="left-sidebar"){Gt.getState().closeLeft();return}Zt(!1),Kt(P=>P+1),bt(!1),Pt(P=>P+1),Nt(!1),Ze(P=>P+1),Gt.getState().closeRight()},[qn]),Hn=b.useCallback(_=>{if(!c&&typeof window<"u"&&is.current===_&&Su(window.history.state)===_){window.history.back();return}So(_)},[So,c]),fa=b.useCallback(()=>{kt(!1);const _=Gt.getState();_.closeRight(),_.openLeft()},[]),ms=b.useCallback(()=>{kt(!1);const _=Gt.getState();_.closeLeft(),_.openRight()},[]),Ia=b.useCallback(()=>{kt(!1);const _=Gt.getState();_.closeLeft(),_.openRight(),_.setRightTab("files"),_.openRightSearch()},[]),as=b.useCallback(()=>{const _=Gt.getState();if(_.leftPinned){_.setLeftPinned(!1),_.closeLeft();return}if(Cr){Hn("left-sidebar");return}fa()},[fa,Hn,Cr]),qa=b.useCallback(()=>{const _=Gt.getState();_.leftPinned?(_.setLeftPinned(!1),_.openLeft()):(_.setLeftPinned(!0),_.openLeft())},[]),ei=b.useCallback(()=>{const _=Gt.getState();_.setLeftPinned(!1),_.closeLeft()},[]),ti=b.useCallback(()=>{const _=Gt.getState();_.rightPinned?(_.setRightPinned(!1),_.openRight()):(_.setRightPinned(!0),_.openRight())},[]),Hs=b.useCallback(()=>{const _=Gt.getState();_.setRightPinned(!1),_.closeRight()},[]),Ya=b.useRef(0),Is=b.useRef(0),pa=b.useRef(null),dl=b.useCallback(_=>{_.preventDefault(),Ya.current=_.clientX,Is.current=Gt.getState().leftSidebarWidth;const P=tt=>{pa.current===null&&(pa.current=requestAnimationFrame(()=>{pa.current=null;const St=tt.clientX-Ya.current;Gt.getState().setLeftSidebarWidth(Is.current+St)}))},de=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",de),pa.current!==null&&(cancelAnimationFrame(pa.current),pa.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)},[]),Za=b.useRef(0),os=b.useRef(0),js=b.useRef(null),Hi=b.useCallback(_=>{_.preventDefault(),Za.current=_.clientX;const P=Gt.getState(),de=P.leftPinned?P.leftSidebarWidth:0;os.current=Oh(P.rightSidebarWidth,window.innerWidth,de);const tt=Yt=>{js.current===null&&(js.current=requestAnimationFrame(()=>{js.current=null;const Nr=Za.current-Yt.clientX,An=Gt.getState(),Nn=An.leftPinned?An.leftSidebarWidth:0;An.setRightSidebarWidth(Oh(os.current+Nr,window.innerWidth,Nn))}))},St=()=>{window.removeEventListener("mousemove",tt),window.removeEventListener("mouseup",St),js.current!==null&&(cancelAnimationFrame(js.current),js.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",St)},[]),xi=b.useCallback(()=>{const _=Gt.getState();if(_.rightPinned){_.setRightPinned(!1),_.closeRight();return}if(qr){Hn("right-sidebar");return}ms()},[ms,Hn,qr]),bi=b.useCallback(()=>{!Bn&&!c&&typeof window<"u"&&is.current==="right-sidebar"&&Su(window.history.state)==="right-sidebar"&&(Yd("right-sidebar-file-preview"),zi.current="right-sidebar-file-preview"),qn(!0)},[Bn,c,qn]),hl=b.useCallback(()=>{Hn("right-sidebar-file-preview")},[Hn]),ri=b.useCallback(()=>{!Je&&!c&&typeof window<"u"&&is.current==="right-sidebar"&&Su(window.history.state)==="right-sidebar"&&(Yd("right-sidebar-repo-picker"),zi.current="right-sidebar-repo-picker"),bt(!0)},[Je,c]),Uo=b.useCallback(()=>{Hn("right-sidebar-repo-picker")},[Hn]),ma=b.useCallback(()=>{!mt&&!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&(Yd("markdown-outline"),zi.current="markdown-outline"),Zt(!0)},[mt,c]),fl=b.useCallback(()=>{Hn("markdown-outline")},[Hn]),pl=b.useCallback(()=>{!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&(Yd("markdown-image-lightbox"),zi.current="markdown-image-lightbox"),Nt(!0)},[c]),ls=b.useCallback(()=>{Hn("markdown-image-lightbox")},[Hn]),Ds=b.useCallback(()=>{!c&&typeof window<"u"&&is.current&&Su(window.history.state)===is.current&&($$("settings"),zi.current="settings"),Gt.getState().closeAll(),kt(!0)},[c]),Ri=b.useCallback(()=>{Hn("settings")},[Hn]);b.useEffect(()=>{if(!Pe)return;const _=()=>Ds();return window.addEventListener("termdock:open-settings",_),()=>window.removeEventListener("termdock:open-settings",_)},[Pe,Ds]);const zo=b.useCallback(()=>{Ce(!0),ct.current!==null&&(window.clearTimeout(ct.current),ct.current=null)},[]),Dl=b.useCallback(()=>{ct.current!==null&&(window.clearTimeout(ct.current),ct.current=null),Ce(!1),bs.current=!0,Qh(),bs.current},[]);b.useEffect(()=>()=>{ct.current!==null&&window.clearTimeout(ct.current)},[]),b.useEffect(()=>{c||Qh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let _=null;const P=()=>{_!==null&&(window.clearTimeout(_),_=null)},de=An=>{if(is.current,bs.current,is.current){is.current;return}!An?.force&&bs.current||(An?.userActivated&&(bs.current=!0),Qh(),bs.current,void 0)},tt=()=>{P(),_=window.setTimeout(()=>{_=null,de({force:!0})},my)},St=()=>{de({userActivated:!0})},Yt=()=>{tt()},Nr=()=>{document.visibilityState==="visible"&&tt()};return window.addEventListener("pointerdown",St,{capture:!0,passive:!0}),window.addEventListener("touchstart",St,{capture:!0,passive:!0}),window.addEventListener("keydown",St,{capture:!0}),window.addEventListener("pageshow",Yt),document.addEventListener("visibilitychange",Nr),()=>{P(),window.removeEventListener("pointerdown",St,{capture:!0}),window.removeEventListener("touchstart",St,{capture:!0}),window.removeEventListener("keydown",St,{capture:!0}),window.removeEventListener("pageshow",Yt),document.removeEventListener("visibilitychange",Nr)}},[c]),b.useEffect(()=>{is.current=Qn},[Qn]),b.useEffect(()=>{if(typeof window>"u"||Qn||c)return;const _=window.setTimeout(()=>{is.current?(is.current,void 0):Qh()},my);return()=>window.clearTimeout(_)},[Qn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const _=zi.current;ha.current,Qn&&Qn!==_&&!ha.current&&Yd(Qn),!Qn&&_&&Va(),zi.current=Qn,!Qn&&ha.current&&window.setTimeout(()=>{ha.current=!1},0)},[Qn,c,Va]),b.useEffect(()=>{if(typeof window>"u"||c)return;const _=()=>{const P=is.current;if(bs.current,!P){bs.current=!1,bs.current,zo(),a4();return}ha.current=!0,So(P)};return window.addEventListener("popstate",_),()=>window.removeEventListener("popstate",_)},[So,zo,c]),b.useEffect(()=>{const _=P=>{const de=P.metaKey||P.ctrlKey;if(de&&P.key==="b"&&!P.shiftKey&&(P.preventDefault(),as()),de&&P.shiftKey&&P.key==="E"&&(P.preventDefault(),xi()),de&&P.shiftKey&&P.key==="P"&&(P.preventDefault(),Ia()),de&&!P.shiftKey&&P.altKey&&(P.key==="ArrowLeft"||P.key==="ArrowRight")){P.preventDefault();const 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",_),()=>{document.removeEventListener("keydown",_)}},[as,xi,Ia]);const Es=b.useCallback(async()=>{q(!0),qe(null);try{const _=await La({localAccess:{name:ee}});pe(_.localAccess),ke(_.localAccess.name),Fn(Gd,{preventSleep:_.preventSleep,networkAvailable:_.networkAvailable,localAccess:_.localAccess})}catch(_){qe(_ instanceof Error?_.message:"Failed to save local access name")}finally{q(!1)}},[ee]),Ea=b.useCallback(async()=>{q(!0),qe(null);try{const _=await La({localAccess:{reset:!0}});pe(_.localAccess),ke(_.localAccess.name),Fn(Gd,{preventSleep:_.preventSleep,networkAvailable:_.networkAvailable,localAccess:_.localAccess})}catch(_){qe(_ instanceof Error?_.message:"Failed to reset local access name")}finally{q(!1)}},[]),ml=b.useCallback(async(_,P="url")=>{if(_)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(_);else{const de=document.createElement("textarea");de.value=_,de.style.position="fixed",de.style.left="-9999px",document.body.appendChild(de),de.focus(),de.select(),document.execCommand("copy"),document.body.removeChild(de)}ve(P),window.setTimeout(()=>ve(de=>de===P?null:de),1600)}catch{ve(null)}},[]),es=b.useCallback(_=>{const P=z$(vt,_);P.map(de=>de.id).join("\0")!==vt.map(de=>de.id).join("\0")&&(wt(P),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:P.map(de=>de.id)}})))},[vt]),Wi=b.useCallback(_=>{Xt||_.type!=="session"||(G.current=!1,kr(!1),gn(_.draggableId))},[Xt]),Mi=b.useCallback(_=>{if(Xt||_.type!=="session")return;const P=_.destination?.droppableId===D1;P!==G.current&&(G.current=P,kr(P),P&&navigator.vibrate?.(20))},[Xt]),Gi=b.useCallback(_=>{const P=k$(_,!Xt);if(G.current=!1,kr(!1),gn(null),!P)return!1;const de=vt.find(St=>St.id===_.draggableId),tt=de?ir.get(de.id):null;return de&&F5({mode:de.mode,activeProgram:tt?.activeProgram??null,promptState:tt?.promptState??null,shellNames:_a})?(it(null),$e(de.id),ze(null)):de&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:de.id,source:"other",closeMode:de.mode==="tmux"?"destroy":"auto"}})),!0},[Xt,vt,ir]),{groups:gs,arranged:Ws}=L.useMemo(()=>uf(vt,_=>ir.get(_.id)?.cwd??null,jt,e("sidebar.ungrouped"),ot,nr),[vt,ir,jt,e,ot,nr]),Bl=b.useCallback(_=>{Gi(_)||!_.destination||_.source.index===_.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:Ws[_.source.index]?.id,targetId:Ws[_.destination.index]?.id}}))},[Gi,Ws]),Vi=b.useCallback((_,P)=>{const de=P.trim();de&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:_,name:de}}))},[]),qi=b.useCallback(_=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:_}}))},[]),{newSessionMode:fn,newSessionTmuxName:ga,userSelectedNewSessionMode:Yi,setNewSessionMode:Na}=eQ(),[ji,Di]=b.useState(null),[ni,ws]=L.useState(!1),[Gs,Bi]=L.useState(!1),[Ra,si]=L.useState(!1),[ys,Ka]=L.useState("idle"),Xa=L.useRef(Tc(Bh,R$)).current,[As,Ja]=L.useState(()=>{const _=Xa?.presets;if(_&&_.length>0){const P=Ru(_);if(P.length>0)return P}return v0()}),[Ql,Ho]=L.useState(!1),[Co,xa]=L.useState("default"),Ma=L.useRef(typeof Xa?.updatedAt=="number"?Xa.updatedAt:null),Wo=L.useRef(!1),[ba,cs]=L.useState(!1),[Go,Zi]=L.useState(!1),gl=L.useRef(Tc(Ca,N$)).current,[se,T]=L.useState(gl??[]),[j,Q]=L.useState(gl!==null),[F,xe]=L.useState(!1),Se=!Mt&&!Qn&&!Gs&&!Ra&&!ni&&!ba&&!Go&&!cr&&!je&&!ji,Oe=L.useCallback(_=>{const P=typeof _.version=="number"?_.version:0,de=M$(Array.isArray(_.presets)?_.presets:[],P);Ma.current=typeof _.updatedAt=="number"?_.updatedAt:null,Ja(tt=>Y9(tt,de)?tt:(Wo.current=!0,de)),Fn(Bh,{version:Xd,presets:de,updatedAt:Ma.current??void 0})},[]);b.useEffect(()=>{const _=P=>{if(P.key!=="Escape"||P.defaultPrevented||P.isComposing||P1())return;if(Gs){P.preventDefault(),Bi(!1);return}if(Ra){P.preventDefault(),si(!1);return}if(ni){P.preventDefault(),ws(!1);return}if(ba){P.preventDefault(),cs(!1);return}if(Go){P.preventDefault(),Zi(!1);return}if(cr){P.preventDefault(),Qt();return}if(dn){P.preventDefault(),jr(null),_r(null);return}if(Ke){P.preventDefault(),Ri();return}if(qr&&!(zr&&Xt)){P.preventDefault(),Hn("right-sidebar");return}Cr&&!(mn&&Xt)&&(P.preventDefault(),Hn("left-sidebar"))};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[Gs,Ra,ni,ba,cr,Qt,Ke,qr,zr,Cr,mn,Xt,Ri,Hn]),b.useEffect(()=>{Q(!0)},[]);const[Xe,dt]=L.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:o4}),[,er]=L.useState(!1),or=L.useCallback(()=>Z9().then(_=>{dt(_),_a=new Set(_.shellNames),er(!0)}).catch(()=>{}),[]);b.useEffect(()=>{or()},[or]),b.useEffect(()=>hx(_=>{if(_.type==="config-updated"){if(_.key==="toolbar-presets"){fx().then(P=>Oe(P)).catch(P=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",P)});return}_.key==="program-detection"&&or()}}),[Oe,or]),b.useEffect(()=>{let _=!1;return(async()=>{try{const P=await fx();if(_)return;Oe(P)}catch(P){console.warn("[toolbar-presets] Failed to load from server:",P)}finally{_||Ho(!0)}})(),()=>{_=!0}},[Oe]),b.useEffect(()=>{if(Ql){if(Wo.current){Wo.current=!1;return}Fn(Bh,{version:Xd,presets:As,updatedAt:Ma.current??void 0}),K9({version:Xd,presets:As,baseUpdatedAt:Ma.current??void 0}).then(_=>{Ma.current=typeof _.updatedAt=="number"?_.updatedAt:null,Fn(Bh,{version:Xd,presets:As,updatedAt:Ma.current??void 0})}).catch(_=>{const P=_ instanceof Error&&"current"in _?_.current:null;P&&typeof P=="object"&&Oe(P),console.warn("[toolbar-presets] Failed to save to server:",_)})}},[Oe,As,Ql]),b.useEffect(()=>{fc().then(_=>{w(P=>P===_.preventSleep?P:_.preventSleep),S(P=>P===_.networkAvailable?P:_.networkAvailable),pe(_.localAccess),ke(_.localAccess.name),pr(_.runningSessionButtonEnabled),Fn(Vd,_.runningSessionButtonEnabled),En(_.attentionButtonEnabled),Fn(qd,_.attentionButtonEnabled),Fn(Gd,{preventSleep:_.preventSleep,networkAvailable:_.networkAvailable,localAccess:_.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!C)return;const _=Cp();le(_),_!=="granted"&&(I(!1),th(!1))},[C]),b.useEffect(()=>{if(!C)return;hd();const _=()=>{document.visibilityState==="visible"&&(hd(),uA())},P=window.setInterval(()=>{hd()},360*60*1e3);return document.addEventListener("visibilitychange",_),window.addEventListener("focus",_),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",_),window.removeEventListener("focus",_)}},[C]);const $r=b.useCallback(async()=>{if(C){I(!1),th(!1),X9(),le(Cp());return}const _=await J9();if(le(_),_!=="granted"){I(!1),th(!1);return}I(!0),th(!0),await hd(!0,!0),Ka("idle")},[C]),nn=b.useCallback(async()=>{Ka("checking"),await vo()?.prepareNotificationTest?.();const _=await eA({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Ka(_?"delivered":"failed")},[e]),Pn=b.useCallback(_=>{B(_),tA(_),_p()},[]),yr=b.useCallback(_=>{O(_),rA(_),_p()},[]),wn=b.useCallback(_=>{V(_),nA(_),_p()},[]);b.useEffect(()=>{As.some(_=>_.id===Co)||xa(As[0]?.id??"default")},[Co,As]),b.useEffect(()=>{if(!Tr.available&&fn==="tmux"){Na("shell",{userInitiated:!1});return}Tr.available&&Yi!=="shell"&&fn!=="tmux"&&Na("tmux",{userInitiated:!1})},[fn,Tr.available,Yi,Na]),b.useEffect(()=>{Di(null)},[Ke,fn,Tr.available]),b.useEffect(()=>{const _={};typeof navigator<"u"&&(_.userAgent=navigator.userAgent,_.platform=navigator.platform,_.maxTouchPoints=navigator.maxTouchPoints,_.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,_.vendor=navigator.vendor),typeof window<"u"&&(_.screenWidth=window.innerWidth,_.screenHeight=window.innerHeight,_.pixelRatio=window.devicePixelRatio,_.orientation=window.screen?.orientation?.type||"unknown",_.hasVisualViewport=!!window.visualViewport,_.visualViewportHeight=window.visualViewport?.height,_.visualViewportWidth=window.visualViewport?.width,_.location=window.location.href),_.timestamp=new Date().toISOString(),_.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,_.isAndroid=/Android/.test(navigator.userAgent),X(_)},[]);const us=b.useCallback(_=>{if(Gi(_)||!_.destination)return;if(_.type==="group"){if(_.source.index===_.destination.index)return;es(Yy(gs,_.source.index,_.destination.index));return}if(_.source.droppableId!==_.destination.droppableId||_.source.index===_.destination.index)return;const P=_.source.droppableId.replace(/^group-sessions:/,""),de=gs.find(tt=>tt.key===P);de&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:de.sessions[_.source.index]?.id,targetId:de.sessions[_.destination.index]?.id}}))},[gs,es,Gi]),Bs=L.useMemo(()=>Ws.flatMap(_=>{const P=ir.get(_.id);if(P?.agentStatus!=="working")return[];const{primary:de,secondary:tt}=il(_,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null);return[{id:_.id,label:de,detail:tt}]}),[Ws,ir]),pc=_t?Ws.findIndex(_=>_.id===_t):-1,Vs=Ws.length>0&&pc>=0?`${pc+1}/${Ws.length}`:`${Ws.length}`,Ki=L.useMemo(()=>{let _=0;for(const P of vt){const de=ir.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&(_+=1)}return{running:Bs.length,review:_}},[Bs.length,vt,ir]),_o=L.useMemo(()=>Ws.flatMap(_=>{const P=ir.get(_.id);if(P?.agentStatus!=="waiting"&&!P?.agentNeedsReview)return[];const{primary:de}=il(_,P.activeProgram,P.cwd,_a,P.shellTitle,P.promptState);return[{id:P.terminalSessionId??_.id,label:de,waiting:P.agentStatus==="waiting"}]}),[Ws,ir]);sA(Ki.running,Ki.review,_o);const yi=_t?vt.find(_=>_.id===_t)??null:null,ko=yi?ir.get(yi.id):void 0,tu=!!(yi&&ko?.agentResumeRecovered&&ko.agentNativeSessionId&&ko.terminalSessionId),vi=yi&&pn?.sessionId===yi.id?pn:null;L.useLayoutEffect(()=>{if(!Z)return;const _=Bt.current;if(!_)return;const P=!ht.current;_.scrollIntoView({inline:"nearest",block:"nearest",behavior:P?"auto":"smooth"}),ht.current=!0,P&&Mu("active-tab-positioned")},[_t,Z]),b.useEffect(()=>{rr&&Ct.current&&(Ct.current.scrollIntoView({block:"nearest",inline:"nearest"}),Ct.current.focus(),Ct.current.select()),rr||(Lt.current=!1)},[rr]);const F0=b.useCallback(_=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_}))},[]),wi=b.useCallback((_,P)=>{Xn(P??null),Cn(_)},[]),rd=kg(),eo=b.useCallback(_=>{if(!_)return;U(_),we.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:we.current,requestedSessionId:_,activeSessionId:_t,sessions:vt.map(de=>({id:de.id,terminalSessionId:ir.get(de.id)?.terminalSessionId??null}))}),iA(_);const P=vt.find(de=>de.id===_||ir.get(de.id)?.terminalSessionId===_);P?(Qe.current=null,we.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:we.current,requestedSessionId:_,targetSessionId:P.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):(Qe.current=_,we.current&&ka("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:we.current,requestedSessionId:_}))},[_t,vt,ir]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let _=!1;const P=async()=>{if(window.parent!==window&&Po()){fe(!0);return}try{const tt=await caches.open(Q$),St=await tt.match(gy);if(!St)return;await tt.delete(gy);const Yt=await St.json();if(_)return;const Nr=typeof Yt.sessionId=="string"?Yt.sessionId:null,An=typeof Yt.traceId=="string"?Yt.traceId:null,Nn=typeof Yt.clickedAt=="number"?Yt.clickedAt:0,Ln=Date.now()-Nn;ka("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:An,sessionId:Nr,ageMs:Ln,valid:!!(Nr&&Ln>=0&&Ln<=xy),visibilityState:document.visibilityState}),Nr&&Ln>=0&&Ln<=xy&&(we.current=An,typeof Yt.targetPeerId=="string"&&Yt.targetPeerId!==Sc()?.targetPeerId?Po()?.focusSession(Yt.targetPeerId,Nr):eo(Nr))}catch(tt){ka("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:tt instanceof Error?tt.message:String(tt)})}finally{_||fe(!0)}},de=()=>{document.visibilityState==="visible"&&P()};return P(),document.addEventListener("visibilitychange",de),window.addEventListener("pageshow",P),()=>{_=!0,document.removeEventListener("visibilitychange",de),window.removeEventListener("pageshow",P)}},[eo]),b.useEffect(()=>{if(typeof window>"u")return;const _=new URLSearchParams(window.location.search),P=_.get("session");if(!P)return;ka("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:we.current,targetSessionId:P,href:window.location.href,visibilityState:document.visibilityState});const de=_.get("service");de&&de!==Sc()?.targetPeerId?Po()?.focusSession(de,P):Qe.current=P,_.delete("service"),_.delete("session"),_.delete("_notifTrace");const tt=_.toString(),St=`${window.location.pathname}${tt?`?${tt}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",St)},[]),b.useEffect(()=>{if(typeof window>"u")return;const _=new URLSearchParams(window.location.search);if(_.get("_notif")!=="1")return;const P=_.get("session");_.delete("_notif");const de=_.toString(),tt=`${window.location.pathname}${de?`?${de}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",tt),window.parent!==window&&Po())return;const St=new BroadcastChannel("termdock:notif");let Yt=!1;const Nr=Nn=>{Nn.data?.type==="termdock:notif-pong"&&!Yt&&(Yt=!0,St.close(),window.close())};St.addEventListener("message",Nr),St.postMessage({type:"termdock:notif-ping",sessionId:P,targetPeerId:_.get("service")});const An=setTimeout(()=>{Yt||St.close()},500);return()=>{clearTimeout(An),Yt||St.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&Po())return;const _=new BroadcastChannel("termdock:notif"),P=de=>{de.data?.type==="termdock:notif-ping"&&(_.postMessage({type:"termdock:notif-pong"}),typeof de.data.sessionId=="string"&&(typeof de.data.targetPeerId=="string"&&de.data.targetPeerId!==Sc()?.targetPeerId?Po()?.focusSession(de.data.targetPeerId,de.data.sessionId):eo(de.data.sessionId)))};return _.addEventListener("message",P),()=>_.close()},[eo]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const _=P=>{const de=P.data;if(de&&de.type==="termdock:focus-session"&&typeof de.sessionId=="string"){if(typeof de.targetPeerId=="string"&&de.targetPeerId!==Sc()?.targetPeerId){Po()?.focusSession(de.targetPeerId,de.sessionId)&&P.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}P.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),eo(de.sessionId)}else de?.type==="termdock:push-subscription-changed"?hd(!0):de?.type};return navigator.serviceWorker.addEventListener("message",_),()=>navigator.serviceWorker.removeEventListener("message",_)},[eo]),b.useEffect(()=>{const _=P=>{const de=P.detail;typeof de=="string"&&eo(de)};return window.addEventListener("termdock:focus-session",_),()=>window.removeEventListener("termdock:focus-session",_)},[eo]),b.useEffect(()=>{const _=()=>{const P=dA(Sc()?.targetPeerId);P&&eo(P)};return _(),window.addEventListener("termdock:workspace-session",_),()=>window.removeEventListener("termdock:workspace-session",_)},[eo]),b.useEffect(()=>{const _=Qe.current;if(!_)return;const P=vt.find(de=>de.id===_||ir.get(de.id)?.terminalSessionId===_);P?(Qe.current=null,we.current&&ka("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:we.current,requestedSessionId:_,targetSessionId:P.id,activeSessionId:_t}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):we.current&&ka("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:we.current,requestedSessionId:_,activeSessionId:_t,sessions:vt.map(de=>({id:de.id,terminalSessionId:ir.get(de.id)?.terminalSessionId??null}))})},[_t,vt,ir]);const ya=L.useMemo(()=>{const _=[];for(const P of vt){const de=ir.get(P.id);(de?.agentStatus==="waiting"||de?.agentNeedsReview)&&_.push(P.id)}return _},[vt,ir]),Pl=b.useCallback(()=>{if(ya.length===0)return;_t&&Yr.getState().clearAgentNeedsReview(_t);const _=_t?vt.findIndex(de=>de.id===_t):-1,P=ya.find(de=>vt.findIndex(tt=>tt.id===de)>_)??ya[0];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[ya,vt,_t]),ru=b.useCallback(()=>{if(ya.length===0)return;_t&&Yr.getState().clearAgentNeedsReview(_t);const _=_t?vt.findIndex(de=>de.id===_t):vt.length,P=[...ya].reverse().find(de=>vt.findIndex(tt=>tt.id===de)<_)??ya[ya.length-1];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[ya,vt,_t]);b.useEffect(()=>{const _=P=>{!P.altKey||!P.shiftKey||P.metaKey||P.ctrlKey||P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventDefault(),P.key==="ArrowUp"?ru():Pl())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[Pl,ru]);const lp=b.useCallback(async _=>{const de=Yr.getState().sessions.get(_)?.cwd;if(de)try{await navigator.clipboard?.writeText(de),Gn(de),window.setTimeout(()=>{Gn(tt=>tt===de?null:tt)},1400)}catch{}},[]),cp=b.useCallback(_=>{wt(_.sessions),fr(_.activeSessionId),ft(_.splitWorkspaces),Yr.getState().setActiveSessionId(_.activeSessionId)},[]),up=b.useCallback(()=>{Sr(!0)},[]),dp=b.useCallback(()=>{Sr(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!N||!_t)return;vt.find(P=>P.id===N||ir.get(P.id)?.terminalSessionId===N)?.id===_t&&U(null)},[_t,N,vt,ir]);const nd=b.useRef(!1),[nu,$0]=b.useState(!1),ja=b.useCallback(_=>{const P=!_?.onResult;if(P&&nd.current)return;P&&(nd.current=!0,$0(!0));const de=_?.mode??fn,tt=de==="tmux"&&(_?.tmuxSessionName?.trim()||ga.trim())||void 0,St=_?.cwd||(_t?Yr.getState().sessions.get(_t)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:de,tmuxSessionName:tt,cwd:St,command:_?.command,shouldActivate:_?.shouldActivate,onResult:_?.onResult??(Yt=>{nd.current=!1,$0(!1),Yt.ok||Gr({tone:"error",message:e(Hm(Yt.error))})})}}))},[fn,ga,_t,e]),Vo=b.useCallback(async()=>{Qr(!0);try{const _=await Om();if(Jr(_),!_.available){jn([]);return}const P=await Fm();jn(P)}catch{Jr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),jn([])}finally{Qr(!1)}},[]),mc=b.useCallback(async _=>{const{cleanedSessions:P}=await Cy(_);for(const de of P)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:de}));await Vo()},[Vo]),su=b.useCallback(async _=>{xn(_),ze(null);try{await mc(_),Dr(null)}catch(P){ze(P instanceof Error?P.message:"Failed to kill tmux session")}finally{xn(null)}},[mc]);b.useEffect(()=>{if(!Rt)return;if(Mr.find(de=>de.name===Rt&&(de.connected||de.boundFrontendSessionId))){Et(null);return}const P=setTimeout(()=>Et(null),1e4);return()=>clearTimeout(P)},[Rt,Mr]);const gc=b.useCallback(_=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:_}))},[]),iu=b.useCallback(_=>{const P=_??_t;P&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:P}))},[_t]),sd=b.useCallback((_,P)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:_,layout:P}}))},[]),U0=b.useCallback((_,P)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:_,sessionIds:P}}))},[]),z0=b.useCallback((_,P)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:_,name:P}}))},[]),H0=b.useCallback((_,P)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:_,secondaryId:P}}))},[]),Ol=b.useCallback((_,P,de)=>{const tt=vt.find(Yt=>Yt.id===_);if(!tt)return;const St=ir.get(_);if(de?.skipConfirmation||!F5({mode:tt.mode,activeProgram:St?.activeProgram??null,promptState:St?.promptState??null,shellNames:_a})){gc({sessionId:_,source:"sidebar",closeMode:tt.mode==="tmux"?"destroy":"auto"});return}it(P?{x:P.clientX,y:P.clientY}:null),$e(_),ze(null)},[vt,ir,gc]);b.useEffect(()=>{if(!Pe)return;const _=P=>{const de=P.detail;de==="new-session"?ja():de==="close-session"?_t&&Ol(_t):de==="previous-session"||de==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:de==="next-session"?"next":"prev"}})):de==="toggle-left-sidebar"?as():de==="toggle-right-sidebar"?xi():de==="previous-attention"?ru():de==="next-attention"&&Pl()};return window.addEventListener("termdock:native-command",_),()=>window.removeEventListener("termdock:native-command",_)},[_t,Pe,ja,Ol,as,xi,Pl,ru]);const to=L.useMemo(()=>vt.find(_=>_.id===je)??null,[vt,je]),id=b.useCallback(()=>{to&&(gc({sessionId:to.id,source:"sidebar",closeMode:"destroy"}),$e(null),it(null))},[to,gc]);b.useEffect(()=>{if(!to)return;const _=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopImmediatePropagation(),$e(null),it(null),ze(null);return}P.key!=="Enter"||P.isComposing||P.keyCode===229||P.altKey||P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.stopImmediatePropagation(),P.repeat||id())};return window.addEventListener("keydown",_,!0),()=>window.removeEventListener("keydown",_,!0)},[to,id]);const W0=L.useMemo(()=>{if(!to)return"";const _=ir.get(to.id);return il(to,_?.activeProgram??null,_?.cwd??null,_a,_?.shellTitle??null,_?.promptState??null).primary},[to,ir]);b.useEffect(()=>{if(!Ke)return;let _=!1,P=!1;const de=async()=>{if(!P)try{const St=await Om();if(_||Jr(St),!St.available){_||jn([]);return}const Yt=await Fm();_||jn(Yt)}catch{P=!0,_||(Jr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),jn([]))}};de();const tt=setInterval(()=>{de()},4e3);return()=>{_=!0,clearInterval(tt)}},[Ke]);const xc=ji??fn,Fl=xc==="shell",au=xc==="tmux"&&Tr.available,xl=L.useMemo(()=>qy(Mr.map(_=>({..._,id:_.name})),_=>_.cwd??null,e("sidebar.ungrouped")),[Mr,e]),ad=L.useMemo(()=>Mr.filter(_=>_.recoveryCandidate===!0&&!_.connected&&!_.boundFrontendSessionId).sort((_,P)=>(P.lastActiveAt??P.createdAt??0)-(_.lastActiveAt??_.createdAt??0)),[Mr]);b.useEffect(()=>{!Cr&&!(mn&&Xt)||Vo()},[Cr,mn,Xt,vt.length,Vo]);const bc=(_,P,de,tt=!1)=>{const St=_.id===_t,Yt=_.id===rr,Nr=ir.get(_.id),{primary:An,secondary:Nn}=il(_,Nr?.activeProgram??null,Nr?.cwd??null,_a,Nr?.shellTitle??null,Nr?.promptState??null),Ln=Yu(Nr?.cwd??null),Ai=P?Nn??(Ln&&Ln!==An?Ln:null):null,Tn=Nr?.gitStatus,Xi=`${Nr?.cwd||_.name}${Tn?`
|
|
186
|
-
⎇ ${Tn.branch} +${Tn.added} −${Tn.removed}`:""}`,Io=!!(Nr?.tuiProgress&&Nr.tuiProgress.state!=="remove"),Eo=Nr?.agentStatus==="working"||Io?"var(--success)":Nr?.agentStatus==="waiting"||Nr?.agentNeedsReview?"var(--warning)":Nr?.inCopyMode?"var(--tmux)":null;if(Yt&&Xt&&!dn){const Ba=_.customName?_.name:An,Qi=(ro,hp)=>{const cd=hp.trim();cd?cd!==Ba&&Vi(ro,cd):qi(ro),jr(null)};return s.jsx("input",{ref:ro=>{Ct.current=ro},type:"text",defaultValue:Ba,className:"h-8 shrink-0 rounded-md bg-surface-elevated px-2 text-[12px] leading-none text-foreground outline-none ring-1 ring-primary/50 sm:h-8 min-w-[5rem]",style:{width:`${Math.max(Ba.length,5)}ch`},onKeyDown:ro=>{ro.key==="Enter"?Qi(_.id,ro.target.value):ro.key==="Escape"&&jr(null)},onBlur:ro=>Qi(_.id,ro.target.value)})}return s.jsx("div",{ref:St?Bt:null,onContextMenu:Ba=>{Ba.preventDefault(),Xn({x:Ba.clientX,y:Ba.clientY}),Cn(_.id)},...rd(()=>wi(_.id)),className:tt?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${St?"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 ${St?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!tt&&St&&Eo?{boxShadow:`inset 2px 0 0 0 ${Eo}`}:!tt&&St?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:Xi,children:s.jsx("button",{type:"button",...de??{},onClick:()=>F0(_.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:Xi,children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 overflow-hidden",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center",children:[yy(_.mode,Nr),Nr?.agentResumeRecovered&&s.jsx(Qc,{size:tt?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),Io&&!Nr?.agentStatus&&s.jsx(_n,{size:tt?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),Ai?s.jsxs("span",{className:"flex min-w-0 flex-col justify-center leading-[0.82rem] sm:leading-[0.85rem]",children:[s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Nr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:An}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:Ai})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Nr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:An})]})})})},od=()=>s.jsx(Ll,{droppableId:D1,type:"session",isDropDisabled:Xt,children:(_,P)=>{const de=Jn||P.isDraggingOver;return s.jsxs("div",{ref:_.innerRef,..._.droppableProps,className:"pointer-events-none fixed left-1/2 top-[42%] z-toast flex h-32 w-32 -translate-x-1/2 -translate-y-1/2 items-center justify-center",role:"status","aria-live":"polite","aria-hidden":!Vn,"data-mobile-session-destroy-target":"","data-active":de?"true":"false",children:[s.jsxs("div",{className:`flex h-28 w-28 flex-col items-center justify-center gap-2 rounded-full border bg-surface-elevated/95 shadow-2xl backdrop-blur transition duration-200 ${Vn?de?"scale-110 border-destructive bg-destructive text-destructive-foreground opacity-100":"scale-100 border-destructive/50 text-destructive opacity-100":"scale-75 border-transparent opacity-0"}`,children:[s.jsx(Ms,{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")})]}),_.placeholder]})}}),va=mn&&Xt,$l=zr&&Xt,ld=Oh(un,Jt,va?on:0),yc=$l?ld+Sy:0,Ul=va?vt.find(_=>_.id===_t):null,Qs=Ul?ir.get(Ul.id):void 0,G0=Ul?il(Ul,Qs?.activeProgram??null,Qs?.cwd??null,_a,Qs?.shellTitle??null,Qs?.promptState??null).primary:"",Da=Xt?lt:null,Lo=va&&!Da&&Qs?Qs.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Qs.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Qs.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Qs.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",zl=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[yn&&s.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 bg-surface-2 px-3 py-2 text-xs",children:[s.jsx("p",{className:"min-w-0 flex-1 break-words",children:yn}),s.jsx("button",{type:"button",className:"min-h-11 px-2 text-primary",onClick:()=>hn(""),children:e("common.close")})]}),s.jsx("main",{className:"relative min-h-0 flex-1 overflow-visible px-0 pb-0 pt-0",children:s.jsxs(oC,{rightInset:yc,workspace:Mt&&s.jsx(L.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(H$,{groupId:Mt,activeSessionId:_t,defaultSessionMode:fn,onOpenSidebar:as,leftSidebarVisible:Cr||va,onToggleRightSidebar:xi,rightSidebarOpen:qr||$l},Mt)}),children:[s.jsxs("div",{className:`${Xt?"absolute inset-x-0 top-0 z-20":"relative"} shrink-0 items-center gap-1 app-chrome-bg px-1 sm:px-1.5 transition-colors duration-500 ${va?"flex justify-end":"flex justify-between"} ${jt?"h-10 sm:h-10":"h-9 sm:h-10"} ${Lo}`,style:{position:Xt?"absolute":void 0,marginRight:yc||void 0,display:Da?"none":void 0},children:[!va&&s.jsxs("button",{type:"button",onClick:as,className:"relative inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.sessionsTitle"),title:`${e("tab.sessionsTitle")} · ${e("agent.aiRunning")}: ${Ki.running} · ${e("agent.needsReview")}: ${Ki.review}`,children:[s.jsx(qT,{size:14}),s.jsx(GP,{runningCount:Ki.running,reviewCount:Ki.review,className:"sm:hidden"})]}),va?s.jsx("div",{className:"absolute left-1/2 flex max-w-[40%] min-w-0 -translate-x-1/2 items-center justify-center gap-1.5 overflow-hidden",children:Ul?s.jsxs(s.Fragment,{children:[yy(Ul.mode,Qs),s.jsx("span",{className:`truncate text-[12px] font-medium ${Qs?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:G0}),Qs?.agentStatus==="working"&&s.jsx("span",{title:Qs?.agentMessage??void 0,children:s.jsx(_n,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Qs?.agentStatus==="waiting"&&s.jsx("span",{title:Qs?.agentMessage??void 0,children:s.jsx(lf,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Qs?.agentStatus&&Qs?.agentNeedsReview&&s.jsx("span",{title:Qs?.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")})}):jt?s.jsxs(u0,{onDragStart:Wi,onDragUpdate:Mi,onDragEnd:us,children:[od(),s.jsx(Ll,{droppableId:"groups",type:"group",direction:"horizontal",children:_=>s.jsxs("div",{ref:_.innerRef,..._.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,St=0;for(const Nn of P.sessions){const Ln=ir.get(Nn.id);Ln?.agentStatus==="working"&&(tt+=1),(Ln?.agentStatus==="waiting"||Ln?.agentNeedsReview)&&(St+=1)}const Yt=P.sessions.some(Nn=>Nn.id===_t),Nr=Ar.has(P.key),An=P.key==="";return s.jsx(kl,{draggableId:`group-${P.key||"__ungrouped__"}`,index:de,isDragDisabled:An,disableInteractiveElementBlocking:!0,children:(Nn,Ln)=>s.jsxs("div",{ref:Nn.innerRef,...Nn.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${Ln.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":Yt?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...An?{}:Nn.dragHandleProps,onClick:()=>Fr(P.key),className:`flex ${Nr?"":P.sessions.length>1?"w-0 min-w-full":""} items-center gap-0.5 rounded text-[9px] font-semibold uppercase tracking-[0.08em] leading-none transition hover:bg-surface-elevated/40 ${An?"":"cursor-grab active:cursor-grabbing"} ${Yt?"text-primary/80":"text-muted-foreground/55"}`,title:P.key||P.label,children:[s.jsx(Xs,{size:9,className:`shrink-0 opacity-70 transition-transform ${Nr?"":"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)]"}),St>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${tt>0?"":"ml-auto"}`})]}),Nr?s.jsx("span",{className:"flex h-5 items-center text-[10px] leading-none text-muted-foreground/50",children:e("tab.sessionCount",{count:P.sessions.length})}):s.jsx(Ll,{droppableId:`group-sessions:${P.key}`,type:"session",direction:"horizontal",children:Ai=>s.jsxs("div",{ref:Ai.innerRef,...Ai.droppableProps,className:"flex items-center gap-px",children:[P.sessions.map((Tn,Xi)=>s.jsx(kl,{draggableId:Tn.id,index:Xi,disableInteractiveElementBlocking:!0,children:(Io,Eo)=>s.jsx("div",{ref:Io.innerRef,...Io.draggableProps,className:`flex shrink-0 items-center ${Eo.isDragging?"opacity-70":""}`,children:bc(Tn,!1,Io.dragHandleProps,!0)})},Tn.id)),Ai.placeholder]})})]})},P.key||"__ungrouped__")}),_.placeholder,s.jsx("button",{type:"button",onClick:()=>ja(),disabled:nu,"aria-busy":nu,className:"my-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(zs,{size:14})})]})})]}):s.jsxs(u0,{onDragStart:Wi,onDragUpdate:Mi,onDragEnd:Bl,children:[od(),s.jsx(Ll,{droppableId:"tabs",type:"session",direction:"horizontal",children:_=>s.jsxs("div",{ref:_.innerRef,..._.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===rr?s.jsx(L.Fragment,{children:s.jsx(kl,{draggableId:P.id,index:de,isDragDisabled:!0,children:St=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:"flex h-full items-center",children:bc(P,!0)})})},P.id):s.jsx(L.Fragment,{children:s.jsx(kl,{draggableId:P.id,index:de,disableInteractiveElementBlocking:!0,children:(St,Yt)=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:`flex h-full shrink-0 items-center ${Yt.isDragging?"opacity-70":""}`,children:bc(P,!0,St.dragHandleProps)})})},P.id)),s.jsx("button",{type:"button",onClick:()=>ja(),disabled:nu,"aria-busy":nu,className:"ml-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(zs,{size:14})}),_.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!va&&Ki.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(O6,{count:Ki.running,tone:"running",title:e("agent.aiRunning")})}),!va&&vt.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 ${vt.length}`,children:Vs}),!$l&&s.jsx("button",{type:"button",onClick:xi,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.explorerTitle"),title:e("tab.explorerTitle"),children:s.jsx(zy,{size:14})})]})]}),tu&&yi&&ko?.terminalSessionId&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 bg-surface/80 px-3 py-2 animate-fade-in sm:px-4",style:{marginRight:yc||void 0},role:"status","data-testid":"agent-resume-recovery-banner",children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] text-[color:var(--warning)]",children:!vi?.error&&(vi?.status==="submitting"||vi?.status==="waiting")?s.jsx(_n,{size:14,className:"animate-spin"}):s.jsx(Qc,{size:14})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:e("tab.resumeAgentRecoveredTitle",{agent:ko.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${vi?.error?"text-destructive":"text-muted-foreground"}`,children:vi?.error??(vi?.status==="submitting"?e("tab.resumeAgentSubmitting"):vi?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!vi?.error&&(vi?.status==="submitting"||vi?.status==="waiting"),onClick:()=>{Xr(yi.id,ko.terminalSessionId)},className:"shrink-0 rounded-full bg-primary px-3 py-1.5 text-[11px] font-semibold text-primary-foreground transition hover:opacity-90 active:scale-95 disabled:cursor-wait disabled:opacity-60 sm:text-[12px]",children:vi?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Yr.getState().setAgentResumeRecovered(yi.id,!1),dr(_=>_?.sessionId===yi.id?null:_)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("tab.resumeAgentLater"),title:e("tab.resumeAgentLater"),children:s.jsx(In,{size:13})})]}),s.jsx("div",{ref:tn,className:"min-h-0 flex-1 flex overflow-hidden app-chrome-bg",children:s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(NN,{terminalSettings:yt,colorTheme:f,toolbarPresets:As,showDebug:l&&Xt,terminalFocusAvailable:Se,defaultSessionMode:fn,defaultTmuxSessionName:ga,connectionPrioritySessionId:N,connectionPriorityReady:Z,desktopRightSidebarEnabled:Xt,onToggleRightSidebar:xi,desktopFloatingTitle:Xt,desktopPinnedLeftSidebarWidth:va?on:0,desktopViewportWidth:Jt,onSessionDataUpdate:cp,onInitialViewportReady:dp,onInitialRecoveryRequired:up})})})]})}),!Mt&&s.jsx(KP,{reviewCount:Ki.review,runningSessions:Bs,activeSessionId:_t,runningButtonEnabled:Lr,attentionButtonEnabled:Un,isDesktopLayout:Xt,containerElement:ss,occlusionInsets:{right:yc}}),Ke&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-drawer-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm animate-fade-in cursor-default",onClick:Ri,"aria-label":e("settings.closeSettings")}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-dialog-title",className:"pointer-events-none fixed inset-0 z-drawer-panel flex items-stretch justify-center p-0 animate-fade-in sm:p-4 md:p-6",children:s.jsxs("div",{className:"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden bg-surface shadow-[0_28px_90px_var(--app-shadow-strong),0_14px_34px_var(--app-shadow-soft)] sm:max-h-[calc(100dvh-3rem)] sm:rounded-3xl sm:border sm:border-border/15",style:{paddingTop:n,paddingBottom:a},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/15 px-4 py-3 sm:px-6 sm:py-4",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary/15 text-primary sm:h-9 sm:w-9",children:s.jsx(zm,{size:15})}),s.jsx("h2",{id:"settings-dialog-title",className:"text-[15px] font-semibold text-foreground sm:text-[16px]",children:e("settings.title")})]}),s.jsx("button",{type:"button",onClick:Ri,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive","aria-label":e("common.close"),children:s.jsx(In,{size:16})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background/25 px-3 py-3 sm:px-6 sm:py-5 md:px-8",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>nt({fontSize:Math.max(8,_e-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:_e,onChange:_=>nt({fontSize:parseInt(_.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>nt({fontSize:Math.min(32,_e+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:[_e,"px"]})]}),s.jsx(_$,{}),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(_=>{const P=tr===_;return s.jsx("button",{type:"button",onClick:()=>nt({rendererMode:_}),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(_==="auto"?"settings.auto":_==="webgl"?"settings.webgl":"settings.canvas")},_)})})]})}),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",FT,e("settings.darkTheme")],["light",NS,e("settings.lightTheme")]].map(([_,P,de])=>{const tt=f===_;return s.jsxs("button",{type:"button",onClick:()=>m(_),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})]},_)})})]})}),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(_=>{const P=fn===_,de=_==="tmux"&&!Tr.available;return s.jsx("button",{type:"button",disabled:de,onClick:()=>Na(_,{userInitiated:!0}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":de?"cursor-not-allowed text-muted-foreground/40":"text-muted-foreground hover:bg-surface-elevated"}`,title:de?Tr.reason||e("settings.installTmuxHint"):void 0,children:e(_==="shell"?"settings.shell":"settings.tmux")},_)})})]}),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 _=!y;w(_);try{const P=await La({preventSleep:_});w(P.preventSleep),S(P.networkAvailable),pe(P.localAccess),Fn(Gd,{preventSleep:P.preventSleep,networkAvailable:P.networkAvailable,localAccess:P.localAccess})}catch{w(!_)}},className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${y?"bg-[rgb(var(--success-rgb)_/_0.15)] text-[color:var(--success)]":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:!v&&y?e("settings.noSleepUnavailable"):void 0,children:[s.jsx("span",{className:"font-medium truncate",children:e("settings.noSleep")}),s.jsx(ll,{checked:y,size:"sm"})]})]})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":Lr,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{ns(!Lr)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(cf,{size:14,className:Lr?"shrink-0 text-[color:var(--success)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.runningSessionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.runningSessionButtonHint")})]}),s.jsx(ll,{checked:Lr,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":Un,"aria-label":e("sidebar.attentionButton"),onClick:()=>{kn(!Un)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(cc,{size:14,className:Un?"shrink-0 text-[color:var(--warning)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.attentionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.attentionButtonHint")})]}),s.jsx(ll,{checked:Un,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>si(!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(Qy,{size:14,className:C?"shrink-0 text-primary":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("settings.notifications")}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e(C?R&&z?"settings.notificationsBothOnSummary":R?"settings.notificationsAiOnSummary":z?"settings.notificationsExitOnSummary":"settings.notificationsNoEventsSummary":"settings.notificationsOffSummary")})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e(C?"common.on":"common.off")}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>Bi(!0),className:"mt-3 flex w-full items-center justify-between gap-3 rounded-xl bg-surface-2 px-3 py-3 text-left transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block text-[12px] font-medium text-foreground/90",children:e("settings.localAccess")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.localAccessHint")})]}),s.jsx(Xs,{size:16,className:"shrink-0 text-muted-foreground"})]}),s.jsx(y$,{state:Ie,pending:ne,onCheck:()=>{xt()},onConfirmRestart:()=>{st()},desktopState:Ee?rt:void 0,desktopPending:ue,onCheckDesktop:Ee?()=>{Br()}:void 0,onInstallDesktop:()=>{Vr()},desktopSnapshot:oe,desktopActions:Pe?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-px border-t border-border/10 bg-border/10 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Pe.showConnectionCenter()},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(FA,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{Ne(null),Pe.revealDataDirectory().catch(_=>Ne(_ instanceof Error?_.message:String(_)))},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(Du,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),at&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:at})]}):void 0}),s.jsx(w$,{backendSessionId:_t?ir.get(_t)?.terminalSessionId??null:null}),s.jsx(T$,{state:Le,onDismiss:()=>{De()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Di(null),ja({mode:"shell"}),Ri()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Fl?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:e(ji==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(zs,{size:14,className:Fl?"shrink-0":"hidden"}),s.jsx($o,{size:12}),s.jsx("span",{className:Fl?"whitespace-nowrap":"hidden",children:e(ji==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Tr.available,onClick:()=>{Tr.available&&(Di(null),ja({mode:"tmux"}),Ri())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Tr.available?au?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"flex-1 bg-surface-2/50 text-muted-foreground/50 cursor-not-allowed"}`,title:Tr.available?e(ji==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Tr.reason||e("settings.installTmuxHint"),children:[s.jsx(zs,{size:14,className:au?"shrink-0":"hidden"}),s.jsx(qc,{size:12}),s.jsx("span",{className:au?"whitespace-nowrap":"hidden",children:e(ji==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Tr.available||Mr.length>0)&&s.jsxs("details",{className:"mt-3 group rounded-xl bg-surface-2 [&[open]]:bg-surface-2",children:[s.jsxs("summary",{className:"flex cursor-pointer items-center justify-between rounded-xl px-3 py-2.5 text-[13px] hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-flex h-2 w-2 rounded-full ${Tr.available?"bg-primary":"bg-destructive"}`}),s.jsx("span",{className:"font-medium",children:e("settings.tmuxServer")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Tr.available?e("settings.sessions",{n:Mr.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:_=>{_.preventDefault(),Vo()},disabled:ln,className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":e("settings.refresh"),children:s.jsx(bn,{size:12,className:ln?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Tr.available?Mr.length===0?s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:e("settings.noTmuxSessions")}):s.jsxs("div",{className:"space-y-2",children:[xl.map(_=>s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1.5 py-1 text-[10px] text-muted-foreground",children:[s.jsx(Vc,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"shrink-0 font-medium text-foreground/75",children:_.label}),s.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:e("settings.sessions",{n:_.sessions.length})}),_.key&&s.jsx("span",{className:"min-w-0 truncate text-muted-foreground/60",children:_.key})]}),_.sessions.map(P=>{const de=P.boundFrontendSessionId??null,tt=!!(P.connected||de),St=de?vt.find(Qi=>Qi.id===de)??null:null,Yt=P.friendlyName?.trim()||null,Nr=P.label&&P.label!==P.name?P.label:null,An=Yt||Nr||P.name,Nn=Yt||Nr?`tmux:${P.name}`:null,Ln=P.clientCount&&P.clientCount>0?t==="zh"?`网页连接 ${P.clientCount}`:`Web clients ${P.clientCount}`:null,Ai=P.attached>0?t==="zh"?`原生 tmux ${P.attached}`:`Native tmux ${P.attached}`:null,Tn=[Nn,tt?P.restorable?e("settings.restorable"):e("settings.attached"):null,Ln,Ai].filter(Qi=>!!Qi),Xi=[e("settings.windows",{n:P.windows}),P.createdAt?new Date(P.createdAt).toLocaleDateString():null].filter(Qi=>!!Qi),Io=ks===P.name,Eo=en===P.name,Ba=Rt===P.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${Io?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(qc,{size:13,className: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:An}),P.friendlyName&&s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:t==="zh"?"自定义":"custom"})]}),Tn.length>0&&s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:Tn.map(Qi=>s.jsx("span",{className:"max-w-full truncate",children:Qi},Qi))}),(P.program||P.cwd)&&s.jsxs("div",{className:"grid min-w-0 gap-0.5 text-[10px] text-muted-foreground",children:[P.program&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(AT,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate text-foreground/75",children:P.program})]}),P.cwd&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(Vc,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:P.cwd})]})]}),s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/80",children:Xi.map(Qi=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rT,{size:10,className:"shrink-0 text-muted-foreground/60"}),Qi]},Qi))})]}),Io?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{su(P.name)},className:"shrink-0 rounded-full bg-destructive/90 px-2.5 py-1 text-[11px] font-medium text-destructive-foreground transition hover:bg-destructive disabled:opacity-50",children:Eo?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{Dr(null),ze(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:()=>{St?F0(St.id):(Et(P.name),ja({mode:"tmux",tmuxSessionName:P.name}))},disabled:Ba,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${tt?"bg-surface text-foreground hover:bg-surface-elevated":Ba?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:Ba?s.jsxs(s.Fragment,{children:[s.jsx(_n,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(tt?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:Eo,onClick:()=>{ze(null),Dr(P.name)},className:"shrink-0 inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":`Kill tmux session ${P.name}`,children:s.jsx(Ms,{size:12})})]})]},P.name)})]},_.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:Tr.reason||e("settings.installTmuxHint")})})]}),s.jsxs("button",{type:"button",onClick:()=>ws(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Fy,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.keyboardToolbar")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e("settings.sessions",{n:As.length})}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>cs(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(N0,{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(_=>{const P=t===_.code;return s.jsx("button",{type:"button",onClick:()=>r(_.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:_.label},_.code)})})]}),s.jsxs("button",{type:"button",onClick:async()=>{try{await aA()}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(Gy,{size:14}),e("settings.signOut")]})]})]})})]}),to&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm cursor-default animate-fade-in",onClick:()=>{$e(null),it(null),ze(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 ${et&&Xt?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:et&&Xt?{...py(et),paddingBottom:a}:{paddingBottom:a},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.closeChooserTitle")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:W0}),s.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground/80",children:e("tab.closeChooserDescription")})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:id,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(Ms,{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:()=>{$e(null),it(null),ze(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 _=vt.find(Ln=>Ln.id===cr);if(!_)return null;const P=ir.get(_.id),{primary:de}=il(_,P?.activeProgram??null,P?.cwd??null,_a),tt=Xt,St=tt?py(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%]",Nr=tt?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",An=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",Nn=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:Qt,"aria-label":"Close menu"}),s.jsxs("div",{className:Yt,style:St,children:[s.jsxs("div",{className:Nr,children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:de}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/80",children:P.cwd})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{const Ln=Ls;Qt(),_r(Ln),jr(_.id)},className:`${An} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Nn} bg-primary/15 text-primary`,children:s.jsx(nS,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.rename")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.renameHint")})]})]}),s.jsxs("button",{type:"button",disabled:!P?.cwd,onClick:()=>{lp(_.id),Qt()},className:`${An} ${P?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${Nn} bg-surface-2 text-muted-foreground`,children:s.jsx($y,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.copyCwd")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.copyCwdHint")})]}),Or&&Or===P?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const Ln=$m(_.id),Ai=Ln??_e;return s.jsxs("div",{className:`${An} text-foreground`,children:[s.jsx("span",{className:`${Nn} bg-surface-2 text-muted-foreground`,children:s.jsx(jS,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.fontSize")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.fontSizeHint")})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>{Ph(_.id,Ai-1),cn(Tn=>Tn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} -1`,children:"−"}),s.jsxs("span",{className:"w-8 text-center text-[11px] tabular-nums text-muted-foreground",children:[Ai,"px"]}),s.jsx("button",{type:"button",onClick:()=>{Ph(_.id,Ai+1),cn(Tn=>Tn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} +1`,children:"+"}),Ln!==null&&s.jsx("button",{type:"button",onClick:()=>{Ph(_.id,null),cn(Tn=>Tn+1)},className:"ml-1 shrink-0 rounded-md px-1.5 py-1 text-[11px] text-primary transition hover:bg-primary/10",children:e("tab.fontSizeReset")})]})]})})(),P?.agentNativeSessionId&&P.agentStatus!=="working"&&P.agentStatus!=="waiting"&&P.terminalSessionId&&s.jsxs("button",{type:"button",onClick:()=>{const Ln=P.terminalSessionId;Ln&&(Qt(),Xr(_.id,Ln))},className:`${An} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Nn} bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)]`,children:s.jsx(Qc,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block font-medium",children:[e("tab.resumeAgent"),P.agent?.displayName?` · ${P.agent.displayName}`:""]}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.resumeAgentHint")})]})]}),s.jsx("div",{className:"my-1 border-t border-border/15"}),_.mode==="tmux"?s.jsxs("button",{type:"button",onClick:()=>{Qt(),Ol(_.id)},className:`${An} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Nn} bg-destructive/15 text-destructive`,children:s.jsx(Ms,{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:()=>{Qt(),gc({sessionId:_.id,source:"tab-menu",closeMode:"auto"})},className:`${An} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Nn} bg-destructive/15 text-destructive`,children:s.jsx(In,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.close")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.closeHint")})]})]}),!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:()=>{Qt()},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:Qt,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")})})]})]})})(),rr&&dn&&Xt&&(()=>{const _=vt.find(Tn=>Tn.id===rr);if(!_)return null;const P=ir.get(_.id),{primary:de}=il(_,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null),tt=_.customName?_.name:de,St=Tn=>{const Xi=Tn.trim();Xi?Xi!==tt&&Vi(_.id,Xi):qi(_.id),jr(null),_r(null)},Yt=300,Nr=160,An=dn.x,Nn=dn.y,Ln=Math.min(Math.max(An-Yt/2,12),window.innerWidth-Yt-12),Ai=Nn+Nr+20>window.innerHeight?Math.max(Nn-Nr-12,12):Nn+12;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-transparent",onClick:()=>{jr(null),_r(null)},"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed z-menu-panel w-[300px] rounded-xl bg-surface-elevated border border-border/15 shadow-[0_12px_36px_var(--app-shadow-soft)] animate-fade-in",style:{left:`${Ln}px`,top:`${Ai}px`},children:[s.jsxs("div",{className:"border-b border-border/15 px-3 py-2.5",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.rename")}),s.jsx("div",{className:"mt-0.5 truncate text-[13px] font-medium text-foreground",children:de}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",children:P.cwd})]}),s.jsxs("form",{className:"px-3 py-2.5",onSubmit:Tn=>{Tn.preventDefault();const Xi=new FormData(Tn.currentTarget).get("session-name");St(typeof Xi=="string"?Xi:"")},children:[s.jsx("input",{ref:Tn=>{Ct.current=Tn,Tn&&!Lt.current&&(Lt.current=!0,Tn.focus({preventScroll:!0}),Tn.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:Tn=>{Tn.key==="Escape"&&(Tn.stopPropagation(),jr(null),_r(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{jr(null),_r(null)},className:"flex-1 rounded-full bg-surface-2 px-3 py-1.5 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary px-3 py-1.5 text-[12px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.97]",children:e("common.save")})]})]})]})]})})(),rr&&!Xt&&(()=>{const _=vt.find(Yt=>Yt.id===rr);if(!_)return null;const P=ir.get(_.id),{primary:de}=il(_,P?.activeProgram??null,P?.cwd??null,_a,P?.shellTitle??null,P?.promptState??null),tt=_.customName?_.name:de,St=Yt=>{const Nr=Yt.trim();Nr?Nr!==tt&&Vi(_.id,Nr):qi(_.id),jr(null)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>jr(null),"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed inset-x-3 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",style:{top:`calc(${n} + 3.5rem)`},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 text-[14px] font-medium text-foreground",children:e("tab.rename")})]}),s.jsxs("form",{className:"px-4 py-3",onSubmit:Yt=>{Yt.preventDefault();const Nr=new FormData(Yt.currentTarget).get("session-name");St(typeof Nr=="string"?Nr:"")},children:[s.jsx("input",{ref:Yt=>{Ct.current=Yt,Yt&&!Lt.current&&(Lt.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(),jr(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>jr(null),className:"flex-1 rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary/20 px-3 py-2 text-[12px] font-medium text-primary transition hover:bg-primary/30",children:e("common.save")})]})]})]})]})})(),Gs&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":e("common.close"),className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Bi(!1)}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"local-access-title",className:"fixed inset-x-3 top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 p-4",children:[s.jsx("h2",{id:"local-access-title",className:"section-title",children:e("settings.localAccess")}),s.jsx("button",{autoFocus:!0,type:"button","aria-label":e("common.close"),onClick:()=>Bi(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(In,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(lC,{state:be,onCopy:_=>{ml(_,"setup")},copied:Ae==="setup"}),s.jsxs("div",{className:"mt-3 flex items-center overflow-hidden rounded-lg bg-surface ring-1 ring-border/10 focus-within:ring-primary/40",children:[s.jsx("input",{value:ee,onChange:_=>ke(_.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:He,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(He?"settings.saving":"common.save")}),s.jsx("button",{type:"button",disabled:He,onClick:()=>{Ea()},className:"rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-50",children:e("settings.resetAutoName")})]}),s.jsxs("div",{className:"mt-3 space-y-1.5 text-[11px]",children:[be.url&&s.jsxs("button",{type:"button",onClick:()=>{ml(be.url,"lan")},className:"flex w-full items-center justify-between gap-2 rounded-lg bg-surface px-2.5 py-2 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"min-w-0 truncate",children:["Branded: ",be.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:Ae==="lan"?"Copied":e("common.copy")})]}),be.interfaces.length>0&&s.jsxs("details",{className:"rounded-lg bg-surface px-2.5 py-2 text-muted-foreground",open:!1,children:[s.jsx("summary",{className:"cursor-pointer text-[11px] font-medium text-foreground/80",children:"IP fallback addresses"}),s.jsx("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:be.interfaces.map(_=>{const P=_.url??`${be.httpsEnabled?"https":"http"}://${_.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:[_.label," (",_.name,")"]}),s.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:_.address}),_.qrDataUrl&&s.jsx("div",{className:"mt-2 inline-block rounded-lg bg-[var(--background)] p-1.5",children:s.jsx("img",{src:_.qrDataUrl,alt:`QR code for ${P}`,className:"h-28 w-28"})}),s.jsxs("button",{type:"button",onClick:()=>{ml(P,`ip-${_.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:Ae===`ip-${_.address}`?"Copied":e("common.copy")})]})]},`${_.name}-${_.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[be.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!be.caAvailable&&` · ${e("settings.caMissing")}`]}),be.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:be.reason}),ce&&s.jsx("div",{className:"text-destructive",children:ce})]})]})]})]}),Ra&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>si(!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:()=>si(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close notifications settings",children:s.jsx(In,{size:18})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:e("settings.notificationsPageHint")}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsMaster")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:Y==="denied"?e("settings.notificationsDenied"):rh()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),rh()&&!oA()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{$r()},disabled:!rh()||Y==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":C,children:s.jsx(ll,{checked:C,disabled:!rh()||Y==="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 ${Y==="granted"?"bg-primary/15 text-primary":"bg-surface text-muted-foreground"}`,children:[e("settings.notificationsPermission"),": ",vo()?e("settings.notificationsPermissionSystem"):Y]}),s.jsx("button",{type:"button",disabled:!C||Y!=="granted"||ys==="checking",onClick:()=>{nn()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:e(ys==="checking"?"settings.notificationsTestChecking":"settings.notificationsTest")}),vo()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{vo()?.openNotificationSettings?.()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:e("settings.notificationsOpenSystemSettings")})]}),ys!=="idle"&&ys!=="checking"&&s.jsx("div",{className:`mt-2 text-[11px] leading-relaxed ${ys==="delivered"?"text-primary":"text-[var(--warning)]"}`,children:e(ys==="delivered"?"settings.notificationsTestDelivered":"settings.notificationsTestFailed")})]}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAlertStyle")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAlertStyleHint")}),s.jsx("div",{className:"mt-3 grid grid-cols-3 gap-1 rounded-xl bg-surface p-1",children:[["normal",e("settings.notificationsStyleNormal"),e("settings.notificationsStyleNormalHint")],["quiet",e("settings.notificationsStyleQuiet"),e("settings.notificationsStyleQuietHint")],["persistent",e("settings.notificationsStylePersistent"),e("settings.notificationsStylePersistentHint")]].map(([_,P,de])=>{const tt=$===_;return s.jsxs("button",{type:"button",disabled:!C,onClick:()=>wn(_),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${tt&&C?"bg-primary/15 text-primary":C?"text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"cursor-not-allowed text-muted-foreground/40"}`,title: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})]},_)})})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notificationsEvents")}),s.jsxs("div",{className:"mt-2 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAiFinished")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAiFinishedHint")})]}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>Pn(!R),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":R&&C,children:s.jsx(ll,{checked:R&&C,disabled:!C})})]}),s.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-border/10 pt-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsSessionExited")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsSessionExitedHint")})]}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>yr(!z),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":z&&C,children:s.jsx(ll,{checked:z&&C,disabled:!C})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),ni&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>ws(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.mobileKeyboard")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.toolbarPresets")})]}),s.jsx("button",{type:"button",onClick:()=>ws(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close toolbar presets",children:s.jsx(In,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(g$,{presets:As,selectedPresetId:Co,onSelectPreset:xa,onUpdatePreset:(_,P)=>{Ja(de=>Ru(de.map(tt=>tt.id===_?P(tt):tt)))},onAddPreset:()=>{const _=`preset-${Date.now()}`;Ja(P=>Ru([...P,{id:_,label:`Preset ${P.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),xa(_)},onRemovePreset:_=>{Ja(P=>Ru(P.filter(de=>de.id!==_)))},onResetDefaults:()=>{Ja(v0()),xa("default")}})})]})]}),ba&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>cs(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.aiAgentDetection")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.detectionRules")})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{type:"button",onClick:()=>cs(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close agent rules",children:s.jsx(In,{size:18})})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:e("settings.agentHooksHint")}),s.jsx(b$,{}),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:vt.map(_=>{const P=ir.get(_.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:_.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-${_.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:_,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[_].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 St={...Xe,[_]:Xe[_].filter(Yt=>Yt!==tt)};dt(St),_==="shellNames"&&(_a=new Set(St.shellNames)),px(St).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 St=tt.target.value.trim().toLowerCase();if(!St||Xe[_].includes(St))return;const Yt={...Xe,[_]:[...Xe[_],St]};dt(Yt),_==="shellNames"&&(_a=new Set(Yt.shellNames)),tt.target.value="",px(Yt).catch(()=>{})}})]})]},_)),s.jsx("button",{type:"button",onClick:()=>{lA().then(_=>{dt(_),_a=new Set(_.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((_,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:_.enabled!==!1,onChange:de=>{const tt=se.map((St,Yt)=>Yt===P?{...St,enabled:de.target.checked}:St);T(tt),Fn(Ca,tt),xe(!0),uu(tt).then(St=>{T(St),Fn(Ca,St)}).catch(()=>{}).finally(()=>xe(!1))}}),s.jsxs("select",{value:_.matchType,onChange:de=>{const tt=se.map((St,Yt)=>Yt===P?{...St,matchType:de.target.value}:St);T(tt),Fn(Ca,tt),xe(!0),uu(tt).then(St=>{T(St),Fn(Ca,St)}).catch(()=>{}).finally(()=>xe(!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:_.pattern,onChange:de=>{const tt=se.map((St,Yt)=>Yt===P?{...St,pattern:de.target.value}:St);T(tt),Fn(Ca,tt)},onBlur:()=>{xe(!0),uu(se).then(de=>{T(de),Fn(Ca,de)}).catch(()=>{}).finally(()=>xe(!1))},placeholder:"pattern",className:"min-w-[180px] flex-1 rounded bg-surface px-2 py-1 text-[11px] font-mono"}),s.jsx("input",{value:_.output,onChange:de=>{const tt=se.map((St,Yt)=>Yt===P?{...St,output:de.target.value}:St);T(tt),Fn(Ca,tt)},onBlur:()=>{xe(!0),uu(se).then(de=>{T(de),Fn(Ca,de)}).catch(()=>{}).finally(()=>xe(!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,St)=>St!==P);T(de),Fn(Ca,de),xe(!0),uu(de).then(tt=>{T(tt),Fn(Ca,tt)}).catch(()=>{}).finally(()=>xe(!1))},className:"rounded bg-surface px-2 py-1 text-[11px] text-muted-foreground hover:text-destructive",children:e("common.delete")})]})},_.id)),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{const _=[...se,{id:`rule-${Date.now()}`,enabled:!0,priority:100,matchType:"includes",pattern:"",output:""}];T(_),Fn(Ca,_),xe(!0),uu(_).then(P=>{T(P),Fn(Ca,P)}).catch(()=>{}).finally(()=>xe(!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:()=>{xe(!0),cA().then(_=>{T(_),Fn(Ca,_)}).catch(()=>{}).finally(()=>xe(!1))},className:"rounded-full bg-surface-2 px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:F?e("settings.saving"):j?`${se.length} rules`:"…"})]})]})]})]})]})]}),Go&&s.jsx(u$,{isOpen:Go,onClose:()=>Zi(!1)}),!va&&s.jsx(Ob,{isOpen:Cr,drawerWidthPx:hr,onClose:()=>Hn("left-sidebar"),onOpen:fa,sessions:vt,activeSessionId:_t,sessionStates:ir,onNewSession:_=>ja(_),recoverableTmuxSessions:ad,recoverableTmuxSessionsLoading:ln,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Ol,onSplitSession:iu,onCloseSplit:_=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:_})),onRemoveFromSplit:_=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:_})),splitWorkspaces:ot,onSetSplitLayout:sd,onReorderSplitWorkspace:U0,onRenameSplitWorkspace:z0,onCombineSplitSessions:H0,onReorderSessions:es,onSessionMenu:wi,onOpenSettings:Ds,onJumpToNextAttention:ya.length>0?Pl:void 0,onOpenQuota:()=>Zi(!0),updateState:Ie,updateActionPending:ne,onConfirmUpdateRestart:st,onRetryUpdate:xt,serverHealthState:Le,tmuxAvailable:Tr.available,defaultSessionMode:fn,onTogglePinned:Xt?qa:void 0}),!$l&&s.jsx(Fb,{isOpen:qr,sessionId:_t,drawerWidthPx:zn,onClose:()=>Hn("right-sidebar"),onOpen:ms,rightSidebarFilePreviewOpen:Bn,rightSidebarFilePreviewCloseSignal:ye,onOpenRightSidebarFilePreview:bi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Vt,onOpenRightSidebarRepoPicker:ri,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:mt,markdownOutlineCloseSignal:Ht,onOpenMarkdownOutline:ma,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:Ot,markdownImageLightboxCloseSignal:me,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:ls,onTogglePinned:Xt?ti:void 0}),Ge&&!c&&s.jsx("button",{type:"button",onClick:Dl,className:"fixed inset-0 z-toast flex cursor-default items-center justify-center bg-[var(--app-backdrop-soft)] px-6 text-left backdrop-blur-[1px]","aria-label":t==="zh"?"继续使用 Termdock":"Continue using Termdock",children:s.jsxs("div",{className:"max-w-[18rem] rounded-2xl border border-border/15 bg-surface/95 px-5 py-4 text-center shadow-[0_18px_50px_var(--app-shadow-strong)] backdrop-blur animate-fade-in",children:[s.jsx("div",{className:"text-[14px] font-semibold text-foreground",children:t==="zh"?"建议使用 Home":"Use Home instead"}),s.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:t==="zh"?"按 Home 退后台,点任意位置继续。":"Use Home to leave. Tap anywhere to continue."}),s.jsx("div",{className:"mt-3 text-[11px] font-medium text-muted-foreground/80",children:t==="zh"?"轻点关闭提示":"Tap to dismiss"})]})}),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(lf,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:ge.message}),s.jsx("button",{type:"button",onClick:()=>Gr(null),className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("common.close"),children:s.jsx(In,{size:12})})]}),l&&s.jsxs(s.Fragment,{children:[!Xt&&s.jsx(cC,{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(Tt,null,2)})]})]})]}),Hl=qt?null:s.jsx(hA,{className:"z-modal-panel",status:"正在恢复终端…"});return Xt?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[va&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:on,flexShrink:0,height:"100%"},children:s.jsx(Ob,{isOpen:Cr,drawerWidthPx:on,onClose:ei,onOpen:fa,sessions:vt,activeSessionId:_t,sessionStates:ir,onNewSession:_=>ja(_),recoverableTmuxSessions:ad,recoverableTmuxSessionsLoading:ln,onRefreshRecoverableTmuxSessions:()=>{Vo()},onCloseRecoverableTmuxSession:mc,onCloseSession:Ol,onSplitSession:iu,onCloseSplit:_=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:_})),onRemoveFromSplit:_=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:_})),splitWorkspaces:ot,onSetSplitLayout:sd,onReorderSplitWorkspace:U0,onRenameSplitWorkspace:z0,onCombineSplitSessions:H0,onReorderSessions:es,onSessionMenu:wi,onOpenSettings:Ds,onJumpToNextAttention:ya.length>0?Pl:void 0,onOpenQuota:()=>Zi(!0),updateState:Ie,updateActionPending:ne,onConfirmUpdateRestart:st,onRetryUpdate:xt,serverHealthState:Le,tmuxAvailable:Tr.available,defaultSessionMode:fn,pinned:!0,onTogglePinned:qa})}),s.jsx("div",{role:"separator",tabIndex:-1,className:"shrink-0 w-[5px] h-full cursor-col-resize bg-border/10 hover:bg-primary/30 active:bg-primary/50 transition-colors",onMouseDown:dl})]}),s.jsxs("div",{className:"relative flex-1 min-w-0 h-full overflow-hidden",children:[zl,$l&&s.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex",style:{width:yc},children:[s.jsx("div",{role:"separator",tabIndex:-1,className:"h-full w-[5px] shrink-0 cursor-col-resize bg-border/10 transition-colors hover:bg-primary/30 active:bg-primary/50",onMouseDown:Hi}),s.jsx("div",{style:{width:ld,flexShrink:0,height:"100%"},children:s.jsx(Fb,{isOpen:!0,sessionId:_t,drawerWidthPx:ld,onClose:Hs,onOpen:ms,pinned:!0,onTogglePinned:ti,rightSidebarFilePreviewOpen:Bn,rightSidebarFilePreviewCloseSignal:ye,onOpenRightSidebarFilePreview:bi,onCloseRightSidebarFilePreview:hl,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Vt,onOpenRightSidebarRepoPicker:ri,onCloseRightSidebarRepoPicker:Uo,markdownOutlineOpen:mt,markdownOutlineCloseSignal:Ht,onOpenMarkdownOutline:ma,onCloseMarkdownOutline:fl,markdownImageLightboxOpen:Ot,markdownImageLightboxCloseSignal:me,onOpenMarkdownImageLightbox:pl,onCloseMarkdownImageLightbox:ls})})]})]}),s.jsx(ty,{sessionId:_t}),Hl]}):s.jsxs(s.Fragment,{children:[zl,s.jsx(ty,{sessionId:_t}),Hl]})}const OU=Object.freeze(Object.defineProperty({__proto__:null,default:W$},Symbol.toStringTag,{value:"Module"}));export{tU as $,e0 as A,x0 as B,uF as C,XS as D,cf as E,Oy as F,dF as G,Qc as H,Hy as I,gS as J,Fy as K,$y as L,RT as M,HT as N,n0 as O,qT as P,B6 as Q,bn as R,jl as S,zm as T,NS as U,II as V,Ms as W,Gy as X,US as Y,nh as Z,rC as _,JS as a,J$ as a0,Jy as a1,nU as a2,sU as a3,rU as a4,iv as a5,QU as a6,U2 as a7,u1 as a8,Hf as a9,Kb as aa,Xy as ab,$h as ac,z1 as ad,pC as ae,WO as af,eU as ag,z2 as ah,eN as ai,$b as aj,Dm as ak,Ei as al,PU as am,i3 as an,df as b,t$ as c,OU as d,tC as e,Dy as f,MA as g,NA as h,By as i,Py as j,p0 as k,PO as l,oT as m,m0 as n,fO as o,Du as p,U1 as q,CT as r,BT as s,Uy as t,FT as u,zy as v,tS as w,nS as x,iS as y,g0 as z};
|