@p4code/cli 0.8.35 → 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-26z5sNBT.mjs → binCli-k72_SR2Z.mjs} +2556 -2301
- package/dist/client/.vite/manifest.json +2004 -2044
- package/dist/client/assets/{2NI2N5EU-BLnY4aCF.js → 2NI2N5EU-DPAxyySd.js} +2 -2
- package/dist/client/assets/{4UO7MD6I-BApNVkfU.js → 4UO7MD6I-C0aflwpw.js} +2 -2
- package/dist/client/assets/{5B3SVYGG-Y7V7NdZO.js → 5B3SVYGG-hhn6T1ru.js} +2 -2
- package/dist/client/assets/{5GK6JWQ2-BSIhKcw-.js → 5GK6JWQ2-BQ0OdoZ6.js} +2 -2
- package/dist/client/assets/{5N7A7DKN-CNUCnWLs.js → 5N7A7DKN-BR8rdHwZ.js} +2 -2
- package/dist/client/assets/{5OC2THR4-Bne-pf_A.js → 5OC2THR4-DVDBlcjJ.js} +2 -2
- package/dist/client/assets/{5S6HY5KT-7d4UMONz.js → 5S6HY5KT-CjtOXys8.js} +2 -2
- package/dist/client/assets/{6IMQ5BUJ-BWW19n-D.js → 6IMQ5BUJ-Bpy1Geo9.js} +2 -2
- package/dist/client/assets/{6OLKWJ4F-CxTUuvA6.js → 6OLKWJ4F-D2naWV4i.js} +2 -2
- package/dist/client/assets/{74OO7NKP-DByVTRKE.js → 74OO7NKP-CceNos-7.js} +2 -2
- package/dist/client/assets/{75O6YZUN-CZanyedf.js → 75O6YZUN-CnXm_L8w.js} +2 -2
- package/dist/client/assets/{77XECAW3-TL2w7pHK.js → 77XECAW3-ECBcD47O.js} +2 -2
- package/dist/client/assets/{ABYRPUBD-CJboH7Uz.js → ABYRPUBD-B4F4wZam.js} +2 -2
- package/dist/client/assets/AlertDialogRoot-D5eL1YFA.js +2 -0
- package/dist/client/assets/{AnimatedHeight-OxEbW01v.js → AnimatedHeight-BZhIfVtA.js} +2 -2
- package/dist/client/assets/AuthSurfaceShell-DR9yRrzS.js +2 -0
- package/dist/client/assets/{BB2UYUI2-BxW-R2h1.js → BB2UYUI2-Cae7rC8c.js} +2 -2
- package/dist/client/assets/{BUM34MOA-ngG-irUy.js → BUM34MOA-DBDboDOb.js} +2 -2
- package/dist/client/assets/{CEQABKGZ-C-u-W0bS.js → CEQABKGZ-C6UutqUy.js} +2 -2
- package/dist/client/assets/{CXAC5362-DfFRkI7L.js → CXAC5362-BnZlf1Fg.js} +2 -2
- package/dist/client/assets/{ChatGptUsageButton-C3KgGt4z.js → ChatGptUsageButton-3K5PpaVk.js} +2 -2
- package/dist/client/assets/{ChatMarkdown-9gWM0ED9.js → ChatMarkdown-EK5C8Dje.js} +7 -7
- package/dist/client/assets/{CheckboxIndicator-DbU3csPQ.js → CheckboxIndicator-DZ8vBLEv.js} +2 -2
- package/dist/client/assets/{ClippedText-CS_BYNco.js → ClippedText-Dswe5Mb4.js} +2 -2
- package/dist/client/assets/CodexSetupSection.logic-BepCZ25p.js +2 -0
- package/dist/client/assets/{ComboboxClear-Bn_kslrf.js → ComboboxClear-By718biy.js} +2 -2
- package/dist/client/assets/{ComboboxGroupLabel-fL8lMA25.js → ComboboxGroupLabel-DjWIIS5_.js} +2 -2
- package/dist/client/assets/{CommandBlock-DcQXu_lq.js → CommandBlock-C967hvdK.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-DQ9wFfKn.js → ComposerPromptEditor-kPs79YCA.js} +10 -10
- package/dist/client/assets/{CompositeRoot-BuwzXGHT.js → CompositeRoot-BFPe8O0M.js} +2 -2
- package/dist/client/assets/{ConnectionDiagnosisDetails-DGbJY7Hw.js → ConnectionDiagnosisDetails-B5VXf5lv.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-CixsTBXI.js → ConnectionStatusDot-wmgCjAfF.js} +2 -2
- package/dist/client/assets/{DRLTVNUE-Cbb71R0Y.js → DRLTVNUE-Du8kYl_L.js} +2 -2
- package/dist/client/assets/{DYY6UVD2-BZn5fuF5.js → DYY6UVD2-DxjEuWNy.js} +2 -2
- package/dist/client/assets/{DevicePanel-JP__PY1s.js → DevicePanel-YEBH-Vqd.js} +2 -2
- package/dist/client/assets/DeviceSetup-CAlj40rJ.js +2 -0
- package/dist/client/assets/{DialogTitle-B_9LEmy3.js → DialogTitle-DNp9zThp.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-WMKzOwCh.js → DiffCommentAnnotation-BOk2MTlv.js} +2 -2
- package/dist/client/assets/{DiffFileTree-BSbsOOmA.js → DiffFileTree-Dg3cvfi5.js} +2 -2
- package/dist/client/assets/{DiffPanel-BWFuiHvv.js → DiffPanel-fTHMPAQJ.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-BBk0lIX3.js → DiffWorkerPoolProvider-CqmToECA.js} +3 -3
- package/dist/client/assets/{EmbeddedDesign-D5YUndkh.js → EmbeddedDesign-BXKBSCcw.js} +2 -2
- package/dist/client/assets/{EnvironmentMachineIcon-Dpgx67FY.js → EnvironmentMachineIcon-DBWK6C8T.js} +2 -2
- package/dist/client/assets/{ExpandableText-Cpm1gOKG.js → ExpandableText-B9cfY7p2.js} +2 -2
- package/dist/client/assets/{FNOVOB4O-BkEIrB0k.js → FNOVOB4O-BeMBYVRF.js} +2 -2
- package/dist/client/assets/{FieldControl-BHe6unoZ.js → FieldControl-BOrs67_f.js} +2 -2
- package/dist/client/assets/{FileDiff-C1vAOUga.js → FileDiff-DW1zPAn5.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-CbpNevZP.js → FilePreviewPanel-CTTCKfik.js} +10 -10
- package/dist/client/assets/{FoldedSettingsSection-DySTg20x.js → FoldedSettingsSection-ClboCRR4.js} +2 -2
- package/dist/client/assets/{FormContext-CmvUzTS-.js → FormContext-DcLeIpxJ.js} +2 -2
- package/dist/client/assets/{HDGCDEEZ-CN-ckGDk.js → HDGCDEEZ-DtsLNbcM.js} +2 -2
- package/dist/client/assets/{HSJLKHB7-B0BvmnZE.js → HSJLKHB7-Cj1_K-Mg.js} +2 -2
- package/dist/client/assets/{Icons-B4l3TqYa.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-IS0rWO1U.js → K3MD6TGW-SNOidZ8r.js} +2 -2
- package/dist/client/assets/{K7RP3OMA-DcqjCOJO.js → K7RP3OMA-CpajkG5B.js} +2 -2
- package/dist/client/assets/{KeybindingsSettings.logic-mF9mJWrc.js → KeybindingsSettings.logic-BA5WG7V2.js} +2 -2
- package/dist/client/assets/{LHDIQX7Q-CLMgIt4Y.js → LHDIQX7Q-CAyO0Nv9.js} +2 -2
- package/dist/client/assets/{LUXOKEGN-B1dkmN_M.js → LUXOKEGN-Dp60gO-M.js} +2 -2
- package/dist/client/assets/{MathTypeset-qeRVy_bc.js → MathTypeset-DG9QDH3a.js} +2 -2
- package/dist/client/assets/{N3JZAHOW-C6sq5aqx.js → N3JZAHOW-CPZZhC9o.js} +2 -2
- package/dist/client/assets/{NUIALGQ3-BG7xJ_qe.js → NUIALGQ3-Bapg3pv1.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-B0KzU91d.js → NoProjectsHero-DunzHVd0.js} +2 -2
- package/dist/client/assets/{O65XPQGZ-BEfVfDlS.js → O65XPQGZ-BmLVfB2-.js} +2 -2
- package/dist/client/assets/{O7XIQ6OM-BUiRjV87.js → O7XIQ6OM-BzZlSmaP.js} +2 -2
- package/dist/client/assets/{OFQON5FD-DTgVPbd-.js → OFQON5FD-Ciy1Dfj8.js} +2 -2
- package/dist/client/assets/{P4ConnectAccountPages-C4KYM5XU.js → P4ConnectAccountPages-DO-fCpTN.js} +2 -2
- package/dist/client/assets/{P4ConnectSidebarSignIn-DNPUNJl_.js → P4ConnectSidebarSignIn-7hkM7xr7.js} +2 -2
- package/dist/client/assets/{PJQHF43J-QRnhQpHu.js → PJQHF43J-CTTmTIhc.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-4VFKEoHg.js → PanelLayoutControls-clP6N7xc.js} +7 -7
- package/dist/client/assets/{PierreEntryIcon-DeI-j_7w.js → PierreEntryIcon-wm-IkF2y.js} +2 -2
- package/dist/client/assets/{PopoverHandle-DMB4QSp6.js → PopoverHandle-CqjlXffy.js} +2 -2
- package/dist/client/assets/PreviewPanel-fTwWXayK.js +2 -0
- package/dist/client/assets/{ProjectDefaultsSettings-BF-iyQ8T.js → ProjectDefaultsSettings-DABlQCRQ.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-_6hkSNzm.js → ProjectFavicon-zExdjKgc.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-DeL1rZxy.js → ProjectIconPickerDialog-D4Br81iW.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-Cn4l-YGU.js → ProjectMonogram-Ba70a8_s.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-qGeMxZDy.js → ProviderAuthTerminal-Gf_5AaPE.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-DJQYH_Pp.js → ProviderModelPicker-DrfK42fH.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-BSVuPnR0.js → ProviderSettingsForm-CXVYrIzw.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-0OaJE6XS.js → PullRequestCodeTab-DaXxo4Bs.js} +3 -3
- package/dist/client/assets/{RHNBAITX-ChqB7inB.js → RHNBAITX-DKMeuR6R.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-B08Wms4m.js → ReadOnlySourcePreview-DPJWK3HJ.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-BsOuLEci.js → RenderErrorBoundary-BI5KBtsb.js} +2 -2
- package/dist/client/assets/{SLD4V6NK-IkYRGtTH.js → SLD4V6NK-CR4aIcpx.js} +2 -2
- package/dist/client/assets/ScheduledTasksSettings-CTHyd4UX.js +4 -0
- package/dist/client/assets/{ScopedSwitch-Bhp6-hCj.js → ScopedSwitch-De6GoQiO.js} +2 -2
- package/dist/client/assets/{ScrollAreaCorner-BPMuWLbs.js → ScrollAreaCorner-DF4GCx0d.js} +2 -2
- package/dist/client/assets/{SecretInput-RlOzrLKL.js → SecretInput-Dg6ZsU9p.js} +2 -2
- package/dist/client/assets/{SelectScrollUpArrow-6kh66YCd.js → SelectScrollUpArrow-DeRXucOo.js} +2 -2
- package/dist/client/assets/{SettingsPanels-BfBUSBAG.js → SettingsPanels-D6e2byZQ.js} +8 -8
- package/dist/client/assets/{SettingsPanels.logic-BsFZYDgm.js → SettingsPanels.logic-BSXSdFru.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-H7UzC9bb.js → SettingsScopeNotice-MbxDDMZ9.js} +2 -2
- package/dist/client/assets/SidebarStageBackdrop-B0F--sat.js +2 -0
- package/dist/client/assets/{T3PCR2KE-BxaunvVy.js → T3PCR2KE-C0_7R2Oa.js} +2 -2
- package/dist/client/assets/{TKWO2OVW-DFURsfqA.js → TKWO2OVW-DqJmzuhq.js} +2 -2
- package/dist/client/assets/{TSHNXIZL-CIukdyLy.js → TSHNXIZL-CmCl4WMk.js} +2 -2
- package/dist/client/assets/ThemeEditorPanel-IhSXPcO9.js +5 -0
- package/dist/client/assets/{ThreadTerminalDrawer-BQKZCFAC.js → ThreadTerminalDrawer-DnOstFPr.js} +4 -4
- package/dist/client/assets/TooltipViewport-DJXNIjFt.js +2 -0
- package/dist/client/assets/{UQJE5E4I-CfqCotH2.js → UQJE5E4I-U1f_Qxq0.js} +2 -2
- package/dist/client/assets/{USNYFO5S-CctAAheU.js → USNYFO5S-BFU1s0-x.js} +2 -2
- package/dist/client/assets/{Virtualizer-CImHNxBq.js → Virtualizer-CI2uidEs.js} +2 -2
- package/dist/client/assets/{WEVWDWVA-DS9YO9IT.js → WEVWDWVA-DVuH1I8D.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-BW_omYU1.js → WorkspaceBreadcrumb-Dr-p0Dtn.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-BS8FWt_4.js → WorkspacePageContainer-MDWEFwmu.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-CE_94tTR.js → WorkspacePageHeader-CNcKDaqG.js} +2 -2
- package/dist/client/assets/{X5RFHQXM-B0KbwoE1.js → X5RFHQXM-DhiPjZ2I.js} +2 -2
- package/dist/client/assets/{X62E3GBT-wpz8X9Yh.js → X62E3GBT-BoEmDIYA.js} +2 -2
- package/dist/client/assets/{XBNEOJTC-DFRK5c6Y.js → XBNEOJTC-ACchb7zJ.js} +2 -2
- package/dist/client/assets/{YHV2MVVZ-1NnqTTZ2.js → YHV2MVVZ-WIW1NclZ.js} +2 -2
- package/dist/client/assets/{YURCZMG2-rnzWY5ij.js → YURCZMG2-D8PyipKA.js} +2 -2
- package/dist/client/assets/{YVG2LODB-Dxuuk2M-.js → YVG2LODB-BQvBC9bF.js} +2 -2
- package/dist/client/assets/_chat-DDGjgFMR.js +45 -0
- package/dist/client/assets/{_chat.design-z2pu_9A5.js → _chat.design-DjIqnlVZ.js} +2 -2
- package/dist/client/assets/{_chat.index-D8X9o5jY.js → _chat.index-Dku1iZH1.js} +2 -2
- package/dist/client/assets/{_chat.new-CGJw8cpo.js → _chat.new-8-cjg5K7.js} +3 -3
- package/dist/client/assets/_chat.pull-requests-DVfSewSZ.js +2 -0
- package/dist/client/assets/{alert-DO06etEs.js → alert-DpVw79VA.js} +2 -2
- package/dist/client/assets/{assetUrls-CmOUMX2M.js → assetUrls-BOJMUK_1.js} +2 -2
- package/dist/client/assets/{assets-aBpLf8r4.js → assets-6zZLBDZw.js} +2 -2
- package/dist/client/assets/{browserHistoryStore-tYgeZygn.js → browserHistoryStore-TJXTYA-V.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-CQFfJKWJ.js → browserLinkTarget-DRbX4L_9.js} +2 -2
- package/dist/client/assets/{checkbox-BEQFb7GO.js → checkbox-4yBjrqWQ.js} +2 -2
- package/dist/client/assets/{color-picker-CXfnfmuH.js → color-picker-B6JEgpDa.js} +2 -2
- package/dist/client/assets/{combobox--XoXA5uu.js → combobox-CKWbcPIR.js} +2 -2
- package/dist/client/assets/{command-E2aLhsct.js → command-D8XZec1r.js} +2 -2
- package/dist/client/assets/{connect-CU9dNvTt.js → connect-Dp9BB7ev.js} +2 -2
- package/dist/client/assets/{connect-agent-Byc9PCdW.js → connect-agent-DkbIqI-8.js} +2 -2
- package/dist/client/assets/{design-CoGbXd61.js → design-Dn5DzqF2.js} +2 -2
- package/dist/client/assets/{device-DmH6IHQ4.js → device-dylO5xoO.js} +2 -2
- package/dist/client/assets/{dialog-CBBxT1gk.js → dialog-_vbB7RKH.js} +2 -2
- package/dist/client/assets/{diffRendering-BOVFJuWd.js → diffRendering-MXukhqw1.js} +2 -2
- package/dist/client/assets/{dist-B2P3f-0Q.js → dist-ceTe_mn7.js} +3 -3
- package/dist/client/assets/{draft-input-CSOOVntS.js → draft-input-C-u_3cDw.js} +2 -2
- package/dist/client/assets/{duoViewer-BhHYrurM.js → duoViewer-C0aL6Kyr.js} +2 -2
- package/dist/client/assets/{dynamic-BhzrutAo.js → dynamic-DTzzXo3L.js} +2 -2
- package/dist/client/assets/{embeddedScripts-43_R83vp.js → embeddedScripts-DcWCyBxX.js} +2 -2
- package/dist/client/assets/{empty-FOL5U4KY.js → empty-BlKDGTzb.js} +2 -2
- package/dist/client/assets/{entities-Bqo0n1Pb.js → entities-eRiwvW2F.js} +2 -2
- package/dist/client/assets/{fileLinks-D4GSqJYj.js → fileLinks-CYejoXPq.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-BBT5F8P1.js → fileTreeExpansion-wG1G7D6R.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-CGw09SPI.js → getDiffFileInput-CzeweGHs.js} +2 -2
- package/dist/client/assets/{guideRunStore-DvIkVECt.js → guideRunStore-DAYN2Zd7.js} +2 -2
- package/dist/client/assets/{htmlRender-CmEeFzCo.js → htmlRender-C3rZ0xgC.js} +2 -2
- package/dist/client/assets/{index-B1djVqM4.js → index-DA9og9YW.js} +3 -3
- package/dist/client/assets/{input-ekYqAkUx.js → input-DXGWoa4O.js} +2 -2
- package/dist/client/assets/{input-group-C3pxk97H.js → input-group-De0xZXfc.js} +2 -2
- package/dist/client/assets/{kbd-3FPzNikV.js → kbd-WWNLIkTn.js} +2 -2
- package/dist/client/assets/{keybindings-B3oDRRkK.js → keybindings-DAHl8jIl.js} +2 -2
- package/dist/client/assets/{lazy-DyNR0b0B.js → lazy-Ccs3klKO.js} +4 -4
- package/dist/client/assets/{lazyRouteComponent-BPxq_G_s.js → lazyRouteComponent-BU0ER5FO.js} +2 -2
- package/dist/client/assets/{link-B3B5a5Ju.js → link-C3TbL1do.js} +2 -2
- package/dist/client/assets/{linkedPrompt-BsCPMHxQ.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-Bb8H-qbI.js → mediaReference-BbSbhpkR.js} +2 -2
- package/dist/client/assets/{mediaSource-C2MsZgy8.js → mediaSource-B_75uvyp.js} +2 -2
- package/dist/client/assets/{number-field-SoHEiP55.js → number-field-qEfih146.js} +2 -2
- package/dist/client/assets/{observeResize-3Vj9DYOV.js → observeResize-DzSkewug.js} +2 -2
- package/dist/client/assets/{onboarding-CPgiVEVK.js → onboarding-1Zg3fM0A.js} +2 -2
- package/dist/client/assets/{openFileInPreview-BBWCOLh_.js → openFileInPreview-CiPuDrfB.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-qmvlbzKv.js → p4ProjectFile-BVKW5TIA.js} +2 -2
- package/dist/client/assets/{pair-CZnRGdd8.js → pair-DUv1mY4i.js} +2 -2
- package/dist/client/assets/{pendingSendStore-L5KquCDf.js → pendingSendStore-BFVsboDn.js} +2 -2
- package/dist/client/assets/{phoneViewer-D-8v-sMf.js → phoneViewer-CStYy_tX.js} +2 -2
- package/dist/client/assets/{pierre-icons-jwqMPUxD.js → pierre-icons-D3vWvKqU.js} +2 -2
- package/dist/client/assets/{popover-OfG3wVsl.js → popover-CogH2zM4.js} +2 -2
- package/dist/client/assets/{preview-DGdQ5Ycc.js → preview-O1ZL8Awg.js} +2 -2
- package/dist/client/assets/{preview-BYnEURcB.js → preview-ipLyyv_l.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-Dlbj5KrZ.js → previewMiniPlayerStore-C5z1mN8S.js} +2 -2
- package/dist/client/assets/{primary-B47ivN3o.js → primary-CMBPxKMH.js} +2 -2
- package/dist/client/assets/{primaryCloudLinkState-CreqR0gU.js → primaryCloudLinkState-CER468V5.js} +2 -2
- package/dist/client/assets/{projectFilesQueryState-CanWrACx.js → projectFilesQueryState-D4FdR3Xm.js} +2 -2
- package/dist/client/assets/{projectScriptEditor-gWuw6vwd.js → projectScriptEditor-4wQTbXvz.js} +2 -2
- package/dist/client/assets/{providerSkills-C_Rxqah9.js → providerSkills-D3rxPB_g.js} +2 -2
- package/dist/client/assets/{pullRequestDetail.logic-RASi2EgP.js → pullRequestDetail.logic-Bkh57WzV.js} +2 -2
- package/dist/client/assets/{pullRequestIcons-ucGaXXG7.js → pullRequestIcons-DPbMXqGp.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-CEr41DEl.js → pullRequestReviewStore-BAxwf6rl.js} +2 -2
- package/dist/client/assets/{pullRequests-Bw3Ui6hK.js → pullRequests-DggtcbhA.js} +2 -2
- package/dist/client/assets/{queries-EslKFJTV.js → queries-DJfKGsHe.js} +2 -2
- package/dist/client/assets/{query-d1pQlqP0.js → query-B3Zo1YOE.js} +2 -2
- package/dist/client/assets/{radio-group-Ciy_K5uE.js → radio-group-l1Zl-3hQ.js} +2 -2
- package/dist/client/assets/{renderScheduler-CP-JkmKx.js → renderScheduler-BgGYA97h.js} +2 -2
- package/dist/client/assets/{rightPanelStore-D3KOmuPa.js → rightPanelStore-Cv1U3yrU.js} +2 -2
- package/dist/client/assets/{runtime-d6B1vJeH.js → runtime-BOlBBevr.js} +3 -3
- package/dist/client/assets/{runtime-DR7JxgbQ.js → runtime-CeFhsGnm.js} +3 -3
- package/dist/client/assets/{runtimeModeConfig-Rxeb1uGg.js → runtimeModeConfig-BQ0QCQhj.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-CVIC4Kpr.js → scheduledTasksSettings.logic-BpOBCcOk.js} +2 -2
- package/dist/client/assets/{scroll-area-yyfi3ycu.js → scroll-area-CQNIjQ8U.js} +2 -2
- package/dist/client/assets/{select-DaYjjw1q.js → select-Cbpdz6n3.js} +2 -2
- package/dist/client/assets/{selfImproveFindings-1XIHD-7i.js → selfImproveFindings-CT79AgdK.js} +2 -2
- package/dist/client/assets/{server-sXApTCjZ.js → server-DvWrfyUO.js} +2 -2
- package/dist/client/assets/{session-C949OsEI.js → session-D3gY-tOR.js} +2 -2
- package/dist/client/assets/{session-logic-DkSfwnHl.js → session-logic-OeNFZd_V.js} +3 -3
- package/dist/client/assets/{settings-B0O54Q3P.js → settings-C6gUwixG.js} +2 -2
- package/dist/client/assets/{settings.appearance-BesXhA1a.js → settings.appearance-BdGq8dkT.js} +2 -2
- package/dist/client/assets/settings.archived-DobN7ZtC.js +2 -0
- package/dist/client/assets/{settings.computer-use-BeKmLbNe.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-D97jIUyr.js → settings.decisions-D3zMITNw.js} +2 -2
- package/dist/client/assets/{settings.designs-B473PRvt.js → settings.designs-DWeI1d2s.js} +2 -2
- package/dist/client/assets/{settings.diagnostics-DDOaOIDg.js → settings.diagnostics-CqC6fhz6.js} +2 -2
- package/dist/client/assets/{settings.general-qzEOE2zF.js → settings.general-BDEcQVI4.js} +2 -2
- package/dist/client/assets/{settings.integrations-D6ctQ9WI.js → settings.integrations-BmqNoylk.js} +2 -2
- package/dist/client/assets/{settings.keybindings-BL57H4sD.js → settings.keybindings-Mt7J5TKC.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-DaS82UhN.js → settings.open-source-licenses-Dvex7Jce.js} +2 -2
- package/dist/client/assets/{settings.plugins-DnS3RrT2.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-IEAC3STn.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-D4vBYBRP.js → settings.storage-B4ahmlhx.js} +2 -2
- package/dist/client/assets/{settingsLayout-CFQx1XDM.js → settingsLayout-DrhqvTJ8.js} +3 -3
- package/dist/client/assets/{sidebar-C1E4GqL6.js → sidebar-BhJqncti.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-9cUrCOXH.js → sidebarProjectGrouping-DDt6qTcu.js} +2 -2
- package/dist/client/assets/{skeleton-BCpBrYxh.js → skeleton-CFtayHTe.js} +2 -2
- package/dist/client/assets/{sourceControl-DwJWPP0h.js → sourceControl-Dqo9EYNC.js} +2 -2
- package/dist/client/assets/{sourceControlClients-BBJW7ra4.js → sourceControlClients-DGnHi6Rd.js} +2 -2
- package/dist/client/assets/{spinner-CSTrcxhP.js → spinner-BZh9P0sD.js} +2 -2
- package/dist/client/assets/{terminal-links-D18LpQ1T.js → terminal-links-CFKe0iu0.js} +2 -2
- package/dist/client/assets/{terminalSessions-C2NUFncF.js → terminalSessions-BykgTNwT.js} +2 -2
- package/dist/client/assets/{textarea-R4UQ47Ns.js → textarea-hXQFbdrS.js} +2 -2
- package/dist/client/assets/themePalette-MbAn2gqj.js +5 -0
- package/dist/client/assets/{toast-B84QdqqM.js → toast-C61oyZY1.js} +2 -2
- package/dist/client/assets/{toggle-BH5BGBcD.js → toggle-B03MQDgB.js} +2 -2
- package/dist/client/assets/{toggle-group-Di3SFV73.js → toggle-group-yF5GZ53o.js} +2 -2
- package/dist/client/assets/{tooltip-D-GRl-oZ.js → tooltip-ChmjT8Ns.js} +2 -2
- package/dist/client/assets/uiStateStore-DL8OsPjd.js +2 -0
- package/dist/client/assets/{usage-DUdXloVo.js → usage-DATBL2Du.js} +2 -2
- package/dist/client/assets/{usageAccess-DSLF-sRE.js → usageAccess-kgUHYKOw.js} +2 -2
- package/dist/client/assets/{usageFormat-Bzyvr9m4.js → usageFormat-D5Mz5ugL.js} +2 -2
- package/dist/client/assets/{usageShortcuts-D6nQeRtx.js → usageShortcuts-mAekk3eG.js} +2 -2
- package/dist/client/assets/{use-atom-command-DA6OG-Qk.js → use-atom-command-Bt7x9oO0.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-PLuOxvFb.js → useAriaLabelledBy-DjNn9irU.js} +2 -2
- package/dist/client/assets/useHandleNewThread-BOKOo2wA.js +2 -0
- package/dist/client/assets/{useLocation-Bqc94klS.js → useLocation-Cwv1HZ3K.js} +2 -2
- package/dist/client/assets/{useNavigate-DdjG4MB_.js → useNavigate-Cdrlv-yJ.js} +2 -2
- package/dist/client/assets/{useNavigateBack-sP0LsL3p.js → useNavigateBack-CwjQ4iuL.js} +2 -2
- package/dist/client/assets/{useP4ConnectAuthPrompt-C9d7n33S.js → useP4ConnectAuthPrompt-D63n-MFC.js} +2 -2
- package/dist/client/assets/{useParams-DZQvRQLJ.js → useParams-C5D_t-0u.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-BzfAUU9X.js → usePermissionStatus-CKmeNk61.js} +2 -2
- package/dist/client/assets/{usePullRequestActions-DIjGLg1E.js → usePullRequestActions-D53oZord.js} +2 -2
- package/dist/client/assets/{useRegisterFieldControl-CyBVe0G0.js → useRegisterFieldControl-DUs9w2Me.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-D4n22Nmm.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-w_CQ3i43.js → vcsRefInvalidation-B2f3qDSR.js} +2 -2
- package/dist/client/assets/{welcome-BIKH3rbU.js → welcome-CQgOocvj.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/{renderer-CveKT929.mjs → renderer-BBWgEvuE.mjs} +2 -2
- package/dist/{runtime-DGGSjC6Q.mjs → runtime-DNjlpJkJ.mjs} +288 -242
- package/package.json +2 -2
- package/dist/client/assets/AlertDialogRoot-9jRALQXL.js +0 -2
- package/dist/client/assets/AuthSurfaceShell-KQXgPV4i.js +0 -2
- package/dist/client/assets/CodexSetupSection.logic-CNbTXxKb.js +0 -2
- package/dist/client/assets/DeviceSetup-D8qb_qBj.js +0 -2
- package/dist/client/assets/Input-Cv-TKh6s.js +0 -2
- package/dist/client/assets/JZOYTAAL-CB_B_Rei.js +0 -1
- package/dist/client/assets/PreviewPanel-CO66mekh.js +0 -2
- package/dist/client/assets/ScheduledTasksSettings-1UDkELZo.js +0 -4
- package/dist/client/assets/ThemeEditorPanel-otrA-nTg.js +0 -5
- package/dist/client/assets/TooltipViewport-ZmVCer7P.js +0 -2
- package/dist/client/assets/_chat-1QGQLbCc.js +0 -45
- package/dist/client/assets/_chat.pull-requests-BfW9qMU1.js +0 -2
- package/dist/client/assets/composer-logic-BPTz1APL.js +0 -6
- package/dist/client/assets/composerDraftUploads-b_0oxKs9.js +0 -2
- package/dist/client/assets/main-BWh6jqG2.js +0 -29
- package/dist/client/assets/main-DdVSHl80.css +0 -2
- package/dist/client/assets/settings.archived-FtcZf_Ug.js +0 -2
- package/dist/client/assets/settings.connections-D1UxckE0.js +0 -2
- package/dist/client/assets/settings.data-controls-lPiIwMgc.js +0 -2
- package/dist/client/assets/settings.projects-D-ZICXey.js +0 -4
- package/dist/client/assets/settings.providers-CFpCmv0o.js +0 -3
- package/dist/client/assets/settings.snap-shot-BaOFk9WR.js +0 -2
- package/dist/client/assets/settings.source-control-BW16AA5z.js +0 -2
- package/dist/client/assets/themePalette-neUNWCzK.js +0 -5
- package/dist/client/assets/uiStateStore-xSkh4_PU.js +0 -6
- package/dist/client/assets/useHandleNewThread-Dm0SCq59.js +0 -2
- package/dist/client/assets/useSettings-CaJMqrvF.js +0 -3
- package/dist/client/assets/utils-BoMYW9A3.js +0 -37
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{c as e,d as t,g as n,h as r,i,n as a,o,p as s,r as c,s as l,t as u}from"./6OLKWJ4F-
|
|
1
|
+
import{c as e,d as t,g as n,h as r,i,n as a,o,p as s,r as c,s as l,t as u}from"./6OLKWJ4F-D2naWV4i.js";import{d,f,g as p,m,r as h,s as g,t as _,u as ee,y as v}from"./77XECAW3-ECBcD47O.js";import{a as y,s as b}from"./N3JZAHOW-CPZZhC9o.js";import{n as x,r as S,t as C}from"./5B3SVYGG-hhn6T1ru.js";import{t as w}from"./DKTLEL5E-DciMwFJ1.js";import{t as T}from"./K3MD6TGW-SNOidZ8r.js";import{PeleError as E,_ as D,d as O,m as k}from"./lazy-Ccs3klKO.js";var A=new Map([[`ui`,`ui`],[`pcr`,`processor`],[`processor`,`processor`],[`rmo`,`readmodel`],[`readmodel`,`readmodel`],[`cmd`,`command`],[`command`,`command`],[`evt`,`event`],[`event`,`event`]]),j=new Map([[`trigger`,[0,`UI/Automation`,`UI/A: `]],[`state`,[100,`Command/Read Model`,`C/RM: `]],[`stream`,[200,`Events`,`Stream: `]]]);function M(e){return e===`ui`||e===`processor`?`trigger`:e===`event`?`stream`:`state`}function N(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`),r=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):``).replace(/\r/g,``).split(`
|
|
2
2
|
`);for(;r.length>0&&r[0].trim()===``;)r.shift();for(;r.length>0&&r[r.length-1].trim()===``;)r.pop();let i=1/0;for(let e of r)e.trim()!==``&&(i=Math.min(i,e.length-e.trimStart().length));return r.map(e=>e.slice(Math.min(i,e.length)).trimEnd()).join(`
|
|
3
3
|
`)}function P(r,i){let a=new Set;for(let e of r.frames){if(a.has(e.name)){let t=O(r.$source,e.$offset).line;throw new E(`Duplicate event modeling frame ID "${e.name}" on line ${t}`,`semantic`,{type:`eventmodeling`,line:t})}a.add(e.name)}let o=new Map;for(let e of r.dataEntities)o.has(e.name)||o.set(e.name,e.dataBlockValue);let s=new Map,c=new Map,l=(e,t)=>{let n=M(e),r=t===void 0?n:`${n} ${t}`,i=s.get(r);if(!i){let[e,a,o]=j.get(n),l=e;t!==void 0&&(l=c.get(n)??e+1,c.set(n,l+1)),i={index:l,label:t===void 0?a:o+t,group:n,namespace:t},s.set(r,i)}return i},u=[],d=new Map,f=[];r.frames.forEach((e,t)=>{let n=e.entityIdentifier.split(`.`),r=n.length===2?n[0]:void 0,i=A.get(e.modelEntityType)??`event`,a=e.dataInlineValue===void 0?void 0:N(e.dataInlineValue);if(e.dataReference){let t=o.get(e.dataReference.$refText);t!==void 0&&(a=N(t))}let s={id:e.name,kind:i,entity:e.entityIdentifier,name:n.length===2?n[1]:e.entityIdentifier,namespace:r,reset:e.$type===`EmResetFrame`,lane:l(i,r),data:a,dataType:e.dataType};if(u.push(s),d.set(s.id,s),e.sourceFrames.length>0){let t=new Set(e.sourceFrames.map(e=>e.$refText));for(let e of u)t.has(e.id)&&f.push({source:e,target:s})}else if(t>0&&!s.reset){for(let e=t-1;e>=0;e--)if(u[e].lane!==s.lane){f.push({source:u[e],target:s});break}}});let p=e=>e.map(e=>e.entityIdentifier.$refText);return{type:`eventmodeling`,title:r.title&&t(r.title)||i,accTitle:r.accTitle?n(r.accTitle).replace(/^\s+/g,``):void 0,accDescr:r.accDescr?e(r.accDescr).replace(/\n\s+/g,`
|
|
4
4
|
`):void 0,boxes:u,lanes:[...s.values()].sort((e,t)=>e.index-t.index),relations:f,notes:r.noteEntities.map(e=>({frame:e.sourceFrame.$refText,text:N(e.dataBlockValue),dataType:e.dataType})),specifications:r.gwtEntities.map(e=>({frame:e.sourceFrame.$refText,given:p(e.givenStatements),when:p(e.whenStatements),then:p(e.thenStatements)})),entities:r.modelEntities.map(e=>e.name)}}var F={name:`EM_ID`,pattern:/[_a-zA-Z][\w_]*/y},I=e=>({name:e,pattern:e,longer:[F]}),L=e=>({name:e,pattern:e}),R=[`resetframe`,`readmodel`,`processor`,`timeframe`,`command`,`entity`,`event`,`jsobj`,`figma`,`given`,`json`,`salt`,`html`,`text`,`data`,`note`,`when`,`then`,`rmo`,`cmd`,`evt`,`pcr`,`uri`],z=[{...i(`eventmodeling`),longer:[F]},...R.map(I),L(`->>`),I(`gwt`),I(`ui`),I(`md`),I(`tf`),L(`[[`),L(`]]`),I(`rf`),L("`"),L(`.`),F,{name:`EM_FID`,pattern:/\d{1,3}/y},{name:`EM_DATA_INLINE`,pattern:/\{(.*)\}|"(.*)"|'(.*)'/y},{name:`EM_DATA_BLOCK`,pattern:/\{[\t ]*\r?\n(?:[\S\s]*?\r?\n)?\}(?:\r?\n|(?!\S))/y},T(`EM_ACC_DESCR`),{...u,name:`EM_ACC_TITLE`},{...s,name:`EM_TITLE`},{name:`EM_WS`,pattern:/\s+/y,hidden:!0},{...c,name:`EM_YAML`},{...o,name:`EM_DIRECTIVE`},{...l,name:`EM_SINGLE_LINE_COMMENT`},{name:`EM_ML_COMMENT`,pattern:/\/\*[\s\S]*?\*\//y,hidden:!0},{name:`EM_SL_COMMENT`,pattern:/\/\/[^\n\r]*/y,hidden:!0}],B=e=>z.findIndex(t=>t.name===e),V=e=>new Set(e.map(B)),H={keyword:0,arrow:B(`->>`),open:B(`[[`),close:B(`]]`),tick:B("`"),dot:B(`.`),id:B(`EM_ID`),frameId:B(`EM_FID`),inline:B(`EM_DATA_INLINE`),block:B(`EM_DATA_BLOCK`),accDescr:B(`EM_ACC_DESCR`),accTitle:B(`EM_ACC_TITLE`),title:B(`EM_TITLE`),entity:B(`entity`),data:B(`data`),note:B(`note`),gwt:B(`gwt`),given:B(`given`),when:B(`when`),then:B(`then`)},U=V([`tf`,`timeframe`]),W=V([`rf`,`resetframe`]),G=V([`rmo`,`readmodel`,`ui`,`cmd`,`command`,`evt`,`event`,`pcr`,`processor`]),K=V([`json`,`jsobj`,`figma`,`salt`,`uri`,`md`,`html`,`text`]);function te(e){let t=new r(a(e,z,`eventmodeling`),z,`eventmodeling`),n={$type:`EventModel`,modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},i=e=>t.kinds[t.i]===e,o=(e,n)=>e.has(t.kinds[t.i])?t.take():t.fail(n),s=()=>{let e=t.expect(H.id);for(;t.accept(H.dot);)e+=`.`+t.expect(H.id);return e},c=()=>{if(!t.accept(H.tick))return;let e=o(K,`a data type`);return t.expect(H.tick),e},l=()=>{let e=[];do o(G,`an entity type`),e.push({$type:`EmGwtStatement`,entityIdentifier:{$refText:t.expect(H.id)}});while(G.has(t.kinds[t.i]));return e};for(t.expect(H.keyword);!i(-1);){let e=t.kinds[t.i];if(e===H.accDescr)n.accDescr=t.take();else if(e===H.accTitle)n.accTitle=t.take();else if(e===H.title)n.title=t.take();else if(e===H.entity)t.i++,n.modelEntities.push({$type:`EmModelEntity`,name:s()});else if(U.has(e)||W.has(e)){let r={$type:U.has(e)?`EmTimeFrame`:`EmResetFrame`,name:``,modelEntityType:``,entityIdentifier:``,sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,r.name=t.expect(H.frameId),r.modelEntityType=o(G,`an entity type`),r.entityIdentifier=s();t.accept(H.arrow);)r.sourceFrames.push({$refText:t.expect(H.frameId)});if(t.accept(H.open)&&(r.dataReference={$refText:t.expect(H.id)},t.expect(H.close)),i(H.tick)||i(H.inline)){let e=c();e!==void 0&&(r.dataType=e),r.dataInlineValue=t.expect(H.inline)}n.frames.push(r)}else if(e===H.data){t.i++;let e={$type:`EmDataEntity`,name:t.expect(H.id),dataBlockValue:``},r=c();r!==void 0&&(e.dataType=r),e.dataBlockValue=t.expect(H.block),n.dataEntities.push(e)}else if(e===H.note){t.i++;let e={$type:`EmNoteEntity`,sourceFrame:{$refText:t.expect(H.frameId)},dataBlockValue:``},r=c();r!==void 0&&(e.dataType=r),e.dataBlockValue=t.expect(H.block),n.noteEntities.push(e)}else if(e===H.gwt){t.i++;let e={$type:`EmGwt`,sourceFrame:{$refText:t.expect(H.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(H.given),e.givenStatements=l(),t.accept(H.when)&&(e.whenStatements=l()),t.expect(H.then),e.thenStatements=l(),n.gwtEntities.push(e)}else t.fail(`a frame, an entity, a data block, a note, or a specification`)}return n}var q=new Map([[`command`,0],[`event`,1],[`readmodel`,2],[`processor`,6]]),J=12,Y=10,ne=96,X=16,re=80,Z=12,ie=8,ae=48,oe=80,se=8;function Q(e,t){let n=[];for(let r of k(e).split(`
|
|
5
5
|
`)){if(r.length<=t){n.push(r);continue}for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t))}return n}function $(e,t,n,r,i){let a=``;for(let i=0;i<e.length;i++)e[i]!==``&&(a+=`<tspan x="${f(t)}" y="${f(n+i*r)}">${v(e[i])}</tspan>`);return a===``?``:`<text${i} xml:space="preserve">${a}</text>`}function ce(e,t,n){return w(n,r=>le(e,t,n,r))}function le(e,t,n,r){if(r)return pe(e,n);let i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.8125),s=Math.round(i*.75),c=Math.round(s*1.4),l=Math.round(o*1.5),u=n.measurer??D(n.fontFamily,n.fontFamilyMono),v=n.padding??8,x=(e,t,n)=>{let r=0;for(let i of e)r=Math.max(r,u.width(i,t,n));return r},S=new Map,C=0;for(let t of e.lanes){let e=g(t.label,!1,u,o,4e3,1);C=Math.max(C,e.width),S.set(t,{lane:t,label:e,right:-1/0,y:0,h:0})}C+=2*Z;let w=[],T=new Map,E;for(let t of e.boxes){let e=S.get(t.lane),n=g(t.name,!1,u,a,4e3,1),r=t.data?Q(t.data,ae):[],i=Math.max(ne,Math.max(n.width,x(r,s,4))+2*J),o=2*Y+n.height+(r.length>0?6+r.length*c:0),l=0;if(E){let n=E.x+Math.max(E.w/2,E.w-re);l=E.box.lane===t.lane?e.right+X:Math.max(n,e.right+X)}let d={box:t,name:n,data:r,x:l,y:0,w:i,h:o};e.right=l+i,e.h=Math.max(e.h,o),w.push(d),T.set(t,d),E=d}let O=0;for(let e of w)O=Math.max(O,e.x+e.w);let k=C+O+Z,A=g(e.title,!1,u,i,4e3,1),j=A.height>0?A.height+12:0,M=v,N=v+j,P=N,F=``;for(let e of S.values())e.y=P,e.h+=2*Z,F+=`<g class="pele-cluster pele-em-lane" data-id="${h(e.lane.label)}"><rect x="${f(M)}" y="${f(P)}" width="${f(k)}" height="${f(e.h)}" fill="var(--_s)"${m}/>`+_(e.label,M+Z+e.label.width/2,P+e.h/2,` class="pele-cluster-label" font-size="${o}" font-weight="var(--_hw)" fill="var(--_m)"`)+`</g>`,P+=e.h+ie;let I=S.size>0?P-ie:N,L=``;for(let e of w){let t=S.get(e.box.lane);e.x+=M+C,e.y=t.y+(t.h-e.h)/2;let n=q.get(e.box.kind),r=`x="${f(e.x)}" y="${f(e.y)}" width="${f(e.w)}" height="${f(e.h)}"`,i=n===void 0?`<rect ${r} fill="var(--_bg)" stroke="var(--_b)"${m}/>`:`<rect ${r} fill="var(--_bg)"${m}/><rect ${r} fill="${d(n)}" fill-opacity="0.22" stroke="${d(n)}"${m}/>`,o=e.y+Y+e.name.height/2,l=_(e.name,e.x+e.w/2,o,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+$(e.data,e.x+J,e.y+Y+e.name.height+6+c/2+s*.35,c,` class="pele-em-data" font-family="${ee}" font-size="${s}"`);L+=`<g class="pele-node pele-em-${e.box.kind}${e.box.reset?` pele-em-reset`:``}" data-id="${h(e.box.id)}">${i}${l}</g>`}let R=``,z=y(`arrow_point`);for(let t of e.relations){let e=T.get(t.source),n=T.get(t.target);if(!e||!n||e===n)continue;let r,i;if(e.box.lane===n.box.lane){let t=n.x>=e.x,a=t?e.x+e.w:e.x,o=t?n.x:n.x+n.w,s=e.y+e.h/2,c=n.y+n.h/2,l=o>=a?1:-1;r=`M${f(a)},${f(s)}L${f(o-l*z)},${f(c)}`,i=b(`arrow_point`,o,c,l,0,`var(--_l)`)}else{let t=n.y>e.y,a=Math.max(e.x,n.x),o=Math.min(e.x+e.w,n.x+n.w),s=e=>Math.min(24,e/4),c=o-a>=16?(a+o)/2:n.x>e.x?e.x+e.w-s(e.w):e.x+s(e.w),l=o-a>=16?c:n.x>e.x?n.x+s(n.w):n.x+n.w-s(n.w),u=t?e.y+e.h:e.y,d=t?n.y:n.y+n.h,p=t?1:-1,m=d-p*z,h=(u+m)/2;r=c===l?`M${f(c)},${f(u)}V${f(m)}`:`M${f(c)},${f(u)}C${f(c)},${f(h)} ${f(l)},${f(h)} ${f(l)},${f(m)}`,i=b(`arrow_point`,l,d,0,p,`var(--_l)`)}R+=`<g class="pele-edge" data-id="${h(t.source.id)}-${h(t.target.id)}"><path d="${r}" fill="none" stroke="var(--_l)"/>${i}</g>`}let B=new Map;for(let t of e.boxes)B.set(t.id,t.name);let V=``,H=0,U=(e,t,n,r)=>{let i=g(`${t} · ${n}${B.has(n)?` `+B.get(n):``}`,!1,u,o,4e3,1),a=Math.max(i.width,x(r,o,0))+2*J,s=2*Y+i.height+r.length*l,c=I+(V===``&&S.size===0?0:se);V+=`<g class="pele-em-${e}" data-id="${h(n)}"><rect x="${f(M)}" y="${f(c)}" width="${f(a)}" height="${f(s)}" fill="var(--_bg)" stroke="var(--_b)"${m}/>`+_(i,M+J+i.width/2,c+Y+i.height/2,` font-size="${o}" font-weight="var(--_hw)"`)+$(r,M+J,c+Y+i.height+l/2+o*.35,l,` font-size="${o}"`)+`</g>`,I=c+s,H=Math.max(H,a)};for(let t of e.notes)U(`note`,`Note`,t.frame,Q(t.text,oe));for(let t of e.specifications){let e=[`Given ${t.given.join(`, `)}`];t.when.length>0&&e.push(`When ${t.when.join(`, `)}`),e.push(`Then ${t.then.join(`, `)}`),U(`specification`,`Given / When / Then`,t.frame,e.flatMap(e=>Q(e,oe)))}let W=Math.max(S.size>0?k:0,H,A.width),G=Math.ceil(W+2*v),K=Math.ceil(I+v),te=_(A,G/2,v+A.height/2,` class="pele-title" font-weight="var(--_tw)"`)+F+R+L+V;return{svg:p(`eventmodeling`,G,K,i,n,e,te),width:G,height:K,links:[]}}var ue=8,de=120,fe=20;function pe(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=Math.round(n*.75),a=t.padding??8,o=t.measurer??D(t.fontFamily,t.fontFamilyMono),s=Math.max(160,(t.maxWidth??320)-2*a),c=new Map(e.boxes.map((e,t)=>[e,t])),l=new Map,u=new Set;for(let t of e.relations){let n=c.get(t.source),r=c.get(t.target);if(n===void 0||r===void 0||n===r)continue;if(Math.abs(n-r)<2){u.add(e.boxes[Math.max(n,r)]);continue}let i=l.get(t.target);i?(i[0]=Math.min(i[0],n),i[1]=Math.max(i[1],n)):l.set(t.target,[Math.min(n,r),Math.max(n,r)])}let w=new Map,T=[];for(let[e,[t,n]]of[...l].sort((e,t)=>e[1][0]-t[1][0])){let r=T.findIndex(e=>e<t);r<0&&(r=T.length),T[r]=n,w.set(e,r)}let E=24+ue*Math.max(0,T.length-1),O=Math.max(de,s-E),A=O-2*J,j=g(e.title,!1,o,n,s,1),M=a+(j.height?j.height+12:0),N=a+j.height,P=Math.max(j.width,O+E),F=``,I=``,L=``,R=new Map,z=(e,t,n=0)=>C(k(e),o,t,A,n);e.boxes.forEach((e,t)=>{let n=u.has(e)?A-fe:A,s=S(g(e.lane.label,!1,o,r,n,1),o,n),c=g(e.name,!1,o,r,A-36,1),l=e.data?z(e.data,i,4):void 0,p=Math.max(O,s.width+2*J,c.width+2*J+36,(l?.width??0)+2*J),y=s.height+12,b=2*Y+c.height+(l?l.height+6:0),C=q.get(e.kind),w=M+y,T=`x="${f(a)}" y="${f(w)}" width="${f(p)}" height="${f(b)}"`;F+=`<g class="pele-cluster pele-em-lane" data-id="${h(e.lane.label)}">`+x(s,a+J,M,` class="pele-cluster-label" font-size="${r}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${e.kind}${e.reset?` pele-em-reset`:``}" data-id="${h(e.id)}"><rect ${T} fill="var(--_bg)" stroke="var(--_b)"${m}/>`+(C===void 0?``:`<rect ${T} fill="${d(C)}" fill-opacity="0.22" stroke="${d(C)}"${m}/>`)+_(c,a+J+c.width/2,w+Y+c.height/2,` class="pele-label" font-size="${r}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${f(a+p-J)}" y="${f(w+Y+r)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${v(e.id)}</text>`+(l?$(l.lines.map(e=>e.map(e=>e.text).join(``)),a+J,w+Y+c.height+6+l.lineHeight/2+i*.35,l.lineHeight,` class="pele-em-data" font-family="${ee}" font-size="${i}"`):``)+`</g></g>`,R.set(e,{y:w,h:b,w:p,index:t,lane:s.width}),P=Math.max(P,p+E),N=w+b,M=N+28});for(let t of e.relations){let e=R.get(t.source),n=R.get(t.target);if(!e||!n||e===n)continue;let r=n.y>e.y,i=r?1:-1,o=r?e.y+e.h:e.y,s=r?n.y:n.y+n.h,c,l;if(Math.abs(e.index-n.index)===1){let t=a+Math.max(Math.min(e.w,n.w)/2,J+(r?n:e).lane+16);c=`M${f(t)},${f(o)}V${f(s-i*y(`arrow_point`))}`,l=b(`arrow_point`,t,s,0,i,`var(--_l)`)}else{let r=a+P-E+12+ue*(w.get(t.target)??0),i=e.y+e.h/2-5,o=n.y+n.h/2+5;c=`M${f(a+e.w)},${f(i)}H${f(r)}V${f(o)}H${f(a+n.w+y(`arrow_point`))}`,l=b(`arrow_point`,a+n.w,o,-1,0,`var(--_l)`)}I+=`<g class="pele-edge" data-id="${h(t.source.id)}-${h(t.target.id)}"><path d="${c}" fill="none" stroke="var(--_l)"/>${l}</g>`}let B=new Map(e.boxes.map(e=>[e.id,e.name])),V=(e,t,n,i)=>{let s=g(`${t} · ${n}${B.has(n)?` `+B.get(n):``}`,!1,o,r,A,1),c=z(i,r),l=Math.max(O,s.width+2*J,c.width+2*J),u=2*Y+s.height+c.height;L+=`<g class="pele-em-${e}" data-id="${h(n)}"><rect x="${f(a)}" y="${f(M)}" width="${f(l)}" height="${f(u)}" fill="var(--_bg)" stroke="var(--_b)"${m}/>`+_(s,a+J+s.width/2,M+Y+s.height/2,` font-size="${r}" font-weight="var(--_hw)"`)+$(c.lines.map(e=>e.map(e=>e.text).join(``)),a+J,M+Y+s.height+c.lineHeight/2+r*.35,c.lineHeight,` font-size="${r}"`)+`</g>`,N=M+u,M=N+se,P=Math.max(P,l)};for(let t of e.notes)V(`note`,`Note`,t.frame,t.text);for(let t of e.specifications){let e=[`Given ${t.given.join(`, `)}`];t.when.length&&e.push(`When ${t.when.join(`, `)}`),e.push(`Then ${t.then.join(`, `)}`),V(`specification`,`Given / When / Then`,t.frame,e.join(`
|
|
6
6
|
`))}let H=Math.ceil(P+2*a),U=Math.ceil(N+a),W=_(j,H/2,a+j.height/2,` class="pele-title" font-weight="var(--_tw)"`)+I+F+L;return{svg:p(`eventmodeling`,H,U,n,t,e,W),width:H,height:U,links:[]}}var me={type:`eventmodeling`,keepComments:!0,parse:(e,t,n)=>P(te(e),n),render:ce};export{me as eventmodeling};
|
|
7
|
-
//# sourceMappingURL=FNOVOB4O-
|
|
7
|
+
//# sourceMappingURL=FNOVOB4O-BeMBYVRF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,t}from"./react-DH3P2YXY.js";import{Ha as n,Ln as r,Rn as i,Un as a,Va as o,Vn as s,ka as c,pa as l,qa as u,sa as d,uo as f,wo as p}from"./utils-
|
|
2
|
-
//# sourceMappingURL=FieldControl-
|
|
1
|
+
import{a as e,t}from"./react-DH3P2YXY.js";import{Ha as n,Ln as r,Rn as i,Un as a,Va as o,Vn as s,ka as c,pa as l,qa as u,sa as d,uo as f,wo as p}from"./utils-CBe1bHL7.js";import{t as m}from"./useRegisterFieldControl-DUs9w2Me.js";var h=e(t()),g=h.forwardRef(function(e,t){let{render:g,className:_,id:v,name:y,value:b,disabled:x=!1,onValueChange:S,defaultValue:C,autoFocus:w=!1,style:T,...E}=e,{state:D,name:O,disabled:k,setTouched:A,setDirty:j,validityData:M,setFocused:N,setFilled:P,validationMode:F,validation:I}=s(),L=k||x,R=O??y,z={...D,disabled:L},{labelId:B}=i(),V=r({id:v});o(()=>{let e=b!=null;I.inputRef.current?.value||e&&b!==``?P(!0):e&&b===``&&P(!1)},[I.inputRef,P,b]);let H=h.useRef(null);o(()=>{w&&H.current===l(d(H.current))&&N(!0)},[w,N]);let[U]=u({controlled:b,default:C,name:`FieldControl`,state:`value`}),W=b!==void 0,G=W?U:void 0,K=n(()=>I.inputRef.current?.value);return m(I.inputRef,V,G,K),p(`input`,e,{ref:[t,H],state:z,props:[{id:V,disabled:L,name:R,ref:I.inputRef,"aria-labelledby":B,autoFocus:w,...W?{value:G}:{defaultValue:C},onChange(e){let t=e.currentTarget.value;S?.(t,c(f,e.nativeEvent)),j(t!==M.initialValue),P(t!==``)},onFocus(){N(!0)},onBlur(e){A(!0),N(!1),F===`onBlur`&&I.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(A(!0),I.commit(e.currentTarget.value))}},I.getInputValidationProps(),E],stateAttributesMapping:a})});export{g as t};
|
|
2
|
+
//# sourceMappingURL=FieldControl-BOrs67_f.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,t}from"./react-DH3P2YXY.js";import{t as n}from"./jsx-runtime-BnjsACtP.js";import{D as r,J as i,X as a,Y as o,_t as s,et as c,f as l,ft as u,g as d,gt as f,h as p,ht as m,mt as h,ot as g,pt as _,w as v}from"./diffRendering-BOVFJuWd.js";import{D as y,E as b,F as x,G as S,I as C,K as w,L as T,M as E,N as D,O,P as k,R as A,S as j,T as M,U as N,W as P,b as F,c as I,d as L,f as R,g as ee,i as te,k as z,n as ne,o as re,r as ie,s as ae,u as oe,v as se,x as ce,y as le,z as ue}from"./Virtualizer-CImHNxBq.js";import{A as de,C as fe,D as pe,E as me,F as he,I as ge,N as _e,O as ve,Q as B,S as ye,Z as be,a as xe,b as Se,d as Ce,f as V,g as we,h as H,i as Te,l as U,m as W,n as Ee,o as De,p as Oe,r as ke,rt as Ae,s as je,t as Me,u as G,ut as Ne,v as K,w as Pe,x as q,y as Fe}from"./getDiffFileInput-CGw09SPI.js";import{n as Ie,t as Le}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{Ca as J}from"./main-BWh6jqG2.js";var Y=e(n(),1);function X(e){return e===``?[]:e.split(s)}function Re(e,t,n){let r=e===`clone`?Le(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return ze(r,Ve(r,n),He(r,n));case`rename-pure`:{let e=He(r,n);Ue(r,n);let t=X(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Ge(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function ze(e,t,n){let r=X(t.contents),i=X(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Be(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Ge(e,t,n),e}function Be(e,t){let n=0,r=0,i=0,s=[];for(let t of e){let e=Math.max(t.additionStart-1,0),c=Math.max(t.deletionStart-1,0),l=e,u=c,d=0,f=0,p=0,m=0,h=[];for(let e of t.hunkContent){if(e.type===`context`){h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.lines,u+=e.lines,p+=e.lines,m+=e.lines;continue}h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.additions,u+=e.deletions,d+=e.additions,f+=e.deletions,p+=Math.max(e.additions,e.deletions),m+=e.additions+e.deletions}let g=Math.max(a(t.additionStart,t.additionCount)-i,0);s.push({...t,collapsedBefore:g,additionLineIndex:e,deletionLineIndex:c,additionLines:d,deletionLines:f,hunkContent:h,splitLineStart:n+g,unifiedLineStart:r+g,splitLineCount:p,unifiedLineCount:m}),n+=g+p,r+=g+m,i=o(t.additionStart,t.additionCount)}if(s.length>0){let e=s[s.length-1],i=o(e.additionStart,e.additionCount),a=Math.max(t-i,0);n+=a,r+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:r}}function Ve(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function He(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Ue(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function We(e,t,n){return e.cacheKey==null?Ke(t,n):`${e.cacheKey}:hydrated`}function Ge(e,t,n){let r=We(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Ke(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?i(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var qe=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Je(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Ye(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}async function Xe(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ze(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:fe(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Qe(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function $e(e){let t={...e};return delete t.cacheKey,t}function et(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??J(e.name),r=t.lang??J(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function tt(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function nt(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&tt(n.lines,t.deletionLines)}var rt=-1,it=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++rt}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:g},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new T,this.scrollSyncManager=new qe,this.interactionManager=new A(`diff`,ue(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??g}getHunksRendererOptions(e){return Ze(e)}createHunksRenderer(e){return new Ee(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,o;hunkIterator:for(let s of e.hunks){let e=n===`deletions`?s.deletionStart:s.additionStart,c=n===`deletions`?s.deletionCount:s.additionCount,l=a(e,c)+1,u=s.splitLineStart,d=s.unifiedLineStart;if(t<l){let e=l-t;i=Math.max(d-e,0),o=Math.max(u-e,0);break hunkIterator}if(t>=l+c){if(s===r){let e=t-(l+c);i=d+s.unifiedLineCount+e,o=u+s.splitLineCount+e;break hunkIterator}continue}for(let e of s.hunkContent)if(e.type===`context`){if(t<l+e.lines){let e=t-l;o=u+e,i=d+e;break hunkIterator}l+=e.lines,u+=e.lines,d+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<l+r){let r=t-l;i=d+(n===`additions`?e.deletions:0)+r,o=u+r;break hunkIterator}l+=r,u+=Math.max(e.deletions,e.additions),d+=e.deletions+e.additions}break hunkIterator}if(i!=null&&o!=null)return[i,o]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ue(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ne(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>ce(this.editSession?.annotations,e,B);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}this.isNewAnnotations(e)&&(this.lineAnnotations=e,j(t,e,B))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;S(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Me(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||lt(this.pre,st({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||ut(this.headerElement,ct({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),O(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?l(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||!Qe(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){return this.fileDiff!=null&&!this.fileDiff.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null)throw this.fileDiff?.isPartial===!0&&!Qe(this.fileDiff)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`);if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(!this.__canAttachEditor()){if(this.fileDiff?.isPartial===!0&&!Qe(this.fileDiff))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(Re(`merge`,e,t),this.setHydratedState(t),this.installHydratedSessionDiff(e)){this.rerender();return}await Xe(()=>this.primeHighlightCache(e)),this.enabled&&this.fileDiff===e&&this.rerender()}}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.fileDiff===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateExternalDiff(e,t){if(K(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;return this.fileDiff=e,n!=null&&(e.isPartial?this.loadFilesIfNecessary():this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=n)),this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=F(t,B,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:X(t.contents),a=n!=null&&nt(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=$e(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&i!=null&&(s.additionLines=i,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,je(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??F(this.lineAnnotations,B),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let u=Me(c,`FileDiff.render`),d=u?.oldFile,f=u?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:m=`system`,expandUnchanged:h=!1}=this.options,g=p?void 0:s,v=this.hasThemeChanged(),y=u!=null,b=y&&(!ot(d,this.deletionFile)||!ot(f,this.additionFile)),x=e!=null&&!K(e,this.fileDiff),S=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!p&&Ae(g,this.renderRange)&&!n&&!S&&!v&&(e!=null&&!x||e==null&&!b)){let e=this.applyCachedThemeState(m);return e&&this.finalizeRender(),e}let C;e==null&&y&&(b||this.fileDiff==null)&&(C=l(u.oldFile,u.newFile,this.options.parseDiffOptions));let{renderRange:w}=this;this.renderRange=g,y?(this.deletionFile=d,this.additionFile=f):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&x?this.updateExternalDiff(e,i):C!=null&&(x=!0,this.updateExternalDiff(C,i)),x&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let T=this.getLatestDiff();if(T==null)return!1;T.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(xe(T,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),h&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:E=!1,disableFileHeader:D=!1}=this.options;if(D&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(m),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(T,_);e!=null&&this.applyThemeState(a,e.themeStyles,m,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??T,this.injectUnsafeCSS()}catch(e){if(E)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,S,b||x||v||!K(this.renderedDiff,T))&&this.applyPartialRender({fileDiff:T,previousRenderRange:w,renderRange:g}))){let t=this.hunksRenderer.renderDiff(T,g);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,m,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData),this.renderedDiff=t.fileDiff}this.applyBuffers(e,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(E)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let o=this.editSession?.outgoingDiff,{fileDiff:s}=this,c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?et(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??J(i.name),c=p({theme:o,lang:s});c==null?d({themes:v(o),langs:[`text`,s],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(a):a(c)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||be(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return U({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&et(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?Ie(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(at(r)),e.__getDocumentSessionState()),this.editor=e,this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&(this.renderedDiff=i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:a,annotations:o}=n;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=o?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=Le(a),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:r,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===r.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&(this.fileDiff=c,this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),s!=null&&(this.lineAnnotations=s)),this.editSession=void 0,e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Te(e,this.hunksRenderer.getExpandedHunksMap(),t);return xe(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(De(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;if(this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return we({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Oe({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=Ce(o);if(e<s){let c=G({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=W({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=Ce(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){w(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||ke(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{ee(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!Ye(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!Je(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:k(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=D();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:b(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):b(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=de;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:i,html:a,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&K(i,n)?a:void 0)??r(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let e=document.createElement(`div`);e.innerHTML=s;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.headerCache.lastRenderedHTML=s}if(this.isContainerManaged)return;let{renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:p}=this.options;if(l!=null){let e=l(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,c,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let g=u?.(n)??void 0,_=d?.(n)??void 0,v=p?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,g),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,h,_),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,m,v),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=E(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=pe(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=ve(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=se({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:me(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Pe(this.themeCSSStyle.textContent??``,ve(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&M()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?le(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let i=this.getColumnPair(e);if(i==null)return!1;let a=Z(t[0]),o=Z(t[1]);return a==null||o==null?!1:(i.gutter.innerHTML=r(a),i.content.innerHTML=r(o),n!==this.lastRowCount&&(i.gutter.style.setProperty(`grid-row`,`span ${n}`),i.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=z({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=z({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=z({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.renderedDiff=e.fileDiff}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=Z(r?.[0]),a=Z(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let i=this.hunksRenderer.renderCodeAST(`unified`,t),a=Z(i?.[0]),o=Z(i?.[1]),s=()=>{for(let[e,t]of[[n.gutter,a],[n.content,o]])t!=null&&(e.innerHTML=r(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?le(this.pre,s):s(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Z(t[0]),i=Z(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};x(u,this.appliedPreAttributes)||(y(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function at(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function st({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function ct({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function lt(e,t,n=!1){return!n&&e==null&&t}function ut(e,t,n=!1){return e==null&&t&&!n}function Z(e){if(e!=null&&e.type===`element`)return e.children??[]}function dt({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=q(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=G({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=V({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=ft(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?W({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=ye(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function ft(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return pt(e,t)}function pt(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}var mt=3e3,Q=new Map,ht=-1,gt=class extends it{__id=`little-virtualized-file-diff:${++ht}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Q,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=Fe(n)}setMetrics(e,t=!1){let n=Fe(e);(t||!P(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLatestAnnotations();return he(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!N(t,e),r=n&&wt(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Tt(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=Q,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??Q);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.getLatestAnnotations().length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&ge(this.renderRange)){let t=_t(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=kt(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateExternalDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=Fe(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=q(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Se(this.metrics,i),height:0};let m;return U({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=V({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=H({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??q(this.metrics,n)+this.cache.fileAnnotationHeight,u;return U({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=V({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=H({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!K(this.getRenderedDiff(),this.getLatestDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(this.isAdvancedMode()){let n=Re(`clone`,e,t);if(await Xe(()=>this.primeHighlightCache(n)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Re(`merge`,e,t),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await Xe(()=>this.primeHighlightCache(e)),this.fileDiff!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return we({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.fileDiff!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!K(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??Q);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;if(a){this.height+=Se(this.metrics,i),this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=dt({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Et(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Me(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,u=o&&(!Ot(s,this.deletionFile)||!Ot(c,this.additionFile)),d=t??this.fileDiff;t==null&&o&&(u||this.fileDiff==null)&&(d=l(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:f,isSetup:p}=this;this.forceRenderOverride=void 0;let m=d!=null&&!K(this.fileDiff,d),h=m||u;if(e=this.getOrCreateFileContainer(e),d==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;m&&this.updateExternalDiff(d,r);let{pendingRenderDiff:g,layoutDiffChanged:_,renderedDiffChanged:v,annotationsChanged:y}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(d)??d)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(d,r);if(_&&this.resetLayoutCache({includeEstimatedHeights:!0}),p)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,g));else{this.computeApproximateSize(!1,g);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!h||!p))return a!=null&&(this.deletionFile=s,this.additionFile=c),m&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let b=this.virtualizer.getWindowSpecs(),x=this.top??0,S=this.computeRenderRangeFromWindow(g,x,b);return super.render({fileDiff:d,fileContainer:e,renderRange:S,lineAnnotations:r,forceRender:(f??n)||y||v||m,...a,...i})}finalizeRender(){if(!K(this.getRenderedDiff(),this.pendingRender?.diff))throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!K(a,o),renderedDiffChanged:!K(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Dt(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Et(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=vt(this.cache.heightDeltas),u=q(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=xt(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+St(i,e)*this.metrics.lineHeight+yt(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=mt}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+yt(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=G({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?V({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?W({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?H({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Ct({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=G({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=W({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Et(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=q(this.metrics,i),h=e.hunks.length>0?ye(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(U({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?V({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=H({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,ee=E[I]??0,te=L===0?0:g+ee,z=I+R/s,ne=z<E.length?v-E[z]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:te,bufferAfter:Math.max(0,ne)}}};function _t(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===_e&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function vt(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function yt({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=bt(e,n);return(t[bt(e,r)]??0)-(t[i]??0)}function bt(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function xt(e){return Math.ceil(e/mt)*mt}function St(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Ct({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function wt(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Tt(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Et(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Dt(e){return typeof e==`function`?`custom`:e??`line-info`}function Ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function kt(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function At({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function jt(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Mt(n,e.startContentIndex)}}function Mt(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function Nt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:l,lineAnnotations:u,getHoveredLine:d,getInstance:f,getAnnotationSlotName:p=B}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,Y.jsxs)(Y.Fragment,{children:[m==null?(0,Y.jsxs)(Y.Fragment,{children:[h!=null&&(0,Y.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,Y.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,Y.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,Y.jsx)(`div`,{slot:c,children:m}),o!=null&&u?.map((e,t)=>(0,Y.jsx)(`div`,{slot:p(e),children:o(e)},t)),t!=null&&l!=null&&f!=null&&t.map(t=>{if(t==null)return;let n=Pt(t,e);return(0,Y.jsx)(`div`,{slot:n,style:ae,children:l(t,f)},n)}),s!=null&&(0,Y.jsx)(`div`,{slot:`gutter-utility-slot`,style:re,children:s(d)})]})}function Pt(e,t){let n=jt(e,t);return n==null?void 0:At({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var $=e(t(),1),Ft=typeof window>`u`?$.useEffect:$.useLayoutEffect;function It({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=ne(),_=s!==void 0,v=(0,$.useContext)(te),y=oe(),[b,x]=(0,$.useState)(),S=L(e=>m?.(e)),C=m==null?void 0:S,w=(0,$.useRef)(null),T=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(w.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),E=h==null?void 0:T,D=Lt({acceptedCache:w,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),O=(0,$.useRef)(null),k=(0,$.useRef)(null),A=(0,$.useRef)(null),j=L(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),M=L(e=>{if(e!=null){if(O.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?O.current=new it(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),f?void 0:v,!0):O.current=new gt(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),g,l,f?void 0:v,!0),O.current.hydrate({fileDiff:D,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(O.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);A.current=null,O.current.cleanUp(),O.current=null,k.current=null}});Ft(()=>{let{current:e}=O;if(e==null)return;let t=Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),n=t!==void 0&&!N(e.options,t);if(e.setOptions(t),!p&&(A.current=null,k.current!=null)){let{current:e}=k;k.current=null,e()}let i=zt(D,o,w);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||k.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{O.current===e&&k.current==null&&e.__canAttachEditor()&&(k.current=Vt(e,j))};if(e.__canAttachEditor()){A.current=null,a();return}let c=e.__prepareForEditing();if(c==null){A.current=null;return}if(A.current?.promise===c)return;let l={promise:c};A.current=l,c.then(()=>{A.current===l&&(a(),A.current=null)}).catch(e=>{A.current===l&&(A.current=null,x(e))})});let P=(0,$.useCallback)(()=>O.current?.getHoveredLine(),[]),F=(0,$.useCallback)(e=>O.current?.getAnnotationSlotName(e)??B(e),[]);if(b!=null)throw b;return{fileDiff:D,ref:M,getHoveredLine:P,getAnnotationSlotName:F}}function Lt({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,$.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(Rt(r,n,o.stale)||Rt(r,n,o.installed))return o.fileDiff;a.filePair=null}return l(r??null,n??null,i)},[e,t,r,n,i])}function Rt(e,t,n){return C(e??void 0,n.oldFile??void 0)&&C(t??void 0,n.newFile??void 0)}function zt(e,t,n){let{current:r}=n;if(r==null)return{fileDiff:e,lineAnnotations:t};let{fileDiff:i,annotations:a}=r,o=e;i!=null&&(K(e,i.stale)?o=i.installed:r.fileDiff=null);let s=t;return a!=null&&(t===a.stale?s=a.installed:r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null),{fileDiff:o,lineAnnotations:s}}function Bt({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return t||r||n||i!=null||a!=null?{...e,controlledSelection:t,renderCustomHeader:n?I:e?.renderCustomHeader,renderGutterUtility:r?I:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function Vt(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Ht({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:d,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=It({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:g!=null,hasCustomHeader:f!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Nt({fileDiff:e,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderAnnotation:d,renderGutterUtility:g,lineAnnotations:a,getHoveredLine:S,getAnnotationSlotName:C});return(0,Y.jsx)(u,{ref:x,className:s,style:c,children:ie(w,l)})}export{Nt as n,gt as r,Ht as t};
|
|
2
|
-
//# sourceMappingURL=FileDiff-
|
|
1
|
+
import{a as e,t}from"./react-DH3P2YXY.js";import{t as n}from"./jsx-runtime-BnjsACtP.js";import{D as r,J as i,X as a,Y as o,_t as s,et as c,f as l,ft as u,g as d,gt as f,h as p,ht as m,mt as h,ot as g,pt as _,w as v}from"./diffRendering-MXukhqw1.js";import{D as y,E as b,F as x,G as S,I as C,K as w,L as T,M as E,N as D,O,P as k,R as A,S as j,T as M,U as N,W as P,b as F,c as I,d as L,f as R,g as ee,i as te,k as z,n as ne,o as re,r as ie,s as ae,u as oe,v as se,x as ce,y as le,z as ue}from"./Virtualizer-CI2uidEs.js";import{A as de,C as fe,D as pe,E as me,F as he,I as ge,N as _e,O as ve,Q as B,S as ye,Z as be,a as xe,b as Se,d as Ce,f as V,g as we,h as H,i as Te,l as U,m as W,n as Ee,o as De,p as Oe,r as ke,rt as Ae,s as je,t as Me,u as G,ut as Ne,v as K,w as Pe,x as q,y as Fe}from"./getDiffFileInput-CzeweGHs.js";import{n as Ie,t as Le}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{go as J}from"./main-DleJeMZO.js";var Y=e(n(),1);function X(e){return e===``?[]:e.split(s)}function Re(e,t,n){let r=e===`clone`?Le(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return ze(r,Ve(r,n),He(r,n));case`rename-pure`:{let e=He(r,n);Ue(r,n);let t=X(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Ge(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function ze(e,t,n){let r=X(t.contents),i=X(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Be(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Ge(e,t,n),e}function Be(e,t){let n=0,r=0,i=0,s=[];for(let t of e){let e=Math.max(t.additionStart-1,0),c=Math.max(t.deletionStart-1,0),l=e,u=c,d=0,f=0,p=0,m=0,h=[];for(let e of t.hunkContent){if(e.type===`context`){h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.lines,u+=e.lines,p+=e.lines,m+=e.lines;continue}h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.additions,u+=e.deletions,d+=e.additions,f+=e.deletions,p+=Math.max(e.additions,e.deletions),m+=e.additions+e.deletions}let g=Math.max(a(t.additionStart,t.additionCount)-i,0);s.push({...t,collapsedBefore:g,additionLineIndex:e,deletionLineIndex:c,additionLines:d,deletionLines:f,hunkContent:h,splitLineStart:n+g,unifiedLineStart:r+g,splitLineCount:p,unifiedLineCount:m}),n+=g+p,r+=g+m,i=o(t.additionStart,t.additionCount)}if(s.length>0){let e=s[s.length-1],i=o(e.additionStart,e.additionCount),a=Math.max(t-i,0);n+=a,r+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:r}}function Ve(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function He(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Ue(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function We(e,t,n){return e.cacheKey==null?Ke(t,n):`${e.cacheKey}:hydrated`}function Ge(e,t,n){let r=We(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Ke(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?i(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var qe=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Je(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Ye(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}async function Xe(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ze(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:fe(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Qe(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function $e(e){let t={...e};return delete t.cacheKey,t}function et(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??J(e.name),r=t.lang??J(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function tt(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function nt(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&tt(n.lines,t.deletionLines)}var rt=-1,it=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++rt}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:g},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new T,this.scrollSyncManager=new qe,this.interactionManager=new A(`diff`,ue(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??g}getHunksRendererOptions(e){return Ze(e)}createHunksRenderer(e){return new Ee(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,o;hunkIterator:for(let s of e.hunks){let e=n===`deletions`?s.deletionStart:s.additionStart,c=n===`deletions`?s.deletionCount:s.additionCount,l=a(e,c)+1,u=s.splitLineStart,d=s.unifiedLineStart;if(t<l){let e=l-t;i=Math.max(d-e,0),o=Math.max(u-e,0);break hunkIterator}if(t>=l+c){if(s===r){let e=t-(l+c);i=d+s.unifiedLineCount+e,o=u+s.splitLineCount+e;break hunkIterator}continue}for(let e of s.hunkContent)if(e.type===`context`){if(t<l+e.lines){let e=t-l;o=u+e,i=d+e;break hunkIterator}l+=e.lines,u+=e.lines,d+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<l+r){let r=t-l;i=d+(n===`additions`?e.deletions:0)+r,o=u+r;break hunkIterator}l+=r,u+=Math.max(e.deletions,e.additions),d+=e.deletions+e.additions}break hunkIterator}if(i!=null&&o!=null)return[i,o]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ue(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ne(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>ce(this.editSession?.annotations,e,B);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}this.isNewAnnotations(e)&&(this.lineAnnotations=e,j(t,e,B))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;S(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Me(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||lt(this.pre,st({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||ut(this.headerElement,ct({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),O(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?l(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||!Qe(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){return this.fileDiff!=null&&!this.fileDiff.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null)throw this.fileDiff?.isPartial===!0&&!Qe(this.fileDiff)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`);if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(!this.__canAttachEditor()){if(this.fileDiff?.isPartial===!0&&!Qe(this.fileDiff))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(Re(`merge`,e,t),this.setHydratedState(t),this.installHydratedSessionDiff(e)){this.rerender();return}await Xe(()=>this.primeHighlightCache(e)),this.enabled&&this.fileDiff===e&&this.rerender()}}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.fileDiff===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateExternalDiff(e,t){if(K(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;return this.fileDiff=e,n!=null&&(e.isPartial?this.loadFilesIfNecessary():this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=n)),this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=F(t,B,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:X(t.contents),a=n!=null&&nt(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=$e(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&i!=null&&(s.additionLines=i,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,je(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??F(this.lineAnnotations,B),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let u=Me(c,`FileDiff.render`),d=u?.oldFile,f=u?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:m=`system`,expandUnchanged:h=!1}=this.options,g=p?void 0:s,v=this.hasThemeChanged(),y=u!=null,b=y&&(!ot(d,this.deletionFile)||!ot(f,this.additionFile)),x=e!=null&&!K(e,this.fileDiff),S=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!p&&Ae(g,this.renderRange)&&!n&&!S&&!v&&(e!=null&&!x||e==null&&!b)){let e=this.applyCachedThemeState(m);return e&&this.finalizeRender(),e}let C;e==null&&y&&(b||this.fileDiff==null)&&(C=l(u.oldFile,u.newFile,this.options.parseDiffOptions));let{renderRange:w}=this;this.renderRange=g,y?(this.deletionFile=d,this.additionFile=f):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&x?this.updateExternalDiff(e,i):C!=null&&(x=!0,this.updateExternalDiff(C,i)),x&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let T=this.getLatestDiff();if(T==null)return!1;T.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(xe(T,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),h&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:E=!1,disableFileHeader:D=!1}=this.options;if(D&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(m),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(T,_);e!=null&&this.applyThemeState(a,e.themeStyles,m,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??T,this.injectUnsafeCSS()}catch(e){if(E)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,S,b||x||v||!K(this.renderedDiff,T))&&this.applyPartialRender({fileDiff:T,previousRenderRange:w,renderRange:g}))){let t=this.hunksRenderer.renderDiff(T,g);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,m,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData),this.renderedDiff=t.fileDiff}this.applyBuffers(e,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(E)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let o=this.editSession?.outgoingDiff,{fileDiff:s}=this,c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?et(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??J(i.name),c=p({theme:o,lang:s});c==null?d({themes:v(o),langs:[`text`,s],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(a):a(c)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||be(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return U({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&et(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?Ie(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(at(r)),e.__getDocumentSessionState()),this.editor=e,this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&(this.renderedDiff=i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:a,annotations:o}=n;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=o?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=Le(a),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:r,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===r.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&(this.fileDiff=c,this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),s!=null&&(this.lineAnnotations=s)),this.editSession=void 0,e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Te(e,this.hunksRenderer.getExpandedHunksMap(),t);return xe(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(De(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;if(this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return we({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Oe({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=Ce(o);if(e<s){let c=G({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=W({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=Ce(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){w(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||ke(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{ee(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!Ye(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!Je(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:k(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=D();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:b(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):b(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=de;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:i,html:a,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&K(i,n)?a:void 0)??r(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let e=document.createElement(`div`);e.innerHTML=s;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.headerCache.lastRenderedHTML=s}if(this.isContainerManaged)return;let{renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:p}=this.options;if(l!=null){let e=l(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,c,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let g=u?.(n)??void 0,_=d?.(n)??void 0,v=p?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,g),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,h,_),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,m,v),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=E(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=pe(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=ve(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=se({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:me(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Pe(this.themeCSSStyle.textContent??``,ve(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&M()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?le(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let i=this.getColumnPair(e);if(i==null)return!1;let a=Z(t[0]),o=Z(t[1]);return a==null||o==null?!1:(i.gutter.innerHTML=r(a),i.content.innerHTML=r(o),n!==this.lastRowCount&&(i.gutter.style.setProperty(`grid-row`,`span ${n}`),i.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=z({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=z({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=z({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.renderedDiff=e.fileDiff}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=Z(r?.[0]),a=Z(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let i=this.hunksRenderer.renderCodeAST(`unified`,t),a=Z(i?.[0]),o=Z(i?.[1]),s=()=>{for(let[e,t]of[[n.gutter,a],[n.content,o]])t!=null&&(e.innerHTML=r(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?le(this.pre,s):s(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Z(t[0]),i=Z(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};x(u,this.appliedPreAttributes)||(y(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function at(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function st({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function ct({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function lt(e,t,n=!1){return!n&&e==null&&t}function ut(e,t,n=!1){return e==null&&t&&!n}function Z(e){if(e!=null&&e.type===`element`)return e.children??[]}function dt({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=q(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=G({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=V({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=ft(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?W({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=ye(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function ft(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return pt(e,t)}function pt(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}var mt=3e3,Q=new Map,ht=-1,gt=class extends it{__id=`little-virtualized-file-diff:${++ht}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Q,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=Fe(n)}setMetrics(e,t=!1){let n=Fe(e);(t||!P(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLatestAnnotations();return he(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!N(t,e),r=n&&wt(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Tt(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=Q,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??Q);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.getLatestAnnotations().length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&ge(this.renderRange)){let t=_t(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=kt(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateExternalDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=Fe(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=q(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Se(this.metrics,i),height:0};let m;return U({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=V({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=H({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??q(this.metrics,n)+this.cache.fileAnnotationHeight,u;return U({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=V({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=H({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!K(this.getRenderedDiff(),this.getLatestDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(this.isAdvancedMode()){let n=Re(`clone`,e,t);if(await Xe(()=>this.primeHighlightCache(n)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Re(`merge`,e,t),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await Xe(()=>this.primeHighlightCache(e)),this.fileDiff!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return we({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.fileDiff!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!K(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??Q);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;if(a){this.height+=Se(this.metrics,i),this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=dt({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Et(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Me(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,u=o&&(!Ot(s,this.deletionFile)||!Ot(c,this.additionFile)),d=t??this.fileDiff;t==null&&o&&(u||this.fileDiff==null)&&(d=l(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:f,isSetup:p}=this;this.forceRenderOverride=void 0;let m=d!=null&&!K(this.fileDiff,d),h=m||u;if(e=this.getOrCreateFileContainer(e),d==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;m&&this.updateExternalDiff(d,r);let{pendingRenderDiff:g,layoutDiffChanged:_,renderedDiffChanged:v,annotationsChanged:y}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(d)??d)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(d,r);if(_&&this.resetLayoutCache({includeEstimatedHeights:!0}),p)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,g));else{this.computeApproximateSize(!1,g);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!h||!p))return a!=null&&(this.deletionFile=s,this.additionFile=c),m&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let b=this.virtualizer.getWindowSpecs(),x=this.top??0,S=this.computeRenderRangeFromWindow(g,x,b);return super.render({fileDiff:d,fileContainer:e,renderRange:S,lineAnnotations:r,forceRender:(f??n)||y||v||m,...a,...i})}finalizeRender(){if(!K(this.getRenderedDiff(),this.pendingRender?.diff))throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!K(a,o),renderedDiffChanged:!K(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Dt(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Et(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=vt(this.cache.heightDeltas),u=q(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=xt(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+St(i,e)*this.metrics.lineHeight+yt(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=mt}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+yt(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=G({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?V({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?W({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?H({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Ct({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=G({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=W({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Et(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=q(this.metrics,i),h=e.hunks.length>0?ye(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(U({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?V({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=H({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,ee=E[I]??0,te=L===0?0:g+ee,z=I+R/s,ne=z<E.length?v-E[z]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:te,bufferAfter:Math.max(0,ne)}}};function _t(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===_e&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function vt(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function yt({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=bt(e,n);return(t[bt(e,r)]??0)-(t[i]??0)}function bt(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function xt(e){return Math.ceil(e/mt)*mt}function St(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Ct({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function wt(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Tt(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Et(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Dt(e){return typeof e==`function`?`custom`:e??`line-info`}function Ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function kt(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function At({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function jt(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Mt(n,e.startContentIndex)}}function Mt(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function Nt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:l,lineAnnotations:u,getHoveredLine:d,getInstance:f,getAnnotationSlotName:p=B}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,Y.jsxs)(Y.Fragment,{children:[m==null?(0,Y.jsxs)(Y.Fragment,{children:[h!=null&&(0,Y.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,Y.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,Y.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,Y.jsx)(`div`,{slot:c,children:m}),o!=null&&u?.map((e,t)=>(0,Y.jsx)(`div`,{slot:p(e),children:o(e)},t)),t!=null&&l!=null&&f!=null&&t.map(t=>{if(t==null)return;let n=Pt(t,e);return(0,Y.jsx)(`div`,{slot:n,style:ae,children:l(t,f)},n)}),s!=null&&(0,Y.jsx)(`div`,{slot:`gutter-utility-slot`,style:re,children:s(d)})]})}function Pt(e,t){let n=jt(e,t);return n==null?void 0:At({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var $=e(t(),1),Ft=typeof window>`u`?$.useEffect:$.useLayoutEffect;function It({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=ne(),_=s!==void 0,v=(0,$.useContext)(te),y=oe(),[b,x]=(0,$.useState)(),S=L(e=>m?.(e)),C=m==null?void 0:S,w=(0,$.useRef)(null),T=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(w.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),E=h==null?void 0:T,D=Lt({acceptedCache:w,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),O=(0,$.useRef)(null),k=(0,$.useRef)(null),A=(0,$.useRef)(null),j=L(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),M=L(e=>{if(e!=null){if(O.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?O.current=new it(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),f?void 0:v,!0):O.current=new gt(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),g,l,f?void 0:v,!0),O.current.hydrate({fileDiff:D,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(O.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);A.current=null,O.current.cleanUp(),O.current=null,k.current=null}});Ft(()=>{let{current:e}=O;if(e==null)return;let t=Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),n=t!==void 0&&!N(e.options,t);if(e.setOptions(t),!p&&(A.current=null,k.current!=null)){let{current:e}=k;k.current=null,e()}let i=zt(D,o,w);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||k.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{O.current===e&&k.current==null&&e.__canAttachEditor()&&(k.current=Vt(e,j))};if(e.__canAttachEditor()){A.current=null,a();return}let c=e.__prepareForEditing();if(c==null){A.current=null;return}if(A.current?.promise===c)return;let l={promise:c};A.current=l,c.then(()=>{A.current===l&&(a(),A.current=null)}).catch(e=>{A.current===l&&(A.current=null,x(e))})});let P=(0,$.useCallback)(()=>O.current?.getHoveredLine(),[]),F=(0,$.useCallback)(e=>O.current?.getAnnotationSlotName(e)??B(e),[]);if(b!=null)throw b;return{fileDiff:D,ref:M,getHoveredLine:P,getAnnotationSlotName:F}}function Lt({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,$.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(Rt(r,n,o.stale)||Rt(r,n,o.installed))return o.fileDiff;a.filePair=null}return l(r??null,n??null,i)},[e,t,r,n,i])}function Rt(e,t,n){return C(e??void 0,n.oldFile??void 0)&&C(t??void 0,n.newFile??void 0)}function zt(e,t,n){let{current:r}=n;if(r==null)return{fileDiff:e,lineAnnotations:t};let{fileDiff:i,annotations:a}=r,o=e;i!=null&&(K(e,i.stale)?o=i.installed:r.fileDiff=null);let s=t;return a!=null&&(t===a.stale?s=a.installed:r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null),{fileDiff:o,lineAnnotations:s}}function Bt({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return t||r||n||i!=null||a!=null?{...e,controlledSelection:t,renderCustomHeader:n?I:e?.renderCustomHeader,renderGutterUtility:r?I:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function Vt(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Ht({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:d,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=It({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:g!=null,hasCustomHeader:f!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Nt({fileDiff:e,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderAnnotation:d,renderGutterUtility:g,lineAnnotations:a,getHoveredLine:S,getAnnotationSlotName:C});return(0,Y.jsx)(u,{ref:x,className:s,style:c,children:ie(w,l)})}export{Nt as n,gt as r,Ht as t};
|
|
2
|
+
//# sourceMappingURL=FileDiff-DW1zPAn5.js.map
|