@forsion/unit 2.13.4 → 2.13.6
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 +2 -2
- package/main.mjs +129 -10
- package/package.json +1 -1
- package/release.json +6 -5
- package/web/assets/ArtificialView-DHqb9CTL.js +1 -0
- package/web/assets/AutomationBuilder-CzBKmOiw.js +1 -0
- package/web/assets/CalendarConfigView-Blw47NCs.js +1 -0
- package/web/assets/CalendarSide-CFSzme3H.js +1 -0
- package/web/assets/CalendarView-B8sQfgZt.js +3 -0
- package/web/assets/CalendarView-t91KpUG7.css +1 -0
- package/web/assets/CapabilityMenu-Dzn6RbB1.js +1 -0
- package/web/assets/Chrome-owLewFu4.js +1 -0
- package/web/assets/{CodeView-GZ0BAgoW.js → CodeView-E18NDilX.js} +3 -3
- package/web/assets/CtxMenuButtons-CAiwQkOK.js +1 -0
- package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
- package/web/assets/DashboardGridView-RoVFSkNO.css +1 -0
- package/web/assets/EventCard-D9uQe7g4.js +1 -0
- package/web/assets/ExcalidrawCanvas-BSOERegJ.js +1 -0
- package/web/assets/ExcalidrawCanvas-BgcFPMpU.css +1 -0
- package/web/assets/FloatingToc-iK08Qpjc.js +1 -0
- package/web/assets/{GitCloneDialog-Bj9G3o-n.css → GitCloneDialog-DOxZk2K0.css} +1 -1
- package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
- package/web/assets/HomepageView-BCqFe1Ym.js +4 -0
- package/web/assets/HomepageView-Bx8FbWlY.css +1 -0
- package/web/assets/ImageStudioPanels-DdwihAkT.js +3 -0
- package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
- package/web/assets/InlineAiPanel-CjYOW0_0.js +1 -0
- package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
- package/web/assets/{MarkdownBlock-DQTuoen3.css → MarkdownBlock-Cqfk5DhC.css} +1 -1
- package/web/assets/MarkdownBlock-DjsGkPZ_.js +58 -0
- package/web/assets/{ModelPill-CzdNh7Mt.css → ModelPill-BiUsuhy3.css} +1 -1
- package/web/assets/ModelPill-DgyXBsL9.js +2 -0
- package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
- package/web/assets/MuseView-BVDlmM6i.js +7 -0
- package/web/assets/{PageHistoryPanel-Bn4-XmdK.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
- package/web/assets/{PdfAnnotator-Cq8cklTz.js → PdfAnnotator-bdB9evsY.js} +3 -3
- package/web/assets/PenRow-DCOIGlfY.js +1 -0
- package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
- package/web/assets/PluginToolCard-BmTRr5JT.css +1 -0
- package/web/assets/ProductView-l5Q7uBy6.js +1 -0
- package/web/assets/SettingsPage-fjxfS_Mt.js +3 -0
- package/web/assets/StudioGuestSurface-360CWUwf.js +1 -0
- package/web/assets/TodoListView-BsPt2GUU.js +1 -0
- package/web/assets/Tooltip-CuXpWtdJ.js +1 -0
- package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
- package/web/assets/UnifiedPage-CTmQpf2T.css +1 -0
- package/web/assets/{ViewSelectionBar-35x8TiLA.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
- package/web/assets/appStore-BskcSDl6.js +455 -0
- package/web/assets/appStore-iy8_Tmac.css +1 -0
- package/web/assets/arrow-up-right-DEykpgsH.js +1 -0
- package/web/assets/{artificial-BzLFkChP.css → artificial-BubVxExB.css} +1 -1
- package/web/assets/astryxBridge-B2IZdPvo.js +69 -0
- package/web/assets/astryxBridge-djzCiy4v.css +1 -0
- package/web/assets/automationListSource-Cm09JKkK.js +1 -0
- package/web/assets/boardSurface-Dv-aVaUJ.js +1 -0
- package/web/assets/calendarNavStore-FKStA7Hh.js +1 -0
- package/web/assets/canvasPrefs-CMulOS0k.js +1 -0
- package/web/assets/chatBoxSurface-BR_G6cxG.js +1 -0
- package/web/assets/chevron-up-C_EDOZzI.js +1 -0
- package/web/assets/{client-CaivGZFR.js → client-DD5czSuF.js} +5 -5
- package/web/assets/code-xml-vTB4LtTf.js +1 -0
- package/web/assets/{codeStudioStore-DhyMazGT.js → codeStudioStore-OswE1_s0.js} +8 -8
- package/web/assets/codingNavigation-BrkLENBZ.css +1 -0
- package/web/assets/contextMenuSurface-DqdYEGuH.js +1 -0
- package/web/assets/copy-plus-CVHqDNny.js +1 -0
- package/web/assets/create-DZWy4zBR.js +14 -0
- package/web/assets/dashboardSurface-Co4byEQm.js +1 -0
- package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
- package/web/assets/deskCapture-BfTzH2aO.js +1 -0
- package/web/assets/{diff2html-Daje9Kkm.js → diff2html-0MkNy2ws.js} +2 -2
- package/web/assets/{docx-preview-CABR7n30.js → docx-preview-CwNWZegI.js} +1 -1
- package/web/assets/draft-DTzuTatQ.js +2 -0
- package/web/assets/drawingStore-BD5m2eqn.js +7 -0
- package/web/assets/file-down-Cjo_T6By.js +1 -0
- package/web/assets/floatingTocSurface-D3IIVNnq.js +1 -0
- package/web/assets/foldActions-utwZpRrA.js +1 -0
- package/web/assets/folder-DiaFWdCg.js +1 -0
- package/web/assets/folder-minus-DUEOcs12.js +1 -0
- package/web/assets/folder-plus-Cmhq0GcR.js +1 -0
- package/web/assets/gestures-Bx9M0le5.js +1 -0
- package/web/assets/git-branch-DzGWffyD.js +1 -0
- package/web/assets/homeCardStatus-NAk4A77P.js +1 -0
- package/web/assets/i18n-CAf4PT1o.css +1 -0
- package/web/assets/i18n.generated-D4-Wu9Wh.js +15 -0
- package/web/assets/imageStudio-CwG21Bat.css +1 -0
- package/web/assets/imageStudio-D67oElIb.js +4 -0
- package/web/assets/index-3VWZ1rsL.js +13 -0
- package/web/assets/index-58wBjkHy.js +3 -0
- package/web/assets/index-B9_zH7f5.js +1 -0
- package/web/assets/index-BQrMYjou.js +1 -0
- package/web/assets/index-BWrWMYua.js +1 -0
- package/web/assets/index-BdLJBf4-.js +1 -0
- package/web/assets/index-Bf3W92Hb.js +1 -0
- package/web/assets/index-BjmPaLFA.js +1 -0
- package/web/assets/index-Bv-vJTzF.js +7 -0
- package/web/assets/index-C7yb62gg.js +1 -0
- package/web/assets/index-C9gBBMYv.js +1 -0
- package/web/assets/index-CiQ59Kib.js +1 -0
- package/web/assets/{index-gt5JBIFf.js → index-CzTUjEMt.js} +2 -2
- package/web/assets/index-D4Qx6o3E.js +1 -0
- package/web/assets/index-DDBcn3UD.js +1 -0
- package/web/assets/index-DEADY94l.js +1 -0
- package/web/assets/index-DGTKsPAQ.js +1 -0
- package/web/assets/index-DRwDqvjf.js +1 -0
- package/web/assets/{index-BGfvNj7R.js → index-DexVkoxH.js} +2 -2
- package/web/assets/{index-O05r2Ty6.js → index-IMOhRWY8.js} +1 -1
- package/web/assets/index-XjvpYHIo.js +1 -0
- package/web/assets/index-YuejkHoJ.js +3412 -0
- package/web/assets/index-pH0266gX.js +1 -0
- package/web/assets/index-sQl_bGM_.js +1 -0
- package/web/assets/index-vbNFy5lS.js +1 -0
- package/web/assets/{invitePage-Bgveo6Hj.js → invitePage-BT_rFfab.js} +1 -1
- package/web/assets/{ipc-B6hkgxQL.js → ipc-8cxXGSZK.js} +1 -1
- package/web/assets/{jszip.min-eU-k-vEy.js → jszip.min-By4OI3XR.js} +1 -1
- package/web/assets/launchpad-BX4jQyF4.js +2 -0
- package/web/assets/launchpad-C9U9hpWJ.css +1 -0
- package/web/assets/layout-grid-CzxXbCDa.js +1 -0
- package/web/assets/linkFollow-J2c0wSgB.js +8 -0
- package/web/assets/{listFold-M8s5JYEC.js → listFold-B_2Xqxn_.js} +1 -1
- package/web/assets/lock-open-DVWCLSZm.js +1 -0
- package/web/assets/log-out-CdKTS7HC.js +1 -0
- package/web/assets/magnet-BmVcZ9U4.js +1 -0
- package/web/assets/main-BlVApHpj.css +1 -0
- package/web/assets/main-CForzSFD.js +15 -0
- package/web/assets/markdownEditorSurface-BiDH0__r.css +1 -0
- package/web/assets/markdownEditorSurface-Bs8FJNHu.js +3 -0
- package/web/assets/mediaPlayer-O9pVRl_k.js +1 -0
- package/web/assets/message-square-plus-CspBv9iG.js +1 -0
- package/web/assets/{messages-CKtabOqy.js → messages-CG7ywZ-K.js} +1 -1
- package/web/assets/minimize-2-Bq4vUin-.js +1 -0
- package/web/assets/mobileEntry-6u7TYC4s.css +1 -0
- package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
- package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
- package/web/assets/nativeDownload-DlnT8U-y.js +1 -0
- package/web/assets/nativeSheetMenu-CVC51DzC.js +1 -0
- package/web/assets/pageStore-BC6Z18n7.css +1 -0
- package/web/assets/pageStore-D_fKLv-o.js +13 -0
- package/web/assets/{pageTree-BYYPgZm_.js → pageTree-DtDKozTg.js} +3 -3
- package/web/assets/pen-line-ho1GgAe2.js +1 -0
- package/web/assets/pen-tool-CV-FKFEZ.js +1 -0
- package/web/assets/pencil-BgF4Kiqp.js +1 -0
- package/web/assets/phoneList-BLVdQcXY.js +1 -0
- package/web/assets/phoneList-BpLxxdq6.css +1 -0
- package/web/assets/pluginChat-C6t6DWhY.js +2 -0
- package/web/assets/react-DOzedx9n.js +1 -0
- package/web/assets/recordSurface-C9SRNjy4.js +1 -0
- package/web/assets/redo-2-DWZTaEz-.js +1 -0
- package/web/assets/rotate-ccw-CyZpL7MX.js +1 -0
- package/web/assets/selectionActions-C2a8ImJm.js +2 -0
- package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
- package/web/assets/sessionTitle-BtZ1BteL.js +1 -0
- package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
- package/web/assets/sharePage-vnghra3Q.js +2 -0
- package/web/assets/{shareViewer-BiMqIBxP.js → shareViewer-CWJQHiV-.js} +2 -2
- package/web/assets/star-ZEpUQwnX.js +1 -0
- package/web/assets/tableSurface-DfEdzVDn.js +1 -0
- package/web/assets/tanguProbe-BboOas-a.js +6 -0
- package/web/assets/{terminalView-lbcBgG0c.js → terminalView-xp8ARBLi.js} +3 -3
- package/web/assets/type-CMyP4cKt.js +1 -0
- package/web/assets/undo-2-C4ZCsMsx.js +1 -0
- package/web/assets/{unitAccount-DGwGsmC3.js → unitAccount-DNxfGo3c.js} +1 -1
- package/web/assets/{unitBridge-CE2yAvm0.js → unitBridge-Bq0n1ZM6.js} +1 -1
- package/web/assets/{unitCloudTransport-BGFwkaDM.js → unitCloudTransport-CErylgEO.js} +1 -1
- package/web/assets/unitOwnerAccess-7s-3dfNM.js +1 -0
- package/web/assets/unitShim-BfheyIG8.js +5 -0
- package/web/assets/upload-VtCrluEO.js +1 -0
- package/web/assets/userSpaces-BpeYjLni.js +1 -0
- package/web/assets/viewportLock-B0l1GU_k.css +1 -0
- package/web/assets/viewportLock-cVUalJAI.js +738 -0
- package/web/assets/zoom-in-C7R8s9x-.js +1 -0
- package/web/excalidraw/excalidraw.js +4 -2
- package/web/index.html +12 -13
- package/web/assets/ArtificialView-DLh75dAI.js +0 -1
- package/web/assets/AutomationBuilder-DNWWGnFr.js +0 -1
- package/web/assets/CalendarConfigView-G7je7k9-.js +0 -1
- package/web/assets/CalendarView-B2MtaOJk.js +0 -1
- package/web/assets/CapabilityMenu-DJaZ_Cyt.js +0 -1
- package/web/assets/CheckboxInput-FYXLaZke.js +0 -1
- package/web/assets/Chrome-CFonajM4.js +0 -1
- package/web/assets/DashboardGridView-D9s9pez_.css +0 -1
- package/web/assets/DashboardGridView-Xgw4wa0_.js +0 -17
- package/web/assets/EventCard-_39F_I5M.js +0 -1
- package/web/assets/ExcalidrawCanvas-4uYrLYin.css +0 -1
- package/web/assets/ExcalidrawCanvas-rXujil36.js +0 -1
- package/web/assets/FloatingToc-DNqAkkI0.js +0 -1
- package/web/assets/GitCloneDialog-CQx-O4j1.js +0 -1
- package/web/assets/HomepageView-DcWmTPQO.css +0 -1
- package/web/assets/HomepageView-MYEk3RCs.js +0 -3
- package/web/assets/ImageStudioPanels-4wnb2XF4.js +0 -3
- package/web/assets/ImageStudioView-qrmW8pfx.js +0 -1
- package/web/assets/InlineAiPanel-B3kd1ob2.js +0 -1
- package/web/assets/InlineFiles-Clnqh9jD.js +0 -1
- package/web/assets/MarkdownBlock-DT_wsaja.js +0 -58
- package/web/assets/ModelPill-JaIH3ffZ.js +0 -2
- package/web/assets/MuseLibraryView-DOJVVeU6.js +0 -2
- package/web/assets/MuseView-uxTmjVQa.js +0 -6
- package/web/assets/PenRow-COOYAaxx.js +0 -1
- package/web/assets/ProductView-DPTveulg.js +0 -1
- package/web/assets/RightPanel-BJUacrsf.js +0 -4
- package/web/assets/RightPanel-D0zk1g3I.css +0 -1
- package/web/assets/SketchCard-B_UU5sxV.js +0 -641
- package/web/assets/StudioGuestSurface-yBa4QKfX.js +0 -1
- package/web/assets/TargetHealthNotice-BLzDB-Xl.css +0 -1
- package/web/assets/TargetHealthNotice-CgkdTdhB.js +0 -47
- package/web/assets/TodoListView-CricdCfW.js +0 -1
- package/web/assets/Tooltip-o8ZqIb3L.js +0 -1
- package/web/assets/UnifiedPage-BWAyqj65.js +0 -69
- package/web/assets/UnifiedPage-CWXc_mo1.css +0 -1
- package/web/assets/appStore-CI1_L5OS.js +0 -3357
- package/web/assets/appStore-DQc2marq.css +0 -1
- package/web/assets/approvalText-Cy2UAUAQ.js +0 -2
- package/web/assets/arrow-up-right-BDsMFoNQ.js +0 -1
- package/web/assets/astryxBridge-CF_hpqC2.css +0 -1
- package/web/assets/astryxBridge-CH_c5xjo.js +0 -70
- package/web/assets/automationListSource-CB6AWkL_.js +0 -1
- package/web/assets/boardSurface-CLvEUjbF.js +0 -1
- package/web/assets/book-open-BLzEdGfu.js +0 -1
- package/web/assets/calendarNavStore-BHUNxDx8.js +0 -1
- package/web/assets/canvasPrefs-CvE7mgyq.js +0 -1
- package/web/assets/chatBoxSurface-CuuHLzs5.js +0 -1
- package/web/assets/circle-question-mark-BM4ZRxQS.js +0 -1
- package/web/assets/circle-x-DTcNGZDT.js +0 -1
- package/web/assets/code-xml-AE3mT4T5.js +0 -1
- package/web/assets/codingNavigation-B0kVsy4x.js +0 -53
- package/web/assets/codingNavigation-DHCidM4N.css +0 -1
- package/web/assets/create-1JI2I47p.js +0 -14
- package/web/assets/dashboardSurface-CIE5HybN.js +0 -1
- package/web/assets/deskCapture-COW7aG5Y.js +0 -1
- package/web/assets/emoji-DZ9CA_3l.css +0 -1
- package/web/assets/emoji-DphwSxPx.js +0 -1
- package/web/assets/floatingTocSurface-BOm2QYBK.js +0 -1
- package/web/assets/foldActions-DNbJPlPl.js +0 -1
- package/web/assets/folder-DotgUhYD.js +0 -1
- package/web/assets/folder-plus-aJgL9NeP.js +0 -1
- package/web/assets/gestures-dqncPOwo.js +0 -1
- package/web/assets/git-branch-CwR2qic6.js +0 -1
- package/web/assets/hack2gate-dark-Dx2RtDRI.jpg +0 -0
- package/web/assets/hack2gate-light-DRKq9tyS.jpg +0 -0
- package/web/assets/hand-XNkzNiW2.js +0 -1
- package/web/assets/hard-drive-CfWKRoAE.js +0 -1
- package/web/assets/i18n-CykmULlm.css +0 -1
- package/web/assets/i18n.generated-BwynSSMk.js +0 -15
- package/web/assets/imageStudio-CWgLpC_d.js +0 -2
- package/web/assets/imageStudio-DZ0qGU2s.css +0 -1
- package/web/assets/index-B65ULikK.js +0 -1
- package/web/assets/index-BIIeiIap.js +0 -1
- package/web/assets/index-BOzsniE1.js +0 -297
- package/web/assets/index-BfrjVzia.js +0 -13
- package/web/assets/index-Bi9UtjVz.js +0 -1
- package/web/assets/index-C1uilc9i.js +0 -1
- package/web/assets/index-C3Dc3Ivz.js +0 -1
- package/web/assets/index-CJF_Ld1Y.js +0 -1
- package/web/assets/index-CMARP4oV.js +0 -1
- package/web/assets/index-C_RsQVNm.js +0 -7
- package/web/assets/index-ChyxZMm8.js +0 -1
- package/web/assets/index-CoKcOaZg.js +0 -1
- package/web/assets/index-CuviSCbk.js +0 -1
- package/web/assets/index-Cw43kua8.js +0 -1
- package/web/assets/index-D1fu6XQN.js +0 -3
- package/web/assets/index-DG-hXb63.js +0 -1
- package/web/assets/index-DjnTfJpN.js +0 -1
- package/web/assets/index-Dtw0abst.js +0 -1
- package/web/assets/index-W3ErfZiX.js +0 -1
- package/web/assets/index-Yc56b3XX.js +0 -1
- package/web/assets/index-d4jCdYJH.js +0 -1
- package/web/assets/index-siHtlYTM.js +0 -1
- package/web/assets/launchpad-C2c1MSVX.css +0 -1
- package/web/assets/layout-grid-CraV7nhh.js +0 -1
- package/web/assets/linkFollow-BpvDWzUx.js +0 -8
- package/web/assets/list-tree-cLJw-jYQ.js +0 -1
- package/web/assets/lock-DBkXXwaI.js +0 -1
- package/web/assets/lock-open-C-9-AWct.js +0 -1
- package/web/assets/log-out-C8bDXj9P.js +0 -1
- package/web/assets/main-BiS_5wrB.css +0 -1
- package/web/assets/main-CMk6twzA.js +0 -20
- package/web/assets/markdownEditorSurface-Bql20IAf.css +0 -1
- package/web/assets/markdownEditorSurface-DgQ0TUWH.js +0 -3
- package/web/assets/message-square-plus-8pfimvem.js +0 -1
- package/web/assets/minus-CfA9fAN3.js +0 -1
- package/web/assets/mobileEntry-DS1vohuL.css +0 -1
- package/web/assets/mobileEntry-NcMcK0LV.js +0 -13
- package/web/assets/nativeDownload-CNtwSCy0.js +0 -1
- package/web/assets/pageChrome-BR4cfIaA.js +0 -1
- package/web/assets/pageChrome-BbUhILy0.css +0 -1
- package/web/assets/pen-tool-C5ftHCnm.js +0 -1
- package/web/assets/pencil-ehhM9_9k.js +0 -1
- package/web/assets/phoneList-B6gwUJZF.js +0 -9
- package/web/assets/phoneList-iRdfiKA8.css +0 -1
- package/web/assets/pluginChat-DTTWWiUS.js +0 -2
- package/web/assets/redo-2-DCEAgQlN.js +0 -1
- package/web/assets/rotate-ccw-DdkrbRAB.js +0 -1
- package/web/assets/selectionActions-BQD2kox1.js +0 -2
- package/web/assets/selectionBarSurface-CzUZmJDJ.js +0 -1
- package/web/assets/server-Ddu9f1k3.js +0 -1
- package/web/assets/sharePage-CNrm2xTC.js +0 -2
- package/web/assets/star-Dxv7XANS.js +0 -1
- package/web/assets/tableSurface-Bly1iCXc.js +0 -1
- package/web/assets/terminal-CAmmC9cV.js +0 -1
- package/web/assets/type-Dz6rnTvG.js +0 -1
- package/web/assets/undo-2-B7izWNb_.js +0 -1
- package/web/assets/unitOwnerAccess-D4nKS6Gg.js +0 -1
- package/web/assets/unitShim-2_2hhGxS.js +0 -5
- package/web/assets/upload-DqpRRAhG.js +0 -1
- package/web/assets/userSpaces-VFu4s05v.js +0 -1
- package/web/assets/viewportLock-3AOdDmwi.js +0 -631
- package/web/assets/viewportLock-djvL8fUQ.css +0 -1
- package/web/assets/zoom-in-Bf-eKTnH.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./appStore-BskcSDl6.js","./index-YuejkHoJ.js","./dbStore-Bc2lC8ZI.js","./react-DOzedx9n.js","./ipc-8cxXGSZK.js","./client-DD5czSuF.js","./nativeDownload-DlnT8U-y.js","./drawingStore-BD5m2eqn.js","./appStore-iy8_Tmac.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as P,j as w,O as rn,g as jc,R as Rc,t as Z,bv as $c,bw as zc,v as ds,a as za,bx as ze,by as Fn,bz as Ts,bA as hn,br as Vc,bB as si,a9 as yt,bC as pn,aZ as gn,m as yo,p as Fc,e as Dc,_ as Ve,i as Wc,f as Os,s as Kc,k as Bc,ae as wo,n as Va,a1 as So,bD as Hc}from"./index-YuejkHoJ.js";import{c as ue,u as qc}from"./react-DOzedx9n.js";import{r as Gc,c as Uc}from"./client-DD5czSuF.js";function Jc(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const i in s)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(s,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>s[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const ii="lcl.uiMode",ee=typeof location<"u"&&new URLSearchParams(location.search).get("window")==="mini",fs=ee&&new URLSearchParams(location.search).get("transient")==="1",le=(()=>{if(typeof location>"u")return null;const e=new URLSearchParams(location.search);return e.get("window")==="detached"&&e.get("space")||null})(),Dn=typeof location>"u"||!new URLSearchParams(location.search).get("window");function Xc(){if(ee)return"desktop";try{const e=new URLSearchParams(location.search).get("ui");return e==="mobile"||e==="desktop"?e:localStorage.getItem(ii)==="mobile"?"mobile":"desktop"}catch{return"desktop"}}const Fa=Xc();function Hm(e){try{localStorage.setItem(ii,e),localStorage.removeItem(`${ii}.auto`)}catch{}}const ms=new Map,Wn=new Set;function qm(e){ms.set(e.type,e),Wn.forEach(t=>t())}function Gm(e){ms.delete(e)&&Wn.forEach(t=>t())}function W(e){return ms.get(e)}function Um(){return[...ms.values()]}function Jm(e){return Wn.add(e),()=>Wn.delete(e)}function Yc(e){return!!e.mini&&e.mini.view.type!==e.mini.mainView.type&&!!W(e.mini.view.type)&&!!W(e.mini.mainView.type)}let Da=null;function Xm(e){Da=e}function Ym(e){Da?.(e)}let oi=null;function Zm(e){oi=e}function ko(e){return oi?oi(e):e}const Jt=new Map;function Zc({id:e,side:t}){const n=P.useRef(null);return P.useLayoutEffect(()=>{const s=n.current,i=Jt.get(e);if(i)return s.append(i),()=>{i.parentElement===s&&i.remove()}},[e]),w.jsx("div",{ref:n,className:`wb-view wb-view--${t} wb-native-extend`,"data-transient-view":e})}function Qc(e,t={}){const n=new Set(Object.entries(e.panels??{}).filter(([,r])=>r.contentComponent==="__extend").map(([r])=>r));if(!n.size)return e;const s=structuredClone(e);for(const r of n)delete s.panels[r];const i=r=>{if(Array.isArray(r.data))return r.data=r.data.map(i).filter(f=>f!==null),r.data.length?r:null;const c=r.data.views.length;if(r.data.views=r.data.views.filter(f=>!n.has(f)),c&&!r.data.views.length)return null;if(r.data.activeView&&n.has(r.data.activeView)){const f=t[r.data.activeView];r.data.activeView=r.data.views.includes(f)?f:r.data.views[0]}return r},o=i(s.grid.root);o&&(s.grid.root=o);const a=(r,c)=>Array.isArray(r.data)?r.data.some(f=>a(f,c)):r.data.id===c;return s.activeGroup&&!a(s.grid.root,s.activeGroup)&&delete s.activeGroup,s}const el=3,tl=.01;function ai(e){const t={sashes:[],fractions:[]};let n;try{n=e.toJSON()}catch{return t}const s=n.panels??{},i=a=>{if(a.type!=="leaf")return!1;const r=(a.data??{}).views??[];return r.length>0&&r.every(c=>{const f=s[c]?.params?.__loc;return f==="left"||f==="right"})},o=a=>{if(!a||a.type!=="branch"||!Array.isArray(a.data))return;const r=a.data.filter(c=>c&&c.visible!==!1);if(r.some(i)){let c=0;r.forEach((f,l)=>{c+=f.size??0;const m=r[l+1];m&&!i(f)&&!i(m)&&t.sashes.push(c)})}else if(r.length>1){const c=r.reduce((f,l)=>f+(l.size??0),0);if(c>0)for(const f of r)t.fractions.push((f.size??0)/c)}r.forEach(o)};return o(n.grid?.root),t}function nl(e,t){return e.sashes.length!==t.sashes.length||e.fractions.length!==t.fractions.length?!1:e.sashes.every((n,s)=>Math.abs(n-t.sashes[s])<=el)&&e.fractions.every((n,s)=>Math.abs(n-t.fractions[s])<=tl)}const sl=e=>e==="horizontal"?"vertical":"horizontal";function Kn(e,t){const n=t.filter(s=>!!s).flatMap(s=>"axis"in s&&s.axis===e?s.children:[s]);return n.length?n.length===1?n[0]:{axis:e,children:n,width:e==="horizontal"?n.reduce((s,i)=>s+i.width,0):Math.max(...n.map(s=>s.width)),height:e==="vertical"?n.reduce((s,i)=>s+i.height,0):Math.max(...n.map(s=>s.height))}:null}function Ye(e){const t=e.toJSON().grid;if(!t?.root)return null;const n=(s,i)=>{if(Array.isArray(s.data))return Kn(i,s.data.map(a=>n(a,sl(i))));const o=e.getPanel(s.data.views[0]);return o?{panel:o.id,instance:o,loc:o.params?.__loc??"main",width:o.group.api.width,height:o.group.api.height}:null};return n(t.root,t.orientation==="HORIZONTAL"?"horizontal":"vertical")}function Xt(e,t){return"panel"in e?e.loc===t?e:null:Kn(e.axis,e.children.map(n=>Xt(n,t)))}const Wa=e=>"panel"in e?e.panel:Wa(e.children[0]),ri=e=>"panel"in e?[e.panel]:e.children.flatMap(ri),Ka=(e,t)=>"panel"in t?e.getPanel(t.panel)===t.instance:t.children.every(n=>Ka(e,n)),Yt=e=>"panel"in e?e.panel:`${e.axis}(${e.children.map(Yt).join(",")})`;function Zt(e,t){const n=Ye(e);if(!(!n||!t))for(const s of["main","left","right","bottom"]){const i=Xt(t,s),o=Xt(n,s);if(!i||!o||!Ka(e,i)||Yt(i)!==Yt(o))continue;const a=[],r=(c,f,l,m)=>{if("panel"in c){a.push({panel:c.panel,width:f,height:l,depth:m});return}const g=c.axis==="horizontal"?"width":"height",p=c.children.reduce((d,S)=>d+S[g],0)||1;c.children.forEach(d=>r(d,g==="width"?f*d.width/p:f,g==="height"?l*d.height/p:l,m+1))};r(i,o.width,o.height,0),a.sort((c,f)=>c.depth-f.depth);for(const{panel:c,width:f,height:l}of a)e.getPanel(c)?.group.api.setSize({width:f,height:l})}}function il(e,t,n="right"){const s=Ye(e);if(!s)return!1;const i=v=>{const I=Xt(s,v),C=t&&Xt(t,v);return I&&C&&ri(I).sort().join("|")===ri(C).sort().join("|")?C:I},o=i("main");if(!o)return!1;const a=i("left"),r=i("right"),c=i("bottom"),f=(...v)=>Kn("horizontal",v),l=(...v)=>Kn("vertical",v),m=n==="left"?f(l(f(a,o),c),r):n==="full"?l(f(a,o,r),c):n==="main"?f(a,l(o,c),r):f(a,l(f(o,r),c));if(Yt(s)===Yt(m))return!1;const g=e.activePanel?.id,p=e.groups.map(v=>v.activePanel?.id).filter(v=>!!v),d=v=>e.getPanel(Wa(v)).group,S=e.addGroup({direction:"right",skipSetActive:!0});d(m).api.moveTo({group:S,position:"right",skipSetActive:!0});const _=v=>{if(!("panel"in v)){for(let I=1;I<v.children.length;I++)d(v.children[I]).api.moveTo({group:d(v.children[I-1]),position:v.axis==="horizontal"?"right":"bottom",skipSetActive:!0});v.children.forEach(_)}};_(m),e.removeGroup(S),Zt(e,m);for(const v of p)e.getPanel(v)?.api.setActive();return g&&e.getPanel(g)?.api.setActive(),!0}function B(e){return typeof e=="function"?e():e}function hs(e){return Object.keys(e).filter(t=>/path$/i.test(t)||t==="sessionId").sort().map(t=>`${t}=${String(e[t])}`).join("&")}function ol(e){const t=n=>typeof e[n]=="string"&&e[n]?e[n]:void 0;return t("notePath")??t("path")??Object.keys(e).filter(n=>/Path$/.test(n)).sort().map(t).find(Boolean)}const al=300,js=new Map;function rl(e){if(!(e instanceof HTMLElement))return;const t=js.get(e);t&&clearTimeout(t.timer);const n=t?t.prev:e.style.getPropertyValue("overflow-anchor");e.style.setProperty("overflow-anchor","none"),js.set(e,{prev:n,timer:setTimeout(()=>{js.delete(e),n?e.style.setProperty("overflow-anchor",n):e.style.removeProperty("overflow-anchor")},al)})}function Qm(e){const t=new Map,n=o=>{const a=o.target;if(!(a instanceof Element)||!e.isConnected)return;const r=a.scrollTop;if(t.set(a,{top:r,left:a.scrollLeft,end:r>0&&a.scrollHeight-a.clientHeight-r<2}),t.size>64)for(const c of t.keys())c.isConnected||t.delete(c)};e.addEventListener("scroll",n,{capture:!0,passive:!0});const s=o=>{const a=[];for(const[r,c]of o){if(!e.contains(r)){t.delete(r);continue}const f=c.end?r.scrollHeight-r.clientHeight:c.top;f>0&&rl(r),Math.abs(r.scrollTop-f)>1&&(r.scrollTop=f),Math.abs(r.scrollLeft-c.left)>1&&(r.scrollLeft=c.left),(Math.abs(r.scrollTop-f)>1||Math.abs(r.scrollLeft-c.left)>1)&&a.push([r,c,r.scrollTop])}return a};let i=0;return{restore:()=>{const o=s([...t]);typeof requestAnimationFrame=="function"&&(cancelAnimationFrame(i),i=requestAnimationFrame(()=>{s(o.filter(([a,,r])=>Math.abs(a.scrollTop-r)<=1).map(([a,r])=>[a,r])),Ba(e)}))},dispose:()=>{typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(i),e.removeEventListener("scroll",n,{capture:!0}),t.clear()}}}function Ba(e){const t=e;for(const n of t.getAnimations?.({subtree:!0})??[])if(n.effect?.getTiming().iterations!==1/0&&!(Number(n.currentTime??0)>80))try{n.finish()}catch{}}const cl=.191,ll=1.2,ci=220;function ul(e,t,n){const o=Math.round(Math.min(t==="left"?280:300,Math.max(t==="left"?220:240,e*cl)));if(!n.free)return o;const a=typeof n.saved=="number"?n.saved:Math.round(o*(n.scale??1)),r=Math.max(ci,Math.min(680,Math.round(e*.6)));return Math.min(r,Math.max(ci,a))}function dl(e,t){const n=Math.max(ci,Math.min(680,Math.round(e*.6))),s=Math.round(t*ll);return Math.max(t,Math.min(n,s))}const xo=120;function fl(e,t){const n=Math.max(xo,Math.round(e*.6)),s=typeof t=="number"?t:Math.round(e*.32);return Math.min(n,Math.max(xo,s))}function Eo({measured:e,target:t,prev:n,pinPending:s}){return s||e<120||Math.abs(e-t)<=2?!1:n==null||Math.abs(n-e)>2}function Fi(e){return(e.panels[0]?.params??{}).__loc??"main"}function ml(e,t,n,s){const i=n.top+n.height/2;if(s==="left"||s==="right")return t<i?"top":"bottom";const o=(e-(n.left+n.width/2))/(n.width||1),a=(t-i)/(n.height||1);return Math.abs(o)>Math.abs(a)?o<0?"left":"right":a<0?"top":"bottom"}function hl(e,t){const{left:n,top:s,width:i,height:o}=e;return t==="left"?{left:n,top:s,width:i/2,height:o}:t==="right"?{left:n+i/2,top:s,width:i/2,height:o}:t==="top"?{left:n,top:s,width:i,height:o/2}:{left:n,top:s+o/2,width:i,height:o/2}}function pl(e,t,n){let s=e.length,i=n;for(let o=0;o<e.length;o++){const a=e[o];if(i=a.right,t<a.left+(a.right-a.left)/2){i=a.left,s=o;break}}return{index:s,lineX:i}}function eh(e,t,n){const s=document.elementFromPoint(t,n)?.closest(".dv-groupview");if(!s)return null;const i=e.groups.find(m=>m.element===s);if(!i)return null;const o=Fi(i),a=s.querySelector(".dv-tabs-and-actions-container"),r=a?.getBoundingClientRect();if(a&&r&&n>=r.top&&n<=r.bottom){const m=a.querySelector(".dv-tabs-container");if(!m)return null;const g=m.getBoundingClientRect(),p=Array.from(m.querySelectorAll(".dv-tab")).filter(_=>!_.classList.contains("wb-tab-dragging")).map(_=>_.getBoundingClientRect()),{index:d,lineX:S}=pl(p,t,g.left);return{mode:"tab",group:i,index:d,lineX:S,top:g.top+3,height:Math.max(0,g.height-6)}}const f=(s.querySelector(".dv-content-container")??s).getBoundingClientRect(),l=ml(t,n,f,o);return{mode:"split",group:i,dir:l,rect:hl(f,l)}}function Ie(e,t,n){return!!e[t]?.some(s=>s.type===n)}function Bn(e,t,n,s){return Ie(e,n,s)&&t.filter(i=>i.loc===n&&i.type===s).length<=1}function Ha(e,t,n){const s=[];for(const i of["main","left","right"])for(const o of e[i]??[])n(o.type)&&!t.some(a=>a.loc===i&&a.type===o.type)&&s.push({...o,loc:i});return s}function gl(e,t,n,s=[]){const i=e?.onePage?e.pinned?.main?.[0]?.type:void 0,o=i?t.find(a=>a.type===i):void 0;return o?{activate:o.id!==n?o.id:null,close:[...t.filter(a=>a.id!==o.id),...s.filter(a=>a.type!=="__extend")].map(a=>a.id)}:{activate:null,close:[]}}function bl(e,t){const n=e?.mainPage;if(!n)return{activate:null,open:null};const s=t.find(i=>i.type===n.type);return s?{activate:s.front?null:s.id,open:null}:{activate:null,open:{...n,newTab:t.some(i=>i.type!=="home")}}}const vl=new Set(["launcher","home","sidebar-empty"]);function yl(e,t,n){const s=e.find(i=>i.id===t);if(!(!s?.onePage||vl.has(n)||s.pinned?.main?.some(i=>i.type===n)))return e.find(i=>i.id!==t&&[...i.pinned?.main??[],...i.launcherViews??[]].some(o=>o.type===n))?.id}const Rs="__by",bn="rule",wl=4,Sl=new Set(["launcher","home","sidebar-empty"]);function qa(e,t,n,s){if(!e||Sl.has(e))return null;const i=r=>{const c=new Set;return r.filter(f=>c.has(f.type)||!s(f.type)?!1:(c.add(f.type),!0))},o=i(t??[]).slice(0,wl),a=o.length?o:i(n);return{key:a.map(r=>r.type).join("|"),group:a}}function li(e){const{group:t,current:n,changed:s}=e,i=new Set(t.map(v=>v.type)),o=new Set(e.pinned.map(v=>v.type)),a=new Set(e.spaceDefaults.map(v=>v.type)),r=v=>v.tagged||a.has(v.type),c=n.filter(v=>r(v)&&!i.has(v.type)&&!o.has(v.type)),f=new Set(c.map(v=>v.id)),l=n.filter(v=>!f.has(v.id)),m=new Set(l.map(v=>v.type)),g=[],p=[];let d=null;for(const v of t){if(!m.has(v.type)){if(e.elsewhere?.has(v.type))continue;g.push({...v,after:d})}p.push(v.type),d=v.type}for(const v of l)i.has(v.type)||p.push(v.type);const S=n.find(v=>v.active);let _=null;return s&&p.length&&t.length&&p.includes(t[0].type)?_=t[0].type:S&&f.has(S.id)&&(_=p[0]??null),_&&S&&S.type===_&&!f.has(S.id)&&(_=null),{open:g,close:c.map(v=>v.id),activate:_,order:p}}function Ga(e,t,n){const s=e.map(i=>t.find(o=>o.type===i.type)??n(i.type)).filter(i=>!!i);return[...s,...t.filter(i=>!s.includes(i))]}let Wt=!1,Hn=null;function th(){Hn=null,!Wt&&(Wt=!0,setTimeout(()=>{Wt=!1,Hn=null},0))}const ui=()=>Wt;function di(e){Wt&&(Hn=e)}const nh=()=>Hn;let fi=0;function _o(e,t,n,s){const i=e().stacks[n];!i||s===i.idx||s<0||s>=i.entries.length||(t({stacks:{...e().stacks,[n]:{...i,idx:s}}}),fi++,Promise.resolve(i.entries[s].restore()).finally(()=>{fi--}))}const fe=ue((e,t)=>({stacks:{},record(n,s){if(fi>0||!n)return;const i=t().stacks[n]??{entries:[],idx:-1};if(i.entries[i.idx]?.key===s.key)return;const o=[...i.entries.slice(0,i.idx+1),s].slice(-100);e({stacks:{...t().stacks,[n]:{entries:o,idx:o.length-1}}})},back(n){_o(t,e,n,(t().stacks[n]?.idx??0)-1)},forward(n){_o(t,e,n,(t().stacks[n]?.idx??-1)+1)},drop(n){if(!(n in t().stacks))return;const s={...t().stacks};delete s[n],e({stacks:s})},reset(){e({stacks:{}})}})),sh=(e,t,n)=>{e&&fe.getState().record(e,{key:t,restore:n})},Ua="forsion_tangu_ribbon_expanded",zt="forsion_tangu_ribbon_order",Ja="forsion_tangu_ribbon_v2",Xa="forsion_ribbon_auto_home",ih=()=>{try{return localStorage.getItem(Xa)!=="0"}catch{return!0}},oh=e=>{try{localStorage.setItem(Xa,e?"1":"0")}catch{}},Di="forsion_ribbon_recent_spaces",kl=5,$s=3;function mi(){try{const e=localStorage.getItem(Di),t=e===null?$s:Number(e);return Number.isInteger(t)?Math.max(0,Math.min(kl,t)):$s}catch{return $s}}function ah(e,t,n,s,i){return i?0:Math.max(0,Math.min(e,t-n-s))}function xl(){try{return localStorage.getItem(Ua)==="1"}catch{return!1}}function El(){try{const e=JSON.parse(localStorage.getItem(zt)||"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch{return[]}}const zs=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],_l=e=>{const t={};if(e&&typeof e=="object")for(const[n,s]of Object.entries(e))typeof s=="string"&&(t[n]=s);return t};function Ml(){try{const e=JSON.parse(localStorage.getItem(Ja)||"{}");return{bottomOrder:zs(e.bottomOrder),commandItems:zs(e.commandItems),commandIcons:_l(e.commandIcons),folders:(Array.isArray(e.folders)?e.folders:[]).filter(t=>!!t&&typeof t.id=="string").map(t=>({id:t.id,name:typeof t.name=="string"?t.name:"",zone:t.zone==="bottom"?"bottom":"top",items:zs(t.items),...typeof t.icon=="string"?{icon:t.icon}:{}}))}}catch{return{bottomOrder:[],folders:[],commandItems:[],commandIcons:{}}}}const Il=e=>{try{localStorage.setItem(Ja,JSON.stringify({bottomOrder:e.bottomOrder,folders:e.folders,commandItems:e.commandItems,commandIcons:e.commandIcons}))}catch{}},Pl=e=>t=>e(n=>{const s=t(n);return Il({...n,...s}),s}),ae=ue(e=>{const t=Pl(e);return{items:[],expanded:xl(),order:El(),recentCount:mi(),setRecentCount:n=>{try{localStorage.setItem(Di,String(n))}catch{}e({recentCount:mi()})},...Ml(),addRibbonIcon:n=>e(s=>({items:[...s.items.filter(i=>i.id!==n.id),n]})),removeRibbonIcon:n=>t(s=>{const i=s.order.filter(o=>o!==n);try{localStorage.setItem(zt,JSON.stringify(i))}catch{}return{items:s.items.filter(o=>o.id!==n),order:i,bottomOrder:s.bottomOrder.filter(o=>o!==n),folders:s.folders.map(o=>({...o,items:o.items.filter(a=>a!==n)}))}}),toggleExpanded:()=>e(n=>{const s=!n.expanded;try{localStorage.setItem(Ua,s?"1":"0")}catch{}return{expanded:s}}),setZoneOrder:(n,s)=>{if(n==="top"){try{localStorage.setItem(zt,JSON.stringify(s))}catch{}e({order:s})}else t(()=>({bottomOrder:s}))},addFolder:(n,s)=>t(i=>{const o=`folder:${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,a=[...i.folders,{id:o,name:s,zone:n,items:[]}],r=[...n==="top"?i.order:i.bottomOrder,o];if(n==="top")try{localStorage.setItem(zt,JSON.stringify(r))}catch{}return n==="top"?{folders:a,order:r}:{folders:a,bottomOrder:r}}),renameFolder:(n,s)=>t(i=>({folders:i.folders.map(o=>o.id===n?{...o,name:s}:o)})),setFolderIcon:(n,s)=>t(i=>({folders:i.folders.map(o=>o.id===n?{...o,icon:s||void 0}:o)})),setCommandIcon:(n,s)=>t(i=>{const o={...i.commandIcons};return s?o[n]=s:delete o[n],{commandIcons:o}}),removeFolder:n=>t(s=>{const i=s.folders.find(f=>f.id===n);if(!i)return{};const o=i.zone==="top"?s.order:s.bottomOrder,a=o.indexOf(n),r=a>=0?[...o.slice(0,a),...i.items,...o.slice(a+1)]:[...o,...i.items];if(i.zone==="top")try{localStorage.setItem(zt,JSON.stringify(r))}catch{}const c=s.folders.filter(f=>f.id!==n);return i.zone==="top"?{folders:c,order:r}:{folders:c,bottomOrder:r}}),setFolderItems:(n,s)=>t(i=>({folders:i.folders.map(o=>o.id===n?{...o,items:s}:o)})),moveIntoFolder:(n,s)=>t(i=>({folders:i.folders.map(o=>o.id===n?{...o,items:[...o.items.filter(a=>a!==s),s]}:{...o,items:o.items.filter(a=>a!==s)})})),moveOutOfFolder:n=>t(s=>({folders:s.folders.map(i=>({...i,items:i.items.filter(o=>o!==n)}))})),addCommandItem:n=>t(s=>s.commandItems.includes(n)?{}:{commandItems:[...s.commandItems,n],bottomOrder:[...s.bottomOrder,`cmd:${n}`]}),removeCommandItem:n=>t(s=>{const i={...s.commandIcons};return delete i[n],{commandItems:s.commandItems.filter(o=>o!==n),commandIcons:i,bottomOrder:s.bottomOrder.filter(o=>o!==`cmd:${n}`),folders:s.folders.map(o=>({...o,items:o.items.filter(a=>a!==`cmd:${n}`)}))}})}});typeof window<"u"&&window.addEventListener("storage",e=>{e.key===Di&&ae.setState({recentCount:mi()})});const rh=e=>ae.getState().addRibbonIcon(e),ch=e=>ae.getState().removeRibbonIcon(e);function Ya(e){const t=P.useMemo(()=>e.filter(i=>i.dot),[e]),n=P.useCallback(i=>{const o=t.map(a=>a.dot.subscribe(i));return()=>{for(const a of o)a()}},[t]),s=P.useSyncExternalStore(n,()=>t.filter(i=>i.dot.get()).map(i=>i.id).join(`
|
|
3
|
+
`));return P.useMemo(()=>new Set(s?s.split(`
|
|
4
|
+
`):[]),[s])}function lh(e,t){const n=new Map(t.map((s,i)=>[s,i]));return e.map((s,i)=>({id:s,k:n.has(s)?n.get(s):t.length+i})).sort((s,i)=>s.k-i.k).map(s=>s.id)}function Ll(e,t){const n=[...e];for(const s of t)n.includes(s)||n.push(s);return n}function uh(e,t,n){return Ll(e,t).filter(s=>s!==n)}function dh(e,t,n){return t<2||!n.pitch?0:Math.max(0,Math.min(t-1,Math.round((e-n.grabDy-n.top)/n.pitch)))}function fh(e,t,n){const s=e.filter(i=>i!==t);return s.splice(Math.max(0,Math.min(n,s.length)),0,t),s}const Za={},mh=e=>{Object.assign(Za,e)},Qa={"lcl.withHotkey":{zh:"{label}({key})",en:"{label} ({key})"},"lcl.ribbon.showLabels":{zh:"显示名称",en:"Show labels"},"lcl.ribbon.iconsOnly":{zh:"只显示图标",en:"Icons only"},"lcl.ribbon.addSpaceOrFolder":{zh:"新建 Space 或收纳夹",en:"New Space or folder"},"lcl.ribbon.addCommand":{zh:"添加命令",en:"Add command"},"lcl.ribbon.more":{zh:"更多",en:"More"},"lcl.ribbon.less":{zh:"收起",en:"Show less"},"lcl.ribbon.switchSpace":{zh:"切到第 {n} 个 Space",en:"Switch to Space {n}"},"lcl.ribbon.newSpace":{zh:"新建 Space",en:"New Space"},"lcl.ribbon.newFolder":{zh:"新建收纳夹",en:"New folder"},"lcl.ribbon.folderDefaultName":{zh:"收纳夹",en:"Folder"},"lcl.ribbon.newFolderSpaces":{zh:"新建收纳夹(Space 区)",en:"New folder (Spaces)"},"lcl.ribbon.newFolderCommands":{zh:"新建收纳夹(命令区)",en:"New folder (commands)"},"lcl.ribbon.changeIcon":{zh:"更换图标",en:"Change icon"},"lcl.ribbon.rename":{zh:"重命名",en:"Rename"},"lcl.ribbon.renameFolder":{zh:"重命名收纳夹",en:"Rename folder"},"lcl.ribbon.dissolveFolder":{zh:"解散收纳夹",en:"Dissolve folder"},"lcl.ribbon.setIcon":{zh:"设置图标",en:"Set icon"},"lcl.ribbon.removeCommand":{zh:"从 Ribbon 移除",en:"Remove from ribbon"},"lcl.ribbon.moveOut":{zh:"移出收纳夹",en:"Move out of folder"},"lcl.ribbon.folderEmpty":{zh:"把图标拖到收纳夹图标上即可放入",en:"Drag icons onto the folder to collect them"},"lcl.peek.enter":{zh:"进入「{name}」",en:"Go to {name}"},"lcl.ribbon.defaultIcon":{zh:"默认图标",en:"Default icon"},"lcl.ribbon.openInNewWindow":{zh:"在新窗口中打开",en:"Open in new window"},"lcl.ribbon.recentSpaces":{zh:"最近使用的 Space",en:"Recent Spaces"},"lcl.tab.close":{zh:"关闭",en:"Close"},"lcl.tab.moveToWindow":{zh:"移到新窗口",en:"Move to new window"},"lcl.tab.new":{zh:"新建标签页",en:"New tab"},"lcl.nav.back":{zh:"后退",en:"Back"},"lcl.nav.forward":{zh:"前进",en:"Forward"},"lcl.edge.left":{zh:"左侧栏",en:"Toggle left panel"},"lcl.edge.right":{zh:"右侧栏",en:"Toggle right panel"},"lcl.edge.bottom":{zh:"底部面板",en:"Toggle bottom panel"},"lcl.edge.reset":{zh:"恢复本 Space 默认布局",en:"Restore default layout for this Space"},"lcl.layout.restored":{zh:"已恢复本 Space 默认布局",en:"Restored the default layout"},"lcl.layout.undo":{zh:"撤销",en:"Undo"},"lcl.view.loadFailed":{zh:"此视图加载失败",en:"Failed to load this view"},"lcl.view.retry":{zh:"重试",en:"Retry"},"lcl.palette.pickCommand":{zh:"选择要添加的命令…",en:"Pick a command to add…"},"lcl.mini.switchSpace":{zh:"切换 Space",en:"Switch Space"},"lcl.mini.showMain":{zh:"在主面板显示",en:"Show in main panel"},"lcl.mini.close":{zh:"关闭 Mini Panel",en:"Close Mini Panel"},"lcl.mini.empty":{zh:"暂无已适配的 Space",en:"No Mini Panel Spaces available"},"lcl.mini.closeMenu":{zh:"关闭菜单",en:"Close menu"},"lcl.mobile.closeTab":{zh:"关闭标签页",en:"Close tab"},"lcl.mobile.leftPanel":{zh:"左侧面板",en:"Left panel"},"lcl.mobile.rightPanel":{zh:"右侧面板",en:"Right panel"},"lcl.mobile.tabs":{zh:"标签页",en:"Tabs"},"lcl.mobile.more":{zh:"更多",en:"More"},"lcl.mobile.back":{zh:"返回",en:"Back"},"lcl.mobile.allSpaces":{zh:"全部",en:"All"},"lcl.mobile.allSpacesTitle":{zh:"全部 Space",en:"All Spaces"},"lcl.mobile.dock.inDock":{zh:"固定在 Dock",en:"In the dock"},"lcl.mobile.dock.others":{zh:"其他",en:"Others"},"lcl.mobile.dock.edit":{zh:"选择固定在 Dock 的 Space",en:"Choose the Spaces in the dock"},"lcl.mobile.dock.editTitle":{zh:"固定在 Dock",en:"Spaces in the dock"},"lcl.mobile.dock.editHint":{zh:"{first}常驻,另外最多固定 {max} 个。满了先取消一个再选。",en:"{first} is always there; pick up to {max} more. When the dock is full, take one out first."},"lcl.mobile.dock.done":{zh:"完成",en:"Done"},"lcl.viewMode.aria":{zh:"看法",en:"View mode"},"lcl.viewMode.next":{zh:"切到下一种看法",en:"Next view mode"},"lcl.viewMode.pick":{zh:"看法:{label}",en:"View: {label}"}};function Mo(e,t){return t?e.replace(/\{(\w+)\}/g,(n,s)=>s in t?String(t[s]):n):e}function Wi(e,t){const n=Qa[e];if(!n)return Mo(e,t);let s=!1;try{s=document.documentElement.lang.startsWith("zh")}catch{}return Mo(s?n.zh:n.en,t)}const Io=e=>(t,n)=>{const s=e(t,n);return s===t&&t in Qa?Wi(t,n):s};let er=()=>({t:Wi}),tr=Wi;function hh(e,t){er=()=>{const{t:n}=e();return{t:Io(n)}},t&&(tr=Io(t))}function Tt(){return er()}function Ze(e,t){return tr(e,t)}function Cl(e){const t=e.dockview?.panels,{left:n,right:s,bottom:i}=e.sidebars;return!Object.keys(t??{}).length&&!n.stash.length&&!s.stash.length&&!i?.stash.length}function Al(){try{const e=new URLSearchParams(location.search);if(e.get("window")==="detached")return`tangu2_layout_detached_${e.get("id")||"default"}`}catch{}return"tangu2_layout_v4"}const qn=rn(Al()),nr=rn("tangu2_layout_v3"),Ki=rn("tangu2_named_layouts");function Vs(e){return Array.isArray(e)&&e.every(t=>!!t&&typeof t=="object"&&typeof t.type=="string")}function sr(e){if(!e||typeof e!="object")return!1;const t=e;return t.version===4&&!!t.sidebars&&typeof t.sidebars.left?.visible=="boolean"&&typeof t.sidebars.right?.visible=="boolean"&&Vs(t.sidebars.left?.stash)&&Vs(t.sidebars.right?.stash)&&(t.sidebars.bottom===void 0||typeof t.sidebars.bottom.visible=="boolean"&&Vs(t.sidebars.bottom.stash))}function ir(e){if(!e||typeof e!="object")return null;const t=e.panels;if(!t||typeof t!="object")return null;const n=new Set(Object.values(t).map(s=>s?.params?.__loc).filter(Boolean));return!n.has("left")||!n.has("right")?null:{version:4,dockview:e,sidebars:{left:{visible:!0,stash:[]},right:{visible:!0,stash:[]}}}}function Ot(e){if(e)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Bi(e,t){const n=Ot(t);if(n)try{n.setItem(qn,JSON.stringify(e))}catch{}}function cn(e){const t=Ot(e);if(!t)return null;try{const n=t.getItem(qn);if(n){const o=JSON.parse(n);return sr(o)?o:null}const s=t.getItem(nr);if(!s)return null;const i=ir(JSON.parse(s));return i&&t.setItem(qn,JSON.stringify(i)),i}catch{return null}}function Gn(e){const t=Ot(e);t?.removeItem(qn),t?.removeItem(nr)}function ln(e){const t=Ot(e);if(!t)return{};try{const n=t.getItem(Ki);if(!n)return{};const s=JSON.parse(n),i={};for(const[o,a]of Object.entries(s)){const r=sr(a)?a:ir(a);r&&(i[o]=r)}return i}catch{return{}}}function or(e,t,n){const s=Ot(n);if(!s)return;const i=ln(s);i[e]=t;try{s.setItem(Ki,JSON.stringify(i))}catch{}}function wt(e,t){const n=ln(t);return e in n?n[e]:null}function Po(e,t){const n=Ot(t);if(!n)return;const s=ln(n);if(e in s){delete s[e];try{n.setItem(Ki,JSON.stringify(s))}catch{}}}function Nl(e,t){const n=new Set(e);let s=1;for(;n.has(`${t}#${s}`);)s++;return`${t}#${s}`}function rt(e,t){return Nl(e.panels.map(n=>n.id),t)}function vn(e,t){if(t==="main")return;const n=D(e,t);n.some(s=>V(s)!=="sidebar-empty")&&n.filter(s=>V(s)==="sidebar-empty").forEach(s=>s.api.close())}const ne={left:!1,right:!1,bottom:!1},oe={},be={},Lo=()=>{for(const e of["left","right","bottom"])be[e]?.dismiss("layout"),be[e]?.dispose(!0)},hi=new WeakSet;typeof document<"u"&&document.addEventListener("contentvisibilityautostatechange",e=>{const t=e.target;e.skipped?hi.add(t):hi.delete(t)},!0);function St(){const e=typeof document<"u"?document.querySelector(".wb-dockview"):null;if(!e)return()=>{};const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const a=o,r=a.scrollTop,c=a.scrollLeft;return(r||c)&&t.push({el:a,top:r,left:c}),hi.has(a)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});for(;n.nextNode(););const s=()=>{for(const o of t)o.el.scrollTop!==o.top&&(o.el.scrollTop=o.top),o.el.scrollLeft!==o.left&&(o.el.scrollLeft=o.left)},i=()=>Ba(e);return()=>{s(),typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>{s(),i()}):i()}}const Me={left:0,right:0,bottom:0};let Fs=!1;const Qt=100;function yn(e){return e==="left"?"leftVisible":e==="right"?"rightVisible":"bottomVisible"}let pi=!1,Co=0;function qe(e,t){const n=X.getState(),s=ul(e.width,t,{free:n.sideFree[t],saved:n.sideWidths[t],scale:n.sideScale[t]});return n.sideWidths[t]==null?be[t]?.defaultWidth??s:s}function en(e){return fl(e.height,X.getState().sideWidths.bottom)}let An=null;function Un(e){const t=()=>{if(!ne.bottom)try{D(e,"bottom")[0]?.group.api.setSize({height:en(e)})}catch{}},n=typeof requestAnimationFrame=="function"?requestAnimationFrame:i=>i(),s=An=D(e,"bottom")[0]?.group??null;t(),n(()=>n(t)),setTimeout(()=>{t(),An===s&&(An=null)},60)}function ph(e){const t=X.getState();if(!t.sideProfileKey)return;let n=!1;const s={...t.sideWidths};for(const o of["left","right"]){if(!t.sideFree[o]||ne[o])continue;const a=D(e,o)[0]?.group?.api?.width;typeof a=="number"&&Eo({measured:a,target:qe(e,o),prev:s[o],pinPending:pi})&&(s[o]=Math.round(a),n=!0)}const i=D(e,"bottom")[0]?.group;if(!ne.bottom&&i!==An){const o=i?.api?.height;typeof o=="number"&&Eo({measured:o,target:en(e),prev:s.bottom,pinPending:!1})&&(s.bottom=Math.round(o),n=!0)}if(n){X.setState({sideWidths:s});try{localStorage.setItem(`lcl.sideWidth2.${t.sideProfileKey}`,JSON.stringify({left:s.left,right:s.right,bottomH:s.bottom}))}catch{}}}function Hi(e,t,n=!1){const s=[];for(const i of t){const o=D(e,i)[0]?.group;if(!o)continue;const a=(n?o.api.width:0)||qe(e,i);try{o.api.setConstraints?.({minimumWidth:a,maximumWidth:a})}catch{}s.push(o)}return()=>{for(const i of s)try{i.api.setConstraints?.({minimumWidth:0,maximumWidth:Number.MAX_SAFE_INTEGER})}catch{}}}const ar=(e,t)=>Hi(e,[t==="left"?"right":"left"]);function Jn(e,t,n,s,i,o){if(typeof requestAnimationFrame!="function"||typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){if(o?.())return;try{e.api.setSize({[t]:s})}catch{}i();return}const a=200,r=l=>1-Math.pow(1-l,3);let c=0;const f=l=>{if(o?.())return;c||(c=l);const m=Math.min(1,(l-c)/a);try{e.api.setSize({[t]:Math.round(n+(s-n)*r(m))})}catch{}m<1?requestAnimationFrame(f):i()};requestAnimationFrame(f)}function ve(e){const t=++Co;pi=!0;const n=()=>{if(e.width){for(const o of["left","right"])if(!ne[o])try{D(e,o)[0]?.group.api.setSize({width:qe(e,o)})}catch{}}},s=typeof requestAnimationFrame=="function"?requestAnimationFrame:i=>i();s(()=>s(n)),setTimeout(()=>{n(),t===Co&&(pi=!1)},60)}function V(e){return(e.params??{}).__type||e.component||""}const Qe=new Set;function gh(e){Qe.add(e)}function gi(e=X.getState().api){if(e){for(const t of e.panels){if(Qe.has(t.id))continue;const n=W(V(t));if(!n)continue;const s=B(n.displayName);t.title!==s&&t.api.setTitle(s)}X.getState().refreshTabs()}}function ge(e){const t=e.params??{},{__loc:n,__type:s,__by:i,...o}=t;return{id:e.id,type:V(e),loc:n??"main",params:o,setTitle:a=>{Qe.add(e.id),e.api.setTitle(a)},setParams:a=>{e.api.updateParameters({...e.params??{},...a}),X.getState().refreshTabs(),Q()},close:()=>X.getState().closeLeaf(e.id)}}function D(e,t){return e.panels.filter(n=>(n.params??{}).__loc===t)}const ke=e=>(e.params??{}).__loc??"main",bi=e=>e.panels.map(t=>({loc:ke(t),type:V(t)}));function ct(e,t){return Bn(X.getState().pinned,bi(e),ke(t),V(t))}function Tl(e,t,n){const s=e.getPanel(t);return!s||Fi(n.group)===ke(s)||!ct(e,s)}function vi(e,t,n,s,i){const o=W(n),a=e.addPanel({id:o?.singleton&&!e.getPanel(n)?n:rt(e,n),component:"__frame",title:o?B(o.displayName):n,params:{...s,__loc:"main",__type:n},position:i??{referencePanel:t.id,direction:"within"}});return n==="chat"&&X.setState({focusedChatLeafId:a.id}),Q(),ge(a)}function Ol(e,t){if(t.group.api.location.type!=="grid")return{referencePanel:t.id,direction:"within"};const n=r=>r.element.getBoundingClientRect(),s=r=>{const c=n(r);return c.left+c.width/2},i=n(t.group),o=[...new Set(D(e,"main").map(r=>r.group))].filter(r=>{if(r.id===t.group.id||r.api.location.type!=="grid")return!1;const c=n(r);return c.width>0&&c.top<i.bottom-1&&c.bottom>i.top+1&&Math.abs(s(r)-s(t.group))>1}),a=o.filter(r=>s(r)>s(t.group)).sort((r,c)=>s(r)-s(c))[0]??o.sort((r,c)=>s(c)-s(r))[0];return a?{referenceGroup:a.id,direction:"within"}:{referencePanel:t.id,direction:"right"}}function Ds(e,t,n,s){const i=W(n);if(!i)return null;const{focusedChatLeafId:o,refreshTabs:a}=X.getState(),r=t.params??{},c=V(t)===n,f={};for(const l of Object.keys(r))f[l]=void 0;if(t.api.updateParameters({...f,...s,__loc:r.__loc??"main",__type:n}),Qe.delete(t.id),t.api.setTitle(B(i.displayName)),t.api.setActive(),n==="chat")X.setState({focusedChatLeafId:t.id});else if(!c&&o===t.id){const l=D(e,"main").find(m=>m.id!==t.id&&V(m)==="chat");X.setState({focusedChatLeafId:l?.id??null})}return a(),Q(),ge(t)}function Ao(e,t,n,s){const i=D(e,"main").find(a=>{const r=a.params??{};return V(a)===n&&Object.keys(s).every(c=>r[c]===s[c])});if(i)return i.api.setActive(),di(i.id),ge(i);const o=vi(e,t,n,s,{referencePanel:t.id,direction:"within",index:t.group.panels.indexOf(t)+1});return di(o.id),o}let Vt=null;function tn(e){const t=D(e,"main"),n=e.activePanel;if(n&&t.some(o=>o.id===n.id))return n;const s=o=>o.group,i=t.filter(o=>s(o)?.activePanel?.id===o.id);return i.find(o=>s(o)?.id===Vt)??i[0]??t[0]??null}let xe=null,Ws=!1;const No=()=>!ee&&(Dn||!!le),jl=e=>{const t=W(e);return!!t&&t.kind!=="entity"};function To(e,t){const n=tn(e),s=n?V(n):null;return qa(s,s?W(s)?.rightCompanions:void 0,t,jl)}function Rl(){Ws||(Ws=!0,queueMicrotask(()=>{Ws=!1;try{X.getState().applyRightRules()}catch(e){console.error("[lcl] right panel rules",e)}}))}function Nn(e,t){const n=D(e,t);if(n.length)return{referencePanel:n[0].id,direction:"within"};if(t==="main")return;const s=t==="bottom"?$l(e):void 0;if(s){try{s.api.setVisible(!0),ne.bottom||s.api.setConstraints({minimumHeight:Qt})}catch{}return{referenceGroup:s.id,direction:"within"}}return{direction:t==="bottom"?"below":t}}function $l(e){return e.groups?.find(t=>t.panels.length===0&&t.api.isVisible===!1)}function zl(e,t){const n=e.component;n?.removePanel?n.removePanel(t,{removeEmptyGroup:!1}):t.api.close()}function yi(e,t,n){for(const s of n)try{s.group===t?zl(e,s):s.api.close()}catch{}if(!(!e.groups?.includes(t)||t.panels.length))try{e.activeGroup===t&&tn(e)?.group.api.setActive(),t.api.setVisible(!1)}catch{}}function Kt(e,t){const n=t??Ye(e),s=St();ve(e);try{il(e,n,X.getState().bottomSpan),D(e,"bottom").length&&Un(e),setTimeout(()=>{X.getState().api===e&&!Object.values(ne).some(Boolean)&&Zt(e,n)},80)}finally{s()}}let ye;const Oo=()=>ye===void 0?X.getState().sideProfileKey:ye;function Ks(e,t){const n=ye===void 0?t.sideProfileKey:ye;return{version:4,...n?{space:n}:{},dockview:Qc(e.toJSON(),Object.fromEntries(Object.values(be).filter(s=>s.previousId).map(s=>[s.id,s.previousId]))),sidebars:{left:{visible:D(e,"left").some(s=>V(s)!=="__extend"),stash:t.stash.left},right:{visible:D(e,"right").some(s=>V(s)!=="__extend"),stash:t.stash.right,...xe!==null?{rule:xe}:{}},bottom:{visible:D(e,"bottom").some(s=>V(s)!=="__extend"),stash:t.stash.bottom}}}}let Fe=null;const Vl=600;function jo(e,t){return e.api!==t||rr(t)!==e.shape?!1:Date.now()<e.settleUntil||nl(ai(t),e.metrics)}function rr(e){try{return e.groups.map(t=>t.panels.map(n=>n.id).join(",")).join("|")}catch{return""}}function Bs(){const e=Fe;Fe=null;try{e?.dismiss?.()}catch{}}let wn=null;function Q(){wn&&clearTimeout(wn),wn=setTimeout(()=>{wn=null,X.getState().saveCurrent()},100)}const X=ue((e,t)=>({api:null,focusedChatLeafId:null,mainTabs:[],leftTabs:[],rightTabs:[],chatSurfaces:{},leftVisible:!0,rightVisible:!0,bottomVisible:!1,stash:{left:[],right:[],bottom:[]},stashActive:{left:null,right:null,bottom:null},sidebarDefaults:{left:[],right:[],bottom:[]},defaultBuilder:null,sideFree:{left:!1,right:!1},sideWidths:{left:null,right:null,bottom:null},sideScale:{left:1,right:1},sideProfileKey:null,bottomSpan:"right",pinned:{},setApi:n=>{n?.onDidRemovePanel?.(s=>Qe.delete(s.id)),e({api:n})},setDefaultBuilder:n=>e({defaultBuilder:n}),setSidebarDefaults:n=>e({sidebarDefaults:{left:n.left,right:n.right,bottom:n.bottom??[]}}),setSideProfile:(n,s,i,o)=>{let a={left:null,right:null,bottom:null};try{localStorage.removeItem(`lcl.sideWidth.${n}`);const r=localStorage.getItem(`lcl.sideWidth2.${n}`);if(r){const c=JSON.parse(r);a={left:typeof c.left=="number"?c.left:null,right:typeof c.right=="number"?c.right:null,bottom:typeof c.bottomH=="number"?c.bottomH:null}}}catch{}ye=void 0,e({sideProfileKey:n,sideFree:{left:s.left!==!1,right:s.right!==!1},sideWidths:a,sideScale:{left:i?.left??1,right:i?.right??1},bottomSpan:o??"right",stashActive:{left:null,right:null,bottom:null}})},initializeSidebar:(n,s)=>e(i=>({[yn(n)]:s,stash:s?i.stash:{...i.stash,[n]:i.sidebarDefaults[n]}})),setFocusedLeaf:n=>{n&&V(n)==="chat"&&e({focusedChatLeafId:n.id})},registerChatSurface:(n,s)=>e(i=>{const o={...i.chatSurfaces};return s?o[n]=s:delete o[n],{chatSurfaces:o}}),syncPanelState:()=>{const n=t().api;if(!n)return;const s=D(n,"left").length>0,i=D(n,"right").length>0,o=D(n,"bottom").length>0;(s!==t().leftVisible||i!==t().rightVisible||o!==t().bottomVisible)&&e({leftVisible:s,rightVisible:i,bottomVisible:o})},retitleDefaults:()=>gi(t().api),realignRegions:()=>{const n=t().api;n&&Kt(n)},setPinned:n=>{e({pinned:n??{}}),t().refreshTabs()},isPinnedLeaf:n=>{const s=t().api,i=s?.getPanel(n);return!!s&&!!i&&ct(s,i)},ensurePinned:()=>{const n=t().api;if(!n)return;const s=bi(n),i=a=>t().stash[a].length?t().stash[a]:t().sidebarDefaults[a];for(const a of["left","right"])if(!D(n,a).length)for(const r of i(a))s.push({loc:a,type:r.type});const o=Ha(t().pinned,s,a=>!!W(a));if(o.length){for(const a of o){const r=D(n,a.loc);if(a.loc!=="main"&&!r.length){const f=a.loc;e(l=>({stash:{...l.stash,[f]:[{type:a.type,params:a.params},...i(f)]}}));continue}if(r.length===1&&V(r[0])==="home"){Ds(n,r[0],a.type,a.params);continue}const c=W(a.type);n.addPanel({id:c.singleton&&!n.getPanel(a.type)?a.type:rt(n,a.type),component:a.loc==="main"?"__frame":a.type,title:B(c.displayName),params:{...a.params,__loc:a.loc,__type:a.type},position:r.length?{referencePanel:r[0],index:0}:Nn(n,a.loc),inactive:r.length>0}),r.filter(f=>V(f)==="sidebar-empty").forEach(f=>f.api.close())}t().refreshTabs(),Q()}},applyRightRules:()=>{const n=t().api;if(!n||!No())return;const s=t().sidebarDefaults.right,i=To(n,s);if(!i||i.key===xe)return;const o=xe!==null;xe=i.key;const a=t().pinned.right??[],r=new Set(n.panels.filter(S=>ke(S)!=="right").map(V).filter(S=>W(S)?.singleton)),c=D(n,"right").filter(S=>!["sidebar-empty","__extend"].includes(V(S))),f=S=>S.group?.activePanel?.id===S.id;if(!t().rightVisible){const{stash:S,stashActive:_}=t(),v=S.right.length?S.right:s.filter(u=>!!W(u.type)),I=v.map((u,b)=>({id:String(b),type:u.type,tagged:u.params?.[Rs]===bn,active:u.type===_.right})),C=li({group:i.group,pinned:a,spaceDefaults:s,current:I,changed:o,elsewhere:r}),A=v.filter((u,b)=>!C.close.includes(String(b))),M=new Map(C.open.map(u=>[u.type,{type:u.type,params:{...u.params,[Rs]:bn}}])),O=Ga(i.group,A,u=>M.get(u)),$=C.activate??(O.some(u=>u.type===_.right)?_.right:null);if(O.map(u=>u.type).join("|")===v.map(u=>u.type).join("|")&&$===_.right){Q();return}e({stash:{...S,right:O},stashActive:{..._,right:$}}),t().refreshTabs(),Q();return}const l=c.map(S=>({id:S.id,type:V(S),tagged:(S.params??{}).__by===bn,active:f(S)})),m=li({group:i.group,pinned:a,spaceDefaults:s,current:l,changed:o,elsewhere:r});if(!m.open.length&&!m.close.length&&!m.activate){Q();return}const g=n.activePanel;for(const S of m.open){const _=W(S.type),v=D(n,"right"),I=S.after?v.find(M=>V(M)===S.after):void 0,C=I??v[0],A=I?(I.group.panels?.indexOf(I)??-1)+1:0;n.addPanel({id:_.singleton&&!n.getPanel(S.type)?S.type:rt(n,S.type),component:S.type,title:B(_.displayName),params:{...S.params,__loc:"right",__type:S.type,[Rs]:bn},position:C?{referencePanel:C.id,index:A}:Nn(n,"right"),inactive:!0})}vn(n,"right");for(const S of m.close)t().closeLeaf(S);const p=m.activate?D(n,"right").find(S=>V(S)===m.activate):void 0;p&&!f(p)&&p.api.setActive();const d=g?n.getPanel(g.id):void 0;d&&ke(d)!=="right"&&n.activePanel?.id!==d.id&&(d.group?.activePanel===d?d.group.api.setActive():d.api.setActive()),t().refreshTabs(),Q()},refreshTabs:()=>{const n=t().api;if(!n){t().mainTabs.length&&e({mainTabs:[]});return}const s=n.activePanel?.id;n.activePanel&&(n.activePanel.params??{}).__loc==="main"&&(Vt=n.activePanel.group?.id??null);const i=t().pinned,o=bi(n),a=D(n,"main").map(d=>{const S=V(d),_=d.params??{},v=W(S);return{id:d.id,type:S,title:d.title||(v?B(v.displayName):S),active:d.id===s,closable:v?.closable!==!1&&!Bn(i,o,"main",S),sessionId:typeof _.sessionId=="string"?_.sessionId:void 0,followActive:_.followActive!==!1,filePath:ol(_),front:d.group?.activePanel?.id===d.id,sig:hs(_)}}),r=t().mainTabs;r.length===a.length&&r.every((d,S)=>d.id===a[S].id&&d.active===a[S].active&&d.title===a[S].title&&d.filePath===a[S].filePath&&d.front===a[S].front&&d.sig===a[S].sig&&d.closable===a[S].closable)||e({mainTabs:a});const f=d=>{const S=d==="left"?t().leftVisible:t().rightVisible,_=(I,C)=>{const A=W(I),M=S?Bn(i,o,d,I):Ie(i,d,I);return{type:I,title:A?B(A.displayName):I,active:C,closable:A?.closable!==!1&&!M}};return S?D(n,d).map(I=>{const C=I.group;return{..._(V(I),C?.activePanel?.id===I.id),title:I.title??V(I)}}):(t().stash[d].length?t().stash[d]:t().sidebarDefaults[d]).map(I=>_(I.type,!1))},l=(d,S)=>d.length===S.length&&d.every((_,v)=>_.type===S[v].type&&_.active===S[v].active&&_.closable===S[v].closable),m=f("left"),g=f("right");l(t().leftTabs,m)||e({leftTabs:m}),l(t().rightTabs,g)||e({rightTabs:g});const p=No()?To(n,t().sidebarDefaults.right):null;p&&p.key!==xe&&Rl()},activateLeaf:n=>{const s=t().api?.getPanel(n);s&&ke(s)==="main"&&di(n),s?.api.setActive(),t().refreshTabs()},closeLeaf:(n,s)=>{const i=t().api,o=i?.getPanel(n);if(!i||!o)return;if(V(o)==="__extend"){const l=Object.values(be).find(m=>m?.id===n);l?.dismiss(),l?.dispose();return}if(V(o)==="home"||!s&&ct(i,o))return;const a=(o.params??{}).__loc??"main";if(a==="main"&&D(i,"main").length<=1){fe.getState().drop(n),Ds(i,o,"home",{});return}const r=(a==="left"||a==="right")&&V(o)!=="sidebar-empty"&&D(i,a).length<=1,c=a==="bottom"&&D(i,"bottom").length<=1,f=a==="main"?Hi(i,["left","right"],!0):()=>{};c?yi(i,o.group,[o]):o.api.close(),r&&t().openView("sidebar-empty",{},a),c&&e(l=>({stash:{...l.stash,bottom:[]},stashActive:{...l.stashActive,bottom:null},bottomVisible:!1})),fe.getState().drop(n),t().refreshTabs(),setTimeout(f,180)},dropView:(n,s)=>{const i=t().api,o=i?.getPanel(n);if(!i||!o)return;const a=Fi(s.group);if(!Tl(i,n,s))return;const r=(o.params??{}).__loc==="main"?o.group?.id??null:null,c={left:D(i,"left").length,right:D(i,"right").length,bottom:D(i,"bottom").length};try{s.mode==="tab"?o.api.moveTo({group:s.group,position:"center",index:s.index}):o.api.moveTo({group:s.group,position:s.dir})}catch{return}o.api.updateParameters({...o.params??{},__loc:a}),r&&a!=="main"&&(Vt=r),D(i,"main").length===0&&t().openView("home",{},"main");for(const l of["left","right"]){const m=D(i,l);c[l]>0&&m.length===0?t().openView("sidebar-empty",{},l):m.length>1&&m.filter(g=>V(g)==="sidebar-empty").forEach(g=>g.api.close())}const f=D(i,"bottom");c.bottom>0&&f.length===0?e(l=>({stash:{...l.stash,bottom:[]},stashActive:{...l.stashActive,bottom:null},bottomVisible:!1})):f.length>1&&f.filter(l=>V(l)==="sidebar-empty").forEach(l=>l.api.close()),ve(i),t().refreshTabs(),Q()},showSideView:(n,s)=>{const i=t().api;if(!i)return;if(t()[yn(n)]){const c=D(i,n).find(f=>f.group?.activePanel?.id===f.id);if(c&&V(c)===s){t().toggleSidebar(n),t().refreshTabs();return}}else t().toggleSidebar(n);const r=D(t().api,n).find(c=>V(c)===s);r?r.api.setActive():t().openView(s,{},n),t().refreshTabs()},closeSideView:(n,s)=>{const i=t().api;if(!i)return;const o=D(i,n).find(a=>V(a)===s);o&&!ct(i,o)&&o.api.close(),t().refreshTabs()},closeViewsOfType(n,s){const i=t().api;if(i){for(const o of i.panels.filter(a=>V(a)===n))t().closeLeaf(o.id,s);t().refreshTabs()}},replaceViewsOfType(n,s,i={}){const o=t().api;if(!o||n===s||!W(s))return 0;const a=o.activePanel?.id,r=W(s);let c=0,f=0,l=!1,m=!0;const g=t().pinned;for(const A of[...o.panels]){if(V(A)!==n)continue;const M=(A.params??{}).__loc??"main",O=ct(o,A);O&&a===A.id&&(m=!1);const $=M!=="main"||O||Ie(g,"main",s);if(M==="main"&&!($&&D(o,"main").some(y=>y!==A&&V(y)===s))){t().navigateLeaf(A.id,s,i)&&c++;continue}const u=A.group,b=D(o,M).find(y=>y!==A&&V(y)===s);if(b){if(Object.keys(i).length&&b.api.updateParameters({...b.params??{},...i}),u?.activePanel===A&&(b.api.setActive(),l=!0),O)continue;M==="main"?t().closeLeaf(A.id):o.removePanel(A),c++,f++;continue}const h=u?.panels?.indexOf(A)??-1;o.addPanel({id:r.singleton&&!o.getPanel(s)?s:rt(o,s),component:s,title:B(r.displayName),params:{...i,__loc:M,__type:s},position:{referencePanel:A,...h>=0?{index:O?h+1:h}:{}},inactive:u?.activePanel!==A}),O||o.removePanel(A),c++,f++}f&&(t().refreshTabs(),Q());const p=a?o.getPanel(a):void 0;(c||l)&&p&&m&&(p.group?.activePanel===p?p.group.api.setActive():p.api.setActive());const d=(A,M)=>{if(Ie(g,A,n)||!M.some(u=>u.type===n))return M;const O=M.find(u=>u.type===s);if(O)return M.filter(u=>u.type!==n).map(u=>u===O?{...u,params:{...u.params??{},...i}}:u);const $=M.findIndex(u=>u.type===n);return M.filter((u,b)=>u.type!==n||b===$).map(u=>u.type===n?{type:s,params:{...i}}:u)},{stash:S,stashActive:_,sidebarDefaults:v}=t();let I=["left","right","bottom"].reduce((A,M)=>A+(Ie(g,M,n)?0:S[M].filter(O=>O.type===n).length),0);const C=A=>{const M=S[A],O=M.findIndex($=>$.type===n);return O<0||!Ie(g,A,n)?M:M.some($=>$.type===s)?Object.keys(i).length?M.map($=>$.type===s?{...$,params:{...$.params??{},...i}}:$):M:(I++,[...M.slice(0,O+1),{type:s,params:{...i}},...M.slice(O+1)])};return e({stash:{left:d("left",C("left")),right:d("right",C("right")),bottom:d("bottom",S.bottom)},stashActive:Object.fromEntries(["left","right","bottom"].map(A=>[A,_[A]===n?s:_[A]])),sidebarDefaults:{left:d("left",v.left),right:d("right",v.right),bottom:d("bottom",v.bottom)}}),I&&(t().refreshTabs(),Q()),c+I},remapLeaves(n){for(const o of[...t().api?.panels??[]]){const{__loc:a,__type:r,...c}=o.params??{},f=n(V(o),c);f===null?t().closeLeaf(o.id,!0):f&&ge(o).setParams(f)}let s=!1;const i=Object.fromEntries(Object.entries(t().stash).map(([o,a])=>[o,a.flatMap(r=>{const c=n(r.type,r.params);return c===void 0?[r]:(s=!0,c===null?[]:[{...r,params:{...r.params,...c}}])})]));s&&(e({stash:i}),t().refreshTabs(),Q()),t().ensurePinned()},resetLayout(n){const s=t().api;if(!s)return;let i=null;if(n?.undoable)try{i={env:Ks(s,t()),api:s,profile:t().sideProfileKey,owner:ye,stashActive:{...t().stashActive}}}catch{i=null}Bs(),Lo();try{s.clear()}catch{}if(Gn(),ye=void 0,fe.getState().reset(),Vt=null,xe=null,e({stash:{left:[],right:[],bottom:[]},stashActive:{left:null,right:null,bottom:null},leftVisible:!0,rightVisible:!0,bottomVisible:!1,focusedChatLeafId:null}),t().defaultBuilder?.(),Q(),i){const o={...i,shape:rr(s),metrics:ai(s),settleUntil:Date.now()+Vl};Fe=o;const a=Za.notify?.(Ze("lcl.layout.restored"),{label:Ze("lcl.layout.undo"),run:()=>{t().undoResetLayout()}});typeof a=="function"&&Fe===o&&(o.dismiss=a)}},noteLayoutChange(){const n=Fe;if(!n)return;const s=t().api;if(!s||!jo(n,s)){Bs();return}Date.now()<n.settleUntil&&(n.metrics=ai(s))},undoResetLayout(){const n=Fe;Fe=null;const s=t().api;if(!n||!s||n.profile!==t().sideProfileKey||!jo(n,s))return!1;const i=t().applyLayout(n.env);return i&&(ye=n.owner,e({stashActive:n.stashActive}),Q()),i},repinSides:()=>{const n=t().api;n&&ve(n)},openView(n,s={},i="main",o){const a=t().api;if(!a)return null;const r=W(n);if(i==="main"&&ui()){const d=tn(a);if(d)return Ao(a,d,n,s)}if(r?.singleton&&!o?.newTab){const d=s.reuseKey,S=a.panels.find(_=>{if(V(_)!==n)return!1;if(d===void 0)return!0;const v=_.params??{};return v.reuseKey===d||d==="primary"&&v.reuseKey===void 0&&v.followActive!==!1});if(S)return d==="primary"&&S.api.updateParameters({...S.params??{},...s}),vn(a,ke(S)),S.api.setActive(),ge(S)}if(i==="main"&&!o?.newTab){const d=tn(a);if(d&&o?.split)return vi(a,d,n,s,Ol(a,d));if(d)return t().navigateLeaf(d.id,n,s)}if(i!=="main"&&!o?.newTab){const d=D(a,i).find(S=>V(S)===n);if(d)return vn(a,i),d.api.setActive(),ge(d)}const c=r?.singleton&&!o?.newTab?n:rt(a,n),f=r?B(r.displayName):n,l=i!=="main"&&D(a,i).length===0,m=l?Ye(a):null,g=l&&!Fs?St():()=>{},p=a.addPanel({id:c,component:i==="main"?"__frame":n,title:f,params:{...s,__loc:i,__type:n},position:Nn(a,i)});return l&&(Kt(a,m),i==="bottom"&&Un(a),g()),vn(a,i),i!=="main"&&e({[yn(i)]:!0}),n==="chat"&&e({focusedChatLeafId:p.id}),Q(),ge(p)},navigateLeaf(n,s,i={}){const o=t().api,a=o?.getPanel(n);return!o||!a||!W(s)?null:ui()&&ke(a)==="main"?Ao(o,a,s,i):V(a)!==s&&ct(o,a)?ke(a)==="main"?vi(o,a,s,i):null:Ds(o,a,s,i)},getActiveLeaf(){const s=t().api?.activePanel;return s?ge(s):null},leafById(n){const s=t().api?.getPanel(n);return s?ge(s):null},splitActive(n,s){const i=t().api,o=i?.activePanel;if(!i||!o)return null;const a=V(o);if(a==="__extend")return null;const{__loc:r,__type:c,...f}=o.params??{},l=r==="left"||r==="right",m=i.addPanel({id:rt(i,a),component:r&&r!=="main"?a:"__frame",title:o.title??a,params:{...f,...s,__loc:r??"main",__type:a},position:{referencePanel:o.id,direction:n==="right"&&!l?"right":"below"}});return a==="chat"&&e({focusedChatLeafId:m.id}),Q(),ge(m)},toggleSidebar(n){const s=t().api;if(!s)return;const i=Ye(s),o=n==="bottom",a=o?"height":"width",r=v=>o?v.api.height:v.api.width,c=()=>o?en(s):qe(s,n),f=(v,I)=>{try{v.api.setSize({[a]:I})}catch{}},l=()=>{o||ve(s),setTimeout(()=>{S()||Zt(s,i)},80)},m=()=>o?()=>{}:ar(s,n),g=yn(n),p=D(s,n),d=++Me[n],S=()=>d!==Me[n];if(p.length>0){const v=p.filter(u=>!["sidebar-empty","__extend"].includes(V(u))).map(u=>{const{__loc:b,__type:h,...y}=u.params??{};return{type:V(u),params:y}}),I=p.find(u=>u.group?.activePanel?.id===u.id),C=I&&!["sidebar-empty","__extend"].includes(V(I))?V(I):t().stashActive[n];p.every(u=>V(u)==="__extend")&&v.push(...t().stash[n]),e(u=>({stash:{...u.stash,[n]:v},stashActive:{...u.stashActive,[n]:C},[g]:!1}));const A=p[0].group;oe[n]?.();const M=m(),O=()=>{oe[n]===O&&(delete oe[n],M())};oe[n]=O;const $=()=>{if(S())return;const u=St();o?yi(s,p[0].group,p):p.forEach(b=>{try{b.api.close()}catch{}}),u(),l(),setTimeout(O,180),Q()};if(A){ne[n]=!0;try{A.api.setConstraints?.(o?{minimumHeight:0}:{minimumWidth:0})}catch{}const u=r(A)??c();Jn(A,a,u,0,()=>{S()||(ne[n]=!1,$())},S)}else $()}else{const v=k=>!!W(k.type),I=t().stash[n].filter(v),C=t().sidebarDefaults[n].filter(v),A=I.length?I:C,M=A.length?A:[{type:"sidebar-empty",params:{}}];e({[g]:!0}),ne[n]=!0,oe[n]?.();const O=m(),$=()=>{oe[n]===$&&(delete oe[n],O())};oe[n]=$;const u=St();Fs=!0;try{M.forEach(k=>t().openView(k.type,k.params,n))}finally{Fs=!1}u();const b=t().stashActive[n]??M[0]?.type??null;if(b){const k=D(s,n).find(x=>V(x)===b);k&&t().activateLeaf(k.id)}const h=D(s,n)[0]?.group,y=()=>{S()||(ne[n]=!1,l(),setTimeout($,180),Q())};if(h){try{h.api.setConstraints?.(o?{minimumHeight:0}:{minimumWidth:0})}catch{}f(h,1),Jn(h,a,1,c(),()=>{if(!S()){try{h.api.setConstraints?.(o?{minimumHeight:Qt}:{minimumWidth:Qt})}catch{}y()}},S)}else y()}},saveCurrent(){const n=t().api;n&&Bi(Ks(n,t()))},saveNamed(n){const s=t().api;s&&or(n,Ks(s,t()))},applyNamed(n){const s=wt(n);return!t().api||!s||Cl(s)?!1:(Bs(),t().applyLayout(s))},applyLayout(n){const s=t().api;if(!s)return!1;try{return ps(n),Lo(),Qe.clear(),s.fromJSON(n.dockview),Kt(s),gi(),fe.getState().reset(),Vt=null,xe=n.sidebars.right.rule??null,e({leftVisible:n.sidebars.left.visible,rightVisible:n.sidebars.right.visible,bottomVisible:n.sidebars.bottom?.visible??!1,stash:{left:n.sidebars.left.stash,right:n.sidebars.right.stash,bottom:n.sidebars.bottom?.stash??[]}}),ve(s),e({mainTabs:[]}),t().refreshTabs(),!0}catch{return!1}},namedLayouts:()=>Object.keys(ln())}));function qi(e){const t=e?.panels;if(!t)return!0;for(const n of Object.values(t)){const s=n?.params?.__type;if(s&&!W(s))return!1}return!0}const Fl={sessions:"workspace",files:"workspace","amadeus-pages":"workspace",toc:"outline","amadeus-outline":"outline","inbox-list":{type:"workspace",params:{mode:"plugin:inbox:messages"}}};function Ro(e){const t=e?Fl[e]:void 0;return t?typeof t=="string"?{type:t,params:{}}:t:null}function ps(e){const t=e.dockview?.panels;if(t)for(const n of Object.values(t)){if(!n||typeof n!="object")continue;const s=n.params??={},i=Ro(s.__type);if(i){s.__type=i.type,n.contentComponent=i.type;const o=s;for(const[a,r]of Object.entries(i.params))o[a]===void 0&&(o[a]=r)}(s.__loc??"main")==="main"&&(n.contentComponent="__frame")}for(const n of["left","right","bottom"]){const s=e.sidebars?.[n];s&&(s.stash=s.stash.map(i=>{const o=Ro(i.type);return o?{...i,type:o.type,params:{...o.params,...i.params??{}}}:i}))}}let wi=null;const Dl=()=>wi===!1;function bh(e){return wi=Wl(e),wi}function vh(e){const t=wt(e);return t?(ps(t),qi(t.dockview)):!1}function yh(){const e=cn();return e?(ps(e),qi(e.dockview)):!0}function Wl(e){ye=void 0;const t=cn();if(!t||(ps(t),!qi(t.dockview)))return!1;const n=s=>!!W(s.type);try{Qe.clear(),xe=t.sidebars.right.rule??null,e.fromJSON(t.dockview),Kt(e),gi(e),X.setState({leftVisible:t.sidebars.left.visible,rightVisible:t.sidebars.right.visible,bottomVisible:t.sidebars.bottom?.visible??!1,stash:{left:t.sidebars.left.stash.filter(n),right:t.sidebars.right.stash.filter(n),bottom:(t.sidebars.bottom?.stash??[]).filter(n)}});const s=e.activePanel&&V(e.activePanel)==="chat"?e.activePanel:e.panels.find(i=>V(i)==="chat");return X.getState().setFocusedLeaf(s),ve(e),e.panels.length?(ye=t.space||null,!0):!1}catch{return!1}}let Kl=0;const wh=(e,t)=>{const n=X.getState().api;if(!n)throw new Error("Workbench is not ready");const s=Ye(n),i=e.side??"right";be[i]?.dismiss("layout"),be[i]?.dispose(!0),++Me[i],oe[i]?.();const o=ne[i];ne[i]=!1;const a=D(n,i),r=a.find(h=>h.group.activePanel===h),c=document.createElement("div");c.className="wb-extend-target";const f=`__extend-${++Kl}`,l=i==="bottom",m=l?"height":"width",g=l?{minimumHeight:0}:{minimumWidth:0},p=l?{minimumHeight:Qt}:{minimumWidth:Qt},d=typeof requestAnimationFrame=="function",S=i==="bottom"||a.length>0||X.getState().sideWidths[i]!=null?void 0:dl(n.width,qe(n,i)),_=()=>{oe[i]?.();const h=l?Hi(n,["left","right"],!0):ar(n,i),y=()=>{oe[i]===y&&(delete oe[i],h())};return oe[i]=y,y};let v,I,C=!1,A=!1,M=null,O=null;const $={id:f,dismiss:t,previousId:r?.id,defaultWidth:S,dispose(h=!1){if(C)return M??void 0;C=!0,I?.dispose(),A&&(A=!1,ne[i]=!1,++Me[i],O?.());const y=v?.group.activePanel===v;be[i]===$&&delete be[i],Jt.delete(f);const k=()=>{ve(n);const z=St();v&&n.getPanel(f)===v&&(l?yi(n,v.group,[v]):v.api.close()),y&&r&&n.getPanel(r.id)===r&&r.api.setActive(),z(),c.remove(),X.getState().syncPanelState(),X.getState().refreshTabs(),ve(n),setTimeout(()=>Zt(n,s),80),Q()},x=v?.group,E=!!v&&n.getPanel(f)===v&&(v.group.panels?.length??0)===1,L=x?(l?x.api.height:x.api.width)??0:0;if(h||!E||!x||L<2||!d){k();return}const T=++Me[i],N=()=>T!==Me[i],F=_();ne[i]=!0;try{x.api.setConstraints?.(g)}catch{}return M=new Promise(z=>{let q=!1;const j=()=>{q||(q=!0,ne[i]=!1,k(),setTimeout(F,180),z())};Jn(x,m,L,0,j,N),setTimeout(j,260)}),M}};be[i]=$,Jt.set(f,c);const u=St();O=_();const b=a.length?null:Ye(n);try{if(v=n.addPanel({id:f,component:"__extend",title:typeof e.title=="function"?e.title():e.title,params:{__loc:i,__type:"__extend"},position:Nn(n,i)}),a.length){if(v.group.api.setConstraints(p),o){try{v.group.api.setSize({[m]:l?en(n):qe(n,i)})}catch{}l?Un(n):ve(n)}}else{Kt(n,b);const h=v.group,y=Me[i],k=()=>y!==Me[i]||C,x=l?en(n):qe(n,i);A=d,ne[i]=d;try{h.api.setConstraints?.(g)}catch{}try{h.api.setSize({[m]:1})}catch{}Jn(h,m,1,x,()=>{if(!k()){A=!1,ne[i]=!1;try{h.api.setConstraints?.(p)}catch{}l?Un(n):ve(n),setTimeout(()=>{C||Zt(n,s)},80),setTimeout(()=>O?.(),180),Q()}},k)}return I=n.onDidRemovePanel(h=>{h===v&&(t("layout"),$.dispose())}),X.getState().syncPanelState(),X.getState().refreshTabs(),Q(),{element:c,titled:l,activate:()=>{C||v?.api.setActive()},dispose:$.dispose}}catch(h){throw $.dispose(!0),h}finally{u(),A||O?.()}};function te(e){return e==="left"?"leftLeaves":e==="right"?"rightLeaves":"mainLeaves"}function lt(e){return e==="left"?"leftActiveId":e==="right"?"rightActiveId":"activeMainId"}function Sn(e,t){const n=new Set(t);let s=1;for(;n.has(`${e}#${s}`);)s++;return`${e}#${s}`}function cr(e){try{const t=new URLSearchParams(location.search).get("window");return t&&t!=="main"?`${e}_${t}`:e}catch{return e}}const Le=rn(cr("lcl_sc_layout_v1")),De=rn(cr("lcl_sc_named_layouts_v1"));function $o(e){try{const t=e?Ee(Le):null,n=t?.main,s=Ui(t);(!e||(s?s===e.space:Array.isArray(n)&&n.some(a=>e.mainTypes.includes(a?.type??""))))&&localStorage.removeItem(Le);const o=Ee(De);if(!o)return;for(const a of Object.keys(o))(e?a===`space:${e.space}`:a.startsWith("space:"))&&delete o[a];localStorage.setItem(De,JSON.stringify(o))}catch{}}function Ee(e){try{const t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function zo(e,t){if(!fs)try{localStorage.setItem(e,JSON.stringify(t))}catch(n){console.warn("[lcl] 单列布局存盘失败",e,n)}}function Gi(e){const t=e;return!!t&&t.v===1&&Array.isArray(t.main)&&Array.isArray(t.left)&&Array.isArray(t.right)}const Ui=e=>typeof e?.space=="string"&&e.space?e.space:null,Hs=e=>e.filter(t=>!!t&&typeof t=="object"&&typeof t.id=="string"&&typeof t.type=="string"&&!!t.params&&typeof t.params=="object"&&!!W(t.type));let nn=!1,Xn=null;function Bl(e){Xn=e}let lr=null;function Hl(e){lr=e}function ql(){if(R.getState().mainLeaves.length)return nn=!0,mr(),!0;Pt=void 0;const e=Ee(Le),t=dr(e);return t&&(Pt=Ui(e)),nn=!0,t}let ur=null,Pe=null,qs=!1;const Gl=e=>{const t=W(e);return!!t&&t.kind!=="entity"};function Vo(e){const t=e.mainLeaves.find(n=>n.id===e.activeMainId);return qa(t?.type,t?W(t.type)?.rightCompanions:void 0,e.sidebarDefaults.right,Gl)}let Pt;const Tn=()=>!nn&&!R.getState().mainLeaves.length,Ul=()=>{if(Tn()){const e=Ee(Le);return Gi(e)?Ui(e):null}return Pt===void 0?ur:Pt};function dr(e){if(!Gi(e))return!1;const t=Hs(e.main);if(t.every(o=>o.type==="home"))return!1;const n=Hs(e.left),s=Hs(e.right),i=(o,a)=>a.some(r=>r.id===o)?o:a[a.length-1]?.id??null;return fe.getState().reset(),Pe=typeof e.rightRule=="string"?e.rightRule:null,R.setState({mainLeaves:t,leftLeaves:n,rightLeaves:s,activeMainId:i(e.activeMainId,t),leftActiveId:i(e.leftActiveId,n),rightActiveId:i(e.rightActiveId,s),leftVisible:!1,rightVisible:!1,focusedChatLeafId:t.find(o=>o.type==="chat")?.id??null}),fr(),R.getState().refreshTabs(),Xn?.(),!0}function fr(){const e=R.getState();e.wideMode&&!e.leftVisible&&(e.leftLeaves.length>0||e.sidebarDefaults.left.length>0)&&e.toggleSidebar("left")}function Fo(){const e=R.getState(),t=s=>{const i=e[te(s)].filter(o=>o.type!=="__extend");return i.find(o=>o.id===e[lt(s)])?.id??i.find(o=>o.id===We[s]?.previousId)?.id??i[0]?.id??null},n=Ul();return{v:1,...n?{space:n}:{},main:e.mainLeaves,left:e.leftLeaves.filter(s=>s.type!=="__extend"),right:e.rightLeaves.filter(s=>s.type!=="__extend"),activeMainId:e.activeMainId,leftActiveId:t("left"),rightActiveId:t("right"),...Pe!==null?{rightRule:Pe}:{}}}let kt=null;function mr(){!nn||kt||(kt=setTimeout(()=>{kt=null,R.getState().saveCurrent()},200))}typeof window<"u"&&window.addEventListener("pagehide",()=>{!nn||!kt||(clearTimeout(kt),kt=null,R.getState().saveCurrent())});const R=ue((e,t)=>{const n=()=>[...t().mainLeaves,...t().leftLeaves,...t().rightLeaves],s=l=>n().find(m=>m.id===l),i=()=>ee?{}:t().pinned,o=l=>Bn(i(),n(),l.loc,l.type),a=l=>({id:l.id,type:l.type,loc:l.loc,get params(){return s(l.id)?.params??l.params},setTitle:m=>{const g=s(l.id);!g||g.title===m||(e(p=>({[te(l.loc)]:p[te(l.loc)].map(d=>d.id===l.id?{...d,title:m}:d)})),t().refreshTabs())},setParams:m=>{const g=s(l.id);if(!g)return;const p={...g.params,...m},d=new Set([...Object.keys(g.params),...Object.keys(p)]);let S=!1;for(const _ of d)if(g.params[_]!==p[_]){S=!0;break}S&&(e(_=>({[te(l.loc)]:_[te(l.loc)].map(v=>v.id===l.id?{...v,params:p}:v)})),t().refreshTabs())},close:()=>t().closeLeaf(l.id)}),r=(l,m)=>{e({[lt(l)]:m}),l==="main"&&s(m)?.type==="chat"&&e({focusedChatLeafId:m})},c=()=>{const l=t(),m={};!l.wideMode&&l.leftVisible&&(m.leftVisible=!1),l.rightVisible&&(m.rightVisible=!1),Object.keys(m).length&&e(m)},f=(l,m,g)=>{const p=W(m);if(!p)return null;const d=l.type==="chat",S={...l,type:m,params:{...g},title:B(p.displayName)};if(e(_=>({[te(l.loc)]:_[te(l.loc)].map(v=>v.id===l.id?S:v)})),m==="chat")e({focusedChatLeafId:l.id});else if(d&&t().focusedChatLeafId===l.id){const _=t().mainLeaves.find(v=>v.id!==l.id&&v.type==="chat");e({focusedChatLeafId:_?.id??null})}return l.loc==="main"&&c(),t().refreshTabs(),a(S)};return{api:null,mainLeaves:[],leftLeaves:[],rightLeaves:[],activeMainId:null,leftActiveId:null,rightActiveId:null,leftVisible:!1,rightVisible:!1,wideMode:!1,focusedChatLeafId:null,chatSurfaces:{},sidebarDefaults:{left:[],right:[]},mainTabs:[],leftTabs:[],rightTabs:[],defaultBuilder:null,pinned:{},setPinned:l=>{e({pinned:l??{}}),t().refreshTabs()},isPinnedLeaf:l=>{const m=s(l);return!!m&&o(m)},ensurePinned:()=>{const l=[...n()];for(const g of["left","right"])if(!t()[te(g)].length)for(const p of t().sidebarDefaults[g])l.push({loc:g,type:p.type});const m=Ha(i(),l,g=>!!W(g));if(m.length){for(const g of m){const p=te(g.loc),d=t()[p];if(g.loc==="main"&&d.length===1&&d[0].type==="home"){f(d[0],g.type,g.params);continue}const S=W(g.type),_={id:S.singleton&&!s(g.type)?g.type:Sn(g.type,n().map(v=>v.id)),type:g.type,loc:g.loc,params:g.params,title:B(S.displayName)};e({[p]:[_,...d],...d.length?{}:{[lt(g.loc)]:_.id}})}t().refreshTabs()}},applyRightRules:()=>{if(ee)return;const l=t(),m=Vo(l);if(!m||m.key===Pe)return;const g=Pe!==null;Pe=m.key;const p=l.sidebarDefaults.right,d=l.rightLeaves.filter(h=>h.type==="__extend"),S=l.rightLeaves.filter(h=>h.type!=="__extend"&&h.type!=="sidebar-empty"),_=S.length?S:p.filter(h=>!!W(h.type)).map((h,y)=>({id:`\0default${y}`,type:h.type,loc:"right",params:h.params??{},title:""})),v=_.map(h=>({id:h.id,type:h.type,tagged:h.by==="rule",active:h.id===l.rightActiveId})),I=new Set([...l.mainLeaves,...l.leftLeaves].map(h=>h.type).filter(h=>W(h)?.singleton)),C=li({group:m.group,pinned:i().right??[],spaceDefaults:p,current:v,changed:g,elsewhere:I});if(!C.open.length&&!C.close.length&&!C.activate)return;const A=new Set(n().map(h=>h.id)),M=(h,y,k)=>{const x=W(h),E=x.singleton&&!A.has(h)?h:Sn(h,A);return A.add(E),{id:E,type:h,loc:"right",params:{...y},title:B(x.displayName),...k?{by:k}:{}}},O=_.filter(h=>!C.close.includes(h.id)).map(h=>S.length?h:M(h.type,h.params)),$=Ga(m.group,O,h=>{const y=C.open.find(k=>k.type===h);return y?M(y.type,y.params??{},"rule"):void 0}),u=C.activate?$.find(h=>h.type===C.activate)?.id:void 0,b=$.some(h=>h.id===l.rightActiveId)||d.some(h=>h.id===l.rightActiveId);e({rightLeaves:[...$,...d],rightActiveId:u??(b?l.rightActiveId:$[0]?.id??null)}),t().refreshTabs()},setApi:()=>{},setWideMode:l=>e({wideMode:l}),setDefaultBuilder:l=>e({defaultBuilder:l}),setSidebarDefaults:l=>e({sidebarDefaults:l}),setSideProfile:l=>{ur=l,Pt=void 0},initializeSidebar:(l,m)=>e({[l==="left"?"leftVisible":"rightVisible"]:m}),registerChatSurface:(l,m)=>e(g=>{const p={...g.chatSurfaces};return m?p[l]=m:delete p[l],{chatSurfaces:p}}),syncPanelState:()=>{},refreshTabs:()=>{const l=t(),m=(d,S)=>{const _=W(d.type);return{id:d.id,type:d.type,title:d.title||(_?B(_.displayName):d.type),active:S,closable:_?.closable!==!1&&!o(d),sessionId:typeof d.params.sessionId=="string"?d.params.sessionId:void 0,followActive:d.params.followActive!==!1,filePath:typeof d.params.notePath=="string"?d.params.notePath:typeof d.params.path=="string"?d.params.path:void 0,front:S,sig:hs(d.params)}},g=(d,S)=>d.map(_=>{const v=W(_.type);return{type:_.type,title:_.title||(v?B(v.displayName):_.type),active:_.id===S,closable:v?.closable!==!1&&!o(_)}});e({mainTabs:l.mainLeaves.map(d=>m(d,d.id===l.activeMainId)),leftTabs:g(l.leftLeaves,l.leftActiveId),rightTabs:g(l.rightLeaves,l.rightActiveId)});const p=ee?null:Vo(t());p&&p.key!==Pe&&!qs&&(qs=!0,queueMicrotask(()=>{qs=!1;try{t().applyRightRules()}catch(d){console.error("[lcl] right panel rules",d)}}))},openView(l,m={},g="main",p){if(ee){const v=ko({type:l,params:m});if(!v)return null;l=v.type,m=v.params??{},g="main",p=void 0}const d=g==="main"&&!ee&&lr?.(l)===!0,S=W(l);if(S?.singleton){const v=m.reuseKey,I=n().find(C=>C.type!==l?!1:v===void 0?!0:C.params.reuseKey===v||v==="primary"&&C.params.reuseKey===void 0&&C.params.followActive!==!1);if(I){const C=S.idParam;return d&&C&&m[C]!=null&&I.params.followActive===!1&&I.params[C]!==m[C]?(r(I.loc,I.id),f(I,l,m)):((ee||v==="primary")&&e(A=>({[te(I.loc)]:A[te(I.loc)].map(M=>M.id===I.id?{...M,params:{...M.params,...m}}:M)})),r(I.loc,I.id),I.loc==="main"&&c(),t().refreshTabs(),a(I))}}if(g==="main"&&!p?.newTab&&t().activeMainId)return t().navigateLeaf(t().activeMainId,l,m);if(g!=="main"){const I=t()[te(g)].find(C=>C.type===l);if(I)return r(g,I.id),t().refreshTabs(),a(I)}const _={id:S?.singleton?l:Sn(l,n().map(v=>v.id)),type:l,loc:g,params:m,title:S?B(S.displayName):l};return e(v=>({[te(g)]:[...v[te(g)],_]})),e({[lt(g)]:_.id}),l==="chat"&&e({focusedChatLeafId:_.id}),g==="main"&&c(),t().refreshTabs(),a(_)},navigateLeaf(l,m,g={}){if(ee){const d=ko({type:m,params:g});if(!d)return null;m=d.type,g=d.params??{}}const p=s(l);return!p||!W(m)?null:p.type!==m&&o(p)?p.loc==="main"?t().openView(m,g,"main",{newTab:!0}):null:f(p,m,g)},getActiveLeaf(){const l=t().activeMainId,m=l?s(l):void 0;return m?a(m):null},getActiveSideLeaf(l){const m=l==="left"?t().leftActiveId:t().rightActiveId,g=m?s(m):void 0,p=(l==="left"?t().leftLeaves:t().rightLeaves)[0],d=g??p;return d?a(d):null},leafById(l){const m=s(l);return m?a(m):null},splitActive(l,m){const g=t().activeMainId?s(t().activeMainId):void 0;return g?t().openView(g.type,{...g.params,...m},"main",{newTab:!0}):null},toggleSidebar(l){const m=l==="left"?"leftVisible":"rightVisible";if(t()[m]){e({[m]:!1});return}if(t()[te(l)].length===0)for(const d of t().sidebarDefaults[l])t().openView(d.type,d.params,l);e({[m]:!0}),t().refreshTabs()},showSideView(l,m){const g=l==="left"?"leftVisible":"rightVisible";t()[g]||t().toggleSidebar(l);const p=t()[te(l)].find(d=>d.type===m);p?r(l,p.id):t().openView(m,{},l),t().refreshTabs()},activateLeaf(l){const m=s(l);m&&(r(m.loc,l),m.loc==="main"&&c(),t().refreshTabs())},closeLeaf(l,m){const g=s(l);if(!g)return;if(g.type==="__extend"){const _=We[g.loc];_?.dismiss(),_?.dispose();return}if(g.type==="home"||!m&&o(g))return;if(!ee&&g.loc==="main"&&t().mainLeaves.length<=1){f(g,"home",{}),Xn?.();return}const p=te(g.loc),d=t()[p].filter(_=>_.id!==l);e({[p]:d}),fe.getState().drop(l);const S=lt(g.loc);if(t()[S]===l&&e({[S]:d[d.length-1]?.id??null}),t().focusedChatLeafId===l){const _=t().mainLeaves.find(v=>v.type==="chat");e({focusedChatLeafId:_?.id??null})}t().refreshTabs()},closeViewsOfType(l,m){for(const g of n().filter(p=>p.type===l))t().closeLeaf(g.id,m)},replaceViewsOfType(l,m,g={}){if(l===m||!W(m))return 0;let p=0;const d=W(m);for(const v of n().filter(I=>I.type===l)){const I=o(v),C=te(v.loc),M=v.loc!=="main"||I||Ie(i(),"main",m)?t()[C].find(b=>b.id!==v.id&&b.type===m):void 0,O=t()[lt(v.loc)]===v.id;if(M){Object.keys(g).length&&a(M).setParams(g),O&&r(v.loc,M.id),I||(t().closeLeaf(v.id),p++);continue}if(!I){t().navigateLeaf(v.id,m,g)&&p++;continue}const $=n().map(b=>b.id),u={id:d.singleton&&!$.includes(m)?m:Sn(m,$),type:m,loc:v.loc,params:{...g},title:B(d.displayName)};e(b=>({[C]:[...b[C],u]})),O&&r(v.loc,u.id),p++}t().refreshTabs();const S=(v,I)=>Ie(i(),v,l)?I:I.map(C=>C.type===l?{type:m,params:{...g}}:C),_=t().sidebarDefaults;return e({sidebarDefaults:{left:S("left",_.left),right:S("right",_.right)}}),p},remapLeaves(l){for(const m of n()){const g=l(m.type,m.params);g===null?t().closeLeaf(m.id,!0):g&&a(m).setParams(g)}t().ensurePinned()},resetLayout(){if(Pt=void 0,Pe=null,e({mainLeaves:[],leftLeaves:[],rightLeaves:[],activeMainId:null,leftActiveId:null,rightActiveId:null,leftVisible:!1,rightVisible:!1,focusedChatLeafId:null}),fe.getState().reset(),t().defaultBuilder?.(),fr(),Tn()&&!ee)try{const l=localStorage.getItem(Le);l&&Object.values(Ee(De)??{}).some(m=>JSON.stringify(m)===l)&&localStorage.removeItem(Le)}catch{}t().refreshTabs(),Xn?.()},saveCurrent(){Tn()||zo(Le,Fo())},saveNamed(l){const m=Tn()?Ee(Le):Fo();if(!Gi(m))return;const g=Ee(De)??{};g[l]=m,zo(De,g)},applyNamed(l){return dr((Ee(De)??{})[l])},namedLayouts(){return Object.keys(Ee(De)??{})}}});R.subscribe(mr);const We={};let Jl=0;const Xl=(e,t)=>{const n=e.side==="left"?"left":"right";We[n]?.dismiss("layout"),We[n]?.dispose();const s=R.getState(),i=n==="left"?"leftLeaves":"rightLeaves",o=n==="left"?"leftActiveId":"rightActiveId",a=n==="left"?"leftVisible":"rightVisible",r=`__extend-mobile-${++Jl}`,c=document.createElement("div");c.className="wb-extend-target";const f={id:r,type:"__extend",loc:n,params:{},title:typeof e.title=="function"?e.title():e.title};let l=!1,m;const g={previousId:s[o],dismiss:t,dispose(){if(l)return;l=!0,m?.(),We[n]===g&&delete We[n],Jt.delete(r),c.remove();const p=R.getState();if(!p[i].some(S=>S.id===r))return;const d=p[i].filter(S=>S.id!==r);R.setState({[i]:d,[o]:p[o]===r?d.find(S=>S.id===s[o])?.id??d[0]?.id??null:p[o],[a]:p[a]&&(s[a]||d.length>s[i].length)}),R.getState().refreshTabs()}};return We[n]=g,Jt.set(r,c),R.setState({[i]:[...s[i],f],[o]:r,...n==="left"?{leftVisible:!0,rightVisible:!1}:{rightVisible:!0,...s.wideMode?{}:{leftVisible:!1}}}),R.getState().refreshTabs(),m=R.subscribe(p=>{(!p[a]||!p[i].some(d=>d.id===r))&&(t("layout"),g.dispose())}),{element:c,titled:!0,activate:()=>{l||R.getState().activateLeaf(r)},dispose:g.dispose}},je=Fa==="mobile"||ee?R:X,Ji=ee?"forsion_mini_active_space":"forsion_tangu_active_space",Ge=e=>`space:${e}`,hr="forsion_tangu_recent_spaces",Yl=12;function Zl(){try{const e=JSON.parse(localStorage.getItem(hr)||"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch{return[]}}function Ql(e,t,n){return[t,n,...e.filter(s=>s!==t&&s!==n)].slice(0,Yl)}function pr(){if(le)return le;if(fs)return"tangu";try{return localStorage.getItem(Ji)||"tangu"}catch{return"tangu"}}const eu=pr(),Y=ue((e,t)=>({spaces:[],activeSpaceId:pr(),recent:Zl(),registerSpace:n=>e(s=>({spaces:[...s.spaces.filter(i=>i.id!==n.id),n]})),unregisterSpace:n=>e(s=>({spaces:s.spaces.filter(i=>i.id!==n)})),setActiveSpace:n=>{const{spaces:s,activeSpaceId:i}=t();if(n===i)return;const o=s.find(f=>f.id===n);if(!o||ee&&!Yc(o)||le||ui())return;const a=je.getState();!ee&&!(Dl()&&Oo()===null)&&a.saveNamed(Ge(Oo()??i));const r=Dn?Ql(t().recent,n,i):t().recent;e({activeSpaceId:n,recent:r});try{fs||localStorage.setItem(Ji,n),Dn&&localStorage.setItem(hr,JSON.stringify(r))}catch{}if(ee){a.resetLayout();return}a.setSidebarDefaults(o.sidebarDefaults),a.setSideProfile(n,o.resizableSides??{},o.sideDefaultScale,o.bottomSpan),a.setPinned(o.pinned),a.namedLayouts().includes(Ge(n))&&a.applyNamed(Ge(n))?(a.ensurePinned(),a.saveCurrent()):a.resetLayout(),Xi()}}));let Yn=null;const Sh=()=>Yn;function tu(e){const{spaces:t,activeSpaceId:n}=Y.getState(),s=yl(t,n,e);if(!s)return!1;Yn=e;try{Y.getState().setActiveSpace(s)}finally{Yn=null}return Y.getState().activeSpaceId===s}function Xi(){const e=et()?.mainPage;if(!e||ee||!Dn&&!le||Yn!==null||!W(e.type))return;const t=je.getState();t.refreshTabs();const n=je.getState().mainTabs;if(!n.length)return;const{activate:s,open:i}=bl(et(),n);s?t.activateLeaf(s):i&&t.openView(i.type,i.params,"main",i.newTab?{newTab:!0}:void 0)}const et=()=>{const{spaces:e,activeSpaceId:t}=Y.getState();return le?e.find(n=>n.id===le):e.find(n=>n.id===t)??e[0]};function kh(e,t=!0){const{spaces:n}=Y.getState();if(n.some(s=>s.id===e)){Y.setState({activeSpaceId:e});try{t&&!fs&&!le&&localStorage.setItem(Ji,e)}catch{}}}function xh(){if(!le||cn())return;const e=wt(Ge(le));e&&Bi({...e,space:le})}function Eh(e,t){Y.getState().activeSpaceId;const n=cn(),s=n?.space||e,i=Ge(s),o=s!==e,a=!!n&&(!o||!wt(i));if(a&&or(i,n),s===t||o&&s===Y.getState().activeSpaceId||a&&!wt(i))return;const r=wt(Ge(t));r?Bi({...r,space:t}):Gn()}let gr=!1;const _h=()=>gr;function Mh(e){if(e){Po(Ge(e)),(cn()?.space??eu)===e&&Gn();const t=Y.getState().spaces.find(n=>n.id===e)?.pinned?.main?.map(n=>n.type)??[];$o({space:e,mainTypes:t});return}gr=!0;for(const t of Object.keys(ln()))t.startsWith("space:")&&Po(t);Gn(),$o()}function br(e,t){return!1}const Ih=e=>Y.getState().registerSpace(e),Ph=e=>Y.getState().unregisterSpace(e),vr=e=>Y.getState().setActiveSpace(e);const yr=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const nu=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const su=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const Do=e=>{const t=su(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Gs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const iu=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},ou=P.createContext({}),au=()=>P.useContext(ou),ru=P.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:s,className:i="",children:o,iconNode:a,...r},c)=>{const{size:f=24,strokeWidth:l=2,absoluteStrokeWidth:m=!1,color:g="currentColor",className:p=""}=au()??{},d=s??m?Number(n??l)*24/Number(t??f):n??l;return P.createElement("svg",{ref:c,...Gs,width:t??f??Gs.width,height:t??f??Gs.height,stroke:e??g,strokeWidth:d,className:yr("lucide",p,i),...!o&&!iu(r)&&{"aria-hidden":"true"},...r},[...a.map(([S,_])=>P.createElement(S,_)),...Array.isArray(o)?o:[o]])});const J=(e,t)=>{const n=P.forwardRef(({className:s,...i},o)=>P.createElement(ru,{ref:o,iconNode:t,className:yr(`lucide-${nu(Do(e))}`,`lucide-${e}`,s),...i}));return n.displayName=Do(e),n};const cu=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],lu=J("arrow-left",cu);const uu=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],du=J("bookmark",uu);const fu=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Wo=J("bot",fu);const mu=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],hu=J("bug",mu);const pu=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],gu=J("check",pu);const bu=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],vu=J("chevron-down",bu);const yu=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],wu=J("chevron-right",yu);const Su=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],ku=J("compass",Su);const xu=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],Eu=J("crown",xu);const _u=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Mu=J("database",_u);const Iu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Pu=J("ellipsis",Iu);const Lu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ko=J("file-text",Lu);const Cu=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],Au=J("files",Cu);const Nu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Tu=J("image",Nu);const Ou=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ju=J("layers",Ou);const Ru=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],$u=J("library",Ru);const zu=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Vu=J("log-in",zu);const Fu=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Du=J("message-circle",Fu);const Wu=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],Ku=J("messages-square",Wu);const Bu=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Hu=J("palette",Bu);const qu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Gu=J("panel-left",qu);const Uu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ju=J("panel-right",Uu);const Xu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],gs=J("plus",Xu);const Yu=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Zu=J("send",Yu);const Qu=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],ed=J("sliders-horizontal",Qu);const td=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],nd=J("sparkles",td);const sd=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],id=J("store",sd);const od=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ad=J("users",od);const rd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],bs=J("x",rd);const cd=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],wr=J("zap",cd),Bo=[{id:"starter",icon:ku,medals:{bronze:10,silver:25,gold:55},achievements:[{id:"first-login",event:"account.login",goal:1,points:10,icon:Vu},{id:"theme-change",event:"theme.change",goal:1,points:10,icon:Hu},{id:"market-install",event:"market.install",goal:1,points:15,icon:id},{id:"space-save",event:"space.save",goal:1,points:15,icon:du},{id:"debug-toast",event:"debug.toast",goal:1,points:5,icon:hu}]},{id:"chat",icon:Du,medals:{bronze:10,silver:35,gold:70},achievements:[{id:"first-message",event:"chat.send",goal:1,points:10,icon:Zu},{id:"chat-10",event:"chat.send",goal:10,points:15,icon:Ku},{id:"chat-100",event:"chat.send",goal:100,points:30,icon:Eu},{id:"group-chat",event:"chat.group",goal:1,points:15,icon:ad}]},{id:"notes",icon:Ko,medals:{bronze:10,silver:35,gold:70},achievements:[{id:"first-note",event:"note.create",goal:1,points:10,icon:Ko},{id:"notes-10",event:"note.create",goal:10,points:15,icon:Au},{id:"notes-100",event:"note.create",goal:100,points:30,icon:$u},{id:"first-base",event:"base.create",goal:1,points:15,icon:Mu}]},{id:"agents",icon:Wo,medals:{bronze:15,silver:30,gold:60},achievements:[{id:"first-agent",event:"agent.create",goal:1,points:15,icon:Wo},{id:"agents-3",event:"agent.create",goal:3,points:20,icon:ju},{id:"special-agent",event:"special.enable",goal:1,points:15,icon:nd},{id:"first-image",event:"image.generate",goal:1,points:10,icon:Tu}]}];function Lh(e,t){return e.achievements.reduce((n,s)=>n+(t[s.id]?s.points:0),0)}function Ch(e,t){return t>=e.medals.gold?"gold":t>=e.medals.silver?"silver":t>=e.medals.bronze?"bronze":null}const Yi="forsion_tangu_achievements",Sr=999999,kr="forsion_cloud_achievements",Ho="forsion_achievements_device",ld=3e3;function Zi(){try{const e=JSON.parse(localStorage.getItem(Yi)||"null");if(e?.v===1){const t={};for(const[s,i]of Object.entries(e.counters||{}))typeof i=="number"&&i>0&&(t[s]=Math.min(i,Sr));const n={};for(const s of e.claimed||[])typeof s=="string"&&(n[s]=!0);return{counters:t,claimed:n}}}catch{}return{counters:{},claimed:{}}}function xr(){try{const{counters:e,claimed:t}=ie.getState(),n=Zi();for(const[i,o]of Object.entries(e))n.counters[i]=Math.max(n.counters[i]||0,o);const s={v:1,counters:n.counters,claimed:Object.keys({...n.claimed,...t})};localStorage.setItem(Yi,JSON.stringify(s))}catch{}}const ie=ue((e,t)=>({...Zi(),pluginSeries:[],queue:[],cloud:dd(),claim:n=>{const s=t(),i=un(s).flatMap(o=>o.achievements).find(o=>o.id===n);!i||s.claimed[n]||(s.counters[i.event]||0)<i.goal||(e({claimed:{...s.claimed,[n]:!0}}),xr())},shiftToast:n=>{const s=t().queue;s[0]===n&&e({queue:s.slice(1)})}}));function ud(){const e=ie.getState(),t=Zi(),n={...e.counters};for(const[o,a]of Object.entries(t.counters))n[o]=Math.max(n[o]||0,a);const s={...e.claimed,...t.claimed},i=un(e).flatMap(o=>o.achievements).filter(o=>(e.counters[o.event]||0)<o.goal&&(n[o.event]||0)>=o.goal&&!s[o.id]&&!e.queue.includes(o.id)).map(o=>o.id);ie.setState({counters:n,claimed:s,queue:i.length?[...e.queue,...i]:e.queue})}typeof window<"u"&&window.addEventListener("storage",e=>{e.key===Yi&&ud()});function un(e){const t=(e||ie.getState()).pluginSeries;return t.length?[...Bo,...t.map(n=>n.def)]:Bo}function Ah(e=ie.getState(),t){return!t&&e.cloud&&fd(e.cloud)?!0:(t?[t]:un(e)).some(n=>n.achievements.some(s=>!e.claimed[s.id]&&(e.counters[s.event]||0)>=s.goal))}function Nh(e){for(const t of un()){const n=t.achievements.find(s=>s.id===e);if(n)return{a:n,series:t}}return null}function Er(e,t=1){try{if(!e||!(t>0))return;const n=ie.getState(),s=n.counters[e]||0,i=Math.min(s+Math.floor(t),Sr);if(i===s)return;const o=un(n).flatMap(a=>a.achievements).filter(a=>a.event===e&&s<a.goal&&i>=a.goal&&!n.claimed[a.id]&&!n.queue.includes(a.id)).map(a=>a.id);ie.setState({counters:{...n.counters,[e]:i},queue:o.length?[...n.queue,...o]:n.queue}),xr(),gd(e)}catch{}}function Th(e,t){try{if(!t?.id||!Array.isArray(t.achievements)||!t.achievements.length)throw new Error("empty series");const n=r=>`plugin:${e}:${r}`,s=t.achievements.map(r=>{if(!r.id||!r.event||!(r.goal>0)||!(r.points>=0))throw new Error(`bad achievement "${r.id}"`);return{id:n(r.id),event:n(r.event),goal:Math.floor(r.goal),points:Math.floor(r.points),title:String(r.title||r.id),desc:String(r.desc||"")}}),i=s.reduce((r,c)=>r+c.points,0),o=t.medals&&t.medals.bronze>0?t.medals:{bronze:Math.ceil(i*.25),silver:Math.ceil(i*.6),gold:i},a={id:n(t.id),title:String(t.title||t.id),medals:o,achievements:s};ie.setState(r=>({pluginSeries:[...r.pluginSeries.filter(c=>c.def.id!==a.id),{pluginId:e,def:a}]}))}catch(n){console.error(`[achievements] plugin "${e}" registerSeries failed`,n)}}function Oh(){Er("debug.toast"),ie.setState(e=>e.queue.includes("debug-toast")?e:{queue:[...e.queue,"debug-toast"]})}function jh(e){ie.setState(t=>t.pluginSeries.some(n=>n.pluginId===e)?{pluginSeries:t.pluginSeries.filter(n=>n.pluginId!==e)}:t)}function dd(){try{const e=JSON.parse(localStorage.getItem(kr)||"null");if(e&&Array.isArray(e.list))return{list:e.list,signedIn:!!e.signedIn}}catch{}return{list:[],signedIn:!1}}function _r(e){ie.setState({cloud:e});try{localStorage.setItem(kr,JSON.stringify(e))}catch{}}function fd(e,t){return e.signedIn&&e.list.some(n=>(!t||n.series===t)&&!n.claimed&&!n.expired&&n.progress>=n.goal)}let md=0,qo=0,Qi=0;async function On(e,t="GET",n){const s=typeof window<"u"?window.tangu?.cloudFetch:void 0;if(!s)return null;const i=++md,o=Qi;try{return{...await s({path:e,method:t,...n!==void 0?{body:n}:{}}),seq:i,epoch:o}}catch{return null}}function Mr(){const{list:e}=ie.getState().cloud;_r({signedIn:!1,list:e.filter(t=>t.enabled!==!1).map(t=>({...t,progress:0,claimed:null}))})}function Si(e){if(!e)return!1;const t=e.epoch===Qi&&e.seq>qo;return t&&(qo=e.seq),e.status===401?(t&&Mr(),!1):e.status===200&&Array.isArray(e.json?.achievements)?(t&&_r({signedIn:!0,list:e.json.achievements}),t?"fresh":"stale"):!1}function hd(){try{let e=localStorage.getItem(Ho);return(!e||!/^[A-Za-z0-9_-]{8,64}$/.test(e))&&(e=globalThis.crypto?.randomUUID?.()??`d${Date.now().toString(36)}${Math.random().toString(36).slice(2,12)}`,localStorage.setItem(Ho,e)),e}catch{return"device-unknown"}}function pd(){const e=typeof window<"u"?window.tangu:void 0;return e?.mobile?"Android":{darwin:"Mac",win32:"Windows",linux:"Linux"}[e?.platform||""]||"Web"}function Go(){const e=ie.getState(),t={};for(const n of e.cloud.list)(e.counters[n.event]||0)>0&&(t[n.event]=e.counters[n.event]);return Object.keys(t).length?t:null}async function xt(){const e=o=>On("/achievements/progress","POST",{deviceId:hd(),counts:o}),t=Go();let n=await(t?e(t):On("/achievements/me"));t&&n?.status===429&&(n=await On("/achievements/me"));const s=Si(n),i=!t&&s?Go():null;i&&Si(await e(i))}let Us=null;function gd(e){const{cloud:t}=ie.getState();Us||!t.signedIn||!t.list.some(n=>n.event===e)||(Us=setTimeout(()=>{Us=null,xt()},ld))}const bd=new Set(["not_completed","expired","not_found","grant_failed"]);async function Rh(e){const t=await On(`/achievements/${encodeURIComponent(e)}/claim`,"POST",{device:pd()}),n=Si(t);if(n==="stale"&&xt(),n)return{ok:!0};t&&t.status!==401&&xt();const s=t?.json?.error;return{ok:!1,reason:!t||!t.status?"network":t.status===401?"signed_out":bd.has(s)?s:"unknown"}}let Uo=!1;function $h(){if(Uo||typeof window>"u"||!window.tangu?.cloudFetch)return;Uo=!0,setTimeout(()=>{xt()},4e3),window.tangu.onAuthChanged?.(()=>{Qi++,Mr(),xt()});let e=Date.now();window.addEventListener("focus",()=>{Date.now()-e>6e4&&(e=Date.now(),xt())})}var jt=Gc();const vd=jc(jt),zh=Jc({__proto__:null,default:vd},[jt]),eo="forsion_shortcuts";function Ir(){try{const e=JSON.parse(localStorage.getItem(eo)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Js(e){try{localStorage.setItem(eo,JSON.stringify(e))}catch{}}const to=ue(e=>({overrides:Ir(),recording:!1,setOverride:(t,n)=>e(s=>{const i={...s.overrides,[t]:n};return Js(i),{overrides:i}}),clearOverride:t=>e(n=>{const s={...n.overrides};return delete s[t],Js(s),{overrides:s}}),resetAll:()=>{Js({}),e({overrides:{}})},setRecording:t=>e({recording:t})}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===eo||e.key===null)&&to.setState({overrides:Ir()})});function ki(e){const t=to.getState().overrides;return Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]||"":e.hotkey||""}function Pr(e){if(e.altKey&&so()){const t=/^(?:Key([A-Z])|Digit(\d))$/.exec(e.code||"");if(t)return(t[1]??t[2]).toLowerCase()}return e.key.toLowerCase()}function Vh(e){if(["Control","Shift","Alt","Meta"].includes(e.key))return null;const t=[];(e.metaKey||e.ctrlKey)&&t.push("mod"),e.shiftKey&&t.push("shift"),e.altKey&&t.push("alt");let n=Pr(e);return n===" "?n="space":n==="{"?n="[":n==="}"&&(n="]"),t.push(n),t.join("+")}const no="mod+mod",yd=[no,"shift+shift","alt+alt"],Lr=e=>yd.includes(e),Jo=new Set,Cr=new WeakMap;let Xo=!1;function Yo(e,t){const n=e.replace(/(Left|Right)$/,"");return n===e?null:n===(t?"Meta":"Control")?no:n==="Shift"?"shift+shift":n==="Alt"?"alt+alt":null}function wd(e,t,n){if(t.type==="keyup")return e.delete(t.code),null;const s=Yo(t.code,n);if(!s)return e.clear(),null;if(t.repeat||([...e].some(o=>Yo(o,n)!==s)&&e.clear(),e.add(t.code),e.size<2))return null;const i=s===no?n?"metaKey":"ctrlKey":s==="shift+shift"?"shiftKey":"altKey";return["metaKey","ctrlKey","shiftKey","altKey"].some(o=>o!==i&&t[o])?null:(e.clear(),s)}function Ar(){if(Xo||typeof window>"u")return;Xo=!0;const e=t=>{const n=wd(Jo,t,so());n&&Cr.set(t,n)};window.addEventListener("keydown",e,!0),window.addEventListener("keyup",e,!0),window.addEventListener("blur",()=>Jo.clear())}function Sd(e){return Ar(),Cr.get(e)??null}function so(){try{return document.documentElement.dataset.platform==="mac"}catch{return!1}}function Nr(e,t){if(!e)return"";if(Lr(e)){const r=Nr(e.split("+")[0],t);return`${r} + ${r}`}const n=t?{mod:"⌘",shift:"⇧",alt:"⌥",space:"Space",enter:"↵",escape:"Esc",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→"}:{mod:"Ctrl",shift:"Shift",alt:"Alt",space:"Space",enter:"Enter",escape:"Esc",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→"},s=r=>n[r]||(r.length===1?r.toUpperCase():r.charAt(0).toUpperCase()+r.slice(1)),i=["alt","shift","mod"],o=e.split("+");return(t?[...o.slice(0,-1).sort((r,c)=>i.indexOf(r)-i.indexOf(c)),o[o.length-1]]:o).map(s).join(t?"":"+")}Ar();const he=ue((e,t)=>({commands:[],paletteOpen:!1,pickCb:null,addCommand:n=>e(s=>({commands:[...s.commands.filter(i=>i.id!==n.id),n]})),removeCommand:n=>e(s=>({commands:s.commands.filter(i=>i.id!==n)})),run:(n,s)=>{const i=t().commands.find(o=>o.id===n);if(i){if(s&&i.invoke?.run){i.invoke.run(s);return}i.run(s)}},setPaletteOpen:n=>e(n?{paletteOpen:!0}:{paletteOpen:!1,pickCb:null})})),Tr=e=>he.getState().addCommand(e),Or=e=>he.getState().removeCommand(e),Fh=()=>he.getState().setPaletteOpen(!0),Dh=e=>he.setState({pickCb:e,paletteOpen:!0});function kd(e){const t=he.getState().commands.find(s=>s.id===e),n=t?ki(t):"";return n?Nr(n,so()):""}const xd={"{":"[","}":"]"};function Zo(e,t){if(Lr(e))return Sd(t)===e;const n=e.toLowerCase().split("+").map(l=>l.trim()),s=n[n.length-1],i=n.includes("mod"),o=n.includes("shift"),a=n.includes("alt"),r=t.metaKey||t.ctrlKey;if(i!==r||o!==t.shiftKey||a!==t.altKey)return!1;const c=Pr(t);if((xd[c]??c)===s)return!0;const f=t.key.toLowerCase();return f!==c&&f===s}function Wh(){const e=t=>{if(to.getState().recording||t.defaultPrevented)return;const n=he.getState(),s=ki({id:"command-palette",hotkey:"mod+k"});if(s&&Zo(s,t)){t.preventDefault(),n.setPaletteOpen(!n.paletteOpen);return}for(const i of n.commands){const o=ki(i);if(o&&Zo(o,t)){t.preventDefault(),i.run();return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}const Ed={response:.42,damping:1},Kh={response:.36,damping:.78};function Qo(e,t,{response:n,damping:s}){const i=2*Math.PI/n;if(s>=1)return 1+Math.exp(-i*e)*((t-i)*e-1);const o=i*Math.sqrt(1-s*s);return 1+Math.exp(-s*i*e)*((t-s*i)/o*Math.sin(o*e)-Math.cos(o*e))}function jr(){try{return!!globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}let kn;function _d(){if(jr())return!1;if(kn===void 0)try{kn=CSS.supports("transition-timing-function","linear(0, 1)")}catch{kn=!1}return kn}const ea=1/60,Md=1.2;function Id(e,t,n={}){if(!_d()||!Number.isFinite(e))return null;e=Math.max(-60,Math.min(60,e)),n.clamp&&(e=Math.max(0,e));const s=[0];let i=0,o=!1;for(;i<Md;){i+=ea;let a=Qo(i,e,t);if(n.clamp&&a>=1||Math.abs(1-a)<.002&&Math.abs(Qo(i+ea,e,t)-a)<.001)break;a>=1&&(o=!0),o&&n.give&&(a=1+n.give*Math.tanh((a-1)/n.give)),s.push(a)}return s.push(1),{easing:`linear(${s.map(a=>+a.toFixed(4)).join(", ")})`,ms:Math.max(16,Math.round(i*1e3))}}let Rr=[];function Bh(e){Rr=e}function Pd(e,t,n,s){for(const i of[e,t]){const o=i.indexOf(n),a=i.indexOf(s);if(o>=0&&a>=0)return a>o?"next":"prev"}return"next"}let ta=0,dt=null,xn=null,na=!1;function Ld(){if(na)return;na=!0;const e=(t,n)=>document.elementFromPoint(t,n)?.closest(".rb button, .mb-drawer-foot button")??null;window.addEventListener("pointerdown",t=>{xn=null,dt&&(dt.skipTransition(),xn=e(t.clientX,t.clientY))},!0),window.addEventListener("click",t=>{const n=xn;if(xn=null,!n||t.target!==document.documentElement||e(t.clientX,t.clientY)!==n)return;t.stopPropagation();const{clientX:s,clientY:i,screenX:o,screenY:a,button:r,buttons:c,detail:f,metaKey:l,ctrlKey:m,shiftKey:g,altKey:p}=t;n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:s,clientY:i,screenX:o,screenY:a,button:r,buttons:c,detail:f,metaKey:l,ctrlKey:m,shiftKey:g,altKey:p}))},!0)}function xi(e,t=()=>vr(e),{axis:n="y"}={}){const s=++ta,{activeSpaceId:i,spaces:o}=Y.getState(),a=typeof document>"u"?null:document;if(n==="x"||e===i||!o.some(f=>f.id===e)||ee||le||typeof a?.startViewTransition!="function"||a.visibilityState==="hidden"){dt?.skipTransition(),t();return}Ld();const r=a.documentElement;r.dataset.spaceSwitch=jr()?"fade":Pd(Rr,o.map(f=>f.id),i,e),r.dataset.spaceSwitchAxis=n;const c=a.startViewTransition(()=>{ta===s&&Y.getState().activeSpaceId===i&&jt.flushSync(t)});dt=c,c.ready.catch(()=>{}),c.updateCallbackDone.catch(f=>console.error("[space] switch failed",f)),c.finished.catch(()=>{}).finally(()=>{dt===c&&(dt=null,delete r.dataset.spaceSwitch,delete r.dataset.spaceSwitchAxis)})}const Zn="forsion:uizoom";function Et(e){return e?.currentCSSZoom||1}function Cd(e,t,n,s,i,o,a={}){const{anchorTop:r=t,prefer:c="below",center:f=!1,margin:l=8}=a,m=Math.max(l,Math.min(f?e-n/2:e,i-n-l)),g=_=>_>=l&&_+s<=o-l,p=t,d=r-s,S=c==="above"?[d,p]:[p,d];for(const _ of S)if(g(_))return{left:m,top:_};return{left:m,top:Math.max(l,Math.min(S[0],o-s-l))}}function Ad(e,t,n={}){const{anchorTop:s,prefer:i,center:o,margin:a=8}=n,r=P.useRef(null),[c,f]=P.useState({left:e,top:t,maxWidth:void 0});return P.useLayoutEffect(()=>{const l=r.current;if(!l)return;const m=()=>{const p=Et(l),d=window.innerWidth,S=l.offsetWidth*p,_=Cd(e,t,S,l.offsetHeight*p,d,window.innerHeight,{anchorTop:s,prefer:i,center:o,margin:a}),v=S>d-2*a?(d-2*a)/p:void 0;f(I=>{const C={left:_.left/p,top:_.top/p,maxWidth:v};return I.left===C.left&&I.top===C.top&&I.maxWidth===C.maxWidth?I:C})};m(),window.addEventListener("resize",m),window.addEventListener(Zn,m);const g=new ResizeObserver(m);return g.observe(l),()=>{window.removeEventListener("resize",m),window.removeEventListener(Zn,m),g.disconnect()}},[e,t,s,i,o,a]),{ref:r,style:{left:c.left,top:c.top,maxWidth:c.maxWidth}}}function Nd(e,t,n,s,i=8){if(t<=0)return{dx:0};const o=n-2*i,a=t>o,r=a?o:t;let c=0;return e<i?c=i-e:e+r>n-i&&(c=n-i-r-e),{dx:c/s,maxWidth:a?o/s:void 0}}function Hh(e,t,n,s,i,o=1,a=6,r=8){const c=n*o,f=a*o,l=r*o;return t+f+c<=i-l?"right":e-f-c>=s+l?"left":"stacked"}function qh(e,t,n,s,i,o,a=1,r=8){const c=a>0?a:1,f=r*c,l=i+f,m=Math.min(s,o-f),g=Math.max(l,m-t*c);return(Math.min(Math.max(e,l),g)-n)/c}function Gh(e,t=8){const n=typeof t=="number"?t:t.margin??8,s=typeof t=="number"?void 0:t.boundary,i=P.useRef(null),[o,a]=P.useState({dx:0});return P.useLayoutEffect(()=>{if(!e)return a(m=>m.dx===0&&m.maxWidth===void 0?m:{dx:0});const r=i.current;if(!r)return;const c=()=>{const m=Et(r),g=r.style.translate;r.style.translate="";const p=r.getBoundingClientRect();r.style.translate=g;const d=r.offsetWidth*m,S=s?r.closest(s)?.getBoundingClientRect():void 0,_=S?.left??0,v=S?.right??window.innerWidth,I=(p.left+p.right)/2-d/2-_,{dx:C,maxWidth:A}=Nd(I,d,v-_,m,n);a(M=>Math.abs(M.dx-C)<.5&&M.maxWidth===A?M:{dx:C,maxWidth:A})};c(),Promise.allSettled(r.getAnimations().map(m=>m.finished)).then(()=>{i.current===r&&c()}),window.addEventListener("resize",c),window.addEventListener(Zn,c);const f=new ResizeObserver(c);f.observe(r);const l=s?r.closest(s):null;return l&&f.observe(l),()=>{window.removeEventListener("resize",c),window.removeEventListener(Zn,c),f.disconnect()}},[e,n,s]),{ref:i,style:{translate:o.dx?`${o.dx}px`:void 0,maxWidth:o.maxWidth}}}function Td({x:e,y:t,anchorTop:n,prefer:s,center:i,margin:o,innerRef:a,className:r,style:c,children:f,...l}){const m=Ad(e,t,{anchorTop:n,prefer:s,center:i,margin:o});return w.jsx("div",{ref:g=>{m.ref.current=g,a?.(g)},className:r,style:{...c,...m.style},...l,children:f})}function Od(){let e=null,t=!0,n=!0,s=0;const i=new Set,o=()=>i.forEach(c=>c()),a=c=>{const f=e;if(f){e=null,o();try{f.options.onClose?.(c)}catch(l){console.error("[extend-view] onClose failed",l)}}};return{controller:{open(c){if(!t)throw new Error("Extend view owner is no longer mounted");if(!n)throw new Error("Extend view owner is not visible");if(!c.id||typeof c.mount!="function")throw new Error("Extend view requires an id and mount");if(c.side&&!["left","right","bottom"].includes(c.side))throw new Error("Invalid extend view side");if(e?.options.id===c.id)return e={...e,revision:++s},o(),e.handle;if(a("replace"),!t)throw new Error("Extend view owner is no longer mounted");if(e)return e.handle;const f={id:c.id,get isOpen(){return e?.handle===f},close:()=>{e?.handle===f&&a("close")}};return e={options:{...c},handle:f,revision:++s},o(),f},close:()=>a("close")},getSnapshot:()=>e,subscribe(c){return i.add(c),()=>{i.delete(c)}},dismiss:c=>a(c==="layout"?"layout":"dismiss"),setVisible(c){n=c,c||a("owner")},dispose(){t=!1,a("owner")}}}const $r=(e,t,n)=>{if(!n)throw new Error("Inline extend view requires its owner frame");const s=[...n.children];for(const o of s)o.toggleAttribute("inert",!0);const i=document.createElement("div");return i.className="wb-extend-target wb-extend-inline",n.appendChild(i),n.dataset.extendInline="",{element:i,back:!0,dispose(){for(const o of s)o.removeAttribute("inert");i.remove(),n.querySelector(":scope > .wb-extend-inline")||delete n.dataset.extendInline}}};let it=null;function jd({entry:e,titled:t,back:n,opener:s,onDismiss:i}){const{t:o}=Tt(),a=P.useRef(null),r=P.useRef(null),c=e.options,f=typeof c.title=="function"?c.title():c.title;P.useLayoutEffect(()=>{const m=document.createElement("div");m.className="wb-extend-mount",a.current.appendChild(m);const g=s??(document.activeElement instanceof HTMLElement?document.activeElement:null);let p;try{p=c.mount(m,e.handle)}catch(d){console.error("[extend-view] mount failed",d),m.textContent=o("extendView.failed")}return()=>{const d=r.current?.contains(document.activeElement)||document.activeElement===document.body;try{p?.()}catch(S){console.error("[extend-view] cleanup failed",S)}queueMicrotask(()=>m.remove()),d&&g?.isConnected&&queueMicrotask(()=>{g.isConnected&&(!document.activeElement||document.activeElement===document.body)&&g.focus({preventScroll:!0})})}},[e.handle]),P.useEffect(()=>{(a.current?.querySelector('input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])')??r.current)?.focus({preventScroll:!0})},[e.revision]);const l=c.side??"right";return w.jsxs("section",{ref:r,tabIndex:-1,role:"dialog","aria-label":f,className:"wb-extend","data-side":l,children:[!t&&w.jsxs("header",{className:`wb-extend-head${n?" wb-extend-head--back":""}`,children:[n&&w.jsx("button",{type:"button",className:"wb-extend-close",title:o("extendView.back"),"aria-label":o("extendView.back"),onClick:i,children:w.jsx(lu,{size:14})}),w.jsx("span",{className:"wb-extend-title",children:f}),!n&&w.jsx("button",{type:"button",className:"wb-extend-close",title:o("extendView.close"),"aria-label":o("extendView.close"),onClick:i,children:w.jsx(bs,{size:14})})]}),w.jsx("div",{ref:a,className:"wb-extend-body"})]})}function io({children:e,present:t,owner:n,ownerKey:s=""}){const i=P.useMemo(Od,[s]),o=P.useMemo(()=>({generation:0}),[i]),a=P.useRef(null),r=P.useSyncExternalStore(i.subscribe,i.getSnapshot),c=P.useRef(null),[f,l]=P.useState(null),m=f?.element??null,g=f?r?.handle===f.entry.handle?r:f.entry:null;return P.useLayoutEffect(()=>{if(!r)return;const p=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null,d=t(r.options,i.dismiss,a.current??void 0);return c.current=d,l({element:d.element,entry:r,titled:!!d.titled,back:!!d.back,opener:p}),()=>{c.current=null;const S=!!i.getSnapshot();Promise.resolve(d.dispose(S)).then(()=>l(_=>_?.entry.handle===r.handle?null:_))}},[r?.handle,t,i]),P.useLayoutEffect(()=>{c.current?.activate?.()},[r?.revision]),P.useEffect(()=>{i.setVisible(n?.isVisible??!0);const p=n?.onDidVisibilityChange(()=>i.setVisible(n.isVisible));return()=>p?.dispose()},[i,n]),P.useEffect(()=>{const p=++o.generation;return()=>{queueMicrotask(()=>{o.generation===p&&i.dispose()})}},[i,o]),P.useEffect(()=>{const p=()=>!!a.current&&(a.current.contains(document.activeElement)||!!m?.contains(document.activeElement)||document.activeElement===document.body&&it===a.current),d=_=>{!i.getSnapshot()||!p()||_.defaultPrevented||(_.preventDefault(),!_.detail?.probe&&i.dismiss())},S=_=>{_.key==="Escape"&&d(_)};return window.addEventListener("keydown",S),window.addEventListener("forsion:mobile-back",d),()=>{window.removeEventListener("keydown",S),window.removeEventListener("forsion:mobile-back",d),it&&!it.isConnected&&(it=null)}},[i,m]),w.jsxs("div",{ref:a,className:"wb-extend-owner",onFocusCapture:()=>{it=a.current},onPointerDownCapture:()=>{it=a.current},children:[e(i.controller),g&&f&&jt.createPortal(w.jsx(jd,{entry:g,titled:f.titled,back:f.back,opener:f.opener,onDismiss:i.dismiss},g.handle.id),f.element)]})}function zr(e,t){return t==="left"||t==="right"?"list":/chat|session/i.test(e)?"chat":"document"}const Rd=[72,55,66,48,70,52,62,45],$d=[48,34,42,28,45,31,38,26];function oo({variant:e="document"}){return e==="list"?w.jsx("div",{className:"sk sk-list","aria-hidden":"true",children:Rd.map((t,n)=>w.jsxs("div",{className:"sk-row",children:[w.jsx("span",{className:"sk-b sk-dot"}),w.jsxs("span",{className:"sk-col",children:[w.jsx("span",{className:"sk-b sk-line",style:{width:`${t}%`}}),w.jsx("span",{className:"sk-b sk-line sk-thin",style:{width:`${$d[n]}%`}})]})]},n))}):e==="chat"?w.jsxs("div",{className:"sk sk-chat","aria-hidden":"true",children:[w.jsxs("div",{className:"sk-msg",children:[w.jsx("span",{className:"sk-b sk-ava"}),w.jsxs("span",{className:"sk-col",children:[w.jsx("span",{className:"sk-b sk-line",style:{width:"82%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"64%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"43%"}})]})]}),w.jsx("div",{className:"sk-msg sk-msg-user",children:w.jsx("span",{className:"sk-b sk-bubble",style:{width:"46%"}})}),w.jsxs("div",{className:"sk-msg",children:[w.jsx("span",{className:"sk-b sk-ava"}),w.jsxs("span",{className:"sk-col",children:[w.jsx("span",{className:"sk-b sk-line",style:{width:"71%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"86%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"32%"}})]})]}),w.jsx("div",{className:"sk-msg sk-msg-user",children:w.jsx("span",{className:"sk-b sk-bubble",style:{width:"33%"}})})]}):w.jsxs("div",{className:"sk sk-document","aria-hidden":"true",children:[w.jsx("span",{className:"sk-b sk-title",style:{width:"46%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"92%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"84%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"96%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"61%"}}),w.jsx("span",{className:"sk-gap"}),w.jsx("span",{className:"sk-b sk-line",style:{width:"89%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"94%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"73%"}}),w.jsx("span",{className:"sk-b sk-line",style:{width:"40%"}})]})}class ao extends P.Component{constructor(){super(...arguments),this.state={err:null,n:0}}static getDerivedStateFromError(t){return{err:t}}render(){const{err:t,n}=this.state;return t?w.jsxs("div",{className:"sk-error",role:"alert",children:[w.jsx("div",{className:"sk-error-title",children:Ze("lcl.view.loadFailed")}),w.jsx("div",{className:"sk-error-msg",children:String(t?.message||t)}),w.jsx("button",{className:"sk-error-btn",onClick:()=>this.setState(s=>({err:null,n:s.n+1})),children:Ze("lcl.view.retry")})]}):w.jsx(Rc.Fragment,{children:this.props.children},n)}}function zd({spaceId:e,view:t}){const[n,s]=P.useState(t.params??{}),i=W(t.type);if(!i)return null;const o=`peek:${e}:${t.type}`,a={id:o,type:t.type,loc:"left",params:n,setTitle:()=>{},setParams:r=>s(c=>({...c,...r})),close:()=>{}};return w.jsx(io,{present:$r,ownerKey:o,children:r=>w.jsx("div",{className:"wb-view wb-view--left",children:w.jsx(ao,{children:w.jsx(P.Suspense,{fallback:w.jsx(oo,{variant:zr(t.type,"left")}),children:i.factory({leaf:a,params:n,extendView:r})})})})})}function Vd({space:e,views:t,onBeforeClick:n,onEnter:s}){const{t:i}=Tt(),[o,a]=P.useState(0),r=Math.min(o,t.length-1),c=t[r],f=e.icon;return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"rb-peek-head",children:[s?w.jsxs("button",{type:"button",className:"rb-peek-enter",title:i("lcl.peek.enter",{name:B(e.name)}),onClick:s,children:[f&&w.jsx(f,{size:14}),w.jsx("span",{className:"rb-peek-name",children:B(e.name)}),w.jsx(wu,{className:"rb-peek-enter-go",size:12,"aria-hidden":!0})]}):w.jsxs(w.Fragment,{children:[f&&w.jsx(f,{size:14}),w.jsx("span",{className:"rb-peek-name",children:B(e.name)})]}),t.length>1&&t.map((l,m)=>{const g=W(l.type),p=g?.icon,d=g?B(g.displayName):l.type;return w.jsx("button",{type:"button",className:`rb-peek-tab${m===r?" is-on":""}`,"aria-label":d,title:d,"aria-pressed":m===r,onClick:()=>a(m),children:p?w.jsx(p,{size:14}):d.slice(0,1)},m)})]}),w.jsx("div",{className:"rb-peek-body",onClickCapture:n,children:w.jsx(zd,{spaceId:e.id,view:c},r)})]})}const Uh=P.forwardRef(function({space:t,views:n,style:s,onBeforeClick:i,onEnter:o,onContextMenuCapture:a},r){return w.jsx("div",{ref:r,className:"rb-peek",role:"region","aria-label":B(t.name),"data-space":t.id,style:s,onContextMenuCapture:a,children:w.jsx(Vd,{space:t,views:n,onBeforeClick:i,onEnter:o},t.id)})}),jn=e=>e.id==="rb-settings"||!!e.mobileFoot;function Vr(e,t){return t&&e.some(n=>n.id==="rb-account")?e.filter(n=>jn(n)&&!!n.onClick):[]}function ro(e,t){const n=new Set(t?Vr(e,!0):e.filter(jn)),s=e.filter(i=>i.side==="bottom"&&i.id!=="rb-account"&&!n.has(i));return t?[...s.filter(jn),...s.filter(i=>!jn(i))]:s}function Fr(e){const t=new Map;for(const n of e){const s=n.moreGroup;if(!s||typeof s.id!="string"||!s.id)continue;let i=t.get(s.id);i||(i={id:s.id,title:Kr(s.title,""),commands:[]},t.set(s.id,i)),i.commands.push(n)}return[...t.values()]}function Fd(e,t,n){const s=e.find(i=>i.id===n);return s&&t.find(i=>i.id===n)===s?s:null}function co(e){return e.replace(/\s*[((][^()()]*(?:[⌘⌃⌥⇧]|\b(?:Ctrl|Cmd|Alt|Shift)\b)[^()()]*[))]\s*$/,"")||e}function Dr(e){return Kr(e.title,e.id)}function Wr(e){if(!e.checked)return!1;try{return!!e.checked()}catch{return!1}}function Kr(e,t){try{return B(e)||t}catch{return t}}const Dd=32,Wd=8192,Br=16,Kd=300,Bd=new Set(["defs","clippath","mask","symbol","pattern","marker"]),Ft=(e,t=0)=>{const n=e==null?NaN:parseFloat(e);return Number.isFinite(n)?n:t},G=e=>String(Math.round(e*1e3)/1e3);function Hd(e,t,n,s,i,o){if(n<=0||s<=0)return"";let a=i>0?i:o>0?o:0,r=o>0?o:a;if(a=Math.min(a,n/2),r=Math.min(r,s/2),a<=0||r<=0)return`M${G(e)} ${G(t)}H${G(e+n)}V${G(t+s)}H${G(e)}Z`;const c=(f,l)=>`A${G(a)} ${G(r)} 0 0 1 ${G(f)} ${G(l)}`;return`M${G(e+a)} ${G(t)}H${G(e+n-a)}${c(e+n,t+r)}V${G(t+s-r)}${c(e+n-a,t+s)}H${G(e+a)}${c(e,t+s-r)}V${G(t+r)}${c(e+a,t)}Z`}function sa(e,t,n,s){if(n<=0||s<=0)return"";const i=`${G(n)} ${G(s)}`;return`M${G(e-n)} ${G(t)}A${i} 0 1 0 ${G(e+n)} ${G(t)}A${i} 0 1 0 ${G(e-n)} ${G(t)}Z`}function ia(e,t){const n=(e??"").trim().split(/[\s,]+/).map(Number).filter(Number.isFinite);if(n.length<4)return"";let s=`M${G(n[0])} ${G(n[1])}`;for(let i=2;i+1<n.length;i+=2)s+=`L${G(n[i])} ${G(n[i+1])}`;return t?s+"Z":s}function qd(e){const t=n=>Ft(e.getAttribute(n));switch(e.tagName.toLowerCase()){case"path":return(e.getAttribute("d")??"").trim();case"circle":return sa(t("cx"),t("cy"),t("r"),t("r"));case"ellipse":return sa(t("cx"),t("cy"),t("rx"),t("ry"));case"rect":return Hd(t("x"),t("y"),t("width"),t("height"),t("rx"),t("ry"));case"line":return`M${G(t("x1"))} ${G(t("y1"))}L${G(t("x2"))} ${G(t("y2"))}`;case"polyline":return ia(e.getAttribute("points"),!1);case"polygon":return ia(e.getAttribute("points"),!0);default:return""}}const oa=e=>!!e&&e!=="none"&&e!=="transparent";function Gd(e,t){const n=e.getAttribute("style");if(!n)return null;let s=null;for(const i of n.split(";")){const o=i.indexOf(":");o<0||i.slice(0,o).trim().toLowerCase()!==t||(s=i.slice(o+1).replace(/!important\s*$/i,"").trim())}return s||null}function En(e,t,n){for(let s=e;s;s=s.parentElement){const i=Gd(s,n)??s.getAttribute(n);if(i!=null&&i.trim().toLowerCase()!=="inherit")return i.trim();if(s===t)break}return n==="fill"?"black":null}function Ud(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number),n=t.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0?[t[0],t[1],t[2],t[3]]:[0,0,Ft(e.getAttribute("width"),24)||24,Ft(e.getAttribute("height"),24)||24],s=[];let i;for(const a of Array.from(e.querySelectorAll("path,circle,ellipse,rect,line,polyline,polygon"))){let r=!1;for(let g=a.parentElement;g&&g!==e;g=g.parentElement)if(Bd.has(g.tagName.toLowerCase())){r=!0;break}if(r)continue;const c=qd(a);if(!c||c.length>Wd)continue;const l=!(a.tagName.toLowerCase()==="line"||a.tagName.toLowerCase()==="polyline")&&oa(En(a,e,"fill")),m=oa(En(a,e,"stroke"));if(!(!l&&!m)&&(m&&i===void 0&&(i=Ft(En(a,e,"stroke-width"),1)),s.push({d:c,fill:l,stroke:m}),s.length>=Dd))break}if(!s.length)return;const o=i??Ft(En(e,e,"stroke-width"),1);return{kind:"vector",viewBox:n,strokeWidth:o>0&&o<=16?o:1,paths:s}}function Jd(e){const t=e.querySelector("svg");if(t)return Ud(t);const n=(e.textContent??"").trim();return n&&[...n].length<=Br?{kind:"text",text:n}:void 0}class Xd extends P.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){}render(){return this.state.failed?null:this.props.children}}function Yd({onCommit:e}){return P.useLayoutEffect(()=>{e()},[e]),null}const Hr=e=>typeof e=="function"||typeof e=="object"&&e!==null&&!P.isValidElement(e)&&"$$typeof"in e;function Zd(e){return Hr(e)?P.createElement(e,{size:24}):e}async function Qd(e){const t=e.map(c=>{if(typeof c=="string"||typeof c=="number"){const f=String(c).trim();return f&&[...f].length<=Br?{kind:"text",text:f}:void 0}}),n=e.map((c,f)=>({s:c,i:f})).filter(({s:c})=>c!=null&&typeof c!="boolean"&&typeof c!="string"&&typeof c!="number");if(!n.length||typeof document>"u")return t;const s=new Map,i=[],o=[];for(const c of n){const f=ef(c.s);if(f){const l=s.get(f[0])??new Map;s.set(f[0],l);const m=l.get(f[1]);if(m!==void 0){i.push({from:m,to:c.i});continue}l.set(f[1],c.i)}o.push(c)}const a=document.createElement("div");let r=null;try{r=Uc.createRoot(a);const c=r;await new Promise(f=>{const l=setTimeout(f,Kd),m=()=>{clearTimeout(l),f()};c.render(P.createElement("div",null,...o.map(({s:g,i:p})=>P.createElement("span",{key:p,"data-native-icon":p},P.createElement(Xd,null,Zd(g)))),P.createElement(Yd,{key:"commit",onCommit:m})))});for(const{i:f}of o){const l=a.querySelector(`[data-native-icon="${f}"]`);t[f]=l?Jd(l):void 0}}catch{}finally{try{r?.unmount()}catch{}}for(const{from:c,to:f}of i)t[f]=t[c];return t}function ef(e){if(Hr(e))return[e,""];if(!P.isValidElement(e)||typeof e.type=="string"||e.key!=null)return null;const t=e.props;for(const n of Object.values(t))if(n!=null&&typeof n=="object"||typeof n=="function"||typeof n=="symbol")return null;try{return[e.type,JSON.stringify(t)]}catch{return null}}let Ce;function Jh(e){return Ce=e,()=>{Ce===e&&(Ce=void 0)}}function aa(){return Ce}const vs=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ys=(e,t)=>Object.keys(e).every(n=>t.includes(n));function qr(e,t){for(const n of e)for(const s of n.items){if(s.id===t)return s;const i=s.children?qr(s.children,t):void 0;if(i)return i}}function tf(e,t){if(!vs(t)||!ys(t,["id","trailing"]))return null;const{id:n,trailing:s}=t;if(typeof n!="string"||s!==void 0&&typeof s!="boolean")return null;const i=qr(e.sections,n);return!i||i.disabled?null:s?i.trailing?{id:n,trailing:!0}:null:i.children?.length?null:{id:n}}function nf(e,t){if(!vs(t)||!ys(t,["checked"])||!Array.isArray(t.checked))return null;const n=t.checked;if(!n.every(i=>typeof i=="string")||new Set(n).size!==n.length||n.length>e.max||n.length<Math.min(e.min??0,e.checked.length))return null;const s=i=>e.checked.includes(i)||e.items.some(o=>o.id===i&&!o.disabled);return n.every(s)?{checked:[...n]}:null}function sf(e){return!vs(e)||!ys(e,["text"])||typeof e.text!="string"||e.text.length>1e5?null:{text:e.text}}function of(e){return vs(e)&&ys(e,["ok"])&&e.ok===!0?{ok:!0}:null}function Gr(e,t=new Set){for(const n of e)for(const s of n.items)if(!s.id||s.id.length>Jr||t.has(s.id)||(t.add(s.id),s.children&&!Gr(s.children,t)))return!1;return!0}function Ur(e){let t=0;for(const n of e)for(const s of n.items)t+=1+(s.children?Ur(s.children):0);return t}const Jr=160,Ke=256,Ei=1024,Xr=64,Yr=600;function ce(e,t){if(e.length<=t)return e;let n=t-1;const s=e.charCodeAt(n-1);return s>=55296&&s<=56319&&(n-=1),e.slice(0,n)+"…"}const ra=e=>({placeholder:ce(e.placeholder,Ke),empty:ce(e.empty,Ke)}),af={background:[248,247,246,1],surface:[255,255,255,1],text:[32,33,36,1],muted:[110,112,118,1],border:[0,0,0,.1],accent:[77,135,148,1],onAccent:[255,255,255,1],danger:[208,64,64,1],warning:[128,96,0,1]},rf={background:[32,34,36,1],surface:[40,42,44,1],text:[236,238,240,1],muted:[160,164,170,1],border:[255,255,255,.12],accent:[95,163,178,1],onAccent:[255,255,255,1],danger:[232,96,96,1],warning:[224,184,91,1]},Xs={background:"--bg",surface:"--bg-card",text:"--text",muted:"--text-muted",border:"--border",accent:"--accent",onAccent:"--on-accent",danger:"--danger",warning:"--warning"};let Ys;function cf(e){try{if(Ys===void 0){const i=document.createElement("canvas");i.width=i.height=1,Ys=i.getContext("2d",{willReadFrequently:!0})}const t=Ys;if(!t||typeof t.getImageData!="function")return null;t.fillStyle="#000000",t.fillStyle=e;const n=String(t.fillStyle);if(t.fillStyle="#ffffff",t.fillStyle=e,String(t.fillStyle)!==n)return null;t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const s=t.getImageData(0,0,1,1).data;return[s[0],s[1],s[2],s[3]/255]}catch{return null}}function lf(e){const t=e.trim(),n=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)$/i);if(n){const i=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return[Math.round(+n[1]),Math.round(+n[2]),Math.round(+n[3]),Math.max(0,Math.min(1,i))]}const s=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(s&&[3,4,6,8].includes(s.length)){const i=s.length<=4?[...s].map(a=>a+a).join(""):s,o=a=>parseInt(i.slice(a,a+2),16);return[o(0),o(2),o(4),i.length===8?o(6)/255:1]}return typeof document>"u"?null:cf(t)}const _n=(e,t)=>{const n=e[3];return[0,1,2].map(s=>Math.round(e[s]*n+t[s]*(1-n))).concat(1)},Se=([e,t,n,s])=>"#"+[Math.round(s*255),e,t,n].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("").toUpperCase();function ws(){let e=!1;try{e=document.documentElement.dataset.mode==="dark"}catch{}const t=e?rf:af,n={};if(typeof document<"u"&&document.body){const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none",document.documentElement.appendChild(r);try{const c=getComputedStyle(document.documentElement);for(const f of Object.keys(Xs)){if(!c.getPropertyValue(Xs[f]).trim())continue;r.style.color="",r.style.color=`var(${Xs[f]})`;const l=getComputedStyle(r).color,m=l?lf(l):null;m&&(n[f]=m)}}finally{r.remove()}}const s=r=>n[r]??t[r],i=e?[0,0,0,1]:[255,255,255,1],o=_n(s("background"),i),a=_n(s("surface"),o);return{dark:e,background:Se(o),surface:Se(a),text:Se(s("text")),muted:Se(s("muted")),border:Se(s("border")),accent:Se(_n(s("accent"),a)),onAccent:Se(s("onAccent")),danger:Se(s("danger")),warning:Se(_n(s("warning"),o))}}async function Zr(e){const t=[],n=a=>{for(const r of a)for(const c of r.items)t.push(c.icon,c.trailing?.icon),c.children&&n(c.children)};n(e.sections);const s=await Qd(t);let i=0;const o=a=>a.map(r=>({...r.title?{title:ce(r.title,Ke)}:{},...r.footer?{footer:ce(r.footer,Ei)}:{},...r.grid?{grid:!0}:{},items:r.items.map(c=>{const f=s[i++],l=s[i++],m={id:c.id,label:ce(c.label,Ke)};return c.detail&&(m.detail=ce(c.detail,Ei)),f&&(m.icon=f),c.checked&&(m.checked=!0),c.danger&&(m.danger=!0),c.disabled&&(m.disabled=!0),c.children?.length&&(m.children=o(c.children),c.search&&(m.search=ra(c.search))),c.trailing&&(m.trailing={id:c.trailing.id,label:ce(c.trailing.label,Ke),...l?{icon:l}:{}}),m})}));return{kind:"menu",...e.title?{title:ce(e.title,Ke)}:{},sections:o(e.sections),...e.search?{search:ra(e.search)}:{},...e.back?{back:ce(e.back,Xr)}:{}}}async function Ss(e,t,n){const s=Ce;if(!s)return{handled:!1};if(n?.aborted)return{handled:!0,value:null};const i=new AbortController,o=()=>i.abort();n?.addEventListener("abort",o,{once:!0});try{const a=await e();if(i.signal.aborted)return{handled:!0,value:null};const r=await s(a,i.signal);return i.signal.aborted?{handled:!0,value:null}:{handled:!0,value:r==null?null:t(r)}}catch{return i.signal.aborted?{handled:!0,value:null}:{handled:!1}}finally{n?.removeEventListener("abort",o)}}function ks(e,t){const n={...e,kind:"menu"};return Ce?!Gr(n.sections)||!n.sections.some(s=>s.items.length)||Ur(n.sections)>Yr?Promise.resolve({handled:!1}):Ss(async()=>({...await Zr(n),theme:ws()}),s=>tf(n,s),t):Promise.resolve({handled:!1})}function uf(e,t){if(!Ce)return Promise.resolve({handled:!1});const n=new Set(e.items.map(o=>o.id)),s=Math.min(e.max,e.items.length);if(!e.items.length||n.size!==e.items.length||e.items.some(o=>!o.id||o.id.length>Jr||o.children?.length||o.trailing)||e.items.length>Yr||s<1||new Set(e.checked).size!==e.checked.length||e.checked.length>s||!e.checked.every(o=>n.has(o)))return Promise.resolve({handled:!1});const i={...e,max:s};return Ss(async()=>{const o=await Zr({kind:"menu",sections:[{items:i.items}]});return{kind:"checklist",...i.title?{title:ce(i.title,Ke)}:{},items:o.sections[0].items,checked:[...i.checked],...i.footer?{footer:ce(i.footer,Ei)}:{},done:ce(i.done,Xr),...i.min?{min:Math.max(0,Math.min(i.min,s))}:{},max:s,theme:ws()}},o=>nf(i,o),t)}function Xh(e,t){return Ss(()=>({...e,kind:"prompt",theme:ws()}),sf,t)}function Yh(e,t){return Ss(()=>({...e,kind:"confirm",theme:ws()}),of,t)}async function df(e,t={}){if(!Ce||!e.length)return{handled:!1};const n=[...e],s=[];n.forEach((o,a)=>{(!s.length||o.separatorBefore&&s[s.length-1].items.length)&&s.push({items:[]}),s[s.length-1].items.push({id:String(a),label:o.label,icon:o.icon,...o.danger?{danger:!0}:{},...o.disabled?{disabled:!0}:{}})});const i=await ks({...t.title?{title:t.title}:{},sections:s},t.signal);return i.handled?{handled:!0,value:i.value?n[Number(i.value.id)]??null:null}:i}async function Zh(e,t={}){const n=await df(e,t);return n.handled?(n.value?.run(),!0):!1}function Qh(e,t){if(e.length<=t)return{cells:[...e],more:[]};if(t<=1)return{cells:[],more:[...e]};const n=new Set([...e.filter(s=>s.pinned),...e.filter(s=>!s.pinned)].slice(0,t-1).map(s=>s.id));return{cells:e.filter(s=>n.has(s.id)),more:e.filter(s=>!n.has(s.id))}}const _i={mode:"hidden"};let me,Ue=null;const Ae=[];let Qn="";const Lt=new Set;function ff(){const e=Ae[Ae.length-1]?.claim;return e?e.mode==="page"?{mode:"page",title:e.title,back:e.back,...e.close&&e.onClose?{close:e.close}:{}}:_i:Ue?.state??_i}function Bt(){if(!me)return;const e=ff(),t=JSON.stringify(e);if(t!==Qn){Qn=t;try{me.render(e)}catch{}}}function ep(e){return me=e,Qn="",Lt.forEach(t=>t()),Bt(),()=>{me===e&&(me=void 0,Qn="",Lt.forEach(t=>t()))}}function mf(){return!!me}function tp(){return typeof me?.haptic=="function"}function np(e){try{me?.haptic?.(e)}catch{}}function dn(){return!!me?.spaces}function lo(){return P.useSyncExternalStore(e=>(Lt.add(e),()=>{Lt.delete(e)}),()=>!!me?.spaces,()=>!1)}function Qr(){return P.useSyncExternalStore(e=>(Lt.add(e),()=>{Lt.delete(e)}),()=>!!me,()=>!1)}function ca(e,t={}){Ue=e?{state:{mode:"shell",...e},handlers:t}:null,Bt()}function hf(e){const t={claim:e};return Ae.push(t),Bt(),{update(n){t.claim=n,Bt()},release(){const n=Ae.indexOf(t);n>=0&&(Ae.splice(n,1),Bt())}}}function sp(e){const t=P.useRef(void 0),n=P.useRef(void 0);t.current=e&&e.mode==="page"?e.onBack:void 0,n.current=e&&e.mode==="page"?e.onClose:void 0;const s=e?JSON.stringify(e.mode==="page"?{m:"page",t:e.title,b:e.back,c:e.close&&e.onClose?e.close:""}:{m:"hidden"}):"",i=P.useRef(null);P.useEffect(()=>{if(!s)return;const o=JSON.parse(s),a=o.m==="page"?{mode:"page",title:o.t??"",back:o.b??"",onBack:()=>t.current?.(),...o.c?{close:o.c,onClose:()=>n.current?.()}:{}}:_i;i.current?i.current.update(a):i.current=hf(a)},[s]),P.useEffect(()=>()=>{i.current?.release(),i.current=null},[]),P.useEffect(()=>{!s&&i.current&&(i.current.release(),i.current=null)},[s])}function ip(e){const t=Ae[Ae.length-1]?.claim;if(t)return e==="back"&&t.mode==="page"?(t.onBack(),!0):e==="close"&&t.mode==="page"&&t.close&&t.onClose?(t.onClose(),!0):!1;if(e==="back"||e==="close"||!Ue)return!1;const n=Ue.handlers[e];return n?(n(),!0):!1}function op(e,t=!1){if(Ae.length||!Ue)return!1;const n=t?Ue.handlers.spaceLong:Ue.handlers.space;return n?(n(e),!0):!1}const _t=[],es=new Set;function pf(e){for(let t=_t.length-1;t>=0;t--)if(_t[t].value.where===e)return _t[t].value}function gf(e){return es.add(e),()=>{es.delete(e)}}function ap(e){const t=P.useRef(e);t.current=e;const n=e?JSON.stringify({w:e.where,s:e.search?.label??null,t:e.title?.sub??null,r:!!e.title?.run,c:e.capLeftMax??0}):"";P.useEffect(()=>{if(!n)return;const s=JSON.parse(n),i={value:{where:s.w,...s.s!==null?{search:{label:s.s,run:()=>t.current?.search?.run()}}:{},...s.t!==null?{title:{sub:s.t,...s.r?{run:()=>t.current?.title?.run?.()}:{}}}:{},...s.c>0?{capLeftMax:s.c}:{}}};return _t.push(i),es.forEach(o=>o()),()=>{const o=_t.indexOf(i);o>=0&&_t.splice(o,1),es.forEach(a=>a())}},[n])}const ec=5,ts=ec-2,tc="lcl_dock_pins_v1",Mi=new Set;function bf(){try{const e=JSON.parse(localStorage.getItem(tc)??"null");return Array.isArray(e)?e.filter(t=>typeof t=="string"):null}catch{return null}}function xs(e,t=bf()){if(e.length<=ec)return new Set(e);const n=e.slice(1),s=t?n.filter(i=>t.includes(i)):n;return new Set([e[0],...s.slice(0,ts)])}function vf(e,t){const n=xs(e),s=e.slice(1).filter(i=>t.includes(i)).slice(0,ts);if(!(s.length===n.size-1&&s.every(i=>n.has(i)))){try{localStorage.setItem(tc,JSON.stringify(s))}catch{return}Mi.forEach(i=>i())}}function yf(e){return Mi.add(e),()=>{Mi.delete(e)}}function tt(){if(!dn())return!1;const e=R.getState();return e.wideMode||!(e.leftLeaves.length?e.leftLeaves:e.leftVisible?[]:e.sidebarDefaults.left).some(n=>n.type==="__extend"||!!W(n.type))?!1:et()?.listFirst!==!1}function rp(){const e=lo(),t=R(n=>n.wideMode);return e&&!t&&tt()}let ns=!1;const nc=()=>R.getState().leftVisible&&tt();function la(){if(nc()&&(ns=!0),!ns)return;const{stacks:e}=fe.getState();let t=null;for(const n in e){const s=e[n];s.entries.length>1&&((t??={...e})[n]={entries:[s.entries[s.idx]],idx:0})}t&&fe.setState({stacks:t})}function ua(){nc()||(ns=!1)}function wf(){const e=[R.subscribe(la),fe.subscribe(la)];if(typeof window<"u")for(const t of["pointerdown","keydown"])window.addEventListener(t,ua,!0),e.push(()=>window.removeEventListener(t,ua,!0));return()=>{e.forEach(t=>t()),ns=!1}}function Es(){return ee?!1:Fa==="mobile"||"activeMainId"in je.getState()}const Je=new Map,Ii=new Set,da=()=>{for(const e of Ii)e()},sc=e=>(Ii.add(e),()=>{Ii.delete(e)}),ic=e=>`${e.value}${e.ariaLabel??""}${e.modes.map(t=>`${t.value}${t.label}`).join("")}`;function cp(e,t){const n=P.useRef(t);n.current=t;const s=t?ic(t):"";P.useLayoutEffect(()=>{const i=n.current;if(!e||!i)return;const o={modes:i.modes,value:i.value,ariaLabel:i.ariaLabel,onChange:a=>n.current?.onChange(a)};return Je.set(e,o),da(),()=>{Je.get(e)===o&&(Je.delete(e),da())}},[e,s])}function oc(e){return P.useSyncExternalStore(sc,()=>e?Je.get(e)??null:null)}function Rn(e){return e?Je.get(e)??null:null}function $n(){const e=je.getState(),t=e.getActiveLeaf()?.id;if(t&&Je.has(t))return t;const n=e.api,s=n?tn(n)?.id:void 0;return s&&Je.has(s)?s:null}function Sf(e){const t=e.modes.length;if(t<2)return null;const n=e.modes.findIndex(s=>s.value===e.value);return e.modes[(n+1)%t].value}const Pi="view-mode-next",fa="view-mode:";let ma=[],ha="";function Zs(){const e=$n(),t=Rn(e),n=t&&t.modes.length>1?t.modes:[],s=Es()&&mf(),i=`${e}${s}${t?ic(t):""}`;if(i!==ha){ha=i;for(const o of ma)Or(o);ma=n.map(o=>fa+o.value);for(const o of n)Tr({id:fa+o.value,title:Ze("lcl.viewMode.pick",{label:o.label}),keywords:`view mode switch ${o.value} 看法 视图 切换`,...s?{moreGroup:{id:"lcl-view-mode",title:()=>Ze("lcl.viewMode.aria")},checked:()=>Rn($n())?.value===o.value}:{},run:()=>{const a=Rn($n());a&&a.value!==o.value&&a.modes.some(r=>r.value===o.value)&&a.onChange(o.value)}})}}function lp(){Tr({id:Pi,title:()=>Ze("lcl.viewMode.next"),keywords:"view mode next switch canvas 看法 视图 切换 画布",hotkey:"mod+alt+v",run:()=>{const t=Rn($n()),n=t&&Sf(t);t&&n&&t.onChange(n)}});const e=[he.subscribe((t,n)=>{t.paletteOpen&&!n.paletteOpen&&Zs()})];return Es()&&e.push(sc(Zs),je.subscribe(Zs)),()=>{for(const t of e)t();Or(Pi)}}function ac(e){const t=oc(e.leafId),n=e.spec??t,{t:s}=Tt(),[i,o]=P.useState(null),a=P.useRef(null),r=P.useRef(null);if(P.useEffect(()=>{if(!i)return;const v=C=>{!r.current?.contains(C.target)&&!a.current?.contains(C.target)&&o(null)},I=C=>{C.key==="Escape"&&(o(null),a.current?.focus())};return r.current?.querySelector('[aria-checked="true"]')?.focus(),window.addEventListener("pointerdown",v,!0),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",v,!0),window.removeEventListener("keydown",I)}},[i]),!n||n.modes.length<2||e.leafId!==void 0&&!e.inTopbar&&Es())return null;const c=n.modes.length,f=Math.max(0,n.modes.findIndex(v=>v.value===n.value)),l=n.modes[f],m=(f+1)%c,g=e.leafId!==void 0?kd(Pi):"",p=v=>{const I=n.modes[v],C=I.hotkey||(v===m?g:"");return C?s("lcl.withHotkey",{label:I.label,key:C}):I.label},d=v=>{v!==n.value&&(e.leafId&&je.getState().getActiveLeaf()?.id!==e.leafId&&je.getState().activateLeaf(e.leafId),n.onChange(v))},S=v=>{const I=[...v.currentTarget.querySelectorAll('[role="menuitemradio"]')],C=I.indexOf(document.activeElement),A=M=>{v.preventDefault(),I[(M+I.length)%I.length]?.focus()};v.key==="ArrowDown"?A(C+1):v.key==="ArrowUp"?A(C-1):v.key==="Home"?A(0):v.key==="End"?A(I.length-1):v.key==="Tab"&&(v.preventDefault(),o(null),a.current?.focus())},_=n.ariaLabel||s("lcl.viewMode.aria");return w.jsxs("div",{className:`lcl-vmode${e.className?` ${e.className}`:""}`,"data-n":c,"data-icons":n.modes.every(v=>v.icon)?"":void 0,"data-compact":e.compact?"":void 0,"data-testid":e.testId,style:{"--seg-n":c,"--seg-i":f},children:[w.jsxs("div",{className:"lcl-vmode-pill",role:"tablist","aria-label":_,children:[w.jsx("div",{className:"lcl-vmode-thumb","data-value":l.value}),n.modes.map((v,I)=>{const C=v.icon;return w.jsxs("button",{type:"button",role:"tab","aria-selected":I===f,"aria-label":v.label,title:p(I),className:I===f?"on":"","data-guide-anchor":v.guideAnchor,onMouseDown:A=>A.preventDefault(),onClick:()=>d(v.value),children:[C?w.jsx(C,{size:14,className:"lcl-vmode-ic"}):null,w.jsx("span",{className:"lcl-vmode-tx",children:v.label})]},v.value)})]}),w.jsxs("button",{ref:a,type:"button",className:"lcl-vmode-drop","aria-haspopup":"menu","aria-expanded":!!i,"aria-label":_,onMouseDown:v=>v.preventDefault(),onClick:()=>{const v=a.current?.getBoundingClientRect();o(i||!v?null:{x:v.left,y:v.bottom+4})},children:[w.jsx("span",{className:"lcl-vmode-tx",children:l.label}),w.jsx(vu,{size:12})]}),i&&jt.createPortal(w.jsx(Td,{className:"ctx-menu lcl-vmode-menu",x:i.x,y:i.y,innerRef:v=>{r.current=v},role:"menu",onKeyDown:S,children:n.modes.map((v,I)=>{const C=v.icon;return w.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":I===f,onClick:()=>{o(null),a.current?.focus(),d(v.value)},children:[C?w.jsx(C,{size:13}):null,w.jsx("span",{children:v.label}),I===f?w.jsx(gu,{size:13,className:"lcl-vmode-check"}):null]},v.value)})}),document.body)]})}function up({leafId:e,children:t,className:n,testId:s}){const i=oc(e),o=!!i&&i.modes.length>1&&!Es();return!o&&!t?null:w.jsxs("div",{className:`lcl-viewhead${n?` ${n}`:""}`,children:[o?w.jsx(ac,{leafId:e,testId:s}):null,w.jsx("div",{className:"lcl-viewhead-actions",children:t})]})}function kf(e,t){const[n,s]=P.useState(!1),i=R(a=>a.activeMainId),o=R(a=>a.leftVisible||a.rightVisible);return P.useEffect(()=>{s(!1)},[i,o,t]),P.useEffect(()=>{const a=e.current;if(!a||!t)return;let r=null,c=0,f=0;const l=g=>{const p=g.target;if(!p||!(p instanceof HTMLElement))return;if(p!==r){r=p,c=p.scrollTop,f=0;return}const d=p.scrollTop,S=d-c;if(c=d,!(Math.abs(S)<2)){if(d<56){f=0,s(!1);return}if(f=S>0==f>0?f+S:S,f>44){const _=document.activeElement;if(_&&(_.isContentEditable||/^(input|textarea)$/i.test(_.tagName)))return;s(!0)}else f<-28&&s(!1)}},m=g=>{const p=g.target;p&&(p.isContentEditable||/^(input|textarea)$/i.test(p.tagName))&&(f=0,s(!1))};return a.addEventListener("scroll",l,!0),a.addEventListener("focusin",m),()=>{a.removeEventListener("scroll",l,!0),a.removeEventListener("focusin",m)}},[e,t]),n}function xf({children:e}){const[t,n]=P.useState(()=>!(R.getState().leftVisible&&tt()));return P.useEffect(()=>{t||P.startTransition(()=>n(!0))},[]),t?e():null}function Ef({extendable:e=!0}={}){const t=R(a=>a.activeMainId),n=R(a=>a.mainLeaves.find(r=>r.id===a.activeMainId)?.type),s=R(a=>a.mainLeaves.find(r=>r.id===a.activeMainId)?.params);if(!t||!n)return null;const i=R.getState().getActiveLeaf(),o=i?W(i.type):null;return!i||!o?null:w.jsx("div",{className:"mb-view","data-view":i.type,children:w.jsx(ao,{children:w.jsx(P.Suspense,{fallback:w.jsx(oo,{variant:zr(i.type)}),children:w.jsx(xf,{children:()=>e?w.jsx(io,{present:Xl,ownerKey:hs(s??i.params),children:a=>o.factory({leaf:i,params:s??i.params,extendView:a})}):o.factory({leaf:i,params:s??i.params})})})})},`${i.id}:${i.type}`)}const rc=(e,t)=>e>1||t.some(n=>n.id==="rb-account"||n.id==="rb-settings"||n.mobileFoot);function uo(){return rc(Y(e=>e.spaces.length),ae(e=>e.items))}const cc=()=>rc(Y.getState().spaces.length,ae.getState().items),_f=450,Mf=()=>document.documentElement.hasAttribute("data-reader");let ss=0;const Li=new Set,pa=e=>{e!==ss&&(ss=e,Li.forEach(t=>t()))},If=e=>(Li.add(e),()=>{Li.delete(e)}),Pf=e=>{const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-reader"]}),()=>t.disconnect()};function ga({side:e,docked:t,showFoot:n,page:s}){const i=R(M=>e==="left"?M.leftVisible:M.rightVisible),o=uo(),a=lo(),r=e==="left"&&!!n&&o&&!a;R(M=>(e==="left"?M.leftLeaves:M.rightLeaves).map(O=>O.id).join(",")),R(M=>e==="left"?M.leftActiveId:M.rightActiveId);const[c,f]=P.useState(i);i&&!c&&f(!0);const l=P.useRef(null),m=!!s&&!i;P.useEffect(()=>{const M=l.current;if(!m||!M)return;const O=()=>{const u=document.activeElement;u instanceof HTMLElement&&M.contains(u)&&u.blur()},$=()=>{O(),M.inert=!0};return O(),M.addEventListener("focusin",$),()=>{M.removeEventListener("focusin",$),M.inert=!1}},[m]);const g=P.useSyncExternalStore(Pf,Mf);P.useEffect(()=>{const M=l.current;if(!M)return;if(!s||!g){M.removeAttribute("aria-hidden");return}const O=window.setTimeout(()=>{m?M.setAttribute("aria-hidden","true"):M.removeAttribute("aria-hidden")},_f);return()=>window.clearTimeout(O)},[m,s,g]);const p=e==="left"?R.getState().leftLeaves:R.getState().rightLeaves,d=R.getState().getActiveSideLeaf(e),S=d?W(d.type):null,_=()=>R.getState().toggleSidebar(e),v=p.length>0||r,I=P.useRef(null),C=!!t&&i&&v;P.useEffect(()=>{const M=I.current;if(!C||!M)return;const O=new ResizeObserver(()=>pa(Math.round(M.getBoundingClientRect().right-(M.closest(".mb-shell")?.getBoundingClientRect().left??0))));return O.observe(M),()=>{O.disconnect(),pa(0)}},[C]);const A=v?w.jsxs(w.Fragment,{children:[!(s&&p.length<=1)&&w.jsxs("div",{className:"mb-drawer-bar",children:[p.length>1?w.jsx("select",{className:"mb-drawer-select",value:d?.id??"",onChange:M=>R.getState().activateLeaf(M.target.value),children:p.map(M=>{const O=W(M.type);return w.jsx("option",{value:M.id,children:M.type==="__extend"?M.title:O?B(O.displayName):M.type},M.id)})}):w.jsx("div",{className:"mb-drawer-title",children:d?.type==="__extend"?p.find(M=>M.id===d.id)?.title:S?B(S.displayName):""}),!s&&w.jsx("button",{className:"mb-icon-btn",onClick:_,"aria-label":"close",children:w.jsx(bs,{size:20})})]}),w.jsx("div",{className:"mb-drawer-body",children:d?.type==="__extend"?w.jsx(Zc,{id:d.id,side:e}):S&&d?w.jsx("div",{className:"mb-view",children:w.jsx(ao,{children:w.jsx(P.Suspense,{fallback:w.jsx(oo,{variant:"list"}),children:w.jsx(io,{present:$r,ownerKey:hs(d.params),children:M=>S.factory({leaf:d,params:d.params,extendView:M})})})})},`${d.id}:${d.type}`):null}),r&&w.jsx(jf,{})]}):null;return t?!i||!v?null:w.jsx("aside",{className:"mb-sidecol",ref:I,children:A}):w.jsx("div",{ref:l,className:`mb-drawer mb-drawer--${e}${i&&v?" open":""}`,children:c?A:null})}function Lf(e,t,n,s){const i=P.useRef({wide:t,hasLeft:n,hasRight:s});i.current={wide:t,hasLeft:n,hasRight:s},P.useEffect(()=>{const o=e.current;if(!o)return;const a=10,r=.5;let c=null;const f=u=>u<0?0:u>1?1:u;let l=[],m=0;const g=()=>{m&&(cancelAnimationFrame(m),m=0),o.removeAttribute("data-drag");for(const u of l)u.style.transform="",u.style.opacity="";l=[]};let p=[],d=0;const S=()=>{d&&(clearTimeout(d),d=0);for(const u of p)u.style.transition="";p=[]},_=(u,b)=>{S();const h=R.getState(),k=((u.side==="left"?h.leftVisible:h.rightVisible)?1:0)-u.p;if(Math.abs(k)<.002)return;const x=Id(b*1e3/k,Ed,{clamp:!0}),E=x?.ms??Math.round(340*Math.max(.35,Math.abs(k))),L=x?.easing??"var(--mb-ease)";for(const T of l){const N=T===u.dim?`opacity ${E}ms ${L}`:`transform ${E}ms ${L}`;T.style.transition=T===u.panel?`${N}, visibility 0s linear ${E}ms`:N}p=[...l],d=window.setTimeout(S,E+80)},v=()=>{m&&cancelAnimationFrame(m),m=requestAnimationFrame(()=>{m=0,g()})},I=u=>{const b=u.side==="left",h=y=>`${(y*100).toFixed(2)}%`;u.panel&&(u.panel.style.transform=`translateX(${h(b?u.p-1:1-u.p)})`),u.main&&(u.main.style.transform=u.nav&&b?`translateX(${h(u.p)})`:`translateX(calc(${(b?u.p:-u.p).toFixed(4)} * var(--mb-panelw)))`),u.dim&&(u.dim.style.opacity=u.nav&&b?"0":u.p.toFixed(4))},C=u=>{const b=o.querySelector(`.mb-drawer--${u.side}`);return u.w=b?.getBoundingClientRect().width??0,u.w?(g(),S(),u.panel=b,u.main=i.current.wide?null:o.querySelector(":scope > .mb-main"),u.dim=o.querySelector(":scope > .mb-push-dim"),u.nav=!!o.closest(".mb-shell")?.hasAttribute("data-list-first"),l=[u.panel,u.main,u.dim].filter(h=>!!h),o.dataset.drag=u.side,!0):!1},A=u=>{c=null;const b=u.touches[0];if(!b||u.touches.length>1)return;const h=u.target;let y=!!h?.closest?.(".amx-draw, .pdfa-container, .amx-stage:not(.amx-stage-off), .pl-swipe");if(!y)for(let E=h;E&&E!==o;E=E.parentElement){const L=getComputedStyle(E);if((L.overflowX==="auto"||L.overflowX==="scroll")&&E.scrollWidth>E.clientWidth+1){y=!0;break}}const k=24,x=b.clientX<k||b.clientX>window.innerWidth-k;c={x0:b.clientX,y0:b.clientY,ok:!y||x,side:null,opening:!1,w:0,p:0,panel:null,main:null,dim:null,nav:!1,lastX:b.clientX,lastT:u.timeStamp,vx:0,vp:0,trail:[[u.timeStamp,b.clientX]]}},M=u=>{if(!c||$)return;const b=u.touches[0];if(!b)return;const h=b.clientX-c.x0,y=b.clientY-c.y0;if(!c.side){if(Math.abs(h)<a)return;if(Math.abs(h)<Math.abs(y)||!c.ok){c=null;return}const T=R.getState(),N=i.current;if(T.rightVisible&&h>0)c.side="right",c.opening=!1;else if(T.leftVisible&&!N.wide&&h<0&&!tt())c.side="left",c.opening=!1;else if(T.leftVisible||T.rightVisible){c=null;return}else if(h>0&&N.hasLeft&&!N.wide)c.side="left",c.opening=!0;else if(h<0&&N.hasRight)c.side="right",c.opening=!0;else{c=null;return}if(!C(c)){c=null;return}}const k=u.timeStamp;for(c.trail.push([k,b.clientX]);c.trail.length>2&&k-c.trail[0][0]>80;)c.trail.shift();const[x,E]=c.trail[0];k>x&&(c.vx=(b.clientX-E)/(k-x)),c.lastX=b.clientX,c.lastT=k;const L=c.side==="left"?1:-1;c.p=f((c.opening?0:1)+L*h/c.w),I(c),u.preventDefault()},O=u=>{const b=c;if(c=null,!b||!b.side)return;const h=b.side==="left"?1:-1,y=b.p,k=u.timeStamp-b.lastT>100?0:h*b.vx,x=k>r?!0:k<-r?!1:y>.5,E=R.getState(),L=b.side==="left"?E.leftVisible:E.rightVisible;x!==L&&jt.flushSync(()=>E.toggleSidebar(b.side)),_(b,k/b.w),v()};let $=null;return o.addEventListener("touchstart",A,{passive:!0}),o.addEventListener("touchmove",M,{passive:!1}),o.addEventListener("touchend",O),o.addEventListener("touchcancel",O),()=>{o.removeEventListener("touchstart",A),o.removeEventListener("touchmove",M),o.removeEventListener("touchend",O),o.removeEventListener("touchcancel",O),g(),S()}},[])}function Cf(e){if(e===Y.getState().activeSpaceId){xi(e,fo);return}xi(e,()=>{vr(e);const t=R.getState();t.leftVisible||t.leftLeaves.length===0&&t.sidebarDefaults.left.length===0&&!cc()||t.toggleSidebar("left")},{axis:"x"})}function Af(){const{spaces:e,activeSpaceId:t}=Y.getState(),n=e.some(i=>i.id===t),s=xs(e.map(i=>i.id));return e.map((i,o)=>({id:i.id,label:B(i.name),active:n?i.id===t:o===0,iconRev:Tf(i.icon),...s.has(i.id)?{pinned:!0}:{}}))}const ba=new WeakMap;let Nf=0;function Tf(e){if(!e)return 0;let t=ba.get(e);return t||(t=++Nf,ba.set(e,t)),t}function Of(){tt()&&!R.getState().leftVisible&&R.getState().toggleSidebar("left")}function fo(){const e=et();if(!e?.onePage)return;R.getState().ensurePinned();const t=R.getState(),{activate:n,close:s}=gl(e,t.mainLeaves,t.activeMainId,[...t.leftLeaves,...t.rightLeaves]);n&&t.activateLeaf(n);for(const i of s)t.closeLeaf(i,!0);for(const i of["left","right"]){const o=R.getState();o[i==="left"?"leftVisible":"rightVisible"]&&!o[i==="left"?"leftLeaves":"rightLeaves"].length&&o.toggleSidebar(i)}}function lc(){fo(),Xi(),Of()}function uc(e){xi(e,e===Y.getState().activeSpaceId?()=>{fo(),Xi()}:void 0,{axis:"x"})}Hl(tu);const _s=()=>!et()?.onePage;Bl(lc);wf();function jf(){const e=uo(),t=Y(f=>f.spaces),n=Y(f=>f.activeSpaceId),s=ae(f=>f.items.find(l=>l.id==="rb-account")),i=ae(f=>f.items.find(l=>l.id==="rb-settings")),o=ae(f=>f.items).filter(f=>f.mobileFoot),a=s?.component,r=i?.icon,c=P.useRef(null);return P.useEffect(()=>{c.current?.querySelector(".mb-tab.on")?.scrollIntoView({block:"nearest",inline:"center"})},[n]),e?w.jsxs("div",{className:"mb-drawer-foot",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[t.length>1&&w.jsx("nav",{className:"mb-spacebar",ref:c,children:t.map(f=>{const l=f.icon,m=f.id===n||!t.some(g=>g.id===n)&&f===t[0];return w.jsxs("button",{className:`mb-tab${m?" on":""}`,"data-space":f.id,onClick:()=>Cf(f.id),onContextMenu:g=>{br(f.id,B(f.name))&&g.preventDefault()},children:[l&&w.jsx(l,{size:20}),w.jsx("span",{className:"mb-tab-label",children:B(f.name)})]},f.id)})}),(a||i||o.length>0)&&w.jsxs("div",{className:"mb-foot-row",children:[w.jsx("div",{className:"mb-foot-account",children:a?w.jsx(a,{expanded:!0}):null}),o.map(f=>{const l=f.icon;return w.jsx("button",{className:"mb-icon-btn",onClick:()=>f.onClick?.(),"aria-label":f.tooltip?B(f.tooltip):f.id,children:l?w.jsx(l,{size:20}):null},f.id)}),i&&w.jsx("button",{className:"mb-icon-btn",onClick:()=>i.onClick?.(),"aria-label":"settings",children:r?w.jsx(r,{size:20}):null})]})]}):null}function dp(){return Vr(ae.getState().items,dn()).map(e=>({id:e.id,label:e.tooltip?co(B(e.tooltip)):e.id,...e.icon?{icon:P.createElement(e.icon,{size:14})}:{},run:()=>e.onClick?.()}))}function Ms(){const e=et();e?.newPage?e.newPage():R.getState().openView("launcher",{},"main",{newTab:!0})}async function dc(e){const t=R.getState().mainTabs,n=t.map(a=>{const r=W(a.type);return{id:`tab:${a.id}`,label:a.title||(r?B(r.displayName):a.type),icon:r?.TabIcon?P.createElement(r.TabIcon,{params:{notePath:a.filePath},size:24}):r?.icon,...a.active?{checked:!0}:{},...a.closable&&t.length>1?{trailing:{id:"close",label:e("lcl.mobile.closeTab"),icon:bs}}:{}}}),s=await ks({title:e("lcl.mobile.tabs"),sections:[{items:n},..._s()?[{items:[{id:"new",label:e("lcl.tab.new"),icon:gs}]}]:[]]});if(!s.handled)return!1;const i=s.value;if(!i)return!0;if(i.id==="new")return Ms(),!0;const o=i.id.slice(4);return i.trailing?(R.getState().closeLeaf(o),R.getState().mainTabs.length>0&&dc(e),!0):(R.getState().activateLeaf(o),!0)}const va="tab:new",fc=e=>e.icon?.imageUrl?e.icon.nativeFallback:e.icon;async function Rf(e){const{spaces:t,activeSpaceId:n}=Y.getState(),s=xs(t.map(r=>r.id)),i=r=>({id:`space:${r.id}`,label:B(r.name),icon:fc(r),...r.id===n?{checked:!0}:{}}),o=await ks({title:e("lcl.mobile.allSpacesTitle"),sections:[{title:e("lcl.mobile.dock.inDock"),grid:!0,items:t.filter(r=>s.has(r.id)).map(i)},{title:e("lcl.mobile.dock.others"),grid:!0,items:t.filter(r=>!s.has(r.id)).map(i)},{items:[{id:"dock:edit",label:e("lcl.mobile.dock.edit"),icon:ed}]}].filter(r=>r.items.length)}),a=o.handled?o.value?.id:void 0;if(a){if(a==="dock:edit"){$f(e);return}uc(a.slice(6))}}async function $f(e){const t=Y.getState().spaces,n=t.map(o=>o.id),s=xs(n),i=await uf({title:e("lcl.mobile.dock.editTitle"),items:t.slice(1).map(o=>({id:`pick:${o.id}`,label:B(o.name),icon:fc(o)})),checked:n.slice(1).filter(o=>s.has(o)).map(o=>`pick:${o}`),footer:e("lcl.mobile.dock.editHint",{first:B(t[0]?.name??""),max:ts}),done:e("lcl.mobile.dock.done"),max:ts});i.handled&&i.value&&vf(n,i.value.checked.map(o=>o.slice(5)))}async function zf(e){const t=ro(ae.getState().items,dn()),n=Fr(he.getState().commands);if(t.some(o=>o.component))return!1;const s=await ks({title:e("lcl.mobile.more"),sections:[..._s()?[{items:[{id:va,label:e("lcl.tab.new"),icon:gs}]}]:[],...t.length?[{items:t.map(o=>({id:o.id,label:o.tooltip?co(B(o.tooltip)):o.id,icon:o.icon,...o.dot?.get()&&o.dot.label?{detail:o.dot.label()}:{}}))}]:[],...n.map(o=>({...o.title?{title:o.title}:{},items:o.commands.map(a=>({id:`cmd:${a.id}`,label:Dr(a),icon:a.icon??wr,...Wr(a)?{checked:!0}:{}}))}))]});if(!s.handled)return!1;const i=s.value?.id;if(!i)return!0;if(i===va)return Ms(),!0;if(i.startsWith("cmd:")){const o=i.slice(4),a=he.getState();return Fd(n.flatMap(r=>r.commands),a.commands,o)&&a.run(o),!0}return t.find(o=>o.id===i)?.onClick?.(),!0}function Vf({onClose:e}){const t=ae(r=>r.items),n=ro(t,dn()),s=Ya(t),i=Fr(he(r=>r.commands)),o=Qr(),{t:a}=Tt();return w.jsx("div",{className:"mb-sheet-scrim",onClick:e,children:w.jsxs("div",{className:"mb-sheet",onClick:r=>r.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[w.jsx("div",{className:"mb-sheet-grip"}),o&&_s()&&w.jsxs("button",{className:"mb-sheet-row","data-act":"new-tab",onClick:()=>{e(),Ms()},children:[w.jsx(gs,{size:20}),w.jsx("span",{children:a("lcl.tab.new")})]}),n.map(r=>{if(r.component){const f=r.component;return w.jsx("div",{className:"mb-sheet-card",children:w.jsx(f,{expanded:!0})},r.id)}const c=r.icon;return w.jsxs("button",{className:"mb-sheet-row","data-ribbon-id":r.id,onClick:()=>{r.onClick?.(),e()},children:[c&&w.jsx(c,{size:20}),w.jsx("span",{children:r.tooltip?co(B(r.tooltip)):r.id}),s.has(r.id)&&w.jsx("span",{className:"rb-badge rb-dot",role:"img","aria-label":r.dot?.label?.()})]},r.id)}),i.map(r=>w.jsxs("div",{className:"mb-sheet-group","data-more-group":r.id,children:[r.title&&w.jsx("div",{className:"mb-sheet-head",children:r.title}),r.commands.map(c=>{const f=c.icon??wr,l=Wr(c);return w.jsxs("button",{className:"mb-sheet-row","data-command-id":c.id,"aria-pressed":c.checked?l:void 0,onClick:()=>{e(),he.getState().run(c.id)},children:[w.jsx(f,{size:20}),w.jsx("span",{children:Dr(c)})]},c.id)})]},r.id))]})})}function Ff({onClose:e}){const t=R(i=>i.mainTabs),{t:n}=Tt(),s=()=>{Ms(),e()};return w.jsx("div",{className:"mb-sheet-scrim",onClick:e,children:w.jsxs("div",{className:"mb-sheet",onClick:i=>i.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[w.jsx("div",{className:"mb-sheet-grip"}),t.map(i=>{const o=W(i.type),a=o?.icon,r=o?.TabIcon;return w.jsxs("div",{role:"button",className:`mb-sheet-row mb-tabrow${i.active?" on":""}`,onClick:()=>{R.getState().activateLeaf(i.id),e()},children:[r?w.jsx(r,{params:{notePath:i.filePath},size:18}):a?w.jsx(a,{size:18}):null,w.jsx("span",{className:"mb-tabrow-label",children:i.title}),i.closable&&t.length>1?w.jsx("span",{className:"mb-tabrow-x",role:"button","aria-label":n("lcl.mobile.closeTab"),onClick:c=>{c.stopPropagation(),R.getState().closeLeaf(i.id)},children:w.jsx(bs,{size:17})}):null]},i.id)}),_s()&&w.jsxs("button",{className:"mb-sheet-row mb-tabrow-new",onClick:s,children:[w.jsx(gs,{size:18})," ",w.jsx("span",{children:n("lcl.tab.new")})]})]})})}const mc="(min-aspect-ratio: 4/3) and (min-width: 520px)",Ci=()=>{const e=document.documentElement.dataset.nativeWide;return e?e==="1":window.matchMedia(mc).matches};function hc(e){const[t,n]=P.useState(()=>Ci());return P.useEffect(()=>{const s=window.matchMedia(mc),i=()=>n(Ci());i(),s.addEventListener("change",i);const o=new MutationObserver(i);return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-native-wide"]}),()=>{s.removeEventListener("change",i),o.disconnect()}},[e]),t}function fp(){return hc(!0)}const mp=({buildDefault:e})=>{P.useEffect(()=>{const j=R.getState();j.setWideMode(Ci()),e&&j.setDefaultBuilder(e),ql()||e?.(),lc(),j.refreshTabs()},[]);const t=P.useRef(null),[n,s]=P.useState(!1),[i,o]=P.useState(!1),a=uo(),r=lo(),c=R(j=>j.leftLeaves.length>0||j.sidebarDefaults.left.length>0)||a&&!r,f=R(j=>j.rightLeaves.length>0||j.sidebarDefaults.right.length>0),l=R(j=>j.leftVisible),m=R(j=>j.rightVisible),g=R(j=>j.mainTabs.length),p=R(j=>j.activeMainId),d=ae(j=>j.items),S=Ya(d),_=ro(d,r).find(j=>S.has(j.id)),v=!!_,I=_?String(_.dot?.label?.()??"").slice(0,120):null,C=Y(j=>j.activeSpaceId),A=hc(!0),M=kf(t,!0);R(j=>j.wideMode);const O=tt(),{t:$}=Tt(),u=P.useRef($);u.current=$;const b=()=>{if(!aa()){o(!0);return}dc(u.current).then(j=>{j||o(!0)})},h=()=>{if(!aa()){s(!0);return}zf(u.current).then(j=>{j||s(!0)})},y=Qr(),k={left:$("lcl.mobile.leftPanel"),right:$("lcl.mobile.rightPanel"),tabs:$("lcl.mobile.tabs"),more:$("lcl.mobile.more")},x=JSON.stringify({...k,back:$("lcl.mobile.back")}),E=P.useRef({tabs:b,more:h});E.current={tabs:b,more:h},P.useEffect(()=>{if(!y)return;const{back:j,...H}=JSON.parse(x),U=()=>{const re=R.getState(),st=dn(),$e=tt(),fn=$e&&re.leftVisible,mn=$e&&!fn,we=pf(fn?"list":"main");ca({title:fn?B(et()?.name??""):re.mainTabs.find(As=>As.active)?.title??"",left:$e?mn:re.leftLeaves.length>0||re.sidebarDefaults.left.length>0||!st&&cc(),...mn?{leftBack:!0}:{},right:!fn&&(re.rightLeaves.length>0||re.sidebarDefaults.right.length>0),tabCount:re.mainTabs.length||1,labels:mn?{...H,left:j}:H,...st&&!mn?{spaces:Af(),allLabel:u.current("lcl.mobile.allSpaces")}:{},...we?.search?{search:we.search.label}:{},...we?.title?{titleSub:we.title.sub,...we.title.run?{titleTap:!0}:{}}:{},...I!==null?{moreDot:{label:I}}:{},...ss?{leftInset:ss}:{},...we?.capLeftMax?{capLeftMax:we.capLeftMax}:{}},{left:()=>R.getState().toggleSidebar("left"),right:()=>R.getState().toggleSidebar("right"),tabs:()=>E.current.tabs(),more:()=>E.current.more(),search:()=>we?.search?.run(),title:()=>we?.title?.run?.(),spacesAll:()=>{Rf(u.current)},space:uc,spaceLong:As=>{const Ns=Y.getState().spaces.find(Oc=>Oc.id===As);Ns&&br(Ns.id,B(Ns.name))}})};U();const de=[R.subscribe(U),Y.subscribe(U),ae.subscribe(U),gf(U),yf(U),If(U)];return()=>{de.forEach(re=>re())}},[y,x,I]),P.useEffect(()=>()=>ca(null),[]);const L=P.useRef({tabs:!1,more:!1});L.current={tabs:i,more:n},P.useEffect(()=>{const j=H=>{const U=H.detail?.probe;if(L.current.tabs){U||o(!1),H.preventDefault();return}L.current.more&&(U||s(!1),H.preventDefault())};return window.addEventListener("forsion:mobile-back",j),()=>window.removeEventListener("forsion:mobile-back",j)},[]);const T=P.useRef("left");P.useEffect(()=>{l&&(T.current="left")},[l]),P.useEffect(()=>{m&&(T.current="right")},[m]),P.useEffect(()=>{A||!l||!m||R.getState().toggleSidebar(T.current==="left"?"right":"left")},[l,m,A]),P.useEffect(()=>{if(R.getState().setWideMode(A),!A)return;const j=R.getState();!j.leftVisible&&(j.leftLeaves.length>0||j.sidebarDefaults.left.length>0)&&j.toggleSidebar("left")},[A]);const N=()=>{const j=R.getState();j.rightVisible?j.toggleSidebar("right"):j.leftVisible&&!A&&j.toggleSidebar("left")},F=P.useRef(null);Lf(F,A,c,f);const z=!A&&(l&&!O||m),q=w.jsxs("header",{className:"mb-topbar",children:[w.jsx("div",{className:"mb-cap",children:c?w.jsx("button",{className:"mb-icon-btn",onClick:()=>R.getState().toggleSidebar("left"),"aria-label":"left panel",children:w.jsx(Gu,{size:20})}):w.jsx("span",{className:"mb-icon-btn mb-icon-btn--ghost"})}),w.jsx("div",{className:"mb-topbar-spacer",children:!m&&!(l&&!A)?w.jsx(ac,{leafId:p,inTopbar:!0}):null}),w.jsxs("div",{className:"mb-cap",children:[f?w.jsx("button",{className:"mb-icon-btn",onClick:()=>R.getState().toggleSidebar("right"),"aria-label":"right panel",children:w.jsx(Ju,{size:20})}):null,w.jsx("button",{className:"mb-icon-btn mb-tabsbtn",onClick:b,"aria-label":"tabs",children:w.jsx("span",{className:"mb-tabcount",children:g||1})}),w.jsxs("button",{className:`mb-icon-btn${v?" mb-has-dot":""}`,onClick:h,"aria-label":"more",children:[w.jsx(Pu,{size:20}),v&&w.jsx("span",{className:"rb-badge rb-dot","aria-hidden":"true"})]})]})]});return w.jsxs("div",{className:"mb-shell","data-chrome":M?"off":void 0,"data-native-chrome":y?"":void 0,"data-space":C,"data-nav":O?l?"list":"detail":void 0,"data-list-first":O?"":void 0,"data-wide":A?"":void 0,style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[w.jsxs("div",{ref:F,className:`mb-body${!A&&l?" push-left":""}${!A&&m?" push-right":""}`,children:[w.jsx(ga,{side:"left",docked:A,showFoot:!0,page:O}),w.jsxs("main",{ref:t,className:"mb-main",children:[!y&&q,w.jsx(Ef,{})]}),w.jsx("div",{className:`mb-push-dim${z||A&&m?" on":""}`,onClick:N}),w.jsx(ga,{side:"right"})]}),i&&w.jsx(Ff,{onClose:()=>o(!1)}),n&&w.jsx(Vf,{onClose:()=>s(!1)})]})},pc=ue(e=>({items:[],addStatusItem:t=>e(n=>({items:[...n.items.filter(s=>s.id!==t.id),t]})),removeStatusItem:t=>e(n=>({items:n.items.filter(s=>s.id!==t)}))})),hp=e=>pc.getState().addStatusItem(e),pp=e=>pc.getState().removeStatusItem(e),Qs=e=>e.replace(/\\/g,"/"),Df=/^[a-zA-Z]:[\\/]|^[\\/]{2}/,gc=e=>!!e&&Df.test(e),gp=(e,t)=>gc(t)&&!/^(?:[a-zA-Z]:)?[\\/]/.test(e)&&e.includes("\\")?e.replace(/\\/g,"/"):e,Is=(e,t)=>gc(t)&&e.includes("/")?e.replace(/\//g,"\\"):null;function bc(e){return/\.(?=[a-z0-9]*[a-z])[a-z0-9]{1,10}$/i.test(e)&&!/\.md$/i.test(e)}function Wf(e,t,n){return zn(e,t,n)??(bc(e)?sn(`${e}.md`,t,n):null)??(/\.[^./\\]+\.md$/i.test(e)?sn(e,t,n):null)}function zn(e,t,n){return bc(e)?sn(e,t,n):null}function sn(e,t,n){const s=Qs(e).toLowerCase(),i=a=>Qs(a).toLowerCase();if(s.includes("/"))return t.find(a=>i(a)===s)??null;const o=t.filter(a=>i(a).split("/").pop()===s).sort();if(o.length>1&&n){const a=Qs(n).toLowerCase().split("/").slice(0,-1).join("/"),r=o.find(c=>i(c).split("/").slice(0,-1).join("/")===a);if(r)return r}return o[0]??null}function bp(e,t){const n=e.split("|")[0].split("#")[0].trim().replace(/\\/g,"/").toLowerCase();return!n||n.includes("/")?!1:t.filter(s=>s.replace(/\\/g,"/").toLowerCase().split("/").pop()===n).length>1}const Kf=/^(?:[A-Za-z0-9]|%[0-9A-F]{2})(?:[A-Za-z0-9._-]|%[0-9A-F]{2}){0,254}$/,vc=e=>typeof e=="string"&&e.length<=255&&Kf.test(e);function Ps(e){const t=String(e||"").replace(/[[\]|\r\n]+/g," ").replace(/\s+/g," ").trim(),n=[...t];return n.length>60?n.slice(0,59).join("").trimEnd()+"…":t}function vp(e){return`[[${e.kind}://${e.id}|${Ps(e.name)||e.id}]]`}function Bf(e){const t=/^\s*(app|window):\/\/([^|\s]+)\s*(?:\|([\s\S]*))?$/.exec(e),n=t?t[2].replace(/\\/g,""):"";return!t||!vc(n)?null:{kind:t[1],id:n,name:Ps(t[3]||"")||n}}const yp=e=>`${e.kind}://${e.id}|${e.kind==="window"?Ps(e.name):""}`;function wp(e){const t=e;return!t||t.kind!=="app"&&t.kind!=="window"||!vc(t.id)?null:{kind:t.kind,id:t.id,name:Ps(typeof t.name=="string"?t.name:"")||t.id}}const K=typeof window>"u"?void 0:window.amadeus,Mn=e=>/\.md$/i.test(e),ft=e=>e.replace(/\.md$/i,".fd"),Hf=e=>e.replace(/\.fd$/i,".md");function qf(e){const t=e.replace(/\\/g,"/").split("/");for(let n=t.length-2;n>=0;n--)if(/\.fd$/i.test(t[n]))return t.slice(0,n+1).join("/");return null}function Gf(e,t,n){const s=o=>o.replace(/\\/g,"/"),i=`${s(ft(e))}/`;return[...t,...n].map(s).filter(o=>o.startsWith(i)&&!o.slice(i.length).includes("/")).map(o=>o.slice(i.length)).sort((o,a)=>o.localeCompare(a))}function Uf(e={}){const t=e.cap??200,n=e.coalesceMs??500,s=[],i=[];let o=0,a=null;const r=()=>{s.length=0,i.length=0,a=null},c=(f,l,m)=>{const g=f[f.length-1];return g?g.page!==m.page?(r(),null):(l.push(m),a=null,f.pop()):null};return{push(f,l,m){if(a===l&&m-o<n){o=m;return}s.push(f),s.length>t&&s.shift(),i.length=0,o=m,a=l},undo:f=>c(s,i,f),redo:f=>c(i,s,f),reset:r}}let ei=null;const ya=ue(e=>({palette:null,setPalette:t=>e({palette:t}),toast:null,notify:t=>{e({toast:t}),ei&&clearTimeout(ei),ei=setTimeout(()=>e({toast:null}),2600)}})),Jf=700,Xf=120,Yf=8e3,Zf=3e4;let is=0,os=0;const Ne=()=>Date.now();function Qf(){os=Ne()}function em(){return is>0&&Ne()-is<Zf}function tm(){return Ne()-os<Jf}let wa=!1;function nm(e){if(wa)return;wa=!0,e.addEventListener("compositionstart",()=>{is=Ne()},!0);const t=()=>{is=0,os=Ne()};e.addEventListener("compositionend",t,!0),e.addEventListener("beforeinput",()=>{os=Ne()},!0)}async function sm(e=Yf){const t=Ne()+e;for(;em()||tm()&&Ne()<t;)await new Promise(n=>setTimeout(n,Xf))}const as=24,im=.25,om=2.5,Sa=8,Sp=(e,t)=>e?as:t?Sa*4:Sa,kp=3,xp=10,Ep=500,_p=10,In=e=>Math.round(e/as)*as;function Mp(e,t,n,s,i,o,a){const r=t.includes("w"),c=t.includes("e"),f=t.includes("n"),l=t.includes("s");let m=r?e.x+n:e.x,g=c?e.x+e.w+n:e.x+e.w,p=f?e.y+s:e.y,d=l?e.y+e.h+s:e.y+e.h;return i?(r&&(m=In(m)),c&&(g=In(g)),f&&(p=In(p)),l&&(d=In(d))):(m=Math.round(m),g=Math.round(g),p=Math.round(p),d=Math.round(d)),g-m<o&&(r?m=g-o:g=m+o),d-p<a&&(f?p=d-a:d=p+a),{x:m,y:p,w:g-m,h:d-p}}const am=(e,t)=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y,Ip=(e,t,n,s)=>({x:Math.min(e,n),y:Math.min(t,s),w:Math.abs(n-e),h:Math.abs(s-t)});function Pp(e,t){const n=[];for(const[s,i]of t)am(e,i)&&n.push(s);return n}function rm(e){if(!e.length)return null;let t=1/0,n=1/0,s=-1/0,i=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),s=Math.max(s,o.x+o.w),i=Math.max(i,o.y+o.h);return{x:t,y:n,w:Math.max(1,s-t),h:Math.max(1,i-n)}}const yc={v:[],h:[]},mt=(e,t)=>[e,e+t/2,e+t];function ht(e,t,n){let s=null;for(const i of e)for(const o of t){const a=o-i;Math.abs(a)>n||(!s||Math.abs(a)<Math.abs(s.d))&&(s={d:a,line:o})}return s}function Lp(e,t,n){if(!t.length||n<=0)return{dx:0,dy:0,guides:yc};const s=[],i=[];for(const r of t)s.push(...mt(r.x,r.w)),i.push(...mt(r.y,r.h));const o=ht(mt(e.x,e.w),s,n),a=ht(mt(e.y,e.h),i,n);return{dx:o?.d??0,dy:a?.d??0,guides:{v:o?[o.line]:[],h:a?[a.line]:[]}}}function Cp(e,t,n,s,i,o){if(!n.length||s<=0)return{box:e,guides:yc};const a=[],r=[];for(const p of n)a.push(p.x,p.x+p.w),r.push(p.y,p.y+p.h);let{x:c,y:f,w:l,h:m}=e;const g={v:[],h:[]};if(t.includes("w")){const p=ht([c],a,s);p&&l-p.d>=i&&(c+=p.d,l-=p.d,g.v.push(p.line))}else if(t.includes("e")){const p=ht([c+l],a,s);p&&l+p.d>=i&&(l+=p.d,g.v.push(p.line))}if(t.includes("n")){const p=ht([f],r,s);p&&m-p.d>=o&&(f+=p.d,m-=p.d,g.h.push(p.line))}else if(t.includes("s")){const p=ht([f+m],r,s);p&&m+p.d>=o&&(m+=p.d,g.h.push(p.line))}return{box:{x:Math.round(c),y:Math.round(f),w:Math.round(l),h:Math.round(m)},guides:g}}function Ap(e,t,n,s){const i=(a,r)=>a.some(c=>Math.abs(c-r)<=.5),o=[];for(const a of n.v){const r=[e,...t.filter(l=>i(mt(l.x,l.w),a))],c=Math.min(...r.map(l=>l.y)),f=Math.max(...r.map(l=>l.y+l.h));o.push({dir:"v",x:a-s/2,y:c,w:s,h:f-c})}for(const a of n.h){const r=[e,...t.filter(l=>i(mt(l.y,l.h),a))],c=Math.min(...r.map(l=>l.x)),f=Math.max(...r.map(l=>l.x+l.w));o.push({dir:"h",x:c,y:a-s/2,w:f-c,h:s})}return o}const Np=7,Rt=32,cm=1e3;function Tp(e,t,n){const s=(i,o,a)=>{if(a-o<Rt*3)return 0;const r=c=>{const f=Math.min(1,(Rt-c)/Rt);return cm*f*f};return a-i<Rt?r(a-i):i-o<Rt?-r(i-o):0};return{vx:s(t,e.left,e.right),vy:s(n,e.top,e.bottom)}}const lm=2,on=new Map,um=(e,t)=>{e&&on.set(e,t)},dm=e=>on.get(e),fm=e=>{on.delete(e)},wc=e=>Math.max(im,Math.min(om,e));function mm(e,t,n,s){const i=wc(t);return{z:i,x:n-(n-e.x)*i/e.z,y:s-(s-e.y)*i/e.z}}function Sc(e){if(!e)return{w:0,h:0,u:1};const t=Et(e)||1,n=e.getBoundingClientRect();return{w:n.width/t,h:n.height/t,u:t}}function hm(e,t,n=48){const s=rm(t),{w:i,h:o}=Sc(e);if(!s||i<=0||o<=0)return null;const a=wc(Math.min((i-n*2)/s.w,(o-n*2)/s.h,1));return{z:a,x:(i-s.w*a)/2-s.x*a,y:(o-s.h*a)/2-s.y*a}}function Op(e,t=as){const n=t*e.z,s=i=>(i%n+n)%n;return{"--amx-grid-step":`${n}px`,transform:`translate3d(${s(e.x)}px, ${s(e.y)}px, 0)`}}function jp(e,t="",n,s={x:0,y:0,z:1},i){const[o,a]=P.useState(()=>t&&on.get(t)||s),r=P.useRef(o);r.current=o;const c=P.useRef(t);c.current=t;const f=P.useRef(n);f.current=n;const l=P.useRef(i);l.current=i;const m=P.useCallback(C=>{const A=l.current?.(C,e.current)??C;r.current=A,c.current&&on.set(c.current,A),a(A)},[e]),g=P.useCallback((C,A)=>{const M=e.current,O=Et(M??void 0)||1,$=M?.getBoundingClientRect(),{x:u,y:b,z:h}=r.current,y=((C-($?.left??0))/O-u)/h,k=((A-($?.top??0))/O-b)/h;return{x:y,y:k}},[e]),p=P.useCallback((C,A)=>{const M=Et(e.current??void 0)||1,O=r.current.z;return{dx:C/M/O,dy:A/M/O}},[e]),d=P.useCallback(C=>{if(!C)return()=>{};const A=M=>{if(M.target?.closest?.(".amx-stage-minimap"))return;f.current?.(),M.preventDefault();const O=r.current,$=Et(C)||1;if(M.metaKey||M.ctrlKey){const u=M.ctrlKey&&!M.metaKey?lm:1,b=C.getBoundingClientRect();m(mm(O,O.z*Math.exp(-M.deltaY*u/300),(M.clientX-b.left)/$,(M.clientY-b.top)/$))}else{const u=M.shiftKey&&!M.deltaX?M.deltaY:M.deltaX,b=M.shiftKey?0:M.deltaY;m({z:O.z,x:O.x-u/$,y:O.y-b/$})}};return C.addEventListener("wheel",A,{passive:!1}),()=>C.removeEventListener("wheel",A)},[m]),S=P.useCallback((C,A)=>{f.current?.();const{w:M,h:O}=Sc(e.current);if(!M||!O)return;const $=r.current.z;m({z:$,x:M/2-C*$,y:O/2-A*$})},[e,m]),_=P.useCallback((C,A=48)=>{const M=hm(e.current,C,A);M&&(f.current?.(),m(M))},[e,m]),v=P.useRef(s),I=P.useCallback(()=>{f.current?.(),m(v.current)},[m]);return{vp:o,vpRef:r,setVp:m,toStage:g,toStageDelta:p,bindWheel:d,centerOn:S,fitTo:_,reset:I}}const pm="amx.noteSurfaceMode:",pt=new Map;function _e(e,t){return JSON.stringify([e??"",t])}const mo=(e,t)=>`${pm}${_e(e,t)}`;function gm(e,t){try{const n=localStorage.getItem(mo(e,t));return n==="doc"||n==="canvas"?n:null}catch{return null}}function bm(e,t,n){try{localStorage.setItem(mo(e,t),n)}catch{}}function Rp(e,t){const n=_e(e,t);return pt.get(n)??Ls(nt()[n])?.s??0}function $p(e,t,n){const s=_e(e,t),i=Math.max(0,Number.isFinite(n)?n:0);pt.set(s,i),go(s,{s:Math.round(i)})}const ho="amx.noteView.v1",ka=300;let Ht=null,Xe=null;function po(){try{const e=JSON.parse(localStorage.getItem(ho)??"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function nt(){return Ht||(Ht=po()),Ht}const Ls=e=>e&&!e.d?e:void 0;function kc(){const e=nt();for(const[t,n]of Object.entries(po()))(!e[t]||(e[t].u??0)<(n.u??0))&&(e[t]=n)}function Cs(){Xe&&(clearTimeout(Xe),Xe=null);const e=nt(),t=po();for(const[s,i]of Object.entries(e))(!t[s]||(t[s].u??0)<=i.u)&&(t[s]=i);const n=Object.keys(t);if(n.length>ka){n.sort((s,i)=>(t[i].u??0)-(t[s].u??0));for(const s of n.slice(ka))delete t[s]}Ht=t;try{localStorage.setItem(ho,JSON.stringify(t))}catch{}}function go(e,t){const n=nt();n[e]={...Ls(n[e]),...t,u:Date.now()},Xe||(Xe=setTimeout(Cs,500))}if(typeof window<"u"){const e=()=>{Xe&&Cs()};window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e),window.addEventListener("storage",t=>{t.key===ho&&Ht&&kc()})}function zp(){Xe&&Cs()}function Vp(e,t){const n=Ls(nt()[_e(e,t)])?.c;return n&&Number.isInteger(n.a)&&Number.isInteger(n.h)&&typeof n.t=="string"?n:null}function Fp(e,t,n){go(_e(e,t),{c:n})}function vm(e,t,n){if(t===n)return;const s=gm(e,t);if(s){bm(e,n,s);try{localStorage.removeItem(mo(e,t))}catch{}}const i=_e(e,t),o=_e(e,n);pt.has(i)&&(pt.set(o,pt.get(i)),pt.delete(i)),kc();const a=Ls(nt()[i]);if(a){const{u:c,d:f,...l}=a;go(o,l)}nt()[i]={d:1,u:Date.now()},Cs();const r=dm(i);r&&(um(o,r),fm(i)),ym(e,t)&&(xa(e,n,!0),xa(e,t,!1)),Mc(e,t,n)}const xc="amx.noteLocked:",Ai="amadeus:note-lock",gt=(e,t)=>`${xc}${_e(e,t)}`;function ym(e,t){try{const n=Is(t,e),s=!!n&&localStorage.getItem(gt(e,n))==="1";if(s)try{localStorage.setItem(gt(e,t),"1"),localStorage.removeItem(gt(e,n))}catch{}return s||localStorage.getItem(gt(e,t))==="1"}catch{return!1}}function xa(e,t,n){try{if(n)localStorage.setItem(gt(e,t),"1");else for(const s of[t,Is(t,e)])s&&localStorage.removeItem(gt(e,s))}catch{}try{window.dispatchEvent(new Event(Ai))}catch{}}function Dp(e){const t=n=>{(!n.key||n.key.startsWith(xc))&&e()};return window.addEventListener(Ai,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ai,e),window.removeEventListener("storage",t)}}const Ni={wide:!1,small:!1,font:"default"},rs="amx.notePage:",cs="amadeus:note-page-style",qt=(e,t)=>`${rs}${_e(e,t)}`;function Ec(e){if(!e)return Ni;try{const t=JSON.parse(e);return{wide:t.w===1,small:t.s===1,font:t.f==="serif"||t.f==="mono"?t.f:"default"}}catch{return Ni}}function wm(e,t){try{return Ec(localStorage.getItem(qt(e,t)))}catch{return Ni}}function Wp(e,t,n){const s={...wm(e,t),...n};_c(qt(e,t),s);try{window.dispatchEvent(new Event(cs))}catch{}}function _c(e,t){const n={};t.wide&&(n.w=1),t.small&&(n.s=1),t.font!=="default"&&(n.f=t.font);try{Object.keys(n).length?localStorage.setItem(e,JSON.stringify(n)):localStorage.removeItem(e)}catch{}}function Kp(e){const t=n=>{(!n.key||n.key.startsWith(rs))&&e()};return window.addEventListener(cs,e),window.addEventListener("storage",t),()=>{window.removeEventListener(cs,e),window.removeEventListener("storage",t)}}function Mc(e,t,n){let s=null;try{s=localStorage.getItem(qt(e,t))}catch{return}if(s!=null){_c(qt(e,n),Ec(s));try{localStorage.removeItem(qt(e,t))}catch{}try{window.dispatchEvent(new Event(cs))}catch{}}}function Sm(e,t,n){if(t===n)return;const s=[];try{for(let i=0;i<localStorage.length;i++){const o=localStorage.key(i);if(!o||!o.startsWith(rs))continue;let a;try{a=JSON.parse(o.slice(rs.length))}catch{continue}if(!Array.isArray(a)||a[0]!==(e??"")||typeof a[1]!="string")continue;const r=a[1];(r===t||r.startsWith(`${t}/`))&&s.push([r,n+r.slice(t.length)])}}catch{return}for(const[i,o]of s)Mc(e,i,o)}const Ic="amx.propsOpen:";function Bp(e){try{const t=localStorage.getItem(`${Ic}${e??""}`);return t==="1"?!0:t==="0"?!1:null}catch{return null}}function Hp(e,t){try{localStorage.setItem(`${Ic}${e??""}`,t?"1":"0")}catch{}}function km(e,t){let n=Object.create(null);for(let o=0;o<t.length;o++){const a=t[o];n[a]?n[a].push(o):n[a]=[o]}let i=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let o=0;o<e.length;o++){const a=e[o],r=n[a]||[];let c=0,f=i[0];for(const l of r){let m;for(m=c;m<i.length&&!(i[m].buffer2index<l&&(m===i.length-1||i[m+1].buffer2index>l));m++);if(m<i.length){const g={buffer1index:o,buffer2index:l,chain:i[m]};if(c===i.length?i.push(f):i[c]=f,c=m+1,f=g,c===i.length)break}}i[c]=f}return i[i.length-1]}function Ea(e,t){const n=km(e,t);let s=[],i=e.length,o=t.length;for(let a=n;a!==null;a=a.chain){const r=i-a.buffer1index-1,c=o-a.buffer2index-1;i=a.buffer1index,o=a.buffer2index,(r||c)&&s.push({buffer1:[i+1,r],buffer1Content:e.slice(i+1,i+1+r),buffer2:[o+1,c],buffer2Content:t.slice(o+1,o+1+c)})}return s.reverse(),s}function xm(e,t,n){let s=[];function i(c,f){s.push({ab:f,oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]})}Ea(t,e).forEach(c=>i(c,"a")),Ea(t,n).forEach(c=>i(c,"b")),s.sort((c,f)=>c.oStart-f.oStart);let o=[],a=0;function r(c){c>a&&(o.push({stable:!0,buffer:"o",bufferStart:a,bufferLength:c-a,bufferContent:t.slice(a,c)}),a=c)}for(;s.length;){let c=s.shift(),f=c.oStart,l=c.oStart+c.oLength,m=[c];for(r(f);s.length;){const g=s[0],p=g.oStart;if(p>l)break;l=Math.max(l,p+g.oLength),m.push(s.shift())}if(m.length===1){if(c.abLength>0){const g=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,bufferContent:g.slice(c.abStart,c.abStart+c.abLength)})}}else{let g={a:[e.length,-1,t.length,-1],b:[n.length,-1,t.length,-1]};for(;m.length;){c=m.shift();const I=c.oStart,C=I+c.oLength,A=c.abStart,M=A+c.abLength;let O=g[c.ab];O[0]=Math.min(A,O[0]),O[1]=Math.max(M,O[1]),O[2]=Math.min(I,O[2]),O[3]=Math.max(C,O[3])}const p=g.a[0]+(f-g.a[2]),d=g.a[1]+(l-g.a[3]),S=g.b[0]+(f-g.b[2]),_=g.b[1]+(l-g.b[3]);let v={stable:!1,aStart:p,aLength:d-p,aContent:e.slice(p,d),oStart:f,oLength:l-f,oContent:t.slice(f,l),bStart:S,bLength:_-S,bContent:n.slice(S,_)};o.push(v)}a=l}return r(t.length),o}function Em(e,t,n,s){s=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},s),typeof e=="string"&&(e=e.split(s.stringSeparator)),typeof t=="string"&&(t=t.split(s.stringSeparator)),typeof n=="string"&&(n=n.split(s.stringSeparator));let o=[];const a=xm(e,t,n);let r=[];function c(){r.length&&o.push({ok:r}),r=[]}function f(l,m){if(l.length!==m.length)return!1;for(let g=0;g<l.length;g++)if(l[g]!==m[g])return!1;return!0}return a.forEach(l=>{l.stable?r.push(...l.bufferContent):s.excludeFalseConflicts&&f(l.aContent,l.bContent)?r.push(...l.aContent):(c(),o.push({conflict:{a:l.aContent,aIndex:l.aStart,o:l.oContent,oIndex:l.oStart,b:l.bContent,bIndex:l.bStart}}))}),c(),o}za({"unisave.conflict.toast":{zh:"「{name}」在你编辑时被别处改过。已保留你的版本,被覆盖的那一版另存为「{copy}」。",en:'"{name}" was changed elsewhere while you were editing. Your version was kept, and the overwritten version was saved as "{copy}".'},"unisave.conflict.agentToast":{zh:"Tangu 在你编辑时改了「{name}」。已保留你的版本,Tangu 的改动另存为「{copy}」。",en:'Tangu changed "{name}" while you were editing. Your version was kept, and Tangu’s changes were saved as "{copy}".'},"unisave.conflict.open":{zh:"打开副本",en:"Open copy"},"unisave.failed.toast":{zh:"「{name}」没能保存({reason}),正在自动重试。保存成功之前请不要关闭它。",en:'Couldn’t save "{name}" ({reason}). Retrying automatically — keep it open until it’s saved.'},"unisave.failed.unknown":{zh:"未知原因",en:"unknown reason"},"unisave.failed.bar":{zh:"未保存:写入失败,正在自动重试",en:"Unsaved: the write failed and is being retried"},"unisave.failed.retry":{zh:"立即重试",en:"Retry now"},"unisave.draft.bar":{zh:"这篇笔记有一份上次没保存成功的草稿({time})。",en:"This note has a draft that wasn’t saved last time ({time})."},"unisave.draft.hint":{zh:"恢复后会覆盖盘上当前内容;盘上那一版若是别处改过的,会先另存为冲突副本。",en:"Restoring replaces what’s on disk now. If that version was changed elsewhere, it is saved as a conflict copy first."},"unisave.draft.restore":{zh:"恢复草稿",en:"Restore draft"},"unisave.draft.discard":{zh:"丢弃",en:"Discard"},"unisave.gone.toast":{zh:"「{name}」已在别处被删除或移走,最后的改动没来得及保存,另存副本也没写成。可以把这篇的内容复制下来。",en:'"{name}" was deleted or moved elsewhere before your last changes were saved, and a backup copy couldn’t be written. You can copy its text.'},"unisave.renameCopy.toast":{zh:"「{name}」改名时已被别处改过,没有覆盖它。你改名期间打的字另存为「{copy}」。",en:'"{name}" was changed elsewhere while it was being renamed, so it wasn’t overwritten. What you typed during the rename was saved as "{copy}".'},"unisave.moveCopy.toast":{zh:"「{name}」移动期间你打的字没能并进挪过去的那篇,另存为「{copy}」。",en:'What you typed while "{name}" was being moved couldn’t be merged into the moved note, so it was saved as "{copy}".'},"unisave.rescued.toast":{zh:"「{name}」已在别处被删除或移走。你还没保存的内容另存为「{copy}」。",en:'"{name}" was deleted or moved elsewhere. Your unsaved changes were saved as "{copy}".'},"unisave.gone.copy":{zh:"复制内容",en:"Copy text"},"unisave.gone.copied":{zh:"已复制到剪贴板",en:"Copied to clipboard"}});function Ct(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("amadeus:toast",{detail:e}))}const Re=e=>(e.split("/").pop()??e).replace(/\.md$/i,"");let _a=Promise.resolve();function Ma(e,t,n=new Date){const s=_a.then(()=>Ia(e,t,n),()=>Ia(e,t,n));return _a=s.catch(()=>{}),s}async function Ia(e,t,n){const s=$c(e,n);for(let i=1;i<=50;i++){const o=zc(s,i),a=await K.readTextFile(o);if(a===t)return o;if(a!=null)continue;const r=await K.writeTextFile(o,t,{create:!0});if(r&&r.ok===!1){if(r.current===t)return o;if(r.current!=null)continue;throw new Error("The conflict copy could not be created")}return o}throw new Error("Too many conflict copies in one minute")}function qp(e,t,n=!1){Ct({level:"error",dedupeKey:`amx-conflict:${e}`,text:Z(n?"unisave.conflict.agentToast":"unisave.conflict.toast",{name:Re(e),copy:Re(t)}),action:{label:Z("unisave.conflict.open"),run:()=>{window.dispatchEvent(new CustomEvent("amadeus:navigate-note",{detail:{path:t},cancelable:!0}))}}})}function _m(e){const n=(e instanceof Error?e.message:typeof e=="string"?e:"").replace(/^Error invoking remote method '[^']*':\s*/,"").replace(/^(?:[A-Za-z]*Error:\s*)+/,"").trim();return n?n.length>80?`${n.slice(0,79)}…`:n:Z("unisave.failed.unknown")}function Pa(e,t){Ct({level:"warning",dedupeKey:`amx-savefail:${e}`,text:Z("unisave.failed.toast",{name:Re(e),reason:_m(t)})})}function Gp(e,t){Ct({level:"error",dedupeKey:`amx-rescued:${t}`,text:Z("unisave.rescued.toast",{name:Re(e),copy:Re(t)}),action:{label:Z("unisave.conflict.open"),run:()=>{window.dispatchEvent(new CustomEvent("amadeus:navigate-note",{detail:{path:t},cancelable:!0}))}}})}function La(e,t,n=!1){Ct({level:"error",dedupeKey:`amx-renamecopy:${t}`,text:Z(n?"unisave.moveCopy.toast":"unisave.renameCopy.toast",{name:Re(e),copy:Re(t)}),action:{label:Z("unisave.conflict.open"),run:()=>{window.dispatchEvent(new CustomEvent("amadeus:navigate-note",{detail:{path:t},cancelable:!0}))}}})}function Ca(e,t,n){const s=[];for(const i of Em(t.split(`
|
|
5
|
+
`),e.split(`
|
|
6
|
+
`),n.split(`
|
|
7
|
+
`),{excludeFalseConflicts:!0})){if(!i.ok)return null;s.push(...i.ok)}return s.join(`
|
|
8
|
+
`)}function Up(e,t){Ct({level:"error",dedupeKey:`amx-gone:${e}:${ds(t)}`,text:Z("unisave.gone.toast",{name:Re(e)}),action:{label:Z("unisave.gone.copy"),run:()=>{navigator.clipboard?.writeText(t).then(()=>Ct({text:Z("unisave.gone.copied")}),()=>{})}}})}const Jp=[2e3,5e3,1e4,3e4,6e4],Pc=(e,t)=>`amadeus.unsavedDraft:${e??""}:${t}`,At=(e,t,n)=>Pc(e,t)+(n?`\0${n}`:"");function Xp(e,t,n,s,i){try{const o={text:n,base:ds(s),at:Date.now()};localStorage.setItem(At(e,t,i),JSON.stringify(o))}catch{}}function Dt(e,t){if(!e)return null;const n=JSON.parse(e);return typeof n.text=="string"&&typeof n.base=="string"?{text:n.text,base:n.base,at:Number(n.at)||0,slot:t}:null}function Yp(e,t,n,s=()=>!0){const i=Aa(e,t,n,s),o=i?null:Is(t,e),a=o?Aa(e,o,n,s):null;if(!a||!o)return i;try{const r=At(e,o,a.slot),c=At(e,t,a.slot),f=localStorage.getItem(r);f!=null&&localStorage.getItem(c)==null&&(localStorage.setItem(c,f),localStorage.removeItem(r))}catch{}return a}function Aa(e,t,n,s){try{const i=At(e,t);if(n){const r=Dt(localStorage.getItem(At(e,t,n)),n);if(r)return r;const c=s(null)?null:Dt(localStorage.getItem(i),null);if(c)return c}else{const r=Dt(localStorage.getItem(i),null);if(r)return r}const o=Pc(e,t)+"\0";let a=null;for(let r=0;r<localStorage.length;r++){const c=localStorage.key(r);if(!c||!c.startsWith(o))continue;const f=c.slice(o.length);if(f===n||s(f))continue;const l=Dt(localStorage.getItem(c),f);l&&(!a||l.at>a.at)&&(a=l)}return a}catch{return null}}function Zp(e,t,n,s){try{for(const i of[t,Is(t,e)]){if(!i)continue;const o=At(e,i,s);if(n!=null){const a=Dt(localStorage.getItem(o),s??null);if(!a||a.text!==n)continue}localStorage.removeItem(o)}}catch{}}function Qp(){return typeof navigator<"u"&&/\bElectron\//.test(navigator.userAgent)}function Mm(){try{return window.tangu?.act}catch{return}}function bo(e,t){try{Mm()?.(e,t)}catch{}}const Im=5*6e4,Pn=new Map;function eg(e,t,n){try{const s=n||`${e}|${JSON.stringify(t||{})}`,i=Date.now(),o=Pn.get(s)||0;if(i-o<Im)return;Pn.set(s,i),Pn.size>500&&Pn.clear(),bo(e,t)}catch{}}const tg=e=>e==null?void 0:String(Array.isArray(e)?e.join(","):e).slice(0,40),Pm=1e4,ti=new Map;function ng(e,t,n){try{const s=`${e}|${n}`,i=ti.get(s);i&&clearTimeout(i),ti.set(s,setTimeout(()=>{ti.delete(s),bo(e,t)},Pm))}catch{}}za({"pagestore.error.renameUnsupportedType":{zh:"该文件类型不支持在标题栏改名",en:"This file type cannot be renamed from the title bar"},"pagestore.error.fdNameTaken":{zh:"目标名称已被同名 .fd 文件夹占用",en:"That name is already taken by a .fd folder"},"pagestore.error.moveIntoOwnSubpage":{zh:"不能移动到该笔记自己的子页面里",en:"A note can't be moved into its own subpages"},"pagestore.error.fdExistsAtDest":{zh:"目标位置已存在同名 .fd 文件夹",en:"A .fd folder with the same name already exists at the destination"},"pagestore.error.fdMoveFailed":{zh:"子页面文件夹未跟随移动:{err}",en:"The subpage folder didn't move along with the note: {err}"},"pagestore.notify.movedToTrash":{zh:"已移入回收站",en:"Moved to trash"},"pagestore.birth.failed":{zh:"没能新建「{name}」:{reason}",en:'Couldn’t create "{name}": {reason}'},"pagestore.birth.unknown":{zh:"文件没有建成",en:"the file wasn’t created"},"pagestore.confirm.deleteEmbeddedBlock":{zh:"有 {n} 处笔记嵌入了这个块,删除后那些嵌入会显示「丢失」。仍要删除?",en:"This block is embedded in {n} place(s). Those embeds will show as missing once it is deleted. Delete anyway?"}});const pe=e=>structuredClone(e);typeof document<"u"&&nm(document);function bt(e,t){for(let n=0;n<e.children.length;n++){const s=e.children[n];for(let i=0;i<s.columns.length;i++){const o=s.columns[i].children.findIndex(a=>a.ref===t);if(o>=0)return{rowIdx:n,colIdx:i,childIdx:o}}}return null}function Lm(e,t,n,s){const i=bt(e,t);if(!i)return null;const o=e.children[i.rowIdx].columns[i.colIdx];if(n==="prev"){if(i.childIdx>0)return o.children[i.childIdx-1].ref;if(i.rowIdx>0){const a=e.children[i.rowIdx-1],r=a.columns[Na(a,s)].children;return r.length?r[r.length-1].ref:null}return null}if(i.childIdx<o.children.length-1)return o.children[i.childIdx+1].ref;if(i.rowIdx<e.children.length-1){const a=e.children[i.rowIdx+1],r=a.columns[Na(a,s)].children;return r.length?r[0].ref:null}return null}function Na(e,t){if(e.columns.length<=1||t==null)return 0;let n=0,s=1/0;for(let i=0;i<e.columns.length;i++){let o=1/0,a=-1/0;for(const c of e.columns[i].children){const f=document.querySelector(`.block-host[data-block-id="${CSS.escape(c.ref)}"]`);if(!f)continue;const l=f.getBoundingClientRect();o=Math.min(o,l.left),a=Math.max(a,l.right)}if(a<=o)continue;if(t>=o&&t<=a)return i;const r=Math.abs(t-(o+a)/2);r<s&&(s=r,n=i)}return n}function Ta(e,t){for(const n of e.children)for(const s of n.columns)if(s.id===t)return{row:n,col:s};return null}function Cm(e){if(e.columns.length===1){e.columns[0].width=1;return}const t=e.columns.reduce((n,s)=>n+(s.width>0?s.width:0),0);if(t<=0){const n=1/e.columns.length;e.columns.forEach(s=>s.width=n);return}e.columns.forEach(n=>n.width=(n.width>0?n.width:0)/t)}function ot(e){for(let t=e.children.length-1;t>=0;t--){const n=e.children[t];for(let s=n.columns.length-1;s>=0;s--)n.columns[s].children.length===0&&n.columns.splice(s,1);if(n.columns.length===0){e.children.splice(t,1);continue}Cm(n)}}function at(e,t){const n=e.children[e.children.length-1];n?n.columns[n.columns.length-1].children.push({ref:t}):e.children.push({type:"row",id:Fn(),columns:[{id:ze(),width:1,children:[{ref:t}]}]})}function Ln(e,t){const n=new Set(t),s=[];for(const i of e.children)for(const o of i.columns){const a=[];for(const r of o.children)n.has(r.ref)?s.push(r):a.push(r);o.children=a}return s}const Cn=e=>[...new Set(Array.isArray(e)?e:[e])];function Oa(e,t){const n=bt(e,t);if(!n)return null;const s=e.children[n.rowIdx];if(s.columns.length!==1||s.columns[0].children.length<=1)return n.rowIdx;const i=s.columns[0],o=i.children.slice(0,n.childIdx),a=i.children[n.childIdx],r=i.children.slice(n.childIdx+1),c=m=>({type:"row",id:Fn(),columns:[{id:ze(),width:1,children:m}]}),f=[];let l;return o.length?(i.children=o,f.push(s),l=c([a])):(i.children=[a],l=s),f.push(l),r.length&&f.push(c(r)),e.children.splice(n.rowIdx,1,...f),e.children.indexOf(l)}function $t(e){const t={};for(const[n,s]of Object.entries(e.blocks))t[n]={id:n,type:s.type,content:s.content};return{manifest:e.manifest,blocks:t,loadNonce:{}}}function Am(e={}){let t=null,n=0,s=null,i=null,o=null;const a=new Set;let r=!1,c=null;const f=[],l=new Map;let m=!1;const g=p=>!!p&&f.some(d=>d(p));return ue((p,d)=>{const S=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,d().save()},400)},_=Uf(),v=()=>{const u=d();return{page:u.activePage,data:{manifest:u.manifest,blocks:u.blocks}}},I=u=>_.push(v(),u,Date.now()),C=u=>Object.fromEntries(Object.entries(u).map(([b,h])=>[b,h.content])),A=async(u,b,h,y,k)=>{const x=()=>{const H=d();if(H.activePage===u&&H.manifest)return So(H.manifest,C(H.blocks));const U=l.get(u);return U?So(U.manifest,U.contents):null};let E=x();if(E==null)return;const L=H=>H.replace(/\r\n/g,`
|
|
9
|
+
`);let T=b==null?null:L(b);const N=()=>Ra()===k,F=y?h:u;let z;try{z=await K.readTextFile(h);for(let H=0;H<5;H++){if(T==null||E!==T){let de=null;for(let re=0;re<3&&z!=null;re++){const st=T==null?null:Ca(T,E,L(z));if(st==null||!N())break;const $e=await K.writeTextFile(h,st,{base:ds(z)});if(!$e||$e.ok!==!1){de=st;break}z=$e.current}if(de!=null)z=de;else{if(!N())return;La(h,await Ma(F,E),!0),d().refreshPages()}}const U=x();if(U==null||U===E)break;T=E,E=U}}catch(H){if(T!=null&&E===T||!N())return;let U;try{U=await Ma(F,E)}catch{Pa(h,H);return}La(h,U,!0),d().activePage===u&&N()&&(t&&(clearTimeout(t),t=null),p({activePage:U,...$t(wo(U,E,new Date().toISOString())),status:"ready",error:null}));return}if(z==null||!N()||d().activePage!==u)return;t&&(clearTimeout(t),t=null);const q=x();let j=L(z);if(q!=null&&q!==E&&(j=Ca(E,q,j),j==null)){p({activePage:h}),S();return}p({activePage:h,...$t(wo(h,j,new Date().toISOString())),status:"ready",error:null}),j!==L(z)&&S()},M=async u=>{await d().refreshStructure().catch(()=>{});const{pages:b,files:h,folders:y}=d();return!b.includes(u)&&!h.includes(u)&&!y.includes(u)},O=u=>{(K.listFiles?.()??Promise.resolve([])).then(b=>{d().vaultRoot===u&&p({files:b,filesPendingFor:null})}).catch(()=>{})},$=(u,b=0)=>{K.pageIcons?.().then(h=>{d().vaultRoot===u&&p({icons:h})}).catch(()=>{b<2&&d().vaultRoot===u&&setTimeout(()=>$(u,b+1),b===0?3e3:12e3)})};return{vaultRoot:null,vaultSide:"local",pages:[],folders:[],files:[],filesPendingFor:null,icons:{},activePage:null,pendingPage:null,manifest:null,blocks:{},loadNonce:{},status:"idle",error:null,vaultLoading:!1,focusRequest:null,dndActiveId:null,dndOverId:null,linkGraphVersion:0,activeNotePath:null,pendingWikiCreate:null,setActiveNotePath(u){d().activeNotePath!==u&&p({activeNotePath:u})},bumpLinkGraph(){p(u=>({linkGraphVersion:u.linkGraphVersion+1}))},setDnd(u,b){p({dndActiveId:u,dndOverId:b})},requestFocus(u,b,h){p({focusRequest:{id:u,place:b,goalX:h}})},requestFocusAt(u,b){p({focusRequest:{id:u,place:"start",anchor:b}})},consumeFocus(u){const b=d().focusRequest;b&&b.id===u&&p({focusRequest:null})},flatOrder(){const u=d().manifest;if(!u)return[];const b=[];for(const h of u.root.children)for(const y of h.columns)for(const k of y.children)b.push(k.ref);return b},focusAdjacent(u,b,h){const y=d().manifest;if(!y)return;const k=Lm(y.root,u,b,h);k&&d().requestFocus(k,b==="prev"?"end":"start",h)},deleteBlockFocusPrev(u){const b=d().flatOrder(),h=b.indexOf(u),y=h>0?b[h-1]:null,k=h>=0&&h<b.length-1?b[h+1]:null;d().deleteBlock(u);const x=y??k;x&&d().requestFocus(x,y?"end":"start")},mergeWithPrev(u){const b=d().flatOrder(),h=b.indexOf(u);if(h<=0)return;const y=b[h-1],k=d().blocks,x=k[y]?.content??"",E=k[u]?.content??"",L=x.split(`
|
|
10
|
+
`).pop()??"",N=/^\s*(?:[-*+]\s|\d+[.)]\s|>|\||#{1,6}\s|```|~~~)/.test(L)?`
|
|
11
|
+
|
|
12
|
+
`:`
|
|
13
|
+
`,F=x&&E?`${x}${N}${E}`:x+E;I("struct"),p(z=>({blocks:{...z.blocks,[y]:{...z.blocks[y],content:F}}})),d().deleteBlock(u),x&&E?d().requestFocusAt(y,x.slice(-40)):d().requestFocus(y,"end")},async openVault(){try{await ut(!0);const u=await K.openVault();if(!u)return;Vi(),p({vaultRoot:u.root,vaultSide:"local",pages:u.pages,folders:u.folders??[],files:[],filesPendingFor:u.root,error:null}),O(u.root),$(u.root),u.pages.length>0&&await d().loadPage(u.pages[0])}catch(u){p({error:String(u)})}},async restoreVault(){p({vaultLoading:!0});try{const u=await K.restoreVault();if(!u)return;p({vaultRoot:u.root,pages:u.pages,folders:u.folders??[],files:[],filesPendingFor:u.root,error:null}),O(u.root),$(u.root);const b=u.lastPage&&u.pages.includes(u.lastPage)?u.lastPage:u.pages[0];b&&await d().loadPage(b)}catch(u){p({error:String(u)})}finally{p({vaultLoading:!1})}},async switchVaultSide(u){const b=window.amadeusSync;if(!(!b?.switchSide||d().vaultSide===u))try{await ut(!0);const h=await b.switchSide(u);if(!h)return;p({vaultSide:u,vaultRoot:h.root,pages:h.pages,folders:h.folders??[],files:[],filesPendingFor:h.root,icons:{},error:null,activePage:null,pendingPage:null,manifest:null,blocks:{}}),Vi(),O(h.root),$(h.root);const y=h.lastPage&&h.pages.includes(h.lastPage)?h.lastPage:h.pages[0];y?await d().loadPage(y):p({activePage:null,pendingPage:null,manifest:null,blocks:{},activeNotePath:null})}catch(h){p({error:String(h)})}},async initVaultSide(){const u=window.amadeusSync;if(u?.get)try{const h=(await u.get())?.side;h&&p({vaultSide:h})}catch{}},async refreshPages(){const u=await K.listPages();p({pages:u})},refreshIcons(){$(d().vaultRoot)},async loadPage(u){const b=++n;p({pendingPage:u,status:"loading",error:null});const h=d().flushSave().catch(()=>{});if((u===d().activePage||u===s)&&(await h,u===s&&await i?.catch(()=>{})),!(b!==n||d().pendingPage!==u))try{const y=await K.loadPage(u);if(b!==n||d().pendingPage!==u)return;p({activePage:u,pendingPage:null,...$t(y),status:"ready"})}catch(y){b===n&&d().pendingPage===u&&p({status:"idle",error:String(y),pendingPage:null})}},async createPage(){await d().createPageInFolder("")},async openOrCreate(u){const b=d().pages.includes(u);await d().loadPage(u),b||await d().refreshPages()},async createPageInFolder(u){await d().flushSave();const b=u.replace(/\\/g,"/").replace(/\/+$/,""),h=new Set(d().pages),y=L=>b?`${b}/${L}`:L;let k="untitled.md",x=1;for(;h.has(y(k));)x++,k=`untitled-${x}.md`;const E=y(k);await d().birthAndOpen(E)},async birthAndOpen(u){const b=await Oi(u);await d().refreshStructure(),b!=="failed"&&(b==="created"&&Ri(u),!Ti(u)&&await d().loadPage(u))},async releasePage(u){d().activePage===u&&(await d().flushSave(),d().activePage===u&&p({activePage:null,pendingPage:null,manifest:null,blocks:{}}))},async renamePage(u){const{manifest:b,activePage:h}=d();if(!b||!h)return!1;{const{matchFileType:N}=await Ve(async()=>{const{matchFileType:q}=await import("./appStore-BskcSDl6.js").then(j=>j.r9);return{matchFileType:q}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),{normalizePluginRename:F}=await Ve(async()=>{const{normalizePluginRename:q}=await import("./pluginExt-Byb64tQO.js");return{normalizePluginRename:q}},[],import.meta.url),z=N(h)?.extensions.find(q=>h.toLowerCase().endsWith(q.toLowerCase()));if(z){if(!/\.md$/i.test(z))return p({error:Z("pagestore.error.renameUnsupportedType")}),!1;u=F(u,z)}}const y=ft(h),k=d().folders.includes(y);if(k){let N=u.trim().replace(/[\\/]/g,"");if(N.toLowerCase().endsWith(".md")&&(N=N.slice(0,-3)),N){const F=h.includes("/")?h.slice(0,h.lastIndexOf("/")):"",z=F?`${F}/${N}.fd`:`${N}.fd`,{pages:q,folders:j,files:H}=d();if(z!==y&&(j.includes(z)||q.includes(z)||H.includes(z)))return p({error:Z("pagestore.error.fdNameTaken")}),!1}}t&&(clearTimeout(t),t=null),await ut();const{manifest:x,blocks:E,activePage:L}=d();if(!x||L!==h)return!1;const T={};for(const[N,F]of Object.entries(E))T[N]=F.content;try{const{newPath:N,page:F}=await K.renamePage(h,u,x,T);return p({activePage:N,pendingPage:null,...$t(F),status:"ready",error:null}),vt(h,N,"file"),k&&N!==h&&await Tc(h,N),await d().refreshStructure(),!0}catch(N){return p({error:String(N)}),!1}},async setPageCover(u,b){const h={cover:b??void 0},{activePage:y,manifest:k}=d();if(u===y&&k){const x=pn(k.fmExtra??"",h);x!==null&&x!==(k.fmExtra??"")&&d().setFmExtra(x)}else await(gn(u,h)??K.setPageFrontmatter?.(u,h))},async setPageCoverY(u,b){const h={cover_y:b??void 0},{activePage:y,manifest:k}=d();if(u===y&&k){const x=pn(k.fmExtra??"",h);x!==null&&x!==(k.fmExtra??"")&&d().setFmExtra(x)}else await(gn(u,h)??K.setPageFrontmatter?.(u,h))},async setPageIcon(u,b){const h={icon:b??void 0};p(x=>{const E={...x.icons};return b?E[u]=b:delete E[u],{icons:E}});const{activePage:y,manifest:k}=d();if(u===y&&k){const x=pn(k.fmExtra??"",h);x!==null&&x!==(k.fmExtra??"")&&d().setFmExtra(x)}else await(gn(u,h)??K.setPageFrontmatter?.(u,h))},openWikiLink(u,b,h){const y=u.trim();if(!y)return;const k=b??d().activePage??void 0,x=Bf(y);if(x){window.tangu?.appRefs?.open(x);return}const E=Fc(y);if(E){const j=zn(E.target,d().files,k);j&&window.dispatchEvent(new CustomEvent("amadeus:open-pdf",{detail:{path:j,page:E.loc?.page,q:E.loc?.q,newTab:h?.newTab,split:h?.split}}));return}const L=Dc(y);if(L){const j=zn(L.target,d().files,k);if(j&&L.loc&&!h?.newTab){const H=new CustomEvent("amadeus:media-goto",{detail:{path:j,at:L.loc.at,to:L.loc.to,handled:!1}});if(window.dispatchEvent(H),H.detail.handled)return}if(j){const H=L.loc??void 0;Ve(()=>import("./appStore-BskcSDl6.js").then(U=>U.r8),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url).then(U=>U.openMedia(j,H,{newTab:h?.newTab,split:h?.split}))}return}if(/^https?:\/\//i.test(y)){window.tangu?.openExternal?window.tangu.openExternal(y):window.open(y,"_blank","noopener");return}if(Wc(y)){const j=Wf(y,d().files,k);window.dispatchEvent(new CustomEvent("amadeus:open-drawing",{detail:{path:j??y,newTab:h?.newTab,split:h?.split}}));return}let T=y;const N=y.includes("#")&&!Os(y,d().pages,k)?Kc(y):null;if(N?.subpath){const j=N.subpath,H=N.target?Os(N.target,d().pages,k):k&&Mn(k)?k:null;if(H){H!==k&&!h?.newTab&&d().loadPage(H);const U=Bc(j);Ve(()=>import("./appStore-BskcSDl6.js").then(de=>de.r8),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url).then(async de=>{h?.newTab&&await de.openNote(H,{newTab:!0}),U?await de.revealBlockWhenReady(H,U):j.startsWith("^")||await de.revealHeadingWhenReady(H,j)});return}if(!N.target)return;T=N.target}const F=Os(T,d().pages,k);if(F){h?.newTab?Ve(()=>import("./appStore-BskcSDl6.js").then(j=>j.r8),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url).then(j=>j.openNote(F,{newTab:!0})):d().loadPage(F);return}const z=zn(T,d().files,k);if(z){if(/\.db$/i.test(z))window.dispatchEvent(new CustomEvent("amadeus:open-db",{detail:{path:z,newTab:h?.newTab,split:h?.split}}));else{const j=new CustomEvent("amadeus:open-file",{detail:{path:z,newTab:h?.newTab,split:h?.split,handled:!1}});window.dispatchEvent(j),j.detail.handled||K.openVaultFile?.(z)?.catch(()=>{})}return}const q=sn(T,d().files,k)??sn(`${T}.md`,d().files,k);if(q){window.dispatchEvent(new CustomEvent("amadeus:open-file",{detail:{path:q,newTab:h?.newTab,split:h?.split}}));return}p({pendingWikiCreate:{name:T,sourcePath:k&&Mn(k)?k:null}})},async createWikiPage(u){const b=u.trim().replace(/[\\/]/g,"");if(b)try{await d().flushSave(),await d().birthAndOpen(`${b}.md`)}catch(h){p({error:String(h)})}},async confirmWikiCreate(){const u=d().pendingWikiCreate;if(!u)return;p({pendingWikiCreate:null});const{name:b,sourcePath:h}=u;try{if(/[\\/]/.test(b)){const y=b.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");if(!y)return;await d().flushSave(),await d().birthAndOpen(/\.md$/i.test(y)?y:`${y}.md`);return}if(h){const y=await d().createChildNote(h,b);Ti(y)||await d().loadPage(y);return}await d().createWikiPage(b)}catch(y){p({error:String(y)})}},cancelWikiCreate(){p({pendingWikiCreate:null})},async createChildNote(u,b){await d().flushSave();const h=ft(u),y=b.trim().replace(/[\\/]/g,"").replace(/\.md$/i,"")||Z("amadeus.default.note"),{pages:k,files:x}=d(),E=new Set(k.map(yo)),L=new Set([...k,...x].filter(F=>F.startsWith(`${h}/`)).map(F=>F.split("/").pop().toLowerCase()));let T=y;for(let F=1;E.has(yo(T))||L.has(`${T}.md`.toLowerCase());F++)T=`${y}-${F}`;const N=`${h}/${T}.md`;if(await Oi(N)==="failed")throw new Error(`create failed: ${N}`);return await d().syncFdChildren(u),Ri(N),N},async syncFdChildren(u){await d().refreshStructure();const{pages:b,files:h,activePage:y,manifest:k}=d();if(!b.includes(u))return;const x=Gf(u,b,h),E={children:x.length?x:void 0};if(u===y&&k){const L=pn(k.fmExtra??"",E);L!==null&&L!==(k.fmExtra??"")&&d().setFmExtra(L)}else await(gn(u,E)??K.setPageFrontmatter?.(u,E))},async syncFdParentsOf(u){const b=new Set;for(const h of u){const y=qf(h);y&&b.add(Hf(y))}for(const h of b)await d().syncFdChildren(h)},async refreshStructure(){const u=d().vaultRoot,[b,h,y]=await Promise.all([K.listPages(),K.listFolders(),K.listFiles?.()??[]]);p({pages:b,folders:h,files:y,...d().vaultRoot===u?{filesPendingFor:null}:{}}),$(d().vaultRoot)},async deletePage(u){const b=Mn(u)?ft(u):null,h=!!b&&d().folders.includes(b),y=d().activePage,k=!!y&&(y===u||h&&y.startsWith(`${b}/`));k&&t&&(clearTimeout(t),t=null),await Promise.all([si(),ls()]);const x=K.trashEntry?.bind(K);try{x?await x(u):await K.deletePage(u)}catch(L){if(p({error:String(L)}),!await M(u))return}yt(u),It(u,"file");let E=!1;if(h&&b){try{x?await x(b):await K.deleteFolder(b),E=!0}catch(L){p({error:String(L)}),E=await M(b)}E&&(yt(b,"prefix"),It(b,"prefix"))}if(x&&ya.getState().notify(Z("pagestore.notify.movedToTrash")),await d().refreshStructure(),await d().syncFdParentsOf([u]),k){const L=d().pages.find(T=>T!==u)??null;L?await d().loadPage(L):p({activePage:null,pendingPage:null,manifest:null,blocks:{},status:"idle",activeNotePath:null})}Mt(u,"file",null),E&&b&&Mt(b,"prefix",null)},async movePage(u,b){const h=Mn(u)?ft(u):null,y=!!h&&d().folders.includes(h),k=b.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");if(y){if(k===h||k.startsWith(`${h}/`)){p({error:Z("pagestore.error.moveIntoOwnSubpage")});return}const L=h.split("/").pop(),T=k?`${k}/${L}`:L,{pages:N,folders:F,files:z}=d();if(T!==h&&(F.includes(T)||N.includes(T)||z.includes(T))){p({error:Z("pagestore.error.fdExistsAtDest")});return}}await ut();const x=await ja(u);let E=!0;try{const L=await K.movePage(u,k);if(E=!1,await x(L===u?null:L),L===u)return;if(vt(u,L,"file"),y)try{const T=await K.moveFolder(h,k);vt(h,T,"prefix")}catch(T){p({error:Z("pagestore.error.fdMoveFailed",{err:String(T)})})}await d().refreshStructure(),await d().syncFdParentsOf([u,L])}catch(L){E&&await x(null),p({error:String(L)}),await d().refreshStructure()}},async createFolder(u,b){try{await K.createFolder(u,b)}catch(h){p({error:String(h)});return}await d().refreshStructure()},async renameFolder(u,b){await ut();const h=await ja(u,"prefix");try{const y=await K.renameFolder(u,b);await h(y===u?null:y),vt(u,y,"prefix")}catch(y){await h(null),p({error:String(y)});return}await d().refreshStructure()},async deleteFolder(u){const b=d().activePage,h=!!b&&(b===u||b.startsWith(u+"/"));h&&t&&(clearTimeout(t),t=null),await Promise.all([si(),ls()]);try{K.trashEntry?(await K.trashEntry(u),ya.getState().notify(Z("pagestore.notify.movedToTrash"))):await K.deleteFolder(u)}catch(y){if(p({error:String(y)}),!await M(u))return}if(yt(u,"prefix"),It(u,"prefix"),await d().refreshStructure(),h){const y=d().pages[0]??null;y?await d().loadPage(y):p({activePage:null,pendingPage:null,manifest:null,blocks:{},status:"idle",activeNotePath:null})}Mt(u,"prefix",null)},setBlockContent(u,b){Qf(),I("edit"),p(h=>({blocks:{...h.blocks,[u]:{...h.blocks[u],content:b}}})),S()},insertBlockAfter(u,b,h=""){const y=d().manifest,k=d().activePage;if(!y||!k)return"";const x=Ts(Object.keys(y.blocks),y.nextId),E=pe(y.root);if(u){const N=bt(E,u);N?E.children[N.rowIdx].columns[N.colIdx].children.splice(N.childIdx+1,0,{ref:x}):at(E,x)}else if(b){const N=Ta(E,b);N?N.col.children.push({ref:x}):at(E,x)}else at(E,x);const L={type:"markdown"},T={...d().blocks,[x]:{id:x,type:"markdown",content:h}};return d()._commit({...y,root:E,blocks:{...y.blocks,[x]:L},nextId:hn(y.nextId,x)},T),d().requestFocus(x,h?"end":"start"),x},insertBlocksAfter(u,b){const h=d().manifest;if(!h||!b.length)return;const y=pe(h.root),k=[];let x=Object.keys(h.blocks);for(let N=0;N<b.length;N++){const F=Ts(x,h.nextId);k.push(F),x=[...x,F]}const E=u?bt(y,u):null;if(E)y.children[E.rowIdx].columns[E.colIdx].children.splice(E.childIdx+1,0,...k.map(N=>({ref:N})));else for(const N of k)at(y,N);const L={...h.blocks},T={...d().blocks};k.forEach((N,F)=>{L[N]={type:"markdown"},T[N]={id:N,type:"markdown",content:b[F]}}),d()._commit({...h,root:y,blocks:L,nextId:k.reduce(hn,h.nextId)},T),d().requestFocus(k[k.length-1],"end")},insertEmbed(u){d().insertBlockAfter(null,void 0,`![[${u}]]`)},duplicateBlock(u){const b=d().blocks[u];b&&d().insertBlockAfter(u,void 0,b.content)},async deleteBlock(u){const b=d().manifest,h=d().activePage,y=d().loadNonce;if(!b)return;if(b.blocks[u]&&h)try{const N=await K.blockBacklinks(`${Vc(h)}#${u}`);if(N.length>0&&!window.confirm(Z("pagestore.confirm.deleteEmbeddedBlock",{n:N.length})))return}catch{}if(d().activePage!==h||d().loadNonce!==y)return;const k=d().manifest;if(!k)return;const x=pe(k.root),E=bt(x,u);E&&x.children[E.rowIdx].columns[E.colIdx].children.splice(E.childIdx,1),ot(x);const L={...d().blocks};delete L[u];const T={...k.blocks};delete T[u],d()._commit({...k,root:x,blocks:T,nextId:hn(k.nextId,u)},L)},moveBlock(u,b,h){const y=d().manifest;if(!y)return;const k=pe(y.root),x=Cn(u);if(h&&x.includes(h))return;const E=Ln(k,x);if(!E.length)return;const L=Ta(k,b);if(!L)return;const T=h?(()=>{const N=L.col.children.findIndex(F=>F.ref===h);return N>=0?N:L.col.children.length})():L.col.children.length;L.col.children.splice(T,0,...E),ot(k),d()._commit({...y,root:k})},moveBlockDir(u,b){const h=d().manifest;if(!h)return;const y=pe(h.root),k=bt(y,u);if(!k)return;const x=y.children[k.rowIdx].columns[k.colIdx],E=k.childIdx+(b==="up"?-1:1);if(E<0||E>=x.children.length)return;const L=x.children[k.childIdx];x.children[k.childIdx]=x.children[E],x.children[E]=L,d()._commit({...h,root:y})},splitToColumn(u,b){const h=d().manifest,y=d().activePage;if(!h||!y)return;const k=pe(h.root),x=Oa(k,u);if(x===null)return;const E=k.children[x];if(E.columns.length>=4)return;const L=Ts(Object.keys(h.blocks),h.nextId),T={id:ze(),width:1,children:[{ref:L}]};b==="left"?E.columns.unshift(T):E.columns.push(T);const N=1/E.columns.length;E.columns.forEach(q=>q.width=N);const F={type:"markdown"},z={...d().blocks,[L]:{id:L,type:"markdown",content:""}};d()._commit({...h,root:k,blocks:{...h.blocks,[L]:F},nextId:hn(h.nextId,L)},z),d().requestFocus(L,"start")},pairBlocks(u,b,h){const y=d().manifest,k=Cn(u);if(!y||k.includes(b))return;const x=pe(y.root),E=Ln(x,k);if(!E.length)return;ot(x);const L=Oa(x,b);if(L===null)E.forEach(T=>at(x,T.ref));else{const T=x.children[L];if(T.columns.length>=4)E.forEach(N=>at(x,N.ref));else{const N={id:ze(),width:1,children:E};h==="left"?T.columns.unshift(N):T.columns.push(N);const F=1/T.columns.length;T.columns.forEach(z=>z.width=F)}}ot(x),d()._commit({...y,root:x})},addColumnWithBlock(u,b,h){const y=d().manifest;if(!y)return;const k=pe(y.root),x=Ln(k,Cn(b));if(!x.length)return;const E=k.children.find(L=>L.id===u);if(!E)k.children.push({type:"row",id:Fn(),columns:[{id:ze(),width:1,children:x}]});else{const L={id:ze(),width:1,children:x};h==="left"?E.columns.unshift(L):E.columns.push(L);const T=1/E.columns.length;E.columns.forEach(N=>N.width=T)}ot(k),d()._commit({...y,root:k})},addRowWithBlock(u,b){const h=d().manifest;if(!h)return;const y=pe(h.root),k=new Set(y.children.slice(0,Math.max(0,u+1)).map(T=>T.id)),x=Ln(y,Cn(b));if(!x.length)return;ot(y);const E={type:"row",id:Fn(),columns:[{id:ze(),width:1,children:x}]},L=y.children.filter(T=>k.has(T.id)).length;y.children.splice(L,0,E),d()._commit({...h,root:y})},resizeColumns(u,b,h,y){const k=d().manifest;if(!k)return;const x=pe(k.root),E=x.children.find(z=>z.id===u);if(!E)return;const L=E.columns.find(z=>z.id===b),T=E.columns.find(z=>z.id===h);if(!L||!T)return;const N=L.width+T.width,F=Math.max(.12,Math.min(.88,y));L.width=N*F,T.width=N*(1-F),d()._commit({...k,root:x})},setFmExtra(u){const b=d().manifest;if(!b)return;const h=u.replace(/^\n+|\n+$/g,""),y={...b};h?y.fmExtra=h:delete y.fmExtra,d()._commit(y)},async save(){c&&await c.catch(()=>{});const u=i;u&&await u.catch(()=>{});const{manifest:b,activePage:h,blocks:y}=d();if(!b||!h)return;if(g(h)){l.set(h,{manifest:b,contents:C(y)}),m=!0;return}p({status:"saving"});const k=h;s=k,i=(async()=>{try{const x={};for(const[L,T]of Object.entries(y))x[L]=T.content;const E={...b,updatedAt:new Date().toISOString()};e.sink?await e.sink(k,E,x):await K.savePage(k,E,x),o?.path===k&&(o=null),p(L=>L.activePage===k?{manifest:L.manifest?{...L.manifest,updatedAt:E.updatedAt}:E,status:"ready",error:null,linkGraphVersion:L.linkGraphVersion+1}:{linkGraphVersion:L.linkGraphVersion+1})}catch(x){o={path:k,error:String(x)},p(E=>E.activePage===k?{status:"ready",error:String(x)}:{error:String(x)})}finally{s=null,i=null}})(),await i},async flushSave(u=!1){if(t||u&&o?.path===d().activePage?(t&&clearTimeout(t),t=null,await d().save()):await i?.catch(()=>{}),u&&o?.path===d().activePage)throw new Error(o.error)},async reconcileExternal(u){if(!d().manifest||u!==d().activePage||(a.add(u),r))return;r=!0;let b=()=>{};c=new Promise(h=>{b=h});try{for(;a.size;){const h=a.values().next().value;if(a.delete(h),d().activePage!==h)continue;await sm();const{manifest:y,blocks:k,activePage:x}=d();if(!y||x!==h)continue;const E={};for(const[L,T]of Object.entries(k))E[L]=T.content;try{const L=await K.reconcilePage(h,y,E);if(d().activePage!==h)continue;p(T=>({...$t(L),linkGraphVersion:T.linkGraphVersion+1}))}catch(L){p({error:String(L)})}}}finally{r=!1,c=null,b()}},undo(){const u=_.undo(v());u&&(p({manifest:u.data.manifest,blocks:u.data.blocks}),S())},redo(){const u=_.redo(v());u&&(p({manifest:u.data.manifest,blocks:u.data.blocks}),S())},_commit(u,b){I("struct"),p(b?{manifest:u,blocks:b}:{manifest:u}),S()},async _holdForMove(u,b){const{activePage:h,manifest:y,blocks:k}=d(),x=N=>Va(N,u,b);if(e.sink||!h||!y||y.schemaTooNew||!x(h))return null;const E=h,L=Ra();f.push(x),t&&(clearTimeout(t),t=null,m=!0,l.set(E,{manifest:y,contents:C(k)})),await i?.catch(()=>{});let T=null;try{T=await K.readTextFile(E)}catch{}return async N=>{const F=m;try{if(N){const z=q=>b==="file"?N:N+q.slice(u.length);await A(E,T,z(E),b==="prefix",L);for(const q of[...l.keys()])q!==E&&x(q)&&await A(q,null,z(q),!0,L)}else for(const[z,q]of l)!x(z)||z===d().activePage||f.some(j=>j!==x&&j(z))||await K.savePage(z,q.manifest,q.contents).catch(j=>Pa(z,j))}finally{f.splice(f.indexOf(x),1),f.length||(l.clear(),m=!1)}!N&&F&&d().activePage===E&&!g(E)&&S()}}}})}function Ti(e){const t=typeof CustomEvent=="function"?new CustomEvent("amadeus:navigate-note",{detail:{path:e},cancelable:!0}):null;return!!t&&window.dispatchEvent?.(t)===!1}async function Oi(e){if(await K.readTextFile?.(e)?.catch(()=>null)!=null)return"exists";const n=i=>{const o=(e.split("/").pop()??e).replace(/\.md$/i,"");return typeof window<"u"&&window.dispatchEvent(new CustomEvent("amadeus:toast",{detail:{level:"error",text:Z("pagestore.birth.failed",{name:o,reason:i})}})),"failed"};let s;try{s=await K.writeTextFile(e,"",{create:!0,base:ds("")})}catch(i){return n(i instanceof Error&&i.message?i.message:Z("pagestore.birth.unknown"))}return s&&s.ok===!1?s.current!=null?"exists":n(Z("pagestore.birth.unknown")):(Er("note.create"),bo("note.create",{f:e}),"created")}let ji=null;function Ri(e){ji=e}function Nm(e){return!e||ji!==e?!1:(ji=null,!0)}const se=new Map,Be="main",Nt=ue(()=>({id:Be})),an=()=>Nt.getState().id,Tm=()=>Nt(e=>e.id),He=[];function Lc(e){const t=He.indexOf(e);t>=0&&He.splice(t,1),He.push(e),Nt.getState().id!==e&&Nt.setState({id:e})}const Om=["vaultRoot","vaultSide","pages","folders","files","filesPendingFor","icons"],Cc=e=>({vaultRoot:e.vaultRoot,vaultSide:e.vaultSide,pages:e.pages,folders:e.folders,files:e.files,filesPendingFor:e.filesPendingFor,icons:e.icons});let $i=0;async function ut(e=!1){if(e&&$i)throw new Error("A note is being moved");await Promise.all([...[...se.values()].map(t=>e?t.getState().flushSave(!0):t.getState().flushSave().catch(()=>{})),si(e),ls(e)])}async function ls(e=!1){const[{useDbStore:t},{useDrawStore:n}]=await Promise.all([Ve(()=>import("./dbStore-Bc2lC8ZI.js").then(i=>i.ah),__vite__mapDeps([2,1,3]),import.meta.url),Ve(()=>import("./drawingStore-BD5m2eqn.js").then(i=>i.m),__vite__mapDeps([7,1,3]),import.meta.url)]),s=i=>e?i:i.catch(()=>{});await Promise.all([s(t.getState().flushAll(e)),s(n.getState().flushAll(e))])}async function ja(e,t="file"){$i++;const[n,s]=await Promise.all([Hc(e,t),Promise.all([...se.values()].map(o=>o.getState()._holdForMove(e,t).catch(()=>null)))]);let i=!1;return async o=>{if(!i){i=!0;try{await n(o);for(const a of s)a&&await a(o).catch(()=>{})}finally{$i--}}}}function vt(e,t,n){if(e===t)return;if(yt(e,n,t),!us){const o=Oe.getState().vaultRoot;n==="file"?vm(o,e,t):Sm(o,e,t)}const s=o=>Va(o,e,n),i=o=>n==="file"?t:t+o.slice(e.length);for(const o of se.values()){const a=o.getState(),r={};a.activePage&&s(a.activePage)&&(r.activePage=i(a.activePage)),a.activeNotePath&&s(a.activeNotePath)&&(r.activeNotePath=i(a.activeNotePath)),a.pendingPage&&s(a.pendingPage)&&(r.pendingPage=null,r.status=a.manifest?"ready":"idle"),Object.keys(r).length&&o.setState(r)}Mt(e,n,t)}const zi=new Set;function jm(e){return zi.add(e),()=>zi.delete(e)}function Mt(e,t,n){for(const i of zi)i(e,t,n);const s=Oe.getState().vaultRoot;!us&&s&&K?.broadcastPathGone?.({from:e,kind:t,to:n,root:s})}let us=!1;K?.onPathGone?.(({from:e,kind:t,to:n,root:s})=>{const i=Oe.getState().vaultRoot;if(!(i&&i!==s)){us=!0;try{n?vt(e,n,t):(yt(e,t),It(e,t),Mt(e,t,null))}finally{us=!1}}});async function Rm(e){if(e.length){await ls();for(const t of e)if(!Oe.getState().folders.includes(t)){try{K.trashEntry?await K.trashEntry(t):await K.deletePage(t)}catch{if(!await Oe.getState().refreshStructure().then(()=>{const{pages:i,files:o,folders:a}=Oe.getState();return!i.includes(t)&&!o.includes(t)&&!a.includes(t)},()=>!1))continue}yt(t),It(t,"file"),Mt(t,"file",null)}}}function It(e,t){for(const n of se.values()){const s=n.getState().activeNotePath;s&&(t==="file"?s===e:s===e||s.startsWith(`${e}/`))&&n.setState({activeNotePath:null})}}function Vi(){for(const e of se.values())e.setState({activePage:null,pendingPage:null,manifest:null,blocks:{},status:"idle",error:null,activeNotePath:null})}function Ra(){return(se.get(Be)??se.values().next().value)?.getState().vaultRoot??null}let ni=!1;function $m(e){if(ni)return;ni=!0;const t=Cc(e.getState());for(const n of se.values())n!==e&&n.setState(t);ni=!1}const Vn=new Map;function Te(e,t){let n=se.get(e);if(n)return Vn.delete(e),n;n=Am(t);const s=se.values().next().value;return s&&n.setState(Cc(s.getState())),se.set(e,n),n.subscribe((i,o)=>{Om.some(a=>i[a]!==o[a])&&$m(n)}),n}function zm(e){return se.has(e)}function $a(e){if(e===Be)return;const t=se.get(e);if(!t)return;const n={};Vn.set(e,n),t.getState().flushSave().finally(()=>{Vn.get(e)===n&&(Vn.delete(e),se.get(e)===t&&se.delete(e))});const s=He.indexOf(e);if(s>=0&&He.splice(s,1),an()===e){const i=He[He.length-1]??Be;if(i===Be){const o=Te(Be),{activePage:a,pendingPage:r}=o.getState();a?o.getState().releasePage(a):r&&o.setState({pendingPage:null})}Lc(i)}}const Ac=P.createContext(null);function vo(){const e=P.useContext(Ac),t=Nt(n=>n.id);return e??t}function Vm(e){return e.activePage??e.activeNotePath}function Fm(e){return e.activePage?null:e.activeNotePath}function Dm(){return Te(vo())}const Gt=new Set;let Ut=null;function Nc(e){Ut?.();const t=Te(an());if(Ut=t.subscribe((n,s)=>{for(const i of Gt)i(n,s)}),e)for(const n of Gt)n(t.getState(),e.getState())}Nt.subscribe((e,t)=>{e.id!==t.id&&Nc(Te(t.id))});const Oe=Object.assign(function(t){return qc(Te(vo()),t)},{getState:()=>Te(an()).getState(),setState:e=>{Te(an()).setState(e)},subscribe:e=>(Gt.add(e),Ut||Nc(),()=>{Gt.delete(e),Gt.size||(Ut?.(),Ut=null)})});K?.onExternalChange?.(e=>{for(const t of se.values())t.getState().reconcileExternal(e)});async function Tc(e,t){const n=Oe.getState(),s=ft(e);if(!n.folders.includes(s))return;const i=t.split("/").pop().replace(/\.md$/i,"");await n.renameFolder(s,`${i}.fd`)}const sg=Object.freeze(Object.defineProperty({__proto__:null,MAIN_SCOPE:Be,PageScopeCtx:Ac,activePageScope:an,birthNoteFile:Oi,cascadeFdAfterRename:Tc,claimTitleFocus:Nm,clearScopeNotePaths:It,disposePageScope:$a,disposePageStoreScope:$a,flushAllScopes:ut,hasPageScope:zm,navigateToNote:Ti,noteOf:Vm,onNotePathGone:jm,pageStoreFor:Te,remapScopePaths:vt,requestTitleFocus:Ri,resetAllScopeDocs:Vi,setActivePageScope:Lc,trashVaultFiles:Rm,useActivePageScope:Tm,usePageScope:vo,usePageStore:Oe,useScopedPageStore:Dm,v4PathOf:Fm},Symbol.toStringTag,{value:"Module"}));export{Ll as $,W as A,Wo as B,ku as C,Mu as D,Bh as E,Ko as F,ah as G,xi as H,Tu as I,Or as J,Tr as K,ju as L,Du as M,Yr as N,Ze as O,Hu as P,Za as Q,Et as R,mp as S,jt as T,Zn as U,Uh as V,th as W,Td as X,lh as Y,wr as Z,ih as _,rh as a,Bo as a$,fh as a0,uh as a1,dh as a2,B as a3,ul as a4,Dh as a5,gs as a6,Pu as a7,vu as a8,ki as a9,wu as aA,Zu as aB,Sd as aC,Vh as aD,K as aE,hp as aF,Fh as aG,tn as aH,Hm as aI,Qr as aJ,Vu as aK,oh as aL,kl as aM,$u as aN,oo as aO,Eu as aP,bo as aQ,zn as aR,sn as aS,Mn as aT,ya as aU,ft as aV,ie as aW,Nh as aX,Ch as aY,Lh as aZ,xt as a_,Nr as aa,so as ab,Wh as ac,Fa as ad,Yc as ae,R as af,kh as ag,bs as ah,ao as ai,gu as aj,Ym as ak,et as al,lu as am,hu as an,Ku as ao,Oh as ap,le as aq,yh as ar,Er as as,Xm as at,Zm as au,ut as av,Oo as aw,Ge as ax,kd as ay,pc as az,ep as b,wh as b$,Rh as b0,fd as b1,Ah as b2,Ac as b3,Dm as b4,Gh as b5,Lc as b6,jp as b7,Um as b8,mm as b9,ap as bA,id as bB,ui as bC,dp as bD,Gu as bE,Ju as bF,Od as bG,Qa as bH,hh as bI,eu as bJ,Eh as bK,xh as bL,$h as bM,mh as bN,lp as bO,Sh as bP,Yh as bQ,vd as bR,X as bS,Zc as bT,hs as bU,Qm as bV,io as bW,$r as bX,bh as bY,Xi as bZ,gh as b_,Sc as ba,In as bb,jm as bc,$a as bd,Te as be,qm as bf,jr as bg,Hh as bh,qh as bi,Bf as bj,no as bk,wp as bl,vp as bm,np as bn,ed as bo,Xh as bp,Ti as bq,ac as br,Zh as bs,cp as bt,dm as bu,Op as bv,Es as bw,up as bx,sh as by,rp as bz,fp as c,Cp as c$,zr as c0,eh as c1,Tl as c2,Fi as c3,ph as c4,Q as c5,nh as c6,Wf as c7,_m as c8,Ct as c9,tg as cA,ng as cB,Ph as cC,ch as cD,Ih as cE,eg as cF,Th as cG,jh as cH,mf as cI,hf as cJ,tp as cK,bc as cL,Vp as cM,Fp as cN,zp as cO,Bp as cP,Hp as cQ,_e as cR,um as cS,im as cT,as as cU,om as cV,kp as cW,xp as cX,Sp as cY,Ep as cZ,_p as c_,xa as ca,Kp as cb,Ni as cc,wm as cd,Wp as ce,an as cf,vo as cg,gp as ch,Nm as ci,Tm as cj,Be as ck,Rm as cl,Dp as cm,ym as cn,vt as co,Tc as cp,vc as cq,yp as cr,bp as cs,Fm as ct,gc as cu,Oi as cv,Ie as cw,Vm as cx,Gm as cy,pp as cz,Qh as d,Ap as d0,rm as d1,Lp as d2,Tp as d3,Mp as d4,Np as d5,Ca as d6,gm as d7,Rp as d8,nm as d9,Dl as dA,ks as dB,Id as dC,Kh as dD,df as dE,Ip as dF,Pp as dG,wc as dH,zh as dI,un as dJ,uf as dK,sg as dL,Yp as da,Zp as db,$p as dc,bm as dd,sm as de,Qp as df,Xp as dg,zm as dh,vm as di,La as dj,Ma as dk,Pa as dl,Up as dm,Gp as dn,qp as dp,Jp as dq,wt as dr,or as ds,cn as dt,Bi as du,Mh as dv,Po as dw,Gn as dx,_h as dy,vh as dz,ip as e,Y as f,op as g,sp as h,Jh as i,lo as j,ae as k,je as l,tt as m,aa as n,fe as o,J as p,nd as q,ad as r,vr as s,du as t,Oe as u,Ya as v,he as w,to as x,Tt as y,Jm as z};
|