@ensocode/server 0.3.14 → 0.3.15-beta.236
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/README.md +11 -1
- package/out/phone/assets/{EditDiff-7At9BpWJ.js → EditDiff-DPrGvGAU.js} +1 -1
- package/out/phone/assets/{ReadFileView-CFkjh0Xx.js → ReadFileView-s4kjqMan.js} +1 -1
- package/out/phone/assets/{abnfDiagram-VCTEODGH-D4384sfe.js → abnfDiagram-VCTEODGH-BbG8PpJN.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-DroUMTKc.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-CjzMXFHb.js → architectureDiagram-5GKGNRK7-DnxOyC6a.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-COX4_2NT.js → blockDiagram-I7D4REHJ-B5s7XAHT.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-C0PHCrzg.js → c4Diagram-7LVT6UL2-DixPhQ_p.js} +1 -1
- package/out/phone/assets/channel-BF88Uwu2.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-BSqiGn28.js → chunk-4HAMMTFA-ClCSp7Xk.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-7eocu_Pa.js → chunk-75Z2AOVW-QvFknKGi.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-DMttOQUE.js → chunk-DU6HZSFF-CeYtDBPs.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-BFNRrOvq.js → chunk-F27PBJKO-BnR5_CAQ.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW-DPVV1Shj.js → chunk-GMAD6QVW-SLRPQ8AI.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-YataTcA_.js → chunk-GVQU2GXP-BiPH1vVN.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-DBQKd74U.js → chunk-IMKFNOWR-DHtYLC41.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-DXfrfXkv.js → chunk-L3NEJ4N5-2hf9zWlv.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-DWr7pP6Q.js → chunk-OSK3NFVY-BDSQEHdr.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-C_qNKS0g.js → chunk-P2QGCYS3-KWTrRS1P.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-BhJK3UtM.js → chunk-POPQ4Y6H-DjbY6mYy.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-MmcwGVgC.js → chunk-PWAF6VOD-CV-3dG-I.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BQHA3p2Q.js → chunk-SHT3W25Y-CAuUqICh.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-DbQH56Ci.js → chunk-SVP7TREG-CLX8NrQn.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-pixKba1z.js → chunk-TICWLB2K-CxmZOcaM.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-VmTmyVMD.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-VmTmyVMD.js +1 -0
- package/out/phone/assets/{codeHighlighter-CrZcFhK_.js → codeHighlighter-Dd1boUw8.js} +1 -1
- package/out/phone/assets/{cynefin-OW5HDTMX-67ETi-0P.js → cynefin-OW5HDTMX-D7J6hO8o.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-C3wqlm_-.js → cynefinDiagram-5FMLGOSQ-54NONNDT.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-DTC1fZsc.js → dagre-GXQ25YYZ-z_jqgr0R.js} +1 -1
- package/out/phone/assets/desk-DnE_YcZf.js +70 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-uqcU7OpS.js → diagram-S7CK7UJ4-BGOTpV8e.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-BQ6K9f6g.js → diagram-UQ7AKVKN-BDuxJ6Pi.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-CDzRWkI9.js → diagram-VSXAHHWV-BZfIBI0n.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-CvI10CG1.js → diagram-VX7I27RA-D7XcWAj9.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-DM8G_CIZ.js → diagram-Z3DM3KII-BnKcajkr.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-BBbLoaIE.js → ebnfDiagram-PWID7BFC-BycKMCHF.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-Dz98FGLq.js → erDiagram-RLTQ6QDP-Cz0JIM68.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-D5llMeQ5.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-CkQ2of0C.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-BADRjlHl.js → ganttDiagram-EL5Y4UJY-BQMB-70Y.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-DQGKRsA2.js → gitGraph-4MIJSDKK-ChNDb-oT.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-DrLRujhH.js → gitGraphDiagram-WWUBYQGX-1jVNY0Pd.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-b7IbwKqs.js → info-A6RAGUB7-BFyIuYXR.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-BNbXaMmR.js → infoDiagram-27XIBGKW-Bkixk8KZ.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-B3SG131F.js → ishikawaDiagram-5VMMS53U-DDo4d686.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-BoRfNykb.js → journeyDiagram-3NMN7TZE-CMIpH7AF.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-D0tKrJ8_.js → kanban-definition-UXKFOSKX-DCrzCNHL.js} +1 -1
- package/out/phone/assets/{line-W1HWn4B7.js → line-Owcld2hO.js} +1 -1
- package/out/phone/assets/main-Bk2Gcz5l.css +2 -0
- package/out/phone/assets/main-DtnpLJjx.js +277 -0
- package/out/phone/assets/{mermaid-parser.core-CpGE7UgS.js → mermaid-parser.core-DCnmw5kY.js} +3 -3
- package/out/phone/assets/{mermaid.core-wueTI3u_.js → mermaid.core-CL48hMfG.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-BDctzErY.js → mindmap-definition-YA3MSWOX-D9Vm9oAs.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-C0YWsXol.js → packet-AYTQ26CC-0_3hoxAg.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-C97XjNI7.js → pegDiagram-XKGWAZYB-CaTsidSZ.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-BxuJ1GKP.js → pie-WAS4IAKB-CZGajbj1.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-SP4DeWDw.js → pieDiagram-E7YTZNPT-CSaGEUBU.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-DDHL4rrG.js → quadrantDiagram-AXDQQJYC-ZrxLtEGP.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-AzVB8zoH.js → radar-RG4KPBEZ-DJS9j7IU.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-CA2_A72l.js → railroad-74A4TZTK-BhE1CVxj.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-Dtu3vS3c.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-DruUmiMw.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-DmK0BjdF.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-D5zpQ5kq.js → railroadDiagram-O6MQD6OU-jZFf0rRp.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-DkQKt5hJ.js → requirementDiagram-BXWQKSXE-BesfzmXy.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-xeXrVMVr.js → sankeyDiagram-P5KCCOFB-Cv065AkB.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BOiNtyS8.js → sequenceDiagram-WJ2MYXX4-USwT-H0A.js} +1 -1
- package/out/phone/assets/shellUpdate-Bz93QVRZ.js +5 -0
- package/out/phone/assets/{stateDiagram-D77RDMKH-Bs8LX9-n.js → stateDiagram-D77RDMKH-DHejOw4C.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-CSeiPhWU.js +1 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-DQVYfgSI.js → swimlanes-42K2YHIH-CQPL8t9s.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BZvdvCoE.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-BlpgdxeN.js → timeline-definition-24CTP7MA-Bz-Yw2Ha.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-D0PiggHr.js → treeView-Q6P3EWNA-FT_AXPvw.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-DA07Kvo0.js → treemap-WGGIJYW6-GvrJTu-Y.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-BtvfF1a4.js → vennDiagram-4TSXK5OY-bTmZFq-k.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-Db-UrSZJ.js → wardley-WFR3VGLG-DxZxBwnT.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-CaBnqFYM.js → wardleyDiagram-VM6X3IG4-t5MwTl6Q.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-Bbzz9YwS.js → xychartDiagram-S5SC5T6Z-o-QLA07Y.js} +1 -1
- package/out/phone/desk.html +3 -3
- package/out/phone/index.html +4 -4
- package/out/phone/sw.js +2 -2
- package/out/renderer/assets/EditDiff-C4s3bU-R.js +1 -0
- package/out/renderer/assets/ReadFileView-cJEX2HPH.js +4 -0
- package/out/renderer/assets/SidePanel-DimtLT8Q.js +48 -0
- package/out/renderer/assets/abnfDiagram-VCTEODGH-DKvQLNxl.js +1 -0
- package/out/renderer/assets/{arc-DXzwxP4j.js → arc-COwxE35C.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-Bcykp-Fb.js → architectureDiagram-5GKGNRK7-CXxYVQ-x.js} +2 -2
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-P7zMiiL3.js → blockDiagram-I7D4REHJ-CMvFU-xh.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-BVD9zEE8.js → c4Diagram-7LVT6UL2-DqkIurG4.js} +1 -1
- package/out/renderer/assets/channel-CFaWfxDZ.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-BXj05DaP.js → chunk-2Q5K7J3B-BvJ68CJ9.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-D-SpodcG.js → chunk-5VM5RSS4-pQq3Ri2E.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-ORLEQ9sv.js → chunk-F27PBJKO-4eAk8-1c.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-1lhHjr20.js → chunk-IMKFNOWR-CORuLEem.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-BgmlC9Vl.js → chunk-JWPE2WC7-Co1JP8hE.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-DPEfkZnH.js → chunk-POPQ4Y6H-BG_gUWlb.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-7_S5Geoi.js → chunk-SVP7TREG-D_azldtp.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-BKi8yvLf.js → chunk-TICWLB2K-DBNgcUM3.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-PfB25f1D.js → chunk-XXDRQBXY-BpFx2_oS.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-BIvTaGhI.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BIvTaGhI.js +1 -0
- package/out/renderer/assets/cose-bilkent-JH36ORCC-cbzVUH5i.js +1 -0
- package/out/renderer/assets/{cynefin-OW5HDTMX-Dr9W26Pe.js → cynefin-OW5HDTMX-DdGVKXpD.js} +1 -1
- package/out/renderer/assets/cynefinDiagram-5FMLGOSQ-CoXvoyv7.js +62 -0
- package/out/renderer/assets/{dagre-GXQ25YYZ-Dt2pulYx.js → dagre-GXQ25YYZ-DPj7Fszf.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-Bx-0FuVR.js → diagram-S7CK7UJ4-CEBiLgR8.js} +1 -1
- package/out/renderer/assets/diagram-UQ7AKVKN-CO-GLoBI.js +41 -0
- package/out/renderer/assets/{diagram-VSXAHHWV-CI0jUOHM.js → diagram-VSXAHHWV-MII5LBuz.js} +1 -1
- package/out/renderer/assets/diagram-VX7I27RA-C6vVEfMX.js +24 -0
- package/out/renderer/assets/diagram-Z3DM3KII-BYQcJvzV.js +24 -0
- package/out/renderer/assets/ebnfDiagram-PWID7BFC-DqjynLKg.js +1 -0
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-UjxTTQ7M.js → erDiagram-RLTQ6QDP-C3EnWx_s.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-BVuwOxKp.js → flowDiagram-HODETNUW-CaR5_paJ.js} +1 -1
- package/out/renderer/assets/ganttDiagram-EL5Y4UJY-DOrZ_6co.js +292 -0
- package/out/renderer/assets/gitGraphDiagram-WWUBYQGX-BnQuPD29.js +106 -0
- package/out/renderer/assets/index-BCmk6x7B.js +3003 -0
- package/out/renderer/assets/index-CtOLwaEJ.css +1 -0
- package/out/renderer/assets/infoDiagram-27XIBGKW-MZQIidAo.js +2 -0
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-B2YfGNEH.js → ishikawaDiagram-5VMMS53U-8Ns166qG.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-fUfanA7T.js → journeyDiagram-3NMN7TZE-BZRcR7NU.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-DU0d3NVH.js → kanban-definition-UXKFOSKX-BL8MeZ8V.js} +1 -1
- package/out/renderer/assets/{layout-C0hE7llw.js → layout-Bd0RsD3t.js} +1 -1
- package/out/renderer/assets/{linear-BXPh0BlC.js → linear-CLNSvs6X.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DlBAsGZ7.js → mermaid.core-C7_3uxUU.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-DUIiyta9.js → mindmap-definition-YA3MSWOX-D5EZxj9K.js} +1 -1
- package/out/renderer/assets/pegDiagram-XKGWAZYB-Dnhwt7dm.js +1 -0
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-DsaSjWfA.js → pieDiagram-E7YTZNPT-CBDZCyRu.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-BpWn5xT_.js → quadrantDiagram-AXDQQJYC-DEQXP9Eo.js} +1 -1
- package/out/renderer/assets/railroadDiagram-O6MQD6OU-wppyfObu.js +1 -0
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-CMIMPMzx.js → requirementDiagram-BXWQKSXE-My1GIaoL.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-CKqneOc7.js → sankeyDiagram-P5KCCOFB-CODqfCoJ.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-azbHkcGk.js → sequenceDiagram-WJ2MYXX4-DWTI2GPN.js} +1 -1
- package/out/renderer/assets/{sessionChanges--o0RBCJW.js → sessionChanges-55Ce2W6e.js} +5 -5
- package/out/renderer/assets/sizeCapture-INFHLROL-BtNh4g-W.js +1 -0
- package/out/renderer/assets/stateDiagram-D77RDMKH-BpLm_QD-.js +1 -0
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-uLtDbyZ2.js +1 -0
- package/out/renderer/assets/swimlanes-42K2YHIH-Dj27vx03.js +1 -0
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-Cz-6UA9B.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-DdVDUmce.js → timeline-definition-24CTP7MA-BXaGk6Mr.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-DP6DTjdX.js → vennDiagram-4TSXK5OY-B8VVfucW.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-DYJsuZCs.js → wardleyDiagram-VM6X3IG4-TCPh_Xam.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-CloAJCw-.js → xychartDiagram-S5SC5T6Z-ChKUHFHq.js} +1 -1
- package/out/renderer/index.html +2 -3
- package/out/renderer/web-preload.js +1 -1
- package/out/server/agent.js +258 -82
- package/out/server/chunks/{builtinOccupancy-Ci-Szozb.js → builtinOccupancy-D8_T5SBm.js} +6 -6
- package/out/server/chunks/{dispatchModel-DJxnHup9.js → dispatchModel-COFs7Mxc.js} +4 -3
- package/out/server/chunks/{gpuBackendInstall-snisWLXN.js → gpuBackendInstall-xFEdr70P.js} +2 -2
- package/out/server/chunks/{loadProvider-Uq3i7kKZ.js → loadProvider-DMF_f1uH.js} +2 -2
- package/out/server/chunks/{menuSkills-BEtW-Is6.js → menuSkills-D-SjYY21.js} +5 -4
- package/out/server/chunks/{projectCode-D9lgShsp.js → projectCode-UvWkPILc.js} +2 -2
- package/out/server/chunks/{registry-R2KRdU8n.js → registry-G4AKEQtl.js} +3 -3
- package/out/server/chunks/{sendImage-CCjNsa-D.js → sendImage-BmenO8Vx.js} +208 -61
- package/out/server/chunks/{toolParams-DVs5d3F9.js → toolParams-0GakTs9V.js} +2 -2
- package/out/server/chunks/{web-BIJOMDlz.js → web-DlqMGm8c.js} +30 -16
- package/out/server/chunks/{workflowPresets-DVbQh2el.js → workflowPresets-COjG82iz.js} +242 -158
- package/out/server/index.js +1678 -735
- package/out/server/memory-service.js +12 -5
- package/package.json +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-vDamN_Vr.js +0 -1
- package/out/phone/assets/channel-TsMJYH0f.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-Bhtnzu97.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-Bhtnzu97.js +0 -1
- package/out/phone/assets/desk-B382G0e_.js +0 -52
- package/out/phone/assets/eventmodeling-NTZA5JFV-BGT2L4_J.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-CpTX9nm5.js +0 -1
- package/out/phone/assets/main-Bc8DQVa6.css +0 -2
- package/out/phone/assets/main-Bez4gfKe.js +0 -281
- package/out/phone/assets/railroad-abnf-HS5TGJTU-CTHhRGvc.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-CS68P4fL.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-BqCcrVdf.js +0 -1
- package/out/phone/assets/shellUpdate-C4yk9AaU.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-nBP_YibA.js +0 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BkfzXxS-.js +0 -8
- package/out/renderer/assets/EditDiff-C9JBUR0o.js +0 -1
- package/out/renderer/assets/File-BIf-onMm.js +0 -1
- package/out/renderer/assets/ReadFileView-C5AKNlFU.js +0 -4
- package/out/renderer/assets/SidePanel-DkSc3og9.js +0 -48
- package/out/renderer/assets/Virtualizer-tZu4hGtC.js +0 -1345
- package/out/renderer/assets/abnfDiagram-VCTEODGH-DxBBUZxF.js +0 -1
- package/out/renderer/assets/channel-7bWV5QTy.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-mgQwYiWM.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-mgQwYiWM.js +0 -1
- package/out/renderer/assets/cose-bilkent-JH36ORCC-C246yayw.js +0 -1
- package/out/renderer/assets/cynefinDiagram-5FMLGOSQ-B3Jtuns2.js +0 -62
- package/out/renderer/assets/cytoscape-fcose-CJat50hU.js +0 -1
- package/out/renderer/assets/cytoscape.esm-DzSz-X2X.js +0 -321
- package/out/renderer/assets/diagram-UQ7AKVKN-D-8o1p4p.js +0 -41
- package/out/renderer/assets/diagram-VX7I27RA-Byl54mOd.js +0 -24
- package/out/renderer/assets/diagram-Z3DM3KII-Kf_GIJ7p.js +0 -24
- package/out/renderer/assets/ebnfDiagram-PWID7BFC-BbOdw7R1.js +0 -1
- package/out/renderer/assets/ganttDiagram-EL5Y4UJY-BpBSO-4X.js +0 -292
- package/out/renderer/assets/gitGraphDiagram-WWUBYQGX-b72vZ1j2.js +0 -106
- package/out/renderer/assets/globals-2G408HiJ.css +0 -1
- package/out/renderer/assets/globals-BqVjlAT_.js +0 -673
- package/out/renderer/assets/index-AHhNcASr.js +0 -113
- package/out/renderer/assets/infoDiagram-27XIBGKW-CtnN4sif.js +0 -2
- package/out/renderer/assets/manifest-DoBt8euy.js +0 -525
- package/out/renderer/assets/pegDiagram-XKGWAZYB-yP15oXPx.js +0 -1
- package/out/renderer/assets/railroadDiagram-O6MQD6OU-BnXhwCom.js +0 -1
- package/out/renderer/assets/settings-D5R80op8.js +0 -28
- package/out/renderer/assets/sizeCapture-INFHLROL-C3uhIZ1e.js +0 -1
- package/out/renderer/assets/stateDiagram-D77RDMKH-CrGab2Ck.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-k_H7O8MU.js +0 -1
- package/out/renderer/assets/swimlanes-42K2YHIH-6aX1l7C2.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-D2XerlPy.js +0 -8
- package/out/renderer/settings.html +0 -23
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import{aj as yt,aR as bf,aS as wf,aT as gs,c as Zr,aU as yf,aV as xf,aW as Sf,D as Cf,A as Df,r as w,W as kf,aX as Cn,j as d,aY as oe,aZ as Pf,a_ as ce,a$ as Ef,b0 as kl,b1 as Tf,b2 as If,b3 as Af,b4 as Rf,b5 as Nf,b6 as Lf,u as ae,b7 as Ks,b8 as qs,b9 as Qn,ba as ai,bb as Di,ax as U,bc as Qr,bd as Qd,be as Mf,bf as ec,bg as Of,bh as ns,bi as tc,bj as er,bk as ic,bl as as,bm as Ii,bn as ma,bo as rs,bp as li,bq as sc,br as ga,bs as va,bt as $e,bu as eo,bv as Gf,aQ as _a,bw as zf,bx as nc,by as jf,aP as Bf,bz as rc,bA as $f,bB as Wf,bC as Hf,bD as Ff,bE as oc,bF as Vf,bG as Uf,bH as ac,bI as lc,bJ as hc,bK as Kf,bL as qf,M as Yf,bM as Xf,bN as Jf,bO as Ln,bP as dc,a as ba,C as wa,e as ya,aO as Me,bQ as xa,bR as cc,bS as Zf,bT as Qf,bU as em,bV as tm,bW as im,bX as sm,bY as nm,bZ as Pl,aF as rm,b_ as uc,b$ as pc,c0 as fc,c1 as Nt,c2 as om,c3 as Mn,c4 as De,c5 as mc,c6 as gc,c7 as to,t as am,i as lm,c8 as hm,c9 as dm,ca as vc,cb as _c,aE as bc,cc as tr,cd as sn,ce as cm,cf as um,cg as pm,ch as fm,ci as mm,cj as gm,ck as vm,cl as _m,cm as bm,cn as wm,co as El,cp as ym,cq as Sa,cr as xm,cs as Sm,ct as Cm,cu as Dm,cv as wc,cw as Ca,cx as Da,cy as ka,cz as nt,cA as km,cB as yc,cC as _r,cD as Tl,cE as Pm,cF as Pa,cG as Em,cH as Tm,cI as Pi,cJ as Im,cK as Am,cL as xc,cM as Rm,cN as io,cO as Nm,cP as Lm,cQ as Mm,cR as Om,cS as Gm,cT as zm,cU as jm,cV as Bm,cW as $m,cX as Wm,cY as Hm,cZ as Fm,c_ as Vm,c$ as Um,d0 as Km,d1 as Il,d2 as qm,d3 as Ym,d4 as Xm,d5 as Jm,d6 as Zm,d7 as Qm,d8 as eg,d9 as tg,da as ig,db as Sc,dc as Cc,dd as Dc,de as sg,df as ng,dg as rg}from"./globals-BqVjlAT_.js";import{S as Ea,I as og,i as ag,U as On,C as Ta,G as lg,o as Ia,u as hg,t as dg,a as cg,K as ug,s as pg,k as fg,b as mg,c as Pt,m as gg,A as kc,e as vg,R as _g,f as bg,g as Pc,Q as wg,h as Ec,j as Tc,l as Aa,q as yg,n as xg,p as Sg,r as Cg,v as Dg,w as kg,x as Pg,y as Al,z as Eg,M as Ra,B as Tg,D as Ig,T as Ag,F as Rg,H as Ng,J as Lg,L as Mg,N as Ic,O as Na,d as Og,P as Gg,V as zg,W as jg,X as Bg,Y as ir,Z as sr,_ as $g,$ as Wg,a0 as nn,a1 as vs,a2 as so,a3 as Hg,a4 as Rl,a5 as Fg,a6 as Vg,a7 as Ug,a8 as Kg,a9 as qg,aa as La,ab as Ac,ac as Yg,ad as Xg,ae as Jg,af as Zg}from"./index-AHhNcASr.js";import{i as Nl,Q as Qg,H as Ys,L as ev,M as tv,a as iv,b as sv,c as nr,F as nv,E as rv}from"./manifest-DoBt8euy.js";import{P as Ll,L as Ml,c as Rc,Q as ov,V as av,W as lv,F as hv,a as dv,b as xi,X as cv,Y as uv}from"./Virtualizer-tZu4hGtC.js";import{V as pv,f as fv,r as mv,p as gv,s as vv,b as _v,c as bv}from"./sessionChanges--o0RBCJW.js";import{V as wv,r as yv,F as xv}from"./File-BIf-onMm.js";const Sv=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Cv=yt("chevrons-down-up",Sv);const Dv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],kv=yt("circle-pause",Dv);const Pv=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],Ev=yt("coffee",Pv);const Tv=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Iv=yt("earth",Tv);const Av=[["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:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],Rv=yt("file-diff",Av);const Nv=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Lv=yt("git-commit-horizontal",Nv);const Mv=[["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"}]],Nc=yt("layout-grid",Mv);const Ov=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],Gv=yt("list-checks",Ov);const zv=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],jv=yt("list-tree",zv);const Bv=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Lc=yt("lock",Bv);const $v=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],Wv=yt("radio-tower",$v);const Hv=[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],Fv=yt("sunrise",Hv);const Vv=[["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"}]],Uv=yt("unlink",Vv);function Kv(e){const t=[];for(const i of e){const s=t.at(-1);if(s&&s.batch===i.batch&&s.phase===i.phase){s.members.push(i);continue}t.push({batch:i.batch,members:[i],...i.phase?{phase:i.phase}:{}})}return t}const qv=new Set(["failed","needs-user"]),Ol=40,Yv="Done · needs you",Gn={"goal-complete":{tone:"ok",label:"Goal complete"},"turn-ended":{tone:"ok",label:"Turn ended"},"goal-blocked":{tone:"warn",label:"Goal blocked"},"needs-user":{tone:"warn",label:"Waiting for you"},stalled:{tone:"warn",label:"Stalled"},interrupted:{tone:"warn",label:"Interrupted"},failed:{tone:"bad",label:"Failed"}},Xv={running:{tone:"run",label:"Started"},idle:{tone:"idle",label:"Idle"},waiting:{tone:"idle",label:"Waiting for you"},error:{tone:"idle",label:"Failed"},"not-started":{tone:"idle",label:"Not started"},queued:{tone:"idle",label:"Queued"}};function Ma(e){if(!(e.pendingReminder&&e.state!=="running")&&!e.continuing&&!(!e.result||e.state==="running"))return e.result}function Oa(e,t){const i=(e.needsUser??[]).map(n=>n.trim()).filter(n=>n.length>0);if(i.length>0)return{feed:{tone:"ok",label:Yv},detail:i.join(";")};const s=e.summary?.trim();if(s)return{feed:t,detail:s}}function Mc(e){const t=Ma(e);return t?{...(t==="goal-complete"?Oa(e,Gn[t]):void 0)?.feed??Gn[t],at:e.resultAt??e.stateSince}:e.pendingReminder&&e.state!=="running"?{tone:"idle",label:"Waiting for reminder",at:e.stateSince}:e.continuing?{tone:"run",label:"In progress",at:e.stateSince}:{...Xv[e.state],at:e.stateSince}}function Jv(e){const t=Mc(e),i=Ma(e),n=(i==="goal-complete"?Oa(e,Gn[i]):void 0)?.detail??(e.needsUser&&e.needsUser.length>0?e.needsUser.join(";"):e.lastText);return{id:`session:${e.conversationId}`,at:t.at,tone:t.tone,projectName:e.projectName,title:e.title,label:t.label,...n?{detail:n}:{},conversationId:e.conversationId,...e.state==="running"?{running:!0}:{}}}function Zv(e){return e.kind==="profile"?"Update the secretary profile":e.kind==="skill"?`Skill: ${e.draft.name}`:e.kind==="tool"?`Tool: ${e.draft.name}`:e.kind==="takeover"?e.draft.title??e.draft.conversationId:e.kind==="cleanup"?`Clean up ${e.draft.items.length} items`:e.draft.title?.trim()||e.draft.prompt.split(`
|
|
2
|
-
`)[0]?.trim()||""}function Qv(e){return{id:`proposal:${e.proposal.id}`,at:e.proposal.createdAt,tone:"warn",projectName:e.projectName??"",title:Zv(e.proposal),label:"Waiting for your confirmation"}}function e_(e){const t=e.pending.status==="failed";return{id:`pending:${e.pending.id}`,at:e.pending.updatedAt,tone:t?"bad":"run",projectName:e.projectName,title:e.pending.draft.title?.trim()||e.pending.draft.prompt.split(`
|
|
3
|
-
`)[0]?.trim()||"",label:t?"Dispatch problem":"Waiting for dependencies"}}function t_(e,t){const i=e.kind==="seen"?{tone:"idle",label:"Secretary saw this"}:Gn[e.kind],s=t!==void 0&&t.result===e.kind&&t.resultAt===e.at?t:void 0,n=e.kind==="goal-complete"?Oa({needsUser:e.needsUser??s?.needsUser,summary:e.summary??s?.summary},i):void 0,r=n?.detail??e.text;return{id:`activity:${e.conversationId}:${e.at}:${e.kind}`,at:e.at,tone:n?.feed.tone??i.tone,projectName:t?.projectName??"",title:t?.title||e.conversationId,label:n?.feed.label??i.label,...r?{detail:r}:{},conversationId:e.conversationId}}function i_(e,t){return t.at-e.at||e.id.localeCompare(t.id)}function s_(e){const t=[...e.needsYou,...e.running,...e.done].filter(r=>r.kind==="session"),i=new Map(t.map(r=>[r.conversationId,r])),s=new Set((e.activity??[]).map(r=>`${r.conversationId}:${r.at}:${r.kind}`)),n=r=>{const o=Ma(r);return!!o&&s.has(`${r.conversationId}:${r.resultAt}:${o}`)};return[...e.needsYou,...e.running,...e.done].filter(r=>r.kind!=="session"||!n(r)).map(r=>r.kind==="proposal"?Qv(r):r.kind==="pending"?e_(r):Jv(r)).concat((e.activity??[]).map(r=>t_(r,i.get(r.conversationId)))).sort(i_)}function br(e,t,i){const s=new Map(t.map(a=>[a.id,a])),n=new Set(e.map(a=>a.id)),r=e.map(a=>s.get(a.id)??a),o=t.filter(a=>!n.has(a.id));return i?{events:[...o,...r],pending:[]}:{events:r,pending:o}}function n_(e,t){const i=new Map(e.map((r,o)=>[r.id,o])),s=e.slice(),n=[];for(const r of t){const o=i.get(r.id);o===void 0?n.push(r):s[o]=r}return[...s,...n]}function Oc(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:r_(e.items,t.items)}function r_(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],n=t[i];if(s==null||n==null||s.id!==n.id||s.type!==n.type||s.element!==n.element||s.instance!==n.instance||s.version!==n.version)return!1}return!0}function o_(e,t,i){const s=document.createElement("div");return s.style.display="flow-root",e==="header"?(s.setAttribute(bf,""),t.before(s)):(s.setAttribute(wf,""),t.after(s)),i?.observe(s),s}function a_(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function zt(e){const t=window.devicePixelRatio??1;return Math.round(e*t)/t}const l_=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],h_=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],Gl=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],zl=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],Gc=Symbol("CodeView.itemOptionsState");function jl(e,t){Object.defineProperty(e,Gc,{configurable:!1,enumerable:!1,value:t})}function _s(e){return e[Gc]}function Jt(e,t,i){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return i(this)}})}const d_=120,Bl=1,$l="--diffs-overflow-override",Ga=12e6,zc=1e6,jc=2e6,c_=Ga-jc,Wl=Ga-zc;function u_(e){if(e==null)throw new Error("CodeView: createEditor is required for items with edit: true")}const p_=(()=>{const{navigator:e}=globalThis,t=e.userAgent,i=/iP(?:hone|ad|od)/.test(t),s=e.platform==="MacIntel"&&e.maxTouchPoints>1;return(i||s)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})();var f_=class ti{static __STOP=!1;static __lastScrollPosition=0;type="advanced";config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=gs;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement("div");stickyContainer=document.createElement("div");stickyOffset=document.createElement("div");header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(t={theme:Zr},i,s=!1){this.options=t,this.computeMetricsCache(t.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=i,this.isContainerManaged=s,this.stickyOffset.style.contain="layout size",this.stickyContainer.style.position="sticky",this.stickyContainer.style.width="100%",this.stickyContainer.style.contain="layout style inline-size",this.stickyContainer.style.isolation="isolate",this.stickyContainer.style.display="flex",this.stickyContainer.style.flexDirection="column"}getLayout(){return this.options.layout??yf}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(t){return this.itemMetricsCache={hunkLineCount:t?.hunkLineCount??gs.hunkLineCount,lineHeight:t?.lineHeight??gs.lineHeight,diffHeaderHeight:t?.diffHeaderHeight??gs.diffHeaderHeight,hunkSeparatorHeight:t?.hunkSeparatorHeight,spacing:t?.spacing??gs.spacing,paddingTop:t?.paddingTop,paddingBottom:t?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??xf}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return Sf&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(t){if(!this.shouldValidateItemHeights()||t.element==null)return;const i=t.instance.getAdvancedStickySpecs();if(i==null)return;const s=i.height,n=t.element.getBoundingClientRect().height;s!==n&&console.error("CodeView: reconciled item height does not match DOM height",{id:t.item.id,type:t.type,index:t.index,version:t.version,expectedHeight:s,actualHeight:n,delta:n-s,stickyTopOffset:i.topOffset,virtualizedHeight:t.instance.getVirtualizedHeight(),top:t.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:t.element,instance:t.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;const{firstIndex:t,lastIndex:i,stickyHeight:s,stickyTop:n,stickyBottom:r}=this.renderState;if(t===-1||i===-1)return;const o=this.stickyContainer.getBoundingClientRect().height;Math.abs(o-s)<Bl||console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:s,actualStickyHeight:o,delta:o-s,stickyTop:n,stickyBottom:r,firstIndex:t,lastIndex:i,firstStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[i]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents="none",this.pointerEventsDisabled=!0),p_&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty($l,"hidden"),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,d_)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&(this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1),this.codeOverflowFix&&(this.stickyContainer.style.setProperty($l,"auto"),this.codeOverflowFix=!1)};syncLayout(){const{gap:t,paddingBottom:i,paddingTop:s}=this.getLayout();this.stickyContainer.style.gap=`${t}px`,this.container?.style.setProperty("margin-top",`${s}px`),this.container?.style.setProperty("margin-bottom",`${i}px`)}reconcileHeaderFooterHosts(){const t=this.reconcileHost("header"),i=this.reconcileHost("footer");return t||i}reconcileHost(t){const{root:i,container:s}=this;if(i==null||s==null)return!1;const n=t==="header"?this.header:this.footer,r=t==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(r==null)return n.element==null||(this.resizeObserver?.unobserve(n.element),n.element.remove(),n.element=void 0,n.render=void 0,this.setHostHeight(n,0)),!1;if(n.element!=null&&r===n.render)return!1;const o=n.element??o_(t,s,this.resizeObserver);n.element=o;const a=r();return a!=null?o.replaceChildren(a):!this.isContainerManaged&&o.children.length>0&&(o.textContent=""),n.render=r,!0}setHostHeight(t,i){t.height!==i&&(t.height=i,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw new Error("CodeView.setup: already setup");this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor="none",this.root.hasAttribute("tabindex")||(this.root.tabIndex=-1),this.container??=document.createElement("div"),this.container.style.contain="layout style",this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener("scroll",this.handleScroll,{passive:!0}),this.root.addEventListener("wheel",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("touchstart",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("pointerdown",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("keydown",this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{ti.__STOP?(ti.__STOP=!1,this.scrollTo({type:"position",position:ti.__lastScrollPosition,behavior:"instant"})):(ti.__lastScrollPosition=this.getScrollTop(),ti.__STOP=!0)}}reset(){Ll(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(const t of this.itemEditors.values())t.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",this.container?.style.removeProperty("height"),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener("scroll",this.handleScroll),this.root?.removeEventListener("wheel",this.clearPendingScroll),this.root?.removeEventListener("touchstart",this.clearPendingScroll),this.root?.removeEventListener("pointerdown",this.clearPendingScroll),this.root?.removeEventListener("keydown",this.clearPendingScroll),this.root?.style.removeProperty("overflow-anchor"),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let t=this.renderState.firstIndex;t<=this.renderState.lastIndex;t++){const i=this.items[t];if(i==null)throw new Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${t}`);this.releaseRenderedItem(i)}}primeScrollTarget(t){if(t.type==="position")return;const i=this.idToItem.get(t.id);i?.instance.primeHighlightCache()}getElementPoolLimit(){const t=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:i}=this.itemMetricsCache;return Math.max(8,Math.ceil(t/Math.max(i,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let t=this.elementPool.pop();for(;t!=null&&!this.isElementPoolGenerationCurrent(t);)t=this.elementPool.pop();return t??=document.createElement(Cf),this.markElementPoolGenerationCurrent(t),t}releaseRenderedItem(t){const{element:i}=t;i!=null&&this.renderedItemOwnsFocus(i)&&(this.shouldFixContainerFocus=!0),t.instance.cleanUp(!0),this.attachedEditors.delete(t.item.id),t.element=void 0,i!=null&&(i.remove(),this.cleanElement(i),this.queueElementForPool(i))}renderedItemOwnsFocus(t){const{activeElement:i}=document;return i===t||t.contains(i)||t.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(t){const{shadowRoot:i}=t;if(i!=null)for(const s of Array.from(i.children))b_(s)||s.remove();this.isContainerManaged||t.replaceChildren()}queueElementForPool(t){const i=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(t)||this.getElementPoolSize()>=i||(this.isElementClean(t)?this.elementPool.push(t):this.pendingElementPool.push(t))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;const{pendingElementPool:t}=this;this.pendingElementPool=[];const i=this.getElementPoolLimit();for(const s of t)this.isElementPoolGenerationCurrent(s)&&this.isElementClean(s)&&this.elementPool.length<i?this.elementPool.push(s):this.isElementPoolGenerationCurrent(s)&&this.getElementPoolSize()<i&&this.pendingElementPool.push(s)}isElementClean(t){return t.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(t){this.elementPoolTracker.set(t,this.elementPoolVersion)}isElementPoolGenerationCurrent(t){return this.elementPoolTracker.get(t)===this.elementPoolVersion}resolveEffectiveScrollBehavior(t,i){return a_()?"instant":t.behavior!=="smooth-auto"?t.behavior??"instant":Math.abs(i-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(t){if(this.root==null)return;const i=this.normalizeScrollTarget(t);if(i==null)return;const s=this.resolveScrollTargetTop(i);s!=null&&(this.primeScrollTarget(i),this.resolveEffectiveScrollBehavior(i,s)==="smooth"?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=i,this.render())}setSelectedLines(t,i){this.applySelectedLines(t,i)}getSelectedLines(){return this.selectedLines}clearSelectedLines(t){this.applySelectedLines(null,t)}getItem(t){return this.idToItem.get(t)?.item}getEditor(t){return this.itemEditors.get(t)?.editor}updateItem(t){const i=this.idToItem.get(t.id);return i==null?(console.error(`CodeView.updateItem: unknown item id "${t.id}"`),!1):this.syncItemRecord(i,t)?(this.markItemLayoutDirty(i),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(t,i){if(t===i)return!0;const s=this.idToItem.get(t);if(s==null)return console.error(`CodeView.updateItemId: unknown item id "${t}"`),!1;if(this.idToItem.has(i))return console.error(`CodeView.updateItemId: duplicate item id "${i}"`),!1;this.idToItem.delete(t),s.item.id=i,this.idToItem.set(i,s),this.updateItemOptionsId(s.instance.options,i),this.selectedLines?.id===t&&(this.selectedLines={...this.selectedLines,id:i},this.options.onSelectedLinesChange?.(this.selectedLines));const n=this.itemEditors.get(t);return n!=null&&(n.state.id=i,this.itemEditors.delete(t),this.itemEditors.set(i,n),this.attachedEditors.delete(t)&&this.attachedEditors.add(i)),this.renamePendingScrollTarget(t,i),this.renamePendingLayoutAnchor(t,i),this.render(),!0}addItem(t){this.addItems([t])}addItems(t){this.appendItemsInternal(t),this.syncItemEditors(),this.syncSelection()}removeItem(t){const i=this.idToItem.get(t);if(i==null)return console.error(`CodeView.removeItem: unknown item id "${t}"`),!1;const s=[];for(const n of this.items)n!==i&&s.push(n.item);return this.setItems(s),!0}setItems(t){let i;this.items.length===0?this.appendItemsInternal(t):this.tryAppendItems(t)||(i=this.reconcileItems(t)),this.syncItemEditors(i),this.syncSelection()}appendItemsInternal(t,i=!0){if(t.length===0)return;const s=this.getLayout();let n=this.items.length===0?0:this.scrollHeight+s.gap;const r=n;for(let o=0;o<t.length;o++){const a=t[o];if(a==null)throw new Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(a.id))throw new Error(`CodeView.addItem: duplicate id "${a.id}"`);const l=this.createItem(a,this.items.length,n);this.items.push(l),this.idToItem.set(l.item.id,l),this.instanceToItem.set(l.instance,l),l.height=m_(l),n+=l.height+s.gap}this.scrollHeight=n-s.gap,this.scrollDirty=!0,i&&(this.canSkipRenderForAppend(r)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(t){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&t>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(t){if(t==null)return;this.capturePendingLayoutAnchor();const{options:i}=this,s=this.getLayout(),{itemMetricsCache:n}=this;g_(i,t)&&this.invalidateElementPool(),this.options=t;const r=this.computeMetricsCache(t.itemMetrics),o=!Ml(n,r),a=!Ml(s,this.getLayout());a&&this.syncLayout();const l=o||v_(i,t);if(l){const c=this.pendingLayoutReset;this.pendingLayoutReset={metrics:o?r:c?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:c?.includeEstimatedDiffHeights===!0||o||__(i,t)}}(a||l)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),Rc(i,t)||this.renderOptionsRevision++,this.syncItemEditors();const h=i.renderCodeViewHeader!==t.renderCodeViewHeader||i.renderCodeViewFooter!==t.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||h)&&this.render()}capturePendingLayoutAnchor(t=this.idToItem){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),t))}render(t=!1){ti.__STOP||(t?(Ll(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):ov(this.computeRenderRangeAndEmit))}isReady(){const{workerManager:t}=this;return t==null||t.isInitialized()||t.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=t.subscribeToStatChanges(i=>{i.managerState!=="initialized"&&!i.workersFailed||(this.clearReadySubscription(),this.render(!0))}),t.getStats().managerState==="waiting"&&t.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(t,i){const s=this.instanceToItem.get(t);if(s==null)throw new Error("CodeView.instanceChanged: An instance has changed that is not registered");i&&this.markItemLayoutDirty(s),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){const{firstIndex:t,lastIndex:i}=this.renderState;if(t===-1||i===-1||i<t)return[];const s=[];for(let n=t;n<=i;n++){const r=this.items[n];r?.element!=null&&(r.type==="diff"?s.push({id:r.item.id,type:"diff",item:r.item,version:r.version,element:r.element,instance:r.instance}):s.push({id:r.item.id,type:"file",item:r.item,version:r.version,element:r.element,instance:r.instance}))}return s}setSlotCoordinator(t){return t===this.slotCoordinator?!1:(this.slotCoordinator=t,this.slotSnapshot=void 0,!0)}getSlotSnapshot(t){return this.buildSlotSnapshot(t)}buildSlotSnapshot(t){const i=y_(this.getRenderedItems(),t),{element:s}=this.header,{element:n}=this.footer;if(!(i==null&&s==null&&n==null))return{items:i,header:s,footer:n}}subscribeToScroll(t){return this.scrollListeners.add(t),()=>{this.scrollListeners.delete(t)}}getLocalTopForInstance(t){const i=this.instanceToItem.get(t);if(i==null)throw new Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return i.top}getTopForItem(t){const i=this.idToItem.get(t);if(i!=null)return i.top+this.getItemTopOffset()}createItem(t,i,s){const{itemMetricsCache:n}=this;if(t.type==="diff"){const o=new pv(this.createDiffOptions(t.id),this,n,this.workerManager,this.isContainerManaged);return{type:"diff",item:t,version:t.version,index:i,top:s,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}const r=new wv(this.createFileOptions(t.id),this,n,this.workerManager,this.isContainerManaged);return{type:"file",item:t,version:t.version,index:i,top:s,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:r}}applySelectedLines(t,i){const{selectedLines:s}=this;t==null&&s==null||t!=null&&s?.id===t.id&&av(s.range,t.range)||(s!=null&&s.id!==t?.id&&this.idToItem.get(s.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=t,this.idToItem.get(t?.id??"")?.instance.setSelectedLines(t?.range??null,i))}syncSelection(){if(this.selectedLines==null)return;const t=this.idToItem.get(this.selectedLines.id);if(t==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}t.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(t){return t.item.edit===!0&&t.item.collapsed!==!0}attachItemEditor(t){const{id:i}=t.item,{createEditor:s}=this.options;if(t.element==null||this.attachedEditors.has(i)||!this.isItemInEditMode(t))return;let n=this.itemEditors.get(i),r=!1;try{if(n==null){u_(s);const o={id:i},a=s({onChange:(l,h)=>{const c=this.idToItem.get(o.id);c!=null&&(o.lastChange={item:c.item,file:l,lineAnnotations:h},this.options.onItemEditChange?.(c.item,l,h))}});if(a==null)return;n={editor:a,state:o},this.itemEditors.set(i,n),r=!0}n.editor.edit(t.instance),this.attachedEditors.add(i)}catch(o){throw r&&n!=null&&(this.itemEditors.delete(i),n.editor.cleanUp()),this.releaseRenderedItem(t),o}}syncItemEditors(t){if(this.itemEditors.size===0)return;const i=[];for(const[s,n]of this.itemEditors){const r=this.idToItem.get(s),o=t?.get(s);if(o==null&&r!=null&&this.isItemInEditMode(r))continue;n.editor.cleanUp(),this.itemEditors.delete(s),this.attachedEditors.delete(s);const{lastChange:a}=n.state,l=o==null?r?.item??a?.item:a?.item??o.item;l?.type==="diff"&&(o==null&&r!=null&&r.type==="diff"&&r.instance.completeEditSession()&&(this.markItemLayoutDirty(r),this.render()),fv(l.fileDiff)),a!=null&&i.push(o!=null||r==null?a:{...a,item:r.item})}for(const{item:s,file:n,lineAnnotations:r}of i)this.options.onItemEditComplete?.(s,n,r)}renamePendingScrollTarget(t,i){const{pendingScrollTarget:s}=this;s==null||s.type==="position"||s.id!==t||(this.pendingScrollTarget={...s,id:i})}renamePendingLayoutAnchor(t,i){this.pendingLayoutAnchor?.id===t&&(this.pendingLayoutAnchor.id=i)}createFileOptionsPrototype(){const t={};for(const i of h_)Jt(t,i,()=>this.options[i]);Jt(t,"stickyHeader",()=>this.options.stickyHeaders),Jt(t,"collapsed",i=>{const s=_s(i);if(s!=null)return this.getItemOptions(s,"file")?.item.collapsed});for(const i of Gl)this.defineItemSharedCallback(t,"file",i);for(const i of zl)this.defineItemSelectionCallback(t,"file",i);return t}createDiffOptionsPrototype(){const t={};for(const i of l_)Jt(t,i,()=>this.options[i]);Jt(t,"stickyHeader",()=>this.options.stickyHeaders),Jt(t,"hunkSeparators",()=>this.options.hunkSeparators),Jt(t,"collapsed",i=>{const s=_s(i);if(s!=null)return this.getItemOptions(s,"diff")?.item.collapsed});for(const i of Gl)this.defineItemSharedCallback(t,"diff",i);for(const i of zl)this.defineItemSelectionCallback(t,"diff",i);return t}createFileOptions(t){const i=Object.create(this.fileOptionsPrototype);return jl(i,{id:t}),i}createDiffOptions(t){const i=Object.create(this.diffOptionsPrototype);return jl(i,{id:t}),i}updateItemOptionsId(t,i){const s=_s(t);if(s==null)throw new Error("CodeView.updateItemOptionsId: No valid state");s.id=i}getItemOptions(t,i){const s=this.idToItem.get(t.id);if(!(s==null||s.type!==i))return s}defineItemSharedCallback(t,i,s){Jt(t,s,n=>{if(this.options[s]==null)return;const r=_s(n);if(r==null)return;const o=r.callbackCache??={};let a=o[s];return a==null&&(a=((...l)=>{const h=this.getItemOptions(r,i);if(h==null)return;const c=this.options[s];return c?.(...l,h)}),o[s]=a),a})}defineItemSelectionCallback(t,i,s){Jt(t,s,n=>{const r=_s(n);if(r==null)return;const o=r.callbackCache??={};let a=o[s];return a==null&&(a=(l=>{const h=this.getItemOptions(r,i);if(h==null)return;const c=l==null?null:{id:h.item.id,range:l};this.options.controlledSelection!==!0&&(l!=null||this.selectedLines?.id===h.item.id)&&this.applySelectedLines(c,{notify:!1}),this.options.onSelectedLinesChange?.(c);const u=this.options[s];return u?.(l,h)}),o[s]=a),a})}markLayoutDirtyFromIndex(t){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??t,t)}markItemLayoutDirty(t){if(this.items[t.index]!==t)throw new Error(`CodeView.markItemLayoutDirty: unknown item id "${t.item.id}"`);this.markLayoutDirtyFromIndex(t.index)}tryAppendItems(t){if(t.length<=this.items.length)return!1;for(let i=0;i<this.items.length;i++){const s=this.items[i];if(s==null)throw new Error("CodeView.tryAppendItems: missing existing item");const n=t[i];if(n==null||s.item.id!==n.id||s.type!==n.type)return!1}for(let i=0;i<this.items.length;i++){const s=this.items[i];if(s==null)throw new Error("CodeView.tryAppendItems: missing existing item");const n=t[i];if(n==null)throw new Error("CodeView.tryAppendItems: append candidate missing prefix item");this.syncItemRecord(s,n)&&this.markLayoutDirtyFromIndex(i)}return this.appendItemsInternal(t.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(t){const{items:i,idToItem:s}=this,n=new Set(i),r=[],o=new Map,a=new Map,l=new Map;let h;for(let c=0;c<t.length;c++){const u=t[c];if(u==null)throw new Error("CodeView.reconcileItems: missing input item");if(o.has(u.id))throw new Error(`CodeView.setItems: duplicate id "${u.id}"`);const p=s.get(u.id),f=p!=null&&p.type===u.type?p:this.createItem(u,c,0);f.index=c,p!=null&&p.type===u.type?(n.delete(p),this.syncItemRecord(f,u)&&(h=Math.min(h??c,c))):h=Math.min(h??c,c),i[c]!==f&&(h=Math.min(h??c,c)),r.push(f),o.set(u.id,f),a.set(f.instance,f)}if(h==null){if(n.size===0)return;h=Math.max(r.length-1,0)}this.capturePendingLayoutAnchor(o);for(let c=0;c<i.length;c++){const u=i[c];if(u==null||!n.has(u))continue;l.set(u.item.id,u),this.releaseRenderedItem(u);const p=Math.max(r.length-1,0);h=Math.min(h??p,p)}return this.items=r,this.idToItem=o,this.instanceToItem=a,this.renderState.firstIndex>=r.length?this.resetRenderState():this.renderState.lastIndex>=r.length&&(this.renderState.lastIndex=r.length-1),this.markLayoutDirtyFromIndex(h),this.scrollDirty=!0,this.render(),l.size>0?l:void 0}syncItemRecord(t,i){if(t.type!==i.type)throw new Error(`CodeView.syncItemRecord: type mismatch for id "${i.id}"`);return t.version===i.version?!1:(t.item=i,t.version=i.version,t.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(t){const{paddingBottom:i,paddingTop:s}=this.getLayout();return Math.max(s+this.header.height+t+this.footer.height+i-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>Wl}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),Ga):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(t){const i=this.getMaxPagedScrollTop();return Math.max(0,Math.min(t,i))}clampScrollTop(t){const i=this.getMaxScrollTop();return Math.max(0,Math.min(t,i))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(t){const i=this.getMaxScrollPageOffset();return Math.max(0,Math.min(t,i))}resolveScrollPageWindow(t,i){let s=zt(this.clampPagedScrollTop(i)),n=this.clampScrollPageOffset(t-s);return s=zt(this.clampPagedScrollTop(t-n)),n=this.clampScrollPageOffset(t-s),{pagedScrollTop:s,scrollPageOffset:n}}resolvePagedScrollPosition(t){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(t),scrollPageOffset:0};const i=this.clampScrollPageOffset(this.scrollPageOffset),s=t-i,n=this.getMaxPagedScrollTop(),r=this.getMaxScrollPageOffset(),o=s>Wl&&i<r,a=s<zc&&i>0;return s<0||s>n||o||a?this.resolveScrollPageWindow(t,a?Math.min(c_,n):jc):{pagedScrollTop:zt(this.clampPagedScrollTop(s)),scrollPageOffset:i}}needsScrollPageUpdate(t){const i=zt(this.clampScrollTop(t)),{scrollPageOffset:s}=this.resolvePagedScrollPosition(i);return s!==this.scrollPageOffset}getPagedLayoutTop(t){return this.shouldRebaseScroll()?Math.max(t-this.scrollPageOffset,0):t}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(t){const i=this.idToItem.get(t.id);if(i==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return{top:i.top,height:i.height};if(t.type==="range"){const n=this.getRangeScrollPosition(i,t);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Hl(t.range)} for item "${t.id}"`);return}return{top:i.top+n.top,height:n.height}}const s=this.getLineScrollPosition(i,t);if(s==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return{top:i.top+s.top,height:s.height}}normalizeScrollTarget(t){if(t.type==="position"||t.align!=="nearest")return t;const i=this.getScrollTargetRect(t);if(i==null)return;const s=t.offset??0,n=this.getItemTopOffset()+i.top,r=n+i.height,o=this.getScrollTop(),a=o+(t.type==="line"||t.type==="range"?this.getStickyHeaderOffset():0),l=o+this.getHeight();if(!(n-s<=a&&r+s>=l)){if(n-s<a)return{...t,align:"start"};if(r+s>l)return{...t,align:"end"}}}resolveScrollTargetTop(t){if(t.type==="position"){const n=this.clampScrollTop(t.position);return n!==t.position?n:this.clampScrollTop(t.position-this.getStickyHeaderOffset())}const i=this.idToItem.get(t.id);if(i==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top,i.height,t.align,t.offset));if(t.type==="range"){const n=this.getRangeScrollPosition(i,t);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Hl(t.range)} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top+n.top,n.height,t.align,t.offset,this.getStickyHeaderOffset()))}const s=this.getLineScrollPosition(i,t);if(s==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top+s.top,s.height,t.align,t.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(t,i,s,n=0,r=0){t+=this.getItemTopOffset();const o=this.getHeight();return s==="center"&&i+n<o?t-(o-i)/2+n:s==="end"?t-(o-i)+n:t-r-n}getLineScrollPosition(t,i){return t.type==="diff"?t.instance.getLinePosition(i.lineNumber,i.side):t.instance.getLinePosition(i.lineNumber)}getRangeScrollPosition(t,i){const{range:s}=i,n=this.getLineScrollPosition(t,{type:"line",id:i.id,lineNumber:s.start,side:s.side}),r=this.getLineScrollPosition(t,{type:"line",id:i.id,lineNumber:s.end,side:s.endSide??s.side});if(n==null||r==null)return;const o=n.top,a=o+n.height,l=r.top,h=l+r.height,c=Math.min(o,l);return{top:c,height:Math.max(a,h)-c}}computeTargetScrollTopForFrame(t,i){if(this.pendingScrollTarget==null)return t;const s=this.resolveScrollTargetTop(this.pendingScrollTarget);if(s==null)return t;const{scrollAnimation:n}=this;return n==null?s:this.computeSpringStep(n,s,i).position}computeSpringStep(t,i,s){const n=Math.max(0,s-t.lastTimestamp),{omega:r}=this.getSmoothScrollSettings(),o=Math.exp(-r*n),a=t.position-i,l=t.velocity+r*a;return{position:i+(a+l*n)*o,velocity:(l*(1-r*n)-r*a)*o}}advanceScrollAnimation(t,i){if(this.pendingScrollTarget==null)return;const s=this.resolveScrollTargetTop(this.pendingScrollTarget);if(s==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}const n=this.scrollAnimation;if(n==null)return s;n.position+=i;const{position:r,velocity:o}=this.computeSpringStep(n,s,t);n.lastTimestamp=t,n.position=r,n.velocity=o;const{positionEpsilon:a,velocityEpsilon:l}=this.getSmoothScrollSettings();return Math.abs(s-r)<=a&&Math.abs(o)<=l?(n.position=s,n.velocity=0,this.scrollAnimation=void 0,s):n.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(ti.__STOP||this.container==null||!this.isReady())return;const i=this.getHeight(),s=this.getScrollTop();let n=s,r=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(n);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,r=!0),r&&o!=null){const L=this.resolveAnchoredScrollTop(o);if(L!=null){const O=L-n;n=L,this.scrollAnimation!=null&&(this.scrollAnimation.position+=O)}}r&&(n=this.clampScrollTop(n),this.syncContainerHeight());const a=this.computeTargetScrollTopForFrame(n,t),l=!r&&(this.renderState.scrollTop===-1||Math.abs(a-this.renderState.scrollTop)>i+this.config.overscrollSize*2);l&&(o=void 0),this.windowSpecs=lv({scrollTop:a-this.header.height,height:i,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let h=s;(this.pendingScrollTarget!=null&&a!==h||this.needsScrollPageUpdate(a))&&(this.applyScrollFix(a,h,this.windowSpecs),h=a);const{top:c,bottom:u}=this.windowSpecs,{firstIndex:p,lastIndex:f}=this.renderState;if(p>=0)for(let L=p;L<=f;L++){const O=this.items[L];if(O==null)throw new Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${L}`);O.top>c-O.height&&O.top<=u||this.releaseRenderedItem(O)}const m=this.reconcileHeaderFooterHosts();let g;const _=new Set,T=this.findFirstVisibleIndex(c),D=this.findLastVisibleIndex(u);for(let L=T;L<=D;L++){const O=this.items[L];if(O==null)throw new Error("CodeView.computeRenderRangeAndEmit: missing item");const{instance:z}=O;O.element==null?(O.element=this.acquireElement(),Ul(this.stickyContainer,O.element,g),z.virtualizedSetup(),Vl(O,O.element)&&(O.renderedOptionsRevision=this.renderOptionsRevision,_.add(O)),g=O.element):(Ul(this.stickyContainer,O.element,g),Vl(O,void 0,O.renderedOptionsRevision!==this.renderOptionsRevision)&&(O.renderedOptionsRevision=this.renderOptionsRevision,_.add(O)),g=O.element),O.item.edit===!0&&this.attachItemEditor(O)}this.renderState.firstIndex=T<=D?T:-1,this.renderState.lastIndex=D,this.flushSlotCoordinator(),this.flushManagers(_),m&&this.measureMountedHosts(),this.reconcileRenderedItems(_),this.syncContainerHeight(),this.updateStickyPositioning();const E=o!=null?this.resolveAnchoredScrollTop(o):void 0;o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);const S=E!=null?E-n:0;let A=a,k=!1;if(this.pendingScrollTarget!=null){const L=this.advanceScrollAnimation(t,S);L!=null?(A=L,k=!0):A=n}else A=E??a;A!==h&&(this.applyScrollFix(A,h,this.windowSpecs),h=A),k&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=zt(h),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||this.scrollAnimation!=null)&&this.render()};flushManagers(t){for(const i of t)i.instance.flushManagers()}syncContainerHeight(){const t=this.getPagedScrollHeight();this.container==null||this.containerHeight===t||(this.container.style.height=`${t}px`,this.containerHeight=t)}getStickyBounds(t){const{firstIndex:i,lastIndex:s}=t!=null?{firstIndex:this.findFirstVisibleIndex(t.top),lastIndex:this.findLastVisibleIndex(t.bottom)}:this.renderState;if(i===-1||s===-1||i>s)return;const n=this.items[i]?.instance.getAdvancedStickySpecs(t),r=this.items[s]?.instance.getAdvancedStickySpecs(t);if(!(n==null||r==null))return{stickyTop:this.getPagedLayoutTop(Math.max(n.topOffset,0)),stickyBottom:this.getPagedLayoutTop(r.topOffset+r.height)}}applyStickyPositioning({stickyTop:t,stickyBottom:i}){const s=this.getHeight(),{itemMetricsCache:n}=this,r=i-t;this.renderState.stickyHeight=r,this.renderState.stickyTop=t,this.renderState.stickyBottom=i,this.stickyOffset.style.height=`${t}px`;const o=(Math.random()*n.lineHeight>>0)*-1,a=-Math.max(r+o,0)+s;this.stickyContainer.style.top=`${a}px`,this.stickyContainer.style.bottom=`${a+n.diffHeaderHeight}px`}syncPagedScrollScaffolding(t){this.syncContainerHeight();const i=this.getStickyBounds(t);i!=null&&this.applyStickyPositioning(i)}reconcileRenderedItems(t){const{firstIndex:i,lastIndex:s}=this.renderState;if(i===-1)return;let n=-1,r=!1;for(let o=i;o<this.items.length&&!(!r&&o>s);o++){const a=this.items[o];if(a==null)throw new Error("CodeView.reconcileRenderedItems: Invalid item");n===-1?n=a.top:a.top!==n&&(a.top=n,a.instance.syncVirtualizedTop(),r=!0),(t==null?o<=s:t.has(a))&&(a.instance.reconcileHeights()&&(r=!0,a.height=a.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(a)),n+=a.instance.getVirtualizedHeight(),o<this.items.length-1&&(n+=this.getLayout().gap)}r&&n!=null&&(this.scrollDirty=!0,this.scrollHeight=n)}updateStickyPositioning(){const t=this.getStickyBounds();if(t==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height="");return}const{stickyTop:i,stickyBottom:s}=t;s-i===this.renderState.stickyHeight&&i===this.renderState.stickyTop&&s===this.renderState.stickyBottom||this.applyStickyPositioning(t)}handleScroll=()=>{ti.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=t=>{let i=!1;for(const s of t)if(s.target===this.stickyContainer){const n=s.borderBoxSize[0].blockSize;if(Math.abs(n-this.renderState.stickyHeight)>=Bl){const r=this.getScrollTop(),o=this.getScrollAnchor(r);this.reconcileRenderedItems(),this.updateStickyPositioning();const a=o!=null?this.resolveAnchoredScrollTop(o):void 0;if(a!=null){const l=a-r;this.applyScrollFix(a,r,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=l)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),i=!0}}else if(s.target===this.header.element||s.target===this.footer.element){const n=s.target===this.header.element?this.header:this.footer,r=s.borderBoxSize[0].blockSize;if(r!==n.height){const o=this.getScrollTop(),a=this.getScrollAnchor(o);this.setHostHeight(n,r);const l=a!=null?this.resolveAnchoredScrollTop(a):void 0;if(l!=null){const h=l-o;this.applyScrollFix(l,o,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=h)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),i=!0}}else this.scrollDirty=!0,this.heightDirty=!0,i=!0;i&&this.render(!0)};getScrollAnchorViewportTop(t,i){return t<i?i+this.getStickyHeaderOffset():i}getScrollAnchor(t,i=this.idToItem){let s;const{pendingLayoutAnchor:n}=this;if(n!=null){const c=this.idToItem.get(n.id);if(c!=null&&i.get(n.id)===c)return n;c!=null&&(s=c)}if(t<=0)return;const{firstIndex:r,lastIndex:o,stickyTop:a,stickyBottom:l}=this.renderState;if(r===-1||o===-1)return;const h=this.getHeight();if(!(a===-1||l===-1)){for(let c=r;c<=o;c++){const u=this.items[c];if(u==null)continue;const p=this.getItemTopOffset()+u.top;if(p+u.height<=t)continue;if(p>=t+h)break;if(i.get(u.item.id)!==u){s??=u;continue}if(p>=t)return{type:"item",id:u.item.id,viewportOffset:p-t};const f=this.getScrollAnchorViewportTop(p,t)-p,m=u.instance.getNumericScrollAnchor(f);if(m!=null){const g=p+m.top;return{type:"line",id:u.item.id,lineNumber:m.lineNumber,side:m.side,viewportOffset:g-t}}}if(s!=null)for(let c=s.index+1;c<this.items.length;c++){const u=this.items[c];if(u!=null&&i.get(u.item.id)===u)return{type:"item",id:u.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(t){const i=this.idToItem.get(t.id);if(i==null)return;const s=this.getItemTopOffset();if(t.type==="item"){const o=s+i.top;return this.clampScrollTop(o-t.viewportOffset)}const n=i.type==="diff"?i.instance.getLinePosition(t.lineNumber,t.side):i.instance.getLinePosition(t.lineNumber);if(n==null)return;const r=s+i.top+n.top;return this.clampScrollTop(r-t.viewportOffset)}applyScrollFix(t,i,s){if(this.root==null)return;const n=zt(this.clampScrollTop(t)),r=zt(i),{scrollPageOffset:o}=this,a=zt(this.clampPagedScrollTop(r-o)),{pagedScrollTop:l,scrollPageOffset:h}=this.resolvePagedScrollPosition(n),c=l,u=o!==h;n===this.renderState.scrollTop&&n===r&&c===a&&!u||(this.suspendScrollInteractions(),(c!==a||u)&&(this.scrollPageOffset=h,this.syncPagedScrollScaffolding(s)),c!==a&&this.root.scrollTo({top:c,behavior:"instant"}),this.renderState.scrollTop=n,this.scrollTop=n,this.scrollDirty=!1)}isPendingTargetSettled(t){const i=this.resolveScrollTargetTop(t);return i==null?!0:zt(this.getScrollTop())===zt(i)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;const t=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(t+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;const t=this.buildSlotSnapshot(this.slotCoordinator);Oc(this.slotSnapshot,t)||(this.slotSnapshot=t,this.slotCoordinator.onSnapshotChange(t))}notifyScroll(){if(this.scrollListeners.size===0)return;const t=this.getScrollTop();for(const i of this.scrollListeners)i(t,this)}findFirstVisibleIndex(t){let i=0,s=this.items.length-1,n=this.items.length;for(;i<=s;){const r=i+s>>1,o=this.items[r];if(o==null)throw new Error("CodeView.findFirstVisibleIndex: invalid item index");o.top+o.height>t?(n=r,s=r-1):i=r+1}return n}findLastVisibleIndex(t){let i=0,s=this.items.length-1,n=-1;for(;i<=s;){const r=i+s>>1,o=this.items[r];if(o==null)throw new Error("CodeView.findLastVisibleIndex: invalid item index");o.top<=t?(n=r,i=r+1):s=r-1}return n}recomputeLayout(t=0,i){if(this.items.length===0){this.scrollHeight=0;return}const s=this.getLayout();let n=0;if(t>0){const r=this.items[t-1];if(r==null)throw new Error("CodeView.recomputeLayout: invalid dirty index");n=r.top+r.height+s.gap}for(let r=t;r<this.items.length;r++){const o=this.items[r];if(o==null)throw new Error("CodeView.recomputeLayout: invalid item index");if(o.top=n,o.type==="diff"){const a=o.instance.consumeCodeViewLayoutChanges(o.item.fileDiff);a!=null&&Object.assign(o.item.fileDiff,a),o.height=o.instance.prepareCodeViewItem(o.item.fileDiff,n,i,o.item.annotations??[])}else o.height=o.instance.prepareCodeViewItem(o.item.file,n,i,o.item.annotations??[]);n+=o.height,r<this.items.length-1&&(n+=s.gap)}n!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=n}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function m_(e){return e.instance.cleanUp(!0),e.type==="diff"?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function g_(e,t){return!Df(e.theme??Zr,t.theme??Zr)||(e.themeType??"system")!==(t.themeType??"system")||e.unsafeCSS!==t.unsafeCSS}function v_(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function __(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function b_(e){return e instanceof SVGElement?!0:hv(e)&&(e.hasAttribute("data-core-css")||e.hasAttribute("data-theme-css")||e.hasAttribute("data-unsafe-css"))}function Hl(e){const t=Fl(e.start,e.side),i=Fl(e.end,e.endSide??e.side);return t===i?t:`${t}-${i}`}function Fl(e,t){return t==null?`${e}`:`${t==="deletions"?"D":"A"}${e}`}function Vl(e,t,i=!1){return e.type==="diff"?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:i,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:i,lineAnnotations:e.item.annotations??[]})}function Ul(e,t,i){if(i==null){e.firstChild!==t&&e.prepend(t);return}i.nextSibling!==t&&i.after(t)}function w_(e){return(e.annotations?.length??0)>0}function y_(e,{hasHeaderRenderers:t,hasAnnotationRenderer:i,hasGutterRenderer:s}){if(e.length===0)return;if(t||s)return e;if(!i)return;const n=[];for(const r of e)w_(r.item)&&n.push(r);return n.length>0?n:void 0}const Kl=typeof window>"u"?w.useEffect:w.useLayoutEffect;function ql(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function x_(e,t){const{className:i,containerRef:s,disableWorkerPool:n=!1,editorOptions:r,initialItems:o,items:a,onItemEditChange:l,onItemEditComplete:h,onScroll:c,onSelectedLinesChange:u,options:p,renderAnnotation:f,renderCodeViewFooter:m,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:T,renderHeaderFilenameSuffix:D,renderHeaderMetadata:E,renderHeaderPrefix:S,selectedLines:A,style:k}=e,L=a!==void 0,O=dv(),z=w.useContext(kf),N=w.useRef(ql(L)),I=_!=null,C=f!=null,v=T!=null,y=I||S!=null||D!=null||E!=null,x=y||C||v,b=g!=null,R=m!=null,M=xi(F=>{u?.(F)}),W=A!==void 0,B=xi(F=>{if(O==null)throw new Error("CodeView: EditContext is not attached");const le=O({...r,...F});if(le==null)throw new Error("CodeView: EditProvider.createEditor must return an editor instance");return le}),Q=xi((F,le,pe)=>{l?.(F,le,pe)}),ie=xi((F,le,pe)=>{h?.(F,le,pe)}),ne=w.useMemo(()=>k_({options:p,hasCustomHeader:I,hasGutterRenderer:v,hasCodeViewHeader:b,hasCodeViewFooter:R,onSelectedLinesChange:u!=null?M:void 0,controlledSelection:W,createEditor:O!=null?B:void 0,onItemEditChange:l!=null?Q:void 0,onItemEditComplete:h!=null?ie:void 0}),[O,W,B,Q,ie,M,R,b,I,v,l,h,u,p]),[de]=w.useState(()=>D_()),[,ve]=w.useState({}),re=xi(F=>{N.current.instance!=null&&(F==null||F!==N.current.instance.getContainerElement())&&(N.current.instance.cleanUp(),de.publish(void 0),N.current=ql(L)),F!=null&&F!==N.current.instance?.getContainerElement()&&(N.current.instance=new f_(ne,n?void 0:z,!0),N.current.instance.setup(F)),typeof s=="function"?s(F):s!=null&&(s.current=F)}),me=xi(F=>{N.current.disableFlushSync?de.publish(F):Cn.flushSync(()=>{de.publish(F)})}),K=w.useMemo(()=>{if(!(!y&&!C&&!v&&!b&&!R))return{hasHeaderRenderers:y,hasAnnotationRenderer:C,hasGutterRenderer:v,onSnapshotChange:me}},[me,C,v,y,b,R]);return Kl(()=>c!=null?N.current.instance?.subscribeToScroll(c):void 0),Kl(()=>{const{instance:F,controlled:le,items:pe,managedOptions:ke,slotCoordinator:we}=N.current;if(F!=null)try{N.current.disableFlushSync=!0;let Xe=!1;if(Rc(ne,ke)||(N.current.managedOptions=ne,F.setOptions(ne),Xe=!0),le!==L){console.error("CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.");return}if(L)a!==pe&&(C_(pe,a)?N.current.items=a:S_(pe,a)?(N.current.items=a,F.addItems(a.slice(pe.length))):(N.current.items=a,F.setItems(a),Xe=!0));else if(pe==null){const ft=o??[];N.current.items=ft,ft.length>0&&(F.setItems(ft),Xe=!0)}A!==void 0&&F.setSelectedLines(A,{notify:!1});const ct=F.setSlotCoordinator(K);let Re=!1;K!==we&&((K==null||we==null)&&(Re=!0),N.current.slotCoordinator=K),(Xe||ct)&&F.render(!0),ct&&K==null&&de.publish(void 0),Re&&ve({})}finally{N.current.disableFlushSync=!1}}),w.useImperativeHandle(t,()=>({addItems(F){const{controlled:le,instance:pe}=N.current;rn(le,"addItems"),pe==null?console.error("CodeView.addItems: no valid instance to append items with",F):pe.addItems(F)},getItem(F){const{instance:le}=N.current;if(le==null){console.error("CodeView.getItem: no valid instance exists",F);return}else return le.getItem(F)},removeItem(F){const{controlled:le,instance:pe}=N.current;return rn(le,"removeItem"),pe==null?(console.error("CodeView.removeItem: no valid instance to remove item from",F),!1):pe.removeItem(F)},updateItem(F){const{controlled:le,instance:pe}=N.current;return rn(le,"updateItem"),pe==null?(console.error("CodeView.updateItem: no valid instance to update item with",F),!1):pe.updateItem(F)},updateItemId(F,le){const{controlled:pe,instance:ke}=N.current;return rn(pe,"updateItemId"),ke==null?(console.error("CodeView.updateItemId: no valid instance to update item id with",F,le),!1):ke.updateItemId(F,le)},scrollTo(F){const{instance:le}=N.current;le==null?console.error("CodeView.scrollTo: no valid instance to scroll with",F):le.scrollTo(F)},setSelectedLines(F){const{instance:le}=N.current;le==null?console.error("CodeView.setSelectedLines: no valid instance to update selection with",F):(le.setSelectedLines(F,{notify:!1}),M(F))},getSelectedLines(){const{instance:F}=N.current;return F==null?(console.error("CodeView.getSelectedLines: no valid instance exists"),null):F.getSelectedLines()},clearSelectedLines(){const{instance:F}=N.current;F==null?console.error("CodeView.clearSelectedLines: no valid instance to update selection with"):(F.clearSelectedLines({notify:!1}),M(null))},getEditor(F){const{instance:le}=N.current;if(le==null){console.error("CodeView.getEditor: no valid instance exists",F);return}return le.getEditor(F)},getInstance(){return N.current.instance}}),[M]),d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:re,className:i,style:k}),(x||b||R)&&d.jsx(P_,{managedContentStore:de,renderCustomHeader:_,renderHeaderPrefix:S,renderHeaderFilenameSuffix:D,renderHeaderMetadata:E,renderAnnotation:f,renderGutterUtility:T,renderCodeViewHeader:g,renderCodeViewFooter:m})]})}const Bc=w.forwardRef(x_);function S_(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let i=0;i<e.length;i++)if(t[i]!==e[i])return!1;return!0}function C_(e,t){if(e==null||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function rn(e,t){if(e)throw new Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function D_(){let e;const t=new Set;return{getSnapshot(){return e},publish(i){if(!Oc(e,i)){e=i;for(const s of t)s()}},subscribe(i){return t.add(i),()=>{t.delete(i)}}}}function k_({options:e,hasCustomHeader:t,hasGutterRenderer:i,hasCodeViewHeader:s,hasCodeViewFooter:n,onSelectedLinesChange:r,controlledSelection:o,createEditor:a,onItemEditChange:l,onItemEditComplete:h}){const c={...e,controlledSelection:o,onSelectedLinesChange:r,createEditor:a};return l!=null&&(c.onItemEditChange=l),h!=null&&(c.onItemEditComplete=h),t&&(c.renderCustomHeader=on),i&&(c.renderGutterUtility=on),s&&(c.renderCodeViewHeader=on),n&&(c.renderCodeViewFooter=on),c}const P_=w.memo(function({managedContentStore:t,renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:o,renderGutterUtility:a,renderCodeViewHeader:l,renderCodeViewFooter:h}){"use no memo";const c=xi(m=>t.subscribe(m)),u=xi(()=>t.getSnapshot()),p=w.useSyncExternalStore(c,u,u);let f="";for(const m of p?.items??[])f+=`${m.id}:${m.version}:${m.type}`;return d.jsxs(d.Fragment,{children:[w.useMemo(()=>p?.items?.map(m=>Cn.createPortal(E_({renderedItem:m,renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:o,renderGutterUtility:a}),m.element,m.id)),[i,s,n,r,o,a,f]),w.useMemo(()=>l!=null&&p?.header!=null?Cn.createPortal(l(),p.header):null,[l,p?.header]),w.useMemo(()=>h!=null&&p?.footer!=null?Cn.createPortal(h(),p.footer):null,[h,p?.footer])]})});function E_({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:i,renderHeaderFilenameSuffix:s,renderHeaderMetadata:n,renderAnnotation:r,renderGutterUtility:o}){if(e.type==="diff"){const{item:a,instance:l}=e;return mv({fileDiff:a.fileDiff,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:i!=null?()=>i(a):void 0,renderHeaderFilenameSuffix:s!=null?()=>s(a):void 0,renderHeaderMetadata:n!=null?()=>n(a):void 0,renderAnnotation:r!=null?h=>r(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}else{const{item:a,instance:l}=e;return yv({file:a.file,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:i!=null?()=>i(a):void 0,renderHeaderFilenameSuffix:s!=null?()=>s(a):void 0,renderHeaderMetadata:n!=null?()=>n(a):void 0,renderAnnotation:r!=null?h=>r(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}}function on(){}var $c,Wc=class{constructor(){}},Et=class extends Wc{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}},Ms=class extends Wc{constructor(e,t){super(),this.viewId=e,this.paneId=t}},hi=class Hc{constructor(){}static getInstance(){return Hc.INSTANCE}hasData(t){return t&&t===this.proto}clearData(t){this.hasData(t)&&(this.proto=void 0,this.data=void 0)}getData(t){if(this.hasData(t))return this.data}setData(t,i){i&&(this.data=t,this.proto=i)}};$c=hi;hi.INSTANCE=new $c;function Ie(){const e=hi.getInstance();if(e.hasData(Et.prototype))return e.getData(Et.prototype)[0]}function bs(){const e=hi.getInstance();if(e.hasData(Ms.prototype))return e.getData(Ms.prototype)[0]}let xe;(function(e){e.NONE={dispose:()=>{}};function t(i){return{dispose:()=>{i()}}}e.from=t})(xe||(xe={}));var te=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(t=>this._disposables.add(t))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},Ge=class{constructor(){this._disposable=xe.NONE}get value(){return this._disposable===xe.NONE?void 0:this._disposable}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=xe.NONE)}};let Tt;(function(e){e.any=(...t)=>i=>{const s=t.map(n=>n(i));return{dispose:()=>{s.forEach(n=>{n.dispose()})}}}})(Tt||(Tt={}));var za=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},Fc=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},T_=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},Yl=class Vc{static create(){var t;return new Vc((t=new Error("listener stacktrace").stack)!==null&&t!==void 0?t:"")}constructor(t){this.value=t}print(){console.warn("dockview: stacktrace",this.value)}},I_=class{constructor(e,t){this.callback=e,this.stacktrace=t}},G=class $t{static setLeakageMonitorEnabled(t){t!==$t.ENABLE_TRACKING&&$t.MEMORY_LEAK_WATCHER.clear(),$t.ENABLE_TRACKING=t}get value(){return this._last}constructor(t){this.options=t,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=t=>{var i;!((i=this.options)===null||i===void 0)&&i.replay&&this._last!==void 0&&t(this._last);const s=new I_(t,$t.ENABLE_TRACKING?Yl.create():void 0);return this._listeners.push(s),{dispose:()=>{const n=this._listeners.indexOf(s);n>-1&&this._listeners.splice(n,1)}}},$t.ENABLE_TRACKING&&$t.MEMORY_LEAK_WATCHER.add(this._event,Yl.create())),this._event}fire(t){var i;if(this._pauseTokens!==void 0&&this._pauseTokens.size>0)return;!((i=this.options)===null||i===void 0)&&i.replay&&(this._last=t);const s=this._listeners,n=s.length;if(n!==0){if(n===1){s[0].callback(t);return}for(const r of s.slice())r.callback(t)}}pause(){var t;const i={};return(t=this._pauseTokens)!==null&&t!==void 0||(this._pauseTokens=new Set),this._pauseTokens.add(i),xe.from(()=>{var s;return(s=this._pauseTokens)===null||s===void 0?void 0:s.delete(i)})}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&($t.ENABLE_TRACKING?queueMicrotask(()=>{for(const i of this._listeners){var t;console.warn("dockview: stacktrace",(t=i.stacktrace)===null||t===void 0?void 0:t.print())}this._listeners=[]}):this._listeners=[]),$t.ENABLE_TRACKING&&this._event&&$t.MEMORY_LEAK_WATCHER.delete(this._event))}};G.ENABLE_TRACKING=!1;G.MEMORY_LEAK_WATCHER=new T_;function Z(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}var Xl=class{constructor(){this._onFired=new G,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{const t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},A_=class extends te{constructor(e){super(),this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,Ui(e,t=>{const i=t.target.scrollWidth>t.target.clientWidth,s=t.target.scrollHeight>t.target.clientHeight;this._value={hasScrollX:i,hasScrollY:s},this._onDidChange.fire(this._value)}))}};function Ui(e,t){const i=new ResizeObserver(s=>{requestAnimationFrame(()=>{const n=s[0];t(n)})});return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const Mt=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},Ot=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},Y=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function no(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function Uc(e){return new R_(e)}var R_=class extends te{constructor(e){super(),this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=no(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},n=()=>{t&&(i=!0,globalThis.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{no(document.activeElement,e)!==t&&(t?n():s())},this.addDisposables(Z(e,"focus",s,!0)),this.addDisposables(Z(e,"blur",n,!0))}refreshState(){this._refreshStateHandler()}};const Kc="dv-quasiPreventDefault";function qc(e){e[Kc]=!0}function Jl(e){return e[Kc]}function N_(e,t,i={}){const s=Array.from(t),{nonce:n}=i,r=typeof n=="function"?n(e):n;for(const o of s){if(o.href){const h=e.createElement("link");h.href=o.href,h.type=o.type,h.rel="stylesheet",e.head.appendChild(h);continue}let a=[];try{o.cssRules&&(a=Array.from(o.cssRules).map(h=>h.cssText))}catch(h){console.warn("dockview: failed to access stylesheet rules due to security restrictions",h)}const l=e.createDocumentFragment();for(const h of a){const c=e.createElement("style");r&&c.setAttribute("nonce",r),c.appendChild(e.createTextNode(h)),l.appendChild(c)}e.head.appendChild(l)}}function ro(e){const{left:t,top:i,width:s,height:n}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:s,height:n}}function Yc(e){let t=e;for(;t?.parentNode;){if(t.parentNode===document)return!0;t.parentNode instanceof DocumentFragment?t=t.parentNode.host:t=t.parentNode}return!1}function L_(e,t){e.dataset.testid=t}function M_(e,t){const i=[];function s(n){if(n.nodeType===Node.ELEMENT_NODE){e.includes(n.tagName)&&i.push(n),n.shadowRoot&&s(n.shadowRoot);for(const r of n.children)s(r)}}return s(t instanceof Document?t.documentElement:t),i}function js(e=document){const t=M_(["IFRAME","WEBVIEW"],e),i=new WeakMap;for(const s of t)i.set(s,s.style.pointerEvents),s.style.pointerEvents="none";return{release:()=>{for(const n of t){var s;n.style.pointerEvents=(s=i.get(n))!==null&&s!==void 0?s:"auto"}t.splice(0,t.length)}}}function O_(e){function t(n){const r=[];for(let o=0;o<n.classList.length;o++)r.push(n.classList.item(o));return r}let i,s=e;for(;s!==null&&(i=t(s).find(n=>n.startsWith("dockview-theme-")),typeof i!="string");)s=s.parentElement;return i}var rr=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const t of this._classNames)Y(this.element,t,!1);this._classNames=e.split(" ").filter(t=>t.trim().length>0);for(const t of this._classNames)Y(this.element,t,!0)}};const Xc=100;function wr(e,t){const i=ro(e),s=ro(t);return!(i.left<s.left||i.left+i.width>s.left+s.width||i.top<s.top||i.top+i.height>s.top+s.height)}function G_(e){const t=new G;let i=e.screenX,s=e.screenY,n,r=0,o=!1;const a=()=>{if(o||e.closed)return;const h=e.screenX,c=e.screenY;(h!==i||c!==s)&&(clearTimeout(n),n=setTimeout(()=>{t.fire()},Xc),i=h,s=c),r=requestAnimationFrame(a)};a();const l=t.dispose.bind(t);return t.dispose=()=>{o||(o=!0,cancelAnimationFrame(r),clearTimeout(n)),l()},t}function z_(e,t){let i;return new te(Z(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},Xc)}))}function j_(e,t,i){var s;const n=(s=void 0)!==null&&s!==void 0?s:10,r=e.getBoundingClientRect(),o=t.getBoundingClientRect();let a=0,l=0;const h=r.left-o.left,c=r.top-o.top,u=r.bottom-o.bottom,p=r.right-o.right;h<n?a=n-h:p>n&&(a=-n-p),c<n?l=n-c:u>n&&(l=-u-n),(a!==0||l!==0)&&(e.style.transform=`translate(${a}px, ${l}px)`)}function B_(e){let t=e;for(;t&&(t.style.zIndex==="auto"||t.style.zIndex==="");)t=t.parentElement;return t}function ri(e){if(e.length===0)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function Jc(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function yr(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function an(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function $_(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(t(s))return i}return-1}function Zc(e,t){const i=e.indexOf(t);return i>-1?(e.splice(i,1),!0):!1}const Te=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),ja=()=>{let e=1;return{next:()=>(e++).toString()}},Rt=(e,t)=>{const i=[];if(typeof t!="number"&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};var W_=class{set size(e){this._size=e}setContainerGeometry(e,t){this._appliedStyles[e]!==t&&(this._appliedStyles[e]=t,this.container.style[e]=t)}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,this._appliedStyles={},typeof i=="number"?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){if(e!==this.visible){if(e){var i;this.size=Te((i=this._cachedVisibleSize)!==null&&i!==void 0?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0}else this._cachedVisibleSize=typeof t=="number"?t:this.size,this.size=0;this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e)}}dispose(){return this.disposable.dispose(),this.view}};function Zl(e,t,i){e.appliedLeft!==t&&(e.appliedLeft=t,e.container.style.left=t),e.appliedTop!==i&&(e.appliedTop=i,e.container.style.top=i)}let lt;(function(e){e.Distribute={type:"distribute"};function t(s){return{type:"split",index:s}}e.Split=t;function i(s){return{type:"invisible",cachedVisibleSize:s}}e.Invisible=i})(lt||(lt={}));var Hi=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,Mt(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation=="HORIZONTAL"?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?Number.POSITIVE_INFINITY:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,Y(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,Y(this.element,"dv-splitview-has-margin",e!==0)}constructor(e,t){var i,s;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new G,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(n,r,o=this.viewItems.map(f=>f.size),a,l,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,u,p)=>{if(n<0||n>this.viewItems.length)return 0;const f=Rt(n,-1),m=Rt(n+1,this.viewItems.length);if(l)for(const N of l)yr(f,N),yr(m,N);if(a)for(const N of a)an(f,N),an(m,N);const g=f.reduce((N,I)=>N+this.viewItems[I].minimumSize-o[I],0),_=f.reduce((N,I)=>N+this.viewItems[I].maximumSize-o[I],0),T=m.length===0?Number.POSITIVE_INFINITY:m.reduce((N,I)=>N+o[I]-this.viewItems[I].minimumSize,0),D=m.length===0?Number.NEGATIVE_INFINITY:m.reduce((N,I)=>N+o[I]-this.viewItems[I].maximumSize,0),E=Math.max(g,D),S=Math.min(T,_);let A=!1;if(u){const N=this.viewItems[u.index],I=r>=u.limitDelta;A=I!==N.visible,N.setVisible(I,u.size)}if(!A&&p){const N=this.viewItems[p.index],I=r<p.limitDelta;A=I!==N.visible,N.setVisible(I,p.size)}if(A)return this.resize(n,r,o,a,l,h,c);const k=Te(r,E,S);let L=0,O=k;for(const N of f){const I=this.viewItems[N],C=o[N],v=Te(C+O,I.minimumSize,I.maximumSize),y=v-C;L+=y,O-=y,I.size=v}let z=L;for(const N of m){const I=this.viewItems[N],C=o[N],v=Te(C-z,I.minimumSize,I.maximumSize),y=v-C;z+=y,I.size=v}return r},this._orientation=(i=t.orientation)!==null&&i!==void 0?i:"VERTICAL",this.element=this.createContainer(),this.margin=(s=t.margin)!==null&&s!==void 0?s:0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((n,r)=>{const o=n.visible===void 0||n.visible?n.size:{type:"invisible",cachedVisibleSize:n.size},a=n.view;this.addView(a,o,r,!0)}),this._contentSize=this.viewItems.reduce((n,r)=>n+r.size,0),this.saveProportions())}style(e){e?.separatorBorder==="transparent"?(Mt(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(Ot(this.element,"dv-separator-border"),e?.separatorBorder&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");const i=this.viewItems[e];i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;const i=Rt(this.viewItems.length).filter(o=>o!==e),s=[...i.filter(o=>this.viewItems[o].priority==="low"),e],n=i.filter(o=>this.viewItems[o].priority==="high"),r=this.viewItems[e];t=Math.round(t),t=Te(t,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=t,this.relayout(s,n)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t=typeof t=="number"?t:e.size,t=Te(t,e.minimumSize,e.maximumSize),e.size=t;const s=Rt(this.viewItems.length).filter(o=>o!==i),n=[...s.filter(o=>this.viewItems[o].priority==="low"),i],r=s.filter(o=>this.viewItems[o].priority==="high");this.relayout([...n,i],r)}addView(e,t=lt.Distribute,i=this.viewItems.length,s){const n=document.createElement("div");n.className="dv-view",n.appendChild(e.element);let r;typeof t=="number"?r=t:t.type==="split"?r=this.getViewSize(t.index)/2:t.type==="invisible"?r={cachedVisibleSize:t.cachedVisibleSize}:r=e.minimumSize;const o=e.onDidChange(l=>this.onDidChange(a,l.size)),a=new W_(n,e,r,{dispose:()=>{o.dispose(),n.remove()}});if(i===this.viewItems.length?this.viewContainer.appendChild(n):this.viewContainer.insertBefore(n,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,a),this.viewItems.length>1){const l=document.createElement("div");l.className="dv-sash";const h=u=>{var p;for(const b of this.viewItems)b.enabled=!1;const f=(p=l.ownerDocument)!==null&&p!==void 0?p:document,m=js(f),g=this._orientation==="HORIZONTAL"?u.clientX:u.clientY,_=$_(this.sashes,b=>b.container===l),T=this.viewItems.map(b=>b.size);let D,E;const S=Rt(_,-1),A=Rt(_+1,this.viewItems.length),k=S.reduce((b,R)=>b+(this.viewItems[R].minimumSize-T[R]),0),L=S.reduce((b,R)=>b+(this.viewItems[R].viewMaximumSize-T[R]),0),O=A.length===0?Number.POSITIVE_INFINITY:A.reduce((b,R)=>b+(T[R]-this.viewItems[R].minimumSize),0),z=A.length===0?Number.NEGATIVE_INFINITY:A.reduce((b,R)=>b+(T[R]-this.viewItems[R].viewMaximumSize),0),N=Math.max(k,z),I=Math.min(O,L),C=this.findFirstSnapIndex(S),v=this.findFirstSnapIndex(A);if(typeof C=="number"){const b=this.viewItems[C],R=Math.floor(b.viewMinimumSize/2);D={index:C,limitDelta:b.visible?N-R:N+R,size:b.size}}if(typeof v=="number"){const b=this.viewItems[v],R=Math.floor(b.viewMinimumSize/2);E={index:v,limitDelta:b.visible?I+R:I-R,size:b.size}}const y=b=>{const R=(this._orientation==="HORIZONTAL"?b.clientX:b.clientY)-g;this.resize(_,R,T,void 0,void 0,N,I,D,E),this.distributeEmptySpace(),this.layoutViews()},x=()=>{for(const b of this.viewItems)b.enabled=!0;m.release(),this.saveProportions(),f.removeEventListener("pointermove",y),f.removeEventListener("pointerup",x),f.removeEventListener("pointercancel",x),f.removeEventListener("contextmenu",x),this._onDidSashEnd.fire(void 0)};f.addEventListener("pointermove",y),f.addEventListener("pointerup",x),f.addEventListener("pointercancel",x),f.addEventListener("contextmenu",x)};l.addEventListener("pointerdown",h);const c={container:l,disposable:()=>{l.removeEventListener("pointerdown",h),l.remove()}};this.sashContainer.appendChild(l),this.sashes.push(c)}s||this.relayout([i]),!s&&typeof t!="number"&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const o of this.viewItems)o.maximumSize-o.minimumSize>0&&(e.push(o),t+=o.size);const i=Math.floor(t/e.length);for(const o of e)o.size=Te(i,o.minimumSize,o.maximumSize);const s=Rt(this.viewItems.length),n=s.filter(o=>this.viewItems[o].priority==="low"),r=s.filter(o=>this.viewItems[o].priority==="high");this.relayout(n,r)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const n=Math.max(e-1,0);this.sashes.splice(n,1)[0].disposable()}return i||this.relayout(),t?.type==="distribute"&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),s=i===void 0?this.getViewSize(e):lt.Invisible(i),n=this.removeView(e,void 0,!0);this.addView(n,s,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let s=0;for(let n=0;n<this.viewItems.length;n++){const r=this.viewItems[n],o=this.proportions[n];typeof o=="number"?s+=o:e-=r.size}for(let n=0;n<this.viewItems.length;n++){const r=this.viewItems[n],o=this.proportions[n];typeof o=="number"&&s>0&&(r.size=Te(Math.round(o*e/s),r.minimumSize,r.maximumSize))}}else{const s=Rt(this.viewItems.length),n=s.filter(o=>this.viewItems[o].priority==="low"),r=s.filter(o=>this.viewItems[o].priority==="high");this.resize(this.viewItems.length-1,e-i,void 0,n,r)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((s,n)=>s+n.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=0;for(const r of this.viewItems)t+=r.size;let i=this.size-t;if(i===0)return;const s=Rt(this.viewItems.length-1,-1);let n=!1;for(const r of this.viewItems)if(r.priority==="low"||r.priority==="high"){n=!0;break}if(n){const r=s.filter(a=>this.viewItems[a].priority==="low"),o=s.filter(a=>this.viewItems[a].priority==="high");for(const a of o)yr(s,a);for(const a of r)an(s,a)}typeof e=="number"&&an(s,e);for(let r=0;i!==0&&r<s.length;r++){const o=this.viewItems[s[r]],a=Te(o.size+i,o.minimumSize,o.maximumSize),l=a-o.size;i-=l,o.size=a}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){let e=0,t=0;for(const l of this.viewItems)e+=l.size,l.visible&&t++;if(this._contentSize=e,this.updateSashEnablement(),this.viewItems.length===0)return;const i=Math.max(0,t-1),s=this.margin*i/Math.max(1,t);let n=0;const r=[],o=4;let a=0;this.viewItems.forEach((l,h)=>{n+=this.viewItems[h].size,r.push(n),a+=l.visible?1:0;const c=l.visible?l.size-s:0,u=Math.max(0,a-1),p=h===0||u===0?0:r[h-1]+u/i*s;if(h<this.viewItems.length-1){const f=l.visible?p+c-o/2+this.margin/2:p,m=this.sashes[h];this._orientation==="HORIZONTAL"&&Zl(m,`${f}px`,"0px"),this._orientation==="VERTICAL"&&Zl(m,"0px",`${f}px`)}this._orientation==="HORIZONTAL"&&(l.setContainerGeometry("width",`${c}px`),l.setContainerGeometry("left",`${p}px`),l.setContainerGeometry("top",""),l.setContainerGeometry("height","")),this._orientation==="VERTICAL"&&(l.setContainerGeometry("height",`${c}px`),l.setContainerGeometry("top",`${p}px`),l.setContainerGeometry("width",""),l.setContainerGeometry("left","")),l.view.layout(l.size-s,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const i=this.viewItems[t];if(i.visible&&i.snap)return t}for(const t of e){const i=this.viewItems[t];if(i.visible&&i.maximumSize-i.minimumSize>0)return;if(!i.visible&&i.snap)return t}}updateSashEnablement(){if(this.sashes.length===0)return;let e=!1;const t=this.viewItems.map(a=>e=a.size-a.minimumSize>0||e);e=!1;const i=this.viewItems.map(a=>e=a.maximumSize-a.size>0||e),s=[...this.viewItems].reverse();e=!1;const n=s.map(a=>e=a.size-a.minimumSize>0||e).reverse();e=!1;const r=s.map(a=>e=a.maximumSize-a.size>0||e).reverse();let o=0;for(let a=0;a<this.sashes.length;a++){const l=this.sashes[a],h=this.viewItems[a];o+=h.size;const c=!(t[a]&&r[a+1]),u=!(i[a]&&n[a+1]);if(c&&u){const p=Rt(a,-1),f=Rt(a+1,this.viewItems.length),m=this.findFirstSnapIndex(p),g=this.findFirstSnapIndex(f),_=typeof m=="number"&&!this.viewItems[m].visible,T=typeof g=="number"&&!this.viewItems[g].visible;_&&n[a]&&(o>0||this.startSnappingEnabled)?this.updateSash(l,1):T&&t[a]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(l,0):this.updateSash(l,2)}else c&&!u?this.updateSash(l,1):!c&&u?this.updateSash(l,0):this.updateSash(l,3)}}updateSash(e,t){Y(e.container,"dv-disabled",t===2),Y(e.container,"dv-enabled",t===3),Y(e.container,"dv-maximum",t===0),Y(e.container,"dv-minimum",t===1)}createViewContainer(){const e=document.createElement("div");return e.className="dv-view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="dv-sash-container",e}createContainer(){const e=document.createElement("div");return e.className=`dv-split-view-container ${this._orientation==="HORIZONTAL"?"dv-horizontal":"dv-vertical"}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.remove();break}for(const e of this.viewItems)e.dispose();this.element.remove()}};const oo=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0});var Ql=class extends te{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orientation=(i=t.orientation)!==null&&i!==void 0?i:"VERTICAL",this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new Hi(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(s=>{const n=new te(s.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),r={pane:s,disposable:{dispose:()=>{n.dispose()}}};this.paneItems.push(r),s.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,i=this.splitview.length,s=!1){const n=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),r={pane:e,disposable:{dispose:()=>{n.dispose()}}};this.paneItems.splice(i,0,r),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getViewCachedVisibleSize(e){return this.splitview.getViewCachedVisibleSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t?.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});i.disposable.dispose(),this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),Ot(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,Mt(this.element,"dv-animated")},200))}dispose(){super.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},st=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation==="HORIZONTAL"?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation==="HORIZONTAL"?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation==="HORIZONTAL"?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation==="HORIZONTAL"?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation==="HORIZONTAL"?this.orthogonalSize:this.size}get height(){return this.orientation==="HORIZONTAL"?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange(n=>{n?this._onDidChange.fire({size:this.orientation==="VERTICAL"?n.width:n.height,orthogonalSize:this.orientation==="VERTICAL"?n.height:n.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},qe=class ao extends te{get width(){return this.orientation==="HORIZONTAL"?this.size:this.orthogonalSize}get height(){return this.orientation==="HORIZONTAL"?this.orthogonalSize:this.size}get minimumSize(){if(this._cachedMinimumSize===void 0){let t=0;for(let i=0;i<this.children.length;i++)this.splitview.isViewVisible(i)&&(t=Math.max(t,this.children[i].minimumOrthogonalSize));this._cachedMinimumSize=t}return this._cachedMinimumSize}get maximumSize(){if(this._cachedMaximumSize===void 0){let t=Number.POSITIVE_INFINITY;for(let i=0;i<this.children.length;i++)this.splitview.isViewVisible(i)&&(t=Math.min(t,this.children[i].maximumOrthogonalSize));this._cachedMaximumSize=t}return this._cachedMaximumSize}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation==="HORIZONTAL"?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation==="HORIZONTAL"?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation==="HORIZONTAL"?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation==="HORIZONTAL"?this.maximumSize:this.maximumOrthogonalSize}get priority(){var t;return(t=this._cachedPriority)!==null&&t!==void 0||(this._cachedPriority=this.computePriority()),this._cachedPriority}computePriority(){if(this.children.length===0)return"normal";let t=!1,i=!1;for(const n of this.children){var s;const r=(s=n.priority)!==null&&s!==void 0?s:"normal";r==="high"?t=!0:r==="low"&&(i=!0)}return t?"high":i?"low":"normal"}invalidateCachedSizes(){this._cachedMinimumSize=void 0,this._cachedMaximumSize=void 0,this._cachedPriority=void 0}get disabled(){return this.splitview.disabled}set disabled(t){this.splitview.disabled=t}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(i=>{i instanceof ao&&(i.margin=t)})}constructor(t,i,s,n,r,o,a,l){if(super(),this.orientation=t,this.proportionalLayout=i,this.styles=s,this._childrenDisposable=xe.NONE,this.children=[],this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new G,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=r,this._size=n,this.element=document.createElement("div"),this.element.className="dv-branch-node",l){const h={views:l.map(c=>{var u;return{view:c.node,size:c.node.size,visible:(u=c.visible)!==null&&u!==void 0?u:!0}}),size:this.orthogonalSize};this.children=l.map(c=>c.node),this.splitview=new Hi(this.element,{orientation:this.orientation,descriptor:h,proportionalLayout:i,styles:s,margin:a})}else this.splitview=new Hi(this.element,{orientation:this.orientation,proportionalLayout:i,styles:s,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=o,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(t){}isChildVisible(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.isViewVisible(t)}setChildVisible(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");if(this.splitview.isViewVisible(t)===i)return;const s=this.splitview.contentSize===0;this.splitview.setViewVisible(t,i),this.invalidateCachedSizes();const n=this.splitview.contentSize===0;(i&&s||!i&&n)&&this._onDidVisibilityChange.fire({visible:i})}moveChild(t,i){if(t===i)return;if(t<0||t>=this.children.length)throw new Error("Invalid from index");t<i&&i--,this.splitview.moveView(t,i);const s=this._removeChild(t);this._addChild(s,i)}getChildSize(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(t)}resizeChild(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(t,i)}layout(t,i){this._size=i,this._orthogonalSize=t,this.splitview.layout(i,t)}addChild(t,i,s,n){if(s<0||s>this.children.length)throw new Error("Invalid index");this.splitview.addView(t,i,s,n),this._addChild(t,s)}getChildCachedVisibleSize(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(t)}removeChild(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(t,i),this._removeChild(t)}_addChild(t,i){this.children.splice(i,0,t),this.setupChildrenEvents()}_removeChild(t){const[i]=this.children.splice(t,1);return this.setupChildrenEvents(),i}setupChildrenEvents(){this.invalidateCachedSizes(),this._childrenDisposable.dispose(),this._childrenDisposable=new te(Tt.any(...this.children.map(t=>t.onDidChange))(t=>{this.invalidateCachedSizes(),this._onDidChange.fire({size:t.orthogonalSize})}),...this.children.map((t,i)=>t instanceof ao?t.onDidVisibilityChange(({visible:s})=>{this.setChildVisible(i,s)}):xe.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(t=>t.dispose()),super.dispose()}};function lo(e,t){if(e instanceof st)return e;if(e instanceof qe)return lo(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function Qc(e,t,i){if(e instanceof qe){const s=new qe(e.orientation,e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);for(let n=e.children.length-1;n>=0;n--){const r=e.children[n];s.addChild(Qc(r,r.size,r.orthogonalSize),r.size,0,!0)}return s}else return new st(e.view,e.orientation,i)}function ho(e,t,i){if(e instanceof qe){const s=new qe(Ft(e.orientation),e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);let n=0;for(let r=e.children.length-1;r>=0;r--){const o=e.children[r],a=o instanceof qe?o.orthogonalSize:o.size;let l=e.size===0?0:Math.round(t*a/e.size);n+=l,r===0&&(l+=t-n),s.addChild(ho(o,i,l),l,0,!0)}return s}else return new st(e.view,Ft(e.orientation),i)}function H_(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function Ce(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=H_(t),s=t.parentElement.parentElement.parentElement;return[...Ce(s),i]}function Dt(e,t,i){if(V_(e,t)===F_(i)){const[s,n]=ri(t);let r=n;return(i==="right"||i==="bottom")&&(r+=1),[...s,r]}else{const s=i==="right"||i==="bottom"?1:0;return[...t,s]}}function F_(e){return e==="top"||e==="bottom"?"VERTICAL":"HORIZONTAL"}function V_(e,t){return t.length%2===0?Ft(e):e}const Ft=e=>e==="HORIZONTAL"?"VERTICAL":"HORIZONTAL";function U_(e){return!!e.children}const co=(e,t)=>{const i=t==="VERTICAL"?e.box.width:e.box.height;if(!U_(e))return typeof e.cachedVisibleSize=="number"?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i};const s=e.children.map(n=>co(n,Ft(t)));return typeof e.cachedVisibleSize=="number"?{type:"branch",data:s,size:e.cachedVisibleSize,visible:!1}:{type:"branch",data:s,size:i}};var eu=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=ho(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumWidth}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;const t=[this.root];for(;t.length>0;){const i=t.pop();i instanceof qe&&(i.disabled=e,t.push(...i.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){var e;return(e=this._maximizedNode)===null||e===void 0?void 0:e.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){var t;const i=Ce(e.element),[s,n]=this.getNode(i);if(!(n instanceof st)||((t=this._maximizedNode)===null||t===void 0?void 0:t.leaf)===n)return;this.hasMaximizedView()&&this.exitMaximizedView(),co(this.getView(),this.orientation);const r=[];function o(a,l){for(let h=0;h<a.children.length;h++){const c=a.children[h];c instanceof st?c!==l&&(a.isChildVisible(h)?a.setChildVisible(h,!1):r.push(c)):o(c,l)}}o(this.root,n),this._maximizedNode={leaf:n,hiddenOnMaximize:r},this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;function t(s){for(let n=s.children.length-1;n>=0;n--){const r=s.children[n];r instanceof st?e.includes(r)||s.setChildVisible(n,!0):t(r)}}t(this.root);const i=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:i.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=Ce(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const s={root:co(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(s.maximizedNode={location:t}),e&&this.maximizeView(e),s}finally{i.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new qe(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,s=i==="VERTICAL"?e.height:e.width;if(this._deserialize(e.root,i,t,s),this.layout(e.width,e.height),e.maximizedNode){const n=e.maximizedNode.location,[r,o]=this.getNode(n);if(!(o instanceof st))return;this.maximizeView(o.view)}}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){let n;if(e.type==="branch"){const o=e.data.map(a=>({node:this._deserializeNode(a,Ft(t),i,e.size),visible:a.visible}));n=new qe(t,this.proportionalLayout,this.styles,e.size,s,this.locked,this.margin,o)}else{const o=i.fromJSON(e);if(typeof e.visible=="boolean"){var r;(r=o.setVisible)===null||r===void 0||r.call(o,e.visible)}n=new st(o,t,s,e.size)}return n}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,t.element.remove()),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(i=>{this._onDidChange.fire(i)})}normalize(){if(!this._root||this._root.children.length!==1)return;const e=this.root,t=e.children[0];if(t instanceof st)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=Qc(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(s=>{this._onDidChange.fire(s)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const e=this.root;if(e.element.remove(),this._root=new qe(Ft(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(ho(t,t.orthogonalSize,t.size),lt.Distribute,0)}else this._root.addChild(e,lt.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(t=>{this._onDidChange.fire(t)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const s={height:e.height,width:e.width};if(e instanceof st)return{box:s,view:e.view,cachedVisibleSize:i};const n=[];for(let r=0;r<e.children.length;r++){const o=e.children[r],a=e.getChildCachedVisibleSize(r);n.push(this._getViews(o,Ft(t),a))}return{box:s,children:n,cachedVisibleSize:i}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof st))throw new TypeError("invalid location");for(let n=i.length-1;n>-1;n--){const r=i[n],o=e[n]||0;if(t?o-1>-1:o+1<r.children.length)return lo(r.children[t?o-1:o+1],t)}return lo(this.root,t)}constructor(e,t,i,s,n){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new Ge,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new G,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new G,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=s??!1,this._margin=n??0,this.root=new qe(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=ri(e),[,s]=this.getNode(t);if(!(s instanceof qe))throw new TypeError("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=ri(e),[,n]=this.getNode(i);if(!(n instanceof qe))throw new TypeError("Invalid from location");this._onDidViewVisibilityChange.fire(),n.setChildVisible(s,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,s]=this.getNode(e);if(!(s instanceof qe))throw new TypeError("Invalid location");s.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,n]=ri(i),[r,o]=this.getNode(s);if(o instanceof qe){const a=new st(e,Ft(o.orientation),o.orthogonalSize);o.addChild(a,t,n)}else{const[a,...l]=[...r].reverse(),[h,...c]=[...s].reverse();let u=0;const p=a.getChildCachedVisibleSize(h);typeof p=="number"&&(u=lt.Invisible(p)),a.removeChild(h).dispose();const f=new qe(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);a.addChild(f,o.size,h);const m=new st(o.view,a.orientation,o.size);f.addChild(m,u,0),typeof t!="number"&&t.type==="split"&&(t={type:"split",index:0});const g=new st(e,a.orientation,o.size);f.addChild(g,t,n)}}remove(e,t){const i=Ce(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=ri(e),[n,r]=this.getNode(i);if(!(r instanceof qe))throw new TypeError("Invalid location");const o=r.children[s];if(!(o instanceof st))throw new TypeError("Invalid location");if(r.removeChild(s,t),o.dispose(),r.children.length!==1)return o.view;const a=r.children[0];if(n.length===0)return a instanceof st||(r.removeChild(0,t),this.root=a),o.view;const[l,...h]=[...n].reverse(),[c,...u]=[...i].reverse(),p=r.isChildVisible(0);r.removeChild(0,t);const f=l.children.map((m,g)=>l.getChildSize(g));if(l.removeChild(c,t).dispose(),a instanceof qe){f.splice(c,1,...a.children.map(m=>m.size));for(let m=0;m<a.children.length;m++){const g=a.children[m];l.addChild(g,g.size,c+m)}for(;a.children.length>0;)a.removeChild(0)}else{const m=new st(a.view,Ft(a.orientation),a.size),g=p?a.orthogonalSize:lt.Invisible(a.orthogonalSize);l.addChild(m,g,c)}a.dispose();for(let m=0;m<f.length;m++)l.resizeChild(m,f[m]);return o.view}layout(e,t){const[i,s]=this.root.orientation==="HORIZONTAL"?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(e.length===0)return[i,t];if(!(t instanceof qe))throw new TypeError("Invalid location");const[s,...n]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const r=t.children[s];return i.push(t),this.getNode(n,r,i)}};const uo=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0});var Ba=class extends te{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(Ui(this._element,i=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!Yc(this._element))return;const s=Math.round(i.contentRect.width),n=Math.round(i.contentRect.height);s===this._lastWidth&&n===this._lastHeight||(this._lastWidth=s,this._lastHeight=n,this.layout(s,n))}))}};const K_=ja();function zn(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}var tu=class extends Ba{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=K_.next(),this._groups=new Map,this._onDidRemove=new G,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new G,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new G,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new G,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new Xl,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new Xl,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new rr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this.gridview=new eu(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(s=>{this._onDidMaximizedChange.fire({panel:s.view,isMaximized:s.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),xe.from(()=>{this.element.remove()}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),Tt.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Ce(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Ce(e.element))}updateOptions(e){if(e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableAutoResizing"in e){var t;this.disableResizing=(t=e.disableAutoResizing)!==null&&t!==void 0?t:!1}if("locked"in e){var i;this.locked=(i=e.locked)!==null&&i!==void 0?i:!1}if("margin"in e){var s;this.gridview.margin=(s=e.margin)!==null&&s!==void 0?s:0}if("className"in e){var n;this._classNames.setClassNames((n=e.className)!==null&&n!==void 0?n:"")}}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],i,s=this.gridview){s.addView(e,i??lt.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,lt.Distribute);if(i&&!t?.skipDispose&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){const n=Array.from(this._groups.values());this.doSetGroupActive(n.length>0?n[0].value:void 0)}return s}getPanel(e){var t;return(t=this._groups.get(e))===null||t===void 0?void 0:t.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}activateNext(e){var t,i;if((t=e)!==null&&t!==void 0||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const s=Ce(e.group.element),n=(i=this.gridview.next(s))===null||i===void 0?void 0:i.view;this.doSetGroupActive(n)}activatePrevious(e){var t,i;if((t=e)!==null&&t!==void 0||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const s=Ce(e.group.element),n=(i=this.gridview.previous(s))===null||i===void 0?void 0:i.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}};function Bs(e){"@babel/helpers - typeof";return Bs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bs(e)}function q_(e,t){if(Bs(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,t);if(Bs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Y_(e){var t=q_(e,"string");return Bs(t)=="symbol"?t:t+""}function X_(e,t,i){return(t=Y_(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function eh(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),i.push.apply(i,s)}return i}function se(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?eh(Object(i),!0).forEach(function(s){X_(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):eh(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function J_(e,t){return e==="center"?`Tab into ${t}`:`Split ${e} of ${t}`}function Z_(e,t){return e==="center"?`docked into ${t}`:`split ${e} of ${t}`}const jn={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,closeTab:e=>`Close ${e}`,closeTabPlain:()=>"Close",movePickTarget:(e,t,i,s)=>`Moving ${e}. Target ${t}, ${i} of ${s}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${J_(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,i)=>`${e} ${Z_(i,t)}.`,moveCancelled:()=>"Move cancelled.",moveNotAllowed:()=>"That move is not allowed.",moveFloated:e=>`${e} floated.`};function iu(e){return e?se(se({},jn),e):jn}var su=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},$s=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},nu=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},$a=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidPanelPinnedChange(){return this.component.onDidPanelPinnedChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}get messages(){return iu(this.component.options.messages)}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.withOrigin("api",()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin("api",()=>this.component.removePanel(e))}addGroup(e){return this.component.withOrigin("api",()=>this.component.addGroup(e))}closeAllGroups(){return this.component.withOrigin("api",()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin("api",()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin("api",()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin("api",()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin("api",()=>this.component.clear())}undo(){this.component.undo()}redo(){this.component.redo()}get canUndo(){return this.component.canUndo}get canRedo(){return this.component.canRedo}clearHistory(){this.component.clearHistory()}get onDidChangeHistory(){return this.component.onDidChangeHistory}get smartGuidesEnabled(){return this.component.smartGuidesEnabled}setSmartGuidesEnabled(e){this.component.setSmartGuidesEnabled(e)}updateSmartGuidesOptions(e){this.component.updateSmartGuidesOptions(e)}get onDidSnapFloat(){return this.component.onDidSnapFloat}get onDidSnapTogether(){return this.component.onDidSnapTogether}get popoutRestorationPromise(){return this.component.popoutRestorationPromise}activateNext(e){this.component.activateNext(e)}activatePrevious(e){this.component.activatePrevious(e)}moveToNext(e){this.activateNext(e)}moveToPrevious(e){this.activatePrevious(e)}maximizeGroup(e){this.component.withOrigin("api",()=>this.component.maximizeGroup(e.group))}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.withOrigin("api",()=>this.component.exitMaximizedGroup())}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin("api",()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}revealEdgeGroupWithData(e,t,i){this.component.revealEdgeGroupWithData(e,t,i)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}pinEdgeGroup(e){this.component.pinEdgeGroup(e)}autoHideEdgeGroup(e){this.component.autoHideEdgeGroup(e)}peekEdgeGroup(e,t){this.component.peekEdgeGroup(e,t)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){const t=this.component.getPanel(e);if(!t)throw new Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){const t=this._getGroupModel(e.groupId);return this.component.withOrigin("api",()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},ru=class extends te{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(Z(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(Z(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(Z(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(Z(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(Z(this.element,"drop",e=>{this.onDrop(e)}))}};const Q_={value:50,type:"percentage"},eb=100,tb=100;function po(){const e=document.createElement("div");e.className="dv-drop-target-dropzone";const t=document.createElement("div");return t.className="dv-drop-target-selection",e.appendChild(t),{dropzone:e,selection:t}}function ou(e,t,i,s){var n,r,o;const a=(n=s?.smallWidthBoundary)!==null&&n!==void 0?n:eb,l=(r=s?.smallHeightBoundary)!==null&&r!==void 0?r:tb,h=t<a,c=i<l,u=e==="left",p=e==="right",f=e==="top",m=e==="bottom",g=!h&&p,_=!h&&u,T=!c&&f,D=!c&&m;let E=1;const S=(o=s?.size)!==null&&o!==void 0?o:Q_;return S.type==="percentage"?E=Te(S.value,0,100)/100:((g||_)&&(E=Te(0,S.value,t)/t),(T||D)&&(E=Te(0,S.value,i)/i)),{isSmallX:h,isSmallY:c,isLeft:u,isRight:p,isTop:f,isBottom:m,rightClass:g,leftClass:_,topClass:T,bottomClass:D,size:E}}function au(e,t,i,s,n){const r=ou(t,i,s,n),{rightClass:o,leftClass:a,topClass:l,bottomClass:h,size:c}=r,u={top:"0px",left:"0px",width:"100%",height:"100%"};o?(u.left=`${100*(1-c)}%`,u.width=`${100*c}%`):a?u.width=`${100*c}%`:l?u.height=`${100*c}%`:h&&(u.top=`${100*(1-c)}%`,u.height=`${100*c}%`),r.isSmallX&&r.isLeft&&(u.width="4px"),r.isSmallX&&r.isRight&&(u.left=`${i-4}px`,u.width="4px"),r.isSmallY&&r.isTop&&(u.height="4px"),r.isSmallY&&r.isBottom&&(u.top=`${s-4}px`,u.height="4px"),e.style.top=u.top,e.style.left=u.left,e.style.width=u.width,e.style.height=u.height,e.style.visibility="visible",(!e.style.transform||e.style.transform==="")&&(e.style.transform="translate3d(0, 0, 0)");const p=r.isSmallX&&(r.isLeft||r.isRight)||r.isSmallY&&(r.isTop||r.isBottom);Y(e,"dv-drop-target-small-vertical",r.isSmallY),Y(e,"dv-drop-target-small-horizontal",r.isSmallX),Y(e,"dv-drop-target-selection-line",p),Y(e,"dv-drop-target-left",r.isLeft),Y(e,"dv-drop-target-right",r.isRight),Y(e,"dv-drop-target-top",r.isTop),Y(e,"dv-drop-target-bottom",r.isBottom),Y(e,"dv-drop-target-center",t==="center")}function ib(e,t){const i=`${Math.round(t.top)}px`,s=`${Math.round(t.left)}px`,n=`${Math.round(t.width)}px`,r=`${Math.round(t.height)}px`;return e.style.top!==i||e.style.left!==s||e.style.width!==n||e.style.height!==r}function sb(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility="visible",(!e.style.transform||e.style.transform==="")&&(e.style.transform="translate3d(0, 0, 0)")}function lu(e){const t=ou(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:i,leftClass:s,topClass:n,bottomClass:r,size:o}=t,a=e.outlineElement.getBoundingClientRect(),l=e.targetModel.getElements(void 0,e.outlineElement),h=l.root,c=l.overlay,u=h.getBoundingClientRect(),p=a.top-u.top,f=a.left-u.left,m={top:p,left:f,width:e.width,height:e.height};return i?(m.left=f+e.width*(1-o),m.width=e.width*o):s?m.width=e.width*o:n?m.height=e.height*o:r&&(m.top=p+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=f+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=p+e.height-4,m.height=4),ib(c,m)?(sb(c,m),c.className=`dv-drop-target-anchor${e.className?` ${e.className}`:""}`,Y(c,"dv-drop-target-left",t.isLeft),Y(c,"dv-drop-target-right",t.isRight),Y(c,"dv-drop-target-top",t.isTop),Y(c,"dv-drop-target-bottom",t.isBottom),Y(c,"dv-drop-target-anchor-line",t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),Y(c,"dv-drop-target-center",e.quadrant==="center"),l.changed&&(Y(c,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{Y(c,"dv-drop-target-anchor-container-changed",!1)},10)),{boundsChanged:!0,targetChanged:l.changed}):{boundsChanged:!1,targetChanged:l.changed}}var hu=class extends za{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get edge(){return!!this.options.edge}get edgeGroup(){return!!this.options.edgeGroup}constructor(e){super(),this.options=e}};function th(e){switch(e){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${e}'`)}}function nb(e){switch(e){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${e}'`)}}const rb={value:20,type:"percentage"};var or=class Es extends te{get disabled(){return this._disabled}set disabled(t){this._disabled=t}get state(){return this._state}constructor(t,i){super(),this.element=t,this.options=i,this._edge=!1,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new ru(this.element,{onDragEnter:()=>{var s,n;(s=(n=this.options).getOverrideTarget)===null||s===void 0||(s=s.call(n))===null||s===void 0||s.getElements()},onDragOver:s=>{var n,r,o,a,l,h,c;if(this._disabled){this.clearOwnOverlay();return}Es.ACTUAL_TARGET=this;const u=(n=(r=this.options).getOverrideTarget)===null||n===void 0?void 0:n.call(r);if(this._acceptedTargetZonesSet.size===0){this.clearOwnOverlay();return}const p=(o=(a=(l=this.options).getOverlayOutline)===null||a===void 0?void 0:a.call(l))!==null&&o!==void 0?o:this.element,f=p.offsetWidth,m=p.offsetHeight;if(f===0||m===0)return;const g=p.getBoundingClientRect(),_=((h=s.clientX)!==null&&h!==void 0?h:0)-g.left,T=((c=s.clientY)!==null&&c!==void 0?c:0)-g.top,D=this.resolvePosition(_,T,f,m,s);if(this.isAlreadyUsed(s)){this.removeDropTarget();return}if(D===null){this.clearOwnOverlay();return}const E=D.position;if(!this.options.canDisplayOverlay(s,E)){this.clearOwnOverlay();return}const S=new hu({nativeEvent:s,position:E,edge:D.edge,edgeGroup:D.edgeGroup});if(this._onWillShowOverlay.fire(S),S.defaultPrevented){this.clearOwnOverlay();return}if(this.markAsUsed(s),D.edge){this.clearOwnOverlay(),this._state=E,this._edge=!0;return}if(this._edge=!1,!u){if(!this.targetElement){const A=po();this.targetElement=A.dropzone,this.overlayElement=A.selection,this._state="center",p.classList.add("dv-drop-target"),p.append(this.targetElement)}}this.toggleClasses(E,f,m),this._state=E},onDragLeave:()=>{var s,n;const r=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);if(r){var o;this._state=void 0,this._edge=!1,(o=r.scheduleClear)===null||o===void 0||o.call(r);return}this.removeDropTarget()},onDragEnd:s=>{var n,r;const o=(n=(r=this.options).getOverrideTarget)===null||n===void 0?void 0:n.call(r);o&&Es.ACTUAL_TARGET===this&&this._state&&(s.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:s,edge:this._edge})),this.removeDropTarget(),o?.clear()},onDrop:s=>{var n,r;s.preventDefault();const o=this._state,a=this._edge;this.removeDropTarget(),(n=(r=this.options).getOverrideTarget)===null||n===void 0||(n=n.call(r))===null||n===void 0||n.clear(),o&&(s.stopPropagation(),this._onDrop.fire({position:o,nativeEvent:s,edge:a}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(t){this._acceptedTargetZonesSet=new Set(t)}setOverlayModel(t){this.options.overlayModel=t}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[Es.USED_EVENT_ID]=!0}isAlreadyUsed(t){const i=t[Es.USED_EVENT_ID];return typeof i=="boolean"&&i}toggleClasses(t,i,s){var n,r;const o=(n=(r=this.options).getOverrideTarget)===null||n===void 0?void 0:n.call(r);if(o){var a,l,h;lu({outlineElement:(a=(l=(h=this.options).getOverlayOutline)===null||l===void 0?void 0:l.call(h))!==null&&a!==void 0?a:this.element,targetModel:o,quadrant:t,width:i,height:s,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&au(this.overlayElement,t,i,s,this.options.overlayModel)}resolvePosition(t,i,s,n,r){var o,a;const l=(o=(a=this.options).getPositionResolver)===null||o===void 0?void 0:o.call(a);if(l){const c=l.resolve({x:t,y:i,width:s,height:n,zones:this._acceptedTargetZonesSet,event:r});return c?{position:c.position,edge:!!c.edge,edgeGroup:!!c.edgeGroup}:null}const h=this.calculateQuadrant(this._acceptedTargetZonesSet,t,i,s,n);return h?{position:h,edge:!1,edgeGroup:!1}:null}calculateQuadrant(t,i,s,n,r){var o,a;const l=(o=(a=this.options.overlayModel)===null||a===void 0?void 0:a.activationSize)!==null&&o!==void 0?o:rb;return l.type==="percentage"?du(t,i,s,n,r,l.value):cu(t,i,s,n,r,l.value)}clearOwnOverlay(){const t=this._state!==void 0;if(this.removeDropTarget(),t){var i,s;(i=(s=this.options).getOverrideTarget)===null||i===void 0||(i=i.call(s))===null||i===void 0||i.clear()}}removeDropTarget(){if(this._state=void 0,this._edge=!1,this.targetElement){var t;(t=this.targetElement.parentElement)===null||t===void 0||t.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0}}showOverlay(t){var i,s,n,r,o;const a=(i=(s=this.options).getOverrideTarget)===null||i===void 0?void 0:i.call(s),l=(n=(r=(o=this.options).getOverlayOutline)===null||r===void 0?void 0:r.call(o))!==null&&n!==void 0?n:this.element,h=l.offsetWidth,c=l.offsetHeight;if(!a&&!this.targetElement){const u=po();this.targetElement=u.dropzone,this.overlayElement=u.selection,l.classList.add("dv-drop-target"),l.append(this.targetElement)}this.toggleClasses(t,h,c),this._state=t}clearOverlay(){var t,i;this.removeDropTarget(),(t=(i=this.options).getOverrideTarget)===null||t===void 0||(t=t.call(i))===null||t===void 0||t.clear(),this._state=void 0}};or.USED_EVENT_ID="__dockview_droptarget_event_is_used__";function du(e,t,i,s,n,r){const o=100*t/s,a=100*i/n;return e.has("left")&&o<r?"left":e.has("right")&&o>100-r?"right":e.has("top")&&a<r?"top":e.has("bottom")&&a>100-r?"bottom":e.has("center")?"center":null}function cu(e,t,i,s,n,r){return e.has("left")&&t<r?"left":e.has("right")&&t>s-r?"right":e.has("top")&&i<r?"top":e.has("bottom")&&i>n-r?"bottom":e.has("center")?"center":null}function ob(e,t,i){var s,n,r;Ot(t,"dv-dragged"),t.style.top="-9999px",((s=i?.ownerDocument)!==null&&s!==void 0?s:document).body.appendChild(t),e.setDragImage(t,(n=i?.x)!==null&&n!==void 0?n:0,(r=i?.y)!==null&&r!==void 0?r:0),setTimeout(()=>{Mt(t,"dv-dragged"),t.remove()},0)}var Bn=class Ts extends te{static getInstance(){var t;return(t=Ts._instance)!==null&&t!==void 0||(Ts._instance=new Ts),Ts._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._onDragMove=new G,this.onDragMove=this._onDragMove.event,this._onDragEnd=new G,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(t){return this._targets.add(t),this._targetByElement.set(t.element,t),{dispose:()=>{this._targets.delete(t),this._targetByElement.get(t.element)===t&&this._targetByElement.delete(t.element),this._currentTarget===t&&(this._currentTarget=void 0)}}}beginDrag(t){var i,s,n;this._active&&this.cancel();const{pointerEvent:r,source:o}=t,a=t.getData();this._active={pointerId:r.pointerId,startX:r.clientX,startY:r.clientY,source:o},this._lastPointerEvent=r,this._onDragMoveCallback=t.onDragMove,this._onDragEndCallback=t.onDragEnd,this._dataDisposable=a,this._ghost=t.ghost,this._iframeShield=js((i=o.ownerDocument)!==null&&i!==void 0?i:document);const l={clientX:r.clientX,clientY:r.clientY,pointerEvent:r};this._onDragStart.fire(l);const h=(s=(n=o.ownerDocument)===null||n===void 0?void 0:n.defaultView)!==null&&s!==void 0?s:globalThis.window;this._moveListener=Z(h,"pointermove",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleMove(c)}),this._upListener=Z(h,"pointerup",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleEnd(c,!0)}),this._cancelListener=Z(h,"pointercancel",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleEnd(c,!1)})}cancel(){var t,i;if(!this._active)return;const s=this._onDragEndCallback,n=this._lastPointerEvent;if((t=this._currentTarget)===null||t===void 0||t.handleDragLeave(),this._teardown(),(i=this._dataDisposable)===null||i===void 0||i.dispose(),this._dataDisposable=void 0,n){const r={clientX:n.clientX,clientY:n.clientY,pointerEvent:n};s?.(r,!1),this._onDragEnd.fire(r)}}_findTargetUnder(t,i){var s,n;const r=((s=(n=this._active)===null||n===void 0?void 0:n.source.ownerDocument)!==null&&s!==void 0?s:document).elementsFromPoint(t,i);for(const o of r){let a=o;for(;a;){const l=this._targetByElement.get(a);if(l)return l;a=a.parentElement}}}_handleMove(t){var i,s;this._lastPointerEvent=t,(i=this._ghost)===null||i===void 0||i.update(t.clientX,t.clientY);const n={clientX:t.clientX,clientY:t.clientY,pointerEvent:t},r=this._findTargetUnder(t.clientX,t.clientY);if(r!==this._currentTarget){var o;(o=this._currentTarget)===null||o===void 0||o.handleDragLeave(),this._currentTarget=r}r&&r.handleDragOver(n),(s=this._onDragMoveCallback)===null||s===void 0||s.call(this,n),this._onDragMove.fire(n)}_handleEnd(t,i){const s={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};if(i&&this._currentTarget)this._currentTarget.handleDrop(s);else{var n;(n=this._currentTarget)===null||n===void 0||n.handleDragLeave()}const r=this._onDragEndCallback,o=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>o?.dispose(),0),r?.(s,i),this._onDragEnd.fire(s)}_teardown(){var t,i,s,n,r;this._currentTarget=void 0,this._active=void 0,this._lastPointerEvent=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(t=this._ghost)===null||t===void 0||t.dispose(),this._ghost=void 0,(i=this._iframeShield)===null||i===void 0||i.release(),this._iframeShield=void 0,(s=this._moveListener)===null||s===void 0||s.dispose(),(n=this._upListener)===null||n===void 0||n.dispose(),(r=this._cancelListener)===null||r===void 0||r.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}};const ab={value:20,type:"percentage"};var lb=class extends te{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._edge=!1,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);const i={element:this.element,handleDragOver:s=>this._onDragOver(s),handleDragLeave:()=>this._onDragLeave(),handleDrop:s=>this._onDropEvent(s)};this.addDisposables(this._onDrop,this._onWillShowOverlay,Bn.getInstance().registerTarget(i))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,i,s,n,r;if(this._disabled){this._clearOwnOverlay();return}const o=(t=(i=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(i);if(this._acceptedTargetZonesSet.size===0){this._clearOwnOverlay();return}const a=(s=(n=(r=this.options).getOverlayOutline)===null||n===void 0?void 0:n.call(r))!==null&&s!==void 0?s:this.element,l=a.offsetWidth,h=a.offsetHeight;if(l===0||h===0)return;const c=a.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top,f=this._resolvePosition(u,p,l,h,e.pointerEvent);if(f===null){this._clearOwnOverlay();return}const m=f.position;if(!this.options.canDisplayOverlay(e.pointerEvent,m)){this._clearOwnOverlay();return}const g=new hu({nativeEvent:e.pointerEvent,position:m,edge:f.edge});if(this._onWillShowOverlay.fire(g),g.defaultPrevented){this._clearOwnOverlay();return}if(f.edge){this._clearOwnOverlay(),this._state=m,this._edge=!0;return}if(this._edge=!1,o){lu({outlineElement:a,targetModel:o,quadrant:m,width:l,height:h,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=m;return}if(!this._targetElement){const _=po();this._targetElement=_.dropzone,this._overlayElement=_.selection,this._state="center",this.element.classList.add("dv-drop-target"),this.element.append(this._targetElement)}this._overlayElement&&au(this._overlayElement,m,l,h,this.options.overlayModel),this._state=m}_onDragLeave(){var e,t;const i=(e=(t=this.options).getOverrideTarget)===null||e===void 0?void 0:e.call(t);if(i){this._state=void 0,i.clear();return}this._removeOverlay()}_onDropEvent(e){var t,i;const s=this._state,n=this._edge,r=(t=(i=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(i);this._removeOverlay(),r?.clear(),s&&this._onDrop.fire({position:s,nativeEvent:e.pointerEvent,edge:n})}_resolvePosition(e,t,i,s,n){var r,o;const a=(r=(o=this.options).getPositionResolver)===null||r===void 0?void 0:r.call(o);if(a){const h=a.resolve({x:e,y:t,width:i,height:s,zones:this._acceptedTargetZonesSet,event:n});return h?{position:h.position,edge:!!h.edge}:null}const l=this._calculateQuadrant(e,t,i,s);return l?{position:l,edge:!1}:null}_calculateQuadrant(e,t,i,s){var n,r;const o=(n=(r=this.options.overlayModel)===null||r===void 0?void 0:r.activationSize)!==null&&n!==void 0?n:ab;return o.type==="percentage"?du(this._acceptedTargetZonesSet,e,t,i,s,o.value):cu(this._acceptedTargetZonesSet,e,t,i,s,o.value)}_clearOwnOverlay(){const e=this._state!==void 0;if(this._removeOverlay(),e){var t,i;(t=(i=this.options).getOverrideTarget)===null||t===void 0||(t=t.call(i))===null||t===void 0||t.clear()}}_removeOverlay(){if(this._edge=!1,this._targetElement){var e;this._state=void 0,(e=this._targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0}else this._state=void 0}};const hb=5,db=250,cb=8;var ub=class extends te{constructor(e,t){var i;super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=(i=t.touchOnly)!==null&&i!==void 0?i:!0,this.addDisposables(Z(this.element,"pointerdown",s=>{this._onPointerDown(s)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t,i;return!(this._disabled||this._touchOnly&&e.pointerType!=="touch"&&e.pointerType!=="pen"||!((t=(i=this.options).isCancelled)===null||t===void 0)&&t.call(i,e))}_onPointerDown(e){var t,i,s,n,r;if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;const o=e.pointerType==="touch"||e.pointerType==="pen",a=this.options.touchInitiationDelay,l=(t=typeof a=="function"?a():a)!==null&&t!==void 0?t:db;this._armed=!o||l<=0,o&&l>0&&Number.isFinite(l)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},l));const h=(i=this.options.threshold)!==null&&i!==void 0?i:hb,c=this.options.pressTolerance,u=(s=typeof c=="function"?c():c)!==null&&s!==void 0?s:cb,p=(n=(r=this.element.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&n!==void 0?n:globalThis.window;this._pendingMoveListener=Z(p,"pointermove",f=>{if(f.pointerId!==this._pendingPointerId)return;const m=f.clientX-this._startX,g=f.clientY-this._startY,_=Math.hypot(m,g);if(this._armed){_>=h&&this._beginDrag(f);return}_>u&&this._beginDrag(f)}),this._pendingUpListener=Z(p,"pointerup",f=>{f.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=Z(p,"pointercancel",f=>{f.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,i;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)===null||e===void 0||e.dispose(),(t=this._pendingUpListener)===null||t===void 0||t.dispose(),(i=this._pendingCancelListener)===null||i===void 0||i.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,i,s,n,r;const o=(t=this._startEvent)!==null&&t!==void 0?t:e;this._cancelPending(),(i=(s=this.options).onDragStart)===null||i===void 0||i.call(s,o);const a=(n=(r=this.options).createGhost)===null||n===void 0?void 0:n.call(r,o);Bn.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(o),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},pb=class{constructor(e){var t,i,s,n,r;this._disposed=!1,this.element=e.element,this.offsetX=(t=e.offsetX)!==null&&t!==void 0?t:0,this.offsetY=(i=e.offsetY)!==null&&i!==void 0?i:0,this.element.style.position="fixed",this.element.style.left="0px",this.element.style.top="0px",this.element.style.pointerEvents="none",this.element.style.zIndex="99999",this.element.style.opacity=String((s=e.opacity)!==null&&s!==void 0?s:.8),this.element.style.willChange="transform",this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,((n=(r=e.owner)===null||r===void 0?void 0:r.ownerDocument)!==null&&n!==void 0?n:document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}},fb=class extends te{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new Ge,this._pointerEventsDisposable=new Ge,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,Z(this.el,"dragstart",i=>{var s,n,r,o,a,l,h;if(i.defaultPrevented||this._disabled||!((s=(n=this.opts).isCancelled)===null||s===void 0)&&s.call(n,i)){i.preventDefault();return}const c=js((r=this.el.ownerDocument)!==null&&r!==void 0?r:document);this._pointerEventsDisposable.value={dispose:()=>c.release()},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this._dataDisposable.value=this.opts.getData(i);const u=(o=(a=this.opts).createGhost)===null||o===void 0?void 0:o.call(a,i);if(u&&i.dataTransfer){var p,f,m;if(ob(i.dataTransfer,u.element,{x:(p=u.offsetX)!==null&&p!==void 0?p:0,y:(f=u.offsetY)!==null&&f!==void 0?f:0,ownerDocument:(m=this.el.ownerDocument)!==null&&m!==void 0?m:void 0}),u.dispose){const g=u.dispose;setTimeout(()=>g(),0)}}i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.items.length===0&&i.dataTransfer.setData("text/plain","")),(l=(h=this.opts).onDragStart)===null||l===void 0||l.call(h,i)}),Z(this.el,"dragend",i=>{var s,n;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(s=(n=this.opts).onDragEnd)===null||s===void 0||s.call(n,i)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},mb=class{constructor(){this.kind="html5"}createDropTarget(e,t){return new or(e,t)}createDragSource(e,t){return new fb(e,t)}},gb=class{constructor(){this.kind="pointer"}createDropTarget(e,t){return new lb(e,t)}createDragSource(e,t){const i=t.createGhost?n=>{const r=t.createGhost(n);if(!r)return;const o=new pb({element:r.element,initialX:n.clientX,initialY:n.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){const a=o.dispose.bind(o),l=r.dispose;o.dispose=()=>{a(),l()}}return o}:void 0,s=new ub(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?n=>t.onDragEnd(n.pointerEvent):void 0,createGhost:i,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&s.setDisabled(!0),s}};const Ei=new mb,di=new gb,fo=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0});var vb=class extends Fc{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}},uu=class extends za{constructor(){super()}},pu=class extends te{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new Ge,this._onDidDimensionChange=new G,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new G,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new G,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new G,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new G,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new G,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new G,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new G,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(i=>{this._isFocused=i.isFocused}),this.onDidActiveChange(i=>{this._isActive=i.isActive}),this.onDidVisibilityChange(i=>{this._isVisible=i.isVisible}),this.onDidDimensionsChange(i=>{this._width=i.width,this._height=i.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},fu=class extends pu{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new G,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new G({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new G,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},_b=class extends fu{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new G({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new G({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new G({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)===null||t===void 0||t.setExpanded(e)}get isExpanded(){var e;return!!(!((e=this._pane)===null||e===void 0)&&e.isExpanded())}},Wa=class extends te{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return(e=this._params)===null||e===void 0?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const s=Uc(this._element);this.addDisposables(this.api,s.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),s.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),s)}focus(){const e=new uu;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t,i;this._params=se(se({},this._params),{},{params:se(se({},(t=this._params)===null||t===void 0?void 0:t.params),e.params)});for(const s of Object.keys(e.params))e.params[s]===void 0&&delete this._params.params[s];(i=this.part)===null||i===void 0||i.update({params:this._params.params})}toJSON(){var e,t;const i=(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)===null||e===void 0||e.dispose(),super.dispose()}},bb=class extends Wa{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e=="number"?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e=="number"?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}constructor(e){super(e.id,e.component,new _b(e.id,e.component)),this._onDidChangeExpansionState=new G({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add("dv-pane"),this.addDisposables(this.api.onWillVisibilityChange(t=>{const{isVisible:i}=t,{accessor:s}=this._params;s.setVisible(this,i)}),this.api.onDidSizeChange(t=>{this._onDidChange.fire({size:t.size})}),Z(this.element,"mouseenter",t=>{this.api._onMouseEnter.fire(t)}),Z(this.element,"mouseleave",t=>{this.api._onMouseLeave.fire(t)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(t=>{this.api._onDidExpansionChange.fire({isExpanded:t})}),this.api.onDidFocusChange(t=>{this.header&&(t.isFocused?Ot(this.header,"focused"):Mt(this.header,"focused"))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){var t;this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):(this._expandedSize=this._size,this.animationTimer=setTimeout(()=>{var i;(i=this.body)===null||i===void 0||i.remove()},200)),this._onDidChange.fire(e?{size:(t=this._expandedSize)!==null&&t!==void 0?t:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation==="HORIZONTAL"?[e,t]:[t,e];super.layout(i,s)}init(e){var t,i;super.init(e),typeof e.minimumBodySize=="number"&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize=="number"&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(se(se({},e),{},{api:this.api})),this.headerPart.init(se(se({},e),{},{api:this.api})),(t=this.body)===null||t===void 0||t.append(this.bodyPart.element),(i=this.header)===null||i===void 0||i.append(this.headerPart.element),typeof e.isExpanded=="boolean"&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return se(se({},super.toJSON()),{},{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="dv-pane-header",this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement("div"),this.body.className="dv-pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;(t=this.bodyPart)===null||t===void 0||t.update({params:e}),(i=this.headerPart)===null||i===void 0||i.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)===null||e===void 0||e.dispose(),(t=this.headerPart)===null||t===void 0||t.dispose()}}}},wb=class extends bb{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0;const i={getData:()=>(hi.getInstance().setData([new Ms(t,e)],Ms.prototype),{dispose:()=>{hi.getInstance().clearData(Ms.prototype)}})};this.html5DragSource=Ei.createDragSource(this.header,i),this.pointerDragSource=di.createDragSource(this.header,i);const n={acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(r,o)=>{const a=bs();if(a&&a.paneId!==this.id&&a.viewId===this.accessor.id)return!0;const l=new vb(r,o,bs,this);return this._onUnhandledDragOver.fire(l),l.isAccepted}};this.target=Ei.createDropTarget(this.element,n),this.pointerTarget=di.createDropTarget(this.element,n),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(r=>{this.onDrop(r)}),this.pointerTarget.onDrop(r=>{this.onDrop(r)}))}onDrop(e){const t=bs();if(t?.viewId!==this.accessor.id){this._onDidDrop.fire(se(se({},e),{},{panel:this,api:new $s(this.accessor),getData:bs}));return}const i=this._params.containerApi,s=t.paneId,n=i.getPanel(s);if(!n){this._onDidDrop.fire(se(se({},e),{},{panel:this,getData:bs,api:new $s(this.accessor)}));return}const r=i.panels,o=r.indexOf(n);let a=i.panels.indexOf(this);(e.position==="left"||e.position==="top")&&(a=Math.max(0,a-1)),(e.position==="right"||e.position==="bottom")&&(o>a&&a++,a=Math.min(r.length-1,a)),i.movePanel(o,a)}};let yb=0;const xb=()=>`dv-tabpanel-${yb++}`;var Sb=class extends te{get element(){return this._element}constructor(e,t){var i,s,n,r,o,a,l;super(),this.accessor=e,this.group=t,this.disposable=new Ge,this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-content-container",this._element.tabIndex=-1,this._element.id=xb(),this._element.setAttribute("role","tabpanel"),this.addDisposables(this._onDidFocus,this._onDidBlur);const h=()=>{var u;return(u=t.dropTargetContainer)===null||u===void 0?void 0:u.model},c=(u,p)=>this.group.canDisplayContentOverlay(u,p);this.dropTarget=new or(this.element,{getOverlayOutline:()=>{var u;return((u=e.options.theme)===null||u===void 0?void 0:u.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:c,getOverrideTarget:h,overlayModel:(i=(s=this.accessor).resolveDropOverlayModel)===null||i===void 0?void 0:i.call(s,"content"),getPositionResolver:()=>{var u;return(u=e.getDropPositionResolver)===null||u===void 0?void 0:u.call(e)}}),this.pointerDropTarget=di.createDropTarget(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:c,getOverlayOutline:()=>{var u;return((u=e.options.theme)===null||u===void 0?void 0:u.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",getOverrideTarget:h,overlayModel:(n=(r=this.accessor).resolveDropOverlayModel)===null||n===void 0?void 0:n.call(r,"content"),getPositionResolver:()=>{var u;return(u=e.getDropPositionResolver)===null||u===void 0?void 0:u.call(e)}}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(o=(a=(l=this.accessor).onDidOptionsChange)===null||a===void 0?void 0:a.call(l,()=>{var u,p,f;const m=(u=(p=(f=this.accessor).resolveDropOverlayModel)===null||p===void 0?void 0:p.call(f,"content"))!==null&&u!==void 0?u:{};this.dropTarget.setOverlayModel(m),this.pointerDropTarget.setOverlayModel(m)}))!==null&&o!==void 0?o:xe.NONE)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}setLabelledBy(e){e?this._element.setAttribute("aria-labelledby",e):this._element.removeAttribute("aria-labelledby")}renderPanel(e,t){var i,s;const n=((i=t?.asActive)!==null&&i!==void 0?i:!0)||this.panel&&this.group.isPanelActive(this.panel);if(((s=this.panel)===null||s===void 0?void 0:s.view.content.element.parentElement)===this._element){var r,o;this.panel.view.content.element.remove(),(r=(o=this.panel.view.content).onHide)===null||r===void 0||r.call(o)}this.panel=e;let a;switch(e.api.renderer){case"onlyWhenVisible":if(this.group.renderContainer.detatch(e),this.panel&&n){var l,h;this._element.appendChild(this.panel.view.content.element),(l=(h=this.panel.view.content).onShow)===null||l===void 0||l.call(h)}a=this._element;break;case"always":e.view.content.element.parentElement===this._element&&e.view.content.element.remove(),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(n){const c=Uc(a);this.focusTracker=c;const u=new te;u.addDisposables(c,c.onDidFocus(()=>this._onDidFocus.fire()),c.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=u}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){if(this.panel&&this.panel.api.renderer==="onlyWhenVisible"){var e,t;this.panel.view.content.element.remove(),(e=(t=this.panel.view.content).onHide)===null||e===void 0||e.call(t)}this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;!((e=this.focusTracker)===null||e===void 0)&&e.refreshState&&this.focusTracker.refreshState()}};const ar=e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"height",e.height),t.setAttributeNS(null,"width",e.width),t.setAttributeNS(null,"viewBox",e.viewbox),t.setAttributeNS(null,"aria-hidden","false"),t.setAttributeNS(null,"focusable","false"),t.classList.add("dv-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},Cb=()=>ar({width:"11",height:"11",viewbox:"0 0 28 28",path:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}),mu=()=>ar({width:"11",height:"11",viewbox:"0 0 24 24",path:"M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z"}),Db=()=>ar({width:"11",height:"11",viewbox:"0 0 24 15",path:"M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z"}),gu=()=>ar({width:"11",height:"11",viewbox:"0 0 15 25",path:"M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z"}),kb=500,Pb=8;var Ha=class extends te{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(Z(this.element,"pointerdown",i=>{this._onPointerDown(i)}))}_onPointerDown(e){var t,i,s,n,r;if((!((t=this.options.touchOnly)!==null&&t!==void 0)||t)&&e.pointerType!=="touch"&&e.pointerType!=="pen")return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;const o=(i=this.options.delay)!==null&&i!==void 0?i:kb,a=(s=this.options.tolerance)!==null&&s!==void 0?s:Pb,l=(n=(r=this.element.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&n!==void 0?n:globalThis.window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(l),this._installClickGuard(l),this.options.onLongPress(e)},o),this._moveListener=Z(l,"pointermove",h=>{if(h.pointerId!==this._pointerId)return;const c=h.clientX-this._startX,u=h.clientY-this._startY;Math.hypot(c,u)>a&&this._cancelPending()}),this._upListener=Z(l,"pointerup",h=>{h.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=Z(l,"pointercancel",h=>{h.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=Z(e,"contextmenu",s=>{s.preventDefault(),clearTimeout(i),t?.dispose()},{capture:!0})}_installClickGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=Z(e,"click",s=>{const n=s.target;n&&this.element.contains(n)&&(s.preventDefault(),s.stopPropagation()),clearTimeout(i),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,i;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)===null||e===void 0||e.dispose(),(t=this._upListener)===null||t===void 0||t.dispose(),(i=this._cancelListener)===null||i===void 0||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function Lt(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case"pointer":return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case"html5":return{html5:!0,pointer:!1,pointerHandlesMouse:!1};default:return Eb()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function Eb(){if(globalThis.window===void 0||!globalThis.matchMedia)return!1;const e=globalThis.matchMedia("(pointer: coarse)").matches,t=globalThis.matchMedia("(pointer: fine)").matches;return e&&!t}let Tb=0;const Ib=()=>`dv-tab-${Tb++}`;var Ab=class extends te{get element(){return this._element}constructor(e,t,i){var s,n,r,o,a,l,h,c;super(),this.panel=e,this.accessor=t,this.group=i,this.content=void 0,this.panelTransfer=hi.getInstance(),this._direction="horizontal",this._pinIndicator=void 0,this._onPointDown=new G,this.onPointerDown=this._onPointDown.event,this._onTabClick=new G,this.onTabClick=this._onTabClick.event,this._onDropped=new G,this.onDrop=this._onDropped.event,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._onDragEnd=new G,this.onDragEnd=this._onDragEnd.event;const u=Lt(this.accessor.options);this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=-1,this._element.draggable=u.html5,this._element.id=Ib(),this._element.setAttribute("role","tab"),this._element.setAttribute("aria-selected","false"),this._element.setAttribute("aria-label",(s=this.panel.title)!==null&&s!==void 0?s:this.panel.id),this._element.dataset.tabPanelId=this.panel.id;const p=(n=this.group)===null||n===void 0||(n=n.model)===null||n===void 0?void 0:n.contentContainerId;p&&this._element.setAttribute("aria-controls",p),Y(this.element,"dv-inactive-tab",!0),this._updatePinnedClasses();const f=(g,_)=>{if(this.group.locked)return!1;const T=Ie();if(this.accessor.id===T?.viewId){var D;return((D=this.accessor.options.theme)===null||D===void 0?void 0:D.tabAnimation)!=="smooth"}return this.group.model.canDisplayOverlay(g,_,"tab")};this.dropTarget=Ei.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:f,getOverrideTarget:()=>{var g;return(g=i.model.dropTargetContainer)===null||g===void 0?void 0:g.model}}),this.pointerDropTarget=di.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:f,getOverrideTarget:()=>{var g;return(g=i.model.dropTargetContainer)===null||g===void 0?void 0:g.model}});const m={getData:()=>(this.panelTransfer.setData([new Et(this.accessor.id,this.group.id,this.panel.id)],Et.prototype),{dispose:()=>{this.panelTransfer.clearData(Et.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:g=>{var _;this._onDragStart.fire(g),!(g instanceof PointerEvent)&&((_=this.accessor.options.theme)===null||_===void 0?void 0:_.tabAnimation)==="smooth"&&requestAnimationFrame(()=>{Y(this.element,"dv-tab--dragging",!0)})},onDragEnd:g=>{this._onDragEnd.fire(g)}};this.html5DragSource=Ei.createDragSource(this._element,se(se({},m),{},{disabled:!u.html5})),this.pointerDragSource=di.createDragSource(this._element,se(se({},m),{},{disabled:!u.pointer,touchOnly:!u.pointerHandlesMouse,isCancelled:()=>!Lt(this.accessor.options).pointer})),this.onWillShowOverlay=Tt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{const g=this._buildOverlayModel();this.dropTarget.setOverlayModel(g),this.pointerDropTarget.setOverlayModel(g),this._updatePinnedClasses()}),(r=(o=this.panel.api)===null||o===void 0||(a=o.onDidChangePinned)===null||a===void 0?void 0:a.call(o,()=>{this._updatePinnedClasses()}))!==null&&r!==void 0?r:{dispose:()=>{}},(l=(h=this.panel.api)===null||h===void 0||(c=h.onDidTitleChange)===null||c===void 0?void 0:c.call(h,g=>{var _;this._element.setAttribute("aria-label",(_=g.title)!==null&&_!==void 0?_:this.panel.id)}))!==null&&l!==void 0?l:{dispose:()=>{}},Z(this._element,"dragend",()=>{Y(this.element,"dv-tab--dragging",!1)}),this.html5DragSource,Z(this._element,"pointerdown",g=>{this._onPointDown.fire(g)}),Z(this._element,"click",g=>{this._onTabClick.fire(g)}),Z(this._element,"contextmenu",g=>{var _;(_=this.accessor.contextMenuService)===null||_===void 0||_.show(this.panel,this.group,g)}),new Ha(this._element,{onLongPress:g=>{var _;this.pointerDragSource.cancelPending(),(_=this.accessor.contextMenuService)===null||_===void 0||_.show(this.panel,this.group,g)}}),this.dropTarget.onDrop(g=>{this._onDropped.fire(g)}),this.pointerDropTarget.onDrop(g=>{this._onDropped.fire(g)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}_updatePinnedClasses(){var e,t,i,s;const n=(e=(t=this.panel.api)===null||t===void 0?void 0:t.isPinned)!==null&&e!==void 0?e:!1,r=n&&((i=this.accessor.options.pinnedTabs)===null||i===void 0?void 0:i.compact)===!0;Y(this.element,"dv-tab--pinned",n),Y(this.element,"dv-tab--pinned-compact",r);const o=n&&!(!((s=this.panel.api)===null||s===void 0)&&s.tabComponent);if(o&&!this._pinIndicator){const a=document.createElement("div");a.className="dv-tab-pin",a.appendChild(mu()),this._element.insertBefore(a,this._element.firstChild),this._pinIndicator=a}else!o&&this._pinIndicator&&(this._pinIndicator.remove(),this._pinIndicator=void 0)}setActive(e){Y(this.element,"dv-active-tab",e),Y(this.element,"dv-inactive-tab",!e),this._element.setAttribute("aria-selected",e?"true":"false"),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this.content.element.remove(),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e,t,i;const s=(e=(t=this.accessor).resolveDropOverlayModel)===null||e===void 0?void 0:e.call(t,"tab",this.group);if(s)return s;const n=((i=this.accessor.options.theme)===null||i===void 0?void 0:i.dndTabIndicator)==="line"?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:n,smallHeightBoundary:n}}setDirection(e){this._direction=e;const t=e==="vertical"?["top","bottom"]:["left","right"];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){const e=Lt(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){const e=getComputedStyle(this.element),t=this.element.cloneNode(!0),i=this._direction==="vertical",s=new Set(["writing-mode","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end","padding-inline","padding-inline-start","padding-inline-end","padding-block","padding-block-start","padding-block-end"]);return Array.from(e).forEach(n=>{i&&s.has(n)||t.style.setProperty(n,e.getPropertyValue(n),e.getPropertyPriority(n))}),i&&(t.style.setProperty("writing-mode","horizontal-tb"),t.style.setProperty("width",e.height),t.style.setProperty("height",e.width)),t.style.position="absolute",t.classList.add("dv-tab-ghost-drag"),t}},Ws=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get edge(){return this.event.edge}get edgeGroup(){return this.event.edgeGroup}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},vu=class extends te{get group(){return this.groupAccessor()}constructor(e){var t,i;super(),this.panelTransfer=hi.getInstance(),this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;const s=e.group;this.groupAccessor=typeof s=="function"?s:()=>s,this.isFloatingMoveHandle=(t=e.isFloatingMoveHandle)!==null&&t!==void 0?t:(()=>!0);const n=Lt(this.accessor.options);this._element.draggable=n.html5,Y(this._element,"dv-draggable",n.html5||n.pointer),this.addDisposables(this._onDragStart);const r=()=>{const p=document.createElement("div"),f=globalThis.getComputedStyle(this._element),m=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),g=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");return p.style.backgroundColor=m,p.style.color=g,p.style.padding="2px 8px",p.style.height="24px",p.style.fontSize="11px",p.style.lineHeight="20px",p.style.borderRadius="12px",p.style.whiteSpace="nowrap",p.style.boxSizing="border-box",p.style.display="inline-block",p.textContent=`Multiple Panels (${this.group.size})`,p},a={getData:()=>(this.panelTransfer.setData([new Et(this.accessor.id,this.group.id,null)],Et.prototype),{dispose:()=>{this.panelTransfer.clearData(Et.prototype)}}),createGhost:()=>{var p,f;const m=(p=(f=this.accessor).buildGroupDragGhost)===null||p===void 0?void 0:p.call(f,this.group);return m||{element:r(),offsetX:30,offsetY:-10}},onDragStart:p=>{this._onDragStart.fire(p)}};this.html5DragSource=Ei.createDragSource(this._element,se(se({},a),{},{disabled:!n.html5,isCancelled:p=>!!(this.group.api.location.type==="floating"&&this.isFloatingMoveHandle()&&!p.shiftKey||this.group.api.location.type==="edge"&&this.group.size===0)}));const l=()=>{var p;return((p=this.group)===null||p===void 0||(p=p.api)===null||p===void 0||(p=p.location)===null||p===void 0?void 0:p.type)==="floating"&&this.isFloatingMoveHandle()};this.pointerDragSource=di.createDragSource(this._element,se(se({},a),{},{disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,touchInitiationDelay:()=>l()?500:250,pressTolerance:()=>l()?1/0:8,isCancelled:()=>!Lt(this.accessor.options).pointer||this.group.api.location.type==="edge"&&this.group.size===0,onDragStart:p=>{var f;(f=this.getFloatingOverlay())===null||f===void 0||f.cancelPendingDrag(),this._onDragStart.fire(p)}}));const h=new Ge,c=()=>{const p=this.getFloatingOverlay();h.value=p?p.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):xe.NONE};c(),this.addDisposables(h);const u=(i=this.group)===null||i===void 0||(i=i.api)===null||i===void 0?void 0:i.onDidLocationChange;u&&this.addDisposables(u(c)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){const e=Lt(this.accessor.options);this._element.draggable=e.html5,Y(this._element,"dv-draggable",e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e;if(this.group)return(e=this.accessor.floatingGroups)===null||e===void 0||(e=e.find(t=>t.group===this.group))===null||e===void 0?void 0:e.overlay}},Rb=class extends te{get element(){return this._element}constructor(e,t){var i,s,n,r,o,a,l;super(),this.accessor=e,this.group=t,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this.addDisposables(this._onDrop,this._onDragStart,Z(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)}),Z(this._element,"pointerdown",c=>{c.shiftKey&&qc(c)},!0)),this.dragSource=new vu({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(".dv-resize-container-with-titlebar")});const h=(c,u)=>{if(this.group.api.locked)return!1;const p=Ie();return this.accessor.id===p?.viewId?!0:t.model.canDisplayOverlay(c,u,"header_space")};this.dropTarget=Ei.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var c;return(c=t.model.dropTargetContainer)===null||c===void 0?void 0:c.model},overlayModel:(i=(s=this.accessor).resolveDropOverlayModel)===null||i===void 0?void 0:i.call(s,"header_space",this.group)}),this.pointerDropTarget=di.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var c;return(c=t.model.dropTargetContainer)===null||c===void 0?void 0:c.model},overlayModel:(n=(r=this.accessor).resolveDropOverlayModel)===null||n===void 0?void 0:n.call(r,"header_space",this.group)}),this.onWillShowOverlay=Tt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(c=>{this._onDragStart.fire(c)}),this.dropTarget.onDrop(c=>{this._onDrop.fire(c)}),this.pointerDropTarget.onDrop(c=>{this._onDrop.fire(c)}),this.dropTarget,this.pointerDropTarget,(o=(a=(l=this.accessor).onDidOptionsChange)===null||a===void 0?void 0:a.call(l,()=>{var c,u,p;const f=(c=(u=(p=this.accessor).resolveDropOverlayModel)===null||u===void 0?void 0:u.call(p,"header_space",this.group))!==null&&c!==void 0?c:{};this.dropTarget.setOverlayModel(f),this.pointerDropTarget.setOverlayModel(f)}))!==null&&o!==void 0?o:xe.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},_u=class bu extends te{get element(){return this._element}get orientation(){return this._orientation}set orientation(t){this._orientation!==t&&(this._scrollOffset=0,this._orientation=t,Mt(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),t==="vertical"?Ot(this._scrollbar,"dv-scrollbar-vertical"):Ot(this._scrollbar,"dv-scrollbar-horizontal"))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation="horizontal",this._element=document.createElement("div"),this._element.className="dv-scrollable",this._scrollbar=document.createElement("div"),this._scrollbar.className="dv-scrollbar dv-scrollbar-horizontal",this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(Z(this.element,"wheel",i=>{this._scrollOffset+=i.deltaY*bu.MouseWheelSpeed,this.scheduleStyleUpdate()}),Z(this._scrollbar,"pointerdown",i=>{var s;i.preventDefault();const n=(s=this._scrollbar.ownerDocument)!==null&&s!==void 0?s:document;Y(this.element,"dv-scrollable-scrolling",!0);const r=this._orientation==="horizontal"?i.clientX:i.clientY,o=this._scrollOffset,a=h=>{const c=this._orientation==="horizontal"?h.clientX-r:h.clientY-r,u=(this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight)/(this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=o+c/u,this.scheduleStyleUpdate()},l=()=>{Y(this.element,"dv-scrollable-scrolling",!1),n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",l),n.removeEventListener("pointercancel",l)};n.addEventListener("pointermove",a),n.addEventListener("pointerup",l),n.addEventListener("pointercancel",l)}),Z(this.element,"scroll",()=>{this.scheduleStyleUpdate()}),Z(this.scrollableElement,"scroll",()=>{this._scrollOffset=this._orientation==="horizontal"?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.scheduleStyleUpdate()}),Ui(this.element,()=>{Y(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),Y(this.element,"dv-scrollable-resizing",!1)},500),this.scheduleStyleUpdate()}),xe.from(()=>{this._pendingStyleFrame!==void 0&&(cancelAnimationFrame(this._pendingStyleFrame),this._pendingStyleFrame=void 0)}))}scheduleStyleUpdate(){this._pendingStyleFrame===void 0&&(this._pendingStyleFrame=requestAnimationFrame(()=>{this._pendingStyleFrame=void 0,this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const t=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,i=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(i>t){const s=t*(t/i);this._orientation==="horizontal"?(this._scrollbar.style.width=`${s}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${s}px`,this._scrollbar.style.width=""),this._scrollOffset=Te(this._scrollOffset,0,i-t),this._orientation==="horizontal"?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const n=this._scrollOffset/(i-t);this._orientation==="horizontal"?(this._scrollbar.style.left=`${(t-s)*n}px`,this._scrollbar.style.top=""):(this._scrollbar.style.top=`${(t-s)*n}px`,this._scrollbar.style.left="")}else this._orientation==="horizontal"?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}};_u.MouseWheelSpeed=1;const wu="dv-tabs-container--wrap";function Nb(e,t){return typeof e=="boolean"?e:!!e?.[t]}function mo(e){return typeof e=="boolean"?e:e?Object.values(e).some(Boolean):!1}var yu=class extends Fc{constructor(e,t,i,s,n){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=n}};const go=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,smartGuides:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,dropPositionResolver:void 0,dndCompass:void 0,theme:void 0,disableTabsOverflowList:void 0,overflow:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,layoutHistory:void 0,autoHideEdgeGroups:void 0,dockToEdgeGroups:void 0,edgeGroupPeek:void 0,tabGroupColors:void 0,tabGroupAccent:void 0,pinnedTabs:void 0});function Lb(e){return!!e.referencePanel}function Mb(e){return!!e.referenceGroup}function Ob(e){return!!e.referencePanel}function Gb(e){return!!e.referenceGroup}const Fa=[{id:"grey",value:"var(--dv-tab-group-color-grey)",label:"Grey"},{id:"blue",value:"var(--dv-tab-group-color-blue)",label:"Blue"},{id:"red",value:"var(--dv-tab-group-color-red)",label:"Red"},{id:"yellow",value:"var(--dv-tab-group-color-yellow)",label:"Yellow"},{id:"green",value:"var(--dv-tab-group-color-green)",label:"Green"},{id:"pink",value:"var(--dv-tab-group-color-pink)",label:"Pink"},{id:"purple",value:"var(--dv-tab-group-color-purple)",label:"Purple"},{id:"cyan",value:"var(--dv-tab-group-color-cyan)",label:"Cyan"},{id:"orange",value:"var(--dv-tab-group-color-orange)",label:"Orange"}];var xu=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(i=>[i.id,i])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(t=>[t.id,t]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return(e=this._entries[0])===null||e===void 0?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}};let xr;function Su(){var e;return(e=xr)!==null&&e!==void 0||(xr=new xu(Fa,!0)),xr}function Va(e,t,i){const s=(i??Su()).resolveValue(t);s===void 0?e.style.removeProperty("--dv-tab-group-color"):e.style.setProperty("--dv-tab-group-color",s)}function Ua(e,t){return(t??Su()).resolveValue(e)}var ih=class extends te{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new G,this.onClick=this._onClick.event,this._onContextMenu=new G,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=0,this._label=document.createElement("span"),this._label.className="dv-tab-group-chip-label",this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new Ha(this._element,{onLongPress:t=>{this._onContextMenu.fire(t)}}),Z(this._element,"click",t=>{this._onClick.fire(t)}),Z(this._element,"contextmenu",t=>{this._onContextMenu.fire(t)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(t=>{this.updateCollapsed(t)}),this._onClick.event(()=>{var t;(t=this._tabGroup)===null||t===void 0||t.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){var t;Va(this._element,e,this._palette),Y(this._element,"dv-tab-group-chip--accent-off",((t=this._palette)===null||t===void 0?void 0:t.enabled)===!1)}updateLabel(e){this._label.textContent=e,Y(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){Y(this._element,"dv-tab-group-chip--collapsed",e)}};const zb="dv-tab-group-chip-continuation",sh=8;var Cu=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._continuationMarkers=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=250,i=()=>{this._positionUnderlinesSync(),performance.now()-e<t?this._rafId=requestAnimationFrame(i):this._rafId=null};this._rafId=requestAnimationFrame(i)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const i=document.createElement("div");i.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(i),this._underlines.set(t,i)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t),this._clearContinuationMarkers(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(const[,e]of this._underlines)e.remove();this._underlines.clear(),this._clearContinuationMarkers()}_syncContinuationMarkers(e,t){let i=this._continuationMarkers.get(e);for(i||(i=[],this._continuationMarkers.set(e,i));i.length<t;){const s=document.createElement("div");s.className=zb,this._ctx.tabsList.appendChild(s),i.push(s)}for(;i.length>t;){const s=i.pop();s?.remove()}return i}_clearContinuationMarkers(e){if(e===void 0){for(const[,i]of this._continuationMarkers)for(const s of i)s.remove();this._continuationMarkers.clear();return}const t=this._continuationMarkers.get(e);if(t){for(const i of t)i.remove();this._continuationMarkers.delete(e)}}_positionUnderlinesSync(){const e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),i=this._ctx.getDirection()==="vertical",s=this._ctx.tabsList.classList.contains(wu);s||this._clearContinuationMarkers();const n=i?e.width:e.height,r=this._ctx.getActivePanelId(),o=this._ctx.getTabMap();for(const a of t){const l=this._underlines.get(a.id);if(!l)continue;const h=a.panelIds;if(h.length===0){l.style.display="none";continue}if(l.style.display="",s){this._positionWrappedUnderline(l,a,e,o,i);continue}const c=this._ctx.getChipElement(a.id);let u;if(c){const T=c.getBoundingClientRect(),D=getComputedStyle(c),E=i?Number.parseFloat(D.marginTop)||0:Number.parseFloat(D.marginLeft)||0;u=i?T.top-e.top-E:T.left-e.left-E}else{const T=h[0],D=o.get(T);if(D){const E=D.value.element.getBoundingClientRect();u=i?E.top-e.top:E.left-e.left}else u=0}const p=h[h.length-1],f=o.get(p);if(!f){i?(l.style.top=`${u}px`,l.style.height="0px",l.style.left="",l.style.width=""):(l.style.left=`${u}px`,l.style.width="0px",l.style.top="",l.style.height="");continue}const m=f.value.element.getBoundingClientRect();let g=i?m.bottom-e.top:m.right-e.left,_=g-u;if((a.collapsed||a.panelIds.some(T=>{const D=o.get(T);return D?.value.element.classList.contains("dv-tab--group-expanding")}))&&c){const T=c.getBoundingClientRect(),D=i?T.top+T.height/2-e.top:T.left+T.width/2-e.left;let E=0,S=0;for(const k of a.panelIds){const L=o.get(k);if(!L)continue;const O=L.value.element;i?(E+=O.getBoundingClientRect().height,S+=O.scrollHeight):(E+=O.getBoundingClientRect().width,S+=O.scrollWidth)}const A=S>0?Math.min(1,E/S):0;u=D+(u-D)*A,g=D+(g-D)*A,_=Math.max(0,g-u)}i?(l.style.top=`${u}px`,l.style.height=`${Math.max(0,_)}px`,l.style.left="",l.style.width="",l.style.bottom=""):(l.style.left=`${u}px`,l.style.width=`${Math.max(0,_)}px`,l.style.top="",l.style.height="",l.style.bottom=""),this.applyShape(l,a,u,_,n,r,e,i)}}_positionWrappedUnderline(e,t,i,s,n){const o=Ua(t.color,this._ctx.getColorPalette());if(o===void 0){e.style.display="none",this._clearContinuationMarkers(t.id);return}const{runs:a,firstRun:l}=this._computeWrappedRuns(t,i,s,n);if(a.length===0){e.style.display="none",this._clearContinuationMarkers(t.id);return}this._positionContinuationMarkers(t.id,a,l,o,n);const h=Math.min(...a.map(E=>E.left)),c=Math.max(...a.map(E=>E.right)),u=Math.min(...a.map(E=>E.top)),p=Math.max(...a.map(E=>E.bottom)),f=n?Math.max(0,c-h):i.width,m=n?i.height:Math.max(0,p-u);e.style.left=n?`${h}px`:"0px",e.style.top=n?"0px":`${u}px`,e.style.bottom="auto",e.style.width=`${f}px`,e.style.height=`${m}px`,e.style.backgroundColor="";const{svg:g,path:_}=this.ensureSvgPath(e);g.setAttribute("width",String(f)),g.setAttribute("height",String(m)),_.setAttribute("stroke",o),_.setAttribute("stroke-width",String(2));const T=this._ctx.getHeaderPosition(),D=n?T==="right":T==="bottom";_.setAttribute("d",this._wrappedPathData(a,n,D,h,u,2))}_computeWrappedRuns(e,t,i,s){const n=[];let r;for(const a of e.panelIds){var o;const l=i.get(a);if(!l)continue;const h=l.value.element.getBoundingClientRect();if(h.width===0&&h.height===0)continue;const c=h.top-t.top,u=h.bottom-t.top,p=h.left-t.left,f=h.right-t.left,m=s?p:c;let g=n.find(_=>Math.abs((s?_.left:_.top)-m)<=2);g?(g.top=Math.min(g.top,c),g.bottom=Math.max(g.bottom,u),g.left=Math.min(g.left,p),g.right=Math.max(g.right,f)):(g={top:c,bottom:u,left:p,right:f},n.push(g)),(o=r)!==null&&o!==void 0||(r=g)}return{runs:n,firstRun:r}}_wrappedPathData(e,t,i,s,n,r){let o="";for(const a of e)if(t){const l=i?a.right-s-r/2:a.left-s+r/2;o+=`M ${l},${a.top} L ${l},${a.bottom} `}else{const l=i?a.top-n+r/2:a.bottom-n-r/2;o+=`M ${a.left},${l} L ${a.right},${l} `}return o.trim()}_positionContinuationMarkers(e,t,i,s,n){const r=t.filter(a=>a!==i),o=this._syncContinuationMarkers(e,r.length);r.forEach((a,l)=>{const h=o[l];if(h.style.backgroundColor=s,n){const c=(a.left+a.right)/2;h.style.left=`${c-sh/2}px`,h.style.top=`${a.top}px`}else{const c=(a.top+a.bottom)/2;h.style.left=`${a.left}px`,h.style.top=`${c-sh/2}px`}})}ensureSvgPath(e){const t=e.firstElementChild;if(t?.tagName==="svg")return{svg:t,path:t.firstElementChild};e.replaceChildren();const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.display="block";const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("fill","none"),i.appendChild(s),e.appendChild(i),{svg:i,path:s}}},jb=class extends Cu{_applyStraightLine(e,t,i,s,n,r,o){const a=o?n:s,l=o?s:n;e.setAttribute("width",String(a)),e.setAttribute("height",String(l)),i.style.width=`${a}px`,i.style.height=`${l}px`,t.setAttribute("d",o?`M ${r},0 L ${r},${s}`:`M 0,${r} L ${s},${r}`)}applyShape(e,t,i,s,n,r,o,a){const h=n,c=s,u=Ua(t.color,this._ctx.getColorPalette());if(c<=0||h<=0||u===void 0){e.style.display="none";return}e.style.display="";let p;r&&t.panelIds.includes(r)&&(p=this._ctx.getTabMap().get(r));const{svg:f,path:m}=this.ensureSvgPath(e);m.setAttribute("stroke",u),m.setAttribute("stroke-width",String(2));const g=2,_=this._ctx.getHeaderPosition(),T=!a&&_==="bottom",D=a&&_==="right";let E,S;if(a?(E=D?h-g:g,S=D?g:h-g):(E=T?g:h-g,S=T?h-g:g),!p){this._applyStraightLine(f,m,e,c,h,E,a);return}const A=p.value.element.getBoundingClientRect();let k,L;if(a?(k=Math.max(0,A.top-o.top-i),L=Math.min(c,A.bottom-o.top-i)):(k=Math.max(0,A.left-o.left-i),L=Math.min(c,A.right-o.left-i)),L<=k){this._applyStraightLine(f,m,e,c,h,E,a);return}const O=6,z=S>E?1:-1;if(a){const N=h,I=c;f.setAttribute("width",String(N)),f.setAttribute("height",String(I)),e.style.width=`${N}px`,e.style.height=`${I}px`;const C=[`M ${E},0`,`L ${E},${k-O}`,`Q ${E},${k} ${E+z*O},${k}`,`L ${S-z*O},${k}`,`Q ${S},${k} ${S},${k+O}`,`L ${S},${L-O}`,`Q ${S},${L} ${S-z*O},${L}`,`L ${E+z*O},${L}`,`Q ${E},${L} ${E},${L+O}`,`L ${E},${I}`].join(" ");m.setAttribute("d",C)}else{const N=c,I=h;f.setAttribute("width",String(N)),f.setAttribute("height",String(I)),e.style.width=`${N}px`,e.style.height=`${I}px`;const C=[`M 0,${E}`,`L ${k-O},${E}`,`Q ${k},${E} ${k},${E+z*O}`,`L ${k},${S-z*O}`,`Q ${k},${S} ${k+O},${S}`,`L ${L-O},${S}`,`Q ${L},${S} ${L},${S-z*O}`,`L ${L},${E+z*O}`,`Q ${L},${E} ${L+O},${E}`,`L ${N},${E}`].join(" ");m.setAttribute("d",C)}}},Bb=class extends Cu{applyShape(e,t,i,s,n,r,o,a){const h=Ua(t.color,this._ctx.getColorPalette());if(s<=0||h===void 0){e.style.display="none";return}e.style.display="",e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=h,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px")}};const $b=new Map;var Wb=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return(e=(t=this._indicator)===null||t===void 0?void 0:t.underlines)!==null&&e!==void 0?e:$b}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){const e=this._ctx.group.model.getTabGroups(),t=new Set;for(const s of e)t.add(s.id),this._ensureChipForGroup(s),this._positionChipForGroup(s);for(const[s,n]of this._chipRenderers)if(!t.has(s)){var i;n.chip.element.remove(),n.chip.dispose(),(i=n.dragSourcesDisposable)===null||i===void 0||i.dispose(),n.disposable.dispose(),this._chipRenderers.delete(s)}this._updateTabGroupClasses()}refreshAccents(){for(const i of this._ctx.group.model.getTabGroups()){var e,t;const s=this._chipRenderers.get(i.id);s==null||(t=(e=s.chip).update)===null||t===void 0||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){const e=this._ctx.getDirection()==="vertical";for(const[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?["top"]:["left"])}snapshotChipWidths(){const e=new Map;for(const[t,i]of this._chipRenderers)e.set(t,i.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const s=this._ctx.getDirection()==="vertical",n=this._ctx.tabsList.cloneNode(!0);s?(n.classList.remove("dv-tabs-container-vertical","dv-vertical"),n.classList.add("dv-horizontal"),n.style.writingMode="horizontal-tb",n.style.height=`${this._ctx.tabsList.offsetWidth}px`):n.style.height=`${this._ctx.tabsList.offsetHeight}px`,n.style.width="auto",n.style.overflow="visible",n.style.pointerEvents="none";const r=Array.from(n.children),o=Array.from(this._ctx.tabsList.children);for(let f=r.length-1;f>=0;f--)o[f]!==i&&r[f].remove();const a=document.createElement("div");a.className="dv-groupview dv-active-group",a.style.position="fixed",a.style.top="-10000px",a.style.left="0px",a.style.height="auto",a.style.width="auto",a.style.pointerEvents="none";const l=document.createElement("div");l.className="dv-tabs-and-actions-container",l.style.height="auto",l.style.width="auto",a.appendChild(l),l.appendChild(n),this._ctx.accessor.element.appendChild(a);const h=n.querySelector(".dv-tab-group-chip"),c=i.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top;if(h){const f=h.getBoundingClientRect(),m=a.getBoundingClientRect(),g=f.left-m.left+u,_=f.top-m.top+p;e.dataTransfer.setDragImage(a,g,_)}else e.dataTransfer.setDragImage(a,u,p);requestAnimationFrame(()=>{a.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))===null||t===void 0||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){const e=Lt(this._ctx.accessor.options);for(const n of this._chipRenderers.values()){var t,i,s;n.chip.element.draggable=e.html5,(t=n.html5DragSource)===null||t===void 0||t.setDisabled(!e.html5),(i=n.pointerDragSource)===null||i===void 0||i.setDisabled(!e.pointer),(s=n.pointerDragSource)===null||s===void 0||s.setTouchOnly(!e.pointerHandlesMouse)}}disposeChipDrag(e){var t;const i=this._chipRenderers.get(e);i&&((t=i.dragSourcesDisposable)===null||t===void 0||t.dispose(),i.html5DragSource=void 0,i.pointerDragSource=void 0,i.dragSourcesDisposable=void 0)}_buildChipGhostElement(e){const t=getComputedStyle(e),i=e.cloneNode(!0);return Array.from(t).forEach(s=>{i.style.setProperty(s,t.getPropertyValue(s),t.getPropertyPriority(s))}),i.style.position="absolute",i}disposeAll(){var e;(e=this._indicator)===null||e===void 0||e.dispose(),this._indicator=null;for(const[,i]of this._pendingTransitionCleanups)i();this._pendingTransitionCleanups.clear();for(const[,i]of this._chipRenderers){var t;i.chip.element.remove(),i.chip.dispose(),(t=i.dragSourcesDisposable)===null||t===void 0||t.dispose(),i.disposable.dispose()}this._chipRenderers.clear()}_ensureIndicator(){var e,t,i;const s=((e=(t=this._ctx.accessor.options.theme)===null||t===void 0?void 0:t.tabGroupIndicator)!==null&&e!==void 0?e:"wrap")==="none"?Bb:jb;this._indicator&&!(this._indicator instanceof s)&&(this._indicator.dispose(),this._indicator=null),(i=this._indicator)!==null&&i!==void 0||(this._indicator=new s({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var n;return(n=this._ctx.group.activePanel)===null||n===void 0?void 0:n.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:n=>{var r;return(r=this._chipRenderers.get(n))===null||r===void 0?void 0:r.chip.element},getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette}))}_createChipDragSources(e,t){const i=Lt(this._ctx.accessor.options);e.element.draggable=i.html5;const s=hi.getInstance(),n=()=>(s.setData([new Et(this._ctx.accessor.id,this._ctx.group.id,null,t.id)],Et.prototype),{dispose:()=>{s.clearData(Et.prototype)}}),r=Ei.createDragSource(e.element,{getData:n,disabled:!i.html5,isCancelled:()=>!Lt(this._ctx.accessor.options).html5,onDragStart:l=>{"dataTransfer"in l&&l.dataTransfer&&this.setGroupDragImage(l,t,e.element),this._callbacks.onChipDragStart(t,e,l)},onDragEnd:l=>{var h,c;(h=(c=this._callbacks).onChipDragEnd)===null||h===void 0||h.call(c,t,e,l)}}),o=()=>{s.clearData(Et.prototype)};e.element.addEventListener("dragend",o,{once:!0});const a=di.createDragSource(e.element,{getData:n,disabled:!i.pointer,touchOnly:!i.pointerHandlesMouse,isCancelled:()=>!Lt(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(e.element),offsetX:8,offsetY:8}),onDragStart:l=>{this._callbacks.onChipDragStart(t,e,l)}});return{html5DragSource:r,pointerDragSource:a,disposable:{dispose:()=>{r.dispose(),a.dispose(),e.element.removeEventListener("dragend",o)}}}}_ensureChipForGroup(e){const t=this._chipRenderers.get(e.id);if(t){if(!t.html5DragSource){const c=this._createChipDragSources(t.chip,e);t.html5DragSource=c.html5DragSource,t.pointerDragSource=c.pointerDragSource,t.dragSourcesDisposable=c.disposable}return}const i=this._ctx.accessor.options.createTabGroupChipComponent,s=i?i(e):new ih(this._ctx.accessor.tabGroupColorPalette);s.init({tabGroup:e,api:this._ctx.accessor.api});const n=this._createChipDragSources(s,e),r=[e.onDidChange(()=>{var c;(c=s.update)===null||c===void 0||c.call(s,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})],o=c=>{var u;(u=this._chipRenderers.get(e.id))===null||u===void 0||(u=u.pointerDragSource)===null||u===void 0||u.cancelPending(),this._callbacks.onChipContextMenu(e,c)};s instanceof ih?r.push(s.onContextMenu(o)):r.push(new Ha(s.element,{onLongPress:o}),Z(s.element,"contextmenu",o));const a=this._ctx.getDirection()==="vertical",l=new or(s.element,{acceptedTargetZones:a?["top"]:["left"],overlayModel:{activationSize:{value:100,type:"percentage"}},canDisplayOverlay:(c,u)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;const p=Ie();if(this._ctx.accessor.id===p?.viewId){var f;return((f=this._ctx.accessor.options.theme)===null||f===void 0?void 0:f.tabAnimation)!=="smooth"}return this._ctx.group.model.canDisplayOverlay(c,u,"tab")}});r.push(l,l.onDrop(c=>{this._callbacks.onChipDrop(e,c)}));const h=new te(...r);this._chipRenderers.set(e.id,{chip:s,html5DragSource:n.html5DragSource,pointerDragSource:n.pointerDragSource,dragSourcesDisposable:n.disposable,disposable:h,dropTarget:l}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,s=e.panelIds;if(s.length===0){i.remove();return}const n=s[0],r=this._ctx.getTabMap().get(n);if(!r){i.remove();return}const o=r.value.element;i.nextSibling!==o&&this._ctx.tabsList.insertBefore(i,o)}_updateTabGroupClasses(){const e=this._ctx.group.model.getTabGroups(),t=this._ctx.getTabs(),i=this._ctx.getTabMap();let s=!1;const n=new Map;for(const a of e)for(const l of a.panelIds)n.set(l,a);for(const a of t){const l=a.value,h=l.panel.id,c=n.get(h),u=!!c;if(Y(l.element,"dv-tab--grouped",u),c){const p=c.panelIds,f=p[0]===h,m=p[p.length-1]===h;Y(l.element,"dv-tab--group-first",f),Y(l.element,"dv-tab--group-last",m),Va(l.element,c.color,this._ctx.accessor.tabGroupColorPalette);const g=l.element.classList.contains("dv-tab--group-collapsed");if(!c.collapsed&&g){var r;s=!0,l.element.classList.remove("dv-tab--group-collapsed"),l.element.classList.add("dv-tab--group-expanding"),(r=this._pendingTransitionCleanups.get(h))===null||r===void 0||r();const _=()=>{l.element.classList.remove("dv-tab--group-expanding"),l.element.style.removeProperty("width"),l.element.removeEventListener("transitionend",_),clearTimeout(T),this._pendingTransitionCleanups.delete(h)},T=setTimeout(_,300);this._pendingTransitionCleanups.set(h,_),l.element.addEventListener("transitionend",_)}}else Y(l.element,"dv-tab--group-first",!1),Y(l.element,"dv-tab--group-last",!1),l.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),l.element.style.removeProperty("width"),l.element.style.removeProperty("--dv-tab-group-color")}const o=new Set;for(const a of e)if(o.add(a.id),a.collapsed&&a.panelIds.some(l=>{const h=i.get(l);return h&&!h.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const l=[];for(const h of a.panelIds){const c=i.get(h);c&&(c.value.element.style.transition="none",c.value.element.classList.add("dv-tab--group-collapsed"),l.push(c.value.element))}if(l.length>0){l[0].offsetHeight;for(const h of l)h.style.removeProperty("transition")}}else{s=!0;const l=this._ctx.getDirection()==="vertical";for(const h of a.panelIds){const c=i.get(h);if(c&&!c.value.element.classList.contains("dv-tab--group-collapsed")){const u=c.value.element.getBoundingClientRect();l?c.value.element.style.height=`${u.height}px`:c.value.element.style.width=`${u.width}px`,c.value.element.offsetHeight,c.value.element.classList.add("dv-tab--group-collapsed")}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),s?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}},Hb=class extends te{get _tabs(){return this.host.tabItems}get _tabMap(){return this.host.tabMap}get _tabsList(){return this.host.tabsList}get _direction(){return this.host.direction}get group(){return this.host.groupPanel}get accessor(){return this.host.component}get _tabGroupManager(){return this.host.tabGroupManager}get _wrapMode(){return this._tabsList.classList.contains(wu)}get animState(){return this._animState}set animState(e){this._animState=e}get pendingCollapse(){return this._pendingCollapse}set pendingCollapse(e){this._pendingCollapse=e}set voidContainerElement(e){this._voidContainer=e}constructor(e){super(),this.host=e,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._wrapIndicatorEl=null,this.addDisposables({dispose:()=>{var t;(t=this._flipTransitionCleanup)===null||t===void 0||t.call(this)}})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){const e=new Map;for(const t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;const e=this._direction==="vertical";let t=0;for(const i of this._tabs){const s=i.value.element.getBoundingClientRect();t+=e?s.height:s.width}return t/this._tabs.length}handlePointerDragMove(e,t){var i;const s=((i=this._tabsList.ownerDocument)!==null&&i!==void 0?i:document).elementFromPoint(e,t);if(!(s&&(this._tabsList.contains(s)||this._extendedDropZone&&this._extendedDropZone.contains(s)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this.processDragLeave(s));return}this._pointerInsideTabsList=!0,this.processDragOver(e,t)}handlePointerDragEnd(e){e&&this._animState&&this._animState.sourceIndex!==-1&&!this._animState.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&this.isPointInsideTabsList(e.clientX,e.clientY)&&this.commitPointerReorder(e.pointerEvent),this._pointerInsideTabsList=!1,this.resetDragAnimation()}isPointInsideTabsList(e,t){var i;const s=((i=this._tabsList.ownerDocument)!==null&&i!==void 0?i:document).elementFromPoint(e,t);return!!s&&this._tabsList.contains(s)}commitPointerReorder(e){const t=this._animState;if(t?.currentInsertionIndex==null)return;const i=t.currentInsertionIndex,s=t.sourceIndex,n=i-(s!==-1&&s<i?1:0);this._animState=null,this.clearWrapDropIndicator(),this.uncollapseSourceTab(t.sourceTabId),n!==s&&this.host.fireDrop({event:e,index:n,targetTabGroupId:null})}processDragOver(e,t){if(this.accessor.options.disableDnd||(this._dropStaleAnimState(),!this._animState&&!this._initAnimStateForExternalDrag()))return!1;if(this._animState.sourceIndex!==-1){var i;(i=this.group.model.dropTargetContainer)===null||i===void 0||(i=i.model)===null||i===void 0||i.clear()}return this.handleDragOver({clientX:e,clientY:t}),!0}_dropStaleAnimState(){if(!this._animState)return;const e=Ie();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}_initAnimStateForExternalDrag(){var e;const t=Ie();if(((e=this.accessor.options.theme)===null||e===void 0?void 0:e.tabAnimation)==="default"&&!t?.tabGroupId||!t||!(t.panelId||t.tabGroupId)||t.groupId===this.group.id)return!1;const i=this.getAverageTabWidth();return this._animState=t.tabGroupId?this._makeGroupDragAnimState(t,i):this._makeTabDragAnimState(t,i),!0}_makeGroupDragAnimState(e,t){var i;const s=this.accessor.getPanel(e.groupId),n=s?.model.getTabGroups().find(o=>o.id===e.tabGroupId),r=t*((i=n?.panelIds.length)!==null&&i!==void 0?i:1)+t;return{sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left}}_makeTabDragAnimState(e,t){return{sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}processDragLeave(e){var t;if(this._animState&&!(e&&this._tabsList.contains(e))){if(e&&(!((t=this._extendedDropZone)===null||t===void 0)&&t.contains(e))){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}if(!(this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))))if(this.resetTabTransforms(),this._animState.sourceIndex===-1){var i;(i=this.group.model.dropTargetContainer)===null||i===void 0||(i=i.model)===null||i===void 0||i.clear(),this._animState=null}else this._animState.currentInsertionIndex=null}}handleDragOver(e){var t;if(!this._animState)return;if(this._wrapMode&&!this._animState.sourceTabGroupId){var i;this.handleWrappedDragOver(e.clientX,(i=e.clientY)!==null&&i!==void 0?i:0);return}const s=e.clientX,n=this._buildFirstPanelToGroupMap();let r=this._computeDragOverInsertionIndex(s,n),o=null;if(r!==null&&this._tabGroupManager.chipRenderers.size>0){const a=this._resolveInsertionAgainstTabGroups(s,r,n);r=a.insertionIndex,o=a.targetTabGroupId}r===this._animState.currentInsertionIndex&&o===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=r,this._animState.targetTabGroupId=o,((t=this.accessor.options.theme)===null||t===void 0?void 0:t.tabAnimation)==="smooth"&&this.applyDragOverTransforms())}_buildFirstPanelToGroupMap(){const e=new Map;if(this._tabGroupManager.chipRenderers.size===0)return e;for(const t of this.group.model.getTabGroups())t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&e.set(t.panelIds[0],t.id);return e}_computeDragOverInsertionIndex(e,t){const i=this._animState,s=i.sourceGroupPanelIds,n=e-i.cursorOffsetFromDragLeft-i.containerLeft;let r=0,o=null;for(let c=0;c<this._tabs.length;c++){const u=this._tabs[c].value;if(u.panel.id===i.sourceTabId||s?.has(u.panel.id))continue;const p=t.get(u.panel.id);if(p){var a;const g=(a=i.chipPositions.get(p))!==null&&a!==void 0?a:0;if(r+g>n){var l;(l=o)!==null&&l!==void 0||(o=c);break}r+=g}const f=i.tabPositions.get(u.panel.id),m=f?f.width:u.element.getBoundingClientRect().width;if(r+m/2<=n)r+=m,o=c+1;else{var h;(h=o)!==null&&h!==void 0||(o=c);break}}return o}_accumulatedWidthUpTo(e,t){const i=this._animState,s=i.sourceGroupPanelIds;let n=0;for(let o=0;o<this._tabs.length;o++){const a=this._tabs[o].value;if(a.panel.id===i.sourceTabId||s?.has(a.panel.id))continue;if(o>=e)break;const l=t.get(a.panel.id);if(l){var r;n+=(r=i.chipPositions.get(l))!==null&&r!==void 0?r:0}const h=i.tabPositions.get(a.panel.id);n+=h?h.width:a.element.getBoundingClientRect().width}return n}_resolveInsertionAgainstTabGroups(e,t,i){const s=!!this._animState.sourceTabGroupId,n=this._accumulatedWidthUpTo(t,i);for(const r of this.group.model.getTabGroups()){const o=this._evaluateTabGroupForInsertion(r,e,t,n,s);if(o)return o}return{insertionIndex:t,targetTabGroupId:null}}_evaluateTabGroupForInsertion(e,t,i,s,n){const r=this._resolveGroupRange(e);if(!r)return null;const{firstIdx:o,lastIdx:a}=r,l=i>=o&&i<=a,h=!l&&i===o-1;return!l&&!h?null:n?this._resolveGroupDragTarget(i,o,a,l):this._resolveTabDragTarget(e,t,i,s,o,h)}_resolveGroupRange(e){const t=this._animState,i=t.sourceGroupPanelIds,s=e.panelIds.filter(o=>o!==t.sourceTabId&&!i?.has(o));if(s.length===0)return null;const n=this._tabs.findIndex(o=>o.value.panel.id===s[0]),r=this._tabs.findIndex(o=>o.value.panel.id===s[s.length-1]);return n===-1||r===-1?null:{firstIdx:n,lastIdx:r}}_resolveGroupDragTarget(e,t,i,s){return s?{insertionIndex:e<(t+i+1)/2?t:i+1,targetTabGroupId:null}:{insertionIndex:e,targetTabGroupId:null}}_resolveTabDragTarget(e,t,i,s,n,r){var o;const a=this._animState,l=(o=a.chipPositions.get(e.id))!==null&&o!==void 0?o:0;if(r)return this._onlySourceBetween(i,n)?t>=(e.collapsed?a.containerLeft+s+l/2:a.containerLeft+s+l)?{insertionIndex:n,targetTabGroupId:e.id}:{insertionIndex:i,targetTabGroupId:null}:null;const h=a.containerLeft+s+l;return i===n?{insertionIndex:i,targetTabGroupId:t>=h?e.id:null}:{insertionIndex:i,targetTabGroupId:e.id}}_onlySourceBetween(e,t){const i=this._animState;for(let n=e;n<t;n++){var s;const r=this._tabs[n].value.panel.id;if(r!==i.sourceTabId&&!(!((s=i.sourceGroupPanelIds)===null||s===void 0)&&s.has(r)))return!1}return!0}handleWrappedDragOver(e,t){if(!this._animState)return;const i=this.computeWrappedInsertionIndex(e,t);i===this._animState.currentInsertionIndex&&this._animState.targetTabGroupId===null||(this._animState.currentInsertionIndex=i,this._animState.targetTabGroupId=null,this.updateWrapDropIndicator(i))}computeWrappedInsertionIndex(e,t){var i;const s=this._direction==="vertical",n=this._wrappedDragEntries();if(n.length===0)return this._tabs.length;const r=s?e:t,o=s?t:e,a=f=>s?f.left:f.top,l=f=>s?f.right:f.bottom,h=f=>s?f.top:f.left,c=f=>s?f.height:f.width,u=this._bucketWrappedLines(n,a,l),p=[...((i=u.find(f=>r>=f.start&&r<=f.end))!==null&&i!==void 0?i:this._nearestWrappedLine(u,r)).items].sort((f,m)=>h(f.rect)-h(m.rect));for(const f of p)if(o<h(f.rect)+c(f.rect)/2)return f.index;return p[p.length-1].index+1}_wrappedDragEntries(){var e,t;const i=(e=this._animState)===null||e===void 0?void 0:e.sourceTabId,s=(t=this._animState)===null||t===void 0?void 0:t.sourceGroupPanelIds,n=[];for(let r=0;r<this._tabs.length;r++){const o=this._tabs[r].value;o.panel.id!==i&&(s?.has(o.panel.id)||n.push({index:r,rect:o.element.getBoundingClientRect()}))}return n}_bucketWrappedLines(e,t,i){const s=[];for(const n of e){const r=t(n.rect),o=s.find(a=>Math.abs(a.start-r)<=2);o?(o.items.push(n),o.end=Math.max(o.end,i(n.rect))):s.push({start:r,end:i(n.rect),items:[n]})}return s.sort((n,r)=>n.start-r.start),s}_nearestWrappedLine(e,t){const i=s=>t<s.start?s.start-t:t-s.end;return e.reduce((s,n)=>i(n)<i(s)?n:s,e[0])}updateWrapDropIndicator(e){var t;this.clearWrapDropIndicator();const i=this._tabs.length;if(i===0)return;const s=(t=this._animState)===null||t===void 0?void 0:t.sourceTabId;if(e<i){const n=this._tabs[e].value.element;if(this._tabs[e].value.panel.id===s)return;n.classList.add("dv-tab--reorder-before"),this._wrapIndicatorEl=n}else{const n=this._tabs[i-1].value.element;n.classList.add("dv-tab--reorder-after"),this._wrapIndicatorEl=n}}clearWrapDropIndicator(){var e;(e=this._wrapIndicatorEl)===null||e===void 0||e.classList.remove("dv-tab--reorder-before","dv-tab--reorder-after"),this._wrapIndicatorEl=null}_removeClassInstantlyBatch(e,t){const i=[];for(const s of e)s.classList.contains(t)&&(s.style.transition="none",Y(s,t,!1),i.push(s));if(i.length>0){i[0].getBoundingClientRect();for(const s of i)s.style.removeProperty("transition")}}uncollapseSourceTab(e){const t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],"dv-tab--dragging")}applyDragOverTransforms(e=!1){var t;if(this._wrapMode)return;if(((t=this._animState)===null||t===void 0?void 0:t.currentInsertionIndex)==null){this.resetTabTransforms();return}if(this._pendingCollapse)return;const i=this._animState.currentInsertionIndex,s=this._computeGapWidth(),n=this._computeChipToShift(i);this._applyGapMargins(i,s,n,e)}_computeGapWidth(){const e=this._animState;if(e.sourceTabGroupId&&e.sourceGroupPanelIds)return e.sourceGapWidth;const t=e.tabPositions.get(e.sourceTabId);return t?t.width:this.getAverageTabWidth()}_computeChipToShift(e){if(this._tabGroupManager.chipRenderers.size===0)return null;for(const t of this.group.model.getTabGroups()){const i=this._chipToShiftForGroup(t,e);if(i!==void 0)return i}return null}_chipToShiftForGroup(e,t){const i=this._animState;if(e.id===i.sourceTabGroupId||e.panelIds.includes(i.sourceTabId))return;const s=e.panelIds.filter(r=>{var o;return r!==i.sourceTabId&&!(!((o=i.sourceGroupPanelIds)===null||o===void 0)&&o.has(r))});if(s.length===0)return;const n=this._tabs.findIndex(r=>r.value.panel.id===s[0]);if((!i.targetTabGroupId||i.targetTabGroupId===e.id&&e.collapsed)&&!(n<t)){if(this._onlySourceBetween(t,n)){const r=this._tabGroupManager.chipRenderers.get(e.id);if(r)return r.chip.element}return null}}_applyGapMargins(e,t,i,s){const n=this._animState,r=n.sourceGroupPanelIds;let o=!1;for(const[a,l]of this._tabGroupManager.chipRenderers)a!==n.sourceTabGroupId&&this._clearMargin(l.chip.element,s);i&&(this._setMargin(i,`${t}px`,s),o=!0);for(let a=0;a<this._tabs.length;a++){const l=this._tabs[a].value;l.panel.id!==n.sourceTabId&&(r?.has(l.panel.id)||(!o&&a>=e?(this._setMargin(l.element,`${t}px`,s),o=!0):this._clearMargin(l.element,s)))}this._tabGroupManager.trackUnderlines()}_shiftingClass(e){return e.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting"}_setMargin(e,t,i){i?(e.style.transition="none",e.style.marginLeft=t,e.getBoundingClientRect(),e.style.removeProperty("transition")):e.style.marginLeft=t,Y(e,this._shiftingClass(e),!0)}_clearMargin(e,t){const i=this._shiftingClass(e),s=this._pendingMarginCleanups.get(e);if(s&&s(),t||!e.style.marginLeft)e.style.removeProperty("margin-left"),Y(e,i,!1);else{e.style.marginLeft="0px",Y(e,i,!0);const n=()=>{e.style.removeProperty("margin-left"),Y(e,i,!1),e.removeEventListener("transitionend",n),clearTimeout(r),this._pendingMarginCleanups.delete(e)},r=setTimeout(n,300);this._pendingMarginCleanups.set(e,n),e.addEventListener("transitionend",n)}}resetTabTransforms(){this.clearWrapDropIndicator();for(const[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(const e of this._tabs)e.value.element.style.removeProperty("margin-left"),e.value.element.style.removeProperty("margin-right"),e.value.element.style.removeProperty("margin-top"),e.value.element.style.removeProperty("margin-bottom"),e.value.element.style.removeProperty("transform"),Y(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),Y(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}commitGroupMove(e,t){const i=Ie();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(r=>r.id===e)){var s;if(((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="smooth"){this._clearGroupDragClasses(e);const r=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(r,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t)}else if(i){var n;this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:i.groupId,tabGroupId:(n=i.tabGroupId)!==null&&n!==void 0?n:e},to:{group:this.group,position:"center",index:t}})}}_clearGroupDragClasses(e){const t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],"dv-tab-group-chip--dragging"),this._removeClassInstantlyBatch(this._tabs.map(s=>s.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),"dv-tab--dragging"),this._animState=null;for(const[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty("display")}}runFlipAnimation(e,t,i=!1,s){if(this._wrapMode)return;let n=!1;for(let r=0;r<this._tabs.length;r++)this._applyFlipTransform(this._tabs[r],r,t,i,e,s)&&(n=!0);n&&this._scheduleFlipReset()}_applyFlipTransform(e,t,i,s,n,r){const o=this._direction==="vertical",a=e.value.panel.id;if(a===i){if(!s)return!1;const u=e.value.element.getBoundingClientRect();return e.value.element.style.transform=o?`translateY(${u.height}px)`:`translateX(${u.width}px)`,Y(e.value.element,"dv-tab--shifting",!0),!0}if(r!==void 0&&(t<r.from||t>r.to))return!1;const l=n.get(a);if(!l)return!1;const h=e.value.element.getBoundingClientRect(),c=o?l.top-h.top:l.left-h.left;return Math.abs(c)<1?!1:(e.value.element.style.transform=o?`translateY(${c}px)`:`translateX(${c}px)`,Y(e.value.element,"dv-tab--shifting",!0),!0)}_scheduleFlipReset(){requestAnimationFrame(()=>{var e;for(const s of this._tabs)s.value.element.style.transform&&(s.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)===null||e===void 0||e.call(this);const t=s=>{if(s.propertyName==="transform"){i();for(const n of this._tabs)Y(n.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},i=()=>{this._tabsList.removeEventListener("transitionend",t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=i,this._tabsList.addEventListener("transitionend",t)})}},Fb=class extends te{get _animState(){return this._reorder.animState}set _animState(e){this._reorder.animState=e}get _pendingCollapse(){return this._reorder.pendingCollapse}set _pendingCollapse(e){this._reorder.pendingCollapse=e}get tabItems(){return this._tabs}get tabMap(){return this._tabMap}get tabsList(){return this._tabsList}get groupPanel(){return this.group}get component(){return this.accessor}get tabGroupManager(){return this._tabGroupManager}fireDrop(e){this._onDrop.fire(e)}setOverflowExclude(e){this._overflowExclude=e,this.refreshOverflow()}setForcedOverflow(e){this._forcedOverflow=e,this.refreshOverflow()}refreshOverflow(){this._showTabsOverflowControl&&this.toggleDropdown({reset:!1}),this._applyPinnedSticky()}setPinnedSticky(e){this._pinnedSticky!==e&&(this._pinnedSticky=e,this._applyPinnedSticky())}_applyPinnedSticky(){const e=this._pinnedSticky?this._tabs.filter(i=>this._overflowExclude(i.value.panel.id)):[];if(e.length===0&&!this._hasPinnedStickyStyling)return;for(const i of this._tabs){const s=i.value.element;s.classList.contains("dv-tab--pinned-sticky")&&(s.classList.remove("dv-tab--pinned-sticky"),s.style.removeProperty("--dv-pinned-sticky-left"))}if(e.length===0){this._hasPinnedStickyStyling=!1;return}const t=e.map(i=>i.value.element.offsetLeft);e.forEach((i,s)=>{const n=i.value.element;n.classList.add("dv-tab--pinned-sticky"),n.style.setProperty("--dv-pinned-sticky-left",`${t[s]}px`)}),this._hasPinnedStickyStyling=!0}get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e)if(this._showTabsOverflowControl=e,e){const t=new A_(this._tabsList);this._observerDisposable.value=new te(t,t.onDidChange(i=>{const s=i.hasScrollX||i.hasScrollY;this.toggleDropdown({reset:!s}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),Z(this._tabsList,"scroll",()=>{this.toggleDropdown({reset:!1}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}else this._observerDisposable.value=xe.NONE}get element(){return this._element}get tabsListElement(){return this._tabsList}set voidContainer(e){var t;(t=this._voidContainerListeners)===null||t===void 0||t.dispose(),this._voidContainerListeners=null,this._reorder.voidContainerElement=e,e&&(this._voidContainerListeners=new te(Z(e,"dragover",i=>{this._animState&&i.preventDefault()}),Z(e,"drop",i=>{var s;!((s=this._animState)===null||s===void 0)&&s.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(i.preventDefault(),i.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,s=(t=this._animState.currentInsertionIndex)!==null&&t!==void 0?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,s),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute("aria-orientation",e==="vertical"?"vertical":"horizontal"),this._scrollbar&&(this._scrollbar.orientation=e),Mt(this._tabsList,"dv-horizontal","dv-vertical"),e==="vertical"?Ot(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(Mt(this._tabsList,"dv-tabs-container-vertical"),Ot(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new Ge,this._pointerActivation=new Ge,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._overflowExclude=()=>!1,this._forcedOverflow=()=>!1,this._pinnedSticky=!1,this._hasPinnedStickyStyling=!1,this._direction="horizontal",this._voidContainerListeners=null,this._onTabDragStart=new G,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new G,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this._tabsList.setAttribute("role","tablist"),this._tabsList.setAttribute("aria-orientation",this._direction==="vertical"?"vertical":"horizontal"),this.showTabsOverflowControl=i.showTabsOverflowControl,t.options.scrollbars==="native"?this._element=this._tabsList:(this._scrollbar=new _u(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Wb({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(s,n)=>{var r;(r=this.accessor.contextMenuService)===null||r===void 0||r.showForChip(s,this.group,n)},onChipDragStart:(s,n,r)=>{this._handleChipDragStart(s,n,r)},onChipDragEnd:()=>{this._reorder.resetDragAnimation()},onChipDrop:(s,n)=>{this._handleChipDrop(s,n)}}),this._reorder=new Hb(this),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._pointerActivation,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,this._reorder,Bn.getInstance().onDragEnd(s=>{this._reorder.handlePointerDragEnd(s)}),Bn.getInstance().onDragMove(s=>{this._reorder.handlePointerDragMove(s.clientX,s.clientY)}),Z(this.element,"pointerdown",s=>{s.defaultPrevented||s.button===0&&this.accessor.doSetGroupActive(this.group)}),Z(this._tabsList,"wheel",s=>{const n=this._direction==="vertical",r=n?s.deltaY||s.deltaX:s.deltaX||s.deltaY;if(r===0)return;const o=n?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(o<=0)return;const a=n?this._tabsList.scrollTop:this._tabsList.scrollLeft;r<0&&a<=0||r>0&&a>=o||(s.preventDefault(),s.stopPropagation(),n?this._tabsList.scrollTop=a+r:this._tabsList.scrollLeft=a+r)},{passive:!1}),Z(this._tabsList,"keydown",s=>{this._onKeyDown(s)}),Z(this._tabsList,"dragover",s=>{this._reorder.processDragOver(s.clientX,s.clientY)&&s.preventDefault()},!0),Z(this._tabsList,"dragleave",s=>{this._reorder.processDragLeave(s.relatedTarget)},!0),Z(this._tabsList,"dragend",()=>{this._reorder.resetDragAnimation()}),Z(this._tabsList,"drop",s=>{var n,r,o;if(((n=this._animState)===null||n===void 0?void 0:n.currentInsertionIndex)==null||((r=this.accessor.options.theme)===null||r===void 0?void 0:r.tabAnimation)!=="smooth"&&!this._animState.sourceTabGroupId)return;s.stopPropagation(),s.preventDefault(),(o=this.group.model.dropTargetContainer)===null||o===void 0||(o=o.model)===null||o===void 0||o.clear();const a=this._animState;if(this._animState=null,this._pendingCollapse=!1,a.sourceTabGroupId){this._commitGroupMove(a.sourceTabGroupId,a.currentInsertionIndex);return}const l=a.currentInsertionIndex,h=a.sourceIndex,c=l-(h!==-1&&h<l?1:0),u=this.group.model.getTabGroupForPanel(a.sourceTabId);if(c===h&&!a.targetTabGroupId&&!u){this._reorder.uncollapseSourceTab(a.sourceTabId),this.resetTabTransforms();return}this._reorder.uncollapseSourceTab(a.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:s,index:c,targetTabGroupId:a.targetTabGroupId}),this.runFlipAnimation(p,a.sourceTabId,a.sourceIndex===-1,{from:Math.min(h,c),to:Math.max(h,c)})},!0),xe.from(()=>{var s;(s=this._voidContainerListeners)===null||s===void 0||s.dispose(),this._reorder.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:n,disposable:r}of this._tabs)r.dispose(),n.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){var t;return(t=this._tabMap.get(e))===null||t===void 0?void 0:t.value.element.id}getPanelForTab(e){for(const{value:t}of this._tabs)if(t.element===e||t.element.contains(e))return t.panel}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){const t=this._tabs.findIndex(o=>o.value.element===e.target);if(t===-1)return;const i=this._direction==="vertical",s=i?"ArrowDown":"ArrowRight",n=i?"ArrowUp":"ArrowLeft",r=this._tabs.length-1;switch(e.key){case s:e.preventDefault(),this._focusTab(Math.min(t+1,r));break;case n:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case"Home":e.preventDefault(),this._focusTab(0);break;case"End":e.preventDefault(),this._focusTab(r);break;case"Enter":case" ":e.preventDefault(),this.accessor.withOrigin("user",()=>this._tabs[t].value.panel.api.setActive());break;case"Delete":case"Backspace":e.preventDefault(),this._closeTab(t);break}}_closeTab(e){var t,i,s,n,r;const o=(t=this._tabs[e])===null||t===void 0?void 0:t.value;if(!o)return;const a=(i=(s=(n=this._tabs[e+1])===null||n===void 0?void 0:n.value)!==null&&s!==void 0?s:(r=this._tabs[e-1])===null||r===void 0?void 0:r.value)===null||i===void 0?void 0:i.panel.id;if(o.panel.api.close(),a!==void 0){const l=this._tabs.findIndex(h=>h.value.panel.id===a);l>-1&&this._focusTab(l)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){var e;if(this._tabs.length===0)return;const t=(e=this.group.activePanel)===null||e===void 0?void 0:e.id,i=t?this._tabs.findIndex(s=>s.value.panel.id===t):-1;this._focusTab(i>-1?i:0)}setActivePanel(e){const t=this._direction==="vertical";for(const i of this._tabs){const s=e.id===i.value.panel.id;i.value.setActive(s),s&&this._scrollTabIntoView(i.value.element,t)}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}_scrollTabIntoView(e,t){const i=e.parentElement;if(!i)return;const s=t?e.offsetTop:e.offsetLeft,n=t?e.offsetHeight:e.offsetWidth,r=t?i.scrollTop:i.scrollLeft,o=t?i.clientHeight:i.clientWidth;(s<r||s+n>r+o)&&(t?i.scrollTop=s:i.scrollLeft=s)}_activateOnPointerDown(e){if(!Lt(this.accessor.options).html5){this.group.model.openPanel(e);return}const t=requestAnimationFrame(()=>{this._tabMap.has(e.id)&&this.group.model.openPanel(e)});this._pointerActivation.value={dispose:()=>cancelAnimationFrame(t)}}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;const i=new Ab(e,this.accessor,this.group);i.setContent(e.view.tab),this._direction!=="horizontal"&&i.setDirection(this._direction);const s={value:i,disposable:new te(i.onDragStart(n=>{var r;if(this._onTabDragStart.fire({nativeEvent:n,panel:e}),((r=this.accessor.options.theme)===null||r===void 0?void 0:r.tabAnimation)==="smooth"){const o=i.element.getBoundingClientRect().width,a=this._tabs.findIndex(l=>l.value===i);this._animState={sourceTabId:e.id,sourceIndex:a,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:o/2,sourceGapWidth:o,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var l,h;this._pendingCollapse=!1,this._animState&&(this._tabsList.classList.contains("dv-tabs-container--wrap")||(i.element.style.transition="none",Y(i.element,"dv-tab--dragging",!0),i.element.offsetHeight),(h=(l=this._animState).currentInsertionIndex)!==null&&h!==void 0||(l.currentInsertionIndex=a),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(n=>{n.defaultPrevented||this.group.api.location.type==="edge"&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),i.onPointerDown(n=>{if(n.defaultPrevented)return;const r=!this.accessor.options.disableFloatingGroups,o=this.group.api.location.type==="floating"&&this.size===1;if(r&&!o&&n.shiftKey){n.preventDefault();const a=this.accessor.getGroupPanel(i.panel.id),{top:l,left:h}=i.element.getBoundingClientRect(),{top:c,left:u}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(a,{x:h-u,y:l-c,inDragMode:!0});return}n.button===0&&this.group.api.location.type!=="edge"&&this.group.activePanel!==e&&this._activateOnPointerDown(e)}),i.onDrop(n=>{const r=this._animState;this._animState=null,this._pendingCollapse=!1;const o=this._tabs.findIndex(u=>u.value===i);if(r){var a;const u=n.position==="right"?o+1:o;if(r.sourceTabGroupId){var l;this._commitGroupMove(r.sourceTabGroupId,(l=r.currentInsertionIndex)!==null&&l!==void 0?l:u);return}this._reorder.uncollapseSourceTab(r.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:n.nativeEvent,index:u,targetTabGroupId:r.targetTabGroupId}),((a=this.accessor.options.theme)===null||a===void 0?void 0:a.tabAnimation)==="smooth"&&this.runFlipAnimation(p,r.sourceTabId,r.sourceIndex===-1,r.sourceIndex===-1?void 0:{from:Math.min(r.sourceIndex,u),to:Math.max(r.sourceIndex,u)})}else{var h,c;const u=this._direction==="vertical"?"bottom":"right",p=n.position===u?o+1:o,f=Ie(),m=f?this._tabs.findIndex(T=>T.value.panel.id===f.panelId):-1,g=p-(m!==-1&&m<p?1:0),_=(h=(c=this.group.model.getTabGroupForPanel(i.panel.id))===null||c===void 0?void 0:c.id)!==null&&h!==void 0?h:null;this._onDrop.fire({event:n.nativeEvent,index:g,targetTabGroupId:_})}}),i.onWillShowOverlay(n=>{this._onWillShowOverlay.fire(new Ws(n,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Ie}))}))};this.addTab(s,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;((t=this._animState)===null||t===void 0?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),s=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),s){const{value:n,disposable:r}=s;r.dispose(),n.dispose(),n.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw new Error("invalid location");const i=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,i),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){const t=this._tabs.some(o=>!this._overflowExclude(o.value.panel.id)&&this._forcedOverflow(o.value.panel.id));if(e.reset&&!t){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],pinnedTabs:[],reset:!0});return}const i=this._tabs.filter(o=>!this._overflowExclude(o.value.panel.id)&&(this._forcedOverflow(o.value.panel.id)||!e.reset&&!wr(o.value.element,this._tabsList))).map(o=>o.value.panel.id),s=e.reset?[]:this._tabs.filter(o=>this._overflowExclude(o.value.panel.id)&&o.value.element.getBoundingClientRect().width>0&&!wr(o.value.element,this._tabsList)).map(o=>o.value.panel.id),n=new Set(i),r=[];for(const o of this.group.model.getTabGroups()){const a=this._tabGroupManager.chipRenderers.get(o.id),l=a&&!wr(a.chip.element,this._tabsList),h=o.panelIds.length>0&&o.panelIds.every(c=>n.has(c));if((l||h)&&(r.push(o.id),o.collapsed))for(const c of o.panelIds)n.has(c)||(n.add(c),i.push(c))}this._onOverflowTabsChange.fire({tabs:i,tabGroups:r,pinnedTabs:s,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var s;const n=e.panelIds[0],r=n?this._tabs.findIndex(h=>h.value.panel.id===n):-1,o=t.element.getBoundingClientRect();let a=o.width;for(const h of e.panelIds){const c=this._tabMap.get(h);c&&(a+=c.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:"",sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:o.width,cursorOffsetFromDragLeft:i.clientX-o.left,sourceGapWidth:a,containerLeft:this._tabsList.getBoundingClientRect().left},((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)!=="smooth")return;const l=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,c;if(this._pendingCollapse=!1,!this._animState)return;for(const f of this._tabs)l.has(f.value.panel.id)&&(f.value.element.style.transition="none",Y(f.value.element,"dv-tab--dragging",!0));const u=this._tabGroupManager.chipRenderers.get(e.id);u&&(u.chip.element.style.transition="none",Y(u.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const p=this._tabGroupManager.groupUnderlines.get(e.id);p&&(p.style.display="none"),(c=(h=this._animState).currentInsertionIndex)!==null&&c!==void 0||(h.currentInsertionIndex=r),this.applyDragOverTransforms(!0);for(const f of this._tabs)l.has(f.value.panel.id)&&f.value.element.style.removeProperty("transition");u&&u.chip.element.style.removeProperty("transition")})}_handleChipDrop(e,t){const i=e.panelIds[0];if(!i)return;const s=this._tabs.findIndex(a=>a.value.panel.id===i);if(s===-1)return;const n=Ie(),r=n?.groupId===this.group.id&&n?.panelId?this._tabs.findIndex(a=>a.value.panel.id===n.panelId):-1,o=s-(r!==-1&&r<s?1:0);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._reorder.setExtendedDropZone(e)}setExternalInsertionIndex(e){this._reorder.setExternalInsertionIndex(e)}clearExternalAnimState(){this._reorder.clearExternalAnimState()}snapshotTabPositions(){return this._reorder.snapshotTabPositions()}handleDragOver(e){this._reorder.handleDragOver(e)}applyDragOverTransforms(e=!1){this._reorder.applyDragOverTransforms(e)}resetTabTransforms(){this._reorder.resetTabTransforms()}_commitGroupMove(e,t){this._reorder.commitGroupMove(e,t)}runFlipAnimation(e,t,i=!1,s){this._reorder.runFlipAnimation(e,t,i,s)}};function Vb(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=gu();return e.appendChild(i),e.appendChild(t),{element:e,update:s=>{t.textContent=`${s.tabs}`}}}var Ub=class extends te{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}get direction(){return this._direction}set direction(e){this._direction=e,e==="vertical"?(Ot(this._element,"dv-groupview-header-vertical"),Ot(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(Mt(this._element,"dv-groupview-header-vertical"),Mt(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e)}get element(){return this._element}get tabsListElement(){return this.tabs.tabsListElement}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction="horizontal",this._dropIndexResolver=(i,s)=>s,this._pinnedRow=void 0,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._overflowPinnedTabs=[],this._dropdownDisposable=new Ge,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onGroupDragStart=new G,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",Y(this._element,"dv-full-width-single-tab",this.accessor.options.singleTabMode==="fullwidth"),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="dv-right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="dv-left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="dv-pre-actions-container",this.tabs=new Fb(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Rb(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(i=>this._onDrop.fire(i)),this.tabs.onWillShowOverlay(i=>this._onWillShowOverlay.fire(i)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(i=>{this.toggleDropdown(i)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(i=>{this._onGroupDragStart.fire({nativeEvent:i,group:this.group})}),this.voidContainer.onDrop(i=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:i.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(i=>{this._onWillShowOverlay.fire(new Ws(i,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Ie}))}),Z(this.leftActionsContainer,"dragleave",i=>{const s=i.relatedTarget;!this.leftActionsContainer.contains(s)&&!this._element.contains(s)&&this.tabs.clearExternalAnimState()}),Z(this.voidContainer.element,"dragleave",i=>{const s=i.relatedTarget;this.voidContainer.element.contains(s)||(this._element.contains(s)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),Z(this.voidContainer.element,"pointerdown",i=>{if(!i.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&i.shiftKey&&this.group.api.location.type!=="floating"&&this.group.api.location.type!=="edge"){i.preventDefault();const{top:s,left:n}=this.element.getBoundingClientRect(),{top:r,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-o+20,y:s-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display="")}hide(){this._element.style.display="none"}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&(this.rightActions.remove(),this.rightActions=void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&(this.leftActions.remove(),this.leftActions=void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&(this.preActions.remove(),this.preActions=void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}getPanelForTab(e){return this.tabs.getPanelForTab(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}setOverflowExclude(e){this.tabs.setOverflowExclude(e)}setForcedOverflow(e){this.tabs.setForcedOverflow(e)}setPinnedSticky(e){this.tabs.setPinnedSticky(e)}refreshOverflow(){this.tabs.refreshOverflow()}setPinnedRow(e){this._pinnedRow!==e&&(this._pinnedRow&&this._pinnedRow.remove(),this._pinnedRow=e,e&&(e.classList.add("dv-pinned-row"),this._element.insertBefore(e,this._element.firstChild)),Y(this._element,"dv-tabs-and-actions-container--pinned-row",!!e))}setDropIndexResolver(e){this._dropIndexResolver=e}resolveDropIndex(e,t){return this._dropIndexResolver(e,t)}updateClassnames(){Y(this._element,"dv-single-tab",this.size===1)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups,s=e.reset?[]:e.pinnedTabs;this._overflowTabs=t,this._overflowTabGroups=i,this._overflowPinnedTabs=s;const n=this._overflowTabs.length+this._overflowPinnedTabs.length;if(n>0&&this.dropdownPart){this.dropdownPart.update({tabs:n});return}if(n===0){this._dropdownDisposable.dispose();return}const r=document.createElement("div");r.className="dv-tabs-overflow-dropdown-root";const o=Vb();o.update({tabs:n}),this.dropdownPart=o,r.appendChild(o.element),this.rightActionsContainer.prepend(r),this._dropdownDisposable.value=new te(xe.from(()=>{var a,l;r.remove(),(a=this.dropdownPart)===null||a===void 0||(l=a.dispose)===null||l===void 0||l.call(a),this.dropdownPart=null}),Z(r,"pointerdown",a=>{a.preventDefault()},{capture:!0}),Z(r,"click",a=>{const l=B_(r),h={x:a.clientX,y:a.clientY,zIndex:l?.style.zIndex?`calc(${l.style.zIndex} * 2)`:void 0},c=this.createOverflowRenderContext(r,h),u=this.accessor.advancedOverflowService;u?u.renderOverflow({group:this.group,overflowTabs:[...this._overflowTabs],overflowTabGroups:[...this._overflowTabGroups],pinnedOverflowTabs:[...this._overflowPinnedTabs],context:c}):c.open(this.renderFreeOverflowList(c))}))}createOverflowRenderContext(e,t){const i=new Set(this._overflowTabGroups),s=this.group.model.getTabGroups(),n=new Map,r=new Map;for(const l of s)if(r.set(l.id,l),i.has(l.id))for(const h of l.panelIds)n.set(h,l);const o=()=>this.accessor.getPopupServiceForGroup(this.group),a=l=>{const h=document.createElement("div");h.className="dv-tabs-overflow-group-header";const c=document.createElement("span");c.className="dv-tabs-overflow-group-color",Va(c,l.color,this.accessor.tabGroupColorPalette),h.appendChild(c);const u=document.createElement("span");if(u.className="dv-tabs-overflow-group-label",u.textContent=l.label||l.id,h.appendChild(u),l.collapsed){const p=document.createElement("span");p.className="dv-tabs-overflow-group-collapsed-badge",p.textContent=`${l.panelIds.length}`,h.appendChild(p)}return h.addEventListener("click",()=>{o().close(),l.collapsed&&l.expand();const p=l.panelIds[0];if(p){const f=this.group.panels.find(m=>m.id===p);this.accessor.withOrigin("user",()=>f?.api.setActive())}}),h};return{overflowGroupIdForPanel:l=>{var h;return(h=n.get(l))===null||h===void 0?void 0:h.id},buildGroupHeader:l=>{const h=r.get(l);if(!(!h||!i.has(h.id)))return a(h)},buildPinnedHeader:()=>{const l=document.createElement("div");l.className="dv-tabs-overflow-group-header dv-tabs-overflow-pinned-header";const h=mu();h.classList.add("dv-tabs-overflow-pinned-icon"),l.appendChild(h);const c=document.createElement("span");return c.className="dv-tabs-overflow-group-label",c.textContent="Pinned",l.appendChild(c),l},buildRow:l=>{const h=this.group.panels.find(g=>g.id===l);if(!h)return;const c=this.tabs.tabs.find(g=>g.panel.id===l),u=n.get(l),p=h.view.createTabRenderer("headerOverflow").element,f=document.createElement("div");Y(f,"dv-tab",!0),Y(f,"dv-active-tab",h.api.isActive),Y(f,"dv-inactive-tab",!h.api.isActive),u&&Y(f,"dv-tab--grouped",!0);const m=()=>{u?.collapsed&&u.expand(),c?.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.accessor.withOrigin("user",()=>h.api.setActive())};return f.addEventListener("click",g=>{o().close(),!g.defaultPrevented&&m()}),f.appendChild(p),{element:f,panel:h,activate:()=>{o().close(),m()}}},open:l=>{o().openPopover(l,t)},close:()=>o().close(),focusTrigger:()=>{e.tabIndex=-1,e.focus()}}}renderFreeOverflowList(e){const t=document.createElement("div");t.style.overflow="auto",t.className="dv-tabs-overflow-container";const i=this._overflowPinnedTabs.map(n=>e.buildRow(n)).filter(n=>n!=null);if(i.length>0){t.appendChild(e.buildPinnedHeader());for(const n of i)t.appendChild(n.element)}const s=new Set;for(const n of this.tabs.tabs.filter(r=>this._overflowTabs.includes(r.panel.id))){const r=e.overflowGroupIdForPanel(n.panel.id);if(r&&!s.has(r)){s.add(r);const a=e.buildGroupHeader(r);a&&t.appendChild(a)}const o=e.buildRow(n.panel.id);o&&t.appendChild(o.element)}return t}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},Kb=class extends te{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;const t=e===""?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){var i,s;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new G,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new G,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new G,this.onDidDestroy=this._onDidDestroy.event,this._label=(i=t?.label)!==null&&i!==void 0?i:"",this._color=t?.color===""?void 0:t?.color,this._collapsed=(s=t?.collapsed)!==null&&s!==void 0?s:!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;const i=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(i,0,e),this._onDidPanelChange.fire({panelId:e,type:"add"})}removePanel(e){if(this.isDisposed)return!1;const t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:"remove"}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){const e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},Ka=class extends za{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},Du=class extends Ka{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},qb=class extends te{get tabGroups(){return this._tabGroups}get element(){throw new Error("dockview: not supported")}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,Y(this.container,"dv-locked-groupview",e==="no-drop-target"||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get tabsListElement(){return this.tabsContainer.tabsListElement}getPanelForTab(e){return this.tabsContainer.getPanelForTab(e)}get isContentFocused(){return document.activeElement?no(document.activeElement,this.contentContainer.element):!1}get headerPosition(){var e;return(e=this._headerPosition)!==null&&e!==void 0?e:"top"}set headerPosition(e){var t;this._headerPosition=e,this.invalidateHeaderSize(),Mt(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),Ot(this.container,`dv-groupview-header-${e}`);const i=e==="top"||e==="bottom"?"horizontal":"vertical",s=this._headerDirection;if(this._headerDirection=i,this.tabsContainer.direction=i,this.header.direction=i,!((t=this._activePanel)===null||t===void 0)&&t.layout){const{width:r,height:o}=this.contentDimensions();this._activePanel.layout(r,o)}if(this.updateHeaderActions(),s!==void 0&&s!==i){var n;(n=this.groupPanel)===null||n===void 0||n.api._onDidHeaderDirectionChange.fire({direction:i,position:e})}}get location(){return this._location}set location(e){this._location=e,Y(this.container,"dv-groupview-floating",!1),Y(this.container,"dv-groupview-popout",!1),Y(this.container,"dv-groupview-edge",!1);const t=i=>{this.contentContainer.dropTarget.setTargetZones(i),this.contentContainer.pointerDropTarget.setTargetZones(i)};switch(e.type){case"grid":t(["top","bottom","left","right","center"]);break;case"floating":t(["top","bottom","left","right","center"]),Y(this.container,"dv-groupview-floating",!0);break;case"popout":t(["top","bottom","left","right","center"]),Y(this.container,"dv-groupview-popout",!0);break;case"edge":t(["center"]),Y(this.container,"dv-groupview-edge",!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,n){var r,o;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=n,this._isGroupActive=!1,this._locked=!1,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new G,this.onMove=this._onMove.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new G,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new G,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new G,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new G,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new G,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new G,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new G,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new G,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new G,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new G,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new G,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new G,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new G,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new G,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,Y(this.container,"dv-groupview",!0),this.container.setAttribute("role","region"),this._api=new $a(this.accessor),this.tabsContainer=new Ub(this.accessor,this.groupPanel),this.contentContainer=new Sb(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=(r=s.locked)!==null&&r!==void 0?r:!1,this.headerPosition=(o=s.headerPosition)!==null&&o!==void 0?o:t.defaultHeaderPosition,this.addDisposables(Ui(this.tabsContainer.element,()=>{if(this.isDisposed)return;const a=this.measureHeaderSize();a!==this._cachedHeaderSize&&(this._cachedHeaderSize=a,this.layout(this._width,this._height))}),this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(a=>{this._onTabDragStart.fire(a)}),this.tabsContainer.onGroupDragStart(a=>{this._onGroupDragStart.fire(a)}),this.tabsContainer.onDrop(a=>{var l;const h=Ie(),c=(l=h?.panelId)!==null&&l!==void 0?l:null,u=c?this.tabsContainer.resolveDropIndex(c,a.index):a.index;if(this.handleDropEvent("header",a.event,"center",u),c&&a.targetTabGroupId){const p=this._tabGroupMap.get(a.targetTabGroupId);let f;if(p){const m=this._panels.findIndex(g=>g.id===c);if(m!==-1){f=0;for(const g of p.panelIds)this._panels.findIndex(_=>_.id===g)<m&&f++}}this.addPanelToTabGroup(a.targetTabGroupId,c,f)}else c&&a.targetTabGroupId===null&&this.removePanelFromTabGroup(c)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(a=>{this.handleDropEvent("content",a.nativeEvent,a.position,void 0,a.edge)}),this.contentContainer.pointerDropTarget.onDrop(a=>{this.handleDropEvent("content",a.nativeEvent,a.position,void 0,a.edge)}),this.tabsContainer.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(a)}),this.contentContainer.dropTarget.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(new Ws(a,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Ie}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(new Ws(a,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Ie}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation("tab-group",e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){var t;const i=(t=e?.id)!==null&&t!==void 0?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,s=new Kb(i,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(s),this._tabGroupMap.set(i,s),this._tabGroupDisposables.set(i,new te(s.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:s})}),s.onDidCollapseChange(n=>{n?this._handleGroupCollapse(s):this._handleGroupExpand(s),this._onDidTabGroupCollapsedChange.fire({tabGroup:s})}),s.onDidDestroy(()=>{this._removeTabGroupInternal(s)}))),this._onDidCreateTabGroup.fire({tabGroup:s}),s}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{const i=[...t.panelIds];for(const s of i)t.removePanel(s),this._panelToTabGroup.delete(s),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:s});t.dispose()})}addPanelToTabGroup(e,t,i){const s=this._tabGroupMap.get(e);if(!s||!this._panels.some(r=>r.id===t))return;const n=this.getTabGroupForPanel(t);n?.id!==e&&this._bracketTabGroupMutation(()=>{n&&this.removePanelFromTabGroup(t),s.addPanel(t,i),this._panelToTabGroup.set(t,s),this._enforceContiguity(s,t),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:t})})}movePanelWithinGroup(e,t,i){const s=this._tabGroupMap.get(e);s?.containsPanel(t)&&(s.removePanel(t),s.addPanel(t,i),this._enforceContiguity(s,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const s=this._findTabGroupForPanel(e),n=this._tabGroupMap.get(t);n&&(s&&(s.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:s,panelId:e}),s.isEmpty&&s.dispose()),n.addPanel(e,i),this._panelToTabGroup.set(e,n),this._enforceContiguity(n,e),this._onDidAddPanelToTabGroup.fire({tabGroup:n,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||i.panelIds.length===0)return;const s=new Set(i.panelIds),n=i.panelIds.map(l=>this._panels.find(h=>h.id===l)).filter(l=>l!==void 0);if(n.length===0)return;let r=0;for(let l=0;l<Math.min(t,this._panels.length);l++)s.has(this._panels[l].id)&&r++;for(const l of n){const h=this._panels.indexOf(l);h!==-1&&this._panels.splice(h,1)}const o=t-r,a=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(a,0,...n);for(const l of this._panels)this.tabsContainer.delete(l.id);for(let l=0;l<this._panels.length;l++)this.tabsContainer.openPanel(this._panels[l],l);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(a=>a.id===t);if(!i)return;const s=e.indexOfPanel(t),n=this._computeGlobalIndex(e,s),r=this._panels.indexOf(i);if(r===n)return;this._panels.splice(r,1);const o=n>r?n-1:n;this._panels.splice(o,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,o)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const s=this._panels.find(n=>n.id===i[0]);return s?this._panels.indexOf(s):this._panels.length}for(let s=0;s<i.length;s++){if(s===t)continue;const n=this._panels.find(r=>r.id===i[s]);if(n){const r=this._panels.indexOf(n);return Math.max(0,r+(t-s))}}return this._panels.length}removePanelFromTabGroup(e){const t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){if(this.watermark){var e,t;this.watermark.element.remove(),(e=(t=this.watermark).dispose)===null||e===void 0||e.call(t),this.watermark=void 0}this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const s of e.panelIds)this._panelToTabGroup.delete(s);this._onDidDestroyTabGroup.fire({tabGroup:e});const i=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),i&&(this._pendingMicrotaskDisposables.add(i),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(i),i.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let i=t+1;i<this._panels.length;i++){const s=this._panels[i],n=this._findTabGroupForPanel(s.id);if(!n?.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}for(let i=t-1;i>=0;i--){const s=this._panels[i],n=this._findTabGroupForPanel(s.id);if(!n?.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const i=this._panels.find(s=>s.id===t);i&&(this.doSetActivePanel(i),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const i=/-(\d+)$/.exec(t.id);if(i){const s=Number.parseInt(i[1],10)+1;s>this._tabGroupIdCounter&&(this._tabGroupIdCounter=s)}}for(const t of e){const i=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),s=this._tabGroupMap.get(i.id);for(const n of t.panelIds)this._panels.some(r=>r.id===n)&&(i.addPanel(n),this._panelToTabGroup.set(n,s),this._enforceContiguity(s,n));t.collapsed&&i.collapse(),i.isEmpty&&i.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){if(this.panels.forEach(t=>{this.renderContainer.detatch(t)}),this._overwriteRenderContainer=e,this.panels.forEach(t=>{this.rerender(t)}),this._activePanel){this.contentContainer.renderPanel(this._activePanel,{asActive:!0});const{width:t,height:i}=this.contentDimensions();this._activePanel.layout(t,i)}}get renderContainer(){var e;return(e=this._overwriteRenderContainer)!==null&&e!==void 0?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return this._location.type==="floating"&&this.accessor.rootDropTargetContainer.disabled?this.accessor.floatingDropTargetContainer:(e=this._overwriteDropTargetContainer)!==null&&e!==void 0?e:this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)===null||e===void 0||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case"left":this.tabsContainer.setLeftActionsElement(t);break;case"right":this.tabsContainer.setRightActionsElement(t);break;case"prefix":this.tabsContainer.setPrefixActionsElement(t);break}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,id:this.id};return this.locked!==!1&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),this.headerPosition!=="top"&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(i=>i.toJSON())),t}moveToNext(e){var t,i,s;(t=e)!==null&&t!==void 0||(e={}),(s=(i=e).panel)!==null&&s!==void 0||(i.panel=this.activePanel);const n=e.panel?this.panels.indexOf(e.panel):-1;let r;if(n<this.panels.length-1)r=n+1;else{if(e.suppressRoll)return;r=0}this.openPanel(this.panels[r])}moveToPrevious(e){var t,i,s;if((t=e)!==null&&t!==void 0||(e={}),(s=(i=e).panel)!==null&&s!==void 0||(i.panel=this.activePanel),!e.panel)return;const n=this.panels.indexOf(e.panel);let r;if(n>0)r=n-1;else{if(e.suppressRoll)return;r=this.panels.length-1}this.openPanel(this.panels[r])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}openPanel(e,t={}){(typeof t.index!="number"||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this.invalidateHeaderSize(),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t){const i=typeof e=="string"?e:e.id,s=this._panels.find(n=>n.id===i);if(!s)throw new Error("invalid operation");return this._removePanel(s,t)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){const t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay==="emptyGroup"?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,Y(this.container,"dv-active-group",e),Y(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const i=this._panels.find(s=>{const n=this._findTabGroupForPanel(s.id);return!n?.collapsed});i&&this.doSetActivePanel(i)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t;const{width:s,height:n}=this.contentDimensions();this.contentContainer.layout(s,n),!((i=this._activePanel)===null||i===void 0)&&i.layout&&this._activePanel.layout(s,n)}relayout(){this.invalidateHeaderSize(),this.layout(this._width,this._height)}measureHeaderSize(){const e=this.tabsContainer.element;return this.headerPosition==="top"||this.headerPosition==="bottom"?e.offsetHeight:e.offsetWidth}invalidateHeaderSize(){this._cachedHeaderSize=void 0}contentDimensions(){var e;const t=this.headerPosition==="top"||this.headerPosition==="bottom",i=(e=this._cachedHeaderSize)!==null&&e!==void 0?e:this._cachedHeaderSize=this.measureHeaderSize();return{width:t?this._width:Math.max(0,this._width-i),height:t?Math.max(0,this._height-i):this._height}}_removePanel(e,t){const i=this._activePanel===e;if(this.doRemovePanel(e),this.invalidateHeaderSize(),i&&this.panels.length>0){const s=this.mostRecentlyUsed[0];this.openPanel(s,{skipSetActive:t?.skipSetActive,skipSetGroupActive:t?.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t?.skipSetActive||this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){const s=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(s,1)}const i=this._panelDisposables.get(e.id);i&&(i.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i){const s=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i?.skipSetActive?e.api.renderer==="always"&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!s&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new te(e.api.onDidTitleChange(n=>this._onDidPanelTitleChange.fire(n)),e.api.onDidParametersChange(n=>this._onDidPanelParametersChange.fire(n)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){if(this._activePanel!==e){if(this._activePanel=e,e){var t,i,s;this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e);const{width:n,height:r}=this.contentDimensions();e.layout(n,r),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=(i=(s=this.accessor).currentOrigin)===null||i===void 0?void 0:i.call(s))!==null&&t!==void 0?t:"user"})}this.updateAccessibleLabel()}}updateAccessibleLabel(){var e;const t=(e=this._activePanel)===null||e===void 0?void 0:e.title;t?this.container.setAttribute("aria-label",t):this.container.removeAttribute("aria-label")}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){this.panels.forEach(s=>s.runEvents());const e=this.isEmpty||!this._activePanel;if(e&&!this.watermark){const s=this.accessor.createWatermarkComponent();s.init({containerApi:this._api,group:this.groupPanel}),this.watermark=s,Z(this.watermark.element,"pointerdown",()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}if(!e&&this.watermark){var t,i;this.watermark.element.remove(),(t=(i=this.watermark).dispose)===null||t===void 0||t.call(i),this.watermark=void 0}}canDisplayOverlay(e,t,i){const s=new yu(e,i,t,Ie,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(s),s.isAccepted}canDisplayContentOverlay(e,t){if(this.locked==="no-drop-target"||this.locked&&t==="center")return!1;const i=Ie();return!i&&e.shiftKey&&this.location.type!=="floating"?!1:i?.viewId===this.accessor.id?!0:this.canDisplayOverlay(e,t,"content")}handleDropEvent(e,t,i,s,n){if(this.locked==="no-drop-target")return;if(e==="content"&&n){this.accessor.dockToLayoutEdge(t,i);return}function r(){switch(e){case"header":return typeof s=="number"?"tab":"header_space";case"content":return"content"}}const o=typeof s=="number"?this.panels[s]:void 0,a=new Du({nativeEvent:t,position:i,panel:o,getData:()=>Ie(),kind:r(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(a),a.defaultPrevented)return;const l=Ie();if(l?.viewId===this.accessor.id){if(e==="content"&&l.groupId===this.id&&(i==="center"||l.panelId===null&&!l.tabGroupId)||e==="header"&&l.groupId===this.id&&l.panelId===null&&!l.tabGroupId)return;if(l.panelId===null){const{groupId:u}=l;this._onMove.fire({target:i,groupId:u,index:s,tabGroupId:l.tabGroupId});return}if(this.tabsContainer.indexOf(l.panelId)!==-1&&this.tabsContainer.size===1)return;const{groupId:h,panelId:c}=l;if(this.id===h&&!i&&this.tabsContainer.indexOf(c)===s)return;this._onMove.fire({target:i,groupId:l.groupId,itemId:l.panelId,index:s})}else this._onDidDrop.fire(new Ka({nativeEvent:t,position:i,panel:o,getData:()=>Ie(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),(e=this.watermark)===null||e===void 0||e.element.remove(),(t=this.watermark)===null||t===void 0||(i=t.dispose)===null||i===void 0||i.call(t),this.watermark=void 0;for(const s of[...this._tabGroups])s.dispose();for(const s of this._tabGroupDisposables.values())s.dispose();this._tabGroupDisposables.clear();for(const s of this._pendingMicrotaskDisposables)s.dispose();this._pendingMicrotaskDisposables.clear();for(const s of this.panels)s.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},qa=class extends pu{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new G,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new G,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new G,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),i&&this.initialize(i)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},ku=class extends Wa{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){const e=typeof this._minimumWidth=="function"?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e=typeof this._maximumWidth=="function"?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e=typeof this._minimumHeight=="function"?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e=typeof this._maximumHeight=="function"?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,i,s){super(e,t,s??new qa(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=Number.MAX_SAFE_INTEGER,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=Number.MAX_SAFE_INTEGER,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=Number.MAX_SAFE_INTEGER,this._maximumHeight=Number.MAX_SAFE_INTEGER,this._snap=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,typeof i?.minimumWidth=="number"&&(this._minimumWidth=i.minimumWidth),typeof i?.maximumWidth=="number"&&(this._maximumWidth=i.maximumWidth),typeof i?.minimumHeight=="number"&&(this._minimumHeight=i.minimumHeight),typeof i?.maximumHeight=="number"&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(n=>{const{isVisible:r}=n,{accessor:o}=this._params;o.setVisible(this,r)}),this.api.onActiveChange(()=>{const{accessor:n}=this._params;n.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(n=>{(typeof n.minimumWidth=="number"||typeof n.minimumWidth=="function")&&(this._minimumWidth=n.minimumWidth),(typeof n.minimumHeight=="number"||typeof n.minimumHeight=="function")&&(this._minimumHeight=n.minimumHeight),(typeof n.maximumWidth=="number"||typeof n.maximumWidth=="function")&&(this._maximumWidth=n.maximumWidth),(typeof n.maximumHeight=="number"||typeof n.maximumHeight=="function")&&(this._maximumHeight=n.maximumHeight),this._onDidChange.fire(void 0)}),this.api.onDidSizeChange(n=>{this._onDidChange.fire({height:n.height,width:n.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible=="boolean"&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){const e=super.toJSON(),t=s=>s===Number.MAX_SAFE_INTEGER?void 0:s,i=s=>s<=0?void 0:s;return se(se({},e),{},{minimumHeight:i(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:i(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}};const Zt="dockview: DockviewGroupPanelApiImpl not initialized";var Yb=class extends qa{get location(){if(!this._group)throw new Error(Zt);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type==="popout")return;const e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw new Error(Zt);return this._group.locked}set locked(e){if(!this._group)throw new Error(Zt);this._group.locked=e}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new G,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new G,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new G,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this._onDidPeekChange=new G,this.onDidPeekChange=this._onDidPeekChange.event,this._onDidHeaderDirectionChange=new G,this.onDidHeaderDirectionChange=this._onDidHeaderDirectionChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidPeekChange,this._onDidHeaderDirectionChange,this._onDidVisibilityChange.event(i=>{i.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=se({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type==="popout"?this.location.getWindow():globalThis.window}setHeaderPosition(e){if(!this._group)throw new Error(Zt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(Zt);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw new Error(Zt);this.accessor.withOrigin("api",()=>{var t,i,s,n;const r=(t=e.group)!==null&&t!==void 0?t:this.accessor.addGroup({direction:nb((i=e.position)!==null&&i!==void 0?i:"right"),skipSetActive:(s=e.skipSetActive)!==null&&s!==void 0?s:!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:r,position:e.group&&(n=e.position)!==null&&n!==void 0?n:"center",index:e.index},skipSetActive:e.skipSetActive})})}maximize(){if(!this._group)throw new Error(Zt);this.location.type==="grid"&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Zt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Zt);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}isPeeking(){return this._group?this.accessor.isEdgeGroupPeeking(this._group):!1}setAutoHide(e){this._group&&this.accessor.setEdgeGroupAutoHide(this._group,e)}isAutoHide(){return this._group?this.accessor.isEdgeGroupAutoHide(this._group):!1}initialize(e){this._group=e}};const Xb=100,Jb=100;var ln=class extends ku{get minimumWidth(){var e;if(typeof this._explicitConstraints.minimumWidth=="number")return this._explicitConstraints.minimumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumWidth;return typeof t=="number"?t:super.__minimumWidth()}get minimumHeight(){var e;if(typeof this._explicitConstraints.minimumHeight=="number")return this._explicitConstraints.minimumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumHeight;return typeof t=="number"?t:super.__minimumHeight()}get maximumWidth(){var e;if(typeof this._explicitConstraints.maximumWidth=="number")return this._explicitConstraints.maximumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumWidth;return typeof t=="number"?t:super.__maximumWidth()}get maximumHeight(){var e;if(typeof this._explicitConstraints.maximumHeight=="number")return this._explicitConstraints.maximumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumHeight;return typeof t=="number"?t:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,i){var s,n,r,o,a,l;super(t,"groupview_default",{minimumHeight:(s=(n=i.constraints)===null||n===void 0?void 0:n.minimumHeight)!==null&&s!==void 0?s:Jb,minimumWidth:(r=(o=i.constraints)===null||o===void 0?void 0:o.minimumWidth)!==null&&r!==void 0?r:Xb,maximumHeight:(a=i.constraints)===null||a===void 0?void 0:a.maximumHeight,maximumWidth:(l=i.constraints)===null||l===void 0?void 0:l.maximumWidth},new Yb(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new qb(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(h=>{this.api._onDidActivePanelChange.fire(h)}),this.api.onDidConstraintsChangeInternal(h=>{h.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof h.minimumWidth=="function"?h.minimumWidth():h.minimumWidth),h.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof h.minimumHeight=="function"?h.minimumHeight():h.minimumHeight),h.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof h.maximumWidth=="function"?h.maximumWidth():h.maximumWidth),h.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof h.maximumHeight=="function"?h.maximumHeight():h.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}relayout(){this.model.relayout()}getComponent(){return this._model}toJSON(){return this.model.toJSON()}};const Zb={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},Qb={name:"light",className:"dockview-theme-light",colorScheme:"light"},ew={className:"dockview-theme-abyss",tabGroupIndicator:"none"};var tw=class extends qa{get location(){return this.group.api.location}get title(){return this.panel.title}get isPinned(){return this.panel.isPinned}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this.fireLocationChange())}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,i,s,n){super(e.id,s),this.panel=e,this.accessor=i,this._onDidTitleChange=new G,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidChangePinned=new G,this.onDidChangePinned=this._onDidChangePinned.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new G,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new G,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new G,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new Ge,this._tabComponent=n,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidChangePinned,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin("api",()=>super.setActive())}moveTo(e){this.accessor.withOrigin("api",()=>{var t,i;return this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:(t=e.group)!==null&&t!==void 0?t:this._group,position:e.group&&(i=e.position)!==null&&i!==void 0?i:"center",index:e.index},skipSetActive:e.skipSetActive})})}setTitle(e){this.panel.setTitle(e)}setPinned(e){this.accessor.setPanelPinned(this.panel,e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}fireLocationChange(){this.accessor.deferLocationChange(this,()=>{this.isDisposed||this._onDidLocationChange.fire({location:this.location})})}setupGroupEventListeners(e){var t;let i=(t=e?.isActive)!==null&&t!==void 0?t:!1;this.groupEventsDisposable.value=new te(this.group.api.onDidVisibilityChange(s=>{const n=!s.isVisible&&this.isVisible,r=s.isVisible&&!this.isVisible,o=this.group.model.isPanelActive(this.panel);(n||r&&o)&&this._onDidVisibilityChange.fire(s)}),this.group.api.onDidLocationChange(()=>{this.group===this.panel.group&&this.fireLocationChange()}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},es=class extends te{get params(){return this._params}get title(){return this._title}get isPinned(){return this._pinned}get group(){return this._group}get renderer(){var e;return(e=this._renderer)!==null&&e!==void 0?e:this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,i,s,n,r,o,a){super(),this.id=e,this.accessor=s,this.containerApi=n,this.view=o,this._pinned=!1,this._renderer=a.renderer,this._group=r,this._minimumWidth=a.minimumWidth,this._minimumHeight=a.minimumHeight,this._maximumWidth=a.maximumWidth,this._maximumHeight=a.maximumHeight,this.api=new tw(this,this._group,s,t,i),this.addDisposables(this.api.onActiveChange(()=>{s.setActivePanel(this)}),this.api.onDidSizeChange(l=>{this.group.api.setSize(l)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(se(se({},e),{},{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){const e=new uu;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth,pinned:this._pinned?!0:void 0}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setPinned(e){this._pinned!==e&&(this._pinned=e,this.api._onDidChangePinned.fire({isPinned:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=se(se({},this._params),e.params);for(const t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,s,n,r;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this._params=(t=e.params)!==null&&t!==void 0?t:{},this.view.update({params:this._params}),this.setTitle((i=e.title)!==null&&i!==void 0?i:this.id),this.setRenderer((s=e.renderer)!==null&&s!==void 0?s:this.accessor.renderer),this.setPinned(((n=e.pinned)!==null&&n!==void 0?n:!1)&&!!(!((r=this.accessor.options.pinnedTabs)===null||r===void 0)&&r.enabled))}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),s=this.group.api.isActive&&i;t?.skipSetActive||this.api.isActive!==s&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&i}),this.api.isVisible!==i&&this.api._onDidVisibilityChange.fire({isVisible:i})}runEvents(){const e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},nh=class extends te{get element(){return this._element}constructor(){super(),this._messages=jn,this._element=document.createElement("div"),this._element.className="dv-default-tab",this._content=document.createElement("div"),this._content.className="dv-default-tab-content",this.action=document.createElement("div"),this.action.className="dv-default-tab-action",this.action.setAttribute("role","button"),this.action.setAttribute("tabindex","-1");const e=Cb();e.setAttribute("aria-hidden","true"),this.action.appendChild(e),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){var t;this._title=e.title,this._messages=(t=e.containerApi.messages)!==null&&t!==void 0?t:jn,this.addDisposables(e.api.onDidTitleChange(i=>{this._title=i.title,this.render()}),Z(this.action,"pointerdown",i=>{i.preventDefault()}),Z(this.action,"click",i=>{i.defaultPrevented||(i.preventDefault(),e.api.close())})),this.render()}render(){if(this._content.textContent!==this._title){var e;this._content.textContent=(e=this._title)!==null&&e!==void 0?e:""}this.action.setAttribute("aria-label",this._title?this._messages.closeTab(this._title):this._messages.closeTabPlain())}},Pu=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}createTabRenderer(e){const t=this.createTabComponent(this.id,this.tabComponent);if(this._params&&t.init(se(se({},this._params),{},{tabLocation:e})),this._updateEvent){var i;(i=t.update)===null||i===void 0||i.call(t,this._updateEvent)}return t}init(e){this._params=e,this.content.init(e),this.tab.init(se(se({},e),{},{tabLocation:"header"}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var i,s;(i=(s=this.content).layout)===null||i===void 0||i.call(s,e,t)}update(e){var t,i,s,n;this._updateEvent=e,(t=(i=this.content).update)===null||t===void 0||t.call(i,e),(s=(n=this.tab).update)===null||s===void 0||s.call(n,e)}dispose(){var e,t,i,s;(e=(t=this.content).dispose)===null||e===void 0||e.call(t),(i=(s=this.tab).dispose)===null||i===void 0||i.call(s)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=t??this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const s=this.accessor.options.createTabComponent({id:e,name:i});return s||new nh}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new nh}},iw=class{constructor(e){this.accessor=e}fromJSON(e,t){var i,s,n;const r=e.id,o=e.params,a=e.title,l=e.view,h=l?l.content.id:(i=e.contentComponent)!==null&&i!==void 0?i:"unknown",c=l?(s=l.tab)===null||s===void 0?void 0:s.id:e.tabComponent,u=new Pu(this.accessor,r,h,c),p=new es(r,h,c,this.accessor,new $a(this.accessor),t,u,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return p.init({title:a??r,params:o??{}}),e.pinned&&(!((n=this.accessor.options.pinnedTabs)===null||n===void 0)&&n.enabled)&&p.setPinned(!0),p}},sw=class extends te{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(t){}},nw=class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute("aria-level",`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}};const hn=new nw;var Ya=class Mi extends te{set minimumInViewportWidth(t){this.options.minimumInViewportWidth=t}set minimumInViewportHeight(t){this.options.minimumInViewportHeight=t}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){var t,i;return(t=(i=this.options.header)===null||i===void 0?void 0:i.offsetHeight)!==null&&t!==void 0?t:0}constructor(t){super(),this.options=t,this._element=document.createElement("div"),this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new G,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new G,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new Ge,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className="dv-resize-container",this._element.setAttribute("role","dialog"),this._element.setAttribute("aria-modal","false"),this._isVisible=!0,this.setupResize("top"),this.setupResize("bottom"),this.setupResize("left"),this.setupResize("right"),this.setupResize("topleft"),this.setupResize("topright"),this.setupResize("bottomleft"),this.setupResize("bottomright"),this.options.header&&(Y(this._element,"dv-resize-container-with-titlebar",!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(se(se(se(se({height:this.options.height,width:this.options.width},"top"in this.options&&{top:this.options.top}),"bottom"in this.options&&{bottom:this.options.bottom}),"left"in this.options&&{left:this.options.left}),"right"in this.options&&{right:this.options.right})),hn.push(this._element)}setVisible(t){t!==this.isVisible&&(this._isVisible=t,Y(this.element,"dv-hidden",!this.isVisible))}bringToFront(){hn.push(this._element)}setBounds(t={}){typeof t.height=="number"&&(this._element.style.height=`${t.height}px`),typeof t.width=="number"&&(this._element.style.width=`${t.width}px`),"top"in t&&typeof t.top=="number"&&(this._element.style.top=`${t.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in t&&typeof t.bottom=="number"&&(this._element.style.bottom=`${t.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in t&&typeof t.left=="number"&&(this._element.style.left=`${t.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in t&&typeof t.right=="number"&&(this._element.style.right=`${t.right}px`,this._element.style.left="auto",this.horiziontalAlignment="right");const i=this.options.container.getBoundingClientRect(),s=this._element.getBoundingClientRect(),n=Math.max(0,this.getMinimumWidth(s.width)),r=Math.max(0,this.getMinimumHeight(s.height));if(this.verticalAlignment==="top"){const o=Te(s.top-i.top,-r,Math.max(0,i.height-s.height+r));this._element.style.top=`${o}px`,this._element.style.bottom="auto"}if(this.verticalAlignment==="bottom"){const o=Te(i.bottom-s.bottom,-r,Math.max(0,i.height-s.height+r));this._element.style.bottom=`${o}px`,this._element.style.top="auto"}if(this.horiziontalAlignment==="left"){const o=Te(s.left-i.left,-n,Math.max(0,i.width-s.width+n));this._element.style.left=`${o}px`,this._element.style.right="auto"}if(this.horiziontalAlignment==="right"){const o=Te(i.right-s.right,-n,Math.max(0,i.width-s.width+n));this._element.style.right=`${o}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),s={};return this.verticalAlignment==="top"?s.top=Number.parseFloat(this._element.style.top):this.verticalAlignment==="bottom"?s.bottom=Number.parseFloat(this._element.style.bottom):s.top=i.top-t.top,this.horiziontalAlignment==="left"?s.left=Number.parseFloat(this._element.style.left):this.horiziontalAlignment==="right"?s.right=Number.parseFloat(this._element.style.right):s.left=i.left-t.left,s.width=i.width,s.height=i.height,s}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,Y(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=xe.NONE)}setupDrag(t,i){const s=(n,r)=>{var o,a,l;let h=null,c=!1;this._dragCancelled=!1;const u=this.options.transformDragPosition?(o=(a=(l=this.options).getSiblingBoxes)===null||a===void 0?void 0:a.call(l))!==null&&o!==void 0?o:[]:[],p=js();if(n&&typeof r=="number"&&typeof n.setPointerCapture=="function")try{n.setPointerCapture(r)}catch{}const f=()=>{Y(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=xe.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new te({dispose:()=>{if(p.release(),n&&typeof r=="number"&&typeof n.releasePointerCapture=="function")try{n.releasePointerCapture(r)}catch{}}},Z(globalThis.window,"pointermove",m=>{var g;if(this._dragCancelled)return;const _=this.options.container.getBoundingClientRect(),T=m.clientX-_.left,D=m.clientY-_.top;Y(this._element,"dv-resize-container-dragging",!0);const E=this._element.getBoundingClientRect();(g=h)!==null&&g!==void 0||(h={x:m.clientX-E.left,y:m.clientY-E.top});const S=Math.max(0,this.getMinimumWidth(E.width)),A=Math.max(0,this.getMinimumHeight(E.height));let k=D-h.y,L=T-h.x;if(this.options.transformDragPosition){const x=this.options.transformDragPosition({proposed:{top:k,left:L,width:E.width,height:E.height},container:{width:_.width,height:_.height},others:u,modifiers:{altKey:m.altKey,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey}});x&&(k=x.top,L=x.left)}const O=Math.max(0,_.height-E.height+A),z=Math.max(0,_.width-E.width+S),N=Te(k,-A,O),I=Te(_.height-E.height-k,-A,O),C=Te(L,-S,z),v=Te(_.width-E.width-L,-S,z),y={};N<=I?y.top=N:y.bottom=I,C<=v?y.left=C:y.right=v,this.setBounds(y),c||(c=!0,this._onDidStartMoving.fire())}),Z(globalThis.window,"pointerup",f),Z(globalThis.window,"pointercancel",f))};this.addDisposables(Z(t,"pointerdown",n=>{if(n.defaultPrevented){n.preventDefault();return}Jl(n)||s(t,n.pointerId)}),Z(this.options.content,"pointerdown",n=>{n.defaultPrevented||Jl(n)||n.shiftKey&&s(this.options.content,n.pointerId)}),Z(this.options.content,"pointerdown",()=>{hn.push(this._element)},!0)),i?.inDragMode&&s()}setupResize(t){const i=document.createElement("div");i.className=`dv-resize-handle-${t}`,this._element.appendChild(i);const s=new Ge;this.addDisposables(s,Z(i,"pointerdown",n=>{n.preventDefault();let r=null;const o=js(),a=n.pointerId;if(typeof i.setPointerCapture=="function")try{i.setPointerCapture(a)}catch{}const l=()=>{s.dispose(),this._onDidChangeEnd.fire()};s.value=new te(Z(globalThis.window,"pointermove",h=>{var c;const u=this.options.container.getBoundingClientRect(),p=this._element.getBoundingClientRect(),f=h.clientY-u.top,m=h.clientX-u.left;(c=r)!==null&&c!==void 0||(r={originalY:f,originalHeight:p.height,originalX:m,originalWidth:p.width});let g,_,T,D,E,S;const A=()=>{const N=r.originalY+r.originalHeight>u.height?Math.max(0,u.height-Mi.MINIMUM_HEIGHT):Math.max(0,r.originalY+r.originalHeight-Mi.MINIMUM_HEIGHT);g=Te(f,0,N),T=r.originalY+r.originalHeight-g,_=u.height-g-T},k=()=>{g=r.originalY-r.originalHeight;const N=g<0&&typeof this.options.minimumInViewportHeight=="number"?-g+this.options.minimumInViewportHeight:Mi.MINIMUM_HEIGHT,I=u.height-Math.max(0,g);T=Te(f-g,N,I),_=u.height-g-T},L=()=>{const N=r.originalX+r.originalWidth>u.width?Math.max(0,u.width-Mi.MINIMUM_WIDTH):Math.max(0,r.originalX+r.originalWidth-Mi.MINIMUM_WIDTH);D=Te(m,0,N),S=r.originalX+r.originalWidth-D,E=u.width-D-S},O=()=>{D=r.originalX-r.originalWidth;const N=D<0&&typeof this.options.minimumInViewportWidth=="number"?-D+this.options.minimumInViewportWidth:Mi.MINIMUM_WIDTH,I=u.width-Math.max(0,D);S=Te(m-D,N,I),E=u.width-D-S};switch(t){case"top":A();break;case"bottom":k();break;case"left":L();break;case"right":O();break;case"topleft":A(),L();break;case"topright":A(),O();break;case"bottomleft":k(),L();break;case"bottomright":k(),O();break}const z={};g<=_?z.top=g:z.bottom=_,D<=E?z.left=D:z.right=E,z.height=T,z.width=S,this.setBounds(z)}),{dispose:()=>{if(o.release(),typeof i.releasePointerCapture=="function")try{i.releasePointerCapture(a)}catch{}}},Z(globalThis.window,"pointerup",l),Z(globalThis.window,"pointercancel",l))}))}getMinimumWidth(t){return typeof this.options.minimumInViewportWidth=="number"?t-this.options.minimumInViewportWidth:0}getMinimumHeight(t){return typeof this.options.minimumInViewportHeight=="number"?t-this.options.minimumInViewportHeight:0}dispose(){hn.destroy(this._element),this._element.remove(),super.dispose()}};Ya.MINIMUM_HEIGHT=20;Ya.MINIMUM_WIDTH=20;var rw=class extends te{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement("div"),this._element.className="dv-floating-titlebar",this.addDisposables(this._onDragStart,Z(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this._group)}),Z(this._element,"pointerdown",i=>{i.shiftKey&&qc(i)},!0)),this.dragSource=new vu({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(i=>{this._onDragStart.fire(i)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function ci(e){return{moduleName:e.name,options:e.options,services:{[e.serviceKey]:e.create},init:e.init?(t,i)=>e.init(t,i[e.serviceKey]):void 0,dependsOn:e.dependsOn}}const ow=new Set(["AdvancedOverflow","AutoEdgeGroup","AutoHideEdgeGroup","ContextMenu","DndCompass","KeyboardDocking","KeyboardNavigation","LayoutHistory","License","MultiRowTabs","PinnedTabs","SmartGuides"]),rh=new Set;function Eu(e,t){const i=t===void 0?[]:[].concat(t),s=i.map(o=>`\`${o}\``).join(", "),n=i.length>1?"require":"requires",r=i.length?`${s} ${n} the "${e}" module`:`The "${e}" module is required`;return ow.has(e)?`dockview: ${r}, which ships in dockview-enterprise.
|
|
4
|
-
|
|
5
|
-
npm install dockview-enterprise
|
|
6
|
-
import 'dockview-enterprise'; // self-registers every enterprise module
|
|
7
|
-
`:`dockview: ${r}, but it is not registered.`}function Tu(e,t){const i=`${e}|${(t===void 0?[]:[].concat(t)).join("|")}`;rh.has(i)||(rh.add(i),console.error(Eu(e,t)))}function mt(e,t,i){if(e!==void 0)return e;Tu(t,i)}var aw=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(const t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(const t of this._modules.values())if(t.services)for(const[i,s]of Object.entries(t.services))this._services[i]=s(e)}postConstruct(e){for(const t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(const e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(const e of Object.values(this._services))e!==void 0&&typeof e.dispose=="function"&&e.dispose()}};const lw=[];function hw(){return[...lw]}const dw=[{optionKey:"smartGuides",reason:"smartGuides",moduleName:"SmartGuides",when:e=>!!e.smartGuides&&e.smartGuides.enabled!==!1},{optionKey:"layoutHistory",reason:"layoutHistory.enabled: true",moduleName:"LayoutHistory",when:e=>{var t;return((t=e.layoutHistory)===null||t===void 0?void 0:t.enabled)===!0}},{optionKey:"pinnedTabs",reason:"pinnedTabs.enabled: true",moduleName:"PinnedTabs",when:e=>{var t;return((t=e.pinnedTabs)===null||t===void 0?void 0:t.enabled)===!0}},{optionKey:"overflow",reason:"overflow.mode: 'wrap'",moduleName:"MultiRowTabs",when:e=>{var t;return((t=e.overflow)===null||t===void 0?void 0:t.mode)==="wrap"}},{optionKey:"overflow",reason:"overflow.maxRows",moduleName:"MultiRowTabs",when:e=>{var t;return((t=e.overflow)===null||t===void 0?void 0:t.maxRows)!=null}},{optionKey:"overflow",reason:"overflow.search",moduleName:"AdvancedOverflow",when:e=>{var t;return!!(!((t=e.overflow)===null||t===void 0)&&t.search)}},{optionKey:"overflow",reason:"overflow.mru",moduleName:"AdvancedOverflow",when:e=>{var t;return!!(!((t=e.overflow)===null||t===void 0)&&t.mru)}},{optionKey:"autoHideEdgeGroups",reason:"autoHideEdgeGroups",moduleName:"AutoHideEdgeGroup",when:e=>mo(e.autoHideEdgeGroups)},{optionKey:"dockToEdgeGroups",reason:"dockToEdgeGroups",moduleName:"AutoEdgeGroup",when:e=>mo(e.dockToEdgeGroups)},{optionKey:"getTabContextMenuItems",reason:"getTabContextMenuItems",moduleName:"ContextMenu",when:e=>e.getTabContextMenuItems!=null},{optionKey:"getTabGroupChipContextMenuItems",reason:"getTabGroupChipContextMenuItems",moduleName:"ContextMenu",when:e=>e.getTabGroupChipContextMenuItems!=null},{optionKey:"dndCompass",reason:"dndCompass",moduleName:"DndCompass",when:e=>!!e.dndCompass},{optionKey:"keyboardNavigation",reason:"keyboardNavigation",moduleName:"KeyboardNavigation",when:e=>!!e.keyboardNavigation}];function cw(e,t){const i=new Map;for(const s of dw){if(!s.when(e)||t(s.moduleName))continue;const n=i.get(s.moduleName);n?n.push(s.reason):i.set(s.moduleName,[s.reason])}for(const[s,n]of i)Tu(s,n)}const fi={left:100,top:100,width:300,height:300};var uw=class extends te{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)===null||t===void 0||t.setGroup(e)}constructor(e,t,i){super(),this.overlay=t,this.gridview=i,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},pw=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,i){const s=new uw(e,t,i),n=new te(e.api.onDidActiveChange(o=>{o.isActive&&t.bringToFront()}),(()=>{let o=-1,a=-1;return Ui(i.element,l=>{const h=Math.round(l.contentRect.width),c=Math.round(l.contentRect.height);h===o&&c===a||(o=h,a=c,i.layout(h,c))})})()),r=()=>{var o;const a=(o=e.activePanel)===null||o===void 0?void 0:o.title;a?t.element.setAttribute("aria-label",a):t.element.removeAttribute("aria-label")};return r(),s.addDisposables(e.api.onDidActivePanelChange(()=>r()),t.onDidChange(()=>{i.layout(i.width,i.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(o=>{t.setBounds({height:typeof o?.height=="number"?o.height+t.headerHeight:o?.height,width:o?.width})}),{dispose:()=>{n.dispose(),Zc(this._floatingGroups,s),e.model.location={type:"grid"}}}),this._floatingGroups.push(s),s}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{const t=e.gridview.serialize(),i=e.overlay.toJSON(),s=t.root;return s.type==="branch"&&s.data.length===1&&s.data[0].type==="leaf"?{data:s.data[0].data,position:i}:{grid:t,position:i}})}constrainBounds(){for(const e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if("floatingGroupBounds"in e)for(const s of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":s.overlay.minimumInViewportHeight=void 0,s.overlay.minimumInViewportWidth=void 0;break;case void 0:s.overlay.minimumInViewportHeight=100,s.overlay.minimumInViewportWidth=100;break;default:var t,i;s.overlay.minimumInViewportHeight=(t=e.floatingGroupBounds)===null||t===void 0?void 0:t.minimumHeightWithinViewport,s.overlay.minimumInViewportWidth=(i=e.floatingGroupBounds)===null||i===void 0?void 0:i.minimumWidthWithinViewport}s.overlay.setBounds()}}disposeAll(){for(const e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}};const fw=ci({name:"FloatingGroup",serviceKey:"floatingGroupService",create:e=>new pw(e)});var mw=class{constructor(e){this._entries=[],this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new G,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){Zc(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){var t;return(t=this._entries.find(i=>i.popoutGroup===e))===null||t===void 0?void 0:t.referenceGroup}observeGridviewSize(e,t,i){var s;const n=(s=e.window)===null||s===void 0?void 0:s.ResizeObserver;if(!n)return;let r=-1,o=-1;const a=()=>{const h=e.window;if(this._host.isDisposed||!h||h.closed)return;const c=Math.round(t.element.clientWidth),u=Math.round(t.element.clientHeight);c===r&&u===o||(r=c,o=u,c>0&&u>0&&t.layout(c,u),i.updateAllPositions())},l=new n(()=>{var h;const c=(h=e.window)===null||h===void 0?void 0:h.requestAnimationFrame;c?c.call(e.window,a):a()});return l.observe(t.element),{dispose:()=>l.disconnect()}}scheduleRestoration(e,t,i){return new Promise(s=>{const n=()=>{this._restorationCleanups.delete(n),clearTimeout(r),i?.(),s()},r=setTimeout(()=>{if(this._restorationCleanups.delete(n),this._host.isDisposed){s();return}t(),s()},e);this._restorationCleanups.add(n)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>{})}cancelPendingRestorations(){for(const e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{const t=e.gridview.serialize(),i=t.root,s=e.popoutGroup.api.location.type==="popout"?e.popoutGroup.api.location.popoutUrl:void 0,n={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:s};return i.type==="branch"&&i.data.length===1&&i.data[0].type==="leaf"?se(se({},n),{},{data:i.data[0].data}):se(se({},n),{},{grid:t})})}disposeAll(){for(const e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}};const gw=ci({name:"PopoutWindow",serviceKey:"popoutWindowService",create:e=>new mw(e)});var vw=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});const e=document.createElement("div");e.className="dv-watermark-container",L_(e,"watermark-component"),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&(this._watermark.element.parentElement.remove(),(e=(t=this._watermark).dispose)===null||e===void 0||e.call(t),this._watermark=null)}dispose(){this._unmount()}};const _w=ci({name:"Watermark",serviceKey:"watermarkService",create:e=>new vw(e),init:(e,t)=>(t.update(),new te(Tt.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))});var bw=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._autoHide=new WeakMap,this._autoReveal=new WeakMap}add(e,t,i){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,i)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))===null||t===void 0||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(const t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(const[t,i]of this._edgeGroups)if(i===e)return t}setAutoHide(e,t){t===void 0?this._autoHide.delete(e):this._autoHide.set(e,t)}isAutoHide(e){return this._autoHide.get(e)}setAutoReveal(e,t){this._autoReveal.set(e,t)}isAutoReveal(e){var t;return(t=this._autoReveal.get(e))!==null&&t!==void 0?t:!1}disposeAll(){for(const e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}};const ww=ci({name:"EdgeGroup",serviceKey:"edgeGroupService",create:()=>new bw}),yw={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}},xw={activationSize:{type:"pixels",value:32},size:{type:"pixels",value:20}};function oh(e,t){return typeof e.dndEdges=="object"&&e.dndEdges!==null?e.dndEdges:t&&mo(e.dockToEdgeGroups)?xw:yw}var Sw=class{constructor(e){this._host=e;const t=(s,n)=>{const r=Ie();return r?r.viewId!==e.id?!1:n==="center"?e.isGridEmpty():!0:n==="center"&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(s,n)},i=oh(e.options,!1);this._html5Target=Ei.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this._pointerTarget=di.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this.onWillShowOverlay=Tt.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=Tt.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if("dndEdges"in e){const t=typeof e.dndEdges=="boolean"&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t}if("dndEdges"in e||"dockToEdgeGroups"in e){const t=oh({dndEdges:"dndEdges"in e?e.dndEdges:this._host.options.dndEdges,dockToEdgeGroups:"dockToEdgeGroups"in e?e.dockToEdgeGroups:this._host.options.dockToEdgeGroups},this._host.hasEdgeDragReveal);this._html5Target.setOverlayModel(t),this._pointerTarget.setOverlayModel(t)}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}};const Cw=ci({name:"RootDropTarget",serviceKey:"rootDropTargetService",create:e=>new Sw(e),init:(e,t)=>(t.setOptions(e.options),xe.NONE)}),Dw={left:"createLeftHeaderActionComponent",right:"createRightHeaderActionComponent",prefix:"createPrefixHeaderActionComponent"};var kw=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;const t=this._ensureState(e);this._refreshSlot("left",e,t.left),this._refreshSlot("right",e,t.right),this._refreshSlot("prefix",e,t.prefix)}refreshAll(){for(const e of this._host.groups)this.refresh(e)}disposeGroup(e){const t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(const e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new Ge,right:new Ge,prefix:new Ge},this._perGroup.set(e,t)),t}_refreshSlot(e,t,i){const s=this._host.options[Dw[e]];if(s){const n=s(t);i.value=n,n.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,n.element)}else i.dispose(),t.model.attachHeaderAction(e,void 0)}};const Pw=ci({name:"HeaderActions",serviceKey:"headerActionsService",create:e=>new kw(e),init:(e,t)=>new te(e.onDidRemoveGroup(i=>{t.disposeGroup(i)}))}),ah=e=>e==="load"||e==="clear";function dn(e,t){const i=e.createElement("div");return i.className=t==="assertive"?"dv-live-region-assertive":"dv-live-region",i.setAttribute("role",t==="assertive"?"alert":"status"),i.setAttribute("aria-live",t),i.setAttribute("aria-atomic","true"),Object.assign(i.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:"0"}),i}var Ew=class extends te{constructor(e){var t;super(),this._regions=new Map,this._suppressDepth=0,this._locationSubs=new Map,this._host=e;const i=e.element.ownerDocument;this._mainWindow=(t=i.defaultView)!==null&&t!==void 0?t:window;const s={polite:dn(i,"polite"),assertive:dn(i,"assertive")};e.element.appendChild(s.polite),e.element.appendChild(s.assertive),this._regions.set(this._mainWindow,s),this._syncPopoutRegions(),this.addDisposables({dispose:()=>this._disposeRegions()},e.onDidChangePopouts(()=>this._syncPopoutRegions()),e.onDidAddPanel(n=>this._announce(n,"open")),e.onDidRemovePanel(n=>this._announce(n,"close")),e.onWillMutateLayout(n=>{ah(n.kind)&&this._suppressDepth++}),e.onDidMutateLayout(n=>{ah(n.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(n=>{const r=n.group.activePanel;r&&this._announce(r,n.isMaximized?"maximize":"restore")}),e.onDidAddGroup(n=>this._trackLocation(n)),e.onDidRemoveGroup(n=>{var r;(r=this._locationSubs.get(n.id))===null||r===void 0||r.dispose(),this._locationSubs.delete(n.id)}),{dispose:()=>{this._locationSubs.forEach(n=>n.dispose()),this._locationSubs.clear()}})}_syncPopoutRegions(){const e=this._host.element.ownerDocument,t=new Set([this._mainWindow]);for(const s of this._host.getPopoutWindows()){var i;if(s.document===e||(t.add(s),this._regions.has(s)))continue;const n=s.document,r=(i=n.body)!==null&&i!==void 0?i:n.documentElement,o={polite:dn(n,"polite"),assertive:dn(n,"assertive")};r.appendChild(o.polite),r.appendChild(o.assertive),this._regions.set(s,o)}for(const[s,n]of this._regions)t.has(s)||(n.polite.remove(),n.assertive.remove(),this._regions.delete(s))}_disposeRegions(){for(const e of this._regions.values())e.polite.remove(),e.assertive.remove();this._regions.clear()}_focusedRegions(){for(const[e,t]of this._regions)if(e!==this._mainWindow)try{if(e.document.hasFocus())return t}catch{}return this._regions.get(this._mainWindow)}_trackLocation(e){let t=e.api.location.type;const i=e.api.onDidLocationChange(s=>{const n=s.location.type;if(n===t)return;t=n;const r=e.activePanel;if(!r)return;let o;switch(n){case"floating":o="float";break;case"popout":o="popout";break;default:o="dock";break}this._announce(r,o)});this._locationSubs.set(e.id,i)}announce(e,t="polite"){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;const i=this._host.options.announcer;if(i){i({message:e,politeness:t});return}const s=this._focusedRegions(),n=t==="assertive"?s.assertive:s.polite;n.textContent="",n.textContent=e}_announce(e,t){var i,s;const n=(i=(s=this._host.options).getAnnouncement)===null||i===void 0?void 0:i.call(s,{kind:t,panel:e});n===null||n===""||this.announce(n??this._defaultMessage(e,t))}_defaultMessage(e,t){var i;const s=iu(this._host.options.messages),n=(i=e.title)!==null&&i!==void 0?i:e.id;switch(t){case"open":return s.panelOpened(n);case"close":return s.panelClosed(n);case"maximize":return s.groupMaximized(n);case"restore":return s.groupRestored(n);case"float":return s.groupFloated(n);case"dock":return s.groupDocked(n);case"popout":return s.groupPoppedOut(n)}}};const Tw=ci({name:"LiveRegion",serviceKey:"liveRegionService",create:e=>new Ew(e)}),Iw=30,Aw=-10;var Rw=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){const t=this.host.options.createGroupDragGhostComponent;if(!t)return;const i=t(e);return i.init({group:e,api:this.host.api}),{element:i.element,offsetX:Iw,offsetY:Aw,dispose:i.dispose?()=>{var s;return(s=i.dispose)===null||s===void 0?void 0:s.call(i)}:void 0}}resolveOverlayModel(e,t){var i,s;return(i=(s=this.host.options).dropOverlayModel)===null||i===void 0?void 0:i.call(s,{location:e,group:t})}showPreviewOverlay(e,t){const i=e.model.contentDropTarget;return i.showOverlay(t),xe.from(()=>i.clearOverlay())}dispose(){}};const Nw=ci({name:"AdvancedDnD",serviceKey:"advancedDnDService",create:e=>new Rw(e)});var Lw=class{constructor(e){this._host=e}attachToGroup(e){return new te(e.model.onDidCreateTabGroup(t=>{this._host.fireDidCreateTabGroup(t)}),e.model.onDidDestroyTabGroup(t=>{this._host.fireDidDestroyTabGroup(t)}),e.model.onDidAddPanelToTabGroup(t=>{this._host.fireDidAddPanelToTabGroup(t)}),e.model.onDidRemovePanelFromTabGroup(t=>{this._host.fireDidRemovePanelFromTabGroup(t)}),e.model.onDidTabGroupChange(t=>{this._host.fireDidTabGroupChange(t)}),e.model.onDidTabGroupCollapsedChange(t=>{this._host.fireDidTabGroupCollapsedChange(t)}))}dispose(){}};const Mw=ci({name:"TabGroupChips",serviceKey:"tabGroupChipsService",create:e=>new Lw(e),init:(e,t)=>{const i=new Map;return new te(e.onDidAddGroup(s=>{i.set(s,t.attachToGroup(s))}),e.onDidRemoveGroup(s=>{var n;(n=i.get(s))===null||n===void 0||n.dispose(),i.delete(s)}),{dispose:()=>{for(const s of i.values())s.dispose();i.clear()}})}}),Ow=[fw,gw,_w,ww,Cw,Pw,Tw,Nw,Mw];var Gw=class{constructor(){this.cache=new WeakMap,this.currentFrameId=0,this.rafId=null}getPosition(e){const t=this.cache.get(e);if(t?.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();const i=ro(e);return this.cache.set(e,{rect:i,frameId:this.currentFrameId}),i}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||(this.rafId=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null}))}};const lh=-1;function zw(){const e=document.createElement("div");return e.tabIndex=-1,e}var hh=class extends te{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this._generation=0,this.positionCache=new Gw,this.addDisposables(xe.from(()=>{for(const i of Object.values(this.map))i.disposable.dispose(),i.destroy.dispose(),this.cancelPendingUpdate(i);this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(const e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}repositionPanelOverlay(e,t=!1,i){var s;if(this._disposed)return;const n=this.map[e];n&&(n.forceVisible=t,n.clip=i,this.positionCache.invalidate(),(s=n.resize)===null||s===void 0||s.call(n))}cancelPendingUpdate(e){e.pendingUpdate!==void 0&&(cancelAnimationFrame(e.pendingUpdate),e.pendingUpdate=void 0)}detatch(e){if(this.map[e.api.id]){const t=this.map[e.api.id];return t.disposable.dispose(),t.destroy.dispose(),this.cancelPendingUpdate(t),delete this.map[e.api.id],!0}return!1}attach(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const p=zw();p.className="dv-render-overlay",p.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:xe.NONE,destroy:xe.NONE,element:p,retainPreviousGeometry:!1,positioned:!1,generation:++this._generation}}const s=this.map[t.api.id];s.referenceContainer!==i&&(s.generation=++this._generation,this.cancelPendingUpdate(s),s.referenceContainer=i,s.retainPreviousGeometry=s.positioned);const n=s.generation,r=s.element,o=t.view.content.element;o.parentElement!==r&&r.appendChild(o),r.parentElement!==this.element&&this.element.appendChild(r);const a=()=>{const p=t.api.id,f=this.map[p];if(f?.generation!==n||f.pendingUpdate!==void 0)return;f.pendingUpdate=lh;const m=requestAnimationFrame(()=>{var g;const _=this.map[p];if(_&&(_.pendingUpdate=void 0),this.isDisposed||_?.generation!==n)return;const T=(g=_.forceVisible)!==null&&g!==void 0?g:!1,D=_.clip,E=this.positionCache.getPosition(i.element),S=this.positionCache.getPosition(this.element),A=E.left-S.left,k=E.top-S.top,L=E.width,O=E.height;if(_.retainPreviousGeometry&&(L===0||O===0)){!t.api.isVisible&&!T&&(r.style.visibility="hidden",r.style.pointerEvents="none");return}if(_.retainPreviousGeometry=!1,_.positioned=!0,r.style.left=`${A}px`,r.style.top=`${k}px`,r.style.width=`${L}px`,r.style.height=`${O}px`,t.api.isVisible||T?(r.style.visibility="",r.style.pointerEvents=""):(r.style.visibility="hidden",r.style.pointerEvents="none"),T?r.style.zIndex="1000":t.api.location.type!=="floating"&&(r.style.zIndex=""),D){var z,N;const I=this.element.ownerDocument.defaultView,C=(z=I?.scrollX)!==null&&z!==void 0?z:0,v=(N=I?.scrollY)!==null&&N!==void 0?N:0,y=D.top+v,x=D.left+C,b=Math.max(0,y-E.top),R=Math.max(0,x-E.left),M=Math.max(0,E.left+L-(D.right+C)),W=Math.max(0,E.top+O-(D.bottom+v));r.style.clipPath=`inset(${b}px ${M}px ${W}px ${R}px)`}else r.style.clipPath="";Y(r,"dv-render-overlay-float",t.group.api.location.type==="floating")});f.pendingUpdate===lh&&(f.pendingUpdate=m)},l=()=>{if(t.api.isVisible){var p;this.positionCache.invalidate(),a(),!((p=this.map[t.api.id])===null||p===void 0)&&p.retainPreviousGeometry&&(r.style.visibility=""),r.style.pointerEvents=""}else r.style.visibility="hidden",r.style.pointerEvents="none"},h=new Ge,c=()=>{t.api.location.type==="floating"?queueMicrotask(()=>{const p=this.accessor.getFloatingWindowForGroup(t.api.group);if(!p)return;const f=p.overlay.element,m=()=>{const _=Number(f.getAttribute("aria-level"));r.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${_*2+1})`},g=new MutationObserver(()=>{m()});h.value=xe.from(()=>g.disconnect()),g.observe(f,{attributeFilter:["aria-level"],attributes:!0}),m()}):r.style.zIndex=""},u=new te(h,new ru(r,{onDragEnd:p=>{i.dropTarget.dnd.onDragEnd(p)},onDragEnter:p=>{i.dropTarget.dnd.onDragEnter(p)},onDragLeave:p=>{i.dropTarget.dnd.onDragLeave(p)},onDrop:p=>{i.dropTarget.dnd.onDrop(p)},onDragOver:p=>{i.dropTarget.dnd.onDragOver(p)}}),t.api.onDidVisibilityChange(()=>{l()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&a()}),t.api.onDidLocationChange(()=>{c()}));return this.map[t.api.id].destroy=xe.from(()=>{o.parentElement===r&&o.remove(),r.remove()}),c(),queueMicrotask(()=>{this.isDisposed||l()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=u,this.map[t.api.id].resize=a,r}};function dh(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(h){i(h);return}a.done?t(l):Promise.resolve(l).then(s,n)}function Iu(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(l){dh(r,s,n,o,a,"next",l)}function a(l){dh(r,s,n,o,a,"throw",l)}o(void 0)})}}function jw(e){let t;try{t=new URL(e,globalThis.location.href)}catch{throw new Error(`dockview: invalid popout URL: ${e}`)}if(!(t.protocol==="http:"||t.protocol==="https:")||t.origin!==globalThis.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}var Bw=class extends te{get window(){var e,t;return(e=(t=this._window)===null||t===void 0?void 0:t.value)!==null&&e!==void 0?e:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new G,this.onWillClose=this._onWillClose.event,this._onDidClose=new G,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;const e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){if(this._window){var e,t;this._onWillClose.fire(),(e=(t=this.options).onWillClose)===null||e===void 0||e.call(t,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire()}}open(){var e=this;return Iu(function*(){var t,i;if(e._window)throw new Error("instance of popout window is already open");const s=`${e.options.url}`;jw(s);const n=Object.entries({top:e.options.top,left:e.options.left,width:e.options.width,height:e.options.height}).map(([l,h])=>`${l}=${h}`).join(","),r=window.open(s,e.target,n);if(!r)return null;const o=new te;e._window={value:r,disposable:o},o.addDisposables(xe.from(()=>{r.close()}),Z(globalThis.window,"beforeunload",()=>{e.close()}));const a=e.createPopoutWindowContainer();return e.className&&a.classList.add(e.className),(t=(i=e.options).onDidOpen)===null||t===void 0||t.call(i,{id:e.target,window:r}),new Promise((l,h)=>{r.addEventListener("unload",()=>{}),o.addDisposables(e.onWillClose(()=>l(null))),r.addEventListener("load",()=>{try{const c=r.document;c.title=document.title,c.body.appendChild(a),N_(c,globalThis.document.styleSheets,{nonce:e.options.nonce}),Z(r,"beforeunload",()=>{e.close()}),l(a)}catch(c){h(c)}})})})()}createPopoutWindowContainer(){const e=document.createElement("div");return e.classList.add("dv-popout-window"),e.id="dv-popout-window",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.top="0px",e.style.left="0px",e}},$w=class extends te{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(i=>{if(e.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${i.api.id} but panel already exists`);e.add(i.api.id)}),this.accessor.onDidRemovePanel(i=>{if(e.has(i.api.id))e.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${i.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(i=>{if(t.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${i.api.id} but group already exists`);t.add(i.api.id)}),this.accessor.onDidRemoveGroup(i=>{if(t.has(i.api.id))t.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${i.api.id} but group does not exists`)}))}};function Ww(e){if(!e.matchMedia)return!1;const t=e.matchMedia("(pointer: coarse)").matches,i=e.matchMedia("(pointer: fine)").matches;return t&&!i}function Hw(e){var t,i,s,n,r,o,a;const l=(t=e.window)!==null&&t!==void 0?t:window,h=(i=e.capture)!==null&&i!==void 0?i:!1,c=(s=e.escape)!==null&&s!==void 0?s:!0,u=(n=e.keys)!==null&&n!==void 0?n:[],p=(r=e.outsidePointerDown)!==null&&r!==void 0?r:!0,f=(o=e.pointerDownGraceMs)!==null&&o!==void 0?o:0,m=(a=e.now)!==null&&a!==void 0?a:Date.now,g=m(),_=new te,T=D=>{var E,S;if(e.isInside)return e.isInside(D);const A=D.target;return A instanceof Node?((E=(S=e.elements)===null||S===void 0?void 0:S.call(e))!==null&&E!==void 0?E:[]).some(k=>k.contains(A)):!1};if((c||u.length>0)&&_.addDisposables(Z(l,"keydown",D=>{(c&&D.key==="Escape"||u.includes(D.key))&&e.onDismiss()},h)),(p||e.onInsidePointerDown)&&_.addDisposables(Z(l,"pointerdown",D=>{if(T(D)){var E;(E=e.onInsidePointerDown)===null||E===void 0||E.call(e,D);return}!p||m()-g<f||e.onDismiss()},h)),e.resize&&_.addDisposables(Z(l,"resize",()=>{Ww(l)||e.onDismiss()})),e.focusOut){const D=S=>{var A,k;return e.isFocusInside?e.isFocusInside(S):((A=(k=e.elements)===null||k===void 0?void 0:k.call(e))!==null&&A!==void 0?A:[]).some(L=>L.contains(S))},E=S=>{const A=S.target;A instanceof Element&&!D(A)&&e.onDismiss()};l.addEventListener("focusin",E,h),_.addDisposables({dispose:()=>l.removeEventListener("focusin",E,h)})}return _}var ch=class extends te{constructor(e,t=globalThis.window){super(),this._active=null,this._activeDisposable=new Ge,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(xe.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const s=this._window.document.createElement("div");s.style.position="absolute",s.style.zIndex=(i=t.zIndex)!==null&&i!==void 0?i:"var(--dv-overlay-z-index)",s.appendChild(e);const n=this._element.getBoundingClientRect(),r=n.left,o=n.top;s.style.top=`${t.y-o}px`,s.style.left=`${t.x-r}px`,this._element.appendChild(s),this._active=s;const a=200;this._activeDisposable.value=Hw({window:this._window,onDismiss:()=>this.close(),elements:()=>this._active?[this._active]:[],keys:["Enter"],pointerDownGraceMs:a,resize:!0}),this._window.requestAnimationFrame(()=>{j_(s,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}},Sr=class extends te{get disabled(){return this._disabled}set disabled(e){this.disabled!==e&&(this._disabled=e,e&&this._clearNow())}_cancelPendingClear(){this._pendingClear!==void 0&&(clearTimeout(this._pendingClear),this._pendingClear=void 0)}_clearNow(){this._cancelPendingClear(),this._model&&this._model.root.remove(),this._model=void 0}get model(){if(!this.disabled)return{clear:()=>{this._clearNow()},scheduleClear:()=>{this._pendingClear!==void 0||!this._model||(this._pendingClear=setTimeout(()=>{this._pendingClear=void 0,this._clearNow()},0))},exists:()=>!!this._model,getElements:(e,t)=>{this._cancelPendingClear();const i=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=i,this._model;const s=this.createContainer(),n=this.createAnchor();if(this._model={root:s,overlay:n,changed:i},s.appendChild(n),this.element.appendChild(s),e?.target instanceof HTMLElement){const r=e.target.getBoundingClientRect(),o=this.element.getBoundingClientRect();n.style.left=`${r.left-o.left}px`,n.style.top=`${r.top-o.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(xe.from(()=>{var i;(i=this.model)===null||i===void 0||i.clear()}))}createContainer(){const e=document.createElement("div");return e.className="dv-drop-target-container",e}createAnchor(){const e=document.createElement("div");return e.className="dv-drop-target-anchor",e.style.visibility="hidden",e}},Fw=class{get _effectiveBaseCollapsed(){var e;return(e=this._measuredTabSize)!==null&&e!==void 0?e:this._baseCollapsedSize}get minimumSize(){return this._isCollapsed?this.collapsedSize:this._baseMinimumSize!==void 0?this._baseMinimumSize+this._gapAdd:this._effectiveBaseCollapsed+50+this._gapAdd}get maximumSize(){return this._isCollapsed?this.collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._effectiveBaseCollapsed+this._gapAdd}get configuredMinimumSize(){return this._baseMinimumSize}get configuredMaximumSize(){return this._expandedMaximumSize}get configuredCollapsedSize(){return this._baseCollapsedSize}constructor(e,t,i,s=0){var n,r,o;this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority="low",this._isCollapsed=!1,this._tabSizeDisposables=new te,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._baseCollapsedSize=(n=e.collapsedSize)!==null&&n!==void 0?n:35,this._baseMinimumSize=e.minimumSize,this._gapAdd=s,this._expandedMaximumSize=(r=e.maximumSize)!==null&&r!==void 0?r:Number.POSITIVE_INFINITY,this._lastExpandedSize=(o=e.initialSize)!==null&&o!==void 0?o:200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add("dv-edge-collapsed")),this._observeTabStrip()}_observeTabStrip(){const e=this._group.element.querySelector(".dv-tabs-and-actions-container");e&&this._tabSizeDisposables.addDisposables(Ui(e,()=>{this._applyMeasuredTabSize(this._orientation==="vertical"?e.offsetHeight:e.offsetWidth)}))}_applyMeasuredTabSize(e){e<=0||e===this._measuredTabSize||(this._measuredTabSize=e,this._isCollapsed&&this._onDidChange.fire({size:this.collapsedSize}))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation==="horizontal"?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle("dv-edge-collapsed",e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateSizing(e,t,i){this._baseCollapsedSize=e,this._baseMinimumSize=t,this._gapAdd=i}dispose(){this._tabSizeDisposables.dispose(),this._onDidChange.dispose()}},Vw=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority="high",this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new G,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},Uw=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority="high",this._element=document.createElement("div"),this._element.className="dv-shell-middle-column",this._element.style.height="100%",this._element.style.width="100%",this._splitview=new Hi(this._element,{orientation:"VERTICAL",proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t=e==="top"?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e==="top"?(this._topIndex=void 0,this._centerIndex-=1,this._bottomIndex!==void 0&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.isViewVisible(t):!1}getViewSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.getViewSize(t):0}getViewCachedVisibleSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;if(t!==void 0)return this._splitview.getViewCachedVisibleSize(t)}resizeView(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}},Kw=class{constructor(e,t,i,s=0,n=35){this._disposables=new te,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=s,this._defaultCollapsedSize=n,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const r=new Vw(t,i);this._middleColumn=new Uw(r,s),this._outerSplitview=new Hi(this._shellElement,{orientation:"HORIZONTAL",proportionalLayout:!1,margin:s}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(Ui(this._shellElement,o=>{if(!this._shellElement.offsetParent||!Yc(this._shellElement))return;const a=Math.round(o.contentRect.width),l=Math.round(o.contentRect.height);a===this._currentWidth&&l===this._currentHeight||(this._currentWidth=a,this._currentHeight=l,this.layout(a,l))}),this._outerSplitview,this._middleColumn,r)}get element(){return this._shellElement}addEdgeView(e,t,i){if(this.hasEdgeGroup(e))throw new Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);const s=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),n=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),r=s>1?this._gap*(s-1)/s:0,o=n>1?this._gap*(n-1)/n:0,a=e==="left"||e==="right",l=a?r:o,h=a?"horizontal":"vertical",c=new Fw(se({collapsedSize:this._defaultCollapsedSize},t),i,h,l),u=c.isCollapsed?c.collapsedSize:c.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(c,u,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=c;break;case"right":{const p=this._outerSplitview.length;this._outerSplitview.addView(c,u,p),this._rightIndex=p,this._rightView=c}break;case"top":this._middleColumn.addTopView(c,u),this._topView=c;break;case"bottom":this._middleColumn.addBottomView(c,u),this._bottomView=c;break}return this._disposables.addDisposables(c),this.updateTheme(this._gap,this._defaultCollapsedSize),c}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,s,n,r;this._gap=e,this._defaultCollapsedSize=t;const o=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),a=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),l=o>1?e*(o-1)/o:0,h=a>1?e*(a-1)/a:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const c=(g,_,T)=>{var D;const E=(D=_.collapsedSize)!==null&&D!==void 0?D:t;g.updateSizing(E,_.minimumSize,T)},u=this._viewConfigs.get("top");this._topView&&u&&c(this._topView,u,h);const p=this._viewConfigs.get("bottom");this._bottomView&&p&&c(this._bottomView,p,h);const f=this._viewConfigs.get("left");this._leftView&&f&&c(this._leftView,f,l);const m=this._viewConfigs.get("right");this._rightView&&m&&c(this._rightView,m,l),!((i=this._leftView)===null||i===void 0)&&i.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),!((s=this._rightView)===null||s===void 0)&&s.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),!((n=this._topView)===null||n===void 0)&&n.isCollapsed&&this._middleColumn.resizeView("top",this._topView.collapsedSize),!((r=this._bottomView)===null||r===void 0)&&r.isCollapsed&&this._middleColumn.resizeView("bottom",this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){const t=this._getView(e);if(t){switch(e){case"left":this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,this._middleIndex-=1,this._rightIndex!==void 0&&(this._rightIndex-=1);break;case"right":this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case"top":this._middleColumn.removeView("top"),this._topView=void 0;break;case"bottom":this._middleColumn.removeView("bottom"),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return this._topView!==void 0;case"bottom":return this._bottomView!==void 0;case"left":return this._leftView!==void 0;case"right":return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case"left":return this._leftIndex!==void 0?this._outerSplitview.isViewVisible(this._leftIndex):!1;case"right":return this._rightIndex!==void 0?this._outerSplitview.isViewVisible(this._rightIndex):!1;case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const s=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,s);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,s);break;case"top":case"bottom":this._middleColumn.resizeView(e,s);break}}isEdgeGroupCollapsed(e){var t,i;return(t=(i=this._getView(e))===null||i===void 0?void 0:i.isCollapsed)!==null&&t!==void 0?t:!1}getEdgeGroupExpandedSize(e){var t,i;return(t=(i=this._getView(e))===null||i===void 0?void 0:i.lastExpandedSize)!==null&&t!==void 0?t:0}_getView(e){switch(e){case"top":return this._topView;case"bottom":return this._bottomView;case"left":return this._leftView;case"right":return this._rightView}}toJSON(){const e={},t=s=>({minimumSize:s.configuredMinimumSize,maximumSize:Number.isFinite(s.configuredMaximumSize)?s.configuredMaximumSize:void 0,collapsedSize:s.configuredCollapsedSize}),i=(s,n,r,o)=>s.isCollapsed?s.lastExpandedSize:n?r:o??s.lastExpandedSize;if(this._leftView&&this._leftIndex!==void 0){const s=this._outerSplitview.isViewVisible(this._leftIndex);e.left=se({size:i(this._leftView,s,this._outerSplitview.getViewSize(this._leftIndex),this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),visible:s,collapsed:this._leftView.isCollapsed||void 0},t(this._leftView))}if(this._rightView&&this._rightIndex!==void 0){const s=this._outerSplitview.isViewVisible(this._rightIndex);e.right=se({size:i(this._rightView,s,this._outerSplitview.getViewSize(this._rightIndex),this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),visible:s,collapsed:this._rightView.isCollapsed||void 0},t(this._rightView))}if(this._topView){const s=this._middleColumn.isViewVisible("top");e.top=se({size:i(this._topView,s,this._middleColumn.getViewSize("top"),this._middleColumn.getViewCachedVisibleSize("top")),visible:s,collapsed:this._topView.isCollapsed||void 0},t(this._topView))}if(this._bottomView){const s=this._middleColumn.isViewVisible("bottom");e.bottom=se({size:i(this._bottomView,s,this._middleColumn.getViewSize("bottom"),this._middleColumn.getViewCachedVisibleSize("bottom")),visible:s,collapsed:this._bottomView.isCollapsed||void 0},t(this._bottomView))}return e}fromJSON(e){if(e.left&&this._leftIndex!==void 0){var t,i,s,n,r;(t=this._leftView)===null||t===void 0||t.restoreExpandedSize(e.left.size),(i=this._leftView)===null||i===void 0||i.setCollapsed((s=e.left.collapsed)!==null&&s!==void 0?s:!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&(n=(r=this._leftView)===null||r===void 0?void 0:r.collapsedSize)!==null&&n!==void 0?n:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)}if(e.right&&this._rightIndex!==void 0){var o,a,l,h,c;(o=this._rightView)===null||o===void 0||o.restoreExpandedSize(e.right.size),(a=this._rightView)===null||a===void 0||a.setCollapsed((l=e.right.collapsed)!==null&&l!==void 0?l:!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&(h=(c=this._rightView)===null||c===void 0?void 0:c.collapsedSize)!==null&&h!==void 0?h:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)}if(e.top){var u,p,f,m,g;(u=this._topView)===null||u===void 0||u.restoreExpandedSize(e.top.size),(p=this._topView)===null||p===void 0||p.setCollapsed((f=e.top.collapsed)!==null&&f!==void 0?f:!1),this._middleColumn.resizeView("top",e.top.collapsed&&(m=(g=this._topView)===null||g===void 0?void 0:g.collapsedSize)!==null&&m!==void 0?m:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)}if(e.bottom){var _,T,D,E,S;(_=this._bottomView)===null||_===void 0||_.restoreExpandedSize(e.bottom.size),(T=this._bottomView)===null||T===void 0||T.setCollapsed((D=e.bottom.collapsed)!==null&&D!==void 0?D:!1),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&(E=(S=this._bottomView)===null||S===void 0?void 0:S.collapsedSize)!==null&&E!==void 0?E:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1)}}dispose(){this._disposables.dispose(),this._shellElement.remove()}};function qw(e){var t;return new xu((t=e.tabGroupColors)!==null&&t!==void 0?t:Fa,e.tabGroupAccent!=="off")}function cn(e){const t=e.from.activePanel;[...e.from.panels].map(i=>{const s=e.from.model.removePanel(i);return e.from.model.renderContainer.detatch(i),s}).forEach(i=>{e.to.model.openPanel(i,{skipSetActive:t!==i,skipSetGroupActive:!0})})}const vo=()=>({dispose:()=>{}}),Yw=vo;var Xw=class extends tu{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return(e=this.options.defaultRenderer)!==null&&e!==void 0?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return(e=this.options.defaultHeaderPosition)!==null&&e!==void 0?e:"top"}get api(){return this._api}get floatingGroups(){var e,t;return(e=(t=this._moduleRegistry)===null||t===void 0||(t=t.services.floatingGroupService)===null||t===void 0?void 0:t.floatingGroups)!==null&&e!==void 0?e:[]}getFloatingWindowForGroup(e){var t;return(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e)}_gatherFloatingGroupBoxes(e){return this.getFloatingGroupSnapshots(e).map(t=>t.box)}getFloatingContainer(){var e;return(e=this._floatingOverlayHost)!==null&&e!==void 0?e:this.gridview.element}getFloatingGroupSnapshots(e){const t=this.getFloatingContainer().getBoundingClientRect();return this.floatingGroups.filter(i=>i.group!==e).map(i=>{const s=i.overlay.element.getBoundingClientRect();return{group:i.group,box:{left:s.left-t.left,top:s.top-t.top,width:s.width,height:s.height}}})}mergeFloatInto(e,t,i){e===t||!this.getPanel(t.id)||this.moveGroupOrPanel({from:{groupId:e.id},to:{group:t,position:i}})}getGridSplitterRects(){const e=this.getFloatingContainer().getBoundingClientRect(),t=[];return this.gridview.element.querySelectorAll(".dv-sash").forEach(i=>{const s=i.getBoundingClientRect();t.push({left:s.left-e.left,top:s.top-e.top,width:s.width,height:s.height})}),t}get _smartGuidesService(){return this._moduleRegistry.services.smartGuidesService}get smartGuidesEnabled(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.enabled)!==null&&e!==void 0?e:!1}setSmartGuidesEnabled(e){var t;(t=mt(this._smartGuidesService,"SmartGuides","api.setSmartGuidesEnabled"))===null||t===void 0||t.setEnabled(e)}updateSmartGuidesOptions(e){var t;(t=mt(this._smartGuidesService,"SmartGuides","api.updateSmartGuidesOptions"))===null||t===void 0||t.updateOptions(e)}get onDidSnapFloat(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.onDidSnapFloat)!==null&&e!==void 0?e:vo}get onDidSnapTogether(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.onDidSnapTogether)!==null&&e!==void 0?e:vo}_buildFloatingDragTransform(e,t){const i=this.options.transformFloatingGroupDrag,s=!t;if(!(!i&&!(s&&this._smartGuidesService)))return n=>{var r,o;const a=i?.({group:e,proposed:n.proposed,container:n.container,others:n.others,modifiers:n.modifiers}),l=a?se(se({},n.proposed),a):n.proposed,h=s?(r=this._smartGuidesService)===null||r===void 0?void 0:r.transformFloatingGroupDrag({group:e,proposed:l,container:n.container,others:n.others,modifiers:n.modifiers}):void 0;return(o=h??a)!==null&&o!==void 0?o:void 0}}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get _dndCompassService(){return this._moduleRegistry.services.dndCompassService}canDropOnGroup(e,t,i){return e.model.canDisplayContentOverlay(i,t)}getDropOverlayElement(e){var t,i;const s=e.element.querySelector(".dv-content-container");if(s)return((t=this.options.theme)===null||t===void 0?void 0:t.dndPanelOverlay)==="group"&&(i=s.parentElement)!==null&&i!==void 0?i:s}getTabsListElement(e){return e.model.header.hidden?void 0:e.model.tabsListElement}relayoutGroup(e){e.relayout()}setForcedOverflow(e,t){e.model.header.setForcedOverflow(t)}getLayoutElement(){return this.gridview.element}getDropPositionResolver(){var e;if(this.options.dropPositionResolver)return this.options.dropPositionResolver;const t=(e=this._dndCompassService)===null||e===void 0?void 0:e.resolver,i=this._moduleRegistry.services.autoEdgeGroupService;return t&&i?{resolve:s=>{var n;return(n=i.resolveEdge(s))!==null&&n!==void 0?n:t.resolve(s)}}:t??i?.resolver}dockToLayoutEdge(e,t){const i=new Du({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Ie,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=Ie();if(s){var n;this.moveGroupOrPanel({from:{groupId:s.groupId,panelId:(n=s.panelId)!==null&&n!==void 0?n:void 0},to:{group:this.orthogonalize(t),position:"center"}})}else this._onDidDrop.fire(new Ka({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Ie}))}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}get _layoutHistoryService(){return this._moduleRegistry.services.layoutHistoryService}undo(){var e;(e=mt(this._layoutHistoryService,"LayoutHistory","api.undo"))===null||e===void 0||e.undo()}redo(){var e;(e=mt(this._layoutHistoryService,"LayoutHistory","api.redo"))===null||e===void 0||e.redo()}get canUndo(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.canUndo)!==null&&e!==void 0?e:!1}get canRedo(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.canRedo)!==null&&e!==void 0?e:!1}clearHistory(){var e;(e=this._layoutHistoryService)===null||e===void 0||e.clear()}get onDidChangeHistory(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.onDidChangeHistory)!==null&&e!==void 0?e:Yw}get hasEdgeDragReveal(){return!!this._moduleRegistry.services.autoEdgeGroupService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){var e;return(e=this.rootDropTargetContainer)===null||e===void 0?void 0:e.model}dispatchUnhandledDragOver(e,t){const i=new yu(e,"edge",t,Ie);return this._onUnhandledDragOver.fire(i),i.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){var t;return(t=this._advancedDnDService)===null||t===void 0?void 0:t.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){var i;return(i=this._advancedDnDService)===null||i===void 0?void 0:i.resolveOverlayModel(e,t)}get rootElement(){var e,t;return(e=(t=this._shellManager)===null||t===void 0?void 0:t.element)!==null&&e!==void 0?e:this.element}ownsElement(e){if(this.rootElement.contains(e))return!0;const t=this.rootElement.ownerDocument,i=e.ownerDocument;return!i||i===t?!1:this.getPopoutWindows().some(s=>s.document===i)}adjacentGroup(e,t){var i;if(e.api.location.type!=="grid")return;const s=Ce(e.element);return(i=t?this.gridview.previous(s):this.gridview.next(s))===null||i===void 0?void 0:i.view}adjacentGroupInDirection(e,t){if(e.api.location.type!=="grid")return;const i=e.element.getBoundingClientRect(),s=i.left+i.width/2,n=i.top+i.height/2;let r,o=Number.POSITIVE_INFINITY;for(const a of this.groups){if(a===e||a.api.location.type!=="grid")continue;const l=a.element.getBoundingClientRect(),h=l.left+l.width/2-s,c=l.top+l.height/2-n;let u;switch(t){case"left":u=h<0&&Math.abs(h)>=Math.abs(c);break;case"right":u=h>0&&Math.abs(h)>=Math.abs(c);break;case"up":u=c<0&&Math.abs(c)>=Math.abs(h);break;default:u=c>0&&Math.abs(c)>=Math.abs(h);break}if(!u)continue;const p=h*h+c*c;p<o&&(o=p,r=a)}return r}showDropPreview(e,t){var i,s;return(i=(s=this._advancedDnDService)===null||s===void 0?void 0:s.showPreviewOverlay(e,t))!==null&&i!==void 0?i:xe.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)===null||t===void 0||t.announce(e)}dockPanel(e,t,i){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:i}})}floatPanel(e){this.addFloatingGroup(e)}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get pinnedTabsService(){return this._moduleRegistry.services.pinnedTabsService}get advancedOverflowService(){return this._moduleRegistry.services.advancedOverflowService}setPanelPinned(e,t){var i;e.isPinned!==t&&!((i=this.options.pinnedTabs)===null||i===void 0)&&i.enabled&&this.pinnedTabsService&&(e.setPinned(t),this._onDidPanelPinnedChange.fire({panel:e,isPinned:t}))}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type==="grid"&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){var e,t;return(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.restorationPromise)!==null&&e!==void 0?e:Promise.resolve()}constructor(e,t){var i,s,n,r,o;super(e,{proportionalLayout:!0,orientation:"HORIZONTAL",styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:(i=(s=t.theme)===null||s===void 0?void 0:s.gap)!==null&&i!==void 0?i:0,className:t.className}),this.nextGroupId=ja(),this._deserializer=new iw(this),this._moduleRegistry=new aw,this._onWillDragPanel=new G,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new G,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new G,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._pendingLocationChanges=new Map,this._origin="user",this._originDepth=0,this._onWillMutateLayout=new G,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new G,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new G,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new G,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new G,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new G,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new G,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new G,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidChangePopouts=new G,this.onDidChangePopouts=this._onDidChangePopouts.event,this._onDidOpenPopoutWindowFail=new G,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidStartFloatingGroupDrag=new G,this.onDidStartFloatingGroupDrag=this._onDidStartFloatingGroupDrag.event,this._onDidEndFloatingGroupDrag=new G,this.onDidEndFloatingGroupDrag=this._onDidEndFloatingGroupDrag.event,this._onDidLayoutFromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new G({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidPanelPinnedChange=new G,this.onDidPanelPinnedChange=this._onDidPanelPinnedChange.event,this._onDidMovePanel=new G,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new G,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new G,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new G,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new G,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new G,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new G,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new G,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new G,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidEdgeGroupAutoHideChange=new G,this.onDidEdgeGroupAutoHideChange=this._onDidEdgeGroupAutoHideChange.event,this._onDidAddGroup=new G,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new G,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._peekingGroups=new Set,this._moving=!1,this._options=t,this._tabGroupColorPalette=qw(t);const a=t.modules,l=a??[...Ow,...hw()];for(const u of l)this._moduleRegistry.register(u);this._moduleRegistry.initialize(this),this.reportMissingOptionModules(t);const h=this._popoutWindowService;h&&this.addDisposables(h.onDidRemove(u=>{this._onDidRemovePopoutGroup.fire({id:u.popoutGroup.id,group:u.popoutGroup,window:u.getWindow()})})),this.popupService=new ch(this.element),this._api=new $a(this),this.disableResizing=!0,this.element.remove(),this._shellManager=new Kw(e,this.element,(u,p)=>this._layoutFromShell(u,p),(n=(r=t.theme)===null||r===void 0?void 0:r.gap)!==null&&n!==void 0?n:0,(o=t.theme)===null||o===void 0?void 0:o.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new rr(this._shellManager.element),this.rootDropTargetContainer=new Sr(this._shellManager.element,{disabled:!0}),this.floatingDropTargetContainer=new Sr(this._shellManager.element,{disabled:!1}),this.overlayRenderContainer=new hh(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost),Y(this.gridview.element,"dv-dockview",!0),Y(this.element,"dv-debug",!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new $w(this)),this.addDisposables(xe.from(()=>this._pendingLocationChanges.clear()),this.rootDropTargetContainer,this.floatingDropTargetContainer,Z(this._shellManager.element,"dragend",()=>{var u,p;(u=this.rootDropTargetContainer.model)===null||u===void 0||u.clear(),(p=this.floatingDropTargetContainer.model)===null||p===void 0||p.clear()},!0),this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidPanelPinnedChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidEdgeGroupAutoHideChange,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidChangePopouts,this._onDidAddPopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidRemovePopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidOpenPopoutWindowFail,this._onDidStartFloatingGroupDrag,this._onDidEndFloatingGroupDrag,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,Tt.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(u=>{this._moving||this._onDidAddGroup.fire(u)}),this.onDidRemove(u=>{this._moving||this._onDidRemoveGroup.fire(u)}),this.onDidActiveChange(u=>{this._moving||this._onDidActiveGroupChange.fire(u)}),this.onDidMaximizedChange(u=>{this._onDidMaximizedGroupChange.fire({group:u.panel,isMaximized:u.isMaximized})}),Tt.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),xe.from(()=>{var u;this._moduleRegistry.dispose(),(u=this._shellManager)===null||u===void 0||u.dispose()}));const c=this._rootDropTargetService;c&&this.addDisposables(c.onWillShowOverlay(u=>{this.gridview.length>0&&u.position==="center"||this._onWillShowOverlay.fire(new Ws(u,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:Ie}))}),c.onDrop(u=>this.dockToLayoutEdge(u.nativeEvent,u.position))),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(s=>s.group===e);i&&(i.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case"popout":console.warn("dockview: You cannot hide a group that is in a popout window");break}}getPopupServiceForGroup(e){var t,i;return(t=(i=this._popoutWindowService)===null||i===void 0||(i=i.findByGroup(e))===null||i===void 0?void 0:i.popupService)!==null&&t!==void 0?t:this.popupService}addPopoutGroup(e,t){return this.mutationAsync("popout",()=>this._doAddPopoutGroup(e,t))}getPopouts(){var e,t;return(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.entries.map(i=>({id:i.popoutGroup.id,group:i.popoutGroup,window:i.getWindow()})))!==null&&e!==void 0?e:[]}getPopoutWindows(){return this.getPopouts().map(e=>e.window)}_doAddPopoutGroup(e,t){var i,s,n,r,o;const a=mt(this._popoutWindowService,"PopoutWindow","api.addPopoutGroup");if(!a||e instanceof ln&&e.model.location.type==="edge")return Promise.resolve(!1);if(e instanceof es&&e.group.size===1)return this.addPopoutGroup(e.group,t);const l=O_(this.gridview.element),h=this.element;function c(){var _,T;if(t?.position)return t.position;const D=(e instanceof ln?e.element:(_=(T=e.group)===null||T===void 0?void 0:T.element)!==null&&_!==void 0?_:h).getBoundingClientRect();return{left:window.screenX+D.left,top:window.screenY+D.top,width:D.width,height:D.height}}const u=c(),p=(i=t==null||(s=t.overridePopoutGroup)===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:this.getNextGroupId(),f=(n=t?.popoutUrl)!==null&&n!==void 0?n:(r=this.options)===null||r===void 0?void 0:r.popoutUrl,m=new Bw(`${this.id}-${p}`,l??"",{url:f??"/popout.html",left:u.left,top:u.top,width:u.width,height:u.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:(o=this.options)===null||o===void 0?void 0:o.nonce}),g=new te(m,m.onDidClose(()=>{g.dispose()}));return m.open().then(_=>{var T,D;if(m.isDisposed)return!1;const E=(T=t?.referenceGroup)!==null&&T!==void 0?T:e instanceof es?e.group:e,S=e.api.location.type,A=E.element.parentElement!==null;let k;if(t?.overridePopoutGridview){var L;k=(L=t.overridePopoutGroup)!==null&&L!==void 0?L:E}else A?t?.overridePopoutGroup?k=t.overridePopoutGroup:(k=this.createGroup({id:p}),_&&this._onDidAddGroup.fire(k)):k=E;if(_===null)return this.handleBlockedPopout({group:k,referenceGroup:E,options:t,popoutWindowDisposable:g}),!1;const O=document.createElement("div");O.className="dv-overlay-render-container";const z=new hh(O,this);k.model.renderContainer=z;const N=(D=t?.overridePopoutGridview)!==null&&D!==void 0?D:this.createNestedGridview();t?.overridePopoutGridview||N.addView(k,lt.Distribute,[0]),N.element.style.width="100%",N.element.style.height="100%",N.layout(m.window.innerWidth,m.window.innerHeight);let I=!1;const C=()=>{I||(I=!0,N.dispose())};let v,y=[];if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&A)if(e instanceof es){const re=e.group;this.movingLock(()=>{const me=E.model.removePanel(e);k.model.openPanel(me)}),y=[{panel:e,from:re}]}else switch(this.movingLock(()=>cn({from:E,to:k})),y=k.panels.map(re=>({panel:re,from:E})),S){case"grid":E.api.setVisible(!1);break;case"floating":case"popout":var x;v=(x=this.floatingGroups.find(re=>re.group.api.id===e.api.id))===null||x===void 0?void 0:x.overlay.toJSON(),this.removeGroup(E);break}_.classList.add("dv-dockview"),_.style.overflow="hidden",_.appendChild(O),_.appendChild(N.element);const b=document.createElement("div"),R=new Sr(b,{disabled:this.rootDropTargetContainer.disabled});_.appendChild(b),k.model.dropTargetContainer=R;const M=new ch(_,m.window);if(g.addDisposables(M),k.model.location={type:"popout",getWindow:()=>m.window,popoutUrl:f},t?.overridePopoutGridview){const re=this.groups.filter(me=>N.element.contains(me.element));for(const me of re)me.model.renderContainer=z,me.model.dropTargetContainer=R,me.model.location={type:"popout",getWindow:()=>m.window,popoutUrl:f}}A&&e.api.location.type==="grid"&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(k);const W=a.observeGridviewSize(m,N,z);W&&g.addDisposables(W);const B=new Ge;g.addDisposables(B);const Q=re=>{B.value=new te(re.api.onDidActiveChange(me=>{if(me.isActive){var K;(K=m.window)===null||K===void 0||K.focus()}}),re.api.onWillFocus(()=>{var me;(me=m.window)===null||me===void 0||me.focus()}))};Q(k);const ie={},ne=A&&E&&this.getPanel(E.id),de={window:m,popoutGroup:k,gridview:N,overlayRenderContainer:z,dropTargetContainer:R,getWindow:()=>m.window,popoutUrl:f,referenceGroup:ne?E.id:void 0,popupService:M,setAnchorGroup:re=>{de.popoutGroup=re,Q(re)},disposable:{dispose:()=>(g.dispose(),ie.returnedGroup)}},ve=G_(m.window);g.addDisposables(ve,z_(m.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:m.window.innerWidth,height:m.window.innerHeight,group:de.popoutGroup})}),ve.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:m.window.screenX,screenY:m.window.screenY,group:de.popoutGroup})}),Z(m.window,"resize",()=>{N.layout(m.window.innerWidth,m.window.innerHeight)}),z,xe.from(()=>this.disposePopoutWindow({group:k,referenceGroup:E,popoutGridview:N,isGroupAddedToDom:A,floatingBox:v,disposePopoutGridview:C,closeResult:ie}))),a.add(de),this._onDidAddPopoutGroup.fire({id:de.popoutGroup.id,group:de.popoutGroup,window:de.getWindow()});for(const{panel:re,from:me}of y)this.fireDidMovePanel(re,me);return!0}).catch(_=>(console.error("dockview: failed to create popout.",_),!1))}handleBlockedPopout(e){const{group:t,referenceGroup:i,options:s,popoutWindowDisposable:n}=e;if(console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),n.dispose(),this._onDidOpenPopoutWindowFail.fire(),s?.overridePopoutGridview){const r=s.overridePopoutGridview,o=this.groups.filter(a=>r.element.contains(a.element));for(const a of o)this.movingLock(()=>{r.remove(a),this.redockGroupToMainGrid(a)});r.dispose(),i&&!i.api.isVisible&&i.api.setVisible(!0);return}t===i?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:"grid"}):(this.movingLock(()=>cn({from:t,to:i})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),i.api.isVisible||i.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:"grid"},this.doAddGroup(e,[0])}disposePopoutWindow(e){var t;const{group:i,referenceGroup:s,popoutGridview:n,isGroupAddedToDom:r,floatingBox:o,disposePopoutGridview:a,closeResult:l}=e;if(this.isDisposed){a();return}const h=!!(!((t=this._popoutWindowService)===null||t===void 0)&&t.entries.find(m=>m.gridview===n)),c=this.groups.filter(m=>n.element.contains(m.element)),u=c.includes(i),p=u&&c.length===1,f=[];if(h){for(const m of c)if(m!==i){this.movingLock(()=>{this.doRemoveGroup(m,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(m)});for(const g of m.panels)f.push({panel:g,from:m})}}if(u&&r&&this.getPanel(s.id)){const m=[...i.panels];this.movingLock(()=>cn({from:i,to:s}));for(const g of m)f.push({panel:g,from:i});s.api.isVisible||s.api.setVisible(!0),this.getPanel(i.id)&&this.doRemoveGroup(i,{skipPopoutAssociated:!0})}else if(u&&this.getPanel(i.id)){if(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,l.returnedGroup=i,!h){a();return}if(o&&p)this.addFloatingGroup(i,{height:o.height,width:o.width,position:o});else{this.doRemoveGroup(i,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),i.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(i,[0])});for(const m of i.panels)f.push({panel:m,from:i})}this.doSetGroupAndPanelActive(i)}a();for(const{panel:m,from:g}of f)this.fireDidMovePanel(m,g)}addFloatingGroup(e,t){this.mutation("float",()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!mt(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup")||e instanceof ln&&e.model.location.type==="edge")return;let i,s=[];if(e instanceof es){const l=e.group;i=this.createGroup(),this._onDidAddGroup.fire(i),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>i.model.openPanel(e,{skipSetGroupActive:!0})),s=[{panel:e,from:l}]}else{var n;i=e;const l=(n=this._popoutWindowService)===null||n===void 0?void 0:n.findReferenceGroupId(i),h=l?this.getPanel(l):void 0;typeof t?.skipRemoveGroup=="boolean"&&t.skipRemoveGroup||(h?(this.movingLock(()=>cn({from:e,to:h})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(h,{skipDispose:!0}),i=h,s=i.panels.map(c=>({panel:c,from:e}))):(this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}),s=i.panels.map(c=>({panel:c,from:i}))))}function r(){if(t?.position){const l={};return"left"in t.position?l.left=Math.max(t.position.left,0):"right"in t.position?l.right=Math.max(t.position.right,0):l.left=fi.left,"top"in t.position?l.top=Math.max(t.position.top,0):"bottom"in t.position?l.bottom=Math.max(t.position.bottom,0):l.top=fi.top,typeof t.width=="number"?l.width=Math.max(t.width,0):l.width=fi.width,typeof t.height=="number"?l.height=Math.max(t.height,0):l.height=fi.height,l}return{left:typeof t?.x=="number"?Math.max(t.x,0):fi.left,top:typeof t?.y=="number"?Math.max(t.y,0):fi.top,width:typeof t?.width=="number"?Math.max(t.width,0):fi.width,height:typeof t?.height=="number"?Math.max(t.height,0):fi.height}}const o=r(),a=this.createNestedGridview();a.addView(i,lt.Distribute,[0]),this.mountFloatingWindow(a,i,[i],o,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup,disableSmartGuides:t?.disableSmartGuides});for(const{panel:l,from:h}of s)this.fireDidMovePanel(l,h)}createNestedGridview(e="HORIZONTAL"){var t,i;return new eu(!0,this.options.hideBorders?{separatorBorder:"transparent"}:void 0,e,!1,(t=(i=this.options.theme)===null||i===void 0?void 0:i.gap)!==null&&t!==void 0?t:0)}mountFloatingWindow(e,t,i,s,n){var r,o,a,l,h,c,u,p,f;const m=mt(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup");if(!m)return;const g=((r=(o=n?.dragHandle)!==null&&o!==void 0?o:this.options.floatingGroupDragHandle)!==null&&r!==void 0?r:"titlebar")==="titlebar"?new rw(this,t):void 0,_=new Ya(se(se({container:(a=this._floatingOverlayHost)!==null&&a!==void 0?a:this.gridview.element,content:e.element,header:g?.element},s),{},{minimumInViewportWidth:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(l=(h=this.options.floatingGroupBounds)===null||h===void 0?void 0:h.minimumWidthWithinViewport)!==null&&l!==void 0?l:100,minimumInViewportHeight:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(c=(u=this.options.floatingGroupBounds)===null||u===void 0?void 0:u.minimumHeightWithinViewport)!==null&&c!==void 0?c:100,transformDragPosition:this._buildFloatingDragTransform(t,(p=n?.disableSmartGuides)!==null&&p!==void 0?p:!1),getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),T=(f=g?.element)!==null&&f!==void 0?f:t.element.querySelector(".dv-void-container");if(!T)throw new Error("dockview: failed to find drag handle");_.setupDrag(T,{inDragMode:typeof n?.inDragMode=="boolean"?n.inDragMode:!1});const D=m.add(t,_,e);D.addDisposables(_.onDidStartMoving(()=>this._onDidStartFloatingGroupDrag.fire(t)),_.onDidChangeEnd(()=>this._onDidEndFloatingGroupDrag.fire(t))),g&&(D.setTitleBar(g),D.addDisposables(g,xe.from(()=>D.setTitleBar(void 0)),g.onDragStart(E=>{this._onWillDragGroup.fire({nativeEvent:E,group:D.group})})));for(const E of i)E.model.location={type:"floating"};n?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation==="HORIZONTAL"&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation==="VERTICAL"&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i;super.updateOptions(e),this.reportMissingOptionModules(e),(t=this._floatingGroupService)===null||t===void 0||t.updateBounds(e),(i=this._rootDropTargetService)===null||i===void 0||i.setOptions(e);const s=this.options.disableDnd,n=this.options.dndStrategy;this._options=se(se({},this.options),e);const r=this.options.disableDnd,o=this.options.dndStrategy;if((s!==r||n!==o)&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e){var a;(a=this.headerActionsService)===null||a===void 0||a.refreshAll()}if("createWatermarkComponent"in e){var l;(l=this._watermarkService)===null||l===void 0||l.refresh();for(const c of this.groups)c.model.refreshWatermark()}if("tabGroupColors"in e||"tabGroupAccent"in e){var h;this._tabGroupColorPalette.setEntries((h=this._options.tabGroupColors)!==null&&h!==void 0?h:Fa),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!=="off";for(const c of this.groups)c.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}reportMissingOptionModules(e){cw(e,t=>this._moduleRegistry.has(t))}layout(e,t,i){var s;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,i),this._syncFloatingOverlayHost(),(s=this._moduleRegistry)===null||s===void 0||(s=s.services.floatingGroupService)===null||s===void 0||s.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;const e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),i=this._floatingOverlayHost;i.style.left=`${t.left-e.left}px`,i.style.top=`${t.top-e.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){const i=this._edgeGroupService;if(!i)throw new Error(Eu("EdgeGroup","api.addEdgeGroup"));if(i.has(e))throw new Error(`dockview: edge group already exists at position '${e}'`);return this.mutation("add",()=>{const s=this.createGroup({id:t.id});s.model.location={type:"edge",position:e},s.model.headerPosition=e;const n=s.model.onDidRemovePanel(()=>{s.model.isEmpty&&(i.isAutoReveal(s)?queueMicrotask(()=>{var r;s.model.isEmpty&&(!((r=this._edgeGroupService)===null||r===void 0)&&r.includes(s))&&this.removeEdgeGroup(e)}):this.setEdgeGroupCollapsed(s,!0))});return i.add(e,s,n),t.autoHide!==void 0&&i.setAutoHide(s,t.autoHide),t.autoReveal!==void 0&&i.setAutoReveal(s,t.autoReveal),this._onDidAddGroup.fire(s),this._shellManager.addEdgeView(e,t,s),s.api})}revealEdgeGroupWithData(e,t,i){const s=this._edgeGroupService;s&&this.mutation("add",()=>{var n;let r=s.get(e);r||(this.addEdgeGroup(e,{id:this.getNextGroupId(),autoReveal:!0,autoHide:i?.autoHide,collapsed:!0}),r=s.get(e)),r&&this.moveGroupOrPanel({from:{groupId:t.groupId,panelId:(n=t.panelId)!==null&&n!==void 0?n:void 0},to:{group:r,position:"center"}})})}getEdgeGroup(e){var t;return(t=this._edgeGroupService)===null||t===void 0||(t=t.get(e))===null||t===void 0?void 0:t.api}getEdgeGroupPanel(e){var t;return(t=this._edgeGroupService)===null||t===void 0?void 0:t.get(e)}pinEdgeGroup(e){var t;(t=mt(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.pinEdgeGroup"))===null||t===void 0||t.pin(e)}autoHideEdgeGroup(e){var t;(t=mt(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.autoHideEdgeGroup"))===null||t===void 0||t.autoHide(e)}peekEdgeGroup(e,t){var i;(i=mt(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.peekEdgeGroup"))===null||i===void 0||i.peek(e,t)}get overlayRoot(){return this.rootElement}getDropZoneRect(){return this.element.getBoundingClientRect()}getEdgeGroupExpandedSize(e){var t,i;return(t=(i=this._shellManager)===null||i===void 0?void 0:i.getEdgeGroupExpandedSize(e))!==null&&t!==void 0?t:0}repositionPanelOverlay(e,t,i){this.overlayRenderContainer.repositionPanelOverlay(e.api.id,t,i)}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){const t=mt(this._edgeGroupService,"EdgeGroup","api.removeEdgeGroup");if(!t)return;const i=t.get(e);if(!i)throw new Error(`dockview: no edge group exists at position '${e}'`);this.mutation("remove",()=>{for(const s of[...i.panels])this.removePanel(s,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),i.dispose(),this._groups.delete(i.id),this._onDidRemoveGroup.fire(i)})}setEdgeGroupCollapsed(e,t){var i;const s=(i=this._edgeGroupService)===null||i===void 0?void 0:i.findPositionOf(e);s&&this._shellManager.isEdgeGroupCollapsed(s)!==t&&(this._shellManager.setEdgeGroupCollapsed(s,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){var t;const i=(t=this._edgeGroupService)===null||t===void 0?void 0:t.findPositionOf(e);return i?this._shellManager.isEdgeGroupCollapsed(i):!1}isEdgeGroupPeeking(e){return this._peekingGroups.has(e)}setEdgeGroupPeeking(e,t){this._peekingGroups.has(e)!==t&&(t?this._peekingGroups.add(e):this._peekingGroups.delete(e),e.api._onDidPeekChange.fire({isPeeking:t}))}isEdgeGroupAutoHide(e){var t,i;const s=(t=this._edgeGroupService)===null||t===void 0?void 0:t.isAutoHide(e);if(s!==void 0)return s;const n=(i=this._edgeGroupService)===null||i===void 0?void 0:i.findPositionOf(e);return n===void 0?!1:Nb(this.options.autoHideEdgeGroups,n)}setEdgeGroupAutoHide(e,t){const i=this._edgeGroupService;i?.includes(e)&&(i.setAutoHide(e,t),this._onDidEdgeGroupAutoHideChange.fire(e))}updateDragAndDropState(){for(const e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}activateNext(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}const i=Ce(e.group.element),s=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupAndPanelActive(s)}activatePrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}const i=Ce(e.group.element),s=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;s&&this.doSetGroupAndPanelActive(s)}toJSON(){var e,t,i,s,n;const r=this.gridview.serialize(),o=this.panels.reduce((u,p)=>(u[p.id]=p.toJSON(),u),{}),a=(e=(t=this._floatingGroupService)===null||t===void 0?void 0:t.serialize())!==null&&e!==void 0?e:[],l=(i=(s=this._popoutWindowService)===null||s===void 0?void 0:s.serialize())!==null&&i!==void 0?i:[],h={grid:r,panels:o,activeGroup:(n=this.activeGroup)===null||n===void 0?void 0:n.id};a.length>0&&(h.floatingGroups=a),l.length>0&&(h.popoutGroups=l);const c=this._serializeEdgeGroups();return c&&(h.edgeGroups=c),h}_serializeEdgeGroups(){var e;if(!(!((e=this._edgeGroupService)===null||e===void 0)&&e.hasAny()))return;const t=this._shellManager.toJSON();for(const[i,s]of this._edgeGroupService.entries()){const n=t[i];if(!n)continue;if(this._edgeGroupService.isAutoReveal(s)&&s.model.isEmpty){delete t[i];continue}n.group=s.toJSON(),this._edgeGroupService.isAutoReveal(s)&&(n.autoReveal=!0);const r=this._edgeGroupService.isAutoHide(s);r!==void 0&&(n.autoHide=r)}return t}fromJSON(e,t){this.mutation("load",()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var i,s;if((i=this._popoutWindowService)===null||i===void 0||i.cancelPendingRestorations(),typeof e!="object"||e===null)throw new Error("dockview: serialized layout must be a non-null object");if(!e.grid||((s=e.grid.root)===null||s===void 0?void 0:s.type)!=="branch"||!Array.isArray(e.grid.root.data))throw new Error("dockview: root must be of type branch");const n=new Map,r=new Map,o=[],a=[],l=()=>{for(const E of a)try{E.dispose()}catch(S){console.error("dockview: failed to dispose a temporary group created for reuseExistingPanels",S)}a.length=0};if(t?.reuseExistingPanels){const E=Object.keys(e.panels);let S;const A=()=>{const k=this.createGroup(),L=this._groups.get(k.api.id);return this._groups.delete(k.api.id),a.push(xe.from(()=>{this.movingLock(()=>{for(const O of k.panels.slice())k.model.removePanel(O)}),L?.disposable.dispose(),k.dispose()})),k};try{for(const k of this.panels)if(E.includes(k.api.id)){n.set(k.api.id,k);let L;if(k.api.renderer==="always"&&k.api.isVisible)L=A();else{var h;(h=S)!==null&&h!==void 0||(S=A()),L=S}r.set(k.api.id,L),o.push({panel:k,temporaryGroup:L})}this.movingLock(()=>{o.forEach(({panel:k,temporaryGroup:L})=>{this.moveGroupOrPanel({from:{groupId:k.api.group.api.id,panelId:k.api.id},to:{group:L,position:"center"},keepEmptyGroups:!0})})}),this.clear()}catch(k){throw l(),k}}else this.clear();const{grid:c,panels:u,activeGroup:p}=e;try{var f,m,g,_,T;const E=this.width,S=this.height,A=L=>{const{id:O,locked:z,hideHeader:N,headerPosition:I,views:C,activeView:v}=L;if(typeof O!="string")throw new TypeError("dockview: group id must be of type string");const y=this.createGroup({id:O,locked:!!z,hideHeader:!!N,headerPosition:I});this._onDidAddGroup.fire(y);const x=[],b=C.filter(R=>u[R]);for(const R of b){const M=n.get(R),W=r.get(R);if(W&&M)this.movingLock(()=>{W.model.removePanel(M)}),x.push(M),M.updateFromStateModel(u[R]);else{const B=this._deserializer.fromJSON(u[R],y);x.push(B)}}for(const R of x){const M=typeof v=="string"&&v===R.id;n.has(R.api.id)?this.movingLock(()=>{y.model.openPanel(R,{skipSetActive:!M,skipSetGroupActive:!0})}):y.model.openPanel(R,{skipSetActive:!M,skipSetGroupActive:!0})}return L.tabGroups&&L.tabGroups.length>0&&y.model.restoreTabGroups(L.tabGroups),!y.activePanel&&y.panels.length>0&&y.model.openPanel(y.panels[y.panels.length-1],{skipSetGroupActive:!0}),y};this.gridview.deserialize(c,{fromJSON:L=>A(L.data)}),this._layoutFromShell(E,S),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,u,n,r),this.deserializeFloatingWindows((f=e.floatingGroups)!==null&&f!==void 0?f:[],A);const k=this.deserializePopoutWindows((m=e.popoutGroups)!==null&&m!==void 0?m:[],A);if((g=this._popoutWindowService)===null||g===void 0||g.finishRestoration(k),(_=this._floatingGroupService)===null||_===void 0||_.constrainBounds(),typeof p=="string"){const L=this.getPanel(p);L&&this.doSetGroupAndPanelActive(L)}(T=this._watermarkService)===null||T===void 0||T.update()}catch(E){var D;console.error("dockview: failed to deserialize layout. Reverting changes",E);for(const S of this.groups)for(const A of S.panels)this.removePanel(A,{removeEmptyGroup:!1,skipDispose:!1});for(const S of this.groups)S.dispose(),this._groups.delete(S.id),this._onDidRemoveGroup.fire(S);throw(D=this._floatingGroupService)===null||D===void 0||D.disposeAll(),this.clear(),E}finally{l()}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){const i=this.createNestedGridview(e.orientation),s=[];return i.deserialize(e,{fromJSON:n=>{const r=t(n.data);return s.push(r),r}}),{gridview:i,members:s}}deserializeEdgeGroups(e,t,i,s){const n=mt(this._edgeGroupService,"EdgeGroup","fromJSON edge restoration");if(n){for(const o of["top","bottom","left","right"]){const a=e[o];if(a&&!n.has(o)){var r;const l=a.group,h=(r=l?.id)!==null&&r!==void 0?r:`${o}-group`;this.addEdgeGroup(o,{id:h,autoReveal:a.autoReveal,autoHide:a.autoHide,minimumSize:a.minimumSize,maximumSize:a.maximumSize,collapsedSize:a.collapsedSize})}}for(const[o,a]of n.entries()){const l=e[o],h=l?.group;if(h){const{views:c,activeView:u}=h,p=[];for(const f of c){if(!t[f])continue;const m=i.get(f),g=s.get(f);if(g&&m)this.movingLock(()=>{g.model.removePanel(m)}),p.push(m),m.updateFromStateModel(t[f]);else{const _=this._deserializer.fromJSON(t[f],a);p.push(_)}}for(const f of p){const m=u===f.id;i.has(f.api.id)?this.movingLock(()=>{a.model.openPanel(f,{skipSetActive:!m,skipSetGroupActive:!0})}):a.model.openPanel(f,{skipSetActive:!m,skipSetGroupActive:!0})}h.tabGroups&&h.tabGroups.length>0&&a.model.restoreTabGroups(h.tabGroups),!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(const i of e){const{data:s,grid:n,position:r}=i;if(n){const{gridview:o,members:a}=this.deserializeNestedGridview(n,t);if(a.length===0)continue;this.mountFloatingWindow(o,a[0],a,r,{inDragMode:!1})}else if(s){const o=t(s);this.addFloatingGroup(o,{position:r,width:r.width,height:r.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){const i=e.length>0?mt(this._popoutWindowService,"PopoutWindow","fromJSON popout restoration"):this._popoutWindowService;return i?e.flatMap((s,n)=>{const{data:r,grid:o,position:a,gridReferenceGroup:l,url:h}=s;let c,u=[];if(o){const f=this.deserializeNestedGridview(o,t);if(c=f.gridview,u=f.members,u.length===0)return c.dispose(),[]}const p=o?u[0]:t(r);return i.scheduleRestoration(n*100,()=>{this.addPopoutGroup(p,{position:a??void 0,overridePopoutGroup:l?p:void 0,overridePopoutGridview:c,referenceGroup:l?this.getPanel(l):void 0,popoutUrl:h})},()=>{for(const f of u.length>0?u:[p])if(!this.isDisposed&&this._groups.has(f.id)&&f.element.parentElement===null){for(const m of[...f.panels])this.removePanel(m,{removeEmptyGroup:!1});f.dispose(),this._groups.delete(f.id),this._onDidRemoveGroup.fire(f)}})}):[]}clear(){this.mutation("clear",()=>this._doClear())}_doClear(){const e=Array.from(this._groups.values()).map(s=>s.value),t=!!this.activeGroup;for(const s of e){var i;if(!((i=this._edgeGroupService)===null||i===void 0)&&i.includes(s)){const n=[...s.panels];for(const r of n)this.removePanel(r,{removeEmptyGroup:!1});continue}this.removeGroup(s,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation("remove",()=>{for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}})}addPanel(e){return this.mutation("add",()=>this._doAddPanel(e))}_doAddPanel(e){if(this.panels.some(c=>c.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const i={width:e.initialWidth,height:e.initialHeight};let s;const n=c=>!!e.inactive&&c.model.size>0;if(e.position)if(Lb(e.position)){const c=typeof e.position.referencePanel=="string"?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(s=e.position.index,!c){var r;const u=typeof e.position.referencePanel=="string"?e.position.referencePanel:(r=e.position.referencePanel)===null||r===void 0?void 0:r.id;throw new Error(`dockview: referencePanel '${u}' does not exist`)}t=this.findGroup(c)}else if(Mb(e.position)){var o;if(t=typeof e.position.referenceGroup=="string"?(o=this._groups.get(e.position.referenceGroup))===null||o===void 0?void 0:o.value:e.position.referenceGroup,s=e.position.index,!t){var a;const c=typeof e.position.referenceGroup=="string"?e.position.referenceGroup:(a=e.position.referenceGroup)===null||a===void 0?void 0:a.id;throw new Error(`dockview: referenceGroup '${c}' does not exist`)}}else{const c=this.orthogonalize(th(e.position.direction)),u=this.createPanel(e,c);return c.model.openPanel(u,{skipSetActive:n(c),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(c),c.api.setSize({height:i?.height,width:i?.width}),u}else t=this.activeGroup;let l;if(t){var h;const c=zn(((h=e.position)===null||h===void 0?void 0:h.direction)||"within");if(e.floating){const u=this.createGroup();this._onDidAddGroup.fire(u);const p=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(u,se(se({},p),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,u),u.model.openPanel(l,{skipSetActive:n(u),skipSetGroupActive:e.inactive,index:s})}else if(t.api.location.type==="floating"||t.api.location.type==="edge"||c==="center")l=this.createPanel(e,t),t.model.openPanel(l,{skipSetActive:n(t),skipSetGroupActive:e.inactive,index:s}),t.api.setSize({width:i?.width,height:i?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{const u=Ce(t.element),p=Dt(this.gridview.orientation,u,c),f=this.createGroupAtLocation(p,this.orientationAtLocation(p)==="VERTICAL"?i?.height:i?.width);l=this.createPanel(e,f),f.model.openPanel(l,{skipSetActive:n(f),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(f)}}else if(e.floating){const c=this.createGroup();this._onDidAddGroup.fire(c);const u=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(c,se(se({},u),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,c),c.model.openPanel(l,{skipSetActive:n(c),skipSetGroupActive:e.inactive,index:s})}else{const c=this.createGroupAtLocation([0],this.gridview.orientation==="VERTICAL"?i?.height:i?.width);l=this.createPanel(e,c),c.model.openPanel(l,{skipSetActive:n(c),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(c)}return l}removePanel(e,t){this.mutation("remove",()=>{var i;return this._doRemovePanel(e,{removeEmptyGroup:(i=t?.removeEmptyGroup)!==null&&i!==void 0?i:!0,skipDispose:t?.skipDispose,skipSetActiveGroup:t?.skipSetActiveGroup})})}_doRemovePanel(e,t){const i=e.group;if(!i)throw new Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),i.size===0&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new sw}addGroup(e){return this.mutation("add",()=>this._doAddGroup(e))}_doAddGroup(e){if(e){let n;if(Ob(e)){var t;const c=typeof e.referencePanel=="string"?this.panels.find(p=>p.id===e.referencePanel):e.referencePanel,u=typeof e.referencePanel=="string"?e.referencePanel:(t=e.referencePanel)===null||t===void 0?void 0:t.id;if(!c)throw new Error(`dockview: reference panel ${u} does not exist`);if(n=this.findGroup(c),!n)throw new Error(`dockview: reference group for reference panel ${u} does not exist`)}else if(Gb(e)){var i;if(n=typeof e.referenceGroup=="string"?(i=this._groups.get(e.referenceGroup))===null||i===void 0?void 0:i.value:e.referenceGroup,!n){var s;const c=typeof e.referenceGroup=="string"?e.referenceGroup:(s=e.referenceGroup)===null||s===void 0?void 0:s.id;throw new Error(`dockview: reference group ${c} does not exist`)}}else{const c=this.orthogonalize(th(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(c),c}const r=zn(e.direction||"within"),o=Ce(n.element),a=Dt(this.gridview.orientation,o,r),l=this.createGroup(e),h=this.getLocationOrientation(a)==="VERTICAL"?e.initialHeight:e.initialWidth;return this.doAddGroup(l,a,h),e.skipSetActive||this.doSetGroupAndPanelActive(l),l}else{const n=this.createGroup(e);return this.doAddGroup(n),this.doSetGroupAndPanelActive(n),n}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation==="HORIZONTAL"?"HORIZONTAL":"VERTICAL"}removeGroup(e,t){this.mutation("remove",()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s){const r=this.nestedWindowMembers(e);return r.length<=1?!1:(s.gridview.remove(e),s.group===e&&s.setAnchorGroup(r.find(o=>o!==e)),!0)}const n=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);if(n){const r=this.nestedWindowMembers(e);return r.length<=1?!1:(n.gridview.remove(e),n.popoutGroup===e&&n.setAnchorGroup(r.find(o=>o!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){const i=Array.from(this._groups.values());this.doSetGroupAndPanelActive(i.length>0?i[0].value:void 0)}}doRemoveGroup(e,t){var i;if(!((i=this._edgeGroupService)===null||i===void 0)&&i.includes(e))return e;const s=[...e.panels];if(!t?.skipDispose)for(const c of s){var n;this.removePanel(c,{removeEmptyGroup:!1,skipDispose:(n=t?.skipDispose)!==null&&n!==void 0?n:!1})}const r=this.activePanel;if(e.api.location.type==="floating"){var o;const c=(o=this._floatingGroupService)===null||o===void 0?void 0:o.findByGroup(e);if(!c)throw new Error("dockview: failed to find floating group");return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),c.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type==="popout"){var a,l;const c=(a=this._popoutWindowService)===null||a===void 0?void 0:a.findByGroup(e);if(!c)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){const p=c.referenceGroup?this.getPanel(c.referenceGroup):void 0;p?.panels.length===0&&this.removeGroup(p)}c.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(l=this._popoutWindowService)===null||l===void 0||l.remove(c);const u=c.disposable.dispose();return!t?.skipPopoutReturn&&u&&(this.doAddGroup(u,[0]),this.doSetGroupAndPanelActive(u)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),c.popoutGroup}if(!this.gridview.element.contains(e.element)){if(!t?.skipDispose){const c=this._groups.get(e.id);c?.disposable.dispose(),this.disposeGroupRecord(e)}return this.activateFallbackGroupIfRemoved(e,t?.skipActive),e}const h=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==r&&this.fireActivePanelChange(this.activePanel),h}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{var e,t;this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(const i of(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.entries)!==null&&e!==void 0?e:[])i.overlayRenderContainer.updateAllPositions()})}movingLock(e){const t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){const i=this.openMutation(e);try{return t()}finally{i()}}mutationAsync(e,t){var i=this;return Iu(function*(){const s=i.openMutation(e);try{return yield t()}finally{s()}})()}openMutation(e){const t=this._origin;return this._mutationDepth===0&&this._onWillMutateLayout.fire({kind:e,origin:t}),this._mutationDepth++,()=>{this._mutationDepth--,this._mutationDepth===0&&(this.flushLocationChanges(),this._onDidMutateLayout.fire({kind:e,origin:t}))}}deferLocationChange(e,t){if(this._mutationDepth===0){t();return}this._pendingLocationChanges.set(e,t)}flushLocationChanges(){if(this._pendingLocationChanges.size===0)return;const e=Array.from(this._pendingLocationChanges.values());this._pendingLocationChanges.clear();for(const t of e)t()}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();const i=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=i}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}fireDidMovePanel(e,t){this._onDidMovePanel.fire({panel:e,from:t,to:e.group})}moveGroupOrPanel(e){this.mutation("move",()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){var t;const i=e.to.group,s=e.from.groupId,n=e.from.panelId,r=e.to.position,o=e.to.index,a=s?(t=this._groups.get(s))===null||t===void 0?void 0:t.value:void 0;if(!a)throw new Error(`dockview: Failed to find group id ${s}`);if(n===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:a,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:r,destinationIndex:o,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:a},to:{group:i,position:r},skipSetActive:e.skipSetActive});return}if(!r||r==="center"){const h=this.movingLock(()=>a.model.removePanel(n,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!h)throw new Error(`dockview: No panel with id ${n}`);!e.keepEmptyGroups&&a.model.size===0&&this.doRemoveGroup(a,{skipActive:!0});const c=i.model.size===0;this.movingLock(()=>{var u;return i.model.openPanel(h,{index:o,skipSetActive:((u=e.skipSetActive)!==null&&u!==void 0?u:!1)&&!c,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this.fireDidMovePanel(h,a)}else{const h=this.getGridviewForGroup(i),c=Ce(i.element),u=Dt(h.orientation,c,r);if(a.size<2){const[p,f]=ri(u);if(a.api.location.type==="grid"&&h===this.gridview){const[T,D]=ri(Ce(a.element));if(Jc(T,p)){this.gridview.moveView(T,D,f),this.fireDidMovePanel(this.getGroupPanel(n),a);return}}if(a.api.location.type==="popout"&&this.nestedWindowMembers(a).length<=1){var l;const T=(l=this._popoutWindowService)===null||l===void 0?void 0:l.findByGroup(a);if(!T)return;const D=this.movingLock(()=>T.popoutGroup.model.removePanel(T.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const E=Dt(h.orientation,Ce(i.element),r),S=this.createGroupAtLocation(E,void 0,void 0,h);this.movingLock(()=>S.model.openPanel(D,{skipSetActive:!0})),this.doSetGroupAndPanelActive(S),this.fireDidMovePanel(this.getGroupPanel(n),a);return}if(a.api.location.type==="edge"){const T=this.movingLock(()=>a.model.removePanel(n,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!T)throw new Error(`dockview: No panel with id ${n}`);const D=this.createGroupAtLocation(u,void 0,void 0,h);this.movingLock(()=>D.model.openPanel(T,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(D),this.fireDidMovePanel(T,a);return}const m=this.movingLock(()=>this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0})),g=Ce(i.element),_=Dt(h.orientation,g,r);this.movingLock(()=>this.doAddGroup(m,_,void 0,h)),this.setGroupLocationForRoot(m,h),this.doSetGroupAndPanelActive(m),this.fireDidMovePanel(this.getGroupPanel(n),a)}else{const p=this.movingLock(()=>a.model.removePanel(n,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!p)throw new Error(`dockview: No panel with id ${n}`);const f=Dt(h.orientation,c,r),m=this.createGroupAtLocation(f,void 0,void 0,h);this.movingLock(()=>m.model.openPanel(p,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(m),this.fireDidMovePanel(p,a)}}}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:s,destinationTarget:n,destinationIndex:r}=e,o=t.model.getTabGroups().find(_=>_.id===i);if(!o||o.panelIds.length===0)return;const a=o.label,l=o.color,h=o.collapsed,c=o.componentParams,u=[...o.panelIds],p=n&&n!=="center"?Ce(s.element):void 0,f=this.movingLock(()=>u.map(_=>t.model.removePanel(_,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(_=>_!==void 0));if(f.length===0)return;const m=_=>{this.movingLock(()=>{for(const D of f)_.model.openPanel(D,{index:r,skipSetActive:!0,skipSetGroupActive:!0})});const T=_.model.createTabGroup({label:a,color:l,collapsed:h,componentParams:c});for(const D of f)_.model.addPanelToTabGroup(T.id,D.id);e.skipSetActive||this.doSetGroupAndPanelActive(_);for(const D of f)this.fireDidMovePanel(D,t)};let g;if(!n||n==="center"||!p)g=s;else{const _=Dt(this.gridview.orientation,p,n);g=this.createGroupAtLocation(_)}!e.keepEmptyGroups&&t.model.size===0&&t!==g&&this.doRemoveGroup(t,{skipActive:!0}),m(g)}moveGroup(e){this.mutation("move",()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation("maximize",()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation("maximize",()=>super.exitMaximizedGroup())}_doMoveGroup(e){var t;const i=e.from.group,s=e.to.group,n=e.to.position;let r=i,o;if(n==="center"){const c=i.activePanel,u=i.model.getTabGroups().map(f=>({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams,panelIds:[...f.panelIds]})),p=this.movingLock(()=>[...i.panels].map(f=>i.model.removePanel(f.id,{skipSetActive:!0})));i?.model.size===0&&this.doRemoveGroup(i,{skipActive:!0}),this.movingLock(()=>{for(const f of p)s.model.openPanel(f,{skipSetActive:f!==c,skipSetGroupActive:!0})}),o=p;for(const f of u){const m=s.model.createTabGroup({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams});for(const g of f.panelIds)s.model.addPanelToTabGroup(m.id,g)}e.skipSetActive!==!0?this.doSetGroupAndPanelActive(s):this.activePanel||this.doSetGroupAndPanelActive(s)}else{if(i.api.location.type==="edge"){const c=i.activePanel,u=i.model.getTabGroups().map(f=>({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams,panelIds:[...f.panelIds]})),p=this.movingLock(()=>[...i.panels].map(f=>i.model.removePanel(f.id,{skipSetActive:!0})));r=this.createGroup(),this._onDidAddGroup.fire(r),this.movingLock(()=>{for(const f of p)r.model.openPanel(f,{skipSetActive:f!==c,skipSetGroupActive:!0})});for(const f of u){const m=r.model.createTabGroup({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams});for(const g of f.panelIds)r.model.addPanelToTabGroup(m.id,g)}}else switch(i.api.location.type){case"grid":this.gridview.removeView(Ce(i.element));break;case"floating":{var a;const c=(a=this._floatingGroupService)===null||a===void 0?void 0:a.findByGroup(i);if(!c)throw new Error("dockview: failed to find floating group");this.detachFromNestedWindow(i)||c.dispose();break}case"popout":{var l,h;const c=(l=this._popoutWindowService)===null||l===void 0?void 0:l.findByGroup(i);if(!c)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(i))break;if((h=this._popoutWindowService)===null||h===void 0||h.remove(c),c.referenceGroup){const u=this.getPanel(c.referenceGroup);u&&!u.api.isVisible&&this.doRemoveGroup(u,{skipActive:!0})}c.window.dispose();break}}if(s.api.location.type==="grid"||s.api.location.type==="floating"||s.api.location.type==="popout"){const c=this.getGridviewForGroup(s),u=Ce(s.element),p=Dt(c.orientation,u,n);let f;switch(c.orientation){case"VERTICAL":f=u.length%2==0?i.api.width:i.api.height;break;case"HORIZONTAL":f=u.length%2==0?i.api.height:i.api.width;break}c.addView(r,f,p),this.setGroupLocationForRoot(r,c)}}if(((t=o)!==null&&t!==void 0?t:r.panels).forEach(c=>{this.fireDidMovePanel(c,i)}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){const c=s??i;this.doSetGroupAndPanelActive(c)}else r!==i&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(r)}doSetGroupActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}doSetGroupAndPanelActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){var t;(t=e)!==null&&t!==void 0||(e={});let i=e?.id;if(i&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=this.nextGroupId.next();this._groups.has(i);)i=this.nextGroupId.next();const s=new ln(this,i,e);if(s.init({params:{},accessor:this}),!this._groups.has(s.id)){const n=new te(s.model.onTabDragStart(r=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDragPanel(r)}),s.model.onGroupDragStart(r=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDragGroup(r)}),s.model.onMove(r=>{const{groupId:o,itemId:a,target:l,index:h,tabGroupId:c}=r;this.moveGroupOrPanel({from:{groupId:o,panelId:a,tabGroupId:c},to:{group:s,position:l,index:h}})}),s.model.onDidDrop(r=>{this._onDidDrop.fire(r)}),s.model.onWillDrop(r=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDrop(r)}),s.model.onWillShowOverlay(r=>{var o;if(this.options.disableDnd){r.preventDefault();return}(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillShowOverlay(r)}),s.model.onUnhandledDragOver(r=>{this._onUnhandledDragOver.fire(r)}),s.model.onDidAddPanel(r=>{this._moving||this._onDidAddPanel.fire(r.panel)}),s.model.onDidRemovePanel(r=>{this._moving||this._onDidRemovePanel.fire(r.panel)}),s.model.onDidActivePanelChange(r=>{var o;this._moving||r.panel===this.activePanel&&((o=this._onDidActivePanelChange.value)===null||o===void 0?void 0:o.panel)!==r.panel&&this.fireActivePanelChange(r.panel)}),Tt.any(s.model.onDidPanelTitleChange,s.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(s.id,{value:s,disposable:n})}return s.initialize(),s}createPanel(e,t){var i,s,n;const r=e.component,o=(i=e.tabComponent)!==null&&i!==void 0?i:this.options.defaultTabComponent,a=new Pu(this,e.id,r,o),l=new es(e.id,r,o,this,this._api,t,a,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:(s=e.title)!==null&&s!==void 0?s:e.id,params:(n=e?.params)!==null&&n!==void 0?n:{}}),l}createGroupAtLocation(e,t,i,s=this.gridview){const n=this.createGroup(i);return this.doAddGroup(n,e,t,s),this.setGroupLocationForRoot(n,s),n}setGroupLocationForRoot(e,t){var i;const s=(i=this._popoutWindowService)===null||i===void 0?void 0:i.entries.find(n=>n.gridview===t);if(s){e.model.renderContainer!==s.overlayRenderContainer&&(e.model.renderContainer=s.overlayRenderContainer),e.model.dropTargetContainer=s.dropTargetContainer,e.model.location={type:"popout",getWindow:s.getWindow,popoutUrl:s.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:"grid"}:{type:"floating"}}getGridviewForGroup(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s)return s.gridview;const n=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);return n?n.gridview:this.gridview}nestedWindowMembers(e){const t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(i=>t.element.contains(i.element))}findGroup(e){var t;return(t=Array.from(this._groups.values()).find(i=>i.value.model.containsPanel(e)))===null||t===void 0?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:Ft(t)}updateTheme(){var e,t,i,s,n,r,o,a;const l=(e=this._options.theme)!==null&&e!==void 0?e:ew;(t=this._shellThemeClassnames)===null||t===void 0||t.setClassNames(l.className);const h=(i=l.gap)!==null&&i!==void 0?i:0;this.gridview.margin=h;for(const f of this.floatingGroups)f.gridview.margin=h;for(const f of(s=(n=this._popoutWindowService)===null||n===void 0?void 0:n.entries)!==null&&s!==void 0?s:[])f.gridview.margin=h;if((r=this._shellManager)===null||r===void 0||r.updateTheme(h,(o=l.edgeGroupCollapsedSize)!==null&&o!==void 0?o:35),l.dndOverlayBorder===void 0){var c;this.element.style.removeProperty("--dv-drag-over-border"),(c=this._shellManager)===null||c===void 0||c.element.style.removeProperty("--dv-drag-over-border")}else{var u;this.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder),(u=this._shellManager)===null||u===void 0||u.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder)}l.dndOverlayMounting==="absolute"?this.rootDropTargetContainer.disabled=!1:this.rootDropTargetContainer.disabled=!0;const p=((a=l.tabGroupIndicator)!==null&&a!==void 0?a:"wrap")==="none";Y(this.element,"dv-tab-group-indicator-none",p),this._shellManager&&Y(this._shellManager.element,"dv-tab-group-indicator-none",p);for(const f of this.groups)f.model.updateTabGroups()}},Jw=class extends tu{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){var i;super(e,{proportionalLayout:(i=t.proportionalLayout)!==null&&i!==void 0?i:!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new G,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new G,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(s=>{this._onDidAddGroup.fire(s)}),this.onDidRemove(s=>{this._onDidRemoveGroup.fire(s)}),this.onDidActiveChange(s=>{this._onDidActiveGroupChange.fire(s)}))}updateOptions(e){super.updateOptions(e);const t=typeof e.orientation=="string"&&this.gridview.orientation!==e.orientation;this._options=se(se({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){var e;return{grid:this.gridview.serialize(),activePanel:(e=this.activeGroup)===null||e===void 0?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(Ce(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const s=[],n=this.width,r=this.height;if(this.gridview.deserialize(t,{fromJSON:o=>{const{data:a}=o,l=this.options.createComponent({id:a.id,name:a.component});return s.push(()=>l.init({params:a.params,minimumWidth:a.minimumWidth,maximumWidth:a.maximumWidth,minimumHeight:a.minimumHeight,maximumHeight:a.maximumHeight,priority:a.priority,snap:!!a.snap,accessor:this,isVisible:o.visible})),this._onDidAddGroup.fire(l),this.registerPanel(l),l}}),this.layout(n,r,!0),s.forEach(o=>o()),typeof i=="string"){const o=this.getPanel(i);o&&this.doSetGroupActive(o)}}catch(s){for(const n of this.groups)n.dispose(),this._groups.delete(n.id),this._onDidRemoveGroup.fire(n);throw this.clear(),s}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const i of t)i.disposable.dispose(),this.doRemoveGroup(i.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;const s=(i=this._groups.get(t.reference))===null||i===void 0?void 0:i.value;if(!s)throw new Error(`reference group ${t.reference} does not exist`);const n=zn(t.direction);if(n==="center")throw new Error(`${n} not supported as an option`);const r=Ce(s.element),o=Dt(this.gridview.orientation,r,n),a=this.gridview.remove(e);this.doAddGroup(a,o,t.size)}addPanel(e){var t,i,s;let n=(t=e.location)!==null&&t!==void 0?t:[0];if(!((i=e.position)===null||i===void 0)&&i.referencePanel){var r;const a=(r=this._groups.get(e.position.referencePanel))===null||r===void 0?void 0:r.value;if(!a)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const l=zn(e.position.direction);if(l==="center")throw new Error(`${l} not supported as an option`);{const h=Ce(a.element);n=Dt(this.gridview.orientation,h,l)}}const o=this.options.createComponent({id:e.id,name:e.component});return o.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(o,n,e.size),this.registerPanel(o),this.doSetGroupActive(o),o}registerPanel(e){const t=new te(e.api.onDidFocusChange(i=>{i.isFocused&&this._groups.forEach(s=>{const n=s.value;n.setActive(n===e)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const n=Ce(e.element),[r,o]=ri(Dt(this.gridview.orientation,n,i)),[a,l]=ri(Ce(s.element));if(Jc(a,r)){this.gridview.moveView(a,l,o);return}const h=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),c=Ce(e.element),u=Dt(this.gridview.orientation,c,i);this.doAddGroup(h,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},Zw=class extends Ba{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new te(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(t=>this._onDidAddView.fire(t)),this._splitview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation==="HORIZONTAL"?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation==="HORIZONTAL"?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new Ge,this._panels=new Map,this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new G,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new rr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.splitview=new Hi(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){if("className"in e){var t;this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:"")}if("disableResizing"in e){var i;this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1}typeof e.orientation=="string"&&(this.splitview.orientation=e.orientation),this._options=se(se({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){const i=this.panels.indexOf(e);this.splitview.setViewVisible(i,t)}setActive(e,t){this._activePanel=e,this.panels.filter(i=>i!==e).forEach(i=>{i.api._onDidActiveChange.fire({isActive:!1}),t||i.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){const i=this._panels.get(e.id);if(!i)throw new Error(`unknown splitview panel ${e.id}`);i.dispose(),this._panels.delete(e.id);const s=this.panels.indexOf(e);this.splitview.removeView(s,t).dispose();const n=this.panels;n.length>0&&this.setActive(n[n.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:(t=e.params)!==null&&t!==void 0?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const s=typeof e.size=="number"?e.size:lt.Distribute,n=typeof e.index=="number"?e.index:void 0;return this.splitview.addView(i,s,n),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,s]=this.splitview.orientation==="HORIZONTAL"?[e,t]:[t,e];this.splitview.layout(i,s)}doAddView(e){const t=e.api.onDidFocusChange(i=>{i.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((t,i)=>({size:this.splitview.getViewSize(i),data:t.toJSON(),snap:!!t.snap,priority:t.priority})),activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:n}=e,r=[],o=this.width,a=this.height;if(this.splitview=new Hi(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map(l=>{const h=l.data;if(this._panels.has(h.id))throw new Error(`panel ${h.id} already exists`);const c=this.options.createComponent({id:h.id,name:h.component});return r.push(()=>{var u;c.init({params:(u=h.params)!==null&&u!==void 0?u:{},minimumSize:h.minimumSize,maximumSize:h.maximumSize,snap:l.snap,priority:l.priority,accessor:this})}),c.orientation=i,this.doAddView(c),setTimeout(()=>{this._onDidAddView.fire(c)},0),{size:l.size,view:c}})}}),this.layout(o,a),r.forEach(l=>l()),typeof n=="string"){const l=this.getPanel(n);l&&this.setActive(l)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,lt.Distribute,!0).dispose()}dispose(){for(const t of this._panels.values())t.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();this.element.remove(),super.dispose()}},uh=class extends te{get element(){return this._element}constructor(){super(),this._expandedIcon=Db(),this._collapsedIcon=gu(),this.disposable=new Ge,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="dv-default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dv-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(Z(this._element,"click",()=>{var e;(e=this.apiRef.api)===null||e===void 0||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){var e;const t=!!(!((e=this.apiRef.api)===null||e===void 0)&&e.isExpanded);Y(this._expander,"collapsed",!t),t?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}};const Qw=ja(),ph=22,fh=0,mh=Number.MAX_SAFE_INTEGER;var gh=class extends wb{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},e0=class extends Ba{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new te(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(t=>this._onDidAddView.fire(t)),this._paneview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation==="HORIZONTAL"?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation==="HORIZONTAL"?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=Qw.next(),this._disposable=new Ge,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new G,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height="100%",this.element.style.width="100%",this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new rr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.paneview=new Ql(this.element,{orientation:"VERTICAL"}),this.addDisposables(this._disposable)}setVisible(e,t){const i=this.panels.indexOf(e);this.paneview.setViewVisible(i,t)}focus(){}updateOptions(e){if("className"in e){var t;this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:"")}if("disableAutoResizing"in e){var i;this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1}this._options=se(se({},this.options),e)}addPanel(e){var t,i,s;const n=this.options.createComponent({id:e.id,name:e.component});let r;e.headerComponent&&this.options.createHeaderComponent&&(r=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),(t=r)!==null&&t!==void 0||(r=new uh);const o=new gh({id:e.id,component:e.component,headerComponent:e.headerComponent,header:r,body:n,orientation:"VERTICAL",isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(i=e.headerSize)!==null&&i!==void 0?i:ph,minimumBodySize:fh,maximumBodySize:mh});this.doAddPanel(o);const a=typeof e.size=="number"?e.size:lt.Distribute,l=typeof e.index=="number"?e.index:void 0;return o.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new $s(this),accessor:this}),this.paneview.addPane(o,a,l),o.orientation=this.paneview.orientation,o}removePanel(e){const t=this.panels.indexOf(e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){const[i,s]=this.paneview.orientation==="HORIZONTAL"?[e,t]:[t,e];this.paneview.layout(i,s)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return{views:this.paneview.getPanes().map((i,s)=>{const n=this.paneview.getViewCachedVisibleSize(s),r=typeof n=="number";return se({size:r?n:this.paneview.getViewSize(s),data:i.toJSON(),minimumSize:t(i.minimumBodySize),maximumSize:e(i.maximumBodySize),headerSize:i.headerSize,expanded:i.isExpanded()},r?{visible:!1}:{})}),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,s=[],n=this.width,r=this.height;this.paneview=new Ql(this.element,{orientation:"VERTICAL",descriptor:{size:i,views:t.map(o=>{var a,l,h,c;const u=o.data,p=this.options.createComponent({id:u.id,name:u.component});let f;u.headerComponent&&this.options.createHeaderComponent&&(f=this.options.createHeaderComponent({id:u.id,name:u.headerComponent})),(a=f)!==null&&a!==void 0||(f=new uh);const m=new gh({id:u.id,component:u.component,headerComponent:u.headerComponent,header:f,body:p,orientation:"VERTICAL",isExpanded:!!o.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(l=o.headerSize)!==null&&l!==void 0?l:ph,minimumBodySize:(h=o.minimumSize)!==null&&h!==void 0?h:fh,maximumBodySize:(c=o.maximumSize)!==null&&c!==void 0?c:mh});return this.doAddPanel(m),s.push(()=>{var g;m.init({params:(g=u.params)!==null&&g!==void 0?g:{},minimumBodySize:o.minimumSize,maximumBodySize:o.maximumSize,title:u.title,isExpanded:!!o.expanded,containerApi:new $s(this),accessor:this}),m.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(m)},0),{size:o.size,view:m,visible:o.visible}})}}),this.layout(n,r),s.forEach(o=>o()),this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){const t=new te(e.onDidDrop(i=>{this._onDidDrop.fire(i)}),e.onUnhandledDragOver(i=>{this._onUnhandledDragOver.fire(i)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){const t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},t0=class extends Wa{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=typeof this._minimumSize=="function"?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e=typeof this._maximumSize=="function"?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new fu(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(i=>{const{isVisible:s}=i,{accessor:n}=this._params;n.setVisible(this,s)}),this.api.onActiveChange(()=>{const{accessor:i}=this._params;i.setActive(this)}),this.api.onDidConstraintsChangeInternal(i=>{(typeof i.minimumSize=="number"||typeof i.minimumSize=="function")&&(this._minimumSize=i.minimumSize),(typeof i.maximumSize=="number"||typeof i.maximumSize=="function")&&(this._maximumSize=i.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(i=>{this._onDidChange.fire({size:i.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){const[i,s]=this.orientation==="HORIZONTAL"?[e,t]:[t,e];super.layout(i,s)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return se(se({},super.toJSON()),{},{minimumSize:t(this.minimumSize),maximumSize:e(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function i0(e,t){return new Xw(e,t).api}function s0(e,t){return new su(new Zw(e,t))}function n0(e,t){return new nu(new Jw(e,t))}function r0(e,t){return new $s(new e0(e,t))}function Hs(e){"@babel/helpers - typeof";return Hs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hs(e)}function o0(e,t){if(Hs(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,t);if(Hs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function a0(e){var t=o0(e,"string");return Hs(t)=="symbol"?t:t+""}function l0(e,t,i){return(t=a0(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function vh(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),i.push.apply(i,s)}return i}function pt(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?vh(Object(i),!0).forEach(function(s){l0(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):vh(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}const Au=(e,t)=>{const[,i]=oe.useState(0),s=oe.useRef(e.componentProps);return oe.useImperativeHandle(t,()=>({update:n=>{s.current=pt(pt({},s.current),n),i(r=>r+1)}}),[]),oe.createElement(e.component,s.current)};Au.displayName="DockviewReactJsBridge";const h0=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),d0=oe.createContext({});var Yt=class{constructor(e,t,i,s,n){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=n,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=pt(pt({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!c0(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=oe.createElement(oe.forwardRef(Au),{component:this.component,componentProps:this.parameters,ref:s=>{this.componentInstance=s,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?oe.createElement(d0.Provider,{value:this.context},e):e,i=Pf.createPortal(t,this.parent,h0.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}};const lr=()=>{const[e,t]=oe.useState([]);return oe.useDebugValue(`Portal count: ${e.length}`),[e,oe.useCallback(i=>{t(n=>[...n,i]);let s=!1;return xe.from(()=>{if(s)throw new Error("invalid operation: resource already disposed");s=!0,t(n=>n.filter(r=>r!==i))})},[])]};function c0(e){return typeof e=="function"||!!e?.$$typeof}var _h=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Yt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}},bh=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Yt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},wh=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Yt(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,i,s;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(i=(s=this.parameters)===null||s===void 0?void 0:s.params)!==null&&i!==void 0?i:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},u0=class{get element(){return this._element}get part(){return this._part}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new Ge,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new te(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new Yt(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},p0=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Yt(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},yh=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new Yt(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},xh=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new Yt(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}};function Yi(e,t){return e?i=>new u0(e,t,i):void 0}const un="props.defaultTabComponent";function f0(e){return go.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const Ru=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[n,r]=lr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};go.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},go.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return;const a=pt({},e.tabComponents);e.defaultTabComponent&&(a[un]=e.defaultTabComponent);const l={createLeftHeaderActionComponent:Yi(e.leftHeaderActionsComponent,{addPortal:r}),createRightHeaderActionComponent:Yi(e.rightHeaderActionsComponent,{addPortal:r}),createPrefixHeaderActionComponent:Yi(e.prefixHeaderActionsComponent,{addPortal:r}),createComponent:f=>new _h(f.id,e.components[f.name],{addPortal:r}),createTabComponent(f){return new bh(f.id,a[f.name],{addPortal:r})},createWatermarkComponent:e.watermarkComponent?()=>new wh("watermark",e.watermarkComponent,{addPortal:r}):void 0,defaultTabComponent:e.defaultTabComponent?un:void 0,createContextMenuItemComponent:f=>{if(f.component)return new p0(f.id,f.component,{addPortal:r})}},h=f0(e);if(e.tabGroupChipComponent){const f=e.tabGroupChipComponent;h.createTabGroupChipComponent=()=>new yh(f,{addPortal:r})}if(e.groupDragGhostComponent){const f=e.groupDragGhostComponent;h.createGroupDragGhostComponent=()=>new xh(f,{addPortal:r})}const c=i0(i.current,pt(pt({},h),l)),{clientWidth:u,clientHeight:p}=i.current;return c.layout(u,p),e.onReady&&e.onReady({api:c}),s.current=c,()=>{s.current=void 0,c.dispose()}},[]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onDidDrop(l=>{e.onDidDrop&&e.onDidDrop(l)});return()=>{a.dispose()}},[e.onDidDrop]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onWillDrop(l=>{e.onWillDrop&&e.onWillDrop(l)});return()=>{a.dispose()}},[e.onWillDrop]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new yh(e.tabGroupChipComponent,{addPortal:r}):void 0})},[e.tabGroupChipComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new xh(e.groupDragGhostComponent,{addPortal:r}):void 0})},[e.groupDragGhostComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new _h(a.id,e.components[a.name],{addPortal:r})})},[e.components]),oe.useEffect(()=>{if(!s.current)return;const a=pt({},e.tabComponents);e.defaultTabComponent&&(a[un]=e.defaultTabComponent),s.current.updateOptions({defaultTabComponent:e.defaultTabComponent?un:void 0,createTabComponent(l){return new bh(l.id,a[l.name],{addPortal:r})}})},[e.tabComponents,e.defaultTabComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new wh("watermark",e.watermarkComponent,{addPortal:r}):void 0})},[e.watermarkComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createRightHeaderActionComponent:Yi(e.rightHeaderActionsComponent,{addPortal:r})})},[e.rightHeaderActionsComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createLeftHeaderActionComponent:Yi(e.leftHeaderActionsComponent,{addPortal:r})})},[e.leftHeaderActionsComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createPrefixHeaderActionComponent:Yi(e.prefixHeaderActionsComponent,{addPortal:r})})},[e.prefixHeaderActionsComponent]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},n)});Ru.displayName="DockviewComponent";var Sh=class extends t0{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new Yt(this.element,this.reactPortalStore,this.reactComponent,{params:(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{},api:this.api,containerApi:new su(this._params.accessor)})}};function m0(e){return oo.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const g0=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[n,r]=lr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};oo.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},oo.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return()=>{};const a=s0(i.current,pt(pt({},m0(e)),{createComponent:c=>new Sh(c.id,c.name,e.components[c.name],{addPortal:r})})),{clientWidth:l,clientHeight:h}=i.current;return a.layout(l,h),e.onReady&&e.onReady({api:a}),s.current=a,()=>{s.current=void 0,a.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new Sh(a.id,a.name,e.components[a.name],{addPortal:r})})},[e.components]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},n)});g0.displayName="SplitviewComponent";var Ch=class extends ku{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new Yt(this.element,this.reactPortalStore,this.reactComponent,{params:(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{},api:this.api,containerApi:new nu(this._params.accessor)})}};function v0(e){return uo.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const _0=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[n,r]=lr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};uo.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},uo.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return()=>{};const a=n0(i.current,pt(pt({},v0(e)),{createComponent:c=>new Ch(c.id,c.name,e.components[c.name],{addPortal:r})})),{clientWidth:l,clientHeight:h}=i.current;return a.layout(l,h),e.onReady&&e.onReady({api:a}),s.current=a,()=>{s.current=void 0,a.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new Ch(a.id,a.name,e.components[a.name],{addPortal:r})})},[e.components]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},n)});_0.displayName="GridviewComponent";var pn=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Yt(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}};function b0(e){return fo.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const w0=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[n,r]=lr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};fo.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},fo.map(a=>e[a])),oe.useEffect(()=>{var a;if(!i.current)return()=>{};const l=(a=e.headerComponents)!==null&&a!==void 0?a:{},h=r0(i.current,pt(pt({},b0(e)),{createComponent:p=>new pn(p.id,e.components[p.name],{addPortal:r}),createHeaderComponent:p=>new pn(p.id,l[p.name],{addPortal:r})})),{clientWidth:c,clientHeight:u}=i.current;return h.layout(c,u),e.onReady&&e.onReady({api:h}),s.current=h,()=>{s.current=void 0,h.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new pn(a.id,e.components[a.name],{addPortal:r})})},[e.components]),oe.useEffect(()=>{var a;if(!s.current)return;const l=(a=e.headerComponents)!==null&&a!==void 0?a:{};s.current.updateOptions({createHeaderComponent:h=>new pn(h.id,l[h.name],{addPortal:r})})},[e.headerComponents]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onDidDrop(l=>{e.onDidDrop&&e.onDidDrop(l)});return()=>{a.dispose()}},[e.onDidDrop]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},n)});w0.displayName="PaneviewComponent";function y0(e,t){const i=t.trim();if(i.length===0||i.length>512||i.startsWith("/")||i.startsWith("\\")||i.includes("\\")||i.includes("\0")||i.includes("?")||i.includes("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(i))return null;const s=Nl(e)&&e!=="."?e:e.split("/").pop()??"",n=s.lastIndexOf("/"),r=n===-1?"":s.slice(0,n),o=r?`${r}/${i}`:i,a=[];for(const h of o.split("/"))if(!(h===""||h===".")){if(h===".."){if(a.length===0)return null;a.pop();continue}a.push(h)}const l=a.join("/");return!l||!Nl(l)?null:l}function Dh(e,t){const i=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'=<>]+))`,"i").exec(e);return i?i[1]??i[2]??i[3]??"":null}function x0(e,t,i){return e.replace(new RegExp(`\\b${t}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>]+)`,"i"),`${t}="${i}"`)}function S0(e){return e?.trim().toLowerCase().split(/\s+/).includes("stylesheet")??!1}function C0(e){try{return new TextDecoder().decode(Uint8Array.from(atob(e),t=>t.charCodeAt(0)))}catch{return null}}function D0(e,t){const i=[],s=(n,r,o,a)=>{const l=r[1]??"";if(!a(l))return;const h=Dh(l,o);if(h===null)return;const c=y0(t,h);c&&i.push({start:r.index,end:r.index+r[0].length,kind:n,rel:c,attrs:l,full:r[0]})};for(const n of e.matchAll(/<script\b([^>]*)>[\s\S]*?<\/script>/gi))s("script",n,"src",()=>!0);for(const n of e.matchAll(/<link\b([^>]*?)\/?>/gi))s("style",n,"href",r=>S0(Dh(r,"rel")));for(const n of e.matchAll(/<img\b([^>]*?)\/?>/gi))s("img",n,"src",()=>!0);return i.sort((n,r)=>n.start-r.start),i}async function k0(e,t,i){const s=D0(e,t),n=new Map;await Promise.all([...new Set(s.map(a=>a.rel))].map(async a=>{n.set(a,await i(a))}));let r=0,o="";for(const a of s){o+=e.slice(r,a.start),r=a.end;const l=n.get(a.rel);if(!l){o+=a.full;continue}if(a.kind==="img"){const c=l.mime||"application/octet-stream";o+=`<img${x0(a.attrs,"src",`data:${c};base64,${l.base64}`)}>`;continue}const h=C0(l.base64);if(h===null){o+=a.full;continue}o+=a.kind==="script"?`<script>${h.replace(/<\/script/gi,"<\\/script")}<\/script>`:`<style>${h.replace(/<\/style/gi,"<\\/style")}</style>`}return o+e.slice(r)}const P0="plugin-view.html";function kh(){return document.documentElement.classList.contains("dark")?"dark":"light"}function E0({pluginId:e,viewId:t,sessionId:i}){const{t:s}=ae(),n=Ks().find(r=>r.pluginId===e&&r.id===t);return n?d.jsx(hr,{pluginId:e,entry:n.entry,title:n.title,sessionId:i}):d.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm text-muted-foreground",children:s("Plugin is not enabled")})}function hr({pluginId:e,entry:t,title:i,sessionId:s,file:n}){const r=w.useRef(null),[o,a]=w.useState(null),l=w.useRef(s);l.current=s;const h=ce(_=>s?_.conversations[s]?.projectId??null:null),c=w.useRef(h);c.current=h;const u=w.useRef(n);u.current=n;const p=w.useRef(null),f=w.useRef(null);w.useEffect(()=>{const _=r.current;if(!_)return;a(null);let T=!1,D=null;const E=()=>{try{D?.port1.postMessage(If(kh()))}catch{}},S=new MutationObserver(E);S.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const A=window.electronAPI.extensionPlugins.onViewEvent(O=>{if(!(O.pluginId!==e||typeof O.name!="string"))try{D?.port1.postMessage(Ef(O.name,O.data))}catch{}}),k=Lf(async(O,z)=>{const N=await window.electronAPI.extensionPlugins.call({pluginId:e,method:"renderer.call",payload:{method:O,args:z},sessionId:l.current});if(!N.ok)throw new Error(N.error);return N.value}),L=async O=>{if(O.source!==_.contentWindow||O.data?.type!=="enso-view-ready")return;D?.port1.close();const z=new MessageChannel;D=z,p.current=z,z.port1.onmessage=y=>{const x=Af(y.data);if(x){window.electronAPI.extensionPlugins.viewStateSet(e,x);return}const b=Rf(y.data);if(b!==null){f.current=b,u.current?.onEdit(b);return}k(y.data).then(R=>{R&&!T&&D===z&&z.port1.postMessage(R)})};const[N,I]=await Promise.all([window.electronAPI.extensionPlugins.asset(e,t),window.electronAPI.extensionPlugins.viewStateGet(e)]);if(T||D!==z)return;if(!N.ok){a(N.error);return}const C=await k0(Nf(N.base64),t,async y=>{const x=await window.electronAPI.extensionPlugins.asset(e,y);return x.ok?{mime:x.mime,base64:x.base64}:null});if(T||D!==z)return;const v=u.current;_.contentWindow?.postMessage({type:"enso-view-init",html:C,theme:kh(),storage:I.ok?I.state:{},session:kl(l.current,c.current),...v?{file:{rel:v.rel,text:v.text}}:{}},"*",[z.port2])};return window.addEventListener("message",L),_.src=new URL(P0,document.baseURI).href,()=>{T=!0,S.disconnect(),A(),window.removeEventListener("message",L),D?.port1.close(),p.current=null,_.removeAttribute("src")}},[e,t]),w.useEffect(()=>{try{p.current?.port1.postMessage(kl(s,h))}catch{}},[s,h]);const m=n?.rel,g=n?.text;return w.useEffect(()=>{if(!(m===void 0||g===void 0)){if(f.current===g){f.current=null;return}try{p.current?.port1.postMessage(Tf(m,g))}catch{}}},[m,g]),d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o&&d.jsx("div",{className:"shrink-0 px-3 py-2 text-xs text-destructive",children:o}),d.jsx("iframe",{ref:r,title:i,className:"min-h-0 w-full flex-1 border-0 bg-background"})]})}const T0=/^(\d{4})-(\d{2})-(\d{2})$/u;function Ph(e){return e<10?`0${e}`:String(e)}function Os(e){const t=new Date(e);return`${t.getFullYear()}-${Ph(t.getMonth()+1)}-${Ph(t.getDate())}`}function I0(e){if(typeof e!="string")return null;const t=T0.exec(e.trim());if(!t)return null;const i=Number(t[1]),s=Number(t[2]),n=Number(t[3]),r=new Date(i,s-1,n);return r.getFullYear()!==i||r.getMonth()!==s-1||r.getDate()!==n?null:`${t[1]}-${t[2]}-${t[3]}`}function A0(e){const t=I0(e);if(!t)return Number.NaN;const[i,s,n]=t.split("-").map(Number);return new Date(i,s-1,n).getTime()}function Eh(e,t){const i=A0(e);if(Number.isNaN(i))return e;const s=new Date(i);return Os(new Date(s.getFullYear(),s.getMonth(),s.getDate()+t).getTime())}const R0=[{name:"status",zh:"进行中的会话,以及需要你处理的",en:"Running sessions and what needs you"},{name:"board",zh:"今天的看板;可带日期,如 /board 2026-05-20 或 yesterday",en:"Today's board; optional date"},{name:"feed",zh:"最近的动态,底部可翻更早",en:"Recent activity, with an older button"},{name:"todo",zh:"未完成的待办",en:"Open todos"},{name:"schedules",zh:"定时任务与下次运行时间",en:"Scheduled tasks and next run"},{name:"following",zh:"手机关注的任务;/following clear 全清",en:"Tasks followed from the phone; /following clear drops all"},{name:"last",zh:"回看秘书会话最近一轮;/last 3 看最近三轮",en:"Replay the last round; /last 3 for three"},{name:"sync",zh:"把所有回复同步到手机;/sync off 关掉",en:"Mirror every reply here; /sync off stops it"},{name:"memory",zh:"秘书记得的标题(默认关闭)",en:"Memory titles (off by default)",gated:!0},{name:"help",zh:"列出所有命令",en:"List every command"}];function N0(e){return e.result==="interrupted"?"interrupted":e.state==="error"?"failed":e.state==="waiting"?"waiting":e.stalled?"stalled":e.subagents&&e.subagents.length>0?"subagent":e.state==="running"?"running":e.backgroundRunning?"background":e.pendingReminder?"reminder":e.backgroundPersistent?"persistent":e.continuing?"continuing":"idle"}const L0="1",Xi="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",Th={network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-group":"This chat is not a group","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","invalid-topic":"Pick at least one topic","route-conflict":"Another secretary already has this group or one of these topics"};function M0({checked:e,disabled:t,label:i,onClick:s,enso:n}){return d.jsxs("button",{type:"button",role:"checkbox","aria-checked":e,"data-enso":n,disabled:t,onClick:s,className:"flex items-center gap-1.5 text-left text-[12px] disabled:opacity-50",children:[d.jsx("span",{className:U("flex size-3.5 shrink-0 items-center justify-center rounded border border-border",e&&"border-foreground bg-foreground text-background"),children:e&&d.jsx(Di,{className:"size-2.5"})}),i]})}function Ih({checked:e,disabled:t,label:i,onClick:s,enso:n}){return d.jsx("button",{type:"button",role:"radio","aria-checked":e,"data-enso":n,disabled:t,onClick:s,className:U("rounded-md px-2 py-0.5 text-[11.5px] transition-colors disabled:opacity-50",e?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),children:i})}function O0({group:e,secretaryId:t,busy:i,onRemove:s,onSaved:n}){const{t:r}=ae(),[o,a]=w.useState(!1),[l,h]=w.useState({state:"idle"}),[c,u]=w.useState(e.topics.map(N=>N.id)),[p,f]=w.useState(!1),[m,g]=w.useState(null),_=N=>N.id===L0?r("General (default topic)"):N.title??r("Topic #{{id}}",{id:N.id}),T=(N,I)=>{const C=r(Th[N]??Th.api),v=N==="api"?` ${r("Make sure the bot is in this group.")}`:"";return`${C}${I?`: ${I}`:""}${v}`},D=()=>{h({state:"loading"}),window.electronAPI.secretary.contactTelegramTopics(e.id,t).then(N=>h(N.ok?{state:"ready",forum:N.forum,topics:N.topics}:{state:"error",error:N.error,...N.detail?{detail:N.detail}:{}}),()=>h({state:"error",error:"api"}))},E=()=>{u(e.topics.map(N=>N.id)),g(null),a(!0),D()},S=N=>{f(!0),g(null),window.electronAPI.secretary.contactSettings({telegramGroupScope:{chatId:e.id,scope:N}},t).then(I=>{I.ok?(a(!1),n()):g(I.error)},()=>g("api")).finally(()=>f(!1))},A=()=>{o&&a(!1),e.all||S("all")},k=e.title??e.id,L=l.state==="ready"?[...l.topics,...e.topics.filter(N=>!l.topics.some(I=>I.id===N.id))]:[],O=i||p,z=o||!e.all;return d.jsxs("li",{"data-enso":"secretary-contact-group",className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{"data-enso":"secretary-contact-group-name",className:"min-w-0 flex-1 truncate text-[12px]",children:e.title?d.jsxs(d.Fragment,{children:[e.title," ",d.jsx("span",{className:"font-mono text-[11px] text-muted-foreground",children:e.id})]}):d.jsx("span",{className:"font-mono text-[11.5px]",children:e.id})}),d.jsxs("div",{role:"radiogroup","aria-label":r("What {{name}} hands to this secretary",{name:k}),className:"inline-flex shrink-0 rounded-lg border border-border p-0.5",children:[d.jsx(Ih,{enso:"secretary-contact-scope-all",checked:!z,disabled:O,label:r("Whole group"),onClick:A}),d.jsx(Ih,{enso:"secretary-contact-scope-topics",checked:z,disabled:O,label:r("Pick topics"),onClick:()=>{o||E()}})]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-group-remove",disabled:i,"aria-label":r("Remove {{name}}",{name:k}),className:Xi,onClick:s,children:d.jsx(qs,{className:"size-3.5"})})]}),!e.all&&!o&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{"data-enso":"secretary-contact-group-scope",className:"min-w-0 flex-1 truncate text-[11.5px] text-muted-foreground",children:r("Topics: {{names}}",{names:e.topics.map(_).join(", ")})}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-group-topics",disabled:i,className:Xi,onClick:E,children:[d.jsx(Gv,{className:"size-3.5"}),r("Change topics")]})]}),m&&!o&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:T(m)}),o&&d.jsxs("div",{"data-enso":"secretary-contact-group-picker",className:"flex flex-col gap-1.5 rounded-lg bg-muted/40 px-2.5 py-2",children:[l.state==="loading"&&d.jsxs("p",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx(Qn,{className:"size-3.5 animate-spin"}),r("Loading topics…")]}),l.state==="error"&&d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[d.jsx("p",{"data-enso":"secretary-contact-topics-error",className:"min-w-0 flex-1 text-[11.5px] text-destructive",children:r("Could not load topics: {{reason}}",{reason:T(l.error,l.detail)})}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-retry",className:Xi,onClick:D,children:[d.jsx(ai,{className:"size-3.5"}),r("Retry")]})]}),l.state==="ready"&&(l.forum?d.jsxs(d.Fragment,{children:[L.map(N=>d.jsx(M0,{enso:"secretary-contact-topic",checked:c.includes(N.id),disabled:O||!!N.owner&&!c.includes(N.id),label:N.owner?`${_(N)} · ${r("taken by {{owner}}",{owner:N.owner})}`:_(N),onClick:()=>u(I=>I.includes(N.id)?I.filter(C=>C!==N.id):[...I,N.id])},N.id)),d.jsx("p",{className:"text-[11px] text-subtle-foreground",children:r("Only topics the bot has seen are listed. If one is missing, send a message in that topic, then refresh. Topics you leave unchecked are ignored.")})]}):d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:r("This group has no topics, so it can only be bound as a whole.")})),m&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:T(m)}),d.jsxs("div",{className:"flex gap-1.5",children:[l.state==="ready"&&l.forum&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-scope-save",disabled:O||c.length===0,className:Xi,onClick:()=>S(c),children:[d.jsx(Di,{className:"size-3.5"}),r("Save")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-refresh",disabled:O,className:Xi,onClick:D,children:[d.jsx(ai,{className:"size-3.5"}),r("Refresh")]})]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-topics-cancel",disabled:p,className:Xi,onClick:()=>a(!1),children:r("Cancel")})]})]})]})}const G0="rounded-xl border border-border px-3 py-2.5",Cr="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50";function z0(e){return e?.find(t=>!t.self&&t.privateChat)?.name??null}const j0={"private-owned":'Your private chat with this bot already belongs to secretary "{{owner}}". One person has only one private chat with a bot, so bind this secretary to a group or forum topic below, or give it a different bot.',"route-conflict":'That group or topic already belongs to secretary "{{owner}}". Send the code in another group or topic.',expired:"The code expired. Generate a new one.","missing-code":"The bot got /start without the code. Open the bot with the button or QR code (the link carries the code), or send /start {{code}} yourself."};function B0({bind:e}){const{t}=ae(),i=e.rejected;return i?d.jsxs("p",{"data-enso":"secretary-contact-bind-rejected","data-reason":i.reason,className:"mt-2 flex gap-1.5 rounded-lg bg-warning/10 px-2.5 py-2 text-[11.5px] text-warning",children:[d.jsx(ec,{className:"mt-px size-3.5 shrink-0"}),d.jsx("span",{children:t(j0[i.reason],{owner:i.owner??"",code:e.code})})]}):null}function $0({bind:e,bot:t,now:i,busy:s,onNewCode:n,onCopied:r}){const{t:o}=ae(),a=e?e.expiresAt<=i:!1,l=e?Math.max(0,Math.ceil((e.expiresAt-i)/6e4)):0,h=e?.topicCommand??(t?`/bind@${t} ${o("<code>")}`:null);return d.jsxs("ol",{"data-enso":"secretary-contact-bind-places",className:"mt-1.5 flex flex-col gap-1.5",children:[d.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[d.jsxs("span",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"1."})," ",o("Add the bot to the group: tap the button, or add @{{bot}} as a member in Telegram. For a forum group, turn on Topics first.",{bot:t??"bot"})]}),e?.groupLink&&d.jsxs("a",{"data-enso":"secretary-contact-group-link",href:e.groupLink,target:"_blank",rel:"noreferrer",className:`${Cr} self-start text-foreground`,children:[d.jsx(Qr,{className:"size-3.5"}),o("Add the bot to a group")]})]}),d.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[d.jsxs("span",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"2."})," ",o("Send this in the group to hand the whole group to this secretary, or inside a forum topic to hand over only that topic:")]}),h?d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("code",{"data-enso":"secretary-contact-topic-command",className:"min-w-0 flex-1 truncate rounded bg-muted px-1.5 py-1 font-mono text-[11.5px] text-foreground",children:h}),e&&!a&&d.jsx("button",{type:"button","data-enso":"secretary-contact-copy-topic-command",className:Cr,"aria-label":o("Copy"),onClick:()=>{navigator.clipboard.writeText(e.topicCommand??""),r()},children:d.jsx(Qd,{className:"size-3.5"})})]}):d.jsx("span",{className:"text-subtle-foreground",children:o("Verify a bot above first; the binding code shows up here.")}),e&&d.jsxs("span",{"data-enso":"secretary-contact-groups-code",className:a?"text-warning":"text-subtle-foreground",children:[o("Binding code of this secretary: {{code}}",{code:e.code})," ·"," ",a?o("This code has expired"):o("Valid for {{minutes}} more minutes",{minutes:l})]}),t&&(!e||a)&&d.jsxs("button",{type:"button","data-enso":"secretary-contact-groups-new-code",disabled:s,className:`${Cr} self-start text-foreground`,onClick:n,children:[d.jsx(Mf,{className:"size-3.5"}),o(e?"New code":"Get a binding code")]})]}),d.jsxs("li",{className:"text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"font-medium text-foreground",children:"3."})," ",o("Bound groups show up in the list of this section, where you can switch between the whole group and picked topics.")]})]})}function W0({shared:e}){const{t}=ae(),i=(e??[]).filter(s=>!s.self).flatMap(s=>s.groups.map(n=>({owner:s.name,group:n})));return i.length===0?null:d.jsxs("div",{className:"mt-2",children:[d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Claimed by other secretaries on this bot (read only):")}),d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:i.map(({owner:s,group:n})=>d.jsxs("li",{"data-enso":"secretary-contact-group-other",className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[d.jsx(Lc,{className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:H0(n,t)}),d.jsx("span",{className:"shrink-0 text-[11px]",children:t("belongs to {{owner}}",{owner:s})})]},`${s}:${n.id}`))})]})}function H0(e,t){const i=e.title??e.id;if(e.all)return`${i} · ${t("Whole group")}`;const s=e.topics.map(n=>n.id==="1"?t("General (default topic)"):n.title??t("Topic #{{id}}",{id:n.id})).join(", ");return`${i} · ${t("Topics: {{names}}",{names:s})}`}function F0({shared:e,bot:t}){const{t:i}=ae();return d.jsxs("div",{"data-enso":"secretary-contact-shared",className:G0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[d.jsx(Of,{className:"size-3.5"}),i("@{{bot}} is shared by {{count}} secretaries",{bot:t??"",count:e.length})]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:i("Each private chat, group or forum topic belongs to one secretary. A topic bound on its own wins over the whole group. Places nobody bound get no reply.")}),d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1.5",children:e.map(s=>{const n=[...s.privateChat?[i("Private chat with @{{name}}",{name:s.privateChat.username??String(s.privateChat.id)})]:[],...s.groups.length>0?[i("Groups and topics: {{count}}",{count:s.groups.length})]:[]];return d.jsxs("li",{"data-enso":"secretary-contact-shared-user","data-self":s.self||void 0,className:"text-[12px]",children:[d.jsx("span",{className:"font-medium",children:s.name}),s.self&&d.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground",children:["(",i("this secretary"),")"]}),!s.enabled&&d.jsxs("span",{className:"ml-1 text-[11px] text-subtle-foreground",children:["· ",i("Telegram off")]}),n.length===0?d.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:i("Nothing bound yet")}):d.jsx("ul",{className:"text-[11.5px] text-muted-foreground",children:n.map(r=>d.jsxs("li",{className:"truncate",children:["· ",r]},r))})]},s.secretaryId)})})]})}const V0="https://t.me/BotFather",U0={"token-invalid":"That does not look like a bot token",network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-bound":"Not bound yet","not-found":"That task is already gone","no-secretary":"No secretary conversation is available","deliver-failed":"Could not reach the secretary session","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","channel-paused":"Pushes to this channel are paused after repeated failures","invalid sender":"Not allowed from this window"},mi="rounded-xl border border-border px-3 py-2.5",_t="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",Dr="inline-flex items-center gap-1.5 rounded-lg bg-foreground px-2.5 py-1.5 text-[12.5px] font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50";function kr({index:e,label:t}){return d.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[d.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-muted text-[10px] tabular-nums",children:e}),t]})}const K0={unconfigured:"Not set up",pending:"Waiting to bind",connected:"Connected",error:"Error"},q0={unconfigured:"bg-muted text-muted-foreground",pending:"bg-warning/15 text-warning",connected:"bg-success/15 text-success",error:"bg-destructive/15 text-destructive"},Nu="enso.secretary.contact.collapsed";function Y0(){try{const e=JSON.parse(window.localStorage.getItem(Nu)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t===!0))}catch{return{}}}function X0(e){try{window.localStorage.setItem(Nu,JSON.stringify(e))}catch{}}function J0({outbound:e,busy:t,onRetry:i}){const{t:s,locale:n}=ae(),r=Date.now(),o=e.state==="paused",a=o&&e.pausedUntil!==void 0&&e.pausedUntil>r;return d.jsxs("div",{"data-enso":"secretary-contact-outbound","data-state":e.state,className:U("rounded-lg border px-2.5 py-2 text-[12px]",o?"border-warning/50 bg-warning/5":"border-destructive/40 bg-destructive/5"),children:[d.jsxs("div",{className:U("flex items-center gap-1.5 font-medium",o?"text-warning":"text-destructive"),children:[o?d.jsx(kv,{className:"size-3.5 shrink-0"}):d.jsx(er,{className:"size-3.5 shrink-0"}),o?s("Pushes paused: {{count}} sends failed in a row",{count:e.consecutiveFailures}):s("The last send failed ({{count}} in a row)",{count:e.consecutiveFailures})]}),e.userMessage&&d.jsx("p",{"data-enso":"secretary-contact-outbound-hint",className:"mt-1 text-[12.5px]",children:e.userMessage}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:s("Last failure: {{time}}",{time:`${rs(e.lastErrorAt,n)} (${li(e.lastErrorAt,n,r)})`})}),e.detail&&d.jsx("p",{"data-enso":"secretary-contact-outbound-detail",className:"mt-0.5 break-all font-mono text-[11px] text-muted-foreground",children:e.detail}),o&&d.jsxs("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:[a?s("Next try at {{time}}. A message from this channel or Retry now resumes pushes right away.",{time:rs(e.pausedUntil??r,n)}):s("The next push will try again."),e.suppressedCount>0&&` ${s("{{count}} pushes held back.",{count:e.suppressedCount})}`]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-outbound-retry",disabled:t,className:U(_t,"mt-1.5"),onClick:i,children:[d.jsx(ai,{className:"size-3.5"}),s("Retry now")]}),d.jsx("span",{className:"ml-2 text-[11px] text-subtle-foreground",children:s("Sends a test message to this channel.")})]})}const Z0="enso.telegram";function fn({label:e,hint:t,checked:i,disabled:s,dataEnso:n,onChange:r}){return d.jsxs("label",{className:"flex items-start gap-2",children:[d.jsx("input",{type:"checkbox","data-enso":n,className:"mt-0.5",checked:i,disabled:s,onChange:o=>r(o.target.checked)}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block text-[12.5px]",children:e}),d.jsx("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground",children:t})]})]})}function Q0({channel:e,collapsed:t,busy:i,onToggle:s,onPrefs:n,onRetry:r,children:o}){const{t:a}=ae(),l=e.id==="telegram",{prefs:h,caps:c}=e,u=[!c.buttons&&a("No buttons: questions and cards arrive as numbered text."),!c.edit&&a("Cannot edit sent messages: answered questions are not marked there."),!c.typing&&a("No typing indicator.")].filter(p=>typeof p=="string");return d.jsxs("div",{"data-enso":"secretary-contact-channel","data-channel":e.id,className:"rounded-xl border border-border",children:[d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-channel-toggle","aria-expanded":!t,className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:s,children:[t?d.jsx(as,{className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(Ii,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.pluginId?d.jsx(ma,{pluginId:e.pluginId,icon:e.icon,className:"size-4"}):d.jsx(Ea,{className:"size-4 shrink-0"}),d.jsx("span",{className:"truncate text-[13px] font-medium",children:e.title}),d.jsx("span",{className:"shrink-0 rounded bg-muted px-1 text-[10.5px] text-muted-foreground",children:e.builtin?a("Built-in"):a("Plugin")}),d.jsx("span",{"data-enso":"secretary-contact-channel-status",className:U("shrink-0 rounded px-1 text-[10.5px]",q0[e.status]),children:a(K0[e.status])}),e.outbound&&d.jsx("span",{"data-enso":"secretary-contact-channel-outbound",className:U("shrink-0 rounded px-1 text-[10.5px]",e.outbound.state==="paused"?"bg-warning/15 text-warning":"bg-destructive/15 text-destructive"),children:e.outbound.state==="paused"?a("Pushes paused"):a("Send failed")})]}),d.jsx(tc,{"data-enso":"secretary-contact-channel-enabled",checked:h.enabled,disabled:i,"aria-label":a("Enable {{name}}",{name:e.title}),onCheckedChange:p=>n({enabled:p})})]}),!t&&d.jsxs("div",{className:"flex flex-col gap-2 border-t border-border px-3 py-2.5",children:[e.detail&&e.status==="error"&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:e.detail}),e.outbound&&d.jsx(J0,{outbound:e.outbound,busy:i,onRetry:r}),d.jsx(fn,{dataEnso:"secretary-contact-push",label:a("Push to this channel"),hint:a("Milestones, questions from the secretary, cards and approval notices go out here."),checked:h.push,disabled:i,onChange:p=>n({push:p})}),d.jsx(fn,{dataEnso:l?"secretary-contact-allow-dispatch":"secretary-contact-card-confirm",label:a(l?"Allow confirming cards from Telegram":"Confirm cards from the phone"),hint:l?a("On by default. A tap on your phone can confirm settings, skill, tool, takeover and cleanup cards. Those cards change which projects the secretary sees, what it may take over, which skills and tools it installs and what it cleans up. Approvals are never handled from Telegram."):c.buttons?a("Off by default. Approvals are never handled from the phone."):a('Off by default. Reply "confirm 1" to confirm a card. Approvals are never handled from the phone.'),checked:h.cardConfirm,disabled:i,onChange:p=>n({cardConfirm:p})}),d.jsx(fn,{dataEnso:"secretary-contact-mirror",label:a("Mirror every reply"),hint:a("Off by default. Every reply in the secretary conversation is sent here, not just milestones."),checked:h.syncMirror,disabled:i,onChange:p=>n({syncMirror:p})}),d.jsx(fn,{dataEnso:l?"secretary-contact-allow-memory":"secretary-contact-memory",label:a(l?"Allow viewing memory titles on Telegram":"Allow viewing memory titles"),hint:a("Off by default. /memory lists titles only, never the memory text."),checked:h.memory,disabled:i,onChange:p=>n({memory:p})}),u.length>0&&d.jsx("ul",{"data-enso":"secretary-contact-limits",className:"flex flex-col gap-0.5 text-[11.5px] text-subtle-foreground",children:u.map(p=>d.jsxs("li",{children:["· ",p]},p))}),o]})]})}function ey({secretaryId:e}={}){const{t}=ae(),[i,s]=w.useState(null),[n,r]=w.useState(""),[o,a]=w.useState(!1),[l,h]=w.useState(null),[c,u]=w.useState(null),[p,f]=w.useState(null),[m,g]=w.useState(Y0),[_,T]=w.useState([]),[D,E]=w.useState(""),[S,A]=w.useState(()=>Date.now());w.useEffect(()=>{const K=window.electronAPI.extensionPlugins,F=()=>{K.list().then(T).catch(()=>T([]))};return F(),K.onChanged(F)},[]);const k=K=>{g(F=>{const le={...F};return le[K]?delete le[K]:le[K]=!0,X0(le),le})},L=w.useCallback(()=>{window.electronAPI.secretary.contactState(e).then(s)},[e]);w.useEffect(()=>(L(),window.electronAPI.secretary.onContactChanged(K=>{e&&K.secretaryId&&K.secretaryId!==e||s(K)})),[L,e]);const O=i?.telegram.bind?.expiresAt;w.useEffect(()=>{if(O===void 0)return;A(Date.now());const K=window.setInterval(()=>A(Date.now()),15e3);return()=>window.clearInterval(K)},[O]);const z=i?.telegram.bind?.link;w.useEffect(()=>{if(!z){f(null);return}let K=!0;return Qg.toDataURL(z,{width:320,margin:1}).then(F=>{K&&f(F)}).catch(()=>f(null)),()=>{K=!1}},[z]);const N=K=>{a(!0),h(null),u(null),K().then(F=>{F.ok||h(F.error??"api")}).finally(()=>{a(!1),L()})};if(!i)return null;const I=i.telegram,C=i.channels??[],v=_.some(K=>K.id===Z0&&K.state==="enabled"),y=(K,F)=>N(()=>window.electronAPI.secretary.contactSettings({channelId:K,prefs:F},e)),x=K=>N(()=>window.electronAPI.secretary.contactTest(e,K).then(F=>{if(F.ok)u(t("Test message sent"));else if(["api","network","unauthorized","channel-paused"].includes(F.error))return{ok:!0};return F})),b=I.poll.state==="error"||I.poll.state==="backoff",R=I.poll.state!=="stopped"&&I.poll.state!=="error",M=l==="network"&&R?null:l,W=I.groups??[],B=D.trim(),Q=(K,F)=>N(()=>window.electronAPI.secretary.contactSettings({telegramGroup:{action:K,chatId:F}},e).then(le=>(le.ok&&K==="add"&&E(""),le))),ie=I.bind?Math.max(0,Math.ceil((I.bind.expiresAt-S)/6e4)):0,ne=I.bind?I.bind.expiresAt<=S:!1,de=I.chat?null:z0(I.shared),ve=d.jsx($0,{bind:I.bind,bot:I.bot?.username,now:S,busy:o,onNewCode:()=>N(()=>window.electronAPI.secretary.contactBind(void 0,e)),onCopied:()=>u(t("Copied"))}),re=d.jsxs("div",{"data-enso":"secretary-contact-groups",className:mi,children:[d.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:t("Groups and topics")}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Only groups on this list reach the secretary, and only messages from the bound account count. Messages from anyone else in the group are not received.")}),W.length===0?d.jsxs(d.Fragment,{children:[ve,d.jsx("p",{className:"mt-1.5 text-[11.5px] text-subtle-foreground",children:t("No groups yet: group messages are not received.")})]}):d.jsxs(d.Fragment,{children:[d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:W.map(K=>d.jsx(O0,{group:K,secretaryId:e,busy:o,onRemove:()=>Q("remove",K.id),onSaved:L},K.id))}),d.jsx("p",{className:"mt-2.5 text-[11.5px] font-medium text-muted-foreground",children:t("Bind another group or topic")}),ve]}),d.jsx(W0,{shared:I.shared}),d.jsx("p",{className:"mt-2 text-[11px] text-subtle-foreground",children:t("Or add a group by its chat ID:")}),d.jsxs("form",{className:"mt-1 flex gap-1.5",onSubmit:K=>{if(K.preventDefault(),!!B){if(W.some(F=>F.id===B)){E("");return}Q("add",B)}},children:[d.jsx("input",{"data-enso":"secretary-contact-group-input",value:D,spellCheck:!1,autoComplete:"off",placeholder:t("Group chat ID, e.g. -1001234567890"),onChange:K=>E(K.target.value),className:"min-w-0 flex-1 rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),d.jsxs("button",{type:"submit","data-enso":"secretary-contact-group-add",disabled:o||!B,className:_t,children:[d.jsx(ns,{className:"size-3.5"}),t("Add group")]})]})]}),me=d.jsxs(d.Fragment,{children:[v&&d.jsx("p",{"data-enso":"secretary-contact-token-conflict",className:"text-[11.5px] text-warning",children:t("The Telegram remote plugin (enso.telegram) is enabled. Do not give both the same bot token: only one place can poll a bot, so they would steal each other's messages.")}),I.status==="bound"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-bound",className:mi,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-success/15 text-success",children:d.jsx(Di,{className:"size-3.5"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13px] font-medium",children:I.chat?t("Bound to @{{username}}",{username:I.chat.username??String(I.chat.id)}):t("Bound to groups and topics")}),d.jsxs("p",{className:"truncate text-[11.5px] text-muted-foreground",children:[t("Bot @{{bot}}",{bot:I.bot?.username??""}),I.tokenHint?` · ${I.tokenHint}`:""]})]})]}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-test",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactTest(e).then(K=>(K.ok&&u(t("Test message sent")),K))),children:[d.jsx(Ea,{className:"size-3.5"}),t("Send a test message")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-unbind",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactUnbind(e)),children:[d.jsx(Uv,{className:"size-3.5"}),t("Unbind")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-replace",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactForgetBot(e)),children:[d.jsx(ai,{className:"size-3.5"}),t("Change bot")]})]})]}),re,d.jsx("div",{"data-enso":"secretary-contact-sync",className:U(mi,I.syncMirror&&"border-warning/50 bg-warning/5"),children:I.syncMirror?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-medium text-warning",children:[d.jsx(Wv,{className:"size-3.5 shrink-0"}),t("Mirroring every conversation to Telegram")]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Every reply in the secretary conversation is sent to your phone, not just milestones. Silent turns arrive as a one-line summary. Telegram messages are not end-to-end encrypted and stay on Telegram servers. Send /sync off in Telegram to stop.")})]}):d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Only milestones go to Telegram. Send /sync in Telegram to mirror every reply; /last replays the latest round.")})}),d.jsxs("div",{"data-enso":"secretary-contact-commands",className:mi,children:[d.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:t("Commands you can send")}),d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:R0.filter(K=>!K.gated||I.allowMemory).map(K=>d.jsxs("li",{className:"text-[12px]",children:[d.jsxs("code",{className:"rounded bg-muted px-1 text-[11.5px]",children:["/",K.name]})," ",d.jsx("span",{className:"text-muted-foreground",children:t(K.en)})]},K.name))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] text-muted-foreground",children:t("Telegram messages are not end-to-end encrypted and stay on Telegram servers. /status, /board and /feed show titles and short summaries; /last and /sync send conversation text. Memory text and tool output never leave the app.")})]}),!I.secure&&d.jsx("p",{className:"px-1 text-[11.5px] text-warning",children:t("No system keychain available: the bot token is stored unencrypted on this machine.")})]}),I.status==="awaiting-start"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-verified",className:mi,children:[d.jsx(kr,{index:2,label:t("Bot verified")}),d.jsxs("p",{className:"mt-1 text-[13px] font-medium",children:[I.bot?.name," ",d.jsxs("span",{className:"text-muted-foreground",children:["@",I.bot?.username]})]})]}),d.jsxs("div",{"data-enso":"secretary-contact-code",className:mi,children:[d.jsx(kr,{index:3,label:t("Open the bot and press Start")}),d.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[p&&d.jsx("img",{"data-enso":"secretary-contact-qr",src:p,alt:t("Binding QR code"),className:"size-28 shrink-0 rounded-lg bg-white p-1"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Binding code")}),d.jsx("p",{"data-enso":"secretary-contact-code-value",className:"font-mono text-[22px] tracking-[0.2em] tabular-nums",children:I.bind?.code}),ne?d.jsx("p",{"data-enso":"secretary-contact-code-expired",className:"mt-1 text-[11.5px] text-warning",children:t("This code has expired")}):d.jsx("p",{className:"mt-1 text-[11.5px] text-subtle-foreground",children:t("Valid for {{minutes}} more minutes",{minutes:ie})})]})]}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.jsxs("a",{"data-enso":"secretary-contact-open-bot",href:I.bind?.link,target:"_blank",rel:"noreferrer",className:Dr,children:[d.jsx(Qr,{className:"size-3.5"}),t("Open @{{bot}}",{bot:I.bot?.username??""})]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-copy",className:_t,onClick:()=>{navigator.clipboard.writeText(I.bind?.link??""),u(t("Link copied"))},children:[d.jsx(Qd,{className:"size-3.5"}),t("Copy link")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-regenerate",disabled:o,className:ne?Dr:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[d.jsx(ai,{className:"size-3.5"}),t("New code")]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-cancel",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactCancel(e)),children:t("Cancel")})]}),I.bind&&d.jsx(B0,{bind:I.bind}),de&&I.bind?.rejected?.reason!=="private-owned"&&d.jsx("p",{"data-enso":"secretary-contact-private-owned",className:"mt-2 text-[11.5px] text-warning",children:t('Your private chat with this bot already belongs to secretary "{{owner}}". Bind this secretary to a group or forum topic instead.',{owner:de})}),d.jsx("p",{className:"mt-2 text-[11.5px] text-subtle-foreground",children:t("The code works once. Press Start in a private chat with the bot, or send it in a group or forum topic to bind that place to this secretary instead.")})]}),re]}),I.shared&&I.status!=="unbound"&&d.jsx(F0,{shared:I.shared,bot:I.bot?.username}),I.status==="unbound"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-step1",className:mi,children:[d.jsx(kr,{index:1,label:t("Create a bot with @BotFather")}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Send /newbot, pick a name, and copy the token it gives you.")}),d.jsxs("a",{"data-enso":"secretary-contact-botfather",href:V0,target:"_blank",rel:"noreferrer",className:U(_t,"mt-2"),children:[d.jsx(Qr,{className:"size-3.5"}),t("Open @BotFather")]}),d.jsx("input",{"data-enso":"secretary-contact-token",type:"password",value:n,spellCheck:!1,autoComplete:"off",placeholder:t("Paste the bot token"),onChange:K=>r(K.target.value),className:"mt-2 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-verify",disabled:o||n.trim().length===0,className:U(Dr,"mt-2"),onClick:()=>N(()=>window.electronAPI.secretary.contactBind(n.trim(),e)),children:[o?d.jsx(Qn,{className:"size-3.5 animate-spin"}):d.jsx(Di,{className:"size-3.5"}),t("Verify and continue")]}),I.bot&&d.jsxs("button",{type:"button","data-enso":"secretary-contact-reconnect",disabled:o,className:U(_t,"mt-1.5"),onClick:()=>N(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[d.jsx(ai,{className:"size-3.5"}),t("Bind again with @{{bot}}",{bot:I.bot.username})]})]}),d.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:t("The token is stored with the system keychain and never written to logs.")}),re]})]});return d.jsxs("div",{"data-enso":"secretary-contact",className:"flex flex-col gap-2 px-3 py-3",children:[d.jsx("p",{className:"px-1 text-[11.5px] text-muted-foreground",children:t("Reach the secretary from your phone. Milestones go out; your replies come back.")}),d.jsxs("div",{"data-enso":"secretary-contact-master",className:"flex items-center justify-between gap-2 rounded-xl border border-border px-3 py-2",children:[d.jsx("span",{className:"text-[13px] font-medium",children:t("Enable contacts")}),d.jsx(tc,{"data-enso":"secretary-contact-enabled",checked:i.enabled,disabled:o,"aria-label":t("Enable contacts"),onCheckedChange:K=>N(()=>window.electronAPI.secretary.contactSettings({enabled:K},e))})]}),i.enabled?d.jsxs(d.Fragment,{children:[(M||b)&&d.jsxs("div",{"data-enso":"secretary-contact-error",className:"flex items-start gap-1.5 rounded-lg border border-destructive/40 bg-destructive/5 px-2.5 py-2 text-[12px] text-destructive",children:[d.jsx(er,{className:"mt-0.5 size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1",children:t(M?U0[M]??"Telegram returned an error":"Cannot reach api.telegram.org. Check the proxy.")})]}),c&&d.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-success/40 bg-success/5 px-2.5 py-2 text-[12px] text-success",children:[d.jsx(Di,{className:"size-3.5 shrink-0"}),d.jsx("span",{children:c})]}),C.map(K=>d.jsx(Q0,{channel:K,collapsed:m[K.id]===!0,busy:o,onToggle:()=>k(K.id),onPrefs:F=>y(K.id,F),onRetry:()=>x(K.id),children:K.id==="telegram"?me:K.pluginId&&K.settingsView?d.jsx("div",{"data-enso":"secretary-contact-plugin-view",className:"h-72 overflow-hidden rounded-lg border border-border",children:d.jsx(hr,{pluginId:K.pluginId,entry:K.settingsView,title:K.title,sessionId:null})}):null},K.id)),d.jsxs("div",{"data-enso":"secretary-contact-following",className:mi,children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("div",{className:"text-[12.5px] font-medium",children:t("Followed from the phone: {{count}}",{count:I.following.length})}),I.following.length>0&&d.jsx("button",{type:"button","data-enso":"secretary-contact-following-clear",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactFollowing({action:"clear"},e)),children:t("Clear all")})]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("What you dispatch or schedule from the phone keeps reporting here until it finishes or fails once, even with /sync off.")}),I.following.length>0&&d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:I.following.map(K=>d.jsxs("li",{className:"flex items-start justify-between gap-2",children:[d.jsxs("span",{className:"min-w-0 flex-1 text-[12px]",children:[d.jsxs("span",{className:"text-muted-foreground",children:[K.kind==="schedule"?t("Scheduled"):t("Session")," ·"," "]}),K.summary]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-following-cancel",disabled:o,className:_t,onClick:()=>N(()=>window.electronAPI.secretary.contactFollowing({action:"cancel",id:K.id},e)),children:t("Drop")})]},K.id))})]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-market",className:U(_t,"self-start"),onClick:()=>{window.electronAPI.window.openSettings({category:"plugins",rowId:"plugins.enso",marketQuery:"contact"})},children:[d.jsx(ic,{className:"size-3.5"}),t("Find more contact channels in the plugin market")]})]}):d.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:t("Contacts are off: nothing is sent or received on any channel.")})]})}const ty=[{key:"running",title:"In progress",dot:"#3b82f6"},{key:"withSecretary",title:"With secretary",dot:"#8b5cf6",stamp:"With secretary"},{key:"stopped",title:"Stopped",dot:"#64748b",stamp:"Stopped"},{key:"needsYou",title:"Needed you",dot:"#f59e0b",stamp:"Needed you"},{key:"done",title:"What got done",dot:"#10b981",stamp:"Completed"},{key:"failed",title:"Failed or interrupted",dot:"#ef4444",stamp:"Failed"},{key:"todos",title:"To-dos",dot:"#a855f7"},{key:"changes",title:"Settings and capabilities",dot:"#06b6d4"}],iy="flex-none rounded-lg p-1 pb-1.5 bg-[color-mix(in_oklch,var(--muted)_55%,transparent)] shadow-[inset_0_0_0_1px_color-mix(in_oklch,var(--border)_60%,transparent)] @[560px]:w-[260px]",sy="rounded-md border border-border bg-card px-2.5 py-2 shadow-[0_1px_2px_0_rgb(0_0_0/0.05)] transition-[border-color,box-shadow] duration-200 hover:border-foreground/15 hover:shadow-[0_1px_3px_0_rgb(0_0_0/0.08)]",ii="inline-flex h-[18px] max-w-full items-center gap-1 rounded-full bg-foreground/[0.06] px-1.5 font-medium",Ah=U(ii,"relative shrink-0 text-[11px] leading-none text-muted-foreground transition-colors before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] hover:bg-foreground/10 hover:text-foreground"),$n="flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground";function ws(e,t,i){const s=rs(e,i);if(Os(e)===t)return s;const n=new Date(e);return`${n.getMonth()+1}/${n.getDate()} ${s}`}function ny({conversationId:e,task:t}){const{t:i}=ae(),s=hg(),n=dg(t);return d.jsxs("div",{"data-enso":"secretary-daily-leftover-task",className:"flex min-w-0 items-center gap-1.5 py-0.5",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate font-mono text-[11px] text-foreground/80",title:t.command,children:t.command}),n==="idle"?d.jsx("div",{className:"text-[10.5px] text-warning",children:cg(t,s,i)}):n==="kept"?d.jsx(ug,{task:t,className:"text-[10.5px]"}):d.jsx("div",{className:"text-[10.5px] text-muted-foreground tabular-nums",children:i("Running for {{duration}}",{duration:pg(s-t.startedAt)})})]}),n==="idle"&&d.jsx("button",{type:"button",onClick:()=>fg(e,t.taskId,""),className:"shrink-0 rounded-[5px] px-1 text-[11px] text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground",children:i("Keep")}),d.jsx("button",{type:"button","data-enso":"secretary-daily-stop-task",onClick:()=>mg(e,t.taskId),className:"shrink-0 rounded-[5px] px-1 text-[11px] text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:i("Stop")})]})}function ry({item:e,column:t,day:i}){const{t:s,locale:n}=ae(),[r,o]=w.useState(!1),[a,l]=w.useState(!1),h=e.summary??e.detail,c=e.detail??e.summary,u=e.needsUser&&e.needsUser.length>0?e.needsUser:void 0,p=e.doneAt!==void 0,f=[e.dispatchedAt!==void 0?`${s("Dispatched")} ${ws(e.dispatchedAt,i,n)}`:"",e.addedAt!==void 0?`${s("Added")} ${ws(e.addedAt,i,n)}`:"",e.doneAt!==void 0?`${s("Done")} ${ws(e.doneAt,i,n)}`:"",t.stamp?`${s(t.stamp)} ${ws(e.at,i,n)}`:""].filter(Boolean),m=e.tracked&&e.manual&&t.key==="done"?"undo":null,g=e.tracked&&(t.key==="running"||t.key==="withSecretary"||t.key==="stopped"||t.key==="needsYou"||t.key==="failed"),_=t.key==="done"&&e.conversationId?{title:e.title,...c?{fallback:c}:{}}:void 0,T=()=>{e.conversationId&&Ia(e.conversationId,_)},D=ce(L=>e.conversationId?L.conversations[e.conversationId]?.backgroundTasks:void 0),E=e.leftover?(D??[]).filter(L=>L.status==="running"):[],S=E.filter(ag).length,A=e.leftover!==void 0&&D!==void 0&&E.length===0,k=e.leftover&&e.conversationId&&!A&&(E.length===0||S>0)?e.conversationId:null;return d.jsxs("div",{"data-enso":"secretary-daily-card","data-item":e.id,"data-done":p?"true":void 0,className:U(sy,"group/row relative"),children:[k&&d.jsx(Ys,{className:"from-card",children:d.jsx("button",{type:"button","data-enso":"secretary-daily-stop-leftover",title:s("Stop suspected idle leftover tasks"),"aria-label":s("Stop suspected idle leftover tasks"),disabled:a,onClick:()=>{l(!0),window.electronAPI.secretary.stopTasks(k).finally(()=>l(!1))},className:U($n,"w-auto px-1 text-[11px] hover:bg-destructive/10 hover:text-destructive"),children:s("Stop")})}),(m||g)&&d.jsxs("div",{"data-enso":"secretary-daily-actions",className:"mb-1.5 flex flex-wrap items-center justify-start gap-1",children:[(m||g)&&d.jsxs("button",{type:"button","data-enso":g?"secretary-daily-mark-done":"secretary-daily-mark-undo",title:s(g?"Mark done":"Undo mark done"),"aria-label":s(g?"Mark done":"Undo mark done"),onClick:()=>{e.conversationId&&window.electronAPI.secretary.markResult(e.conversationId,g?"done":"undo")},className:Ah,children:[g?d.jsx(Di,{className:"size-[11px]"}):d.jsx(On,{className:"size-[11px]"}),d.jsx("span",{children:s(g?"Mark done":"Undo mark done")})]}),g&&d.jsxs("button",{type:"button","data-enso":"secretary-daily-dismiss",title:s("Move off the board"),"aria-label":s("Move off the board"),onClick:()=>{e.conversationId&&window.electronAPI.secretary.markResult(e.conversationId,"dismiss")},className:Ah,children:[d.jsx(qs,{className:"size-[11px]"}),d.jsx("span",{children:s("Move off the board")})]})]}),d.jsxs("button",{type:"button","data-enso":"secretary-daily-expand",..._?{"aria-haspopup":"dialog"}:{"aria-expanded":r},onClick:_?T:()=>o(L=>!L),className:"block w-full text-left",children:[d.jsx("span",{className:U("block text-[12.5px] font-medium leading-[1.45] break-words",p&&"text-muted-foreground line-through"),children:e.title}),u?d.jsxs(d.Fragment,{children:[e.summary&&d.jsx("span",{"data-enso":"secretary-daily-needs-user-summary",title:e.summary,className:"mt-[4px] block line-clamp-1 break-words text-[12px] text-muted-foreground",children:e.summary}),d.jsx("ul",{"data-enso":"secretary-daily-needs-user",className:"mt-[4px] flex flex-col gap-0.5 text-[12px] text-foreground/90",children:u.map((L,O)=>{const z=e.goalResult?.answers?.find(N=>N.index===O);return d.jsxs("li",{"data-enso":"secretary-daily-needs-user-item","data-answered":z?"true":void 0,title:L,className:"break-words",children:[d.jsx("span",{className:U("line-clamp-2",z&&"text-muted-foreground line-through"),children:s("Needs you: {{item}}",{item:L})}),z&&d.jsx("span",{"data-enso":"secretary-daily-needs-user-answer",title:z.answer,className:"line-clamp-1 text-success",children:s("Answered: {{answer}}",{answer:z.answer})})]},L)})}),r&&c&&d.jsx("span",{className:"mt-1.5 block whitespace-pre-wrap break-words border-t border-border/60 pt-1 text-[11.5px] text-muted-foreground",children:c})]}):h&&d.jsx("span",{className:U("mt-[3px] block whitespace-pre-wrap break-words text-[12px] text-muted-foreground",r?void 0:"line-clamp-3"),children:r?c:h})]}),E.length>0&&e.conversationId&&d.jsx("div",{"data-enso":"secretary-daily-leftover-tasks",className:"mt-[7px] rounded-[5px] bg-foreground/[0.04] px-1.5 py-1",children:E.map(L=>d.jsx(ny,{conversationId:e.conversationId,task:L},L.taskId))}),d.jsxs("div",{className:"mt-[7px] flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.projectName&&d.jsx("span",{className:ii,children:e.projectName}),e.label&&d.jsx("span",{className:ii,children:s(e.label)}),e.leftover&&!A&&d.jsx("span",{"data-enso":"secretary-daily-leftover",className:U(ii,(E.length===0||S>0)&&"text-warning"),children:E.length>0&&S===0?s("Done ({{count}} kept tasks)",{count:E.length}):s("Done ({{count}} leftover tasks)",{count:E.length||e.leftover.count})}),e.persistent&&d.jsx("span",{"data-enso":"secretary-daily-persistent",className:U(ii,"text-warning"),children:s("Service running")}),e.pendingReminder&&d.jsxs("span",{"data-enso":"secretary-daily-reminder",title:va(e.pendingReminder,Date.now(),s),className:U(ii,"bg-sky-500/15 text-sky-600 tabular-nums dark:text-sky-400"),children:[d.jsx(Ta,{className:"size-[11px] shrink-0","aria-hidden":!0}),d.jsxs("span",{className:"truncate",children:[s("Waiting for reminder · {{time}}",{time:ga(e.pendingReminder.dueAt)}),e.pendingReminder.label?` · ${e.pendingReminder.label}`:""]})]}),e.branch&&d.jsx("span",{"data-enso":"secretary-daily-branch",className:U(ii,"font-mono"),children:e.branch}),e.commit&&d.jsx("span",{"data-enso":"secretary-daily-commit",className:U(ii,"font-mono"),children:e.commit}),e.conversationId&&d.jsxs("button",{type:"button","data-enso":"secretary-daily-open",title:s("Open session"),"aria-label":s("Open session"),onClick:T,className:U(ii,"cursor-pointer text-foreground transition-colors hover:bg-brand/15 hover:text-brand"),children:[d.jsx(ev,{className:"size-[11px] shrink-0"}),d.jsx("span",{className:"truncate",children:s("Session")})]}),e.goalResult&&d.jsx(lg,{view:e.goalResult,hideNeedsUser:t.key==="done"||!!u}),d.jsx("span",{"data-enso":"secretary-daily-times",className:"tabular-nums",children:f.length>0?f.join(" · "):ws(e.at,i,n)})]})]})}function oy({column:e,items:t,folded:i,onToggleFold:s,day:n}){const{t:r}=ae();return d.jsxs("section",{"data-enso":"secretary-daily-column","data-group":e.key,className:iy,children:[d.jsxs("div",{className:"flex min-h-[30px] items-center gap-1 pt-0.5 pb-1.5",children:[d.jsx("button",{type:"button","data-enso":"secretary-daily-fold","aria-expanded":!i,"aria-label":r(i?"Expand":"Collapse"),onClick:s,className:U($n,"size-6"),children:d.jsx(Ii,{className:U("size-3.5 transition-transform duration-300",i&&"-rotate-90")})}),d.jsx("span",{"aria-hidden":!0,className:"mx-0.5 size-[7px] shrink-0 rounded-full",style:{background:e.dot,boxShadow:`0 0 0 3px color-mix(in oklch, ${e.dot} 18%, transparent)`}}),d.jsx("span",{className:"min-w-0 truncate px-1.5 py-0.5 text-[12.5px] font-semibold",children:r(e.title)}),d.jsx("span",{"data-enso":"secretary-daily-count","data-key":e.key,className:"rounded-full bg-foreground/[0.06] px-1.5 py-0.5 font-mono text-[11px] leading-none tabular-nums text-muted-foreground",children:t.length})]}),!i&&d.jsxs("div",{className:"flex min-h-1.5 flex-col gap-1.5",children:[t.map(o=>d.jsx(ry,{item:o,column:e,day:n},o.id)),t.length===0&&d.jsxs("div",{"data-enso":"secretary-daily-empty-column",className:"flex flex-col items-center gap-1 px-2 pt-3.5 pb-2 text-center text-[11.5px] text-subtle-foreground",children:[d.jsx(og,{className:"size-5 opacity-60"}),r("No cards yet")]})]})]})}function ay({secretaryId:e}={}){const{t}=ae(),[i,s]=w.useState(()=>Os(Date.now())),[n,r]=w.useState(null),[o,a]=w.useState(()=>new Set),l=Os(Date.now()),h=w.useCallback(g=>{window.electronAPI.secretary.daily(g,e).then(_=>{_.ok&&r(_.daily)}).catch(()=>{})},[e]);w.useEffect(()=>{h(i)},[i,h]),w.useEffect(()=>{if(i===Os(Date.now()))return window.electronAPI.secretary.onStateChanged(()=>h(i))},[i,h]);const c=g=>n?.groups.find(_=>_.key===g)?.items??[],u=(n?.groups??[]).reduce((g,_)=>g+_.items.length,0),p=c("done").length,f=n?.counts.dispatched??0,m=g=>a(_=>{const T=new Set(_);return T.has(g)?T.delete(g):T.add(g),T});return d.jsxs("div",{"data-enso":"secretary-daily",className:"@container flex flex-col gap-2 px-3 py-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button","data-enso":"secretary-daily-prev",title:t("Previous day"),"aria-label":t("Previous day"),onClick:()=>s(g=>Eh(g,-1)),className:$n,children:d.jsx(sc,{className:"h-3.5 w-3.5"})}),d.jsx("input",{type:"date","data-enso":"secretary-daily-date","aria-label":t("Daily board"),value:i,max:l,onChange:g=>{const _=g.target.value;_&&s(_)},className:"min-w-0 flex-1 rounded-[6px] border border-border bg-transparent px-1.5 py-0.5 text-[12.5px] tabular-nums outline-none focus:border-foreground/30"}),d.jsx("button",{type:"button","data-enso":"secretary-daily-next",title:t("Next day"),"aria-label":t("Next day"),disabled:i>=l,onClick:()=>s(g=>Eh(g,1)),className:U($n,"disabled:opacity-40 disabled:hover:bg-transparent"),children:d.jsx(as,{className:"h-3.5 w-3.5"})}),d.jsxs("span",{"data-enso":"secretary-daily-stat",title:`${t("Dispatched")} / ${t("What got done")} / ${t("All")}`,className:"shrink-0 whitespace-nowrap font-mono text-[11.5px] tabular-nums text-muted-foreground",children:[t("Dispatched")," ",f," · ",p,"/",u]}),d.jsx("button",{type:"button","data-enso":"secretary-daily-today",disabled:i===l,onClick:()=>s(l),className:"shrink-0 rounded-md border border-border px-2 py-0.5 text-[11.5px] whitespace-nowrap transition-colors hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent",children:t("Today")})]}),d.jsx("div",{"data-enso":"secretary-daily-board",className:"flex flex-col gap-2.5 @[560px]:flex-row @[560px]:items-start @[560px]:overflow-x-auto @[560px]:pb-1",children:ty.map(g=>d.jsx(oy,{column:g,items:c(g.key),folded:o.has(g.key),onToggleFold:()=>m(g.key),day:i},g.key))}),n?.earliest&&d.jsx("p",{"data-enso":"secretary-daily-earliest",className:"px-1.5 pt-1 text-[11px] text-subtle-foreground",children:t("Look back to {{day}}",{day:n.earliest})})]})}function ly(e){return`proj:${e}`}const Rh=50,hy=10;function dy({item:e,onOpen:t,onEdit:i,onDelete:s,trailing:n,children:r}){return d.jsxs("div",{"data-enso":"secretary-memory-row","data-memory-id":e.id,className:"flex flex-col",children:[d.jsxs("div",{className:U(nr,"w-full rounded-lg px-1.5 py-2"),children:[d.jsxs("button",{type:"button","data-enso":"secretary-memory-open",onClick:()=>t(e.id),className:"block w-full min-w-0 text-left",children:[d.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1.5",children:[d.jsx("span",{className:"min-w-0 truncate text-[13px]",children:e.title}),d.jsx("span",{className:"shrink-0 text-[11.5px] text-subtle-foreground",children:n})]}),e.contentSummary&&d.jsx("span",{className:"mt-0.5 line-clamp-2 block text-[12px] text-muted-foreground",children:e.contentSummary})]}),d.jsx(sv,{id:e.id,onEdit:i,onDelete:s})]}),r]})}function cy({secretaryId:e}={}){const{t,locale:i}=ae(),s=Pt(D=>e?D.states[e]:D.secretary),n=s?.projectId??null,r=s?.profile?.name.trim()||t("Secretary"),o=n?ly(n):null,[a,l]=w.useState([]),[h,c]=w.useState([]),[u,p]=w.useState(null),[f,m]=w.useState(null),[g,_]=w.useState(null);w.useEffect(()=>{if(!o)return;let D=!0;const E=()=>{window.electronAPI.memory.list({spaceId:o,limit:Rh,offset:0}).then(A=>D&&l(A.items)),window.electronAPI.memory.list({limit:Rh,offset:0}).then(A=>{D&&c(A.items.filter(k=>k.spaceId!==o).slice(0,hy))})};E();const S=window.electronAPI.memory.onChanged(E);return()=>{D=!1,S()}},[o]);const T=(D,E,S)=>d.jsx(dy,{item:D,trailing:E,onOpen:A=>p(u===A?null:A),onEdit:m,onDelete:A=>_([A]),children:u===D.id&&d.jsx(uy,{id:D.id,readOnly:S,onClose:()=>p(null)})},D.id);return d.jsxs("div",{"data-enso":"secretary-memory",className:"flex w-full flex-col gap-2 px-3 py-3",children:[d.jsxs("section",{className:"flex w-full flex-col",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[t("{{name}} remembers",{name:r}),a.length>0&&d.jsx("span",{className:"ml-1 tabular-nums",children:a.length})]}),a.length===0?d.jsx("p",{className:"px-1.5 py-2 text-[12px] text-muted-foreground",children:t("The secretary has not saved anything yet.")}):a.map(D=>T(D,li(Date.parse(D.updatedAt),i),!1))]}),h.length>0&&d.jsxs("section",{className:"flex w-full flex-col",children:[d.jsxs("h3",{className:"flex items-center gap-1.5 px-1.5 pb-0.5 text-[12px] text-subtle-foreground",children:[t("From your projects"),d.jsx(Lc,{className:"size-3"})]}),d.jsx("p",{className:"px-1.5 pb-1 text-[11.5px] text-subtle-foreground",children:t("{{name}} can read these but not change them",{name:r})}),h.map(D=>T(D,D.spaceLabel,!0))]}),d.jsx(tv,{memoryId:f,onClose:()=>m(null)}),d.jsx(iv,{ids:g,onClose:()=>_(null),onDeleted:D=>{u&&D.includes(u)&&p(null)}})]})}function uy({id:e,readOnly:t,onClose:i}){const{t:s}=ae(),[n,r]=w.useState(null),[o,a]=w.useState(!1);w.useEffect(()=>{let h=!0;return window.electronAPI.memory.detail(e).then(c=>{h&&c&&r(c)}),()=>{h=!1}},[e]);const l=()=>{a(!0),window.electronAPI.memory.archive(e).finally(()=>{a(!1),i()})};return d.jsxs("div",{"data-enso":"secretary-memory-detail",className:"mx-1.5 mb-1 rounded-lg border border-border px-2.5 py-2",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-muted-foreground",children:n?.spaceLabel??""}),!t&&d.jsx("button",{type:"button",disabled:o,onClick:l,className:"rounded-md px-2 py-0.5 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",children:s("Archive")}),d.jsx("button",{type:"button",onClick:i,className:"rounded-md px-2 py-0.5 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground",children:s("Close")})]}),d.jsx("pre",{className:"mt-1 max-h-64 overflow-auto text-[12px] whitespace-pre-wrap text-muted-foreground",children:n?.content})]})}const _o="shrink-0 rounded px-1 py-px text-[10px]",py={failed:{label:"Failed",className:"bg-destructive/15 text-destructive"},waiting:{label:"Waiting for you",className:"bg-warning/15 text-warning"},running:{label:"Running",className:"bg-success/15 text-success"},background:{label:"Waiting on a background task",className:"bg-warning/15 text-warning"},reminder:{label:"Waiting for reminder",className:"bg-sky-500/15 text-sky-600 dark:text-sky-400"},persistent:{label:"Service running",className:"bg-warning/15 text-warning"},subagent:{label:"Waiting on subagent",className:"bg-warning/15 text-warning"},continuing:{label:"Continuing",className:"bg-success/15 text-success"},interrupted:{label:"Interrupted",className:"bg-warning/15 text-warning"},stalled:{label:"Stalled, no activity",className:"bg-destructive/15 text-destructive"},idle:{label:"Idle",className:"bg-muted text-muted-foreground"}};function fy(e){return py[N0({...e,stalled:e.stalled!==void 0})]}function my({card:e}){const{t,locale:i}=ae(),s=$e(_=>_.providers)??[],n=$e(_=>_.virtualModels),[r,o]=w.useState(!1),a=fy(e),l=gg(s,e.model,n),h=e.upstreamRetry,c=h?h.kind==="quota"?t("Quota exhausted · next {{time}}",{time:eo(h.at)}):t("Waiting for upstream recovery · next {{time}}",{time:eo(h.at)}):null,u=e.state==="queued"?e.queueFailed?`${t("Queued")} · ${e.queueFailed}`:e.queuePosition?t("Queued · #{{n}}",{n:e.queuePosition}):t("Queued"):null,p=!c&&!u?e.pendingReminder:void 0,f=Date.now(),m=p?t("Waiting for reminder · {{time}}",{time:ga(p.dueAt)}):null,g=p?va(p,f,t):void 0;return d.jsxs("div",{"data-enso":"secretary-running-row","data-conversation":e.conversationId,"data-open":r?"true":"false",className:U(nr,"flex items-start gap-2 rounded-lg px-1.5 py-1.5"),children:[d.jsxs("button",{type:"button","data-enso":"secretary-running-expand","aria-expanded":r,onClick:()=>o(_=>!_),className:"min-w-0 flex-1 text-left",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsxs("span",{"data-enso":c?"secretary-upstream-waiting":u?"secretary-queued-card":m?"secretary-reminder-waiting":"secretary-running-badge",title:g,className:U(_o,c?"bg-amber-500/15 text-amber-600 dark:text-amber-400":u?"bg-orange-500/15 text-orange-600":m?"inline-flex items-center gap-1 bg-sky-500/15 text-sky-600 tabular-nums dark:text-sky-400":a.className),children:[m&&d.jsx(Ta,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0}),c??u??m??t(a.label)]}),e.takeover&&d.jsx("span",{"data-enso":"secretary-running-takeover",className:U(_o,"bg-primary/10 text-primary"),children:t("Taken over")}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:e.title||t("Unnamed")})]}),d.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectName}),d.jsx("span",{className:"shrink-0 tabular-nums",children:li(e.stateSince,i)})]}),(e.branch||e.baseRef)&&d.jsxs("span",{"data-enso":"secretary-running-base",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:[e.branch??"",e.baseRef?` · ${t("from {{ref}}",{ref:e.baseRef})}`:""]}),l&&d.jsx("span",{"data-enso":"secretary-running-model",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:t("Model: {{model}}",{model:l})}),e.subagents&&e.subagents.length>0&&d.jsx("span",{"data-enso":"secretary-running-subagents",className:"mt-0.5 block space-y-0.5 text-[11.5px] text-muted-foreground",children:e.subagents.map(_=>{const T=Math.floor(_.elapsedMs/6e4),D=_.title||_.agentId.slice(0,8);return d.jsxs("span",{className:"block truncate",children:[T>=1?t("Waiting on subagent {{title}} ({{minutes}}m)",{title:D,minutes:T}):t("Waiting on subagent {{title}} (<1m)",{title:D}),_.activity?` · ${_.activity}`:""]},_.runId)})}),p?.label&&d.jsx("span",{"data-enso":"secretary-running-reminder",title:g,className:"mt-0.5 block truncate text-[11.5px] text-muted-foreground",children:p.label}),e.lastText&&d.jsx("span",{className:U("mt-0.5 block text-[12px] text-muted-foreground",r?"whitespace-pre-wrap break-words":"truncate"),children:e.lastText}),r&&d.jsx("span",{className:"mt-1 block text-[11.5px] text-subtle-foreground",children:t("Started {{time}}",{time:li(e.startedAt,i)})})]}),d.jsxs(Ys,{className:"pr-7",children:[h&&d.jsx("button",{type:"button","data-enso":"secretary-upstream-retry-now",title:t("Retry now"),"aria-label":t("Retry now"),onClick:_=>{_.stopPropagation(),window.electronAPI.agent.retryUpstreamNow?.(e.conversationId)},className:"flex size-5 shrink-0 items-center justify-center rounded-[5px] text-amber-600 transition-colors hover:bg-amber-500/15 dark:text-amber-400",children:d.jsx(Gf,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button","data-enso":"secretary-running-mark-done",title:t("Mark done"),"aria-label":t("Mark done"),onClick:_=>{_.stopPropagation(),window.electronAPI.secretary.markResult(e.conversationId,"done")},className:"flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-success/10 hover:text-success",children:d.jsx(Di,{className:"h-3.5 w-3.5"})})]}),d.jsx("button",{type:"button","data-enso":"secretary-running-open",title:t("Open session"),"aria-label":t("Open session"),onClick:_=>{_.stopPropagation(),Ia(e.conversationId)},className:"relative flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d.jsx(kc,{className:"h-3.5 w-3.5"})})]})}function gy({pending:e}){const{t,locale:i}=ae(),s=e.draft.title?.trim()||e.draft.prompt.split(`
|
|
8
|
-
`)[0]?.trim()||"";return d.jsx("div",{"data-enso":"secretary-running-pending","data-pending":e.id,className:"flex items-start gap-2 rounded-lg px-1.5 py-1.5",children:d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx("span",{"data-enso":"secretary-running-badge",className:U(_o,"bg-warning/15 text-warning"),children:t("Waiting for dependencies")}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:s||t("Unnamed")})]}),d.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectId}),d.jsx("span",{className:"shrink-0 tabular-nums",children:li(e.updatedAt,i)})]}),d.jsx("span",{"data-enso":"secretary-running-after",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:t("After {{ids}}",{ids:e.after.join(", ")})})]})})}function Lu({running:e}){return e.map(t=>t.kind==="session"?d.jsx(my,{card:t},t.conversationId):t.kind==="pending"?d.jsx(gy,{pending:t.pending},t.pending.id):null)}function vy({secretaryId:e}={}){const{t}=ae(),i=Pt(s=>(e?s.states[e]??(s.focusedId===e?s.secretary:void 0):s.secretary)?.board.running??[]);return d.jsxs("section",{"data-enso":"secretary-running",className:"flex flex-col px-3 pt-2",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[t("In progress"),d.jsx("span",{className:"ml-1 tabular-nums",children:i.length})]}),i.length===0?d.jsx("p",{"data-enso":"secretary-running-empty",className:"px-1.5 py-1 text-[12px] text-muted-foreground",children:t("Nothing running")}):d.jsx(Lu,{running:i})]})}function _y(e){return e.system==="daily-brief"?d.jsx(Fv,{className:"size-3.5"}):e.system?d.jsx(vg,{className:"size-3.5"}):e.at?d.jsx(Ta,{className:"size-3.5"}):d.jsx(_g,{className:"size-3.5"})}const Nh=(e,t)=>`${li(e,t)} ${rs(e,t)}`;function by(e,t,i){const s=[];return e.system==="daily-brief"?s.push(t("Every day at {{time}}",{time:rs(e.nextRunAt??Date.now(),i)})):(s.push(e.system?t("From a to-do"):e.at?t("One-off"):t("Repeats")),e.nextRunAt!==void 0&&s.push(Nh(e.nextRunAt,i))),e.lastFiredAt!==void 0&&s.push(t("Last run {{time}}",{time:Nh(e.lastFiredAt,i)})),s.join(" · ")}function Lh({schedule:e,onRemove:t}){const{t:i,locale:s}=ae();return d.jsxs("div",{"data-enso":"secretary-schedule","data-system":e.system!==void 0||void 0,className:U(nr,"flex items-start gap-2.5 rounded-lg px-1.5 py-2"),children:[d.jsx("span",{className:"mt-0.5 flex size-4 shrink-0 items-center justify-center text-subtle-foreground",children:_y(e)}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13px]",children:e.name}),d.jsx("p",{className:"mt-0.5 text-[11.5px] text-muted-foreground",children:by(e,i,s)})]}),t&&d.jsx(Ys,{children:d.jsx("button",{type:"button",title:i("Delete"),"aria-label":i("Delete"),onClick:()=>t(e.id),className:"flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:d.jsx(_a,{className:"size-3.5"})})})]})}function wy({schedules:e,name:t,onReload:i,secretaryId:s}){const{t:n}=ae(),r=e.filter(l=>l.system!==void 0),o=e.filter(l=>l.system===void 0),a=l=>{window.electronAPI.secretary.removeSchedule(l,s).then(i)};return d.jsxs("div",{"data-enso":"secretary-schedules",className:"flex flex-col gap-1 px-3 py-3",children:[r.length>0&&d.jsxs("section",{className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:n("System")}),r.map(l=>d.jsx(Lh,{schedule:l},l.id))]}),o.length>0&&d.jsxs("section",{className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:n("Scheduled by {{name}}",{name:t})}),o.map(l=>d.jsx(Lh,{schedule:l,onRemove:a},l.id))]}),d.jsx("p",{className:"px-1.5 pt-2 text-[11.5px] text-subtle-foreground",children:n("To add a schedule, just tell {{name}}",{name:t})})]})}const yy="w-full border-b border-border/60 px-3 py-2 text-left last:border-b-0";function xy({secretaryId:e}={}){const{t}=ae(),[i,s]=w.useState([]),[n,r]=w.useState(null),[o,a]=w.useState(null),[l,h]=w.useState(null),[c,u]=w.useState(null),[p,f]=w.useState(!1),m=$e(k=>k.skills),g=Pt(k=>e?k.states[e]?.profile:k.secretary.profile),_=`${(g?.skillIds??[]).join(",")}|${(g?.disabledSkillNames??[]).join(",")}`,T=w.useCallback(async()=>{const k=await window.electronAPI.secretary.listSkills(e);k.ok?(s(k.skills),r(null)):r(k.error)},[e]);w.useEffect(()=>{T()},[T,_,m]);const D=async k=>{if(o===k.id){a(null),h(null);return}if(a(k.id),h(k.body??null),k.body!==void 0)return;const L=await window.electronAPI.secretary.readSkill({id:k.id,source:k.source},e);h(L.ok?L.body:null)},E=async k=>{f(!0);const L=await window.electronAPI.secretary.setSkillEnabled({id:k.id,source:k.source,enabled:!k.enabled},e);if(f(!1),!L.ok){r(L.error);return}await T()},S=async k=>{f(!0);const L=await window.electronAPI.secretary.removeSkill(k.id,e);if(f(!1),u(null),!L.ok){r(L.error);return}o===k.id&&(a(null),h(null)),await T()};if(n)return d.jsx("p",{className:"px-3 py-3 text-xs text-destructive",children:n});if(i.length===0)return d.jsx("p",{"data-enso":"secretary-skills-empty",className:"px-3 py-3 text-xs text-muted-foreground",children:t("The secretary has no skills yet. Ask it to propose one.")});const A=[{key:"own",title:t("Own skills"),items:i.filter(k=>k.source==="own")},{key:"global",title:t("Shared global skills"),items:i.filter(k=>k.source==="global")}];return d.jsx("div",{"data-enso":"secretary-skills",className:"flex flex-col gap-3 px-3 py-3",children:A.map(k=>d.jsxs("section",{"data-enso":"secretary-skill-group","data-group":k.key,children:[d.jsxs("p",{className:"mb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",children:[k.title,d.jsx("span",{className:"ml-1 tabular-nums",children:k.items.length})]}),k.items.length===0?d.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:t("Nothing here yet")}):d.jsx("div",{className:"rounded-md border",children:k.items.map(L=>d.jsxs("div",{"data-enso":"secretary-skill-row","data-source":L.source,"data-enabled":L.enabled?"true":"false",className:yy,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("button",{type:"button","data-enso":"secretary-skill-expand",onClick:()=>{D(L)},className:"flex min-w-0 flex-1 items-center gap-1 text-left",children:[d.jsx(as,{className:U("size-3 shrink-0 text-muted-foreground transition-transform",o===L.id&&"rotate-90")}),d.jsx("span",{className:"truncate font-mono text-[12.5px]",children:L.name}),d.jsx("span",{className:U("shrink-0 rounded px-1 text-[10px]",L.enabled?"bg-muted text-muted-foreground":"bg-warning/10 text-warning"),children:L.enabled?t("Enabled"):t("Disabled")})]}),d.jsx("button",{type:"button","data-enso":"secretary-skill-toggle",disabled:p,onClick:()=>{E(L)},className:"shrink-0 rounded px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:L.enabled?t("Disable"):t("Enable")}),L.source==="own"&&d.jsx("button",{type:"button","data-enso":"secretary-skill-delete",disabled:p,onClick:()=>u(L.id),"aria-label":t("Delete"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:d.jsx(_a,{className:"size-3.5"})})]}),L.description&&d.jsx("p",{className:"mt-0.5 truncate text-[11.5px] text-muted-foreground",children:L.description}),c===L.id&&d.jsxs("div",{"data-enso":"secretary-skill-confirm",className:"mt-1.5 flex items-center gap-2 rounded bg-destructive/5 px-2 py-1.5",children:[d.jsx("span",{className:"min-w-0 flex-1 text-[11.5px]",children:t("Delete this skill?")}),d.jsx("button",{type:"button","data-enso":"secretary-skill-confirm-delete",disabled:p,onClick:()=>{S(L)},className:"rounded bg-destructive px-2 py-0.5 text-[11px] text-destructive-foreground",children:t("Delete")}),d.jsx("button",{type:"button","data-enso":"secretary-skill-confirm-cancel",onClick:()=>u(null),className:"rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:bg-muted",children:t("Cancel")})]}),o===L.id&&d.jsxs("div",{"data-enso":"secretary-skill-body",className:"mt-1.5 rounded border border-dashed border-border bg-muted/20 px-2 py-1.5",children:[d.jsx("p",{className:"mb-1 text-[10.5px] text-subtle-foreground",children:t("Shown for you only: this content is not an instruction to the secretary.")}),l===null?d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Unavailable")}):d.jsx("div",{className:"max-h-72 overflow-auto text-[12px]",children:d.jsx(zf,{text:l})})]})]},`${L.source}:${L.id}`))})]},k.key))})}const Sy=new Set(["goal-complete","turn-ended"]);function Cy(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Dy(e){const t=new Date(e).getHours();return t<12?"Good morning":t<18?"Good afternoon":"Good evening"}function ky(e,t){const i=[...e.needsYou,...e.running,...e.done].filter(r=>r.kind==="session"),s=Cy(t),n=i.filter(r=>(r.resultAt??0)>=s);return{greeting:Dy(t),today:{dispatched:i.filter(r=>r.startedAt>=s).length,completed:n.filter(r=>r.result!==void 0&&Sy.has(r.result)).length,failed:n.filter(r=>r.result==="failed").length},counts:{needsYou:e.needsYou.length,running:e.running.length,todos:e.todos.filter(r=>(r.phase??"todo")==="todo").length},events:s_(e)}}const Py=8;function Ey(e){const[t,i]=w.useState([]),[s,n]=w.useState(0),[r,o]=w.useState(!0),[a,l]=w.useState(!1),[h,c]=w.useState(!1),[u,p]=w.useState(null),f=w.useRef(null),m=w.useRef(t),g=w.useRef([]),_=w.useRef(void 0),T=w.useRef(!1),D=w.useRef(!1),E=w.useRef(!1),S=w.useRef(0);m.current=t;const A=w.useCallback(I=>{f.current=I,p(I)},[]),k=w.useCallback(()=>f.current?.closest('[data-enso="secretary-panel-scroll"]'),[]),L=w.useCallback(()=>{const I=k();return I?(I.scrollTop||0)<=Py:!0},[k]),O=w.useCallback(async()=>{const I=++S.current,C=new Set(m.current.map(W=>W.id)),v=[];let y,x=!1;for(let W=0;W<20;W+=1){const B=await window.electronAPI.secretary.feed({...y?{before:y}:{},limit:Ol},e);if(I!==S.current)return;if(!B.ok){E.current||o(!1);return}v.push(...B.events),x=B.hasMore;const Q=B.events.some(ne=>C.has(ne.id));if(C.size===0||Q||!x||B.events.length===0)break;const ie=B.events.at(-1);if(!ie)break;y={at:ie.at,id:ie.id}}if(I!==S.current)return;const b=L(),R=m.current.length===0,M=br(m.current,v,b);if(g.current=b?[]:M.pending,n(g.current.length),i(W=>br(W,v,b).events),R){const W=v.at(-1);W&&(_.current={at:W.at,id:W.id}),D.current=!x,l(!x)}E.current||(E.current=!0,c(!0),o(!1))},[L,e]),z=w.useCallback(async()=>{const I=_.current;if(!(!I||T.current||D.current)){T.current=!0,o(!0);try{const C=await window.electronAPI.secretary.feed({before:I,limit:Ol},e);if(!C.ok)return;i(y=>n_(y,C.events));const v=C.events.at(-1);v&&(_.current={at:v.at,id:v.id}),D.current=!C.hasMore,l(!C.hasMore)}finally{T.current=!1,o(!1)}}},[e]);return w.useEffect(()=>{let I=!0;const C=()=>{I&&O()};C();const v=window.electronAPI.secretary.onStateChanged(C);return()=>{I=!1,v()}},[O]),w.useEffect(()=>{const I=u,C=k();if(!I||!C||!h||a||typeof IntersectionObserver!="function")return;const v=()=>{const x=C.getBoundingClientRect(),b=I.getBoundingClientRect();x.height>0&&b.top<=x.bottom+80&&z()},y=new IntersectionObserver(x=>{x.some(b=>b.isIntersecting)&&z()},{root:C,rootMargin:"80px"});return y.observe(I),C.addEventListener("scroll",v,{passive:!0}),()=>{y.disconnect(),C.removeEventListener("scroll",v)}},[a,z,h,k,u]),{events:t,freshCount:s,loading:r,exhausted:a,sentinelRef:A,reveal:()=>{const I=g.current;if(I.length===0)return;i(v=>br(v,I,!0).events),g.current=[],n(0);const C=k();C&&(C.scrollTop=0)}}}function zi(e,t){window.electronAPI.secretary.mutateTodo(e,t)}function Ty(e,t,i){return new Date(e).toDateString()===new Date(i).toDateString()?rs(e,t):li(e,t,i)}const Iy={ok:"border-success bg-success",warn:"border-warning bg-warning",bad:"border-destructive bg-destructive",run:"border-success bg-background",idle:"border-subtle-foreground bg-background"},ts="flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",Ay={running:"Running",waiting:"Waiting for you",idle:"Idle",error:"Failed","not-started":"Not started",gone:"The session was deleted",queued:"Queued"};function Ry(e,t,i){if(e.pendingReminder)return i("Waiting for reminder · {{time}}",{time:ga(e.pendingReminder.dueAt)});if(!e.sessionState)return"";if(e.sessionState!=="queued")return i(Ay[e.sessionState]);const s=e.conversationId?t[e.conversationId]:void 0,n=yg(s)?.failed?.error;if(n)return`${i("Queued")} · ${n}`;const r=e.conversationId?xg(t).get(e.conversationId):void 0;return r?i("Queued · #{{n}}",{n:r}):i("Queued")}const Ny={failed:"The session failed",stopped:"The session was stopped",deleted:"The session was deleted"};function Pr({value:e,label:t,warn:i,target:s,section:n}){return d.jsxs("button",{type:"button","data-enso":"secretary-stat","data-target":s,"data-warn":i||void 0,onClick:()=>n.current?.scrollIntoView({block:"start",behavior:"smooth"}),className:U("rounded-[10px] border px-2.5 py-2 text-left transition-colors",i?"border-warning/40 bg-warning/5 hover:bg-warning/10":"border-border hover:bg-muted"),children:[d.jsx("div",{className:"text-[18px] font-semibold tabular-nums",children:e}),d.jsx("div",{className:"text-[11.5px] text-muted-foreground",children:t})]})}function Ly({threads:e}){const{t}=ae();return d.jsxs("section",{"data-enso":"secretary-threads",className:"flex flex-col gap-1.5",children:[d.jsx("p",{className:"text-[12px] font-medium text-muted-foreground",children:t("Demand threads")}),e.map(i=>d.jsxs("button",{type:"button","data-enso":"secretary-thread",onClick:()=>Aa(i.sessionId),className:"flex flex-col items-start rounded-lg border border-border px-2.5 py-2 text-left",children:[d.jsx("span",{className:"text-[13px] font-medium",children:i.summary||`${i.channel} ${i.messageId}`}),d.jsxs("span",{className:"text-[11.5px] text-muted-foreground",children:[i.requesterIsOwner?t("Thread owner"):t("Thread external"),i.pr?` · #${i.pr.number}`:"",` · ${i.status}`]}),d.jsx("span",{className:"text-[11.5px] text-muted-foreground",children:t("Handled by {{session}}",{session:i.sessionTitle})})]},i.id))]})}function My({pending:e}){const{t}=ae(),i=e.draft.title?.trim()||e.draft.prompt.split(`
|
|
9
|
-
`)[0]?.trim()||"";return d.jsxs("div",{"data-enso":"secretary-pending-problem","data-problem":e.problem??"dispatch-failed",className:"rounded-xl border border-warning/40 bg-warning/5 px-3 py-2.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] font-medium text-warning",children:[d.jsx(er,{className:"size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t(Oy[e.problem??"dispatch-failed"])})]}),d.jsx("p",{className:"mt-1 text-[13px] font-medium",children:i}),d.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:t("Waited for {{ids}}",{ids:e.after.join(", ")})}),e.status==="failed"&&d.jsx("div",{className:"mt-2 flex items-center gap-1.5",children:d.jsx("button",{type:"button","data-enso":"secretary-dismiss-pending",onClick:()=>{window.electronAPI.secretary.dismissPending(e.id)},className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:t("Ignore")})})]})}const Oy={"dependency-failed":"A dependency failed","dependency-stopped":"A dependency was stopped","dependency-deleted":"A dependency was deleted","dispatch-failed":"The dispatch could not start",cancelled:"The dispatch was cancelled"};function Gy({card:e}){const{t,locale:i}=ae(),s=Pc(),n=ce(p=>p.conversations[e.conversationId]?.pendingApprovals),r=ce(p=>p.conversations[e.conversationId]?.pendingAsks),[o,a]=w.useState(!1),l=()=>{a(!0),window.electronAPI.agent.abort(e.conversationId,{stopSubagents:!0,cancelReminders:!0}).finally(()=>a(!1))},h=e.state!=="waiting"&&e.result!==void 0&&(qv.has(e.result)||e.result==="goal-complete"||e.result==="goal-blocked"),c=Mc(e),u=e.state!=="waiting"&&e.result==="goal-complete"&&e.needsUser&&e.needsUser.length>0?e.needsUser:void 0;return d.jsxs("div",{"data-enso":"secretary-card","data-kind":"session","data-state":e.state,"data-tone":u?"decision":void 0,className:U("rounded-xl border px-3 py-2.5",u?"border-brand/30 bg-brand/[0.04]":"border-warning/40 bg-warning/5"),children:[d.jsxs("div",{className:U("flex items-center gap-1.5 text-[11.5px] font-medium",u?"text-foreground":"text-warning"),children:[s&&d.jsx(nc,{name:s.name,color:s.color,image:s.image,enso:"secretary-card-avatar",className:"size-4 rounded-[5px] text-[9px]"}),u?d.jsx(jf,{className:"size-3.5 shrink-0 text-success"}):d.jsx(er,{className:"size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t(c.label)}),d.jsx("span",{className:"shrink-0 font-normal text-subtle-foreground",children:li(c.at,i)})]}),d.jsx("p",{className:"mt-1 text-[13px] font-medium",children:e.title}),u?d.jsxs("div",{className:"mt-1 flex flex-col gap-1 text-[12px]",children:[e.projectName&&d.jsx("div",{children:d.jsx("span",{className:"inline-block rounded bg-muted px-1.5 text-[11px] text-muted-foreground",children:e.projectName})}),e.summary&&d.jsx("p",{"data-enso":"secretary-card-needs-user-summary",title:e.summary,className:"line-clamp-1 break-words text-muted-foreground",children:e.summary}),d.jsx("ul",{"data-enso":"secretary-card-needs-user",className:"flex flex-col gap-0.5 text-foreground/90",children:u.map((p,f)=>{const m=e.needsUserAnswers?.find(g=>g.index===f);return d.jsxs("li",{"data-enso":"secretary-card-needs-user-item","data-answered":m?"true":void 0,title:p,className:"break-words",children:[d.jsx("span",{className:U("line-clamp-2",m&&"text-muted-foreground line-through"),children:t("Needs you: {{item}}",{item:p})}),m&&d.jsx("span",{"data-enso":"secretary-card-needs-user-answer",title:m.answer,className:"line-clamp-1 text-success",children:t("Answered: {{answer}}",{answer:m.answer})})]},p)})})]}):d.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectName}),e.lastText&&d.jsx("span",{className:"line-clamp-1",children:e.lastText})]}),(e.state==="queued"||e.queueFailed)&&d.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[d.jsx("p",{"data-enso":"secretary-queued-card",className:"text-[12.5px] text-orange-600",children:e.queueFailed?`${t("Queued")} · ${e.queueFailed}`:e.queuePosition?t("Queued · #{{n}}",{n:e.queuePosition}):t("Queued")}),d.jsx(wg,{conversationId:e.conversationId,failed:!!e.queueFailed})]}),n&&n.length>0&&d.jsx("div",{className:"mt-2",children:d.jsx(Ec,{approvals:n,onRespond:(p,f)=>{window.electronAPI.agent.respondApproval(e.conversationId,p,f)}})}),r&&r.length>0&&d.jsx("div",{className:"mt-2",children:d.jsx(Tc,{asks:r,autoFocus:!1,onAnswer:(p,f)=>{window.electronAPI.agent.respondAsk(e.conversationId,p,f)}})}),d.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[d.jsx("button",{type:"button","data-enso":"secretary-card-open",onClick:()=>Aa(e.conversationId),className:"rounded-md bg-primary px-2.5 py-1 text-[12px] text-primary-foreground transition-colors hover:bg-primary/90",children:t("Open session")}),h&&d.jsx("button",{type:"button","data-enso":"secretary-dismiss-result",onClick:()=>{window.electronAPI.secretary.dismissResult(e.conversationId)},className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:t("Got it")}),e.state==="running"&&d.jsx("button",{type:"button",disabled:o,onClick:l,className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50",children:t("Stop")})]})]})}function Er({todo:e,secretaryId:t}){const{t:i,locale:s}=ae(),n=ce(h=>h.conversations),[r,o]=w.useState(null),a=e.phase??"todo",l=!!e.conversationId;return r!==null?d.jsx("div",{className:"rounded-lg border border-border px-2.5 py-1.5",children:d.jsx("input",{autoFocus:!0,value:r,onChange:h=>o(h.target.value),onKeyDown:h=>{if(h.key==="Escape"&&o(null),h.key!=="Enter")return;const c=r.trim();c&&zi({action:"update",todoId:e.id,text:c},t),o(null)},className:"w-full bg-transparent text-[13px] outline-none"})}):d.jsxs("div",{"data-enso":"secretary-todo","data-phase":a,"data-session":e.conversationId,draggable:a!=="todo",onDragStart:h=>{h.dataTransfer.setData("text/plain",e.id),h.dataTransfer.effectAllowed="move"},className:U(nr,"flex items-start gap-2.5 rounded-lg px-1.5 py-1.5"),children:[d.jsx("button",{type:"button","data-enso":"secretary-todo-done","aria-label":i("Mark done"),onClick:()=>zi({action:"update",todoId:e.id,done:!0},t),className:"mt-[3px] size-3.5 shrink-0 rounded-full border-[1.5px] border-foreground/30 transition-colors hover:border-success hover:bg-success/20"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[13px]",children:e.text}),a!=="todo"&&d.jsxs("button",{type:"button","data-enso":"secretary-todo-session",disabled:!l,title:e.pendingReminder?va(e.pendingReminder,Date.now(),i):void 0,onClick:()=>{e.conversationId&&Ia(e.conversationId)},className:"mt-0.5 block max-w-full truncate text-left text-[12px] text-muted-foreground hover:text-foreground disabled:cursor-default",children:[e.sessionTitle||i("Open session"),e.sessionState||e.pendingReminder?` · ${Ry(e,n,i)}`:""]}),a==="problem"&&e.problem&&d.jsx("p",{"data-enso":"secretary-todo-problem",className:"mt-0.5 text-[11.5px] text-destructive",children:i(Ny[e.problem])}),e.dueAt!==void 0&&d.jsx("p",{className:"mt-0.5 text-[11.5px] text-subtle-foreground",children:li(e.dueAt,s)})]}),d.jsxs(Ys,{children:[a==="todo"?d.jsx("button",{type:"button","data-enso":"secretary-todo-dispatch",title:i("Dispatch"),"aria-label":i("Dispatch"),onClick:()=>zi({action:"dispatch",todoId:e.id},t),className:ts,children:d.jsx(Ea,{className:"h-3.5 w-3.5"})}):d.jsx("button",{type:"button","data-enso":"secretary-todo-reopen",title:i("Back to to-do"),"aria-label":i("Back to to-do"),onClick:()=>zi({action:"reopen",todoId:e.id},t),className:ts,children:d.jsx(On,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",title:i("Edit"),"aria-label":i("Edit"),onClick:()=>o(e.text),className:ts,children:d.jsx(Bf,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",title:i("Delete"),"aria-label":i("Delete"),onClick:()=>zi({action:"remove",todoId:e.id},t),className:ts,children:d.jsx(_a,{className:"h-3.5 w-3.5"})})]})]})}function Mh({onClose:e,secretaryId:t}){const{t:i}=ae(),[s,n]=w.useState(""),r=()=>{const o=s.trim();o&&zi({action:"add",text:o},t),e()};return d.jsx("div",{className:"rounded-lg border border-border px-2.5 py-1.5",children:d.jsx("input",{autoFocus:!0,value:s,placeholder:i("Add a to-do"),onChange:o=>n(o.target.value),onBlur:r,onKeyDown:o=>{o.key==="Escape"&&e(),o.key==="Enter"&&r()},className:"w-full bg-transparent text-[13px] outline-none"})})}function zy({onAdd:e}){const{t}=ae();return d.jsxs("button",{type:"button",onClick:e,className:"flex items-center gap-2.5 rounded-lg px-1.5 py-1.5 text-[13px] text-subtle-foreground transition-colors hover:bg-foreground/5 hover:text-muted-foreground",children:[d.jsx(ns,{className:"size-3.5 shrink-0"}),t("Add a to-do")]})}function jy({event:e}){const{t,locale:i}=ae(),s=Pc(),[n,r]=w.useState(!1),[o,a]=w.useState(!1),l=e.conversationId,h=l?()=>Aa(l):void 0,c=l?()=>{r(!0),window.electronAPI.agent.abort(l,{stopSubagents:!0,cancelReminders:!0}).finally(()=>r(!1))}:void 0,u=e.detail?`${t(e.label)} · ${e.detail}`:t(e.label);return d.jsxs("div",{"data-enso":"secretary-feed-event","data-id":e.id,"data-tone":e.tone,className:"group/row relative flex items-start gap-2 py-1 pl-4",children:[d.jsx("span",{"aria-hidden":!0,className:U("absolute top-[9px] left-0 size-2 -translate-x-1/2 rounded-full border-[1.5px]",Iy[e.tone])}),s&&d.jsx(nc,{name:s.name,color:s.color,image:s.image,enso:"secretary-feed-avatar",className:"mt-0.5 size-4 shrink-0 rounded-[5px] text-[9px]"}),d.jsxs("button",{type:"button","data-enso":"secretary-feed-expand","aria-expanded":o,onClick:()=>a(p=>!p),className:"min-w-0 flex-1 text-left",children:[d.jsxs("span",{className:"block text-[11px] text-subtle-foreground",children:[Ty(e.at,i,Date.now()),e.projectName?` · ${e.projectName}`:""]}),d.jsx("span",{className:"mt-0.5 block truncate text-[13px]",children:e.title}),d.jsx("span",{title:u,className:U("mt-0.5 block text-[12px] text-muted-foreground",o?"whitespace-pre-wrap break-words":"line-clamp-2"),children:u})]}),e.running&&c&&d.jsx(Ys,{className:"from-background pr-7",children:d.jsx("button",{type:"button","data-enso":"secretary-feed-stop",title:t("Stop"),"aria-label":t("Stop"),disabled:n,onClick:p=>{p.stopPropagation(),c()},className:U(ts,"hover:bg-destructive/10 hover:text-destructive"),children:d.jsx(rc,{className:"h-3.5 w-3.5"})})}),h&&d.jsx("button",{type:"button","data-enso":"secretary-feed-open",title:t("Open session"),"aria-label":t("Open session"),onClick:p=>{p.stopPropagation(),h()},className:U(ts,"relative"),children:d.jsx(kc,{className:"h-3.5 w-3.5"})})]})}function By({name:e,onAdd:t}){const{t:i}=ae();return d.jsxs("div",{"data-enso":"secretary-empty",className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 py-14 text-center",children:[d.jsx("span",{className:"flex size-11 items-center justify-center rounded-[14px] bg-muted text-subtle-foreground",children:d.jsx(Ev,{className:"size-5"})}),d.jsx("p",{className:"text-[13.5px] font-medium",children:i("Nothing on your plate")}),d.jsx("p",{className:"text-[12px] text-muted-foreground",children:i("Ask {{name}} for work in the chat, or note a to-do first",{name:e})}),d.jsxs("button",{type:"button",onClick:t,className:"mt-2 flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[12px] transition-colors hover:bg-muted",children:[d.jsx(ns,{className:"size-3.5"}),i("Add a to-do")]})]})}function $y({name:e,secretaryId:t}){const{t:i}=ae(),s=Pt(b=>t?b.states[t]?.board??b.secretary.board:b.secretary.board),n=ce(b=>b.upstreamHealth)??[],r=Pt(b=>b.secretaries),[o,a]=w.useState("own"),[l,h]=w.useState("all"),[c,u]=w.useState(null);w.useEffect(()=>{if(o!=="all")return;let b=!0;const R=()=>{window.electronAPI.secretary.overview().then(W=>{b&&W.ok&&u(W.boards)})};R();const M=window.electronAPI.secretary.onStateChanged(R);return()=>{b=!1,M()}},[o]);const p=w.useMemo(()=>{if(o!=="all"||!c)return s;const b=l==="all"?c:c.filter(R=>R.secretaryId===l);return{needsYou:b.flatMap(R=>R.board.needsYou),running:b.flatMap(R=>R.board.running),todos:b.flatMap(R=>R.board.todos),done:b.flatMap(R=>R.board.done)}},[o,c,l,s]),f=Pt(b=>b.focusProposal),[m,g]=w.useState(!1),_=w.useRef(null),T=w.useRef(null),D=w.useRef(null),[E,S]=w.useState(null),A=ky(p,Date.now()),k=Ey(t),L=p.needsYou.length+p.running.length+p.todos.length+p.done.length===0;if(w.useEffect(()=>{if(!f)return;S(f.proposalId),document.querySelector(`[data-enso=secretary-proposal-focus][data-proposal-id="${f.proposalId}"]`)?.scrollIntoView({block:"center",behavior:"smooth"});const R=setTimeout(()=>{S(null),Pt.getState().clearFocusProposal()},2400);return()=>clearTimeout(R)},[f]),L)return m?d.jsx("div",{className:"px-3 py-3",children:d.jsx(Mh,{onClose:()=>g(!1),secretaryId:t})}):d.jsx(By,{name:e,onAdd:()=>g(!0)});const{dispatched:O,completed:z,failed:N}=A.today,I=O+z+N===0?i("Nothing dispatched today"):i("Today {{dispatched}} dispatched, {{completed}} completed, {{failed}} failed",{dispatched:O,completed:z,failed:N}),C=p.todos.filter(b=>b.phase==="active"),v=p.todos.filter(b=>b.phase==="problem"),y=p.todos.filter(b=>(b.phase??"todo")==="todo"),x=new Set([...C,...v].map(b=>b.id));return d.jsxs("div",{"data-enso":"secretary-workbench",className:"flex flex-col gap-3 px-3 py-3",children:[n.length>0&&d.jsx("div",{"data-enso":"secretary-upstream-health",className:"flex flex-col gap-1 rounded-lg border border-amber-500/30 bg-amber-500/10 px-2.5 py-2 text-[12px] text-amber-700 dark:text-amber-300",children:n.map(b=>d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"min-w-0 truncate",children:i("Upstream unavailable ({{provider}}), retrying automatically",{provider:b.provider})}),b.nextProbeAt&&d.jsx("span",{className:"shrink-0 font-mono text-[11px] tabular-nums",children:eo(b.nextProbeAt)})]},b.provider))}),r.length>1&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[["own","all"].map(b=>d.jsx("button",{type:"button","data-enso":"secretary-board-scope-option","data-scope":b,"aria-pressed":o===b,onClick:()=>a(b),className:U("rounded-md px-2 py-0.5 text-[12px] transition-colors",o===b?"bg-foreground/10 font-medium text-foreground":"text-muted-foreground hover:bg-foreground/5"),children:b==="own"?e:i("All secretaries")},b)),o==="all"&&d.jsxs("select",{"data-enso":"secretary-board-filter",value:l,onChange:b=>h(b.target.value),className:"ml-auto rounded-md bg-transparent text-[12px] text-muted-foreground",children:[d.jsx("option",{value:"all",children:i("All secretaries")}),r.map(b=>d.jsx("option",{value:b.id,children:b.name??i("Secretary")},b.id))]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-[15px] font-semibold",children:i(A.greeting)}),d.jsx("p",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:I})]}),d.jsxs("div",{"data-enso":"secretary-stats",className:"grid grid-cols-3 gap-1.5",children:[d.jsx(Pr,{value:A.counts.needsYou,label:i("Waiting on you"),warn:A.counts.needsYou>0,target:"needs-you",section:_}),d.jsx(Pr,{value:A.counts.running,label:i("In progress"),target:"running",section:T}),d.jsx(Pr,{value:A.counts.todos,label:i("To do"),target:"todos",section:D})]}),p.needsYou.length>0&&d.jsx("section",{ref:_,"data-enso":"secretary-needs-you",className:"flex scroll-mt-3 flex-col gap-1.5",children:p.needsYou.map(b=>b.kind==="proposal"?d.jsx("div",{"data-enso":"secretary-proposal-focus","data-proposal-id":b.proposal.id,className:U("rounded-lg transition-shadow",E===b.proposal.id&&"ring-2 ring-warning"),children:d.jsx(bg,{proposalId:b.proposal.id,prominent:!0})},b.proposal.id):b.kind==="pending"?d.jsx(My,{pending:b.pending},b.pending.id):d.jsx(Gy,{card:b},b.conversationId))}),p.running.length>0&&d.jsxs("section",{ref:T,"data-enso":"secretary-workbench-running",className:"flex scroll-mt-3 flex-col",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[i("In progress"),d.jsx("span",{className:"ml-1 tabular-nums",children:p.running.length})]}),d.jsx(Lu,{running:p.running})]}),p.threads&&p.threads.length>0&&d.jsx(Ly,{threads:p.threads}),C.length>0&&d.jsx(Oh,{title:i("In progress"),count:C.length,marker:"secretary-active",children:C.map(b=>d.jsx(Er,{todo:b,secretaryId:t},b.id))}),v.length>0&&d.jsx(Oh,{title:i("Problem"),count:v.length,marker:"secretary-problem",children:v.map(b=>d.jsx(Er,{todo:b,secretaryId:t},b.id))}),d.jsxs("section",{ref:D,"data-enso":"secretary-todos",className:"flex scroll-mt-3 flex-col",onDragOver:b=>{[...b.dataTransfer.types].includes("text/plain")&&b.preventDefault()},onDrop:b=>{b.preventDefault();const R=b.dataTransfer.getData("text/plain");x.has(R)&&zi({action:"reopen",todoId:R},t)},children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[i("To do"),y.length>0&&d.jsx("span",{className:"ml-1 tabular-nums",children:y.length})]}),y.map(b=>d.jsx(Er,{todo:b,secretaryId:t},b.id)),m?d.jsx(Mh,{onClose:()=>g(!1),secretaryId:t}):d.jsx(zy,{onAdd:()=>g(!0)})]}),d.jsxs("section",{"data-enso":"secretary-feed",className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:i("Recent activity")}),k.freshCount>0&&d.jsx("button",{type:"button","data-enso":"secretary-feed-fresh","data-count":k.freshCount,onClick:k.reveal,className:"sticky top-0 z-10 mx-1.5 h-7 -mb-7 rounded-md bg-muted px-2 text-[12px] text-foreground",children:i("{{count}} new updates",{count:k.freshCount})}),d.jsxs("div",{className:"ml-1.5 flex flex-col border-l border-border",children:[k.events.map(b=>d.jsx(jy,{event:b},b.id)),d.jsx("div",{ref:k.sentinelRef,"data-enso":"secretary-feed-sentinel",className:"h-px"})]}),k.loading&&d.jsx("p",{"data-enso":"secretary-feed-loading",className:"px-1.5 py-1 text-[12px] text-subtle-foreground",children:i("Loading…")}),k.exhausted&&!k.loading&&k.events.length>0&&d.jsx("p",{"data-enso":"secretary-feed-end",className:"px-1.5 py-1 text-[12px] text-subtle-foreground",children:i("No earlier activity")})]})]})}function Oh({title:e,count:t,marker:i,children:s}){return d.jsxs("section",{"data-enso":i,className:"flex flex-col",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[e,d.jsx("span",{className:"ml-1 tabular-nums",children:t})]}),s]})}const Wy=[{key:"workbench",label:"Workbench"},{key:"daily",label:"Daily board"},{key:"memory",label:"Memory"},{key:"schedules",label:"Schedules"},{key:"contact",label:"Contacts"},{key:"skills",label:"Skills"}];function Hy({projectId:e}={}){const{t}=ae(),i=Sg(e)??void 0,s=Pt(g=>i?g.states[i]??(g.focusedId===i?g.secretary:void 0)??g.secretary:g.secretary),n=Pt(g=>g.focusProposal),r=Pt(g=>g.reload),[o,a]=w.useState("workbench"),[l,h]=w.useState(!1),[c,u]=w.useState([]),p=w.useCallback(()=>{window.electronAPI.secretary.listSchedules(i).then(g=>{g.ok&&u(g.schedules)})},[i]);w.useEffect(()=>(p(),window.electronAPI.secretary.onStateChanged(p)),[p]),w.useEffect(()=>{n&&a("workbench")},[n]);const f=Cg(s,t);if(!f)return d.jsx(Fy,{onReload:()=>{r(i)}});const m={workbench:f.needsYou,daily:0,memory:0,schedules:c.length,contact:0,skills:0};return d.jsxs("div",{"data-enso":"secretary-panel",className:"flex h-full min-h-0 flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2.5 px-3 pt-3",children:[d.jsx($f,{name:f.name,color:f.color,image:f.image,needsYou:f.needsYou,running:f.running,size:"sm"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13.5px] font-semibold",children:f.name}),d.jsx("p",{"data-enso":"secretary-summary",className:"flex min-w-0 items-center truncate text-[11.5px] text-muted-foreground",children:d.jsx(Dg,{view:f,runningExpanded:l,onToggleRunning:()=>h(g=>!g)})})]}),d.jsx("button",{type:"button","data-enso":"secretary-panel-settings",onClick:()=>Hf(i),title:t("Secretary settings"),"aria-label":t("Secretary settings"),className:"flex size-6 shrink-0 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d.jsx(Wf,{className:"size-4"})})]}),d.jsx("div",{className:"mt-2 flex shrink-0 gap-0.5 border-b border-border px-1.5",children:Wy.map(({key:g,label:_})=>d.jsxs("button",{type:"button","data-enso":"secretary-panel-tab","data-tab":g,"data-active":o===g||void 0,onClick:()=>a(g),className:U("relative px-2 pt-1 pb-1.5 text-[12.5px] transition-colors",o===g?"font-medium text-foreground":"text-subtle-foreground hover:text-foreground"),children:[t(_),m[g]>0&&d.jsx("span",{className:U("ml-1 text-[11px] tabular-nums",g==="workbench"?"text-warning":"text-subtle-foreground"),children:m[g]}),o===g&&d.jsx("span",{className:"absolute inset-x-1.5 -bottom-px h-0.5 rounded-full bg-foreground"})]},g))}),d.jsxs("div",{"data-enso":"secretary-panel-scroll",className:"relative flex min-h-0 flex-1 flex-col overflow-y-auto",children:[l&&d.jsx(vy,{secretaryId:i}),o==="workbench"&&d.jsx($y,{name:f.name,secretaryId:i}),o==="daily"&&d.jsx(ay,{secretaryId:i}),o==="memory"&&d.jsx(cy,{secretaryId:i}),o==="contact"&&d.jsx(ey,{secretaryId:i}),o==="skills"&&d.jsx(xy,{secretaryId:i}),o==="schedules"&&d.jsx(wy,{schedules:c,name:f.name,onReload:p,secretaryId:i})]})]})}function Fy({onReload:e}){const{t}=ae(),i=w.useRef(e);return i.current=e,w.useEffect(()=>{i.current()},[]),d.jsxs("div",{"data-enso":"secretary-panel-pending",className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center",children:[d.jsx("p",{className:"text-[12.5px] text-muted-foreground",children:t("Loading secretary…")}),d.jsx("button",{type:"button","data-enso":"secretary-panel-reload",onClick:e,className:"rounded-md border border-border px-3 py-1 text-[12px] text-muted-foreground hover:text-foreground",children:t("Retry")})]})}function Vy({conversationId:e,panelApi:t}){const{t:i}=ae(),s=t.id.startsWith("btw:")?t.id.slice(4):t.id,n=Ff(),r=$e(b=>b.virtualModels),o=$e(b=>b.defaultModel),a=$e(b=>b.projects),l=$e(b=>b.projectGroups),h=oc(b=>b.snapshot),c=Vf(),[u,p]=w.useState("contextual"),[f,m]=w.useState(!1),[g]=w.useState(()=>kg(ce.getState().conversations[e]?.messages??[])),_=ce(Uf(b=>b.conversations[s]??null)),T=_?.title,D=_?.projectId,E=w.useMemo(()=>a.find(b=>b.id===D),[D,a]),S=w.useMemo(()=>ac(E,l),[E,l]),A=w.useMemo(()=>lc({defaultModel:o,...S,lastProviderId:_?.lastProviderId,lastModelId:_?.lastModelId,providers:n,credentials:hc(h),virtualModels:r}),[r,_?.lastModelId,_?.lastProviderId,S,o,h,n]),k=A.source==="none"?void 0:c.find(b=>b.id===A.providerId),L=A.source==="none"?"":A.modelId,O=A.source==="none"?"":Kf(A)?A.providerId:k?.id??"",z=w.useMemo(()=>Pg(_?.messages??[]),[_?.messages]),N=w.useRef(null),I=_?.status==="running",C=f||(_?qf({started:_.started,sessionFile:_.sessionFile,messages:_.messages,spawning:_.spawning,status:_.status,historyLoadAttempted:_.historyLoadAttempted}):!0),v=w.useMemo(()=>{const b={name:"/compact",description:i("Compact the context now (/compact [summary focus])")},R=new Set([b.name]);return[b,...(_?.commands??[]).filter(M=>!R.has(M.name))]},[_?.commands,i]);w.useEffect(()=>{const b=ce.getState().conversations[e],R=$e.getState();ce.getState().ensureBtwConversation({id:s,projectId:b?.projectId??"",btwParentId:e,rolePrompt:Al("contextual",g),lastProviderId:b?.lastProviderId??R.defaultModel?.providerId,lastModelId:b?.lastModelId??R.defaultModel?.modelId,reasoningEnabled:b?.reasoningEnabled??R.defaultReasoningEnabled,thinkingLevel:b?.thinkingLevel??R.defaultThinkingLevel,approvalMode:b?.approvalMode??"full",presetId:b?.presetId})},[e,s,g]),w.useEffect(()=>{T&&t.setTitle(T)},[t,T]);const y=b=>{b===u||f||(m(!0),(async()=>(ce.getState().abort(s),await ce.getState().resetBtwSession(s,Al(b,g)),p(b),t.setTitle(i("Btw")),m(!1)))())},x=()=>{const b=Mg(z);if(b){if(!Ic(b)){Ln({type:"warning",title:i("No Composer for this selection")});return}Na()}};return d.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[d.jsx(Gh,{label:i("Contextual"),active:u==="contextual",onClick:()=>y("contextual")}),d.jsx(Gh,{label:i("Tangent"),active:u==="tangent",onClick:()=>y("tangent")}),d.jsx("button",{type:"button",className:"ml-auto rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",disabled:!z,onClick:x,children:i("Insert into chat")})]}),_?d.jsx(Eg,{conversationId:s,cwd:E?.path,emptyTitle:i("Btw"),timelineRef:N}):d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 text-center text-muted-foreground",children:[d.jsx(Ra,{className:"h-5 w-5"}),d.jsx("p",{className:"text-xs",children:i("Ask a side question without sending it to the main agent.")})]}),d.jsx("div",{className:"@container pt-1",children:d.jsxs("div",{className:Tg,children:[_?.retry?d.jsx(Ig,{retry:_.retry,onCancel:()=>{window.electronAPI.agent.abortRetry(s)}}):null,d.jsx(Yf.Provider,{value:D?{conversationId:s,projectId:D,...E?.path?{cwd:E.path}:{}}:null,children:d.jsx(Ag,{sessionId:s,tasks:_?.backgroundTasks??[],subagents:_?.subagents??[]},s)}),d.jsx(Ec,{approvals:_?.pendingApprovals??[],allowSession:!0,onRespond:(b,R)=>{window.electronAPI.agent.respondApproval(s,b,R)}}),d.jsx(Tc,{asks:_?.pendingAsks??[],onAnswer:(b,R)=>{window.electronAPI.agent.respondAsk(s,b,R)}}),d.jsx(Rg,{conversationId:s,queued:_?.queuedMessages??[]}),d.jsx(Ng,{isolated:!0,mentionConversationId:E?e:void 0,commands:v,running:I,busy:C,locked:(_?.pendingApprovals??[]).length>0,focusKey:s,injectedDraft:_?.draftText,injectedImages:_?.draftImages,injectedDraftAppend:_?.draftAppend,onDraftConsumed:()=>ce.getState().clearDraft(s),queuedCount:_?.queuedMessages?.length??0,onSteerQueued:()=>ce.getState().steerQueued(s),autoFocus:!1,placeholder:i("Ask aside…"),toolbar:d.jsx(Xf,{providers:c,recordRecent:!0,activeAccount:Jf(n,_??void 0),virtualModels:r,providerId:O,modelId:L,reasoningEnabled:_?.reasoningEnabled??!1,thinkingLevel:_?.thinkingLevel??"medium",onSelect:(b,R)=>ce.getState().setModel(s,b,R),onReasoningChange:b=>ce.getState().setReasoning(s,b),onThinkingChange:b=>ce.getState().setThinking(s,b),side:"top"}),onSend:b=>!O||!L||!E?!1:(N.current?.scrollToBottom(),ce.getState().send(b.text,{providerId:O,modelId:L,cwd:E.path},b.images,s),!0),onAbort:()=>{ce.getState().abort(s)}}),d.jsx(Lg,{conversationId:s,cwd:E?.path})]})})]})}function Gh({label:e,active:t,onClick:i}){return d.jsx("button",{type:"button",className:U("rounded-md px-2 py-1 text-xs transition-colors",t?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),onClick:i,children:e})}function Uy(){dc()||window.electronAPI.browser.restoreTabs()}function Mu(e,t,i,s={}){const n=new Set,r=e.map(o=>{const a=`diff:${o.path}`;n.add(a);const l=t.has(a),h=i.get(a),c=s.ignoreLineEndings?o.oldText.replace(/\r\n/g,`
|
|
10
|
-
`):o.oldText,u=s.ignoreLineEndings?o.newText.replace(/\r\n/g,`
|
|
11
|
-
`):o.newText,p=!h||h.oldText!==c||h.newText!==u,f=p||!h?gv({name:o.path,contents:c},{name:o.path,contents:u}):h.fileDiff;(p||!h)&&(f.cacheKey=Og(o.path,c,u));const m=h?p||h.collapsed!==l?h.version+1:h.version:0;return i.set(a,{oldText:c,newText:u,collapsed:l,version:m,fileDiff:f}),{id:a,type:"diff",fileDiff:f,version:m,collapsed:l}});for(const o of i.keys())n.has(o)||i.delete(o);return r}const Ky={theme:wa,diffStyle:"split",lineDiffType:"word",preferredHighlighter:"shiki-js",overflow:"scroll",stickyHeaders:!0},qy={height:"100%",overflow:"auto"},Yy=new Set;function Ou({result:e,loading:t}){const{t:i}=ae(),s=ba(Ky),[n,r]=w.useState(!1),[o,a]=w.useState(!1),l=w.useRef(new Map);w.useEffect(()=>{let u=!0;return ya().then(()=>{u&&r(!0)},()=>{u&&a(!0)}),()=>{u=!1}},[]);const h=w.useMemo(()=>Mu(e?.ok?[e]:[],Yy,l.current,{ignoreLineEndings:!0}),[e]),c=t?i("Loading..."):o?i("Could not load the diff viewer."):e?e.ok?n?e.oldText===e.newText?i("No text changes to display."):h[0]?.fileDiff.hunks.length===0?i("Only line endings changed."):null:i("Loading..."):i(e.error):i("Select a file to view its diff.");return d.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:c?d.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 text-center text-xs text-muted-foreground",role:"status",children:c}):d.jsx(Bc,{className:"min-h-0 w-full flex-1",items:h,style:qy,options:s})})}function Gu({tree:e,onToggle:t}){const{t:i}=ae(),s=i(e?"List view":"Tree view");return d.jsx(Me,{variant:"ghost",size:"icon-xs",title:s,"aria-label":s,onClick:t,children:e?d.jsx(Gg,{className:"size-3.5"}):d.jsx(jv,{className:"size-3.5"})})}function zu({files:e,tree:t,children:i}){const s=w.useId(),[n,r]=w.useState(()=>new Set),o=w.useMemo(()=>{const l={name:"",path:"",directories:new Map,files:[]};if(!t)return l;for(const h of e){const c=h.path.split("/");let u=l;for(const p of c.slice(0,-1)){let f=u.directories.get(p);f||(f={name:p,path:u.path?`${u.path}/${p}`:p,directories:new Map,files:[]},u.directories.set(p,f)),u=f}u.files.push(h)}return l},[e,t]),a=l=>d.jsxs(d.Fragment,{children:[[...l.directories.values()].sort((h,c)=>h.name.localeCompare(c.name)).map(h=>{const c=!n.has(h.path),u=`${s}-${encodeURIComponent(h.path)}`;return d.jsxs("div",{children:[d.jsxs("button",{type:"button",title:h.path,"aria-expanded":c,"aria-controls":c?u:void 0,className:"flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>r(p=>{const f=new Set(p);return f.has(h.path)?f.delete(h.path):f.add(h.path),f}),children:[d.jsx(Ii,{"aria-hidden":"true",className:U("size-3 shrink-0 text-muted-foreground",!c&&"-rotate-90")}),c?d.jsx(xa,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(zg,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"truncate",children:h.name})]}),c&&d.jsx("div",{id:u,className:"ml-3 min-w-0 border-l pl-1",children:a(h)})]},`directory:${h.path}`)}),l.files.slice().sort((h,c)=>h.path.localeCompare(c.path)).map(h=>d.jsx(w.Fragment,{children:i(h)},`file:${h.path}`))]});return t?a(o):e.map(l=>d.jsx(w.Fragment,{children:i(l)},l.path))}const Xy={added:{label:"A",color:"text-success"},modified:{label:"M",color:"text-info"},deleted:{label:"D",color:"text-destructive"},untracked:{label:"?",color:"text-success"},conflicted:{label:"!",color:"text-warning"}};function ju({file:e,selected:t,onSelect:i,actions:s,showDirectory:n=!0}){const{t:r}=ae(),o=e.path.lastIndexOf("/"),a=e.path.slice(o+1),l=e.path.slice(0,Math.max(0,o)),h=Xy[e.status];return d.jsxs("div",{className:U("group flex min-w-0 items-center rounded-md pr-1 hover:bg-muted/50",t&&"bg-brand/10 dark:bg-brand/15"),children:[d.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",title:e.path,"aria-pressed":t,onClick:i,children:[d.jsx(cc,{"aria-hidden":"true",className:U("size-3.5 shrink-0",h.color)}),d.jsx("span",{className:U("truncate",!n&&"flex-1"),children:a}),n&&d.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-muted-foreground",children:l}),d.jsxs("span",{className:U("relative shrink-0 font-mono text-[11px]",h.color),title:r(e.status),children:[d.jsx("span",{"aria-hidden":"true",children:h.label}),d.jsx("span",{className:"sr-only",children:r(e.status)})]})]}),s&&d.jsx("div",{className:"flex shrink-0 items-center opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:s})]})}function Bu({title:e,hasSelection:t,navigation:i,actions:s,children:n}){const{t:r}=ae(),o=w.useId(),[a,l]=w.useState(!0),h=!t||a;return d.jsx("div",{className:"@container/git flex min-h-0 min-w-0 flex-1 flex-col",children:d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden @min-[720px]/git:flex-row",children:[d.jsxs("div",{className:U("flex min-h-0 min-w-0 flex-col overflow-hidden border-b @min-[720px]/git:h-full @min-[720px]/git:max-h-none @min-[720px]/git:flex-none @min-[720px]/git:border-r @min-[720px]/git:border-b-0",h?"flex-1 @min-[720px]/git:w-[280px]":"shrink-0 @min-[720px]/git:w-8",h&&t&&"max-h-[45%] basis-[45%] shrink-0"),children:[d.jsxs("div",{className:"flex shrink-0 items-center",children:[d.jsxs("button",{type:"button",className:"flex min-h-7 min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-[11px] font-medium text-muted-foreground hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring","aria-expanded":h,"aria-controls":o,disabled:!t,title:r(h?"Collapse list":"Expand list"),onClick:()=>l(!h),children:[d.jsx(Ii,{className:U("size-3.5 shrink-0",!h&&"-rotate-90")}),d.jsx("span",{className:U("truncate",!h&&"@min-[720px]/git:hidden"),children:e})]}),h&&s&&d.jsx("div",{className:"mr-1 flex shrink-0 items-center",children:s})]}),d.jsx("div",{id:o,className:U("flex min-h-0 flex-1 flex-col overflow-hidden",!h&&"hidden"),children:i})]}),d.jsx("div",{className:U("min-h-0 min-w-0 flex-1 flex-col overflow-hidden @min-[720px]/git:flex",t?"flex":"hidden"),children:n})]})})}function Jy({request:e,head:t,tree:i,onToggleTree:s}){const{t:n}=ae(),r=w.useId(),[o,a]=w.useState([]),[l,h]=w.useState(0),[c,u]=w.useState(0),[p,f]=w.useState(!1),[m,g]=w.useState(!0),[_,T]=w.useState(null),[D,E]=w.useState(null),[S,A]=w.useState([]),[k,L]=w.useState(!1),[O,z]=w.useState(null),[N,I]=w.useState(null),[C,v]=w.useState(null),[y,x]=w.useState(!1);return w.useEffect(()=>{let b=!0;return g(!0),T(null),window.electronAPI.git.history({...e,head:t??void 0,skip:l,limit:20}).then(R=>{b&&(R.ok?(a(M=>l===0?R.commits:[...M,...R.commits]),f(R.hasMore)):T(R.error))}).catch(()=>{b&&T("Could not load Git history.")}).finally(()=>{b&&g(!1)}),()=>{b=!1}},[e,t,l,c]),w.useEffect(()=>{if(!D)return;let b=!0;return L(!0),z(null),window.electronAPI.git.commitFiles({...e,hash:D.hash}).then(R=>{b&&(R.ok?A(R.files):z(R.error))}).catch(()=>{b&&z("Could not load the changed files.")}).finally(()=>{b&&L(!1)}),()=>{b=!1}},[e,D]),w.useEffect(()=>{if(!N||!D)return;let b=!0;return x(!0),window.electronAPI.git.commitDiff({...e,hash:D.hash,path:N}).then(R=>{b&&v(R)}).catch(()=>{b&&v({ok:!1,error:"Could not load the diff."})}).finally(()=>{b&&x(!1)}),()=>{b=!1}},[e,D,N]),d.jsxs(Bu,{title:n("History"),hasSelection:N!==null,actions:d.jsx(Gu,{tree:i,onToggle:s}),navigation:d.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto px-1 pb-1",children:[o.map(b=>{const R=D?.hash===b.hash;return d.jsxs("div",{children:[d.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":R?`${r}-${b.hash}`:void 0,className:U("flex w-full min-w-0 items-start gap-1.5 rounded-md px-2 py-1.5 text-left hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",R&&"bg-brand/10 dark:bg-brand/15"),title:`${b.subject}
|
|
12
|
-
${b.hash}
|
|
13
|
-
${b.author} · ${b.date}`,onClick:()=>{E(R?null:b),A([]),L(!R),z(null),I(null),v(null),x(!1)},children:[d.jsx(Ii,{"aria-hidden":"true",className:U("mt-0.5 size-3.5 shrink-0 text-muted-foreground",!R&&"-rotate-90")}),d.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[d.jsx("span",{className:"truncate text-xs",children:b.subject}),d.jsxs("span",{className:"flex min-w-0 gap-2 text-[11px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 font-mono",children:b.hash.slice(0,7)}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.author}),d.jsx("time",{className:"shrink-0",dateTime:b.date,children:new Date(b.date).toLocaleDateString()})]})]})]}),R&&d.jsx("div",{id:`${r}-${b.hash}`,className:"my-1 ml-3 border-l pl-1",children:k?d.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:n("Loading...")}):O?d.jsx("p",{role:"alert",className:"px-2 py-3 text-xs text-destructive",children:n(O)}):S.length===0?d.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:n("No file changes in this commit.")}):d.jsx(zu,{files:S,tree:i,children:M=>d.jsx(ju,{file:M,showDirectory:!i,selected:N===M.path,onSelect:()=>{N!==M.path&&(I(M.path),v(null),x(!0))}})},b.hash)})]},b.hash)}),m&&d.jsx("div",{className:"flex justify-center p-3",children:d.jsx(Qn,{className:"size-4 animate-spin","aria-label":n("Loading...")})}),_&&d.jsx("p",{role:"alert",className:"px-2 py-3 text-xs text-destructive",children:n(_)}),!m&&!_&&o.length===0&&d.jsx("p",{className:"m-1 rounded-md border border-dashed px-2 py-5 text-center text-xs text-muted-foreground",children:n("No commits yet.")}),p&&!m&&!_&&d.jsx(Me,{variant:"ghost",size:"xs",className:"w-full",onClick:()=>h(o.length),children:n("Load more commits")}),_&&d.jsx(Me,{variant:"ghost",size:"xs",className:"w-full",onClick:()=>u(b=>b+1),children:n("Retry")})]}),children:[D&&N&&d.jsxs("div",{className:"shrink-0 truncate border-b px-3 py-1 text-[11px] text-muted-foreground",title:`${D.subject} · ${N}`,children:[D.hash.slice(0,7)," · ",N]}),d.jsx(Ou,{result:C,loading:y})]})}function Zy({conversationId:e,projectId:t,disabled:i,unavailable:s,editWriteKey:n}){const{t:r}=ae(),{visible:o}=jg(),a=w.useMemo(()=>({conversationId:e,projectId:t}),[e,t]),[l,h]=w.useState(null),[c,u]=w.useState(!0),[p,f]=w.useState(null),[m,g]=w.useState(null),[_,T]=w.useState(null),[D,E]=w.useState("changes"),[S,A]=w.useState(!0),[k,L]=w.useState(""),[O,z]=w.useState(""),N=w.useRef(null),[I,C]=w.useState(null),[v,y]=w.useState(null),[x,b]=w.useState(null),[R,M]=w.useState({staged:!0}),[W,B]=w.useState(null),[Q,ie]=w.useState(!1),[ne,de]=w.useState(0),ve=w.useRef(!1),re=w.useRef(!1),me=w.useRef(0),K=w.useRef(0),F=w.useCallback(async(J=!1)=>{if(!o||i||s||re.current||K.current!==0&&!J)return;const ye=++me.current;K.current=ye,J&&u(!0);try{const Fe=await window.electronAPI.git.status(a);if(!ve.current||ye!==me.current)return;Fe.ok?(h(Fe),f(null)):(h(null),f(Fe.error))}catch{ve.current&&ye===me.current&&(h(null),f("Could not read Git status."))}finally{K.current===ye&&(K.current=0),ve.current&&ye===me.current&&u(!1)}},[o,i,s,a]);w.useEffect(()=>{ve.current=!0;const J=()=>{F()},ye=window.setInterval(()=>{document.visibilityState==="visible"&&document.hasFocus()&&F()},5e3);return window.addEventListener("focus",J),()=>{ve.current=!1,me.current+=1,window.clearInterval(ye),window.removeEventListener("focus",J)}},[F]),w.useEffect(()=>{F(!0)},[F,n]),w.useEffect(()=>{if(!I||!l)return;(I.staged?l.staged:l.unstaged).some(ye=>ye.path===I.path)||(C(null),B(null),ie(!1))},[I,l]),w.useEffect(()=>{if(!o||!I||i||s||_!==null||D!=="changes")return;let J=!0,ye=!1;const Fe=async()=>{if(!ye){ye=!0;try{const fs=await window.electronAPI.git.fileDiff({...a,...I});J&&B(fs)}catch{J&&B({ok:!1,error:"Could not load the diff."})}finally{ye=!1,J&&ie(!1)}}};Fe();const Pe=()=>{Fe()},ps=window.setInterval(()=>{document.visibilityState==="visible"&&document.hasFocus()&&Fe()},5e3);return window.addEventListener("focus",Pe),()=>{J=!1,window.clearInterval(ps),window.removeEventListener("focus",Pe)}},[o,a,I,ne,i,s,D,_]);const le=async(J,ye,Fe)=>{if(!(re.current||i||s||c||!l)){re.current=!0,me.current+=1,T(J),g(null);try{const Pe=await ye();if(!ve.current)return;Pe.ok?Fe?.():g(Pe.error)}catch{ve.current&&g("Could not complete the Git operation.")}finally{re.current=!1,ve.current&&(T(null),de(Pe=>Pe+1),F(!0),ce.getState().refreshWorktreeStatuses().catch(()=>{}))}}},pe=i||s||c||_!==null||!l,ke=!pe&&!!k.trim()&&!!l?.staged.length,we=(J,ye)=>{I?.path===J.path&&I.staged===ye||(B(null),ie(!0),C({path:J.path,staged:ye}))},Xe=[{id:"staged",staged:!0,title:r("Staged changes"),files:l?.staged??[]},{id:"unstaged",staged:!1,title:r("Unstaged changes"),files:l?.unstaged.filter(J=>J.status!=="untracked")??[]},{id:"untracked",staged:!1,title:r("Untracked changes"),files:l?.unstaged.filter(J=>J.status==="untracked")??[]}],ct=O.trim().toLowerCase(),Re=Xe.map(J=>({...J,files:J.files.filter(ye=>ye.path.toLowerCase().includes(ct))})),ft=Re.reduce((J,ye)=>J+ye.files.length,0),it=Xe[1].files.filter(J=>J.status==="conflicted").length,Gt=Xe[1].files.map(J=>J.path),He=Xe[2].files.map(J=>J.path),us=x?[x.tracked.length>0&&r("Unstaged changes in {{count}} tracked files will be lost; the files are restored to their staged version.",{count:x.tracked.length}),x.untracked.length>0&&r("{{count}} untracked files will be permanently deleted and cannot be recovered.",{count:x.untracked.length}),x.kind==="untracked"&&r("Tracked files are not changed.")].filter(Boolean).join(" "):"",Ai=()=>{ke&&le("Commit",()=>window.electronAPI.git.commit({...a,message:k}),()=>L(""))};return d.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[l&&!i&&!s&&!p&&d.jsxs("div",{className:"flex shrink-0 items-center gap-1",role:"tablist","aria-label":r("Git views"),children:[d.jsxs(Me,{role:"tab","aria-selected":D==="changes",variant:D==="changes"?"secondary":"ghost",size:"xs",onClick:()=>E("changes"),children:[d.jsx(Rv,{className:"size-3.5"}),r("Changes")]}),d.jsxs(Me,{role:"tab","aria-selected":D==="history",variant:D==="history"?"secondary":"ghost",size:"xs",onClick:()=>E("history"),children:[d.jsx(Zf,{className:"size-3.5"}),r("History")]})]}),d.jsx(Bg,{className:"size-3.5 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",title:l?.branch??void 0,children:l?.branch??r(l?"Detached HEAD":"Git")}),l?.upstream&&d.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:l.upstream,children:["↓",l.behind," ↑",l.ahead]}),l&&!l.upstream&&d.jsx("span",{className:"max-w-20 truncate text-[11px] text-muted-foreground",title:r("No upstream branch configured."),children:r("No upstream")}),d.jsx(Ri,{title:r("Fetch"),disabled:pe,onClick:()=>{le("Fetch",()=>window.electronAPI.git.fetch(a))},children:d.jsx(Qf,{className:"size-3.5"})}),d.jsx(Ri,{title:r("Pull"),disabled:pe||!l?.upstream,onClick:()=>{le("Pull",()=>window.electronAPI.git.pull(a))},children:d.jsx(em,{className:"size-3.5"})}),d.jsx(Ri,{title:r("Push"),disabled:pe||!l?.upstream,onClick:()=>{le("Push",()=>window.electronAPI.git.push(a))},children:d.jsx(tm,{className:"size-3.5"})}),d.jsx(Ri,{title:r("Refresh"),disabled:i||s||_!==null||c,onClick:()=>{de(J=>J+1),F(!0)},children:d.jsx(ai,{className:U("size-3.5",c&&!s&&!i&&"animate-spin")})})]}),_&&d.jsxs("p",{role:"status",className:"flex shrink-0 items-center gap-2 px-3 py-1 text-xs text-muted-foreground",children:[d.jsx(Qn,{className:"size-3 animate-spin"}),r(_),"…"]}),m&&d.jsx("p",{role:"alert",className:"max-h-24 shrink-0 overflow-auto whitespace-pre-wrap break-words border-b px-3 py-2 text-xs text-destructive",children:r(m)}),s||i||p||!l?d.jsx("div",{role:"status",className:"m-3 flex min-h-0 flex-1 items-center justify-center rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground",children:r(s?"Git diff is not available for this workspace.":i?"Workspace is changing. Please wait.":p??"Loading...")}):D==="history"?d.jsx(Jy,{request:a,head:l.head,tree:S,onToggleTree:()=>A(J=>!J)},`${l.head}:${ne}`):d.jsxs(Bu,{title:r("Changed files"),hasSelection:I!==null,actions:d.jsxs(d.Fragment,{children:[d.jsxs(uc,{children:[d.jsx(pc,{render:d.jsx(Me,{variant:"ghost",size:"icon-xs"}),title:r("Discard…"),"aria-label":r("Discard…"),disabled:pe,children:d.jsx(On,{className:"size-3.5"})}),d.jsxs(fc,{align:"end",className:"min-w-56",children:[d.jsx(Nt,{variant:"destructive","data-discard-option":"all",disabled:it>0||Gt.length+He.length===0,onClick:()=>b({kind:"all",tracked:Gt,untracked:He}),children:d.jsxs("span",{className:"flex flex-col",children:[r("Discard all"),d.jsx("span",{className:"text-[11px] text-muted-foreground",children:it>0?r("Resolve conflicts first."):r("Discard {{tracked}} tracked changes, delete {{untracked}} untracked files",{tracked:Gt.length,untracked:He.length})})]})}),d.jsx(Nt,{variant:"destructive","data-discard-option":"untracked",disabled:it>0||He.length===0,onClick:()=>b({kind:"untracked",tracked:[],untracked:He}),children:d.jsxs("span",{className:"flex flex-col",children:[r("Discard untracked"),d.jsx("span",{className:"text-[11px] text-muted-foreground",children:it>0?r("Resolve conflicts first."):r("Permanently delete {{count}} untracked files",{count:He.length})})]})}),d.jsx(om,{}),d.jsx(Nt,{"data-discard-option":"cancel",children:r("Cancel")})]})]}),d.jsx(Gu,{tree:S,onToggle:()=>A(J=>!J)})]}),navigation:d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:d.jsxs(im,{className:"text-xs",children:[d.jsx(sm,{ref:N,size:"sm",type:"search",value:O,onChange:J=>z(J.target.value),placeholder:r("Filter changed files…"),"aria-label":r("Filter changed files…")}),O.length>0&&d.jsx(nm,{align:"inline-end",children:d.jsx(Me,{type:"button",variant:"ghost",size:"icon-xs",title:r("Clear"),"aria-label":r("Clear"),onClick:()=>{z(""),N.current?.focus()},children:d.jsx(qs,{className:"size-3.5"})})})]})}),d.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto px-1 pb-1",children:[Re.map(J=>{if(J.files.length===0)return null;const ye=!!ct||!R[J.id],Fe=ye?0:J.files.filter(Pe=>Pe.status==="conflicted").length;return d.jsxs("section",{"data-git-group":J.id,className:"mb-2 last:mb-0",children:[d.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 text-[11px] font-medium text-muted-foreground",children:[d.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1 text-left hover:text-foreground","aria-expanded":ye,onClick:()=>{ct||M(Pe=>({...Pe,[J.id]:!Pe[J.id]}))},children:[d.jsx("span",{className:"min-w-0 truncate",children:J.title}),d.jsxs("span",{className:"shrink-0 font-normal",children:["· ",J.files.length]}),Fe>0&&d.jsx("span",{className:"shrink-0 font-normal text-destructive",children:r("{{count}} conflicted",{count:Fe})}),ye?d.jsx(Ii,{className:"size-3 shrink-0"}):d.jsx(as,{className:"size-3 shrink-0"})]}),d.jsx(Ri,{title:r(J.staged?"Unstage all":"Stage all"),disabled:pe,onClick:()=>{le(J.staged?"Unstage":"Stage",()=>window.electronAPI.git[J.staged?"unstage":"stage"]({...a,paths:J.files.map(Pe=>Pe.path)}))},children:J.staged?d.jsx(Pl,{className:"size-3.5"}):d.jsx(ns,{className:"size-3.5"})})]}),ye&&d.jsx(zu,{files:J.files,tree:S,children:Pe=>d.jsx(ju,{file:Pe,showDirectory:!S,selected:I?.path===Pe.path&&I.staged===J.staged,onSelect:()=>we(Pe,J.staged),actions:d.jsxs(d.Fragment,{children:[!J.staged&&d.jsx(Ri,{title:r(Pe.status==="untracked"?"Delete untracked file":"Discard changes"),disabled:pe||Pe.status==="conflicted",onClick:()=>y(Pe),children:d.jsx(On,{className:"size-3.5"})}),d.jsx(Ri,{title:r(J.staged?"Unstage":"Stage"),disabled:pe,onClick:()=>{le(J.staged?"Unstage":"Stage",()=>window.electronAPI.git[J.staged?"unstage":"stage"]({...a,paths:[Pe.path]}))},children:J.staged?d.jsx(Pl,{className:"size-3.5"}):d.jsx(ns,{className:"size-3.5"})})]})})},ct)]},J.id)}),ft===0&&d.jsx("p",{className:"m-1 rounded-md border border-dashed px-2 py-5 text-center text-xs text-muted-foreground",children:r(l.staged.length+l.unstaged.length===0?"Working tree clean.":"No matching files.")})]}),d.jsxs("div",{className:"flex shrink-0 items-end gap-1.5 border-t p-2",children:[d.jsx(rm,{size:"sm",rows:3,value:k,"aria-label":r("Commit message"),placeholder:r("Enter commit message…"),className:"min-w-0 flex-1 text-xs [&_textarea]:max-h-[calc(6lh+0.5rem)] [&_textarea]:min-h-[calc(3lh+0.5rem)] [&_textarea]:resize-none [&_textarea]:overflow-auto",disabled:_!==null,onChange:J=>L(J.target.value),onKeyDown:J=>{(J.ctrlKey||J.metaKey)&&J.key==="Enter"&&!J.nativeEvent.isComposing&&(J.preventDefault(),Ai())}}),d.jsxs(Me,{size:"xs",className:"mb-0.5 shrink-0",title:r("{{count}} staged files",{count:l.staged.length}),"aria-label":r("Commit"),disabled:!ke,onClick:Ai,children:[d.jsx(Lv,{className:"size-3.5"}),r("Commit"),l.staged.length>0&&d.jsx("span",{className:"font-mono text-[11px]",children:l.staged.length})]})]})]}),children:[I&&d.jsxs("div",{className:"shrink-0 truncate border-b px-3 py-1 text-[11px] text-muted-foreground",title:I.path,children:[r(I.staged?"Staged changes":"Unstaged changes")," · ",I.path]}),d.jsx(Ou,{result:W,loading:I!==null&&Q})]}),d.jsx(Mn,{open:v!==null&&!pe,onOpenChange:J=>{J||y(null)},title:r(v?.status==="untracked"?"Delete untracked file":"Discard changes"),description:v?.status==="untracked"?r("Delete untracked file {{path}} permanently?",{path:v.path}):r("Restore {{path}} to its staged version? Unstaged changes will be lost.",{path:v?.path??""}),confirmLabel:r(v?.status==="untracked"?"Delete":"Discard"),onConfirm:()=>{v&&le("Discard",()=>window.electronAPI.git.discard({...a,paths:[v.path],confirmUntracked:v.status==="untracked"}))}}),d.jsx(Mn,{open:x!==null&&!pe,onOpenChange:J=>{J||b(null)},title:r(x?.kind==="untracked"?"Discard untracked":"Discard all"),description:us,confirmLabel:x?.untracked.length?r(x.kind==="all"?"Discard and delete {{count}} untracked files":"Delete {{count}} untracked files",{count:x.untracked.length}):r("Discard all"),onConfirm:()=>{if(x){const{tracked:J,untracked:ye}=x;le("Discard",async()=>{if(J.length){const Fe=await window.electronAPI.git.discard({...a,paths:J,confirmUntracked:!1});if(!Fe.ok||!ye.length)return Fe}return window.electronAPI.git.discard({...a,paths:ye,confirmUntracked:!0})})}}})]})}function Ri({title:e,disabled:t,onClick:i,children:s}){return d.jsx(Me,{variant:"ghost",size:"icon-xs",title:e,"aria-label":e,disabled:t,onClick:i,children:s})}const $u=28,Qy={theme:wa,diffStyle:"split",lineDiffType:"word",preferredHighlighter:"shiki-js",overflow:"scroll",stickyHeaders:!0,itemMetrics:{diffHeaderHeight:$u}},ex={height:"max-content",overflow:"auto"},tx={files:[],snapshots:{}},zh=[];function ix({conversationId:e,projectId:t}){const{t:i}=ae(),s=ba(Qy),n=De(B=>B.changesModeByConversation[e])??"all",r=De(B=>B.setChangesMode),o=w.useRef(null),a=w.useRef(null),l=w.useRef(!1);w.useLayoutEffect(()=>{const B=o.current,Q=a.current,ie=B?.querySelector('[aria-selected="true"]');!B||!Q||!ie||(l.current||(Q.style.transition="none"),Q.style.transform=`translate(${ie.offsetLeft}px, ${ie.offsetTop}px)`,Q.style.width=`${ie.offsetWidth}px`,Q.style.height=`${ie.offsetHeight}px`,l.current||(Q.offsetWidth,Q.style.transition="",l.current=!0))},[n]);const h=De(B=>B.snapshotsByConversation[e]),c=De(B=>B.saveSnapshots),u=De(B=>B.loadSnapshots),p=ce(B=>mc(B.conversations[e]?.messages??zh)),f=ce(B=>B.workspaceRevisionByConversation[e]??0),m=ce(B=>!!B.conversations[e]?.workspaceMigrating),g=$e(B=>B.projects.find(Q=>Q.id===t)),_=ce(B=>g?.kind==="secretary"?void 0:g?.kind==="scratch"?gc({kind:"scratch",canonicalPath:g.path,conversationId:e})??void 0:B.conversations[e]?.worktree?.path??g?.path),T=ce(B=>B.conversations[e]?.status==="running"),D=w.useRef([]),E=w.useMemo(()=>{const B=ce.getState().conversations[e],ie=to(B?.messages??zh,T,B?.customEntries??[],_).flatMap(ne=>ne.kind!=="tool"?[]:ne.name==="apply_patch"?(ne.fileChanges??[]).map(de=>({path:de.path,edits:null,writeContent:null,fileChange:de})):ne.state!=="ok"||ne.name!=="edit"&&ne.name!=="write"?[]:ne.summary?ne.name==="edit"&&!(ne.edits&&ne.edits.length>0)?[]:ne.name==="write"&&ne.writeContent==null?[]:[{path:ne.summary,edits:ne.edits,writeContent:ne.writeContent}]:[]);return vv(D.current,ie)?D.current:(D.current=ie,ie)},[e,p,_,T]),[S,A]=w.useState(!1),[k,L]=w.useState({});w.useEffect(()=>{let B=!0;return ya().then(()=>{B&&A(!0)}),()=>{B=!1}},[]),w.useEffect(()=>{n==="all"&&u(e)},[e,u,n]),w.useEffect(()=>{if(n!=="all"||m)return;const B=[...new Set(E.map(ie=>ie.path))];let Q=!0;return Promise.all(B.map(async ie=>{const ne=am(ie,_),de=ne?await window.electronAPI.files.read({conversationId:e,projectId:t,rel:ne}):lm(ie)?await window.electronAPI.files.read({conversationId:e,projectId:t,path:ie}):null;return[ie,de]})).then(ie=>{if(!Q)return;const ne=Object.fromEntries(ie);L(de=>_v(de,ne)?de:ne)}),()=>{Q=!1}},[e,n,t,_,E,m,f]);const O=w.useMemo(()=>h?bv({tools:E,snapshots:h,currentByPath:k}):tx,[E,h,k]);w.useEffect(()=>{if(n!=="all"||!h)return;const B=O.snapshots,Q=Object.keys(B);Q.length===Object.keys(h).length&&Q.every(ie=>h[ie]===B[ie])||c(e,B)},[O.snapshots,e,n,c,h]);const z=O.files,N=O.incompletePaths??[],[I,C]=w.useState(()=>new Set),v=w.useCallback(B=>{C(Q=>{const ie=new Set(Q);return ie.delete(B)||ie.add(B),ie})},[]),y=w.useRef(new Map),x=w.useMemo(()=>Mu(z,I,y.current),[z,I]),b=x.length>0&&x.every(B=>B.collapsed),R=()=>C(b?new Set:new Set(x.map(B=>B.id))),M=w.useCallback(B=>d.jsx(sx,{item:B,onToggle:()=>v(B.id)}),[v]),W=!S||!h;return d.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[d.jsxs("div",{ref:o,role:"tablist",className:"t-tabs",children:[d.jsx("span",{ref:a,"aria-hidden":"true",className:"t-tabs-pill"}),d.jsx(jh,{active:n==="all",onClick:()=>r(e,"all"),children:i("Session")}),d.jsx(jh,{active:n==="git",onClick:()=>r(e,"git"),children:i("Git")})]}),n==="all"&&x.length>0&&d.jsx("button",{type:"button",onClick:R,title:i(b?"Expand all":"Collapse all"),className:"ml-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted/50 hover:text-foreground",children:b?d.jsx(hm,{className:"h-3.5 w-3.5"}):d.jsx(Cv,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"min-h-0 flex-1",children:n==="git"?d.jsx(Zy,{conversationId:e,projectId:t,disabled:m,unavailable:g?.kind==="ssh",editWriteKey:p},`${e}:${_}:${f}`):W||z.length===0&&N.length===0?d.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-sm text-muted-foreground",children:i(W?"Loading...":"No file changes in this conversation yet.")}):d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N.map(B=>d.jsxs("div",{className:"m-2 flex shrink-0 items-start gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[d.jsx(dm,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate font-mono text-foreground",title:B,children:B}),d.jsx("div",{children:i("Diff unavailable because the original snapshot was truncated.")})]})]},B)),z.length>0&&d.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:d.jsx(Bc,{className:"min-h-0 w-full",items:x,style:ex,options:s,renderCustomHeader:M})})]})})]})}function sx({item:e,onToggle:t}){const i=e.type==="diff"?e.fileDiff:null;let s=0,n=0;for(const o of i?.hunks??[])s+=o.additionLines,n+=o.deletionLines;const r=i?.name??(e.type==="file"?e.file.name:"");return d.jsxs("button",{type:"button",onClick:t,style:{height:$u},className:"flex w-full min-w-0 items-center gap-1.5 px-2 text-left font-mono text-xs hover:bg-muted/50",children:[e.collapsed?d.jsx(as,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):d.jsx(Ii,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",title:r,children:r}),n>0&&d.jsxs("span",{className:"shrink-0 text-red-500",children:["-",n]}),s>0&&d.jsxs("span",{className:"shrink-0 text-green-600",children:["+",s]})]})}function jh({active:e,onClick:t,children:i}){return d.jsx("button",{type:"button",role:"tab",onClick:t,"aria-selected":e,className:U("t-tab rounded-md px-2 py-1 text-xs transition-colors",e?"font-medium":"text-muted-foreground hover:bg-muted/50"),children:i})}const nx=/\.(png|jpe?g|gif|webp|bmp|svg|ico|avif)$/i;function Bh(e){return nx.test(e)}const rx=4*1024*1024,ox={backgroundImage:"repeating-conic-gradient(rgb(128 128 128 / 0.18) 0% 25%, transparent 0% 50%)",backgroundSize:"16px 16px"};function ax({rel:e,version:t,resolveImage:i,onOpenSource:s}){const{t:n}=ae(),[r,o]=w.useState({status:"loading"}),[a,l]=w.useState(!0),[h,c]=w.useState(!1);return w.useEffect(()=>{let u=!0;return i(e).then(p=>{u&&o(f=>p.ok?f.status==="ready"&&f.dataUrl===p.dataUrl?f:{status:"ready",dataUrl:p.dataUrl}:{status:"error",tooLarge:p.error==="too-large"})},()=>{u&&o({status:"error",tooLarge:!1})}),()=>{u=!1}},[e,t,i]),r.status==="loading"?d.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:n("Loading...")}):r.status==="error"?d.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[d.jsx("span",{children:r.tooLarge?n("The image is too large to preview."):n("Unable to preview this image.")}),d.jsx(Me,{type:"button",variant:"outline",size:"sm",onClick:s,children:n("Open in code editor")})]}):r.dataUrl.length>rx&&!h?d.jsx("div",{className:"flex h-full items-center justify-center px-6",children:d.jsx(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>c(!0),children:n("Image is too large. Click to load.")})}):d.jsxs("div",{className:"relative h-full",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsxs(Me,{type:"button",variant:"outline",size:"sm","aria-label":n(a?"Actual size":"Fit to window"),onClick:()=>l(u=>!u),children:[a?d.jsx(vc,{className:"h-3.5 w-3.5"}):d.jsx(_c,{className:"h-3.5 w-3.5"}),n(a?"Actual size":"Fit to window")]})}),d.jsx("div",{className:"h-full overflow-auto p-4",style:ox,children:d.jsx("button",{type:"button",className:U(a?"flex h-full w-full cursor-zoom-in items-center justify-center":"m-auto block w-max cursor-zoom-out"),onClick:()=>l(u=>!u),children:d.jsx("img",{src:r.dataUrl,alt:e,"data-fit":a?"contain":"actual",className:a?"max-h-full max-w-full object-contain":"max-w-none"})})})]})}function lx({conversationId:e,projectId:t,onOpenFile:i,onClose:s,menu:n}){const{t:r}=ae(),o=w.useRef(0),[a,l]=w.useState(""),[h,c]=w.useState("names"),[u,p]=w.useState(null),[f,m]=w.useState(!1);return w.useEffect(()=>{if(!a.trim()){o.current+=1,p(null),m(!1);return}const _=++o.current;m(!0);const T=setTimeout(()=>{window.electronAPI.workspaceFiles.search({conversationId:e,projectId:t,query:a,mode:h}).then(D=>{_===o.current&&(p(D),m(!1))})},150);return()=>clearTimeout(T)},[e,h,t,a]),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"flex flex-col gap-1 px-1 pb-1",children:[d.jsx(bc,{size:"sm",autoFocus:!0,value:a,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"&&s()},placeholder:r(h==="names"?"Search file names":"Search file contents"),"aria-label":r("Search")}),d.jsxs("div",{className:"flex gap-0.5",children:[d.jsx(Wh,{active:h==="names",onClick:()=>c("names"),label:r("File name"),icon:nv}),d.jsx(Wh,{active:h==="content",onClick:()=>c("content"),label:r("Content"),icon:cc})]})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-1 pb-1",children:a.trim()?f&&!u?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:r("Searching…")}):u&&!u.ok?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:r(dx(u.error))}):u?.ok&&u.hits.length===0?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:r("No results")}):u?.ok&&u.mode==="names"?u.hits.map(g=>{const _=ir(g.name,!1);return d.jsx($h,{rel:g.relativePath,name:g.name,menu:n,onOpenFile:i,children:d.jsxs("button",{type:"button","data-search-hit":g.relativePath,className:"flex w-full items-start gap-1 rounded-sm px-1 py-0.5 text-left hover:bg-muted",onClick:()=>i(g.relativePath),children:[d.jsx(_,{className:U("mt-0.5 size-3.5 shrink-0",sr(g.name,!1))}),d.jsxs("span",{className:"min-w-0",children:[d.jsx("span",{className:"block truncate text-xs",children:g.name}),d.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:g.relativePath})]})]})},g.relativePath)}):u?.ok&&u.mode==="content"?u.hits.map(g=>{const _=g.relativePath.split("/").pop()||g.relativePath;return d.jsx($h,{rel:g.relativePath,name:_,menu:n,onOpenFile:i,children:hx(g,i)},Wu(g))}):null:d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:r("Type to search this workspace.")})})]})}function Wu(e){return`${e.relativePath}:${e.line}:${e.column}`}function hx(e,t){const i=e.relativePath.split("/").pop()||e.relativePath,s=ir(i,!1);return d.jsxs("button",{type:"button","data-search-hit":Wu(e),className:"flex w-full items-start gap-1 rounded-sm px-1 py-0.5 text-left hover:bg-muted",onClick:()=>t(e.relativePath),children:[d.jsx(s,{className:U("mt-0.5 size-3.5 shrink-0",sr(i,!1))}),d.jsxs("span",{className:"min-w-0",children:[d.jsxs("span",{className:"block truncate text-xs",children:[i,d.jsxs("span",{className:"text-muted-foreground",children:[":",e.line]})]}),d.jsx("span",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:e.content.trim()})]})]})}function $h({rel:e,name:t,menu:i,onOpenFile:s,children:n}){return d.jsx(tr,{target:{kind:"file",rel:e,name:t},local:i.local,onNewFile:i.onNewFile,onNewFolder:i.onNewFolder,onView:s,onPreview:i.onPreview,onBrowser:i.onBrowser,onCopyPath:i.onCopyPath,onCopyRel:i.onCopyRel,onCopyFile:i.onCopyFile,onReveal:i.onReveal,onRename:i.onRename,onDelete:i.onDelete,onSend:i.onSend,children:n})}function dx(e){switch(e){case"unsupported":return"Search is not available for SSH workspaces.";case"rg-missing":return"Search needs ripgrep (rg). Install it and make sure it is on PATH.";case"timeout":return"Search timed out. Try a more specific query or a smaller folder.";default:return"Could not complete the file action."}}function Wh({active:e,onClick:t,label:i,icon:s}){return d.jsxs(Me,{type:"button",variant:"ghost",size:"sm",className:U("h-6 flex-1 px-1 text-xs",e&&"bg-muted"),"aria-pressed":e,onClick:t,children:[d.jsx(s,{className:"size-3.5"}),i]})}const cx=/^data:image\/(png|jpe?g|gif|webp|bmp|x-icon|svg\+xml);/i;function ux(){return{...sn,attributes:{...sn.attributes,source:[]},protocols:{...sn.protocols,src:[...sn.protocols?.src??[],"data"]}}}function px(){return e=>{cm(e,"element",t=>{if(t.tagName!=="img")return;const i=t.properties?.src;typeof i!="string"||!i.startsWith("data:")||cx.test(i)||delete t.properties.src})}}const fx=[vm],mx=ux(),gx=[mm,[gm,mx],px],vx=({children:e,node:t,...i})=>d.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",...i,children:e}),_x=({children:e,node:t,...i})=>d.jsx("h1",{className:"mt-3 mb-1.5 text-base font-semibold",...i,children:e}),bx=({children:e,node:t,...i})=>d.jsx("h2",{className:"mt-3 mb-1.5 text-base font-semibold",...i,children:e}),wx=({children:e,node:t,...i})=>d.jsx("h3",{className:"mt-2 mb-1 text-sm font-semibold",...i,children:e}),yx=({children:e,node:t,...i})=>d.jsx("ul",{className:"my-1.5 list-disc pl-5 space-y-0.5",...i,children:e}),xx=({children:e,node:t,...i})=>d.jsx("ol",{className:"my-1.5 list-decimal pl-5 space-y-0.5",...i,children:e}),Sx=({children:e,node:t,...i})=>d.jsx("th",{className:"whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium",...i,children:e}),Cx=({children:e,node:t,...i})=>d.jsx("td",{className:"whitespace-nowrap border-b border-border/50 px-2 py-1",...i,children:e}),Dx={p:vx,h1:_x,h2:bx,h3:wx,ul:yx,ol:xx,th:Sx,td:Cx};function kx({text:e,baseDirRel:t,resolveImage:i,resolveRemoteImage:s}){const n=w.useRef(new Map),r=w.useMemo(()=>({...um,...Dx,img:({node:l,src:h,alt:c,...u})=>d.jsx(Px,{src:typeof h=="string"?h:void 0,alt:c,rest:u,baseDirRel:t,resolveImage:i,resolveRemoteImage:s,cache:n.current})}),[t,i,s]),o=w.useMemo(()=>({text:e,streaming:!1,searchQuery:"",activeNth:-1}),[e]);return d.jsx(pm.Provider,{value:o,children:d.jsx("div",{style:_m(bm),children:d.jsx(fm,{remarkPlugins:fx,rehypePlugins:gx,components:r,urlTransform:a=>a,children:e})})})}function Px({src:e,alt:t,rest:i,baseDirRel:s,resolveImage:n,resolveRemoteImage:r,cache:o}){const a=e?wm(e):"unsupported",l=a==="local"&&e?`local:${El(s,e)??""}`:e,[h,c]=w.useState(()=>a==="data"?e??null:l?o.get(l)??null:null);return w.useEffect(()=>{if(!e||a==="unsupported"){c(null);return}if(a==="data"){c(e);return}const u=l?o.get(l):void 0;if(u){c(u);return}let p=!0;return(a==="local"?(()=>{const m=El(s,e);return m?n(m):Promise.resolve(null)})():r(ym(e))).then(m=>{p&&(m&&l&&o.set(l,m),c(m))}),()=>{p=!1}},[e,a,s,n,r,o,l]),h?d.jsx("img",{...i,src:h,alt:t,className:"max-w-full rounded",loading:"lazy"}):null}function Hu(e){const t=e.trim();if(!t||t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return null;const i=t.split(/[/\\]/).filter(s=>s&&s!==".");return i.length===0||i.includes("..")?null:i.join("/")}function mn(e){const t=Hu(e);if(!t)return[];const i=t.split("/");if(i.length<=1)return[];const s=[];let n="";for(let r=0;r<i.length-1;r++)n=n?`${n}/${i[r]}`:i[r],s.push(n);return s}function Ex(e,t,i=!0){if(!i)return{refreshRels:[],nextSeen:null};const s=[],n=o=>{for(const a of o){if(a.kind==="tool-group"){n(a.children);continue}a.kind!=="tool"||a.state!=="ok"||a.name!=="write"||a.output===null&&a.durationMs===null||a.summary&&s.push({key:a.key,rel:Hu(a.summary)})}};n(e);const r=new Set(s.map(o=>o.key));return t===null?{refreshRels:[],nextSeen:r}:{refreshRels:s.filter(o=>!t.has(o.key)&&o.rel).map(o=>o.rel),nextSeen:r}}const Xa="\0preview";function Fu(e){return`${e}${Xa}`}function Vu(e){return e.endsWith(Xa)}function ji(e){return Vu(e)?e.slice(0,-Xa.length):e}function Tx(e,t){return e===t||e.startsWith(`${t}/`)}function bo(e,t){return Tx(ji(e),t)}function Ix(e,t){const i=e.trim();return!i||i===t?"cancel":"commit"}function gn(e,t,i){const s=Vu(e),n=ji(e);let r=null;return n===t?r=i:n.startsWith(`${t}/`)&&(r=i+n.slice(t.length)),r==null?null:s?Fu(r):r}function Ax(e){return e==="preview"?"source":"preview"}function Rx(e,t){const i=ji(e),s=[{id:"copy-path",rel:i,mode:"absolute"}];return t&&s.push({id:"reveal",rel:i}),s}function ys(e,t,i){return e.some(s=>s.epoch>i&&bo(t,s.rel))}async function Nx(e,t){const{revision:i,migrating:s}=t();if(s)return null;const n=await e(),r=t();return r.migrating||r.revision!==i?null:n}function Hh(e,t){return t===null?{...e,conflict:!0}:e.dirty?t!==e.contents&&t!==e.draft?{...e,conflict:!0}:e:t===e.draft&&!e.tooLarge?e:{...e,contents:t,draft:t,version:e.version+1,conflict:!1,tooLarge:!1}}function wo(e,t,i,s){const n=e.indexOf(t);if(n<0)return[];switch(i){case"self":return[t];case"others":return e.filter(r=>r!==t);case"right":return e.slice(n+1);case"saved":return e.filter(r=>!0);case"all":return[...e]}}const Lx={theme:wa,disableFileHeader:!0,overflow:"scroll",preferredHighlighter:"shiki-js"};function Mx(e){return new rv(e)}function Ox(e,t){return e?`${e}/${t}`:t}function Ji(e){return e.split("/").pop()||e}function Gx(e){const t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}const Tr=[];function zx({conversationId:e,projectId:t}){const{t:i}=ae(),s=ba(Lx),n=$g("files"),r=w.useMemo(()=>({conversationId:e,projectId:t}),[e,t]),o=ce(P=>P.workspaceRevisionByConversation[e]??0),a=ce(P=>!!P.conversations[e]?.workspaceMigrating),l=w.useCallback(P=>Nx(()=>window.electronAPI.workspaceFiles.read({...r,rel:P}),()=>{const j=ce.getState();return{revision:j.workspaceRevisionByConversation[e]??0,migrating:!!j.conversations[e]?.workspaceMigrating}}),[e,r]),[h,c]=w.useState(!1),[u,p]=w.useState([]),[f,m]=w.useState(null),g=Wg(),_=w.useRef(g);_.current=g;const T=Sa(),[D,E]=w.useState(!0),S=w.useRef(null),[A,k]=w.useState(0);w.useEffect(()=>{const P=S.current;if(!P||typeof ResizeObserver>"u")return;const j=new ResizeObserver(H=>{const V=H.at(-1)?.contentRect.width;V!==void 0&&k(Math.round(V))});return j.observe(P),()=>j.disconnect()},[]);const L=De(P=>xm(P.filesTreeWidth,A)),O=De(P=>P.nudgeFilesTreeWidth),z=De(P=>P.resetFilesTreeWidth),N=w.useCallback(P=>O(P,A),[O,A]),I=w.useCallback(P=>{m(P),E(!1)},[]);w.useEffect(()=>{f||E(!0)},[f]);const[C,v]=w.useState(0),[y,x]=w.useState(()=>new Set),[b,R]=w.useState(!1),[M,W]=w.useState(null),[B,Q]=w.useState(null),[ie,ne]=w.useState(null),de=$e(P=>P.projects.find(j=>j.id===t)),ve=de?.kind!=="ssh"&&!window.electronAPI.remote,re=w.useRef(u);re.current=u;const me=w.useRef(f);me.current=f;const K=w.useRef(null),F=w.useRef(null),le=w.useRef(null),pe=w.useRef(0),ke=w.useRef([]),we=w.useCallback(P=>{pe.current+=1,ke.current.push({epoch:pe.current,rel:P}),ke.current.length>200&&ke.current.splice(0,100)},[]);w.useEffect(()=>{const P=le.current;if(!P||!f)return;P.querySelector(`[data-file-tab="${CSS.escape(f)}"]`)?.scrollIntoView({inline:"nearest",block:"nearest"})},[f]),w.useEffect(()=>{let P=!0;return ya().then(()=>{P&&c(!0)}),()=>{P=!1}},[]);const Xe=w.useCallback((P,j)=>{p(H=>H.map(V=>V.rel===P?Hh(V,j):V))},[]),ct=w.useCallback(P=>{p(j=>j.map(H=>H.rel===P?{...H,version:H.version+1}:H))},[]),Re=w.useCallback(P=>{Ln({title:i(P==="exists"?"A file or folder with that name already exists.":P==="invalid-name"?"Invalid name.":"Could not complete the file action.")})},[i]),ft=w.useCallback(async(P,j)=>{if(re.current.find(he=>he.rel===P)){j&&p(he=>he.map(fe=>fe.rel===P?{...fe,viewMode:j,viewer:void 0}:fe)),I(P);return}if(Bh(P)&&j!=="source"&&!nn(P,_.current).some(he=>he.default)){p(he=>[...he,{rel:P,contents:"",draft:"",version:0,dirty:!1,conflict:!1,image:!0}]),I(P),window.electronAPI.workspaceFiles.watchStart({...r,rel:P});return}const V=pe.current,q=await l(P);if(!(!q||ys(ke.current,P,V))){if(!q.ok){if(q.error!=="too-large"){Re(q.error);return}p(he=>[...he,{rel:P,contents:"",draft:"",version:0,dirty:!1,conflict:!1,tooLarge:!0}]),I(P);return}p(he=>[...he,{rel:P,contents:q.content,draft:q.content,version:0,dirty:!1,conflict:!1,viewMode:j,viewer:j?void 0:(()=>{const fe=nn(P,_.current).find(At=>At.default);return fe?vs(fe):void 0})()}]),I(P),window.electronAPI.workspaceFiles.watchStart({...r,rel:P})}},[Re,l,r,I]),[it,Gt]=w.useState(null),He=w.useCallback(P=>{const j=re.current,H=j.filter(V=>!P(V.rel));for(const V of j)P(V.rel)&&window.electronAPI.workspaceFiles.watchStop({...r,rel:V.rel});p(H),m(V=>V&&H.some(q=>q.rel===V)?V:H.at(-1)?.rel??null)},[r]),us=w.useCallback(P=>{He(j=>j===P)},[He]),Ai=w.useCallback(P=>{if(re.current.find(H=>H.rel===P)?.dirty){Gt({kind:"one",rel:P});return}us(P)},[us]);w.useEffect(()=>Sm(e,()=>{const P=me.current;return!P||re.current.length===0?!1:(Ai(P),!0)}),[e,Ai]),w.useEffect(()=>()=>{for(const P of re.current)window.electronAPI.workspaceFiles.watchStop({...r,rel:P.rel})},[r]),w.useEffect(()=>{let P=!0;const j=window.electronAPI.workspaceFiles.onChange(H=>{if(H.conversationId!==e)return;const V=re.current.find(q=>q.rel===H.rel);if(V){if(V.image){ct(H.rel);return}l(H.rel).then(q=>{P&&q?.ok&&Xe(H.rel,q.content)})}});return()=>{P=!1,j()}},[Xe,ct,e,l]);const J=ce(P=>P.conversations[e]?.status==="running"),ye=ce(P=>de?.kind==="secretary"?void 0:de?.kind==="scratch"?gc({kind:"scratch",canonicalPath:de.path,conversationId:e})??void 0:P.conversations[e]?.worktree?.path??de?.path),Fe=ce(P=>P.conversations[e]?.historyBaseIndex),Pe=ce(P=>mc(P.conversations[e]?.messages??Tr)),ps=w.useMemo(()=>{const P=ce.getState().conversations[e];return to(P?.messages??Tr,J,P?.customEntries??[],ye).flatMap(j=>j.kind!=="tool"||j.state!=="ok"?[]:j.name!=="edit"&&j.name!=="write"?[]:j.summary?[j.summary]:[]).join(`
|
|
14
|
-
`)},[e,Pe,ye,J]);w.useEffect(()=>{let P=!0;const j=new Set(ps?ps.split(`
|
|
15
|
-
`):[]);for(const H of j){const V=re.current.find(q=>q.rel===H);if(V){if(V.image){ct(H);continue}l(H).then(q=>{P&&q?.ok&&Xe(H,q.content)})}}return()=>{P=!1}},[Xe,ct,l,ps]);const fs=w.useRef(null),bl=w.useRef(e),wl=w.useRef(Fe),Xt=w.useCallback(()=>v(P=>P+1),[]);w.useEffect(()=>{if(o===0||a)return;let P=!0;Xt();for(const j of re.current){if(j.image){ct(j.rel);continue}const H=ji(j.rel),V=pe.current;l(H).then(q=>{!P||!q||ys(ke.current,H,V)||p(he=>he.map(fe=>fe.rel===j.rel?Hh(fe,q.ok?q.content:null):fe))})}return()=>{P=!1}},[ct,Xt,l,a,o]);const en=w.useCallback(P=>{P&&x(j=>{if(j.has(P))return j;const H=new Set(j);return H.add(P),H})},[]),ms=w.useCallback(P=>{P.length!==0&&x(j=>{let H=!1;const V=new Set(j);for(const q of P)!q||V.has(q)||(V.add(q),H=!0);return H?V:j})},[]);w.useEffect(()=>{const P=ce.getState().conversations[e],j=Fe;(bl.current!==e||wl.current!==j)&&(bl.current=e,wl.current=j,fs.current=null);const H=to(P?.messages??Tr,J,P?.customEntries??[],ye),{refreshRels:V,nextSeen:q}=Ex(H,fs.current,Cm(P?.messages??[]));fs.current=q,V.length!==0&&(ms(V.flatMap(mn)),Xt())},[Xt,e,Pe,ms,Fe,ye,J]);const cf=w.useCallback(P=>{x(j=>{const H=new Set(j);return H.has(P)?H.delete(P):H.add(P),H})},[]),mr=w.useCallback(P=>{en(P),W({parent:P,kind:"file"})},[en]),gr=w.useCallback(P=>{en(P),W({parent:P,kind:"dir"})},[en]),tn=w.useCallback(async(P,j=!1)=>{if(j){await ft(P,"preview");return}const H=Fu(P);if(re.current.find(fe=>fe.rel===H)){I(H);return}const q=pe.current,he=await l(P);if(!(!he||ys(ke.current,P,q))){if(!he.ok){Re(he.error);return}p(fe=>[...fe,{rel:H,contents:he.content,draft:he.content,version:0,dirty:!1,conflict:!1,preview:!0}]),I(H)}},[Re,l,ft,I]);w.useEffect(()=>Dm(e,(P,j,H)=>{K.current=j?{rel:P,line:j}:null;const V=F.current,q=re.current.find(he=>he.rel===P);if(j&&V?.rel===P&&me.current===P&&q?.viewMode!=="preview"&&!q?.viewer){K.current=null,V.editor.focus({lineNumber:j});return}H==="markdown"&&!j?tn(P,!0):ft(P,!j&&(Bh(P)||nn(P,_.current).some(he=>he.default))?void 0:"source")}),[e,ft,tn]);const uf=w.useCallback(P=>window.electronAPI.workspaceFiles.readImage({...r,rel:P}).then(j=>j.ok?j.dataUrl:null),[r]),pf=w.useCallback(P=>window.electronAPI.workspaceFiles.readImage({...r,rel:P}),[r]),ff=w.useCallback(P=>window.electronAPI.workspaceFiles.fetchRemoteImage({...r,url:P}).then(j=>j.ok?j.dataUrl:null),[r]),mf=w.useCallback(async P=>{const j=pe.current,H=await l(P);if(!(!H||ys(ke.current,P,j))){if(!H.ok&&H.error!=="too-large"){Re(H.error);return}p(V=>V.map(q=>q.rel!==P?q:H.ok?{...q,image:void 0,contents:H.content,draft:H.content,version:q.version+1}:{...q,image:void 0,tooLarge:!0}))}},[Re,l]),yl=w.useCallback(async P=>{const j=await window.electronAPI.workspaceFiles.absPath({...r,rel:P});if(!j.ok||!j.local||!j.fileUrl){Re(j.ok?"unsupported":j.error);return}const H=`browser:file:${e}:${P}`;wc({conversationId:e,tabId:H,title:Ji(P)});const V=await window.electronAPI.browser.navigate(H,e,j.fileUrl);V.ok||Re(V.error)},[e,Re,r]),xl=w.useCallback(async P=>{if(ce.getState().conversations[e]?.workspaceMigrating){Ln({type:"error",title:i("Wait for the workspace operation to finish before saving.")});return}const j=re.current.find(he=>he.rel===P);if(!j||j.preview||!j.dirty)return;const H=j.draft,V=pe.current,q=await window.electronAPI.workspaceFiles.write({...r,rel:P,content:H});if(!ys(ke.current,P,V)){if(!q.ok){Re(q.error);return}p(he=>he.map(fe=>fe.rel===P?{...fe,contents:H,dirty:fe.draft!==H,conflict:!1}:fe))}},[e,Re,r,i]),gf=w.useCallback(P=>{p(j=>j.map(H=>H.rel===P?{...H,viewMode:Ax(H.viewMode)}:H))},[]),Sl=w.useCallback((P,j)=>{p(H=>H.map(V=>V.rel===P?{...V,viewer:j}:V))},[]),vf=w.useCallback((P,j)=>{p(H=>H.map(V=>V.rel===P?{...V,draft:j,dirty:j!==V.contents}:V))},[]);w.useEffect(()=>{if(!n)return;const P=j=>{!(Pm?j.metaKey:j.ctrlKey)||j.key.toLowerCase()!=="s"||f&&(j.preventDefault(),xl(f))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[f,xl,n]);const ge=u.find(P=>P.rel===f)??null,vr=ge&&!ge.preview&&!ge.tooLarge&&!ge.image?nn(ge.rel,g):[],qi=ge?.viewer?vr.find(P=>vs(P)===ge.viewer):void 0,_f=w.useMemo(()=>({enabledSelectionAction:!0,renderSelectionAction(P){const j=document.createElement("button");return j.type="button",j.style.cssText="appearance:none;border:0;margin:0;background:transparent;padding:2px 8px;font:inherit;font-size:12px;font-weight:500;line-height:20px;cursor:pointer;color:inherit;border-radius:6px",j.textContent=i("Send to conversation"),j.addEventListener("mouseenter",()=>{j.style.background="color-mix(in lab, currentColor 8%, transparent)"}),j.addEventListener("mouseleave",()=>{j.style.background="transparent"}),j.addEventListener("mousedown",H=>H.preventDefault()),j.addEventListener("click",()=>{const H=P.getSelectionText().trim(),V=f;if(!H||!V){P.close();return}const q=P.selection.start.line+1;let he=P.selection.end.line+1;P.selection.end.character===0&&he>q&&(he-=1);const fe=q===he?`L${q}`:`L${q}-L${he}`;so({kind:"file",id:`${V}#${fe}`,label:`${Ji(V)}#${fe}`,relativePath:`${V}#${fe}`}),Na(),P.close()}),j},onChange(P){const j=f;if(!j)return;const H=P.contents;p(V=>V.map(q=>q.rel===j?{...q,draft:H,dirty:H!==q.contents}:q))},onAttach(P){if(!f)return;F.current={rel:f,editor:P};const j=K.current;j?.rel===f&&(K.current=null,P.focus({lineNumber:j.line}))}}),[f,i]),Cl=w.useCallback(async(P,j)=>{const H=await window.electronAPI.workspaceFiles.rename({...r,rel:P,name:j});if(!H.ok)return Re(H.error),!1;Q(null);const V=H.rel;if(V){we(P);for(const q of re.current){if(q.preview||q.tooLarge)continue;const he=gn(q.rel,P,V);he!=null&&(window.electronAPI.workspaceFiles.watchStop({...r,rel:q.rel}),window.electronAPI.workspaceFiles.watchStart({...r,rel:he}))}p(q=>q.map(he=>{const fe=gn(he.rel,P,V);return fe==null?he:{...he,rel:fe}})),m(q=>q==null?q:gn(q,P,V)??q),x(q=>{let he=!1;const fe=new Set;for(const At of q){const Dl=gn(At,P,V)??At;Dl!==At&&(he=!0),fe.add(Dl)}return he?fe:q})}return Xt(),!0},[Xt,Re,we,r]);return d.jsxs(cv,{createEditor:Mx,children:[d.jsxs("div",{ref:S,className:"flex h-full min-h-0 bg-background",children:[d.jsxs("div",{className:U("flex shrink-0 flex-col overflow-hidden text-sm",T&&(D?"w-full":"hidden")),style:T?void 0:{width:L},children:[d.jsxs("div",{className:"flex justify-end gap-0.5 px-1 py-0.5",children:[d.jsx(Me,{variant:"ghost",size:"icon-sm",onClick:()=>R(P=>!P),"aria-label":i("Search"),"aria-pressed":b,children:d.jsx(ic,{})}),d.jsx(Me,{variant:"ghost",size:"icon-sm",onClick:Xt,"aria-label":i("Refresh"),children:d.jsx(ai,{})})]}),b?d.jsx(lx,{conversationId:e,projectId:t,onOpenFile:P=>{ft(P)},onClose:()=>R(!1),menu:{local:ve,onPreview:P=>{tn(P)},onBrowser:P=>{yl(P)},onCopyPath:P=>{window.electronAPI.workspaceFiles.copyPath({...r,rel:P,mode:"absolute"})},onCopyRel:P=>{window.electronAPI.workspaceFiles.copyPath({...r,rel:P,mode:"relative"})},onCopyFile:P=>{window.electronAPI.workspaceFiles.copyFile({...r,rel:P}).then(j=>{j.ok||Re(j.error)})},onReveal:P=>{window.electronAPI.workspaceFiles.reveal({...r,rel:P})},onNewFile:P=>{R(!1),ms(mn(P)),mr(P)},onNewFolder:P=>{R(!1),ms(mn(P)),gr(P)},onRename:(P,j)=>{R(!1),ms(mn(P)),Q({rel:P,name:j,at:"tree"})},onDelete:(P,j)=>ne({rel:P,name:j}),onSend:(P,j)=>{so({kind:"file",id:P,label:j,relativePath:P})}}}):d.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d.jsx(tr,{target:{kind:"blank"},local:ve,onNewFile:mr,onNewFolder:gr,onCopyPath:()=>{},onCopyRel:()=>{},children:d.jsx("div",{className:"min-h-full",children:d.jsx(Uu,{rel:"",depth:0,conversationId:e,projectId:t,treeEpoch:C,draft:M,renaming:B,local:ve,expandedDirs:y,onToggleDir:cf,onOpen:ft,onPreview:tn,onBrowser:yl,onCopyPath:P=>{window.electronAPI.workspaceFiles.copyPath({...r,rel:P,mode:"absolute"})},onCopyRel:P=>{window.electronAPI.workspaceFiles.copyPath({...r,rel:P,mode:"relative"})},onCopyFile:P=>{window.electronAPI.workspaceFiles.copyFile({...r,rel:P}).then(j=>{j.ok||Re(j.error)})},onReveal:P=>{window.electronAPI.workspaceFiles.reveal({...r,rel:P})},onNewFile:mr,onNewFolder:gr,onRenameStart:(P,j)=>Q({rel:P,name:j,at:"tree"}),onDelete:(P,j)=>ne({rel:P,name:j}),onDraftCancel:()=>W(null),onRenameCancel:()=>Q(null),onDraftCommit:async(P,j,H)=>{const q=await(j==="dir"?window.electronAPI.workspaceFiles.mkdir:window.electronAPI.workspaceFiles.createFile)({...r,rel:P||void 0,name:H});return q.ok?(W(null),Xt(),j==="file"&&q.rel&&ft(q.rel),!0):(Re(q.error),!1)},onRenameCommit:Cl})})})})]}),!T&&d.jsx(Hg,{onResize:N,onReset:z}),d.jsxs("div",{className:U("flex min-w-0 flex-1 flex-col",T&&D&&"hidden"),children:[u.length>0&&d.jsxs("div",{ref:le,className:"flex h-[36px] shrink-0 items-center gap-1 overflow-x-auto border-b px-2",children:[T&&d.jsx("button",{type:"button",className:"flex shrink-0 items-center rounded-md px-1 text-muted-foreground hover:bg-muted/50",onClick:()=>E(!0),"aria-label":i("Files"),title:i("Files"),children:d.jsx(sc,{className:"h-4 w-4"})}),u.map(P=>{const j=B?.rel===P.rel&&B.at==="tab"&&!P.preview,H=d.jsxs("button",{type:"button","data-file-tab":P.rel,className:U("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs",P.rel===f?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),onClick:()=>{j||m(P.rel)},onDoubleClick:V=>{P.preview||(V.preventDefault(),V.stopPropagation(),Q({rel:P.rel,name:Ji(P.rel),at:"tab"}))},children:[j?d.jsx(Wn,{depth:0,kind:"file",variant:"tab",initial:B.name,onCancel:()=>Q(null),onCommit:V=>Cl(P.rel,V)}):d.jsxs("span",{className:"max-w-36 truncate",children:[Ji(P.preview?ji(P.rel):P.rel),P.preview?` ${i("Preview")}`:"",P.dirty?"*":""]}),d.jsx("button",{type:"button",className:"text-muted-foreground hover:text-destructive",onClick:V=>{V.stopPropagation(),Ai(P.rel)},children:"×"})]});return d.jsxs(Ca,{children:[d.jsx(Da,{render:H}),d.jsxs(ka,{className:"min-w-40",children:[Rx(P.rel,ve).map(V=>V.id==="copy-path"?d.jsx(nt,{onClick:()=>{window.electronAPI.workspaceFiles.copyPath({...r,rel:V.rel,mode:V.mode})},children:i("Copy Path")},V.id):d.jsx(nt,{onClick:()=>{window.electronAPI.workspaceFiles.reveal({...r,rel:V.rel})},children:i(km())},V.id)),d.jsx(yc,{}),!P.preview&&d.jsx(nt,{onClick:()=>Q({rel:P.rel,name:Ji(P.rel),at:"tab"}),children:i("Rename")}),d.jsx(nt,{onClick:()=>Ai(P.rel),children:i("Close")}),d.jsx(nt,{onClick:()=>{const V=re.current,q=P.rel,he=V.some(fe=>fe.rel!==q&&fe.dirty);He(fe=>fe!==q&&!V.find(At=>At.rel===fe)?.dirty),he&&Gt({kind:"others",rel:q})},children:i("Close others")}),d.jsx(nt,{onClick:()=>{const V=re.current,q=wo(V.map(fe=>fe.rel),P.rel,"right"),he=q.some(fe=>V.find(At=>At.rel===fe)?.dirty);He(fe=>q.includes(fe)&&!V.find(At=>At.rel===fe)?.dirty),he&&Gt({kind:"right",rel:P.rel})},children:i("Close tabs to the right")}),d.jsx(nt,{onClick:()=>{const V=re.current;He(q=>!V.find(he=>he.rel===q)?.dirty)},children:i("Close saved")}),d.jsx(nt,{onClick:()=>{const V=re.current,q=V.some(he=>he.dirty);He(he=>!V.find(fe=>fe.rel===he)?.dirty),q&&Gt({kind:"all"})},children:i("Close all")}),d.jsx(nt,{onClick:()=>He(V=>V!==P.rel),children:i("Force close others")}),d.jsx(nt,{onClick:()=>He(()=>!0),children:i("Force close all")})]})]},P.rel)})]}),ge?.conflict&&d.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-2 py-1 text-[11px]",children:[d.jsx("span",{children:i("This file changed on disk.")}),d.jsx("button",{type:"button",className:"underline",disabled:a,onClick:()=>{l(ji(ge.rel)).then(P=>{P?.ok&&p(j=>j.map(H=>H.rel===ge.rel?{...H,contents:P.content,draft:P.content,version:H.version+1,dirty:!1,conflict:!1}:H))})},children:i("Reload")})]}),d.jsxs("div",{className:"relative min-h-0 flex-1",children:[ge&&!ge.preview&&!ge.tooLarge&&(_r(ge.rel)||vr.length>0)&&d.jsx("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:qi?d.jsxs(Me,{type:"button",variant:"outline",size:"sm","aria-label":i("View Source"),onClick:()=>Sl(ge.rel,void 0),children:[d.jsx(Rl,{className:"h-3.5 w-3.5"}),i("View Source")]}):d.jsxs(d.Fragment,{children:[vr.map(P=>d.jsxs(Me,{type:"button",variant:"outline",size:"sm","aria-label":P.title,title:P.pluginName,onClick:()=>Sl(ge.rel,vs(P)),children:[d.jsx(Tl,{className:"h-3.5 w-3.5"}),P.title]},vs(P))),_r(ge.rel)&&d.jsxs(Me,{type:"button",variant:"outline",size:"sm","aria-label":ge.viewMode==="preview"?i("View Source"):i("Preview"),onClick:()=>gf(ge.rel),children:[ge.viewMode==="preview"?d.jsx(Rl,{className:"h-3.5 w-3.5"}):d.jsx(Tl,{className:"h-3.5 w-3.5"}),ge.viewMode==="preview"?i("View Source"):i("Preview")]})]})}),!h||!ge?d.jsx("div",{className:"flex h-full items-center justify-center px-3 text-center text-sm text-muted-foreground",children:i(h?"Open a file from the tree.":"Loading...")}):ge.tooLarge?d.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:i("This file is too large to open in the editor.")}):ge.image?d.jsx(ax,{rel:ge.rel,version:ge.version,resolveImage:pf,onOpenSource:()=>{mf(ge.rel)}},ge.rel):qi?d.jsx(hr,{pluginId:qi.pluginId,entry:qi.entry,title:qi.title,sessionId:e,file:{rel:ge.rel,text:ge.draft,onEdit:P=>vf(ge.rel,P)}},`${ge.rel}:${vs(qi)}`):ge.preview||ge.viewMode==="preview"&&_r(ge.rel)?d.jsx("div",{className:"h-full overflow-auto px-3 py-2 text-sm",children:d.jsx(kx,{text:ge.preview?ge.contents:ge.draft,baseDirRel:Gx(ji(ge.rel)),resolveImage:uf,resolveRemoteImage:ff})}):d.jsx(uv,{style:{height:"100%",overflow:"auto"},children:d.jsx(xv,{file:{name:Ji(ge.rel),contents:ge.draft},disableWorkerPool:!0,edit:!0,editorOptions:_f,options:s},`${ge.rel}:${ge.version}`)})]})]})]}),d.jsx(Mn,{open:it!==null,onOpenChange:P=>{P||Gt(null)},title:i("Unsaved changes"),description:it?.kind==="one"?i("This file has unsaved changes. Close anyway?"):i("Some files have unsaved changes. Close anyway?"),confirmLabel:i("Close"),onConfirm:()=>{if(it){if(it.kind==="one"&&it.rel)us(it.rel);else if(it.kind==="others"&&it.rel){const P=it.rel;He(j=>j!==P)}else if(it.kind==="right"&&it.rel){const P=it.rel,j=new Set(wo(re.current.map(H=>H.rel),P,"right"));He(H=>j.has(H))}else He(()=>!0);Gt(null)}}}),d.jsx(Mn,{open:ie!==null,onOpenChange:P=>{P||ne(null)},title:i("Delete"),description:i("Delete {{name}} permanently?",{name:ie?.name??""}),confirmLabel:i("Delete"),onConfirm:()=>{if(!ie)return;const{rel:P}=ie;window.electronAPI.workspaceFiles.remove({...r,rel:P}).then(j=>{if(!j.ok){Re(j.error);return}we(P),He(H=>bo(H,P)),x(H=>{let V=!1;const q=new Set;for(const he of H){if(bo(he,P)){V=!0;continue}q.add(he)}return V?q:H}),ne(null),Xt()})}})]})}function Wn({depth:e,kind:t,initial:i,onCancel:s,onCommit:n,variant:r="tree"}){const[o,a]=w.useState(i),l=w.useRef(null),h=w.useRef(!0),c=w.useRef(!1);w.useEffect(()=>{const p=window.setTimeout(()=>{const m=l.current;m&&(m.focus(),m.select())},0),f=window.setTimeout(()=>{h.current=!1},50);return()=>{window.clearTimeout(p),window.clearTimeout(f)}},[]);const u=p=>{if(!c.current){if(p==="commit"&&Ix(o,i)==="commit"){c.current=!0,n(o.trim()).then(f=>{f||(c.current=!1,l.current?.focus())});return}c.current=!0,s()}};return d.jsx("input",{ref:l,className:r==="tab"?"max-w-36 rounded-sm border bg-background px-1 py-0 text-xs outline-none":"mx-1 my-0.5 w-[calc(100%-0.5rem)] rounded-sm border bg-background px-1 py-0.5 text-sm outline-none",style:r==="tree"?{marginLeft:8+e*12}:void 0,value:o,onChange:p=>a(p.target.value),onPointerDown:p=>p.stopPropagation(),onClick:p=>p.stopPropagation(),onBlur:()=>{if(h.current){l.current?.focus();return}u("commit")},onKeyDown:p=>{p.nativeEvent.isComposing||(p.key==="Escape"&&(p.preventDefault(),u("cancel")),p.key==="Enter"&&(p.preventDefault(),u("commit")))},"aria-label":t==="dir"?"New Folder":"New File"})}function Uu({rel:e,depth:t,conversationId:i,projectId:s,treeEpoch:n,...r}){const[o,a]=w.useState(null);if(w.useEffect(()=>{let h=!0;return window.electronAPI.workspaceFiles.listDir({conversationId:i,projectId:s,rel:e||void 0}).then(c=>{h&&a(c.ok?c.entries:[])}),()=>{h=!1}},[i,s,e,n]),!o)return d.jsx("div",{className:"px-2 py-1 text-muted-foreground",children:"…"});const l=r.draft?.parent===e;return d.jsxs("div",{children:[o.map(h=>{const c=Ox(e,h.name),u=r.expandedDirs.has(c);if(h.kind==="dir"){const f=r.renaming?.rel===c&&r.renaming.at==="tree"?d.jsx(Wn,{depth:t,kind:"dir",initial:h.name,onCancel:r.onRenameCancel,onCommit:m=>r.onRenameCommit(c,m)}):d.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left hover:bg-muted/60",style:{paddingLeft:8+t*12},onClick:()=>r.onToggleDir(c),children:[d.jsx(as,{className:U("h-3.5 w-3.5 shrink-0",u&&"rotate-90")}),(()=>{const m=ir(h.name,!0,u);return d.jsx(m,{className:U("h-4 w-4 shrink-0",sr(h.name,!0))})})(),d.jsx("span",{className:"truncate",children:h.name})]});return d.jsxs("div",{children:[d.jsx(tr,{target:{kind:"dir",rel:c,name:h.name},local:r.local,onNewFile:r.onNewFile,onNewFolder:r.onNewFolder,onCopyPath:r.onCopyPath,onCopyRel:r.onCopyRel,onReveal:r.onReveal,onRename:r.onRenameStart,onDelete:r.onDelete,children:f}),u&&d.jsx(Uu,{rel:c,depth:t+1,conversationId:i,projectId:s,treeEpoch:n,...r})]},c)}return d.jsx(jx,{rel:c,name:h.name,depth:t,renaming:r.renaming?.rel===c&&r.renaming.at==="tree",handlers:r},c)}),l&&r.draft&&d.jsx(Wn,{depth:t,kind:r.draft.kind,initial:"",onCancel:r.onDraftCancel,onCommit:h=>r.onDraftCommit(e,r.draft.kind,h)})]})}function jx({rel:e,name:t,depth:i,renaming:s,handlers:n}){const{setNodeRef:r,listeners:o,isDragging:a}=Fg({id:`workspace-file:${e}`,data:{type:"workspace-file",relativePath:e,name:t}}),l=s?d.jsx(Wn,{depth:i,kind:"file",initial:t,onCancel:n.onRenameCancel,onCommit:h=>n.onRenameCommit(e,h)}):d.jsxs("button",{type:"button",ref:r,...o,style:{paddingLeft:20+i*12,opacity:a?.4:void 0},className:"flex w-full cursor-default items-center gap-1.5 px-2 py-1 text-left hover:bg-muted/60",onClick:()=>n.onOpen(e),children:[(()=>{const h=ir(t,!1);return d.jsx(h,{className:U("h-4 w-4 shrink-0",sr(t,!1))})})(),d.jsx("span",{className:"truncate",children:t})]});return d.jsx(tr,{target:{kind:"file",rel:e,name:t},local:n.local,onNewFile:n.onNewFile,onNewFolder:n.onNewFolder,onView:n.onOpen,onPreview:n.onPreview,onBrowser:n.onBrowser,onCopyPath:n.onCopyPath,onCopyRel:n.onCopyRel,onCopyFile:n.onCopyFile,onReveal:n.onReveal,onRename:n.onRenameStart,onDelete:n.onDelete,onSend:(h,c)=>{so({kind:"file",id:h,label:c,relativePath:h})},children:l})}const yo=new Set,xo=new Set;function Ni(){for(const e of xo)e()}function Bx({panelId:e,conversationId:t,api:i,containerApi:s}){const n=w.useRef(null);return w.useEffect(()=>{const r=n.current;if(!r)return;const o={panelId:e,conversationId:t,el:r,api:i};yo.add(o),Ni();const a=new ResizeObserver(Ni);a.observe(r);const l=[i.onDidVisibilityChange(Ni),i.onDidActiveChange(Ni),i.onDidDimensionsChange(Ni),s.onDidLayoutChange(Ni)];return()=>{yo.delete(o),a.disconnect();for(const h of l)h.dispose();Ni()}},[e,t,i,s]),d.jsx("div",{ref:n,"data-global-plugin-slot":e,className:"h-full w-full"})}function $x(e,t){return e===t||!!e&&!!t&&e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Fh(e,t){if(t){for(const i of yo)if(!(i.panelId!==e||i.conversationId!==t)&&i.el.isConnected&&i.api.isVisible)return i}}function Wx(){const e=ce(p=>p.activeId),t=Pa(e),i=De(p=>p.liveGlobalTabs),s=Ks(),n=w.useRef(null),[r,o]=w.useState({}),[a,l]=w.useState({}),[h,c]=w.useState(!1);w.useEffect(()=>{const p=m=>{m.target instanceof Element&&m.target.closest(".dv-dockview")&&c(!0)},f=()=>c(!1);return document.addEventListener("dragstart",p,!0),document.addEventListener("dragend",f,!0),document.addEventListener("drop",f,!0),()=>{document.removeEventListener("dragstart",p,!0),document.removeEventListener("dragend",f,!0),document.removeEventListener("drop",f,!0)}},[]);const u=w.useCallback(()=>{const p=n.current;if(!p)return;const f=p.getBoundingClientRect(),m={};for(const _ of i){const D=(t?Fh(_,e):void 0)?.el.getBoundingClientRect();m[_]=D&&D.width>0&&D.height>0?{left:D.left-f.left,top:D.top-f.top,width:D.width,height:D.height}:null}o(_=>{let T=!1;const D={..._};for(const[E,S]of Object.entries(m))S&&!$x(_[E],S)&&(D[E]=S,T=!0);return T?D:_});const g=Object.fromEntries(Object.entries(m).map(([_,T])=>[_,T!==null]));l(_=>{const T=new Set([...Object.keys(_),...Object.keys(g)]);for(const D of T)if(_[D]!==g[D])return g;return _})},[e,i,t]);return w.useLayoutEffect(u,[u]),w.useEffect(()=>{let p=0;const f=()=>{p||(p=requestAnimationFrame(()=>{p=0,u()}))};xo.add(f);const m=new ResizeObserver(f);n.current&&m.observe(n.current),window.addEventListener("resize",f);const g=()=>{const _=document.activeElement;if(!_||!n.current?.contains(_))return;const T=_.closest("[data-global-plugin]")?.dataset.globalPlugin;T&&Fh(T,ce.getState().activeId)?.api.setActive()};return window.addEventListener("blur",g),()=>{p&&cancelAnimationFrame(p),xo.delete(f),m.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("blur",g)}},[u]),d.jsx("div",{ref:n,className:"enso-global-plugin-layer pointer-events-none absolute inset-0",children:i.map(p=>{const f=s.find(_=>Em(_)===p);if(!f)return null;const m=r[p],g={position:"absolute",left:m?.left??0,top:m?.top??0,width:m?.width??"100%",height:m?.height??"100%",visibility:a[p]&&!h?"visible":"hidden"};return d.jsx("div",{"data-global-plugin":p,style:g,children:d.jsx(hr,{pluginId:f.pluginId,entry:f.entry,title:f.title,sessionId:e})},p)})})}function Vh(e){return e.closest(".dv-tabs-overflow-container")}function Uh(e){const t=new Map;for(const i of e.children){if(!i.classList.contains("dv-tab"))continue;const s=i.querySelector("[data-panel-id]")?.getAttribute("data-panel-id");s&&t.set(s,i)}return t}function Hx(e){for(const t of e.children)if(t.classList.contains("dv-tab"))return!0;return!1}function Fx(e){const t=e.closest(".dv-popover-anchor"),i=e.parentElement;if(t&&i&&i.parentElement===t){i.remove();return}e.remove()}function Kh(e,t){for(const i of t)i.parentElement===e&&i.remove();Hx(e)||Fx(e)}function Vx(e){return e instanceof Error?e.message||e.name:String(e)}function Ux(e,t){const{error:i}=t,s=i instanceof Error?i.stack??`${i.name}: ${i.message}`:String(i);return[`[${e}]`,s,t.componentStack.trim()].filter(Boolean).join(`
|
|
16
|
-
`)}function Kx({name:e,failure:t,onRetry:i}){const{t:s}=ae(),[n,r]=w.useState(!1);return d.jsxs("div",{"data-enso":"side-panel-error","data-panel":e,role:"alert",className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center",children:[d.jsx(ec,{className:"size-5 text-warning"}),d.jsx("p",{className:"text-[13.5px] font-medium",children:s("This panel crashed")}),d.jsx("p",{"data-enso":"side-panel-error-message",className:"line-clamp-3 max-w-full break-words text-[12px] text-muted-foreground",children:Vx(t.error)}),d.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[d.jsx("button",{type:"button","data-enso":"side-panel-error-retry",onClick:i,className:"rounded-md bg-foreground px-3 py-1 text-[12px] text-background hover:opacity-90",children:s("Retry")}),d.jsx("button",{type:"button","data-enso":"side-panel-error-copy",onClick:()=>{Tm(Ux(e,t)).then(r)},className:"rounded-md border border-border px-3 py-1 text-[12px] text-muted-foreground hover:text-foreground",children:s(n?"Copied":"Copy error")})]})]})}class qx extends w.Component{state={failure:null};static getDerivedStateFromError(t){return{failure:{error:t,componentStack:""}}}componentDidCatch(t,i){console.error(`[side-panel] ${this.props.name} 渲染失败`,t),this.setState({failure:{error:t,componentStack:i.componentStack??""}})}render(){const{failure:t}=this.state;return t?d.jsx(Kx,{name:this.props.name,failure:t,onRetry:()=>this.setState({failure:null})}):this.props.children}}function Ku(e){return e.startsWith("pinned-terminal:")||/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e)}function qu(e){const t=e.indexOf(":",7);return e.startsWith("plugin:")&&t>7&&t<e.length-1}function Yx(e){if(e==="changes"||e==="files"||e==="workflow")return e;if(e==="browser"||e.startsWith("browser:"))return"browser";if(e.startsWith("btw:"))return"btw";if(qu(e))return e;if(Ku(e))return"terminal"}function Ir(e,t){return e.some(t)}function Xx(e){if(!Array.isArray(e.pinnedTabs))return[];const t=[...e.openPanelIds],i=[];for(const s of e.pinnedTabs)if(s==="terminal"&&!e.secretary){if(Ir(t,Ku))continue;i.push({kind:"terminal"}),t.push("pinned-terminal:planned")}else if(s==="changes"&&!e.secretary){if(t.includes("changes"))continue;i.push({kind:"changes"}),t.push("changes")}else if(s==="files"&&!e.secretary){if(t.includes("files"))continue;i.push({kind:"files"}),t.push("files")}else if(s==="browser"){if(Ir(t,n=>n==="browser"||n.startsWith("browser:")))continue;i.push({kind:"browser"}),t.push("browser:planned")}else if(s==="btw"&&!e.secretary){if(Ir(t,n=>n.startsWith("btw:")))continue;i.push({kind:"btw"}),t.push("btw:planned")}else if(s==="workflow"&&e.workflowAvailable&&!e.secretary){if(t.includes("workflow"))continue;i.push({kind:"workflow"}),t.push("workflow")}else if(typeof s=="string"&&s.startsWith("plugin:")){const n=e.pluginViews.find(r=>`plugin:${r.pluginId}:${r.id}`===s);if(!n||e.secretary&&!e.secretaryPluginIds?.includes(n.pluginId)||t.includes(s))continue;i.push({kind:"plugin",pluginId:n.pluginId,viewId:n.id}),t.push(s)}return i}function Hn(e,t,i,s){const n=e.getPanel("secretary");if(n){n.focus();return}e.addPanel({id:"secretary",component:"secretary",title:s,params:{conversationId:t,projectId:i}})}function Jx(){let e=!1;return({secretary:t,open:i,active:s,ready:n})=>i?e||!t||!s||!n?!1:(e=!0,!0):(e=!1,!1)}const qh="plugin:";function Zx(e,t){const i=new Set(t??[]);return e.filter(s=>i.has(s.pluginId))}function Qx(e,t,i=new Set){if(!t)return[];const s=new Set(t);return e.filter(n=>{if(!n.startsWith(qh)||i.has(n))return!1;const r=n.slice(qh.length).split(":")[0]??"";return!s.has(r)})}function eS({checked:e,onClick:t}){const{t:i}=ae();return d.jsxs(nt,{"data-enso":"side-tab-show-everywhere",role:"menuitemcheckbox","aria-checked":e,onClick:t,children:[d.jsx("span",{className:"min-w-0 flex-1",children:i("Show in all sessions")}),e?d.jsx(Di,{className:"size-3.5 text-primary"}):null]})}function tS({title:e,global:t}){const{t:i}=ae(),s=i("Show in all sessions");return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"min-w-0 max-w-32 truncate",children:e}),t?d.jsx("span",{"data-enso":"side-tab-global",role:"img","aria-label":s,title:s,className:"shrink-0 text-primary",children:d.jsx(Iv,{className:"h-3 w-3"})}):null]})}var iS=2,sS=1,nS=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),n=Math.max(0,parseInt(i.getPropertyValue("width"))),r=window.getComputedStyle(this._terminal.element),o={top:parseInt(r.getPropertyValue("padding-top")),bottom:parseInt(r.getPropertyValue("padding-bottom")),right:parseInt(r.getPropertyValue("padding-right")),left:parseInt(r.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,h=s-a,c=n-l-t;return{cols:Math.max(iS,Math.floor(c/e.css.cell.width)),rows:Math.max(sS,Math.floor(h/e.css.cell.height))}}};var rS=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Yh.isErrorNoTelemetry(t)?new Yh(t.message+`
|
|
17
|
-
|
|
18
|
-
`+t.stack):new Error(t.message+`
|
|
19
|
-
|
|
20
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(i=>{i(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},oS=new rS;function Ar(e){aS(e)||oS.onUnexpectedError(e)}var So="Canceled";function aS(e){return e instanceof lS?!0:e instanceof Error&&e.name===So&&e.message===So}var lS=class extends Error{constructor(){super(So),this.name=this.message}},Yh=class Co extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Co)return t;let i=new Co;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hS;(e=>{function t(r){return r<0}e.isLessThan=t;function i(r){return r<=0}e.isLessThanOrEqual=i;function s(r){return r>0}e.isGreaterThan=s;function n(r){return r===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(hS||={});function dS(e,t){let i=this,s=!1,n;return function(){return s||(s=!0,t||(n=e.apply(i,arguments))),n}}var Yu;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*n(S){yield S}e.single=n;function r(S){return t(S)?S:n(S)}e.wrap=r;function o(S){return S||i}e.from=o;function*a(S){for(let A=S.length-1;A>=0;A--)yield S[A]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(S){return S[Symbol.iterator]().next().value}e.first=h;function c(S,A){let k=0;for(let L of S)if(A(L,k++))return!0;return!1}e.some=c;function u(S,A){for(let k of S)if(A(k))return k}e.find=u;function*p(S,A){for(let k of S)A(k)&&(yield k)}e.filter=p;function*f(S,A){let k=0;for(let L of S)yield A(L,k++)}e.map=f;function*m(S,A){let k=0;for(let L of S)yield*A(L,k++)}e.flatMap=m;function*g(...S){for(let A of S)yield*A}e.concat=g;function _(S,A,k){let L=k;for(let O of S)L=A(L,O);return L}e.reduce=_;function*T(S,A,k=S.length){for(A<0&&(A+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);A<k;A++)yield S[A]}e.slice=T;function D(S,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,S];let L=S[Symbol.iterator]();for(let O=0;O<A;O++){let z=L.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return L}}]}e.consume=D;async function E(S){let A=[];for await(let k of S)A.push(k);return Promise.resolve(A)}e.asyncToArray=E})(Yu||={});function Gs(e){if(Yu.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Xu(...e){return ls(()=>Gs(e))}function ls(e){return{dispose:dS(()=>{e()})}}var Ju=class Zu{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Gs(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Zu.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Ju.DISABLE_DISPOSED_WARNING=!1;var Ja=Ju,Ti=class{constructor(){this._store=new Ja,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Ti.None=Object.freeze({dispose(){}});var Fn=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}clearAndLeak(){let t=this._value;return this._value=void 0,t}},cS=globalThis.performance&&typeof globalThis.performance.now=="function",uS=class Qu{static create(t){return new Qu(t)}constructor(t){this._now=cS&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Za;(e=>{e.None=()=>Ti.None;function t(C,v){return u(C,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(C){return(v,y=null,x)=>{let b=!1,R;return R=C(M=>{if(!b)return R?R.dispose():b=!0,v.call(y,M)},null,x),b&&R.dispose(),R}}e.once=i;function s(C,v,y){return h((x,b=null,R)=>C(M=>x.call(b,v(M)),null,R),y)}e.map=s;function n(C,v,y){return h((x,b=null,R)=>C(M=>{v(M),x.call(b,M)},null,R),y)}e.forEach=n;function r(C,v,y){return h((x,b=null,R)=>C(M=>v(M)&&x.call(b,M),null,R),y)}e.filter=r;function o(C){return C}e.signal=o;function a(...C){return(v,y=null,x)=>{let b=Xu(...C.map(R=>R(M=>v.call(y,M))));return c(b,x)}}e.any=a;function l(C,v,y,x){let b=y;return s(C,R=>(b=v(b,R),b),x)}e.reduce=l;function h(C,v){let y,x={onWillAddFirstListener(){y=C(b.fire,b)},onDidRemoveLastListener(){y?.dispose()}},b=new Ht(x);return v?.add(b),b.event}function c(C,v){return v instanceof Array?v.push(C):v&&v.add(C),C}function u(C,v,y=100,x=!1,b=!1,R,M){let W,B,Q,ie=0,ne,de={leakWarningThreshold:R,onWillAddFirstListener(){W=C(re=>{ie++,B=v(B,re),x&&!Q&&(ve.fire(B),B=void 0),ne=()=>{let me=B;B=void 0,Q=void 0,(!x||ie>1)&&ve.fire(me),ie=0},typeof y=="number"?(clearTimeout(Q),Q=setTimeout(ne,y)):Q===void 0&&(Q=0,queueMicrotask(ne))})},onWillRemoveListener(){b&&ie>0&&ne?.()},onDidRemoveLastListener(){ne=void 0,W.dispose()}},ve=new Ht(de);return M?.add(ve),ve.event}e.debounce=u;function p(C,v=0,y){return e.debounce(C,(x,b)=>x?(x.push(b),x):[b],v,void 0,!0,void 0,y)}e.accumulate=p;function f(C,v=(x,b)=>x===b,y){let x=!0,b;return r(C,R=>{let M=x||!v(R,b);return x=!1,b=R,M},y)}e.latch=f;function m(C,v,y){return[e.filter(C,v,y),e.filter(C,x=>!v(x),y)]}e.split=m;function g(C,v=!1,y=[],x){let b=y.slice(),R=C(B=>{b?b.push(B):W.fire(B)});x&&x.add(R);let M=()=>{b?.forEach(B=>W.fire(B)),b=null},W=new Ht({onWillAddFirstListener(){R||(R=C(B=>W.fire(B)),x&&x.add(R))},onDidAddFirstListener(){b&&(v?setTimeout(M):M())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return x&&x.add(W),W.event}e.buffer=g;function _(C,v){return(y,x,b)=>{let R=v(new D);return C(function(M){let W=R.evaluate(M);W!==T&&y.call(x,W)},void 0,b)}}e.chain=_;let T=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(y=>(v(y),y)),this}filter(v){return this.steps.push(y=>v(y)?y:T),this}reduce(v,y){let x=y;return this.steps.push(b=>(x=v(x,b),x)),this}latch(v=(y,x)=>y===x){let y=!0,x;return this.steps.push(b=>{let R=y||!v(b,x);return y=!1,x=b,R?b:T}),this}evaluate(v){for(let y of this.steps)if(v=y(v),v===T)break;return v}}function E(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.on(v,x),R=()=>C.removeListener(v,x),M=new Ht({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromNodeEventEmitter=E;function S(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.addEventListener(v,x),R=()=>C.removeEventListener(v,x),M=new Ht({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromDOMEventEmitter=S;function A(C){return new Promise(v=>i(C)(v))}e.toPromise=A;function k(C){let v=new Ht;return C.then(y=>{v.fire(y)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function L(C,v){return C(y=>v.fire(y))}e.forward=L;function O(C,v,y){return v(y),C(x=>v(x))}e.runAndSubscribe=O;class z{constructor(v,y){this._observable=v,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new Ht(x),y&&y.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,y){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function N(C,v){return new z(C,v).emitter.event}e.fromObservable=N;function I(C){return(v,y,x)=>{let b=0,R=!1,M={beginUpdate(){b++},endUpdate(){b--,b===0&&(C.reportChanges(),R&&(R=!1,v.call(y)))},handlePossibleChange(){},handleChange(){R=!0}};C.addObserver(M),C.reportChanges();let W={dispose(){C.removeObserver(M)}};return x instanceof Ja?x.add(W):Array.isArray(x)&&x.push(W),W}}e.fromObservableLight=I})(Za||={});var Do=class ko{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ko._idPool++}`,ko.all.add(this)}start(t){this._stopWatch=new uS,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Do.all=new Set,Do._idPool=0;var pS=Do,fS=-1,ep=class tp{constructor(t,i,s=(tp._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[r,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(r);let l=new vS(a,r);this._errorHandler(l)}return()=>{let r=this._stacks.get(t.value)||0;this._stacks.set(t.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,n]of this._stacks)(!t||i<n)&&(t=[s,n],i=n);return t}};ep._idPool=1;var mS=ep,gS=class ip{constructor(t){this.value=t}static create(){let t=new Error;return new ip(t.stack??"")}print(){console.warn(this.value.split(`
|
|
21
|
-
`).slice(2).join(`
|
|
22
|
-
`))}},vS=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},_S=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},bS=0,Rr=class{constructor(t){this.value=t,this.id=bS++}},wS=2,yS,Ht=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new mS(t?.onListenerError??Ar,this._options?.leakWarningThreshold??fS):void 0,this._perfMon=this._options?._profName?new pS(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new _S(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Ar)(h),Ti.None}if(this._disposed)return Ti.None;i&&(t=t.bind(i));let n=new Rr(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=gS.create(),r=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Rr?(this._deliveryQueue??=new xS,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ls(()=>{r?.(),this._removeListener(n)});return s instanceof Ja?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*wS<=i.length){let r=0;for(let o=0;o<i.length;o++)i[o]?i[r++]=i[o]:n&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=r}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Ar;if(!s){t.value(i);return}try{t.value(i)}catch(n){s(n)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Rr)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},xS=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},sp=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),SS;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof CS?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Za.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sp})})(SS||={});var CS=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?sp:(this._emitter||(this._emitter=new Ht),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},is="en",Nr=!1,vn,Dn=is,Xh=is,DS,si,$i=globalThis,bt;typeof $i.vscode<"u"&&typeof $i.vscode.process<"u"?bt=$i.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(bt=process);var kS=typeof bt?.versions?.electron=="string",PS=kS&&bt?.type==="renderer";if(typeof bt=="object"){bt.platform,bt.platform,Nr=bt.platform==="linux",Nr&&bt.env.SNAP&&bt.env.SNAP_REVISION,bt.env.CI||bt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,vn=is,Dn=is;let e=bt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);vn=t.userLocale,Xh=t.osLocale,Dn=t.resolvedLanguage||is,DS=t.languagePack?.translationsConfigFile}catch{}}else typeof navigator=="object"&&!PS?(si=navigator.userAgent,si.indexOf("Windows")>=0,si.indexOf("Macintosh")>=0,(si.indexOf("Macintosh")>=0||si.indexOf("iPad")>=0||si.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Nr=si.indexOf("Linux")>=0,si?.indexOf("Mobi")>=0,Dn=globalThis._VSCODE_NLS_LANGUAGE||is,vn=navigator.language.toLowerCase(),Xh=vn):console.error("Unable to resolve platform.");var Kt=si,gi=Dn,ES;(e=>{function t(){return gi}e.value=t;function i(){return gi.length===2?gi==="en":gi.length>=3?gi[0]==="e"&&gi[1]==="n"&&gi[2]==="-":!1}e.isDefaultVariant=i;function s(){return gi==="en"}e.isDefault=s})(ES||={});var TS=typeof $i.postMessage=="function"&&!$i.importScripts;(()=>{if(TS){let e=[];$i.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,n=e.length;s<n;s++){let r=e[s];if(r.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),r.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),$i.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var IS=!!(Kt&&Kt.indexOf("Chrome")>=0);Kt&&Kt.indexOf("Firefox")>=0;!IS&&Kt&&Kt.indexOf("Safari")>=0;Kt&&Kt.indexOf("Edg/")>=0;Kt&&Kt.indexOf("Android")>=0;function np(e,t=0,i){let s=setTimeout(()=>{e()},t);return ls(()=>{clearTimeout(s)})}var AS;(e=>{async function t(s){let n,r=await Promise.all(s.map(o=>o.then(a=>a,a=>{n||(n=a)})));if(typeof n<"u")throw n;return r}e.settled=t;function i(s){return new Promise(async(n,r)=>{try{await s(n,r)}catch(o){r(o)}})}e.withAsyncBody=i})(AS||={});var Jh=class St{static fromArray(t){return new St(i=>{i.emitMany(t)})}static fromPromise(t){return new St(async i=>{i.emitMany(await t)})}static fromPromises(t){return new St(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new St(async i=>{await Promise.all(t.map(async s=>{for await(let n of s)i.emitOne(n)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Ht,queueMicrotask(async()=>{let s={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(s)),this.resolve()}catch(n){this.reject(n)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Za.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new St(async s=>{for await(let n of t)s.emitOne(i(n))})}map(t){return St.map(this,t)}static filter(t,i){return new St(async s=>{for await(let n of t)i(n)&&s.emitOne(n)})}filter(t){return St.filter(this,t)}static coalesce(t){return St.filter(t,i=>!!i)}coalesce(){return St.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return St.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Jh.EMPTY=Jh.fromArray([]);var RS=class extends Ti{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Fn),this._linesCacheDisposables=this._register(new Fn),this._register(ls(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Xu(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=np(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(t){return this._linesCache?.[t]}setLineInCache(t,i){this._linesCache&&(this._linesCache[t]=i)}translateBufferLineToStringWithWrap(t,i){let s=[],n=[0],r=this._terminal.buffer.active.getLine(t);for(;r;){let o=this._terminal.buffer.active.getLine(t+1),a=o?o.isWrapped:!1,l=r.translateToString(!a&&i);if(a&&o){let h=r.getCell(r.length-1);h&&h.getCode()===0&&h.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(l=l.slice(0,-1))}if(s.push(l),a)n.push(n[n.length-1]+l.length);else break;t++,r=o}return[s.join(""),n]}},NS=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,i){return i?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(i):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},LS=class{constructor(t,i){this._terminal=t,this._lineCache=i}find(t,i,s,n){if(!t||t.length===0){this._terminal.clearSelection();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:i,startCol:s},o=this._findInLine(t,r,n);if(!o)for(let a=i+1;a<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=a,r.startCol=0,o=this._findInLine(t,r,n),!o);a++);return o}findNextWithSelection(t,i,s){if(!t||t.length===0){this._terminal.clearSelection();return}let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,o=0;n&&(s===t?(r=n.end.x,o=n.end.y):(r=n.start.x,o=n.start.y)),this._lineCache.initLinesCache();let a={startRow:o,startCol:r},l=this._findInLine(t,a,i);if(!l)for(let h=o+1;h<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=h,a.startCol=0,l=this._findInLine(t,a,i),!l);h++);if(!l&&o!==0)for(let h=0;h<o&&(a.startRow=h,a.startCol=0,l=this._findInLine(t,a,i),!l);h++);return!l&&n&&(a.startRow=n.start.y,a.startCol=0,l=this._findInLine(t,a,i)),l}findPreviousWithSelection(t,i,s){if(!t||t.length===0){this._terminal.clearSelection();return}let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,o=this._terminal.cols,a=!0;this._lineCache.initLinesCache();let l={startRow:r,startCol:o},h;if(n&&(l.startRow=r=n.start.y,l.startCol=o=n.start.x,s!==t&&(h=this._findInLine(t,l,i,!1),h||(l.startRow=r=n.end.y,l.startCol=o=n.end.x))),h||(h=this._findInLine(t,l,i,a)),!h){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let c=r-1;c>=0&&(l.startRow=c,h=this._findInLine(t,l,i,a),!h);c--);}if(!h&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let c=this._terminal.buffer.active.baseY+this._terminal.rows-1;c>=r&&(l.startRow=c,h=this._findInLine(t,l,i,a),!h);c--);return h}_isWholeWord(t,i,s){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t-1]))&&(t+s.length===i.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t+s.length]))}_findInLine(t,i,s={},n=!1){let r=i.startRow,o=i.startCol;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(n){i.startCol+=this._terminal.cols;return}return i.startRow--,i.startCol+=this._terminal.cols,this._findInLine(t,i,s)}let a=this._lineCache.getLineFromCache(r);a||(a=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,a));let[l,h]=a,c=this._bufferColsToStringOffset(r,o),u=t,p=l;s.regex||(u=s.caseSensitive?t:t.toLowerCase(),p=s.caseSensitive?l:l.toLowerCase());let f=-1;if(s.regex){let m=RegExp(u,s.caseSensitive?"g":"gi"),g;if(n)for(;g=m.exec(p.slice(0,c));)f=m.lastIndex-g[0].length,t=g[0],m.lastIndex-=t.length-1;else g=m.exec(p.slice(c)),g&&g[0].length>0&&(f=c+(m.lastIndex-g[0].length),t=g[0])}else n?c-u.length>=0&&(f=p.lastIndexOf(u,c-u.length)):f=p.indexOf(u,c);if(f>=0){if(s.wholeWord&&!this._isWholeWord(f,p,t))return;let m=0;for(;m<h.length-1&&f>=h[m+1];)m++;let g=m;for(;g<h.length-1&&f+t.length>=h[g+1];)g++;let _=f-h[m],T=f+t.length-h[g],D=this._stringLengthToBufferSize(r+m,_),E=this._stringLengthToBufferSize(r+g,T)-D+this._terminal.cols*(g-m);return{term:t,col:D,row:r+m,size:E}}}_stringLengthToBufferSize(t,i){let s=this._terminal.buffer.active.getLine(t);if(!s)return 0;for(let n=0;n<i;n++){let r=s.getCell(n);if(!r)break;let o=r.getChars();o.length>1&&(i-=o.length-1);let a=s.getCell(n+1);a&&a.getWidth()===0&&i++}return i}_bufferColsToStringOffset(t,i){let s=t,n=0,r=this._terminal.buffer.active.getLine(s);for(;i>0&&r;){for(let o=0;o<i&&o<this._terminal.cols;o++){let a=r.getCell(o);if(!a)break;a.getWidth()&&(n+=a.getCode()===0?1:a.getChars().length)}if(s++,r=this._terminal.buffer.active.getLine(s),r&&!r.isWrapped)break;i-=this._terminal.cols}return n}},MS=class extends Ti{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ls(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,i){this.clearHighlightDecorations();for(let s of t){let n=this._createResultDecorations(s,i,!1);if(n)for(let r of n)this._storeDecoration(r,s)}}createActiveDecoration(t,i){let s=this._createResultDecorations(t,i,!0);if(s)return{decorations:s,match:t,dispose(){Gs(s)}}}clearHighlightDecorations(){Gs(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,i){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:i,dispose(){t.dispose()}})}_applyStyles(t,i,s){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),i&&(t.style.outline=`1px solid ${i}`)),s&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,i,s){let n=[],r=t.col,o=t.size,a=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;o>0;){let h=Math.min(this._terminal.cols-r,o);n.push([a,r,h]),r=0,o-=h,a++}let l=[];for(let h of n){let c=this._terminal.registerMarker(h[0]),u=this._terminal.registerDecoration({marker:c,x:h[1],width:h[2],backgroundColor:s?i.activeMatchBackground:i.matchBackground,overviewRulerOptions:this._highlightedLines.has(c.line)?void 0:{color:s?i.activeMatchColorOverviewRuler:i.matchOverviewRuler,position:"center"}});if(u){let p=[];p.push(c),p.push(u.onRender(f=>this._applyStyles(f,s?i.activeMatchBorder:i.matchBorder,!1))),p.push(u.onDispose(()=>Gs(p))),l.push(u)}}return l.length===0?void 0:l}},OS=class extends Ti{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Ht)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,i){this._searchResults=t.slice(0,i)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let i=0;i<this._searchResults.length;i++){let s=this._searchResults[i];if(s.row===t.row&&s.col===t.col&&s.size===t.size)return i}return-1}fireResultsChanged(t){if(!t)return;let i=-1;this._selectedDecoration&&(i=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:i,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},GS=class extends Ti{constructor(t){super(),this._highlightTimeout=this._register(new Fn),this._lineCache=this._register(new Fn),this._state=new NS,this._resultTracker=this._register(new OS),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new RS(t),this._engine=new LS(t,this._lineCache.value),this._decorationManager=new MS(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ls(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=np(()=>{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,i,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let n=this._findNextAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,n}_highlightAllMatches(t,i){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 s=[],n,r=this._engine.find(t,0,0,i);for(;r&&(n?.row!==r.row||n?.col!==r.col)&&!(s.length>=this._highlightLimit);)n=r,s.push(n),r=this._engine.find(t,n.col+n.term.length>=this._terminal.cols?n.row+1:n.row,n.col+n.term.length>=this._terminal.cols?0:n.col+1,i);this._resultTracker.updateResults(s,this._highlightLimit),i.decorations&&this._decorationManager.createHighlightDecorations(s,i.decorations)}_findNextAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let n=this._engine.findNextWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(n,i?.decorations,s?.noScroll)}findPrevious(t,i,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let n=this._findPreviousAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,n}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let n=this._engine.findPreviousWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(n,i?.decorations,s?.noScroll)}_selectResult(t,i,s){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),i){let n=this._decorationManager.createActiveDecoration(t,i);n&&(this._resultTracker.selectedDecoration=n)}if(!s&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let n=t.row-this._terminal.buffer.active.viewportY;n-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(n)}return!0}};var Lr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],zS=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ve;function jS(e,t){let i=0,s=t.length-1,n;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(n=i+s>>1,e>t[n][1])i=n+1;else if(e<t[n][0])s=n-1;else return!0;return!1}var BS=class{constructor(){if(this.version="6",!Ve){Ve=new Uint8Array(65536),Ve.fill(1),Ve[0]=0,Ve.fill(0,1,32),Ve.fill(0,127,160),Ve.fill(2,4352,4448),Ve[9001]=2,Ve[9002]=2,Ve.fill(2,11904,42192),Ve[12351]=1,Ve.fill(2,44032,55204),Ve.fill(2,63744,64256),Ve.fill(2,65040,65050),Ve.fill(2,65072,65136),Ve.fill(2,65280,65377),Ve.fill(2,65504,65511);for(let t=0;t<Lr.length;++t)Ve.fill(0,Lr[t][0],Lr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Ve[t]:jS(t,zS)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,i){let s=this.wcwidth(t),n=s===0&&i!==0;if(n){let r=Un.extractWidth(i);r===0?n=!1:r>s&&(s=r)}return Un.createPropertyValue(0,s,n)}},$S=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Zh.isErrorNoTelemetry(t)?new Zh(t.message+`
|
|
23
|
-
|
|
24
|
-
`+t.stack):new Error(t.message+`
|
|
25
|
-
|
|
26
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(i=>{i(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},WS=new $S;function Mr(e){HS(e)||WS.onUnexpectedError(e)}var Po="Canceled";function HS(e){return e instanceof FS?!0:e instanceof Error&&e.name===Po&&e.message===Po}var FS=class extends Error{constructor(){super(Po),this.name=this.message}},Zh=class Eo extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Eo)return t;let i=new Eo;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};function VS(e,t){let i=this,s=!1,n;return function(){return s||(s=!0,t||(n=e.apply(i,arguments))),n}}var US;(e=>{function t(r){return r<0}e.isLessThan=t;function i(r){return r<=0}e.isLessThanOrEqual=i;function s(r){return r>0}e.isGreaterThan=s;function n(r){return r===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(US||={});var rp;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*n(S){yield S}e.single=n;function r(S){return t(S)?S:n(S)}e.wrap=r;function o(S){return S||i}e.from=o;function*a(S){for(let A=S.length-1;A>=0;A--)yield S[A]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(S){return S[Symbol.iterator]().next().value}e.first=h;function c(S,A){let k=0;for(let L of S)if(A(L,k++))return!0;return!1}e.some=c;function u(S,A){for(let k of S)if(A(k))return k}e.find=u;function*p(S,A){for(let k of S)A(k)&&(yield k)}e.filter=p;function*f(S,A){let k=0;for(let L of S)yield A(L,k++)}e.map=f;function*m(S,A){let k=0;for(let L of S)yield*A(L,k++)}e.flatMap=m;function*g(...S){for(let A of S)yield*A}e.concat=g;function _(S,A,k){let L=k;for(let O of S)L=A(L,O);return L}e.reduce=_;function*T(S,A,k=S.length){for(A<0&&(A+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);A<k;A++)yield S[A]}e.slice=T;function D(S,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,S];let L=S[Symbol.iterator]();for(let O=0;O<A;O++){let z=L.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return L}}]}e.consume=D;async function E(S){let A=[];for await(let k of S)A.push(k);return Promise.resolve(A)}e.asyncToArray=E})(rp||={});function op(e){if(rp.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function KS(...e){return ap(()=>op(e))}function ap(e){return{dispose:VS(()=>{e()})}}var lp=class hp{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{op(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?hp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};lp.DISABLE_DISPOSED_WARNING=!1;var Qa=lp,Vn=class{constructor(){this._store=new Qa,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Vn.None=Object.freeze({dispose(){}});var qS=globalThis.performance&&typeof globalThis.performance.now=="function",YS=class dp{static create(t){return new dp(t)}constructor(t){this._now=qS&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},XS;(e=>{e.None=()=>Vn.None;function t(C,v){return u(C,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(C){return(v,y=null,x)=>{let b=!1,R;return R=C(M=>{if(!b)return R?R.dispose():b=!0,v.call(y,M)},null,x),b&&R.dispose(),R}}e.once=i;function s(C,v,y){return h((x,b=null,R)=>C(M=>x.call(b,v(M)),null,R),y)}e.map=s;function n(C,v,y){return h((x,b=null,R)=>C(M=>{v(M),x.call(b,M)},null,R),y)}e.forEach=n;function r(C,v,y){return h((x,b=null,R)=>C(M=>v(M)&&x.call(b,M),null,R),y)}e.filter=r;function o(C){return C}e.signal=o;function a(...C){return(v,y=null,x)=>{let b=KS(...C.map(R=>R(M=>v.call(y,M))));return c(b,x)}}e.any=a;function l(C,v,y,x){let b=y;return s(C,R=>(b=v(b,R),b),x)}e.reduce=l;function h(C,v){let y,x={onWillAddFirstListener(){y=C(b.fire,b)},onDidRemoveLastListener(){y?.dispose()}},b=new yi(x);return v?.add(b),b.event}function c(C,v){return v instanceof Array?v.push(C):v&&v.add(C),C}function u(C,v,y=100,x=!1,b=!1,R,M){let W,B,Q,ie=0,ne,de={leakWarningThreshold:R,onWillAddFirstListener(){W=C(re=>{ie++,B=v(B,re),x&&!Q&&(ve.fire(B),B=void 0),ne=()=>{let me=B;B=void 0,Q=void 0,(!x||ie>1)&&ve.fire(me),ie=0},typeof y=="number"?(clearTimeout(Q),Q=setTimeout(ne,y)):Q===void 0&&(Q=0,queueMicrotask(ne))})},onWillRemoveListener(){b&&ie>0&&ne?.()},onDidRemoveLastListener(){ne=void 0,W.dispose()}},ve=new yi(de);return M?.add(ve),ve.event}e.debounce=u;function p(C,v=0,y){return e.debounce(C,(x,b)=>x?(x.push(b),x):[b],v,void 0,!0,void 0,y)}e.accumulate=p;function f(C,v=(x,b)=>x===b,y){let x=!0,b;return r(C,R=>{let M=x||!v(R,b);return x=!1,b=R,M},y)}e.latch=f;function m(C,v,y){return[e.filter(C,v,y),e.filter(C,x=>!v(x),y)]}e.split=m;function g(C,v=!1,y=[],x){let b=y.slice(),R=C(B=>{b?b.push(B):W.fire(B)});x&&x.add(R);let M=()=>{b?.forEach(B=>W.fire(B)),b=null},W=new yi({onWillAddFirstListener(){R||(R=C(B=>W.fire(B)),x&&x.add(R))},onDidAddFirstListener(){b&&(v?setTimeout(M):M())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return x&&x.add(W),W.event}e.buffer=g;function _(C,v){return(y,x,b)=>{let R=v(new D);return C(function(M){let W=R.evaluate(M);W!==T&&y.call(x,W)},void 0,b)}}e.chain=_;let T=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(y=>(v(y),y)),this}filter(v){return this.steps.push(y=>v(y)?y:T),this}reduce(v,y){let x=y;return this.steps.push(b=>(x=v(x,b),x)),this}latch(v=(y,x)=>y===x){let y=!0,x;return this.steps.push(b=>{let R=y||!v(b,x);return y=!1,x=b,R?b:T}),this}evaluate(v){for(let y of this.steps)if(v=y(v),v===T)break;return v}}function E(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.on(v,x),R=()=>C.removeListener(v,x),M=new yi({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromNodeEventEmitter=E;function S(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.addEventListener(v,x),R=()=>C.removeEventListener(v,x),M=new yi({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromDOMEventEmitter=S;function A(C){return new Promise(v=>i(C)(v))}e.toPromise=A;function k(C){let v=new yi;return C.then(y=>{v.fire(y)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function L(C,v){return C(y=>v.fire(y))}e.forward=L;function O(C,v,y){return v(y),C(x=>v(x))}e.runAndSubscribe=O;class z{constructor(v,y){this._observable=v,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new yi(x),y&&y.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,y){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function N(C,v){return new z(C,v).emitter.event}e.fromObservable=N;function I(C){return(v,y,x)=>{let b=0,R=!1,M={beginUpdate(){b++},endUpdate(){b--,b===0&&(C.reportChanges(),R&&(R=!1,v.call(y)))},handlePossibleChange(){},handleChange(){R=!0}};C.addObserver(M),C.reportChanges();let W={dispose(){C.removeObserver(M)}};return x instanceof Qa?x.add(W):Array.isArray(x)&&x.push(W),W}}e.fromObservableLight=I})(XS||={});var To=class Io{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Io._idPool++}`,Io.all.add(this)}start(t){this._stopWatch=new YS,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};To.all=new Set,To._idPool=0;var JS=To,ZS=-1,cp=class up{constructor(t,i,s=(up._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[r,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(r);let l=new tC(a,r);this._errorHandler(l)}return()=>{let r=this._stacks.get(t.value)||0;this._stacks.set(t.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,n]of this._stacks)(!t||i<n)&&(t=[s,n],i=n);return t}};cp._idPool=1;var QS=cp,eC=class pp{constructor(t){this.value=t}static create(){let t=new Error;return new pp(t.stack??"")}print(){console.warn(this.value.split(`
|
|
27
|
-
`).slice(2).join(`
|
|
28
|
-
`))}},tC=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},iC=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},sC=0,Or=class{constructor(e){this.value=e,this.id=sC++}},nC=2,rC,yi=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new QS(t?.onListenerError??Mr,this._options?.leakWarningThreshold??ZS):void 0,this._perfMon=this._options?._profName?new JS(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new iC(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Mr)(h),Vn.None}if(this._disposed)return Vn.None;i&&(t=t.bind(i));let n=new Or(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=eC.create(),r=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Or?(this._deliveryQueue??=new oC,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ap(()=>{r?.(),this._removeListener(n)});return s instanceof Qa?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*nC<=i.length){let r=0;for(let o=0;o<i.length;o++)i[o]?i[r++]=i[o]:n&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=r}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Mr;if(!s){t.value(i);return}try{t.value(i)}catch(n){s(n)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Or)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},oC=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Un=class kn{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new yi,this.onChange=this._onChange.event;let t=new BS;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,n=t.length;for(let r=0;r<n;++r){let o=t.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=n)return i+this.wcwidth(o);let h=t.charCodeAt(r);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=kn.extractWidth(a);kn.extractShouldJoin(a)&&(l-=kn.extractWidth(s)),i+=l,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Gr=[[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]],aC=[[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]],zr=[[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]],lC=[[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]],Qt;function Qh(e,t){let i=0,s=t.length-1,n;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(n=i+s>>1,e>t[n][1])i=n+1;else if(e<t[n][0])s=n-1;else return!0;return!1}var hC=class{constructor(){if(this.version="11",!Qt){Qt=new Uint8Array(65536),Qt.fill(1),Qt[0]=0,Qt.fill(0,1,32),Qt.fill(0,127,160);for(let t=0;t<Gr.length;++t)Qt.fill(0,Gr[t][0],Gr[t][1]+1);for(let t=0;t<zr.length;++t)Qt.fill(2,zr[t][0],zr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Qt[t]:Qh(t,aC)?0:Qh(t,lC)?2:1}charProperties(t,i){let s=this.wcwidth(t),n=s===0&&i!==0;if(n){let r=Un.extractWidth(i);r===0?n=!1:r>s&&(s=r)}return Un.createPropertyValue(0,s,n)}},dC=class{activate(e){e.unicode.register(new hC)}dispose(){}};var cC=class{constructor(t,i,s,n={}){this._terminal=t,this._regex=i,this._handler=s,this._options=n}provideLinks(t,i){let s=pC.computeLink(t,this._regex,this._terminal,this._handler);i(this._addCallbacks(s))}_addCallbacks(t){return t.map(i=>(i.leave=this._options.leave,i.hover=(s,n)=>{if(this._options.hover){let{range:r}=i;this._options.hover(s,n,r)}},i))}};function uC(e){try{let t=new URL(e),i=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(i.toLocaleLowerCase())}catch{return!1}}var pC=class Pn{static computeLink(t,i,s,n){let r=new RegExp(i.source,(i.flags||"")+"g"),[o,a]=Pn._getWindowedLineStrings(t-1,s),l=o.join(""),h,c=[];for(;h=r.exec(l);){let u=h[0];if(!uC(u))continue;let[p,f]=Pn._mapStrIdx(s,a,0,h.index),[m,g]=Pn._mapStrIdx(s,p,f,u.length);if(p===-1||f===-1||m===-1||g===-1)continue;let _={start:{x:f+1,y:p+1},end:{x:g,y:m+1}};c.push({range:_,text:u,activate:n})}return c}static _getWindowedLineStrings(t,i){let s,n=t,r=t,o=0,a="",l=[];if(s=i.buffer.active.getLine(t)){let h=s.translateToString(!0);if(s.isWrapped&&h[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--n))&&o<2048&&(a=s.translateToString(!0),o+=a.length,l.push(a),!(!s.isWrapped||a.indexOf(" ")!==-1)););l.reverse()}for(l.push(h),o=0;(s=i.buffer.active.getLine(++r))&&s.isWrapped&&o<2048&&(a=s.translateToString(!0),o+=a.length,l.push(a),a.indexOf(" ")===-1););}return[l,n]}static _mapStrIdx(t,i,s,n){let r=t.buffer.active,o=r.getNullCell(),a=s;for(;n;){let l=r.getLine(i);if(!l)return[-1,-1];for(let h=a;h<l.length;++h){l.getCell(h,o);let c=o.getChars();if(o.getWidth()&&(n-=c.length||1,h===l.length-1&&c==="")){let u=r.getLine(i+1);u&&u.isWrapped&&(u.getCell(0,o),o.getWidth()===2&&(n+=1))}if(n<0)return[i,h]}i++,a=0}return[i,a]}},fC=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function mC(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var gC=class{constructor(t=mC,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options,s=i.urlRegex||fC;this._linkProvider=this._terminal.registerLinkProvider(new cC(this._terminal,s,this._handler,i))}dispose(){this._linkProvider?.dispose()}};var fp=Object.defineProperty,vC=Object.getOwnPropertyDescriptor,_C=(e,t)=>{for(var i in t)fp(e,i,{get:t[i],enumerable:!0})},ze=(e,t,i,s)=>{for(var n=s>1?void 0:s?vC(t,i):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(n=(s?o(t,i,n):o(n))||n);return s&&n&&fp(t,i,n),n},ee=(e,t)=>(i,s)=>t(i,s,e),ed="Terminal input",Ao={get:()=>ed,set:e=>ed=e},td="Too much output to announce, navigate to rows manually to read",Ro={get:()=>td,set:e=>td=e};function bC(e){return e.replace(/\r?\n/g,"\r")}function wC(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function yC(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function xC(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");mp(n,t,i,s)}}function mp(e,t,i,s){e=bC(e),e=wC(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function gp(e,t,i){let s=i.getBoundingClientRect(),n=e.clientX-s.left-10,r=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${r}px`,t.style.zIndex="1000",t.focus()}function id(e,t,i,s,n){gp(e,t,i),n&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Si(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function dr(e,t=0,i=e.length){let s="";for(let n=t;n<i;++n){let r=e[n];r>65535?(r-=65536,s+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):s+=String.fromCharCode(r)}return s}var SC=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,n=0;if(this._interim){let r=e.charCodeAt(n++);56320<=r&&r<=57343?t[s++]=(this._interim-55296)*1024+r-56320+65536:(t[s++]=this._interim,t[s++]=r),this._interim=0}for(let r=n;r<i;++r){let o=e.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=i)return this._interim=o,s;let a=e.charCodeAt(r);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},CC=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,n,r,o,a,l=0,h=0;if(this.interim[0]){let p=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let m=0,g;for(;(g=this.interim[++m]&63)&&m<4;)f<<=6,f|=g;let _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,T=_-m;for(;h<T;){if(h>=i)return 0;if(g=e[h++],(g&192)!==128){h--,p=!0;break}else this.interim[m++]=g,f<<=6,f|=g&63}p||(_===2?f<128?h--:t[s++]=f:_===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,u=h;for(;u<i;){for(;u<c&&!((n=e[u])&128)&&!((r=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[s++]=n,t[s++]=r,t[s++]=o,t[s++]=a,u+=4;if(n=e[u++],n<128)t[s++]=n;else if((n&224)===192){if(u>=i)return this.interim[0]=n,s;if(r=e[u++],(r&192)!==128){u--;continue}if(l=(n&31)<<6|r&63,l<128){u--;continue}t[s++]=l}else if((n&240)===224){if(u>=i)return this.interim[0]=n,s;if(r=e[u++],(r&192)!==128){u--;continue}if(u>=i)return this.interim[0]=n,this.interim[1]=r,s;if(o=e[u++],(o&192)!==128){u--;continue}if(l=(n&15)<<12|(r&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[s++]=l}else if((n&248)===240){if(u>=i)return this.interim[0]=n,s;if(r=e[u++],(r&192)!==128){u--;continue}if(u>=i)return this.interim[0]=n,this.interim[1]=r,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=n,this.interim[1]=r,this.interim[2]=o,s;if(a=e[u++],(a&192)!==128){u--;continue}if(l=(n&7)<<18|(r&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[s++]=l}}return s}},vp="",Ci=" ",Xs=class _p{constructor(){this.fg=0,this.bg=0,this.extended=new Kn}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 _p;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}},Kn=class bp{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 bp(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},It=class wp extends Xs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Kn,this.combinedData=""}static fromCharData(t){let i=new wp;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Si(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(s-55296)*1024+n-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},sd="di$target",No="di$dependencies",jr=new Map;function DC(e){return e[No]||[]}function tt(e){if(jr.has(e))return jr.get(e);let t=function(i,s,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");kC(t,i,n)};return t._id=e,jr.set(e,t),t}function kC(e,t,i){t[sd]===t?t[No].push({id:e,index:i}):(t[No]=[{id:e,index:i}],t[sd]=t)}var ht=tt("BufferService"),yp=tt("CoreMouseService"),Ki=tt("CoreService"),PC=tt("CharsetService"),el=tt("InstantiationService"),xp=tt("LogService"),dt=tt("OptionsService"),Sp=tt("OscLinkService"),EC=tt("UnicodeService"),Js=tt("DecorationService"),Lo=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],n=this._optionsService.rawOptions.linkHandler,r=new It,o=i.getTrimmedLength(),a=-1,l=-1,h=!1;for(let c=0;c<o;c++)if(!(l===-1&&!i.hasContent(c))){if(i.loadCell(c,r),r.hasExtendedAttrs()&&r.extended.urlId)if(l===-1){l=c,a=r.extended.urlId;continue}else h=r.extended.urlId!==a;else l!==-1&&(h=!0);if(h||l!==-1&&c===o-1){let u=this._oscLinkService.getLinkData(a)?.uri;if(u){let p={start:{x:l+1,y:e},end:{x:c+(!h&&c===o-1?1:0),y:e}},f=!1;if(!n?.allowNonHttpProtocols)try{let m=new URL(u);["http:","https:"].includes(m.protocol)||(f=!0)}catch{f=!0}f||s.push({text:u,range:p,activate:(m,g)=>n?n.activate(m,g,p):TC(m,g),hover:(m,g)=>n?.hover?.(m,g,p),leave:(m,g)=>n?.leave?.(m,g,p)})}h=!1,r.hasExtendedAttrs()&&r.extended.urlId?(l=c,a=r.extended.urlId):(l=-1,a=-1)}}t(s)}};Lo=ze([ee(0,ht),ee(1,dt),ee(2,Sp)],Lo);function TC(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
29
|
-
|
|
30
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var cr=tt("CharSizeService"),ui=tt("CoreBrowserService"),tl=tt("MouseService"),pi=tt("RenderService"),IC=tt("SelectionService"),Cp=tt("CharacterJoinerService"),hs=tt("ThemeService"),Dp=tt("LinkProviderService"),AC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?nd.isErrorNoTelemetry(e)?new nd(e.message+`
|
|
31
|
-
|
|
32
|
-
`+e.stack):new Error(e.message+`
|
|
33
|
-
|
|
34
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},RC=new AC;function En(e){NC(e)||RC.onUnexpectedError(e)}var Mo="Canceled";function NC(e){return e instanceof LC?!0:e instanceof Error&&e.name===Mo&&e.message===Mo}var LC=class extends Error{constructor(){super(Mo),this.name=this.message}};function MC(e){return new Error(`Illegal argument: ${e}`)}var nd=class Oo extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Oo)return t;let i=new Oo;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Go=class kp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,kp.prototype)}};function gt(e,t=0){return e[e.length-(1+t)]}var OC;(e=>{function t(r){return r<0}e.isLessThan=t;function i(r){return r<=0}e.isLessThanOrEqual=i;function s(r){return r>0}e.isGreaterThan=s;function n(r){return r===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(OC||={});function GC(e,t){let i=this,s=!1,n;return function(){return s||(s=!0,t||(n=e.apply(i,arguments))),n}}var Pp;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*n(S){yield S}e.single=n;function r(S){return t(S)?S:n(S)}e.wrap=r;function o(S){return S||i}e.from=o;function*a(S){for(let A=S.length-1;A>=0;A--)yield S[A]}e.reverse=a;function l(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(S){return S[Symbol.iterator]().next().value}e.first=h;function c(S,A){let k=0;for(let L of S)if(A(L,k++))return!0;return!1}e.some=c;function u(S,A){for(let k of S)if(A(k))return k}e.find=u;function*p(S,A){for(let k of S)A(k)&&(yield k)}e.filter=p;function*f(S,A){let k=0;for(let L of S)yield A(L,k++)}e.map=f;function*m(S,A){let k=0;for(let L of S)yield*A(L,k++)}e.flatMap=m;function*g(...S){for(let A of S)yield*A}e.concat=g;function _(S,A,k){let L=k;for(let O of S)L=A(L,O);return L}e.reduce=_;function*T(S,A,k=S.length){for(A<0&&(A+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);A<k;A++)yield S[A]}e.slice=T;function D(S,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,S];let L=S[Symbol.iterator]();for(let O=0;O<A;O++){let z=L.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return L}}]}e.consume=D;async function E(S){let A=[];for await(let k of S)A.push(k);return Promise.resolve(A)}e.asyncToArray=E})(Pp||={});function Fi(e){if(Pp.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function zC(...e){return Ae(()=>Fi(e))}function Ae(e){return{dispose:GC(()=>{e()})}}var Ep=class Tp{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Fi(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Tp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Ep.DISABLE_DISPOSED_WARNING=!1;var ki=Ep,be=class{constructor(){this._store=new ki,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};be.None=Object.freeze({dispose(){}});var os=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}clearAndLeak(){let e=this._value;return this._value=void 0,e}},oi=typeof window=="object"?window:globalThis,zo=class jo{constructor(t){this.element=t,this.next=jo.Undefined,this.prev=jo.Undefined}};zo.Undefined=new zo(void 0);var Ne=zo,rd=class{constructor(){this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ne.Undefined}clear(){let e=this._first;for(;e!==Ne.Undefined;){let t=e.next;e.prev=Ne.Undefined,e.next=Ne.Undefined,e=t}this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new Ne(e);if(this._first===Ne.Undefined)this._first=i,this._last=i;else if(t){let n=this._last;this._last=i,i.prev=n,n.next=i}else{let n=this._first;this._first=i,i.next=n,n.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==Ne.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ne.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ne.Undefined&&e.next!==Ne.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ne.Undefined&&e.next===Ne.Undefined?(this._first=Ne.Undefined,this._last=Ne.Undefined):e.next===Ne.Undefined?(this._last=this._last.prev,this._last.next=Ne.Undefined):e.prev===Ne.Undefined&&(this._first=this._first.next,this._first.prev=Ne.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ne.Undefined;)yield e.element,e=e.next}},jC=globalThis.performance&&typeof globalThis.performance.now=="function",BC=class Ip{static create(t){return new Ip(t)}constructor(t){this._now=jC&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},rt;(e=>{e.None=()=>be.None;function t(C,v){return u(C,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(C){return(v,y=null,x)=>{let b=!1,R;return R=C(M=>{if(!b)return R?R.dispose():b=!0,v.call(y,M)},null,x),b&&R.dispose(),R}}e.once=i;function s(C,v,y){return h((x,b=null,R)=>C(M=>x.call(b,v(M)),null,R),y)}e.map=s;function n(C,v,y){return h((x,b=null,R)=>C(M=>{v(M),x.call(b,M)},null,R),y)}e.forEach=n;function r(C,v,y){return h((x,b=null,R)=>C(M=>v(M)&&x.call(b,M),null,R),y)}e.filter=r;function o(C){return C}e.signal=o;function a(...C){return(v,y=null,x)=>{let b=zC(...C.map(R=>R(M=>v.call(y,M))));return c(b,x)}}e.any=a;function l(C,v,y,x){let b=y;return s(C,R=>(b=v(b,R),b),x)}e.reduce=l;function h(C,v){let y,x={onWillAddFirstListener(){y=C(b.fire,b)},onDidRemoveLastListener(){y?.dispose()}},b=new X(x);return v?.add(b),b.event}function c(C,v){return v instanceof Array?v.push(C):v&&v.add(C),C}function u(C,v,y=100,x=!1,b=!1,R,M){let W,B,Q,ie=0,ne,de={leakWarningThreshold:R,onWillAddFirstListener(){W=C(re=>{ie++,B=v(B,re),x&&!Q&&(ve.fire(B),B=void 0),ne=()=>{let me=B;B=void 0,Q=void 0,(!x||ie>1)&&ve.fire(me),ie=0},typeof y=="number"?(clearTimeout(Q),Q=setTimeout(ne,y)):Q===void 0&&(Q=0,queueMicrotask(ne))})},onWillRemoveListener(){b&&ie>0&&ne?.()},onDidRemoveLastListener(){ne=void 0,W.dispose()}},ve=new X(de);return M?.add(ve),ve.event}e.debounce=u;function p(C,v=0,y){return e.debounce(C,(x,b)=>x?(x.push(b),x):[b],v,void 0,!0,void 0,y)}e.accumulate=p;function f(C,v=(x,b)=>x===b,y){let x=!0,b;return r(C,R=>{let M=x||!v(R,b);return x=!1,b=R,M},y)}e.latch=f;function m(C,v,y){return[e.filter(C,v,y),e.filter(C,x=>!v(x),y)]}e.split=m;function g(C,v=!1,y=[],x){let b=y.slice(),R=C(B=>{b?b.push(B):W.fire(B)});x&&x.add(R);let M=()=>{b?.forEach(B=>W.fire(B)),b=null},W=new X({onWillAddFirstListener(){R||(R=C(B=>W.fire(B)),x&&x.add(R))},onDidAddFirstListener(){b&&(v?setTimeout(M):M())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return x&&x.add(W),W.event}e.buffer=g;function _(C,v){return(y,x,b)=>{let R=v(new D);return C(function(M){let W=R.evaluate(M);W!==T&&y.call(x,W)},void 0,b)}}e.chain=_;let T=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(y=>(v(y),y)),this}filter(v){return this.steps.push(y=>v(y)?y:T),this}reduce(v,y){let x=y;return this.steps.push(b=>(x=v(x,b),x)),this}latch(v=(y,x)=>y===x){let y=!0,x;return this.steps.push(b=>{let R=y||!v(b,x);return y=!1,x=b,R?b:T}),this}evaluate(v){for(let y of this.steps)if(v=y(v),v===T)break;return v}}function E(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.on(v,x),R=()=>C.removeListener(v,x),M=new X({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromNodeEventEmitter=E;function S(C,v,y=x=>x){let x=(...W)=>M.fire(y(...W)),b=()=>C.addEventListener(v,x),R=()=>C.removeEventListener(v,x),M=new X({onWillAddFirstListener:b,onDidRemoveLastListener:R});return M.event}e.fromDOMEventEmitter=S;function A(C){return new Promise(v=>i(C)(v))}e.toPromise=A;function k(C){let v=new X;return C.then(y=>{v.fire(y)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function L(C,v){return C(y=>v.fire(y))}e.forward=L;function O(C,v,y){return v(y),C(x=>v(x))}e.runAndSubscribe=O;class z{constructor(v,y){this._observable=v,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new X(x),y&&y.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,y){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function N(C,v){return new z(C,v).emitter.event}e.fromObservable=N;function I(C){return(v,y,x)=>{let b=0,R=!1,M={beginUpdate(){b++},endUpdate(){b--,b===0&&(C.reportChanges(),R&&(R=!1,v.call(y)))},handlePossibleChange(){},handleChange(){R=!0}};C.addObserver(M),C.reportChanges();let W={dispose(){C.removeObserver(M)}};return x instanceof ki?x.add(W):Array.isArray(x)&&x.push(W),W}}e.fromObservableLight=I})(rt||={});var Bo=class $o{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${$o._idPool++}`,$o.all.add(this)}start(t){this._stopWatch=new BC,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Bo.all=new Set,Bo._idPool=0;var $C=Bo,WC=-1,Ap=class Rp{constructor(t,i,s=(Rp._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[r,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(r);let l=new VC(a,r);this._errorHandler(l)}return()=>{let r=this._stacks.get(t.value)||0;this._stacks.set(t.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,n]of this._stacks)(!t||i<n)&&(t=[s,n],i=n);return t}};Ap._idPool=1;var HC=Ap,FC=class Np{constructor(t){this.value=t}static create(){let t=new Error;return new Np(t.stack??"")}print(){console.warn(this.value.split(`
|
|
35
|
-
`).slice(2).join(`
|
|
36
|
-
`))}},VC=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},UC=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},KC=0,Br=class{constructor(e){this.value=e,this.id=KC++}},qC=2,YC,X=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new HC(e?.onListenerError??En,this._options?.leakWarningThreshold??WC):void 0,this._perfMon=this._options?._profName?new $C(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new UC(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||En)(l),be.None}if(this._disposed)return be.None;t&&(e=e.bind(t));let s=new Br(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=FC.create(),n=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Br?(this._deliveryQueue??=new XC,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Ae(()=>{n?.(),this._removeListener(s)});return i instanceof ki?i.add(r):Array.isArray(i)&&i.push(r),r},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*qC<=t.length){let n=0;for(let r=0;r<t.length;r++)t[r]?t[n++]=t[r]:s&&(this._deliveryQueue.end--,n<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=n}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||En;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Br)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},XC=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Wo=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new X,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new X,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Wo.INSTANCE=new Wo;var il=Wo;function JC(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}il.INSTANCE.onDidChangeZoomLevel;function ZC(e){return il.INSTANCE.getZoomFactor(e)}il.INSTANCE.onDidChangeFullscreen;var ds=typeof navigator=="object"?navigator.userAgent:"",Ho=ds.indexOf("Firefox")>=0,QC=ds.indexOf("AppleWebKit")>=0,sl=ds.indexOf("Chrome")>=0,e1=!sl&&ds.indexOf("Safari")>=0;ds.indexOf("Electron/")>=0;ds.indexOf("Android")>=0;var $r=!1;if(typeof oi.matchMedia=="function"){let e=oi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=oi.matchMedia("(display-mode: fullscreen)");$r=e.matches,JC(oi,e,({matches:i})=>{$r&&t.matches||($r=i)})}var ss="en",Fo=!1,Vo=!1,Tn=!1,Lp=!1,_n,In=ss,od=ss,t1,ni,Wi=globalThis,wt;typeof Wi.vscode<"u"&&typeof Wi.vscode.process<"u"?wt=Wi.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(wt=process);var i1=typeof wt?.versions?.electron=="string",s1=i1&&wt?.type==="renderer";if(typeof wt=="object"){Fo=wt.platform==="win32",Vo=wt.platform==="darwin",Tn=wt.platform==="linux",Tn&&wt.env.SNAP&&wt.env.SNAP_REVISION,wt.env.CI||wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,_n=ss,In=ss;let e=wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);_n=t.userLocale,od=t.osLocale,In=t.resolvedLanguage||ss,t1=t.languagePack?.translationsConfigFile}catch{}Lp=!0}else typeof navigator=="object"&&!s1?(ni=navigator.userAgent,Fo=ni.indexOf("Windows")>=0,Vo=ni.indexOf("Macintosh")>=0,(ni.indexOf("Macintosh")>=0||ni.indexOf("iPad")>=0||ni.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Tn=ni.indexOf("Linux")>=0,ni?.indexOf("Mobi")>=0,In=globalThis._VSCODE_NLS_LANGUAGE||ss,_n=navigator.language.toLowerCase(),od=_n):console.error("Unable to resolve platform.");var Mp=Fo,Ut=Vo,n1=Tn,ad=Lp,qt=ni,vi=In,r1;(e=>{function t(){return vi}e.value=t;function i(){return vi.length===2?vi==="en":vi.length>=3?vi[0]==="e"&&vi[1]==="n"&&vi[2]==="-":!1}e.isDefaultVariant=i;function s(){return vi==="en"}e.isDefault=s})(r1||={});var o1=typeof Wi.postMessage=="function"&&!Wi.importScripts;(()=>{if(o1){let e=[];Wi.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,n=e.length;s<n;s++){let r=e[s];if(r.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),r.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Wi.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var a1=!!(qt&&qt.indexOf("Chrome")>=0);qt&&qt.indexOf("Firefox")>=0;!a1&&qt&&qt.indexOf("Safari")>=0;qt&&qt.indexOf("Edg/")>=0;qt&&qt.indexOf("Android")>=0;var Zi=typeof navigator=="object"?navigator:{};ad||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zi&&Zi.clipboard&&Zi.clipboard.writeText,ad||Zi&&Zi.clipboard&&Zi.clipboard.readText;var nl=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Wr=new nl,ld=new nl,hd=new nl,l1=new Array(230),Op;(e=>{function t(a){return Wr.keyCodeToStr(a)}e.toString=t;function i(a){return Wr.strToKeyCode(a)}e.fromString=i;function s(a){return ld.keyCodeToStr(a)}e.toUserSettingsUS=s;function n(a){return hd.keyCodeToStr(a)}e.toUserSettingsGeneral=n;function r(a){return ld.strToKeyCode(a)||hd.strToKeyCode(a)}e.fromUserSettings=r;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Wr.keyCodeToStr(a)}e.toElectronAccelerator=o})(Op||={});var h1=class Gp{constructor(t,i,s,n,r){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=n,this.keyCode=r}equals(t){return t instanceof Gp&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${i}${s}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new d1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},d1=class{constructor(e){if(e.length===0)throw MC("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function c1(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Op.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Ho)switch(t){case 59:return 85;case 60:if(n1)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ut)return 57;break}else if(QC&&(Ut&&t===93||!Ut&&t===92))return 57;return l1[t]||0}var u1=Ut?256:2048,p1=512,f1=1024,m1=Ut?2048:256,dd=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=c1(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=u1),this.altKey&&(t|=p1),this.shiftKey&&(t|=f1),this.metaKey&&(t|=m1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new h1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},cd=new WeakMap;function g1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var v1=class{static getSameOriginWindowChain(e){let t=cd.get(e);if(!t){t=[],cd.set(e,t);let i=e,s;do s=g1(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,n=this.getSameOriginWindowChain(e);for(let r of n){let o=r.window.deref();if(i+=o?.scrollY??0,s+=o?.scrollX??0,o===t||!r.iframeElement)break;let a=r.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},bn=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=v1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ud=class{constructor(e,t=0,i=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(sl){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,r=e,o=e.view?.devicePixelRatio||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*o):this.deltaY=n.wheelDeltaY/120;else if(typeof r.VERTICAL_AXIS<"u"&&r.axis===r.VERTICAL_AXIS)this.deltaY=-r.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Ho&&!Ut?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")e1&&Mp?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*o):this.deltaX=n.wheelDeltaX/120;else if(typeof r.HORIZONTAL_AXIS<"u"&&r.axis===r.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Ho&&!Ut?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*o):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},zp=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),_1;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof b1?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:rt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:zp})})(_1||={});var b1=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?zp:(this._emitter||(this._emitter=new X),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},rl=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Go("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Go("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},w1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Go("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=Ae(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},y1;(e=>{async function t(s){let n,r=await Promise.all(s.map(o=>o.then(a=>a,a=>{n||(n=a)})));if(typeof n<"u")throw n;return r}e.settled=t;function i(s){return new Promise(async(n,r)=>{try{await s(n,r)}catch(o){r(o)}})}e.withAsyncBody=i})(y1||={});var pd=class Ct{static fromArray(t){return new Ct(i=>{i.emitMany(t)})}static fromPromise(t){return new Ct(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ct(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ct(async i=>{await Promise.all(t.map(async s=>{for await(let n of s)i.emitOne(n)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new X,queueMicrotask(async()=>{let s={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(s)),this.resolve()}catch(n){this.reject(n)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await rt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new Ct(async s=>{for await(let n of t)s.emitOne(i(n))})}map(t){return Ct.map(this,t)}static filter(t,i){return new Ct(async s=>{for await(let n of t)i(n)&&s.emitOne(n)})}filter(t){return Ct.filter(this,t)}static coalesce(t){return Ct.filter(t,i=>!!i)}coalesce(){return Ct.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ct.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};pd.EMPTY=pd.fromArray([]);var{getWindow:Vt,getWindowId:x1,onDidRegisterWindow:S1}=(function(){let e=new Map,t={window:oi,disposables:new ki};e.set(oi.vscodeWindowId,t);let i=new X,s=new X,n=new X;function r(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return be.None;let a=new ki,l={window:o,disposables:a.add(new ki)};return e.set(o.vscodeWindowId,l),a.add(Ae(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(ue(o,Je.BEFORE_UNLOAD,()=>{n.fire(o)})),i.fire(l),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:r,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:oi},getDocument(o){return Vt(o).document}}})(),C1=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ue(e,t,i,s){return new C1(e,t,i,s)}var fd=function(e,t,i,s){return ue(e,t,i,s)},ol,D1=class extends w1{constructor(e){super(),this.defaultTarget=e&&Vt(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},md=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){En(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,n=r=>{i.set(r,!1);let o=e.get(r)??[];for(t.set(r,o),e.set(r,[]),s.set(r,!0);o.length>0;)o.sort(md.sort),o.shift().execute();s.set(r,!1)};ol=(r,o,a=0)=>{let l=x1(r),h=new md(o,a),c=e.get(l);return c||(c=[],e.set(l,c)),c.push(h),i.get(l)||(i.set(l,!0),r.requestAnimationFrame(()=>n(l))),h}})();function k1(e){let t=e.getBoundingClientRect(),i=Vt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Je={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},P1=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ut(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ut(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ut(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ut(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ut(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ut(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ut(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ut(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ut(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ut(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ut(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ut(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ut(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ut(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ut(e){return typeof e=="number"?`${e}px`:e}function zs(e){return new P1(e)}var jp=class{constructor(){this._hooks=new ki,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=n;let r=e;try{e.setPointerCapture(t),this._hooks.add(Ae(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{r=Vt(e)}this._hooks.add(ue(r,Je.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(ue(r,Je.POINTER_UP,o=>this.stopMonitoring(!0)))}};function E1(e,t,i){let s=null,n=null;if(typeof i.value=="function"?(s="value",n=i.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",n=i.get),!n)throw new Error("not supported");let r=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(r)||Object.defineProperty(this,r,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,o)}),this[r]}}var Wt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Wt||={});var Is=class ot extends be{constructor(){super(),this.dispatched=!1,this.targets=new rd,this.ignoreTargets=new rd,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(rt.runAndSubscribe(S1,({window:t,disposables:i})=>{i.add(ue(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(ue(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(ue(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:oi,disposables:this._store}))}static addTarget(t){if(!ot.isTouchDevice())return be.None;ot.INSTANCE||(ot.INSTANCE=new ot);let i=ot.INSTANCE.targets.push(t);return Ae(i)}static ignoreTarget(t){if(!ot.isTouchDevice())return be.None;ot.INSTANCE||(ot.INSTANCE=new ot);let i=ot.INSTANCE.ignoreTargets.push(t);return Ae(i)}static isTouchDevice(){return"ontouchstart"in oi||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,n=t.targetTouches.length;s<n;s++){let r=t.targetTouches.item(s);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:i,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[i],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let o=this.newGestureEvent(Wt.Start,r.target);o.pageX=r.pageX,o.pageY=r.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),n=Object.keys(this.activeTouches).length;for(let r=0,o=i.changedTouches.length;r<o;r++){let a=i.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<ot.HOLD_DELAY&&Math.abs(l.initialPageX-gt(l.rollingPageX))<30&&Math.abs(l.initialPageY-gt(l.rollingPageY))<30){let c=this.newGestureEvent(Wt.Tap,l.initialTarget);c.pageX=gt(l.rollingPageX),c.pageY=gt(l.rollingPageY),this.dispatchEvent(c)}else if(h>=ot.HOLD_DELAY&&Math.abs(l.initialPageX-gt(l.rollingPageX))<30&&Math.abs(l.initialPageY-gt(l.rollingPageY))<30){let c=this.newGestureEvent(Wt.Contextmenu,l.initialTarget);c.pageX=gt(l.rollingPageX),c.pageY=gt(l.rollingPageY),this.dispatchEvent(c)}else if(n===1){let c=gt(l.rollingPageX),u=gt(l.rollingPageY),p=gt(l.rollingTimestamps)-l.rollingTimestamps[0],f=c-l.rollingPageX[0],m=u-l.rollingPageY[0],g=[...this.targets].filter(_=>l.initialTarget instanceof Node&&_.contains(l.initialTarget));this.inertia(t,g,s,Math.abs(f)/p,f>0?1:-1,c,Math.abs(m)/p,m>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Wt.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Wt.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>ot.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Wt.Change||t.type===Wt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let n=0,r=t.initialTarget;for(;r&&r!==s;)n++,r=r.parentElement;i.push([n,s])}i.sort((s,n)=>s[0]-n[0]);for(let[s,n]of i)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,n,r,o,a,l,h){this.handle=ol(t,()=>{let c=Date.now(),u=c-s,p=0,f=0,m=!0;n+=ot.SCROLL_FRICTION*u,a+=ot.SCROLL_FRICTION*u,n>0&&(m=!1,p=r*n*u),a>0&&(m=!1,f=l*a*u);let g=this.newGestureEvent(Wt.Change);g.translationX=p,g.translationY=f,i.forEach(_=>_.dispatchEvent(g)),m||this.inertia(t,i,c,n,r,o+p,a,l,h+f)})}onTouchMove(t){let i=Date.now();for(let s=0,n=t.changedTouches.length;s<n;s++){let r=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn("end of an UNKNOWN touch",r);continue}let o=this.activeTouches[r.identifier],a=this.newGestureEvent(Wt.Change,o.initialTarget);a.translationX=r.pageX-gt(o.rollingPageX),a.translationY=r.pageY-gt(o.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(r.pageX),o.rollingPageY.push(r.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Is.SCROLL_FRICTION=-.005,Is.HOLD_DELAY=700,Is.CLEAR_TAP_COUNT_TIME=400,ze([E1],Is,"isTouchDevice",1);var T1=Is,al=class extends be{onclick(e,t){this._register(ue(e,Je.CLICK,i=>t(new bn(Vt(e),i))))}onmousedown(e,t){this._register(ue(e,Je.MOUSE_DOWN,i=>t(new bn(Vt(e),i))))}onmouseover(e,t){this._register(ue(e,Je.MOUSE_OVER,i=>t(new bn(Vt(e),i))))}onmouseleave(e,t){this._register(ue(e,Je.MOUSE_LEAVE,i=>t(new bn(Vt(e),i))))}onkeydown(e,t){this._register(ue(e,Je.KEY_DOWN,i=>t(new dd(i))))}onkeyup(e,t){this._register(ue(e,Je.KEY_UP,i=>t(new dd(i))))}oninput(e,t){this._register(ue(e,Je.INPUT,t))}onblur(e,t){this._register(ue(e,Je.BLUR,t))}onfocus(e,t){this._register(ue(e,Je.FOCUS,t))}onchange(e,t){this._register(ue(e,Je.CHANGE,t))}ignoreGesture(e){return T1.ignoreTarget(e)}},gd=11,I1=class extends al{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=gd+"px",this.domNode.style.height=gd+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new jp),this._register(fd(this.bgDomNode,Je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(fd(this.domNode,Je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new D1),this._pointerdownScheduleRepeatTimer=this._register(new rl)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Vt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},A1=class Uo{constructor(t,i,s,n,r,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,n=n|0,r=r|0,o=o|0,a=a|0),this.rawScrollLeft=n,this.rawScrollTop=a,i<0&&(i=0),n+i>s&&(n=s-i),n<0&&(n=0),r<0&&(r=0),a+r>o&&(a=o-r),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=n,this.height=r,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Uo(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Uo(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,r=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,l=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:n,scrollLeftChanged:r,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},R1=class extends be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new A1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new _d(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=_d.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},vd=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Hr(e,t){let i=t-e;return function(s){return e+i*M1(s)}}function N1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var _d=class Ko{constructor(t,i,s,n){this.from=t,this.to=i,this.duration=n,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let n,r;return t<i?(n=t+.75*s,r=i-.75*s):(n=t-.75*s,r=i+.75*s),N1(Hr(t,n),Hr(r,i),.33)}return Hr(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),n=this.scrollTop(i);return new vd(s,n,!1)}return new vd(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Ko.start(t,i,s)}static start(t,i,s){s=s+10;let n=Date.now()-10;return new Ko(t,i,n,s)}};function L1(e){return Math.pow(e,3)}function M1(e){return 1-L1(1-e)}var O1=class extends be{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new rl)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},G1=140,Bp=class extends al{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new O1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new jp),this._shouldRender=!0,this.domNode=zs(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ue(this.domNode.domNode,Je.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new I1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=zs(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ue(this.slider.domNode,Je.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);i<=n&&n<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let n=k1(this.domNode.domNode);t=e.pageX-n.left,i=e.pageY-n.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let r=this._sliderOrthogonalPointerPosition(n),o=Math.abs(r-i);if(Mp&&o>G1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},$p=class qo{constructor(t,i,s,n,r,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=r,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new qo(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,n,r){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),l=n>0&&n>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*a/n))),c=(a-h)/(n-s),u=r*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=qo._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},z1=class extends Bp{constructor(e,t,i){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new $p(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},j1=class extends Bp{constructor(e,t,i){let s=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new $p(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},B1=500,bd=50,$1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Yo=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,n=this._rear;do{let r=n===this._front?t:Math.pow(2,-s);if(t-=r,i+=this._memory[n].score*r,n===this._front)break;n=(this._capacity+n-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(sl){let i=Vt(t.browserEvent),s=ZC(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let n=null,r=new $1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=r,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=r),r.score=this._computeScore(r,n)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let n=Math.abs(t.deltaX),r=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(n,o),1),h=Math.max(Math.min(r,a),1),c=Math.max(n,o),u=Math.max(r,a);c%l===0&&u%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Yo.INSTANCE=new Yo;var W1=Yo,H1=class extends al{constructor(e,t,i){super(),this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new X),this.onWillScroll=this._onWillScroll.event,this._options=V1(t),this._scrollable=i,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let s={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new j1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new z1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zs(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new rl),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Fi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Ut&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new ud(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Fi(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new ud(i))};this._mouseWheelToDispose.push(ue(this._listenOnDomNode,Je.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=W1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,r=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&r+n===0?r=n=0:Math.abs(n)>=Math.abs(r)?r=0:n=0),this._options.flipAxes&&([n,r]=[r,n]);let o=!Ut&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!r&&(r=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(r=r*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(n){let h=bd*n,c=a.scrollTop-(h<0?Math.floor(h):Math.ceil(h));this._verticalScrollbar.writeScrollPosition(l,c)}if(r){let h=bd*r,c=a.scrollLeft-(h<0?Math.floor(h):Math.ceil(h));this._horizontalScrollbar.writeScrollPosition(l,c)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",n=t?" top":"",r=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${r}${n}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),B1)}},F1=class extends H1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function V1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Ut&&(t.className+=" mac"),t}var Xo=class extends be{constructor(e,t,i,s,n,r,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new X),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new R1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>ol(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new F1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(rt.runAndSubscribe(r.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ae(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ae(()=>this._styleElement.remove())),this._register(rt.runAndSubscribe(r.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${r.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
37
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Xo=ze([ee(2,ht),ee(3,ui),ee(4,yp),ee(5,hs),ee(6,dt),ee(7,pi)],Xo);var Jo=class extends be{constructor(e,t,i,s,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(r=>this._removeDecoration(r))),this._register(Ae(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Jo=ze([ee(1,ht),ee(2,ui),ee(3,Js),ee(4,pi)],Jo);var U1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},jt={full:0,left:0,center:0,right:0},_i={full:0,left:0,center:0,right:0},xs={full:0,left:0,center:0,right:0},qn=class extends be{constructor(e,t,i,s,n,r,o,a){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=n,this._optionsService=r,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new U1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Ae(()=>this._canvas?.remove()));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);_i.full=this._canvas.width,_i.left=e,_i.center=t,_i.right=e,this._refreshDrawHeightConstants(),xs.full=1,xs.left=1,xs.center=1+_i.left,xs.right=1+_i.left+_i.center}_refreshDrawHeightConstants(){jt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);jt.left=t,jt.center=t,jt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*jt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*jt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*jt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*jt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(xs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-jt[e.position||"full"]/2),_i[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+jt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};qn=ze([ee(2,ht),ee(3,Js),ee(4,pi),ee(5,dt),ee(6,hs),ee(7,ui)],qn);var $;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
38
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))($||={});var An;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(An||={});var Wp;(e=>e.ST=`${$.ESC}\\`)(Wp||={});var Zo=class{constructor(e,t,i,s,n,r){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=n,this._renderService=r,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let r=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(r.width,1)+"px",this._textarea.style.height=Math.max(r.height,1)+"px",this._textarea.style.lineHeight=r.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Zo=ze([ee(2,ht),ee(3,dt),ee(4,Ki),ee(5,pi)],Zo);var Ze=0,Qe=0,et=0,Oe=0,wd={css:"#00000000",rgba:0},We;(e=>{function t(n,r,o,a){return a!==void 0?`#${Li(n)}${Li(r)}${Li(o)}${Li(a)}`:`#${Li(n)}${Li(r)}${Li(o)}`}e.toCss=t;function i(n,r,o,a=255){return(n<<24|r<<16|o<<8|a)>>>0}e.toRgba=i;function s(n,r,o,a){return{css:e.toCss(n,r,o,a),rgba:e.toRgba(n,r,o,a)}}e.toColor=s})(We||={});var Ee;(e=>{function t(l,h){if(Oe=(h.rgba&255)/255,Oe===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,u=h.rgba>>16&255,p=h.rgba>>8&255,f=l.rgba>>24&255,m=l.rgba>>16&255,g=l.rgba>>8&255;Ze=f+Math.round((c-f)*Oe),Qe=m+Math.round((u-m)*Oe),et=g+Math.round((p-g)*Oe);let _=We.toCss(Ze,Qe,et),T=We.toRgba(Ze,Qe,et);return{css:_,rgba:T}}e.blend=t;function i(l){return(l.rgba&255)===255}e.isOpaque=i;function s(l,h,c){let u=Rn.ensureContrastRatio(l.rgba,h.rgba,c);if(u)return We.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function n(l){let h=(l.rgba|255)>>>0;return[Ze,Qe,et]=Rn.toChannels(h),{css:We.toCss(Ze,Qe,et),rgba:h}}e.opaque=n;function r(l,h){return Oe=Math.round(h*255),[Ze,Qe,et]=Rn.toChannels(l.rgba),{css:We.toCss(Ze,Qe,et,Oe),rgba:We.toRgba(Ze,Qe,et,Oe)}}e.opacity=r;function o(l,h){return Oe=l.rgba&255,r(l,Oe*h/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(Ee||={});var Le;(e=>{let t,i;try{let n=document.createElement("canvas");n.width=1,n.height=1;let r=n.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Ze=parseInt(n.slice(1,2).repeat(2),16),Qe=parseInt(n.slice(2,3).repeat(2),16),et=parseInt(n.slice(3,4).repeat(2),16),We.toColor(Ze,Qe,et);case 5:return Ze=parseInt(n.slice(1,2).repeat(2),16),Qe=parseInt(n.slice(2,3).repeat(2),16),et=parseInt(n.slice(3,4).repeat(2),16),Oe=parseInt(n.slice(4,5).repeat(2),16),We.toColor(Ze,Qe,et,Oe);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let r=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Ze=parseInt(r[1]),Qe=parseInt(r[2]),et=parseInt(r[3]),Oe=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),We.toColor(Ze,Qe,et,Oe);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ze,Qe,et,Oe]=t.getImageData(0,0,1,1).data,Oe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:We.toRgba(Ze,Qe,et,Oe),css:n}}e.toColor=s})(Le||={});var at;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,n,r){let o=s/255,a=n/255,l=r/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+u*.0722}e.relativeLuminance2=i})(at||={});var Rn;(e=>{function t(o,a){if(Oe=(a&255)/255,Oe===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,u=o>>24&255,p=o>>16&255,f=o>>8&255;return Ze=u+Math.round((l-u)*Oe),Qe=p+Math.round((h-p)*Oe),et=f+Math.round((c-f)*Oe),We.toRgba(Ze,Qe,et)}e.blend=t;function i(o,a,l){let h=at.relativeLuminance(o>>8),c=at.relativeLuminance(a>>8);if(ei(h,c)<l){if(c<h){let f=s(o,a,l),m=ei(h,at.relativeLuminance(f>>8));if(m<l){let g=n(o,a,l),_=ei(h,at.relativeLuminance(g>>8));return m>_?f:g}return f}let u=n(o,a,l),p=ei(h,at.relativeLuminance(u>>8));if(p<l){let f=s(o,a,l),m=ei(h,at.relativeLuminance(f>>8));return p>m?u:f}return u}}e.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,u=o>>8&255,p=a>>24&255,f=a>>16&255,m=a>>8&255,g=ei(at.relativeLuminance2(p,f,m),at.relativeLuminance2(h,c,u));for(;g<l&&(p>0||f>0||m>0);)p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),g=ei(at.relativeLuminance2(p,f,m),at.relativeLuminance2(h,c,u));return(p<<24|f<<16|m<<8|255)>>>0}e.reduceLuminance=s;function n(o,a,l){let h=o>>24&255,c=o>>16&255,u=o>>8&255,p=a>>24&255,f=a>>16&255,m=a>>8&255,g=ei(at.relativeLuminance2(p,f,m),at.relativeLuminance2(h,c,u));for(;g<l&&(p<255||f<255||m<255);)p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),g=ei(at.relativeLuminance2(p,f,m),at.relativeLuminance2(h,c,u));return(p<<24|f<<16|m<<8|255)>>>0}e.increaseLuminance=n;function r(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=r})(Rn||={});function Li(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ei(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var K1=class extends Xs{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Yn=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new It}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),n=0,r=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-n>1){let c=this._getJoinedRanges(s,o,r,t,n);for(let u=0;u<c.length;u++)i.push(c[u])}n=h,o=r,a=this._workCell.fg,l=this._workCell.bg}r+=this._workCell.getChars().length||Ci.length}if(this._bufferService.cols-n>1){let h=this._getJoinedRanges(s,o,r,t,n);for(let c=0;c<h.length;c++)i.push(h[c])}return i}_getJoinedRanges(e,t,i,s,n){let r=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(r)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(r);for(let h=0;h<l.length;h++)Yn._mergeRanges(o,l[h])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,n),o}_stringRangesToCellRanges(e,t,i){let s=0,n=!1,r=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let l=t.getWidth(a),h=t.getString(a).length||Ci.length;if(l!==0){if(!n&&o[0]<=r&&(o[0]=a,n=!0),o[1]<=r){if(o[1]=a,o=e[++s],!o)break;o[0]<=r?(o[0]=a,n=!0):n=!1}r+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let n=e[s];if(i){if(t[1]<=n[0])return e[s-1][1]=t[1],e;if(t[1]<=n[1])return e[s-1][1]=Math.max(t[1],n[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=n[0])return e.splice(s,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Yn=ze([ee(0,ht)],Yn);function q1(e){return 57508<=e&&e<=57558}function Y1(e){return 9472<=e&&e<=9631}function X1(e){return q1(e)||Y1(e)}function J1(){return{css:{canvas:wn(),cell:wn()},device:{canvas:wn(),cell:wn(),char:{width:0,height:0,left:0,top:0}}}}function wn(){return{width:0,height:0}}var Qo=class{constructor(e,t,i,s,n,r,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=n,this._decorationService=r,this._themeService=o,this._workCell=new It,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,n,r,o,a,l,h,c){let u=[],p=this._characterJoinerService.getJoinedCharacters(t),f=this._themeService.colors,m=e.getNoBgTrimmedLength();i&&m<r+1&&(m=r+1);let g,_=0,T="",D=0,E=0,S=0,A=0,k=!1,L=0,O=!1,z=0,N=0,I=[],C=h!==-1&&c!==-1;for(let v=0;v<m;v++){e.loadCell(v,this._workCell);let y=this._workCell.getWidth();if(y===0)continue;let x=!1,b=v>=N,R=v,M=this._workCell;if(p.length>0&&v===p[0][0]&&b){let we=p.shift(),Xe=this._isCellInSelection(we[0],t);for(D=we[0]+1;D<we[1];D++)b&&=Xe===this._isCellInSelection(D,t);b&&=!i||r<we[0]||r>=we[1],b?(x=!0,M=new K1(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),R=we[1]-1,y=M.getWidth()):N=we[1]}let W=this._isCellInSelection(v,t),B=i&&v===r,Q=C&&v>=h&&v<=c,ie=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,we=>{ie=!0});let ne=M.getChars()||Ci;if(ne===" "&&(M.isUnderline()||M.isOverline())&&(ne=" "),z=y*a-l.get(ne,M.isBold(),M.isItalic()),!g)g=this._document.createElement("span");else if(_&&(W&&O||!W&&!O&&M.bg===E)&&(W&&O&&f.selectionForeground||M.fg===S)&&M.extended.ext===A&&Q===k&&z===L&&!B&&!x&&!ie&&b){M.isInvisible()?T+=Ci:T+=ne,_++;continue}else _&&(g.textContent=T),g=this._document.createElement("span"),_=0,T="";if(E=M.bg,S=M.fg,A=M.extended.ext,k=Q,L=z,O=W,x&&r>=v&&r<=R&&(r=v),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&I.push("xterm-cursor-blink"),I.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(M.isBold()&&I.push("xterm-bold"),M.isItalic()&&I.push("xterm-italic"),M.isDim()&&I.push("xterm-dim"),M.isInvisible()?T=Ci:T=M.getChars()||Ci,M.isUnderline()&&(I.push(`xterm-underline-${M.extended.underlineStyle}`),T===" "&&(T=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${Xs.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let we=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&we<8&&(we+=8),g.style.textDecorationColor=f.ansi[we].css}M.isOverline()&&(I.push("xterm-overline"),T===" "&&(T=" ")),M.isStrikethrough()&&I.push("xterm-strikethrough"),Q&&(g.style.textDecoration="underline");let de=M.getFgColor(),ve=M.getFgColorMode(),re=M.getBgColor(),me=M.getBgColorMode(),K=!!M.isInverse();if(K){let we=de;de=re,re=we;let Xe=ve;ve=me,me=Xe}let F,le,pe=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,we=>{we.options.layer!=="top"&&pe||(we.backgroundColorRGB&&(me=50331648,re=we.backgroundColorRGB.rgba>>8&16777215,F=we.backgroundColorRGB),we.foregroundColorRGB&&(ve=50331648,de=we.foregroundColorRGB.rgba>>8&16777215,le=we.foregroundColorRGB),pe=we.options.layer==="top")}),!pe&&W&&(F=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,re=F.rgba>>8&16777215,me=50331648,pe=!0,f.selectionForeground&&(ve=50331648,de=f.selectionForeground.rgba>>8&16777215,le=f.selectionForeground)),pe&&I.push("xterm-decoration-top");let ke;switch(me){case 16777216:case 33554432:ke=f.ansi[re],I.push(`xterm-bg-${re}`);break;case 50331648:ke=We.toColor(re>>16,re>>8&255,re&255),this._addStyle(g,`background-color:#${yd((re>>>0).toString(16),"0",6)}`);break;default:K?(ke=f.foreground,I.push("xterm-bg-257")):ke=f.background}switch(F||M.isDim()&&(F=Ee.multiplyOpacity(ke,.5)),ve){case 16777216:case 33554432:M.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(g,ke,f.ansi[de],M,F,void 0)||I.push(`xterm-fg-${de}`);break;case 50331648:let we=We.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(g,ke,we,M,F,le)||this._addStyle(g,`color:#${yd(de.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,ke,f.foreground,M,F,le)||K&&I.push("xterm-fg-257")}I.length&&(g.className=I.join(" "),I.length=0),!B&&!x&&!ie&&b?_++:g.textContent=T,z!==this.defaultSpacing&&(g.style.letterSpacing=`${z}px`),u.push(g),v=R}return g&&_&&(g.textContent=T),u}_applyMinimumContrast(e,t,i,s,n,r){if(this._optionsService.rawOptions.minimumContrastRatio===1||X1(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!n&&!r&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=Ee.ensureContrastRatio(n||t,r||i,l),o.setColor((n||t).rgba,(r||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Qo=ze([ee(1,Cp),ee(2,dt),ee(3,ui),ee(4,Ki),ee(5,Js),ee(6,hs)],Qo);function yd(e,t,i){for(;e.length<i;)e=t+e;return e}var Z1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold",r.style.fontStyle="italic",this._measureElements=[i,s,n,r],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(r),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let n=e;t&&(n+="B"),i&&(n+="I");let r=this._holey.get(n);if(r===void 0){let o=0;t&&(o|=1),i&&(o|=2),r=this._measure(e,o),r>0&&this._holey.set(n,r)}return r}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Q1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let n=e.buffers.active.ydisp,r=t[1]-n,o=i[1]-n,a=Math.max(r,0),l=Math.min(o,e.rows-1);if(a>=e.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=r,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function eD(){return new Q1}var Fr="xterm-dom-renderer-owner-",xt="xterm-rows",yn="xterm-fg-",xd="xterm-bg-",Ss="xterm-focus",xn="xterm-selection",tD=1,ea=class extends be{constructor(e,t,i,s,n,r,o,a,l,h,c,u,p,f){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=n,this._helperContainer=r,this._linkifier2=o,this._charSizeService=l,this._optionsService=h,this._bufferService=c,this._coreService=u,this._coreBrowserService=p,this._themeService=f,this._terminalClass=tD++,this._rowElements=[],this._selectionRenderModel=eD(),this.onRequestRedraw=this._register(new X).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(xt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(xn),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=J1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Qo,document),this._element.classList.add(Fr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ae(()=>{this._element.classList.remove(Fr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Z1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${xt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${xt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${xt} .xterm-dim { color: ${Ee.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${xt}.${Ss} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${xt}.${Ss} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${xt}.${Ss} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${xt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${xt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${xt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${xt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${xt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${xn} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${xn} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${xn} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[r,o]of e.ansi.entries())t+=`${this._terminalSelector} .${yn}${r} { color: ${o.css}; }${this._terminalSelector} .${yn}${r}.xterm-dim { color: ${Ee.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${xd}${r} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${yn}257 { color: ${Ee.opaque(e.background).css}; }${this._terminalSelector} .${yn}257.xterm-dim { color: ${Ee.multiplyOpacity(Ee.opaque(e.background),.5).css}; }${this._terminalSelector} .${xd}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ss),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ss),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,r=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(r,l?t[0]:e[0],l?e[0]:t[0],o-r+1))}else{let l=s===r?e[0]:0,h=r===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(r,l,h));let c=o-r-1;if(a.appendChild(this._createSelectionElement(r+1,0,this._bufferService.cols,c)),r!==o){let u=n===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let n=this._document.createElement("div"),r=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return r+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-r),n.style.height=`${s*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${r}px`,n.style.width=`${o}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,n=Math.min(i.x,this._bufferService.cols-1),r=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let h=l+i.ydisp,c=this._rowElements[l],u=i.lines.get(h);if(!c||!u)break;c.replaceChildren(...this._rowFactory.createRow(u,h,h===s,o,a,n,r,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Fr}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,n,r){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),n=Math.min(n,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,h=Math.min(a.x,n-1),c=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=i;f<=s;++f){let m=f+a.ydisp,g=this._rowElements[f],_=a.lines.get(m);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,m,m===l,u,p,h,c,this.dimensions.css.cell.width,this._widthCache,r?f===i?e:0:-1,r?(f===s?t:n)-1:-1))}}};ea=ze([ee(7,el),ee(8,cr),ee(9,dt),ee(10,ht),ee(11,Ki),ee(12,ui),ee(13,hs)],ea);var ta=class extends be{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new X),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new sD(this._optionsService))}catch{this._measureStrategy=this._register(new iD(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};ta=ze([ee(2,dt)],ta);var Hp=class extends be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},iD=class extends Hp{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},sD=class extends Hp{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},nD=class extends be{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new rD(this._window)),this._onDprChange=this._register(new X),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new X),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(rt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ue(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ue(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},rD=class extends be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new os),this._onDprChange=this._register(new X),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ae(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ue(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},oD=class extends be{constructor(){super(),this.linkProviders=[],this._register(Ae(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ll(e,t,i){let s=i.getBoundingClientRect(),n=e.getComputedStyle(i),r=parseInt(n.getPropertyValue("padding-left")),o=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-s.left-r,t.clientY-s.top-o]}function aD(e,t,i,s,n,r,o,a,l){if(!r)return;let h=ll(e,t,i);if(h)return h[0]=Math.ceil((h[0]+(l?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),s+(l?1:0)),h[1]=Math.min(Math.max(h[1],1),n),h}var ia=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,n){return aD(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let i=ll(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};ia=ze([ee(0,pi),ee(1,cr)],ia);var lD=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Fp={};_C(Fp,{getSafariVersion:()=>dD,isChromeOS:()=>qp,isFirefox:()=>Vp,isIpad:()=>cD,isIphone:()=>uD,isLegacyEdge:()=>hD,isLinux:()=>hl,isMac:()=>Xn,isNode:()=>ur,isSafari:()=>Up,isWindows:()=>Kp});var ur=typeof process<"u"&&"title"in process,Zs=ur?"node":navigator.userAgent,Qs=ur?"node":navigator.platform,Vp=Zs.includes("Firefox"),hD=Zs.includes("Edge"),Up=/^((?!chrome|android).)*safari/i.test(Zs);function dD(){if(!Up)return 0;let e=Zs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Xn=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Qs),cD=Qs==="iPad",uD=Qs==="iPhone",Kp=["Windows","Win16","Win32","WinCE"].includes(Qs),hl=Qs.indexOf("Linux")>=0,qp=/\bCrOS\b/.test(Zs),Yp=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),n=e.timeRemaining(),i*1.5>n){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=n}this.clear()}},pD=class extends Yp{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},fD=class extends Yp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Jn=!ur&&"requestIdleCallback"in window?fD:pD,mD=class{constructor(){this._queue=new Jn}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},sa=class extends be{constructor(e,t,i,s,n,r,o,a,l){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=n,this._coreBrowserService=a,this._renderer=this._register(new os),this._pausedResizeTask=new mD,this._observerDisposable=this._register(new os),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new X),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new X),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new X),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lD((h,c)=>this._renderRows(h,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gD(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ae(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(r.onDecorationRegistered(()=>this._fullRefresh())),this._register(r.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=Ae(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,i){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,this._renderer.value?.handleSelectionChanged(e,t,i)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};sa=ze([ee(2,dt),ee(3,cr),ee(4,Ki),ee(5,Js),ee(6,ht),ee(7,ui),ee(8,hs)],sa);var gD=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function vD(e,t,i,s){let n=i.buffer.x,r=i.buffer.y;if(!i.buffer.hasScrollback)return wD(n,r,e,t,i,s)+pr(r,t,i,s)+yD(n,r,e,t,i,s);let o;if(r===t)return o=n>e?"D":"C",Vs(Math.abs(n-e),Fs(o,s));o=r>t?"D":"C";let a=Math.abs(r-t),l=bD(r>t?e:n,i)+(a-1)*i.cols+1+_D(r>t?n:e);return Vs(l,Fs(o,s))}function _D(e,t){return e-1}function bD(e,t){return t.cols-e}function wD(e,t,i,s,n,r){return pr(t,s,n,r).length===0?"":Vs(Jp(e,t,e,t-Vi(t,n),!1,n).length,Fs("D",r))}function pr(e,t,i,s){let n=e-Vi(e,i),r=t-Vi(t,i),o=Math.abs(n-r)-xD(e,t,i);return Vs(o,Fs(Xp(e,t),s))}function yD(e,t,i,s,n,r){let o;pr(t,s,n,r).length>0?o=s-Vi(s,n):o=t;let a=s,l=SD(e,t,i,s,n,r);return Vs(Jp(e,o,i,a,l==="C",n).length,Fs(l,r))}function xD(e,t,i){let s=0,n=e-Vi(e,i),r=t-Vi(t,i);for(let o=0;o<Math.abs(n-r);o++){let a=Xp(e,t)==="A"?-1:1;i.buffer.lines.get(n+a*o)?.isWrapped&&s++}return s}function Vi(e,t){let i=0,s=t.buffer.lines.get(e),n=s?.isWrapped;for(;n&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),n=s?.isWrapped;return i}function SD(e,t,i,s,n,r){let o;return pr(i,s,n,r).length>0?o=s-Vi(s,n):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Xp(e,t){return e>t?"A":"B"}function Jp(e,t,i,s,n,r){let o=e,a=t,l="";for(;(o!==i||a!==s)&&a>=0&&a<r.buffer.lines.length;)o+=n?1:-1,n&&o>r.cols-1?(l+=r.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!n&&o<0&&(l+=r.buffer.translateBufferLineToString(a,!1,0,e+1),o=r.cols-1,e=o,a--);return l+r.buffer.translateBufferLineToString(a,!1,e,o)}function Fs(e,t){let i=t?"O":"[";return $.ESC+i+e}function Vs(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var CD=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Sd(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Vr=50,DD=15,kD=50,PD=500,ED=" ",TD=new RegExp(ED,"g"),na=class extends be{constructor(e,t,i,s,n,r,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=n,this._mouseService=r,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new It,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new X),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new X),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new X),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new CD(this._bufferService),this._activeSelectionMode=0,this._register(Ae(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],r=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,n,r);s.push(a)}}else{let n=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],n));for(let r=e[1]+1;r<=t[1]-1;r++){let o=i.lines.get(r),a=i.translateBufferLineToString(r,!0);o?.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let r=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);r&&r.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(n=>n.replace(TD," ")).join(Kp?`\r
|
|
39
|
-
`:`
|
|
40
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),hl&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Sd(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ll(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Vr),Vr),t/=Vr,t/Math.abs(t)+Math.round(t*(DD-1)))}shouldForceSelection(e){return Xn?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),kD)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Xn&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<PD&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=vD(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let n=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:n>1&&t!==s&&(i+=n-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,r=n.lines.get(e[1]);if(!r)return;let o=n.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(r,e[0]),l=a,h=e[0]-a,c=0,u=0,p=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let _=e[0],T=e[0];r.getWidth(_)===0&&(c++,_--),r.getWidth(T)===2&&(u++,T++);let D=r.getString(T).length;for(D>1&&(f+=D-1,l+=D-1);_>0&&a>0&&!this._isCharWordSeparator(r.loadCell(_-1,this._workCell));){r.loadCell(_-1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,_--):E>1&&(p+=E-1,a-=E-1),a--,_--}for(;T<r.length&&l+1<o.length&&!this._isCharWordSeparator(r.loadCell(T+1,this._workCell));){r.loadCell(T+1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,T++):E>1&&(f+=E-1,l+=E-1),l++,T++}}l++;let m=a+h-c+p,g=Math.min(this._bufferService.cols,l-a+c+u-p-f);if(!(!t&&o.slice(a,l).trim()==="")){if(i&&m===0&&r.getCodePoint(0)!==32){let _=n.lines.get(e[1]-1);if(_&&r.isWrapped&&_.getCodePoint(this._bufferService.cols-1)!==32){let T=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(T){let D=this._bufferService.cols-T.start;m-=D,g+=D}}}if(s&&m+g===this._bufferService.cols&&r.getCodePoint(this._bufferService.cols-1)!==32){let _=n.lines.get(e[1]+1);if(_?.isWrapped&&_.getCodePoint(0)!==32){let T=this._getWordAt([0,e[1]+1],!1,!1,!0);T&&(g+=T.length)}}return{start:m,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Sd(i,this._bufferService.cols)}};na=ze([ee(3,ht),ee(4,Ki),ee(5,tl),ee(6,dt),ee(7,pi),ee(8,ui)],na);var Cd=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Dd=class{constructor(){this._color=new Cd,this._css=new Cd}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ue=Object.freeze((()=>{let e=[Le.toColor("#2e3436"),Le.toColor("#cc0000"),Le.toColor("#4e9a06"),Le.toColor("#c4a000"),Le.toColor("#3465a4"),Le.toColor("#75507b"),Le.toColor("#06989a"),Le.toColor("#d3d7cf"),Le.toColor("#555753"),Le.toColor("#ef2929"),Le.toColor("#8ae234"),Le.toColor("#fce94f"),Le.toColor("#729fcf"),Le.toColor("#ad7fa8"),Le.toColor("#34e2e2"),Le.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],n=t[i/6%6|0],r=t[i%6];e.push({css:We.toCss(s,n,r),rgba:We.toRgba(s,n,r)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:We.toCss(s,s,s),rgba:We.toRgba(s,s,s)})}return e})()),Oi=Le.toColor("#ffffff"),As=Le.toColor("#000000"),kd=Le.toColor("#ffffff"),Pd=As,Cs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ID=Oi,ra=class extends be{constructor(e){super(),this._optionsService=e,this._contrastCache=new Dd,this._halfContrastCache=new Dd,this._onChangeColors=this._register(new X),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Oi,background:As,cursor:kd,cursorAccent:Pd,selectionForeground:void 0,selectionBackgroundTransparent:Cs,selectionBackgroundOpaque:Ee.blend(As,Cs),selectionInactiveBackgroundTransparent:Cs,selectionInactiveBackgroundOpaque:Ee.blend(As,Cs),scrollbarSliderBackground:Ee.opacity(Oi,.2),scrollbarSliderHoverBackground:Ee.opacity(Oi,.4),scrollbarSliderActiveBackground:Ee.opacity(Oi,.5),overviewRulerBorder:Oi,ansi:Ue.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Se(e.foreground,Oi),t.background=Se(e.background,As),t.cursor=Ee.blend(t.background,Se(e.cursor,kd)),t.cursorAccent=Ee.blend(t.background,Se(e.cursorAccent,Pd)),t.selectionBackgroundTransparent=Se(e.selectionBackground,Cs),t.selectionBackgroundOpaque=Ee.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Se(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ee.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Se(e.selectionForeground,wd):void 0,t.selectionForeground===wd&&(t.selectionForeground=void 0),Ee.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ee.opacity(t.selectionBackgroundTransparent,.3)),Ee.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ee.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Se(e.scrollbarSliderBackground,Ee.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Se(e.scrollbarSliderHoverBackground,Ee.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Se(e.scrollbarSliderActiveBackground,Ee.opacity(t.foreground,.5)),t.overviewRulerBorder=Se(e.overviewRulerBorder,ID),t.ansi=Ue.slice(),t.ansi[0]=Se(e.black,Ue[0]),t.ansi[1]=Se(e.red,Ue[1]),t.ansi[2]=Se(e.green,Ue[2]),t.ansi[3]=Se(e.yellow,Ue[3]),t.ansi[4]=Se(e.blue,Ue[4]),t.ansi[5]=Se(e.magenta,Ue[5]),t.ansi[6]=Se(e.cyan,Ue[6]),t.ansi[7]=Se(e.white,Ue[7]),t.ansi[8]=Se(e.brightBlack,Ue[8]),t.ansi[9]=Se(e.brightRed,Ue[9]),t.ansi[10]=Se(e.brightGreen,Ue[10]),t.ansi[11]=Se(e.brightYellow,Ue[11]),t.ansi[12]=Se(e.brightBlue,Ue[12]),t.ansi[13]=Se(e.brightMagenta,Ue[13]),t.ansi[14]=Se(e.brightCyan,Ue[14]),t.ansi[15]=Se(e.brightWhite,Ue[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Se(e.extendedAnsi[s],Ue[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};ra=ze([ee(0,dt)],ra);function Se(e,t){if(e!==void 0)try{return Le.toColor(e)}catch{}return t}var AD=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},RD=class{constructor(){this._services=new AD,this._services.set(el,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=DC(e).sort((r,o)=>r.index-o.index),s=[];for(let r of i){let o=this._services.get(r.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);s.push(o)}let n=i.length>0?i[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},ND={trace:0,debug:1,info:2,warn:3,error:4,off:5},LD="xterm.js: ",oa=class extends be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ND[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":LD)+t,...i)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};oa=ze([ee(0,dt)],oa);var Ed=class extends be{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new X),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new X),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new X),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let n=t-1;n>=0;n--)this.set(e+n+i,this.get(e+n));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},_e=3,Be=Object.freeze(new Xs),Sn=0,Ur=2,Rs=class Zp{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*_e);let n=i||It.fromCharData([0,vp,1,0]);for(let r=0;r<t;++r)this.setCell(r,n);this.length=t}get(t){let i=this._data[t*_e+0],s=i&2097151;return[this._data[t*_e+1],i&2097152?this._combined[t]:s?Si(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*_e+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*_e+0]=t|2097152|i[2]<<22):this._data[t*_e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*_e+0]>>22}hasWidth(t){return this._data[t*_e+0]&12582912}getFg(t){return this._data[t*_e+1]}getBg(t){return this._data[t*_e+2]}hasContent(t){return this._data[t*_e+0]&4194303}getCodePoint(t){let i=this._data[t*_e+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*_e+0]&2097152}getString(t){let i=this._data[t*_e+0];return i&2097152?this._combined[t]:i&2097151?Si(i&2097151):""}isProtected(t){return this._data[t*_e+2]&536870912}loadCell(t,i){return Sn=t*_e,i.content=this._data[Sn+0],i.fg=this._data[Sn+1],i.bg=this._data[Sn+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*_e+0]=i.content,this._data[t*_e+1]=i.fg,this._data[t*_e+2]=i.bg}setCellFromCodepoint(t,i,s,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*_e+0]=i|s<<22,this._data[t*_e+1]=n.fg,this._data[t*_e+2]=n.bg}addCodepointToCell(t,i,s){let n=this._data[t*_e+0];n&2097152?this._combined[t]+=Si(i):n&2097151?(this._combined[t]=Si(n&2097151)+Si(i),n&=-2097152,n|=2097152):n=i|1<<22,s&&(n&=-12582913,n|=s<<22),this._data[t*_e+0]=n}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let n=new It;for(let r=this.length-t-i-1;r>=0;--r)this.setCell(t+i+r,this.loadCell(t+r,n));for(let r=0;r<i;++r)this.setCell(t+r,s)}else for(let n=t;n<this.length;++n)this.setCell(n,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let n=new It;for(let r=0;r<this.length-t-i;++r)this.setCell(t+r,this.loadCell(t+i+r,n));for(let r=this.length-i;r<this.length;++r)this.setCell(r,s)}else for(let n=t;n<this.length;++n)this.setCell(n,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Ur<this._data.buffer.byteLength;let s=t*_e;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let n=new Uint32Array(s);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,i)}else{this._data=this._data.subarray(0,s);let n=Object.keys(this._combined);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._combined[a]}let r=Object.keys(this._extendedAttrs);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*Ur<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ur<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Zp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*_e+0]&4194303)return t+(this._data[t*_e+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*_e+0]&4194303||this._data[t*_e+2]&50331648)return t+(this._data[t*_e+0]>>22);return 0}copyCellsFrom(t,i,s,n,r){let o=t._data;if(r)for(let l=n-1;l>=0;l--){for(let h=0;h<_e;h++)this._data[(s+l)*_e+h]=o[(i+l)*_e+h];o[(i+l)*_e+2]&268435456&&(this._extendedAttrs[s+l]=t._extendedAttrs[i+l])}else for(let l=0;l<n;l++){for(let h=0;h<_e;h++)this._data[(s+l)*_e+h]=o[(i+l)*_e+h];o[(i+l)*_e+2]&268435456&&(this._extendedAttrs[s+l]=t._extendedAttrs[i+l])}let a=Object.keys(t._combined);for(let l=0;l<a.length;l++){let h=parseInt(a[l],10);h>=i&&(this._combined[h-i+s]=t._combined[h])}}translateToString(t,i,s,n){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),n&&(n.length=0);let r="";for(;i<s;){let o=this._data[i*_e+0],a=o&2097151,l=o&2097152?this._combined[i]:a?Si(a):Ci;if(r+=l,n)for(let h=0;h<l.length;++h)n.push(i);i+=o>>22||1}return n&&n.push(i),r}};function MD(e,t,i,s,n,r){let o=[];for(let a=0;a<e.length-1;a++){let l=a,h=e.get(++l);if(!h.isWrapped)continue;let c=[e.get(a)];for(;l<e.length&&h.isWrapped;)c.push(h),h=e.get(++l);if(!r&&s>=a&&s<l){a+=c.length-1;continue}let u=0,p=Us(c,u,t),f=1,m=0;for(;f<c.length;){let _=Us(c,f,t),T=_-m,D=i-p,E=Math.min(T,D);c[u].copyCellsFrom(c[f],m,p,E,!1),p+=E,p===i&&(u++,p=0),m+=E,m===_&&(f++,m=0),p===0&&u!==0&&c[u-1].getWidth(i-1)===2&&(c[u].copyCellsFrom(c[u-1],i-1,p++,1,!1),c[u-1].setCell(i-1,n))}c[u].replaceCells(p,i,n);let g=0;for(let _=c.length-1;_>0&&(_>u||c[_].getTrimmedLength()===0);_--)g++;g>0&&(o.push(a+c.length-g),o.push(g)),a+=c.length-1}return o}function OD(e,t){let i=[],s=0,n=t[s],r=0;for(let o=0;o<e.length;o++)if(n===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-r,amount:a}),o+=a-1,r+=a,n=t[++s]}else i.push(o);return{layout:i,countRemoved:r}}function GD(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function zD(e,t,i){let s=[],n=e.map((l,h)=>Us(e,h,t)).reduce((l,h)=>l+h),r=0,o=0,a=0;for(;a<n;){if(n-a<i){s.push(n-a);break}r+=i;let l=Us(e,o,t);r>l&&(r-=l,o++);let h=e[o].getWidth(r-1)===2;h&&r--;let c=h?i-1:i;s.push(c),a+=c}return s}function Us(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,n=e[t+1].getWidth(0)===2;return s&&n?i-1:i}var Qp=class ef{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ef._nextId++,this._onDispose=this.register(new X),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Fi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Qp._nextId=1;var jD=Qp,Ye={},Gi=Ye.B;Ye[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ye.A={"#":"£"};Ye.B=void 0;Ye[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ye.C=Ye[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ye.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ye.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ye.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ye.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ye.E=Ye[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ye.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ye.H=Ye[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ye["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Td=4294967295,Id=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Be.clone(),this.savedCharset=Gi,this.markers=[],this._nullCell=It.fromCharData([0,vp,1,0]),this._whitespaceCell=It.fromCharData([0,Ci,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Jn,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ed(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Kn),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Kn),this._whitespaceCell}getBlankLine(e,t){return new Rs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Td?Td:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Be);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Ed(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Be),s=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let r=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Rs(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+r+1?(this.ybase--,r++,this.ydisp>0&&this.ydisp--):this.lines.push(new Rs(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let o=this.lines.length-n;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),r&&(this.y+=r),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let r=0;r<this.lines.length;r++)s+=+this.lines.get(r).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=MD(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Be),i);if(s.length>0){let n=OD(this.lines,s);GD(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Be),n=i;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Rs(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Be),n=[],r=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let E=this.ybase+this.y;if(E>=o&&E<o+l.length)continue}let h=l[l.length-1].getTrimmedLength(),c=zD(l,this._cols,e),u=c.length-l.length,p;this.ybase===0&&this.y!==this.lines.length-1?p=Math.max(0,this.y-this.lines.maxLength+u):p=Math.max(0,this.lines.length-this.lines.maxLength+u);let f=[];for(let E=0;E<u;E++){let S=this.getBlankLine(Be,!0);f.push(S)}f.length>0&&(n.push({start:o+l.length+r,newLines:f}),r+=f.length),l.push(...f);let m=c.length-1,g=c[m];g===0&&(m--,g=c[m]);let _=l.length-u-1,T=h;for(;_>=0;){let E=Math.min(T,g);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[_],T-E,g-E,E,!0),g-=E,g===0&&(m--,g=c[m]),T-=E,T===0){_--;let S=Math.max(_,0);T=Us(l,S,this._cols)}}for(let E=0;E<l.length;E++)c[E]<e&&l[E].setCell(c[E],s);let D=u-p;for(;D-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(n.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let l=this.lines.length,h=l-1,c=0,u=n[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let p=0;for(let g=Math.min(this.lines.maxLength-1,l+r-1);g>=0;g--)if(u&&u.start>h+p){for(let _=u.newLines.length-1;_>=0;_--)this.lines.set(g--,u.newLines[_]);g++,o.push({index:h+1,amount:u.newLines.length}),p+=u.newLines.length,u=n[++c]}else this.lines.set(g,a[h--]);let f=0;for(let g=o.length-1;g>=0;g--)o[g].index+=f,this.lines.onInsertEmitter.fire(o[g]),f+=o[g].amount;let m=Math.max(0,l+r-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,i=0,s){let n=this.lines.get(e);return n?n.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new jD(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},BD=class extends be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new X),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Id(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Id(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},tf=2,sf=1,aa=class extends be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,tf),this.rows=Math.max(e.rawOptions.rows||0,sf),this.buffers=this._register(new BD(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let n=i.ybase+i.scrollTop,r=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;r===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(r+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=r-n+1;i.lines.shiftElements(n+1,o-1,-1),i.lines.set(r,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};aa=ze([ee(0,dt)],aa);var Qi={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Xn,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},$D=["normal","bold","100","200","300","400","500","600","700","800","900"],WD=class extends be{constructor(e){super(),this._onOptionChange=this._register(new X),this.onOptionChange=this._onOptionChange.event;let t={...Qi};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ae(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Qi))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Qi))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Qi[e]),!HD(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Qi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=$D.includes(t)?t:Qi[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function HD(e){return e==="block"||e==="underline"||e==="bar"}function Ns(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Ns(e[s],t-1);return i}var Ad=Object.freeze({insertMode:!1}),Rd=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),la=class extends be{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new X),this.onData=this._onData.event,this._onUserInput=this._register(new X),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new X),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ns(Ad),this.decPrivateModes=Ns(Rd)}reset(){this.modes=Ns(Ad),this.decPrivateModes=Ns(Rd)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};la=ze([ee(0,ht),ee(1,xp),ee(2,dt)],la);var Nd={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Kr(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var qr=String.fromCharCode,Ld={DEFAULT:e=>{let t=[Kr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${qr(t[0])}${qr(t[1])}${qr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.x};${e.y}${t}`}},ha=class extends be{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new X),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Nd))this.addProtocol(s,Nd[s]);for(let s of Object.keys(Ld))this.addEncoding(s,Ld[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=s+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ha=ze([ee(0,ht),ee(1,Ki),ee(2,dt)],ha);var Yr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],FD=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ke;function VD(e,t){let i=0,s=t.length-1,n;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(n=i+s>>1,e>t[n][1])i=n+1;else if(e<t[n][0])s=n-1;else return!0;return!1}var UD=class{constructor(){if(this.version="6",!Ke){Ke=new Uint8Array(65536),Ke.fill(1),Ke[0]=0,Ke.fill(0,1,32),Ke.fill(0,127,160),Ke.fill(2,4352,4448),Ke[9001]=2,Ke[9002]=2,Ke.fill(2,11904,42192),Ke[12351]=1,Ke.fill(2,44032,55204),Ke.fill(2,63744,64256),Ke.fill(2,65040,65050),Ke.fill(2,65072,65136),Ke.fill(2,65280,65377),Ke.fill(2,65504,65511);for(let e=0;e<Yr.length;++e)Ke.fill(0,Yr[e][0],Yr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ke[e]:VD(e,FD)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let n=Bi.extractWidth(t);n===0?s=!1:n>i&&(i=n)}return Bi.createPropertyValue(0,i,s)}},Bi=class Nn{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new X,this.onChange=this._onChange.event;let t=new UD;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,n=t.length;for(let r=0;r<n;++r){let o=t.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=n)return i+this.wcwidth(o);let h=t.charCodeAt(r);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=Nn.extractWidth(a);Nn.extractShouldJoin(a)&&(l-=Nn.extractWidth(s)),i+=l,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},KD=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Md(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Ds=2147483647,qD=256,nf=class da{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>qD)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new da;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let n=t[s];if(Array.isArray(n))for(let r=0;r<n.length;++r)i.addSubParam(n[r]);else i.addParam(n)}return i}clone(){let t=new da(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,n=this._subParamsIdx[i]&255;n-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ds?Ds:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Ds?Ds:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,n=this._subParamsIdx[i]&255;n-s>0&&(t[i]=this._subParams.slice(s,n))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,n=s[i-1];s[i-1]=~n?Math.min(n*10+t,Ds):t}},ks=[],YD=class{constructor(){this._state=0,this._active=ks,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ks}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ks,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ks,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",dr(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ks,this._id=-1,this._state=0}}},vt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=dr(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Ps=[],XD=class{constructor(){this._handlers=Object.create(null),this._active=Ps,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ps}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ps,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ps,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",dr(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,n=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ps,this._ident=0}},Ls=new nf;Ls.addParam(0);var Od=class{constructor(e){this._handler=e,this._data="",this._params=Ls,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ls,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=dr(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Ls,this._data="",this._hitLimit=!1,i));return this._params=Ls,this._data="",this._hitLimit=!1,t}},JD=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=i<<4|s}},kt=160,ZD=(function(){let e=new JD(4095),t=Array.apply(null,Array(256)).map((a,l)=>l),i=(a,l)=>t.slice(a,l),s=i(32,127),n=i(0,24);n.push(25),n.push.apply(n,i(28,32));let r=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in r)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(kt,0,2,0),e.add(kt,8,5,8),e.add(kt,6,0,6),e.add(kt,11,0,11),e.add(kt,13,13,13),e})(),QD=class extends be{constructor(e=ZD){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new nf,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ae(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new YD),this._dcsParser=this._register(new XD),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let r=e.intermediates.charCodeAt(n);if(32>r||r>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=r}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=n}parse(e,t,i){let s=0,n=0,r=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,r=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&l>-1){for(;l>=0&&(o=a[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&l>-1){for(;l>=0&&(o=a[l](),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,r=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=r;a<t;++a){switch(s=e[a],n=this._transitions.table[this.currentState<<8|(s<160?s:kt)],n>>4){case 2:for(let p=a+1;;++p){if(p>=t||(s=e[p])<32||s>126&&s<kt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<kt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<kt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<kt){this._printHandler(e,a,p),a=p-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|s],h=l?l.length-1:-1;for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,l,h,n,a),o;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let c=this._escHandlers[this._collect<<8|s],u=c?c.length-1:-1;for(;u>=0&&(o=c[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,c,u,n,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let p=a+1;;++p)if(p>=t||(s=e[p])===24||s===26||s===27||s>127&&s<kt){this._dcsParser.put(e,a,p),a=p-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,n,a),o;s===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let p=a+1;;p++)if(p>=t||(s=e[p])<32||s>127&&s<kt){this._oscParser.put(e,a,p),a=p-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,n,a),o;s===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},ek=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,tk=/^[\da-f]+$/;function Gd(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=ek.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),tk.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let n=0;n<3;++n){let r=parseInt(t.slice(i*n,i*n+i),16);s[n]=i===1?r<<4:i===2?r:i===3?r>>4:r>>8}return s}}function Xr(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function ik(e,t=16){let[i,s,n]=e;return`rgb:${Xr(i,t)}/${Xr(s,t)}/${Xr(n,t)}`}var sk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},bi=131072,zd=10;function jd(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Bd=5e3,$d=0,nk=class extends be{constructor(e,t,i,s,n,r,o,a,l=new QD){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=n,this._oscLinkService=r,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new SC,this._utf8Decoder=new CC,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Be.clone(),this._eraseAttrDataInternal=Be.clone(),this._onRequestBell=this._register(new X),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new X),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new X),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new X),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new X),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new X),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new X),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new X),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new X),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ca(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:u})}),this._parser.setDcsHandlerFallback((h,c,u)=>{c==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:u})}),this._parser.setPrintHandler((h,c,u)=>this.print(h,c,u)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(An.IND,()=>this.index()),this._parser.setExecuteHandler(An.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(An.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vt(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new vt(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new vt(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new vt(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new vt(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new vt(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new vt(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new vt(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new vt(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new vt(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new vt(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new vt(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Ye)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Od((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Bd))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Bd} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,n=this._activeBuffer.y,r=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>bi&&(r=this._parseStack.position+bi)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<bi&&(this._parseBuffer=new Uint32Array(Math.min(e.length,bi))),o||this._dirtyRowTracker.clearRange(),e.length>bi)for(let h=r;h<e.length;h+=bi){let c=h+bi<e.length?h+bi:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,c),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,c),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,n,u,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(s,n,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,n,r=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,c=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let p=this._parser.precedingJoinState;for(let f=t;f<i;++f){if(s=e[f],s<127&&r){let T=r[String.fromCharCode(s)];T&&(s=T.charCodeAt(0))}let m=this._unicodeService.charProperties(s,p);n=Bi.extractWidth(m);let g=Bi.extractShouldJoin(m),_=g?Bi.extractWidth(p):0;if(p=m,o&&this._onA11yChar.fire(Si(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-_>a){if(l){let T=u,D=this._activeBuffer.x-_;for(this._activeBuffer.x=_,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&u instanceof Rs&&u.copyCellsFrom(T,D,0,_,!1);D<a;)T.setCellFromCodepoint(D++,0,1,c)}else if(this._activeBuffer.x=a-1,n===2)continue}if(g&&this._activeBuffer.x){let T=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-T,s,n);for(let D=n-_;--D>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(u.insertCells(this._activeBuffer.x,n-_,this._activeBuffer.getNullCell(c)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,c)),u.setCellFromCodepoint(this._activeBuffer.x++,s,n,c),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=p,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>jd(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Od(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vt(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,n=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),n),s&&(r.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Be));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=Bi.extractWidth(t),n=this._activeBuffer.x-s,r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),o=new Uint32Array(r.length*i),a=0;for(let h=0;h<r.length;){let c=r.codePointAt(h)||0;o[a++]=c,h+=c>65535?2:1}let l=a;for(let h=1;h<i;++h)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent($.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent($.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent($.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent($.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent($.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Gi),this._charsetService.setgCharset(1,Gi),this._charsetService.setgCharset(2,Gi),this._charsetService.setgCharset(3,Gi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let i;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:r}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:h,alt:c}=a,u=this._optionsService.rawOptions,p=(g,_)=>(o.triggerDataEvent(`${$.ESC}[${t?"":"?"}${g};${_}$y`),!0),f=g=>g?1:2,m=e.params[0];return t?m===2?p(m,4):m===4?p(m,f(o.modes.insertMode)):m===12?p(m,3):m===20?p(m,f(u.convertEol)):p(m,0):m===1?p(m,f(s.applicationCursorKeys)):m===3?p(m,u.windowOptions.setWinLines?l===80?2:l===132?1:0:0):m===6?p(m,f(s.origin)):m===7?p(m,f(s.wraparound)):m===8?p(m,3):m===9?p(m,f(n==="X10")):m===12?p(m,f(u.cursorBlink)):m===25?p(m,f(!o.isCursorHidden)):m===45?p(m,f(s.reverseWraparound)):m===66?p(m,f(s.applicationKeypad)):m===67?p(m,4):m===1e3?p(m,f(n==="VT200")):m===1002?p(m,f(n==="DRAG")):m===1003?p(m,f(n==="ANY")):m===1004?p(m,f(s.sendFocus)):m===1005?p(m,4):m===1006?p(m,f(r==="SGR")):m===1015?p(m,4):m===1016?p(m,f(r==="SGR_PIXELS")):m===1048?p(m,1):m===47||m===1047||m===1049?p(m,f(h===c)):m===2004?p(m,f(s.bracketedPasteMode)):m===2026?p(m,f(s.synchronizedOutput)):p(m,0)}_updateAttrColor(e,t,i,s,n){return t===2?(e|=50331648,e&=-16777216,e|=Xs.fromColorRGB([i,s,n])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],n=0,r=0;do{if(s[r+n]=e.params[t+r],e.hasSubParams(t+r)){let o=e.getSubParams(t+r),a=0;do s[1]===5&&(n=1),s[r+a+1+n]=o[a];while(++a<o.length&&a+r+1+n<s.length);break}if(s[1]===5&&r+n>=2||s[1]===2&&r+n>=5)break;s[1]&&(n=1)}while(++r+t<e.length&&r+n<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return r}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Be.fg,e.bg=Be.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let n=0;n<t;n++)i=e.params[n],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Be.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Be.bg&16777215):i===38||i===48||i===58?n+=this._extractColor(e,n,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Be.fg&16777215,s.bg&=-67108864,s.bg|=Be.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${t};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Be.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!jd(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>zd&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>zd&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),n=i.shift();if(/^\d+$/.exec(s)){let r=parseInt(s);if(Wd(r))if(n==="?")t.push({type:0,index:r});else{let o=Gd(n);o&&t.push({type:1,index:r,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,n=i.findIndex(r=>r.startsWith("id="));return n!==-1&&(s=i[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=Gd(i[s]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let n=parseInt(i[s]);Wd(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Gi),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(sk[e[0]],Ye[e[1]]||Gi),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Be.clone(),this._eraseAttrDataInternal=Be.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new It;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${$.ESC}${o}${$.ESC}\\`),!0),s=this._bufferService.buffer,n=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ca=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&($d=e,e=t,t=$d),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ca=ze([ee(0,ht)],ca);function Wd(e){return 0<=e&&e<256}var rk=5e7,Hd=12,ok=50,ak=class extends be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>rk)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],n=this._action(s,t);if(n){let o=a=>performance.now()-i>=Hd?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);n.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let r=this._callbacks[this._bufferOffset];if(r&&r(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Hd)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ok&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},ua=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.id}let i=e,s=this._getEntryIdKey(i),n=this._entriesWithId.get(s);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let r=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[r]};return r.onDispose(()=>this._removeMarkerFromLink(o,r)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};ua=ze([ee(0,ht)],ua);var Fd=!1,lk=class extends be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new os),this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onData=this._register(new X),this.onData=this._onData.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new X),this._instantiationService=new RD,this.optionsService=this._register(new WD(e)),this._instantiationService.setService(dt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(aa)),this._instantiationService.setService(ht,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(oa)),this._instantiationService.setService(xp,this._logService),this.coreService=this._register(this._instantiationService.createInstance(la)),this._instantiationService.setService(Ki,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ha)),this._instantiationService.setService(yp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Bi)),this._instantiationService.setService(EC,this.unicodeService),this._charsetService=this._instantiationService.createInstance(KD),this._instantiationService.setService(PC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ua),this._instantiationService.setService(Sp,this._oscLinkService),this._inputHandler=this._register(new nk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(rt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(rt.forward(this._bufferService.onResize,this._onResize)),this._register(rt.forward(this.coreService.onData,this._onData)),this._register(rt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new ak((t,i)=>this._inputHandler.parse(t,i))),this._register(rt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new X),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Fd&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fd=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,tf),t=Math.max(t,sf),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Md.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Md(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ae(()=>{for(let t of e)t.dispose()})}}},hk={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function dk(e,t,i,s){let n={type:0,cancel:!1,key:void 0},r=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=$.ESC+"OA":n.key=$.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=$.ESC+"OD":n.key=$.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=$.ESC+"OC":n.key=$.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=$.ESC+"OB":n.key=$.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":$.DEL,e.altKey&&(n.key=$.ESC+n.key);break;case 9:if(e.shiftKey){n.key=$.ESC+"[Z";break}n.key=$.HT,n.cancel=!0;break;case 13:n.key=e.altKey?$.ESC+$.CR:$.CR,n.cancel=!0;break;case 27:n.key=$.ESC,e.altKey&&(n.key=$.ESC+$.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;r?n.key=$.ESC+"[1;"+(r+1)+"D":t?n.key=$.ESC+"OD":n.key=$.ESC+"[D";break;case 39:if(e.metaKey)break;r?n.key=$.ESC+"[1;"+(r+1)+"C":t?n.key=$.ESC+"OC":n.key=$.ESC+"[C";break;case 38:if(e.metaKey)break;r?n.key=$.ESC+"[1;"+(r+1)+"A":t?n.key=$.ESC+"OA":n.key=$.ESC+"[A";break;case 40:if(e.metaKey)break;r?n.key=$.ESC+"[1;"+(r+1)+"B":t?n.key=$.ESC+"OB":n.key=$.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=$.ESC+"[2~");break;case 46:r?n.key=$.ESC+"[3;"+(r+1)+"~":n.key=$.ESC+"[3~";break;case 36:r?n.key=$.ESC+"[1;"+(r+1)+"H":t?n.key=$.ESC+"OH":n.key=$.ESC+"[H";break;case 35:r?n.key=$.ESC+"[1;"+(r+1)+"F":t?n.key=$.ESC+"OF":n.key=$.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=$.ESC+"[5;"+(r+1)+"~":n.key=$.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=$.ESC+"[6;"+(r+1)+"~":n.key=$.ESC+"[6~";break;case 112:r?n.key=$.ESC+"[1;"+(r+1)+"P":n.key=$.ESC+"OP";break;case 113:r?n.key=$.ESC+"[1;"+(r+1)+"Q":n.key=$.ESC+"OQ";break;case 114:r?n.key=$.ESC+"[1;"+(r+1)+"R":n.key=$.ESC+"OR";break;case 115:r?n.key=$.ESC+"[1;"+(r+1)+"S":n.key=$.ESC+"OS";break;case 116:r?n.key=$.ESC+"[15;"+(r+1)+"~":n.key=$.ESC+"[15~";break;case 117:r?n.key=$.ESC+"[17;"+(r+1)+"~":n.key=$.ESC+"[17~";break;case 118:r?n.key=$.ESC+"[18;"+(r+1)+"~":n.key=$.ESC+"[18~";break;case 119:r?n.key=$.ESC+"[19;"+(r+1)+"~":n.key=$.ESC+"[19~";break;case 120:r?n.key=$.ESC+"[20;"+(r+1)+"~":n.key=$.ESC+"[20~";break;case 121:r?n.key=$.ESC+"[21;"+(r+1)+"~":n.key=$.ESC+"[21~";break;case 122:r?n.key=$.ESC+"[23;"+(r+1)+"~":n.key=$.ESC+"[23~";break;case 123:r?n.key=$.ESC+"[24;"+(r+1)+"~":n.key=$.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=$.DEL:e.keyCode===219?n.key=$.ESC:e.keyCode===220?n.key=$.FS:e.keyCode===221&&(n.key=$.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let o=hk[e.keyCode]?.[e.shiftKey?1:0];if(o)n.key=$.ESC+o;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(a);e.shiftKey&&(l=l.toUpperCase()),n.key=$.ESC+l}else if(e.keyCode===32)n.key=$.ESC+(e.ctrlKey?$.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),n.key=$.ESC+a,n.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=$.US),e.key==="@"&&(n.key=$.NUL));break}return n}var je=0,ck=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Jn,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Jn,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,r)=>this._getKey(n)-this._getKey(r)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<s.length;n++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[n]=e[t],t++):s[n]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(je=this._search(t),je===-1)||this._getKey(this._array[je])!==t)return!1;do if(this._array[je]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(je),!0;while(++je<this._array.length&&this._getKey(this._array[je])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,r)=>n-r),t=0,i=new Array(this._array.length-e.length),s=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:i[s++]=this._array[n];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(je=this._search(e),!(je<0||je>=this._array.length)&&this._getKey(this._array[je])===e))do yield this._array[je];while(++je<this._array.length&&this._getKey(this._array[je])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(je=this._search(e),!(je<0||je>=this._array.length)&&this._getKey(this._array[je])===e))do t(this._array[je]);while(++je<this._array.length&&this._getKey(this._array[je])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,n=this._getKey(this._array[s]);if(n>e)i=s-1;else if(n<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Jr=0,Vd=0,uk=class extends be{constructor(){super(),this._decorations=new ck(e=>e?.marker.line),this._onDecorationRegistered=this._register(new X),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new X),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ae(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new pk(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,n=0;for(let r of this._decorations.getKeyIterator(t))s=r.options.x??0,n=s+(r.options.width??1),e>=s&&e<n&&(!i||(r.options.layer??"bottom")===i)&&(yield r)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,n=>{Jr=n.options.x??0,Vd=Jr+(n.options.width??1),e>=Jr&&e<Vd&&(!i||(n.options.layer??"bottom")===i)&&s(n)})}},pk=class extends ki{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new X),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new X),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Le.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Le.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fk=1e3,mk=class{constructor(e,t=fk){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=s-this._lastRefreshMs,r=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Ud=20,Zn=class extends be{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let r=0;r<this._terminal.rows;r++)this._rowElements[r]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[r]);if(this._topBoundaryFocusListener=r=>this._handleBoundaryFocus(r,0),this._bottomBoundaryFocusListener=r=>this._handleBoundaryFocus(r,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new mk(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(r=>this._handleResize(r.rows))),this._register(this._terminal.onRender(r=>this._refreshRows(r.start,r.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(r=>this._handleChar(r))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
41
|
-
`))),this._register(this._terminal.onA11yTab(r=>this._handleTab(r))),this._register(this._terminal.onKey(r=>this._handleKey(r.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ue(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ae(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Ud+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
42
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ud+1&&(this._liveRegion.textContent+=Ro.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let n=e;n<=t;n++){let r=i.lines.get(i.ydisp+n),o=[],a=r?.translateToString(!0,void 0,void 0,o)||"",l=(i.ydisp+n+1).toString(),h=this._rowElements[n];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",l),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],n=i.getAttribute("aria-posinset"),r=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===r||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let n=({node:a,offset:l})=>{let h=a instanceof Text?a.parentNode:a,c=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(h);if(!u)return console.warn("columns is null. Race condition?"),null;let p=l<u.length?u[l]:u.slice(-1)[0]+1;return p>=this._terminal.cols&&(++c,p=0),{row:c,column:p}},r=n(t),o=n(i);if(!(!r||!o)){if(r.row>o.row||r.row===o.row&&r.column>=o.column)throw new Error("invalid range");this._terminal.select(r.column,r.row,(o.row-r.row)*this._terminal.cols-r.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,i=this._rowColumns.get(e)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Zn=ze([ee(1,el),ee(2,ui),ee(3,pi)],Zn);var pa=class extends be{constructor(e,t,i,s,n){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new X),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new X),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ae(()=>{Fi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ue(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ue(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ue(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ue(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let n=i[s];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(n=>{n.link.dispose&&n.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[s,n]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,e,i)):n.provideLinks(e.y,r=>{if(this._isMouseOut)return;let o=r?.map(a=>({link:a}));this._activeProviderReplies?.set(s,o),i=this._checkLinkProviderResult(s,e,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let n=t.get(s);if(n)for(let r=0;r<n.length;r++){let o=n[r],a=o.link.range.start.y<e?0:o.link.range.start.x,l=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=l;h++){if(i.has(h)){n.splice(r--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),n=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(n=!0);if(!n&&s){let r=s.find(o=>this._linkAtPosition(o.link,t));r&&(i=!0,this._handleNewLink(r))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let r=0;r<this._activeProviderReplies.size;r++){let o=this._activeProviderReplies.get(r)?.find(a=>this._linkAtPosition(a.link,t));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&gk(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Fi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(s,n),this._lastMouseEvent)){let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._askForLink(r,!1)}})))}_linkHover(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return i<=n&&n<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,n){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:n}}};pa=ze([ee(1,tl),ee(2,pi),ee(3,ht),ee(4,Dp)],pa);function gk(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var vk=class extends lk{constructor(e={}){super(e),this._linkifier=this._register(new os),this.browser=Fp,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new os),this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new X),this.onKey=this._onKey.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new X),this.onBell=this._onBell.event,this._onFocus=this._register(new X),this._onBlur=this._register(new X),this._onA11yCharEmitter=this._register(new X),this._onA11yTabEmitter=this._register(new X),this._onWillOpen=this._register(new X),this._setup(),this._decorationService=this._instantiationService.createInstance(uk),this._instantiationService.setService(Js,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(oD),this._instantiationService.setService(Dp,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Lo)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(rt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(rt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(rt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(rt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ae(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let n=Ee.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${$.ESC}]${s};${ik(n)}${Wp.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(r=>r.ansi[t.index]=We.toColor(...t.color));else{let r=i;this._themeService.modifyColors(o=>o[r]=We.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Zn,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,n=t.getWidth(i),r=this._renderService.dimensions.css.cell.width*n,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=r+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ue(this.element,"copy",t=>{this.hasSelection()&&yC(t,this._selectionService)}));let e=t=>xC(t,this.textarea,this.coreService,this.optionsService);this._register(ue(this.textarea,"paste",e)),this._register(ue(this.element,"paste",e)),Vp?this._register(ue(this.element,"mousedown",t=>{t.button===2&&id(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ue(this.element,"contextmenu",t=>{id(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),hl&&this._register(ue(this.element,"auxclick",t=>{t.button===1&&gp(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ue(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ue(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ue(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ue(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ue(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ue(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ue(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ue(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ao.get()),qp||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(nD,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ui,this._coreBrowserService),this._register(ue(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(ue(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ta,this._document,this._helperContainer),this._instantiationService.setService(cr,this._charSizeService),this._themeService=this._instantiationService.createInstance(ra),this._instantiationService.setService(hs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Yn),this._instantiationService.setService(Cp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sa,this.rows,this.screenElement)),this._instantiationService.setService(pi,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Zo,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ia),this._instantiationService.setService(tl,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(pa,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xo,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(na,this.element,this.screenElement,s)),this._instantiationService.setService(IC,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(rt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Jo,this.screenElement)),this._register(ue(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Zn,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(qn,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(qn,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ea,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(r){let o=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!o)return!1;let a,l;switch(r.overrideType||r.type){case"mousemove":l=32,r.buttons===void 0?(a=3,r.button!==void 0&&(a=r.button<3?r.button:3)):a=r.buttons&1?0:r.buttons&4?1:r.buttons&2?2:3;break;case"mouseup":l=0,a=r.button<3?r.button:3;break;case"mousedown":l=1,a=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(r)===!1)return!1;let h=r.deltaY;if(h===0||e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;l=h<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:l,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:r=>(i(r),r.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(r)),wheel:r=>(i(r),this.cancel(r,!0)),mousedrag:r=>{r.buttons&&i(r)},mousemove:r=>{r.buttons||i(r)}};this._register(this.coreMouseService.onProtocolChange(r=>{r?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(r)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),r&8?s.mousemove||(t.addEventListener("mousemove",n.mousemove),s.mousemove=n.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),r&16?s.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),s.wheel=n.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),r&2?s.mouseup||(s.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),r&4?s.mousedrag||(s.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ue(t,"mousedown",r=>{if(r.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(r)))return i(r),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(r)})),this._register(ue(t,"wheel",r=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(r)===!1)return!1;if(!this.buffer.hasScrollback){if(r.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(r,!0);let o=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(o,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){mp(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=dk(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===$.ETX||i.key===$.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(_k(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Be));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent($.ESC+"[I"):this.coreService.triggerDataEvent($.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${n};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function _k(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bk=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},wk=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new It)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Kd=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new wk(t)}getNullCell(){return new It}},yk=class extends be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new X),this.onBufferChange=this._onBufferChange.event,this._normal=new Kd(this._core.buffers.normal,"normal"),this._alternate=new Kd(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},xk=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Sk=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Ck=["cols","rows"],Bt=0,Dk=class extends be{constructor(e){super(),this._core=this._register(new vk(e)),this._addonManager=this._register(new bk),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,n)=>{this._checkReadonlyOptions(s),this._core.options[s]=n};for(let s in this._core.options){let n={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,n)}}_checkReadonlyOptions(e){if(Ck.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new xk(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Sk(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new yk(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
43
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Ao.get()},set promptLabel(e){Ao.set(e)},get tooMuchOutput(){return Ro.get()},set tooMuchOutput(e){Ro.set(e)}}}_verifyIntegers(...e){for(Bt of e)if(Bt===1/0||isNaN(Bt)||Bt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Bt of e)if(Bt&&(Bt===1/0||isNaN(Bt)||Bt%1!==0||Bt<0))throw new Error("This API only accepts positive integers")}};function qd(e){const t=e.replace(/[\u0000-\u001f\u007f]/g,"").trim();if(!t)return"";let i=t;const s=t.lastIndexOf(": ");return s>=0&&(i=t.slice(s+2).trim()),!i.includes("/")&&!i.startsWith("~")?i:i.replace(/^~\/?/,"").split("/").filter(Boolean).at(-1)||i}let Yd=!1;function kk(){Yd||(Yd=!0,window.electronAPI.terminal.onData(({termId:e,data:t})=>{Pi.get(e)?.term.write(t)}),window.electronAPI.terminal.onExit(({termId:e,exitCode:t})=>{Pi.get(e)?.term.write(`\r
|
|
44
|
-
\x1B[2m[process exited: ${t}]\x1B[0m\r
|
|
45
|
-
`)}))}function Pk(e,t){kk();const i=Pi.get(e);if(i)return i;const s=new Dk({cursorBlink:!0,fontFamily:`"Enso Nerd Symbols", ${t.fontFamily}`,fontSize:t.fontSize,...t.fontWeight?{fontWeight:t.fontWeight}:{},...t.fontWeightBold?{fontWeightBold:t.fontWeightBold}:{},theme:t.theme,allowTransparency:!0,allowProposedApi:!0,scrollback:5e3}),n=new nS,r=new GS;s.loadAddon(n),s.loadAddon(r),s.loadAddon(new gC((h,c)=>{window.open(c,"_blank")}));const o=new dC;s.loadAddon(o),s.unicode.activeVersion="11";const a=document.createElement("div");a.dataset.termId=e,a.style.width="100%",a.style.height="100%",s.onData(h=>{window.electronAPI.terminal.write(e,h)});const l={term:s,fit:n,search:r,host:a,opened:!1};return s.onTitleChange(h=>{const c=qd(h);c&&l.onTitle?.(c)}),s.parser.registerOscHandler(7,h=>{try{const c=decodeURIComponent(h).replace(/^file:\/\/[^/]*/,""),u=qd(c);u&&l.onTitle?.(u)}catch{}return!1}),Pi.set(e,l),l}function Ek(e,t,i){const s=Pk(e,i);return s.host.parentElement!==t&&t.appendChild(s.host),!s.opened&&t.isConnected&&t.clientWidth>0&&(s.term.open(s.host),s.opened=!0),s}function Tk(e){Pi.get(e)?.host.remove()}function Ik(e,t,i,s,n){for(const{term:r}of Pi.values())r.options.theme=e,r.options.fontFamily=`"Enso Nerd Symbols", ${t}`,r.options.fontSize=i,s&&(r.options.fontWeight=s),n&&(r.options.fontWeightBold=n)}function Xd(e,t,i,s){const n=Pi.get(e)?.search;return!n||!t?!1:i==="next"?n.findNext(t,s):n.findPrevious(t,s)}function Ak(e){Pi.get(e)?.search.clearDecorations()}function Rk({open:e,onClose:t,onFindNext:i,onFindPrevious:s,onClear:n,theme:r}){const{t:o}=ae(),a=w.useRef(null),[l,h]=w.useState(""),[c,u]=w.useState(!1),[p,f]=w.useState(!1),[m,g]=w.useState(!1),[_,T]=w.useState(null);w.useEffect(()=>{e?(a.current?.focus(),a.current?.select()):(n(),T(null))},[e,n]);const D=()=>({caseSensitive:c,wholeWord:p,regex:m}),E=k=>{if(!l){T(null);return}T(k==="next"?i(l,D()):s(l,D()))};if(!e)return null;const S=r?.background??"#1e1e1e",A=r?.foreground??"#d4d4d4";return d.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1 rounded-md border px-2 py-1 shadow-lg",style:{backgroundColor:S,borderColor:`${A}30`},children:[d.jsx("input",{ref:a,value:l,onChange:k=>{const L=k.target.value;h(L),L?T(i(L,D())):(n(),T(null))},onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),E(k.shiftKey?"prev":"next")):k.key==="Escape"&&(k.preventDefault(),t())},placeholder:o("Search..."),className:U("w-40 bg-transparent text-sm outline-none placeholder:opacity-50",_===!1&&l&&"text-red-400"),style:{color:A}}),d.jsx("button",{type:"button",onClick:()=>u(k=>!k),className:U("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",c?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Case sensitive"),children:"Aa"}),d.jsx("button",{type:"button",onClick:()=>f(k=>!k),className:U("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",p?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Whole word"),children:"W"}),d.jsx("button",{type:"button",onClick:()=>g(k=>!k),className:U("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",m?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Regular expression"),children:".*"}),d.jsx("div",{className:"mx-1 h-4 w-px",style:{backgroundColor:`${A}30`}}),d.jsx("button",{type:"button",onClick:()=>E("prev"),className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Previous match"),children:d.jsx(Im,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:()=>E("next"),className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Next match"),children:d.jsx(Ii,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:t,className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Close"),children:d.jsx(qs,{className:"h-4 w-4"})})]})}function Jd(e,t){const i=xc(e);return t?Rm(i):i}function Nk({termId:e,conversationId:t,projectId:i,onTitle:s}){const{t:n}=ae(),r=w.useRef(null),o=w.useRef(null),a=w.useRef(""),[l,h]=w.useState(!1),c=w.useRef(t);c.current=t;const u=w.useRef(i);u.current=i;const p=w.useRef(s);p.current=s;const f=$e(y=>y.terminalTheme),m=$e(y=>y.terminalFontFamily),g=$e(y=>y.terminalFontSize),_=$e(y=>y.terminalFontWeight),T=$e(y=>y.terminalFontWeightBold),D=Am()!==null,E=w.useRef(D);E.current=D;const[S,A]=w.useState(!1);w.useEffect(()=>{const y=r.current;if(!y)return;let x=!1,b=0,R;const M=()=>{if(x)return;if(!y.isConnected||y.clientWidth===0||y.clientHeight===0){b=requestAnimationFrame(M);return}const B=$e.getState(),Q=Ek(e,y,{theme:Jd(B.terminalTheme,E.current),fontFamily:B.terminalFontFamily,fontSize:B.terminalFontSize,fontWeight:B.terminalFontWeight,fontWeightBold:B.terminalFontWeightBold});if(!Q.opened){b=requestAnimationFrame(M);return}Q.onTitle=ne=>p.current?.(ne);const ie=()=>{!y.isConnected||y.clientWidth===0||(Q.fit.fit(),window.electronAPI.terminal.resize(e,Q.term.cols,Q.term.rows))};ie(),window.electronAPI.terminal.create({termId:e,conversationId:c.current,projectId:u.current,cols:Q.term.cols,rows:Q.term.rows}),Q.term.focus(),o.current=Q.term,R=new ResizeObserver(ie),R.observe(y)};document.fonts.load('14px "Enso Nerd Symbols"',"").then(M,B=>{console.warn("Failed to load terminal icon font",B),M()});const W=B=>{(B.metaKey||B.ctrlKey)&&B.key==="f"&&(B.preventDefault(),B.stopPropagation(),A(!0))};return y.addEventListener("keydown",W,!0),()=>{x=!0,cancelAnimationFrame(b),R?.disconnect(),y.removeEventListener("keydown",W,!0),o.current=null,Tk(e)}},[e]),w.useEffect(()=>{Ik(Jd(f,D),m,g,_,T)},[f,m,g,_,T,D]);const k=w.useCallback((y,x)=>Xd(e,y,"next",x),[e]),L=w.useCallback((y,x)=>Xd(e,y,"prev",x),[e]),O=w.useCallback(()=>Ak(e),[e]),z=()=>{const y=o.current?.getSelection().trim()??"";a.current=y,h(y.length>0)},N=()=>{const y=a.current||o.current?.getSelection().trim()||"";y&&(Ic(y),Na(),o.current?.clearSelection(),h(!1))},I=()=>{const y=a.current||o.current?.getSelection().trim()||"";y&&navigator.clipboard.writeText(y)},C=xc(f),v=d.jsx("div",{ref:r,"data-slot":"terminal-pane",className:"relative h-full w-full overflow-hidden p-2",style:{backgroundColor:C?.background,"--terminal-bg":C?.background},onContextMenu:z,children:d.jsx(Rk,{open:S,onClose:()=>A(!1),onFindNext:k,onFindPrevious:L,onClear:O,theme:C})});return d.jsxs(Ca,{children:[d.jsx(Da,{render:v}),d.jsxs(ka,{className:"min-w-40",children:[d.jsx(nt,{disabled:!l,onClick:I,children:n("Copy")}),d.jsx(nt,{disabled:!l,onClick:N,children:n("Send to conversation")})]})]})}const rf={running:"bg-amber-500",completed:"bg-emerald-500",failed:"bg-destructive",cancelled:"bg-muted-foreground"},Lk=[],Mk={project:"Project",custom:"Custom",global:"Global",plugin:"Plugin",builtin:"Built-in"};function Ok(e,t,i,s){const n=ce.getState(),r=n.conversations[e],o=$e.getState(),a=o.projects.find(c=>c.id===r?.projectId);if(!r||!a)return!1;const l=lc({defaultModel:o.defaultModel,...ac(a,o.projectGroups),lastProviderId:r.lastProviderId,lastModelId:r.lastModelId,providers:Om(),credentials:hc(oc.getState().snapshot),virtualModels:o.virtualModels});if(l.source==="none")return Ln({type:"warning",title:s("No usable model is available. Configure provider credentials and enable a model first.")}),!1;const h={};for(const c of t.args){const u=i[c.key]?.trim();u&&(h[c.key]=u)}return n.send(Gm({id:t.id,name:t.source==="builtin"?s(t.name):t.name,args:h}),{providerId:l.providerId,modelId:l.modelId,cwd:a.path},void 0,e),!0}function Gk({conversationId:e,preset:t,open:i,onToggle:s}){const{t:n}=ae(),[r,o]=w.useState({}),a=t.args.some(c=>c.required&&!c.default?.trim()&&!r[c.key]?.trim()),l=t.source==="builtin"?n(t.name):t.name,h=t.source==="builtin"?n(t.description):t.description;return d.jsxs("li",{className:"rounded-md border",children:[d.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted/60",onClick:s,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:l}),d.jsx("span",{className:"shrink-0 text-muted-foreground",children:n(Mk[t.source])})]}),d.jsx("p",{className:"mt-0.5 line-clamp-2 text-muted-foreground",children:h})]}),i?d.jsxs("form",{className:"space-y-2 border-t px-2 py-2",onSubmit:c=>{c.preventDefault(),!(a||!Ok(e,t,r,n))&&(o({}),s())},children:[t.args.map(c=>d.jsxs("label",{className:"block text-xs",children:[d.jsxs("span",{className:"text-muted-foreground",children:[t.source==="builtin"?n(c.label):c.label,c.required?" *":""]}),d.jsx(bc,{size:"sm",className:"mt-1",value:r[c.key]??"",placeholder:c.default,onChange:u=>o(p=>({...p,[c.key]:u.target.value}))})]},c.key)),d.jsx("div",{className:"flex justify-end",children:d.jsxs(Me,{type:"submit",size:"xs",disabled:a,children:[d.jsx(Mm,{}),n("Run")]})})]}):null]})}function zk({conversationId:e}){const{t}=ae(),[i,s]=w.useState([]),[n,r]=w.useState(null),o=$e(c=>c.disabledWorkflowPresets),a=ce(c=>c.conversations[e]?.presetId),l=w.useCallback(()=>{let c=!1;return window.electronAPI.assets.listWorkflowPresets(e,a).then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[e,a]);w.useEffect(l,[l]);const h=i.filter(c=>c.source!=="builtin"||!o.includes(c.id));return d.jsxs("section",{children:[d.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[d.jsx("h3",{className:"flex-1 text-xs font-medium text-muted-foreground",children:t("Presets")}),d.jsx(Me,{type:"button",variant:"ghost",size:"icon-xs","aria-label":t("Manage workflow presets"),title:t("Manage workflow presets"),onClick:()=>{window.electronAPI.window.openSettings({category:"workflows",rowId:"workflows.root"})},children:d.jsx(Lm,{})}),d.jsx(Me,{type:"button",variant:"ghost",size:"icon-xs","aria-label":t("Refresh"),onClick:()=>l(),children:d.jsx(ai,{})})]}),d.jsx("ul",{className:"space-y-1.5",children:h.map(c=>d.jsx(Gk,{conversationId:e,preset:c,open:n===c.id,onToggle:()=>r(u=>u===c.id?null:c.id)},`${c.source}:${c.id}`))})]})}function jk(e,t){const i=ce.getState();i.activeId!==e&&i.selectConversation(e),i.selectTab(e,t)}function Bk({conversationId:e,member:t}){const{t:i}=ae(),s=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:U("h-1.5 w-1.5 shrink-0 rounded-full",rf[t.status])}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),d.jsx("span",{className:"text-muted-foreground",children:i(t.status)})]}),t.prompt?d.jsx("p",{className:"mt-0.5 truncate pl-3.5 text-muted-foreground",children:t.prompt}):null,t.result?d.jsx("p",{className:"mt-0.5 line-clamp-3 whitespace-pre-wrap pl-3.5 text-foreground/80",children:t.result}):null]}),n=t.childId;return n?d.jsx("li",{children:d.jsx("button",{type:"button",className:"w-full rounded px-1 py-0.5 text-left text-xs hover:bg-muted/60",onClick:()=>jk(e,n),children:s})}):d.jsx("li",{className:"text-xs",children:s})}function $k({conversationId:e}){const{t}=ae(),i=io(r=>r.byConversation[e])??Lk,s=io(r=>r.clearFinished),n=i.some(r=>r.status!=="running");return d.jsx("div",{className:"h-full overflow-auto bg-background p-3",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(zk,{conversationId:e}),n?d.jsx("div",{className:"flex justify-end",children:d.jsxs(Me,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>s(e),children:[d.jsx(Nm,{}),t("Clear finished runs")]})}):null,i.length===0?d.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:t("No workflow runs")}):null,i.map(r=>d.jsxs("section",{className:"rounded-md border px-3 py-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:U("h-2 w-2 shrink-0 rounded-full",rf[r.status])}),d.jsx("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:r.name}),d.jsx("span",{className:"text-xs text-muted-foreground",children:t(r.status)}),r.status==="running"?d.jsx(Me,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive","aria-label":t("Stop"),title:t("Stop"),onClick:()=>{window.electronAPI.agent.stopWorkflow(e,r.runId)},children:d.jsx(rc,{})}):null]}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.description}),d.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("{{count}} agents",{count:r.members.length})}),d.jsx("div",{className:"mt-2 space-y-2",children:Kv(r.members).map((o,a,l)=>{const h=!!o.phase&&o.phase!==l[a-1]?.phase;return d.jsxs("div",{children:[d.jsxs("div",{className:"mb-1 flex items-center gap-2 text-xs",children:[h?d.jsx("span",{className:"font-medium",children:o.phase}):null,o.members.length>1?d.jsx("span",{className:"text-muted-foreground",children:t("Parallel")}):null]}),d.jsx("ul",{className:"space-y-1",children:o.members.map(c=>d.jsx(Bk,{conversationId:e,member:c},c.seq))})]},`${o.batch}:${o.phase??""}`)})}),r.error?d.jsx("p",{className:"mt-2 text-xs text-destructive",children:r.error}):null,r.logs.length>0?d.jsx("p",{className:"mt-2 whitespace-pre-wrap text-xs text-muted-foreground",children:r.logs.join(`
|
|
46
|
-
`)}):null]},r.runId))]})})}const cs=w.createContext({}),of=w.createContext(!1);function fr({api:e,children:t}){const{conversationId:i}=w.useContext(cs);return i?d.jsx(Zg,{dockConversationId:i,api:e,children:t}):t}function Wk(e,t){const[i,s]=w.useState(!t);return w.useEffect(()=>{if(!t)return;const n=()=>{const o=t.element.closest(".dv-dockview")?.getBoundingClientRect(),a=t.element.getBoundingClientRect();s(!!o&&Math.abs(a.top-o.top)<1&&Math.abs(a.right-o.right)<1)};n();const r=e.onDidLayoutChange(n);return()=>r.dispose()},[e,t]),i}function af(e,t){const i=e.panels.length;return i===0?t:`${t} ${i+1}`}function lf(e,t,i,s){e.addPanel({id:crypto.randomUUID(),component:"terminal",title:af(e,s),params:{conversationId:t,projectId:i}})}function dl(e,t,i,s){const n=e.getPanel("changes");if(n){n.focus();return}e.addPanel({id:"changes",component:"changes",title:s,params:{conversationId:t,projectId:i}})}function Hk(e){return d.jsx(Nk,{termId:e.api.id,conversationId:e.params.conversationId,projectId:e.params.projectId,onTitle:t=>e.api.setTitle(t)})}function Fk(e){const{conversationId:t,projectId:i}=e.params;return!t||!i?null:d.jsx(fr,{api:e.api,children:d.jsx(ix,{conversationId:t,projectId:i})})}function cl(e,t,i,s){const n=e.getPanel("files");if(n){n.focus();return}e.addPanel({id:"files",component:"files",title:s,params:{conversationId:t,projectId:i}})}function Vk(e){const{conversationId:t,projectId:i}=e.params;return!t||!i?null:d.jsx(fr,{api:e.api,children:d.jsx(zx,{conversationId:t,projectId:i})})}function ul(e,t,i,s,n){const r=e.panels.filter(o=>o.id.startsWith("btw:")).length;e.addPanel({id:n??`btw:${crypto.randomUUID()}`,component:"btw",title:r===0?s:`${s} ${r+1}`,params:{conversationId:t,projectId:i}})}function Uk(e){const{conversationId:t}=e.params;return t?d.jsx(Vy,{conversationId:t,panelApi:e.api}):null}function pl(e,t,i,s,n){const r=n??`browser:${crypto.randomUUID()}`,o=e.getPanel(r);if(o){o.focus();return}e.addPanel({id:r,component:"browser",title:s,params:{conversationId:t,projectId:i}})}function Kk(e){const{conversationId:t}=e.params;return t?d.jsx(fr,{api:e.api,children:d.jsx(Jg,{conversationId:t,panelApi:e.api})}):null}function fl(e,t,i,s){const n=e.getPanel("workflow");if(n){n.focus();return}e.addPanel({id:"workflow",component:"workflow",title:s,params:{conversationId:t,projectId:i}})}function qk(e){return d.jsx(fr,{api:e.api,children:d.jsx(Hy,{projectId:e.params.projectId})})}function ml(e){return $e(t=>Xm(t,e))}function gl(e){return $e(t=>t.secretaryEnabled&&Jm(t.projects,e))}const Yk=[];function vl(){return Pt(e=>e.secretary.profile?e.secretary.profile.pluginIds??Yk:null)}function _l(e,t,i,s,n){const r=`plugin:${s.pluginId}:${s.id}`,o=e.getPanel(r);if(o){o.focus();return}e.addPanel({id:r,component:"plugin",title:s.title,params:{conversationId:t,projectId:i,pluginId:s.pluginId,viewId:s.id},renderer:"always",...n?{position:{referenceGroup:n}}:{}})}function Xk(e){const{conversationId:t,pluginId:i,viewId:s}=e.params,n=w.useContext(cs).conversationId,r=De(o=>o.liveGlobalTabs.includes(e.api.id));return w.useEffect(()=>{e.api.renderer!=="always"&&e.api.setRenderer("always")},[e.api]),!i||!s?null:r&&n?d.jsx(Bx,{panelId:e.api.id,conversationId:n,api:e.api,containerApi:e.containerApi}):d.jsx(E0,{pluginId:i,viewId:s,sessionId:t??null})}function Jk(e){const{conversationId:t}=e.params;return t?d.jsx($k,{conversationId:t}):null}function Zk(e,t){const i=e.group.panels.map(r=>r.id),s=new Set(wo(i,e.id,t)),n=[];for(const r of[...e.group.panels])s.has(r.id)&&(r.api.close(),n.push(r.id));return n}const Qk=new Set(["terminal","changes","files","btw"]),fa=new Set;function eP(e){for(const t of fa)t(e)}function tP(e){const{t}=ae(),{conversationId:i}=w.useContext(cs),s=w.useRef(null),[n,r]=w.useState(e.api.isActive),[o,a]=w.useState(e.api.title??""),[l,h]=w.useState(e.params.favicon??null),[c,u]=w.useState(!1),p=De(N=>N.pinnedTabs),f=De(N=>N.togglePinnedTab),m=Yx(e.api.id),g=m?p.includes(m):!1,_=Ks(),T=De(N=>N.globalScopeOverrides),D=De(N=>N.liveGlobalTabs.includes(e.api.id)),E=qu(e.api.id),S=E?_.some(N=>`plugin:${N.pluginId}:${N.id}`===e.api.id):m!==void 0&&Qk.has(m),A=E?ig(e.api.id,T,_)==="global":g,k=()=>{if(E){i&&rg(e.api.id,i,A?"session":"global");return}m&&(f(m),A||eP(m))};w.useEffect(()=>{const N=e.api.onDidActiveChange(()=>r(e.api.isActive)),I=e.api.onDidTitleChange(()=>a(e.api.title??"")),C=e.api.onDidParametersChange(v=>{const y=v&&typeof v=="object"&&"favicon"in v?v.favicon??null:e.api.getParameters()?.favicon??null;h(y??null),u(!1)});return()=>{N.dispose(),I.dispose(),C.dispose()}},[e.api]);const L=e.api.id==="browser"||e.api.id.startsWith("browser:"),O=N=>{const I=s.current?Vh(s.current):null,C=I?Uh(I):null,v=Zk(e.api,N);!I||!C||Kh(I,v.flatMap(y=>{const x=C.get(y);return x?[x]:[]}))},z=d.jsxs("div",{ref:N=>{s.current=N},"data-side-tab":!0,"data-panel-id":e.api.id,"data-active":n||void 0,className:U("group/tab relative flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",n?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),children:[e.api.id==="changes"?d.jsx(Ac,{className:"h-3 w-3 shrink-0"}):e.api.id==="files"?d.jsx(xa,{className:"h-3 w-3 shrink-0"}):e.api.id.startsWith("btw:")?d.jsx(Ra,{className:"h-3 w-3 shrink-0"}):e.api.id==="workflow"?d.jsx(Sc,{className:"h-3 w-3 shrink-0"}):e.api.id==="secretary"?d.jsx(Nc,{className:"h-3 w-3 shrink-0"}):e.api.id.startsWith("plugin:")?d.jsx(ma,{pluginId:e.api.id.split(":")[1]??"",className:"h-3 w-3 shrink-0"}):L&&l&&!c?d.jsx("img",{src:l,alt:"",className:"h-3 w-3 shrink-0",onError:()=>u(!0)}):L?d.jsx(Cc,{className:"h-3 w-3 shrink-0"}):d.jsx(Dc,{className:"h-3 w-3 shrink-0"}),d.jsx(tS,{title:o,global:E&&A}),m&&!D?d.jsx("button",{type:"button","aria-label":t(g?"Unpin default tab":"Pin as default tab"),"aria-pressed":g,title:t(g?"Unpin default tab":"Pin as default tab"),className:U("rounded p-0.5 transition-opacity hover:text-foreground",g?"text-primary":"text-muted-foreground opacity-0 group-hover/tab:opacity-100 focus-visible:opacity-100"),onPointerDown:N=>N.stopPropagation(),onClick:N=>{N.preventDefault(),N.stopPropagation(),f(m)},children:d.jsx(Yg,{className:"h-3 w-3"})}):null,d.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/tab:opacity-100",onPointerDown:N=>N.stopPropagation(),onClick:N=>{N.preventDefault(),N.stopPropagation();const I=Vh(N.currentTarget),C=I?Uh(I).get(e.api.id):void 0;e.api.close(),I&&C&&Kh(I,[C])},children:d.jsx(qs,{className:"h-3 w-3"})})]});return d.jsxs(Ca,{children:[d.jsx(Da,{render:z}),d.jsxs(ka,{className:"min-w-40",children:[d.jsx(nt,{onClick:()=>O("self"),children:t("Close")}),d.jsx(nt,{onClick:()=>O("others"),children:t("Close others")}),d.jsx(nt,{onClick:()=>O("right"),children:t("Close tabs to the right")}),d.jsx(nt,{onClick:()=>O("all"),children:t("Close all")}),S?d.jsxs(d.Fragment,{children:[d.jsx(yc,{}),d.jsx(eS,{checked:A,onClick:k})]}):null]})]})}function hf({onNewTerminal:e,onNewChanges:t,onNewFiles:i,onNewBrowser:s,onNewBtw:n,onNewWorkflow:r,onNewSecretary:o,secretaryLabel:a,onNewPluginView:l,secretaryPluginIds:h,compact:c}){const{t:u}=ae(),p=Ks(),f=h===void 0?p:Zx(p,h??void 0);return d.jsxs(uc,{children:[d.jsxs(pc,{className:U("flex items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",c?"h-6 w-6 rounded p-1 hover:bg-muted":"h-8 gap-1.5 border border-dashed px-3 text-sm hover:border-solid"),"aria-label":u("New tab"),children:[d.jsx(ns,{className:"h-4 w-4"}),!c&&d.jsx("span",{children:u("New tab")})]}),d.jsxs(fc,{align:c?"end":"center",className:"min-w-36",children:[e?d.jsxs(Nt,{onClick:e,children:[d.jsx(Dc,{className:"h-4 w-4"}),u("Terminal")]}):null,t?d.jsxs(Nt,{onClick:t,children:[d.jsx(Ac,{className:"h-4 w-4"}),u("Changes")]}):null,i?d.jsxs(Nt,{onClick:i,children:[d.jsx(xa,{className:"h-4 w-4"}),u("Files")]}):null,d.jsxs(Nt,{onClick:s,children:[d.jsx(Cc,{className:"h-4 w-4"}),u("Browser")]}),n?d.jsxs(Nt,{onClick:n,children:[d.jsx(Ra,{className:"h-4 w-4"}),u("Btw")]}):null,r?d.jsxs(Nt,{onClick:r,children:[d.jsx(Sc,{className:"h-4 w-4"}),u("Workflow")]}):null,o?d.jsxs(Nt,{"data-enso":"secretary-panel-open",onClick:o,children:[d.jsx(Nc,{className:"h-4 w-4"}),a??u("Secretary")]}):null,l?f.map(m=>d.jsxs(Nt,{onClick:()=>l(m),children:[d.jsx(ma,{pluginId:m.pluginId,className:"h-4 w-4"}),m.title]},`${m.pluginId}:${m.id}`)):null]})]})}function df({containerApi:e,group:t}){const{t:i}=ae(),{conversationId:s,projectId:n}=w.useContext(cs),r=De(D=>D.fullscreen),o=De(D=>D.toggleFullscreen),a=ml(n),l=gl(n),h=vl(),c=La(),u=Sa(),p=w.useContext(of),f=Wk(e,t),m=De(D=>D.toggleOpen),g=sg()==="windows",_=Pt(D=>D.focusProposal),T=w.useRef(0);return w.useEffect(()=>{!_||!l||_.at===T.current||(T.current=_.at,Hn(e,s,n,c))},[_,l,e,s,n,c]),d.jsxs("div",{className:"flex h-full items-center gap-0.5",children:[d.jsx(hf,{compact:!0,onNewTerminal:l?void 0:()=>{if(t){e.addPanel({id:crypto.randomUUID(),component:"terminal",title:af(e,i("Terminal")),params:{conversationId:s,projectId:n},position:{referenceGroup:t}});return}lf(e,s,n,i("Terminal"))},onNewChanges:l?void 0:()=>dl(e,s,n,i("Changes")),onNewFiles:l?void 0:()=>cl(e,s,n,i("Files")),onNewBrowser:()=>pl(e,s,n,i("Browser")),onNewBtw:l?void 0:()=>{if(t){const D=e.panels.filter(E=>E.id.startsWith("btw:")).length;e.addPanel({id:`btw:${crypto.randomUUID()}`,component:"btw",title:D===0?i("Btw"):`${i("Btw")} ${D+1}`,params:{conversationId:s,projectId:n},position:{referenceGroup:t}});return}ul(e,s,n,i("Btw"))},onNewWorkflow:a&&!l?()=>fl(e,s,n,i("Workflow")):void 0,onNewSecretary:l?()=>Hn(e,s,n,c):void 0,secretaryLabel:c,onNewPluginView:D=>_l(e,s,n,D,t),secretaryPluginIds:l?h:void 0}),d.jsx("button",{type:"button",className:U("flex h-6 w-6 items-center justify-center rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",u&&"hidden"),onClick:o,"aria-label":i(r?"Exit side panel fullscreen":"Expand side panel"),title:i(r?"Exit side panel fullscreen":"Expand side panel"),children:r?d.jsx(_c,{className:"h-3.5 w-3.5"}):d.jsx(vc,{className:"h-3.5 w-3.5"})}),p&&f&&d.jsx("button",{type:"button",className:"ml-1 flex h-8 w-8 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted",onClick:m,"aria-label":i("Toggle side panel"),title:i("Toggle side panel"),children:d.jsx(Xg,{className:"h-4 w-4"})}),p&&f&&g&&d.jsx("span",{"aria-hidden":!0,className:"shrink-0",style:{width:`calc(100vw - env(titlebar-area-width, calc(100vw - ${ng}px)) - 19px)`}})]})}function iP(e){const{t}=ae(),{conversationId:i,projectId:s}=w.useContext(cs),n=ml(s),r=gl(s),o=vl(),a=La();return d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsx("div",{className:"enso-side-dock-header flex shrink-0 items-center justify-end border-b bg-background px-2 py-1",children:d.jsx(df,{containerApi:e.containerApi})}),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 bg-background px-6 text-center",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:t("No tabs yet. Create one to get started.")}),d.jsx(hf,{onNewTerminal:r?void 0:()=>lf(e.containerApi,i,s,t("Terminal")),onNewChanges:r?void 0:()=>dl(e.containerApi,i,s,t("Changes")),onNewFiles:r?void 0:()=>cl(e.containerApi,i,s,t("Files")),onNewBrowser:()=>pl(e.containerApi,i,s,t("Browser")),onNewBtw:r?void 0:()=>ul(e.containerApi,i,s,t("Btw")),onNewWorkflow:n&&!r?()=>fl(e.containerApi,i,s,t("Workflow")):void 0,onNewSecretary:r?()=>Hn(e.containerApi,i,s,a):void 0,secretaryLabel:a,onNewPluginView:l=>_l(e.containerApi,i,s,l),secretaryPluginIds:r?o:void 0})]})]})}function sP(e){return d.jsx(df,{containerApi:e.containerApi,group:e.group})}function wi(e,t){return function(s){return d.jsx(qx,{name:e,children:d.jsx(t,{...s})})}}const Zd={terminal:wi("terminal",Hk),changes:wi("changes",Fk),files:wi("files",Vk),browser:wi("browser",Kk),btw:wi("btw",Uk),workflow:wi("workflow",Jk),secretary:wi("secretary",qk),plugin:wi("plugin",Xk)};function nP(){const[e,t]=w.useState(()=>document.documentElement.classList.contains("dark"));return w.useEffect(()=>{const i=new MutationObserver(()=>t(document.documentElement.classList.contains("dark")));return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[]),e}function rP({conversationId:e,hidden:t}){const i=ce(s=>s.conversations[e]?.projectId);return i?d.jsx("div",{className:U("absolute inset-0",t&&"hidden"),children:d.jsx(oP,{conversationId:e,projectId:i})}):null}function oP({conversationId:e,projectId:t}){const{t:i}=ae(),s=nP(),n=ml(t),r=gl(t),o=vl(),a=Ks(),l=La(),[h]=w.useState(Jx),[c,u]=w.useState(null),p=w.useRef(null),f=ce(z=>z.activeId),m=Pa(e),g=De(z=>z.uiByConversation[e]?.open===!0),_=De(z=>z.pinnedTabs),T=De(z=>z.globalTabs),D=De(z=>z.liveGlobalTabs),E=De(z=>z.globalScopeOverrides),S=Km(),A=w.useRef(!1);w.useLayoutEffect(()=>(p.current&&Il(e,p.current),()=>{p.current&&qm(e,p.current)}),[e]),w.useEffect(()=>{n||c?.getPanel("workflow")?.api.close()},[c,n]),w.useEffect(()=>{if(!c||!r)return;const z=c.panels.map(I=>I.id),N=new Set([...T,...D]);for(const I of Qx(z,o,N))c.getPanel(I)?.api.close()},[c,r,o,T,D]),w.useEffect(()=>{!c||!S||(Ym(e,c,!A.current),A.current=!0)},[e,c,g,T,a,E,S]);const k=(z,N)=>{const I=Xx({pinnedTabs:N,openPanelIds:z.panels.map(v=>v.id),secretary:r,workflowAvailable:n,pluginViews:a,secretaryPluginIds:o});let C;for(const v of I)if(v.kind==="terminal"){const y=crypto.randomUUID();z.addPanel({id:y,component:"terminal",title:i("Terminal"),params:{conversationId:e,projectId:t}}),C??=y}else if(v.kind==="changes")dl(z,e,t,i("Changes")),C??="changes";else if(v.kind==="files")cl(z,e,t,i("Files")),C??="files";else if(v.kind==="browser"){const y=`browser:${crypto.randomUUID()}`;pl(z,e,t,i("Browser"),y),C??=y}else if(v.kind==="btw"){const y=`btw:${crypto.randomUUID()}`;ul(z,e,t,i("Btw"),y),C??=y}else if(v.kind==="workflow")fl(z,e,t,i("Workflow")),C??="workflow";else{const y=a.find(b=>b.pluginId===v.pluginId&&b.id===v.viewId);if(!y)continue;const x=`plugin:${v.pluginId}:${v.viewId}`;_l(z,e,t,y),C??=x}return C},L=w.useRef(k);L.current=k,w.useEffect(()=>{const z=N=>{const I=p.current;if(!I)return;const C=I.activePanel;L.current(I,[N])&&C&&C.api.setActive()};return fa.add(z),()=>{fa.delete(z)}},[]),w.useEffect(()=>{if(!c||!m||f!==e)return;const z=c.panels.length===0,N=L.current(c,_);z&&N&&c.getPanel(N)?.focus()},[f,e,c,a,_,t,r,o,m,i,n]),w.useEffect(()=>{h({secretary:r,open:m,active:f===e,ready:c!==null})&&c&&Hn(c,e,t,l)},[f,e,c,t,h,r,l,m]);const O=z=>{Il(e,z.api);const N=De.getState().layouts[e],I=Zm(N,new Set(Object.keys(Zd)));let C=!!N&&!I;if(I)try{z.api.fromJSON(I)}catch{C=!0}Qm(e,z.api),eg(e,z.api),z.api.onDidLayoutChange(()=>{const v=z.api.toJSON();C&&Object.keys(v.panels??{}).length===0||(C=!1,De.getState().saveLayout(e,v))}),z.api.onDidRemovePanel(v=>{if(!(v.id==="changes"||v.id==="files"||v.id==="secretary"||v.id.startsWith("plugin:"))){if(v.id==="browser"||v.id.startsWith("browser:")){dc()||window.electronAPI.browser.closeTab(v.id);return}if(v.id.startsWith("btw:")){ce.getState().disposeBtwConversation(v.id.slice(4));return}tg(v.id),window.electronAPI.terminal.dispose(v.id)}}),p.current=z.api,u(z.api)};return d.jsx(cs.Provider,{value:{conversationId:e,projectId:t},children:d.jsx("div",{className:"enso-side-dock h-full",children:d.jsx(Ru,{components:Zd,defaultTabComponent:tP,watermarkComponent:iP,rightHeaderActionsComponent:sP,theme:s?Zb:Qb,onReady:O})})})}function UP({width:e,resizing:t=!1,card:i=!1,titleRow:s=!1}){const{t:n}=ae(),r=ce(v=>v.activeId),o=Pa(r),a=Sa(),h=De(v=>v.fullscreen)||a&&o;w.useEffect(()=>zm(),[]),w.useEffect(()=>{const v=window.electronAPI.browser.onReveal(x=>{jm(x.conversationId)||wc({conversationId:x.conversationId,tabId:x.tabId})}),y=window.electronAPI.browser.onTabClosed(x=>{Bm(x.conversationId,x.tabId)});return Uy(),()=>{v(),y()}},[]),w.useEffect(()=>io.subscribe((v,y)=>{for(const[x,b]of Object.entries(v.byConversation)){if(y.byConversation[x]===b)continue;const R=b.find(M=>M.status==="running");R&&$m({conversationId:x,runId:R.runId,title:n("Workflow")})}}),[n]),w.useEffect(()=>ce.subscribe((v,y)=>{for(const x of Object.keys(y.conversations))v.conversations[x]||Wm(x)}),[]);const c=ce(v=>v.activeId),[u,p]=w.useState([]),f=ce(v=>u.filter(y=>!!v.conversations[y]).join(`
|
|
47
|
-
`)),[m,g]=w.useState(h),[_,T]=w.useState(0),D=i&&!s?Vm:Um,E=Fm(e,_,D),S=w.useRef(null),[A,k]=w.useState({id:c,from:c});c!==A.id&&k({id:c,from:A.id}),h&&!m&&g(!0),w.useEffect(()=>{const v=S.current?.parentElement;if(!v)return;const y=()=>{const b=getComputedStyle(v);T(v.clientWidth-parseFloat(b.paddingLeft)-parseFloat(b.paddingRight))};y();const x=new ResizeObserver(y);return x.observe(v),()=>x.disconnect()},[]),w.useEffect(()=>{A.from!==A.id&&k(v=>v.from===v.id?v:{...v,from:v.id})},[A.from,A.id]);const L=m?void 0:Math.max(0,E-(o&&!i?1:0)),O=c,z=Vg({resizing:t,conversationId:A.id??void 0,previousConversationId:A.from??void 0}),N=h?_||E:o?E:0,I=!!s&&!a;O&&!u.includes(O)&&p(v=>v.includes(O)?v:[...v,O]);const C=f===""?[]:f.split(`
|
|
48
|
-
`);return d.jsxs(d.Fragment,{children:[m&&!a?d.jsx("div",{className:"shrink-0",style:{width:E},"aria-hidden":!0}):null,d.jsxs(Ug.aside,{ref:S,"data-slot":"side-panel",initial:!1,animate:{width:N},style:m?{position:"absolute"}:{position:"relative",maxWidth:`max(0px, calc(100% - ${Hm+D}px))`},transition:Kg({skip:z,cover:m,targetW:N}),onAnimationComplete:()=>{h||g(!1)},className:U("flex min-h-0 flex-col",I&&o?"overflow-clip [overflow-clip-margin:4px]":"overflow-hidden",o&&(I||!m)?"bg-transparent":I?"":"bg-background",m?I?"top-px right-[8px] bottom-[8px]":i?"top-0 right-[8px] bottom-[8px]":"inset-y-0 right-0":"shrink-0",I?U("no-drag -mt-[44px]",m?"rounded-b-[10px]":"rounded-br-[10px]"):i?U("rounded-[10px]",o&&"shadow-surface"):o&&"border-l"),"data-enso":"side-panel","data-title-row":I||void 0,children:[o&&(I||!m)?d.jsx(hP,{titleRow:I,full:m}):null,o&&!m&&L!==void 0?d.jsx("div",{"aria-hidden":!0,className:U("pointer-events-none absolute right-0 bottom-0 bg-background",s?"top-[44px]":"top-0"),style:{left:L}}):null,d.jsx("div",{className:U("relative flex h-full min-h-0 flex-col",m&&"w-full",!o&&"invisible"),style:{width:L,clipPath:I?m?lP:aP:void 0},children:d.jsxs("div",{className:"relative min-h-0 flex-1",children:[d.jsx(of.Provider,{value:I,children:C.map(v=>d.jsx(rP,{conversationId:v,hidden:v!==O},v))}),d.jsx(Wx,{}),C.length===0?d.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground",children:n("Select a conversation to use the side panel.")}):null]})})]})]})}const aP="shape(from 0 0, hline to 100%, vline to 44px, hline to calc(100% - 10px), arc to 100% 54px of 10px cw, vline to calc(100% - 10px), arc to calc(100% - 10px) 100% of 10px cw, hline to 0, close)",lP="shape(from 0 0, hline to 100%, vline to 44px, hline to calc(100% - 10px), arc to 100% 54px of 10px cw, vline to calc(100% - 10px), arc to calc(100% - 10px) 100% of 10px cw, hline to 10px, arc to 0 calc(100% - 10px) of 10px cw, vline to 54px, arc to 10px 44px of 10px cw, hline to 0, close)";function hP({titleRow:e,full:t}){const i=w.useRef(null),s=De(n=>n.browserHoles);return w.useLayoutEffect(()=>{const n=i.current;if(!n)return;const{left:r,top:o}=n.getBoundingClientRect(),a=Object.values(s).map(c=>({...c,x:c.x-r,y:c.y-o})),l=qg(a)??"";n.style.clipPath=l;const h=n.closest('[data-enso="side-panel"]');return h&&(l?h.style.setProperty("--enso-side-panel-holes-clip",l):h.style.removeProperty("--enso-side-panel-holes-clip")),()=>{h?.style.removeProperty("--enso-side-panel-holes-clip")}},[s]),d.jsxs(d.Fragment,{children:[e&&d.jsx("div",{"aria-hidden":!0,className:U("pointer-events-none absolute inset-x-0 top-[44px] bottom-0 shadow-surface",t?"rounded-[10px]":"rounded-r-[10px]"),style:t?void 0:{clipPath:"inset(-24px -24px -24px 0)"}}),d.jsx("div",{ref:i,"aria-hidden":!0,className:U("pointer-events-none absolute inset-x-0 bottom-0 bg-background",e?U("top-[44px]",t?"rounded-[10px]":"rounded-r-[10px]"):"top-0")})]})}export{UP as SidePanel};
|