@vantran-se/openchamber-web 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DZF8ntaq.js → CodeMirrorCommentWidgets-BlzB2e0C.js} +1 -1
- package/dist/assets/DiffView-D7JQzQVZ.js +4 -0
- package/dist/assets/FilesView-DC2gadXM.js +17 -0
- package/dist/assets/{GitView-DwQwqDvu.js → GitView-Gzl0wbdd.js} +4 -4
- package/dist/assets/{GuestAttachDialog-CoXM0gh_.js → GuestAttachDialog-CQdDIeco.js} +1 -1
- package/dist/assets/GuestSurfacePane-CrOhlIdt.js +1 -0
- package/dist/assets/{JsonTreeView-Cq_27v0y.js → JsonTreeView-C3QZifYe.js} +1 -1
- package/dist/assets/{LinearIssuesView-CsSSRMhn.js → LinearIssuesView-X27TCI3v.js} +1 -1
- package/dist/assets/MarkdownImageGallery-BlTWU9oH.js +1 -0
- package/dist/assets/MarkdownRendererImpl-Cno7QsJO.js +12 -0
- package/dist/assets/{OnboardingScreen-ClatMQAX.js → OnboardingScreen-Wr_UzNtt.js} +1 -1
- package/dist/assets/{PatchDiff-DOwlrIK9.js → PatchDiff-D6pWS7cD.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CrcGqqD_.js → PierreDiffViewer-DDljFbJJ.js} +3 -3
- package/dist/assets/{PlanView-BGLsMgQk.js → PlanView-LcfEbBPi.js} +4 -4
- package/dist/assets/PluginPane-DPWPLc2f.js +3 -0
- package/dist/assets/SettingsView-CFe9O3EM.js +30 -0
- package/dist/assets/{SettingsWindow-B0BAy-f9.js → SettingsWindow-DT1xhvgi.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-fcdDzCSW.js → SubmoduleDiffSummary-CBHXaIkB.js} +1 -1
- package/dist/assets/{ToolOutputDialog-B7xaUz2H.js → ToolOutputDialog-B_ZX8ZbZ.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-CkWCaUmZ.js → ToolPartDiffPreview-D_HQzkXU.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-DONC4eI2.js → VirtualizedFileDiff-BUK1ujXg.js} +1 -1
- package/dist/assets/{WalkthroughView-CXDImOXW.js → WalkthroughView-H-tYOvhO.js} +2 -2
- package/dist/assets/{appThemeRegistry-Br2TLSlb.js → appThemeRegistry-BoJGAwCP.js} +1 -1
- package/dist/assets/changesTree-CePHbFcj.js +1 -0
- package/dist/assets/commitAndPush-BzZrF8bK.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-_-20umCs.js → computeVirtualFileMetrics-kYyVjXLu.js} +2 -2
- package/dist/assets/de-ByfQDcPj.js +10 -0
- package/dist/assets/es-DzNbjsQS.js +16 -0
- package/dist/assets/fr-B8AVLrnX.js +14 -0
- package/dist/assets/{index-OKDYjcMF.js → index-0-ON1L7L.js} +1 -1
- package/dist/assets/index-DUke1nme.css +1 -0
- package/dist/assets/index-Di6zUe5h.js +41 -0
- package/dist/assets/{isDiffPlainText-D77M6q1f.js → isDiffPlainText-Bgm_aLpu.js} +1 -1
- package/dist/assets/{isFilePlainText-C54B4Mns.js → isFilePlainText-D5GMgURH.js} +1 -1
- package/dist/assets/ja-1g6S0G19.js +16 -0
- package/dist/assets/ko-CxplvYkJ.js +16 -0
- package/dist/assets/{main-CGEvLMd2.js → main--Y98ZLsD.js} +2 -2
- package/dist/assets/main-GjXmVNpD.js +896 -0
- package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
- package/dist/assets/markdownCore-CVdUcVCi.js +7 -0
- package/dist/assets/{miniChat-BSxkRQLj.js → miniChat-tTx5mpbd.js} +2 -2
- package/dist/assets/{mobile-C5KRTNOB.js → mobile-BmbiDWGb.js} +2 -2
- package/dist/assets/patchFileDiff-CV4iVQ8L.js +13 -0
- package/dist/assets/pl-f3QyqvIB.js +16 -0
- package/dist/assets/pt-BR-BsaoaiCK.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-CnkAQV6o.js → renderElectronMiniChatApp-BnCdnDhv.js} +2 -2
- package/dist/assets/renderMobileApp-CKn8nbSW.js +25 -0
- package/dist/assets/runtimeEndpointReset-sCi88eed.js +27 -0
- package/dist/assets/scheduledTasksApi-Dahv3ws0.js +1 -0
- package/dist/assets/{shikiHighlight-4O0ZM14D.js → shikiHighlight-O5_xLmWt.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-yNq7b0DZ.js → textMateThemeFromAppTheme-XM4VefqN.js} +1 -1
- package/dist/assets/tr-BNFsa6nz.js +7 -0
- package/dist/assets/uk-CJ9y5ULA.js +16 -0
- package/dist/assets/{useAppFontEffects-Bzyszv2N.js → useAppFontEffects-BN06mgHB.js} +160 -156
- package/dist/assets/{useInlineCommentController-zOf6ORAq.js → useInlineCommentController-Bb9Gjz1Q.js} +2 -2
- package/dist/assets/{useRootScrollLock-DCaZ4BWi.js → useRootScrollLock-Chk1cFUw.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-6cEFPNUR.js → vendor-codemirror-language-data-C2qMZiA7.js} +2 -2
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
- package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
- package/dist/assets/{web-components-BEo4-ISu.js → web-components-BQWjCn_U.js} +1 -1
- package/dist/assets/zh-CN-U0QjVlAA.js +16 -0
- package/dist/assets/zh-TW-J9PTJQJi.js +16 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +4 -4
- package/server/index.js +82 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +132 -47
- package/server/lib/agent-tool/runtime.js +34 -15
- package/server/lib/agent-tool/runtime.test.js +15 -0
- package/server/lib/browser-control/DOCUMENTATION.md +14 -2
- package/server/lib/event-stream/global-hub.js +23 -1
- package/server/lib/event-stream/global-hub.test.js +35 -0
- package/server/lib/event-stream/global-ws-bridge.js +3 -1
- package/server/lib/event-stream/upstream-reader.js +3 -2
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +22 -0
- package/server/lib/git/service.test.js +8 -0
- package/server/lib/guests/DOCUMENTATION.md +4 -3
- package/server/lib/guests/catalog.js +19 -1
- package/server/lib/guests/catalog.test.js +22 -0
- package/server/lib/guests/html-styles.js +5 -3
- package/server/lib/guests/html-styles.test.js +3 -1
- package/server/lib/guests/routes.js +11 -3
- package/server/lib/guests/service.js +5 -0
- package/server/lib/guests/surface.js +55 -9
- package/server/lib/guests/surface.test.js +56 -6
- package/server/lib/notifications/DOCUMENTATION.md +10 -0
- package/server/lib/notifications/emit-route.js +118 -0
- package/server/lib/notifications/emit-route.test.js +112 -0
- package/server/lib/openchamber-control/actions.js +16 -2
- package/server/lib/openchamber-control/service.js +23 -0
- package/server/lib/openchamber-control/service.test.js +31 -0
- package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
- package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
- package/server/lib/openchamber-sessions/routes.js +11 -0
- package/server/lib/openchamber-sessions/routes.test.js +18 -0
- package/server/lib/opencode/bootstrap-runtime.js +14 -1
- package/server/lib/opencode/compatibility.js +6 -3
- package/server/lib/opencode/compatibility.test.js +8 -0
- package/server/lib/opencode/config-entity-v2.test.js +27 -0
- package/server/lib/opencode/config-paths.test.js +12 -0
- package/server/lib/opencode/config-v2.d.ts +2 -0
- package/server/lib/opencode/config-v2.js +42 -0
- package/server/lib/opencode/config-v2.test.js +17 -0
- package/server/lib/opencode/core-routes.js +20 -4
- package/server/lib/opencode/core-routes.test.js +41 -0
- package/server/lib/opencode/env-runtime.js +1 -8
- package/server/lib/opencode/feature-routes-runtime.js +2 -1
- package/server/lib/opencode/lifecycle.js +30 -2
- package/server/lib/opencode/lifecycle.test.js +27 -0
- package/server/lib/opencode/managed-config-file.js +18 -6
- package/server/lib/opencode/managed-config-file.test.js +23 -7
- package/server/lib/opencode/mcp.js +7 -2
- package/server/lib/opencode/npm-registry-config.d.ts +1 -0
- package/server/lib/opencode/npm-registry-config.js +123 -0
- package/server/lib/opencode/npm-registry-config.test.js +167 -0
- package/server/lib/opencode/npm-registry.js +5 -6
- package/server/lib/opencode/npm-registry.test.js +30 -0
- package/server/lib/opencode/openchamber-routes.js +29 -11
- package/server/lib/opencode/openchamber-routes.test.js +18 -0
- package/server/lib/opencode/project-directory-runtime.js +8 -0
- package/server/lib/opencode/project-directory-runtime.test.js +13 -0
- package/server/lib/opencode/provider-source-route.test.js +59 -0
- package/server/lib/opencode/providers.js +3 -0
- package/server/lib/opencode/providers.test.js +62 -0
- package/server/lib/opencode/proxy.js +38 -2
- package/server/lib/opencode/routes-upgrade.test.js +1 -1
- package/server/lib/opencode/routes.js +36 -1
- package/server/lib/opencode/server-utils-runtime.js +5 -0
- package/server/lib/opencode/settings-helpers.js +10 -0
- package/server/lib/opencode/settings-helpers.test.js +2 -2
- package/server/lib/opencode/settings-registry.json +17 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/opencode/shared.js +49 -4
- package/server/lib/opencode/shared.test.js +78 -1
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/skill-routes.js +28 -12
- package/server/lib/opencode/skill-routes.test.js +121 -1
- package/server/lib/opencode/upgrade-capability.js +0 -14
- package/server/lib/opencode/v1-migration-topup.js +21 -15
- package/server/lib/opencode/v1-migration-topup.test.js +14 -6
- package/server/lib/opencode/v2-install.d.ts +1 -0
- package/server/lib/opencode/v2-install.js +8 -7
- package/server/lib/opencode/v2-install.test.js +13 -4
- package/server/lib/opencode/watcher.js +3 -1
- package/server/lib/opencode/websearch-config.js +13 -1
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/realtime-proxy.js +5 -1
- package/server/lib/realtime-proxy.test.js +29 -0
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +11 -0
- package/server/lib/session-assist/DOCUMENTATION.md +17 -5
- package/server/lib/session-assist/runtime.js +19 -2
- package/server/lib/session-assist/runtime.test.js +8 -0
- package/server/lib/session-goal/DOCUMENTATION.md +11 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -10
- package/server/lib/small-model/index.js +27 -32
- package/server/lib/small-model/index.test.js +28 -16
- package/server/lib/spaces/DOCUMENTATION.md +404 -32
- package/server/lib/spaces/code-in-bait.js +145 -6
- package/server/lib/spaces/code-in.js +10 -150
- package/server/lib/spaces/code-in.test.js +7 -83
- package/server/lib/spaces/code-out.js +1819 -0
- package/server/lib/spaces/code-out.test.js +3945 -0
- package/server/lib/spaces/code-transfer.js +173 -0
- package/server/lib/spaces/command-stream.test.js +181 -0
- package/server/lib/spaces/dispatcher.js +670 -0
- package/server/lib/spaces/dispatcher.test.js +582 -0
- package/server/lib/spaces/gatekeeper-channel.js +61 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +43 -7
- package/server/lib/spaces/gatekeeper-program.cjs +68 -14
- package/server/lib/spaces/gatekeeper-program.test.js +118 -3
- package/server/lib/spaces/hardening.js +20 -4
- package/server/lib/spaces/hardening.test.js +18 -3
- package/server/lib/spaces/host-git.js +7 -4
- package/server/lib/spaces/host-git.test.js +6 -2
- package/server/lib/spaces/host.js +310 -0
- package/server/lib/spaces/host.test.js +273 -0
- package/server/lib/spaces/journey.js +552 -0
- package/server/lib/spaces/journey.test.js +589 -0
- package/server/lib/spaces/layout.js +42 -8
- package/server/lib/spaces/manager.js +4 -3
- package/server/lib/spaces/manager.test.js +6 -0
- package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
- package/server/lib/spaces/places/contract-suite.js +36 -0
- package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
- package/server/lib/spaces/places/docker-live-support.js +27 -4
- package/server/lib/spaces/places/docker.js +33 -5
- package/server/lib/spaces/places/docker.test.js +42 -3
- package/server/lib/spaces/places/escape-suite.js +118 -14
- package/server/lib/spaces/places/fake-docker.js +3 -1
- package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
- package/server/lib/spaces/places/memory-place.js +24 -1
- package/server/lib/spaces/places/registry.js +1 -1
- package/server/lib/spaces/places/server.docker.live.test.js +69 -33
- package/server/lib/spaces/places/sessions.docker.live.test.js +222 -0
- package/server/lib/spaces/routes.js +216 -0
- package/server/lib/spaces/routes.test.js +213 -0
- package/server/lib/spaces/run-command.js +261 -8
- package/server/lib/spaces/run-command.test.js +193 -3
- package/server/lib/spaces/space-events.js +153 -0
- package/server/lib/spaces/space-events.test.js +160 -0
- package/server/lib/spaces/space-opencode.js +52 -0
- package/server/lib/spaces/space-opencode.test.js +41 -0
- package/server/lib/spaces/space-records.js +150 -0
- package/server/lib/spaces/space-records.test.js +113 -0
- package/server/lib/spaces/space-sessions.js +210 -0
- package/server/lib/spaces/space-sessions.test.js +161 -0
- package/server/lib/spaces/websocket.js +329 -0
- package/server/lib/spaces/websocket.test.js +345 -0
- package/server/lib/ui-auth/ui-auth.js +8 -2
- package/server/lib/ui-auth/ui-auth.test.js +29 -0
- package/server/opencode-proxy.test.js +113 -0
- package/dist/assets/DiffView-D2p4Ar0H.js +0 -4
- package/dist/assets/FilesView-BeTtbsip.js +0 -17
- package/dist/assets/GuestSurfacePane-DIJvkkM-.js +0 -1
- package/dist/assets/MarkdownImageGallery-CY0dWTaE.js +0 -1
- package/dist/assets/MarkdownRendererImpl-ILdXzLrt.js +0 -12
- package/dist/assets/PluginPane-B39JEUL8.js +0 -3
- package/dist/assets/SettingsView-13B2_G-A.js +0 -29
- package/dist/assets/commitAndPush-CcI4ol7c.js +0 -1
- package/dist/assets/de-BtYnUgII.js +0 -10
- package/dist/assets/es-crP5qPye.js +0 -16
- package/dist/assets/fr-CLSRuALk.js +0 -14
- package/dist/assets/index-CLcM8HKx.css +0 -1
- package/dist/assets/index-CvLgnuNI.js +0 -41
- package/dist/assets/ja-SZ1-ucLV.js +0 -16
- package/dist/assets/ko-HthbT_Ve.js +0 -16
- package/dist/assets/main-BJklC7Cl.js +0 -896
- package/dist/assets/markdownCore-BzQuETm0.js +0 -5
- package/dist/assets/patchFileDiff-DGw2KryM.js +0 -13
- package/dist/assets/pl-C8eYfjL1.js +0 -16
- package/dist/assets/pt-BR-cYOrZdxS.js +0 -16
- package/dist/assets/renderMobileApp-CMxjwisj.js +0 -25
- package/dist/assets/runtimeEndpointReset-C45jrFq4.js +0 -27
- package/dist/assets/scheduledTasksApi-CkK1F9s2.js +0 -1
- package/dist/assets/tr-B4IQ5t-T.js +0 -7
- package/dist/assets/uk-DCoXG6ve.js +0 -16
- package/dist/assets/vendor-opencode-client-_BAHQo4R.js +0 -12
- package/dist/assets/vendor-zod-Gea9uBlY.js +0 -39
- package/dist/assets/zh-CN-BXBoxsFk.js +0 -16
- package/dist/assets/zh-TW-C6oelpnL.js +0 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{R as l,r as ve,j as t,f as jt}from"./vendor-react-BUCujlKS.js";import{f as nt,z as rt,a7 as Bt,kZ as _n,dy as qt,cI as Yt,t as v,I as T,as as Ls,at as Os,au as Rr,av as As,d4 as zs,d5 as Gs,d6 as _s,d7 as $s,c$ as Qt,d0 as Xt,B as W,k_ as $n,k$ as Hn,c2 as mt,c3 as ht,c4 as gt,c5 as ft,c6 as bt,X as gr,ae as Zt,af as es,ag as ts,l0 as Wn,h as Se,l1 as Un,l2 as Kn,l3 as Jn,l4 as qn,bh as Yn,ay as Qn,ce as Xn,l5 as Zn,l6 as ea,l7 as ta,l8 as sa,l9 as ra,la as na,lb as aa,c8 as Br,cj as ia,ck as oa,cl as la,cm as ca,cn as da,cr as ua,ch as ma,cg as ha,lc as ga,cq as fa,c7 as Ts,fl as pa,_ as xa,ai as wa,aj as ya,J as ba,ak as va,bO as ja,ld as Ca,al as Na,le as Sa,lf as ka,am as Va,lg as Ia,K as Pa,cc as Fa,k2 as Ra,lh as Ba,l as Da,cs as Ea,g as Ma,d9 as Ta,ar as fr,a9 as La,li as Oa,lj as Ds}from"./useAppFontEffects-Bzyszv2N.js";import{a as Aa,b as za}from"./main-BJklC7Cl.js";import{ao as Ga,X as _a,k as $a,au as Ha}from"./runtimeEndpointReset-C45jrFq4.js";import{u as pr}from"./vendor-zustand-BAGL70zf.js";import{h as Wa,u as Ft}from"./index-CvLgnuNI.js";import{C as Ua,a as Ka,D as Ja,p as xr}from"./commitAndPush-CcI4ol7c.js";import{P as qa}from"./PierreDiffViewer-CrcGqqD_.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-6cEFPNUR.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-DCaZ4BWi.js";import"./scheduledTasksApi-CkK1F9s2.js";import"./PluginPane-B39JEUL8.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./GuestAttachDialog-CoXM0gh_.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./web-components-BEo4-ISu.js";import"./computeVirtualFileMetrics-_-20umCs.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-DONC4eI2.js";import"./isDiffPlainText-D77M6q1f.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-zOf6ORAq.js";import"./appThemeRegistry-Br2TLSlb.js";import"./textMateThemeFromAppTheme-yNq7b0DZ.js";const Dr="gitmojiCache",Ya=1e3*60*60*24*7,Er="1",Qa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Mr=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Es=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(Dr);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==Er||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Mr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Xa=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:Er};window.localStorage.setItem(Dr,JSON.stringify(e))}catch{return}},wr=o=>Date.now()-o.fetchedAt<Ya;let Kt=null;const Rt=new Set,yr=async()=>{if(Kt)return Kt;const o=(async()=>{try{const e=await fetch(Qa);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const i=await e.json(),m=Array.isArray(i.gitmojis)?i.gitmojis.filter(Mr):[];return Xa(m),Rt.forEach(N=>N(m)),m}catch(e){console.warn("Failed to load gitmoji list:",e);const i=[];return Rt.forEach(m=>m(i)),i}finally{Kt=null}})();return Kt=o,o},Za=o=>{const[e,i]=l.useState(()=>o?Es()?.gitmojis??[]:[]),[m,N]=l.useState(!1),f=l.useRef(o);f.current=o,l.useEffect(()=>{if(!o){Rt.delete(i),i([]),N(!1);return}const x=Es();if(x&&(i(x.gitmojis),wr(x)))return;Rt.add(i),N(!0);let g=!1;return yr().finally(()=>{!g&&f.current&&N(!1)}),()=>{g=!0,Rt.delete(i)}},[o]);const p=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const x=Es();return x&&wr(x)?x.gitmojis:yr()},[e]);return{gitmojis:e,isLoading:m,ensureLoaded:p}},Ct=async(o,e)=>{const i=await Wa(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok){const m=await i.json().catch(()=>null);throw new Error(m?.error||`Git integrate request failed: ${i.statusText}`)}return i.json()};async function Pt(o){return Ct("plan",o)}async function ei(o){return Ct("conflict-details",{tempWorktreePath:o})}async function ti(o){return(await Ct("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function si(o){return Ct("run",{plan:o})}async function ri(o){await Ct("abort",{state:o})}async function ni(o){return Ct("continue",{state:o})}const ai=({repoRoot:o,sourceBranch:e,worktreeMetadata:i,localBranches:m,defaultTargetBranch:N,refreshKey:f,onRefresh:p,showHeader:x=!0})=>{const{t:g}=nt(),w=rt(h=>h.currentSessionId),[E,b]=ve.useState(!1),[V,O]=ve.useState(""),S=ve.useRef(null),z=ve.useMemo(()=>Bt(m,V,h=>[h]),[m,V]),[C,y]=ve.useState(N);ve.useEffect(()=>{y(N)},[N]),ve.useEffect(()=>{if(E){const h=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(h)}},[E]);const D=!!(o&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=ve.useState({kind:"idle"}),[P,F]=ve.useState(!1),[r,Y]=ve.useState([]),B=ve.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);ve.useEffect(()=>{if(!B||typeof window>"u")return;const h=window.localStorage.getItem(B);if(!h)return;let d=!1;try{const I=JSON.parse(h);if(!I?.tempWorktreePath||I.repoRoot!==o){window.localStorage.removeItem(B);return}(async()=>{const A=await ti(I.tempWorktreePath).catch(()=>!1);if(d)return;if(!A){window.localStorage.removeItem(B);return}const q=await ei(I.tempWorktreePath).catch(()=>null);d||q&&R({kind:"conflict",state:I,details:q})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,o]),ve.useEffect(()=>{if(!D){R({kind:"idle"});return}let h=!1;return R({kind:"loading"}),(async()=>{try{const d=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C});if(h)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const A=d.commits.slice(-50).reverse(),q=await _n(o,A);h||(Y(q),F(!1))}else h||(Y([]),F(!1))}catch{h||R({kind:"idle"})}})(),()=>{h=!0}},[D,o,e,C,f]);const u=ve.useCallback(h=>{w&&rt.getState().setWorktreeMetadata(w,{...i,createdFromBranch:h})},[w,i]),M=rt(h=>h.openNewSessionDraft),te=ve.useCallback(async h=>{const d=await qt("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),I=await qt("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),A=`Cherry-pick conflict context (JSON)
|
|
2
|
-
${JSON.stringify({repoRoot:h.state.repoRoot,tempWorktreePath:h.state.tempWorktreePath,sourceBranch:h.state.sourceBranch,targetBranch:h.state.targetBranch,currentCommit:h.state.currentCommit,remainingCommits:h.state.remainingCommits,statusPorcelain:h.details.statusPorcelain,unmergedFiles:h.details.unmergedFiles,currentPatchMeta:h.details.currentPatchMeta,currentPatch:h.details.currentPatch,diff:h.details.diff},null,2)}`;return{visibleText:d,instructionsText:I,payloadText:A}},[]),U=Yt(h=>h.setPendingInputText),G=Yt(h=>h.setPendingSyntheticParts),_=ve.useCallback(async(h,d)=>{const I=await te(h);if(d){M({directoryOverride:h.state.tempWorktreePath,initialPrompt:I.visibleText,syntheticParts:[{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}]});return}if(!w){v.error(g("gitView.integrate.noActiveSession"),{description:g("gitView.integrate.noActiveSessionDescription")});return}U(I.visibleText,"replace"),G([{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}])},[w,te,M,U,G,g]),X=ve.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){v.message(g("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const h=await si(k.plan);if(h.kind==="success"){v.success(g("gitView.integrate.commitsMovedToast"),{description:h.moved===1?g("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:k.plan.targetBranch}):g("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:k.plan.targetBranch})});const d=await Pt(k.plan);R({kind:"ready",plan:d}),p?.();return}h.kind==="conflict"&&(v.error(g("gitView.integrate.cherryPickConflictToast"),{description:g("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);v.error(g("gitView.integrate.failedToMoveToast"),{description:d});const I=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(I?{kind:"ready",plan:I}:{kind:"idle"})}}},[k,p,o,e,C,B,g]),$=ve.useCallback(async()=>{if(k.kind==="conflict")try{await ri(k.state),v.message(g("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const h=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(h?{kind:"ready",plan:h}:{kind:"idle"})}},[k,o,e,C,B,g]),le=ve.useCallback(async()=>{if(k.kind==="conflict")try{const h=await ni(k.state);if(h.kind==="success"){v.success(g("gitView.integrate.cherryPickFinishedToast"));const d=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),p?.();return}h.kind==="conflict"&&(R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);v.error(g("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,o,e,C,p,B,g]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[x?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(T,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g("gitView.integrate.toMoveCount",{count:k.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:k.kind==="loading"||k.kind==="running"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}):null,t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Ls,{open:E,onOpenChange:b,children:[t.jsx(Os,{asChild:!0,children:t.jsxs("button",{type:"button",className:Rr({size:"default"}),children:[g("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(As,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(zs,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Gs,{ref:S,placeholder:g("gitView.branch.searchPlaceholder"),value:V,onValueChange:O,onKeyDown:h=>h.stopPropagation()}),t.jsxs(_s,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx($s,{children:g("gitView.branch.empty")}),t.jsx(Qt,{heading:g("gitView.branch.localBranches"),children:z.map(h=>t.jsx(Xt,{value:h,onSelect:()=>{y(h),u(h),b(!1),O("")},children:h},h))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{X()},disabled:!D||k.plan.commits.length===0,children:g("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.noCommitsToMove")}),k.kind==="ready"&&k.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[g("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",k.plan.commits.length,")"]})]}),r.length>0&&k.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>F(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:g(P?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(P?r:r.slice(0,5)).map(h=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:h.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h.subject||h.sha})]},h.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:g("gitView.integrate.showingFirstCommits",{count:r.length})})]})]}),k.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:g("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[g("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:k.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[k.details.unmergedFiles.slice(0,6).map(h=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:h},h)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:g("gitView.integrate.moreFiles",{count:k.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{$()},children:g("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{_({state:k.state,details:k.details},!1)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{_({state:k.state,details:k.details},!0)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{le()},children:g("gitView.operation.continue")})]})]})]})]})},ii=({open:o,onOpenChange:e,directory:i,hasUncommittedChanges:m,hasStagedChanges:N=!1,uncommittedFileCount:f,onChanged:p})=>{const{t:x}=nt(),[g,w]=l.useState([]),[E,b]=l.useState(!1),[V,O]=l.useState(""),[S,z]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(i){b(!0);try{const u=await $n(i);w(u.stashes),k({})}catch(u){v.error(u instanceof Error?u.message:x("gitView.stashes.toast.loadFailed"))}finally{b(!1)}}},[i,x]);l.useEffect(()=>{o&&R()},[R,o]),l.useEffect(()=>{if(!o||!i||g.length===0)return;let u=!1;const M=g.map(te=>te.ref);return Hn(i,M).then(te=>{u||k(te.counts)}).catch(()=>{}),()=>{u=!0}},[i,o,g]);const P=l.useMemo(()=>Bt(g,V,u=>[u.message,u.ref,u.relativeTime]),[V,g]),F=l.useCallback(async u=>{await R(),await p?.(u)},[R,p]),r=async()=>{if(!(!i||C)){y("create");try{const u=await Wn(i,{message:S.trim()||void 0});u.created?(v.success(x("gitView.stashes.toast.created")),z("")):v.info(x("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(u.created&&N)})}catch(u){v.error(u instanceof Error?u.message:x("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(u,M)=>{if(!(!i||C)&&!(M==="drop"&&!window.confirm(x("gitView.stashes.confirm.drop",{ref:u.ref})))){y(`${M}:${u.ref}`);try{M==="apply"&&await Un(i,{ref:u.ref}),M==="pop"&&await Kn(i,{ref:u.ref}),M==="drop"&&await Jn(i,{ref:u.ref});const te=M==="apply"?"gitView.stashes.toast.applySuccess":M==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";v.success(x(te)),await F({affectsIndex:M!=="drop"})}catch(te){const U=M==="apply"?"gitView.stashes.toast.applyFailed":M==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";v.error(te instanceof Error?te.message:x(U)),await F({affectsIndex:M!=="drop"})}finally{y(null)}}},B=C!==null;return t.jsx(mt,{open:o,onOpenChange:e,children:t.jsxs(ht,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(gt,{children:[t.jsxs(ft,{className:"flex items-center gap-2",children:[t.jsx(T,{name:"archive-stack",className:"h-5 w-5"}),x("gitView.stashes.title")]}),t.jsx(bt,{children:x("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(gr,{value:S,onChange:u=>z(u.target.value),placeholder:x("gitView.stashes.messagePlaceholder"),disabled:B||!m,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!m||B||!i,children:[C==="create"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"inbox-archive",className:"size-4"}),x("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:x("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(T,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gr,{value:V,onChange:u=>O(u.target.value),placeholder:x("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:E?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(T,{name:"loader-4",className:"size-5 animate-spin"})}):P.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:x(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):P.map((u,M)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:u.message||x("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Zt,{children:[t.jsx(es,{asChild:!0,children:t.jsx("span",{children:M===0&&!V.trim()?x("gitView.stashes.latestLabel"):x("gitView.stashes.itemNumber",{number:M+1})})}),t.jsx(ts,{sideOffset:6,children:u.ref})]})," · ",u.relativeTime," · ",typeof D[u.ref]=="number"?x("gitView.stashes.fileCount",{count:D[u.ref]}):x("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ms,{label:x("gitView.stashes.actions.apply"),loading:C===`apply:${u.ref}`,onClick:()=>Y(u,"apply"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.pop"),loading:C===`pop:${u.ref}`,onClick:()=>Y(u,"pop"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.drop"),loading:C===`drop:${u.ref}`,onClick:()=>Y(u,"drop"),disabled:B,destructive:!0,children:t.jsx(T,{name:"delete-bin",className:"size-4"})})]})]},u.ref))})]})})},Ms=o=>{const e=jt.c(17),{label:i,loading:m,disabled:N,destructive:f,onClick:p,children:x}=o,g=m||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let E;e[0]!==w?(E=Se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=E):E=e[1];let b;e[2]!==x||e[3]!==m?(b=m?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):x,e[2]=x,e[3]=m,e[4]=b):b=e[4];let V;e[5]!==N||e[6]!==i||e[7]!==p||e[8]!==g||e[9]!==E||e[10]!==b?(V=t.jsx(es,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":i,"aria-busy":g,className:E,onClick:p,disabled:N,children:b})}),e[5]=N,e[6]=i,e[7]=p,e[8]=g,e[9]=E,e[10]=b,e[11]=V):V=e[11];let O;e[12]!==i?(O=t.jsx(ts,{sideOffset:6,children:i}),e[12]=i,e[13]=O):O=e[13];let S;return e[14]!==V||e[15]!==O?(S=t.jsxs(Zt,{children:[V,O]}),e[14]=V,e[15]=O,e[16]=S):S=e[16],S},oi=o=>{const e=jt.c(16),{onOpenStashes:i}=o,{t:m}=nt();let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(T,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=N):N=e[0];let f;e[1]!==m?(f=m("gitView.empty.cleanTitle"),e[1]=m,e[2]=f):f=e[2];let p;e[3]!==f?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=p):p=e[4];let x;e[5]!==m?(x=m("gitView.empty.cleanDescription"),e[5]=m,e[6]=x):x=e[6];let g;e[7]!==x?(g=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:x}),e[7]=x,e[8]=g):g=e[8];let w;e[9]!==i||e[10]!==m?(w=i?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:i,className:"gap-1.5",children:[t.jsx(T,{name:"archive-stack",className:"size-4"}),m("gitView.stashes.title")]}):null,e[9]=i,e[10]=m,e[11]=w):w=e[11];let E;return e[12]!==p||e[13]!==g||e[14]!==w?(E=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[N,p,g,w]}),e[12]=p,e[13]=g,e[14]=w,e[15]=E):E=e[15],E},ut=8,li=o=>{const e=jt.c(18),{laned:i,totalLanes:m,isExpanded:N}=o,{lane:f,color:p,connectors:x}=i,w=Math.max(m,f+1)*ut+ut/2,E=l.useRef(null),b=l.useRef(null);let V;e[0]!==p||e[1]!==x||e[2]!==f||e[3]!==w?(V=()=>{const y=E.current,D=b.current;if(!y||!D)return;const k=y.offsetHeight;if(k===0)return;const R=window.devicePixelRatio||1;D.width=w*R,D.height=k*R;const P=D.getContext("2d");if(!P)return;P.scale(R,R),P.clearRect(0,0,w,k);const F=k/2,r=f*ut+ut/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,u=U=>{if(!U.startsWith("var("))return U;const G=U.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},M=[...x].sort(di);for(const U of M){const G=U.fromLane*ut+ut/2,_=U.toLane*ut+ut/2,X=U.type==="passing"?.72:U.type==="branch-out"||U.type==="merge-in"?.95:1;P.beginPath(),P.strokeStyle=u(U.color),P.globalAlpha=X,P.lineWidth=1.25,P.lineCap="round";e:switch(U.type){case"passing":case"commit-lane":{P.moveTo(G,0),P.lineTo(G,k);break e}case"top-stub":{P.moveTo(G,0),P.lineTo(G,F);break e}case"bottom-stub":{P.moveTo(G,F),P.lineTo(G,k);break e}case"branch-out":{const $=(F+k)/2;P.moveTo(r,F),P.bezierCurveTo(r,$,_,$,_,k);break e}case"merge-in":{const $=F/2;P.moveTo(G,0),P.bezierCurveTo(G,$,r,$,r,F);break e}default:continue}P.stroke(),P.globalAlpha=1}const te=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();P.beginPath(),P.arc(r,F,4,0,Math.PI*2),P.fillStyle=u(p),P.fill(),P.beginPath(),P.arc(r,F,5,0,Math.PI*2),P.strokeStyle=te||B,P.lineWidth=2,P.stroke()},e[0]=p,e[1]=x,e[2]=f,e[3]=w,e[4]=V):V=e[4];let O;e[5]!==p||e[6]!==x||e[7]!==N||e[8]!==f||e[9]!==i||e[10]!==m||e[11]!==w?(O=[i,f,p,x,m,N,w],e[5]=p,e[6]=x,e[7]=N,e[8]=f,e[9]=i,e[10]=m,e[11]=w,e[12]=O):O=e[12],l.useLayoutEffect(V,O);let S;e[13]!==w?(S={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=S):S=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("canvas",{ref:b,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=z):z=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:E,style:S,children:z}),e[16]=S,e[17]=C):C=e[17],C};function ci(o){return o==="branch-out"||o==="merge-in"}function di(o,e){const i=ci;return(i(o.type)?1:0)-(i(e.type)?1:0)}const br=15e3,vr=500,jr=12,Cr=8*1024*1024,Nr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),Sr=o=>{if(o.size<=jr){let N=0;for(const f of o.values())N+=Nr(f);if(N<=Cr)return o}const e=Array.from(o.entries()).reverse(),i=new Map;let m=0;for(const[N,f]of e){if(i.size>=jr)continue;const p=Nr(f);m+p>Cr&&i.size>0||(i.set(N,f),m+=p)}return new Map(Array.from(i.entries()).reverse())};function kr(o,e){const i=new Date(o);return Number.isNaN(i.getTime())?o:Xn(i,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ui(o){switch(o){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 mi(o){return o?o.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const i=e.startsWith("HEAD ->");return{label:i?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:i,isTag:e.startsWith("tag: ")}}):[]}const hi=l.memo(({entry:o,mode:e="history",laned:i,totalLanes:m,isExpanded:N,onToggle:f,files:p,isLoadingFiles:x,onCopyHash:g,directory:w,onConflict:E,onActionSuccess:b})=>{const{t:V}=nt(),O=Ft(d=>d.timeFormatPreference),S=e==="graph",[z,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[P,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,u]=l.useState(new Map),[M,te]=l.useState(new Set),U=async()=>{if(w){C("checkout");try{await aa(w,o.hash),v.success(V("gitView.history.actions.detachedHead")),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Zn(w,k.trim(),o.hash),D(!1),R(""),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},_=async()=>{if(w){C("cherryPick");try{const d=await na(w,o.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},X=async()=>{if(w){C("revert");try{const d=await ra(w,o.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},$=async(d,I=!1)=>{if(!(!w||z!==null)){C("reset");try{await ea(w,o.hash,d,I),b?.()}catch(A){v.error(String(A.message))}finally{C(null)}}},le=async()=>{if(!P)return;const d=P;switch(F(null),d){case"checkout":return U();case"cherryPick":return _();case"revert":return X();case"merge":return ae();case"rebase":return ce();case"resetSoft":return $("soft");case"resetMixed":return $("mixed");case"resetHard":return $("hard",!0)}},ae=async()=>{if(w){C("merge");try{const d=await sa(w,{branch:o.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},ce=async()=>{if(w){C("rebase");try{const d=await ta(w,{onto:o.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},ie=l.useCallback(async d=>{const I=d.path;if(!w){u(A=>new Map(A).set(I,"error"));return}u(A=>Sr(new Map(A).set(I,"loading")));try{const A=qn(w,o.hash,d.path,!1),q=new Promise((se,J)=>{setTimeout(()=>J(new Error(`Timed out after ${br}ms`)),br)}),ne=await Promise.race([A,q]);u(se=>Sr(new Map(se).set(I,ne)))}catch{u(A=>new Map(A).set(I,"error"))}},[w,o.hash]),h=l.useCallback(async d=>{const I=d.path;if(d.changeType==="R"||d.isBinary){Y(se=>{const J=new Set(se);return J.has(I)?J.delete(I):J.add(I),J});return}const A=B.get(I);if(r.has(I)&&A&&A!=="error"){Y(se=>{const J=new Set(se);return J.delete(I),J});return}Y(se=>{const J=new Set(se);return J.add(I),J}),!(A&&A!=="error"||d.insertions+d.deletions>vr&&!M.has(I))&&await ie(d)},[B,M,ie,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":N?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&i&&m!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(li,{laned:i,totalLanes:m,isExpanded:N})}):t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[S?(()=>{const d=mi(o.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(I=>t.jsx("span",{className:Se("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",I.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":I.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:I.label},I.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:o.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:o.author_name,children:o.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:kr(o.date,O),children:kr(o.date,O)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(Zt,{children:[t.jsx(es,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),g(o.hash)},children:t.jsx(T,{name:"file-copy",className:"size-3"})})}),t.jsx(ts,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),N&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&P?t.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:V(`gitView.history.actions.${P}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),le()},children:[z!==null?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),F(null)},children:V("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("checkout")},children:V("gitView.history.actions.checkout")}),y?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:k,onChange:d=>R(d.target.value),onKeyDown:d=>{d.key==="Enter"&&G(),d.key==="Escape"&&(D(!1),R(""))},placeholder:V("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!k.trim()||z!==null,onClick:d=>{d.stopPropagation(),G()},children:[z==="createBranch"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:d=>{d.stopPropagation(),D(!0)},children:V("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Ls,{children:[t.jsx(Os,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>d.stopPropagation(),children:[z==="reset"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(As,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(Yn,{disabled:z!==null,onSelect:I=>{I.stopPropagation(),F(`reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},children:V(`gitView.history.actions.reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},d))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,x?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:V("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:V("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>h(d),className:Se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",r.has(d.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Se("font-semibold w-3 text-center shrink-0",ui(d.changeType)),children:d.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:d.path,children:d.path}),!d.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d.deletions]})]}),d.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:V("gitView.history.binary")}),t.jsx(T,{name:r.has(d.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),r.has(d.path)&&t.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:d.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.renamedNoDiff")}):d.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.binaryNoDiff")}):(()=>{const I=d.insertions+d.deletions;if(!M.has(d.path)&&I>vr)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:V("gitView.history.largeDiffTitle",{count:I})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:V("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{te(q=>new Set(q).add(d.path)),ie(d)},children:V("gitView.history.renderDiffAnyway")})]});const A=B.get(d.path);return A==="loading"||A===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):A==="error"?t.jsx("button",{type:"button",onClick:()=>h(d),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:V("gitView.history.diffError")}):t.jsx(qa,{original:A.original,modified:A.modified,language:Qn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),Vr=["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 Jt(o){return Vr[o%Vr.length]}function gi(o){if(o.length===0)return[];const e=[],i=[];for(let m=0;m<o.length;m++){const N=o[m],f=[];for(let S=0;S<e.length;S++)e[S]===N.hash&&f.push(S);let p=f.length>0?f[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const x=f.slice(1),g=Jt(p),w=e[p]===N.hash,E=N.parents.length>0;E?e[p]=N.parents[0]:e[p]=null;const b=[],V=new Set;for(let S=1;S<N.parents.length;S++){const z=N.parents[S],C=e.indexOf(z);if(C!==-1)b.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=z,b.push(y),V.add(y);else{const D=e.length;e.push(z),b.push(D),V.add(D)}}}const O=[];w&&E?O.push({fromLane:p,toLane:p,color:g,type:"commit-lane"}):w&&!E?O.push({fromLane:p,toLane:p,color:g,type:"top-stub"}):!w&&E&&O.push({fromLane:p,toLane:p,color:g,type:"bottom-stub"});for(const S of x)O.push({fromLane:S,toLane:p,color:Jt(S),type:"merge-in"}),e[S]=null;for(const S of b)O.push({fromLane:p,toLane:S,color:Jt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(V.has(S)||O.push({fromLane:S,toLane:S,color:Jt(S),type:"passing"}));i.push({commit:N,lane:p,color:g,connectors:O})}return i}const fi=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],pi=o=>{const e=jt.c(84),{mode:i,log:m,isLogLoading:N,logMaxCount:f,onLogMaxCountChange:p,expandedCommitHashes:x,onToggleCommit:g,commitFilesMap:w,loadingCommitHashes:E,onCopyHash:b,directory:V,showHeader:O,contentMaxHeightClassName:S,branchDivider:z,onConflict:C,onActionSuccess:y}=o,D=i===void 0?"history":i,k=O===void 0?!0:O,R=S===void 0?"max-h-[50vh]":S,P=z===void 0?null:z,{t:F}=nt(),[r,Y]=l.useState(!0),B=D==="graph";let u;e[0]!==B||e[1]!==m?(u=B&&m?gi(m.all):[],e[0]=B,e[1]=m,e[2]=u):u=e[2];const M=u;let te;e[3]!==M?(te=Math.max(1,...M.map(xi)),e[3]=M,e[4]=te):te=e[4];const U=te;let G;e[5]!==M?(G=new Map(M.map(wi)),e[5]=M,e[6]=G):G=e[6];const _=G;if(!m)return null;const X=P!==null&&P.insertBeforeIndex>0&&P.insertBeforeIndex<m.all.length,$=P!==null&&P.insertBeforeIndex===m.all.length,le=X||$;let ae;e[7]!==P||e[8]!==X||e[9]!==$||e[10]!==m.all?(ae=X?m.all.slice(0,P.insertBeforeIndex):$?m.all:[],e[7]=P,e[8]=X,e[9]=$,e[10]=m.all,e[11]=ae):ae=e[11];const ce=ae;let ie;if(e[12]!==P||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==x||e[17]!==X||e[18]!==le||e[19]!==B||e[20]!==N||e[21]!==_||e[22]!==E||e[23]!==m.all||e[24]!==f||e[25]!==U||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==b||e[30]!==p||e[31]!==g||e[32]!==F||e[33]!==ce){const K=X?m.all.slice(P.insertBeforeIndex):[];let de;e[35]!==P?.direction?(de=P?.direction==="down"?t.jsx(T,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(T,{name:"arrow-up",className:"size-3.5"}),e[35]=P?.direction,e[36]=de):de=e[36];const ke=de;let ye;e[37]!==w||e[38]!==V||e[39]!==x||e[40]!==B||e[41]!==_||e[42]!==E||e[43]!==U||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==b||e[48]!==g?(ye=Re=>t.jsx("ul",{className:"divide-y divide-border/60",children:Re.map(ue=>t.jsx(hi,{entry:ue,mode:D,laned:B?_.get(ue.hash):void 0,totalLanes:B?U:void 0,isExpanded:x.has(ue.hash),onToggle:()=>g(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:E.has(ue.hash),onCopyHash:b,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=x,e[40]=B,e[41]=_,e[42]=E,e[43]=U,e[44]=D,e[45]=y,e[46]=C,e[47]=b,e[48]=g,e[49]=ye):ye=e[49];const me=ye;let xe;e[50]!==N||e[51]!==m.all.length||e[52]!==f||e[53]!==p||e[54]!==F?(xe=m.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(f+25),disabled:N,className:"px-3 text-muted-foreground hover:text-foreground",children:N?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=N,e[51]=m.all.length,e[52]=f,e[53]=p,e[54]=F,e[55]=xe):xe=e[55];const Ve=xe;ie=t.jsx(Br,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:m.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:F("gitView.history.noCommits")})}):le&&P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(ce)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:P.branchName,children:P.branchName}),ke]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),K.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(K)}):null]}),Ve]}):t.jsxs(t.Fragment,{children:[me(m.all),Ve]})}),e[12]=P,e[13]=w,e[14]=R,e[15]=V,e[16]=x,e[17]=X,e[18]=le,e[19]=B,e[20]=N,e[21]=_,e[22]=E,e[23]=m.all,e[24]=f,e[25]=U,e[26]=D,e[27]=y,e[28]=C,e[29]=b,e[30]=p,e[31]=g,e[32]=F,e[33]=ce,e[34]=ie}else ie=e[34];const h=ie;if(!k){if(le){let de;return e[56]!==h?(de=t.jsx("section",{className:"h-full min-h-0",children:h}),e[56]=h,e[57]=de):de=e[57],de}let K;return e[58]!==h?(K=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:h}),e[58]=h,e[59]=K):K=e[59],K}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let I;e[62]!==d?(I=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=I):I=e[63];let A;e[64]!==N||e[65]!==r||e[66]!==f||e[67]!==p||e[68]!==F?(A=r&&t.jsx("div",{onClick:yi,onPointerDown:bi,children:t.jsxs(ia,{value:String(f),onValueChange:K=>p(Number(K)),disabled:N,children:[t.jsx(oa,{size:"sm",className:"w-auto",disabled:N,children:t.jsx(la,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ca,{children:fi.map(K=>t.jsx(da,{value:String(K.value),children:F(K.labelKey)},K.value))})]})}),e[64]=N,e[65]=r,e[66]=f,e[67]=p,e[68]=F,e[69]=A):A=e[69];let q;e[70]!==r?(q=r?t.jsx(T,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(T,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=q):q=e[71];let ne;e[72]!==A||e[73]!==q?(ne=t.jsxs("div",{className:"flex items-center gap-2",children:[A,q]}),e[72]=A,e[73]=q,e[74]=ne):ne=e[74];let se;e[75]!==I||e[76]!==ne?(se=t.jsxs(ua,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[I,ne]}),e[75]=I,e[76]=ne,e[77]=se):se=e[77];let J;e[78]!==h?(J=t.jsx(ma,{children:h}),e[78]=h,e[79]=J):J=e[79];let we;return e[80]!==r||e[81]!==se||e[82]!==J?(we=t.jsxs(ha,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[se,J]}),e[80]=r,e[81]=se,e[82]=J,e[83]=we):we=e[83],we};function xi(o){return o.lane+1}function wi(o){return[o.commit.hash,o]}function yi(o){return o.stopPropagation()}function bi(o){return o.stopPropagation()}const vi=o=>{const e=jt.c(148),{open:i,onOpenChange:m,conflictFiles:N,directory:f,operation:p,onAbort:x,onClearState:g}=o;let w;e[0]!==N?(w=N===void 0?[]:N,e[0]=N,e[1]=w):w=e[1];const E=w,{t:b}=nt(),V=rt(ji),O=rt(Ci),S=Yt(Ni),z=Yt(Si),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,P]=l.useState(null);let F,r;e[2]!==f||e[3]!==i||e[4]!==b?(F=()=>{!i||!f||(y(!0),P(null),k(null),ga(f).then(ee=>{k(ee)}).catch(ee=>{const he=ee instanceof Error?ee.message:b("gitView.conflict.loadFailed");P(he)}).finally(()=>{y(!1)}))},r=[i,f,b],e[2]=f,e[3]=i,e[4]=b,e[5]=F,e[6]=r):(F=e[5],r=e[6]),l.useEffect(F,r);let Y;e[7]!==D||e[8]!==f||e[9]!==p?(Y=async()=>{if(!D)return null;const ee=p==="merge"?"merge":"rebase",he=D.headInfo||(p==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Be=p==="merge"?"git commit --no-edit":"git rebase --continue",ge=await qt("git.conflict.resolve.visible",{operation_label:ee,head_ref:he}),Ne=await qt("git.conflict.resolve.instructions",{operation_label:ee,directory:f,operation:p,head_info:D.headInfo||"N/A",continue_cmd:Be}),Ie=`${ee} conflict context (JSON)
|
|
3
|
-
${JSON.stringify({directory:f,operation:D.operation,headInfo:D.headInfo,statusPorcelain:D.statusPorcelain,unmergedFiles:D.unmergedFiles,diff:D.diff},null,2)}`;return{visibleText:ge,instructionsText:Ne,payloadText:Ie}},e[7]=D,e[8]=f,e[9]=p,e[10]=Y):Y=e[10];const B=Y;let u;e[11]!==x||e[12]!==m?(u=()=>{x(),m(!1)},e[11]=x,e[12]=m,e[13]=u):u=e[13];const M=u;let te;e[14]!==g||e[15]!==m?(te=()=>{g?.(),m(!1)},e[14]=g,e[15]=m,e[16]=te):te=e[16];const U=te;let G;e[17]!==B||e[18]!==O||e[19]!==g||e[20]!==m||e[21]!==S||e[22]!==z||e[23]!==b?(G=async()=>{const ee=await B();if(!ee){v.error(b("gitView.conflict.noDetailsAvailable"));return}if(!O){v.error(b("gitView.conflict.noActiveSession"),{description:b("gitView.conflict.noActiveSessionDescription")});return}S(ee.visibleText,"replace"),z([{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]),g?.(),m(!1)},e[17]=B,e[18]=O,e[19]=g,e[20]=m,e[21]=S,e[22]=z,e[23]=b,e[24]=G):G=e[24];const _=G;let X;e[25]!==B||e[26]!==f||e[27]!==g||e[28]!==m||e[29]!==V||e[30]!==b?(X=async()=>{const ee=await B();if(!ee){v.error(b("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:ee.visibleText,syntheticParts:[{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]}),g?.(),m(!1)},e[25]=B,e[26]=f,e[27]=g,e[28]=m,e[29]=V,e[30]=b,e[31]=X):X=e[31];const $=X;let le,ae,ce,ie,h,d,I,A,q,ne,se,J,we,K,de,ke,ye,me,xe,Ve,Re,ue;if(e[32]!==D||e[33]!==E||e[34]!==O||e[35]!==M||e[36]!==U||e[37]!==_||e[38]!==$||e[39]!==C||e[40]!==R||e[41]!==m||e[42]!==i||e[43]!==p||e[44]!==b){const ee=b(p==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),he=D?.unmergedFiles||E;ce=mt,Re=i,ue=m,ae=ht,Ve="max-w-md w-[calc(100vw-2rem)]",K="flex flex-col gap-4 overflow-hidden";let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx(T,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Be):Be=e[67];const ge=t.jsxs("div",{className:"flex items-center gap-2",children:[Be,t.jsx(ft,{children:b("gitView.conflict.detectedTitle",{operation:ee})})]});let Ne;e[68]!==p||e[69]!==b?(Ne=b("gitView.conflict.detectedDescription",{operation:p}),e[68]=p,e[69]=b,e[70]=Ne):Ne=e[70];let Ie;e[71]!==Ne?(Ie=t.jsx(bt,{children:Ne}),e[71]=Ne,e[72]=Ie):Ie=e[72],e[73]!==ge||e[74]!==Ie?(de=t.jsxs(gt,{children:[ge,Ie]}),e[73]=ge,e[74]=Ie,e[75]=de):de=e[75],e[76]!==C||e[77]!==b?(ke=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:b("gitView.conflict.loading")})]}),e[76]=C,e[77]=b,e[78]=ke):ke=e[78],e[79]!==R||e[80]!==b?(ye=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:b("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=b,e[81]=ye):ye=e[81],e[82]!==he||e[83]!==b?(me=he.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:he.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:he.map(ki)})})]}),e[82]=he,e[83]=b,e[84]=me):me=e[84],e[85]!==D||e[86]!==b?(xe=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.headInfo")}),t.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[85]=D,e[86]=b,e[87]=xe):xe=e[87],se="flex flex-col gap-2 pt-2";let Te;e[88]!==$?(Te=()=>{$()},e[88]=$,e[89]=Te):Te=e[89];const oe=C||!D;let Pe;e[90]!==C?(Pe=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"add",className:"size-4"}),e[90]=C,e[91]=Pe):Pe=e[91];let Fe;e[92]!==b?(Fe=b("gitView.conflict.resolveNewSession"),e[92]=b,e[93]=Fe):Fe=e[93],e[94]!==Te||e[95]!==oe||e[96]!==Pe||e[97]!==Fe?(J=t.jsxs(W,{variant:"default",onClick:Te,disabled:oe,className:"w-full gap-2",children:[Pe,Fe]}),e[94]=Te,e[95]=oe,e[96]=Pe,e[97]=Fe,e[98]=J):J=e[98];let De;e[99]!==_?(De=()=>{_()},e[99]=_,e[100]=De):De=e[100];const We=C||!D||!O;let Le;e[101]!==C?(Le=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Le):Le=e[102];let Q;e[103]!==b?(Q=b("gitView.conflict.resolveCurrentSession"),e[103]=b,e[104]=Q):Q=e[104],e[105]!==De||e[106]!==We||e[107]!==Le||e[108]!==Q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:We,className:"w-full gap-2",children:[Le,Q]}),e[105]=De,e[106]=We,e[107]=Le,e[108]=Q,e[109]=we):we=e[109],q="flex gap-2 pt-1";let fe;e[110]!==b?(fe=b("gitView.conflict.continueLater"),e[110]=b,e[111]=fe):fe=e[111],e[112]!==U||e[113]!==fe?(ne=t.jsx(W,{variant:"ghost",size:"sm",onClick:U,className:"flex-1",children:fe}),e[112]=U,e[113]=fe,e[114]=ne):ne=e[114],le=W,ie="destructive",h="sm",d=M,I="flex-1",A=b("gitView.conflict.abortOperation",{operation:ee}),e[32]=D,e[33]=E,e[34]=O,e[35]=M,e[36]=U,e[37]=_,e[38]=$,e[39]=C,e[40]=R,e[41]=m,e[42]=i,e[43]=p,e[44]=b,e[45]=le,e[46]=ae,e[47]=ce,e[48]=ie,e[49]=h,e[50]=d,e[51]=I,e[52]=A,e[53]=q,e[54]=ne,e[55]=se,e[56]=J,e[57]=we,e[58]=K,e[59]=de,e[60]=ke,e[61]=ye,e[62]=me,e[63]=xe,e[64]=Ve,e[65]=Re,e[66]=ue}else le=e[45],ae=e[46],ce=e[47],ie=e[48],h=e[49],d=e[50],I=e[51],A=e[52],q=e[53],ne=e[54],se=e[55],J=e[56],we=e[57],K=e[58],de=e[59],ke=e[60],ye=e[61],me=e[62],xe=e[63],Ve=e[64],Re=e[65],ue=e[66];let _e;e[115]!==le||e[116]!==ie||e[117]!==h||e[118]!==d||e[119]!==I||e[120]!==A?(_e=t.jsx(le,{variant:ie,size:h,onClick:d,className:I,children:A}),e[115]=le,e[116]=ie,e[117]=h,e[118]=d,e[119]=I,e[120]=A,e[121]=_e):_e=e[121];let Ae;e[122]!==q||e[123]!==ne||e[124]!==_e?(Ae=t.jsxs("div",{className:q,children:[ne,_e]}),e[122]=q,e[123]=ne,e[124]=_e,e[125]=Ae):Ae=e[125];let je;e[126]!==se||e[127]!==J||e[128]!==we||e[129]!==Ae?(je=t.jsxs("div",{className:se,children:[J,we,Ae]}),e[126]=se,e[127]=J,e[128]=we,e[129]=Ae,e[130]=je):je=e[130];let be;e[131]!==K||e[132]!==de||e[133]!==ke||e[134]!==ye||e[135]!==me||e[136]!==xe||e[137]!==je?(be=t.jsxs("div",{className:K,children:[de,ke,ye,me,xe,je]}),e[131]=K,e[132]=de,e[133]=ke,e[134]=ye,e[135]=me,e[136]=xe,e[137]=je,e[138]=be):be=e[138];let Ce;e[139]!==ae||e[140]!==Ve||e[141]!==be?(Ce=t.jsx(ae,{className:Ve,children:be}),e[139]=ae,e[140]=Ve,e[141]=be,e[142]=Ce):Ce=e[142];let Me;return e[143]!==ce||e[144]!==Re||e[145]!==ue||e[146]!==Ce?(Me=t.jsx(ce,{open:Re,onOpenChange:ue,children:Ce}),e[143]=ce,e[144]=Re,e[145]=ue,e[146]=Ce,e[147]=Me):Me=e[147],Me};function ji(o){return o.openNewSessionDraft}function Ci(o){return o.currentSessionId}function Ni(o){return o.setPendingInputText}function Si(o){return o.setPendingSyntheticParts}function ki(o){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:o,children:o},o)}const Vi=({open:o,onOpenChange:e,operation:i,targetBranch:m,onConfirm:N})=>{const{t:f}=nt(),[p,x]=l.useState(!0),[g,w]=l.useState(!1),E=f(i==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),b=async()=>{w(!0);try{await N(p),e(!1)}catch(O){const S=O instanceof Error?O.message:`Failed to ${i}`;v.error(S)}finally{w(!1)}},V=()=>{g||e(!1)};return t.jsx(mt,{open:o,onOpenChange:g?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(ft,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:i})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(i==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(i==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:m})]}),p&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(fa,{checked:p,onChange:x,disabled:g,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!g&&x(!p),children:f("gitView.stash.restoreAfterOperation",{operation:i})})]}),t.jsxs(Ts,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:g,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:b,disabled:g,className:"gap-1.5",children:g?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:E})})]})]})})},Ii=({mergeInProgress:o,rebaseInProgress:e,onContinue:i,onAbort:m,onResolveWithAI:N,conflictCount:f=0,isLoading:p=!1})=>{const{t:x}=nt(),[g,w]=l.useState(null),E=o&&o.head,b=e&&(e.headName||e.onto),V=E?"merge":b?"rebase":null;if(!V)return null;const O=async()=>{w("continue");try{await i()}finally{w(null)}},S=async()=>{w("abort");try{await m()}finally{w(null)}},z=g!==null,C=f>0,y=x(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";o?D=o.message?x("gitView.operation.mergingMessage",{message:o.message}):x("gitView.operation.mergeInProgressWithHead",{head:o.head}):e&&(D=e.headName?x("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):x("gitView.operation.rebaseInProgress"));const k=C?f===1?x("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):x("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):x("gitView.operation.inProgressTitle",{operation:y}),R=x(C?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:k}),D&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:R}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:S,disabled:z||p,className:"gap-1.5",children:[g==="abort"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"close",className:"size-4"}),x("gitView.operation.abort")]}),C?N&&t.jsx(W,{variant:"default",size:"sm",onClick:N,disabled:z||p,children:x("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:O,disabled:z||p,className:"gap-1.5",children:[g==="continue"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"check",className:"size-4"}),x("gitView.operation.continue")]})]})]})]})})},Pi=o=>{const e=jt.c(104),{currentBranch:i,localBranches:m,remoteBranches:N,onMerge:f,onRebase:p,disabled:x,isOperating:g,operationLogs:w,onOperationComplete:E,mode:b,defaultTargetBranch:V}=o,O=x===void 0?!1:x,S=g===void 0?!1:g,z=w===void 0?[]:w,C=b===void 0?"dialog":b,{t:y}=nt(),[D,k]=l.useState(!1),[R,P]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[u,M]=l.useState(""),te=l.useRef(null),U=l.useRef(null),G=O||S,_=i||y("gitView.branch.currentBranchFallback"),X=z.length>0&&z.every(Fi),$=z.some(Ri);let le;e[0]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},e[0]=le):le=e[0],l.useEffect(le,[z]);let ae;e[1]!==N?(ae=new Set(N.map(Bi).filter(Boolean)),e[1]=N,e[2]=ae):ae=e[2];const ce=ae;let ie;if(e[3]!==u||e[4]!==i||e[5]!==m||e[6]!==ce){let Q;e[8]!==i||e[9]!==ce?(Q=Oe=>Oe!==i&&!ce.has(Oe),e[8]=i,e[9]=ce,e[10]=Q):Q=e[10];const fe=m.filter(Q);ie=Bt(fe,u,Di),e[3]=u,e[4]=i,e[5]=m,e[6]=ce,e[7]=ie}else ie=e[7];const h=ie;let d;e[11]!==u||e[12]!==N?(d=Bt(N,u,Ei),e[11]=u,e[12]=N,e[13]=d):d=e[13];const I=d;let A;e[14]!==V||e[15]!==m||e[16]!==N?(A=()=>V&&(N.includes(V)||m.includes(V))?V:null,e[14]=V,e[15]=m,e[16]=N,e[17]=A):A=e[17];const q=A;let ne;e[18]!==q||e[19]!==k?(ne=()=>{k(!0),r(q()),P("merge"),M("")},e[18]=q,e[19]=k,e[20]=ne):ne=e[20];const se=ne;let J;e[21]===Symbol.for("react.memo_cache_sentinel")?(J=Q=>{r(Q),B(!1),M("")},e[21]=J):J=e[21];const we=J;let K;e[22]!==f||e[23]!==p||e[24]!==R||e[25]!==F?(K=()=>{F&&(R==="merge"?f(F):p(F))},e[22]=f,e[23]=p,e[24]=R,e[25]=F,e[26]=K):K=e[26];const de=K;let ke;e[27]!==S||e[28]!==k?(ke=()=>{S||(r(null),P("merge"),M(""),k(!1))},e[27]=S,e[28]=k,e[29]=ke):ke=e[29];const ye=ke,me=()=>{S&&!X||(X&&E?.(),r(null),P("merge"),M(""),k(!1))};let xe,Ve;e[30]!==Y?(xe=()=>{Y||M("")},Ve=[Y],e[30]=Y,e[31]=xe,e[32]=Ve):(xe=e[31],Ve=e[32]),l.useEffect(xe,Ve);let Re,ue;e[33]!==C||e[34]!==q||e[35]!==F?(Re=()=>{C==="dialog"||F||r(q())},ue=[C,q,F],e[33]=C,e[34]=q,e[35]=F,e[36]=Re,e[37]=ue):(Re=e[36],ue=e[37]),l.useEffect(Re,ue);const je=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:U,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:z.map(Mi)})}),X?C==="dialog"?t.jsx(Ts,{children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y($?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y($?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>P("merge"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="merge"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-merge",className:Se("size-4",R==="merge"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="merge"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>P("rebase"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="rebase"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-branch",className:Se("size-4",R==="rebase"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="rebase"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?y("gitView.branch.branchToMergeInto",{branch:_}):y("gitView.branch.branchToRebaseOnto")}),t.jsxs(Ls,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(Os,{asChild:!0,children:t.jsxs("button",{type:"button",className:Se(Rr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Se("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(As,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(zs,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Gs,{ref:te,placeholder:y("gitView.branch.searchPlaceholder"),value:u,onValueChange:M,onKeyDown:Ti}),t.jsxs(_s,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx($s,{children:y("gitView.branch.empty")}),h.length>0&&t.jsx(Qt,{heading:y("gitView.branch.localBranches"),children:h.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`local-${Q}`))}),h.length>0&&I.length>0?t.jsx(pa,{}):null,I.length>0&&t.jsx(Qt,{heading:y("gitView.branch.remoteBranches"),children:I.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`remote-${Q}`))})]})]})})]})]}),F?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})," ",y("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})]}):t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})," ",y("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})]})})}):null,C==="dialog"?t.jsxs(Ts,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ye,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-branch",className:"size-4"}),y("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:ye,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return je;if(C==="inline"){let Q;e[38]!==y?(Q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=Q):Q=e[39];let fe;e[40]!==Q?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:Q}),e[40]=Q,e[41]=fe):fe=e[41];let Oe;e[42]!==y?(Oe=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Oe):Oe=e[43];let et;e[44]!==_?(et=t.jsx("span",{className:"font-mono text-foreground",children:_}),e[44]=_,e[45]=et):et=e[45];let $e;e[46]!==Oe||e[47]!==et?($e=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Oe," ",et,"."]}),e[46]=Oe,e[47]=et,e[48]=$e):$e=e[48];let Ue;e[49]!==fe||e[50]!==$e?(Ue=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,$e]})}),e[49]=fe,e[50]=$e,e[51]=Ue):Ue=e[51];let He;e[52]!==je?(He=t.jsx("div",{className:"pt-3",children:je}),e[52]=je,e[53]=He):He=e[53];let pt;return e[54]!==Ue||e[55]!==He?(pt=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Ue,He]}),e[54]=Ue,e[55]=He,e[56]=pt):pt=e[56],pt}let be;e[57]!==S?(be=S?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=be):be=e[58];let Ce;e[59]!==y?(Ce=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Ce):Ce=e[60];let Me;e[61]!==Ce?(Me=t.jsx("span",{children:Ce}),e[61]=Ce,e[62]=Me):Me=e[62];let ee;e[63]!==se||e[64]!==G||e[65]!==be||e[66]!==Me?(ee=t.jsx(es,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:se,disabled:G,children:[be,Me]})}),e[63]=se,e[64]=G,e[65]=be,e[66]=Me,e[67]=ee):ee=e[67];let he;e[68]!==y?(he=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=he):he=e[69];let Be;e[70]!==he?(Be=t.jsx(ts,{sideOffset:8,children:he}),e[70]=he,e[71]=Be):Be=e[71];let ge;e[72]!==ee||e[73]!==Be?(ge=t.jsxs(Zt,{children:[ee,Be]}),e[72]=ee,e[73]=Be,e[74]=ge):ge=e[74];let Ne;e[75]!==me||e[76]!==k?(Ne=Q=>{Q?k(!0):me()},e[75]=me,e[76]=k,e[77]=Ne):Ne=e[77];let Ie;e[78]!==y?(Ie=y("gitView.branch.updateTitle"),e[78]=y,e[79]=Ie):Ie=e[79];let Te;e[80]!==Ie?(Te=t.jsx(ft,{children:Ie}),e[80]=Ie,e[81]=Te):Te=e[81];let oe;e[82]!==$||e[83]!==S||e[84]!==R||e[85]!==X||e[86]!==y||e[87]!==_?(oe=S?y(X?$?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":R==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[y("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_}),"."]}),e[82]=$,e[83]=S,e[84]=R,e[85]=X,e[86]=y,e[87]=_,e[88]=oe):oe=e[88];let Pe;e[89]!==oe?(Pe=t.jsx(bt,{children:oe}),e[89]=oe,e[90]=Pe):Pe=e[90];let Fe;e[91]!==Te||e[92]!==Pe?(Fe=t.jsxs(gt,{children:[Te,Pe]}),e[91]=Te,e[92]=Pe,e[93]=Fe):Fe=e[93];let De;e[94]!==je||e[95]!==Fe?(De=t.jsxs(ht,{className:"max-w-md",children:[Fe,je]}),e[94]=je,e[95]=Fe,e[96]=De):De=e[96];let We;e[97]!==D||e[98]!==Ne||e[99]!==De?(We=t.jsx(mt,{open:D,onOpenChange:Ne,children:De}),e[97]=D,e[98]=Ne,e[99]=De,e[100]=We):We=e[100];let Le;return e[101]!==ge||e[102]!==We?(Le=t.jsxs(t.Fragment,{children:[ge,We]}),e[101]=ge,e[102]=We,e[103]=Le):Le=e[103],Le};function Fi(o){return o.status==="done"||o.status==="error"}function Ri(o){return o.status==="error"}function Bi(o){return o.slice(o.indexOf("/")+1)}function Di(o){return[o]}function Ei(o){return[o]}function Mi(o,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[o.status==="running"&&t.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(T,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(T,{name:"close",className:"size-3.5 text-destructive"}),o.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Se("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})]},e)}function Ti(o){return o.stopPropagation()}const Li=({runMutation:o,onMutationComplete:e,onMutationError:i,onPathsComplete:m,scheduleFlush:N})=>{const f=[];let p=!1;return{enqueue:g=>{const w=f[f.length-1];if(w?.directory===g.directory&&w.direction===g.direction){g.paths.forEach(E=>w.paths.add(E));return}f.push(g)},flush:()=>{if(p)return;const g=f.shift();if(!g)return;p=!0;const w={directory:g.directory,direction:g.direction,paths:Array.from(g.paths),rollback:g.rollback};(async()=>{try{await o(w),e(w)}catch(E){i(w,E)}finally{m(w.paths),p=!1,f.length>0&&N()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>p}},Oi=15e3,Ai=40,zi=20,Ir={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Pr=(o,e)=>{const i=o.toLowerCase(),m=/^([a-z]+)(?:\(.*\))?!?:/,N=i.match(m);if(N){const x=N[1],g=Ir[x];if(g)return e.find(w=>w.code===g)||null}const f=i.split(" ")[0],p=Ir[f];return p&&e.find(x=>x.code===p)||null},Gi=20,yt=new Map,_i=(o,e)=>{if(yt.delete(o),yt.set(o,e),yt.size>Gi){const i=yt.keys().next().value;i!==void 0&&yt.delete(i)}},Ze=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Fr=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},$i=o=>{const e=o.working_dir?.trim(),i=o.index?.trim();return!!(e||i==="?")},cc=({isActive:o})=>{const{t:e}=nt(),{git:i}=xa(),m=wa(),[N,f]=l.useState(null),[p,x]=l.useState(null),g=rt(s=>s.currentSessionId),w=rt(s=>s.newSessionDraft),E=rt(s=>s.setDraftBootstrapPendingDirectory),b=rt(s=>s.worktreeMetadata),V=rt(s=>s.availableWorktrees),O=Ze(m),S=l.useMemo(()=>{if(!O)return;const s=V.find(n=>Ze(n.path)===O);if(s)return s;for(const n of b.values())if(Ze(n.path)===O)return n},[V,O,b]),z=l.useMemo(()=>{if(g)return b.get(g)??S;if(w?.open)return S},[g,S,w?.open,b]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:P}=Ga(pr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:F,gitDirectory:r,nestedRepos:Y}=ya(m??null,{enabled:o}),B=ba(r??null),u=va(r??null),M=ja(s=>g?s.getAttachment(g):void 0),te=M?Ca(M):[],U=M&&!M.degraded&&!M.legacy?M.worktreeRoot??void 0:void 0,G=Aa(m,z,u?.current??void 0),_=Na(r??null),X=Sa(r??null),$=ka(r??null),le=Va(r??null),ae=Ia(r??null),{setActiveDirectory:ce,ensureAll:ie,fetchStatus:h,fetchBranches:d,fetchLog:I,setLogMaxCount:A,fetchIdentity:q,prefetchDiffs:ne,clearDiffCache:se,moveStatusPathsOptimistically:J,restoreStatus:we,bumpIndexRevision:K,ensureNestedRepos:de,selectNestedRepo:ke}=Pa(pr(s=>({setActiveDirectory:s.setActiveDirectory,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),ye=Ft(s=>s.isMobile),me=Ft(s=>s.openContextDiff),xe=Ft(s=>s.openContextSurface),Ve=u?.current??null,Re=Fa(s=>!r||!Ve?null:Ra(s.entries,r,Ve)),ue=Ft(s=>s.navigateToDiff),_e=l.useRef(null),Ae=l.useRef(null),je=l.useRef(null),be=l.useRef(!0);l.useEffect(()=>()=>{be.current=!1},[]);const Ce=l.useCallback(()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null)},[]),Me=l.useCallback(s=>{Ce(),_e.current=window.setTimeout(()=>{_e.current=null,Ze(s)===Ze(r)&&h(s,i,{silent:!0})},Oi)},[Ce,r,h,i]);l.useEffect(()=>Ce,[Ce]);const ee=l.useCallback(()=>{Ae.current!==null&&(window.clearTimeout(Ae.current),Ae.current=null)},[]),he=l.useCallback(()=>{Ae.current===null&&(Ae.current=window.setTimeout(()=>{Ae.current=null,je.current?.()},0))},[]),Be=l.useCallback(async(s,n,a)=>{if(n==="stage"){if(i.stageGitFiles){await i.stageGitFiles(s,a);return}await Promise.all(a.map(c=>i.stageGitFile(s,c)));return}if(i.unstageGitFiles){await i.unstageGitFiles(s,a);return}await Promise.all(a.map(c=>i.unstageGitFile(s,c)))},[i]),ge=l.useMemo(()=>Li({runMutation:({directory:s,direction:n,paths:a})=>Be(s,n,a),onMutationComplete:({directory:s})=>{K(s),Me(s)},onMutationError:({directory:s,direction:n,rollback:a},c)=>{a?.(),K(s),Me(s);const j=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");v.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{Ys(n=>{const a=new Set(n);return s.forEach(c=>a.delete(c)),a})},scheduleFlush:he}),[K,Be,he,Me,e]);l.useEffect(()=>(je.current=ge.flush,()=>{je.current=null}),[ge]),l.useEffect(()=>()=>ge.clear(),[ge]),l.useEffect(()=>ee,[ee]),l.useEffect(()=>{if(!o)return;if(!m){f(null);return}const s=Ze(m)??m;f({directory:s,status:null});let n=!1,a=null;const c=async()=>{try{const j=await Oa(m);if(n)return;f({directory:s,status:j.status}),j.status==="pending"&&(a=window.setTimeout(()=>{c()},500))}catch{n||f({directory:s,status:null})}};return c(),()=>{n=!0,a!==null&&window.clearTimeout(a)}},[o,m]);const Ne=Ze(w?.bootstrapPendingDirectory??null),Ie=!!(m&&Ne&&Ne===Ze(m)),Te=Ba(m??null),oe=Ze(m),Pe=N?.directory===oe?N.status:null,Fe=!!(m&&(Te||Pe==="pending"||Ie&&w?.pendingWorktreeRequestId)),De=!!(oe&&p?.directory===oe);l.useEffect(()=>{if(!oe)return;if(Pe==="failed"){E(null),x(n=>n?.directory===oe?null:n);return}if(Fe){x(n=>n?.directory===oe&&n.status==="refreshing"?n:{directory:oe,status:"refreshing"});return}if(p?.directory!==oe||p.status!=="refreshing"||!r||!i)return;let s=!1;return h(r,i,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||x(n=>n?.directory===oe?null:n)}).catch(()=>{s||x(n=>n?.directory===oe?{...n,status:"failed"}:n)}),()=>{s=!0}},[h,i,r,Fe,oe,Pe,p,E]);const We=Fe||De,Le=De&&p?.status==="failed",Q=l.useMemo(()=>r?yt.get(r)??null:null,[r]),fe=Da(s=>s.settingsGitmojiEnabled),[Oe,et]=l.useState(null),{gitmojis:$e}=Za(fe);l.useEffect(()=>{const s=U||G?.projectDirectory;if(!s){et(null);return}let n=!1;return Ea(s).then(a=>{if(n)return;const c=a.trim();et(c&&c!=="HEAD"?c:null)}).catch(()=>{n||et(null)}),()=>{n=!0}},[U,G?.projectDirectory]);const[Ue,He]=l.useState(Q?.commitMessage??""),[pt,Tr]=l.useState([]),[Lr,ss]=l.useState(!1),Hs=l.useRef(null),[Ws,Dt]=l.useState(null),[Or,rs]=l.useState(!1),[Us,Ks]=l.useState(null),[Ye,Ar]=l.useState(25),[zr,Js]=l.useState(!1),{triggerFireworks:Gr}=za(),qs=l.useRef(new Map),Et=l.useRef(0),ns=l.useCallback(()=>{Et.current+=1,be.current&&Js(!0)},[]),as=l.useCallback(()=>{Et.current=Math.max(0,Et.current-1),be.current&&Et.current===0&&Js(!1)},[]),[is,Mt]=l.useState(new Set),[_r,Ys]=l.useState(new Set),[os,Qs]=l.useState(!1),[$r,Hr]=l.useState(0),[Wr,Xs]=l.useState(!1),[ls,cs]=l.useState(Q?.generatedHighlights??[]),Ur=_r.size>0||ge.size()>0||ge.isRunning(),Zs=l.useCallback(()=>{const s=Hs.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),ds=U||G?.projectDirectory||null,us=u?.current||null,Kr=l.useMemo(()=>{const s=u?.tracking;return s?s.startsWith("origin/"):!0},[u?.tracking]),er=l.useMemo(()=>{const s=G?.createdFromBranch,n=typeof s=="string"?s.trim():"",a=typeof u?.current=="string"?u.current.trim():"",c=typeof Oe=="string"?Oe.trim():"";return n?n===a&&n.startsWith("opencode/")&&c.length>0&&c!==n?c:n:c||a||"HEAD"},[G?.createdFromBranch,u,Oe]),Tt=l.useCallback(()=>{cs([])},[]),[ms,Jr]=l.useState(new Set),[Lt,qr]=l.useState(new Map),[Ot,hs]=l.useState(new Set),gs=l.useRef(Lt),Nt=l.useRef(Ot),[Yr,vt]=l.useState(null),[xt,fs]=l.useState(null),[tr,sr]=l.useState(""),[Ee,At]=l.useState(null),[Qr,rr]=l.useState(!1),[Xr,nr]=l.useState(!1),[ps,xs]=l.useState([]),[Zr,ar]=l.useState(null),[ir,ws]=l.useState(null),[en,zt]=l.useState([]),[tn,Qe]=l.useState(!1),[sn,tt]=l.useState([]),[Gt,st]=l.useState("merge"),[rn,ys]=l.useState(null),[bs,or]=l.useState(!1),[vs,nn]=l.useState(100),[an,on]=l.useState(0),Xe=l.useMemo(()=>g?`openchamber.conflict:${g}`:null,[g]),at=l.useCallback((s,n,a)=>{if(!Xe||typeof window>"u")return;const c={directory:s,conflictFiles:n,operation:a};window.localStorage.setItem(Xe,JSON.stringify(c))},[Xe]),Ke=l.useCallback(()=>{!Xe||typeof window>"u"||window.localStorage.removeItem(Xe)},[Xe]);l.useEffect(()=>{if(!Xe||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Xe);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Xe);return}tt(n.conflictFiles??[]),st(n.operation??"merge"),Qe(!0)}catch{window.localStorage.removeItem(Xe)}},[Xe,r]);const[ln,js]=l.useState(!1),[_t,St]=l.useState(null),[Cs,lr]=l.useState("merge"),[Ns,cr]=l.useState(""),cn=l.useCallback(s=>{Ma(s).then(n=>{if(n.ok){v.success(e("gitView.toast.commitHashCopied"));return}v.error(e("gitView.toast.copyFailed"))})},[e]),dn=l.useCallback(s=>{Jr(n=>{const a=new Set(n);return a.has(s)?a.delete(s):a.add(s),a})},[]);l.useEffect(()=>{gs.current=Lt},[Lt]),l.useEffect(()=>{Nt.current=Ot},[Ot]),l.useEffect(()=>{if(!r||!i)return;const s=Array.from(ms).filter(a=>!gs.current.has(a)&&!Nt.current.has(a));if(s.length===0)return;let n=!1;return hs(a=>{const c=new Set(a);for(const j of s)c.add(j);return Nt.current=c,c}),Promise.all(s.map(a=>i.getCommitFiles(r,a).then(c=>({hash:a,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:a,files:[]})))).then(a=>{n||(qr(c=>{const j=new Map(c);for(const{hash:L,files:Z}of a)j.set(L,Z);return gs.current=j,j}),hs(c=>{const j=new Set(c);for(const{hash:L}of a)j.delete(L);return Nt.current=j,j}))}),()=>{n=!0,hs(a=>{let c=!1;const j=new Set(a);for(const L of s)j.delete(L)&&(c=!0);return c?(Nt.current=j,j):a})}},[ms,r,i]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;He(s?.commitMessage??""),cs(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&_i(r,{directory:r,commitMessage:Ue,generatedHighlights:ls})},[Ue,r,ls]),l.useEffect(()=>{o&&(k(),R(),P())},[o,k,R,P]),l.useEffect(()=>{if(!o)return;if(!r||!i?.getRemoteUrl||B!==!0){fs(null);return}let s=!1;return i.getRemoteUrl(r).then(n=>{s||fs(n)}).catch(()=>{s||fs(null)}),()=>{s=!0}},[o,r,i,B]);const $t=l.useCallback(async()=>{if(!r||!i?.getRemotes||B!==!0){xs([]);return}try{const s=await i.getRemotes(r);be.current&&xs(s)}catch{be.current&&xs([])}},[r,i,B]);l.useEffect(()=>{o&&$t()},[o,$t]),l.useEffect(()=>{o&&m&&r&&(ce(m),ie(r,i))},[o,m,r,ce,ie,i]),l.useEffect(()=>{if(o&&r)return Ta.onGitRefreshHint(s=>{Ze(s.directory)===Ze(r)&&(s.paths?.length&&se(r,s.paths),h(r,i,{silent:!0}))})},[o,se,r,h,i]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,i),d(r,i)])}catch(n){if(s){const a=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");v.error(a)}}},[r,i,h,d,e]),pe=l.useCallback(async()=>{r&&await I(r,i,Ye)},[r,i,I,Ye]),Ss=l.useCallback(async()=>{r&&await q(r,i)},[r,i,q]);l.useEffect(()=>{if(!o||!r||!i?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||qs.current.get(r)===s)return;let a=!1;return(async()=>{try{const j=await i.hasLocalIdentity?.(r);if(a||j===!0)return;ns(),await i.setGitIdentity(r,s),qs.current.set(r,s),await Ss()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{a||as()}})(),()=>{a=!0}},[o,ns,r,D,as,i,B,Ss]);const it=l.useMemo(()=>u?[...u.files??[]].sort((n,a)=>n.path.localeCompare(a.path)):[],[u]),Je=l.useMemo(()=>it.filter(Fr),[it]),ks=l.useMemo(()=>it.filter($i),[it]);l.useEffect(()=>{if(!o||!r||it.length===0)return;const s=[],n=new Set,a=j=>{!j||n.has(j)||(n.add(j),s.push(j))};if(Je.forEach(j=>a(j.path)),pt.forEach(a),it.slice(0,zi).forEach(j=>a(j.path)),s.length===0)return;const c=window.setTimeout(()=>{ne(r,i,s,{maxFiles:Ai})},120);return()=>{window.clearTimeout(c)}},[o,it,r,i,ne,Je,pt]);const Vs=s=>s?.pushed[0]?.remote||u?.tracking?.split("/")[0]||ze.find(n=>n.name==="origin")?.name||ze[0]?.name||"origin",dr=async(s,n)=>{if(r){Dt(s);try{const a=c=>{const j=`${c.name}/`,L=u?.tracking?.startsWith(j)?u.tracking.slice(j.length):void 0;return{remote:c.name,branch:L,rebase:!0}};if(s==="fetch"){if(!n)throw new Error("No remote available for fetch");await i.gitFetch(r,{remote:n.name}),v.success(e("gitView.toast.fetchedFromRemote",{name:n.name}))}else if(s==="pull"){if(!n)throw new Error("No remote available for pull");const c=await i.gitPull(r,a(n));v.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:n.name}))}else if(s==="push"){const c=await i.gitPush(r);v.success(c.pushed.length>0?e("gitView.toast.pushedToUpstream",{name:Vs(c)}):e("gitView.toast.alreadyUpToDate"))}else if(s==="sync"){if(!n)throw new Error("No remote available for sync");let c=0;const j=await xr({git:i,directory:r,remote:n,dirtyWorktreeError:e("gitView.toast.commitOrStashBeforeSync"),onPulled:H=>{c=H.files.length}}),L=j.pushed.length>0,Z=Vs(j);c>0&&L&&Z===n.name?v.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:n.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:n.name})):(c>0&&v.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:n.name})),L&&v.success(e("gitView.toast.pushedToUpstream",{name:Z})),c===0&&!L&&v.success(e("gitView.toast.alreadyUpToDate")))}await re(!1),await pe()}catch(a){const c=a instanceof Error?a.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});v.error(c)}finally{Dt(null)}}},un=l.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){v.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){v.error(e("gitView.toast.cannotRemoveOriginRemote"));return}ar(n);try{await i.removeRemote(r,{remote:n}),v.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([re(!1),$t()])}catch(a){const c=a instanceof Error?a.message:`Failed to remove ${n}`;v.error(c)}finally{ar(null)}},[r,i,$t,re,e]),ur=async(s={})=>{if(!r)return;if(!Ue.trim()){v.error(e("gitView.toast.enterCommitMessage"));return}const n=Je.map(c=>c.path).sort();if(n.length===0){v.error(e("gitView.toast.stageFileToCommit"));return}const a=s.pushAfter?"commitAndPush":"commit";Ks(a);try{if(await i.createGitCommit(r,Ue.trim(),{files:n,stageFiles:[]}),K(r),v.success(e("gitView.toast.commitCreated")),He(""),Tt(),await re(),s.pushAfter){const c=u?.tracking?.split("/")[0],j=ze.find(L=>L.name===c)??ze[0];if(!j)throw new Error(e("mobile.changes.noRemote"));Dt("sync"),await xr({git:i,directory:r,remote:j,dirtyWorktreeError:e("gitView.toast.commitOrStashBeforeSync"),onPushed:L=>{v.success(e("gitView.toast.pushedToUpstream",{name:Vs(L)})),Gr()}}),await re(!1)}else await re(!1);await pe(),Hr(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");v.error(j)}finally{Ks(null),s.pushAfter&&Dt(null)}},mn=l.useCallback(async()=>{if(!r)return;const s=Je.map(n=>n.path).sort();if(s.length===0){v.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Xs(!0);try{const{message:n}=await fr(r,s),a=n.subject?.trim()??"",c=Array.isArray(n.highlights)?n.highlights:[];if(a){let j=a;if(fe&&$e.length>0){const L=Pr(a,$e);if(L){const{code:Z,emoji:H}=L;!a.startsWith(Z)&&!a.startsWith(H)&&(j=`${Z} ${a}`)}}He(j)}cs(c),Zs()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const a=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");v.error(a)}finally{Xs(!1)}},[r,Je,fe,$e,Zs,e]),Is=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",hn=async(s,n)=>{if(!r||!u)return;const a=Ds(M);if(a.length>0){v.error(e("gitView.toast.cannotCreateBranch",{reason:Is(a[0])}));return}const c=u.current??null,j=n?.name??"origin";try{await i.createBranch(r,s,c??"HEAD"),v.success(e("gitView.toast.createdBranch",{name:s})),await i.checkoutBranch(r,s);let L=!1;try{await i.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),L=!0}catch(Z){const H=Z instanceof Error?Z.message:`Unable to push new branch to ${j}.`;v.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",H]})})}await re(),await pe(),L&&v.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(L){const Z=L instanceof Error?L.message:e("gitView.toast.createBranchFailed");throw v.error(Z),L}},gn=async(s,n)=>{if(!r)return;const a=Ds(M);if(a.length>0){v.error(e("gitView.toast.cannotRenameBranch",{reason:Is(a[0])}));return}try{await i.renameBranch(r,s,n),v.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await re(),await pe()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});v.error(j)}},fn=async s=>{if(!r)return;const n=Ds(M);if(n.length>0){v.error(e("gitView.toast.cannotCheckout",{reason:Is(n[0])}));return}const a=s.replace(/^remotes\//,"");if(u?.current!==a){if((u?.files?.length??0)>0){St(a);return}await Ps(a)}},Ps=async s=>{if(!r)return;const n=s;try{const a=await i.checkoutBranch(r,n);v.success(e("gitView.toast.checkedOut",{name:a?.branch||n})),await re(),await pe()}catch(a){const c=a instanceof Error?a.message:e("gitView.toast.checkoutFailed",{name:n});v.error(c)}},pn=async s=>{if(r){ns();try{await i.setGitIdentity(r,s.id),v.success(e("gitView.toast.appliedIdentity",{name:s.name})),await Ss()}catch(n){const a=n instanceof Error?n.message:e("gitView.toast.applyIdentityFailed");v.error(a)}finally{as()}}},kt=l.useMemo(()=>_?.all?_.all.filter(s=>!s.startsWith("remotes/")).sort():[],[_]),ot=l.useMemo(()=>_?.all?_.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[_]),ze=l.useMemo(()=>{if(ps.length>0)return ps;const s=new Set,n=u?.tracking?.trim();n&&n.includes("/")&&s.add(n.split("/")[0]);for(const a of ot){const c=a.indexOf("/");c>0&&s.add(a.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(a=>({name:a,fetchUrl:xt??"",pushUrl:xt??""}))},[ps,ot,xt,u?.tracking]),lt=u?.current??null,mr=l.useMemo(()=>{const s=u?.tracking?.trim().split("/")[0];return(s&&_?.defaultBranches?.[s])??_?.defaultBranches?.origin},[_,u?.tracking]),wt=l.useMemo(()=>_a({remoteNames:new Set(ze.map(s=>s.name)),localBranches:kt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Oe,defaultBranch:mr,headBranch:lt}),[lt,mr,ze,kt,Oe,G?.createdFromBranch]),xn=l.useMemo(()=>ze.map(a=>a.name).map(a=>`${a}/${wt}`).find(a=>ot.includes(a))??wt,[wt,ze,ot]),wn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let n=null;if(xt)try{let a=xt.trim();a.startsWith("git@")&&(a=`https://${a.slice(4).replace(":","/")}`),a.endsWith(".git")&&(a=a.slice(0,-4));const c=new URL(a);n=c.hostname+c.pathname}catch{}for(const a of C){if(a.authType!=="token"){s.set(a.id,a);continue}const c=a.host;if(!c){s.set(a.id,a);continue}if(!c.includes("/")){s.set(a.id,a);continue}n&&n===c&&s.set(a.id,a)}return Array.from(s.values())},[C,y,xt]),yn=l.useMemo(()=>{if($?.userName&&$?.userEmail){const s=C.find(n=>n.userName===$.userName&&n.userEmail===$.userEmail);return s||(y&&y.userName===$.userName&&y.userEmail===$.userEmail?y:{id:"local-config",name:$.userName,userName:$.userName,userEmail:$.userEmail,sshKey:$.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return y??null},[$,C,y]),bn=Je.length,vn=le||Ws!==null||Us!==null,jn=!!(G&&ds&&us&&Kr),hr=!!lt,ct=jn&&ds&&us&&G?{repoRoot:ds,sourceBranch:us,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!i||!X?.all?.length||!lt||!wt||lt===wt){vt(null);return}let s=!1;return(async()=>{try{const a=await i.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ye});if(s)return;const c=new Set((a?.all??[]).map(L=>L.hash).filter(L=>typeof L=="string"&&L.length>0));if(c.size===0){vt(null);return}const j=X.all.findIndex(L=>!c.has(L.hash));if(j===0){vt(null);return}if(j===-1){vt({insertBeforeIndex:X.all.length,branchName:lt,direction:"up"});return}vt({insertBeforeIndex:j,branchName:lt,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,lt,r,i,X,Ye]),l.useEffect(()=>{ys(null)},[r]),l.useEffect(()=>{if(Ee!=="graph"||!r){Ee!=="graph"&&ys(null);return}let s=!1;return or(!0),i.getGitLog(r,{maxCount:vs,all:!0}).then(n=>{s||ys(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||or(!1)}),()=>{s=!0}},[Ee,r,vs,an,i]);const Vt=l.useCallback((s,n)=>{if(!r||s.length===0)return;const a=Array.from(new Set(s));Ys(j=>{const L=new Set(j);return a.forEach(Z=>L.add(Z)),L});const c=J(r,a,n);ge.enqueue({directory:r,direction:n,paths:new Set(a),rollback:()=>we(r,c)}),he()},[r,ge,J,we,he]),Fs=l.useCallback(async s=>{if(r){Mt(n=>{const a=new Set(n);return a.add(s),a});try{await i.revertGitFile(r,s,{scope:"working"}),v.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(n){const a=n instanceof Error?n.message:e("gitView.toast.revertFailed");v.error(a)}finally{Mt(n=>{const a=new Set(n);return a.delete(s),a})}}},[r,re,i,e]),It=l.useCallback(async(s,n,a="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(os||c.some(H=>is.has(H)))return;const j=new Set(Je.map(H=>H.path)),L=a==="all"&&c.some(H=>j.has(H));n&&Qs(!0),Mt(H=>{const qe=new Set(H);return c.forEach(Bs=>qe.add(Bs)),qe});const Z=[];try{if(await Promise.all(c.map(async H=>{try{await i.revertGitFile(r,H,{scope:a})}catch(qe){Z.push({path:H,message:qe instanceof Error?qe.message:e("gitView.toast.revertFailed")})}})),L&&Z.length<c.length&&K(r),await re(!1),Z.length===0)v.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(Z.length===c.length)v.error(Z[0]?.message||e("gitView.toast.revertFailed"));else{const H=c.length-Z.length;v.warning(H===1?e("gitView.toast.revertedSomeSingle",{success:H,failed:Z.length}):e("gitView.toast.revertedSomePlural",{success:H,failed:Z.length}))}}finally{Mt(H=>{const qe=new Set(H);return c.forEach(Bs=>qe.delete(Bs)),qe}),n&&Qs(!1)}},[K,r,i,os,re,is,Je,e]),Cn=l.useCallback(async s=>{await It(s,!0)},[It]),Nn=l.useCallback(async s=>{await It(s,!1,"working")},[It]),Rs=l.useCallback((s,n)=>{if(m&&!ye){me(m,s,n);return}ue(s,n)},[m,ye,ue,me]),Sn=l.useCallback(()=>rs(!0),[]),kn=l.useMemo(()=>{const s=[];return Je.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Je,statsScope:"staged",actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{Vt([n],"unstage")},onActionAll:n=>{Vt(n,"unstage")},onViewDiff:n=>Rs(n,!0),onRevertFile:Fs,showRevertActions:!1,accent:!0}),ks.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:ks,statsScope:"working",actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{Vt([n],"stage")},onActionAll:n=>{Vt(n,"stage")},onViewDiff:n=>Rs(n,!1),onRevertFile:Fs}),s},[Fs,Rs,Vt,Je,e,ks]),Vn=l.useCallback(s=>{if(s.length===0)return;const n=s.map(a=>a.trim()).filter(Boolean);if(n.length===0){Tt();return}He(a=>{const c=a.trim(),j=c.length>0?`
|
|
1
|
+
import{R as l,r as ve,j as t,f as jt}from"./vendor-react-BUCujlKS.js";import{f as nt,z as rt,a7 as Bt,l9 as _n,dA as qt,cI as Yt,t as v,I as T,as as Ls,at as As,au as Rr,av as Os,d5 as zs,d6 as Gs,d7 as _s,d8 as Hs,d0 as Qt,d1 as Xt,B as W,la as Hn,lb as $n,c2 as mt,c3 as ht,c4 as gt,c5 as ft,c6 as bt,X as gr,ae as Zt,af as es,ag as ts,lc as Wn,h as Se,ld as Un,le as Kn,lf as Jn,lg as qn,bh as Yn,ay as Qn,ce as Xn,lh as Zn,li as ea,lj as ta,lk as sa,ll as ra,lm as na,ln as aa,c8 as Br,cj as ia,ck as oa,cl as la,cm as ca,cn as da,cr as ua,ch as ma,cg as ha,lo as ga,cq as fa,c7 as Ts,fo as pa,_ as xa,ai as wa,aj as ya,J as ba,ak as va,bO as ja,lp as Ca,al as Na,lq as Sa,lr as ka,am as Va,ls as Ia,K as Pa,cc as Fa,kd as Ra,lt as Ba,l as Da,cs as Ea,g as Ma,da as Ta,ar as fr,a9 as La,lu as Aa,lv as Ds}from"./useAppFontEffects-BN06mgHB.js";import{a as Oa,b as za}from"./main-GjXmVNpD.js";import{at as Ga,Y as _a,k as Ha,aA as $a}from"./runtimeEndpointReset-sCi88eed.js";import{u as pr}from"./vendor-zustand-BAGL70zf.js";import{h as Wa,u as Ft}from"./index-Di6zUe5h.js";import{C as Ua,a as Ka,D as Ja,p as xr}from"./commitAndPush-BzZrF8bK.js";import{P as qa}from"./PierreDiffViewer-DDljFbJJ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C2qMZiA7.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-Chk1cFUw.js";import"./scheduledTasksApi-Dahv3ws0.js";import"./PluginPane-DPWPLc2f.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./GuestAttachDialog-CQdDIeco.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./changesTree-CePHbFcj.js";import"./web-components-BQWjCn_U.js";import"./computeVirtualFileMetrics-kYyVjXLu.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-BUK1ujXg.js";import"./isDiffPlainText-Bgm_aLpu.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-Bb9Gjz1Q.js";import"./appThemeRegistry-BoJGAwCP.js";import"./textMateThemeFromAppTheme-XM4VefqN.js";const Dr="gitmojiCache",Ya=1e3*60*60*24*7,Er="1",Qa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Mr=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Es=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(Dr);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==Er||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Mr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Xa=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:Er};window.localStorage.setItem(Dr,JSON.stringify(e))}catch{return}},wr=o=>Date.now()-o.fetchedAt<Ya;let Kt=null;const Rt=new Set,yr=async()=>{if(Kt)return Kt;const o=(async()=>{try{const e=await fetch(Qa);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const i=await e.json(),m=Array.isArray(i.gitmojis)?i.gitmojis.filter(Mr):[];return Xa(m),Rt.forEach(N=>N(m)),m}catch(e){console.warn("Failed to load gitmoji list:",e);const i=[];return Rt.forEach(m=>m(i)),i}finally{Kt=null}})();return Kt=o,o},Za=o=>{const[e,i]=l.useState(()=>o?Es()?.gitmojis??[]:[]),[m,N]=l.useState(!1),f=l.useRef(o);f.current=o,l.useEffect(()=>{if(!o){Rt.delete(i),i([]),N(!1);return}const x=Es();if(x&&(i(x.gitmojis),wr(x)))return;Rt.add(i),N(!0);let g=!1;return yr().finally(()=>{!g&&f.current&&N(!1)}),()=>{g=!0,Rt.delete(i)}},[o]);const p=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const x=Es();return x&&wr(x)?x.gitmojis:yr()},[e]);return{gitmojis:e,isLoading:m,ensureLoaded:p}},Ct=async(o,e)=>{const i=await Wa(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok){const m=await i.json().catch(()=>null);throw new Error(m?.error||`Git integrate request failed: ${i.statusText}`)}return i.json()};async function Pt(o){return Ct("plan",o)}async function ei(o){return Ct("conflict-details",{tempWorktreePath:o})}async function ti(o){return(await Ct("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function si(o){return Ct("run",{plan:o})}async function ri(o){await Ct("abort",{state:o})}async function ni(o){return Ct("continue",{state:o})}const ai=({repoRoot:o,sourceBranch:e,worktreeMetadata:i,localBranches:m,defaultTargetBranch:N,refreshKey:f,onRefresh:p,showHeader:x=!0})=>{const{t:g}=nt(),w=rt(h=>h.currentSessionId),[E,b]=ve.useState(!1),[V,A]=ve.useState(""),S=ve.useRef(null),z=ve.useMemo(()=>Bt(m,V,h=>[h]),[m,V]),[C,y]=ve.useState(N);ve.useEffect(()=>{y(N)},[N]),ve.useEffect(()=>{if(E){const h=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(h)}},[E]);const D=!!(o&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=ve.useState({kind:"idle"}),[P,F]=ve.useState(!1),[r,Y]=ve.useState([]),B=ve.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);ve.useEffect(()=>{if(!B||typeof window>"u")return;const h=window.localStorage.getItem(B);if(!h)return;let d=!1;try{const I=JSON.parse(h);if(!I?.tempWorktreePath||I.repoRoot!==o){window.localStorage.removeItem(B);return}(async()=>{const O=await ti(I.tempWorktreePath).catch(()=>!1);if(d)return;if(!O){window.localStorage.removeItem(B);return}const q=await ei(I.tempWorktreePath).catch(()=>null);d||q&&R({kind:"conflict",state:I,details:q})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,o]),ve.useEffect(()=>{if(!D){R({kind:"idle"});return}let h=!1;return R({kind:"loading"}),(async()=>{try{const d=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C});if(h)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const O=d.commits.slice(-50).reverse(),q=await _n(o,O);h||(Y(q),F(!1))}else h||(Y([]),F(!1))}catch{h||R({kind:"idle"})}})(),()=>{h=!0}},[D,o,e,C,f]);const u=ve.useCallback(h=>{w&&rt.getState().setWorktreeMetadata(w,{...i,createdFromBranch:h})},[w,i]),M=rt(h=>h.openNewSessionDraft),te=ve.useCallback(async h=>{const d=await qt("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),I=await qt("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),O=`Cherry-pick conflict context (JSON)
|
|
2
|
+
${JSON.stringify({repoRoot:h.state.repoRoot,tempWorktreePath:h.state.tempWorktreePath,sourceBranch:h.state.sourceBranch,targetBranch:h.state.targetBranch,currentCommit:h.state.currentCommit,remainingCommits:h.state.remainingCommits,statusPorcelain:h.details.statusPorcelain,unmergedFiles:h.details.unmergedFiles,currentPatchMeta:h.details.currentPatchMeta,currentPatch:h.details.currentPatch,diff:h.details.diff},null,2)}`;return{visibleText:d,instructionsText:I,payloadText:O}},[]),U=Yt(h=>h.setPendingInputText),G=Yt(h=>h.setPendingSyntheticParts),_=ve.useCallback(async(h,d)=>{const I=await te(h);if(d){M({directoryOverride:h.state.tempWorktreePath,initialPrompt:I.visibleText,syntheticParts:[{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}]});return}if(!w){v.error(g("gitView.integrate.noActiveSession"),{description:g("gitView.integrate.noActiveSessionDescription")});return}U(I.visibleText,"replace"),G([{text:I.instructionsText,synthetic:!0},{text:I.payloadText,synthetic:!0}])},[w,te,M,U,G,g]),X=ve.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){v.message(g("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const h=await si(k.plan);if(h.kind==="success"){v.success(g("gitView.integrate.commitsMovedToast"),{description:h.moved===1?g("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:k.plan.targetBranch}):g("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:k.plan.targetBranch})});const d=await Pt(k.plan);R({kind:"ready",plan:d}),p?.();return}h.kind==="conflict"&&(v.error(g("gitView.integrate.cherryPickConflictToast"),{description:g("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);v.error(g("gitView.integrate.failedToMoveToast"),{description:d});const I=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(I?{kind:"ready",plan:I}:{kind:"idle"})}}},[k,p,o,e,C,B,g]),H=ve.useCallback(async()=>{if(k.kind==="conflict")try{await ri(k.state),v.message(g("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const h=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(h?{kind:"ready",plan:h}:{kind:"idle"})}},[k,o,e,C,B,g]),le=ve.useCallback(async()=>{if(k.kind==="conflict")try{const h=await ni(k.state);if(h.kind==="success"){v.success(g("gitView.integrate.cherryPickFinishedToast"));const d=await Pt({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),p?.();return}h.kind==="conflict"&&(R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);v.error(g("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,o,e,C,p,B,g]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[x?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(T,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g("gitView.integrate.toMoveCount",{count:k.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:k.kind==="loading"||k.kind==="running"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}):null,t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Ls,{open:E,onOpenChange:b,children:[t.jsx(As,{asChild:!0,children:t.jsxs("button",{type:"button",className:Rr({size:"default"}),children:[g("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Os,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(zs,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Gs,{ref:S,placeholder:g("gitView.branch.searchPlaceholder"),value:V,onValueChange:A,onKeyDown:h=>h.stopPropagation()}),t.jsxs(_s,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Hs,{children:g("gitView.branch.empty")}),t.jsx(Qt,{heading:g("gitView.branch.localBranches"),children:z.map(h=>t.jsx(Xt,{value:h,onSelect:()=>{y(h),u(h),b(!1),A("")},children:h},h))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{X()},disabled:!D||k.plan.commits.length===0,children:g("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.noCommitsToMove")}),k.kind==="ready"&&k.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[g("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",k.plan.commits.length,")"]})]}),r.length>0&&k.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>F(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:g(P?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(P?r:r.slice(0,5)).map(h=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:h.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h.subject||h.sha})]},h.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:g("gitView.integrate.showingFirstCommits",{count:r.length})})]})]}),k.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:g("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[g("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:k.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[k.details.unmergedFiles.slice(0,6).map(h=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:h},h)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:g("gitView.integrate.moreFiles",{count:k.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{H()},children:g("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{_({state:k.state,details:k.details},!1)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{_({state:k.state,details:k.details},!0)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{le()},children:g("gitView.operation.continue")})]})]})]})]})},ii=({open:o,onOpenChange:e,directory:i,hasUncommittedChanges:m,hasStagedChanges:N=!1,uncommittedFileCount:f,onChanged:p})=>{const{t:x}=nt(),[g,w]=l.useState([]),[E,b]=l.useState(!1),[V,A]=l.useState(""),[S,z]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(i){b(!0);try{const u=await Hn(i);w(u.stashes),k({})}catch(u){v.error(u instanceof Error?u.message:x("gitView.stashes.toast.loadFailed"))}finally{b(!1)}}},[i,x]);l.useEffect(()=>{o&&R()},[R,o]),l.useEffect(()=>{if(!o||!i||g.length===0)return;let u=!1;const M=g.map(te=>te.ref);return $n(i,M).then(te=>{u||k(te.counts)}).catch(()=>{}),()=>{u=!0}},[i,o,g]);const P=l.useMemo(()=>Bt(g,V,u=>[u.message,u.ref,u.relativeTime]),[V,g]),F=l.useCallback(async u=>{await R(),await p?.(u)},[R,p]),r=async()=>{if(!(!i||C)){y("create");try{const u=await Wn(i,{message:S.trim()||void 0});u.created?(v.success(x("gitView.stashes.toast.created")),z("")):v.info(x("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(u.created&&N)})}catch(u){v.error(u instanceof Error?u.message:x("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(u,M)=>{if(!(!i||C)&&!(M==="drop"&&!window.confirm(x("gitView.stashes.confirm.drop",{ref:u.ref})))){y(`${M}:${u.ref}`);try{M==="apply"&&await Un(i,{ref:u.ref}),M==="pop"&&await Kn(i,{ref:u.ref}),M==="drop"&&await Jn(i,{ref:u.ref});const te=M==="apply"?"gitView.stashes.toast.applySuccess":M==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";v.success(x(te)),await F({affectsIndex:M!=="drop"})}catch(te){const U=M==="apply"?"gitView.stashes.toast.applyFailed":M==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";v.error(te instanceof Error?te.message:x(U)),await F({affectsIndex:M!=="drop"})}finally{y(null)}}},B=C!==null;return t.jsx(mt,{open:o,onOpenChange:e,children:t.jsxs(ht,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(gt,{children:[t.jsxs(ft,{className:"flex items-center gap-2",children:[t.jsx(T,{name:"archive-stack",className:"h-5 w-5"}),x("gitView.stashes.title")]}),t.jsx(bt,{children:x("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(gr,{value:S,onChange:u=>z(u.target.value),placeholder:x("gitView.stashes.messagePlaceholder"),disabled:B||!m,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!m||B||!i,children:[C==="create"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"inbox-archive",className:"size-4"}),x("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:x("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(T,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gr,{value:V,onChange:u=>A(u.target.value),placeholder:x("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:E?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(T,{name:"loader-4",className:"size-5 animate-spin"})}):P.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:x(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):P.map((u,M)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:u.message||x("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Zt,{children:[t.jsx(es,{asChild:!0,children:t.jsx("span",{children:M===0&&!V.trim()?x("gitView.stashes.latestLabel"):x("gitView.stashes.itemNumber",{number:M+1})})}),t.jsx(ts,{sideOffset:6,children:u.ref})]})," · ",u.relativeTime," · ",typeof D[u.ref]=="number"?x("gitView.stashes.fileCount",{count:D[u.ref]}):x("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ms,{label:x("gitView.stashes.actions.apply"),loading:C===`apply:${u.ref}`,onClick:()=>Y(u,"apply"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.pop"),loading:C===`pop:${u.ref}`,onClick:()=>Y(u,"pop"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.drop"),loading:C===`drop:${u.ref}`,onClick:()=>Y(u,"drop"),disabled:B,destructive:!0,children:t.jsx(T,{name:"delete-bin",className:"size-4"})})]})]},u.ref))})]})})},Ms=o=>{const e=jt.c(17),{label:i,loading:m,disabled:N,destructive:f,onClick:p,children:x}=o,g=m||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let E;e[0]!==w?(E=Se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=E):E=e[1];let b;e[2]!==x||e[3]!==m?(b=m?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):x,e[2]=x,e[3]=m,e[4]=b):b=e[4];let V;e[5]!==N||e[6]!==i||e[7]!==p||e[8]!==g||e[9]!==E||e[10]!==b?(V=t.jsx(es,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":i,"aria-busy":g,className:E,onClick:p,disabled:N,children:b})}),e[5]=N,e[6]=i,e[7]=p,e[8]=g,e[9]=E,e[10]=b,e[11]=V):V=e[11];let A;e[12]!==i?(A=t.jsx(ts,{sideOffset:6,children:i}),e[12]=i,e[13]=A):A=e[13];let S;return e[14]!==V||e[15]!==A?(S=t.jsxs(Zt,{children:[V,A]}),e[14]=V,e[15]=A,e[16]=S):S=e[16],S},oi=o=>{const e=jt.c(16),{onOpenStashes:i}=o,{t:m}=nt();let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(T,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=N):N=e[0];let f;e[1]!==m?(f=m("gitView.empty.cleanTitle"),e[1]=m,e[2]=f):f=e[2];let p;e[3]!==f?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=p):p=e[4];let x;e[5]!==m?(x=m("gitView.empty.cleanDescription"),e[5]=m,e[6]=x):x=e[6];let g;e[7]!==x?(g=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:x}),e[7]=x,e[8]=g):g=e[8];let w;e[9]!==i||e[10]!==m?(w=i?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:i,className:"gap-1.5",children:[t.jsx(T,{name:"archive-stack",className:"size-4"}),m("gitView.stashes.title")]}):null,e[9]=i,e[10]=m,e[11]=w):w=e[11];let E;return e[12]!==p||e[13]!==g||e[14]!==w?(E=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[N,p,g,w]}),e[12]=p,e[13]=g,e[14]=w,e[15]=E):E=e[15],E},ut=8,li=o=>{const e=jt.c(18),{laned:i,totalLanes:m,isExpanded:N}=o,{lane:f,color:p,connectors:x}=i,w=Math.max(m,f+1)*ut+ut/2,E=l.useRef(null),b=l.useRef(null);let V;e[0]!==p||e[1]!==x||e[2]!==f||e[3]!==w?(V=()=>{const y=E.current,D=b.current;if(!y||!D)return;const k=y.offsetHeight;if(k===0)return;const R=window.devicePixelRatio||1;D.width=w*R,D.height=k*R;const P=D.getContext("2d");if(!P)return;P.scale(R,R),P.clearRect(0,0,w,k);const F=k/2,r=f*ut+ut/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,u=U=>{if(!U.startsWith("var("))return U;const G=U.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},M=[...x].sort(di);for(const U of M){const G=U.fromLane*ut+ut/2,_=U.toLane*ut+ut/2,X=U.type==="passing"?.72:U.type==="branch-out"||U.type==="merge-in"?.95:1;P.beginPath(),P.strokeStyle=u(U.color),P.globalAlpha=X,P.lineWidth=1.25,P.lineCap="round";e:switch(U.type){case"passing":case"commit-lane":{P.moveTo(G,0),P.lineTo(G,k);break e}case"top-stub":{P.moveTo(G,0),P.lineTo(G,F);break e}case"bottom-stub":{P.moveTo(G,F),P.lineTo(G,k);break e}case"branch-out":{const H=(F+k)/2;P.moveTo(r,F),P.bezierCurveTo(r,H,_,H,_,k);break e}case"merge-in":{const H=F/2;P.moveTo(G,0),P.bezierCurveTo(G,H,r,H,r,F);break e}default:continue}P.stroke(),P.globalAlpha=1}const te=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();P.beginPath(),P.arc(r,F,4,0,Math.PI*2),P.fillStyle=u(p),P.fill(),P.beginPath(),P.arc(r,F,5,0,Math.PI*2),P.strokeStyle=te||B,P.lineWidth=2,P.stroke()},e[0]=p,e[1]=x,e[2]=f,e[3]=w,e[4]=V):V=e[4];let A;e[5]!==p||e[6]!==x||e[7]!==N||e[8]!==f||e[9]!==i||e[10]!==m||e[11]!==w?(A=[i,f,p,x,m,N,w],e[5]=p,e[6]=x,e[7]=N,e[8]=f,e[9]=i,e[10]=m,e[11]=w,e[12]=A):A=e[12],l.useLayoutEffect(V,A);let S;e[13]!==w?(S={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=S):S=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("canvas",{ref:b,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=z):z=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:E,style:S,children:z}),e[16]=S,e[17]=C):C=e[17],C};function ci(o){return o==="branch-out"||o==="merge-in"}function di(o,e){const i=ci;return(i(o.type)?1:0)-(i(e.type)?1:0)}const br=15e3,vr=500,jr=12,Cr=8*1024*1024,Nr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),Sr=o=>{if(o.size<=jr){let N=0;for(const f of o.values())N+=Nr(f);if(N<=Cr)return o}const e=Array.from(o.entries()).reverse(),i=new Map;let m=0;for(const[N,f]of e){if(i.size>=jr)continue;const p=Nr(f);m+p>Cr&&i.size>0||(i.set(N,f),m+=p)}return new Map(Array.from(i.entries()).reverse())};function kr(o,e){const i=new Date(o);return Number.isNaN(i.getTime())?o:Xn(i,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ui(o){switch(o){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 mi(o){return o?o.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const i=e.startsWith("HEAD ->");return{label:i?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:i,isTag:e.startsWith("tag: ")}}):[]}const hi=l.memo(({entry:o,mode:e="history",laned:i,totalLanes:m,isExpanded:N,onToggle:f,files:p,isLoadingFiles:x,onCopyHash:g,directory:w,onConflict:E,onActionSuccess:b})=>{const{t:V}=nt(),A=Ft(d=>d.timeFormatPreference),S=e==="graph",[z,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[P,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,u]=l.useState(new Map),[M,te]=l.useState(new Set),U=async()=>{if(w){C("checkout");try{await aa(w,o.hash),v.success(V("gitView.history.actions.detachedHead")),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Zn(w,k.trim(),o.hash),D(!1),R(""),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},_=async()=>{if(w){C("cherryPick");try{const d=await na(w,o.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},X=async()=>{if(w){C("revert");try{const d=await ra(w,o.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},H=async(d,I=!1)=>{if(!(!w||z!==null)){C("reset");try{await ea(w,o.hash,d,I),b?.()}catch(O){v.error(String(O.message))}finally{C(null)}}},le=async()=>{if(!P)return;const d=P;switch(F(null),d){case"checkout":return U();case"cherryPick":return _();case"revert":return X();case"merge":return ae();case"rebase":return ce();case"resetSoft":return H("soft");case"resetMixed":return H("mixed");case"resetHard":return H("hard",!0)}},ae=async()=>{if(w){C("merge");try{const d=await sa(w,{branch:o.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},ce=async()=>{if(w){C("rebase");try{const d=await ta(w,{onto:o.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},ie=l.useCallback(async d=>{const I=d.path;if(!w){u(O=>new Map(O).set(I,"error"));return}u(O=>Sr(new Map(O).set(I,"loading")));try{const O=qn(w,o.hash,d.path,!1),q=new Promise((se,J)=>{setTimeout(()=>J(new Error(`Timed out after ${br}ms`)),br)}),ne=await Promise.race([O,q]);u(se=>Sr(new Map(se).set(I,ne)))}catch{u(O=>new Map(O).set(I,"error"))}},[w,o.hash]),h=l.useCallback(async d=>{const I=d.path;if(d.changeType==="R"||d.isBinary){Y(se=>{const J=new Set(se);return J.has(I)?J.delete(I):J.add(I),J});return}const O=B.get(I);if(r.has(I)&&O&&O!=="error"){Y(se=>{const J=new Set(se);return J.delete(I),J});return}Y(se=>{const J=new Set(se);return J.add(I),J}),!(O&&O!=="error"||d.insertions+d.deletions>vr&&!M.has(I))&&await ie(d)},[B,M,ie,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":N?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&i&&m!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(li,{laned:i,totalLanes:m,isExpanded:N})}):t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[S?(()=>{const d=mi(o.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(I=>t.jsx("span",{className:Se("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",I.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":I.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:I.label},I.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:o.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:o.author_name,children:o.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:kr(o.date,A),children:kr(o.date,A)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(Zt,{children:[t.jsx(es,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),g(o.hash)},children:t.jsx(T,{name:"file-copy",className:"size-3"})})}),t.jsx(ts,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),N&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&P?t.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:V(`gitView.history.actions.${P}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),le()},children:[z!==null?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),F(null)},children:V("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("checkout")},children:V("gitView.history.actions.checkout")}),y?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:k,onChange:d=>R(d.target.value),onKeyDown:d=>{d.key==="Enter"&&G(),d.key==="Escape"&&(D(!1),R(""))},placeholder:V("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!k.trim()||z!==null,onClick:d=>{d.stopPropagation(),G()},children:[z==="createBranch"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:d=>{d.stopPropagation(),D(!0)},children:V("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Ls,{children:[t.jsx(As,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>d.stopPropagation(),children:[z==="reset"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(Os,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(Yn,{disabled:z!==null,onSelect:I=>{I.stopPropagation(),F(`reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},children:V(`gitView.history.actions.reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},d))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,x?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:V("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:V("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>h(d),className:Se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",r.has(d.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Se("font-semibold w-3 text-center shrink-0",ui(d.changeType)),children:d.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:d.path,children:d.path}),!d.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d.deletions]})]}),d.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:V("gitView.history.binary")}),t.jsx(T,{name:r.has(d.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),r.has(d.path)&&t.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:d.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.renamedNoDiff")}):d.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.binaryNoDiff")}):(()=>{const I=d.insertions+d.deletions;if(!M.has(d.path)&&I>vr)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:V("gitView.history.largeDiffTitle",{count:I})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:V("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{te(q=>new Set(q).add(d.path)),ie(d)},children:V("gitView.history.renderDiffAnyway")})]});const O=B.get(d.path);return O==="loading"||O===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):O==="error"?t.jsx("button",{type:"button",onClick:()=>h(d),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:V("gitView.history.diffError")}):t.jsx(qa,{original:O.original,modified:O.modified,language:Qn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),Vr=["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 Jt(o){return Vr[o%Vr.length]}function gi(o){if(o.length===0)return[];const e=[],i=[];for(let m=0;m<o.length;m++){const N=o[m],f=[];for(let S=0;S<e.length;S++)e[S]===N.hash&&f.push(S);let p=f.length>0?f[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const x=f.slice(1),g=Jt(p),w=e[p]===N.hash,E=N.parents.length>0;E?e[p]=N.parents[0]:e[p]=null;const b=[],V=new Set;for(let S=1;S<N.parents.length;S++){const z=N.parents[S],C=e.indexOf(z);if(C!==-1)b.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=z,b.push(y),V.add(y);else{const D=e.length;e.push(z),b.push(D),V.add(D)}}}const A=[];w&&E?A.push({fromLane:p,toLane:p,color:g,type:"commit-lane"}):w&&!E?A.push({fromLane:p,toLane:p,color:g,type:"top-stub"}):!w&&E&&A.push({fromLane:p,toLane:p,color:g,type:"bottom-stub"});for(const S of x)A.push({fromLane:S,toLane:p,color:Jt(S),type:"merge-in"}),e[S]=null;for(const S of b)A.push({fromLane:p,toLane:S,color:Jt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(V.has(S)||A.push({fromLane:S,toLane:S,color:Jt(S),type:"passing"}));i.push({commit:N,lane:p,color:g,connectors:A})}return i}const fi=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],pi=o=>{const e=jt.c(84),{mode:i,log:m,isLogLoading:N,logMaxCount:f,onLogMaxCountChange:p,expandedCommitHashes:x,onToggleCommit:g,commitFilesMap:w,loadingCommitHashes:E,onCopyHash:b,directory:V,showHeader:A,contentMaxHeightClassName:S,branchDivider:z,onConflict:C,onActionSuccess:y}=o,D=i===void 0?"history":i,k=A===void 0?!0:A,R=S===void 0?"max-h-[50vh]":S,P=z===void 0?null:z,{t:F}=nt(),[r,Y]=l.useState(!0),B=D==="graph";let u;e[0]!==B||e[1]!==m?(u=B&&m?gi(m.all):[],e[0]=B,e[1]=m,e[2]=u):u=e[2];const M=u;let te;e[3]!==M?(te=Math.max(1,...M.map(xi)),e[3]=M,e[4]=te):te=e[4];const U=te;let G;e[5]!==M?(G=new Map(M.map(wi)),e[5]=M,e[6]=G):G=e[6];const _=G;if(!m)return null;const X=P!==null&&P.insertBeforeIndex>0&&P.insertBeforeIndex<m.all.length,H=P!==null&&P.insertBeforeIndex===m.all.length,le=X||H;let ae;e[7]!==P||e[8]!==X||e[9]!==H||e[10]!==m.all?(ae=X?m.all.slice(0,P.insertBeforeIndex):H?m.all:[],e[7]=P,e[8]=X,e[9]=H,e[10]=m.all,e[11]=ae):ae=e[11];const ce=ae;let ie;if(e[12]!==P||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==x||e[17]!==X||e[18]!==le||e[19]!==B||e[20]!==N||e[21]!==_||e[22]!==E||e[23]!==m.all||e[24]!==f||e[25]!==U||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==b||e[30]!==p||e[31]!==g||e[32]!==F||e[33]!==ce){const K=X?m.all.slice(P.insertBeforeIndex):[];let de;e[35]!==P?.direction?(de=P?.direction==="down"?t.jsx(T,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(T,{name:"arrow-up",className:"size-3.5"}),e[35]=P?.direction,e[36]=de):de=e[36];const ke=de;let ye;e[37]!==w||e[38]!==V||e[39]!==x||e[40]!==B||e[41]!==_||e[42]!==E||e[43]!==U||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==b||e[48]!==g?(ye=Re=>t.jsx("ul",{className:"divide-y divide-border/60",children:Re.map(ue=>t.jsx(hi,{entry:ue,mode:D,laned:B?_.get(ue.hash):void 0,totalLanes:B?U:void 0,isExpanded:x.has(ue.hash),onToggle:()=>g(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:E.has(ue.hash),onCopyHash:b,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=x,e[40]=B,e[41]=_,e[42]=E,e[43]=U,e[44]=D,e[45]=y,e[46]=C,e[47]=b,e[48]=g,e[49]=ye):ye=e[49];const me=ye;let xe;e[50]!==N||e[51]!==m.all.length||e[52]!==f||e[53]!==p||e[54]!==F?(xe=m.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(f+25),disabled:N,className:"px-3 text-muted-foreground hover:text-foreground",children:N?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=N,e[51]=m.all.length,e[52]=f,e[53]=p,e[54]=F,e[55]=xe):xe=e[55];const Ve=xe;ie=t.jsx(Br,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:m.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:F("gitView.history.noCommits")})}):le&&P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(ce)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:P.branchName,children:P.branchName}),ke]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),K.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(K)}):null]}),Ve]}):t.jsxs(t.Fragment,{children:[me(m.all),Ve]})}),e[12]=P,e[13]=w,e[14]=R,e[15]=V,e[16]=x,e[17]=X,e[18]=le,e[19]=B,e[20]=N,e[21]=_,e[22]=E,e[23]=m.all,e[24]=f,e[25]=U,e[26]=D,e[27]=y,e[28]=C,e[29]=b,e[30]=p,e[31]=g,e[32]=F,e[33]=ce,e[34]=ie}else ie=e[34];const h=ie;if(!k){if(le){let de;return e[56]!==h?(de=t.jsx("section",{className:"h-full min-h-0",children:h}),e[56]=h,e[57]=de):de=e[57],de}let K;return e[58]!==h?(K=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:h}),e[58]=h,e[59]=K):K=e[59],K}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let I;e[62]!==d?(I=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=I):I=e[63];let O;e[64]!==N||e[65]!==r||e[66]!==f||e[67]!==p||e[68]!==F?(O=r&&t.jsx("div",{onClick:yi,onPointerDown:bi,children:t.jsxs(ia,{value:String(f),onValueChange:K=>p(Number(K)),disabled:N,children:[t.jsx(oa,{size:"sm",className:"w-auto",disabled:N,children:t.jsx(la,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ca,{children:fi.map(K=>t.jsx(da,{value:String(K.value),children:F(K.labelKey)},K.value))})]})}),e[64]=N,e[65]=r,e[66]=f,e[67]=p,e[68]=F,e[69]=O):O=e[69];let q;e[70]!==r?(q=r?t.jsx(T,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(T,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=q):q=e[71];let ne;e[72]!==O||e[73]!==q?(ne=t.jsxs("div",{className:"flex items-center gap-2",children:[O,q]}),e[72]=O,e[73]=q,e[74]=ne):ne=e[74];let se;e[75]!==I||e[76]!==ne?(se=t.jsxs(ua,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[I,ne]}),e[75]=I,e[76]=ne,e[77]=se):se=e[77];let J;e[78]!==h?(J=t.jsx(ma,{children:h}),e[78]=h,e[79]=J):J=e[79];let we;return e[80]!==r||e[81]!==se||e[82]!==J?(we=t.jsxs(ha,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[se,J]}),e[80]=r,e[81]=se,e[82]=J,e[83]=we):we=e[83],we};function xi(o){return o.lane+1}function wi(o){return[o.commit.hash,o]}function yi(o){return o.stopPropagation()}function bi(o){return o.stopPropagation()}const vi=o=>{const e=jt.c(148),{open:i,onOpenChange:m,conflictFiles:N,directory:f,operation:p,onAbort:x,onClearState:g}=o;let w;e[0]!==N?(w=N===void 0?[]:N,e[0]=N,e[1]=w):w=e[1];const E=w,{t:b}=nt(),V=rt(ji),A=rt(Ci),S=Yt(Ni),z=Yt(Si),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,P]=l.useState(null);let F,r;e[2]!==f||e[3]!==i||e[4]!==b?(F=()=>{!i||!f||(y(!0),P(null),k(null),ga(f).then(ee=>{k(ee)}).catch(ee=>{const he=ee instanceof Error?ee.message:b("gitView.conflict.loadFailed");P(he)}).finally(()=>{y(!1)}))},r=[i,f,b],e[2]=f,e[3]=i,e[4]=b,e[5]=F,e[6]=r):(F=e[5],r=e[6]),l.useEffect(F,r);let Y;e[7]!==D||e[8]!==f||e[9]!==p?(Y=async()=>{if(!D)return null;const ee=p==="merge"?"merge":"rebase",he=D.headInfo||(p==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Be=p==="merge"?"git commit --no-edit":"git rebase --continue",ge=await qt("git.conflict.resolve.visible",{operation_label:ee,head_ref:he}),Ne=await qt("git.conflict.resolve.instructions",{operation_label:ee,directory:f,operation:p,head_info:D.headInfo||"N/A",continue_cmd:Be}),Ie=`${ee} conflict context (JSON)
|
|
3
|
+
${JSON.stringify({directory:f,operation:D.operation,headInfo:D.headInfo,statusPorcelain:D.statusPorcelain,unmergedFiles:D.unmergedFiles,diff:D.diff},null,2)}`;return{visibleText:ge,instructionsText:Ne,payloadText:Ie}},e[7]=D,e[8]=f,e[9]=p,e[10]=Y):Y=e[10];const B=Y;let u;e[11]!==x||e[12]!==m?(u=()=>{x(),m(!1)},e[11]=x,e[12]=m,e[13]=u):u=e[13];const M=u;let te;e[14]!==g||e[15]!==m?(te=()=>{g?.(),m(!1)},e[14]=g,e[15]=m,e[16]=te):te=e[16];const U=te;let G;e[17]!==B||e[18]!==A||e[19]!==g||e[20]!==m||e[21]!==S||e[22]!==z||e[23]!==b?(G=async()=>{const ee=await B();if(!ee){v.error(b("gitView.conflict.noDetailsAvailable"));return}if(!A){v.error(b("gitView.conflict.noActiveSession"),{description:b("gitView.conflict.noActiveSessionDescription")});return}S(ee.visibleText,"replace"),z([{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]),g?.(),m(!1)},e[17]=B,e[18]=A,e[19]=g,e[20]=m,e[21]=S,e[22]=z,e[23]=b,e[24]=G):G=e[24];const _=G;let X;e[25]!==B||e[26]!==f||e[27]!==g||e[28]!==m||e[29]!==V||e[30]!==b?(X=async()=>{const ee=await B();if(!ee){v.error(b("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:ee.visibleText,syntheticParts:[{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]}),g?.(),m(!1)},e[25]=B,e[26]=f,e[27]=g,e[28]=m,e[29]=V,e[30]=b,e[31]=X):X=e[31];const H=X;let le,ae,ce,ie,h,d,I,O,q,ne,se,J,we,K,de,ke,ye,me,xe,Ve,Re,ue;if(e[32]!==D||e[33]!==E||e[34]!==A||e[35]!==M||e[36]!==U||e[37]!==_||e[38]!==H||e[39]!==C||e[40]!==R||e[41]!==m||e[42]!==i||e[43]!==p||e[44]!==b){const ee=b(p==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),he=D?.unmergedFiles||E;ce=mt,Re=i,ue=m,ae=ht,Ve="max-w-md w-[calc(100vw-2rem)]",K="flex flex-col gap-4 overflow-hidden";let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx(T,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Be):Be=e[67];const ge=t.jsxs("div",{className:"flex items-center gap-2",children:[Be,t.jsx(ft,{children:b("gitView.conflict.detectedTitle",{operation:ee})})]});let Ne;e[68]!==p||e[69]!==b?(Ne=b("gitView.conflict.detectedDescription",{operation:p}),e[68]=p,e[69]=b,e[70]=Ne):Ne=e[70];let Ie;e[71]!==Ne?(Ie=t.jsx(bt,{children:Ne}),e[71]=Ne,e[72]=Ie):Ie=e[72],e[73]!==ge||e[74]!==Ie?(de=t.jsxs(gt,{children:[ge,Ie]}),e[73]=ge,e[74]=Ie,e[75]=de):de=e[75],e[76]!==C||e[77]!==b?(ke=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:b("gitView.conflict.loading")})]}),e[76]=C,e[77]=b,e[78]=ke):ke=e[78],e[79]!==R||e[80]!==b?(ye=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:b("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=b,e[81]=ye):ye=e[81],e[82]!==he||e[83]!==b?(me=he.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:he.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:he.map(ki)})})]}),e[82]=he,e[83]=b,e[84]=me):me=e[84],e[85]!==D||e[86]!==b?(xe=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.headInfo")}),t.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[85]=D,e[86]=b,e[87]=xe):xe=e[87],se="flex flex-col gap-2 pt-2";let Te;e[88]!==H?(Te=()=>{H()},e[88]=H,e[89]=Te):Te=e[89];const oe=C||!D;let Pe;e[90]!==C?(Pe=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"add",className:"size-4"}),e[90]=C,e[91]=Pe):Pe=e[91];let Fe;e[92]!==b?(Fe=b("gitView.conflict.resolveNewSession"),e[92]=b,e[93]=Fe):Fe=e[93],e[94]!==Te||e[95]!==oe||e[96]!==Pe||e[97]!==Fe?(J=t.jsxs(W,{variant:"default",onClick:Te,disabled:oe,className:"w-full gap-2",children:[Pe,Fe]}),e[94]=Te,e[95]=oe,e[96]=Pe,e[97]=Fe,e[98]=J):J=e[98];let De;e[99]!==_?(De=()=>{_()},e[99]=_,e[100]=De):De=e[100];const We=C||!D||!A;let Le;e[101]!==C?(Le=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Le):Le=e[102];let Q;e[103]!==b?(Q=b("gitView.conflict.resolveCurrentSession"),e[103]=b,e[104]=Q):Q=e[104],e[105]!==De||e[106]!==We||e[107]!==Le||e[108]!==Q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:We,className:"w-full gap-2",children:[Le,Q]}),e[105]=De,e[106]=We,e[107]=Le,e[108]=Q,e[109]=we):we=e[109],q="flex gap-2 pt-1";let fe;e[110]!==b?(fe=b("gitView.conflict.continueLater"),e[110]=b,e[111]=fe):fe=e[111],e[112]!==U||e[113]!==fe?(ne=t.jsx(W,{variant:"ghost",size:"sm",onClick:U,className:"flex-1",children:fe}),e[112]=U,e[113]=fe,e[114]=ne):ne=e[114],le=W,ie="destructive",h="sm",d=M,I="flex-1",O=b("gitView.conflict.abortOperation",{operation:ee}),e[32]=D,e[33]=E,e[34]=A,e[35]=M,e[36]=U,e[37]=_,e[38]=H,e[39]=C,e[40]=R,e[41]=m,e[42]=i,e[43]=p,e[44]=b,e[45]=le,e[46]=ae,e[47]=ce,e[48]=ie,e[49]=h,e[50]=d,e[51]=I,e[52]=O,e[53]=q,e[54]=ne,e[55]=se,e[56]=J,e[57]=we,e[58]=K,e[59]=de,e[60]=ke,e[61]=ye,e[62]=me,e[63]=xe,e[64]=Ve,e[65]=Re,e[66]=ue}else le=e[45],ae=e[46],ce=e[47],ie=e[48],h=e[49],d=e[50],I=e[51],O=e[52],q=e[53],ne=e[54],se=e[55],J=e[56],we=e[57],K=e[58],de=e[59],ke=e[60],ye=e[61],me=e[62],xe=e[63],Ve=e[64],Re=e[65],ue=e[66];let _e;e[115]!==le||e[116]!==ie||e[117]!==h||e[118]!==d||e[119]!==I||e[120]!==O?(_e=t.jsx(le,{variant:ie,size:h,onClick:d,className:I,children:O}),e[115]=le,e[116]=ie,e[117]=h,e[118]=d,e[119]=I,e[120]=O,e[121]=_e):_e=e[121];let Oe;e[122]!==q||e[123]!==ne||e[124]!==_e?(Oe=t.jsxs("div",{className:q,children:[ne,_e]}),e[122]=q,e[123]=ne,e[124]=_e,e[125]=Oe):Oe=e[125];let je;e[126]!==se||e[127]!==J||e[128]!==we||e[129]!==Oe?(je=t.jsxs("div",{className:se,children:[J,we,Oe]}),e[126]=se,e[127]=J,e[128]=we,e[129]=Oe,e[130]=je):je=e[130];let be;e[131]!==K||e[132]!==de||e[133]!==ke||e[134]!==ye||e[135]!==me||e[136]!==xe||e[137]!==je?(be=t.jsxs("div",{className:K,children:[de,ke,ye,me,xe,je]}),e[131]=K,e[132]=de,e[133]=ke,e[134]=ye,e[135]=me,e[136]=xe,e[137]=je,e[138]=be):be=e[138];let Ce;e[139]!==ae||e[140]!==Ve||e[141]!==be?(Ce=t.jsx(ae,{className:Ve,children:be}),e[139]=ae,e[140]=Ve,e[141]=be,e[142]=Ce):Ce=e[142];let Me;return e[143]!==ce||e[144]!==Re||e[145]!==ue||e[146]!==Ce?(Me=t.jsx(ce,{open:Re,onOpenChange:ue,children:Ce}),e[143]=ce,e[144]=Re,e[145]=ue,e[146]=Ce,e[147]=Me):Me=e[147],Me};function ji(o){return o.openNewSessionDraft}function Ci(o){return o.currentSessionId}function Ni(o){return o.setPendingInputText}function Si(o){return o.setPendingSyntheticParts}function ki(o){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:o,children:o},o)}const Vi=({open:o,onOpenChange:e,operation:i,targetBranch:m,onConfirm:N})=>{const{t:f}=nt(),[p,x]=l.useState(!0),[g,w]=l.useState(!1),E=f(i==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),b=async()=>{w(!0);try{await N(p),e(!1)}catch(A){const S=A instanceof Error?A.message:`Failed to ${i}`;v.error(S)}finally{w(!1)}},V=()=>{g||e(!1)};return t.jsx(mt,{open:o,onOpenChange:g?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(ft,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:i})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(i==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(i==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:m})]}),p&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(fa,{checked:p,onChange:x,disabled:g,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!g&&x(!p),children:f("gitView.stash.restoreAfterOperation",{operation:i})})]}),t.jsxs(Ts,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:g,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:b,disabled:g,className:"gap-1.5",children:g?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:E})})]})]})})},Ii=({mergeInProgress:o,rebaseInProgress:e,onContinue:i,onAbort:m,onResolveWithAI:N,conflictCount:f=0,isLoading:p=!1})=>{const{t:x}=nt(),[g,w]=l.useState(null),E=o&&o.head,b=e&&(e.headName||e.onto),V=E?"merge":b?"rebase":null;if(!V)return null;const A=async()=>{w("continue");try{await i()}finally{w(null)}},S=async()=>{w("abort");try{await m()}finally{w(null)}},z=g!==null,C=f>0,y=x(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";o?D=o.message?x("gitView.operation.mergingMessage",{message:o.message}):x("gitView.operation.mergeInProgressWithHead",{head:o.head}):e&&(D=e.headName?x("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):x("gitView.operation.rebaseInProgress"));const k=C?f===1?x("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):x("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):x("gitView.operation.inProgressTitle",{operation:y}),R=x(C?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:k}),D&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:R}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:S,disabled:z||p,className:"gap-1.5",children:[g==="abort"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"close",className:"size-4"}),x("gitView.operation.abort")]}),C?N&&t.jsx(W,{variant:"default",size:"sm",onClick:N,disabled:z||p,children:x("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:A,disabled:z||p,className:"gap-1.5",children:[g==="continue"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"check",className:"size-4"}),x("gitView.operation.continue")]})]})]})]})})},Pi=o=>{const e=jt.c(104),{currentBranch:i,localBranches:m,remoteBranches:N,onMerge:f,onRebase:p,disabled:x,isOperating:g,operationLogs:w,onOperationComplete:E,mode:b,defaultTargetBranch:V}=o,A=x===void 0?!1:x,S=g===void 0?!1:g,z=w===void 0?[]:w,C=b===void 0?"dialog":b,{t:y}=nt(),[D,k]=l.useState(!1),[R,P]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[u,M]=l.useState(""),te=l.useRef(null),U=l.useRef(null),G=A||S,_=i||y("gitView.branch.currentBranchFallback"),X=z.length>0&&z.every(Fi),H=z.some(Ri);let le;e[0]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},e[0]=le):le=e[0],l.useEffect(le,[z]);let ae;e[1]!==N?(ae=new Set(N.map(Bi).filter(Boolean)),e[1]=N,e[2]=ae):ae=e[2];const ce=ae;let ie;if(e[3]!==u||e[4]!==i||e[5]!==m||e[6]!==ce){let Q;e[8]!==i||e[9]!==ce?(Q=Ae=>Ae!==i&&!ce.has(Ae),e[8]=i,e[9]=ce,e[10]=Q):Q=e[10];const fe=m.filter(Q);ie=Bt(fe,u,Di),e[3]=u,e[4]=i,e[5]=m,e[6]=ce,e[7]=ie}else ie=e[7];const h=ie;let d;e[11]!==u||e[12]!==N?(d=Bt(N,u,Ei),e[11]=u,e[12]=N,e[13]=d):d=e[13];const I=d;let O;e[14]!==V||e[15]!==m||e[16]!==N?(O=()=>V&&(N.includes(V)||m.includes(V))?V:null,e[14]=V,e[15]=m,e[16]=N,e[17]=O):O=e[17];const q=O;let ne;e[18]!==q||e[19]!==k?(ne=()=>{k(!0),r(q()),P("merge"),M("")},e[18]=q,e[19]=k,e[20]=ne):ne=e[20];const se=ne;let J;e[21]===Symbol.for("react.memo_cache_sentinel")?(J=Q=>{r(Q),B(!1),M("")},e[21]=J):J=e[21];const we=J;let K;e[22]!==f||e[23]!==p||e[24]!==R||e[25]!==F?(K=()=>{F&&(R==="merge"?f(F):p(F))},e[22]=f,e[23]=p,e[24]=R,e[25]=F,e[26]=K):K=e[26];const de=K;let ke;e[27]!==S||e[28]!==k?(ke=()=>{S||(r(null),P("merge"),M(""),k(!1))},e[27]=S,e[28]=k,e[29]=ke):ke=e[29];const ye=ke,me=()=>{S&&!X||(X&&E?.(),r(null),P("merge"),M(""),k(!1))};let xe,Ve;e[30]!==Y?(xe=()=>{Y||M("")},Ve=[Y],e[30]=Y,e[31]=xe,e[32]=Ve):(xe=e[31],Ve=e[32]),l.useEffect(xe,Ve);let Re,ue;e[33]!==C||e[34]!==q||e[35]!==F?(Re=()=>{C==="dialog"||F||r(q())},ue=[C,q,F],e[33]=C,e[34]=q,e[35]=F,e[36]=Re,e[37]=ue):(Re=e[36],ue=e[37]),l.useEffect(Re,ue);const je=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:U,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:z.map(Mi)})}),X?C==="dialog"?t.jsx(Ts,{children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>P("merge"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="merge"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-merge",className:Se("size-4",R==="merge"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="merge"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>P("rebase"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="rebase"?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-branch",className:Se("size-4",R==="rebase"?"text-inherit":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="rebase"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?y("gitView.branch.branchToMergeInto",{branch:_}):y("gitView.branch.branchToRebaseOnto")}),t.jsxs(Ls,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(As,{asChild:!0,children:t.jsxs("button",{type:"button",className:Se(Rr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Se("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Os,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(zs,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Gs,{ref:te,placeholder:y("gitView.branch.searchPlaceholder"),value:u,onValueChange:M,onKeyDown:Ti}),t.jsxs(_s,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Hs,{children:y("gitView.branch.empty")}),h.length>0&&t.jsx(Qt,{heading:y("gitView.branch.localBranches"),children:h.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`local-${Q}`))}),h.length>0&&I.length>0?t.jsx(pa,{}):null,I.length>0&&t.jsx(Qt,{heading:y("gitView.branch.remoteBranches"),children:I.map(Q=>t.jsx(Xt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`remote-${Q}`))})]})]})})]})]}),F?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})," ",y("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})]}):t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})," ",y("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})]})})}):null,C==="dialog"?t.jsxs(Ts,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ye,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-branch",className:"size-4"}),y("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:ye,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return je;if(C==="inline"){let Q;e[38]!==y?(Q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=Q):Q=e[39];let fe;e[40]!==Q?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:Q}),e[40]=Q,e[41]=fe):fe=e[41];let Ae;e[42]!==y?(Ae=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Ae):Ae=e[43];let et;e[44]!==_?(et=t.jsx("span",{className:"font-mono text-foreground",children:_}),e[44]=_,e[45]=et):et=e[45];let He;e[46]!==Ae||e[47]!==et?(He=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Ae," ",et,"."]}),e[46]=Ae,e[47]=et,e[48]=He):He=e[48];let Ue;e[49]!==fe||e[50]!==He?(Ue=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,He]})}),e[49]=fe,e[50]=He,e[51]=Ue):Ue=e[51];let $e;e[52]!==je?($e=t.jsx("div",{className:"pt-3",children:je}),e[52]=je,e[53]=$e):$e=e[53];let pt;return e[54]!==Ue||e[55]!==$e?(pt=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Ue,$e]}),e[54]=Ue,e[55]=$e,e[56]=pt):pt=e[56],pt}let be;e[57]!==S?(be=S?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=be):be=e[58];let Ce;e[59]!==y?(Ce=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Ce):Ce=e[60];let Me;e[61]!==Ce?(Me=t.jsx("span",{children:Ce}),e[61]=Ce,e[62]=Me):Me=e[62];let ee;e[63]!==se||e[64]!==G||e[65]!==be||e[66]!==Me?(ee=t.jsx(es,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:se,disabled:G,children:[be,Me]})}),e[63]=se,e[64]=G,e[65]=be,e[66]=Me,e[67]=ee):ee=e[67];let he;e[68]!==y?(he=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=he):he=e[69];let Be;e[70]!==he?(Be=t.jsx(ts,{sideOffset:8,children:he}),e[70]=he,e[71]=Be):Be=e[71];let ge;e[72]!==ee||e[73]!==Be?(ge=t.jsxs(Zt,{children:[ee,Be]}),e[72]=ee,e[73]=Be,e[74]=ge):ge=e[74];let Ne;e[75]!==me||e[76]!==k?(Ne=Q=>{Q?k(!0):me()},e[75]=me,e[76]=k,e[77]=Ne):Ne=e[77];let Ie;e[78]!==y?(Ie=y("gitView.branch.updateTitle"),e[78]=y,e[79]=Ie):Ie=e[79];let Te;e[80]!==Ie?(Te=t.jsx(ft,{children:Ie}),e[80]=Ie,e[81]=Te):Te=e[81];let oe;e[82]!==H||e[83]!==S||e[84]!==R||e[85]!==X||e[86]!==y||e[87]!==_?(oe=S?y(X?H?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":R==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[y("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_}),"."]}),e[82]=H,e[83]=S,e[84]=R,e[85]=X,e[86]=y,e[87]=_,e[88]=oe):oe=e[88];let Pe;e[89]!==oe?(Pe=t.jsx(bt,{children:oe}),e[89]=oe,e[90]=Pe):Pe=e[90];let Fe;e[91]!==Te||e[92]!==Pe?(Fe=t.jsxs(gt,{children:[Te,Pe]}),e[91]=Te,e[92]=Pe,e[93]=Fe):Fe=e[93];let De;e[94]!==je||e[95]!==Fe?(De=t.jsxs(ht,{className:"max-w-md",children:[Fe,je]}),e[94]=je,e[95]=Fe,e[96]=De):De=e[96];let We;e[97]!==D||e[98]!==Ne||e[99]!==De?(We=t.jsx(mt,{open:D,onOpenChange:Ne,children:De}),e[97]=D,e[98]=Ne,e[99]=De,e[100]=We):We=e[100];let Le;return e[101]!==ge||e[102]!==We?(Le=t.jsxs(t.Fragment,{children:[ge,We]}),e[101]=ge,e[102]=We,e[103]=Le):Le=e[103],Le};function Fi(o){return o.status==="done"||o.status==="error"}function Ri(o){return o.status==="error"}function Bi(o){return o.slice(o.indexOf("/")+1)}function Di(o){return[o]}function Ei(o){return[o]}function Mi(o,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[o.status==="running"&&t.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(T,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(T,{name:"close",className:"size-3.5 text-destructive"}),o.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Se("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})]},e)}function Ti(o){return o.stopPropagation()}const Li=({runMutation:o,onMutationComplete:e,onMutationError:i,onPathsComplete:m,scheduleFlush:N})=>{const f=[];let p=!1;return{enqueue:g=>{const w=f[f.length-1];if(w?.directory===g.directory&&w.direction===g.direction){g.paths.forEach(E=>w.paths.add(E));return}f.push(g)},flush:()=>{if(p)return;const g=f.shift();if(!g)return;p=!0;const w={directory:g.directory,direction:g.direction,paths:Array.from(g.paths),rollback:g.rollback};(async()=>{try{await o(w),e(w)}catch(E){i(w,E)}finally{m(w.paths),p=!1,f.length>0&&N()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>p}},Ai=15e3,Oi=40,zi=20,Ir={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Pr=(o,e)=>{const i=o.toLowerCase(),m=/^([a-z]+)(?:\(.*\))?!?:/,N=i.match(m);if(N){const x=N[1],g=Ir[x];if(g)return e.find(w=>w.code===g)||null}const f=i.split(" ")[0],p=Ir[f];return p&&e.find(x=>x.code===p)||null},Gi=20,yt=new Map,_i=(o,e)=>{if(yt.delete(o),yt.set(o,e),yt.size>Gi){const i=yt.keys().next().value;i!==void 0&&yt.delete(i)}},Ze=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Fr=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Hi=o=>{const e=o.working_dir?.trim(),i=o.index?.trim();return!!(e||i==="?")},dc=({isActive:o})=>{const{t:e}=nt(),{git:i}=xa(),m=wa(),[N,f]=l.useState(null),[p,x]=l.useState(null),g=rt(s=>s.currentSessionId),w=rt(s=>s.newSessionDraft),E=rt(s=>s.setDraftBootstrapPendingDirectory),b=rt(s=>s.worktreeMetadata),V=rt(s=>s.availableWorktrees),A=Ze(m),S=l.useMemo(()=>{if(!A)return;const s=V.find(n=>Ze(n.path)===A);if(s)return s;for(const n of b.values())if(Ze(n.path)===A)return n},[V,A,b]),z=l.useMemo(()=>{if(g)return b.get(g)??S;if(w?.open)return S},[g,S,w?.open,b]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:P}=Ga(pr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:F,gitDirectory:r,nestedRepos:Y}=ya(m??null,{enabled:o}),B=ba(r??null),u=va(r??null),M=ja(s=>g?s.getAttachment(g):void 0),te=M?Ca(M):[],U=M&&!M.degraded&&!M.legacy?M.worktreeRoot??void 0:void 0,G=Oa(m,z,u?.current??void 0),_=Na(r??null),X=Sa(r??null),H=ka(r??null),le=Va(r??null),ae=Ia(r??null),{setActiveDirectory:ce,ensureAll:ie,fetchStatus:h,fetchBranches:d,fetchLog:I,setLogMaxCount:O,fetchIdentity:q,prefetchDiffs:ne,clearDiffCache:se,moveStatusPathsOptimistically:J,restoreStatus:we,bumpIndexRevision:K,ensureNestedRepos:de,selectNestedRepo:ke}=Pa(pr(s=>({setActiveDirectory:s.setActiveDirectory,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),ye=Ft(s=>s.isMobile),me=Ft(s=>s.openContextDiff),xe=Ft(s=>s.openContextSurface),Ve=u?.current??null,Re=Fa(s=>!r||!Ve?null:Ra(s.entries,r,Ve)),ue=Ft(s=>s.navigateToDiff),_e=l.useRef(null),Oe=l.useRef(null),je=l.useRef(null),be=l.useRef(!0);l.useEffect(()=>()=>{be.current=!1},[]);const Ce=l.useCallback(()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null)},[]),Me=l.useCallback(s=>{Ce(),_e.current=window.setTimeout(()=>{_e.current=null,Ze(s)===Ze(r)&&h(s,i,{silent:!0})},Ai)},[Ce,r,h,i]);l.useEffect(()=>Ce,[Ce]);const ee=l.useCallback(()=>{Oe.current!==null&&(window.clearTimeout(Oe.current),Oe.current=null)},[]),he=l.useCallback(()=>{Oe.current===null&&(Oe.current=window.setTimeout(()=>{Oe.current=null,je.current?.()},0))},[]),Be=l.useCallback(async(s,n,a)=>{if(n==="stage"){if(i.stageGitFiles){await i.stageGitFiles(s,a);return}await Promise.all(a.map(c=>i.stageGitFile(s,c)));return}if(i.unstageGitFiles){await i.unstageGitFiles(s,a);return}await Promise.all(a.map(c=>i.unstageGitFile(s,c)))},[i]),ge=l.useMemo(()=>Li({runMutation:({directory:s,direction:n,paths:a})=>Be(s,n,a),onMutationComplete:({directory:s})=>{K(s),Me(s)},onMutationError:({directory:s,direction:n,rollback:a},c)=>{a?.(),K(s),Me(s);const j=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");v.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{Ys(n=>{const a=new Set(n);return s.forEach(c=>a.delete(c)),a})},scheduleFlush:he}),[K,Be,he,Me,e]);l.useEffect(()=>(je.current=ge.flush,()=>{je.current=null}),[ge]),l.useEffect(()=>()=>ge.clear(),[ge]),l.useEffect(()=>ee,[ee]),l.useEffect(()=>{if(!o)return;if(!m){f(null);return}const s=Ze(m)??m;f({directory:s,status:null});let n=!1,a=null;const c=async()=>{try{const j=await Aa(m);if(n)return;f({directory:s,status:j.status}),j.status==="pending"&&(a=window.setTimeout(()=>{c()},500))}catch{n||f({directory:s,status:null})}};return c(),()=>{n=!0,a!==null&&window.clearTimeout(a)}},[o,m]);const Ne=Ze(w?.bootstrapPendingDirectory??null),Ie=!!(m&&Ne&&Ne===Ze(m)),Te=Ba(m??null),oe=Ze(m),Pe=N?.directory===oe?N.status:null,Fe=!!(m&&(Te||Pe==="pending"||Ie&&w?.pendingWorktreeRequestId)),De=!!(oe&&p?.directory===oe);l.useEffect(()=>{if(!oe)return;if(Pe==="failed"){E(null),x(n=>n?.directory===oe?null:n);return}if(Fe){x(n=>n?.directory===oe&&n.status==="refreshing"?n:{directory:oe,status:"refreshing"});return}if(p?.directory!==oe||p.status!=="refreshing"||!r||!i)return;let s=!1;return h(r,i,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||x(n=>n?.directory===oe?null:n)}).catch(()=>{s||x(n=>n?.directory===oe?{...n,status:"failed"}:n)}),()=>{s=!0}},[h,i,r,Fe,oe,Pe,p,E]);const We=Fe||De,Le=De&&p?.status==="failed",Q=l.useMemo(()=>r?yt.get(r)??null:null,[r]),fe=Da(s=>s.settingsGitmojiEnabled),[Ae,et]=l.useState(null),{gitmojis:He}=Za(fe);l.useEffect(()=>{const s=U||G?.projectDirectory;if(!s){et(null);return}let n=!1;return Ea(s).then(a=>{if(n)return;const c=a.trim();et(c&&c!=="HEAD"?c:null)}).catch(()=>{n||et(null)}),()=>{n=!0}},[U,G?.projectDirectory]);const[Ue,$e]=l.useState(Q?.commitMessage??""),[pt,Tr]=l.useState([]),[Lr,ss]=l.useState(!1),$s=l.useRef(null),[Ws,Dt]=l.useState(null),[Ar,rs]=l.useState(!1),[Us,Ks]=l.useState(null),[Ye,Or]=l.useState(25),[zr,Js]=l.useState(!1),{triggerFireworks:Gr}=za(),qs=l.useRef(new Map),Et=l.useRef(0),ns=l.useCallback(()=>{Et.current+=1,be.current&&Js(!0)},[]),as=l.useCallback(()=>{Et.current=Math.max(0,Et.current-1),be.current&&Et.current===0&&Js(!1)},[]),[is,Mt]=l.useState(new Set),[_r,Ys]=l.useState(new Set),[os,Qs]=l.useState(!1),[Hr,$r]=l.useState(0),[Wr,Xs]=l.useState(!1),[ls,cs]=l.useState(Q?.generatedHighlights??[]),Ur=_r.size>0||ge.size()>0||ge.isRunning(),Zs=l.useCallback(()=>{const s=$s.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),ds=U||G?.projectDirectory||null,us=u?.current||null,Kr=l.useMemo(()=>{const s=u?.tracking;return s?s.startsWith("origin/"):!0},[u?.tracking]),er=l.useMemo(()=>{const s=G?.createdFromBranch,n=typeof s=="string"?s.trim():"",a=typeof u?.current=="string"?u.current.trim():"",c=typeof Ae=="string"?Ae.trim():"";return n?n===a&&n.startsWith("opencode/")&&c.length>0&&c!==n?c:n:c||a||"HEAD"},[G?.createdFromBranch,u,Ae]),Tt=l.useCallback(()=>{cs([])},[]),[ms,Jr]=l.useState(new Set),[Lt,qr]=l.useState(new Map),[At,hs]=l.useState(new Set),gs=l.useRef(Lt),Nt=l.useRef(At),[Yr,vt]=l.useState(null),[xt,fs]=l.useState(null),[tr,sr]=l.useState(""),[Ee,Ot]=l.useState(null),[Qr,rr]=l.useState(!1),[Xr,nr]=l.useState(!1),[ps,xs]=l.useState([]),[Zr,ar]=l.useState(null),[ir,ws]=l.useState(null),[en,zt]=l.useState([]),[tn,Qe]=l.useState(!1),[sn,tt]=l.useState([]),[Gt,st]=l.useState("merge"),[rn,ys]=l.useState(null),[bs,or]=l.useState(!1),[vs,nn]=l.useState(100),[an,on]=l.useState(0),Xe=l.useMemo(()=>g?`openchamber.conflict:${g}`:null,[g]),at=l.useCallback((s,n,a)=>{if(!Xe||typeof window>"u")return;const c={directory:s,conflictFiles:n,operation:a};window.localStorage.setItem(Xe,JSON.stringify(c))},[Xe]),Ke=l.useCallback(()=>{!Xe||typeof window>"u"||window.localStorage.removeItem(Xe)},[Xe]);l.useEffect(()=>{if(!Xe||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Xe);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Xe);return}tt(n.conflictFiles??[]),st(n.operation??"merge"),Qe(!0)}catch{window.localStorage.removeItem(Xe)}},[Xe,r]);const[ln,js]=l.useState(!1),[_t,St]=l.useState(null),[Cs,lr]=l.useState("merge"),[Ns,cr]=l.useState(""),cn=l.useCallback(s=>{Ma(s).then(n=>{if(n.ok){v.success(e("gitView.toast.commitHashCopied"));return}v.error(e("gitView.toast.copyFailed"))})},[e]),dn=l.useCallback(s=>{Jr(n=>{const a=new Set(n);return a.has(s)?a.delete(s):a.add(s),a})},[]);l.useEffect(()=>{gs.current=Lt},[Lt]),l.useEffect(()=>{Nt.current=At},[At]),l.useEffect(()=>{if(!r||!i)return;const s=Array.from(ms).filter(a=>!gs.current.has(a)&&!Nt.current.has(a));if(s.length===0)return;let n=!1;return hs(a=>{const c=new Set(a);for(const j of s)c.add(j);return Nt.current=c,c}),Promise.all(s.map(a=>i.getCommitFiles(r,a).then(c=>({hash:a,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:a,files:[]})))).then(a=>{n||(qr(c=>{const j=new Map(c);for(const{hash:L,files:Z}of a)j.set(L,Z);return gs.current=j,j}),hs(c=>{const j=new Set(c);for(const{hash:L}of a)j.delete(L);return Nt.current=j,j}))}),()=>{n=!0,hs(a=>{let c=!1;const j=new Set(a);for(const L of s)j.delete(L)&&(c=!0);return c?(Nt.current=j,j):a})}},[ms,r,i]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;$e(s?.commitMessage??""),cs(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&_i(r,{directory:r,commitMessage:Ue,generatedHighlights:ls})},[Ue,r,ls]),l.useEffect(()=>{o&&(k(),R(),P())},[o,k,R,P]),l.useEffect(()=>{if(!o)return;if(!r||!i?.getRemoteUrl||B!==!0){fs(null);return}let s=!1;return i.getRemoteUrl(r).then(n=>{s||fs(n)}).catch(()=>{s||fs(null)}),()=>{s=!0}},[o,r,i,B]);const Ht=l.useCallback(async()=>{if(!r||!i?.getRemotes||B!==!0){xs([]);return}try{const s=await i.getRemotes(r);be.current&&xs(s)}catch{be.current&&xs([])}},[r,i,B]);l.useEffect(()=>{o&&Ht()},[o,Ht]),l.useEffect(()=>{o&&m&&r&&(ce(m),ie(r,i))},[o,m,r,ce,ie,i]),l.useEffect(()=>{if(o&&r)return Ta.onGitRefreshHint(s=>{Ze(s.directory)===Ze(r)&&(s.paths?.length&&se(r,s.paths),h(r,i,{silent:!0}))})},[o,se,r,h,i]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,i),d(r,i)])}catch(n){if(s){const a=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");v.error(a)}}},[r,i,h,d,e]),pe=l.useCallback(async()=>{r&&await I(r,i,Ye)},[r,i,I,Ye]),Ss=l.useCallback(async()=>{r&&await q(r,i)},[r,i,q]);l.useEffect(()=>{if(!o||!r||!i?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||qs.current.get(r)===s)return;let a=!1;return(async()=>{try{const j=await i.hasLocalIdentity?.(r);if(a||j===!0)return;ns(),await i.setGitIdentity(r,s),qs.current.set(r,s),await Ss()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{a||as()}})(),()=>{a=!0}},[o,ns,r,D,as,i,B,Ss]);const it=l.useMemo(()=>u?[...u.files??[]].sort((n,a)=>n.path.localeCompare(a.path)):[],[u]),Je=l.useMemo(()=>it.filter(Fr),[it]),ks=l.useMemo(()=>it.filter(Hi),[it]);l.useEffect(()=>{if(!o||!r||it.length===0)return;const s=[],n=new Set,a=j=>{!j||n.has(j)||(n.add(j),s.push(j))};if(Je.forEach(j=>a(j.path)),pt.forEach(a),it.slice(0,zi).forEach(j=>a(j.path)),s.length===0)return;const c=window.setTimeout(()=>{ne(r,i,s,{maxFiles:Oi})},120);return()=>{window.clearTimeout(c)}},[o,it,r,i,ne,Je,pt]);const Vs=s=>s?.pushed[0]?.remote||u?.tracking?.split("/")[0]||ze.find(n=>n.name==="origin")?.name||ze[0]?.name||"origin",dr=async(s,n)=>{if(r){Dt(s);try{const a=c=>{const j=`${c.name}/`,L=u?.tracking?.startsWith(j)?u.tracking.slice(j.length):void 0;return{remote:c.name,branch:L,rebase:!0}};if(s==="fetch"){if(!n)throw new Error("No remote available for fetch");await i.gitFetch(r,{remote:n.name}),v.success(e("gitView.toast.fetchedFromRemote",{name:n.name}))}else if(s==="pull"){if(!n)throw new Error("No remote available for pull");const c=await i.gitPull(r,a(n));v.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:n.name}))}else if(s==="push"){const c=await i.gitPush(r);v.success(c.pushed.length>0?e("gitView.toast.pushedToUpstream",{name:Vs(c)}):e("gitView.toast.alreadyUpToDate"))}else if(s==="sync"){if(!n)throw new Error("No remote available for sync");let c=0;const j=await xr({git:i,directory:r,remote:n,dirtyWorktreeError:e("gitView.toast.commitOrStashBeforeSync"),onPulled:$=>{c=$.files.length}}),L=j.pushed.length>0,Z=Vs(j);c>0&&L&&Z===n.name?v.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:n.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:n.name})):(c>0&&v.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:n.name})),L&&v.success(e("gitView.toast.pushedToUpstream",{name:Z})),c===0&&!L&&v.success(e("gitView.toast.alreadyUpToDate")))}await re(!1),await pe()}catch(a){const c=a instanceof Error?a.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});v.error(c)}finally{Dt(null)}}},un=l.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){v.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){v.error(e("gitView.toast.cannotRemoveOriginRemote"));return}ar(n);try{await i.removeRemote(r,{remote:n}),v.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([re(!1),Ht()])}catch(a){const c=a instanceof Error?a.message:`Failed to remove ${n}`;v.error(c)}finally{ar(null)}},[r,i,Ht,re,e]),ur=async(s={})=>{if(!r)return;if(!Ue.trim()){v.error(e("gitView.toast.enterCommitMessage"));return}const n=Je.map(c=>c.path).sort();if(n.length===0){v.error(e("gitView.toast.stageFileToCommit"));return}const a=s.pushAfter?"commitAndPush":"commit";Ks(a);try{if(await i.createGitCommit(r,Ue.trim(),{files:n,stageFiles:[]}),K(r),v.success(e("gitView.toast.commitCreated")),$e(""),Tt(),await re(),s.pushAfter){const c=u?.tracking?.split("/")[0],j=ze.find(L=>L.name===c)??ze[0];if(!j)throw new Error(e("mobile.changes.noRemote"));Dt("sync"),await xr({git:i,directory:r,remote:j,dirtyWorktreeError:e("gitView.toast.commitOrStashBeforeSync"),onPushed:L=>{v.success(e("gitView.toast.pushedToUpstream",{name:Vs(L)})),Gr()}}),await re(!1)}else await re(!1);await pe(),$r(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");v.error(j)}finally{Ks(null),s.pushAfter&&Dt(null)}},mn=l.useCallback(async()=>{if(!r)return;const s=Je.map(n=>n.path).sort();if(s.length===0){v.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Xs(!0);try{const{message:n}=await fr(r,s),a=n.subject?.trim()??"",c=Array.isArray(n.highlights)?n.highlights:[];if(a){let j=a;if(fe&&He.length>0){const L=Pr(a,He);if(L){const{code:Z,emoji:$}=L;!a.startsWith(Z)&&!a.startsWith($)&&(j=`${Z} ${a}`)}}$e(j)}cs(c),Zs()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const a=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");v.error(a)}finally{Xs(!1)}},[r,Je,fe,He,Zs,e]),Is=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",hn=async(s,n)=>{if(!r||!u)return;const a=Ds(M);if(a.length>0){v.error(e("gitView.toast.cannotCreateBranch",{reason:Is(a[0])}));return}const c=u.current??null,j=n?.name??"origin";try{await i.createBranch(r,s,c??"HEAD"),v.success(e("gitView.toast.createdBranch",{name:s})),await i.checkoutBranch(r,s);let L=!1;try{await i.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),L=!0}catch(Z){const $=Z instanceof Error?Z.message:`Unable to push new branch to ${j}.`;v.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",$]})})}await re(),await pe(),L&&v.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(L){const Z=L instanceof Error?L.message:e("gitView.toast.createBranchFailed");throw v.error(Z),L}},gn=async(s,n)=>{if(!r)return;const a=Ds(M);if(a.length>0){v.error(e("gitView.toast.cannotRenameBranch",{reason:Is(a[0])}));return}try{await i.renameBranch(r,s,n),v.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await re(),await pe()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});v.error(j)}},fn=async s=>{if(!r)return;const n=Ds(M);if(n.length>0){v.error(e("gitView.toast.cannotCheckout",{reason:Is(n[0])}));return}const a=s.replace(/^remotes\//,"");if(u?.current!==a){if((u?.files?.length??0)>0){St(a);return}await Ps(a)}},Ps=async s=>{if(!r)return;const n=s;try{const a=await i.checkoutBranch(r,n);v.success(e("gitView.toast.checkedOut",{name:a?.branch||n})),await re(),await pe()}catch(a){const c=a instanceof Error?a.message:e("gitView.toast.checkoutFailed",{name:n});v.error(c)}},pn=async s=>{if(r){ns();try{await i.setGitIdentity(r,s.id),v.success(e("gitView.toast.appliedIdentity",{name:s.name})),await Ss()}catch(n){const a=n instanceof Error?n.message:e("gitView.toast.applyIdentityFailed");v.error(a)}finally{as()}}},kt=l.useMemo(()=>_?.all?_.all.filter(s=>!s.startsWith("remotes/")).sort():[],[_]),ot=l.useMemo(()=>_?.all?_.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[_]),ze=l.useMemo(()=>{if(ps.length>0)return ps;const s=new Set,n=u?.tracking?.trim();n&&n.includes("/")&&s.add(n.split("/")[0]);for(const a of ot){const c=a.indexOf("/");c>0&&s.add(a.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(a=>({name:a,fetchUrl:xt??"",pushUrl:xt??""}))},[ps,ot,xt,u?.tracking]),lt=u?.current??null,mr=l.useMemo(()=>{const s=u?.tracking?.trim().split("/")[0];return(s&&_?.defaultBranches?.[s])??_?.defaultBranches?.origin},[_,u?.tracking]),wt=l.useMemo(()=>_a({remoteNames:new Set(ze.map(s=>s.name)),localBranches:kt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Ae,defaultBranch:mr,headBranch:lt}),[lt,mr,ze,kt,Ae,G?.createdFromBranch]),xn=l.useMemo(()=>ze.map(a=>a.name).map(a=>`${a}/${wt}`).find(a=>ot.includes(a))??wt,[wt,ze,ot]),wn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let n=null;if(xt)try{let a=xt.trim();a.startsWith("git@")&&(a=`https://${a.slice(4).replace(":","/")}`),a.endsWith(".git")&&(a=a.slice(0,-4));const c=new URL(a);n=c.hostname+c.pathname}catch{}for(const a of C){if(a.authType!=="token"){s.set(a.id,a);continue}const c=a.host;if(!c){s.set(a.id,a);continue}if(!c.includes("/")){s.set(a.id,a);continue}n&&n===c&&s.set(a.id,a)}return Array.from(s.values())},[C,y,xt]),yn=l.useMemo(()=>{if(H?.userName&&H?.userEmail){const s=C.find(n=>n.userName===H.userName&&n.userEmail===H.userEmail);return s||(y&&y.userName===H.userName&&y.userEmail===H.userEmail?y:{id:"local-config",name:H.userName,userName:H.userName,userEmail:H.userEmail,sshKey:H.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return y??null},[H,C,y]),bn=Je.length,vn=le||Ws!==null||Us!==null,jn=!!(G&&ds&&us&&Kr),hr=!!lt,ct=jn&&ds&&us&&G?{repoRoot:ds,sourceBranch:us,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!i||!X?.all?.length||!lt||!wt||lt===wt){vt(null);return}let s=!1;return(async()=>{try{const a=await i.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ye});if(s)return;const c=new Set((a?.all??[]).map(L=>L.hash).filter(L=>typeof L=="string"&&L.length>0));if(c.size===0){vt(null);return}const j=X.all.findIndex(L=>!c.has(L.hash));if(j===0){vt(null);return}if(j===-1){vt({insertBeforeIndex:X.all.length,branchName:lt,direction:"up"});return}vt({insertBeforeIndex:j,branchName:lt,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,lt,r,i,X,Ye]),l.useEffect(()=>{ys(null)},[r]),l.useEffect(()=>{if(Ee!=="graph"||!r){Ee!=="graph"&&ys(null);return}let s=!1;return or(!0),i.getGitLog(r,{maxCount:vs,all:!0}).then(n=>{s||ys(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||or(!1)}),()=>{s=!0}},[Ee,r,vs,an,i]);const Vt=l.useCallback((s,n)=>{if(!r||s.length===0)return;const a=Array.from(new Set(s));Ys(j=>{const L=new Set(j);return a.forEach(Z=>L.add(Z)),L});const c=J(r,a,n);ge.enqueue({directory:r,direction:n,paths:new Set(a),rollback:()=>we(r,c)}),he()},[r,ge,J,we,he]),Fs=l.useCallback(async s=>{if(r){Mt(n=>{const a=new Set(n);return a.add(s),a});try{await i.revertGitFile(r,s,{scope:"working"}),v.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(n){const a=n instanceof Error?n.message:e("gitView.toast.revertFailed");v.error(a)}finally{Mt(n=>{const a=new Set(n);return a.delete(s),a})}}},[r,re,i,e]),It=l.useCallback(async(s,n,a="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(os||c.some($=>is.has($)))return;const j=new Set(Je.map($=>$.path)),L=a==="all"&&c.some($=>j.has($));n&&Qs(!0),Mt($=>{const qe=new Set($);return c.forEach(Bs=>qe.add(Bs)),qe});const Z=[];try{if(await Promise.all(c.map(async $=>{try{await i.revertGitFile(r,$,{scope:a})}catch(qe){Z.push({path:$,message:qe instanceof Error?qe.message:e("gitView.toast.revertFailed")})}})),L&&Z.length<c.length&&K(r),await re(!1),Z.length===0)v.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(Z.length===c.length)v.error(Z[0]?.message||e("gitView.toast.revertFailed"));else{const $=c.length-Z.length;v.warning($===1?e("gitView.toast.revertedSomeSingle",{success:$,failed:Z.length}):e("gitView.toast.revertedSomePlural",{success:$,failed:Z.length}))}}finally{Mt($=>{const qe=new Set($);return c.forEach(Bs=>qe.delete(Bs)),qe}),n&&Qs(!1)}},[K,r,i,os,re,is,Je,e]),Cn=l.useCallback(async s=>{await It(s,!0)},[It]),Nn=l.useCallback(async s=>{await It(s,!1,"working")},[It]),Rs=l.useCallback((s,n)=>{if(m&&!ye){me(m,s,n);return}ue(s,n)},[m,ye,ue,me]),Sn=l.useCallback(()=>rs(!0),[]),kn=l.useMemo(()=>{const s=[];return Je.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Je,statsScope:"staged",actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{Vt([n],"unstage")},onActionAll:n=>{Vt(n,"unstage")},onViewDiff:n=>Rs(n,!0),onRevertFile:Fs,showRevertActions:!1,accent:!0}),ks.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:ks,statsScope:"working",actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{Vt([n],"stage")},onActionAll:n=>{Vt(n,"stage")},onViewDiff:n=>Rs(n,!1),onRevertFile:Fs}),s},[Fs,Rs,Vt,Je,e,ks]),Vn=l.useCallback(s=>{if(s.length===0)return;const n=s.map(a=>a.trim()).filter(Boolean);if(n.length===0){Tt();return}$e(a=>{const c=a.trim(),j=c.length>0?`
|
|
4
4
|
|
|
5
5
|
`:"";return`${c}${j}${n.join(`
|
|
6
|
-
`)}`.trim()}),Tt()},[Tt]),In=l.useCallback((s,n)=>{const a=n||s;He(c=>{const j=c.trimStart();return j.startsWith(s)||n&&j.startsWith(n)?c:`${a.endsWith(" ")?a:`${a} `}${c}`.trimStart()}),sr(""),ss(!1)},[]),Ht=l.useCallback(s=>{const n=s instanceof Error?s.message.toLowerCase():"";return n.includes("uncommitted changes")||n.includes("local changes")||n.includes("your local changes would be overwritten")||n.includes("please commit your changes or stash them")||n.includes("cannot rebase: you have unstaged changes")||n.includes("error: cannot pull with rebase")},[]),dt=l.useCallback((s,n)=>{zt(a=>[...a,{message:s,status:n,timestamp:Date.now()}])},[]),Ge=l.useCallback((s,n)=>{zt(a=>{if(a.length===0)return a;const c=[...a];return c[c.length-1]={...c[c.length-1],status:s,...n?{message:n}:{}},c})},[]),Wt=l.useCallback(()=>{zt([])},[]),Pn=l.useCallback(()=>{zt([]),ws(null)},[]),Ut=l.useCallback(s=>{const n=s.trim(),a=new Set(ze.map(j=>j.name)),c=n.indexOf("/");if(c>0){const j=n.slice(0,c),L=n.slice(c+1);if(a.has(j)&&L)return{branch:n,remote:j,remoteBranch:L}}for(const j of ze){const L=`${j.name}/${n}`;if(ot.includes(L))return{branch:L,remote:j.name,remoteBranch:n}}return{branch:n,remote:null,remoteBranch:null}},[ze,ot]),Fn=l.useCallback(async s=>{if(!r)return;ws("merge"),Wt();const n=u?.current,a=Ut(s);try{a.remote&&a.remoteBranch&&(dt(`Fetching ${a.remote}/${a.remoteBranch}...`,"running"),await i.gitFetch(r,{remote:a.remote,branch:a.remoteBranch}),Ge("done",`Fetched ${a.remote}/${a.remoteBranch}`)),dt(`Merging ${a.branch} into ${n}...`,"running");const c=await i.merge(r,{branch:a.branch});c.conflict?(Ge("error","Merge conflicts detected"),tt(c.conflictFiles??[]),st("merge"),Qe(!0),at(r,c.conflictFiles??[],"merge")):(Ge("done",`Merged ${a.branch} into ${n}`),Ke(),dt("Refreshing repository status...","running"),await re(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Ht(c))Ge("error","Uncommitted changes detected"),lr("merge"),cr(a.branch),js(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${a.branch}`;Ge("error",j)}}},[r,i,u,Ut,re,pe,Ht,at,Ke,dt,Ge,Wt]),Rn=l.useCallback(async s=>{if(!r)return;ws("rebase"),Wt();const n=u?.current,a=Ut(s);try{a.remote&&a.remoteBranch&&(dt(`Fetching ${a.remote}/${a.remoteBranch}...`,"running"),await i.gitFetch(r,{remote:a.remote,branch:a.remoteBranch}),Ge("done",`Fetched ${a.remote}/${a.remoteBranch}`)),dt(`Rebasing ${n} onto ${a.branch}...`,"running");const c=await i.rebase(r,{onto:a.branch});c.conflict?(Ge("error","Rebase conflicts detected"),tt(c.conflictFiles??[]),st("rebase"),Qe(!0),at(r,c.conflictFiles??[],"rebase")):(Ge("done",`Rebased ${n} onto ${a.branch}`),Ke(),dt("Refreshing repository status...","running"),await re(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Ht(c))Ge("error","Uncommitted changes detected"),lr("rebase"),cr(a.branch),js(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${a.branch}`;Ge("error",j)}}},[r,i,u,Ut,re,pe,Ht,at,Ke,dt,Ge,Wt]),Bn=l.useCallback(async()=>{if(r)try{Gt==="merge"?(await i.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await i.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),Ke(),await re(),await pe()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${Gt}`;v.error(n)}},[r,i,Gt,re,pe,Ke,e]),Dn=l.useMemo(()=>u?.files?u.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[u?.files]),En=l.useCallback(async()=>{if(r)try{const s=!!u?.mergeInProgress?.head,n=!!(u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto);if(s){const a=await i.continueMerge(r);a.conflict?(tt(a.conflictFiles??[]),st("merge"),Qe(!0),at(r,a.conflictFiles??[],"merge"),v.error(e("gitView.toast.mergeConflictsDetected"))):(Ke(),v.success(e("gitView.toast.mergeCompleted")),await re(),await pe())}else if(n){const a=await i.continueRebase(r);a.conflict?(tt(a.conflictFiles??[]),st("rebase"),Qe(!0),at(r,a.conflictFiles??[],"rebase"),v.error(e("gitView.toast.rebaseConflictsDetected"))):(Ke(),v.success(e("gitView.toast.rebaseStepCompleted")),await re(),await pe())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");v.error(n)}},[r,i,u,re,pe,at,Ke,e]),Mn=l.useCallback(async()=>{if(r)try{!!u?.mergeInProgress?.head?(await i.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await i.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),Ke(),await re(),await pe()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");v.error(n)}},[r,i,u,re,pe,Ke,e]),Tn=l.useCallback(()=>{if(!r)return;const n=!!u?.mergeInProgress?.head?"merge":"rebase",a=u?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];a.length>0&&tt(a),st(n),Qe(!0)},[r,u]),Ln=l.useCallback(async s=>{if(!r)return;const n=u?.current,a=Cs,c=Ns,j=(u?.files??[]).some(Fr);try{await i.stash(r,{message:`Auto-stash before ${a} with ${c}`,includeUntracked:!0}),j&&K(r)}catch(H){const qe=H instanceof Error?H.message:"Failed to stash changes";v.error(qe);return}let L=!1,Z=!1;try{if(a==="merge"){const H=await i.merge(r,{branch:c});H.conflict?(Z=!0,tt(H.conflictFiles??[]),st("merge"),Qe(!0)):(L=!0,v.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:n||""})))}else{const H=await i.rebase(r,{onto:c});H.conflict?(Z=!0,tt(H.conflictFiles??[]),st("rebase"),Qe(!0)):(L=!0,v.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:c})))}if(s&&L)try{await i.stashPop(r),K(r),v.success(e("gitView.toast.stashedRestored"))}catch(H){const qe=H instanceof Error?H.message:e("gitView.toast.restoreStashFailed");v.error(qe)}else s&&Z&&v.info(e("gitView.toast.restoreStashManually"));await re(),await pe()}catch(H){if(s)try{await i.stashPop(r),K(r)}catch{}throw H}},[K,r,i,u,Cs,Ns,re,pe,e]),On=l.useCallback(s=>{Ar(s),r&&(A(r,s),I(r,i,s))},[r,I,i,A]),An=l.useCallback(s=>{nn(s)},[]),zn=l.useCallback(()=>{At(null),r&&(h(r,i),d(r,i),I(r,i,Ye))},[r,h,d,I,Ye,i]),Gn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){v.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,i),d(r,i),I(r,i,Ye));return}tt(s.conflictFiles??[]),st(s.operation),Qe(!0),r&&at(r,s.conflictFiles??[],s.operation)}},[e,tt,st,Qe,at,r,h,d,I,Ye,i]);return m?We?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[Le?null:t.jsx(T,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e(Le?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),Le?t.jsx(W,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{oe&&x({directory:oe,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):B===null||B===!0&&!u?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?t.jsx($a,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{m&&de(m,{force:!0})},emptyStateFooter:te.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:Se("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ha,{directory:r??"",status:u,localBranches:kt,remoteBranches:ot,branchInfo:_?.branches,syncAction:Ws,remotes:ze,onFetch:s=>dr("fetch",s),onSync:s=>dr("sync",s),onRemoveRemote:un,removingRemoteName:Zr,onCheckoutBranch:fn,onCreateBranch:hn,onRenameBranch:gn,activeIdentityProfile:yn,availableIdentities:wn,onSelectIdentity:pn,isApplyingIdentity:zr,isWorktreeMode:!!G,onOpenHistory:()=>At("history"),onOpenGraph:()=>At("graph"),onOpenStashes:Sn,onOpenUpdateBranch:hr?()=>rr(!0):void 0,onOpenReintegrateCommits:ct?()=>nr(!0):void 0,pullRequest:Re?.pr??null,prChecks:Re?.checks??null,onOpenPullRequest:r?()=>xe(r,"pr"):void 0,repositoryOptions:r!==m&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==m?r:null,onSelectRepository:r!==m&&m?s=>ke(m,s):void 0,repositoryRoot:r!==m?m:void 0}),m&&(u?.mergeInProgress?.head||u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto)&&t.jsx(Ii,{mergeInProgress:u?.mergeInProgress,rebaseInProgress:u?.rebaseInProgress,onContinue:En,onAbort:Mn,onResolveWithAI:Tn,conflictCount:Dn,isLoading:le}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Se("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Br,{as:La,ref:Hs,outerClassName:"flex-1 min-h-0",className:Se("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(it?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ua,{groups:kn,diffStats:u?.diffStats,revertingPaths:is,isRevertingAll:os,onVisiblePathsChange:Tr,onRevertAll:Cn,onRevertDirectory:Nn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ka,{stagedCount:bn,commitMessage:Ue,onCommitMessageChange:He,generatedHighlights:ls,onInsertHighlights:Vn,onGenerateMessage:mn,isGeneratingMessage:Wr,onCommit:()=>ur({pushAfter:!1}),onCommitAndPush:()=>ur({pushAfter:!0}),commitAction:Us,hasPendingIndexMutation:Ur,gitmojiEnabled:fe,onOpenGitmojiPicker:()=>ss(!0)})]}):t.jsx(oi,{onOpenStashes:()=>rs(!0)})})})})})}),t.jsx(mt,{open:Qr,onOpenChange:s=>{!s&&ir!==null||rr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:u?.current??""}),"."]})]}),hr?t.jsx(Pi,{mode:"bare",currentBranch:u?.current,localBranches:kt,remoteBranches:ot,defaultTargetBranch:xn,onMerge:Fn,onRebase:Rn,disabled:vn,isOperating:ir!==null,operationLogs:en,onOperationComplete:Pn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Xr,onOpenChange:nr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:ct?t.jsxs("span",{className:"font-mono text-foreground",children:[ct.sourceBranch," → ",er]}):null})]}),ct?t.jsx(ai,{repoRoot:ct.repoRoot,sourceBranch:ct.sourceBranch,worktreeMetadata:ct.worktreeMetadata,localBranches:kt,defaultTargetBranch:er,refreshKey:$r,showHeader:!1,onRefresh:()=>{r&&(h(r,i),d(r,i),I(r,i,Ye))}},ct.worktreeMetadata.path):null]})}),t.jsx(mt,{open:Ee!==null,onOpenChange:s=>{s||At(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(ft,{children:e(Ee==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Ee==="graph"){on(s=>s+1);return}r&&I(r,i,Ye)},disabled:Ee==="graph"?bs:ae,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(T,{name:"refresh",className:Se("size-4",(Ee==="graph"?bs:ae)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(bt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(pi,{mode:Ee==="graph"?"graph":"history",log:Ee==="graph"?rn??X:X,isLogLoading:Ee==="graph"&&bs||ae,logMaxCount:Ee==="graph"?vs:Ye,onLogMaxCountChange:Ee==="graph"?An:On,expandedCommitHashes:ms,onToggleCommit:dn,commitFilesMap:Lt,loadingCommitHashes:Ot,onCopyHash:cn,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Ee==="graph"?null:Yr,onConflict:Ee==="graph"?Gn:void 0,onActionSuccess:Ee==="graph"?zn:void 0})})]})}),t.jsx(ii,{open:Or,onOpenChange:rs,directory:r,hasUncommittedChanges:(u?.files?.length??0)>0,hasStagedChanges:Je.length>0,uncommittedFileCount:u?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&K(r),await re(!1),await pe()}}),t.jsx(mt,{open:Lr,onOpenChange:ss,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(gt,{className:"px-4 pt-4",children:t.jsx(ft,{children:e("gitView.gitmoji.title")})}),t.jsxs(zs,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(Gs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:tr,onValueChange:sr}),t.jsxs(_s,{children:[t.jsx($s,{children:e("gitView.gitmoji.empty")}),t.jsx(Qt,{children:Bt($e,tr,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Xt,{onSelect:()=>In(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(vi,{open:tn,onOpenChange:Qe,conflictFiles:sn,directory:r,operation:Gt,onAbort:Bn,onClearState:Ke}),t.jsx(Ja,{open:_t!==null,onOpenChange:s=>{s||St(null)},targetBranch:_t??"",changedFileCount:u?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const a=_t;if(!a||!r)return;const c=u?.current??null;await i.createGitCommit(r,s,{addAll:!0}),K(r);let j=null;if(n){const L=u?.tracking?.split("/")[0],Z=ze.find(H=>H.name===L)??ze[0];try{if(!Z)throw new Error(e("mobile.changes.noRemote"));await i.gitPush(r,u?.tracking?{remote:Z.name}:{remote:Z.name,branch:c??void 0,options:["--set-upstream"]}),j=Z.name}catch(H){console.error("Push after commit failed:",H),v.error(e("gitView.dirtySwitch.pushFailed")),await re(),await pe(),St(null);return}}v.success(j?e("gitView.toast.pushedToUpstream",{name:j}):c?e("gitView.dirtySwitch.committedNotPushed",{branch:c}):e("gitView.toast.commitCreated")),await re(),await pe(),St(null),await Ps(a)},onGenerateMessage:async()=>{if(!r)return"";const s=(u?.files??[]).map(c=>c.path).sort(),{message:n}=await fr(r,s),a=n.subject?.trim()??"";if(a&&fe&&$e.length>0){const c=Pr(a,$e);if(c&&!a.startsWith(c.code)&&!a.startsWith(c.emoji))return`${c.code} ${a}`}return a},onRevertAndSwitch:async()=>{const s=_t;if(!s||!r)return;const n=(u?.files??[]).map(c=>c.path);await It(n,!0,"all");const a=await i.getGitStatus(r);if(!a.isClean&&(a.files?.length??0)>0){v.error(e("gitView.dirtySwitch.revertIncomplete"));return}St(null),await Ps(s)}}),t.jsx(Vi,{open:ln,onOpenChange:js,operation:Cs,targetBranch:Ns,onConfirm:Ln})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{cc as GitView};
|
|
6
|
+
`)}`.trim()}),Tt()},[Tt]),In=l.useCallback((s,n)=>{const a=n||s;$e(c=>{const j=c.trimStart();return j.startsWith(s)||n&&j.startsWith(n)?c:`${a.endsWith(" ")?a:`${a} `}${c}`.trimStart()}),sr(""),ss(!1)},[]),$t=l.useCallback(s=>{const n=s instanceof Error?s.message.toLowerCase():"";return n.includes("uncommitted changes")||n.includes("local changes")||n.includes("your local changes would be overwritten")||n.includes("please commit your changes or stash them")||n.includes("cannot rebase: you have unstaged changes")||n.includes("error: cannot pull with rebase")},[]),dt=l.useCallback((s,n)=>{zt(a=>[...a,{message:s,status:n,timestamp:Date.now()}])},[]),Ge=l.useCallback((s,n)=>{zt(a=>{if(a.length===0)return a;const c=[...a];return c[c.length-1]={...c[c.length-1],status:s,...n?{message:n}:{}},c})},[]),Wt=l.useCallback(()=>{zt([])},[]),Pn=l.useCallback(()=>{zt([]),ws(null)},[]),Ut=l.useCallback(s=>{const n=s.trim(),a=new Set(ze.map(j=>j.name)),c=n.indexOf("/");if(c>0){const j=n.slice(0,c),L=n.slice(c+1);if(a.has(j)&&L)return{branch:n,remote:j,remoteBranch:L}}for(const j of ze){const L=`${j.name}/${n}`;if(ot.includes(L))return{branch:L,remote:j.name,remoteBranch:n}}return{branch:n,remote:null,remoteBranch:null}},[ze,ot]),Fn=l.useCallback(async s=>{if(!r)return;ws("merge"),Wt();const n=u?.current,a=Ut(s);try{a.remote&&a.remoteBranch&&(dt(`Fetching ${a.remote}/${a.remoteBranch}...`,"running"),await i.gitFetch(r,{remote:a.remote,branch:a.remoteBranch}),Ge("done",`Fetched ${a.remote}/${a.remoteBranch}`)),dt(`Merging ${a.branch} into ${n}...`,"running");const c=await i.merge(r,{branch:a.branch});c.conflict?(Ge("error","Merge conflicts detected"),tt(c.conflictFiles??[]),st("merge"),Qe(!0),at(r,c.conflictFiles??[],"merge")):(Ge("done",`Merged ${a.branch} into ${n}`),Ke(),dt("Refreshing repository status...","running"),await re(),await pe(),Ge("done","Repository status updated"))}catch(c){if($t(c))Ge("error","Uncommitted changes detected"),lr("merge"),cr(a.branch),js(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${a.branch}`;Ge("error",j)}}},[r,i,u,Ut,re,pe,$t,at,Ke,dt,Ge,Wt]),Rn=l.useCallback(async s=>{if(!r)return;ws("rebase"),Wt();const n=u?.current,a=Ut(s);try{a.remote&&a.remoteBranch&&(dt(`Fetching ${a.remote}/${a.remoteBranch}...`,"running"),await i.gitFetch(r,{remote:a.remote,branch:a.remoteBranch}),Ge("done",`Fetched ${a.remote}/${a.remoteBranch}`)),dt(`Rebasing ${n} onto ${a.branch}...`,"running");const c=await i.rebase(r,{onto:a.branch});c.conflict?(Ge("error","Rebase conflicts detected"),tt(c.conflictFiles??[]),st("rebase"),Qe(!0),at(r,c.conflictFiles??[],"rebase")):(Ge("done",`Rebased ${n} onto ${a.branch}`),Ke(),dt("Refreshing repository status...","running"),await re(),await pe(),Ge("done","Repository status updated"))}catch(c){if($t(c))Ge("error","Uncommitted changes detected"),lr("rebase"),cr(a.branch),js(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${a.branch}`;Ge("error",j)}}},[r,i,u,Ut,re,pe,$t,at,Ke,dt,Ge,Wt]),Bn=l.useCallback(async()=>{if(r)try{Gt==="merge"?(await i.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await i.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),Ke(),await re(),await pe()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${Gt}`;v.error(n)}},[r,i,Gt,re,pe,Ke,e]),Dn=l.useMemo(()=>u?.files?u.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[u?.files]),En=l.useCallback(async()=>{if(r)try{const s=!!u?.mergeInProgress?.head,n=!!(u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto);if(s){const a=await i.continueMerge(r);a.conflict?(tt(a.conflictFiles??[]),st("merge"),Qe(!0),at(r,a.conflictFiles??[],"merge"),v.error(e("gitView.toast.mergeConflictsDetected"))):(Ke(),v.success(e("gitView.toast.mergeCompleted")),await re(),await pe())}else if(n){const a=await i.continueRebase(r);a.conflict?(tt(a.conflictFiles??[]),st("rebase"),Qe(!0),at(r,a.conflictFiles??[],"rebase"),v.error(e("gitView.toast.rebaseConflictsDetected"))):(Ke(),v.success(e("gitView.toast.rebaseStepCompleted")),await re(),await pe())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");v.error(n)}},[r,i,u,re,pe,at,Ke,e]),Mn=l.useCallback(async()=>{if(r)try{!!u?.mergeInProgress?.head?(await i.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await i.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),Ke(),await re(),await pe()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");v.error(n)}},[r,i,u,re,pe,Ke,e]),Tn=l.useCallback(()=>{if(!r)return;const n=!!u?.mergeInProgress?.head?"merge":"rebase",a=u?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];a.length>0&&tt(a),st(n),Qe(!0)},[r,u]),Ln=l.useCallback(async s=>{if(!r)return;const n=u?.current,a=Cs,c=Ns,j=(u?.files??[]).some(Fr);try{await i.stash(r,{message:`Auto-stash before ${a} with ${c}`,includeUntracked:!0}),j&&K(r)}catch($){const qe=$ instanceof Error?$.message:"Failed to stash changes";v.error(qe);return}let L=!1,Z=!1;try{if(a==="merge"){const $=await i.merge(r,{branch:c});$.conflict?(Z=!0,tt($.conflictFiles??[]),st("merge"),Qe(!0)):(L=!0,v.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:n||""})))}else{const $=await i.rebase(r,{onto:c});$.conflict?(Z=!0,tt($.conflictFiles??[]),st("rebase"),Qe(!0)):(L=!0,v.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:c})))}if(s&&L)try{await i.stashPop(r),K(r),v.success(e("gitView.toast.stashedRestored"))}catch($){const qe=$ instanceof Error?$.message:e("gitView.toast.restoreStashFailed");v.error(qe)}else s&&Z&&v.info(e("gitView.toast.restoreStashManually"));await re(),await pe()}catch($){if(s)try{await i.stashPop(r),K(r)}catch{}throw $}},[K,r,i,u,Cs,Ns,re,pe,e]),An=l.useCallback(s=>{Or(s),r&&(O(r,s),I(r,i,s))},[r,I,i,O]),On=l.useCallback(s=>{nn(s)},[]),zn=l.useCallback(()=>{Ot(null),r&&(h(r,i),d(r,i),I(r,i,Ye))},[r,h,d,I,Ye,i]),Gn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){v.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,i),d(r,i),I(r,i,Ye));return}tt(s.conflictFiles??[]),st(s.operation),Qe(!0),r&&at(r,s.conflictFiles??[],s.operation)}},[e,tt,st,Qe,at,r,h,d,I,Ye,i]);return m?We?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[Le?null:t.jsx(T,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e(Le?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),Le?t.jsx(W,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{oe&&x({directory:oe,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):B===null||B===!0&&!u?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?t.jsx(Ha,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{m&&de(m,{force:!0})},emptyStateFooter:te.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:Se("flex h-full flex-col overflow-hidden"),children:[t.jsx($a,{directory:r??"",status:u,localBranches:kt,remoteBranches:ot,branchInfo:_?.branches,syncAction:Ws,remotes:ze,onFetch:s=>dr("fetch",s),onSync:s=>dr("sync",s),onRemoveRemote:un,removingRemoteName:Zr,onCheckoutBranch:fn,onCreateBranch:hn,onRenameBranch:gn,activeIdentityProfile:yn,availableIdentities:wn,onSelectIdentity:pn,isApplyingIdentity:zr,isWorktreeMode:!!G,onOpenHistory:()=>Ot("history"),onOpenGraph:()=>Ot("graph"),onOpenStashes:Sn,onOpenUpdateBranch:hr?()=>rr(!0):void 0,onOpenReintegrateCommits:ct?()=>nr(!0):void 0,pullRequest:Re?.pr??null,prChecks:Re?.checks??null,onOpenPullRequest:r?()=>xe(r,"pr"):void 0,repositoryOptions:r!==m&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==m?r:null,onSelectRepository:r!==m&&m?s=>ke(m,s):void 0,repositoryRoot:r!==m?m:void 0}),m&&(u?.mergeInProgress?.head||u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto)&&t.jsx(Ii,{mergeInProgress:u?.mergeInProgress,rebaseInProgress:u?.rebaseInProgress,onContinue:En,onAbort:Mn,onResolveWithAI:Tn,conflictCount:Dn,isLoading:le}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Se("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Br,{as:La,ref:$s,outerClassName:"flex-1 min-h-0",className:Se("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(it?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ua,{groups:kn,diffStats:u?.diffStats,revertingPaths:is,isRevertingAll:os,onVisiblePathsChange:Tr,onRevertAll:Cn,onRevertDirectory:Nn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ka,{stagedCount:bn,commitMessage:Ue,onCommitMessageChange:$e,generatedHighlights:ls,onInsertHighlights:Vn,onGenerateMessage:mn,isGeneratingMessage:Wr,onCommit:()=>ur({pushAfter:!1}),onCommitAndPush:()=>ur({pushAfter:!0}),commitAction:Us,hasPendingIndexMutation:Ur,gitmojiEnabled:fe,onOpenGitmojiPicker:()=>ss(!0)})]}):t.jsx(oi,{onOpenStashes:()=>rs(!0)})})})})})}),t.jsx(mt,{open:Qr,onOpenChange:s=>{!s&&ir!==null||rr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:u?.current??""}),"."]})]}),hr?t.jsx(Pi,{mode:"bare",currentBranch:u?.current,localBranches:kt,remoteBranches:ot,defaultTargetBranch:xn,onMerge:Fn,onRebase:Rn,disabled:vn,isOperating:ir!==null,operationLogs:en,onOperationComplete:Pn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Xr,onOpenChange:nr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:ct?t.jsxs("span",{className:"font-mono text-foreground",children:[ct.sourceBranch," → ",er]}):null})]}),ct?t.jsx(ai,{repoRoot:ct.repoRoot,sourceBranch:ct.sourceBranch,worktreeMetadata:ct.worktreeMetadata,localBranches:kt,defaultTargetBranch:er,refreshKey:Hr,showHeader:!1,onRefresh:()=>{r&&(h(r,i),d(r,i),I(r,i,Ye))}},ct.worktreeMetadata.path):null]})}),t.jsx(mt,{open:Ee!==null,onOpenChange:s=>{s||Ot(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(ft,{children:e(Ee==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Ee==="graph"){on(s=>s+1);return}r&&I(r,i,Ye)},disabled:Ee==="graph"?bs:ae,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(T,{name:"refresh",className:Se("size-4",(Ee==="graph"?bs:ae)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(bt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(pi,{mode:Ee==="graph"?"graph":"history",log:Ee==="graph"?rn??X:X,isLogLoading:Ee==="graph"&&bs||ae,logMaxCount:Ee==="graph"?vs:Ye,onLogMaxCountChange:Ee==="graph"?On:An,expandedCommitHashes:ms,onToggleCommit:dn,commitFilesMap:Lt,loadingCommitHashes:At,onCopyHash:cn,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Ee==="graph"?null:Yr,onConflict:Ee==="graph"?Gn:void 0,onActionSuccess:Ee==="graph"?zn:void 0})})]})}),t.jsx(ii,{open:Ar,onOpenChange:rs,directory:r,hasUncommittedChanges:(u?.files?.length??0)>0,hasStagedChanges:Je.length>0,uncommittedFileCount:u?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&K(r),await re(!1),await pe()}}),t.jsx(mt,{open:Lr,onOpenChange:ss,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(gt,{className:"px-4 pt-4",children:t.jsx(ft,{children:e("gitView.gitmoji.title")})}),t.jsxs(zs,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(Gs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:tr,onValueChange:sr}),t.jsxs(_s,{children:[t.jsx(Hs,{children:e("gitView.gitmoji.empty")}),t.jsx(Qt,{children:Bt(He,tr,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Xt,{onSelect:()=>In(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(vi,{open:tn,onOpenChange:Qe,conflictFiles:sn,directory:r,operation:Gt,onAbort:Bn,onClearState:Ke}),t.jsx(Ja,{open:_t!==null,onOpenChange:s=>{s||St(null)},targetBranch:_t??"",changedFileCount:u?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const a=_t;if(!a||!r)return;const c=u?.current??null;await i.createGitCommit(r,s,{addAll:!0}),K(r);let j=null;if(n){const L=u?.tracking?.split("/")[0],Z=ze.find($=>$.name===L)??ze[0];try{if(!Z)throw new Error(e("mobile.changes.noRemote"));await i.gitPush(r,u?.tracking?{remote:Z.name}:{remote:Z.name,branch:c??void 0,options:["--set-upstream"]}),j=Z.name}catch($){console.error("Push after commit failed:",$),v.error(e("gitView.dirtySwitch.pushFailed")),await re(),await pe(),St(null);return}}v.success(j?e("gitView.toast.pushedToUpstream",{name:j}):c?e("gitView.dirtySwitch.committedNotPushed",{branch:c}):e("gitView.toast.commitCreated")),await re(),await pe(),St(null),await Ps(a)},onGenerateMessage:async()=>{if(!r)return"";const s=(u?.files??[]).map(c=>c.path).sort(),{message:n}=await fr(r,s),a=n.subject?.trim()??"";if(a&&fe&&He.length>0){const c=Pr(a,He);if(c&&!a.startsWith(c.code)&&!a.startsWith(c.emoji))return`${c.code} ${a}`}return a},onRevertAndSwitch:async()=>{const s=_t;if(!s||!r)return;const n=(u?.files??[]).map(c=>c.path);await It(n,!0,"all");const a=await i.getGitStatus(r);if(!a.isClean&&(a.files?.length??0)>0){v.error(e("gitView.dirtySwitch.revertIncomplete"));return}St(null),await Ps(s)}}),t.jsx(Vi,{open:ln,onOpenChange:js,operation:Cs,targetBranch:Ns,onConfirm:Ln})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{dc as GitView};
|