@p4code/cli 0.8.0 → 0.8.1
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/{AcpMcpStdioBridge-CfALMbjp.mjs → AcpMcpStdioBridge-DBONIB-w.mjs} +120 -19
- package/dist/AcpMcpStdioBridge-D_JnxPWS.mjs +4 -0
- package/dist/{Effect-zfMCY1g4.mjs → Effect-BahT0mOQ.mjs} +2 -2
- package/dist/bin.mjs +2 -2
- package/dist/{binCli-C3s3kGWK.mjs → binCli-mL63pmet.mjs} +7185 -5813
- package/dist/claude-history-worker.mjs +1 -1
- package/dist/{claudeHistoryWorker-CMjiofbZ.mjs → claudeHistoryWorker-v_0uyLGp.mjs} +2 -2
- package/dist/client/.vite/manifest.json +2114 -2088
- package/dist/client/assets/{AnimatedHeight-BwS0L5jd.js → AnimatedHeight-CcLJhBdM.js} +2 -2
- package/dist/client/assets/{AuthSurfaceShell-B5dTwcVl.js → AuthSurfaceShell-DV9IfxfT.js} +2 -2
- package/dist/client/assets/{CSPContext-B1m61J9R.js → CSPContext-5fUBIm56.js} +2 -2
- package/dist/client/assets/ChatGptUsageButton-BjxGhmRJ.js +2 -0
- package/dist/client/assets/ChatMarkdown-S_dLZdsH.js +65 -0
- package/dist/client/assets/{CodexSetupSection.logic-BpefaM8S.js → CodexSetupSection.logic-CpyIRPfJ.js} +2 -2
- package/dist/client/assets/{ComboboxClear-CSnbXRcJ.js → ComboboxClear-DCanpiKf.js} +2 -2
- package/dist/client/assets/{CommandBlock-DcgLBXYD.js → CommandBlock-CCY3uLti.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-oniaSNnQ.js → ComposerPromptEditor-CTei4iV_.js} +13 -13
- package/dist/client/assets/{CompositeRoot-ykxKqF8U.js → CompositeRoot-Dz15SC7i.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-BvfbN2Tp.js → ConnectionStatusDot-BXxnqJgm.js} +2 -2
- package/dist/client/assets/{DevicePanel-wE6eEt9P.js → DevicePanel-hMvCLVG0.js} +2 -2
- package/dist/client/assets/{DeviceSetup-kaQqI-00.js → DeviceSetup--U2_cth3.js} +2 -2
- package/dist/client/assets/{DialogTitle-Cwi7QOum.js → DialogTitle-CdRWiE23.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-CnCPh4ot.js → DiffCommentAnnotation-BO9ZEof3.js} +3 -3
- package/dist/client/assets/DiffFileTree-DOh6vP89.js +2 -0
- package/dist/client/assets/DiffPanel-BdHAXHTV.js +2 -0
- package/dist/client/assets/{DiffWorkerPoolProvider-C8TyWhmO.js → DiffWorkerPoolProvider-HxohyeGq.js} +3 -3
- package/dist/client/assets/{EnvironmentMachineIcon-CBS8TSmT.js → EnvironmentMachineIcon-DYqBsAxl.js} +2 -2
- package/dist/client/assets/{ExpandableText-CWbIeyDn.js → ExpandableText-B9MQs34j.js} +3 -3
- package/dist/client/assets/{FieldControl-CWR3fEt0.js → FieldControl-DuWupdaP.js} +2 -2
- package/dist/client/assets/{FileDiff-BiIVs0i-.js → FileDiff-XdtrigfB.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-CXgaN8cb.js → FilePreviewPanel-Dj_tLsu8.js} +5 -5
- package/dist/client/assets/{FoldedSettingsSection-BimbnaOl.js → FoldedSettingsSection-CJhrFR0_.js} +2 -2
- package/dist/client/assets/{FormContext-DyOeI4sU.js → FormContext-DzMW0viI.js} +2 -2
- package/dist/client/assets/{Icons-BlUgSxml.js → Icons-DJ824_3l.js} +2 -2
- package/dist/client/assets/{KeybindingsSettings.logic-Dfld_XQx.js → KeybindingsSettings.logic-DBks3HZy.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-ZE4gAFj0.js → NoProjectsHero-DyYs0dvZ.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-x5a58Pdn.js → PanelLayoutControls-DmAKKHlt.js} +10 -10
- package/dist/client/assets/{PierreEntryIcon-DeBbijxO.js → PierreEntryIcon-uqPwKknu.js} +2 -2
- package/dist/client/assets/{PreviewPanel-2vuw0skj.js → PreviewPanel-BQkFJlas.js} +2 -2
- package/dist/client/assets/ProjectDefaultsSettings-DglkVzkM.js +2 -0
- package/dist/client/assets/{ProjectFavicon-BhJj4G_1.js → ProjectFavicon-CDpXbAhP.js} +3 -3
- package/dist/client/assets/ProjectIconPickerDialog-yxBKY_6V.js +2 -0
- package/dist/client/assets/{ProjectMonogram-BgobvHld.js → ProjectMonogram-Dd6xeLhS.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-CJSJcjB9.js → ProviderAuthTerminal-DgUIYMm9.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-riIGf-PI.js → ProviderModelPicker-lxEwYGAB.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-Dh_vspcE.js → ProviderSettingsForm-DGMc_kKy.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-Do36z71f.js → PullRequestCodeTab-CXrKDJ3m.js} +3 -3
- package/dist/client/assets/{ReadOnlySourcePreview-BfLIaC5x.js → ReadOnlySourcePreview-DkXxXiTJ.js} +2 -2
- package/dist/client/assets/{RedactedSensitiveText-D5aX1wQs.js → RedactedSensitiveText-DtYR94zZ.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-DTEG6arv.js → RenderErrorBoundary-Dla4qj6V.js} +2 -2
- package/dist/client/assets/ScheduledTasksSettings-2vzTutJz.js +4 -0
- package/dist/client/assets/ScopedSwitch-BdMg8rKM.js +2 -0
- package/dist/client/assets/{SettingsPanels-Betza2Al.js → SettingsPanels-XjjE56Xl.js} +7 -7
- package/dist/client/assets/{SettingsPanels.logic-Dn2Jcxyy.js → SettingsPanels.logic-DSOfF88n.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-CAaNSKvu.js → SettingsScopeNotice-um2bOG_J.js} +2 -2
- package/dist/client/assets/{T3ConnectAccountPages-DEqOE3hy.js → T3ConnectAccountPages-Dx0LK6U5.js} +2 -2
- package/dist/client/assets/{T3ConnectSidebarSignIn-C4jpzdPh.js → T3ConnectSidebarSignIn-2r05ubXZ.js} +2 -2
- package/dist/client/assets/{ThemeEditorPanel-BBkly3jP.js → ThemeEditorPanel-CnhjGelD.js} +3 -3
- package/dist/client/assets/{ThreadTerminalDrawer-Z7ArIuq0.js → ThreadTerminalDrawer-BzElqolI.js} +4 -4
- package/dist/client/assets/{UsageLimits-7-_nKQT_.js → UsageLimits-B_IIjpyx.js} +2 -2
- package/dist/client/assets/{Virtualizer-EvXC5PAR.js → Virtualizer-DItXd38b.js} +2 -2
- package/dist/client/assets/WorkspaceBreadcrumb-Y41aNu4D.js +2 -0
- package/dist/client/assets/WorkspacePageContainer-D3YV5jc4.js +2 -0
- package/dist/client/assets/{WorkspacePageHeader-DB9Z9OtR.js → WorkspacePageHeader-Dduxade-.js} +2 -2
- package/dist/client/assets/_chat-B4G7pIId.js +58 -0
- package/dist/client/assets/{_chat.index-CTfxLY4F.js → _chat.index-BGOR58rk.js} +2 -2
- package/dist/client/assets/{_chat.new-B_FNmP8f.js → _chat.new-CioC4l4P.js} +3 -3
- package/dist/client/assets/_chat.pull-requests-Cs7eiOH6.js +2 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-Du15a8Yu.js → abnfDiagram-VCTEODGH-l9yoycqs.js} +2 -2
- package/dist/client/assets/{alert-DUQHh6vz.js → alert-B49R80NU.js} +2 -2
- package/dist/client/assets/architecture-7GRP2DOG-B67w-l9F.js +1 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-DhXH9Bsf.js → architectureDiagram-5GKGNRK7-BQwAkSAo.js} +2 -2
- package/dist/client/assets/arrow-left-D1nB4UjJ.js +1 -0
- package/dist/client/assets/arrow-right-Cbg5uZyw.js +1 -0
- package/dist/client/assets/arrow-up-down-DRcJBavW.js +1 -0
- package/dist/client/assets/assets-CLIqG-m-.js +2 -0
- package/dist/client/assets/bell-D5jiydSo.js +1 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-CZ4PIO64.js → blockDiagram-I7D4REHJ-C1YTuxst.js} +2 -2
- package/dist/client/assets/blocks-mHGBm843.js +1 -0
- package/dist/client/assets/bot-Db9dBVz5.js +1 -0
- package/dist/client/assets/{browserHistoryStore-D6A_83JY.js → browserHistoryStore-D6dhsqE8.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-BuFHp5RQ.js → browserLinkTarget-D0HujxdB.js} +2 -2
- package/dist/client/assets/{c4Diagram-7LVT6UL2-tMXW_Jy8.js → c4Diagram-7LVT6UL2-DpPcyaba.js} +2 -2
- package/dist/client/assets/calendar-clock-KAbrMUlv.js +1 -0
- package/dist/client/assets/channel-D8Is9vbt.js +2 -0
- package/dist/client/assets/chart-no-axes-column-CnM4ppv4.js +1 -0
- package/dist/client/assets/checkbox-WRJ0D_10.js +2 -0
- package/dist/client/assets/{chunk-4HAMMTFA-gISFFADw.js → chunk-4HAMMTFA-C0t_GKFv.js} +2 -2
- package/dist/client/assets/{chunk-75Z2AOVW-iWd1WVXJ.js → chunk-75Z2AOVW-B6rgeqZP.js} +2 -2
- package/dist/client/assets/{chunk-DU6HZSFF-hD69jU_T.js → chunk-DU6HZSFF-BuYM0Cu8.js} +2 -2
- package/dist/client/assets/{chunk-F27PBJKO-DnDFIjHp.js → chunk-F27PBJKO-CvPd3lcw.js} +2 -2
- package/dist/client/assets/{chunk-GMAD6QVW-Chr0sR5B.js → chunk-GMAD6QVW-DbBkxyCE.js} +2 -2
- package/dist/client/assets/{chunk-GVQU2GXP-D84Xc6Vy.js → chunk-GVQU2GXP-CVZeJiG5.js} +2 -2
- package/dist/client/assets/{chunk-IMKFNOWR-DOdemMNR.js → chunk-IMKFNOWR-CbY3DGV3.js} +2 -2
- package/dist/client/assets/{chunk-L3NEJ4N5-CILnb7VE.js → chunk-L3NEJ4N5-Bhkym4YW.js} +2 -2
- package/dist/client/assets/{chunk-OSK3NFVY-Bxpu9Oo4.js → chunk-OSK3NFVY-B89_sN-h.js} +2 -2
- package/dist/client/assets/{chunk-P2QGCYS3-75l6wJUu.js → chunk-P2QGCYS3-zeIYnZbd.js} +2 -2
- package/dist/client/assets/{chunk-POPQ4Y6H-jYZ1RdM0.js → chunk-POPQ4Y6H-Bv7ZWEJI.js} +2 -2
- package/dist/client/assets/{chunk-PWAF6VOD-DtONZJrC.js → chunk-PWAF6VOD-BnsKTwi6.js} +2 -2
- package/dist/client/assets/{chunk-SHT3W25Y-NY6-WqgC.js → chunk-SHT3W25Y-Daoidttm.js} +2 -2
- package/dist/client/assets/{chunk-SVP7TREG-CGG6Z85U.js → chunk-SVP7TREG-BK4Qxtm6.js} +2 -2
- package/dist/client/assets/{chunk-TICWLB2K-DzB7PtXF.js → chunk-TICWLB2K-CihSBYRG.js} +2 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-CxsiNRJs.js +2 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CxsiNRJs.js +2 -0
- package/dist/client/assets/{collapsible-CLujF6F7.js → collapsible-DyaDJVJ5.js} +2 -2
- package/dist/client/assets/{color-picker-BG3Rpy98.js → color-picker-BWffD8SG.js} +2 -2
- package/dist/client/assets/{combobox-Cx4FP7Bk.js → combobox-zg5NNJOT.js} +2 -2
- package/dist/client/assets/{command-CVKxjYiJ.js → command-CBIpuXFt.js} +2 -2
- package/dist/client/assets/{connect-DeTNO4tO.js → connect-BVveo2H6.js} +2 -2
- package/dist/client/assets/{connect-agent-CTLxG7lp.js → connect-agent-Rlpt-C4T.js} +2 -2
- package/dist/client/assets/corner-left-up-DSgsQQJh.js +1 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-C3y7gjYM.js → cynefin-OW5HDTMX-BTvkQvHj.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-DEFegOUv.js → cynefinDiagram-5FMLGOSQ-glf_yMKF.js} +2 -2
- package/dist/client/assets/{dagre-GXQ25YYZ-C3YHw-ZL.js → dagre-GXQ25YYZ-XUkjXaQW.js} +2 -2
- package/dist/client/assets/device-Bu2mO4gL.js +2 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-B04fDyJ1.js → diagram-S7CK7UJ4-CiNxlSJZ.js} +2 -2
- package/dist/client/assets/{diagram-UQ7AKVKN-DJ5yQdqn.js → diagram-UQ7AKVKN-C4_9QuDF.js} +2 -2
- package/dist/client/assets/{diagram-VSXAHHWV-DwQn4LJH.js → diagram-VSXAHHWV-BoRcnfst.js} +2 -2
- package/dist/client/assets/{diagram-VX7I27RA-BFeEJB2L.js → diagram-VX7I27RA-g5AlZjEL.js} +2 -2
- package/dist/client/assets/{diagram-Z3DM3KII-DjNPPgna.js → diagram-Z3DM3KII-Crw_yJrX.js} +2 -2
- package/dist/client/assets/{dialog-BBidAZq_.js → dialog-C5PVc2Dc.js} +2 -2
- package/dist/client/assets/{diffRendering-BcgWZBc6.js → diffRendering-DVfiIxj4.js} +2 -2
- package/dist/client/assets/{discovery-list-BOhsy2yk.js → discovery-list-Bb2RP3-9.js} +2 -2
- package/dist/client/assets/{dist-D-bAcBTo.js → dist-BTyn8sKm.js} +3 -3
- package/dist/client/assets/download-BrSkg4EE.js +1 -0
- package/dist/client/assets/{draft-input-Dk-JXf0v.js → draft-input-CwdApNsc.js} +2 -2
- package/dist/client/assets/{duoViewer-DELDCd_3.js → duoViewer-BsAzTMk3.js} +2 -2
- package/dist/client/assets/dynamic-COZhF9Vt.js +3 -0
- package/dist/client/assets/earth-D0ZhOX9I.js +1 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-R_zFp3Q4.js → ebnfDiagram-PWID7BFC-Co02q3t2.js} +2 -2
- package/dist/client/assets/ellipsis-Dze-H3uy.js +1 -0
- package/dist/client/assets/{embeddedScripts-S6heIv6s.js → embeddedScripts-cxUGD6UP.js} +2 -2
- package/dist/client/assets/{empty-B3wHlMsI.js → empty-B9cgefGv.js} +2 -2
- package/dist/client/assets/entities-B0tFBQjY.js +2 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-DgSVOlTI.js → erDiagram-RLTQ6QDP-BuoWr1gw.js} +2 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-jDgS08dP.js +1 -0
- package/dist/client/assets/eye-OVEPp8Os.js +1 -0
- package/dist/client/assets/file-search-Y-7Ql86o.js +1 -0
- package/dist/client/assets/{fileLinks-M_i1pQMr.js → fileLinks-BBnShh-N.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-BoH-LpwD.js → fileTreeExpansion-DaFd8SRp.js} +2 -2
- package/dist/client/assets/flowDiagram-HODETNUW-DsHnGCQL.js +1 -0
- package/dist/client/assets/folder-git-2-DdgpEuW8.js +1 -0
- package/dist/client/assets/folder-open-B9DmXcog.js +1 -0
- package/dist/client/assets/folder-plus-CLFJj-Gh.js +1 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CsDp8eOV.js → ganttDiagram-EL5Y4UJY-CMAUkeMs.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-y6l8uCrc.js → getDiffFileInput-D0WCXPuc.js} +2 -2
- package/dist/client/assets/git-branch-SJsNyJlB.js +1 -0
- package/dist/client/assets/{gitGraph-4MIJSDKK-ByZ8Ddcu.js → gitGraph-4MIJSDKK-B22BskFD.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-QkPoZOxP.js → gitGraphDiagram-WWUBYQGX-D9yz6pSR.js} +2 -2
- package/dist/client/assets/grip-vertical-_2pxkeEI.js +1 -0
- package/dist/client/assets/{guideRunStore-Ca6LGvkb.js → guideRunStore-CPFfk-BJ.js} +2 -2
- package/dist/client/assets/hard-drive-DMfAIp4-.js +1 -0
- package/dist/client/assets/history-C7dJNEkM.js +1 -0
- package/dist/client/assets/house-BpsJcs6J.js +1 -0
- package/dist/client/assets/{htmlRender-Bs_dTcPz.js → htmlRender-Cdm053qU.js} +2 -2
- package/dist/client/assets/index-TkyxWt2Q.js +3 -0
- package/dist/client/assets/{info-A6RAGUB7-DWgAQmsU.js → info-A6RAGUB7-CicHHROU.js} +1 -1
- package/dist/client/assets/{infoDiagram-27XIBGKW-DqBsTg-0.js → infoDiagram-27XIBGKW-DAFhUj2V.js} +2 -2
- package/dist/client/assets/{input-BOT1WFGI.js → input-CN9xdIYL.js} +2 -2
- package/dist/client/assets/{input-group-13zF6rZl.js → input-group-CV0ZpOg5.js} +2 -2
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-DhvmZSIn.js → ishikawaDiagram-5VMMS53U-CBEywTMi.js} +2 -2
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-sBAsW8ZW.js → journeyDiagram-3NMN7TZE-BIKjvqRL.js} +2 -2
- package/dist/client/assets/{kanban-definition-UXKFOSKX-7pB8050L.js → kanban-definition-UXKFOSKX-XOFfprGt.js} +2 -2
- package/dist/client/assets/kbd-Fa27fInv.js +2 -0
- package/dist/client/assets/{keybindings-B4uuYLfE.js → keybindings-C81QSEVL.js} +2 -2
- package/dist/client/assets/keyboard-C0H4XsBS.js +1 -0
- package/dist/client/assets/{lazyRouteComponent-C2UuNVTE.js → lazyRouteComponent-BTBK1UDq.js} +2 -2
- package/dist/client/assets/{line-CYcVbD9r.js → line-CEyB3WPo.js} +2 -2
- package/dist/client/assets/{link-DnyZixWB.js → link-C1pmqztR.js} +2 -2
- package/dist/client/assets/link-CsVCGX_A.js +1 -0
- package/dist/client/assets/{linkedPrompt-Cjzkkr18.js → linkedPrompt-B6Q0Cmi6.js} +2 -2
- package/dist/client/assets/list-BKOLPymO.js +1 -0
- package/dist/client/assets/main-CJvawsJJ.js +27 -0
- package/dist/client/assets/main-DjXoj7An.css +2 -0
- package/dist/client/assets/{mediaReference-DCRMHOD7.js → mediaReference-o1DLUGKI.js} +2 -2
- package/dist/client/assets/{mediaSource-C-YyAgza.js → mediaSource-Cfv5uiFj.js} +2 -2
- package/dist/client/assets/{mermaid-parser.core-CUhkd3Km.js → mermaid-parser.core-BT2QN4a3.js} +4 -4
- package/dist/client/assets/{mermaid.core-7L34oYGP.js → mermaid.core-EPDLhovC.js} +5 -5
- package/dist/client/assets/message-circle-question-mark-0PixhBRe.js +1 -0
- package/dist/client/assets/message-square-dashed-jX8EWVKo.js +1 -0
- package/dist/client/assets/message-square-xfL83Fxi.js +1 -0
- package/dist/client/assets/messages-square-DwkvqiPv.js +1 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-CpfzOIsM.js → mindmap-definition-YA3MSWOX-aqL3ALYK.js} +2 -2
- package/dist/client/assets/number-field-BiWh0ioY.js +2 -0
- package/dist/client/assets/{observeResize-CK9qVTLF.js → observeResize-DBJpB0Hu.js} +2 -2
- package/dist/client/assets/{onboarding-DWVdcMTo.js → onboarding-gue-HaiI.js} +2 -2
- package/dist/client/assets/{openFileInPreview-DsWLDsnf.js → openFileInPreview-BuKYchiT.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-DVeZFEli.js → p4ProjectFile-DH7qoFHx.js} +2 -2
- package/dist/client/assets/{packet-AYTQ26CC-TJIgXg7Z.js → packet-AYTQ26CC-BkyzJMIf.js} +1 -1
- package/dist/client/assets/{pair-Ds7MhGzA.js → pair-DESVHftX.js} +2 -2
- package/dist/client/assets/palette-DvhXYFMC.js +1 -0
- package/dist/client/assets/panel-left-DCz3M7jv.js +1 -0
- package/dist/client/assets/{panel-tab-close-button-CeVf2Cp1.js → panel-tab-close-button-DKugpobT.js} +2 -2
- package/dist/client/assets/panels-top-left-C1xu8Xiu.js +1 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-BWjyJv0r.js → pegDiagram-XKGWAZYB-DilAu2aa.js} +2 -2
- package/dist/client/assets/{phoneViewer-4yzlTfRU.js → phoneViewer-xqyGZwKn.js} +2 -2
- package/dist/client/assets/{pie-WAS4IAKB-DI1xrBNC.js → pie-WAS4IAKB-DgPx2D64.js} +1 -1
- package/dist/client/assets/{pieDiagram-E7YTZNPT-D5BJ4dMD.js → pieDiagram-E7YTZNPT-D9PFl5qt.js} +2 -2
- package/dist/client/assets/{pierre-icons-C4_Is1e6.js → pierre-icons-BVuUNHGs.js} +2 -2
- package/dist/client/assets/popover-aTTlR6NX.js +2 -0
- package/dist/client/assets/{preview-ChiUlq6M.js → preview-8KYmxrad.js} +2 -2
- package/dist/client/assets/{preview-BXSjnvc2.js → preview-DgLUnqIn.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-BWBB4WZZ.js → previewMiniPlayerStore-CZUX4gpf.js} +2 -2
- package/dist/client/assets/primary-GHQewxsn.js +2 -0
- package/dist/client/assets/primaryCloudLinkState-BS4O3v7M.js +2 -0
- package/dist/client/assets/{projectFilesQueryState-DLmHVuBp.js → projectFilesQueryState-DmDFr3yJ.js} +2 -2
- package/dist/client/assets/projectScriptEditor-DxxYqdMP.js +2 -0
- package/dist/client/assets/{pullRequestDetail.logic-CiIqeGLs.js → pullRequestDetail.logic-C6mxjZFd.js} +4 -4
- package/dist/client/assets/{pullRequestReviewStore-Ckm9o--D.js → pullRequestReviewStore-VIPIhGsh.js} +2 -2
- package/dist/client/assets/pullRequests-DEHxyBeZ.js +2 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-USH3mFeD.js → quadrantDiagram-AXDQQJYC-36GcvWjt.js} +2 -2
- package/dist/client/assets/queries-BAbZ6wRj.js +2 -0
- package/dist/client/assets/{query-DG-FU00d.js → query-gfas_Faw.js} +2 -2
- package/dist/client/assets/{radar-RG4KPBEZ-BgwqseQY.js → radar-RG4KPBEZ-B_1p1XBS.js} +1 -1
- package/dist/client/assets/radio-group-BcuemB8E.js +2 -0
- package/dist/client/assets/{railroad-74A4TZTK-lU1hozFq.js → railroad-74A4TZTK-DjaD7aBa.js} +1 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-CA1GF-5t.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-Beda5tl-.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-D2CRVbbY.js +1 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-BX2DBjFX.js → railroadDiagram-O6MQD6OU-BfFU3IUU.js} +2 -2
- package/dist/client/assets/{renderScheduler-e5LS9_r8.js → renderScheduler-DE6WzqZi.js} +2 -2
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-Bp2BwkCA.js → requirementDiagram-BXWQKSXE-WVgmezGx.js} +2 -2
- package/dist/client/assets/{rightPanelStore-Dnc28mSJ.js → rightPanelStore-CsSGBQ8t.js} +2 -2
- package/dist/client/assets/rotate-ccw-CyPuoUiH.js +1 -0
- package/dist/client/assets/rotate-cw-B20Q7RJJ.js +1 -0
- package/dist/client/assets/runtime-C9evwoB9.js +2 -0
- package/dist/client/assets/runtime-CxeCZPZ3.js +6 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BklNNjEB.js → sankeyDiagram-P5KCCOFB-BsCi2aYb.js} +2 -2
- package/dist/client/assets/scheduledTasksSettings.logic-Bin7R9R3.js +3 -0
- package/dist/client/assets/{scroll-area-Cj3OF_L_.js → scroll-area-CRoS-lxP.js} +2 -2
- package/dist/client/assets/{select-BDMo6Fqt.js → select-BXOHHCMJ.js} +2 -2
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-ufTHSg4p.js → sequenceDiagram-WJ2MYXX4-C_qj_Szb.js} +2 -2
- package/dist/client/assets/{server-DNo9AqHW.js → server-BBIVfjrf.js} +2 -2
- package/dist/client/assets/session-DZH3pyoG.js +2 -0
- package/dist/client/assets/session-logic-RDMPhilH.js +13 -0
- package/dist/client/assets/{settings-DxGY3RT5.js → settings-0qbtr9oy.js} +2 -2
- package/dist/client/assets/settings-2-DmZK5Wif.js +1 -0
- package/dist/client/assets/settings-Br2yM9q3.js +1 -0
- package/dist/client/assets/settings.appearance-CtG85Hzv.js +2 -0
- package/dist/client/assets/settings.archived-D1CPem1-.js +2 -0
- package/dist/client/assets/settings.computer-use-DvBtreaX.js +2 -0
- package/dist/client/assets/settings.connections-CeSH1Y-S.js +2 -0
- package/dist/client/assets/settings.decisions-FBz5pyct.js +2 -0
- package/dist/client/assets/settings.diagnostics-Ct39tZgQ.js +2 -0
- package/dist/client/assets/settings.general-YgAeT2ec.js +2 -0
- package/dist/client/assets/settings.integrations-DIuNSxXg.js +2 -0
- package/dist/client/assets/{settings.keybindings-CITYXalz.js → settings.keybindings-BHpTOm8T.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-CTznEYnQ.js → settings.open-source-licenses-Dlp4u1NR.js} +2 -2
- package/dist/client/assets/settings.projects-BZP8BJZK.js +4 -0
- package/dist/client/assets/settings.providers-Dad6hRGg.js +3 -0
- package/dist/client/assets/settings.scheduled-tasks-B1Q7wnRI.js +2 -0
- package/dist/client/assets/settings.snap-shot-ZBGDHF90.js +2 -0
- package/dist/client/assets/settings.source-control-BXuO43FQ.js +2 -0
- package/dist/client/assets/{settings.storage-C4lRhJsq.js → settings.storage-Dl3cI_3U.js} +2 -2
- package/dist/client/assets/settingsLayout-DKjAOwp4.js +3 -0
- package/dist/client/assets/shield-question-mark-Cmz7w9_M.js +1 -0
- package/dist/client/assets/{sidebar-Bulbb3cX.js → sidebar-D6V5N0ZC.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-DEvzxecx.js → sidebarProjectGrouping-DVAIOuq4.js} +2 -2
- package/dist/client/assets/{skeleton-BFPHmDcq.js → skeleton-DuFqUDDw.js} +2 -2
- package/dist/client/assets/{sortable.esm-CHiRbsvI.js → sortable.esm-DdMawn0Y.js} +2 -2
- package/dist/client/assets/{sourceControl-DfhPxa0l.js → sourceControl-U8x7jR8g.js} +2 -2
- package/dist/client/assets/{spinner-rP6J82Of.js → spinner-C6X42yHv.js} +2 -2
- package/dist/client/assets/square-pen-Dew4fHbM.js +1 -0
- package/dist/client/assets/{standalone-page-BkHTM3MP.js → standalone-page-hDUmjFb0.js} +2 -2
- package/dist/client/assets/{stateDiagram-D77RDMKH-UnviM1_a.js → stateDiagram-D77RDMKH-FdsqVfsR.js} +2 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-PvZEFfKe.js +2 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-CpD6LDbC.js → swimlanes-42K2YHIH-D65Z1Od_.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DIDrEY3U.js +9 -0
- package/dist/client/assets/{terminalSessions-C9u_KQdo.js → terminalSessions-DhPFaHUr.js} +2 -2
- package/dist/client/assets/text-search-Cchv2p-9.js +1 -0
- package/dist/client/assets/{textarea-D7qN_9_U.js → textarea-CCFZJhy-.js} +2 -2
- package/dist/client/assets/{themePalette-au2ZXbqB.js → themePalette-CxbxrCEH.js} +3 -3
- package/dist/client/assets/threadSort-TlzPAte9.js +2 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-CNy-4Mtq.js → timeline-definition-24CTP7MA-DrXF0NCa.js} +2 -2
- package/dist/client/assets/toast-B-l3XS_F.js +2 -0
- package/dist/client/assets/{toggle-4i71sOFB.js → toggle-DOFhC9C7.js} +2 -2
- package/dist/client/assets/{toggle-group-BtpeJU3C.js → toggle-group-B1ghB_yR.js} +2 -2
- package/dist/client/assets/tooltip-CYNXW1Ow.js +2 -0
- package/dist/client/assets/{treeView-Q6P3EWNA-fz73DkUg.js → treeView-Q6P3EWNA-D6bZIPSq.js} +1 -1
- package/dist/client/assets/{treemap-WGGIJYW6-CHp0lk61.js → treemap-WGGIJYW6-CJr_vK1t.js} +1 -1
- package/dist/client/assets/{usage-BoYlRHNx.js → usage-1aJeDf79.js} +2 -2
- package/dist/client/assets/{usageAccess-BmfDNhp2.js → usageAccess-9ld15_dP.js} +2 -2
- package/dist/client/assets/{usageFormat-DdjdHqj5.js → usageFormat-D7uBkeaA.js} +2 -2
- package/dist/client/assets/{usageShortcuts-RpypNfqZ.js → usageShortcuts--2waLBa-.js} +2 -2
- package/dist/client/assets/{use-atom-command-Bc7LgQy1.js → use-atom-command-DdGPgtPS.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-B_3SmrJo.js → useAriaLabelledBy-Bp_qmGgf.js} +2 -2
- package/dist/client/assets/{useHandleNewThread-Csguf2GC.js → useHandleNewThread-DtCuKpGU.js} +2 -2
- package/dist/client/assets/{useLocation-DaTcl6iI.js → useLocation-yjRHv-GS.js} +2 -2
- package/dist/client/assets/useNavigate-DfvN7ISg.js +2 -0
- package/dist/client/assets/{useNavigateBack-C43_t49N.js → useNavigateBack-NMRi6phK.js} +2 -2
- package/dist/client/assets/{useParams-s9hrFQQQ.js → useParams-OFLEf5Ub.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-CCpQkKk1.js → usePermissionStatus-D4K04nHy.js} +2 -2
- package/dist/client/assets/usePullRequestActions-DyXuVFpA.js +3 -0
- package/dist/client/assets/{useRegisterFieldControl-BVraoamc.js → useRegisterFieldControl-QWoLGfik.js} +2 -2
- package/dist/client/assets/useScopedModelAvailability-udJ9IYpQ.js +2 -0
- package/dist/client/assets/useSettings-C1hmCYRR.js +3 -0
- package/dist/client/assets/{useT3ConnectAuthPrompt-D3ARnr92.js → useT3ConnectAuthPrompt-NQ5SmnTg.js} +2 -2
- package/dist/client/assets/utils-Nv21__t3.js +37 -0
- package/dist/client/assets/vcsRefInvalidation-CEbBuVCf.js +2 -0
- package/dist/client/assets/{vennDiagram-4TSXK5OY-BBpGz6rf.js → vennDiagram-4TSXK5OY-BJt3j1aO.js} +2 -2
- package/dist/client/assets/{wardley-WFR3VGLG-M4Al1qCV.js → wardley-WFR3VGLG-D_UZZZRB.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-V-_mOkU8.js → wardleyDiagram-VM6X3IG4-gZMVt8-K.js} +2 -2
- package/dist/client/assets/{welcome-Bok5fRqT.js → welcome-BRjof1AW.js} +2 -2
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-CZOR99Bj.js → xychartDiagram-S5SC5T6Z-BwaDo7WT.js} +2 -2
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/dist/AcpMcpStdioBridge-Ch5bMyss.mjs +0 -4
- package/dist/client/assets/ChatGptUsageButton-GxPReM3u.js +0 -2
- package/dist/client/assets/ChatMarkdown-DOdrk8tK.js +0 -65
- package/dist/client/assets/DiffFileTree-D3P47wbG.js +0 -2
- package/dist/client/assets/DiffPanel-cvlTVhB4.js +0 -2
- package/dist/client/assets/ProjectDefaultsSettings-Cu80XFdb.js +0 -2
- package/dist/client/assets/ProjectIconPickerDialog-Dwmv78OH.js +0 -2
- package/dist/client/assets/ScheduledTasksSettings-Cp8h_lNS.js +0 -4
- package/dist/client/assets/ScopedSwitch-CLAFXjj6.js +0 -2
- package/dist/client/assets/WorkspaceBreadcrumb-fx0ZD7ay.js +0 -2
- package/dist/client/assets/WorkspacePageContainer-DFsaHi02.js +0 -2
- package/dist/client/assets/_chat-BerxDjpp.js +0 -58
- package/dist/client/assets/_chat.pull-requests-BwpBKnt3.js +0 -2
- package/dist/client/assets/architecture-7GRP2DOG-CT4QCEL3.js +0 -1
- package/dist/client/assets/arrow-left-BiKrB-pT.js +0 -1
- package/dist/client/assets/arrow-right-DWAwZU0q.js +0 -1
- package/dist/client/assets/arrow-up-down-CfYH5v22.js +0 -1
- package/dist/client/assets/assets-DwywdbuJ.js +0 -2
- package/dist/client/assets/bell-C3RUvq1T.js +0 -1
- package/dist/client/assets/blocks-CoLUV11Q.js +0 -1
- package/dist/client/assets/bot-CjcO3F5G.js +0 -1
- package/dist/client/assets/calendar-clock-CJyS1C-x.js +0 -1
- package/dist/client/assets/channel-kQEwHVv9.js +0 -2
- package/dist/client/assets/chart-no-axes-column-B3ZqbY05.js +0 -1
- package/dist/client/assets/checkbox-Cw_SXlJ5.js +0 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-BO_GIPO1.js +0 -2
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BO_GIPO1.js +0 -2
- package/dist/client/assets/corner-left-up-D653FjvK.js +0 -1
- package/dist/client/assets/device-DrIICsXu.js +0 -2
- package/dist/client/assets/download-CNXPbBhc.js +0 -1
- package/dist/client/assets/dynamic-BRlOHH6g.js +0 -3
- package/dist/client/assets/earth-C1f0Qxwi.js +0 -1
- package/dist/client/assets/ellipsis-0J7zX441.js +0 -1
- package/dist/client/assets/entities-yblphBg3.js +0 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-bjJqzJYE.js +0 -1
- package/dist/client/assets/eye-CmsLgU-5.js +0 -1
- package/dist/client/assets/file-search-ClaIV60V.js +0 -1
- package/dist/client/assets/flowDiagram-HODETNUW-CsPXFMK4.js +0 -1
- package/dist/client/assets/folder-git-2-BxqGR5ht.js +0 -2
- package/dist/client/assets/folder-open-gQZmKQ4n.js +0 -1
- package/dist/client/assets/folder-plus-BVmedEeH.js +0 -1
- package/dist/client/assets/git-branch-Ba9jLbPu.js +0 -1
- package/dist/client/assets/grip-vertical-BmIJSASv.js +0 -1
- package/dist/client/assets/hard-drive-hWUfbbG9.js +0 -1
- package/dist/client/assets/history-jvN7Bdkc.js +0 -1
- package/dist/client/assets/house-ozmwce4p.js +0 -1
- package/dist/client/assets/index-FZqrCEhr.js +0 -3
- package/dist/client/assets/kbd-BR8-VeaN.js +0 -2
- package/dist/client/assets/keyboard-_YjrW4PX.js +0 -1
- package/dist/client/assets/link-BcMcYjHb.js +0 -1
- package/dist/client/assets/list-DEjg_Q5H.js +0 -1
- package/dist/client/assets/main-BQLZB-ZD.css +0 -2
- package/dist/client/assets/main-Ch0n0whg.js +0 -26
- package/dist/client/assets/message-circle-question-mark-DzWFFMDp.js +0 -1
- package/dist/client/assets/message-square-BqGKFtP8.js +0 -1
- package/dist/client/assets/message-square-dashed-FPkUUYSB.js +0 -1
- package/dist/client/assets/messages-square-BNeF2306.js +0 -2
- package/dist/client/assets/number-field-DsVu9T6C.js +0 -2
- package/dist/client/assets/palette-JCVMAFVd.js +0 -1
- package/dist/client/assets/panel-left-STqObAvQ.js +0 -1
- package/dist/client/assets/panels-top-left-B90U_rdS.js +0 -1
- package/dist/client/assets/popover-UOfX8iZ4.js +0 -2
- package/dist/client/assets/primary-BubJSDIO.js +0 -2
- package/dist/client/assets/primaryCloudLinkState-CFnZkCiA.js +0 -2
- package/dist/client/assets/projectScriptEditor-_TwHfcHY.js +0 -2
- package/dist/client/assets/pullRequests-C0Gr2876.js +0 -2
- package/dist/client/assets/queries-DbiotSzd.js +0 -2
- package/dist/client/assets/radio-group-DhxCP5q0.js +0 -2
- package/dist/client/assets/railroad-abnf-HS5TGJTU-DRzBu_EH.js +0 -1
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-BuQh-rCG.js +0 -1
- package/dist/client/assets/railroad-peg-WCYAUIDC-DH1f3-__.js +0 -1
- package/dist/client/assets/rotate-ccw-98iN1bsB.js +0 -1
- package/dist/client/assets/rotate-cw-DdW3sRx4.js +0 -1
- package/dist/client/assets/runtime-BUB2ex14.js +0 -2
- package/dist/client/assets/runtime-BoEmkhOe.js +0 -6
- package/dist/client/assets/scheduledTasksSettings.logic-Bk1lq8Ri.js +0 -3
- package/dist/client/assets/session-CyPECDtf.js +0 -2
- package/dist/client/assets/session-logic-BBZj8pNB.js +0 -13
- package/dist/client/assets/settings-2-C-KVP40_.js +0 -1
- package/dist/client/assets/settings-D62zpRkD.js +0 -1
- package/dist/client/assets/settings.appearance-C-MzWdtB.js +0 -2
- package/dist/client/assets/settings.archived-BZ0wU-2j.js +0 -2
- package/dist/client/assets/settings.connections-B-h_wi7q.js +0 -2
- package/dist/client/assets/settings.diagnostics-ByUhN_HC.js +0 -2
- package/dist/client/assets/settings.general-DodDmaXX.js +0 -2
- package/dist/client/assets/settings.integrations-Dq9yt9c-.js +0 -2
- package/dist/client/assets/settings.projects-Bj9oI9dE.js +0 -4
- package/dist/client/assets/settings.providers-BPb4TbH8.js +0 -3
- package/dist/client/assets/settings.scheduled-tasks-TxnTVd7r.js +0 -2
- package/dist/client/assets/settings.snap-shot-DZaxUAEE.js +0 -2
- package/dist/client/assets/settings.source-control-BlHoYUC0.js +0 -2
- package/dist/client/assets/settingsLayout-De_r3pyr.js +0 -3
- package/dist/client/assets/shield-question-mark-B5w7j5aC.js +0 -1
- package/dist/client/assets/square-pen-DYBPSam-.js +0 -1
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CJW4DyfF.js +0 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Buz7ig8b.js +0 -9
- package/dist/client/assets/text-search-DrO_MCzY.js +0 -1
- package/dist/client/assets/threadSort-R2JvSO3D.js +0 -2
- package/dist/client/assets/toast-CIGvRti2.js +0 -2
- package/dist/client/assets/tooltip-Ciaezkl4.js +0 -2
- package/dist/client/assets/useNavigate-CnhAAl0Z.js +0 -2
- package/dist/client/assets/usePullRequestActions-CiF7znkV.js +0 -3
- package/dist/client/assets/useScopedModelAvailability-kFNRNx2C.js +0 -2
- package/dist/client/assets/useSettings-CNd8OM7A.js +0 -3
- package/dist/client/assets/utils-geC9CGP4.js +0 -37
- package/dist/client/assets/vcsRefInvalidation-DMpp-BNA.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{A as n,E as r,
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{A as n,E as r,Ef as i,Im as a,Jn as o,Kn as s,Lo as c,Qn as l,Wn as u,Xn as d,Zn as f,_s as p,ar as m,ay as h,er as g,hs as _,ln as v,ma as y,or as b,t as x,vs as S,wx as C,xf as w}from"./utils-Nv21__t3.js";import{t as T}from"./chevron-right-NbahR9_s.js";import{t as E}from"./folder-tree-CIpeR87A.js";import{t as D}from"./text-wrap-C8SwAUbc.js";import{I as O,L as k,U as ee}from"./runtime-CxeCZPZ3.js";import{s as te}from"./vcsRefInvalidation-CEbBuVCf.js";import{W as A}from"./entities-B0tFBQjY.js";import{En as j,d as ne,f as re,gn as ie,u as ae,yn as oe}from"./runtime-C9evwoB9.js";import{a as M,c as se,n as N,t as P,u as ce}from"./tooltip-CYNXW1Ow.js";import{$ as le,et as ue,n as F,ot as de}from"./ChatMarkdown-S_dLZdsH.js";import{t as I}from"./spinner-C6X42yHv.js";import{i as fe,m as L}from"./toast-B-l3XS_F.js";import{C as pe,J as me,K as he,O as ge,s as _e,v as ve}from"./useSettings-C1hmCYRR.js";import{i as ye,n as R}from"./session-DZH3pyoG.js";import{t as be}from"./use-atom-command-DdGPgtPS.js";import{a as xe}from"./fileLinks-BBnShh-N.js";import{n as Se}from"./toastHelpers-Dsph6LwL.js";import{o as Ce}from"./queries-BAbZ6wRj.js";import{H as z,V as we,l as Te,ot as Ee,st as De}from"./diffRendering-DVfiIxj4.js";import{A as Oe,B as ke,G as B,K as Ae,T as je,a as Me,j as V,l as Ne,t as Pe}from"./Virtualizer-DItXd38b.js";import{B as H,G as Fe,H as Ie,J as Le,K as Re,Q as ze,U as Be,V as Ve,W as He,q as Ue}from"./getDiffFileInput-D0WCXPuc.js";import{c as We,i as Ge,n as Ke,o as qe,s as Je,t as Ye}from"./DiffWorkerPoolProvider-HxohyeGq.js";import{n as Xe}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{S as Ze,_ as Qe,b as $e,c as et,d as tt,f as nt,g as rt,h as U,i as it,l as at,m as W,o as ot,p as st,r as ct,s as G,t as lt,u as K,v as ut,x as dt,y as ft}from"./DiffCommentAnnotation-BO9ZEof3.js";import{t as pt}from"./mediaReference-o1DLUGKI.js";import{i as mt,n as ht,r as gt,t as _t}from"./fileCommentAnnotations-BgdL_7u9.js";import{r as vt,t as yt}from"./ReadOnlySourcePreview-DkXxXiTJ.js";import{a as bt,c as xt,i as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt}from"./fileTreeExpansion-DaFd8SRp.js";import{t as Ot}from"./pierre-icons-BVuUNHGs.js";import{t as kt}from"./scroll-area-CRoS-lxP.js";import{A as At,C as jt,E as Mt,O as Nt,S as Pt,T as Ft,_ as It,b as Lt,j as Rt,w as zt,x as Bt,y as Vt}from"./ComposerPromptEditor-CTei4iV_.js";import{t as Ht}from"./assets-CLIqG-m-.js";import{i as Ut,l as Wt,o as Gt,r as Kt,s as qt}from"./openFileInPreview-BuKYchiT.js";import{w as Jt}from"./browserHistoryStore-D6dhsqE8.js";import{t as Yt}from"./preview-8KYmxrad.js";import{t as Xt}from"./PierreEntryIcon-uqPwKknu.js";import{r as Zt,t as Qt}from"./input-group-CV0ZpOg5.js";import{a as $t,c as en,d as tn,i as nn,l as rn,n as an,t as on}from"./projectFilesQueryState-DmDFr3yJ.js";import{Na as sn,Ra as cn,Vo as ln,ka as un,ss as dn}from"./main-CJvawsJJ.js";import{M as fn,O as pn,g as mn,h as hn,m as gn,p as _n}from"./_chat-B4G7pIId.js";var vn={compositeOverBg:H,contrastRatio:Ve,deriveMutedFg:Ie,hoverWouldEraseText:Be,isDarkSurface:He,isFullyTransparent:Fe,pickReadableForeground:Re,relativeLuminance:Ue,surfacesMatch:Le},q=e(t(),1);function yn(e,t){return e.isOpen===t.isOpen&&e.value===t.value&&bt(e.matchingPaths,t.matchingPaths)}function bn(e){let t=wt(e,e=>({isOpen:e.isSearchOpen(),matchingPaths:e.getSearchMatchingPaths(),value:e.getSearchValue()}),yn);return(0,q.useMemo)(()=>({...t,close:()=>{e.closeSearch()},focusNextMatch:()=>{e.focusNextSearchMatch()},focusPreviousMatch:()=>{e.focusPreviousSearchMatch()},open:t=>{e.openSearch(t)},setValue:t=>{e.setSearch(t)}}),[e,t])}var xn=100,Sn=`insert`,Cn=`backspace`,wn=`delete`,Tn=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??xn)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(Dn),redoStack:this.#t.map(Dn),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function En(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(On),selectionsAfter:e.selectionsAfter?.map(On),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function Dn(e){return{...En(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function On(e){return{...e,start:{...e.start},end:{...e.end}}}function kn(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?Cn:n?wn:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function An(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=Nn(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
|
|
2
2
|
`)&&!a.text.includes(`
|
|
3
3
|
`),u=o.start===o.end&&o.text.length>0&&!o.text.includes(`
|
|
4
4
|
`)&&s.text.length===0;if(l&&u){if(o.start!==a.end||(n??=Sn,n!==Sn||e.coalescingMode!==void 0&&e.coalescingMode!==Sn||t.coalescingMode!==void 0&&t.coalescingMode!==Sn))return!1;continue}let d=i.text.length===0&&i.end>i.start&&a.text.length>0,f=o.text.length===0&&o.end>o.start&&s.text.length>0;if(d&&f){let r;if(c===i.end)r=wn;else if(c+(o.end-o.start)!==i.start)return!1;else r=Cn;if(n??=r,n!==r||e.coalescingMode!==void 0&&e.coalescingMode!==r||t.coalescingMode!==void 0&&t.coalescingMode!==r)return!1;continue}return!1}return n!==void 0}function jn(e,t){let n=[],r=[],i;for(let a=0;a<e.forwardEdits.length;a++){let o=e.forwardEdits[a],s=e.inverseEdits[a],c=t.forwardEdits[a],l=t.inverseEdits[a],u=Nn(c.start,e.forwardEdits);if(o.text.length>0){i??=Sn,n.push({start:o.start,end:o.end,text:o.text+c.text}),r.push(s.text);continue}if(u===o.end){i??=wn,n.push({start:o.start,end:u+(c.end-c.start),text:``}),r.push(s.text+l.text);continue}i??=Cn,n.push({start:Math.min(o.start,u),end:o.end,text:``}),r.push(l.text+s.text)}return{forwardEdits:n,inverseEdits:Mn(n,r),versionBefore:e.versionBefore,versionAfter:t.versionAfter,selectionsBefore:e.selectionsBefore?.slice(),selectionsAfter:t.selectionsAfter?.slice(),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:t.lineAnnotationsAfter?.slice(),coalescingMode:i}}function Mn(e,t){let n=[];for(let r=0,i=0;r<e.length;r++){let a=e[r],o=a.start+i;n.push({start:o,end:o+a.text.length,text:t[r]}),i+=a.text.length-(a.end-a.start)}return n}function Nn(e,t){let n=e;for(let e of t){let t=e.end-e.start,r=e.text.length,i=r-t;if(!(n<e.start)){if(n>=e.start+r){n-=i;continue}n=e.start+Math.min(n-e.start,t)}}return n}var Pn=new WeakMap;function Fn(e){return Pn.get(e)}function In(e,t){Pn.set(e,t)}var Ln=class e{#e;#t;#n;#r;#i;#a;constructor(e,t,n=`text`,r=0,i=new Tn,a){if(this.#e=new URL(e,`file://`).toString(),this.#t=n,this.#n=r,this.#r=new ut(t),this.#i=i,a!=null)this.#a=a;else{let e=this.#r.getLineText(0,!0);this.#a=e.endsWith(`\r
|
|
@@ -20,7 +20,7 @@ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19
|
|
|
20
20
|
--diffs-editor-info-fg: ${g??`initial`};
|
|
21
21
|
--diffs-editor-warning-fg: ${_??`initial`};
|
|
22
22
|
--diffs-editor-error-fg: ${v??`initial`};
|
|
23
|
-
}`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!za(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??z;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??z;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1;continue}b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!za(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(za(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=La(this.#t,this.#a,n,t,Pa,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??z;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=La(this.#t,this.#a,e,a,Pa,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);if(!(this.#b||this.#x||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#y=this.#h.length-1,this.#z(e)}}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??z,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=La(this.#t,this.#a,r,o,Pa,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e);return}this.#y=a,this.#D=c,this.#z(e)}}};function La(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=we.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&we.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ra(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?U(`br`):n:U(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function za(e){return e===`text`||e===`ansi`}function Ba(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Va(e,t){let n=qe(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Ha(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var Ua=2,Wa=1e4,Ga=300,Ka=256,qa=131072,Ja=new TextEncoder,Ya=`selection-action`,Xa=`application/vnd.pierre.diffs-selections+json`,Za=class{type;#e;#t;#n;#r=new ka;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ra(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=Qa({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Gn.releaseFile(a,t):Gn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=Fr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Hn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return Un(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return X(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(Y(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);if(e.length===0){this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[]);return}this.#U??=new Di({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt()}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,B(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Hn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Gn.releaseFile(t,n):Gn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:ji(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??dn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Va(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new Tn({maxEntries:this.#e.historyMaxEntries});n=new Ln(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Ia({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=nt(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=Fr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Ha(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new Kn({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(B(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,Ae(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return rt(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=U(`style`,{dataset:`editorGlobalCss`,textContent:`
|
|
23
|
+
}`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!za(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??z;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??z;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1;continue}b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!za(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(za(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=La(this.#t,this.#a,n,t,Pa,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??z;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=La(this.#t,this.#a,e,a,Pa,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);if(!(this.#b||this.#x||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#y=this.#h.length-1,this.#z(e)}}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??z,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=La(this.#t,this.#a,r,o,Pa,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e);return}this.#y=a,this.#D=c,this.#z(e)}}};function La(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=we.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&we.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ra(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?U(`br`):n:U(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function za(e){return e===`text`||e===`ansi`}function Ba(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Va(e,t){let n=qe(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Ha(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var Ua=2,Wa=1e4,Ga=300,Ka=256,qa=131072,Ja=new TextEncoder,Ya=`selection-action`,Xa=`application/vnd.pierre.diffs-selections+json`,Za=class{type;#e;#t;#n;#r=new ka;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ra(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=Qa({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Gn.releaseFile(a,t):Gn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=Fr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Hn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return Un(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return X(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(Y(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);if(e.length===0){this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[]);return}this.#U??=new Di({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt()}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,B(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Hn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Gn.releaseFile(t,n):Gn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:ji(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??sn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Va(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new Tn({maxEntries:this.#e.historyMaxEntries});n=new Ln(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Ia({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=nt(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=Fr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Ha(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new Kn({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(B(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,Ae(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return rt(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=U(`style`,{dataset:`editorGlobalCss`,textContent:`
|
|
24
24
|
[data-annotation-slot] {
|
|
25
25
|
user-select: none;
|
|
26
26
|
-webkit-user-select: none;
|
|
@@ -28,7 +28,7 @@ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19
|
|
|
28
28
|
`}),this.#y=U(`style`,{dataset:`editorCss`,textContent:ct}),this.#b=U(`style`,{dataset:`editorThemeCss`}),this.#x=ot(),this.#E=U(`div`,{dataset:`editorOverlay`});let e=e=>{let t=e.composedPath()[0];return t instanceof Node&&this.#w?.contains(t)===!0},t=()=>{this.#Z!=null&&(this.#Z=void 0,this.#X=!1,this.#J=!1)},n=e=>{if(e.pointerType!==`mouse`)return;let t=this.#$;this.#Ke(),t&&this.#ut(),this.#e.enabledSelectionAction===!0&&this.#se!==void 0&&this.#se.length>0&&!J(this.#se.at(-1))&&this.#Wt(this.#se)};this.#s=[G(document,`focusin`,n=>{e(n)||t()},{passive:!0}),G(document,`pointerdown`,n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),G(document,`selectionchange`,()=>{let e=this.#S?.shadowRoot;if(this.#J||this.#Y||e==null||!this.#X||this.#se!==void 0&&this.#se.length>1&&!this.#ee)return;let t=document.getSelection();if(t==null)return;let n;if(n=typeof t.getComposedRanges==`function`?t.getComposedRanges({shadowRoots:[e]})?.[0]:Ba(e),n===void 0||!this.#Cn(n))return;let r=ur(n,0);if(r!==void 0){if(this.#ee&&this.#ne&&this.#se!==void 0&&this.#se.length>0){let e=this.#se.at(-1);this.#Wt([Lr(e,r)]);return}if(this.#re!==void 0)r.direction=Ir(this.#re,r).direction;else if(this.#ee)this.#re=r;else if(this.#se!==void 0&&this.#se.length===1){let e=this.#se[0];X(e.start,r.start)===0&&X(e.end,r.end)===0&&(r.direction=e.direction)}this.#te!==void 0&&(this.#te.focusLine=Y(r).line,this.#kt())||(this.#ae===void 0?this.#Wt([r]):this.#Wt([...this.#ae.filter(e=>!Mr(e,r)),r]))}},{passive:!0}),G(document,`pointerup`,n,{passive:!0}),G(document,`pointercancel`,n,{passive:!0}),G(document,`keydown`,e=>{e.key===`Shift`?this.#re=this.#se?.at(-1):e.key===`Alt`&&!e.repeat&&this.#X&&this.#e.editPrediction?.mode===`subtle`&&(this.#ye=!this.#ye,this.#Wt(this.#se??[]))},{passive:!0}),G(document,`keyup`,e=>{e.key===`Shift`&&(this.#re=void 0)},{passive:!0})]}#Ke(){this.#c?.forEach(e=>e()),this.#c=void 0,this.#J=!1,this.#$=!1,this.#ee=!1,this.#te=void 0,this.#ne=!1,this.#re=void 0,this.#ae=void 0}#qe(e){this.#c?.forEach(e=>e()),this.#c=e}#Je(){return this.#M?.options.enableLineSelection===!0}#Ye(){this.#Y=this.#se!==void 0}#Xe(e,t){let{onFocus:n,onBlur:r}=this.#e,i=t=>{let n=t.composedPath()[0];return n!==void 0&&(n===e||e.contains(n))};this.#o?.forEach(e=>e()),this.#o=[G(e,`focus`,()=>{this.#X=!0,n?.(),!this.#ee&&!this.#J&&this.#se!==void 0&&this.#se.length>0&&this.#ht(this.#se.at(-1))},{passive:!0}),G(e,`blur`,()=>{this.#Z?.target===e&&(this.#Z=void 0,this.#J=!1),this.#X=!1,r?.()},{passive:!0}),G(e,`pointerdown`,t=>{if(this.#q=!0,this.#Y=!1,t.pointerType!==`mouse`)return;if(this.#te=void 0,this.#bt(t)){this.#Et(!0),this.#se!==void 0&&this.#Wt([]);return}this.#Et(!1),this.#U?.removePopover();let n=[];if(je()&&this.#R!==void 0&&this.#R.length>0){let t=[...e.querySelectorAll(`[data-line-annotation]`)].map(e=>[G(e,`mouseenter`,()=>{this.#J=!0}),G(e,`mouseleave`,()=>{this.#J=!1})]).flat();n.push(...t)}this.#ee=!0;let r=t.button===0&&t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(this.#re=void 0,r?(this.#te={pointerId:t.pointerId,startClientX:t.clientX,clientX:t.clientX,startScrollLeft:e.parentElement?.scrollLeft??0},this.#ae=void 0,this.#se=void 0,this.#Wt([]),n.push(G(document,`pointermove`,e=>{let t=this.#te;t!==void 0&&e.pointerType===`mouse`&&e.pointerId===t.pointerId&&(t.clientX=e.clientX,this.#kt())},{capture:!0,passive:!0}))):t.button===0&&Ze(t)&&(this.#ae=this.#se?.map(e=>({...e}))),this.#qe(n),t.shiftKey){let e=this.#se?.at(-1);if(e!==void 0){let t=e.direction===-1?e.end:e.start;this.#ht({start:t,end:t,direction:0})}this.#ne=!0}},{passive:!0}),G(e,`keydown`,e=>{if(!i(e)||(this.#q=!0,this.#Y=!1,e.isComposing||e.keyCode===229))return;if(e.key===`Tab`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&!this.#Q&&(!e.altKey||this.#e.editPrediction?.mode===`subtle`)&&this.#xe?.rendered===!0){this.#Ht(),e.preventDefault();return}if(e.key===`Escape`&&this.#xe!==void 0){this.#Rt(!0),e.preventDefault();return}let t=ft(e,this.#e.keymap);if(t!==void 0){e.preventDefault(),t===`simplifySelection`&&(this.#G?.close(),this.#G=void 0,this.#pe=!1,this.#K?.cleanup(),this.#K=void 0),this.#et(t);return}let n=dt(e),r=this.#n?.document;if(this.#se!==void 0&&this.#se.length>0&&n!==void 0&&r!==void 0){let t={getSoftLineOffsets:this.#Le?e=>this.#Sn(e):void 0,resolveRenderableLine:this.#Ne};e.shiftKey?this.#Wt(vr(r,this.#se,n,t)):this.#Wt(fr(r,this.#se,n,t)),this.#gt(),e.preventDefault();return}if((e.key.length===1?e.key.toLowerCase():e.key)===`v`&&Ze(e)){if(e.repeat&&this.#Ie){e.preventDefault();return}if(this.#e.clipboard!==void 0){e.preventDefault(),Ae(this.#Ze);return}}if(this.#G!==void 0){let t=$e(e);if(t!==void 0){e.preventDefault(),this.#G.navigate(t===`previous`);return}}}),G(e,`copy`,e=>{i(e)&&(e.preventDefault(),this.#wt()?e.clipboardData?.setData(`text`,this.#Tt()):this.#nn(e.clipboardData,this.#en(),this.#tn()))}),G(e,`cut`,e=>{if(i(e)){if(e.preventDefault(),this.#wt())e.clipboardData?.setData(`text`,this.#Tt());else{let t=this.#tn();this.#nn(e.clipboardData,this.#rn(),t)}}}),G(e,`paste`,e=>{if(!i(e))return;e.preventDefault();let t=e.clipboardData,n=this.#n?.document;if(t===null||n===void 0)return;let r=t.getData(`text`),a=this.#se?.length??0;if(a>1){let e=t.getData(Xa);if(e!==void 0)try{let t=JSON.parse(e);Array.isArray(t)&&t.length===a&&(r=t)}catch{}}this.#an(Array.isArray(r)?r.map(e=>n.normalizeEol(e)):n.normalizeEol(r),void 0,!0,`document`)}),G(e,`beforeinput`,e=>{if(i(e)){if(e.inputType===`insertCompositionText`){this.#Rt(!0);return}e.preventDefault(),this.#lt(e.inputType,e.data)}}),G(e,`drop`,e=>{i(e)&&e.preventDefault()}),G(e,`compositionstart`,e=>{i(e)&&(this.#Rt(!0),this.#Q=!0,this.#J=!0)},{passive:!0}),G(e,`compositionend`,e=>{if(!i(e))return;this.#J=!1;let t=this.#Q;this.#Q=!1,(e.data!==``||!t)&&this.#lt(`insertText`,e.data)},{passive:!0})];let a=this.#S?.shadowRoot?.querySelector(`[data-deletions]`);if(a!=null&&this.#o.push(G(a,`pointerdown`,e=>{let t=e.composedPath();if(ke(t)){this.#Ye();return}let n=t[0],r=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(r instanceof HTMLElement){if(this.#Je()){this.#Ye();return}if(this.#Ct(r,a,e.pointerType===`mouse`))return}this.#Et(!0),this.#se!==void 0&&this.#Wt([])},{passive:!0})),t!==void 0){let e=(e,t=!1)=>{let n=e;return n?.dataset.lineNumberContent===void 0?t&&n?.tagName===`SPAN`&&(n=n.closest(`[data-line]`)):n=n.parentElement??void 0,n},n=e=>{if(e===void 0)return;let t=e.dataset.lineType,n=W(e)??W(e,`columnNumber`);if(n!==void 0&&t!==void 0&&jr(t))return n-1};this.#o.push(G(t,`pointerdown`,t=>{let r=t.composedPath();if(ke(r)){this.#Ye();return}let i=e(r[0]);if(i!==void 0&&this.#Je()){this.#Ye();return}if(i?.dataset.lineType===`change-deletion`){let e=i.closest(`[data-code]`);e!=null&&this.#Ct(i,e,t.pointerType===`mouse`);return}if(t.pointerType!==`mouse`)return;let a=this.#n?.document,o=n(i);if(o===void 0||a===void 0)return;this.#q=!0,this.#U?.removePopover();let s=this.#yt(o,o,a);this.#$=!0,this.#re=s,this.#Wt([s]),this.#ht(s),this.#ut(),this.#qe([G(document,`mousemove`,t=>{if(!this.#$)return;let r=this.#n?.document,i=n(e(t.composedPath()[0],!0));if(i===void 0||r===void 0)return;let a=this.#re?.start.line??i,o=this.#yt(a,i,r);this.#re??=o,this.#Wt([o]),this.#ut(o.direction===-1?o.start:o.end)},{passive:!0})])},{passive:!0}))}this.#U?.listenHover(e),this.#j?.disconnect(),this.#j=new ResizeObserver(this.#ot),this.#j.observe(e),this.#j.observe(e.parentElement),this.#Qe(e)}#Ze=async()=>{let e=this.#e.clipboard;if(e!==void 0){let t=await e.readText(),n=this.#se?.length??0;if(n>1){let r=await e.readText(Xa);try{let e=JSON.parse(r);Array.isArray(e)&&e.length===n&&(t=e)}catch{}}let r=this.#n?.document;r!=null&&this.#an(Array.isArray(t)?t.map(e=>r.normalizeEol(e)):r.normalizeEol(t),void 0,!0,`document`)}};#Qe(e){this.#Ie&&this.#Fe===`split`&&this.#Le&&(this.#d={top:e.offsetTop-this.#r.paddingTop,left:e.offsetLeft-this.#_n()},this.#e.__debug===!0&&console.log(`[diffs/editor] content offset:`,this.#d))}get#$e(){if(this.#Ie&&this.#Fe===`split`&&this.#Le)return this.#d}#et(e){let t=this.#n?.document;if(t!=null)switch(e){case`openSearchPanel`:this.#Qt(`find`);break;case`openSearchReplacePanel`:this.#Qt(`replace`);break;case`findNextMatch`:{let e=this.#se;if(e===void 0)break;if(e.some(J)){let n=e.map(e=>J(e)?ti(t,e):e);this.#Wt(n),this.focus()}else{let n=Hr(t,e);if(n!==void 0){this.#Wt(n);let e=n.at(-1);e!==void 0&&this.#Pe(Y(e).line),this.#gt()}}break}case`moveLineUp`:case`moveLineDown`:this.#at(e===`moveLineUp`?-1:1);break;case`copyLineUp`:case`copyLineDown`:this.#rt(e===`copyLineUp`?-1:1);break;case`simplifySelection`:{let e=this.#se,t=e?.at(-1);if(e===void 0||t===void 0)break;if(e.length>1)this.#Wt([t]),this.#ut(Y(t));else if(!J(t)){let e=Y(t);this.#Wt([{start:e,end:e,direction:0}]),this.#ut(e)}break}case`insertBlankLine`:this.#it();break;case`deleteHardLineForward`:this.#ln();break;case`toggleComment`:case`toggleBlockComment`:{let n=this.#se;if(n===void 0)break;let{lineComment:r,blockComment:i}=ia(t.languageId,this.#e.languageCommentConfig);if(e===`toggleComment`&&r!==null){this.#nt(aa(t,n,r));break}let a=e===`toggleComment`,o=la(t,n,i,a);o!==void 0&&this.#nt(o.edits,a?void 0:e=>o.nextSelectionOffsets.map(([t,n,r])=>({start:e.positionAt(t),end:e.positionAt(n),direction:r})));break}case`indent`:case`outdent`:case`indentLess`:case`indentMore`:if(this.#se!==void 0){let n=[],r=[],i=new Set,a=[];for(let o of this.#se){let s=o.start.line,c=e===`outdent`||e===`indentLess`,l=e===`indentLess`||e===`indentMore`;if(s!==o.end.line||c||l){let e=dr(t,o,this.#r.tabSize,c);for(let t of e[0]){let e=t.range.start.line;i.has(e)||(i.add(e),n.push(t))}r.push(e[1])}else{let e=t.charAt({line:s,character:0})===` `?` `:` `.repeat(this.#r.tabSize);n.push({range:o,newText:e}),a.push({line:s,startCharacter:o.start.character,addedLength:e.length-(o.end.character-o.start.character),selectionIndex:r.length});let i={line:o.start.line,character:o.start.character+e.length};r.push({start:i,end:i,direction:0})}}for(let e of a){let t=0;for(let n of a)n.line===e.line&&n.startCharacter<e.startCharacter&&(t+=n.addedLength);if(t!==0){let n=r[e.selectionIndex],i={line:e.line,character:n.start.character+t};r[e.selectionIndex]={start:i,end:i,direction:0}}}let o=t.applyEdits(n,!0,this.#se,r);o!==void 0&&this.#dn(o,r)}break;case`selectAll`:{let e=Ur(t);this.#Wt([e]),this.focus();let n=this.#mn(),r=n[0]?.[0],i=n.at(-1)?.[1];r!==void 0&&i!==void 0&&(this.#Y=!0,this.#ht({start:{line:r,character:0},end:{line:i,character:t.getLineLength(i)},direction:1}));break}case`moveCursorToDocStart`:case`moveCursorToDocEnd`:{let n=Wr(t,e===`moveCursorToDocEnd`,this.#Ie);this.#Wt([n]),this.#Pe(Y(n).line),this.#gt()}break;case`expandSelectionDocStart`:case`expandSelectionDocEnd`:{let n=e===`expandSelectionDocEnd`,r=this.#se;if(r!==void 0){let e=Wr(t,n,this.#Ie);this.#Wt(Rr(r,e)),this.#Pe(Y(e).line),this.#gt()}}break;case`undo`:case`redo`:this.#tt(e)}}#tt(e){let t=this.#n?.document;if(t==null||e===`undo`&&!t.canUndo||e===`redo`&&!t.canRedo)return;let n=this.#se,r=n?.map(e=>[t.offsetAt(e.start),t.offsetAt(e.end)]),i=e===`undo`?t.undo():t.redo();if(i===void 0)return;let[a,o,s,c]=i,l=o??(n!==void 0&&r!==void 0&&c!==void 0?Fr(t,n,r,c):void 0),u=s??(this.#R==null?void 0:Yn(a,this.#R));this.#dn(a,l,u)}#nt(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0)return;let i=t===void 0,a=i?r.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]):void 0,o=i?e.map(e=>{let t=n.offsetAt(e.range.start),r=n.offsetAt(e.range.end);return{start:Math.min(t,r),end:Math.max(t,r),text:e.newText}}).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n}):void 0,s=n.applyEdits(e,!0,r,void 0,!0);if(s===void 0)return;let c=i?Fr(n,r,a,o):t(n);n.setLastUndoSelectionsAfter(c),this.#dn(s,c,this.#pn(s))}#rt(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Br(n);if(r.length===0)return;let i=[],a=0,o=[];for(let n of r){i.push(a);let r=n.endLine-n.startLine+1;a+=r;let s=t.getText({start:{line:n.startLine,character:0},end:{line:n.endLine,character:t.getLineLength(n.endLine)}});if(e>0){let e={line:n.startLine,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else if(n.endLine<t.lineCount-1){let e={line:n.endLine+1,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else{let e={line:n.endLine,character:t.getLineLength(n.endLine)};o.push({range:{start:e,end:e},newText:t.eol+s})}}let s=n.map(t=>{let n=t.start.line,a=0,o=r.length-1;for(;a<=o;){let e=a+o>>>1,t=r[e];if(n<t.startLine)o=e-1;else if(n>t.endLine)a=e+1;else{a=e;break}}let s=Math.max(0,a<=o?a:o),c=r[s],l=i[s]+(e>0?c.endLine-c.startLine+1:0);return{start:{...t.start,line:t.start.line+l},end:{...t.end,line:t.end.line+l},direction:t.direction}});this.#nt(o,()=>s)}#it(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0)return;let n=t.map(e=>Y(e).line),r=Array.from(new Set(n)).sort((e,t)=>e-t),i=new Map,a=new Map,o=[];for(let t=0;t<r.length;t++){let n=r[t],s=e.getLineText(n),c=/^\s*/.exec(s)?.[0]??``;i.set(n,t),a.set(n,c);let l={line:n,character:e.getLineLength(n)};o.push({range:{start:l,end:l},newText:e.eol+c})}let s=t.map((e,t)=>{let r=n[t],o={line:r+1+i.get(r),character:a.get(r).length};return{start:o,end:o,direction:0}});this.#nt(o,()=>s)}#at(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=Br(n);if(r.length===0||e<0&&r[0].startLine===0||e>0&&r.at(-1).endLine>=t.lineCount-1)return;let i=t.lineCount,a=e=>e<i-1?{line:e+1,character:0}:{line:e,character:t.getLineLength(e)},o=(e,n)=>{let r=e.map(e=>t.getLineText(e)).join(t.eol);return n?r+t.eol:r},s=[];if(e<0)for(let e of r){let t=e.startLine-1,n=[];for(let t=e.startLine;t<=e.endLine;t++)n.push(t);s.push({range:{start:{line:t,character:0},end:a(e.endLine)},newText:o([...n,t],e.endLine<i-1)})}else for(let e=r.length-1;e>=0;e--){let t=r[e],n=t.endLine+1,c=[];for(let e=t.startLine;e<=t.endLine;e++)c.push(e);s.push({range:{start:{line:t.startLine,character:0},end:a(n)},newText:o([n,...c],n<i-1)})}let c=r.at(-1),l=e>0&&c.endLine===i-2?t.getLineLength(c.endLine):t.getLineLength(i-1),u=n.map(n=>Vr(n,e,i,e=>e===i-1?l:t.getLineLength(e))),d=t.applyEdits(s,!0,n,u,!0);d!==void 0&&this.#dn(d,u)}#ot=()=>{let e=this.#R?.length??0,t=this.#f,n=this.#p;this.#f=void 0,this.#p=void 0;let r=this.#_n()!==t,i=this.#vn()!==n;(r||i)&&(this.#g.clear(),this.#_=void 0,this.#r.clearTextWidthCache(),i&&(this.#h.clear(),(this.#Le||e>0)&&this.#m.clear()),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&(this.#Wt(this.#se??[]),this.#se!==void 0&&this.#X&&this.focus()),this.#U?.removePopover(),this.#Qe(this.#w),this.#Gt())};#st(){if(this.#me)return;let e=document.fonts;e!==void 0&&(this.#me=!0,e.ready.then(()=>{this.#w!==void 0&&this.#r.remeasureCharacterWidth()&&(this.#f=void 0,this.#p=void 0,this.#ze(),this.#h.clear(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#U?.removePopover())}))}#ct(e,t,n=this.#V,r){let i=this.#i,a=this.#M,o=this.#N,s=this.#n?.document,c=this.#C,l=this.#w;if(i==null||a==null||o==null||s==null||l==null)return;i.stopBackgroundTokenize();let u=performance.now(),d=i.tokenize(e,n,!this.#Ie&&this.#je!=null),f=performance.now();if(d.size>0){let e=l.children,t=new Set;for(let e of d.keys())this.#Me(e)&&t.add(e);for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=W(r),n=r.dataset.lineType;if(e===void 0||n===`change-deletion`)continue;let i=e-1;if(t.has(i)){let e=d.get(i);if(r.replaceChildren(...Ra(e)),t.delete(i),t.size===0)break}}}if(t.size>0){let n=0;for(let t=e.length-1;t>=0;t--){let r=e[t],i=W(r);if(i!==void 0&&r.dataset.lineType!==`change-deletion`){n=i;break}}for(let e of t){if(e<n)continue;let t=d.get(e),r=String(e+1);U(`div`,{dataset:{line:r,lineType:`context`,lineIndex:e.toString()},children:Ra(t)},l),c!==void 0&&U(`div`,{dataset:{lineType:`context`,columnNumber:r,lineIndex:e.toString()},children:[U(`span`,{dataset:{lineNumberContent:``},textContent:r})]},c)}}}if(e.lineDelta<0)for(let t of[l.children,c?.children??[]])for(let n=t.length-1;n>=0;n--){let r=t[n],i=W(r)??W(r,`columnNumber`),a=r.dataset.lineType;if(i!==void 0&&a!==`change-deletion`){if(i-1<e.lineCount)break;r.remove()}}let p=e.lineDelta!==0;if(p){let e=l.children.length;for(let t of l.children){let{bufferSize:n}=t.dataset;n!==void 0&&(e+=parseInt(n)-1)}l.style.gridRow=`span `+e,c!==void 0&&(c.style.gridRow=`span `+e)}a.updateRenderCache(d,i.themeType,{shouldRefreshDiffsView:this.#Ie&&!p,lineCountChangeInFlight:p,changedDocumentLines:this.#Ie&&!p?ea(s,e):void 0,documentLineCount:s.lineCount}),p&&o(s,t,r,String(e.previousLineCount).length===String(e.lineCount).length?e.startLine:0),(p||this.#Ie&&this.#Fe===`unified`)&&this.#ze(),t!=null&&(this.#R=t,(!this.#Ie||!p)&&tr(t,l,c,a.getAnnotationSlotName)),this.#Gt(),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${Qe(performance.now()-f)}ms,`,`tokenize in: ${Qe(f-u)}ms (${d.size} dirty lines)`)}#lt(e,t){switch(e){case`insertText`:{let e=t??``,n=this.#n?.document,r=this.#se,i=n!==void 0&&r!==void 0?wr(n,r,e,this.#e.autoSurround):void 0;this.#an(i??e);break}case`insertCompositionText`:break;case`insertLineBreak`:case`insertParagraph`:this.#an(this.#n?.document?.eol??`
|
|
29
29
|
`);break;case`deleteContentBackward`:this.#on();break;case`deleteContentForward`:this.#on(!0);break;case`deleteSoftLineBackward`:case`deleteHardLineBackward`:this.#sn();break;case`deleteWordBackward`:this.#cn();break;case`insertTranspose`:this.#un();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t)}}#ut(e,t=!0,n){this.#X=!0,e===void 0?n?.()===!1?this.#X=!1:this.#w?.focus({preventScroll:t}):(this.#J=!0,this.#ht({start:e,end:e,direction:0}),Ae(()=>{if(n?.()===!1||!this.#X){this.#J=!1;return}this.#w?.focus({preventScroll:t}),Ae(()=>{this.#J=!1})}))}#dt(e){let t=this.#Z;if(t==null)return;if(this.#pe){this.#Z=void 0,this.#X=!1,this.#J=!1;return}let n=this.#w;if(n==null||!this.#ft(n)){this.#Z=void 0,this.#X=!1;return}let r=()=>{if(this.#Z!==t)return!1;let e=this.#ft(n);return this.#Z=void 0,e};if(e!=null){this.#ut(e,!0,r);return}let i=this.#se?.at(-1);if(i==null){this.#ut(void 0,!0,r);return}let a=i.direction===-1?i.end:i.start;this.#ut(a,!0,r)}#ft(e){let t=this.#S,n=t?.shadowRoot;if(t==null||n==null||this.#w!==e||!n.contains(e))return!1;let{activeElement:r}=n;if(r===e||r!=null&&e.contains(r))return!0;if(r!=null)return!1;let{ownerDocument:i}=t,{activeElement:a}=i;return a==null||a===i.body||a===i.documentElement||a===t}#pt(e=0){let t=this.#w,n=this.#S;if(this.#n?.document==null||t==null||n==null)return;let r=this.#Ue();if(r===void 0)return;let i,a;if(r instanceof HTMLElement){let e=r.getBoundingClientRect();i=e.top,a=e.bottom}else i=0,a=r.defaultView?.innerHeight??0;let o=n.shadowRoot?.querySelector(`[data-diffs-header][data-sticky]`);if(o!=null&&(i=Math.max(i,o.getBoundingClientRect().bottom)),Number.isFinite(e)&&(i+=Math.max(0,e)),!(a<=i))for(let e of t.children){let t=e,n=W(t),r=t.dataset.lineType;if(n==null||r==null||!jr(r))continue;let o=t.getBoundingClientRect();if(!(o.bottom<=o.top)&&o.top>=i&&o.top<a)return n}}#mt(e,t){let n={start:e,end:e,direction:0};this.#q=!1,this.#Wt([n]),this.#Pe(e.line),t?this.#ut(e,!0):this.#gt()}#ht(e){let t=window.getSelection();if(t===null)return;let{start:n,end:r,direction:i}=e;X(n,r)>0&&([n,r]=[r,n]);let a=this.#gn(n.line),o=this.#gn(r.line);if(a===void 0||o===void 0)return;let[s,c]=ei(a,n.character),[l,u]=ei(o,r.character);i===-1&&([s,c,l,u]=[l,u,s,c]);try{t.setBaseAndExtent(s,et(s,c),l,et(l,u))}catch(e){console.error(`[diffs/editor] failed to update window selection:`,e)}}#gt(e=!1,t=`nearest`){let n=this.#se?.at(-1);if(n===void 0)return;let r=this.#A;if(r!==void 0){if(r.scrollIntoView({block:t,inline:`nearest`}),!e){let e=n.direction===-1?n.end:n.start;this.#Z===void 0?this.#ut(e):this.#dt(e)}}else{let t=Y(n);this.#vt(t.line,t.character,e)}}#_t(){let e=this.#G===void 0?0:48,t=this.#_n()+this.#r.ch;return`${e}px ${this.#r.ch}px 0 ${t}px`}#vt(e,t=0,n=!1){this.__postponeBgTokenizeToNextFrame();let r=U(`div`,{style:{position:`absolute`,left:`0`,width:`2px`,height:this.#r.lineHeight+`px`,scrollMargin:this.#_t()}});if(this.#gn(e)!==void 0){let[i,a]=this.#bn(e,t),o=this.#yn(e)+a*this.#r.lineHeight;if(r.style.top=o+`px`,r.style.left=i+`px`,this.#E?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),!n){let n={line:e,character:t};this.#Z===void 0?this.#ut(n):this.#dt(n)}this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1}else{let i=this.#je?.getLinePosition?.(e+1);if(i!==void 0)r.style.top=i.top+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),i.height>0&&this.#Me(e)?(this.#le=e,this.#ue=t,this.#fe=n):(this.#le=void 0,this.#ue=void 0,this.#fe=!1);else{let i=0;if(this.#le===e&&this.#w!==void 0)for(let t=this.#w.childElementCount-1;t>=0;t--){let n=this.#w.children[t],r=n.dataset.lineType,a=W(n);if(r!==void 0&&jr(r)&&a!==void 0){i=(e-(a-1))*this.#r.lineHeight;break}}let a=((this.#R??[]).filter(t=>t.lineNumber<e).length+e)*this.#r.lineHeight+i;r.style.top=a+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),this.#le===e&&(i===0||this.#de)||!this.#Me(e)?(this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1):(this.#le=e,this.#ue=t,this.#de=i!==0,this.#fe=n)}}r.remove()}#yt(e,t,n){let r=e=>({line:e,character:0}),i=e=>({line:e,character:n.getLineText(e).length});return t<e?{start:r(t),end:i(e),direction:-1}:{start:r(e),end:i(t),direction:1}}#bt(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&t.closest(`[data-line]`)?.getAttribute(`data-line-type`)===`change-deletion`}#xt(e,t,n){let r=[...n.querySelectorAll(`[data-content] > [data-line]`)],i=r.indexOf(e),a=r.indexOf(t),[o,s]=a<i?[t,e]:[e,t],c=window.getSelection();if(c!==null){let e=document.createRange();e.setStart(o,0),e.setEnd(s,s.childNodes.length),c.removeAllRanges(),c.addRange(e)}this.#Et(!0),this.#Wt([]),this.#Dt(W(t)??null,!0,`deletions`);let l=Math.min(i,a),u=Math.max(i,a);this.#ie=l<0?``:r.slice(l,u+1).filter(e=>e.getAttribute(`data-line-type`)===`change-deletion`).map(e=>e.textContent??``).join(`
|
|
30
30
|
`)}#St(e,t){let n=e.parentElement;if(n==null||t==null)return;let r=[...n.children].indexOf(e),i=t.children[r];return i instanceof HTMLElement?i:void 0}#Ct(e,t,n){let r=t.querySelector(`[data-content]`),i=this.#St(e,r);return i!==void 0&&(this.#xt(i,i,t),n&&this.#qe([G(document,`mousemove`,e=>{let n=e.composedPath()[0],a=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(a instanceof HTMLElement&&t.contains(a)){let e=this.#St(a,r);e!==void 0&&this.#xt(i,e,t)}},{passive:!0})]),!0)}#wt(){return this.#S?.shadowRoot?.querySelector(`pre`)?.hasAttribute(`data-deleted-text-selection`)??!1}#Tt(){return this.#ie===``?window.getSelection()?.toString()??``:this.#ie}#Et(e){let t=this.#S?.shadowRoot?.querySelector(`pre`);t!=null&&(e?(t.setAttribute(`data-deleted-text-selection`,``),this.#Dt(null),this.#ie=``):(t.removeAttribute(`data-deleted-text-selection`),this.#ie=``))}#Dt(e,t=!1,n=`additions`){try{this.#M?.setEditorActiveLine(e,{lineNumberOnly:t,side:n})}catch{}}#Ot(){this.#he===void 0&&(this.#he=requestAnimationFrame(()=>{this.#he=void 0,(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[])}))}#kt(){let e=this.#te,t=this.#re,n=this.#n?.document;if(e===void 0||e.focusLine===void 0||t===void 0||n===void 0)return!1;let r=t.direction===-1?t.end:t.start,i=this.#w?.parentElement?.scrollLeft??0,a=(e.clientX-e.startClientX+i-e.startScrollLeft)/this.#r.ch,o=a<0?-Math.round(-a):Math.round(a),s=Math.max(0,r.character+o),c={line:e.focusLine,character:s};if(e.renderedGoal!==void 0&&X(e.renderedGoal,c)===0)return!0;e.renderedGoal=c;let l=[],u=c.line<r.line?-1:1;for(let e=r.line;;e+=u){if(this.#Me(e)){let t=n.getLineText(e),i=Math.min(r.character,t.length),a=Math.min(s,t.length),o=mr(t,i),c=a===i?o:mr(t,a);l.push({start:{line:e,character:Math.min(o,c)},end:{line:e,character:Math.max(o,c)},direction:o===c?0:o<c?1:-1})}if(e===c.line)break}return this.#Wt(l),!0}#At(){for(let[e,t]of this.#D??[])e.startsWith(`editPrediction`)&&(t.remove(),this.#D?.delete(e))}#jt(e,t,n){let r=t[n],i=n,a=r.range.end.line;for(;i+1<t.length&&t[i+1].range.start.line<=a;)i++,a=Math.max(a,t[i].range.end.line);if(i===n&&(r.newText.length===0||X(r.range.start,r.range.end)===0))return{edit:r,endIndex:i};let o=r.range.start,s={line:a,character:e.getLineLength(a)},c=[],l=e.offsetAt(o);for(let r=n;r<=i;r++){let n=t[r],i=e.offsetAt(n.range.start),a=e.offsetAt(n.range.end);c.push(e.getTextSlice(l,i),n.newText),l=a}return c.push(e.getTextSlice(l,e.offsetAt(s))),{edit:{range:{start:o,end:s},newText:c.join(``)},endIndex:i}}#Mt(){let e=this.#xe,t=this.#n?.document;if(e==null||t==null||e.document!==t||e.version!==t.version||this.#e.editPrediction?.mode===`subtle`&&!this.#ye)return;let{edits:n}=e.response,r=[],i=n.length>0;for(let e=0;e<n.length;){let{edit:a,endIndex:o}=this.#jt(t,n,e);for(let e=a.range.start.line;i&&e<=a.range.end.line;e++)i=this.#wn(e);r.push({edit:a,startIndex:e,endIndex:o}),e=o+1}return{groups:r,allVisible:i}}#Nt(e,t,n,r,i){this.#Le?(e.dataset.wrap=``,e.style.width=`calc(100cqw - ${r}px)`):(delete e.dataset.wrap,e.style.width=`max-content`);let a=t.split(/\r\n|\r|\n/);for(let t=0;t<a.length;t++){let o=a[t],s=t===a.length-1?i:void 0,c=o.length===0&&s===void 0,l=U(`span`,{dataset:c?[`editPredictionLine`,`empty`]:`editPredictionLine`,textContent:c?``:o},e);s!==void 0&&U(`span`,{dataset:`editPredictionSuffix`},l).append(s),t===0&&n!==r&&(l.style.textIndent=`${n-r}px`)}}#Pt(e){let t=this.#xe,n=this.#n?.document;if(t==null||n==null)return;let{edit:r,startIndex:i,endIndex:a}=e,{start:o,end:s}=r.range;if(!(X(o,s)===0&&o.character<n.getLineLength(o.line))||t.response.edits[i-1]?.range.end.line===o.line||t.response.edits[a+1]?.range.start.line===o.line)return;let c=this.#gn(o.line);if(c===void 0)return document.createTextNode(n.getLineText(o.line).slice(o.character));let[l,u]=ei(c,o.character),d=document.createRange();d.selectNodeContents(c),d.setStart(l,et(l,u));let f=d.cloneContents();return f.firstChild?.textContent===``&&f.firstChild.remove(),f}#Ft(e){let{edit:t}=e,{start:n}=t.range,[r,i]=this.#bn(n.line,n.character),a=1,o=t.newText.split(/\r\n|\r|\n/).length,s=this.#E;if(this.#Le&&s!=null){a=Math.max(1,this.#Sn(n.line).length-1);let i=U(`span`,{dataset:`editPrediction`,style:{visibility:`hidden`}},s);this.#Nt(i,t.newText,r,this.#bn(n.line,0)[0],this.#Pt(e));let{width:c,height:l}=i.getBoundingClientRect();i.remove();let{lineHeight:u}=this.#r;c>0&&l>0&&u>0&&(o=Math.round(l/u))}return Math.max(0,o-(a-i))}#It(e=!0){let t=new Map,n=new Map,r=this.#we,i=!1,a=this.#w,o=this.#Mt();if(a!=null&&o!=null&&o.allVisible){for(let e of o.groups){let{edit:t}=e;if(t.newText.length===0)continue;let r=this.#Ft(e);r>(n.get(t.range.start.line)??0)&&n.set(t.range.start.line,r)}if(n.size>0){let e,o=this.#V?.startingLine??0;for(let[s,c]of n){i||=r.get(s)!==c;let n=this.#gn(s);if(n===void 0)continue;let l=s-o;if(a.children[l]!==n){if(e===void 0){e=new Map;for(let t=0;t<a.children.length;t++)e.set(a.children[t],t)}l=e.get(n)??-1}if(l<0)continue;t.set(n,c);let u=this.#C?.children[l];u instanceof HTMLElement&&t.set(u,c);let d=this.#Lt(l);d!=null&&(t.set(d.content,(t.get(d.content)??0)+c),t.set(d.gutter,(t.get(d.gutter)??0)+c))}}}let s=!1;for(let[e,n]of this.#Ce)t.get(e)!==n&&(delete e.dataset.editPredictionSpacer,e.style.removeProperty(`--diffs-edit-prediction-spacer-height`),s=!0);for(let[e,n]of t)this.#Ce.get(e)!==n&&(e.dataset.editPredictionSpacer=``,e.style.setProperty(`--diffs-edit-prediction-spacer-height`,`${n}lh`),s=!0);this.#Ce=t,(i||n.size!==r.size)&&(this.#we=n,e&&this.#je?.syncGhostTextRows()),s&&this.#ze()}#Lt(e){let t=this.#T,n=this.#w;if(t==null||n==null||!this.#Ie||this.#Fe!==`split`||this.#Le)return;let r=0;for(let t=0;t<e;t++)r+=$a(n.children[t]);let{content:i,gutter:a}=t,o=0;for(let e=0;e<i.children.length;e++){let t=i.children[e];if(o+=$a(t),o>r){let n=a.children[e];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))throw Error(`Editor: deletions column rows and gutter cells are out of step`);return{content:t,gutter:n}}}}#Rt(e,t=!0){this.#ge!==void 0&&(clearTimeout(this.#ge),this.#ge=void 0),this.#_e?.abort(),this.#_e=void 0,this.#ve++,this.#ye=!1,this.#be=!1,this.#xe=void 0,this.#It(t),e&&this.#At()}#zt(e){let t=this.#e.editPrediction;if(t===void 0)return!1;let n=e.replaceAll(`\\`,`/`);return(t.include===void 0||t.include.some(e=>$i(n,e)))&&t.exclude?.some(e=>$i(n,e))!==!0}#Bt(){this.#Rt(!0);let e=this.#se?.[0];if(this.#e.editPrediction===void 0||this.#n?.document===void 0||this.#n?.fileInfo===void 0||this.#se?.length!==1||e===void 0||!J(e))return;let t=this.#n?.document,n=t.offsetAt(Y(e));this.#ge=setTimeout(()=>{this.#ge=void 0;let e=this.#e.editPrediction,r=this.#se?.[0],i=this.#n?.fileInfo?.name;if(e===void 0||i===void 0||this.#n?.document!==t||this.#se?.length!==1||r===void 0||!J(r)||t.offsetAt(Y(r))!==n||!this.#zt(i))return;let a=e=>this.#hn(e)&&this.#Me(e);if(!a(Y(r).line)){this.#be=!0;return}let o=Qi(i,t,n,this.#Se,a);if(o===void 0)return;let s=t.offsetAt({line:o.excerptStartLine,character:0}),c=s+o.editableRange.start,l=s+o.editableRange.end,u=new AbortController,d=++this.#ve;this.#_e=u;let f;try{f=e.provider.predict(o,{signal:u.signal})}catch{this.#_e=void 0;return}Promise.resolve(f).then(e=>{let r=this.#se?.[0];if(u.signal.aborted||d!==this.#ve||this.#_e!==u||this.#n?.document!==t||t.version!==o.version||this.#se?.length!==1||r===void 0||!J(r)||t.offsetAt(Y(r))!==n||e==null||!Array.isArray(e.edits)||e.edits.length===0||e.edits.length>Ka||e.newCursor==null)return;let i=[],a=0;for(let n of e.edits){if(n==null||typeof n.newText!=`string`||!eo(t,n.range?.start)||!eo(t,n.range?.end)||X(n.range.start,n.range.end)>0||(a+=Ja.encode(n.newText).byteLength,a>qa))return;let e=t.offsetAt(n.range.start),r=t.offsetAt(n.range.end),o=t.resolveEdits([n])[0];if(o.start!==e||o.end!==r)return;i.push(o)}i.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<i.length;e++){let t=i[e];if(t.start<c||t.end>l||e>0&&i[e-1].end>t.start)return}let s=i.filter(e=>e.text!==t.getTextSlice(e.start,e.end));if(s.length===0)return;let f=t.positionAt(s[0].start),p=t.positionAt(s.at(-1).end),m=t.offsetAt({line:f.line,character:0}),h=t.offsetAt({line:p.line,character:t.getLineLength(p.line)}),g=[],_=m;for(let e of s)g.push(t.getTextSlice(_,e.start),e.text),_=e.end;g.push(t.getTextSlice(_,h));let v=g.join(``).split(/\r\n|\r|\n/),y=f.line+v.length-1,b=v.length-(p.line-f.line+1),x=e.newCursor;if(!(!Number.isInteger(x.line)||!Number.isInteger(x.character)||x.line<0||x.character<0)){if(x.line>=f.line&&x.line<=y){let e=v[x.line-f.line];if(x.character>e.length||to(e,x.character))return}else{let e=x.line<f.line?x.line:x.line-b;if(e<0||e>=t.lineCount||x.character>t.getLineLength(e))return;let n=t.offsetAt({line:e,character:x.character});if(to(t.charAt(n-1)+t.charAt(n),1))return}this.#xe={document:t,version:o.version,cursorOffset:n,rendered:!1,response:{edits:s.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),newCursor:{...x}}},this.#Wt(this.#se)}}).catch(()=>{}).finally(()=>{this.#_e===u&&(this.#_e=void 0)})},Ga)}#Vt(e,t){let n=this.#n?.document,r=this.#n?.fileInfo?.name,i=Fn(e);n!==void 0&&r!==void 0&&i!==void 0&&this.#zt(r)&&(this.#Se=Xi(this.#Se,r,n,i,t))}#Ht(){let e=this.#xe,t=this.#n?.document,n=this.#se?.[0];if(e===void 0||!e.rendered||t===void 0||e.document!==t||e.version!==t.version||this.#se?.length!==1||n===void 0||!J(n)||t.offsetAt(Y(n))!==e.cursorOffset)return;let{edits:r,newCursor:i}=e.response;this.#Rt(!0);let a=t.applyEdits(r.map(e=>({range:{start:{...e.range.start},end:{...e.range.end}},newText:e.newText})),!0,this.#se,void 0,!0);if(a===void 0){this.#Bt();return}let o=t.normalizePosition(i),s=[{start:o,end:o,direction:0}];t.setLastUndoSelectionsAfter(s),this.#dn(a,s,this.#pn(a),{editSource:`prediction`})}#Ut(e){let t=this.#xe,n=this.#n?.document;t!==void 0&&(t.rendered=!1);let r=this.#Mt();if(t!=null&&n!=null&&r!=null&&r.allVisible){for(let t of r.groups){let{edit:r,endIndex:i}=t,{start:a,end:o}=r.range,s=r.newText.length===0,c=X(a,o)!==0,l=n.getLineLength(a.line),u=!c&&a.character<l;if(c?this.#Kt(e,s?`editPredictionDeletion`:`editPredictionReplacement`,{start:a,end:o}):u&&this.#Kt(e,`editPredictionInsertion`,{start:a,end:{line:a.line,character:l}}),s)continue;let[d,f]=this.#bn(a.line,a.character),p=this.#bn(a.line,0)[0],m=this.#yn(a.line)+f*this.#r.lineHeight,h=`editPrediction-${i}`,g=this.#D?.get(h);if(g===void 0?g=U(`span`,{ariaHidden:`true`,contentEditable:`false`,dataset:`editPrediction`},e.fragment):(this.#D?.delete(h),g.replaceChildren()),c){g.dataset.replacement=``;let e=this.#gn(a.line);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else delete g.dataset.replacement,g.style.removeProperty(`--diffs-edit-prediction-bg`);this.#Nt(g,r.newText,d,p,this.#Pt(t)),g.style.transform=`translateX(${p}px) translateY(${m}px)`,e.elements.set(h,g)}t.rendered=!0}}#Wt(e){this.__postponeBgTokenizeToNextFrame();let t=this.#se,n=t?.length!==e.length;if(!n&&t!==void 0)for(let r=0;r<e.length;r++){let i=t[r],a=e[r];if(i.direction!==a.direction||X(i.start,a.start)!==0||X(i.end,a.end)!==0){n=!0;break}}if(n&&this.#Rt(!0),this.#It(),this.#A=void 0,this.#Dt(null),e.length===0&&this.#ce===void 0&&this.#U===void 0){this.#se=void 0,this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#K?.cleanup(),this.#K=void 0,n&&this.#Bt();return}let r=document.createDocumentFragment(),i={fragment:r,elements:new Map};if(e.length>0){let t=zr(e),n=t.at(-1);this.#se=t;let r=t.some(e=>!J(e)),a=Y(n).line+1;this.#Dt(a,r);for(let e of t)J(e)||this.#Kt(i,`selection`,e),this.#Xt(i,e,e===n);let o=this.#e.matchBrackets!==!1&&this.#n?.document!=null&&this.#i!==void 0&&J(n)?ma(this.#n?.document,this.#i,n.start):void 0;if(o!==void 0)for(let e of o)this.#Kt(i,`bracketMatch`,e)}let a=this.#n?.document;if(this.#ce!==void 0&&a!==void 0){let e=this.#ce,t=this.#V,n=t!=null&&Number.isFinite(t.totalLines)||this.#Ie&&this.#Ae?.options.expandUnchanged!==!0?this.#mn():void 0,r=this.#se?.at(-1),o=r===void 0?-1:a.offsetAt(r.start),s=r===void 0?-1:a.offsetAt(r.end),c=0,l=n?.length??1;for(let t=0;t<l;t++){let r=1/0,l=n?.[t];if(l!==void 0){let[t,n]=l,i=a.offsetAt({line:t,character:0}),o=n+1;r=o<a.lineCount?a.offsetAt({line:o,character:0}):a.offsetAt({line:o-1,character:a.getLineLength(o-1)});let s=c,u=e.length;for(;s<u;){let t=s+Math.floor((u-s)/2);e[t][1]<=i?s=t+1:u=t}c=s}for(;c<e.length;c++){let[t,n]=e[c];if(t>=r)break;let l={start:a.positionAt(t),end:a.positionAt(n)},u=o===t&&s===n;this.#Kt(i,`match`,l,u?`focus`:void 0)}}}if(this.#U!==void 0&&a!==void 0)for(let e of this.#U.markers)this.#Kt(i,`marker`,e,Ai(e.severity));this.#Ut(i),this.#E?.appendChild(r),this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#D=i.elements,this.#Zt(),n&&this.#Bt()}#Gt(){let e=this.#W,t=this.#e.renderCaret,n=this.#E;if(this.#k?.forEach(e=>e.remove()),this.#k=void 0,e===void 0||t===void 0||n===void 0){this.#O?.forEach(e=>e.remove()),this.#O=void 0;return}let r=this.#O??=new Map;for(let[e,t]of r)this.#wn(e.caret.focus.line)||(t.remove(),r.delete(e));let i=document.createDocumentFragment(),a=[];for(let n of e){let{caret:e}=n,{line:o,character:s}=e.focus;if(n.anchorOffset!==n.focusOffset){let t={fragment:i,elements:new Map};this.#Kt(t,`caretHighlight`,n.anchorOffset<n.focusOffset?{start:e.anchor,end:e.focus}:{start:e.focus,end:e.anchor},void 0,e.focus);for(let n of t.elements.values())n.style.setProperty(`--diffs-caret-highlight-bg`,`color-mix(in srgb, ${e.metadata.color} 32%, transparent)`),a.push(n)}if(!this.#wn(o))continue;let c=r.get(n);c===void 0&&(c=U(`div`,{dataset:`remoteCaret`,children:[t(e)]},i),r.set(n,c));let[l,u]=this.#bn(o,s),d=this.#yn(o)+u*this.#r.lineHeight;c.style.transform=`translateX(${l}px) translateY(${d}px)`}this.#k=a,n.appendChild(i)}#Kt(e,t,n,r,i){if(this.#n?.document==null)return;let{start:a,end:o}=n,s=a.line,c=o.line+1;if(this.#V!==void 0){let{startingLine:e,totalLines:t}=this.#V;s=Math.max(s,e),c=Math.min(c,e+t)}for(let n=s;n<c;n++){if(!this.#wn(n))continue;let s=n===o.line,c=n===a.line?a.character:0,l=s?o.character:this.#n?.document.getLineLength(n);if(c===l&&(t===`editPredictionDeletion`||t===`editPredictionReplacement`)){if(s&&n!==a.line)continue;let[i,o]=this.#bn(n,c);this.#Yt(e,t,n,o,i,this.#r.ch,r);continue}if(this.#Le){let a=this.#vn(),o=this.#n?.document.getLineText(n);if(2*this.#r.ch+this.#r.measureTextWidth(o)>a){this.#qt(e,n,o,c,l,s,t,r,i);continue}}let u=0,d=0,f=0;u=c===0?this.#_n()+this.#r.ch+(this.#$e?.left??0):this.#bn(n,c)[0],!s&&t===`selection`&&(f=this.#r.ch),d=c===l?f:this.#bn(n,l)[0]-u+f,this.#Yt(e,t,n,0,u,d,r,{start:i?.line===a.line&&i.character===a.character&&n===a.line,end:i?.line===o.line&&i.character===o.character&&n===o.line})}}#qt(e,t,n,r,i,a,o,s,c){let l=this.#Sn(t),u=l.length-1,d=this.#_n()+this.#r.ch+(this.#$e?.left??0);for(let f=0;f<u;f++){let p=l[f],m=l[f+1],h=Math.max(r,p),g=Math.min(i,m);if(h>g)continue;let _=this.#Jt(n,p,h),v=d+_,y=0;!a&&f===u-1&&o===`selection`&&(y=this.#r.ch);let b=h===g?y:this.#Jt(n,p,g)-_+y;this.#Yt(e,o,t,f,v,b,s,{start:c?.line===t&&c.character===r&&h===r,end:c?.line===t&&c.character===i&&g===i})}}#Jt(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=Na(r,this.#r.tabSize);return i===-1?this.#r.measureTextWidth(r):i*this.#r.ch}#Yt(e,t,n,r,i,a,o,s){if(a===0)return;let{ch:c,lineHeight:l}=this.#r,u=this.#yn(n)+r*l,d=`${t}-${n}/${r}-${i}-${a} ${o??``}`,f=this.#D,p=(this.#e.roundedSelection??!0)&&(t===`selection`||t===`caretHighlight`),m=(n,r,i,a)=>{let o=this.#yn(n)+r*l,s=this.#gn(n),u=`initial`;s!==void 0&&(s.dataset.lineType===`change-addition`||s.dataset.selectedLine!==void 0)&&(u=getComputedStyle(s).getPropertyValue(`--diffs-line-bg`));let d=`width:${c}px;transform:translateX(${i}px) translateY(${o}px);--diffs-selection-corner-bg:${u}`,p={selectionCorner:``,[a]:``},m=`${t}-block-${n}/${r}-${i}-1ch`,h=m+`-`+a;if(a===`rbl`){let t=m+`-rtl`,n=e.elements.get(t);n!==void 0&&(n.remove(),e.elements.delete(t),h+=`-rtl`,p.rtl=``)}let g=e.elements.get(h);g===void 0&&(f?.has(h)===!0?(g=f.get(h),g.style.cssText=d,f.delete(h)):g=U(`div`,{dataset:t===`caretHighlight`?`caretHighlightRange`:`selectionRange`,style:{cssText:d},children:[U(`div`,{dataset:p})]},e.fragment),e.elements.set(h,g))},h=t=>{let o=i+a,l=t.dataset,u=e.previousSelectionRange;if((u===void 0||u.line!==n||u.wrapLine!==r)&&(e.previousSelectionRange={element:t,line:n,wrapLine:r,left:i,width:a}),u===void 0||o<=u.left)[`rtl`,`rtr`,`rbl`,`rbr`].forEach(e=>{l[e]=``});else{let e=u.line,t=u.wrapLine,a=u.left,s=u.element.dataset,d=a+u.width;a>i&&m(e,t,a-c,`rbr`),delete s.rbl,delete l.rtl,delete l.rtr,o>=d&&delete s.rbr,o>d&&(m(e,t,d,`rbl`),l.rtr=``),o<d&&m(n,r,o,`rtl`),i<a&&(l.rtl=``),l.rbl=``,l.rbr=``}s?.start===!0&&(delete l.rtl,delete l.rbl),s?.end===!0&&(delete l.rtr,delete l.rbr)},g=e.elements.get(d);if(g!==void 0){p&&h(g);return}if(f?.has(d)===!0?(g=f.get(d),f.delete(d)):g=U(`div`,{dataset:o?[t+`Range`,o]:t+`Range`},e.fragment),g.style.width=`${a}px`,g.style.transform=`translateX(${i}px) translateY(${u}px)`,t===`editPredictionInsertion`||t===`editPredictionReplacement`){let e=this.#gn(n);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else g.style.removeProperty(`--diffs-edit-prediction-bg`);p&&h(g),e.elements.set(d,g)}#Xt(e,t,n){let{line:r,character:i}=Y(t);if(!this.#wn(r))return;let[a,o]=this.#bn(r,i),s=`caret-`+r+`/`+o+`:`+i;if(e.elements.has(s))return;let c=a-1,l=this.#yn(r)+o*this.#r.lineHeight,u=U(`div`,{dataset:`caret`,style:{transform:`translateX(${c}px) translateY(${l}px)`}},e.fragment);e.elements.set(s,u),n&&(u.style.scrollMargin=this.#_t(),this.#A=u)}#Zt(){let e=this.#se?.at(-1),t=this.#E,n=this.#n?.document,r=this.#e.renderSelectionAction,i=()=>{this.#K?.cleanup(),this.#K=void 0};if(this.#e.enabledSelectionAction!==!0||r===void 0||e===void 0||J(e)||this.#ee||t===void 0||n===void 0){i();return}let a=Y(e);if(!this.#wn(a.line)){i();return}if(this.#K===void 0){if(!this.#q)return;let a=()=>this.#se?.at(-1)??e,o=r({textDocument:n,get selection(){return a()},applyEdits:e=>this.applyEdits(e),getSelectionText:()=>this.#n?.document?.getText(a())??``,replaceSelectionText:e=>{this.#an(e,[a()])},close:()=>{i(),this.#gt()}});this.#K=new Ea(o,t,()=>this.#Zt()),this.#Re().resetPlacement(Ya)}let o=this.#r.lineHeight,s=e.direction===-1,c={placeAbove:s,anchor:a},l=s?{placeAbove:!1,anchor:e.end}:{placeAbove:!0,anchor:e.start},u=this.#K.height,d=e=>{let[t,n]=this.#bn(e.anchor.line,e.anchor.character),r=this.#yn(e.anchor.line)+n*o,i=e.placeAbove?r:r+o,a=e.placeAbove?i-u:i;return{top:a,bottom:a+u,left:t,anchorTop:i,rowTop:r}},f=d(c),p=n.lineCount,m=s?a.line<3:a.line>=p-3,h=this.#wn(l.anchor.line)?d(l):void 0,g=this.#Re(),_=g.getPlacementBounds(),v=h!==void 0&&g.choosePlacement({preferred:f,fallback:h,viewport:_,popoverHeight:u,atDocumentEdge:m,placementKey:Ya})===`fallback`;h===void 0&&g.setPlacement(`preferred`,Ya);let{placeAbove:y}=v?l:c,{left:b,anchorTop:x}=v&&h!==void 0?h:f,S=s?f.rowTop:h?.rowTop??-1/0,C=(s?h?.rowTop??1/0:f.rowTop)+(e.end.line>e.start.line&&e.end.character===0?0:o),w=_===void 0||C>_.top&&S<_.bottom;this.#K.reposition(b,x,this.#_n(),y,w,_)}#Qt(e){if(this.#G!==void 0){this.#G.setMode(e);return}this.#$t(e)}#$t(e){this.#G?.cleanup();let t=this.#n?.document,n=this.#S?.shadowRoot?.querySelector(`pre`),r=this.#se;if(t===void 0||n==null)return;let i=``,a;if(r!==void 0&&r.length>0){let e=r.at(-1);if(J(e)){e=ti(t,e),this.#Wt([...r.slice(0,-1),e]);let n=t.getText(e);n!==``&&!n.includes(`
|
|
31
|
-
`)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Nr(t,e,n);this.#Wt([i]),this.#Pe(Y(i).line),this.#gt(!0),this.#pe=r},s=new it({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:Jr(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:qr(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(Xa,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>J(e))){let n=$r(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=Jr(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?Sr(i,t,e,this.#R,n,r):yr(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Ar(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Dr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Or(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Er(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Tr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Pr(t.anchorOffset,e.changes),t.focusOffset=Pr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*Ua;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(Y(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=Y(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=Yn(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=W(e);if(i===void 0||r===void 0||!jr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=W(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&jr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=ja(n,Math.min(t,n.length)),a=n.slice(0,i),o=Na(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=Na(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Wa&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=U(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ma(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=je()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function Qa({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Gn.activate(e,t,n,a)}function $a(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function eo(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function to(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=l(),no=ce(),ro=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function io(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(e){if(e.dataTransfer===null)return;let r=null;for(let t of e.composedPath())if(r=ro(t),r!==null)break;if(r===null)return;let i=t.includes(r)?t:[r],a=i.map(e=>gn(e)).filter(e=>e!==null);a.length!==0&&(n=i,e.dataTransfer.setData(_n,a.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function ao(e){return e.split(`/`).filter(Boolean).length}function oo(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>ao(e)-ao(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>ao(e)-ao(t));for(let e of s)a.push({type:`add`,path:e});return a}function so(e,t){let[n,r]=(0,q.useState)(new Map),[i,a]=(0,q.useState)(new Map),[s,c]=(0,q.useState)(0),[l,u]=(0,q.useState)(new Set),d=(0,q.useRef)(new Map),f=(0,q.useRef)(new Set),p=(0,q.useRef)(new Set),m=(0,q.useRef)(!0),h=(0,q.useRef)(0),g=(0,q.useRef)([]),_=(0,q.useCallback)(function n(i,s=!1){let l=d.current.get(i);if(l)return s?l.then(()=>n(i,!0)):l;if(!s&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let _=A.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});c(e=>e+1),s||u(e=>new Set(e).add(i));let v=(async()=>{h.current>=4?await new Promise(e=>g.current.push(e)):h.current++;try{return m.current?await O(o,_,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=g.current.shift();e?e():h.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),a(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=b(e.cause);a(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{d.current.delete(i),m.current&&(c(e=>e-1),s||u(e=>{let t=new Set(e);return t.delete(i),t}))});return d.current.set(i,v),v},[t,e]);(0,q.useEffect)(()=>(m.current=!0,_(``),()=>{m.current=!1}),[_]);let v=(0,q.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),y=(0,q.useMemo)(()=>new Set([``,...v.filter(e=>e.kind===`directory`).map(e=>e.path)]),[v]);return{entries:v,load:_,refresh:(0,q.useCallback)(()=>{let e=[...p.current].filter(e=>y.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await _(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[_,y]),isPending:s>0,loadingDirectories:l,ready:n.has(``),error:[...i].find(([e])=>y.has(e))?.[1]??null}}var $=e(v(),1);function co(e){return e.kind===`directory`?`${e.path}/`:e.path}function lo(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(y,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(ln,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(M,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(N,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(P,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function uo(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(Qt,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(Zt,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function fo({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s}){let{resolvedTheme:c}=he(),l=_(),u=fn(e),{entries:d,load:f,refresh:p,ready:m,error:h,isPending:g,loadingDirectories:v}=so(e,t),[b,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(!1),w=Ce({environmentId:e,cwd:t,query:b.slice(0,256)},200),T=(0,q.useMemo)(()=>{let e=new Map(d.map(e=>[e.path,e]));if(b.trim()&&!w.isPending)for(let t of w.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[d,w.entries,w.isPending,b]),E=(0,q.useMemo)(()=>new Map(T.map(e=>[e.path,e.kind])),[T]),D=(0,q.useRef)(E),O=(0,q.useMemo)(()=>T.map(co),[T]),k=(0,q.useMemo)(()=>T.filter(e=>e.kind===`directory`).map(co),[T]),ee=(0,q.useRef)(null),te=(0,q.useRef)(!1),A=(0,q.useRef)(null),j=(0,q.useRef)(null),ne=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{ne.current={x:e.clientX,y:e.clientY,at:e.timeStamp}};return document.addEventListener(`contextmenu`,e,!0),()=>document.removeEventListener(`contextmenu`,e,!0)},[]);let re=async(n,r)=>{let i=me();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=hn(a),s=ne.current,c=s!==null&&performance.now()-s.at<1e3,d=r.anchorElement.getBoundingClientRect(),f=c?{x:s.x,y:s.y}:{x:d.left,y:d.bottom},p={environmentId:e,filePath:a,workspaceRoot:t},m=u.buildItems(p);try{let e=await i.contextMenu.show([...m,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],f);if(e===null)return;if(m.some(t=>t.id===e)||e.startsWith(`editor:`)){await u.activate(e,p);return}if(e===`copy-mention`){try{await L(o),fe.add({type:`success`,title:`Mention copied`,description:a})}catch(e){fe.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}return}if(e===`add-to-chat`){let e=l?.current;if(!e){fe.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||fe.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}finally{r.close()}},ie=(0,q.useRef)(re);(0,q.useEffect)(()=>{ie.current=re});let ae=(0,q.useRef)(v),oe=(0,q.useRef)(null),M=(0,q.useMemo)(()=>io({deselect:e=>oe.current?.getItem(e)?.deselect()}),[]),{model:N}=Et({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{ie.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Ot,onSelectionChange:e=>{if(M.handleSelectionChange(e),te.current||M.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&D.current.get(t)===`file`&&(A.current=t,a(t))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ae.current.has(e.path.replace(/\/$/,``))?{icon:`t3-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>x(e??``),unsafeCSS:Tt});(0,q.useEffect)(()=>{ae.current!==v&&(ae.current=v,N.setComposition(N.getComposition()))},[v,N]);let P=bn(N),ce=wt(N,e=>Dt(e,k)),le=()=>{let e=!(S||ce);C(e),Ct(N,k,e)},ue=()=>{x(``),P.close()},F=(0,q.useRef)(new Set);(0,q.useEffect)(()=>{let e=new Set(k);for(let t of F.current)e.has(t)||F.current.delete(t);let t=()=>{if(!N.isSearchOpen())for(let e of k){let t=N.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?F.current.has(e)||(F.current.add(e),f(e.replace(/\/$/,``))):(t?.isDirectory()&&F.current.has(e)&&C(!1),F.current.delete(e))}};return t(),N.subscribe(t)},[k,f,N]),(0,q.useEffect)(()=>{N.setGitStatus(T.filter(e=>e.ignored).map(e=>({path:co(e),status:`ignored`})))},[T,N]),(0,q.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await f(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[f,r]);let de=e=>{if(x(e),e.trim().length===0){P.close();return}P.setValue(e)},I=()=>{p(),b.trim()&&w.refresh(),o?.()};pn({mutationId:s,refresh:()=>{p(),b.trim()&&w.refresh()},resourceKey:`files:${e}:${t}`}),(0,q.useEffect)(()=>{if(!m||ee.current===O)return;D.current=E;let e=ee.current;if(ee.current=O,e===null){N.resetPaths(O);return}let t=oo(e,O);t.length>0&&N.batch(t)},[m,E,N,O]),(0,q.useEffect)(()=>{S&&!b.trim()&&Ct(N,k,!0)},[k,S,N,b]),(0,q.useEffect)(()=>{if(!r){j.current=null;return}let e=E.get(r);if(e===void 0){j.current=null;return}let t={path:r,revealId:i},n=j.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=N.getItem(a);if(!o)return;if(N.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&A.current===r){A.current=null,j.current=t;return}A.current=null,j.current=t,te.current=!0,x(``),N.closeSearch();for(let e of N.getSelectedPaths())N.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=N.getItem(`${c}/`)??N.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),N.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{te.current=!1})},[E,N,r,i]);let pe=(0,q.useRef)(null);return(0,q.useEffect)(()=>{oe.current=N},[N]),(0,q.useEffect)(()=>{let e=pe.current;if(e===null)return;let t=e=>M.handleDragStart(e),n=()=>M.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[M]),(0,$.jsxs)(`div`,{ref:pe,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(lo,{isPending:g,onRefresh:I}),(0,$.jsx)(uo,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:P.value,onValueChange:de,onClose:ue}),k.length>0?(0,$.jsx)(y,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":S||ce?`Collapse all folders`:`Expand all folders`,onClick:le,children:(0,$.jsx)(se,{className:`size-3.5`,icon:ce?no.ChevronsDownUp:no.ChevronsUpDown})}):null]}),h||w.error?(0,$.jsxs)(`button`,{type:`button`,onClick:I,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[h??w.error,` Click to retry.`]}):null,b.trim()&&w.truncated&&!w.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!m||w.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(xt,{model:N,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:St(c)})]})}function po(e,t){let n=ie(t),r=oe(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:n&&r===`/`?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>({label:e,path:a+i.slice(0,t+1).join(r),kind:t===i.length-1?`file`:`directory`}))]}function mo(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function ho(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function go(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function _o(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=x(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(M,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(N,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(P,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function vo(e){let t=(0,Q.c)(44),n=rn(e.environmentId,e.cwd,e.directoryPath),r=`files:${e.environmentId}:${e.cwd}`,o;t[0]!==n.refresh||t[1]!==e.workspaceMutationId||t[2]!==r?(o={mutationId:e.workspaceMutationId,refresh:n.refresh,resourceKey:r},t[0]=n.refresh,t[1]=e.workspaceMutationId,t[2]=r,t[3]=o):o=t[3],pn(o);let{resolvedTheme:s}=he(),l;t[4]===n.data?.entries?l=t[5]:(l=n.data?.entries??[],t[4]=n.data?.entries,t[5]=l);let u=l,p=n.data?.truncated??!1,m;t[6]!==u||t[7]!==e.directoryPath?(m=mo(u,e.directoryPath),t[6]=u,t[7]=e.directoryPath,t[8]=m):m=t[8];let g=m,_=n.data!==null,v,y,b,S,C;if(t[9]!==e){let n=ho(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));v=d,y=`start`,b=`bottom`,S=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},C=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(sn,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,go(n,e.projectName)]})]}),(0,$.jsx)(h,{})]}):null,t[9]=e,t[10]=v,t[11]=y,t[12]=b,t[13]=S,t[14]=C}else v=t[10],y=t[11],b=t[12],S=t[13],C=t[14];let w;t[15]!==g||t[16]!==_||t[17]!==n.data||t[18]!==n.error||t[19]!==n.isPending||t[20]!==n.refresh||t[21]!==p||t[22]!==e||t[23]!==s?(w=n.isPending&&n.data===null?(0,$.jsxs)(i,{disabled:!0,children:[(0,$.jsx)(I,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(ln,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!_&&!p?(0,$.jsx)(i,{disabled:!0,children:`This folder is no longer available.`}):g.length===0?(0,$.jsx)(i,{disabled:!0,children:p?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(f,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:g.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,r=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xt,{pathValue:t.path,kind:t.kind,theme:s}),(0,$.jsxs)(P,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(`span`,{className:x(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(N,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(i,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[r,(0,$.jsx)(T,{})]},t.path):(0,$.jsx)(c,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:r})},t.path)})}),t[15]=g,t[16]=_,t[17]=n.data,t[18]=n.error,t[19]=n.isPending,t[20]=n.refresh,t[21]=p,t[22]=e,t[23]=s,t[24]=w):w=t[24];let E;t[25]!==e.directoryPath||t[26]!==w?(E=(0,$.jsx)(a,{children:w},e.directoryPath),t[25]=e.directoryPath,t[26]=w,t[27]=E):E=t[27];let D;t[28]!==n.data||t[29]!==n.error||t[30]!==n.isPending||t[31]!==n.refresh?(D=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{}),(0,$.jsxs)(i,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(ln,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[28]=n.data,t[29]=n.error,t[30]=n.isPending,t[31]=n.refresh,t[32]=D):D=t[32];let O;t[33]===p?O=t[34]:(O=p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{}),(0,$.jsx)(i,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[33]=p,t[34]=O);let k;return t[35]!==v||t[36]!==D||t[37]!==O||t[38]!==y||t[39]!==b||t[40]!==S||t[41]!==C||t[42]!==E?(k=(0,$.jsxs)(v,{align:y,side:b,onKeyDown:S,children:[C,E,D,O]}),t[35]=v,t[36]=D,t[37]=O,t[38]=y,t[39]=b,t[40]=S,t[41]=C,t[42]=E,t[43]=k):k=t[43],k}function yo(e){let t=(0,Q.c)(35),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,q.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,d=`Browse ${e.crumb.label}`,f;t[7]===d?f=t[8]:(f=(0,$.jsx)(m,{render:(0,$.jsx)(`button`,{type:`button`,"aria-label":d,className:`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left text-muted-foreground outline-none pointer-coarse:after:-inset-y-3 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`})}),t[7]=d,t[8]=f);let p;t[9]===e.crumb.label?p=t[10]:(p=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[9]=e.crumb.label,t[10]=p);let h;t[11]!==f||t[12]!==p?(h=(0,$.jsx)(M,{render:f,children:p}),t[11]=f,t[12]=p,t[13]=h):h=t[13];let g=e.crumb.path||e.projectName,_;t[14]===g?_=t[15]:(_=(0,$.jsx)(N,{side:`top`,children:g}),t[14]=g,t[15]=_);let v;t[16]!==h||t[17]!==_?(v=(0,$.jsxs)(P,{children:[h,_]}),t[16]=h,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==i||t[20]!==l||t[21]!==n||t[22]!==e.crumb.path||t[23]!==e.cwd||t[24]!==e.environmentId||t[25]!==e.onOpenFile||t[26]!==e.projectName||t[27]!==e.relativePath||t[28]!==e.workspaceMutationId?(y=n?(0,$.jsx)(vo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[19]=i,t[20]=l,t[21]=n,t[22]=e.crumb.path,t[23]=e.cwd,t[24]=e.environmentId,t[25]=e.onOpenFile,t[26]=e.projectName,t[27]=e.relativePath,t[28]=e.workspaceMutationId,t[29]=y):y=t[29];let b;return t[30]!==l||t[31]!==n||t[32]!==y||t[33]!==v?(b=(0,$.jsxs)(u,{open:n,onOpenChange:l,children:[v,y]}),t[30]=l,t[31]=n,t[32]=y,t[33]=v,t[34]=b):b=t[34],b}function bo(e){let t=(0,Q.c)(12),n;t[0]===e.relativePath?n=t[1]:(n=ie(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.relativePath?(i=po(e.projectName,e.relativePath),t[2]=e.projectName,t[3]=e.relativePath,t[4]=i):i=t[4];let a=i,o;if(t[5]!==a||t[6]!==r||t[7]!==e){let n;t[9]!==r||t[10]!==e?(n=(t,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":t.kind===`file`,children:[n>0?(0,$.jsx)(T,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,t.kind===`file`?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(_o,{current:!0,label:t.label,pathLabel:t.path})}):r?(0,$.jsx)(_o,{label:t.label,pathLabel:t.path}):(0,$.jsx)(yo,{...e,crumb:t})]},t.path||`project`),t[9]=r,t[10]=e,t[11]=n):n=t[11],o=a.map(n),t[5]=a,t[6]=r,t[7]=e,t[8]=o}else o=t[8];return o}function xo(e){let t=(0,Q.c)(14),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?xe(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;return t[8]!==o||t[9]!==e.cwd||t[10]!==e.onTaskListChange||t[11]!==e.text||t[12]!==e.threadRef?(s=(0,$.jsx)(F,{text:e.text,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[8]=o,t[9]=e.cwd,t[10]=e.onTaskListChange,t[11]=e.text,t[12]=e.threadRef,t[13]=s):s=t[13],s}function So({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Co(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function wo({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||So({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Co(e)&&(i.preventDefault(),i.stopImmediatePropagation(),So({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function To(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function Eo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Do(e,t,n){return`${e}:${t}:${Eo(n)}`}function Oo(e,t){return e===null||e===`.`||j(e,t)===`.`?null:e}var ko=e=>/\.(?:md|mdx)$/i.test(e);function Ao(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function jo(e){return e.attachmentOpen||e.relativePath&&ie(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Mo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function No(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Po=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},Fo=500;function Io(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=ye(n,w),s=be(A.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Po({debounceMs:Fo,canPersist:()=>R(n,w),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>on(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let f=d,p;t[8]===f?p=t[9]:(p=[f],t[8]=f,t[9]=p),(0,q.useEffect)(f.setup,p);let m,h;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==f?(m=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=$t(n,r,i);t&&f.change(t.contents)}),()=>{e=!0}},h=[o,r,n,i,f],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=f,t[15]=m,t[16]=h):(m=t[15],h=t[16]),(0,q.useEffect)(m,h),f}var Lo=`t3code.fileExplorerOpen`,Ro=`t3code.renderMarkdown`,zo=`t3code.renderBrowserFile`,Bo=`t3code.renderTable`;function Vo(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),[a,o]=(0,q.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=pt(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(ue,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(ue,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function Ho(e){let t=(0,Q.c)(18),n=pt(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=No({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=qt(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=e.title,u;t[12]===e.absolutePath?u=t[13]:(u=Nt(e.absolutePath),t[12]=e.absolutePath,t[13]=u);let d;return t[14]!==e.title||t[15]!==c||t[16]!==u?(d=(0,$.jsx)(Mt,{src:c,title:l,pdf:u}),t[14]=e.title,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function Uo(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),a=Gt(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(Wo)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],pn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=pt(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(le,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function Wo(){}function Go(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),a=Gt(e.environmentId,r),[o,s]=(0,q.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(qo)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],pn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(zt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(Ko)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ft,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(At,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function Ko(){}function qo(){}function Jo(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function Yo(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Lt}]`))e.removeAttribute(Lt);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Lt,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Lt,``))}var Xo=30,Zo=20,Qo=2;function $o(e,t,n){let r=(0,Q.c)(5),[i]=(0,q.useState)(es),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(Yo(r,t===null||u===void 0?null:Jo(u,t)),!(a instanceof Ge))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return To({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=Zo,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>Qo&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:Jo(i,t),s=o===null?null:f(o);if(o===null||s===null){e<Xo&&m(e+1);return}Yo(r,o),d.scrollTop=s,c.handledRequestId=n,p(o)})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function es(){return new Map}var ts=(e,t,n)=>new Za(e,t,n);function ns(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Do(t,n,r)}`}}function rs(e,t){if(e?.isWorkingPool()!==!0||(t.lang??dn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
|
|
31
|
+
`)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Nr(t,e,n);this.#Wt([i]),this.#Pe(Y(i).line),this.#gt(!0),this.#pe=r},s=new it({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:Jr(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:qr(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(Xa,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>J(e))){let n=$r(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=Jr(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?Sr(i,t,e,this.#R,n,r):yr(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Ar(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Dr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Or(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Er(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Tr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Pr(t.anchorOffset,e.changes),t.focusOffset=Pr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*Ua;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(Y(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=Y(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=Yn(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=W(e);if(i===void 0||r===void 0||!jr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=W(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&jr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=ja(n,Math.min(t,n.length)),a=n.slice(0,i),o=Na(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=Na(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Wa&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=U(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ma(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=je()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function Qa({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Gn.activate(e,t,n,a)}function $a(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function eo(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function to(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=C(),no=ce(),ro=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function io(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(e){if(e.dataTransfer===null)return;let r=null;for(let t of e.composedPath())if(r=ro(t),r!==null)break;if(r===null)return;let i=t.includes(r)?t:[r],a=i.map(e=>gn(e)).filter(e=>e!==null);a.length!==0&&(n=i,e.dataTransfer.setData(_n,a.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function ao(e){return e.split(`/`).filter(Boolean).length}function oo(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>ao(e)-ao(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>ao(e)-ao(t));for(let e of s)a.push({type:`add`,path:e});return a}function so(e,t){let[n,r]=(0,q.useState)(new Map),[i,a]=(0,q.useState)(new Map),[o,s]=(0,q.useState)(0),[l,u]=(0,q.useState)(new Set),d=(0,q.useRef)(new Map),f=(0,q.useRef)(new Set),p=(0,q.useRef)(new Set),m=(0,q.useRef)(!0),g=(0,q.useRef)(0),_=(0,q.useRef)([]),v=(0,q.useCallback)(function n(i,o=!1){let l=d.current.get(i);if(l)return o?l.then(()=>n(i,!0)):l;if(!o&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let v=A.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});s(e=>e+1),o||u(e=>new Set(e).add(i));let y=(async()=>{g.current>=4?await new Promise(e=>_.current.push(e)):g.current++;try{return m.current?await O(c,v,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=_.current.shift();e?e():g.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),a(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=h(e.cause);a(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{d.current.delete(i),m.current&&(s(e=>e-1),o||u(e=>{let t=new Set(e);return t.delete(i),t}))});return d.current.set(i,y),y},[t,e]);(0,q.useEffect)(()=>(m.current=!0,v(``),()=>{m.current=!1}),[v]);let y=(0,q.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),b=(0,q.useMemo)(()=>new Set([``,...y.filter(e=>e.kind===`directory`).map(e=>e.path)]),[y]);return{entries:y,load:v,refresh:(0,q.useCallback)(()=>{let e=[...p.current].filter(e=>b.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await v(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[v,b]),isPending:o>0,loadingDirectories:l,ready:n.has(``),error:[...i].find(([e])=>b.has(e))?.[1]??null}}var $=e(y(),1);function co(e){return e.kind===`directory`?`${e.path}/`:e.path}function lo(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(cn,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(M,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(N,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(P,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function uo(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(Qt,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(Zt,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function fo({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s}){let{resolvedTheme:c}=he(),l=v(),u=fn(e),{entries:d,load:f,refresh:p,ready:m,error:h,isPending:g,loadingDirectories:_}=so(e,t),[y,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(!1),w=Ce({environmentId:e,cwd:t,query:y.slice(0,256)},200),T=(0,q.useMemo)(()=>{let e=new Map(d.map(e=>[e.path,e]));if(y.trim()&&!w.isPending)for(let t of w.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[d,w.entries,w.isPending,y]),E=(0,q.useMemo)(()=>new Map(T.map(e=>[e.path,e.kind])),[T]),D=(0,q.useRef)(E),O=(0,q.useMemo)(()=>T.map(co),[T]),k=(0,q.useMemo)(()=>T.filter(e=>e.kind===`directory`).map(co),[T]),ee=(0,q.useRef)(null),te=(0,q.useRef)(!1),A=(0,q.useRef)(null),j=(0,q.useRef)(null),ne=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{ne.current={x:e.clientX,y:e.clientY,at:e.timeStamp}};return document.addEventListener(`contextmenu`,e,!0),()=>document.removeEventListener(`contextmenu`,e,!0)},[]);let re=async(n,r)=>{let i=me();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=hn(a),s=ne.current,c=s!==null&&performance.now()-s.at<1e3,d=r.anchorElement.getBoundingClientRect(),f=c?{x:s.x,y:s.y}:{x:d.left,y:d.bottom},p={environmentId:e,filePath:a,workspaceRoot:t},m=u.buildItems(p);try{let e=await i.contextMenu.show([...m,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],f);if(e===null)return;if(m.some(t=>t.id===e)||e.startsWith(`editor:`)){await u.activate(e,p);return}if(e===`copy-mention`){try{await L(o),fe.add({type:`success`,title:`Mention copied`,description:a})}catch(e){fe.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}return}if(e===`add-to-chat`){let e=l?.current;if(!e){fe.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||fe.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}finally{r.close()}},ie=(0,q.useRef)(re);(0,q.useEffect)(()=>{ie.current=re});let ae=(0,q.useRef)(_),oe=(0,q.useRef)(null),M=(0,q.useMemo)(()=>io({deselect:e=>oe.current?.getItem(e)?.deselect()}),[]),{model:N}=Et({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{ie.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Ot,onSelectionChange:e=>{if(M.handleSelectionChange(e),te.current||M.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&D.current.get(t)===`file`&&(A.current=t,a(t))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ae.current.has(e.path.replace(/\/$/,``))?{icon:`t3-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>x(e??``),unsafeCSS:Tt});(0,q.useEffect)(()=>{ae.current!==_&&(ae.current=_,N.setComposition(N.getComposition()))},[_,N]);let P=bn(N),ce=wt(N,e=>Dt(e,k)),le=()=>{let e=!(S||ce);C(e),Ct(N,k,e)},ue=()=>{x(``),P.close()},F=(0,q.useRef)(new Set);(0,q.useEffect)(()=>{let e=new Set(k);for(let t of F.current)e.has(t)||F.current.delete(t);let t=()=>{if(!N.isSearchOpen())for(let e of k){let t=N.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?F.current.has(e)||(F.current.add(e),f(e.replace(/\/$/,``))):(t?.isDirectory()&&F.current.has(e)&&C(!1),F.current.delete(e))}};return t(),N.subscribe(t)},[k,f,N]),(0,q.useEffect)(()=>{N.setGitStatus(T.filter(e=>e.ignored).map(e=>({path:co(e),status:`ignored`})))},[T,N]),(0,q.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await f(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[f,r]);let de=e=>{if(x(e),e.trim().length===0){P.close();return}P.setValue(e)},I=()=>{p(),y.trim()&&w.refresh(),o?.()};pn({mutationId:s,refresh:()=>{p(),y.trim()&&w.refresh()},resourceKey:`files:${e}:${t}`}),(0,q.useEffect)(()=>{if(!m||ee.current===O)return;D.current=E;let e=ee.current;if(ee.current=O,e===null){N.resetPaths(O);return}let t=oo(e,O);t.length>0&&N.batch(t)},[m,E,N,O]),(0,q.useEffect)(()=>{S&&!y.trim()&&Ct(N,k,!0)},[k,S,N,y]),(0,q.useEffect)(()=>{if(!r){j.current=null;return}let e=E.get(r);if(e===void 0){j.current=null;return}let t={path:r,revealId:i},n=j.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=N.getItem(a);if(!o)return;if(N.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&A.current===r){A.current=null,j.current=t;return}A.current=null,j.current=t,te.current=!0,x(``),N.closeSearch();for(let e of N.getSelectedPaths())N.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=N.getItem(`${c}/`)??N.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),N.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{te.current=!1})},[E,N,r,i]);let pe=(0,q.useRef)(null);return(0,q.useEffect)(()=>{oe.current=N},[N]),(0,q.useEffect)(()=>{let e=pe.current;if(e===null)return;let t=e=>M.handleDragStart(e),n=()=>M.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[M]),(0,$.jsxs)(`div`,{ref:pe,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(lo,{isPending:g,onRefresh:I}),(0,$.jsx)(uo,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:P.value,onValueChange:de,onClose:ue}),k.length>0?(0,$.jsx)(b,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":S||ce?`Collapse all folders`:`Expand all folders`,onClick:le,children:(0,$.jsx)(se,{className:`size-3.5`,icon:ce?no.ChevronsDownUp:no.ChevronsUpDown})}):null]}),h||w.error?(0,$.jsxs)(`button`,{type:`button`,onClick:I,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[h??w.error,` Click to retry.`]}):null,y.trim()&&w.truncated&&!w.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!m||w.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(xt,{model:N,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:St(c)})]})}function po(e,t){let n=ie(t),r=oe(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:n&&r===`/`?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>({label:e,path:a+i.slice(0,t+1).join(r),kind:t===i.length-1?`file`:`directory`}))]}function mo(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function ho(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function go(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function _o(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=x(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(M,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(N,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(P,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function vo(e){let t=(0,Q.c)(44),n=rn(e.environmentId,e.cwd,e.directoryPath),r=`files:${e.environmentId}:${e.cwd}`,i;t[0]!==n.refresh||t[1]!==e.workspaceMutationId||t[2]!==r?(i={mutationId:e.workspaceMutationId,refresh:n.refresh,resourceKey:r},t[0]=n.refresh,t[1]=e.workspaceMutationId,t[2]=r,t[3]=i):i=t[3],pn(i);let{resolvedTheme:a}=he(),c;t[4]===n.data?.entries?c=t[5]:(c=n.data?.entries??[],t[4]=n.data?.entries,t[5]=c);let u=c,p=n.data?.truncated??!1,m;t[6]!==u||t[7]!==e.directoryPath?(m=mo(u,e.directoryPath),t[6]=u,t[7]=e.directoryPath,t[8]=m):m=t[8];let h=m,_=n.data!==null,v,y,b,S,C;if(t[9]!==e){let n=ho(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));v=d,y=`start`,b=`bottom`,S=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},C=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(o,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(dn,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,go(n,e.projectName)]})]}),(0,$.jsx)(g,{})]}):null,t[9]=e,t[10]=v,t[11]=y,t[12]=b,t[13]=S,t[14]=C}else v=t[10],y=t[11],b=t[12],S=t[13],C=t[14];let w;t[15]!==h||t[16]!==_||t[17]!==n.data||t[18]!==n.error||t[19]!==n.isPending||t[20]!==n.refresh||t[21]!==p||t[22]!==e||t[23]!==a?(w=n.isPending&&n.data===null?(0,$.jsxs)(o,{disabled:!0,children:[(0,$.jsx)(I,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(o,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(cn,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!_&&!p?(0,$.jsx)(o,{disabled:!0,children:`This folder is no longer available.`}):h.length===0?(0,$.jsx)(o,{disabled:!0,children:p?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(f,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:h.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,r=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xt,{pathValue:t.path,kind:t.kind,theme:a}),(0,$.jsxs)(P,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(`span`,{className:x(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(N,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(o,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[r,(0,$.jsx)(T,{})]},t.path):(0,$.jsx)(l,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:r})},t.path)})}),t[15]=h,t[16]=_,t[17]=n.data,t[18]=n.error,t[19]=n.isPending,t[20]=n.refresh,t[21]=p,t[22]=e,t[23]=a,t[24]=w):w=t[24];let E;t[25]!==e.directoryPath||t[26]!==w?(E=(0,$.jsx)(s,{children:w},e.directoryPath),t[25]=e.directoryPath,t[26]=w,t[27]=E):E=t[27];let D;t[28]!==n.data||t[29]!==n.error||t[30]!==n.isPending||t[31]!==n.refresh?(D=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{}),(0,$.jsxs)(o,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(cn,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[28]=n.data,t[29]=n.error,t[30]=n.isPending,t[31]=n.refresh,t[32]=D):D=t[32];let O;t[33]===p?O=t[34]:(O=p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{}),(0,$.jsx)(o,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[33]=p,t[34]=O);let k;return t[35]!==v||t[36]!==D||t[37]!==O||t[38]!==y||t[39]!==b||t[40]!==S||t[41]!==C||t[42]!==E?(k=(0,$.jsxs)(v,{align:y,side:b,onKeyDown:S,children:[C,E,D,O]}),t[35]=v,t[36]=D,t[37]=O,t[38]=y,t[39]=b,t[40]=S,t[41]=C,t[42]=E,t[43]=k):k=t[43],k}function yo(e){let t=(0,Q.c)(35),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,q.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,d=`Browse ${e.crumb.label}`,f;t[7]===d?f=t[8]:(f=(0,$.jsx)(m,{render:(0,$.jsx)(`button`,{type:`button`,"aria-label":d,className:`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left text-muted-foreground outline-none pointer-coarse:after:-inset-y-3 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`})}),t[7]=d,t[8]=f);let p;t[9]===e.crumb.label?p=t[10]:(p=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[9]=e.crumb.label,t[10]=p);let h;t[11]!==f||t[12]!==p?(h=(0,$.jsx)(M,{render:f,children:p}),t[11]=f,t[12]=p,t[13]=h):h=t[13];let g=e.crumb.path||e.projectName,_;t[14]===g?_=t[15]:(_=(0,$.jsx)(N,{side:`top`,children:g}),t[14]=g,t[15]=_);let v;t[16]!==h||t[17]!==_?(v=(0,$.jsxs)(P,{children:[h,_]}),t[16]=h,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==i||t[20]!==l||t[21]!==n||t[22]!==e.crumb.path||t[23]!==e.cwd||t[24]!==e.environmentId||t[25]!==e.onOpenFile||t[26]!==e.projectName||t[27]!==e.relativePath||t[28]!==e.workspaceMutationId?(y=n?(0,$.jsx)(vo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[19]=i,t[20]=l,t[21]=n,t[22]=e.crumb.path,t[23]=e.cwd,t[24]=e.environmentId,t[25]=e.onOpenFile,t[26]=e.projectName,t[27]=e.relativePath,t[28]=e.workspaceMutationId,t[29]=y):y=t[29];let b;return t[30]!==l||t[31]!==n||t[32]!==y||t[33]!==v?(b=(0,$.jsxs)(u,{open:n,onOpenChange:l,children:[v,y]}),t[30]=l,t[31]=n,t[32]=y,t[33]=v,t[34]=b):b=t[34],b}function bo(e){let t=(0,Q.c)(12),n;t[0]===e.relativePath?n=t[1]:(n=ie(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.relativePath?(i=po(e.projectName,e.relativePath),t[2]=e.projectName,t[3]=e.relativePath,t[4]=i):i=t[4];let a=i,o;if(t[5]!==a||t[6]!==r||t[7]!==e){let n;t[9]!==r||t[10]!==e?(n=(t,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":t.kind===`file`,children:[n>0?(0,$.jsx)(T,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,t.kind===`file`?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(_o,{current:!0,label:t.label,pathLabel:t.path})}):r?(0,$.jsx)(_o,{label:t.label,pathLabel:t.path}):(0,$.jsx)(yo,{...e,crumb:t})]},t.path||`project`),t[9]=r,t[10]=e,t[11]=n):n=t[11],o=a.map(n),t[5]=a,t[6]=r,t[7]=e,t[8]=o}else o=t[8];return o}function xo(e){let t=(0,Q.c)(14),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?xe(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;return t[8]!==o||t[9]!==e.cwd||t[10]!==e.onTaskListChange||t[11]!==e.text||t[12]!==e.threadRef?(s=(0,$.jsx)(F,{text:e.text,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[8]=o,t[9]=e.cwd,t[10]=e.onTaskListChange,t[11]=e.text,t[12]=e.threadRef,t[13]=s):s=t[13],s}function So({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Co(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function wo({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||So({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Co(e)&&(i.preventDefault(),i.stopImmediatePropagation(),So({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function To(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function Eo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Do(e,t,n){return`${e}:${t}:${Eo(n)}`}function Oo(e,t){return e===null||e===`.`||j(e,t)===`.`?null:e}var ko=e=>/\.(?:md|mdx)$/i.test(e);function Ao(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function jo(e){return e.attachmentOpen||e.relativePath&&ie(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Mo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function No(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Po=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},Fo=500;function Io(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=ye(n,w),s=be(A.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Po({debounceMs:Fo,canPersist:()=>R(n,w),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>on(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let f=d,p;t[8]===f?p=t[9]:(p=[f],t[8]=f,t[9]=p),(0,q.useEffect)(f.setup,p);let m,h;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==f?(m=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=$t(n,r,i);t&&f.change(t.contents)}),()=>{e=!0}},h=[o,r,n,i,f],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=f,t[15]=m,t[16]=h):(m=t[15],h=t[16]),(0,q.useEffect)(m,h),f}var Lo=`t3code.fileExplorerOpen`,Ro=`t3code.renderMarkdown`,zo=`t3code.renderBrowserFile`,Bo=`t3code.renderTable`;function Vo(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),[a,o]=(0,q.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=pt(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(ue,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(ue,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function Ho(e){let t=(0,Q.c)(18),n=pt(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=No({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=qt(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=e.title,u;t[12]===e.absolutePath?u=t[13]:(u=Nt(e.absolutePath),t[12]=e.absolutePath,t[13]=u);let d;return t[14]!==e.title||t[15]!==c||t[16]!==u?(d=(0,$.jsx)(Mt,{src:c,title:l,pdf:u}),t[14]=e.title,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function Uo(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),a=Gt(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(Wo)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],pn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=pt(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(le,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function Wo(){}function Go(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=No({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=qt(e.environmentId,r),a=Gt(e.environmentId,r),[o,s]=(0,q.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(qo)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],pn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(zt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(Ko)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ft,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(At,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function Ko(){}function qo(){}function Jo(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function Yo(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Lt}]`))e.removeAttribute(Lt);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Lt,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Lt,``))}var Xo=30,Zo=20,Qo=2;function $o(e,t,n){let r=(0,Q.c)(5),[i]=(0,q.useState)(es),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(Yo(r,t===null||u===void 0?null:Jo(u,t)),!(a instanceof Ge))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return To({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=Zo,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>Qo&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:Jo(i,t),s=o===null?null:f(o);if(o===null||s===null){e<Xo&&m(e+1);return}Yo(r,o),d.scrollTop=s,c.handledRequestId=n,p(o)})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function es(){return new Map}var ts=(e,t,n)=>new Za(e,t,n);function ns(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Do(t,n,r)}`}}function rs(e,t){if(e?.isWorkingPool()!==!0||(t.lang??sn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
|
|
32
32
|
`);e!==-1;e=t.contents.indexOf(`
|
|
33
|
-
`,e+1))n+=1;return n<=De}function is(e){let t=(0,Q.c)(15),n=Me(),[r,i]=(0,q.useState)(null),a;t[0]!==e||t[1]!==n?(a=rs(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,q.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function as(e){let t=(0,Q.c)(68),{environmentId:i,cwd:a,relativePath:o,composerDraftTarget:s,contents:c,resolvedTheme:l,revealRequestId:u,wordWrap:d,onPostRender:f,onPendingChange:p}=e,m=r(fs),h=r(ds),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,q.useState)(g),[y,b]=(0,q.useState)(null),x=y?.revealRequestId===u?y.range:null,S;t[1]===u?S=t[2]:(S=e=>{b({revealRequestId:u,range:e})},t[1]=u,t[2]=S);let C=S,w=(0,q.useRef)(null),T=(0,q.useRef)(null),E;t[3]!==a||t[4]!==i||t[5]!==p||t[6]!==o?(E={environmentId:i,cwd:a,relativePath:o,onPendingChange:p},t[3]=a,t[4]=i,t[5]=p,t[6]=o,t[7]=E):E=t[7];let D=Io(E),O;t[8]!==c||t[9]!==a||t[10]!==i||t[11]!==o?(O=()=>ns(i,a,o,c),t[8]=c,t[9]=a,t[10]=i,t[11]=o,t[12]=O):O=t[12];let[k,ee]=(0,q.useState)(O),[te,A]=(0,q.useState)(null);c!==(te??k.contents)&&(ee(ns(i,a,o,c)),A(null));let{ready:j,onPostRender:ne}=is(k),re=(0,q.useRef)(null),ie;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ie={onAttach:e=>{re.current=e},onComplete:()=>{re.current=null}},t[13]=ie):ie=t[13];let ae=ie,oe;t[14]!==m||t[15]!==s||t[16]!==a||t[17]!==i||t[18]!==o||t[19]!==D?(oe=e=>{let{file:t,lineAnnotations:r}=e;if(t.contents===nn(i,a,o)||(A(t.contents),en(i,a,o,t.contents),D.change(t.contents),!r))return;let c=mt(r);v(e=>e===r?e:c);for(let e of c)for(let r of e.metadata.entries)r.kind===`comment`&&m(s,n({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:r.text,contents:t.contents}))},t[14]=m,t[15]=s,t[16]=a,t[17]=i,t[18]=o,t[19]=D,t[20]=oe):oe=t[20];let M=oe,se;t[21]!==s||t[22]!==h||t[23]!==C?(se=e=>{C(null),h(s,e),v(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=s,t[22]=h,t[23]=C,t[24]=se):se=t[24];let N=se,P;t[25]!==m||t[26]!==s||t[27]!==c||t[28]!==_||t[29]!==o||t[30]!==C?(P=(e,t)=>{C(null);let r=_.flatMap(us).find(t=>t.id===e);r&&m(s,n({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:t,contents:c})),v(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=m,t[26]=s,t[27]=c,t[28]=_,t[29]=o,t[30]=C,t[31]=P):P=t[31];let ce=P,le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{re.current?.setSelections([]),re.current?.blur();let{startLine:t,endLine:n}=gt(e),r={id:ht(),kind:`draft`,startLine:t,endLine:n,text:``};v(e=>{let t=e.flatMap(cs),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=le):le=t[32];let ue=le,F;t[33]===_?F=t[34]:(F=_.some(os),t[33]=_,t[34]=F);let de=F,I,fe;t[35]!==de||t[36]!==C?(I=()=>{let e=w.current;if(e)return wo({root:e,editor:{setSelections:e=>re.current?.setSelections(e)},isBlocked:()=>de,onDismiss:()=>C(null)})},fe=[de,C],t[35]=de,t[36]=C,t[37]=I,t[38]=fe):(I=t[37],fe=t[38]),(0,q.useEffect)(I,fe);let L;t[39]===C?L=t[40]:(L=e=>{C(e),e&&ue(e)},t[39]=C,t[40]=L);let pe=L,me;t[41]!==ne||t[42]!==f||t[43]!==x?(me=(e,t,n)=>{f(e,t,n),ne(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[41]=ne,t[42]=f,t[43]=x,t[44]=me):me=t[44];let he=me,ge;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ge={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ge):ge=t[45];let _e=!de,ve=!de,ye=d?`wrap`:`scroll`,R;t[46]===l?R=t[47]:(R=Te(l),t[46]=l,t[47]=R);let be;t[48]!==pe||t[49]!==he||t[50]!==l||t[51]!==C||t[52]!==_e||t[53]!==ve||t[54]!==ye||t[55]!==R?(be={disableFileHeader:!0,enableGutterUtility:_e,enableLineSelection:ve,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:pe,overflow:ye,theme:R,preferredHighlighter:un,themeType:l,unsafeCSS:Bt,onPostRender:he},t[48]=pe,t[49]=he,t[50]=l,t[51]=C,t[52]=_e,t[53]=ve,t[54]=ye,t[55]=R,t[56]=be):be=t[56];let xe;t[57]!==N||t[58]!==ce?(xe=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(lt,{kind:e.kind,rangeLabel:_t(e.startLine,e.endLine),text:e.text,onCancel:()=>N(e.id),onComment:t=>ce(e.id,t),onDelete:()=>N(e.id)},e.id))}),t[57]=N,t[58]=ce,t[59]=xe):xe=t[59];let Se;return t[60]!==j||t[61]!==k||t[62]!==M||t[63]!==_||t[64]!==x||t[65]!==be||t[66]!==xe?(Se=(0,$.jsx)(Ne,{createEditor:ts,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(Pe,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ge,children:(0,$.jsx)(vt,{file:k,edit:j,editorOptions:ae,onEditChange:M,options:be,selectedLines:x,lineAnnotations:_,renderAnnotation:xe,className:`min-h-full`})})})}),t[60]=j,t[61]=k,t[62]=M,t[63]=_,t[64]=x,t[65]=be,t[66]=xe,t[67]=Se):Se=t[67],Se}function os(e){return e.metadata.entries.some(ss)}function ss(e){return e.kind===`draft`}function cs(e){let t=e.metadata.entries.filter(ls);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function ls(e){return e.kind!==`draft`}function us(e){return e.metadata.entries}function ds(e){return e.removeReviewComment}function fs(e){return e.addReviewComment}function ps(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=Io(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=an(n,r,i)?.contents??a,c=Mo(s,t,o);c!==s&&(en(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(kt,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function ms(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function hs(){try{return g(Lo,s)??!0}catch(e){return console.error(e),!0}}function gs(e){let t=(0,Q.c)(156),{environmentId:n,cwd:r,projectName:i,relativePath:a,attachment:o,threadRef:c,composerDraftTarget:l,keybindings:u,availableEditors:d,revealLine:f,revealRequestId:p,onOpenFile:m,onPendingChange:h,selectedFilePending:g,workspaceMutationId:_}=e,v;t[0]!==o||t[1]!==r||t[2]!==a?(v=o===void 0?Oo(a,r):a,t[0]=o,t[1]=r,t[2]=a,t[3]=v):v=t[3];let y=v,b=typeof l==`string`,{resolvedTheme:T}=he(),O=_e(vs),A=ye(n,C),j=ge(),oe=de(n),M=pe(n),N=Jt(n),P;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(P={reportFailure:!1},t[4]=P):P=t[4];let ce=Wt(Ht.createUrl,P),le;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(le={reportFailure:!1},t[5]=le):le=t[5];let ue=be(Yt.open,le),F;t[6]===y?F=t[7]:(F=y!==null&&re(y),t[6]=y,t[7]=F);let L=F,me;t[8]!==L||t[9]!==y?(me=y!==null&&!L&&ae(y),t[8]=L,t[9]=y,t[10]=me):me=t[10];let R=me,Ce;t[11]!==L||t[12]!==y?(Ce=y!==null&&!L&&ne(y),t[11]=L,t[12]=y,t[13]=Ce):Ce=t[13];let z=Ce,we=z||L||R,Te;t[14]===y?Te=t[15]:(Te=y!==null&&Nt(y),t[14]=y,t[15]=Te);let Ee=Te,De;t[16]!==Ee||t[17]!==y?(De=y!==null&&!Ee&&Kt(y),t[16]=Ee,t[17]=y,t[18]=De):De=t[18];let Oe=De,ke;t[19]!==o||t[20]!==y?(ke=o!==void 0||y!==null&&ie(y),t[19]=o,t[20]=y,t[21]=ke):ke=t[21];let B=ke,Ae=te(n),{canReadFiles:je}=Ae,Me=ye(n,w),V=tn(n,r,y,o===void 0&&y!==null),Ne=V.readError?.resolvedPath??V.readError?.operationPath,Pe=V.isNotFile&&!B,H=Pe?null:y,[Fe,Ie]=(0,q.useState)(hs),Le=o!==void 0,Re;t[22]!==Fe||t[23]!==H||t[24]!==Le?(Re=jo({relativePath:H,explorerOpen:Fe,attachmentOpen:Le}),t[22]=Fe,t[23]=H,t[24]=Le,t[25]=Re):Re=t[25];let ze=Re,[Be,Ve]=S(Ro,!1,s),[He,Ue]=S(zo,!0,s),[We,Ge]=S(Bo,!0,s),[Ke,qe]=(0,q.useState)(null),Je=(0,q.useRef)(null),Xe;t[26]===H?Xe=t[27]:(Xe=H?ko(H):!1,t[26]=H,t[27]=Xe);let Ze=Xe,Qe;t[28]!==o||t[29]!==H?(Qe=H&&o===void 0?Rt({name:H}):null,t[28]=o,t[29]=H,t[30]=Qe):Qe=t[30];let $e=Qe,et=f===null||Ke?.path===y&&Ke.requestId===p,tt=Ze&&Be&&et,nt=Ee||Oe&&He&&et,rt=$e!==null&&We&&et,U=Ze?`markdown`:$e?`table`:Oe?`html`:null,it=H!==null&&o===void 0&&U!==null,at=ve(),W=H!==null&&V.data!==null&&!(Ze&&tt)&&!($e&&rt)&&!nt,ot=Ze?tt:$e?rt:nt,st=Ze?Ve:$e?Ge:Ue,ct;t[31]!==o||t[32]!==A||t[33]!==L||t[34]!==N||t[35]!==H?(ct=A&&H!==null&&o===void 0&&!L&&N&&Kt(H),t[31]=o,t[32]=A,t[33]=L,t[34]=N,t[35]=H,t[36]=ct):ct=t[36];let G=ct,lt;t[37]!==o||t[38]!==r||t[39]!==y?(lt=y&&o===void 0?xe(y,r):null,t[37]=o,t[38]=r,t[39]=y,t[40]=lt):lt=t[40];let K=lt,ut=$o(y,f,p),dt=o===void 0&&y!==null&&(Pe||!we&&!Ee)&&!g,ft=`file:${n}:${r}:${y??``}`,pt;t[41]!==V.refresh||t[42]!==dt||t[43]!==ft||t[44]!==_?(pt={enabled:dt,mutationId:_,refresh:V.refresh,resourceKey:ft},t[41]=V.refresh,t[42]=dt,t[43]=ft,t[44]=_,t[45]=pt):pt=t[45],pn(pt);let mt;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(mt=()=>{(Je.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[46]=mt):mt=t[46];let ht;t[47]===y?ht=t[48]:(ht=[y],t[47]=y,t[48]=ht),(0,q.useEffect)(mt,ht);let gt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>{Ie(_s)},t[49]=gt):gt=t[49];let _t=gt,vt;t[50]!==K||t[51]!==A||t[52]!==je||t[53]!==ce||t[54]!==r||t[55]!==M||t[56]!==ue||t[57]!==c?(vt=()=>{je&&A&&K&&M&&(async()=>{let e=await Ut({threadRef:c,filePath:K,workspaceRoot:r,httpBaseUrl:M,createAssetUrl:ce,openPreview:ue});if(e._tag===`Success`||k(e))return;let t=ee(e);fe.add(Se({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[50]=K,t[51]=A,t[52]=je,t[53]=ce,t[54]=r,t[55]=M,t[56]=ue,t[57]=c,t[58]=vt):vt=t[58];let bt=vt;if(o===void 0&&!je){if(Ae.isPending){let e;return t[59]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(I,{className:`size-4`}),`Checking file access...`]}),t[59]=e):e=t[59],e}let e=Ae.error??`This connection cannot read host files.`,n;return t[60]===e?n=t[61]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[60]=e,t[61]=n),n}let xt;t[62]!==K||t[63]!==o||t[64]!==d||t[65]!==G||t[66]!==it||t[67]!==r||t[68]!==n||t[69]!==Fe||t[70]!==bt||t[71]!==B||t[72]!==u||t[73]!==m||t[74]!==H||t[75]!==j||t[76]!==i||t[77]!==y||t[78]!==oe||t[79]!==ot||t[80]!==U||t[81]!==p||t[82]!==st||t[83]!==W||t[84]!==at||t[85]!==O||t[86]!==_?(xt=y&&o===void 0?(0,$.jsxs)(`div`,{className:Pt,"data-surface-subheader":!0,children:[(0,$.jsx)(kt,{radius:`none`,ref:Je,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(bo,{cwd:r,environmentId:n,onOpenFile:m,projectName:i,relativePath:y,workspaceMutationId:_})})}),K&&(n===j||oe.mode!==`local-exec`)?(0,$.jsx)(mn,{environmentId:n,keybindings:u,availableEditors:d,openInCwd:K,compact:!0}):null,it&&U?(0,$.jsx)(jt,{label:ms(U,ot),pressed:ot,onPress:()=>{let e=!ot;st(e),qe(e&&y!==null?{path:y,requestId:p}:null)},children:(0,$.jsx)(se,{className:`size-3.5`,icon:ot?no.Code2:U===`table`?no.Table2:no.Eye})}):null,W?(0,$.jsx)(jt,{label:O?`Disable word wrap`:`Enable word wrap`,pressed:O,onPress:()=>at({wordWrap:!O}),children:(0,$.jsx)(D,{className:`size-3.5`})}):null,G?(0,$.jsx)(jt,{label:`Open file in preview browser`,onPress:bt,children:(0,$.jsx)(cn,{className:`size-3.5`})}):null,!B&&H!==null?(0,$.jsx)(jt,{label:Fe?`Hide file explorer`:`Show file explorer`,pressed:Fe,onPress:_t,children:(0,$.jsx)(E,{className:`size-3.5`})}):null]}):null,t[62]=K,t[63]=o,t[64]=d,t[65]=G,t[66]=it,t[67]=r,t[68]=n,t[69]=Fe,t[70]=bt,t[71]=B,t[72]=u,t[73]=m,t[74]=H,t[75]=j,t[76]=i,t[77]=y,t[78]=oe,t[79]=ot,t[80]=U,t[81]=p,t[82]=st,t[83]=W,t[84]=at,t[85]=O,t[86]=_,t[87]=xt):xt=t[87];let St;t[88]!==o||t[89]!==Me||t[90]!==Ae.isPending||t[91]!==B||t[92]!==y?(St=y&&!o&&!B&&!Me&&!Ae.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[88]=o,t[89]=Me,t[90]=Ae.isPending,t[91]=B,t[92]=y,t[93]=St):St=t[93];let Ct;t[94]!==o||t[95]!==V.data||t[96]!==we||t[97]!==H||t[98]!==nt?(Ct=H&&o===void 0&&!we&&!nt&&V.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,V.data.byteLength.toLocaleString(),` byte file.`]}):null,t[94]=o,t[95]=V.data,t[96]=we,t[97]=H,t[98]=nt,t[99]=Ct):Ct=t[99];let wt=H?`flex`:`hidden`,Tt;t[100]===wt?Tt=t[101]:(Tt=x(`min-w-0 flex-1 flex-col overflow-hidden`,wt),t[100]=wt,t[101]=Tt);let Et;t[102]!==K||t[103]!==o||t[104]!==Ne||t[105]!==Me||t[106]!==l||t[107]!==r||t[108]!==b||t[109]!==n||t[110]!==V.data||t[111]!==V.error||t[112]!==V.readError||t[113]!==R||t[114]!==Pe||t[115]!==B||t[116]!==z||t[117]!==Ze||t[118]!==L||t[119]!==ut||t[120]!==h||t[121]!==y||t[122]!==nt||t[123]!==tt||t[124]!==rt||t[125]!==T||t[126]!==p||t[127]!==$e||t[128]!==c||t[129]!==O||t[130]!==_?(Et=Pe?null:y&&o?(0,$.jsx)(It,{name:o.name,mimeType:o.mimeType,sizeBytes:o.sizeBytes,asset:{environmentId:n,attachmentId:o.id},htmlRender:o.htmlRender===!0,threadRef:c},`${n}:${o.id}`):y&&L&&K?(0,$.jsx)(Uo,{environmentId:n,threadRef:c,draft:b,absolutePath:K,workspaceRoot:r,name:y,workspaceMutationId:_},`${n}:${c.threadId}:${K}`):y&&R&&K?(0,$.jsx)(Go,{environmentId:n,threadRef:c,draft:b,absolutePath:K,workspaceRoot:r,name:y,workspaceMutationId:_},`${n}:${c.threadId}:${K}`):y&&z&&K?(0,$.jsx)(Vo,{environmentId:n,threadRef:c,draft:b,absolutePath:K,workspaceRoot:r,alt:y,workspaceMutationId:_},K):y&&nt&&K?(0,$.jsx)(Ho,{environmentId:n,threadRef:c,draft:b,absolutePath:K,workspaceRoot:r,title:y,workspaceMutationId:_},K):y&&V.error&&V.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:V.readError?Ao(V.readError):V.error}),Ne?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:Ne})]}):null,B?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:V.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):y&&V.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}):y&&V.data?Ze&&tt?(0,$.jsx)(ps,{environmentId:n,cwd:r,relativePath:y,threadRef:c,contents:V.data.contents,readOnly:B||!Me,onPendingChange:h},y):$e&&rt?(0,$.jsx)(Vt,{name:y,text:V.data.contents,delimiter:$e},y):V.data.truncated||B||!Me?(0,$.jsx)(yt,{name:y,text:V.data.contents,cacheKey:Do(r,y,V.data.contents),onPostRender:ut}):(0,$.jsx)(Ye,{children:(0,$.jsx)(as,{environmentId:n,cwd:r,relativePath:y,composerDraftTarget:l,contents:V.data.contents,resolvedTheme:T,revealRequestId:p,wordWrap:O,onPostRender:ut,onPendingChange:h},`${y}:${T}`)}):null,t[102]=K,t[103]=o,t[104]=Ne,t[105]=Me,t[106]=l,t[107]=r,t[108]=b,t[109]=n,t[110]=V.data,t[111]=V.error,t[112]=V.readError,t[113]=R,t[114]=Pe,t[115]=B,t[116]=z,t[117]=Ze,t[118]=L,t[119]=ut,t[120]=h,t[121]=y,t[122]=nt,t[123]=tt,t[124]=rt,t[125]=T,t[126]=p,t[127]=$e,t[128]=c,t[129]=O,t[130]=_,t[131]=Et):Et=t[131];let Dt;t[132]!==Tt||t[133]!==Et?(Dt=(0,$.jsx)(`div`,{className:Tt,children:Et}),t[132]=Tt,t[133]=Et,t[134]=Dt):Dt=t[134];let Ot;t[135]!==r||t[136]!==n||t[137]!==V.refresh||t[138]!==we||t[139]!==Ee||t[140]!==m||t[141]!==H||t[142]!==i||t[143]!==y||t[144]!==p||t[145]!==ze||t[146]!==_?(Ot=ze?(0,$.jsx)(`aside`,{className:x(`flex min-h-0 shrink-0 bg-background`,H?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,$.jsx)(fo,{environmentId:n,cwd:r,projectName:i,selectedPath:y,selectedPathRevealId:p,onOpenFile:m,workspaceMutationId:_,...H&&!we&&!Ee?{onRefreshSelectedFile:V.refresh}:{}},`${n}:${r}`)}):null,t[135]=r,t[136]=n,t[137]=V.refresh,t[138]=we,t[139]=Ee,t[140]=m,t[141]=H,t[142]=i,t[143]=y,t[144]=p,t[145]=ze,t[146]=_,t[147]=Ot):Ot=t[147];let At;t[148]!==Dt||t[149]!==Ot?(At=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[Dt,Ot]}),t[148]=Dt,t[149]=Ot,t[150]=At):At=t[150];let Mt;return t[151]!==xt||t[152]!==St||t[153]!==Ct||t[154]!==At?(Mt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[xt,St,Ct,At]}),t[151]=xt,t[152]=St,t[153]=Ct,t[154]=At,t[155]=Mt):Mt=t[155],Mt}function _s(e){let t=!e;try{p(Lo,t,s)}catch(e){console.error(e)}return t}function vs(e){return e.wordWrap}export{gs as default};
|
|
34
|
-
//# sourceMappingURL=FilePreviewPanel-
|
|
33
|
+
`,e+1))n+=1;return n<=De}function is(e){let t=(0,Q.c)(15),n=Me(),[r,i]=(0,q.useState)(null),a;t[0]!==e||t[1]!==n?(a=rs(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,q.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function as(e){let t=(0,Q.c)(68),{environmentId:i,cwd:a,relativePath:o,composerDraftTarget:s,contents:c,resolvedTheme:l,revealRequestId:u,wordWrap:d,onPostRender:f,onPendingChange:p}=e,m=r(fs),h=r(ds),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,q.useState)(g),[y,b]=(0,q.useState)(null),x=y?.revealRequestId===u?y.range:null,S;t[1]===u?S=t[2]:(S=e=>{b({revealRequestId:u,range:e})},t[1]=u,t[2]=S);let C=S,w=(0,q.useRef)(null),T=(0,q.useRef)(null),E;t[3]!==a||t[4]!==i||t[5]!==p||t[6]!==o?(E={environmentId:i,cwd:a,relativePath:o,onPendingChange:p},t[3]=a,t[4]=i,t[5]=p,t[6]=o,t[7]=E):E=t[7];let D=Io(E),O;t[8]!==c||t[9]!==a||t[10]!==i||t[11]!==o?(O=()=>ns(i,a,o,c),t[8]=c,t[9]=a,t[10]=i,t[11]=o,t[12]=O):O=t[12];let[k,ee]=(0,q.useState)(O),[te,A]=(0,q.useState)(null);c!==(te??k.contents)&&(ee(ns(i,a,o,c)),A(null));let{ready:j,onPostRender:ne}=is(k),re=(0,q.useRef)(null),ie;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ie={onAttach:e=>{re.current=e},onComplete:()=>{re.current=null}},t[13]=ie):ie=t[13];let ae=ie,oe;t[14]!==m||t[15]!==s||t[16]!==a||t[17]!==i||t[18]!==o||t[19]!==D?(oe=e=>{let{file:t,lineAnnotations:r}=e;if(t.contents===nn(i,a,o)||(A(t.contents),en(i,a,o,t.contents),D.change(t.contents),!r))return;let c=mt(r);v(e=>e===r?e:c);for(let e of c)for(let r of e.metadata.entries)r.kind===`comment`&&m(s,n({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:r.text,contents:t.contents}))},t[14]=m,t[15]=s,t[16]=a,t[17]=i,t[18]=o,t[19]=D,t[20]=oe):oe=t[20];let M=oe,se;t[21]!==s||t[22]!==h||t[23]!==C?(se=e=>{C(null),h(s,e),v(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=s,t[22]=h,t[23]=C,t[24]=se):se=t[24];let N=se,P;t[25]!==m||t[26]!==s||t[27]!==c||t[28]!==_||t[29]!==o||t[30]!==C?(P=(e,t)=>{C(null);let r=_.flatMap(us).find(t=>t.id===e);r&&m(s,n({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:t,contents:c})),v(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=m,t[26]=s,t[27]=c,t[28]=_,t[29]=o,t[30]=C,t[31]=P):P=t[31];let ce=P,le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{re.current?.setSelections([]),re.current?.blur();let{startLine:t,endLine:n}=gt(e),r={id:ht(),kind:`draft`,startLine:t,endLine:n,text:``};v(e=>{let t=e.flatMap(cs),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=le):le=t[32];let ue=le,F;t[33]===_?F=t[34]:(F=_.some(os),t[33]=_,t[34]=F);let de=F,I,fe;t[35]!==de||t[36]!==C?(I=()=>{let e=w.current;if(e)return wo({root:e,editor:{setSelections:e=>re.current?.setSelections(e)},isBlocked:()=>de,onDismiss:()=>C(null)})},fe=[de,C],t[35]=de,t[36]=C,t[37]=I,t[38]=fe):(I=t[37],fe=t[38]),(0,q.useEffect)(I,fe);let L;t[39]===C?L=t[40]:(L=e=>{C(e),e&&ue(e)},t[39]=C,t[40]=L);let pe=L,me;t[41]!==ne||t[42]!==f||t[43]!==x?(me=(e,t,n)=>{f(e,t,n),ne(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[41]=ne,t[42]=f,t[43]=x,t[44]=me):me=t[44];let he=me,ge;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ge={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ge):ge=t[45];let _e=!de,ve=!de,ye=d?`wrap`:`scroll`,R;t[46]===l?R=t[47]:(R=Te(l),t[46]=l,t[47]=R);let be;t[48]!==pe||t[49]!==he||t[50]!==l||t[51]!==C||t[52]!==_e||t[53]!==ve||t[54]!==ye||t[55]!==R?(be={disableFileHeader:!0,enableGutterUtility:_e,enableLineSelection:ve,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:pe,overflow:ye,theme:R,preferredHighlighter:un,themeType:l,unsafeCSS:Bt,onPostRender:he},t[48]=pe,t[49]=he,t[50]=l,t[51]=C,t[52]=_e,t[53]=ve,t[54]=ye,t[55]=R,t[56]=be):be=t[56];let xe;t[57]!==N||t[58]!==ce?(xe=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(lt,{kind:e.kind,rangeLabel:_t(e.startLine,e.endLine),text:e.text,onCancel:()=>N(e.id),onComment:t=>ce(e.id,t),onDelete:()=>N(e.id)},e.id))}),t[57]=N,t[58]=ce,t[59]=xe):xe=t[59];let Se;return t[60]!==j||t[61]!==k||t[62]!==M||t[63]!==_||t[64]!==x||t[65]!==be||t[66]!==xe?(Se=(0,$.jsx)(Ne,{createEditor:ts,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(Pe,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ge,children:(0,$.jsx)(vt,{file:k,edit:j,editorOptions:ae,onEditChange:M,options:be,selectedLines:x,lineAnnotations:_,renderAnnotation:xe,className:`min-h-full`})})})}),t[60]=j,t[61]=k,t[62]=M,t[63]=_,t[64]=x,t[65]=be,t[66]=xe,t[67]=Se):Se=t[67],Se}function os(e){return e.metadata.entries.some(ss)}function ss(e){return e.kind===`draft`}function cs(e){let t=e.metadata.entries.filter(ls);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function ls(e){return e.kind!==`draft`}function us(e){return e.metadata.entries}function ds(e){return e.removeReviewComment}function fs(e){return e.addReviewComment}function ps(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=Io(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=an(n,r,i)?.contents??a,c=Mo(s,t,o);c!==s&&(en(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(kt,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function ms(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function hs(){try{return _(Lo,a)??!0}catch(e){return console.error(e),!0}}function gs(e){let t=(0,Q.c)(156),{environmentId:n,cwd:r,projectName:o,relativePath:s,attachment:c,threadRef:l,composerDraftTarget:u,keybindings:d,availableEditors:f,revealLine:p,revealRequestId:m,onOpenFile:h,onPendingChange:g,selectedFilePending:_,workspaceMutationId:v}=e,y;t[0]!==c||t[1]!==r||t[2]!==s?(y=c===void 0?Oo(s,r):s,t[0]=c,t[1]=r,t[2]=s,t[3]=y):y=t[3];let b=y,C=typeof u==`string`,{resolvedTheme:T}=he(),O=_e(vs),A=ye(n,i),j=ge(),oe=de(n),M=pe(n),N=Jt(n),P;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(P={reportFailure:!1},t[4]=P):P=t[4];let ce=Wt(Ht.createUrl,P),le;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(le={reportFailure:!1},t[5]=le):le=t[5];let ue=be(Yt.open,le),F;t[6]===b?F=t[7]:(F=b!==null&&re(b),t[6]=b,t[7]=F);let L=F,me;t[8]!==L||t[9]!==b?(me=b!==null&&!L&&ae(b),t[8]=L,t[9]=b,t[10]=me):me=t[10];let R=me,Ce;t[11]!==L||t[12]!==b?(Ce=b!==null&&!L&&ne(b),t[11]=L,t[12]=b,t[13]=Ce):Ce=t[13];let z=Ce,we=z||L||R,Te;t[14]===b?Te=t[15]:(Te=b!==null&&Nt(b),t[14]=b,t[15]=Te);let Ee=Te,De;t[16]!==Ee||t[17]!==b?(De=b!==null&&!Ee&&Kt(b),t[16]=Ee,t[17]=b,t[18]=De):De=t[18];let Oe=De,ke;t[19]!==c||t[20]!==b?(ke=c!==void 0||b!==null&&ie(b),t[19]=c,t[20]=b,t[21]=ke):ke=t[21];let B=ke,Ae=te(n),{canReadFiles:je}=Ae,Me=ye(n,w),V=tn(n,r,b,c===void 0&&b!==null),Ne=V.readError?.resolvedPath??V.readError?.operationPath,Pe=V.isNotFile&&!B,H=Pe?null:b,[Fe,Ie]=(0,q.useState)(hs),Le=c!==void 0,Re;t[22]!==Fe||t[23]!==H||t[24]!==Le?(Re=jo({relativePath:H,explorerOpen:Fe,attachmentOpen:Le}),t[22]=Fe,t[23]=H,t[24]=Le,t[25]=Re):Re=t[25];let ze=Re,[Be,Ve]=S(Ro,!1,a),[He,Ue]=S(zo,!0,a),[We,Ge]=S(Bo,!0,a),[Ke,qe]=(0,q.useState)(null),Je=(0,q.useRef)(null),Xe;t[26]===H?Xe=t[27]:(Xe=H?ko(H):!1,t[26]=H,t[27]=Xe);let Ze=Xe,Qe;t[28]!==c||t[29]!==H?(Qe=H&&c===void 0?Rt({name:H}):null,t[28]=c,t[29]=H,t[30]=Qe):Qe=t[30];let $e=Qe,et=p===null||Ke?.path===b&&Ke.requestId===m,tt=Ze&&Be&&et,nt=Ee||Oe&&He&&et,rt=$e!==null&&We&&et,U=Ze?`markdown`:$e?`table`:Oe?`html`:null,it=H!==null&&c===void 0&&U!==null,at=ve(),W=H!==null&&V.data!==null&&!(Ze&&tt)&&!($e&&rt)&&!nt,ot=Ze?tt:$e?rt:nt,st=Ze?Ve:$e?Ge:Ue,ct;t[31]!==c||t[32]!==A||t[33]!==L||t[34]!==N||t[35]!==H?(ct=A&&H!==null&&c===void 0&&!L&&N&&Kt(H),t[31]=c,t[32]=A,t[33]=L,t[34]=N,t[35]=H,t[36]=ct):ct=t[36];let G=ct,lt;t[37]!==c||t[38]!==r||t[39]!==b?(lt=b&&c===void 0?xe(b,r):null,t[37]=c,t[38]=r,t[39]=b,t[40]=lt):lt=t[40];let K=lt,ut=$o(b,p,m),dt=c===void 0&&b!==null&&(Pe||!we&&!Ee)&&!_,ft=`file:${n}:${r}:${b??``}`,pt;t[41]!==V.refresh||t[42]!==dt||t[43]!==ft||t[44]!==v?(pt={enabled:dt,mutationId:v,refresh:V.refresh,resourceKey:ft},t[41]=V.refresh,t[42]=dt,t[43]=ft,t[44]=v,t[45]=pt):pt=t[45],pn(pt);let mt;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(mt=()=>{(Je.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[46]=mt):mt=t[46];let ht;t[47]===b?ht=t[48]:(ht=[b],t[47]=b,t[48]=ht),(0,q.useEffect)(mt,ht);let gt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>{Ie(_s)},t[49]=gt):gt=t[49];let _t=gt,vt;t[50]!==K||t[51]!==A||t[52]!==je||t[53]!==ce||t[54]!==r||t[55]!==M||t[56]!==ue||t[57]!==l?(vt=()=>{je&&A&&K&&M&&(async()=>{let e=await Ut({threadRef:l,filePath:K,workspaceRoot:r,httpBaseUrl:M,createAssetUrl:ce,openPreview:ue});if(e._tag===`Success`||k(e))return;let t=ee(e);fe.add(Se({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[50]=K,t[51]=A,t[52]=je,t[53]=ce,t[54]=r,t[55]=M,t[56]=ue,t[57]=l,t[58]=vt):vt=t[58];let bt=vt;if(c===void 0&&!je){if(Ae.isPending){let e;return t[59]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(I,{className:`size-4`}),`Checking file access...`]}),t[59]=e):e=t[59],e}let e=Ae.error??`This connection cannot read host files.`,n;return t[60]===e?n=t[61]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[60]=e,t[61]=n),n}let xt;t[62]!==K||t[63]!==c||t[64]!==f||t[65]!==G||t[66]!==it||t[67]!==r||t[68]!==n||t[69]!==Fe||t[70]!==bt||t[71]!==B||t[72]!==d||t[73]!==h||t[74]!==H||t[75]!==j||t[76]!==o||t[77]!==b||t[78]!==oe||t[79]!==ot||t[80]!==U||t[81]!==m||t[82]!==st||t[83]!==W||t[84]!==at||t[85]!==O||t[86]!==v?(xt=b&&c===void 0?(0,$.jsxs)(`div`,{className:Pt,"data-surface-subheader":!0,children:[(0,$.jsx)(kt,{radius:`none`,ref:Je,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(bo,{cwd:r,environmentId:n,onOpenFile:h,projectName:o,relativePath:b,workspaceMutationId:v})})}),K&&(n===j||oe.mode!==`local-exec`)?(0,$.jsx)(mn,{environmentId:n,keybindings:d,availableEditors:f,openInCwd:K,compact:!0}):null,it&&U?(0,$.jsx)(jt,{label:ms(U,ot),pressed:ot,onPress:()=>{let e=!ot;st(e),qe(e&&b!==null?{path:b,requestId:m}:null)},children:(0,$.jsx)(se,{className:`size-3.5`,icon:ot?no.Code2:U===`table`?no.Table2:no.Eye})}):null,W?(0,$.jsx)(jt,{label:O?`Disable word wrap`:`Enable word wrap`,pressed:O,onPress:()=>at({wordWrap:!O}),children:(0,$.jsx)(D,{className:`size-3.5`})}):null,G?(0,$.jsx)(jt,{label:`Open file in preview browser`,onPress:bt,children:(0,$.jsx)(ln,{className:`size-3.5`})}):null,!B&&H!==null?(0,$.jsx)(jt,{label:Fe?`Hide file explorer`:`Show file explorer`,pressed:Fe,onPress:_t,children:(0,$.jsx)(E,{className:`size-3.5`})}):null]}):null,t[62]=K,t[63]=c,t[64]=f,t[65]=G,t[66]=it,t[67]=r,t[68]=n,t[69]=Fe,t[70]=bt,t[71]=B,t[72]=d,t[73]=h,t[74]=H,t[75]=j,t[76]=o,t[77]=b,t[78]=oe,t[79]=ot,t[80]=U,t[81]=m,t[82]=st,t[83]=W,t[84]=at,t[85]=O,t[86]=v,t[87]=xt):xt=t[87];let St;t[88]!==c||t[89]!==Me||t[90]!==Ae.isPending||t[91]!==B||t[92]!==b?(St=b&&!c&&!B&&!Me&&!Ae.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[88]=c,t[89]=Me,t[90]=Ae.isPending,t[91]=B,t[92]=b,t[93]=St):St=t[93];let Ct;t[94]!==c||t[95]!==V.data||t[96]!==we||t[97]!==H||t[98]!==nt?(Ct=H&&c===void 0&&!we&&!nt&&V.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,V.data.byteLength.toLocaleString(),` byte file.`]}):null,t[94]=c,t[95]=V.data,t[96]=we,t[97]=H,t[98]=nt,t[99]=Ct):Ct=t[99];let wt=H?`flex`:`hidden`,Tt;t[100]===wt?Tt=t[101]:(Tt=x(`min-w-0 flex-1 flex-col overflow-hidden`,wt),t[100]=wt,t[101]=Tt);let Et;t[102]!==K||t[103]!==c||t[104]!==Ne||t[105]!==Me||t[106]!==u||t[107]!==r||t[108]!==C||t[109]!==n||t[110]!==V.data||t[111]!==V.error||t[112]!==V.readError||t[113]!==R||t[114]!==Pe||t[115]!==B||t[116]!==z||t[117]!==Ze||t[118]!==L||t[119]!==ut||t[120]!==g||t[121]!==b||t[122]!==nt||t[123]!==tt||t[124]!==rt||t[125]!==T||t[126]!==m||t[127]!==$e||t[128]!==l||t[129]!==O||t[130]!==v?(Et=Pe?null:b&&c?(0,$.jsx)(It,{name:c.name,mimeType:c.mimeType,sizeBytes:c.sizeBytes,asset:{environmentId:n,attachmentId:c.id},htmlRender:c.htmlRender===!0,threadRef:l},`${n}:${c.id}`):b&&L&&K?(0,$.jsx)(Uo,{environmentId:n,threadRef:l,draft:C,absolutePath:K,workspaceRoot:r,name:b,workspaceMutationId:v},`${n}:${l.threadId}:${K}`):b&&R&&K?(0,$.jsx)(Go,{environmentId:n,threadRef:l,draft:C,absolutePath:K,workspaceRoot:r,name:b,workspaceMutationId:v},`${n}:${l.threadId}:${K}`):b&&z&&K?(0,$.jsx)(Vo,{environmentId:n,threadRef:l,draft:C,absolutePath:K,workspaceRoot:r,alt:b,workspaceMutationId:v},K):b&&nt&&K?(0,$.jsx)(Ho,{environmentId:n,threadRef:l,draft:C,absolutePath:K,workspaceRoot:r,title:b,workspaceMutationId:v},K):b&&V.error&&V.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:V.readError?Ao(V.readError):V.error}),Ne?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:Ne})]}):null,B?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:V.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):b&&V.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(I,{size:`lg`})}):b&&V.data?Ze&&tt?(0,$.jsx)(ps,{environmentId:n,cwd:r,relativePath:b,threadRef:l,contents:V.data.contents,readOnly:B||!Me,onPendingChange:g},b):$e&&rt?(0,$.jsx)(Vt,{name:b,text:V.data.contents,delimiter:$e},b):V.data.truncated||B||!Me?(0,$.jsx)(yt,{name:b,text:V.data.contents,cacheKey:Do(r,b,V.data.contents),onPostRender:ut}):(0,$.jsx)(Ye,{children:(0,$.jsx)(as,{environmentId:n,cwd:r,relativePath:b,composerDraftTarget:u,contents:V.data.contents,resolvedTheme:T,revealRequestId:m,wordWrap:O,onPostRender:ut,onPendingChange:g},`${b}:${T}`)}):null,t[102]=K,t[103]=c,t[104]=Ne,t[105]=Me,t[106]=u,t[107]=r,t[108]=C,t[109]=n,t[110]=V.data,t[111]=V.error,t[112]=V.readError,t[113]=R,t[114]=Pe,t[115]=B,t[116]=z,t[117]=Ze,t[118]=L,t[119]=ut,t[120]=g,t[121]=b,t[122]=nt,t[123]=tt,t[124]=rt,t[125]=T,t[126]=m,t[127]=$e,t[128]=l,t[129]=O,t[130]=v,t[131]=Et):Et=t[131];let Dt;t[132]!==Tt||t[133]!==Et?(Dt=(0,$.jsx)(`div`,{className:Tt,children:Et}),t[132]=Tt,t[133]=Et,t[134]=Dt):Dt=t[134];let Ot;t[135]!==r||t[136]!==n||t[137]!==V.refresh||t[138]!==we||t[139]!==Ee||t[140]!==h||t[141]!==H||t[142]!==o||t[143]!==b||t[144]!==m||t[145]!==ze||t[146]!==v?(Ot=ze?(0,$.jsx)(`aside`,{className:x(`flex min-h-0 shrink-0 bg-background`,H?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,$.jsx)(fo,{environmentId:n,cwd:r,projectName:o,selectedPath:b,selectedPathRevealId:m,onOpenFile:h,workspaceMutationId:v,...H&&!we&&!Ee?{onRefreshSelectedFile:V.refresh}:{}},`${n}:${r}`)}):null,t[135]=r,t[136]=n,t[137]=V.refresh,t[138]=we,t[139]=Ee,t[140]=h,t[141]=H,t[142]=o,t[143]=b,t[144]=m,t[145]=ze,t[146]=v,t[147]=Ot):Ot=t[147];let At;t[148]!==Dt||t[149]!==Ot?(At=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[Dt,Ot]}),t[148]=Dt,t[149]=Ot,t[150]=At):At=t[150];let Mt;return t[151]!==xt||t[152]!==St||t[153]!==Ct||t[154]!==At?(Mt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[xt,St,Ct,At]}),t[151]=xt,t[152]=St,t[153]=Ct,t[154]=At,t[155]=Mt):Mt=t[155],Mt}function _s(e){let t=!e;try{p(Lo,t,a)}catch(e){console.error(e)}return t}function vs(e){return e.wordWrap}export{gs as default};
|
|
34
|
+
//# sourceMappingURL=FilePreviewPanel-Dj_tLsu8.js.map
|
package/dist/client/assets/{FoldedSettingsSection-BimbnaOl.js → FoldedSettingsSection-CJhrFR0_.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{
|
|
2
|
-
//# sourceMappingURL=FoldedSettingsSection-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{ma as n,t as r,wx as i}from"./utils-Nv21__t3.js";import{t as a}from"./chevron-right-NbahR9_s.js";import{n as o,r as s,t as c}from"./collapsible-DyaDJVJ5.js";import{H as l,d as u,f as d}from"./settingsLayout-DKjAOwp4.js";var f=i(),p=e(t(),1),m=e(n(),1);function h(e){let t=(0,f.c)(50),{id:n,title:i,summary:h,control:g,headerPlacement:_,children:v}=e,y=_===void 0?`inside`:_,[b,x]=(0,p.useState)(!1),S=d(),C=u(n),[w,T]=(0,p.useState)(null);if(S===n&&w!==n&&(T(n),b||x(!0)),y===`outside`){let e=b&&`rotate-90`,u;t[0]===e?u=t[1]:(u=r(`size-4 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,e),t[0]=e,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,m.jsx)(a,{"aria-hidden":!0,className:u}),t[2]=u,t[3]=d);let f;t[4]!==d||t[5]!==i?(f=(0,m.jsx)(`h2`,{children:(0,m.jsxs)(s,{className:`flex min-h-7 items-center gap-2 rounded-md text-sm font-normal text-foreground/70 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i,d]})}),t[4]=d,t[5]=i,t[6]=f):f=t[6];let p;t[7]!==g||t[8]!==f?(p=(0,m.jsxs)(`div`,{"data-settings-scroll-target":!0,className:`flex min-h-7 items-start justify-between gap-4 px-3 sm:px-4`,children:[f,g]}),t[7]=g,t[8]=f,t[9]=p):p=t[9];let h;t[10]===v?h=t[11]:(h=(0,m.jsx)(o,{children:(0,m.jsx)(l,{children:v})}),t[10]=v,t[11]=h);let _;t[12]!==p||t[13]!==h?(_=(0,m.jsxs)(`div`,{className:`space-y-2.5`,children:[p,h]}),t[12]=p,t[13]=h,t[14]=_):_=t[14];let y;t[15]!==b||t[16]!==_?(y=(0,m.jsx)(c,{open:b,onOpenChange:x,children:_}),t[15]=b,t[16]=_,t[17]=y):y=t[17];let S;return t[18]!==n||t[19]!==y||t[20]!==C?(S=(0,m.jsx)(`section`,{id:n,ref:C,tabIndex:-1,className:`outline-none`,children:y}),t[18]=n,t[19]=y,t[20]=C,t[21]=S):S=t[21],S}let E;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,m.jsx)(l,{divided:!1}),t[22]=E):E=t[22];let D=b&&`rotate-90`,O;t[23]===D?O=t[24]:(O=r(`size-4 shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,D),t[23]=D,t[24]=O);let k;t[25]===O?k=t[26]:(k=(0,m.jsx)(a,{"aria-hidden":!0,className:O}),t[25]=O,t[26]=k);let A;t[27]===i?A=t[28]:(A=(0,m.jsx)(`span`,{className:`shrink-0 text-sm font-medium`,children:i}),t[27]=i,t[28]=A);let j;t[29]===h?j=t[30]:(j=h?(0,m.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:h}):null,t[29]=h,t[30]=j);let M;t[31]!==k||t[32]!==A||t[33]!==j?(M=(0,m.jsxs)(s,{className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring rounded-md`,children:[k,A,j]}),t[31]=k,t[32]=A,t[33]=j,t[34]=M):M=t[34];let N;t[35]===g?N=t[36]:(N=g?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:g}):null,t[35]=g,t[36]=N);let P;t[37]!==M||t[38]!==N?(P=(0,m.jsxs)(`div`,{className:`flex items-center gap-4 px-3 sm:px-4`,children:[M,N]}),t[37]=M,t[38]=N,t[39]=P):P=t[39];let F;t[40]===v?F=t[41]:(F=(0,m.jsx)(o,{children:(0,m.jsx)(`div`,{className:`border-t border-border/50 [&>*+*]:border-t [&>*+*]:border-border/50`,children:v})}),t[40]=v,t[41]=F);let I;t[42]!==b||t[43]!==P||t[44]!==F?(I=(0,m.jsxs)(c,{open:b,onOpenChange:x,render:E,children:[P,F]}),t[42]=b,t[43]=P,t[44]=F,t[45]=I):I=t[45];let L;return t[46]!==n||t[47]!==I||t[48]!==C?(L=(0,m.jsx)(`section`,{id:n,ref:C,tabIndex:-1,className:`outline-none`,children:I}),t[46]=n,t[47]=I,t[48]=C,t[49]=L):L=t[49],L}export{h as t};
|
|
2
|
+
//# sourceMappingURL=FoldedSettingsSection-CJhrFR0_.js.map
|