@pi-chamber/web 1.0.3 → 1.0.4-rc.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/assets/DiagramView-DfZMQkXY.js +1 -0
- package/dist/assets/{DiffView-D19Jps0i.js → DiffView-BjWUdbL5.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-u5L4k_5k.js +3 -0
- package/dist/assets/FilesView-qP1ypN9J.js +6 -0
- package/dist/assets/GitHubDetailScaffold-zCKCy5OJ.js +11 -0
- package/dist/assets/GitHubLinkPicker-CwxKY3lN.js +1 -0
- package/dist/assets/GitHubListPrimitives-Ck3zllel.js +1 -0
- package/dist/assets/GitView-y2k2i4gR.js +9 -0
- package/dist/assets/IssuesSurface-HWgR87N3.js +7 -0
- package/dist/assets/JsonTreeView-DSuC4naV.js +1 -0
- package/dist/assets/{MarkdownRendererImpl-DV5Xkj8N.js → MarkdownRendererImpl-CT5ln9em.js} +5 -5
- package/dist/assets/PatchDiff-DArTeWeK.js +1 -0
- package/dist/assets/PierreDiffViewer-DQKujzLb.js +134 -0
- package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +2 -0
- package/dist/assets/SessionSwitcherContent-DEGJyZBl.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-cC9wVBH7.js +2 -0
- package/dist/assets/SessionUnreadDot-CELKNVIM.js +1 -0
- package/dist/assets/SettingsView-CZvRRgJe.js +6 -0
- package/dist/assets/SettingsWindow-CZM1dmVb.js +1 -0
- package/dist/assets/ToolOutputDialog-DClOSbJc.js +8 -0
- package/dist/assets/ToolPartDiffPreview-BaFiGUDE.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-CJondRlh.js → VirtualizedFileDiff-D6KbvKc6.js} +3 -3
- package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
- package/dist/assets/collapsible-DhV9d4dT.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-CeMpF2xC.js +3 -0
- package/dist/assets/{contextFileOpenGuard-CsZL8yie.js → contextFileOpenGuard-Ck5u_kAP.js} +1 -1
- package/dist/assets/gitStatusPredicates-DEBSqUNE.js +1 -0
- package/dist/assets/githubLink-DT7i2NlH.js +10 -0
- package/dist/assets/index-6IO1AcJI.js +10 -0
- package/dist/assets/index-BAmzAlNx.css +1 -0
- package/dist/assets/index-eDf4LKLY.js +1 -0
- package/dist/assets/main-BczEScAA.js +2 -0
- package/dist/assets/main-CHLNMYeJ.js +136 -0
- package/dist/assets/markdownCore-C4Gk5Zht.js +2 -0
- package/dist/assets/miniChat-Do3hE87Z.js +2 -0
- package/dist/assets/mobile-CTnihwfa.js +2 -0
- package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
- package/dist/assets/pi-session-focus-preference-LDVCJ_YR.js +10 -0
- package/dist/assets/renderDiffWithHighlighter-CDsgOnkH.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DSa3gYqR.js +2 -0
- package/dist/assets/renderFileWithHighlighter-TpKRyfCY.js +1 -0
- package/dist/assets/renderMobileApp-CPE-3uMl.js +11 -0
- package/dist/assets/runtimeEndpointReset-CzJfovWI.js +62 -0
- package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-DW_Ia4q3.js} +1 -1
- package/dist/assets/shell-CjFT_Tl9.js +1 -0
- package/dist/assets/sprite-HGQGInUp.js +6510 -0
- package/dist/assets/useAppFontEffects-CG3_yteE.js +212 -0
- package/dist/assets/{useFilesViewSearch-DJ3psTKU.js → useFilesViewSearch-C_LzYIgD.js} +1 -1
- package/dist/assets/useGitHubRemoteSearch-DsxWOzKZ.js +1 -0
- package/dist/assets/useSwitcherItems-BmoCnS9W.js +1 -0
- package/dist/assets/vendor-base-ui-DIkTOIJS.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-D3YCkKz7.js → vendor-beautiful-mermaid-DApbjBp2.js} +1 -1
- package/dist/assets/vendor-boot-DyL2td56.js +69 -0
- package/dist/assets/vendor-codemirror-autocomplete-DsFn4GLp.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-B_NMmBbS.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +1 -0
- package/dist/assets/vendor-codemirror-lang-go-C2KHbcll.js +7 -0
- package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-DpTUrvx8.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-HpQWHJjv.js → vendor-codemirror-lang-sql-C_RazIaB.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-BYL0r7KR.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +1 -0
- package/dist/assets/vendor-codemirror-language-data-DglcKYWT.js +2 -0
- package/dist/assets/vendor-codemirror-search-DaE6R5gH.js +2 -0
- package/dist/assets/{vendor-elkjs-mzfkf0ML.js → vendor-elkjs-D27273Ms.js} +1 -1
- package/dist/assets/{vendor-heic2any-BHsbokcA.js → vendor-heic2any-pq-UTQQR.js} +1 -1
- package/dist/assets/vendor-lezer-cpp-Dt99h3WT.js +1 -0
- package/dist/assets/vendor-lezer-css-DNU_fzPI.js +1 -0
- package/dist/assets/vendor-lezer-go-BEFtcNyS.js +1 -0
- package/dist/assets/vendor-lezer-html-DDGRhRUz.js +1 -0
- package/dist/assets/vendor-lezer-java-DmfZtW09.js +1 -0
- package/dist/assets/vendor-lezer-javascript-oje4tdp_.js +1 -0
- package/dist/assets/vendor-lezer-json-BRXb_bDX.js +1 -0
- package/dist/assets/vendor-lezer-lr-BU2qmu_5.js +1 -0
- package/dist/assets/{vendor-lezer-markdown-C6g-d6P3.js → vendor-lezer-markdown-CicYv7V9.js} +4 -4
- package/dist/assets/vendor-lezer-php-COORrTpE.js +1 -0
- package/dist/assets/vendor-lezer-python-Cuvm9X9Y.js +1 -0
- package/dist/assets/vendor-lezer-rust-C_zOfHbX.js +1 -0
- package/dist/assets/vendor-lezer-sass-DWP4w7O1.js +1 -0
- package/dist/assets/vendor-lezer-xml-Br6nOYeG.js +1 -0
- package/dist/assets/vendor-lezer-yaml-CYQmm6Sb.js +1 -0
- package/dist/assets/{vendor-lru_map-Cy8fTs3_.js → vendor-lru_map-DOPmc7GU.js} +1 -1
- package/dist/assets/{vendor-qrcode-B0KNSajT.js → vendor-qrcode-Dv4uniC1.js} +1 -1
- package/dist/assets/vendor-react-DASdDPIk.js +1 -0
- package/dist/assets/{vendor-react-drawio-BYDptOsj.js → vendor-react-drawio-Duu5LgQA.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-DaSwPsXt.js → vendor-replit-codemirror-vim-CZy3BUVv.js} +15 -15
- package/dist/assets/vendor-zustand-CUi8eEds.js +6 -0
- package/dist/assets/{web-components-CCKlju0Z.js → web-components-CH3-XV-n.js} +4 -4
- package/dist/index.html +7 -9
- package/dist/mini-chat.html +6 -8
- package/dist/mobile.html +6 -8
- package/package.json +1 -1
- package/server/index.js +3 -1
- package/server/lib/fs/DOCUMENTATION.md +1 -1
- package/server/lib/fs/routes.js +1 -50
- package/server/lib/git/DOCUMENTATION.md +18 -11
- package/server/lib/git/index.js +8 -3
- package/server/lib/git/routes.js +0 -129
- package/server/lib/git/service.js +40 -152
- package/server/lib/git/service.test.js +42 -18
- package/server/lib/github/DOCUMENTATION.md +271 -0
- package/server/lib/github/cache.js +164 -0
- package/server/lib/github/checks.js +230 -0
- package/server/lib/github/client.js +305 -0
- package/server/lib/github/context.js +177 -0
- package/server/lib/github/contracts.test.js +235 -0
- package/server/lib/github/correctness.test.js +356 -0
- package/server/lib/github/credential.js +46 -0
- package/server/lib/github/errors.js +151 -0
- package/server/lib/github/gh-cli.js +336 -0
- package/server/lib/github/index.js +27 -0
- package/server/lib/github/issues.js +495 -0
- package/server/lib/github/pulls.js +699 -0
- package/server/lib/github/repo-scope.js +688 -0
- package/server/lib/github/routes.js +599 -0
- package/server/lib/github/security.test.js +275 -0
- package/server/lib/github/templates.js +153 -0
- package/server/lib/package-manager-detect-child.js +12 -0
- package/server/lib/package-manager.js +366 -92
- package/server/lib/package-manager.test.js +109 -0
- package/server/lib/pi/routes-extension-events.test.js +268 -4
- package/server/lib/pi/routes.js +109 -25
- package/server/lib/pi/routes.test.js +118 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +5 -3
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +222 -0
- package/server/lib/pi/session-daemon/extension-bridge.js +415 -42
- package/server/lib/pi/session-daemon/extension-name.js +87 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +143 -0
- package/server/lib/pi/session-daemon/extension-theme.js +142 -0
- package/server/lib/pi/session-daemon/extension-theme.test.js +117 -0
- package/server/lib/pi/session-daemon/extension-tool-render.js +365 -0
- package/server/lib/pi/session-daemon/extension-tool-render.test.js +607 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +322 -2
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
- package/server/lib/pi/session-daemon/session-daemon.js +204 -33
- package/server/lib/pi/session-daemon/session-daemon.test.js +218 -0
- package/server/lib/pi/ui-settings-store.js +1 -1
- package/server/lib/static-cache-control.js +18 -0
- package/server/lib/static-cache-control.test.js +25 -0
- package/server/lib/workspace/host.js +2 -0
- package/dist/assets/DiagramView-Bj1ZrdhI.js +0 -1
- package/dist/assets/FileSaveConflictDialog-2Z4V_gZU.js +0 -3
- package/dist/assets/FilesView-K18gBSws.js +0 -6
- package/dist/assets/GitView-Hm1KBPaD.js +0 -8
- package/dist/assets/JsonTreeView-fNsiZEIo.js +0 -1
- package/dist/assets/PatchDiff-DZaJG6jj.js +0 -1
- package/dist/assets/SessionSwitcherContent-RAsmsuYk.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-DuLPlIF_.js +0 -2
- package/dist/assets/SessionUnreadDot-Dm6k5OCd.js +0 -1
- package/dist/assets/SettingsView-Chu4zbWo.js +0 -6
- package/dist/assets/SettingsWindow-CJzFmmfu.js +0 -1
- package/dist/assets/ToolOutputDialog-uYeXsAGc.js +0 -8
- package/dist/assets/ToolPartDiffPreview-DnAHVRs-.js +0 -1
- package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
- package/dist/assets/collapsible-BH1vXEAI.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-DXkR5jdw.js +0 -3
- package/dist/assets/gitStatusPredicates-BW8heN1a.js +0 -134
- package/dist/assets/index-5fyXnZFi.css +0 -1
- package/dist/assets/index-BrgKwTb0.js +0 -1
- package/dist/assets/index-C-sV_9sb.js +0 -8
- package/dist/assets/isDiffPlainText-DZFr1Tta.js +0 -1
- package/dist/assets/isFilePlainText-KNpEMvb-.js +0 -1
- package/dist/assets/main-BPY2ug1A.js +0 -135
- package/dist/assets/main-BRIjzIRl.js +0 -2
- package/dist/assets/markdownCore-DYizLr1N.js +0 -3
- package/dist/assets/miniChat-Dva4MINl.js +0 -2
- package/dist/assets/mobile-6jNUNv_x.js +0 -2
- package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BIeBrZmO.js +0 -2
- package/dist/assets/renderMobileApp-BDCtZpeS.js +0 -11
- package/dist/assets/runtimeEndpointReset-DqdGOWp8.js +0 -53
- package/dist/assets/useAppFontEffects-BABx-DxZ.js +0 -6722
- package/dist/assets/usePushVisibilityBeacon-BciEu3HS.js +0 -10
- package/dist/assets/useSwitcherItems-C7_5TB_n.js +0 -1
- package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +0 -1
- package/dist/assets/vendor-base-ui-DXSHfszQ.js +0 -1
- package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +0 -1
- package/dist/assets/vendor-cmdk-zXx6sGnS.js +0 -1
- package/dist/assets/vendor-codemirror-autocomplete-wd6iRebq.js +0 -1
- package/dist/assets/vendor-codemirror-commands-CNlncqrr.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-DU_4KiiW.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-CmIT9Z5_.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-djiuoTi8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-go-COZSwZYW.js +0 -7
- package/dist/assets/vendor-codemirror-lang-html-CKHqhW5R.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-CNMP5hyC.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js +0 -13
- package/dist/assets/vendor-codemirror-lang-jinja-DaKn_b1k.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-CZ07HmNC.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-wJdQiDBf.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-0z48Roi8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-DtcZDGqe.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-W8plS-JQ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-DzzokVau.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-C4ulBVpf.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BkZJYEwS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-DiBPljCc.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-DoABsogh.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-BhLJhOCH.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-D95i1Y5R.js +0 -1
- package/dist/assets/vendor-codemirror-language-BByA_dGF.js +0 -3
- package/dist/assets/vendor-codemirror-language-data-BB5mQv-R.js +0 -2
- package/dist/assets/vendor-codemirror-search-BV44140v.js +0 -2
- package/dist/assets/vendor-codemirror-state-CNWM3Q8V.js +0 -5
- package/dist/assets/vendor-codemirror-view-Ct4T37Ue.js +0 -4
- package/dist/assets/vendor-crelt-C8TCjufn.js +0 -1
- package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-dnd-kit-accessibility-DZKKhs9S.js +0 -1
- package/dist/assets/vendor-dnd-kit-core-C9qcAm_1.js +0 -5
- package/dist/assets/vendor-dnd-kit-sortable-D8ozj8M-.js +0 -1
- package/dist/assets/vendor-dnd-kit-utilities-DTY1C6ST.js +0 -1
- package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +0 -1
- package/dist/assets/vendor-floating-ui-dom-WyXykhNi.js +0 -1
- package/dist/assets/vendor-floating-ui-react-dom-BZOGXAGe.js +0 -1
- package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +0 -1
- package/dist/assets/vendor-framer-motion-CfplGuM0.js +0 -1
- package/dist/assets/vendor-get-nonce-C-Z93AgS.js +0 -1
- package/dist/assets/vendor-lezer-common-B3-cUCR_.js +0 -1
- package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +0 -1
- package/dist/assets/vendor-lezer-css-C5xB6jxd.js +0 -1
- package/dist/assets/vendor-lezer-go-CXK1UKk8.js +0 -1
- package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +0 -1
- package/dist/assets/vendor-lezer-html-C0I1p52t.js +0 -1
- package/dist/assets/vendor-lezer-java-D_zzj-NV.js +0 -1
- package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +0 -1
- package/dist/assets/vendor-lezer-json-Iaex0UN-.js +0 -1
- package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +0 -1
- package/dist/assets/vendor-lezer-php-_DHrbsZG.js +0 -1
- package/dist/assets/vendor-lezer-python-CvuFxeZl.js +0 -1
- package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +0 -1
- package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +0 -1
- package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +0 -1
- package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +0 -1
- package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +0 -1
- package/dist/assets/vendor-motion-dom-DhJ-sYS5.js +0 -1
- package/dist/assets/vendor-motion-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-motion-utils-CKEGc_YG.js +0 -1
- package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +0 -1
- package/dist/assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js +0 -1
- package/dist/assets/vendor-radix-ui-react-context-CFsX-AUC.js +0 -1
- package/dist/assets/vendor-radix-ui-react-dialog-D2yhEu2p.js +0 -5
- package/dist/assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js +0 -1
- package/dist/assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js +0 -1
- package/dist/assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js +0 -1
- package/dist/assets/vendor-radix-ui-react-id-D2kS9K1j.js +0 -1
- package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +0 -1
- package/dist/assets/vendor-radix-ui-react-presence-D432pCMB.js +0 -1
- package/dist/assets/vendor-radix-ui-react-primitive-DkH8dMOR.js +0 -1
- package/dist/assets/vendor-radix-ui-react-slot-BIDFZX0-.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +0 -1
- package/dist/assets/vendor-react-B5Z1Mdn3.js +0 -9
- package/dist/assets/vendor-react-remove-scroll-bar-CSAHp1YF.js +0 -38
- package/dist/assets/vendor-react-remove-scroll-vR1dy1aP.js +0 -4
- package/dist/assets/vendor-react-style-singleton-Ctw6HnYx.js +0 -1
- package/dist/assets/vendor-reselect-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-scheduler-7OC5HNn7.js +0 -1
- package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +0 -2
- package/dist/assets/vendor-sonner-BDtm25td.js +0 -1
- package/dist/assets/vendor-style-mod-NZ5MEPvj.js +0 -3
- package/dist/assets/vendor-tanstack-react-virtual-2skouoFw.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +0 -1
- package/dist/assets/vendor-tslib-De9GV7Vy.js +0 -1
- package/dist/assets/vendor-use-callback-ref-CVVuCyLj.js +0 -1
- package/dist/assets/vendor-use-sidecar-Vv4V8Nd1.js +0 -1
- package/dist/assets/vendor-use-sync-external-store-D0AXkdQC.js +0 -1
- package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +0 -1
- package/dist/assets/vendor-zustand-GVb4H8HE.js +0 -6
- package/server/lib/git/credentials.js +0 -41
- package/server/lib/git/identity-storage.js +0 -122
- /package/dist/assets/{vendor-katex-CNckGUMB.js → vendor-katex-DZG0Ov6p.js} +0 -0
- /package/dist/assets/{vendor-katex-Cp579UoJ.css → vendor-katex-css-Cp579UoJ.css} +0 -0
- /package/dist/assets/{vendor-xterm-xterm-CrXqRur4.js → vendor-xterm-xterm-B-qIQCd3.js} +0 -0
- /package/dist/assets/{vendor-xterm-xterm-DDGTF8rc.css → vendor-xterm-xterm-css-DDGTF8rc.css} +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-D19Jps0i.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-C-sV_9sb.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-5fyXnZFi.css","assets/useAppFontEffects-BABx-DxZ.js","assets/vendor-base-ui-DXSHfszQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-BdndJV2m.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BB5mQv-R.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/gitStatusPredicates-BW8heN1a.js","assets/web-components-CCKlju0Z.js","assets/computeVirtualFileMetrics-DXkR5jdw.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/VirtualizedFileDiff-CJondRlh.js","assets/isDiffPlainText-DZFr1Tta.js","assets/vendor-diff-C3JhlQdm.js","assets/runtimeEndpointReset-DqdGOWp8.js","assets/SessionUnreadDot-Dm6k5OCd.js","assets/vendor-xterm-xterm-CrXqRur4.js","assets/vendor-xterm-xterm-DDGTF8rc.css","assets/permissionStore-iKN1K2_x.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/appThemeRegistry-gegrE2dq.js","assets/registerCustomTheme-DmolaWWZ.js","assets/contextFileOpenGuard-CsZL8yie.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as vs}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as a,j as e,r as it,b as Aa}from"./vendor-react-B5Z1Mdn3.js";import{a2 as He,a3 as we,a4 as Ne,a5 as Ue,B as _,I as w,a6 as Ce,a7 as Ve,aJ as ws,aK as Ns,aL as Cs,aM as Ss,aN as Oe,aO as De,cm as Dt,a9 as pe,aa as Ba,ab as ut,f as Lt,$ as rs,ag as Fe,ah as ze,ai as $e,aj as Ie,ak as Me,t as R,cc as ks,as as Ta,af as Ga,cn as Oa,co as _a,cp as Ha,cq as Ua,cr as Va,a_ as Wa,al as _e,ae as is,b9 as Ka,_ as qa,a8 as Ya,a1 as Ja,ca as Rs,cs as Za,at as Es,cd as Qa,ac as Xa,au as en,ad as tn,ct as sn,cu as an,cv as nn,cw as rn,cx as on,ay as ln,aG as cn}from"./useAppFontEffects-BABx-DxZ.js";import{J as dn,K as un,L as hn}from"./runtimeEndpointReset-DqdGOWp8.js";import{u as os}from"./vendor-zustand-GVb4H8HE.js";import{o as te,t as Pt,bZ as mn,B as ot}from"./index-C-sV_9sb.js";import{C as fn,P as Fs,d as pn,i as ls,a as gn}from"./gitStatusPredicates-BW8heN1a.js";import{C as xn,a as bn,b as yn}from"./collapsible-BH1vXEAI.js";import{u as jn}from"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-BdndJV2m.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BB5mQv-R.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./SessionUnreadDot-Dm6k5OCd.js";import"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-CCKlju0Z.js";import"./computeVirtualFileMetrics-DXkR5jdw.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-CJondRlh.js";import"./isDiffPlainText-DZFr1Tta.js";import"./vendor-diff-C3JhlQdm.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const vn=n=>n.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),wn=({currentBranch:n,localBranches:r,remoteBranches:c,branchInfo:m,onCheckout:h,onCreate:s,remotes:t=[],disabled:g=!1})=>{const[u,y]=a.useState(!1),[C,S]=a.useState(""),[v,f]=a.useState(!1),[l,d]=a.useState(!1),[E,k]=a.useState(""),[I,T]=a.useState(!1),H=a.useRef(null),A=a.useCallback($=>{$.stopPropagation()},[]),L=t.length>1,M=a.useMemo(()=>vn(E),[E]),z=a.useMemo(()=>{const $=C.toLowerCase();return $?r.filter(X=>X.toLowerCase().includes($)):r},[C,r]),G=a.useMemo(()=>{const $=C.toLowerCase();return $?c.filter(X=>X.toLowerCase().includes($)):c},[C,c]),x=$=>{if($===n){y(!1);return}h($),y(!1),S("")},B=()=>{f(!0),setTimeout(()=>H.current?.focus(),50)},q=async()=>{if(!(!M||I)){if(L){d(!0);return}T(!0);try{await s(M,t[0]),k(""),f(!1),y(!1)}finally{T(!1)}}},Q=async $=>{if(!(!M||I)){T(!0);try{await s(M,$),k(""),f(!1),d(!1),y(!1)}finally{T(!1)}}},U=()=>{d(!1)},W=()=>{k(""),f(!1),d(!1)};return a.useEffect(()=>{u||(S(""),f(!1),d(!1),k(""))},[u]),e.jsxs(He,{open:u,onOpenChange:y,children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Ue,{asChild:!0,children:e.jsxs(_,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:g,children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:n||"Detached HEAD"}),e.jsx(w,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),e.jsx(Ce,{sideOffset:8,children:"Current branch"})]}),e.jsx(Ve,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:e.jsxs(ws,{className:"h-full min-h-0",children:[e.jsx(Ns,{placeholder:"Search branches...",value:C,onValueChange:S,onKeyDown:A}),e.jsxs(Cs,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[e.jsx(Ss,{children:"No branches found."}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{type:"button",onClick:U,disabled:I,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"arrow-left",className:"size-4"})}),e.jsxs("span",{className:"typography-meta text-muted-foreground",children:["Push To Prefix"," ",e.jsx("span",{className:"text-foreground font-medium",children:M})," ","Push To Suffix"]})]}),e.jsx("div",{className:"flex flex-col gap-1",children:t.map($=>e.jsxs("button",{type:"button",onClick:()=>Q($),disabled:I,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[e.jsxs("span",{className:"typography-ui-label text-foreground",children:[I?e.jsx(w,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,$.name]}),e.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:$.pushUrl})]},$.name))})]}):v?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[e.jsx("input",{ref:H,placeholder:"New branch name",value:E,onChange:$=>k($.target.value),onClick:$=>$.stopPropagation(),onKeyDown:$=>{A($),$.key==="Enter"?($.preventDefault(),q()):$.key==="Escape"&&($.preventDefault(),W())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),e.jsx("button",{type:"button",onClick:q,disabled:!M||I,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:I?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"add",className:"size-4"})}),e.jsx("button",{type:"button",onClick:W,disabled:I,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"close",className:"size-4"})})]}):e.jsxs(De,{onSelect:B,children:[e.jsx(w,{name:"add",className:"size-4"}),e.jsx("span",{children:"Create new branch..."})]})}),e.jsx(Dt,{}),e.jsxs(Oe,{heading:"Local branches",children:[z.map($=>e.jsxs(De,{onSelect:()=>x($),children:[e.jsxs("span",{className:"flex flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:$}),(m?.[$]?.ahead||m?.[$]?.behind)&&e.jsxs("span",{className:"typography-micro text-muted-foreground",children:[m[$].ahead||0," ahead ·"," ",m[$].behind||0," behind"]})]}),n===$&&e.jsx("span",{className:"typography-micro text-primary",children:"Current"})]},`local-${$}`)),z.length===0&&e.jsx(De,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No local branches"})})]}),e.jsx(Dt,{}),e.jsxs(Oe,{heading:"Remote branches",children:[G.map($=>e.jsx(De,{onSelect:()=>x($),children:e.jsx("span",{className:"typography-ui-label text-foreground",children:$})},`remote-${$}`)),G.length===0&&e.jsx(De,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No remote branches"})})]})]})]})})]})},Nn=n=>n.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Cn=({currentBranch:n,onRename:r,showEditButton:c=!0})=>{const[m,h]=a.useState(!1),[s,t]=a.useState(n||""),[g,u]=a.useState(!1),y=a.useRef(null),C=()=>{!n||!r||(t(n),h(!0),setTimeout(()=>y.current?.focus(),0))},S=async()=>{if(!n||!r||!s.trim())return;const l=Nn(s);if(l===n){h(!1);return}u(!0);try{await r(n,l),h(!1),t("")}finally{u(!1)}},v=()=>{h(!1),t("")},f=l=>{l.key==="Enter"?(l.preventDefault(),S()):l.key==="Escape"&&(l.preventDefault(),v())};return m?e.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:e.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:l=>{l.preventDefault(),S()},children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("input",{ref:y,value:s,onChange:l=>t(l.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:"Branch name",onKeyDown:f,autoFocus:!0}),e.jsx("button",{type:"submit",disabled:g,"aria-label":g?"Saving branch name":"Save branch name",title:g?"Saving branch name":"Save branch name",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:g?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"check",className:"size-4"})}),e.jsx("button",{type:"button",onClick:v,disabled:g,"aria-label":"Cancel branch rename",title:"Cancel branch rename",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"close",className:"size-4"})})]})}):e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary shrink-0"}),e.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[e.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:n||"Detached HEAD"}),c&&r&&n&&e.jsx(_,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:C,title:"Rename branch",children:e.jsx(w,{name:"edit",className:"size-4"})})]})]})},zs=({syncAction:n,remotes:r=[],onFetch:c,onSync:m,onRemoveRemote:h,disabled:s,removingRemoteName:t=null,aheadCount:g=0,behindCount:u=0,trackingRemoteName:y,hasUncommittedChanges:C=!1,iconOnly:S=!1,upstreamTarget:v=null})=>{const f=a.useRef(!1),l=!!t,d=r.find(M=>M.name===y)??r[0],E=u>0&&C,k=s||n!==null||l||!d||E,I=s||n!==null||l||r.length===0,T=g>0||u>0,H=["sync",u>0?`↓${u}`:null,g>0?`↑${g}`:null].filter(Boolean).join(" "),A=E?"Commit or stash your changes before syncing":d?[T?`Sync Changes (${u} down, ${g} up)`:"Sync Changes",v?`Compared with ${v}`:null].filter(Boolean).join(". "):"No remotes configured",L=()=>{d&&m(d)};return e.jsxs("div",{className:"inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"inline-flex",tabIndex:E?0:void 0,children:e.jsxs("button",{type:"button",onClick:L,disabled:k,className:te("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),"aria-label":"Sync Changes",children:[n==="sync"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"refresh",className:"size-4"}),S?T?e.jsx("span",{className:"whitespace-nowrap tabular-nums",children:[u>0?`↓${u}`:null,g>0?`↑${g}`:null].filter(Boolean).join(" ")}):null:e.jsx("span",{className:"whitespace-nowrap tabular-nums",children:H})]})})}),e.jsx(Ce,{sideOffset:8,children:A})]}),e.jsxs(He,{children:[e.jsx(Ue,{asChild:!0,children:e.jsx("button",{type:"button",className:te("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),disabled:I,"aria-label":"More sync actions",children:e.jsx(w,{name:"arrow-down-s",className:"size-4"})})}),e.jsx(Ve,{align:"start",alignOffset:-40,className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:r.map(M=>e.jsx(pe,{onSelect:z=>{if(f.current){z.preventDefault(),f.current=!1;return}c(M)},children:e.jsxs("div",{className:"flex w-full items-center gap-2",children:[e.jsx(w,{name:"refresh",className:"size-4 text-muted-foreground"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:`Fetch from ${M.name}`}),e.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:M.fetchUrl})]})}),h&&M.name!==y?e.jsx(_,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||l,onPointerDown:z=>{f.current=!0,z.preventDefault(),z.stopPropagation()},onClick:z=>{f.current=!0,z.preventDefault(),z.stopPropagation(),h(M)},"aria-label":`Remove remote ${M.name}`,title:`Remove remote ${M.name}`,children:t===M.name?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"close",className:"size-3.5"})}):null]})},M.name))})]})]})},Sn=({status:n,localBranches:r,remoteBranches:c,branchInfo:m,syncAction:h,remotes:s,onFetch:t,onSync:g,onRemoveRemote:u,removingRemoteName:y,onCheckoutBranch:C,onCreateBranch:S,onRenameBranch:v,activeIdentityProfile:f,availableIdentities:l,onSelectIdentity:d,isApplyingIdentity:E,isWorktreeMode:k,upstreamTarget:I,onOpenHistory:T,onOpenGraph:H,onOpenStashes:A,onOpenUpdateBranch:L,onOpenReintegrateCommits:M,diffScope:z,onDiffScopeChange:G,allCount:x,workingCount:B,stagedCount:q,branchAvailable:Q,diffHeaderState:U})=>{const W=T||H||A||L||M,$=(U?.totalCount??0)>0,X=z!=="turn"&&z!=="branch",ne=W||U!==null;return e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[e.jsx("div",{className:"min-w-0 flex-shrink",children:k?e.jsx(Cn,{currentBranch:n.current,onRename:v}):e.jsx(wn,{currentBranch:n.current,localBranches:r,remoteBranches:c,branchInfo:m,onCheckout:C,onCreate:S,remotes:s})}),e.jsx("div",{className:"shrink-0",children:e.jsx(dn,{activeProfile:f,identities:l,onSelect:d,isApplying:E,iconOnly:!0})}),e.jsx("div",{className:"min-w-0 shrink-0",children:e.jsx(fn,{scope:z,isGitRepo:!0,branchAvailable:Q,allCount:x,workingCount:B,stagedCount:q,turnCount:U?.turnCount??0,branchCount:U?.branchCount??0,onScopeChange:G})}),e.jsx("div",{className:"min-w-0 flex-1"}),e.jsx("div",{className:"shrink-0",children:e.jsx(zs,{syncAction:h,remotes:s,onFetch:t,onSync:g,onRemoveRemote:u,removingRemoteName:y,disabled:!n,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:n.tracking?.split("/")[0],hasUncommittedChanges:(n.files?.length??0)>0,upstreamTarget:I})}),ne?e.jsx("div",{className:"shrink-0",children:e.jsxs(He,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Ue,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":"Repository views",children:e.jsx(w,{name:"more-fill",className:"size-4"})})})}),e.jsx(Ce,{sideOffset:8,children:"Repository views"})]}),e.jsxs(Ve,{align:"end",children:[T?e.jsxs(pe,{onSelect:T,children:[e.jsx(w,{name:"history",className:"size-4"}),"History"]}):null,H?e.jsxs(pe,{onSelect:H,children:[e.jsx(w,{name:"git-branch",className:"size-4"}),"Graph"]}):null,A?e.jsxs(pe,{onSelect:A,children:[e.jsx(w,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null,L?e.jsxs(pe,{onSelect:L,children:[e.jsx(w,{name:"git-merge",className:"size-4"}),"Update branch"]}):null,M?e.jsxs(pe,{onSelect:M,children:[e.jsx(w,{name:"split-cells-horizontal",className:"size-4"}),"Re-integrate commits"]}):null,W&&U!==null?e.jsx(Ba,{}):null,U!==null?e.jsxs(pe,{disabled:!$,onSelect:U.onExpandOrCollapseAll,children:[e.jsx(w,{name:"expand-up-down",className:"size-4"}),U.expandedCount>0?"Collapse all":"Expand all"]}):null,U!==null?e.jsxs(pe,{disabled:!$||!X,onSelect:U.onToggleLoadFullFiles,children:[e.jsx(w,{name:"file-download",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Load full files"}),U.loadFullFiles?e.jsx(w,{name:"check",className:"size-4"}):null]}):null,U!==null?e.jsxs(pe,{disabled:!$,onSelect:U.onToggleWrapLines,children:[e.jsx(w,{name:"text-wrap",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Wrap lines"}),U.wrapLines?e.jsx(w,{name:"check",className:"size-4"}):null]}):null,U!==null?e.jsxs(pe,{disabled:U.layoutMode===null,onSelect:U.onToggleLayout,children:[e.jsx(w,{name:U.layoutMode==="side-by-side"?"layout-column":"align-justify",className:"size-4"}),U.layoutMode==="side-by-side"?"Switch to unified view":"Switch to side-by-side view"]}):null]})]})}):null]})},kn=({open:n,onOpenChange:r,conflictFiles:c=[],directory:m,operation:h,onAbort:s,onClearState:t})=>{const{git:g}=ut(),u=Lt(x=>x.openNewSessionDraft),y=Lt(x=>x.currentSessionId),C=rs(x=>x.setPendingInputText),S=rs(x=>x.setPendingSyntheticParts),v=Pt(x=>x.setActiveMainTab),[f,l]=a.useState(!1),[d,E]=a.useState(null),[k,I]=a.useState(null);a.useEffect(()=>{!n||!m||(l(!0),I(null),E(null),g.getConflictDetails(m).then(x=>{E(x)}).catch(x=>{const B=x instanceof Error?x.message:"Failed to load conflict details";I(B)}).finally(()=>{l(!1)}))},[m,g,n]);const T=a.useCallback(async()=>{if(!d)return null;const x=h==="merge"?"merge":"rebase",B=d.headInfo||(h==="merge"?"MERGE_HEAD":"REBASE_HEAD"),q=h==="merge"?"git commit --no-edit":"git rebase --continue",Q=`Investigate the ${x} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the ${x}. Preserve the intent of changes from ${B}.`,U=`Git ${x} operation is in progress with conflicts.
|
|
3
|
-
- Directory: ${m}
|
|
4
|
-
- Operation: ${h}
|
|
5
|
-
- Head Info: ${d.headInfo||"N/A"}
|
|
6
|
-
|
|
7
|
-
Inspect each conflicted file and both sides of every conflict. Report a concise per-file resolution strategy and any assumptions or tradeoffs. Wait for explicit user confirmation before editing, staging, or running ${q}. After confirmation, remove all conflict markers, preserve intent from both sides, verify syntax, and complete the ${x}.`,W=`${x} conflict context (JSON)
|
|
8
|
-
${JSON.stringify({directory:m,operation:d.operation,headInfo:d.headInfo,statusPorcelain:d.statusPorcelain,unmergedFiles:d.unmergedFiles,diff:d.diff},null,2)}`;return{visibleText:Q,instructionsText:U,payloadText:W}},[d,m,h]),H=()=>{s(),r(!1)},A=()=>{t?.(),r(!1)},L=async()=>{const x=await T();if(!x){R.error("No conflict details available");return}if(!y){R.error("No active session",{description:"Open or create a session to resolve conflicts."});return}C(x.visibleText,"replace"),S([{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]),v("chat"),t?.(),r(!1)},M=async()=>{const x=await T();if(!x){R.error("No conflict details available");return}u({directoryOverride:m,initialPrompt:x.visibleText,syntheticParts:[{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]}),v("chat"),t?.(),r(!1)},z=h==="merge"?"Merge":"Rebase",G=d?.unmergedFiles||c;return e.jsx(Fe,{open:n,onOpenChange:r,children:e.jsx(ze,{className:"max-w-md w-[calc(100vw-2rem)]",children:e.jsxs("div",{className:"flex flex-col gap-4 overflow-hidden",children:[e.jsxs($e,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e.jsx(Ie,{children:`${z} conflicts detected`})]}),e.jsx(Me,{children:`Resolve the ${h} conflicts to continue.`})]}),f&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Loading conflict details..."})]}),k&&e.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:`Failed to load conflict details: ${k}`}),G.length>0&&e.jsxs("div",{className:"space-y-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Conflicted files:"}),e.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:G.length})]}),e.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:e.jsx("ul",{className:"space-y-1",children:G.map(x=>e.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:x,children:x},x))})})]}),d?.headInfo&&e.jsxs("div",{className:"space-y-1 overflow-hidden",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"HEAD information:"}),e.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:d.headInfo})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(_,{variant:"default",onClick:()=>{M()},disabled:f||!d,className:"w-full gap-2",children:[f?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"add",className:"size-4"}),"Resolve in new session"]}),e.jsxs(_,{variant:"outline",onClick:()=>{L()},disabled:f||!d||!y,className:"w-full gap-2",children:[f?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"chat-1",className:"size-4"}),"Resolve in current session"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:A,className:"flex-1",children:"Continue later"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:H,className:"flex-1",children:`Abort ${z}`})]})]})]})})})},Re=8,Rn=({laned:n,totalLanes:r,isExpanded:c})=>{const{lane:m,color:h,connectors:s}=n,g=Math.max(r,m+1)*Re+Re/2,u=a.useRef(null),y=a.useRef(null);return a.useLayoutEffect(()=>{const C=u.current,S=y.current;if(!C||!S)return;const v=C.offsetHeight;if(v===0)return;const f=window.devicePixelRatio||1;S.width=g*f,S.height=v*f;const l=S.getContext("2d");if(!l)return;l.scale(f,f),l.clearRect(0,0,g,v);const d=v/2,E=m*Re+Re/2,k=getComputedStyle(S),I=k.getPropertyValue("--surface-muted-foreground").trim()||k.color,T=L=>{if(!L.startsWith("var("))return L;const M=L.slice(4,-1).trim();return k.getPropertyValue(M).trim()||I},H=[...s].sort((L,M)=>{const z=G=>G==="branch-out"||G==="merge-in";return(z(L.type)?1:0)-(z(M.type)?1:0)});for(const L of H){const M=L.fromLane*Re+Re/2,z=L.toLane*Re+Re/2,G=L.type==="passing"?.72:L.type==="branch-out"||L.type==="merge-in"?.95:1;switch(l.beginPath(),l.strokeStyle=T(L.color),l.globalAlpha=G,l.lineWidth=1.25,l.lineCap="round",L.type){case"passing":case"commit-lane":l.moveTo(M,0),l.lineTo(M,v);break;case"top-stub":l.moveTo(M,0),l.lineTo(M,d);break;case"bottom-stub":l.moveTo(M,d),l.lineTo(M,v);break;case"branch-out":{const x=(d+v)/2;l.moveTo(E,d),l.bezierCurveTo(E,x,z,x,z,v);break}case"merge-in":{const x=d/2;l.moveTo(M,0),l.bezierCurveTo(M,x,E,x,E,d);break}default:continue}l.stroke(),l.globalAlpha=1}const A=k.getPropertyValue("--background").trim()||k.getPropertyValue("--surface-background").trim();l.beginPath(),l.arc(E,d,4,0,Math.PI*2),l.fillStyle=T(h),l.fill(),l.beginPath(),l.arc(E,d,5,0,Math.PI*2),l.strokeStyle=A||I,l.lineWidth=2,l.stroke()},[n,m,h,s,r,c,g]),e.jsx("div",{ref:u,style:{width:g,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},children:e.jsx("canvas",{ref:y,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}})})},cs=15e3,ds=500,us=12,hs=8*1024*1024,ms=n=>typeof n=="string"?0:(n.original?.length??0)+(n.modified?.length??0),fs=n=>{if(n.size<=us){let h=0;for(const s of n.values())h+=ms(s);if(h<=hs)return n}const r=Array.from(n.entries()).reverse(),c=new Map;let m=0;for(const[h,s]of r){if(c.size>=us)continue;const t=ms(s);m+t>hs&&c.size>0||(c.set(h,s),m+=t)}return new Map(Array.from(c.entries()).reverse())};function ps(n,r){const c=new Date(n);return Number.isNaN(c.getTime())?n:Ta(c,r,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function En(n){switch(n){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function Fn(n){return n?n.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{const c=r.startsWith("HEAD ->");return{label:c?r.replace("HEAD -> ",""):r.replace("tag: ",""),isHead:c,isTag:r.startsWith("tag: ")}}):[]}const zn=a.memo(({entry:n,mode:r="history",laned:c,totalLanes:m,isExpanded:h,onToggle:s,files:t,isLoadingFiles:g,onCopyHash:u,directory:y,onConflict:C,onActionSuccess:S})=>{const{git:v}=ut(),f=Pt(o=>o.timeFormatPreference),l=r==="graph",d={checkout:"Check out this commit as detached HEAD?",cherryPick:"Cherry-pick this commit onto the current branch?",revert:"Stage a revert of this commit?",merge:"Merge this commit into the current branch?",rebase:"Rebase current branch onto this commit?",resetSoft:"Soft reset — HEAD moves, staged changes preserved.",resetMixed:"Mixed reset — HEAD moves, changes unstaged.",resetHard:"Hard reset — HEAD moves, all uncommitted changes permanently discarded."},E={soft:"Soft — keep staged",mixed:"Mixed — unstage changes",hard:"Hard — discard all changes"},[k,I]=a.useState(null),[T,H]=a.useState(!1),[A,L]=a.useState(""),[M,z]=a.useState(null),[G,x]=a.useState(new Set),[B,q]=a.useState(new Map),[Q,U]=a.useState(new Set),W=async()=>{if(y){I("checkout");try{await v.checkoutCommit(y,n.hash),R.success("Checked out (detached HEAD)"),S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},$=async()=>{if(!(!y||!A.trim())){I("createBranch");try{await v.createBranch(y,A.trim(),n.hash),H(!1),L(""),S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},X=async()=>{if(y){I("cherryPick");try{const o=await v.cherryPick(y,n.hash);o.conflict?C?.({conflict:!0,conflictFiles:o.conflictFiles,operation:"cherry-pick"}):S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},ne=async()=>{if(y){I("revert");try{const o=await v.revertCommit(y,n.hash);o.conflict?C?.({conflict:!0,conflictFiles:o.conflictFiles,operation:"revert"}):S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},ae=async(o,D=!1)=>{if(!(!y||k!==null)){I("reset");try{await v.resetToCommit(y,n.hash,o,D),S?.()}catch(V){R.error(String(V.message))}finally{I(null)}}},Y=async()=>{if(!M)return;const o=M;switch(z(null),o){case"checkout":return W();case"cherryPick":return X();case"revert":return ne();case"merge":return K();case"rebase":return O();case"resetSoft":return ae("soft");case"resetMixed":return ae("mixed");case"resetHard":return ae("hard",!0)}},K=async()=>{if(y){I("merge");try{const o=await v.merge(y,{branch:n.hash});o.conflict?C?.({conflict:!0,conflictFiles:o.conflictFiles,operation:"merge"}):S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},O=async()=>{if(y){I("rebase");try{const o=await v.rebase(y,{onto:n.hash});o.conflict?C?.({conflict:!0,conflictFiles:o.conflictFiles,operation:"rebase"}):S?.()}catch(o){R.error(String(o.message))}finally{I(null)}}},N=a.useCallback(async o=>{const D=o.path;if(!y){q(V=>new Map(V).set(D,"error"));return}q(V=>fs(new Map(V).set(D,"loading")));try{const se=(v.getCommitFileDiff??mn)(y,n.hash,o.path,!1),oe=new Promise((le,Ge)=>{setTimeout(()=>Ge(new Error(`Timed out after ${cs}ms`)),cs)}),he=await Promise.race([se,oe]);q(le=>fs(new Map(le).set(D,he)))}catch{q(V=>new Map(V).set(D,"error"))}},[y,n.hash,v.getCommitFileDiff]),F=a.useCallback(async o=>{const D=o.path;if(o.changeType==="R"||o.isBinary){x(he=>{const le=new Set(he);return le.has(D)?le.delete(D):le.add(D),le});return}const V=B.get(D);if(G.has(D)&&V&&V!=="error"){x(he=>{const le=new Set(he);return le.delete(D),le});return}x(he=>{const le=new Set(he);return le.add(D),le}),!(V&&V!=="error"||o.insertions+o.deletions>ds&&!Q.has(D))&&await N(o)},[B,Q,N,G]);return e.jsxs("li",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":h,onClick:s,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),s())},className:te("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",l?"hover:bg-[var(--interactive-hover)]/40":h?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[l&&c&&m!==void 0?e.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:e.jsx(Rn,{laned:c,totalLanes:m,isExpanded:h})}):e.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[l?(()=>{const o=Fn(n.refs);return o.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:o.map(D=>e.jsx("span",{className:te("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",D.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":D.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:D.label},D.label))}):null})():null,e.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:n.message}),e.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[e.jsx("span",{className:"truncate min-w-[3ch]",title:n.author_name,children:n.author_name}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"truncate min-w-0",title:ps(n.date,f),children:ps(n.date,f)})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("code",{className:"shrink-0 font-mono",children:n.hash.slice(0,8)}),e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:o=>{o.stopPropagation(),u(n.hash)},children:e.jsx(w,{name:"file-copy",className:"size-3"})})}),e.jsx(Ce,{sideOffset:8,children:"Copy SHA"})]})]})]})]}),h&&e.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[l&&M?e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[e.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:d[M]}),e.jsxs(_,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:k!==null,onClick:o=>{o.stopPropagation(),Y()},children:[k!==null?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Confirm"]}),e.jsx(_,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:k!==null,onClick:o=>{o.stopPropagation(),z(null)},children:"Cancel"})]}):l?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>{o.stopPropagation(),z("checkout")},children:"Checkout"}),T?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:A,onChange:o=>L(o.target.value),onKeyDown:o=>{o.key==="Enter"&&$(),o.key==="Escape"&&(H(!1),L(""))},placeholder:"Branch name",className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),e.jsxs(_,{variant:"outline",size:"xs",className:"h-6",disabled:!A.trim()||k!==null,onClick:o=>{o.stopPropagation(),$()},children:[k==="createBranch"?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Create"]})]}):e.jsx(_,{variant:"outline",size:"xs",className:"h-6",onClick:o=>{o.stopPropagation(),H(!0)},children:"Create branch here"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>{o.stopPropagation(),z("cherryPick")},children:"Cherry-pick"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>{o.stopPropagation(),z("revert")},children:"Revert"}),e.jsxs(He,{children:[e.jsx(Ue,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>o.stopPropagation(),children:[k==="reset"?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Reset..."]})}),e.jsx(Ve,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(o=>e.jsx(pe,{disabled:k!==null,onSelect:D=>{D.stopPropagation(),z(`reset${o.charAt(0).toUpperCase()+o.slice(1)}`)},children:E[o]},o))})]}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>{o.stopPropagation(),z("merge")},children:"Merge into current"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:o=>{o.stopPropagation(),z("rebase")},children:"Rebase onto this"})]}):null,g?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading files..."})]}):t.length===0?e.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:"No files"}):e.jsx("ul",{className:"space-y-0.5 py-2",children:t.map(o=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>F(o),className:te("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",G.has(o.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[e.jsx("span",{className:te("font-semibold w-3 text-center shrink-0",En(o.changeType)),children:o.changeType}),e.jsx("span",{className:"truncate text-foreground min-w-0",title:o.path,children:o.path}),!o.isBinary&&e.jsxs("span",{className:"shrink-0",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",o.insertions]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",o.deletions]})]}),o.isBinary&&e.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:"Binary"}),e.jsx(w,{name:G.has(o.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),G.has(o.path)&&e.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:o.changeType==="R"?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Renamed file — diff not supported"}):o.isBinary?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Binary file — no diff available"}):(()=>{const D=o.insertions+o.deletions;if(!Q.has(o.path)&&D>ds)return e.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${D} changed lines)`}),e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),e.jsx(_,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{U(se=>new Set(se).add(o.path)),N(o)},children:"Render anyway"})]});const V=B.get(o.path);return V==="loading"||V===void 0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Loading diff..."}):V==="error"?e.jsx("button",{type:"button",onClick:()=>F(o),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:"Failed to load diff. Click to retry."}):e.jsx(Fs,{original:V.original,modified:V.modified,language:ks(o.path)||"",fileName:o.path,renderSideBySide:!1,layout:"inline"})})()})]},o.path))})]})]})}),gs=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function lt(n){return gs[n%gs.length]}function $n(n){if(n.length===0)return[];const r=[],c=[];for(let m=0;m<n.length;m++){const h=n[m],s=[];for(let f=0;f<r.length;f++)r[f]===h.hash&&s.push(f);let t=s.length>0?s[0]:-1;if(t===-1){const f=r.indexOf(null);f!==-1?t=f:(t=r.length,r.push(null))}const g=s.slice(1),u=lt(t),y=r[t]===h.hash,C=h.parents.length>0;C?r[t]=h.parents[0]:r[t]=null;const S=[];for(let f=1;f<h.parents.length;f++){const l=h.parents[f],d=r.indexOf(l);if(d!==-1)S.push(d);else{const E=r.indexOf(null),k=E!==-1?E:r.length;r[k]=l,k===r.length&&r.push(l),S.push(k)}}const v=[];y&&C?v.push({fromLane:t,toLane:t,color:u,type:"commit-lane"}):y&&!C?v.push({fromLane:t,toLane:t,color:u,type:"top-stub"}):!y&&C&&v.push({fromLane:t,toLane:t,color:u,type:"bottom-stub"});for(const f of g)v.push({fromLane:f,toLane:t,color:lt(f),type:"merge-in"}),r[f]=null;for(const f of S)v.push({fromLane:t,toLane:f,color:lt(f),type:"branch-out"});for(let f=0;f<r.length;f++)r[f]!==null&&f!==t&&(S.includes(f)||v.push({fromLane:f,toLane:f,color:lt(f),type:"passing"}));c.push({commit:h,lane:t,color:u,connectors:v})}return c}const In=[{label:"25 commits",value:25},{label:"50 commits",value:50},{label:"100 commits",value:100}],Mn=({mode:n="history",log:r,isLogLoading:c,logMaxCount:m,onLogMaxCountChange:h,expandedCommitHashes:s,onToggleCommit:t,commitFilesMap:g,loadingCommitHashes:u,onCopyHash:y,directory:C,showHeader:S=!0,contentMaxHeightClassName:v="max-h-[50vh]",branchDivider:f=null,onConflict:l,onActionSuccess:d})=>{const[E,k]=a.useState(!0),I=n==="graph",T=a.useMemo(()=>I&&r?$n(r.all):[],[I,r]),H=a.useMemo(()=>Math.max(1,...T.map(W=>W.lane+1)),[T]),A=a.useMemo(()=>new Map(T.map(W=>[W.commit.hash,W])),[T]);if(!r)return null;const L=f!==null&&f.insertBeforeIndex>0&&f.insertBeforeIndex<r.all.length,M=f!==null&&f.insertBeforeIndex===r.all.length,z=L||M,G=L?r.all.slice(0,f.insertBeforeIndex):M?r.all:[],x=L?r.all.slice(f.insertBeforeIndex):[],B=f?.direction==="down"?e.jsx(w,{name:"arrow-down-s",className:"size-3.5"}):e.jsx(w,{name:"arrow-up",className:"size-3.5"}),q=W=>e.jsx("ul",{className:"divide-y divide-border/60",children:W.map($=>e.jsx(zn,{entry:$,mode:n,laned:I?A.get($.hash):void 0,totalLanes:I?H:void 0,isExpanded:s.has($.hash),onToggle:()=>t($.hash),files:g.get($.hash)??[],isLoadingFiles:u.has($.hash),onCopyHash:y,directory:C,onConflict:l,onActionSuccess:d},$.hash))}),Q=r.all.length>=m?e.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:e.jsx(_,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(m+25),disabled:c,className:"px-3 text-muted-foreground hover:text-foreground",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(w,{name:"loader-4",className:"size-3 animate-spin"}),"Loading..."]}):"Load more"})}):null,U=e.jsx(Ga,{outerClassName:`min-h-0 ${v}`,className:"h-full w-full",children:r.all.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"No commits found"})}):z&&f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-0",children:[G.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:q(G)}):null,e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60"}),e.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"truncate",title:f.branchName,children:f.branchName}),B]}),e.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),x.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:q(x)}):null]}),Q]}):e.jsxs(e.Fragment,{children:[q(r.all),Q]})});return S?e.jsxs(xn,{open:E,onOpenChange:k,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs(bn,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"History"}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&e.jsx("div",{onClick:W=>W.stopPropagation(),onPointerDown:W=>W.stopPropagation(),children:e.jsxs(Oa,{value:String(m),onValueChange:W=>h(Number(W)),disabled:c,children:[e.jsx(_a,{size:"sm",className:"w-auto",disabled:c,children:e.jsx(Ha,{placeholder:"Commits"})}),e.jsx(Ua,{children:In.map(W=>e.jsx(Va,{value:String(W.value),children:W.label},W.value))})]})}),E?e.jsx(w,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):e.jsx(w,{name:"arrow-down-s",className:"size-4 text-muted-foreground"})]})]}),e.jsx(yn,{children:U})]}):z?e.jsx("section",{className:"h-full min-h-0",children:U}):e.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:U})},Dn=a.memo(function({mode:r,onOpenChange:c,onRefresh:m,isRefreshing:h,log:s,maxCount:t,onMaxCountChange:g,expandedCommitHashes:u,onToggleCommit:y,commitFilesMap:C,loadingCommitHashes:S,onCopyHash:v,directory:f,branchDivider:l,onConflict:d,onActionSuccess:E}){return r?e.jsx(Fe,{open:r!==null,onOpenChange:c,children:e.jsxs(ze,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs($e,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Ie,{children:r==="graph"?"Graph":"History"}),e.jsxs(_,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:m,disabled:h,title:"Refresh","aria-label":"Refresh",children:[e.jsx(w,{name:"refresh",className:te("size-4",h&&"animate-spin")}),"Refresh"]})]}),e.jsx(Me,{children:"Browse recent commits and inspect changed files."})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Mn,{mode:r==="graph"?"graph":"history",log:s,isLogLoading:h,logMaxCount:t,onLogMaxCountChange:g,expandedCommitHashes:u,onToggleCommit:y,commitFilesMap:C,loadingCommitHashes:S,onCopyHash:v,directory:f,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:r==="graph"?null:l,onConflict:r==="graph"?d:void 0,onActionSuccess:r==="graph"?E:void 0})})]})}):null}),Ln=({open:n,onOpenChange:r,operation:c,targetBranch:m,onConfirm:h})=>{const[s,t]=a.useState(!0),[g,u]=a.useState(!1),y=c==="merge"?"Merge":"Rebase",C=async()=>{u(!0);try{await h(s),r(!1)}catch(v){const f=v instanceof Error?v.message:`Failed to ${c}`;R.error(f)}finally{u(!1)}},S=()=>{g||r(!1)};return e.jsx(Fe,{open:n,onOpenChange:g?void 0:r,children:e.jsxs(ze,{className:"max-w-md",children:[e.jsxs($e,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),e.jsx(Ie,{children:"Uncommitted Changes"})]}),e.jsx(Me,{children:`Stash your local changes before starting the ${c}.`})]}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:"This will:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[e.jsx("li",{children:"Stash your uncommitted changes"}),e.jsxs("li",{children:[c==="merge"?"Merge":"Rebase"," ",c==="merge"?"with":"onto"," ",e.jsx("span",{className:"font-mono text-primary",children:m})]}),s&&e.jsx("li",{children:"Restore your stashed changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(Wa,{checked:s,onChange:t,disabled:g,ariaLabel:"Restore stashed changes after operation"}),e.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!g&&t(!s),children:`Restore stashed changes after ${c}`})]}),e.jsxs(_e,{className:"gap-2",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:S,disabled:g,children:"Cancel"}),e.jsx(_,{variant:"default",size:"sm",onClick:C,disabled:g,className:"gap-1.5",children:g?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),"Processing..."]}):`${y}`})]})]})})},Pn=({open:n,onOpenChange:r,directory:c,hasUncommittedChanges:m,hasStagedChanges:h=!1,uncommittedFileCount:s,onChanged:t})=>{const{git:g}=ut(),[u,y]=a.useState([]),[C,S]=a.useState(!1),[v,f]=a.useState(""),[l,d]=a.useState(""),[E,k]=a.useState(null),[I,T]=a.useState({}),H=a.useCallback(async()=>{if(c){S(!0);try{const x=await g.listGitStashes(c);y(x.stashes),T({})}catch(x){R.error(x instanceof Error?x.message:"Failed to load stashes")}finally{S(!1)}}},[c,g]);a.useEffect(()=>{n&&H()},[H,n]),a.useEffect(()=>{if(!n||!c||u.length===0)return;let x=!1;const B=u.map(q=>q.ref);return g.countGitStashFiles(c,B).then(q=>{x||T(q.counts)}).catch(()=>{}),()=>{x=!0}},[c,g,n,u]);const A=a.useMemo(()=>{const x=v.trim().toLowerCase();return x?u.filter(B=>`${B.ref} ${B.message} ${B.relativeTime}`.toLowerCase().includes(x)):u},[v,u]),L=a.useCallback(async x=>{await H(),await t?.(x)},[H,t]),M=async()=>{if(!(!c||E)){k("create");try{const x=await g.stashGitChanges(c,{message:l.trim()||void 0});x.created?(R.success("Changes stashed"),d("")):R.info("No local changes to stash"),await L({affectsIndex:!!(x.created&&h)})}catch(x){R.error(x instanceof Error?x.message:"Failed to stash changes")}finally{k(null)}}},z=async(x,B)=>{if(!(!c||E)&&!(B==="drop"&&!window.confirm(`Drop ${x.ref}?`))){k(`${B}:${x.ref}`);try{B==="apply"&&await g.applyGitStash(c,{ref:x.ref}),B==="pop"&&await g.popGitStash(c,{ref:x.ref}),B==="drop"&&await g.dropGitStash(c,{ref:x.ref});const q=B==="apply"?"Stash applied":B==="pop"?"Stash popped":"Stash dropped";R.success(q),await L({affectsIndex:B!=="drop"})}catch(q){const Q=B==="apply"?"Failed to apply stash":B==="pop"?"Failed to pop stash":"Failed to drop stash";R.error(q instanceof Error?q.message:Q),await L({affectsIndex:B!=="drop"})}finally{k(null)}}},G=E!==null;return e.jsx(Fe,{open:n,onOpenChange:r,children:e.jsxs(ze,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs($e,{children:[e.jsxs(Ie,{className:"flex items-center gap-2",children:[e.jsx(w,{name:"archive-stack",className:"h-5 w-5"}),"Stashes"]}),e.jsx(Me,{children:"Save, restore, and clean up Git stashes for this repository."})]}),e.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(is,{value:l,onChange:x=>d(x.target.value),placeholder:"Stash name",disabled:G||!m,className:"flex-1"}),e.jsxs(_,{onClick:M,disabled:!m||G||!c,children:[E==="create"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"inbox-archive",className:"size-4"}),`Stash ${s} files`]})]}),e.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:"Untracked files are included automatically."})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(w,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(is,{value:v,onChange:x=>f(x.target.value),placeholder:"Search stashes",className:"pl-9"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:C?e.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:e.jsx(w,{name:"loader-4",className:"size-5 animate-spin"})}):A.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:v?"No matching stashes.":"No stashes yet."}):A.map((x,B)=>e.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[e.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[e.jsx("p",{className:"typography-small truncate text-foreground",children:x.message||"Untitled stash"}),e.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{children:B===0&&!v.trim()?"Latest":`#${B+1}`})}),e.jsx(Ce,{sideOffset:6,children:x.ref})]})," · ",x.relativeTime," · ",typeof I[x.ref]=="number"?`${I[x.ref]} files`:"counting files..."]})]}),e.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[e.jsx(zt,{label:"Apply",loading:E===`apply:${x.ref}`,onClick:()=>z(x,"apply"),disabled:G,children:e.jsx(w,{name:"inbox-unarchive",className:"size-4"})}),e.jsx(zt,{label:"Pop",loading:E===`pop:${x.ref}`,onClick:()=>z(x,"pop"),disabled:G,children:e.jsx(w,{name:"inbox-unarchive-fill",className:"size-4"})}),e.jsx(zt,{label:"Drop",loading:E===`drop:${x.ref}`,onClick:()=>z(x,"drop"),disabled:G,destructive:!0,children:e.jsx(w,{name:"delete-bin",className:"size-4"})})]})]},x.ref))})]})})},zt=({label:n,loading:r,disabled:c,destructive:m,onClick:h,children:s})=>e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":n,"aria-busy":r||void 0,className:te("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",m?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground"),onClick:h,disabled:c,children:r?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):s})}),e.jsx(Ce,{sideOffset:6,children:n})]}),An=({currentBranch:n,localBranches:r,remoteBranches:c,onMerge:m,onRebase:h,disabled:s=!1,isOperating:t=!1,operationLogs:g=[],onOperationComplete:u,mode:y="dialog",defaultTargetBranch:C})=>{const[S,v]=a.useState(!1),[f,l]=a.useState("merge"),[d,E]=a.useState(null),[k,I]=a.useState(!1),[T,H]=a.useState(""),A=a.useRef(null),L=a.useRef(null),M=s||t,z=n||"current branch",G=g.length>0&&g.every(O=>O.status==="done"||O.status==="error"),x=g.some(O=>O.status==="error");a.useEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[g]);const B=a.useMemo(()=>{const O=T.toLowerCase(),N=new Set(c.map(o=>o.slice(o.indexOf("/")+1)).filter(Boolean)),F=r.filter(o=>o!==n&&!N.has(o));return O?F.filter(o=>o.toLowerCase().includes(O)):F},[T,r,n,c]),q=a.useMemo(()=>{const O=T.toLowerCase();return O?c.filter(N=>N.toLowerCase().includes(O)):c},[T,c]),Q=a.useCallback(()=>C&&(c.includes(C)||r.includes(C))?C:null,[C,r,c]),U=()=>{v(!0),E(Q()),l("merge"),H("")},W=O=>{E(O),I(!1),H("")},$=()=>{d&&(f==="merge"?m(d):h(d))},X=()=>{t||(E(null),l("merge"),H(""),v(!1))},ne=()=>{t&&!G||(G&&u?.(),E(null),l("merge"),H(""),v(!1))};a.useEffect(()=>{k||H("")},[k]),a.useEffect(()=>{y==="dialog"||d||E(Q())},[y,Q,d]);const K=t?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{ref:L,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:g.map((O,N)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"mt-0.5 shrink-0",children:[O.status==="running"&&e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),O.status==="done"&&e.jsx(w,{name:"check",className:"size-3.5 text-success"}),O.status==="error"&&e.jsx(w,{name:"close",className:"size-3.5 text-destructive"}),O.status==="pending"&&e.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),e.jsx("span",{className:te("typography-micro",O.status==="error"&&"text-destructive",O.status==="done"&&"text-muted-foreground",O.status==="running"&&"text-foreground",O.status==="pending"&&"text-muted-foreground/60"),children:O.message})]},N))})}),G?y==="dialog"?e.jsx(_e,{children:e.jsx(_,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):e.jsx("div",{className:"flex justify-end",children:e.jsx(_,{variant:"default",size:"sm",onClick:ne,children:x?"Close":"Done"})}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Operation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>l("merge"),className:te("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"git-merge",className:te("size-4",f==="merge"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:te("typography-ui-label",f==="merge"?"text-foreground":"text-muted-foreground"),children:"Merge"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Create a merge commit and preserve branch history."})]}),e.jsxs("button",{type:"button",onClick:()=>l("rebase"),className:te("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",f==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"git-branch",className:te("size-4",f==="rebase"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:te("typography-ui-label",f==="rebase"?"text-foreground":"text-muted-foreground"),children:"Rebase"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Replay your commits on top of the selected branch."})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?`Branch to merge into ${z}`:"Branch to rebase onto"}),e.jsxs(He,{open:k,onOpenChange:I,modal:!1,children:[e.jsx(Ue,{asChild:!0,children:e.jsxs("button",{type:"button",className:te(Ka({size:"default"}),"w-full"),children:[e.jsx("span",{className:te("truncate",!d&&"text-muted-foreground"),children:d||"Select Branch"}),e.jsx(w,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),e.jsx(Ve,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:e.jsxs(ws,{className:"h-full min-h-0",children:[e.jsx(Ns,{ref:A,placeholder:"Search branches...",value:T,onValueChange:H,onKeyDown:O=>O.stopPropagation()}),e.jsxs(Cs,{className:"h-full min-h-0",disableHorizontal:!0,children:[e.jsx(Ss,{children:"No branches found."}),B.length>0&&e.jsx(Oe,{heading:"Local branches",children:B.map(O=>e.jsx(De,{onSelect:()=>W(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`local-${O}`))}),B.length>0&&q.length>0?e.jsx(Dt,{}):null,q.length>0&&e.jsx(Oe,{heading:"Remote branches",children:q.map(O=>e.jsx(De,{onSelect:()=>W(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`remote-${O}`))})]})]})})]})]}),d?e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:f==="merge"?e.jsxs(e.Fragment,{children:["This will merge"," ",e.jsx("span",{className:"font-mono text-foreground",children:d})," ","into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z})]}):e.jsxs(e.Fragment,{children:["This will rebase"," ",e.jsx("span",{className:"font-mono text-foreground",children:z})," ","onto"," ",e.jsx("span",{className:"font-mono text-foreground",children:d})]})})}):null,y==="dialog"?e.jsxs(_e,{className:"gap-2 pt-1",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:X,children:"Cancel"}),e.jsx(_,{variant:"default",size:"sm",onClick:$,disabled:!d,className:"gap-1.5",children:f==="merge"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-merge",className:"size-4"}),"Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-branch",className:"size-4"}),"Rebase"]})})]}):e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(_,{variant:"destructive",size:"sm",onClick:X,disabled:M,children:"Reset"}),e.jsx("div",{className:"flex-1"}),e.jsx(_,{variant:"default",size:"sm",onClick:$,disabled:M||!d,children:f==="merge"?"Merge":"Rebase"})]})]});return y==="bare"?K:y==="inline"?e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:"Update branch"}),e.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z}),"."]})]})}),e.jsx("div",{className:"pt-3",children:K})]}):e.jsxs(e.Fragment,{children:[e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-1.5",onClick:U,disabled:M,children:[t?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"git-merge",className:"size-4"}),e.jsx("span",{children:"Merge/Rebase"})]})}),e.jsx(Ce,{sideOffset:8,children:"Update this branch from another branch."})]}),e.jsx(Fe,{open:S,onOpenChange:O=>{O?v(!0):ne()},children:e.jsxs(ze,{className:"max-w-md",children:[e.jsxs($e,{children:[e.jsx(Ie,{children:"Update branch"}),e.jsx(Me,{children:t?G?x?"Operation Failed":"Operation Completed":f==="merge"?"Merging In Progress":"Rebasing In Progress":e.jsxs(e.Fragment,{children:["Choose how to bring another branch into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z}),"."]})})]}),K]})})]})},Bn=a.memo(function({open:r,onOpenChange:c,branchOperation:m,currentBranch:h,localBranches:s,remoteBranches:t,defaultTargetBranch:g,onMerge:u,onRebase:y,disabled:C,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:f}){return e.jsx(Fe,{open:r,onOpenChange:l=>{!l&&m!==null||c(l)},children:e.jsxs(ze,{className:"max-w-2xl min-h-[26rem]",children:[e.jsxs($e,{children:[e.jsx(Ie,{children:"Update branch"}),e.jsxs(Me,{children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:h??""}),"."]})]}),f?e.jsx(An,{mode:"bare",currentBranch:h,localBranches:s,remoteBranches:t,defaultTargetBranch:g??void 0,onMerge:u,onRebase:y,disabled:C,isOperating:m!==null,operationLogs:S,onOperationComplete:v}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Branch actions unavailable in this repository state"})]})})}),Tn=({currentDirectory:n,isUpdateBranchDialogOpen:r,setIsUpdateBranchDialogOpen:c,branchOperation:m,currentBranch:h,localBranches:s,remoteBranches:t,updateTargetBranch:g,onMerge:u,onRebase:y,isBusy:C,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:f,gitLogDialogMode:l,setGitLogDialogMode:d,onRefreshHistory:E,isLogRefreshing:k,log:I,maxCount:T,onMaxCountChange:H,expandedCommitHashes:A,onToggleCommit:L,commitFilesMap:M,loadingCommitHashes:z,onCopyHash:G,historyBranchDivider:x,onConflict:B,onActionSuccess:q,isStashesDialogOpen:Q,setIsStashesDialogOpen:U,hasUncommittedChanges:W,hasStagedChanges:$,uncommittedFileCount:X,onStashesChanged:ne,conflictDialogOpen:ae,setConflictDialogOpen:Y,conflictFiles:K,conflictOperation:O,onAbortConflict:N,onClearConflictState:F,stashDialogOpen:o,setStashDialogOpen:D,stashDialogOperation:V,stashDialogBranch:se,onConfirmStashAndRetry:oe})=>e.jsxs(e.Fragment,{children:[e.jsx(Bn,{open:r,onOpenChange:c,branchOperation:m,currentBranch:h,localBranches:s,remoteBranches:t,defaultTargetBranch:g,onMerge:u,onRebase:y,disabled:C,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:f}),e.jsx(Dn,{mode:l,onOpenChange:he=>{he||d(null)},onRefresh:E,isRefreshing:k,log:I,maxCount:T,onMaxCountChange:H,expandedCommitHashes:A,onToggleCommit:L,commitFilesMap:M,loadingCommitHashes:z,onCopyHash:G,directory:n??void 0,branchDivider:x,onConflict:B,onActionSuccess:q}),e.jsx(Pn,{open:Q,onOpenChange:U,directory:n,hasUncommittedChanges:W,hasStagedChanges:$,uncommittedFileCount:X,onChanged:ne}),n&&e.jsx(kn,{open:ae,onOpenChange:Y,conflictFiles:K,directory:n,operation:O,onAbort:N,onClearState:F}),e.jsx(Ln,{open:o,onOpenChange:D,operation:V,targetBranch:se,onConfirm:oe})]}),Gn=20,Te=new Map;function On(n){return Te.get(n)??null}function _n(n,r){if(Te.delete(n),Te.set(n,r),Te.size>Gn){const c=Te.keys().next().value;c!==void 0&&Te.delete(c)}}const $t=38,ct=200,Hn=({value:n,onChange:r,placeholder:c,disabled:m=!1,hasTouchInput:h=!1,isMobile:s=!1})=>{const t=a.useRef(null);return a.useLayoutEffect(()=>{const g=t.current;if(!g)return;const u=document.activeElement===g,y=()=>{g.style.height=`${$t}px`;const S=g.scrollHeight,v=Math.min(Math.max(S,$t),ct);g.style.height=`${v}px`,g.style.overflowY=S>ct?"auto":"hidden",S>ct&&!u&&(g.scrollTop=g.scrollHeight)};y();const C=window.requestAnimationFrame(y);return()=>{window.cancelAnimationFrame(C)}},[n]),e.jsx("textarea",{ref:t,value:n,onChange:g=>r(g.target.value),placeholder:c??"Commit message",rows:1,disabled:m,autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:s,className:te("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",m&&"opacity-50"),style:{minHeight:$t,maxHeight:ct}})},$s=({stagedCount:n,commitMessage:r,onCommitMessageChange:c,onCommit:m,onCommitAndPush:h,commitAction:s,hasPendingIndexMutation:t=!1})=>{const g=n>0,u=r.trim()&&g&&s===null&&!t,{isMobile:y,hasTouchInput:C}=qa();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),g?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(Hn,{value:r,onChange:c,placeholder:"Commit message",disabled:s!==null,hasTouchInput:C,isMobile:y}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"flex-1"}),e.jsx(_,{size:"sm",variant:"outline",onClick:m,disabled:!u,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:s==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),y?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(_,{variant:"default",size:"sm",onClick:()=>h(),disabled:!u,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:s==="commitAndPush"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(Ce,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(_,{size:"sm",variant:"default",onClick:()=>h(),disabled:!u,className:"commit-actions__btn","aria-label":"Commit and sync",children:s==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})},Un=({onOpenStashes:n})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[e.jsx(w,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:"Working tree clean"}),e.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:"All changes have been committed"}),n?e.jsxs(_,{type:"button",variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(w,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null]}),Vn=({mergeInProgress:n,rebaseInProgress:r,onContinue:c,onAbort:m,onResolveWithAI:h,conflictCount:s=0,isLoading:t=!1})=>{const[g,u]=a.useState(null),y=n&&n.head,C=r&&(r.headName||r.onto),S=y?"merge":C?"rebase":null;if(!S)return null;const v=async()=>{u("continue");try{await c()}finally{u(null)}},f=async()=>{u("abort");try{await m()}finally{u(null)}},l=g!==null,d=s>0,E=S==="merge"?"Merge":"Rebase";let k="";n?k=n.message?`Merging: ${n.message}`:`Merging ${n.head}`:r&&(k=r.headName?`Rebasing ${r.headName} onto ${r.onto||""}`:"Rebase in progress");const I=d?s===1?`${E} in progress: ${s} conflict`:`${E} in progress: ${s} conflicts`:`${E} in progress`,T=d?"Resolve conflicts, then continue the operation.":"All conflicts resolved. Continue to finish the operation.";return e.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:I}),k&&e.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:k})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:T}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:f,disabled:l||t,className:"gap-1.5",children:[g==="abort"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"close",className:"size-4"}),"Abort"]}),d?h&&e.jsx(_,{variant:"default",size:"sm",onClick:h,disabled:l||t,children:"Resolve with AI"}):e.jsxs(_,{variant:"default",size:"sm",onClick:v,disabled:l||t,className:"gap-1.5",children:[g==="continue"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"check",className:"size-4"}),"Continue"]})]})]})]})})};function Wn(n,r){const[c,m]=a.useState(new Set),[h,s]=a.useState(new Map),[t,g]=a.useState(new Set),u=a.useRef(h),y=a.useRef(t),C=a.useCallback(v=>{Ya(v).then(f=>{if(f.ok){R.success("Commit hash copied");return}R.error("Failed to copy")})},[]),S=a.useCallback(v=>{m(f=>{const l=new Set(f);return l.has(v)?l.delete(v):l.add(v),l})},[]);return a.useEffect(()=>{u.current=h},[h]),a.useEffect(()=>{y.current=t},[t]),a.useEffect(()=>{if(!n||!r)return;const v=Array.from(c).filter(l=>!u.current.has(l)&&!y.current.has(l));if(v.length===0)return;let f=!1;return g(l=>{const d=new Set(l);for(const E of v)d.add(E);return y.current=d,d}),Promise.all(v.map(l=>r.getCommitFiles(n,l).then(d=>({hash:l,files:d.files})).catch(d=>(console.error("Failed to fetch commit files:",d),{hash:l,files:[]})))).then(l=>{f||(s(d=>{const E=new Map(d);for(const{hash:k,files:I}of l)E.set(k,I);return u.current=E,E}),g(d=>{const E=new Set(d);for(const{hash:k}of l)E.delete(k);return y.current=E,E}))}),()=>{f=!0,g(l=>{let d=!1;const E=new Set(l);for(const k of v)E.delete(k)&&(d=!0);return d?(y.current=E,E):l})}},[c,n,r]),{expandedCommitHashes:c,commitFilesMap:h,loadingCommitHashes:t,handleCopyCommitHash:C,handleToggleCommit:S}}const Kn=n=>{const{remoteNames:r,localBranches:c,worktreeCreatedFromBranch:m,rootBranchHint:h,defaultBranch:s,headBranch:t}=n,g=typeof t=="string"?t.trim():"",u=f=>{if(!f)return"";let l=f.trim();if(!l||l==="HEAD")return"";if(c.includes(l))return l;l.startsWith("refs/heads/")&&(l=l.slice(11)),l.startsWith("heads/")&&(l=l.slice(6)),l.startsWith("remotes/")&&(l=l.slice(8));const d=l.indexOf("/");if(d>0){const E=l.slice(0,d);if(r.has(E)){const k=l.slice(d+1).trim();k&&(l=k)}}return l},y=f=>{const l=u(typeof f=="string"?f:"");return l&&l!==g?l:""},C=y(m);if(C)return C;const S=y(h);if(S)return S;const v=y(s);return v||(c.includes("main")?"main":c.includes("master")?"master":c.includes("develop")?"develop":"main")},qn=n=>{const{baseBranch:r,localBranches:c,remoteBranches:m}=n;return c.includes(r)?!0:m.some(h=>{const s=h.indexOf("/");return s>0&&h.slice(s+1)===r})},Yn=n=>n?n.filter(r=>!r.startsWith("remotes/")).sort():[],Jn=n=>n?n.filter(r=>r.startsWith("remotes/")).map(r=>r.replace(/^remotes\//,"")).sort():[],Zn=(n,r,c,m)=>{if(n.length>0)return n;const h=new Set,s=c?.trim();s&&s.includes("/")&&h.add(s.split("/")[0]);for(const t of r){const g=t.indexOf("/");g>0&&h.add(t.slice(0,g))}return h.size===0&&m&&h.add("origin"),Array.from(h).map(t=>({name:t,fetchUrl:m??"",pushUrl:m??""}))},Qn=(n,r)=>{const c=r?.trim().split("/")[0];return(c&&n?.[c])??n?.origin},Xn=(n,r,c)=>c?n.map(s=>s.name).map(s=>`${s}/${c}`).find(s=>r.includes(s))??c:null;function er({branches:n,status:r,remotes:c,remoteUrl:m,git:h}){const s=a.useMemo(()=>Yn(n?.all),[n?.all]),t=a.useMemo(()=>Jn(n?.all),[n?.all]),g=a.useMemo(()=>Zn(c,t,r?.tracking,m),[c,t,m,r?.tracking]),u=r?.current??null,y=a.useMemo(()=>Qn(n?.defaultBranches,r?.tracking),[n?.defaultBranches,r?.tracking]),C=a.useMemo(()=>Kn({remoteNames:new Set(g.map(f=>f.name)),localBranches:s,defaultBranch:y,headBranch:u}),[u,y,g,s]),S=!!(u&&C&&u!==C&&(r?.tracking||g.length>0)&&typeof h?.getGitRangeDiff=="function"&&qn({baseBranch:C,localBranches:s,remoteBranches:t})),v=a.useMemo(()=>Xn(g,t,C),[C,g,t]);return{localBranches:s,remoteBranches:t,effectiveRemotes:g,currentBranch:u,defaultBranch:y,baseBranch:C,branchScopeAvailable:S,updateTargetBranch:v}}const tr=n=>{if(!n)return null;try{let r=n.trim();r.startsWith("git@")&&(r=`https://${r.slice(4).replace(":","/")}`),r.endsWith(".git")&&(r=r.slice(0,-4));const c=new URL(r);return c.hostname+c.pathname}catch{return null}},sr=(n,r,c)=>{const m=new Map;r&&m.set(r.id,r);const h=tr(c);for(const s of n){if(s.authType!=="token"){m.set(s.id,s);continue}const t=s.host;if(!t){m.set(s.id,s);continue}if(!t.includes("/")){m.set(s.id,s);continue}h&&h===t&&m.set(s.id,s)}return Array.from(m.values())},ar=(n,r,c)=>{if(n?.userName&&n?.userEmail){const m=r.find(h=>h.userName===n.userName&&h.userEmail===n.userEmail);return m||(c&&c.userName===n.userName&&c.userEmail===n.userEmail?c:{id:"local-config",name:n.userName,userName:n.userName,userEmail:n.userEmail,sshKey:n.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return c??null};function nr({profiles:n,globalIdentity:r,currentIdentity:c,remoteUrl:m}){const h=a.useMemo(()=>sr(n,r,m),[n,r,m]),s=a.useMemo(()=>ar(c,n,r),[c,n,r]);return{availableIdentities:h,activeIdentityProfile:s}}function rr({currentSessionId:n,currentDirectory:r}){const[c,m]=a.useState(!1),[h,s]=a.useState([]),[t,g]=a.useState("merge"),u=a.useMemo(()=>n?`pichamber.conflict:${n}`:null,[n]),y=a.useCallback((S,v,f)=>{if(!u||typeof window>"u")return;const l={directory:S,conflictFiles:v,operation:f};window.localStorage.setItem(u,JSON.stringify(l))},[u]),C=a.useCallback(()=>{!u||typeof window>"u"||window.localStorage.removeItem(u)},[u]);return a.useEffect(()=>{if(!u||typeof window>"u"||!r)return;const S=window.localStorage.getItem(u);if(S)try{const v=JSON.parse(S);if(v.directory!==r){window.localStorage.removeItem(u);return}s(v.conflictFiles??[]),g(v.operation??"merge"),m(!0)}catch{window.localStorage.removeItem(u)}},[u,r]),{conflictDialogOpen:c,setConflictDialogOpen:m,conflictFiles:h,setConflictFiles:s,conflictOperation:t,setConflictOperation:g,persistConflictState:y,clearConflictState:C}}const ir=({runMutation:n,onMutationComplete:r,onMutationError:c,onPathsComplete:m,scheduleFlush:h})=>{const s=[];let t=!1;return{enqueue:u=>{const y=s[s.length-1];if(y?.directory===u.directory&&y.direction===u.direction){u.paths.forEach(C=>y.paths.add(C));return}s.push(u)},flush:()=>{if(t)return;const u=s.shift();if(!u)return;t=!0;const y={directory:u.directory,direction:u.direction,paths:Array.from(u.paths),rollback:u.rollback};(async()=>{try{await n(y),r(y)}catch(C){c(y,C)}finally{m(y.paths),t=!1,s.length>0&&h()}})()},clear:()=>{s.length=0},size:()=>s.length,isRunning:()=>t}},or=a.memo(function({file:r,actionLabel:c,actionSymbol:m,onAction:h,onViewDiff:s,onRevert:t,isReverting:g,stats:u,rowPaddingClassName:y,indentPx:C=0,actionAtStart:S=!1,showRevert:v=!0}){const f=it.useMemo(()=>pn(r),[r]),l=f.description,d=u?.insertions??0,E=u?.deletions??0,k=it.useCallback(A=>{A.key===" "?(A.preventDefault(),h()):A.key==="Enter"&&(A.preventDefault(),s())},[h,s]),I=it.useCallback(A=>{A.preventDefault(),A.stopPropagation(),h()},[h]),T=it.useCallback(A=>{A.preventDefault(),A.stopPropagation(),t()},[t]),H=e.jsx("button",{type:"button",onClick:I,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":c,title:c,children:m});return e.jsxs("div",{className:`group flex items-center gap-2 py-1.5 cursor-pointer ${y??"px-3"}`,role:"button",tabIndex:0,onClick:s,onKeyDown:k,style:C>0?{paddingLeft:`${C}px`}:void 0,children:[S?H:null,e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:f.color},title:l,"aria-label":l,children:f.code}),e.jsx(Ja,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const A=r.path.lastIndexOf("/");if(A===-1)return e.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:r.path,children:r.path});const L=r.path.slice(0,A),M=r.path.slice(A);return e.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[e.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:L}),e.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-foreground",children:M.slice(1)})]})]})})(),e.jsxs("span",{className:"shrink-0 typography-micro",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",E]})]}),v?e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button",onClick:T,disabled:g,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Revert changes in ${r.path}`,children:g?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"arrow-go-back",className:"size-3.5"})})}),e.jsx(Ce,{sideOffset:8,children:"Revert changes"})]}):null,S?null:H]})}),xs=14,Is=n=>n.replace(/\\/g,"/").replace(/^\/+/,"").trim(),bs=(n,r)=>({id:`dir:${n}`,path:n,name:r,children:new Map,directFiles:[],files:[]}),lr=n=>{const r=bs("","");for(const c of n){const m=Is(c.path);if(!m)continue;const s=m.split("/").filter(Boolean).slice(0,-1);let t=r;if(t.files.push(c),s.length>0){let g="";for(const u of s){g=g?`${g}/${u}`:u;const y=t.children.get(u);if(y){y.files.push(c),t=y;continue}const C=bs(g,u);C.files.push(c),t.children.set(u,C),t=C}}t.directFiles.push(c)}return r},cr=(n,r)=>{const c=[],m=(h,s)=>{const t=Array.from(h.children.values()).sort((u,y)=>u.path.localeCompare(y.path));for(const u of t)c.push({key:u.id,kind:"directory",depth:s,directory:u}),r.has(u.path)&&m(u,s+1);const g=[...h.directFiles].sort((u,y)=>u.path.localeCompare(y.path));for(const u of g)c.push({key:`file:${Is(u.path)}`,kind:"file",depth:s,file:u})};return m(n,0),c},dr=1e3,ys=34,It=30,dt="pl-0 pr-2",Mt=(n,r)=>`${n} ${r}`,ur=({groups:n,diffStats:r,revertingPaths:c,isRevertingAll:m=!1,headerBackgroundClassName:h="bg-sidebar",onVisiblePathsChange:s,onRevertAll:t,onRevertDirectory:g})=>{const u=a.useRef(null),C=Pt(N=>N.gitChangesViewMode)==="tree",S=a.useMemo(()=>n.filter(N=>N.entries.length>0),[n]),[v,f]=a.useState(new Set),[l,d]=a.useState(new Set),[E,k]=a.useState(!1),[I,T]=a.useState(null),H=a.useMemo(()=>S.map(N=>lr(N.entries)),[S]),A=a.useMemo(()=>{const N=[];return S.forEach((F,o)=>{Array.from(H[o]?.children.values()??[]).forEach(D=>{N.push(Mt(F.id,D.path))})}),N},[H,S]);a.useEffect(()=>{C&&d(N=>{const F=new Set,o=new Set(A);return N.forEach(D=>{(D.slice(D.indexOf(" ")+1).includes("/")||o.has(D))&&F.add(D)}),A.forEach(D=>F.add(D)),F})},[C,A]);const L=a.useMemo(()=>{const N=[];return S.forEach((F,o)=>{if(N.push({type:"header",key:`header:${F.id}`,groupIndex:o}),!v.has(F.id)){if(C){const D=new Set;l.forEach(se=>{se.startsWith(`${F.id} `)&&D.add(se.slice(F.id.length+1))}),cr(H[o],D).forEach(se=>{se.kind==="file"?N.push({type:"file",key:`${F.id}:${se.key}`,groupIndex:o,file:se.file,depth:se.depth}):N.push({type:"directory",key:`${F.id}:${se.key}`,groupIndex:o,directory:se.directory,depth:se.depth})});return}F.entries.forEach(D=>{N.push({type:"file",key:`${F.id}:file:${D.path}`,groupIndex:o,file:D,depth:0})})}}),t&&S.length>0&&N.push({type:"revert-all",key:"revert-all"}),N},[v,l,C,t,H,S]),M=L.length,z=M>=dr,G=jn({count:M,enabled:z,getScrollElement:()=>u.current,estimateSize:()=>ys,overscan:12,getItemKey:N=>L[N]?.key??N}),x=G.getVirtualItems(),B=a.useMemo(()=>{if(!z)return 0;const N=u.current?.scrollTop??0;return x.find(o=>o.end>N)?.index??0},[z,x,u]);a.useEffect(()=>{if(!s)return;const N=F=>F&&F.type==="file"?F.file.path:null;if(M===0){s([]);return}if(!z){const F=[];for(const o of L)if(o.type==="file"&&(F.push(o.file.path),F.length>=It))break;s(F);return}s(L.slice(B,B+Math.ceil((u.current?.clientHeight??0)/ys)+It).map(F=>N(F)).filter(F=>!!F).slice(0,It))},[s,M,L,z,B]);const q=a.useCallback(N=>{f(F=>{const o=new Set(F);return o.has(N)?o.delete(N):o.add(N),o})},[]),Q=a.useCallback((N,F)=>{d(o=>{const D=new Set(o),V=Mt(N,F);return D.has(V)?D.delete(V):D.add(V),D})},[]),U=a.useMemo(()=>{const N=new Set;return S.forEach(F=>F.entries.forEach(o=>N.add(o.path))),Array.from(N)},[S]),W=U.length,$=I?m||I.paths.some(N=>c.has(N)):!1,X=a.useCallback(async()=>{!t||m||U.length===0||(await t(U),k(!1))},[U,m,t]),ne=a.useCallback(async()=>{!g||!I||$||(await g(I.paths),T(null))},[$,g,I]),ae=a.useCallback((N,F)=>{const o=v.has(N.id),D=N.entries.length;return e.jsxs("div",{className:te("sticky top-0 z-10 flex items-center gap-2 py-2",h,dt,!F&&"mt-1 border-t border-border/40"),children:[e.jsx("button",{type:"button",onClick:()=>N.onActionAll(N.entries.map(V=>V.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":N.actionAllLabel,title:N.actionAllLabel,children:N.actionSymbol}),e.jsxs("button",{type:"button",onClick:()=>q(N.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!o,children:[e.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:N.title}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:D}),e.jsx(w,{name:"arrow-down-s",className:te("size-3.5 shrink-0 text-muted-foreground transition-transform",o&&"-rotate-90")})]})]})},[v,h,q]),Y=a.useCallback((N,F,o)=>{const D=l.has(Mt(N.id,F.path)),V=F.files.map(oe=>oe.path),se=m||V.some(oe=>c.has(oe));return e.jsxs("div",{className:te("group flex items-center gap-2 py-1.5",dt),style:{paddingLeft:`${o*xs}px`},children:[e.jsxs("button",{type:"button",onClick:()=>Q(N.id,F.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":D?`Collapse directory ${F.path}`:`Expand directory ${F.path}`,children:[D?e.jsx(w,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):e.jsx(w,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:F.path,children:F.name}),e.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:F.files.length})]}),N.showRevertActions!==!1&&g?e.jsx("button",{type:"button",onClick:()=>T({path:F.path,paths:V,count:V.length}),disabled:se,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Revert changes in ${F.path}`,title:"Revert folder changes",children:se?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"arrow-go-back",className:"size-3.5"})}):null,e.jsx("button",{type:"button",onClick:()=>N.onActionAll(F.files.map(oe=>oe.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":N.actionSymbol==="+"?`Stage all changes in ${F.path}`:`Unstage all changes in ${F.path}`,title:N.actionSymbol==="+"?`Stage all changes in ${F.path}`:`Unstage all changes in ${F.path}`,children:N.actionSymbol})]})},[l,m,g,c,Q]),K=a.useCallback((N,F)=>{if(N.type==="revert-all")return e.jsx("div",{className:te("flex justify-end py-2",dt),children:e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>k(!0),disabled:m,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[e.jsx(w,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const o=S[N.groupIndex];if(!o)return null;if(N.type==="header")return ae(o,F);if(N.type==="directory")return Y(o,N.directory,N.depth);const D=N.file;return e.jsx(or,{file:D,actionLabel:o.getActionLabel(D.path),actionSymbol:o.actionSymbol,onAction:()=>o.onActionFile(D.path),stats:r?.[D.path],onViewDiff:()=>o.onViewDiff(D.path),onRevert:()=>o.onRevertFile(D.path),isReverting:c.has(D.path)||m,rowPaddingClassName:dt,indentPx:N.depth*xs,actionAtStart:!C,showRevert:o.showRevertActions!==!1})},[r,m,C,Y,ae,c,S]),O=a.useCallback(N=>{const F=L[N],o=L[N-1];return!F||!o||F.type!=="file"&&F.type!=="directory"||o.type!=="file"&&o.type!=="directory"?!1:o.groupIndex===F.groupIndex},[L]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[e.jsx(Rs,{ref:u,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:z?e.jsx("div",{style:{height:G.getTotalSize(),position:"relative"},children:x.map(N=>{const F=L[N.index];return F?e.jsx("div",{"data-index":N.index,ref:G.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},className:te(O(N.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(F,N.index===0)},F.key):null})}):e.jsx("div",{role:"list","aria-label":"Changed files",children:L.map((N,F)=>e.jsx("div",{className:te("relative",O(F)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(N,F===0)},N.key))})}),e.jsx(Za,{containerRef:u,disableHorizontal:!0})]}),e.jsx(Fe,{open:E,onOpenChange:N=>{!m&&!N&&k(!1)},children:e.jsxs(ze,{className:"max-w-md",children:[e.jsxs($e,{children:[e.jsx(Ie,{children:"Revert all changes?"}),e.jsx(Me,{children:W===1?`Revert ${W} changed file? This cannot be undone.`:`Revert ${W} changed files? This cannot be undone.`})]}),e.jsxs(_e,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>k(!1),disabled:m,children:"Cancel"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>{X()},disabled:m,children:m?"Reverting...":"Revert all"})]})]})}),e.jsx(Fe,{open:!!I,onOpenChange:N=>{!$&&!N&&T(null)},children:e.jsxs(ze,{className:"max-w-md",children:[e.jsxs($e,{children:[e.jsx(Ie,{children:"Revert folder changes?"}),e.jsx(Me,{children:I?I.count===1?`This will discard local changes in ${I.count} file under ${I.path}.`:`This will discard local changes in ${I.count} files under ${I.path}.`:null})]}),e.jsxs(_e,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>T(null),disabled:$,children:"Cancel"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>{ne()},disabled:$||!I,children:$?"Reverting...":"Revert folder"})]})]})})]})},hr=Es(()=>vs(()=>import("./DiffView-D19Jps0i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119])).then(n=>({default:n.DiffView}))),mr=({currentDirectory:n,status:r,isGitRepo:c,isLoadingStatus:m,changeEntries:h,stagedChangeEntries:s,unstagedChangeEntries:t,effectiveRemotes:g,syncAction:u,commitAction:y,commitMessage:C,hasPendingIndexMutation:S,revertingPaths:v,isRevertingAll:f,initialDiffPath:l,initialDiffStaged:d=!1,onSyncAction:E,onMoveChangePaths:k,onRevertFile:I,onRevertAll:T,onCommitMessageChange:H,onCommit:A,onVisiblePathsChange:L,loadDiff:M})=>{const[z,G]=a.useState(()=>l?{type:"diff",path:l,staged:d}:{type:"list"}),[x,B]=a.useState(null),[q,Q]=a.useState(null),[U,W]=a.useState(0);a.useEffect(()=>{l&&G(Y=>Y.type==="diff"&&Y.path===l&&Y.staged===d?Y:{type:"diff",path:l,staged:d})},[l,d]);const $=a.useMemo(()=>z.type==="diff"&&h.some(Y=>Y.path===z.path),[h,z]);a.useEffect(()=>{if(z.type!=="diff"||!$){B(null),Q(null);return}let Y=!1;return B(null),Q(null),M(z.path,z.staged).then(K=>{Y||B(K)}).catch(K=>{Y||Q(K instanceof Error?K.message:String(K))}),()=>{Y=!0}},[U,M,z,$]);const X=a.useCallback((Y,K=!1)=>{G({type:"diff",path:Y,staged:K})},[]),ne=a.useMemo(()=>{const Y=[];return s.length>0&&Y.push({id:"staged",title:"Staged",entries:s,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:K=>`Unstage ${K}`,onActionFile:K=>k([K],"unstage"),onActionAll:K=>k(K,"unstage"),onViewDiff:K=>X(K,!0),onRevertFile:I,showRevertActions:!1,accent:!0}),t.length>0&&Y.push({id:"unstaged",title:"Changes",entries:t,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:K=>`Stage ${K}`,onActionFile:K=>k([K],"stage"),onActionAll:K=>k(K,"stage"),onViewDiff:K=>X(K,!1),onRevertFile:I}),Y},[X,k,I,s,t]),ae=a.useCallback(Y=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsx("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||n||""})}),e.jsx("div",{className:"min-h-0 flex-1",children:Y})]}),[n,r]);return n?c===null||c===!0&&!r?ae(e.jsx(Ee,{loading:!0,message:"Checking repository..."})):c===!1?ae(e.jsx(a.Suspense,{fallback:e.jsx(Ee,{loading:!0,message:"Loading last turn changes..."}),children:e.jsx(hr,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):z.type==="diff"?e.jsx(fr,{path:z.path,diff:x,fileExists:$,error:q,onBack:()=>G({type:"list"}),onRetry:()=>W(Y=>Y+1)}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||n}),e.jsx(zs,{syncAction:u,remotes:g,onFetch:Y=>E("fetch",Y),onSync:Y=>E("sync",Y),disabled:y!==null||m,aheadCount:r?.ahead??0,behindCount:r?.behind??0,trackingRemoteName:r?.tracking?.split("/")[0],hasUncommittedChanges:h.length>0})]}),h.length>0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 pt-2",children:e.jsx(ur,{groups:ne,diffStats:r?.diffStats,revertingPaths:v,onRevertAll:T,isRevertingAll:f,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:L})}),e.jsx("div",{className:"shrink-0 border-t border-border/40 px-3 pb-3 pt-3",children:e.jsx($s,{stagedCount:s.length,commitMessage:C,onCommitMessageChange:H,onCommit:()=>{if(!C.trim()){R.error("Enter a commit message");return}if(s.length===0){R.error("Select at least one file to commit");return}A({pushAfter:!1})},onCommitAndPush:()=>{if(!C.trim()){R.error("Enter a commit message");return}if(s.length===0){R.error("Select at least one file to commit");return}A({pushAfter:!0})},commitAction:y,hasPendingIndexMutation:S})})]}):e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Ee,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):ae(e.jsx(Ee,{message:"Select a session or directory to view Git status"}))},Ee=({message:n,description:r,loading:c=!1,icon:m=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[c?e.jsx(w,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,m?e.jsx(w,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:n}),r?e.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null]})}),fr=({path:n,diff:r,fileExists:c,error:m,onBack:h,onRetry:s})=>{const t=a.useMemo(()=>ks(n)||"text",[n]);return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Back",onClick:h,children:e.jsx(w,{name:"arrow-left",className:"size-5"})}),e.jsx("div",{className:"min-w-0 flex-1 px-2",children:e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:n})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:c?m?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:m}),e.jsx(_,{type:"button",size:"sm",variant:"outline",onClick:s,children:"Retry"})]})}):r?r.isBinary?e.jsx(Ee,{icon:!0,message:"Content of this file cannot be viewed."}):Qa(n)?e.jsx(Ee,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):e.jsx(Rs,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.jsx(Fs,{original:r.original,modified:r.modified,language:t,fileName:n,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):e.jsx(Ee,{loading:!0,message:"Loading diff..."}):e.jsx(Ee,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},js=Es(()=>vs(()=>import("./DiffView-D19Jps0i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119])).then(n=>({default:n.DiffView}))),pr=15e3,gr=40,xr=20,Eo=({isActive:n,chrome:r="desktop",initialDiffPath:c=null,initialDiffStaged:m=!1,gitHeaderSlot:h=null})=>{const{git:s}=ut(),t=Xa(),g=Lt(i=>i.currentSessionId),{profiles:u,globalIdentity:y,defaultGitIdentityId:C,loadProfiles:S,loadGlobalIdentity:v,loadDefaultGitIdentityId:f}=un(os(i=>({profiles:i.profiles,globalIdentity:i.globalIdentity,defaultGitIdentityId:i.defaultGitIdentityId,loadProfiles:i.loadProfiles,loadGlobalIdentity:i.loadGlobalIdentity,loadDefaultGitIdentityId:i.loadDefaultGitIdentityId}))),l=en(t??null),d=tn(t??null),E=sn(t??null),k=an(t??null),I=nn(t??null),T=rn(t??null),H=on(t??null),{setActiveDirectory:A,fetchAll:L,ensureAll:M,fetchStatus:z,fetchBranches:G,fetchLog:x,setLogMaxCount:B,fetchIdentity:q,prefetchDiffs:Q,clearDiffCache:U,moveStatusPathsOptimistically:W,restoreStatus:$,bumpIndexRevision:X}=ln(os(i=>({setActiveDirectory:i.setActiveDirectory,fetchAll:i.fetchAll,ensureAll:i.ensureAll,fetchStatus:i.fetchStatus,fetchBranches:i.fetchBranches,fetchLog:i.fetchLog,setLogMaxCount:i.setLogMaxCount,fetchIdentity:i.fetchIdentity,prefetchDiffs:i.prefetchDiffs,clearDiffCache:i.clearDiffCache,moveStatusPathsOptimistically:i.moveStatusPathsOptimistically,restoreStatus:i.restoreStatus,bumpIndexRevision:i.bumpIndexRevision})));a.useRef(null);const ne=a.useRef(null),ae=a.useRef(null),Y=a.useRef(null),K=a.useRef(!0);a.useEffect(()=>()=>{K.current=!1},[]);const O=a.useCallback(()=>{ne.current!==null&&(window.clearTimeout(ne.current),ne.current=null)},[]),N=a.useCallback(i=>{O(),ne.current=window.setTimeout(()=>{ne.current=null,ot(i)===ot(t)&&z(i,s,{silent:!0})},pr)},[O,t,z,s]);a.useEffect(()=>O,[O]);const F=a.useCallback(()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null)},[]),o=a.useCallback(()=>{ae.current===null&&(ae.current=window.setTimeout(()=>{ae.current=null,Y.current?.()},0))},[]),D=a.useCallback(async(i,p,b)=>{if(p==="stage"){if(s.stageGitFiles){await s.stageGitFiles(i,b);return}await Promise.all(b.map(j=>s.stageGitFile(i,j)));return}if(s.unstageGitFiles){await s.unstageGitFiles(i,b);return}await Promise.all(b.map(j=>s.unstageGitFile(i,j)))},[s]),V=a.useMemo(()=>ir({runMutation:({directory:i,direction:p,paths:b})=>D(i,p,b),onMutationComplete:({directory:i})=>{X(i),N(i)},onMutationError:({directory:i,direction:p,rollback:b},j)=>{b?.(),X(i),N(i);const P=p==="stage"?"Failed to stage changes":"Failed to unstage changes";R.error(j instanceof Error?j.message:P)},onPathsComplete:i=>{Gt(p=>{const b=new Set(p);return i.forEach(j=>b.delete(j)),b})},scheduleFlush:o}),[X,D,o,N]);a.useEffect(()=>(Y.current=V.flush,()=>{Y.current=null}),[V]),a.useEffect(()=>()=>V.clear(),[V]),a.useEffect(()=>F,[F]);const se=a.useMemo(()=>t?On(t):null,[t]),[oe,he]=a.useState(se?.commitMessage??""),le=a.useRef(null),[Ge,We]=a.useState(null),[Ms,ht]=a.useState(!1),[mt,At]=a.useState(null),[ge,Ds]=a.useState(25),[Ls,Bt]=a.useState(!1),{triggerFireworks:Ps}=hn(),Tt=a.useRef(new Map),Ke=a.useRef(0),ft=a.useCallback(()=>{Ke.current+=1,K.current&&Bt(!0)},[]),pt=a.useCallback(()=>{Ke.current=Math.max(0,Ke.current-1),K.current&&Ke.current===0&&Bt(!1)},[]),[gt,qe]=a.useState(new Set),[As,Gt]=a.useState(new Set),[xt,Ot]=a.useState(!1),[_t,Bs]=a.useState([]),[br,Ts]=a.useState(0),[Gs,Ht]=a.useState(!1),Ut=As.size>0||V.size()>0||V.isRunning();a.useCallback(()=>{const i=le.current;i&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})})},[]);const{expandedCommitHashes:Os,commitFilesMap:_s,loadingCommitHashes:Hs,handleCopyCommitHash:Us,handleToggleCommit:Vs}=Wn(t,s),{conflictDialogOpen:Ws,setConflictDialogOpen:xe,conflictFiles:Ks,setConflictFiles:be,conflictOperation:Ye,setConflictOperation:ye,persistConflictState:je,clearConflictState:me}=rr({currentSessionId:g,currentDirectory:t}),[qs,bt]=a.useState([]),[Vt,yt]=a.useState(null),[Ys,Wt]=a.useState(null),[Js,jt]=a.useState(null),[Zs,Je]=a.useState([]),[Qs,vt]=a.useState(null),[Xs,Kt]=a.useState(!1),[wt,ea]=a.useState(100),[ta,sa]=a.useState(0),[fe,Ze]=a.useState(null),[aa,Le]=a.useState(null),[na,Nt]=a.useState(!1),[Ct,qt]=a.useState("merge"),[St,Yt]=a.useState("");a.useEffect(()=>{t&&_n(t,{directory:t,commitMessage:oe})},[oe,t]),a.useEffect(()=>{n&&(S(),v(),f())},[n,S,v,f]),a.useEffect(()=>{if(!n)return;if(!t||!s?.getRemoteUrl){yt(null);return}let i=!1;return s.getRemoteUrl(t).then(p=>{i||yt(p)}).catch(()=>{i||yt(null)}),()=>{i=!0}},[n,t,s]);const Qe=a.useCallback(async()=>{if(!t||!s?.getRemotes){bt([]);return}try{const i=await s.getRemotes(t);K.current&&bt(i)}catch{K.current&&bt([])}},[t,s]);a.useEffect(()=>{n&&Qe()},[n,Qe]),a.useEffect(()=>{n&&t&&(A(t),M(t,s))},[n,t,A,M,s]),a.useEffect(()=>{if(n&&t)return cn.onGitRefreshHint(i=>{ot(i.directory)===ot(t)&&(i.paths?.length&&U(t,i.paths),z(t,s,{silent:!0}))})},[n,U,t,z,s]);const ee=a.useCallback(async(i=!0)=>{if(t)try{await Promise.all([z(t,s),G(t,s)])}catch(p){if(i){const b=p instanceof Error?p.message:"Failed to refresh repository";R.error(b)}}},[t,s,z,G]),re=a.useCallback(async()=>{t&&await x(t,s,ge)},[t,s,x,ge]),kt=a.useCallback(async()=>{t&&await q(t,s)},[t,s,q]);a.useEffect(()=>{if(!n||!t||!s?.hasLocalIdentity||l!==!0)return;const i=typeof C=="string"?C.trim():"";if(!i||i==="global"||Tt.current.get(t)===i)return;let b=!1;return(async()=>{try{const P=await s.hasLocalIdentity?.(t);if(b||P===!0)return;ft(),await s.setGitIdentity(t,i),Tt.current.set(t,i),await kt()}catch(P){console.warn("Failed to auto-apply default git identity:",P)}finally{b||pt()}})(),()=>{b=!0}},[n,ft,t,C,pt,s,l,kt]);const ce=a.useMemo(()=>d?[...d.files??[]].sort((p,b)=>p.path.localeCompare(b.path)):[],[d]),Se=a.useMemo(()=>ce.filter(ls),[ce]),Jt=a.useMemo(()=>ce.filter(gn),[ce]);a.useEffect(()=>{if(!t||ce.length===0)return;const i=[],p=new Set,b=P=>{!P||p.has(P)||(p.add(P),i.push(P))};if(Se.forEach(P=>b(P.path)),r==="mobile"&&_t.forEach(b),ce.slice(0,xr).forEach(P=>b(P.path)),i.length===0)return;const j=window.setTimeout(()=>{Q(t,s,i,{maxFiles:gr})},120);return()=>{window.clearTimeout(j)}},[ce,r,t,s,_t,Q,Se]);const Zt=i=>i?.pushed[0]?.remote||d?.tracking?.split("/")[0]||ve.find(p=>p.name==="origin")?.name||ve[0]?.name||"origin",Rt=async(i,p)=>{if(t){We(i);try{const b=j=>{const P=`${j.name}/`,J=d?.tracking?.startsWith(P)?d.tracking.slice(P.length):void 0;return{remote:j.name,branch:J,rebase:!0}};if(i==="fetch"){if(!p)throw new Error("No remote available for fetch");await s.gitFetch(t,{remote:p.name}),R.success(`Fetched from ${p.name}`)}else if(i==="pull"){if(!p)throw new Error("No remote available for pull");const j=await s.gitPull(t,b(p));R.success(j.files.length===1?`Pulled ${j.files.length} file from ${p.name}`:`Pulled ${j.files.length} files from ${p.name}`)}else if(i==="push"){const j=await s.gitPush(t);R.success(`Pushed to ${Zt(j)}`)}else if(i==="sync"){if(!p)throw new Error("No remote available for sync");let j=0,P=!1;await s.gitFetch(t,{remote:p.name});const J=await s.getGitStatus(t);if((J.behind??0)>0){if((J.files?.length??0)>0){R.error("Commit or stash your changes before syncing");return}j=(await s.gitPull(t,b(p))).files.length}((await s.getGitStatus(t)).ahead??0)>0&&(await s.gitPush(t),P=!0),j>0&&P?R.success(j===1?`Pulled ${j} file from ${p.name} and pushed to upstream`:`Pulled ${j} files from ${p.name} and pushed to upstream`):j>0?R.success(j===1?`Pulled ${j} file from ${p.name}`:`Pulled ${j} files from ${p.name}`):P?R.success(`Pushed to ${p.name}`):R.success("Already up to date")}await ee(!1),await re()}catch(b){const j=b instanceof Error?b.message:`${i==="sync"?"Sync Changes":i==="pull"?"Pull":i} failed`;R.error(j)}finally{We(null)}}},ra=a.useCallback(async(i,p)=>{if(!t)throw new Error("No active directory");const b=await s.getGitFileDiff(t,{path:i,staged:p||void 0});return{original:b.original??"",modified:b.modified??"",isBinary:b.isBinary}},[t,s]),ia=a.useCallback(async i=>{if(!t)return;const p=i.name.trim();if(!p){R.error("Remote name is required");return}if(p==="origin"){R.error("Cannot remove the origin remote");return}Wt(p);try{await s.removeRemote(t,{remote:p}),R.success(`Removed remote ${p}`),await Promise.all([ee(!1),Qe()])}catch(b){const j=b instanceof Error?b.message:`Failed to remove ${p}`;R.error(j)}finally{Wt(null)}},[t,s,Qe,ee]),Et=async(i={})=>{if(!t)return;if(!oe.trim()){R.error("Enter a commit message");return}const p=Se.map(j=>j.path).sort();if(p.length===0){R.error("Stage at least one file to commit");return}const b=i.pushAfter?"commitAndPush":"commit";At(b);try{if(await s.createGitCommit(t,oe.trim(),{files:p,stageFiles:[]}),X(t),R.success("Commit created"),he(""),await ee(),i.pushAfter){const j=d?.tracking?.split("/")[0],P=ve.find(Pa=>Pa.name===j)??ve[0];if(!P)throw new Error("No remote available");We("sync");const J=`${P.name}/`,ie=d?.tracking?.startsWith(J)?d.tracking.slice(J.length):void 0;await s.gitFetch(t,{remote:P.name});const Z=await s.getGitStatus(t);if((Z.behind??0)>0){if((Z.files?.length??0)>0){R.error("Commit or stash your changes before syncing"),await ee(!1);return}await s.gitPull(t,{remote:P.name,branch:ie,rebase:!0})}const ue=await s.getGitStatus(t);let Be;(ue.ahead??0)>0&&(Be=await s.gitPush(t)),R.success(`Pushed to ${Zt(Be)}`),r!=="mobile"&&Ps(),await ee(!1)}else await ee(!1);await re(),Ts(j=>j+1)}catch(j){const P=j instanceof Error?j.message:"Failed to create commit";R.error(P)}finally{At(null),i.pushAfter&&We(null)}},oa=async(i,p)=>{if(!t||!d)return;const b=d.current??null,j=p?.name??"origin";try{await s.createBranch(t,i,b??"HEAD"),R.success(`Created branch ${i}`),await s.checkoutBranch(t,i);let P=!1;try{await s.gitPush(t,{remote:j,branch:i,options:["--set-upstream"]}),P=!0}catch(J){const ie=J instanceof Error?J.message:`Unable to push new branch to ${j}.`;R.warning("Branch created locally, but failed to set upstream.",{description:e.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",ie]})})}await ee(),await re(),P&&R.success(`Set upstream for ${i} to ${j}`)}catch(P){const J=P instanceof Error?P.message:"Failed to create branch";throw R.error(J),P}},la=async(i,p)=>{if(t)try{await s.renameBranch(t,i,p),R.success(`Renamed ${i} to ${p}`),await ee(),await re()}catch(b){const j=b instanceof Error?b.message:`Failed to rename ${i} to ${p}`;R.error(j)}},ca=async i=>{if(!t)return;const p=i.replace(/^remotes\//,"");if(d?.current!==p)try{await s.checkoutBranch(t,p),R.success(`Checked out ${p}`),await ee(),await re()}catch(b){const j=b instanceof Error?b.message:`Failed to checkout ${p}`;R.error(j)}},da=async i=>{if(t){ft();try{await s.setGitIdentity(t,i.id),R.success(`Applied identity: ${i.name}`),await kt()}catch(p){const b=p instanceof Error?p.message:"Failed to apply identity";R.error(b)}finally{pt()}}},{localBranches:Qt,remoteBranches:Xe,effectiveRemotes:ve,currentBranch:Pe,baseBranch:et,branchScopeAvailable:Ae,updateTargetBranch:ua}=er({branches:E,status:d,remotes:qs,remoteUrl:Vt,git:s}),{availableIdentities:ha,activeIdentityProfile:ma}=nr({profiles:u,globalIdentity:y,currentIdentity:I,remoteUrl:Vt}),Xt=Se.length,fa=T||Ge!==null||mt!==null,es=!!Pe;a.useEffect(()=>{if(!t||!s||!k?.all?.length||!Pe||!et||!Ae){Le(null);return}let i=!1;return(async()=>{try{const b=await s.getGitLog(t,{from:et,to:"HEAD",maxCount:ge});if(i)return;const j=new Set((b?.all??[]).map(J=>J.hash).filter(J=>typeof J=="string"&&J.length>0));if(j.size===0){Le(null);return}const P=k.all.findIndex(J=>!j.has(J.hash));if(P===0){Le(null);return}if(P===-1){Le({insertBeforeIndex:k.all.length,branchName:Pe,direction:"up"});return}Le({insertBeforeIndex:P,branchName:Pe,direction:"up"})}catch{i||Le(null)}})(),()=>{i=!0}},[et,Ae,Pe,t,s,k,ge]),a.useEffect(()=>{vt(null)},[t]),a.useEffect(()=>{if(fe!=="graph"||!t){fe!=="graph"&&vt(null);return}let i=!1;return Kt(!0),s.getGitLog(t,{maxCount:wt,all:!0}).then(p=>{i||vt(p)}).catch(p=>{console.error("Failed to fetch graph log:",p)}).finally(()=>{i||Kt(!1)}),()=>{i=!0}},[fe,t,wt,ta,s]);const pa=a.useCallback((i,p)=>{if(!t||i.length===0)return;const b=Array.from(new Set(i));Gt(P=>{const J=new Set(P);return b.forEach(ie=>J.add(ie)),J});const j=W(t,b,p);V.enqueue({directory:t,direction:p,paths:new Set(b),rollback:()=>$(t,j)}),o()},[t,V,W,$,o]),ga=a.useCallback(async i=>{if(t){qe(p=>{const b=new Set(p);return b.add(i),b});try{await s.revertGitFile(t,i,{scope:"working"}),R.success(`Reverted ${i}`),await ee(!1)}catch(p){const b=p instanceof Error?p.message:"Failed to revert changes";R.error(b)}finally{qe(p=>{const b=new Set(p);return b.delete(i),b})}}},[t,ee,s]),tt=a.useCallback(async(i,p,b="all")=>{if(!t||i.length===0)return;const j=Array.from(new Set(i));if(xt||j.some(Z=>gt.has(Z)))return;const P=new Set(Se.map(Z=>Z.path)),J=b==="all"&&j.some(Z=>P.has(Z));p&&Ot(!0),qe(Z=>{const ue=new Set(Z);return j.forEach(Be=>ue.add(Be)),ue});const ie=[];try{if(await Promise.all(j.map(async Z=>{try{await s.revertGitFile(t,Z,{scope:b})}catch(ue){ie.push({path:Z,message:ue instanceof Error?ue.message:"Failed to revert changes"})}})),J&&ie.length<j.length&&X(t),await ee(!1),ie.length===0)R.success(j.length===1?`Reverted ${j.length} file`:`Reverted ${j.length} files`);else if(ie.length===j.length)R.error(ie[0]?.message||"Failed to revert changes");else{const Z=j.length-ie.length;R.warning(Z===1?`Reverted ${Z} file, ${ie.length} failed`:`Reverted ${Z} files, ${ie.length} failed`)}}finally{qe(Z=>{const ue=new Set(Z);return j.forEach(Be=>ue.delete(Be)),ue}),p&&Ot(!1)}},[X,t,s,xt,ee,gt,Se]),xa=a.useCallback(async i=>{await tt(i,!0)},[tt]);a.useCallback(async i=>{await tt(i,!1,"working")},[tt]);const ba=a.useCallback(()=>ht(!0),[]),st=a.useCallback(i=>{const p=i instanceof Error?i.message.toLowerCase():"";return p.includes("uncommitted changes")||p.includes("local changes")||p.includes("your local changes would be overwritten")||p.includes("please commit your changes or stash them")||p.includes("cannot rebase: you have unstaged changes")||p.includes("error: cannot pull with rebase")},[]),ke=a.useCallback((i,p)=>{Je(b=>[...b,{message:i,status:p,timestamp:Date.now()}])},[]),de=a.useCallback((i,p)=>{Je(b=>{if(b.length===0)return b;const j=[...b];return j[j.length-1]={...j[j.length-1],status:i,...p?{message:p}:{}},j})},[]),at=a.useCallback(()=>{Je([])},[]),ya=a.useCallback(()=>{Je([]),jt(null)},[]),nt=a.useCallback(i=>{const p=i.trim(),b=new Set(ve.map(P=>P.name)),j=p.indexOf("/");if(j>0){const P=p.slice(0,j),J=p.slice(j+1);if(b.has(P)&&J)return{branch:p,remote:P,remoteBranch:J}}for(const P of ve){const J=`${P.name}/${p}`;if(Xe.includes(J))return{branch:J,remote:P.name,remoteBranch:p}}return{branch:p,remote:null,remoteBranch:null}},[ve,Xe]),ja=a.useCallback(async i=>{if(!t)return;jt("merge"),at();const p=d?.current,b=nt(i);try{b.remote&&b.remoteBranch&&(ke(`Fetching ${b.remote}/${b.remoteBranch}...`,"running"),await s.gitFetch(t,{remote:b.remote,branch:b.remoteBranch}),de("done",`Fetched ${b.remote}/${b.remoteBranch}`)),ke(`Merging ${b.branch} into ${p}...`,"running");const j=await s.merge(t,{branch:b.branch});j.conflict?(de("error","Merge conflicts detected"),be(j.conflictFiles??[]),ye("merge"),xe(!0),je(t,j.conflictFiles??[],"merge")):(de("done",`Merged ${b.branch} into ${p}`),me(),ke("Refreshing repository status...","running"),await ee(),await re(),de("done","Repository status updated"))}catch(j){if(st(j))de("error","Uncommitted changes detected"),qt("merge"),Yt(b.branch),Nt(!0);else{const P=j instanceof Error?j.message:`Failed to merge ${b.branch}`;de("error",P)}}},[t,s,d,nt,ee,re,st,je,me,ke,de,at]),va=a.useCallback(async i=>{if(!t)return;jt("rebase"),at();const p=d?.current,b=nt(i);try{b.remote&&b.remoteBranch&&(ke(`Fetching ${b.remote}/${b.remoteBranch}...`,"running"),await s.gitFetch(t,{remote:b.remote,branch:b.remoteBranch}),de("done",`Fetched ${b.remote}/${b.remoteBranch}`)),ke(`Rebasing ${p} onto ${b.branch}...`,"running");const j=await s.rebase(t,{onto:b.branch});j.conflict?(de("error","Rebase conflicts detected"),be(j.conflictFiles??[]),ye("rebase"),xe(!0),je(t,j.conflictFiles??[],"rebase")):(de("done",`Rebased ${p} onto ${b.branch}`),me(),ke("Refreshing repository status...","running"),await ee(),await re(),de("done","Repository status updated"))}catch(j){if(st(j))de("error","Uncommitted changes detected"),qt("rebase"),Yt(b.branch),Nt(!0);else{const P=j instanceof Error?j.message:`Failed to rebase onto ${b.branch}`;de("error",P)}}},[t,s,d,nt,ee,re,st,je,me,ke,de,at]),wa=a.useCallback(async()=>{if(t)try{Ye==="merge"?(await s.abortMerge(t),R.success("Merge aborted")):(await s.abortRebase(t),R.success("Rebase aborted")),me(),await ee(),await re()}catch(i){const p=i instanceof Error?i.message:`Failed to abort ${Ye}`;R.error(p)}},[t,s,Ye,ee,re,me]),Na=a.useMemo(()=>d?.files?d.files.filter(i=>i.index==="U"||i.working_dir==="U"||i.index==="A"&&i.working_dir==="A"||i.index==="D"&&i.working_dir==="D").length:0,[d?.files]),Ca=a.useCallback(async()=>{if(t)try{const i=!!d?.mergeInProgress?.head,p=!!(d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto);if(i){const b=await s.continueMerge(t);b.conflict?(be(b.conflictFiles??[]),ye("merge"),xe(!0),je(t,b.conflictFiles??[],"merge"),R.error("Merge conflicts detected")):(me(),R.success("Merge completed"),await ee(),await re())}else if(p){const b=await s.continueRebase(t);b.conflict?(be(b.conflictFiles??[]),ye("rebase"),xe(!0),je(t,b.conflictFiles??[],"rebase"),R.error("Rebase conflicts detected")):(me(),R.success("Rebase step completed"),await ee(),await re())}}catch(i){const p=i instanceof Error?i.message:"Failed to continue operation";R.error(p)}},[t,s,d,ee,re,je,me]),Sa=a.useCallback(async()=>{if(t)try{!!d?.mergeInProgress?.head?(await s.abortMerge(t),R.success("Merge aborted")):(await s.abortRebase(t),R.success("Rebase aborted")),me(),await ee(),await re()}catch(i){const p=i instanceof Error?i.message:"Failed to abort operation";R.error(p)}},[t,s,d,ee,re,me]),ka=a.useCallback(()=>{if(!t)return;const p=!!d?.mergeInProgress?.head?"merge":"rebase",b=d?.files?.filter(j=>j.index==="U"||j.working_dir==="U").map(j=>j.path)??[];b.length>0&&be(b),ye(p),xe(!0)},[t,d]),Ra=a.useCallback(async i=>{if(!t)return;const p=d?.current,b=Ct,j=St,P=(d?.files??[]).some(ls);try{await s.stash(t,{message:`Auto-stash before ${b} with ${j}`,includeUntracked:!0}),P&&X(t)}catch(Z){const ue=Z instanceof Error?Z.message:"Failed to stash changes";R.error(ue);return}let J=!1,ie=!1;try{if(b==="merge"){const Z=await s.merge(t,{branch:j});Z.conflict?(ie=!0,be(Z.conflictFiles??[]),ye("merge"),xe(!0)):(J=!0,R.success(`Merged ${j} into ${p||""}`))}else{const Z=await s.rebase(t,{onto:j});Z.conflict?(ie=!0,be(Z.conflictFiles??[]),ye("rebase"),xe(!0)):(J=!0,R.success(`Rebased ${p||""} onto ${j}`))}if(i&&J)try{await s.stashPop(t),X(t),R.success("Stashed changes restored")}catch(Z){const ue=Z instanceof Error?Z.message:"Failed to restore stash";R.error(ue)}else i&&ie&&R.info("Stash restored manually required");await ee(),await re()}catch(Z){if(i)try{await s.stashPop(t),X(t)}catch{}throw Z}},[X,t,s,d,Ct,St,ee,re]),Ea=a.useCallback(i=>{Ds(i),t&&(B(t,i),x(t,s,i))},[t,x,s,B]),Fa=a.useCallback(i=>{ea(i)},[]),za=a.useCallback(()=>{Ze(null),t&&(z(t,s),G(t,s),x(t,s,ge))},[t,z,G,x,ge,s]),$a=a.useCallback(i=>{if(i.conflict){if(i.operation==="cherry-pick"||i.operation==="revert"){R.error("Conflict",{description:`Conflicts in: ${i.conflictFiles?.join(", ")??"unknown files"}. Resolve manually and commit, or abort with git cherry-pick/revert --abort.`}),t&&(z(t,s),G(t,s),x(t,s,ge));return}be(i.conflictFiles??[]),ye(i.operation),xe(!0),t&&je(t,i.conflictFiles??[],i.operation)}},[be,ye,xe,je,t,z,G,x,ge,s]),[ts,ss]=a.useState(()=>ce.length>0?"all":"branch"),[Ia,Ma]=a.useState(null),rt=`${t??""}:${ce.length>0?"nonempty":"empty"}`,as=a.useRef(rt);a.useEffect(()=>{as.current!==rt&&(as.current=rt,ss(ce.length>0?"all":"branch"))},[ce.length,rt]);const ns=a.useCallback(i=>{ss(i)},[]),Da=a.useCallback(i=>{Ma(i)},[]),Ft=l===!0&&d?e.jsx(Sn,{status:d,localBranches:Qt,remoteBranches:Xe,branchInfo:E?.branches,syncAction:Ge,remotes:ve,onFetch:i=>Rt("fetch",i),onSync:i=>Rt("sync",i),onRemoveRemote:ia,removingRemoteName:Ys,onCheckoutBranch:ca,onCreateBranch:oa,onRenameBranch:la,activeIdentityProfile:ma,availableIdentities:ha,onSelectIdentity:da,isApplyingIdentity:Ls,isWorktreeMode:!1,upstreamTarget:d.upstreamComparison?`${d.upstreamComparison.remote}/${d.upstreamComparison.branch}`:null,onOpenHistory:()=>Ze("history"),onOpenGraph:()=>Ze("graph"),onOpenStashes:ba,onOpenUpdateBranch:es?()=>Ht(!0):void 0,diffScope:ts,onDiffScopeChange:ns,allCount:ce.length,workingCount:Jt.length,stagedCount:Xt,branchAvailable:Ae,diffHeaderState:Ia}):null,La=Ft?h?Aa.createPortal(e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:Ft}),h):e.jsx("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:Ft}):null;return r==="mobile"?e.jsx(mr,{currentDirectory:t??null,status:d,isGitRepo:l,isLoadingStatus:T,changeEntries:ce,stagedChangeEntries:Se,unstagedChangeEntries:Jt,effectiveRemotes:ve,syncAction:Ge,commitAction:mt,commitMessage:oe,hasPendingIndexMutation:Ut,revertingPaths:gt,isRevertingAll:xt,initialDiffPath:c,initialDiffStaged:m,onSyncAction:(i,p)=>{Rt(i,p)},onMoveChangePaths:pa,onRevertFile:i=>{ga(i)},onRevertAll:xa,onCommitMessageChange:he,onCommit:i=>{Et(i)},onVisiblePathsChange:Bs,loadDiff:ra}):t?l===null||l===!0&&!d?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-ui-label",children:"Checking repository..."})]})}):l===!1?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(js,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,toolbarSlot:h})})}):e.jsxs("div",{className:te("flex h-full flex-col overflow-hidden"),children:[La,t&&(d?.mergeInProgress?.head||d?.rebaseInProgress?.headName||d?.rebaseInProgress?.onto)&&e.jsx(Vn,{mergeInProgress:d?.mergeInProgress,rebaseInProgress:d?.rebaseInProgress,onContinue:Ca,onAbort:Sa,onResolveWithAI:ka,conflictCount:Na,isLoading:T}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:(ce?.length??0)>0||Ae?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(js,{diffScope:ts,onDiffScopeChange:ns,branchBase:Ae?et:null,branchHead:Ae?Pe:null,showOpenInEditorAction:!0,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,hideToolbar:!0,onHeaderControlsStateChange:Da})})}),ce.length>0?e.jsx("div",{ref:le,className:"shrink-0 px-4 pb-4 pt-2",children:e.jsx($s,{stagedCount:Xt,commitMessage:oe,onCommitMessageChange:he,onCommit:()=>Et({pushAfter:!1}),onCommitAndPush:()=>Et({pushAfter:!0}),commitAction:mt,hasPendingIndexMutation:Ut})}):null]}):e.jsx(Un,{onOpenStashes:()=>ht(!0)})})}),e.jsx(Tn,{currentDirectory:t,isUpdateBranchDialogOpen:Gs,setIsUpdateBranchDialogOpen:Ht,branchOperation:Js,currentBranch:d?.current,localBranches:Qt,remoteBranches:Xe,updateTargetBranch:ua,onMerge:ja,onRebase:va,isBusy:fa,operationLogs:Zs,onOperationComplete:ya,canShowBranchWorkflows:es,gitLogDialogMode:fe,setGitLogDialogMode:Ze,onRefreshHistory:()=>{if(fe==="graph"){sa(i=>i+1);return}t&&x(t,s,ge)},isLogRefreshing:fe==="graph"?Xs:H,log:fe==="graph"?Qs??k:k,maxCount:fe==="graph"?wt:ge,onMaxCountChange:fe==="graph"?Fa:Ea,expandedCommitHashes:Os,onToggleCommit:Vs,commitFilesMap:_s,loadingCommitHashes:Hs,onCopyHash:Us,historyBranchDivider:aa,onConflict:fe==="graph"?$a:void 0,onActionSuccess:fe==="graph"?za:void 0,isStashesDialogOpen:Ms,setIsStashesDialogOpen:ht,hasUncommittedChanges:(d?.files?.length??0)>0,hasStagedChanges:Se.length>0,uncommittedFileCount:d?.files?.length??0,onStashesChanged:async i=>{t&&i?.affectsIndex&&X(t),await ee(!1),await re()},conflictDialogOpen:Ws,setConflictDialogOpen:xe,conflictFiles:Ks,conflictOperation:Ye,onAbortConflict:wa,onClearConflictState:me,stashDialogOpen:na,setStashDialogOpen:Nt,stashDialogOperation:Ct,stashDialogBranch:St,onConfirmStashAndRetry:Ra})]}):e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"Select a session or directory to view Git status"})})};export{Eo as GitView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bZ as A,cK as Z,cL as Fe,cM as Ce,cN as ke,cO as Ie,cP as ze,cQ as Ne,cR as Oe,B as ee,I as te,cS as Pe}from"./useAppFontEffects-BABx-DxZ.js";import{a as ie,s as Ve,b as Se,c as ne,d as ve,g as Be,e as re,f as I,h as De,i as Ue,j as _e,k as We,R as Ge,I as je,p as se,l as $e,m as Ke,n as qe,o as Je,w as Ye,q as ae,u as Xe,r as Qe,t as Ze,v as et,x as oe,S as tt,y as it,z as nt,A as rt,B as ye,C as he,F as st}from"./web-components-CCKlju0Z.js";import{G as at,u as ot,W as ht,a as lt,b as dt,n as le,t as ct}from"./Virtualizer-BSHVMKgK.js";import{j as C,r as k,R as L}from"./vendor-react-B5Z1Mdn3.js";import{j as ut,i as j,f as M,a as ft,k as de,l as pt,m as ce,d as gt,n as ue,b as mt,o as B,q as fe}from"./computeVirtualFileMetrics-DXkR5jdw.js";import{a as F,i as q,l as pe,h as Ct,r as St}from"./isFilePlainText-KNpEMvb-.js";import{t as H}from"./vendor-hast-util-to-html-BKBhbTDb.js";let vt=-1;var yt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++vt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;textDoucmentCache=new WeakMap;constructor(i={theme:A},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=ie(i.theme??A)?ut():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0}clearRenderCache(){const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!F(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!q(i),result:t?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();const{theme:n=A,tokenizeMaxLineLength:r=1e3}=this.options;return{theme:n,useTokenTransformer:Ve(this.options),tokenizeMaxLineLength:r}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!M(i,t.file)||!F(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){if(i.cacheKey==null)return this.lineCache=void 0,pe(i.contents);let{lineCache:e}=this;return(e==null||e.cacheKey!==i.cacheKey)&&(e={cacheKey:i.cacheKey,lines:pe(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){return this.textDoucmentCache.get(i)?.lineCount??this.getOrCreateLineCache(i).length}updateRenderCache(i,e){if(this.renderCache==null)return;const{result:t}=this.renderCache;if(t!=null){for(const[n,r]of i)t.code[n]={type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:r.map(([s,a,o])=>s===0&&a===""?o===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:o}:{type:"element",tagName:"span",properties:{"data-char":s,style:`--diffs-token-${e}:${a};`},children:[{type:"text",value:o}]})};t.baseThemeType=e,this.renderCache.isDirty=!0}}applyDocumentChange(i){if(this.renderCache==null)return;const{file:e,result:t}=this.renderCache;if(t!=null&&t.code.length!==i.lineCount){t.code.length=Math.min(t.code.length,i.lineCount);for(let n=t.code.length;n<i.lineCount;n++)t.code.push({type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(n)}]}]});this.renderCache.isDirty=!0}this.textDoucmentCache.set(e,i)}renderFile(i=this.renderCache?.file,e=Z){if(i==null)return;let{options:t,forceHighlight:n}=this.getRenderOptions(i);const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),a=i.contents.length>0,o=!a||q(i)||$(s.length,this.getTokenizeMaxLength()),h=!M(i,this.renderCache.file),d=!Se(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(o||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!o&&a&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const l=this.highlighter!=null&&ie(t.theme),c=this.highlighter!=null&&ne(this.computedLang),u=!o&&c;if(this.highlighter!=null&&l&&(n||o||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:p,options:f}=this.renderFileWithHighlighter(i,this.highlighter,o||!c);this.renderCache={file:i,options:f,highlighted:u,result:p,renderRange:void 0}}(!l||!o&&!c)&&this.asyncHighlight(i).then(({result:p,options:f})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(i,p,f,!o)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=Z){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&Ct(ft(this.options.theme)),n=e||this.highlighter!=null&&ne(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:St(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:a=!1}=this.options,o=[],h=ue(),d=Math.min(e.startingLine+e.totalLines,s);let l=0;const c=ve(e)?Be(this.lineAnnotations):void 0;c!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>I(u))})),l++);for(let u=e.startingLine;u<d;u++){const p=u+1,f=t[u];if(f==null){const g="FileRenderer.processFileResult: Line doesnt exist";throw console.error(g,{name:i.name,lineIndex:u,lineNumber:p}),new Error(g)}h.children.push(pt("context",p,`${u}`)),o.push(f),l++;const S=this.lineAnnotations[p];S!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:0,lineIndex:p,annotations:S.map(g=>I(g))})),l++)}return h.properties.style=`grid-row: span ${l}`,{gutterAST:h.children??[],contentAST:o,preAST:this.createPreElement(s),headerAST:a?void 0:this.renderHeader(i),totalLines:s,rowCount:l,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return De({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return H(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(ce({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=ue();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,Ue(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?H(ce({tagName:"code",children:i,properties:{"data-code":""}})):H(i)}async initializeHighlighter(){return this.highlighter=await gt(_e(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(i,e,t,n=!0){if(this.renderCache==null)return;const r=!M(i,this.renderCache.file)||!this.renderCache.highlighted||!F(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!F(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&M(i,t.file)&&F(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return We({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function $(i,e){return i>e}function Tt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function ge(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:i?.useTokenTransformer,tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const bt=[""];let Rt=-1;var Te=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Rt}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:A},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new yt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Ge,this.interactionManager=new je("file",se(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(se(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??A)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.annotationCache.clear(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:a}=e;this.hydrateElements(t,n),Lt(this.pre,s,this.options.collapsed)||Mt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),$e(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):bt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(r=>{e.__syncRenderView(r,t,n,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:a=!1,lineAnnotations:o,renderRange:h}){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:d=!1,themeType:l="system"}=this.options,c=d?void 0:h,u=this.renderRange,p=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,S=!M(this.file,e);if(!d&&!n&&Se(c,this.renderRange)&&!S&&!f&&!p)return this.applyCachedThemeState(l);this.renderRange=c,S&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const m=this.fileRenderer.renderFile(e,Fe);m!=null&&this.applyThemeState(t,m.themeStyles,l,m.baseThemeType),m?.headerAST!=null&&this.applyHeaderToDOM(m.headerAST,t),this.injectUnsafeCSS()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}try{const m=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,S||p)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,l,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,m)}this.applyBuffers(m,c),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||q(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${I(r)}`;let a=this.annotationCache.get(s);if(a==null||!Tt(r,a.annotation)){a?.element.remove();const o=t(r);if(o==null)continue;a={element:Ke(I(r)),annotation:r},a.element.appendChild(o),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=qe();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Je(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ye(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),a=r??n,o=this.options.theme??A,h=typeof o=="string"?o:{...o},d=ae(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=h;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=Xe({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Qe(t,a,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Ze(this.themeCSSStyle.textContent??"",ae(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=et({code:this.code});const n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let r=0;r<2;r++){const s=this.code.children[r],a=n[r];s.innerHTML=H(a.children),s.style.cssText=a.properties.style}else this.code.innerHTML=H(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const a=e.startingLine,o=t.startingLine,h=e.totalLines===1/0?Number.POSITIVE_INFINITY:a+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=Math.max(a,o),c=Math.min(h,d);if(c<=l||!this.trimDOMToOverlap(s.gutter,l,c)||!this.trimDOMToOverlap(s.content,l,c))return!1;let{length:u}=s.content.children;const p=(y,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(n,{startingLine:y,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<l?p(o,l-o):void 0;if(f===void 0&&o<l)return!1;const S=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),g=d>c?p(c,S):void 0;return g===void 0&&d>c?!1:(this.cleanupErrorWrapper(),f!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),g!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),u+=g.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(s>a)return!1;for(let o=e.children.length-1;o>=a;o-=1)e.children[o]?.remove();for(let o=s-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((h,d)=>h-d),r=new Map;if(n.length===0)return r;let s=0,a=n[s];const{children:o}=e;a===0&&(r.set(0,0),s+=1,a=n[s]);for(let h=0;h<o.length;h+=1){const d=o[h];if(!(d instanceof HTMLElement))continue;const l=this.getLineIndexFromDOMNode(d);if(l!=null){for(;a!=null&&l>=a;)r.set(a,h),s+=1,a=n[s];if(s>=n.length)break}}for(const h of n)r.has(h)||r.set(h,o.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??H(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const l=d.firstElementChild;if(!(l instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(l,this.headerElement):t.shadowRoot?.prepend(l),this.headerElement=l,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:h}=this.options;if(o!=null){const d=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ce,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,l=a?.(n)??void 0,c=h?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ke,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ie,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:oe(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):oe(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=tt;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};it(s,this.appliedPreAttributes)||(nt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Lt(i,e,t=!1){return!t&&i==null&&e!=null}function Mt(i,e,t=!1){return i==null&&e!=null&&!t}const At=5e3;let Ht=-1;function xt(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var wt=class extends Te{virtualizer;metrics;__id=`virtualized-file:${++Ht}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ne,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){!e&&rt(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!ye(e,i),n=xt(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=he(this.lineAnnotations);if(this.renderRange!=null&&n&&ve(this.renderRange)){const r=Et(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const a=Number(s);let o=r.getBoundingClientRect().height,h=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(h=!0),o+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(a,h);o!==d&&(i=!0,o===this.metrics.lineHeight*(h?2:1)?this.cache.heights.delete(a):this.cache.heights.set(a,o))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n);let s=t?.resetFileLayoutCache===!0||r;t?.metrics!=null&&(this.metrics=t.metrics,s=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,s=!0),s&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=B(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:a="scroll"}=this.options,{lineHeight:o}=this.metrics;if(r+=this.cache.fileAnnotationHeight,a==="scroll"&&!this.hasLineAnnotations())return{top:r+s*o,height:o};const h=this.getLayoutCheckpointBeforeLineIndex(s);r=h?.top??r;for(let d=h?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=B(this.metrics,e),a=Math.min(this.renderRange.startingLine,r),o=Math.min(a+this.renderRange.totalLines-1,r);if(o<a)return;const{fileAnnotationHeight:h}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:l}=this.metrics,c=s+(a===0?h:this.renderRange.bufferBefore),u=a+Math.max(Math.ceil((i-c)/l),0);return u>o?void 0:{lineNumber:u+1,top:s+h+u*l}}let d=s+(a===0?h:this.renderRange.bufferBefore);for(let l=a;l<=o;l++){if(d>=i)return{lineNumber:l+1,top:d};d+=this.getLineHeight(l)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const a=i??this.virtualizer.getWindowSpecs();this.top<a.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1){const e=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!e)return;const t=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:r=!1,overflow:s="scroll"}=this.options,{lineHeight:a}=this.metrics,o=this.fileRenderer.getLineCount(this.file),h=B(this.metrics,n),d=fe(this.metrics);if(this.height+=h,r){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,s==="scroll"&&!this.hasLineAnnotations())this.height+=o*a;else for(let l=0;l<o;l++)this.addLayoutCheckpoint(l,this.height),this.height+=this.getLineHeight(l,!1);if(o>0&&(this.height+=d),this.fileContainer!=null&&e&&!t){const l=this.fileContainer.getBoundingClientRect();l.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:this.file.name,elementHeight:l.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{heights:n,checkpoints:r}=this.cache,s=this.renderRange;if(super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.layoutDirty=!0,n.size>0&&n.clear(),r.length>0&&(r.length=0),this.isSimpleMode()&&this.computeApproximateSize(),t&&s!==void 0&&this.file!==void 0){const a=this.virtualizer.getWindowSpecs(),o=this.computeRenderRangeFromWindow(this.file,this.top??0,a);o.bufferAfter!==s.bufferAfter&&this.updateBuffers(o)}}render({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!M(this.file,e),{forceRenderOverride:a,isSetup:o}=this;this.forceRenderOverride=void 0;const h=this.syncLineAnnotations(n);if(h&&this.resetLayoutCache(),this.file=e,i=this.getOrCreateFileContainerNode(i),this.file==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(o)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();const u=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(u==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");u.connect(i,this),this.isVisible=u.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),l=this.top??0,c=this.computeRenderRangeFromWindow(this.file,l,d);return super.render({file:this.file,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(a??t)||h,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%At===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");a.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(a.lineIndex%e===0)return a}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,h=this.fileRenderer.getLineCount(i),d=this.height,l=B(this.metrics,r),c=h>0?fe(this.metrics):0,{fileAnnotationHeight:u}=this.cache,p=l+u,f=Math.max(0,d-l-u-c),S=he(this.lineAnnotations),g=e+l,y=u>0&&S&&g<n&&g+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};if(h<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};const m=Math.ceil(Math.max(n-t,0)/o),v=Math.ceil(m/a)*a+a*2,z=v/a,D=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const R=e+p,V=R+f;if(!y&&!(R<n&&V>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};const w=Math.floor(y&&D<e+p?0:(D-(e+p))/o),b=Math.floor(w/a)-Math.floor(z/2),xe=Math.ceil(h/a),E=Math.max(0,Math.min(b,xe))*a,Q=b<0?v+b*a:v,we=E===0?0:u+E*o,Ee=Math.min(Q,h-E);return{startingLine:E,totalLines:Q,bufferBefore:we,bufferAfter:Math.max(0,(h-E-Ee)*o)}}const be=z,N=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*o*2),a);let T=e+(U?.top??p),_=U?.lineIndex??0,O,P,x;const Re=U?.lineIndex??0;for(let R=Re;R<h;R++){const V=_%a===0,w=Math.floor(_/a);if(V&&(N[w]=T-(e+p),x!=null)){if(x<=0)break;x--}const b=this.getLineHeight(R,!1);T>t-b&&T<n&&(O??=w),T+b>D&&(P??=w),x==null&&T>=n&&V&&(x=be),_++,T+=b}if(O==null)if(y)O=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};P??=O;const W=Math.round(P-z/2),Le=Math.max(0,Math.ceil(h/a)-z),G=Math.max(0,Math.min(W,Le)),J=G*a,Y=W<0?v+W*a:v,Me=N[G]??0,Ae=J===0?0:u+Me,X=G+Y/a,He=X<N.length?f-N[X]:f-(T-e-p);return{startingLine:J,totalLines:Y,bufferBefore:Ae,bufferAfter:Math.max(0,He)}}};function Et(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===st&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}function Ft({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:a,renderGutterUtility:o,getHoveredLine:h}){const d=e?.(i),l=t?.(i),c=n?.(i),u=r?.(i);return C.jsxs(C.Fragment,{children:[d!=null?C.jsx("div",{slot:Ce,children:d}):C.jsxs(C.Fragment,{children:[l!=null&&C.jsx("div",{slot:"header-prefix",children:l}),c!=null&&C.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&C.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&a?.map((p,f)=>C.jsx("div",{slot:I(p),children:s(p)},f)),o!=null&&C.jsx("div",{slot:"gutter-utility-slot",style:at,children:o(h)})]})}const me=typeof window>"u"?k.useEffect:k.useLayoutEffect;function kt({file:i,options:e,lineAnnotations:t,selectedLines:n,prerenderedHTML:r,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:o,disableWorkerPool:h,contentEditable:d}){const l=ot(),c=n!==void 0,u=k.useContext(ht),p=lt(),f=k.useRef(null),S=dt(g=>{if(g!=null){if(f.current!=null)throw new Error("File: An instance should not already exist when a node is created");l!=null?f.current=new wt(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),l,s,h?void 0:u,!0):f.current=new Te(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),h?void 0:u,!0),f.current.hydrate({file:i,fileContainer:g,lineAnnotations:t,prerenderedHTML:r})}else{if(f.current==null)throw new Error("File: A File instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return me(()=>{if(f.current==null)return;const g=K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),y=!ye(f.current.options,g);f.current.setOptions(g),f.current.render({file:i,lineAnnotations:t,forceRender:y}),n!==void 0&&f.current.setSelectedLines(n)}),me(()=>{if(d&&f.current!=null){if(p===void 0)throw new Error("File: Editor is not attached");return p.edit(f.current)}},[d,p]),{ref:S,getHoveredLine:k.useCallback(()=>f.current?.getHoveredLine(),[])}}function K({options:i,controlledSelection:e,contentEditable:t,hasCustomHeader:n,hasEditor:r,hasGutterRenderUtility:s}){const a=t&&r,o=e||s||n;if(!o&&!a)return i;let h={...i};return o&&(h={...h,controlledSelection:e,renderCustomHeader:n?le:i?.renderCustomHeader,renderGutterUtility:s?le:i?.renderGutterUtility}),a&&(h={...h,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,lineHoverHighlight:"disabled"}),h}function Ut({file:i,lineAnnotations:e,selectedLines:t,options:n,metrics:r,className:s,style:a,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,prerenderedHTML:u,renderGutterUtility:p,disableWorkerPool:f=!1,contentEditable:S=!1}){const{ref:g,getHoveredLine:y}=kt({file:i,options:n,metrics:r,lineAnnotations:e,selectedLines:t,prerenderedHTML:u,hasGutterRenderUtility:p!=null,hasCustomHeader:h!=null,disableWorkerPool:f,contentEditable:S});return C.jsx(Oe,{ref:g,className:s,style:a,children:ct(Ft({file:i,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,renderGutterUtility:p,lineAnnotations:e,getHoveredLine:y}),u)})}const _t=L.memo(function({jsonString:e,className:t,maxHeight:n="100%",initiallyExpandedDepth:r=2}){const s=L.useRef(null),[a,o]=L.useState(null),h=L.useMemo(()=>{try{const c=e.trim();if(!c)return o("Empty JSON content"),null;const u=JSON.parse(c);return o(null),u}catch(c){return o(c instanceof Error?c.message:"Invalid JSON"),null}},[e]),d=L.useCallback(()=>{s.current?.expandAll()},[]),l=L.useCallback(()=>{s.current?.collapseAll()},[]);return a?C.jsx("div",{className:t,children:C.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[C.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:"Invalid JSON"}),C.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:a})]})}):h===null?null:C.jsxs("div",{className:t,children:[C.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[C.jsxs(ee,{variant:"ghost",size:"xs",onClick:d,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-down-s",className:"h-3 w-3"}),"Expand All"]}),C.jsxs(ee,{variant:"ghost",size:"xs",onClick:l,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-up-s",className:"h-3 w-3"}),"Collapse All"]})]}),C.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:n,overflow:"auto"},children:C.jsx(Pe,{ref:s,data:h,maxHeight:n,initiallyExpandedDepth:r})})]})});export{Ut as F,_t as J};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{dx as j,cM as y,cR as D}from"./useAppFontEffects-BABx-DxZ.js";import{f as k,B as C}from"./web-components-CCKlju0Z.js";import{M as P,G as O,u as L,W as M,a as R,b as A,n as F,t as H}from"./Virtualizer-BSHVMKgK.js";import{j as d,r as w}from"./vendor-react-B5Z1Mdn3.js";import{V as _,F as N}from"./VirtualizedFileDiff-CJondRlh.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:y,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:k(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(M),c=R(),i=w.useRef(null),v=A(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(D,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as f,j as e}from"./vendor-react-B5Z1Mdn3.js";import{f as j,I as x,h as T,i as U,r as R}from"./useAppFontEffects-BABx-DxZ.js";import{u as E}from"./useSwitcherItems-C7_5TB_n.js";import{t as M,o as N}from"./index-C-sV_9sb.js";import{g as P,a as G,S as B,f as F}from"./SessionUnreadDot-Dm6k5OCd.js";import{d as v}from"./vendor-base-ui-DXSHfszQ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-BdndJV2m.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BB5mQv-R.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";function dt({onSelect:t,variant:d,scopeProjectId:c}){const i=E(!0,{scopeProjectId:c}),n=j(r=>r.openNewSessionDraft),o=M(r=>r.setActiveMainTab),a=f.useCallback(()=>{o("chat"),t(),n()},[t,n,o]),[l,u]=f.useState(new Set),m=f.useCallback(r=>{u(h=>{const p=new Set(h);return p.has(r)?p.delete(r):p.add(r),p})},[]);return e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(v,{onClick:a,className:N("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),children:[e.jsx(x,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:"New session"})]}),i.length===0?e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"No recent sessions"}):i.map(r=>e.jsx(C,{item:r,depth:0,variant:d,expandedParents:l,toggleParent:m,closeDropdown:t},r.node.session.id))]})})}function C({item:t,depth:d,variant:c,expandedParents:i,toggleParent:n,closeDropdown:o}){const{node:a,secondaryMeta:l}=t,u=a.session,m=a.children.length>0,r=i.has(u.id);return e.jsxs(e.Fragment,{children:[e.jsx(H,{session:u,depth:d,variant:c,secondaryMeta:l,hasChildren:m,isExpanded:r,onToggleExpand:m?()=>n(u.id):void 0,closeDropdown:o}),m&&r?a.children.map(h=>e.jsx(C,{item:{node:h,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:l},depth:d+1,variant:c,expandedParents:i,toggleParent:n,closeDropdown:o},h.session.id)):null]})}function H({session:t,depth:d,variant:c,secondaryMeta:i,hasChildren:n,isExpanded:o,onToggleExpand:a,closeDropdown:l}){const u=j(s=>s.currentSessionId),m=j(s=>s.setCurrentSession),r=T(t.id),h=U(t.id),p=u===t.id,k=P(t),b=r?.type??"idle",g=b==="busy"||b==="retry",D=!g&&h>0&&!p,I=t.time?.updated||t.time?.created||Date.now(),L=F(I),S=i?.projectLabel?.trim()||null,w=i?.branchLabel?.trim()||null,y=w&&w!=="HEAD"?w:null,A=f.useCallback(()=>{if(p){l();return}const s=R(t);m(t.id,s??null),l()},[l,p,t,m]);return e.jsxs(v,{onClick:s=>{if(s.target?.closest("[data-switcher-expand]")){s.preventDefault();return}A()},"data-slot":"session-switcher-item",className:N("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),style:{paddingLeft:8+d*12},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[c==="compact"&&n?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:s=>{s.preventDefault(),s.stopPropagation(),a?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o?"Collapse subsessions":"Expand subsessions",children:o?e.jsx(x,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):e.jsx(x,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:k})]}),c==="default"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight typography-micro",children:[n?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:s=>{s.preventDefault(),s.stopPropagation(),a?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o?"Collapse subsessions":"Expand subsessions",children:o?e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}):e.jsx(x,{name:"arrow-right-s",className:"h-3 w-3"})}):null,e.jsx("span",{className:"flex-shrink-0",children:g?e.jsx(G,{sessionId:t.id,running:!0}):D?e.jsx(B,{label:"Session complete"}):L}),S?e.jsx("span",{className:"truncate",children:S}):null,y?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(x,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:y})]}):null]}):null]}),g?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":"Session active",title:"Session active"})}):null]})}export{dt as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-RAsmsuYk.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BABx-DxZ.js","assets/index-C-sV_9sb.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-5fyXnZFi.css","assets/vendor-base-ui-DXSHfszQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-BdndJV2m.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BB5mQv-R.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/useSwitcherItems-C7_5TB_n.js","assets/SessionUnreadDot-Dm6k5OCd.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as a}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as o,r as c,R as d}from"./vendor-react-B5Z1Mdn3.js";import{a2 as l,a5 as x,a7 as u}from"./useAppFontEffects-BABx-DxZ.js";import{t as m,o as f}from"./index-C-sV_9sb.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-BdndJV2m.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BB5mQv-R.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const w=d.lazy(()=>a(()=>import("./SessionSwitcherContent-RAsmsuYk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81])));function Bo({children:e,variant:r="default",scopeProjectId:s=null,align:n="start"}){const p=m(t=>t.isSessionDropdownOpen),i=m(t=>t.setSessionDropdownOpen);return o.jsxs(l,{open:p,onOpenChange:i,modal:!1,children:[o.jsx(x,{asChild:!0,children:e}),o.jsx(u,{align:n,sideOffset:6,className:f("overflow-hidden p-1 max-w-[calc(100vw-32px)]",r==="compact"?"w-[280px]":"w-[360px]"),children:p?o.jsx(c.Suspense,{fallback:o.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"Loading…"}),children:o.jsx(w,{onSelect:()=>i(!1),variant:r,scopeProjectId:s})}):null})]})}export{Bo as SessionSwitcherDropdown};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as m,o as h}from"./index-C-sV_9sb.js";import{j as g}from"./vendor-react-B5Z1Mdn3.js";import{cT as y,cU as D,cV as w}from"./useAppFontEffects-BABx-DxZ.js";const S="Awaiting first prompt";function F(e,t="Untitled Session"){const r=e?.title?.trim();return r||(e?.messageCount===0?S:t)}const I=(e,t,r)=>{const a=`${r}:`,o=new Set([...t].filter(s=>s.startsWith(a)));return e.size===o.size&&[...o].every(s=>e.has(s))?e:o},T=(e,t)=>{const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r},b=e=>{const t=new Date(e),r=new Date,a=(n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate(),o=new Date(r);return o.setDate(r.getDate()-1),a(t,r)?"Today":a(t,o)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},R=e=>{const t=new Date,r=new Date(e);if(((o,s)=>o.getFullYear()===s.getFullYear()&&o.getMonth()===s.getMonth()&&o.getDate()===s.getDate())(r,t)){const o=Date.now()-e;return o<6e4?"Just now":o<36e5?`${Math.floor(o/6e4)}min ago`:`${Math.floor(o/36e5)}h ago`}return b(e)},k=e=>{const t=Math.max(0,Date.now()-e),r=6e4,a=60*r,o=24*a,s=7*o,n=30*o,i=365*o;return t<a?`${Math.max(1,Math.floor(t/r))}m`:t<o?`${Math.floor(t/a)}h`:t<s?`${Math.floor(t/o)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<i?`${Math.floor(t/n)}mo`:`${Math.floor(t/i)}y ago`},d=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?d(e)!==d(t):!1,U=e=>{const t=new Map;return e.forEach(r=>{t.set(r.id,r)}),Array.from(t.values())},z=e=>`__archived__:${e}`,B=(e,t)=>{const r=m(e.directory??null),a=m(e.project?.worktree??null),o=r??a;if(!o)return"unassigned";if(t&&o===t)return"project root";const n=(t&&o.startsWith(`${t}/`)?o.slice(t.length+1):o).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},P=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),j="0.75rem",M="size-4 shrink-0",p="min-w-0 truncate typography-ui-label font-normal",x=M,v=p,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Y=$,K=e=>e?x:M,W=e=>e?v:p,u=1e3,c=60*u,l=60*c,C=e=>{const t=Math.max(0,e);return t<c?`${Math.floor(t/u)}s`:t<l?`${Math.floor(t/c)}m ${Math.floor(t%c/u)}s`:`${Math.floor(t/l)}h ${Math.floor(t%l/c)}m`},A=1e3,O=({sessionId:e,running:t,className:r})=>{const a=y(e),o=D(e),s=w(t,A),n=t?Math.max(0,s-(a??s)):o;if(n===void 0)return null;const i=C(n),f=t?`Active for ${i}`:`Last turn took ${i}`;return g.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",r),"aria-label":f,title:f,children:i})};function G({label:e,className:t}){return g.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{G as S,O as a,R as b,z as c,U as d,p as e,k as f,F as g,K as h,W as i,Y as j,$ as k,E as l,j as m,P as n,I as o,B as r,M as s,T as t};
|