@p4code/cli 0.8.37 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/{binCli-mInzhqSL.mjs → binCli-k72_SR2Z.mjs} +2556 -2301
- package/dist/client/.vite/manifest.json +2008 -2048
- package/dist/client/assets/{2NI2N5EU-DVsZziQ3.js → 2NI2N5EU-DPAxyySd.js} +2 -2
- package/dist/client/assets/{4UO7MD6I-Cs3yBe-m.js → 4UO7MD6I-C0aflwpw.js} +2 -2
- package/dist/client/assets/{5B3SVYGG-CxW0L1iX.js → 5B3SVYGG-hhn6T1ru.js} +2 -2
- package/dist/client/assets/{5GK6JWQ2-Cb25PEnx.js → 5GK6JWQ2-BQ0OdoZ6.js} +2 -2
- package/dist/client/assets/{5N7A7DKN-udLyT643.js → 5N7A7DKN-BR8rdHwZ.js} +2 -2
- package/dist/client/assets/{5OC2THR4-DqD-reis.js → 5OC2THR4-DVDBlcjJ.js} +2 -2
- package/dist/client/assets/{5S6HY5KT-Cy7mIKKq.js → 5S6HY5KT-CjtOXys8.js} +2 -2
- package/dist/client/assets/{6IMQ5BUJ-Qu9PVsT7.js → 6IMQ5BUJ-Bpy1Geo9.js} +2 -2
- package/dist/client/assets/{6OLKWJ4F-BYzZS9mf.js → 6OLKWJ4F-D2naWV4i.js} +2 -2
- package/dist/client/assets/{74OO7NKP-h3ga2-vb.js → 74OO7NKP-CceNos-7.js} +2 -2
- package/dist/client/assets/{75O6YZUN-ByAK3P56.js → 75O6YZUN-CnXm_L8w.js} +2 -2
- package/dist/client/assets/{77XECAW3-D_lZqaZv.js → 77XECAW3-ECBcD47O.js} +2 -2
- package/dist/client/assets/{ABYRPUBD-BPWfXZyu.js → ABYRPUBD-B4F4wZam.js} +2 -2
- package/dist/client/assets/AlertDialogRoot-D5eL1YFA.js +2 -0
- package/dist/client/assets/{AnimatedHeight-D0-6CAPr.js → AnimatedHeight-BZhIfVtA.js} +2 -2
- package/dist/client/assets/AuthSurfaceShell-DR9yRrzS.js +2 -0
- package/dist/client/assets/{BB2UYUI2-CGgafKC2.js → BB2UYUI2-Cae7rC8c.js} +2 -2
- package/dist/client/assets/{BUM34MOA-Cn4iaSBT.js → BUM34MOA-DBDboDOb.js} +2 -2
- package/dist/client/assets/{CEQABKGZ-CmBEfzh3.js → CEQABKGZ-C6UutqUy.js} +2 -2
- package/dist/client/assets/{CXAC5362-xibpmz3Y.js → CXAC5362-BnZlf1Fg.js} +2 -2
- package/dist/client/assets/{ChatGptUsageButton-DU3PVHJW.js → ChatGptUsageButton-3K5PpaVk.js} +2 -2
- package/dist/client/assets/{ChatMarkdown-D-cNSjFn.js → ChatMarkdown-EK5C8Dje.js} +7 -7
- package/dist/client/assets/{CheckboxIndicator-CZCy38xt.js → CheckboxIndicator-DZ8vBLEv.js} +2 -2
- package/dist/client/assets/{ClippedText-D_rM_XDj.js → ClippedText-Dswe5Mb4.js} +2 -2
- package/dist/client/assets/CodexSetupSection.logic-BepCZ25p.js +2 -0
- package/dist/client/assets/{ComboboxClear-tOmMpuVi.js → ComboboxClear-By718biy.js} +2 -2
- package/dist/client/assets/{ComboboxGroupLabel-CgZZIHwV.js → ComboboxGroupLabel-DjWIIS5_.js} +2 -2
- package/dist/client/assets/{CommandBlock-6rjypfVF.js → CommandBlock-C967hvdK.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-Dxfhec2W.js → ComposerPromptEditor-kPs79YCA.js} +10 -10
- package/dist/client/assets/{CompositeRoot-Bsb8efI6.js → CompositeRoot-BFPe8O0M.js} +2 -2
- package/dist/client/assets/{ConnectionDiagnosisDetails-Q0M5gCCf.js → ConnectionDiagnosisDetails-B5VXf5lv.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-DAuD0jkU.js → ConnectionStatusDot-wmgCjAfF.js} +2 -2
- package/dist/client/assets/{DRLTVNUE-BVseXOzv.js → DRLTVNUE-Du8kYl_L.js} +2 -2
- package/dist/client/assets/{DYY6UVD2-Bz33D3dq.js → DYY6UVD2-DxjEuWNy.js} +2 -2
- package/dist/client/assets/{DevicePanel-CsSQr7vQ.js → DevicePanel-YEBH-Vqd.js} +2 -2
- package/dist/client/assets/DeviceSetup-CAlj40rJ.js +2 -0
- package/dist/client/assets/{DialogTitle-bcvBtKP-.js → DialogTitle-DNp9zThp.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-bhzNqujM.js → DiffCommentAnnotation-BOk2MTlv.js} +2 -2
- package/dist/client/assets/{DiffFileTree-BySeJqhq.js → DiffFileTree-Dg3cvfi5.js} +2 -2
- package/dist/client/assets/{DiffPanel-CCFas4eA.js → DiffPanel-fTHMPAQJ.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-CkkqWbz-.js → DiffWorkerPoolProvider-CqmToECA.js} +3 -3
- package/dist/client/assets/{EmbeddedDesign-iuThcPT3.js → EmbeddedDesign-BXKBSCcw.js} +2 -2
- package/dist/client/assets/{EnvironmentMachineIcon-iUmoTUYt.js → EnvironmentMachineIcon-DBWK6C8T.js} +2 -2
- package/dist/client/assets/{ExpandableText-ByCx68yv.js → ExpandableText-B9cfY7p2.js} +2 -2
- package/dist/client/assets/{FNOVOB4O-DK3iet1g.js → FNOVOB4O-BeMBYVRF.js} +2 -2
- package/dist/client/assets/{FieldControl-DtsEariK.js → FieldControl-BOrs67_f.js} +2 -2
- package/dist/client/assets/{FileDiff-Bu2BSqBV.js → FileDiff-DW1zPAn5.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-8cI8gciT.js → FilePreviewPanel-CTTCKfik.js} +10 -10
- package/dist/client/assets/{FoldedSettingsSection-RYq8GTvV.js → FoldedSettingsSection-ClboCRR4.js} +2 -2
- package/dist/client/assets/{FormContext-CIK8MKa2.js → FormContext-DcLeIpxJ.js} +2 -2
- package/dist/client/assets/{HDGCDEEZ-B_J1N6RY.js → HDGCDEEZ-DtsLNbcM.js} +2 -2
- package/dist/client/assets/{HSJLKHB7-B2SbZQUf.js → HSJLKHB7-Cj1_K-Mg.js} +2 -2
- package/dist/client/assets/{Icons-xsXA_L6w.js → Icons-B1qw9fnR.js} +2 -2
- package/dist/client/assets/Input-DQflEYBs.js +2 -0
- package/dist/client/assets/JZOYTAAL-BrzaFmLe.js +1 -0
- package/dist/client/assets/{K3MD6TGW-VU68yYxr.js → K3MD6TGW-SNOidZ8r.js} +2 -2
- package/dist/client/assets/{K7RP3OMA-zaD_NBVC.js → K7RP3OMA-CpajkG5B.js} +2 -2
- package/dist/client/assets/{KeybindingsSettings.logic-BJe27xmi.js → KeybindingsSettings.logic-BA5WG7V2.js} +2 -2
- package/dist/client/assets/{LHDIQX7Q-DCLqoRGy.js → LHDIQX7Q-CAyO0Nv9.js} +2 -2
- package/dist/client/assets/{LUXOKEGN-CmxZpSzC.js → LUXOKEGN-Dp60gO-M.js} +2 -2
- package/dist/client/assets/{MathTypeset-Hhqwg4PF.js → MathTypeset-DG9QDH3a.js} +2 -2
- package/dist/client/assets/{N3JZAHOW-Cev8Cn9M.js → N3JZAHOW-CPZZhC9o.js} +2 -2
- package/dist/client/assets/{NUIALGQ3-CV92Kt25.js → NUIALGQ3-Bapg3pv1.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-CMqIlSNl.js → NoProjectsHero-DunzHVd0.js} +2 -2
- package/dist/client/assets/{O65XPQGZ-bGyTGMsB.js → O65XPQGZ-BmLVfB2-.js} +2 -2
- package/dist/client/assets/{O7XIQ6OM-DVdEfB1N.js → O7XIQ6OM-BzZlSmaP.js} +2 -2
- package/dist/client/assets/{OFQON5FD-Ca_CNS26.js → OFQON5FD-Ciy1Dfj8.js} +2 -2
- package/dist/client/assets/{P4ConnectAccountPages-Buss2oTL.js → P4ConnectAccountPages-DO-fCpTN.js} +2 -2
- package/dist/client/assets/{P4ConnectSidebarSignIn-D1n4y6Gq.js → P4ConnectSidebarSignIn-7hkM7xr7.js} +2 -2
- package/dist/client/assets/{PJQHF43J-B__IdKwP.js → PJQHF43J-CTTmTIhc.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-EIunk_2Q.js → PanelLayoutControls-clP6N7xc.js} +7 -7
- package/dist/client/assets/{PierreEntryIcon-GQImyog1.js → PierreEntryIcon-wm-IkF2y.js} +2 -2
- package/dist/client/assets/{PopoverHandle-Cj5egwXv.js → PopoverHandle-CqjlXffy.js} +2 -2
- package/dist/client/assets/PreviewPanel-fTwWXayK.js +2 -0
- package/dist/client/assets/{ProjectDefaultsSettings-DX2Kf-tx.js → ProjectDefaultsSettings-DABlQCRQ.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-OMOnEzVu.js → ProjectFavicon-zExdjKgc.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-Q4GkqwDs.js → ProjectIconPickerDialog-D4Br81iW.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-Br5sgd24.js → ProjectMonogram-Ba70a8_s.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-Q584HoOn.js → ProviderAuthTerminal-Gf_5AaPE.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-JNM9nJs_.js → ProviderModelPicker-DrfK42fH.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-CdiKhrJE.js → ProviderSettingsForm-CXVYrIzw.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-Co76Qf6Z.js → PullRequestCodeTab-DaXxo4Bs.js} +3 -3
- package/dist/client/assets/{RHNBAITX-Oryl0UiR.js → RHNBAITX-DKMeuR6R.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-aUjexBVb.js → ReadOnlySourcePreview-DPJWK3HJ.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-Oe5BzG3n.js → RenderErrorBoundary-BI5KBtsb.js} +2 -2
- package/dist/client/assets/{SLD4V6NK-DbsINoTD.js → SLD4V6NK-CR4aIcpx.js} +2 -2
- package/dist/client/assets/ScheduledTasksSettings-CTHyd4UX.js +4 -0
- package/dist/client/assets/{ScopedSwitch-D8-FelRH.js → ScopedSwitch-De6GoQiO.js} +2 -2
- package/dist/client/assets/{ScrollAreaCorner-nnFi-Ecx.js → ScrollAreaCorner-DF4GCx0d.js} +2 -2
- package/dist/client/assets/{SecretInput-CqAhFuNO.js → SecretInput-Dg6ZsU9p.js} +2 -2
- package/dist/client/assets/{SelectScrollUpArrow-BQJrvk31.js → SelectScrollUpArrow-DeRXucOo.js} +2 -2
- package/dist/client/assets/{SettingsPanels-CNgY_ZPe.js → SettingsPanels-D6e2byZQ.js} +8 -8
- package/dist/client/assets/{SettingsPanels.logic-Dr_NyHjE.js → SettingsPanels.logic-BSXSdFru.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-BFxCBOnl.js → SettingsScopeNotice-MbxDDMZ9.js} +2 -2
- package/dist/client/assets/SidebarStageBackdrop-B0F--sat.js +2 -0
- package/dist/client/assets/{T3PCR2KE-2R1FY5zG.js → T3PCR2KE-C0_7R2Oa.js} +2 -2
- package/dist/client/assets/{TKWO2OVW-BjhIZzCe.js → TKWO2OVW-DqJmzuhq.js} +2 -2
- package/dist/client/assets/{TSHNXIZL-B_cvoUct.js → TSHNXIZL-CmCl4WMk.js} +2 -2
- package/dist/client/assets/ThemeEditorPanel-IhSXPcO9.js +5 -0
- package/dist/client/assets/{ThreadTerminalDrawer-DHoyxd6-.js → ThreadTerminalDrawer-DnOstFPr.js} +4 -4
- package/dist/client/assets/TooltipViewport-DJXNIjFt.js +2 -0
- package/dist/client/assets/{UQJE5E4I-2r98lr05.js → UQJE5E4I-U1f_Qxq0.js} +2 -2
- package/dist/client/assets/{USNYFO5S-CvTI5t_o.js → USNYFO5S-BFU1s0-x.js} +2 -2
- package/dist/client/assets/{Virtualizer-BgcEI5KE.js → Virtualizer-CI2uidEs.js} +2 -2
- package/dist/client/assets/{WEVWDWVA-U7ygIdf3.js → WEVWDWVA-DVuH1I8D.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-_zND61qF.js → WorkspaceBreadcrumb-Dr-p0Dtn.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-LYv_7Qc0.js → WorkspacePageContainer-MDWEFwmu.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-B_0ute56.js → WorkspacePageHeader-CNcKDaqG.js} +2 -2
- package/dist/client/assets/{X5RFHQXM-D4S0_b0W.js → X5RFHQXM-DhiPjZ2I.js} +2 -2
- package/dist/client/assets/{X62E3GBT-CrIC4h9P.js → X62E3GBT-BoEmDIYA.js} +2 -2
- package/dist/client/assets/{XBNEOJTC-D2_RQZjM.js → XBNEOJTC-ACchb7zJ.js} +2 -2
- package/dist/client/assets/{YHV2MVVZ-BmAcJLBt.js → YHV2MVVZ-WIW1NclZ.js} +2 -2
- package/dist/client/assets/{YURCZMG2-RCCTu3bv.js → YURCZMG2-D8PyipKA.js} +2 -2
- package/dist/client/assets/{YVG2LODB-Cvp0Ei-1.js → YVG2LODB-BQvBC9bF.js} +2 -2
- package/dist/client/assets/_chat-DDGjgFMR.js +45 -0
- package/dist/client/assets/{_chat.design-DX1VqYkX.js → _chat.design-DjIqnlVZ.js} +2 -2
- package/dist/client/assets/{_chat.index-Dzh3d42S.js → _chat.index-Dku1iZH1.js} +2 -2
- package/dist/client/assets/{_chat.new-BHRvXFPr.js → _chat.new-8-cjg5K7.js} +3 -3
- package/dist/client/assets/_chat.pull-requests-DVfSewSZ.js +2 -0
- package/dist/client/assets/{alert-BN-r9V4f.js → alert-DpVw79VA.js} +2 -2
- package/dist/client/assets/{assetUrls-B6vsSVWR.js → assetUrls-BOJMUK_1.js} +2 -2
- package/dist/client/assets/{assets-CID0y4Uv.js → assets-6zZLBDZw.js} +2 -2
- package/dist/client/assets/{browserHistoryStore-CK4YsfkQ.js → browserHistoryStore-TJXTYA-V.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-BJ30b4-s.js → browserLinkTarget-DRbX4L_9.js} +2 -2
- package/dist/client/assets/{checkbox-BJhN1L_L.js → checkbox-4yBjrqWQ.js} +2 -2
- package/dist/client/assets/{color-picker-D2LwMwlZ.js → color-picker-B6JEgpDa.js} +2 -2
- package/dist/client/assets/{combobox-Cw2-7qyI.js → combobox-CKWbcPIR.js} +2 -2
- package/dist/client/assets/{command-BIELTYJu.js → command-D8XZec1r.js} +2 -2
- package/dist/client/assets/{connect-D4llmZsa.js → connect-Dp9BB7ev.js} +2 -2
- package/dist/client/assets/{connect-agent-BlR0FAbF.js → connect-agent-DkbIqI-8.js} +2 -2
- package/dist/client/assets/{design-Cdl1XCBU.js → design-Dn5DzqF2.js} +2 -2
- package/dist/client/assets/{device-Bc5H3PTz.js → device-dylO5xoO.js} +2 -2
- package/dist/client/assets/{dialog-BRtKKGzk.js → dialog-_vbB7RKH.js} +2 -2
- package/dist/client/assets/{diffRendering-DtBTalAD.js → diffRendering-MXukhqw1.js} +2 -2
- package/dist/client/assets/{dist-oE_MNxpZ.js → dist-ceTe_mn7.js} +3 -3
- package/dist/client/assets/{draft-input-vviXwx5Q.js → draft-input-C-u_3cDw.js} +2 -2
- package/dist/client/assets/{duoViewer-kcp00m8a.js → duoViewer-C0aL6Kyr.js} +2 -2
- package/dist/client/assets/{dynamic-C8_ODyue.js → dynamic-DTzzXo3L.js} +2 -2
- package/dist/client/assets/{embeddedScripts-skldQmE1.js → embeddedScripts-DcWCyBxX.js} +2 -2
- package/dist/client/assets/{empty-rC3eYvxq.js → empty-BlKDGTzb.js} +2 -2
- package/dist/client/assets/{entities-B8Vupv5g.js → entities-eRiwvW2F.js} +2 -2
- package/dist/client/assets/{fileLinks-BoyzENAX.js → fileLinks-CYejoXPq.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-DndrZZAD.js → fileTreeExpansion-wG1G7D6R.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-C1QBFdFu.js → getDiffFileInput-CzeweGHs.js} +2 -2
- package/dist/client/assets/{guideRunStore-BgFFILxA.js → guideRunStore-DAYN2Zd7.js} +2 -2
- package/dist/client/assets/{htmlRender-ddkOIEbT.js → htmlRender-C3rZ0xgC.js} +2 -2
- package/dist/client/assets/{index-BwdieRvq.js → index-DA9og9YW.js} +3 -3
- package/dist/client/assets/{input-BYd74ook.js → input-DXGWoa4O.js} +2 -2
- package/dist/client/assets/{input-group-DMFlSk_7.js → input-group-De0xZXfc.js} +2 -2
- package/dist/client/assets/{kbd-rp5mX21h.js → kbd-WWNLIkTn.js} +2 -2
- package/dist/client/assets/{keybindings-B_kRk5Fi.js → keybindings-DAHl8jIl.js} +2 -2
- package/dist/client/assets/{lazy-CeaQ3-Fj.js → lazy-Ccs3klKO.js} +4 -4
- package/dist/client/assets/{lazyRouteComponent-COYyJY2H.js → lazyRouteComponent-BU0ER5FO.js} +2 -2
- package/dist/client/assets/{link-CsXnX9WM.js → link-C3TbL1do.js} +2 -2
- package/dist/client/assets/{linkedPrompt-B5iI7U8H.js → linkedPrompt-BJh0Yqud.js} +2 -2
- package/dist/client/assets/main-DjrB0l0D.css +2 -0
- package/dist/client/assets/main-DleJeMZO.js +37 -0
- package/dist/client/assets/{mediaReference-ZW7gfO5X.js → mediaReference-BbSbhpkR.js} +2 -2
- package/dist/client/assets/{mediaSource-DsT6G6Wm.js → mediaSource-B_75uvyp.js} +2 -2
- package/dist/client/assets/{number-field-CEA6qXbs.js → number-field-qEfih146.js} +2 -2
- package/dist/client/assets/{observeResize-DSyLC8QK.js → observeResize-DzSkewug.js} +2 -2
- package/dist/client/assets/{onboarding-BPkAEHBV.js → onboarding-1Zg3fM0A.js} +2 -2
- package/dist/client/assets/{openFileInPreview-CGM83ICx.js → openFileInPreview-CiPuDrfB.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-CwpteA7b.js → p4ProjectFile-BVKW5TIA.js} +2 -2
- package/dist/client/assets/{pair-D9v8gc0o.js → pair-DUv1mY4i.js} +2 -2
- package/dist/client/assets/{pendingSendStore-BuEVrrEM.js → pendingSendStore-BFVsboDn.js} +2 -2
- package/dist/client/assets/{phoneViewer-CNE0SVmy.js → phoneViewer-CStYy_tX.js} +2 -2
- package/dist/client/assets/{pierre-icons-ChDlOt-h.js → pierre-icons-D3vWvKqU.js} +2 -2
- package/dist/client/assets/{popover-BjUpdrKu.js → popover-CogH2zM4.js} +2 -2
- package/dist/client/assets/{preview-DHLYKEKb.js → preview-O1ZL8Awg.js} +2 -2
- package/dist/client/assets/{preview-3EscFepc.js → preview-ipLyyv_l.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-DHjQeV1U.js → previewMiniPlayerStore-C5z1mN8S.js} +2 -2
- package/dist/client/assets/{primary-NcsmRI6j.js → primary-CMBPxKMH.js} +2 -2
- package/dist/client/assets/{primaryCloudLinkState-DkXIVBHW.js → primaryCloudLinkState-CER468V5.js} +2 -2
- package/dist/client/assets/{projectFilesQueryState-0jxJ50Qq.js → projectFilesQueryState-D4FdR3Xm.js} +2 -2
- package/dist/client/assets/{projectScriptEditor-CMGXoIEJ.js → projectScriptEditor-4wQTbXvz.js} +2 -2
- package/dist/client/assets/{providerSkills-4hnESoi_.js → providerSkills-D3rxPB_g.js} +2 -2
- package/dist/client/assets/{pullRequestDetail.logic-sbOM8yDW.js → pullRequestDetail.logic-Bkh57WzV.js} +2 -2
- package/dist/client/assets/{pullRequestIcons-B7Om_B_D.js → pullRequestIcons-DPbMXqGp.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-CIL8WfOG.js → pullRequestReviewStore-BAxwf6rl.js} +2 -2
- package/dist/client/assets/{pullRequests-CMTRCOu7.js → pullRequests-DggtcbhA.js} +2 -2
- package/dist/client/assets/{queries-hhl_J8u9.js → queries-DJfKGsHe.js} +2 -2
- package/dist/client/assets/{query-CfGzD8v6.js → query-B3Zo1YOE.js} +2 -2
- package/dist/client/assets/{radio-group-up2QNXjf.js → radio-group-l1Zl-3hQ.js} +2 -2
- package/dist/client/assets/{renderScheduler-Dgqqs-EX.js → renderScheduler-BgGYA97h.js} +2 -2
- package/dist/client/assets/{rightPanelStore-CGF0-d-1.js → rightPanelStore-Cv1U3yrU.js} +2 -2
- package/dist/client/assets/{runtime-Ca_Z-vg5.js → runtime-BOlBBevr.js} +3 -3
- package/dist/client/assets/{runtime-OeWFs5Hf.js → runtime-CeFhsGnm.js} +3 -3
- package/dist/client/assets/{runtimeModeConfig-BTG9FTYe.js → runtimeModeConfig-BQ0QCQhj.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-BeuOnCov.js → scheduledTasksSettings.logic-BpOBCcOk.js} +2 -2
- package/dist/client/assets/{scroll-area-BNQKEZbp.js → scroll-area-CQNIjQ8U.js} +2 -2
- package/dist/client/assets/{select-D_zHR42Y.js → select-Cbpdz6n3.js} +2 -2
- package/dist/client/assets/{selfImproveFindings-CAZ0j1GD.js → selfImproveFindings-CT79AgdK.js} +2 -2
- package/dist/client/assets/{server-6nKYyc8r.js → server-DvWrfyUO.js} +2 -2
- package/dist/client/assets/{session-BxUdP61p.js → session-D3gY-tOR.js} +2 -2
- package/dist/client/assets/{session-logic-Dr1plzXe.js → session-logic-OeNFZd_V.js} +3 -3
- package/dist/client/assets/{settings-DE_hSu0q.js → settings-C6gUwixG.js} +2 -2
- package/dist/client/assets/{settings.appearance-C--uy4It.js → settings.appearance-BdGq8dkT.js} +2 -2
- package/dist/client/assets/settings.archived-DobN7ZtC.js +2 -0
- package/dist/client/assets/{settings.computer-use-DhnqPqMm.js → settings.computer-use-DTAvnNqQ.js} +2 -2
- package/dist/client/assets/settings.connections-CZD-0BNX.js +2 -0
- package/dist/client/assets/settings.data-controls-CTVHY8Rd.js +2 -0
- package/dist/client/assets/{settings.decisions-CU-6rIpn.js → settings.decisions-D3zMITNw.js} +2 -2
- package/dist/client/assets/{settings.designs-DHYhhG4k.js → settings.designs-DWeI1d2s.js} +2 -2
- package/dist/client/assets/{settings.diagnostics-csgW1_E8.js → settings.diagnostics-CqC6fhz6.js} +2 -2
- package/dist/client/assets/{settings.general-CeBkrL9-.js → settings.general-BDEcQVI4.js} +2 -2
- package/dist/client/assets/{settings.integrations-DqSYBosl.js → settings.integrations-BmqNoylk.js} +2 -2
- package/dist/client/assets/{settings.keybindings-C7D1i238.js → settings.keybindings-Mt7J5TKC.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-6oFDgAt7.js → settings.open-source-licenses-Dvex7Jce.js} +2 -2
- package/dist/client/assets/{settings.plugins-DfM65Xio.js → settings.plugins-BAFed2wY.js} +4 -4
- package/dist/client/assets/settings.projects-DhuXD_vx.js +4 -0
- package/dist/client/assets/settings.providers-D_-kNRqH.js +3 -0
- package/dist/client/assets/{settings.scheduled-tasks-Csi8wfij.js → settings.scheduled-tasks-Z4aprmEO.js} +2 -2
- package/dist/client/assets/settings.snap-shot-o0bdbS5t.js +2 -0
- package/dist/client/assets/settings.source-control-CwJzBnSu.js +2 -0
- package/dist/client/assets/{settings.storage-DTcg-0aj.js → settings.storage-B4ahmlhx.js} +2 -2
- package/dist/client/assets/{settingsLayout-4ySvFdXb.js → settingsLayout-DrhqvTJ8.js} +3 -3
- package/dist/client/assets/{sidebar-CHDwV4Ca.js → sidebar-BhJqncti.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-BcOVY8p-.js → sidebarProjectGrouping-DDt6qTcu.js} +2 -2
- package/dist/client/assets/{skeleton-BcLPbojY.js → skeleton-CFtayHTe.js} +2 -2
- package/dist/client/assets/{sourceControl-CPrl7cyO.js → sourceControl-Dqo9EYNC.js} +2 -2
- package/dist/client/assets/{sourceControlClients-oNOd36Cq.js → sourceControlClients-DGnHi6Rd.js} +2 -2
- package/dist/client/assets/{spinner-_ourbdVb.js → spinner-BZh9P0sD.js} +2 -2
- package/dist/client/assets/{terminal-links-DuZi4b83.js → terminal-links-CFKe0iu0.js} +2 -2
- package/dist/client/assets/{terminalSessions-D0vbdqqx.js → terminalSessions-BykgTNwT.js} +2 -2
- package/dist/client/assets/{textarea-DlXXDHPJ.js → textarea-hXQFbdrS.js} +2 -2
- package/dist/client/assets/themePalette-MbAn2gqj.js +5 -0
- package/dist/client/assets/{toast-DXWclCrr.js → toast-C61oyZY1.js} +2 -2
- package/dist/client/assets/{toggle-Dofc34s2.js → toggle-B03MQDgB.js} +2 -2
- package/dist/client/assets/{toggle-group-CYKsfBbD.js → toggle-group-yF5GZ53o.js} +2 -2
- package/dist/client/assets/{tooltip-CY3W5y-f.js → tooltip-ChmjT8Ns.js} +2 -2
- package/dist/client/assets/uiStateStore-DL8OsPjd.js +2 -0
- package/dist/client/assets/{usage-DQcgd75_.js → usage-DATBL2Du.js} +2 -2
- package/dist/client/assets/{usageAccess-CCSxXl9X.js → usageAccess-kgUHYKOw.js} +2 -2
- package/dist/client/assets/{usageFormat-ByjmRjTe.js → usageFormat-D5Mz5ugL.js} +2 -2
- package/dist/client/assets/{usageShortcuts-DOWm0Vo9.js → usageShortcuts-mAekk3eG.js} +2 -2
- package/dist/client/assets/{use-atom-command-vqjL7n-x.js → use-atom-command-Bt7x9oO0.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-B7FNFpmO.js → useAriaLabelledBy-DjNn9irU.js} +2 -2
- package/dist/client/assets/useHandleNewThread-BOKOo2wA.js +2 -0
- package/dist/client/assets/{useLocation-B_XV0lDx.js → useLocation-Cwv1HZ3K.js} +2 -2
- package/dist/client/assets/{useNavigate-BWqAWfiZ.js → useNavigate-Cdrlv-yJ.js} +2 -2
- package/dist/client/assets/{useNavigateBack-C52nbvbb.js → useNavigateBack-CwjQ4iuL.js} +2 -2
- package/dist/client/assets/{useP4ConnectAuthPrompt-DKhdNYj8.js → useP4ConnectAuthPrompt-D63n-MFC.js} +2 -2
- package/dist/client/assets/{useParams-ekGanxxb.js → useParams-C5D_t-0u.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-CWV_yoZe.js → usePermissionStatus-CKmeNk61.js} +2 -2
- package/dist/client/assets/{usePullRequestActions-DxtkLQ5D.js → usePullRequestActions-D53oZord.js} +2 -2
- package/dist/client/assets/{useRegisterFieldControl-BAJIcFiO.js → useRegisterFieldControl-DUs9w2Me.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-815e0x20.js → useScopedModelAvailability-CeAUx0qZ.js} +2 -2
- package/dist/client/assets/useSettings-VTow9ZEM.js +3 -0
- package/dist/client/assets/utils-CBe1bHL7.js +37 -0
- package/dist/client/assets/{vcsRefInvalidation-CW_MIqdt.js → vcsRefInvalidation-B2f3qDSR.js} +2 -2
- package/dist/client/assets/{welcome-k7S47hyM.js → welcome-CQgOocvj.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/{renderer-Ay-1ojn7.mjs → renderer-BBWgEvuE.mjs} +2 -2
- package/dist/{runtime-bP6MSuMS.mjs → runtime-DNjlpJkJ.mjs} +286 -242
- package/package.json +1 -1
- package/dist/client/assets/AlertDialogRoot-BSP6M0Mu.js +0 -2
- package/dist/client/assets/AuthSurfaceShell-30QvY1bI.js +0 -2
- package/dist/client/assets/CodexSetupSection.logic-g6_GE4bw.js +0 -2
- package/dist/client/assets/DeviceSetup-Cl7L9wsi.js +0 -2
- package/dist/client/assets/Input-D3Qi4jCN.js +0 -2
- package/dist/client/assets/JZOYTAAL-BlxFvoz4.js +0 -1
- package/dist/client/assets/PreviewPanel-BkFeksTl.js +0 -2
- package/dist/client/assets/ScheduledTasksSettings-1uXNtcPA.js +0 -4
- package/dist/client/assets/ThemeEditorPanel-B7MiqZ90.js +0 -5
- package/dist/client/assets/TooltipViewport-ThbbZQDo.js +0 -2
- package/dist/client/assets/_chat-CwO3_WVM.js +0 -45
- package/dist/client/assets/_chat.pull-requests-BZilN1TK.js +0 -2
- package/dist/client/assets/composer-logic-P-jVPXi4.js +0 -6
- package/dist/client/assets/composerDraftUploads-S66xDlS0.js +0 -2
- package/dist/client/assets/main-DdVSHl80.css +0 -2
- package/dist/client/assets/main-VfCRP294.js +0 -29
- package/dist/client/assets/settings.archived-D-55XnxQ.js +0 -2
- package/dist/client/assets/settings.connections-BPVLazeK.js +0 -2
- package/dist/client/assets/settings.data-controls-CIzGvqCI.js +0 -2
- package/dist/client/assets/settings.projects-CeoZzdMW.js +0 -4
- package/dist/client/assets/settings.providers-BBgppyE3.js +0 -3
- package/dist/client/assets/settings.snap-shot-BdVdSIJy.js +0 -2
- package/dist/client/assets/settings.source-control-Bme3qg7j.js +0 -2
- package/dist/client/assets/themePalette-VIM7Gehx.js +0 -5
- package/dist/client/assets/uiStateStore-CdkBStdp.js +0 -6
- package/dist/client/assets/useHandleNewThread-BYNZXzR_.js +0 -2
- package/dist/client/assets/useSettings-gPlpTIWi.js +0 -3
- package/dist/client/assets/utils-DhUt689t.js +0 -37
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as e,t}from"./react-DH3P2YXY.js";import{n,t as r}from"./jsx-runtime-BnjsACtP.js";import{$n as i,D as a,Ef as o,Lf as s,Md as c,Ms as l,Qw as u,Uy as d,W_ as f,Y_ as p,Yn as m,Zn as h,Zo as g,ar as _,dr as v,eh as y,j as b,js as x,ks as S,mn as C,nr as w,od as T,rr as E,t as ee,tr as D,ur as O}from"./utils-
|
|
1
|
+
import{a as e,t}from"./react-DH3P2YXY.js";import{n,t as r}from"./jsx-runtime-BnjsACtP.js";import{$n as i,D as a,Ef as o,Lf as s,Md as c,Ms as l,Qw as u,Uy as d,W_ as f,Y_ as p,Yn as m,Zn as h,Zo as g,ar as _,dr as v,eh as y,j as b,js as x,ks as S,mn as C,nr as w,od as T,rr as E,t as ee,tr as D,ur as O}from"./utils-CBe1bHL7.js";import{L as k,R as te,W as ne}from"./runtime-CeFhsGnm.js";import{s as re}from"./vcsRefInvalidation-B2f3qDSR.js";import{G as ie}from"./entities-eRiwvW2F.js";import{Fn as A,On as j,d as ae,f as oe,u as se,wn as M}from"./runtime-BOlBBevr.js";import{U as ce,b as le,g as ue,h as de,l as fe,w as pe}from"./TooltipViewport-DJXNIjFt.js";import{J as N,Y as P,n as me,tt as he}from"./ChatMarkdown-EK5C8Dje.js";import{t as ge}from"./spinner-BZh9P0sD.js";import{i as _e,m as ve}from"./toast-C61oyZY1.js";import{D as ye,G as be,S as xe,_ as Se,q as F,s as Ce}from"./useSettings-VTow9ZEM.js";import{i as we,n as Te}from"./session-D3gY-tOR.js";import{t as Ee}from"./use-atom-command-Bt7x9oO0.js";import{a as De}from"./fileLinks-CYejoXPq.js";import{u as Oe}from"./providerSkills-D3rxPB_g.js";import{t as ke}from"./toastHelpers-DxXYm50b.js";import{o as Ae}from"./queries-DJfKGsHe.js";import{H as I,V as je,l as Me,ot as L,st as Ne}from"./diffRendering-MXukhqw1.js";import{A as Pe,B as Fe,G as R,K as z,T as Ie,a as Le,j as B,l as Re,t as ze}from"./Virtualizer-CI2uidEs.js";import{B as V,G as Be,H as Ve,J as He,K as Ue,Q as We,U as Ge,V as Ke,W as qe,q as Je}from"./getDiffFileInput-CzeweGHs.js";import{c as Ye,i as Xe,n as Ze,o as Qe,s as $e,t as et}from"./DiffWorkerPoolProvider-CqmToECA.js";import{n as tt}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{S as nt,_ as rt,b as H,c as it,d as at,f as ot,g as st,h as U,i as ct,l as lt,m as W,o as ut,p as dt,r as ft,s as G,t as pt,u as K,v as mt,x as ht,y as gt}from"./DiffCommentAnnotation-BOk2MTlv.js";import{t as _t}from"./mediaReference-BbSbhpkR.js";import{a as vt,n as yt,t as bt}from"./tooltip-ChmjT8Ns.js";import{i as xt,n as St,r as Ct,t as wt}from"./fileCommentAnnotations-BgdL_7u9.js";import{r as Tt,t as Et}from"./ReadOnlySourcePreview-DPJWK3HJ.js";import{a as Dt,c as Ot,i as kt,n as At,o as jt,r as Mt,s as Nt,t as Pt}from"./fileTreeExpansion-wG1G7D6R.js";import{t as Ft}from"./pierre-icons-D3vWvKqU.js";import{t as It}from"./scroll-area-CQNIjQ8U.js";import{A as Lt,C as Rt,E as zt,O as Bt,S as Vt,T as Ht,_ as Ut,b as Wt,j as Gt,w as Kt,x as qt,y as Jt}from"./ComposerPromptEditor-kPs79YCA.js";import{t as Yt}from"./assets-6zZLBDZw.js";import{i as Xt,n as Zt,t as Qt}from"./assetUrls-BOJMUK_1.js";import{w as $t}from"./browserHistoryStore-TJXTYA-V.js";import{i as en,r as tn}from"./openFileInPreview-CiPuDrfB.js";import{t as nn}from"./preview-ipLyyv_l.js";import{t as rn}from"./PierreEntryIcon-wm-IkF2y.js";import{n as an}from"./composerTrigger-BGi0iyhl.js";import{r as on,t as sn}from"./input-group-De0xZXfc.js";import{f as cn,i as ln,l as un,n as dn,o as fn,t as pn,u as mn}from"./projectFilesQueryState-D4FdR3Xm.js";import{fo as hn,go as gn,xo as _n}from"./main-DleJeMZO.js";import{D as vn,h as yn,m as bn,p as xn}from"./_chat-DDGjgFMR.js";var Sn={compositeOverBg:V,contrastRatio:Ke,deriveMutedFg:Ve,hoverWouldEraseText:Ge,isDarkSurface:qe,isFullyTransparent:Be,pickReadableForeground:Ue,relativeLuminance:Je,surfacesMatch:He},q=e(t(),1);function Cn(e,t){return e.isOpen===t.isOpen&&e.value===t.value&&Dt(e.matchingPaths,t.matchingPaths)}function wn(e){let t=jt(e,e=>({isOpen:e.isSearchOpen(),matchingPaths:e.getSearchMatchingPaths(),value:e.getSearchValue()}),Cn);return(0,q.useMemo)(()=>({...t,close:()=>{e.closeSearch()},focusNextMatch:()=>{e.focusNextSearchMatch()},focusPreviousMatch:()=>{e.focusPreviousSearchMatch()},open:t=>{e.openSearch(t)},setValue:t=>{e.setSearch(t)}}),[e,t])}var Tn=100,En=`insert`,Dn=`backspace`,On=`delete`,kn=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??Tn)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(jn),redoStack:this.#t.map(jn),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function An(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(Mn),selectionsAfter:e.selectionsAfter?.map(Mn),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function jn(e){return{...An(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function Mn(e){return{...e,start:{...e.start},end:{...e.end}}}function Nn(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?Dn:n?On:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function Pn(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=Ln(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
|
|
2
2
|
`)&&!a.text.includes(`
|
|
3
3
|
`),u=o.start===o.end&&o.text.length>0&&!o.text.includes(`
|
|
4
4
|
`)&&s.text.length===0;if(l&&u){if(o.start!==a.end||(n??=En,n!==En||e.coalescingMode!==void 0&&e.coalescingMode!==En||t.coalescingMode!==void 0&&t.coalescingMode!==En))return!1;continue}let d=i.text.length===0&&i.end>i.start&&a.text.length>0,f=o.text.length===0&&o.end>o.start&&s.text.length>0;if(d&&f){let r;if(c===i.end)r=On;else if(c+(o.end-o.start)!==i.start)return!1;else r=Dn;if(n??=r,n!==r||e.coalescingMode!==void 0&&e.coalescingMode!==r||t.coalescingMode!==void 0&&t.coalescingMode!==r)return!1;continue}return!1}return n!==void 0}function Fn(e,t){let n=[],r=[],i;for(let a=0;a<e.forwardEdits.length;a++){let o=e.forwardEdits[a],s=e.inverseEdits[a],c=t.forwardEdits[a],l=t.inverseEdits[a],u=Ln(c.start,e.forwardEdits);if(o.text.length>0){i??=En,n.push({start:o.start,end:o.end,text:o.text+c.text}),r.push(s.text);continue}if(u===o.end){i??=On,n.push({start:o.start,end:u+(c.end-c.start),text:``}),r.push(s.text+l.text);continue}i??=Dn,n.push({start:Math.min(o.start,u),end:o.end,text:``}),r.push(l.text+s.text)}return{forwardEdits:n,inverseEdits:In(n,r),versionBefore:e.versionBefore,versionAfter:t.versionAfter,selectionsBefore:e.selectionsBefore?.slice(),selectionsAfter:t.selectionsAfter?.slice(),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:t.lineAnnotationsAfter?.slice(),coalescingMode:i}}function In(e,t){let n=[];for(let r=0,i=0;r<e.length;r++){let a=e[r],o=a.start+i;n.push({start:o,end:o+a.text.length,text:t[r]}),i+=a.text.length-(a.end-a.start)}return n}function Ln(e,t){let n=e;for(let e of t){let t=e.end-e.start,r=e.text.length,i=r-t;if(!(n<e.start)){if(n>=e.start+r){n-=i;continue}n=e.start+Math.min(n-e.start,t)}}return n}var Rn=new WeakMap;function zn(e){return Rn.get(e)}function Bn(e,t){Rn.set(e,t)}var Vn=class e{#e;#t;#n;#r;#i;#a;constructor(e,t,n=`text`,r=0,i=new kn,a){if(this.#e=new URL(e,`file://`).toString(),this.#t=n,this.#n=r,this.#r=new mt(t),this.#i=i,a!=null)this.#a=a;else{let e=this.#r.getLineText(0,!0);this.#a=e.endsWith(`\r
|
|
5
5
|
`)?`\r
|
|
6
6
|
`:e.endsWith(`\r`)?`\r`:`
|
|
7
|
-
`}}get uri(){return this.#e}get languageId(){return this.#t}get version(){return this.#n}get lineCount(){return this.#r.lineCount}get eol(){return this.#a}get history(){return this.#i.getLiveState()}get canUndo(){return this.#i.canUndo}get canRedo(){return this.#i.canRedo}clearHistory(){this.#i.clear()}positionAt(e){return this.normalizePosition(this.#r.positionAt(e))}positionsAt(e){let t=this.#r.positionsAt(e);for(let e=0;e<t.length;e++)t[e]=this.normalizePosition(t[e]);return t}offsetAt(e){return this.#r.offsetAt(this.normalizePosition(e))}getText(e){return e===void 0?this.#r.getText():this.#r.getText({start:this.normalizePosition(e.start),end:this.normalizePosition(e.end)})}getLineText(e,t){return this.#r.getLineText(e,t)}normalizeEol(e){return e.replace(/\r\n|\r|\n/g,this.eol)}getLineLength(e,t){return this.#r.getLineLength(e,t)}charAt(e){return typeof e==`number`?this.#r.charAt(e):this.#r.charAt(this.offsetAt(e))}getTextSlice(e,t){return this.#r.getTextSlice(e,t)}findNextNonOverlappingSubstring(e,t){return this.#r.findNextNonOverlappingSubstring(e,t)}search(e){return this.#r.search(e)}applyEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(this.resolveEdits(e)),t,n,r,i)}resolveEdits(e){return e.map(e=>this.#c(e))}applyResolvedEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(e.map(e=>this.#l(e))),t,n,r,i)}#o(e,t,n,r,i){let a=Nn(this,e,this.#n,this.#n+1,t?n:void 0,t?r:void 0);t&&i&&(a.undoBoundary=!0);let o=this.#i.peekUndoForCoalescing(),s=this.#f(e);return this.#n++,s.lineDelta===0&&Pn(o,a)?this.#i.replaceLastUndo(Fn(o,a)):this.#i.push(a),Bn(s,{appliedEdits:a.forwardEdits,inverseEdits:a.inverseEdits}),s}setLastUndoSelectionsAfter(e){this.#i.setLastUndoSelectionsAfter(e)}setLastUndoLineAnnotations(e,t){this.#i.setLastUndoLineAnnotations(e,t)}undo(){let e=this.#i.popUndoToRedo();if(e===void 0)return;let t=this.#f(e.inverseEdits);if(t===void 0)return;Bn(t,{appliedEdits:e.inverseEdits,inverseEdits:e.forwardEdits}),this.#n=e.versionBefore;let n=e.selectionsBefore?.slice();return[t,n,e.lineAnnotationsBefore?.slice(),n===void 0?e.inverseEdits.map(e=>({...e})):void 0]}redo(){let e=this.#i.popRedoToUndo();if(e===void 0)return;let t=this.#f(e.forwardEdits);if(t===void 0)return;Bn(t,{appliedEdits:e.forwardEdits,inverseEdits:e.inverseEdits}),this.#n=e.versionAfter;let n=e.selectionsAfter?.slice();return[t,n,e.lineAnnotationsAfter?.slice(),n===void 0?e.forwardEdits.map(e=>({...e})):void 0]}normalizePosition(t){let n=e.#s(t.line,this.lineCount-1);return{line:n,character:e.#s(t.character,this.getLineLength(n))}}static#s(e,t){return Number.isNaN(e)?0:Math.max(0,Math.min(Math.floor(e),t))}#c(e){let t=this.offsetAt(e.range.start),n=this.offsetAt(e.range.end);if(t>n){let e=t;t=n,n=e}return this.#l({start:t,end:n,text:e.newText})}#l(e){let{start:t,end:n}=e,r=t===n;return this.#u(t)&&t--,r?n=t:this.#u(n)&&n++,{start:t,end:n,text:e.text}}#u(e){let t=this.#r.charAt(e-1).charCodeAt(0),n=this.#r.charAt(e).charCodeAt(0);return t>=55296&&t<=56319&&n>=56320&&n<=57343}#d(e){let t=[...e].sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<t.length-1;e++)if(t[e].end>t[e+1].start)throw Error(`Overlapping text edits are not supported`);return t}#f(e){let t=this.#r.lineCount,n=this.positionsAt(e.flatMap(e=>[e.start,e.end])),r=this.#p(e,n),i=n[0],a=n[n.length-1],o=a.line===t-1&&a.character===this.#r.getLineLength(a.line);this.#r.applyEdits(e);let s=this.#r.lineCount;return{changes:e.map((e,t)=>({...e,range:{start:n[t*2],end:n[t*2+1]}})),startLine:r.startLine,startCharacter:i.character,endCharacter:a.character,endLine:Math.min(r.endLine,Math.max(0,s-1)),endedAtDocumentEnd:o,previousLineCount:t,lineCount:s,lineDelta:s-t,changedLineRanges:r.ranges,changedLineChanges:r.changes}}#p(e,t){let n=1/0,r=0,i=0,a=[],o=[],s=this.#r.lineCount-1,c=this.#r.getLineLength(s);for(let l=0;l<e.length;l++){let u=e[l],d=t[l*2],f=t[l*2+1],p=d.line,m=f.line,h=Qe(u.text),g=p+i,_=g+h,v=h-(m-p);n=Math.min(n,p),r=Math.max(r,_);let y=a[a.length-1];y!==void 0&&g<=y[1]+1?a[a.length-1]=[y[0],Math.max(y[1],_)]:a.push([g,_]),o.push([g,_,v,d.character,f.character,m===s&&f.character===c]),i+=v}return n===1/0?{startLine:0,endLine:0,ranges:[[0,0]],changes:[[0,0,0,0,0,!1]]}:{startLine:n,endLine:r,ranges:a,changes:o}}},Hn=e(Xe(),1),Un=100,Wn=class{type;#e=new Hn.default.LRUMap(Un);#t=new Map;constructor(e){this.type=e}activate(e,t,n){let r=this.#t.get(e);if(r!=null&&r.owner!==t)throw Error(`Editor: editStateKey "${e}" is already attached to another editor`);if(r!=null)return n!=null&&(r.session=n),r.session;let i=this.#e.delete(e),a={type:this.type},o=n??i??a;return this.#t.set(e,{owner:t,session:o}),o}release(e,t,n=!1){let r=this.#t.get(e);if(r?.owner!==t||(this.#t.delete(e),n))return;let i=qn(r.session);i!=null&&this.#e.set(e,i)}get(e){let t=this.#t.get(e);return t==null?this.#e.find(e):qn(t.session)??void 0}clear(e,t){if(this.#t.has(e))return!1;let n=this.#e.find(e);return n!=null&&(t==null||t.document===!0?this.#e.delete(e):Jn(n,t),!0)}clearAll(){this.#e.clear()}setCapacity(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`EditStateManager: capacity must be a positive integer`);for(;this.#e.size>e;)this.#e.shift();this.#e.limit=e}},Gn=class{#e=new Wn(`file`);#t=new Wn(`file-diff`);activate(e,t,n,r){return e===`file`?this.#e.activate(t,n,r):this.#t.activate(t,n,r)}releaseFile(e,t,n=!1){this.#e.release(e,t,n)}releaseFileDiff(e,t,n=!1){this.#t.release(e,t,n)}get(e,t){return e===`file`?this.#e.get(t):this.#t.get(t)}clear(e,t,n){return e===`file`?this.#e.clear(t,n):this.#t.clear(t,n)}clearAll(){this.#e.clearAll(),this.#t.clearAll()}setCapacity(e){this.#e.setCapacity(e),this.#t.setCapacity(e)}};function Kn(e){return{selections:e.selections?.map(e=>({...e,start:{...e.start},end:{...e.end}})),view:e.view==null?void 0:{...e.view}}}function qn(e){if(e.document!=null&&e.fileInfo!=null&&(e.type===`file`||e.diffSession!=null))return e.editor??={},e}function Jn(e,t){e!=null&&(t.history===!0&&e.document?.clearHistory(),e.editor!=null&&((t.editor===!0||t.selections===!0)&&(e.editor.selections=void 0),(t.editor===!0||t.view===!0)&&(e.editor.view=void 0)))}var Yn=new Gn,Xn=class{#e;#t;#n;#r;#i;#a;#o=0;#s=0;#c=0;#l=!0;#u;#d=new Map;#f;#p;constructor(e){this.#f=e.hasActivePopover,this.#p=e.updateActivePopover}setViewportElements(e,t){let n=this.#e!==e||this.#t!==t;this.#e=e,n&&(this.#t=t,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0)}cleanUp(){this.#t=void 0,this.#e=void 0,this.#n=void 0,this.#r=void 0,this.#i=void 0,this.#a=void 0,this.#o=0,this.#s=0,this.#c=0,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0,this.#d.clear()}resetPlacement(e=`default`){this.#d.delete(e)}setPlacement(e,t=`default`){this.#d.set(t,e)}choosePlacement(e){let{preferred:t,fallback:n,viewport:r,popoverHeight:i,atDocumentEdge:a,placementKey:o=`default`}=e,s=this.#d.get(o),c;if(r!==void 0&&i>0){let e=(e,t=0)=>e.top>=r.top+t&&e.bottom<=r.bottom-t;c=s===`fallback`&&e(n)&&!e(t,4)||!e(t)&&e(n)?`fallback`:`preferred`}else c=a?`fallback`:`preferred`;return this.#d.set(o,c),c}getPlacementBounds(){let e=this.#g();if(e===void 0)return;let t=this.#_(),n,r;if(t===void 0?(n=0,r=window.innerHeight):(n=t.top,r=t.bottom),n=Math.max(n,e.top),r=Math.min(r,e.bottom),r<=n)return;let i=this.#o,a=this.#s,o=this.#c>0?this.#c:e.width,s=t===void 0?0:t.left,c=t===void 0?window.innerWidth:t.right,l=i,u=i+o,d=Math.max(l,s-e.left+i),f=Math.min(u,c-e.left+i);return{top:n-e.top+a,bottom:r-e.top+a,left:d,right:Math.max(d,f)}}#m(){let e=this.#e;if(e===void 0)return;if(this.#r===e&&(this.#n===void 0||this.#n.isConnected))return this.#n;let t=e.parentElement;for(;t!==null;){let n=getComputedStyle(t).overflowY;if(n===`auto`||n===`scroll`||n===`overlay`)return this.#n=t,this.#r=e,t;t=t.parentElement}this.#n=void 0,this.#r=e}#h(){if(!this.#l)return;this.#v();let e=this.#t;this.#i=e?.getBoundingClientRect(),this.#o=e?.scrollLeft??0,this.#s=e?.scrollTop??0,this.#c=e?.clientWidth??0,this.#a=this.#m()?.getBoundingClientRect(),this.#l=!1}#g(){return this.#h(),this.#i}#_(){return this.#h(),this.#a}#v(){if(this.#u!==void 0)return;let e,t=()=>{this.#l=!0,this.#f()&&e===void 0&&(e=requestAnimationFrame(()=>{e=void 0,this.#p()}))},n=this.#m(),r=this.#t;this.#u=[G(n===void 0?window:n,`scroll`,t,{passive:!0}),...r===void 0?[]:[G(r,`scroll`,t,{passive:!0})],G(window,`resize`,t,{passive:!0}),()=>{e!==void 0&&(cancelAnimationFrame(e),e=void 0)}]}};function Zn(e,{gutterWidth:t,placeAbove:n,viewport:r,x:i,y:a}){if(e.style.setProperty(`--gutter-width`,t+`px`),e.style.setProperty(`--popover-x`,i+`px`),e.style.setProperty(`--popover-y`,a+`px`),e.style.setProperty(`--popover-y-shift`,n?`-100%`:`0px`),r===void 0){e.style.removeProperty(`--popover-viewport-left`),e.style.removeProperty(`--popover-viewport-right`),e.style.removeProperty(`--popover-viewport-top`),e.style.removeProperty(`--popover-viewport-bottom`);return}e.style.setProperty(`--popover-viewport-left`,r.left+`px`),e.style.setProperty(`--popover-viewport-right`,r.right+`px`),e.style.setProperty(`--popover-viewport-top`,r.top+`px`),e.style.setProperty(`--popover-viewport-bottom`,r.bottom+`px`)}function Qn(e){return Ue(e)}function $n(e,t){let n=er(e);if(n.length===0)return;let r=[],i=!1;for(let a of t){if(`side`in a&&a.side===`deletions`||a.lineNumber<=0){r.push(a);continue}let t=a.lineNumber-1,o=e.previousLineCount,s=!1;for(let e of n){let n=Math.max(1,o+e.lineDelta),r=tr(t,e,n);if(r===void 0){s=!0,t=void 0;break}(r!==t||rr(t,e))&&(s=!0),t=r,o=n}if(t===void 0){i=!0;continue}let c=t+1;if(s){if(c===a.lineNumber)r.push(a);else{let e={...a,lineNumber:c};V(e,Ne(a)),r.push(e)}i=!0;continue}r.push(a)}return i?r:void 0}function er(e){if(e.changedLineChanges!==void 0)return e.changedLineChanges.flatMap(([e,t,n,r=0,i=0,a=!1])=>{if(n===0)return[];let o=Math.max(0,t-e);return[{startLine:e,startCharacter:r,endLine:e+Math.max(0,o-n),deletesEndLine:n<0&&a,insertedLineBreaks:o,lineDelta:n}]});if(e.lineDelta===0)return e.changedLineRanges.flatMap(([e,t])=>{let n=t-e;return n<=0?[]:[{startLine:e,startCharacter:0,endLine:e,deletesEndLine:!1,insertedLineBreaks:n,lineDelta:n}]});let t=Math.max(0,-e.lineDelta),n=e.endedAtDocumentEnd&&e.startLine+t===e.previousLineCount-1;return[{startLine:e.startLine,startCharacter:e.startCharacter,endLine:e.startLine+t,deletesEndLine:n,insertedLineBreaks:Math.max(0,e.lineDelta),lineDelta:e.lineDelta}]}function tr(e,t,n){if(e<t.startLine)return e;if(e>t.endLine||t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)return e+t.lineDelta;if(t.startLine===t.endLine)return t.startCharacter===0?e+t.insertedLineBreaks:e;if(nr(e,t))return;let r=Math.min(Math.max(0,e-t.startLine),t.insertedLineBreaks);return ir(t.startLine+r,n)}function nr(e,t){return!(t.lineDelta>=0||e<t.startLine||e>t.endLine||e===t.startLine&&t.startCharacter>0||e===t.endLine&&!t.deletesEndLine)}function rr(e,t){return t.lineDelta===0||e<t.startLine||e>t.endLine?!1:!(t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)}function ir(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}function ar(e,t,n,r=Qn){let i=new Map,a=new Map;for(let t of e){let e=t.lineNumber;i.has(e)||i.set(e,[]),a.has(e)||a.set(e,[]),(`side`in t&&t.side===`deletions`?a:i).get(e).push(r(t))}let o=t.parentElement?.previousElementSibling,s,c;if(o!=null&&o instanceof HTMLElement&&o.dataset.deletions!==void 0)for(let e of o.children){let t=e,{gutter:n,content:r}=t.dataset;n===void 0?r!==void 0&&(c=t):s=t}or(t,n),c!==void 0&&or(c,s);let l=sr(i,t,n);if(c===void 0)return;let u=sr(a,c,s);requestAnimationFrame(()=>{cr(i,a,l,u)})}function or(e,t){let n=[];for(let r=1;r<e.childElementCount;r++){let i=e.children[r];i.dataset.lineAnnotation!==void 0&&(n.push(i),t!==void 0&&n.push(t.children[r]))}for(let e of n)e.remove()}function sr(e,t,n){let r=new Map;for(let n of t.children){let t=W(n);if(t!==void 0){let i=e.get(t);if(i!==void 0){let e=t-1,a=U(`div`,{dataset:{lineAnnotation:`0,`+e},children:[U(`div`,{dataset:`annotationContent`,children:i.map(e=>U(`slot`,{name:e}))})]});n.after(a),r.set(t,a)}}}if(n!==void 0)for(let t of n.children){let n=W(t,`columnNumber`);if(n!==void 0&&e.has(n)){let e=U(`div`,{dataset:{gutterBuffer:`annotation`,bufferSize:`1`},style:{gridRow:`span 1`}});t.after(e)}}return r}function cr(e,t,n,r){let i=new Map;for(let[t,n]of e.entries()){let e=r.get(t);if(n.length===0&&e!==void 0){let n=lr(e);n>0&&i.set(t,n)}}for(let[e,r]of t.entries()){let t=n.get(e);if(r.length===0&&t!==void 0){let n=lr(t);n>0&&i.set(e,n)}}ur(e,n,i),ur(t,r,i)}function lr(e){let t=e.firstElementChild;return t instanceof HTMLElement?t.getBoundingClientRect().height:0}function ur(e,t,n){for(let[r,i]of t.entries()){let t=e.get(r),a=n.get(r);t?.length===0&&a!==void 0&&i.style.setProperty(`--diffs-annotation-min-height`,`${a}px`)}}var dr=new Map([[`'`,`'`],[`"`,`"`],["`","`"],[`{`,`}`],[`[`,`]`],[`<`,`>`],[`(`,`)`]]),fr=new Set([`'`,`"`,"`"]),pr=new Set([`{`,`[`,`(`,`<`]);function mr(e,t=0){let n=_i(e.startContainer,e.startOffset),r=_i(e.endContainer,e.endOffset);if(n!==null&&r!==null)return{start:n,end:r,direction:t}}function hr(e,t,n,r){if(e===void 0)return[[],t];let{start:i,end:a}=t,o=[],s={...t},c=i.line!==a.line,l=a.line;i.line<a.line&&a.character===0&&l--;for(let t=i.line;t<=l;t++){let l=e.getLineText(t);if(l===void 0||c&&l.trim().length===0)continue;let u=l.startsWith(` `)?` `:` `.repeat(n),d=0,f=u;if(r){if(l.startsWith(` `))d=1;else if(l.startsWith(` `)){let e=l.length-l.trimStart().length;d=Math.min(u.length,e)}if(d===0)continue;f=``}o.push({range:{start:{line:t,character:0},end:{line:t,character:d}},newText:f});let p=f.length-d;t===i.line&&(s={...s,start:{...i,character:Math.max(0,i.character+p)}}),t===a.line&&(s={...s,end:{...a,character:Math.max(0,a.character+p)}})}return[o,s]}function gr(e,t,n,r={}){let i=e.lineCount;return t.map(t=>{let{line:a,character:o}=n===`up`||n===`left`?t.start:t.end;if(n===`textStart`||n===`start`||n===`end`){let i=Y(t);a=i.line,o=i.character;let s=yr(e,a,o,r);if(n===`textStart`){let t=e.getLineText(a).slice(s.start,s.end),n=s.start+mi(t);o=o===n?s.start:n}else o=n===`start`?s.start:s.end}else if(n===`up`){let t=_r(e,a,o,-1,r);t===void 0?a>0&&(a=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`)??a):(a=t.line,o=t.character)}else if(n===`down`){let t=_r(e,a,o,1,r);if(t!==void 0)a=t.line,o=t.character;else{let e=Math.max(i-1,0);a<e&&(a=r.resolveRenderableLine==null?a+1:Math.min(r.resolveRenderableLine(a+1,`down`)??a,e))}}else if(J(t)){let t=e.getLineLength(a);if(o=Math.min(o,t),n===`left`){if(o>0)o=ui(e,a,o,!1);else if(a>0){let t=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`);t!==void 0&&(a=t,o=e.getLineLength(a))}}else if(o<t)o=ui(e,a,o,!0);else if(a<i-1){let e=r.resolveRenderableLine==null?a+1:r.resolveRenderableLine(a+1,`down`);e!==void 0&&(a=Math.min(e,i-1),o=0)}}let s={line:a,character:o};return{start:s,end:s,direction:0}})}function _r(e,t,n,r,i){if(i.getSoftLineOffsets===void 0)return;let a=yr(e,t,n,i),o=a.index+r,s=t,c;if(o>=0&&o<a.count)c=xr(e,s,o,i);else{let a=t+r;if(a<0||a>=e.lineCount)return{line:t,character:n};let o=i.resolveRenderableLine==null?a:i.resolveRenderableLine(a,r<0?`up`:`down`);if(o===void 0)return{line:t,character:n};s=Math.min(o,e.lineCount-1);let l=br(s,i);c=xr(e,s,r<0?l-1:0,i)}let l=Math.max(0,n-a.start),u=c.start+l,d=c.index===c.count-1?u:Math.min(u,c.end),f=e.getLineText(s);return{line:s,character:d>f.length?d:vr(f,d)}}function vr(e,t){if(t<=0||t>=e.length)return t;let n=dt();if(n!==void 0){for(let r of n.segment(e)){if(t<=r.index)return t;let e=r.index+r.segment.length;if(t<e)return e}return t}let r=0;for(let n of e){if(t<=r)return t;let e=r+n.length;if(t<e)return e;r=e}return t}function yr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};for(let i=0;i+1<a.length;i++){let a=xr(e,t,i,r);if(n>=a.start&&n<=a.end)return a}return xr(e,t,n<(a[0]??0)?0:a.length-2,r)}function br(e,t){let n=t.getSoftLineOffsets?.(e);return n===void 0||n.length<2?1:n.length-1}function xr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};let o=a.length-1,s=Math.max(0,Math.min(n,o-1)),c=Math.max(0,Math.min(i,a[s]??0));return{start:c,end:Math.max(c,Math.min(i,a[s+1]??i)),index:s,count:o}}function Sr(e,t,n,r={}){return t.map(t=>{let i=t.direction===-1?t.start:t.end,[a]=gr(e,[{start:i,end:i,direction:0}],n,r);return Br(t,a)})}function Cr(e,t,n,r,i=2,a=!1){if(t[t.length-1]===void 0)return{nextSelections:[]};let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=s[(t.length-1)*2],l=s[(t.length-1)*2+1],u=[],d=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=u[u.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(d=!1),u.push(t)}d||u.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let f=gi(e,n,i),p=[],m=Array.from({length:t.length}),h=0,g,_=()=>{if(g===void 0)return;let t=gi(e,{start:g.start,end:g.end,text:f.text},i),n=pi(e,t.text,t.start);p.push({start:t.start,end:t.end,text:n});let r=[g.start+h+n.length,g.start+h+n.length];for(let e of g.indices)m[e]=r;h+=n.length-(t.end-t.start),g=void 0};for(let e of u){let t=Math.max(0,e.start+(f.start-c)),n=Math.max(t,e.end+(f.end-l));if(g!==void 0&&t<g.end){g.end=Math.max(g.end,n),g.indices.push(e.index);continue}_(),g={start:t,end:n,indices:[e.index]}}_();let v=e.applyResolvedEdits(p,!0,t,void 0,a),y=hi(e,m.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(y),v!==void 0&&r!==void 0){let t=$n(v,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:y,change:v}}function wr(e,t){if(t.length!==e.length+2)return;let n=dr.get(t[0]);if(n!==void 0&&t[t.length-1]===n&&t.slice(1,-1)===e)return 1}function Tr(e,t,n,r){let i=t.start+n,a=i+r.length;if(t.end-t.start>0){let n=e.getTextSlice(t.start,t.end),a=wr(n,r)??r.indexOf(n);if(a!==-1&&a+n.length<=r.length){let e=i+a;return[e,e+n.length]}}return[a,a]}function Er(e,t,n,r,i=!1,a=`selection`){if(t.length!==n.length)throw Error(`Selection text replacements must match the selection count`);let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=[],l=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=c[c.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(l=!1),c.push(t)}l||c.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let u=n.every(e=>e===``),d,f=Array.from({length:t.length});if(u){d=[];let e=!1;for(let t of c){if(f[t.index]=[t.end,t.end],t.start>=t.end)continue;e=!0;let n=d[d.length-1];n!==void 0&&t.start<n.end?d[d.length-1]={start:n.start,end:Math.max(n.end,t.end),text:``}:d.push({start:t.start,end:t.end,text:``})}if(!e)return{nextSelections:t};for(let e of c){let t=e.end,n=0,r=t;for(let e of d){if(t<=e.start)break;if(t>=e.end){n-=e.end-e.start;continue}r=e.start+n;break}r===t&&(r+=n),f[e.index]=[r,r]}}else{d=[];let t=0,r=-1;for(let i=0;i<c.length;i++){let o=c[i];if(o.start<r)throw Error(`Overlapping multi-selection edits are not supported`);r=o.end;let s=pi(e,n[a===`document`?i:o.index],o.start);d.push({start:o.start,end:o.end,text:s}),f[o.index]=Tr(e,o,t,s),t+=s.length-(o.end-o.start)}}let p=e.applyResolvedEdits(d,!0,t,void 0,i),m=hi(e,f.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(m),p!==void 0&&r!==void 0){let t=$n(p,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:m,change:p}}function Dr(e,t){return e===`never`?!1:e===`brackets`?pr.has(t):e!==`quotes`||fr.has(t)}function Or(e,t,n,r){if(n.length!==1||t.length===0)return;let i=dr.get(n);if(i===void 0||!Dr(r,n))return;let a=[];for(let r of t){if(J(r))return;a.push(n+e.getText(r)+i)}return a}function kr(e,t,n){let r=[],i=[];for(let n of t){let[t,a]=di(e,n);if(!J(n)){i.push([t,a]);continue}let{line:o,character:s}=n.start,c=t,l=e.getLineText(o),u=l.length,d=c-s,f=li(l),p;if(s>0&&s<u){let e=ci(l,s,!1,f),t=ci(l,s,!0,f);p={start:d+e,end:d+t,text:l.slice(s,t)+l.slice(e,s)},i.push([d+t,d+t])}else if(s===u&&f.length>=2){let e=f[f.length-1],t=f[f.length-2];p={start:d+t,end:c,text:l.slice(e,u)+l.slice(t,e)},i.push([c,c])}else if(s===0&&o>0&&u>0){let t=o-1,n=e.getLineText(t),r=n.length,a=e.offsetAt({line:t,character:r}),s=r>0?ci(n,r,!1,li(n)):r,u=ci(l,0,!0,f),d=a-(r-s),m=l.slice(0,u)+e.getTextSlice(a,c)+n.slice(s,r);p={start:d,end:c+u,text:m};let h=d+m.length;i.push([h,h])}else{i.push([t,a]);continue}r.push(p)}if(r.length===0)return{nextSelections:t};r.sort((e,t)=>e.start-t.start);for(let e=1;e<r.length;e++)if(r[e].start<r[e-1].end)throw Error(`Overlapping multi-selection edits are not supported`);let a=e.applyResolvedEdits(r,!0,t),o=hi(e,i);if(e.setLastUndoSelectionsAfter(o),a!==void 0&&n!==void 0){let t=$n(a,n);t!==void 0&&e.setLastUndoLineAnnotations(n,t)}return{nextSelections:o,change:a}}function Ar(e,t,n){let r=t.map(t=>{let n=fi(e,t);return{start:n.start,end:n.end,direction:0}});return Er(e,r,r.map(()=>``),n)}function jr(e,t,n,r){let i=t.map(t=>{if(!J(t))return{start:t.start,end:t.end,direction:0};let r=Y(t),{line:i,character:a}=r,o=n?.(i,a)??0;if(a>o)return{start:{line:i,character:o},end:{line:i,character:a},direction:0};if(i===0)return{start:r,end:r,direction:0};let s=e.getLineLength(i-1);return{start:{line:i-1,character:s},end:{line:i,character:0},direction:0}});return Er(e,i,i.map(()=>``),r)}function Mr(e,t,n){let r=t.map(t=>{let[n,r]=si(e,t);return{start:n,end:r,direction:0}});return Er(e,r,r.map(()=>``),n)}function Nr(e,t,n){if(!J(t))return[t.start,t.end];let r=Y(t),{line:i,character:a}=r,o=e.getLineLength(i),s=e.lineCount;if(a=Math.min(a,o),n)return a<o?[{line:i,character:a},{line:i,character:ui(e,i,a,!0)}]:i<s-1?[{line:i,character:o},{line:i+1,character:0}]:[r,r];if(a>0)return[{line:i,character:ui(e,i,a,!1)},{line:i,character:a}];if(i>0){let t=e.getLineLength(i-1);return[{line:i-1,character:t},{line:i,character:0}]}return[r,r]}function Pr(e,t,n,r,i=2){let a=t.map(t=>{let[r,a]=Nr(e,t,n);if(!n&&J(t)){let t=gi(e,{start:e.offsetAt(r),end:e.offsetAt(a),text:``},i);r=e.positionAt(t.start),a=e.positionAt(t.end)}return{start:r,end:a,direction:0}});return Er(e,a,a.map(()=>``),r)}function J(e){return e.start.line===e.end.line&&e.start.character===e.end.character}function Y(e){let{start:t,end:n,direction:r}=e;return r===-1?t:n}function Fr(e){return e===`context`||e===`context-expanded`||e===`change-addition`}function Ir(e,t){let n=J(e),r=J(t);return n&&r?X(e.start,t.start)===0:n?X(t.start,e.start)<=0&&X(e.start,t.end)<=0:r?X(e.start,t.start)<=0&&X(t.start,e.end)<=0:X(e.start,t.end)<0&&X(t.start,e.end)<0}function X(e,t){return e.line===t.line?e.character-t.character:e.line-t.line}function Lr(e,t,n){let r=t===n?0:t<n?1:-1,i=Math.min(t,n),a=Math.max(t,n);return{start:e.positionAt(i),end:e.positionAt(a),direction:r}}function Rr(e,t){let n=0;for(let r of t){if(e<r.start)break;if(e>=r.end)n+=r.text.length-(r.end-r.start);else return r.start+n+r.text.length}return e+n}function zr(e,t,n,r){return t.map((t,i)=>{let[a,o]=n[i],s=Rr(a,r),c=Rr(o,r);return Lr(e,t.direction===-1?c:s,t.direction===-1?s:c)})}function Br(e,t){let n=e.direction===-1?e.end:e.start,r=X(n,t.start),i=X(n,t.end),a=t.end;a=r<=0?t.end:i>=0?t.start:r===0?t.end:t.start;let o=X(n,a);return{start:o<=0?n:a,end:o<=0?a:n,direction:o===0?0:o<0?1:-1}}function Vr(e,t){let n=X(t.start,e.start)<0,r=X(t.end,e.end)>0;return n&&!r?{start:t.start,end:e.end,direction:-1}:r&&!n?{start:e.start,end:t.end,direction:1}:e.direction===-1?{start:t.start,end:e.end,direction:X(t.start,e.end)===0?0:-1}:{start:e.start,end:t.end,direction:X(e.start,t.end)===0?0:1}}function Hr(e,t){return Ur(e.map(e=>Vr(e,t)))}function Ur(e){if(e.length<=1)return e;let t=e.map((e,t)=>({index:t,selection:e})).sort((e,t)=>{let n=X(e.selection.start,t.selection.start);if(n!==0)return n;let r=X(e.selection.end,t.selection.end);return r===0?e.index-t.index:r}),n=[],r=t[0];for(let e of t.slice(1)){if(Ir(r.selection,e.selection)){let t=e.index>r.index?e:r,n=X(e.selection.start,r.selection.start)<0?e.selection.start:r.selection.start,i=X(e.selection.end,r.selection.end)>0?e.selection.end:r.selection.end,a=t.selection.direction;a===0&&X(n,i)!==0&&(a=X(t.selection.start,n)===0?-1:1),r={index:t.index,selection:{direction:a,end:i,start:n}};continue}n.push(r),r=e}return n.push(r),n.sort((e,t)=>e.index-t.index).map(({selection:e})=>e)}function Wr(e){let t=e.map(e=>{let t=e.end.line;return e.end.character===0&&X(e.start,e.end)!==0&&t--,{startLine:e.start.line,endLine:Math.max(e.start.line,t)}}).sort((e,t)=>{let n=e.startLine-t.startLine;return n===0?e.endLine-t.endLine:n}),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&e.startLine<=t.endLine+1?t.endLine=Math.max(t.endLine,e.endLine):n.push({...e})}return n}function Gr(e,t,n,r){let i=e=>{let i=e.line+t;if(i>=n){let e=Math.max(0,n-1);return{line:e,character:r(e)}}return i<0?{line:0,character:0}:{line:i,character:e.character}};return{start:i(e.start),end:i(e.end),direction:e.direction}}function Kr(e,t){if(t.length===0)return;let n=t.map(t=>J(t)?ai(e,t):t),r=n.map(t=>e.getText(t)),i=r[0];if(i.length===0||r.some(e=>e!==i))return;let a=n.map(t=>[e.offsetAt(t.start),e.offsetAt(t.end)]),o=e.findNextNonOverlappingSubstring(i,a);if(o===void 0)return n.some((e,n)=>{let r=t[n];return X(e.start,r.start)!==0||X(e.end,r.end)!==0||e.direction!==r.direction})?n:void 0;let s=Lr(e,o,o+i.length);return[...n,s]}function qr(e){let t=e.lineCount-1;return{start:{line:0,character:0},end:{line:t,character:e.getLineLength(t)},direction:1}}function Jr(e,t,n){let r=0;if(t){let t=e.lineCount-1;r=n===!0&&t>0&&e.getLineLength(t)===0?t-1:t}let i=t?e.getLineLength(r):0,a={line:r,character:i};return{start:a,end:a,direction:1}}function Yr(e,t){if(J(t)){let n=t.start.line;return{start:e.offsetAt({line:n,character:0}),end:n<e.lineCount-1?e.offsetAt({line:n+1,character:0}):e.offsetAt({line:n,character:e.getLineLength(n)})}}let n=e.offsetAt(t.start),r=e.offsetAt(t.end);return n<=r?{start:n,end:r}:{start:r,end:n}}function Xr(e,t){return t.map(t=>Yr(e,t)).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n})}function Zr(e,t){return Xr(e,t).map(({start:t,end:n})=>e.getTextSlice(t,n))}function Qr(e,t){let n=Xr(e,t),r=e.eol,i=``,a=-1;for(let t of n)if(!(t.end<=t.start)){if(t.start<=a){t.end>a&&(i+=e.getTextSlice(a,t.end),a=t.end);continue}i.length>0&&!at(i)&&(i+=r),i+=e.getTextSlice(t.start,t.end),a=t.end}return i}function $r(e,t){if(J(t))return ei(e,t);let[n,r]=X(t.start,t.end)<=0?[t.start,t.end]:[t.end,t.start];return{start:e.offsetAt(n),end:e.offsetAt(r),text:``}}function ei(e,t){let n=t.start.line,r=e.offsetAt({line:n,character:0}),i=e.offsetAt({line:n,character:e.getLineLength(n)});return n<e.lineCount-1?{start:r,end:e.offsetAt({line:n+1,character:0}),text:``}:n>0?{start:e.offsetAt({line:n-1,character:e.getLineLength(n-1)}),end:i,text:``}:{start:r,end:i,text:``}}function ti(e){let t=[];for(let{edit:n}of e){if(n.start>=n.end)continue;let e=t.at(-1);e!==void 0&&n.start<=e.end?t[t.length-1]={start:e.start,end:Math.max(e.end,n.end),text:``}:t.push(n)}return t}function ni(e,t){let n=Array.from({length:e.length}),r=0,i=0;for(let a of e){for(;r<t.length&&a.edit.start>t[r].end;){let e=t[r];i-=e.end-e.start,r++}let e=t[r];e!==void 0&&a.edit.start>=e.start&&a.edit.start<=e.end?n[a.index]=e.start+i:n[a.index]=a.edit.start+i}return n}function ri(e,t){let n=[...t.map((t,n)=>({index:n,edit:$r(e,t)}))].sort((e,t)=>{let n=e.edit.start-t.edit.start;if(n!==0)return n;let r=e.edit.end-t.edit.end;return r===0?e.index-t.index:r}),r=ti(n);return{text:Qr(e,t),edits:r,nextSelectionOffsets:ni(n,r)}}function ii(e,t){let n=Math.max(0,t),r=vi(e),i=null;for(let e of r){i=e;let t=Ei(e);if(n<=t+(e.textContent?.length??0)){let r=yi(e,n<t?0:n-t);if(r!==null)return r}}if(i!==null){let e=yi(i,i.textContent?.length??0);return e===null?[i,0]:e}let a=0,o=null;for(let t of e.childNodes){if(t.nodeType===1&&t.tagName===`BR`)return[t,0];if(t.nodeType!==3)continue;o=t;let e=Di(o.textContent,o.textContent?.length??0);if(n<=a+e)return[o,Di(o.textContent,n-a)];a+=e}return o===null?[e,0]:[o,Di(o.textContent,o.textContent?.length??0)]}function ai(e,t){let{line:n,character:r}=t.start,i=e.getLineText(n),a=oi(i,Math.max(0,Math.min(r,i.length)));return a===void 0?t:{start:{line:n,character:a.start},end:{line:n,character:a.end},direction:1}}function oi(e,t){let n=lt({granularity:`word`});if(n!==void 0){for(let r of n.segment(e)){if(r.isWordLike!==!0)continue;let e=r.index,n=e+r.segment.length;if(t>=e&&t<=n)return{start:e,end:n}}return}let r=/[\p{Alphabetic}\p{Number}_]+/gu,i;for(;(i=r.exec(e))!==null;){let e=i.index,n=e+i[0].length;if(t>=e&&t<=n)return{start:e,end:n}}}function si(e,t){if(!J(t))return[t.start,t.end];let n=Y(t),{line:r,character:i}=n;if(i===0){if(r===0)return[n,n];let t=e.getLineLength(r-1);return[{line:r-1,character:t},{line:r,character:0}]}let a=e.getLineText(r),o=li(a),s=i,c;for(;s>0;){let e=ci(a,s,!1,o),t=a.slice(e,s),n=/\S/.test(t)?/\p{Alphabetic}|\p{Number}|_/u.test(t)?1:2:0;if(c!==void 0&&n!==c)break;(n!==0||s!==i)&&(c=n),s=e}return[{line:r,character:s},{line:r,character:i}]}function ci(e,t,n,r){if(n){for(let e of r)if(e>t)return e;return e.length}for(let e=r.length-1;e>=0;e--){let n=r[e];if(n<t)return n}return 0}function li(e){let t=[0],n=dt();if(n!==void 0){for(let r of n.segment(e))r.index>0&&t.push(r.index);return t}let r=0;for(let n of e)r>0&&t.push(r),r+=n.length;return t}function ui(e,t,n,r){let i=e.getLineLength(t);if(r){if(n>=i)return i;let r=e.offsetAt({line:t,character:0}),a=e.getTextSlice(r+n,r+i),o=dt();if(o!==void 0){for(let e of o.segment(a))return n+e.segment.length;return i}for(let e of a)return n+e.length;return i}if(n<=0)return 0;let a=e.offsetAt({line:t,character:0}),o=e.getTextSlice(a,a+n),s=0,c=dt();if(c!==void 0){for(let e of c.segment(o))s=e.index;return s}let l=0;for(let e of o)s=l,l+=e.length;return s}function di(e,t){let n=t.direction===-1;return[e.offsetAt(n?t.end:t.start),e.offsetAt(Y(t))]}function fi(e,t){if(!J(t))return{start:t.start,end:t.end};let{line:n,character:r}=t.start,i=e.getLineText(n).length;return r<i?{start:{line:n,character:r},end:{line:n,character:i}}:n<e.lineCount-1?{start:{line:n,character:r},end:{line:n+1,character:0}}:{start:{line:n,character:r},end:{line:n,character:r}}}function pi(e,t,n){if(t!==`
|
|
7
|
+
`}}get uri(){return this.#e}get languageId(){return this.#t}get version(){return this.#n}get lineCount(){return this.#r.lineCount}get eol(){return this.#a}get history(){return this.#i.getLiveState()}get canUndo(){return this.#i.canUndo}get canRedo(){return this.#i.canRedo}clearHistory(){this.#i.clear()}positionAt(e){return this.normalizePosition(this.#r.positionAt(e))}positionsAt(e){let t=this.#r.positionsAt(e);for(let e=0;e<t.length;e++)t[e]=this.normalizePosition(t[e]);return t}offsetAt(e){return this.#r.offsetAt(this.normalizePosition(e))}getText(e){return e===void 0?this.#r.getText():this.#r.getText({start:this.normalizePosition(e.start),end:this.normalizePosition(e.end)})}getLineText(e,t){return this.#r.getLineText(e,t)}normalizeEol(e){return e.replace(/\r\n|\r|\n/g,this.eol)}getLineLength(e,t){return this.#r.getLineLength(e,t)}charAt(e){return typeof e==`number`?this.#r.charAt(e):this.#r.charAt(this.offsetAt(e))}getTextSlice(e,t){return this.#r.getTextSlice(e,t)}findNextNonOverlappingSubstring(e,t){return this.#r.findNextNonOverlappingSubstring(e,t)}search(e){return this.#r.search(e)}applyEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(this.resolveEdits(e)),t,n,r,i)}resolveEdits(e){return e.map(e=>this.#c(e))}applyResolvedEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(e.map(e=>this.#l(e))),t,n,r,i)}#o(e,t,n,r,i){let a=Nn(this,e,this.#n,this.#n+1,t?n:void 0,t?r:void 0);t&&i&&(a.undoBoundary=!0);let o=this.#i.peekUndoForCoalescing(),s=this.#f(e);return this.#n++,s.lineDelta===0&&Pn(o,a)?this.#i.replaceLastUndo(Fn(o,a)):this.#i.push(a),Bn(s,{appliedEdits:a.forwardEdits,inverseEdits:a.inverseEdits}),s}setLastUndoSelectionsAfter(e){this.#i.setLastUndoSelectionsAfter(e)}setLastUndoLineAnnotations(e,t){this.#i.setLastUndoLineAnnotations(e,t)}undo(){let e=this.#i.popUndoToRedo();if(e===void 0)return;let t=this.#f(e.inverseEdits);if(t===void 0)return;Bn(t,{appliedEdits:e.inverseEdits,inverseEdits:e.forwardEdits}),this.#n=e.versionBefore;let n=e.selectionsBefore?.slice();return[t,n,e.lineAnnotationsBefore?.slice(),n===void 0?e.inverseEdits.map(e=>({...e})):void 0]}redo(){let e=this.#i.popRedoToUndo();if(e===void 0)return;let t=this.#f(e.forwardEdits);if(t===void 0)return;Bn(t,{appliedEdits:e.forwardEdits,inverseEdits:e.inverseEdits}),this.#n=e.versionAfter;let n=e.selectionsAfter?.slice();return[t,n,e.lineAnnotationsAfter?.slice(),n===void 0?e.forwardEdits.map(e=>({...e})):void 0]}normalizePosition(t){let n=e.#s(t.line,this.lineCount-1);return{line:n,character:e.#s(t.character,this.getLineLength(n))}}static#s(e,t){return Number.isNaN(e)?0:Math.max(0,Math.min(Math.floor(e),t))}#c(e){let t=this.offsetAt(e.range.start),n=this.offsetAt(e.range.end);if(t>n){let e=t;t=n,n=e}return this.#l({start:t,end:n,text:e.newText})}#l(e){let{start:t,end:n}=e,r=t===n;return this.#u(t)&&t--,r?n=t:this.#u(n)&&n++,{start:t,end:n,text:e.text}}#u(e){let t=this.#r.charAt(e-1).charCodeAt(0),n=this.#r.charAt(e).charCodeAt(0);return t>=55296&&t<=56319&&n>=56320&&n<=57343}#d(e){let t=[...e].sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<t.length-1;e++)if(t[e].end>t[e+1].start)throw Error(`Overlapping text edits are not supported`);return t}#f(e){let t=this.#r.lineCount,n=this.positionsAt(e.flatMap(e=>[e.start,e.end])),r=this.#p(e,n),i=n[0],a=n[n.length-1],o=a.line===t-1&&a.character===this.#r.getLineLength(a.line);this.#r.applyEdits(e);let s=this.#r.lineCount;return{changes:e.map((e,t)=>({...e,range:{start:n[t*2],end:n[t*2+1]}})),startLine:r.startLine,startCharacter:i.character,endCharacter:a.character,endLine:Math.min(r.endLine,Math.max(0,s-1)),endedAtDocumentEnd:o,previousLineCount:t,lineCount:s,lineDelta:s-t,changedLineRanges:r.ranges,changedLineChanges:r.changes}}#p(e,t){let n=1/0,r=0,i=0,a=[],o=[],s=this.#r.lineCount-1,c=this.#r.getLineLength(s);for(let l=0;l<e.length;l++){let u=e[l],d=t[l*2],f=t[l*2+1],p=d.line,m=f.line,h=$e(u.text),g=p+i,_=g+h,v=h-(m-p);n=Math.min(n,p),r=Math.max(r,_);let y=a[a.length-1];y!==void 0&&g<=y[1]+1?a[a.length-1]=[y[0],Math.max(y[1],_)]:a.push([g,_]),o.push([g,_,v,d.character,f.character,m===s&&f.character===c]),i+=v}return n===1/0?{startLine:0,endLine:0,ranges:[[0,0]],changes:[[0,0,0,0,0,!1]]}:{startLine:n,endLine:r,ranges:a,changes:o}}},Hn=e(Ze(),1),Un=100,Wn=class{type;#e=new Hn.default.LRUMap(Un);#t=new Map;constructor(e){this.type=e}activate(e,t,n){let r=this.#t.get(e);if(r!=null&&r.owner!==t)throw Error(`Editor: editStateKey "${e}" is already attached to another editor`);if(r!=null)return n!=null&&(r.session=n),r.session;let i=this.#e.delete(e),a={type:this.type},o=n??i??a;return this.#t.set(e,{owner:t,session:o}),o}release(e,t,n=!1){let r=this.#t.get(e);if(r?.owner!==t||(this.#t.delete(e),n))return;let i=qn(r.session);i!=null&&this.#e.set(e,i)}get(e){let t=this.#t.get(e);return t==null?this.#e.find(e):qn(t.session)??void 0}clear(e,t){if(this.#t.has(e))return!1;let n=this.#e.find(e);return n!=null&&(t==null||t.document===!0?this.#e.delete(e):Jn(n,t),!0)}clearAll(){this.#e.clear()}setCapacity(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`EditStateManager: capacity must be a positive integer`);for(;this.#e.size>e;)this.#e.shift();this.#e.limit=e}},Gn=class{#e=new Wn(`file`);#t=new Wn(`file-diff`);activate(e,t,n,r){return e===`file`?this.#e.activate(t,n,r):this.#t.activate(t,n,r)}releaseFile(e,t,n=!1){this.#e.release(e,t,n)}releaseFileDiff(e,t,n=!1){this.#t.release(e,t,n)}get(e,t){return e===`file`?this.#e.get(t):this.#t.get(t)}clear(e,t,n){return e===`file`?this.#e.clear(t,n):this.#t.clear(t,n)}clearAll(){this.#e.clearAll(),this.#t.clearAll()}setCapacity(e){this.#e.setCapacity(e),this.#t.setCapacity(e)}};function Kn(e){return{selections:e.selections?.map(e=>({...e,start:{...e.start},end:{...e.end}})),view:e.view==null?void 0:{...e.view}}}function qn(e){if(e.document!=null&&e.fileInfo!=null&&(e.type===`file`||e.diffSession!=null))return e.editor??={},e}function Jn(e,t){e!=null&&(t.history===!0&&e.document?.clearHistory(),e.editor!=null&&((t.editor===!0||t.selections===!0)&&(e.editor.selections=void 0),(t.editor===!0||t.view===!0)&&(e.editor.view=void 0)))}var Yn=new Gn,Xn=class{#e;#t;#n;#r;#i;#a;#o=0;#s=0;#c=0;#l=!0;#u;#d=new Map;#f;#p;constructor(e){this.#f=e.hasActivePopover,this.#p=e.updateActivePopover}setViewportElements(e,t){let n=this.#e!==e||this.#t!==t;this.#e=e,n&&(this.#t=t,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0)}cleanUp(){this.#t=void 0,this.#e=void 0,this.#n=void 0,this.#r=void 0,this.#i=void 0,this.#a=void 0,this.#o=0,this.#s=0,this.#c=0,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0,this.#d.clear()}resetPlacement(e=`default`){this.#d.delete(e)}setPlacement(e,t=`default`){this.#d.set(t,e)}choosePlacement(e){let{preferred:t,fallback:n,viewport:r,popoverHeight:i,atDocumentEdge:a,placementKey:o=`default`}=e,s=this.#d.get(o),c;if(r!==void 0&&i>0){let e=(e,t=0)=>e.top>=r.top+t&&e.bottom<=r.bottom-t;c=s===`fallback`&&e(n)&&!e(t,4)||!e(t)&&e(n)?`fallback`:`preferred`}else c=a?`fallback`:`preferred`;return this.#d.set(o,c),c}getPlacementBounds(){let e=this.#g();if(e===void 0)return;let t=this.#_(),n,r;if(t===void 0?(n=0,r=window.innerHeight):(n=t.top,r=t.bottom),n=Math.max(n,e.top),r=Math.min(r,e.bottom),r<=n)return;let i=this.#o,a=this.#s,o=this.#c>0?this.#c:e.width,s=t===void 0?0:t.left,c=t===void 0?window.innerWidth:t.right,l=i,u=i+o,d=Math.max(l,s-e.left+i),f=Math.min(u,c-e.left+i);return{top:n-e.top+a,bottom:r-e.top+a,left:d,right:Math.max(d,f)}}#m(){let e=this.#e;if(e===void 0)return;if(this.#r===e&&(this.#n===void 0||this.#n.isConnected))return this.#n;let t=e.parentElement;for(;t!==null;){let n=getComputedStyle(t).overflowY;if(n===`auto`||n===`scroll`||n===`overlay`)return this.#n=t,this.#r=e,t;t=t.parentElement}this.#n=void 0,this.#r=e}#h(){if(!this.#l)return;this.#v();let e=this.#t;this.#i=e?.getBoundingClientRect(),this.#o=e?.scrollLeft??0,this.#s=e?.scrollTop??0,this.#c=e?.clientWidth??0,this.#a=this.#m()?.getBoundingClientRect(),this.#l=!1}#g(){return this.#h(),this.#i}#_(){return this.#h(),this.#a}#v(){if(this.#u!==void 0)return;let e,t=()=>{this.#l=!0,this.#f()&&e===void 0&&(e=requestAnimationFrame(()=>{e=void 0,this.#p()}))},n=this.#m(),r=this.#t;this.#u=[G(n===void 0?window:n,`scroll`,t,{passive:!0}),...r===void 0?[]:[G(r,`scroll`,t,{passive:!0})],G(window,`resize`,t,{passive:!0}),()=>{e!==void 0&&(cancelAnimationFrame(e),e=void 0)}]}};function Zn(e,{gutterWidth:t,placeAbove:n,viewport:r,x:i,y:a}){if(e.style.setProperty(`--gutter-width`,t+`px`),e.style.setProperty(`--popover-x`,i+`px`),e.style.setProperty(`--popover-y`,a+`px`),e.style.setProperty(`--popover-y-shift`,n?`-100%`:`0px`),r===void 0){e.style.removeProperty(`--popover-viewport-left`),e.style.removeProperty(`--popover-viewport-right`),e.style.removeProperty(`--popover-viewport-top`),e.style.removeProperty(`--popover-viewport-bottom`);return}e.style.setProperty(`--popover-viewport-left`,r.left+`px`),e.style.setProperty(`--popover-viewport-right`,r.right+`px`),e.style.setProperty(`--popover-viewport-top`,r.top+`px`),e.style.setProperty(`--popover-viewport-bottom`,r.bottom+`px`)}function Qn(e){return We(e)}function $n(e,t){let n=er(e);if(n.length===0)return;let r=[],i=!1;for(let a of t){if(`side`in a&&a.side===`deletions`||a.lineNumber<=0){r.push(a);continue}let t=a.lineNumber-1,o=e.previousLineCount,s=!1;for(let e of n){let n=Math.max(1,o+e.lineDelta),r=tr(t,e,n);if(r===void 0){s=!0,t=void 0;break}(r!==t||rr(t,e))&&(s=!0),t=r,o=n}if(t===void 0){i=!0;continue}let c=t+1;if(s){if(c===a.lineNumber)r.push(a);else{let e={...a,lineNumber:c};B(e,Pe(a)),r.push(e)}i=!0;continue}r.push(a)}return i?r:void 0}function er(e){if(e.changedLineChanges!==void 0)return e.changedLineChanges.flatMap(([e,t,n,r=0,i=0,a=!1])=>{if(n===0)return[];let o=Math.max(0,t-e);return[{startLine:e,startCharacter:r,endLine:e+Math.max(0,o-n),deletesEndLine:n<0&&a,insertedLineBreaks:o,lineDelta:n}]});if(e.lineDelta===0)return e.changedLineRanges.flatMap(([e,t])=>{let n=t-e;return n<=0?[]:[{startLine:e,startCharacter:0,endLine:e,deletesEndLine:!1,insertedLineBreaks:n,lineDelta:n}]});let t=Math.max(0,-e.lineDelta),n=e.endedAtDocumentEnd&&e.startLine+t===e.previousLineCount-1;return[{startLine:e.startLine,startCharacter:e.startCharacter,endLine:e.startLine+t,deletesEndLine:n,insertedLineBreaks:Math.max(0,e.lineDelta),lineDelta:e.lineDelta}]}function tr(e,t,n){if(e<t.startLine)return e;if(e>t.endLine||t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)return e+t.lineDelta;if(t.startLine===t.endLine)return t.startCharacter===0?e+t.insertedLineBreaks:e;if(nr(e,t))return;let r=Math.min(Math.max(0,e-t.startLine),t.insertedLineBreaks);return ir(t.startLine+r,n)}function nr(e,t){return!(t.lineDelta>=0||e<t.startLine||e>t.endLine||e===t.startLine&&t.startCharacter>0||e===t.endLine&&!t.deletesEndLine)}function rr(e,t){return t.lineDelta===0||e<t.startLine||e>t.endLine?!1:!(t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)}function ir(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}function ar(e,t,n,r=Qn){let i=new Map,a=new Map;for(let t of e){let e=t.lineNumber;i.has(e)||i.set(e,[]),a.has(e)||a.set(e,[]),(`side`in t&&t.side===`deletions`?a:i).get(e).push(r(t))}let o=t.parentElement?.previousElementSibling,s,c;if(o!=null&&o instanceof HTMLElement&&o.dataset.deletions!==void 0)for(let e of o.children){let t=e,{gutter:n,content:r}=t.dataset;n===void 0?r!==void 0&&(c=t):s=t}or(t,n),c!==void 0&&or(c,s);let l=sr(i,t,n);if(c===void 0)return;let u=sr(a,c,s);requestAnimationFrame(()=>{cr(i,a,l,u)})}function or(e,t){let n=[];for(let r=1;r<e.childElementCount;r++){let i=e.children[r];i.dataset.lineAnnotation!==void 0&&(n.push(i),t!==void 0&&n.push(t.children[r]))}for(let e of n)e.remove()}function sr(e,t,n){let r=new Map;for(let n of t.children){let t=W(n);if(t!==void 0){let i=e.get(t);if(i!==void 0){let e=t-1,a=U(`div`,{dataset:{lineAnnotation:`0,`+e},children:[U(`div`,{dataset:`annotationContent`,children:i.map(e=>U(`slot`,{name:e}))})]});n.after(a),r.set(t,a)}}}if(n!==void 0)for(let t of n.children){let n=W(t,`columnNumber`);if(n!==void 0&&e.has(n)){let e=U(`div`,{dataset:{gutterBuffer:`annotation`,bufferSize:`1`},style:{gridRow:`span 1`}});t.after(e)}}return r}function cr(e,t,n,r){let i=new Map;for(let[t,n]of e.entries()){let e=r.get(t);if(n.length===0&&e!==void 0){let n=lr(e);n>0&&i.set(t,n)}}for(let[e,r]of t.entries()){let t=n.get(e);if(r.length===0&&t!==void 0){let n=lr(t);n>0&&i.set(e,n)}}ur(e,n,i),ur(t,r,i)}function lr(e){let t=e.firstElementChild;return t instanceof HTMLElement?t.getBoundingClientRect().height:0}function ur(e,t,n){for(let[r,i]of t.entries()){let t=e.get(r),a=n.get(r);t?.length===0&&a!==void 0&&i.style.setProperty(`--diffs-annotation-min-height`,`${a}px`)}}var dr=new Map([[`'`,`'`],[`"`,`"`],["`","`"],[`{`,`}`],[`[`,`]`],[`<`,`>`],[`(`,`)`]]),fr=new Set([`'`,`"`,"`"]),pr=new Set([`{`,`[`,`(`,`<`]);function mr(e,t=0){let n=_i(e.startContainer,e.startOffset),r=_i(e.endContainer,e.endOffset);if(n!==null&&r!==null)return{start:n,end:r,direction:t}}function hr(e,t,n,r){if(e===void 0)return[[],t];let{start:i,end:a}=t,o=[],s={...t},c=i.line!==a.line,l=a.line;i.line<a.line&&a.character===0&&l--;for(let t=i.line;t<=l;t++){let l=e.getLineText(t);if(l===void 0||c&&l.trim().length===0)continue;let u=l.startsWith(` `)?` `:` `.repeat(n),d=0,f=u;if(r){if(l.startsWith(` `))d=1;else if(l.startsWith(` `)){let e=l.length-l.trimStart().length;d=Math.min(u.length,e)}if(d===0)continue;f=``}o.push({range:{start:{line:t,character:0},end:{line:t,character:d}},newText:f});let p=f.length-d;t===i.line&&(s={...s,start:{...i,character:Math.max(0,i.character+p)}}),t===a.line&&(s={...s,end:{...a,character:Math.max(0,a.character+p)}})}return[o,s]}function gr(e,t,n,r={}){let i=e.lineCount;return t.map(t=>{let{line:a,character:o}=n===`up`||n===`left`?t.start:t.end;if(n===`textStart`||n===`start`||n===`end`){let i=Y(t);a=i.line,o=i.character;let s=yr(e,a,o,r);if(n===`textStart`){let t=e.getLineText(a).slice(s.start,s.end),n=s.start+mi(t);o=o===n?s.start:n}else o=n===`start`?s.start:s.end}else if(n===`up`){let t=_r(e,a,o,-1,r);t===void 0?a>0&&(a=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`)??a):(a=t.line,o=t.character)}else if(n===`down`){let t=_r(e,a,o,1,r);if(t!==void 0)a=t.line,o=t.character;else{let e=Math.max(i-1,0);a<e&&(a=r.resolveRenderableLine==null?a+1:Math.min(r.resolveRenderableLine(a+1,`down`)??a,e))}}else if(J(t)){let t=e.getLineLength(a);if(o=Math.min(o,t),n===`left`){if(o>0)o=ui(e,a,o,!1);else if(a>0){let t=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`);t!==void 0&&(a=t,o=e.getLineLength(a))}}else if(o<t)o=ui(e,a,o,!0);else if(a<i-1){let e=r.resolveRenderableLine==null?a+1:r.resolveRenderableLine(a+1,`down`);e!==void 0&&(a=Math.min(e,i-1),o=0)}}let s={line:a,character:o};return{start:s,end:s,direction:0}})}function _r(e,t,n,r,i){if(i.getSoftLineOffsets===void 0)return;let a=yr(e,t,n,i),o=a.index+r,s=t,c;if(o>=0&&o<a.count)c=xr(e,s,o,i);else{let a=t+r;if(a<0||a>=e.lineCount)return{line:t,character:n};let o=i.resolveRenderableLine==null?a:i.resolveRenderableLine(a,r<0?`up`:`down`);if(o===void 0)return{line:t,character:n};s=Math.min(o,e.lineCount-1);let l=br(s,i);c=xr(e,s,r<0?l-1:0,i)}let l=Math.max(0,n-a.start),u=c.start+l,d=c.index===c.count-1?u:Math.min(u,c.end),f=e.getLineText(s);return{line:s,character:d>f.length?d:vr(f,d)}}function vr(e,t){if(t<=0||t>=e.length)return t;let n=dt();if(n!==void 0){for(let r of n.segment(e)){if(t<=r.index)return t;let e=r.index+r.segment.length;if(t<e)return e}return t}let r=0;for(let n of e){if(t<=r)return t;let e=r+n.length;if(t<e)return e;r=e}return t}function yr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};for(let i=0;i+1<a.length;i++){let a=xr(e,t,i,r);if(n>=a.start&&n<=a.end)return a}return xr(e,t,n<(a[0]??0)?0:a.length-2,r)}function br(e,t){let n=t.getSoftLineOffsets?.(e);return n===void 0||n.length<2?1:n.length-1}function xr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};let o=a.length-1,s=Math.max(0,Math.min(n,o-1)),c=Math.max(0,Math.min(i,a[s]??0));return{start:c,end:Math.max(c,Math.min(i,a[s+1]??i)),index:s,count:o}}function Sr(e,t,n,r={}){return t.map(t=>{let i=t.direction===-1?t.start:t.end,[a]=gr(e,[{start:i,end:i,direction:0}],n,r);return Br(t,a)})}function Cr(e,t,n,r,i=2,a=!1){if(t[t.length-1]===void 0)return{nextSelections:[]};let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=s[(t.length-1)*2],l=s[(t.length-1)*2+1],u=[],d=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=u[u.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(d=!1),u.push(t)}d||u.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let f=gi(e,n,i),p=[],m=Array.from({length:t.length}),h=0,g,_=()=>{if(g===void 0)return;let t=gi(e,{start:g.start,end:g.end,text:f.text},i),n=pi(e,t.text,t.start);p.push({start:t.start,end:t.end,text:n});let r=[g.start+h+n.length,g.start+h+n.length];for(let e of g.indices)m[e]=r;h+=n.length-(t.end-t.start),g=void 0};for(let e of u){let t=Math.max(0,e.start+(f.start-c)),n=Math.max(t,e.end+(f.end-l));if(g!==void 0&&t<g.end){g.end=Math.max(g.end,n),g.indices.push(e.index);continue}_(),g={start:t,end:n,indices:[e.index]}}_();let v=e.applyResolvedEdits(p,!0,t,void 0,a),y=hi(e,m.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(y),v!==void 0&&r!==void 0){let t=$n(v,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:y,change:v}}function wr(e,t){if(t.length!==e.length+2)return;let n=dr.get(t[0]);if(n!==void 0&&t[t.length-1]===n&&t.slice(1,-1)===e)return 1}function Tr(e,t,n,r){let i=t.start+n,a=i+r.length;if(t.end-t.start>0){let n=e.getTextSlice(t.start,t.end),a=wr(n,r)??r.indexOf(n);if(a!==-1&&a+n.length<=r.length){let e=i+a;return[e,e+n.length]}}return[a,a]}function Er(e,t,n,r,i=!1,a=`selection`){if(t.length!==n.length)throw Error(`Selection text replacements must match the selection count`);let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=[],l=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=c[c.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(l=!1),c.push(t)}l||c.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let u=n.every(e=>e===``),d,f=Array.from({length:t.length});if(u){d=[];let e=!1;for(let t of c){if(f[t.index]=[t.end,t.end],t.start>=t.end)continue;e=!0;let n=d[d.length-1];n!==void 0&&t.start<n.end?d[d.length-1]={start:n.start,end:Math.max(n.end,t.end),text:``}:d.push({start:t.start,end:t.end,text:``})}if(!e)return{nextSelections:t};for(let e of c){let t=e.end,n=0,r=t;for(let e of d){if(t<=e.start)break;if(t>=e.end){n-=e.end-e.start;continue}r=e.start+n;break}r===t&&(r+=n),f[e.index]=[r,r]}}else{d=[];let t=0,r=-1;for(let i=0;i<c.length;i++){let o=c[i];if(o.start<r)throw Error(`Overlapping multi-selection edits are not supported`);r=o.end;let s=pi(e,n[a===`document`?i:o.index],o.start);d.push({start:o.start,end:o.end,text:s}),f[o.index]=Tr(e,o,t,s),t+=s.length-(o.end-o.start)}}let p=e.applyResolvedEdits(d,!0,t,void 0,i),m=hi(e,f.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(m),p!==void 0&&r!==void 0){let t=$n(p,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:m,change:p}}function Dr(e,t){return e===`never`?!1:e===`brackets`?pr.has(t):e!==`quotes`||fr.has(t)}function Or(e,t,n,r){if(n.length!==1||t.length===0)return;let i=dr.get(n);if(i===void 0||!Dr(r,n))return;let a=[];for(let r of t){if(J(r))return;a.push(n+e.getText(r)+i)}return a}function kr(e,t,n){let r=[],i=[];for(let n of t){let[t,a]=di(e,n);if(!J(n)){i.push([t,a]);continue}let{line:o,character:s}=n.start,c=t,l=e.getLineText(o),u=l.length,d=c-s,f=li(l),p;if(s>0&&s<u){let e=ci(l,s,!1,f),t=ci(l,s,!0,f);p={start:d+e,end:d+t,text:l.slice(s,t)+l.slice(e,s)},i.push([d+t,d+t])}else if(s===u&&f.length>=2){let e=f[f.length-1],t=f[f.length-2];p={start:d+t,end:c,text:l.slice(e,u)+l.slice(t,e)},i.push([c,c])}else if(s===0&&o>0&&u>0){let t=o-1,n=e.getLineText(t),r=n.length,a=e.offsetAt({line:t,character:r}),s=r>0?ci(n,r,!1,li(n)):r,u=ci(l,0,!0,f),d=a-(r-s),m=l.slice(0,u)+e.getTextSlice(a,c)+n.slice(s,r);p={start:d,end:c+u,text:m};let h=d+m.length;i.push([h,h])}else{i.push([t,a]);continue}r.push(p)}if(r.length===0)return{nextSelections:t};r.sort((e,t)=>e.start-t.start);for(let e=1;e<r.length;e++)if(r[e].start<r[e-1].end)throw Error(`Overlapping multi-selection edits are not supported`);let a=e.applyResolvedEdits(r,!0,t),o=hi(e,i);if(e.setLastUndoSelectionsAfter(o),a!==void 0&&n!==void 0){let t=$n(a,n);t!==void 0&&e.setLastUndoLineAnnotations(n,t)}return{nextSelections:o,change:a}}function Ar(e,t,n){let r=t.map(t=>{let n=fi(e,t);return{start:n.start,end:n.end,direction:0}});return Er(e,r,r.map(()=>``),n)}function jr(e,t,n,r){let i=t.map(t=>{if(!J(t))return{start:t.start,end:t.end,direction:0};let r=Y(t),{line:i,character:a}=r,o=n?.(i,a)??0;if(a>o)return{start:{line:i,character:o},end:{line:i,character:a},direction:0};if(i===0)return{start:r,end:r,direction:0};let s=e.getLineLength(i-1);return{start:{line:i-1,character:s},end:{line:i,character:0},direction:0}});return Er(e,i,i.map(()=>``),r)}function Mr(e,t,n){let r=t.map(t=>{let[n,r]=si(e,t);return{start:n,end:r,direction:0}});return Er(e,r,r.map(()=>``),n)}function Nr(e,t,n){if(!J(t))return[t.start,t.end];let r=Y(t),{line:i,character:a}=r,o=e.getLineLength(i),s=e.lineCount;if(a=Math.min(a,o),n)return a<o?[{line:i,character:a},{line:i,character:ui(e,i,a,!0)}]:i<s-1?[{line:i,character:o},{line:i+1,character:0}]:[r,r];if(a>0)return[{line:i,character:ui(e,i,a,!1)},{line:i,character:a}];if(i>0){let t=e.getLineLength(i-1);return[{line:i-1,character:t},{line:i,character:0}]}return[r,r]}function Pr(e,t,n,r,i=2){let a=t.map(t=>{let[r,a]=Nr(e,t,n);if(!n&&J(t)){let t=gi(e,{start:e.offsetAt(r),end:e.offsetAt(a),text:``},i);r=e.positionAt(t.start),a=e.positionAt(t.end)}return{start:r,end:a,direction:0}});return Er(e,a,a.map(()=>``),r)}function J(e){return e.start.line===e.end.line&&e.start.character===e.end.character}function Y(e){let{start:t,end:n,direction:r}=e;return r===-1?t:n}function Fr(e){return e===`context`||e===`context-expanded`||e===`change-addition`}function Ir(e,t){let n=J(e),r=J(t);return n&&r?X(e.start,t.start)===0:n?X(t.start,e.start)<=0&&X(e.start,t.end)<=0:r?X(e.start,t.start)<=0&&X(t.start,e.end)<=0:X(e.start,t.end)<0&&X(t.start,e.end)<0}function X(e,t){return e.line===t.line?e.character-t.character:e.line-t.line}function Lr(e,t,n){let r=t===n?0:t<n?1:-1,i=Math.min(t,n),a=Math.max(t,n);return{start:e.positionAt(i),end:e.positionAt(a),direction:r}}function Rr(e,t){let n=0;for(let r of t){if(e<r.start)break;if(e>=r.end)n+=r.text.length-(r.end-r.start);else return r.start+n+r.text.length}return e+n}function zr(e,t,n,r){return t.map((t,i)=>{let[a,o]=n[i],s=Rr(a,r),c=Rr(o,r);return Lr(e,t.direction===-1?c:s,t.direction===-1?s:c)})}function Br(e,t){let n=e.direction===-1?e.end:e.start,r=X(n,t.start),i=X(n,t.end),a=t.end;a=r<=0?t.end:i>=0?t.start:r===0?t.end:t.start;let o=X(n,a);return{start:o<=0?n:a,end:o<=0?a:n,direction:o===0?0:o<0?1:-1}}function Vr(e,t){let n=X(t.start,e.start)<0,r=X(t.end,e.end)>0;return n&&!r?{start:t.start,end:e.end,direction:-1}:r&&!n?{start:e.start,end:t.end,direction:1}:e.direction===-1?{start:t.start,end:e.end,direction:X(t.start,e.end)===0?0:-1}:{start:e.start,end:t.end,direction:X(e.start,t.end)===0?0:1}}function Hr(e,t){return Ur(e.map(e=>Vr(e,t)))}function Ur(e){if(e.length<=1)return e;let t=e.map((e,t)=>({index:t,selection:e})).sort((e,t)=>{let n=X(e.selection.start,t.selection.start);if(n!==0)return n;let r=X(e.selection.end,t.selection.end);return r===0?e.index-t.index:r}),n=[],r=t[0];for(let e of t.slice(1)){if(Ir(r.selection,e.selection)){let t=e.index>r.index?e:r,n=X(e.selection.start,r.selection.start)<0?e.selection.start:r.selection.start,i=X(e.selection.end,r.selection.end)>0?e.selection.end:r.selection.end,a=t.selection.direction;a===0&&X(n,i)!==0&&(a=X(t.selection.start,n)===0?-1:1),r={index:t.index,selection:{direction:a,end:i,start:n}};continue}n.push(r),r=e}return n.push(r),n.sort((e,t)=>e.index-t.index).map(({selection:e})=>e)}function Wr(e){let t=e.map(e=>{let t=e.end.line;return e.end.character===0&&X(e.start,e.end)!==0&&t--,{startLine:e.start.line,endLine:Math.max(e.start.line,t)}}).sort((e,t)=>{let n=e.startLine-t.startLine;return n===0?e.endLine-t.endLine:n}),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&e.startLine<=t.endLine+1?t.endLine=Math.max(t.endLine,e.endLine):n.push({...e})}return n}function Gr(e,t,n,r){let i=e=>{let i=e.line+t;if(i>=n){let e=Math.max(0,n-1);return{line:e,character:r(e)}}return i<0?{line:0,character:0}:{line:i,character:e.character}};return{start:i(e.start),end:i(e.end),direction:e.direction}}function Kr(e,t){if(t.length===0)return;let n=t.map(t=>J(t)?ai(e,t):t),r=n.map(t=>e.getText(t)),i=r[0];if(i.length===0||r.some(e=>e!==i))return;let a=n.map(t=>[e.offsetAt(t.start),e.offsetAt(t.end)]),o=e.findNextNonOverlappingSubstring(i,a);if(o===void 0)return n.some((e,n)=>{let r=t[n];return X(e.start,r.start)!==0||X(e.end,r.end)!==0||e.direction!==r.direction})?n:void 0;let s=Lr(e,o,o+i.length);return[...n,s]}function qr(e){let t=e.lineCount-1;return{start:{line:0,character:0},end:{line:t,character:e.getLineLength(t)},direction:1}}function Jr(e,t,n){let r=0;if(t){let t=e.lineCount-1;r=n===!0&&t>0&&e.getLineLength(t)===0?t-1:t}let i=t?e.getLineLength(r):0,a={line:r,character:i};return{start:a,end:a,direction:1}}function Yr(e,t){if(J(t)){let n=t.start.line;return{start:e.offsetAt({line:n,character:0}),end:n<e.lineCount-1?e.offsetAt({line:n+1,character:0}):e.offsetAt({line:n,character:e.getLineLength(n)})}}let n=e.offsetAt(t.start),r=e.offsetAt(t.end);return n<=r?{start:n,end:r}:{start:r,end:n}}function Xr(e,t){return t.map(t=>Yr(e,t)).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n})}function Zr(e,t){return Xr(e,t).map(({start:t,end:n})=>e.getTextSlice(t,n))}function Qr(e,t){let n=Xr(e,t),r=e.eol,i=``,a=-1;for(let t of n)if(!(t.end<=t.start)){if(t.start<=a){t.end>a&&(i+=e.getTextSlice(a,t.end),a=t.end);continue}i.length>0&&!at(i)&&(i+=r),i+=e.getTextSlice(t.start,t.end),a=t.end}return i}function $r(e,t){if(J(t))return ei(e,t);let[n,r]=X(t.start,t.end)<=0?[t.start,t.end]:[t.end,t.start];return{start:e.offsetAt(n),end:e.offsetAt(r),text:``}}function ei(e,t){let n=t.start.line,r=e.offsetAt({line:n,character:0}),i=e.offsetAt({line:n,character:e.getLineLength(n)});return n<e.lineCount-1?{start:r,end:e.offsetAt({line:n+1,character:0}),text:``}:n>0?{start:e.offsetAt({line:n-1,character:e.getLineLength(n-1)}),end:i,text:``}:{start:r,end:i,text:``}}function ti(e){let t=[];for(let{edit:n}of e){if(n.start>=n.end)continue;let e=t.at(-1);e!==void 0&&n.start<=e.end?t[t.length-1]={start:e.start,end:Math.max(e.end,n.end),text:``}:t.push(n)}return t}function ni(e,t){let n=Array.from({length:e.length}),r=0,i=0;for(let a of e){for(;r<t.length&&a.edit.start>t[r].end;){let e=t[r];i-=e.end-e.start,r++}let e=t[r];e!==void 0&&a.edit.start>=e.start&&a.edit.start<=e.end?n[a.index]=e.start+i:n[a.index]=a.edit.start+i}return n}function ri(e,t){let n=[...t.map((t,n)=>({index:n,edit:$r(e,t)}))].sort((e,t)=>{let n=e.edit.start-t.edit.start;if(n!==0)return n;let r=e.edit.end-t.edit.end;return r===0?e.index-t.index:r}),r=ti(n);return{text:Qr(e,t),edits:r,nextSelectionOffsets:ni(n,r)}}function ii(e,t){let n=Math.max(0,t),r=vi(e),i=null;for(let e of r){i=e;let t=Ei(e);if(n<=t+(e.textContent?.length??0)){let r=yi(e,n<t?0:n-t);if(r!==null)return r}}if(i!==null){let e=yi(i,i.textContent?.length??0);return e===null?[i,0]:e}let a=0,o=null;for(let t of e.childNodes){if(t.nodeType===1&&t.tagName===`BR`)return[t,0];if(t.nodeType!==3)continue;o=t;let e=Di(o.textContent,o.textContent?.length??0);if(n<=a+e)return[o,Di(o.textContent,n-a)];a+=e}return o===null?[e,0]:[o,Di(o.textContent,o.textContent?.length??0)]}function ai(e,t){let{line:n,character:r}=t.start,i=e.getLineText(n),a=oi(i,Math.max(0,Math.min(r,i.length)));return a===void 0?t:{start:{line:n,character:a.start},end:{line:n,character:a.end},direction:1}}function oi(e,t){let n=lt({granularity:`word`});if(n!==void 0){for(let r of n.segment(e)){if(r.isWordLike!==!0)continue;let e=r.index,n=e+r.segment.length;if(t>=e&&t<=n)return{start:e,end:n}}return}let r=/[\p{Alphabetic}\p{Number}_]+/gu,i;for(;(i=r.exec(e))!==null;){let e=i.index,n=e+i[0].length;if(t>=e&&t<=n)return{start:e,end:n}}}function si(e,t){if(!J(t))return[t.start,t.end];let n=Y(t),{line:r,character:i}=n;if(i===0){if(r===0)return[n,n];let t=e.getLineLength(r-1);return[{line:r-1,character:t},{line:r,character:0}]}let a=e.getLineText(r),o=li(a),s=i,c;for(;s>0;){let e=ci(a,s,!1,o),t=a.slice(e,s),n=/\S/.test(t)?/\p{Alphabetic}|\p{Number}|_/u.test(t)?1:2:0;if(c!==void 0&&n!==c)break;(n!==0||s!==i)&&(c=n),s=e}return[{line:r,character:s},{line:r,character:i}]}function ci(e,t,n,r){if(n){for(let e of r)if(e>t)return e;return e.length}for(let e=r.length-1;e>=0;e--){let n=r[e];if(n<t)return n}return 0}function li(e){let t=[0],n=dt();if(n!==void 0){for(let r of n.segment(e))r.index>0&&t.push(r.index);return t}let r=0;for(let n of e)r>0&&t.push(r),r+=n.length;return t}function ui(e,t,n,r){let i=e.getLineLength(t);if(r){if(n>=i)return i;let r=e.offsetAt({line:t,character:0}),a=e.getTextSlice(r+n,r+i),o=dt();if(o!==void 0){for(let e of o.segment(a))return n+e.segment.length;return i}for(let e of a)return n+e.length;return i}if(n<=0)return 0;let a=e.offsetAt({line:t,character:0}),o=e.getTextSlice(a,a+n),s=0,c=dt();if(c!==void 0){for(let e of c.segment(o))s=e.index;return s}let l=0;for(let e of o)s=l,l+=e.length;return s}function di(e,t){let n=t.direction===-1;return[e.offsetAt(n?t.end:t.start),e.offsetAt(Y(t))]}function fi(e,t){if(!J(t))return{start:t.start,end:t.end};let{line:n,character:r}=t.start,i=e.getLineText(n).length;return r<i?{start:{line:n,character:r},end:{line:n,character:i}}:n<e.lineCount-1?{start:{line:n,character:r},end:{line:n+1,character:0}}:{start:{line:n,character:r},end:{line:n,character:r}}}function pi(e,t,n){if(t!==`
|
|
8
8
|
`&&t!==`\r`&&t!==`\r
|
|
9
|
-
`)return t;let r=e.positionAt(n).line,i=e.getLineText(r),a=mi(i);return a===0?t:t+i.slice(0,a)}function mi(e){let t=0;for(;t<e.length;t++){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}return t}function hi(e,t){let n=[];for(let[e,r]of t)n.push(Math.min(e,r),Math.max(e,r));let r=e.positionsAt(n);return t.map(([e,t],n)=>{let i=e===t?0:e<t?1:-1;return{start:r[n*2],end:r[n*2+1],direction:i}})}function gi(e,t,n){if(t.text!==``||t.start!==t.end-1)return t;let r=e.positionAt(t.end);if(r.character===0)return t;let i=e.getLineText(r.line),a=i.slice(0,r.character);if(/[^ \t]/.test(a)||i[r.character-1]===` `)return t;let o=Math.max(0,r.character-n),s=i.slice(o,r.character);return s.length===n&&/^ +$/.test(s)?{...t,start:t.end-s.length}:t}function _i(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n!==null&&Ti(n)===void 0;)n=n.parentElement;if(n===null)return null;let r=Ti(n);if(r===void 0)return null;if(e.nodeType===3)return e.parentElement===null?null:Ci(e.parentElement)===null?{line:r,character:Si(n,e)+Di(e.textContent,t)}:{line:r,character:wi(e,t)};if(e.nodeType===1){let i=e;if(i.tagName===`DIV`){let e=0;for(let n=0;n<t;n++)e=wi(i.childNodes[n]);return{line:r,character:e}}if(i.tagName===`BR`)return{line:r,character:0};if(i.tagName===`SPAN`){if(t<i.childNodes.length){let e=i.childNodes[t];if(e?.nodeType===1){let t=Ei(e);if(t!==void 0)return{line:r,character:t};let n=Ci(e),i=n===null?void 0:Ei(n);if(i!==void 0)return{line:r,character:i}}}return{line:r,character:t>0?wi(i.childNodes[t-1]):Si(n,i)}}return{line:r,character:Si(n,i)}}return null}function vi(e){let t=[];for(let n of e.childNodes){if(n.nodeType!==1)continue;let e=n;if(e.tagName===`SPAN`){if(Ei(e)!==void 0){t.push(e);continue}for(let n of e.childNodes)n.nodeType===1&&Ei(n)!==void 0&&t.push(n)}}return t}function yi(e,t){let n=Math.max(0,t),r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let t=e.container.childNodes[e.index];if(e.index++,t.nodeType===3){let e=Di(t.textContent,t.textContent?.length??0);if(n<=e)return[t,n];n-=e}else t.nodeType===1&&r.push({container:t,index:0})}return null}function bi(e,t){let n=0,r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let i=e.container.childNodes[e.index];if(i===t)return n;e.index++,i.nodeType===3?n+=Di(i.textContent,i.textContent?.length??0):i.nodeType===1&&r.push({container:i,index:0})}return n}function xi(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parentElement}return!1}function Si(e,t){if(t.parentElement===e){let n=0,r=Array.prototype.indexOf.call(e.childNodes,t);for(let t=0;t<r;t++)n=wi(e.childNodes[t]);return n}for(let n of vi(e))if(xi(n,t))return Ei(n)+(t.nodeType===3?bi(n,t):0);let n=0,r=t.nodeType===1?t:t.parentElement;for(;r!==null&&r.parentElement!==null&&Ti(r.parentElement)===void 0;){let e=r.parentElement,t=Array.prototype.indexOf.call(e.childNodes,r);for(let r=0;r<t;r++)n=wi(e.childNodes[r]);r=e}return n}function Ci(e){let t=e;for(;t!==null;){if(Ti(t)!==void 0)return null;if(Ei(t)!==void 0)return t;t=t.parentElement}return null}function wi(e,t){if(e===void 0)return 0;if(e.nodeType===3){let n=e.parentElement;if(n===null)return 0;let r=Ci(n);if(r===null)return 0;let i=Ei(r);if(i===void 0)return 0;let a=t===void 0?Di(e.textContent,e.textContent?.length??0):Di(e.textContent,t);return i+bi(r,e)+a}if(e.nodeType!==1)return 0;let n=e;if(n.tagName!==`SPAN`&&n.tagName!==`BR`)return 0;let r=Ei(n);if(r!==void 0)return r+(n.textContent?.length??0);let i=0;for(let e of n.childNodes)i=Math.max(i,wi(e));return i}function Ti(e){let{line:t,lineType:n}=e.dataset;if(t!==void 0&&n!==`change-deletion`){let e=parseInt(t,10);if(!Number.isNaN(e))return e-1}}function Ei(e){let{char:t}=e.dataset;if(t!==void 0){let e=parseInt(t,10);if(!Number.isNaN(e))return e}}function Di(e,t){let n=e??``,r=n.search(/[\r\n]/);return Math.min(t,r===-1?n.length:r)}var Oi=300,ki=100,Ai=`marker-popover`,ji=class{#e;#t=[];#n=0;#r;#i;#a;#o;#s;#c;#l;#u=!1;constructor(e){this.#e=e}get markers(){return this.#t}isPopoverVisible(){return this.#l!==void 0}updatePopoverPosition(){let e=this.#l,t=this.#r;if(e===void 0||t===void 0)return;let n=this.#t[e];if(n===void 0){this.removePopover();return}this.#_(t,n.start.line,n.start.character)}setMarkers(e,t){this.#n=t.lineCount,this.#t=e.map(e=>({...e,start:t.normalizePosition(e.start),end:t.normalizePosition(e.end)})),this.removePopover()}listenHover(e){this.#a?.forEach(e=>e()),this.#a=void 0,this.#t.length!==0&&(this.#a=[G(e,`mouseover`,e=>{if(this.#e.isMouseDown())return;let t=e.composedPath()[0];if(t===void 0)return;let n=this.#d(t);n===void 0?(this.#f(),this.#h()):this.#m(n)}),G(e,`mouseleave`,()=>{this.#f(),this.#h()})])}removePopover(){this.#f(),this.#p(),this.#v()}cleanup(){this.#a?.forEach(e=>e()),this.#a=void 0,this.removePopover(),this.#t=[]}#d(e){let t=e.closest(`[data-line]`);if(t==null)return;let n=W(t);if(n===void 0)return;let r;if(e.tagName===`SPAN`){let t=e.dataset.char;if(t===void 0||(r=parseInt(t,10),Number.isNaN(r)))return}else if(e.tagName===`BR`)r=0;else return;let i={line:n-1,character:r};for(let e=this.#t.length-1;e>=0;e--)if(Ir({start:i,end:i},this.#t[e]))return e}#f(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0),this.#c=void 0}#p(){this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#m(e){if(e===this.#l||e===this.#c){this.#p();return}if(this.#f(),this.#p(),this.#r!==void 0){this.#y(e);return}this.#c=e,this.#o=setTimeout(()=>{this.#o=void 0,this.#c=void 0,this.#y(e)},Oi)}#h(){this.#u||(this.#p(),this.#s=setTimeout(()=>{this.#s=void 0,this.#u||this.removePopover()},ki))}#g(e,t,n,r,i=this.#e.popoverManager.getPlacementBounds()){Zn(e,{gutterWidth:this.#e.getGutterWidth(),placeAbove:r,viewport:i,x:t,y:n})}#_(e,t,n){let{getCharX:r,getLineY:i,getLineHeight:a,popoverManager:o}=this.#e,[s,c]=r(t,n),l=a(),u=i(t)+c*l,d=e.offsetHeight,f={top:u+l,bottom:u+l+d},p={top:u-d,bottom:u},m=t>=this.#n-3,h=o.getPlacementBounds(),g=o.choosePlacement({preferred:f,fallback:p,viewport:h,popoverHeight:d,atDocumentEdge:m,placementKey:Ai})===`fallback`;this.#g(e,s,g?u:u+l,g,h)}#v(){this.#i?.forEach(e=>e()),this.#i=void 0,this.#r?.remove(),this.#r=void 0,this.#l=void 0,this.#u=!1,this.#e.popoverManager.resetPlacement(Ai)}#y(e){if(e===this.#l)return;let t=this.#e.getOverlayElement();if(e>=this.#t.length||t==null)return;let{start:n,message:r,severity:i}=this.#t[e],{line:a,character:o}=n,s=this.#r;if(this.#e.popoverManager.resetPlacement(Ai),s!==void 0){Ni(s,i);let t=s.firstElementChild;t?.dataset.markerMessage!==void 0&&(typeof r==`string`?t.textContent=r:r instanceof HTMLElement?t.replaceChildren(r):t.innerHTML=r.html),this.#_(s,a,o),this.#l=e;return}this.#r=U(`div`,{dataset:{editorWidget:``,markerPopover:``,[Pi(i)]:``},children:[U(`div`,{dataset:`markerMessage`,...typeof r==`string`?{textContent:r}:r instanceof HTMLElement?{children:[r]}:{innerHTML:r.html}})]},t),this.#_(this.#r,a,o),this.#l=e,this.#i=[G(this.#r,`mouseenter`,()=>{this.#u=!0,this.#p()}),G(this.#r,`mouseleave`,()=>{this.#u=!1,this.#h()})]}},Mi=[`error`,`warning`,`info`,`hint`];function Ni(e,t){for(let t of Mi)delete e.dataset[Pi(t)];e.dataset[Pi(t)]=``}function Pi(e){switch(e){case`error`:return`markerError`;case`warning`:return`markerWarning`;case`info`:return`markerInfo`;case`hint`:return`markerHint`}}function Fi(e){return{...e,oldFile:e.oldFile==null?null:{...e.oldFile,lines:[...e.oldFile.lines]},hunks:
|
|
10
|
-
`);return Gi.encode(v).byteLength<=Z?{hunk:v,bounds:o}:void 0}function Qi(e,t,n){let r=[],i=0;for(let a of n){let n=a.start-t,o=a.end-t;if(n<i||o<n||o>e.length)return;r.push(e.slice(i,n),a.text),i=o}return r.push(e.slice(i)),r.join(``)}function $i(e,t){let n=t.inverseEdits;if(n.length===0)return;let r=n[0].start,i=n[0].end;for(let e=1;e<n.length;e++)r=Math.min(r,n[e].start),i=Math.max(i,n[e].end);let[a,o]=e.positionsAt([r,i]);for(let t of Wi){let r=Math.max(0,a.line-t),i=Math.min(e.lineCount-1,o.line+t),s=e.offsetAt({line:r,character:0}),c=i+1<e.lineCount?e.offsetAt({line:i+1,character:0}):e.offsetAt({line:i,character:e.getLineLength(i)});if(c-s>Z)continue;let l=e.getTextSlice(s,c);if(Gi.encode(l).byteLength>Z)continue;let u=Qi(l,s,n);if(!(u===void 0||u.length>Z||Gi.encode(u).byteLength>Z))return{beforeText:u,afterText:l,startOffset:s,startLine:r,bounds:Xi(u,Ki(u),l,Ki(l))}}}function ea(e,t,n,r,i,a=Date.now()){let o=e.slice(-10),s=$i(n,r);if(s===void 0){let e=o.at(-1);return e?.fragment!==void 0&&(o[o.length-1]={...e,fragment:void 0}),o}if(s.beforeText===s.afterText)return o;let c=s.startLine+s.bounds.prefixLines,l=s.startLine+s.bounds.oldLineCount-s.bounds.suffixLines,u=o.at(-1),d=u!==void 0&&c>u.end?c-u.end:u!==void 0&&u.start>l?u.start-l:0;if(u!==void 0&&u.fragment!==void 0&&u.path===t&&u.source===i&&a-u.at<Vi&&d<=Hi){let e=u.fragment,n=s.startOffset+s.beforeText.length,c=Math.max(e.currentStart,s.startOffset),l=Math.min(e.currentEnd,n);if(c<=l&&e.currentText.slice(c-e.currentStart,l-e.currentStart)===s.beforeText.slice(c-s.startOffset,l-s.startOffset)){let c=Math.min(e.currentStart,s.startOffset),l=e.currentStart<=s.startOffset?e.currentText+s.beforeText.slice(Math.max(0,e.currentEnd-s.startOffset)):s.beforeText+e.currentText.slice(Math.max(0,n-e.currentStart)),u=l.slice(0,e.currentStart-c),d=l.slice(e.currentEnd-c),f=u+e.baseText+d,p=Qi(l,c,r.appliedEdits),m=e.currentStart<=s.startOffset?e.startLine:s.startLine;if(p!==void 0&&f.length<=Z&&p.length<=Z&&Gi.encode(f).byteLength<=Z&&Gi.encode(p).byteLength<=Z){if(f===p)return o.pop(),o;let e=Zi(t,f,p,m);if(e!==void 0)return o[o.length-1]={path:t,hunk:e.hunk,start:m+e.bounds.prefixLines,end:m+e.bounds.newLineCount-e.bounds.suffixLines,at:a,source:i,fragment:{baseText:f,currentText:p,currentStart:c,currentEnd:c+p.length,startLine:m}},o}}}let f=o.at(-1);f?.fragment!==void 0&&(o[o.length-1]={...f,fragment:void 0});let p=Zi(t,s.beforeText,s.afterText,s.startLine);return p===void 0?o:(o.push({path:t,hunk:p.hunk,start:c,end:s.startLine+s.bounds.newLineCount-s.bounds.suffixLines,at:a,source:i,fragment:{baseText:s.beforeText,currentText:s.afterText,currentStart:s.startOffset,currentEnd:s.startOffset+s.afterText.length,startLine:s.startLine}}),o.slice(-10))}function ta(e,t,n,r,i,a){for(;a>0&&(r>0||i<e-1);){let o=!1;if(r>0&&n(r-1)){let e=t(r-1);e<=a&&(r--,a-=e,o=!0)}if(i<e-1&&n(i+1)){let e=t(i+1);e<=a&&(i++,a-=e,o=!0)}if(!o)break}return{first:r,last:i}}function na(e,t,n,r,i){if(t.lineCount<=0)return;let a=t.lineCount-1,o=t.offsetAt({line:a,character:t.getLineLength(a)}),s=Math.max(0,Math.min(Number.isFinite(n)?Math.trunc(n):0,o)),c=t.charAt(s-1).charCodeAt(0),l=t.charAt(s).charCodeAt(0);s>0&&s<o&&(c===13&&l===10||c>=55296&&c<=56319&&l>=56320&&l<=57343)&&s--;let u=t.positionAt(s).line,d=new Map,f=e=>{if(e<0||e>=t.lineCount)return!1;let n=d.get(e);return n??(n=i(e),d.set(e,n)),n};if(!f(u))return;let p=new Map,m=e=>{let n=p.get(e);if(n!==void 0)return n;let r=t.getLineLength(e);if(Math.floor(r/3)>zi)return p.set(e,663),663;let i=Math.max(1,Math.floor(Gi.encode(t.getLineText(e)).byteLength/3));return p.set(e,i),i},h=u,g=u,_=Math.max(0,Math.floor(Ii*3/4)-m(u));for(;_>0&&(f(h-1)||f(g+1));){if(f(g+1)){let e=m(g+1);if(e>_)break;g++,_-=e}if(f(h-1)&&_>0){let e=m(h-1);if(e>_)break;h--,_-=e}}_+=88,{first:h,last:g}=ta(t.lineCount,m,f,h,g,_);let v=h,y=g;({first:v,last:y}=ta(t.lineCount,m,()=>!0,v,y,Li));let b=0;for(let e=h;e<=g;e++)b+=m(e);let x=0;for(let e=v;e<=y;e++)x+=m(e);if(b>Ri||x>zi)return;let S=t.offsetAt({line:v,character:0}),C=t.offsetAt({line:y,character:t.getLineLength(y)}),w=t.getTextSlice(S,C),T={path:e,version:t.version,eol:t.eol,excerptText:w,excerptStartLine:v,cursorOffsetInExcerpt:s-S,editableRange:{start:t.offsetAt({line:h,character:0})-S,end:t.offsetAt({line:g,character:t.getLineLength(g)})-S},editHistory:r.slice(-10).map(({hunk:e,source:t})=>({diff:e,source:t}))};return Gi.encode(JSON.stringify(T)).byteLength<=Bi?T:void 0}function ra(e,t){if(typeof t!=`string`)return new RegExp(t.source,t.flags).test(e);t=t.replaceAll(`\\`,`/`);let n=`^`;for(let e=0;e<t.length;e++){let r=t[e];r===`*`?t[e+1]===`*`?(e++,t[e+1]===`/`?(e++,n+=`(?:.*/)?`):n+=`.*`):n+=`[^/]*`:n+=r===`?`?`[^/]`:/[\\^$.*+?()[\]{}|]/.test(r)?`\\${r}`:r}return RegExp(`${n}$`).test(e)}function ia(e,t){let n=t.changedLineChanges?.some(([,,e])=>e!==0)===!0?[[t.startLine,t.endLine]]:t.changedLineRanges,r=new Map;for(let[t,i]of n){let n=Math.min(i,e.lineCount-1);if(n<t)continue;if(n===t){r.set(t,e.getLineText(t,!0));continue}let a=n+1<e.lineCount?{line:n+1,character:0}:{line:n,character:e.getLineText(n).length},o=e.getText({start:{line:t,character:0},end:a}),s=Je(o);for(let e=t;e<=n;e++)r.set(e,s[e-t])}return r}var aa=`//`,oa=[`/*`,`*/`],sa={sql:{lineComment:`--`},ruby:{lineComment:`#`,blockComment:[`=begin`,`=end`]},rst:{lineComment:`..`},coffeescript:{lineComment:`#`,blockComment:[`###`,`###`]},cmd:{lineComment:`@REM`},julia:{lineComment:`#`,blockComment:[`#=`,`=#`]},yaml:{lineComment:`#`},yml:{lineComment:`#`},markdown:{lineComment:null,blockComment:[`<!--`,`-->`]},zsh:{lineComment:`#`},makefile:{lineComment:`#`},handlebars:{lineComment:null,blockComment:[`{{!--`,`--}}`]},ini:{lineComment:`;`,blockComment:[`;`,` `]},powershell:{lineComment:`#`,blockComment:[`<#`,`#>`]},vb:{lineComment:`'`},xml:{lineComment:null,blockComment:[`<!--`,`-->`]},lua:{lineComment:`--`,blockComment:[`--[[`,`]]`]},html:{lineComment:null,blockComment:[`<!--`,`-->`]},diff:{lineComment:`#`,blockComment:[`#`,` `]},r:{lineComment:`#`},fsharp:{blockComment:[`(*`,`*)`]},pug:{lineComment:`//-`},perl:{lineComment:`#`},tex:{lineComment:`%`},clojure:{lineComment:`;;`},css:{lineComment:null},python:{lineComment:`#`,blockComment:[`"""`,`"""`]},dotenv:{lineComment:`#`},dockerfile:{lineComment:`#`},razor:{lineComment:null,blockComment:[`<!--`,`-->`]},prompt:{lineComment:null,blockComment:[`<!--`,`-->`]}};function ca(e,t){let n={...sa[e],...t?.[e]};return{lineComment:n.lineComment===void 0?aa:n.lineComment,blockComment:n.blockComment??oa}}function la(e,t,n){let r=[],i=new Set;for(let a of t){let t=a.end.line;a.start.line<t&&a.end.character===0&&t--;let o=r.length,s=1/0;for(let o=a.start.line;o<=t;o++){if(i.has(o))continue;i.add(o);let t=e.getLineText(o),a=t.length-t.trimStart().length,c=a===t.length;c||(s=Math.min(s,a)),r.push({line:o,comment:t.slice(a,a+n.length)===n?a:-1,empty:c,indent:a,single:!1})}if(s!==1/0)for(let e=o;e<r.length;e++)r[e].empty||(r[e].indent=s);r.length===o+1&&(r[o].single=!0)}let a=r.some(e=>e.comment<0&&(!e.empty||e.single)),o=[];if(a){for(let e of r){if(e.empty&&!e.single)continue;let t={line:e.line,character:e.indent};o.push({range:{start:t,end:t},newText:n+` `})}return o}for(let t of r){if(t.comment<0)continue;let r=e.getLineText(t.line),i=t.comment,a=i+n.length+ +(r[i+n.length]===` `);o.push({range:{start:{line:t.line,character:i},end:{line:t.line,character:a}},newText:``})}return o}var ua=50;function da(e,t,n,r,i){let a=Math.max(0,r-ua),o=e.getTextSlice(a,r),s=e.getTextSlice(i,i+ua),c=o.length-o.trimEnd().length,l=s.length-s.trimStart().length,u=o.length-c;if(o.slice(u-t.length,u)===t&&s.slice(l,l+n.length)===n)return{open:{start:r-c-t.length,end:r-c+ +(c>0),text:``},close:{start:i+l-+(l>0),end:i+l+n.length,text:``},contentStart:r,contentEnd:i};let d=i-r<=100?e.getTextSlice(r,i):void 0,f=d??e.getTextSlice(r,r+ua),p=d??e.getTextSlice(i-ua,i),m=f.length-f.trimStart().length,h=i-(p.length-p.trimEnd().length)-n.length;if(f.slice(m,m+t.length)!==t||e.getTextSlice(h,h+n.length)!==n)return;let g=r+m,_=g+t.length+ +!!/\s/.test(f[t.length+m]??``),v=h-+!!/\s/.test(e.getTextSlice(h-1,h));return{open:{start:g,end:_,text:``},close:{start:v,end:h+n.length,text:``},contentStart:_,contentEnd:v}}function fa(e,t,n,r){let i=0,a=t.length;for(;i<a;){let n=i+a>>>1;t[n].end<e?i=n+1:a=n}let o=n[i];for(let n=i;n<t.length;n++){let i=t[n];if(e<i.start)break;if(i.start===i.end&&e===i.start){if(r<0)break;o+=i.text.length;continue}if(e>i.end){o+=i.text.length-(i.end-i.start);continue}return e===i.end?i.start+o+i.text.length:i.start+o+(r>0?i.text.length:0)}return e+o}function pa(e,t,[n,r],i=!1){let a=t.map(t=>{let{start:n,end:r}=t;if(i){let t=r.line;n.line<t&&r.character===0&&t--;let i=e.getLineText(n.line),a=i.length-i.trimStart().length;n={line:n.line,character:a},r={line:t,character:e.getLineLength(t)}}return{from:e.offsetAt(n),to:e.offsetAt(r),direction:t.direction,comment:void 0}});if(i&&a.length>1){a.sort((e,t)=>{let n=e.from-t.from;return n===0?e.to-t.to:n});let e=0;for(let t=1;t<a.length;t++){let n=a[e],r=a[t];r.from<=n.to?n.to=Math.max(n.to,r.to):a[++e]=r}a.length=e+1}for(let t of a)t.comment=da(e,n,r,t.from,t.to);let o=a.every(e=>e.comment!==void 0),s=[];for(let e of a){let t=e.comment;if(o&&t!==void 0){s.push(t.open,t.close);continue}if(t===void 0){if(e.from===e.to){s.push({start:e.from,end:e.to,text:n+` `+r});continue}s.push({start:e.from,end:e.from,text:n+` `},{start:e.to,end:e.to,text:` `+r})}}if(s.length===0)return;s.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});let c=s.map(t=>({range:{start:e.positionAt(t.start),end:e.positionAt(t.end)},newText:t.text}));if(i)return{edits:c,nextSelectionOffsets:[]};let l=a.map(e=>{let t=e.comment;return o&&t!==void 0?{start:t.contentStart,end:t.contentEnd,startAssociation:1,endAssociation:-1}:t===void 0?e.from===e.to?{start:e.from,end:e.to,startAssociation:-1,endAssociation:-1,collapsedInset:n.length+1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:-1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:1}}),u=Array(s.length+1);u[0]=0;for(let e=0;e<s.length;e++){let t=s[e];u[e+1]=u[e]+t.text.length-(t.end-t.start)}return{edits:c,nextSelectionOffsets:l.map((e,t)=>{let n=fa(e.start,s,u,e.startAssociation)+(e.collapsedInset??0);return[n,e.collapsedInset===void 0?fa(e.end,s,u,e.endAssociation):n,a[t].direction]})}}var ma=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`]]),ha=new Map([...ma].map(([e,t])=>[t,e])),ga=1e3,_a=5e4;function va(e,t,n){let r=ya(e,t,e.normalizePosition(n));if(r===void 0)return;let i=ma.get(r.char),a=ha.get(r.char);if(i!==void 0)return Oa(r,Sa(e,t,r,i));if(a!==void 0)return Oa(Ca(e,t,r,a),r)}function ya(e,t,n){let r=ba(n);if(r!==void 0){let n=xa(e,t,r);if(n!==void 0)return n}return xa(e,t,n)}function ba(e){if(e.character>0)return{line:e.line,character:e.character-1}}function xa(e,t,n){let r=e.getLineText(n.line)[n.character];if(!(r===void 0||!ma.has(r)&&!ha.has(r)||wa(t,n)))return{...n,char:r}}function Sa(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s<e.lineCount;s++){if(a>=ga)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:0},d=s===n.line?n.character:0;for(let e=d;e<c.length;e++){if(o>=_a)return;if(o++,Ea(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function Ca(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s>=0;s--){if(a>=ga)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:l===null?-1:l.length-1},d=s===n.line?n.character:c.length-1;for(let e=d;e>=0;e--){if(o>=_a)return;if(o++,Da(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function wa(e,t){return Ta(e.getStringCommentRegexpRangesInLine(t.line),t.character)}function Ta(e,t){if(e===null)return!1;for(let[n,r]of e){if(t<n)return!1;if(t<r)return!0}return!1}function Ea(e,t,n){if(e===null)return!1;for(;n.index<e.length&&t>=e[n.index][1];)n.index++;let r=e[n.index];return r!==void 0&&t>=r[0]}function Da(e,t,n){if(e===null)return!1;for(;n.index>=0&&t<e[n.index][0];)n.index--;let r=e[n.index];return r!==void 0&&t<r[1]}function Oa(e,t){if(e!==void 0&&t!==void 0)return[ka(e),ka(t)]}function ka(e){return{start:{line:e.line,character:e.character},end:{line:e.line,character:e.character+1}}}var Aa=class{#e;#t;#n;constructor(e,t,n){this.#e=U(`div`,{dataset:{editorWidget:``,selectionActionPopover:``},contentEditable:`false`,children:[e]},t),this.#t=this.#e.offsetHeight,this.#n=new ResizeObserver(()=>{let e=this.#e.offsetHeight;e!==this.#t&&(this.#t=e,n())}),this.#n.observe(this.#e)}reposition(e,t,n,r,i,a){this.#e.style.visibility=i?``:`hidden`,Zn(this.#e,{gutterWidth:n,placeAbove:r,viewport:a,x:e,y:t})}get height(){return this.#t}cleanup(){this.#n.disconnect(),this.#e.remove()}},ja=4096,Ma=/\p{Mark}/u,Na=class{#e;#t;#n;#r;#i=new Map;ch=-1;tabSize=2;lineHeight=20;paddingTop=0;init(e){if(this.#e===e&&this.#n!==void 0&&this.ch!==-1)return;if(this.#e=e,this.#t??=U(`canvas`,{style:{display:`none`}}),this.#n??=this.#t.getContext(`2d`)??void 0,this.#n===void 0)throw Error(`Could not get canvas context`);let t=e.parentElement;if(t!==null){let{paddingTop:e}=getComputedStyle(t);e.endsWith(`px`)&&(this.paddingTop=parseFloat(e.slice(0,-2)))}let{fontSize:n,fontFamily:r,tabSize:i,lineHeight:a}=getComputedStyle(e);a.endsWith(`px`)?this.lineHeight=parseFloat(a.slice(0,-2)):n.endsWith(`px`)&&(this.lineHeight=nt(parseFloat(n.slice(0,-2))*parseFloat(a)));let o=n+` `+r;(this.#r!==o||this.ch===-1)&&(this.#r=o,this.#a(o),this.ch=this.canvasMeasureTextWidth(`0`),this.clearTextWidthCache());let s=parseInt(i,10);Number.isNaN(s)||(this.tabSize=s)}remeasureCharacterWidth(){if(this.#n===void 0||this.#r===void 0)return!1;this.#a(this.#r);let e=this.canvasMeasureTextWidth(`0`),t=e!==this.ch;t&&(this.ch=e);let n=this.#s();return t||n}#a(e){let t=this.#e,n=this.#t,r=this.#n;if(t==null||n==null||r==null)throw Error(`Metrics not initialized`);t.append(n);try{r.font=e}finally{n.remove()}}measureTextWidth(e){if(!e.includes(` `))return this.#o(e);if(this.#n===void 0)throw Error(`Metrics not initialized`);let t=La(e,this.tabSize);if(t!==-1)return t*this.ch;let n=0,r=0,i=this.tabSize*this.ch;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===9){if(t>r&&(n+=this.#o(e.slice(r,t))),i>0){let e=n%i;n+=e===0?i:i-e}r=t+1}return r<e.length&&(n+=this.#o(e.slice(r))),nt(n)}segmentTextWidth(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=La(r,this.tabSize);return i===-1?this.measureTextWidth(r):i*this.ch}#o(e){return Pa(e)?this.domMeasureTextWidth(e):this.canvasMeasureTextWidth(e)}canvasMeasureTextWidth(e){if(this.#n===void 0)throw Error(`Metrics not initialized`);return nt(this.#n.measureText(e).width)}domMeasureTextWidth(e){if(this.#e===void 0)throw Error(`Metrics not initialized`);let t=e+`|`+this.#r,n=this.#i.get(t);if(n!==void 0)return n;let r=U(`span`,{style:{position:`absolute`,top:`0`,left:`0`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre`,font:`inherit`},textContent:e},this.#e),i;try{i=nt(r.getBoundingClientRect().width)}finally{r.remove()}if(this.#i.size>=ja){let e=this.#i.keys().next().value;e!==void 0&&this.#i.delete(e)}return this.#i.set(t,i),i}clearTextWidthCache(){this.#s()}#s(){let e=this.#i.size>0;return this.#i.clear(),e}};function Pa(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=57343||n===8205||n===65038||n===65039||n>127&&Ma.test(e.charAt(t)))return!0}return!1}function Fa(e,t){let n=Math.max(0,Math.min(t,e.length));if(n===0||n===e.length||!Pa(e))return n;let r=dt();if(r!==void 0){for(let t of r.segment(e)){let e=t.index,r=e+t.segment.length;if(n>e&&n<r)return r;if(n<=e)break}return n}let i=0;for(let t of e){let e=i+t.length;if(n>i&&n<e)return e;if(n<=i)break;i=e}return n}function Ia(e){if(!Pa(e))return;let t=[0],n=dt();if(n!==void 0){for(let r of n.segment(e))t.push(r.index+r.segment.length);return t}let r=0;for(let n of e)r+=n.length,t.push(r);return t}function La(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i>127)return-1;n+=i===9?t-n%t:1}return n}var Ra=500,za=0,Ba=class{#e;#t;#n;#r=`dark`;#i=``;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=!1;#h=[L];#g=[];#_=0;#v=[];#y=-1;#b=!0;#x=!1;#S=0;#C=++za;#w=-1;#T=-1;#E;#D=0;#O=[];#k=!1;#A=K(async e=>{if(this.#m)return;let{startingLine:t=0,totalLines:n=1/0}=e??{},r=Math.min(n===1/0?1/0:t+n,this.#o.lineCount);if(this.#t===void 0&&!Ua(this.#o.languageId)){if(await this.#e.loadLanguage(this.#o.languageId),this.#m)return;this.#t=this.#e.getLanguage(this.#o.languageId)}this.#F(),this.#V(r)},500);#j=({data:e})=>{if(typeof e!=`object`||!e)return;let{type:t,tokenizerId:n,jobId:r}=e;t===`tokenize`&&n===this.#C&&typeof r==`number`&&r===this.#S&&(this.#w>=0?this.#q(r):this.#J(r))};get themeType(){return this.#r}getStringCommentRegexpRangesInLine(e){if(!this.#d||e<0||e>=this.#o.lineCount||(this.#I(),this.#t===void 0))return null;if(this.#O[e]===void 0){this.#K(e);let t=this.#h[e]??L,n=this.#H(e,t);this.#h[e+1]=n.state}return this.#O[e]??null}constructor({codeOptions:e,highlighter:t,textDocument:n,matchBrackets:r,setStyle:i,onDeferTokenize:a,onThemeChange:o,__debug:s}){let{themeType:c=`system`,theme:l=R,tokenizeMaxLineLength:u=1e3}=e;this.#n=window.matchMedia(`(prefers-color-scheme: dark)`);let d;if(d=c===`system`?this.#N():c,typeof l!=`string`&&c===`system`){let e=new MutationObserver(e=>{for(let{type:t,attributeName:n}of e)if(t===`attributes`&&n!==null&&(n===`class`||n.startsWith(`data-`))){let e=this.#N();this.#M(l[e],e);break}});e.observe(document.documentElement,{attributes:!0}),e.observe(document.body,{attributes:!0}),this.#p=[G(this.#n,`change`,()=>{let e=this.#N();this.#M(l[e],e)}),()=>e.disconnect()]}this.#e=t,this.#o=n,this.#s=u,this.#c=i,this.#l=a,this.#u=o,this.#d=r!==!1,this.#f=s??!1,this.#I(),this.#a=[],this.#P(typeof l==`string`?l:l[d],typeof l==`string`?void 0:d)}#M(e,t){(e!==this.#i||t!==this.#r)&&(this.#P(e,t),this.stopBackgroundTokenize(),this.#h=[L],this.#g=[],this.#_=0,this.#v=[],this.#t!==void 0&&this.#o.lineCount>0&&this.#B(0),this.#u?.())}#N(){try{if(typeof document<`u`&&typeof getComputedStyle==`function`&&document.body!=null){let e=getComputedStyle(document.body).colorScheme.split(/\s+/),t=e.includes(`dark`);if(t!==e.includes(`light`))return t?`dark`:`light`}}catch{}return this.#n.matches?`dark`:`light`}syncTheme(e){let{themeType:t=`system`,theme:n=R}=e;if(typeof n==`string`){let e=this.#e.getTheme(n).type;if(n===this.#i&&e===this.#r)return;this.#M(n,e);return}let r=t===`system`?this.#N():t,i=n[r];(r!==this.#r||i!==this.#i)&&this.#M(i,r)}#P(e,t){let{theme:n,colorMap:r}=this.#e.setTheme(e),{colors:i={}}=this.#e.getTheme(e),a=i[`editor.selectionBackground`],o=i[`editor.lineHighlightBackground`],s=o!=null&&o.trim()!==``&&!Sn.isFullyTransparent(o)?o:void 0,c=i[`editor.lineHighlightBorder`]??(s==null?`color-mix(in lab, var(--diffs-bg) 70%, var(--diffs-fg))`:`transparent`),l=s==null?`100%`:`85%`,u=i[`editorCursor.foreground`],d=i[`editor.findMatchBackground`],f=i[`editor.findMatchHighlightBackground`],p=i[`editorBracketMatch.background`],m=i[`editorBracketMatch.border`],h=i[`editorHint.foreground`],g=i[`editorInfo.foreground`],_=i[`editorWarning.foreground`],v=i[`editorError.foreground`];this.#c(`:host {
|
|
9
|
+
`)return t;let r=e.positionAt(n).line,i=e.getLineText(r),a=mi(i);return a===0?t:t+i.slice(0,a)}function mi(e){let t=0;for(;t<e.length;t++){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}return t}function hi(e,t){let n=[];for(let[e,r]of t)n.push(Math.min(e,r),Math.max(e,r));let r=e.positionsAt(n);return t.map(([e,t],n)=>{let i=e===t?0:e<t?1:-1;return{start:r[n*2],end:r[n*2+1],direction:i}})}function gi(e,t,n){if(t.text!==``||t.start!==t.end-1)return t;let r=e.positionAt(t.end);if(r.character===0)return t;let i=e.getLineText(r.line),a=i.slice(0,r.character);if(/[^ \t]/.test(a)||i[r.character-1]===` `)return t;let o=Math.max(0,r.character-n),s=i.slice(o,r.character);return s.length===n&&/^ +$/.test(s)?{...t,start:t.end-s.length}:t}function _i(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n!==null&&Ti(n)===void 0;)n=n.parentElement;if(n===null)return null;let r=Ti(n);if(r===void 0)return null;if(e.nodeType===3)return e.parentElement===null?null:Ci(e.parentElement)===null?{line:r,character:Si(n,e)+Di(e.textContent,t)}:{line:r,character:wi(e,t)};if(e.nodeType===1){let i=e;if(i.tagName===`DIV`){let e=0;for(let n=0;n<t;n++)e=wi(i.childNodes[n]);return{line:r,character:e}}if(i.tagName===`BR`)return{line:r,character:0};if(i.tagName===`SPAN`){if(t<i.childNodes.length){let e=i.childNodes[t];if(e?.nodeType===1){let t=Ei(e);if(t!==void 0)return{line:r,character:t};let n=Ci(e),i=n===null?void 0:Ei(n);if(i!==void 0)return{line:r,character:i}}}return{line:r,character:t>0?wi(i.childNodes[t-1]):Si(n,i)}}return{line:r,character:Si(n,i)}}return null}function vi(e){let t=[];for(let n of e.childNodes){if(n.nodeType!==1)continue;let e=n;if(e.tagName===`SPAN`){if(Ei(e)!==void 0){t.push(e);continue}for(let n of e.childNodes)n.nodeType===1&&Ei(n)!==void 0&&t.push(n)}}return t}function yi(e,t){let n=Math.max(0,t),r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let t=e.container.childNodes[e.index];if(e.index++,t.nodeType===3){let e=Di(t.textContent,t.textContent?.length??0);if(n<=e)return[t,n];n-=e}else t.nodeType===1&&r.push({container:t,index:0})}return null}function bi(e,t){let n=0,r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let i=e.container.childNodes[e.index];if(i===t)return n;e.index++,i.nodeType===3?n+=Di(i.textContent,i.textContent?.length??0):i.nodeType===1&&r.push({container:i,index:0})}return n}function xi(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parentElement}return!1}function Si(e,t){if(t.parentElement===e){let n=0,r=Array.prototype.indexOf.call(e.childNodes,t);for(let t=0;t<r;t++)n=wi(e.childNodes[t]);return n}for(let n of vi(e))if(xi(n,t))return Ei(n)+(t.nodeType===3?bi(n,t):0);let n=0,r=t.nodeType===1?t:t.parentElement;for(;r!==null&&r.parentElement!==null&&Ti(r.parentElement)===void 0;){let e=r.parentElement,t=Array.prototype.indexOf.call(e.childNodes,r);for(let r=0;r<t;r++)n=wi(e.childNodes[r]);r=e}return n}function Ci(e){let t=e;for(;t!==null;){if(Ti(t)!==void 0)return null;if(Ei(t)!==void 0)return t;t=t.parentElement}return null}function wi(e,t){if(e===void 0)return 0;if(e.nodeType===3){let n=e.parentElement;if(n===null)return 0;let r=Ci(n);if(r===null)return 0;let i=Ei(r);if(i===void 0)return 0;let a=t===void 0?Di(e.textContent,e.textContent?.length??0):Di(e.textContent,t);return i+bi(r,e)+a}if(e.nodeType!==1)return 0;let n=e;if(n.tagName!==`SPAN`&&n.tagName!==`BR`)return 0;let r=Ei(n);if(r!==void 0)return r+(n.textContent?.length??0);let i=0;for(let e of n.childNodes)i=Math.max(i,wi(e));return i}function Ti(e){let{line:t,lineType:n}=e.dataset;if(t!==void 0&&n!==`change-deletion`){let e=parseInt(t,10);if(!Number.isNaN(e))return e-1}}function Ei(e){let{char:t}=e.dataset;if(t!==void 0){let e=parseInt(t,10);if(!Number.isNaN(e))return e}}function Di(e,t){let n=e??``,r=n.search(/[\r\n]/);return Math.min(t,r===-1?n.length:r)}var Oi=300,ki=100,Ai=`marker-popover`,ji=class{#e;#t=[];#n=0;#r;#i;#a;#o;#s;#c;#l;#u=!1;constructor(e){this.#e=e}get markers(){return this.#t}isPopoverVisible(){return this.#l!==void 0}updatePopoverPosition(){let e=this.#l,t=this.#r;if(e===void 0||t===void 0)return;let n=this.#t[e];if(n===void 0){this.removePopover();return}this.#_(t,n.start.line,n.start.character)}setMarkers(e,t){this.#n=t.lineCount,this.#t=e.map(e=>({...e,start:t.normalizePosition(e.start),end:t.normalizePosition(e.end)})),this.removePopover()}listenHover(e){this.#a?.forEach(e=>e()),this.#a=void 0,this.#t.length!==0&&(this.#a=[G(e,`mouseover`,e=>{if(this.#e.isMouseDown())return;let t=e.composedPath()[0];if(t===void 0)return;let n=this.#d(t);n===void 0?(this.#f(),this.#h()):this.#m(n)}),G(e,`mouseleave`,()=>{this.#f(),this.#h()})])}removePopover(){this.#f(),this.#p(),this.#v()}cleanup(){this.#a?.forEach(e=>e()),this.#a=void 0,this.removePopover(),this.#t=[]}#d(e){let t=e.closest(`[data-line]`);if(t==null)return;let n=W(t);if(n===void 0)return;let r;if(e.tagName===`SPAN`){let t=e.dataset.char;if(t===void 0||(r=parseInt(t,10),Number.isNaN(r)))return}else if(e.tagName===`BR`)r=0;else return;let i={line:n-1,character:r};for(let e=this.#t.length-1;e>=0;e--)if(Ir({start:i,end:i},this.#t[e]))return e}#f(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0),this.#c=void 0}#p(){this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#m(e){if(e===this.#l||e===this.#c){this.#p();return}if(this.#f(),this.#p(),this.#r!==void 0){this.#y(e);return}this.#c=e,this.#o=setTimeout(()=>{this.#o=void 0,this.#c=void 0,this.#y(e)},Oi)}#h(){this.#u||(this.#p(),this.#s=setTimeout(()=>{this.#s=void 0,this.#u||this.removePopover()},ki))}#g(e,t,n,r,i=this.#e.popoverManager.getPlacementBounds()){Zn(e,{gutterWidth:this.#e.getGutterWidth(),placeAbove:r,viewport:i,x:t,y:n})}#_(e,t,n){let{getCharX:r,getLineY:i,getLineHeight:a,popoverManager:o}=this.#e,[s,c]=r(t,n),l=a(),u=i(t)+c*l,d=e.offsetHeight,f={top:u+l,bottom:u+l+d},p={top:u-d,bottom:u},m=t>=this.#n-3,h=o.getPlacementBounds(),g=o.choosePlacement({preferred:f,fallback:p,viewport:h,popoverHeight:d,atDocumentEdge:m,placementKey:Ai})===`fallback`;this.#g(e,s,g?u:u+l,g,h)}#v(){this.#i?.forEach(e=>e()),this.#i=void 0,this.#r?.remove(),this.#r=void 0,this.#l=void 0,this.#u=!1,this.#e.popoverManager.resetPlacement(Ai)}#y(e){if(e===this.#l)return;let t=this.#e.getOverlayElement();if(e>=this.#t.length||t==null)return;let{start:n,message:r,severity:i}=this.#t[e],{line:a,character:o}=n,s=this.#r;if(this.#e.popoverManager.resetPlacement(Ai),s!==void 0){Ni(s,i);let t=s.firstElementChild;t?.dataset.markerMessage!==void 0&&(typeof r==`string`?t.textContent=r:r instanceof HTMLElement?t.replaceChildren(r):t.innerHTML=r.html),this.#_(s,a,o),this.#l=e;return}this.#r=U(`div`,{dataset:{editorWidget:``,markerPopover:``,[Pi(i)]:``},children:[U(`div`,{dataset:`markerMessage`,...typeof r==`string`?{textContent:r}:r instanceof HTMLElement?{children:[r]}:{innerHTML:r.html}})]},t),this.#_(this.#r,a,o),this.#l=e,this.#i=[G(this.#r,`mouseenter`,()=>{this.#u=!0,this.#p()}),G(this.#r,`mouseleave`,()=>{this.#u=!1,this.#h()})]}},Mi=[`error`,`warning`,`info`,`hint`];function Ni(e,t){for(let t of Mi)delete e.dataset[Pi(t)];e.dataset[Pi(t)]=``}function Pi(e){switch(e){case`error`:return`markerError`;case`warning`:return`markerWarning`;case`info`:return`markerInfo`;case`hint`:return`markerHint`}}function Fi(e){return{...e,oldFile:e.oldFile==null?null:{...e.oldFile,lines:[...e.oldFile.lines]},hunks:tt(e.hunks)}}var Ii=350,Li=150,Ri=512,zi=662,Bi=131072,Z=6144,Vi=1e3,Hi=8,Ui=3,Wi=[11,Ui],Gi=new TextEncoder;function Ki(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===13&&e.charCodeAt(n+1)===10&&n++,(e.charCodeAt(n)===10||e.charCodeAt(n)===13)&&t.push(n+1);return t}function qi(e,t){return e.length===0?0:t.at(-1)===e.length?t.length-1:t.length}function Ji(e,t,n){let r=t[n+1];return r===void 0?e.length:r-(e.charCodeAt(r-1)===10&&e.charCodeAt(r-2)===13?2:1)}function Yi(e,t,n,r,i,a){let o=t[n],s=i[a],c=Ji(e,t,n)-o;if(c!==Ji(r,i,a)-s)return!1;for(let t=0;t<c;t++)if(e.charCodeAt(o+t)!==r.charCodeAt(s+t))return!1;return!0}function Xi(e,t,n,r){let i=qi(e,t),a=qi(n,r),o=0;for(;o<i&&o<a&&Yi(e,t,o,n,r,o);)o++;let s=0;for(;s<i-o&&s<a-o&&Yi(e,t,i-1-s,n,r,a-1-s);)s++;return{oldLineCount:i,newLineCount:a,prefixLines:o,suffixLines:s}}function Zi(e,t,n,r=0){if(t===n)return;let i=Ki(t),a=Ki(n),o=Xi(t,i,n,a);if(o.prefixLines===o.oldLineCount&&o.prefixLines===o.newLineCount)return;let s=o.oldLineCount-o.suffixLines,c=o.newLineCount-o.suffixLines,l=t.slice(i[o.prefixLines]??t.length,i[s]??t.length),u=n.slice(a[o.prefixLines]??n.length,a[c]??n.length);if(Gi.encode(l).byteLength>Z||Gi.encode(u).byteLength>Z)return;let d=Math.max(0,o.prefixLines-Ui),f=Math.min(o.oldLineCount,s+Ui),p=Math.min(o.newLineCount,c+Ui),m=f-d,h=p-d,g=d+r,_=[`--- a/${e}`,`+++ b/${e}`,`@@ -${m===0?g:g+1},${m} +${h===0?g:g+1},${h} @@`];for(let e=d;e<o.prefixLines;e++)_.push(` ${t.slice(i[e],Ji(t,i,e))}`);for(let e=o.prefixLines;e<s;e++)_.push(`-${t.slice(i[e],Ji(t,i,e))}`);for(let e=o.prefixLines;e<c;e++)_.push(`+${n.slice(a[e],Ji(n,a,e))}`);for(let e=s;e<f;e++)_.push(` ${t.slice(i[e],Ji(t,i,e))}`);let v=_.join(`
|
|
10
|
+
`);return Gi.encode(v).byteLength<=Z?{hunk:v,bounds:o}:void 0}function Qi(e,t,n){let r=[],i=0;for(let a of n){let n=a.start-t,o=a.end-t;if(n<i||o<n||o>e.length)return;r.push(e.slice(i,n),a.text),i=o}return r.push(e.slice(i)),r.join(``)}function $i(e,t){let n=t.inverseEdits;if(n.length===0)return;let r=n[0].start,i=n[0].end;for(let e=1;e<n.length;e++)r=Math.min(r,n[e].start),i=Math.max(i,n[e].end);let[a,o]=e.positionsAt([r,i]);for(let t of Wi){let r=Math.max(0,a.line-t),i=Math.min(e.lineCount-1,o.line+t),s=e.offsetAt({line:r,character:0}),c=i+1<e.lineCount?e.offsetAt({line:i+1,character:0}):e.offsetAt({line:i,character:e.getLineLength(i)});if(c-s>Z)continue;let l=e.getTextSlice(s,c);if(Gi.encode(l).byteLength>Z)continue;let u=Qi(l,s,n);if(!(u===void 0||u.length>Z||Gi.encode(u).byteLength>Z))return{beforeText:u,afterText:l,startOffset:s,startLine:r,bounds:Xi(u,Ki(u),l,Ki(l))}}}function ea(e,t,n,r,i,a=Date.now()){let o=e.slice(-10),s=$i(n,r);if(s===void 0){let e=o.at(-1);return e?.fragment!==void 0&&(o[o.length-1]={...e,fragment:void 0}),o}if(s.beforeText===s.afterText)return o;let c=s.startLine+s.bounds.prefixLines,l=s.startLine+s.bounds.oldLineCount-s.bounds.suffixLines,u=o.at(-1),d=u!==void 0&&c>u.end?c-u.end:u!==void 0&&u.start>l?u.start-l:0;if(u!==void 0&&u.fragment!==void 0&&u.path===t&&u.source===i&&a-u.at<Vi&&d<=Hi){let e=u.fragment,n=s.startOffset+s.beforeText.length,c=Math.max(e.currentStart,s.startOffset),l=Math.min(e.currentEnd,n);if(c<=l&&e.currentText.slice(c-e.currentStart,l-e.currentStart)===s.beforeText.slice(c-s.startOffset,l-s.startOffset)){let c=Math.min(e.currentStart,s.startOffset),l=e.currentStart<=s.startOffset?e.currentText+s.beforeText.slice(Math.max(0,e.currentEnd-s.startOffset)):s.beforeText+e.currentText.slice(Math.max(0,n-e.currentStart)),u=l.slice(0,e.currentStart-c),d=l.slice(e.currentEnd-c),f=u+e.baseText+d,p=Qi(l,c,r.appliedEdits),m=e.currentStart<=s.startOffset?e.startLine:s.startLine;if(p!==void 0&&f.length<=Z&&p.length<=Z&&Gi.encode(f).byteLength<=Z&&Gi.encode(p).byteLength<=Z){if(f===p)return o.pop(),o;let e=Zi(t,f,p,m);if(e!==void 0)return o[o.length-1]={path:t,hunk:e.hunk,start:m+e.bounds.prefixLines,end:m+e.bounds.newLineCount-e.bounds.suffixLines,at:a,source:i,fragment:{baseText:f,currentText:p,currentStart:c,currentEnd:c+p.length,startLine:m}},o}}}let f=o.at(-1);f?.fragment!==void 0&&(o[o.length-1]={...f,fragment:void 0});let p=Zi(t,s.beforeText,s.afterText,s.startLine);return p===void 0?o:(o.push({path:t,hunk:p.hunk,start:c,end:s.startLine+s.bounds.newLineCount-s.bounds.suffixLines,at:a,source:i,fragment:{baseText:s.beforeText,currentText:s.afterText,currentStart:s.startOffset,currentEnd:s.startOffset+s.afterText.length,startLine:s.startLine}}),o.slice(-10))}function ta(e,t,n,r,i,a){for(;a>0&&(r>0||i<e-1);){let o=!1;if(r>0&&n(r-1)){let e=t(r-1);e<=a&&(r--,a-=e,o=!0)}if(i<e-1&&n(i+1)){let e=t(i+1);e<=a&&(i++,a-=e,o=!0)}if(!o)break}return{first:r,last:i}}function na(e,t,n,r,i){if(t.lineCount<=0)return;let a=t.lineCount-1,o=t.offsetAt({line:a,character:t.getLineLength(a)}),s=Math.max(0,Math.min(Number.isFinite(n)?Math.trunc(n):0,o)),c=t.charAt(s-1).charCodeAt(0),l=t.charAt(s).charCodeAt(0);s>0&&s<o&&(c===13&&l===10||c>=55296&&c<=56319&&l>=56320&&l<=57343)&&s--;let u=t.positionAt(s).line,d=new Map,f=e=>{if(e<0||e>=t.lineCount)return!1;let n=d.get(e);return n??(n=i(e),d.set(e,n)),n};if(!f(u))return;let p=new Map,m=e=>{let n=p.get(e);if(n!==void 0)return n;let r=t.getLineLength(e);if(Math.floor(r/3)>zi)return p.set(e,663),663;let i=Math.max(1,Math.floor(Gi.encode(t.getLineText(e)).byteLength/3));return p.set(e,i),i},h=u,g=u,_=Math.max(0,Math.floor(Ii*3/4)-m(u));for(;_>0&&(f(h-1)||f(g+1));){if(f(g+1)){let e=m(g+1);if(e>_)break;g++,_-=e}if(f(h-1)&&_>0){let e=m(h-1);if(e>_)break;h--,_-=e}}_+=88,{first:h,last:g}=ta(t.lineCount,m,f,h,g,_);let v=h,y=g;({first:v,last:y}=ta(t.lineCount,m,()=>!0,v,y,Li));let b=0;for(let e=h;e<=g;e++)b+=m(e);let x=0;for(let e=v;e<=y;e++)x+=m(e);if(b>Ri||x>zi)return;let S=t.offsetAt({line:v,character:0}),C=t.offsetAt({line:y,character:t.getLineLength(y)}),w=t.getTextSlice(S,C),T={path:e,version:t.version,eol:t.eol,excerptText:w,excerptStartLine:v,cursorOffsetInExcerpt:s-S,editableRange:{start:t.offsetAt({line:h,character:0})-S,end:t.offsetAt({line:g,character:t.getLineLength(g)})-S},editHistory:r.slice(-10).map(({hunk:e,source:t})=>({diff:e,source:t}))};return Gi.encode(JSON.stringify(T)).byteLength<=Bi?T:void 0}function ra(e,t){if(typeof t!=`string`)return new RegExp(t.source,t.flags).test(e);t=t.replaceAll(`\\`,`/`);let n=`^`;for(let e=0;e<t.length;e++){let r=t[e];r===`*`?t[e+1]===`*`?(e++,t[e+1]===`/`?(e++,n+=`(?:.*/)?`):n+=`.*`):n+=`[^/]*`:n+=r===`?`?`[^/]`:/[\\^$.*+?()[\]{}|]/.test(r)?`\\${r}`:r}return RegExp(`${n}$`).test(e)}function ia(e,t){let n=t.changedLineChanges?.some(([,,e])=>e!==0)===!0?[[t.startLine,t.endLine]]:t.changedLineRanges,r=new Map;for(let[t,i]of n){let n=Math.min(i,e.lineCount-1);if(n<t)continue;if(n===t){r.set(t,e.getLineText(t,!0));continue}let a=n+1<e.lineCount?{line:n+1,character:0}:{line:n,character:e.getLineText(n).length},o=e.getText({start:{line:t,character:0},end:a}),s=Ye(o);for(let e=t;e<=n;e++)r.set(e,s[e-t])}return r}var aa=`//`,oa=[`/*`,`*/`],sa={sql:{lineComment:`--`},ruby:{lineComment:`#`,blockComment:[`=begin`,`=end`]},rst:{lineComment:`..`},coffeescript:{lineComment:`#`,blockComment:[`###`,`###`]},cmd:{lineComment:`@REM`},julia:{lineComment:`#`,blockComment:[`#=`,`=#`]},yaml:{lineComment:`#`},yml:{lineComment:`#`},markdown:{lineComment:null,blockComment:[`<!--`,`-->`]},zsh:{lineComment:`#`},makefile:{lineComment:`#`},handlebars:{lineComment:null,blockComment:[`{{!--`,`--}}`]},ini:{lineComment:`;`,blockComment:[`;`,` `]},powershell:{lineComment:`#`,blockComment:[`<#`,`#>`]},vb:{lineComment:`'`},xml:{lineComment:null,blockComment:[`<!--`,`-->`]},lua:{lineComment:`--`,blockComment:[`--[[`,`]]`]},html:{lineComment:null,blockComment:[`<!--`,`-->`]},diff:{lineComment:`#`,blockComment:[`#`,` `]},r:{lineComment:`#`},fsharp:{blockComment:[`(*`,`*)`]},pug:{lineComment:`//-`},perl:{lineComment:`#`},tex:{lineComment:`%`},clojure:{lineComment:`;;`},css:{lineComment:null},python:{lineComment:`#`,blockComment:[`"""`,`"""`]},dotenv:{lineComment:`#`},dockerfile:{lineComment:`#`},razor:{lineComment:null,blockComment:[`<!--`,`-->`]},prompt:{lineComment:null,blockComment:[`<!--`,`-->`]}};function ca(e,t){let n={...sa[e],...t?.[e]};return{lineComment:n.lineComment===void 0?aa:n.lineComment,blockComment:n.blockComment??oa}}function la(e,t,n){let r=[],i=new Set;for(let a of t){let t=a.end.line;a.start.line<t&&a.end.character===0&&t--;let o=r.length,s=1/0;for(let o=a.start.line;o<=t;o++){if(i.has(o))continue;i.add(o);let t=e.getLineText(o),a=t.length-t.trimStart().length,c=a===t.length;c||(s=Math.min(s,a)),r.push({line:o,comment:t.slice(a,a+n.length)===n?a:-1,empty:c,indent:a,single:!1})}if(s!==1/0)for(let e=o;e<r.length;e++)r[e].empty||(r[e].indent=s);r.length===o+1&&(r[o].single=!0)}let a=r.some(e=>e.comment<0&&(!e.empty||e.single)),o=[];if(a){for(let e of r){if(e.empty&&!e.single)continue;let t={line:e.line,character:e.indent};o.push({range:{start:t,end:t},newText:n+` `})}return o}for(let t of r){if(t.comment<0)continue;let r=e.getLineText(t.line),i=t.comment,a=i+n.length+ +(r[i+n.length]===` `);o.push({range:{start:{line:t.line,character:i},end:{line:t.line,character:a}},newText:``})}return o}var ua=50;function da(e,t,n,r,i){let a=Math.max(0,r-ua),o=e.getTextSlice(a,r),s=e.getTextSlice(i,i+ua),c=o.length-o.trimEnd().length,l=s.length-s.trimStart().length,u=o.length-c;if(o.slice(u-t.length,u)===t&&s.slice(l,l+n.length)===n)return{open:{start:r-c-t.length,end:r-c+ +(c>0),text:``},close:{start:i+l-+(l>0),end:i+l+n.length,text:``},contentStart:r,contentEnd:i};let d=i-r<=100?e.getTextSlice(r,i):void 0,f=d??e.getTextSlice(r,r+ua),p=d??e.getTextSlice(i-ua,i),m=f.length-f.trimStart().length,h=i-(p.length-p.trimEnd().length)-n.length;if(f.slice(m,m+t.length)!==t||e.getTextSlice(h,h+n.length)!==n)return;let g=r+m,_=g+t.length+ +!!/\s/.test(f[t.length+m]??``),v=h-+!!/\s/.test(e.getTextSlice(h-1,h));return{open:{start:g,end:_,text:``},close:{start:v,end:h+n.length,text:``},contentStart:_,contentEnd:v}}function fa(e,t,n,r){let i=0,a=t.length;for(;i<a;){let n=i+a>>>1;t[n].end<e?i=n+1:a=n}let o=n[i];for(let n=i;n<t.length;n++){let i=t[n];if(e<i.start)break;if(i.start===i.end&&e===i.start){if(r<0)break;o+=i.text.length;continue}if(e>i.end){o+=i.text.length-(i.end-i.start);continue}return e===i.end?i.start+o+i.text.length:i.start+o+(r>0?i.text.length:0)}return e+o}function pa(e,t,[n,r],i=!1){let a=t.map(t=>{let{start:n,end:r}=t;if(i){let t=r.line;n.line<t&&r.character===0&&t--;let i=e.getLineText(n.line),a=i.length-i.trimStart().length;n={line:n.line,character:a},r={line:t,character:e.getLineLength(t)}}return{from:e.offsetAt(n),to:e.offsetAt(r),direction:t.direction,comment:void 0}});if(i&&a.length>1){a.sort((e,t)=>{let n=e.from-t.from;return n===0?e.to-t.to:n});let e=0;for(let t=1;t<a.length;t++){let n=a[e],r=a[t];r.from<=n.to?n.to=Math.max(n.to,r.to):a[++e]=r}a.length=e+1}for(let t of a)t.comment=da(e,n,r,t.from,t.to);let o=a.every(e=>e.comment!==void 0),s=[];for(let e of a){let t=e.comment;if(o&&t!==void 0){s.push(t.open,t.close);continue}if(t===void 0){if(e.from===e.to){s.push({start:e.from,end:e.to,text:n+` `+r});continue}s.push({start:e.from,end:e.from,text:n+` `},{start:e.to,end:e.to,text:` `+r})}}if(s.length===0)return;s.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});let c=s.map(t=>({range:{start:e.positionAt(t.start),end:e.positionAt(t.end)},newText:t.text}));if(i)return{edits:c,nextSelectionOffsets:[]};let l=a.map(e=>{let t=e.comment;return o&&t!==void 0?{start:t.contentStart,end:t.contentEnd,startAssociation:1,endAssociation:-1}:t===void 0?e.from===e.to?{start:e.from,end:e.to,startAssociation:-1,endAssociation:-1,collapsedInset:n.length+1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:-1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:1}}),u=Array(s.length+1);u[0]=0;for(let e=0;e<s.length;e++){let t=s[e];u[e+1]=u[e]+t.text.length-(t.end-t.start)}return{edits:c,nextSelectionOffsets:l.map((e,t)=>{let n=fa(e.start,s,u,e.startAssociation)+(e.collapsedInset??0);return[n,e.collapsedInset===void 0?fa(e.end,s,u,e.endAssociation):n,a[t].direction]})}}var ma=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`]]),ha=new Map([...ma].map(([e,t])=>[t,e])),ga=1e3,_a=5e4;function va(e,t,n){let r=ya(e,t,e.normalizePosition(n));if(r===void 0)return;let i=ma.get(r.char),a=ha.get(r.char);if(i!==void 0)return Oa(r,Sa(e,t,r,i));if(a!==void 0)return Oa(Ca(e,t,r,a),r)}function ya(e,t,n){let r=ba(n);if(r!==void 0){let n=xa(e,t,r);if(n!==void 0)return n}return xa(e,t,n)}function ba(e){if(e.character>0)return{line:e.line,character:e.character-1}}function xa(e,t,n){let r=e.getLineText(n.line)[n.character];if(!(r===void 0||!ma.has(r)&&!ha.has(r)||wa(t,n)))return{...n,char:r}}function Sa(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s<e.lineCount;s++){if(a>=ga)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:0},d=s===n.line?n.character:0;for(let e=d;e<c.length;e++){if(o>=_a)return;if(o++,Ea(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function Ca(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s>=0;s--){if(a>=ga)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:l===null?-1:l.length-1},d=s===n.line?n.character:c.length-1;for(let e=d;e>=0;e--){if(o>=_a)return;if(o++,Da(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function wa(e,t){return Ta(e.getStringCommentRegexpRangesInLine(t.line),t.character)}function Ta(e,t){if(e===null)return!1;for(let[n,r]of e){if(t<n)return!1;if(t<r)return!0}return!1}function Ea(e,t,n){if(e===null)return!1;for(;n.index<e.length&&t>=e[n.index][1];)n.index++;let r=e[n.index];return r!==void 0&&t>=r[0]}function Da(e,t,n){if(e===null)return!1;for(;n.index>=0&&t<e[n.index][0];)n.index--;let r=e[n.index];return r!==void 0&&t<r[1]}function Oa(e,t){if(e!==void 0&&t!==void 0)return[ka(e),ka(t)]}function ka(e){return{start:{line:e.line,character:e.character},end:{line:e.line,character:e.character+1}}}var Aa=class{#e;#t;#n;constructor(e,t,n){this.#e=U(`div`,{dataset:{editorWidget:``,selectionActionPopover:``},contentEditable:`false`,children:[e]},t),this.#t=this.#e.offsetHeight,this.#n=new ResizeObserver(()=>{let e=this.#e.offsetHeight;e!==this.#t&&(this.#t=e,n())}),this.#n.observe(this.#e)}reposition(e,t,n,r,i,a){this.#e.style.visibility=i?``:`hidden`,Zn(this.#e,{gutterWidth:n,placeAbove:r,viewport:a,x:e,y:t})}get height(){return this.#t}cleanup(){this.#n.disconnect(),this.#e.remove()}},ja=4096,Ma=/\p{Mark}/u,Na=class{#e;#t;#n;#r;#i=new Map;ch=-1;tabSize=2;lineHeight=20;paddingTop=0;init(e){if(this.#e===e&&this.#n!==void 0&&this.ch!==-1)return;if(this.#e=e,this.#t??=U(`canvas`,{style:{display:`none`}}),this.#n??=this.#t.getContext(`2d`)??void 0,this.#n===void 0)throw Error(`Could not get canvas context`);let t=e.parentElement;if(t!==null){let{paddingTop:e}=getComputedStyle(t);e.endsWith(`px`)&&(this.paddingTop=parseFloat(e.slice(0,-2)))}let{fontSize:n,fontFamily:r,tabSize:i,lineHeight:a}=getComputedStyle(e);a.endsWith(`px`)?this.lineHeight=parseFloat(a.slice(0,-2)):n.endsWith(`px`)&&(this.lineHeight=rt(parseFloat(n.slice(0,-2))*parseFloat(a)));let o=n+` `+r;(this.#r!==o||this.ch===-1)&&(this.#r=o,this.#a(o),this.ch=this.canvasMeasureTextWidth(`0`),this.clearTextWidthCache());let s=parseInt(i,10);Number.isNaN(s)||(this.tabSize=s)}remeasureCharacterWidth(){if(this.#n===void 0||this.#r===void 0)return!1;this.#a(this.#r);let e=this.canvasMeasureTextWidth(`0`),t=e!==this.ch;t&&(this.ch=e);let n=this.#s();return t||n}#a(e){let t=this.#e,n=this.#t,r=this.#n;if(t==null||n==null||r==null)throw Error(`Metrics not initialized`);t.append(n);try{r.font=e}finally{n.remove()}}measureTextWidth(e){if(!e.includes(` `))return this.#o(e);if(this.#n===void 0)throw Error(`Metrics not initialized`);let t=La(e,this.tabSize);if(t!==-1)return t*this.ch;let n=0,r=0,i=this.tabSize*this.ch;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===9){if(t>r&&(n+=this.#o(e.slice(r,t))),i>0){let e=n%i;n+=e===0?i:i-e}r=t+1}return r<e.length&&(n+=this.#o(e.slice(r))),rt(n)}segmentTextWidth(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=La(r,this.tabSize);return i===-1?this.measureTextWidth(r):i*this.ch}#o(e){return Pa(e)?this.domMeasureTextWidth(e):this.canvasMeasureTextWidth(e)}canvasMeasureTextWidth(e){if(this.#n===void 0)throw Error(`Metrics not initialized`);return rt(this.#n.measureText(e).width)}domMeasureTextWidth(e){if(this.#e===void 0)throw Error(`Metrics not initialized`);let t=e+`|`+this.#r,n=this.#i.get(t);if(n!==void 0)return n;let r=U(`span`,{style:{position:`absolute`,top:`0`,left:`0`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre`,font:`inherit`},textContent:e},this.#e),i;try{i=rt(r.getBoundingClientRect().width)}finally{r.remove()}if(this.#i.size>=ja){let e=this.#i.keys().next().value;e!==void 0&&this.#i.delete(e)}return this.#i.set(t,i),i}clearTextWidthCache(){this.#s()}#s(){let e=this.#i.size>0;return this.#i.clear(),e}};function Pa(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=57343||n===8205||n===65038||n===65039||n>127&&Ma.test(e.charAt(t)))return!0}return!1}function Fa(e,t){let n=Math.max(0,Math.min(t,e.length));if(n===0||n===e.length||!Pa(e))return n;let r=dt();if(r!==void 0){for(let t of r.segment(e)){let e=t.index,r=e+t.segment.length;if(n>e&&n<r)return r;if(n<=e)break}return n}let i=0;for(let t of e){let e=i+t.length;if(n>i&&n<e)return e;if(n<=i)break;i=e}return n}function Ia(e){if(!Pa(e))return;let t=[0],n=dt();if(n!==void 0){for(let r of n.segment(e))t.push(r.index+r.segment.length);return t}let r=0;for(let n of e)r+=n.length,t.push(r);return t}function La(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i>127)return-1;n+=i===9?t-n%t:1}return n}var Ra=500,za=0,Ba=class{#e;#t;#n;#r=`dark`;#i=``;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=!1;#h=[I];#g=[];#_=0;#v=[];#y=-1;#b=!0;#x=!1;#S=0;#C=++za;#w=-1;#T=-1;#E;#D=0;#O=[];#k=!1;#A=K(async e=>{if(this.#m)return;let{startingLine:t=0,totalLines:n=1/0}=e??{},r=Math.min(n===1/0?1/0:t+n,this.#o.lineCount);if(this.#t===void 0&&!Ua(this.#o.languageId)){if(await this.#e.loadLanguage(this.#o.languageId),this.#m)return;this.#t=this.#e.getLanguage(this.#o.languageId)}this.#F(),this.#V(r)},500);#j=({data:e})=>{if(typeof e!=`object`||!e)return;let{type:t,tokenizerId:n,jobId:r}=e;t===`tokenize`&&n===this.#C&&typeof r==`number`&&r===this.#S&&(this.#w>=0?this.#q(r):this.#J(r))};get themeType(){return this.#r}getStringCommentRegexpRangesInLine(e){if(!this.#d||e<0||e>=this.#o.lineCount||(this.#I(),this.#t===void 0))return null;if(this.#O[e]===void 0){this.#K(e);let t=this.#h[e]??I,n=this.#H(e,t);this.#h[e+1]=n.state}return this.#O[e]??null}constructor({codeOptions:e,highlighter:t,textDocument:n,matchBrackets:r,setStyle:i,onDeferTokenize:a,onThemeChange:o,__debug:s}){let{themeType:c=`system`,theme:l=L,tokenizeMaxLineLength:u=1e3}=e;this.#n=window.matchMedia(`(prefers-color-scheme: dark)`);let d;if(d=c===`system`?this.#N():c,typeof l!=`string`&&c===`system`){let e=new MutationObserver(e=>{for(let{type:t,attributeName:n}of e)if(t===`attributes`&&n!==null&&(n===`class`||n.startsWith(`data-`))){let e=this.#N();this.#M(l[e],e);break}});e.observe(document.documentElement,{attributes:!0}),e.observe(document.body,{attributes:!0}),this.#p=[G(this.#n,`change`,()=>{let e=this.#N();this.#M(l[e],e)}),()=>e.disconnect()]}this.#e=t,this.#o=n,this.#s=u,this.#c=i,this.#l=a,this.#u=o,this.#d=r!==!1,this.#f=s??!1,this.#I(),this.#a=[],this.#P(typeof l==`string`?l:l[d],typeof l==`string`?void 0:d)}#M(e,t){(e!==this.#i||t!==this.#r)&&(this.#P(e,t),this.stopBackgroundTokenize(),this.#h=[I],this.#g=[],this.#_=0,this.#v=[],this.#t!==void 0&&this.#o.lineCount>0&&this.#B(0),this.#u?.())}#N(){try{if(typeof document<`u`&&typeof getComputedStyle==`function`&&document.body!=null){let e=getComputedStyle(document.body).colorScheme.split(/\s+/),t=e.includes(`dark`);if(t!==e.includes(`light`))return t?`dark`:`light`}}catch{}return this.#n.matches?`dark`:`light`}syncTheme(e){let{themeType:t=`system`,theme:n=L}=e;if(typeof n==`string`){let e=this.#e.getTheme(n).type;if(n===this.#i&&e===this.#r)return;this.#M(n,e);return}let r=t===`system`?this.#N():t,i=n[r];(r!==this.#r||i!==this.#i)&&this.#M(i,r)}#P(e,t){let{theme:n,colorMap:r}=this.#e.setTheme(e),{colors:i={}}=this.#e.getTheme(e),a=i[`editor.selectionBackground`],o=i[`editor.lineHighlightBackground`],s=o!=null&&o.trim()!==``&&!Sn.isFullyTransparent(o)?o:void 0,c=i[`editor.lineHighlightBorder`]??(s==null?`color-mix(in lab, var(--diffs-bg) 70%, var(--diffs-fg))`:`transparent`),l=s==null?`100%`:`85%`,u=i[`editorCursor.foreground`],d=i[`editor.findMatchBackground`],f=i[`editor.findMatchHighlightBackground`],p=i[`editorBracketMatch.background`],m=i[`editorBracketMatch.border`],h=i[`editorHint.foreground`],g=i[`editorInfo.foreground`],_=i[`editorWarning.foreground`],v=i[`editorError.foreground`];this.#c(`:host {
|
|
11
11
|
--diffs-editor-selection-bg: ${a??`var(--diffs-line-bg)`};
|
|
12
12
|
--diffs-editor-line-highlight-border: ${c};
|
|
13
13
|
--diffs-editor-active-line-source-mix: ${l};
|
|
@@ -20,15 +20,15 @@ import{a as e,t}from"./react-DH3P2YXY.js";import{n,t as r}from"./jsx-runtime-Bnj
|
|
|
20
20
|
--diffs-editor-info-fg: ${g??`initial`};
|
|
21
21
|
--diffs-editor-warning-fg: ${_??`initial`};
|
|
22
22
|
--diffs-editor-error-fg: ${v??`initial`};
|
|
23
|
-
}`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!Ua(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??L;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??L;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1;continue}b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!Ua(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(Ua(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=Va(this.#t,this.#a,n,t,Ra,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??L;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=Va(this.#t,this.#a,e,a,Ra,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);if(!(this.#b||this.#x||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#y=this.#h.length-1,this.#z(e)}}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??L,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=Va(this.#t,this.#a,r,o,Ra,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e);return}this.#y=a,this.#D=c,this.#z(e)}}};function Va(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=Ae.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&Ae.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ha(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?U(`br`):n:U(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function Ua(e){return e===`text`||e===`ansi`}function Wa(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Ga(e,t){let n=Ze(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Ka(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var qa=2,Ja=1e4,Ya=300,Xa=256,Za=131072,Qa=new TextEncoder,$a=`selection-action`,eo=`application/vnd.pierre.diffs-selections+json`,to=class{type;#e;#t;#n;#r=new Na;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ha(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=no({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Yn.releaseFile(a,t):Yn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=zr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Kn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return qn(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return X(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(Y(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);if(e.length===0){this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[]);return}this.#U??=new ji({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt()}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,z(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Kn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Yn.releaseFile(t,n):Yn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:Fi(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??hn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Ga(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new kn({maxEntries:this.#e.historyMaxEntries});n=new Vn(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Ba({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=ot(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=zr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Ka(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new Xn({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(z(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,B(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return st(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=U(`style`,{dataset:`editorGlobalCss`,textContent:`
|
|
23
|
+
}`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!Ua(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??I;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??I;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1;continue}b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!Ua(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(Ua(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=Va(this.#t,this.#a,n,t,Ra,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??I;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=Va(this.#t,this.#a,e,a,Ra,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);if(!(this.#b||this.#x||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#y=this.#h.length-1,this.#z(e)}}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??I,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=Va(this.#t,this.#a,r,o,Ra,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e);return}this.#y=a,this.#D=c,this.#z(e)}}};function Va(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=je.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&je.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ha(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?U(`br`):n:U(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function Ua(e){return e===`text`||e===`ansi`}function Wa(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Ga(e,t){let n=Qe(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Ka(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var qa=2,Ja=1e4,Ya=300,Xa=256,Za=131072,Qa=new TextEncoder,$a=`selection-action`,eo=`application/vnd.pierre.diffs-selections+json`,to=class{type;#e;#t;#n;#r=new Na;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ha(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=no({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Yn.releaseFile(a,t):Yn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=zr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Kn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return qn(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return X(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(Y(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);if(e.length===0){this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[]);return}this.#U??=new ji({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt()}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,R(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Kn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Yn.releaseFile(t,n):Yn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:Fi(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??gn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Ga(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new kn({maxEntries:this.#e.historyMaxEntries});n=new Vn(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Ba({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=ot(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=zr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Ka(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new Xn({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(R(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,z(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return st(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=U(`style`,{dataset:`editorGlobalCss`,textContent:`
|
|
24
24
|
[data-annotation-slot] {
|
|
25
25
|
user-select: none;
|
|
26
26
|
-webkit-user-select: none;
|
|
27
27
|
}
|
|
28
|
-
`}),this.#y=U(`style`,{dataset:`editorCss`,textContent:ft}),this.#b=U(`style`,{dataset:`editorThemeCss`}),this.#x=ut(),this.#E=U(`div`,{dataset:`editorOverlay`});let e=e=>{let t=e.composedPath()[0];return t instanceof Node&&this.#w?.contains(t)===!0},t=()=>{this.#Z!=null&&(this.#Z=void 0,this.#X=!1,this.#J=!1)},n=e=>{if(e.pointerType!==`mouse`)return;let t=this.#$;this.#Ke(),t&&this.#ut(),this.#e.enabledSelectionAction===!0&&this.#se!==void 0&&this.#se.length>0&&!J(this.#se.at(-1))&&this.#Wt(this.#se)};this.#s=[G(document,`focusin`,n=>{e(n)||t()},{passive:!0}),G(document,`pointerdown`,n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),G(document,`selectionchange`,()=>{let e=this.#S?.shadowRoot;if(this.#J||this.#Y||e==null||!this.#X||this.#se!==void 0&&this.#se.length>1&&!this.#ee)return;let t=document.getSelection();if(t==null)return;let n;if(n=typeof t.getComposedRanges==`function`?t.getComposedRanges({shadowRoots:[e]})?.[0]:Wa(e),n===void 0||!this.#Cn(n))return;let r=mr(n,0);if(r!==void 0){if(this.#ee&&this.#ne&&this.#se!==void 0&&this.#se.length>0){let e=this.#se.at(-1);this.#Wt([Vr(e,r)]);return}if(this.#re!==void 0)r.direction=Br(this.#re,r).direction;else if(this.#ee)this.#re=r;else if(this.#se!==void 0&&this.#se.length===1){let e=this.#se[0];X(e.start,r.start)===0&&X(e.end,r.end)===0&&(r.direction=e.direction)}this.#te!==void 0&&(this.#te.focusLine=Y(r).line,this.#kt())||(this.#ae===void 0?this.#Wt([r]):this.#Wt([...this.#ae.filter(e=>!Ir(e,r)),r]))}},{passive:!0}),G(document,`pointerup`,n,{passive:!0}),G(document,`pointercancel`,n,{passive:!0}),G(document,`keydown`,e=>{e.key===`Shift`?this.#re=this.#se?.at(-1):e.key===`Alt`&&!e.repeat&&this.#X&&this.#e.editPrediction?.mode===`subtle`&&(this.#ye=!this.#ye,this.#Wt(this.#se??[]))},{passive:!0}),G(document,`keyup`,e=>{e.key===`Shift`&&(this.#re=void 0)},{passive:!0})]}#Ke(){this.#c?.forEach(e=>e()),this.#c=void 0,this.#J=!1,this.#$=!1,this.#ee=!1,this.#te=void 0,this.#ne=!1,this.#re=void 0,this.#ae=void 0}#qe(e){this.#c?.forEach(e=>e()),this.#c=e}#Je(){return this.#M?.options.enableLineSelection===!0}#Ye(){this.#Y=this.#se!==void 0}#Xe(e,t){let{onFocus:n,onBlur:r}=this.#e,i=t=>{let n=t.composedPath()[0];return n!==void 0&&(n===e||e.contains(n))};this.#o?.forEach(e=>e()),this.#o=[G(e,`focus`,()=>{this.#X=!0,n?.(),!this.#ee&&!this.#J&&this.#se!==void 0&&this.#se.length>0&&this.#ht(this.#se.at(-1))},{passive:!0}),G(e,`blur`,()=>{this.#Z?.target===e&&(this.#Z=void 0,this.#J=!1),this.#X=!1,r?.()},{passive:!0}),G(e,`pointerdown`,t=>{if(this.#q=!0,this.#Y=!1,t.pointerType!==`mouse`)return;if(this.#te=void 0,this.#bt(t)){this.#Et(!0),this.#se!==void 0&&this.#Wt([]);return}this.#Et(!1),this.#U?.removePopover();let n=[];if(Fe()&&this.#R!==void 0&&this.#R.length>0){let t=[...e.querySelectorAll(`[data-line-annotation]`)].map(e=>[G(e,`mouseenter`,()=>{this.#J=!0}),G(e,`mouseleave`,()=>{this.#J=!1})]).flat();n.push(...t)}this.#ee=!0;let r=t.button===0&&t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(this.#re=void 0,r?(this.#te={pointerId:t.pointerId,startClientX:t.clientX,clientX:t.clientX,startScrollLeft:e.parentElement?.scrollLeft??0},this.#ae=void 0,this.#se=void 0,this.#Wt([]),n.push(G(document,`pointermove`,e=>{let t=this.#te;t!==void 0&&e.pointerType===`mouse`&&e.pointerId===t.pointerId&&(t.clientX=e.clientX,this.#kt())},{capture:!0,passive:!0}))):t.button===0&&tt(t)&&(this.#ae=this.#se?.map(e=>({...e}))),this.#qe(n),t.shiftKey){let e=this.#se?.at(-1);if(e!==void 0){let t=e.direction===-1?e.end:e.start;this.#ht({start:t,end:t,direction:0})}this.#ne=!0}},{passive:!0}),G(e,`keydown`,e=>{if(!i(e)||(this.#q=!0,this.#Y=!1,e.isComposing||e.keyCode===229))return;if(e.key===`Tab`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&!this.#Q&&(!e.altKey||this.#e.editPrediction?.mode===`subtle`)&&this.#xe?.rendered===!0){this.#Ht(),e.preventDefault();return}if(e.key===`Escape`&&this.#xe!==void 0){this.#Rt(!0),e.preventDefault();return}let t=gt(e,this.#e.keymap);if(t!==void 0){e.preventDefault(),t===`simplifySelection`&&(this.#G?.close(),this.#G=void 0,this.#pe=!1,this.#K?.cleanup(),this.#K=void 0),this.#et(t);return}let n=ht(e),r=this.#n?.document;if(this.#se!==void 0&&this.#se.length>0&&n!==void 0&&r!==void 0){let t={getSoftLineOffsets:this.#Le?e=>this.#Sn(e):void 0,resolveRenderableLine:this.#Ne};e.shiftKey?this.#Wt(Sr(r,this.#se,n,t)):this.#Wt(gr(r,this.#se,n,t)),this.#gt(),e.preventDefault();return}if((e.key.length===1?e.key.toLowerCase():e.key)===`v`&&tt(e)){if(e.repeat&&this.#Ie){e.preventDefault();return}if(this.#e.clipboard!==void 0){e.preventDefault(),B(this.#Ze);return}}if(this.#G!==void 0){let t=rt(e);if(t!==void 0){e.preventDefault(),this.#G.navigate(t===`previous`);return}}}),G(e,`copy`,e=>{i(e)&&(e.preventDefault(),this.#wt()?e.clipboardData?.setData(`text`,this.#Tt()):this.#nn(e.clipboardData,this.#en(),this.#tn()))}),G(e,`cut`,e=>{if(i(e)){if(e.preventDefault(),this.#wt())e.clipboardData?.setData(`text`,this.#Tt());else{let t=this.#tn();this.#nn(e.clipboardData,this.#rn(),t)}}}),G(e,`paste`,e=>{if(!i(e))return;e.preventDefault();let t=e.clipboardData,n=this.#n?.document;if(t===null||n===void 0)return;let r=t.getData(`text`),a=this.#se?.length??0;if(a>1){let e=t.getData(eo);if(e!==void 0)try{let t=JSON.parse(e);Array.isArray(t)&&t.length===a&&(r=t)}catch{}}this.#an(Array.isArray(r)?r.map(e=>n.normalizeEol(e)):n.normalizeEol(r),void 0,!0,`document`)}),G(e,`beforeinput`,e=>{if(i(e)){if(e.inputType===`insertCompositionText`){this.#Rt(!0);return}e.preventDefault(),this.#lt(e.inputType,e.data)}}),G(e,`drop`,e=>{i(e)&&e.preventDefault()}),G(e,`compositionstart`,e=>{i(e)&&(this.#Rt(!0),this.#Q=!0,this.#J=!0)},{passive:!0}),G(e,`compositionend`,e=>{if(!i(e))return;this.#J=!1;let t=this.#Q;this.#Q=!1,(e.data!==``||!t)&&this.#lt(`insertText`,e.data)},{passive:!0})];let a=this.#S?.shadowRoot?.querySelector(`[data-deletions]`);if(a!=null&&this.#o.push(G(a,`pointerdown`,e=>{let t=e.composedPath();if(Pe(t)){this.#Ye();return}let n=t[0],r=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(r instanceof HTMLElement){if(this.#Je()){this.#Ye();return}if(this.#Ct(r,a,e.pointerType===`mouse`))return}this.#Et(!0),this.#se!==void 0&&this.#Wt([])},{passive:!0})),t!==void 0){let e=(e,t=!1)=>{let n=e;return n?.dataset.lineNumberContent===void 0?t&&n?.tagName===`SPAN`&&(n=n.closest(`[data-line]`)):n=n.parentElement??void 0,n},n=e=>{if(e===void 0)return;let t=e.dataset.lineType,n=W(e)??W(e,`columnNumber`);if(n!==void 0&&t!==void 0&&Fr(t))return n-1};this.#o.push(G(t,`pointerdown`,t=>{let r=t.composedPath();if(Pe(r)){this.#Ye();return}let i=e(r[0]);if(i!==void 0&&this.#Je()){this.#Ye();return}if(i?.dataset.lineType===`change-deletion`){let e=i.closest(`[data-code]`);e!=null&&this.#Ct(i,e,t.pointerType===`mouse`);return}if(t.pointerType!==`mouse`)return;let a=this.#n?.document,o=n(i);if(o===void 0||a===void 0)return;this.#q=!0,this.#U?.removePopover();let s=this.#yt(o,o,a);this.#$=!0,this.#re=s,this.#Wt([s]),this.#ht(s),this.#ut(),this.#qe([G(document,`mousemove`,t=>{if(!this.#$)return;let r=this.#n?.document,i=n(e(t.composedPath()[0],!0));if(i===void 0||r===void 0)return;let a=this.#re?.start.line??i,o=this.#yt(a,i,r);this.#re??=o,this.#Wt([o]),this.#ut(o.direction===-1?o.start:o.end)},{passive:!0})])},{passive:!0}))}this.#U?.listenHover(e),this.#j?.disconnect(),this.#j=new ResizeObserver(this.#ot),this.#j.observe(e),this.#j.observe(e.parentElement),this.#Qe(e)}#Ze=async()=>{let e=this.#e.clipboard;if(e!==void 0){let t=await e.readText(),n=this.#se?.length??0;if(n>1){let r=await e.readText(eo);try{let e=JSON.parse(r);Array.isArray(e)&&e.length===n&&(t=e)}catch{}}let r=this.#n?.document;r!=null&&this.#an(Array.isArray(t)?t.map(e=>r.normalizeEol(e)):r.normalizeEol(t),void 0,!0,`document`)}};#Qe(e){this.#Ie&&this.#Fe===`split`&&this.#Le&&(this.#d={top:e.offsetTop-this.#r.paddingTop,left:e.offsetLeft-this.#_n()},this.#e.__debug===!0&&console.log(`[diffs/editor] content offset:`,this.#d))}get#$e(){if(this.#Ie&&this.#Fe===`split`&&this.#Le)return this.#d}#et(e){let t=this.#n?.document;if(t!=null)switch(e){case`openSearchPanel`:this.#Qt(`find`);break;case`openSearchReplacePanel`:this.#Qt(`replace`);break;case`findNextMatch`:{let e=this.#se;if(e===void 0)break;if(e.some(J)){let n=e.map(e=>J(e)?ai(t,e):e);this.#Wt(n),this.focus()}else{let n=Kr(t,e);if(n!==void 0){this.#Wt(n);let e=n.at(-1);e!==void 0&&this.#Pe(Y(e).line),this.#gt()}}break}case`moveLineUp`:case`moveLineDown`:this.#at(e===`moveLineUp`?-1:1);break;case`copyLineUp`:case`copyLineDown`:this.#rt(e===`copyLineUp`?-1:1);break;case`simplifySelection`:{let e=this.#se,t=e?.at(-1);if(e===void 0||t===void 0)break;if(e.length>1)this.#Wt([t]),this.#ut(Y(t));else if(!J(t)){let e=Y(t);this.#Wt([{start:e,end:e,direction:0}]),this.#ut(e)}break}case`insertBlankLine`:this.#it();break;case`deleteHardLineForward`:this.#ln();break;case`toggleComment`:case`toggleBlockComment`:{let n=this.#se;if(n===void 0)break;let{lineComment:r,blockComment:i}=ca(t.languageId,this.#e.languageCommentConfig);if(e===`toggleComment`&&r!==null){this.#nt(la(t,n,r));break}let a=e===`toggleComment`,o=pa(t,n,i,a);o!==void 0&&this.#nt(o.edits,a?void 0:e=>o.nextSelectionOffsets.map(([t,n,r])=>({start:e.positionAt(t),end:e.positionAt(n),direction:r})));break}case`indent`:case`outdent`:case`indentLess`:case`indentMore`:if(this.#se!==void 0){let n=[],r=[],i=new Set,a=[];for(let o of this.#se){let s=o.start.line,c=e===`outdent`||e===`indentLess`,l=e===`indentLess`||e===`indentMore`;if(s!==o.end.line||c||l){let e=hr(t,o,this.#r.tabSize,c);for(let t of e[0]){let e=t.range.start.line;i.has(e)||(i.add(e),n.push(t))}r.push(e[1])}else{let e=t.charAt({line:s,character:0})===` `?` `:` `.repeat(this.#r.tabSize);n.push({range:o,newText:e}),a.push({line:s,startCharacter:o.start.character,addedLength:e.length-(o.end.character-o.start.character),selectionIndex:r.length});let i={line:o.start.line,character:o.start.character+e.length};r.push({start:i,end:i,direction:0})}}for(let e of a){let t=0;for(let n of a)n.line===e.line&&n.startCharacter<e.startCharacter&&(t+=n.addedLength);if(t!==0){let n=r[e.selectionIndex],i={line:e.line,character:n.start.character+t};r[e.selectionIndex]={start:i,end:i,direction:0}}}let o=t.applyEdits(n,!0,this.#se,r);o!==void 0&&this.#dn(o,r)}break;case`selectAll`:{let e=qr(t);this.#Wt([e]),this.focus();let n=this.#mn(),r=n[0]?.[0],i=n.at(-1)?.[1];r!==void 0&&i!==void 0&&(this.#Y=!0,this.#ht({start:{line:r,character:0},end:{line:i,character:t.getLineLength(i)},direction:1}));break}case`moveCursorToDocStart`:case`moveCursorToDocEnd`:{let n=Jr(t,e===`moveCursorToDocEnd`,this.#Ie);this.#Wt([n]),this.#Pe(Y(n).line),this.#gt()}break;case`expandSelectionDocStart`:case`expandSelectionDocEnd`:{let n=e===`expandSelectionDocEnd`,r=this.#se;if(r!==void 0){let e=Jr(t,n,this.#Ie);this.#Wt(Hr(r,e)),this.#Pe(Y(e).line),this.#gt()}}break;case`undo`:case`redo`:this.#tt(e)}}#tt(e){let t=this.#n?.document;if(t==null||e===`undo`&&!t.canUndo||e===`redo`&&!t.canRedo)return;let n=this.#se,r=n?.map(e=>[t.offsetAt(e.start),t.offsetAt(e.end)]),i=e===`undo`?t.undo():t.redo();if(i===void 0)return;let[a,o,s,c]=i,l=o??(n!==void 0&&r!==void 0&&c!==void 0?zr(t,n,r,c):void 0),u=s??(this.#R==null?void 0:$n(a,this.#R));this.#dn(a,l,u)}#nt(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0)return;let i=t===void 0,a=i?r.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]):void 0,o=i?e.map(e=>{let t=n.offsetAt(e.range.start),r=n.offsetAt(e.range.end);return{start:Math.min(t,r),end:Math.max(t,r),text:e.newText}}).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n}):void 0,s=n.applyEdits(e,!0,r,void 0,!0);if(s===void 0)return;let c=i?zr(n,r,a,o):t(n);n.setLastUndoSelectionsAfter(c),this.#dn(s,c,this.#pn(s))}#rt(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Wr(n);if(r.length===0)return;let i=[],a=0,o=[];for(let n of r){i.push(a);let r=n.endLine-n.startLine+1;a+=r;let s=t.getText({start:{line:n.startLine,character:0},end:{line:n.endLine,character:t.getLineLength(n.endLine)}});if(e>0){let e={line:n.startLine,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else if(n.endLine<t.lineCount-1){let e={line:n.endLine+1,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else{let e={line:n.endLine,character:t.getLineLength(n.endLine)};o.push({range:{start:e,end:e},newText:t.eol+s})}}let s=n.map(t=>{let n=t.start.line,a=0,o=r.length-1;for(;a<=o;){let e=a+o>>>1,t=r[e];if(n<t.startLine)o=e-1;else if(n>t.endLine)a=e+1;else{a=e;break}}let s=Math.max(0,a<=o?a:o),c=r[s],l=i[s]+(e>0?c.endLine-c.startLine+1:0);return{start:{...t.start,line:t.start.line+l},end:{...t.end,line:t.end.line+l},direction:t.direction}});this.#nt(o,()=>s)}#it(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0)return;let n=t.map(e=>Y(e).line),r=Array.from(new Set(n)).sort((e,t)=>e-t),i=new Map,a=new Map,o=[];for(let t=0;t<r.length;t++){let n=r[t],s=e.getLineText(n),c=/^\s*/.exec(s)?.[0]??``;i.set(n,t),a.set(n,c);let l={line:n,character:e.getLineLength(n)};o.push({range:{start:l,end:l},newText:e.eol+c})}let s=t.map((e,t)=>{let r=n[t],o={line:r+1+i.get(r),character:a.get(r).length};return{start:o,end:o,direction:0}});this.#nt(o,()=>s)}#at(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Wr(n);if(r.length===0||e<0&&r[0].startLine===0||e>0&&r.at(-1).endLine>=t.lineCount-1)return;let i=t.lineCount,a=e=>e<i-1?{line:e+1,character:0}:{line:e,character:t.getLineLength(e)},o=(e,n)=>{let r=e.map(e=>t.getLineText(e)).join(t.eol);return n?r+t.eol:r},s=[];if(e<0)for(let e of r){let t=e.startLine-1,n=[];for(let t=e.startLine;t<=e.endLine;t++)n.push(t);s.push({range:{start:{line:t,character:0},end:a(e.endLine)},newText:o([...n,t],e.endLine<i-1)})}else for(let e=r.length-1;e>=0;e--){let t=r[e],n=t.endLine+1,c=[];for(let e=t.startLine;e<=t.endLine;e++)c.push(e);s.push({range:{start:{line:t.startLine,character:0},end:a(n)},newText:o([n,...c],n<i-1)})}let c=r.at(-1),l=e>0&&c.endLine===i-2?t.getLineLength(c.endLine):t.getLineLength(i-1),u=n.map(n=>Gr(n,e,i,e=>e===i-1?l:t.getLineLength(e))),d=t.applyEdits(s,!0,n,u,!0);d!==void 0&&this.#dn(d,u)}#ot=()=>{let e=this.#R?.length??0,t=this.#f,n=this.#p;this.#f=void 0,this.#p=void 0;let r=this.#_n()!==t,i=this.#vn()!==n;(r||i)&&(this.#g.clear(),this.#_=void 0,this.#r.clearTextWidthCache(),i&&(this.#h.clear(),(this.#Le||e>0)&&this.#m.clear()),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&(this.#Wt(this.#se??[]),this.#se!==void 0&&this.#X&&this.focus()),this.#U?.removePopover(),this.#Qe(this.#w),this.#Gt())};#st(){if(this.#me)return;let e=document.fonts;e!==void 0&&(this.#me=!0,e.ready.then(()=>{this.#w!==void 0&&this.#r.remeasureCharacterWidth()&&(this.#f=void 0,this.#p=void 0,this.#ze(),this.#h.clear(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#U?.removePopover())}))}#ct(e,t,n=this.#V,r){let i=this.#i,a=this.#M,o=this.#N,s=this.#n?.document,c=this.#C,l=this.#w;if(i==null||a==null||o==null||s==null||l==null)return;i.stopBackgroundTokenize();let u=performance.now(),d=i.tokenize(e,n,!this.#Ie&&this.#je!=null),f=performance.now();if(d.size>0){let e=l.children,t=new Set;for(let e of d.keys())this.#Me(e)&&t.add(e);for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=W(r),n=r.dataset.lineType;if(e===void 0||n===`change-deletion`)continue;let i=e-1;if(t.has(i)){let e=d.get(i);if(r.replaceChildren(...Ha(e)),t.delete(i),t.size===0)break}}}if(t.size>0){let n=0;for(let t=e.length-1;t>=0;t--){let r=e[t],i=W(r);if(i!==void 0&&r.dataset.lineType!==`change-deletion`){n=i;break}}for(let e of t){if(e<n)continue;let t=d.get(e),r=String(e+1);U(`div`,{dataset:{line:r,lineType:`context`,lineIndex:e.toString()},children:Ha(t)},l),c!==void 0&&U(`div`,{dataset:{lineType:`context`,columnNumber:r,lineIndex:e.toString()},children:[U(`span`,{dataset:{lineNumberContent:``},textContent:r})]},c)}}}if(e.lineDelta<0)for(let t of[l.children,c?.children??[]])for(let n=t.length-1;n>=0;n--){let r=t[n],i=W(r)??W(r,`columnNumber`),a=r.dataset.lineType;if(i!==void 0&&a!==`change-deletion`){if(i-1<e.lineCount)break;r.remove()}}let p=e.lineDelta!==0;if(p){let e=l.children.length;for(let t of l.children){let{bufferSize:n}=t.dataset;n!==void 0&&(e+=parseInt(n)-1)}l.style.gridRow=`span `+e,c!==void 0&&(c.style.gridRow=`span `+e)}a.updateRenderCache(d,i.themeType,{shouldRefreshDiffsView:this.#Ie&&!p,lineCountChangeInFlight:p,changedDocumentLines:this.#Ie&&!p?ia(s,e):void 0,documentLineCount:s.lineCount}),p&&o(s,t,r,String(e.previousLineCount).length===String(e.lineCount).length?e.startLine:0),(p||this.#Ie&&this.#Fe===`unified`)&&this.#ze(),t!=null&&(this.#R=t,(!this.#Ie||!p)&&ar(t,l,c,a.getAnnotationSlotName)),this.#Gt(),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${nt(performance.now()-f)}ms,`,`tokenize in: ${nt(f-u)}ms (${d.size} dirty lines)`)}#lt(e,t){switch(e){case`insertText`:{let e=t??``,n=this.#n?.document,r=this.#se,i=n!==void 0&&r!==void 0?Or(n,r,e,this.#e.autoSurround):void 0;this.#an(i??e);break}case`insertCompositionText`:break;case`insertLineBreak`:case`insertParagraph`:this.#an(this.#n?.document?.eol??`
|
|
29
|
-
`);break;case`deleteContentBackward`:this.#on();break;case`deleteContentForward`:this.#on(!0);break;case`deleteSoftLineBackward`:case`deleteHardLineBackward`:this.#sn();break;case`deleteWordBackward`:this.#cn();break;case`insertTranspose`:this.#un();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t)}}#ut(e,t=!0,n){this.#X=!0,e===void 0?n?.()===!1?this.#X=!1:this.#w?.focus({preventScroll:t}):(this.#J=!0,this.#ht({start:e,end:e,direction:0}),
|
|
28
|
+
`}),this.#y=U(`style`,{dataset:`editorCss`,textContent:ft}),this.#b=U(`style`,{dataset:`editorThemeCss`}),this.#x=ut(),this.#E=U(`div`,{dataset:`editorOverlay`});let e=e=>{let t=e.composedPath()[0];return t instanceof Node&&this.#w?.contains(t)===!0},t=()=>{this.#Z!=null&&(this.#Z=void 0,this.#X=!1,this.#J=!1)},n=e=>{if(e.pointerType!==`mouse`)return;let t=this.#$;this.#Ke(),t&&this.#ut(),this.#e.enabledSelectionAction===!0&&this.#se!==void 0&&this.#se.length>0&&!J(this.#se.at(-1))&&this.#Wt(this.#se)};this.#s=[G(document,`focusin`,n=>{e(n)||t()},{passive:!0}),G(document,`pointerdown`,n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),G(document,`selectionchange`,()=>{let e=this.#S?.shadowRoot;if(this.#J||this.#Y||e==null||!this.#X||this.#se!==void 0&&this.#se.length>1&&!this.#ee)return;let t=document.getSelection();if(t==null)return;let n;if(n=typeof t.getComposedRanges==`function`?t.getComposedRanges({shadowRoots:[e]})?.[0]:Wa(e),n===void 0||!this.#Cn(n))return;let r=mr(n,0);if(r!==void 0){if(this.#ee&&this.#ne&&this.#se!==void 0&&this.#se.length>0){let e=this.#se.at(-1);this.#Wt([Vr(e,r)]);return}if(this.#re!==void 0)r.direction=Br(this.#re,r).direction;else if(this.#ee)this.#re=r;else if(this.#se!==void 0&&this.#se.length===1){let e=this.#se[0];X(e.start,r.start)===0&&X(e.end,r.end)===0&&(r.direction=e.direction)}this.#te!==void 0&&(this.#te.focusLine=Y(r).line,this.#kt())||(this.#ae===void 0?this.#Wt([r]):this.#Wt([...this.#ae.filter(e=>!Ir(e,r)),r]))}},{passive:!0}),G(document,`pointerup`,n,{passive:!0}),G(document,`pointercancel`,n,{passive:!0}),G(document,`keydown`,e=>{e.key===`Shift`?this.#re=this.#se?.at(-1):e.key===`Alt`&&!e.repeat&&this.#X&&this.#e.editPrediction?.mode===`subtle`&&(this.#ye=!this.#ye,this.#Wt(this.#se??[]))},{passive:!0}),G(document,`keyup`,e=>{e.key===`Shift`&&(this.#re=void 0)},{passive:!0})]}#Ke(){this.#c?.forEach(e=>e()),this.#c=void 0,this.#J=!1,this.#$=!1,this.#ee=!1,this.#te=void 0,this.#ne=!1,this.#re=void 0,this.#ae=void 0}#qe(e){this.#c?.forEach(e=>e()),this.#c=e}#Je(){return this.#M?.options.enableLineSelection===!0}#Ye(){this.#Y=this.#se!==void 0}#Xe(e,t){let{onFocus:n,onBlur:r}=this.#e,i=t=>{let n=t.composedPath()[0];return n!==void 0&&(n===e||e.contains(n))};this.#o?.forEach(e=>e()),this.#o=[G(e,`focus`,()=>{this.#X=!0,n?.(),!this.#ee&&!this.#J&&this.#se!==void 0&&this.#se.length>0&&this.#ht(this.#se.at(-1))},{passive:!0}),G(e,`blur`,()=>{this.#Z?.target===e&&(this.#Z=void 0,this.#J=!1),this.#X=!1,r?.()},{passive:!0}),G(e,`pointerdown`,t=>{if(this.#q=!0,this.#Y=!1,t.pointerType!==`mouse`)return;if(this.#te=void 0,this.#bt(t)){this.#Et(!0),this.#se!==void 0&&this.#Wt([]);return}this.#Et(!1),this.#U?.removePopover();let n=[];if(Ie()&&this.#R!==void 0&&this.#R.length>0){let t=[...e.querySelectorAll(`[data-line-annotation]`)].map(e=>[G(e,`mouseenter`,()=>{this.#J=!0}),G(e,`mouseleave`,()=>{this.#J=!1})]).flat();n.push(...t)}this.#ee=!0;let r=t.button===0&&t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(this.#re=void 0,r?(this.#te={pointerId:t.pointerId,startClientX:t.clientX,clientX:t.clientX,startScrollLeft:e.parentElement?.scrollLeft??0},this.#ae=void 0,this.#se=void 0,this.#Wt([]),n.push(G(document,`pointermove`,e=>{let t=this.#te;t!==void 0&&e.pointerType===`mouse`&&e.pointerId===t.pointerId&&(t.clientX=e.clientX,this.#kt())},{capture:!0,passive:!0}))):t.button===0&&nt(t)&&(this.#ae=this.#se?.map(e=>({...e}))),this.#qe(n),t.shiftKey){let e=this.#se?.at(-1);if(e!==void 0){let t=e.direction===-1?e.end:e.start;this.#ht({start:t,end:t,direction:0})}this.#ne=!0}},{passive:!0}),G(e,`keydown`,e=>{if(!i(e)||(this.#q=!0,this.#Y=!1,e.isComposing||e.keyCode===229))return;if(e.key===`Tab`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&!this.#Q&&(!e.altKey||this.#e.editPrediction?.mode===`subtle`)&&this.#xe?.rendered===!0){this.#Ht(),e.preventDefault();return}if(e.key===`Escape`&&this.#xe!==void 0){this.#Rt(!0),e.preventDefault();return}let t=gt(e,this.#e.keymap);if(t!==void 0){e.preventDefault(),t===`simplifySelection`&&(this.#G?.close(),this.#G=void 0,this.#pe=!1,this.#K?.cleanup(),this.#K=void 0),this.#et(t);return}let n=ht(e),r=this.#n?.document;if(this.#se!==void 0&&this.#se.length>0&&n!==void 0&&r!==void 0){let t={getSoftLineOffsets:this.#Le?e=>this.#Sn(e):void 0,resolveRenderableLine:this.#Ne};e.shiftKey?this.#Wt(Sr(r,this.#se,n,t)):this.#Wt(gr(r,this.#se,n,t)),this.#gt(),e.preventDefault();return}if((e.key.length===1?e.key.toLowerCase():e.key)===`v`&&nt(e)){if(e.repeat&&this.#Ie){e.preventDefault();return}if(this.#e.clipboard!==void 0){e.preventDefault(),z(this.#Ze);return}}if(this.#G!==void 0){let t=H(e);if(t!==void 0){e.preventDefault(),this.#G.navigate(t===`previous`);return}}}),G(e,`copy`,e=>{i(e)&&(e.preventDefault(),this.#wt()?e.clipboardData?.setData(`text`,this.#Tt()):this.#nn(e.clipboardData,this.#en(),this.#tn()))}),G(e,`cut`,e=>{if(i(e)){if(e.preventDefault(),this.#wt())e.clipboardData?.setData(`text`,this.#Tt());else{let t=this.#tn();this.#nn(e.clipboardData,this.#rn(),t)}}}),G(e,`paste`,e=>{if(!i(e))return;e.preventDefault();let t=e.clipboardData,n=this.#n?.document;if(t===null||n===void 0)return;let r=t.getData(`text`),a=this.#se?.length??0;if(a>1){let e=t.getData(eo);if(e!==void 0)try{let t=JSON.parse(e);Array.isArray(t)&&t.length===a&&(r=t)}catch{}}this.#an(Array.isArray(r)?r.map(e=>n.normalizeEol(e)):n.normalizeEol(r),void 0,!0,`document`)}),G(e,`beforeinput`,e=>{if(i(e)){if(e.inputType===`insertCompositionText`){this.#Rt(!0);return}e.preventDefault(),this.#lt(e.inputType,e.data)}}),G(e,`drop`,e=>{i(e)&&e.preventDefault()}),G(e,`compositionstart`,e=>{i(e)&&(this.#Rt(!0),this.#Q=!0,this.#J=!0)},{passive:!0}),G(e,`compositionend`,e=>{if(!i(e))return;this.#J=!1;let t=this.#Q;this.#Q=!1,(e.data!==``||!t)&&this.#lt(`insertText`,e.data)},{passive:!0})];let a=this.#S?.shadowRoot?.querySelector(`[data-deletions]`);if(a!=null&&this.#o.push(G(a,`pointerdown`,e=>{let t=e.composedPath();if(Fe(t)){this.#Ye();return}let n=t[0],r=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(r instanceof HTMLElement){if(this.#Je()){this.#Ye();return}if(this.#Ct(r,a,e.pointerType===`mouse`))return}this.#Et(!0),this.#se!==void 0&&this.#Wt([])},{passive:!0})),t!==void 0){let e=(e,t=!1)=>{let n=e;return n?.dataset.lineNumberContent===void 0?t&&n?.tagName===`SPAN`&&(n=n.closest(`[data-line]`)):n=n.parentElement??void 0,n},n=e=>{if(e===void 0)return;let t=e.dataset.lineType,n=W(e)??W(e,`columnNumber`);if(n!==void 0&&t!==void 0&&Fr(t))return n-1};this.#o.push(G(t,`pointerdown`,t=>{let r=t.composedPath();if(Fe(r)){this.#Ye();return}let i=e(r[0]);if(i!==void 0&&this.#Je()){this.#Ye();return}if(i?.dataset.lineType===`change-deletion`){let e=i.closest(`[data-code]`);e!=null&&this.#Ct(i,e,t.pointerType===`mouse`);return}if(t.pointerType!==`mouse`)return;let a=this.#n?.document,o=n(i);if(o===void 0||a===void 0)return;this.#q=!0,this.#U?.removePopover();let s=this.#yt(o,o,a);this.#$=!0,this.#re=s,this.#Wt([s]),this.#ht(s),this.#ut(),this.#qe([G(document,`mousemove`,t=>{if(!this.#$)return;let r=this.#n?.document,i=n(e(t.composedPath()[0],!0));if(i===void 0||r===void 0)return;let a=this.#re?.start.line??i,o=this.#yt(a,i,r);this.#re??=o,this.#Wt([o]),this.#ut(o.direction===-1?o.start:o.end)},{passive:!0})])},{passive:!0}))}this.#U?.listenHover(e),this.#j?.disconnect(),this.#j=new ResizeObserver(this.#ot),this.#j.observe(e),this.#j.observe(e.parentElement),this.#Qe(e)}#Ze=async()=>{let e=this.#e.clipboard;if(e!==void 0){let t=await e.readText(),n=this.#se?.length??0;if(n>1){let r=await e.readText(eo);try{let e=JSON.parse(r);Array.isArray(e)&&e.length===n&&(t=e)}catch{}}let r=this.#n?.document;r!=null&&this.#an(Array.isArray(t)?t.map(e=>r.normalizeEol(e)):r.normalizeEol(t),void 0,!0,`document`)}};#Qe(e){this.#Ie&&this.#Fe===`split`&&this.#Le&&(this.#d={top:e.offsetTop-this.#r.paddingTop,left:e.offsetLeft-this.#_n()},this.#e.__debug===!0&&console.log(`[diffs/editor] content offset:`,this.#d))}get#$e(){if(this.#Ie&&this.#Fe===`split`&&this.#Le)return this.#d}#et(e){let t=this.#n?.document;if(t!=null)switch(e){case`openSearchPanel`:this.#Qt(`find`);break;case`openSearchReplacePanel`:this.#Qt(`replace`);break;case`findNextMatch`:{let e=this.#se;if(e===void 0)break;if(e.some(J)){let n=e.map(e=>J(e)?ai(t,e):e);this.#Wt(n),this.focus()}else{let n=Kr(t,e);if(n!==void 0){this.#Wt(n);let e=n.at(-1);e!==void 0&&this.#Pe(Y(e).line),this.#gt()}}break}case`moveLineUp`:case`moveLineDown`:this.#at(e===`moveLineUp`?-1:1);break;case`copyLineUp`:case`copyLineDown`:this.#rt(e===`copyLineUp`?-1:1);break;case`simplifySelection`:{let e=this.#se,t=e?.at(-1);if(e===void 0||t===void 0)break;if(e.length>1)this.#Wt([t]),this.#ut(Y(t));else if(!J(t)){let e=Y(t);this.#Wt([{start:e,end:e,direction:0}]),this.#ut(e)}break}case`insertBlankLine`:this.#it();break;case`deleteHardLineForward`:this.#ln();break;case`toggleComment`:case`toggleBlockComment`:{let n=this.#se;if(n===void 0)break;let{lineComment:r,blockComment:i}=ca(t.languageId,this.#e.languageCommentConfig);if(e===`toggleComment`&&r!==null){this.#nt(la(t,n,r));break}let a=e===`toggleComment`,o=pa(t,n,i,a);o!==void 0&&this.#nt(o.edits,a?void 0:e=>o.nextSelectionOffsets.map(([t,n,r])=>({start:e.positionAt(t),end:e.positionAt(n),direction:r})));break}case`indent`:case`outdent`:case`indentLess`:case`indentMore`:if(this.#se!==void 0){let n=[],r=[],i=new Set,a=[];for(let o of this.#se){let s=o.start.line,c=e===`outdent`||e===`indentLess`,l=e===`indentLess`||e===`indentMore`;if(s!==o.end.line||c||l){let e=hr(t,o,this.#r.tabSize,c);for(let t of e[0]){let e=t.range.start.line;i.has(e)||(i.add(e),n.push(t))}r.push(e[1])}else{let e=t.charAt({line:s,character:0})===` `?` `:` `.repeat(this.#r.tabSize);n.push({range:o,newText:e}),a.push({line:s,startCharacter:o.start.character,addedLength:e.length-(o.end.character-o.start.character),selectionIndex:r.length});let i={line:o.start.line,character:o.start.character+e.length};r.push({start:i,end:i,direction:0})}}for(let e of a){let t=0;for(let n of a)n.line===e.line&&n.startCharacter<e.startCharacter&&(t+=n.addedLength);if(t!==0){let n=r[e.selectionIndex],i={line:e.line,character:n.start.character+t};r[e.selectionIndex]={start:i,end:i,direction:0}}}let o=t.applyEdits(n,!0,this.#se,r);o!==void 0&&this.#dn(o,r)}break;case`selectAll`:{let e=qr(t);this.#Wt([e]),this.focus();let n=this.#mn(),r=n[0]?.[0],i=n.at(-1)?.[1];r!==void 0&&i!==void 0&&(this.#Y=!0,this.#ht({start:{line:r,character:0},end:{line:i,character:t.getLineLength(i)},direction:1}));break}case`moveCursorToDocStart`:case`moveCursorToDocEnd`:{let n=Jr(t,e===`moveCursorToDocEnd`,this.#Ie);this.#Wt([n]),this.#Pe(Y(n).line),this.#gt()}break;case`expandSelectionDocStart`:case`expandSelectionDocEnd`:{let n=e===`expandSelectionDocEnd`,r=this.#se;if(r!==void 0){let e=Jr(t,n,this.#Ie);this.#Wt(Hr(r,e)),this.#Pe(Y(e).line),this.#gt()}}break;case`undo`:case`redo`:this.#tt(e)}}#tt(e){let t=this.#n?.document;if(t==null||e===`undo`&&!t.canUndo||e===`redo`&&!t.canRedo)return;let n=this.#se,r=n?.map(e=>[t.offsetAt(e.start),t.offsetAt(e.end)]),i=e===`undo`?t.undo():t.redo();if(i===void 0)return;let[a,o,s,c]=i,l=o??(n!==void 0&&r!==void 0&&c!==void 0?zr(t,n,r,c):void 0),u=s??(this.#R==null?void 0:$n(a,this.#R));this.#dn(a,l,u)}#nt(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0)return;let i=t===void 0,a=i?r.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]):void 0,o=i?e.map(e=>{let t=n.offsetAt(e.range.start),r=n.offsetAt(e.range.end);return{start:Math.min(t,r),end:Math.max(t,r),text:e.newText}}).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n}):void 0,s=n.applyEdits(e,!0,r,void 0,!0);if(s===void 0)return;let c=i?zr(n,r,a,o):t(n);n.setLastUndoSelectionsAfter(c),this.#dn(s,c,this.#pn(s))}#rt(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Wr(n);if(r.length===0)return;let i=[],a=0,o=[];for(let n of r){i.push(a);let r=n.endLine-n.startLine+1;a+=r;let s=t.getText({start:{line:n.startLine,character:0},end:{line:n.endLine,character:t.getLineLength(n.endLine)}});if(e>0){let e={line:n.startLine,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else if(n.endLine<t.lineCount-1){let e={line:n.endLine+1,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else{let e={line:n.endLine,character:t.getLineLength(n.endLine)};o.push({range:{start:e,end:e},newText:t.eol+s})}}let s=n.map(t=>{let n=t.start.line,a=0,o=r.length-1;for(;a<=o;){let e=a+o>>>1,t=r[e];if(n<t.startLine)o=e-1;else if(n>t.endLine)a=e+1;else{a=e;break}}let s=Math.max(0,a<=o?a:o),c=r[s],l=i[s]+(e>0?c.endLine-c.startLine+1:0);return{start:{...t.start,line:t.start.line+l},end:{...t.end,line:t.end.line+l},direction:t.direction}});this.#nt(o,()=>s)}#it(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0)return;let n=t.map(e=>Y(e).line),r=Array.from(new Set(n)).sort((e,t)=>e-t),i=new Map,a=new Map,o=[];for(let t=0;t<r.length;t++){let n=r[t],s=e.getLineText(n),c=/^\s*/.exec(s)?.[0]??``;i.set(n,t),a.set(n,c);let l={line:n,character:e.getLineLength(n)};o.push({range:{start:l,end:l},newText:e.eol+c})}let s=t.map((e,t)=>{let r=n[t],o={line:r+1+i.get(r),character:a.get(r).length};return{start:o,end:o,direction:0}});this.#nt(o,()=>s)}#at(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Wr(n);if(r.length===0||e<0&&r[0].startLine===0||e>0&&r.at(-1).endLine>=t.lineCount-1)return;let i=t.lineCount,a=e=>e<i-1?{line:e+1,character:0}:{line:e,character:t.getLineLength(e)},o=(e,n)=>{let r=e.map(e=>t.getLineText(e)).join(t.eol);return n?r+t.eol:r},s=[];if(e<0)for(let e of r){let t=e.startLine-1,n=[];for(let t=e.startLine;t<=e.endLine;t++)n.push(t);s.push({range:{start:{line:t,character:0},end:a(e.endLine)},newText:o([...n,t],e.endLine<i-1)})}else for(let e=r.length-1;e>=0;e--){let t=r[e],n=t.endLine+1,c=[];for(let e=t.startLine;e<=t.endLine;e++)c.push(e);s.push({range:{start:{line:t.startLine,character:0},end:a(n)},newText:o([n,...c],n<i-1)})}let c=r.at(-1),l=e>0&&c.endLine===i-2?t.getLineLength(c.endLine):t.getLineLength(i-1),u=n.map(n=>Gr(n,e,i,e=>e===i-1?l:t.getLineLength(e))),d=t.applyEdits(s,!0,n,u,!0);d!==void 0&&this.#dn(d,u)}#ot=()=>{let e=this.#R?.length??0,t=this.#f,n=this.#p;this.#f=void 0,this.#p=void 0;let r=this.#_n()!==t,i=this.#vn()!==n;(r||i)&&(this.#g.clear(),this.#_=void 0,this.#r.clearTextWidthCache(),i&&(this.#h.clear(),(this.#Le||e>0)&&this.#m.clear()),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&(this.#Wt(this.#se??[]),this.#se!==void 0&&this.#X&&this.focus()),this.#U?.removePopover(),this.#Qe(this.#w),this.#Gt())};#st(){if(this.#me)return;let e=document.fonts;e!==void 0&&(this.#me=!0,e.ready.then(()=>{this.#w!==void 0&&this.#r.remeasureCharacterWidth()&&(this.#f=void 0,this.#p=void 0,this.#ze(),this.#h.clear(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#U?.removePopover())}))}#ct(e,t,n=this.#V,r){let i=this.#i,a=this.#M,o=this.#N,s=this.#n?.document,c=this.#C,l=this.#w;if(i==null||a==null||o==null||s==null||l==null)return;i.stopBackgroundTokenize();let u=performance.now(),d=i.tokenize(e,n,!this.#Ie&&this.#je!=null),f=performance.now();if(d.size>0){let e=l.children,t=new Set;for(let e of d.keys())this.#Me(e)&&t.add(e);for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=W(r),n=r.dataset.lineType;if(e===void 0||n===`change-deletion`)continue;let i=e-1;if(t.has(i)){let e=d.get(i);if(r.replaceChildren(...Ha(e)),t.delete(i),t.size===0)break}}}if(t.size>0){let n=0;for(let t=e.length-1;t>=0;t--){let r=e[t],i=W(r);if(i!==void 0&&r.dataset.lineType!==`change-deletion`){n=i;break}}for(let e of t){if(e<n)continue;let t=d.get(e),r=String(e+1);U(`div`,{dataset:{line:r,lineType:`context`,lineIndex:e.toString()},children:Ha(t)},l),c!==void 0&&U(`div`,{dataset:{lineType:`context`,columnNumber:r,lineIndex:e.toString()},children:[U(`span`,{dataset:{lineNumberContent:``},textContent:r})]},c)}}}if(e.lineDelta<0)for(let t of[l.children,c?.children??[]])for(let n=t.length-1;n>=0;n--){let r=t[n],i=W(r)??W(r,`columnNumber`),a=r.dataset.lineType;if(i!==void 0&&a!==`change-deletion`){if(i-1<e.lineCount)break;r.remove()}}let p=e.lineDelta!==0;if(p){let e=l.children.length;for(let t of l.children){let{bufferSize:n}=t.dataset;n!==void 0&&(e+=parseInt(n)-1)}l.style.gridRow=`span `+e,c!==void 0&&(c.style.gridRow=`span `+e)}a.updateRenderCache(d,i.themeType,{shouldRefreshDiffsView:this.#Ie&&!p,lineCountChangeInFlight:p,changedDocumentLines:this.#Ie&&!p?ia(s,e):void 0,documentLineCount:s.lineCount}),p&&o(s,t,r,String(e.previousLineCount).length===String(e.lineCount).length?e.startLine:0),(p||this.#Ie&&this.#Fe===`unified`)&&this.#ze(),t!=null&&(this.#R=t,(!this.#Ie||!p)&&ar(t,l,c,a.getAnnotationSlotName)),this.#Gt(),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${rt(performance.now()-f)}ms,`,`tokenize in: ${rt(f-u)}ms (${d.size} dirty lines)`)}#lt(e,t){switch(e){case`insertText`:{let e=t??``,n=this.#n?.document,r=this.#se,i=n!==void 0&&r!==void 0?Or(n,r,e,this.#e.autoSurround):void 0;this.#an(i??e);break}case`insertCompositionText`:break;case`insertLineBreak`:case`insertParagraph`:this.#an(this.#n?.document?.eol??`
|
|
29
|
+
`);break;case`deleteContentBackward`:this.#on();break;case`deleteContentForward`:this.#on(!0);break;case`deleteSoftLineBackward`:case`deleteHardLineBackward`:this.#sn();break;case`deleteWordBackward`:this.#cn();break;case`insertTranspose`:this.#un();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t)}}#ut(e,t=!0,n){this.#X=!0,e===void 0?n?.()===!1?this.#X=!1:this.#w?.focus({preventScroll:t}):(this.#J=!0,this.#ht({start:e,end:e,direction:0}),z(()=>{if(n?.()===!1||!this.#X){this.#J=!1;return}this.#w?.focus({preventScroll:t}),z(()=>{this.#J=!1})}))}#dt(e){let t=this.#Z;if(t==null)return;if(this.#pe){this.#Z=void 0,this.#X=!1,this.#J=!1;return}let n=this.#w;if(n==null||!this.#ft(n)){this.#Z=void 0,this.#X=!1;return}let r=()=>{if(this.#Z!==t)return!1;let e=this.#ft(n);return this.#Z=void 0,e};if(e!=null){this.#ut(e,!0,r);return}let i=this.#se?.at(-1);if(i==null){this.#ut(void 0,!0,r);return}let a=i.direction===-1?i.end:i.start;this.#ut(a,!0,r)}#ft(e){let t=this.#S,n=t?.shadowRoot;if(t==null||n==null||this.#w!==e||!n.contains(e))return!1;let{activeElement:r}=n;if(r===e||r!=null&&e.contains(r))return!0;if(r!=null)return!1;let{ownerDocument:i}=t,{activeElement:a}=i;return a==null||a===i.body||a===i.documentElement||a===t}#pt(e=0){let t=this.#w,n=this.#S;if(this.#n?.document==null||t==null||n==null)return;let r=this.#Ue();if(r===void 0)return;let i,a;if(r instanceof HTMLElement){let e=r.getBoundingClientRect();i=e.top,a=e.bottom}else i=0,a=r.defaultView?.innerHeight??0;let o=n.shadowRoot?.querySelector(`[data-diffs-header][data-sticky]`);if(o!=null&&(i=Math.max(i,o.getBoundingClientRect().bottom)),Number.isFinite(e)&&(i+=Math.max(0,e)),!(a<=i))for(let e of t.children){let t=e,n=W(t),r=t.dataset.lineType;if(n==null||r==null||!Fr(r))continue;let o=t.getBoundingClientRect();if(!(o.bottom<=o.top)&&o.top>=i&&o.top<a)return n}}#mt(e,t){let n={start:e,end:e,direction:0};this.#q=!1,this.#Wt([n]),this.#Pe(e.line),t?this.#ut(e,!0):this.#gt()}#ht(e){let t=window.getSelection();if(t===null)return;let{start:n,end:r,direction:i}=e;X(n,r)>0&&([n,r]=[r,n]);let a=this.#gn(n.line),o=this.#gn(r.line);if(a===void 0||o===void 0)return;let[s,c]=ii(a,n.character),[l,u]=ii(o,r.character);i===-1&&([s,c,l,u]=[l,u,s,c]);try{t.setBaseAndExtent(s,it(s,c),l,it(l,u))}catch(e){console.error(`[diffs/editor] failed to update window selection:`,e)}}#gt(e=!1,t=`nearest`){let n=this.#se?.at(-1);if(n===void 0)return;let r=this.#A;if(r!==void 0){if(r.scrollIntoView({block:t,inline:`nearest`}),!e){let e=n.direction===-1?n.end:n.start;this.#Z===void 0?this.#ut(e):this.#dt(e)}}else{let t=Y(n);this.#vt(t.line,t.character,e)}}#_t(){let e=this.#G===void 0?0:48,t=this.#_n()+this.#r.ch;return`${e}px ${this.#r.ch}px 0 ${t}px`}#vt(e,t=0,n=!1){this.__postponeBgTokenizeToNextFrame();let r=U(`div`,{style:{position:`absolute`,left:`0`,width:`2px`,height:this.#r.lineHeight+`px`,scrollMargin:this.#_t()}});if(this.#gn(e)!==void 0){let[i,a]=this.#bn(e,t),o=this.#yn(e)+a*this.#r.lineHeight;if(r.style.top=o+`px`,r.style.left=i+`px`,this.#E?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),!n){let n={line:e,character:t};this.#Z===void 0?this.#ut(n):this.#dt(n)}this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1}else{let i=this.#je?.getLinePosition?.(e+1);if(i!==void 0)r.style.top=i.top+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),i.height>0&&this.#Me(e)?(this.#le=e,this.#ue=t,this.#fe=n):(this.#le=void 0,this.#ue=void 0,this.#fe=!1);else{let i=0;if(this.#le===e&&this.#w!==void 0)for(let t=this.#w.childElementCount-1;t>=0;t--){let n=this.#w.children[t],r=n.dataset.lineType,a=W(n);if(r!==void 0&&Fr(r)&&a!==void 0){i=(e-(a-1))*this.#r.lineHeight;break}}let a=((this.#R??[]).filter(t=>t.lineNumber<e).length+e)*this.#r.lineHeight+i;r.style.top=a+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),this.#le===e&&(i===0||this.#de)||!this.#Me(e)?(this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1):(this.#le=e,this.#ue=t,this.#de=i!==0,this.#fe=n)}}r.remove()}#yt(e,t,n){let r=e=>({line:e,character:0}),i=e=>({line:e,character:n.getLineText(e).length});return t<e?{start:r(t),end:i(e),direction:-1}:{start:r(e),end:i(t),direction:1}}#bt(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&t.closest(`[data-line]`)?.getAttribute(`data-line-type`)===`change-deletion`}#xt(e,t,n){let r=[...n.querySelectorAll(`[data-content] > [data-line]`)],i=r.indexOf(e),a=r.indexOf(t),[o,s]=a<i?[t,e]:[e,t],c=window.getSelection();if(c!==null){let e=document.createRange();e.setStart(o,0),e.setEnd(s,s.childNodes.length),c.removeAllRanges(),c.addRange(e)}this.#Et(!0),this.#Wt([]),this.#Dt(W(t)??null,!0,`deletions`);let l=Math.min(i,a),u=Math.max(i,a);this.#ie=l<0?``:r.slice(l,u+1).filter(e=>e.getAttribute(`data-line-type`)===`change-deletion`).map(e=>e.textContent??``).join(`
|
|
30
30
|
`)}#St(e,t){let n=e.parentElement;if(n==null||t==null)return;let r=[...n.children].indexOf(e),i=t.children[r];return i instanceof HTMLElement?i:void 0}#Ct(e,t,n){let r=t.querySelector(`[data-content]`),i=this.#St(e,r);return i!==void 0&&(this.#xt(i,i,t),n&&this.#qe([G(document,`mousemove`,e=>{let n=e.composedPath()[0],a=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(a instanceof HTMLElement&&t.contains(a)){let e=this.#St(a,r);e!==void 0&&this.#xt(i,e,t)}},{passive:!0})]),!0)}#wt(){return this.#S?.shadowRoot?.querySelector(`pre`)?.hasAttribute(`data-deleted-text-selection`)??!1}#Tt(){return this.#ie===``?window.getSelection()?.toString()??``:this.#ie}#Et(e){let t=this.#S?.shadowRoot?.querySelector(`pre`);t!=null&&(e?(t.setAttribute(`data-deleted-text-selection`,``),this.#Dt(null),this.#ie=``):(t.removeAttribute(`data-deleted-text-selection`),this.#ie=``))}#Dt(e,t=!1,n=`additions`){try{this.#M?.setEditorActiveLine(e,{lineNumberOnly:t,side:n})}catch{}}#Ot(){this.#he===void 0&&(this.#he=requestAnimationFrame(()=>{this.#he=void 0,(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[])}))}#kt(){let e=this.#te,t=this.#re,n=this.#n?.document;if(e===void 0||e.focusLine===void 0||t===void 0||n===void 0)return!1;let r=t.direction===-1?t.end:t.start,i=this.#w?.parentElement?.scrollLeft??0,a=(e.clientX-e.startClientX+i-e.startScrollLeft)/this.#r.ch,o=a<0?-Math.round(-a):Math.round(a),s=Math.max(0,r.character+o),c={line:e.focusLine,character:s};if(e.renderedGoal!==void 0&&X(e.renderedGoal,c)===0)return!0;e.renderedGoal=c;let l=[],u=c.line<r.line?-1:1;for(let e=r.line;;e+=u){if(this.#Me(e)){let t=n.getLineText(e),i=Math.min(r.character,t.length),a=Math.min(s,t.length),o=vr(t,i),c=a===i?o:vr(t,a);l.push({start:{line:e,character:Math.min(o,c)},end:{line:e,character:Math.max(o,c)},direction:o===c?0:o<c?1:-1})}if(e===c.line)break}return this.#Wt(l),!0}#At(){for(let[e,t]of this.#D??[])e.startsWith(`editPrediction`)&&(t.remove(),this.#D?.delete(e))}#jt(e,t,n){let r=t[n],i=n,a=r.range.end.line;for(;i+1<t.length&&t[i+1].range.start.line<=a;)i++,a=Math.max(a,t[i].range.end.line);if(i===n&&(r.newText.length===0||X(r.range.start,r.range.end)===0))return{edit:r,endIndex:i};let o=r.range.start,s={line:a,character:e.getLineLength(a)},c=[],l=e.offsetAt(o);for(let r=n;r<=i;r++){let n=t[r],i=e.offsetAt(n.range.start),a=e.offsetAt(n.range.end);c.push(e.getTextSlice(l,i),n.newText),l=a}return c.push(e.getTextSlice(l,e.offsetAt(s))),{edit:{range:{start:o,end:s},newText:c.join(``)},endIndex:i}}#Mt(){let e=this.#xe,t=this.#n?.document;if(e==null||t==null||e.document!==t||e.version!==t.version||this.#e.editPrediction?.mode===`subtle`&&!this.#ye)return;let{edits:n}=e.response,r=[],i=n.length>0;for(let e=0;e<n.length;){let{edit:a,endIndex:o}=this.#jt(t,n,e);for(let e=a.range.start.line;i&&e<=a.range.end.line;e++)i=this.#wn(e);r.push({edit:a,startIndex:e,endIndex:o}),e=o+1}return{groups:r,allVisible:i}}#Nt(e,t,n,r,i){this.#Le?(e.dataset.wrap=``,e.style.width=`calc(100cqw - ${r}px)`):(delete e.dataset.wrap,e.style.width=`max-content`);let a=t.split(/\r\n|\r|\n/);for(let t=0;t<a.length;t++){let o=a[t],s=t===a.length-1?i:void 0,c=o.length===0&&s===void 0,l=U(`span`,{dataset:c?[`editPredictionLine`,`empty`]:`editPredictionLine`,textContent:c?``:o},e);s!==void 0&&U(`span`,{dataset:`editPredictionSuffix`},l).append(s),t===0&&n!==r&&(l.style.textIndent=`${n-r}px`)}}#Pt(e){let t=this.#xe,n=this.#n?.document;if(t==null||n==null)return;let{edit:r,startIndex:i,endIndex:a}=e,{start:o,end:s}=r.range;if(!(X(o,s)===0&&o.character<n.getLineLength(o.line))||t.response.edits[i-1]?.range.end.line===o.line||t.response.edits[a+1]?.range.start.line===o.line)return;let c=this.#gn(o.line);if(c===void 0)return document.createTextNode(n.getLineText(o.line).slice(o.character));let[l,u]=ii(c,o.character),d=document.createRange();d.selectNodeContents(c),d.setStart(l,it(l,u));let f=d.cloneContents();return f.firstChild?.textContent===``&&f.firstChild.remove(),f}#Ft(e){let{edit:t}=e,{start:n}=t.range,[r,i]=this.#bn(n.line,n.character),a=1,o=t.newText.split(/\r\n|\r|\n/).length,s=this.#E;if(this.#Le&&s!=null){a=Math.max(1,this.#Sn(n.line).length-1);let i=U(`span`,{dataset:`editPrediction`,style:{visibility:`hidden`}},s);this.#Nt(i,t.newText,r,this.#bn(n.line,0)[0],this.#Pt(e));let{width:c,height:l}=i.getBoundingClientRect();i.remove();let{lineHeight:u}=this.#r;c>0&&l>0&&u>0&&(o=Math.round(l/u))}return Math.max(0,o-(a-i))}#It(e=!0){let t=new Map,n=new Map,r=this.#we,i=!1,a=this.#w,o=this.#Mt();if(a!=null&&o!=null&&o.allVisible){for(let e of o.groups){let{edit:t}=e;if(t.newText.length===0)continue;let r=this.#Ft(e);r>(n.get(t.range.start.line)??0)&&n.set(t.range.start.line,r)}if(n.size>0){let e,o=this.#V?.startingLine??0;for(let[s,c]of n){i||=r.get(s)!==c;let n=this.#gn(s);if(n===void 0)continue;let l=s-o;if(a.children[l]!==n){if(e===void 0){e=new Map;for(let t=0;t<a.children.length;t++)e.set(a.children[t],t)}l=e.get(n)??-1}if(l<0)continue;t.set(n,c);let u=this.#C?.children[l];u instanceof HTMLElement&&t.set(u,c);let d=this.#Lt(l);d!=null&&(t.set(d.content,(t.get(d.content)??0)+c),t.set(d.gutter,(t.get(d.gutter)??0)+c))}}}let s=!1;for(let[e,n]of this.#Ce)t.get(e)!==n&&(delete e.dataset.editPredictionSpacer,e.style.removeProperty(`--diffs-edit-prediction-spacer-height`),s=!0);for(let[e,n]of t)this.#Ce.get(e)!==n&&(e.dataset.editPredictionSpacer=``,e.style.setProperty(`--diffs-edit-prediction-spacer-height`,`${n}lh`),s=!0);this.#Ce=t,(i||n.size!==r.size)&&(this.#we=n,e&&this.#je?.syncGhostTextRows()),s&&this.#ze()}#Lt(e){let t=this.#T,n=this.#w;if(t==null||n==null||!this.#Ie||this.#Fe!==`split`||this.#Le)return;let r=0;for(let t=0;t<e;t++)r+=ro(n.children[t]);let{content:i,gutter:a}=t,o=0;for(let e=0;e<i.children.length;e++){let t=i.children[e];if(o+=ro(t),o>r){let n=a.children[e];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))throw Error(`Editor: deletions column rows and gutter cells are out of step`);return{content:t,gutter:n}}}}#Rt(e,t=!0){this.#ge!==void 0&&(clearTimeout(this.#ge),this.#ge=void 0),this.#_e?.abort(),this.#_e=void 0,this.#ve++,this.#ye=!1,this.#be=!1,this.#xe=void 0,this.#It(t),e&&this.#At()}#zt(e){let t=this.#e.editPrediction;if(t===void 0)return!1;let n=e.replaceAll(`\\`,`/`);return(t.include===void 0||t.include.some(e=>ra(n,e)))&&t.exclude?.some(e=>ra(n,e))!==!0}#Bt(){this.#Rt(!0);let e=this.#se?.[0];if(this.#e.editPrediction===void 0||this.#n?.document===void 0||this.#n?.fileInfo===void 0||this.#se?.length!==1||e===void 0||!J(e))return;let t=this.#n?.document,n=t.offsetAt(Y(e));this.#ge=setTimeout(()=>{this.#ge=void 0;let e=this.#e.editPrediction,r=this.#se?.[0],i=this.#n?.fileInfo?.name;if(e===void 0||i===void 0||this.#n?.document!==t||this.#se?.length!==1||r===void 0||!J(r)||t.offsetAt(Y(r))!==n||!this.#zt(i))return;let a=e=>this.#hn(e)&&this.#Me(e);if(!a(Y(r).line)){this.#be=!0;return}let o=na(i,t,n,this.#Se,a);if(o===void 0)return;let s=t.offsetAt({line:o.excerptStartLine,character:0}),c=s+o.editableRange.start,l=s+o.editableRange.end,u=new AbortController,d=++this.#ve;this.#_e=u;let f;try{f=e.provider.predict(o,{signal:u.signal})}catch{this.#_e=void 0;return}Promise.resolve(f).then(e=>{let r=this.#se?.[0];if(u.signal.aborted||d!==this.#ve||this.#_e!==u||this.#n?.document!==t||t.version!==o.version||this.#se?.length!==1||r===void 0||!J(r)||t.offsetAt(Y(r))!==n||e==null||!Array.isArray(e.edits)||e.edits.length===0||e.edits.length>Xa||e.newCursor==null)return;let i=[],a=0;for(let n of e.edits){if(n==null||typeof n.newText!=`string`||!io(t,n.range?.start)||!io(t,n.range?.end)||X(n.range.start,n.range.end)>0||(a+=Qa.encode(n.newText).byteLength,a>Za))return;let e=t.offsetAt(n.range.start),r=t.offsetAt(n.range.end),o=t.resolveEdits([n])[0];if(o.start!==e||o.end!==r)return;i.push(o)}i.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<i.length;e++){let t=i[e];if(t.start<c||t.end>l||e>0&&i[e-1].end>t.start)return}let s=i.filter(e=>e.text!==t.getTextSlice(e.start,e.end));if(s.length===0)return;let f=t.positionAt(s[0].start),p=t.positionAt(s.at(-1).end),m=t.offsetAt({line:f.line,character:0}),h=t.offsetAt({line:p.line,character:t.getLineLength(p.line)}),g=[],_=m;for(let e of s)g.push(t.getTextSlice(_,e.start),e.text),_=e.end;g.push(t.getTextSlice(_,h));let v=g.join(``).split(/\r\n|\r|\n/),y=f.line+v.length-1,b=v.length-(p.line-f.line+1),x=e.newCursor;if(!(!Number.isInteger(x.line)||!Number.isInteger(x.character)||x.line<0||x.character<0)){if(x.line>=f.line&&x.line<=y){let e=v[x.line-f.line];if(x.character>e.length||ao(e,x.character))return}else{let e=x.line<f.line?x.line:x.line-b;if(e<0||e>=t.lineCount||x.character>t.getLineLength(e))return;let n=t.offsetAt({line:e,character:x.character});if(ao(t.charAt(n-1)+t.charAt(n),1))return}this.#xe={document:t,version:o.version,cursorOffset:n,rendered:!1,response:{edits:s.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),newCursor:{...x}}},this.#Wt(this.#se)}}).catch(()=>{}).finally(()=>{this.#_e===u&&(this.#_e=void 0)})},Ya)}#Vt(e,t){let n=this.#n?.document,r=this.#n?.fileInfo?.name,i=zn(e);n!==void 0&&r!==void 0&&i!==void 0&&this.#zt(r)&&(this.#Se=ea(this.#Se,r,n,i,t))}#Ht(){let e=this.#xe,t=this.#n?.document,n=this.#se?.[0];if(e===void 0||!e.rendered||t===void 0||e.document!==t||e.version!==t.version||this.#se?.length!==1||n===void 0||!J(n)||t.offsetAt(Y(n))!==e.cursorOffset)return;let{edits:r,newCursor:i}=e.response;this.#Rt(!0);let a=t.applyEdits(r.map(e=>({range:{start:{...e.range.start},end:{...e.range.end}},newText:e.newText})),!0,this.#se,void 0,!0);if(a===void 0){this.#Bt();return}let o=t.normalizePosition(i),s=[{start:o,end:o,direction:0}];t.setLastUndoSelectionsAfter(s),this.#dn(a,s,this.#pn(a),{editSource:`prediction`})}#Ut(e){let t=this.#xe,n=this.#n?.document;t!==void 0&&(t.rendered=!1);let r=this.#Mt();if(t!=null&&n!=null&&r!=null&&r.allVisible){for(let t of r.groups){let{edit:r,endIndex:i}=t,{start:a,end:o}=r.range,s=r.newText.length===0,c=X(a,o)!==0,l=n.getLineLength(a.line),u=!c&&a.character<l;if(c?this.#Kt(e,s?`editPredictionDeletion`:`editPredictionReplacement`,{start:a,end:o}):u&&this.#Kt(e,`editPredictionInsertion`,{start:a,end:{line:a.line,character:l}}),s)continue;let[d,f]=this.#bn(a.line,a.character),p=this.#bn(a.line,0)[0],m=this.#yn(a.line)+f*this.#r.lineHeight,h=`editPrediction-${i}`,g=this.#D?.get(h);if(g===void 0?g=U(`span`,{ariaHidden:`true`,contentEditable:`false`,dataset:`editPrediction`},e.fragment):(this.#D?.delete(h),g.replaceChildren()),c){g.dataset.replacement=``;let e=this.#gn(a.line);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else delete g.dataset.replacement,g.style.removeProperty(`--diffs-edit-prediction-bg`);this.#Nt(g,r.newText,d,p,this.#Pt(t)),g.style.transform=`translateX(${p}px) translateY(${m}px)`,e.elements.set(h,g)}t.rendered=!0}}#Wt(e){this.__postponeBgTokenizeToNextFrame();let t=this.#se,n=t?.length!==e.length;if(!n&&t!==void 0)for(let r=0;r<e.length;r++){let i=t[r],a=e[r];if(i.direction!==a.direction||X(i.start,a.start)!==0||X(i.end,a.end)!==0){n=!0;break}}if(n&&this.#Rt(!0),this.#It(),this.#A=void 0,this.#Dt(null),e.length===0&&this.#ce===void 0&&this.#U===void 0){this.#se=void 0,this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#K?.cleanup(),this.#K=void 0,n&&this.#Bt();return}let r=document.createDocumentFragment(),i={fragment:r,elements:new Map};if(e.length>0){let t=Ur(e),n=t.at(-1);this.#se=t;let r=t.some(e=>!J(e)),a=Y(n).line+1;this.#Dt(a,r);for(let e of t)J(e)||this.#Kt(i,`selection`,e),this.#Xt(i,e,e===n);let o=this.#e.matchBrackets!==!1&&this.#n?.document!=null&&this.#i!==void 0&&J(n)?va(this.#n?.document,this.#i,n.start):void 0;if(o!==void 0)for(let e of o)this.#Kt(i,`bracketMatch`,e)}let a=this.#n?.document;if(this.#ce!==void 0&&a!==void 0){let e=this.#ce,t=this.#V,n=t!=null&&Number.isFinite(t.totalLines)||this.#Ie&&this.#Ae?.options.expandUnchanged!==!0?this.#mn():void 0,r=this.#se?.at(-1),o=r===void 0?-1:a.offsetAt(r.start),s=r===void 0?-1:a.offsetAt(r.end),c=0,l=n?.length??1;for(let t=0;t<l;t++){let r=1/0,l=n?.[t];if(l!==void 0){let[t,n]=l,i=a.offsetAt({line:t,character:0}),o=n+1;r=o<a.lineCount?a.offsetAt({line:o,character:0}):a.offsetAt({line:o-1,character:a.getLineLength(o-1)});let s=c,u=e.length;for(;s<u;){let t=s+Math.floor((u-s)/2);e[t][1]<=i?s=t+1:u=t}c=s}for(;c<e.length;c++){let[t,n]=e[c];if(t>=r)break;let l={start:a.positionAt(t),end:a.positionAt(n)},u=o===t&&s===n;this.#Kt(i,`match`,l,u?`focus`:void 0)}}}if(this.#U!==void 0&&a!==void 0)for(let e of this.#U.markers)this.#Kt(i,`marker`,e,Pi(e.severity));this.#Ut(i),this.#E?.appendChild(r),this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#D=i.elements,this.#Zt(),n&&this.#Bt()}#Gt(){let e=this.#W,t=this.#e.renderCaret,n=this.#E;if(this.#k?.forEach(e=>e.remove()),this.#k=void 0,e===void 0||t===void 0||n===void 0){this.#O?.forEach(e=>e.remove()),this.#O=void 0;return}let r=this.#O??=new Map;for(let[e,t]of r)this.#wn(e.caret.focus.line)||(t.remove(),r.delete(e));let i=document.createDocumentFragment(),a=[];for(let n of e){let{caret:e}=n,{line:o,character:s}=e.focus;if(n.anchorOffset!==n.focusOffset){let t={fragment:i,elements:new Map};this.#Kt(t,`caretHighlight`,n.anchorOffset<n.focusOffset?{start:e.anchor,end:e.focus}:{start:e.focus,end:e.anchor},void 0,e.focus);for(let n of t.elements.values())n.style.setProperty(`--diffs-caret-highlight-bg`,`color-mix(in srgb, ${e.metadata.color} 32%, transparent)`),a.push(n)}if(!this.#wn(o))continue;let c=r.get(n);c===void 0&&(c=U(`div`,{dataset:`remoteCaret`,children:[t(e)]},i),r.set(n,c));let[l,u]=this.#bn(o,s),d=this.#yn(o)+u*this.#r.lineHeight;c.style.transform=`translateX(${l}px) translateY(${d}px)`}this.#k=a,n.appendChild(i)}#Kt(e,t,n,r,i){if(this.#n?.document==null)return;let{start:a,end:o}=n,s=a.line,c=o.line+1;if(this.#V!==void 0){let{startingLine:e,totalLines:t}=this.#V;s=Math.max(s,e),c=Math.min(c,e+t)}for(let n=s;n<c;n++){if(!this.#wn(n))continue;let s=n===o.line,c=n===a.line?a.character:0,l=s?o.character:this.#n?.document.getLineLength(n);if(c===l&&(t===`editPredictionDeletion`||t===`editPredictionReplacement`)){if(s&&n!==a.line)continue;let[i,o]=this.#bn(n,c);this.#Yt(e,t,n,o,i,this.#r.ch,r);continue}if(this.#Le){let a=this.#vn(),o=this.#n?.document.getLineText(n);if(2*this.#r.ch+this.#r.measureTextWidth(o)>a){this.#qt(e,n,o,c,l,s,t,r,i);continue}}let u=0,d=0,f=0;u=c===0?this.#_n()+this.#r.ch+(this.#$e?.left??0):this.#bn(n,c)[0],!s&&t===`selection`&&(f=this.#r.ch),d=c===l?f:this.#bn(n,l)[0]-u+f,this.#Yt(e,t,n,0,u,d,r,{start:i?.line===a.line&&i.character===a.character&&n===a.line,end:i?.line===o.line&&i.character===o.character&&n===o.line})}}#qt(e,t,n,r,i,a,o,s,c){let l=this.#Sn(t),u=l.length-1,d=this.#_n()+this.#r.ch+(this.#$e?.left??0);for(let f=0;f<u;f++){let p=l[f],m=l[f+1],h=Math.max(r,p),g=Math.min(i,m);if(h>g)continue;let _=this.#Jt(n,p,h),v=d+_,y=0;!a&&f===u-1&&o===`selection`&&(y=this.#r.ch);let b=h===g?y:this.#Jt(n,p,g)-_+y;this.#Yt(e,o,t,f,v,b,s,{start:c?.line===t&&c.character===r&&h===r,end:c?.line===t&&c.character===i&&g===i})}}#Jt(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=La(r,this.#r.tabSize);return i===-1?this.#r.measureTextWidth(r):i*this.#r.ch}#Yt(e,t,n,r,i,a,o,s){if(a===0)return;let{ch:c,lineHeight:l}=this.#r,u=this.#yn(n)+r*l,d=`${t}-${n}/${r}-${i}-${a} ${o??``}`,f=this.#D,p=(this.#e.roundedSelection??!0)&&(t===`selection`||t===`caretHighlight`),m=(n,r,i,a)=>{let o=this.#yn(n)+r*l,s=this.#gn(n),u=`initial`;s!==void 0&&(s.dataset.lineType===`change-addition`||s.dataset.selectedLine!==void 0)&&(u=getComputedStyle(s).getPropertyValue(`--diffs-line-bg`));let d=`width:${c}px;transform:translateX(${i}px) translateY(${o}px);--diffs-selection-corner-bg:${u}`,p={selectionCorner:``,[a]:``},m=`${t}-block-${n}/${r}-${i}-1ch`,h=m+`-`+a;if(a===`rbl`){let t=m+`-rtl`,n=e.elements.get(t);n!==void 0&&(n.remove(),e.elements.delete(t),h+=`-rtl`,p.rtl=``)}let g=e.elements.get(h);g===void 0&&(f?.has(h)===!0?(g=f.get(h),g.style.cssText=d,f.delete(h)):g=U(`div`,{dataset:t===`caretHighlight`?`caretHighlightRange`:`selectionRange`,style:{cssText:d},children:[U(`div`,{dataset:p})]},e.fragment),e.elements.set(h,g))},h=t=>{let o=i+a,l=t.dataset,u=e.previousSelectionRange;if((u===void 0||u.line!==n||u.wrapLine!==r)&&(e.previousSelectionRange={element:t,line:n,wrapLine:r,left:i,width:a}),u===void 0||o<=u.left)[`rtl`,`rtr`,`rbl`,`rbr`].forEach(e=>{l[e]=``});else{let e=u.line,t=u.wrapLine,a=u.left,s=u.element.dataset,d=a+u.width;a>i&&m(e,t,a-c,`rbr`),delete s.rbl,delete l.rtl,delete l.rtr,o>=d&&delete s.rbr,o>d&&(m(e,t,d,`rbl`),l.rtr=``),o<d&&m(n,r,o,`rtl`),i<a&&(l.rtl=``),l.rbl=``,l.rbr=``}s?.start===!0&&(delete l.rtl,delete l.rbl),s?.end===!0&&(delete l.rtr,delete l.rbr)},g=e.elements.get(d);if(g!==void 0){p&&h(g);return}if(f?.has(d)===!0?(g=f.get(d),f.delete(d)):g=U(`div`,{dataset:o?[t+`Range`,o]:t+`Range`},e.fragment),g.style.width=`${a}px`,g.style.transform=`translateX(${i}px) translateY(${u}px)`,t===`editPredictionInsertion`||t===`editPredictionReplacement`){let e=this.#gn(n);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else g.style.removeProperty(`--diffs-edit-prediction-bg`);p&&h(g),e.elements.set(d,g)}#Xt(e,t,n){let{line:r,character:i}=Y(t);if(!this.#wn(r))return;let[a,o]=this.#bn(r,i),s=`caret-`+r+`/`+o+`:`+i;if(e.elements.has(s))return;let c=a-1,l=this.#yn(r)+o*this.#r.lineHeight,u=U(`div`,{dataset:`caret`,style:{transform:`translateX(${c}px) translateY(${l}px)`}},e.fragment);e.elements.set(s,u),n&&(u.style.scrollMargin=this.#_t(),this.#A=u)}#Zt(){let e=this.#se?.at(-1),t=this.#E,n=this.#n?.document,r=this.#e.renderSelectionAction,i=()=>{this.#K?.cleanup(),this.#K=void 0};if(this.#e.enabledSelectionAction!==!0||r===void 0||e===void 0||J(e)||this.#ee||t===void 0||n===void 0){i();return}let a=Y(e);if(!this.#wn(a.line)){i();return}if(this.#K===void 0){if(!this.#q)return;let a=()=>this.#se?.at(-1)??e,o=r({textDocument:n,get selection(){return a()},applyEdits:e=>this.applyEdits(e),getSelectionText:()=>this.#n?.document?.getText(a())??``,replaceSelectionText:e=>{this.#an(e,[a()])},close:()=>{i(),this.#gt()}});this.#K=new Aa(o,t,()=>this.#Zt()),this.#Re().resetPlacement($a)}let o=this.#r.lineHeight,s=e.direction===-1,c={placeAbove:s,anchor:a},l=s?{placeAbove:!1,anchor:e.end}:{placeAbove:!0,anchor:e.start},u=this.#K.height,d=e=>{let[t,n]=this.#bn(e.anchor.line,e.anchor.character),r=this.#yn(e.anchor.line)+n*o,i=e.placeAbove?r:r+o,a=e.placeAbove?i-u:i;return{top:a,bottom:a+u,left:t,anchorTop:i,rowTop:r}},f=d(c),p=n.lineCount,m=s?a.line<3:a.line>=p-3,h=this.#wn(l.anchor.line)?d(l):void 0,g=this.#Re(),_=g.getPlacementBounds(),v=h!==void 0&&g.choosePlacement({preferred:f,fallback:h,viewport:_,popoverHeight:u,atDocumentEdge:m,placementKey:$a})===`fallback`;h===void 0&&g.setPlacement(`preferred`,$a);let{placeAbove:y}=v?l:c,{left:b,anchorTop:x}=v&&h!==void 0?h:f,S=s?f.rowTop:h?.rowTop??-1/0,C=(s?h?.rowTop??1/0:f.rowTop)+(e.end.line>e.start.line&&e.end.character===0?0:o),w=_===void 0||C>_.top&&S<_.bottom;this.#K.reposition(b,x,this.#_n(),y,w,_)}#Qt(e){if(this.#G!==void 0){this.#G.setMode(e);return}this.#$t(e)}#$t(e){this.#G?.cleanup();let t=this.#n?.document,n=this.#S?.shadowRoot?.querySelector(`pre`),r=this.#se;if(t===void 0||n==null)return;let i=``,a;if(r!==void 0&&r.length>0){let e=r.at(-1);if(J(e)){e=ai(t,e),this.#Wt([...r.slice(0,-1),e]);let n=t.getText(e);n!==``&&!n.includes(`
|
|
31
|
-
`)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Lr(t,e,n);this.#Wt([i]),this.#Pe(Y(i).line),this.#gt(!0),this.#pe=r},s=new ct({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:Qr(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:Zr(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(eo,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>J(e))){let n=ri(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=Qr(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?Er(i,t,e,this.#R,n,r):Cr(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Pr(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=jr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Mr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Ar(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=kr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Rr(t.anchorOffset,e.changes),t.focusOffset=Rr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*qa;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(Y(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=Y(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=$n(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=W(e);if(i===void 0||r===void 0||!Fr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=W(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&Fr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=Fa(n,Math.min(t,n.length)),a=n.slice(0,i),o=La(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=La(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Ja&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=U(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ia(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=Fe()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function no({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Yn.activate(e,t,n,a)}function ro(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function io(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function ao(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=n(),oo=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function so(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(e){if(e.dataTransfer===null)return;let r=null;for(let t of e.composedPath())if(r=oo(t),r!==null)break;if(r===null)return;let i=t.includes(r)?t:[r],a=i.map(e=>bn(e)).filter(e=>e!==null);a.length!==0&&(n=i,e.dataTransfer.setData(xn,a.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function co(e){return e.split(`/`).filter(Boolean).length}function lo(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>co(e)-co(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>co(e)-co(t));for(let e of s)a.push({type:`add`,path:e});return a}function uo(e,t){let[n,r]=(0,q.useState)(new Map),[i,a]=(0,q.useState)(new Map),[o,s]=(0,q.useState)(0),[c,l]=(0,q.useState)(new Set),d=(0,q.useRef)(new Map),f=(0,q.useRef)(new Set),p=(0,q.useRef)(new Set),m=(0,q.useRef)(!0),h=(0,q.useRef)(0),_=(0,q.useRef)([]),v=(0,q.useCallback)(function n(i,o=!1){let c=d.current.get(i);if(c)return o?c.then(()=>n(i,!0)):c;if(!o&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let v=ie.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});s(e=>e+1),o||l(e=>new Set(e).add(i));let y=(async()=>{h.current>=4?await new Promise(e=>_.current.push(e)):h.current++;try{return m.current?await k(g,v,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=_.current.shift();e?e():h.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),a(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=u(e.cause);a(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{d.current.delete(i),m.current&&(s(e=>e-1),o||l(e=>{let t=new Set(e);return t.delete(i),t}))});return d.current.set(i,y),y},[t,e]);(0,q.useEffect)(()=>(m.current=!0,v(``),()=>{m.current=!1}),[v]);let y=(0,q.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),b=(0,q.useMemo)(()=>new Set([``,...y.filter(e=>e.kind===`directory`).map(e=>e.path)]),[y]);return{entries:y,load:v,refresh:(0,q.useCallback)(()=>{let e=[...p.current].filter(e=>b.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await v(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[v,b]),isPending:o>0,loadingDirectories:c,ready:n.has(``),error:[...i].find(([e])=>b.has(e))?.[1]??null}}var $=e(r(),1);function fo(e){return e.kind===`directory`?`${e.path}/`:e.path}function po(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(gn,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(vt,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(yt,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(bt,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function mo(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(sn,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(on,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function ho({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s}){let{resolvedTheme:c}=ye(),l=C(),u=De(e),{entries:d,load:f,refresh:p,ready:m,error:h,isPending:g,loadingDirectories:_}=uo(e,t),[y,b]=(0,q.useState)(``),[x,S]=(0,q.useState)(!1),w=ke({environmentId:e,cwd:t,query:y.slice(0,256)},200),T=(0,q.useMemo)(()=>{let e=new Map(d.map(e=>[e.path,e]));if(y.trim()&&!w.isPending)for(let t of w.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[d,w.entries,w.isPending,y]),E=(0,q.useMemo)(()=>new Map(T.map(e=>[e.path,e.kind])),[T]),ee=(0,q.useRef)(E),D=(0,q.useMemo)(()=>T.map(fo),[T]),O=(0,q.useMemo)(()=>T.filter(e=>e.kind===`directory`).map(fo),[T]),k=(0,q.useRef)(null),te=(0,q.useRef)(!1),ne=(0,q.useRef)(null),re=(0,q.useRef)(null),ie=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{ie.current={x:e.clientX,y:e.clientY,at:e.timeStamp}};return document.addEventListener(`contextmenu`,e,!0),()=>document.removeEventListener(`contextmenu`,e,!0)},[]);let A=async(n,r)=>{let i=I();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=an(a),s=ie.current,c=s!==null&&performance.now()-s.at<1e3,d=r.anchorElement.getBoundingClientRect(),f=c?{x:s.x,y:s.y}:{x:d.left,y:d.bottom},p={environmentId:e,filePath:a,workspaceRoot:t},m=u.buildItems(p);try{let e=await i.contextMenu.show([...m,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],f);if(e===null)return;if(m.some(t=>t.id===e)||e.startsWith(`editor:`)){await u.activate(e,p);return}if(e===`copy-mention`){try{await _e(o),ge.add({type:`success`,title:`Mention copied`,description:a})}catch(e){ge.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}return}if(e===`add-to-chat`){let e=l?.current;if(!e){ge.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||ge.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}finally{r.close()}},j=(0,q.useRef)(A);(0,q.useEffect)(()=>{j.current=A});let ae=(0,q.useRef)(_),oe=(0,q.useRef)(null),se=(0,q.useMemo)(()=>so({deselect:e=>oe.current?.getItem(e)?.deselect()}),[]),{model:M}=Nt({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{j.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Ft,onSelectionChange:e=>{if(se.handleSelectionChange(e),te.current||se.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&ee.current.get(t)===`file`&&(ne.current=t,a(t))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ae.current.has(e.path.replace(/\/$/,``))?{icon:`p4-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>b(e??``),unsafeCSS:Mt});(0,q.useEffect)(()=>{ae.current!==_&&(ae.current=_,M.setComposition(M.getComposition()))},[_,M]);let ce=wn(M),le=jt(M,e=>Pt(e,O)),pe=()=>{let e=!(x||le);S(e),At(M,O,e)},N=()=>{b(``),ce.close()},P=(0,q.useRef)(new Set);(0,q.useEffect)(()=>{let e=new Set(O);for(let t of P.current)e.has(t)||P.current.delete(t);let t=()=>{if(!M.isSearchOpen())for(let e of O){let t=M.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?P.current.has(e)||(P.current.add(e),f(e.replace(/\/$/,``))):(t?.isDirectory()&&P.current.has(e)&&S(!1),P.current.delete(e))}};return t(),M.subscribe(t)},[O,f,M]),(0,q.useEffect)(()=>{M.setGitStatus(T.filter(e=>e.ignored).map(e=>({path:fo(e),status:`ignored`})))},[T,M]),(0,q.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await f(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[f,r]);let me=e=>{if(b(e),e.trim().length===0){ce.close();return}ce.setValue(e)},he=()=>{p(),y.trim()&&w.refresh(),o?.()};vn({mutationId:s,refresh:()=>{p(),y.trim()&&w.refresh()},resourceKey:`files:${e}:${t}`}),(0,q.useEffect)(()=>{if(!m||k.current===D)return;ee.current=E;let e=k.current;if(k.current=D,e===null){M.resetPaths(D);return}let t=lo(e,D);t.length>0&&M.batch(t)},[m,E,M,D]),(0,q.useEffect)(()=>{x&&!y.trim()&&At(M,O,!0)},[O,x,M,y]),(0,q.useEffect)(()=>{if(!r){re.current=null;return}let e=E.get(r);if(e===void 0){re.current=null;return}let t={path:r,revealId:i},n=re.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=M.getItem(a);if(!o)return;if(M.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&ne.current===r){ne.current=null,re.current=t;return}ne.current=null,re.current=t,te.current=!0,b(``),M.closeSearch();for(let e of M.getSelectedPaths())M.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=M.getItem(`${c}/`)??M.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),M.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{te.current=!1})},[E,M,r,i]);let F=(0,q.useRef)(null);return(0,q.useEffect)(()=>{oe.current=M},[M]),(0,q.useEffect)(()=>{let e=F.current;if(e===null)return;let t=e=>se.handleDragStart(e),n=()=>se.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[se]),(0,$.jsxs)(`div`,{ref:F,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(po,{isPending:g,onRefresh:he}),(0,$.jsx)(mo,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:ce.value,onValueChange:me,onClose:N}),O.length>0?(0,$.jsx)(v,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":x||le?`Collapse all folders`:`Expand all folders`,onClick:pe,children:(0,$.jsx)(fe,{className:`size-3.5`,icon:le?de:ue})}):null]}),h||w.error?(0,$.jsxs)(`button`,{type:`button`,onClick:he,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[h??w.error,` Click to retry.`]}):null,y.trim()&&w.truncated&&!w.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!m||w.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(Ot,{model:M,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:kt(c)})]})}function go(e,t){let n=M(t),r=j(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:n&&r===`/`?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>({label:e,path:a+i.slice(0,t+1).join(r),kind:t===i.length-1?`file`:`directory`}))]}function _o(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function vo(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function yo(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function bo(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=ee(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(vt,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(yt,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(bt,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function xo(e){let t=(0,Q.c)(44),n=mn(e.environmentId,e.cwd,e.directoryPath),r=`files:${e.environmentId}:${e.cwd}`,a;t[0]!==n.refresh||t[1]!==e.workspaceMutationId||t[2]!==r?(a={mutationId:e.workspaceMutationId,refresh:n.refresh,resourceKey:r},t[0]=n.refresh,t[1]=e.workspaceMutationId,t[2]=r,t[3]=a):a=t[3],vn(a);let{resolvedTheme:o}=ye(),s;t[4]===n.data?.entries?s=t[5]:(s=n.data?.entries??[],t[4]=n.data?.entries,t[5]=s);let l=s,u=n.data?.truncated??!1,d;t[6]!==l||t[7]!==e.directoryPath?(d=_o(l,e.directoryPath),t[6]=l,t[7]=e.directoryPath,t[8]=d):d=t[8];let f=d,p=n.data!==null,m,g,v,y,b;if(t[9]!==e){let n=vo(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));m=D,g=`start`,v=`bottom`,y=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},b=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(T,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,yo(n,e.projectName)]})]}),(0,$.jsx)(_,{})]}):null,t[9]=e,t[10]=m,t[11]=g,t[12]=v,t[13]=y,t[14]=b}else m=t[10],g=t[11],v=t[12],y=t[13],b=t[14];let x;t[15]!==f||t[16]!==p||t[17]!==n.data||t[18]!==n.error||t[19]!==n.isPending||t[20]!==n.refresh||t[21]!==u||t[22]!==e||t[23]!==o?(x=n.isPending&&n.data===null?(0,$.jsxs)(i,{disabled:!0,children:[(0,$.jsx)(F,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(gn,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!p&&!u?(0,$.jsx)(i,{disabled:!0,children:`This folder is no longer available.`}):f.length===0?(0,$.jsx)(i,{disabled:!0,children:u?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(w,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:f.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,r=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rn,{pathValue:t.path,kind:t.kind,theme:o}),(0,$.jsxs)(bt,{children:[(0,$.jsx)(vt,{render:(0,$.jsx)(`span`,{className:ee(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(yt,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[r,(0,$.jsx)(c,{})]},t.path):(0,$.jsx)(E,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:r})},t.path)})}),t[15]=f,t[16]=p,t[17]=n.data,t[18]=n.error,t[19]=n.isPending,t[20]=n.refresh,t[21]=u,t[22]=e,t[23]=o,t[24]=x):x=t[24];let S;t[25]!==e.directoryPath||t[26]!==x?(S=(0,$.jsx)(h,{children:x},e.directoryPath),t[25]=e.directoryPath,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==n.data||t[29]!==n.error||t[30]!==n.isPending||t[31]!==n.refresh?(C=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{}),(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(gn,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[28]=n.data,t[29]=n.error,t[30]=n.isPending,t[31]=n.refresh,t[32]=C):C=t[32];let O;t[33]===u?O=t[34]:(O=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{}),(0,$.jsx)(i,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[33]=u,t[34]=O);let k;return t[35]!==m||t[36]!==C||t[37]!==O||t[38]!==g||t[39]!==v||t[40]!==y||t[41]!==b||t[42]!==S?(k=(0,$.jsxs)(m,{align:g,side:v,onKeyDown:y,children:[b,S,C,O]}),t[35]=m,t[36]=C,t[37]=O,t[38]=g,t[39]=v,t[40]=y,t[41]=b,t[42]=S,t[43]=k):k=t[43],k}function So(e){let t=(0,Q.c)(35),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,q.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,u=`Browse ${e.crumb.label}`,d;t[7]===u?d=t[8]:(d=(0,$.jsx)(O,{render:(0,$.jsx)(`button`,{type:`button`,"aria-label":u,className:`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left text-muted-foreground outline-none pointer-coarse:after:-inset-y-3 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`})}),t[7]=u,t[8]=d);let f;t[9]===e.crumb.label?f=t[10]:(f=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[9]=e.crumb.label,t[10]=f);let p;t[11]!==d||t[12]!==f?(p=(0,$.jsx)(vt,{render:d,children:f}),t[11]=d,t[12]=f,t[13]=p):p=t[13];let h=e.crumb.path||e.projectName,g;t[14]===h?g=t[15]:(g=(0,$.jsx)(yt,{side:`top`,children:h}),t[14]=h,t[15]=g);let _;t[16]!==p||t[17]!==g?(_=(0,$.jsxs)(bt,{children:[p,g]}),t[16]=p,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==i||t[20]!==l||t[21]!==n||t[22]!==e.crumb.path||t[23]!==e.cwd||t[24]!==e.environmentId||t[25]!==e.onOpenFile||t[26]!==e.projectName||t[27]!==e.relativePath||t[28]!==e.workspaceMutationId?(v=n?(0,$.jsx)(xo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[19]=i,t[20]=l,t[21]=n,t[22]=e.crumb.path,t[23]=e.cwd,t[24]=e.environmentId,t[25]=e.onOpenFile,t[26]=e.projectName,t[27]=e.relativePath,t[28]=e.workspaceMutationId,t[29]=v):v=t[29];let y;return t[30]!==l||t[31]!==n||t[32]!==v||t[33]!==_?(y=(0,$.jsxs)(m,{open:n,onOpenChange:l,children:[_,v]}),t[30]=l,t[31]=n,t[32]=v,t[33]=_,t[34]=y):y=t[34],y}function Co(e){let t=(0,Q.c)(12),n;t[0]===e.relativePath?n=t[1]:(n=M(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.relativePath?(i=go(e.projectName,e.relativePath),t[2]=e.projectName,t[3]=e.relativePath,t[4]=i):i=t[4];let a=i,o;if(t[5]!==a||t[6]!==r||t[7]!==e){let n;t[9]!==r||t[10]!==e?(n=(t,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":t.kind===`file`,children:[n>0?(0,$.jsx)(c,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,t.kind===`file`?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(bo,{current:!0,label:t.label,pathLabel:t.path})}):r?(0,$.jsx)(bo,{label:t.label,pathLabel:t.path}):(0,$.jsx)(So,{...e,crumb:t})]},t.path||`project`),t[9]=r,t[10]=e,t[11]=n):n=t[11],o=a.map(n),t[5]=a,t[6]=r,t[7]=e,t[8]=o}else o=t[8];return o}function wo(e){let t=(0,Q.c)(14),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?Ee(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;return t[8]!==o||t[9]!==e.cwd||t[10]!==e.onTaskListChange||t[11]!==e.text||t[12]!==e.threadRef?(s=(0,$.jsx)(me,{text:e.text,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[8]=o,t[9]=e.cwd,t[10]=e.onTaskListChange,t[11]=e.text,t[12]=e.threadRef,t[13]=s):s=t[13],s}function To({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Eo(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function Do({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||To({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Eo(e)&&(i.preventDefault(),i.stopImmediatePropagation(),To({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function Oo(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function ko(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Ao(e,t,n){return`${e}:${t}:${ko(n)}`}function jo(e,t){return e===null||e===`.`||A(e,t)===`.`?null:e}var Mo=e=>/\.(?:md|mdx)$/i.test(e);function No(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function Po(e){return e.attachmentOpen||e.relativePath&&M(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Fo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function Io(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Lo=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},Ro=500;function zo(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=Ce(n,f),s=Te(ie.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Lo({debounceMs:Ro,canPersist:()=>we(n,f),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>pn(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let p=d,m;t[8]===p?m=t[9]:(m=[p],t[8]=p,t[9]=m),(0,q.useEffect)(p.setup,m);let h,g;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==p?(h=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=fn(n,r,i);t&&p.change(t.contents)}),()=>{e=!0}},g=[o,r,n,i,p],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=p,t[15]=h,t[16]=g):(h=t[15],g=t[16]),(0,q.useEffect)(h,g),p}var Bo=`p4code.fileExplorerOpen`,Vo=`p4code.renderMarkdown`,Ho=`p4code.renderBrowserFile`,Uo=`p4code.renderTable`;function Wo(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),[a,o]=(0,q.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=_t(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(P,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(P,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(F,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function Go(e){let t=(0,Q.c)(19),n=_t(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=Io({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=Zt(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(F,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=`${e.environmentId}:${i._tag}:${e.threadRef.threadId}:${e.absolutePath}:${e.workspaceMutationId}`,u=e.title,d;t[12]===e.absolutePath?d=t[13]:(d=Bt(e.absolutePath),t[12]=e.absolutePath,t[13]=d);let f;return t[14]!==e.title||t[15]!==c||t[16]!==l||t[17]!==d?(f=(0,$.jsx)(zt,{src:c,documentKey:l,title:u,pdf:d}),t[14]=e.title,t[15]=c,t[16]=l,t[17]=d,t[18]=f):f=t[18],f}function Ko(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),a=Qt(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(qo)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],vn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=_t(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(N,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function qo(){}function Jo(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),a=Qt(e.environmentId,r),[o,s]=(0,q.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(Xo)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],vn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(Kt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(Yo)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ht,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(Lt,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function Yo(){}function Xo(){}function Zo(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function Qo(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Wt}]`))e.removeAttribute(Wt);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Wt,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Wt,``))}var $o=30,es=20,ts=2;function ns(e,t,n){let r=(0,Q.c)(5),[i]=(0,q.useState)(rs),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(Qo(r,t===null||u===void 0?null:Zo(u,t)),!(a instanceof Ye))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return Oo({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=es,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>ts&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:Zo(i,t),s=o===null?null:f(o);if(o===null||s===null){e<$o&&m(e+1);return}Qo(r,o),d.scrollTop=s,c.handledRequestId=n,p(o)})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function rs(){return new Map}var is=(e,t,n)=>new to(e,t,n);function as(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Ao(t,n,r)}`}}function os(e,t){if(e?.isWorkingPool()!==!0||(t.lang??hn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
|
|
31
|
+
`)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Lr(t,e,n);this.#Wt([i]),this.#Pe(Y(i).line),this.#gt(!0),this.#pe=r},s=new ct({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:Qr(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:Zr(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(eo,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>J(e))){let n=ri(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=Qr(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?Er(i,t,e,this.#R,n,r):Cr(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Pr(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=jr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Mr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Ar(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=kr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Rr(t.anchorOffset,e.changes),t.focusOffset=Rr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*qa;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(Y(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=Y(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=$n(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=W(e);if(i===void 0||r===void 0||!Fr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=W(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&Fr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=Fa(n,Math.min(t,n.length)),a=n.slice(0,i),o=La(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=La(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Ja&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=U(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ia(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=Ie()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function no({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Yn.activate(e,t,n,a)}function ro(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function io(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function ao(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=n(),oo=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function so(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(e){if(e.dataTransfer===null)return;let r=null;for(let t of e.composedPath())if(r=oo(t),r!==null)break;if(r===null)return;let i=t.includes(r)?t:[r],a=i.map(e=>bn(e)).filter(e=>e!==null);a.length!==0&&(n=i,e.dataTransfer.setData(xn,a.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function co(e){return e.split(`/`).filter(Boolean).length}function lo(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>co(e)-co(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>co(e)-co(t));for(let e of s)a.push({type:`add`,path:e});return a}function uo(e,t){let[n,r]=(0,q.useState)(new Map),[i,a]=(0,q.useState)(new Map),[o,s]=(0,q.useState)(0),[c,l]=(0,q.useState)(new Set),d=(0,q.useRef)(new Map),f=(0,q.useRef)(new Set),p=(0,q.useRef)(new Set),m=(0,q.useRef)(!0),h=(0,q.useRef)(0),_=(0,q.useRef)([]),v=(0,q.useCallback)(function n(i,o=!1){let c=d.current.get(i);if(c)return o?c.then(()=>n(i,!0)):c;if(!o&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let v=ie.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});s(e=>e+1),o||l(e=>new Set(e).add(i));let y=(async()=>{h.current>=4?await new Promise(e=>_.current.push(e)):h.current++;try{return m.current?await k(g,v,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=_.current.shift();e?e():h.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),a(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=u(e.cause);a(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{d.current.delete(i),m.current&&(s(e=>e-1),o||l(e=>{let t=new Set(e);return t.delete(i),t}))});return d.current.set(i,y),y},[t,e]);(0,q.useEffect)(()=>(m.current=!0,v(``),()=>{m.current=!1}),[v]);let y=(0,q.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),b=(0,q.useMemo)(()=>new Set([``,...y.filter(e=>e.kind===`directory`).map(e=>e.path)]),[y]);return{entries:y,load:v,refresh:(0,q.useCallback)(()=>{let e=[...p.current].filter(e=>b.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await v(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[v,b]),isPending:o>0,loadingDirectories:c,ready:n.has(``),error:[...i].find(([e])=>b.has(e))?.[1]??null}}var $=e(r(),1);function fo(e){return e.kind===`directory`?`${e.path}/`:e.path}function po(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(v,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(_n,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(vt,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(yt,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(bt,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function mo(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(sn,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(on,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function ho({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s}){let{resolvedTheme:c}=be(),l=C(),u=Oe(e),{entries:d,load:f,refresh:p,ready:m,error:h,isPending:g,loadingDirectories:_}=uo(e,t),[y,b]=(0,q.useState)(``),[x,S]=(0,q.useState)(!1),w=Ae({environmentId:e,cwd:t,query:y.slice(0,256)},200),T=(0,q.useMemo)(()=>{let e=new Map(d.map(e=>[e.path,e]));if(y.trim()&&!w.isPending)for(let t of w.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[d,w.entries,w.isPending,y]),E=(0,q.useMemo)(()=>new Map(T.map(e=>[e.path,e.kind])),[T]),ee=(0,q.useRef)(E),D=(0,q.useMemo)(()=>T.map(fo),[T]),O=(0,q.useMemo)(()=>T.filter(e=>e.kind===`directory`).map(fo),[T]),k=(0,q.useRef)(null),te=(0,q.useRef)(!1),ne=(0,q.useRef)(null),re=(0,q.useRef)(null),ie=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{ie.current={x:e.clientX,y:e.clientY,at:e.timeStamp}};return document.addEventListener(`contextmenu`,e,!0),()=>document.removeEventListener(`contextmenu`,e,!0)},[]);let A=async(n,r)=>{let i=F();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=an(a),s=ie.current,c=s!==null&&performance.now()-s.at<1e3,d=r.anchorElement.getBoundingClientRect(),f=c?{x:s.x,y:s.y}:{x:d.left,y:d.bottom},p={environmentId:e,filePath:a,workspaceRoot:t},m=u.buildItems(p);try{let e=await i.contextMenu.show([...m,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],f);if(e===null)return;if(m.some(t=>t.id===e)||e.startsWith(`editor:`)){await u.activate(e,p);return}if(e===`copy-mention`){try{await ve(o),_e.add({type:`success`,title:`Mention copied`,description:a})}catch(e){_e.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}return}if(e===`add-to-chat`){let e=l?.current;if(!e){_e.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||_e.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}finally{r.close()}},j=(0,q.useRef)(A);(0,q.useEffect)(()=>{j.current=A});let ae=(0,q.useRef)(_),oe=(0,q.useRef)(null),se=(0,q.useMemo)(()=>so({deselect:e=>oe.current?.getItem(e)?.deselect()}),[]),{model:M}=Nt({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{j.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Ft,onSelectionChange:e=>{if(se.handleSelectionChange(e),te.current||se.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&ee.current.get(t)===`file`&&(ne.current=t,a(t))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ae.current.has(e.path.replace(/\/$/,``))?{icon:`p4-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>b(e??``),unsafeCSS:Mt});(0,q.useEffect)(()=>{ae.current!==_&&(ae.current=_,M.setComposition(M.getComposition()))},[_,M]);let ce=wn(M),le=jt(M,e=>Pt(e,O)),pe=()=>{let e=!(x||le);S(e),At(M,O,e)},N=()=>{b(``),ce.close()},P=(0,q.useRef)(new Set);(0,q.useEffect)(()=>{let e=new Set(O);for(let t of P.current)e.has(t)||P.current.delete(t);let t=()=>{if(!M.isSearchOpen())for(let e of O){let t=M.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?P.current.has(e)||(P.current.add(e),f(e.replace(/\/$/,``))):(t?.isDirectory()&&P.current.has(e)&&S(!1),P.current.delete(e))}};return t(),M.subscribe(t)},[O,f,M]),(0,q.useEffect)(()=>{M.setGitStatus(T.filter(e=>e.ignored).map(e=>({path:fo(e),status:`ignored`})))},[T,M]),(0,q.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await f(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[f,r]);let me=e=>{if(b(e),e.trim().length===0){ce.close();return}ce.setValue(e)},he=()=>{p(),y.trim()&&w.refresh(),o?.()};vn({mutationId:s,refresh:()=>{p(),y.trim()&&w.refresh()},resourceKey:`files:${e}:${t}`}),(0,q.useEffect)(()=>{if(!m||k.current===D)return;ee.current=E;let e=k.current;if(k.current=D,e===null){M.resetPaths(D);return}let t=lo(e,D);t.length>0&&M.batch(t)},[m,E,M,D]),(0,q.useEffect)(()=>{x&&!y.trim()&&At(M,O,!0)},[O,x,M,y]),(0,q.useEffect)(()=>{if(!r){re.current=null;return}let e=E.get(r);if(e===void 0){re.current=null;return}let t={path:r,revealId:i},n=re.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=M.getItem(a);if(!o)return;if(M.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&ne.current===r){ne.current=null,re.current=t;return}ne.current=null,re.current=t,te.current=!0,b(``),M.closeSearch();for(let e of M.getSelectedPaths())M.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=M.getItem(`${c}/`)??M.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),M.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{te.current=!1})},[E,M,r,i]);let ge=(0,q.useRef)(null);return(0,q.useEffect)(()=>{oe.current=M},[M]),(0,q.useEffect)(()=>{let e=ge.current;if(e===null)return;let t=e=>se.handleDragStart(e),n=()=>se.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[se]),(0,$.jsxs)(`div`,{ref:ge,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(po,{isPending:g,onRefresh:he}),(0,$.jsx)(mo,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:ce.value,onValueChange:me,onClose:N}),O.length>0?(0,$.jsx)(v,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":x||le?`Collapse all folders`:`Expand all folders`,onClick:pe,children:(0,$.jsx)(fe,{className:`size-3.5`,icon:le?de:ue})}):null]}),h||w.error?(0,$.jsxs)(`button`,{type:`button`,onClick:he,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[h??w.error,` Click to retry.`]}):null,y.trim()&&w.truncated&&!w.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!m||w.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(Ot,{model:M,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:kt(c)})]})}function go(e,t){let n=M(t),r=j(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:n&&r===`/`?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>({label:e,path:a+i.slice(0,t+1).join(r),kind:t===i.length-1?`file`:`directory`}))]}function _o(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function vo(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function yo(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function bo(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=ee(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(vt,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(yt,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(bt,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function xo(e){let t=(0,Q.c)(44),n=mn(e.environmentId,e.cwd,e.directoryPath),r=`files:${e.environmentId}:${e.cwd}`,a;t[0]!==n.refresh||t[1]!==e.workspaceMutationId||t[2]!==r?(a={mutationId:e.workspaceMutationId,refresh:n.refresh,resourceKey:r},t[0]=n.refresh,t[1]=e.workspaceMutationId,t[2]=r,t[3]=a):a=t[3],vn(a);let{resolvedTheme:o}=be(),s;t[4]===n.data?.entries?s=t[5]:(s=n.data?.entries??[],t[4]=n.data?.entries,t[5]=s);let l=s,u=n.data?.truncated??!1,d;t[6]!==l||t[7]!==e.directoryPath?(d=_o(l,e.directoryPath),t[6]=l,t[7]=e.directoryPath,t[8]=d):d=t[8];let f=d,p=n.data!==null,m,g,v,y,b;if(t[9]!==e){let n=vo(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));m=D,g=`start`,v=`bottom`,y=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},b=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(T,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,yo(n,e.projectName)]})]}),(0,$.jsx)(_,{})]}):null,t[9]=e,t[10]=m,t[11]=g,t[12]=v,t[13]=y,t[14]=b}else m=t[10],g=t[11],v=t[12],y=t[13],b=t[14];let x;t[15]!==f||t[16]!==p||t[17]!==n.data||t[18]!==n.error||t[19]!==n.isPending||t[20]!==n.refresh||t[21]!==u||t[22]!==e||t[23]!==o?(x=n.isPending&&n.data===null?(0,$.jsxs)(i,{disabled:!0,children:[(0,$.jsx)(ge,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(_n,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!p&&!u?(0,$.jsx)(i,{disabled:!0,children:`This folder is no longer available.`}):f.length===0?(0,$.jsx)(i,{disabled:!0,children:u?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(w,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:f.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,r=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rn,{pathValue:t.path,kind:t.kind,theme:o}),(0,$.jsxs)(bt,{children:[(0,$.jsx)(vt,{render:(0,$.jsx)(`span`,{className:ee(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(yt,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[r,(0,$.jsx)(c,{})]},t.path):(0,$.jsx)(E,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:r})},t.path)})}),t[15]=f,t[16]=p,t[17]=n.data,t[18]=n.error,t[19]=n.isPending,t[20]=n.refresh,t[21]=u,t[22]=e,t[23]=o,t[24]=x):x=t[24];let S;t[25]!==e.directoryPath||t[26]!==x?(S=(0,$.jsx)(h,{children:x},e.directoryPath),t[25]=e.directoryPath,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==n.data||t[29]!==n.error||t[30]!==n.isPending||t[31]!==n.refresh?(C=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{}),(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(_n,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[28]=n.data,t[29]=n.error,t[30]=n.isPending,t[31]=n.refresh,t[32]=C):C=t[32];let O;t[33]===u?O=t[34]:(O=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{}),(0,$.jsx)(i,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[33]=u,t[34]=O);let k;return t[35]!==m||t[36]!==C||t[37]!==O||t[38]!==g||t[39]!==v||t[40]!==y||t[41]!==b||t[42]!==S?(k=(0,$.jsxs)(m,{align:g,side:v,onKeyDown:y,children:[b,S,C,O]}),t[35]=m,t[36]=C,t[37]=O,t[38]=g,t[39]=v,t[40]=y,t[41]=b,t[42]=S,t[43]=k):k=t[43],k}function So(e){let t=(0,Q.c)(35),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,q.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,u=`Browse ${e.crumb.label}`,d;t[7]===u?d=t[8]:(d=(0,$.jsx)(O,{render:(0,$.jsx)(`button`,{type:`button`,"aria-label":u,className:`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left text-muted-foreground outline-none pointer-coarse:after:-inset-y-3 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`})}),t[7]=u,t[8]=d);let f;t[9]===e.crumb.label?f=t[10]:(f=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[9]=e.crumb.label,t[10]=f);let p;t[11]!==d||t[12]!==f?(p=(0,$.jsx)(vt,{render:d,children:f}),t[11]=d,t[12]=f,t[13]=p):p=t[13];let h=e.crumb.path||e.projectName,g;t[14]===h?g=t[15]:(g=(0,$.jsx)(yt,{side:`top`,children:h}),t[14]=h,t[15]=g);let _;t[16]!==p||t[17]!==g?(_=(0,$.jsxs)(bt,{children:[p,g]}),t[16]=p,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==i||t[20]!==l||t[21]!==n||t[22]!==e.crumb.path||t[23]!==e.cwd||t[24]!==e.environmentId||t[25]!==e.onOpenFile||t[26]!==e.projectName||t[27]!==e.relativePath||t[28]!==e.workspaceMutationId?(v=n?(0,$.jsx)(xo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[19]=i,t[20]=l,t[21]=n,t[22]=e.crumb.path,t[23]=e.cwd,t[24]=e.environmentId,t[25]=e.onOpenFile,t[26]=e.projectName,t[27]=e.relativePath,t[28]=e.workspaceMutationId,t[29]=v):v=t[29];let y;return t[30]!==l||t[31]!==n||t[32]!==v||t[33]!==_?(y=(0,$.jsxs)(m,{open:n,onOpenChange:l,children:[_,v]}),t[30]=l,t[31]=n,t[32]=v,t[33]=_,t[34]=y):y=t[34],y}function Co(e){let t=(0,Q.c)(12),n;t[0]===e.relativePath?n=t[1]:(n=M(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.relativePath?(i=go(e.projectName,e.relativePath),t[2]=e.projectName,t[3]=e.relativePath,t[4]=i):i=t[4];let a=i,o;if(t[5]!==a||t[6]!==r||t[7]!==e){let n;t[9]!==r||t[10]!==e?(n=(t,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":t.kind===`file`,children:[n>0?(0,$.jsx)(c,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,t.kind===`file`?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(bo,{current:!0,label:t.label,pathLabel:t.path})}):r?(0,$.jsx)(bo,{label:t.label,pathLabel:t.path}):(0,$.jsx)(So,{...e,crumb:t})]},t.path||`project`),t[9]=r,t[10]=e,t[11]=n):n=t[11],o=a.map(n),t[5]=a,t[6]=r,t[7]=e,t[8]=o}else o=t[8];return o}function wo(e){let t=(0,Q.c)(14),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?De(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;return t[8]!==o||t[9]!==e.cwd||t[10]!==e.onTaskListChange||t[11]!==e.text||t[12]!==e.threadRef?(s=(0,$.jsx)(me,{text:e.text,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[8]=o,t[9]=e.cwd,t[10]=e.onTaskListChange,t[11]=e.text,t[12]=e.threadRef,t[13]=s):s=t[13],s}function To({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Eo(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function Do({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||To({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Eo(e)&&(i.preventDefault(),i.stopImmediatePropagation(),To({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function Oo(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function ko(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Ao(e,t,n){return`${e}:${t}:${ko(n)}`}function jo(e,t){return e===null||e===`.`||A(e,t)===`.`?null:e}var Mo=e=>/\.(?:md|mdx)$/i.test(e);function No(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function Po(e){return e.attachmentOpen||e.relativePath&&M(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Fo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function Io(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Lo=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},Ro=500;function zo(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=we(n,f),s=Ee(ie.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Lo({debounceMs:Ro,canPersist:()=>Te(n,f),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>pn(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let p=d,m;t[8]===p?m=t[9]:(m=[p],t[8]=p,t[9]=m),(0,q.useEffect)(p.setup,m);let h,g;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==p?(h=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=fn(n,r,i);t&&p.change(t.contents)}),()=>{e=!0}},g=[o,r,n,i,p],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=p,t[15]=h,t[16]=g):(h=t[15],g=t[16]),(0,q.useEffect)(h,g),p}var Bo=`p4code.fileExplorerOpen`,Vo=`p4code.renderMarkdown`,Ho=`p4code.renderBrowserFile`,Uo=`p4code.renderTable`;function Wo(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),[a,o]=(0,q.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=_t(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(P,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(P,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(ge,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function Go(e){let t=(0,Q.c)(19),n=_t(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=Io({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=Zt(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(ge,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=`${e.environmentId}:${i._tag}:${e.threadRef.threadId}:${e.absolutePath}:${e.workspaceMutationId}`,u=e.title,d;t[12]===e.absolutePath?d=t[13]:(d=Bt(e.absolutePath),t[12]=e.absolutePath,t[13]=d);let f;return t[14]!==e.title||t[15]!==c||t[16]!==l||t[17]!==d?(f=(0,$.jsx)(zt,{src:c,documentKey:l,title:u,pdf:d}),t[14]=e.title,t[15]=c,t[16]=l,t[17]=d,t[18]=f):f=t[18],f}function Ko(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),a=Qt(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(qo)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],vn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=_t(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(N,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function qo(){}function Jo(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Io({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=Zt(e.environmentId,r),a=Qt(e.environmentId,r),[o,s]=(0,q.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(Xo)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],vn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(Kt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(Yo)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ht,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(Lt,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function Yo(){}function Xo(){}function Zo(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function Qo(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Wt}]`))e.removeAttribute(Wt);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Wt,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Wt,``))}var $o=30,es=20,ts=2;function ns(e,t,n){let r=(0,Q.c)(5),[i]=(0,q.useState)(rs),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(Qo(r,t===null||u===void 0?null:Zo(u,t)),!(a instanceof Xe))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return Oo({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=es,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>ts&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:Zo(i,t),s=o===null?null:f(o);if(o===null||s===null){e<$o&&m(e+1);return}Qo(r,o),d.scrollTop=s,c.handledRequestId=n,p(o)})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function rs(){return new Map}var is=(e,t,n)=>new to(e,t,n);function as(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Ao(t,n,r)}`}}function os(e,t){if(e?.isWorkingPool()!==!0||(t.lang??gn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
|
|
32
32
|
`);e!==-1;e=t.contents.indexOf(`
|
|
33
|
-
`,e+1))n+=1;return n<=Me}function ss(e){let t=(0,Q.c)(15),n=Ie(),[r,i]=(0,q.useState)(null),a;t[0]!==e||t[1]!==n?(a=os(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,q.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function cs(e){let t=(0,Q.c)(68),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:o,contents:s,resolvedTheme:c,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=a(hs),m=a(ms),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,q.useState)(h),[v,y]=(0,q.useState)(null),x=v?.revealRequestId===l?v.range:null,S;t[1]===l?S=t[2]:(S=e=>{y({revealRequestId:l,range:e})},t[1]=l,t[2]=S);let C=S,w=(0,q.useRef)(null),T=(0,q.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(E={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=E):E=t[7];let ee=zo(E),D;t[8]!==s||t[9]!==r||t[10]!==n||t[11]!==i?(D=()=>as(n,r,i,s),t[8]=s,t[9]=r,t[10]=n,t[11]=i,t[12]=D):D=t[12];let[O,k]=(0,q.useState)(D),[te,ne]=(0,q.useState)(null);s!==(te??O.contents)&&(k(as(n,r,i,s)),ne(null));let{ready:re,onPostRender:ie}=ss(O),A=(0,q.useRef)(null),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j={onAttach:e=>{A.current=e},onComplete:()=>{A.current=null}},t[13]=j):j=t[13];let ae=j,oe;t[14]!==p||t[15]!==o||t[16]!==r||t[17]!==n||t[18]!==i||t[19]!==ee?(oe=e=>{let{file:t,lineAnnotations:a}=e;if(t.contents===ln(n,r,i)||(ne(t.contents),un(n,r,i,t.contents),ee.change(t.contents),!a))return;let s=xt(a);_(e=>e===a?e:s);for(let e of s)for(let n of e.metadata.entries)n.kind===`comment`&&p(o,b({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:t.contents}))},t[14]=p,t[15]=o,t[16]=r,t[17]=n,t[18]=i,t[19]=ee,t[20]=oe):oe=t[20];let se=oe,M;t[21]!==o||t[22]!==m||t[23]!==C?(M=e=>{C(null),m(o,e),_(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=o,t[22]=m,t[23]=C,t[24]=M):M=t[24];let ce=M,le;t[25]!==p||t[26]!==o||t[27]!==s||t[28]!==g||t[29]!==i||t[30]!==C?(le=(e,t)=>{C(null);let n=g.flatMap(ps).find(t=>t.id===e);n&&p(o,b({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:s})),_(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=p,t[26]=o,t[27]=s,t[28]=g,t[29]=i,t[30]=C,t[31]=le):le=t[31];let ue=le,de;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{A.current?.setSelections([]),A.current?.blur();let{startLine:t,endLine:n}=Ct(e),r={id:St(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(ds),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=de):de=t[32];let fe=de,pe;t[33]===g?pe=t[34]:(pe=g.some(ls),t[33]=g,t[34]=pe);let N=pe,P,me;t[35]!==N||t[36]!==C?(P=()=>{let e=w.current;if(e)return Do({root:e,editor:{setSelections:e=>A.current?.setSelections(e)},isBlocked:()=>N,onDismiss:()=>C(null)})},me=[N,C],t[35]=N,t[36]=C,t[37]=P,t[38]=me):(P=t[37],me=t[38]),(0,q.useEffect)(P,me);let he;t[39]===C?he=t[40]:(he=e=>{C(e),e&&fe(e)},t[39]=C,t[40]=he);let F=he,ge;t[41]!==ie||t[42]!==d||t[43]!==x?(ge=(e,t,n)=>{d(e,t,n),ie(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[41]=ie,t[42]=d,t[43]=x,t[44]=ge):ge=t[44];let _e=ge,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ve):ve=t[45];let I=!N,ye=!N,be=u?`wrap`:`scroll`,xe;t[46]===c?xe=t[47]:(xe=je(c),t[46]=c,t[47]=xe);let Se;t[48]!==F||t[49]!==_e||t[50]!==c||t[51]!==C||t[52]!==I||t[53]!==ye||t[54]!==be||t[55]!==xe?(Se={disableFileHeader:!0,enableGutterUtility:I,enableLineSelection:ye,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:F,overflow:be,theme:xe,preferredHighlighter:_n,themeType:c,unsafeCSS:qt,onPostRender:_e},t[48]=F,t[49]=_e,t[50]=c,t[51]=C,t[52]=I,t[53]=ye,t[54]=be,t[55]=xe,t[56]=Se):Se=t[56];let Ce;t[57]!==ce||t[58]!==ue?(Ce=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(pt,{kind:e.kind,rangeLabel:wt(e.startLine,e.endLine),text:e.text,onCancel:()=>ce(e.id),onComment:t=>ue(e.id,t),onDelete:()=>ce(e.id)},e.id))}),t[57]=ce,t[58]=ue,t[59]=Ce):Ce=t[59];let we;return t[60]!==re||t[61]!==O||t[62]!==se||t[63]!==g||t[64]!==x||t[65]!==Se||t[66]!==Ce?(we=(0,$.jsx)(Le,{createEditor:is,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(Re,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ve,children:(0,$.jsx)(Tt,{file:O,edit:re,editorOptions:ae,onEditChange:se,options:Se,selectedLines:x,lineAnnotations:g,renderAnnotation:Ce,className:`min-h-full`})})})}),t[60]=re,t[61]=O,t[62]=se,t[63]=g,t[64]=x,t[65]=Se,t[66]=Ce,t[67]=we):we=t[67],we}function ls(e){return e.metadata.entries.some(us)}function us(e){return e.kind===`draft`}function ds(e){let t=e.metadata.entries.filter(fs);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function fs(e){return e.kind!==`draft`}function ps(e){return e.metadata.entries}function ms(e){return e.removeReviewComment}function hs(e){return e.addReviewComment}function gs(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=zo(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=dn(n,r,i)?.contents??a,c=Fo(s,t,o);c!==s&&(un(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(It,{className:`min-h-0 flex-1`,children:(0,$.jsx)(wo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function _s(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function vs(){try{return S(Bo,d)??!0}catch(e){return console.error(e),!0}}function ys(e){let t=(0,Q.c)(156),{environmentId:n,cwd:r,projectName:i,relativePath:a,attachment:c,threadRef:u,composerDraftTarget:m,keybindings:h,availableEditors:g,revealLine:_,revealRequestId:v,onOpenFile:b,onPendingChange:x,selectedFilePending:S,workspaceMutationId:C}=e,w;t[0]!==c||t[1]!==r||t[2]!==a?(w=c===void 0?jo(a,r):a,t[0]=c,t[1]=r,t[2]=a,t[3]=w):w=t[3];let T=w,E=typeof m==`string`,{resolvedTheme:D}=ye(),O=xe(xs),k=Ce(n,p),ie=be(),A=he(n),j=ve(n),ue=$t(n),de;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(de={reportFailure:!1},t[4]=de):de=t[4];let N=Xt(Yt.createUrl,de),P;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(P={reportFailure:!1},t[5]=P):P=t[5];let me=Te(nn.open,P),_e;t[6]===T?_e=t[7]:(_e=T!==null&&oe(T),t[6]=T,t[7]=_e);let I=_e,we;t[8]!==I||t[9]!==T?(we=T!==null&&!I&&se(T),t[8]=I,t[9]=T,t[10]=we):we=t[10];let De=we,ke;t[11]!==I||t[12]!==T?(ke=T!==null&&!I&&ae(T),t[11]=I,t[12]=T,t[13]=ke):ke=t[13];let L=ke,Ae=L||I||De,je;t[14]===T?je=t[15]:(je=T!==null&&Bt(T),t[14]=T,t[15]=je);let R=je,Me;t[16]!==R||t[17]!==T?(Me=T!==null&&!R&&tn(T),t[16]=R,t[17]=T,t[18]=Me):Me=t[18];let Ne=Me,Pe;t[19]!==c||t[20]!==T?(Pe=c!==void 0||T!==null&&M(T),t[19]=c,t[20]=T,t[21]=Pe):Pe=t[21];let z=Pe,B=re(n),{canReadFiles:Fe}=B,Ie=Ce(n,f),V=cn(n,r,T,c===void 0&&T!==null),Le=V.readError?.resolvedPath??V.readError?.operationPath,Re=V.isNotFile&&!z,H=Re?null:T,[ze,Be]=(0,q.useState)(vs),Ve=c!==void 0,He;t[22]!==ze||t[23]!==H||t[24]!==Ve?(He=Po({relativePath:H,explorerOpen:ze,attachmentOpen:Ve}),t[22]=ze,t[23]=H,t[24]=Ve,t[25]=He):He=t[25];let Ue=He,[We,Ge]=l(Vo,!1,d),[Ke,qe]=l(Ho,!0,d),[Je,Ye]=l(Uo,!0,d),[Xe,Ze]=(0,q.useState)(null),Qe=(0,q.useRef)(null),et;t[26]===H?et=t[27]:(et=H?Mo(H):!1,t[26]=H,t[27]=et);let tt=et,nt;t[28]!==c||t[29]!==H?(nt=H&&c===void 0?Gt({name:H}):null,t[28]=c,t[29]=H,t[30]=nt):nt=t[30];let rt=nt,it=_===null||Xe?.path===T&&Xe.requestId===v,at=tt&&We&&it,ot=R||Ne&&Ke&&it,st=rt!==null&&Je&&it,U=tt?`markdown`:rt?`table`:Ne?`html`:null,ct=H!==null&&c===void 0&&U!==null,lt=Se(),W=H!==null&&V.data!==null&&!(tt&&at)&&!(rt&&st)&&!ot,ut=tt?at:rt?st:ot,dt=tt?Ge:rt?Ye:qe,ft;t[31]!==c||t[32]!==k||t[33]!==I||t[34]!==ue||t[35]!==H?(ft=k&&H!==null&&c===void 0&&!I&&ue&&tn(H),t[31]=c,t[32]=k,t[33]=I,t[34]=ue,t[35]=H,t[36]=ft):ft=t[36];let G=ft,pt;t[37]!==c||t[38]!==r||t[39]!==T?(pt=T&&c===void 0?Ee(T,r):null,t[37]=c,t[38]=r,t[39]=T,t[40]=pt):pt=t[40];let K=pt,mt=ns(T,_,v),ht=c===void 0&&T!==null&&(Re||!Ae&&!R)&&!S,gt=`file:${n}:${r}:${T??``}`,_t;t[41]!==V.refresh||t[42]!==ht||t[43]!==gt||t[44]!==C?(_t={enabled:ht,mutationId:C,refresh:V.refresh,resourceKey:gt},t[41]=V.refresh,t[42]=ht,t[43]=gt,t[44]=C,t[45]=_t):_t=t[45],vn(_t);let vt;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>{(Qe.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[46]=vt):vt=t[46];let yt;t[47]===T?yt=t[48]:(yt=[T],t[47]=T,t[48]=yt),(0,q.useEffect)(vt,yt);let bt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(bt=()=>{Be(bs)},t[49]=bt):bt=t[49];let xt=bt,St;t[50]!==K||t[51]!==k||t[52]!==Fe||t[53]!==N||t[54]!==r||t[55]!==j||t[56]!==me||t[57]!==u?(St=()=>{Fe&&k&&K&&j&&(async()=>{let e=await en({threadRef:u,filePath:K,workspaceRoot:r,httpBaseUrl:j,createAssetUrl:N,openPreview:me});if(e._tag===`Success`||te(e))return;let t=ne(e);ge.add(Oe({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[50]=K,t[51]=k,t[52]=Fe,t[53]=N,t[54]=r,t[55]=j,t[56]=me,t[57]=u,t[58]=St):St=t[58];let Ct=St;if(c===void 0&&!Fe){if(B.isPending){let e;return t[59]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(F,{className:`size-4`}),`Checking file access...`]}),t[59]=e):e=t[59],e}let e=B.error??`This connection cannot read host files.`,n;return t[60]===e?n=t[61]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[60]=e,t[61]=n),n}let wt;t[62]!==K||t[63]!==c||t[64]!==g||t[65]!==G||t[66]!==ct||t[67]!==r||t[68]!==n||t[69]!==ze||t[70]!==Ct||t[71]!==z||t[72]!==h||t[73]!==b||t[74]!==H||t[75]!==ie||t[76]!==i||t[77]!==T||t[78]!==A||t[79]!==ut||t[80]!==U||t[81]!==v||t[82]!==dt||t[83]!==W||t[84]!==lt||t[85]!==O||t[86]!==C?(wt=T&&c===void 0?(0,$.jsxs)(`div`,{className:Vt,"data-surface-subheader":!0,children:[(0,$.jsx)(It,{radius:`none`,ref:Qe,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(Co,{cwd:r,environmentId:n,onOpenFile:b,projectName:i,relativePath:T,workspaceMutationId:C})})}),K&&(n===ie||A.mode!==`local-exec`)?(0,$.jsx)(yn,{environmentId:n,keybindings:h,availableEditors:g,openInCwd:K,compact:!0}):null,ct&&U?(0,$.jsx)(Rt,{label:_s(U,ut),pressed:ut,onPress:()=>{let e=!ut;dt(e),Ze(e&&T!==null?{path:T,requestId:v}:null)},children:(0,$.jsx)(fe,{className:`size-3.5`,icon:ut?le:U===`table`?ce:pe})}):null,W?(0,$.jsx)(Rt,{label:O?`Disable word wrap`:`Enable word wrap`,pressed:O,onPress:()=>lt({wordWrap:!O}),children:(0,$.jsx)(y,{className:`size-3.5`})}):null,G?(0,$.jsx)(Rt,{label:`Open file in preview browser`,onPress:Ct,children:(0,$.jsx)(s,{className:`size-3.5`})}):null,!z&&H!==null?(0,$.jsx)(Rt,{label:ze?`Hide file explorer`:`Show file explorer`,pressed:ze,onPress:xt,children:(0,$.jsx)(o,{className:`size-3.5`})}):null]}):null,t[62]=K,t[63]=c,t[64]=g,t[65]=G,t[66]=ct,t[67]=r,t[68]=n,t[69]=ze,t[70]=Ct,t[71]=z,t[72]=h,t[73]=b,t[74]=H,t[75]=ie,t[76]=i,t[77]=T,t[78]=A,t[79]=ut,t[80]=U,t[81]=v,t[82]=dt,t[83]=W,t[84]=lt,t[85]=O,t[86]=C,t[87]=wt):wt=t[87];let Tt;t[88]!==c||t[89]!==Ie||t[90]!==B.isPending||t[91]!==z||t[92]!==T?(Tt=T&&!c&&!z&&!Ie&&!B.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[88]=c,t[89]=Ie,t[90]=B.isPending,t[91]=z,t[92]=T,t[93]=Tt):Tt=t[93];let Dt;t[94]!==c||t[95]!==V.data||t[96]!==Ae||t[97]!==H||t[98]!==ot?(Dt=H&&c===void 0&&!Ae&&!ot&&V.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,V.data.byteLength.toLocaleString(),` byte file.`]}):null,t[94]=c,t[95]=V.data,t[96]=Ae,t[97]=H,t[98]=ot,t[99]=Dt):Dt=t[99];let Ot=H?`flex`:`hidden`,kt;t[100]===Ot?kt=t[101]:(kt=ee(`min-w-0 flex-1 flex-col overflow-hidden`,Ot),t[100]=Ot,t[101]=kt);let At;t[102]!==K||t[103]!==c||t[104]!==Le||t[105]!==Ie||t[106]!==m||t[107]!==r||t[108]!==E||t[109]!==n||t[110]!==V.data||t[111]!==V.error||t[112]!==V.readError||t[113]!==De||t[114]!==Re||t[115]!==z||t[116]!==L||t[117]!==tt||t[118]!==I||t[119]!==mt||t[120]!==x||t[121]!==T||t[122]!==ot||t[123]!==at||t[124]!==st||t[125]!==D||t[126]!==v||t[127]!==rt||t[128]!==u||t[129]!==O||t[130]!==C?(At=Re?null:T&&c?(0,$.jsx)(Ut,{name:c.name,mimeType:c.mimeType,sizeBytes:c.sizeBytes,asset:{environmentId:n,attachmentId:c.id},htmlRender:c.htmlRender===!0,threadRef:u},`${n}:${c.id}`):T&&I&&K?(0,$.jsx)(Ko,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,name:T,workspaceMutationId:C},`${n}:${u.threadId}:${K}`):T&&De&&K?(0,$.jsx)(Jo,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,name:T,workspaceMutationId:C},`${n}:${u.threadId}:${K}`):T&&L&&K?(0,$.jsx)(Wo,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,alt:T,workspaceMutationId:C},K):T&&ot&&K?(0,$.jsx)(Go,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,title:T,workspaceMutationId:C},K):T&&V.error&&V.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:V.readError?No(V.readError):V.error}),Le?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:Le})]}):null,z?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:V.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):T&&V.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(F,{size:`lg`})}):T&&V.data?tt&&at?(0,$.jsx)(gs,{environmentId:n,cwd:r,relativePath:T,threadRef:u,contents:V.data.contents,readOnly:z||!Ie,onPendingChange:x},T):rt&&st?(0,$.jsx)(Jt,{name:T,text:V.data.contents,delimiter:rt},T):V.data.truncated||z||!Ie?(0,$.jsx)(Et,{name:T,text:V.data.contents,cacheKey:Ao(r,T,V.data.contents),onPostRender:mt}):(0,$.jsx)($e,{children:(0,$.jsx)(cs,{environmentId:n,cwd:r,relativePath:T,composerDraftTarget:m,contents:V.data.contents,resolvedTheme:D,revealRequestId:v,wordWrap:O,onPostRender:mt,onPendingChange:x},`${T}:${D}`)}):null,t[102]=K,t[103]=c,t[104]=Le,t[105]=Ie,t[106]=m,t[107]=r,t[108]=E,t[109]=n,t[110]=V.data,t[111]=V.error,t[112]=V.readError,t[113]=De,t[114]=Re,t[115]=z,t[116]=L,t[117]=tt,t[118]=I,t[119]=mt,t[120]=x,t[121]=T,t[122]=ot,t[123]=at,t[124]=st,t[125]=D,t[126]=v,t[127]=rt,t[128]=u,t[129]=O,t[130]=C,t[131]=At):At=t[131];let jt;t[132]!==kt||t[133]!==At?(jt=(0,$.jsx)(`div`,{className:kt,children:At}),t[132]=kt,t[133]=At,t[134]=jt):jt=t[134];let Mt;t[135]!==r||t[136]!==n||t[137]!==V.refresh||t[138]!==Ae||t[139]!==R||t[140]!==b||t[141]!==H||t[142]!==i||t[143]!==T||t[144]!==v||t[145]!==Ue||t[146]!==C?(Mt=Ue?(0,$.jsx)(`aside`,{className:ee(`flex min-h-0 shrink-0 bg-background`,H?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,$.jsx)(ho,{environmentId:n,cwd:r,projectName:i,selectedPath:T,selectedPathRevealId:v,onOpenFile:b,workspaceMutationId:C,...H&&!Ae&&!R?{onRefreshSelectedFile:V.refresh}:{}},`${n}:${r}`)}):null,t[135]=r,t[136]=n,t[137]=V.refresh,t[138]=Ae,t[139]=R,t[140]=b,t[141]=H,t[142]=i,t[143]=T,t[144]=v,t[145]=Ue,t[146]=C,t[147]=Mt):Mt=t[147];let Nt;t[148]!==jt||t[149]!==Mt?(Nt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[jt,Mt]}),t[148]=jt,t[149]=Mt,t[150]=Nt):Nt=t[150];let Pt;return t[151]!==wt||t[152]!==Tt||t[153]!==Dt||t[154]!==Nt?(Pt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[wt,Tt,Dt,Nt]}),t[151]=wt,t[152]=Tt,t[153]=Dt,t[154]=Nt,t[155]=Pt):Pt=t[155],Pt}function bs(e){let t=!e;try{x(Bo,t,d)}catch(e){console.error(e)}return t}function xs(e){return e.wordWrap}export{ys as default};
|
|
34
|
-
//# sourceMappingURL=FilePreviewPanel-
|
|
33
|
+
`,e+1))n+=1;return n<=Ne}function ss(e){let t=(0,Q.c)(15),n=Le(),[r,i]=(0,q.useState)(null),a;t[0]!==e||t[1]!==n?(a=os(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,q.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function cs(e){let t=(0,Q.c)(68),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:o,contents:s,resolvedTheme:c,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=a(hs),m=a(ms),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,q.useState)(h),[v,y]=(0,q.useState)(null),x=v?.revealRequestId===l?v.range:null,S;t[1]===l?S=t[2]:(S=e=>{y({revealRequestId:l,range:e})},t[1]=l,t[2]=S);let C=S,w=(0,q.useRef)(null),T=(0,q.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(E={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=E):E=t[7];let ee=zo(E),D;t[8]!==s||t[9]!==r||t[10]!==n||t[11]!==i?(D=()=>as(n,r,i,s),t[8]=s,t[9]=r,t[10]=n,t[11]=i,t[12]=D):D=t[12];let[O,k]=(0,q.useState)(D),[te,ne]=(0,q.useState)(null);s!==(te??O.contents)&&(k(as(n,r,i,s)),ne(null));let{ready:re,onPostRender:ie}=ss(O),A=(0,q.useRef)(null),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j={onAttach:e=>{A.current=e},onComplete:()=>{A.current=null}},t[13]=j):j=t[13];let ae=j,oe;t[14]!==p||t[15]!==o||t[16]!==r||t[17]!==n||t[18]!==i||t[19]!==ee?(oe=e=>{let{file:t,lineAnnotations:a}=e;if(t.contents===ln(n,r,i)||(ne(t.contents),un(n,r,i,t.contents),ee.change(t.contents),!a))return;let s=xt(a);_(e=>e===a?e:s);for(let e of s)for(let n of e.metadata.entries)n.kind===`comment`&&p(o,b({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:t.contents}))},t[14]=p,t[15]=o,t[16]=r,t[17]=n,t[18]=i,t[19]=ee,t[20]=oe):oe=t[20];let se=oe,M;t[21]!==o||t[22]!==m||t[23]!==C?(M=e=>{C(null),m(o,e),_(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=o,t[22]=m,t[23]=C,t[24]=M):M=t[24];let ce=M,le;t[25]!==p||t[26]!==o||t[27]!==s||t[28]!==g||t[29]!==i||t[30]!==C?(le=(e,t)=>{C(null);let n=g.flatMap(ps).find(t=>t.id===e);n&&p(o,b({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:s})),_(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=p,t[26]=o,t[27]=s,t[28]=g,t[29]=i,t[30]=C,t[31]=le):le=t[31];let ue=le,de;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{A.current?.setSelections([]),A.current?.blur();let{startLine:t,endLine:n}=Ct(e),r={id:St(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(ds),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=de):de=t[32];let fe=de,pe;t[33]===g?pe=t[34]:(pe=g.some(ls),t[33]=g,t[34]=pe);let N=pe,P,me;t[35]!==N||t[36]!==C?(P=()=>{let e=w.current;if(e)return Do({root:e,editor:{setSelections:e=>A.current?.setSelections(e)},isBlocked:()=>N,onDismiss:()=>C(null)})},me=[N,C],t[35]=N,t[36]=C,t[37]=P,t[38]=me):(P=t[37],me=t[38]),(0,q.useEffect)(P,me);let he;t[39]===C?he=t[40]:(he=e=>{C(e),e&&fe(e)},t[39]=C,t[40]=he);let ge=he,_e;t[41]!==ie||t[42]!==d||t[43]!==x?(_e=(e,t,n)=>{d(e,t,n),ie(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[41]=ie,t[42]=d,t[43]=x,t[44]=_e):_e=t[44];let ve=_e,ye;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ye={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ye):ye=t[45];let be=!N,xe=!N,Se=u?`wrap`:`scroll`,F;t[46]===c?F=t[47]:(F=Me(c),t[46]=c,t[47]=F);let Ce;t[48]!==ge||t[49]!==ve||t[50]!==c||t[51]!==C||t[52]!==be||t[53]!==xe||t[54]!==Se||t[55]!==F?(Ce={disableFileHeader:!0,enableGutterUtility:be,enableLineSelection:xe,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:ge,overflow:Se,theme:F,preferredHighlighter:hn,themeType:c,unsafeCSS:qt,onPostRender:ve},t[48]=ge,t[49]=ve,t[50]=c,t[51]=C,t[52]=be,t[53]=xe,t[54]=Se,t[55]=F,t[56]=Ce):Ce=t[56];let we;t[57]!==ce||t[58]!==ue?(we=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(pt,{kind:e.kind,rangeLabel:wt(e.startLine,e.endLine),text:e.text,onCancel:()=>ce(e.id),onComment:t=>ue(e.id,t),onDelete:()=>ce(e.id)},e.id))}),t[57]=ce,t[58]=ue,t[59]=we):we=t[59];let Te;return t[60]!==re||t[61]!==O||t[62]!==se||t[63]!==g||t[64]!==x||t[65]!==Ce||t[66]!==we?(Te=(0,$.jsx)(Re,{createEditor:is,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(ze,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ye,children:(0,$.jsx)(Tt,{file:O,edit:re,editorOptions:ae,onEditChange:se,options:Ce,selectedLines:x,lineAnnotations:g,renderAnnotation:we,className:`min-h-full`})})})}),t[60]=re,t[61]=O,t[62]=se,t[63]=g,t[64]=x,t[65]=Ce,t[66]=we,t[67]=Te):Te=t[67],Te}function ls(e){return e.metadata.entries.some(us)}function us(e){return e.kind===`draft`}function ds(e){let t=e.metadata.entries.filter(fs);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function fs(e){return e.kind!==`draft`}function ps(e){return e.metadata.entries}function ms(e){return e.removeReviewComment}function hs(e){return e.addReviewComment}function gs(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=zo(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=dn(n,r,i)?.contents??a,c=Fo(s,t,o);c!==s&&(un(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(It,{className:`min-h-0 flex-1`,children:(0,$.jsx)(wo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function _s(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function vs(){try{return S(Bo,d)??!0}catch(e){return console.error(e),!0}}function ys(e){let t=(0,Q.c)(156),{environmentId:n,cwd:r,projectName:i,relativePath:a,attachment:c,threadRef:u,composerDraftTarget:m,keybindings:h,availableEditors:g,revealLine:_,revealRequestId:v,onOpenFile:b,onPendingChange:x,selectedFilePending:S,workspaceMutationId:C}=e,w;t[0]!==c||t[1]!==r||t[2]!==a?(w=c===void 0?jo(a,r):a,t[0]=c,t[1]=r,t[2]=a,t[3]=w):w=t[3];let T=w,E=typeof m==`string`,{resolvedTheme:D}=be(),O=Ce(xs),k=we(n,p),ie=ye(),A=he(n),j=xe(n),ue=$t(n),de;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(de={reportFailure:!1},t[4]=de):de=t[4];let N=Xt(Yt.createUrl,de),P;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(P={reportFailure:!1},t[5]=P):P=t[5];let me=Ee(nn.open,P),ve;t[6]===T?ve=t[7]:(ve=T!==null&&oe(T),t[6]=T,t[7]=ve);let F=ve,Te;t[8]!==F||t[9]!==T?(Te=T!==null&&!F&&se(T),t[8]=F,t[9]=T,t[10]=Te):Te=t[10];let Oe=Te,Ae;t[11]!==F||t[12]!==T?(Ae=T!==null&&!F&&ae(T),t[11]=F,t[12]=T,t[13]=Ae):Ae=t[13];let I=Ae,je=I||F||Oe,Me;t[14]===T?Me=t[15]:(Me=T!==null&&Bt(T),t[14]=T,t[15]=Me);let L=Me,Ne;t[16]!==L||t[17]!==T?(Ne=T!==null&&!L&&tn(T),t[16]=L,t[17]=T,t[18]=Ne):Ne=t[18];let Pe=Ne,Fe;t[19]!==c||t[20]!==T?(Fe=c!==void 0||T!==null&&M(T),t[19]=c,t[20]=T,t[21]=Fe):Fe=t[21];let R=Fe,z=re(n),{canReadFiles:Ie}=z,Le=we(n,f),B=cn(n,r,T,c===void 0&&T!==null),Re=B.readError?.resolvedPath??B.readError?.operationPath,ze=B.isNotFile&&!R,V=ze?null:T,[Be,Ve]=(0,q.useState)(vs),He=c!==void 0,Ue;t[22]!==Be||t[23]!==V||t[24]!==He?(Ue=Po({relativePath:V,explorerOpen:Be,attachmentOpen:He}),t[22]=Be,t[23]=V,t[24]=He,t[25]=Ue):Ue=t[25];let We=Ue,[Ge,Ke]=l(Vo,!1,d),[qe,Je]=l(Ho,!0,d),[Ye,Xe]=l(Uo,!0,d),[Ze,Qe]=(0,q.useState)(null),$e=(0,q.useRef)(null),tt;t[26]===V?tt=t[27]:(tt=V?Mo(V):!1,t[26]=V,t[27]=tt);let nt=tt,rt;t[28]!==c||t[29]!==V?(rt=V&&c===void 0?Gt({name:V}):null,t[28]=c,t[29]=V,t[30]=rt):rt=t[30];let H=rt,it=_===null||Ze?.path===T&&Ze.requestId===v,at=nt&&Ge&&it,ot=L||Pe&&qe&&it,st=H!==null&&Ye&&it,U=nt?`markdown`:H?`table`:Pe?`html`:null,ct=V!==null&&c===void 0&&U!==null,lt=Se(),W=V!==null&&B.data!==null&&!(nt&&at)&&!(H&&st)&&!ot,ut=nt?at:H?st:ot,dt=nt?Ke:H?Xe:Je,ft;t[31]!==c||t[32]!==k||t[33]!==F||t[34]!==ue||t[35]!==V?(ft=k&&V!==null&&c===void 0&&!F&&ue&&tn(V),t[31]=c,t[32]=k,t[33]=F,t[34]=ue,t[35]=V,t[36]=ft):ft=t[36];let G=ft,pt;t[37]!==c||t[38]!==r||t[39]!==T?(pt=T&&c===void 0?De(T,r):null,t[37]=c,t[38]=r,t[39]=T,t[40]=pt):pt=t[40];let K=pt,mt=ns(T,_,v),ht=c===void 0&&T!==null&&(ze||!je&&!L)&&!S,gt=`file:${n}:${r}:${T??``}`,_t;t[41]!==B.refresh||t[42]!==ht||t[43]!==gt||t[44]!==C?(_t={enabled:ht,mutationId:C,refresh:B.refresh,resourceKey:gt},t[41]=B.refresh,t[42]=ht,t[43]=gt,t[44]=C,t[45]=_t):_t=t[45],vn(_t);let vt;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>{($e.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[46]=vt):vt=t[46];let yt;t[47]===T?yt=t[48]:(yt=[T],t[47]=T,t[48]=yt),(0,q.useEffect)(vt,yt);let bt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(bt=()=>{Ve(bs)},t[49]=bt):bt=t[49];let xt=bt,St;t[50]!==K||t[51]!==k||t[52]!==Ie||t[53]!==N||t[54]!==r||t[55]!==j||t[56]!==me||t[57]!==u?(St=()=>{Ie&&k&&K&&j&&(async()=>{let e=await en({threadRef:u,filePath:K,workspaceRoot:r,httpBaseUrl:j,createAssetUrl:N,openPreview:me});if(e._tag===`Success`||te(e))return;let t=ne(e);_e.add(ke({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[50]=K,t[51]=k,t[52]=Ie,t[53]=N,t[54]=r,t[55]=j,t[56]=me,t[57]=u,t[58]=St):St=t[58];let Ct=St;if(c===void 0&&!Ie){if(z.isPending){let e;return t[59]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(ge,{className:`size-4`}),`Checking file access...`]}),t[59]=e):e=t[59],e}let e=z.error??`This connection cannot read host files.`,n;return t[60]===e?n=t[61]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[60]=e,t[61]=n),n}let wt;t[62]!==K||t[63]!==c||t[64]!==g||t[65]!==G||t[66]!==ct||t[67]!==r||t[68]!==n||t[69]!==Be||t[70]!==Ct||t[71]!==R||t[72]!==h||t[73]!==b||t[74]!==V||t[75]!==ie||t[76]!==i||t[77]!==T||t[78]!==A||t[79]!==ut||t[80]!==U||t[81]!==v||t[82]!==dt||t[83]!==W||t[84]!==lt||t[85]!==O||t[86]!==C?(wt=T&&c===void 0?(0,$.jsxs)(`div`,{className:Vt,"data-surface-subheader":!0,children:[(0,$.jsx)(It,{radius:`none`,ref:$e,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(Co,{cwd:r,environmentId:n,onOpenFile:b,projectName:i,relativePath:T,workspaceMutationId:C})})}),K&&(n===ie||A.mode!==`local-exec`)?(0,$.jsx)(yn,{environmentId:n,keybindings:h,availableEditors:g,openInCwd:K,compact:!0}):null,ct&&U?(0,$.jsx)(Rt,{label:_s(U,ut),pressed:ut,onPress:()=>{let e=!ut;dt(e),Qe(e&&T!==null?{path:T,requestId:v}:null)},children:(0,$.jsx)(fe,{className:`size-3.5`,icon:ut?le:U===`table`?ce:pe})}):null,W?(0,$.jsx)(Rt,{label:O?`Disable word wrap`:`Enable word wrap`,pressed:O,onPress:()=>lt({wordWrap:!O}),children:(0,$.jsx)(y,{className:`size-3.5`})}):null,G?(0,$.jsx)(Rt,{label:`Open file in preview browser`,onPress:Ct,children:(0,$.jsx)(s,{className:`size-3.5`})}):null,!R&&V!==null?(0,$.jsx)(Rt,{label:Be?`Hide file explorer`:`Show file explorer`,pressed:Be,onPress:xt,children:(0,$.jsx)(o,{className:`size-3.5`})}):null]}):null,t[62]=K,t[63]=c,t[64]=g,t[65]=G,t[66]=ct,t[67]=r,t[68]=n,t[69]=Be,t[70]=Ct,t[71]=R,t[72]=h,t[73]=b,t[74]=V,t[75]=ie,t[76]=i,t[77]=T,t[78]=A,t[79]=ut,t[80]=U,t[81]=v,t[82]=dt,t[83]=W,t[84]=lt,t[85]=O,t[86]=C,t[87]=wt):wt=t[87];let Tt;t[88]!==c||t[89]!==Le||t[90]!==z.isPending||t[91]!==R||t[92]!==T?(Tt=T&&!c&&!R&&!Le&&!z.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[88]=c,t[89]=Le,t[90]=z.isPending,t[91]=R,t[92]=T,t[93]=Tt):Tt=t[93];let Dt;t[94]!==c||t[95]!==B.data||t[96]!==je||t[97]!==V||t[98]!==ot?(Dt=V&&c===void 0&&!je&&!ot&&B.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,B.data.byteLength.toLocaleString(),` byte file.`]}):null,t[94]=c,t[95]=B.data,t[96]=je,t[97]=V,t[98]=ot,t[99]=Dt):Dt=t[99];let Ot=V?`flex`:`hidden`,kt;t[100]===Ot?kt=t[101]:(kt=ee(`min-w-0 flex-1 flex-col overflow-hidden`,Ot),t[100]=Ot,t[101]=kt);let At;t[102]!==K||t[103]!==c||t[104]!==Re||t[105]!==Le||t[106]!==m||t[107]!==r||t[108]!==E||t[109]!==n||t[110]!==B.data||t[111]!==B.error||t[112]!==B.readError||t[113]!==Oe||t[114]!==ze||t[115]!==R||t[116]!==I||t[117]!==nt||t[118]!==F||t[119]!==mt||t[120]!==x||t[121]!==T||t[122]!==ot||t[123]!==at||t[124]!==st||t[125]!==D||t[126]!==v||t[127]!==H||t[128]!==u||t[129]!==O||t[130]!==C?(At=ze?null:T&&c?(0,$.jsx)(Ut,{name:c.name,mimeType:c.mimeType,sizeBytes:c.sizeBytes,asset:{environmentId:n,attachmentId:c.id},htmlRender:c.htmlRender===!0,threadRef:u},`${n}:${c.id}`):T&&F&&K?(0,$.jsx)(Ko,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,name:T,workspaceMutationId:C},`${n}:${u.threadId}:${K}`):T&&Oe&&K?(0,$.jsx)(Jo,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,name:T,workspaceMutationId:C},`${n}:${u.threadId}:${K}`):T&&I&&K?(0,$.jsx)(Wo,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,alt:T,workspaceMutationId:C},K):T&&ot&&K?(0,$.jsx)(Go,{environmentId:n,threadRef:u,draft:E,absolutePath:K,workspaceRoot:r,title:T,workspaceMutationId:C},K):T&&B.error&&B.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:B.readError?No(B.readError):B.error}),Re?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:Re})]}):null,R?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:B.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):T&&B.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(ge,{size:`lg`})}):T&&B.data?nt&&at?(0,$.jsx)(gs,{environmentId:n,cwd:r,relativePath:T,threadRef:u,contents:B.data.contents,readOnly:R||!Le,onPendingChange:x},T):H&&st?(0,$.jsx)(Jt,{name:T,text:B.data.contents,delimiter:H},T):B.data.truncated||R||!Le?(0,$.jsx)(Et,{name:T,text:B.data.contents,cacheKey:Ao(r,T,B.data.contents),onPostRender:mt}):(0,$.jsx)(et,{children:(0,$.jsx)(cs,{environmentId:n,cwd:r,relativePath:T,composerDraftTarget:m,contents:B.data.contents,resolvedTheme:D,revealRequestId:v,wordWrap:O,onPostRender:mt,onPendingChange:x},`${T}:${D}`)}):null,t[102]=K,t[103]=c,t[104]=Re,t[105]=Le,t[106]=m,t[107]=r,t[108]=E,t[109]=n,t[110]=B.data,t[111]=B.error,t[112]=B.readError,t[113]=Oe,t[114]=ze,t[115]=R,t[116]=I,t[117]=nt,t[118]=F,t[119]=mt,t[120]=x,t[121]=T,t[122]=ot,t[123]=at,t[124]=st,t[125]=D,t[126]=v,t[127]=H,t[128]=u,t[129]=O,t[130]=C,t[131]=At):At=t[131];let jt;t[132]!==kt||t[133]!==At?(jt=(0,$.jsx)(`div`,{className:kt,children:At}),t[132]=kt,t[133]=At,t[134]=jt):jt=t[134];let Mt;t[135]!==r||t[136]!==n||t[137]!==B.refresh||t[138]!==je||t[139]!==L||t[140]!==b||t[141]!==V||t[142]!==i||t[143]!==T||t[144]!==v||t[145]!==We||t[146]!==C?(Mt=We?(0,$.jsx)(`aside`,{className:ee(`flex min-h-0 shrink-0 bg-background`,V?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,$.jsx)(ho,{environmentId:n,cwd:r,projectName:i,selectedPath:T,selectedPathRevealId:v,onOpenFile:b,workspaceMutationId:C,...V&&!je&&!L?{onRefreshSelectedFile:B.refresh}:{}},`${n}:${r}`)}):null,t[135]=r,t[136]=n,t[137]=B.refresh,t[138]=je,t[139]=L,t[140]=b,t[141]=V,t[142]=i,t[143]=T,t[144]=v,t[145]=We,t[146]=C,t[147]=Mt):Mt=t[147];let Nt;t[148]!==jt||t[149]!==Mt?(Nt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[jt,Mt]}),t[148]=jt,t[149]=Mt,t[150]=Nt):Nt=t[150];let Pt;return t[151]!==wt||t[152]!==Tt||t[153]!==Dt||t[154]!==Nt?(Pt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[wt,Tt,Dt,Nt]}),t[151]=wt,t[152]=Tt,t[153]=Dt,t[154]=Nt,t[155]=Pt):Pt=t[155],Pt}function bs(e){let t=!e;try{x(Bo,t,d)}catch(e){console.error(e)}return t}function xs(e){return e.wordWrap}export{ys as default};
|
|
34
|
+
//# sourceMappingURL=FilePreviewPanel-CTTCKfik.js.map
|