collabmd 0.1.39 → 0.1.41
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 +75 -1
- package/dist/client/assets/{CodeMirrorEditor-UCMRAMCV-75Zi8U_A.js → CodeMirrorEditor-UCMRAMCV-DHEFSr_E.js} +1 -1
- package/dist/client/assets/{ar-SA-NXDWD63E-CTf_wpt3.js → ar-SA-NXDWD63E-S8m2UyIj.js} +1 -1
- package/dist/client/assets/{arc-DD8jaAGl.js → arc-OeTCl9Oy.js} +1 -1
- package/dist/client/assets/architecture-7EHR7CIX-BQpCYB3J.js +1 -0
- package/dist/client/assets/{architectureDiagram-Q4EWVU46-BftXiJA8.js → architectureDiagram-3BPJPVTR-CDqq0KA0.js} +3 -3
- package/dist/client/assets/{az-AZ-MXSORGZV-C_C9i9u3.js → az-AZ-MXSORGZV-DSzWvZBB.js} +1 -1
- package/dist/client/assets/bases-preview-controller-CBHDzzot.js +143 -0
- package/dist/client/assets/{bg-BG-O6MV2KSF-YmfvQf63.js → bg-BG-O6MV2KSF-C5nBekx3.js} +1 -1
- package/dist/client/assets/blockDiagram-GPEHLZMM-Z9jBLpGg.js +132 -0
- package/dist/client/assets/{bn-IN-MMW2ORAC-BTEFR4Ed.js → bn-BD-T2VJNT7N-D-8xXOzM.js} +1 -1
- package/dist/client/assets/{bn-BD-T2VJNT7N-BD0ob0JE.js → bn-IN-MMW2ORAC-D-8xXOzM.js} +1 -1
- package/dist/client/assets/button-2ZnWQkWV.js +1 -0
- package/dist/client/assets/{c4Diagram-AHTNJAMY-Gz7ZAK0d.js → c4Diagram-AAUBKEIU-UA_Eopag.js} +2 -2
- package/dist/client/assets/{ca-ES-MKBCGNOG-aLX_cjA0.js → ca-ES-MKBCGNOG-B3Ly68p3.js} +1 -1
- package/dist/client/assets/channel-CpvwJaGK.js +1 -0
- package/dist/client/assets/{chunk-EDXVE4YY-M4QxyGNt.js → chunk-2J33WTMH-DjYq2kZ3.js} +1 -1
- package/dist/client/assets/chunk-3OPIFGDE-DucrRywM.js +62 -0
- package/dist/client/assets/{chunk-4BX2VUAB-D5YiFdu1.js → chunk-4BX2VUAB-DcdHBPEH.js} +1 -1
- package/dist/client/assets/chunk-4EGX6M5U-BfCFom1o.js +1 -0
- package/dist/client/assets/{chunk-55IACEB6-VHgZjidg.js → chunk-55IACEB6-B7ycySPI.js} +1 -1
- package/dist/client/assets/chunk-5DO6E6H7-DP8QnaJj.js +1 -0
- package/dist/client/assets/chunk-5ZQYHXKU-C4q4UVKa.js +2 -0
- package/dist/client/assets/chunk-727SXJPM-DdWH2cfs.js +206 -0
- package/dist/client/assets/chunk-AQP2D5EJ-D8o8QwFY.js +231 -0
- package/dist/client/assets/{chunk-LIHQZDEY-DtYrHuCi.js → chunk-BR22UD5L-CT6fcRkN.js} +1 -1
- package/dist/client/assets/{chunk-BSJP7CBP-D2KkrA_B.js → chunk-BSJP7CBP-COmh28sk.js} +1 -1
- package/dist/client/assets/chunk-CSCIHK7Q-D0bHjxCO.js +123 -0
- package/dist/client/assets/chunk-FHYWG6QK-Ce318laP.js +1 -0
- package/dist/client/assets/{chunk-FMBD7UC4-qQT7MtX2.js → chunk-FMBD7UC4-CM39cCCr.js} +1 -1
- package/dist/client/assets/chunk-KSCS5N6A-Bk33m7yK.js +10 -0
- package/dist/client/assets/{chunk-ZZ45TVLE-DGIhE_ST.js → chunk-L5ZTLDWV-J2sQu4Os.js} +1 -1
- package/dist/client/assets/chunk-LZXEDZCA-CTmBbzaL.js +2 -0
- package/dist/client/assets/chunk-MMN3DZ5N-pTRxhVYl.js +35 -0
- package/dist/client/assets/chunk-MPE355IW-C_vkbqLj.js +1 -0
- package/dist/client/assets/chunk-MZUSXYTE-BnVcgphH.js +1 -0
- package/dist/client/assets/chunk-N66VUXT2-B6CG-CnY.js +1 -0
- package/dist/client/assets/{chunk-YZCP3GAM-D1jf1WUI.js → chunk-ND2GUHAM-D-_vkA5V.js} +1 -1
- package/dist/client/assets/chunk-NNHCCRGN-DlpIbxXb.js +159 -0
- package/dist/client/assets/{chunk-X2U36JSP-D3OEPG7k.js → chunk-NZK2D7GU-Dc42C0Jt.js} +1 -1
- package/dist/client/assets/{chunk-U2HBQHQK-BBXgsocS.js → chunk-O5CBEL6O-DdEDfb8z.js} +4 -4
- package/dist/client/assets/chunk-PUPMXCY4-BZ88kQjK.js +1 -0
- package/dist/client/assets/chunk-QZHKN3VN-D5YLQvjj.js +1 -0
- package/dist/client/assets/{chunk-SRAX5OIU-yDw8XRsi.js → chunk-SRAX5OIU-CiRgnkYo.js} +1 -1
- package/dist/client/assets/chunk-UIBZB4QT-r8p3pBHw.js +1 -0
- package/dist/client/assets/chunk-WCWK7LTN-DrKYkgXF.js +1 -0
- package/dist/client/assets/chunk-WU5MYG2G-Cg2iUbET.js +1 -0
- package/dist/client/assets/{chunk-XPW4576I-BUfyrOtN.js → chunk-XPW4576I-BZyvtu42.js} +1 -1
- package/dist/client/assets/{chunk-Z5NKEFVG-Vu8zBV4H.js → chunk-Z5NKEFVG-Dknufskm.js} +7 -7
- package/dist/client/assets/chunk-aKtaBQYM.js +1 -0
- package/dist/client/assets/classDiagram-4FO5ZUOK-CGWY0cfg.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CGWY0cfg.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-A8ssRFyt.js → cose-bilkent-S5V4N54A-BuQb9WEM.js} +1 -1
- package/dist/client/assets/{cs-CZ-V77HGUP7-Du3y53BB.js → cs-CZ-V77HGUP7-6BCNHMpz.js} +1 -1
- package/dist/client/assets/{cytoscape.esm-BurByw8X.js → cytoscape.esm-DelgaX4f.js} +2 -2
- package/dist/client/assets/{da-DK-I5RFNTM4-CDJtjf5s.js → da-DK-I5RFNTM4-CVeCWpi2.js} +1 -1
- package/dist/client/assets/dagre-BM42HDAG-ux5hA7G6.js +4 -0
- package/dist/client/assets/dagre-Bx709z4p.js +1 -0
- package/dist/client/assets/{de-CH-WLRDEVBV-CLV2tVw6.js → de-CH-WLRDEVBV-CV-FNCkY.js} +1 -1
- package/dist/client/assets/{de-DE-DTI4WUSC-B53J0BQ8.js → de-DE-DTI4WUSC-CV-FNCkY.js} +1 -1
- package/dist/client/assets/diagram-2AECGRRQ-Cx-EPj3F.js +43 -0
- package/dist/client/assets/{diagram-5BDNPKRD-BuK-UBuN.js → diagram-5GNKFQAL-B6qUTxVg.js} +2 -2
- package/dist/client/assets/diagram-KO2AKTUF-BedClayW.js +3 -0
- package/dist/client/assets/{diagram-TYMM5635-CT8BdT4s.js → diagram-LMA3HP47-DCwyG0i5.js} +1 -1
- package/dist/client/assets/diagram-OG6HWLK6-BZD0jSxR.js +24 -0
- package/dist/client/assets/diagram-action-icons-aa_KOv9h.js +36 -0
- package/dist/client/assets/{dist-BXiFOexW.js → dist-B-m0-H59.js} +1 -1
- package/dist/client/assets/dist-B6Q0y0J8.js +1 -0
- package/dist/client/assets/dist-BCQCG0we.js +1 -0
- package/dist/client/assets/{dist-Bz-8_JmE.js → dist-BEyxdnUD.js} +1 -1
- package/dist/client/assets/{dist-eAgBpkKv.js → dist-BYneHrvV.js} +1 -1
- package/dist/client/assets/dist-BsPHL5xw2.js +1 -0
- package/dist/client/assets/{dist-CRyP6okk.js → dist-CX-kKEdL.js} +1 -1
- package/dist/client/assets/{dist-Bp_j2hKC.js → dist-CaLooK5r.js} +1 -1
- package/dist/client/assets/{dist-CQZDuOJ9.js → dist-Cd4FT8TV.js} +1 -1
- package/dist/client/assets/{dist-CIt_ogHO.js → dist-ClWZ99Dh.js} +1 -1
- package/dist/client/assets/{dist-D8d0IGSI.js → dist-D01mg-Uh.js} +1 -1
- package/dist/client/assets/{dist-fpFkgu34.js → dist-D36UTodj.js} +1 -1
- package/dist/client/assets/{dist-bkoMCmF7.js → dist-D6YOhZ_d.js} +1 -1
- package/dist/client/assets/{dist-CH3l6nVf.js → dist-D8jTFU06.js} +1 -1
- package/dist/client/assets/dist-DGI-0uwF.js +1 -0
- package/dist/client/assets/{dist-Das5WX49.js → dist-DGO-wCq8.js} +1 -1
- package/dist/client/assets/dist-DMKYvLqD.js +1 -0
- package/dist/client/assets/{dist-8EAyH6_p.js → dist-DRQhk99i.js} +1 -1
- package/dist/client/assets/{dist-uyVGTnZh.js → dist-DScq22KK.js} +1 -1
- package/dist/client/assets/{dist-wkd-N1L5.js → dist-DbpddOpB.js} +1 -1
- package/dist/client/assets/{dist-1SMeCZhf.js → dist-Dl5uZm2T.js} +1 -1
- package/dist/client/assets/{dist-_THc9HiJ.js → dist-DvpEZjAN.js} +1 -1
- package/dist/client/assets/dist-Dw8hKOQm.js +1 -0
- package/dist/client/assets/{dist-NcJIpTJ8.js → dist-G7j-noyR.js} +1 -1
- package/dist/client/assets/dist-PItC1DRE.js +1 -0
- package/dist/client/assets/{dist-QktK6LIH.js → dist-cMoydUa-.js} +1 -1
- package/dist/client/assets/dist-cTuGB1EW.js +9 -0
- package/dist/client/assets/{dist-yy8SO13g.js → dist-efgaKpVU.js} +1 -1
- package/dist/client/assets/{dist-B7XQNod9.js → dist-nx-MGJIM.js} +1 -1
- package/dist/client/assets/{dist-DplP0BiK.js → dist-pww3cL4Q.js} +7 -7
- package/dist/client/assets/dist-uhQ-mkuh.js +2 -0
- package/dist/client/assets/{dockerfile-D8_6_FRV.js → dockerfile-BLkNEvjs.js} +1 -1
- package/dist/client/assets/drawio-editor-BM_W6Lkj.js +9 -0
- package/dist/client/assets/drawio-embed-controller-BKHnRnaj.js +1 -0
- package/dist/client/assets/drawioEditor-DBfHYCO5.js +2 -0
- package/dist/client/assets/editor-session-VueuoR_r.js +16 -0
- package/dist/client/assets/{el-GR-ZXDJ2OS4-DFmRQv0o.js → el-GR-ZXDJ2OS4-DzgGVibO.js} +1 -1
- package/dist/client/assets/{en-CMP6EMR6-D9x8hVSu.js → en-CMP6EMR6-l-4iz8RC.js} +1 -1
- package/dist/client/assets/{erDiagram-SMLLAGMA-6VFZA3Qb.js → erDiagram-TEJ5UH35-7XmGIzui.js} +2 -2
- package/dist/client/assets/{es-ES-DYQHAD43-BiGWIrBG.js → es-ES-DYQHAD43-DP98e8ox.js} +1 -1
- package/dist/client/assets/{eu-ES-QDSYU5Y3-BjwS0kZi.js → eu-ES-QDSYU5Y3-DrEfH-2N.js} +1 -1
- package/dist/client/assets/eventmodeling-FCH6USID-D-VxYsbw.js +1 -0
- package/dist/client/assets/excalidraw-editor-B3ffLqi6.css +1 -0
- package/dist/client/assets/excalidraw-editor-C6fTkMBx.js +9 -0
- package/dist/client/assets/excalidraw-embed-controller-BKx05cjZ.js +1 -0
- package/dist/client/assets/excalidraw-embed-reconciler-DGiagExg.js +1 -0
- package/dist/client/assets/{excalidraw-mermaid-stub-Df0Q2qkW.js → excalidraw-mermaid-stub-DE5FTiZB.js} +1 -1
- package/dist/client/assets/excalidraw-scene-DjODomMW.js +176 -0
- package/dist/client/assets/excalidrawEditor-DQD_lLF4.js +2 -0
- package/dist/client/assets/{export-page-Bnk-YQp-.js → export-page-D0iHYSPi.js} +4 -4
- package/dist/client/assets/exportDocument-Ct-Zvf7_.js +2 -0
- package/dist/client/assets/{fa-IR-26LZG4PM-BgANg2TD.js → fa-IR-26LZG4PM-CEwnMxEY.js} +1 -1
- package/dist/client/assets/{factor-Cz-hzBGH.js → factor-D7LVTn2l.js} +1 -1
- package/dist/client/assets/{fi-FI-6YS4KDE4-CBL5f3oN.js → fi-FI-6YS4KDE4-DPKGe_vC.js} +1 -1
- package/dist/client/assets/file-history-view-controller-CK3oHDCT.js +112 -0
- package/dist/client/assets/{flowDiagram-DWJPFMVM-DO9RH8YQ.js → flowDiagram-I6XJVG4X-DgTAG2K2.js} +6 -6
- package/dist/client/assets/{fr-FR-BRLLPTZC-CRibNSLG.js → fr-FR-BRLLPTZC-CgMmN9yd.js} +1 -1
- package/dist/client/assets/ganttDiagram-6RSMTGT7-Curra433.js +292 -0
- package/dist/client/assets/git-diff-view-controller-qorJ_Quo.js +150 -0
- package/dist/client/assets/git-panel-controller-DG8ws6B_.js +203 -0
- package/dist/client/assets/gitGraph-WXDBUCRP-CRS5XD98.js +1 -0
- package/dist/client/assets/gitGraphDiagram-PVQCEYII-DVf7-iH0.js +106 -0
- package/dist/client/assets/{gl-ES-OKUZTLYG-DEDwa_xt.js → gl-ES-OKUZTLYG-qCIGpEXP.js} +1 -1
- package/dist/client/assets/graphlib-B8gBHxth.js +1 -0
- package/dist/client/assets/{haxe-CcPA1xnA.js → haxe-DjVOVvNP.js} +1 -1
- package/dist/client/assets/{he-IL-26MGYIU7-47wxy70N.js → he-IL-26MGYIU7-_Pd-m9Sj.js} +1 -1
- package/dist/client/assets/{hi-IN-Q4ZOGTP2-bhV7c3dK.js → hi-IN-Q4ZOGTP2-B4kd5rva.js} +1 -1
- package/dist/client/assets/{hu-HU-P2OXPSN5-xG-gBMzE.js → hu-HU-P2OXPSN5-DL2sEPhQ.js} +1 -1
- package/dist/client/assets/{id-ID-2EIKXYN6-MQuYaNHo.js → id-ID-2EIKXYN6-DqXHubyc.js} +1 -1
- package/dist/client/assets/image-MLCQRF34-BT938jMR.js +1 -0
- package/dist/client/assets/index-AdGl0Mjr.js +2 -0
- package/dist/client/assets/index-V7z92VYK.css +1 -0
- package/dist/client/assets/info-J43DQDTF-CdrjkAmK.js +1 -0
- package/dist/client/assets/{infoDiagram-42DDH7IO-C77Pt7T1.js → infoDiagram-5YYISTIA-DT8NjvZp.js} +1 -1
- package/dist/client/assets/input-CXk9Zxz9.js +1 -0
- package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-Cy1fwvvg.js → ishikawaDiagram-YF4QCWOH-axeWdm72.js} +2 -2
- package/dist/client/assets/{it-IT-4CFKVXI2-v2kj-y7j.js → it-IT-4CFKVXI2-CyToZF8R.js} +1 -1
- package/dist/client/assets/{ja-JP-MAND2Z4V-BahXSQz-.js → ja-JP-MAND2Z4V-CdMMUzyq.js} +1 -1
- package/dist/client/assets/{javascript-gTK9fxz6.js → javascript-B9TABJff.js} +1 -1
- package/dist/client/assets/javascript-BRzqD9BA.js +1 -0
- package/dist/client/assets/{journeyDiagram-VCZTEJTY-CYWaI6re.js → journeyDiagram-JHISSGLW-_K7qmGID.js} +3 -3
- package/dist/client/assets/{jsx-runtime-1KUJVfx8.js → jsx-runtime-DqMcooe2.js} +1 -1
- package/dist/client/assets/{kaa-HQRTCXTJ-BF26ydFa.js → kaa-HQRTCXTJ-D6kVHP9w.js} +1 -1
- package/dist/client/assets/{kab-KAB-JKIKKTGH-CEIH0F80.js → kab-KAB-JKIKKTGH-XYCYTUmV.js} +1 -1
- package/dist/client/assets/{kanban-definition-6JOO6SKY-DY1xE7tm.js → kanban-definition-UN3LZRKU-DaPREf-3.js} +6 -6
- package/dist/client/assets/keyboard-shortcuts-Ctp9_GHy.js +1 -0
- package/dist/client/assets/{kk-KZ-HXQ63ZFC-CxWjc9Sf.js → kk-KZ-HXQ63ZFC-Du2sGLmI.js} +1 -1
- package/dist/client/assets/{km-KH-PKL3LSGX-DJlCteEp.js → km-KH-PKL3LSGX-B2OnEat4.js} +1 -1
- package/dist/client/assets/{ko-KR-KXLREZX3-B1gtI_ci.js → ko-KR-KXLREZX3-CcxALsEE.js} +1 -1
- package/dist/client/assets/{ku-TR-MJ4IER3X-Bf41y2v2.js → ku-TR-MJ4IER3X-HDyr9f4z.js} +1 -1
- package/dist/client/assets/line-CbpIuf9e.js +1 -0
- package/dist/client/assets/{linear-dsIQT_iU.js → linear-BGe2G4b5.js} +1 -1
- package/dist/client/assets/{lt-LT-H6WFQ6FJ-DA1or-Eo.js → lt-LT-H6WFQ6FJ-BzZe8pg9.js} +1 -1
- package/dist/client/assets/{lv-LV-GOCK6SJW-qa0BoYMm.js → lv-LV-GOCK6SJW-CMspwH0q.js} +1 -1
- package/dist/client/assets/main-C8f6FlSO.js +789 -0
- package/dist/client/assets/mermaid-parser.core-C4gZtCl9.js +4 -0
- package/dist/client/assets/mermaid-runtime-CX_vmg3J.js +9 -0
- package/dist/client/assets/{mindmap-definition-QFDTVHPH-DB_M5r-j.js → mindmap-definition-RKZ34NQL-DB1uitpo.js} +23 -23
- package/dist/client/assets/{mr-IN-IXVLDMEQ-DXFRgvgb.js → mr-IN-IXVLDMEQ-C6mqoMmX.js} +1 -1
- package/dist/client/assets/{my-MM-YG6MYTTD-BKDIfalJ.js → my-MM-YG6MYTTD-Q33bVx2B.js} +1 -1
- package/dist/client/assets/navigation-D173qvIt.css +1 -0
- package/dist/client/assets/{nb-NO-XGWJISD2-DbwbopH8.js → nb-NO-XGWJISD2-B1jdnBFb.js} +1 -1
- package/dist/client/assets/{nl-NL-XVDVCPNC-ChSneTSU.js → nl-NL-XVDVCPNC-DoQkA2lu.js} +1 -1
- package/dist/client/assets/{nn-NO-EMX5MJX5-Cf7ZWKWZ.js → nn-NO-EMX5MJX5-Db3tHf5b.js} +1 -1
- package/dist/client/assets/{nsis-QPGhLAeY.js → nsis-AQ_alPln.js} +1 -1
- package/dist/client/assets/{oc-FR-ROEINTVO-lM7Nl7hD.js → oc-FR-ROEINTVO-DLu-4Ze0.js} +1 -1
- package/dist/client/assets/{ordinal-Dz3y_j0K.js → ordinal-hYBb2elL.js} +1 -1
- package/dist/client/assets/{pa-IN-ZYN6SUDY-C9WNUTeR.js → pa-IN-ZYN6SUDY-XvJuMxJR.js} +1 -1
- package/dist/client/assets/packet-YPE3B663-r4oAflYS.js +1 -0
- package/dist/client/assets/percentages-5DKR754L-D_KAYeu8.js +1 -0
- package/dist/client/assets/{pica-CgGaIJly.js → pica-DjQMjoX_.js} +1 -1
- package/dist/client/assets/pie-LRSECV5Y-DkaVktH1.js +1 -0
- package/dist/client/assets/pieDiagram-4H26LBE5-CdDwk3iQ.js +30 -0
- package/dist/client/assets/{pl-PL-6VTG7PHC-DqRVepnC.js → pl-PL-6VTG7PHC-DjJq8QfA.js} +1 -1
- package/dist/client/assets/preview-diagram-utils-DnqteI9Q.js +1 -0
- package/dist/client/assets/preview-render-compiler-Dts88fM3.js +35 -0
- package/dist/client/assets/preview-render-compiler-VKNqrOZN.js +1 -0
- package/dist/client/assets/preview-render-profile-CU6rvKx3.js +23 -0
- package/dist/client/assets/preview-render-worker-CFKBP7xz.js +59 -0
- package/dist/client/assets/{pt-BR-5YFKRR5G-CopLYEA6.js → pt-BR-5YFKRR5G-Dg2lIz1V.js} +1 -1
- package/dist/client/assets/{pt-PT-GEIXXZ67-BjZ_Lphg.js → pt-PT-GEIXXZ67-COIg15TS.js} +1 -1
- package/dist/client/assets/{pug-lkTEco3G.js → pug-Ck0YjsGM.js} +1 -1
- package/dist/client/assets/quadrantDiagram-W4KKPZXB-C6n3eYzo.js +7 -0
- package/dist/client/assets/quick-switcher-controller-CVRUPEKp.js +12 -0
- package/dist/client/assets/radar-GUYGQ44K-Bjhhjq-k.js +1 -0
- package/dist/client/assets/{requirementDiagram-MS252O5E-CtUIQnWa.js → requirementDiagram-4Y6WPE33-B-sVI-jx.js} +4 -4
- package/dist/client/assets/{ro-RO-E2P6TFZI-DakDz5Xu.js → ro-RO-E2P6TFZI-CdCIa8N3.js} +1 -1
- package/dist/client/assets/{room-z2w9b96b.js → room-CpCcgtG8.js} +1 -1
- package/dist/client/assets/{ru-RU-YBIIY43T-BMvCT-XT.js → ru-RU-YBIIY43T-C5TT1jTX.js} +1 -1
- package/dist/client/assets/runtime-config-CDgeuPWN.js +1 -0
- package/dist/client/assets/runtime-paths-DvpihCEq.js +1 -0
- package/dist/client/assets/{sankeyDiagram-XADWPNL6-tcSeuifE.js → sankeyDiagram-5OEKKPKP-EY2cdbUV.js} +36 -6
- package/dist/client/assets/segmented-control-DhUkW6ro.js +1 -0
- package/dist/client/assets/sequenceDiagram-3UESZ5HK-D6h6knAb.js +162 -0
- package/dist/client/assets/{si-LK-673C2CI2-hGdH1S9E.js → si-LK-673C2CI2-f_5ZzunQ.js} +1 -1
- package/dist/client/assets/{sk-SK-CKZHQ4AP-DiRA-fj8.js → sk-SK-CKZHQ4AP-4jimlXp1.js} +1 -1
- package/dist/client/assets/{sl-SI-557H2GWM-DN94n_1-.js → sl-SI-557H2GWM-BnZ04ZfX.js} +1 -1
- package/dist/client/assets/{src-BuiVcSz-.js → src-DSz_pbBa.js} +1 -1
- package/dist/client/assets/stateDiagram-AJRCARHV-Ca8ZuIR2.js +1 -0
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-DGRDwQhE.js +1 -0
- package/dist/client/assets/subset-shared.chunk-DcaFK0zo.js +1 -0
- package/dist/client/assets/{subset-worker.chunk-kj1e3wjW.js → subset-worker.chunk-CVu8sQYq.js} +1 -1
- package/dist/client/assets/{sv-SE-XOPKKDWS-CkHUNABj.js → sv-SE-XOPKKDWS-B2uKmd06.js} +1 -1
- package/dist/client/assets/{ta-IN-XBH7DQI3-W-157oVK.js → ta-IN-XBH7DQI3-Bld4KtCz.js} +1 -1
- package/dist/client/assets/{th-TH-TOCWH3R4-BsU-Pydr.js → th-TH-TOCWH3R4-DUlvnJTX.js} +1 -1
- package/dist/client/assets/{timeline-definition-GMOUNBTQ-Bs6U53Mo.js → timeline-definition-PNZ67QCA-BAhvj49M.js} +5 -5
- package/dist/client/assets/{tr-TR-GXW6CYY5-CTddyq89.js → tr-TR-GXW6CYY5-BXTTqJlZ.js} +1 -1
- package/dist/client/assets/treeView-BLDUP644-DbX5QpdZ.js +1 -0
- package/dist/client/assets/treemap-LRROVOQU-DT4YRX1p.js +1 -0
- package/dist/client/assets/turtle-Cx3rYX2g.js +1 -0
- package/dist/client/assets/{uk-UA-IJKTNUDG-1LzXkII3.js → uk-UA-IJKTNUDG-DbQpa2ug.js} +1 -1
- package/dist/client/assets/{uz-UZ-TBZZEA4V-kqm-qcUj.js → uz-UZ-TBZZEA4V-Dt35hEMk.js} +1 -1
- package/dist/client/assets/vault-api-client-BPVNCJZC.js +1 -0
- package/dist/client/assets/vault-api-client-VAfZ8okg.js +1 -0
- package/dist/client/assets/{vault-utils-CRpy8MQz.js → vault-utils-kIbqyWPm.js} +1 -1
- package/dist/client/assets/vennDiagram-CIIHVFJN-GGrxyoPK.js +34 -0
- package/dist/client/assets/{vi-VN-MULSGNVB-C3H2AUhm.js → vi-VN-MULSGNVB-BgxNIE1N.js} +1 -1
- package/dist/client/assets/wardley-L42UT6IY-Ba5lVG9E.js +1 -0
- package/dist/client/assets/{wardleyDiagram-NUSXRM2D-C-scJfPY.js → wardleyDiagram-YWT4CUSO-BgYuJM9o.js} +61 -3
- package/dist/client/assets/{xychartDiagram-5P7HB3ND-D3nQoxhz.js → xychartDiagram-2RQKCTM6-DKA6F9sv.js} +3 -3
- package/dist/client/assets/{yjs-provider-reset-guard-DSPzcvAO.js → yjs-provider-reset-guard-BicD2Ate.js} +1 -1
- package/dist/client/assets/{zh-CN-MVX3E32U-BULPbsyl.js → zh-CN-MVX3E32U-W0nclq-N.js} +1 -1
- package/dist/client/assets/{zh-HK-JNU5RLIE-bNGmeSaW.js → zh-HK-JNU5RLIE-C2VRLD9Z.js} +1 -1
- package/dist/client/assets/{zh-TW-LENVCA6T-CQDp064P.js → zh-TW-LENVCA6T-Ci7udZjZ.js} +1 -1
- package/dist/client/drawio-editor.html +3 -3
- package/dist/client/excalidraw-editor.html +3 -3
- package/dist/client/export-document.html +4 -4
- package/dist/client/index.html +5 -5
- package/package.json +21 -21
- package/src/client/application/app-shell/comments-feature.js +108 -0
- package/src/client/application/app-shell/git-feature.js +6 -1
- package/src/client/application/app-shell/ui-feature-shell.js +7 -4
- package/src/client/application/app-shell/ui-feature-sidebar.js +11 -2
- package/src/client/application/app-shell-elements.js +2 -0
- package/src/client/application/diagram-chrome.js +708 -0
- package/src/client/application/mermaid-preview-hydrator.js +44 -524
- package/src/client/application/plantuml-preview-hydrator.js +22 -518
- package/src/client/application/preview-renderer.js +21 -5
- package/src/client/application/quick-switcher-loader.js +14 -0
- package/src/client/application/workspace-route-controller.js +25 -1
- package/src/client/bootstrap/app-shell-feature-surface.js +67 -0
- package/src/client/bootstrap/collabmd-app-shell.js +111 -356
- package/src/client/bootstrap/lazy-controller-feature.js +434 -0
- package/src/client/domain/drawio-frame-load.js +28 -0
- package/src/client/domain/hash-routes.js +16 -1
- package/src/client/domain/runtime-paths.js +7 -0
- package/src/client/drawio-editor.js +23 -10
- package/src/client/excalidraw-editor.js +66 -13
- package/src/client/infrastructure/editor-session.js +4 -0
- package/src/client/infrastructure/editor-view-adapter.js +30 -0
- package/src/client/infrastructure/runtime-config.js +17 -2
- package/src/client/infrastructure/vault-api-client.js +16 -0
- package/src/client/presentation/app-shell-template.js +29 -12
- package/src/client/presentation/bases-preview-controller.js +33 -16
- package/src/client/presentation/comment-overview-controller.js +238 -0
- package/src/client/presentation/comment-ui/comment-ui-state.js +23 -0
- package/src/client/presentation/drawio-embed-controller.js +230 -64
- package/src/client/presentation/excalidraw-embed-controller.js +51 -60
- package/src/client/presentation/file-explorer-controller.js +9 -0
- package/src/client/presentation/file-explorer-view.js +11 -1
- package/src/client/presentation/quick-switcher-controller.js +217 -21
- package/src/client/presentation/quick-switcher-text-search.js +125 -0
- package/src/client/styles/components/navigation.css +43 -8
- package/src/client/styles/components/scrollbars.css +5 -0
- package/src/client/styles/features/comment-overview.css +196 -0
- package/src/client/styles/features/comments.css +1 -0
- package/src/client/styles/features/diagram-preview.css +43 -23
- package/src/client/styles/features/quick-switcher.css +153 -15
- package/src/client/styles/layout/responsive.css +3 -2
- package/src/client/styles/layout/shell.css +6 -3
- package/src/client/styles/surfaces/excalidraw-editor.css +4 -0
- package/src/server/application/workspace-reconciliation.js +446 -0
- package/src/server/config/env.js +74 -0
- package/src/server/create-app-server.js +68 -38
- package/src/server/domain/bases/base-expression-runtime.js +183 -147
- package/src/server/domain/bases/base-index-snapshot-store.js +53 -2
- package/src/server/domain/bases/base-query-service.js +55 -38
- package/src/server/domain/collaboration/collaboration-document-store.js +6 -2
- package/src/server/domain/collaboration/collaboration-room.js +66 -2
- package/src/server/domain/comment-overview.js +108 -0
- package/src/server/domain/hosted-workspace-contract.js +18 -0
- package/src/server/domain/hosted-workspace.js +744 -0
- package/src/server/domain/ripgrep-search-service.js +365 -0
- package/src/server/domain/workspace-state.js +848 -2
- package/src/server/infrastructure/github/github-app-client.js +205 -0
- package/src/server/infrastructure/github/github-setup-flow.js +86 -0
- package/src/server/infrastructure/http/create-git-api-command-handler.js +1 -1
- package/src/server/infrastructure/http/create-hosted-api-handler.js +200 -0
- package/src/server/infrastructure/http/create-request-handler.js +23 -1
- package/src/server/infrastructure/http/create-static-handler.js +14 -1
- package/src/server/infrastructure/http/create-vault-api-command-handler.js +44 -119
- package/src/server/infrastructure/http/create-vault-api-handler.js +2 -0
- package/src/server/infrastructure/http/create-vault-api-query-handler.js +56 -35
- package/src/server/infrastructure/http/request-body.js +12 -2
- package/src/server/infrastructure/persistence/hosted-metadata-store.js +500 -0
- package/src/server/infrastructure/persistence/sidecar-store.js +53 -2
- package/src/server/infrastructure/persistence/vault-content-adapter.js +8 -8
- package/src/server/infrastructure/persistence/vault-file-store.js +64 -135
- package/src/server/infrastructure/websocket/attach-collaboration-gateway.js +49 -5
- package/src/server/infrastructure/workspace/file-system-sync-service.js +28 -411
- package/src/server/infrastructure/workspace/workspace-mutation-coordinator.js +13 -621
- package/src/server/infrastructure/workspace/workspace-state-file-system-adapter.js +37 -0
- package/dist/client/assets/_baseFor-BSErPbF2.js +0 -1
- package/dist/client/assets/architecture-YZFGNWBL-DWWrde02.js +0 -1
- package/dist/client/assets/blockDiagram-DXYQGD6D-6UN-nR8-.js +0 -132
- package/dist/client/assets/channel-XGCkuPi6.js +0 -1
- package/dist/client/assets/chunk-2KRD3SAO-CFcF2aNP.js +0 -1
- package/dist/client/assets/chunk-336JU56O-DvrrHsJT.js +0 -2
- package/dist/client/assets/chunk-426QAEUC-CEbmCgux.js +0 -1
- package/dist/client/assets/chunk-4TB4RGXK-CoouNThi.js +0 -206
- package/dist/client/assets/chunk-5FUZZQ4R-CxIIxXPy.js +0 -62
- package/dist/client/assets/chunk-5PVQY5BW-ciE7eHID.js +0 -2
- package/dist/client/assets/chunk-67CJDMHE-CW-fbgQB.js +0 -1
- package/dist/client/assets/chunk-7N4EOEYR-DbAW6XnF.js +0 -1
- package/dist/client/assets/chunk-AA7GKIK3-ClDHDAza.js +0 -1
- package/dist/client/assets/chunk-CIAEETIT-BnB8a6HR.js +0 -1
- package/dist/client/assets/chunk-ENJZ2VHE-BQj_1YA_.js +0 -10
- package/dist/client/assets/chunk-FOC6F5B3-Bw6XfKDP.js +0 -1
- package/dist/client/assets/chunk-ICPOFSXX-DqJi89rc.js +0 -122
- package/dist/client/assets/chunk-K5T4RW27-CQtjKF2g.js +0 -94
- package/dist/client/assets/chunk-KGLVRYIC-BWSPiKjp.js +0 -1
- package/dist/client/assets/chunk-ORNJ4GCN-Csga44e5.js +0 -1
- package/dist/client/assets/chunk-OYMX7WX6-DvtmCasj.js +0 -231
- package/dist/client/assets/chunk-QZHKN3VN-CHVH9_3S.js +0 -1
- package/dist/client/assets/chunk-YHkbxXgt.js +0 -1
- package/dist/client/assets/chunk-YKPWT25G-GISHuloq.js +0 -35
- package/dist/client/assets/classDiagram-6PBFFD2Q-D1KhAUL3.js +0 -1
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-BSyyJpnR.js +0 -1
- package/dist/client/assets/clone-DI0bYZ1L.js +0 -1
- package/dist/client/assets/dagre-Dn6rkrte.js +0 -1
- package/dist/client/assets/dagre-KV5264BT-COzej2en.js +0 -4
- package/dist/client/assets/diagram-G4DWMVQ6-CbswIU9X.js +0 -24
- package/dist/client/assets/diagram-MMDJMWI5-BE-yOVGX.js +0 -43
- package/dist/client/assets/dist-BCzW2jDH.js +0 -1
- package/dist/client/assets/dist-BEk5kTf_.js +0 -1
- package/dist/client/assets/dist-BOn786F3.js +0 -1
- package/dist/client/assets/dist-BwUX6zpo.js +0 -1
- package/dist/client/assets/dist-D-ixVAsS2.js +0 -1
- package/dist/client/assets/dist-DwgKARew.js +0 -2
- package/dist/client/assets/dist-GgGgSSbl.js +0 -1
- package/dist/client/assets/dist-ZuMKSK7c.js +0 -9
- package/dist/client/assets/dist-tRNsnttY.js +0 -1
- package/dist/client/assets/drawio-editor-B_Sr8Z_Z.js +0 -9
- package/dist/client/assets/drawioEditor-DBSyP3_d.js +0 -2
- package/dist/client/assets/editor-session-C1scHGLl.js +0 -16
- package/dist/client/assets/excalidraw-editor-B0XXVLHd.js +0 -9
- package/dist/client/assets/excalidraw-editor-BZCE9ydu.css +0 -1
- package/dist/client/assets/excalidraw-scene-wAbVSY1L.js +0 -176
- package/dist/client/assets/excalidrawEditor-37sk03H8.js +0 -2
- package/dist/client/assets/exportDocument-WQNApAbg.js +0 -2
- package/dist/client/assets/flatten-DjXjUsvv.js +0 -1
- package/dist/client/assets/ganttDiagram-T4ZO3ILL-B-NMvHWN.js +0 -292
- package/dist/client/assets/gitGraph-7Q5UKJZL-DWNinXu4.js +0 -1
- package/dist/client/assets/gitGraphDiagram-UUTBAWPF-B95qkCUx.js +0 -106
- package/dist/client/assets/graphlib-CAwOVCJc.js +0 -1
- package/dist/client/assets/image-J2CAS7OM-DD4DaQTs.js +0 -1
- package/dist/client/assets/index-BoKmcqkH.js +0 -2
- package/dist/client/assets/index-maPm_Kvk.css +0 -1
- package/dist/client/assets/info-OMHHGYJF-DtYG_rX0.js +0 -1
- package/dist/client/assets/isEmpty-CpfhGGBo.js +0 -1
- package/dist/client/assets/javascript-qUBHINSy.js +0 -1
- package/dist/client/assets/line-BCItEgq3.js +0 -1
- package/dist/client/assets/main-BKumyd95.js +0 -1410
- package/dist/client/assets/mermaid-parser.core-CsTVsPcD.js +0 -4
- package/dist/client/assets/mermaid-runtime-BGlnoUXY.js +0 -11
- package/dist/client/assets/navigation-Du6CLhvs.css +0 -1
- package/dist/client/assets/packet-4T2RLAQJ-CUVefhAv.js +0 -1
- package/dist/client/assets/percentages-5DKR754L-DuhOjTM2.js +0 -1
- package/dist/client/assets/pie-ZZUOXDRM-BHBJ1dLX.js +0 -1
- package/dist/client/assets/pieDiagram-DEJITSTG-BOo-WzjZ.js +0 -30
- package/dist/client/assets/preview-diagram-utils-Nqpp4FNV.js +0 -1
- package/dist/client/assets/preview-render-compiler-9SmLUP5V.js +0 -1
- package/dist/client/assets/preview-render-compiler-IUtgIlOM.js +0 -35
- package/dist/client/assets/preview-render-profile-Bf6R7v4w.js +0 -23
- package/dist/client/assets/preview-render-worker-BwQ5sPy9.js +0 -59
- package/dist/client/assets/quadrantDiagram-34T5L4WZ-2vfo0l5S.js +0 -7
- package/dist/client/assets/quick-switcher-controller-B1erSgJ1.js +0 -5
- package/dist/client/assets/radar-PYXPWWZC-2jR4qZNU.js +0 -1
- package/dist/client/assets/reduce-ChpYjEUB.js +0 -1
- package/dist/client/assets/runtime-config-BcUbZKho.js +0 -1
- package/dist/client/assets/sequenceDiagram-FGHM5R23-DtF-1Kt2.js +0 -157
- package/dist/client/assets/stateDiagram-FHFEXIEX-DKk7Sb0f.js +0 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-DJUaiADr.js +0 -1
- package/dist/client/assets/subset-shared.chunk-CWNYNLru.js +0 -1
- package/dist/client/assets/treeView-SZITEDCU-DN5dP2ol.js +0 -1
- package/dist/client/assets/treemap-W4RFUUIX-Dva7DBJR.js +0 -1
- package/dist/client/assets/turtle-BkP3ExOG.js +0 -1
- package/dist/client/assets/vault-api-client-BDKKvtOF.js +0 -1
- package/dist/client/assets/vennDiagram-DHZGUBPP-DNnIjRae.js +0 -34
- package/dist/client/assets/wardley-RL74JXVD-CDZW5uzY.js +0 -1
- /package/dist/client/assets/{apl-C1JYSI8J.js → apl-CnwPGSsG.js} +0 -0
- /package/dist/client/assets/{array-B3agRrCs.js → array-BifhSqXX.js} +0 -0
- /package/dist/client/assets/{asciiarmor-DHW75j1s.js → asciiarmor-qTkVPQu6.js} +0 -0
- /package/dist/client/assets/{asn1-CQiG40kG.js → asn1-Dr8qZg38.js} +0 -0
- /package/dist/client/assets/{asterisk-BWExh0n4.js → asterisk-Bja0s6e1.js} +0 -0
- /package/dist/client/assets/{base-h1uscjTi.js → base-CxPEiHuy.js} +0 -0
- /package/dist/client/assets/{brainfuck-CTNFyOLg.js → brainfuck-D5EjA2JK.js} +0 -0
- /package/dist/client/assets/{chunk-3PELD44J-DymL2rGq.js → chunk-3PELD44J-C625MXe_.js} +0 -0
- /package/dist/client/assets/{chunk-A66AFZZU-BFHL744F.js → chunk-A66AFZZU-BbU3ThId.js} +0 -0
- /package/dist/client/assets/{chunk-LOOWOR4L-C5BUwXgZ.js → chunk-LOOWOR4L-CGCAV5nC.js} +0 -0
- /package/dist/client/assets/{clike-BFTLRaGS.js → clike-DHH8Ad3s.js} +0 -0
- /package/dist/client/assets/{clojure-D-DYVqu7.js → clojure-BflJGmDX.js} +0 -0
- /package/dist/client/assets/{cmake-DtGL-Unu.js → cmake-CyVbuzPu.js} +0 -0
- /package/dist/client/assets/{cobol-DP4QggbL.js → cobol-B_OZ4V-R.js} +0 -0
- /package/dist/client/assets/{coffeescript-B7GZajzV.js → coffeescript-B2pKbFk8.js} +0 -0
- /package/dist/client/assets/{commonlisp-COlJYiQT.js → commonlisp-CcllspGY.js} +0 -0
- /package/dist/client/assets/{crystal-I_dE9xG-.js → crystal-M5-qzICs.js} +0 -0
- /package/dist/client/assets/{css-CmhPNxBE.js → css-CYpP4FRV.js} +0 -0
- /package/dist/client/assets/{cypher-DEGl2llJ.js → cypher-p9eYesGn.js} +0 -0
- /package/dist/client/assets/{d-BspB0dox.js → d-BhMjBjQP.js} +0 -0
- /package/dist/client/assets/{defaultLocale-B_FbTTbl.js → defaultLocale-C8Fc0cco.js} +0 -0
- /package/dist/client/assets/{diff-BWuPUsEo.js → diff-ChtP43wD.js} +0 -0
- /package/dist/client/assets/{drawio-room-1i6Nn0_Z.js → drawio-room-B3OZRHTH.js} +0 -0
- /package/dist/client/assets/{dtd-C6brJFPg.js → dtd-DTF72YNO.js} +0 -0
- /package/dist/client/assets/{dylan-Bft86ZSB.js → dylan-C6jEEEk-.js} +0 -0
- /package/dist/client/assets/{ebnf-D6ifG44A.js → ebnf-D4c0_ac3.js} +0 -0
- /package/dist/client/assets/{ecl-D9rhJ9-u.js → ecl-BSZaIHnp.js} +0 -0
- /package/dist/client/assets/{eiffel-DwxtewZF.js → eiffel-BEjRio4Q.js} +0 -0
- /package/dist/client/assets/{elm-B1TncobV.js → elm-Cshzl8qu.js} +0 -0
- /package/dist/client/assets/{erlang-BDJZNtt8.js → erlang-DaB2Rkuy.js} +0 -0
- /package/dist/client/assets/{excalidraw-mermaid-stub-DzxtBcQW.js → excalidraw-mermaid-stub-BNckbX2n.js} +0 -0
- /package/dist/client/assets/{fcl-CUXJFJn1.js → fcl-ClOhbFR7.js} +0 -0
- /package/dist/client/assets/{file-kind-DmKq2MvD.js → file-kind-BKPOIRPE.js} +0 -0
- /package/dist/client/assets/{forth-nvhcMz63.js → forth-Cezjo90N.js} +0 -0
- /package/dist/client/assets/{fortran-BZID-z10.js → fortran-Bt6PBEDR.js} +0 -0
- /package/dist/client/assets/{gas-DjQsZDGE.js → gas-BHEdbvp9.js} +0 -0
- /package/dist/client/assets/{gherkin-S0kHlzux.js → gherkin-oBAE_ms0.js} +0 -0
- /package/dist/client/assets/{groovy-Di--Vb9Z.js → groovy-BC3IOsC8.js} +0 -0
- /package/dist/client/assets/{haskell-C6qH3-aI.js → haskell-BRsoo5mP.js} +0 -0
- /package/dist/client/assets/{http-DG1Y9fpK.js → http-CLVgA2GD.js} +0 -0
- /package/dist/client/assets/{idl-B64p3NTJ.js → idl-BUZw3wgd.js} +0 -0
- /package/dist/client/assets/{image-blob-reduce.esm-D8JQdTFk.js → image-blob-reduce.esm-NzmDxm1v.js} +0 -0
- /package/dist/client/assets/{init-DtLQcSuO.js → init-D6jRqBbL.js} +0 -0
- /package/dist/client/assets/{julia-B22G9Bym.js → julia-CQfgDRfP.js} +0 -0
- /package/dist/client/assets/{katex-CXYULLWy.js → katex-C7GtLiLd.js} +0 -0
- /package/dist/client/assets/{vault-api-client-D7Ck0CvR.css → keyboard-shortcuts-D7Ck0CvR.css} +0 -0
- /package/dist/client/assets/{livescript-CkcuHqeS.js → livescript-BXxG0Yva.js} +0 -0
- /package/dist/client/assets/{lua-Cg0FqIlO.js → lua-CL1SqxuB.js} +0 -0
- /package/dist/client/assets/{mathematica-CKVhKnoY.js → mathematica-u8YMmbU0.js} +0 -0
- /package/dist/client/assets/{mbox-DANyzFJ2.js → mbox-BEMVcqjs.js} +0 -0
- /package/dist/client/assets/{mirc-BVG2S5rO.js → mirc-C9zpzAZU.js} +0 -0
- /package/dist/client/assets/{mllike-C0p7lv48.js → mllike-B45xgp2S.js} +0 -0
- /package/dist/client/assets/{modelica-vJ-Qa9jV.js → modelica-CqHI_q-D.js} +0 -0
- /package/dist/client/assets/{mscgen-vUD-SWGJ.js → mscgen-qgSLujhx.js} +0 -0
- /package/dist/client/assets/{mumps-D0KfUTSd.js → mumps-CW_TBmxz.js} +0 -0
- /package/dist/client/assets/{nginx-DkVceJrH.js → nginx-BMaDbqW3.js} +0 -0
- /package/dist/client/assets/{ntriples-BBuCIfS0.js → ntriples-d28e9m0E.js} +0 -0
- /package/dist/client/assets/{octave-BTv2CqSQ.js → octave-D2Q8cUp1.js} +0 -0
- /package/dist/client/assets/{oz-D8SjVDNU.js → oz-BwTct_5T.js} +0 -0
- /package/dist/client/assets/{pascal-T-tfhVyx.js → pascal-Dp_KdFgX.js} +0 -0
- /package/dist/client/assets/{path-DIlZIGue.js → path-BWPyau1x.js} +0 -0
- /package/dist/client/assets/{perl-BDrCkHRd.js → perl-CdEHsPfU.js} +0 -0
- /package/dist/client/assets/{pig-BEyI4fPq.js → pig-AF4Hwhju.js} +0 -0
- /package/dist/client/assets/{powershell-DtnFc6GG.js → powershell-CzG71I4L.js} +0 -0
- /package/dist/client/assets/{preload-helper-Bo9GmnuQ.js → preload-helper-kNaey6uv.js} +0 -0
- /package/dist/client/assets/{properties-DWUvbxV9.js → properties-C357ku5U.js} +0 -0
- /package/dist/client/assets/{protobuf-CQGoYyfE.js → protobuf-D1ij_kNL.js} +0 -0
- /package/dist/client/assets/{puppet-Dd-qWO3p.js → puppet-B4hC2X4m.js} +0 -0
- /package/dist/client/assets/{python-BUyhM0Ew.js → python-BqYw9LYJ.js} +0 -0
- /package/dist/client/assets/{q-Dls1OX0D.js → q-B9NhS7L_.js} +0 -0
- /package/dist/client/assets/{r-DeZ8Mdev.js → r-DADKenSm.js} +0 -0
- /package/dist/client/assets/{rough.esm-BU2knLt9.js → rough.esm-CSKSodPl.js} +0 -0
- /package/dist/client/assets/{roundRect-BzEouiv_.js → roundRect-D01gJrlt.js} +0 -0
- /package/dist/client/assets/{rpm-CjWxLM68.js → rpm-gpDK5sbt.js} +0 -0
- /package/dist/client/assets/{ruby-CB34f2Gf.js → ruby-DsYpTuWg.js} +0 -0
- /package/dist/client/assets/{runtime-config-loader-_D2KZKn-.js → runtime-config-loader-BUK56BZz.js} +0 -0
- /package/dist/client/assets/{sas-Bji4HDQq.js → sas-C2OyD2Y6.js} +0 -0
- /package/dist/client/assets/{scheme-C3elI80V.js → scheme-CyDdOh7e.js} +0 -0
- /package/dist/client/assets/{shell-DUveK2Hb.js → shell-Du5Qg9im.js} +0 -0
- /package/dist/client/assets/{sieve-2ogwMVx4.js → sieve-BAxa3IjF.js} +0 -0
- /package/dist/client/assets/{simple-mode-pOKc0mfx.js → simple-mode-DRpGK0lJ.js} +0 -0
- /package/dist/client/assets/{smalltalk-BuGhc6lW.js → smalltalk-BLp5-jwC.js} +0 -0
- /package/dist/client/assets/{solr-DTxshpm8.js → solr-BBopId9w.js} +0 -0
- /package/dist/client/assets/{sparql-vm8qNO8J.js → sparql-Dz-mlCAC.js} +0 -0
- /package/dist/client/assets/{spreadsheet-C6Vbtl9-.js → spreadsheet-CTIncYxj.js} +0 -0
- /package/dist/client/assets/{sql-GL7dVWcd.js → sql-DcCJ9jop.js} +0 -0
- /package/dist/client/assets/{stex-CEwW0Q_0.js → stex-sDrdk2BW.js} +0 -0
- /package/dist/client/assets/{stylus-D1SZIMDs.js → stylus-DLLZ8dgm.js} +0 -0
- /package/dist/client/assets/{swift-CKcKnWv9.js → swift-DKB6_1j6.js} +0 -0
- /package/dist/client/assets/{tcl-SPk7uiDB.js → tcl-BGfruO1u.js} +0 -0
- /package/dist/client/assets/{textile-C48beRus.js → textile-DWBqthVk.js} +0 -0
- /package/dist/client/assets/{tiddlywiki-CiImjFLN.js → tiddlywiki-VlUiK86J.js} +0 -0
- /package/dist/client/assets/{tiki-HkXZ4BIW.js → tiki-CxVlf5KZ.js} +0 -0
- /package/dist/client/assets/{toml-BmfpMy1_.js → toml-LvoKBwCs.js} +0 -0
- /package/dist/client/assets/{troff-BjbEOT5E.js → troff-C2dAgh7P.js} +0 -0
- /package/dist/client/assets/{ttcn-NA-V4KnY.js → ttcn-BePYh-hG.js} +0 -0
- /package/dist/client/assets/{ttcn-cfg-TPHncdGN.js → ttcn-cfg-CY0aot7Q.js} +0 -0
- /package/dist/client/assets/{vb-C19AQWqO.js → vb-BthdM_4N.js} +0 -0
- /package/dist/client/assets/{vbscript-CHJk3s95.js → vbscript-D9f6rSsU.js} +0 -0
- /package/dist/client/assets/{velocity-Ya0P4sQU.js → velocity-CqftRsjg.js} +0 -0
- /package/dist/client/assets/{verilog-DSARZZPc.js → verilog-D-x6ne0Z.js} +0 -0
- /package/dist/client/assets/{vhdl-CnYyYTpa.js → vhdl-CMrOq2q1.js} +0 -0
- /package/dist/client/assets/{webidl-DttrYZRT.js → webidl-D5jiJvOU.js} +0 -0
- /package/dist/client/assets/{xquery-CEDTd8qs.js → xquery-fj_R-kMw.js} +0 -0
- /package/dist/client/assets/{yacas-C7dxlPB0.js → yacas-CXXgtw0p.js} +0 -0
- /package/dist/client/assets/{z80-BqEfFSnA.js → z80-CL1naaMV.js} +0 -0
|
@@ -1,1410 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid-runtime-BGlnoUXY.js","./preload-helper-Bo9GmnuQ.js","./chunk-U2HBQHQK-BBXgsocS.js","./src-BuiVcSz-.js","./chunk-YHkbxXgt.js","./chunk-5PVQY5BW-ciE7eHID.js","./dist-wkd-N1L5.js","./chunk-ICPOFSXX-DqJi89rc.js","./_baseFor-BSErPbF2.js","./isEmpty-CpfhGGBo.js","./chunk-336JU56O-DvrrHsJT.js","./chunk-5FUZZQ4R-CxIIxXPy.js","./chunk-X2U36JSP-D3OEPG7k.js","./chunk-ZZ45TVLE-DGIhE_ST.js","./rough.esm-BU2knLt9.js","./chunk-ENJZ2VHE-BQj_1YA_.js","./line-BCItEgq3.js","./path-DIlZIGue.js","./array-B3agRrCs.js","./chunk-BSJP7CBP-D2KkrA_B.js","./chunk-426QAEUC-CEbmCgux.js","./chunk-XPW4576I-BUfyrOtN.js","./preview-render-compiler-9SmLUP5V.js","./preview-render-compiler-IUtgIlOM.js","./preview-render-profile-Bf6R7v4w.js","./vault-utils-CRpy8MQz.js","./file-kind-DmKq2MvD.js","./editor-session-C1scHGLl.js","./dist-QktK6LIH.js","./dist-DplP0BiK.js","./dist-Bz-8_JmE.js","./dist-D8d0IGSI.js","./dist-BXiFOexW.js","./dist-yy8SO13g.js","./dist-NcJIpTJ8.js","./dist-bkoMCmF7.js","./dist-fpFkgu34.js","./yjs-provider-reset-guard-DSPzcvAO.js","./runtime-config-BcUbZKho.js","./room-z2w9b96b.js","./quick-switcher-controller-B1erSgJ1.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-Bo9GmnuQ.js";import{a as t,i as n,n as r,r as i}from"./preview-render-profile-Bf6R7v4w.js";import{a,c as o,d as s,f as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v}from"./file-kind-DmKq2MvD.js";import{i as y,n as b,t as x}from"./vault-utils-CRpy8MQz.js";import{n as S,r as C,t as w}from"./vault-api-client-BDKKvtOF.js";import{a as T,c as ee,d as E,f as te,i as ne,l as re,m as ie,n as D,o as ae,p as O,r as oe,s as se,t as ce,u as k}from"./runtime-config-BcUbZKho.js";import{n as le,r as ue,t as A}from"./yjs-provider-reset-guard-DSPzcvAO.js";import{r as j}from"./drawio-room-1i6Nn0_Z.js";import{a as de,c as fe,d as pe,f as M,g as me,h as he,i as ge,l as _e,m as ve,n as N,o as ye,p as be,r as xe,s as Se,t as P,u as Ce}from"./preview-diagram-utils-Nqpp4FNV.js";import{l as we,n as Te,r as Ee,t as De}from"./room-z2w9b96b.js";var Oe={copy:`
|
|
3
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
4
|
-
<path d="M5.5 5.5h6.8v8h-6.8z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
5
|
-
<path d="M3.7 10.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v.7" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
6
|
-
</svg>
|
|
7
|
-
`,download:`
|
|
8
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
9
|
-
<path d="M8 2.2v7.2" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
10
|
-
<path d="M5.3 7.2 8 10l2.7-2.8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
11
|
-
<path d="M3 12.8h10" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
12
|
-
</svg>
|
|
13
|
-
`,edit:`
|
|
14
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
15
|
-
<path d="M11.8 1.8a1.5 1.5 0 0 1 2.1 2.1l-7.2 7.2-3.2.9.9-3.2z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
16
|
-
<path d="M10.7 2.9l2.4 2.4" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
17
|
-
</svg>
|
|
18
|
-
`,fit:`
|
|
19
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
20
|
-
<path d="M5.5 6.2V3H2.3M10.5 6.2V3h3.2M10.5 9.8V13h3.2M5.5 9.8V13H2.3" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
21
|
-
<path d="M5.5 6.2h5M5.5 9.8h5" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
22
|
-
</svg>
|
|
23
|
-
`,maximize:`
|
|
24
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
25
|
-
<path d="M6 2H2v4M10 2h4v4M14 10v4h-4M2 10v4h4" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
26
|
-
</svg>
|
|
27
|
-
`,refresh:`
|
|
28
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
29
|
-
<path d="M13 4.5V1.8M13 1.8h-2.7M13 11.5v2.7M13 14.2h-2.7" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
30
|
-
<path d="M12.3 4.2A5.3 5.3 0 1 0 13 11.8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
31
|
-
</svg>
|
|
32
|
-
`,restore:`
|
|
33
|
-
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
34
|
-
<path d="M6 5V2H2M10 5V2h4M10 11v3h4M6 11v3H2" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
35
|
-
<path d="M4.5 4.5h7v7h-7z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4"/>
|
|
36
|
-
</svg>
|
|
37
|
-
`};function F(e,t){if(!(e instanceof HTMLElement))return;let n=Oe[t];if(!n){e.classList.remove(`is-icon-only`),e.classList.remove(`ui-preview-action--icon-only`);return}e.classList.add(`is-icon-only`),e.classList.add(`ui-preview-action--icon-only`),e.dataset.icon=t,e.innerHTML=n.trim()}var ke=Object.freeze({htmlLabels:!1,flowchart:{defaultRenderer:`dagre-wrapper`,htmlLabels:!1,useMaxWidth:!0},class:{defaultRenderer:`dagre-wrapper`,htmlLabels:!1,useMaxWidth:!0},startOnLoad:!1,theme:`default`}),Ae=/^\s*%%\{\s*(?:init|initialize)\s*:[\s\S]*?\}%%\s*\n?/gim,je=0;function Me(e){return String(e??``).replace(/\/+$/u,``).split(`/`).filter(Boolean).pop()||``}function Ne(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Pe(){return je+=1,`mermaid-export-${je.toString(36)}`}function Fe(e){let t=Number.parseFloat(e.getAttribute(`width`)||``),n=Number.parseFloat(e.getAttribute(`height`)||``),r=(e.getAttribute(`viewBox`)||``).split(/\s+/u).map(e=>Number.parseFloat(e));return{height:Number.isFinite(n)&&n>0?n:Number.isFinite(r[3])&&r[3]>0?r[3]:800,width:Number.isFinite(t)&&t>0?t:Number.isFinite(r[2])&&r[2]>0?r[2]:1200}}function Ie(e){return new Promise((t,n)=>{let r=new Image;r.decoding=`async`,r.addEventListener(`load`,()=>t(r),{once:!0}),r.addEventListener(`error`,()=>n(Error(`Failed to load image: ${e}`)),{once:!0}),r.src=e})}async function Le(e){if(typeof e.toBlob==`function`){let t=await new Promise(t=>e.toBlob(t,`image/png`));if(t instanceof Blob)return t}return Re(e.toDataURL(`image/png`))}function Re(e){let[t=``,n=``]=String(e).split(`,`,2),r=t.match(/^data:([^;,]+)?/u)?.[1]||`application/octet-stream`;if(t.includes(`;base64`)){let e=atob(n),t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n);return new Blob([t],{type:r})}return new Blob([decodeURIComponent(n)],{type:r})}function ze(e){let t=e.cloneNode(!0);if(!(t instanceof SVGSVGElement))throw Error(`Renderer returned invalid SVG`);t.style.removeProperty(`display`),t.style.removeProperty(`margin`),t.style.removeProperty(`max-width`),t.style.removeProperty(`height`),t.style.removeProperty(`width`),t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`);let{width:n,height:r}=Fe(t);return t.setAttribute(`width`,String(Math.max(1,Math.ceil(n)))),t.setAttribute(`height`,String(Math.max(1,Math.ceil(r)))),t}function Be(e,{padding:t=16}={}){let n=ze(e);if(typeof e.getBBox!=`function`)return n;try{let r=e.getBBox();if(!r||r.width<=0||r.height<=0)return n;let i=Math.max(0,Number(t)||0),a=Math.ceil(r.width+i*2),o=Math.ceil(r.height+i*2),s=[Math.floor(r.x-i),Math.floor(r.y-i),a,o];return n.setAttribute(`viewBox`,s.join(` `)),n.setAttribute(`width`,String(a)),n.setAttribute(`height`,String(o)),n.setAttribute(`preserveAspectRatio`,`xMidYMid meet`),n}catch{return n}}function Ve({currentFilePath:e=``,diagramKind:t=`diagram`,sourceLine:n=``,targetPath:r=``}={}){let i=Me(r);if(i)return c(i)||`${t}-diagram`;let a=c(Me(e))||`document`;return t===`mermaid`&&v(e)||t===`plantuml`&&s(e)?a:n?`${a}-${t}-L${n}`:`${a}-${t}`}function He(e={}){let t=Ve(e);return{baseName:t,pngFileName:`${t}.png`,svgFileName:`${t}.svg`}}function Ue(e){return ve(ze(e))}function We(e,t={}){return ve(Be(e,t))}function Ge(e){let t=String(e??``).replace(Ae,``);if(t=`%%{init: ${JSON.stringify(ke)}}%%\n${t}`,/^\s*gantt\b/m.test(t)&&!/\btodayMarker\b/.test(t)){let e=t.split(`
|
|
38
|
-
`),n=e.findIndex(e=>/^\s*gantt\b/.test(e));n!==-1&&(e.splice(n+1,0,` todayMarker off`),t=e.join(`
|
|
39
|
-
`))}return t}async function Ke(e,t){if(!e?.initialize||!e?.run)throw Error(`Mermaid runtime is unavailable`);e.initialize(ke);let n=document.createElement(`div`);n.style.position=`fixed`,n.style.left=`-10000px`,n.style.top=`0`,n.style.width=`1200px`,n.style.visibility=`hidden`,n.style.pointerEvents=`none`,document.body.appendChild(n);try{let r=document.createElement(`div`);r.className=`mermaid mermaid-export-node`,r.id=Pe(),r.textContent=Ge(t),n.appendChild(r),await e.run({nodes:[r]});let i=r.querySelector(`svg`);if(!(i instanceof SVGSVGElement))throw Error(`Mermaid export returned no SVG`);return We(i,{padding:24})}finally{n.remove()}}async function qe(e){let t=be(e),n=await Ie(Ne(t)),r=document.createElement(`div`);r.innerHTML=t;let i=r.querySelector(`svg`),{width:a,height:o}=i?Fe(i):{height:n.naturalHeight||800,width:n.naturalWidth||1200},s=document.createElement(`canvas`);s.width=Math.max(1,Math.ceil(a)),s.height=Math.max(1,Math.ceil(o));let c=s.getContext(`2d`);if(!c)throw Error(`Canvas is unavailable`);return c.fillStyle=`#ffffff`,c.fillRect(0,0,s.width,s.height),c.drawImage(n,0,0,s.width,s.height),Le(s)}function Je(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),window.setTimeout(()=>{r.remove(),URL.revokeObjectURL(n)},3e4)}async function Ye(e){if(typeof ClipboardItem!=`function`||!navigator.clipboard?.write)throw Error(`Clipboard image copy is unavailable`);await navigator.clipboard.write([new ClipboardItem({[e.type||`image/png`]:e})])}function Xe(e){return`data-${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`}var Ze=class{constructor(e,{batchSize:t,datasetKeys:n,fetchFn:r=null,loadFileSource:i=null,filePathLabel:a,requestIdleRenderFn:o=M,cancelIdleRenderFn:s=xe,intersectionObserverFactory:c=(e,t)=>new IntersectionObserver(e,t),isNearViewportFn:l=Ce,requestAnimationFrameFn:u=e=>requestAnimationFrame(e),shellClassName:d,sourceClassName:f}){this.renderer=e,this.batchSize=t,this.datasetKeys=n,this.loadFileSource=i??this.createLegacyFileSourceLoader(r),this.filePathLabel=a,this.requestIdleRenderFn=o,this.cancelIdleRenderFn=s,this.intersectionObserverFactory=c,this.isNearViewportFn=l,this.requestAnimationFrameFn=u,this.shellClassName=d,this.sourceClassName=f,this.shellSelector=`.${d}`,this.sourceSelector=`.${f}`,this.attributeNames=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Xe(t)])),this.observer=null,this.idleId=null,this.pendingShells=[],this.hydrationInProgress=!1,this.instanceCounter=0,this.preservedShells=new Map,this.fileInflightRequests=new Map}createLegacyFileSourceLoader(e){return typeof e==`function`?async t=>{let n=await e(E(`/file?path=${encodeURIComponent(t)}`)),r=await n.json().catch(()=>({}));if(!n.ok||r?.ok===!1)throw Error(r?.error||`Failed to load ${this.filePathLabel.toLowerCase()} source`);return String(r?.content??``)}:null}destroy(){this.cancelHydration(),this.preservedShells.clear()}cancelHydration(){this.observer&&=(this.observer.disconnect(),null),this.cancelIdleRenderFn(this.idleId),this.idleId=null,this.pendingShells=[],this.hydrationInProgress=!1}cancelPendingIdleWork(){this.cancelIdleRenderFn(this.idleId),this.idleId=null}clearPreservedShells(){this.preservedShells.clear()}hasPendingWork(){return this.hydrationInProgress||this.pendingShells.length>0}preserveHydratedShellsForCommit(){this.preservedShells.clear();let e=this.renderer.previewElement;e&&Array.from(e.querySelectorAll(`${this.shellSelector}[${this.attributeNames.hydrated}="true"][${this.attributeNames.key}]`)).forEach(e=>{let t=e.dataset[this.datasetKeys.key],n=e.querySelector(this.sourceSelector)?.textContent??``,r=e.dataset[this.datasetKeys.target]??``;!t||!n&&!r||(e.isConnected&&e.remove(),this.preservedShells.set(t,{key:t,shell:e,source:n,target:r}))})}reconcileHydratedShells(){let e=this.renderer.previewElement;if(!e||this.preservedShells.size===0){this.preservedShells.clear();return}let t=!1;Array.from(e.querySelectorAll(`${this.shellSelector}[${this.attributeNames.key}]`)).forEach(e=>{let n=e.dataset[this.datasetKeys.key],r=n?this.preservedShells.get(n):null;r&&he({nextSource:e.querySelector(this.sourceSelector)?.textContent??``,nextTarget:e.dataset[this.datasetKeys.target]??``,preservedSource:r.source,preservedTarget:r.target})&&(this.syncPreservedShell(r.shell,e),e.replaceWith(r.shell),t||=r.shell.classList.contains(`is-maximized`),this.preservedShells.delete(n))}),this.preservedShells.clear(),this.handleReconcile({restoredMaximizedShell:t})}handleReconcile(){}syncPreservedShell(e,t){me(e,t,this.attributeNames.sourceLine),me(e,t,this.attributeNames.sourceLineEnd),me(e,t,this.attributeNames.key),me(e,t,this.attributeNames.target),me(e,t,this.attributeNames.label),me(e,t,this.attributeNames.sourceHash),e.classList.add(this.shellClassName),e.dataset[this.datasetKeys.hydrated]=`true`,this.removeDatasetValue(e,`queued`);let n=t.querySelector(this.sourceSelector),r=e.querySelector(this.sourceSelector);if(!r&&n&&(r=n.cloneNode(!0),e.prepend(r)),r&&n){let e=n.textContent??``;(e||!t.dataset[this.datasetKeys.target])&&(r.textContent=e),r.hidden=!0}}setupHydration(e){let t=this.renderer.previewElement,n=this.renderer.previewContainer;if(!t||!n)return 0;let r=Array.from(t.querySelectorAll(this.shellSelector));return r.length===0?0:(this.observer=this.intersectionObserverFactory(e=>{e.forEach(e=>{e.isIntersecting&&this.enqueueShell(e.target)})},{root:n,rootMargin:this.renderer.isLargeDocument?`180px 0px`:`420px 0px`}),r.forEach(e=>this.observer.observe(e)),this.requestAnimationFrameFn(()=>{e===this.renderer.activeRenderVersion&&(this.hydrateVisibleShells(),this.renderer.updateHydrationPhase())}),r.length)}hydrateVisibleShells(){let e=this.renderer.previewElement,t=this.renderer.previewContainer;if(this.renderer.hydrationPaused||!e||!t)return;let n=this.renderer.isLargeDocument?180:420;Array.from(e.querySelectorAll(this.shellSelector)).forEach(e=>{this.isNearViewportFn(e,t,n)&&this.enqueueShell(e,{prioritize:!0})})}enqueueShell(e,{prioritize:t=!1}={}){!e?.isConnected||this.isShellHydrated(e)||this.isShellQueued(e)||(e.dataset[this.datasetKeys.queued]=`true`,t?this.pendingShells.unshift(e):this.pendingShells.push(e),!this.renderer.hydrationPaused&&(this.renderer.updateHydrationPhase(),this.scheduleHydration()))}scheduleHydration(){this.renderer.hydrationPaused||this.hydrationInProgress||this.idleId!==null||(this.idleId=this.requestIdleRenderFn(()=>{this.idleId=null,this.flushHydrationQueue()},500))}async flushHydrationQueue(){if(this.renderer.hydrationPaused||this.hydrationInProgress)return;let e=[];for(;this.pendingShells.length>0&&e.length<this.batchSize;){let t=this.pendingShells.shift();!t?.isConnected||this.isShellHydrated(t)||(this.removeDatasetValue(t,`queued`),e.push(t))}if(e.length===0){this.renderer.updateHydrationPhase();return}this.hydrationInProgress=!0,this.renderer.setPhase(`hydrating`);let t;try{t=await this.prepareHydrationBatch(e)}catch(t){this.handlePrepareHydrationBatchError(e,t),this.hydrationInProgress=!1,this.renderer.updateHydrationPhase();return}for(let n of e)await this.hydrateShell(n,t);this.hydrationInProgress=!1,this.pendingShells.length>0&&this.scheduleHydration(),this.renderer.updateHydrationPhase()}async prepareHydrationBatch(){return null}handlePrepareHydrationBatchError(e,t){}async hydrateShell(){throw Error(`hydrateShell must be implemented by subclasses`)}markShellHydrated(e){e.dataset[this.datasetKeys.hydrated]=`true`,e.dataset[this.datasetKeys.instanceId]=String(++this.instanceCounter)}isShellHydrated(e){return e?.dataset?.[this.datasetKeys.hydrated]===`true`}removeDatasetValue(e,t){let n=this.datasetKeys[t];!n||!e||(e.removeAttribute?.(this.attributeNames[t]),e.dataset&&delete e.dataset[n])}isShellQueued(e){return e?.dataset?.[this.datasetKeys.queued]===`true`}async fetchSource(e){let t=String(e??``).trim();if(!t)throw Error(`Missing ${this.filePathLabel} file path`);if(this.fileInflightRequests.has(t))return this.fileInflightRequests.get(t);if(typeof this.loadFileSource!=`function`)throw Error(`Missing ${this.filePathLabel} source loader`);let n=this.loadFileSource(t).finally(()=>{this.fileInflightRequests.delete(t)});return this.fileInflightRequests.set(t,n),n}},Qe=class extends Ze{constructor(e,{fetchFn:t=null,loadFileSource:n=null}={}){super(e,{batchSize:2,datasetKeys:{hydrated:`mermaidHydrated`,instanceId:`mermaidInstanceId`,key:`mermaidKey`,label:`mermaidLabel`,queued:`mermaidQueued`,sourceHash:`mermaidSourceHash`,sourceLine:`sourceLine`,sourceLineEnd:`sourceLineEnd`,target:`mermaidTarget`},fetchFn:t,filePathLabel:`Mermaid`,loadFileSource:n,shellClassName:`mermaid-shell`,sourceClassName:`mermaid-source`}),this.renderer=e,this.currentTheme=document.documentElement?.dataset.theme===`light`?`light`:`dark`,this.loader=null,this.runtime=null,this.shellRefits=new WeakMap,this.shellResizeObservers=new WeakMap,this.resizeObservers=new Set,this.activeMaximizedShell=null,this.maximizedRoot=null}destroy(){this.cancelHydration(),this.preservedShells.clear(),this.clearActiveShell(),this.disconnectResizeObservers(),this.maximizedRoot?.remove(),this.maximizedRoot=null}cancelHydration(){super.cancelHydration();let e=this.syncActiveShell();e&&(this.restoreShellMount(e),e.classList.remove(`is-maximized`),this.clearActiveShell(),document.body.classList.remove(`mermaid-maximized-open`))}clearActiveShell(){this.activeMaximizedShell=null,this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}disconnectResizeObservers(){this.resizeObservers.forEach(e=>e.disconnect()),this.resizeObservers.clear(),this.shellResizeObservers=new WeakMap}disconnectShellResizeObserver(e){let t=this.shellResizeObservers.get(e);t&&(t.disconnect(),this.resizeObservers.delete(t),this.shellResizeObservers.delete(e))}attachShellResizeObserver(e,t,n){if(this.disconnectShellResizeObserver(e),typeof ResizeObserver!=`function`||!e?.isConnected||!(t instanceof HTMLElement))return;let r=new ResizeObserver(()=>n());r.observe(t),r.observe(e),this.shellResizeObservers.set(e,r),this.resizeObservers.add(r)}syncActiveShell(){return this.activeMaximizedShell?.isConnected&&this.activeMaximizedShell.classList.contains(`is-maximized`)?this.activeMaximizedShell:(this.clearActiveShell(),null)}ensureMaximizedRoot(){if(this.maximizedRoot?.isConnected&&this.maximizedRoot.parentElement===document.body)return this.maximizedRoot;let e=document.body.querySelector(`[data-mermaid-maximized-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.mermaidMaximizedRoot=`true`,e.className=`mermaid-maximized-root`,document.body.appendChild(e)),this.maximizedRoot=e,e}mountShellInMaximizedRoot(e){if(!e)return;let t=this.ensureMaximizedRoot();t.hidden=!1,e._mermaidRestoreParent=e.parentElement||null,e._mermaidRestoreNextSibling=e.nextSibling||null,t.appendChild(e)}restoreShellMount(e){if(!e)return;let t=e._mermaidRestoreParent,n=e._mermaidRestoreNextSibling;t?.isConnected&&(n?.parentElement===t?t.insertBefore(e,n):t.appendChild(e)),e._mermaidRestoreParent=null,e._mermaidRestoreNextSibling=null,this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}applyTheme(e){this.currentTheme=e;let t=this.runtime;t&&(this.configureMermaid(t),this.resetHydratedShells())}configureMermaid(e){e.initialize({startOnLoad:!1,flowchart:{defaultRenderer:`dagre-wrapper`,useMaxWidth:!0},class:{defaultRenderer:`dagre-wrapper`,useMaxWidth:!0},theme:this.currentTheme===`dark`?`dark`:`default`,themeVariables:this.currentTheme===`dark`?{background:`#161822`,clusterBkg:`#1a1c28`,edgeLabelBackground:`#161822`,lineColor:`#8b8ba0`,mainBkg:`#1c1e2c`,nodeBorder:`#383a50`,primaryBorderColor:`#383a50`,primaryColor:`#818cf8`,primaryTextColor:`#e2e2ea`,secondaryColor:`#1c1e2c`,tertiaryColor:`#161822`,titleColor:`#e2e2ea`}:{}})}ensureMermaid(){return this.runtime?(this.configureMermaid(this.runtime),Promise.resolve(this.runtime)):(this.loader||=e(()=>import(`./mermaid-runtime-BGlnoUXY.js`).then(e=>{let t=e?.default;if(!t)throw Error(`Mermaid runtime failed to initialize`);return this.runtime=t,this.configureMermaid(t),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]),import.meta.url).catch(e=>{throw this.loader=null,this.runtime=null,Error(e instanceof Error?e.message:`Failed to load Mermaid runtime`)}),this.loader)}handleReconcile({restoredMaximizedShell:e}){e&&document.body.classList.add(`mermaid-maximized-open`),this.syncActiveShell()}async prepareHydrationBatch(){return this.ensureMermaid()}handlePrepareHydrationBatchError(e,t){console.warn(`[preview] Mermaid runtime failed to load:`,t)}async hydrateShell(e,t){if(!t||!e?.isConnected||this.isShellHydrated(e))return;let n=e.querySelector(`.mermaid-source`);n||(n=document.createElement(`span`),n.className=`mermaid-source`,n.hidden=!0,e.appendChild(n));let r=n.textContent??``;try{if(!r.trim()&&e.dataset.mermaidTarget){if(r=await this.fetchSource(e.dataset.mermaidTarget),!e.isConnected)return;n.textContent=r}if(!r.trim())throw Error(e.dataset.mermaidTarget?`Mermaid file is empty`:`Mermaid source is empty`);r=this.prepareSource(r),e.querySelector(`.mermaid-placeholder-card`)?.remove();let i=document.createElement(`div`);i.className=`mermaid mermaid-render-node`,i.id=e.dataset.mermaidKey||`mermaid-${Date.now()}`;let a=e.getAttribute(`data-source-line`),o=e.getAttribute(`data-source-line-end`);if(a&&i.setAttribute(`data-source-line`,a),o&&i.setAttribute(`data-source-line-end`,o),i.textContent=r,e.appendChild(i),await t.run({nodes:[i]}),!i.isConnected||e!==i.parentElement)return;this.enhanceDiagram(e,i),this.markShellHydrated(e)}catch(t){console.warn(`[preview] Mermaid render failed:`,t),e.querySelector(`:scope > .mermaid-toolbar`)?.remove(),e.querySelector(`:scope > .mermaid-frame`)?.remove(),e.querySelector(`:scope > .mermaid-render-node`)?.remove(),e.querySelector(`.mermaid-placeholder-card`)||n?.after(de(e.dataset.mermaidKey||`mermaid`,{label:e.dataset.mermaidLabel||`Mermaid diagram`,message:t instanceof Error?t.message:`Render failed`}))}}prepareSource(e){let t=String(e??``);if(!/%%\{[\s\S]*?\binit\s*:/m.test(t)){let e=this.getPreviewInitConfig(t);e&&(t=`%%{init: ${JSON.stringify(e)}}%%\n${t}`)}if(!/^\s*gantt\b/m.test(t)||/\btodayMarker\b/.test(t))return t;let n=t.split(`
|
|
40
|
-
`),r=n.findIndex(e=>/^\s*gantt\b/.test(e));return r===-1?t:(n.splice(r+1,0,` todayMarker off`),n.join(`
|
|
41
|
-
`))}getPreviewInitConfig(e){return/^\s*stateDiagram(?:-v2)?\b/m.test(e)||/^\s*classDiagram\b/m.test(e)||/^\s*gantt\b/m.test(e)?{htmlLabels:!1}:null}resetHydratedShells(){let e=this.renderer.previewElement;if(!e)return;let t=Array.from(e.querySelectorAll(`.mermaid-shell[data-mermaid-hydrated="true"]`)),n=this.syncActiveShell();n&&!t.includes(n)&&t.push(n),t.length!==0&&t.forEach(e=>{this.disconnectShellResizeObserver(e),this.shellRefits.delete(e),e.removeAttribute(`data-mermaid-hydrated`),e.querySelector(`:scope > .mermaid-toolbar`)?.remove(),e.querySelector(`:scope > .mermaid-frame`)?.remove(),e.querySelector(`:scope > .mermaid-render-node`)?.remove(),e.querySelector(`.mermaid-placeholder-card`)||e.querySelector(`.mermaid-source`)?.after(ge(e.dataset.mermaidKey||`mermaid`)),this.enqueueShell(e,{prioritize:!0})})}async renderExportSvgMarkup(e){let t=await this.ensureMermaid();try{return await Ke(t,e.querySelector(`.mermaid-source`)?.textContent??``)}finally{this.configureMermaid(t)}}async copyExportImage(e,t){try{let{pngFileName:n}=t(),r=await qe(await this.renderExportSvgMarkup(e));try{await Ye(r),this.renderer.toastController?.show?.(`Diagram copied`)}catch{Je(r,n),this.renderer.toastController?.show?.(`Clipboard image copy is unavailable here. Downloaded PNG instead.`)}}catch{this.renderer.toastController?.show?.(`Failed to copy diagram`)}}async downloadExportSvg(e,t){try{let{svgFileName:n}=t();Je(new Blob([await this.renderExportSvgMarkup(e)],{type:`image/svg+xml;charset=utf-8`}),n),this.renderer.toastController?.show?.(`Diagram download started`)}catch{this.renderer.toastController?.show?.(`Failed to download diagram`)}}enhanceDiagram(e,t){let n=t.querySelector(`svg`);if(!n){t.remove();return}let r=document.createElement(`div`);r.className=`mermaid-toolbar diagram-preview-toolbar`;let i=document.createElement(`div`);i.className=`diagram-preview-toolbar-group diagram-preview-toolbar-group--zoom`;let a=document.createElement(`div`);a.className=`diagram-preview-toolbar-group diagram-preview-toolbar-group--actions`;let o=this.createZoomButton(`−`,`Zoom out`),s=this.createZoomButton(`+`,`Zoom in`),c=this.createZoomButton(``,`Reset zoom`,{icon:`fit`}),l=this.createZoomButton(``,`Copy image`,{icon:`copy`}),u=this.createZoomButton(``,`Download SVG`,{icon:`download`}),d=this.createZoomButton(``,`Maximize diagram`,{icon:`maximize`});d.classList.add(`mermaid-maximize-btn`);let f=document.createElement(`span`);f.className=`mermaid-zoom-label diagram-preview-zoom-label`,f.setAttribute(`aria-live`,`polite`),i.append(o,f,c,s),a.append(l,u,d),r.append(i,a);let p=document.createElement(`div`);p.className=`mermaid-frame diagram-preview-frame`;let{width:m,height:h}=pe(n),g=P.default,_=1,v=null,y=null,b=null,S=!1,C=0,w=!1,T=null,ee=0,E=0,te=0,ne=0;n.style.display=`block`,n.style.margin=`0 auto`,n.style.maxWidth=`none`;let re=()=>He({currentFilePath:this.renderer.getSourceFilePath?.()??``,diagramKind:`mermaid`,sourceLine:e.getAttribute(`data-source-line`)||``,targetPath:e.dataset.mermaidTarget||``}),ie=()=>{let e=fe(p);if(!Number.isFinite(m)||m<=0||e.width<=0)return P.default;let t=e.width/m;return!Number.isFinite(t)||t<=0?P.default:x(t,P.min,P.max)},D=e=>{g=x(e,P.min,P.max),n.style.width=`${m*g}px`,n.style.height=`${h*g}px`,f.textContent=`${Math.round(g*100)}%`,o.disabled=g<=P.min,s.disabled=g>=P.max;let t=fe(p),r=m*g>t.width||h*g>t.height;p.classList.toggle(`is-pannable`,r),n.style.margin=r?`0`:`0 auto`},ae=()=>({x:p.scrollLeft+p.clientWidth/2,y:p.scrollTop+p.clientHeight/2}),O=(e,t,n)=>{if(e===0)return;let r=t/e;p.scrollLeft=n.x*r-p.clientWidth/2,p.scrollTop=n.y*r-p.clientHeight/2},oe=e=>{let t=x(e,P.min,P.max),n=g;if(t===n)return;let r=ae(),i=performance.now();v&&cancelAnimationFrame(v);let a=e=>{let o=x((e-i)/P.animationDurationMs,0,1),s=Se(o),c=n+(t-n)*s;if(D(c),O(n,c,r),o<1){v=requestAnimationFrame(a);return}v=null,D(t),O(n,t,r)};v=requestAnimationFrame(a)},se=e=>{S=!0,oe(g+e)},ce=({animate:e=!1}={})=>{if(_=ie(),S=!1,C=fe(p).width,e&&Math.abs(_-g)>.001){oe(_);return}v&&=(cancelAnimationFrame(v),null),D(_),p.scrollLeft=0,p.scrollTop=0},k=({force:t=!1}={})=>{y&&cancelAnimationFrame(y),b&&cancelAnimationFrame(b),y=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>{if(b=null,y=null,!e.isConnected)return;let n=fe(p).width,r=Math.abs(n-C)>1;!t&&S||!t&&n>0&&C>0&&!r||ce()})})})};this.shellRefits.set(e,k),this.attachShellResizeObserver(e,p,()=>k()),o.addEventListener(`click`,()=>se(-P.step)),s.addEventListener(`click`,()=>se(P.step)),c.addEventListener(`click`,()=>{k({force:!0})}),l.addEventListener(`click`,()=>this.copyExportImage(e,re)),u.addEventListener(`click`,()=>this.downloadExportSvg(e,re));let le=()=>{let t=e.classList.contains(`is-maximized`);F(d,t?`restore`:`maximize`);let n=t?`Restore diagram size`:`Maximize diagram`;d.setAttribute(`aria-label`,n),d.title=n},ue=t=>{if(t){let t=this.syncActiveShell();if(t&&t!==e){this.restoreShellMount(t),t.classList.remove(`is-maximized`),this.activeMaximizedShell===t&&this.clearActiveShell(),this.shellRefits.get(t)?.();let e=t.querySelector(`.mermaid-maximize-btn`);e&&(F(e,`maximize`),e.setAttribute(`aria-label`,`Maximize diagram`),e.title=`Maximize diagram`)}this.mountShellInMaximizedRoot(e),e.classList.add(`is-maximized`),this.activeMaximizedShell=e,document.body.classList.add(`mermaid-maximized-open`),le(),k({force:!0});return}this.restoreShellMount(e),e.classList.remove(`is-maximized`),this.activeMaximizedShell===e&&this.clearActiveShell(),this.syncActiveShell()||document.body.classList.remove(`mermaid-maximized-open`),le(),k({force:!0})};le(),d.addEventListener(`click`,()=>{ue(!e.classList.contains(`is-maximized`))});let A=()=>{if(w){if(w=!1,p.classList.remove(`is-dragging`),window.removeEventListener(`pointerup`,A,!0),window.removeEventListener(`pointercancel`,A,!0),window.removeEventListener(`mouseup`,A,!0),window.removeEventListener(`touchend`,A,!0),window.removeEventListener(`touchcancel`,A,!0),window.removeEventListener(`blur`,A,!0),T!==null&&typeof p.releasePointerCapture==`function`)try{p.releasePointerCapture(T)}catch{}T=null}};p.addEventListener(`pointerdown`,e=>{if(!(e.button!==0||!p.classList.contains(`is-pannable`))){if(v&&=(cancelAnimationFrame(v),null),w=!0,T=e.pointerId,ee=e.clientX,E=e.clientY,te=p.scrollLeft,ne=p.scrollTop,p.classList.add(`is-dragging`),window.addEventListener(`pointerup`,A,!0),window.addEventListener(`pointercancel`,A,!0),window.addEventListener(`mouseup`,A,!0),window.addEventListener(`touchend`,A,!0),window.addEventListener(`touchcancel`,A,!0),window.addEventListener(`blur`,A,!0),typeof p.setPointerCapture==`function`)try{p.setPointerCapture(e.pointerId)}catch{}e.preventDefault()}}),p.addEventListener(`pointermove`,e=>{w&&(p.scrollLeft=te-(e.clientX-ee),p.scrollTop=ne-(e.clientY-E))}),p.addEventListener(`pointerup`,A),p.addEventListener(`pointercancel`,A),p.addEventListener(`lostpointercapture`,A),p.addEventListener(`mouseleave`,A),p.addEventListener(`mouseup`,A),p.addEventListener(`touchend`,A),p.addEventListener(`touchcancel`,A),p.appendChild(n);let j=e.querySelector(`.mermaid-source`);t.remove(),e.replaceChildren(),j&&(j.hidden=!0,e.appendChild(j)),e.append(r,p),k({force:!0})}scheduleActiveRefit(){let e=this.syncActiveShell();if(e){this.shellRefits.get(e)?.();return}let t=this.renderer.previewElement;t&&Array.from(t.querySelectorAll(`.mermaid-shell[data-mermaid-hydrated="true"]`)).forEach(e=>{this.shellRefits.get(e)?.()})}createZoomButton(e,t,{icon:n=``}={}){let r=document.createElement(`button`);return r.type=`button`,r.className=`mermaid-zoom-btn ui-preview-action`,r.setAttribute(`aria-label`,t),r.title=t,n?F(r,n):r.textContent=e,r}},$e=class extends Ze{constructor(e,{loadFileSource:t=null,renderClient:n=null}={}){super(e,{batchSize:2,datasetKeys:{hydrated:`plantumlHydrated`,instanceId:`plantumlInstanceId`,key:`plantumlKey`,label:`plantumlLabel`,queued:`plantumlQueued`,sourceHash:`plantumlSourceHash`,sourceLine:`sourceLine`,sourceLineEnd:`sourceLineEnd`,target:`plantumlTarget`},filePathLabel:`PlantUML`,loadFileSource:t,shellClassName:`plantuml-shell`,sourceClassName:`plantuml-source`}),this.renderer=e,this.renderClient=n,this.svgCache=new Map,this.svgInflightRequests=new Map,this.shellRefits=new WeakMap,this.shellResizeObservers=new WeakMap,this.resizeObservers=new Set,this.activeMaximizedShell=null,this.maximizedRoot=null,this.resizeFrameId=null}destroy(){this.cancelHydration(),this.preservedShells.clear(),this.clearActiveShell(),this.resizeFrameId&&=(cancelAnimationFrame(this.resizeFrameId),null),this.disconnectResizeObservers(),this.maximizedRoot?.remove(),this.maximizedRoot=null}disconnectResizeObservers(){this.resizeObservers.forEach(e=>e.disconnect()),this.resizeObservers.clear(),this.shellResizeObservers=new WeakMap}disconnectShellResizeObserver(e){let t=this.shellResizeObservers.get(e);t&&(t.disconnect(),this.resizeObservers.delete(t),this.shellResizeObservers.delete(e))}attachShellResizeObserver(e,t,n){if(this.disconnectShellResizeObserver(e),typeof ResizeObserver!=`function`||!e?.isConnected||!(t instanceof HTMLElement))return;let r=new ResizeObserver(()=>n());r.observe(t),r.observe(e),this.shellResizeObservers.set(e,r),this.resizeObservers.add(r)}clearActiveShell(){this.activeMaximizedShell=null,this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}syncActiveShell(){return this.activeMaximizedShell?.isConnected&&this.activeMaximizedShell.classList.contains(`is-maximized`)?this.activeMaximizedShell:(this.clearActiveShell(),null)}scheduleActiveRefit(){this.resizeFrameId&&cancelAnimationFrame(this.resizeFrameId),this.resizeFrameId=requestAnimationFrame(()=>{this.resizeFrameId=null;let e=this.syncActiveShell();e&&this.shellRefits.get(e)?.()})}handleReconcile({restoredMaximizedShell:e}){e&&document.body.classList.add(`plantuml-maximized-open`),this.syncActiveShell()}ensureMaximizedRoot(){if(this.maximizedRoot?.isConnected&&this.maximizedRoot.parentElement===document.body)return this.maximizedRoot;let e=document.body.querySelector(`[data-plantuml-maximized-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.plantumlMaximizedRoot=`true`,e.className=`plantuml-maximized-root`,document.body.appendChild(e)),this.maximizedRoot=e,e}mountShellInMaximizedRoot(e){if(!e)return;let t=this.ensureMaximizedRoot();t.hidden=!1,e._plantumlRestoreParent=e.parentElement||null,e._plantumlRestoreNextSibling=e.nextSibling||null,t.appendChild(e)}restoreShellMount(e){if(!e)return;let t=e._plantumlRestoreParent,n=e._plantumlRestoreNextSibling;t?.isConnected&&(n?.parentElement===t?t.insertBefore(e,n):t.appendChild(e)),e._plantumlRestoreParent=null,e._plantumlRestoreNextSibling=null,this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}async hydrateShell(e){if(!e?.isConnected||this.isShellHydrated(e))return;let t=e.querySelector(`.plantuml-source`);t||(t=document.createElement(`span`),t.className=`plantuml-source`,t.hidden=!0,e.appendChild(t)),e.querySelector(`.plantuml-placeholder-card`)?.remove();try{let n=t.textContent??``;if(!n.trim()&&e.dataset.plantumlTarget){if(n=await this.fetchSource(e.dataset.plantumlTarget),!e.isConnected)return;t.textContent=n}if(!n.trim())throw Error(e.dataset.plantumlTarget?`PlantUML file is empty`:`PlantUML source is empty`);let r=await this.fetchSvg(n);if(!e.isConnected)return;this.enhanceDiagram(e,r),this.markShellHydrated(e)}catch(n){console.warn(`[preview] PlantUML render failed:`,n),e.querySelector(`:scope > .plantuml-toolbar`)?.remove(),e.querySelector(`:scope > .plantuml-frame`)?.remove(),e.querySelector(`.plantuml-placeholder-card`)||t?.after(ye(e.dataset.plantumlKey||`plantuml`,n instanceof Error?n.message:`Render failed`))}}async fetchSvg(e){let t=e;if(this.svgCache.has(t))return this.svgCache.get(t);if(this.svgInflightRequests.has(t))return this.svgInflightRequests.get(t);let n=this.renderClient.renderSvg(e).then(e=>{let n=be(e);return this.svgCache.set(t,n),n}).finally(()=>{this.svgInflightRequests.delete(t)});return this.svgInflightRequests.set(t,n),n}resetShell(e,{clearCache:t=!1,message:n=`Renders server-side when visible`}={}){let r=e.querySelector(`.plantuml-source`)?.textContent??``;t&&r&&(this.svgCache.delete(r),this.svgInflightRequests.delete(r)),this.disconnectShellResizeObserver(e),this.shellRefits.delete(e),this.activeMaximizedShell===e&&(this.restoreShellMount(e),this.clearActiveShell()),e.removeAttribute(`data-plantuml-hydrated`),e.removeAttribute(`data-plantuml-instance-id`),e.removeAttribute(`data-plantuml-queued`),e.classList.remove(`is-maximized`),this.syncActiveShell()||document.body.classList.remove(`plantuml-maximized-open`),e.querySelector(`:scope > .plantuml-toolbar`)?.remove(),e.querySelector(`:scope > .plantuml-frame`)?.remove(),e.querySelector(`.plantuml-placeholder-card`)||e.querySelector(`.plantuml-source`)?.after(ye(e.dataset.plantumlKey||`plantuml`,n))}enhanceDiagram(e,t){let n=document.createElement(`div`);n.innerHTML=t;let r=n.querySelector(`svg`);if(!r)throw Error(`Renderer returned invalid SVG`);let i=document.createElement(`div`);i.className=`plantuml-toolbar diagram-preview-toolbar`;let a=document.createElement(`div`);a.className=`diagram-preview-toolbar-group diagram-preview-toolbar-group--zoom`;let o=document.createElement(`div`);o.className=`diagram-preview-toolbar-group diagram-preview-toolbar-group--actions`;let s=document.createElement(`div`);s.className=`plantuml-frame diagram-preview-frame`;let c=this.createToolButton(`−`,`Zoom out`),l=this.createToolButton(`+`,`Zoom in`),u=this.createToolButton(``,`Reset zoom`,{icon:`fit`}),d=this.createToolButton(``,`Copy image`,{icon:`copy`}),f=this.createToolButton(``,`Download SVG`,{icon:`download`}),p=this.createToolButton(``,`Reload diagram`,{icon:`refresh`}),m=this.createToolButton(``,`Maximize diagram`,{icon:`maximize`});m.classList.add(`plantuml-maximize-btn`);let h=document.createElement(`span`);h.className=`plantuml-zoom-label diagram-preview-zoom-label`,h.setAttribute(`aria-live`,`polite`),a.append(c,h,u,l),o.append(d,f,p,m),i.append(a,o);let{width:g,height:_}=_e(r),v=N.default,y=1,b=null,S=null,C=null,w=!1,T=0,ee=!1,E=!1,te=null,ne=0,re=0,ie=0,D=0;r.style.display=`block`,r.style.margin=`0 auto`,r.style.maxWidth=`none`;let ae=()=>Ue(r),O=()=>He({currentFilePath:this.renderer.getSourceFilePath?.()??``,diagramKind:`plantuml`,sourceLine:e.getAttribute(`data-source-line`)||``,targetPath:e.dataset.plantumlTarget||``}),oe=()=>{let e=fe(s);return!Number.isFinite(g)||g<=0||e.width<=0?N.default:x(Math.min(N.default,e.width/g),N.min,N.max)},se=e=>{v=x(e,N.min,N.max),r.style.width=`${g*v}px`,r.style.height=`${_*v}px`,h.textContent=`${Math.round(v*100)}%`,c.disabled=v<=N.min,l.disabled=v>=N.max;let t=fe(s),n=g*v>t.width||_*v>t.height;s.classList.toggle(`is-pannable`,n)},ce=()=>({x:s.scrollLeft+s.clientWidth/2,y:s.scrollTop+s.clientHeight/2}),k=(e,t,n)=>{if(e===0)return;let r=t/e;s.scrollLeft=n.x*r-s.clientWidth/2,s.scrollTop=n.y*r-s.clientHeight/2},le=e=>{let t=x(e,N.min,N.max),n=v;if(t===n)return;let r=ce(),i=performance.now();b&&cancelAnimationFrame(b);let a=e=>{let o=x((e-i)/N.animationDurationMs,0,1),s=Se(o),c=n+(t-n)*s;if(se(c),k(n,c,r),o<1){b=requestAnimationFrame(a);return}b=null,se(t),k(n,t,r)};b=requestAnimationFrame(a)},ue=e=>{w=!0,le(v+e)},A=({animate:e=!1}={})=>{if(y=oe(),w=!1,T=fe(s).width,e&&Math.abs(y-v)>.001){le(y);return}b&&=(cancelAnimationFrame(b),null),se(y),s.scrollLeft=0,s.scrollTop=0},j=({force:t=!1}={})=>{ee||=t,S&&cancelAnimationFrame(S),C&&cancelAnimationFrame(C),S=requestAnimationFrame(()=>{C=requestAnimationFrame(()=>{C=requestAnimationFrame(()=>{if(C=null,S=null,!e.isConnected)return;let t=ee;ee=!1;let n=fe(s).width,r=Math.abs(n-T)>1;!t&&w||!t&&n>0&&T>0&&!r||A()})})})};this.shellRefits.set(e,j),this.attachShellResizeObserver(e,s,()=>j()),c.addEventListener(`click`,()=>ue(-N.step)),l.addEventListener(`click`,()=>ue(N.step)),u.addEventListener(`click`,()=>{j({force:!0})}),d.addEventListener(`click`,async()=>{try{let{pngFileName:e}=O(),t=await qe(ae());try{await Ye(t),this.renderer.toastController?.show?.(`Diagram copied`)}catch{Je(t,e),this.renderer.toastController?.show?.(`Clipboard image copy is unavailable here. Downloaded PNG instead.`)}}catch{this.renderer.toastController?.show?.(`Failed to copy diagram`)}}),f.addEventListener(`click`,()=>{try{let{svgFileName:e}=O();Je(new Blob([ae()],{type:`image/svg+xml;charset=utf-8`}),e),this.renderer.toastController?.show?.(`Diagram download started`)}catch{this.renderer.toastController?.show?.(`Failed to download diagram`)}});let de=()=>{let t=e.classList.contains(`is-maximized`);F(m,t?`restore`:`maximize`);let n=t?`Restore diagram size`:`Maximize diagram`;m.setAttribute(`aria-label`,n),m.title=n},pe=t=>{if(t){let t=this.syncActiveShell();if(t&&t!==e){this.restoreShellMount(t),t.classList.remove(`is-maximized`),this.activeMaximizedShell===t&&this.clearActiveShell(),this.shellRefits.get(t)?.();let e=t.querySelector(`.plantuml-maximize-btn`);e&&(F(e,`maximize`),e.setAttribute(`aria-label`,`Maximize diagram`),e.title=`Maximize diagram`)}this.mountShellInMaximizedRoot(e),e.classList.add(`is-maximized`),this.activeMaximizedShell=e,document.body.classList.add(`plantuml-maximized-open`),de(),j({force:!0});return}this.restoreShellMount(e),e.classList.remove(`is-maximized`),this.activeMaximizedShell===e&&this.clearActiveShell(),this.syncActiveShell()||document.body.classList.remove(`plantuml-maximized-open`),de(),j({force:!0})};p.addEventListener(`click`,()=>{this.resetShell(e,{clearCache:!0,message:`Refreshing…`}),this.enqueueShell(e,{prioritize:!0})}),de(),m.addEventListener(`click`,()=>{pe(!e.classList.contains(`is-maximized`))});let M=()=>{if(E){if(E=!1,s.classList.remove(`is-dragging`),window.removeEventListener(`pointerup`,M,!0),window.removeEventListener(`pointercancel`,M,!0),window.removeEventListener(`mouseup`,M,!0),window.removeEventListener(`touchend`,M,!0),window.removeEventListener(`touchcancel`,M,!0),window.removeEventListener(`blur`,M,!0),te!==null&&typeof s.releasePointerCapture==`function`)try{s.releasePointerCapture(te)}catch{}te=null}};s.addEventListener(`pointerdown`,e=>{if(!(e.button!==0||!s.classList.contains(`is-pannable`))){if(b&&=(cancelAnimationFrame(b),null),E=!0,te=e.pointerId,ne=e.clientX,re=e.clientY,ie=s.scrollLeft,D=s.scrollTop,s.classList.add(`is-dragging`),window.addEventListener(`pointerup`,M,!0),window.addEventListener(`pointercancel`,M,!0),window.addEventListener(`mouseup`,M,!0),window.addEventListener(`touchend`,M,!0),window.addEventListener(`touchcancel`,M,!0),window.addEventListener(`blur`,M,!0),typeof s.setPointerCapture==`function`)try{s.setPointerCapture(e.pointerId)}catch{}e.preventDefault()}}),s.addEventListener(`pointermove`,e=>{E&&(s.scrollLeft=ie-(e.clientX-ne),s.scrollTop=D-(e.clientY-re))}),s.addEventListener(`pointerup`,M),s.addEventListener(`pointercancel`,M),s.addEventListener(`lostpointercapture`,M),s.addEventListener(`mouseleave`,M),s.addEventListener(`mouseup`,M),s.addEventListener(`touchend`,M),s.addEventListener(`touchcancel`,M),s.appendChild(r);let me=e.querySelector(`.plantuml-source`);e.replaceChildren(),me&&(me.hidden=!0,e.appendChild(me)),e.append(i,s),y=oe(),se(y)}createToolButton(e,t,{icon:n=``}={}){let r=document.createElement(`button`);return r.type=`button`,r.className=`plantuml-tool-btn ui-preview-action`,r.setAttribute(`aria-label`,t),r.title=t,n?F(r,n):r.textContent=e,r}};function et(){return new Worker(new URL(``+new URL(`preview-render-worker-BwQ5sPy9.js`,import.meta.url).href,``+import.meta.url),{type:`module`})}var tt=class{constructor({attachmentApiPath:t=`/api/attachment`,cancelIdleRenderFn:n=xe,compilePreviewDocumentLoader:r=()=>e(()=>import(`./preview-render-compiler-9SmLUP5V.js`),__vite__mapDeps([22,23,24,4,25,26]),import.meta.url),createWorkerFn:i=et,getFileList:a,getSourceFilePath:o=null,getWikiLinkAutoCreate:s=null,idleTimeoutMs:c=500,requestIdleRenderFn:l=M}={}){this.attachmentApiPath=t,this.cancelIdleRenderFn=n,this.compilePreviewDocumentLoader=r,this.createWorkerFn=i,this.getFileList=a,this.getSourceFilePath=o,this.getWikiLinkAutoCreate=s,this.idleTimeoutMs=c,this.requestIdleRenderFn=l,this.worker=null,this.workerDisabled=!1,this.workerJob=null,this.workerPrewarmId=null,this.handleWorkerMessage=e=>{if(!this.workerJob||e.data?.renderVersion!==this.workerJob.renderVersion)return;let t=this.workerJob;if(this.workerJob=null,e.data?.error){t.reject(Error(e.data.error));return}t.resolve({html:e.data.html,stats:e.data.stats})},this.handleWorkerError=e=>{let t=Error(e.message||`Preview worker failed`);this.workerJob&&=(this.workerJob.reject(t),null),this.reset(`Preview worker failed`,{disable:!0})}}hasPendingJob(){return this.workerJob!==null}schedulePrewarm({timeout:e=this.idleTimeoutMs}={}){this.workerDisabled||this.worker||this.workerPrewarmId!==null||(this.workerPrewarmId=this.requestIdleRenderFn(()=>{this.workerPrewarmId=null,this.ensureWorker()},e))}ensureWorker(){if(this.workerDisabled)return null;if(this.worker)return this.worker;try{return this.worker=this.createWorkerFn(),this.worker.addEventListener(`message`,this.handleWorkerMessage),this.worker.addEventListener(`error`,this.handleWorkerError),this.worker}catch{return this.workerDisabled=!0,null}}async compile(e,t,{frontmatterCollapsed:n=!1,frontmatterInteractive:r=!1}={}){if(this.ensureWorker()){this.workerJob&&this.reset(`Superseded preview render`);let i=this.ensureWorker();return new Promise((a,o)=>{this.workerJob={reject:o,renderVersion:t,resolve:a},i.postMessage({attachmentApiPath:this.attachmentApiPath,fileList:this.getFileList?.()??[],frontmatterCollapsed:n,frontmatterInteractive:r,markdownText:e,renderVersion:t,sourceFilePath:this.getSourceFilePath?.()??``,wikiLinkAutoCreate:this.getWikiLinkAutoCreate?.()??!0})})}let{compilePreviewDocument:i}=await this.compilePreviewDocumentLoader();return i({attachmentApiPath:this.attachmentApiPath,fileList:this.getFileList?.()??[],frontmatterCollapsed:n,frontmatterInteractive:r,markdownText:e,sourceFilePath:this.getSourceFilePath?.()??``,wikiLinkAutoCreate:this.getWikiLinkAutoCreate?.()??!0})}cancelWorkerJob(e){this.workerJob&&=(this.workerJob.reject(Error(e)),null)}reset(e,{disable:t=!1}={}){this.cancelWorkerJob(e),this.worker&&=(this.worker.removeEventListener(`message`,this.handleWorkerMessage),this.worker.removeEventListener(`error`,this.handleWorkerError),this.worker.terminate(),null),t&&(this.workerDisabled=!0)}destroy(e=`Preview renderer destroyed`){this.workerPrewarmId!==null&&this.cancelIdleRenderFn(this.workerPrewarmId),this.workerPrewarmId=null,this.reset(e)}},nt=class{constructor({cancelAnimationFrameFn:e=e=>cancelAnimationFrame(e),cancelIdleRenderFn:t=xe,clearTimeoutFn:n=e=>clearTimeout(e),getRenderProfileFn:i=r,idleTimeoutMs:a=500,requestAnimationFrameFn:o=e=>requestAnimationFrame(e),requestIdleRenderFn:s=M,setTimeoutFn:c=(e,t)=>setTimeout(e,t)}={}){this.cancelAnimationFrameFn=e,this.cancelIdleRenderFn=t,this.clearTimeoutFn=n,this.getRenderProfileFn=i,this.idleTimeoutMs=a,this.requestAnimationFrameFn=o,this.requestIdleRenderFn=s,this.setTimeoutFn=c,this.frameId=null,this.idleId=null,this.timeoutId=null}queue({markdownText:e,onRenderRequested:t,renderVersion:n}){let r=this.getRenderProfileFn(e);this.cancel();let i=()=>{this.frameId=this.requestAnimationFrameFn(()=>{this.frameId=null,this.timeoutId=null,t?.(e,n)})},a=()=>{if(r.deferUntilIdle){this.idleId=this.requestIdleRenderFn(()=>{this.idleId=null,i()},this.idleTimeoutMs);return}i()};this.timeoutId=this.setTimeoutFn(a,r.debounceMs)}cancel(){this.clearTimeoutFn(this.timeoutId),this.frameId&&this.cancelAnimationFrameFn(this.frameId),this.cancelIdleRenderFn(this.idleId),this.frameId=null,this.idleId=null,this.timeoutId=null}destroy(){this.cancel()}},rt=class{constructor({getContent:e,getFileList:t,getSourceFilePath:n,getWikiLinkAutoCreate:i=null,loadFileSource:a=null,onAfterRenderCommit:o,onBeforeRenderCommit:s,onPreviewLayoutChange:c,onRenderComplete:l,outlineController:u,plantUmlRenderClient:d=null,previewContainer:f,previewElement:p,toastController:m=null}){this.getContent=e,this.getFileList=t,this.getSourceFilePath=n,this.getWikiLinkAutoCreate=i,this.loadFileSource=a,this.onAfterRenderCommit=o,this.onBeforeRenderCommit=s,this.onPreviewLayoutChange=c,this.onRenderComplete=l,this.outlineController=u,this.plantUmlRenderClient=d,this.previewContainer=f,this.previewElement=p,this.toastController=m,this.renderHost=null,this.pendingRenderVersion=0,this.activeRenderVersion=0,this.readyRenderVersion=0,this.currentStats=null,this.isLargeDocument=!1,this.hydrationPaused=!1,this.frontmatterCollapsed=!1,this.handlePreviewClick=e=>{if(e.target.closest(`.frontmatter-toggle`)){e.preventDefault(),this.frontmatterCollapsed=!this.frontmatterCollapsed,this.applyFrontmatterState(),this.handleFrontmatterLayoutChange();return}let t=e.target.closest(`.mermaid-placeholder-btn`);if(t){let n=t.closest(`.mermaid-shell`);if(!n)return;e.preventDefault(),this.enqueueMermaidShell(n,{prioritize:!0});return}let n=e.target.closest(`.plantuml-placeholder-btn`);if(n){let t=n.closest(`.plantuml-shell`);if(!t)return;e.preventDefault(),this.enqueuePlantUmlShell(t,{prioritize:!0})}},this.handleWindowResize=()=>{this.mermaidHydrator.scheduleActiveRefit(),this.plantUmlHydrator.scheduleActiveRefit()},this.mermaidHydrator=new Qe(this,{loadFileSource:a}),this.plantUmlHydrator=new $e(this,{loadFileSource:a,renderClient:d}),this.renderScheduler=new nt({getRenderProfileFn:r}),this.renderExecutor=new tt({attachmentApiPath:E(`/attachment`),getFileList:()=>this.getFileList?.()??[],getSourceFilePath:()=>this.getSourceFilePath?.()??``,getWikiLinkAutoCreate:()=>this.getWikiLinkAutoCreate?.()??!0,idleTimeoutMs:500}),this.previewElement?.addEventListener(`click`,this.handlePreviewClick),window.addEventListener(`resize`,this.handleWindowResize),this.setPhase(`ready`)}ensureRenderHost(){if(!this.previewElement)return null;if(this.renderHost?.isConnected&&this.renderHost.parentElement===this.previewElement)return this.renderHost;let e=this.previewElement.querySelector(`[data-preview-render-host="true"]`);return e||(e=document.createElement(`div`),e.dataset.previewRenderHost=`true`,this.previewElement.appendChild(e)),this.renderHost=e,this.renderHost}normalizePreviewChildren(e=this.renderHost){this.previewElement&&Array.from(this.previewElement.children).forEach(t=>{t===e||t.dataset.excalidrawOverlayRoot===`true`||t.dataset.videoOverlayRoot===`true`||t.remove()})}getReservedPreviewHeight(){let e=this.renderHost?.getBoundingClientRect?.().height??0,t=this.previewContainer?.clientHeight??0;return Math.max(Math.round(e),Math.round(t),320)}beginDocumentLoad(){this.cancelScheduledRender(),this.cancelMermaidHydration(),this.cancelPlantUmlHydration(),this.mermaidHydrator.clearPreservedShells(),this.plantUmlHydrator.clearPreservedShells(),this.clearActivePlantUmlShell(),this.onBeforeRenderCommit?.(this.previewElement),this.pendingRenderVersion+=1,this.activeRenderVersion=this.pendingRenderVersion,this.readyRenderVersion=0,this.currentStats=null,this.isLargeDocument=!1,this.frontmatterCollapsed=!1,this.renderExecutor.hasPendingJob()&&this.resetWorker(`Document changed`);let e=this.ensureRenderHost();this.normalizePreviewChildren(e);let t=this.getReservedPreviewHeight();e&&(e.replaceChildren(),e.style.minHeight=`${t}px`);let n=document.createElement(`div`);n.className=`preview-shell`,n.style.minHeight=`${t}px`,n.textContent=`Rendering preview…`,e?.append(n),this.setPhase(`shell`)}applyTheme(e){let t=document.getElementById(`hljs-theme`);if(t){let{darkHref:n,lightHref:r}=t.dataset;t.href=e===`dark`?n:r}this.mermaidHydrator.applyTheme(e)}configureMermaid(e){this.mermaidHydrator.configureMermaid(e)}ensureMermaid(){return this.mermaidHydrator.ensureMermaid()}queueRender(){let e=this.getContent();this.cancelScheduledRender(),this.pendingRenderVersion+=1;let t=this.pendingRenderVersion;this.renderScheduler.queue({markdownText:e,onRenderRequested:(e,t)=>{this.render(e,t)},renderVersion:t})}async render(e=this.getContent(),t=this.pendingRenderVersion){if(this.previewElement)try{let n=await this.compilePreview(e,t);if(t!==this.pendingRenderVersion)return;this.commitBaseRender(n,t)}catch(e){if(t!==this.pendingRenderVersion)return;console.warn(`[preview] Failed to render preview:`,e)}}destroy(){this.renderScheduler.destroy(),this.mermaidHydrator.destroy(),this.plantUmlHydrator.destroy(),this.renderExecutor.destroy(),this.previewElement?.removeEventListener(`click`,this.handlePreviewClick),window.removeEventListener(`resize`,this.handleWindowResize)}setPhase(e){this.previewElement&&(this.previewElement.dataset.renderPhase=e)}cancelScheduledRender(){this.renderScheduler.cancel()}cancelMermaidHydration(){this.mermaidHydrator.cancelHydration()}cancelPlantUmlHydration(){this.plantUmlHydrator.cancelHydration()}clearActivePlantUmlShell(){this.plantUmlHydrator.clearActiveShell()}scheduleActiveMermaidRefit(){this.mermaidHydrator.scheduleActiveRefit()}syncActivePlantUmlShell(){return this.plantUmlHydrator.syncActiveShell()}scheduleActivePlantUmlRefit(){this.plantUmlHydrator.scheduleActiveRefit()}setHydrationPaused(e){if(this.hydrationPaused=!!e,this.hydrationPaused){this.mermaidHydrator.cancelPendingIdleWork(),this.plantUmlHydrator.cancelPendingIdleWork();return}this.mermaidHydrator.hydrateVisibleShells(),this.mermaidHydrator.scheduleHydration(),this.plantUmlHydrator.hydrateVisibleShells(),this.plantUmlHydrator.scheduleHydration(),this.updateHydrationPhase()}resetWorker(e,{disable:t=!1}={}){this.renderExecutor.reset(e,{disable:t})}scheduleWorkerPrewarm({timeout:e=500}={}){this.renderExecutor.schedulePrewarm({timeout:e})}async compilePreview(e,t){return this.renderExecutor.compile(e,t,{frontmatterCollapsed:this.frontmatterCollapsed,frontmatterInteractive:!0})}commitBaseRender({html:e,stats:t},n){this.activeRenderVersion=n,this.readyRenderVersion=0,this.currentStats=t,this.isLargeDocument=i(t),this.cancelMermaidHydration(),this.cancelPlantUmlHydration(),document.body.classList.remove(`mermaid-maximized-open`),document.body.classList.remove(`plantuml-maximized-open`),this.preserveHydratedMermaidsForCommit(),this.preserveHydratedPlantUmlsForCommit(),this.onBeforeRenderCommit?.(this.previewElement);let r=this.ensureRenderHost();this.normalizePreviewChildren(r),r&&(r.innerHTML=e),this.applyFrontmatterState(),this.reconcileHydratedMermaids(),this.reconcileHydratedPlantUmls(),this.setPhase(`base`),this.outlineController.refresh(),this.onAfterRenderCommit?.(this.previewElement,{...t,isLargeDocument:this.isLargeDocument,renderVersion:n});let a=this.setupMermaidHydration(n),o=this.setupPlantUmlHydration(n);a===0&&o===0&&this.notifyReady()}applyFrontmatterState(){let e=this.renderHost?.querySelector?.(`.frontmatter-block`);if(!(e instanceof HTMLElement))return;let t=this.frontmatterCollapsed,n=e.querySelector(`.frontmatter-toggle`),r=e.querySelector(`.frontmatter-summary`),i=e.querySelector(`.frontmatter-content`);e.dataset.collapsed=t?`true`:`false`,n instanceof HTMLButtonElement&&(n.setAttribute(`aria-expanded`,t?`false`:`true`),n.textContent=t?`Show`:`Hide`),r instanceof HTMLElement&&(r.hidden=!t),i instanceof HTMLElement&&(i.hidden=t)}handleFrontmatterLayoutChange(){this.outlineController.refresh(),this.onPreviewLayoutChange?.({isLargeDocument:this.isLargeDocument,renderVersion:this.activeRenderVersion,stats:this.currentStats})}preserveHydratedMermaidsForCommit(){this.mermaidHydrator.preserveHydratedShellsForCommit()}preserveHydratedPlantUmlsForCommit(){this.plantUmlHydrator.preserveHydratedShellsForCommit()}reconcileHydratedMermaids(){this.mermaidHydrator.reconcileHydratedShells()}reconcileHydratedPlantUmls(){this.plantUmlHydrator.reconcileHydratedShells()}syncPreservedMermaidShell(e,t){this.mermaidHydrator.syncPreservedShell(e,t)}syncPreservedPlantUmlShell(e,t){this.plantUmlHydrator.syncPreservedShell(e,t)}setupMermaidHydration(e){return this.mermaidHydrator.setupHydration(e)}hydrateVisibleMermaids(){this.mermaidHydrator.hydrateVisibleShells()}enqueueMermaidShell(e,{prioritize:t=!1}={}){this.mermaidHydrator.enqueueShell(e,{prioritize:t})}scheduleMermaidHydration(){this.mermaidHydrator.scheduleHydration()}async flushMermaidHydrationQueue(){await this.mermaidHydrator.flushHydrationQueue()}async hydrateMermaidShell(e,t){await this.mermaidHydrator.hydrateShell(e,t)}resetHydratedMermaids(){this.mermaidHydrator.resetHydratedShells()}setupPlantUmlHydration(e){return this.plantUmlHydrator.setupHydration(e)}hydrateVisiblePlantUmls(){this.plantUmlHydrator.hydrateVisibleShells()}enqueuePlantUmlShell(e,{prioritize:t=!1}={}){this.plantUmlHydrator.enqueueShell(e,{prioritize:t})}schedulePlantUmlHydration(){this.plantUmlHydrator.scheduleHydration()}async flushPlantUmlHydrationQueue(){await this.plantUmlHydrator.flushHydrationQueue()}async hydratePlantUmlShell(e){await this.plantUmlHydrator.hydrateShell(e)}updateHydrationPhase(){if(this.hydrationPaused&&(this.mermaidHydrator.hasPendingWork()||this.plantUmlHydrator.hasPendingWork())){this.setPhase(`base`);return}if(this.mermaidHydrator.hasPendingWork()||this.plantUmlHydrator.hasPendingWork()){this.setPhase(`hydrating`);return}this.notifyReady()}notifyReady(){this.renderHost&&(this.renderHost.style.minHeight=``),this.setPhase(`ready`),this.readyRenderVersion!==this.activeRenderVersion&&(this.readyRenderVersion=this.activeRenderVersion,this.onRenderComplete?.({isLargeDocument:this.isLargeDocument,stats:this.currentStats}))}async fetchPlantUmlSvg(e){return this.plantUmlHydrator.fetchSvg(e)}async fetchPlantUmlSource(e){return this.plantUmlHydrator.fetchSource(e)}async fetchMermaidSource(e){return this.mermaidHydrator.fetchSource(e)}resetPlantUmlShell(e,{clearCache:t=!1,message:n=`Renders server-side when visible`}={}){this.plantUmlHydrator.resetShell(e,{clearCache:t,message:n})}enhancePlantUmlDiagram(e,t){this.plantUmlHydrator.enhanceDiagram(e,t)}enhanceMermaidDiagram(e,t){this.mermaidHydrator.enhanceDiagram(e,t)}createMermaidZoomButton(e,t){return this.mermaidHydrator.createZoomButton(e,t)}createPlantUmlToolButton(e,t){return this.plantUmlHydrator.createToolButton(e,t)}};async function it(e){if(e.quickSwitcher)return e.quickSwitcher;e.quickSwitcherModulePromise||=e.loadQuickSwitcherController();let t;try{t=await e.quickSwitcherModulePromise}catch(t){throw e.quickSwitcherModulePromise=null,console.error(`[quick-switcher] Failed to load file search.`,t),e.toastController?.show?.(`Failed to load file search. Try again.`,{dismissible:!0}),t}return e.quickSwitcher||=new t({getFileList:()=>e.fileExplorer.flatFiles,onFileSelect:t=>e.handleFileSelection(t,{closeSidebarOnMobile:!0,revealInTree:!0})}),e.quickSwitcher}async function at(e){try{(await it(e)).toggle()}catch{}}var ot=class{constructor({backlinksPanel:e,clearInitialFileBootstrap:t,clearStaticPreviewDocument:n=null,closeSidebarOnMobile:r,drawioEmbed:i,elements:a,excalidrawEmbed:o,fileHistoryView:s=null,fileExplorer:c,getIsTabActive:l,getSessionLoadToken:u,gitDiffView:d,gitPanel:f,imageLightbox:p=null,lobby:m,navigation:h,previewRenderer:g,renderAvatars:_,renderPresence:v,requestPreviewRouteAnchor:y=null,resetPreviewMode:b,scrollSyncController:x,setSession:S,setSessionLoadToken:C,setSidebarTab:w,setSidebarVisibility:T,setCurrentFilePath:ee,showGitCommit:E,showGitDiff:te,showGitFileHistory:ne,showGitFilePreview:re,showGitHistory:ie,syncMainChrome:D,videoEmbed:ae,workspaceCoordinator:O,layoutController:oe}){this.backlinksPanel=e,this.clearInitialFileBootstrap=t,this.clearStaticPreviewDocument=n,this.closeSidebarOnMobile=r,this.drawioEmbed=i??{setHydrationPaused(){}},this.elements=a,this.excalidrawEmbed=o,this.fileHistoryView=s,this.fileExplorer=c,this.getIsTabActive=l,this.getSessionLoadToken=u,this.gitDiffView=d,this.gitPanel=f,this.imageLightbox=p,this.lobby=m,this.navigation=h,this.previewRenderer=g,this.renderAvatars=_,this.renderPresence=v,this.requestPreviewRouteAnchor=y,this.resetPreviewMode=b,this.scrollSyncController=x,this.setSession=S,this.setSessionLoadToken=C,this.setSidebarTab=w,this.setSidebarVisibility=T??(()=>{}),this.setCurrentFilePath=ee,this.showGitCommit=E,this.showGitDiff=te,this.showGitFileHistory=ne,this.showGitFilePreview=re,this.showGitHistory=ie,this.syncMainChrome=D,this.videoEmbed=ae,this.workspaceCoordinator=O,this.layoutController=oe,this.pendingTreeRevealPath=null}async handleHashChange(){if(!this.getIsTabActive())return;let e=this.navigation.getHashRoute();if(e.type===`empty`){this.requestPreviewRouteAnchor?.(null),this.gitPanel.setSelection(),this.showEmptyState(),this.syncMainChrome({mode:`empty`,title:`CollabMD`});return}if(e.type===`git-diff`){this.requestPreviewRouteAnchor?.(null),this.setSidebarTab(`git`),await this.showGitDiff(e);return}if(e.type===`git-file-history`){this.requestPreviewRouteAnchor?.(null),this.setSidebarTab(`files`),await this.showGitFileHistory(e);return}if(e.type===`git-file-preview`){this.requestPreviewRouteAnchor?.(null),this.setSidebarTab(`files`),await this.showGitFilePreview(e);return}if(e.type===`git-history`){this.requestPreviewRouteAnchor?.(null),this.setSidebarTab(`git`),await this.showGitHistory();return}if(e.type===`git-commit`){this.requestPreviewRouteAnchor?.(null),this.setSidebarTab(`git`),await this.showGitCommit(e);return}this.setSidebarTab(`files`),await this.openFile(e.filePath,{drawioMode:e.drawioMode||null}),this.requestPreviewRouteAnchor?.(e.anchor??null,e.filePath)}showEmptyState(){this.gitDiffView.hide(),this.fileHistoryView?.hide?.(),this.workspaceCoordinator.cleanupSession(),this.clearStaticPreviewDocument?.(),this.setSession(null),this.setSessionLoadToken(this.getSessionLoadToken()+1),this.clearInitialFileBootstrap(),this.resetPreviewMode(),this.elements.outlineToggle?.classList.remove(`hidden`),this.elements.markdownToolbar?.classList.add(`hidden`),this.setCurrentFilePath(null),this.lobby.setCurrentFile(null),this.fileExplorer.setActiveFile(null),this.elements.emptyState?.classList.remove(`hidden`),this.elements.editorPage?.classList.add(`hidden`),this.elements.diffPage?.classList.add(`hidden`),this.elements.previewContent&&(this.elements.previewContent.innerHTML=``,this.elements.previewContent.dataset.renderPhase=`ready`),this.videoEmbed?.reconcileEmbeds(this.elements.previewContent),this.resetPreviewSurface(),this.renderAvatars(),this.renderPresence(),this.backlinksPanel.clear(),this.elements.activeFileName&&(this.elements.activeFileName.textContent=`CollabMD`)}showDiffState(){this.fileHistoryView?.hide?.(),this.setSessionLoadToken(this.getSessionLoadToken()+1),this.clearInitialFileBootstrap(),this.clearStaticPreviewDocument?.(),this.workspaceCoordinator.cleanupSession(),this.setSession(null),this.resetPreviewMode(),this.layoutController.reset(),this.setCurrentFilePath(null),this.lobby.setCurrentFile(null),this.fileExplorer.setActiveFile(null),this.elements.emptyState?.classList.add(`hidden`),this.elements.editorPage?.classList.add(`hidden`),this.elements.diffPage?.classList.remove(`hidden`),this.elements.previewContent&&(this.elements.previewContent.innerHTML=``,this.elements.previewContent.dataset.renderPhase=`ready`),this.videoEmbed?.reconcileEmbeds(this.elements.previewContent),this.resetPreviewSurface(),this.elements.outlineToggle?.classList.add(`hidden`),this.elements.markdownToolbar?.classList.add(`hidden`),this.renderAvatars(),this.renderPresence(),this.backlinksPanel.clear()}showFileHistoryState(e){this.gitDiffView.hide(),this.setSessionLoadToken(this.getSessionLoadToken()+1),this.clearInitialFileBootstrap(),this.clearStaticPreviewDocument?.(),this.workspaceCoordinator.cleanupSession(),this.setSession(null),this.resetPreviewMode(),this.layoutController.reset(),this.setCurrentFilePath(e),this.lobby.setCurrentFile(null),this.fileExplorer.setActiveFile(e),this.elements.emptyState?.classList.add(`hidden`),this.elements.editorPage?.classList.add(`hidden`),this.elements.diffPage?.classList.remove(`hidden`),this.elements.previewContent&&(this.elements.previewContent.innerHTML=``,this.elements.previewContent.dataset.renderPhase=`ready`),this.videoEmbed?.reconcileEmbeds(this.elements.previewContent),this.resetPreviewSurface(),this.elements.outlineToggle?.classList.add(`hidden`),this.elements.markdownToolbar?.classList.add(`hidden`),this.renderAvatars(),this.renderPresence(),this.backlinksPanel.clear()}showPreviewOnlyState(e){this.gitDiffView.hide(),this.fileHistoryView?.hide?.(),this.setSessionLoadToken(this.getSessionLoadToken()+1),this.clearInitialFileBootstrap(),this.clearStaticPreviewDocument?.(),this.workspaceCoordinator.cleanupSession(),this.setSession(null),this.resetPreviewMode(),this.layoutController.reset(),this.setCurrentFilePath(e),this.lobby.setCurrentFile(null),this.fileExplorer.setActiveFile(e),this.elements.emptyState?.classList.add(`hidden`),this.elements.editorPage?.classList.remove(`hidden`),this.elements.diffPage?.classList.add(`hidden`),this.elements.previewContent&&(this.elements.previewContent.innerHTML=``,this.elements.previewContent.dataset.renderPhase=`ready`),this.videoEmbed?.reconcileEmbeds(this.elements.previewContent),this.resetPreviewSurface(),this.elements.markdownToolbar?.classList.add(`hidden`),this.renderAvatars(),this.renderPresence(),this.backlinksPanel.clear()}async openFile(e,t={}){let n=this.pendingTreeRevealPath===e;n&&(this.pendingTreeRevealPath=null),this.imageLightbox?.close?.(),this.gitPanel.setSelection(),this.gitDiffView.hide(),this.fileHistoryView?.hide?.(),this.clearStaticPreviewDocument?.(),this.syncMainChrome({mode:`editor`}),await this.workspaceCoordinator.openFile(e,t),this.setSession(this.workspaceCoordinator.getSession()),n&&this.revealFileInTree(e,{clearSearch:!0})}cleanupSession(){this.workspaceCoordinator.cleanupSession(),this.setSession(this.workspaceCoordinator.getSession())}handleFileSelection(e,{closeSidebarOnMobile:t=!1,revealInTree:n=!1}={}){let r=this.navigation.getHashRoute?.()??null,i=r?.type===`file`&&r.filePath===e&&!r.drawioMode;if(n&&(this.pendingTreeRevealPath=e,i)){this.pendingTreeRevealPath=null,this.revealFileInTree(e,{clearSearch:!0});return}t&&!n&&this.closeSidebarOnMobile(),this.navigation.navigateToFile(e)}revealFileInTree(e,{clearSearch:t=!1}={}){this.setSidebarTab(`files`),this.setSidebarVisibility(!0),this.fileExplorer.revealFile?.(e,{clearSearch:t})}resetPreviewSurface(){this.imageLightbox?.close?.(),this.previewRenderer.setHydrationPaused(!1),this.drawioEmbed.setHydrationPaused(!1),this.excalidrawEmbed.setHydrationPaused(!1),this.videoEmbed?.detachForCommit(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks()}};function I(e){let t=String(e??``).trim().replace(/\\/g,`/`).replace(/^\/+/u,``).split(`/`).map(e=>e.trim()).filter(Boolean);return t.some(e=>e===`.`||e===`..`)?``:t.join(`/`)}function L(e,t){let n=I(e),r=I(t);return n?r?`${n}/${r}`:n:r}function st(e,t){return e.toLowerCase().endsWith(t.toLowerCase())?e:`${e}${t}`}function ct(e){return`# ${c(String(e??``).split(`/`).pop()||``)||`Untitled`}\n\n`}function lt(e){let t=I(e),n=l(t)?t:`${t}.base`;return{content:[`views:`,` - type: table`,` name: Table`,` order:`,` - file.name`,``].join(`
|
|
42
|
-
`),path:n}}function ut(e){let t=I(e),n=v(t)?t:`${t}.mmd`;return{content:[`flowchart TD`,` A[Start] --> B{Decide}`,` B -->|Yes| C[Ship it]`,` B -->|No| D[Revise]`,``].join(`
|
|
43
|
-
`),path:n}}function dt(e){let t=I(e),n=p(t)?t:`${t}.drawio`;return{content:[`<mxfile host="app.diagrams.net" modified="2026-01-01T00:00:00.000Z" agent="CollabMD" version="24.7.17">`,` <diagram id="page-1" name="Page-1">`,` <mxGraphModel dx="1200" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">`,` <root>`,` <mxCell id="0" />`,` <mxCell id="1" parent="0" />`,` </root>`,` </mxGraphModel>`,` </diagram>`,`</mxfile>`,``].join(`
|
|
44
|
-
`),path:n}}function ft(e){let t=I(e),n=s(t)?t:`${t}.puml`;return{content:[`@startuml`,`Alice -> Bob: Hello`,`@enduml`,``].join(`
|
|
45
|
-
`),path:n}}var pt=class{constructor({getFileList:e,navigation:t,refreshExplorer:n,toastController:r,vaultApiClient:i,wikiLinkAutoCreate:a=!0}){this.getFileList=e,this.navigation=t,this.refreshExplorer=n,this.toastController=r,this.vaultApiClient=i,this.wikiLinkAutoCreate=a}handleWikiLinkClick(e){let t=y(e,this.getFileList());if(t){this.navigation.navigateToFile(t);return}if(!this.wikiLinkAutoCreate){this.toastController.show(`Wiki-link target does not exist`);return}let n=this.normalizeNewWikiFilePath(e);if(!n){this.toastController.show(`Cannot create an empty wiki-link target`);return}this.createAndOpenFile(n,e)}normalizeNewWikiFilePath(e){let t=I(e);return t?t.endsWith(`.md`)?t:`${t}.md`:null}async createAndOpenFile(e,t){try{await this.vaultApiClient.createFile({content:ct(t||e),path:e}),await this.refreshExplorer(),this.navigation.navigateToFile(e)}catch(e){this.toastController.show(`Failed to create file: ${e.message}`)}}},mt=class{constructor({backlinksPanel:e,basesPreview:t=null,drawioEmbed:n,elements:r,excalidrawEmbed:i,getDisplayName:a,getSession:o,isDrawioFile:s,isExcalidrawFile:c,isBaseFile:u,isImageFile:d,isMermaidFile:f,isPlantUmlFile:p,layoutController:m,outlineController:h,previewRenderer:g,schedulePreviewLayoutSync:_,scrollSyncController:v,videoEmbed:y}){this.backlinksPanel=e,this.basesPreview=t??{reconcileEmbeds(){},renderStandalone(){}},this.drawioEmbed=n??{detachForCommit(){},hydrateVisibleEmbeds(){},reconcileEmbeds(){},setHydrationPaused(){},syncLayout(){},updateLocalUser(){},updateTheme(){}},this.elements=r,this.excalidrawEmbed=i,this.getDisplayName=a,this.getSession=o,this.isDrawioFile=s??(()=>!1),this.isExcalidrawFile=c??(()=>!1),this.isBaseFile=u??l,this.isImageFile=d??(()=>!1),this.isMermaidFile=f??(()=>!1),this.isPlantUmlFile=p??(()=>!1),this.layoutController=m,this.outlineController=h,this.previewRenderer=g,this.schedulePreviewLayoutSyncCallback=_,this.scrollSyncController=v,this.videoEmbed=y}createDiagramPreviewDocument(e,t=``){let n=String(t??``),r=Math.max(...n.match(/`+/g)?.map(e=>e.length)??[0]),i="`".repeat(Math.max(3,r+1));return`${i}${e}\n${n}\n${i}`}getPreviewSource(e,{drawioMode:t=null}={}){let n=this.getSession()?.getText()??``;return this.isMermaidFile(e)?this.createDiagramPreviewDocument(`mermaid`,n):this.isPlantUmlFile(e)?this.createDiagramPreviewDocument(`plantuml`,n):this.isDrawioFile(e)&&t===`text`?this.createDiagramPreviewDocument(`xml`,n):n}resetPreviewMode(){this.elements.previewContent?.classList.remove(`is-drawio-file-preview`),this.elements.previewContent?.classList.remove(`is-excalidraw-file-preview`),this.elements.previewContent?.classList.remove(`is-base-file-preview`),this.elements.previewContent?.classList.remove(`is-image-file-preview`),this.elements.previewContent?.classList.remove(`is-mermaid-file-preview`),this.elements.previewContent?.classList.remove(`is-plantuml-file-preview`)}syncFileChrome(e,{drawioMode:t=null,preferPreviewForBase:n=!1}={}){let r=this.isDrawioFile(e),i=this.isExcalidrawFile(e),o=this.isBaseFile(e),s=this.isImageFile(e),c=u(e),l=this.isMermaidFile(e),d=this.isPlantUmlFile(e),f=a(e),p=i||r&&t!==`text`;if(this.backlinksPanel.setDisplayMode?.(p?`header`:`dock`),this.elements.editorFindButton?.classList.toggle(`hidden`,!c),this.elements.markdownToolbar?.classList.toggle(`hidden`,!c),this.elements.exportMenuGroup?.classList.toggle(`hidden`,!c),this.elements.outlineToggle?.classList.toggle(`hidden`,f||s||o),this.elements.previewContent?.classList.toggle(`is-mermaid-file-preview`,l),this.elements.previewContent?.classList.toggle(`is-plantuml-file-preview`,d),r&&t!==`text`||i||s||o&&n){this.layoutController.setView(`preview`,{persist:!1}),this.outlineController.close(),this.backlinksPanel.clear();return}(l||d)&&(this.outlineController.close(),this.backlinksPanel.clear())}renderExcalidrawFilePreview(e){let t=this.elements.previewContent;if(!t)return;this.videoEmbed?.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit(),this.resetPreviewMode(),t.classList.add(`is-excalidraw-file-preview`);let n=this.previewRenderer.ensureRenderHost();this.previewRenderer.normalizePreviewChildren(n);let r=document.createElement(`div`);r.className=`excalidraw-embed-placeholder`,r.dataset.embedKey=`${e}#file-preview`,r.dataset.embedLabel=this.getDisplayName(e),r.dataset.embedTarget=e;let i=document.createElement(`div`);i.className=`preview-shell`,i.textContent=`Loading Excalidraw preview…`,r.appendChild(i),n&&(n.replaceChildren(r),n.style.minHeight=``),t.dataset.renderPhase=`ready`,this.outlineController.refresh(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.videoEmbed?.reconcileEmbeds(t),this.drawioEmbed.reconcileEmbeds(t),this.excalidrawEmbed.reconcileEmbeds(t,{isLargeDocument:!1}),this.drawioEmbed.hydrateVisibleEmbeds(),this.excalidrawEmbed.hydrateVisibleEmbeds(),this.schedulePreviewLayoutSyncCallback({delayMs:0})}renderDrawioFilePreview(e){let t=this.elements.previewContent;if(!t)return;this.videoEmbed?.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit(),this.resetPreviewMode(),t.classList.add(`is-drawio-file-preview`);let n=this.previewRenderer.ensureRenderHost();this.previewRenderer.normalizePreviewChildren(n);let r=document.createElement(`div`);r.className=`drawio-embed-placeholder`,r.dataset.drawioKey=`${e}#file-preview`,r.dataset.drawioLabel=this.getDisplayName(e),r.dataset.drawioMode=`edit`,r.dataset.drawioTarget=e;let i=document.createElement(`div`);i.className=`preview-shell`,i.textContent=`Loading draw.io preview…`,r.appendChild(i),n&&(n.replaceChildren(r),n.style.minHeight=``),t.dataset.renderPhase=`ready`,this.outlineController.refresh(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.videoEmbed?.reconcileEmbeds(t),this.drawioEmbed.reconcileEmbeds(t),this.drawioEmbed.hydrateVisibleEmbeds(),this.schedulePreviewLayoutSyncCallback({delayMs:0})}renderImageFilePreview(e){let t=this.elements.previewContent;if(!t)return;this.videoEmbed?.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit(),this.resetPreviewMode(),t.classList.add(`is-image-file-preview`);let n=this.previewRenderer.ensureRenderHost();this.previewRenderer.normalizePreviewChildren(n);let r=document.createElement(`figure`);r.className=`image-file-preview-shell`;let i=document.createElement(`img`);i.className=`image-file-preview-image`,i.alt=this.getDisplayName(e),i.src=E(`/attachment?path=${encodeURIComponent(e)}`),r.appendChild(i),n&&(n.replaceChildren(r),n.style.minHeight=``),t.dataset.renderPhase=`ready`,this.outlineController.refresh(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.videoEmbed?.reconcileEmbeds(t),this.schedulePreviewLayoutSyncCallback({delayMs:0})}async renderBaseFilePreview(e,{source:t=null}={}){let n=this.elements.previewContent;if(!n)return;this.videoEmbed?.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit(),this.resetPreviewMode(),n.classList.add(`is-base-file-preview`);let r=this.previewRenderer.ensureRenderHost();this.previewRenderer.normalizePreviewChildren(r),r&&(r.replaceChildren(),r.style.minHeight=``),await this.basesPreview.renderStandalone({filePath:e,renderHost:r,source:typeof t==`string`?t:this.getSession()?.getText?.()??null}),n.dataset.renderPhase=`ready`,this.outlineController.close(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.videoEmbed?.reconcileEmbeds(n),this.schedulePreviewLayoutSyncCallback({delayMs:0})}renderTextFilePreview({content:e=``}={}){let t=this.elements.previewContent;if(!t)return;this.videoEmbed?.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit(),this.resetPreviewMode();let n=this.previewRenderer.ensureRenderHost();this.previewRenderer.normalizePreviewChildren(n);let r=document.createElement(`div`);r.className=`preview-shell`;let i=document.createElement(`pre`),a=document.createElement(`code`);a.textContent=String(e??``),i.appendChild(a),r.appendChild(i),n&&(n.replaceChildren(r),n.style.minHeight=``),t.dataset.renderPhase=`ready`,this.outlineController.close(),this.backlinksPanel.clear(),this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.videoEmbed?.reconcileEmbeds(t),this.schedulePreviewLayoutSyncCallback({delayMs:0})}createResizeHandler(e){let t=null;return()=>{clearTimeout(t),t=setTimeout(()=>{e?.(),this.schedulePreviewLayoutSyncCallback({delayMs:0})},100)}}initializePreviewLayoutObserver(e=()=>{}){if(typeof ResizeObserver!=`function`||!this.elements.previewContent)return null;let t=new ResizeObserver(()=>{e()});return t.observe(this.elements.previewContent),t}schedulePreviewLayoutSync({hydrationPaused:e,previewLayoutSyncTimer:t,setPendingPreviewLayoutSync:n,setPreviewLayoutSyncTimer:r,delayMs:i=120}){if(e){n(!0);return}clearTimeout(t),r(setTimeout(()=>{r(null);let t=!!this.getSession(),i=this.elements.previewContent?.classList?.contains?.(`is-drawio-file-preview`)??!1,a=this.elements.previewContent?.classList?.contains?.(`is-excalidraw-file-preview`)??!1;if(!(!t&&!i&&!a||!this.elements.previewContent)&&this.elements.previewContent.dataset.renderPhase!==`shell`){if(e){n(!0);return}this.previewRenderer.scheduleActiveMermaidRefit(),this.previewRenderer.scheduleActivePlantUmlRefit(),this.videoEmbed?.syncLayout(),this.drawioEmbed.syncLayout(),this.excalidrawEmbed.syncLayout(),!((i||a)&&!t)&&(this.scrollSyncController.invalidatePreviewBlocks(),this.scrollSyncController.warmPreviewBlocks({onReady:()=>{this.getSession()&&(this.scrollSyncController.realignAfterLayoutChange(),this.outlineController.scheduleActiveHeadingUpdate())}}))}},i))}handleEditorScrollActivityChange({isActive:e,pendingPreviewLayoutSync:t,previewLayoutSyncTimer:n,setHydrationPaused:r,setPendingPreviewLayoutSync:i,setPreviewLayoutSyncTimer:a}){let o=!!e;if(r(o),this.previewRenderer.setHydrationPaused(o),this.drawioEmbed.setHydrationPaused(o),this.excalidrawEmbed.setHydrationPaused(o),o){clearTimeout(n),a(null),i(!0);return}t&&(i(!1),this.schedulePreviewLayoutSync({delayMs:0,hydrationPaused:!1,previewLayoutSyncTimer:null,setPendingPreviewLayoutSync:i,setPreviewLayoutSyncTimer:a}))}},ht=class{constructor({attachEditorScroller:e,createEditorSession:t,loadEditorSessionClass:n,scrollContainerForSession:r}){this.attachEditorScroller=e,this.createEditorSession=t,this.loadEditorSessionClass=n,this.scrollContainerForSession=r}async createSession(e){let t=await this.loadEditorSessionClass();return this.createEditorSession(t,e)}attachSessionScroller(e){this.attachEditorScroller(this.scrollContainerForSession(e))}clearSessionScroller(){this.attachEditorScroller(null)}},gt=class{constructor({beginDocumentLoad:e,getDisplayName:t,loadBacklinks:n,onBeforeFileOpen:r,onRenderDrawioPreview:i,onFileOpenError:a,onFileOpenReady:o,onRenderBasePreview:s,onRenderExcalidrawPreview:c,onRenderImagePreview:l,onSyncWrapToggle:u,onUpdateActiveFile:d,onUpdateCurrentFile:f,onUpdateLobbyCurrentFile:p,onUpdateVisibleChrome:m,onViewModeReset:h,renderPresence:g,showEditorLoading:_,stateStore:v}){this.beginDocumentLoad=e??(()=>{}),this.getDisplayName=t??(e=>e),this.loadBacklinks=n??(()=>{}),this.onBeforeFileOpen=r??(()=>{}),this.onRenderDrawioPreview=i??(()=>{}),this.onFileOpenError=a??(()=>{}),this.onFileOpenReady=o??(()=>{}),this.onRenderBasePreview=s??(()=>{}),this.onRenderExcalidrawPreview=c??(()=>{}),this.onRenderImagePreview=l??(()=>{}),this.onSyncWrapToggle=u??(()=>{}),this.onUpdateActiveFile=d??(()=>{}),this.onUpdateCurrentFile=f??(()=>{}),this.onUpdateLobbyCurrentFile=p??(()=>{}),this.onUpdateVisibleChrome=m??(()=>{}),this.onViewModeReset=h??(()=>{}),this.renderPresence=g??(()=>{}),this.showEditorLoading=_??(()=>{}),this.stateStore=v}prepareForFileOpen(e,{drawioMode:t=null,resetConnectionState:n=!0}={}){return this.onViewModeReset(),this.onBeforeFileOpen(),this.stateStore.set(`connectionHelpShown`,!1),n&&this.stateStore.set(`connectionState`,{status:`connecting`,unreachable:!1}),this.stateStore.set(`currentDrawioMode`,t??null),this.stateStore.set(`currentFilePath`,e),this.onUpdateCurrentFile(e),this.onUpdateLobbyCurrentFile(e),this.onUpdateActiveFile(e),this.onUpdateVisibleChrome(e,{displayName:this.getDisplayName(e),drawioMode:t,isMarkdown:u(e)}),this.showEditorLoading(),this.beginDocumentLoad(),this.renderPresence(),{supportsBacklinks:m(e)}}markFileOpenReady(e){this.onFileOpenReady(e)}finalizeFileOpen({isBase:e=!1,isDrawio:t=!1,filePath:n,isExcalidraw:r=!1,isImage:i=!1,supportsBacklinks:a}){r&&this.onRenderExcalidrawPreview(n),(e||l(n))&&this.onRenderBasePreview(n),t&&this.onRenderDrawioPreview(n),i&&this.onRenderImagePreview(n),this.onSyncWrapToggle(),a&&this.loadBacklinks(n)}handleFileOpenError(){this.onFileOpenError()}},_t=150;function vt(e){return new Promise(t=>{setTimeout(t,e)})}var yt=class{constructor({attachEditorScroller:e,beginDocumentLoad:t,cleanupAfterSessionDestroy:n,createEditorSession:r,getDisplayName:i,getFileList:a,getLineWrappingEnabled:o,getLocalUser:s,getStoredUserName:c,getTheme:l,isBaseFile:u,isDrawioFile:d,isExcalidrawFile:f,isImageFile:p,isMermaidFile:m,isPlantUmlFile:h,isTabActive:g,loadBootstrapContent:_=null,loadEditorSessionClass:v,loadBacklinks:y,onBeforeFileOpen:b,onConnectionChange:x,onContentChange:S,onCommentsChange:C,onFileAwarenessChange:w,onFileOpenError:T,onFileOpenReady:ee,onImagePaste:E,onSelectionChange:te,onSessionAssigned:ne=null,onFileOpenMetric:re=null,onRenderBasePreview:ie,onRenderExcalidrawPreview:D,onRenderDrawioPreview:ae,onRenderImagePreview:O,onSyncWrapToggle:oe,onUpdateActiveFile:se,onUpdateCurrentFile:ce,onUpdateLobbyCurrentFile:k,onUpdateVisibleChrome:le,onViewModeReset:ue,renderPresence:A,scrollContainerForSession:j,shouldUseDrawioPreview:de=null,showEditorLoading:fe,stateStore:pe}){this.attachEditorScroller=e,this.beginDocumentLoad=t,this.cleanupAfterSessionDestroy=n,this.createEditorSession=r,this.getDisplayName=i,this.getFileList=a,this.getLineWrappingEnabled=o,this.getLocalUser=s,this.getStoredUserName=c,this.getTheme=l,this.isBaseFile=u??(()=>!1),this.isDrawioFile=d??(()=>!1),this.isExcalidrawFile=f??(()=>!1),this.isImageFile=p??(()=>!1),this.isMermaidFile=m??(()=>!1),this.isPlantUmlFile=h??(()=>!1),this.isTabActive=g,this.loadBootstrapContent=_,this.loadEditorSessionClassPort=v,this.loadBacklinks=y,this.onBeforeFileOpen=b,this.onConnectionChange=x,this.onContentChange=S,this.onCommentsChange=C,this.onFileAwarenessChange=w,this.onFileOpenError=T,this.onFileOpenReady=ee,this.onImagePaste=E,this.onSelectionChange=te,this.onSessionAssigned=ne,this.onFileOpenMetric=re,this.onRenderBasePreview=ie,this.onRenderExcalidrawPreview=D,this.onSyncWrapToggle=oe,this.onUpdateActiveFile=se,this.onUpdateCurrentFile=ce,this.onUpdateLobbyCurrentFile=k,this.onUpdateVisibleChrome=le,this.renderPresence=A,this.shouldUseDrawioPreview=de??(()=>!0),this.stateStore=pe,this.session=null,this.lifecycle=new ht({attachEditorScroller:e,createEditorSession:r,loadEditorSessionClass:()=>this.loadEditorSessionClassPort(),scrollContainerForSession:j}),this.chromeController=new gt({beginDocumentLoad:t,getDisplayName:i,loadBacklinks:y,onBeforeFileOpen:b,onRenderDrawioPreview:ae,onFileOpenError:T,onFileOpenReady:ee,onRenderBasePreview:ie,onRenderExcalidrawPreview:D,onRenderImagePreview:O,onSyncWrapToggle:oe,onUpdateActiveFile:se,onUpdateCurrentFile:ce,onUpdateLobbyCurrentFile:k,onUpdateVisibleChrome:le,onViewModeReset:ue,renderPresence:A,showEditorLoading:fe,stateStore:pe})}getSession(){return this.session}loadEditorSessionClass(){return this.loadEditorSessionClassPort()}waitForNextPaint(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(e)})})}reportFileOpenMetric(e,t,n={}){this.onFileOpenMetric?.(e,{filePath:this.stateStore.get(`currentFilePath`),loadToken:t,...n})}cleanupSession(){this.session?.destroy(),this.session=null,this.lifecycle.clearSessionScroller(),this.cleanupAfterSessionDestroy()}async openFile(e,{drawioMode:t=null}={}){if(!this.isTabActive())return;let n=t??null,r=this.stateStore.get(`currentDrawioMode`)??null,i=this.isDrawioFile(e)&&t!==`text`&&this.shouldUseDrawioPreview(e),a=this.isExcalidrawFile(e),o=this.isBaseFile(e),s=this.isImageFile(e),c=this.isMermaidFile(e),l=this.isPlantUmlFile(e);if(e===this.stateStore.get(`currentFilePath`)&&n===r&&(this.session||i||a||s)){this.onUpdateActiveFile(e),this.onUpdateLobbyCurrentFile(e);return}let u=this.stateStore.nextSessionLoadToken(),d=performance.now();this.cleanupSession();let f=this.chromeController.prepareForFileOpen(e,{drawioMode:n,resetConnectionState:!i&&!a&&!s});if(this.reportFileOpenMetric(`open_started`,u,{filePath:e}),i||a||s){if(this.onSessionAssigned?.(null),u!==this.stateStore.get(`sessionLoadToken`))return;this.chromeController.markFileOpenReady(null),this.chromeController.finalizeFileOpen({filePath:e,isBase:o,isDrawio:i,isExcalidraw:a,isImage:s,session:null,supportsBacklinks:f.supportsBacklinks});return}let p=await this.lifecycle.createSession({filePath:e,getFileList:this.getFileList,lineWrappingEnabled:this.getLineWrappingEnabled(),localUser:this.getLocalUser(),onAwarenessChange:e=>this.onFileAwarenessChange(e),onConnectionChange:e=>this.onConnectionChange(e),onCommentsChange:e=>this.onCommentsChange?.(e),onContentChange:()=>{a||this.onContentChange({isBase:o,isMermaid:c,isPlantUml:l})},onImagePaste:e=>this.onImagePaste?.(e),preferredUserName:this.getStoredUserName(),onSelectionChange:e=>this.onSelectionChange?.(e),theme:this.getTheme()});this.session=p,this.onSessionAssigned?.(p);try{let t=!1,n=!1,r=!1,i=async r=>{t||u!==this.stateStore.get(`sessionLoadToken`)||(t=!0,this.lifecycle.attachSessionScroller(p),p.applyTheme(this.getTheme()),this.chromeController.markFileOpenReady(p),this.reportFileOpenMetric(`editor_ready`,u,{reason:r}),p.requestMeasure(),await this.waitForNextPaint(),!(n||u!==this.stateStore.get(`sessionLoadToken`))&&(n=!0,this.chromeController.finalizeFileOpen({filePath:e,isBase:o,isExcalidraw:a,session:p,supportsBacklinks:f.supportsBacklinks})))},s=this.loadBootstrapContent?(async()=>{this.reportFileOpenMetric(`bootstrap_fetch_started`,u);try{let t=await this.loadBootstrapContent(e);return this.reportFileOpenMetric(`bootstrap_fetch_completed`,u,{found:t!==null}),t}catch(e){return this.reportFileOpenMetric(`bootstrap_fetch_completed`,u,{error:e.message,found:!1}),null}})():Promise.resolve(null),c=p.initialize(e),l=(async()=>(await c,u!==this.stateStore.get(`sessionLoadToken`)||(await p.waitForInitialSync(null),u!==this.stateStore.get(`sessionLoadToken`))?!1:(r=!0,p.activateCollaborativeView?.(),this.lifecycle.attachSessionScroller(p),p.applyTheme(this.getTheme()),this.reportFileOpenMetric(`initial_sync_complete`,u),p.ensureInitialContent?.(),t?p.requestMeasure():await i(`live-sync`),!0)))(),m=(async()=>{let n=await s;if(n===null||r||t||u!==this.stateStore.get(`sessionLoadToken`))return!1;let a=performance.now()-d,o=Math.max(0,_t-a);return o>0&&await Promise.race([l.then(e=>e?`live-sync`:`stale`),vt(o).then(()=>`timeout`)])===`live-sync`||r||t||u!==this.stateStore.get(`sessionLoadToken`)||!p.showBootstrapContent({content:n,filePath:e})&&!p.hasBootstrapContent?.()?!1:(this.reportFileOpenMetric(`bootstrap_shown`,u),await i(`bootstrap`),!0)})();if(await c,u!==this.stateStore.get(`sessionLoadToken`)){p.destroy();return}if(await Promise.all([l,m]),u!==this.stateStore.get(`sessionLoadToken`)){p.destroy();return}t||(p.ensureInitialContent?.(),await i(`post-initialize`))}catch(e){if(console.error(`[app] Failed to initialize editor:`,e),p.destroy(),this.lifecycle.clearSessionScroller(),this.session===p&&(this.session=null),u!==this.stateStore.get(`sessionLoadToken`))return;this.chromeController.handleFileOpenError()}}},bt=class{constructor(e={}){this.state={activeSidebarTab:`files`,chatInitialSyncComplete:!1,chatIsOpen:!1,chatMessageIds:new Set,chatMessages:[],chatUnreadCount:0,connectionHelpShown:!1,connectionState:{status:`disconnected`,unreachable:!1},currentDrawioMode:null,currentFilePath:null,fileExplorerReady:!1,followedCursorSignature:``,followedUserClientId:null,gitRepoAvailable:!1,globalUsers:[],isTabActive:!1,presencePanelOpen:!1,sessionLoadToken:0,...e}}get(e){return this.state[e]}set(e,t){return this.state[e]=t,t}nextSessionLoadToken(){let e=Number(this.state.sessionLoadToken||0)+1;return this.state.sessionLoadToken=e,e}replaceChatState({initialSyncComplete:e,isOpen:t,messageIds:n,messages:r,unreadCount:i}){this.state.chatMessages=Array.isArray(r)?r:[],this.state.chatMessageIds=n instanceof Set?n:new Set,this.state.chatUnreadCount=Number.isFinite(i)?i:0,this.state.chatIsOpen=!!t,this.state.chatInitialSyncComplete=!!e}};function xt(e=document){return{currentUserName:e.getElementById(`currentUserName`),chatContainer:e.getElementById(`chatContainer`),chatEmptyState:e.getElementById(`chatEmptyState`),chatForm:e.getElementById(`chatForm`),chatInput:e.getElementById(`chatInput`),chatMessages:e.getElementById(`chatMessages`),chatNotificationButton:e.getElementById(`chatNotificationBtn`),chatPanel:e.getElementById(`chatPanel`),chatStatus:e.getElementById(`chatStatus`),chatToastContainer:e.getElementById(`chatToastContainer`),chatToggleBadge:e.getElementById(`chatToggleBadge`),chatToggleButton:e.getElementById(`chatToggleBtn`),gitCommitCancel:e.getElementById(`gitCommitCancel`),gitCommitCopy:e.getElementById(`gitCommitCopy`),gitCommitDialog:e.getElementById(`gitCommitDialog`),gitCommitForm:e.getElementById(`gitCommitForm`),gitCommitInput:e.getElementById(`gitCommitInput`),gitCommitSubmit:e.getElementById(`gitCommitSubmit`),gitCommitTitle:e.getElementById(`gitCommitTitle`),gitResetCancel:e.getElementById(`gitResetCancel`),gitResetCopy:e.getElementById(`gitResetCopy`),gitResetDialog:e.getElementById(`gitResetDialog`),gitResetFileName:e.getElementById(`gitResetFileName`),gitResetSubmit:e.getElementById(`gitResetSubmit`),gitResetTitle:e.getElementById(`gitResetTitle`),displayNameCancel:e.getElementById(`displayNameCancel`),displayNameCopy:e.getElementById(`displayNameCopy`),displayNameDialog:e.getElementById(`displayNameDialog`),displayNameForm:e.getElementById(`displayNameForm`),displayNameInput:e.getElementById(`displayNameInput`),displayNameSubmit:e.getElementById(`displayNameSubmit`),displayNameTitle:e.getElementById(`displayNameTitle`),editNameButton:e.getElementById(`editNameBtn`),editorFindButton:e.getElementById(`editorFindBtn`),editorContainer:e.getElementById(`editorContainer`),exportDocxButton:e.getElementById(`exportDocxBtn`),exportMenuGroup:e.getElementById(`exportMenuGroup`),exportPdfButton:e.getElementById(`exportPdfBtn`),markdownToolbar:e.getElementById(`markdownToolbar`),editorPage:e.getElementById(`editor-page`),diffPage:e.getElementById(`diff-page`),fileSearch:e.getElementById(`fileSearch`),fileHistoryButton:e.getElementById(`fileHistoryBtn`),fileHistoryButtonLabel:e.getElementById(`fileHistoryBtnLabel`),filesSidebarTab:e.getElementById(`filesSidebarTab`),gitSearch:e.getElementById(`gitSearch`),gitSearchInput:e.getElementById(`gitSearchInput`),gitSidebarTab:e.getElementById(`gitSidebarTab`),gitOperationStatus:e.getElementById(`gitOperationStatus`),lineInfo:e.getElementById(`lineInfo`),mobileViewToggle:e.getElementById(`mobileViewToggle`),previewContent:e.getElementById(`previewContent`),previewContainer:e.getElementById(`previewContainer`),presencePanel:e.getElementById(`presencePanel`),presencePanelList:e.getElementById(`presencePanelList`),presencePanelStatus:e.getElementById(`presencePanelStatus`),searchFilesButton:e.getElementById(`searchFilesBtn`),shareButton:e.getElementById(`shareBtn`),toastContainer:e.getElementById(`toastContainer`),toggleWrapButton:e.getElementById(`toggleWrapBtn`),userAvatars:e.getElementById(`userAvatars`),userCount:e.getElementById(`userCount`),wrapToggleLabel:e.getElementById(`wrapToggleLabel`),activeFileName:e.getElementById(`activeFileName`),sidebarToggle:e.getElementById(`sidebarToggle`),sidebarClose:e.getElementById(`sidebarClose`),sidebar:e.getElementById(`sidebar`),emptyState:e.getElementById(`emptyState`),emptyStateNewFileBtn:e.getElementById(`emptyStateNewFileBtn`),emptyStateSearchBtn:e.getElementById(`emptyStateSearchBtn`),backlinksPanel:e.getElementById(`backlinksPanel`),backlinksHeaderPanel:e.getElementById(`backlinksHeaderPanel`),backlinksInlinePanel:e.getElementById(`backlinksInlinePanel`),commentSelectionButton:e.getElementById(`commentSelectionBtn`),commentsDrawer:e.getElementById(`commentsDrawer`),commentsDrawerEmpty:e.getElementById(`commentsDrawerEmpty`),commentsDrawerList:e.getElementById(`commentsDrawerList`),commentsToggleButton:e.getElementById(`commentsToggle`),outlineToggle:e.getElementById(`outlineToggle`),tabLockCopy:e.getElementById(`tabLockCopy`),tabLockOverlay:e.getElementById(`tabLockOverlay`),tabLockTakeoverButton:e.getElementById(`tabLockTakeoverBtn`),tabLockTitle:e.getElementById(`tabLockTitle`),toolbarCenter:e.getElementById(`toolbarCenter`),toolbarDiffBadge:e.getElementById(`toolbarDiffBadge`),toolbarOverflowMenu:e.getElementById(`toolbarOverflowMenu`),toolbarOverflowToggle:e.getElementById(`toolbarOverflowToggle`),sidebarTabs:e.getElementById(`sidebarTabs`)}}var R={updateChatMessages(e,{initial:t=!1}={}){let n=new Set(this.chatMessageIds),r=this.lobby.getLocalUser()?.peerId??null;if(this.chatMessages=e,this.chatMessageIds=new Set(e.map(e=>e.id)),!this.chatInitialSyncComplete){t&&(this.chatInitialSyncComplete=!0),this.renderChat();return}let i=e.filter(e=>!n.has(e.id)&&e.peerId&&e.peerId!==r);this.chatIsOpen?this.chatUnreadCount=0:i.length>0&&(this.chatUnreadCount+=i.length);for(let e of i)this.maybeNotifyChatMessage(e);this.renderChat()},toggleChatPanel(){if(this.chatIsOpen){this.closeChatPanel();return}this.openChatPanel()},openChatPanel(){this.chatIsOpen=!0,this.chatUnreadCount=0,this.renderChat(),requestAnimationFrame(()=>{this.elements.chatInput?.focus(),this.scrollChatToBottom()})},closeChatPanel(){this.chatIsOpen&&(this.chatIsOpen=!1,this.renderChat())},handleChatSubmit(){if(!this.isTabActive)return;let e=this.elements.chatInput;if(e){if(!this.lobby.sendChatMessage(e.value)){e.focus();return}if(e.value=``,!this.chatIsOpen){this.openChatPanel();return}this.renderChat()}},renderChat(){this.elements.chatContainer?.classList.toggle(`is-open`,this.chatIsOpen),this.elements.chatPanel?.classList.toggle(`hidden`,!this.chatIsOpen),this.syncChatToggleButton(),this.syncChatNotificationButton();let e=this.elements.chatMessages,t=this.elements.chatEmptyState;if(this.elements.chatStatus&&(this.elements.chatStatus.textContent=this.chatInitialSyncComplete?`${this.globalUsers.length} online`:`Syncing...`),!e)return;if(e.replaceChildren(),this.chatMessages.length===0){t?.classList.remove(`hidden`),e.classList.add(`hidden`);return}t?.classList.add(`hidden`),e.classList.remove(`hidden`);let n=document.createDocumentFragment();this.chatMessages.forEach(e=>{n.appendChild(this.createChatMessageElement(e))}),e.appendChild(n),this.chatIsOpen&&this.scrollChatToBottom()},createChatMessageElement(e){let t=document.createElement(`article`),n=e.peerId===this.lobby.getLocalUser()?.peerId;t.className=`chat-message`,t.classList.toggle(`is-local`,n);let r=document.createElement(`div`);r.className=`chat-message-avatar`,r.style.backgroundColor=e.userColor||`var(--color-primary)`,r.textContent=(e.userName||`?`).charAt(0).toUpperCase(),r.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`div`);i.className=`chat-message-body`;let a=document.createElement(`div`);a.className=`chat-message-meta`;let o=document.createElement(`span`);o.className=`chat-message-author`,o.textContent=n?`${e.userName} (you)`:e.userName;let s=document.createElement(`span`);s.className=`chat-message-time`,s.textContent=this.formatChatTimestamp(e.createdAt),a.append(o,s);let c=this.getChatMessageFileLabel(e.filePath);if(c){let e=document.createElement(`span`);e.className=`chat-message-file`,e.textContent=c,a.append(e)}let l=document.createElement(`p`);return l.className=`chat-message-text`,l.textContent=e.text,i.append(a,l),t.append(r,i),t},scrollChatToBottom(){let e=this.elements.chatMessages;e&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight})},formatChatTimestamp(e){if(!Number.isFinite(e))return``;try{return this.chatTimeFormatter.format(new Date(e))}catch{return``}},getChatMessageFileLabel(e){return e?this.getDisplayName(e):``},formatChatToastMessage(e){let t=e?.userName||`Someone`,n=String(e?.text??``).replace(/\s+/g,` `).trim();return`${t}: ${n.length>88?`${n.slice(0,85).trimEnd()}...`:n}`},syncChatToggleButton(){let e=this.elements.chatToggleButton,t=this.elements.chatToggleBadge;if(!e)return;let n=this.chatUnreadCount>0,r=n&&!this.chatIsOpen;e.classList.toggle(`is-active`,this.chatIsOpen),e.classList.toggle(`is-unread`,r),e.setAttribute(`aria-expanded`,String(this.chatIsOpen)),e.setAttribute(`aria-label`,n?`Open team chat, ${this.chatUnreadCount} unread`:`Open team chat`),e.title=this.chatUnreadCount>0?`Team chat (${this.chatUnreadCount} unread)`:`Team chat`,t&&(t.classList.toggle(`hidden`,!n),t.textContent=this.chatUnreadCount>9?`9+`:String(this.chatUnreadCount))},syncChatNotificationButton(){let e=this.elements.chatNotificationButton;if(!e)return;let t=this.notifications.getPermission();this.chatNotificationPermission=t;let n=`Enable alerts`,r=`Enable browser notifications for new chat messages`,i=!1;t===`unsupported`?(n=`No alerts`,r=`Browser notifications are unavailable here`):t===`denied`?(n=`Alerts blocked`,r=`Browser notifications are blocked for this site`):t===`granted`&&(i=this.chatNotificationsEnabled,n=i?`Alerts on`:`Alerts off`,r=i?`Disable browser notifications for chat`:`Enable browser notifications for chat`),e.textContent=n,e.title=r,e.setAttribute(`aria-pressed`,String(i)),e.classList.toggle(`is-enabled`,i),e.classList.toggle(`is-blocked`,t===`denied`)},async handleChatNotificationToggle(){let e=this.notifications.getPermission();if(this.chatNotificationPermission=e,e===`unsupported`){this.toastController.show(`Browser notifications are unavailable here`),this.syncChatNotificationButton();return}if(e===`denied`){this.chatNotificationsEnabled=!1,this.preferences.setChatNotificationsEnabled(!1),this.toastController.show(`Browser notifications are blocked for this site`),this.syncChatNotificationButton();return}if(e===`default`){let e=await this.notifications.requestPermission();if(this.chatNotificationPermission=e,e!==`granted`){this.chatNotificationsEnabled=!1,this.preferences.setChatNotificationsEnabled(!1),e===`denied`&&this.toastController.show(`Browser notifications were blocked`),this.syncChatNotificationButton();return}this.chatNotificationsEnabled=!0,this.preferences.setChatNotificationsEnabled(!0),this.syncChatNotificationButton();return}this.chatNotificationsEnabled=!this.chatNotificationsEnabled,this.preferences.setChatNotificationsEnabled(this.chatNotificationsEnabled),this.syncChatNotificationButton()},maybeNotifyChatMessage(e){if(this.chatInitialSyncComplete){if(document.hidden){this.maybeShowBrowserChatNotification(e);return}!this.isTabActive||this.chatIsOpen||(this.chatToastController??this.toastController).show(this.formatChatToastMessage(e),4e3)}},maybeShowBrowserChatNotification(e){if(!this.chatNotificationsEnabled||this.notifications.getPermission()!==`granted`)return;let t=`CollabMD chat • ${e.userName}`,n=this.getChatMessageFileLabel(e.filePath),r=n?`${n}: ${e.text}`:e.text,i=this.notifications.createNotification({body:r,onClick:()=>{e.filePath&&this.navigation.navigateToFile(e.filePath)},tag:`collabmd-chat-${e.id}`,title:t});i&&setTimeout(()=>{i.close?.()},6e3)}},St={getCommentFileKind(e=this.currentFilePath){return f(e)||`markdown`},syncCommentChrome(e=this.currentFilePath){let t=d(e)&&!this.isExcalidrawFile(e);this.commentUi.setCurrentFile(e,{fileKind:this.getCommentFileKind(e),supported:t}),this.handleCommentThreadsChange(this.session?.getCommentThreads?.()??[]),this.handleCommentSelectionChange(this.session?.getCurrentSelectionCommentAnchor?.()??null)},handleCommentSelectionChange(e){this.commentUi.setSelectionAnchor(e)},handleCommentThreadsChange(e=[]){this.commentUi.setThreads(e)},handleCommentEditorContentChange(){this.commentUi.handleEditorContentChange()},refreshCommentUiLayout(){this.commentUi.refreshLayout()}},Ct=`collabmd-export-page`,wt=`collabmd-export-host`,Tt=500,Et=6e4,Dt=new Map,Ot=null;function kt(){return`export-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function At(e){return e===`pdf`?`pdf`:`docx`}function jt({filePath:e,format:t,jobId:n}){let r=new URL(O(`/export-document.html`),window.location.origin);return r.searchParams.set(`action`,At(t)),r.searchParams.set(`job`,n),e&&r.searchParams.set(`file`,e),r.toString()}function Mt({fileList:e=[],filePath:t,format:n,jobId:r,markdownText:i=``,title:a=``}){return{action:At(n),fileList:Array.isArray(e)?e.slice():[],filePath:String(t??``),jobId:r,markdownText:String(i??``),source:wt,title:String(a??``),type:`bootstrap`}}function Nt(e){e&&(e.closePollId&&window.clearInterval(e.closePollId),e.timeoutId&&window.clearTimeout(e.timeoutId))}function Pt(e,{notifyError:t=!1,message:n=``}={}){let r=Dt.get(e);r&&(Nt(r),Dt.delete(e),t&&n&&Ot?.(n))}function Ft({onError:e=null}={}){Ot=typeof e==`function`?e:null,!window.__collabmdExportBridgeInitialized&&(window.addEventListener(`message`,e=>{if(e.origin!==window.location.origin)return;let t=e.data;if(!t||t.source!==Ct)return;let n=String(t.jobId??``).trim();if(!n)return;let r=Dt.get(n);if(r){if(t.type===`ready`){if(r.window?.closed){Pt(n,{message:`Export window was closed before the export completed`,notifyError:!0});return}try{r.window?.postMessage(r.payload,window.location.origin)}catch(e){Pt(n,{message:e instanceof Error?e.message:`Failed to send export data`,notifyError:!0})}return}(t.type===`complete`||t.type===`error`)&&Pt(n,{message:t.type===`error`&&t.message?String(t.message):``,notifyError:t.type===`error`&&!!t.message})}}),window.__collabmdExportBridgeInitialized=!0)}async function It({fileList:e=[],filePath:t,format:n,markdownText:r=``,title:i=``}={}){let a=String(t??``).trim();if(!a)throw Error(`No markdown note is open`);let o=kt(),s=jt({filePath:a,format:n,jobId:o}),c=window.open(s,`_blank`);if(!c)throw Error(`Export popup was blocked`);return Dt.set(o,{closePollId:window.setInterval(()=>{c.closed&&Pt(o,{message:`Export window was closed before the export completed`,notifyError:!0})},Tt),payload:Mt({fileList:e,filePath:a,format:n,jobId:o,markdownText:r,title:i}),timeoutId:window.setTimeout(()=>{Pt(o,{message:`Export timed out before it completed`,notifyError:!0})},Et),window:c}),c.focus?.(),o}var Lt={initializeExportBridge(){this._exportBridgeInitialized||=(Ft({onError:e=>{this.toastController?.show(e)}}),!0)},async handleExportRequest(e){let t=String(this.currentFilePath??``).trim();if(!u(t))return this.toastController?.show(`Export is available for markdown notes only`),!1;try{return await It({fileList:this.fileExplorer?.flatDocumentFiles??[],filePath:t,format:e,markdownText:this.session?.getText?.()??``,title:this.getDisplayName(t)}),!0}catch(e){return this.toastController?.show(e instanceof Error?e.message:`Failed to start export`),!1}}};function Rt(e=[]){return Array.from(new Set((e??[]).filter(Boolean)))}function zt(e=[]){return Array.from(new Map((e??[]).filter(e=>e?.oldPath&&e?.newPath&&e.oldPath!==e.newPath).map(e=>[`${e.oldPath}:${e.newPath}`,{newPath:e.newPath,oldPath:e.oldPath}])).values())}function Bt(e=[]){return(e??[]).filter(e=>e?.path&&Number.isFinite(e?.from)&&Number.isFinite(e?.to)).map(e=>({from:Math.max(0,Math.round(e.from)),path:e.path,to:Math.max(0,Math.round(e.to))}))}function Vt({changedPaths:e=[],deletedPaths:t=[],refreshExplorer:n=!0,renamedPaths:r=[]}={}){return{changedPaths:Rt(e),deletedPaths:Rt(t),refreshExplorer:n!==!1,renamedPaths:zt(r)}}function Ht(e){return!e||typeof e!=`object`||typeof e.id!=`string`?null:{action:typeof e.action==`string`?e.action:`workspace`,createdAt:Number.isFinite(e.createdAt)?e.createdAt:Date.now(),highlightRanges:Bt(e.highlightRanges),id:e.id,origin:typeof e.origin==`string`?e.origin:`api`,reloadRequiredPaths:Rt(e.reloadRequiredPaths),requestId:typeof e.requestId==`string`?e.requestId:null,sourceRef:typeof e.sourceRef==`string`?e.sourceRef:null,workspaceChange:Vt(e.workspaceChange)}}function Ut(){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`workspace-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function Wt(e={}){return Vt(e)}var z={formatPullBackupToast(e=null){let t=Number(e?.fileCount||0);return t===1?`Pulled latest changes. 1 overlapping local file was backed up.`:t>1?`Pulled latest changes. ${t} overlapping local files were backed up.`:`Pulled latest changes. Overlapping local changes were recorded in a pull backup.`},setGitOperationStatus(e=``){let t=this.elements.gitOperationStatus;if(!t)return;let n=String(e??``).trim();t.textContent=n,t.classList.toggle(`hidden`,!n)},async runGitActionWithStatus(e,t){this.setGitOperationStatus(e);try{return await t()}finally{this.setGitOperationStatus(``)}},handleGitDiffSelection(e,{closeSidebarOnMobile:t=!1,scope:n=`working-tree`}={}){t&&this.closeSidebarOnMobile(),this.navigation.navigateToGitDiff({filePath:e,scope:n})},handleGitCommitSelection(e,{closeSidebarOnMobile:t=!1,historyFilePath:n=null,path:r=null}={}){t&&this.closeSidebarOnMobile(),this.navigation.navigateToGitCommit({hash:e,historyFilePath:n,path:r})},handleGitHistorySelection({closeSidebarOnMobile:e=!1}={}){e&&this.closeSidebarOnMobile(),this.navigation.navigateToGitHistory()},handleGitFileHistorySelection(e=this.currentFilePath,{closeSidebarOnMobile:t=!1}={}){t&&this.closeSidebarOnMobile(),e&&this.navigation.navigateToGitFileHistory({filePath:e})},handleGitFilePreviewSelection({hash:e,path:t,currentFilePath:n=null,closeSidebarOnMobile:r=!1}={}){r&&this.closeSidebarOnMobile(),!(!e||!t)&&this.navigation.navigateToGitFilePreview({hash:e,path:t,currentFilePath:n})},handleGitRepoChange(e,t=null){this.gitRepoAvailable=!!e,this.elements.sidebarTabs?.classList.toggle(`hidden`,!this.gitRepoAvailable),this.elements.gitSidebarTab?.classList.toggle(`hidden`,!this.gitRepoAvailable);let n=e&&t?.summary?.changedFiles>0;if(this.elements.gitSidebarTab?.classList.toggle(`has-changes`,n),this.gitDiffView.setRepoStatus(this.gitRepoAvailable?t:null),!this.gitRepoAvailable&&this.activeSidebarTab===`git`){this.syncFileHistoryButton({mode:this.navigation.getHashRoute().type===`git-file-preview`?`history-preview`:`editor`}),this.setSidebarTab(`files`);return}let r=this.navigation.getHashRoute().type;this.gitRepoAvailable&&(r===`git-diff`||r===`git-commit`||r===`git-history`)&&this.activeSidebarTab!==`git`&&this.setSidebarTab(`git`),this.syncFileHistoryButton({filePath:this.currentFilePath,mode:r===`git-file-preview`?`history-preview`:r===`file`?`editor`:`empty`})},syncFileHistoryButton({filePath:e=this.currentFilePath,mode:t=`editor`}={}){let n=this.elements.fileHistoryButton,r=this.elements.fileHistoryButtonLabel;if(!(!n||!r)){if(!(this.gitRepoAvailable&&this.supportsFileHistory?.(e))){n.classList.add(`hidden`);return}if(n.classList.remove(`hidden`),t===`history-preview`){r.textContent=`Back to History`,n.setAttribute(`aria-label`,`Back to file history`),n.title=`Back to file history`;return}if(t!==`editor`){n.classList.add(`hidden`);return}r.textContent=`History`,n.setAttribute(`aria-label`,`Open file history`),n.title=`View file history`}},syncMainChrome({badgeLabel:e=``,mode:t,title:n=null}={}){let r=t===`diff`||t===`history`||t===`history-preview`;this.elements.toolbarCenter?.classList.toggle(`hidden`,r),this.elements.mobileViewToggle?.classList.toggle(`hidden`,r),this.elements.userCount?.classList.toggle(`hidden`,r),this.elements.toolbarDiffBadge?.classList.toggle(`hidden`,!e),this.elements.toolbarDiffBadge&&(this.elements.toolbarDiffBadge.textContent=e),n&&this.elements.activeFileName&&(this.elements.activeFileName.textContent=n),this.syncFileHistoryButton({filePath:this.currentFilePath,mode:t})},async showGitDiff({filePath:e=null,scope:t=`all`}={}){this.clearStaticPreviewDocument?.(),this.gitPanel.setSelection(e?{path:e,scope:t,source:`workspace`}:{}),this.gitPanel.setMode(`changes`),this.showDiffState(),this.syncMainChrome({badgeLabel:`Diff`,mode:`diff`,title:this.gitDiffView.getToolbarTitle({filePath:e,scope:t})}),this.syncFileHistoryButton({filePath:e,mode:`diff`}),await this.gitDiffView.openWorkspaceDiff({filePath:e,scope:t})},async showGitCommit({hash:e,path:t=null,historyFilePath:n=null}={}){this.clearStaticPreviewDocument?.(),this.gitPanel.setMode(`history`),this.gitPanel.setSelection(e?{commitHash:e,path:t,source:`commit`}:{source:`commit`}),this.showDiffState(),this.syncMainChrome({badgeLabel:`Diff`,mode:`diff`,title:this.gitDiffView.getToolbarTitle({commitHash:e,path:t,source:`commit`})}),this.syncFileHistoryButton({filePath:t,mode:`diff`}),await this.gitDiffView.openCommitDiff({hash:e,historyFilePath:n,path:t})},async showGitHistory(){this.clearStaticPreviewDocument?.(),this.gitPanel.setMode(`history`),this.gitPanel.setSelection({source:`commit`}),this.workspaceRouteController?.showEmptyState?.(),this.syncMainChrome({mode:`empty`,title:`Git History`}),this.syncFileHistoryButton({mode:`empty`})},async showGitFileHistory({filePath:e=null}={}){if(!e){this.workspaceRouteController?.showEmptyState?.();return}this.clearStaticPreviewDocument?.(),this.commentUi?.attachSession?.(null),this.commentUi?.setCurrentFile?.(e,{fileKind:this.getCommentFileKind(e),supported:!1}),this.handleCommentThreadsChange?.([]),this.handleCommentSelectionChange?.(null),this.workspaceRouteController?.showFileHistoryState?.(e),this.syncMainChrome({badgeLabel:`History`,mode:`history`,title:this.getDisplayName(e)}),this.syncFileHistoryButton({filePath:e,mode:`history`}),await this.fileHistoryView.openFileHistory({filePath:e})},async _loadGitFileSnapshot({hash:e,filePath:t,resolvedCurrentFilePath:n}){let r=await this.gitApiClient.readFileSnapshot({hash:e,path:t});if(this.setStaticPreviewDocument?.({...r,currentFilePath:n}),this.resetPreviewMode(),this.elements.markdownToolbar?.classList.add(`hidden`),this.elements.outlineToggle?.classList.toggle(`hidden`,r.fileKind!==`markdown`),r.fileKind===`markdown`||r.fileKind===`mermaid`||r.fileKind===`plantuml`){r.fileKind===`mermaid`?this.elements.previewContent?.classList.add(`is-mermaid-file-preview`):r.fileKind===`plantuml`&&this.elements.previewContent?.classList.add(`is-plantuml-file-preview`),this.previewRenderer.beginDocumentLoad(),this.previewRenderer.queueRender();return}this.elements.outlineToggle?.classList.add(`hidden`),this.renderTextFilePreview?.({content:r.content,filePath:n})},_handleGitFilePreviewError(e,t){console.error(`[git-preview] Failed to load file snapshot:`,e),this.clearStaticPreviewDocument?.(),this.toastController.show(`Failed to load historical file preview`),this.renderTextFilePreview?.({content:`Failed to load historical file preview.`,filePath:t}),this.elements.outlineToggle?.classList.add(`hidden`)},async showGitFilePreview({hash:e,filePath:t=null,currentFilePath:n=null}={}){let r=String(n??``).trim()||t;if(!e||!t||!r){this.workspaceRouteController?.showEmptyState?.();return}this.commentUi?.attachSession?.(null),this.commentUi?.setCurrentFile?.(r,{fileKind:this.getCommentFileKind(r),supported:!1}),this.handleCommentThreadsChange?.([]),this.handleCommentSelectionChange?.(null),this.workspaceRouteController?.showPreviewOnlyState?.(r),this.layoutController.setView(`preview`,{persist:!1}),this.syncMainChrome({badgeLabel:`History Preview`,mode:`history-preview`,title:this.getDisplayName(r)}),this.syncFileHistoryButton({filePath:r,mode:`history-preview`});try{await this._loadGitFileSnapshot({hash:e,filePath:t,resolvedCurrentFilePath:r})}catch(e){this._handleGitFilePreviewError(e,r)}},async postGitAction(e,t){let n=Ut();this.pendingWorkspaceRequestIds?.add(n);try{switch(e){case`stage`:return await this.gitApiClient.stageFile({path:t.path,requestId:n});case`unstage`:return await this.gitApiClient.unstageFile({path:t.path,requestId:n});case`push`:return await this.gitApiClient.pushBranch({requestId:n});case`pull`:return await this.gitApiClient.pullBranch({requestId:n});case`reset-file`:return await this.gitApiClient.resetFile({path:t.path,requestId:n});case`commit`:return await this.gitApiClient.commit({message:t.message,requestId:n});default:throw Error(`Unsupported git action: ${e}`)}}catch(e){throw this.pendingWorkspaceRequestIds?.delete(n),e}},async refreshWorkspaceAfterGitAction({filePath:e=null,preferredScope:t=null}={}){await this.fileExplorer.refresh(),await this.refreshGitAfterAction({filePath:e,preferredScope:t})},async refreshGitAfterAction({filePath:e=null,preferredScope:t=null}={}){await this.gitPanel.refresh({force:!0});let n=this.navigation.getHashRoute();if(n.type===`git-history`){await this.showGitHistory();return}if(n.type===`git-file-history`){await this.showGitFileHistory({filePath:n.filePath});return}if(n.type===`git-file-preview`){await this.showGitFilePreview({hash:n.hash,filePath:n.filePath,currentFilePath:n.currentFilePath});return}if(n.type===`git-commit`){await this.showGitCommit({hash:n.hash,path:n.path,historyFilePath:n.historyFilePath});return}if(n.type!==`git-diff`)return;let r=e??n.filePath,i=t??n.scope;if(i!==n.scope||r!==n.filePath){this.navigation.navigateToGitDiff({filePath:r,scope:i});return}await this.showGitDiff({filePath:n.filePath,scope:n.scope})},async finalizeGitAction({action:e,filePath:t=null,preferredScope:n=null,result:r={},showLocalFileToast:i=!1}={}){let a=Wt(r.workspaceChange);return await this.refreshWorkspaceAfterGitAction({filePath:t,preferredScope:n}),this.handleWorkspaceChangeForCurrentFile(a,{action:e,local:!0,showToast:i}),a},handleWorkspaceChangeForCurrentFile(e,{action:t=`git`,local:n=!1,showToast:r=!0}={}){let i=this.currentFilePath;if(!i)return!1;let a=e.deletedPaths.includes(i),o=e.renamedPaths.find(e=>e.oldPath===i);if(!a&&!o)return!1;if(!r)return o?this.navigation.navigateToFile(o.newPath):this.navigation.navigateToFile(null),!0;let s=this.getDisplayName(i);return o?(this.navigation.navigateToFile(o.newPath),this.toastController.show(n?`${s} moved to ${this.getDisplayName(o.newPath)}`:`${s} moved on disk`),!0):(this.navigation.navigateToFile(null),this.toastController.show(n?`${s} was removed by ${t}`:`${s} was removed after a ${t} operation`),!0)},async handleIncomingWorkspaceEvent(e){if(!this.isTabActive||!e)return;if(e.requestId&&this.pendingWorkspaceRequestIds?.has(e.requestId)){this.pendingWorkspaceRequestIds.delete(e.requestId);return}let t=Wt(e.workspaceChange);if(e.origin===`git`&&await this.refreshGitAfterAction(),this.handleWorkspaceChangeForCurrentFile(t,{action:e.action||e.origin||`workspace`,local:!1,showToast:!0}),e.origin===`filesystem`&&this.currentFilePath&&t.changedPaths.includes(this.currentFilePath)){let n=t.changedPaths.length===1&&Array.isArray(e.highlightRanges)?e.highlightRanges.find(e=>e.path===this.currentFilePath):null;n&&this.session?.flashExternalUpdate?.(n)||this.toastController.show(`${this.getDisplayName(this.currentFilePath)} updated from disk`)}this.currentFilePath&&Array.isArray(e.reloadRequiredPaths)&&e.reloadRequiredPaths.includes(this.currentFilePath)&&this.toastController.show(`${this.getDisplayName(this.currentFilePath)} needs a manual reload`)},async stageGitFile(e,{scope:t=`working-tree`}={}){e&&await this.runGitActionWithStatus(`Staging changes...`,async()=>{let n=await this.postGitAction(`stage`,{path:e});await this.finalizeGitAction({action:`stage`,filePath:e,preferredScope:t===`all`?`all`:`staged`,result:n})})},async unstageGitFile(e,{scope:t=`staged`}={}){e&&await this.runGitActionWithStatus(`Unstaging changes...`,async()=>{let n=await this.postGitAction(`unstage`,{path:e});await this.finalizeGitAction({action:`unstage`,filePath:e,preferredScope:t===`all`?`all`:`working-tree`,result:n})})},async pushGitBranch(){await this.runGitActionWithStatus(`Pushing branch...`,async()=>{try{let e=await this.postGitAction(`push`,{});await this.finalizeGitAction({action:`push`,result:e})}catch(e){this.toastController.show(e.message||`Failed to push branch`)}})},async pullGitBranch(){await this.runGitActionWithStatus(`Pulling branch...`,async()=>{try{let e=await this.postGitAction(`pull`,{});await this.finalizeGitAction({action:`pull`,result:e,showLocalFileToast:!0}),e.pullBackup&&this.toastController.show(this.formatPullBackupToast(e.pullBackup),5e3)}catch(e){if(e?.code===`pull_diverged_ff_only`){this.toastController.show(`Cannot pull because local and remote commits have diverged. Fast-forward only pull is not possible.`,5e3);return}if(e?.code===`pull_conflicted_after_autostash`){this.toastController.show(`Pull updated the branch, but reapplying local changes caused conflicts. Review the conflicted files and the pull backup summary.`,6e3);return}this.toastController.show(e.message||`Failed to pull branch`)}})},openGitResetDialog(e){if(!this.isTabActive||!e)return;let t=this.elements.gitResetDialog;!t||!this.elements.gitResetFileName||(this.pendingGitResetPath=e,this.elements.gitResetTitle&&(this.elements.gitResetTitle.textContent=`Reset file to current branch`),this.elements.gitResetCopy&&(this.elements.gitResetCopy.textContent=`Restore this file from the current checked-out branch. If this branch does not contain the file, the file will be deleted locally.`),this.elements.gitResetFileName.value=e,this.elements.gitResetSubmit&&(this.elements.gitResetSubmit.textContent=`Reset File`),this.elements.gitResetSubmit?.toggleAttribute(`disabled`,!1),!t.open&&(typeof t.showModal==`function`?t.showModal():t.setAttribute(`open`,`true`)))},async handleGitResetSubmit(){let e=this.pendingGitResetPath,t=this.elements.gitResetDialog,n=this.elements.gitResetSubmit;if(!(!e||!t)){n?.toggleAttribute(`disabled`,!0),n&&(n.textContent=`Resetting...`);try{await this.runGitActionWithStatus(`Resetting file...`,async()=>{let t=await this.postGitAction(`reset-file`,{path:e});await this.finalizeGitAction({action:`reset`,filePath:e,result:t,showLocalFileToast:!0})}),t.close()}catch(e){this.toastController.show(e.message||`Failed to reset file`)}finally{n&&(n.textContent=`Reset File`),n?.toggleAttribute(`disabled`,!1)}}},openGitCommitDialog(){if(!this.isTabActive)return;let e=this.elements.gitCommitDialog,t=this.elements.gitCommitInput;if(!(!e||!t)){if(this.elements.gitCommitTitle&&(this.elements.gitCommitTitle.textContent=`Commit staged changes`),this.elements.gitCommitCopy){let e=Number(this.gitPanel.status?.summary?.staged||0);this.elements.gitCommitCopy.textContent=e>0?`${e} staged file${e===1?``:`s`} will be included.`:`All staged changes will be included.`}this.elements.gitCommitSubmit&&(this.elements.gitCommitSubmit.textContent=`Commit staged changes`),t.value=``,!e.open&&(typeof e.showModal==`function`?e.showModal():e.setAttribute(`open`,`true`),requestAnimationFrame(()=>{t.focus(),t.select()}))}},async handleGitCommitSubmit(){let e=this.elements.gitCommitDialog,t=this.elements.gitCommitInput,n=this.elements.gitCommitSubmit,r=String(t?.value??``).trim();if(!(!e||!t)){if(!r){t.focus(),this.toastController.show(`Commit message cannot be empty`);return}n?.toggleAttribute(`disabled`,!0),n&&(n.textContent=`Committing...`);try{await this.runGitActionWithStatus(`Committing changes...`,async()=>{let e=await this.postGitAction(`commit`,{message:r});await this.finalizeGitAction({action:`commit`,result:e})}),e.close()}catch(e){this.toastController.show(e.message||`Failed to commit staged changes`)}finally{n&&(n.textContent=`Commit staged changes`),n?.toggleAttribute(`disabled`,!1)}}}},Gt=5;function Kt(e,t){return String(e?.name??``).localeCompare(String(t?.name??``),void 0,{sensitivity:`base`})}function qt(e){let t=!!e.session,n=!!(e.currentFilePath&&e.isDrawioFile?.(e.currentFilePath)),r=!!(e.currentFilePath&&e.isExcalidrawFile?.(e.currentFilePath)),i=!!(e.currentFilePath&&e.isImageFile?.(e.currentFilePath));return!t&&(!e.currentFilePath||n||r||i)?e.lobby?.getConnectionState?.()??e.connectionState:e.connectionState}function Jt(e,t){let n=[...e],r=n.findIndex(e=>e.isLocal);if(r>0){let[e]=n.splice(r,1);n.unshift(e)}let i=n.findIndex(e=>!e.isLocal&&e.clientId===t),a=+!!n[0]?.isLocal;if(i>a){let[e]=n.splice(i,1);n.splice(a,0,e)}return n}function Yt(e,t){let n=e.filter(e=>e.isLocal).sort(Kt),r=e.filter(e=>!e.isLocal),i=r.filter(e=>e.clientId===t).sort(Kt),a=r.filter(e=>e.clientId!==t).sort(Kt);return[...n,...i,...a]}function Xt(e,t){return t.currentFile&&t.currentFile===e.currentFilePath?`Here`:t.currentFile?e.getDisplayName(t.currentFile):`No file`}var B={updateGlobalUsers(e){this.globalUsers=e,this.syncFollowedUser(),this.renderAvatars(),this.renderChat(),this.renderPresence(),this.syncCurrentUserName()},updateFileAwareness(e){this.syncFollowedUser()},renderPresence(){let e=this.elements.userCount;if(!e)return;let t=qt(this),n=this.globalUsers.length>0;if(t.status!==`connected`&&(this.presencePanelOpen=!1),e.type=`button`,e.setAttribute(`aria-controls`,`presencePanel`),e.setAttribute(`aria-expanded`,String(this.presencePanelOpen)),e.classList.toggle(`is-active`,this.presencePanelOpen),t.status===`connected`){e.textContent=`${this.globalUsers.length} online`,e.style.opacity=`1`,e.disabled=!n,e.setAttribute(`aria-label`,`Show ${this.globalUsers.length} online users`),this.renderPresencePanel();return}if(t.status===`connecting`){e.textContent=t.unreachable?`Unreachable`:`Connecting...`,e.style.opacity=`0.6`,e.disabled=!0,e.setAttribute(`aria-label`,e.textContent),this.renderPresencePanel();return}e.textContent=`Offline`,e.style.opacity=`0.6`,e.disabled=!0,e.setAttribute(`aria-label`,`Offline`),this.renderPresencePanel()},renderAvatars(){let e=this.elements.userAvatars;if(!e)return;e.replaceChildren();let t=Jt(this.globalUsers,this.followedUserClientId);if(t.slice(0,Gt).forEach(t=>{let n=document.createElement(t.isLocal?`div`:`button`);n.className=`user-avatar`,n.classList.toggle(`is-local`,t.isLocal),n.style.backgroundColor=t.color,n.classList.toggle(`is-following`,t.clientId===this.followedUserClientId);let r=document.createElement(`span`);r.className=`user-avatar-initial`,r.textContent=t.name.charAt(0).toUpperCase(),n.appendChild(r);let i=t.currentFile&&t.currentFile===this.currentFilePath,a=t.currentFile?this.getDisplayName(t.currentFile):`No file`;if(t.isLocal){let e=document.createElement(`span`);e.className=`user-avatar-self-label`,e.textContent=`You`,n.appendChild(e),n.title=`${t.name} (you) — ${a}`,n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`${t.name} (you) — ${a}`)}else{n.type=`button`,n.classList.add(`user-avatar-button`),i||n.classList.add(`different-file`);let e=t.clientId===this.followedUserClientId?`Stop following ${t.name}`:i?`Follow ${t.name}`:`Follow ${t.name} — ${a}`;n.title=e,n.setAttribute(`aria-label`,e),n.addEventListener(`click`,()=>this.toggleFollowUser(t.clientId))}e.appendChild(n)}),t.length>Gt){let n=document.createElement(`button`);n.type=`button`,n.className=`user-avatar user-avatar-button user-avatar-overflow-trigger`,n.style.backgroundColor=`var(--color-surface-dynamic)`,n.style.color=`var(--color-text-muted)`,n.setAttribute(`aria-controls`,`presencePanel`),n.setAttribute(`aria-expanded`,String(this.presencePanelOpen)),n.setAttribute(`aria-label`,`Show ${t.length} online users`),n.setAttribute(`data-presence-panel-trigger`,`true`),n.title=`Show ${t.length} online users`,n.addEventListener(`click`,()=>this.openPresencePanel());let r=document.createElement(`span`);r.className=`user-avatar-initial`,r.textContent=`+${t.length-Gt}`,n.appendChild(r),e.appendChild(n)}this.renderPresencePanel()},openPresencePanel(){qt(this).status!==`connected`||this.globalUsers.length===0||(this.presencePanelOpen=!0,this.closeChatPanel?.(),this.closeToolbarOverflowMenu?.(),this.renderAvatars(),this.renderPresence(),this.renderPresencePanel())},closePresencePanel(){this.presencePanelOpen&&(this.presencePanelOpen=!1,this.renderAvatars(),this.renderPresence(),this.renderPresencePanel())},togglePresencePanel(){if(this.presencePanelOpen){this.closePresencePanel();return}this.openPresencePanel()},renderPresencePanel(){let e=this.elements.presencePanel,t=this.elements.presencePanelList,n=this.elements.presencePanelStatus;if(!e||!t)return;e.classList.toggle(`hidden`,!this.presencePanelOpen),e.setAttribute(`aria-hidden`,String(!this.presencePanelOpen));let r=Yt(this.globalUsers,this.followedUserClientId),i=qt(this);if(n&&(i.status===`connected`?n.textContent=`${this.globalUsers.length} online. Click someone to follow.`:i.status===`connecting`?n.textContent=i.unreachable?`Server unreachable.`:`Connecting presence...`:n.textContent=`Presence is offline.`),t.replaceChildren(),r.length===0){let e=document.createElement(`div`);e.className=`presence-panel-empty-state`,e.textContent=i.status===`connected`?`Nobody else is here yet.`:`Presence will appear here when the connection is active.`,t.appendChild(e);return}let a=document.createDocumentFragment();r.forEach(e=>{let t=document.createElement(`article`);t.className=`presence-panel-user`,t.classList.toggle(`is-local`,e.isLocal),t.classList.toggle(`is-following`,e.clientId===this.followedUserClientId);let n=document.createElement(e.isLocal?`div`:`button`);n.className=`presence-panel-user-button`;let r=document.createElement(`span`);r.className=`presence-panel-user-avatar`,r.style.backgroundColor=e.color,r.textContent=e.name.charAt(0).toUpperCase(),r.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`span`);i.className=`presence-panel-user-body`;let o=document.createElement(`span`);o.className=`presence-panel-user-topline`;let s=document.createElement(`span`);if(s.className=`presence-panel-user-name`,s.textContent=e.name,o.appendChild(s),e.isLocal){let e=document.createElement(`span`);e.className=`presence-panel-user-badge`,e.textContent=`You`,o.appendChild(e)}else if(e.clientId===this.followedUserClientId){let e=document.createElement(`span`);e.className=`presence-panel-user-badge`,e.textContent=`Following`,o.appendChild(e)}let c=document.createElement(`span`);if(c.className=`presence-panel-user-file`,c.textContent=Xt(this,e),i.append(o,c),n.append(r,i),e.isLocal)n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`${e.name} (you) — ${c.textContent}`);else{let t=e.clientId===this.followedUserClientId;n.type=`button`,n.setAttribute(`aria-label`,t?`Keep following ${e.name}`:`Follow ${e.name} — ${c.textContent}`),n.addEventListener(`click`,()=>{this.startFollowingUser(e.clientId,{closePanel:!0})})}if(t.appendChild(n),!e.isLocal&&e.clientId===this.followedUserClientId){let n=document.createElement(`button`);n.type=`button`,n.className=`presence-panel-user-stop`,n.textContent=`Stop`,n.setAttribute(`aria-label`,`Stop following ${e.name}`),n.addEventListener(`click`,e=>{e.stopPropagation(),this.stopFollowingUser({closePanel:!0})}),t.appendChild(n)}a.appendChild(t)}),t.appendChild(a)},startFollowingUser(e,{closePanel:t=!1}={}){if(!e)return;let n=this.globalUsers.find(t=>t.clientId===e&&!t.isLocal);if(n){if(this.followedUserClientId=e,this.followedCursorSignature=``,this.renderAvatars(),t&&this.closePresencePanel(),n.currentFile&&n.currentFile!==this.currentFilePath){this.navigation.navigateToFile(n.currentFile);return}requestAnimationFrame(()=>{this.followedUserClientId===e&&this.followUserCursor(n,{force:!0})})}},toggleFollowUser(e){if(e){if(this.followedUserClientId===e){this.stopFollowingUser();return}this.startFollowingUser(e)}},stopFollowingUser({closePanel:e=!1}={}){this.followedUserClientId&&(this.currentFilePath&&this.isExcalidrawFile?.(this.currentFilePath)&&this.excalidrawEmbed?.setFollowedUser(this.currentFilePath,null),this.followedUserClientId=null,this.followedCursorSignature=``,this.renderAvatars(),e&&this.closePresencePanel())},syncFollowedUser(){if(!this.followedUserClientId)return;let e=this.globalUsers.find(e=>e.clientId===this.followedUserClientId);if(!e||e.isLocal){this.stopFollowingUser();return}if(e.currentFile&&e.currentFile!==this.currentFilePath){this.navigation.navigateToFile(e.currentFile);return}this.followUserCursor(e)},followUserCursor(e,{force:t=!1}={}){if(this.currentFilePath&&this.isExcalidrawFile?.(this.currentFilePath)){this.followExcalidrawUser(e,{force:t});return}let n=this.resolveFileClientId(e.peerId),r=n==null?null:this.session?.getUserViewport(n),i=n==null?null:this.session?.getUserCursor(n),a=i?.cursorHead??null,o=i?.cursorLine??null,s=i?.cursorAnchor??null,c=r?.topLine??null,l=r?.viewportRatio??.35;if(!e||c==null&&(a==null||o==null)){this.followedCursorSignature=``;return}let u=`${e.clientId}:${c??`no-viewport`}:${s??`no-anchor`}:${a??`no-head`}`;!t&&u===this.followedCursorSignature||(n!=null&&this.session?.scrollToUserViewport(n)||n!=null&&this.session?.scrollToUserCursor(n,`center`)||a!=null&&this.session?.scrollToPosition(a,`center`)||o!=null&&this.session?.scrollToLine(o,l))&&(this.followedCursorSignature=u)},followExcalidrawUser(e,{force:t=!1}={}){if(!e?.peerId||!this.currentFilePath){this.followedCursorSignature=``;return}let n=`excalidraw:${this.currentFilePath}:${e.peerId}`;!t&&n===this.followedCursorSignature||Promise.resolve(this.excalidrawEmbed?.setFollowedUser(this.currentFilePath,e.peerId)).then(t=>{t===!1||this.followedUserClientId!==e.clientId||(this.followedCursorSignature=n)}).catch(()=>{})},resolveFileClientId(e){if(!e||!this.session?.awareness)return null;for(let[t,n]of this.session.awareness.getStates())if(n.user?.peerId===e)return t;return null}};function Zt(){return this.runtimeConfig?.auth?.strategy===`oidc`&&this.runtimeConfig?.auth?.provider===`google`}function Qt({mode:e=`edit`}={}){if(this.isIdentityManagedByAuth()||!this.isTabActive)return;let t=this.elements.displayNameDialog,n=this.elements.displayNameInput,r=this.elements.displayNameTitle,i=this.elements.displayNameCopy,a=this.elements.displayNameCancel,o=this.elements.displayNameSubmit;if(!t||!n)return;let s=e===`onboarding`;r&&(r.textContent=s?`Choose your display name`:`Update display name`),i&&(i.textContent=s?`Pick a name collaborators will see. You can skip for now and continue as a guest.`:`Your name will be visible to everyone editing this vault.`),a&&(a.textContent=s?`Skip for now`:`Cancel`),o&&(o.textContent=s?`Continue`:`Save name`),n.value=s?``:this.getCurrentUserName(),!t.open&&(typeof t.showModal==`function`?t.showModal():t.setAttribute(`open`,`true`),requestAnimationFrame(()=>{n.focus(),n.select()}))}function $t(){!this.isTabActive||this._hasPromptedForDisplayName||this.getStoredUserName()||this.isIdentityManagedByAuth()||(this._hasPromptedForDisplayName=!0,requestAnimationFrame(()=>{this.openDisplayNameDialog({mode:`onboarding`})}))}function en(){if(this.isIdentityManagedByAuth())return;let e=this.elements.displayNameInput,t=this.elements.displayNameDialog;if(!e||!t)return;let n=this.session?this.session.setUserName(e.value):Te(e.value);if(!n){e.focus(),this.toastController.show(`Name must be 1-24 characters`);return}this.preferences.setUserName(n),this.lobby.setUserName(n);let r=this.lobby.getLocalUser();this.drawioEmbed?.updateLocalUser(r),this.excalidrawEmbed?.updateLocalUser(r),this.syncCurrentUserName(),this.renderChat(),t.close()}function tn(){return this.globalUsers.find(e=>e.isLocal)??this.session?.getLocalUser()??this.lobby?.getLocalUser()??null}function nn(){return this.getCurrentUser()?.name??this.getStoredUserName()??``}function rn(){return this.preferences.getUserName()}function an(){let e=this.elements.currentUserName;if(!e)return;let t=this.getCurrentUserName();e.textContent=t||`Set name`,e.classList.toggle(`has-name`,!!t),this.isIdentityManagedByAuth()||this.elements.editNameButton?.setAttribute(`aria-label`,`${t||`Set name`}. Change display name`)}function on(){let e=this.isIdentityManagedByAuth();this.elements.editNameButton?.classList.toggle(`hidden`,e),this.elements.editNameButton?.toggleAttribute(`disabled`,e),e&&this.elements.displayNameDialog?.open&&this.elements.displayNameDialog.close()}var sn={getCurrentUser:tn,getCurrentUserName:nn,getStoredUserName:rn,handleDisplayNameSubmit:en,isIdentityManagedByAuth:Zt,openDisplayNameDialog:Qt,promptForDisplayNameIfNeeded:$t,syncCurrentUserName:an,syncIdentityManagementUi:on},cn=0,ln=2e3,un=8,dn=`
|
|
46
|
-
<svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false">
|
|
47
|
-
<path d="M10 13.5 14 9.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
48
|
-
<path d="M9.35 7.55 10.6 6.3a4.2 4.2 0 0 1 5.95 5.95l-1.25 1.25" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
49
|
-
<path d="m14.65 16.45-1.25 1.25a4.2 4.2 0 0 1-5.95-5.95L8.7 10.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
50
|
-
</svg>
|
|
51
|
-
`;function fn(){this.initializeExportBridge?.(),this.renderMarkdownToolbar?.(),this.initializeVisualViewportBinding?.(),this.themeController.initialize(),this.previewRenderer.applyTheme(this.themeController.getTheme()),this.previewRenderer.scheduleWorkerPrewarm(),this.scheduleEditorSessionPrewarm?.(),this.outlineController.initialize(),this.layoutController.initialize(),this.scrollSyncController.initialize(),this.fileExplorer.initialize(),this.gitPanel.initialize(),this.gitDiffView.initialize(),this.fileHistoryView.initialize(),this.initializePreviewLayoutObserver(),this.syncIdentityManagementUi(),this.syncCurrentUserName(),this.syncWrapToggle(),this.syncToolbarOverflowVisibility?.(),this.syncChatNotificationButton(),this.syncFileHistoryButton({mode:`empty`}),this.renderChat(),this.gitPanel.refresh({force:!0}),this.elements.chatInput?.setAttribute(`maxlength`,String(this.lobbyChatMessageMaxLength)),this.bindEvents(),this.restoreSidebarState(),this.initializeVersionMonitoring(),this.tabActivityLock.initialize(),this.tabActivityLock.tryActivate(),window.addEventListener(`hashchange`,()=>this.handleHashChange());let e=this.createResizeHandler();window.addEventListener(`resize`,()=>{e(),this.syncToolbarOverflowVisibility?.()}),this.fileExplorerReadyPromise=this.fileExplorer.refresh().then(()=>{if(this.fileExplorerReady=!0,this.isTabActive)return this.handleHashChange()})}function pn(){this.versionMonitor?.start()}function mn(){let e=document.documentElement,t=window.visualViewport;if(e){if(!t){e.style.setProperty(`--app-viewport-height`,`100dvh`),e.style.setProperty(`--app-viewport-offset-top`,`0px`);return}e.style.setProperty(`--app-viewport-height`,`${Math.round(t.height)}px`),e.style.setProperty(`--app-viewport-offset-top`,`${Math.round(t.offsetTop)}px`)}}function hn(){this.syncVisualViewportBounds?.();let e=window.visualViewport;if(!e)return;let t=()=>this.syncVisualViewportBounds?.();e.addEventListener(`resize`,t,{passive:!0}),e.addEventListener(`scroll`,t,{passive:!0}),window.addEventListener(`orientationchange`,t)}function gn(e=null){if(this._reloadPromptShown)return;this._reloadPromptShown=!0;let t=String(e?.build?.packageVersion??this.runtimeConfig?.build?.packageVersion??``).trim(),n=t?`Version ${t} is available. Reload to update.`:`A new version is available. Reload to update.`;this.toastController.show(n,{actionLabel:`Reload`,dismissible:!0,duration:cn,onAction:()=>window.location.reload()})}function _n(){this.elements.shareButton?.addEventListener(`click`,()=>{this.copyCurrentLink(),this.closeToolbarOverflowMenu?.()}),this.elements.searchFilesButton?.addEventListener(`click`,()=>{this.toggleQuickSwitcher(),this.closeToolbarOverflowMenu?.()}),this.elements.exportDocxButton?.addEventListener(`click`,()=>{this.handleExportRequest?.(`docx`),this.closeToolbarOverflowMenu?.()}),this.elements.exportPdfButton?.addEventListener(`click`,()=>{this.handleExportRequest?.(`pdf`),this.closeToolbarOverflowMenu?.()}),this.elements.fileHistoryButton?.addEventListener(`click`,()=>{let e=this.navigation.getHashRoute();if(e.type===`git-file-preview`){this.handleGitFileHistorySelection(e.currentFilePath??e.filePath,{closeSidebarOnMobile:!0}),this.closeToolbarOverflowMenu?.();return}this.handleGitFileHistorySelection(this.currentFilePath,{closeSidebarOnMobile:!0}),this.closeToolbarOverflowMenu?.()}),this.elements.editNameButton?.addEventListener(`click`,()=>{this.openDisplayNameDialog(),this.closeToolbarOverflowMenu?.()})}function vn(){this.elements.displayNameCancel?.addEventListener(`click`,()=>{this.elements.displayNameDialog?.close()}),this.elements.gitCommitCancel?.addEventListener(`click`,()=>{this.elements.gitCommitDialog?.close()}),this.elements.gitResetCancel?.addEventListener(`click`,()=>{this.elements.gitResetDialog?.close()}),this.elements.gitResetSubmit?.addEventListener(`click`,()=>{this.handleGitResetSubmit()}),this.elements.gitCommitDialog?.addEventListener(`close`,()=>{this.elements.gitCommitInput&&(this.elements.gitCommitInput.value=``),this.elements.gitCommitSubmit&&(this.elements.gitCommitSubmit.textContent=`Commit staged changes`)}),this.elements.gitResetDialog?.addEventListener(`close`,()=>{this.pendingGitResetPath=null,this.elements.gitResetFileName&&(this.elements.gitResetFileName.value=``),this.elements.gitResetSubmit&&(this.elements.gitResetSubmit.textContent=`Reset File`)}),this.elements.displayNameForm?.addEventListener(`submit`,e=>{e.preventDefault(),this.handleDisplayNameSubmit()}),this.elements.gitCommitForm?.addEventListener(`submit`,e=>{e.preventDefault(),this.handleGitCommitSubmit()})}function yn(){this.elements.emptyStateNewFileBtn?.addEventListener(`click`,()=>{this.fileExplorer.actionController.openRootCreateMenu({anchor:this.elements.emptyStateNewFileBtn})}),this.elements.emptyStateSearchBtn?.addEventListener(`click`,()=>{this.toggleQuickSwitcher()}),this.elements.chatToggleButton?.addEventListener(`click`,()=>{this.closePresencePanel?.(),this.toggleChatPanel(),this.closeToolbarOverflowMenu?.()}),this.elements.chatForm?.addEventListener(`submit`,e=>{e.preventDefault(),this.handleChatSubmit()}),this.elements.chatNotificationButton?.addEventListener(`click`,()=>{this.handleChatNotificationToggle()}),_n.call(this),vn.call(this),this.elements.markdownToolbar?.addEventListener(`click`,e=>{this.handleMarkdownToolbarClick?.(e)}),this.elements.markdownToolbar?.addEventListener(`keydown`,e=>{this.handleMarkdownToolbarKeydown?.(e)}),this.elements.tabLockTakeoverButton?.addEventListener(`click`,()=>{this.handleTabTakeover()}),this.elements.toggleWrapButton?.addEventListener(`click`,()=>{this.toggleLineWrapping()}),this.elements.userCount?.addEventListener(`click`,e=>{e.preventDefault(),this.togglePresencePanel?.()}),this.elements.editorFindButton?.addEventListener(`click`,()=>{this.runEditorCommand?.(`openSearch`)}),this.elements.toolbarOverflowToggle?.addEventListener(`click`,e=>{e.preventDefault(),this.closePresencePanel?.(),this.toggleToolbarOverflowMenu()}),this.elements.toolbarOverflowMenu?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`button`)&&this.closeToolbarOverflowMenu()}),this.elements.previewContent?.addEventListener(`click`,e=>{this.handlePreviewContentClick?.(e)}),this.elements.sidebarToggle?.addEventListener(`click`,()=>{this.closeToolbarOverflowMenu(),this.toggleSidebar()}),this.elements.sidebarClose?.addEventListener(`click`,()=>{this.closeSidebarOnMobile()}),this.elements.filesSidebarTab?.addEventListener(`click`,()=>{this.setSidebarTab(`files`)}),this.elements.gitSidebarTab?.addEventListener(`click`,()=>{this.gitRepoAvailable&&this.setSidebarTab(`git`)}),document.addEventListener(`pointerdown`,e=>{this.handleDocumentPointerDown(e)}),document.addEventListener(`keydown`,e=>{this.handleDocumentKeydown(e)},{capture:!0})}function bn(e){this.handleMarkdownToolbarDocumentPointerDown?.(e);let t=e.target instanceof Element?e.target:null;this.toolbarOverflowOpen&&!this.elements.toolbarOverflowMenu?.contains(t)&&!this.elements.toolbarOverflowToggle?.contains(t)&&this.closeToolbarOverflowMenu(),this.presencePanelOpen&&!this.elements.presencePanel?.contains(t)&&!t?.closest?.(`[data-presence-panel-trigger="true"]`)&&this.closePresencePanel?.(),this.chatIsOpen&&(this.elements.chatContainer?.contains(t)||this.closeChatPanel())}function xn(e){if(e.key===`Escape`&&this.toolbarOverflowOpen){this.closeToolbarOverflowMenu();return}if(e.key===`Escape`&&this.presencePanelOpen){this.closePresencePanel?.();return}if(e.key===`Escape`&&this.chatIsOpen){this.closeChatPanel();return}S(e)&&(e.preventDefault(),e.stopPropagation(),this.toggleQuickSwitcher())}function Sn(e,t){let n=e.closest(`ul, ol`);return n instanceof Element&&n.parentElement===t}function Cn(e){return e.closest(`input[data-task-checkbox="true"]`)?!1:!!e.closest(`a, button, input, select, textarea, summary, [contenteditable="true"], [role="button"], [role="link"]`)}function wn(e=``){let t=String(e??``).trim();if(!t)return``;try{return decodeURIComponent(t)}catch{return t}}function Tn(e,t,{behavior:n=`smooth`}={}){if(!e||!t)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=e.scrollTop+(i.top-r.top);e.scrollTo({behavior:n,top:Math.max(a,0)})}async function En(e){await navigator.clipboard.writeText(e)}function Dn(e){if(!(e instanceof HTMLElement))return``;let t=e.cloneNode(!0);return t instanceof HTMLElement?(t.querySelectorAll(`.preview-heading-link-button`).forEach(e=>e.remove()),t.textContent.replace(/\s+/g,` `).trim()):e.textContent.trim()}function On(){return globalThis.performance?.now?.()??Date.now()}function kn(e,t,{behavior:n=`auto`}={}){if(!(e instanceof HTMLElement)||!t)return!1;if(this.outlineController?.navigateToHeading?.(e,t,{behavior:n}))return!0;let r=this.elements.previewContainer??document.getElementById(`previewContainer`);if(!r)return!1;this.scrollSyncController?.suspendSync?.(250),Tn(r,e,{behavior:n});let i=Number.parseInt(e.getAttribute(`data-source-line`)||``,10);return Number.isFinite(i)&&this.session?.scrollToLine?.(i,0),!0}function An(e){if(!this.currentFilePath||!e)return``;let t=new URL(window.location.href);return t.hash=re(this.currentFilePath,{anchor:e,drawioMode:this.currentDrawioMode??null}),t.toString()}async function jn(e){let t=this.createPreviewHeadingLinkUrl(e);if(!t){this.toastController.show(`Failed to copy section link`);return}try{await En(t),this.toastController.show(`Section link copied`)}catch{this.toastController.show(`Failed to copy section link`)}}function Mn(){let e=this.elements.previewContent?.querySelectorAll?.(`h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]`)??[];Array.from(e).forEach(e=>{if(!(e instanceof HTMLElement)||!e.id)return;let t=Dn(e),n=e.querySelector(`:scope > .preview-heading-link-button`);n instanceof HTMLButtonElement||(n=document.createElement(`button`),n.type=`button`,n.className=`ui-icon-button preview-heading-link-button`,n.innerHTML=dn,e.appendChild(n)),n.dataset.previewHeadingAnchor=e.id,n.setAttribute(`aria-label`,`Copy link to ${t}`),n.setAttribute(`title`,`Copy link to this section`)})}function Nn(e,t=this.currentFilePath){let n=String(e??``).trim();return this._pendingPreviewRouteAnchor=n?{applied:!1,appliedCount:0,anchorId:n,filePath:t??this.currentFilePath??null,stabilizeUntil:On()+ln}:null,this._pendingPreviewRouteAnchor?this.applyPendingPreviewRouteAnchor({behavior:`auto`,clearMissing:!1}):!1}function Pn({allowExpired:e=!1,behavior:t=`auto`,clearMissing:n=!1}={}){let r=this._pendingPreviewRouteAnchor;if(!r)return!1;if(!e&&r.applied&&r.stabilizeUntil<=On())return this._pendingPreviewRouteAnchor=null,!1;if(r.filePath&&this.currentFilePath&&r.filePath!==this.currentFilePath)return!1;let i=document.getElementById(r.anchorId);return!(i instanceof HTMLElement)||!this.elements.previewContent?.contains(i)?(!r.applied&&n&&r.filePath&&r.filePath===this.currentFilePath&&(this._pendingPreviewRouteAnchor=null),!1):this.navigatePreviewHeading(i,r.anchorId,{behavior:t})?(r.applied=!0,r.appliedCount=(r.appliedCount??0)+1,r.stabilizeUntil=On()+ln,r.appliedCount>=un&&(this._pendingPreviewRouteAnchor=null),!0):!1}function Fn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`button.preview-heading-link-button[data-preview-heading-anchor]`);if(t instanceof HTMLButtonElement){e.preventDefault(),this.copyPreviewHeadingLink(t.dataset.previewHeadingAnchor||``);return}let n=e.target.closest(`a.wiki-link[data-wiki-target]`);if(n){e.preventDefault(),this.handleWikiLinkClick(n.dataset.wikiTarget);return}let r=e.target.closest(`a[href]`),i=r?.getAttribute(`href`)?.trim()||``;if(r&&i.startsWith(`#`)&&!k(i)){if(e.preventDefault(),i===`#`||i.toLowerCase()===`#top`){this.scrollSyncController?.suspendSync?.(250),(this.elements.previewContainer??document.getElementById(`previewContainer`))?.scrollTo({top:0,behavior:`smooth`});return}let t=wn(i.slice(1));if(!t)return;let n=document.getElementById(t);if(!n||!this.elements.previewContent?.contains(n))return;this.navigatePreviewHeading(n,t,{behavior:`smooth`});return}let a=e.target.closest(`.task-list-item[data-source-line]`);if(!a||Sn(e.target,a)||Cn(e.target))return;e.preventDefault();let o=Number.parseInt(a.getAttribute(`data-source-line`)||``,10);Number.isFinite(o)&&this.session?.toggleTaskListItem?.(o)}function In(e){this.toolbarOverflowOpen=!!e,this.elements.toolbarOverflowToggle?.setAttribute(`aria-expanded`,String(this.toolbarOverflowOpen)),this.elements.toolbarOverflowToggle?.classList.toggle(`active`,this.toolbarOverflowOpen),this.elements.toolbarOverflowToggle?.closest(`.toolbar-right`)?.classList.toggle(`is-overflow-open`,this.toolbarOverflowOpen),this.toolbarOverflowOpen||this.elements.toolbarOverflowMenu?.querySelectorAll(`details[open]`).forEach(e=>{e.removeAttribute(`open`)})}function Ln(){let e=this.elements.toolbarOverflowToggle;e&&(e.classList.remove(`hidden`),e.hidden=!1,e.setAttribute(`aria-hidden`,`false`))}function Rn(){this.setToolbarOverflowOpen(!1)}function zn(){this.setToolbarOverflowOpen(!this.toolbarOverflowOpen)}function Bn(e){this.previewRenderer.applyTheme(e),!this.isExcalidrawFile(this.currentFilePath)&&!this.isImageFile?.(this.currentFilePath)&&this.previewRenderer.queueRender(),this.session?.applyTheme(e),this.excalidrawEmbed.updateTheme(e),this.drawioEmbed.updateTheme(e)}function Vn(e){this.connectionState=e,e?.firstConnection&&this.recordFileOpenMetric?.(`ws_connected`,{status:e.status}),this.renderPresence(),e.unreachable&&!this.connectionHelpShown&&(this.connectionHelpShown=!0,this.toastController.show(`Cannot reach server at ${e.wsBaseUrl}`,6e3))}function Hn(){let e=!(this.session?.isLineWrappingEnabled()??this.getStoredLineWrapping());this.session?.setLineWrapping(e),this.preferences.setLineWrappingEnabled(e),this.syncWrapToggle(e),this.session?.requestMeasure(),this.scrollSyncController.syncPreviewToEditor()}function Un(){return this.preferences.getLineWrappingEnabled()}function Wn(e){let t=e??this.session?.isLineWrappingEnabled()??this.getStoredLineWrapping(),n=this.elements.wrapToggleLabel,r=this.elements.toggleWrapButton,i=t?`Wrap on`:`Wrap off`;n&&(n.textContent=i),r&&r.setAttribute(`aria-label`,`${i}. ${t?`Disable line wrap`:`Enable line wrap`}`)}function Gn(){clearTimeout(this._backlinkRefreshTimer),this._backlinkRefreshTimer=setTimeout(()=>{m(this.currentFilePath)&&this.backlinksPanel.load(this.currentFilePath)},2e3)}function Kn(){this.elements.editorContainer&&(this.elements.editorContainer.classList.add(`is-loading-editor`),this.elements.editorContainer.innerHTML=`
|
|
52
|
-
<div class="editor-loading" id="editorLoading">
|
|
53
|
-
<div class="loading-spinner"></div>
|
|
54
|
-
<span class="loading-text">Loading file...</span>
|
|
55
|
-
</div>`)}function qn(){this.elements.editorContainer&&(this.elements.editorContainer.classList.remove(`is-loading-editor`),this.elements.editorContainer.querySelector(`#editorLoading`)?.remove())}function Jn(){this.elements.editorContainer&&(this.elements.editorContainer.classList.remove(`is-loading-editor`),this.elements.editorContainer.innerHTML=`
|
|
56
|
-
<div class="editor-loading" id="editorLoading">
|
|
57
|
-
<span class="loading-text">Failed to load file</span>
|
|
58
|
-
</div>`)}function Yn(){document.documentElement.removeAttribute(`data-initial-file-requested`)}var Xn={applyPendingPreviewRouteAnchor:Pn,bindEvents:yn,clearInitialFileBootstrap:Yn,closeToolbarOverflowMenu:Rn,copyPreviewHeadingLink:jn,createPreviewHeadingLinkUrl:An,getStoredLineWrapping:Un,handleConnectionChange:Vn,handleDocumentKeydown:xn,handleDocumentPointerDown:bn,handlePreviewContentClick:Fn,handleThemeChange:Bn,hideEditorLoading:qn,initialize:fn,initializeVisualViewportBinding:hn,initializeVersionMonitoring:pn,isPlainQuickSwitcherShortcut:S,navigatePreviewHeading:kn,promptForVersionReload:gn,requestPreviewRouteAnchor:Nn,scheduleBacklinkRefresh:Gn,setToolbarOverflowOpen:In,showEditorLoadError:Jn,showEditorLoading:Kn,syncPreviewHeadingLinkButtons:Mn,syncVisualViewportBounds:mn,syncToolbarOverflowVisibility:Ln,syncWrapToggle:Wn,toggleToolbarOverflowMenu:zn,toggleLineWrapping:Hn};function Zn(){return this.mobileBreakpointQuery.matches}function Qn(){let e=this.elements.sidebar;!e||!this.isMobileViewport()||e.classList.contains(`collapsed`)||this.setSidebarVisibility(!1)}function $n(){let e=this.elements.sidebar;if(!e)return;let t=e.classList.contains(`collapsed`);this.setSidebarVisibility(t)}function er(){if(!this.elements.sidebar)return;let e=this.isMobileViewport(),t=this.preferences.getSidebarVisible(),n=!0;t===`true`?n=!0:(t===`false`||e)&&(n=!1),this.applySidebarVisibility(n)}function tr(e){this.applySidebarVisibility(e),this.preferences.setSidebarVisible(e)}function nr(e){let t=this.elements.sidebar;if(!t)return;let n=!e,r=n&&this.isMobileViewport();t.classList.toggle(`collapsed`,n),t.toggleAttribute(`hidden`,r),t.setAttribute(`aria-hidden`,r?`true`:`false`),t.inert=n}function rr(e){let t=e===`git`&&this.gitRepoAvailable?`git`:`files`;this.activeSidebarTab=t,this.elements.filesSidebarTab?.classList.toggle(`active`,t===`files`),this.elements.gitSidebarTab?.classList.toggle(`active`,t===`git`),document.getElementById(`fileTree`)?.classList.toggle(`hidden`,t!==`files`),this.elements.fileSearch?.classList.toggle(`hidden`,t!==`files`),this.elements.gitSearch?.classList.toggle(`hidden`,t!==`git`),document.getElementById(`gitPanel`)?.classList.toggle(`active`,t===`git`),document.getElementById(`gitPanel`)?.classList.toggle(`hidden`,t!==`git`),this.gitPanel.setActive(t===`git`)}var ir={applySidebarVisibility:nr,closeSidebarOnMobile:Qn,isMobileViewport:Zn,restoreSidebarState:er,setSidebarTab:rr,setSidebarVisibility:tr,toggleSidebar:$n};function ar(){this.tabActivityLock.tryActivate({takeover:!0})}function or({takeover:e=!1}={}){let t=!this.isTabActive;this.isTabActive=!0,this.hideTabLockOverlay(),this.lobby.provider||this.lobby.connect(),this.workspaceSync.provider||this.workspaceSync.connect(),t&&(this.fileExplorerReady&&this.handleHashChange(),this.promptForDisplayNameIfNeeded()),e&&this.toastController.show(`This tab is now active`)}async function sr({reason:e}={}){let t=this.isTabActive,n=this.currentFilePath,r=!!(n&&this.isExcalidrawFile?.(n));this.isTabActive=!1,this.elements.displayNameDialog?.open&&this.elements.displayNameDialog.close(),this.lobby.disconnect(),this.workspaceSync.disconnect(),this.globalUsers=[],this.chatMessages=[],this.chatMessageIds.clear(),this.chatUnreadCount=0,this.chatInitialSyncComplete=!1,this.presencePanelOpen=!1,this.followedUserClientId=null,this.followedCursorSignature=``,this.connectionState={status:`disconnected`,unreachable:!1},this.showTabLockOverlay({reason:e}),r&&await this.excalidrawEmbed.prepareFileDisconnect(n),this.showEmptyState(),this.renderChat(),t&&e===`taken-over`&&this.toastController.show(`Another tab took over this session`)}function cr({reason:e}={}){let t=this.elements.tabLockOverlay,n=this.elements.tabLockTitle,r=this.elements.tabLockCopy;t&&(n&&(n.textContent=e===`taken-over`?`This tab is no longer active`:`This vault is active in another tab`),r&&(r.textContent=e===`taken-over`?`Another tab took over the live session. This tab is now disconnected until you explicitly take over here again.`:`To avoid duplicate presence and chat, only one tab can stay connected at a time. Use the other tab, or take over the session here.`),t.classList.remove(`hidden`))}function lr(){this.elements.tabLockOverlay?.classList.add(`hidden`)}var ur={handleTabActivated:or,handleTabBlocked:sr,handleTabTakeover:ar,hideTabLockOverlay:lr,showTabLockOverlay:cr},V=Object.freeze({bold:`
|
|
59
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
60
|
-
<path d="M7 5h6a4 4 0 0 1 0 8H7z"/>
|
|
61
|
-
<path d="M7 13h7a4 4 0 0 1 0 8H7z"/>
|
|
62
|
-
</svg>
|
|
63
|
-
`,italic:`
|
|
64
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
65
|
-
<path d="M14 4h6"/>
|
|
66
|
-
<path d="M4 20h6"/>
|
|
67
|
-
<path d="M14 4 10 20"/>
|
|
68
|
-
</svg>
|
|
69
|
-
`,strikethrough:`
|
|
70
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
71
|
-
<path d="M6 6.5c1.4-1.2 3.2-1.9 5.4-1.9 3.1 0 5.6 1.4 5.6 3.9 0 2.1-1.7 3-4.3 3.5l-2.4.5c-2.7.5-4.3 1.6-4.3 3.6 0 2.7 2.7 4.2 6 4.2 2.1 0 4.2-.6 5.7-1.8"/>
|
|
72
|
-
<path d="M3 12h18"/>
|
|
73
|
-
</svg>
|
|
74
|
-
`,link:`
|
|
75
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
76
|
-
<path d="M10 13a5 5 0 0 0 7.54.54l2.92-2.92a5 5 0 0 0-7.07-7.07L11.5 5.4"/>
|
|
77
|
-
<path d="M14 11a5 5 0 0 0-7.54-.54L3.54 13.38a5 5 0 1 0 7.07 7.07L12.5 18.6"/>
|
|
78
|
-
</svg>
|
|
79
|
-
`,image:`
|
|
80
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
81
|
-
<rect x="3" y="5" width="18" height="14" rx="2"/>
|
|
82
|
-
<circle cx="9" cy="10" r="1.5"/>
|
|
83
|
-
<path d="m21 16-5.5-5.5L7 19"/>
|
|
84
|
-
</svg>
|
|
85
|
-
`,video:`
|
|
86
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
87
|
-
<rect x="3" y="5" width="18" height="14" rx="2"/>
|
|
88
|
-
<path d="m10 9 5 3-5 3z" fill="currentColor" stroke="none"/>
|
|
89
|
-
</svg>
|
|
90
|
-
`,table:`
|
|
91
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
92
|
-
<rect x="3" y="5" width="18" height="14" rx="1"/>
|
|
93
|
-
<path d="M3 10h18"/>
|
|
94
|
-
<path d="M9 5v14"/>
|
|
95
|
-
<path d="M15 5v14"/>
|
|
96
|
-
</svg>
|
|
97
|
-
`,code:`
|
|
98
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
99
|
-
<path d="m8 9-4 3 4 3"/>
|
|
100
|
-
<path d="m16 9 4 3-4 3"/>
|
|
101
|
-
<path d="m13 6-2 12"/>
|
|
102
|
-
</svg>
|
|
103
|
-
`,horizontalRule:`
|
|
104
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
105
|
-
<path d="M4 12h16"/>
|
|
106
|
-
<path d="M9 8h6"/>
|
|
107
|
-
<path d="M9 16h6"/>
|
|
108
|
-
</svg>
|
|
109
|
-
`,indent:`
|
|
110
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
111
|
-
<path d="M4 6h16"/>
|
|
112
|
-
<path d="M10 12h10"/>
|
|
113
|
-
<path d="M10 18h10"/>
|
|
114
|
-
<path d="m4 9 4 3-4 3"/>
|
|
115
|
-
</svg>
|
|
116
|
-
`,outdent:`
|
|
117
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
118
|
-
<path d="M4 6h16"/>
|
|
119
|
-
<path d="M10 12h10"/>
|
|
120
|
-
<path d="M10 18h10"/>
|
|
121
|
-
<path d="m8 9-4 3 4 3"/>
|
|
122
|
-
</svg>
|
|
123
|
-
`,redo:`
|
|
124
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
125
|
-
<path d="M21 7v6h-6"/>
|
|
126
|
-
<path d="M20 13a8 8 0 0 0-14-3"/>
|
|
127
|
-
</svg>
|
|
128
|
-
`,undo:`
|
|
129
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
130
|
-
<path d="M3 7v6h6"/>
|
|
131
|
-
<path d="M4 13a8 8 0 0 1 14-3"/>
|
|
132
|
-
</svg>
|
|
133
|
-
`,chevronDown:`
|
|
134
|
-
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
135
|
-
<path d="m6 9 6 6 6-6"/>
|
|
136
|
-
</svg>
|
|
137
|
-
`}),dr=Object.freeze([{action:`paragraph`,label:`Paragraph`,shortLabel:`P`,title:`Paragraph`},{action:`heading-1`,label:`Heading 1`,shortLabel:`H1`,title:`Heading 1`},{action:`heading-2`,label:`Heading 2`,shortLabel:`H2`,title:`Heading 2`},{action:`heading-3`,label:`Heading 3`,shortLabel:`H3`,title:`Heading 3`},{action:`heading-4`,label:`Heading 4`,shortLabel:`H4`,title:`Heading 4`},{action:`heading-5`,label:`Heading 5`,shortLabel:`H5`,title:`Heading 5`},{action:`heading-6`,label:`Heading 6`,shortLabel:`H6`,title:`Heading 6`},{action:`quote`,label:`Quote`,shortLabel:`Quote`,title:`Block quote`},{action:`bullet-list`,label:`Bullet list`,shortLabel:`List`,title:`Bullet list`},{action:`numbered-list`,label:`Numbered list`,shortLabel:`1.`,title:`Numbered list`},{action:`task-list`,label:`Task list`,shortLabel:`Task`,title:`Task list`},{action:`code-block`,label:`Code block`,shortLabel:`Code`,title:`Code block`}]),fr=Object.freeze([{action:`bold`,label:`Bold`,title:`Bold`,icon:V.bold},{action:`italic`,label:`Italic`,title:`Italic`,icon:V.italic},{action:`strikethrough`,label:`Strikethrough`,title:`Strikethrough`,icon:V.strikethrough},{action:`code`,label:`Inline code`,title:`Inline code`,icon:V.code}]),pr=Object.freeze([{commandId:`undo`,label:`Undo`,title:`Undo`,icon:V.undo},{commandId:`redo`,label:`Redo`,title:`Redo`,icon:V.redo},{commandId:`indentMore`,label:`Indent`,title:`Indent`,icon:V.indent},{commandId:`indentLess`,label:`Outdent`,title:`Outdent`,icon:V.outdent}]),mr=Object.freeze([{action:`link`,label:`Insert link`,title:`Insert link`,icon:V.link},{action:`image`,label:`Insert image`,title:`Insert image`,icon:V.image},{action:`video`,label:`Insert video`,title:`Insert video`,icon:V.video}]),hr=Object.freeze([{action:`table`,label:`Insert table`,title:`Insert table`,icon:V.table},{action:`horizontal-rule`,label:`Insert horizontal rule`,title:`Insert horizontal rule`,icon:V.horizontalRule}]),gr=Object.freeze([{kind:`buttons`,groupLabel:`Edit`,actions:pr,mobileOnly:!0},{kind:`block-menu`,actions:dr},{kind:`buttons`,groupLabel:`Inline formatting`,actions:fr},{kind:`buttons`,groupLabel:`Media and links`,actions:mr},{kind:`buttons`,groupLabel:`Insert`,actions:hr}]),_r=[...dr,...fr,...mr,...hr],vr=new Map(_r.map(e=>[e.action,e]));function yr(e){return vr.get(e)??null}function br(){return dr}function xr(e){return dr.some(t=>t.action===e)}function Sr(e){return yr(e)?.shortLabel??`P`}function Cr(){return V}var wr=`image/png,image/jpeg,image/webp,image/gif,image/svg+xml`,Tr=`paragraph`;function H(e){return String(e??``).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`)}function Er(e){return e===`heading`?`heading-2`:String(e??``).trim()}function Dr(e){return e.map(e=>`<button type="button" class="ui-icon-button ui-icon-button--toolbar ui-toolbar-action" ${e.commandId?`data-editor-command="${H(e.commandId)}"`:`data-markdown-action="${H(e.action)}"`} aria-label="${H(e.label)}" title="${H(e.title)}">${e.icon}</button>`).join(``)}function Or(e){return`
|
|
138
|
-
<div class="markdown-toolbar-block-menu-shell">
|
|
139
|
-
<button
|
|
140
|
-
type="button"
|
|
141
|
-
class="ui-button ui-button--ghost markdown-toolbar-block-trigger"
|
|
142
|
-
data-markdown-block-menu-toggle
|
|
143
|
-
aria-haspopup="menu"
|
|
144
|
-
aria-expanded="false"
|
|
145
|
-
title="Block formatting"
|
|
146
|
-
>
|
|
147
|
-
<span class="markdown-toolbar-block-trigger-label" data-markdown-block-trigger-label>${H(Sr(e))}</span>
|
|
148
|
-
<span class="markdown-toolbar-block-trigger-icon" aria-hidden="true">${Cr().chevronDown}</span>
|
|
149
|
-
</button>
|
|
150
|
-
</div>
|
|
151
|
-
`}function kr(e){return br().map(t=>{let n=t.action===e;return`
|
|
152
|
-
<button
|
|
153
|
-
type="button"
|
|
154
|
-
class="markdown-toolbar-menu-item${n?` is-active`:``}"
|
|
155
|
-
data-markdown-block-action="${H(t.action)}"
|
|
156
|
-
role="menuitemradio"
|
|
157
|
-
aria-checked="${n?`true`:`false`}"
|
|
158
|
-
title="${H(t.title)}"
|
|
159
|
-
>
|
|
160
|
-
<span class="markdown-toolbar-menu-item-label">${H(t.label)}</span>
|
|
161
|
-
<span class="markdown-toolbar-menu-item-shortcut">${H(t.shortLabel)}</span>
|
|
162
|
-
</button>
|
|
163
|
-
`}).join(``)}function Ar(e){return gr.map(t=>t.kind===`block-menu`?Or(e):`
|
|
164
|
-
<div class="markdown-toolbar-group${t.mobileOnly?` markdown-toolbar-group--mobile-only`:``}" role="group" aria-label="${H(t.groupLabel)}">
|
|
165
|
-
${Dr(t.actions)}
|
|
166
|
-
</div>
|
|
167
|
-
`).join(``)}function jr(){let e=Er(this._activeMarkdownBlockAction||Tr);return xr(e)?e:Tr}function Mr(){let e=this.elements?.markdownToolbar;e&&(e.innerHTML=Ar(this.getActiveMarkdownBlockAction()),this.renderMarkdownBlockMenuPopover(),this.syncMarkdownToolbarBlockUi())}function Nr(){return this._markdownBlockMenuPopover??null}function Pr(){let e=this.elements?.editorContainer??document.body,t=this.getMarkdownBlockMenuPopover();t?t.parentElement!==e&&e?.appendChild(t):(t=document.createElement(`div`),t.className=`markdown-toolbar-popover hidden`,t.innerHTML=`<div class="markdown-toolbar-menu" data-markdown-block-menu role="menu" aria-label="Block formatting"></div>`,t.addEventListener(`click`,e=>{this.handleMarkdownToolbarClick?.(e)}),t.addEventListener(`keydown`,e=>{this.handleMarkdownToolbarKeydown?.(e)}),e?.appendChild(t),this._markdownBlockMenuPopover=t);let n=t.querySelector(`[data-markdown-block-menu]`);n&&(n.innerHTML=kr(this.getActiveMarkdownBlockAction()))}function Fr(){let e=this.elements?.markdownToolbar;if(!e)return;let t=this.getActiveMarkdownBlockAction(),n=yr(t),r=e.querySelector(`[data-markdown-block-trigger-label]`);r&&(r.textContent=Sr(t));let i=e.querySelector(`[data-markdown-block-menu-toggle]`);i&&n&&(i.setAttribute(`aria-label`,`${n.label}. Block formatting`),i.setAttribute(`title`,`${n.label}. Block formatting`));let a=Array.from(this.getMarkdownBlockMenuPopover()?.querySelectorAll(`[data-markdown-block-action]`)??[]);[...e.querySelectorAll(`[data-markdown-block-action]`),...a].forEach(e=>{let n=e.getAttribute(`data-markdown-block-action`)===t;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-checked`,n?`true`:`false`)})}function Ir(e){let t=Er(e);xr(t)&&(this._activeMarkdownBlockAction=t,this.syncMarkdownToolbarBlockUi())}function Lr(){return!!this.elements?.markdownToolbar?.classList.contains(`is-menu-open`)}function Rr(){let e=this.getMarkdownBlockMenuPopover(),t=this.elements?.markdownToolbar?.querySelector(`[data-markdown-block-menu-toggle]`),n=e?.parentElement;if(!e||!t||!(n instanceof HTMLElement))return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=e.getBoundingClientRect(),o=a.width||176,s=a.height||240,c=r.left-i.left,l=Math.max(8,i.width-o-8),u=r.bottom-i.top+6,d=u+s<=i.height-8;e.style.left=`${Math.max(8,Math.min(c,l))}px`,e.style.top=`${d?u:Math.max(8,r.top-i.top-s-6)}px`}function zr(){let e=this.elements?.markdownToolbar;e&&(this.renderMarkdownBlockMenuPopover(),e.classList.add(`is-menu-open`),this.getMarkdownBlockMenuPopover()?.classList.remove(`hidden`),e.querySelector(`[data-markdown-block-menu-toggle]`)?.setAttribute(`aria-expanded`,`true`),this.positionMarkdownBlockMenu())}function Br(){let e=this.elements?.markdownToolbar;e&&(e.classList.remove(`is-menu-open`),this.getMarkdownBlockMenuPopover()?.classList.add(`hidden`),e.querySelector(`[data-markdown-block-menu-toggle]`)?.setAttribute(`aria-expanded`,`false`))}function Vr(){if(this.isMarkdownBlockMenuOpen()){this.closeMarkdownBlockMenu();return}this.openMarkdownBlockMenu()}function Hr(e){let t=e.target instanceof Element?e.target:null;if(!t)return;let n=t.closest(`[data-editor-command]`)?.getAttribute(`data-editor-command`);if(n){e.preventDefault(),this.runEditorCommand(n);return}if(t.closest(`[data-markdown-block-menu-toggle]`)){e.preventDefault(),this.toggleMarkdownBlockMenu();return}let r=t.closest(`[data-markdown-block-action]`);if(r){e.preventDefault();let t=r.getAttribute(`data-markdown-block-action`);this.closeMarkdownBlockMenu(),t&&this.applyMarkdownToolbarAction(t);return}let i=t.closest(`[data-markdown-action]`)?.getAttribute(`data-markdown-action`);i&&this.applyMarkdownToolbarAction(i)}function Ur(e){if(!this.isMarkdownBlockMenuOpen()){e.target instanceof Element&&e.target.closest(`[data-markdown-block-menu-toggle]`)&&[`ArrowDown`,`Enter`,` `].includes(e.key)&&(e.preventDefault(),this.openMarkdownBlockMenu(),this.getMarkdownBlockMenuPopover()?.querySelector(`[data-markdown-block-action]`)?.focus());return}if(e.key===`Escape`){e.preventDefault(),this.closeMarkdownBlockMenu(),this.elements?.markdownToolbar?.querySelector(`[data-markdown-block-menu-toggle]`)?.focus();return}let t=Array.from(this.getMarkdownBlockMenuPopover()?.querySelectorAll(`[data-markdown-block-action]`)??[]);if(t.length===0)return;let n=t.findIndex(t=>t===e.target);n<0||(e.key===`ArrowDown`?(e.preventDefault(),t[(n+1)%t.length]?.focus()):e.key===`ArrowUp`&&(e.preventDefault(),t[(n-1+t.length)%t.length]?.focus()))}function Wr(e){this.isMarkdownBlockMenuOpen()&&(this.elements?.markdownToolbar?.contains(e.target)||this.getMarkdownBlockMenuPopover()?.contains(e.target)||this.closeMarkdownBlockMenu())}function Gr(e){if(!this.session||!u(this.currentFilePath))return;if(e===`image`){this.handleToolbarImageInsert();return}let t=Er(e);if(!this.session.applyMarkdownToolbarAction(t)){this.toastController.show(`Formatting action is unavailable`);return}xr(t)&&this.setActiveMarkdownBlockAction(t)}function Kr(e){return this.session?.runEditorCommand?.(e)?!0:(this.toastController.show(`Editor action is unavailable`),!1)}async function qr(){let e=await this.pickImageFile();e&&await this.handleEditorImageInsert(e)}function Jr(){return new Promise(e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=wr,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t);let n=!1,r=null,i=i=>{n||(n=!0,r&&window.clearTimeout(r),window.removeEventListener(`focus`,a),t.remove(),e(i))},a=()=>{r=window.setTimeout(()=>{n||t.files?.length||i(null)},250)};t.addEventListener(`change`,()=>{i(t.files?.[0]??null)},{once:!0}),t.addEventListener(`cancel`,()=>{i(null)},{once:!0}),window.addEventListener(`focus`,a,{once:!0}),t.click()})}async function Yr(e){if(!this.session||!u(this.currentFilePath))return console.warn(`[ui] Ignoring image insert because there is no active markdown session.`,{currentFilePath:this.currentFilePath,hasSession:!!this.session}),!1;let t=this.currentFilePath,n=this.session;try{console.debug(`[ui] Uploading image attachment.`,{fileName:e?.name||``,size:e?.size??null,sourcePath:t,type:e?.type||``});let r=await this.vaultApiClient.uploadImageAttachment({file:e,fileName:e?.name||``,sourcePath:t});return await this.fileExplorer.refresh(),this.currentFilePath===t&&this.session&&this.session===n&&typeof r?.markdown==`string`&&(console.debug(`[ui] Inserting uploaded image markdown into the editor.`,{sourcePath:t,storedPath:r.path??``}),this.session.insertText(r.markdown)),!0}catch(e){return console.error(`[ui] Failed to insert image attachment:`,e),this.toastController.show(e.message||`Failed to upload image`),!1}}async function Xr(){try{await navigator.clipboard.writeText(window.location.href),this.toastController.show(`Link copied`)}catch{this.toastController.show(`Failed to copy link`)}}var Zr={applyMarkdownToolbarAction:Gr,copyCurrentLink:Xr,closeMarkdownBlockMenu:Br,getActiveMarkdownBlockAction:jr,getMarkdownBlockMenuPopover:Nr,handleEditorImageInsert:Yr,handleMarkdownToolbarClick:Hr,handleMarkdownToolbarDocumentPointerDown:Wr,handleMarkdownToolbarKeydown:Ur,handleToolbarImageInsert:qr,isMarkdownBlockMenuOpen:Lr,openMarkdownBlockMenu:zr,positionMarkdownBlockMenu:Rr,renderMarkdownBlockMenuPopover:Pr,pickImageFile:Jr,renderMarkdownToolbar:Mr,runEditorCommand:Kr,setActiveMarkdownBlockAction:Ir,syncMarkdownToolbarBlockUi:Fr,toggleMarkdownBlockMenu:Vr},U={...Xn,...ir,...sn,...Zr,...ur},W={isExcalidrawFile(e){return g(e)},isBaseFile(e){return l(e)},isDrawioFile(e){return p(e)},isImageFile(e){return o(e)},isMermaidFile(e){return v(e)},isPlantUmlFile(e){return s(e)},createDiagramPreviewDocument(e,t=``){return this.workspacePreviewController.createDiagramPreviewDocument(e,t)},getPreviewSource(){let e=this.getStaticPreviewDocument?.(),t=e?.currentFilePath??e?.filePath??null;return e&&t&&t===this.currentFilePath?this.isMermaidFile(this.currentFilePath)?this.createDiagramPreviewDocument(`mermaid`,e.content):this.isPlantUmlFile(this.currentFilePath)?this.createDiagramPreviewDocument(`plantuml`,e.content):String(e.content??``):this.workspacePreviewController.getPreviewSource(this.currentFilePath,{drawioMode:this.currentDrawioMode??null})},getStaticPreviewDocument(){return this._staticPreviewDocument??null},setStaticPreviewDocument(e){let t=e?.filePath??e?.path??null,n=e?.currentFilePath??t;this._staticPreviewDocument=e?{content:String(e.content??``),currentFilePath:n,fileKind:e.fileKind??f(t),filePath:t,hash:e.hash??null}:null},clearStaticPreviewDocument(){this._staticPreviewDocument=null},supportsFileHistory(e){let t=f(e);return t!==null&&t!==`image`},getDisplayName(e){return c(String(e??``).split(`/`).pop())},resetPreviewMode(){this.workspacePreviewController.resetPreviewMode()},syncFileChrome(e,t={}){this.workspacePreviewController.syncFileChrome(e,t)},handleLayoutViewRequest(e){return!this.currentFilePath||!this.isDrawioFile(this.currentFilePath)?!0:this.currentDrawioMode===`text`?e===`preview`?(this.layoutController.isMobileViewport?.()&&this.layoutController.primeView(e),this.navigation.navigateToFile(this.currentFilePath),!1):!0:e===`preview`?!0:(this.layoutController.primeView(e),this.navigation.navigateToFile(this.currentFilePath,{drawioMode:`text`}),!1)},renderExcalidrawFilePreview(e){this.workspacePreviewController.renderExcalidrawFilePreview(e)},renderDrawioFilePreview(e){this.workspacePreviewController.renderDrawioFilePreview(e)},renderImageFilePreview(e){this.workspacePreviewController.renderImageFilePreview(e)},renderBaseFilePreview(e){return this.workspacePreviewController.renderBaseFilePreview(e)},renderTextFilePreview(e){this.workspacePreviewController.renderTextFilePreview(e)},createResizeHandler(){return this.workspacePreviewController.createResizeHandler(()=>this.restoreSidebarState())},initializePreviewLayoutObserver(){this._previewLayoutResizeObserver?.disconnect(),this._previewLayoutResizeObserver=this.workspacePreviewController.initializePreviewLayoutObserver(()=>this.schedulePreviewLayoutSync())},schedulePreviewLayoutSync({delayMs:e=120}={}){this.workspacePreviewController.schedulePreviewLayoutSync({delayMs:e,hydrationPaused:this._previewHydrationPaused,previewLayoutSyncTimer:this._previewLayoutSyncTimer,setPendingPreviewLayoutSync:e=>{this._pendingPreviewLayoutSync=e},setPreviewLayoutSyncTimer:e=>{this._previewLayoutSyncTimer=e}})},handleEditorScrollActivityChange(e){this.workspacePreviewController.handleEditorScrollActivityChange({isActive:e,pendingPreviewLayoutSync:this._pendingPreviewLayoutSync,previewLayoutSyncTimer:this._previewLayoutSyncTimer,setHydrationPaused:e=>{this._previewHydrationPaused=e},setPendingPreviewLayoutSync:e=>{this._pendingPreviewLayoutSync=e},setPreviewLayoutSyncTimer:e=>{this._previewLayoutSyncTimer=e}})},async handleHashChange(){await this.workspaceRouteController.handleHashChange()},showEmptyState(){clearTimeout(this._previewLayoutSyncTimer),this._previewLayoutSyncTimer=null,this._pendingPreviewLayoutSync=!1,this._previewHydrationPaused=!1,this.workspaceRouteController.showEmptyState()},showDiffState(){clearTimeout(this._previewLayoutSyncTimer),this._previewLayoutSyncTimer=null,this._pendingPreviewLayoutSync=!1,this._previewHydrationPaused=!1,this.workspaceRouteController.showDiffState()},async openFile(e){await this.workspaceRouteController.openFile(e)},cleanupSession(){this.workspaceRouteController.cleanupSession()},handleWikiLinkClick(e){this.wikiLinkFileController.handleWikiLinkClick(e)},normalizeNewWikiFilePath(e){return this.wikiLinkFileController.normalizeNewWikiFilePath(e)},async createAndOpenFile(e,t){await this.wikiLinkFileController.createAndOpenFile(e,t)},handleFileSelection(e,{closeSidebarOnMobile:t=!1,revealInTree:n=!1}={}){this.workspaceRouteController.handleFileSelection(e,{closeSidebarOnMobile:t,revealInTree:n})}},Qr=`__lobby__`;function $r(e){return String(e??``).replace(/\s+/g,` `).trim().slice(0,280)||null}function ei(e){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${e||`user`}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ti(e){if(!e||typeof e!=`object`||typeof e.id!=`string`)return null;let t=e.workspaceChange&&typeof e.workspaceChange==`object`?e.workspaceChange:{};return{action:typeof e.action==`string`?e.action:`git`,createdAt:Number.isFinite(e.createdAt)?e.createdAt:Date.now(),id:e.id,peerId:typeof e.peerId==`string`?e.peerId:null,sourceRef:typeof e.sourceRef==`string`?e.sourceRef:null,workspaceChange:{changedPaths:Array.isArray(t.changedPaths)?t.changedPaths.filter(Boolean):[],deletedPaths:Array.isArray(t.deletedPaths)?t.deletedPaths.filter(Boolean):[],refreshExplorer:t.refreshExplorer!==!1,renamedPaths:Array.isArray(t.renamedPaths)?t.renamedPaths.filter(e=>e?.oldPath&&e?.newPath):[]}}}var ni=class{constructor({preferredUserName:e,onChange:t,onChatChange:n,onWorkspaceEvent:r}){this.onChange=t,this.onChatChange=n,this.onWorkspaceEvent=r,this.wsBaseUrl=ie(),this.ydoc=new ue,this.chatMessages=this.ydoc.getArray(`chat-messages`),this.workspaceEvents=this.ydoc.getArray(`workspace-events`),this.provider=null,this.awareness=null,this.localUser=De(e),this.currentFile=null,this._connected=!1,this._didInitialSync=!1,this.seenWorkspaceEventIds=new Set,this.handleAwarenessChange=()=>{this._emitChange()},this.handleChatMessagesChange=()=>{this._emitChatChange()},this.handleWorkspaceEventsChange=()=>{this._emitWorkspaceEvents()}}connect(){this.provider||(this._didInitialSync=!1,this.provider=new le(this.wsBaseUrl,Qr,this.ydoc,{disableBc:!0,maxBackoffTime:5e3}),A(this.provider),this.awareness=this.provider.awareness,this.awareness.setLocalStateField(`user`,this.localUser),this.awareness.setLocalStateField(`currentFile`,this.currentFile),this.awareness.on(`change`,this.handleAwarenessChange),this.chatMessages.observe(this.handleChatMessagesChange),this.workspaceEvents.observe(this.handleWorkspaceEventsChange),this.provider.on(`status`,({status:e})=>{this._connected=e===`connected`}),this.provider.on(`sync`,e=>{!e||this._didInitialSync||(this._didInitialSync=!0,this._primeWorkspaceEventCache(),this._emitChange(),this._emitChatChange({initial:!0}))}))}setCurrentFile(e){this.currentFile=e,this.awareness&&this.awareness.setLocalStateField(`currentFile`,e)}setUserName(e){e&&(this.localUser={...this.localUser,name:e},this.awareness&&this.awareness.setLocalStateField(`user`,this.localUser))}getLocalUser(){return this.localUser}sendChatMessage(e){let t=$r(e);if(!t)return null;let n={createdAt:Date.now(),filePath:this.currentFile??null,id:ei(this.localUser.peerId),peerId:this.localUser.peerId,text:t,userColor:this.localUser.color,userName:this.localUser.name};return this.ydoc.transact(()=>{this.chatMessages.push([n]);let e=this.chatMessages.length-40;e>0&&this.chatMessages.delete(0,e)},`lobby-chat-message`),n}sendWorkspaceEvent({action:e=`git`,sourceRef:t=null,workspaceChange:n={}}={}){let r=ti({action:e,createdAt:Date.now(),id:ei(this.localUser.peerId),peerId:this.localUser.peerId,sourceRef:t,workspaceChange:n});return r?(this.ydoc.transact(()=>{this.workspaceEvents.push([r]);let e=this.workspaceEvents.length-40;e>0&&this.workspaceEvents.delete(0,e)},`lobby-workspace-event`),this.seenWorkspaceEventIds.add(r.id),r):null}getMessages(){return this.chatMessages.toArray().filter(e=>e&&typeof e.id==`string`&&typeof e.peerId==`string`&&typeof e.text==`string`&&typeof e.userName==`string`)}getUsers(){if(!this.awareness)return[];let e=[];return this.awareness.getStates().forEach((t,n)=>{t.user&&e.push({...t.user,clientId:n,currentFile:t.currentFile??null,isLocal:n===this.awareness.clientID})}),e}getConnectionState(){return this._connected?{status:`connected`,unreachable:!1}:this.provider?{status:`connecting`,unreachable:!1}:{status:`disconnected`,unreachable:!1}}disconnect(){this.provider&&(this.awareness?.off(`change`,this.handleAwarenessChange),this.chatMessages?.unobserve(this.handleChatMessagesChange),this.workspaceEvents?.unobserve(this.handleWorkspaceEventsChange)),this.provider?.disconnect(),this.provider?.destroy(),this.provider=null,this.awareness=null,this._connected=!1,this._didInitialSync=!1,this.seenWorkspaceEventIds.clear()}destroy(){this.disconnect(),this.ydoc?.destroy(),this.ydoc=null}_emitChange(){this.onChange?.(this.getUsers())}_emitChatChange(e={}){this.onChatChange?.(this.getMessages(),e)}_primeWorkspaceEventCache(){this.workspaceEvents.toArray().forEach(e=>{let t=ti(e);t&&this.seenWorkspaceEventIds.add(t.id)})}_emitWorkspaceEvents(){if(!this._didInitialSync){this._primeWorkspaceEventCache();return}this.workspaceEvents.toArray().forEach(e=>{let t=ti(e);!t||this.seenWorkspaceEventIds.has(t.id)||(this.seenWorkspaceEventIds.add(t.id),t.peerId!==this.localUser.peerId&&this.onWorkspaceEvent?.(t))})}},ri=class{getHashRoute(){return ce()}navigateToFile(e,t){oe(e,t)}navigateToGitDiff(e){T(e)}navigateToGitCommit(e){ne(e)}navigateToGitHistory(){ee()}navigateToGitFileHistory(e){ae(e)}navigateToGitFilePreview(e){se(e)}},ii=class{constructor({NotificationImpl:e=globalThis.Notification,focusWindow:t=()=>globalThis.window?.focus?.()}={}){this.NotificationImpl=e,this.focusWindow=t}getPermission(){return typeof this.NotificationImpl==`function`?this.NotificationImpl.permission:`unsupported`}async requestPermission(){return typeof this.NotificationImpl==`function`?this.NotificationImpl.requestPermission():`unsupported`}createNotification({body:e,onClick:t,tag:n,title:r}){if(typeof this.NotificationImpl!=`function`)return null;let i=new this.NotificationImpl(r,{body:e,tag:n});return typeof t==`function`&&i.addEventListener(`click`,()=>{this.focusWindow(),t()}),i}},ai=class{constructor({chatNotificationsKey:e,lineWrappingKey:t,sidebarVisibleKey:n,userNameKey:r,storage:i=globalThis.localStorage}){this.chatNotificationsKey=e,this.lineWrappingKey=t,this.sidebarVisibleKey=n,this.storage=i,this.userNameKey=r}getUserName(){try{return this.storage.getItem(this.userNameKey)||``}catch{return``}}setUserName(e){try{this.storage.setItem(this.userNameKey,e)}catch{}}getLineWrappingEnabled(){try{return this.storage.getItem(this.lineWrappingKey)!==`false`}catch{return!0}}setLineWrappingEnabled(e){try{this.storage.setItem(this.lineWrappingKey,String(e))}catch{}}getSidebarVisible(){try{return this.storage.getItem(this.sidebarVisibleKey)}catch{return null}}setSidebarVisible(e){try{this.storage.setItem(this.sidebarVisibleKey,e?`true`:`false`)}catch{}}getChatNotificationsEnabled(){try{return this.storage.getItem(this.chatNotificationsKey)===`true`}catch{return!1}}setChatNotificationsEnabled(e){try{this.storage.setItem(this.chatNotificationsKey,String(e))}catch{}}},oi=6e4;function si(e){return String(e?.build?.id??e?.buildId??``).trim()}var ci=class{constructor({currentBuildId:e=``,documentRef:t=globalThis.document??null,fetchImpl:n=globalThis.fetch?.bind(globalThis),intervalMs:r=oi,onUpdateAvailable:i=null,runtimeConfig:a={basePath:``},versionUrl:o=null,windowRef:s=globalThis.window??globalThis}={}){this.currentBuildId=String(e??``).trim(),this.documentRef=t,this.fetchImpl=n,this.intervalHandle=null,this.intervalMs=Math.max(5e3,Number(r)||oi),this.isChecking=!1,this.onUpdateAvailable=typeof i==`function`?i:null,this.runtimeConfig=a,this.updateDetected=!1,this.versionUrl=o||te(`/version.json`,a),this.windowRef=s,this.handleFocus=()=>{this.checkNow({force:!0})},this.handleVisibilityChange=()=>{this.documentRef?.hidden||this.checkNow({force:!0})}}start(){!this.fetchImpl||this.intervalHandle||(this.documentRef?.addEventListener?.(`visibilitychange`,this.handleVisibilityChange),this.windowRef?.addEventListener?.(`focus`,this.handleFocus),this.intervalHandle=this.windowRef?.setInterval?.(()=>{this.checkNow()},this.intervalMs)??null,this.checkNow({force:!0}))}stop(){this.intervalHandle&&=(this.windowRef?.clearInterval?.(this.intervalHandle),null),this.documentRef?.removeEventListener?.(`visibilitychange`,this.handleVisibilityChange),this.windowRef?.removeEventListener?.(`focus`,this.handleFocus)}async checkNow({force:e=!1}={}){if(!this.fetchImpl||this.isChecking||this.updateDetected||!e&&this.documentRef?.hidden)return!1;this.isChecking=!0;try{let e=await this.fetchImpl(this.versionUrl,{cache:`no-store`,headers:{Accept:`application/json`}});if(!e?.ok)return!1;let t=await e.json().catch(()=>null),n=si(t);return n?this.currentBuildId?n===this.currentBuildId?!1:(this.updateDetected=!0,this.onUpdateAvailable?.(t),!0):(this.currentBuildId=n,!1):!1}catch{return!1}finally{this.isChecking=!1}}},li=new class{async readBacklinks(e,{signal:t}={}){let n=await fetch(E(`/backlinks?file=${encodeURIComponent(e)}`),{signal:t}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`Failed to load backlinks`);return Array.isArray(r.backlinks)?r.backlinks:[]}};function ui(e,t={}){let n={...t};return e&&(n[`X-CollabMD-Request-Id`]=String(e)),n}async function di(e,t){let n=await e.json().catch(()=>({}));if(!e.ok||n.ok===!1){let r=Error(n.error||t);throw r.status=e.status,r.body=n,typeof n?.code==`string`&&(r.code=n.code),r}return n}function fi(e={}){let t=new URLSearchParams;return Object.entries(e).forEach(([e,n])=>{n==null||n===``||t.set(e,String(n))}),t}var pi=new class{async readStatus({force:e=!1}={}){return di(await fetch(E(`/git/status${e?`?force=true`:``}`)),`Failed to load git status`)}async readPullBackups(){return di(await fetch(E(`/git/pull-backups`)),`Failed to load pull backups`)}async readHistory({limit:e,offset:t}={}){let n=fi({limit:e,offset:t});return di(await fetch(E(`/git/history?${n.toString()}`)),`Failed to load git history`)}async readFileHistory({path:e,limit:t,offset:n}={}){let r=fi({limit:t,offset:n,path:e});return di(await fetch(E(`/git/file-history?${r.toString()}`)),`Failed to load file history`)}async readDiff({allowLargePatch:e=!1,metaOnly:t=!1,path:n=null,scope:r=`all`}={}){let i=fi({allowLargePatch:e?`true`:null,metaOnly:t?`true`:null,path:n,scope:r});return di(await fetch(E(`/git/diff?${i.toString()}`)),`Failed to load git diff`)}async readCommit({allowLargePatch:e=!1,hash:t,metaOnly:n=!1,path:r=null}={}){let i=fi({allowLargePatch:e?`true`:null,hash:t,metaOnly:n?`true`:null,path:r});return di(await fetch(E(`/git/commit?${i.toString()}`)),`Failed to load git commit`)}async readFileSnapshot({hash:e,path:t}={}){let n=fi({hash:e,path:t});return di(await fetch(E(`/git/file-snapshot?${n.toString()}`)),`Failed to load historical file preview`)}async stageFile({path:e,requestId:t=null}={}){return this.#e(`/git/stage`,{path:e},{requestId:t,fallbackError:`Failed to stage file`})}async unstageFile({path:e,requestId:t=null}={}){return this.#e(`/git/unstage`,{path:e},{requestId:t,fallbackError:`Failed to unstage file`})}async pushBranch({requestId:e=null}={}){return this.#e(`/git/push`,{},{requestId:e,fallbackError:`Failed to push branch`})}async pullBranch({requestId:e=null}={}){return this.#e(`/git/pull`,{},{requestId:e,fallbackError:`Failed to pull branch`})}async resetFile({path:e,requestId:t=null}={}){return this.#e(`/git/reset-file`,{path:e},{requestId:t,fallbackError:`Failed to reset file`})}async commit({message:e,requestId:t=null}={}){return this.#e(`/git/commit`,{message:e},{requestId:t,fallbackError:`Failed to commit staged changes`})}async#e(e,t,{fallbackError:n,requestId:r=null}={}){return di(await fetch(E(e),{body:JSON.stringify(t),headers:ui(r,{"Content-Type":`application/json`}),method:`POST`}),n)}},mi=new class{async renderSvg(e){let t=await fetch(E(`/plantuml/render`),{body:JSON.stringify({source:e}),headers:{"Content-Type":`application/json`},method:`POST`}),n=await t.json().catch(()=>null);if(!t.ok||!n?.ok||typeof n.svg!=`string`)throw Error(n?.error||`Failed to render PlantUML`);return n.svg}},hi=`collabmd-active-tab-lock`,gi=`collabmd-tab-id`,_i=`collabmd-tab-lock`,vi=4e3;function yi(){return Date.now()}function bi(){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`tab-${yi()}-${Math.random().toString(36).slice(2,10)}`}function xi(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var Si=class{constructor({heartbeatIntervalMs:e=vi,onBlocked:t,onActivated:n,onStolen:r}={}){this.heartbeatIntervalMs=e,this.staleAfterMs=e*3,this.onBlocked=t,this.onActivated=n,this.onStolen=r,this.tabId=this.getOrCreateTabId(),this.channel=null,this.heartbeatTimer=null,this.isOwner=!1,this.handleStorageEvent=this.handleStorageEvent.bind(this),this.handlePageHide=this.handlePageHide.bind(this)}initialize(){window.addEventListener(`storage`,this.handleStorageEvent),window.addEventListener(`pagehide`,this.handlePageHide),`BroadcastChannel`in globalThis&&(this.channel=new BroadcastChannel(_i),this.channel.addEventListener(`message`,e=>{this.handleChannelMessage(e.data)}))}destroy(){this.release(),window.removeEventListener(`storage`,this.handleStorageEvent),window.removeEventListener(`pagehide`,this.handlePageHide),this.channel?.close(),this.channel=null}tryActivate({takeover:e=!1}={}){let t=this.readLock();return this.isFreshLock(t)&&t.tabId!==this.tabId&&!e?(this.isOwner=!1,this.stopHeartbeat(),this.onBlocked?.({reason:`active-elsewhere`,ownerTabId:t.tabId}),!1):(this.writeLock(),this.startHeartbeat(),this.isOwner=!0,this.channel?.postMessage({type:`claimed`,takeover:e,tabId:this.tabId}),this.onActivated?.({takeover:e}),!0)}release(){this.readLock()?.tabId===this.tabId&&(localStorage.removeItem(hi),this.channel?.postMessage({type:`released`,tabId:this.tabId})),this.isOwner=!1,this.stopHeartbeat()}getOrCreateTabId(){try{let e=window.sessionStorage.getItem(gi);if(e)return e;let t=bi();return window.sessionStorage.setItem(gi,t),t}catch{return bi()}}readLock(){try{return xi(window.localStorage.getItem(hi))}catch{return null}}isFreshLock(e){return!!(e&&typeof e.tabId==`string`&&Number.isFinite(e.updatedAt)&&yi()-e.updatedAt<this.staleAfterMs)}writeLock(){try{window.localStorage.setItem(hi,JSON.stringify({tabId:this.tabId,updatedAt:yi()}))}catch{}}startHeartbeat(){this.stopHeartbeat(),this.writeLock(),this.heartbeatTimer=window.setInterval(()=>{if(!this.isOwner){this.stopHeartbeat();return}this.writeLock()},this.heartbeatIntervalMs)}stopHeartbeat(){this.heartbeatTimer&&=(window.clearInterval(this.heartbeatTimer),null)}handleStorageEvent(e){if(e.key!==hi)return;let t=xi(e.newValue);this.handleExternalLockChange(t)}handleChannelMessage(e){!e||typeof e!=`object`||e.tabId===this.tabId||e.type===`claimed`&&this.handleExternalLockChange(this.readLock())}handleExternalLockChange(e){this.isOwner&&this.isFreshLock(e)&&e.tabId!==this.tabId&&(this.isOwner=!1,this.stopHeartbeat(),this.onStolen?.({ownerTabId:e.tabId}))}handlePageHide(){this.release()}},Ci=`__workspace__`;function wi(e=``){return String(e??``).trim().replace(/\\/g,`/`).split(`/`).filter(Boolean).join(`/`)}function Ti(e=``){let t=wi(e);if(!t)return``;let n=t.lastIndexOf(`/`);return n>=0?t.slice(0,n):``}function Ei(e={}){return Ti(e?.path??``)}function Di(e){return!e?.path||!e?.type?null:e.nodeType===`directory`||e.type===`directory`?{children:[],name:e.name,path:e.path,type:`directory`}:{name:e.name,path:e.path,type:e.type}}function Oi(e=[]){return e.sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),e.forEach(e=>{Array.isArray(e.children)&&Oi(e.children)}),e}function ki(e){return e instanceof Map?e:new Map(Object.entries(e??{}))}function Ai(e=[],t=`asc`){let n=t===`desc`?-1:1;return[...e].sort((e,t)=>{let r=e.split(`/`).length-t.split(`/`).length;return r===0?e.localeCompare(t,void 0,{sensitivity:`base`})*n:r*n})}var ji=class{constructor(){this.entriesByPath=new Map,this.nodesByPath=new Map,this.nodeParentPathByPath=new Map,this.roots=[]}reset(e){return this.entriesByPath=ki(e),this.nodesByPath=new Map,this.nodeParentPathByPath=new Map,this.roots=[],this.entriesByPath.forEach(e=>{let t=Di(e);t&&this.nodesByPath.set(e.path,t)}),Ai(Array.from(this.nodesByPath.keys())).forEach(e=>{let t=this.nodesByPath.get(e);t&&this.attachNode(e,t,Ei(this.entriesByPath.get(e)))}),Oi(this.roots),this.roots}getTree(){return this.roots}applyMapChanges(e,t){let n=[],r=[];return e.forEach((e,t)=>{e.action===`delete`?n.push(t):r.push(t)}),Ai(n,`desc`).forEach(e=>{this.removeEntry(e)}),Ai(r).forEach(e=>{this.upsertEntry(e,t.get(e))}),Oi(this.roots),this.roots}removeEntry(e){let t=this.nodesByPath.get(e);if(!t){this.entriesByPath.delete(e),this.nodeParentPathByPath.delete(e);return}this.detachNode(e,t),this.nodesByPath.delete(e),this.entriesByPath.delete(e),this.nodeParentPathByPath.delete(e)}upsertEntry(e,t){if(!t?.path||!t?.type){this.removeEntry(e);return}let n=Di(t);if(!n){this.removeEntry(e);return}let r=this.nodesByPath.get(e);!r||r.type===`directory`!=(n.type===`directory`)?(r&&this.detachNode(e,r),r=n,this.nodesByPath.set(e,r)):(r.name=n.name,r.path=n.path,r.type=n.type,r.type===`directory`&&!Array.isArray(r.children)&&(r.children=[]),r.type!==`directory`&&Array.isArray(r.children)&&delete r.children),this.entriesByPath.set(e,t),this.attachNode(e,r,Ei(t)),r.type===`directory`&&this.rehomeChildren(e)}detachNode(e,t){let n=this.nodeParentPathByPath.get(e)||``,r=n?this.nodesByPath.get(n)?.children:this.roots,i=r?.indexOf?.(t)??-1;i>=0&&r.splice(i,1),this.nodeParentPathByPath.delete(e)}attachNode(e,t,n=``){let r=this.nodesByPath.get(n)?.type===`directory`?n:``,i=this.nodeParentPathByPath.get(e);if(i===r)return;i!==void 0&&this.detachNode(e,t);let a=r?this.nodesByPath.get(r)?.children:this.roots;a.includes(t)||a.push(t),this.nodeParentPathByPath.set(e,r)}rehomeChildren(e){this.entriesByPath.forEach((t,n)=>{if(Ei(t)!==e)return;let r=this.nodesByPath.get(n);r&&this.attachNode(n,r,e)})}},Mi=class{constructor({onTreeChange:e=()=>{},onWorkspaceEvent:t=()=>{}}={}){this.onTreeChange=e,this.onWorkspaceEvent=t,this.ydoc=new ue,this.entries=this.ydoc.getMap(`entries`),this.events=this.ydoc.getArray(`events`),this.provider=null,this._didInitialSync=!1,this.seenEventIds=new Set,this.treeModel=new ji,this.handleEntriesChange=e=>{!this._didInitialSync||!e||this.onTreeChange(this.treeModel.applyMapChanges(e.changes.keys,this.entries),{changedPaths:Array.from(e.changes.keys.keys()),reset:!1})},this.handleEventsChange=()=>{if(!this._didInitialSync){this.primeEventCache();return}this.events.toArray().forEach(e=>{let t=Ht(e);!t||this.seenEventIds.has(t.id)||(this.seenEventIds.add(t.id),this.onWorkspaceEvent(t))})}}connect(){this.provider||(this._didInitialSync=!1,this.provider=new le(ie(),Ci,this.ydoc,{disableBc:!0,maxBackoffTime:5e3}),A(this.provider),this.entries.observe(this.handleEntriesChange),this.events.observe(this.handleEventsChange),this.provider.on(`sync`,e=>{!e||this._didInitialSync||(this._didInitialSync=!0,this.primeEventCache(),this.onTreeChange(this.treeModel.reset(this.entries.toJSON()),{changedPaths:[],reset:!0}))}))}primeEventCache(){this.events.toArray().forEach(e=>{let t=Ht(e);t&&this.seenEventIds.add(t.id)})}disconnect(){this.entries.unobserve(this.handleEntriesChange),this.events.unobserve(this.handleEventsChange),this.provider?.disconnect(),this.provider?.destroy(),this.provider=null,this._didInitialSync=!1,this.seenEventIds.clear(),this.treeModel.reset(new Map)}destroy(){this.disconnect(),this.ydoc.destroy()}},Ni=class{constructor({documentRef:e=document,headerPanelElement:t=null,inlinePanelElement:n=null,loadBacklinks:r=null,onFileSelect:i,panelElement:a}){this.documentRef=e,this.headerPanel=t,this.panelRoot=a,this.inlinePanel=n,this.loadBacklinks=r,this.onFileSelect=i,this._expanded=!1,this._currentFile=null,this._displayMode=`dock`,this._fetchController=null,this._backlinks=[],this._pendingOutsidePointer=null;let o=this.panelRoot?.querySelector(`[data-backlinks-variant="dock"]`)??this.panelRoot;this.panels=[this._createPanelRef(o,this.panelRoot),this._createPanelRef(this.headerPanel,this.headerPanel),this._createPanelRef(this.inlinePanel,this.inlinePanel)].filter(Boolean),this.handleDocumentPointerDown=e=>{if(!this._expanded)return;let t=e?.target;if(t&&this.panels.some(({panel:e})=>e?.contains?.(t))){this._pendingOutsidePointer=null;return}e?.pointerType===`mouse`&&e?.button!==0||(this._pendingOutsidePointer={pointerId:e?.pointerId??`mouse`,startX:Number(e?.clientX??0),startY:Number(e?.clientY??0)})},this.handleDocumentPointerMove=e=>{if(!this._pendingOutsidePointer)return;let t=Math.abs(Number(e?.clientX??0)-this._pendingOutsidePointer.startX),n=Math.abs(Number(e?.clientY??0)-this._pendingOutsidePointer.startY);(t>10||n>10)&&(this._pendingOutsidePointer=null)},this.handleDocumentPointerEnd=e=>{if(!this._expanded||!this._pendingOutsidePointer)return;let t=e?.target;if(t&&this.panels.some(({panel:e})=>e?.contains?.(t))){this._pendingOutsidePointer=null;return}this._pendingOutsidePointer=null,this.close()},this.handleDocumentKeyDown=e=>{!this._expanded||e?.key!==`Escape`||(e.preventDefault?.(),this.close())},this.bindEvents()}bindEvents(){this.panels.forEach(e=>{e.header?.addEventListener(`click`,()=>{this._backlinks.length!==0&&(this._expanded=!this._expanded,this._pendingOutsidePointer=null,this._applyExpandState())})}),this.documentRef?.addEventListener?.(`pointerdown`,this.handleDocumentPointerDown),this.documentRef?.addEventListener?.(`pointermove`,this.handleDocumentPointerMove,{passive:!0}),this.documentRef?.addEventListener?.(`pointerup`,this.handleDocumentPointerEnd),this.documentRef?.addEventListener?.(`pointercancel`,this.handleDocumentPointerEnd),this.documentRef?.addEventListener?.(`keydown`,this.handleDocumentKeyDown)}async load(e){let t=e!==this._currentFile;if(this._currentFile=e,t&&(this._expanded=!1),!e){this._backlinks=[],this._render();return}this._fetchController?.abort(),this._fetchController=new AbortController;try{let t=await this.loadBacklinks(e,{signal:this._fetchController.signal});if(this._currentFile!==e)return;this._backlinks=t}catch(e){if(e.name===`AbortError`)return;console.warn(`[backlinks] Failed to load:`,e.message),this._backlinks=[]}this._render()}setDisplayMode(e=`dock`){let t=e===`header`?`header`:`dock`;this._displayMode!==t&&(this._displayMode=t,this._expanded=!1,this._pendingOutsidePointer=null,this._render())}clear(){this._currentFile=null,this._backlinks=[],this._expanded=!1,this._render()}close(){this._expanded&&(this._expanded=!1,this._pendingOutsidePointer=null,this._applyExpandState())}_createPanelRef(e,t=e){return e?{panel:e,header:e.querySelector(`.backlinks-header`),toggle:e.querySelector(`.backlinks-toggle`),countBadge:e.querySelector(`.backlinks-count`),body:e.querySelector(`.backlinks-body`),list:e.querySelector(`.backlinks-list`),root:t}:null}_render(){let e=this._backlinks.length,t=e===1?`Linked Mention`:`Linked Mentions`,n=!!this._currentFile&&e>0;n||(this._expanded=!1),this.panels.forEach(r=>{let i=n&&this._shouldShowPanel(r);r.root?.classList?.toggle?.(`hidden`,!i),r.countBadge.textContent=n?String(e):``,r.toggle.textContent=t,r.header?.classList.toggle(`backlinks-header-empty`,!i),i?this._renderList(r.list):r.list.innerHTML=``}),this._applyExpandState()}_shouldShowPanel(e){let t=e.panel?.getAttribute?.(`data-backlinks-variant`)??``;return t===`header`?this._displayMode===`header`:t===`dock`?this._displayMode===`dock`:!0}_renderList(e){if(!e)return;e.innerHTML=``;let t=this.documentRef?.createDocumentFragment?.(),n=t??e;this._backlinks.forEach(e=>{n.appendChild(this._createBacklinkItem(e))}),t&&e.appendChild(t)}_createBacklinkItem(e){let t=c(e.file.split(`/`).pop()),n=e.file.includes(`/`)?e.file.substring(0,e.file.lastIndexOf(`/`)):``,r=this.documentRef.createElement(`button`);r.type=`button`,r.className=`backlink-item`,r.addEventListener(`click`,()=>{this.close(),this.onFileSelect?.(e.file)});let i=this.documentRef.createElement(`div`);if(i.className=`backlink-file-name`,i.innerHTML=`
|
|
168
|
-
<svg class="backlink-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
169
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
170
|
-
<polyline points="14 2 14 8 20 8"/>
|
|
171
|
-
</svg>
|
|
172
|
-
<span>${b(t)}</span>
|
|
173
|
-
${n?`<span class="backlink-dir">${b(n)}</span>`:``}
|
|
174
|
-
`,r.appendChild(i),e.contexts.slice(0,3).forEach(e=>{let t=this.documentRef.createElement(`div`);t.className=`backlink-context`,t.textContent=e,r.appendChild(t)}),e.contexts.length>3){let t=this.documentRef.createElement(`div`);t.className=`backlink-context backlink-more`,t.textContent=`+${e.contexts.length-3} more`,r.appendChild(t)}return r}_applyExpandState(){this.panels.forEach(e=>{let t=this._expanded&&this._backlinks.length>0&&this._shouldShowPanel(e);e.panel.classList.toggle(`expanded`,t),e.header?.setAttribute(`aria-expanded`,String(t)),e.header?.setAttribute(`aria-disabled`,String(this._backlinks.length===0)),e.body?.setAttribute(`aria-hidden`,String(!t)),e.body?.toggleAttribute(`inert`,!t)})}};function Pi(...e){let t=[];for(let n of e)if(n){if(Array.isArray(n)){let e=Pi(...n);e&&t.push(e);continue}if(typeof n==`object`){Object.entries(n).forEach(([e,n])=>{n&&t.push(e)});continue}t.push(String(n))}return t.join(` `)}function G(e={}){let{variant:t=`secondary`,size:n=`md`,toggle:r=!1,toolbar:i=!1,action:a=!1,wide:o=!1,surface:s=!1,pill:c=!1,hidden:l=!1,active:u=!1,extra:d=[]}=e;return Pi(`ui-button`,t&&`ui-button--${t}`,n!==`md`&&`ui-button--${n}`,{"ui-button--toggle":r,"ui-button--toolbar":i,"ui-button--action":a,"ui-button--wide":o,"ui-button--surface":s,"ui-button--pill":c,active:u,hidden:l},d)}function Fi(e={}){let{toolbar:t=!1,action:n=!1,surface:r=!1,hidden:i=!1,extra:a=[]}=e;return Pi(`ui-icon-button`,{"ui-icon-button--toolbar":t,"ui-icon-button--action":n,"ui-icon-button--surface":r,hidden:i},a)}function K(e={}){return Pi(`ui-input`,e.extra??[])}function Ii(e={}){return Pi(`ui-segmented-control`,{"ui-segmented-control--pill":e.pill,hidden:e.hidden},e.extra??[])}function q(e={}){return Pi(`ui-segmented-btn`,{active:e.active,hidden:e.hidden},e.extra??[])}function Li(){return`base-${Math.random().toString(36).slice(2,10)}`}function Ri(e=``){return/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/iu.test(String(e??``).trim())}function zi(e=``){return/^https?:\/\/.+\.(?:png|jpe?g|webp|gif|svg)(?:[?#].*)?$/iu.test(String(e??``).trim())}function Bi(e){return Object.prototype.toString.call(e)===`[object Object]`}function Vi(e=`and`){return{children:[],conjunction:e,type:`group`}}function Hi(e,t,n){let r=e.image||t.find(e=>[`cover`,`image`].includes(String(e.id??``).toLowerCase()))?.id||null;return r?n.cells[r]??null:null}function J(e){return String(e?.text??``)}function Ui(e=``){return E(`/attachment?path=${encodeURIComponent(e)}`)}function Wi(e={}){if(e?.type===`image`&&e.path)return Ui(e.path);if(e?.type===`link`){if(e.external&&zi(e.url))return e.url;if(e.path&&o(e.path))return Ui(e.path)}let t=J(e);return zi(t)?t:o(t)?Ui(t):``}function Gi(e={}){let t=e?.type||`string`;if(t===`empty`)return`<span class="bases-value bases-value-empty">—</span>`;if(t===`boolean`)return`<span class="bases-value bases-value-boolean">${e.value?`True`:`False`}</span>`;if(t===`image`&&e.path)return`<img class="bases-inline-image" src="${b(Ui(e.path))}" alt="${b(J(e))}">`;if(t===`list`)return`<span class="bases-value-list">${(e.items??[]).map(e=>`<span class="bases-value-pill">${Gi(e)}</span>`).join(``)}</span>`;if(t===`link`){if(e.external&&e.url)return`<a class="bases-link" href="${b(e.url)}" target="_blank" rel="noopener noreferrer">${b(J(e))}</a>`;if(e.path)return`<button type="button" class="${b(G({variant:`secondary`,size:`compact`,pill:!0,extra:[`bases-link`,`bases-link-button`]}))}" data-base-open-file="${b(e.path)}">${b(J(e))}</button>`}return t===`file`&&e.path?`<button type="button" class="${b(G({variant:`secondary`,size:`compact`,pill:!0,extra:[`bases-link`,`bases-link-button`]}))}" data-base-open-file="${b(e.path)}">${b(J(e))}</button>`:`<span class="bases-value">${b(J(e))}</span>`}function Ki(e,t){let n=t?.cells?.[e.id]??null;return t?.path&&n&&n.type!==`empty`&&(e.id===`file.name`||e.id===`file.basename`)?`<button type="button" class="${b(G({variant:`secondary`,size:`compact`,pill:!0,extra:[`bases-link`,`bases-link-button`]}))}" data-base-open-file="${b(t.path)}">${b(J(n))}</button>`:Gi(n)}function qi(e=[]){return!Array.isArray(e)||e.length===0?``:`<div class="bases-summaries">${e.map(e=>`<div class="bases-summary"><span class="bases-summary-label">${b(e.label)}</span><span class="bases-summary-value">${b(J(e.value))}</span></div>`).join(``)}</div>`}function Ji(e,t){return t.map(t=>`<section class="bases-group"><header class="bases-group-header"><h3>${b(t.label)}</h3>${qi(t.summaries)}</header><div class="bases-table-shell"><table class="bases-table"><thead><tr>${e.map(e=>`<th>${b(e.label)}</th>`).join(``)}</tr></thead><tbody>${(t.rows??[]).map(t=>`<tr>${e.map(e=>`<td>${Ki(e,t)}</td>`).join(``)}</tr>`).join(``)}</tbody></table></div></section>`).join(``)}function Yi(e,t){return t.map(t=>`<section class="bases-group"><header class="bases-group-header"><h3>${b(t.label)}</h3>${qi(t.summaries)}</header><ul class="bases-list">${(t.rows??[]).map(t=>`<li class="bases-list-item">${e.map(e=>{let n=t.cells[e.id];return!n||n.type===`empty`?``:`<span class="bases-list-field"><strong>${b(e.label)}:</strong> ${Ki(e,t)}</span>`}).join(``)}</li>`).join(``)}</ul></section>`).join(``)}function Xi(e,t,n){return t.map(t=>`<section class="bases-group"><header class="bases-group-header"><h3>${b(t.label)}</h3>${qi(t.summaries)}</header><div class="bases-cards">${(t.rows??[]).map(t=>{let r=Hi(n,e,t),i=J(r),a=``;if(Ri(i))a=`<div class="bases-card-media bases-card-media-color" style="--bases-card-swatch:${b(i)}"></div>`;else{let e=Wi(r);e&&(a=`<img class="bases-card-media" src="${b(e)}" alt="${b(i)}">`)}return`<article class="bases-card">${a}<div class="bases-card-body">${e.map(e=>{let n=t.cells[e.id];return!n||n.type===`empty`?``:`<div class="bases-card-field"><div class="bases-card-label">${b(e.label)}</div><div class="bases-card-value">${Ki(e,t)}</div></div>`}).join(``)}</div></article>`}).join(``)}</div></section>`).join(``)}function Zi(e){if(!e.view.supported)return`<div class="bases-unsupported">CollabMD parsed this view but does not render the <code>${b(e.view.type)}</code> layout yet.</div>`;switch(e.view.type){case`cards`:return Xi(e.columns,e.groups,e.view);case`list`:return Yi(e.columns,e.groups);default:return Ji(e.columns,e.groups)}}function Qi(e){return(e.views??[]).map(t=>`<button type="button" class="${b(q({active:t.id===e.view.id,extra:`bases-view-tab`}))}" data-base-view="${b(t.id)}">${b(t.name)}</button>`).join(``)}function $i(e){return e?.meta??{}}function ea(e){return $i(e).availableProperties??[]}function ta(e){let t=$i(e).activeViewConfig?.order;return Array.isArray(t)&&t.length>0?[...t]:Array.isArray(e?.columns)?e.columns.map(e=>e.id).filter(Boolean):[]}function na(e,t=``){return ea(e).find(e=>e.id===t)??null}function ra(e,t=``){return na(e,t)?.filterOperators??[`is`,`is not`,`contains`,`does not contain`,`is empty`,`is not empty`]}function Y(e){let t=$i(e).activeViewConfig??{};return{filters:t.filters??null,groupBy:t.groupBy??null,order:Array.isArray(t.order)?[...t.order]:[],sort:Array.isArray(t.sort)?t.sort.map(e=>({...e})):[]}}function ia(e){return!!(e?.payload?.path&&e?.payload?.sourcePath&&e.payload.path===e.payload.sourcePath)}function aa(e,t,n,r){let i=n.ui?.openPanel===t,a=!!$i(r).editable;return`<button type="button" class="${b(G({variant:i?`primary`:`secondary`,pill:!0,extra:[`bases-toolbar-btn`,i?`is-active`:``]}))}" data-base-panel="${b(t)}"${a?``:` disabled`}>${b(e)}</button>`}function oa(e,t=``){if(!e||e.type!==`group`||!t)return e;let n=(e.children??[]).flatMap(e=>{if(e?.type===`group`){let n=oa(e,t);return n?[n]:[]}return e?.propertyId===t?[]:[e]});return{...e,children:n}}function sa(e,t=``,n=e?.result){let r=$i(n).activeViewConfig?.filters??null,i=Z(r),a=t&&i?ga(oa(i,t),n):r;return JSON.stringify({filters:a,path:e?.payload?.path??``,source:e?.payload?.source??null,sourcePath:e?.payload?.sourcePath??``,view:n?.view?.id??e?.payload?.view??``})}function ca(e,t=``,n=e?.result){let r=e?.propertyValueOptions?.get(t)??null;return r&&r.cacheKey===sa(e,t,n)?r.values??[]:[]}function la(e,t){return[aa(`Sort`,`sort`,t,e),aa(`Filter`,`filter`,t,e),aa(`Properties`,`properties`,t,e)].join(``)}function ua(e,{allowBlank:t=!1,selected:n=``}={}){let r=[];return t&&r.push(`<option value=""${n?``:` selected`}>Property</option>`),ea(e).forEach(e=>{r.push(`<option value="${b(e.id)}"${e.id===n?` selected`:``}>${b(e.label)}</option>`)}),r.join(``)}function da(e){let t=Y(e),n=na(e,t.groupBy?.property)?.sortDirections??[{id:`asc`,label:`A → Z`},{id:`desc`,label:`Z → A`}],r=t.sort??[];return`
|
|
175
|
-
<section class="bases-panel-card">
|
|
176
|
-
<div class="bases-panel-section">
|
|
177
|
-
<div class="bases-panel-title">Group by</div>
|
|
178
|
-
<div class="bases-sort-row">
|
|
179
|
-
<select class="${b(K({extra:`bases-select bases-sort-property`}))}" data-base-group-by-property>
|
|
180
|
-
${ua(e,{allowBlank:!0,selected:t.groupBy?.property??``})}
|
|
181
|
-
</select>
|
|
182
|
-
<select class="${b(K({extra:`bases-select bases-sort-direction`}))}" data-base-group-by-direction${t.groupBy?.property?``:` disabled`}>
|
|
183
|
-
${n.map(e=>`<option value="${b(e.id)}"${e.id===(t.groupBy?.direction??`asc`)?` selected`:``}>${b(e.label)}</option>`).join(``)}
|
|
184
|
-
</select>
|
|
185
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-clear-group-by${t.groupBy?.property?``:` disabled`}>Clear</button>
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
188
|
-
<div class="bases-panel-section">
|
|
189
|
-
<div class="bases-panel-title">Sort by</div>
|
|
190
|
-
<div class="bases-sort-list">
|
|
191
|
-
${r.map((t,n)=>{let i=na(e,t.property)?.sortDirections??[{id:`asc`,label:`A → Z`},{id:`desc`,label:`Z → A`}];return`
|
|
192
|
-
<div class="bases-sort-row">
|
|
193
|
-
<select class="${b(K({extra:`bases-select bases-sort-property`}))}" data-base-sort-property="${n}">
|
|
194
|
-
${ua(e,{selected:t.property})}
|
|
195
|
-
</select>
|
|
196
|
-
<select class="${b(K({extra:`bases-select bases-sort-direction`}))}" data-base-sort-direction="${n}">
|
|
197
|
-
${i.map(e=>`<option value="${b(e.id)}"${e.id===t.direction?` selected`:``}>${b(e.label)}</option>`).join(``)}
|
|
198
|
-
</select>
|
|
199
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-sort-move="${n}:up"${n===0?` disabled`:``}>↑</button>
|
|
200
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-sort-move="${n}:down"${n===r.length-1?` disabled`:``}>↓</button>
|
|
201
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-sort-delete="${n}">Delete</button>
|
|
202
|
-
</div>
|
|
203
|
-
`}).join(``)}
|
|
204
|
-
</div>
|
|
205
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-sort-add>Add sort</button>
|
|
206
|
-
</div>
|
|
207
|
-
</section>
|
|
208
|
-
`}function fa(e=[]){return e.join(`.`)}function X(e=``){return String(e??``).split(`.`).filter(e=>e!==``).map(e=>Number.parseInt(e,10)).filter(Number.isFinite)}function pa(e=``){return JSON.stringify(String(e??``))}function ma(e=``,t=`text`,n=`is`){let r=String(e??``).trim();return!r&&n!==`is`&&n!==`is not`?`""`:t===`boolean`?r===`false`?`false`:`true`:t===`number`&&Number.isFinite(Number(r))?String(Number(r)):pa(r)}function ha(e,t=null){if(!e?.propertyId||!e?.operator)return``;let n=e.propertyId,r=t?.valueType??`text`;switch(e.operator){case`contains`:return`${n}.contains(${ma(e.value,r,e.operator)})`;case`does not contain`:return`!${n}.contains(${ma(e.value,r,e.operator)})`;case`starts with`:return`${n}.startsWith(${ma(e.value,r,e.operator)})`;case`ends with`:return`${n}.endsWith(${ma(e.value,r,e.operator)})`;case`is`:return`${n} == ${ma(e.value,r,e.operator)}`;case`is not`:return`${n} != ${ma(e.value,r,e.operator)}`;case`>`:case`>=`:case`<`:case`<=`:return`${n} ${e.operator} ${ma(e.value,r,e.operator)}`;case`is empty`:return`${n}.isEmpty()`;case`is not empty`:return`!${n}.isEmpty()`;default:return``}}function ga(e,t){if(!e||e.type!==`group`)return null;let n=(e.children??[]).map(e=>e?.type===`group`?ga(e,t):ha(e,na(t,e?.propertyId))).filter(Boolean);return n.length===0?null:e.conjunction===`not`?{not:n}:{[e.conjunction]:n}}function _a(e=``){let t=String(e??``).trim();return t?t===`true`||t===`false`?t:t===`null`?``:/^-?\d+(?:\.\d+)?$/u.test(t)?t:t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/\\(["'])/gu,`$1`):t:``}function va(e=``){let t=String(e??``).trim(),n=[[/^!([A-Za-z0-9_.]+)\.isEmpty\(\)$/u,(e,t)=>({operator:`is not empty`,propertyId:t,type:`rule`,value:``})],[/^([A-Za-z0-9_.]+)\.isEmpty\(\)$/u,(e,t)=>({operator:`is empty`,propertyId:t,type:`rule`,value:``})],[/^!([A-Za-z0-9_.]+)\.contains\((.+)\)$/u,(e,t,n)=>({operator:`does not contain`,propertyId:t,type:`rule`,value:_a(n)})],[/^([A-Za-z0-9_.]+)\.contains\((.+)\)$/u,(e,t,n)=>({operator:`contains`,propertyId:t,type:`rule`,value:_a(n)})],[/^([A-Za-z0-9_.]+)\.startsWith\((.+)\)$/u,(e,t,n)=>({operator:`starts with`,propertyId:t,type:`rule`,value:_a(n)})],[/^([A-Za-z0-9_.]+)\.endsWith\((.+)\)$/u,(e,t,n)=>({operator:`ends with`,propertyId:t,type:`rule`,value:_a(n)})],[/^([A-Za-z0-9_.]+)\s*(==|!=|>=|<=|>|<)\s*(.+)$/u,(e,t,n,r)=>({operator:{"!=":`is not`,"==":`is`,"<":`<`,"<=":`<=`,">":`>`,">=":`>=`}[n]??n,propertyId:t,type:`rule`,value:_a(r)})]];for(let[e,r]of n){let n=t.match(e);if(n)return r(...n)}return null}function Z(e){if(!e)return Vi(`and`);if(typeof e==`string`){let t=va(e);return t?{children:[t],conjunction:`and`,type:`group`}:null}if(!Bi(e))return null;if(Array.isArray(e.and)){let t=e.and.map(e=>Z(e)).flatMap(e=>e?.type===`group`&&e.conjunction===`and`&&e.children?.length===1&&e.children[0]?.type===`rule`?e.children:[e]);return t.every(Boolean)?{children:t,conjunction:`and`,type:`group`}:null}if(Array.isArray(e.or)){let t=e.or.map(e=>Z(e)).flatMap(e=>e?.type===`group`&&e.conjunction===`and`&&e.children?.length===1&&e.children[0]?.type===`rule`?e.children:[e]);return t.every(Boolean)?{children:t,conjunction:`or`,type:`group`}:null}if(e.not!=null){let t=(Array.isArray(e.not)?e.not:(()=>{let t=Z(e.not);return t?t.type===`group`&&t.conjunction===`or`?t.children??[]:[t]:[]})()).flatMap(e=>{let t=e?.type?e:Z(e);return t?t.type===`group`&&t.conjunction===`and`&&t.children?.length===1&&t.children[0]?.type===`rule`?t.children:[t]:[null]});return t.every(Boolean)?{children:t,conjunction:`not`,type:`group`}:null}return null}function ya(e){return e?typeof e==`string`?e:JSON.stringify(e,null,2):``}function ba(e=``){let t=String(e??``).trim();return t?t.startsWith(`{`)||t.startsWith(`[`)?JSON.parse(t):t:null}function xa(e,t=[]){let n=e;for(let e of t)n=n?.children?.[e];return n??null}function Sa(e,t=[],n){if(t.length===0)return n(e);let[r,...i]=t;return{...e,children:(e.children??[]).map((e,t)=>t===r?Sa(e,i,n):e)}}function Ca(e,t=[]){if(t.length===0)return e;let n=t.slice(0,-1),r=t[t.length-1];return Sa(e,n,e=>({...e,children:(e.children??[]).filter((e,t)=>t!==r)}))}function wa(e,t=[],n){return Sa(e,t,e=>({...e,children:[...e.children??[],n]}))}function Ta(e,t=``){return ua(e,{allowBlank:!0,selected:t})}function Ea(e={}){return String(e?.text??e?.value??``).trim()}function Da(e,t){return e.ui.builderFilter??Z(Y(t).filters)??Vi(`and`)}function Oa(e,t,n,r){let i=fa(n),a=ra(e,t.propertyId),o=String(t.value??``).trim().toLowerCase(),s=ca(r,t.propertyId,e).map(e=>({count:e?.count,text:Ea(e)})).filter((e,t,n)=>e.text&&n.findIndex(t=>t.text===e.text)===t),c=s.some(e=>e.text.toLowerCase()===o),l=s.filter(e=>!o||e.text.toLowerCase().includes(o)),u=!o||c?s:l.length>0?l:s,d=u.length>0&&![`is empty`,`is not empty`].includes(t.operator);return{encodedPath:i,operators:a,suggestionListId:`bases-filter-suggestions-${b(r.key)}-${b(i.replace(/\./g,`-`))}`,suggestionsEnabled:d,valueInputClasses:K({extra:d?`bases-filter-value bases-filter-value--suggestions`:`bases-filter-value`}),valueSuggestions:u,valueDisabled:[`is empty`,`is not empty`].includes(t.operator)}}function ka(e,t=``){return e.suggestionsEnabled?`
|
|
209
|
-
<div class="bases-filter-suggestion-list" id="${e.suggestionListId}" role="listbox">
|
|
210
|
-
${e.valueSuggestions.slice(0,8).map(n=>`
|
|
211
|
-
<button
|
|
212
|
-
type="button"
|
|
213
|
-
class="bases-filter-suggestion"
|
|
214
|
-
data-base-filter-suggestion="${b(e.encodedPath)}"
|
|
215
|
-
data-base-filter-suggestion-value="${b(n.text)}"
|
|
216
|
-
role="option"
|
|
217
|
-
aria-selected="${n.text===String(t??``)?`true`:`false`}"
|
|
218
|
-
>
|
|
219
|
-
<span class="bases-filter-suggestion-label">${b(n.text)}</span>
|
|
220
|
-
${n.count==null?``:`<span class="bases-filter-suggestion-meta">${b(String(n.count))}</span>`}
|
|
221
|
-
</button>
|
|
222
|
-
`).join(``)}
|
|
223
|
-
</div>
|
|
224
|
-
`:``}function Aa(e,t,n,r){let i=Oa(e,t,n,r);return`
|
|
225
|
-
<div class="bases-filter-value-combobox${i.suggestionsEnabled?` has-suggestions`:``}">
|
|
226
|
-
<input class="${b(i.valueInputClasses)}" type="text" value="${b(t.value??``)}" data-base-filter-value="${b(i.encodedPath)}"${i.suggestionsEnabled?` aria-controls="${i.suggestionListId}" aria-haspopup="listbox" aria-autocomplete="list" autocomplete="off"`:``}${i.valueDisabled?` disabled`:``}>
|
|
227
|
-
${ka(i,t.value??``)}
|
|
228
|
-
</div>
|
|
229
|
-
`}function ja(e,t,n,r){let i=Oa(e,t,n,r);return`
|
|
230
|
-
<div class="bases-filter-row">
|
|
231
|
-
<select class="${b(K({extra:`bases-select bases-filter-property`}))}" data-base-filter-property="${b(i.encodedPath)}">
|
|
232
|
-
${Ta(e,t.propertyId)}
|
|
233
|
-
</select>
|
|
234
|
-
<select class="${b(K({extra:`bases-select bases-filter-operator`}))}" data-base-filter-operator="${b(i.encodedPath)}">
|
|
235
|
-
${i.operators.map(e=>`<option value="${b(e)}"${e===t.operator?` selected`:``}>${b(e)}</option>`).join(``)}
|
|
236
|
-
</select>
|
|
237
|
-
${Aa(e,t,n,r)}
|
|
238
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-filter-remove="${b(i.encodedPath)}">Delete</button>
|
|
239
|
-
</div>
|
|
240
|
-
`}function Ma(e,t,n,{fallbackToFullRender:r=!0}={}){let i=Va(e)?.querySelector?.(`[data-base-panel-slot]`)??null,a=fa(n),o=i?.querySelector?.(`[data-base-filter-value="${a}"]`)??null,s=o?.parentElement?.classList?.contains(`bases-filter-value-combobox`)?o.parentElement:null,c=xa(Da(e,t),n);if(!o||!s||!c||c.type!==`rule`||typeof o.insertAdjacentHTML!=`function`)return r&&Ua(e,t),!1;let l=Oa(t,c,n,e);return s.classList.toggle(`has-suggestions`,l.suggestionsEnabled),o.className=l.valueInputClasses,o.disabled=l.valueDisabled,o.value!==String(c.value??``)&&(o.value=String(c.value??``)),l.suggestionsEnabled?(o.setAttribute(`aria-controls`,l.suggestionListId),o.setAttribute(`aria-haspopup`,`listbox`),o.setAttribute(`aria-autocomplete`,`list`),o.setAttribute(`autocomplete`,`off`)):(o.removeAttribute(`aria-controls`),o.removeAttribute(`aria-haspopup`),o.removeAttribute(`aria-autocomplete`),o.removeAttribute(`autocomplete`)),s.querySelector(`.bases-filter-suggestion-list`)?.remove?.(),l.suggestionsEnabled&&o.insertAdjacentHTML(`afterend`,ka(l,c.value??``)),!0}function Na(e,t,n=[]){if(e){if(e.type===`rule`){t(e,n);return}(e.children??[]).forEach((e,r)=>{Na(e,t,[...n,r])})}}function Pa(e,t,n,r,{isRoot:i=!1}={}){let a=fa(n);return`
|
|
241
|
-
<div class="bases-filter-group"${i?` data-base-filter-root`:``}>
|
|
242
|
-
<div class="bases-filter-group-header">
|
|
243
|
-
<select class="${b(K({extra:`bases-select bases-filter-conjunction`}))}" data-base-filter-conjunction="${b(a)}">
|
|
244
|
-
${[`and`,`or`,`not`].map(e=>`<option value="${e}"${t.conjunction===e?` selected`:``}>${b({and:`All the following are true`,not:`None of the following are true`,or:`Any of the following are true`}[e])}</option>`).join(``)}
|
|
245
|
-
</select>
|
|
246
|
-
${i?``:`<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-filter-remove="${b(a)}">Delete group</button>`}
|
|
247
|
-
</div>
|
|
248
|
-
<div class="bases-filter-children">
|
|
249
|
-
${(t.children??[]).map((t,i)=>t?.type===`group`?Pa(e,t,[...n,i],r):ja(e,t,[...n,i],r)).join(``)}
|
|
250
|
-
</div>
|
|
251
|
-
<div class="bases-filter-actions-row">
|
|
252
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-filter-add-rule="${b(a)}">Add filter</button>
|
|
253
|
-
<button type="button" class="${b(G({variant:`secondary`,size:`compact`}))}" data-base-filter-add-group="${b(a)}">Add filter group</button>
|
|
254
|
-
</div>
|
|
255
|
-
</div>
|
|
256
|
-
`}function Fa(e,t){let n=Y(e).filters,r=t.ui.builderFilter??Z(n);t.ui.builderFilter??(t.ui.builderFilter=r);let i=r?t.ui.filterMode??`builder`:`advanced`,a=t.ui.rawFilterText??ya(n);return`
|
|
257
|
-
<section class="bases-panel-card">
|
|
258
|
-
<div class="bases-panel-title-row">
|
|
259
|
-
<div class="bases-panel-title">This view</div>
|
|
260
|
-
${r?`
|
|
261
|
-
<div class="bases-toggle-row">
|
|
262
|
-
<button type="button" class="${b(G({variant:i===`builder`?`primary`:`secondary`,size:`compact`}))}" data-base-filter-mode="builder">Builder</button>
|
|
263
|
-
<button type="button" class="${b(G({variant:i===`advanced`?`primary`:`secondary`,size:`compact`}))}" data-base-filter-mode="advanced">Advanced</button>
|
|
264
|
-
</div>
|
|
265
|
-
`:``}
|
|
266
|
-
</div>
|
|
267
|
-
${i===`advanced`?`
|
|
268
|
-
<label class="bases-filter-advanced-label">
|
|
269
|
-
<textarea class="${b(K({extra:`bases-filter-advanced`}))}" data-base-filter-advanced>${b(a)}</textarea>
|
|
270
|
-
</label>
|
|
271
|
-
<div class="bases-filter-actions-row">
|
|
272
|
-
<button type="button" class="${b(G({variant:`primary`,size:`compact`}))}" data-base-filter-save-advanced>Save filter</button>
|
|
273
|
-
</div>
|
|
274
|
-
`:Pa(e,r??Vi(`and`),[],t,{isRoot:!0})}
|
|
275
|
-
</section>
|
|
276
|
-
`}function Ia(e,t){let n=String(t.ui.propertySearch??``).trim().toLowerCase(),r=new Set(ta(e)),i=ea(e).filter(e=>!n||e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n));return`
|
|
277
|
-
<section class="bases-panel-card">
|
|
278
|
-
<label class="bases-properties-search">
|
|
279
|
-
<input class="${b(K({extra:`bases-properties-search-input`}))}" type="search" value="${b(t.ui.propertySearch??``)}" placeholder="Find property" data-base-properties-search>
|
|
280
|
-
</label>
|
|
281
|
-
<div class="bases-properties-list" data-base-properties-list>
|
|
282
|
-
${i.map(e=>`
|
|
283
|
-
<label class="bases-property-option">
|
|
284
|
-
<input type="checkbox" data-base-property-toggle="${b(e.id)}"${r.has(e.id)?` checked`:``}>
|
|
285
|
-
<span class="bases-property-option-label">${b(e.label)}</span>
|
|
286
|
-
<span class="bases-property-option-meta">${b(e.kind)}</span>
|
|
287
|
-
</label>
|
|
288
|
-
`).join(``)}
|
|
289
|
-
</div>
|
|
290
|
-
</section>
|
|
291
|
-
`}function La(e){let t=e?.querySelector?.(`[data-base-properties-list]`)??null,n=e?.querySelector?.(`[data-base-properties-search]`)??null,r=typeof document<`u`?document.activeElement:null,i=null;if(n&&r===n){let e=typeof n.selectionStart==`number`?n.selectionStart:null;i={selectionEnd:typeof n.selectionEnd==`number`?n.selectionEnd:e,selectionStart:e,type:`properties-search`}}else if(r?.dataset?.baseFilterValue!=null){let t=String(r.dataset.baseFilterValue),n=e?.querySelector?.(`[data-base-filter-value="${t}"]`)??null;if(n&&r===n){let e=typeof n.selectionStart==`number`?n.selectionStart:null;i={path:t,selectionEnd:typeof n.selectionEnd==`number`?n.selectionEnd:e,selectionStart:e,type:`filter-value`}}}return{focusedControl:i,propertiesListScrollTop:t?t.scrollTop:null}}function Ra(e,t){if(t){if(t.propertiesListScrollTop!=null){let n=e?.querySelector?.(`[data-base-properties-list]`)??null;n&&(n.scrollTop=t.propertiesListScrollTop)}if(t.focusedControl?.type===`properties-search`){let n=e?.querySelector?.(`[data-base-properties-search]`)??null;n&&(n.focus?.(),typeof n.setSelectionRange==`function`&&t.focusedControl.selectionStart!=null&&n.setSelectionRange(t.focusedControl.selectionStart,t.focusedControl.selectionEnd??t.focusedControl.selectionStart));return}if(t.focusedControl?.type===`filter-value`&&t.focusedControl.path!=null){let n=e?.querySelector?.(`[data-base-filter-value="${t.focusedControl.path}"]`)??null;n&&(n.focus?.(),typeof n.setSelectionRange==`function`&&t.focusedControl.selectionStart!=null&&n.setSelectionRange(t.focusedControl.selectionStart,t.focusedControl.selectionEnd??t.focusedControl.selectionStart))}}}function za(e,t){if(!t.ui?.openPanel)return``;if(!$i(e).editable)return`<section class="bases-panel-card"><div class="bases-readonly-note">Inline base previews are read-only. Open the .base file to edit its sort, filter, and properties.</div></section>`;switch(t.ui.openPanel){case`filter`:return Fa(e,t);case`properties`:return Ia(e,t);default:return da(e)}}function Ba(e,t){return`
|
|
292
|
-
<section class="bases-shell" data-base-shell-key="${b(t.key)}">
|
|
293
|
-
<header class="bases-toolbar">
|
|
294
|
-
<div class="bases-toolbar-main">
|
|
295
|
-
<div class="${b(Ii({pill:!0,extra:`bases-tabs`}))}" data-base-tabs>
|
|
296
|
-
${Qi(e)}
|
|
297
|
-
</div>
|
|
298
|
-
<div class="bases-meta" data-base-meta>${b(String(e.totalRows??0))} results</div>
|
|
299
|
-
</div>
|
|
300
|
-
<div class="bases-toolbar-actions">
|
|
301
|
-
<div class="bases-toolbar-edit-actions" data-base-action-slot>${la(e,t)}</div>
|
|
302
|
-
<label class="bases-search-shell" aria-label="Search this base">
|
|
303
|
-
<svg class="bases-search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
304
|
-
<circle cx="11" cy="11" r="7"></circle>
|
|
305
|
-
<path d="m20 20-3.5-3.5"></path>
|
|
306
|
-
</svg>
|
|
307
|
-
<input class="${b(K({extra:`bases-search-input`}))}" type="search" value="${b(t.search)}" placeholder="Search this base" aria-label="Search this base">
|
|
308
|
-
</label>
|
|
309
|
-
<button type="button" class="${b(G({variant:`secondary`,pill:!0,extra:`bases-export-btn`}))}">Export CSV</button>
|
|
310
|
-
</div>
|
|
311
|
-
</header>
|
|
312
|
-
<div class="bases-panels" data-base-panel-slot>${za(e,t)}</div>
|
|
313
|
-
<div data-base-summary-slot>${qi(e.summaries)}</div>
|
|
314
|
-
<div class="bases-content" data-base-content>${Zi(e)}</div>
|
|
315
|
-
</section>
|
|
316
|
-
`}function Va(e){return e?.placeholder?.querySelector?e.placeholder.querySelector(`[data-base-shell-key="${e.key}"]`)??e.placeholder.querySelector(`.bases-shell`):null}function Ha(e){e?.classList&&(e.classList.add(`is-hydrated`),e.classList.remove(`diagram-preview-shell`))}function Ua(e,t){let n=Va(e);if(!n?.querySelector){e.placeholder.innerHTML=Ba(t,e),Ha(e.placeholder);return}let r=n.querySelector(`[data-base-tabs]`);r&&(r.innerHTML=Qi(t));let i=n.querySelector(`[data-base-meta]`);i&&(i.textContent=`${String(t.totalRows??0)} results`);let a=n.querySelector(`[data-base-action-slot]`);a&&(a.innerHTML=la(t,e));let o=n.querySelector(`[data-base-panel-slot]`);if(o){let n=La(o);o.innerHTML=za(t,e),Ra(o,n)}let s=n.querySelector(`[data-base-summary-slot]`);s&&(s.innerHTML=qi(t.summaries));let c=n.querySelector(`[data-base-content]`);c&&(c.innerHTML=Zi(t));let l=n.querySelector(`.bases-search-input`);l&&l.value!==e.search&&(l.value=e.search)}function Wa(e,t=`base.csv`){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)}function Ga(e=``){let t=e.match(/filename\*=UTF-8''([^;]+)/iu);return t?decodeURIComponent(t[1]):e.match(/filename="([^"]+)"/iu)?.[1]||`base.csv`}var Ka=class{constructor({getActiveFilePath:e=()=>``,getSession:t=()=>null,onOpenFile:n,previewElement:r,replaceBaseSource:i=null,toastController:a,vaultApiClient:o}){this.getActiveFilePath=e,this.getSession=t,this.onOpenFile=n,this.previewElement=r,this.replaceBaseSource=i,this.toastController=a,this.vaultApiClient=o,this.entries=new Map,this.searchTimers=new Map,this.applyFilterSuggestion=(e,t,n)=>{this.updateBuilderFilter(e,e=>Sa(e,t,e=>({...e,value:n})))},this.persistBuilderFilter=e=>{let t=Da(e,e.result);e.ui.builderFilter=t,this.updateViewConfig(e,n=>(n.filters=ga(t,e.result),n))},this.handlePointerDown=e=>{let t=e.target.closest(`[data-base-filter-suggestion]`);if(!t)return;let n=e.target.closest(`[data-base-shell-key]`),r=n?this.entries.get(n.dataset.baseShellKey||``):null;if(!r)return;e.preventDefault();let i=X(t.dataset.baseFilterSuggestion||``),a=t.dataset.baseFilterSuggestionValue||``;this.applyFilterSuggestion(r,i,a)},this.handleClick=e=>{let t=e.target.closest(`[data-base-open-file]`);if(t){e.preventDefault(),this.onOpenFile?.(t.dataset.baseOpenFile||``);return}let n=e.target.closest(`[data-base-shell-key]`),r=n?this.entries.get(n.dataset.baseShellKey||``):null;if(!r)return;let i=e.target.closest(`.bases-view-tab`);if(i){r.payload.view=i.dataset.baseView||``,r.ui.openPanel=``,this.renderEntry(r);return}let a=e.target.closest(`[data-base-panel]`);if(a){let e=a.dataset.basePanel||``;r.ui.openPanel=r.ui.openPanel===e?``:e,r.ui.rawFilterText=ya(Y(r.result).filters),Ua(r,r.result);return}if(e.target.closest(`.bases-export-btn`)){this.exportEntry(r);return}if(e.target.closest(`[data-base-sort-add]`)){this.updateViewConfig(r,e=>{let t=new Set((e.sort??[]).map(e=>e.property)),n=ea(r.result).find(e=>!t.has(e.id))?.id??`file.name`;return e.sort=[...e.sort??[],{direction:`asc`,property:n}],e});return}let o=e.target.closest(`[data-base-sort-delete]`);if(o){let e=Number.parseInt(o.dataset.baseSortDelete||``,10);this.updateViewConfig(r,t=>(t.sort=(t.sort??[]).filter((t,n)=>n!==e),t));return}let s=e.target.closest(`[data-base-sort-move]`);if(s){let[e,t]=String(s.dataset.baseSortMove||``).split(`:`),n=Number.parseInt(e,10);this.updateViewConfig(r,e=>{let r=[...e.sort??[]],i=t===`up`?n-1:n+1;return i<0||i>=r.length?e:([r[n],r[i]]=[r[i],r[n]],e.sort=r,e)});return}if(e.target.closest(`[data-base-clear-group-by]`)){this.updateViewConfig(r,e=>(e.groupBy=null,e));return}let c=e.target.closest(`[data-base-filter-mode]`);if(c){r.ui.filterMode=c.dataset.baseFilterMode||`builder`,r.ui.filterMode===`advanced`&&(r.ui.rawFilterText=ya(Y(r.result).filters),r.ui.builderFilter=null),Ua(r,r.result);return}if(e.target.closest(`[data-base-filter-save-advanced]`)){this.saveAdvancedFilter(r);return}let l=e.target.closest(`[data-base-filter-add-rule]`);if(l){let e=X(l.dataset.baseFilterAddRule||``);this.updateBuilderFilter(r,t=>wa(t,e,{operator:`is`,propertyId:ea(r.result)[0]?.id??`file.name`,type:`rule`,value:``}));return}let u=e.target.closest(`[data-base-filter-add-group]`);if(u){let e=X(u.dataset.baseFilterAddGroup||``);this.updateBuilderFilter(r,t=>wa(t,e,Vi(`and`)));return}let d=e.target.closest(`[data-base-filter-remove]`);if(d){let e=X(d.dataset.baseFilterRemove||``);this.updateBuilderFilter(r,t=>Ca(t,e));return}let f=e.target.closest(`[data-base-filter-suggestion]`);if(f){if(e.preventDefault?.(),e.detail!=null&&e.detail!==0)return;let t=X(f.dataset.baseFilterSuggestion||``),n=f.dataset.baseFilterSuggestionValue||``;this.applyFilterSuggestion(r,t,n)}},this.handleInput=e=>{let t=e.target.closest(`.bases-search-input`);if(t){let e=t.closest(`[data-base-shell-key]`),n=e?this.entries.get(e.dataset.baseShellKey||``):null;if(!n)return;n.search=t.value||``,clearTimeout(this.searchTimers.get(n.key)),this.searchTimers.set(n.key,setTimeout(()=>{n.payload.search=n.search,this.renderEntry(n)},180));return}let n=e.target.closest(`[data-base-properties-search]`);if(n){let e=n.closest(`[data-base-shell-key]`),t=e?this.entries.get(e.dataset.baseShellKey||``):null;if(!t)return;t.ui.propertySearch=n.value||``,Ua(t,t.result);return}let r=e.target.closest(`[data-base-filter-advanced]`);if(r){let e=r.closest(`[data-base-shell-key]`),t=e?this.entries.get(e.dataset.baseShellKey||``):null;if(!t)return;t.ui.rawFilterText=r.value||``;return}let i=e.target.closest(`[data-base-filter-value]`);if(i){let e=i.closest(`[data-base-shell-key]`),t=e?this.entries.get(e.dataset.baseShellKey||``):null;if(!t)return;let n=X(i.dataset.baseFilterValue||``),r=t.ui.builderFilter??Z(Y(t.result).filters)??Vi(`and`);t.ui.builderFilter=Sa(r,n,e=>({...e,value:i.value||``})),Ma(t,t.result,n)}},this.handleChange=e=>{let t=e.target.closest(`[data-base-shell-key]`),n=t?this.entries.get(t.dataset.baseShellKey||``):null;if(!n)return;let r=e.target.closest(`[data-base-group-by-property]`);if(r){this.updateViewConfig(n,e=>(e.groupBy=r.value?{direction:e.groupBy?.direction??`asc`,property:r.value}:null,e));return}let i=e.target.closest(`[data-base-group-by-direction]`);if(i){this.updateViewConfig(n,e=>(e.groupBy=e.groupBy?.property?{direction:i.value||`asc`,property:e.groupBy.property}:null,e));return}let a=e.target.closest(`[data-base-sort-property]`);if(a){let e=Number.parseInt(a.dataset.baseSortProperty||``,10);this.updateViewConfig(n,t=>(t.sort=(t.sort??[]).map((t,n)=>n===e?{...t,property:a.value}:t),t));return}let o=e.target.closest(`[data-base-sort-direction]`);if(o){let e=Number.parseInt(o.dataset.baseSortDirection||``,10);this.updateViewConfig(n,t=>(t.sort=(t.sort??[]).map((t,n)=>n===e?{...t,direction:o.value||`asc`}:t),t));return}let s=e.target.closest(`[data-base-property-toggle]`);if(s){let e=s.dataset.basePropertyToggle||``;this.updateViewConfig(n,t=>{let r=t.order?.length>0?[...t.order]:ta(n.result),i=r.indexOf(e);return s.checked&&i===-1&&r.push(e),!s.checked&&i>=0&&r.splice(i,1),t.order=r,t});return}let c=e.target.closest(`[data-base-filter-conjunction]`);if(c){let e=X(c.dataset.baseFilterConjunction||``);this.updateBuilderFilter(n,t=>Sa(t,e,e=>({...e,conjunction:c.value||`and`})));return}let l=e.target.closest(`[data-base-filter-property]`);if(l){let e=X(l.dataset.baseFilterProperty||``);(async()=>{await this.updateBuilderFilter(n,t=>Sa(t,e,e=>{let t=ra(n.result,l.value)[0]??`is`;return{...e,operator:t,propertyId:l.value,value:``}})),await this.ensurePropertyValues(n,l.value)})();return}let u=e.target.closest(`[data-base-filter-operator]`);if(u){let e=X(u.dataset.baseFilterOperator||``);this.updateBuilderFilter(n,t=>Sa(t,e,e=>({...e,operator:u.value||`is`})));return}e.target.closest(`[data-base-filter-value]`)&&this.persistBuilderFilter(n)},this.handleFocusIn=e=>{let t=e.target.closest(`[data-base-filter-value]`);if(!t)return;let n=t.closest(`[data-base-shell-key]`),r=n?this.entries.get(n.dataset.baseShellKey||``):null;if(!r)return;let i=X(t.dataset.baseFilterValue||``),a=Z(Y(r.result).filters),o=a?xa(a,i):null;o?.propertyId&&this.ensurePropertyValues(r,o.propertyId)},this.previewElement?.addEventListener(`pointerdown`,this.handlePointerDown),this.previewElement?.addEventListener(`click`,this.handleClick),this.previewElement?.addEventListener(`input`,this.handleInput),this.previewElement?.addEventListener(`change`,this.handleChange),this.previewElement?.addEventListener(`focusin`,this.handleFocusIn)}ensureEntryState(e){e.ui||={builderFilter:null,filterMode:`builder`,openPanel:``,propertySearch:``,rawFilterText:``},Object.prototype.hasOwnProperty.call(e.ui,`builderFilter`)||(e.ui.builderFilter=null),e.propertyValueOptions||=new Map}destroy(){this.previewElement?.removeEventListener(`pointerdown`,this.handlePointerDown),this.previewElement?.removeEventListener(`click`,this.handleClick),this.previewElement?.removeEventListener(`input`,this.handleInput),this.previewElement?.removeEventListener(`change`,this.handleChange),this.previewElement?.removeEventListener(`focusin`,this.handleFocusIn),this.searchTimers.forEach(e=>clearTimeout(e)),this.searchTimers.clear(),this.entries.clear()}reconcileEmbeds(e=this.previewElement){e&&Array.from(e.querySelectorAll(`.bases-embed-placeholder[data-base-key]`)).forEach(e=>{let t=e.dataset.baseKey||Li(),n=this.entries.get(t),r={path:e.dataset.basePath||``,search:``,source:e.dataset.baseSource||null,sourcePath:e.dataset.baseSourcePath||``,view:e.dataset.baseView||``},i=n??{key:t,payload:r,placeholder:e,propertyValueOptions:new Map,requestVersion:0,result:null,search:``,ui:{builderFilter:null,filterMode:`builder`,openPanel:``,propertySearch:``,rawFilterText:``}};i.payload=r,i.placeholder=e,this.entries.set(t,i),this.renderEntry(i)})}async renderStandalone({filePath:e,renderHost:t,source:n=null}){let r=`standalone:${e}`,i=this.entries.get(r)??{key:r,payload:{path:e,search:``,source:n,sourcePath:e,view:``},placeholder:t,propertyValueOptions:new Map,requestVersion:0,result:null,search:``,ui:{builderFilter:null,filterMode:`builder`,openPanel:``,propertySearch:``,rawFilterText:``}};i.placeholder=t,i.payload.path=e,i.payload.source=typeof n==`string`?n:null,i.payload.sourcePath=e,this.entries.set(r,i),await this.renderEntry(i)}async renderEntry(e){if(this.ensureEntryState(e),!e?.placeholder?.isConnected)return;let t=(e.requestVersion??0)+1;e.requestVersion=t;let n=!!Va(e);n||(e.placeholder.innerHTML=`<div class="preview-shell">Loading base…</div>`);try{let n=await this.vaultApiClient.queryBase({activeFilePath:this.getActiveFilePath?.()??``,...e.payload});if(t!==e.requestVersion||!e?.placeholder?.isConnected)return;e.result=n.result,e.ui.builderFilter=Z(Y(e.result).filters),e.ui.rawFilterText||(e.ui.rawFilterText=ya(Y(e.result).filters)),Ua(e,e.result)}catch(r){if(t!==e.requestVersion||!e?.placeholder?.isConnected)return;if(n){let t=Va(e)?.querySelector?.(`[data-base-content]`)??null;if(t){t.innerHTML=`<div class="preview-shell">Failed to load base: ${b(r.message||`Unknown error`)}</div>`;return}}e.placeholder.innerHTML=`<div class="preview-shell">Failed to load base: ${b(r.message||`Unknown error`)}</div>`}}async exportEntry(e){this.ensureEntryState(e);try{let t=await this.vaultApiClient.exportBaseCsv({activeFilePath:this.getActiveFilePath?.()??``,...e.payload});Wa(t.blob,Ga(t.contentDisposition))}catch(e){this.toastController?.show?.(e.message||`Failed to export base CSV`)}}async ensurePropertyValues(e,t=``){if(this.ensureEntryState(e),!t)return;let n=sa(e,t);if((e.propertyValueOptions.get(t)??null)?.cacheKey!==n)try{let r=await this.vaultApiClient.queryBasePropertyValues({activeFilePath:this.getActiveFilePath?.()??``,...e.payload,propertyId:t});if(e.propertyValueOptions.set(t,{cacheKey:n,values:r.result?.values??[]}),e.result&&e.ui.openPanel===`filter`){let n=!1;Na(Da(e,e.result),(r,i)=>{r.propertyId===t&&(n=Ma(e,e.result,i,{fallbackToFullRender:!1})||n)}),n||Ua(e,e.result)}}catch{e.propertyValueOptions.set(t,{cacheKey:n,values:[]})}}async applyTransformedSource(e,t){if(this.ensureEntryState(e),ia(e)){e.payload.source=t.source,this.replaceBaseSource?.({path:e.payload.path,source:t.source});return}await this.vaultApiClient.writeFile({content:t.source,path:e.payload.path}),e.payload.source=null}async updateViewConfig(e,t){if(this.ensureEntryState(e),!e?.result||!$i(e.result).editable)return;let n=t(Y(e.result));try{let t=(await this.vaultApiClient.transformBase({activeFilePath:this.getActiveFilePath?.()??``,mutation:{config:n,type:`set-view-config`,view:e.result.view.id},...e.payload})).result;await this.applyTransformedSource(e,t),e.result=t.result,e.ui.rawFilterText=ya(Y(e.result).filters),Ua(e,e.result)}catch(e){this.toastController?.show?.(e.message||`Failed to update base`)}}async updateBuilderFilter(e,t){this.ensureEntryState(e);let n=t(e.ui.builderFilter??Z(Y(e.result).filters)??Vi(`and`));e.ui.builderFilter=n,await this.updateViewConfig(e,t=>(t.filters=ga(n,e.result),t))}async saveAdvancedFilter(e){this.ensureEntryState(e);try{let t=ba(e.ui.rawFilterText??``);e.ui.builderFilter=Z(t),await this.updateViewConfig(e,e=>(e.filters=t,e))}catch(e){this.toastController?.show?.(e.message||`Invalid advanced filter`)}}};function qa(e,t,n,r,i,a){return e?.(t,n,r,i,a)??a.renderToken(t,n,r)}function Ja(e=``){return`<p>${b(String(e??``)).replace(/\n/g,`<br>`)}</p>`}function Ya(){let e=t({breaks:!0,highlight(e,t){try{return t&&n.getLanguage(t)?n.highlight(e,{ignoreIllegals:!0,language:t}).value:n.highlightAuto(e).value}catch{return b(e)}},html:!1,linkify:!0,typographer:!0}),r=e.renderer.rules.link_open,i=e.renderer.rules.table_open,a=e.renderer.rules.table_close;return e.renderer.rules.link_open=(e,t,n,i,a)=>(e[t].attrSet(`target`,`_blank`),e[t].attrSet(`rel`,`noopener noreferrer`),qa(r,e,t,n,i,a)),e.renderer.rules.table_open=(e,t,n,r,a)=>`<div class="comment-markdown-table">${qa(i,e,t,n,r,a)}`,e.renderer.rules.table_close=(e,t,n,r,i)=>`${qa(a,e,t,n,r,i)}</div>`,e}var Xa=Ya();function Za(e=``){let t=String(e??``);try{return Xa.render(t)}catch{return Ja(t)}}var Qa=Object.freeze([`👍`,`❤️`,`🎉`,`👀`,`🚀`]),$a=Object.freeze([`😂`,`🔥`,`✅`,`🙏`,`💡`,`🤔`,`👏`,`😄`,`🎯`,`🙌`]);function eo(e,t,n){return Math.min(Math.max(e,t),n)}function to(e=[]){return[...e].sort((e,t)=>(e.anchor?.startLine??0)-(t.anchor?.startLine??0)||e.createdAt-t.createdAt)}function no(e){return e?.anchorKind||e?.kind||`line`}function ro(e){return no(e)===`text`&&Number.isFinite(e?.startIndex)&&Number.isFinite(e?.endIndex)&&e.endIndex>e.startIndex}function io(e,t){return e===t?!0:!e||!t?!1:no(e)===no(t)&&(e.startIndex??null)===(t.startIndex??null)&&(e.endIndex??null)===(t.endIndex??null)&&(e.startLine??null)===(t.startLine??null)&&(e.endLine??null)===(t.endLine??null)&&(e.anchorQuote??e.quote??``)===(t.anchorQuote??t.quote??``)}function ao(e){return e?((e.kind||e.anchorKind)===`text`&&e.quote,e.startLine===e.endLine?`Line ${e.startLine}`:`Lines ${e.startLine}-${e.endLine}`):`No source anchor`}function oo(e={}){return[e.kind||e.anchorKind||`line`,e.startLine??0,e.endLine??0,e.quote||``].join(`::`)}function so(e){return e&&!e.querySelector(`[data-source-line]`)}function co(e){let t=Number.parseInt(e||``,10);return Number.isFinite(t)?t:null}function lo(e=[]){return e.reduce((e,t)=>e?(t?.createdAt??0)>=(e?.createdAt??0)?t:e:t,null)}function uo(e){return e?.threads?.reduce((e,t)=>{let n=lo(t?.messages??[]);return n&&(n.createdAt??0)>=(e?.createdAt??0)?n:e},null)}function fo(e,t=`comment-markdown`){let n=document.createElement(`div`);return n.className=t,n.innerHTML=Za(e),n}function po(e,t){return!!(t&&e?.users?.some(e=>e?.userId===t))}function mo(e){return String(Array.isArray(e?.users)?e.users.length:0)}function ho(e,t,n){return e?.threadId===t&&e?.messageId===n}function go(e){let t=e?.querySelector?.(`.comment-reaction-picker`),n=t?.closest?.(`.comment-reaction-picker-wrap`),r=e?.querySelector?.(`.comment-card-scroll`);return!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||!(r instanceof HTMLElement)?null:{picker:t,scroll:r,wrap:n}}function _o(e,t){let n=co(e?.getAttribute?.(`data-source-line`)),r=co(e?.getAttribute?.(`data-source-line-end`))??n;return!n||!r||!t?!1:t.startLine<=r&&t.endLine>=n}function vo(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=``,r=[],i=!0;for(;t.nextNode();){let e=t.currentNode,a=e.textContent||``;for(let t=0;t<a.length;t+=1){let o=a[t];if(/\s/.test(o)){if(i)continue;n+=` `,r.push({node:e,offset:t}),i=!0;continue}n+=o,r.push({node:e,offset:t}),i=!1}}for(;n.endsWith(` `);)n=n.slice(0,-1),r.pop();return{map:r,normalized:n}}function yo(e,t){let n=we(t);if(!e||!n)return null;let r=vo(e);if(!r.normalized)return null;let i=r.normalized.indexOf(n);if(i<0||r.normalized.indexOf(n,i+1)>=0)return null;let a=r.map[i],o=r.map[i+n.length-1];if(!a||!o)return null;let s=document.createRange();return s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset+1),s}function bo(e,t){return{bottom:e.bottom-t.top,height:e.height,left:e.left-t.left,right:e.right-t.left,top:e.top-t.top,width:e.width}}function xo(e=[]){if(!Array.isArray(e)||e.length===0)return null;let t=Math.min(...e.map(e=>e.left)),n=Math.min(...e.map(e=>e.top)),r=Math.max(...e.map(e=>e.right)),i=Math.max(...e.map(e=>e.bottom));return{bottom:i,height:i-n,left:t,right:r,top:n,width:r-t}}function So(e,t,n){return n?e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom:!1}function Co(e=[]){return[...new Set(e.filter(Boolean))].sort()}function wo(e=[]){return Co(e).join(` `)}function To(e){let t=document.createDocumentFragment(),n=document.createElement(`span`);if(n.className=`comment-marker-icon`,n.setAttribute(`aria-hidden`,`true`),n.innerHTML=`
|
|
317
|
-
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
318
|
-
<path d="M3 4.75A1.75 1.75 0 0 1 4.75 3h6.5A1.75 1.75 0 0 1 13 4.75v4.5A1.75 1.75 0 0 1 11.25 11H8.9L6.5 13v-2H4.75A1.75 1.75 0 0 1 3 9.25v-4.5Z" stroke="currentColor" stroke-width="1.35" stroke-linejoin="round"/>
|
|
319
|
-
</svg>
|
|
320
|
-
`,t.appendChild(n),e>1){let n=document.createElement(`span`);n.className=`comment-marker-count`,n.textContent=String(e),t.appendChild(n)}return t}function Eo(){if(this.cardRoot?.isConnected&&this.cardRoot.parentElement===document.body)return this.cardRoot;let e=document.createElement(`div`);return e.className=`comment-card-root hidden`,document.body.appendChild(e),this.cardRoot=e,e}function Do(e=`editor`,t=null){let n=this.session?.getCurrentSelectionCommentAnchor?.();if(!n)return;this.selectionAnchor=n,this.reactionPicker=null;let r=e===`editor`&&t?`editor-chip`:e,i=t??(e===`toolbar`?this.commentSelectionButton?.getBoundingClientRect?.():this.session?.getCommentAnchorClientRect?.(n));this.activeCard={anchor:n,composerDraft:null,mode:`create`,origin:r,replyThreadId:null,sourceRect:i},this.render()}function Oo(e,{anchor:t,origin:n,sourceRect:r}){this.reactionPicker=null,this.activeCard={anchor:t,groupKey:e.key,groupThreadIds:e.threads.map(e=>e.id),mode:`group`,origin:n,replyDrafts:{},replyThreadId:null,sourceRect:r},this.renderDrawer(),this.renderCard()}function ko(){this.activeCard=null,this.pendingCardFocusElement=null,this.reactionPicker=null,this.renderCard(),this.scheduleLayoutRefresh()}function Ao(){return this.activeCard?this.activeCard.origin===`editor`?this.session?.getCommentAnchorClientRect?.(this.activeCard.anchor)??this.activeCard.sourceRect:this.activeCard.origin===`editor-chip`?this.activeCard.sourceRect:this.activeCard.origin===`preview`?this.resolvePreviewTarget(this.activeCard.anchor)?.bubbleRect??this.activeCard.sourceRect:this.activeCard.origin===`toolbar`?this.commentSelectionButton?.getBoundingClientRect?.()??this.activeCard.sourceRect:this.activeCard.sourceRect:null}function jo(e){return e instanceof HTMLTextAreaElement?{selectionDirection:e.selectionDirection??`none`,selectionEnd:e.selectionEnd,selectionStart:e.selectionStart,value:e.value}:null}function Mo(){if(!this.activeCard)return;let e=this.cardRoot?.querySelector(`.comment-card-input`),t=jo(e);if(t){if(this.activeCard.mode===`create`){this.activeCard.composerDraft=t;return}this.activeCard.mode===`group`&&this.activeCard.replyThreadId&&(this.activeCard.replyDrafts={...this.activeCard.replyDrafts??{},[this.activeCard.replyThreadId]:t})}}function No(e,t=null){return{element:e,selectionDirection:t?.selectionDirection??`none`,selectionEnd:Number.isInteger(t?.selectionEnd)?t.selectionEnd:null,selectionStart:Number.isInteger(t?.selectionStart)?t.selectionStart:null}}function Po(){let e=this.ensureCardRoot();if(this.captureActiveCardDraft(),e.replaceChildren(),e.classList.toggle(`hidden`,!this.activeCard),!this.activeCard){this.pendingCardFocusElement=null,e.style.visibility=``;return}this.pendingCardFocusElement=null;let t=document.createElement(`section`);t.className=`comment-card`,t.addEventListener(`click`,e=>{!this.reactionPicker||e.target?.closest?.(`.comment-reaction-picker-wrap`)||(this.reactionPicker=null,requestAnimationFrame(()=>{this.activeCard&&this.renderCard()}))});let n=document.createElement(`div`);n.className=`ui-record-header comment-card-header`;let r=document.createElement(`div`);r.className=`comment-card-title-wrap`;let i=document.createElement(`h3`);i.className=`comment-card-title`,i.textContent=this.activeCard.mode===`create`?`New comment`:`Comment threads`;let a=document.createElement(`p`);a.className=`comment-card-meta`,a.textContent=ao(this.activeCard.anchor),r.append(i,a);let o=document.createElement(`button`);o.type=`button`,o.className=G({variant:`ghost`,size:`compact`,pill:!0,extra:[`ui-action-pill`,`comment-card-close`]}),o.setAttribute(`aria-label`,`Close comments`),o.textContent=`Close`,o.addEventListener(`click`,()=>this.closeCard()),n.append(r,o),t.appendChild(n);let s=document.createElement(`div`);if(s.className=`comment-card-scroll`,this.activeCard.anchor?.quote){let e=document.createElement(`p`);e.className=`comment-card-quote`,e.textContent=this.activeCard.anchor.quote,s.appendChild(e)}if(this.activeCard.mode===`create`)s.appendChild(this.createComposer());else{let e=this.getThreadGroups().find(e=>e.key===this.activeCard.groupKey);if(!e){this.closeCard();return}e.threads.forEach(e=>{s.appendChild(this.createThreadElement(e))})}e.style.visibility=`hidden`,t.appendChild(s),e.appendChild(t),this.updateReactionPickerPosition(t),this.positionCard(t),e.style.visibility=``,this.flushPendingCardFocus(),this.scheduleLayoutRefresh()}function Fo(e){let t=go(e);if(!t)return;let{picker:n,scroll:r,wrap:i}=t;n.classList.remove(`is-upward`),n.style.maxHeight=``;let a=i.getBoundingClientRect(),o=r.getBoundingClientRect(),s=n.getBoundingClientRect(),c=window.innerHeight-12,l=Math.min(o.bottom,c),u=Math.max(o.top,12),d=Math.max(l-a.bottom-8,0),f=Math.max(a.top-u-8,0),p=s.height>d&&f>d,m=Math.max(p?f:d,120);n.classList.toggle(`is-upward`,p),n.style.maxHeight=`${m}px`}function Io(){let e=this.cardRoot?.firstElementChild;if(!e||!this.activeCard){this.cardRoot&&(this.cardRoot.style.visibility=``);return}this.positionCard(e),this.cardRoot.style.visibility=``,this.flushPendingCardFocus()}function Lo(){let e=document.createElement(`form`);e.className=`comment-card-form`;let t=document.createElement(`textarea`);t.className=K({extra:`comment-card-input`}),t.rows=4,t.maxLength=Ee,t.placeholder=`Add context, feedback, or a question...`,t.value=this.activeCard?.composerDraft?.value??``;let n=document.createElement(`div`);n.className=`ui-record-actions comment-card-actions`;let r=document.createElement(`button`);r.type=`button`,r.className=G({variant:`secondary`}),r.textContent=`Cancel`,r.addEventListener(`click`,()=>this.closeCard());let i=document.createElement(`button`);return i.type=`submit`,i.className=G({variant:`primary`}),i.textContent=`Post comment`,n.append(r,i),e.append(t,n),e.addEventListener(`submit`,async e=>{if(e.preventDefault(),!await this.onCreateThread?.({anchor:this.activeCard?.anchor,body:t.value})){t.focus();return}this.closeCard()}),this.pendingCardFocusElement=No(t,this.activeCard?.composerDraft),e}function Ro(e){let t=document.createElement(`article`);t.className=`comment-thread-card`;let n=document.createElement(`div`);n.className=`ui-record-header comment-thread-card-header`;let r=document.createElement(`div`);r.className=`comment-thread-card-heading`;let i=document.createElement(`span`);i.className=`comment-thread-card-author`,i.textContent=e.createdByName;let a=document.createElement(`span`);a.className=`comment-thread-card-time`,a.textContent=this.formatTimestamp(e.createdAt);let o=document.createElement(`div`);o.className=`ui-record-actions comment-thread-card-actions`;let s=document.createElement(`button`);s.type=`button`,s.className=G({variant:`ghost`,size:`compact`,pill:!0,extra:[`ui-action-pill`,`comment-thread-card-action`]}),s.textContent=`Jump`,s.addEventListener(`click`,()=>this.onNavigateToLine?.(e.anchor?.startLine??1));let c=document.createElement(`button`);c.type=`button`,c.className=G({variant:`ghost`,size:`compact`,pill:!0,extra:[`ui-action-pill`,`comment-thread-card-action`]});let l=this.activeCard?.replyThreadId===e.id;c.classList.toggle(`is-active`,l),c.textContent=`Reply`,c.setAttribute(`aria-pressed`,String(l)),c.setAttribute(`aria-label`,l?`Cancel reply`:`Reply to thread`),c.title=l?`Cancel reply`:`Reply to thread`,c.addEventListener(`click`,()=>{l&&this.activeCard?.replyDrafts?.[e.id]&&delete this.activeCard.replyDrafts[e.id],this.activeCard={...this.activeCard,replyThreadId:l?null:e.id},this.renderCard()});let u=document.createElement(`button`);return u.type=`button`,u.className=G({variant:`ghost`,size:`compact`,pill:!0,extra:[`ui-action-pill`,`comment-thread-card-action`,`is-danger`]}),u.textContent=`Resolve`,u.addEventListener(`click`,async()=>{await this.onResolveThread?.(e.id)}),o.append(s,c,u),r.append(i,a),n.append(r,o),t.append(n),e.messages.forEach(n=>{t.appendChild(this.createMessageElement(e,n))}),this.activeCard?.replyThreadId===e.id&&t.appendChild(this.createReplyComposer(e)),t}function zo(e,t){let n=document.createElement(`div`);n.className=`comment-message-card`;let r=document.createElement(`div`);r.className=`ui-record-meta comment-message-card-meta`;let i=document.createElement(`span`);i.className=`comment-message-card-author`,i.textContent=t.userName;let a=document.createElement(`span`);a.className=`comment-message-card-time`,a.textContent=this.formatTimestamp(t.createdAt);let o=fo(t.body,`comment-message-card-body comment-markdown`);return r.append(i,a),n.append(r,o),n.appendChild(this.createReactionBar(e,t)),n}function Bo(e,t){let n=this.session?.getLocalUser?.()?.userId??``,r=document.createElement(`div`);r.className=`comment-reaction-bar`;let i=new Set((t.reactions??[]).map(e=>e.emoji)),a=document.createElement(`div`);a.className=`comment-reaction-chips`,(t.reactions??[]).forEach(r=>{let i=document.createElement(`button`);i.type=`button`,i.className=`ui-chip-button ui-chip-button--comment comment-reaction-chip`,i.classList.toggle(`is-active`,po(r,n)),i.setAttribute(`aria-pressed`,String(po(r,n))),i.title=r.users?.map(e=>e.userName).join(`, `)||r.emoji;let o=document.createElement(`span`);o.className=`comment-reaction-chip-emoji`,o.textContent=r.emoji;let s=document.createElement(`span`);s.className=`comment-reaction-chip-count`,s.textContent=mo(r),i.append(o,s),i.addEventListener(`click`,async()=>{await this.onToggleReaction?.(e.id,t.id,r.emoji)}),a.appendChild(i)});let o=document.createElement(`div`);o.className=`comment-reaction-actions`,Qa.filter(e=>!i.has(e)).forEach(n=>{o.appendChild(this.createQuickReactionButton(e,t,n))});let s=document.createElement(`div`);s.className=`comment-reaction-picker-wrap`;let c=document.createElement(`button`);return c.type=`button`,c.className=`ui-chip-button ui-chip-button--comment comment-reaction-more-trigger`,c.dataset.reactionPickerToggle=`true`,c.setAttribute(`aria-expanded`,String(ho(this.reactionPicker,e.id,t.id))),c.textContent=`More`,c.addEventListener(`click`,()=>{let n=ho(this.reactionPicker,e.id,t.id);this.reactionPicker=n?null:{messageId:t.id,threadId:e.id},this.renderCard()}),s.appendChild(c),ho(this.reactionPicker,e.id,t.id)&&s.appendChild(this.createReactionPicker(e,t)),o.appendChild(s),r.append(a,o),r}function Vo(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`ui-icon-chip ui-icon-chip--comment comment-reaction-quick-add`,r.textContent=n,r.title=`React with ${n}`,r.addEventListener(`click`,async()=>{await this.onToggleReaction?.(e.id,t.id,n)}),r}function Ho(e,t){let n=document.createElement(`div`);n.className=`comment-reaction-picker`;let r=document.createElement(`div`);return r.className=`comment-reaction-picker-grid`,$a.forEach(n=>{r.appendChild(this.createReactionPickerButton(e,t,n))}),n.appendChild(r),n}function Uo(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`ui-icon-chip ui-icon-chip--comment comment-reaction-picker-btn`,r.textContent=n,r.title=`React with ${n}`,r.addEventListener(`click`,async()=>{await this.onToggleReaction?.(e.id,t.id,n)&&(this.reactionPicker=null,this.renderCard())}),r}function Wo(e){let t=document.createElement(`form`);t.className=`comment-reply-form`;let n=this.activeCard?.replyDrafts?.[e.id]??null,r=document.createElement(`textarea`);r.className=K({extra:`comment-card-input`}),r.rows=3,r.maxLength=Ee,r.placeholder=`Reply to thread...`,r.value=n?.value??``;let i=document.createElement(`div`);i.className=`ui-record-actions comment-card-actions`;let a=document.createElement(`button`);a.type=`button`,a.className=G({variant:`secondary`}),a.textContent=`Cancel`,a.addEventListener(`click`,()=>{this.activeCard?.replyDrafts?.[e.id]&&delete this.activeCard.replyDrafts[e.id],this.activeCard={...this.activeCard,replyThreadId:null},this.renderCard()});let o=document.createElement(`button`);return o.type=`submit`,o.className=G({variant:`primary`}),o.textContent=`Reply`,i.append(a,o),t.append(r,i),this.pendingCardFocusElement=No(r,n),t.addEventListener(`submit`,async t=>{if(t.preventDefault(),!await this.onReplyToThread?.(e.id,r.value)){r.focus();return}this.activeCard?.replyDrafts?.[e.id]&&delete this.activeCard.replyDrafts[e.id],this.activeCard={...this.activeCard,replyThreadId:null},this.renderCard()}),t}function Go(e){let t=this.updateCardSourceRect(),n=window.innerWidth,r=window.innerHeight,i=e.getBoundingClientRect(),a=eo((n-i.width)/2,16,n-i.width-16),o=eo((r-i.height)/4,16,r-i.height-16),s=a,c=o;t&&(s=eo(t.left,16,n-Math.min(i.width,520)-16),c=t.bottom+14,c+i.height>r-16&&(c=Math.max(t.top-i.height-14,16))),this.cardRoot.style.left=`${s}px`,this.cardRoot.style.top=`${c}px`,this.cardRoot.style.width=`${Math.min(Math.max(i.width,520),n-32)}px`}function Ko(){let e=this.pendingCardFocusElement,t=e instanceof HTMLElement?e:e?.element;if(!(t instanceof HTMLElement)||!t.isConnected){this.pendingCardFocusElement=null;return}this.pendingCardFocusElement=null;let n=()=>{if(!t.isConnected)return;let n=document.activeElement;n instanceof HTMLElement&&this.editorContainer?.contains(n)&&n.blur(),t.focus({preventScroll:!0}),t instanceof HTMLTextAreaElement&&Number.isInteger(e?.selectionStart)&&Number.isInteger(e?.selectionEnd)&&t.setSelectionRange(e.selectionStart,e.selectionEnd,e.selectionDirection??`none`)};n(),document.activeElement!==t&&requestAnimationFrame(()=>{n(),document.activeElement!==t&&setTimeout(()=>{n()},50)})}var qo={captureActiveCardDraft:Mo,closeCard:ko,createComposer:Lo,createPendingFocusTarget:No,createMessageElement:zo,createQuickReactionButton:Vo,createReactionBar:Bo,createReactionPicker:Ho,createReactionPickerButton:Uo,createReplyComposer:Wo,createTextareaDraft:jo,createThreadElement:Ro,ensureCardRoot:Eo,flushPendingCardFocus:Ko,openComposerForSelection:Do,openThreadGroup:Oo,positionCard:Go,renderCard:Po,repositionActiveCard:Io,updateCardSourceRect:Ao,updateReactionPickerPosition:Fo};function Jo(){this.renderEditorLayer(),this.renderPreviewLayer(),this.repositionActiveCard()}function Yo(e=0){if(!this.previewElement)return!1;let t=this.supported&&e>0,n=0,r=0;if(t){let t=getComputedStyle(this.previewElement),i=Number.parseFloat(t.getPropertyValue(`--preview-comment-rail-reserved`))||0,a=Number.parseFloat(t.paddingRight)||0,o=Number.parseFloat(t.getPropertyValue(`--preview-comment-rail-inset`))||0,s=Math.max(a-i,0),c=Math.max(e+o-s,0),l=this.previewContainer?.getBoundingClientRect(),u=this.previewElement.getBoundingClientRect(),d=l?Math.max(l.right-u.right,0):0;r=Math.min(d,c),n=Math.max(c-r,0)}let i=`${Math.ceil(n)}px`,a=`${Math.floor(r)}px`,o=this.previewElement.style.getPropertyValue(`--preview-comment-rail-reserved`)!==i||this.previewElement.style.getPropertyValue(`--preview-comment-rail-offset`)!==a;return o&&(this.previewElement.style.setProperty(`--preview-comment-rail-reserved`,i),this.previewElement.style.setProperty(`--preview-comment-rail-offset`,a)),o}function Xo(){this.layoutFrame||=requestAnimationFrame(()=>{this.layoutFrame=0,this.refreshLayout()})}function Zo(){if(this.editorLayer?.isConnected&&this.editorLayer.parentElement===this.editorContainer)return this.editorLayer;let e=document.createElement(`div`);return e.className=`comment-editor-layer`,this.editorContainer?.appendChild(e),this.editorLayer=e,e}function Qo(){let e=this.ensureEditorLayer();if(e.replaceChildren(),!this.supported||!this.session)return;let t=this.editorContainer?.getBoundingClientRect?.();if(!t)return;let n=this.getThreadGroups(),r=[];if(n.forEach(n=>{let i=this.session.getCommentAnchorClientRect?.(n.anchor);if(!i)return;let a=bo(i,t);if(a.bottom<0||a.top>t.height)return;let o=document.createElement(`button`);o.type=`button`,o.className=`ui-state-marker ui-state-marker--comment comment-editor-badge`,o.dataset.count=String(n.threads.length);let s=this.activeCard?.groupKey===n.key,c=this.hoveredEditorGroupKeys.includes(n.key);o.classList.toggle(`is-active`,s),o.classList.toggle(`is-hovered`,c),o.classList.toggle(`is-passive`,!s&&!c),o.setAttribute(`aria-label`,`${n.threads.length} comment thread${n.threads.length===1?``:`s`}`),o.appendChild(To(n.threads.length));let l=Math.max(a.top,8);o.style.top=`${l}px`,o.style.left=`${Math.max(t.width-36,8)}px`,o.title=`${n.threads.length} comment${n.threads.length===1?``:`s`}`,o.addEventListener(`pointerdown`,e=>{e.preventDefault()}),o.addEventListener(`pointerenter`,()=>{this.updateHoveredEditorGroups([n.key])}),o.addEventListener(`pointerleave`,()=>{this.updateHoveredEditorGroups([])}),o.addEventListener(`focusin`,()=>{this.updateHoveredEditorGroups([n.key])}),o.addEventListener(`focusout`,()=>{this.updateHoveredEditorGroups([])}),o.addEventListener(`click`,()=>{this.openThreadGroup(n,{anchor:n.anchor,origin:`editor`,sourceRect:i})}),e.appendChild(o),r.push(l)}),!this.committedSelectionAnchor||this.activeCard?.mode===`create`)return;let i=this.session.getCommentAnchorClientRect?.(this.committedSelectionAnchor),a=this.session.getSelectionChipClientRect?.(this.committedSelectionAnchor)??i;if(!a)return;let o=bo(a,t);if(o.bottom<0||o.top>t.height)return;let s=eo(o.top,8,Math.max(t.height-36,8));for(;r.some(e=>Math.abs(e-s)<32);)s=eo(s+36,8,Math.max(t.height-36,8));let c=document.createElement(`button`);c.type=`button`,c.className=`ui-selection-pill ui-selection-pill--comment comment-selection-chip`,c.textContent=`Comment`,c.style.top=`${s}px`,c.style.right=`12px`,c.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),this.openComposerForSelection(`editor`,c.getBoundingClientRect())}),e.appendChild(c)}function $o(){if(this.previewLayer?.isConnected&&this.previewLayer.parentElement===this.previewElement)return this.previewLayer;let e=document.createElement(`div`);e.className=`comment-preview-highlights`;let t=document.createElement(`div`);return t.className=`comment-preview-layer`,this.previewElement?.append(e,t),this.previewHighlightLayer=e,this.previewLayer=t,t}function es(){if(this.ensurePreviewLayer(),this.previewLayer?.replaceChildren(),this.previewHighlightLayer?.replaceChildren(),!this.supported||!this.previewElement){this.previewHoverRegions=[],this.syncPreviewRailLayout(0);return}let e=this.previewElement.getBoundingClientRect(),t=this.getThreadGroups(),n=[],r=[],i=this.shouldRenderPassivePreviewMarkers(),a=[];t.forEach(t=>{let o=this.resolvePreviewTarget(t.anchor);if(!o?.bubbleRect)return;r.push({key:t.key,rects:o.hoverRects?.length>0?o.hoverRects:[o.bubbleRect]});let s=this.activeCard?.groupKey===t.key,c=this.hoveredPreviewGroupKeys.includes(t.key),l=s||c;if(o.highlightRects?.forEach(t=>{let n=document.createElement(`div`);n.className=`comment-preview-highlight`,n.classList.toggle(`is-active`,s),n.classList.toggle(`is-hovered`,c),n.classList.toggle(`is-passive`,!l),n.style.left=`${t.left-e.left}px`,n.style.top=`${t.top-e.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,this.previewHighlightLayer?.appendChild(n)}),!i&&!l)return;let u=document.createElement(`button`);u.type=`button`,u.className=`ui-state-marker ui-state-marker--comment comment-preview-badge`,u.dataset.commentPreviewGroupKeys=t.key,u.classList.toggle(`is-active`,s),u.classList.toggle(`is-hovered`,c),u.classList.toggle(`is-passive`,!l),u.setAttribute(`aria-label`,`${t.threads.length} comment thread${t.threads.length===1?``:`s`}`),u.appendChild(To(t.threads.length));let d=eo(o.bubbleRect.top-e.top,6,Math.max(this.previewElement.clientHeight-30,6));for(;n.some(e=>Math.abs(e-d)<26);)d=eo(d+30,6,Math.max(this.previewElement.clientHeight-30,6));u.style.top=`${d}px`,u.title=`${t.threads.length} comment${t.threads.length===1?``:`s`}`,u.addEventListener(`pointerdown`,e=>{e.preventDefault()}),u.addEventListener(`click`,()=>{this.openThreadGroup(t,{anchor:t.anchor,origin:`preview`,sourceRect:u.getBoundingClientRect()})}),this.previewLayer?.appendChild(u),n.push(d),a.push(u)}),this.previewHoverRegions=r;let o=a.reduce((e,t)=>Math.max(e,t.offsetWidth||28),0);this.syncPreviewRailLayout(o)&&this.scheduleLayoutRefresh(),this.lastPreviewPointerPosition&&this.updateHoveredPreviewGroups(this.getPreviewGroupKeysAtPoint(this.lastPreviewPointerPosition.x,this.lastPreviewPointerPosition.y))}function ts(e){if(!this.previewElement||!e)return null;let t=Array.from(this.previewElement.querySelectorAll(`.mermaid-shell, .plantuml-shell`)).find(t=>_o(t,e));if(t)return{bubbleRect:t.getBoundingClientRect(),highlightRects:[],hoverRects:[t.getBoundingClientRect()]};let n=Array.from(this.previewElement.querySelectorAll(`[data-source-line]`)).filter(t=>so(t)&&_o(t,e));if(e.kind===`text`&&e.quote){let t=n.map(t=>({element:t,range:yo(t,e.quote)})).filter(e=>e.range);if(t.length===1){let e=Array.from(t[0].range.getClientRects());return{bubbleRect:xo(e)||t[0].element.getBoundingClientRect(),highlightRects:e,hoverRects:e}}}let r=n[0];return r?{bubbleRect:r.getBoundingClientRect(),highlightRects:[],hoverRects:[r.getBoundingClientRect()]}:null}function ns(e){if(!(e instanceof Node))return[];let t=e.closest?.(`[data-comment-preview-group-keys]`);return wo(String(t?.dataset?.commentPreviewGroupKeys??``).split(/\s+/).filter(Boolean)).split(` `).filter(Boolean)}function rs(e,t){if(!Number.isFinite(e)||!Number.isFinite(t))return[];let n=document.elementFromPoint(e,t),r=this.getPreviewGroupKeysForTarget(n);return r.length>0?r:Co(this.previewHoverRegions.filter(n=>n.rects.some(n=>So(e,t,n))).map(e=>e.key))}function is(e=[]){let t=Co(e),n=t.join(` `);n!==this.hoveredPreviewGroupKeysSignature&&(this.hoveredPreviewGroupKeys=t,this.hoveredPreviewGroupKeysSignature=n,this.scheduleLayoutRefresh())}function as(e=[]){let t=Co(e),n=t.join(` `);n!==this.hoveredEditorGroupKeysSignature&&(this.hoveredEditorGroupKeys=t,this.hoveredEditorGroupKeysSignature=n,this.scheduleLayoutRefresh())}function os(e){this.updateHoveredPreviewGroups(this.getPreviewGroupKeysForTarget(e))}function ss(){let e=this.previewContainer?.clientWidth??this.previewElement?.clientWidth??0;return window.innerWidth>=769&&e>=400}var cs={ensureEditorLayer:Zo,ensurePreviewLayer:$o,getPreviewGroupKeysAtPoint:rs,getPreviewGroupKeysForTarget:ns,refreshLayout:Jo,renderEditorLayer:Qo,renderPreviewLayer:es,resolvePreviewTarget:ts,scheduleLayoutRefresh:Xo,shouldRenderPassivePreviewMarkers:ss,syncHoveredPreviewGroupsFromTarget:os,syncPreviewRailLayout:Yo,updateHoveredEditorGroups:as,updateHoveredPreviewGroups:is};function ls(){this.renderToolbar(),this.renderDrawer(),this.renderCard(),this.scheduleLayoutRefresh()}function us(){let e=this.threads.length,t=this.supported&&!!this.session;if(this.commentSelectionButton?.classList.toggle(`hidden`,!t),this.commentsToggleButton?.classList.toggle(`hidden`,!this.supported),this.commentSelectionButton&&(this.commentSelectionButton.disabled=!this.selectionAnchor),this.commentsToggleButton){this.commentsToggleButton.classList.toggle(`active`,this.drawerOpen),this.commentsToggleButton.setAttribute(`aria-expanded`,String(this.drawerOpen));let t=e>0?`Comments ${e}`:`Comments`,n=this.commentsToggleButton.querySelector(`.ui-action-label`);n?n.textContent=t:this.commentsToggleButton.textContent=t}}function ds(){if(!this.commentsDrawer||!this.commentsDrawerList)return;this.commentsDrawer.classList.toggle(`hidden`,!this.supported||!this.drawerOpen),this.commentsDrawerList.replaceChildren();let e=this.getThreadGroups();if(this.commentsDrawerEmpty?.classList.toggle(`hidden`,e.length>0),!this.supported||e.length===0)return;let t=document.createDocumentFragment();e.forEach(e=>{let n=document.createElement(`button`);n.type=`button`,n.className=`ui-record-surface comments-drawer-item`,n.classList.toggle(`is-active`,this.activeCard?.groupKey===e.key),n.addEventListener(`pointerdown`,e=>{e.preventDefault()}),n.addEventListener(`click`,()=>{this.openThreadGroup(e,{anchor:e.anchor,origin:`drawer`,sourceRect:n.getBoundingClientRect()})});let r=document.createElement(`div`);r.className=`ui-record-header comments-drawer-item-header`;let i=document.createElement(`span`);i.className=`comments-drawer-item-title`,i.textContent=ao(e.anchor);let a=document.createElement(`span`);a.className=`ui-pill-badge ui-pill-badge--count ui-pill-badge--accent comments-drawer-item-count`,a.textContent=String(e.threads.length),r.append(i,a);let o=document.createElement(`p`);o.className=`comments-drawer-item-quote`,o.textContent=e.anchor.quote||e.anchor.excerpt||`Source anchored comment`;let s=uo(e),c=fo(s?.body||``,`comment-markdown comments-drawer-item-preview`),l=document.createElement(`div`);l.className=`ui-record-meta comments-drawer-item-footer`;let u=document.createElement(`span`);u.textContent=`${e.threads.length} thread${e.threads.length===1?``:`s`}`;let d=document.createElement(`span`);d.className=`comments-drawer-item-updated`,d.textContent=s?`${s.userName} • ${this.formatTimestamp(s.createdAt)}`:``,l.append(u,d),n.append(r,o,c,l),t.appendChild(n)}),this.commentsDrawerList.appendChild(t)}function fs(e){if(!Number.isFinite(e))return``;try{return this.timeFormatter.format(new Date(e))}catch{return``}}var ps={formatTimestamp:fs,render:ls,renderDrawer:ds,renderToolbar:us};function ms(e){this.session?.getScrollContainer?.()?.removeEventListener(`scroll`,this.handleEditorScroll),this.session=e,this.selectionAnchor=e?.getCurrentSelectionCommentAnchor?.()??null,this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.reactionPicker=null,this.clearSelectionRevealTimer(),this.pointerSelecting=!1,e?.getScrollContainer?.()?.addEventListener(`scroll`,this.handleEditorScroll,{passive:!0}),this.render()}function hs(e,{fileKind:t=`markdown`,supported:n=!1}={}){let r=this.currentFile!==e;this.currentFile=e,this.fileKind=t,this.supported=!!(e&&n),r&&(this.drawerOpen=!1,this.threads=[],this.selectionAnchor=null,this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.clearSelectionRevealTimer(),this.pointerSelecting=!1,this.activeCard=null,this.updateHoveredEditorGroups([]),this.updateHoveredPreviewGroups([]),this.previewHoverRegions=[],this.lastPreviewPointerPosition=null,this.reactionPicker=null),this.supported||(this.drawerOpen=!1,this.activeCard=null,this.threads=[],this.selectionAnchor=null,this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.clearSelectionRevealTimer(),this.pointerSelecting=!1,this.updateHoveredEditorGroups([]),this.updateHoveredPreviewGroups([]),this.previewHoverRegions=[],this.lastPreviewPointerPosition=null,this.reactionPicker=null),this.render()}function gs(e){if(this.selectionAnchor=this.supported?e:null,!this.supported||!this.selectionAnchor){this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.clearSelectionRevealTimer(),this.renderToolbar(),this.scheduleLayoutRefresh();return}if(!ro(this.selectionAnchor)){this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.clearSelectionRevealTimer(),this.renderToolbar(),this.scheduleLayoutRefresh();return}if(this.pendingSelectionAnchor=this.selectionAnchor,this.activeCard?.mode===`create`){this.clearSelectionRevealTimer(),this.renderToolbar(),this.scheduleLayoutRefresh();return}if(this.pointerSelecting){this.clearSelectionRevealTimer(),this.committedSelectionAnchor=null,this.renderToolbar(),this.scheduleLayoutRefresh();return}if(io(this.committedSelectionAnchor,this.selectionAnchor)){this.renderToolbar(),this.scheduleLayoutRefresh();return}this.scheduleSelectionReveal(this.selectionAnchor),this.renderToolbar(),this.scheduleLayoutRefresh()}function _s(){this.activeCard?.mode!==`create`&&(this.clearSelectionRevealTimer(),this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.scheduleLayoutRefresh())}function vs(e=[]){this.threads=to(e);let t=this.getThreadGroups();if(this.activeCard?.mode===`group`){let e=Array.isArray(this.activeCard.groupThreadIds)?this.activeCard.groupThreadIds:[],n=t.find(e=>e.key===this.activeCard.groupKey)??t.find(t=>t.threads.length===e.length&&t.threads.every(t=>e.includes(t.id)));n?(this.activeCard={...this.activeCard,anchor:n.anchor,groupKey:n.key,groupThreadIds:n.threads.map(e=>e.id)},this.activeCard.replyThreadId&&!n.threads.some(e=>e.id===this.activeCard.replyThreadId)&&(this.activeCard.replyThreadId=null)):this.activeCard=null}this.reactionPicker&&!this.threads.some(e=>e.id===this.reactionPicker.threadId&&e.messages?.some(e=>e.id===this.reactionPicker.messageId))&&(this.reactionPicker=null),this.render()}function ys(e){let t=!!e;t!==this.drawerOpen&&(t&&this.onWillOpenDrawer?.(),this.drawerOpen=t,this.render())}function bs(){this.setDrawerOpen(!1)}function xs(){let e=new Map;return this.threads.forEach(t=>{let n=oo(t.anchor),r=e.get(n);if(r){r.threads.push(t);return}e.set(n,{anchor:t.anchor,key:n,threads:[t]})}),Array.from(e.values()).sort((e,t)=>(e.anchor?.startLine??0)-(t.anchor?.startLine??0))}function Ss(){this.selectionRevealTimer&&=(clearTimeout(this.selectionRevealTimer),0)}function Cs(e){this.clearSelectionRevealTimer(),this.selectionRevealTimer=window.setTimeout(()=>{this.selectionRevealTimer=0,!(this.pointerSelecting||this.activeCard?.mode===`create`||!io(this.pendingSelectionAnchor,e))&&(this.committedSelectionAnchor=e,this.scheduleLayoutRefresh())},150)}var ws={attachSession:ms,clearSelectionRevealTimer:Ss,closeDrawer:bs,getThreadGroups:xs,handleEditorContentChange:_s,scheduleSelectionReveal:Cs,setCurrentFile:hs,setDrawerOpen:ys,setSelectionAnchor:gs,setThreads:vs},Ts=class{constructor({commentSelectionButton:e,commentsDrawer:t,commentsDrawerEmpty:n,commentsDrawerList:r,commentsToggleButton:i,editorContainer:a,onWillOpenDrawer:o,onCreateThread:s,onNavigateToLine:c,onReplyToThread:l,onToggleReaction:u,onResolveThread:d,previewContainer:f,previewElement:p}){this.commentSelectionButton=e,this.commentsDrawer=t,this.commentsDrawerEmpty=n,this.commentsDrawerList=r,this.commentsToggleButton=i,this.editorContainer=a,this.onWillOpenDrawer=o,this.onCreateThread=s,this.onNavigateToLine=c,this.onReplyToThread=l,this.onToggleReaction=u,this.onResolveThread=d,this.previewContainer=f,this.previewElement=p,this.currentFile=null,this.fileKind=`markdown`,this.supported=!1,this.drawerOpen=!1,this.threads=[],this.selectionAnchor=null,this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.selectionRevealTimer=0,this.pointerSelecting=!1,this.session=null,this.activeCard=null,this.hoveredEditorGroupKeys=[],this.hoveredEditorGroupKeysSignature=``,this.hoveredPreviewGroupKeys=[],this.hoveredPreviewGroupKeysSignature=``,this.previewHoverRegions=[],this.lastPreviewPointerPosition=null,this.editorLayer=null,this.previewLayer=null,this.previewHighlightLayer=null,this.cardRoot=null,this.pendingCardFocusElement=null,this.reactionPicker=null,this.layoutFrame=0,this.timeFormatter=new Intl.DateTimeFormat(void 0,{day:`numeric`,hour:`numeric`,minute:`2-digit`,month:`short`}),this.handleEditorScroll=()=>this.scheduleLayoutRefresh(),this.handlePreviewScroll=()=>this.scheduleLayoutRefresh(),this.handleWindowResize=()=>this.scheduleLayoutRefresh(),this.handlePreviewPointerMove=e=>{this.lastPreviewPointerPosition={x:e.clientX,y:e.clientY},this.updateHoveredPreviewGroups(this.getPreviewGroupKeysAtPoint(e.clientX,e.clientY))},this.handlePreviewPointerLeave=()=>{this.lastPreviewPointerPosition=null,this.updateHoveredPreviewGroups([])},this.handlePreviewFocusIn=e=>{this.updateHoveredPreviewGroups(this.getPreviewGroupKeysForTarget(e.target))},this.handlePreviewFocusOut=e=>{this.updateHoveredPreviewGroups(this.getPreviewGroupKeysForTarget(e.relatedTarget))},this.handleCommentSelectionButtonPointerDown=e=>{e.preventDefault()},this.handleEditorPointerDown=e=>{e.button!==0||!this.supported||!this.session||!e.target?.closest?.(`.cm-editor`)||e.target?.closest?.(`.comment-editor-layer`)||(this.pointerSelecting=!0,this.clearSelectionRevealTimer(),this.committedSelectionAnchor&&(this.committedSelectionAnchor=null,this.scheduleLayoutRefresh()))},this.handleDocumentPointerUp=()=>{this.pointerSelecting&&requestAnimationFrame(()=>{let e=this.supported?this.session?.getCurrentSelectionCommentAnchor?.()??null:null;this.pointerSelecting=!1,this.selectionAnchor=e,this.renderToolbar(),this.pendingSelectionAnchor=ro(e)?e:null,this.clearSelectionRevealTimer(),this.committedSelectionAnchor=ro(e)&&this.activeCard?.mode!==`create`?e:null,this.scheduleLayoutRefresh()})},this.handleEditorFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&(this.editorContainer?.contains(t)||this.cardRoot?.contains(t)||this.commentSelectionButton?.contains(t))||(this.clearSelectionRevealTimer(),this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.scheduleLayoutRefresh())},this.handleDocumentPointerDown=e=>{let t=e.target;if(this.activeCard&&this.cardRoot){if(this.cardRoot.contains(t))return;this.closeCard()}this.drawerOpen&&(t instanceof Node&&(this.commentsDrawer?.contains(t)||this.commentsToggleButton?.contains(t))||this.closeDrawer())},this.handleDocumentKeyDown=e=>{if(e.key===`Escape`&&this.reactionPicker){this.reactionPicker=null,this.renderCard();return}e.key===`Escape`&&this.activeCard&&this.closeCard(),e.key===`Escape`&&this.committedSelectionAnchor&&(this.clearSelectionRevealTimer(),this.pendingSelectionAnchor=null,this.committedSelectionAnchor=null,this.scheduleLayoutRefresh())},this.commentSelectionButton?.addEventListener(`pointerdown`,this.handleCommentSelectionButtonPointerDown),this.commentSelectionButton?.addEventListener(`click`,()=>{this.openComposerForSelection(`toolbar`)}),this.commentsToggleButton?.addEventListener(`click`,()=>{this.setDrawerOpen(!this.drawerOpen)}),this.previewContainer?.addEventListener(`scroll`,this.handlePreviewScroll,{passive:!0}),this.previewElement?.addEventListener(`pointermove`,this.handlePreviewPointerMove,{passive:!0}),this.previewElement?.addEventListener(`pointerleave`,this.handlePreviewPointerLeave),this.previewElement?.addEventListener(`focusin`,this.handlePreviewFocusIn),this.previewElement?.addEventListener(`focusout`,this.handlePreviewFocusOut),this.editorContainer?.addEventListener(`pointerdown`,this.handleEditorPointerDown),this.editorContainer?.addEventListener(`focusout`,this.handleEditorFocusOut),window.addEventListener(`resize`,this.handleWindowResize),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerUp),document.addEventListener(`pointerdown`,this.handleDocumentPointerDown),document.addEventListener(`keydown`,this.handleDocumentKeyDown)}destroy(){this.layoutFrame&&=(cancelAnimationFrame(this.layoutFrame),0),this.attachSession(null),this.previewContainer?.removeEventListener(`scroll`,this.handlePreviewScroll),this.previewElement?.removeEventListener(`pointermove`,this.handlePreviewPointerMove),this.previewElement?.removeEventListener(`pointerleave`,this.handlePreviewPointerLeave),this.previewElement?.removeEventListener(`focusin`,this.handlePreviewFocusIn),this.previewElement?.removeEventListener(`focusout`,this.handlePreviewFocusOut),this.commentSelectionButton?.removeEventListener(`pointerdown`,this.handleCommentSelectionButtonPointerDown),this.editorContainer?.removeEventListener(`pointerdown`,this.handleEditorPointerDown),this.editorContainer?.removeEventListener(`focusout`,this.handleEditorFocusOut),window.removeEventListener(`resize`,this.handleWindowResize),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerUp),document.removeEventListener(`pointerdown`,this.handleDocumentPointerDown),document.removeEventListener(`keydown`,this.handleDocumentKeyDown),this.previewHoverRegions=[],this.cardRoot?.remove(),this.editorLayer?.remove(),this.previewLayer?.remove(),this.pendingCardFocusElement=null}};Object.assign(Ts.prototype,ws,ps,cs,qo);var Es=360,Ds=`https://viewer.diagrams.net/js/viewer-static.min.js`,Os=null;function ks(e,t){return typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e,{timeout:t}):window.setTimeout(()=>e({didTimeout:!1,timeRemaining:()=>0}),1)}function As(e){if(e!==null){if(typeof window.cancelIdleCallback==`function`){window.cancelIdleCallback(e);return}window.clearTimeout(e)}}function js(e,t,n){if(!e||!t)return!1;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();return i.bottom>=r.top-n&&i.top<=r.bottom+n}function Ms(){return window.GraphViewer?.processElements?Promise.resolve(window.GraphViewer):Os||(Os=new Promise((e,t)=>{let n=document.querySelector(`script[data-collabmd-drawio-viewer]`),r=n instanceof HTMLScriptElement?n:document.createElement(`script`),i=()=>{r.removeEventListener(`error`,a),r.removeEventListener(`load`,o)},a=()=>{i(),Os=null,t(Error(`Failed to load draw.io viewer`))},o=()=>{if(i(),!window.GraphViewer?.processElements){Os=null,t(Error(`draw.io viewer did not initialize`));return}e(window.GraphViewer)};r.addEventListener(`error`,a,{once:!0}),r.addEventListener(`load`,o,{once:!0}),n?window.GraphViewer?.processElements&&o():(r.src=Ds,r.async=!0,r.dataset.collabmdDrawioViewer=`true`,document.head.append(r))}),Os)}var Ns=class{constructor({getLocalUser:e,getTheme:t,onOpenFile:n=null,onOpenTextFile:r=null,onToggleQuickSwitcher:i=null,previewContainer:a,previewElement:o,toastController:s}){this.getLocalUser=e,this.getTheme=t,this.onOpenFile=n,this.onOpenTextFile=r,this.onToggleQuickSwitcher=i,this.previewContainer=a,this.previewElement=o,this.toastController=s,this.embedEntries=new Map,this.hydrationQueue=[],this.hydrationIdleId=null,this.hydrationPaused=!1,this.instanceCounter=0,this.maximizedEntry=null,this.maximizedRoot=null,this._onMessage=this._onMessage.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPreviewClick=this._onPreviewClick.bind(this),window.addEventListener(`message`,this._onMessage),window.addEventListener(`keydown`,this._onKeyDown),this.previewElement?.addEventListener(`click`,this._onPreviewClick)}destroy(){window.removeEventListener(`message`,this._onMessage),window.removeEventListener(`keydown`,this._onKeyDown),this.previewElement?.removeEventListener(`click`,this._onPreviewClick),As(this.hydrationIdleId),this.hydrationIdleId=null,this.hydrationQueue=[],this._exitMaximizedEntry(),document.body.classList.remove(`drawio-maximized-open`),this.embedEntries.forEach(e=>e.wrapper?.remove()),this.embedEntries.clear(),this.maximizedRoot?.remove(),this.maximizedRoot=null}detachForCommit(){As(this.hydrationIdleId),this.hydrationIdleId=null,this.hydrationQueue=[],this.embedEntries.forEach(e=>{e.placeholder=null})}setHydrationPaused(e){this.hydrationPaused=!!e,this.hydrationPaused||this.hydrateVisibleEmbeds()}reconcileEmbeds(e){this._exitMaximizedEntry();let t=Array.from(e.querySelectorAll(`.drawio-embed-placeholder[data-drawio-key]`)).map(e=>({filePath:e.dataset.drawioTarget||``,key:e.dataset.drawioKey||``,label:e.dataset.drawioLabel||e.dataset.drawioTarget||``,mode:e.dataset.drawioMode===`edit`?`edit`:`view`,placeholder:e})),n=new Map;t.forEach(e=>{let t=this.embedEntries.get(e.key)||null,r=t?{...t,...e}:{...e,iframe:null,imageElement:null,instanceId:``,queued:!1,viewerElement:null,wrapper:null};n.set(e.key,r)}),this.embedEntries.forEach((e,t)=>{n.has(t)||e.wrapper?.remove()}),this.embedEntries=n,this.embedEntries.forEach(e=>{e.wrapper?e.placeholder?.replaceWith(e.wrapper):e.queued=!1}),this.hydrationPaused||this.hydrateVisibleEmbeds()}hydrateVisibleEmbeds(){this.embedEntries.forEach(e=>{e.wrapper||!e.placeholder?.isConnected||(e.mode===`edit`||js(e.placeholder,this.previewContainer,Es))&&this.enqueueHydration(e)})}enqueueHydration(e){e.queued||(e.queued=!0,this.hydrationQueue.push(e),this.hydrationIdleId===null&&(this.hydrationIdleId=ks(()=>{this.hydrationIdleId=null,this.hydrationQueue.splice(0).forEach(e=>{e.queued=!1,this.hydrateEntry(e)})},200)))}hydrateEntry(e){if(!(!e.placeholder?.isConnected||e.wrapper)){if(e.mode===`view`){this.hydrateViewerEntry(e);return}this.hydrateIframeEntry(e)}}hydrateIframeEntry(e){if(!e.placeholder?.isConnected||e.wrapper)return;let t=document.createElement(`div`);t.className=`drawio-embed diagram-preview-shell${e.mode===`edit`?` is-direct-file`:``}`,t.dataset.file=e.filePath,t.dataset.drawioKey=e.key;let n=document.createElement(`div`);n.className=`drawio-embed-header diagram-preview-toolbar`;let r=document.createElement(`span`);r.className=`drawio-embed-icon`,r.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="7" height="6" rx="1"/><rect x="14" y="4" width="7" height="6" rx="1"/><rect x="8.5" y="14" width="7" height="6" rx="1"/><path d="M10 7h4"/><path d="M17.5 10v2.5"/><path d="M6.5 10v2.5"/><path d="M6.5 12.5h11"/></svg>`;let i=document.createElement(`span`);i.className=`drawio-embed-label`,i.textContent=e.label.replace(/\.drawio$/i,``),n.append(r,i),e.mode!==`edit`&&n.appendChild(this.createOpenButton(e)),n.appendChild(this.createMaximizeButton(e,t));let a=document.createElement(`iframe`);a.className=`drawio-embed-iframe`,a.loading=`lazy`,a.referrerPolicy=`strict-origin-when-cross-origin`,e.instanceId=`drawio-${++this.instanceCounter}`,a.dataset.instanceId=e.instanceId,a.src=this.buildIframeUrl(e),t.append(n,a),e.iframe=a,e.wrapper=t,e.placeholder.replaceWith(t)}async hydrateViewerEntry(e){if(!e.placeholder?.isConnected||e.wrapper)return;let t=document.createElement(`div`);t.className=`drawio-embed diagram-preview-shell is-static-preview`,t.dataset.file=e.filePath,t.dataset.drawioKey=e.key;let n=document.createElement(`div`);n.className=`drawio-embed-header diagram-preview-toolbar`;let r=document.createElement(`span`);r.className=`drawio-embed-icon`,r.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="7" height="6" rx="1"/><rect x="14" y="4" width="7" height="6" rx="1"/><rect x="8.5" y="14" width="7" height="6" rx="1"/><path d="M10 7h4"/><path d="M17.5 10v2.5"/><path d="M6.5 10v2.5"/><path d="M6.5 12.5h11"/></svg>`;let i=document.createElement(`span`);i.className=`drawio-embed-label`,i.textContent=e.label.replace(/\.drawio$/i,``),n.append(r,i),n.append(this.createOpenButton(e),this.createMaximizeButton(e,t));let a=document.createElement(`div`);a.className=`drawio-viewer-shell`,a.dataset.filePath=e.filePath;let o=document.createElement(`div`);o.className=`preview-shell`,o.textContent=`Rendering draw.io preview…`,a.appendChild(o),t.append(n,a),e.iframe=null,e.wrapper=t,e.viewerElement=a,e.placeholder.replaceWith(t);try{await this.renderViewerEntry(e)}catch(t){this.renderViewerFallback(e,t instanceof Error?t.message:`Failed to render draw.io preview`)}}async renderViewerEntry(e){let[{content:t},n]=await Promise.all([w.readFile(e.filePath),Ms()]);if(!e.wrapper?.isConnected||!e.viewerElement?.isConnected)return;let r=this.getTheme?.()===`light`?`light`:`dark`,i=document.createElement(`div`);i.className=`mxgraph drawio-viewer-frame`,i.dataset.action=`open-file`,i.dataset.filePath=e.filePath,i.setAttribute(`role`,`button`),i.setAttribute(`tabindex`,`0`),i.setAttribute(`aria-label`,`Open ${e.label.replace(/\.drawio$/i,``)}`),i.addEventListener(`click`,t=>{t.preventDefault(),this.onOpenFile?.(e.filePath)}),i.addEventListener(`keydown`,t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),this.onOpenFile?.(e.filePath))}),i.dataset.mxgraph=JSON.stringify({"check-visible-state":!1,center:!0,border:0,"dark-mode":r,editable:!1,fit:1,lightbox:!1,nav:!1,resize:!1,toolbar:``,tooltips:!1,xml:String(t??``)}),e.viewerElement.replaceChildren(i),e.viewerElement=i,n.processElements()}buildIframeUrl(e){let t=new URL(O(`/drawio-editor.html`)),n=this.getLocalUser?.()??{};return t.searchParams.set(`file`,e.filePath),t.searchParams.set(`hostMode`,e.mode===`edit`?`file-preview`:`embed`),t.searchParams.set(`instanceId`,e.instanceId),t.searchParams.set(`mode`,e.mode===`edit`?`edit`:`view`),t.searchParams.set(`theme`,this.getTheme?.()===`light`?`light`:`dark`),n.name&&t.searchParams.set(`userName`,n.name),n.peerId&&t.searchParams.set(`peerId`,n.peerId),e.mode===`edit`&&t.searchParams.set(`leaseRoom`,j(e.filePath)),t.toString()}updateTheme(e){this.embedEntries.forEach(t=>{t.iframe?.contentWindow&&t.iframe.contentWindow.postMessage({source:`collabmd-host`,theme:e,type:`set-theme`},window.location.origin),t.mode===`view`&&t.wrapper?.isConnected&&t.viewerElement?.isConnected&&this.renderViewerEntry(t).catch(e=>{this.renderViewerFallback(t,e instanceof Error?e.message:`Failed to render draw.io preview`)})})}updateLocalUser(){}syncLayout(){}createOpenButton(e){let t=document.createElement(`button`);return t.type=`button`,t.className=`drawio-embed-btn ui-preview-action ui-preview-action--icon-only`,t.dataset.action=`open-file`,t.dataset.filePath=e.filePath,t.title=`Edit in draw.io`,t.setAttribute(`aria-label`,`Edit in draw.io`),F(t,`edit`),t.addEventListener(`click`,t=>{t.preventDefault(),this.onOpenFile?.(e.filePath)}),t}createMaximizeButton(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`drawio-embed-btn ui-preview-action ui-preview-action--icon-only`,n.dataset.action=`toggle-maximize`,n.dataset.filePath=e.filePath,n.dataset.drawioKey=e.key,n.addEventListener(`click`,n=>{n.preventDefault(),this.maximizedEntry?.key===e.key?this._exitMaximizedEntry():this._enterMaximizedEntry(e,t),this._syncMaximizeButtons()}),(()=>{let t=this.maximizedEntry?.key===e.key;F(n,t?`restore`:`maximize`),n.title=t?`Restore diagram size`:`Maximize diagram`,n.setAttribute(`aria-label`,t?`Restore diagram size`:`Maximize diagram`)})(),n}_ensureMaximizedRoot(){if(this.maximizedRoot?.isConnected&&this.maximizedRoot.parentElement===document.body)return this.maximizedRoot;let e=document.body.querySelector(`[data-drawio-maximized-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.drawioMaximizedRoot=`true`,e.className=`drawio-maximized-root`,document.body.appendChild(e)),this.maximizedRoot=e,e}_enterMaximizedEntry(e,t=e?.wrapper){if(!e?.wrapper||e.wrapper!==t||this.maximizedEntry?.key===e.key)return;this._exitMaximizedEntry();let n=this._ensureMaximizedRoot(),r=e.wrapper.parentElement;if(!r)return;let i=document.createElement(`div`);i.className=`drawio-maximize-spacer`,i.style.height=`${Math.ceil(e.wrapper.getBoundingClientRect().height)}px`,e.maximizeSpacer=i,e.restoreParent=r,e.restoreNextSibling=e.wrapper.nextSibling||null,r.insertBefore(i,e.wrapper),n.hidden=!1,n.appendChild(e.wrapper),e.wrapper.classList.add(`is-maximized`),document.body.classList.add(`drawio-maximized-open`),this.maximizedEntry=e}_exitMaximizedEntry(){let e=this.maximizedEntry;if(!e?.wrapper){this.maximizedEntry=null,document.body.classList.remove(`drawio-maximized-open`);return}let{maximizeSpacer:t,restoreNextSibling:n,restoreParent:r}=e;e.wrapper.classList.remove(`is-maximized`),t?.parentElement?t.replaceWith(e.wrapper):r?.isConnected&&(n?.parentElement===r?r.insertBefore(e.wrapper,n):r.appendChild(e.wrapper)),e.maximizeSpacer=null,e.restoreParent=null,e.restoreNextSibling=null,this.maximizedEntry=null,document.body.classList.remove(`drawio-maximized-open`),this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}_syncMaximizeButtons(){this.embedEntries.forEach(e=>{let t=e.wrapper?.querySelector(`.drawio-embed-btn[data-action="toggle-maximize"]`);if(!(t instanceof HTMLElement))return;let n=this.maximizedEntry?.key===e.key;F(t,n?`restore`:`maximize`),t.title=n?`Restore diagram size`:`Maximize diagram`,t.setAttribute(`aria-label`,n?`Restore diagram size`:`Maximize diagram`)})}_findEntryByInstanceId(e){for(let t of this.embedEntries.values())if(t.instanceId===e)return t;return null}_isMessageFromEntry(e,t){return!!(t?.iframe?.contentWindow&&e.source===t.iframe.contentWindow)}_onMessage(e){if(e.origin!==window.location.origin)return;let t=e.data;if(!t||t.source!==`drawio-editor`)return;let n=this._findEntryByInstanceId(t.instanceId);if(n&&this._isMessageFromEntry(e,n)){if(t.type===`fallback-text`){if(n.mode===`view`){this.renderViewerFallback(n,`Failed to render draw.io preview`);return}this.onOpenTextFile?.(n.filePath);return}if(t.type===`error`){if(n.mode===`view`){this.renderViewerFallback(n,t.message||`Failed to load draw.io preview`);return}this.toastController?.show?.(t.message||`Failed to load draw.io`);return}if(t.type===`request-open-file`){this.onOpenFile?.(n.filePath);return}t.type===`request-toggle-quick-switcher`&&this.onToggleQuickSwitcher?.()}}_onPreviewClick(e){let t=e.target.closest(`.drawio-embed-placeholder-btn`);if(t){let n=t.closest(`.drawio-embed-placeholder`)?.dataset.drawioKey||``,r=this.embedEntries.get(n);r&&(e.preventDefault(),this.hydrateEntry(r));return}}_onKeyDown(e){e.key===`Escape`&&(this._exitMaximizedEntry(),this._syncMaximizeButtons())}renderViewerFallback(e,t){if(!e.wrapper)return;let n=e.wrapper.querySelector(`.drawio-viewer-shell, .drawio-viewer-frame`);if(!n)return;let r=document.createElement(`div`);r.className=`preview-shell`,r.textContent=t,n.replaceChildren(r),e.viewerElement=r}};function Ps(e,t){let n=new Map;t.forEach(t=>{let r=e.get(t.key)??{filePath:t.filePath,iframe:null,instanceId:null,key:t.key,label:t.label,placeholder:t.placeholder,queued:!1,wrapper:null};r.filePath=t.filePath,r.key=t.key,r.label=t.label,r.placeholder=t.placeholder,n.set(t.key,r)});let r=[];return e.forEach((e,t)=>{n.has(t)||r.push(e)}),{nextEntries:n,removedEntries:r}}var Fs=420,Is=500,Ls=15e3,Rs=800,zs=3,Bs=200,Vs=`/excalidraw-editor.html`;function Hs(e,t){return typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e,{timeout:t}):window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>0})},1)}function Us(e){if(e!==null){if(typeof window.cancelIdleCallback==`function`){window.cancelIdleCallback(e);return}window.clearTimeout(e)}}function Ws(e,t,n){if(!e||!t)return!1;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();return i.bottom>=r.top-n&&i.top<=r.bottom+n}var Gs=class{constructor({getTheme:e,getLocalUser:t,onOpenFile:n=null,onToggleQuickSwitcher:r=null,previewContainer:i,previewElement:a,toastController:o}){this.getTheme=e,this.getLocalUser=t,this.onOpenFile=n,this.onToggleQuickSwitcher=r,this.previewContainer=i,this.previewElement=a,this.toastController=o,this.embedEntries=new Map,this.hydrationQueue=[],this.hydrationIdleId=null,this.hydrationPaused=!1,this.hydrationInProgress=!1,this.instanceCounter=0,this.isLargeDocument=!1,this.maximizedEmbed=null,this.overlayRoot=null,this.maximizedRoot=null,this.warmCacheRoot=null,this.warmEntry=null,this.placeholderObserver=null,this.followedPeerIdsByFilePath=new Map,this.pendingDisconnectRequests=new Map,this.disconnectRequestCounter=0,this._onMessage=this._onMessage.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPreviewClick=this._onPreviewClick.bind(this),window.addEventListener(`message`,this._onMessage),window.addEventListener(`keydown`,this._onKeyDown),this.previewElement?.addEventListener(`click`,this._onPreviewClick)}destroy(){window.removeEventListener(`message`,this._onMessage),window.removeEventListener(`keydown`,this._onKeyDown),this.previewElement?.removeEventListener(`click`,this._onPreviewClick),this._disconnectPlaceholderObserver(),Us(this.hydrationIdleId),this.hydrationIdleId=null,this.hydrationQueue=[],this._exitMaximizedEmbed(),document.body.classList.remove(`excalidraw-maximized-open`),this.embedEntries.forEach(e=>{this._clearEntryBootTimeout(e),e.wrapper?.remove(),e.placeholder=null}),this.embedEntries.clear(),this.warmEntry&&=(this._clearEntryBootTimeout(this.warmEntry),this.warmEntry.wrapper?.remove(),null),this.pendingDisconnectRequests.forEach(e=>{e.resolve(!1)}),this.pendingDisconnectRequests.clear(),this.followedPeerIdsByFilePath.clear(),this.overlayRoot?.remove(),this.overlayRoot=null,this.maximizedRoot?.remove(),this.maximizedRoot=null,this.warmCacheRoot?.remove(),this.warmCacheRoot=null}async setFollowedUser(e,t=null){if(!e)return!1;this.followedPeerIdsByFilePath.set(e,t||null);let n=this._findEntryByFilePath(e);return n?(n.wrapper||await this._hydrateEntry(n),n.followedPeerId=this.followedPeerIdsByFilePath.get(e)??null,this._syncEntryFollowState(n),!0):!0}detachForCommit(){this._disconnectPlaceholderObserver(),Us(this.hydrationIdleId),this.hydrationIdleId=null,this.hydrationQueue=[],this.hydrationInProgress=!1,this._exitMaximizedEmbed(),this.overlayRoot&&(this.overlayRoot.hidden=!0),this.maximizedRoot&&(this.maximizedRoot.hidden=!0),this.embedEntries.forEach(e=>{e.queued=!1,e.placeholder=null})}setHydrationPaused(e){if(this.hydrationPaused=!!e,this.hydrationPaused){Us(this.hydrationIdleId),this.hydrationIdleId=null;return}this.hydrateVisibleEmbeds(),this._scheduleHydration()}reconcileEmbeds(e,{isLargeDocument:t=!1}={}){this.isLargeDocument=!!t,this._disconnectPlaceholderObserver(),Us(this.hydrationIdleId),this.hydrationIdleId=null,this.hydrationQueue=[],this.hydrationInProgress=!1;let n=Array.from(e.querySelectorAll(`.excalidraw-embed-placeholder[data-embed-key]`)).map(e=>({filePath:e.dataset.embedTarget,key:e.dataset.embedKey,label:e.dataset.embedLabel||e.dataset.embedTarget,placeholder:e})),{nextEntries:r,removedEntries:i}=Ps(this.embedEntries,n);this._captureWarmEntry(i),this._adoptReusableEntries(r,i),i.forEach(e=>this._destroyEntry(e)),this.embedEntries=r,this._ensurePlaceholderObserver(),this.embedEntries.forEach(e=>{if(e.queued=!1,e.followedPeerId=this.followedPeerIdsByFilePath.get(e.filePath),e.wrapper){this._hydrateEntry(e);return}e.placeholder&&this.placeholderObserver?.observe(e.placeholder)}),this.hydrationPaused||this.hydrateVisibleEmbeds(),this.syncLayout()}hydrateVisibleEmbeds(){if(this.hydrationPaused)return;let e=this.isLargeDocument?180:420;this.embedEntries.forEach(t=>{t.wrapper||!t.placeholder?.isConnected||Ws(t.placeholder,this.previewContainer,e)&&this._enqueueHydration(t,{prioritize:!0})})}updateTheme(e){this._forEachManagedEntry(t=>{this._postMessageToEntry(t,{source:`collabmd-host`,type:`set-theme`,theme:e})})}updateLocalUser(e){this._forEachManagedEntry(t=>{this._syncEntryUser(t,e)})}prepareFileDisconnect(e,{timeoutMs:t=250}={}){let n=this._findEntryByFilePath(e);if(!n?.iframe?.contentWindow)return Promise.resolve(!1);let r=`disconnect-${++this.disconnectRequestCounter}`;return new Promise(e=>{let i=t=>{if(!this.pendingDisconnectRequests.has(r))return;let n=this.pendingDisconnectRequests.get(r);window.clearTimeout(n.timeoutId),this.pendingDisconnectRequests.delete(r),e(t)},a=window.setTimeout(()=>{i(!1)},t);this.pendingDisconnectRequests.set(r,{entry:n,resolve:i,timeoutId:a}),this._postMessageToEntry(n,{source:`collabmd-host`,type:`prepare-disconnect`,requestId:r})})}_ensurePlaceholderObserver(){this.previewContainer&&(this.placeholderObserver=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;let t=this.embedEntries.get(e.target.dataset.embedKey);t&&this._enqueueHydration(t)})},{root:this.previewContainer,rootMargin:this.isLargeDocument?`180px 0px`:`420px 0px`}))}_disconnectPlaceholderObserver(){this.placeholderObserver&&=(this.placeholderObserver.disconnect(),null)}_enqueueHydration(e,{prioritize:t=!1}={}){if(!(!e||e.wrapper||e.queued)&&(e.queued=!0,t?this.hydrationQueue.unshift(e.key):this.hydrationQueue.push(e.key),!this.hydrationPaused)){if(t&&!this.hydrationInProgress&&this.hydrationIdleId===null){this._flushHydrationQueue();return}this._scheduleHydration()}}_scheduleHydration(){this.hydrationPaused||this.hydrationInProgress||this.hydrationIdleId!==null||(this.hydrationIdleId=Hs(()=>{this.hydrationIdleId=null,this._flushHydrationQueue()},Is))}async _flushHydrationQueue(){if(this.hydrationPaused||this.hydrationInProgress)return;let e=null;for(;this.hydrationQueue.length>0&&!e;){let t=this.hydrationQueue.shift(),n=this.embedEntries.get(t);if(!n||n.wrapper||!n.placeholder?.isConnected){n&&(n.queued=!1);continue}e=n}e&&(this.hydrationInProgress=!0,e.queued=!1,await this._hydrateEntry(e),this.hydrationInProgress=!1,this.hydrationQueue.length>0&&this._scheduleHydration())}async _hydrateEntry(e){if(!(!e.placeholder?.isConnected&&!e.wrapper)){if(e.isParked=!1,!e.wrapper){let t=this._createEmbedContainer(e);e.header=t.header,e.wrapper=t.wrapper,e.iframe=t.iframe,e.labelElement=t.labelElement,e.maxButton=t.maxButton,e.openButton=t.openButton,e.instanceId=t.instanceId,e.isReady=!1,e.bootFilePath=e.filePath,e.bootMode=this._getEntryMode(e),e.loadedFilePath=e.bootFilePath,e.loadedMode=e.bootMode,e.bootAttempts=(e.bootAttempts??0)+1,this._armEntryBootTimeout(e)}e.followedPeerId=this.followedPeerIdsByFilePath.get(e.filePath),this._updateEmbedLabel(e),this._entryNeedsHardReload(e)&&this._reloadEntry(e),this._attachWrapper(e)}}_attachWrapper(e){let t=e.placeholder?.isConnected?e.placeholder:this.previewElement?.querySelector(`.excalidraw-embed-placeholder[data-embed-key="${e.key}"]`);if(!t)return;if(e.placeholder=t,this._syncMountedEntryMetadata(e),this._shouldInlineFilePreview(e)){e.wrapper.style.position=``,e.wrapper.style.top=``,e.wrapper.style.left=``,e.wrapper.style.width=``,e.wrapper.style.margin=``,e.wrapper.style.pointerEvents=`auto`,t.replaceWith(e.wrapper),e.placeholder=null;return}let n=this._ensureOverlayRoot();n.hidden=!1,e.wrapper?.parentElement!==n&&n.appendChild(e.wrapper),this._syncEntryLayout(e)}_adoptReusableEntries(e,t){e.forEach((n,r)=>{if(n.wrapper||n.iframe)return;let i=this._claimReusableEntry(n,t);i&&(i.filePath=n.filePath,i.key=n.key,i.label=n.label,i.placeholder=n.placeholder,i.queued=!1,e.set(r,i))})}_destroyEntry(e){this.pendingDisconnectRequests.forEach((t,n)=>{t.entry===e&&(t.resolve(!1),this.pendingDisconnectRequests.delete(n))}),this.maximizedEmbed?.wrapper===e.wrapper&&this._exitMaximizedEmbed(),this._clearEntryBootTimeout(e),this.warmEntry===e&&(this.warmEntry=null),this._resetPlaceholderLayout(e),this._setEntryLoadingState(e,!1),e.wrapper?.remove(),e.placeholder=null}_armEntryBootTimeout(e,t=Ls){this._clearEntryBootTimeout(e),e.bootTimerId=window.setTimeout(()=>{this._handleEntryBootTimeout(e)},t)}_clearEntryBootTimeout(e){e?.bootTimerId&&(window.clearTimeout(e.bootTimerId),e.bootTimerId=null)}async _handleEntryBootTimeout(e){if(e?.iframe?.isConnected){if((e.bootAttempts??0)>=zs){this._clearEntryBootTimeout(e),this.toastController?.show(`Excalidraw embed timed out: ${e.label}`);return}await this._retryEntryBootstrap(e)}}async _retryEntryBootstrap(e){e&&(this._clearEntryBootTimeout(e),this._resetPlaceholderLayout(e),this._setEntryLoadingState(e,!1),this.maximizedEmbed?.wrapper===e.wrapper&&this._exitMaximizedEmbed(),e.wrapper?.remove(),e.wrapper=null,e.iframe=null,e.header=null,e.labelElement=null,e.maxButton=null,e.openButton=null,e.instanceId=null,e.isReady=!1,e.isParked=!1,e.bootFilePath=null,e.bootMode=null,e.loadedFilePath=null,e.loadedMode=null,await this._hydrateEntry(e))}_findEntryByContentWindow(e){if(!e)return null;for(let t of this.embedEntries.values())if(t.iframe?.contentWindow===e)return t;return this.warmEntry?.iframe?.contentWindow===e?this.warmEntry:null}_findEntryByFilePath(e){if(!e)return null;for(let t of this.embedEntries.values())if(t.filePath===e)return t;return this.warmEntry?.filePath===e?this.warmEntry:null}_updateEmbedLabel(e){e.labelElement&&(e.labelElement.textContent=e.label.replace(/\.excalidraw$/i,``))}_syncMountedEntryMetadata(e){e.wrapper&&(e.wrapper.dataset.embedKey=e.key,e.wrapper.dataset.file=e.filePath,e.wrapper.classList.toggle(`is-direct-file`,this._isFilePreviewEntry(e))),e.iframe&&(e.iframe.title=`Excalidraw: ${e.filePath}`),e.openButton&&(this._isFilePreviewEntry(e)?e.openButton.remove():!e.openButton.isConnected&&e.header&&e.header.insertBefore(e.openButton,e.maxButton||null))}_buildIframeUrl(e){let t=new URL(O(Vs)),n=this.getTheme?.()||`dark`;t.searchParams.set(`file`,e.filePath),t.searchParams.set(`theme`,n),t.searchParams.set(`boot`,e.instanceId||``),this._isFilePreviewEntry(e)||t.searchParams.set(`mode`,`preview`);let r=this.getLocalUser?.();r?.name&&t.searchParams.set(`userName`,r.name),r?.color&&t.searchParams.set(`userColor`,r.color),r?.colorLight&&t.searchParams.set(`userColorLight`,r.colorLight),r?.peerId&&t.searchParams.set(`userPeerId`,r.peerId);let i=new URLSearchParams(window.location.search),a=i.get(`server`);return a&&t.searchParams.set(`server`,a),i.get(`test`)===`1`&&t.searchParams.set(`test`,`1`),i.has(`syncTimeoutMs`)&&t.searchParams.set(`syncTimeoutMs`,i.get(`syncTimeoutMs`)),t}_createEmbedContainer(e){let t=document.createElement(`div`);t.className=`excalidraw-embed diagram-preview-shell`,t.dataset.embedKey=e.key,t.dataset.file=e.filePath;let n=document.createElement(`div`);n.className=`excalidraw-embed-header diagram-preview-toolbar`;let r=document.createElement(`span`);r.className=`excalidraw-embed-icon`,r.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg>`;let i=document.createElement(`span`);i.className=`excalidraw-embed-label`,i.textContent=e.label.replace(/\.excalidraw$/i,``);let a=document.createElement(`button`);a.type=`button`,a.className=`excalidraw-embed-btn ui-preview-action ui-preview-action--icon-only`,a.title=`Edit in Excalidraw`,a.setAttribute(`aria-label`,`Edit in Excalidraw`),F(a,`edit`);let o=document.createElement(`button`);o.type=`button`,o.className=`excalidraw-embed-btn ui-preview-action ui-preview-action--icon-only`,o.title=`Maximize diagram`,o.setAttribute(`aria-label`,`Maximize diagram`),F(o,`maximize`),n.append(r,i),this._isFilePreviewEntry(e)||n.append(a),n.append(o);let s=document.createElement(`iframe`);s.className=`excalidraw-embed-iframe`,s.dataset.instanceId=String(++this.instanceCounter),e.instanceId=s.dataset.instanceId,s.src=this._buildIframeUrl(e).toString(),s.setAttribute(`loading`,`eager`),s.title=`Excalidraw: ${e.filePath}`,s.style.height=`${Fs}px`;let c=document.createElement(`div`);c.className=`excalidraw-embed-resizer`,c.title=`Drag to resize`,this._setupResizer(c,s,()=>this._syncEntryLayout(e)),t.append(n,s,c);let l=!1,u=`${Fs}px`,d=()=>{F(o,l?`restore`:`maximize`),o.title=l?`Restore diagram size`:`Maximize diagram`,o.setAttribute(`aria-label`,l?`Restore diagram size`:`Maximize diagram`)},f=()=>{l&&(l=!1,t.classList.remove(`is-maximized`),d(),document.body.classList.remove(`excalidraw-maximized-open`),this._restoreWrapperMount(e),s.style.height=u,this.maximizedEmbed?.wrapper===t&&(this.maximizedEmbed=null),this._syncEntryLayout(e))},p=()=>{l||(this._exitMaximizedEmbed(),l=!0,u=s.style.height||`${Fs}px`,this._mountWrapperInMaximizedRoot(e),t.classList.add(`is-maximized`),d(),document.body.classList.add(`excalidraw-maximized-open`),this.maximizedEmbed={wrapper:t,exit:f},this._syncEntryLayout(e))};return o.addEventListener(`click`,()=>{l?f():p()}),a.addEventListener(`click`,t=>{t.preventDefault(),this._exitMaximizedEmbed(),this.onOpenFile?.(e.filePath)}),d(),{header:n,iframe:s,instanceId:s.dataset.instanceId,labelElement:i,maxButton:o,openButton:a,wrapper:t}}_ensureWarmCacheRoot(){if(this.warmCacheRoot?.isConnected&&this.warmCacheRoot.parentElement===document.body)return this.warmCacheRoot;let e=document.body.querySelector(`[data-excalidraw-warm-cache-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.excalidrawWarmCacheRoot=`true`,e.className=`excalidraw-warm-cache-root`,document.body.appendChild(e)),this.warmCacheRoot=e,e}_setupResizer(e,t,n=null){let r=0,i=0,a=e=>{let n=e.clientY-r,a=Math.min(Math.max(i+n,Bs),Rs);t.style.height=`${a}px`,t.style.pointerEvents=`none`},o=()=>{t.style.pointerEvents=``,document.removeEventListener(`pointermove`,a),document.removeEventListener(`pointerup`,o),n?.()};e.addEventListener(`pointerdown`,e=>{e.preventDefault(),r=e.clientY,i=t.offsetHeight,document.addEventListener(`pointermove`,a),document.addEventListener(`pointerup`,o)})}_ensureOverlayRoot(){if(this.overlayRoot?.isConnected&&this.overlayRoot.parentElement===this.previewElement)return this.overlayRoot;let e=this.previewElement?.querySelector(`[data-excalidraw-overlay-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.excalidrawOverlayRoot=`true`,e.className=`excalidraw-embed-overlay-root`,this.previewElement?.appendChild(e)),this.overlayRoot=e,e}_ensureMaximizedRoot(){if(this.maximizedRoot?.isConnected&&this.maximizedRoot.parentElement===document.body)return this.maximizedRoot;let e=document.body.querySelector(`[data-excalidraw-maximized-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.excalidrawMaximizedRoot=`true`,e.className=`excalidraw-maximized-root`,document.body.appendChild(e)),this.maximizedRoot=e,e}_isFilePreviewEntry(e){return e?.key===`${e?.filePath}#file-preview`}_getEntryMode(e){return this._isFilePreviewEntry(e)?`edit`:`preview`}_shouldInlineFilePreview(e){return this._isFilePreviewEntry(e)}_entryNeedsHardReload(e){let t=this._getEntryMode(e);return!!(e?.wrapper&&e.iframe&&(e.isReady?e.loadedFilePath!==e.filePath||e.loadedMode!==t:e.bootFilePath!==e.filePath||e.bootMode!==t))}_setEntryLoadingState(e,t){e?.wrapper&&(e.wrapper.classList.toggle(`is-loading`,!!t),e.wrapper.setAttribute(`aria-busy`,t?`true`:`false`))}_forEachManagedEntry(e){let t=new Set;this.embedEntries.forEach(n=>{!n||t.has(n)||(t.add(n),e(n))}),this.warmEntry&&!t.has(this.warmEntry)&&e(this.warmEntry)}_claimEntryFromRemovedEntries(e,t){let n=e.findIndex(e=>(e.wrapper||e.iframe)&&t(e));if(n<0)return null;let[r]=e.splice(n,1);return r}_claimReusableEntry(e,t){let n=this._getEntryMode(e);return this._claimEntryFromRemovedEntries(t,t=>t.filePath===e.filePath&&this._getEntryMode(t)===n)||(this._isFilePreviewEntry(e)?this._claimEntryFromRemovedEntries(t,t=>t.filePath===e.filePath)||this._claimWarmEntry()||this._claimEntryFromRemovedEntries(t,e=>this._isFilePreviewEntry(e)):null)}_claimWarmEntry(){let e=this.warmEntry;return e?(this.warmEntry=null,e):null}_captureWarmEntry(e){let t=this._claimEntryFromRemovedEntries(e,e=>this._isFilePreviewEntry(e));t&&(this.warmEntry&&this.warmEntry!==t&&this._destroyEntry(this.warmEntry),this.warmEntry=t,this._parkWarmEntry(t))}_parkWarmEntry(e){if(!e?.wrapper)return;this.maximizedEmbed?.wrapper===e.wrapper&&this._exitMaximizedEmbed();let t=this._ensureWarmCacheRoot();this._setEntryLoadingState(e,!1),e.isParked=!0,e.isReady=!1,e.bootFilePath=null,e.bootMode=null,e.loadedFilePath=null,e.loadedMode=null,e.placeholder=null,e.wrapper.parentElement!==t&&t.appendChild(e.wrapper),this._postMessageToEntry(e,{source:`collabmd-host`,type:`park-room`})}_reloadEntry(e){e?.iframe&&(this._clearEntryBootTimeout(e),this._setEntryLoadingState(e,!0),e.isReady=!1,e.bootAttempts=(e.bootAttempts??0)+1,e.bootFilePath=e.filePath,e.bootMode=this._getEntryMode(e),e.loadedFilePath=null,e.loadedMode=null,e.iframe.src=this._buildIframeUrl(e).toString(),this._armEntryBootTimeout(e))}_resetPlaceholderLayout(e){!e?.placeholder?.isConnected||this._shouldInlineFilePreview(e)||(e.placeholder.classList.remove(`is-hydrated`),e.placeholder.removeAttribute(`data-embed-hydrated`),e.placeholder.style.height=``,e.placeholder.style.pointerEvents=``)}_mountWrapperInMaximizedRoot(e){if(!e?.wrapper)return;let t=this._ensureMaximizedRoot();t.hidden=!1,e.restoreParent=e.wrapper.parentElement||null,e.restoreNextSibling=e.wrapper.nextSibling||null,e.wrapper.style.position=``,e.wrapper.style.top=``,e.wrapper.style.left=``,e.wrapper.style.width=``,e.wrapper.style.margin=``,e.wrapper.parentElement!==t&&t.appendChild(e.wrapper)}_restoreWrapperMount(e){if(e?.wrapper){if(this._shouldInlineFilePreview(e)){let{restoreParent:t,restoreNextSibling:n}=e;t?.isConnected&&(n?.parentElement===t?t.insertBefore(e.wrapper,n):t.appendChild(e.wrapper))}else{let t=this._ensureOverlayRoot();t.hidden=!1,e.wrapper.parentElement!==t&&t.appendChild(e.wrapper)}e.restoreParent=null,e.restoreNextSibling=null,this.maximizedRoot&&this.maximizedRoot.childElementCount===0&&(this.maximizedRoot.hidden=!0)}}_syncEntryLayout(e){if(!e?.wrapper||this._shouldInlineFilePreview(e))return;let t=e.placeholder?.isConnected?e.placeholder:this.previewElement?.querySelector(`.excalidraw-embed-placeholder[data-embed-key="${e.key}"]`);if(!t)return;e.placeholder=t,t.classList.add(`is-hydrated`),t.dataset.embedHydrated=`true`,t.style.pointerEvents=`none`,this._isFilePreviewEntry(e)&&t.childElementCount>0&&t.replaceChildren();let n=e.wrapper.classList.contains(`is-maximized`),r=e.wrapper.querySelector(`.excalidraw-embed-header`)?.offsetHeight||0,i=e.iframe?.offsetHeight||Number.parseFloat(e.iframe?.style.height||``)||Fs,a=n?0:e.wrapper.querySelector(`.excalidraw-embed-resizer`)?.offsetHeight||0,o=Math.ceil(r+i+a);if(n||(e.inlineHeightPx=o),t.style.height=`${Math.ceil(e.inlineHeightPx||o||Fs)}px`,e.wrapper.style.pointerEvents=`auto`,n){e.wrapper.style.position=``,e.wrapper.style.top=``,e.wrapper.style.left=``,e.wrapper.style.width=``,e.wrapper.style.margin=``;return}e.wrapper.style.position=`absolute`,e.wrapper.style.top=`${t.offsetTop}px`,e.wrapper.style.left=`${t.offsetLeft}px`,e.wrapper.style.width=`${t.offsetWidth}px`,e.wrapper.style.margin=`0`}syncLayout(){this.embedEntries.forEach(e=>{e.wrapper&&!this._shouldInlineFilePreview(e)&&this._syncEntryLayout(e)})}_onPreviewClick(e){let t=e.target.closest(`.excalidraw-embed-placeholder-btn`);if(!t)return;e.preventDefault();let n=this.embedEntries.get(t.dataset.embedKey);n&&this._hydrateEntry(n)}_onMessage(e){if(e.origin!==window.location.origin)return;let t=e.data;if(!t||t.source!==`excalidraw-editor`)return;let n=this._findEntryByContentWindow(e.source);if(n){if(t.type===`ready`){if(n.isParked)return;n.isReady=!0,this._clearEntryBootTimeout(n),n.loadedFilePath=n.bootFilePath||n.filePath,n.loadedMode=n.bootMode||this._getEntryMode(n),this._setEntryLoadingState(n,!1),this._syncEntryUser(n),this._postMessageToEntry(n,{source:`collabmd-host`,type:`set-theme`,theme:this.getTheme?.()||`dark`}),this._syncEntryFollowState(n),this._entryNeedsHardReload(n)&&this._hydrateEntry(n);return}if(t.type===`request-toggle-quick-switcher`){this.onToggleQuickSwitcher?.();return}if(t.type===`error`){if(n.isParked)return;n.isReady=!1,this._handleEntryBootTimeout(n);return}if(t.type===`disconnect-ready`){let e=this.pendingDisconnectRequests.get(t.requestId);e?.entry===n&&e.resolve(!0)}}}_onKeyDown(e){e.key===`Escape`&&this._exitMaximizedEmbed()}_exitMaximizedEmbed(){this.maximizedEmbed?.exit&&this.maximizedEmbed.exit(),this.maximizedEmbed=null,document.body.classList.remove(`excalidraw-maximized-open`)}_postMessageToEntry(e,t){e?.iframe?.contentWindow?.postMessage(t,window.location.origin)}_syncEntryUser(e,t=null){let n=t||this.getLocalUser?.();n&&this._postMessageToEntry(e,{source:`collabmd-host`,type:`set-user`,user:{color:n.color||``,colorLight:n.colorLight||``,name:n.name||``,peerId:n.peerId||``}})}_syncEntryFollowState(e){!e?.isReady||e.followedPeerId===void 0||this._postMessageToEntry(e,{source:`collabmd-host`,type:`follow-user`,peerId:e.followedPeerId})}};function Ks(){return typeof window>`u`||typeof window.matchMedia!=`function`?{matches:!1}:window.matchMedia(`(max-width: 768px)`)}function qs(e){return typeof HTMLElement>`u`||!(e instanceof HTMLElement)?[]:Array.from(e.querySelectorAll(`.create-menu-item`))}var Js=class{constructor({mobileBreakpointQuery:e=Ks()}={}){this.mobileBreakpointQuery=e,this.activeAnchor=null,this.desktopMenu=null,this.mobileBackdrop=null,this.mobileSheet=null,this.documentPointerDownHandler=null,this.windowResizeHandler=null,this.boundClose=()=>this.close()}isMobileViewport(){return!!this.mobileBreakpointQuery?.matches}isOpen(){return!!(this.desktopMenu||this.mobileSheet)}toggle(e={}){if(this.isOpen()){this.close();return}this.open(e)}open({anchor:e=null,items:t=[],title:n=`Create`}={}){if(this.close({restoreFocus:!1}),!(!Array.isArray(t)||t.length===0)){if(this.activeAnchor=typeof HTMLElement<`u`&&e instanceof HTMLElement?e:null,this.activeAnchor?.setAttribute(`aria-expanded`,`true`),this.isMobileViewport()){this.openMobileSheet({items:t,title:n});return}this.openDesktopMenu({anchor:this.activeAnchor,items:t,title:n})}}close({restoreFocus:e=!0}={}){this.desktopMenu&&=(this.desktopMenu.remove(),null),this.mobileBackdrop&&=(this.mobileBackdrop.remove(),null),this.mobileSheet&&=(this.mobileSheet.remove(),null),this.documentPointerDownHandler&&=(document.removeEventListener(`pointerdown`,this.documentPointerDownHandler),null),this.windowResizeHandler&&typeof window<`u`&&window.removeEventListener(`resize`,this.windowResizeHandler),this.windowResizeHandler=null;let t=this.activeAnchor;this.activeAnchor?.setAttribute(`aria-expanded`,`false`),this.activeAnchor=null,e&&t?.focus?.()}openDesktopMenu({anchor:e,items:t,title:n}){let r=document.createElement(`div`);r.className=`create-menu`,r.setAttribute(`role`,`menu`),r.setAttribute(`aria-label`,n),this.renderMenuItems(r,t),document.body.appendChild(r),this.positionDesktopMenu(r,e),r.addEventListener(`keydown`,e=>{this.handleDesktopMenuKeyDown(e,r)}),this.documentPointerDownHandler=t=>{r.contains(t.target)||e?.contains?.(t.target)||this.close()},this.windowResizeHandler=this.boundClose,setTimeout(()=>{document.addEventListener(`pointerdown`,this.documentPointerDownHandler)},0),typeof window<`u`&&window.addEventListener(`resize`,this.windowResizeHandler),this.desktopMenu=r,qs(r)[0]?.focus()}openMobileSheet({items:e,title:t}){let n=document.createElement(`button`);n.type=`button`,n.className=`file-action-sheet-backdrop`,n.setAttribute(`aria-label`,`Close ${t.toLowerCase()} menu`);let r=document.createElement(`div`);r.className=`file-action-sheet create-action-sheet`;let i=document.createElement(`div`);i.className=`create-action-sheet-header`,i.textContent=t,r.appendChild(i),this.renderMenuItems(r,e,{mobile:!0});let a=document.createElement(`button`);a.type=`button`,a.className=G({variant:`ghost`,extra:[`file-action-sheet-item`,`create-action-sheet-cancel`]}),a.textContent=`Cancel`,a.addEventListener(`click`,()=>{this.close()}),r.appendChild(a),n.addEventListener(`click`,()=>{this.close()}),document.body.append(n,r),this.mobileBackdrop=n,this.mobileSheet=r}renderMenuItems(e,t,{mobile:n=!1}={}){let r=null;t.forEach(t=>{if(t.group&&t.group!==r){let i=document.createElement(`div`);i.className=n?`create-action-sheet-group`:`create-menu-group`,i.textContent=t.group,e.appendChild(i),r=t.group}let i=document.createElement(`button`);i.type=`button`,i.className=n?G({variant:`ghost`,extra:[`file-action-sheet-item`,`create-action-sheet-item`,`create-action-sheet-option`]}):`create-menu-item`,i.setAttribute(`role`,n?`button`:`menuitem`),i.dataset.actionId=t.id;let a=document.createElement(`span`);a.className=`create-menu-item-icon`,a.setAttribute(`aria-hidden`,`true`),a.innerHTML=t.icon||``,i.appendChild(a);let o=document.createElement(`span`);o.className=`create-menu-item-copy`;let s=document.createElement(`span`);s.className=`create-menu-item-label`,s.textContent=t.label,o.appendChild(s);let c=t.meta||t.hint;if(c){let e=document.createElement(`span`);e.className=`create-menu-item-meta`,e.textContent=c,o.appendChild(e)}i.appendChild(o),i.addEventListener(`click`,()=>{this.close({restoreFocus:!1}),t.onSelect?.()}),e.appendChild(i)})}positionDesktopMenu(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect?.(),i=r?.left??8,a=Math.max(8,window.innerWidth-n.width-8),o=Math.max(8,Math.min(i,a)),s=(r?.bottom??8)+8,c=window.innerHeight-n.height-8;s>c&&r&&(s=Math.max(8,r.top-n.height-8)),e.style.left=`${o}px`,e.style.top=`${Math.max(8,s)}px`}handleDesktopMenuKeyDown(e,t){let n=qs(t);if(n.length===0)return;let r=Math.max(0,n.indexOf(document.activeElement));switch(e.key){case`ArrowDown`:e.preventDefault(),n[(r+1)%n.length]?.focus();break;case`ArrowUp`:e.preventDefault(),n[(r-1+n.length)%n.length]?.focus();break;case`Home`:e.preventDefault(),n[0]?.focus();break;case`End`:e.preventDefault(),n[n.length-1]?.focus();break;case`Escape`:e.preventDefault(),this.close();break;case`Tab`:this.close({restoreFocus:!1});break}}};function Ys(e){return String(e??``).replace(/\/+$/u,``).split(`/`).filter(Boolean).pop()||``}function Xs(e){let t=String(e??``).replace(/\/+$/u,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(0,n):``}function Zs(e,t,n){return e===t?n:`${n}${e.slice(t.length)}`}function Qs(e,t,n){return`${e} ${e===1?t:n}`}function $s(){return JSON.stringify({type:`excalidraw`,version:2,source:`collabmd`,elements:[],appState:{viewBackgroundColor:`#ffffff`,gridSize:null},files:{}})}function ec(e,t){return t?{...e,requestId:t}:e}var tc=class{constructor({mobileBreakpointQuery:e=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(max-width: 768px)`):{matches:!1},onFileDelete:t,onFileSelect:n,pendingWorkspaceRequestIds:r=null,state:i,toastController:a,vaultClient:o,view:s,refresh:c}){this.onFileDelete=t,this.onFileSelect=n,this.pendingWorkspaceRequestIds=r,this.state=i,this.toastController=a,this.vaultClient=o,this.view=s,this.refresh=c,this.createButton=document.getElementById(`sidebarCreateBtn`),this.refreshButton=document.getElementById(`refreshFilesBtn`),this.actionDialog=document.getElementById(`fileActionDialog`),this.actionForm=document.getElementById(`fileActionForm`),this.actionTitle=document.getElementById(`fileActionTitle`),this.actionCopy=document.getElementById(`fileActionCopy`),this.actionField=document.getElementById(`fileActionField`),this.actionLabel=document.getElementById(`fileActionLabel`),this.actionInput=document.getElementById(`fileActionInput`),this.actionHint=document.getElementById(`fileActionHint`),this.actionNote=document.getElementById(`fileActionNote`),this.actionCancelButton=document.getElementById(`fileActionCancel`),this.actionSubmitButton=document.getElementById(`fileActionSubmit`),this.createMenu=new Js({mobileBreakpointQuery:e}),this.pendingAction=null,this.actionBusy=!1}initialize(){this.createButton?.addEventListener(`click`,()=>{this.openRootCreateMenu({anchor:this.createButton})}),this.refreshButton?.addEventListener(`click`,()=>this.refresh()),this.actionCancelButton?.addEventListener(`click`,()=>this.closeActionDialog()),this.actionForm?.addEventListener(`submit`,e=>{e.preventDefault(),this.handleActionSubmit()}),this.actionDialog?.addEventListener(`close`,()=>this.resetActionDialog())}getCreateActions({parentDir:e=``}={}){return[{contextLabel:`New markdown file`,group:`Note`,hint:`Markdown`,icon:this.getCreateActionIcon(`markdown`),id:`markdown`,label:`Markdown note`,meta:`.md`,onSelect:()=>this.handleNewFile({parentDir:e})},{contextLabel:`New base file`,group:`Note`,hint:`Base`,icon:this.getCreateActionIcon(`base`),id:`base`,label:`Base file`,meta:`.base`,onSelect:()=>this.handleNewBase({parentDir:e})},{contextLabel:`New Excalidraw drawing`,group:`Diagram`,hint:`Excalidraw`,icon:this.getCreateActionIcon(`excalidraw`),id:`excalidraw`,label:`Excalidraw drawing`,meta:`.excalidraw`,onSelect:()=>this.handleNewDrawing({parentDir:e})},{contextLabel:`New draw.io diagram`,group:`Diagram`,hint:`draw.io`,icon:this.getCreateActionIcon(`drawio`),id:`drawio`,label:`draw.io diagram`,meta:`.drawio`,onSelect:()=>this.handleNewDrawio({parentDir:e})},{contextLabel:`New Mermaid diagram`,group:`Diagram`,hint:`Mermaid`,icon:this.getCreateActionIcon(`mermaid`),id:`mermaid`,label:`Mermaid diagram`,meta:`.mmd`,onSelect:()=>this.handleNewMermaid({parentDir:e})},{contextLabel:`New PlantUML diagram`,group:`Diagram`,hint:`PlantUML`,icon:this.getCreateActionIcon(`plantuml`),id:`plantuml`,label:`PlantUML diagram`,meta:`.puml`,onSelect:()=>this.handleNewPlantUml({parentDir:e})},{contextLabel:`New folder`,group:`Structure`,hint:`Folder`,icon:this.getCreateActionIcon(`folder`),id:`folder`,label:`Folder`,meta:`folder`,onSelect:()=>this.handleNewFolder({parentDir:e})}]}createContextMenuItems(e=``){return this.getCreateActions({parentDir:e}).map(e=>({label:e.contextLabel,onSelect:e.onSelect}))}getDirectoryContextMenuItems(e){return[...this.createContextMenuItems(e),{label:`Rename / move`,onSelect:()=>this.handleRenameDirectory(e)},{label:`Download`,onSelect:()=>this.handleDownloadDirectory(e)},{label:`Delete`,danger:!0,onSelect:()=>this.handleDeleteDirectory(e)}]}getFileContextMenuItems(e){return[{label:`Rename / move`,onSelect:()=>this.handleRenameFile(e)},{label:`Download`,onSelect:()=>this.handleDownloadFile(e)},{label:`Delete`,danger:!0,onSelect:()=>this.handleDelete(e)}]}showToast(e){e&&this.toastController?.show(String(e))}getCreateActionIcon(e){switch(e){case`base`:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4h7l5 5v11a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"/><path d="M14 4v5h5"/><path d="M8 13h8"/><path d="M8 17h6"/><path d="M8 9h3"/></svg>`;case`drawio`:case`plantuml`:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="7" height="6" rx="1"/><rect x="14" y="4" width="7" height="6" rx="1"/><rect x="8.5" y="14" width="7" height="6" rx="1"/><path d="M10 7h4"/><path d="M17.5 10v2.5"/><path d="M6.5 10v2.5"/><path d="M6.5 12.5h11"/></svg>`;case`excalidraw`:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg>`;case`folder`:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>`;case`mermaid`:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7.5c0-1.38 1.12-2.5 2.5-2.5 1.04 0 1.93.64 2.3 1.56A2.5 2.5 0 0 1 14 8.5v1"/><path d="M19 16.5c0 1.38-1.12 2.5-2.5 2.5-1.04 0-1.93-.64-2.3-1.56A2.5 2.5 0 0 1 10 15.5v-1"/><path d="M8 10.5h8"/><path d="M8 13.5h8"/><path d="M10 8.5v7"/><path d="M14 8.5v7"/></svg>`;default:return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`}}showError(e,t){this.showToast(t?.message?`${e}: ${t.message}`:e)}ensureExtension(e,t){return st(e,t)}createPendingWorkspaceRequestId(){if(!this.pendingWorkspaceRequestIds)return null;let e=Ut();return this.pendingWorkspaceRequestIds.add(e),e}clearPendingWorkspaceRequestId(e){e&&this.pendingWorkspaceRequestIds?.delete(e)}async runWorkspaceMutation(e){let t=this.createPendingWorkspaceRequestId();try{return await e(t)}catch(e){throw this.clearPendingWorkspaceRequestId(t),e}}openActionDialog({title:e,copy:t,label:n=`Path`,hint:r=``,note:i=``,placeholder:a=``,value:o=``,submitLabel:s=`Save`,destructive:c=!1,requiresInput:l=!0,emptyMessage:u=`A value is required`,onSubmit:d}){!this.actionDialog||!this.actionTitle||!this.actionCopy||!this.actionSubmitButton||!this.actionCancelButton||l&&!this.actionInput||(this.actionDialog.open&&(typeof this.actionDialog.close==`function`?this.actionDialog.close():(this.actionDialog.removeAttribute(`open`),this.resetActionDialog())),this.pendingAction={requiresInput:l,emptyMessage:u,onSubmit:d},this.createMenu.close({restoreFocus:!1}),this.view?.removeContextMenu?.(),this.actionTitle.textContent=e,this.actionCopy.textContent=t,this.actionField&&(this.actionField.hidden=!l),this.actionLabel&&(this.actionLabel.textContent=n),this.actionInput&&(this.actionInput.value=o,this.actionInput.placeholder=a,this.actionInput.required=l,this.actionInput.disabled=!1),this.actionHint&&(this.actionHint.textContent=r,this.actionHint.hidden=!l||!r),this.actionNote&&(this.actionNote.textContent=i,this.actionNote.hidden=!i,this.actionNote.classList.toggle(`is-danger`,c)),this.actionSubmitButton.textContent=s,this.actionSubmitButton.disabled=!1,this.actionSubmitButton.classList.toggle(`ui-button--primary`,!c),this.actionSubmitButton.classList.toggle(`ui-button--danger`,c),this.actionCancelButton.disabled=!1,typeof this.actionDialog.showModal==`function`?this.actionDialog.showModal():this.actionDialog.setAttribute(`open`,`true`),requestAnimationFrame(()=>{if(!l||!this.actionInput){this.actionSubmitButton.focus();return}this.actionInput.focus(),o&&this.actionInput.select()}))}resetActionDialog(){this.pendingAction=null,this.actionBusy=!1,this.actionField&&(this.actionField.hidden=!1),this.actionLabel&&(this.actionLabel.textContent=`Path`),this.actionInput&&(this.actionInput.value=``,this.actionInput.placeholder=``,this.actionInput.required=!0,this.actionInput.disabled=!1),this.actionHint&&(this.actionHint.textContent=``,this.actionHint.hidden=!0),this.actionNote&&(this.actionNote.textContent=``,this.actionNote.hidden=!0,this.actionNote.classList.remove(`is-danger`)),this.actionSubmitButton&&(this.actionSubmitButton.textContent=`Save`,this.actionSubmitButton.disabled=!1,this.actionSubmitButton.className=G({variant:`primary`})),this.actionCancelButton&&(this.actionCancelButton.disabled=!1)}closeActionDialog(){if(this.actionDialog){if(this.actionDialog.open&&typeof this.actionDialog.close==`function`){this.actionDialog.close();return}this.actionDialog.removeAttribute(`open`),this.resetActionDialog()}}setActionDialogBusy(e){this.actionBusy=e,this.actionInput&&(this.actionInput.disabled=e||!(this.pendingAction?.requiresInput??!0)),this.actionCancelButton&&(this.actionCancelButton.disabled=e),this.actionSubmitButton&&(this.actionSubmitButton.disabled=e)}async handleActionSubmit(){if(!this.pendingAction?.onSubmit||this.actionBusy)return;let e=this.pendingAction.requiresInput,t=e?this.actionInput?.value.trim()??``:void 0;if(e&&!t){this.showToast(this.pendingAction.emptyMessage),this.actionInput?.focus();return}this.setActionDialogBusy(!0);let n;try{n=await this.pendingAction.onSubmit(t)}catch(e){this.showError(`Failed to complete action`,e)}if(this.setActionDialogBusy(!1),n!==!1){this.closeActionDialog();return}e&&this.actionInput&&(this.actionInput.focus(),this.actionInput.select())}async createVaultFile(e,t,{openAfterCreate:n=!1,errorMessage:r=`Failed to create file`}={}){try{return await this.runWorkspaceMutation(n=>this.vaultClient.createFile(ec({content:t,path:e},n))),this.state.expandDirectoryPath(e,{includeLeaf:!1}),await this.refresh(),n&&this.onFileSelect?.(e),!0}catch(e){return this.showToast(e?.message||r),!1}}async createDirectory(e){let t=I(e);if(!t)return this.showToast(`Folder path is required`),!1;try{return await this.runWorkspaceMutation(e=>this.vaultClient.createDirectory(t,ec({},e))),this.state.expandDirectoryPath(t),await this.refresh(),!0}catch(e){return this.showToast(e?.message||`Failed to create folder`),!1}}async renameVaultFile(e,t,n){let r=I(t);if(!r)return this.showToast(`File path is required`),!1;let i=_(r);if(i&&i.toLowerCase()!==String(n??``).toLowerCase())return this.showToast(`File type changes are not supported during rename. Keep the ${n} extension.`),!1;let a=i?r:`${r}${n}`;if(!Ys(a))return this.showToast(`File path is required`),!1;if(a===e)return!0;try{return await this.runWorkspaceMutation(t=>this.vaultClient.renameFile(ec({newPath:a,oldPath:e},t))),this.state.expandDirectoryPath(a,{includeLeaf:!1}),await this.refresh(),this.state.activeFilePath===e&&(this.state.activeFilePath=a,this.onFileSelect?.(a)),!0}catch(e){return this.showToast(e?.message||`Failed to rename`),!1}}async renameDirectory(e,t){let n=I(t);if(!n)return this.showToast(`Folder path is required`),!1;if(n===e)return!0;try{if(await this.runWorkspaceMutation(t=>this.vaultClient.renameDirectory(ec({newPath:n,oldPath:e},t))),this.state.replaceExpandedDirectoryPrefix(e,n),this.state.expandDirectoryPath(n),await this.refresh(),this.state.activeFilePath&&this.state.activeFilePath.startsWith(`${e}/`)){let t=Zs(this.state.activeFilePath,e,n);this.state.activeFilePath=t,this.onFileSelect?.(t)}return!0}catch(e){return this.showToast(e?.message||`Failed to rename folder`),!1}}async deleteVaultFile(e){try{return await this.runWorkspaceMutation(t=>this.vaultClient.deleteFile(e,ec({},t))),await this.refresh(),this.state.activeFilePath===e&&(this.state.activeFilePath=null,this.onFileDelete?.(e)),!0}catch(e){return this.showToast(e?.message||`Failed to delete`),!1}}async deleteDirectory(e,{recursive:t=!1}={}){try{await this.runWorkspaceMutation(n=>this.vaultClient.deleteDirectory(e,ec({recursive:t},n)));let n=this.state.activeFilePath;return await this.refresh(),this.state.removeExpandedDirectoryPrefix(e),n&&n.startsWith(`${e}/`)&&(this.state.activeFilePath=null,this.onFileDelete?.(n)),!0}catch(e){return this.showToast(e?.message||`Failed to delete folder`),!1}}planMoveEntryByDrop({destinationDirectory:e=``,sourcePath:t=``,sourceType:n=`file`}={}){let r=I(t),i=I(e),a=Xs(r),o=Ys(r);return!r||!o?{ok:!1,reason:`Invalid item to move`}:a===i?{ok:!1,reason:`Item is already in that folder`}:n===`directory`?i===r?{ok:!1,reason:`A folder cannot be moved into itself`}:i.startsWith(`${r}/`)?{ok:!1,reason:`A folder cannot be moved into one of its descendants`}:{nextPath:L(i,o),ok:!0}:{extension:_(r)||`.md`,nextPath:L(i,o),ok:!0}}canMoveEntryByDrop(e={}){return this.planMoveEntryByDrop(e).ok}async moveEntryByDrop(e={}){let t=this.planMoveEntryByDrop(e);return t.ok?e.sourceType===`directory`?this.renameDirectory(e.sourcePath,t.nextPath):this.renameVaultFile(e.sourcePath,t.nextPath,t.extension):(this.showToast(t.reason),!1)}async downloadFileEntry(e){try{return await this.vaultClient.downloadFile(e),!0}catch(e){return this.showToast(e?.message||`Failed to download file`),!1}}async downloadDirectoryEntry(e){try{return await this.vaultClient.downloadDirectory(e),!0}catch(e){return this.showToast(e?.message||`Failed to download folder`),!1}}getCreateContext(e=``){let t=I(e);return{hintPrefix:t?`Use "/" to create nested items under this folder.`:`Use "/" to place it inside a folder.`,inputLabelSuffix:t?`name or path`:`path`,note:t?`Parent folder: ${t}`:``,normalizedParentDir:t}}openRootCreateMenu({anchor:e=this.createButton}={}){this.openCreateMenu({anchor:e,parentDir:``})}openCreateMenu({anchor:e=this.createButton,parentDir:t=``}={}){this.view?.removeContextMenu?.(),this.createMenu.toggle({anchor:e,items:this.getCreateActions({parentDir:t}),title:`Create`})}handleNewFile({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create markdown file`,copy:t.normalizedParentDir?`Add a new note inside the selected folder. It opens immediately after creation.`:`Add a new note to the vault. It opens immediately after creation.`,label:`File ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".md" is added automatically.`,note:t.note,placeholder:t.normalizedParentDir?`my-note`:`notes/my-note`,submitLabel:`Create file`,emptyMessage:`File path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`File path is required`),!1;let r=this.ensureExtension(L(t.normalizedParentDir,n),`.md`);return this.createVaultFile(r,ct(r),{errorMessage:`Failed to create file`,openAfterCreate:!0})}})}handleNewBase({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create base file`,copy:t.normalizedParentDir?"Add a new `.base` file inside the selected folder. It opens immediately after creation.":"Add a new `.base` file to the vault. It opens immediately after creation.",label:`Base ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".base" is added automatically.`,note:t.note,placeholder:t.normalizedParentDir?`table-view`:`views/table-view`,submitLabel:`Create base`,emptyMessage:`Base path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`Base path is required`),!1;let r=lt(L(t.normalizedParentDir,n));return this.createVaultFile(r.path,r.content,{errorMessage:`Failed to create base file`,openAfterCreate:!0})}})}handleNewFolder({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create folder`,copy:t.normalizedParentDir?`Add a new folder inside the selected folder.`:`Add a new folder to organize notes and diagrams.`,label:`Folder ${t.inputLabelSuffix}`,hint:t.hintPrefix,note:t.note,placeholder:t.normalizedParentDir?`archive`:`notes/archive`,submitLabel:`Create folder`,emptyMessage:`Folder path is required`,onSubmit:e=>this.createDirectory(L(t.normalizedParentDir,e))})}handleNewDrawing({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create Excalidraw drawing`,copy:t.normalizedParentDir?`Start a new drawing inside the selected folder.`:`Start a new drawing file in the vault.`,label:`Drawing ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".excalidraw" is added automatically.`,note:t.note,placeholder:t.normalizedParentDir?`architecture`:`diagrams/architecture`,submitLabel:`Create drawing`,emptyMessage:`Drawing path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`Drawing path is required`),!1;let r=this.ensureExtension(L(t.normalizedParentDir,n),`.excalidraw`);return this.createVaultFile(r,$s(),{errorMessage:`Failed to create drawing`,openAfterCreate:!0})}})}handleNewMermaid({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create Mermaid diagram`,copy:t.normalizedParentDir?"Create a new `.mmd` or `.mermaid` file inside the selected folder.":"Create a new `.mmd` or `.mermaid` file with starter diagram content.",label:`Diagram ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".mmd" is added automatically unless you enter ".mermaid".`,note:t.note,placeholder:t.normalizedParentDir?`flow`:`diagrams/flow`,submitLabel:`Create diagram`,emptyMessage:`Diagram path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`Diagram path is required`),!1;let r=ut(L(t.normalizedParentDir,n));return this.createVaultFile(r.path,r.content,{errorMessage:`Failed to create Mermaid diagram`,openAfterCreate:!0})}})}handleNewDrawio({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create draw.io diagram`,copy:t.normalizedParentDir?"Create a new `.drawio` diagram inside the selected folder.":"Create a new `.drawio` diagram with a native starter document.",label:`Diagram ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".drawio" is added automatically.`,note:t.note,placeholder:t.normalizedParentDir?`architecture`:`diagrams/architecture`,submitLabel:`Create diagram`,emptyMessage:`Diagram path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`Diagram path is required`),!1;let r=dt(L(t.normalizedParentDir,n));return this.createVaultFile(r.path,r.content,{errorMessage:`Failed to create draw.io diagram`,openAfterCreate:!0})}})}handleNewPlantUml({parentDir:e=``}={}){let t=this.getCreateContext(e);this.openActionDialog({title:`Create PlantUML diagram`,copy:t.normalizedParentDir?"Create a new `.puml` or `.plantuml` file inside the selected folder.":"Create a new `.puml` or `.plantuml` file with starter diagram content.",label:`Diagram ${t.inputLabelSuffix}`,hint:`${t.hintPrefix} ".puml" is added automatically unless you enter ".plantuml".`,note:t.note,placeholder:t.normalizedParentDir?`sequence-flow`:`diagrams/sequence-flow`,submitLabel:`Create diagram`,emptyMessage:`Diagram path is required`,onSubmit:e=>{let n=I(e);if(!n)return this.showToast(`Diagram path is required`),!1;let r=ft(L(t.normalizedParentDir,n));return this.createVaultFile(r.path,r.content,{errorMessage:`Failed to create PlantUML diagram`,openAfterCreate:!0})}})}handleRenameFile(e){let t=_(e)||`.md`;this.openActionDialog({title:`Rename or move file`,copy:`Update the relative path without changing the file type.`,label:`Path`,hint:`Use "/" to move the file into another folder. ${t} is kept automatically.`,value:e,submitLabel:`Save file path`,emptyMessage:`File path is required`,onSubmit:n=>this.renameVaultFile(e,n,t)})}handleRenameDirectory(e){this.openActionDialog({title:`Rename or move folder`,copy:`Update the relative path for this folder and everything inside it.`,label:`Path`,hint:`Use "/" to move the folder into another location in the vault.`,value:e,submitLabel:`Save folder path`,emptyMessage:`Folder path is required`,onSubmit:t=>this.renameDirectory(e,t)})}handleDelete(e){this.openActionDialog({title:`Delete file`,copy:`This permanently removes the file from the vault.`,note:e,submitLabel:`Delete file`,destructive:!0,requiresInput:!1,onSubmit:()=>this.deleteVaultFile(e)})}handleDeleteDirectory(e){let{directoryCount:t,fileCount:n}=this.state.getDirectoryDescendantSummary(e),r=t>0||n>0,i=r?`This will permanently remove ${Qs(n,`file`,`files`)} and ${Qs(t,`nested folder`,`nested folders`)} inside this folder.`:`This permanently removes the empty folder from the vault.`;this.openActionDialog({title:r?`Delete folder and contents`:`Delete folder`,copy:i,note:e,submitLabel:r?`Delete folder and contents`:`Delete folder`,destructive:!0,requiresInput:!1,onSubmit:()=>this.deleteDirectory(e,{recursive:r})})}handleDownloadFile(e){this.downloadFileEntry(e)}handleDownloadDirectory(e){this.downloadDirectoryEntry(e)}};function nc(e,t=[],n=[]){for(let r of e)if(!(!r?.path||!r?.type)){if(n.push({lowerPath:String(r.path).toLowerCase(),name:r.name,path:r.path,type:r.type}),r.type===`file`||r.type===`base`||r.type===`excalidraw`||r.type===`drawio`||r.type===`mermaid`||r.type===`plantuml`||r.type===`image`){t.push(r.path);continue}r.type===`directory`&&Array.isArray(r.children)&&nc(r.children,t,n)}return{files:t,searchEntries:n}}function rc(e,t){for(let n of e??[]){if(n?.path===t)return n;if(n?.type===`directory`&&Array.isArray(n.children)){let e=rc(n.children,t);if(e)return e}}return null}function ic(e){let t=0,n=0;for(let r of e?.children??[]){if(r?.type===`directory`){t+=1;let e=ic(r);t+=e.directoryCount,n+=e.fileCount;continue}n+=1}return{directoryCount:t,fileCount:n}}function ac(e,t,n){return e===t?n:`${n}${e.slice(t.length)}`}var oc=class{constructor(){this.tree=[],this.flatFiles=[],this.flatSearchEntries=[],this.activeFilePath=null,this.expandedDirs=new Set,this.searchQuery=``}setTree(e){this.tree=Array.isArray(e)?e:[];let t=nc(this.tree,[],[]);this.flatFiles=t.files,this.flatSearchEntries=t.searchEntries}setSearchQuery(e){this.searchQuery=String(e??``).trim().toLowerCase()}getSearchMatches(){return this.searchQuery?this.flatSearchEntries.filter(e=>e.lowerPath.includes(this.searchQuery)).map(e=>({name:e.name,path:e.path,type:e.type})):[]}getNode(e){return rc(this.tree,e)}getDirectoryDescendantSummary(e){let t=this.getNode(e);return!t||t.type!==`directory`?{directoryCount:0,fileCount:0}:ic(t)}setActiveFile(e){this.activeFilePath=e||null,e&&this.expandDirectoryPath(e,{includeLeaf:!1})}toggleDirectory(e){return this.expandedDirs.has(e)?(this.expandedDirs.delete(e),!1):(this.expandedDirs.add(e),!0)}expandDirectoryPath(e,{includeLeaf:t=!0}={}){let n=I(e);if(!n)return;let r=n.split(`/`),i=t?r.length:Math.max(r.length-1,0),a=``;for(let e=0;e<i;e+=1)a=a?`${a}/${r[e]}`:r[e],this.expandedDirs.add(a)}replaceExpandedDirectoryPrefix(e,t){let n=new Set;this.expandedDirs.forEach(r=>{if(r===e||r.startsWith(`${e}/`)){n.add(ac(r,e,t));return}n.add(r)}),this.expandedDirs=n}removeExpandedDirectoryPrefix(e){let t=new Set;this.expandedDirs.forEach(n=>{n===e||n.startsWith(`${e}/`)||t.add(n)}),this.expandedDirs=t}};function sc(e){return String(e??``).replace(/\/+$/u,``).split(`/`).filter(Boolean).pop()||``}function cc(e){let t=String(e??``).replace(/\/+$/u,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(0,n):``}function lc(e=[],t=``){for(let n of e){if(n.path===t)return n;if(n.type===`directory`&&Array.isArray(n.children)){let e=lc(n.children,t);if(e)return e}}return null}var uc=420,dc=10,fc=700,pc=class{constructor({mobileBreakpointQuery:e=window.matchMedia(`(max-width: 768px)`),onEntryDrop:t,onDirectorySelect:n,onDirectoryToggle:r,onFileContextMenu:i,onFileSelect:a,onSearchChange:o,onTreeContextMenu:s,onValidateDrop:c}){this.onEntryDrop=t,this.onDirectorySelect=n,this.onDirectoryToggle=r,this.onFileContextMenu=i,this.onFileSelect=a,this.onSearchChange=o,this.onTreeContextMenu=s,this.onValidateDrop=c,this.mobileBreakpointQuery=e,this.treeContainer=document.getElementById(`fileTree`),this.searchInput=document.getElementById(`fileSearchInput`),this.renderedDirectoryWrappers=new Map,this.renderedChildContainers=new Map,this.lastRenderMode=`tree`,this.longPressTimer=0,this.longPressContext=null,this.suppressedActivationTarget=null,this.contextMenuCloseHandler=null,this.actionSheetCloseHandler=null,this.dragSource=null,this.currentSearchQuery=``,this.activeDropTarget=null,this.invalidDropAttempt=null,this.autoExpandTimer=0,this.autoExpandTargetPath=``,this.rootDropZone=null}initialize(){this.searchInput?.addEventListener(`input`,e=>{this.onSearchChange?.(e.target.value)}),this.treeContainer?.addEventListener(`contextmenu`,e=>{e.target.closest(`.file-tree-item`)||(e.preventDefault(),this.onTreeContextMenu?.(e))}),this.treeContainer?.addEventListener(`pointerdown`,e=>{e.target.closest(`.file-tree-item`)||this.startLongPress(e,()=>{this.onTreeContextMenu?.({clientX:Number(e.clientX||0),clientY:Number(e.clientY||0),preventDefault(){},target:this.treeContainer})},this.treeContainer)}),this.treeContainer?.addEventListener(`pointermove`,e=>{this.handleLongPressPointerMove(e)},{passive:!0}),this.treeContainer?.addEventListener(`pointerup`,()=>{this.cancelLongPress()}),this.treeContainer?.addEventListener(`pointercancel`,()=>{this.cancelLongPress()}),this.treeContainer?.addEventListener(`scroll`,()=>{this.cancelLongPress()},{passive:!0}),this.treeContainer?.addEventListener(`dragover`,e=>{this.handleTreeDragOver(e)}),this.treeContainer?.addEventListener(`drop`,e=>{this.handleTreeDrop(e)}),this.treeContainer?.addEventListener(`dragleave`,e=>{this.handleTreeDragLeave(e)})}revealFile(e){Array.from(this.treeContainer?.querySelectorAll(`.file-tree-file`)??[]).find(t=>t.dataset.path===e)?.scrollIntoView({block:`nearest`})}render({activeFilePath:e,changedPaths:t=null,expandedDirs:n,reset:r=!1,searchMatches:i,searchQuery:a,tree:o}){if(!this.treeContainer)return;if(this.currentSearchQuery=String(a??``),this.currentSearchQuery&&this.clearDragFeedback(),this.searchInput&&this.searchInput.value!==a&&(this.searchInput.value=a),a){this.lastRenderMode=`search`,this.renderSearchResults(i,e);return}if(r||this.lastRenderMode!==`tree`||!Array.isArray(t)||t.length===0){this.renderFullTree(o,{activeFilePath:e,expandedDirs:n}),this.lastRenderMode=`tree`;return}let s=Array.from(new Set(t.map(e=>cc(e)))).sort((e,t)=>e.split(`/`).length-t.split(`/`).length).filter((e,t,n)=>!n.slice(0,t).some(t=>t&&e.startsWith(`${t}/`)));if(s.includes(``)){this.renderFullTree(o,{activeFilePath:e,expandedDirs:n}),this.lastRenderMode=`tree`;return}for(let t of s)if(!this.rerenderDirectoryBranch(t,o,{activeFilePath:e,expandedDirs:n})){this.renderFullTree(o,{activeFilePath:e,expandedDirs:n}),this.lastRenderMode=`tree`;return}this.lastRenderMode=`tree`}renderSearchResults(e,t){if(!this.treeContainer)return;if(this.resetTreeIndexes(),this.treeContainer.innerHTML=``,this.rootDropZone=null,e.length===0){this.treeContainer.innerHTML=`<div class="file-tree-empty">No matches</div>`;return}let n=document.createDocumentFragment();for(let r of e){if(r.type===`directory`){n.appendChild(this.createSearchDirectoryItem(r));continue}n.appendChild(this.createFileItem({activeFilePath:t,depth:0,filePath:r.path,fileType:r.type||(h(r.path)??`file`),name:r.name||sc(r.path)}))}this.treeContainer.appendChild(n)}renderFullTree(e,{activeFilePath:t,expandedDirs:n}){if(this.resetTreeIndexes(),this.treeContainer.innerHTML=``,this.rootDropZone=null,e.length===0){this.treeContainer.innerHTML=`<div class="file-tree-empty">No vault files found</div>`;return}let r=document.createDocumentFragment();r.appendChild(this.createRootDropZone()),this.renderNodes(e,r,{activeFilePath:t,depth:0,expandedDirs:n}),this.treeContainer.appendChild(r)}resetTreeIndexes(){this.renderedDirectoryWrappers.clear(),this.renderedChildContainers.clear()}renderNodes(e,t,{activeFilePath:n,depth:r,expandedDirs:i}){for(let a of e){if(a.type===`directory`){t.appendChild(this.createDirectoryItem(a,{activeFilePath:n,depth:r,expandedDirs:i}));continue}t.appendChild(this.createFileItem({activeFilePath:n,depth:r,filePath:a.path,fileType:a.type,name:a.name}))}}createDirectoryItem(e,{activeFilePath:t,depth:n,expandedDirs:r}){let i=document.createElement(`div`);i.className=`file-tree-group`;let a=document.createElement(`button`);a.className=`file-tree-item file-tree-dir`,a.style.setProperty(`--depth`,n),a.dataset.depth=n;let o=r.has(e.path);if(a.setAttribute(`aria-expanded`,String(o)),a.dataset.path=e.path,a.dataset.entryType=`directory`,a.innerHTML=`
|
|
321
|
-
<svg class="file-tree-chevron${o?` expanded`:``}" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
|
|
322
|
-
<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>
|
|
323
|
-
<span class="file-tree-name">${b(e.name)}</span>
|
|
324
|
-
`,this.configureDragSource(a,{path:e.path,type:`directory`}),this.bindDirectoryDropTarget(a,e.path),a.addEventListener(`click`,t=>{this.consumeSuppressedActivation(a,t)||this.onDirectoryToggle?.(e.path)}),a.addEventListener(`contextmenu`,t=>{t.preventDefault(),this.onFileContextMenu?.(t,{directoryPath:e.path,type:`directory`})}),this.bindLongPress(a,()=>{this.onFileContextMenu?.(this.createLongPressEvent(a),{directoryPath:e.path,type:`directory`})}),i.appendChild(a),this.renderedDirectoryWrappers.set(e.path,i),o&&Array.isArray(e.children)){let a=document.createElement(`div`);a.className=`file-tree-children`,this.renderedChildContainers.set(e.path,a),this.renderNodes(e.children,a,{activeFilePath:t,depth:n+1,expandedDirs:r}),i.appendChild(a)}else this.renderedChildContainers.delete(e.path);return i}createSearchDirectoryItem(e){let t=document.createElement(`button`);return t.className=`file-tree-item file-tree-dir`,t.style.setProperty(`--depth`,0),t.dataset.depth=0,t.dataset.path=e.path,t.dataset.entryType=`directory`,t.innerHTML=`
|
|
325
|
-
<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>
|
|
326
|
-
<span class="file-tree-name">${b(e.name||sc(e.path))}</span>
|
|
327
|
-
`,t.addEventListener(`click`,n=>{this.consumeSuppressedActivation(t,n)||this.onDirectorySelect?.(e.path)}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),this.onFileContextMenu?.(t,{directoryPath:e.path,type:`directory`})}),this.bindLongPress(t,()=>{this.onFileContextMenu?.(this.createLongPressEvent(t),{directoryPath:e.path,type:`directory`})}),t}rerenderDirectoryBranch(e,t,{activeFilePath:n,expandedDirs:r}){let i=this.renderedDirectoryWrappers.get(e),a=lc(t,e);if(!i||a?.type!==`directory`)return!1;let o=i.querySelector(`.file-tree-dir`),s=r.has(e);o?.setAttribute(`aria-expanded`,String(s)),o?.querySelector(`.file-tree-chevron`)?.classList.toggle(`expanded`,s);let c=Number(o?.dataset.depth??0),l=this.renderedChildContainers.get(e)??i.querySelector(`.file-tree-children`);return this.clearRenderedDescendants(e),s?(l?l.innerHTML=``:(l=document.createElement(`div`),l.className=`file-tree-children`,i.appendChild(l)),this.renderedChildContainers.set(e,l),this.renderNodes(a.children??[],l,{activeFilePath:n,depth:c+1,expandedDirs:r}),!0):(l?.remove(),this.renderedChildContainers.delete(e),!0)}clearRenderedDescendants(e){let t=`${e}/`;Array.from(this.renderedDirectoryWrappers.keys()).forEach(e=>{e.startsWith(t)&&this.renderedDirectoryWrappers.delete(e)}),Array.from(this.renderedChildContainers.keys()).forEach(e=>{e.startsWith(t)&&this.renderedChildContainers.delete(e)})}createFileItem({activeFilePath:e,depth:t,filePath:n,fileType:r=`file`,name:i}){let a=document.createElement(`button`);a.className=`file-tree-item file-tree-file`;let o=r===`drawio`,s=r===`excalidraw`,l=r===`base`,u=r===`image`,d=r===`mermaid`,f=r===`plantuml`;return l&&a.classList.add(`is-base`),o&&a.classList.add(`is-drawio`),s&&a.classList.add(`is-excalidraw`),u&&a.classList.add(`is-image`),d&&a.classList.add(`is-mermaid`),f&&a.classList.add(`is-plantuml`),n===e&&a.classList.add(`active`),a.style.setProperty(`--depth`,t),a.dataset.depth=t,a.dataset.path=n,a.dataset.entryType=`file`,a.innerHTML=`
|
|
328
|
-
${this.getFileIconSvg({isBase:l,isDrawio:o,isExcalidraw:s,isImage:u,isMermaid:d,isPlantUml:f})}
|
|
329
|
-
<span class="file-tree-name">${b(c(i))}</span>
|
|
330
|
-
`,this.configureDragSource(a,{path:n,type:`file`}),a.addEventListener(`click`,e=>{this.consumeSuppressedActivation(a,e)||this.onFileSelect?.(n)}),a.addEventListener(`contextmenu`,e=>{e.preventDefault(),this.onFileContextMenu?.(e,{filePath:n,type:`file`})}),this.bindLongPress(a,()=>{this.onFileContextMenu?.(this.createLongPressEvent(a),{filePath:n,type:`file`})}),a}isMobileViewport(){return!!this.mobileBreakpointQuery?.matches}isDragAndDropEnabled(){return!this.isMobileViewport()&&!this.currentSearchQuery}configureDragSource(e,t){if(!(e instanceof HTMLElement))return;let n=this.isDragAndDropEnabled();e.draggable=n,n&&(e.addEventListener(`dragstart`,n=>{this.dragSource={path:t.path,type:t.type},document.body?.classList.add(`is-file-tree-dragging`),this.treeContainer&&(this.treeContainer.dataset.dragActive=`true`),e.classList.add(`is-dragging`),n.dataTransfer&&(n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t.path))}),e.addEventListener(`dragend`,()=>{e.classList.remove(`is-dragging`);let t=this.dragSource;this.invalidDropAttempt&&t&&this.onEntryDrop?.(this.invalidDropAttempt),this.dragSource=null,this.invalidDropAttempt=null,this.clearDragFeedback()}),t.type===`file`&&(e.addEventListener(`dragenter`,e=>{this.handleNonDropTargetDragOver(e)}),e.addEventListener(`dragover`,e=>{this.handleNonDropTargetDragOver(e)})))}bindDirectoryDropTarget(e,t){!(e instanceof HTMLElement)||this.isMobileViewport()||(e.addEventListener(`dragenter`,n=>{this.handleDirectoryDragEnter(n,e,t)}),e.addEventListener(`dragover`,n=>{this.handleDirectoryDragOver(n,e,t)}),e.addEventListener(`drop`,e=>{this.handleDirectoryDrop(e,t)}))}createRootDropZone(){let e=document.createElement(`div`);return e.className=`file-tree-root-drop-zone`,e.textContent=`Drop here to move to vault root`,e.addEventListener(`dragenter`,e=>{this.handleRootZoneDragEnter(e)}),e.addEventListener(`dragover`,e=>{this.handleRootZoneDragOver(e)}),e.addEventListener(`drop`,e=>{this.handleRootZoneDrop(e)}),this.rootDropZone=e,e}validateDrop(e){return!this.dragSource||this.currentSearchQuery?!1:this.onValidateDrop?.({destinationDirectory:e,sourcePath:this.dragSource.path,sourceType:this.dragSource.type})===!0}setDropTarget(e){if(this.activeDropTarget?.element&&this.activeDropTarget.element!==e?.element&&this.activeDropTarget.element.classList.remove(`is-drop-target`,`is-drop-invalid`),this.activeDropTarget?.root&&!e?.root&&this.treeContainer?.classList.remove(`is-drop-target-root`,`is-drop-invalid`),this.activeDropTarget?.rootZone&&!e?.rootZone&&this.rootDropZone?.classList.remove(`is-drop-target`,`is-drop-invalid`),this.activeDropTarget=e,!e||e.isValid?this.invalidDropAttempt=null:this.dragSource&&(this.invalidDropAttempt={destinationDirectory:e.destinationDirectory||``,sourcePath:this.dragSource.path,sourceType:this.dragSource.type}),e){if(e.root){this.treeContainer?.classList.toggle(`is-drop-target-root`,e.isValid),this.treeContainer?.classList.toggle(`is-drop-invalid`,!e.isValid);return}if(e.rootZone){this.rootDropZone?.classList.toggle(`is-drop-target`,e.isValid),this.rootDropZone?.classList.toggle(`is-drop-invalid`,!e.isValid);return}e.element.classList.toggle(`is-drop-target`,e.isValid),e.element.classList.toggle(`is-drop-invalid`,!e.isValid)}}scheduleAutoExpand(e,t){e.getAttribute(`aria-expanded`)===`true`||this.autoExpandTargetPath===t||(this.cancelAutoExpand(),this.autoExpandTargetPath=t,this.autoExpandTimer=window.setTimeout(()=>{this.autoExpandTimer=0,this.autoExpandTargetPath=``,e.isConnected&&e.getAttribute(`aria-expanded`)!==`true`&&this.onDirectoryToggle?.(t)},fc))}cancelAutoExpand(){this.autoExpandTimer&&=(window.clearTimeout(this.autoExpandTimer),0),this.autoExpandTargetPath=``}clearDragFeedback(){this.cancelAutoExpand(),this.setDropTarget(null),document.body?.classList.remove(`is-file-tree-dragging`),this.treeContainer&&delete this.treeContainer.dataset.dragActive}handleDirectoryDragEnter(e,t,n){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let r=this.validateDrop(n);this.setDropTarget({destinationDirectory:n,element:t,isValid:r,root:!1}),r?this.scheduleAutoExpand(t,n):this.cancelAutoExpand()}handleDirectoryDragOver(e,t,n){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let r=this.validateDrop(n);e.dataTransfer&&(e.dataTransfer.dropEffect=r?`move`:`none`),this.setDropTarget({destinationDirectory:n,element:t,isValid:r,root:!1}),r?this.scheduleAutoExpand(t,n):this.cancelAutoExpand()}handleDirectoryDrop(e,t){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let n={destinationDirectory:t,sourcePath:this.dragSource.path,sourceType:this.dragSource.type};this.clearDragFeedback(),this.onEntryDrop?.(n)}handleTreeDragOver(e){if(!this.dragSource||!this.treeContainer||e.target.closest(`.file-tree-dir`)||e.target.closest(`.file-tree-item`))return;e.preventDefault(),this.cancelAutoExpand();let t=this.validateDrop(``);e.dataTransfer&&(e.dataTransfer.dropEffect=t?`move`:`none`),this.setDropTarget({destinationDirectory:``,element:this.treeContainer,isValid:t,root:!0})}handleTreeDrop(e){if(!this.dragSource||!this.treeContainer||e.target.closest(`.file-tree-dir`)||e.target.closest(`.file-tree-item`))return;e.preventDefault();let t={destinationDirectory:``,sourcePath:this.dragSource.path,sourceType:this.dragSource.type};this.clearDragFeedback(),this.onEntryDrop?.(t)}handleTreeDragLeave(e){if(!this.dragSource||!this.treeContainer)return;let t=e.relatedTarget;t&&this.treeContainer.contains(t)||this.clearDragFeedback()}handleRootZoneDragEnter(e){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let t=this.validateDrop(``);this.cancelAutoExpand(),this.setDropTarget({destinationDirectory:``,element:this.rootDropZone,isValid:t,rootZone:!0})}handleRootZoneDragOver(e){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let t=this.validateDrop(``);e.dataTransfer&&(e.dataTransfer.dropEffect=t?`move`:`none`),this.cancelAutoExpand(),this.setDropTarget({destinationDirectory:``,element:this.rootDropZone,isValid:t,rootZone:!0})}handleRootZoneDrop(e){if(!this.dragSource)return;e.preventDefault(),e.stopPropagation();let t={destinationDirectory:``,sourcePath:this.dragSource.path,sourceType:this.dragSource.type};this.clearDragFeedback(),this.onEntryDrop?.(t)}handleNonDropTargetDragOver(e){this.dragSource&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`),this.clearDragFeedback())}bindLongPress(e,t){!(e instanceof HTMLElement)||typeof t!=`function`||(e.addEventListener(`pointerdown`,n=>{this.startLongPress(n,t,e)}),e.addEventListener(`pointermove`,e=>{this.handleLongPressPointerMove(e)},{passive:!0}),e.addEventListener(`pointerup`,()=>{this.cancelLongPress()}),e.addEventListener(`pointercancel`,()=>{this.cancelLongPress()}),e.addEventListener(`pointerleave`,()=>{this.cancelLongPress()}))}startLongPress(e,t,n=null){this.isMobileViewport()&&[`touch`,`pen`].includes(String(e.pointerType||``))&&Number(e.button??0)===0&&(this.cancelLongPress(),this.longPressContext={callback:t,pointerId:e.pointerId,startX:Number(e.clientX||0),startY:Number(e.clientY||0),target:n??e.currentTarget??e.target??null},this.longPressTimer=window.setTimeout(()=>{let e=this.longPressContext;this.longPressTimer=0,e&&(this.suppressedActivationTarget=e.target,e.callback(),this.longPressContext=null)},uc))}handleLongPressPointerMove(e){if(!this.longPressContext||e.pointerId!==this.longPressContext.pointerId)return;let t=Math.abs(Number(e.clientX||0)-this.longPressContext.startX),n=Math.abs(Number(e.clientY||0)-this.longPressContext.startY);(t>dc||n>dc)&&this.cancelLongPress()}cancelLongPress(){this.longPressTimer&&=(window.clearTimeout(this.longPressTimer),0),this.longPressContext=null}createLongPressEvent(e){return{clientX:this.longPressContext?.startX??0,clientY:this.longPressContext?.startY??0,preventDefault(){},stopPropagation(){},target:e}}consumeSuppressedActivation(e,t){return this.suppressedActivationTarget===e?(this.suppressedActivationTarget=null,t?.preventDefault?.(),t?.stopPropagation?.(),!0):!1}getFileIconSvg({isBase:e,isDrawio:t,isExcalidraw:n,isImage:r,isMermaid:i,isPlantUml:a}){return e?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4h7l5 5v11a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"/><path d="M14 4v5h5"/><path d="M8 13h8"/><path d="M8 17h6"/><path d="M8 9h3"/></svg>`:t?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="7" height="6" rx="1"/><rect x="14" y="4" width="7" height="6" rx="1"/><rect x="8.5" y="14" width="7" height="6" rx="1"/><path d="M10 7h4"/><path d="M17.5 10v2.5"/><path d="M6.5 10v2.5"/><path d="M6.5 12.5h11"/></svg>`:n?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg>`:r?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="1.5"/><path d="m21 16-5-5L7 20"/><path d="m14 14 2 2"/></svg>`:i?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7.5c0-1.38 1.12-2.5 2.5-2.5 1.04 0 1.93.64 2.3 1.56A2.5 2.5 0 0 1 14 8.5v1"/><path d="M19 16.5c0 1.38-1.12 2.5-2.5 2.5-1.04 0-1.93-.64-2.3-1.56A2.5 2.5 0 0 1 10 15.5v-1"/><path d="M8 10.5h8"/><path d="M8 13.5h8"/><path d="M10 8.5v7"/><path d="M14 8.5v7"/></svg>`:a?`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="7" height="6" rx="1"/><rect x="14" y="4" width="7" height="6" rx="1"/><rect x="8.5" y="14" width="7" height="6" rx="1"/><path d="M10 7h4"/><path d="M17.5 10v2.5"/><path d="M6.5 10v2.5"/><path d="M6.5 12.5h11"/></svg>`:`<svg class="file-tree-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`}showContextMenu(e,t){if(this.removeContextMenu(),!Array.isArray(t)||t.length===0)return;if(this.isMobileViewport()){this.showActionSheet(t);return}let n=document.createElement(`div`);n.className=`file-context-menu`;for(let e of t){let t=document.createElement(`button`);t.className=`file-context-item${e.danger?` file-context-danger`:``}`,t.textContent=e.label,t.addEventListener(`click`,()=>{this.removeContextMenu(),e.onSelect?.()}),n.appendChild(t)}document.body.appendChild(n);let r=n.getBoundingClientRect(),i=Math.max(8,window.innerWidth-r.width-8),a=Math.max(8,window.innerHeight-r.height-8);n.style.left=`${Math.max(8,Math.min(e.clientX,i))}px`,n.style.top=`${Math.max(8,Math.min(e.clientY,a))}px`;let o=e=>{n.contains(e.target)||this.removeContextMenu()};this.contextMenuCloseHandler=o,setTimeout(()=>document.addEventListener(`click`,o),0)}showActionSheet(e){let t=document.createElement(`button`);t.type=`button`,t.className=`file-action-sheet-backdrop`,t.setAttribute(`aria-label`,`Close file actions`);let n=document.createElement(`div`);n.className=`file-action-sheet`,e.forEach(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=G({variant:`secondary`,extra:[`file-action-sheet-item`,e.danger?`file-context-danger`:``]}),t.textContent=e.label,t.addEventListener(`click`,()=>{this.removeContextMenu(),e.onSelect?.()}),n.appendChild(t)});let r=document.createElement(`button`);r.type=`button`,r.className=G({variant:`ghost`,extra:`file-action-sheet-item`}),r.textContent=`Cancel`,r.addEventListener(`click`,()=>{this.removeContextMenu()}),n.appendChild(r),t.addEventListener(`click`,()=>{this.removeContextMenu()}),document.body.append(t,n),this.actionSheetCloseHandler=()=>{t.remove(),n.remove(),this.actionSheetCloseHandler=null}}removeContextMenu(){this.cancelLongPress(),this.clearDragFeedback(),document.querySelectorAll(`.file-context-menu`).forEach(e=>e.remove()),this.contextMenuCloseHandler&&=(document.removeEventListener(`click`,this.contextMenuCloseHandler),null),this.actionSheetCloseHandler?.()}},mc=class{constructor({mobileBreakpointQuery:e=window.matchMedia(`(max-width: 768px)`),onFileSelect:t,onFileDelete:n,pendingWorkspaceRequestIds:r=null,toastController:i,vaultClient:a=w}){this.onFileSelect=t,this.onFileDelete=n,this.toastController=i,this.vaultClient=a,this.state=new oc,this.view=new pc({mobileBreakpointQuery:e,onDirectorySelect:e=>{this.state.expandDirectoryPath(e),this.state.setSearchQuery(``),this.renderTree({reset:!0})},onDirectoryToggle:e=>{this.state.toggleDirectory(e),this.renderTree()},onEntryDrop:e=>this.actionController.moveEntryByDrop(e),onFileContextMenu:(e,t)=>{if(t.type===`directory`){this.view.showContextMenu(e,this.actionController.getDirectoryContextMenuItems(t.directoryPath));return}this.view.showContextMenu(e,this.actionController.getFileContextMenuItems(t.filePath))},onFileSelect:e=>{this.onFileSelect?.(e)},onValidateDrop:e=>this.actionController.canMoveEntryByDrop(e),onSearchChange:e=>{this.state.setSearchQuery(e),this.renderTree()},onTreeContextMenu:e=>{this.view.showContextMenu(e,this.actionController.createContextMenuItems())}}),this.actionController=new tc({mobileBreakpointQuery:e,onFileDelete:this.onFileDelete,onFileSelect:this.onFileSelect,pendingWorkspaceRequestIds:r,refresh:()=>this.refresh(),state:this.state,toastController:this.toastController,vaultClient:this.vaultClient,view:this.view})}initialize(){this.view.initialize(),this.actionController.initialize()}async refresh(){try{let e=await this.vaultClient.readTree();this.setTree(e.tree||[])}catch(e){console.error(`[explorer] Failed to load file tree:`,e.message)}}setTree(e,{changedPaths:t=null,reset:n=!1}={}){this.state.setTree(e),this.renderTree({changedPaths:t,reset:n})}setActiveFile(e){this.state.setActiveFile(e),this.renderTree()}revealFile(e,{clearSearch:t=!1}={}){t&&this.state.setSearchQuery(``),this.state.setActiveFile(e),this.renderTree({reset:t}),this.view.revealFile(e)}get flatFiles(){return this.state.flatFiles}get flatDocumentFiles(){return this.state.flatFiles.filter(e=>!o(e))}renderTree({changedPaths:e=null,reset:t=!1}={}){this.view.render({activeFilePath:this.state.activeFilePath,changedPaths:e,expandedDirs:this.state.expandedDirs,reset:t,searchMatches:this.state.getSearchMatches(),searchQuery:this.state.searchQuery,tree:this.state.tree})}},hc=30;function gc(e){return String(e??``).split(`/`).pop()||``}function _c(e){let t=String(e??``).split(`/`);return t.pop(),t.join(`/`)}function vc(e=``){let t=gc(e),n=_c(e);return n?`
|
|
331
|
-
<span class="file-history-path">${b(t)}</span>
|
|
332
|
-
<span class="file-history-dir">${b(n)}</span>
|
|
333
|
-
`:`<span class="file-history-path">${b(t)}</span>`}function yc(e={}){let t=[String(e.authorName||`Unknown`),String(e.relativeDateLabel||``)];return e.status===`renamed`&&e.oldPath&&t.push(`Renamed from ${e.oldPath}`),t.filter(Boolean).map(e=>b(e)).join(` · `)}function bc(e={}){return e.type===`local`?`local`:`commit:${String(e.hash||``).trim()}:${String(e.pathAtCommit||``).trim()}`}function xc(){return{commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0}}var Sc=class{constructor({diffRenderer:e=null,gitApiClient:t=null,onOpenCommitDiff:n=()=>{},onOpenFile:r=()=>{},onOpenPreview:i=()=>{},onOpenWorkspaceDiff:a=()=>{},toastController:o=null}={}){this.diffRenderer=e,this.gitApiClient=t,this.onOpenCommitDiff=n,this.onOpenFile=r,this.onOpenPreview=i,this.onOpenWorkspaceDiff=a,this.toastController=o,this.page=document.getElementById(`diff-page`),this.content=document.getElementById(`diffContent`),this.fileIndicator=document.getElementById(`diffFileIndicator`),this.openEditorButton=document.getElementById(`diffOpenEditorBtn`),this.primaryActionButton=document.getElementById(`diffPrimaryActionBtn`),this.commitButton=document.getElementById(`diffCommitBtn`),this.backToHistoryButton=document.getElementById(`diffBackToHistoryBtn`),this.gitActionsGroup=document.getElementById(`diffGitActionsGroup`),this.editorActionsGroup=document.getElementById(`diffEditorActionsGroup`),this.actionsDivider=document.getElementById(`diffToolbarDivider`),this.stats=document.getElementById(`diffStats`),this.prevButton=document.getElementById(`diffPrevBtn`),this.nextButton=document.getElementById(`diffNextBtn`),this.layoutToggle=document.getElementById(`diffLayoutToggle`),this.modeButtons=Array.from(document.querySelectorAll(`[data-diff-mode]`)),this.isActive=!1,this.currentFilePath=null,this.localChanges=null,this.history=xc(),this.diffMode=`unified`,this.selectedEntryKey=null,this.detailCache=new Map,this.detailErrors=new Map,this.historyListElement=null,this.historyListScrollTop=0,this.loadingEntryKey=null,this.selectionRequestToken=0}initialize(){this.openEditorButton?.addEventListener(`click`,()=>{this.isActive&&this.currentFilePath&&this.onOpenFile?.(this.currentFilePath)}),this.modeButtons.forEach(e=>{e.addEventListener(`click`,()=>{if(!this.isActive)return;let t=e.getAttribute(`data-diff-mode`);!t||t===this.diffMode||(this.diffMode=t,this.render())})}),this.content?.addEventListener(`click`,e=>{if(!this.isActive)return;let t=e.target instanceof Element?e.target.closest(`[data-file-history-select]`):null;if(t){let e=this.findEntryByKey(t.getAttribute(`data-file-history-select`));e&&this.selectEntry(e);return}if(e.target instanceof Element&&e.target.closest(`[data-file-history-open-selected-diff]`)){this.openSelectedDiff();return}if(e.target instanceof Element&&e.target.closest(`[data-file-history-open-selected-preview]`)){this.openSelectedPreview();return}e.target instanceof Element&&e.target.closest(`[data-file-history-load-more]`)&&this.loadMore()})}hide(){this.isActive=!1,this.page?.classList.add(`hidden`),this.content?.classList.remove(`diff-content--history`),this.content&&(this.content.innerHTML=``),this.currentFilePath=null,this.localChanges=null,this.history=xc(),this.selectedEntryKey=null,this.loadingEntryKey=null,this.detailCache.clear(),this.detailErrors.clear(),this.historyListElement=null,this.historyListScrollTop=0,this.selectionRequestToken=0}getEntries(){let e=[];this.localChanges&&e.push({...this.localChanges,key:`local`,label:`Local changes`,pathAtCommit:this.currentFilePath,type:`local`});for(let t of this.history.commits??[])e.push({...t,key:bc({...t,type:`commit`}),type:`commit`});return e}findEntryByKey(e){return this.getEntries().find(t=>t.key===e)??null}getSelectedEntry(){return this.findEntryByKey(this.selectedEntryKey)}getDefaultEntry(){return this.getEntries()[0]??null}getSelectedDetailState(){let e=this.getSelectedEntry();return e?{detail:this.detailCache.get(e.key)??null,entry:e,error:this.detailErrors.get(e.key)??``,loading:this.loadingEntryKey===e.key}:null}async openFileHistory({filePath:e}){this.isActive=!0,this.currentFilePath=String(e??``).trim()||null,this.localChanges=null,this.history={...xc(),loading:!0},this.selectedEntryKey=null,this.loadingEntryKey=null,this.detailCache.clear(),this.detailErrors.clear(),this.historyListElement=null,this.historyListScrollTop=0,this.selectionRequestToken=0,this.renderLoading();try{let[e,t]=await Promise.all([this.loadLocalChanges().catch(()=>null),this.fetchHistoryPage({offset:0})]);this.localChanges=e,this.history=t;let n=this.getDefaultEntry();return n?(await this.selectEntry(n),{history:t,localChanges:e}):(this.render(),{history:t,localChanges:e})}catch(e){return console.error(`[file-history] Failed to load file history:`,e),this.toastController?.show(`Failed to load file history`),this.localChanges=null,this.history={...xc(),error:`Failed to load file history`,loaded:!0},this.render(),{history:this.history,localChanges:null}}}async loadLocalChanges(){if(!this.currentFilePath)return null;let e=await this.gitApiClient.readDiff({metaOnly:!0,path:this.currentFilePath,scope:`all`}),t=e.files?.[0];return t?{...t,summary:e.summary??{additions:Number(t.stats?.additions||0),deletions:Number(t.stats?.deletions||0),filesChanged:1}}:null}async fetchHistoryPage({offset:e=0}={}){if(!this.currentFilePath)return{...xc(),loaded:!0};let t=await this.gitApiClient.readFileHistory({limit:hc,offset:e,path:this.currentFilePath}),n=Array.isArray(t.commits)?t.commits:[];return{commits:n,error:``,hasMore:!!t.hasMore,loaded:!0,loading:!1,loadingMore:!1,offset:e+n.length}}async loadSelectedDetail(e){if(!e)return null;if(e.type===`local`){let t=await this.gitApiClient.readDiff({path:this.currentFilePath||``,scope:`all`});return{detail:t.files?.[0]??null,summary:t.summary??e.summary??null}}let t=await this.gitApiClient.readCommit({hash:e.hash||``,path:e.pathAtCommit||``});return{commit:t.commit??null,detail:t.files?.[0]??null,summary:t.summary??null}}async selectEntry(e){if(!e)return null;let t=e.key||bc(e);this.selectedEntryKey=t,this.detailErrors.delete(t);let n=this.detailCache.get(t);if(n)return this.loadingEntryKey=null,this.render(),n;this.loadingEntryKey=t,this.render();let r=++this.selectionRequestToken;try{let n=await this.loadSelectedDetail(e);return this.detailCache.set(t,n),this.detailErrors.delete(t),r===this.selectionRequestToken&&this.selectedEntryKey===t&&(this.loadingEntryKey=null,this.render()),n}catch(n){return console.error(`[file-history] Failed to load selected diff:`,n),this.toastController?.show(e.type===`local`?`Failed to load local diff`:`Failed to load commit diff`),this.detailErrors.set(t,e.type===`local`?`Failed to load local diff`:`Failed to load commit diff`),r===this.selectionRequestToken&&this.selectedEntryKey===t&&(this.loadingEntryKey=null,this.render()),null}}async loadMore(){if(!(!this.currentFilePath||this.history.loading||this.history.loadingMore||!this.history.hasMore)){this.history={...this.history,error:``,loadingMore:!0},this.render();try{let e=await this.fetchHistoryPage({offset:this.history.offset});this.history={commits:[...this.history.commits,...e.commits],error:``,hasMore:e.hasMore,loaded:!0,loading:!1,loadingMore:!1,offset:e.offset},this.render()}catch(e){console.error(`[file-history] Failed to load more history:`,e),this.toastController?.show(`Failed to load file history`),this.history={...this.history,error:`Failed to load file history`,loadingMore:!1},this.render()}}}openSelectedDiff(){let e=this.getSelectedEntry();if(e){if(e.type===`local`){this.onOpenWorkspaceDiff?.(this.currentFilePath);return}this.onOpenCommitDiff?.(e.hash,{historyFilePath:this.currentFilePath,path:e.pathAtCommit})}}openSelectedPreview(){let e=this.getSelectedEntry();!e||e.type!==`commit`||this.onOpenPreview?.({currentFilePath:this.currentFilePath,hash:e.hash,path:e.pathAtCommit})}renderDiffFileHeader(e={}){return typeof this.diffRenderer?.renderFileHeader==`function`?this.diffRenderer.renderFileHeader(e):`
|
|
334
|
-
<div class="diff-file-header">
|
|
335
|
-
<span class="diff-file-path">${b(e.path||this.currentFilePath||``)}</span>
|
|
336
|
-
</div>
|
|
337
|
-
`}renderDiffMarkup(e={}){if(typeof this.diffRenderer?.renderDiffDetail==`function`){let t=this.diffRenderer.mode;this.diffRenderer.mode=this.diffMode;let n=this.diffRenderer.renderDiffDetail(e,0,{includeHeader:!0});return this.diffRenderer.mode=t,n}return`
|
|
338
|
-
${this.renderDiffFileHeader(e)}
|
|
339
|
-
<div class="diff-empty-state">Diff renderer unavailable.</div>
|
|
340
|
-
`}syncToolbar(){let e=this.getSelectedDetailState(),t=e?.entry??null,n=e?.detail?.summary??t?.summary??(t?{additions:Number(t.additions||0),deletions:Number(t.deletions||0)}:null),r=!!t;this.syncToolbarIndicators(t,n,r),this.syncToolbarButtonStates(r)}syncToolbarIndicators(e,t,n){let r=Number(t?.additions||0),i=Number(t?.deletions||0);this.fileIndicator&&(this.fileIndicator.textContent=e?.type===`commit`?e.shortHash||`Commit`:e?.type===`local`?`Local changes`:`History`),this.stats&&(this.stats.innerHTML=`
|
|
341
|
-
<span class="ui-stat-token ui-stat-token--add diff-stats-add">+${r}</span>
|
|
342
|
-
<span class="ui-stat-token ui-stat-token--del diff-stats-del">-${i}</span>
|
|
343
|
-
`,this.stats.classList.toggle(`hidden`,!n))}syncToolbarButtonStates(e){this.backToHistoryButton?.classList.add(`hidden`),this.gitActionsGroup?.classList.add(`hidden`),this.layoutToggle?.classList.add(`hidden`),this.prevButton?.classList.add(`hidden`),this.nextButton?.classList.add(`hidden`),this.actionsDivider?.classList.add(`hidden`),this.editorActionsGroup?.classList.remove(`hidden`),this.modeButtons.forEach(t=>{t.classList.toggle(`hidden`,!e),t.classList.toggle(`active`,t.getAttribute(`data-diff-mode`)===this.diffMode)}),this.openEditorButton?.toggleAttribute(`disabled`,!this.currentFilePath),this.openEditorButton&&(this.openEditorButton.textContent=`Open File`),this.primaryActionButton?.toggleAttribute(`disabled`,!0),this.commitButton?.toggleAttribute(`disabled`,!0)}renderLoading(){this.isActive&&(this.page?.classList.remove(`hidden`),this.content&&(this.content.classList.add(`diff-content--history`),this.content.innerHTML=`<div class="git-panel-empty">Loading file history...</div>`),this.historyListElement=null,this.syncToolbar())}renderEmpty(e){this.isActive&&(this.page?.classList.remove(`hidden`),this.content&&(this.content.classList.add(`diff-content--history`),this.content.innerHTML=`<div class="git-panel-empty">${b(e)}</div>`),this.historyListElement=null,this.syncToolbar())}captureListScroll(){this.historyListElement&&(this.historyListScrollTop=Number(this.historyListElement.scrollTop||0))}restoreListScroll(){if(!this.content?.querySelector){this.historyListElement=null;return}let e=this.content.querySelector(`[data-file-history-list]`);this.historyListElement=e??null,e&&(e.scrollTop=this.historyListScrollTop,e.addEventListener(`scroll`,()=>{this.historyListScrollTop=Number(e.scrollTop||0)},{passive:!0}))}renderScopeLabels(e={}){let t=[];return e.hasStagedChanges&&t.push(`staged`),e.hasWorkingTreeChanges&&t.push(`working tree`),e.hasUntrackedChanges&&t.push(`untracked`),t.length>0?t.join(` · `):`working tree`}renderHistoryItem(e={}){let t=e.key===this.selectedEntryKey,n=Number(e.additions??e.summary?.additions??0),r=Number(e.deletions??e.summary?.deletions??0),i=e.type===`local`?`Live workspace`:yc(e),a=e.type===`local`?`Local changes`:e.subject||e.shortHash||`Commit`,o=e.type===`local`?`<span class="ui-pill-badge ui-pill-badge--accent file-history-item-badge">Live</span>`:`<span class="ui-pill-badge ui-pill-badge--code file-history-item-badge">${b(e.shortHash||``)}</span>`;return`
|
|
344
|
-
<button
|
|
345
|
-
class="ui-record-surface file-history-item${t?` active`:``}${e.type===`local`?` file-history-item-local`:``}"
|
|
346
|
-
type="button"
|
|
347
|
-
data-file-history-select="${b(e.key)}"
|
|
348
|
-
aria-current="${t?`true`:`false`}"
|
|
349
|
-
>
|
|
350
|
-
<span class="file-history-item-top">
|
|
351
|
-
<span class="file-history-item-copy">
|
|
352
|
-
<span class="file-history-item-title">${b(a)}</span>
|
|
353
|
-
<span class="file-history-item-meta">${e.type===`local`?b(this.renderScopeLabels(e)):i}</span>
|
|
354
|
-
</span>
|
|
355
|
-
${o}
|
|
356
|
-
</span>
|
|
357
|
-
<span class="file-history-item-stats">
|
|
358
|
-
<span class="git-change-add">+${n}</span>
|
|
359
|
-
<span class="git-change-del">-${r}</span>
|
|
360
|
-
</span>
|
|
361
|
-
</button>
|
|
362
|
-
`}renderSelectedHeader(e){let t=e?.entry;return t?`
|
|
363
|
-
<div class="file-history-detail-header">
|
|
364
|
-
<div class="file-history-detail-copy">
|
|
365
|
-
<span class="file-history-detail-kicker">${t.type===`local`?`Live workspace`:`Commit ${b(t.shortHash||``)}`}</span>
|
|
366
|
-
<h2 class="file-history-detail-title">${t.type===`local`?`Local changes`:b(t.subject||t.shortHash||`Commit`)}</h2>
|
|
367
|
-
<p class="file-history-detail-meta">${t.type===`local`?b(this.renderScopeLabels(t)):yc(t)}</p>
|
|
368
|
-
</div>
|
|
369
|
-
<div class="file-history-detail-actions">
|
|
370
|
-
<button
|
|
371
|
-
class="${G({variant:`secondary`,action:!0,surface:!0})}"
|
|
372
|
-
type="button"
|
|
373
|
-
data-file-history-open-selected-diff
|
|
374
|
-
>
|
|
375
|
-
Open Standalone Diff
|
|
376
|
-
</button>
|
|
377
|
-
${t.type===`commit`?`
|
|
378
|
-
<button
|
|
379
|
-
class="${G({variant:`primary`,action:!0})}"
|
|
380
|
-
type="button"
|
|
381
|
-
data-file-history-open-selected-preview
|
|
382
|
-
>
|
|
383
|
-
Preview File
|
|
384
|
-
</button>
|
|
385
|
-
`:``}
|
|
386
|
-
</div>
|
|
387
|
-
</div>
|
|
388
|
-
`:`
|
|
389
|
-
<div class="file-history-detail-header">
|
|
390
|
-
<div class="file-history-detail-copy">
|
|
391
|
-
<span class="file-history-detail-kicker">History</span>
|
|
392
|
-
<h2 class="file-history-detail-title">No selection</h2>
|
|
393
|
-
<p class="file-history-detail-meta">Choose a history item to inspect the file diff.</p>
|
|
394
|
-
</div>
|
|
395
|
-
</div>
|
|
396
|
-
`}renderSelectedBody(e){let t=e?.entry;return t?e.loading?`
|
|
397
|
-
<section class="diff-file-block file-history-diff-block">
|
|
398
|
-
${this.renderDiffFileHeader({path:t.pathAtCommit||this.currentFilePath||``})}
|
|
399
|
-
<div class="diff-empty-state">Loading diff...</div>
|
|
400
|
-
</section>
|
|
401
|
-
`:e.error?`
|
|
402
|
-
<section class="diff-file-block file-history-diff-block">
|
|
403
|
-
${this.renderDiffFileHeader({path:t.pathAtCommit||this.currentFilePath||``})}
|
|
404
|
-
<div class="diff-empty-state">${b(e.error)}</div>
|
|
405
|
-
</section>
|
|
406
|
-
`:e.detail?.detail?`
|
|
407
|
-
<section class="diff-file-block file-history-diff-block">
|
|
408
|
-
${this.renderDiffMarkup(e.detail.detail)}
|
|
409
|
-
</section>
|
|
410
|
-
`:`<div class="diff-empty-state">No diff available for this history item.</div>`:`<div class="diff-empty-state">Select a history entry to inspect this file.</div>`}render(){if(!this.isActive)return;if(this.page?.classList.remove(`hidden`),this.captureListScroll(),this.syncToolbar(),!this.currentFilePath){this.renderEmpty(`No file selected.`);return}if(this.history.loading&&!this.history.loaded){this.renderLoading();return}if(!(this.localChanges||(this.history.commits?.length??0)>0)){this.renderEmpty(this.history.error||`No history found for this file.`);return}if(!this.content)return;this.content.classList.add(`diff-content--history`);let e=this.getSelectedDetailState();this.content.innerHTML=`
|
|
411
|
-
<section class="file-history-shell">
|
|
412
|
-
<aside class="file-history-sidebar" aria-label="File history entries">
|
|
413
|
-
<header class="file-history-sidebar-header">
|
|
414
|
-
<span class="file-history-kicker">File history</span>
|
|
415
|
-
<div class="file-history-title">${vc(this.currentFilePath)}</div>
|
|
416
|
-
<p class="file-history-sidebar-copy">Select an entry to inspect the exact changes for this file.</p>
|
|
417
|
-
</header>
|
|
418
|
-
<div class="file-history-list" data-file-history-list>
|
|
419
|
-
${this.getEntries().map(e=>this.renderHistoryItem(e)).join(``)}
|
|
420
|
-
</div>
|
|
421
|
-
${this.history.hasMore?`
|
|
422
|
-
<div class="git-history-footer file-history-footer">
|
|
423
|
-
<button
|
|
424
|
-
class="${G({variant:`secondary`,size:`compact`,action:!0,surface:!0,extra:`git-history-load-more`})}"
|
|
425
|
-
type="button"
|
|
426
|
-
data-file-history-load-more
|
|
427
|
-
${this.history.loadingMore?`disabled`:``}
|
|
428
|
-
>
|
|
429
|
-
${this.history.loadingMore?`Loading...`:`Load More`}
|
|
430
|
-
</button>
|
|
431
|
-
</div>
|
|
432
|
-
`:``}
|
|
433
|
-
</aside>
|
|
434
|
-
<section class="file-history-detail">
|
|
435
|
-
${this.renderSelectedHeader(e)}
|
|
436
|
-
<div class="file-history-detail-body">
|
|
437
|
-
${this.renderSelectedBody(e)}
|
|
438
|
-
</div>
|
|
439
|
-
</section>
|
|
440
|
-
</section>
|
|
441
|
-
`,this.restoreListScroll()}};function Cc(e){return String(e??``).split(`/`).pop()||``}function wc(e){let t=String(e??``).split(`/`);return t.pop(),t.join(`/`)}function Tc(e){return`diff-section-${encodeURIComponent(String(e??``)).replace(/%/g,`_`)}`}function Ec(e){switch(e){case`added`:case`untracked`:return`ui-status-badge--success`;case`deleted`:return`ui-status-badge--danger`;case`renamed`:return`ui-status-badge--accent`;default:return`ui-status-badge--warning`}}function Dc(e=!1){return`<svg class="diff-section-chevron${e?` collapsed`:``}" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>`}function Oc(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;return n}function kc(e,t,n){let r=0,i=Math.min(e.length,t.length)-n;for(;r<i;){let n=e.length-1-r,i=t.length-1-r;if(e[n]!==t[i])break;r+=1}return r}function Ac(e,t){let n=Oc(e,t),r=kc(e,t,n),i=Math.max(n,e.length-r),a=Math.max(n,t.length-r);return{leftHtml:`${b(e.slice(0,n))}${i>n?`<span class="diff-highlight-del">${b(e.slice(n,i))}</span>`:``}${b(e.slice(i))}`,rightHtml:`${b(t.slice(0,n))}${a>n?`<span class="diff-highlight-add">${b(t.slice(n,a))}</span>`:``}${b(t.slice(a))}`}}function jc(e=[]){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.type===`context`||r.type===`note`){t.push({additions:[],context:[r],deletions:[]});continue}if(r.type!==`deletion`&&r.type!==`addition`)continue;let i=[],a=[];for(;n<e.length&&e[n].type===`deletion`;)i.push(e[n]),n+=1;for(;n<e.length&&e[n].type===`addition`;)a.push(e[n]),n+=1;--n,t.push({additions:a,context:[],deletions:i})}return t}function Mc(e,t,n){let r=Number.isInteger(e.oldLine)?e.oldLine:``,i=Number.isInteger(e.newLine)?e.newLine:``;return`
|
|
442
|
-
<div class="diff-line ${e.type===`note`?`note`:e.type}">
|
|
443
|
-
<div class="diff-line-numbers">
|
|
444
|
-
<span class="diff-line-num">${r}</span>
|
|
445
|
-
<span class="diff-line-num">${i}</span>
|
|
446
|
-
</div>
|
|
447
|
-
<div class="diff-line-prefix">${b(e.type===`context`||e.type===`note`?` `:t)}</div>
|
|
448
|
-
<div class="diff-line-content">${n}</div>
|
|
449
|
-
</div>
|
|
450
|
-
`}function Nc(e,t){let n=e?b(e.content):``,r=t?b(t.content):``;if(e&&t&&e.type===`deletion`&&t.type===`addition`){let i=Ac(e.content,t.content);n=i.leftHtml,r=i.rightHtml}return`
|
|
451
|
-
<div class="diff-split-row">
|
|
452
|
-
<div class="diff-split-line ${e?.type||`empty`}">
|
|
453
|
-
<span class="diff-split-num">${Number.isInteger(e?.oldLine)?e.oldLine:``}</span>
|
|
454
|
-
<span class="diff-split-content">${n}</span>
|
|
455
|
-
</div>
|
|
456
|
-
<div class="diff-split-line ${t?.type||`empty`}">
|
|
457
|
-
<span class="diff-split-num">${Number.isInteger(t?.newLine)?t.newLine:``}</span>
|
|
458
|
-
<span class="diff-split-content">${r}</span>
|
|
459
|
-
</div>
|
|
460
|
-
</div>
|
|
461
|
-
`}var Pc=class{constructor({gitApiClient:e=null,onBackToHistory:t=null,onCommitStaged:n=null,onOpenFile:r=null,onStageFile:i=null,onUnstageFile:a=null,toastController:o=null}={}){this.gitApiClient=e,this.onBackToHistory=t,this.onCommitStaged=n,this.onOpenFile=r,this.onStageFile=i,this.onUnstageFile=a,this.toastController=o,this.page=document.getElementById(`diff-page`),this.content=document.getElementById(`diffContent`),this.scrollContainer=document.getElementById(`diffScroll`),this.fileIndicator=document.getElementById(`diffFileIndicator`),this.openEditorButton=document.getElementById(`diffOpenEditorBtn`),this.primaryActionButton=document.getElementById(`diffPrimaryActionBtn`),this.commitButton=document.getElementById(`diffCommitBtn`),this.backToHistoryButton=document.getElementById(`diffBackToHistoryBtn`),this.gitActionsGroup=document.getElementById(`diffGitActionsGroup`),this.editorActionsGroup=document.getElementById(`diffEditorActionsGroup`),this.actionsDivider=document.getElementById(`diffToolbarDivider`),this.stats=document.getElementById(`diffStats`),this.prevButton=document.getElementById(`diffPrevBtn`),this.nextButton=document.getElementById(`diffNextBtn`),this.layoutToggle=document.getElementById(`diffLayoutToggle`),this.modeButtons=Array.from(document.querySelectorAll(`[data-diff-mode]`)),this.layoutButtons=Array.from(document.querySelectorAll(`[data-diff-layout]`)),this.isActive=!1,this.mode=`unified`,this.layoutMode=`focused`,this.source=`workspace`,this.data=null,this.currentIndex=0,this.activeFilePath=null,this.fileCache=new Map,this.fileErrors=new Map,this.loadingFiles=new Set,this.collapsedFiles=new Set,this.fileLoadPromises=new Map,this.requestScope=`all`,this.commitHash=null,this.commitMeta=null,this.historyFilePath=null,this.pendingAction=null,this.repoStatus=null}initialize(){this.prevButton?.addEventListener(`click`,()=>{this.isActive&&this.navigateFile(-1)}),this.nextButton?.addEventListener(`click`,()=>{this.isActive&&this.navigateFile(1)}),this.backToHistoryButton?.addEventListener(`click`,()=>{this.isActive&&this.commitMeta?.hash&&this.onBackToHistory?.({hash:this.commitMeta.hash,historyFilePath:this.historyFilePath})}),this.openEditorButton?.addEventListener(`click`,()=>{if(!this.isActive||this.source!==`workspace`)return;let e=this.getCurrentFile();e?.path&&this.onOpenFile?.(e.path)}),this.primaryActionButton?.addEventListener(`click`,()=>{if(!this.isActive)return;let e=this.getPrimaryAction();e&&this.handleFileAction(e)}),this.commitButton?.addEventListener(`click`,()=>{this.isActive&&this.handleFileAction(`commit`)}),this.content?.addEventListener(`click`,e=>{if(!this.isActive)return;let t=e.target instanceof Element?e.target.closest(`[data-load-full-diff]`):null;if(t){let e=t.getAttribute(`data-diff-file-path`)||this.activeFilePath;e&&this.loadFileForPath(e,{forceFullPatch:!0});return}let n=e.target instanceof Element?e.target.closest(`[data-diff-section-toggle]`):null;if(n){let e=n.getAttribute(`data-diff-section-toggle`);e&&this.toggleFileSection(e);return}let r=e.target instanceof Element?e.target.closest(`[data-diff-index-path]`):null;if(r){let e=r.getAttribute(`data-diff-index-path`);e&&this.handleIndexSelection(e)}}),this.modeButtons.forEach(e=>{e.addEventListener(`click`,()=>{if(!this.isActive)return;let t=e.getAttribute(`data-diff-mode`);!t||t===this.mode||(this.mode=t,this.render())})}),this.layoutButtons.forEach(e=>{e.addEventListener(`click`,()=>{if(!this.isActive)return;let t=e.getAttribute(`data-diff-layout`);!t||t===this.layoutMode||this.setLayoutMode(t)})}),this.scrollContainer?.addEventListener(`scroll`,()=>{this.isActive&&this.handleScrollSelection()})}hide(){this.isActive=!1,this.page?.classList.add(`hidden`),this.content&&(this.content.innerHTML=``),this.data=null,this.source=`workspace`,this.layoutMode=`focused`,this.currentIndex=0,this.activeFilePath=null,this.fileCache.clear(),this.fileErrors.clear(),this.loadingFiles.clear(),this.collapsedFiles.clear(),this.fileLoadPromises.clear(),this.requestScope=`all`,this.commitHash=null,this.commitMeta=null,this.historyFilePath=null,this.pendingAction=null,this.repoStatus=null}async openWorkspaceDiff({filePath:e=null,scope:t=`all`}={}){this.isActive=!0,this.source=`workspace`,this.layoutMode=`focused`,this.commitHash=null,this.commitMeta=null,this.historyFilePath=null,this.activeFilePath=e,this.fileCache.clear(),this.fileErrors.clear(),this.loadingFiles.clear(),this.collapsedFiles.clear(),this.fileLoadPromises.clear(),this.requestScope=t,this.renderLoading(`Loading diff summary...`);try{let n=await this.gitApiClient.readDiff({metaOnly:!0,path:e,scope:t});this.data=n;let r=e?Math.max(0,n.files.findIndex(t=>t.path===e)):0;return this.currentIndex=r,this.activeFilePath=n.files?.[r]?.path??null,(n.files?.length??0)===0?(this.render(),n):(await this.loadCurrentFile(),n)}catch(e){return console.error(`[git-diff] Failed to load diff:`,e),this.toastController?.show(`Failed to load git diff`),this.data={files:[],metaOnly:!1,source:`workspace`,summary:{additions:0,deletions:0,filesChanged:0}},this.renderEmpty(`Failed to load git diff`),this.data}}async openCommitDiff({hash:e,path:t=null,historyFilePath:n=null}={}){this.isActive=!0,this.source=`commit`,this.layoutMode=`stacked`,this.commitHash=String(e??``).trim()||null,this.commitMeta=null,this.historyFilePath=String(n??``).trim()||null,this.activeFilePath=t||null,this.fileCache.clear(),this.fileErrors.clear(),this.loadingFiles.clear(),this.collapsedFiles.clear(),this.fileLoadPromises.clear(),this.requestScope=`all`,this.renderLoading(`Loading commit summary...`);try{let e=await this.gitApiClient.readCommit({hash:this.commitHash||``,metaOnly:!0});this.data=e,this.commitMeta=e.commit??null;let n=t?Math.max(0,e.files.findIndex(e=>e.path===t)):0;return this.currentIndex=n,this.activeFilePath=e.files?.[n]?.path??null,this.collapsedFiles=new Set((e.files??[]).map(e=>e.path).filter(e=>e&&e!==this.activeFilePath)),(e.files?.length??0)===0?(this.render(),e):(this.activeFilePath&&await this.loadFileForPath(this.activeFilePath,{render:!1}),this.render(),e)}catch(e){return console.error(`[git-diff] Failed to load commit:`,e),this.toastController?.show(`Failed to load git commit`),this.data={commit:null,files:[],metaOnly:!1,source:`commit`,summary:{additions:0,deletions:0,filesChanged:0}},this.commitMeta=null,this.renderEmpty(`Failed to load git commit`),this.data}}async open(e={}){return this.openWorkspaceDiff(e)}async setLayoutMode(e){let t=e===`stacked`?`stacked`:`focused`;if(this.source!==`commit`){this.layoutMode=`focused`,this.render();return}if(this.layoutMode=t,this.activeFilePath&&this.setActiveFilePath(this.activeFilePath),this.layoutMode===`focused`){await this.loadCurrentFile();return}this.activeFilePath&&(this.collapsedFiles.delete(this.activeFilePath),await this.loadFileForPath(this.activeFilePath,{render:!1})),this.render()}navigateFile(e){if(!this.data?.files?.length||this.source===`commit`&&this.layoutMode===`stacked`)return;let t=Math.max(0,Math.min(this.currentIndex+e,this.data.files.length-1));t!==this.currentIndex&&(this.currentIndex=t,this.activeFilePath=this.data.files[t]?.path??null,this.scrollContainer?.scrollTo({top:0,behavior:`auto`}),this.loadCurrentFile())}renderLoading(e=`Loading git diff...`){this.isActive&&(this.page?.classList.remove(`hidden`),this.content&&(this.content.innerHTML=`<div class="diff-empty-state">${b(e)}</div>`),this.data=null,this.syncToolbar())}renderEmpty(e){this.isActive&&(this.page?.classList.remove(`hidden`),this.content&&(this.content.innerHTML=`<div class="diff-empty-state">${b(e)}</div>`),this.syncToolbar())}renderUnifiedHunk(e){let t=[];for(let n of jc(e.lines)){if(n.context.length>0){for(let e of n.context)t.push(Mc(e,` `,b(e.content)));continue}let e=Math.max(n.deletions.length,n.additions.length);for(let r=0;r<e;r+=1){let e=n.deletions[r]??null,i=n.additions[r]??null,a=e&&i?Ac(e.content,i.content):null;e&&t.push(Mc(e,`-`,a?.leftHtml??b(e.content))),i&&t.push(Mc(i,`+`,a?.rightHtml??b(i.content)))}}return`
|
|
462
|
-
<div class="diff-hunk-header">${b(e.header)}</div>
|
|
463
|
-
${t.join(``)}
|
|
464
|
-
`}renderFileHeader(e){return`
|
|
465
|
-
<div class="diff-file-header">
|
|
466
|
-
<span class="diff-file-path">${b(e.path)}</span>
|
|
467
|
-
<span class="ui-status-badge ${Ec(e.status)}">${b(e.status)}</span>
|
|
468
|
-
<span class="diff-file-header-stats"><span class="ui-stat-token ui-stat-token--add diff-stats-add">+${e.stats?.additions??0}</span><span class="ui-stat-token ui-stat-token--del diff-stats-del">-${e.stats?.deletions??0}</span></span>
|
|
469
|
-
</div>
|
|
470
|
-
`}renderUnifiedFileBody(e){return`
|
|
471
|
-
${e.isBinary?`<div class="diff-binary-message">${b(e.binaryMessage||`Binary file changed`)}</div>`:``}
|
|
472
|
-
${e.hunks.map(e=>this.renderUnifiedHunk(e)).join(``)}
|
|
473
|
-
`}renderSplitFileBody(e){return`
|
|
474
|
-
<div class="diff-split">
|
|
475
|
-
<div class="diff-split-pane">
|
|
476
|
-
<div class="diff-split-pane-header">Before</div>
|
|
477
|
-
${e.hunks.map(e=>{let t=[];for(let n of jc(e.lines)){if(n.context.length>0){for(let e of n.context)t.push(Nc(e,e));continue}let e=Math.max(n.deletions.length,n.additions.length);for(let r=0;r<e;r+=1)t.push(Nc(n.deletions[r]??null,n.additions[r]??null))}return`
|
|
478
|
-
<div class="diff-split-hunk">${b(e.header)}</div>
|
|
479
|
-
${t.join(``)}
|
|
480
|
-
`}).join(``)}
|
|
481
|
-
</div>
|
|
482
|
-
</div>
|
|
483
|
-
`}renderDiffDetail(e,t,{includeHeader:n=!0}={}){if(!e)return`<div class="diff-empty-state">Select a file to load its diff.</div>`;if(e.tooLarge)return`
|
|
484
|
-
${n?this.renderFileHeader(e):``}
|
|
485
|
-
<div class="diff-limit-card">
|
|
486
|
-
<strong>Large diff withheld</strong>
|
|
487
|
-
<span>This file diff is large enough to impact rendering performance.</span>
|
|
488
|
-
<button class="${G({variant:`secondary`,extra:`diff-load-full-btn`})}" type="button" data-load-full-diff data-diff-file-path="${b(e.path)}">Load full diff</button>
|
|
489
|
-
</div>
|
|
490
|
-
`;let r=this.mode===`split`?this.renderSplitFileBody(e,t):this.renderUnifiedFileBody(e,t);return`${n?this.renderFileHeader(e):``}${r}`}renderFocusedFileBody(){let e=this.getCurrentFile();if(!e)return`<div class="diff-empty-state">No changes to display.</div>`;if(this.isFileLoading(e.path))return`
|
|
491
|
-
<section class="diff-file-block">
|
|
492
|
-
${this.renderFileHeader(e)}
|
|
493
|
-
<div class="diff-empty-state">Loading file diff...</div>
|
|
494
|
-
</section>
|
|
495
|
-
`;let t=this.fileErrors.get(e.path);return t?`
|
|
496
|
-
<section class="diff-file-block">
|
|
497
|
-
${this.renderFileHeader(e)}
|
|
498
|
-
<div class="diff-empty-state">${b(t)}</div>
|
|
499
|
-
</section>
|
|
500
|
-
`:`
|
|
501
|
-
<section class="diff-file-block" data-diff-file-index="${this.currentIndex}">
|
|
502
|
-
${this.renderDiffDetail(this.getFileDetail(e.path)??e,this.currentIndex)}
|
|
503
|
-
</section>
|
|
504
|
-
`}renderCommitHeader(){return this.source!==`commit`||!this.commitMeta?``:`
|
|
505
|
-
<section class="diff-commit-header">
|
|
506
|
-
<div class="diff-commit-subject">${b(this.commitMeta.subject||this.commitMeta.shortHash||`Commit`)}</div>
|
|
507
|
-
<div class="diff-commit-meta">
|
|
508
|
-
<span>${b(this.commitMeta.shortHash||``)}</span>
|
|
509
|
-
<span>${b(this.commitMeta.authorName||`Unknown`)}</span>
|
|
510
|
-
<span title="${b(this.commitMeta.authoredAt||``)}">${b(this.commitMeta.relativeDateLabel||``)}</span>
|
|
511
|
-
${this.commitMeta.isMergeCommit?`<span>Merge commit</span>`:``}
|
|
512
|
-
</div>
|
|
513
|
-
<div class="diff-commit-meta diff-commit-meta-secondary">
|
|
514
|
-
<span>${b(this.commitMeta.hash||``)}</span>
|
|
515
|
-
<span>${Number(this.data?.summary?.filesChanged||0)} file${Number(this.data?.summary?.filesChanged||0)===1?``:`s`}</span>
|
|
516
|
-
</div>
|
|
517
|
-
</section>
|
|
518
|
-
`}renderCommitIndex(){return`
|
|
519
|
-
<aside class="diff-commit-index" aria-label="Changed files in commit">
|
|
520
|
-
<div class="diff-commit-index-header">Changed Files</div>
|
|
521
|
-
<div class="diff-commit-index-list">
|
|
522
|
-
${(this.data?.files??[]).map((e,t)=>{let n=this.activeFilePath===e.path,r=wc(e.path);return`
|
|
523
|
-
<button
|
|
524
|
-
class="ui-record-surface diff-index-item${n?` active`:``}"
|
|
525
|
-
type="button"
|
|
526
|
-
data-diff-index-path="${b(e.path)}"
|
|
527
|
-
aria-current="${n?`true`:`false`}"
|
|
528
|
-
>
|
|
529
|
-
<span class="ui-record-header diff-index-item-top">
|
|
530
|
-
<span class="ui-record-title diff-index-item-name">${b(Cc(e.path))}</span>
|
|
531
|
-
<span class="ui-status-badge ${Ec(e.status)}">${b(e.status)}</span>
|
|
532
|
-
</span>
|
|
533
|
-
${r?`<span class="ui-record-subtitle diff-index-item-path">${b(r)}</span>`:``}
|
|
534
|
-
<span class="ui-record-meta diff-index-item-meta">
|
|
535
|
-
<span>${t+1}</span>
|
|
536
|
-
<span class="ui-stat-token ui-stat-token--add diff-stats-add">+${e.stats?.additions??0}</span>
|
|
537
|
-
<span class="ui-stat-token ui-stat-token--del diff-stats-del">-${e.stats?.deletions??0}</span>
|
|
538
|
-
</span>
|
|
539
|
-
</button>
|
|
540
|
-
`}).join(``)}
|
|
541
|
-
</div>
|
|
542
|
-
</aside>
|
|
543
|
-
`}renderStackedSection(e,t){let n=this.isFileCollapsed(e.path),r=this.activeFilePath===e.path,i=this.isFileLoading(e.path),a=this.fileErrors.get(e.path),o=this.getFileDetail(e.path)??e,s=n?``:i?`<div class="diff-empty-state">Loading file diff...</div>`:a?`<div class="diff-empty-state">${b(a)}</div>`:this.renderDiffDetail(o,t,{includeHeader:!1});return`
|
|
544
|
-
<section
|
|
545
|
-
class="diff-commit-section${r?` active`:``}${n?` collapsed`:``}"
|
|
546
|
-
id="${Tc(e.path)}"
|
|
547
|
-
data-diff-section-path="${b(e.path)}"
|
|
548
|
-
>
|
|
549
|
-
<button
|
|
550
|
-
class="diff-commit-section-header"
|
|
551
|
-
type="button"
|
|
552
|
-
data-diff-section-toggle="${b(e.path)}"
|
|
553
|
-
>
|
|
554
|
-
<span class="diff-commit-section-main">
|
|
555
|
-
${Dc(n)}
|
|
556
|
-
<span class="diff-commit-section-copy">
|
|
557
|
-
<span class="diff-commit-section-name">${b(Cc(e.path))}</span>
|
|
558
|
-
${wc(e.path)?`<span class="diff-commit-section-path">${b(wc(e.path))}</span>`:``}
|
|
559
|
-
</span>
|
|
560
|
-
</span>
|
|
561
|
-
<span class="diff-commit-section-meta">
|
|
562
|
-
<span class="ui-status-badge ${Ec(e.status)}">${b(e.status)}</span>
|
|
563
|
-
<span class="ui-stat-token ui-stat-token--add diff-stats-add">+${e.stats?.additions??0}</span>
|
|
564
|
-
<span class="ui-stat-token ui-stat-token--del diff-stats-del">-${e.stats?.deletions??0}</span>
|
|
565
|
-
</span>
|
|
566
|
-
</button>
|
|
567
|
-
<div class="diff-commit-section-body${n?` hidden`:``}">
|
|
568
|
-
${s}
|
|
569
|
-
</div>
|
|
570
|
-
</section>
|
|
571
|
-
`}renderCommitBody(){return this.layoutMode===`focused`?`
|
|
572
|
-
<div class="diff-commit-shell diff-commit-shell-focused">
|
|
573
|
-
${this.renderCommitIndex()}
|
|
574
|
-
<div class="diff-commit-main">
|
|
575
|
-
${this.renderFocusedFileBody()}
|
|
576
|
-
</div>
|
|
577
|
-
</div>
|
|
578
|
-
`:`
|
|
579
|
-
<div class="diff-commit-shell diff-commit-shell-stacked">
|
|
580
|
-
${this.renderCommitIndex()}
|
|
581
|
-
<div class="diff-commit-main">
|
|
582
|
-
<div class="diff-commit-sections">
|
|
583
|
-
${(this.data?.files??[]).map((e,t)=>this.renderStackedSection(e,t)).join(``)}
|
|
584
|
-
</div>
|
|
585
|
-
</div>
|
|
586
|
-
</div>
|
|
587
|
-
`}getCurrentFile(){let e=this.data?.files??[];return e.length===0?null:e[this.currentIndex]??e[0]??null}getFileByPath(e){return(this.data?.files??[]).find(t=>t.path===e)??null}setActiveFilePath(e,{syncIndex:t=!0}={}){if(this.activeFilePath=e,!t)return;let n=Math.max(0,(this.data?.files??[]).findIndex(t=>t.path===e));n>=0&&(this.currentIndex=n)}getCacheKeyForPath(e){return e?this.source===`commit`?`commit:${this.commitHash}:${e}`:`workspace:${this.requestScope}:${e}`:null}getCurrentCacheKey(){return this.getCacheKeyForPath(this.getCurrentFile()?.path??null)}getCurrentFileDetail(){let e=this.getCurrentCacheKey();return e?this.fileCache.get(e):null}getFileDetail(e){let t=this.getCacheKeyForPath(e);return t?this.fileCache.get(t):null}isFileCollapsed(e){return this.collapsedFiles.has(e)}isFileLoading(e){return this.loadingFiles.has(e)}getCurrentActionState(){if(this.source===`commit`)return{canCommit:!1,canStage:!1,canUnstage:!1};let e=this.getCurrentFile(),t=this.getCurrentFileDetail()??e,n=Number(this.repoStatus?.summary?.staged||0);return t?.path?{canCommit:n>0,canStage:!!(t.hasWorkingTreeChanges||t.hasUntrackedChanges),canUnstage:!!t.hasStagedChanges}:{canCommit:n>0,canStage:!1,canUnstage:!1}}getPrimaryAction(){if(this.source===`commit`)return null;let e=this.getCurrentActionState();return e.canStage&&!e.canUnstage?`stage`:e.canUnstage&&!e.canStage||this.requestScope===`staged`&&e.canUnstage?`unstage`:e.canStage?`stage`:e.canUnstage?`unstage`:null}async handleFileAction(e){if(this.source===`commit`)return;let t=this.getCurrentFile();if(!(!t?.path||this.pendingAction)){this.pendingAction=e,this.syncToolbar();try{e===`stage`?await this.onStageFile?.(t.path,{scope:this.requestScope}):e===`unstage`?await this.onUnstageFile?.(t.path,{scope:this.requestScope}):e===`commit`&&await this.onCommitStaged?.()}finally{this.pendingAction=null,this.syncToolbar()}}}setRepoStatus(e){this.repoStatus=e,this.syncToolbar()}async handleIndexSelection(e){if(this.getFileByPath(e)){if(this.setActiveFilePath(e),this.source===`commit`&&this.layoutMode===`stacked`){this.collapsedFiles.delete(e),await this.loadFileForPath(e,{render:!1}),this.render(),this.scrollToFileSection(e);return}await this.loadFileForPath(e)}}async toggleFileSection(e){if(!(this.source!==`commit`||this.layoutMode!==`stacked`)){if(this.setActiveFilePath(e),this.collapsedFiles.has(e)){this.collapsedFiles.delete(e),await this.loadFileForPath(e,{render:!1}),this.render(),this.scrollToFileSection(e);return}this.collapsedFiles.add(e),this.render()}}scrollToFileSection(e){if(!this.content)return;let t=Tc(e),n=()=>{let e=document.getElementById?.(t)??null;if(e){if(this.scrollContainer?.scrollTo&&this.scrollContainer.getBoundingClientRect&&e.getBoundingClientRect){let t=this.scrollContainer.getBoundingClientRect(),n=e.getBoundingClientRect(),r=Number(this.scrollContainer.scrollTop)||0,i=Math.max(0,r+(n.top-t.top)-8);this.scrollContainer.scrollTo({top:i,behavior:`smooth`});return}e.scrollIntoView?.({behavior:`smooth`,block:`start`})}};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(n);return}setTimeout(n,0)}handleScrollSelection(){if(this.source!==`commit`||this.layoutMode!==`stacked`||!this.scrollContainer||!this.content)return;let e=Array.from(this.content.querySelectorAll?.(`[data-diff-section-path]`)??[]);if(e.length===0)return;let t=this.scrollContainer.getBoundingClientRect?.();if(!t)return;let n=t.top+120,r=null;for(let t of e){let e=t.getBoundingClientRect?.();if(!e)continue;let i=t.getAttribute?.(`data-diff-section-path`);if(i)if(e.top<=n)r=i;else if(r)break;else{r=i;break}}r&&r!==this.activeFilePath&&(this.setActiveFilePath(r),this.render())}async loadCurrentFile({forceFullPatch:e=!1}={}){let t=this.getCurrentFile();return t?.path?this.loadFileForPath(t.path,{forceFullPatch:e}):(this.render(),null)}async loadFileForPath(e,{forceFullPatch:t=!1,render:n=!0}={}){let r=this.getFileByPath(e);if(!r?.path)return n&&this.render(),null;this.setActiveFilePath(e);let i=this.getCacheKeyForPath(e),a=i?this.fileCache.get(i):null;if(a&&(!a.tooLarge||!t))return n&&this.render(),a;let o=`${e}:${t?`full`:`partial`}`;if(this.fileLoadPromises.has(o))return this.fileLoadPromises.get(o);this.loadingFiles.add(e),this.fileErrors.delete(e),n&&this.render();let s=(async()=>{try{let n;if(this.source===`commit`){let i=await this.gitApiClient.readCommit({allowLargePatch:t,hash:this.commitHash||``,path:e});n={...r,...i.files?.[0]??{}}}else{let i=await this.gitApiClient.readDiff({allowLargePatch:t,path:e,scope:this.requestScope});n={...r,...i.files?.[0]??{}}}return i&&this.fileCache.set(i,n),this.fileErrors.delete(e),n}catch(t){console.error(`[git-diff] Failed to load file diff:`,t);let n=this.source===`commit`?`Failed to load commit file diff`:`Failed to load file diff`;return this.fileErrors.set(e,n),this.toastController?.show(n),null}finally{this.loadingFiles.delete(e),this.fileLoadPromises.delete(o),this.render()}})();return this.fileLoadPromises.set(o,s),s}syncToolbar(){let e=this.data?.files?.length??0,t=e===0?0:this.currentIndex+1,n=this.source===`commit`,r=n&&this.layoutMode===`stacked`;if(this.fileIndicator&&(r?this.fileIndicator.textContent=`${e} file${e===1?``:`s`}`:this.fileIndicator.textContent=e>0?`${t} / ${e} files`:`0 / 0 files`),this.stats){let e=this.data?.summary?.additions??0,t=this.data?.summary?.deletions??0;this.stats.innerHTML=`
|
|
588
|
-
<span class="ui-stat-token ui-stat-token--add diff-stats-add">+${e}</span>
|
|
589
|
-
<span class="ui-stat-token ui-stat-token--del diff-stats-del">-${t}</span>
|
|
590
|
-
`}this.modeButtons.forEach(e=>{e.classList.remove(`hidden`),e.classList.toggle(`active`,e.getAttribute(`data-diff-mode`)===this.mode)}),this.layoutButtons.forEach(e=>{e.classList.toggle(`active`,e.getAttribute(`data-diff-layout`)===this.layoutMode)});let i=!!this.getCurrentFile()?.path,a=this.getCurrentActionState(),o=this.getPrimaryAction();this.backToHistoryButton?.classList.toggle(`hidden`,!n),this.gitActionsGroup?.classList.toggle(`hidden`,n),this.editorActionsGroup?.classList.toggle(`hidden`,n),this.actionsDivider?.classList.toggle(`hidden`,n),this.layoutToggle?.classList.toggle(`hidden`,!n),this.stats?.classList.remove(`hidden`),this.openEditorButton&&(this.openEditorButton.textContent=`Open in Editor`),this.openEditorButton?.toggleAttribute(`disabled`,!i||n),this.primaryActionButton&&(this.primaryActionButton.textContent=this.pendingAction===o?`Working...`:o===`unstage`?`Unstage`:`Stage`,this.primaryActionButton.toggleAttribute(`disabled`,n||!i||!o||!!this.pendingAction)),this.commitButton&&(this.commitButton.textContent=this.pendingAction===`commit`?`Working...`:`Commit Staged`),this.commitButton?.toggleAttribute(`disabled`,n||!a.canCommit||!!this.pendingAction),this.prevButton?.classList.remove(`hidden`),this.nextButton?.classList.remove(`hidden`),this.prevButton?.classList.toggle(`hidden`,r),this.nextButton?.classList.toggle(`hidden`,r),this.prevButton?.toggleAttribute(`disabled`,r||this.currentIndex<=0),this.nextButton?.toggleAttribute(`disabled`,r||e===0||this.currentIndex>=e-1)}render(){if(this.isActive){if(this.page?.classList.remove(`hidden`),(this.data?.files??[]).length===0){this.renderEmpty(this.source===`commit`?`No commit changes to display.`:`No changes to display.`);return}this.content&&(this.source===`commit`?this.content.innerHTML=`${this.renderCommitHeader()}${this.renderCommitBody()}`:this.content.innerHTML=this.renderFocusedFileBody(),this.syncToolbar())}}getToolbarTitle({commitHash:e=null,filePath:t=null,path:n=null,scope:r=`all`,source:i=`workspace`}={}){return i===`commit`||this.source===`commit`?this.layoutMode===`stacked`?this.commitMeta?.shortHash?`Commit ${this.commitMeta.shortHash}`:e?`Commit ${String(e).slice(0,7)}`:`Commit Diff`:n?Cc(n):this.activeFilePath?Cc(this.activeFilePath):this.commitMeta?.shortHash?`Commit ${this.commitMeta.shortHash}`:e?`Commit ${String(e).slice(0,7)}`:`Commit Diff`:t?Cc(t):r===`staged`?`Staged Changes`:r===`working-tree`?`Working Tree Changes`:`All Changes`}},Fc=30,Ic=1e4;function Lc(e){let t=String(e??``).split(`/`);return t.pop(),t.join(`/`)}function Rc(e){return String(e??``).split(`/`).pop()||``}function zc(){return`<svg class="git-file-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`}function Bc(){return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="18" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><path d="M13 6h3a2 2 0 0 1 2 2v7"/><path d="M6 9v12"/></svg>`}function Vc(e){return`<svg class="git-section-chevron${e?` collapsed`:``}" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>`}function Hc(e){switch(e){case`commit`:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`;case`pull`:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="m18 13-6 6-6-6"/></svg>`;case`push`:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m6 11 6-6 6 6"/></svg>`;case`unstage`:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 12H8"/><path d="m12 16-4-4 4-4"/></svg>`;case`reset`:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 3-6.7"/><path d="M3 4v5h5"/></svg>`;default:return`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`}}function Uc(e){switch(e){case`added`:return`ui-status-badge--success`;case`deleted`:return`ui-status-badge--danger`;case`renamed`:return`ui-status-badge--accent`;case`untracked`:return`ui-status-badge--muted`;default:return`ui-status-badge--warning`}}function Wc(e={},t={}){let n=Number(e.additions||0),r=Number(e.deletions||0);return Number(e.changedFiles||0)>0||n>0||r>0?`
|
|
591
|
-
<span class="git-change-stats" aria-label="Local diff summary">
|
|
592
|
-
<span class="git-change-add">+${n}</span>
|
|
593
|
-
<span class="git-change-del">-${r}</span>
|
|
594
|
-
</span>
|
|
595
|
-
`:t.upstream||Number(t.ahead||0)>0||Number(t.behind||0)>0?`
|
|
596
|
-
<span class="git-sync-info" aria-label="Remote sync status">
|
|
597
|
-
<span class="git-sync-metric git-sync-metric--ahead">↑${Number(t.ahead||0)}</span>
|
|
598
|
-
<span class="git-sync-metric git-sync-metric--behind">↓${Number(t.behind||0)}</span>
|
|
599
|
-
</span>
|
|
600
|
-
`:`<span class="git-sync-info git-sync-info-muted">Clean</span>`}function Gc(e={}){return b(String(e.subject||``).trim()||e.shortHash||`Commit`)}var Kc=class{constructor({enabled:e=!0,gitApiClient:t=null,onCommitStaged:n=()=>{},onOpenPullBackup:r=()=>{},onPullBranch:i=()=>{},onPushBranch:a=()=>{},onRepoChange:o=()=>{},onResetFile:s=()=>{},onSelectCommit:c=()=>{},onSelectDiff:l=()=>{},onStageFile:u=()=>{},onUnstageFile:d=()=>{},onViewAllDiff:f=()=>{},searchInput:p=null,toastController:m=null}={}){this.enabled=e,this.gitApiClient=t,this.onCommitStaged=n,this.onOpenPullBackup=r,this.onPullBranch=i,this.onPushBranch=a,this.onRepoChange=o,this.onResetFile=s,this.onSelectCommit=c,this.onSelectDiff=l,this.onStageFile=u,this.onUnstageFile=d,this.onViewAllDiff=f,this.searchInput=p,this.toastController=m,this.panel=document.getElementById(`gitPanel`),this.pullBackups=[],this.status=null,this.active=!1,this.refreshTimer=null,this.searchQuery=``,this.panelMode=`changes`,this.collapsedSections=new Set,this.selection={commitHash:null,path:null,scope:null,source:`workspace`},this.pendingActionKey=null,this.history={commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0}}_handlePanelModeClick(e){let t=e.target instanceof Element?e.target.closest(`[data-git-panel-mode]`):null;if(t){let e=t.getAttribute(`data-git-panel-mode`);return(e===`changes`||e===`history`)&&this.setMode(e),!0}return!1}_handleSectionToggleClick(e){let t=e.target instanceof Element?e.target.closest(`[data-git-section-toggle]`):null;return t?(this.toggleSection(t.getAttribute(`data-git-section-toggle`)),!0):!1}_handleCommitHistoryClick(e){let t=e.target instanceof Element?e.target.closest(`[data-git-commit-hash]`):null;if(t&&!e.target.closest(`[data-git-history-load-more]`)){let e=t.getAttribute(`data-git-commit-hash`);return e&&this.onSelectCommit(e,{path:this.selection.commitHash===e?this.selection.path:null}),!0}return!1}_handleFileSelectionClick(e){let t=e.target instanceof Element?e.target.closest(`[data-git-path]`):null;if(t&&!e.target.closest(`[data-git-file-action]`)){let e=t.getAttribute(`data-git-path`);return e&&this.onSelectDiff(e,{scope:t.getAttribute(`data-git-scope`)||`working-tree`}),!0}return!1}_handleFileActionClick(e){let t=e.target instanceof Element?e.target.closest(`[data-git-file-action]`):null;if(t){let n=t.getAttribute(`data-git-file-action`),r=t.getAttribute(`data-git-path`);return n&&r&&(e.preventDefault(),e.stopPropagation(),this.handleFileAction(n,r,t.getAttribute(`data-git-scope`)||`working-tree`)),!0}return!1}_handlePanelClick(e){if(this._handlePanelModeClick(e)||this._handleSectionToggleClick(e)||this._handleCommitHistoryClick(e))return;if(e.target instanceof Element&&e.target.closest(`[data-git-history-load-more]`)){this.loadMoreHistory();return}if(this._handleFileSelectionClick(e))return;let t=e.target instanceof Element?e.target.closest(`[data-git-pull-backup-path]`):null;if(t){let e=t.getAttribute(`data-git-pull-backup-path`);e&&this.onOpenPullBackup(e);return}if(this._handleFileActionClick(e))return;if(e.target instanceof Element&&e.target.closest(`[data-git-view-all]`)){this.onViewAllDiff();return}if(e.target instanceof Element&&e.target.closest(`[data-git-commit-staged]`)){this.handleCommitStaged();return}let n=e.target instanceof Element?e.target.closest(`[data-git-sync-action]`):null;if(n){let e=n.getAttribute(`data-git-sync-action`);(e===`pull`||e===`push`)&&this.handleSyncAction(e)}}initialize(){this.panel?.addEventListener(`click`,e=>{this._handlePanelClick(e)}),this.searchInput?.addEventListener(`input`,e=>{this.searchQuery=String(e.target?.value??``).trim().toLowerCase(),this.render()}),this.syncSearchUi()}setActive(e){let t=!!e;if(!(this.active===t&&(!t||this.refreshTimer||this.panelMode===`history`))){if(this.active=t,!this.active){this.stopStatusPolling();return}this.syncSearchUi(),this.refresh({force:!1,includeHistory:this.panelMode===`history`}),this.panelMode===`changes`?this.ensureStatusPolling():this.stopStatusPolling()}}async setMode(e,{forceHistoryRefresh:t=!1}={}){let n=e===`history`?`history`:`changes`,r=this.panelMode!==n;if(this.panelMode=n,this.syncSearchUi(),this.render(),this.active){if(this.panelMode===`changes`){this.ensureStatusPolling(),r&&await this.refresh({force:!1,includeHistory:!1});return}this.stopStatusPolling(),(t||r||!this.history.loaded)&&await this.refreshHistory({force:t||r})}}setSelection({commitHash:e=null,path:t=null,scope:n=null,source:r=`workspace`}={}){this.selection={commitHash:e,path:t,scope:n,source:r},(r===`commit`||e)&&(this.panelMode=`history`,this.syncSearchUi()),this.render()}toggleSection(e){e&&(this.collapsedSections.has(e)?this.collapsedSections.delete(e):this.collapsedSections.add(e),this.render())}ensureStatusPolling(){this.refreshTimer||!this.active||this.panelMode!==`changes`||(this.refreshTimer=setInterval(()=>{this.refresh({force:!1,includeHistory:!1})},Ic))}stopStatusPolling(){clearInterval(this.refreshTimer),this.refreshTimer=null}syncSearchUi(){this.searchInput&&(this.searchInput.setAttribute(`placeholder`,this.panelMode===`history`?`Filter loaded commits...`:`Search changes...`),this.searchInput.setAttribute(`aria-label`,this.panelMode===`history`?`Filter loaded commits`:`Search changed files`))}async refresh({force:e=!1,includeHistory:t=this.panelMode===`history`}={}){let n=await this.refreshStatus({force:e});return t&&n.isGitRepo&&await this.refreshHistory({force:e}),n}async refreshStatus({force:e=!1}={}){if(!this.enabled)return this.status={isGitRepo:!1,sections:[],summary:{changedFiles:0}},this.pullBackups=[],this.history={...this.history,commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0},this.onRepoChange(!1,this.status),this.render(),this.status;try{let t=await this.gitApiClient.readStatus({force:e});if(this.status=t,this.pullBackups=[],t.isGitRepo)try{let e=await this.gitApiClient.readPullBackups();this.pullBackups=Array.isArray(e.backups)?e.backups:[]}catch(e){console.error(`[git-panel] Failed to load pull backups:`,e)}else this.history={...this.history,commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0};return this.onRepoChange(!!t.isGitRepo,t),this.render(),t}catch(e){return console.error(`[git-panel] Failed to load git status:`,e),this.toastController?.show(`Failed to load git status`),this.status={isGitRepo:!1,sections:[],summary:{changedFiles:0}},this.pullBackups=[],this.history={...this.history,commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0},this.onRepoChange(!1,this.status),this.render(),this.status}}async refreshHistory({force:e=!1}={}){if(!this.status?.isGitRepo)return this.history={...this.history,commits:[],error:``,hasMore:!1,loaded:!1,loading:!1,loadingMore:!1,offset:0},this.render(),this.history;if(this.history.loading&&!e)return this.history;this.history={...this.history,error:``,loading:!0,loadingMore:!1},e&&(this.history={...this.history,commits:[],hasMore:!1,loaded:!1,offset:0}),this.render();try{let e=await this.gitApiClient.readHistory({limit:Fc,offset:0});return this.history={commits:Array.isArray(e.commits)?e.commits:[],error:``,hasMore:!!e.hasMore,loaded:!0,loading:!1,loadingMore:!1,offset:Array.isArray(e.commits)?e.commits.length:0},this.render(),this.history}catch(e){return console.error(`[git-panel] Failed to load git history:`,e),this.toastController?.show(`Failed to load git history`),this.history={...this.history,error:`Failed to load git history`,loading:!1,loadingMore:!1},this.render(),this.history}}async loadMoreHistory(){if(!(!this.status?.isGitRepo||this.history.loading||this.history.loadingMore||!this.history.hasMore)){this.history={...this.history,error:``,loadingMore:!0},this.render();try{let e=await this.gitApiClient.readHistory({limit:Fc,offset:this.history.offset}),t=Array.isArray(e.commits)?e.commits:[];this.history={commits:[...this.history.commits,...t],error:``,hasMore:!!e.hasMore,loaded:!0,loading:!1,loadingMore:!1,offset:this.history.offset+t.length},this.render()}catch(e){console.error(`[git-panel] Failed to load more git history:`,e),this.toastController?.show(`Failed to load git history`),this.history={...this.history,error:`Failed to load git history`,loadingMore:!1},this.render()}}}filterFiles(e=[]){return this.searchQuery?e.filter(e=>e.path.toLowerCase().includes(this.searchQuery)||String(e.oldPath||``).toLowerCase().includes(this.searchQuery)):e}filterCommits(e=[]){return this.searchQuery?e.filter(e=>String(e.subject||``).toLowerCase().includes(this.searchQuery)||String(e.shortHash||``).toLowerCase().includes(this.searchQuery)||String(e.authorName||``).toLowerCase().includes(this.searchQuery)):e}async handleFileAction(e,t,n){let r=`${e}:${n}:${t}`;if(this.pendingActionKey!==r){this.pendingActionKey=r,this.render();try{e===`stage`?await this.onStageFile(t,{scope:n}):e===`unstage`?await this.onUnstageFile(t,{scope:n}):e===`reset`&&await this.onResetFile(t,{scope:n})}finally{this.pendingActionKey=null,this.render()}}}async handleCommitStaged(){let e=`commit-staged`;if(this.pendingActionKey!==e){this.pendingActionKey=e,this.render();try{await this.onCommitStaged()}finally{this.pendingActionKey=null,this.render()}}}async handleSyncAction(e){let t=`sync:${e}`;if(this.pendingActionKey!==t){this.pendingActionKey=t,this.render();try{e===`pull`?await this.onPullBranch():e===`push`&&await this.onPushBranch()}finally{this.pendingActionKey=null,this.render()}}}renderSection(e){let t=this.filterFiles(e.files);if(t.length===0)return``;let n=this.collapsedSections.has(e.key);return`
|
|
601
|
-
<section class="git-section">
|
|
602
|
-
<button class="git-section-header" type="button" data-git-section-toggle="${b(e.key)}">
|
|
603
|
-
${Vc(n)}
|
|
604
|
-
${b(e.label)}
|
|
605
|
-
<span class="ui-pill-badge ui-pill-badge--count ui-pill-badge--muted git-section-count">${t.length}</span>
|
|
606
|
-
</button>
|
|
607
|
-
<div class="git-file-list${n?` hidden`:``}">
|
|
608
|
-
${t.map(e=>this.renderFile(e)).join(``)}
|
|
609
|
-
</div>
|
|
610
|
-
</section>
|
|
611
|
-
`}renderPullBackupsSection(){return!Array.isArray(this.pullBackups)||this.pullBackups.length===0?``:`
|
|
612
|
-
<section class="git-section">
|
|
613
|
-
<button class="git-section-header" type="button" data-git-section-toggle="pull-backups">
|
|
614
|
-
${Vc(this.collapsedSections.has(`pull-backups`))}
|
|
615
|
-
Pull Backups
|
|
616
|
-
<span class="ui-pill-badge ui-pill-badge--count ui-pill-badge--muted git-section-count">${this.pullBackups.length}</span>
|
|
617
|
-
</button>
|
|
618
|
-
<div class="git-file-list${this.collapsedSections.has(`pull-backups`)?` hidden`:``}">
|
|
619
|
-
${this.pullBackups.map(e=>this.renderPullBackup(e)).join(``)}
|
|
620
|
-
</div>
|
|
621
|
-
</section>
|
|
622
|
-
`}renderPullBackup(e){let t=String(e?.createdAt||``).replace(`T`,` `).replace(/\.\d+Z?$/u,`Z`),n=Number(e?.fileCount||0);return`
|
|
623
|
-
<div class="ui-item-row git-file-row">
|
|
624
|
-
<button
|
|
625
|
-
class="ui-item-main git-file-item"
|
|
626
|
-
type="button"
|
|
627
|
-
data-git-pull-backup-path="${b(e.summaryPath||``)}"
|
|
628
|
-
>
|
|
629
|
-
${zc()}
|
|
630
|
-
<span class="ui-item-copy git-file-copy">
|
|
631
|
-
<span class="ui-item-title git-file-name">Pull backup ${b(e.id||``)}</span>
|
|
632
|
-
<span class="ui-item-subtitle git-file-path">${b(`${t} · ${e.branch||`HEAD`} · ${n} file${n===1?``:`s`}`)}</span>
|
|
633
|
-
</span>
|
|
634
|
-
<span class="ui-status-badge ui-status-badge--warning">BK</span>
|
|
635
|
-
</button>
|
|
636
|
-
</div>
|
|
637
|
-
`}renderFile(e){let t=this.selection.source===`workspace`&&this.selection.path===e.path&&this.selection.scope===e.scope,n=Lc(e.path),r=Rc(e.path),i=String(e.path||``),a=Uc(e.status),o=e.scope===`staged`?{label:`Unstage`,value:`unstage`}:{label:`Stage`,value:`stage`},s=`${o.value}:${e.scope}:${e.path}`,c=this.pendingActionKey===s,l=`reset:${e.scope}:${e.path}`,u=this.pendingActionKey===l;return`
|
|
638
|
-
<div class="ui-item-row git-file-row${t?` active`:``}">
|
|
639
|
-
<button
|
|
640
|
-
class="ui-item-main git-file-item${t?` active`:``}"
|
|
641
|
-
type="button"
|
|
642
|
-
data-git-path="${b(e.path)}"
|
|
643
|
-
data-git-scope="${b(e.scope)}"
|
|
644
|
-
title="${b(i)}"
|
|
645
|
-
>
|
|
646
|
-
${zc()}
|
|
647
|
-
<span class="ui-item-copy git-file-copy">
|
|
648
|
-
<span class="ui-item-title git-file-name">${b(r)}</span>
|
|
649
|
-
${n?`<span class="ui-item-subtitle git-file-path">${b(n)}</span>`:``}
|
|
650
|
-
</span>
|
|
651
|
-
<span class="ui-status-badge ${a}">${b(e.code)}</span>
|
|
652
|
-
</button>
|
|
653
|
-
<div class="ui-item-actions git-file-actions">
|
|
654
|
-
<button
|
|
655
|
-
class="ui-icon-button ui-action-icon ui-action-icon--surface"
|
|
656
|
-
type="button"
|
|
657
|
-
data-git-file-action="reset"
|
|
658
|
-
data-git-path="${b(e.path)}"
|
|
659
|
-
data-git-scope="${b(e.scope)}"
|
|
660
|
-
aria-label="Reset ${b(r)}"
|
|
661
|
-
title="Reset to current branch"
|
|
662
|
-
${u?`disabled`:``}
|
|
663
|
-
>
|
|
664
|
-
${u?`...`:Hc(`reset`)}
|
|
665
|
-
</button>
|
|
666
|
-
<button
|
|
667
|
-
class="ui-icon-button ui-action-icon ui-action-icon--surface"
|
|
668
|
-
type="button"
|
|
669
|
-
data-git-file-action="${o.value}"
|
|
670
|
-
data-git-path="${b(e.path)}"
|
|
671
|
-
data-git-scope="${b(e.scope)}"
|
|
672
|
-
aria-label="${b(o.label)} ${b(r)}"
|
|
673
|
-
title="${b(o.label)}"
|
|
674
|
-
${c?`disabled`:``}
|
|
675
|
-
>
|
|
676
|
-
${c?`...`:Hc(o.value)}
|
|
677
|
-
</button>
|
|
678
|
-
</div>
|
|
679
|
-
</div>
|
|
680
|
-
`}renderPanelModes(){return`
|
|
681
|
-
<div class="${Ii({pill:!0,extra:`git-panel-mode-switch`})}" role="tablist" aria-label="Git panel modes">
|
|
682
|
-
<button
|
|
683
|
-
class="${q({active:this.panelMode===`changes`,extra:`git-panel-mode-btn`})}"
|
|
684
|
-
type="button"
|
|
685
|
-
data-git-panel-mode="changes"
|
|
686
|
-
aria-selected="${this.panelMode===`changes`}"
|
|
687
|
-
>
|
|
688
|
-
Changes
|
|
689
|
-
</button>
|
|
690
|
-
<button
|
|
691
|
-
class="${q({active:this.panelMode===`history`,extra:`git-panel-mode-btn`})}"
|
|
692
|
-
type="button"
|
|
693
|
-
data-git-panel-mode="history"
|
|
694
|
-
aria-selected="${this.panelMode===`history`}"
|
|
695
|
-
>
|
|
696
|
-
History
|
|
697
|
-
</button>
|
|
698
|
-
</div>
|
|
699
|
-
`}renderHistoryRow(e){let t=this.selection.source===`commit`&&this.selection.commitHash===e.hash,n=Number(e.filesChanged||0);return`
|
|
700
|
-
<button
|
|
701
|
-
class="ui-record-surface git-history-row${t?` active`:``}"
|
|
702
|
-
type="button"
|
|
703
|
-
data-git-commit-hash="${b(e.hash||``)}"
|
|
704
|
-
title="${b(e.authoredAt||``)}"
|
|
705
|
-
>
|
|
706
|
-
<span class="ui-record-header git-history-row-top">
|
|
707
|
-
<span class="ui-record-title git-history-subject">${Gc(e)}</span>
|
|
708
|
-
<span class="ui-pill-badge ui-pill-badge--code git-history-hash">${b(e.shortHash||``)}</span>
|
|
709
|
-
</span>
|
|
710
|
-
<span class="ui-record-meta git-history-row-meta">
|
|
711
|
-
<span>${b(e.authorName||`Unknown`)}</span>
|
|
712
|
-
<span>${b(e.relativeDateLabel||``)}</span>
|
|
713
|
-
<span>${n} file${n===1?``:`s`}</span>
|
|
714
|
-
${e.isMergeCommit?`<span>Merge</span>`:``}
|
|
715
|
-
</span>
|
|
716
|
-
<span class="ui-record-meta git-history-row-stats">
|
|
717
|
-
<span class="git-change-add">+${Number(e.additions||0)}</span>
|
|
718
|
-
<span class="git-change-del">-${Number(e.deletions||0)}</span>
|
|
719
|
-
</span>
|
|
720
|
-
</button>
|
|
721
|
-
`}renderHistoryPanel(){let e=this.filterCommits(this.history.commits);return this.history.loading&&!this.history.loaded?`<div class="git-panel-empty">Loading git history...</div>`:this.history.error&&!this.history.loaded?`<div class="git-panel-empty">${b(this.history.error)}</div>`:this.history.loaded&&e.length===0&&this.history.commits.length===0?`<div class="git-panel-empty">No commits yet on this branch.</div>`:this.history.loaded&&e.length===0?`<div class="git-panel-empty">No loaded commits match your filter.</div>`:`
|
|
722
|
-
<div class="git-history-list">
|
|
723
|
-
${e.map(e=>this.renderHistoryRow(e)).join(``)}
|
|
724
|
-
</div>
|
|
725
|
-
${this.history.hasMore?`
|
|
726
|
-
<div class="git-history-footer">
|
|
727
|
-
<button
|
|
728
|
-
class="${G({variant:`secondary`,size:`compact`,action:!0,surface:!0,extra:`git-history-load-more`})}"
|
|
729
|
-
type="button"
|
|
730
|
-
data-git-history-load-more
|
|
731
|
-
${this.history.loadingMore?`disabled`:``}
|
|
732
|
-
>
|
|
733
|
-
${this.history.loadingMore?`Loading...`:`Load More`}
|
|
734
|
-
</button>
|
|
735
|
-
</div>
|
|
736
|
-
`:``}
|
|
737
|
-
`}renderChangesPanel(){let e=this.renderPullBackupsSection(),t=(this.status.sections??[]).map(e=>this.renderSection(e)).filter(Boolean).join(``),n=!!this.status.summary?.changedFiles,r=Number(this.status.summary?.staged||0)>0,i=this.pendingActionKey===`commit-staged`;return`
|
|
738
|
-
${e}
|
|
739
|
-
${t||`<div class="git-panel-empty">No local changes</div>`}
|
|
740
|
-
${n?`
|
|
741
|
-
<div class="git-panel-footer">
|
|
742
|
-
<div class="git-panel-footer-actions">
|
|
743
|
-
<button class="${G({variant:`secondary`,size:`compact`,action:!0,surface:!0})}" type="button" data-git-view-all>
|
|
744
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M2 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
|
|
745
|
-
View Full Diff
|
|
746
|
-
</button>
|
|
747
|
-
<button
|
|
748
|
-
class="${G({variant:`primary`,action:!0,wide:!0,extra:`git-footer-commit-btn`})}"
|
|
749
|
-
type="button"
|
|
750
|
-
data-git-commit-staged
|
|
751
|
-
${!r||i?`disabled`:``}
|
|
752
|
-
>
|
|
753
|
-
${i?`Working...`:`Commit Staged`}
|
|
754
|
-
</button>
|
|
755
|
-
</div>
|
|
756
|
-
</div>
|
|
757
|
-
`:``}
|
|
758
|
-
`}renderEmpty(e){this.panel&&(this.panel.innerHTML=`<div class="git-panel-empty">${b(e)}</div>`)}render(){if(!this.panel)return;if(!this.status){this.renderEmpty(`Loading git status...`);return}if(!this.status.isGitRepo){this.renderEmpty(`Git is unavailable for this vault.`);return}let e=this.status.branch??{},t=!!e.upstream,n=this.pendingActionKey===`sync:pull`,r=this.pendingActionKey===`sync:push`;this.panel.innerHTML=`
|
|
759
|
-
<div class="git-branch-bar">
|
|
760
|
-
<div class="git-branch-meta">
|
|
761
|
-
<span class="git-branch-name">
|
|
762
|
-
${Bc()}
|
|
763
|
-
${b(e.name||`HEAD`)}
|
|
764
|
-
</span>
|
|
765
|
-
${Wc(this.status.summary,e)}
|
|
766
|
-
</div>
|
|
767
|
-
<div class="git-branch-actions" role="group" aria-label="Remote sync actions">
|
|
768
|
-
<button
|
|
769
|
-
class="${G({variant:`secondary`,size:`compact`,pill:!0,surface:!0,extra:`ui-action-pill`})}"
|
|
770
|
-
type="button"
|
|
771
|
-
data-git-sync-action="pull"
|
|
772
|
-
title="${t?`Pull remote changes (fast-forward only)`:`No upstream branch configured`}"
|
|
773
|
-
aria-label="Pull branch"
|
|
774
|
-
${!t||n?`disabled`:``}
|
|
775
|
-
>
|
|
776
|
-
${n?`...`:`${Hc(`pull`)}<span>Pull</span>`}
|
|
777
|
-
</button>
|
|
778
|
-
<button
|
|
779
|
-
class="${G({variant:`secondary`,size:`compact`,pill:!0,surface:!0,extra:`ui-action-pill`})}"
|
|
780
|
-
type="button"
|
|
781
|
-
data-git-sync-action="push"
|
|
782
|
-
title="${t?`Push local commits`:`No upstream branch configured`}"
|
|
783
|
-
aria-label="Push branch"
|
|
784
|
-
${!t||r?`disabled`:``}
|
|
785
|
-
>
|
|
786
|
-
${r?`...`:`${Hc(`push`)}<span>Push</span>`}
|
|
787
|
-
</button>
|
|
788
|
-
</div>
|
|
789
|
-
${this.renderPanelModes()}
|
|
790
|
-
</div>
|
|
791
|
-
${this.panelMode===`history`?this.renderHistoryPanel():this.renderChangesPanel()}
|
|
792
|
-
`}},qc=class{constructor({mobileBreakpointQuery:e=window.matchMedia(`(max-width: 768px)`),onMeasureEditor:t,onViewRequest:n=null}){this.mobileBreakpointQuery=e,this.onMeasureEditor=t,this.onViewRequest=n,this.preferredView=`split`,this.mobileShowsEditor=!this.isMobileViewport(),this.currentView=this.mobileShowsEditor?this.preferredView:`preview`,this.editorLayout=document.getElementById(`editorLayout`),this.editorPane=document.getElementById(`editorPane`),this.previewPane=document.getElementById(`previewPane`),this.mobileToggleButton=document.getElementById(`mobileViewToggle`),this.resizer=document.getElementById(`resizer`),this.viewButtons=Array.from(document.querySelectorAll(`.view-btn`))}isMobileViewport(){return this.mobileBreakpointQuery.matches}initialize(){this.viewButtons.forEach(e=>{e.addEventListener(`click`,()=>{this.onViewRequest?.(e.dataset.view)!==!1&&this.setView(e.dataset.view)})}),this.mobileToggleButton?.addEventListener(`click`,()=>this.toggleMobileView()),this.initializeResizer(),this.restorePreferredView()}primeView(e){if(e){if(this.isMobileViewport()){this.mobileShowsEditor=e!==`preview`;return}this.preferredView=e}}reset(){this.restorePreferredView(),this.editorPane&&(this.editorPane.style.flex=``),this.previewPane&&(this.previewPane.style.flex=``),this.updateResizerValue()}restorePreferredView(){let e=this.isMobileViewport()?this.mobileShowsEditor?`split`:`preview`:this.preferredView;this.applyView(e),this.updateMobileToggleButton(this.mobileShowsEditor?`Preview`:`Editor`)}applyView(e){this.currentView=e,this.editorLayout?.setAttribute(`data-view`,e),this.syncViewButtons()}setView(e,{persist:t=!0}={}){e&&(t&&(this.preferredView=e),this.applyView(e),(e===`split`||e===`editor`)&&this.scheduleEditorMeasure())}toggleMobileView(){let e=!this.mobileShowsEditor,t=e?`split`:`preview`;this.onViewRequest?.(t)!==!1&&(this.mobileShowsEditor=e,this.applyView(t),this.updateMobileToggleButton(this.mobileShowsEditor?`Preview`:`Editor`),this.mobileShowsEditor&&this.scheduleEditorMeasure())}scheduleEditorMeasure(){this.onMeasureEditor&&setTimeout(()=>this.onMeasureEditor(),50)}updateMobileToggleButton(e){this.mobileToggleButton&&(this.mobileToggleButton.innerHTML=`${e===`Editor`?`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="8" y1="8" x2="16" y2="8"/><line x1="8" y1="12" x2="14" y2="12"/><line x1="8" y1="16" x2="12" y2="16"/></svg>`:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`}<span class="ui-toolbar-button-label">${e}</span>`)}syncViewButtons(){this.viewButtons.forEach(e=>{let t=e.dataset.view===this.currentView;e.classList.toggle(`active`,t),e.setAttribute(`aria-pressed`,String(t))})}updateResizerValue(){if(!this.resizer||!this.editorLayout||!this.editorPane)return;let e=this.editorLayout.offsetWidth;if(!Number.isFinite(e)||e<=0)return;let t=Math.round(this.editorPane.offsetWidth/e*100);this.resizer.setAttribute(`aria-valuenow`,String(Math.max(20,Math.min(80,t))))}applyEditorPaneWidth(e){if(!this.editorLayout||!this.editorPane||!this.previewPane)return;let t=this.editorLayout.offsetWidth;if(!Number.isFinite(t)||t<=0)return;let n=Math.max(200,Math.min(t-200,e))/t*100;this.editorPane.style.flex=`0 0 ${n}%`,this.previewPane.style.flex=`1`,this.updateResizerValue()}initializeResizer(){if(!this.resizer||!this.editorLayout||!this.editorPane||!this.previewPane)return;let e=!1,t=0,n=0;this.resizer.addEventListener(`mousedown`,r=>{e=!0,t=r.clientX,n=this.editorPane.offsetWidth,this.resizer.classList.add(`dragging`),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,r.preventDefault()}),document.addEventListener(`mousemove`,r=>{if(!e)return;let i=r.clientX-t;this.applyEditorPaneWidth(n+i)}),document.addEventListener(`mouseup`,()=>{e&&(e=!1,this.resizer.classList.remove(`dragging`),document.body.style.cursor=``,document.body.style.userSelect=``,this.scheduleEditorMeasure())}),this.resizer.addEventListener(`keydown`,e=>{let t=this.editorLayout.offsetWidth;if(!Number.isFinite(t)||t<=0)return;let n=Math.max(24,Math.round(t*.05));if(e.key===`ArrowLeft`){e.preventDefault(),this.applyEditorPaneWidth(this.editorPane.offsetWidth-n),this.scheduleEditorMeasure();return}if(e.key===`ArrowRight`){e.preventDefault(),this.applyEditorPaneWidth(this.editorPane.offsetWidth+n),this.scheduleEditorMeasure();return}if(e.key===`Home`){e.preventDefault(),this.applyEditorPaneWidth(t*.2),this.scheduleEditorMeasure();return}e.key===`End`&&(e.preventDefault(),this.applyEditorPaneWidth(t*.8),this.scheduleEditorMeasure())}),this.updateResizerValue()}},Jc=class{constructor({mobileBreakpointQuery:e=window.matchMedia(`(max-width: 768px)`),onNavigateToHeading:t,onWillOpen:n}={}){this.outlineOpen=!1,this.activeHeadingFrame=null,this.activeHeadingId=null,this.headings=[],this.pinnedHeadingId=null,this.onNavigateToHeading=t,this.onWillOpen=n,this.panel=document.getElementById(`outlinePanel`),this.navigation=document.getElementById(`outlineNav`),this.previewContainer=document.getElementById(`previewContainer`),this.toggleButton=document.getElementById(`outlineToggle`),this.mobileBreakpointQuery=e,this.handlePreviewScroll=()=>this.scheduleActiveHeadingUpdate(),this.handleDocumentPointerDown=e=>{if(!this.outlineOpen)return;let t=e.target;t instanceof Node&&(this.panel?.contains(t)||this.toggleButton?.contains(t))||this.close()}}initialize(){this.toggleButton?.addEventListener(`click`,()=>this.toggle()),document.addEventListener(`pointerdown`,this.handleDocumentPointerDown)}toggle(){this.setOpenState(!this.outlineOpen)}close(){this.setOpenState(!1)}setOpenState(e){if(e&&!this.outlineOpen&&this.onWillOpen?.(),this.outlineOpen=e,this.panel?.classList.toggle(`hidden`,!this.outlineOpen),this.toggleButton?.classList.toggle(`active`,this.outlineOpen),this.outlineOpen){this.refresh();return}this.cleanup()}refresh(){if(!this.navigation)return;if(!this.outlineOpen){this.cleanup();return}let e=document.getElementById(`previewContent`)?.querySelectorAll(`h1, h2, h3, h4, h5, h6`)??[];if(e.length===0){this.navigation.innerHTML=`<div class="outline-empty">No headings found</div>`,this.cleanup();return}let t=Array.from(e).map((e,t)=>(e.id||=`heading-${t}-${e.textContent.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,40)}`,{id:e.id,level:Number.parseInt(e.tagName[1],10),sourceLine:Number.parseInt(e.getAttribute(`data-source-line`)||``,10),text:e.textContent.trim()}));this.navigation.innerHTML=t.map(e=>`<button class="outline-item" data-level="${e.level}" data-target="${e.id}"${Number.isFinite(e.sourceLine)?` data-source-line="${e.sourceLine}"`:``} title="${e.text.replace(/"/g,`"`)}">${e.text}</button>`).join(``),this.navigation.querySelectorAll(`.outline-item`).forEach(e=>{e.addEventListener(`click`,()=>{let t=document.getElementById(e.dataset.target);this.navigateToHeading(t,e.dataset.target,{behavior:`auto`}),this.mobileBreakpointQuery.matches&&this.close()})}),this.observeHeadings(Array.from(e))}cleanup({preservePinnedHeading:e=!1}={}){this.activeHeadingFrame&&=(cancelAnimationFrame(this.activeHeadingFrame),null),this.previewContainer?.removeEventListener(`scroll`,this.handlePreviewScroll),this.headings=[],e||(this.pinnedHeadingId=null)}setActiveItem(e,{scrollIntoView:t=!0,behavior:n=`smooth`}={}){this.activeHeadingId=e,this.navigation?.querySelectorAll(`.outline-item`).forEach(t=>{t.classList.toggle(`active`,t.dataset.target===e)}),t&&this.navigation?.querySelector(`.outline-item.active`)?.scrollIntoView({behavior:n,block:`nearest`})}observeHeadings(e){if(this.cleanup({preservePinnedHeading:!0}),!this.previewContainer||e.length===0)return;this.headings=e,this.previewContainer.addEventListener(`scroll`,this.handlePreviewScroll,{passive:!0});let t=this.getPinnedHeading();if(t){this.setActiveItem(t.id,{behavior:`auto`,scrollIntoView:!0});return}this.updateActiveHeading()}scheduleActiveHeadingUpdate(){this.activeHeadingFrame||=requestAnimationFrame(()=>{this.activeHeadingFrame=null,this.updateActiveHeading()})}updateActiveHeading(){if(!this.previewContainer||this.headings.length===0)return;let e=this.getPinnedHeading();if(e&&this.shouldKeepPinnedHeadingActive(e)){this.setActiveItem(e.id,{behavior:`auto`,scrollIntoView:!0});return}this.pinnedHeadingId=null;let t=this.previewContainer.scrollTop,n=this.headings[0];for(let e of this.headings){if(this.getHeadingScrollTop(e)>t)break;n=e}this.setActiveItem(n.id,{behavior:`auto`,scrollIntoView:!0})}getHeadingScrollTop(e){if(!this.previewContainer)return 0;let t=this.previewContainer.getBoundingClientRect(),n=e.getBoundingClientRect();return this.previewContainer.scrollTop+(n.top-t.top)}getPinnedHeading(){return this.pinnedHeadingId?this.headings.find(e=>e.id===this.pinnedHeadingId)??null:null}shouldKeepPinnedHeadingActive(e){if(!this.previewContainer||!e?.isConnected)return!1;let t=this.getHeadingScrollTop(e)-this.previewContainer.scrollTop,n=t+e.getBoundingClientRect().height,r=this.previewContainer.clientHeight*.45;return n>-48&&t<r}notifyHeadingNavigation(e,t){if(!e)return;let n=Number.parseInt(e.getAttribute(`data-source-line`)||``,10);this.onNavigateToHeading?.({headingId:t,sourceLine:Number.isFinite(n)?n:null})}navigateToHeading(e,t,{behavior:n=`auto`}={}){return!e||!t?!1:(this.pinnedHeadingId=t,this.notifyHeadingNavigation(e,t),this.scrollHeadingIntoView(e,{behavior:n}),this.setActiveItem(t,{behavior:n}),!0)}scrollHeadingIntoView(e,{behavior:t=`smooth`}={}){if(!e||!this.previewContainer)return;let n=this.previewContainer.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.previewContainer.scrollTop+(r.top-n.top);this.previewContainer.scrollTo({behavior:t,top:Math.max(i,0)})}},Yc=.35,Xc=120,Zc=12,Qc=2;function $c(e){return Math.max(e.scrollHeight-e.clientHeight,0)}function el(e){return Math.max(e,0)}function tl(e){return Math.max(e.clientHeight*Yc,Zc)}function nl(e){return(e?.scrollTop??0)<=Qc}function rl(e,t){let n=e.getBoundingClientRect();return t.getBoundingClientRect().top-n.top+e.scrollTop}function il(e){return!e.querySelector(`[data-source-line]`)}function al(e){return typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e,{timeout:500}):window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>0})},1)}function ol(e){if(e!==null){if(typeof window.cancelIdleCallback==`function`){window.cancelIdleCallback(e);return}window.clearTimeout(e)}}var sl=class{constructor({getEditorLineNumber:e,onEditorScrollActivityChange:t,previewContainer:n,previewElement:r,scrollEditorToLine:i}){this.getEditorLineNumber=e,this.onEditorScrollActivityChange=t,this.previewContainer=n,this.previewElement=r,this.scrollEditorToLine=i,this.editorScroller=null,this.editorScrollActive=!1,this.editorScrollIdleTimer=null,this.lockedElements=new Set,this.pendingSync=null,this.frameId=null,this.previewBlocks=null,this.previewBlocksWarmId=null,this.previewBlocksReadyCallbacks=[],this.largeDocumentMode=!1,this.lastInteractionSource=`editor`,this.suspendedUntil=0,this.handleEditorScroll=()=>{if(!(!this.editorScroller||this.lockedElements.has(this.editorScroller)||this.isSuspended())){if(this.lastInteractionSource=`editor`,this.largeDocumentMode){this.setEditorScrollActive(!0),this.scheduleEditorScrollIdle(),this.scheduleSync(this.editorScroller,this.previewContainer,{preferApproximateMapping:!0});return}this.scheduleSync(this.editorScroller,this.previewContainer)}},this.handlePreviewScroll=()=>{!this.previewContainer||this.lockedElements.has(this.previewContainer)||this.isSuspended()||(this.lastInteractionSource=`preview`,this.scheduleSync(this.previewContainer,this.editorScroller))}}initialize(){this.previewContainer?.addEventListener(`scroll`,this.handlePreviewScroll,{passive:!0})}attachEditorScroller(e){this.editorScroller!==e&&(this.editorScroller?.removeEventListener(`scroll`,this.handleEditorScroll),this.editorScroller=e,this.editorScroller?.addEventListener(`scroll`,this.handleEditorScroll,{passive:!0}))}syncPreviewToEditor(){this.lastInteractionSource=`editor`,this.sync(this.editorScroller,this.previewContainer)}syncEditorToPreview(){this.lastInteractionSource=`preview`,this.sync(this.previewContainer,this.editorScroller)}destroy(){this.previewContainer?.removeEventListener(`scroll`,this.handlePreviewScroll),this.editorScroller?.removeEventListener(`scroll`,this.handleEditorScroll),this.editorScroller=null,clearTimeout(this.editorScrollIdleTimer),this.editorScrollIdleTimer=null,this.pendingSync=null,this.previewBlocks=null,ol(this.previewBlocksWarmId),this.previewBlocksWarmId=null,this.previewBlocksReadyCallbacks=[],this.lockedElements.clear(),this.editorScrollActive=!1,this.lastInteractionSource=`editor`,this.suspendedUntil=0,this.frameId&&=(cancelAnimationFrame(this.frameId),null)}scheduleSync(e,t,{preferApproximateMapping:n=!1}={}){!e||!t||this.lockedElements.has(e)||this.isSuspended()||(this.pendingSync={preferApproximateMapping:n,source:e,target:t},!this.frameId&&(this.frameId=requestAnimationFrame(()=>{if(this.frameId=null,!this.pendingSync)return;let{preferApproximateMapping:e,source:t,target:n}=this.pendingSync;this.pendingSync=null,this.sync(t,n,{preferApproximateMapping:e})})))}invalidatePreviewBlocks(){this.previewBlocks=null,ol(this.previewBlocksWarmId),this.previewBlocksWarmId=null,this.previewBlocksReadyCallbacks=[]}setLargeDocumentMode(e){this.largeDocumentMode=!!e,this.largeDocumentMode||(clearTimeout(this.editorScrollIdleTimer),this.editorScrollIdleTimer=null,this.setEditorScrollActive(!1))}warmPreviewBlocks({onReady:e}={}){if(typeof e==`function`&&(this.previewBlocks?e(this.previewBlocks):this.previewBlocksReadyCallbacks.push(e)),!this.largeDocumentMode){this.previewBlocks||=this.buildPreviewBlocks(),this.flushPreviewBlocksReadyCallbacks();return}this.previewBlocks||this.previewBlocksWarmId!==null||(this.previewBlocksWarmId=al(()=>{this.previewBlocksWarmId=null,this.previewBlocks=this.buildPreviewBlocks(),this.flushPreviewBlocksReadyCallbacks()}))}realignAfterLayoutChange(){let e=()=>{if(this.lastInteractionSource===`preview`){this.syncEditorToPreview();return}this.syncPreviewToEditor()};if(this.largeDocumentMode&&!this.previewBlocks){this.warmPreviewBlocks({onReady:()=>e()});return}e()}suspendSync(e=250){this.suspendedUntil=performance.now()+e}isSuspended(){return performance.now()<this.suspendedUntil}flushPreviewBlocksReadyCallbacks(){this.previewBlocksReadyCallbacks.length!==0&&this.previewBlocksReadyCallbacks.splice(0).forEach(e=>{try{e(this.previewBlocks??[])}catch(e){console.warn(`[scroll-sync] Preview block callback failed:`,e)}})}setEditorScrollActive(e){this.editorScrollActive!==e&&(this.editorScrollActive=e,this.onEditorScrollActivityChange?.(e))}scheduleEditorScrollIdle(){clearTimeout(this.editorScrollIdleTimer),this.editorScrollIdleTimer=setTimeout(()=>{this.editorScrollIdleTimer=null,this.setEditorScrollActive(!1),this.syncPreviewToEditor()},Xc)}sync(e,t,{preferApproximateMapping:n=!1}={}){if(!e||!t||this.lockedElements.has(e)||this.isSuspended())return;if(!n&&e===this.editorScroller&&t===this.previewContainer){let e=this.getPreviewScrollTopForEditorLine();if(e!==null){this.setScrollTop(t,e);return}}if(e===this.previewContainer&&t===this.editorScroller){let e=this.getEditorLineNumberForPreviewScroll();if(e!==null){this.lockedElements.add(t),this.scrollEditorToLine?.(e,Yc),requestAnimationFrame(()=>{this.lockedElements.delete(t)});return}}let r=$c(e),i=$c(t),a=r>0?e.scrollTop/r:0,o=i>0?i*a:0;this.setScrollTop(t,o)}setScrollTop(e,t){this.lockedElements.add(e),e.scrollTop=el(t),requestAnimationFrame(()=>{this.lockedElements.delete(e)})}getPreviewScrollTopForEditorLine(){if(nl(this.editorScroller))return 0;let e=this.getEditorLineNumber?.();if(!Number.isFinite(e))return null;let t=this.getPreviewBlocks();if(t.length===0||!this.previewContainer)return null;let{block:n,index:r}=this.findBlockForLine(t,e),i=this.getPreviewSpan(t,r),a=Math.max(n.end-n.start,1),o=x((e-n.start)/a,0,1),s=$c(this.previewContainer),c=tl(this.previewContainer);return x(n.top+i*o-c,0,s)}getEditorLineNumberForPreviewScroll(){if(!this.previewContainer)return null;let e=this.getPreviewBlocks();if(e.length===0)return null;let t=this.previewContainer.scrollTop+tl(this.previewContainer),{block:n,index:r}=this.findBlockForScrollTop(e,t),i=this.getPreviewSpan(e,r),a=Math.max(n.end-n.start,1),o=i>0?x((t-n.top)/i,0,1):0;return Math.round(n.start+a*o)}getPreviewBlocks(){return this.previewBlocks?this.previewBlocks:!this.previewContainer||!this.previewElement||this.largeDocumentMode?[]:(this.previewBlocks=this.buildPreviewBlocks(),this.previewBlocks)}buildPreviewBlocks(){let e=Array.from(this.previewElement.querySelectorAll(`[data-source-line]`)).map(e=>{let t=Number.parseInt(e.getAttribute(`data-source-line`)||``,10),n=Number.parseInt(e.getAttribute(`data-source-line-end`)||``,10);return Number.isFinite(t)?{element:e,end:Number.isFinite(n)?Math.max(n,t+1):t+1,start:t,top:rl(this.previewContainer,e)}:null}).filter(Boolean).sort((e,t)=>e.top-t.top||e.start-t.start||e.end-t.end),t=e.filter(e=>il(e.element)),n=t.length>0?t:e;return n.filter((e,t)=>{let r=n[t-1];return!r||Math.abs(r.top-e.top)>1||r.start!==e.start||r.end!==e.end})}findBlockForLine(e,t){let n=null,r=-1;for(let i=0;i<e.length;i+=1){let a=e[i];if(t>=a.start&&t<a.end){if(!n){n=a,r=i;continue}let e=n.end-n.start,t=a.end-a.start;(t<e||t===e&&a.start>=n.start)&&(n=a,r=i)}}if(n)return{block:n,index:r};let i=0;for(let n=0;n<e.length&&!(e[n].start>t);n+=1)i=n;return{block:e[i],index:i}}findBlockForScrollTop(e,t){for(let n=0;n<e.length;n+=1)if(t<this.getPreviewSpan(e,n)+e[n].top)return{block:e[n],index:n};let n=e.length-1;return{block:e[n],index:n}}getPreviewSpan(e,t){if(!this.previewContainer)return 1;let n=e[t],r=e[t+1],i=n.element.getBoundingClientRect().height;if(!r){let e=$c(this.previewContainer);return Math.max(e-n.top+this.previewContainer.clientHeight,i,1)}return Math.max(r.top-n.top,i,1)}},cl=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>`,ll=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>`,ul=class{constructor({storageKey:e=`collabmd-theme`,onChange:t}){this.storageKey=e,this.onChange=t,this.currentTheme=`dark`}initialize(){this.currentTheme=this.readPreferredTheme(),this.applyTheme(),document.querySelectorAll(`[data-theme-toggle]`).forEach(e=>{e.addEventListener(`click`,()=>this.toggle())})}getTheme(){return this.currentTheme}toggle(){this.currentTheme=this.currentTheme===`dark`?`light`:`dark`,this.persistTheme(),this.applyTheme()}readPreferredTheme(){try{let e=window.localStorage.getItem(this.storageKey);if(e===`light`||e===`dark`)return e}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}persistTheme(){try{window.localStorage.setItem(this.storageKey,this.currentTheme)}catch{}}applyTheme(){document.documentElement.setAttribute(`data-theme`,this.currentTheme),this.updateToggleIcons(),this.onChange?.(this.currentTheme)}updateToggleIcons(){let e=this.currentTheme===`dark`?`Dark`:`Light`,t=this.currentTheme===`dark`?`light`:`dark`,n=this.currentTheme===`dark`?ll:cl;document.querySelectorAll(`[data-theme-toggle]`).forEach(r=>{let i=r.querySelector(`[data-theme-toggle-icon]`),a=r.querySelector(`[data-theme-toggle-state]`);i?i.innerHTML=n:r.innerHTML=n,a&&(a.textContent=e,a.dataset.theme=this.currentTheme),r.setAttribute(`aria-label`,`Theme: ${e}. Switch to ${t} mode`),r.setAttribute(`title`,`Theme: ${e}. Switch to ${t} mode`)})}},dl=class{constructor(e){this.container=e}show(e,t=3e3){if(!this.container)return null;let n=typeof t==`number`?{duration:t}:{...t??{}},r=Number(n.duration)>0?Number(n.duration):0,i=document.createElement(`div`);i.className=`toast`;let a=document.createElement(`span`);a.className=`toast__message`,a.textContent=e,i.appendChild(a);let o=()=>{!i.isConnected||i.classList.contains(`leaving`)||(i.classList.add(`leaving`),i.addEventListener(`animationend`,()=>i.remove(),{once:!0}))};if(n.actionLabel&&typeof n.onAction==`function`){let e=document.createElement(`button`);e.className=`toast__action`,e.type=`button`,e.textContent=n.actionLabel,e.addEventListener(`click`,()=>{n.onAction(),n.closeOnAction!==!1&&o()}),i.appendChild(e)}if(n.dismissible){let e=document.createElement(`button`);e.className=`toast__dismiss`,e.type=`button`,e.setAttribute(`aria-label`,`Dismiss notification`),e.textContent=`Close`,e.addEventListener(`click`,o),i.appendChild(e)}return this.container.appendChild(i),r>0&&setTimeout(o,r),i}},fl=16/9,pl=240,ml=720,hl=180;function gl(e){return Math.max(hl,Math.min(ml,Math.ceil(e||pl)))}var _l=class{constructor({previewElement:e}){this.previewElement=e,this.embedEntries=new Map,this.overlayRoot=null}destroy(){this.embedEntries.forEach(e=>{e.hydrateFrameId&&=(cancelAnimationFrame(e.hydrateFrameId),null),e.wrapper?.remove(),e.placeholder=null}),this.embedEntries.clear(),this.overlayRoot?.remove(),this.overlayRoot=null}detachForCommit(){this.embedEntries.forEach(e=>{e.placeholder=null})}reconcileEmbeds(e=this.previewElement){if(this.previewElement=e,!e)return;let t=Array.from(e.querySelectorAll(`.video-embed-placeholder[data-video-embed-key]`)).map(e=>({filePath:e.dataset.videoEmbedSource,key:e.dataset.videoEmbedKey,label:e.dataset.videoEmbedLabel||`Embedded video`,placeholder:e,source:e.dataset.videoEmbedSource||``,kind:e.dataset.videoEmbedKind||``,url:e.dataset.videoEmbedUrl||``,mimeType:e.dataset.videoEmbedMimeType||``})),{nextEntries:n,removedEntries:r}=Ps(this.embedEntries,t);r.forEach(e=>this._destroyEntry(e)),this.embedEntries=n,this.embedEntries.forEach(e=>{e.aspectRatio=e.aspectRatio||fl,e.kind=e.placeholder?.dataset.videoEmbedKind||e.kind,e.label=e.placeholder?.dataset.videoEmbedLabel||e.label,e.mimeType=e.placeholder?.dataset.videoEmbedMimeType||e.mimeType,e.source=e.placeholder?.dataset.videoEmbedSource||e.source,e.url=e.placeholder?.dataset.videoEmbedUrl||e.url,e.wrapper||this._createEmbed(e),this._attachWrapper(e)}),this.syncLayout(),this.embedEntries.size===0&&(this.overlayRoot?.remove(),this.overlayRoot=null)}syncLayout(){this.embedEntries.forEach(e=>{e.wrapper&&this._syncEntryLayout(e)})}_destroyEntry(e){e.hydrateFrameId&&=(cancelAnimationFrame(e.hydrateFrameId),null),e.wrapper?.remove(),e.placeholder=null}_createEmbed(e){let t=document.createElement(`div`);if(t.className=`video-embed video-embed-shell diagram-preview-shell is-${e.kind}`,e.kind===`youtube`){let n=document.createElement(`div`);n.className=`video-embed-frame video-embed-frame-youtube`;let r=document.createElement(`iframe`);r.className=`video-embed-iframe`,r.title=e.label||`Embedded YouTube video`,r.referrerPolicy=`strict-origin-when-cross-origin`,r.allow=`accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,r.allowFullscreen=!0,n.appendChild(r),t.appendChild(n),e.mediaElement=r}else{let n=document.createElement(`video`);n.className=`video-embed-player`,n.controls=!0,n.preload=`metadata`,n.playsInline=!0,e.label&&(n.title=e.label,n.setAttribute(`aria-label`,e.label));let r=document.createElement(`source`);r.src=e.url,e.mimeType&&(r.type=e.mimeType),n.appendChild(r),n.addEventListener(`loadedmetadata`,()=>{Number.isFinite(n.videoWidth)&&Number.isFinite(n.videoHeight)&&n.videoWidth>0&&n.videoHeight>0&&(e.aspectRatio=n.videoWidth/n.videoHeight,this._syncEntryLayout(e))}),t.appendChild(n),e.mediaElement=n}e.wrapper=t}_attachWrapper(e){let t=e.placeholder?.isConnected?e.placeholder:this.previewElement?.querySelector(`.video-embed-placeholder[data-video-embed-key="${e.key}"]`);if(!t)return;e.placeholder=t,t.classList.add(`is-hydrated`),t.dataset.videoEmbedHydrated=`true`,t.style.pointerEvents=`none`;let n=this._ensureOverlayRoot();e.wrapper?.parentElement!==n&&n.appendChild(e.wrapper)}_syncEntryLayout(e){let t=e.placeholder?.isConnected?e.placeholder:this.previewElement?.querySelector(`.video-embed-placeholder[data-video-embed-key="${e.key}"]`);if(!t||!e.wrapper)return;e.placeholder=t;let n=t.offsetWidth||t.clientWidth||0;if(n<=0&&e.inlineHeightPx)return;let r=gl(n>0?n/(e.aspectRatio||fl):e.inlineHeightPx);e.inlineHeightPx=r,vl(t,`height`,`${r}px`),vl(e.wrapper,`position`,`absolute`),vl(e.wrapper,`top`,`${t.offsetTop}px`),vl(e.wrapper,`left`,`${t.offsetLeft}px`),vl(e.wrapper,`width`,`${t.offsetWidth}px`),vl(e.wrapper,`height`,`${r}px`),vl(e.wrapper,`margin`,`0`),vl(e.wrapper,`pointerEvents`,`auto`),this._hydrateEntryMedia(e)}_ensureOverlayRoot(){let e=this.previewElement?.querySelector(`[data-video-overlay-root="true"]`);return e||(e=document.createElement(`div`),e.dataset.videoOverlayRoot=`true`,e.className=`video-embed-overlay-root`,this.previewElement?.appendChild(e)),this.overlayRoot=e,e}_hydrateEntryMedia(e){if(e.kind!==`youtube`)return;let t=e.mediaElement;t instanceof HTMLIFrameElement&&(!e.url||t.getAttribute(`src`)===e.url||e.wrapper?.offsetWidth<=0||e.wrapper?.offsetHeight<=0||(e.hydrateFrameId||=requestAnimationFrame(()=>{if(e.hydrateFrameId=null,!e.url||t.getAttribute(`src`)===e.url)return;let n=Math.round(e.wrapper?.offsetWidth||0),r=Math.round(e.wrapper?.offsetHeight||0);n<=0||r<=0||(t.width=String(n),t.height=String(r),t.src=e.url)})))}};function vl(e,t,n){!e||e.style[t]===n||(e.style[t]=n)}var Q=1,yl=6,bl=.25,xl=2,Sl=6;function Cl(e){let t=Number(e);return Number.isFinite(t)?Math.min(yl,Math.max(Q,Math.round(t*100)/100)):Q}function wl(e,{contentSize:t=0,scale:n=1,viewportSize:r=0}={}){let i=Number(e),a=Number(t),o=Number(n),s=Number(r);if(!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(o)||!Number.isFinite(s))return 0;let c=(a*o-s)/2;return c<=0?0:Math.min(Math.max(i,-c),c)}function Tl(e){return!!e?.ctrlKey}var El=class{constructor({previewElement:e,documentRef:t=document,windowRef:n=window}){this.previewElement=e,this.document=t,this.window=n,this.overlayRoot=null,this.viewport=null,this.imageElement=null,this.zoomLabel=null,this.titleElement=null,this.isOpen=!1,this.scale=Q,this.offsetX=0,this.offsetY=0,this.activePointerId=null,this.dragStartX=0,this.dragStartY=0,this.dragOriginX=0,this.dragOriginY=0,this.touchPointers=new Map,this.pinchPointerIds=[],this.pinchStartDistance=0,this.pinchStartScale=Q,this.pinchStartOffsetX=0,this.pinchStartOffsetY=0,this.pinchStartCenter={x:0,y:0},this.didDrag=!1,this.resetButton=null,this.handlePreviewClick=e=>{let t=e.target;if(!(t instanceof this.window.Element))return;let n=t.closest(`img`);!n||!this.previewElement?.contains(n)||n.closest(`[data-video-overlay-root="true"], [data-excalidraw-overlay-root="true"]`)||(e.preventDefault(),e.stopImmediatePropagation?.(),this.openFromImage(n))},this.handleKeyDown=e=>{if(this.isOpen){if(e.key===`Escape`){e.preventDefault(),this.close();return}if(e.key===`+`||e.key===`=`){e.preventDefault(),this.zoomBy(bl);return}if(e.key===`-`){e.preventDefault(),this.zoomBy(-bl);return}e.key===`0`&&(e.preventDefault(),this.resetView())}},this.handleWindowResize=()=>{this.isOpen&&(this.clampOffsets(),this.syncTransform())},this.previewElement?.addEventListener(`click`,this.handlePreviewClick),this.document.addEventListener(`keydown`,this.handleKeyDown),this.window.addEventListener(`resize`,this.handleWindowResize)}destroy(){this.previewElement?.removeEventListener(`click`,this.handlePreviewClick),this.document.removeEventListener(`keydown`,this.handleKeyDown),this.window.removeEventListener(`resize`,this.handleWindowResize),this.close(),this.overlayRoot?.remove(),this.overlayRoot=null,this.viewport=null,this.imageElement=null,this.zoomLabel=null,this.titleElement=null,this.resetButton=null}openFromImage(e){let t=e?.currentSrc||e?.getAttribute?.(`src`)||``;return t?(this.ensureOverlayRoot(),this.resetView(),this.titleElement.textContent=e.getAttribute(`alt`)||`Image preview`,this.imageElement.src=t,this.imageElement.alt=e.getAttribute(`alt`)||``,this.overlayRoot.hidden=!1,this.isOpen=!0,this.document.body.classList.add(`image-lightbox-open`),this.syncTransform(),this.overlayRoot.focus?.(),!0):!1}close(){!this.isOpen&&!this.overlayRoot||(this.stopDrag(),this.touchPointers.clear(),this.pinchPointerIds=[],this.pinchStartDistance=0,this.didDrag=!1,this.viewport?.classList?.remove(`is-dragging`),this.overlayRoot&&(this.overlayRoot.hidden=!0),this.isOpen=!1,this.document.body.classList.remove(`image-lightbox-open`))}resetView(){this.scale=Q,this.offsetX=0,this.offsetY=0,this.syncTransform()}zoomBy(e){this.setScale(this.scale+e)}setScale(e){this.scale=Cl(e),this.clampOffsets(),this.syncTransform()}capturePointer(e){try{this.viewport?.setPointerCapture?.(e)}catch{}}releasePointer(e){try{this.viewport?.releasePointerCapture?.(e)}catch{}}getViewportPointFromClient(e,t){if(!this.viewport)return{x:0,y:0};let n=this.viewport.getBoundingClientRect();return{x:Number(e)-n.left-n.width/2,y:Number(t)-n.top-n.height/2}}setScaleAroundViewportPoint(e,t,{originScale:n=this.scale,originOffsetX:r=this.offsetX,originOffsetY:i=this.offsetY,targetViewportPoint:a=t}={}){let o=Cl(e),s=Number(n)>0?Number(n):Q,c=Number.isFinite(t?.x)?t.x:0,l=Number.isFinite(t?.y)?t.y:0,u=Number.isFinite(a?.x)?a.x:c,d=Number.isFinite(a?.y)?a.y:l;this.scale=o,this.offsetX=u-(c-r)/s*o,this.offsetY=d-(l-i)/s*o,this.clampOffsets(),this.syncTransform()}startDrag(e,t,n){return!this.viewport||this.scale<=Q?!1:(this.activePointerId=e,this.dragStartX=t,this.dragStartY=n,this.dragOriginX=this.offsetX,this.dragOriginY=this.offsetY,this.viewport.classList.add(`is-dragging`),this.capturePointer(e),!0)}stopDrag(e=this.activePointerId){e===this.activePointerId&&(this.activePointerId=null),this.viewport?.classList?.remove(`is-dragging`),e!==null&&this.releasePointer(e),this.imageElement&&(this.imageElement.style.cursor=this.scale>Q?`grab`:`zoom-in`)}updateDrag(e,t,n){return!this.isOpen||this.activePointerId!==e?!1:(!this.didDrag&&(Math.abs(t-this.dragStartX)>=Sl||Math.abs(n-this.dragStartY)>=Sl)&&(this.didDrag=!0),this.offsetX=this.dragOriginX+(t-this.dragStartX),this.offsetY=this.dragOriginY+(n-this.dragStartY),this.clampOffsets(),this.syncTransform(),!0)}getTrackedTouchPointers(){return Array.from(this.touchPointers.values())}getActivePinchPointers(){if(this.pinchPointerIds.length===2){let e=this.pinchPointerIds.map(e=>this.touchPointers.get(e)).filter(Boolean);if(e.length===2)return e}return this.getTrackedTouchPointers().slice(0,2)}startPinchGesture(){let[e,t]=this.getActivePinchPointers();if(!e||!t)return!1;this.stopDrag(),this.pinchPointerIds=[e.pointerId,t.pointerId],this.pinchStartDistance=Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)||1,this.pinchStartScale=this.scale,this.pinchStartOffsetX=this.offsetX,this.pinchStartOffsetY=this.offsetY;let n=this.getViewportPointFromClient((e.clientX+t.clientX)/2,(e.clientY+t.clientY)/2);return this.pinchStartCenter=n,!0}updatePinchGesture(){let[e,t]=this.getActivePinchPointers();if(!e||!t)return!1;let n=Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY);if(!Number.isFinite(n)||n<=0)return!1;let r=this.getViewportPointFromClient((e.clientX+t.clientX)/2,(e.clientY+t.clientY)/2),i=this.pinchStartScale*(n/this.pinchStartDistance);return this.setScaleAroundViewportPoint(i,this.pinchStartCenter,{originScale:this.pinchStartScale,originOffsetX:this.pinchStartOffsetX,originOffsetY:this.pinchStartOffsetY,targetViewportPoint:r}),!this.didDrag&&(Math.abs(n-this.pinchStartDistance)>=Sl||Math.abs(r.x-this.pinchStartCenter.x)>=Sl||Math.abs(r.y-this.pinchStartCenter.y)>=Sl)&&(this.didDrag=!0),!0}syncTouchGestureAfterPointerChange(){if(this.touchPointers.size>=2){this.startPinchGesture();return}if(this.pinchPointerIds=[],this.pinchStartDistance=0,this.touchPointers.size===1&&this.scale>Q){let[e]=this.getTrackedTouchPointers();this.startDrag(e.pointerId,e.clientX,e.clientY);return}this.stopDrag()}clampOffsets(){if(!this.viewport||!this.imageElement){this.offsetX=0,this.offsetY=0;return}this.offsetX=wl(this.offsetX,{contentSize:this.imageElement.offsetWidth||0,scale:this.scale,viewportSize:this.viewport.clientWidth||0}),this.offsetY=wl(this.offsetY,{contentSize:this.imageElement.offsetHeight||0,scale:this.scale,viewportSize:this.viewport.clientHeight||0})}syncTransform(){this.imageElement&&(this.imageElement.style.transform=`translate3d(${this.offsetX}px, ${this.offsetY}px, 0) scale(${this.scale})`,this.imageElement.style.cursor=this.scale>Q?`grab`:`zoom-in`,this.zoomLabel&&(this.zoomLabel.textContent=`${Math.round(this.scale*100)}%`),this.resetButton&&(this.resetButton.disabled=this.scale<=Q&&this.offsetX===0&&this.offsetY===0))}ensureOverlayRoot(){if(this.overlayRoot?.isConnected&&this.overlayRoot.parentElement===this.document.body)return this.overlayRoot;let e=this.document.createElement(`div`);e.className=`image-lightbox-root`,e.dataset.imageLightboxRoot=`true`,e.hidden=!0,e.tabIndex=-1;let t=this.document.createElement(`button`);t.className=`image-lightbox-backdrop`,t.type=`button`,t.setAttribute(`aria-label`,`Close image preview`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.close()});let n=this.document.createElement(`div`);n.className=`image-lightbox-shell`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-modal`,`true`),n.setAttribute(`aria-label`,`Image preview`),n.addEventListener(`click`,e=>e.stopPropagation()),n.addEventListener(`pointerdown`,e=>e.stopPropagation());let r=this.document.createElement(`div`);r.className=`image-lightbox-toolbar`;let i=this.document.createElement(`div`);i.className=`image-lightbox-title`,i.textContent=`Image preview`;let a=this.document.createElement(`div`);a.className=`image-lightbox-controls`;let o=this.createControlButton(`-`,`Zoom out`,()=>this.zoomBy(-bl)),s=this.document.createElement(`span`);s.className=`image-lightbox-zoom-label`,s.textContent=`100%`;let c=this.createControlButton(`+`,`Zoom in`,()=>this.zoomBy(bl)),l=this.createControlButton(`Reset`,`Reset zoom and position`,()=>this.resetView()),u=this.createControlButton(`Close`,`Close image preview`,()=>this.close());a.append(o,s,c,l,u),r.append(i,a);let d=this.document.createElement(`div`);d.className=`image-lightbox-viewport`;let f=this.document.createElement(`img`);f.className=`image-lightbox-image`,f.alt=``,f.addEventListener(`load`,()=>{this.clampOffsets(),this.syncTransform()}),d.addEventListener(`wheel`,e=>{if(!this.isOpen)return;if(Tl(e)){e.preventDefault(),this.zoomBy(e.deltaY<0?bl:-bl);return}if(this.scale<=Q)return;let t=Number.isFinite(e.deltaX)?e.deltaX:0,n=Number.isFinite(e.deltaY)?e.deltaY:0;t===0&&n===0||(e.preventDefault(),this.offsetX-=t,this.offsetY-=n,this.clampOffsets(),this.syncTransform())},{passive:!1}),d.addEventListener(`pointerdown`,e=>{if(this.isOpen){if(e.pointerType===`touch`){this.touchPointers.size===0&&(this.didDrag=!1),this.touchPointers.set(e.pointerId,{clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId}),this.capturePointer(e.pointerId),this.syncTouchGestureAfterPointerChange(),(this.touchPointers.size>1||this.scale>Q)&&e.preventDefault();return}this.scale<=Q||e.button!==0||(this.didDrag=!1,this.startDrag(e.pointerId,e.clientX,e.clientY),e.preventDefault())}}),d.addEventListener(`pointermove`,e=>{if(this.isOpen){if(e.pointerType===`touch`&&this.touchPointers.has(e.pointerId)){if(this.touchPointers.set(e.pointerId,{clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId}),this.touchPointers.size>=2){this.updatePinchGesture(),e.preventDefault();return}this.updateDrag(e.pointerId,e.clientX,e.clientY)&&e.preventDefault();return}this.updateDrag(e.pointerId,e.clientX,e.clientY)}});let p=e=>{if(e.pointerType===`touch`){this.touchPointers.delete(e.pointerId),this.releasePointer(e.pointerId),this.activePointerId===e.pointerId&&this.stopDrag(e.pointerId),this.syncTouchGestureAfterPointerChange();return}this.activePointerId===e.pointerId&&this.stopDrag(e.pointerId)};return d.addEventListener(`pointerup`,p),d.addEventListener(`pointercancel`,p),d.addEventListener(`lostpointercapture`,p),f.addEventListener(`click`,e=>{if(this.isOpen){if(e.preventDefault(),e.stopPropagation(),this.didDrag){this.didDrag=!1;return}this.scale<=Q&&this.setScale(xl)}}),d.appendChild(f),n.append(r,d),e.append(t,n),this.document.body.appendChild(e),this.overlayRoot=e,this.viewport=d,this.imageElement=f,this.zoomLabel=s,this.titleElement=i,this.resetButton=l,this.syncTransform(),e}createControlButton(e,t,n,{className:r=``}={}){let i=this.document.createElement(`button`);return i.className=`image-lightbox-btn ${r}`.trim(),i.type=`button`,i.setAttribute(`aria-label`,t),i.textContent=e,i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n(e)}),i}},Dl=globalThis,Ol=e=>e,kl=Dl.trustedTypes,Al=kl?kl.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,jl=`$lit$`,Ml=`lit$${Math.random().toFixed(9).slice(2)}$`,Nl=`?`+Ml,Pl=`<${Nl}>`,Fl=document,Il=()=>Fl.createComment(``),Ll=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Rl=Array.isArray,zl=e=>Rl(e)||typeof e?.[Symbol.iterator]==`function`,Bl=`[
|
|
793
|
-
\f\r]`,Vl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Hl=/-->/g,Ul=/>/g,Wl=RegExp(`>|${Bl}(?:([^\\s"'>=/]+)(${Bl}*=${Bl}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Gl=/'/g,Kl=/"/g,ql=/^(?:script|style|textarea|title)$/i,Jl=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),Yl=Symbol.for(`lit-noChange`),$=Symbol.for(`lit-nothing`),Xl=new WeakMap,Zl=Fl.createTreeWalker(Fl,129);function Ql(e,t){if(!Rl(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Al===void 0?t:Al.createHTML(t)}var $l=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Vl;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===Vl?c[1]===`!--`?o=Hl:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=Wl):(ql.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=Wl):o=Ul:o===Wl?c[0]===`>`?(o=i??Vl,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?Wl:c[3]===`"`?Kl:Gl):o===Kl||o===Gl?o=Wl:o===Hl||o===Ul?o=Vl:(o=Wl,i=void 0);let d=o===Wl&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Vl?n+Pl:l>=0?(r.push(s),n.slice(0,l)+jl+n.slice(l)+Ml+d):n+Ml+(l===-2?t:d)}return[Ql(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},eu=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=$l(t,n);if(this.el=e.createElement(l,r),Zl.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Zl.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(jl)){let t=u[o++],n=i.getAttribute(e).split(Ml),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?au:r[1]===`?`?ou:r[1]===`@`?su:iu}),i.removeAttribute(e)}else e.startsWith(Ml)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(ql.test(i.tagName)){let e=i.textContent.split(Ml),t=e.length-1;if(t>0){i.textContent=kl?kl.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],Il()),Zl.nextNode(),c.push({type:2,index:++a});i.append(e[t],Il())}}}else if(i.nodeType===8)if(i.data===Nl)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(Ml,e+1))!==-1;)c.push({type:7,index:a}),e+=Ml.length-1}a++}}static createElement(e,t){let n=Fl.createElement(`template`);return n.innerHTML=e,n}};function tu(e,t,n=e,r){if(t===Yl)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Ll(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=tu(e,i._$AS(e,t.values),i,r)),t}var nu=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??Fl).importNode(t,!0);Zl.currentNode=r;let i=Zl.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new ru(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new cu(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Zl.nextNode(),a++)}return Zl.currentNode=Fl,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},ru=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=$,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=tu(this,e,t),Ll(e)?e===$||e==null||e===``?(this._$AH!==$&&this._$AR(),this._$AH=$):e!==this._$AH&&e!==Yl&&this._(e):e._$litType$===void 0?e.nodeType===void 0?zl(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==$&&Ll(this._$AH)?this._$AA.nextSibling.data=e:this.T(Fl.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=eu.createElement(Ql(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new nu(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Xl.get(e.strings);return t===void 0&&Xl.set(e.strings,t=new eu(e)),t}k(t){Rl(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(Il()),this.O(Il()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Ol(e).nextSibling;Ol(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},iu=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=$,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=$}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=tu(this,e,t,0),a=!Ll(e)||e!==this._$AH&&e!==Yl,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=tu(this,r[n+o],t,o),s===Yl&&(s=this._$AH[o]),a||=!Ll(s)||s!==this._$AH[o],s===$?e=$:e!==$&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===$?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},au=class extends iu{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===$?void 0:e}},ou=class extends iu{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==$)}},su=class extends iu{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=tu(this,e,t,0)??$)===Yl)return;let n=this._$AH,r=e===$&&n!==$||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==$&&(n===$||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},cu=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){tu(this,e)}},lu=Dl.litHtmlPolyfillSupport;lu?.(eu,ru),(Dl.litHtmlVersions??=[]).push(`3.3.2`);var uu=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new ru(t.insertBefore(Il(),e),e,void 0,n??{})}return i._$AI(e),i};function du(e={}){let{tone:t=`accent`,count:n=!1,hidden:r=!1,extra:i=[]}=e;return Pi(`ui-pill-badge`,t&&`ui-pill-badge--${t}`,{"ui-pill-badge--count":n,hidden:r},i)}function fu(){return Jl`
|
|
794
|
-
<a href="#editorContainer" class="sr-only skip-link">Skip to editor</a>
|
|
795
|
-
|
|
796
|
-
<div class="app-shell">
|
|
797
|
-
<aside id="sidebar" class="sidebar">
|
|
798
|
-
<div class="sidebar-header">
|
|
799
|
-
<div class="sidebar-brand">
|
|
800
|
-
<svg width="20" height="20" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
801
|
-
<rect x="6" y="8" width="28" height="38" rx="4" stroke="var(--color-primary)" stroke-width="2" fill="var(--color-primary)" fill-opacity="0.12"></rect>
|
|
802
|
-
<rect x="22" y="10" width="28" height="38" rx="4" stroke="var(--color-primary)" stroke-width="2" fill="var(--color-primary)" fill-opacity="0.25"></rect>
|
|
803
|
-
<path d="M14 20l4 10 1.5-4 4-1.5L14 20z" fill="var(--color-primary)" opacity="0.7"></path>
|
|
804
|
-
<path d="M38 28l-4-10-1.5 4-4 1.5L38 28z" fill="var(--color-primary)"></path>
|
|
805
|
-
</svg>
|
|
806
|
-
<span class="sidebar-title">CollabMD</span>
|
|
807
|
-
</div>
|
|
808
|
-
<div class="sidebar-actions">
|
|
809
|
-
<button class=${Fi({extra:`sidebar-close-btn`})} id="sidebarClose" aria-label="Close sidebar" title="Close sidebar">
|
|
810
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
811
|
-
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
812
|
-
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
813
|
-
</svg>
|
|
814
|
-
</button>
|
|
815
|
-
<div class="sidebar-create-shell">
|
|
816
|
-
<button
|
|
817
|
-
class=${G({variant:`secondary`,size:`compact`,pill:!0,extra:`sidebar-create-btn`})}
|
|
818
|
-
id="sidebarCreateBtn"
|
|
819
|
-
aria-label="Create"
|
|
820
|
-
aria-expanded="false"
|
|
821
|
-
aria-haspopup="menu"
|
|
822
|
-
title="Create file or folder"
|
|
823
|
-
>
|
|
824
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
825
|
-
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
826
|
-
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
827
|
-
</svg>
|
|
828
|
-
<span class="sidebar-create-btn-label">Create</span>
|
|
829
|
-
</button>
|
|
830
|
-
</div>
|
|
831
|
-
<button class=${Fi()} id="refreshFilesBtn" aria-label="Refresh" title="Refresh file list">
|
|
832
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
833
|
-
<polyline points="23 4 23 10 17 10"></polyline>
|
|
834
|
-
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path>
|
|
835
|
-
</svg>
|
|
836
|
-
</button>
|
|
837
|
-
</div>
|
|
838
|
-
</div>
|
|
839
|
-
<div class="ui-nav-tabs hidden" id="sidebarTabs">
|
|
840
|
-
<button class="ui-nav-tab active" id="filesSidebarTab" type="button">
|
|
841
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
842
|
-
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path>
|
|
843
|
-
</svg>
|
|
844
|
-
Files
|
|
845
|
-
</button>
|
|
846
|
-
<button class="ui-nav-tab hidden" id="gitSidebarTab" type="button">
|
|
847
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
848
|
-
<circle cx="18" cy="18" r="3"></circle>
|
|
849
|
-
<circle cx="6" cy="6" r="3"></circle>
|
|
850
|
-
<path d="M13 6h3a2 2 0 0 1 2 2v7"></path>
|
|
851
|
-
<path d="M6 9v12"></path>
|
|
852
|
-
</svg>
|
|
853
|
-
Git
|
|
854
|
-
</button>
|
|
855
|
-
</div>
|
|
856
|
-
<div class="sidebar-search" id="fileSearch">
|
|
857
|
-
<input
|
|
858
|
-
type="text"
|
|
859
|
-
class=${K({extra:`sidebar-search-input`})}
|
|
860
|
-
id="fileSearchInput"
|
|
861
|
-
placeholder="Search files..."
|
|
862
|
-
autocomplete="off"
|
|
863
|
-
spellcheck="false"
|
|
864
|
-
aria-label="Search files"
|
|
865
|
-
>
|
|
866
|
-
</div>
|
|
867
|
-
<div class="sidebar-search hidden" id="gitSearch">
|
|
868
|
-
<input
|
|
869
|
-
type="text"
|
|
870
|
-
class=${K({extra:`sidebar-search-input`})}
|
|
871
|
-
id="gitSearchInput"
|
|
872
|
-
placeholder="Search changes..."
|
|
873
|
-
autocomplete="off"
|
|
874
|
-
spellcheck="false"
|
|
875
|
-
aria-label="Search changed files"
|
|
876
|
-
>
|
|
877
|
-
</div>
|
|
878
|
-
<nav id="fileTree" class="file-tree" aria-label="File explorer"></nav>
|
|
879
|
-
<div id="gitPanel" class="git-panel hidden" aria-label="Git changes"></div>
|
|
880
|
-
</aside>
|
|
881
|
-
|
|
882
|
-
<main class="main-area" id="mainContent">
|
|
883
|
-
<header class="toolbar" role="banner">
|
|
884
|
-
<div class="toolbar-left">
|
|
885
|
-
<button class=${G({variant:`ghost`,toolbar:!0})} id="sidebarToggle" aria-label="Toggle sidebar" title="Toggle sidebar">
|
|
886
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
887
|
-
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
888
|
-
<line x1="3" y1="12" x2="21" y2="12"></line>
|
|
889
|
-
<line x1="3" y1="18" x2="21" y2="18"></line>
|
|
890
|
-
</svg>
|
|
891
|
-
</button>
|
|
892
|
-
<div class="toolbar-room-info">
|
|
893
|
-
<span class="toolbar-room-name" id="activeFileName">CollabMD</span>
|
|
894
|
-
<button
|
|
895
|
-
type="button"
|
|
896
|
-
class=${du({tone:`accent`,extra:[`toolbar-badge`,`toolbar-badge-button`]})}
|
|
897
|
-
id="userCount"
|
|
898
|
-
aria-controls="presencePanel"
|
|
899
|
-
aria-expanded="false"
|
|
900
|
-
data-presence-panel-trigger="true"
|
|
901
|
-
></button>
|
|
902
|
-
<span class=${du({tone:`accent`,hidden:!0,extra:`toolbar-badge`})} id="toolbarDiffBadge">Diff</span>
|
|
903
|
-
<span class=${du({tone:`accent`,hidden:!0,extra:`toolbar-badge`})} id="gitOperationStatus" aria-live="polite" aria-atomic="true"></span>
|
|
904
|
-
</div>
|
|
905
|
-
</div>
|
|
906
|
-
|
|
907
|
-
<div class="toolbar-center" id="toolbarCenter">
|
|
908
|
-
<div class=${Ii({extra:`view-toggle`})} role="group" aria-label="View mode">
|
|
909
|
-
<button class=${q({active:!0,extra:`view-btn`})} data-view="split" aria-label="Split view" aria-pressed="true" title="Split view">
|
|
910
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
911
|
-
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
|
912
|
-
<line x1="12" y1="3" x2="12" y2="21"></line>
|
|
913
|
-
</svg>
|
|
914
|
-
</button>
|
|
915
|
-
<button class=${q({extra:`view-btn`})} data-view="editor" aria-label="Editor only" aria-pressed="false" title="Editor only">
|
|
916
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
917
|
-
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
|
918
|
-
<line x1="8" y1="8" x2="16" y2="8"></line>
|
|
919
|
-
<line x1="8" y1="12" x2="14" y2="12"></line>
|
|
920
|
-
<line x1="8" y1="16" x2="12" y2="16"></line>
|
|
921
|
-
</svg>
|
|
922
|
-
</button>
|
|
923
|
-
<button class=${q({extra:`view-btn`})} data-view="preview" aria-label="Preview only" aria-pressed="false" title="Preview only">
|
|
924
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
925
|
-
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
|
926
|
-
<circle cx="12" cy="12" r="3"></circle>
|
|
927
|
-
</svg>
|
|
928
|
-
</button>
|
|
929
|
-
</div>
|
|
930
|
-
</div>
|
|
931
|
-
|
|
932
|
-
<div class="toolbar-right">
|
|
933
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`mobile-view-toggle`})} id="mobileViewToggle" aria-label="Toggle editor/preview" title="Toggle view">
|
|
934
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
935
|
-
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
|
936
|
-
<circle cx="12" cy="12" r="3"></circle>
|
|
937
|
-
</svg>
|
|
938
|
-
<span class="ui-toolbar-button-label">Preview</span>
|
|
939
|
-
</button>
|
|
940
|
-
|
|
941
|
-
<div class="user-avatars toolbar-presence-cluster" id="userAvatars"></div>
|
|
942
|
-
|
|
943
|
-
<section class="presence-panel hidden" id="presencePanel" aria-label="Online users" aria-hidden="true">
|
|
944
|
-
<div class="presence-panel-header">
|
|
945
|
-
<div>
|
|
946
|
-
<h2 class="presence-panel-title">Online now</h2>
|
|
947
|
-
<p class="presence-panel-status" id="presencePanelStatus">Click someone to follow.</p>
|
|
948
|
-
</div>
|
|
949
|
-
</div>
|
|
950
|
-
<div class="presence-panel-list" id="presencePanelList"></div>
|
|
951
|
-
</section>
|
|
952
|
-
|
|
953
|
-
<div class="chat-container" id="chatContainer">
|
|
954
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`chat-toggle-btn`})} id="chatToggleBtn" aria-label="Open team chat" aria-expanded="false" title="Team chat">
|
|
955
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
956
|
-
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
957
|
-
</svg>
|
|
958
|
-
<span class="ui-toolbar-button-label">Chat</span>
|
|
959
|
-
<span class=${du({tone:`solid`,count:!0,hidden:!0,extra:`chat-toggle-badge`})} id="chatToggleBadge">0</span>
|
|
960
|
-
</button>
|
|
961
|
-
<div class="toast-container chat-toast-container" id="chatToastContainer" aria-live="polite" aria-atomic="true"></div>
|
|
962
|
-
|
|
963
|
-
<section class="chat-panel hidden" id="chatPanel" aria-label="Team chat">
|
|
964
|
-
<div class="chat-panel-header">
|
|
965
|
-
<div>
|
|
966
|
-
<h2 class="chat-panel-title">Team chat</h2>
|
|
967
|
-
<p class="chat-panel-status" id="chatStatus">Syncing...</p>
|
|
968
|
-
</div>
|
|
969
|
-
<button
|
|
970
|
-
class=${G({variant:`secondary`,size:`compact`,pill:!0,surface:!0,action:!0,extra:`chat-notification-action`})}
|
|
971
|
-
id="chatNotificationBtn"
|
|
972
|
-
type="button"
|
|
973
|
-
>
|
|
974
|
-
Enable alerts
|
|
975
|
-
</button>
|
|
976
|
-
</div>
|
|
977
|
-
|
|
978
|
-
<div class="chat-empty-state" id="chatEmptyState">
|
|
979
|
-
Temporary room chat for whoever is online right now.
|
|
980
|
-
</div>
|
|
981
|
-
<div class="chat-messages hidden" id="chatMessages" role="log" aria-live="polite" aria-relevant="additions text"></div>
|
|
982
|
-
|
|
983
|
-
<form class="chat-form" id="chatForm">
|
|
984
|
-
<input
|
|
985
|
-
type="text"
|
|
986
|
-
class=${K({extra:`chat-input`})}
|
|
987
|
-
id="chatInput"
|
|
988
|
-
placeholder="Send a quick update..."
|
|
989
|
-
autocomplete="off"
|
|
990
|
-
spellcheck="true"
|
|
991
|
-
maxlength="280"
|
|
992
|
-
aria-label="Team chat message"
|
|
993
|
-
>
|
|
994
|
-
<button type="submit" class=${G({variant:`primary`,extra:`chat-send-btn`})}>Send</button>
|
|
995
|
-
</form>
|
|
996
|
-
</section>
|
|
997
|
-
</div>
|
|
998
|
-
|
|
999
|
-
<button
|
|
1000
|
-
class=${G({variant:`ghost`,toolbar:!0,extra:`toolbar-overflow-toggle`})}
|
|
1001
|
-
id="toolbarOverflowToggle"
|
|
1002
|
-
aria-label="Open more actions"
|
|
1003
|
-
aria-expanded="false"
|
|
1004
|
-
title="More actions"
|
|
1005
|
-
>
|
|
1006
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
1007
|
-
<circle cx="12" cy="12" r="1"></circle>
|
|
1008
|
-
<circle cx="19" cy="12" r="1"></circle>
|
|
1009
|
-
<circle cx="5" cy="12" r="1"></circle>
|
|
1010
|
-
</svg>
|
|
1011
|
-
</button>
|
|
1012
|
-
|
|
1013
|
-
<div class="toolbar-overflow-menu" id="toolbarOverflowMenu">
|
|
1014
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`hidden`})} id="fileHistoryBtn" aria-label="Open file history" title="View file history">
|
|
1015
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1016
|
-
<path d="M3 12a9 9 0 1 0 3-6.7"></path>
|
|
1017
|
-
<path d="M3 4v5h5"></path>
|
|
1018
|
-
<path d="M12 7v5l3 3"></path>
|
|
1019
|
-
</svg>
|
|
1020
|
-
<span class="ui-toolbar-button-label" id="fileHistoryBtnLabel">History</span>
|
|
1021
|
-
</button>
|
|
1022
|
-
|
|
1023
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`ui-toolbar-button--name`})} id="editNameBtn" aria-label="Set name. Change display name" title="Change display name">
|
|
1024
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1025
|
-
<path d="M12 20h9"></path>
|
|
1026
|
-
<path d="M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z"></path>
|
|
1027
|
-
</svg>
|
|
1028
|
-
<span class="ui-toolbar-button-label ui-toolbar-button-text" id="currentUserName">Set name</span>
|
|
1029
|
-
</button>
|
|
1030
|
-
|
|
1031
|
-
<button class=${G({variant:`ghost`,toolbar:!0})} id="shareBtn" aria-label="Share. Copy link" title="Share link">
|
|
1032
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
1033
|
-
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
|
|
1034
|
-
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
|
|
1035
|
-
</svg>
|
|
1036
|
-
<span class="ui-toolbar-button-label">Share</span>
|
|
1037
|
-
</button>
|
|
1038
|
-
|
|
1039
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`toolbar-search-files-btn`})} id="searchFilesBtn" aria-label="Search files" title="Search files">
|
|
1040
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
1041
|
-
<circle cx="11" cy="11" r="7"></circle>
|
|
1042
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1043
|
-
</svg>
|
|
1044
|
-
<span class="ui-toolbar-button-label">Search files</span>
|
|
1045
|
-
</button>
|
|
1046
|
-
|
|
1047
|
-
<details class="toolbar-overflow-group hidden" id="exportMenuGroup">
|
|
1048
|
-
<summary class=${G({variant:`ghost`,toolbar:!0,extra:`toolbar-overflow-group-toggle`})} aria-label="Export options" title="Export">
|
|
1049
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1050
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
1051
|
-
<polyline points="14 2 14 8 20 8"></polyline>
|
|
1052
|
-
<path d="M12 18v-6"></path>
|
|
1053
|
-
<path d="m9 15 3 3 3-3"></path>
|
|
1054
|
-
</svg>
|
|
1055
|
-
<span class="ui-toolbar-button-label">Export</span>
|
|
1056
|
-
</summary>
|
|
1057
|
-
<div class="toolbar-overflow-submenu">
|
|
1058
|
-
<button class=${G({variant:`ghost`,toolbar:!0})} id="exportDocxBtn" aria-label="Export DOCX" title="Export DOCX">
|
|
1059
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1060
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
1061
|
-
<polyline points="14 2 14 8 20 8"></polyline>
|
|
1062
|
-
<path d="M8 13h2l1.2 2 1.6-4 1.2 2H18"></path>
|
|
1063
|
-
</svg>
|
|
1064
|
-
<span class="ui-toolbar-button-label">Export DOCX</span>
|
|
1065
|
-
</button>
|
|
1066
|
-
<button class=${G({variant:`ghost`,toolbar:!0})} id="exportPdfBtn" aria-label="Print or save PDF" title="Print / Save PDF">
|
|
1067
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1068
|
-
<path d="M6 9V2h12v7"></path>
|
|
1069
|
-
<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path>
|
|
1070
|
-
<rect x="6" y="14" width="12" height="8"></rect>
|
|
1071
|
-
</svg>
|
|
1072
|
-
<span class="ui-toolbar-button-label">Print / Save PDF</span>
|
|
1073
|
-
</button>
|
|
1074
|
-
</div>
|
|
1075
|
-
</details>
|
|
1076
|
-
|
|
1077
|
-
<button class=${G({variant:`ghost`,toolbar:!0,extra:`toolbar-theme-button`})} id="themeToggleBtn" data-theme-toggle aria-label="Toggle theme" title="Toggle theme">
|
|
1078
|
-
<span class="toolbar-theme-icon" data-theme-toggle-icon aria-hidden="true">
|
|
1079
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1080
|
-
<circle cx="12" cy="12" r="5"></circle>
|
|
1081
|
-
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"></path>
|
|
1082
|
-
</svg>
|
|
1083
|
-
</span>
|
|
1084
|
-
<span class="ui-toolbar-button-label">Theme</span>
|
|
1085
|
-
<span class=${du({tone:`muted`,extra:`toolbar-theme-state`})} data-theme-toggle-state>Dark</span>
|
|
1086
|
-
</button>
|
|
1087
|
-
</div>
|
|
1088
|
-
</div>
|
|
1089
|
-
</header>
|
|
1090
|
-
|
|
1091
|
-
<div id="emptyState" class="empty-state">
|
|
1092
|
-
<div class="empty-state-content">
|
|
1093
|
-
<div class="empty-state-logo" aria-hidden="true">
|
|
1094
|
-
<svg width="48" height="48" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1095
|
-
<rect x="6" y="8" width="28" height="38" rx="4" stroke="var(--color-primary)" stroke-width="2" fill="var(--color-primary)" fill-opacity="0.12"></rect>
|
|
1096
|
-
<rect x="22" y="10" width="28" height="38" rx="4" stroke="var(--color-primary)" stroke-width="2" fill="var(--color-primary)" fill-opacity="0.25"></rect>
|
|
1097
|
-
<path d="M14 20l4 10 1.5-4 4-1.5L14 20z" fill="var(--color-primary)" opacity="0.7"></path>
|
|
1098
|
-
<path d="M38 28l-4-10-1.5 4-4 1.5L38 28z" fill="var(--color-primary)"></path>
|
|
1099
|
-
</svg>
|
|
1100
|
-
</div>
|
|
1101
|
-
<h2 class="empty-state-title">Welcome to CollabMD</h2>
|
|
1102
|
-
<p class="empty-state-desc">Open a file from the sidebar, or get started quickly:</p>
|
|
1103
|
-
<div class="empty-state-actions">
|
|
1104
|
-
<button class=${G({variant:`secondary`,extra:`empty-state-btn`})} id="emptyStateNewFileBtn">
|
|
1105
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
1106
|
-
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
1107
|
-
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
1108
|
-
</svg>
|
|
1109
|
-
Create
|
|
1110
|
-
</button>
|
|
1111
|
-
<button class=${G({variant:`secondary`,extra:`empty-state-btn`})} id="emptyStateSearchBtn">
|
|
1112
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
1113
|
-
<circle cx="11" cy="11" r="8"></circle>
|
|
1114
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1115
|
-
</svg>
|
|
1116
|
-
Search Everything
|
|
1117
|
-
<kbd class="empty-state-kbd">⌘K</kbd>
|
|
1118
|
-
</button>
|
|
1119
|
-
</div>
|
|
1120
|
-
</div>
|
|
1121
|
-
</div>
|
|
1122
|
-
|
|
1123
|
-
<div id="editor-page" class="editor-page hidden">
|
|
1124
|
-
<div class="editor-layout" id="editorLayout" data-view="split">
|
|
1125
|
-
<div class="editor-pane" id="editorPane">
|
|
1126
|
-
<div class="pane-header">
|
|
1127
|
-
<div class="pane-header-meta">
|
|
1128
|
-
<span class="pane-label">Editor</span>
|
|
1129
|
-
<span class="pane-label-meta" id="lineInfo">Ln 1, Col 1</span>
|
|
1130
|
-
</div>
|
|
1131
|
-
<div class="pane-header-actions">
|
|
1132
|
-
<button class=${G({variant:`ghost`,size:`compact`,toggle:!0,extra:`mobile-editor-find-btn`})} id="editorFindBtn" aria-label="Find in file" title="Find in file">
|
|
1133
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
1134
|
-
<circle cx="11" cy="11" r="7"></circle>
|
|
1135
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1136
|
-
</svg>
|
|
1137
|
-
<span class="ui-action-label">Find</span>
|
|
1138
|
-
</button>
|
|
1139
|
-
<button class=${G({variant:`ghost`,size:`compact`,toggle:!0,extra:`hidden`})} id="commentSelectionBtn" aria-label="Comment current line or selection" title="Comment current line or selection">
|
|
1140
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1141
|
-
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
1142
|
-
</svg>
|
|
1143
|
-
<span class="ui-action-label">Comment</span>
|
|
1144
|
-
</button>
|
|
1145
|
-
<button class=${G({variant:`ghost`,size:`compact`,toggle:!0})} id="toggleWrapBtn" aria-label="Disable line wrap" title="Disable line wrap">
|
|
1146
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1147
|
-
<path d="M3 6h14a4 4 0 1 1 0 8H9"></path>
|
|
1148
|
-
<path d="m9 10-4 4 4 4"></path>
|
|
1149
|
-
<path d="M3 18h7"></path>
|
|
1150
|
-
</svg>
|
|
1151
|
-
<span id="wrapToggleLabel">Wrap on</span>
|
|
1152
|
-
</button>
|
|
1153
|
-
</div>
|
|
1154
|
-
</div>
|
|
1155
|
-
<div id="markdownToolbar" class="markdown-toolbar hidden" role="toolbar" aria-label="Markdown formatting"></div>
|
|
1156
|
-
<div id="editorContainer" class="editor-container">
|
|
1157
|
-
<div class="editor-loading" id="editorLoading">
|
|
1158
|
-
<div class="skeleton-line skeleton-line--title skeleton-line--break"></div>
|
|
1159
|
-
<div class="skeleton-line skeleton-line--full"></div>
|
|
1160
|
-
<div class="skeleton-line skeleton-line--ninety"></div>
|
|
1161
|
-
<div class="skeleton-line skeleton-line--ninety-five"></div>
|
|
1162
|
-
<div class="skeleton-line skeleton-line--eighty skeleton-line--break"></div>
|
|
1163
|
-
<div class="skeleton-line skeleton-line--full"></div>
|
|
1164
|
-
<div class="skeleton-line skeleton-line--eighty-five"></div>
|
|
1165
|
-
</div>
|
|
1166
|
-
</div>
|
|
1167
|
-
</div>
|
|
1168
|
-
|
|
1169
|
-
<div class="resizer" id="resizer" role="separator" aria-orientation="vertical" tabindex="0" aria-label="Resize editor and preview" aria-controls="editorPane previewPane" aria-valuemin="20" aria-valuemax="80" aria-valuenow="50"></div>
|
|
1170
|
-
|
|
1171
|
-
<div class="preview-pane" id="previewPane">
|
|
1172
|
-
<div class="pane-header">
|
|
1173
|
-
<span class="pane-label">Preview</span>
|
|
1174
|
-
<div class="pane-header-actions">
|
|
1175
|
-
<div id="backlinksHeaderPanel" class="backlinks-panel backlinks-panel-header hidden" data-backlinks-variant="header">
|
|
1176
|
-
<button type="button" class="backlinks-header" aria-expanded="false">
|
|
1177
|
-
<svg class="backlinks-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
1178
|
-
<polyline points="9 18 15 12 9 6"></polyline>
|
|
1179
|
-
</svg>
|
|
1180
|
-
<span class="backlinks-toggle">0 Linked Mentions</span>
|
|
1181
|
-
<span class="backlinks-count"></span>
|
|
1182
|
-
</button>
|
|
1183
|
-
<div class="backlinks-body" aria-hidden="true" inert>
|
|
1184
|
-
<div class="backlinks-list"></div>
|
|
1185
|
-
</div>
|
|
1186
|
-
</div>
|
|
1187
|
-
<button class=${G({variant:`ghost`,size:`compact`,toggle:!0,extra:`hidden`})} id="commentsToggle" aria-label="Toggle comments" title="Toggle comments">
|
|
1188
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1189
|
-
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
1190
|
-
</svg>
|
|
1191
|
-
<span class="ui-action-label">Comments</span>
|
|
1192
|
-
</button>
|
|
1193
|
-
<button class=${G({variant:`ghost`,size:`compact`,toggle:!0})} id="outlineToggle" aria-label="Toggle outline" title="Toggle outline">
|
|
1194
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
1195
|
-
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
1196
|
-
<line x1="3" y1="12" x2="15" y2="12"></line>
|
|
1197
|
-
<line x1="3" y1="18" x2="18" y2="18"></line>
|
|
1198
|
-
</svg>
|
|
1199
|
-
</button>
|
|
1200
|
-
</div>
|
|
1201
|
-
</div>
|
|
1202
|
-
<div class="preview-body">
|
|
1203
|
-
<div id="previewContainer" class="preview-container">
|
|
1204
|
-
<div id="previewContent" class="preview-content"></div>
|
|
1205
|
-
<div id="backlinksInlinePanel" class="backlinks-panel backlinks-panel-inline hidden">
|
|
1206
|
-
<button type="button" class="backlinks-header" aria-expanded="false">
|
|
1207
|
-
<svg class="backlinks-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
1208
|
-
<polyline points="9 18 15 12 9 6"></polyline>
|
|
1209
|
-
</svg>
|
|
1210
|
-
<span class="backlinks-toggle">0 Linked Mentions</span>
|
|
1211
|
-
<span class="backlinks-count"></span>
|
|
1212
|
-
</button>
|
|
1213
|
-
<div class="backlinks-body" aria-hidden="true" inert>
|
|
1214
|
-
<div class="backlinks-list"></div>
|
|
1215
|
-
</div>
|
|
1216
|
-
</div>
|
|
1217
|
-
</div>
|
|
1218
|
-
<div id="backlinksPanel" class="backlinks-panel-layer hidden">
|
|
1219
|
-
<div class="backlinks-panel backlinks-panel-dock" data-backlinks-variant="dock">
|
|
1220
|
-
<button type="button" class="backlinks-header" aria-expanded="false">
|
|
1221
|
-
<svg class="backlinks-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
1222
|
-
<polyline points="9 18 15 12 9 6"></polyline>
|
|
1223
|
-
</svg>
|
|
1224
|
-
<span class="backlinks-toggle">0 Linked Mentions</span>
|
|
1225
|
-
<span class="backlinks-count"></span>
|
|
1226
|
-
</button>
|
|
1227
|
-
<div class="backlinks-body" aria-hidden="true" inert>
|
|
1228
|
-
<div class="backlinks-list"></div>
|
|
1229
|
-
</div>
|
|
1230
|
-
</div>
|
|
1231
|
-
</div>
|
|
1232
|
-
<aside id="commentsDrawer" class="comments-drawer hidden" aria-label="Comments">
|
|
1233
|
-
<div class="comments-drawer-header">
|
|
1234
|
-
<span class="comments-drawer-title">Comments</span>
|
|
1235
|
-
</div>
|
|
1236
|
-
<div id="commentsDrawerEmpty" class="comments-drawer-empty">
|
|
1237
|
-
Add a comment from the editor or the preview bubbles.
|
|
1238
|
-
</div>
|
|
1239
|
-
<div id="commentsDrawerList" class="comments-drawer-list"></div>
|
|
1240
|
-
</aside>
|
|
1241
|
-
<aside id="outlinePanel" class="outline-panel hidden" aria-label="Document outline">
|
|
1242
|
-
<div class="outline-header">
|
|
1243
|
-
<span class="outline-title">Outline</span>
|
|
1244
|
-
</div>
|
|
1245
|
-
<nav id="outlineNav" class="outline-nav"></nav>
|
|
1246
|
-
</aside>
|
|
1247
|
-
</div>
|
|
1248
|
-
</div>
|
|
1249
|
-
</div>
|
|
1250
|
-
</div>
|
|
1251
|
-
|
|
1252
|
-
<div id="diff-page" class="diff-page hidden">
|
|
1253
|
-
<div class="diff-toolbar">
|
|
1254
|
-
<div class="diff-toolbar-left">
|
|
1255
|
-
<div class="diff-file-nav">
|
|
1256
|
-
<button class=${Fi({action:!0})} id="diffPrevBtn" type="button" disabled aria-label="Previous changed file">
|
|
1257
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
1258
|
-
<polyline points="15 18 9 12 15 6"></polyline>
|
|
1259
|
-
</svg>
|
|
1260
|
-
</button>
|
|
1261
|
-
<span class="diff-file-indicator" id="diffFileIndicator">0 / 0 files</span>
|
|
1262
|
-
<button class=${Fi({action:!0})} id="diffNextBtn" type="button" disabled aria-label="Next changed file">
|
|
1263
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
1264
|
-
<polyline points="9 18 15 12 9 6"></polyline>
|
|
1265
|
-
</svg>
|
|
1266
|
-
</button>
|
|
1267
|
-
</div>
|
|
1268
|
-
<div class="diff-toolbar-actions">
|
|
1269
|
-
<button class=${G({variant:`secondary`,action:!0,surface:!0,wide:!0,hidden:!0,extra:`diff-back-btn`})} id="diffBackToHistoryBtn" type="button">
|
|
1270
|
-
Back to History
|
|
1271
|
-
</button>
|
|
1272
|
-
<div class="diff-toolbar-actions-group diff-toolbar-actions-group-git" id="diffGitActionsGroup" role="group" aria-label="Git file actions">
|
|
1273
|
-
<button class=${G({variant:`secondary`,action:!0,surface:!0,wide:!0})} id="diffPrimaryActionBtn" type="button" disabled>
|
|
1274
|
-
Stage
|
|
1275
|
-
</button>
|
|
1276
|
-
<button class=${G({variant:`primary`,action:!0,wide:!0})} id="diffCommitBtn" type="button" disabled>
|
|
1277
|
-
Commit Staged
|
|
1278
|
-
</button>
|
|
1279
|
-
</div>
|
|
1280
|
-
<span class="diff-toolbar-actions-divider" id="diffToolbarDivider" aria-hidden="true"></span>
|
|
1281
|
-
<div class="diff-toolbar-actions-group" id="diffEditorActionsGroup" role="group" aria-label="Navigation actions">
|
|
1282
|
-
<button class=${G({variant:`secondary`,action:!0,surface:!0,wide:!0,extra:`diff-open-editor-btn`})} id="diffOpenEditorBtn" type="button" disabled>
|
|
1283
|
-
Open in Editor
|
|
1284
|
-
</button>
|
|
1285
|
-
</div>
|
|
1286
|
-
</div>
|
|
1287
|
-
</div>
|
|
1288
|
-
<div class="diff-toolbar-right">
|
|
1289
|
-
<div class="diff-stats" id="diffStats">
|
|
1290
|
-
<span class="ui-stat-token ui-stat-token--add diff-stats-add">+0</span>
|
|
1291
|
-
<span class="ui-stat-token ui-stat-token--del diff-stats-del">-0</span>
|
|
1292
|
-
</div>
|
|
1293
|
-
<div class=${Ii({hidden:!0,extra:`diff-layout-toggle`})} id="diffLayoutToggle" role="group" aria-label="Commit diff layout">
|
|
1294
|
-
<button class=${q({extra:`view-btn diff-layout-btn`})} data-diff-layout="stacked" type="button">Stacked</button>
|
|
1295
|
-
<button class=${q({active:!0,extra:`view-btn diff-layout-btn`})} data-diff-layout="focused" type="button">Focused</button>
|
|
1296
|
-
</div>
|
|
1297
|
-
<div class=${Ii({extra:`diff-mode-toggle`})} role="group" aria-label="Diff view mode">
|
|
1298
|
-
<button class=${q({active:!0,extra:`view-btn diff-mode-btn`})} data-diff-mode="unified" type="button">Unified</button>
|
|
1299
|
-
<button class=${q({extra:`view-btn diff-mode-btn`})} data-diff-mode="split" type="button">Split</button>
|
|
1300
|
-
</div>
|
|
1301
|
-
</div>
|
|
1302
|
-
</div>
|
|
1303
|
-
<div class="diff-scroll" id="diffScroll">
|
|
1304
|
-
<div class="diff-content" id="diffContent"></div>
|
|
1305
|
-
</div>
|
|
1306
|
-
</div>
|
|
1307
|
-
</main>
|
|
1308
|
-
</div>
|
|
1309
|
-
|
|
1310
|
-
<dialog class="app-dialog" id="displayNameDialog">
|
|
1311
|
-
<form class="app-dialog-form" id="displayNameForm" method="dialog">
|
|
1312
|
-
<div class="app-dialog-header">
|
|
1313
|
-
<h2 class="app-dialog-title" id="displayNameTitle">Update display name</h2>
|
|
1314
|
-
<p class="app-dialog-copy" id="displayNameCopy">Your name will be visible to everyone editing this vault.</p>
|
|
1315
|
-
</div>
|
|
1316
|
-
<label class="app-dialog-field" for="displayNameInput">
|
|
1317
|
-
<span class="app-dialog-label">Name</span>
|
|
1318
|
-
<input type="text" class=${K()} id="displayNameInput" name="displayName" maxlength="24" autocomplete="nickname" spellcheck="false" required>
|
|
1319
|
-
</label>
|
|
1320
|
-
<div class="app-dialog-actions">
|
|
1321
|
-
<button type="button" class=${G({variant:`secondary`})} id="displayNameCancel">Cancel</button>
|
|
1322
|
-
<button type="submit" class=${G({variant:`primary`})} id="displayNameSubmit">Save name</button>
|
|
1323
|
-
</div>
|
|
1324
|
-
</form>
|
|
1325
|
-
</dialog>
|
|
1326
|
-
|
|
1327
|
-
<dialog class="app-dialog" id="fileActionDialog">
|
|
1328
|
-
<form class="app-dialog-form" id="fileActionForm" method="dialog">
|
|
1329
|
-
<div class="app-dialog-header">
|
|
1330
|
-
<h2 class="app-dialog-title" id="fileActionTitle">Create file</h2>
|
|
1331
|
-
<p class="app-dialog-copy" id="fileActionCopy">Add a new file to the vault.</p>
|
|
1332
|
-
</div>
|
|
1333
|
-
<label class="app-dialog-field" id="fileActionField" for="fileActionInput">
|
|
1334
|
-
<span class="app-dialog-label" id="fileActionLabel">Path</span>
|
|
1335
|
-
<input type="text" class=${K()} id="fileActionInput" name="fileActionValue" autocomplete="off" spellcheck="false" required>
|
|
1336
|
-
<span class="app-dialog-hint" id="fileActionHint" hidden></span>
|
|
1337
|
-
</label>
|
|
1338
|
-
<p class="app-dialog-note" id="fileActionNote" hidden></p>
|
|
1339
|
-
<div class="app-dialog-actions">
|
|
1340
|
-
<button type="button" class=${G({variant:`secondary`})} id="fileActionCancel">Cancel</button>
|
|
1341
|
-
<button type="submit" class=${G({variant:`primary`})} id="fileActionSubmit">Create</button>
|
|
1342
|
-
</div>
|
|
1343
|
-
</form>
|
|
1344
|
-
</dialog>
|
|
1345
|
-
|
|
1346
|
-
<dialog class="app-dialog" id="gitCommitDialog">
|
|
1347
|
-
<form class="app-dialog-form" id="gitCommitForm" method="dialog">
|
|
1348
|
-
<div class="app-dialog-header">
|
|
1349
|
-
<h2 class="app-dialog-title" id="gitCommitTitle">Commit staged changes</h2>
|
|
1350
|
-
<p class="app-dialog-copy" id="gitCommitCopy">All staged changes will be included.</p>
|
|
1351
|
-
</div>
|
|
1352
|
-
<label class="app-dialog-field" for="gitCommitInput">
|
|
1353
|
-
<span class="app-dialog-label">Commit message</span>
|
|
1354
|
-
<input type="text" class=${K()} id="gitCommitInput" name="gitCommitMessage" autocomplete="off" spellcheck="true" required>
|
|
1355
|
-
</label>
|
|
1356
|
-
<div class="app-dialog-actions">
|
|
1357
|
-
<button type="button" class=${G({variant:`secondary`})} id="gitCommitCancel">Cancel</button>
|
|
1358
|
-
<button type="submit" class=${G({variant:`primary`})} id="gitCommitSubmit">Commit staged changes</button>
|
|
1359
|
-
</div>
|
|
1360
|
-
</form>
|
|
1361
|
-
</dialog>
|
|
1362
|
-
|
|
1363
|
-
<dialog class="app-dialog" id="gitResetDialog">
|
|
1364
|
-
<form class="app-dialog-form" method="dialog">
|
|
1365
|
-
<div class="app-dialog-header">
|
|
1366
|
-
<h2 class="app-dialog-title" id="gitResetTitle">Reset file</h2>
|
|
1367
|
-
<p class="app-dialog-copy" id="gitResetCopy">Restore this file from the current checked-out branch. If that branch does not contain the file, it will be deleted locally.</p>
|
|
1368
|
-
</div>
|
|
1369
|
-
<div class="app-dialog-field">
|
|
1370
|
-
<label class="app-dialog-label" for="gitResetFileName">File</label>
|
|
1371
|
-
<input class=${K({extra:`app-dialog-input`})} id="gitResetFileName" type="text" readonly>
|
|
1372
|
-
</div>
|
|
1373
|
-
<div class="app-dialog-note is-danger">
|
|
1374
|
-
Local file content and staged changes for this path will be discarded.
|
|
1375
|
-
</div>
|
|
1376
|
-
<div class="app-dialog-actions">
|
|
1377
|
-
<button class=${G({variant:`secondary`})} id="gitResetCancel" type="button">Cancel</button>
|
|
1378
|
-
<button class=${G({variant:`danger`})} id="gitResetSubmit" type="button">Reset File</button>
|
|
1379
|
-
</div>
|
|
1380
|
-
</form>
|
|
1381
|
-
</dialog>
|
|
1382
|
-
|
|
1383
|
-
<div class="tab-lock-overlay hidden" id="tabLockOverlay" role="dialog" aria-modal="true" aria-labelledby="tabLockTitle">
|
|
1384
|
-
<div class="tab-lock-card">
|
|
1385
|
-
<span class="tab-lock-kicker">Single active tab</span>
|
|
1386
|
-
<h2 class="tab-lock-title" id="tabLockTitle">This vault is active in another tab</h2>
|
|
1387
|
-
<p class="tab-lock-copy" id="tabLockCopy">To avoid duplicate presence and chat, only one tab can stay connected at a time. Use the other tab, or take over the session here.</p>
|
|
1388
|
-
<div class="tab-lock-actions">
|
|
1389
|
-
<button type="button" class=${G({variant:`primary`,size:`lg`})} id="tabLockTakeoverBtn">Take over here</button>
|
|
1390
|
-
</div>
|
|
1391
|
-
</div>
|
|
1392
|
-
</div>
|
|
1393
|
-
|
|
1394
|
-
<div class="toast-container" id="toastContainer"></div>
|
|
1395
|
-
|
|
1396
|
-
<div class="qs-overlay" id="quickSwitcher">
|
|
1397
|
-
<div class="qs-modal">
|
|
1398
|
-
<div class="qs-input-wrap">
|
|
1399
|
-
<svg class="qs-search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
1400
|
-
<circle cx="11" cy="11" r="8"></circle>
|
|
1401
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1402
|
-
</svg>
|
|
1403
|
-
<input type="text" class="qs-input" id="quickSwitcherInput" placeholder="Search files..." autocomplete="off" spellcheck="false">
|
|
1404
|
-
<kbd class="qs-kbd">esc</kbd>
|
|
1405
|
-
</div>
|
|
1406
|
-
<div class="qs-results" id="quickSwitcherResults"></div>
|
|
1407
|
-
<div class="qs-hint" id="quickSwitcherHint">Type to search files</div>
|
|
1408
|
-
</div>
|
|
1409
|
-
</div>
|
|
1410
|
-
`}function pu(e=document){let t=e.getElementById(`appRoot`);if(!t)throw Error(`App shell root element #appRoot is missing.`);return uu(fu(),t),t}var mu=class{updateChatMessages(...e){return R.updateChatMessages.apply(this,e)}toggleChatPanel(...e){return R.toggleChatPanel.apply(this,e)}openChatPanel(...e){return R.openChatPanel.apply(this,e)}closeChatPanel(...e){return R.closeChatPanel.apply(this,e)}handleChatSubmit(...e){return R.handleChatSubmit.apply(this,e)}renderChat(...e){return R.renderChat.apply(this,e)}createChatMessageElement(...e){return R.createChatMessageElement.apply(this,e)}scrollChatToBottom(...e){return R.scrollChatToBottom.apply(this,e)}formatChatTimestamp(...e){return R.formatChatTimestamp.apply(this,e)}getChatMessageFileLabel(...e){return R.getChatMessageFileLabel.apply(this,e)}formatChatToastMessage(...e){return R.formatChatToastMessage.apply(this,e)}syncChatToggleButton(...e){return R.syncChatToggleButton.apply(this,e)}syncChatNotificationButton(...e){return R.syncChatNotificationButton.apply(this,e)}handleChatNotificationToggle(...e){return R.handleChatNotificationToggle.apply(this,e)}maybeNotifyChatMessage(...e){return R.maybeNotifyChatMessage.apply(this,e)}maybeShowBrowserChatNotification(...e){return R.maybeShowBrowserChatNotification.apply(this,e)}getCommentFileKind(...e){return St.getCommentFileKind.apply(this,e)}syncCommentChrome(...e){return St.syncCommentChrome.apply(this,e)}handleCommentSelectionChange(...e){return St.handleCommentSelectionChange.apply(this,e)}handleCommentThreadsChange(...e){return St.handleCommentThreadsChange.apply(this,e)}handleCommentEditorContentChange(...e){return St.handleCommentEditorContentChange.apply(this,e)}refreshCommentUiLayout(...e){return St.refreshCommentUiLayout.apply(this,e)}initializeExportBridge(...e){return Lt.initializeExportBridge.apply(this,e)}handleExportRequest(...e){return Lt.handleExportRequest.apply(this,e)}formatPullBackupToast(...e){return z.formatPullBackupToast.apply(this,e)}setGitOperationStatus(...e){return z.setGitOperationStatus.apply(this,e)}runGitActionWithStatus(...e){return z.runGitActionWithStatus.apply(this,e)}handleGitDiffSelection(...e){return z.handleGitDiffSelection.apply(this,e)}handleGitCommitSelection(...e){return z.handleGitCommitSelection.apply(this,e)}handleGitHistorySelection(...e){return z.handleGitHistorySelection.apply(this,e)}handleGitFileHistorySelection(...e){return z.handleGitFileHistorySelection.apply(this,e)}handleGitFilePreviewSelection(...e){return z.handleGitFilePreviewSelection.apply(this,e)}handleGitRepoChange(...e){return z.handleGitRepoChange.apply(this,e)}syncFileHistoryButton(...e){return z.syncFileHistoryButton.apply(this,e)}syncMainChrome(...e){return z.syncMainChrome.apply(this,e)}showGitDiff(...e){return z.showGitDiff.apply(this,e)}showGitCommit(...e){return z.showGitCommit.apply(this,e)}showGitHistory(...e){return z.showGitHistory.apply(this,e)}showGitFileHistory(...e){return z.showGitFileHistory.apply(this,e)}showGitFilePreview(...e){return z.showGitFilePreview.apply(this,e)}postGitAction(...e){return z.postGitAction.apply(this,e)}refreshWorkspaceAfterGitAction(...e){return z.refreshWorkspaceAfterGitAction.apply(this,e)}refreshGitAfterAction(...e){return z.refreshGitAfterAction.apply(this,e)}finalizeGitAction(...e){return z.finalizeGitAction.apply(this,e)}handleWorkspaceChangeForCurrentFile(...e){return z.handleWorkspaceChangeForCurrentFile.apply(this,e)}handleIncomingWorkspaceEvent(...e){return z.handleIncomingWorkspaceEvent.apply(this,e)}stageGitFile(...e){return z.stageGitFile.apply(this,e)}unstageGitFile(...e){return z.unstageGitFile.apply(this,e)}pushGitBranch(...e){return z.pushGitBranch.apply(this,e)}pullGitBranch(...e){return z.pullGitBranch.apply(this,e)}openGitResetDialog(...e){return z.openGitResetDialog.apply(this,e)}handleGitResetSubmit(...e){return z.handleGitResetSubmit.apply(this,e)}openGitCommitDialog(...e){return z.openGitCommitDialog.apply(this,e)}handleGitCommitSubmit(...e){return z.handleGitCommitSubmit.apply(this,e)}updateGlobalUsers(...e){return B.updateGlobalUsers.apply(this,e)}updateFileAwareness(...e){return B.updateFileAwareness.apply(this,e)}closePresencePanel(...e){return B.closePresencePanel.apply(this,e)}openPresencePanel(...e){return B.openPresencePanel.apply(this,e)}renderPresence(...e){return B.renderPresence.apply(this,e)}renderAvatars(...e){return B.renderAvatars.apply(this,e)}renderPresencePanel(...e){return B.renderPresencePanel.apply(this,e)}startFollowingUser(...e){return B.startFollowingUser.apply(this,e)}toggleFollowUser(...e){return B.toggleFollowUser.apply(this,e)}togglePresencePanel(...e){return B.togglePresencePanel.apply(this,e)}stopFollowingUser(...e){return B.stopFollowingUser.apply(this,e)}syncFollowedUser(...e){return B.syncFollowedUser.apply(this,e)}followUserCursor(...e){return B.followUserCursor.apply(this,e)}followExcalidrawUser(...e){return B.followExcalidrawUser.apply(this,e)}resolveFileClientId(...e){return B.resolveFileClientId.apply(this,e)}bindEvents(...e){return U.bindEvents.apply(this,e)}clearInitialFileBootstrap(...e){return U.clearInitialFileBootstrap.apply(this,e)}closeToolbarOverflowMenu(...e){return U.closeToolbarOverflowMenu.apply(this,e)}applyPendingPreviewRouteAnchor(...e){return U.applyPendingPreviewRouteAnchor.apply(this,e)}copyPreviewHeadingLink(...e){return U.copyPreviewHeadingLink.apply(this,e)}createPreviewHeadingLinkUrl(...e){return U.createPreviewHeadingLinkUrl.apply(this,e)}getStoredLineWrapping(...e){return U.getStoredLineWrapping.apply(this,e)}handleConnectionChange(...e){return U.handleConnectionChange.apply(this,e)}handleDocumentKeydown(...e){return U.handleDocumentKeydown.apply(this,e)}handleDocumentPointerDown(...e){return U.handleDocumentPointerDown.apply(this,e)}handlePreviewContentClick(...e){return U.handlePreviewContentClick.apply(this,e)}handleThemeChange(...e){return U.handleThemeChange.apply(this,e)}hideEditorLoading(...e){return U.hideEditorLoading.apply(this,e)}initialize(...e){return U.initialize.apply(this,e)}initializeVisualViewportBinding(...e){return U.initializeVisualViewportBinding.apply(this,e)}initializeVersionMonitoring(...e){return U.initializeVersionMonitoring.apply(this,e)}navigatePreviewHeading(...e){return U.navigatePreviewHeading.apply(this,e)}promptForVersionReload(...e){return U.promptForVersionReload.apply(this,e)}requestPreviewRouteAnchor(...e){return U.requestPreviewRouteAnchor.apply(this,e)}scheduleBacklinkRefresh(...e){return U.scheduleBacklinkRefresh.apply(this,e)}setToolbarOverflowOpen(...e){return U.setToolbarOverflowOpen.apply(this,e)}showEditorLoadError(...e){return U.showEditorLoadError.apply(this,e)}showEditorLoading(...e){return U.showEditorLoading.apply(this,e)}syncPreviewHeadingLinkButtons(...e){return U.syncPreviewHeadingLinkButtons.apply(this,e)}syncVisualViewportBounds(...e){return U.syncVisualViewportBounds.apply(this,e)}syncToolbarOverflowVisibility(...e){return U.syncToolbarOverflowVisibility.apply(this,e)}syncWrapToggle(...e){return U.syncWrapToggle.apply(this,e)}toggleToolbarOverflowMenu(...e){return U.toggleToolbarOverflowMenu.apply(this,e)}toggleLineWrapping(...e){return U.toggleLineWrapping.apply(this,e)}applySidebarVisibility(...e){return U.applySidebarVisibility.apply(this,e)}closeSidebarOnMobile(...e){return U.closeSidebarOnMobile.apply(this,e)}isMobileViewport(...e){return U.isMobileViewport.apply(this,e)}restoreSidebarState(...e){return U.restoreSidebarState.apply(this,e)}setSidebarTab(...e){return U.setSidebarTab.apply(this,e)}setSidebarVisibility(...e){return U.setSidebarVisibility.apply(this,e)}toggleSidebar(...e){return U.toggleSidebar.apply(this,e)}getCurrentUser(...e){return U.getCurrentUser.apply(this,e)}getCurrentUserName(...e){return U.getCurrentUserName.apply(this,e)}getStoredUserName(...e){return U.getStoredUserName.apply(this,e)}handleDisplayNameSubmit(...e){return U.handleDisplayNameSubmit.apply(this,e)}isIdentityManagedByAuth(...e){return U.isIdentityManagedByAuth.apply(this,e)}openDisplayNameDialog(...e){return U.openDisplayNameDialog.apply(this,e)}promptForDisplayNameIfNeeded(...e){return U.promptForDisplayNameIfNeeded.apply(this,e)}syncCurrentUserName(...e){return U.syncCurrentUserName.apply(this,e)}syncIdentityManagementUi(...e){return U.syncIdentityManagementUi.apply(this,e)}applyMarkdownToolbarAction(...e){return U.applyMarkdownToolbarAction.apply(this,e)}copyCurrentLink(...e){return U.copyCurrentLink.apply(this,e)}closeMarkdownBlockMenu(...e){return U.closeMarkdownBlockMenu.apply(this,e)}getActiveMarkdownBlockAction(...e){return U.getActiveMarkdownBlockAction.apply(this,e)}getMarkdownBlockMenuPopover(...e){return U.getMarkdownBlockMenuPopover.apply(this,e)}handleEditorImageInsert(...e){return U.handleEditorImageInsert.apply(this,e)}handleMarkdownToolbarClick(...e){return U.handleMarkdownToolbarClick.apply(this,e)}handleMarkdownToolbarDocumentPointerDown(...e){return U.handleMarkdownToolbarDocumentPointerDown.apply(this,e)}handleMarkdownToolbarKeydown(...e){return U.handleMarkdownToolbarKeydown.apply(this,e)}handleToolbarImageInsert(...e){return U.handleToolbarImageInsert.apply(this,e)}isMarkdownBlockMenuOpen(...e){return U.isMarkdownBlockMenuOpen.apply(this,e)}openMarkdownBlockMenu(...e){return U.openMarkdownBlockMenu.apply(this,e)}positionMarkdownBlockMenu(...e){return U.positionMarkdownBlockMenu.apply(this,e)}renderMarkdownBlockMenuPopover(...e){return U.renderMarkdownBlockMenuPopover.apply(this,e)}pickImageFile(...e){return U.pickImageFile.apply(this,e)}renderMarkdownToolbar(...e){return U.renderMarkdownToolbar.apply(this,e)}runEditorCommand(...e){return U.runEditorCommand.apply(this,e)}setActiveMarkdownBlockAction(...e){return U.setActiveMarkdownBlockAction.apply(this,e)}syncMarkdownToolbarBlockUi(...e){return U.syncMarkdownToolbarBlockUi.apply(this,e)}toggleMarkdownBlockMenu(...e){return U.toggleMarkdownBlockMenu.apply(this,e)}handleTabActivated(...e){return U.handleTabActivated.apply(this,e)}handleTabBlocked(...e){return U.handleTabBlocked.apply(this,e)}handleTabTakeover(...e){return U.handleTabTakeover.apply(this,e)}hideTabLockOverlay(...e){return U.hideTabLockOverlay.apply(this,e)}showTabLockOverlay(...e){return U.showTabLockOverlay.apply(this,e)}isExcalidrawFile(...e){return W.isExcalidrawFile.apply(this,e)}isBaseFile(...e){return W.isBaseFile.apply(this,e)}isDrawioFile(...e){return W.isDrawioFile.apply(this,e)}isImageFile(...e){return W.isImageFile.apply(this,e)}isMermaidFile(...e){return W.isMermaidFile.apply(this,e)}isPlantUmlFile(...e){return W.isPlantUmlFile.apply(this,e)}createDiagramPreviewDocument(...e){return W.createDiagramPreviewDocument.apply(this,e)}getPreviewSource(...e){return W.getPreviewSource.apply(this,e)}getStaticPreviewDocument(...e){return W.getStaticPreviewDocument.apply(this,e)}setStaticPreviewDocument(...e){return W.setStaticPreviewDocument.apply(this,e)}clearStaticPreviewDocument(...e){return W.clearStaticPreviewDocument.apply(this,e)}supportsFileHistory(...e){return W.supportsFileHistory.apply(this,e)}getDisplayName(...e){return W.getDisplayName.apply(this,e)}resetPreviewMode(...e){return W.resetPreviewMode.apply(this,e)}syncFileChrome(...e){return W.syncFileChrome.apply(this,e)}handleLayoutViewRequest(...e){return W.handleLayoutViewRequest.apply(this,e)}renderExcalidrawFilePreview(...e){return W.renderExcalidrawFilePreview.apply(this,e)}renderDrawioFilePreview(...e){return W.renderDrawioFilePreview.apply(this,e)}renderImageFilePreview(...e){return W.renderImageFilePreview.apply(this,e)}renderBaseFilePreview(...e){return W.renderBaseFilePreview.apply(this,e)}renderTextFilePreview(...e){return W.renderTextFilePreview.apply(this,e)}createResizeHandler(...e){return W.createResizeHandler.apply(this,e)}initializePreviewLayoutObserver(...e){return W.initializePreviewLayoutObserver.apply(this,e)}schedulePreviewLayoutSync(...e){return W.schedulePreviewLayoutSync.apply(this,e)}handleEditorScrollActivityChange(...e){return W.handleEditorScrollActivityChange.apply(this,e)}handleHashChange(...e){return W.handleHashChange.apply(this,e)}showEmptyState(...e){return W.showEmptyState.apply(this,e)}showDiffState(...e){return W.showDiffState.apply(this,e)}openFile(...e){return W.openFile.apply(this,e)}cleanupSession(...e){return W.cleanupSession.apply(this,e)}handleWikiLinkClick(...e){return W.handleWikiLinkClick.apply(this,e)}normalizeNewWikiFilePath(...e){return W.normalizeNewWikiFilePath.apply(this,e)}createAndOpenFile(...e){return W.createAndOpenFile.apply(this,e)}handleFileSelection(...e){return W.handleFileSelection.apply(this,e)}constructor(){pu(document),this.elements=xt(document),this.runtimeConfig=D(),this.stateStore=new bt,this.navigation=new ri,this.preferences=new ai({chatNotificationsKey:`collabmd-chat-notifications-enabled`,lineWrappingKey:`collabmd-editor-line-wrap`,sidebarVisibleKey:`collabmd-sidebar-visible`,userNameKey:`collabmd-user-name`}),this.notifications=new ii,this.backlinksApiClient=li,this.gitApiClient=pi,this.plantUmlApiClient=mi,this.vaultApiClient=w,this._session=null,this._hasPromptedForDisplayName=!1,this._backlinkRefreshTimer=null,this._pendingPreviewLayoutSync=!1,this._previewHydrationPaused=!1,this._previewLayoutResizeObserver=null,this._previewLayoutSyncTimer=null,this._reloadPromptShown=!1,this._staticPreviewDocument=null,this.pendingGitResetPath=null,this.chatTimeFormatter=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),this.chatNotificationsEnabled=this.preferences.getChatNotificationsEnabled(),this.chatNotificationPermission=this.notifications.getPermission(),this.lobbyChatMessageMaxLength=280,this.quickSwitcher=null,this.quickSwitcherModulePromise=null,this.fileExplorerReadyPromise=Promise.resolve(),this.mobileBreakpointQuery=window.matchMedia(`(max-width: 768px)`),this.pendingWorkspaceRequestIds=new Set,this._fileOpenPerf=null,this.versionMonitor=new ci({currentBuildId:this.runtimeConfig.build?.id,onUpdateAvailable:e=>this.promptForVersionReload(e),runtimeConfig:this.runtimeConfig}),this.lobby=new ni({preferredUserName:this.getStoredUserName(),onChange:e=>this.updateGlobalUsers(e),onChatChange:(e,t)=>this.updateChatMessages(e,t)}),this.workspaceSync=new Mi({onTreeChange:(e,t={})=>{let n=this.fileExplorerReady;this.fileExplorer.setTree(e,t),this.fileExplorerReady=!0,!n&&this.isTabActive&&this.handleHashChange()},onWorkspaceEvent:e=>{this.handleIncomingWorkspaceEvent(e)}}),this.toastController=new dl(this.elements.toastContainer),this.chatToastController=new dl(this.elements.chatToastContainer),this.fileExplorer=new mc({mobileBreakpointQuery:this.mobileBreakpointQuery,onFileDelete:()=>this.navigation.navigateToFile(null),onFileSelect:e=>this.handleFileSelection(e,{closeSidebarOnMobile:!0}),pendingWorkspaceRequestIds:this.pendingWorkspaceRequestIds,toastController:this.toastController}),this.gitPanel=new Kc({enabled:this.runtimeConfig.gitEnabled!==!1,gitApiClient:this.gitApiClient,onCommitStaged:()=>this.openGitCommitDialog(),onOpenPullBackup:e=>e&&this.navigation.navigateToFile(e),onPullBranch:()=>this.pullGitBranch(),onPushBranch:()=>this.pushGitBranch(),onRepoChange:(e,t)=>this.handleGitRepoChange(e,t),onResetFile:(e,{scope:t})=>this.openGitResetDialog(e,{scope:t}),onSelectCommit:(e,{path:t})=>this.handleGitCommitSelection(e,{closeSidebarOnMobile:!0,path:t}),onSelectDiff:(e,{scope:t})=>this.handleGitDiffSelection(e,{closeSidebarOnMobile:!0,scope:t}),onStageFile:(e,{scope:t})=>this.stageGitFile(e,{scope:t}),onUnstageFile:(e,{scope:t})=>this.unstageGitFile(e,{scope:t}),onViewAllDiff:()=>this.handleGitDiffSelection(null,{closeSidebarOnMobile:!0,scope:`all`}),searchInput:this.elements.gitSearchInput,toastController:this.toastController}),this.outlineController=new Jc({mobileBreakpointQuery:this.mobileBreakpointQuery,onNavigateToHeading:({sourceLine:e})=>{Number.isFinite(e)&&(this.scrollSyncController.suspendSync(250),this.session?.scrollToLine(e,0))},onWillOpen:()=>this.commentUi?.closeDrawer()}),this.videoEmbed=new _l({previewElement:this.elements.previewContent}),this.basesPreview=new Ka({getActiveFilePath:()=>this.currentFilePath,getSession:()=>this.session,onOpenFile:e=>e&&this.navigation.navigateToFile(e),previewElement:this.elements.previewContent,replaceBaseSource:({path:e,source:t})=>{e&&e===this.currentFilePath&&this.session?.replaceText?.(t)},toastController:this.toastController,vaultApiClient:this.vaultApiClient}),this.imageLightbox=new El({previewElement:this.elements.previewContent}),this.previewRenderer=new rt({getContent:()=>this.getPreviewSource(),getFileList:()=>this.fileExplorer.flatDocumentFiles,getWikiLinkAutoCreate:()=>this.runtimeConfig.wikiLinkAutoCreate!==!1,loadFileSource:async e=>{let t=await this.vaultApiClient.readFile(e);return String(t?.content??``)},getSourceFilePath:()=>this.currentFilePath,onAfterRenderCommit:(e,t)=>{this.recordFileOpenMetric(`preview_committed`,{chars:t?.chars??0,renderVersion:t?.renderVersion??0}),this.videoEmbed.reconcileEmbeds(this.elements.previewContent),this.videoEmbed.syncLayout(),this.basesPreview.reconcileEmbeds(this.elements.previewContent),this.drawioEmbed.reconcileEmbeds(this.elements.previewContent),this.drawioEmbed.syncLayout(),this.excalidrawEmbed.reconcileEmbeds(this.elements.previewContent,{isLargeDocument:t.isLargeDocument}),this.excalidrawEmbed.syncLayout(),this.scrollSyncController.setLargeDocumentMode(t.isLargeDocument),this.syncPreviewHeadingLinkButtons(),this.applyPendingPreviewRouteAnchor({behavior:`auto`,clearMissing:!0}),this.schedulePreviewLayoutSync({delayMs:0}),this.refreshCommentUiLayout()},onBeforeRenderCommit:()=>{this.videoEmbed.detachForCommit(),this.drawioEmbed.detachForCommit(),this.excalidrawEmbed.detachForCommit()},onPreviewLayoutChange:()=>{this.scrollSyncController.invalidatePreviewBlocks(),this.applyPendingPreviewRouteAnchor({behavior:`auto`,clearMissing:!1}),this.schedulePreviewLayoutSync({delayMs:0}),this.refreshCommentUiLayout()},onRenderComplete:()=>{this.videoEmbed.syncLayout(),this.drawioEmbed.syncLayout(),this.excalidrawEmbed.syncLayout(),this.applyPendingPreviewRouteAnchor({allowExpired:!0,behavior:`auto`,clearMissing:!0}),this.schedulePreviewLayoutSync({delayMs:0}),this.refreshCommentUiLayout()},outlineController:this.outlineController,plantUmlRenderClient:this.plantUmlApiClient,previewContainer:this.elements.previewContainer,previewElement:this.elements.previewContent,toastController:this.toastController}),this.themeController=new ul({onChange:e=>this.handleThemeChange(e)}),this.layoutController=new qc({mobileBreakpointQuery:this.mobileBreakpointQuery,onMeasureEditor:()=>this.session?.requestMeasure(),onViewRequest:e=>this.handleLayoutViewRequest(e)}),this.scrollSyncController=new sl({getEditorLineNumber:()=>this.session?.getTopVisibleLineNumber(.35)??1,onEditorScrollActivityChange:e=>this.handleEditorScrollActivityChange(e),previewContainer:this.elements.previewContainer,previewElement:this.elements.previewContent,scrollEditorToLine:(e,t)=>this.session?.scrollToLine(e,t)}),this.backlinksPanel=new Ni({headerPanelElement:this.elements.backlinksHeaderPanel,inlinePanelElement:this.elements.backlinksInlinePanel,loadBacklinks:(e,t={})=>this.backlinksApiClient.readBacklinks(e,t),onFileSelect:e=>this.handleFileSelection(e,{closeSidebarOnMobile:!0}),panelElement:this.elements.backlinksPanel}),this.excalidrawEmbed=new Gs({getLocalUser:()=>this.lobby.getLocalUser(),getTheme:()=>this.themeController.getTheme(),onOpenFile:e=>e&&this.navigation.navigateToFile(e),onToggleQuickSwitcher:()=>{this.toggleQuickSwitcher()},previewContainer:this.elements.previewContainer,previewElement:this.elements.previewContent,toastController:this.toastController}),this.drawioEmbed=new Ns({getLocalUser:()=>this.lobby.getLocalUser(),getTheme:()=>this.themeController.getTheme(),onOpenFile:e=>e&&this.navigation.navigateToFile(e),onOpenTextFile:e=>e&&this.navigation.navigateToFile(e,{drawioMode:`text`}),onToggleQuickSwitcher:()=>{this.toggleQuickSwitcher()},previewContainer:this.elements.previewContainer,previewElement:this.elements.previewContent,toastController:this.toastController}),this.commentUi=new Ts({commentSelectionButton:this.elements.commentSelectionButton,commentsDrawer:this.elements.commentsDrawer,commentsDrawerEmpty:this.elements.commentsDrawerEmpty,commentsDrawerList:this.elements.commentsDrawerList,commentsToggleButton:this.elements.commentsToggleButton,editorContainer:this.elements.editorContainer,onWillOpenDrawer:()=>this.outlineController.close(),previewContainer:this.elements.previewContainer,previewElement:this.elements.previewContent,onCreateThread:({anchor:e,body:t})=>this.session?.createCommentThread({anchor:e,body:t}),onNavigateToLine:e=>{this.scrollSyncController.suspendSync(250),this.session?.scrollToLine(e,.2)},onReplyToThread:(e,t)=>this.session?.replyToCommentThread(e,t),onToggleReaction:(e,t,n)=>this.session?.toggleCommentReaction(e,t,n),onResolveThread:e=>this.session?.deleteCommentThread(e)}),this.workspacePreviewController=new mt({backlinksPanel:this.backlinksPanel,basesPreview:this.basesPreview,drawioEmbed:this.drawioEmbed,elements:this.elements,excalidrawEmbed:this.excalidrawEmbed,getDisplayName:e=>this.getDisplayName(e),getSession:()=>this.session,isBaseFile:e=>this.isBaseFile(e),isDrawioFile:e=>this.isDrawioFile(e),isExcalidrawFile:e=>this.isExcalidrawFile(e),isImageFile:e=>this.isImageFile(e),isMermaidFile:e=>this.isMermaidFile(e),isPlantUmlFile:e=>this.isPlantUmlFile(e),layoutController:this.layoutController,outlineController:this.outlineController,previewRenderer:this.previewRenderer,schedulePreviewLayoutSync:e=>this.schedulePreviewLayoutSync(e),scrollSyncController:this.scrollSyncController,videoEmbed:this.videoEmbed}),this.wikiLinkFileController=new pt({getFileList:()=>this.fileExplorer.flatDocumentFiles,navigation:this.navigation,refreshExplorer:()=>this.fileExplorer.refresh(),toastController:this.toastController,vaultApiClient:this.vaultApiClient,wikiLinkAutoCreate:this.runtimeConfig.wikiLinkAutoCreate!==!1}),this.gitDiffView=new Pc({gitApiClient:this.gitApiClient,onBackToHistory:({historyFilePath:e}={})=>{if(e){this.navigation.navigateToGitFileHistory({filePath:e});return}this.navigation.navigateToGitHistory()},onCommitStaged:()=>this.openGitCommitDialog(),onOpenFile:e=>e&&this.navigation.navigateToFile(e),onStageFile:(e,{scope:t})=>this.stageGitFile(e,{scope:t}),onUnstageFile:(e,{scope:t})=>this.unstageGitFile(e,{scope:t}),toastController:this.toastController}),this.fileHistoryView=new Sc({diffRenderer:this.gitDiffView,gitApiClient:this.gitApiClient,onOpenCommitDiff:(e,{historyFilePath:t,path:n})=>this.handleGitCommitSelection(e,{closeSidebarOnMobile:!1,historyFilePath:t,path:n}),onOpenFile:e=>e&&this.navigation.navigateToFile(e),onOpenPreview:({hash:e,path:t,currentFilePath:n})=>this.handleGitFilePreviewSelection({hash:e,path:t,currentFilePath:n}),onOpenWorkspaceDiff:e=>this.handleGitDiffSelection(e,{closeSidebarOnMobile:!1,scope:`all`}),toastController:this.toastController}),this.tabActivityLock=new Si({onActivated:({takeover:e})=>this.handleTabActivated({takeover:e}),onBlocked:()=>this.handleTabBlocked({reason:`active-elsewhere`}),onStolen:()=>this.handleTabBlocked({reason:`taken-over`})}),this.workspaceCoordinator=new yt({attachEditorScroller:e=>this.scrollSyncController.attachEditorScroller(e),beginDocumentLoad:()=>this.previewRenderer.beginDocumentLoad(),cleanupAfterSessionDestroy:()=>{this.scrollSyncController.setLargeDocumentMode(!1),this.scrollSyncController.invalidatePreviewBlocks(),this.outlineController.cleanup(),this.followedCursorSignature=``,clearTimeout(this._backlinkRefreshTimer)},createEditorSession:(e,t)=>new e({editorContainer:this.elements.editorContainer,getFileList:t.getFileList,initialTheme:t.theme,lineInfoElement:this.elements.lineInfo,lineWrappingEnabled:t.lineWrappingEnabled,localUser:t.localUser,onImagePaste:t.onImagePaste,onAwarenessChange:t.onAwarenessChange,onCommentsChange:t.onCommentsChange,onConnectionChange:t.onConnectionChange,onContentChange:t.onContentChange,onSelectionChange:t.onSelectionChange,preferredUserName:t.preferredUserName}),getDisplayName:e=>this.getDisplayName(e),getFileList:()=>this.fileExplorer.flatDocumentFiles,getLineWrappingEnabled:()=>this.getStoredLineWrapping(),getLocalUser:()=>this.lobby.getLocalUser(),getStoredUserName:()=>this.getStoredUserName(),getTheme:()=>this.themeController.getTheme(),isBaseFile:e=>this.isBaseFile(e),isDrawioFile:e=>this.isDrawioFile(e),isExcalidrawFile:e=>this.isExcalidrawFile(e),isImageFile:e=>this.isImageFile(e),isMermaidFile:e=>this.isMermaidFile(e),isPlantUmlFile:e=>this.isPlantUmlFile(e),isTabActive:()=>this.isTabActive,loadBootstrapContent:async e=>{let t=await this.vaultApiClient.readFile(e);return typeof t?.content==`string`?t.content:null},loadEditorSessionClass:()=>this.loadEditorSessionClass(),loadBacklinks:e=>this.backlinksPanel.load(e),onBeforeFileOpen:()=>{this.session=null,this.commentUi.attachSession(null),this.layoutController.reset(),this.resetPreviewMode(),this.elements.emptyState?.classList.add(`hidden`),this.elements.editorPage?.classList.remove(`hidden`),this.elements.diffPage?.classList.add(`hidden`),this.clearInitialFileBootstrap()},onConnectionChange:e=>this.handleConnectionChange(e),onContentChange:({isBase:e,isMermaid:t,isPlantUml:n})=>{if(this.handleCommentEditorContentChange(),e){this.renderBaseFilePreview(this.currentFilePath,{source:this.session?.getText?.()??``});return}this.previewRenderer.queueRender(),!t&&!n&&this.scheduleBacklinkRefresh()},onCommentsChange:e=>this.handleCommentThreadsChange(e),onFileAwarenessChange:e=>this.updateFileAwareness(e),onFileOpenError:()=>{this.showEditorLoadError(),this.syncWrapToggle(),this.toastController.show(`Failed to initialize editor`)},onFileOpenReady:()=>{this.hideEditorLoading()},onSelectionChange:e=>this.handleCommentSelectionChange(e),onImagePaste:e=>this.handleEditorImageInsert(e),onFileOpenMetric:(e,t)=>this.recordFileOpenMetric(e,t),onSessionAssigned:e=>{this.session=e,this.commentUi.attachSession(e)},onRenderDrawioPreview:e=>this.renderDrawioFilePreview(e),onRenderBasePreview:e=>this.renderBaseFilePreview(e),onRenderExcalidrawPreview:e=>this.renderExcalidrawFilePreview(e),onRenderImagePreview:e=>this.renderImageFilePreview(e),onSyncWrapToggle:()=>this.syncWrapToggle(),onUpdateActiveFile:e=>this.fileExplorer.setActiveFile(e),onUpdateCurrentFile:e=>{this.currentFilePath=e},onUpdateLobbyCurrentFile:e=>this.lobby.setCurrentFile(e),onUpdateVisibleChrome:(e,{displayName:t})=>{this.syncFileChrome(e,{drawioMode:this.currentDrawioMode,preferPreviewForBase:this.isBaseFile(e)}),this.syncCommentChrome(e),this.syncFileHistoryButton({filePath:e,mode:`editor`}),this.elements.activeFileName&&(this.elements.activeFileName.textContent=t)},onViewModeReset:()=>this.resetPreviewMode(),renderPresence:()=>this.renderPresence(),scrollContainerForSession:e=>e.getScrollContainer(),shouldUseDrawioPreview:()=>!!this.runtimeConfig.drawioBaseUrl,showEditorLoading:()=>this.showEditorLoading(),stateStore:this.stateStore}),this.workspaceRouteController=new ot({backlinksPanel:this.backlinksPanel,clearInitialFileBootstrap:()=>this.clearInitialFileBootstrap(),clearStaticPreviewDocument:()=>this.clearStaticPreviewDocument(),closeSidebarOnMobile:()=>this.closeSidebarOnMobile(),drawioEmbed:this.drawioEmbed,elements:this.elements,excalidrawEmbed:this.excalidrawEmbed,fileHistoryView:this.fileHistoryView,fileExplorer:this.fileExplorer,getIsTabActive:()=>this.isTabActive,getSessionLoadToken:()=>this.sessionLoadToken,gitDiffView:this.gitDiffView,gitPanel:this.gitPanel,imageLightbox:this.imageLightbox,layoutController:this.layoutController,lobby:this.lobby,navigation:this.navigation,previewRenderer:this.previewRenderer,requestPreviewRouteAnchor:(e,t)=>this.requestPreviewRouteAnchor(e,t),renderAvatars:()=>this.renderAvatars(),renderPresence:()=>this.renderPresence(),resetPreviewMode:()=>this.resetPreviewMode(),scrollSyncController:this.scrollSyncController,setCurrentFilePath:e=>{this.currentFilePath=e,e||(this.commentUi.setCurrentFile(null,{supported:!1}),this.handleCommentThreadsChange([]),this.handleCommentSelectionChange(null))},setSession:e=>{this.session=e,this.commentUi.attachSession(e)},setSessionLoadToken:e=>{this.sessionLoadToken=e},setSidebarTab:e=>this.setSidebarTab(e),setSidebarVisibility:e=>this.setSidebarVisibility(e),showGitCommit:e=>this.showGitCommit(e),showGitDiff:e=>this.showGitDiff(e),showGitFileHistory:e=>this.showGitFileHistory(e),showGitFilePreview:e=>this.showGitFilePreview(e),showGitHistory:()=>this.showGitHistory(),syncMainChrome:e=>this.syncMainChrome(e),videoEmbed:this.videoEmbed,workspaceCoordinator:this.workspaceCoordinator}),this.chatNotificationPermission!==`granted`&&(this.chatNotificationsEnabled=!1)}get session(){return this._session}set session(e){this._session=e}get currentFilePath(){return this.stateStore.get(`currentFilePath`)}set currentFilePath(e){this.stateStore.set(`currentFilePath`,e)}get currentDrawioMode(){return this.stateStore.get(`currentDrawioMode`)}set currentDrawioMode(e){this.stateStore.set(`currentDrawioMode`,e??null)}get globalUsers(){return this.stateStore.get(`globalUsers`)}set globalUsers(e){this.stateStore.set(`globalUsers`,e)}get connectionState(){return this.stateStore.get(`connectionState`)}set connectionState(e){this.stateStore.set(`connectionState`,e)}get sessionLoadToken(){return this.stateStore.get(`sessionLoadToken`)}set sessionLoadToken(e){this.stateStore.set(`sessionLoadToken`,e)}get connectionHelpShown(){return this.stateStore.get(`connectionHelpShown`)}set connectionHelpShown(e){this.stateStore.set(`connectionHelpShown`,e)}get chatMessages(){return this.stateStore.get(`chatMessages`)}set chatMessages(e){this.stateStore.set(`chatMessages`,e)}get chatMessageIds(){return this.stateStore.get(`chatMessageIds`)}set chatMessageIds(e){this.stateStore.set(`chatMessageIds`,e)}get chatUnreadCount(){return this.stateStore.get(`chatUnreadCount`)}set chatUnreadCount(e){this.stateStore.set(`chatUnreadCount`,e)}get chatIsOpen(){return this.stateStore.get(`chatIsOpen`)}set chatIsOpen(e){this.stateStore.set(`chatIsOpen`,e)}get chatInitialSyncComplete(){return this.stateStore.get(`chatInitialSyncComplete`)}set chatInitialSyncComplete(e){this.stateStore.set(`chatInitialSyncComplete`,e)}get isTabActive(){return this.stateStore.get(`isTabActive`)}set isTabActive(e){this.stateStore.set(`isTabActive`,e)}get fileExplorerReady(){return this.stateStore.get(`fileExplorerReady`)}set fileExplorerReady(e){this.stateStore.set(`fileExplorerReady`,e)}get gitRepoAvailable(){return this.stateStore.get(`gitRepoAvailable`)}set gitRepoAvailable(e){this.stateStore.set(`gitRepoAvailable`,e)}get activeSidebarTab(){return this.stateStore.get(`activeSidebarTab`)}set activeSidebarTab(e){this.stateStore.set(`activeSidebarTab`,e)}get presencePanelOpen(){return this.stateStore.get(`presencePanelOpen`)}set presencePanelOpen(e){this.stateStore.set(`presencePanelOpen`,e)}get followedUserClientId(){return this.stateStore.get(`followedUserClientId`)}set followedUserClientId(e){this.stateStore.set(`followedUserClientId`,e)}get followedCursorSignature(){return this.stateStore.get(`followedCursorSignature`)}set followedCursorSignature(e){this.stateStore.set(`followedCursorSignature`,e)}publishFileOpenPerf(){typeof window>`u`||(window.__COLLABMD_PERF__??={},window.__COLLABMD_PERF__.fileOpen=this._fileOpenPerf?{...this._fileOpenPerf,details:{...this._fileOpenPerf.details},marks:{...this._fileOpenPerf.marks}}:null)}recordFileOpenMetric(e,t={}){if(e===`open_started`){this._fileOpenPerf={details:{filePath:t.filePath||this.currentFilePath||``,loadToken:t.loadToken??0},marks:{open_started:performance.now()}},this.publishFileOpenPerf();return}this._fileOpenPerf&&(t.loadToken??this._fileOpenPerf.details.loadToken)===this._fileOpenPerf.details.loadToken&&(this._fileOpenPerf.marks[e]=performance.now(),t.filePath&&(this._fileOpenPerf.details.filePath=t.filePath),Object.entries(t).forEach(([e,t])=>{e===`filePath`||e===`loadToken`||(this._fileOpenPerf.details[e]=t)}),this.publishFileOpenPerf())}loadEditorSessionClass(){return this._editorSessionModulePromise||=e(()=>import(`./editor-session-C1scHGLl.js`).then(e=>e.EditorSession),__vite__mapDeps([27,1,28,29,30,31,32,33,34,35,36,37,38,39,26]),import.meta.url),this._editorSessionModulePromise}scheduleEditorSessionPrewarm({timeout:e=1500}={}){if(this._editorSessionModulePromise||this._editorSessionPrewarmHandle)return;let t=()=>{this._editorSessionPrewarmHandle=null,this.loadEditorSessionClass()};if(typeof window.requestIdleCallback==`function`){this._editorSessionPrewarmHandle=window.requestIdleCallback(t,{timeout:e});return}this._editorSessionPrewarmHandle=window.setTimeout(t,0)}loadQuickSwitcherController(){return e(()=>import(`./quick-switcher-controller-B1erSgJ1.js`).then(e=>e.QuickSwitcherController),__vite__mapDeps([40,25,26]),import.meta.url)}async ensureQuickSwitcher(){return it(this)}async toggleQuickSwitcher(){return at(this)}};async function hu(){await C(),new mu().initialize()}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{hu()},{once:!0}):hu();
|