@openchamber/web 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
- package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
- package/dist/assets/DiffView-D5cvbEPb.js +4 -0
- package/dist/assets/FilesView-DPU8aNPL.js +17 -0
- package/dist/assets/GitView-Ct6xWrVH.js +6 -0
- package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-osju7J70.js} +1 -1
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
- package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-Dan3mADn.js} +1 -1
- package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
- package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
- package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
- package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
- package/dist/assets/ToolOutputDialog-DrCa1JRk.js +15 -0
- package/dist/assets/ToolPartDiffPreview-B_tfvlNF.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-D9Q4lr5x.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-Gi1d5eU1.js} +1 -1
- package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
- package/dist/assets/de-B_LdJwEM.js +9 -0
- package/dist/assets/es-CubfsAYV.js +15 -0
- package/dist/assets/fr-5qJM0nFS.js +13 -0
- package/dist/assets/index-BW82eK5v.css +1 -0
- package/dist/assets/index-Brm3X9rs.js +1 -0
- package/dist/assets/index-rlLjZUM5.js +7 -0
- package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-pH9kAJQH.js} +1 -1
- package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-CVKy_dgB.js} +1 -1
- package/dist/assets/ja-DJYIBUlH.js +15 -0
- package/dist/assets/ko-DcUBkB7y.js +15 -0
- package/dist/assets/main-DLBxKIoX.js +926 -0
- package/dist/assets/main-vUCh0VB0.js +2 -0
- package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
- package/dist/assets/miniChat-BlzGEYgE.js +2 -0
- package/dist/assets/mobile-CkX6H-IT.js +2 -0
- package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BCTsE43U.js} +3 -3
- package/dist/assets/pl-rB6BLcio.js +15 -0
- package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
- package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
- package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-BgTPSITe.js} +1 -1
- package/dist/assets/uk-INZlFD9A.js +15 -0
- package/dist/assets/useAppFontEffects-Cll4gnsh.js +7268 -0
- package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
- package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-_6j2xOWl.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-DCLjCO9n.js → web-components-DLnGY4fs.js} +4 -4
- package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
- package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
- package/dist/index.html +6 -5
- package/dist/mini-chat.html +5 -4
- package/dist/mobile.html +5 -4
- package/package.json +5 -7
- package/server/index.js +44 -0
- package/server/lib/agent-memory/project-resolution.js +10 -1
- package/server/lib/agent-memory/project-resolution.test.js +9 -0
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/routes.test.js +76 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +85 -5
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/feature-routes-runtime.js +5 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +15 -0
- package/server/lib/opencode/settings-helpers.test.js +22 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +32 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +2 -0
- package/server/lib/project-context/runtime.js +7 -2
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -1
- package/server/lib/quota/providers/claude/index.js +2 -2
- package/server/lib/quota/providers/index.js +1 -7
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +4 -4
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +51 -8
- package/server/lib/small-model/index.test.js +73 -3
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/dist/assets/CommitSection-D9cV-qR9.js +0 -1
- package/dist/assets/DiagramEditor-B9NCadU7.js +0 -1
- package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
- package/dist/assets/DiffView-BWNq-0ov.js +0 -4
- package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
- package/dist/assets/GitView-DsWXqWx3.js +0 -6
- package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
- package/dist/assets/OnboardingScreen-CDjgzxEe.js +0 -1
- package/dist/assets/PierreDiffViewer-D_Gt4A_6.js +0 -136
- package/dist/assets/PlanView-UvuxIl9-.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
- package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
- package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
- package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
- package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
- package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +0 -1
- package/dist/assets/de-DbV6CLxv.js +0 -9
- package/dist/assets/es-CVDlyzZ4.js +0 -15
- package/dist/assets/fr-Czc-p0g-.js +0 -13
- package/dist/assets/index-1OhiMDBz.css +0 -1
- package/dist/assets/index-BSvmTvZl.js +0 -1
- package/dist/assets/index-DzriVon2.js +0 -7
- package/dist/assets/ja-dwc9NM_S.js +0 -15
- package/dist/assets/ko-Ds1DZ8FX.js +0 -15
- package/dist/assets/main-BF51IOVF.js +0 -921
- package/dist/assets/main-D7UPARut.js +0 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
- package/dist/assets/miniChat-BISXSGOo.js +0 -2
- package/dist/assets/mobile-BnYxVuvw.js +0 -2
- package/dist/assets/pl-CLiTO7i-.js +0 -15
- package/dist/assets/pt-BR-GIimJgpK.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
- package/dist/assets/renderMobileApp-BiMbzPq9.js +0 -25
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
- package/dist/assets/scheduledTasksApi-01zzfzqH.js +0 -1
- package/dist/assets/uk-DLfgD1ki.js +0 -15
- package/dist/assets/useAppFontEffects-CbzHzFop.js +0 -7271
- package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
- package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
- package/dist/assets/zh-CN-DkeP5awK.js +0 -15
- package/dist/assets/zh-TW-BocaFm3d.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -72
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{R as n,j as s,f as Gt}from"./vendor-react-BUCujlKS.js";import{Q as Kn,R as Hn,S as qn,T as _n,ai as vi,n as ze,u as he,cT as Xn,B as wi,v as Jn,r as bi,V as yi,e as Qn,cR as Yn,aH as Zn,cS as ea,a as ta}from"./index-DzriVon2.js";import{f as Ds,S as Ts,B as S,h as O,V as sa,L as ra,aV as ia,a0 as na,a1 as aa,b_ as oa,gX as ji,gs as la,t as I,l as Fi,aa as sr,bV as Fs,cq as ca,b as da,gY as rr,ab as Ni,gZ as Ci,bW as Si,bX as ua,fO as fa,g_ as ma,br as ha,g$ as pa,bs as Ii,bt as Oi,bu as Bi,bv as $i,bw as Wi,bx as Ui,I as g,aU as cr,aR as dr,ad as Cs,aT as ur,aQ as Ss,aX as ht,aY as pt,aZ as gt,bU as ir,ac as nr,bQ as ki,by as ga,bz as xa,gq as ar,g as Vs,aS as va,a_ as wa}from"./useAppFontEffects-CbzHzFop.js";import{w as ba,x as ya,y as ja,z as Fa,A as Na}from"./runtimeEndpointReset-BMBRhIbf.js";import{c as Ti,s as Ca,C as Vi,P as or}from"./shikiHighlight-DXYW46vW.js";import{a as Sa}from"./vendor-codemirror-state-C9awkmn-.js";import{E as kt}from"./vendor-codemirror-view-CiLROUVV.js";import{F as ka,J as Ta}from"./JsonTreeView-h4dHASlq.js";import{ensurePierreThemeRegistered as Di,getResolvedShikiTheme as Va}from"./appThemeRegistry-BK0dHKa6.js";import{u as Ns,c as Da,e as Ea}from"./scheduledTasksApi-01zzfzqH.js";import{D as Ra}from"./DiagramEditor-B9NCadU7.js";import{u as Pa,n as Ma}from"./useInlineCommentController-CegKdDXi.js";import{b as za}from"./CodeMirrorCommentWidgets-DAvopJvy.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.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-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-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.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-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.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-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.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"./Virtualizer-X_7XPoTH.js";import"./isFilePlainText-Dwq6ILxo.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Ct3Q0DsD.js";const La=(d,e)=>{if(!e)return null;const r=Number.parseInt(d.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Ei=(d,e)=>{const r=d.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},Ri=(d,e,r)=>{const m=d.state.doc.line(e),x=Math.max(1,Math.min(r,m.length+1)),v=m.from+x-1;d.dispatch({selection:Sa.cursor(v),effects:kt.scrollIntoView(v,{y:"center"})})};function Aa({open:d,onOpenChange:e,view:r,variant:m="overlay"}){const{t:x}=Ds(),[v,y]=n.useState(""),b=n.useRef(null),h=n.useRef(!1),j=n.useRef(null),p=n.useRef(null),F=n.useMemo(()=>La(v,r),[v,r]);n.useEffect(()=>{!d||!r||(h.current=!1,b.current=Ei(r,r.state.selection),y(""))},[d,r]),n.useEffect(()=>{d&&window.requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},[d]),n.useEffect(()=>{if(!(!d||!r||!b.current)){if(F===null){const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})});return}Ri(r,F,b.current.character)}},[F,d,r]);const z=n.useCallback(()=>{if(!r||h.current||!b.current)return;const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})})},[r]),E=n.useCallback(o=>{o||z(),e(o)},[e,z]),N=n.useCallback(()=>{!r||F===null||!b.current||(h.current=!0,Ri(r,F,b.current.character),e(!1),r.focus())},[F,e,r]);n.useEffect(()=>{if(!d)return;const o=W=>{const _=j.current,L=W.target;!_||!(L instanceof Node)||_.contains(L)||E(!1)},q=W=>{W.key==="Escape"&&(W.preventDefault(),E(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",q,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",q,!0)}},[E,d,m]);const R=n.useMemo(()=>{if(!r)return x("goToLineDialog.helper.editorUnavailable");if(F===null){const o=b.current??Ei(r,r.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:F})},[F,x,r]);return m==="inline"?d?s.jsxs("div",{ref:j,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(S,{variant:"outline",size:"xs",onClick:N,disabled:!r||F===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:j,className:O("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",d?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:R})]})})}function Ia(d){return!(!d.autoSaveEnabled||!d.isDirty||!d.canWrite||d.isSaving||d.fileLoading||d.isNonEditableBinary||!d.selectedFilePath||d.loadedFilePath!==d.selectedFilePath)}function Oa(d){return d.selectedFilePath?d.isDirty?!(d.fileLoading||d.loadedFilePath!==d.selectedFilePath||d.isNonEditableBinary||d.draftContent===""&&d.fileContent!==""&&d.loadedFilePath!==d.selectedFilePath):!0:!1}const Ba=d=>{const e=M(d);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const m=e.slice(0,r);return/^[A-Za-z]:$/.test(m)?`${m}/`:m},$a=d=>{const e=Gt.c(8),{label:r,iconDataUrl:m}=d,[x,v]=n.useState(!1);let y;e[0]!==r?(y=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=y):y=e[1];const b=y;if(m&&!x){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>v(!0),e[2]=p):p=e[2];let F;return e[3]!==m?(F=s.jsx("img",{src:m,alt:"",className:"size-4 rounded-sm",onError:p}),e[3]=m,e[4]=F):F=e[4],F}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=O("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let j;return e[6]!==b?(j=s.jsx("span",{className:h,children:b}),e[6]=b,e[7]=j):j=e[7],j},Wa=d=>d.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),M=d=>{if(!d)return"";const e=d.replace(/\\/g,"/"),r=e.startsWith("//");let m=e.replace(/\/+/g,"/");r&&!m.startsWith("//")&&(m=`/${m}`);const x=m==="/",v=/^[A-Za-z]:\/$/.test(m);return!x&&!v&&(m=m.replace(/\/+$/,"")),m},Ua=d=>d.startsWith("/")||d.startsWith("//")||/^[A-Za-z]:\//.test(d),Ut=d=>/^[A-Za-z]:\//.test(d)?d.toLowerCase():d,is=(d,e)=>{const r=M(e),m=M(d);if(!r||!m)return!1;const x=Ut(r),v=Ut(m);return v===x||v.startsWith(`${x}/`)},Pi=(d,e)=>{const r=M(e),m=M(d);if(!is(m,r))return[];const v=m.slice(r.length).replace(/^\//,"").split("/"),y=[];let b=r;for(let h=0;h<v.length-1;h++)b=b?`${b}/${v[h]}`:v[h],y.push(b);return y},ks=(d,e)=>{if(!e)return"";const r=M(e);if(!d||!is(r,d))return r;const m=r.slice(d.length);return m.startsWith("/")?m.slice(1):m},Ga=new Set(["node_modules"]),Ka=d=>{const e=Gt.c(3),{status:r}=d;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=m):m=e[0];const x=m[r];let v;return e[1]!==x?(v=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=v):v=e[2],v},Mi=d=>{const e=Gt.c(11),{name:r}=d,m=n.useRef(null),x=n.useRef(null),[v,y]=n.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const z=m.current,E=x.current;if(!z||!E)return;const N=()=>{y(E.scrollWidth>z.clientWidth+1)};N();const R=new ResizeObserver(N);return R.observe(z),R.observe(E),()=>{R.disconnect()}},e[0]=b):b=e[0];let h;e[1]!==r?(h=[r],e[1]=r,e[2]=h):h=e[2],n.useLayoutEffect(b,h);let j;e[3]!==r?(j=s.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=j):j=e[4];let p;e[5]!==r||e[6]!==v?(p=v?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=v,e[7]=p):p=e[7];let F;return e[8]!==j||e[9]!==p?(F=s.jsxs("span",{ref:m,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,p]}),e[8]=j,e[9]=p,e[10]=F):F=e[10],F},Ha=d=>Ga.has(d),qa=d=>{const e=M(d);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},_a=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},zi=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},rs=2e5,Xa=d=>{let e=0,r=0;for(let m=0;m<d.length;m+=1)d.charCodeAt(m)===10&&(m>0&&d.charCodeAt(m-1)===13?e+=1:r+=1);return e>r?`\r
|
|
2
|
-
`:`
|
|
3
|
-
`},Gi=d=>d.replace(/\r\n/g,`
|
|
4
|
-
`).replace(/\r/g,`
|
|
5
|
-
`),Ja=(d,e)=>{const r=Gi(d);return e===`\r
|
|
6
|
-
`?r.replace(/\n/g,`\r
|
|
7
|
-
`):r},Ki=(d,e)=>s.jsx(Cs,{filePath:d,extension:e}),Li=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Qa=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},lr=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ya=d=>{const e=Gt.c(76),{node:r,root:m,isExpanded:x,isActive:v,isMobile:y,isBrowserClient:b,alwaysShowActions:h,status:j,badge:p,permissions:F,downloadFile:z,contextMenuPath:E,setContextMenuPath:N,rightClickMenuPath:R,setRightClickMenuPath:o,onSelect:q,onToggle:W,onRevealPath:_,onOpenDialog:L}=d,{t:T}=Ds(),V=r.type==="directory",{canRename:le,canCreateFile:Y,canCreateFolder:Z,canDelete:A,canReveal:ce}=F,Le=!V&&!!z,U=ce&&!b,X=le||Y||Z||A||Le||U;let ee;e[0]!==X||e[1]!==r.path||e[2]!==o?(ee=fe=>{X&&(fe?.preventDefault(),o(r.path))},e[0]=X,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const pe=ee;let te;e[4]!==V||e[5]!==r||e[6]!==q||e[7]!==W?(te=()=>{V?W(r.path):q(r)},e[4]=V,e[5]=r,e[6]=q,e[7]=W,e[8]=te):te=e[8];const ge=te;let de;e[9]!==r.path||e[10]!==N||e[11]!==o?(de=fe=>{fe.stopPropagation(),o(null),N(r.path)},e[9]=r.path,e[10]=N,e[11]=o,e[12]=de):de=e[12];const rt=de;let Tt;e[13]!==Y||e[14]!==Z||e[15]!==A||e[16]!==le||e[17]!==U||e[18]!==z||e[19]!==b||e[20]!==V||e[21]!==r||e[22]!==L||e[23]!==_||e[24]!==m||e[25]!==T?(Tt=fe=>{const{Item:ve,Separator:wt}=fe;return s.jsxs(s.Fragment,{children:[le&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("rename",r)},children:[s.jsx(g,{name:"edit",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),Vs(r.path).then(we=>{if(we.ok){I.success(T("sidebarFilesTree.toast.pathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation();const we=ks(m,r.path)||r.path;Vs(we).then(Je=>{if(Je.ok){I.success(T("filesView.toast.relativePathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy-2",className:"mr-2 size-4"})," ",T("filesView.tree.menu.copyRelativePath")]}),!V&&z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),z(r.path).catch(we=>{console.error("Download failed:",we),I.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"})," ",T(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),_(r.path)},children:[s.jsx(g,{name:"folder-received",className:"mr-2 size-4"})," ",T(wa())]}),V&&(Y||Z)&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),Y&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFile",r)},children:[s.jsx(g,{name:"file-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFile")]}),Z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFolder",r)},children:[s.jsx(g,{name:"folder-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFolder")]})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(g,{name:"delete-bin",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[13]=Y,e[14]=Z,e[15]=A,e[16]=le,e[17]=U,e[18]=z,e[19]=b,e[20]=V,e[21]=r,e[22]=L,e[23]=_,e[24]=m,e[25]=T,e[26]=Tt):Tt=e[26];const Xe=Tt,G=R===r.path;let Fe;e[27]!==r.path||e[28]!==o?(Fe=fe=>o(fe?r.path:null),e[27]=r.path,e[28]=o,e[29]=Fe):Fe=e[29];const xt=y?void 0:pe;let Ae;e[30]!==xt?(Ae=s.jsx("div",{className:"group relative flex items-center",onContextMenu:xt}),e[30]=xt,e[31]=Ae):Ae=e[31];const Ie=y?void 0:pe,vt=v?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let xe;e[32]!==vt?(xe=O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",vt),e[32]=vt,e[33]=xe):xe=e[33];let Oe;e[34]!==V||e[35]!==x||e[36]!==r.extension||e[37]!==r.path?(Oe=V?x?s.jsx(g,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(g,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ki(r.path,r.extension),e[34]=V,e[35]=x,e[36]=r.extension,e[37]=r.path,e[38]=Oe):Oe=e[38];let ue;e[39]!==r.name||e[40]!==r.path?(ue=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=ue):ue=e[41];let Ne;e[42]!==V||e[43]!==j?(Ne=!V&&j&&s.jsx(Ka,{status:j}),e[42]=V,e[43]=j,e[44]=Ne):Ne=e[44];let it;e[45]!==p||e[46]!==V?(it=V&&p&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[p.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",p.modified]}),p.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",p.added]})]}),e[45]=p,e[46]=V,e[47]=it):it=e[47];let nt;e[48]!==ge||e[49]!==xe||e[50]!==Oe||e[51]!==ue||e[52]!==Ne||e[53]!==it||e[54]!==Ie?(nt=s.jsxs("button",{type:"button",onClick:ge,onContextMenu:Ie,className:xe,children:[Oe,ue,Ne,it]}),e[48]=ge,e[49]=xe,e[50]=Oe,e[51]=ue,e[52]=Ne,e[53]=it,e[54]=Ie,e[55]=nt):nt=e[55];let Be;e[56]!==h||e[57]!==E||e[58]!==rt||e[59]!==X||e[60]!==y||e[61]!==r.path||e[62]!==Xe||e[63]!==N?(Be=X&&s.jsx("div",{className:O("absolute right-1 top-1/2 -translate-y-1/2",h?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(cr,{open:E===r.path,onOpenChange:fe=>N(fe?r.path:null),children:[s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"icon",className:"size-6",onClick:rt,children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})}),s.jsx(ur,{align:"end",side:"bottom",onCloseAutoFocus:()=>N(null),children:Xe({Item:Ss,Separator:va})})]})}),e[56]=h,e[57]=E,e[58]=rt,e[59]=X,e[60]=y,e[61]=r.path,e[62]=Xe,e[63]=N,e[64]=Be):Be=e[64];let $e;e[65]!==nt||e[66]!==Be||e[67]!==Ae?($e=s.jsxs(Fa,{render:Ae,children:[nt,Be]}),e[65]=nt,e[66]=Be,e[67]=Ae,e[68]=$e):$e=e[68];let We;e[69]!==Xe?(We=s.jsx(ba,{className:"min-w-[180px]",children:Xe({Item:ja,Separator:ya})}),e[69]=Xe,e[70]=We):We=e[70];let at;return e[71]!==$e||e[72]!==We||e[73]!==G||e[74]!==Fe?(at=s.jsxs(Na,{open:G,onOpenChange:Fe,children:[$e,We]}),e[71]=$e,e[72]=We,e[73]=G,e[74]=Fe,e[75]=at):at=e[75],at},Za=d=>{const e=Gt.c(83),{activeDialog:r,dialogData:m,dialogInputValue:x,onDialogInputChange:v,isDialogSubmitting:y,onDialogSubmit:b,onClose:h,inputRef:j}=d,{t:p}=Ds(),F=!!r;let z;e[0]!==h?(z=de=>!de&&h(),e[0]=h,e[1]=z):z=e[1];let E;e[2]!==r||e[3]!==p?(E=r==="createFile"&&p("filesView.dialog.createFile.title"),e[2]=r,e[3]=p,e[4]=E):E=e[4];let N;e[5]!==r||e[6]!==p?(N=r==="createFolder"&&p("filesView.dialog.createFolder.title"),e[5]=r,e[6]=p,e[7]=N):N=e[7];let R;e[8]!==r||e[9]!==p?(R=r==="rename"&&p("filesView.dialog.rename.title"),e[8]=r,e[9]=p,e[10]=R):R=e[10];let o;e[11]!==r||e[12]!==p?(o=r==="delete"&&p("filesView.dialog.delete.title"),e[11]=r,e[12]=p,e[13]=o):o=e[13];let q;e[14]!==E||e[15]!==N||e[16]!==R||e[17]!==o?(q=s.jsxs($i,{children:[E,N,R,o]}),e[14]=E,e[15]=N,e[16]=R,e[17]=o,e[18]=q):q=e[18];let W;e[19]!==r||e[20]!==m?.path||e[21]!==p?(W=r==="createFile"&&p("filesView.dialog.createFile.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[19]=r,e[20]=m?.path,e[21]=p,e[22]=W):W=e[22];let _;e[23]!==r||e[24]!==m?.path||e[25]!==p?(_=r==="createFolder"&&p("filesView.dialog.createFolder.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[23]=r,e[24]=m?.path,e[25]=p,e[26]=_):_=e[26];let L;e[27]!==r||e[28]!==m?.name||e[29]!==p?(L=r==="rename"&&p("filesView.dialog.rename.description",{name:m?.name??""}),e[27]=r,e[28]=m?.name,e[29]=p,e[30]=L):L=e[30];let T;e[31]!==r||e[32]!==m?.name||e[33]!==p?(T=r==="delete"&&p("filesView.dialog.delete.description",{name:m?.name??""}),e[31]=r,e[32]=m?.name,e[33]=p,e[34]=T):T=e[34];let V;e[35]!==L||e[36]!==T||e[37]!==W||e[38]!==_?(V=s.jsxs(Wi,{children:[W,_,L,T]}),e[35]=L,e[36]=T,e[37]=W,e[38]=_,e[39]=V):V=e[39];let le;e[40]!==V||e[41]!==q?(le=s.jsxs(Bi,{children:[q,V]}),e[40]=V,e[41]=q,e[42]=le):le=e[42];let Y;e[43]!==r||e[44]!==x||e[45]!==j||e[46]!==v||e[47]!==b||e[48]!==p?(Y=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Ts,{value:x,onChange:de=>v(de.target.value),placeholder:p(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:de=>{de.key==="Enter"&&b()},ref:j})}),e[43]=r,e[44]=x,e[45]=j,e[46]=v,e[47]=b,e[48]=p,e[49]=Y):Y=e[49];let Z;e[50]!==p?(Z=p("filesView.dialog.cancel"),e[50]=p,e[51]=Z):Z=e[51];let A;e[52]!==y||e[53]!==h||e[54]!==Z?(A=s.jsx(S,{variant:"outline",onClick:h,disabled:y,children:Z}),e[52]=y,e[53]=h,e[54]=Z,e[55]=A):A=e[55];const ce=r==="delete"?"destructive":"default";let Le;e[56]!==b?(Le=()=>{b()},e[56]=b,e[57]=Le):Le=e[57];let U;e[58]!==r||e[59]!==x||e[60]!==y?(U=y||r!=="delete"&&!x.trim(),e[58]=r,e[59]=x,e[60]=y,e[61]=U):U=e[61];let X;e[62]!==r||e[63]!==y||e[64]!==p?(X=y?s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}):p(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=y,e[64]=p,e[65]=X):X=e[65];let ee;e[66]!==ce||e[67]!==Le||e[68]!==U||e[69]!==X?(ee=s.jsx(S,{variant:ce,onClick:Le,disabled:U,children:X}),e[66]=ce,e[67]=Le,e[68]=U,e[69]=X,e[70]=ee):ee=e[70];let pe;e[71]!==A||e[72]!==ee?(pe=s.jsxs(Ui,{children:[A,ee]}),e[71]=A,e[72]=ee,e[73]=pe):pe=e[73];let te;e[74]!==j||e[75]!==le||e[76]!==Y||e[77]!==pe?(te=s.jsxs(Oi,{initialFocus:j,children:[le,Y,pe]}),e[74]=j,e[75]=le,e[76]=Y,e[77]=pe,e[78]=te):te=e[78];let ge;return e[79]!==F||e[80]!==z||e[81]!==te?(ge=s.jsx(Ii,{open:F,onOpenChange:z,children:te}),e[79]=F,e[80]=z,e[81]=te,e[82]=ge):ge=e[82],ge},Ai=(d,e,r)=>{const m=Gt.c(8),[x,v]=n.useState(""),[y,b]=n.useState(0);let h,j;m[0]!==d||m[1]!==r||m[2]!==e?(h=()=>{if(!d){v("");return}let F=!1;v("");const z=Qn(),E=Yn(z);Zn(z).then(R=>{F||!R||(v(d),e(null))}).catch(R=>{F||(e(R instanceof Error?R.message:r),v(d))});const N=ea(()=>{F||(v(d),b(eo),e(null))});return()=>{F=!0,E(),N()}},j=[d,e,r],m[0]=d,m[1]=r,m[2]=e,m[3]=h,m[4]=j):(h=m[3],j=m[4]),n.useEffect(h,j);let p;return m[5]!==y||m[6]!==x?(p={readyKey:x,nonce:y},m[5]=y,m[6]=x,m[7]=p):p=m[7],p},wc=({mode:d="full"})=>{const{t:e}=Ds(),{files:r,runtime:m}=sa(),{currentTheme:x,availableThemes:v,lightThemeId:y,darkThemeId:b}=ra(),{isMobile:h,isTablet:j,screenWidth:p}=ia(),F=Kn(m.platform),z=h||j,E=Hn(),N=qn(),R=na()??"",o=M(R.trim()),q=d!=="editor-only",W=d==="editor-only"&&!h,_=_n(t=>t.searchFiles),L=aa(R),[T,V]=n.useState(""),le=oa(T,200),Y=n.useRef(null),[Z,A]=n.useState(!1),[ce,Le]=n.useState(!0),[U,X]=n.useState(!1),[ee,pe]=n.useState(!1),[te,ge]=n.useState(!1),de=n.useRef(null),rt=n.useRef(0),Tt=n.useCallback(t=>{rt.current=Math.max(0,rt.current+(t?1:-1))},[]),Xe=n.useCallback(t=>t instanceof Element?t.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);n.useEffect(()=>{if(!te)return;const t=i=>{rt.current>0||Xe(i.target)||de.current&&!de.current.contains(i.target)&&ge(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[Xe,te]);const[G,Fe]=n.useState("edit"),[xt,Ae]=n.useState("edit"),[Ie,vt]=n.useState("tree"),[xe,Oe]=n.useState("edit"),[ue,Ne]=n.useState("preview"),[it,nt]=n.useState(0),Be=n.useRef({}),$e=n.useRef({}),We=n.useRef({}),at=n.useRef({}),fe=n.useMemo(()=>v.find(t=>t.metadata.id===y)??vi(!1),[v,y]),ve=n.useMemo(()=>v.find(t=>t.metadata.id===b)??vi(!0),[v,b]);n.useEffect(()=>{Di(fe),Di(ve)},[fe,ve]);const wt=n.useMemo(()=>[],[]),C=ze(t=>o?t.byRoot[o]?.openPaths??wt:wt),we=ze(t=>o?t.byRoot[o]?.selectedPath??null:null),Je=ze(t=>o?t.byRoot[o]?.expandedPaths??wt:wt),Vt=ze(t=>t.removeOpenPath),ot=ze(t=>t.removeOpenPathsByPrefix),fr=ze(t=>t.removeExpandedPathsByPrefix),se=ze(t=>t.setSelectedPath),mr=ze(t=>t.toggleExpandedPath),ns=ze(t=>t.expandPaths),Dt=n.useCallback(t=>{const i=M(t),a=i.split("/"),c=a[a.length-1]||i,u=c.includes(".")?c.split(".").pop()?.toLowerCase():void 0;return{name:c,path:i,type:"file",extension:u}},[]),Et=n.useMemo(()=>C.map(Dt),[C,Dt]),Es=n.useMemo(()=>{if(we){const t=Ut(we);if(C.some(i=>Ut(i)===t))return we}return C[0]??null},[C,we]),l=n.useMemo(()=>Es?Dt(Es):null,[Es,Dt]),Ue=l?.path??"";n.useEffect(()=>{if(!o||!we)return;const t=Ut(we);C.some(a=>Ut(a)===t)||se(o,C[0]??null)},[C,o,we,se]);const as=!!(o&&Ue&&!is(Ue,o)),hr=as?ji(Ue):void 0,Ce=n.useMemo(()=>({allowOutsideWorkspace:d==="editor-only"&&as,outsideFileGrant:hr,directory:o||void 0}),[d,as,hr,o]),Rs=n.useRef(null),[pr,Hi]=n.useState({left:!1,right:!1}),gr=n.useCallback(()=>{const t=Rs.current;t&&Hi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),xr=n.useRef(gr);xr.current=gr,n.useEffect(()=>{const t=Rs.current;if(!t)return;const i=()=>xr.current();i(),t.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(t),()=>{t.removeEventListener("scroll",i),a.disconnect()}},[Et.length]);const[vr,Ps]=n.useState({}),[os,Kt]=n.useState({}),Se=n.useRef(new Set),ke=n.useRef(new Set),Qe=n.useRef(new Map),wr=n.useRef(0),[br,ls]=n.useState([]),[qi,cs]=n.useState(!1),[k,H]=n.useState(""),{isPlaying:ds,play:_i,stop:Xi}=la(),[Re,Ye]=n.useState(!1),[Ze,J]=n.useState(null),[Ji,Te]=n.useState(""),[be,K]=n.useState(null),[B,Q]=n.useState(""),[Rt,Ms]=n.useState(!1),[yr,Qi]=n.useState(`
|
|
8
|
-
`),Yi=n.useRef(null),Ge=n.useRef(null),ye=n.useRef(null),lt=n.useRef(""),Ht=n.useRef(""),et=n.useRef(null),jr=n.useRef(null),Ke=n.useRef(null),qt=n.useRef(0),Pt=n.useRef(null),[us,Zi]=n.useState(0),[en,Mt]=n.useState("idle"),[tn,fs]=n.useState(!1),[_t,Fr]=n.useState(!1),re=he(t=>t.autoSaveEnabled),sn=he(t=>t.setAutoSaveEnabled),[zs,zt]=n.useState(!1),Lt=n.useRef(null),Xt=n.useRef(null),Jt=n.useRef(null),bt=n.useRef(!1),Qt=n.useRef(null),Yt=n.useRef(null),Pe=n.useRef(null),rn=n.useRef(null),[nn,Ls]=n.useState(0),At=n.useRef(null),yt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{At.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(At.current),At.current=null)},[]);const[jt,As]=n.useState(null),[Ft,an]=n.useState(null),[ct,Nr]=n.useState(""),[on,Is]=n.useState(!1),[ln,cn]=n.useState(null),[dn,un]=n.useState(null),[fn,Cr]=n.useState(!1),[mn,Sr]=n.useState(!1),[hn,Os]=n.useState(!1),kr=!!r.writeFile,Tr=!!r.createDirectory,Vr=!!r.rename,Dr=!!r.delete,Er=!!r.revealPath,pn=Ns(t=>t.availableApps),gn=Ns(t=>t.isCacheStale),Rr=Ns(t=>t.initialize),xn=Ns(t=>t.loadInstalledApps);n.useEffect(()=>{Rr()},[Rr]);const vn=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{I.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),wn=n.useCallback(async t=>{if(!l?.path||await Xn(l.path,t.id,t.appName)||await wi(l.path,t.appName))return;const c=Ba(l.path)||o;c&&await wi(c,t.appName)||I.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,l?.path,e]),Bs=n.useCallback((t,i)=>{As(t),an(i),Nr(t==="rename"&&i.name||""),Is(!1)},[]),[P,Me]=n.useState(null),It=n.useRef(!1),dt=n.useRef(null),[Pr,Ot]=n.useState(!1),He=he(t=>t.setMainTabGuard),qe=he(t=>t.pendingFileNavigation),ms=he(t=>t.setPendingFileNavigation),$s=he(t=>t.pendingFileFocusPath),Ws=he(t=>t.setPendingFileFocusPath),Mr=he(t=>t.shortcutOverrides),zr=he(t=>t.fileEditorKeymap),Zt=Fi(t=>t.settingsDefaultFileViewerPreview),bn=Fi(t=>t.showMessageTTSButtons),Lr=he(t=>t.expandedEditorToolbar);n.useEffect(()=>{const t=()=>{It.current=!1,dt.current=null,Ot(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Qt.current!==null&&window.clearTimeout(Qt.current),Yt.current!==null&&window.clearTimeout(Yt.current)},[]);const yn=n.useCallback((t,i)=>{const a=t.split(`
|
|
9
|
-
`),c=Math.max(1,i.start),u=Math.min(a.length,i.end);return c>u?"":a.slice(c-1,u).join(`
|
|
10
|
-
`)},[]),jn=Pa({source:"file",fileLabel:l?.path??null,language:l?.path&&sr(l.path)||"text",getCodeForRange:t=>yn(k,Ma(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Ar,commentText:hs,setCommentText:Ir,editingDraftId:ps,setSelection:Or,saveComment:Br,cancel:es,reset:$r,startEdit:Wr,deleteDraft:Ur}=jn;n.useEffect(()=>{Me(null),$r(),He(null),Q(""),Ms(!1)},[l?.path,$r,He]),n.useEffect(()=>{Or(P)},[P,Or]),n.useEffect(()=>{if(!P&&!ps)return;const t=a=>{const c=a.target;c.closest('[data-comment-input="true"]')||c.closest('[data-comment-card="true"]')||c.closest(".cm-gutterElement")||c.closest("[data-sonner-toast]")||c.closest("[data-sonner-toaster]")||hs.trim()||(Me(null),es())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[es,hs,ps,P]);const Gr=n.useCallback((t,i)=>{const a=i??P??void 0;i&&Me(i),Br(t,a),Me(null)},[P,Br]),Kr=n.useCallback((t,i)=>{const a=[];for(const c of i){if(!(c&&typeof c.name=="string"&&c.name.length>0)||!E&&c.name.startsWith(".")||!N&&Ha(c.name))continue;const u=c.name,f=M(c.path||""),w=f?Ua(f)?f:M(`${t}/${f}`):M(`${t}/${u}`),D=c.isDirectory?"directory":"file",$=D==="file"&&u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;a.push({name:u,path:w,type:D,extension:$})}return Wa(a)},[N,E]),Ve=n.useCallback(async t=>{const i=M(t.trim());if(!i||Se.current.has(i)||ke.current.has(i))return;ke.current=new Set(ke.current),ke.current.add(i);const a=wr.current+1;wr.current=a,Qe.current=new Map(Qe.current),Qe.current.set(i,a);const c=()=>Qe.current.get(i)===a;await(r.listDirectory?r.listDirectory(i).then(f=>f.entries.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory}))):Jn.listLocalDirectory(i).then(f=>f.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory})))).then(f=>{if(!c())return;const w=Kr(i,f);Se.current=new Set(Se.current),Se.current.add(i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$}),Ps(D=>({...D,[i]:w}))}).catch(f=>{if(!c())return;const w=f instanceof Error?f.message:String(f??"");if(w==="Directory not found"&&o&&i!==o){fr(o,i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$});return}console.error("Failed to load files directory:",f),Kt(D=>({...D,[i]:w}))}).finally(()=>{c()&&(Qe.current=new Map(Qe.current),Qe.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i))})},[r,Kr,fr,o]),gs=n.useCallback(async()=>{o&&(Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(t=>Object.keys(t).length===0?t:{}),await Ve(o))},[Ve,o]),_e=n.useCallback(async t=>{if(!t){await gs();return}const i=M(t);Se.current=new Set(Se.current),Se.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i),await Ve(i)},[Ve,gs]),Hr=n.useRef(""),qr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${E?"1":"0"}|g${N?"1":"0"}`,i=Hr.current!==o,a=qr.current!==t;!i&&!a||(i&&(Hr.current=o,H(""),J(null),Te(""),K(null),A(!1)),a&&(qr.current=t,Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(c=>Object.keys(c).length===0?c:{}),Ve(o)))},[Ve,o,N,E]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&Je.length>0)for(const i of Je)_e(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Je,r.listDirectory,_e]),n.useEffect(()=>{if(!r.listDirectory||Je.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of Je)_e(i)},8e3);return()=>clearInterval(t)},[Je,r.listDirectory,_e]);const Fn=n.useCallback(async t=>{if(t?.preventDefault(),!Ft||!jt)return;Is(!0);const i=()=>{As(null)},a=u=>{I.error(u)},c=()=>{Is(!1)};if(jt==="createFile"){if(!ct.trim()){a(e("sidebarFilesTree.toast.filenameRequired")),c();return}if(!r.writeFile){a(e("sidebarFilesTree.toast.writeNotSupported")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.writeFile(w,"").then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.fileCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="createFolder"){if(!ct.trim()){a(e("sidebarFilesTree.toast.folderNameRequired")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.createDirectory(w).then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.folderCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="rename"){if(!ct.trim()){a(e("sidebarFilesTree.toast.nameRequired")),c();return}if(!r.rename){a(e("sidebarFilesTree.toast.renameNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/"),w=f?`${f}/`:"",D=M(`${w}${ct.trim()}`);await r.rename(u,D).then(async $=>{$.success&&(I.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="delete"){if(!r.delete){a(e("sidebarFilesTree.toast.deleteNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/");await r.delete(u).then(async w=>{w.success&&(I.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}c()},[jt,Ft,ct,r,_e,h,ot,o,l?.path,se,e]);n.useEffect(()=>{if(!R){ls([]),cs(!1);return}const t=le.trim();if(!t){ls([]),cs(!1);return}let i=!1;return cs(!0),_(R,t,150,{includeHidden:E,respectGitignore:!N,type:"file"}).then(a=>{if(i)return;const u=a.filter(f=>N||!qa(f.path)).map(f=>({name:f.name,path:M(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));ls(u)}).catch(()=>{i||ls([])}).finally(()=>{i||cs(!1)}),()=>{i=!0}},[R,le,_,E,N]);const _r=n.useCallback(async(t,i)=>{if(r.readFile)return(await r.readFile(t,{...i??{},directory:o||void 0})).content??"";const a=new URLSearchParams({path:t});i?.allowOutsideWorkspace&&a.set("allowOutsideWorkspace","true"),i?.outsideFileGrant&&a.set("outsideFileGrant",i.outsideFileGrant),i?.optional&&a.set("optional","true"),o&&a.set("directory",o);const c=await bi(`/api/fs/read?${a.toString()}`,{cache:i?.optional?"no-store":"default"});if(!c.ok){const u=await c.json().catch(()=>({error:c.statusText}));throw new Error(u.error||e("filesView.error.readFileFailed"))}return c.text()},[r,o,e]),ut=n.useCallback(async(t,i)=>{if(r.statFile){const a=await r.statFile(t,{...i??{},directory:o||void 0});return{path:a.path,size:a.size,mtimeMs:a.mtimeMs}}return null},[r,o]);n.useEffect(()=>{if(!o||!r.statFile||C.length===0)return;let t=!1;const i=[...C];return Promise.all(i.map(async a=>{try{const c=await r.statFile?.(a,{directory:o||void 0});!t&&c&&!c.isFile&&ot(o,a)}catch(c){!t&&zi(c)&&ot(o,a)}})),()=>{t=!0}},[r,C,ot,o]);const Us=n.useMemo(()=>k.length>rs?`${k.slice(0,rs)}
|
|
11
|
-
|
|
12
|
-
… truncated …`:k,[k]),ie=B!==Us,Nt=n.useCallback(async()=>{if(!l||!r.writeFile)return I.error(e("filesView.toast.savingNotSupported")),!1;const t=Fs(l.path)||_t;if(!Oa({selectedFilePath:l.path,loadedFilePath:be,fileLoading:Re,isDirty:ie,draftContent:B,fileContent:k,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${l.path}".`):B===""&&k!==""&&be!==l.path&&console.warn(`[saveDraft] refusing to save empty draft for "${l.path}" (${k.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!ie)return!0;Ms(!0);try{const i=Ja(B,yr);if(!(await r.writeFile(l.path,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;if(H(B),o&&is(l.path,o)){const c=ks(o,l.path);c&&ca.requestGitRefresh({directory:o,paths:[c]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(M(l.path))){const c=da.getState().projects.find(u=>M(u.path)===M(o));if(c)try{await Da(c.id)}catch{I.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return l?.path&&rr(l.path)&&(lt.current=B,Ht.current=B),ut(l.path).then(c=>{c&&(Ke.current=c)}).catch(()=>{}),!0}catch(i){return I.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ms(!1)}},[_t,B,k,Re,r,ie,yr,be,ut,o,l,e]);n.useEffect(()=>{if(!ie){He(null);return}const t=i=>bt.current?(bt.current=!1,!0):(zt(!0),Xt.current=i,!1);return He(t),()=>{he.getState().mainTabGuard===t&&He(null)}},[ie,He]),n.useEffect(()=>{re||(Mt("idle"),Ge.current&&(clearTimeout(Ge.current),Ge.current=null))},[re]);const Xr=1500;n.useEffect(()=>{const t=!!(l&&r.writeFile),i=!!(l?.path&&(Fs(l.path)||_t));if(Ia({autoSaveEnabled:re,isDirty:ie,canWrite:t,isSaving:Rt,fileLoading:Re,selectedFilePath:l?.path,loadedFilePath:be,isNonEditableBinary:i}))return Ge.current=setTimeout(()=>{Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})},Xr),()=>{Ge.current&&(clearTimeout(Ge.current),Ge.current=null)}},[re,_t,B,Re,ie,be,l,r.writeFile,Rt,Nt]),n.useEffect(()=>{Mt("idle")},[l?.path]),n.useEffect(()=>{const t=i=>{ga(i)&&(i.key.toLowerCase()==="s"?(i.preventDefault(),Ge.current&&(clearTimeout(Ge.current),Ge.current=null),Rt||Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})):i.key.toLowerCase()==="f"&&(i.preventDefault(),pe(!0)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Rt,Nt]);const Jr=n.useCallback(async t=>{const i=qt.current+1;qt.current=i;const a=()=>{if(!o)return!1;const je=ze.getState().byRoot[o],oe=je?.selectedPath??je?.openPaths[0]??null;return qt.current===i&&oe===t.path};J(null),Te(""),K(null),Fr(!1);const c=Ni(t.path),u=Ci(t.path),f=Si(t.path),w=Fs(t.path);if(h&&A(!0),m.isDesktop&&c&&!u){H(""),Q(""),Ye(!0);return}if(!m.isDesktop&&c&&!u){H(""),Q(""),K(t.path),Ye(!1);return}if(f){H(""),Q(""),K(t.path),Ye(!1);return}if(w){H(""),Q(""),K(t.path),Ye(!1);return}Ye(!0);const D=ji(t.path),$={allowOutsideWorkspace:d==="editor-only"&&!!o&&!is(t.path,o),outsideFileGrant:D};await _r(t.path,$).then(je=>{if(!a())return;if(ua(je)){Fr(!0),H(""),Q(""),K(t.path);return}const oe=Gi(je);Qi(Xa(je)),H(oe),lt.current=oe,Ht.current=oe,Q(oe.length>rs?`${oe.slice(0,rs)}
|
|
13
|
-
|
|
14
|
-
… truncated …`:oe),K(t.path),ut(t.path,$).then(Ct=>{Ct&&a()&&(Ke.current=Ct)}).catch(()=>{})}).catch(je=>{if(a()){if(_a(je)){if(Ye(!1),o&&se(o,null),J(null),H(""),Q(""),K(null),Ke.current=null,T.trim().length>0&&V(""),h&&A(!1),o){const Ct=[...Pi(t.path,o),t.path];Ct.length>0&&ns(o,Ct);for(const er of Ct)Se.current.has(er)||Ve(er)}return}if(zi(je)){o&&ot(o,t.path),H(""),Q(""),J(null),Ke.current=null,h&&A(!1);return}H(""),Q(""),J(je instanceof Error?je.message:e("filesView.error.readFileFailed")),Ke.current=null}}).finally(()=>{a()&&Ye(!1)})},[ns,h,Ve,d,_r,ut,ot,o,m.isDesktop,T,se,e]),xs=n.useCallback(async(t,i)=>{if(!o)return;const a=Pi(t,o),c=i?[...a,t]:a;c.length>0&&ns(o,c);const u=c.map(f=>{if(!Se.current.has(f))return Ve(f)}).filter(Boolean);await Promise.all(u)},[ns,Ve,o]),Qr=n.useCallback((t,i)=>{const a=i.findIndex(c=>c.path===t);return a===-1||i.length<=1?null:i[a+1]??i[a-1]??null},[]),me=n.useCallback(async t=>{if(bt.current)bt.current=!1;else if(ie){zt(!0),Lt.current=t;return}o&&(se(o,t.path),xs(t.path,!1)),J(null),Te(""),H(""),lt.current="",Ht.current="",Q(""),K(null),h&&A(!0)},[xs,ie,h,o,se]);n.useEffect(()=>{l?.path&&xs(l.path,!1)},[xs,l?.path]),n.useEffect(()=>{if(!l){qt.current+=1,Pt.current=null,Ye(!1);return}if(be===l.path||Pt.current===l.path)return;const t=l.path;Pt.current=t,Jr(l).finally(()=>{Pt.current===t&&(Pt.current=null)})},[us,Jr,be,l]);const Gs=n.useRef(ie);Gs.current=ie,n.useEffect(()=>Ea(({runtimeKey:t,paths:i})=>{const a=l?.path;t!==ta()||!a||Gs.current||!i.includes(M(a))||(qt.current+=1,Pt.current=null,Ke.current=null,Te(""),J(null),K(null),Zi(c=>c+1))}),[l?.path]),n.useEffect(()=>{if(!l?.path||be!==l.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ut(l.path,Ce).then(a=>{if(t||!a)return;const c=Ke.current;if(!c||c.path!==l.path){Ke.current=a;return}const u=a.mtimeMs!==void 0&&c.mtimeMs!==void 0&&a.mtimeMs!==c.mtimeMs,f=a.size!==c.size;!u&&!f||Gs.current||(Ke.current=a,K(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[be,ut,l?.path,Ce]);const Nn=n.useCallback(()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),Q(Us),a){o&&Vt(o,a),l?.path===a&&(t?me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[Us,me,h,Vt,o,l?.path,He,se]),Cn=n.useCallback(async()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(!await Nt()){bt.current=!1;return}if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),a){o&&Vt(o,a),l?.path===a&&(t?await me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){await me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[me,h,Vt,o,Nt,l?.path,He,se]),Yr=n.useCallback(t=>{const i=l?.path===t,a=Qr(t,Et);if(i&&ie){zt(!0),Lt.current=a,Jt.current=t;return}if(o&&Vt(o,t),!!i){if(a){me(a);return}o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)}},[Qr,me,ie,h,Et,Vt,o,l?.path,se]),Sn=n.useCallback(t=>{if(C.includes(t))return"open";if(L?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=L.files.find(c=>c.path===i);if(a){if(a.index==="A"||a.working_dir==="?")return"git-added";if(a.index==="D")return"git-deleted";if(a.index==="M"||a.working_dir==="M")return"git-modified"}}return null},[C,L,o]),kn=n.useCallback(t=>{if(!L?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=i?`${i}/`:"";let c=0,u=0;for(const f of L.files)f.path.startsWith(a)&&((f.index==="M"||f.working_dir==="M")&&c++,(f.index==="A"||f.working_dir==="?")&&u++);return c+u>0?{modified:c,added:u}:null},[L,o]),Tn=n.useCallback(async t=>{const i=M(t);o&&(mr(o,i),Se.current.has(i)||await Ve(i))},[Ve,o,mr]),Vn=n.useMemo(()=>({canRename:Vr,canCreateFile:kr,canCreateFolder:Tr,canDelete:Dr,canReveal:Er}),[Vr,kr,Tr,Dr,Er]);function Zr(t,i){const a=vr[t]??[];return a.map((c,u)=>{const f=c.type==="directory",w=f&&Je.includes(c.path),D=l?.path===c.path,$=u===a.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),$&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Ya,{node:c,root:o,isExpanded:w,isActive:D,isMobile:h,isBrowserClient:F,alwaysShowActions:z,status:f?void 0:Sn(c.path),badge:f?kn(c.path):void 0,permissions:Vn,downloadFile:r.downloadFile,contextMenuPath:ln,setContextMenuPath:cn,rightClickMenuPath:dn,setRightClickMenuPath:un,onSelect:me,onToggle:Tn,onRevealPath:vn,onOpenDialog:Bs}),f&&w&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[os[c.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:os[c.path],children:os[c.path]}),s.jsxs(S,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{_e(c.path)},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Zr(c.path,i+1)]})]},c.path)})}const ne=!!(l?.path&&Ni(l.path)),vs=!!(l?.path&&Ci(l.path)),De=!!(l?.path&&Si(l.path)),Ks=!!(l?.path&&(Fs(l.path)||_t)),tt=Ks&&!ne&&!De,ei=n.useMemo(()=>M(qe?.path??""),[qe?.path]),Bt=!!(qe&&ei&&Ue&&Ue===ei&&!Re&&!Ze&&!ne&&!De&&!tt),ft=n.useMemo(()=>ks(o,Ue),[Ue,o]),Dn=!!(l&&(!ne||vs)&&!De&&!tt&&k.length>0),En=!!(l&&ft.length>0),Ee=!!(l&&!as&&!Ks&&!ne&&r.writeFile&&k.length<=rs),mt=!!(l?.path&&Li(l.path)),ts=!!(l?.path&&Qa(l.path)),$t=!!(l?.path&&lr(l.path)),ss=!!(l?.path&&rr(l.path)),Hs=!!(l&&!Ks&&!ne)&&!mt&&!ss&&!($t&&xe==="preview"),Rn=mt&&xt==="edit"||$t&&xe==="edit"||ts&&Ie==="text"||!mt&&!$t&&!ts&&G==="edit",ws=n.useMemo(()=>Ue?fa(Ue):null,[Ue]),[ti,qs]=n.useState(null);n.useEffect(()=>{let t=!1;const i=l?.path;if(!i||ws){qs(null);return}return qs(null),ma(i).then(a=>{t||qs(a)}),()=>{t=!0}},[l?.path,ws]),n.useEffect(()=>{!Ee&&G==="edit"&&Fe("view")},[Ee,G]);const _s="openchamber:files:md-viewer-mode",Xs="openchamber:files:html-viewer-mode",Js="openchamber:files:json-viewer-mode";n.useEffect(()=>{const t=l?.path;if(!t)return;Fe(Be.current[t]??"edit");let i=Zt?"preview":"edit";try{const u=localStorage.getItem(_s);(u==="preview"||u==="edit")&&(i=u)}catch{}Ae($e.current[t]??i);let a=Zt?"preview":"edit";try{const u=localStorage.getItem(Xs);(u==="preview"||u==="edit")&&(a=u)}catch{}Oe(We.current[t]??a),Ne(at.current[t]??(Zt?"preview":"edit"));let c=Zt?"tree":"text";try{const u=localStorage.getItem(Js);(u==="tree"||u==="text")&&(c=u)}catch{}vt(c)},[l?.path,Zt]);const Pn=n.useCallback(t=>{const i=l?.path;i&&(Be.current[i]=t),Fe(t)},[l?.path]),si=n.useCallback(t=>{const i=l?.path;i&&($e.current[i]=t),Ae(t);try{localStorage.setItem(_s,t)}catch{}},[l?.path]),ae=n.useCallback(()=>xt,[xt]),Mn=n.useCallback(t=>{vt(t);try{localStorage.setItem(Js,t)}catch{}},[]),zn=n.useCallback(t=>{const i=l?.path;i&&(We.current[i]=t),Oe(t);try{localStorage.setItem(Xs,t)}catch{}},[l?.path]),Ln=n.useCallback(t=>{const i=l?.path;if(i&&(at.current[i]=t),ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null),t==="edit")Q(lt.current||k),Ne(t);else{lt.current=B;const a=i;Ne("edit"),et.current=requestAnimationFrame(()=>{et.current=requestAnimationFrame(()=>{et.current=null,!(o&&a&&ze.getState().byRoot[o]?.selectedPath!==a)&&(nt(c=>c+1),Ne("preview"))})});return}},[B,k,o,l?.path]),Qs=n.useCallback(async(t,i)=>{if(!r.writeFile||i===Ht.current)return!1;if(!(await r.writeFile(t,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;lt.current=i,Ht.current=i,Q(i);const c=await ut(t,Ce).catch(()=>null);return c&&(Ke.current=c),!0},[r,ut,Ce,e]);n.useEffect(()=>()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null)},[ue,l?.path]);const An=n.useCallback(t=>{if(lt.current=t,!re||!l?.path||ue!=="preview"||!r.writeFile)return;ye.current&&clearTimeout(ye.current);const i=l.path;ye.current=setTimeout(()=>{ye.current=null,Qs(i,t).then(a=>{a&&(fs(!0),setTimeout(()=>fs(!1),1500))}).catch(a=>{I.error(a instanceof Error?a.message:e("filesView.toast.saveFailed"))})},Xr)},[re,ue,r.writeFile,Qs,l?.path,e]),In=n.useMemo(()=>ss&&(lt.current||B)||k,[B,k,ss]),ri=n.useCallback(()=>xe,[xe]);n.useEffect(()=>{const t=a=>{const c=a?"preview":"edit",u=a?"tree":"text";for(const f of C)Be.current[f]="edit",Li(f)&&($e.current[f]=c),lr(f)&&(We.current[f]=c),rr(f)&&(at.current[f]=c);Fe("edit"),Ae(c),Oe(c),Ne(c),vt(u);try{localStorage.setItem(_s,c),localStorage.setItem(Xs,c),localStorage.setItem(Js,u)}catch{}},i=a=>{const c=!!a.detail?.enabled;t(c)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[C]),n.useEffect(()=>{if(!qe||!o)return;const t=()=>{typeof window>"u"||At.current===null&&(At.current=window.requestAnimationFrame(()=>{At.current=null,Ls(st=>st+1)}))},i=(st,St)=>{if(st.state.doc.length!==St.length)return!1;if(St.length===0)return!0;const tr=Math.min(128,St.length);if(st.state.sliceDoc(0,tr)!==St.slice(0,tr))return!1;const xi=Math.max(0,St.length-tr);return st.state.sliceDoc(xi,St.length)===St.slice(xi)},a=M(qe.path);if(!a){ms(null),yt.current={key:"",attempts:0};return}const c=`${a}:${qe.line}:${qe.column??1}`;if(yt.current.key!==c&&(yt.current={key:c,attempts:0}),l?.path!==a){if(zs)return;me(Dt(a));return}if(Re||be!==a)return;if(Ze||ne||De||tt){ms(null),yt.current={key:"",attempts:0};return}if(!Ee)return;if(G!=="edit"){Fe("edit");return}const u=Pe.current;if(!u){t();return}if(!i(u,B)){t();return}const f=Math.max(1,Math.min(qe.line,u.state.doc.lines)),w=u.state.doc.line(f),D=Math.max(1,qe.column||1),$=Math.max(0,w.to-w.from),je=Math.min($,D-1),oe=w.from+je;if(!(u.state.selection.main.head===oe)||yt.current.attempts===0){yt.current.attempts+=1,u.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),u.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const st=Pe.current;st&&(st.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),st.focus())}),ms(null),yt.current={key:"",attempts:0}},[Ee,zs,B,nn,Ze,Re,ne,De,tt,be,me,qe,o,l?.path,ms,G,Dt]),n.useEffect(()=>{if(!$s||!o)return;const t=M($s);if(!t){Ws(null);return}l?.path===t&&(Re||be!==t||(!Ze&&!ne&&!De&&!tt&&Ee&&G==="edit"&&Pe.current?.focus(),Ws(null)))},[Ee,Ze,Re,ne,De,tt,be,$s,o,l?.path,Ws,G]);const Wt=n.useCallback(t=>{if(!h||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const a=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,a-(i.offsetTop+i.height))<=0)return;const u=t.state.selection.main.head,f=t.coordsAtPos(u);if(!f)return;const w=Math.round(i.offsetTop+i.height),$=f.bottom+20-w;$<=0||(t.scrollDOM.scrollTop+=$)},[h]);n.useEffect(()=>{if(!h||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Wt(Pe.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[h,Wt]),n.useEffect(()=>{if(!Ee||G!=="edit"||h)return;const t=ha("open_go_to_line",Mr),i=a=>{const c=a.target;if(c?.closest('[role="dialog"]'))return;const u=!!c?.closest(".cm-editor");c?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!u||!document.activeElement?.closest(".cm-editor")||xa(a,t)&&(a.preventDefault(),Os(!0))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Ee,h,Mr,G]);const bs=he(t=>t.editorFontSize),ii=n.useMemo(()=>{if(!l?.path)return[Ti(x,{fontSize:bs})];const t=sr(l.path),i=[Ti(x,t?{syntaxColors:!1,fontSize:bs}:{fontSize:bs})],a=ws??ti;return a&&i.push(a),t&&i.push(Ca({language:t,themeName:x.metadata.id,theme:Va(x)})),ce&&i.push(kt.lineWrapping),h&&i.push(kt.updateListener.of(c=>{c.view.hasFocus&&(c.selectionSet||c.focusChanged||c.viewportChanged||c.geometryChanged)&&window.requestAnimationFrame(()=>{Wt(c.view)})})),i},[x,l?.path,ws,ti,ce,h,Wt,bs]),ni=n.useMemo(()=>({light:fe.metadata.id,dark:ve.metadata.id}),[fe.metadata.id,ve.metadata.id]),ys=l?.path&&De?`${l.path}|${Ce.allowOutsideWorkspace?"outside":"workspace"}|${Ce.outsideFileGrant??""}|${us}`:"",js=l?.path&&$t&&xe==="preview"&&!m.isVSCode?`${l.path}|${us}`:"",ai=e("filesView.error.readFileFailed"),{readyKey:oi,nonce:On}=Ai(js,J,ai),{readyKey:li,nonce:ci}=Ai(ys,J,ai),Bn=!!(js&&oi!==js),di=!!(ys&&li!==ys),ui=l?.path&&ne?vs?`data:${pa(l.path)};utf8,${encodeURIComponent(k)}`:Ji:"",fi=l?.path&&De&&li===ys?yi().authenticatedAsset("/api/fs/raw",{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}):"",mi=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:fi,className:"h-full w-full border-0",title:t.name},ci)}),[fi,ci]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!l?.path||!ne||vs){Te("");return}J(null),await(r.readFileBinary?r.readFileBinary(l.path,Ce).then(u=>u.dataUrl):(async()=>{const u=await bi("/api/fs/raw",{query:{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}});if(!u.ok)throw new Error(e("filesView.error.readFileFailed"));const f=await u.blob();return i=URL.createObjectURL(f),t?(URL.revokeObjectURL(i),i="",""):i})()).then(u=>{t||(Te(u),K(l.path))}).catch(u=>{t||(Te(""),J(u instanceof Error?u.message:e("filesView.error.readFileFailed")),K(null))}).finally(()=>{t||Ye(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[us,r,ne,vs,o,l?.path,Ce,e]);const $n=n.useCallback(()=>As(null),[]),Wn=n.useMemo(()=>za({drafts:Ar,editingDraftId:ps,commentText:hs,onTextChange:Ir,selection:P,isDragging:Pr,fileLabel:l?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Gr,onCancel:()=>{Me(null),es()},onEdit:t=>{Wr(t),Me({start:t.startLine,end:t.endLine})},onDelete:Ur}),[es,hs,Ur,ps,Ar,Gr,Pr,P,l?.path,Ir,Wr]),hi=n.useCallback((t,i)=>s.jsx("div",{className:"h-full",children:s.jsx(ka,{file:{name:t.name,contents:i,lang:sr(t.path)||void 0},options:{disableFileHeader:!0,overflow:ce?"wrap":"scroll",theme:ni,themeType:x.metadata.variant==="dark"?"dark":"light"},className:"block h-full w-full",style:{height:"100%"}})}),[x.metadata.variant,ni,ce]),Ys=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!l)return null;const c=i==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",u=(f,w)=>s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:w})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:f})]});return s.jsxs("div",{className:c,children:[Ee&&Rn&&s.jsxs(s.Fragment,{children:[Rt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(g,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):re&&en==="saved"&&!ie?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(g,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ie?u(e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{Nt()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),"aria-label":e("filesView.editor.saveAria",{shortcut:`${ar()}+S`}),children:s.jsx(g,{name:"save-3",className:"size-4"})})):null,u(e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>sn(!re),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",re?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:re?s.jsx(g,{name:"file-check-fill",className:"size-4"}):s.jsx(g,{name:"file-check",className:"size-4"})}))]}),s.jsxs(cr,{onOpenChange:Tt,children:[s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(g,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(ur,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[pn.map(f=>s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{wn(f)},children:[s.jsx($a,{label:f.label,iconDataUrl:f.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:f.label})]},f.id)),gn?s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{xn(!0)},children:[s.jsx(g,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!ne&&!De&&!tt&&s.jsxs(s.Fragment,{children:[u(e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Le(!ce),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",ce?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(g,{name:"text-wrap",className:"size-4"})})),G==="edit"&&s.jsxs(s.Fragment,{children:[u(e("filesView.editor.findInFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{pe(!ee),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(g,{name:"search",className:"size-4"})})),u(e("filesView.editor.goToLine"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{Os(w=>!w),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(g,{name:"menu-fold-2",className:"size-4"})})),s.jsx(Aa,{open:hn,onOpenChange:Os,view:Pe.current,variant:"inline"})]})]}),Hs&&Ee&&!ts&&!$t&&s.jsx(or,{currentMode:G==="view"?"preview":"edit",onToggle:()=>{Pn(G==="view"?"edit":"view")}}),mt&&u(e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})),lr(l?.path??"")&&s.jsx(or,{currentMode:ri(),onToggle:()=>{zn(ri()==="preview"?"edit":"preview")}}),mt&&ae()==="preview"&&bn&&s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ds?Xi():k.trim()&&_i(k)},children:ds?s.jsx(g,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"volume-up",className:"size-4"})})}),s.jsx(gt,{sideOffset:8,children:e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),ss&&s.jsxs(s.Fragment,{children:[s.jsx(or,{currentMode:ue,onToggle:()=>Ln(ue==="preview"?"edit":"preview")}),ue==="preview"&&s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{const f=jr.current?.getXml();if(ye.current&&(clearTimeout(ye.current),ye.current=null),l?.path&&f){if(!await Qs(l.path,f))return;fs(!0),setTimeout(()=>fs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:tn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"save-3",className:"size-4"})})]}),ts&&u(e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Mn(Ie==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ie==="tree"?s.jsx(g,{name:"code-sslash",className:"size-4"}):s.jsx(g,{name:"node-tree",className:"size-4"})})),Dn&&u(e("filesView.editor.copyFileContents"),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(k)).ok?(Cr(!0),Qt.current!==null&&window.clearTimeout(Qt.current),Qt.current=window.setTimeout(()=>{Cr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:fn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"clipboard",className:"size-4"})})),En&&u(e("filesView.editor.copyFilePathTitle",{path:ft}),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(ft)).ok?(Sr(!0),Yt.current!==null&&window.clearTimeout(Yt.current),Yt.current=window.setTimeout(()=>{Sr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:ft}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:ft}),children:mn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&u(e("filesView.editor.saveFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{const f=r.downloadFile;f&&f(l.path).catch(w=>{console.error("Download failed:",w),I.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(g,{name:"download",className:"size-4"})})),t?u(e("filesView.editor.exitFullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(g,{name:"fullscreen-exit",className:"size-4"})})):!h&&d==="full"&&u(e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!U),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:U?s.jsx(g,{name:"fullscreen-exit",className:"size-4"}):s.jsx(g,{name:"fullscreen",className:"size-4"})}))]})},Zs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Ii,{open:zs,onOpenChange:t=>{t||zt(!0)},children:s.jsxs(Oi,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Bi,{children:[s.jsx($i,{children:e("filesView.unsaved.title")}),s.jsx(Wi,{children:e("filesView.unsaved.description")})]}),s.jsxs(Ui,{children:[s.jsx(S,{variant:"outline",onClick:()=>{Cn()},disabled:Rt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(S,{variant:"destructive",onClick:Nn,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:O("flex flex-col flex-shrink-0",q&&"border-b border-border/40"),children:[q?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&Z&&s.jsx("button",{type:"button",onClick:()=>A(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(g,{name:"arrow-left-s",className:"size-5"})}),h?l?s.jsxs(cr,{children:[s.jsx(dr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(Cs,{filePath:l.path,extension:l.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:l.name}),s.jsx(g,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(ur,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs(Ss,{onSelect:a=>{if(a.target.closest("[data-close-open-file]")){a.preventDefault();return}i||me(t)},className:O("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:a=>{a.preventDefault(),a.stopPropagation()},onClick:a=>{a.preventDefault(),a.stopPropagation(),Yr(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Et.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),pr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Rs,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs("div",{title:ks(o,t.path),className:O("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||me(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),Yr(t.path)},className:O("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!z&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,(Lr||h)&&l?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[ft&&!h?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ft,children:ft}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Ys({layout:"docked"})})]}):null]}),s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[l&&!ee&&!(Lr||h)&&s.jsx("div",{ref:de,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{rt.current>0||ge(!1)},children:te?Ys():s.jsxs("div",{className:"flex items-center gap-1",children:[mt?s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode")})]}):null,s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",onMouseEnter:()=>ge(!0),children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>ge(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":e("filesView.editor.showControlsAria"),title:e("filesView.editor.controlsTitle"),children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.controlsTitle")})]})]})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:l?Re||di?W?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Ze?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:ui,alt:l?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):l&&ss&&ue==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Ra,{ref:jr,xml:In,onChange:An},`${l.path}:${it}`)}):l&&ts&&Ie==="tree"?s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Ta,{jsonString:k,maxHeight:"100%",initiallyExpandedDepth:2})})}):l&&mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-3",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):l&&$t&&xe==="preview"?Bn?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!m.isVSCode&&oi===js?(()=>{const t=l.path.split("/").map(i=>encodeURIComponent(i)).join("/");return yi().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:m.isVSCode?(()=>{const t=l.path.substring(0,l.path.lastIndexOf("/")+1);return t?k.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):k})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},On)}):l&&Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),ref:rn,children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",blockWidgets:Wn,onViewReady:t=>{Pe.current=t,Ls(i=>i+1),window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null),Ls(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:pe,highlightLines:P?{start:Math.min(P.start,P.end),end:Math.max(P.start,P.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const c=t.state.doc.lineAt(i.from).number;if(P&&!a.shiftKey&&Math.min(P.start,P.end)===c&&Math.max(P.start,P.end)===c)return Me(null),es(),It.current=!1,dt.current=null,Ot(!1),!0;if(h&&P&&!a.shiftKey){const u=Math.min(P.start,P.end,c),f=Math.max(P.start,P.end,c);return Me({start:u,end:f}),It.current=!1,dt.current=null,Ot(!1),!0}if(It.current=!0,dt.current=c,Ot(!0),P&&a.shiftKey){const u=Math.min(P.start,c),f=Math.max(P.end,c);Me({start:u,end:f})}else Me({start:c,end:c});return!0},mouseover:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!It.current||dt.current===null)return!1;const c=t.state.doc.lineAt(i.from).number,u=Math.min(dt.current,c),f=Math.max(dt.current,c);return Me({start:u,end:f}),Ot(!0),!1},mouseup:()=>(It.current=!1,dt.current=null,Ot(!1),!1)}}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})]})]}),Un=!!(o&&vr[o]),pi=o?os[o]:null,gi=s.jsxs("section",{className:O("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:O("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(g,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Ts,{ref:Y,value:T,onChange:t=>V(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),T.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{V(""),Y.current?.focus()},children:s.jsx(g,{name:"close",className:"size-4"})})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFile",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(g,{name:"file-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFolder",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(g,{name:"folder-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{gs()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(g,{name:"refresh",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(ir,{outerClassName:"flex-1 min-h-0",className:O("py-2",h?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:qi?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):br.length>0?br.map(t=>{const i=l?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{me(t)},className:O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ki(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):pi?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:pi}),s.jsxs(S,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{gs()},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Un?Zr(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Gn=d==="full"&&U&&l&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:Ys({exitFullscreenOnly:!0})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Re||di?W?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Ze?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:ui,alt:l.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-4",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",onViewReady:t=>{Pe.current=t,window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null)}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Za,{activeDialog:jt,dialogData:Ft,dialogInputValue:ct,onDialogInputChange:Nr,isDialogSubmitting:on,onDialogSubmit:Fn,onClose:$n,inputRef:Yi}),Gn,h?Z?Zs:gi:d==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[p>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:gi}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zs})]})]})};function eo(d){return d+1}export{wc as FilesView};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{R as l,r as Te,j as t,f as jt}from"./vendor-react-BUCujlKS.js";import{f as et,y as Ze,hd as In,cR as Ht,c5 as Wt,t as b,I as D,aU as Vs,aR as Is,cP as wr,aT as Ps,cl as Fs,cm as Rs,cn as Ms,co as Bs,ch as Ut,ci as Kt,B as W,he as Pn,hf as Fn,bs as ut,bt as mt,bu as ht,bv as gt,bw as wt,S as nr,aX as Jt,aY as qt,aZ as Yt,hg as Rn,h as Re,hh as Mn,hi as Bn,hj as Tn,hk as Dn,aQ as En,aa as Ln,bH as An,hl as On,hm as zn,hn as Gn,ho as _n,hp as $n,hq as Hn,hr as Wn,bU as yr,bK as Un,bL as Kn,bM as Jn,bN as qn,bO as Yn,hs as Qn,bR as Xn,bx as ks,ex as Zn,V as ea,a0 as ta,a2 as sa,a1 as ra,bk as na,ht as aa,bS as ia,hu as oa,hv as la,a3 as ca,hw as da,a4 as ua,bF as ma,hx as ha,l as ga,bT as fa,g as pa,cq as xa,a9 as wa,Z as ya,hy as ba,hz as Cs}from"./useAppFontEffects-CbzHzFop.js";import{u as va,a as ja,d as Ca}from"./main-BF51IOVF.js";import{s as Na,v as Sa,q as ka,J as Va,X as Ia}from"./runtimeEndpointReset-BMBRhIbf.js";import{u as ar}from"./vendor-zustand-BAGL70zf.js";import{r as Pa,u as xt}from"./index-DzriVon2.js";import{C as Fa,a as Ra}from"./CommitSection-D9cV-qR9.js";import{P as Ma}from"./PierreDiffViewer-D_Gt4A_6.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.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-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-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./SessionSwitcherDropdown-xKU4LRuQ.js";import"./scheduledTasksApi-01zzfzqH.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.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-B37yB9jZ.js";import"./isDiffPlainText-DwHKxDYc.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CegKdDXi.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const br="gitmojiCache",Ba=1e3*60*60*24*7,vr="1",Ta="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",jr=i=>{if(!i||typeof i!="object")return!1;const e=i;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ns=()=>{if(typeof window>"u")return null;try{const i=window.localStorage.getItem(br);if(!i)return null;const e=JSON.parse(i);return!e||e.version!==vr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(jr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Da=i=>{if(!(typeof window>"u"))try{const e={gitmojis:i,fetchedAt:Date.now(),version:vr};window.localStorage.setItem(br,JSON.stringify(e))}catch{return}},ir=i=>Date.now()-i.fetchedAt<Ba;let _t=null;const It=new Set,or=async()=>{if(_t)return _t;const i=(async()=>{try{const e=await fetch(Ta);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),r=Array.isArray(n.gitmojis)?n.gitmojis.filter(jr):[];return Da(r),It.forEach(v=>v(r)),r}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return It.forEach(r=>r(n)),n}finally{_t=null}})();return _t=i,i},Ea=i=>{const[e,n]=l.useState(()=>i?Ns()?.gitmojis??[]:[]),[r,v]=l.useState(!1),f=l.useRef(i);f.current=i,l.useEffect(()=>{if(!i){It.delete(n),n([]),v(!1);return}const p=Ns();if(p&&(n(p.gitmojis),ir(p)))return;It.add(n),v(!0);let m=!1;return or().finally(()=>{!m&&f.current&&v(!1)}),()=>{m=!0,It.delete(n)}},[i]);const x=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const p=Ns();return p&&ir(p)?p.gitmojis:or()},[e]);return{gitmojis:e,isLoading:r,ensureLoaded:x}},Ct=async(i,e)=>{const n=await Pa(`/api/git/integrate/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>null);throw new Error(r?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function Vt(i){return Ct("plan",i)}async function La(i){return Ct("conflict-details",{tempWorktreePath:i})}async function Aa(i){return(await Ct("cherry-pick-status",{tempWorktreePath:i})).inProgress}async function Oa(i){return Ct("run",{plan:i})}async function za(i){await Ct("abort",{state:i})}async function Ga(i){return Ct("continue",{state:i})}const _a=({repoRoot:i,sourceBranch:e,worktreeMetadata:n,localBranches:r,defaultTargetBranch:v,refreshKey:f,onRefresh:x,showHeader:p=!0})=>{const{t:m}=et(),w=Ze(h=>h.currentSessionId),B=xt(h=>h.setActiveMainTab),[y,C]=Te.useState(!1),k=Te.useRef(null),[V,A]=Te.useState(v);Te.useEffect(()=>{A(v)},[v]),Te.useEffect(()=>{if(y){const h=setTimeout(()=>{k.current?.focus()},0);return()=>clearTimeout(h)}},[y]);const I=!!(i&&e&&V&&V!=="HEAD"&&e!==V),[d,E]=Te.useState({kind:"idle"}),[R,O]=Te.useState(!1),[N,P]=Te.useState([]),g=Te.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);Te.useEffect(()=>{if(!g||typeof window>"u")return;const h=window.localStorage.getItem(g);if(!h)return;let L=!1;try{const T=JSON.parse(h);if(!T?.tempWorktreePath||T.repoRoot!==i){window.localStorage.removeItem(g);return}(async()=>{const u=await Aa(T.tempWorktreePath).catch(()=>!1);if(L)return;if(!u){window.localStorage.removeItem(g);return}const M=await La(T.tempWorktreePath).catch(()=>null);L||M&&E({kind:"conflict",state:T,details:M})})()}catch{window.localStorage.removeItem(g)}return()=>{L=!0}},[g,i]),Te.useEffect(()=>{if(!I){E({kind:"idle"});return}let h=!1;return E({kind:"loading"}),(async()=>{try{const L=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V});if(h)return;if(E({kind:"ready",plan:L}),L.commits.length>0){const u=L.commits.slice(-50).reverse(),M=await In(i,u);h||(P(M),O(!1))}else h||(P([]),O(!1))}catch{h||E({kind:"idle"})}})(),()=>{h=!0}},[I,i,e,V,f]);const U=Te.useCallback(h=>{w&&Ze.getState().setWorktreeMetadata(w,{...n,createdFromBranch:h})},[w,n]),Y=Ze(h=>h.openNewSessionDraft),S=Te.useCallback(async h=>{const L=await Ht("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),T=await Ht("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}),u=`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:L,instructionsText:T,payloadText:u}},[]),F=Wt(h=>h.setPendingInputText),J=Wt(h=>h.setPendingSyntheticParts),H=Te.useCallback(async(h,L)=>{const T=await S(h);if(L){Y({directoryOverride:h.state.tempWorktreePath,initialPrompt:T.visibleText,syntheticParts:[{text:T.instructionsText,synthetic:!0},{text:T.payloadText,synthetic:!0}]}),B("chat");return}if(!w){b.error(m("gitView.integrate.noActiveSession"),{description:m("gitView.integrate.noActiveSessionDescription")});return}F(T.visibleText,"replace"),J([{text:T.instructionsText,synthetic:!0},{text:T.payloadText,synthetic:!0}]),B("chat")},[w,B,S,Y,F,J,m]),G=Te.useCallback(async()=>{if(d.kind==="ready"){if(d.plan.commits.length===0){b.message(m("gitView.integrate.noCommitsToMoveToast"));return}E({kind:"running",plan:d.plan});try{const h=await Oa(d.plan);if(h.kind==="success"){b.success(m("gitView.integrate.commitsMovedToast"),{description:h.moved===1?m("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:d.plan.targetBranch}):m("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:d.plan.targetBranch})});const L=await Vt(d.plan);E({kind:"ready",plan:L}),x?.();return}h.kind==="conflict"&&(b.error(m("gitView.integrate.cherryPickConflictToast"),{description:m("gitView.integrate.cherryPickConflictDescription")}),E({kind:"conflict",state:h.state,details:h.details}),g&&typeof window<"u"&&window.localStorage.setItem(g,JSON.stringify(h.state)))}catch(h){const L=h instanceof Error?h.message:String(h);b.error(m("gitView.integrate.failedToMoveToast"),{description:L});const T=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(T?{kind:"ready",plan:T}:{kind:"idle"})}}},[d,x,i,e,V,g,m]),Z=Te.useCallback(async()=>{if(d.kind==="conflict")try{await za(d.state),b.message(m("gitView.integrate.cherryPickAbortedToast")),g&&typeof window<"u"&&window.localStorage.removeItem(g)}finally{const h=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(h?{kind:"ready",plan:h}:{kind:"idle"})}},[d,i,e,V,g,m]),Q=Te.useCallback(async()=>{if(d.kind==="conflict")try{const h=await Ga(d.state);if(h.kind==="success"){b.success(m("gitView.integrate.cherryPickFinishedToast"));const L=await Vt({repoRoot:i,sourceBranch:e,targetBranch:V}).catch(()=>null);E(L?{kind:"ready",plan:L}:{kind:"idle"}),g&&typeof window<"u"&&window.localStorage.removeItem(g),x?.();return}h.kind==="conflict"&&(E({kind:"conflict",state:h.state,details:h.details}),g&&typeof window<"u"&&window.localStorage.setItem(g,JSON.stringify(h.state)))}catch(h){const L=h instanceof Error?h.message:String(h);b.error(m("gitView.integrate.cherryPickContinueFailedToast"),{description:L})}},[d,i,e,V,x,g,m]);return!i||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[p?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(D,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:m("gitView.integrate.title")}),d.kind==="ready"&&d.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m("gitView.integrate.toMoveCount",{count:d.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:d.kind==="loading"||d.kind==="running"?t.jsx(D,{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:m("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",V]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Vs,{open:y,onOpenChange:C,children:[t.jsx(Is,{asChild:!0,children:t.jsxs("button",{type:"button",className:wr({size:"default"}),children:[m("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:V}),t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Ps,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Fs,{className:"h-full min-h-0",children:[t.jsx(Rs,{ref:k,placeholder:m("gitView.branch.searchPlaceholder"),onKeyDown:h=>h.stopPropagation()}),t.jsxs(Ms,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Bs,{children:m("gitView.branch.empty")}),t.jsx(Ut,{heading:m("gitView.branch.localBranches"),children:r.map(h=>t.jsx(Kt,{value:h,onSelect:()=>{A(h),U(h),C(!1)},children:h},h))})]})]})})]}),d.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{G()},disabled:!I||d.plan.commits.length===0,children:m("gitView.integrate.move")}):d.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:m("gitView.integrate.checking")}):d.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:m("gitView.integrate.moving")}):null]}),d.kind==="ready"&&d.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:m("gitView.integrate.noCommitsToMove")}),d.kind==="ready"&&d.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:[m("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",d.plan.commits.length,")"]})]}),N.length>0&&d.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>O(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:m(R?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(R?N:N.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)),N.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:m("gitView.integrate.previewUnavailable")}),d.plan.commits.length>N.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:m("gitView.integrate.showingFirstCommits",{count:N.length})})]})]}),d.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:m("gitView.integrate.conflictsInFiles",{count:d.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[m("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:d.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[d.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)),d.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:m("gitView.integrate.moreFiles",{count:d.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:()=>{Z()},children:m("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{H({state:d.state,details:d.details},!1)},children:[t.jsx(D,{name:"sparkling",className:"size-3.5"}),m("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{H({state:d.state,details:d.details},!0)},children:[t.jsx(D,{name:"sparkling",className:"size-3.5"}),m("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{Q()},children:m("gitView.operation.continue")})]})]})]})]})},$a=({open:i,onOpenChange:e,directory:n,hasUncommittedChanges:r,hasStagedChanges:v=!1,uncommittedFileCount:f,onChanged:x})=>{const{t:p}=et(),[m,w]=l.useState([]),[B,y]=l.useState(!1),[C,k]=l.useState(""),[V,A]=l.useState(""),[I,d]=l.useState(null),[E,R]=l.useState({}),O=l.useCallback(async()=>{if(n){y(!0);try{const S=await Pn(n);w(S.stashes),R({})}catch(S){b.error(S instanceof Error?S.message:p("gitView.stashes.toast.loadFailed"))}finally{y(!1)}}},[n,p]);l.useEffect(()=>{i&&O()},[O,i]),l.useEffect(()=>{if(!i||!n||m.length===0)return;let S=!1;const F=m.map(J=>J.ref);return Fn(n,F).then(J=>{S||R(J.counts)}).catch(()=>{}),()=>{S=!0}},[n,i,m]);const N=l.useMemo(()=>{const S=C.trim().toLowerCase();return S?m.filter(F=>`${F.ref} ${F.message} ${F.relativeTime}`.toLowerCase().includes(S)):m},[C,m]),P=l.useCallback(async S=>{await O(),await x?.(S)},[O,x]),g=async()=>{if(!(!n||I)){d("create");try{const S=await Rn(n,{message:V.trim()||void 0});S.created?(b.success(p("gitView.stashes.toast.created")),A("")):b.info(p("gitView.stashes.toast.noChanges")),await P({affectsIndex:!!(S.created&&v)})}catch(S){b.error(S instanceof Error?S.message:p("gitView.stashes.toast.createFailed"))}finally{d(null)}}},U=async(S,F)=>{if(!(!n||I)&&!(F==="drop"&&!window.confirm(p("gitView.stashes.confirm.drop",{ref:S.ref})))){d(`${F}:${S.ref}`);try{F==="apply"&&await Mn(n,{ref:S.ref}),F==="pop"&&await Bn(n,{ref:S.ref}),F==="drop"&&await Tn(n,{ref:S.ref});const J=F==="apply"?"gitView.stashes.toast.applySuccess":F==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";b.success(p(J)),await P({affectsIndex:F!=="drop"})}catch(J){const H=F==="apply"?"gitView.stashes.toast.applyFailed":F==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";b.error(J instanceof Error?J.message:p(H)),await P({affectsIndex:F!=="drop"})}finally{d(null)}}},Y=I!==null;return t.jsx(ut,{open:i,onOpenChange:e,children:t.jsxs(mt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ht,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(D,{name:"archive-stack",className:"h-5 w-5"}),p("gitView.stashes.title")]}),t.jsx(wt,{children:p("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(nr,{value:V,onChange:S=>A(S.target.value),placeholder:p("gitView.stashes.messagePlaceholder"),disabled:Y||!r,className:"flex-1"}),t.jsxs(W,{onClick:g,disabled:!r||Y||!n,children:[I==="create"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"inbox-archive",className:"size-4"}),p("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:p("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(D,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(nr,{value:C,onChange:S=>k(S.target.value),placeholder:p("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:B?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(D,{name:"loader-4",className:"size-5 animate-spin"})}):N.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:p(C?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):N.map((S,F)=>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:S.message||p("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Jt,{children:[t.jsx(qt,{asChild:!0,children:t.jsx("span",{children:F===0&&!C.trim()?p("gitView.stashes.latestLabel"):p("gitView.stashes.itemNumber",{number:F+1})})}),t.jsx(Yt,{sideOffset:6,children:S.ref})]})," · ",S.relativeTime," · ",typeof E[S.ref]=="number"?p("gitView.stashes.fileCount",{count:E[S.ref]}):p("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(Ss,{label:p("gitView.stashes.actions.apply"),loading:I===`apply:${S.ref}`,onClick:()=>U(S,"apply"),disabled:Y,children:t.jsx(D,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ss,{label:p("gitView.stashes.actions.pop"),loading:I===`pop:${S.ref}`,onClick:()=>U(S,"pop"),disabled:Y,children:t.jsx(D,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ss,{label:p("gitView.stashes.actions.drop"),loading:I===`drop:${S.ref}`,onClick:()=>U(S,"drop"),disabled:Y,destructive:!0,children:t.jsx(D,{name:"delete-bin",className:"size-4"})})]})]},S.ref))})]})})},Ss=i=>{const e=jt.c(17),{label:n,loading:r,disabled:v,destructive:f,onClick:x,children:p}=i,m=r||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let B;e[0]!==w?(B=Re("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=B):B=e[1];let y;e[2]!==p||e[3]!==r?(y=r?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):p,e[2]=p,e[3]=r,e[4]=y):y=e[4];let C;e[5]!==v||e[6]!==n||e[7]!==x||e[8]!==m||e[9]!==B||e[10]!==y?(C=t.jsx(qt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":n,"aria-busy":m,className:B,onClick:x,disabled:v,children:y})}),e[5]=v,e[6]=n,e[7]=x,e[8]=m,e[9]=B,e[10]=y,e[11]=C):C=e[11];let k;e[12]!==n?(k=t.jsx(Yt,{sideOffset:6,children:n}),e[12]=n,e[13]=k):k=e[13];let V;return e[14]!==C||e[15]!==k?(V=t.jsxs(Jt,{children:[C,k]}),e[14]=C,e[15]=k,e[16]=V):V=e[16],V},Ha=i=>{const e=jt.c(16),{onOpenStashes:n}=i,{t:r}=et();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(D,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=v):v=e[0];let f;e[1]!==r?(f=r("gitView.empty.cleanTitle"),e[1]=r,e[2]=f):f=e[2];let x;e[3]!==f?(x=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=x):x=e[4];let p;e[5]!==r?(p=r("gitView.empty.cleanDescription"),e[5]=r,e[6]=p):p=e[6];let m;e[7]!==p?(m=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:p}),e[7]=p,e[8]=m):m=e[8];let w;e[9]!==n||e[10]!==r?(w=n?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[t.jsx(D,{name:"archive-stack",className:"size-4"}),r("gitView.stashes.title")]}):null,e[9]=n,e[10]=r,e[11]=w):w=e[11];let B;return e[12]!==x||e[13]!==m||e[14]!==w?(B=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[v,x,m,w]}),e[12]=x,e[13]=m,e[14]=w,e[15]=B):B=e[15],B},dt=8,Wa=i=>{const e=jt.c(18),{laned:n,totalLanes:r,isExpanded:v}=i,{lane:f,color:x,connectors:p}=n,w=Math.max(r,f+1)*dt+dt/2,B=l.useRef(null),y=l.useRef(null);let C;e[0]!==x||e[1]!==p||e[2]!==f||e[3]!==w?(C=()=>{const d=B.current,E=y.current;if(!d||!E)return;const R=d.offsetHeight;if(R===0)return;const O=window.devicePixelRatio||1;E.width=w*O,E.height=R*O;const N=E.getContext("2d");if(!N)return;N.scale(O,O),N.clearRect(0,0,w,R);const P=R/2,g=f*dt+dt/2,U=getComputedStyle(E),Y=U.getPropertyValue("--surface-muted-foreground").trim()||U.color,S=H=>{if(!H.startsWith("var("))return H;const G=H.slice(4,-1).trim();return U.getPropertyValue(G).trim()||Y},F=[...p].sort(Ka);for(const H of F){const G=H.fromLane*dt+dt/2,Z=H.toLane*dt+dt/2,Q=H.type==="passing"?.72:H.type==="branch-out"||H.type==="merge-in"?.95:1;N.beginPath(),N.strokeStyle=S(H.color),N.globalAlpha=Q,N.lineWidth=1.25,N.lineCap="round";e:switch(H.type){case"passing":case"commit-lane":{N.moveTo(G,0),N.lineTo(G,R);break e}case"top-stub":{N.moveTo(G,0),N.lineTo(G,P);break e}case"bottom-stub":{N.moveTo(G,P),N.lineTo(G,R);break e}case"branch-out":{const se=(P+R)/2;N.moveTo(g,P),N.bezierCurveTo(g,se,Z,se,Z,R);break e}case"merge-in":{const se=P/2;N.moveTo(G,0),N.bezierCurveTo(G,se,g,se,g,P);break e}default:continue}N.stroke(),N.globalAlpha=1}const J=U.getPropertyValue("--background").trim()||U.getPropertyValue("--surface-background").trim();N.beginPath(),N.arc(g,P,4,0,Math.PI*2),N.fillStyle=S(x),N.fill(),N.beginPath(),N.arc(g,P,5,0,Math.PI*2),N.strokeStyle=J||Y,N.lineWidth=2,N.stroke()},e[0]=x,e[1]=p,e[2]=f,e[3]=w,e[4]=C):C=e[4];let k;e[5]!==x||e[6]!==p||e[7]!==v||e[8]!==f||e[9]!==n||e[10]!==r||e[11]!==w?(k=[n,f,x,p,r,v,w],e[5]=x,e[6]=p,e[7]=v,e[8]=f,e[9]=n,e[10]=r,e[11]=w,e[12]=k):k=e[12],l.useLayoutEffect(C,k);let V;e[13]!==w?(V={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=V):V=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("canvas",{ref:y,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=A):A=e[15];let I;return e[16]!==V?(I=t.jsx("div",{ref:B,style:V,children:A}),e[16]=V,e[17]=I):I=e[17],I};function Ua(i){return i==="branch-out"||i==="merge-in"}function Ka(i,e){const n=Ua;return(n(i.type)?1:0)-(n(e.type)?1:0)}const lr=15e3,cr=500,dr=12,ur=8*1024*1024,mr=i=>typeof i=="string"?0:(i.original?.length??0)+(i.modified?.length??0),hr=i=>{if(i.size<=dr){let v=0;for(const f of i.values())v+=mr(f);if(v<=ur)return i}const e=Array.from(i.entries()).reverse(),n=new Map;let r=0;for(const[v,f]of e){if(n.size>=dr)continue;const x=mr(f);r+x>ur&&n.size>0||(n.set(v,f),r+=x)}return new Map(Array.from(n.entries()).reverse())};function gr(i,e){const n=new Date(i);return Number.isNaN(n.getTime())?i:An(n,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ja(i){switch(i){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 qa(i){return i?i.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.startsWith("HEAD ->");return{label:n?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:n,isTag:e.startsWith("tag: ")}}):[]}const Ya=l.memo(({entry:i,mode:e="history",laned:n,totalLanes:r,isExpanded:v,onToggle:f,files:x,isLoadingFiles:p,onCopyHash:m,directory:w,onConflict:B,onActionSuccess:y})=>{const{t:C}=et(),k=xt(u=>u.timeFormatPreference),V=e==="graph",[A,I]=l.useState(null),[d,E]=l.useState(!1),[R,O]=l.useState(""),[N,P]=l.useState(null),[g,U]=l.useState(new Set),[Y,S]=l.useState(new Map),[F,J]=l.useState(new Set),H=async()=>{if(w){I("checkout");try{await Wn(w,i.hash),b.success(C("gitView.history.actions.detachedHead")),y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},G=async()=>{if(!(!w||!R.trim())){I("createBranch");try{await On(w,R.trim(),i.hash),E(!1),O(""),y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},Z=async()=>{if(w){I("cherryPick");try{const u=await Hn(w,i.hash);u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"cherry-pick"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},Q=async()=>{if(w){I("revert");try{const u=await $n(w,i.hash);u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"revert"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},se=async(u,M=!1)=>{if(!(!w||A!==null)){I("reset");try{await zn(w,i.hash,u,M),y?.()}catch($){b.error(String($.message))}finally{I(null)}}},ce=async()=>{if(!N)return;const u=N;switch(P(null),u){case"checkout":return H();case"cherryPick":return Z();case"revert":return Q();case"merge":return oe();case"rebase":return h();case"resetSoft":return se("soft");case"resetMixed":return se("mixed");case"resetHard":return se("hard",!0)}},oe=async()=>{if(w){I("merge");try{const u=await _n(w,{branch:i.hash});u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"merge"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},h=async()=>{if(w){I("rebase");try{const u=await Gn(w,{onto:i.hash});u.conflict?B?.({conflict:!0,conflictFiles:u.conflictFiles,operation:"rebase"}):y?.()}catch(u){b.error(String(u.message))}finally{I(null)}}},L=l.useCallback(async u=>{const M=u.path;if(!w){S($=>new Map($).set(M,"error"));return}S($=>hr(new Map($).set(M,"loading")));try{const $=Dn(w,i.hash,u.path,!1),ae=new Promise((ee,_)=>{setTimeout(()=>_(new Error(`Timed out after ${lr}ms`)),lr)}),ie=await Promise.race([$,ae]);S(ee=>hr(new Map(ee).set(M,ie)))}catch{S($=>new Map($).set(M,"error"))}},[w,i.hash]),T=l.useCallback(async u=>{const M=u.path;if(u.changeType==="R"||u.isBinary){U(ee=>{const _=new Set(ee);return _.has(M)?_.delete(M):_.add(M),_});return}const $=Y.get(M);if(g.has(M)&&$&&$!=="error"){U(ee=>{const _=new Set(ee);return _.delete(M),_});return}U(ee=>{const _=new Set(ee);return _.add(M),_}),!($&&$!=="error"||u.insertions+u.deletions>cr&&!F.has(M))&&await L(u)},[Y,F,L,g]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Re("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",V?"hover:bg-[var(--interactive-hover)]/40":v?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[V&&n&&r!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(Wa,{laned:n,totalLanes:r,isExpanded:v})}):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:[V?(()=>{const u=qa(i.refs);return u.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:u.map(M=>t.jsx("span",{className:Re("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",M.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":M.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:M.label},M.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:i.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:i.author_name,children:i.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:gr(i.date,k),children:gr(i.date,k)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:i.hash.slice(0,8)}),t.jsxs(Jt,{children:[t.jsx(qt,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:u=>{u.stopPropagation(),m(i.hash)},children:t.jsx(D,{name:"file-copy",className:"size-3"})})}),t.jsx(Yt,{sideOffset:8,children:C("gitView.history.copySha")})]})]})]})]}),v&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[V&&N?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:C(`gitView.history.actions.${N}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:A!==null,onClick:u=>{u.stopPropagation(),ce()},children:[A!==null?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:A!==null,onClick:u=>{u.stopPropagation(),P(null)},children:C("gitView.history.actions.cancelButton")})]}):V?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:A!==null,onClick:u=>{u.stopPropagation(),P("checkout")},children:C("gitView.history.actions.checkout")}),d?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:R,onChange:u=>O(u.target.value),onKeyDown:u=>{u.key==="Enter"&&G(),u.key==="Escape"&&(E(!1),O(""))},placeholder:C("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:!R.trim()||A!==null,onClick:u=>{u.stopPropagation(),G()},children:[A==="createBranch"?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:u=>{u.stopPropagation(),E(!0)},children:C("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("cherryPick")},children:C("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("revert")},children:C("gitView.history.actions.revert")}),t.jsxs(Vs,{children:[t.jsx(Is,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>u.stopPropagation(),children:[A==="reset"?t.jsx(D,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,C("gitView.history.actions.reset")]})}),t.jsx(Ps,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(u=>t.jsx(En,{disabled:A!==null,onSelect:M=>{M.stopPropagation(),P(`reset${u.charAt(0).toUpperCase()+u.slice(1)}`)},children:C(`gitView.history.actions.reset${u.charAt(0).toUpperCase()+u.slice(1)}`)},u))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("merge")},children:C("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:A!==null,onClick:u=>{u.stopPropagation(),P("rebase")},children:C("gitView.history.actions.rebase")})]}):null,p?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:C("gitView.history.loadingFiles")})]}):x.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:C("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:x.map(u=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>T(u),className:Re("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",g.has(u.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Re("font-semibold w-3 text-center shrink-0",Ja(u.changeType)),children:u.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:u.path,children:u.path}),!u.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",u.deletions]})]}),u.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:C("gitView.history.binary")}),t.jsx(D,{name:g.has(u.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),g.has(u.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:u.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.renamedNoDiff")}):u.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.binaryNoDiff")}):(()=>{const M=u.insertions+u.deletions;if(!F.has(u.path)&&M>cr)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:C("gitView.history.largeDiffTitle",{count:M})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:C("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:()=>{J(ae=>new Set(ae).add(u.path)),L(u)},children:C("gitView.history.renderDiffAnyway")})]});const $=Y.get(u.path);return $==="loading"||$===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:C("gitView.history.loadingDiff")}):$==="error"?t.jsx("button",{type:"button",onClick:()=>T(u),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:C("gitView.history.diffError")}):t.jsx(Ma,{original:$.original,modified:$.modified,language:Ln(u.path)||"",fileName:u.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},u.path))})]})]})}),fr=["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 $t(i){return fr[i%fr.length]}function Qa(i){if(i.length===0)return[];const e=[],n=[];for(let r=0;r<i.length;r++){const v=i[r],f=[];for(let k=0;k<e.length;k++)e[k]===v.hash&&f.push(k);let x=f.length>0?f[0]:-1;if(x===-1){const k=e.indexOf(null);k!==-1?x=k:(x=e.length,e.push(null))}const p=f.slice(1),m=$t(x),w=e[x]===v.hash,B=v.parents.length>0;B?e[x]=v.parents[0]:e[x]=null;const y=[];for(let k=1;k<v.parents.length;k++){const V=v.parents[k],A=e.indexOf(V);if(A!==-1)y.push(A);else{const I=e.indexOf(null),d=I!==-1?I:e.length;e[d]=V,d===e.length&&e.push(V),y.push(d)}}const C=[];w&&B?C.push({fromLane:x,toLane:x,color:m,type:"commit-lane"}):w&&!B?C.push({fromLane:x,toLane:x,color:m,type:"top-stub"}):!w&&B&&C.push({fromLane:x,toLane:x,color:m,type:"bottom-stub"});for(const k of p)C.push({fromLane:k,toLane:x,color:$t(k),type:"merge-in"}),e[k]=null;for(const k of y)C.push({fromLane:x,toLane:k,color:$t(k),type:"branch-out"});for(let k=0;k<e.length;k++)e[k]!==null&&k!==x&&(y.includes(k)||C.push({fromLane:k,toLane:k,color:$t(k),type:"passing"}));n.push({commit:v,lane:x,color:m,connectors:C})}return n}const Xa=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],Za=i=>{const e=jt.c(84),{mode:n,log:r,isLogLoading:v,logMaxCount:f,onLogMaxCountChange:x,expandedCommitHashes:p,onToggleCommit:m,commitFilesMap:w,loadingCommitHashes:B,onCopyHash:y,directory:C,showHeader:k,contentMaxHeightClassName:V,branchDivider:A,onConflict:I,onActionSuccess:d}=i,E=n===void 0?"history":n,R=k===void 0?!0:k,O=V===void 0?"max-h-[50vh]":V,N=A===void 0?null:A,{t:P}=et(),[g,U]=l.useState(!0),Y=E==="graph";let S;e[0]!==Y||e[1]!==r?(S=Y&&r?Qa(r.all):[],e[0]=Y,e[1]=r,e[2]=S):S=e[2];const F=S;let J;e[3]!==F?(J=Math.max(1,...F.map(ei)),e[3]=F,e[4]=J):J=e[4];const H=J;let G;e[5]!==F?(G=new Map(F.map(ti)),e[5]=F,e[6]=G):G=e[6];const Z=G;if(!r)return null;const Q=N!==null&&N.insertBeforeIndex>0&&N.insertBeforeIndex<r.all.length,se=N!==null&&N.insertBeforeIndex===r.all.length,ce=Q||se;let oe;e[7]!==N||e[8]!==Q||e[9]!==se||e[10]!==r.all?(oe=Q?r.all.slice(0,N.insertBeforeIndex):se?r.all:[],e[7]=N,e[8]=Q,e[9]=se,e[10]=r.all,e[11]=oe):oe=e[11];const h=oe;let L;if(e[12]!==N||e[13]!==w||e[14]!==O||e[15]!==C||e[16]!==p||e[17]!==Q||e[18]!==ce||e[19]!==Y||e[20]!==v||e[21]!==Z||e[22]!==B||e[23]!==r.all||e[24]!==f||e[25]!==H||e[26]!==E||e[27]!==d||e[28]!==I||e[29]!==y||e[30]!==x||e[31]!==m||e[32]!==P||e[33]!==h){const te=Q?r.all.slice(N.insertBeforeIndex):[];let de;e[35]!==N?.direction?(de=N?.direction==="down"?t.jsx(D,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(D,{name:"arrow-up",className:"size-3.5"}),e[35]=N?.direction,e[36]=de):de=e[36];const ve=de;let ue;e[37]!==w||e[38]!==C||e[39]!==p||e[40]!==Y||e[41]!==Z||e[42]!==B||e[43]!==H||e[44]!==E||e[45]!==d||e[46]!==I||e[47]!==y||e[48]!==m?(ue=De=>t.jsx("ul",{className:"divide-y divide-border/60",children:De.map(je=>t.jsx(Ya,{entry:je,mode:E,laned:Y?Z.get(je.hash):void 0,totalLanes:Y?H:void 0,isExpanded:p.has(je.hash),onToggle:()=>m(je.hash),files:w.get(je.hash)??[],isLoadingFiles:B.has(je.hash),onCopyHash:y,directory:C,onConflict:I,onActionSuccess:d},je.hash))}),e[37]=w,e[38]=C,e[39]=p,e[40]=Y,e[41]=Z,e[42]=B,e[43]=H,e[44]=E,e[45]=d,e[46]=I,e[47]=y,e[48]=m,e[49]=ue):ue=e[49];const he=ue;let me;e[50]!==v||e[51]!==r.all.length||e[52]!==f||e[53]!==x||e[54]!==P?(me=r.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:()=>x(f+25),disabled:v,className:"px-3 text-muted-foreground hover:text-foreground",children:v?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(D,{name:"loader-4",className:"size-3 animate-spin"}),P("gitView.history.loadingMore")]}):P("gitView.history.loadMore")})}):null,e[50]=v,e[51]=r.all.length,e[52]=f,e[53]=x,e[54]=P,e[55]=me):me=e[55];const le=me;L=t.jsx(yr,{outerClassName:`min-h-0 ${O}`,className:"h-full w-full",children:r.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:P("gitView.history.noCommits")})}):ce&&N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[h.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:he(h)}):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:N.branchName,children:N.branchName}),ve]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),te.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:he(te)}):null]}),le]}):t.jsxs(t.Fragment,{children:[he(r.all),le]})}),e[12]=N,e[13]=w,e[14]=O,e[15]=C,e[16]=p,e[17]=Q,e[18]=ce,e[19]=Y,e[20]=v,e[21]=Z,e[22]=B,e[23]=r.all,e[24]=f,e[25]=H,e[26]=E,e[27]=d,e[28]=I,e[29]=y,e[30]=x,e[31]=m,e[32]=P,e[33]=h,e[34]=L}else L=e[34];const T=L;if(!R){if(ce){let de;return e[56]!==T?(de=t.jsx("section",{className:"h-full min-h-0",children:T}),e[56]=T,e[57]=de):de=e[57],de}let te;return e[58]!==T?(te=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:T}),e[58]=T,e[59]=te):te=e[59],te}let u;e[60]!==P?(u=P("gitView.history.title"),e[60]=P,e[61]=u):u=e[61];let M;e[62]!==u?(M=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:u}),e[62]=u,e[63]=M):M=e[63];let $;e[64]!==v||e[65]!==g||e[66]!==f||e[67]!==x||e[68]!==P?($=g&&t.jsx("div",{onClick:si,onPointerDown:ri,children:t.jsxs(Un,{value:String(f),onValueChange:te=>x(Number(te)),disabled:v,children:[t.jsx(Kn,{size:"sm",className:"w-auto",disabled:v,children:t.jsx(Jn,{placeholder:P("gitView.history.commitsPlaceholder")})}),t.jsx(qn,{children:Xa.map(te=>t.jsx(Yn,{value:String(te.value),children:P(te.labelKey)},te.value))})]})}),e[64]=v,e[65]=g,e[66]=f,e[67]=x,e[68]=P,e[69]=$):$=e[69];let ae;e[70]!==g?(ae=g?t.jsx(D,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(D,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=g,e[71]=ae):ae=e[71];let ie;e[72]!==$||e[73]!==ae?(ie=t.jsxs("div",{className:"flex items-center gap-2",children:[$,ae]}),e[72]=$,e[73]=ae,e[74]=ie):ie=e[74];let ee;e[75]!==M||e[76]!==ie?(ee=t.jsxs(Na,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[M,ie]}),e[75]=M,e[76]=ie,e[77]=ee):ee=e[77];let _;e[78]!==T?(_=t.jsx(Sa,{children:T}),e[78]=T,e[79]=_):_=e[79];let be;return e[80]!==g||e[81]!==ee||e[82]!==_?(be=t.jsxs(ka,{open:g,onOpenChange:U,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[ee,_]}),e[80]=g,e[81]=ee,e[82]=_,e[83]=be):be=e[83],be};function ei(i){return i.lane+1}function ti(i){return[i.commit.hash,i]}function si(i){return i.stopPropagation()}function ri(i){return i.stopPropagation()}const ni=i=>{const e=jt.c(150),{open:n,onOpenChange:r,conflictFiles:v,directory:f,operation:x,onAbort:p,onClearState:m}=i;let w;e[0]!==v?(w=v===void 0?[]:v,e[0]=v,e[1]=w):w=e[1];const B=w,{t:y}=et(),C=Ze(ai),k=Ze(ii),V=Wt(oi),A=Wt(li),I=xt(ci),[d,E]=l.useState(!1),[R,O]=l.useState(null),[N,P]=l.useState(null);let g,U;e[2]!==f||e[3]!==n||e[4]!==y?(g=()=>{!n||!f||(E(!0),P(null),O(null),Qn(f).then(X=>{O(X)}).catch(X=>{const Pe=X instanceof Error?X.message:y("gitView.conflict.loadFailed");P(Pe)}).finally(()=>{E(!1)}))},U=[n,f,y],e[2]=f,e[3]=n,e[4]=y,e[5]=g,e[6]=U):(g=e[5],U=e[6]),l.useEffect(g,U);let Y;e[7]!==R||e[8]!==f||e[9]!==x?(Y=async()=>{if(!R)return null;const X=x==="merge"?"merge":"rebase",Pe=R.headInfo||(x==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Oe=x==="merge"?"git commit --no-edit":"git rebase --continue",ze=await Ht("git.conflict.resolve.visible",{operation_label:X,head_ref:Pe}),Fe=await Ht("git.conflict.resolve.instructions",{operation_label:X,directory:f,operation:x,head_info:R.headInfo||"N/A",continue_cmd:Oe}),pe=`${X} conflict context (JSON)
|
|
3
|
-
${JSON.stringify({directory:f,operation:R.operation,headInfo:R.headInfo,statusPorcelain:R.statusPorcelain,unmergedFiles:R.unmergedFiles,diff:R.diff},null,2)}`;return{visibleText:ze,instructionsText:Fe,payloadText:pe}},e[7]=R,e[8]=f,e[9]=x,e[10]=Y):Y=e[10];const S=Y;let F;e[11]!==p||e[12]!==r?(F=()=>{p(),r(!1)},e[11]=p,e[12]=r,e[13]=F):F=e[13];const J=F;let H;e[14]!==m||e[15]!==r?(H=()=>{m?.(),r(!1)},e[14]=m,e[15]=r,e[16]=H):H=e[16];const G=H;let Z;e[17]!==S||e[18]!==k||e[19]!==m||e[20]!==r||e[21]!==I||e[22]!==V||e[23]!==A||e[24]!==y?(Z=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}if(!k){b.error(y("gitView.conflict.noActiveSession"),{description:y("gitView.conflict.noActiveSessionDescription")});return}V(X.visibleText,"replace"),A([{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]),I("chat"),m?.(),r(!1)},e[17]=S,e[18]=k,e[19]=m,e[20]=r,e[21]=I,e[22]=V,e[23]=A,e[24]=y,e[25]=Z):Z=e[25];const Q=Z;let se;e[26]!==S||e[27]!==f||e[28]!==m||e[29]!==r||e[30]!==C||e[31]!==I||e[32]!==y?(se=async()=>{const X=await S();if(!X){b.error(y("gitView.conflict.noDetailsAvailable"));return}C({directoryOverride:f,initialPrompt:X.visibleText,syntheticParts:[{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]}),I("chat"),m?.(),r(!1)},e[26]=S,e[27]=f,e[28]=m,e[29]=r,e[30]=C,e[31]=I,e[32]=y,e[33]=se):se=e[33];const ce=se;let oe,h,L,T,u,M,$,ae,ie,ee,_,be,te,de,ve,ue,he,me,le,De,je,ge;if(e[34]!==R||e[35]!==B||e[36]!==k||e[37]!==J||e[38]!==G||e[39]!==Q||e[40]!==ce||e[41]!==d||e[42]!==N||e[43]!==r||e[44]!==n||e[45]!==x||e[46]!==y){const X=y(x==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),Pe=R?.unmergedFiles||B;L=ut,je=n,ge=r,h=mt,De="max-w-md w-[calc(100vw-2rem)]",de="flex flex-col gap-4 overflow-hidden";let Oe;e[69]===Symbol.for("react.memo_cache_sentinel")?(Oe=t.jsx(D,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[69]=Oe):Oe=e[69];const ze=t.jsxs("div",{className:"flex items-center gap-2",children:[Oe,t.jsx(gt,{children:y("gitView.conflict.detectedTitle",{operation:X})})]});let Fe;e[70]!==x||e[71]!==y?(Fe=y("gitView.conflict.detectedDescription",{operation:x}),e[70]=x,e[71]=y,e[72]=Fe):Fe=e[72];let pe;e[73]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[73]=Fe,e[74]=pe):pe=e[74],e[75]!==ze||e[76]!==pe?(ve=t.jsxs(ht,{children:[ze,pe]}),e[75]=ze,e[76]=pe,e[77]=ve):ve=e[77],e[78]!==d||e[79]!==y?(ue=d&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:y("gitView.conflict.loading")})]}),e[78]=d,e[79]=y,e[80]=ue):ue=e[80],e[81]!==N||e[82]!==y?(he=N&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:y("gitView.conflict.errorLoadingDetails",{message:N})}),e[81]=N,e[82]=y,e[83]=he):he=e[83],e[84]!==Pe||e[85]!==y?(me=Pe.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:y("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:Pe.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:Pe.map(di)})})]}),e[84]=Pe,e[85]=y,e[86]=me):me=e[86],e[87]!==R||e[88]!==y?(le=R?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("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:R.headInfo})]}),e[87]=R,e[88]=y,e[89]=le):le=e[89],_="flex flex-col gap-2 pt-2";let Ce;e[90]!==ce?(Ce=()=>{ce()},e[90]=ce,e[91]=Ce):Ce=e[91];const Ge=d||!R;let Ne;e[92]!==d?(Ne=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"add",className:"size-4"}),e[92]=d,e[93]=Ne):Ne=e[93];let Be;e[94]!==y?(Be=y("gitView.conflict.resolveNewSession"),e[94]=y,e[95]=Be):Be=e[95],e[96]!==Ce||e[97]!==Ge||e[98]!==Ne||e[99]!==Be?(be=t.jsxs(W,{variant:"default",onClick:Ce,disabled:Ge,className:"w-full gap-2",children:[Ne,Be]}),e[96]=Ce,e[97]=Ge,e[98]=Ne,e[99]=Be,e[100]=be):be=e[100];let q;e[101]!==Q?(q=()=>{Q()},e[101]=Q,e[102]=q):q=e[102];const xe=d||!R||!k;let Se;e[103]!==d?(Se=d?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"chat-1",className:"size-4"}),e[103]=d,e[104]=Se):Se=e[104];let we;e[105]!==y?(we=y("gitView.conflict.resolveCurrentSession"),e[105]=y,e[106]=we):we=e[106],e[107]!==q||e[108]!==xe||e[109]!==Se||e[110]!==we?(te=t.jsxs(W,{variant:"outline",onClick:q,disabled:xe,className:"w-full gap-2",children:[Se,we]}),e[107]=q,e[108]=xe,e[109]=Se,e[110]=we,e[111]=te):te=e[111],ie="flex gap-2 pt-1";let ye;e[112]!==y?(ye=y("gitView.conflict.continueLater"),e[112]=y,e[113]=ye):ye=e[113],e[114]!==G||e[115]!==ye?(ee=t.jsx(W,{variant:"ghost",size:"sm",onClick:G,className:"flex-1",children:ye}),e[114]=G,e[115]=ye,e[116]=ee):ee=e[116],oe=W,T="destructive",u="sm",M=J,$="flex-1",ae=y("gitView.conflict.abortOperation",{operation:X}),e[34]=R,e[35]=B,e[36]=k,e[37]=J,e[38]=G,e[39]=Q,e[40]=ce,e[41]=d,e[42]=N,e[43]=r,e[44]=n,e[45]=x,e[46]=y,e[47]=oe,e[48]=h,e[49]=L,e[50]=T,e[51]=u,e[52]=M,e[53]=$,e[54]=ae,e[55]=ie,e[56]=ee,e[57]=_,e[58]=be,e[59]=te,e[60]=de,e[61]=ve,e[62]=ue,e[63]=he,e[64]=me,e[65]=le,e[66]=De,e[67]=je,e[68]=ge}else oe=e[47],h=e[48],L=e[49],T=e[50],u=e[51],M=e[52],$=e[53],ae=e[54],ie=e[55],ee=e[56],_=e[57],be=e[58],te=e[59],de=e[60],ve=e[61],ue=e[62],he=e[63],me=e[64],le=e[65],De=e[66],je=e[67],ge=e[68];let Ve;e[117]!==oe||e[118]!==T||e[119]!==u||e[120]!==M||e[121]!==$||e[122]!==ae?(Ve=t.jsx(oe,{variant:T,size:u,onClick:M,className:$,children:ae}),e[117]=oe,e[118]=T,e[119]=u,e[120]=M,e[121]=$,e[122]=ae,e[123]=Ve):Ve=e[123];let Me;e[124]!==ie||e[125]!==ee||e[126]!==Ve?(Me=t.jsxs("div",{className:ie,children:[ee,Ve]}),e[124]=ie,e[125]=ee,e[126]=Ve,e[127]=Me):Me=e[127];let Ee;e[128]!==_||e[129]!==be||e[130]!==te||e[131]!==Me?(Ee=t.jsxs("div",{className:_,children:[be,te,Me]}),e[128]=_,e[129]=be,e[130]=te,e[131]=Me,e[132]=Ee):Ee=e[132];let Ie;e[133]!==de||e[134]!==ve||e[135]!==ue||e[136]!==he||e[137]!==me||e[138]!==le||e[139]!==Ee?(Ie=t.jsxs("div",{className:de,children:[ve,ue,he,me,le,Ee]}),e[133]=de,e[134]=ve,e[135]=ue,e[136]=he,e[137]=me,e[138]=le,e[139]=Ee,e[140]=Ie):Ie=e[140];let Le;e[141]!==h||e[142]!==De||e[143]!==Ie?(Le=t.jsx(h,{className:De,children:Ie}),e[141]=h,e[142]=De,e[143]=Ie,e[144]=Le):Le=e[144];let fe;return e[145]!==L||e[146]!==je||e[147]!==ge||e[148]!==Le?(fe=t.jsx(L,{open:je,onOpenChange:ge,children:Le}),e[145]=L,e[146]=je,e[147]=ge,e[148]=Le,e[149]=fe):fe=e[149],fe};function ai(i){return i.openNewSessionDraft}function ii(i){return i.currentSessionId}function oi(i){return i.setPendingInputText}function li(i){return i.setPendingSyntheticParts}function ci(i){return i.setActiveMainTab}function di(i){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:i,children:i},i)}const ui=({open:i,onOpenChange:e,operation:n,targetBranch:r,onConfirm:v})=>{const{t:f}=et(),[x,p]=l.useState(!0),[m,w]=l.useState(!1),B=f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),y=async()=>{w(!0);try{await v(x),e(!1)}catch(k){const V=k instanceof Error?k.message:`Failed to ${n}`;b.error(V)}finally{w(!1)}},C=()=>{m||e(!1)};return t.jsx(ut,{open:i,onOpenChange:m?void 0:e,children:t.jsxs(mt,{className:"max-w-md",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(gt,{children:f("gitView.stash.title")})]}),t.jsx(wt,{children:f("gitView.stash.description",{operation:n})})]}),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(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(n==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:r})]}),x&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(Xn,{checked:x,onChange:p,disabled:m,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!m&&p(!x),children:f("gitView.stash.restoreAfterOperation",{operation:n})})]}),t.jsxs(ks,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:C,disabled:m,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:y,disabled:m,className:"gap-1.5",children:m?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:B})})]})]})})},mi=({mergeInProgress:i,rebaseInProgress:e,onContinue:n,onAbort:r,onResolveWithAI:v,conflictCount:f=0,isLoading:x=!1})=>{const{t:p}=et(),[m,w]=l.useState(null),B=i&&i.head,y=e&&(e.headName||e.onto),C=B?"merge":y?"rebase":null;if(!C)return null;const k=async()=>{w("continue");try{await n()}finally{w(null)}},V=async()=>{w("abort");try{await r()}finally{w(null)}},A=m!==null,I=f>0,d=p(C==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let E="";i?E=i.message?p("gitView.operation.mergingMessage",{message:i.message}):p("gitView.operation.mergeInProgressWithHead",{head:i.head}):e&&(E=e.headName?p("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):p("gitView.operation.rebaseInProgress"));const R=I?f===1?p("gitView.operation.inProgressTitleOneConflict",{operation:d,count:f}):p("gitView.operation.inProgressTitleManyConflicts",{operation:d,count:f}):p("gitView.operation.inProgressTitle",{operation:d}),O=p(I?"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:R}),E&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:E})]}),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:O}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:V,disabled:A||x,className:"gap-1.5",children:[m==="abort"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"close",className:"size-4"}),p("gitView.operation.abort")]}),I?v&&t.jsx(W,{variant:"default",size:"sm",onClick:v,disabled:A||x,children:p("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:k,disabled:A||x,className:"gap-1.5",children:[m==="continue"?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"check",className:"size-4"}),p("gitView.operation.continue")]})]})]})]})})},hi=i=>{const e=jt.c(104),{currentBranch:n,localBranches:r,remoteBranches:v,onMerge:f,onRebase:x,disabled:p,isOperating:m,operationLogs:w,onOperationComplete:B,mode:y,defaultTargetBranch:C}=i,k=p===void 0?!1:p,V=m===void 0?!1:m,A=w===void 0?[]:w,I=y===void 0?"dialog":y,{t:d}=et(),[E,R]=l.useState(!1),[O,N]=l.useState("merge"),[P,g]=l.useState(null),[U,Y]=l.useState(!1),[S,F]=l.useState(""),J=l.useRef(null),H=l.useRef(null),G=k||V,Z=n||d("gitView.branch.currentBranchFallback"),Q=A.length>0&&A.every(gi),se=A.some(fi);let ce;e[0]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{H.current&&(H.current.scrollTop=H.current.scrollHeight)},e[0]=ce):ce=e[0],l.useEffect(ce,[A]);let oe;if(e[1]!==S||e[2]!==n||e[3]!==r||e[4]!==v){e:{const q=S.toLowerCase();let xe;e[6]!==v?(xe=new Set(v.map(pi).filter(Boolean)),e[6]=v,e[7]=xe):xe=e[7];const Se=xe;let we;e[8]!==n||e[9]!==Se?(we=_e=>_e!==n&&!Se.has(_e),e[8]=n,e[9]=Se,e[10]=we):we=e[10];const ye=r.filter(we);if(!q){oe=ye;break e}oe=ye.filter(_e=>_e.toLowerCase().includes(q))}e[1]=S,e[2]=n,e[3]=r,e[4]=v,e[5]=oe}else oe=e[5];const h=oe;let L;if(e[11]!==S||e[12]!==v){e:{const q=S.toLowerCase();if(!q){L=v;break e}L=v.filter(xe=>xe.toLowerCase().includes(q))}e[11]=S,e[12]=v,e[13]=L}else L=e[13];const T=L;let u;e[14]!==C||e[15]!==r||e[16]!==v?(u=()=>C&&(v.includes(C)||r.includes(C))?C:null,e[14]=C,e[15]=r,e[16]=v,e[17]=u):u=e[17];const M=u;let $;e[18]!==M||e[19]!==R?($=()=>{R(!0),g(M()),N("merge"),F("")},e[18]=M,e[19]=R,e[20]=$):$=e[20];const ae=$;let ie;e[21]===Symbol.for("react.memo_cache_sentinel")?(ie=q=>{g(q),Y(!1),F("")},e[21]=ie):ie=e[21];const ee=ie;let _;e[22]!==f||e[23]!==x||e[24]!==O||e[25]!==P?(_=()=>{P&&(O==="merge"?f(P):x(P))},e[22]=f,e[23]=x,e[24]=O,e[25]=P,e[26]=_):_=e[26];const be=_;let te;e[27]!==V||e[28]!==R?(te=()=>{V||(g(null),N("merge"),F(""),R(!1))},e[27]=V,e[28]=R,e[29]=te):te=e[29];const de=te,ve=()=>{V&&!Q||(Q&&B?.(),g(null),N("merge"),F(""),R(!1))};let ue,he;e[30]!==U?(ue=()=>{U||F("")},he=[U],e[30]=U,e[31]=ue,e[32]=he):(ue=e[31],he=e[32]),l.useEffect(ue,he);let me,le;e[33]!==I||e[34]!==M||e[35]!==P?(me=()=>{I==="dialog"||P||g(M())},le=[I,M,P],e[33]=I,e[34]=M,e[35]=P,e[36]=me,e[37]=le):(me=e[36],le=e[37]),l.useEffect(me,le);const ge=V?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:H,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:A.map(xi)})}),Q?I==="dialog"?t.jsx(ks,{children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:ve,children:d(se?"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:d("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>N("merge"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-merge",className:Re("size-4",O==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="merge"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>N("rebase"),className:Re("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",O==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{name:"git-branch",className:Re("size-4",O==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Re("typography-ui-label",O==="rebase"?"text-foreground":"text-muted-foreground"),children:d("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:d("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?d("gitView.branch.branchToMergeInto",{branch:Z}):d("gitView.branch.branchToRebaseOnto")}),t.jsxs(Vs,{open:U,onOpenChange:Y,modal:!1,children:[t.jsx(Is,{asChild:!0,children:t.jsxs("button",{type:"button",className:Re(wr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Re("truncate",!P&&"text-muted-foreground"),children:P||d("gitView.branch.selectBranch")}),t.jsx(D,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Ps,{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(Fs,{className:"h-full min-h-0",children:[t.jsx(Rs,{ref:J,placeholder:d("gitView.branch.searchPlaceholder"),value:S,onValueChange:F,onKeyDown:wi}),t.jsxs(Ms,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Bs,{children:d("gitView.branch.empty")}),h.length>0&&t.jsx(Ut,{heading:d("gitView.branch.localBranches"),children:h.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`local-${q}`))}),h.length>0&&T.length>0?t.jsx(Zn,{}):null,T.length>0&&t.jsx(Ut,{heading:d("gitView.branch.remoteBranches"),children:T.map(q=>t.jsx(Kt,{onSelect:()=>ee(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`remote-${q}`))})]})]})})]})]}),P?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:O==="merge"?t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})," ",d("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})]}):t.jsxs(t.Fragment,{children:[d("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z})," ",d("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:P})]})})}):null,I==="dialog"?t.jsxs(ks,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:de,children:d("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:!P,className:"gap-1.5",children:O==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-merge",className:"size-4"}),d("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(D,{name:"git-branch",className:"size-4"}),d("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:de,disabled:G,children:d("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:be,disabled:G||!P,children:d(O==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(I==="bare")return ge;if(I==="inline"){let q;e[38]!==d?(q=d("gitView.branch.updateTitle"),e[38]=d,e[39]=q):q=e[39];let xe;e[40]!==q?(xe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:q}),e[40]=q,e[41]=xe):xe=e[41];let Se;e[42]!==d?(Se=d("gitView.branch.updateDescriptionPrefix"),e[42]=d,e[43]=Se):Se=e[43];let we;e[44]!==Z?(we=t.jsx("span",{className:"font-mono text-foreground",children:Z}),e[44]=Z,e[45]=we):we=e[45];let ye;e[46]!==Se||e[47]!==we?(ye=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Se," ",we,"."]}),e[46]=Se,e[47]=we,e[48]=ye):ye=e[48];let _e;e[49]!==xe||e[50]!==ye?(_e=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[xe,ye]})}),e[49]=xe,e[50]=ye,e[51]=_e):_e=e[51];let tt;e[52]!==ge?(tt=t.jsx("div",{className:"pt-3",children:ge}),e[52]=ge,e[53]=tt):tt=e[53];let st;return e[54]!==_e||e[55]!==tt?(st=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[_e,tt]}),e[54]=_e,e[55]=tt,e[56]=st):st=e[56],st}let Ve;e[57]!==V?(Ve=V?t.jsx(D,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(D,{name:"git-merge",className:"size-4"}),e[57]=V,e[58]=Ve):Ve=e[58];let Me;e[59]!==d?(Me=d("gitView.branch.mergeRebase"),e[59]=d,e[60]=Me):Me=e[60];let Ee;e[61]!==Me?(Ee=t.jsx("span",{children:Me}),e[61]=Me,e[62]=Ee):Ee=e[62];let Ie;e[63]!==ae||e[64]!==G||e[65]!==Ve||e[66]!==Ee?(Ie=t.jsx(qt,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ae,disabled:G,children:[Ve,Ee]})}),e[63]=ae,e[64]=G,e[65]=Ve,e[66]=Ee,e[67]=Ie):Ie=e[67];let Le;e[68]!==d?(Le=d("gitView.branch.mergeRebaseTooltip"),e[68]=d,e[69]=Le):Le=e[69];let fe;e[70]!==Le?(fe=t.jsx(Yt,{sideOffset:8,children:Le}),e[70]=Le,e[71]=fe):fe=e[71];let X;e[72]!==Ie||e[73]!==fe?(X=t.jsxs(Jt,{children:[Ie,fe]}),e[72]=Ie,e[73]=fe,e[74]=X):X=e[74];let Pe;e[75]!==ve||e[76]!==R?(Pe=q=>{q?R(!0):ve()},e[75]=ve,e[76]=R,e[77]=Pe):Pe=e[77];let Oe;e[78]!==d?(Oe=d("gitView.branch.updateTitle"),e[78]=d,e[79]=Oe):Oe=e[79];let ze;e[80]!==Oe?(ze=t.jsx(gt,{children:Oe}),e[80]=Oe,e[81]=ze):ze=e[81];let Fe;e[82]!==se||e[83]!==V||e[84]!==O||e[85]!==Q||e[86]!==d||e[87]!==Z?(Fe=V?d(Q?se?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":O==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[d("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:Z}),"."]}),e[82]=se,e[83]=V,e[84]=O,e[85]=Q,e[86]=d,e[87]=Z,e[88]=Fe):Fe=e[88];let pe;e[89]!==Fe?(pe=t.jsx(wt,{children:Fe}),e[89]=Fe,e[90]=pe):pe=e[90];let Ce;e[91]!==ze||e[92]!==pe?(Ce=t.jsxs(ht,{children:[ze,pe]}),e[91]=ze,e[92]=pe,e[93]=Ce):Ce=e[93];let Ge;e[94]!==ge||e[95]!==Ce?(Ge=t.jsxs(mt,{className:"max-w-md",children:[Ce,ge]}),e[94]=ge,e[95]=Ce,e[96]=Ge):Ge=e[96];let Ne;e[97]!==E||e[98]!==Pe||e[99]!==Ge?(Ne=t.jsx(ut,{open:E,onOpenChange:Pe,children:Ge}),e[97]=E,e[98]=Pe,e[99]=Ge,e[100]=Ne):Ne=e[100];let Be;return e[101]!==X||e[102]!==Ne?(Be=t.jsxs(t.Fragment,{children:[X,Ne]}),e[101]=X,e[102]=Ne,e[103]=Be):Be=e[103],Be};function gi(i){return i.status==="done"||i.status==="error"}function fi(i){return i.status==="error"}function pi(i){return i.slice(i.indexOf("/")+1)}function xi(i,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[i.status==="running"&&t.jsx(D,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),i.status==="done"&&t.jsx(D,{name:"check",className:"size-3.5 text-success"}),i.status==="error"&&t.jsx(D,{name:"close",className:"size-3.5 text-destructive"}),i.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Re("typography-micro",i.status==="error"&&"text-destructive",i.status==="done"&&"text-muted-foreground",i.status==="running"&&"text-foreground",i.status==="pending"&&"text-muted-foreground/60"),children:i.message})]},e)}function wi(i){return i.stopPropagation()}const yi=({runMutation:i,onMutationComplete:e,onMutationError:n,onPathsComplete:r,scheduleFlush:v})=>{const f=[];let x=!1;return{enqueue:m=>{const w=f[f.length-1];if(w?.directory===m.directory&&w.direction===m.direction){m.paths.forEach(B=>w.paths.add(B));return}f.push(m)},flush:()=>{if(x)return;const m=f.shift();if(!m)return;x=!0;const w={directory:m.directory,direction:m.direction,paths:Array.from(m.paths),rollback:m.rollback};(async()=>{try{await i(w),e(w)}catch(B){n(w,B)}finally{r(w.paths),x=!1,f.length>0&&v()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>x}},bi=15e3,vi=40,ji=20,pr={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:"},Ci=(i,e)=>{const n=i.toLowerCase(),r=/^([a-z]+)(?:\(.*\))?!?:/,v=n.match(r);if(v){const p=v[1],m=pr[p];if(m)return e.find(w=>w.code===m)||null}const f=n.split(" ")[0],x=pr[f];return x&&e.find(p=>p.code===x)||null},Ni=20,vt=new Map,Si=(i,e)=>{if(vt.delete(i),vt.set(i,e),vt.size>Ni){const n=vt.keys().next().value;n!==void 0&&vt.delete(n)}},nt=i=>(i||"").replace(/\\/g,"/").replace(/\/+$/,""),xr=i=>{const e=i.index?.trim();return!!(e&&e!=="?")},ki=i=>{const e=i.working_dir?.trim(),n=i.index?.trim();return!!(e||n==="?")},Gl=({isActive:i})=>{const{t:e}=et(),{git:n}=ea(),r=ta(),[v,f]=l.useState(null),[x,p]=l.useState(!1),m=Ze(s=>s.currentSessionId),w=Ze(s=>s.newSessionDraft),B=Ze(s=>s.setDraftBootstrapPendingDirectory),y=Ze(s=>s.worktreeMetadata),C=Ze(s=>s.availableWorktrees),k=nt(r),V=l.useMemo(()=>{if(!k)return;const s=C.find(a=>nt(a.path)===k);if(s)return s;for(const a of y.values())if(nt(a.path)===k)return a},[C,k,y]),A=l.useMemo(()=>{if(m)return y.get(m)??V;if(w?.open)return V},[m,V,w?.open,y]),{profiles:I,globalIdentity:d,defaultGitIdentityId:E,loadProfiles:R,loadGlobalIdentity:O,loadDefaultGitIdentityId:N}=Va(ar(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),P=sa(r??null),g=ra(r??null),U=na(s=>m?s.getAttachment(m):void 0),Y=U?aa(U):[],S=U&&!U.degraded&&!U.legacy?U.worktreeRoot??void 0:void 0,F=va(r,A,g?.current??void 0),J=ia(r??null),H=oa(r??null),G=la(r??null),Z=ca(r??null),Q=da(r??null),{setActiveDirectory:se,fetchAll:ce,ensureAll:oe,fetchStatus:h,fetchBranches:L,fetchLog:T,setLogMaxCount:u,fetchIdentity:M,prefetchDiffs:$,clearDiffCache:ae,moveStatusPathsOptimistically:ie,restoreStatus:ee,bumpIndexRevision:_}=ua(ar(s=>({setActiveDirectory:s.setActiveDirectory,fetchAll:s.fetchAll,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}))),be=xt(s=>s.isMobile),te=xt(s=>s.openContextDiff),de=xt(s=>s.openContextSurface),ve=g?.current??null,ue=ma(s=>!r||!ve?null:ha(s.entries,r,ve)),he=xt(s=>s.navigateToDiff),me=l.useRef(null),le=l.useRef(null),De=l.useRef(null),je=l.useRef(null),ge=l.useRef(!0);l.useEffect(()=>()=>{ge.current=!1},[]);const Ve=l.useCallback(()=>{le.current!==null&&(window.clearTimeout(le.current),le.current=null)},[]),Me=l.useCallback(s=>{Ve(),le.current=window.setTimeout(()=>{le.current=null,nt(s)===nt(r)&&h(s,n,{silent:!0})},bi)},[Ve,r,h,n]);l.useEffect(()=>Ve,[Ve]);const Ee=l.useCallback(()=>{De.current!==null&&(window.clearTimeout(De.current),De.current=null)},[]),Ie=l.useCallback(()=>{De.current===null&&(De.current=window.setTimeout(()=>{De.current=null,je.current?.()},0))},[]),Le=l.useCallback(async(s,a,o)=>{if(a==="stage"){if(n.stageGitFiles){await n.stageGitFiles(s,o);return}await Promise.all(o.map(c=>n.stageGitFile(s,c)));return}if(n.unstageGitFiles){await n.unstageGitFiles(s,o);return}await Promise.all(o.map(c=>n.unstageGitFile(s,c)))},[n]),fe=l.useMemo(()=>yi({runMutation:({directory:s,direction:a,paths:o})=>Le(s,a,o),onMutationComplete:({directory:s})=>{_(s),Me(s)},onMutationError:({directory:s,direction:a,rollback:o},c)=>{o?.(),_(s),Me(s);const j=e(a==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");b.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{As(a=>{const o=new Set(a);return s.forEach(c=>o.delete(c)),o})},scheduleFlush:Ie}),[_,Le,Ie,Me,e]);l.useEffect(()=>(je.current=fe.flush,()=>{je.current=null}),[fe]),l.useEffect(()=>()=>fe.clear(),[fe]),l.useEffect(()=>Ee,[Ee]),l.useEffect(()=>{if(!i)return;if(!r){f(null),p(!1);return}let s=!1,a=null;const o=async()=>{try{const c=await ba(r);if(s)return;f(c.status),c.status==="pending"&&(a=window.setTimeout(()=>{o()},500))}catch{s||f(null)}};return o(),()=>{s=!0,a!==null&&window.clearTimeout(a)}},[i,r]),l.useEffect(()=>{const s=me.current;me.current=v,!(!r||!n)&&(s==="pending"&&v==="ready"&&(p(!0),ce(r,n).finally(()=>{window.setTimeout(()=>{p(!1)},1200)})),v==="failed"&&(B(null),p(!1)))},[r,ce,n,B,v]);const X=nt(w?.bootstrapPendingDirectory??null),Pe=!!(r&&X&&X===nt(r)),ze=!!(r&&(v==="pending"||Pe))||x,Fe=l.useMemo(()=>r?vt.get(r)??null:null,[r]),pe=ga(s=>s.settingsGitmojiEnabled),[Ce,Ge]=l.useState(null),{gitmojis:Ne}=Ea(pe);l.useEffect(()=>{const s=S||F?.projectDirectory;if(!s){Ge(null);return}let a=!1;return fa(s).then(o=>{if(a)return;const c=o.trim();Ge(c&&c!=="HEAD"?c:null)}).catch(()=>{a||Ge(null)}),()=>{a=!0}},[S,F?.projectDirectory]);const[Be,q]=l.useState(Fe?.commitMessage??""),[xe,Se]=l.useState([]),[we,ye]=l.useState(!1),_e=l.useRef(null),[tt,st]=l.useState(null),[Cr,Qt]=l.useState(!1),[Ts,Ds]=l.useState(null),[Je,Nr]=l.useState(25),[Sr,Es]=l.useState(!1),{triggerFireworks:kr}=ja(),Ls=l.useRef(new Map),Pt=l.useRef(0),Xt=l.useCallback(()=>{Pt.current+=1,ge.current&&Es(!0)},[]),Zt=l.useCallback(()=>{Pt.current=Math.max(0,Pt.current-1),ge.current&&Pt.current===0&&Es(!1)},[]),[es,Ft]=l.useState(new Set),[Vr,As]=l.useState(new Set),[ts,Os]=l.useState(!1),[Ir,Pr]=l.useState(0),[Fr,zs]=l.useState(!1),[ss,Gs]=l.useState(Fe?.generatedHighlights??[]),Rr=Vr.size>0||fe.size()>0||fe.isRunning(),_s=l.useCallback(()=>{const s=_e.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),rs=S||F?.projectDirectory||null,ns=g?.current||null,Mr=l.useMemo(()=>{const s=g?.tracking;return s?s.startsWith("origin/"):!0},[g?.tracking]),$s=l.useMemo(()=>{const s=F?.createdFromBranch,a=typeof s=="string"?s.trim():"",o=typeof g?.current=="string"?g.current.trim():"",c=typeof Ce=="string"?Ce.trim():"";return a?a===o&&a.startsWith("opencode/")&&c.length>0&&c!==a?c:a:c||o||"HEAD"},[F?.createdFromBranch,g,Ce]),Rt=l.useCallback(()=>{Gs([])},[]),[as,Br]=l.useState(new Set),[Mt,Tr]=l.useState(new Map),[Bt,is]=l.useState(new Set),os=l.useRef(Mt),Nt=l.useRef(Bt),[Dr,yt]=l.useState(null),[ft,ls]=l.useState(null),[Hs,Ws]=l.useState(""),[Ae,Tt]=l.useState(null),[Er,Us]=l.useState(!1),[Lr,Ks]=l.useState(!1),[cs,ds]=l.useState([]),[Ar,Js]=l.useState(null),[qs,us]=l.useState(null),[Or,Dt]=l.useState([]),[zr,qe]=l.useState(!1),[Gr,Qe]=l.useState([]),[Et,Xe]=l.useState("merge"),[_r,ms]=l.useState(null),[hs,Ys]=l.useState(!1),[gs,$r]=l.useState(100),[Hr,Wr]=l.useState(0),Ye=l.useMemo(()=>m?`openchamber.conflict:${m}`:null,[m]),rt=l.useCallback((s,a,o)=>{if(!Ye||typeof window>"u")return;const c={directory:s,conflictFiles:a,operation:o};window.localStorage.setItem(Ye,JSON.stringify(c))},[Ye]),We=l.useCallback(()=>{!Ye||typeof window>"u"||window.localStorage.removeItem(Ye)},[Ye]);l.useEffect(()=>{if(!Ye||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Ye);if(s)try{const a=JSON.parse(s);if(a.directory!==r){window.localStorage.removeItem(Ye);return}Qe(a.conflictFiles??[]),Xe(a.operation??"merge"),qe(!0)}catch{window.localStorage.removeItem(Ye)}},[Ye,r]);const[Ur,fs]=l.useState(!1),[ps,Qs]=l.useState("merge"),[xs,Xs]=l.useState(""),Kr=l.useCallback(s=>{pa(s).then(a=>{if(a.ok){b.success(e("gitView.toast.commitHashCopied"));return}b.error(e("gitView.toast.copyFailed"))})},[e]),Jr=l.useCallback(s=>{Br(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},[]);l.useEffect(()=>{os.current=Mt},[Mt]),l.useEffect(()=>{Nt.current=Bt},[Bt]),l.useEffect(()=>{if(!r||!n)return;const s=Array.from(as).filter(o=>!os.current.has(o)&&!Nt.current.has(o));if(s.length===0)return;let a=!1;return is(o=>{const c=new Set(o);for(const j of s)c.add(j);return Nt.current=c,c}),Promise.all(s.map(o=>n.getCommitFiles(r,o).then(c=>({hash:o,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:o,files:[]})))).then(o=>{a||(Tr(c=>{const j=new Map(c);for(const{hash:z,files:ne}of o)j.set(z,ne);return os.current=j,j}),is(c=>{const j=new Set(c);for(const{hash:z}of o)j.delete(z);return Nt.current=j,j}))}),()=>{a=!0,is(o=>{let c=!1;const j=new Set(o);for(const z of s)j.delete(z)&&(c=!0);return c?(Nt.current=j,j):o})}},[as,r,n]),l.useEffect(()=>{r&&Si(r,{directory:r,commitMessage:Be,generatedHighlights:ss})},[Be,r,ss]),l.useEffect(()=>{i&&(R(),O(),N())},[i,R,O,N]),l.useEffect(()=>{if(!i)return;if(!r||!n?.getRemoteUrl){ls(null);return}let s=!1;return n.getRemoteUrl(r).then(a=>{s||ls(a)}).catch(()=>{s||ls(null)}),()=>{s=!0}},[i,r,n]);const Lt=l.useCallback(async()=>{if(!r||!n?.getRemotes){ds([]);return}try{const s=await n.getRemotes(r);ge.current&&ds(s)}catch{ge.current&&ds([])}},[r,n]);l.useEffect(()=>{i&&Lt()},[i,Lt]),l.useEffect(()=>{i&&r&&(se(r),oe(r,n))},[i,r,se,oe,n]),l.useEffect(()=>{if(i&&r)return xa.onGitRefreshHint(s=>{nt(s.directory)===nt(r)&&(s.paths?.length&&ae(r,s.paths),h(r,n,{silent:!0}))})},[i,ae,r,h,n]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,n),L(r,n)])}catch(a){if(s){const o=a instanceof Error?a.message:e("gitView.toast.refreshRepositoryFailed");b.error(o)}}},[r,n,h,L,e]),ke=l.useCallback(async()=>{r&&await T(r,n,Je)},[r,n,T,Je]),ws=l.useCallback(async()=>{r&&await M(r,n)},[r,n,M]);l.useEffect(()=>{if(!i||!r||!n?.hasLocalIdentity||P!==!0)return;const s=typeof E=="string"?E.trim():"";if(!s||s==="global"||Ls.current.get(r)===s)return;let o=!1;return(async()=>{try{const j=await n.hasLocalIdentity?.(r);if(o||j===!0)return;Xt(),await n.setGitIdentity(r,s),Ls.current.set(r,s),await ws()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{o||Zt()}})(),()=>{o=!0}},[i,Xt,r,E,Zt,n,P,ws]);const at=l.useMemo(()=>g?[...g.files??[]].sort((a,o)=>a.path.localeCompare(o.path)):[],[g]),Ue=l.useMemo(()=>at.filter(xr),[at]),ys=l.useMemo(()=>at.filter(ki),[at]);l.useEffect(()=>{if(!r||at.length===0)return;const s=[],a=new Set,o=j=>{!j||a.has(j)||(a.add(j),s.push(j))};if(Ue.forEach(j=>o(j.path)),xe.forEach(o),at.slice(0,ji).forEach(j=>o(j.path)),s.length===0)return;const c=window.setTimeout(()=>{$(r,n,s,{maxFiles:vi})},120);return()=>{window.clearTimeout(c)}},[at,r,n,$,Ue,xe]);const Zs=s=>s?.pushed[0]?.remote||g?.tracking?.split("/")[0]||Ke.find(a=>a.name==="origin")?.name||Ke[0]?.name||"origin",er=async(s,a)=>{if(r){st(s);try{const o=c=>{const j=`${c.name}/`,z=g?.tracking?.startsWith(j)?g.tracking.slice(j.length):void 0;return{remote:c.name,branch:z,rebase:!0}};if(s==="fetch"){if(!a)throw new Error("No remote available for fetch");await n.gitFetch(r,{remote:a.name}),b.success(e("gitView.toast.fetchedFromRemote",{name:a.name}))}else if(s==="pull"){if(!a)throw new Error("No remote available for pull");const c=await n.gitPull(r,o(a));b.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:a.name}))}else if(s==="push"){const c=await n.gitPush(r);b.success(e("gitView.toast.pushedToUpstream",{name:Zs(c)}))}else if(s==="sync"){if(!a)throw new Error("No remote available for sync");let c=0,j=!1;await n.gitFetch(r,{remote:a.name});const z=await n.getGitStatus(r);if((z.behind??0)>0){if((z.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await n.gitPull(r,o(a))).files.length}((await n.getGitStatus(r)).ahead??0)>0&&(await n.gitPush(r),j=!0),c>0&&j?b.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:a.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:a.name})):c>0?b.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:a.name})):j?b.success(e("gitView.toast.pushedToUpstream",{name:a.name})):b.success(e("gitView.toast.alreadyUpToDate"))}await re(!1),await ke()}catch(o){const c=o instanceof Error?o.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});b.error(c)}finally{st(null)}}},qr=l.useCallback(async s=>{if(!r)return;const a=s.name.trim();if(!a){b.error(e("gitView.toast.remoteNameRequired"));return}if(a==="origin"){b.error(e("gitView.toast.cannotRemoveOriginRemote"));return}Js(a);try{await n.removeRemote(r,{remote:a}),b.success(e("gitView.toast.removedRemote",{name:a})),await Promise.all([re(!1),Lt()])}catch(o){const c=o instanceof Error?o.message:`Failed to remove ${a}`;b.error(c)}finally{Js(null)}},[r,n,Lt,re,e]),tr=async(s={})=>{if(!r)return;if(!Be.trim()){b.error(e("gitView.toast.enterCommitMessage"));return}const a=Ue.map(c=>c.path).sort();if(a.length===0){b.error(e("gitView.toast.stageFileToCommit"));return}const o=s.pushAfter?"commitAndPush":"commit";Ds(o);try{if(await n.createGitCommit(r,Be.trim(),{files:a,stageFiles:[]}),_(r),b.success(e("gitView.toast.commitCreated")),q(""),Rt(),await re(),s.pushAfter){const c=g?.tracking?.split("/")[0],j=Ke.find(Vn=>Vn.name===c)??Ke[0];if(!j)throw new Error(e("mobile.changes.noRemote"));st("sync");const z=`${j.name}/`,ne=g?.tracking?.startsWith(z)?g.tracking.slice(z.length):void 0;await n.gitFetch(r,{remote:j.name});const K=await n.getGitStatus(r);if((K.behind??0)>0){if((K.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync")),await re(!1);return}await n.gitPull(r,{remote:j.name,branch:ne,rebase:!0})}const He=await n.getGitStatus(r);let bt;(He.ahead??0)>0&&(bt=await n.gitPush(r)),b.success(e("gitView.toast.pushedToUpstream",{name:Zs(bt)})),kr(),await re(!1)}else await re(!1);await ke(),Pr(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");b.error(j)}finally{Ds(null),s.pushAfter&&st(null)}},Yr=l.useCallback(async()=>{if(!r)return;const s=Ue.map(a=>a.path).sort();if(s.length===0){b.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),zs(!0);try{const{message:a}=await wa(r,s),o=a.subject?.trim()??"",c=Array.isArray(a.highlights)?a.highlights:[];if(o){let j=o;if(pe&&Ne.length>0){const z=Ci(o,Ne);if(z){const{code:ne,emoji:K}=z;!o.startsWith(ne)&&!o.startsWith(K)&&(j=`${ne} ${o}`)}}q(j)}Gs(c),_s()}catch(a){console.error("[git-generation][browser] GitView generate handler failed",{message:a instanceof Error?a.message:String(a),error:a});const o=a instanceof Error?a.message:e("gitView.toast.generateCommitMessageFailed");b.error(o)}finally{zs(!1)}},[r,Ue,pe,Ne,_s,e]),bs=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",Qr=async(s,a)=>{if(!r||!g)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotCreateBranch",{reason:bs(o[0])}));return}const c=g.current??null,j=a?.name??"origin";try{await n.createBranch(r,s,c??"HEAD"),b.success(e("gitView.toast.createdBranch",{name:s})),await n.checkoutBranch(r,s);let z=!1;try{await n.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),z=!0}catch(ne){const K=ne instanceof Error?ne.message:`Unable to push new branch to ${j}.`;b.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",K]})})}await re(),await ke(),z&&b.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(z){const ne=z instanceof Error?z.message:e("gitView.toast.createBranchFailed");throw b.error(ne),z}},Xr=async(s,a)=>{if(!r)return;const o=Cs(U);if(o.length>0){b.error(e("gitView.toast.cannotRenameBranch",{reason:bs(o[0])}));return}try{await n.renameBranch(r,s,a),b.success(e("gitView.toast.renamedBranch",{oldName:s,newName:a})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:a});b.error(j)}},Zr=async s=>{if(!r)return;const a=Cs(U);if(a.length>0){b.error(e("gitView.toast.cannotCheckout",{reason:bs(a[0])}));return}const o=s.replace(/^remotes\//,"");if(g?.current!==o)try{await n.checkoutBranch(r,o),b.success(e("gitView.toast.checkedOut",{name:o})),await re(),await ke()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.checkoutFailed",{name:o});b.error(j)}},en=async s=>{if(r){Xt();try{await n.setGitIdentity(r,s.id),b.success(e("gitView.toast.appliedIdentity",{name:s.name})),await ws()}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.applyIdentityFailed");b.error(o)}finally{Zt()}}},St=l.useMemo(()=>J?.all?J.all.filter(s=>!s.startsWith("remotes/")).sort():[],[J]),it=l.useMemo(()=>J?.all?J.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[J]),Ke=l.useMemo(()=>{if(cs.length>0)return cs;const s=new Set,a=g?.tracking?.trim();a&&a.includes("/")&&s.add(a.split("/")[0]);for(const o of it){const c=o.indexOf("/");c>0&&s.add(o.slice(0,c))}return s.size===0&&ft&&s.add("origin"),Array.from(s).map(o=>({name:o,fetchUrl:ft??"",pushUrl:ft??""}))},[cs,it,ft,g?.tracking]),ot=g?.current??null,sr=l.useMemo(()=>{const s=g?.tracking?.trim().split("/")[0];return(s&&J?.defaultBranches?.[s])??J?.defaultBranches?.origin},[J,g?.tracking]),pt=l.useMemo(()=>Ca({remoteNames:new Set(Ke.map(s=>s.name)),localBranches:St,worktreeCreatedFromBranch:F?.createdFromBranch,rootBranchHint:Ce,defaultBranch:sr,headBranch:ot}),[ot,sr,Ke,St,Ce,F?.createdFromBranch]),tn=l.useMemo(()=>Ke.map(o=>o.name).map(o=>`${o}/${pt}`).find(o=>it.includes(o))??pt,[pt,Ke,it]),sn=l.useMemo(()=>{const s=new Map;d&&s.set(d.id,d);let a=null;if(ft)try{let o=ft.trim();o.startsWith("git@")&&(o=`https://${o.slice(4).replace(":","/")}`),o.endsWith(".git")&&(o=o.slice(0,-4));const c=new URL(o);a=c.hostname+c.pathname}catch{}for(const o of I){if(o.authType!=="token"){s.set(o.id,o);continue}const c=o.host;if(!c){s.set(o.id,o);continue}if(!c.includes("/")){s.set(o.id,o);continue}a&&a===c&&s.set(o.id,o)}return Array.from(s.values())},[I,d,ft]),rn=l.useMemo(()=>{if(G?.userName&&G?.userEmail){const s=I.find(a=>a.userName===G.userName&&a.userEmail===G.userEmail);return s||(d&&d.userName===G.userName&&d.userEmail===G.userEmail?d:{id:"local-config",name:G.userName,userName:G.userName,userEmail:G.userEmail,sshKey:G.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return d??null},[G,I,d]),nn=Ue.length,an=Z||tt!==null||Ts!==null,on=!!(F&&rs&&ns&&Mr),rr=!!ot,lt=on&&rs&&ns&&F?{repoRoot:rs,sourceBranch:ns,worktreeMetadata:F}:null;l.useEffect(()=>{if(!r||!n||!H?.all?.length||!ot||!pt||ot===pt){yt(null);return}let s=!1;return(async()=>{try{const o=await n.getGitLog(r,{from:pt,to:"HEAD",maxCount:Je});if(s)return;const c=new Set((o?.all??[]).map(z=>z.hash).filter(z=>typeof z=="string"&&z.length>0));if(c.size===0){yt(null);return}const j=H.all.findIndex(z=>!c.has(z.hash));if(j===0){yt(null);return}if(j===-1){yt({insertBeforeIndex:H.all.length,branchName:ot,direction:"up"});return}yt({insertBeforeIndex:j,branchName:ot,direction:"up"})}catch{s||yt(null)}})(),()=>{s=!0}},[pt,ot,r,n,H,Je]),l.useEffect(()=>{ms(null)},[r]),l.useEffect(()=>{if(Ae!=="graph"||!r){Ae!=="graph"&&ms(null);return}let s=!1;return Ys(!0),n.getGitLog(r,{maxCount:gs,all:!0}).then(a=>{s||ms(a)}).catch(a=>{console.error("Failed to fetch graph log:",a)}).finally(()=>{s||Ys(!1)}),()=>{s=!0}},[Ae,r,gs,Hr,n]);const kt=l.useCallback((s,a)=>{if(!r||s.length===0)return;const o=Array.from(new Set(s));As(j=>{const z=new Set(j);return o.forEach(ne=>z.add(ne)),z});const c=ie(r,o,a);fe.enqueue({directory:r,direction:a,paths:new Set(o),rollback:()=>ee(r,c)}),Ie()},[r,fe,ie,ee,Ie]),vs=l.useCallback(async s=>{if(r){Ft(a=>{const o=new Set(a);return o.add(s),o});try{await n.revertGitFile(r,s,{scope:"working"}),b.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.revertFailed");b.error(o)}finally{Ft(a=>{const o=new Set(a);return o.delete(s),o})}}},[r,re,n,e]),At=l.useCallback(async(s,a,o="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(ts||c.some(K=>es.has(K)))return;const j=new Set(Ue.map(K=>K.path)),z=o==="all"&&c.some(K=>j.has(K));a&&Os(!0),Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.add(bt)),He});const ne=[];try{if(await Promise.all(c.map(async K=>{try{await n.revertGitFile(r,K,{scope:o})}catch(He){ne.push({path:K,message:He instanceof Error?He.message:e("gitView.toast.revertFailed")})}})),z&&ne.length<c.length&&_(r),await re(!1),ne.length===0)b.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(ne.length===c.length)b.error(ne[0]?.message||e("gitView.toast.revertFailed"));else{const K=c.length-ne.length;b.warning(K===1?e("gitView.toast.revertedSomeSingle",{success:K,failed:ne.length}):e("gitView.toast.revertedSomePlural",{success:K,failed:ne.length}))}}finally{Ft(K=>{const He=new Set(K);return c.forEach(bt=>He.delete(bt)),He}),a&&Os(!1)}},[_,r,n,ts,re,es,Ue,e]),ln=l.useCallback(async s=>{await At(s,!0)},[At]),cn=l.useCallback(async s=>{await At(s,!1,"working")},[At]),js=l.useCallback((s,a)=>{if(r&&!be){te(r,s,a);return}he(s,a)},[r,be,he,te]),dn=l.useCallback(()=>Qt(!0),[]),un=l.useMemo(()=>{const s=[];return Ue.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ue,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:a=>e("gitView.changes.unstageFileAria",{path:a}),onActionFile:a=>{kt([a],"unstage")},onActionAll:a=>{kt(a,"unstage")},onViewDiff:a=>js(a,!0),onRevertFile:vs,showRevertActions:!1,accent:!0}),ys.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:ys,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:a=>e("gitView.changes.stageFileAria",{path:a}),onActionFile:a=>{kt([a],"stage")},onActionAll:a=>{kt(a,"stage")},onViewDiff:a=>js(a,!1),onRevertFile:vs}),s},[vs,js,kt,Ue,e,ys]),mn=l.useCallback(s=>{if(s.length===0)return;const a=s.map(o=>o.trim()).filter(Boolean);if(a.length===0){Rt();return}q(o=>{const c=o.trim(),j=c.length>0?`
|
|
4
|
-
|
|
5
|
-
`:"";return`${c}${j}${a.join(`
|
|
6
|
-
`)}`.trim()}),Rt()},[Rt]),hn=l.useCallback((s,a)=>{const o=a||s;q(c=>{const j=c.trimStart();return j.startsWith(s)||a&&j.startsWith(a)?c:`${o.endsWith(" ")?o:`${o} `}${c}`.trimStart()}),Ws(""),ye(!1)},[]),Ot=l.useCallback(s=>{const a=s instanceof Error?s.message.toLowerCase():"";return a.includes("uncommitted changes")||a.includes("local changes")||a.includes("your local changes would be overwritten")||a.includes("please commit your changes or stash them")||a.includes("cannot rebase: you have unstaged changes")||a.includes("error: cannot pull with rebase")},[]),ct=l.useCallback((s,a)=>{Dt(o=>[...o,{message:s,status:a,timestamp:Date.now()}])},[]),$e=l.useCallback((s,a)=>{Dt(o=>{if(o.length===0)return o;const c=[...o];return c[c.length-1]={...c[c.length-1],status:s,...a?{message:a}:{}},c})},[]),zt=l.useCallback(()=>{Dt([])},[]),gn=l.useCallback(()=>{Dt([]),us(null)},[]),Gt=l.useCallback(s=>{const a=s.trim(),o=new Set(Ke.map(j=>j.name)),c=a.indexOf("/");if(c>0){const j=a.slice(0,c),z=a.slice(c+1);if(o.has(j)&&z)return{branch:a,remote:j,remoteBranch:z}}for(const j of Ke){const z=`${j.name}/${a}`;if(it.includes(z))return{branch:z,remote:j.name,remoteBranch:a}}return{branch:a,remote:null,remoteBranch:null}},[Ke,it]),fn=l.useCallback(async s=>{if(!r)return;us("merge"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Merging ${o.branch} into ${a}...`,"running");const c=await n.merge(r,{branch:o.branch});c.conflict?($e("error","Merge conflicts detected"),Qe(c.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,c.conflictFiles??[],"merge")):($e("done",`Merged ${o.branch} into ${a}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("merge"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),pn=l.useCallback(async s=>{if(!r)return;us("rebase"),zt();const a=g?.current,o=Gt(s);try{o.remote&&o.remoteBranch&&(ct(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),$e("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ct(`Rebasing ${a} onto ${o.branch}...`,"running");const c=await n.rebase(r,{onto:o.branch});c.conflict?($e("error","Rebase conflicts detected"),Qe(c.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,c.conflictFiles??[],"rebase")):($e("done",`Rebased ${a} onto ${o.branch}`),We(),ct("Refreshing repository status...","running"),await re(),await ke(),$e("done","Repository status updated"))}catch(c){if(Ot(c))$e("error","Uncommitted changes detected"),Qs("rebase"),Xs(o.branch),fs(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${o.branch}`;$e("error",j)}}},[r,n,g,Gt,re,ke,Ot,rt,We,ct,$e,zt]),xn=l.useCallback(async()=>{if(r)try{Et==="merge"?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:`Failed to abort ${Et}`;b.error(a)}},[r,n,Et,re,ke,We,e]),wn=l.useMemo(()=>g?.files?g.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,[g?.files]),yn=l.useCallback(async()=>{if(r)try{const s=!!g?.mergeInProgress?.head,a=!!(g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto);if(s){const o=await n.continueMerge(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("merge"),qe(!0),rt(r,o.conflictFiles??[],"merge"),b.error(e("gitView.toast.mergeConflictsDetected"))):(We(),b.success(e("gitView.toast.mergeCompleted")),await re(),await ke())}else if(a){const o=await n.continueRebase(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("rebase"),qe(!0),rt(r,o.conflictFiles??[],"rebase"),b.error(e("gitView.toast.rebaseConflictsDetected"))):(We(),b.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ke())}}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");b.error(a)}},[r,n,g,re,ke,rt,We,e]),bn=l.useCallback(async()=>{if(r)try{!!g?.mergeInProgress?.head?(await n.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),We(),await re(),await ke()}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");b.error(a)}},[r,n,g,re,ke,We,e]),vn=l.useCallback(()=>{if(!r)return;const a=!!g?.mergeInProgress?.head?"merge":"rebase",o=g?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];o.length>0&&Qe(o),Xe(a),qe(!0)},[r,g]),jn=l.useCallback(async s=>{if(!r)return;const a=g?.current,o=ps,c=xs,j=(g?.files??[]).some(xr);try{await n.stash(r,{message:`Auto-stash before ${o} with ${c}`,includeUntracked:!0}),j&&_(r)}catch(K){const He=K instanceof Error?K.message:"Failed to stash changes";b.error(He);return}let z=!1,ne=!1;try{if(o==="merge"){const K=await n.merge(r,{branch:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("merge"),qe(!0)):(z=!0,b.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:a||""})))}else{const K=await n.rebase(r,{onto:c});K.conflict?(ne=!0,Qe(K.conflictFiles??[]),Xe("rebase"),qe(!0)):(z=!0,b.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:a||"",branch:c})))}if(s&&z)try{await n.stashPop(r),_(r),b.success(e("gitView.toast.stashedRestored"))}catch(K){const He=K instanceof Error?K.message:e("gitView.toast.restoreStashFailed");b.error(He)}else s&&ne&&b.info(e("gitView.toast.restoreStashManually"));await re(),await ke()}catch(K){if(s)try{await n.stashPop(r),_(r)}catch{}throw K}},[_,r,n,g,ps,xs,re,ke,e]),Cn=l.useCallback(s=>{Nr(s),r&&(u(r,s),T(r,n,s))},[r,T,n,u]),Nn=l.useCallback(s=>{$r(s)},[]),Sn=l.useCallback(()=>{Tt(null),r&&(h(r,n),L(r,n),T(r,n,Je))},[r,h,L,T,Je,n]),kn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){b.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,n),L(r,n),T(r,n,Je));return}Qe(s.conflictFiles??[]),Xe(s.operation),qe(!0),r&&rt(r,s.conflictFiles??[],s.operation)}},[e,Qe,Xe,qe,rt,r,h,L,T,Je,n]);return r?P===null||P===!0&&!g?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(D,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):P===!1?ze?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{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("gitView.empty.worktreeSetupInProgress")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(D,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.notGitRepository")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.notGitRepositoryDescription")}),Y.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):null]}):t.jsxs("div",{className:Re("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ia,{status:g,localBranches:St,remoteBranches:it,branchInfo:J?.branches,syncAction:tt,remotes:Ke,onFetch:s=>er("fetch",s),onSync:s=>er("sync",s),onRemoveRemote:qr,removingRemoteName:Ar,onCheckoutBranch:Zr,onCreateBranch:Qr,onRenameBranch:Xr,activeIdentityProfile:rn,availableIdentities:sn,onSelectIdentity:en,isApplyingIdentity:Sr,isWorktreeMode:!!F,onOpenHistory:()=>Tt("history"),onOpenGraph:()=>Tt("graph"),onOpenStashes:dn,onOpenUpdateBranch:rr?()=>Us(!0):void 0,onOpenReintegrateCommits:lt?()=>Ks(!0):void 0,pullRequest:ue?.pr??null,prChecks:ue?.checks??null,onOpenPullRequest:r?()=>de(r,"pr"):void 0}),r&&(g?.mergeInProgress?.head||g?.rebaseInProgress?.headName||g?.rebaseInProgress?.onto)&&t.jsx(mi,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:yn,onAbort:bn,onResolveWithAI:vn,conflictCount:wn,isLoading:Z}),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:Re("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(yr,{as:ya,ref:_e,outerClassName:"flex-1 min-h-0",className:Re("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:(at?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Fa,{groups:un,diffStats:g?.diffStats,revertingPaths:es,isRevertingAll:ts,onVisiblePathsChange:Se,onRevertAll:ln,onRevertDirectory:cn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ra,{stagedCount:nn,commitMessage:Be,onCommitMessageChange:q,generatedHighlights:ss,onInsertHighlights:mn,onGenerateMessage:Yr,isGeneratingMessage:Fr,onCommit:()=>tr({pushAfter:!1}),onCommitAndPush:()=>tr({pushAfter:!0}),commitAction:Ts,hasPendingIndexMutation:Rr,gitmojiEnabled:pe,onOpenGitmojiPicker:()=>ye(!0)})]}):t.jsx(Ha,{onOpenStashes:()=>Qt(!0)})})})})})}),t.jsx(ut,{open:Er,onOpenChange:s=>{!s&&qs!==null||Us(s)},children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.branch.updateTitle")}),t.jsxs(wt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:g?.current??""}),"."]})]}),rr?t.jsx(hi,{mode:"bare",currentBranch:g?.current,localBranches:St,remoteBranches:it,defaultTargetBranch:tn,onMerge:fn,onRebase:pn,disabled:an,isOperating:qs!==null,operationLogs:Or,onOperationComplete:gn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(ut,{open:Lr,onOpenChange:Ks,children:t.jsxs(mt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("gitView.integrate.title")}),t.jsx(wt,{children:lt?t.jsxs("span",{className:"font-mono text-foreground",children:[lt.sourceBranch," → ",$s]}):null})]}),lt?t.jsx(_a,{repoRoot:lt.repoRoot,sourceBranch:lt.sourceBranch,worktreeMetadata:lt.worktreeMetadata,localBranches:St,defaultTargetBranch:$s,refreshKey:Ir,showHeader:!1,onRefresh:()=>{r&&(h(r,n),L(r,n),T(r,n,Je))}},lt.worktreeMetadata.path):null]})}),t.jsx(ut,{open:Ae!==null,onOpenChange:s=>{s||Tt(null)},children:t.jsxs(mt,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(gt,{children:e(Ae==="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(Ae==="graph"){Wr(s=>s+1);return}r&&T(r,n,Je)},disabled:Ae==="graph"?hs:Q,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(D,{name:"refresh",className:Re("size-4",(Ae==="graph"?hs:Q)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(wt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Za,{mode:Ae==="graph"?"graph":"history",log:Ae==="graph"?_r??H:H,isLogLoading:Ae==="graph"&&hs||Q,logMaxCount:Ae==="graph"?gs:Je,onLogMaxCountChange:Ae==="graph"?Nn:Cn,expandedCommitHashes:as,onToggleCommit:Jr,commitFilesMap:Mt,loadingCommitHashes:Bt,onCopyHash:Kr,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Ae==="graph"?null:Dr,onConflict:Ae==="graph"?kn:void 0,onActionSuccess:Ae==="graph"?Sn:void 0})})]})}),t.jsx($a,{open:Cr,onOpenChange:Qt,directory:r,hasUncommittedChanges:(g?.files?.length??0)>0,hasStagedChanges:Ue.length>0,uncommittedFileCount:g?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&_(r),await re(!1),await ke()}}),t.jsx(ut,{open:we,onOpenChange:ye,children:t.jsxs(mt,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ht,{className:"px-4 pt-4",children:t.jsx(gt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Fs,{className:"h-[420px]",children:[t.jsx(Rs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:Hs,onValueChange:Ws}),t.jsxs(Ms,{children:[t.jsx(Bs,{children:e("gitView.gitmoji.empty")}),t.jsx(Ut,{children:(Ne.length===0?[]:Ne.filter(s=>{const a=Hs.trim().toLowerCase();return a?s.emoji.includes(a)||s.code.toLowerCase().includes(a)||s.description.toLowerCase().includes(a):!0})).map(s=>t.jsxs(Kt,{onSelect:()=>hn(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(ni,{open:zr,onOpenChange:qe,conflictFiles:Gr,directory:r,operation:Et,onAbort:xn,onClearState:We}),t.jsx(ui,{open:Ur,onOpenChange:fs,operation:ps,targetBranch:xs,onConfirm:jn})]}):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{Gl as GitView};
|