@vantran-se/openchamber-web 2.4.2 → 2.5.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/{AboutDialog-Dz_8z7Rq.js → AboutDialog-C8mAGhnz.js} +1 -1
- package/dist/assets/{ArchiveView-BoMjLD0N.js → ArchiveView-4-LVDLmf.js} +1 -1
- package/dist/assets/{ChangedPathLabel-BirEUxH2.js → ChangedPathLabel-BCiU4QDF.js} +1 -1
- package/dist/assets/{CommandPalette-DkLX-AKB.js → CommandPalette-DEcmPHdC.js} +1 -1
- package/dist/assets/{DiffView-DwyXDHsF.js → DiffView-CaDZ4gTk.js} +3 -3
- package/dist/assets/{FilesView-BFi9HBg1.js → FilesView-Csrs_BGv.js} +1 -1
- package/dist/assets/{GitView-BzWRNg_F.js → GitView-DvxCZgCW.js} +3 -3
- package/dist/assets/{GuestSurfacePane-zDcKyz78.js → GuestSurfacePane-DNg0xBTD.js} +1 -1
- package/dist/assets/{HelpDialog-DZVlv3x2.js → HelpDialog-CLyz3_xd.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-BiEntIfh.js → InProgressOperationBanner-BVDKUDqn.js} +2 -2
- package/dist/assets/{IntegrationsCatalogView-CCHFMcZP.js → IntegrationsCatalogView-u1gS0Vk8.js} +1 -1
- package/dist/assets/{JsonTreeView-BwELoub1.js → JsonTreeView-BpJU14WJ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DxBYkSKd.js → MarkdownRendererImpl-t3OoYn_0.js} +1 -1
- package/dist/assets/{MemoryDebugPanel-C9zpPXVo.js → MemoryDebugPanel-9z1jGWze.js} +1 -1
- package/dist/assets/{OnboardingScreen-Cnzzs_TQ.js → OnboardingScreen-xzT7ckY0.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-DizE9xAy.js → OpenCodeStatusDialog-skpJZSjK.js} +1 -1
- package/dist/assets/{PatchDiff-Cz_UxB-k.js → PatchDiff-BWW_8bob.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BT3MrXwN.js → PierreDiffViewer-BZDNV4Uj.js} +1 -1
- package/dist/assets/{PlanView-B-SCCd7M.js → PlanView-D7wshtfZ.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-4OSNuzpG.js → ProjectActionsDialog-BPh74BCt.js} +1 -1
- package/dist/assets/{PullRequestComparisonSelector-lp98DrYm.js → PullRequestComparisonSelector-BBdU2rL1.js} +3 -3
- package/dist/assets/{RunOverview-DJhjR9uR.js → RunOverview-Cngm2OOp.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-Dwil7zsx.js → ScheduledTasksDialog-DUjDdkw2.js} +1 -1
- package/dist/assets/{SettingsView-DVcV2Rk9.js → SettingsView-CCZOw018.js} +2 -2
- package/dist/assets/{SettingsWindow-DbbAS4Se.js → SettingsWindow-Cndsj5Vu.js} +1 -1
- package/dist/assets/{SourceBoardView-BVcmYpvE.js → SourceBoardView-8Wp0oUvB.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-DxjFUcHZ.js → SpaceAccessDialog-CxfCzTpe.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-Dbrbh-j4.js → SpaceApplyDialog-CYp0A76N.js} +1 -1
- package/dist/assets/{SpaceRow-Cwam4mHh.js → SpaceRow-CQp4PkPJ.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-B_w02jDi.js → SpaceSetupOutput-RNo0mWrR.js} +1 -1
- package/dist/assets/{SpacesView-CGrFWnO-.js → SpacesView-BwcDCv3D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-DFL-m_eu.js → SubmoduleDiffSummary-BQduif5s.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Co0VXa0y.js → ToolOutputDialog-BVCvqYsK.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-CBSzwkat.js → ToolPartDiffPreview-BXpCHBW9.js} +1 -1
- package/dist/assets/{UsageStatsView-BjtTNSt8.js → UsageStatsView-CsC_RzAH.js} +1 -1
- package/dist/assets/{Virtualizer-Cmng0Q1E.js → Virtualizer-nenVQKi3.js} +1 -1
- package/dist/assets/{WalkthroughView-C7AkVuHQ.js → WalkthroughView-CdIYpttA.js} +1 -1
- package/dist/assets/{WorktreesView-CYU2KJ6E.js → WorktreesView-D102xE1o.js} +1 -1
- package/dist/assets/{appThemeRegistry-CDGE1wtP.js → appThemeRegistry-BWap7OfW.js} +1 -1
- package/dist/assets/{ar-BlEU--PN.js → ar-9CiK5cuu.js} +3 -3
- package/dist/assets/{computeVirtualFileMetrics-BgqasG86.js → computeVirtualFileMetrics-DDyA16hp.js} +1 -1
- package/dist/assets/{de-DWs4Mcjc.js → de-Drq6oIkP.js} +3 -3
- package/dist/assets/{decorate-CpxLqoVw.js → decorate-CemSwkUs.js} +1 -1
- package/dist/assets/{es-k5T7CE97.js → es-0bkFr34F.js} +3 -3
- package/dist/assets/{flexokiTheme-BG4cSAMb.js → flexokiTheme-PoX6Vqyn.js} +1 -1
- package/dist/assets/{fr-CzmypgZ8.js → fr-CjgWVupK.js} +3 -3
- package/dist/assets/{he-DdkxJnUn.js → he-BrJa9oPB.js} +4 -4
- package/dist/assets/{index-BrL960j-.js → index-B2WHEal3.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CrnmmfFs.js → initializeSharedPreferences-1Vo6G7CM.js} +1 -1
- package/dist/assets/{install-DvRQsTjX.js → install-FletzeYD.js} +1 -1
- package/dist/assets/{isDiffPlainText-KGYbp86N.js → isDiffPlainText-yXcpftjI.js} +1 -1
- package/dist/assets/{isFilePlainText-D7rclQrA.js → isFilePlainText-Dpm-_Qu8.js} +1 -1
- package/dist/assets/{ja-Qqkyglaf.js → ja-cfyrqWPa.js} +3 -3
- package/dist/assets/katex.min-F4TD1ekM.js +69 -0
- package/dist/assets/{ko-B8idPK2d.js → ko-herKAlGO.js} +3 -3
- package/dist/assets/{main-D4-y6PQ0.js → main-CO7wKNtS.js} +2 -2
- package/dist/assets/{main-Cmc8m6dZ.js → main-DN47yDMe.js} +19 -19
- package/dist/assets/markdownCore-BY21GJ_M.js +10 -0
- package/dist/assets/{miniChat-CjJ77DDL.js → miniChat-BmFJFQph.js} +2 -2
- package/dist/assets/{mobile-DlFdLxjR.js → mobile-DTi98S93.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CVdEBQ6v.js → moveWorkspacePath-CENAo75W.js} +1 -1
- package/dist/assets/{nl-CFXZKHp7.js → nl-mZ4VCoiQ.js} +3 -3
- package/dist/assets/{parseDiffFromFile-DWemyyqU.js → parseDiffFromFile-BSmRvd3V.js} +1 -1
- package/dist/assets/{pierreDiffTint-B7qPTZmL.js → pierreDiffTint-cyYFR1bm.js} +1 -1
- package/dist/assets/{pl-slLgZWDu.js → pl-C98lvkcZ.js} +4 -4
- package/dist/assets/{pt-BR-C319g_nn.js → pt-BR-CB63WPLS.js} +3 -3
- package/dist/assets/{relocateRestoredSession-cOuWlgWB.js → relocateRestoredSession-D8Sf_FG_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DFnEi5Tr.js → renderElectronMiniChatApp-DmQ8i5jp.js} +2 -2
- package/dist/assets/{renderMobileApp-C2TYqVOV.js → renderMobileApp-CND9CafV.js} +3 -3
- package/dist/assets/{restartOpenCode-Dvk4CWW7.js → restartOpenCode-D8ExMl55.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-D7viEboD.js → runtimeEndpointReset-lg1O2gVX.js} +3 -3
- package/dist/assets/{scheduledTasksApi-FZ9stPNl.js → scheduledTasksApi-CJBNpwgy.js} +1 -1
- package/dist/assets/{selectionMarkdown-CCursbAw.js → selectionMarkdown-B_3WTOUr.js} +1 -1
- package/dist/assets/{shikiHighlight-CLj7Oan9.js → shikiHighlight-DBj_a_TN.js} +1 -1
- package/dist/assets/{space-apply-DdhqZWNy.js → space-apply-COMscpEL.js} +1 -1
- package/dist/assets/{space-close-KXdazynX.js → space-close-DDLvYCUc.js} +1 -1
- package/dist/assets/{spaceNetwork-DzU3SK9K.js → spaceNetwork-CNxs51y4.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-C-jxkZJj.js → textMateThemeFromAppTheme-tYpAceV3.js} +1 -1
- package/dist/assets/{tr-DNnJ5oqk.js → tr-C5KUa-8X.js} +3 -3
- package/dist/assets/{uk-Bw0BJwHw.js → uk-D44Grdmc.js} +3 -3
- package/dist/assets/{useAppFontEffects-DAUhSLPu.js → useAppFontEffects-Dm6zEvrf.js} +200 -199
- package/dist/assets/{useCallableModelProviders-B-UCRuyn.js → useCallableModelProviders-BK3j8Sde.js} +1 -1
- package/dist/assets/{useDiffFindSurface-CU_63uoI.js → useDiffFindSurface-CaCh-qt2.js} +1 -1
- package/dist/assets/{useInlineCommentController-bYCeqE6r.js → useInlineCommentController-a2JepiF3.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-CnMxnDdI.js → useMarkdownLocalAssets-BEApAshz.js} +2 -2
- package/dist/assets/{useRootScrollLock-DNYaZ34X.js → useRootScrollLock-mqVhK2HB.js} +2 -2
- package/dist/assets/{useWalkthroughReview-DGPyQ634.js → useWalkthroughReview-BspAr9Aa.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-KulAIuMz.js → vendor-codemirror-language-data-VzNDjH03.js} +2 -2
- package/dist/assets/{zh-CN-Brx5Btej.js → zh-CN-DwBC4Qtd.js} +3 -3
- package/dist/assets/{zh-TW-WokiutLA.js → zh-TW-DXEqDBAm.js} +3 -3
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +2 -2
- package/server/lib/git/service.test.js +1 -1
- package/server/lib/opencode/openchamber-routes.test.js +1 -0
- package/server/lib/opencode/settings-helpers.js +2 -2
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +1 -1
- package/server/lib/outbound-proxy.test.js +2 -2
- package/server/lib/spaces/tools.test.js +2 -2
- package/dist/assets/katex.min-u4DtE8E5.js +0 -69
- package/dist/assets/markdownCore-D_5e0Wl7.js +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as i,f as Xe,j as t}from"./vendor-react-BUCujlKS.js";import{u as ce,l as Ie,t as pi,n as ts,a8 as ns,aD as sn,a5 as we}from"./katex.min-
|
|
2
|
-
`);let s=null;for(const o of e){const x=o.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(x){const f=Number.parseInt(x[1]??"",10);s=Number.isFinite(f)&&f>=1?f:null;continue}if(s!==null){if(o.startsWith(" ")){s+=1;continue}if(o.startsWith("+"))return s;if(o.startsWith("-"))return Math.max(1,s)}}return null};function kr(){const a=new Map;return({directory:e,filePath:s,revision:o,staged:x,contextLines:f,peers:C,getGitDiffs:
|
|
1
|
+
import{R as i,f as Xe,j as t}from"./vendor-react-BUCujlKS.js";import{u as ce,l as Ie,t as pi,n as ts,a8 as ns,aD as sn,a5 as we}from"./katex.min-F4TD1ekM.js";import{c as hi,a as gi,u as ss,b as xi,B as yi,C as bi,P as wi,h as vi,e as ji,g as ki,i as Ni,f as Si}from"./PullRequestComparisonSelector-BBdU2rL1.js";import{u as Ci,i as Ri,a as Fi,b as Di,c as Ti,d as Ei,s as Vi,W as is,e as Li,S as Ai}from"./SubmoduleDiffSummary-BQduif5s.js";import{u as ze,B as ve,I as q,N as je,b7 as on,aE as Pi,aD as Re,b3 as Mi,b8 as Bi,b4 as Ii,aF as _i,bd as zi,b5 as Oi,ek as Wi,G as hs,dx as $i,P as gs,el as qi,em as _e,A as St,bS as xs,aR as ys,V as Ki,W as Gi,aS as bs,X as Hi,aT as ws,aU as Ui,en as Xi,eo as Ji,dq as an,d0 as Qi,bc as rn,bf as Nt,a5 as Yi,bU as Zi,n as Cn,bj as er,ep as tr,eq as rs,er as nr,es as sr,et as ir}from"./useAppFontEffects-Dm6zEvrf.js";import{u as rr,I as or,J as ar,K as os,C as lr,d as cr,W as dr,L as ln,O as ur}from"./runtimeEndpointReset-lg1O2gVX.js";import{b as fr,c as mr,a as vn,P as pr}from"./PierreDiffViewer-BZDNV4Uj.js";import{v as hr,a as gr}from"./main-DN47yDMe.js";import{p as vs}from"./parseDiffFromFile-BSmRvd3V.js";import{r as At,u as xr,a as yr,D as br}from"./useDiffFindSurface-CaCh-qt2.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./computeVirtualFileMetrics-DDyA16hp.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-VzNDjH03.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./isDiffPlainText-yXcpftjI.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-cyYFR1bm.js";import"./Virtualizer-nenVQKi3.js";import"./useInlineCommentController-a2JepiF3.js";import"./appThemeRegistry-BWap7OfW.js";import"./textMateThemeFromAppTheme-tYpAceV3.js";import"./useRootScrollLock-mqVhK2HB.js";import"./moveWorkspacePath-CENAo75W.js";const wr=i.memo(function(e){const s=Xe.c(13),{index:o,staged:x,busyHunk:f,disabled:C,onAction:j}=e,{t:v}=ze();let y;s[0]!==x?(y=x?["unstage"]:["discard","stage"],s[0]=x,s[1]=y):y=s[1];const d=y;let k;s[2]===Symbol.for("react.memo_cache_sentinel")?(k={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=k):k=s[2];let p;s[3]!==d||s[4]!==f||s[5]!==C||s[6]!==o||s[7]!==j||s[8]!==v?(p=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:d.map(R=>{const N=v(R==="stage"?"diffView.hunk.stageTitle":R==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:o+1}),S=f?.index===o&&f.action===R;return t.jsx(ve,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",R==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",R==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:C||f!==null,title:N,"aria-label":N,onPointerDown:vr,onClick:g=>{g.stopPropagation(),j(o,R)},children:t.jsx(q,{name:S?"loader-4":R==="stage"?"add":"arrow-go-back",className:je(R==="stage"?"size-4":"size-3.5",S&&"animate-spin")})},R)})}),s[3]=d,s[4]=f,s[5]=C,s[6]=o,s[7]=j,s[8]=v,s[9]=p):p=s[9];let m;return s[10]!==o||s[11]!==p?(m=t.jsx("div",{className:"pointer-events-none absolute inset-e-3 z-20",style:k,"data-hunk-actions":o,children:p}),s[10]=o,s[11]=p,s[12]=m):m=s[12],m});function vr(a){return a.stopPropagation()}const as=(a,e)=>{if(e.length===0)return null;let s=null,o=null;for(const f of e)f.top<=a?(!s||f.top>s.top)&&(s=f):(!o||f.top<o.top)&&(o=f);const x=s??o;return x?{path:x.path,topOffset:x.top-a}:null},jr=(a,e,s,o)=>Math.min(Math.max(0,o),Math.max(0,a+s-e)),js=(a,e)=>{const s=[],o=(x,f)=>{const C=Array.from(x.children.values()).sort((v,y)=>v.name.localeCompare(y.name));for(const v of C){const{node:y,label:d}=mr(v),k=!e.has(y.path);s.push({kind:"directory",key:`dir:${y.path}`,depth:f,path:y.path,label:d,fileCount:y.files.length,expanded:k}),k&&o(y,f+1)}const j=[...x.directFiles].sort((v,y)=>vn(v.path).localeCompare(vn(y.path)));for(const v of j)s.push({kind:"file",key:`file:${v.path}`,depth:f,name:vn(v.path),file:v})};return o(fr(a),0),s},ls=a=>{if(!a)return null;const e=a.split(`
|
|
2
|
+
`);let s=null;for(const o of e){const x=o.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(x){const f=Number.parseInt(x[1]??"",10);s=Number.isFinite(f)&&f>=1?f:null;continue}if(s!==null){if(o.startsWith(" ")){s+=1;continue}if(o.startsWith("+"))return s;if(o.startsWith("-"))return Math.max(1,s)}}return null};function kr(){const a=new Map;return({directory:e,filePath:s,revision:o,staged:x,contextLines:f,peers:C,getGitDiffs:j})=>{const v=(p,m)=>{const R=a.get(p);return R!==void 0&&R.directory===e&&R.revision===m},y=a.get(s);if(y&&v(s,o))return y.read;const d=new Map([[s,o]]);for(const p of C)!d.has(p.filePath)&&!v(p.filePath,p.revision)&&d.set(p.filePath,p.revision);const k=j(e,{paths:[...d.keys()],staged:x,contextLines:f}).then(p=>new Map(p.map(m=>[m.path,m])));for(const[p,m]of d){const R=k.then(N=>N.get(p)??null,()=>(a.get(p)?.read===R&&a.delete(p),null));a.set(p,{directory:e,revision:m,read:R})}return a.get(s)?.read??Promise.resolve(null)}}const Nr=1100,Sr=15e3,kn=500,cs=300,en=1e6,mt=3,Cr=a=>a<=6?a:a<=12?6:a<=25?4:2,Nn={status:"loading"},Rr=3,Fr=i.memo(()=>{const a=Xe.c(4),{t:e}=ze();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let o;return a[2]!==s?(o=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),a[2]=s,a[3]=o):o=a[3],o}),ks=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},tn=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},nn=a=>!!a.working_dir?.trim()||a.index==="?",Sn=(a,e)=>Qi(a,e),ds=(a,e)=>{const s=a.split(`
|
|
3
3
|
`),o=e.split(`
|
|
4
|
-
`),x=Math.min(s.length,o.length);for(let f=0;f<x;f+=1)if(s[f]!==o[f])return f+1;return o.length>s.length?s.length+1:s.length>o.length?Math.max(1,o.length):1},Ct=(a,e,s)=>Ni(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Si(a,e),contextMode:s},Pt=(a,e)=>e.isBinary||e.submodule?null:e.fileDiff?e.fileDiff:!e.original&&!e.modified?null:js({name:a,contents:e.original},{name:a,contents:e.modified}),us=new WeakMap;let fs=0;const ms=a=>{if(!a)return"absent";let e=us.get(a);return e===void 0&&(fs+=1,e=fs,us.set(a,e)),String(e)},ps=(a,e)=>e===a||a.endsWith("/")&&e.startsWith(a),Rn=(a,e,s)=>{const o=a??0,x=e??0;return!o&&!x?null:t.jsxs("span",{className:ve("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[o?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",o]}):null,x?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",x]}):null]})},Dr=i.memo(a=>{const e=Xe.c(70),{scope:s,workingCount:o,stagedCount:x,turnCount:f,branchCount:C,commitCount:v,prCount:j,showCommitOption:y,showBranchOption:d,changeRequestProvider:k,onScopeChange:p}=a,{t:m}=ze(),[R,N]=i.useState(!1),S=s==="pr"?j??0:s==="staged"?x:s==="turn"?f:s==="branch"?C??0:s==="commit"?v??0:o;let g;e[0]!==k||e[1]!==s||e[2]!==m?(g=m(s==="pr"?rn("session.githubIntegration.tabs.pullRequests",k):s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=k,e[1]=s,e[2]=m,e[3]=g):g=e[3];const T=g;let L;e[4]!==m?(L=m("diffView.scope.selectorAria"),e[4]=m,e[5]=L):L=e[5];let J;e[6]!==S?(J=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",S]}),e[6]=S,e[7]=J):J=e[7];let K;e[8]!==T||e[9]!==J?(K=t.jsxs("span",{className:"whitespace-nowrap",children:[T,J]}),e[8]=T,e[9]=J,e[10]=K):K=e[10];let fe;e[11]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx(q,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[11]=fe):fe=e[11];let ee;e[12]!==L||e[13]!==K?(ee=t.jsx(bs,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":L,children:[K,fe]})}),e[12]=L,e[13]=K,e[14]=ee):ee=e[14];let ne;e[15]!==p?(ne=A=>{(A==="working"||A==="staged"||A==="turn"||A==="branch"||A==="commit"||A==="pr")&&(p?.(A),N(!1))},e[15]=p,e[16]=ne):ne=e[16];let h;e[17]!==m?(h=m("diffView.scope.changed"),e[17]=m,e[18]=h):h=e[18];let O;e[19]!==h?(O=t.jsx("span",{children:h}),e[19]=h,e[20]=O):O=e[20];let H;e[21]!==o?(H=t.jsx("span",{className:"typography-meta text-muted-foreground",children:o}),e[21]=o,e[22]=H):H=e[22];let P;e[23]!==H||e[24]!==O?(P=t.jsx(Nt,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[O,H]})}),e[23]=H,e[24]=O,e[25]=P):P=e[25];let G;e[26]!==m?(G=m("diffView.scope.staged"),e[26]=m,e[27]=G):G=e[27];let U;e[28]!==G?(U=t.jsx("span",{children:G}),e[28]=G,e[29]=U):U=e[29];let te;e[30]!==x?(te=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[30]=x,e[31]=te):te=e[31];let V;e[32]!==U||e[33]!==te?(V=t.jsx(Nt,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[U,te]})}),e[32]=U,e[33]=te,e[34]=V):V=e[34];let F;e[35]!==m?(F=m("diffView.scope.lastTurn"),e[35]=m,e[36]=F):F=e[36];let z;e[37]!==F?(z=t.jsx("span",{children:F}),e[37]=F,e[38]=z):z=e[38];let B;e[39]!==f?(B=t.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[39]=f,e[40]=B):B=e[40];let W;e[41]!==z||e[42]!==B?(W=t.jsx(Nt,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[z,B]})}),e[41]=z,e[42]=B,e[43]=W):W=e[43];let X;e[44]!==C||e[45]!==d||e[46]!==m?(X=d?t.jsx(Nt,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}):null,e[44]=C,e[45]=d,e[46]=m,e[47]=X):X=e[47];let de;e[48]!==v||e[49]!==y||e[50]!==m?(de=y&&t.jsx(Nt,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[48]=v,e[49]=y,e[50]=m,e[51]=de):de=e[51];let re;e[52]!==k||e[53]!==j||e[54]!==y||e[55]!==m?(re=y&&t.jsx(Nt,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m(rn("session.githubIntegration.tabs.pullRequests",k))}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[52]=k,e[53]=j,e[54]=y,e[55]=m,e[56]=re):re=e[56];let ie;e[57]!==s||e[58]!==P||e[59]!==V||e[60]!==W||e[61]!==X||e[62]!==de||e[63]!==re||e[64]!==ne?(ie=t.jsx(ws,{align:"start",className:"w-40",children:t.jsxs(er,{value:s,onValueChange:ne,children:[P,V,W,X,de,re]})}),e[57]=s,e[58]=P,e[59]=V,e[60]=W,e[61]=X,e[62]=de,e[63]=re,e[64]=ne,e[65]=ie):ie=e[65];let me;return e[66]!==R||e[67]!==ie||e[68]!==ee?(me=t.jsxs(ys,{open:R,onOpenChange:N,children:[ee,ie]}),e[66]=R,e[67]=ie,e[68]=ee,e[69]=me):me=e[69],me}),Tr=i.memo(a=>{const e=Xe.c(11),{changedFiles:s,selectedFile:o,onSelectFile:x}=a,{t:f}=ze();if(s.length===0)return null;let C;if(e[0]!==s||e[1]!==x||e[2]!==o||e[3]!==f){let j;e[5]!==x||e[6]!==o||e[7]!==f?(j=y=>{const d=ln(y),k=o===y.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>x(y.path),className:ve("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start transition-colors",k?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(an,{filePath:y.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:d.color},title:f(d.descriptionKey),"aria-label":f(d.descriptionKey),children:d.code}),t.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",unicodeBidi:"plaintext"},title:y.path,children:y.path}),Rn(y.insertions,y.deletions)]})},y.path)},e[5]=x,e[6]=o,e[7]=f,e[8]=j):j=e[8],C=s.map(j),e[0]=s,e[1]=x,e[2]=o,e[3]=f,e[4]=C}else C=e[4];let v;return e[9]!==C?(v=t.jsx(Cn,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:C})}),e[9]=C,e[10]=v):v=e[10],v}),vn=160,Er=.5,Vr=i.memo(a=>{const e=Xe.c(18),{changedFiles:s,selectedFile:o,onSelectFile:x}=a,{t:f}=ze(),[C,v]=i.useState(Br);let j;e[0]!==s||e[1]!==C?(j=vs(s,C),e[0]=s,e[1]=C,e[2]=j):j=e[2];const y=j;let d,k;e[3]!==o?(d=()=>{o&&v(S=>{const g=Array.from(S).filter(L=>o.startsWith(`${L}/`));if(g.length===0)return S;const T=new Set(S);return g.forEach(L=>T.delete(L)),T})},k=[o],e[3]=o,e[4]=d,e[5]=k):(d=e[4],k=e[5]),i.useEffect(d,k);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=S=>{v(g=>{const T=new Set(g);return T.delete(S)||T.add(S),T})},e[6]=p):p=e[6];const m=p;let R;if(e[7]!==x||e[8]!==y||e[9]!==o||e[10]!==f){let S;e[12]!==x||e[13]!==o||e[14]!==f?(S=g=>{const T=tr(g.depth);if(g.kind==="directory")return t.jsxs("li",{className:"relative",children:[t.jsx(rs,{depth:g.depth}),t.jsxs("button",{type:"button",onClick:()=>m(g.path),"aria-expanded":g.expanded,"aria-label":g.expanded?f("diffView.fileTree.collapseDirectoryAria",{path:g.path}):f("diffView.fileTree.expandDirectoryAria",{path:g.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pe-2 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingInlineStart:T},title:g.path,children:[t.jsx(nr,{expanded:g.expanded}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:g.label})]})]},g.key);const L=ln(g.file),J=o===g.file.path;return t.jsxs("li",{className:"relative",children:[t.jsx(rs,{depth:g.depth}),t.jsxs("button",{type:"button",onClick:()=>x(g.file.path),"aria-current":J?"true":void 0,className:ve("flex w-full items-center gap-1.5 rounded-md py-1 pe-2 text-start transition-colors",ir(J)),style:{paddingInlineStart:T},title:g.file.path,children:[t.jsx(an,{filePath:g.file.path,className:"ms-0.5 size-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:g.name}),t.jsx(sr,{code:L.code,color:L.color,label:f(L.descriptionKey)})]})]},g.key)},e[12]=x,e[13]=o,e[14]=f,e[15]=S):S=e[15],R=y.map(S),e[7]=x,e[8]=y,e[9]=o,e[10]=f,e[11]=R}else R=e[11];let N;return e[16]!==R?(N=t.jsx(Cn,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:t.jsx("ul",{className:"flex flex-col",children:R})}),e[16]=R,e[17]=N):N=e[17],N}),Lr=i.memo(a=>{const e=Xe.c(20),{filePath:s,diff:o,renderSideBySide:x}=a,{t:f}=ze(),C=o.original.length>0,v=o.modified.length>0,j=x?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",y=x?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={contain:"layout"},e[0]=d):d=e[0];let k;e[1]!==o.original||e[2]!==s||e[3]!==C||e[4]!==y||e[5]!==x||e[6]!==f?(k=C&&t.jsxs("div",{className:y,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),t.jsx("img",{src:o.original,alt:f("diffView.image.originalAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=o.original,e[2]=s,e[3]=C,e[4]=y,e[5]=x,e[6]=f,e[7]=k):k=e[7];let p;e[8]!==o.modified||e[9]!==s||e[10]!==v||e[11]!==C||e[12]!==y||e[13]!==x||e[14]!==f?(p=v&&t.jsxs("div",{className:y,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(C?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:o.modified,alt:f("diffView.image.modifiedAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=o.modified,e[9]=s,e[10]=v,e[11]=C,e[12]=y,e[13]=x,e[14]=f,e[15]=p):p=e[15];let m;return e[16]!==j||e[17]!==k||e[18]!==p?(m=t.jsx("div",{className:"w-full overflow-auto p-4",style:d,children:t.jsxs("div",{className:j,children:[k,p]})}),e[16]=j,e[17]=k,e[18]=p,e[19]=m):m=e[19],m}),Ns=i.memo(a=>{const e=Xe.c(26),{filePath:s,diff:o,staged:x,renderSideBySide:f,wrapLines:C,hideWhitespace:v,hunkActions:j,onExpandContextRequest:y,pendingContextExpansion:d,contextLoading:k,viewerRef:p,onFindWordRequest:m}=a;let R;e[0]!==s?(R=Zi(s)||"text",e[0]=s,e[1]=R):R=e[1];const N=R;if(o.submodule){let T;return e[2]!==o.submodule||e[3]!==x?(T=t.jsx(Ai,{state:o.submodule,staged:x}),e[2]=o.submodule,e[3]=x,e[4]=T):T=e[4],T}if(o.isBinary){let T;return e[5]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Fr,{}),e[5]=T):T=e[5],T}if(_e(s)){let T;return e[6]!==o||e[7]!==s||e[8]!==f?(T=t.jsx(Lr,{filePath:s,diff:o,renderSideBySide:f}),e[6]=o,e[7]=s,e[8]=f,e[9]=T):T=e[9],T}let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={contain:"layout"},e[10]=S):S=e[10];let g;return e[11]!==k||e[12]!==o.fileDiff||e[13]!==o.modified||e[14]!==o.original||e[15]!==s||e[16]!==v||e[17]!==j||e[18]!==N||e[19]!==y||e[20]!==m||e[21]!==d||e[22]!==f||e[23]!==p||e[24]!==C?(g=t.jsx("div",{className:"w-full",style:S,children:t.jsx(pr,{ref:p,original:o.original,modified:o.modified,fileDiff:o.fileDiff,language:N,fileName:s,renderSideBySide:f,wrapLines:C,hideWhitespace:v,layout:"inline",hunkActions:j,onExpandContextRequest:y,pendingContextExpansion:d,contextLoading:k,onFindWordRequest:m})}),e[11]=k,e[12]=o.fileDiff,e[13]=o.modified,e[14]=o.original,e[15]=s,e[16]=v,e[17]=j,e[18]=N,e[19]=y,e[20]=m,e[21]=d,e[22]=f,e[23]=p,e[24]=C,e[25]=g):g=e[25],g}),Ss=a=>a.files.map(e=>{const s=a.diffStats?.staged?.[e.path],o=a.diffStats?.working?.[e.path];return{...e,insertions:(s?.insertions??0)+(o?.insertions??0),deletions:(s?.deletions??0)+(o?.deletions??0),isNew:ks(e)}}).sort((e,s)=>e.path.localeCompare(s.path)),Ar=i.memo(a=>{const e=Xe.c(55),{directory:s,file:o,revision:x,renderSideBySide:f,wrapLines:C,hideWhitespace:v,findKeyPrefix:j,registerViewerRef:y,onFindWordRequest:d,findReveal:k}=a,p=k===void 0?null:k,{t:m}=ze(),{git:R}=on(),[N,S]=i.useState(Nn),[g,T]=i.useState(!1),L=j===void 0?null:`${j}${o.path}`;let J;e[0]!==L||e[1]!==p?.key?(J=()=>{L!==null&&p?.key===L&&T(!0)},e[0]=L,e[1]=p?.key,e[2]=J):J=e[2];let K;e[3]!==L||e[4]!==p?(K=[L,p],e[3]=L,e[4]=p,e[5]=K):K=e[5],i.useEffect(J,K);let fe;e[6]!==L||e[7]!==y?(fe=V=>{L!==null&&y?.(L,V)},e[6]=L,e[7]=y,e[8]=fe):fe=e[8];const ee=fe;let ne;e[9]!==L||e[10]!==d?(ne=V=>{L!==null&&d?.(L,V)},e[9]=L,e[10]=d,e[11]=ne):ne=e[11];const h=ne;let O;e[12]!==o?(O=tn(o)&&!nn(o),e[12]=o,e[13]=O):O=e[13];const H=O,P=`${o.index}:${o.working_dir}:${o.insertions}:${o.deletions}`;let G;e[14]!==s||e[15]!==o.path||e[16]!==R||e[17]!==H||e[18]!==m?(G=()=>{let V=!1;const F=we();return(_e(o.path)?R.getGitFileDiff(s,{path:o.path,staged:H}).then(Ir):R.getGitDiff(s,{path:o.path,staged:H,contextLines:mt}).then(B=>({...Ct(o.path,B.diff,"patch"),submodule:B.submodule}))).then(B=>{V||F!==we()||S({status:"ready",data:B})},B=>{if(V||F!==we())return;const W=B instanceof sn?B.reason==="nested_repository"?m("diffView.unavailable.nestedRepositoryTitle"):B.reason==="untracked_directory"?m("diffView.unavailable.untrackedDirectoryTitle"):m("diffView.unavailable.missingTitle"):B instanceof Error?B.message:String(B);S({status:"error",message:W})}),()=>{V=!0}},e[14]=s,e[15]=o.path,e[16]=R,e[17]=H,e[18]=m,e[19]=G):G=e[19];let U;if(e[20]!==s||e[21]!==o.path||e[22]!==P||e[23]!==R||e[24]!==x||e[25]!==H||e[26]!==m?(U=[s,o.path,P,R,x,H,m],e[20]=s,e[21]=o.path,e[22]=P,e[23]=R,e[24]=x,e[25]=H,e[26]=m,e[27]=U):U=e[27],i.useEffect(G,U),N.status==="loading"){let V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),e[28]=V):V=e[28];let F;e[29]!==m?(F=m("diffView.state.loadingDiff"),e[29]=m,e[30]=F):F=e[30];let z;return e[31]!==F?(z=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[V,F]}),e[31]=F,e[32]=z):z=e[32],z}if(N.status==="error"){let V;return e[33]!==N.message?(V=t.jsx("div",{className:"px-4 py-4 text-center typography-meta text-muted-foreground",children:N.message}),e[33]=N.message,e[34]=V):V=e[34],V}if(!g&&o.insertions+o.deletions>kn){const V=o.insertions+o.deletions;let F;e[35]!==m||e[36]!==V?(F=m("diffView.state.largeDiff",{count:V}),e[35]=m,e[36]=V,e[37]=F):F=e[37];let z;e[38]===Symbol.for("react.memo_cache_sentinel")?(z=()=>T(!0),e[38]=z):z=e[38];let B;e[39]!==m?(B=m("diffView.actions.renderAnyway"),e[39]=m,e[40]=B):B=e[40];let W;e[41]!==B?(W=t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:z,children:B}),e[41]=B,e[42]=W):W=e[42];let X;return e[43]!==F||e[44]!==W?(X=t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[F,W]}),e[43]=F,e[44]=W,e[45]=X):X=e[45],X}let te;return e[46]!==o.path||e[47]!==h||e[48]!==v||e[49]!==f||e[50]!==N.data||e[51]!==ee||e[52]!==H||e[53]!==C?(te=t.jsx(Ns,{filePath:o.path,diff:N.data,staged:H,renderSideBySide:f,wrapLines:C,hideWhitespace:v,viewerRef:ee,onFindWordRequest:h}),e[46]=o.path,e[47]=h,e[48]=v,e[49]=f,e[50]=N.data,e[51]=ee,e[52]=H,e[53]=C,e[54]=te):te=e[54],te}),Pr=i.memo(a=>{const e=Xe.c(71),{directory:s,revision:o,renderSideBySide:x,wrapLines:f,hideWhitespace:C,findKeyPrefix:v,registerViewerRef:j,onFindWordRequest:y,findReveal:d}=a,k=d===void 0?null:d,{t:p}=ze(),{git:m}=on(),R=Yi(_r),N=hs(zr);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={kind:"loading"},e[0]=S):S=e[0];const[g,T]=i.useState(S),[L,J]=i.useState(0),[K,fe]=i.useState(Or);let ee;e[1]!==s||e[2]!==m?(ee=()=>{let M=!1;const le=we();return m.getGitStatus(s,{fresh:!0}).then(oe=>{M||le!==we()||T({kind:"ready",files:Ss(oe)})},oe=>{M||le!==we()||T({kind:"error",message:oe instanceof Error?oe.message:String(oe)})}),()=>{M=!0}},e[1]=s,e[2]=m,e[3]=ee):ee=e[3];let ne;e[4]!==s||e[5]!==m||e[6]!==L||e[7]!==o?(ne=[s,m,o,L],e[4]=s,e[5]=m,e[6]=L,e[7]=o,e[8]=ne):ne=e[8],i.useEffect(ee,ne);let h,O;e[9]!==v||e[10]!==k?(h=()=>{if(!k||v===void 0||!k.key.startsWith(v))return;const M=k.key.slice(v.length);fe(le=>le.has(M)?le:new Set(le).add(M))},O=[v,k],e[9]=v,e[10]=k,e[11]=h,e[12]=O):(h=e[11],O=e[12]),i.useEffect(h,O);let H;e[13]===Symbol.for("react.memo_cache_sentinel")?(H=M=>{fe(le=>{const oe=new Set(le);return oe.delete(M)||oe.add(M),oe})},e[13]=H):H=e[13];const P=H;let G;e[14]!==R||e[15]!==s||e[16]!==N||e[17]!==p?(G=async()=>{const M=await R(s);if(!M){St.error(p("diffView.nestedRepository.openFailed"));return}N({selectedProjectId:M.id,directoryOverride:M.path})},e[14]=R,e[15]=s,e[16]=N,e[17]=p,e[18]=G):G=e[18];const U=G;let te;e[19]!==p?(te=p("diffView.unavailable.nestedRepositoryTitle"),e[19]=p,e[20]=te):te=e[20];let V;e[21]!==te?(V=t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:te}),e[21]=te,e[22]=V):V=e[22];let F;e[23]!==p?(F=p("diffView.nestedRepository.description"),e[23]=p,e[24]=F):F=e[24];let z;e[25]!==F?(z=t.jsx("div",{className:"typography-meta text-muted-foreground",children:F}),e[25]=F,e[26]=z):z=e[26];let B;e[27]!==V||e[28]!==z?(B=t.jsxs("div",{className:"min-w-0 flex-1",children:[V,z]}),e[27]=V,e[28]=z,e[29]=B):B=e[29];let W;e[30]!==U?(W=()=>{U()},e[30]=U,e[31]=W):W=e[31];let X;e[32]!==p?(X=p("diffView.nestedRepository.openAsProject"),e[32]=p,e[33]=X):X=e[33];let de;e[34]!==W||e[35]!==X?(de=t.jsx(je,{variant:"outline",size:"sm",className:"shrink-0",onClick:W,children:X}),e[34]=W,e[35]=X,e[36]=de):de=e[36];let re;e[37]!==B||e[38]!==de?(re=t.jsxs("div",{className:"flex items-center gap-3 px-3",children:[B,de]}),e[37]=B,e[38]=de,e[39]=re):re=e[39];let ie;e[40]!==g.kind||e[41]!==p?(ie=g.kind==="loading"?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),p("diffView.nestedRepository.loading")]}):null,e[40]=g.kind,e[41]=p,e[42]=ie):ie=e[42];let me;e[43]!==g.kind||e[44]!==g.message||e[45]!==p?(me=g.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-4",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:p("diffView.nestedRepository.loadFailed")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:g.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(Wr),children:p("diffView.actions.retry")})]}):null,e[43]=g.kind,e[44]=g.message,e[45]=p,e[46]=me):me=e[46];let A;e[47]!==g.files||e[48]!==g.kind||e[49]!==p?(A=g.kind==="ready"&&g.files.length===0?t.jsx("div",{className:"px-3 typography-meta text-muted-foreground",children:p("diffView.nestedRepository.noChanges")}):null,e[47]=g.files,e[48]=g.kind,e[49]=p,e[50]=A):A=e[50];let he;e[51]!==s||e[52]!==K||e[53]!==v||e[54]!==k||e[55]!==C||e[56]!==y||e[57]!==j||e[58]!==x||e[59]!==o||e[60]!==g.files||e[61]!==g.kind||e[62]!==p||e[63]!==f?(he=g.kind==="ready"&&g.files.length>0?t.jsx("ul",{className:"flex flex-col",children:g.files.map(M=>{const le=K.has(M.path),oe=ln(M);return t.jsxs("li",{children:[t.jsxs("button",{type:"button","aria-expanded":le,onClick:()=>P(M.path),className:"flex w-full items-center gap-2 px-3 py-1 text-start text-foreground/80 transition-colors hover:text-foreground",title:M.path,children:[t.jsx(q,{name:le?"arrow-down-s":"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"typography-micro font-semibold w-4 shrink-0 text-center uppercase",style:{color:oe.color},title:p(oe.descriptionKey),"aria-label":p(oe.descriptionKey),children:oe.code}),t.jsx(an,{filePath:M.path,className:"size-3.5 shrink-0"}),t.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",unicodeBidi:"plaintext"},children:M.path}),Rn(M.insertions,M.deletions)]}),le?t.jsx(Ar,{directory:s,file:M,revision:o,renderSideBySide:x,wrapLines:f,hideWhitespace:C,findKeyPrefix:v,registerViewerRef:j,onFindWordRequest:y,findReveal:k?.key===`${v}${M.path}`?k:null}):null]},M.path)})}):null,e[51]=s,e[52]=K,e[53]=v,e[54]=k,e[55]=C,e[56]=y,e[57]=j,e[58]=x,e[59]=o,e[60]=g.files,e[61]=g.kind,e[62]=p,e[63]=f,e[64]=he):he=e[64];let Z;return e[65]!==re||e[66]!==ie||e[67]!==me||e[68]!==A||e[69]!==he?(Z=t.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[re,ie,me,A,he]}),e[65]=re,e[66]=ie,e[67]=me,e[68]=A,e[69]=he,e[70]=Z):Z=e[70],Z}),Mr=i.memo(({visible:a=!0,directory:e,file:s,layout:o,wrapLines:x,hideWhitespace:f=!1,isSelected:C,isExpanded:v,isMounted:j,onSelect:y,onExpandedChange:d,registerSectionRef:k,showOpenInEditorAction:p=!1,isOpeningInEditor:m=!1,onOpenInEditor:R,staged:N=!1,loadFullFiles:S=!1,initialDiffData:g=null,comparisonDiff:T,onRetryComparisonDiff:L,loadFullComparisonDiff:J,readOnlyActions:K=!1,hunkActionsEnabled:fe=!1,contentRevision:ee=0,registerViewerRef:ne,onFindWordRequest:h,onFullContextChange:O,findReveal:H=null})=>{const{t:P}=ze(),{git:G}=on(),U=Re(i.useCallback(w=>w.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),te=Re(w=>w.setDiff),V=Re(w=>w.fetchStatus),F=ce(w=>w.setDiffFileLayout),[z,B]=i.useState(0),[W,X]=i.useState(null),[de,re]=i.useState(!1),[ie,me]=i.useState(null),A=ie!==null&&ie.source===T?ie.result:T,he=!!e&&!g&&(!T||!!J),Z=i.useMemo(()=>A?A.status==="error"?{kind:"error",message:A.message}:null:W,[A,W]),M=A?A.status==="loading":de,[le,oe]=i.useState(null),ge=i.useRef(!1),[Oe,Rt]=i.useState(null),[nt,Mt]=i.useState(!1),[st,We]=i.useState(null),[Bt,Je]=i.useState(null),[it,It]=i.useState(null),ke=S||it!==null;i.useEffect(()=>{if(!(!ke||!O))return O(s.path,!0),()=>O(s.path,!1)},[s.path,ke,O]),i.useEffect(()=>{H?.key===s.path&&Mt(!0)},[s.path,H]),i.useEffect(()=>{if(!it||!J||!T||T.status!=="ready"||ie?.source===T)return;let w=!1;return J(s.path).then(Q=>{if(!w){if(Q.status==="error"){St.error(Q.message),It(null);return}me({source:T,result:Q})}}),()=>{w=!0}},[it,s.path,ie,J,T]);const l=i.useRef(null),Qe=i.useRef(null),Le=i.useMemo(()=>ln(s),[s]),pt=o==="side-by-side",De=ke?"full":"patch",rt=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,Ne=fe&&!K&&!g&&!A&&!_e(s.path),ot=JSON.stringify([we(),e,s.path,N,rt,z,ee]),xe=Oe?.scope===ot?Oe.patch:null,ht=Oe?.scope===ot?Oe.submodule:null,Fe=i.useMemo(()=>A?A.status==="ready"?A.data:null:g||(N?Bt:st||(U?{original:U.original,modified:U.modified,isBinary:U.isBinary,submodule:U.submodule,contextMode:"full"}:null)),[A,U,g,st,N,Bt]),ae=Fe?.contextMode===De,_t=i.useCallback(w=>{Qe.current=w,k(s.path,w)},[s.path,k]),$e=i.useCallback(w=>{ne?.(s.path,w)},[s.path,ne]),zt=i.useCallback(w=>{h?.(s.path,w)},[s.path,h]),Ft=i.useCallback(w=>{d(s.path,w)},[s.path,d]),Ot=i.useCallback(()=>{y(s.path)},[s.path,y]),Ae=i.useRef(N);i.useEffect(()=>{Ae.current!==N&&(Ae.current=N,N?Je(null):We(null),X(null),l.current=null)},[N]);const Ye=`${ee}:${rt}`,[gt,xt]=i.useState(Ye),qe=gt===Ye;i.useEffect(()=>{qe||(X(null),l.current=null)},[qe]),i.useEffect(()=>{if(!a||!v||!j||W)return;if(!e||A||g||Fe&&ae&&qe&&(!Ne||xe!==null)){l.current=null,re(!1);return}const w=`${e}::${s.path}::${N?"staged":"unstaged"}::${rt}::${De}::${z}::${ee}`;if(l.current===w)return;l.current=w,X(null),re(!0);let Q=!1;const ye=we(),lt=ke?en:mt,pe=_e(s.path)?G.getGitFileDiff(e,{path:s.path,staged:N}):!ke&&xe!==null?Promise.resolve({diff:xe,submodule:ht}):G.getGitDiff(e,{path:s.path,staged:N,contextLines:lt}),Dt=Ne&&ke&&xe===null?G.getGitDiff(e,{path:s.path,staged:N,contextLines:mt}).then(Y=>Y.diff):Promise.resolve(xe),qt=Promise.all([pe,Dt]),He=Sr;let be;const ct=new Promise((Y,bt)=>{be=setTimeout(()=>bt(new Error(`Timed out after ${He}ms`)),He)});return Promise.race([qt,ct]).then(([Y,bt])=>{if(Q||ye!==we())return;const Te="diff"in Y&&!ke?Y.diff:bt;if(Ne&&ke&&Te!==null&&/^@@\s/m.test(Te)&&"diff"in Y&&Y.diff!==Te&&!ji(Y.diff,Te))throw Rt(null),new Error(P("diffView.hunk.unavailable"));if(Ne&&Te!==null&&Rt({scope:ot,patch:Te,submodule:Y.submodule}),"diff"in Y){const et={...Ct(s.path,Y.diff,De),submodule:Y.submodule};N?Je(et):We(et)}else{const et={original:Y.original??"",modified:Y.modified??"",isBinary:Y.isBinary,submodule:Y.submodule,contextMode:"full"};N?Je(et):(te(e,s.path,et,ye),We(et))}xt(Ye),re(!1)}).catch(Y=>{if(!(Q||ye!==we())){if(re(!1),Y instanceof sn){X({kind:"unavailable",reason:Y.reason}),Y.reason==="path_not_found"&&V(e,G,{force:!0,silent:!0});return}X({kind:"error",message:Y instanceof Error?Y.message:String(Y)})}}).finally(()=>clearTimeout(be)),()=>{Q=!0,clearTimeout(be),l.current===w&&(l.current=null)}},[xe,ht,ee,Ye,Ne,qe,ot,A,De,Fe,ae,z,e,V,s.path,rt,G,g,v,j,ke,W,te,N,P,a]);const Ke=i.useCallback(()=>{Ft(!v),Ot()},[Ft,Ot,v]),at=i.useCallback(()=>{X(null),Rt(null),We(null),Je(null),l.current=null,B(w=>w+1)},[]),Wt=Ji(),{confirm:$t}=Wt,Pe=i.useCallback(async(w,Q)=>{if(!e||!Ne||M||Z||ge.current||le!==null)return;const ye=xe?vi(xe,w):null;if(!ye){St.error(P("diffView.hunk.unavailable"));return}if(N&&Q!=="unstage"||!N&&Q==="unstage"||Q==="discard"&&!await $t({title:P("diffView.hunk.discardDialogTitle"),message:P("diffView.hunk.discardDescription",{path:s.path}),action:P("diffView.hunk.discard"),destructive:!0})||ge.current)return;ge.current=!0;const lt=we();oe({index:w,action:Q});try{const pe=Q==="stage"?G.stageGitHunk:Q==="unstage"?G.unstageGitHunk:G.revertGitHunk;if(!pe){St.error(P("diffView.hunk.unsupported"));return}if(await pe(e,s.path,ye),lt!==we())return;at(),gs.requestGitRefresh({directory:e,paths:[s.path]}),await V(e,G)}catch(pe){if(lt!==we())return;at(),St.error(pe instanceof Error&&pe.message?pe.message:P("diffView.hunk.unavailable"))}finally{ge.current=!1,oe(pe=>pe?.index===w&&pe.action===Q?null:pe)}},[xe,$t,Ne,M,Z,e,V,s.path,G,le,at,N,P]),yt=i.useMemo(()=>Ne&&xe!==null?ki(xe):[],[xe,Ne]),Ze=i.useCallback(w=>t.jsx(wr,{index:w,staged:N,busyHunk:le,disabled:M||!!Z,onAction:Pe}),[Z,Pe,le,M,N]),Ge=i.useMemo(()=>yt.length>0?{anchors:yt,render:Ze}:void 0,[yt,Ze]);return t.jsxs("div",{ref:_t,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:Ke,onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),Ke())},className:ve("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",C?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:v?t.jsx(q,{name:"arrow-down-s",className:"size-4"}):t.jsx(q,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Le.color},title:P(Le.descriptionKey),"aria-label":P(Le.descriptionKey),children:Le.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(an,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const w=s.path.lastIndexOf("/");if(w===-1)return t.jsx("span",{className:"oc-ui-start-align block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",unicodeBidi:"plaintext"},children:s.path});const Q=s.path.slice(0,w),ye=s.path.slice(w+1);return t.jsxs("span",{dir:"ltr",className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"oc-ui-start-align min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",unicodeBidi:"plaintext"},children:Q}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Rn(s.insertions,s.deletions),p&&R?t.jsx(je,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:P("diffView.actions.openFileInEditorAtChange"),onClick:w=>{w.stopPropagation(),R(s.path,Fe)},disabled:m,children:m?t.jsx(q,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(q,{name:"edit",className:"size-3.5"})}):null,t.jsx(xs,{mode:pt?"side-by-side":"unified",onModeChange:w=>{const Q=w==="side-by-side"?"side-by-side":"inline";F(s.path,Q)},className:"opacity-70"})]})]})}),v&&t.jsxs("div",{className:"relative bg-background overflow-clip",children:[!j&&!Z?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,Z?.kind==="unavailable"&&Z.reason==="nested_repository"?t.jsx(Pr,{directory:Sn(e,s.path),revision:ee,renderSideBySide:pt,wrapLines:x,hideWhitespace:f,findKeyPrefix:s.path,registerViewerRef:ne,onFindWordRequest:h,findReveal:H}):null,Z?.kind==="unavailable"&&Z.reason!=="nested_repository"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:Z.reason==="untracked_directory"?P("diffView.unavailable.untrackedDirectoryTitle"):P("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:Z.reason==="untracked_directory"?P("diffView.unavailable.untrackedDirectoryDescription"):P("diffView.unavailable.missingDescription")}),Z.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:at,children:P("diffView.actions.retry")}):null]}):null,Z?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:P("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:Z.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?L?.():at(),children:P("diffView.actions.retry")})]}):null,j&&M&&!Fe&&!Z?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),P("diffView.state.loadingDiff")]}):null,j&&Fe&&!nt&&s.insertions+s.deletions>kn?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:P("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:P("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Mt(!0),children:P("diffView.actions.renderAnyway")})]}):null,j&&Fe&&(nt||s.insertions+s.deletions<=kn)?t.jsx(t.Fragment,{children:t.jsx(Ns,{filePath:s.path,diff:Fe,staged:N,renderSideBySide:pt,wrapLines:x,hideWhitespace:f,hunkActions:Ge,onExpandContextRequest:he?It:void 0,pendingContextExpansion:it,contextLoading:it!==null&&Fe.contextMode!=="full"&&!Z,viewerRef:$e,onFindWordRequest:zt})}):null]}),Wt.dialog]})}),ol=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:o=!1,showOpenInEditorAction:x=!1,diffScope:f="all",onDiffScopeChange:C,targetFilePath:v=null,flushContent:j=!1,directory:y=null})=>{const{t:d}=ze(),k=rr(),p=i.useRef(null);or(p);const[m,R]=i.useState([]),N=i.useCallback(n=>{if(!n)return;const r=p.current;R(["walkthrough","tree","wrap","whitespace","layout"].filter(c=>r?.hasAttribute(ar[c])??!1))},[]),{git:S,files:g,sourceControl:T}=on(),L=Pi(),J=!!y,K=y??L,fe=Re(n=>n.runtimeKey),{gitDirectory:ee,repositoryOptions:ne}=Mi(K??null,{enabled:a,recheckOnOpen:!0}),h=ee??K,O=Bi(h,T),H=ce(n=>n.openContextSurface),P=ce(n=>n.openContextPanelTab),G=Ii(n=>n.requestTarget),{screenWidth:U,isMobile:te}=_i(),V=zi(h??null),F=Oi(h??null),z=Wi(h??null),B=Re(n=>n.setActiveDirectory),W=Re(n=>n.ensureStatus),X=Re(n=>n.selectNestedRepo),de=Re(n=>n.fetchStatus),re=Re(n=>n.fetchBranches),ie=Re(n=>n.clearDiffCache),me=Re(n=>n.setDiff),[A,he]=i.useState(null),[Z,M]=i.useState(!1),[le,oe]=i.useState(null),[ge,Oe]=i.useState(()=>new Set),[Rt,nt]=i.useState(()=>new Set),[Mt,st]=i.useState(0),[We,Bt]=i.useState(()=>new Map),[Je,it]=i.useState(0),[It,ke]=i.useState(!1),[l,Qe]=i.useState(f??"working");i.useEffect(()=>{f!==null&&Qe(f)},[f]);const Le=ce(n=>n.pendingDiffFile),pt=ce(n=>n.pendingDiffStaged),De=ce(n=>n.pendingDiffScope),rt=ce(n=>n.setPendingDiffFile),Ne=ce(n=>n.diffLayoutPreference),ot=ce(n=>n.diffFileLayout),xe=ce(n=>n.setDiffLayoutForAllFiles),ht=ce(n=>n.diffWrapLines),Fe=ce(n=>n.setDiffWrapLines),ae=ce(n=>n.diffHideWhitespace),_t=ce(n=>n.setDiffHideWhitespace),$e=ce(n=>n.diffFileListMode),zt=ce(n=>n.setDiffFileListMode),Ft=ce(n=>n.openContextFileAtLine),Ot=hs(n=>n.currentSessionId),Ae=J?null:Ot,Ye=$i(l==="turn"?Ae??"":"",K??void 0),gt=ht,xt=l==="staged"?!0:l==="working"?!1:null,qe=xt??Z,Ke=te||U<=768,at=!!Ae&&l!=="turn"&&l!=="commit"&&l!=="pr"&&!Ke&&!Ie(),Wt=l!=="turn"&&!Ke&&!Ie(),$t=!e&&!Ke&&U>=1024,Pe=i.useRef(null),yt=i.useRef(null),Ze=i.useRef(new Map),Ge=i.useRef(null),w=i.useRef(null),Q=i.useRef(!1),ye=i.useRef(null),lt=i.useRef(null),pe=i.useRef(null),Dt=i.useRef(null),qt=i.useCallback(()=>{const n=Pe.current;if(!n)return null;const r=n.getBoundingClientRect().top,c=[];for(const[u,b]of Ze.current)b&&c.push({path:u,top:b.getBoundingClientRect().top});return as(r,c)},[]),He=i.useCallback(()=>{Ge.current=null,Q.current=!1,oe(null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),be=i.useCallback(n=>{Oe(r=>{if(r.has(n))return r;const c=new Set(r);return c.add(n),c})},[]),[ct,Y]=i.useState([]),[bt,Te]=i.useState(null),[et,Cs]=i.useReducer(n=>n+1,0);i.useEffect(()=>{Y([]),Te(null)},[Ae]);const Rs=Ye.length>0?Ye[Ye.length-1].id:"";i.useEffect(()=>{if(l!=="turn"||!Ae||!a)return;let n=!1;return pi.getSessionTurnDiff(Ae,{directory:K??void 0}).then(r=>{n||(Y(r.map(c=>({file:c.file,patch:c.patch,status:c.status,additions:c.additions,deletions:c.deletions}))),Te(null))}).catch(r=>{n||(console.warn("[diff-view] turn diff unavailable:",r instanceof Error?r.message:r),Te(r instanceof Error?r.message:d("diffView.state.failedToLoadDiff")))}),()=>{n=!0}},[l,Ae,Rs,K,d,et,a]);const Kt=i.useMemo(()=>{const n=new Map;for(const r of ct)if(r.file){if(typeof r.patch=="string"){n.set(r.file,Ct(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ct]),Fs=i.useMemo(()=>F?.files?F.files.filter(nn).length:0,[F]),Ds=i.useMemo(()=>F?.files?F.files.filter(tn).length:0,[F]),Ts=ct.length,ue=F?.current??null,Gt=O.contexts[0]?.provider==="github"||O.contexts[0]?.provider==="gitlab"?O.contexts[0]:null,Tt=os(n=>h?n.diffRequests.get(h):void 0),Se=hi(h??null,ue,Gt,a&&l==="pr"&&!Ie(),Tt),Ue=Se.selectedSource;i.useEffect(()=>{!h||!Tt||!F||Ue!==Tt||os.getState().settleDiffRequest(h,Tt)},[h,Tt,Ue,F]);const tt=gi(h??null,ue,a&&l==="commit"&&!Ie()),dt=tt.selectedCommit?.hash??null;i.useEffect(()=>{(l==="commit"||l==="pr")&&Ie()&&(Qe("working"),C?.("working"))},[l,C]);const cn=Re(n=>h?n.directories.get(h)?.branches??null:null),Es=Re(n=>h?n.directories.get(h)?.isLoadingBranches??!1:!1),Vs=i.useCallback(()=>{h&&re(h,S)},[h,re,S]),Ls=Ci(h??null,a&&V!==!1,Es,!!cn,Vs,Rr),As=ss(n=>n.setOverride),Ps=ss(n=>n.clearOverride),Ms=i.useMemo(()=>new Set(O.read?.repository.remotes.map(n=>n.name)??[]),[O.read]),{base:Ee,source:Bs,resolved:Fn,revision:dn}=xi(h??null,ue,a&&!Ie()&&V!==!1,{branches:cn,remoteNames:Ms,primaryRemote:O.contexts[0]?.primaryRemote,readContext:O.contexts[0]??null}),un=!Ie()&&Ri(ue,Ee);i.useEffect(()=>{f===null&&Qe(un?"branch":"working")},[f,un]);const Is=F!==null,Dn=Ie()||Ls||Fi(ue,Ee,Is,Fn&&O.status==="ready"),[_s,zs]=i.useState(0);i.useEffect(()=>{const n=Li(l,!Dn);n!==l&&(Qe(n),n==="working"&&f!==null&&C?.("working"))},[l,Dn,f,C]);const Os=i.useMemo(()=>l==="pr"?Ue:l==="commit"&&dt?{kind:"commit",hash:dt}:l==="branch"&&Ee&&ue?{kind:"branch",baseRef:Ee,headRef:ue}:null,[l,Ee,ue,dt,Ue]),se=Di(h??null,Os,a&&!Ie(),l==="branch"?dn:"",Se.readContext,Se.provider),{fetchDiff:Tn,fetchFullFile:En}=se,Vn=l==="commit"?se.files:null,Ln=l==="commit"?se.error:null,wt=l==="branch"?se.files:null,An=l==="branch"?se.error:null,Pn=se.files?l==="pr"?JSON.stringify([se.key,se.revision]):se.key:null,Ws=i.useMemo(()=>l==="branch"||l==="commit"||l==="pr"?Array.from(ge).sort().join("\0"):"",[l,ge]),Et=i.useCallback(async(n,r=!1)=>{try{const c=await Tn(n,r?en:mt);return{status:"ready",data:Ct(n,c.diff,r?"full":"patch")}}catch(c){return{status:"error",message:c instanceof Error?c.message:d("diffView.state.failedToLoadDiff")}}},[Tn,d]),Mn=i.useCallback(async n=>{try{const{original:r,modified:c}=await En(n),u=js({name:n,contents:r},{name:n,contents:c});return{status:"ready",data:{original:r,modified:c,fileDiff:u,contextMode:"full"}}}catch(r){return{status:"error",message:r instanceof Error?r.message:d("diffView.state.failedToLoadDiff")}}},[En,d]),Ht=i.useMemo(()=>l==="branch"||l==="commit"?n=>Et(n,!0):l==="pr"?Mn:void 0,[l,Et,Mn]),$s=i.useMemo(()=>l==="branch"?Ti(wt,dn):void 0,[l,wt,dn]),Ut=Ei(Pn,a?Ws:"",Pn?Et:null,Nn,JSON.stringify([l==="pr"?se.revision:0,_s]),$s),qs=wt?.length??null,_=i.useMemo(()=>{if(l==="commit"||l==="pr")return(se.files??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:u.insertions,deletions:u.deletions,isNew:u.status==="A"}));if(l==="branch")return(wt??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:0,deletions:0,isNew:u.status==="A"})).sort((u,b)=>u.path.localeCompare(b.path));if(l==="turn")return ct.map(u=>({path:u.file??"",index:"",working_dir:Vi(u.status),insertions:u.additions??0,deletions:u.deletions??0,isNew:u.status==="added"})).filter(u=>u.path).sort((u,b)=>u.path.localeCompare(b.path));if(!F?.files)return[];const n=F.diffStats,r=l==="staged"?tn:l==="working"?nn:()=>!0,c=u=>{const b=n?.staged?.[u],E=n?.working?.[u];return l==="staged"?{insertions:b?.insertions??0,deletions:b?.deletions??0}:l==="working"?{insertions:E?.insertions??0,deletions:E?.deletions??0}:{insertions:(b?.insertions??0)+(E?.insertions??0),deletions:(b?.deletions??0)+(E?.deletions??0)}};return F.files.filter(r).map(u=>{const b=c(u.path);return{...u,insertions:b.insertions,deletions:b.deletions,isNew:ks(u)}}).sort((u,b)=>u.path.localeCompare(b.path))},[l,wt,se.files,ct,F]),fn=i.useMemo(()=>_.map(n=>n.path).join("\0"),[_]);i.useEffect(()=>{const n=fn?fn.split("\0"):[],r=new Set(n),c=`${h??""}:${l}:${s?"collapsed":"default"}`,u=lt.current!==c;lt.current=c,Oe(b=>{if(u){const $=s?0:Cr(n.length);return new Set(n.slice(0,$))}let E=!1;const D=new Set;for(const $ of b){if(!r.has($)){E=!0;continue}D.add($)}return E?D:b}),nt(b=>{if(u)return new Set;let E=!1;const D=new Set;for(const $ of b){if(!r.has($)){E=!0;continue}D.add($)}return E?D:b})},[l,fn,h,s]);const Bn=i.useCallback(()=>{if(ye.current=null,!a)return;const n=Pe.current;if(!n)return;const r=n.getBoundingClientRect(),c=r.top-cs,u=r.bottom+cs,b={},E=[];for(const[D,$]of Ze.current){if(!$)continue;const I=$.getBoundingClientRect();E.push({path:D,top:I.top}),ge.has(D)&&(I.bottom<c||I.top>u||(b[D]=!0))}pe.current=as(r.top,E),nt(D=>{let $=!1;const I=new Set(D);for(const Be of Object.keys(b))I.has(Be)||(I.add(Be),$=!0);return $?I:D})},[ge,a]),Me=i.useCallback(()=>{a&&(typeof window>"u"||ye.current===null&&(ye.current=window.requestAnimationFrame(Bn)))},[Bn,a]),mn=i.useRef(Me);mn.current=Me,i.useEffect(()=>{const n=Pe.current;if(!(!a||!n))return Me(),n.addEventListener("scroll",Me,{passive:!0}),window.addEventListener("resize",Me),()=>{n.removeEventListener("scroll",Me),window.removeEventListener("resize",Me),ye.current!==null&&(window.cancelAnimationFrame(ye.current),ye.current=null)}},[_,ge,Me,a]);const ut=i.useCallback(n=>{const r=ot[n.path];if(r)return r;if(Ne==="inline")return"inline";if(Ne==="side-by-side")return"side-by-side";const c=U<Nr;return n.isNew||c?"inline":"side-by-side"},[ot,Ne,U]),pn=i.useMemo(()=>_.length===0?null:_.every(n=>ut(n)==="side-by-side")?"side-by-side":"inline",[_,ut]);i.useEffect(()=>{a&&h&&(B(h),W(h,S))},[h,B,W,S,a]);const Xt=JSON.stringify([fe,h]),hn=i.useRef({scope:Xt,paths:new Set,dirty:!1,unscoped:!1}),In=i.useRef(a);i.useEffect(()=>{const n=a&&!In.current;if(In.current=a,hn.current.scope!==Xt&&(hn.current={scope:Xt,paths:new Set,dirty:!1,unscoped:!1}),!h)return;const r=(u,b)=>{u.length&&(Dt.current=qt()??pe.current,ie(h,u),Bt(E=>{const D=new Map(E);for(const $ of u)D.set($,(D.get($)??0)+1);return D})),b&&it(E=>E+1),de(h,S,{silent:!0})},c=hn.current;return a&&(n||c.dirty)&&(r([...c.paths],c.unscoped),c.paths.clear(),c.dirty=!1,c.unscoped=!1),gs.onGitRefreshHint(u=>{if(ts(u.directory)!==ts(h))return;const b=u.paths??[],E=b.length===0;if(!a){c.dirty=!0,c.unscoped||=E;for(const D of b)c.paths.add(D);return}r(b,E)})},[qt,ie,h,de,S,Xt,a]),i.useLayoutEffect(()=>{const n=Dt.current;if(!n)return;Dt.current=null;const r=Pe.current,c=Ze.current.get(n.path);if(!r||!c)return;const u=r.getBoundingClientRect().top,b=c.getBoundingClientRect().top-u;r.scrollTop=vr(r.scrollTop,n.topOffset,b,r.scrollHeight-r.clientHeight),pe.current=n},[We]),i.useEffect(()=>{!a||l!=="all"&&!De||Le&&(De&&Qe(De),he(Le),M(De==="staged"||!De&&pt),rt(null),Q.current=!0,Ge.current=Le,be(Le),st(n=>n+1))},[l,be,Le,De,pt,rt,a]),i.useEffect(()=>{if(l==="all")return;const n=v?.trim();n&&(he(n),M(l==="staged"),Q.current=!0,Ge.current=n,be(n),st(r=>r+1))},[l,be,v]),i.useEffect(()=>{if(!A)return;_.some(r=>r.path===A)||(he(null),M(!1))},[_,A]);const Ks=i.useCallback((n,r)=>{const c=Ze.current;r?c.set(n,r):c.delete(n),mn.current()},[]),Gs=i.useCallback((n,r)=>{He(),Oe(c=>{const u=c.has(n);if(r===u)return c;const b=new Set(c);return r?b.add(n):b.delete(n),b}),r||nt(c=>{if(!c.has(n))return c;const u=new Set(c);return u.delete(n),u}),mn.current()},[He]),Hs=i.useCallback(()=>{He(),Oe(n=>n.size>0?new Set:new Set(_.map(r=>r.path))),nt(new Set),Me()},[He,_,Me]),Us=i.useCallback(()=>ke(!1),[]),{submitting:gn,start:Xs}=qi(Ae,K,Us),jt=i.useCallback(n=>{const r=Ze.current.get(n),c=Pe.current;if(!r||!c)return!1;const u=r.getBoundingClientRect().top-c.getBoundingClientRect().top;return c.scrollTo({top:c.scrollTop+u,behavior:"auto"}),!0},[]),ft=i.useCallback(n=>xt!==null?xt:Z&&n===A,[A,Z,xt]);i.useEffect(()=>{const n=Ge.current;if(!a||!n)return;let r=0;const c=20;let u=!1;const b=(D=!0)=>{u||(u=!0,Ge.current=null,Q.current=!1,D&&oe(null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null))},E=()=>{if(u){w.current=null;return}const D=Ge.current;if(!D){b(),w.current=null;return}if(!jt(D)){r+=1,r<c?w.current=window.requestAnimationFrame(E):(b(),w.current=null);return}if(o&&Q.current){oe(D),b(!1);return}b()};return w.current=window.requestAnimationFrame(E),()=>{u=!0,w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)}},[o,Mt,jt,a]);const Js=i.useCallback(n=>{},[]),Ce=$e==="tree"&&!Ke,Qs=ce(n=>n.diffFileTreeWidth),Jt=ce(n=>n.setDiffFileTreeWidth),_n=i.useRef(null),[Ys,zn]=i.useState(!1),Vt=Math.max(Qs,vn),Qt=i.useCallback(n=>{const r=Math.max(vn,(_n.current?.clientWidth??0)*Er);return Math.min(r,Math.max(vn,n))},[]),Zs=i.useCallback(n=>{n.preventDefault();const r=n.clientX,c=Vt,u=ns(n.currentTarget)?-1:1;zn(!0);const b=D=>{Jt(Qt(c+(D.clientX-r)*u))},E=()=>{zn(!1),window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)};window.addEventListener("pointermove",b),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E)},[Qt,Vt,Jt]),ei=i.useCallback(n=>{const r=n.shiftKey?40:10,c=ns(n.currentTarget)?-1:1,u=(n.key==="ArrowLeft"?-r:n.key==="ArrowRight"?r:0)*c;u!==0&&(n.preventDefault(),Jt(Qt(Vt+u)))},[Qt,Vt,Jt]),xn=i.useMemo(()=>Ce?vs(_,new Set).flatMap(n=>n.kind==="file"?[n.file]:[]):[],[_,Ce]),Lt=Ce?xn:_,vt=Ce?xn.find(n=>n.path===A)??xn[0]??null:null,Yt=vt?.path??null;i.useEffect(()=>{Yt&&!ge.has(Yt)&&be(Yt)},[be,ge,Yt]);const Zt=i.useCallback(n=>{if(He(),Ce){he(n),M(!1),be(n),Pe.current?.scrollTo({top:0});return}he(n),M(!1),Q.current=!0,Ge.current=n,be(n),st(r=>r+1),jt(n)},[He,be,Ce,jt]);i.useEffect(()=>{const n=r=>{if(!a||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const c=r.target;if(c instanceof HTMLElement&&(c.isContentEditable||c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.closest('[role="dialog"]'))||(r.preventDefault(),Lt.length===0))return;const u=r.key==="ArrowDown"?1:-1,b=Ce?vt?.path:A,E=b?Lt.findIndex(I=>I.path===b):-1,D=E===-1?u>0?0:Lt.length-1:E+u,$=Lt[D];$&&Zt($.path)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[A,Zt,Ce,Lt,vt,a]);const[kt,ti]=i.useState(()=>new Set),ni=i.useCallback((n,r)=>{ti(c=>{if(c.has(n)===r)return c;const u=new Set(c);return r?u.add(n):u.delete(n),u})},[]),On=i.useCallback(async(n,r,c)=>{if(!h)return null;const u=Sn(h,n),b=await S.getGitStatus(u,{fresh:!0});return{nestedSources:Ss(b).map(E=>({filePath:`${n}${E.path}`,layout:r,revision:c,load:async()=>{if(_e(E.path))return null;const D=tn(E)&&!nn(E),$=await S.getGitDiff(u,{path:E.path,staged:D,contextLines:mt}),I={...Ct(E.path,$.diff,"patch"),submodule:$.submodule};return At(Pt(E.path,I),ae)}}))}},[ae,h,S]),[Wn]=i.useState(kr),$n=i.useRef([]),qn=i.useCallback((n,r,c,u,b)=>{if(!S.getGitDiffs)return Promise.resolve(null);const E=$n.current.filter(D=>!_e(D.filePath)&&ft(D.filePath)===u&&kt.has(D.filePath)===b).map(D=>({filePath:D.filePath,revision:D.revision??""}));return Wn({directory:n,filePath:r,revision:c,staged:u,contextLines:b?en:mt,peers:E,getGitDiffs:(D,$)=>S.getGitDiffs?.(D,$)??Promise.resolve([])})},[kt,ft,S,Wn]),Kn=i.useCallback(async(n,r)=>{const c=n.path,u=kt.has(c);if(l==="turn"){const I=Kt.get(c);return At(I?Pt(c,I):null,ae)}if(l==="branch"||l==="commit"||l==="pr"){const I=Ut.get(c);if(!u&&I?.status==="ready")return At(Pt(c,I.data),ae);if(!u&&I?.status==="loading")return null;const Be=u&&Ht?await Ht(c):await Et(c);if(Be.status!=="ready")throw new Error(Be.status==="error"?Be.message:"Diff not loaded");return At(Pt(c,Be.data),ae)}if(!h||_e(c))return null;const b=ft(c),E=u?en:mt;let D;try{const I=await qn(h,c,r,b,u);if(I&&!I.ok&&I.reason)throw new sn(I.error,I.reason);D=I?.ok?I.diff:await S.getGitDiff(h,{path:c,staged:b,contextLines:E})}catch(I){if(!(I instanceof sn))throw I;return I.reason==="nested_repository"?On(c,ut(n),r):null}const $={...Ct(c,D.diff,u?"full":"patch"),submodule:D.submodule};return At(Pt(c,$),ae)},[l,Ut,ae,h,Et,kt,ft,ut,S,Kt,Ht,qn,On]),Gn=i.useRef(Kn);Gn.current=Kn;const yn=l==="branch"||l==="commit"||l==="pr"?Ut:null,bn=l==="turn"?Kt:null,Hn=l==="all"||l==="working"||l==="staged",Un=i.useMemo(()=>_.map(n=>{const r=yn?.get(n.path),c=yn?`${r?.status??"absent"}:${ms(r)}`:bn?ms(bn.get(n.path)):Hn?`${ft(n.path)?"staged":"unstaged"}:${Je+(We.get(n.path)??0)}`:"local",u=`${ae?"hide":"show"}|${kt.has(n.path)?"full":"patch"}|${c}`;return{filePath:n.path,layout:ut(n),revision:u,load:()=>Gn.current(n,u)}}),[_,ae,We,kt,yn,bn,Hn,ft,ut,Je]);$n.current=Un;const Ve=xr({sources:Un}),[wn,si]=i.useState(null),Xn=i.useRef(_);Xn.current=_;const ii=i.useCallback(n=>{const r=Xn.current.find(c=>ps(c.path,n.filePath))?.path??n.filePath;si(c=>({key:n.filePath,nonce:(c?.nonce??0)+1})),Ce&&r!==A&&(he(r),M(l==="staged")),be(r),jt(r)},[l,A,be,Ce,jt]),{registerViewer:ri,openOnWord:oi,focusNonce:ai}=yr({find:Ve,visible:a,rootRef:yt,reveal:ii}),Jn=i.useCallback(n=>{xe(n==="side-by-side"?"side-by-side":"inline")},[xe]),[li,Qn]=i.useState(null),Yn=i.useCallback(async(n,r)=>{if(!h||!n)return;Qn(n);const c=we();try{let u=null;if(r?.patch&&!r.isBinary&&!_e(n)?u=ls(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!_e(n)&&(u=ds(r.original,r.modified)),u===null)try{const I=await S.getGitDiff(h,{path:n,staged:qe,contextLines:3});u=ls(I.diff)}catch{u=null}let b=r;if(u===null||!b){const I=await S.getGitFileDiff(h,{path:n,staged:qe}),Be={original:I.original??"",modified:I.modified??"",isBinary:I.isBinary,submodule:I.submodule};b=Be,qe||me(h,n,Be,c)}const E=u??(b.isBinary||_e(n)?1:ds(b.original,b.modified)),D=Sn(h,n),$=await hr(g,D,{directory:h});if(!$.ok){St.error(gr($.reason));return}Ft(h,D,E,1)}finally{Qn(u=>u===n?null:u)}},[qe,h,g,S,Ft,me]),ci=i.useCallback((n,r)=>{Yn(n,r)},[Yn]),di=i.useCallback(()=>zs(n=>n+1),[]),ui=()=>{if(!h)return null;const n=(r,c=!1)=>{const u=c||ge.has(r.path);return t.jsx(Mr,{visible:a&&u,directory:h,file:r,layout:ut(r),wrapLines:gt,hideWhitespace:ae,isSelected:!1,isExpanded:u,isMounted:c||Rt.has(r.path)||r.path===le,onSelect:Js,onExpandedChange:Gs,registerSectionRef:Ks,registerViewerRef:ri,onFindWordRequest:oi,onFullContextChange:ni,findReveal:wn&&ps(r.path,wn.key)?wn:null,showOpenInEditorAction:x&&l!=="turn"&&!J,isOpeningInEditor:li===r.path,onOpenInEditor:ci,staged:ft(r.path),readOnlyActions:l==="branch"||l==="commit"||l==="pr",hunkActionsEnabled:l==="all"||l==="working"||l==="staged",contentRevision:Je+(We.get(r.path)??0),comparisonDiff:l==="branch"||l==="commit"||l==="pr"?Ut.get(r.path)??Nn:void 0,onRetryComparisonDiff:di,loadFullComparisonDiff:Ht,initialDiffData:l==="turn"?Kt.get(r.path)??null:null},`${we()}:${h}:${r.path}`)};return t.jsxs("div",{ref:_n,className:ve("flex min-w-0 flex-1 min-h-0 h-full",j?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Ce&&t.jsxs(t.Fragment,{children:[t.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${Vt}px`},children:t.jsx(Vr,{changedFiles:_,selectedFile:vt?.path??null,onSelectFile:Zt})}),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":d("diffView.fileTree.resize"),tabIndex:0,onPointerDown:Zs,onKeyDown:ei,className:ve("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-inset-s-1 before:-inset-e-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Ys&&"bg-interactive-selection")})]}),$t&&!Ce&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:d("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:_.length})]}),t.jsx(Tr,{changedFiles:_,selectedFile:null,onSelectFile:Zt})]}),t.jsxs("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:[Ve.isOpen&&t.jsx(br,{query:Ve.query,onQueryChange:Ve.setQuery,total:Ve.matches.length,currentIndex:Ve.currentIndex,isSearching:Ve.isSearching,failedCount:Ve.failedCount,onNext:Ve.next,onPrevious:Ve.previous,onClose:Ve.close,focusNonce:ai}),t.jsx(Cn,{ref:Pe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none] pb-16","data-diff-virtual-content":!0,children:Ce?vt&&n(vt,!0):_.map(r=>n(r))})})]})]})},fi=()=>{if(!h)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d("diffView.state.selectSessionDirectory")});if(l!=="turn"&&z&&!F)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingRepositoryStatus")]});if(l!=="turn"&&V===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d("diffView.state.notGitRepository")});if(l==="pr"){if(!Ue||se.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[!se.error&&!Se.error&&!Se.loading&&t.jsx(q,{name:"git-pull-request",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:se.error??Se.error??(Se.loading?d(rn("session.githubPrPicker.loading.pullRequests",Se.provider)):d(rn("pullRequestComparison.pickAbove",Se.provider)))}),(se.error||Se.error)&&t.jsx(je,{variant:"outline",size:"sm",onClick:()=>{Ue?se.refresh():Se.refresh()},children:d("diffView.actions.retry")})]});if(!se.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingDiff")]})}if(l==="commit"){if(Ln)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ln}),t.jsx(je,{variant:"outline",size:"sm",onClick:()=>{se.refresh()},children:d("diffView.actions.retry")})]});if(!dt&&!tt.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:tt.error??d("commitComparison.noCommits")});if(!Vn)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingDiff")]})}if(l==="branch"){if(!Fn)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.branch.resolvingBase")]});if(!Ee)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(q,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:d("gitView.pr.toast.baseBranchRequired")})]});if(An)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:An}),t.jsx(je,{variant:"outline",size:"sm",onClick:()=>{se.refresh()},children:d("diffView.actions.retry")})]});if(wt===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.branch.loadingFiles")]})}return l==="turn"&&bt?t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-4 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta max-w-[32rem] text-center",children:bt}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>{Te(null),Cs()},children:d("diffView.actions.retry")})]}):_.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l==="turn"?d("diffView.state.noLastTurnChanges"):l==="pr"?d("walkthrough.blocked.emptyDiff.description"):l==="commit"?d("commitComparison.emptyDiff"):l==="branch"&&Ee?d("diffView.branch.empty",{base:ur(Ee)}):d("diffView.state.cleanWorkingTree")}):ui()},Zn=_.length>0&&Wt&&(l!=="pr"||!!Gt),es=()=>{const n=h??"";G(n,l==="pr"&&Ue&&Gt?{source:Ue,context:Gt}:{source:l==="commit"&&dt?{kind:"commit",hash:dt}:l==="branch"&&Ee&&ue?{kind:"branch",baseRef:Ee,headRef:ue}:{kind:"working-tree",scope:l==="staged"||l==="working"?l:"all"}}),J&&L?P(L,{mode:"walkthrough",targetDirectory:K}):H(K??n,"walkthrough")},mi=n=>{switch(n){case"walkthrough":return Zn?{label:d("walkthrough.action.open"),icon:t.jsx(q,{name:"route",className:"size-4"}),on:!1,select:es}:null;case"tree":return Ke?null:{label:d("diffView.fileTree.showAsTree"),icon:t.jsx(q,{name:"node-tree",className:"size-4"}),on:$e==="tree",select:()=>zt($e==="tree"?"flat":"tree")};case"wrap":return{label:d("diffView.actions.wrapLines"),icon:t.jsx(q,{name:"text-wrap",className:"size-4"}),on:gt,select:()=>Fe(!ht)};case"whitespace":return{label:d("diffView.actions.hideWhitespace"),icon:t.jsx(is,{hidden:ae,className:"size-4"}),on:ae,select:()=>_t(!ae)};case"layout":{const r=pn==="side-by-side";return{label:d("diffView.layout.sideBySide"),icon:t.jsx(q,{name:"layout-column",className:"size-4"}),on:r,select:()=>Jn(r?"unified":"side-by-side")}}}};return t.jsxs("div",{ref:yt,"data-find-surface":"",className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsx(lr,{children:t.jsxs("div",{ref:p,className:ve("flex min-w-0 items-center gap-2",k?"flex-1 py-1 pe-1":"px-3 py-2 bg-background"),children:[ne?t.jsx(cr,{repositories:ne,selectedRepository:ee??null,onSelectRepository:n=>{K&&X(K,n)},repositoryRoot:K??void 0}):null,!te&&!J&&(l!=="all"?t.jsx(Dr,{scope:l,workingCount:Fs,stagedCount:Ds,turnCount:Ts,branchCount:qs,commitCount:l==="commit"?Vn?.length??null:null,prCount:l==="pr"?se.files?.length??null:null,showCommitOption:!Ie(),showBranchOption:un,changeRequestProvider:Se.provider,onScopeChange:n=>{Qe(n),C?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:z&&!F?d("diffView.state.loadingChanges"):_.length===1?d("diffView.summary.changedFilesSingle",{count:_.length}):d("diffView.summary.changedFilesPlural",{count:_.length})})})),l==="branch"&&t.jsx(yi,{branches:cn?.all??[],currentBranch:ue,base:Ee,automatic:Bs!=="chosen",onSelect:n=>{h&&ue&&As(h,ue,n)},onSelectAutomatic:()=>{h&&ue&&Ps(h,ue)}},JSON.stringify([h,ue])),l==="commit"&&t.jsx(bi,{commits:tt.commits,selectedHash:dt,loading:tt.loading,error:tt.error,onSelect:tt.select,onRefresh:()=>{tt.refresh()}},JSON.stringify([h,ue])),l==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(wi,{comparison:Se},JSON.stringify([fe,h,ue])),Ue&&t.jsx(je,{variant:"ghost",size:"sm",disabled:se.loading,"aria-label":d("session.githubIssuePicker.actions.refresh"),title:d("session.githubIssuePicker.actions.refresh"),onClick:()=>{se.refresh()},children:t.jsx(q,{name:"refresh",className:"size-4"})})]}),_.length>0&&t.jsxs(je,{variant:"ghost",size:"sm",onClick:Hs,className:ve("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ms-auto"),title:ge.size>0?d("diffView.actions.collapseAll"):d("diffView.actions.expandAll"),children:[t.jsx(q,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:ge.size>0?d("diffView.actions.collapseAll"):d("diffView.actions.expandAll")})]}),_.length>0&&at&&t.jsxs(je,{variant:"default",size:"sm",onClick:()=>ke(!0),disabled:gn,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":d("diffView.actions.reviewAria"),children:[gn?t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(q,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:d("diffView.actions.review")})]}),Zn&&t.jsxs(je,{variant:"outline",size:"sm",onClick:es,className:ve("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",dr),"aria-label":d("walkthrough.action.open"),children:[t.jsx(q,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:d("walkthrough.action.open")})]}),_.length>0&&!Ke&&t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>zt($e==="tree"?"flat":"tree"),"aria-pressed":$e==="tree",className:ve("diff-toolbar__tree-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",$e==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d($e==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:t.jsx(q,{name:"node-tree",className:"size-4"})}),_.length>0&&t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>Fe(!ht),className:ve("diff-toolbar__wrap-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",gt?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d(gt?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(q,{name:"text-wrap",className:"size-4"})}),_.length>0&&t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>_t(!ae),"aria-pressed":ae,className:ve("diff-toolbar__whitespace-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",ae?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d(ae?"diffView.whitespace.hidden":"diffView.whitespace.shown"),"aria-label":d("diffView.actions.hideWhitespace"),children:t.jsx(is,{hidden:ae,className:"size-4"})}),pn&&t.jsx(xs,{mode:pn==="side-by-side"?"side-by-side":"unified",onModeChange:Jn,className:"diff-toolbar__layout-toggle flex-shrink-0"}),_.length>0&&t.jsxs(ys,{onOpenChange:N,children:[t.jsxs(Ki,{children:[t.jsx(Gi,{asChild:!0,children:t.jsx("span",{className:"diff-toolbar__more flex-shrink-0",children:t.jsx(bs,{asChild:!0,children:t.jsx(je,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":d("diffView.actions.moreActions"),children:t.jsx(q,{name:"more",className:"size-4"})})})})}),t.jsx(Hi,{side:"bottom",sideOffset:6,children:d("diffView.actions.moreActions")})]}),t.jsx(ws,{align:"end",className:"min-w-56",children:m.map(n=>{const r=mi(n);return r?t.jsxs(Ui,{className:"flex items-center gap-2",onClick:r.select,children:[r.icon,t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:r.label}),r.on?t.jsx(q,{name:"check",className:"ms-auto size-4 text-foreground"}):null]},n):null})})]})]})}),t.jsx(Xi,{open:It,onOpenChange:ke,projectDirectory:h??null,submitting:gn,onConfirm:Xs}),fi()]})};function Br(){return new Set}function Ir(a){return{original:a.original??"",modified:a.modified??"",isBinary:a.isBinary,submodule:a.submodule,contextMode:"full"}}function _r(a){return a.addProject}function zr(a){return a.openNewSessionDraft}function Or(){return new Set}function Wr(a){return a+1}export{ol as DiffView,Mr as MultiFileDiffEntry};
|
|
4
|
+
`),x=Math.min(s.length,o.length);for(let f=0;f<x;f+=1)if(s[f]!==o[f])return f+1;return o.length>s.length?s.length+1:s.length>o.length?Math.max(1,o.length):1},Ct=(a,e,s)=>Ni(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Si(a,e),contextMode:s},Pt=(a,e)=>e.isBinary||e.submodule?null:e.fileDiff?e.fileDiff:!e.original&&!e.modified?null:vs({name:a,contents:e.original},{name:a,contents:e.modified}),us=new WeakMap;let fs=0;const ms=a=>{if(!a)return"absent";let e=us.get(a);return e===void 0&&(fs+=1,e=fs,us.set(a,e)),String(e)},ps=(a,e)=>e===a||a.endsWith("/")&&e.startsWith(a),Rn=(a,e,s)=>{const o=a??0,x=e??0;return!o&&!x?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[o?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",o]}):null,x?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",x]}):null]})},Dr=i.memo(a=>{const e=Xe.c(70),{scope:s,workingCount:o,stagedCount:x,turnCount:f,branchCount:C,commitCount:j,prCount:v,showCommitOption:y,showBranchOption:d,changeRequestProvider:k,onScopeChange:p}=a,{t:m}=ze(),[R,N]=i.useState(!1),S=s==="pr"?v??0:s==="staged"?x:s==="turn"?f:s==="branch"?C??0:s==="commit"?j??0:o;let g;e[0]!==k||e[1]!==s||e[2]!==m?(g=m(s==="pr"?rn("session.githubIntegration.tabs.pullRequests",k):s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=k,e[1]=s,e[2]=m,e[3]=g):g=e[3];const T=g;let L;e[4]!==m?(L=m("diffView.scope.selectorAria"),e[4]=m,e[5]=L):L=e[5];let J;e[6]!==S?(J=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",S]}),e[6]=S,e[7]=J):J=e[7];let K;e[8]!==T||e[9]!==J?(K=t.jsxs("span",{className:"whitespace-nowrap",children:[T,J]}),e[8]=T,e[9]=J,e[10]=K):K=e[10];let fe;e[11]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx(q,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[11]=fe):fe=e[11];let ee;e[12]!==L||e[13]!==K?(ee=t.jsx(bs,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":L,children:[K,fe]})}),e[12]=L,e[13]=K,e[14]=ee):ee=e[14];let ne;e[15]!==p?(ne=A=>{(A==="working"||A==="staged"||A==="turn"||A==="branch"||A==="commit"||A==="pr")&&(p?.(A),N(!1))},e[15]=p,e[16]=ne):ne=e[16];let h;e[17]!==m?(h=m("diffView.scope.changed"),e[17]=m,e[18]=h):h=e[18];let O;e[19]!==h?(O=t.jsx("span",{children:h}),e[19]=h,e[20]=O):O=e[20];let H;e[21]!==o?(H=t.jsx("span",{className:"typography-meta text-muted-foreground",children:o}),e[21]=o,e[22]=H):H=e[22];let P;e[23]!==H||e[24]!==O?(P=t.jsx(Nt,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[O,H]})}),e[23]=H,e[24]=O,e[25]=P):P=e[25];let G;e[26]!==m?(G=m("diffView.scope.staged"),e[26]=m,e[27]=G):G=e[27];let U;e[28]!==G?(U=t.jsx("span",{children:G}),e[28]=G,e[29]=U):U=e[29];let te;e[30]!==x?(te=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[30]=x,e[31]=te):te=e[31];let V;e[32]!==U||e[33]!==te?(V=t.jsx(Nt,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[U,te]})}),e[32]=U,e[33]=te,e[34]=V):V=e[34];let F;e[35]!==m?(F=m("diffView.scope.lastTurn"),e[35]=m,e[36]=F):F=e[36];let z;e[37]!==F?(z=t.jsx("span",{children:F}),e[37]=F,e[38]=z):z=e[38];let B;e[39]!==f?(B=t.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[39]=f,e[40]=B):B=e[40];let W;e[41]!==z||e[42]!==B?(W=t.jsx(Nt,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[z,B]})}),e[41]=z,e[42]=B,e[43]=W):W=e[43];let X;e[44]!==C||e[45]!==d||e[46]!==m?(X=d?t.jsx(Nt,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}):null,e[44]=C,e[45]=d,e[46]=m,e[47]=X):X=e[47];let de;e[48]!==j||e[49]!==y||e[50]!==m?(de=y&&t.jsx(Nt,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[48]=j,e[49]=y,e[50]=m,e[51]=de):de=e[51];let re;e[52]!==k||e[53]!==v||e[54]!==y||e[55]!==m?(re=y&&t.jsx(Nt,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m(rn("session.githubIntegration.tabs.pullRequests",k))}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[52]=k,e[53]=v,e[54]=y,e[55]=m,e[56]=re):re=e[56];let ie;e[57]!==s||e[58]!==P||e[59]!==V||e[60]!==W||e[61]!==X||e[62]!==de||e[63]!==re||e[64]!==ne?(ie=t.jsx(ws,{align:"start",className:"w-40",children:t.jsxs(er,{value:s,onValueChange:ne,children:[P,V,W,X,de,re]})}),e[57]=s,e[58]=P,e[59]=V,e[60]=W,e[61]=X,e[62]=de,e[63]=re,e[64]=ne,e[65]=ie):ie=e[65];let me;return e[66]!==R||e[67]!==ie||e[68]!==ee?(me=t.jsxs(ys,{open:R,onOpenChange:N,children:[ee,ie]}),e[66]=R,e[67]=ie,e[68]=ee,e[69]=me):me=e[69],me}),Tr=i.memo(a=>{const e=Xe.c(11),{changedFiles:s,selectedFile:o,onSelectFile:x}=a,{t:f}=ze();if(s.length===0)return null;let C;if(e[0]!==s||e[1]!==x||e[2]!==o||e[3]!==f){let v;e[5]!==x||e[6]!==o||e[7]!==f?(v=y=>{const d=ln(y),k=o===y.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>x(y.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start transition-colors",k?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(an,{filePath:y.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:d.color},title:f(d.descriptionKey),"aria-label":f(d.descriptionKey),children:d.code}),t.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",unicodeBidi:"plaintext"},title:y.path,children:y.path}),Rn(y.insertions,y.deletions)]})},y.path)},e[5]=x,e[6]=o,e[7]=f,e[8]=v):v=e[8],C=s.map(v),e[0]=s,e[1]=x,e[2]=o,e[3]=f,e[4]=C}else C=e[4];let j;return e[9]!==C?(j=t.jsx(Cn,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:C})}),e[9]=C,e[10]=j):j=e[10],j}),jn=160,Er=.5,Vr=i.memo(a=>{const e=Xe.c(18),{changedFiles:s,selectedFile:o,onSelectFile:x}=a,{t:f}=ze(),[C,j]=i.useState(Br);let v;e[0]!==s||e[1]!==C?(v=js(s,C),e[0]=s,e[1]=C,e[2]=v):v=e[2];const y=v;let d,k;e[3]!==o?(d=()=>{o&&j(S=>{const g=Array.from(S).filter(L=>o.startsWith(`${L}/`));if(g.length===0)return S;const T=new Set(S);return g.forEach(L=>T.delete(L)),T})},k=[o],e[3]=o,e[4]=d,e[5]=k):(d=e[4],k=e[5]),i.useEffect(d,k);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=S=>{j(g=>{const T=new Set(g);return T.delete(S)||T.add(S),T})},e[6]=p):p=e[6];const m=p;let R;if(e[7]!==x||e[8]!==y||e[9]!==o||e[10]!==f){let S;e[12]!==x||e[13]!==o||e[14]!==f?(S=g=>{const T=tr(g.depth);if(g.kind==="directory")return t.jsxs("li",{className:"relative",children:[t.jsx(rs,{depth:g.depth}),t.jsxs("button",{type:"button",onClick:()=>m(g.path),"aria-expanded":g.expanded,"aria-label":g.expanded?f("diffView.fileTree.collapseDirectoryAria",{path:g.path}):f("diffView.fileTree.expandDirectoryAria",{path:g.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pe-2 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingInlineStart:T},title:g.path,children:[t.jsx(nr,{expanded:g.expanded}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:g.label})]})]},g.key);const L=ln(g.file),J=o===g.file.path;return t.jsxs("li",{className:"relative",children:[t.jsx(rs,{depth:g.depth}),t.jsxs("button",{type:"button",onClick:()=>x(g.file.path),"aria-current":J?"true":void 0,className:je("flex w-full items-center gap-1.5 rounded-md py-1 pe-2 text-start transition-colors",ir(J)),style:{paddingInlineStart:T},title:g.file.path,children:[t.jsx(an,{filePath:g.file.path,className:"ms-0.5 size-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:g.name}),t.jsx(sr,{code:L.code,color:L.color,label:f(L.descriptionKey)})]})]},g.key)},e[12]=x,e[13]=o,e[14]=f,e[15]=S):S=e[15],R=y.map(S),e[7]=x,e[8]=y,e[9]=o,e[10]=f,e[11]=R}else R=e[11];let N;return e[16]!==R?(N=t.jsx(Cn,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:t.jsx("ul",{className:"flex flex-col",children:R})}),e[16]=R,e[17]=N):N=e[17],N}),Lr=i.memo(a=>{const e=Xe.c(20),{filePath:s,diff:o,renderSideBySide:x}=a,{t:f}=ze(),C=o.original.length>0,j=o.modified.length>0,v=x?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",y=x?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={contain:"layout"},e[0]=d):d=e[0];let k;e[1]!==o.original||e[2]!==s||e[3]!==C||e[4]!==y||e[5]!==x||e[6]!==f?(k=C&&t.jsxs("div",{className:y,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),t.jsx("img",{src:o.original,alt:f("diffView.image.originalAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=o.original,e[2]=s,e[3]=C,e[4]=y,e[5]=x,e[6]=f,e[7]=k):k=e[7];let p;e[8]!==o.modified||e[9]!==s||e[10]!==j||e[11]!==C||e[12]!==y||e[13]!==x||e[14]!==f?(p=j&&t.jsxs("div",{className:y,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(C?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:o.modified,alt:f("diffView.image.modifiedAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=o.modified,e[9]=s,e[10]=j,e[11]=C,e[12]=y,e[13]=x,e[14]=f,e[15]=p):p=e[15];let m;return e[16]!==v||e[17]!==k||e[18]!==p?(m=t.jsx("div",{className:"w-full overflow-auto p-4",style:d,children:t.jsxs("div",{className:v,children:[k,p]})}),e[16]=v,e[17]=k,e[18]=p,e[19]=m):m=e[19],m}),Ns=i.memo(a=>{const e=Xe.c(26),{filePath:s,diff:o,staged:x,renderSideBySide:f,wrapLines:C,hideWhitespace:j,hunkActions:v,onExpandContextRequest:y,pendingContextExpansion:d,contextLoading:k,viewerRef:p,onFindWordRequest:m}=a;let R;e[0]!==s?(R=Zi(s)||"text",e[0]=s,e[1]=R):R=e[1];const N=R;if(o.submodule){let T;return e[2]!==o.submodule||e[3]!==x?(T=t.jsx(Ai,{state:o.submodule,staged:x}),e[2]=o.submodule,e[3]=x,e[4]=T):T=e[4],T}if(o.isBinary){let T;return e[5]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Fr,{}),e[5]=T):T=e[5],T}if(_e(s)){let T;return e[6]!==o||e[7]!==s||e[8]!==f?(T=t.jsx(Lr,{filePath:s,diff:o,renderSideBySide:f}),e[6]=o,e[7]=s,e[8]=f,e[9]=T):T=e[9],T}let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={contain:"layout"},e[10]=S):S=e[10];let g;return e[11]!==k||e[12]!==o.fileDiff||e[13]!==o.modified||e[14]!==o.original||e[15]!==s||e[16]!==j||e[17]!==v||e[18]!==N||e[19]!==y||e[20]!==m||e[21]!==d||e[22]!==f||e[23]!==p||e[24]!==C?(g=t.jsx("div",{className:"w-full",style:S,children:t.jsx(pr,{ref:p,original:o.original,modified:o.modified,fileDiff:o.fileDiff,language:N,fileName:s,renderSideBySide:f,wrapLines:C,hideWhitespace:j,layout:"inline",hunkActions:v,onExpandContextRequest:y,pendingContextExpansion:d,contextLoading:k,onFindWordRequest:m})}),e[11]=k,e[12]=o.fileDiff,e[13]=o.modified,e[14]=o.original,e[15]=s,e[16]=j,e[17]=v,e[18]=N,e[19]=y,e[20]=m,e[21]=d,e[22]=f,e[23]=p,e[24]=C,e[25]=g):g=e[25],g}),Ss=a=>a.files.map(e=>{const s=a.diffStats?.staged?.[e.path],o=a.diffStats?.working?.[e.path];return{...e,insertions:(s?.insertions??0)+(o?.insertions??0),deletions:(s?.deletions??0)+(o?.deletions??0),isNew:ks(e)}}).sort((e,s)=>e.path.localeCompare(s.path)),Ar=i.memo(a=>{const e=Xe.c(55),{directory:s,file:o,revision:x,renderSideBySide:f,wrapLines:C,hideWhitespace:j,findKeyPrefix:v,registerViewerRef:y,onFindWordRequest:d,findReveal:k}=a,p=k===void 0?null:k,{t:m}=ze(),{git:R}=on(),[N,S]=i.useState(Nn),[g,T]=i.useState(!1),L=v===void 0?null:`${v}${o.path}`;let J;e[0]!==L||e[1]!==p?.key?(J=()=>{L!==null&&p?.key===L&&T(!0)},e[0]=L,e[1]=p?.key,e[2]=J):J=e[2];let K;e[3]!==L||e[4]!==p?(K=[L,p],e[3]=L,e[4]=p,e[5]=K):K=e[5],i.useEffect(J,K);let fe;e[6]!==L||e[7]!==y?(fe=V=>{L!==null&&y?.(L,V)},e[6]=L,e[7]=y,e[8]=fe):fe=e[8];const ee=fe;let ne;e[9]!==L||e[10]!==d?(ne=V=>{L!==null&&d?.(L,V)},e[9]=L,e[10]=d,e[11]=ne):ne=e[11];const h=ne;let O;e[12]!==o?(O=tn(o)&&!nn(o),e[12]=o,e[13]=O):O=e[13];const H=O,P=`${o.index}:${o.working_dir}:${o.insertions}:${o.deletions}`;let G;e[14]!==s||e[15]!==o.path||e[16]!==R||e[17]!==H||e[18]!==m?(G=()=>{let V=!1;const F=we();return(_e(o.path)?R.getGitFileDiff(s,{path:o.path,staged:H}).then(Ir):R.getGitDiff(s,{path:o.path,staged:H,contextLines:mt}).then(B=>({...Ct(o.path,B.diff,"patch"),submodule:B.submodule}))).then(B=>{V||F!==we()||S({status:"ready",data:B})},B=>{if(V||F!==we())return;const W=B instanceof sn?B.reason==="nested_repository"?m("diffView.unavailable.nestedRepositoryTitle"):B.reason==="untracked_directory"?m("diffView.unavailable.untrackedDirectoryTitle"):m("diffView.unavailable.missingTitle"):B instanceof Error?B.message:String(B);S({status:"error",message:W})}),()=>{V=!0}},e[14]=s,e[15]=o.path,e[16]=R,e[17]=H,e[18]=m,e[19]=G):G=e[19];let U;if(e[20]!==s||e[21]!==o.path||e[22]!==P||e[23]!==R||e[24]!==x||e[25]!==H||e[26]!==m?(U=[s,o.path,P,R,x,H,m],e[20]=s,e[21]=o.path,e[22]=P,e[23]=R,e[24]=x,e[25]=H,e[26]=m,e[27]=U):U=e[27],i.useEffect(G,U),N.status==="loading"){let V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),e[28]=V):V=e[28];let F;e[29]!==m?(F=m("diffView.state.loadingDiff"),e[29]=m,e[30]=F):F=e[30];let z;return e[31]!==F?(z=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[V,F]}),e[31]=F,e[32]=z):z=e[32],z}if(N.status==="error"){let V;return e[33]!==N.message?(V=t.jsx("div",{className:"px-4 py-4 text-center typography-meta text-muted-foreground",children:N.message}),e[33]=N.message,e[34]=V):V=e[34],V}if(!g&&o.insertions+o.deletions>kn){const V=o.insertions+o.deletions;let F;e[35]!==m||e[36]!==V?(F=m("diffView.state.largeDiff",{count:V}),e[35]=m,e[36]=V,e[37]=F):F=e[37];let z;e[38]===Symbol.for("react.memo_cache_sentinel")?(z=()=>T(!0),e[38]=z):z=e[38];let B;e[39]!==m?(B=m("diffView.actions.renderAnyway"),e[39]=m,e[40]=B):B=e[40];let W;e[41]!==B?(W=t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:z,children:B}),e[41]=B,e[42]=W):W=e[42];let X;return e[43]!==F||e[44]!==W?(X=t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[F,W]}),e[43]=F,e[44]=W,e[45]=X):X=e[45],X}let te;return e[46]!==o.path||e[47]!==h||e[48]!==j||e[49]!==f||e[50]!==N.data||e[51]!==ee||e[52]!==H||e[53]!==C?(te=t.jsx(Ns,{filePath:o.path,diff:N.data,staged:H,renderSideBySide:f,wrapLines:C,hideWhitespace:j,viewerRef:ee,onFindWordRequest:h}),e[46]=o.path,e[47]=h,e[48]=j,e[49]=f,e[50]=N.data,e[51]=ee,e[52]=H,e[53]=C,e[54]=te):te=e[54],te}),Pr=i.memo(a=>{const e=Xe.c(71),{directory:s,revision:o,renderSideBySide:x,wrapLines:f,hideWhitespace:C,findKeyPrefix:j,registerViewerRef:v,onFindWordRequest:y,findReveal:d}=a,k=d===void 0?null:d,{t:p}=ze(),{git:m}=on(),R=Yi(_r),N=hs(zr);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={kind:"loading"},e[0]=S):S=e[0];const[g,T]=i.useState(S),[L,J]=i.useState(0),[K,fe]=i.useState(Or);let ee;e[1]!==s||e[2]!==m?(ee=()=>{let M=!1;const le=we();return m.getGitStatus(s,{fresh:!0}).then(oe=>{M||le!==we()||T({kind:"ready",files:Ss(oe)})},oe=>{M||le!==we()||T({kind:"error",message:oe instanceof Error?oe.message:String(oe)})}),()=>{M=!0}},e[1]=s,e[2]=m,e[3]=ee):ee=e[3];let ne;e[4]!==s||e[5]!==m||e[6]!==L||e[7]!==o?(ne=[s,m,o,L],e[4]=s,e[5]=m,e[6]=L,e[7]=o,e[8]=ne):ne=e[8],i.useEffect(ee,ne);let h,O;e[9]!==j||e[10]!==k?(h=()=>{if(!k||j===void 0||!k.key.startsWith(j))return;const M=k.key.slice(j.length);fe(le=>le.has(M)?le:new Set(le).add(M))},O=[j,k],e[9]=j,e[10]=k,e[11]=h,e[12]=O):(h=e[11],O=e[12]),i.useEffect(h,O);let H;e[13]===Symbol.for("react.memo_cache_sentinel")?(H=M=>{fe(le=>{const oe=new Set(le);return oe.delete(M)||oe.add(M),oe})},e[13]=H):H=e[13];const P=H;let G;e[14]!==R||e[15]!==s||e[16]!==N||e[17]!==p?(G=async()=>{const M=await R(s);if(!M){St.error(p("diffView.nestedRepository.openFailed"));return}N({selectedProjectId:M.id,directoryOverride:M.path})},e[14]=R,e[15]=s,e[16]=N,e[17]=p,e[18]=G):G=e[18];const U=G;let te;e[19]!==p?(te=p("diffView.unavailable.nestedRepositoryTitle"),e[19]=p,e[20]=te):te=e[20];let V;e[21]!==te?(V=t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:te}),e[21]=te,e[22]=V):V=e[22];let F;e[23]!==p?(F=p("diffView.nestedRepository.description"),e[23]=p,e[24]=F):F=e[24];let z;e[25]!==F?(z=t.jsx("div",{className:"typography-meta text-muted-foreground",children:F}),e[25]=F,e[26]=z):z=e[26];let B;e[27]!==V||e[28]!==z?(B=t.jsxs("div",{className:"min-w-0 flex-1",children:[V,z]}),e[27]=V,e[28]=z,e[29]=B):B=e[29];let W;e[30]!==U?(W=()=>{U()},e[30]=U,e[31]=W):W=e[31];let X;e[32]!==p?(X=p("diffView.nestedRepository.openAsProject"),e[32]=p,e[33]=X):X=e[33];let de;e[34]!==W||e[35]!==X?(de=t.jsx(ve,{variant:"outline",size:"sm",className:"shrink-0",onClick:W,children:X}),e[34]=W,e[35]=X,e[36]=de):de=e[36];let re;e[37]!==B||e[38]!==de?(re=t.jsxs("div",{className:"flex items-center gap-3 px-3",children:[B,de]}),e[37]=B,e[38]=de,e[39]=re):re=e[39];let ie;e[40]!==g.kind||e[41]!==p?(ie=g.kind==="loading"?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-4 typography-meta text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),p("diffView.nestedRepository.loading")]}):null,e[40]=g.kind,e[41]=p,e[42]=ie):ie=e[42];let me;e[43]!==g.kind||e[44]!==g.message||e[45]!==p?(me=g.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-4",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:p("diffView.nestedRepository.loadFailed")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:g.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(Wr),children:p("diffView.actions.retry")})]}):null,e[43]=g.kind,e[44]=g.message,e[45]=p,e[46]=me):me=e[46];let A;e[47]!==g.files||e[48]!==g.kind||e[49]!==p?(A=g.kind==="ready"&&g.files.length===0?t.jsx("div",{className:"px-3 typography-meta text-muted-foreground",children:p("diffView.nestedRepository.noChanges")}):null,e[47]=g.files,e[48]=g.kind,e[49]=p,e[50]=A):A=e[50];let he;e[51]!==s||e[52]!==K||e[53]!==j||e[54]!==k||e[55]!==C||e[56]!==y||e[57]!==v||e[58]!==x||e[59]!==o||e[60]!==g.files||e[61]!==g.kind||e[62]!==p||e[63]!==f?(he=g.kind==="ready"&&g.files.length>0?t.jsx("ul",{className:"flex flex-col",children:g.files.map(M=>{const le=K.has(M.path),oe=ln(M);return t.jsxs("li",{children:[t.jsxs("button",{type:"button","aria-expanded":le,onClick:()=>P(M.path),className:"flex w-full items-center gap-2 px-3 py-1 text-start text-foreground/80 transition-colors hover:text-foreground",title:M.path,children:[t.jsx(q,{name:le?"arrow-down-s":"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"typography-micro font-semibold w-4 shrink-0 text-center uppercase",style:{color:oe.color},title:p(oe.descriptionKey),"aria-label":p(oe.descriptionKey),children:oe.code}),t.jsx(an,{filePath:M.path,className:"size-3.5 shrink-0"}),t.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",unicodeBidi:"plaintext"},children:M.path}),Rn(M.insertions,M.deletions)]}),le?t.jsx(Ar,{directory:s,file:M,revision:o,renderSideBySide:x,wrapLines:f,hideWhitespace:C,findKeyPrefix:j,registerViewerRef:v,onFindWordRequest:y,findReveal:k?.key===`${j}${M.path}`?k:null}):null]},M.path)})}):null,e[51]=s,e[52]=K,e[53]=j,e[54]=k,e[55]=C,e[56]=y,e[57]=v,e[58]=x,e[59]=o,e[60]=g.files,e[61]=g.kind,e[62]=p,e[63]=f,e[64]=he):he=e[64];let Z;return e[65]!==re||e[66]!==ie||e[67]!==me||e[68]!==A||e[69]!==he?(Z=t.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[re,ie,me,A,he]}),e[65]=re,e[66]=ie,e[67]=me,e[68]=A,e[69]=he,e[70]=Z):Z=e[70],Z}),Mr=i.memo(({visible:a=!0,directory:e,file:s,layout:o,wrapLines:x,hideWhitespace:f=!1,isSelected:C,isExpanded:j,isMounted:v,onSelect:y,onExpandedChange:d,registerSectionRef:k,showOpenInEditorAction:p=!1,isOpeningInEditor:m=!1,onOpenInEditor:R,staged:N=!1,loadFullFiles:S=!1,initialDiffData:g=null,comparisonDiff:T,onRetryComparisonDiff:L,loadFullComparisonDiff:J,readOnlyActions:K=!1,hunkActionsEnabled:fe=!1,contentRevision:ee=0,registerViewerRef:ne,onFindWordRequest:h,onFullContextChange:O,findReveal:H=null})=>{const{t:P}=ze(),{git:G}=on(),U=Re(i.useCallback(w=>w.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),te=Re(w=>w.setDiff),V=Re(w=>w.fetchStatus),F=ce(w=>w.setDiffFileLayout),[z,B]=i.useState(0),[W,X]=i.useState(null),[de,re]=i.useState(!1),[ie,me]=i.useState(null),A=ie!==null&&ie.source===T?ie.result:T,he=!!e&&!g&&(!T||!!J),Z=i.useMemo(()=>A?A.status==="error"?{kind:"error",message:A.message}:null:W,[A,W]),M=A?A.status==="loading":de,[le,oe]=i.useState(null),ge=i.useRef(!1),[Oe,Rt]=i.useState(null),[nt,Mt]=i.useState(!1),[st,We]=i.useState(null),[Bt,Je]=i.useState(null),[it,It]=i.useState(null),ke=S||it!==null;i.useEffect(()=>{if(!(!ke||!O))return O(s.path,!0),()=>O(s.path,!1)},[s.path,ke,O]),i.useEffect(()=>{H?.key===s.path&&Mt(!0)},[s.path,H]),i.useEffect(()=>{if(!it||!J||!T||T.status!=="ready"||ie?.source===T)return;let w=!1;return J(s.path).then(Q=>{if(!w){if(Q.status==="error"){St.error(Q.message),It(null);return}me({source:T,result:Q})}}),()=>{w=!0}},[it,s.path,ie,J,T]);const l=i.useRef(null),Qe=i.useRef(null),Le=i.useMemo(()=>ln(s),[s]),pt=o==="side-by-side",De=ke?"full":"patch",rt=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,Ne=fe&&!K&&!g&&!A&&!_e(s.path),ot=JSON.stringify([we(),e,s.path,N,rt,z,ee]),xe=Oe?.scope===ot?Oe.patch:null,ht=Oe?.scope===ot?Oe.submodule:null,Fe=i.useMemo(()=>A?A.status==="ready"?A.data:null:g||(N?Bt:st||(U?{original:U.original,modified:U.modified,isBinary:U.isBinary,submodule:U.submodule,contextMode:"full"}:null)),[A,U,g,st,N,Bt]),ae=Fe?.contextMode===De,_t=i.useCallback(w=>{Qe.current=w,k(s.path,w)},[s.path,k]),$e=i.useCallback(w=>{ne?.(s.path,w)},[s.path,ne]),zt=i.useCallback(w=>{h?.(s.path,w)},[s.path,h]),Ft=i.useCallback(w=>{d(s.path,w)},[s.path,d]),Ot=i.useCallback(()=>{y(s.path)},[s.path,y]),Ae=i.useRef(N);i.useEffect(()=>{Ae.current!==N&&(Ae.current=N,N?Je(null):We(null),X(null),l.current=null)},[N]);const Ye=`${ee}:${rt}`,[gt,xt]=i.useState(Ye),qe=gt===Ye;i.useEffect(()=>{qe||(X(null),l.current=null)},[qe]),i.useEffect(()=>{if(!a||!j||!v||W)return;if(!e||A||g||Fe&&ae&&qe&&(!Ne||xe!==null)){l.current=null,re(!1);return}const w=`${e}::${s.path}::${N?"staged":"unstaged"}::${rt}::${De}::${z}::${ee}`;if(l.current===w)return;l.current=w,X(null),re(!0);let Q=!1;const ye=we(),lt=ke?en:mt,pe=_e(s.path)?G.getGitFileDiff(e,{path:s.path,staged:N}):!ke&&xe!==null?Promise.resolve({diff:xe,submodule:ht}):G.getGitDiff(e,{path:s.path,staged:N,contextLines:lt}),Dt=Ne&&ke&&xe===null?G.getGitDiff(e,{path:s.path,staged:N,contextLines:mt}).then(Y=>Y.diff):Promise.resolve(xe),qt=Promise.all([pe,Dt]),He=Sr;let be;const ct=new Promise((Y,bt)=>{be=setTimeout(()=>bt(new Error(`Timed out after ${He}ms`)),He)});return Promise.race([qt,ct]).then(([Y,bt])=>{if(Q||ye!==we())return;const Te="diff"in Y&&!ke?Y.diff:bt;if(Ne&&ke&&Te!==null&&/^@@\s/m.test(Te)&&"diff"in Y&&Y.diff!==Te&&!vi(Y.diff,Te))throw Rt(null),new Error(P("diffView.hunk.unavailable"));if(Ne&&Te!==null&&Rt({scope:ot,patch:Te,submodule:Y.submodule}),"diff"in Y){const et={...Ct(s.path,Y.diff,De),submodule:Y.submodule};N?Je(et):We(et)}else{const et={original:Y.original??"",modified:Y.modified??"",isBinary:Y.isBinary,submodule:Y.submodule,contextMode:"full"};N?Je(et):(te(e,s.path,et,ye),We(et))}xt(Ye),re(!1)}).catch(Y=>{if(!(Q||ye!==we())){if(re(!1),Y instanceof sn){X({kind:"unavailable",reason:Y.reason}),Y.reason==="path_not_found"&&V(e,G,{force:!0,silent:!0});return}X({kind:"error",message:Y instanceof Error?Y.message:String(Y)})}}).finally(()=>clearTimeout(be)),()=>{Q=!0,clearTimeout(be),l.current===w&&(l.current=null)}},[xe,ht,ee,Ye,Ne,qe,ot,A,De,Fe,ae,z,e,V,s.path,rt,G,g,j,v,ke,W,te,N,P,a]);const Ke=i.useCallback(()=>{Ft(!j),Ot()},[Ft,Ot,j]),at=i.useCallback(()=>{X(null),Rt(null),We(null),Je(null),l.current=null,B(w=>w+1)},[]),Wt=Ji(),{confirm:$t}=Wt,Pe=i.useCallback(async(w,Q)=>{if(!e||!Ne||M||Z||ge.current||le!==null)return;const ye=xe?ji(xe,w):null;if(!ye){St.error(P("diffView.hunk.unavailable"));return}if(N&&Q!=="unstage"||!N&&Q==="unstage"||Q==="discard"&&!await $t({title:P("diffView.hunk.discardDialogTitle"),message:P("diffView.hunk.discardDescription",{path:s.path}),action:P("diffView.hunk.discard"),destructive:!0})||ge.current)return;ge.current=!0;const lt=we();oe({index:w,action:Q});try{const pe=Q==="stage"?G.stageGitHunk:Q==="unstage"?G.unstageGitHunk:G.revertGitHunk;if(!pe){St.error(P("diffView.hunk.unsupported"));return}if(await pe(e,s.path,ye),lt!==we())return;at(),gs.requestGitRefresh({directory:e,paths:[s.path]}),await V(e,G)}catch(pe){if(lt!==we())return;at(),St.error(pe instanceof Error&&pe.message?pe.message:P("diffView.hunk.unavailable"))}finally{ge.current=!1,oe(pe=>pe?.index===w&&pe.action===Q?null:pe)}},[xe,$t,Ne,M,Z,e,V,s.path,G,le,at,N,P]),yt=i.useMemo(()=>Ne&&xe!==null?ki(xe):[],[xe,Ne]),Ze=i.useCallback(w=>t.jsx(wr,{index:w,staged:N,busyHunk:le,disabled:M||!!Z,onAction:Pe}),[Z,Pe,le,M,N]),Ge=i.useMemo(()=>yt.length>0?{anchors:yt,render:Ze}:void 0,[yt,Ze]);return t.jsxs("div",{ref:_t,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:Ke,onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),Ke())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",C?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:j?t.jsx(q,{name:"arrow-down-s",className:"size-4"}):t.jsx(q,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Le.color},title:P(Le.descriptionKey),"aria-label":P(Le.descriptionKey),children:Le.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(an,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const w=s.path.lastIndexOf("/");if(w===-1)return t.jsx("span",{className:"oc-ui-start-align block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",unicodeBidi:"plaintext"},children:s.path});const Q=s.path.slice(0,w),ye=s.path.slice(w+1);return t.jsxs("span",{dir:"ltr",className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"oc-ui-start-align min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",unicodeBidi:"plaintext"},children:Q}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Rn(s.insertions,s.deletions),p&&R?t.jsx(ve,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:P("diffView.actions.openFileInEditorAtChange"),onClick:w=>{w.stopPropagation(),R(s.path,Fe)},disabled:m,children:m?t.jsx(q,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(q,{name:"edit",className:"size-3.5"})}):null,t.jsx(xs,{mode:pt?"side-by-side":"unified",onModeChange:w=>{const Q=w==="side-by-side"?"side-by-side":"inline";F(s.path,Q)},className:"opacity-70"})]})]})}),j&&t.jsxs("div",{className:"relative bg-background overflow-clip",children:[!v&&!Z?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,Z?.kind==="unavailable"&&Z.reason==="nested_repository"?t.jsx(Pr,{directory:Sn(e,s.path),revision:ee,renderSideBySide:pt,wrapLines:x,hideWhitespace:f,findKeyPrefix:s.path,registerViewerRef:ne,onFindWordRequest:h,findReveal:H}):null,Z?.kind==="unavailable"&&Z.reason!=="nested_repository"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:Z.reason==="untracked_directory"?P("diffView.unavailable.untrackedDirectoryTitle"):P("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:Z.reason==="untracked_directory"?P("diffView.unavailable.untrackedDirectoryDescription"):P("diffView.unavailable.missingDescription")}),Z.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:at,children:P("diffView.actions.retry")}):null]}):null,Z?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:P("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:Z.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?L?.():at(),children:P("diffView.actions.retry")})]}):null,v&&M&&!Fe&&!Z?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),P("diffView.state.loadingDiff")]}):null,v&&Fe&&!nt&&s.insertions+s.deletions>kn?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:P("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:P("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Mt(!0),children:P("diffView.actions.renderAnyway")})]}):null,v&&Fe&&(nt||s.insertions+s.deletions<=kn)?t.jsx(t.Fragment,{children:t.jsx(Ns,{filePath:s.path,diff:Fe,staged:N,renderSideBySide:pt,wrapLines:x,hideWhitespace:f,hunkActions:Ge,onExpandContextRequest:he?It:void 0,pendingContextExpansion:it,contextLoading:it!==null&&Fe.contextMode!=="full"&&!Z,viewerRef:$e,onFindWordRequest:zt})}):null]}),Wt.dialog]})}),ol=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:o=!1,showOpenInEditorAction:x=!1,diffScope:f="all",onDiffScopeChange:C,targetFilePath:j=null,flushContent:v=!1,directory:y=null})=>{const{t:d}=ze(),k=rr(),p=i.useRef(null);or(p);const[m,R]=i.useState([]),N=i.useCallback(n=>{if(!n)return;const r=p.current;R(["walkthrough","tree","wrap","whitespace","layout"].filter(c=>r?.hasAttribute(ar[c])??!1))},[]),{git:S,files:g,sourceControl:T}=on(),L=Pi(),J=!!y,K=y??L,fe=Re(n=>n.runtimeKey),{gitDirectory:ee,repositoryOptions:ne}=Mi(K??null,{enabled:a,recheckOnOpen:!0}),h=ee??K,O=Bi(h,T),H=ce(n=>n.openContextSurface),P=ce(n=>n.openContextPanelTab),G=Ii(n=>n.requestTarget),{screenWidth:U,isMobile:te}=_i(),V=zi(h??null),F=Oi(h??null),z=Wi(h??null),B=Re(n=>n.setActiveDirectory),W=Re(n=>n.ensureStatus),X=Re(n=>n.selectNestedRepo),de=Re(n=>n.fetchStatus),re=Re(n=>n.fetchBranches),ie=Re(n=>n.clearDiffCache),me=Re(n=>n.setDiff),[A,he]=i.useState(null),[Z,M]=i.useState(!1),[le,oe]=i.useState(null),[ge,Oe]=i.useState(()=>new Set),[Rt,nt]=i.useState(()=>new Set),[Mt,st]=i.useState(0),[We,Bt]=i.useState(()=>new Map),[Je,it]=i.useState(0),[It,ke]=i.useState(!1),[l,Qe]=i.useState(f??"working");i.useEffect(()=>{f!==null&&Qe(f)},[f]);const Le=ce(n=>n.pendingDiffFile),pt=ce(n=>n.pendingDiffStaged),De=ce(n=>n.pendingDiffScope),rt=ce(n=>n.setPendingDiffFile),Ne=ce(n=>n.diffLayoutPreference),ot=ce(n=>n.diffFileLayout),xe=ce(n=>n.setDiffLayoutForAllFiles),ht=ce(n=>n.diffWrapLines),Fe=ce(n=>n.setDiffWrapLines),ae=ce(n=>n.diffHideWhitespace),_t=ce(n=>n.setDiffHideWhitespace),$e=ce(n=>n.diffFileListMode),zt=ce(n=>n.setDiffFileListMode),Ft=ce(n=>n.openContextFileAtLine),Ot=hs(n=>n.currentSessionId),Ae=J?null:Ot,Ye=$i(l==="turn"?Ae??"":"",K??void 0),gt=ht,xt=l==="staged"?!0:l==="working"?!1:null,qe=xt??Z,Ke=te||U<=768,at=!!Ae&&l!=="turn"&&l!=="commit"&&l!=="pr"&&!Ke&&!Ie(),Wt=l!=="turn"&&!Ke&&!Ie(),$t=!e&&!Ke&&U>=1024,Pe=i.useRef(null),yt=i.useRef(null),Ze=i.useRef(new Map),Ge=i.useRef(null),w=i.useRef(null),Q=i.useRef(!1),ye=i.useRef(null),lt=i.useRef(null),pe=i.useRef(null),Dt=i.useRef(null),qt=i.useCallback(()=>{const n=Pe.current;if(!n)return null;const r=n.getBoundingClientRect().top,c=[];for(const[u,b]of Ze.current)b&&c.push({path:u,top:b.getBoundingClientRect().top});return as(r,c)},[]),He=i.useCallback(()=>{Ge.current=null,Q.current=!1,oe(null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),be=i.useCallback(n=>{Oe(r=>{if(r.has(n))return r;const c=new Set(r);return c.add(n),c})},[]),[ct,Y]=i.useState([]),[bt,Te]=i.useState(null),[et,Cs]=i.useReducer(n=>n+1,0);i.useEffect(()=>{Y([]),Te(null)},[Ae]);const Rs=Ye.length>0?Ye[Ye.length-1].id:"";i.useEffect(()=>{if(l!=="turn"||!Ae||!a)return;let n=!1;return pi.getSessionTurnDiff(Ae,{directory:K??void 0}).then(r=>{n||(Y(r.map(c=>({file:c.file,patch:c.patch,status:c.status,additions:c.additions,deletions:c.deletions}))),Te(null))}).catch(r=>{n||(console.warn("[diff-view] turn diff unavailable:",r instanceof Error?r.message:r),Te(r instanceof Error?r.message:d("diffView.state.failedToLoadDiff")))}),()=>{n=!0}},[l,Ae,Rs,K,d,et,a]);const Kt=i.useMemo(()=>{const n=new Map;for(const r of ct)if(r.file){if(typeof r.patch=="string"){n.set(r.file,Ct(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ct]),Fs=i.useMemo(()=>F?.files?F.files.filter(nn).length:0,[F]),Ds=i.useMemo(()=>F?.files?F.files.filter(tn).length:0,[F]),Ts=ct.length,ue=F?.current??null,Gt=O.contexts[0]?.provider==="github"||O.contexts[0]?.provider==="gitlab"?O.contexts[0]:null,Tt=os(n=>h?n.diffRequests.get(h):void 0),Se=hi(h??null,ue,Gt,a&&l==="pr"&&!Ie(),Tt),Ue=Se.selectedSource;i.useEffect(()=>{!h||!Tt||!F||Ue!==Tt||os.getState().settleDiffRequest(h,Tt)},[h,Tt,Ue,F]);const tt=gi(h??null,ue,a&&l==="commit"&&!Ie()),dt=tt.selectedCommit?.hash??null;i.useEffect(()=>{(l==="commit"||l==="pr")&&Ie()&&(Qe("working"),C?.("working"))},[l,C]);const cn=Re(n=>h?n.directories.get(h)?.branches??null:null),Es=Re(n=>h?n.directories.get(h)?.isLoadingBranches??!1:!1),Vs=i.useCallback(()=>{h&&re(h,S)},[h,re,S]),Ls=Ci(h??null,a&&V!==!1,Es,!!cn,Vs,Rr),As=ss(n=>n.setOverride),Ps=ss(n=>n.clearOverride),Ms=i.useMemo(()=>new Set(O.read?.repository.remotes.map(n=>n.name)??[]),[O.read]),{base:Ee,source:Bs,resolved:Fn,revision:dn}=xi(h??null,ue,a&&!Ie()&&V!==!1,{branches:cn,remoteNames:Ms,primaryRemote:O.contexts[0]?.primaryRemote,readContext:O.contexts[0]??null}),un=!Ie()&&Ri(ue,Ee);i.useEffect(()=>{f===null&&Qe(un?"branch":"working")},[f,un]);const Is=F!==null,Dn=Ie()||Ls||Fi(ue,Ee,Is,Fn&&O.status==="ready"),[_s,zs]=i.useState(0);i.useEffect(()=>{const n=Li(l,!Dn);n!==l&&(Qe(n),n==="working"&&f!==null&&C?.("working"))},[l,Dn,f,C]);const Os=i.useMemo(()=>l==="pr"?Ue:l==="commit"&&dt?{kind:"commit",hash:dt}:l==="branch"&&Ee&&ue?{kind:"branch",baseRef:Ee,headRef:ue}:null,[l,Ee,ue,dt,Ue]),se=Di(h??null,Os,a&&!Ie(),l==="branch"?dn:"",Se.readContext,Se.provider),{fetchDiff:Tn,fetchFullFile:En}=se,Vn=l==="commit"?se.files:null,Ln=l==="commit"?se.error:null,wt=l==="branch"?se.files:null,An=l==="branch"?se.error:null,Pn=se.files?l==="pr"?JSON.stringify([se.key,se.revision]):se.key:null,Ws=i.useMemo(()=>l==="branch"||l==="commit"||l==="pr"?Array.from(ge).sort().join("\0"):"",[l,ge]),Et=i.useCallback(async(n,r=!1)=>{try{const c=await Tn(n,r?en:mt);return{status:"ready",data:Ct(n,c.diff,r?"full":"patch")}}catch(c){return{status:"error",message:c instanceof Error?c.message:d("diffView.state.failedToLoadDiff")}}},[Tn,d]),Mn=i.useCallback(async n=>{try{const{original:r,modified:c}=await En(n),u=vs({name:n,contents:r},{name:n,contents:c});return{status:"ready",data:{original:r,modified:c,fileDiff:u,contextMode:"full"}}}catch(r){return{status:"error",message:r instanceof Error?r.message:d("diffView.state.failedToLoadDiff")}}},[En,d]),Ht=i.useMemo(()=>l==="branch"||l==="commit"?n=>Et(n,!0):l==="pr"?Mn:void 0,[l,Et,Mn]),$s=i.useMemo(()=>l==="branch"?Ti(wt,dn):void 0,[l,wt,dn]),Ut=Ei(Pn,a?Ws:"",Pn?Et:null,Nn,JSON.stringify([l==="pr"?se.revision:0,_s]),$s),qs=wt?.length??null,_=i.useMemo(()=>{if(l==="commit"||l==="pr")return(se.files??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:u.insertions,deletions:u.deletions,isNew:u.status==="A"}));if(l==="branch")return(wt??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:0,deletions:0,isNew:u.status==="A"})).sort((u,b)=>u.path.localeCompare(b.path));if(l==="turn")return ct.map(u=>({path:u.file??"",index:"",working_dir:Vi(u.status),insertions:u.additions??0,deletions:u.deletions??0,isNew:u.status==="added"})).filter(u=>u.path).sort((u,b)=>u.path.localeCompare(b.path));if(!F?.files)return[];const n=F.diffStats,r=l==="staged"?tn:l==="working"?nn:()=>!0,c=u=>{const b=n?.staged?.[u],E=n?.working?.[u];return l==="staged"?{insertions:b?.insertions??0,deletions:b?.deletions??0}:l==="working"?{insertions:E?.insertions??0,deletions:E?.deletions??0}:{insertions:(b?.insertions??0)+(E?.insertions??0),deletions:(b?.deletions??0)+(E?.deletions??0)}};return F.files.filter(r).map(u=>{const b=c(u.path);return{...u,insertions:b.insertions,deletions:b.deletions,isNew:ks(u)}}).sort((u,b)=>u.path.localeCompare(b.path))},[l,wt,se.files,ct,F]),fn=i.useMemo(()=>_.map(n=>n.path).join("\0"),[_]);i.useEffect(()=>{const n=fn?fn.split("\0"):[],r=new Set(n),c=`${h??""}:${l}:${s?"collapsed":"default"}`,u=lt.current!==c;lt.current=c,Oe(b=>{if(u){const $=s?0:Cr(n.length);return new Set(n.slice(0,$))}let E=!1;const D=new Set;for(const $ of b){if(!r.has($)){E=!0;continue}D.add($)}return E?D:b}),nt(b=>{if(u)return new Set;let E=!1;const D=new Set;for(const $ of b){if(!r.has($)){E=!0;continue}D.add($)}return E?D:b})},[l,fn,h,s]);const Bn=i.useCallback(()=>{if(ye.current=null,!a)return;const n=Pe.current;if(!n)return;const r=n.getBoundingClientRect(),c=r.top-cs,u=r.bottom+cs,b={},E=[];for(const[D,$]of Ze.current){if(!$)continue;const I=$.getBoundingClientRect();E.push({path:D,top:I.top}),ge.has(D)&&(I.bottom<c||I.top>u||(b[D]=!0))}pe.current=as(r.top,E),nt(D=>{let $=!1;const I=new Set(D);for(const Be of Object.keys(b))I.has(Be)||(I.add(Be),$=!0);return $?I:D})},[ge,a]),Me=i.useCallback(()=>{a&&(typeof window>"u"||ye.current===null&&(ye.current=window.requestAnimationFrame(Bn)))},[Bn,a]),mn=i.useRef(Me);mn.current=Me,i.useEffect(()=>{const n=Pe.current;if(!(!a||!n))return Me(),n.addEventListener("scroll",Me,{passive:!0}),window.addEventListener("resize",Me),()=>{n.removeEventListener("scroll",Me),window.removeEventListener("resize",Me),ye.current!==null&&(window.cancelAnimationFrame(ye.current),ye.current=null)}},[_,ge,Me,a]);const ut=i.useCallback(n=>{const r=ot[n.path];if(r)return r;if(Ne==="inline")return"inline";if(Ne==="side-by-side")return"side-by-side";const c=U<Nr;return n.isNew||c?"inline":"side-by-side"},[ot,Ne,U]),pn=i.useMemo(()=>_.length===0?null:_.every(n=>ut(n)==="side-by-side")?"side-by-side":"inline",[_,ut]);i.useEffect(()=>{a&&h&&(B(h),W(h,S))},[h,B,W,S,a]);const Xt=JSON.stringify([fe,h]),hn=i.useRef({scope:Xt,paths:new Set,dirty:!1,unscoped:!1}),In=i.useRef(a);i.useEffect(()=>{const n=a&&!In.current;if(In.current=a,hn.current.scope!==Xt&&(hn.current={scope:Xt,paths:new Set,dirty:!1,unscoped:!1}),!h)return;const r=(u,b)=>{u.length&&(Dt.current=qt()??pe.current,ie(h,u),Bt(E=>{const D=new Map(E);for(const $ of u)D.set($,(D.get($)??0)+1);return D})),b&&it(E=>E+1),de(h,S,{silent:!0})},c=hn.current;return a&&(n||c.dirty)&&(r([...c.paths],c.unscoped),c.paths.clear(),c.dirty=!1,c.unscoped=!1),gs.onGitRefreshHint(u=>{if(ts(u.directory)!==ts(h))return;const b=u.paths??[],E=b.length===0;if(!a){c.dirty=!0,c.unscoped||=E;for(const D of b)c.paths.add(D);return}r(b,E)})},[qt,ie,h,de,S,Xt,a]),i.useLayoutEffect(()=>{const n=Dt.current;if(!n)return;Dt.current=null;const r=Pe.current,c=Ze.current.get(n.path);if(!r||!c)return;const u=r.getBoundingClientRect().top,b=c.getBoundingClientRect().top-u;r.scrollTop=jr(r.scrollTop,n.topOffset,b,r.scrollHeight-r.clientHeight),pe.current=n},[We]),i.useEffect(()=>{!a||l!=="all"&&!De||Le&&(De&&Qe(De),he(Le),M(De==="staged"||!De&&pt),rt(null),Q.current=!0,Ge.current=Le,be(Le),st(n=>n+1))},[l,be,Le,De,pt,rt,a]),i.useEffect(()=>{if(l==="all")return;const n=j?.trim();n&&(he(n),M(l==="staged"),Q.current=!0,Ge.current=n,be(n),st(r=>r+1))},[l,be,j]),i.useEffect(()=>{if(!A)return;_.some(r=>r.path===A)||(he(null),M(!1))},[_,A]);const Ks=i.useCallback((n,r)=>{const c=Ze.current;r?c.set(n,r):c.delete(n),mn.current()},[]),Gs=i.useCallback((n,r)=>{He(),Oe(c=>{const u=c.has(n);if(r===u)return c;const b=new Set(c);return r?b.add(n):b.delete(n),b}),r||nt(c=>{if(!c.has(n))return c;const u=new Set(c);return u.delete(n),u}),mn.current()},[He]),Hs=i.useCallback(()=>{He(),Oe(n=>n.size>0?new Set:new Set(_.map(r=>r.path))),nt(new Set),Me()},[He,_,Me]),Us=i.useCallback(()=>ke(!1),[]),{submitting:gn,start:Xs}=qi(Ae,K,Us),vt=i.useCallback(n=>{const r=Ze.current.get(n),c=Pe.current;if(!r||!c)return!1;const u=r.getBoundingClientRect().top-c.getBoundingClientRect().top;return c.scrollTo({top:c.scrollTop+u,behavior:"auto"}),!0},[]),ft=i.useCallback(n=>xt!==null?xt:Z&&n===A,[A,Z,xt]);i.useEffect(()=>{const n=Ge.current;if(!a||!n)return;let r=0;const c=20;let u=!1;const b=(D=!0)=>{u||(u=!0,Ge.current=null,Q.current=!1,D&&oe(null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null))},E=()=>{if(u){w.current=null;return}const D=Ge.current;if(!D){b(),w.current=null;return}if(!vt(D)){r+=1,r<c?w.current=window.requestAnimationFrame(E):(b(),w.current=null);return}if(o&&Q.current){oe(D),b(!1);return}b()};return w.current=window.requestAnimationFrame(E),()=>{u=!0,w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)}},[o,Mt,vt,a]);const Js=i.useCallback(n=>{},[]),Ce=$e==="tree"&&!Ke,Qs=ce(n=>n.diffFileTreeWidth),Jt=ce(n=>n.setDiffFileTreeWidth),_n=i.useRef(null),[Ys,zn]=i.useState(!1),Vt=Math.max(Qs,jn),Qt=i.useCallback(n=>{const r=Math.max(jn,(_n.current?.clientWidth??0)*Er);return Math.min(r,Math.max(jn,n))},[]),Zs=i.useCallback(n=>{n.preventDefault();const r=n.clientX,c=Vt,u=ns(n.currentTarget)?-1:1;zn(!0);const b=D=>{Jt(Qt(c+(D.clientX-r)*u))},E=()=>{zn(!1),window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)};window.addEventListener("pointermove",b),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E)},[Qt,Vt,Jt]),ei=i.useCallback(n=>{const r=n.shiftKey?40:10,c=ns(n.currentTarget)?-1:1,u=(n.key==="ArrowLeft"?-r:n.key==="ArrowRight"?r:0)*c;u!==0&&(n.preventDefault(),Jt(Qt(Vt+u)))},[Qt,Vt,Jt]),xn=i.useMemo(()=>Ce?js(_,new Set).flatMap(n=>n.kind==="file"?[n.file]:[]):[],[_,Ce]),Lt=Ce?xn:_,jt=Ce?xn.find(n=>n.path===A)??xn[0]??null:null,Yt=jt?.path??null;i.useEffect(()=>{Yt&&!ge.has(Yt)&&be(Yt)},[be,ge,Yt]);const Zt=i.useCallback(n=>{if(He(),Ce){he(n),M(!1),be(n),Pe.current?.scrollTo({top:0});return}he(n),M(!1),Q.current=!0,Ge.current=n,be(n),st(r=>r+1),vt(n)},[He,be,Ce,vt]);i.useEffect(()=>{const n=r=>{if(!a||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const c=r.target;if(c instanceof HTMLElement&&(c.isContentEditable||c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.closest('[role="dialog"]'))||(r.preventDefault(),Lt.length===0))return;const u=r.key==="ArrowDown"?1:-1,b=Ce?jt?.path:A,E=b?Lt.findIndex(I=>I.path===b):-1,D=E===-1?u>0?0:Lt.length-1:E+u,$=Lt[D];$&&Zt($.path)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[A,Zt,Ce,Lt,jt,a]);const[kt,ti]=i.useState(()=>new Set),ni=i.useCallback((n,r)=>{ti(c=>{if(c.has(n)===r)return c;const u=new Set(c);return r?u.add(n):u.delete(n),u})},[]),On=i.useCallback(async(n,r,c)=>{if(!h)return null;const u=Sn(h,n),b=await S.getGitStatus(u,{fresh:!0});return{nestedSources:Ss(b).map(E=>({filePath:`${n}${E.path}`,layout:r,revision:c,load:async()=>{if(_e(E.path))return null;const D=tn(E)&&!nn(E),$=await S.getGitDiff(u,{path:E.path,staged:D,contextLines:mt}),I={...Ct(E.path,$.diff,"patch"),submodule:$.submodule};return At(Pt(E.path,I),ae)}}))}},[ae,h,S]),[Wn]=i.useState(kr),$n=i.useRef([]),qn=i.useCallback((n,r,c,u,b)=>{if(!S.getGitDiffs)return Promise.resolve(null);const E=$n.current.filter(D=>!_e(D.filePath)&&ft(D.filePath)===u&&kt.has(D.filePath)===b).map(D=>({filePath:D.filePath,revision:D.revision??""}));return Wn({directory:n,filePath:r,revision:c,staged:u,contextLines:b?en:mt,peers:E,getGitDiffs:(D,$)=>S.getGitDiffs?.(D,$)??Promise.resolve([])})},[kt,ft,S,Wn]),Kn=i.useCallback(async(n,r)=>{const c=n.path,u=kt.has(c);if(l==="turn"){const I=Kt.get(c);return At(I?Pt(c,I):null,ae)}if(l==="branch"||l==="commit"||l==="pr"){const I=Ut.get(c);if(!u&&I?.status==="ready")return At(Pt(c,I.data),ae);if(!u&&I?.status==="loading")return null;const Be=u&&Ht?await Ht(c):await Et(c);if(Be.status!=="ready")throw new Error(Be.status==="error"?Be.message:"Diff not loaded");return At(Pt(c,Be.data),ae)}if(!h||_e(c))return null;const b=ft(c),E=u?en:mt;let D;try{const I=await qn(h,c,r,b,u);if(I&&!I.ok&&I.reason)throw new sn(I.error,I.reason);D=I?.ok?I.diff:await S.getGitDiff(h,{path:c,staged:b,contextLines:E})}catch(I){if(!(I instanceof sn))throw I;return I.reason==="nested_repository"?On(c,ut(n),r):null}const $={...Ct(c,D.diff,u?"full":"patch"),submodule:D.submodule};return At(Pt(c,$),ae)},[l,Ut,ae,h,Et,kt,ft,ut,S,Kt,Ht,qn,On]),Gn=i.useRef(Kn);Gn.current=Kn;const yn=l==="branch"||l==="commit"||l==="pr"?Ut:null,bn=l==="turn"?Kt:null,Hn=l==="all"||l==="working"||l==="staged",Un=i.useMemo(()=>_.map(n=>{const r=yn?.get(n.path),c=yn?`${r?.status??"absent"}:${ms(r)}`:bn?ms(bn.get(n.path)):Hn?`${ft(n.path)?"staged":"unstaged"}:${Je+(We.get(n.path)??0)}`:"local",u=`${ae?"hide":"show"}|${kt.has(n.path)?"full":"patch"}|${c}`;return{filePath:n.path,layout:ut(n),revision:u,load:()=>Gn.current(n,u)}}),[_,ae,We,kt,yn,bn,Hn,ft,ut,Je]);$n.current=Un;const Ve=xr({sources:Un}),[wn,si]=i.useState(null),Xn=i.useRef(_);Xn.current=_;const ii=i.useCallback(n=>{const r=Xn.current.find(c=>ps(c.path,n.filePath))?.path??n.filePath;si(c=>({key:n.filePath,nonce:(c?.nonce??0)+1})),Ce&&r!==A&&(he(r),M(l==="staged")),be(r),vt(r)},[l,A,be,Ce,vt]),{registerViewer:ri,openOnWord:oi,focusNonce:ai}=yr({find:Ve,visible:a,rootRef:yt,reveal:ii}),Jn=i.useCallback(n=>{xe(n==="side-by-side"?"side-by-side":"inline")},[xe]),[li,Qn]=i.useState(null),Yn=i.useCallback(async(n,r)=>{if(!h||!n)return;Qn(n);const c=we();try{let u=null;if(r?.patch&&!r.isBinary&&!_e(n)?u=ls(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!_e(n)&&(u=ds(r.original,r.modified)),u===null)try{const I=await S.getGitDiff(h,{path:n,staged:qe,contextLines:3});u=ls(I.diff)}catch{u=null}let b=r;if(u===null||!b){const I=await S.getGitFileDiff(h,{path:n,staged:qe}),Be={original:I.original??"",modified:I.modified??"",isBinary:I.isBinary,submodule:I.submodule};b=Be,qe||me(h,n,Be,c)}const E=u??(b.isBinary||_e(n)?1:ds(b.original,b.modified)),D=Sn(h,n),$=await hr(g,D,{directory:h});if(!$.ok){St.error(gr($.reason));return}Ft(h,D,E,1)}finally{Qn(u=>u===n?null:u)}},[qe,h,g,S,Ft,me]),ci=i.useCallback((n,r)=>{Yn(n,r)},[Yn]),di=i.useCallback(()=>zs(n=>n+1),[]),ui=()=>{if(!h)return null;const n=(r,c=!1)=>{const u=c||ge.has(r.path);return t.jsx(Mr,{visible:a&&u,directory:h,file:r,layout:ut(r),wrapLines:gt,hideWhitespace:ae,isSelected:!1,isExpanded:u,isMounted:c||Rt.has(r.path)||r.path===le,onSelect:Js,onExpandedChange:Gs,registerSectionRef:Ks,registerViewerRef:ri,onFindWordRequest:oi,onFullContextChange:ni,findReveal:wn&&ps(r.path,wn.key)?wn:null,showOpenInEditorAction:x&&l!=="turn"&&!J,isOpeningInEditor:li===r.path,onOpenInEditor:ci,staged:ft(r.path),readOnlyActions:l==="branch"||l==="commit"||l==="pr",hunkActionsEnabled:l==="all"||l==="working"||l==="staged",contentRevision:Je+(We.get(r.path)??0),comparisonDiff:l==="branch"||l==="commit"||l==="pr"?Ut.get(r.path)??Nn:void 0,onRetryComparisonDiff:di,loadFullComparisonDiff:Ht,initialDiffData:l==="turn"?Kt.get(r.path)??null:null},`${we()}:${h}:${r.path}`)};return t.jsxs("div",{ref:_n,className:je("flex min-w-0 flex-1 min-h-0 h-full",v?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Ce&&t.jsxs(t.Fragment,{children:[t.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${Vt}px`},children:t.jsx(Vr,{changedFiles:_,selectedFile:jt?.path??null,onSelectFile:Zt})}),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":d("diffView.fileTree.resize"),tabIndex:0,onPointerDown:Zs,onKeyDown:ei,className:je("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-inset-s-1 before:-inset-e-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Ys&&"bg-interactive-selection")})]}),$t&&!Ce&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:d("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:_.length})]}),t.jsx(Tr,{changedFiles:_,selectedFile:null,onSelectFile:Zt})]}),t.jsxs("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:[Ve.isOpen&&t.jsx(br,{query:Ve.query,onQueryChange:Ve.setQuery,total:Ve.matches.length,currentIndex:Ve.currentIndex,isSearching:Ve.isSearching,failedCount:Ve.failedCount,onNext:Ve.next,onPrevious:Ve.previous,onClose:Ve.close,focusNonce:ai}),t.jsx(Cn,{ref:Pe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none] pb-16","data-diff-virtual-content":!0,children:Ce?jt&&n(jt,!0):_.map(r=>n(r))})})]})]})},fi=()=>{if(!h)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d("diffView.state.selectSessionDirectory")});if(l!=="turn"&&z&&!F)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingRepositoryStatus")]});if(l!=="turn"&&V===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d("diffView.state.notGitRepository")});if(l==="pr"){if(!Ue||se.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[!se.error&&!Se.error&&!Se.loading&&t.jsx(q,{name:"git-pull-request",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:se.error??Se.error??(Se.loading?d(rn("session.githubPrPicker.loading.pullRequests",Se.provider)):d(rn("pullRequestComparison.pickAbove",Se.provider)))}),(se.error||Se.error)&&t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>{Ue?se.refresh():Se.refresh()},children:d("diffView.actions.retry")})]});if(!se.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingDiff")]})}if(l==="commit"){if(Ln)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ln}),t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>{se.refresh()},children:d("diffView.actions.retry")})]});if(!dt&&!tt.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:tt.error??d("commitComparison.noCommits")});if(!Vn)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.state.loadingDiff")]})}if(l==="branch"){if(!Fn)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.branch.resolvingBase")]});if(!Ee)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(q,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:d("gitView.pr.toast.baseBranchRequired")})]});if(An)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:An}),t.jsx(ve,{variant:"outline",size:"sm",onClick:()=>{se.refresh()},children:d("diffView.actions.retry")})]});if(wt===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}),d("diffView.branch.loadingFiles")]})}return l==="turn"&&bt?t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-4 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:d("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta max-w-[32rem] text-center",children:bt}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>{Te(null),Cs()},children:d("diffView.actions.retry")})]}):_.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l==="turn"?d("diffView.state.noLastTurnChanges"):l==="pr"?d("walkthrough.blocked.emptyDiff.description"):l==="commit"?d("commitComparison.emptyDiff"):l==="branch"&&Ee?d("diffView.branch.empty",{base:ur(Ee)}):d("diffView.state.cleanWorkingTree")}):ui()},Zn=_.length>0&&Wt&&(l!=="pr"||!!Gt),es=()=>{const n=h??"";G(n,l==="pr"&&Ue&&Gt?{source:Ue,context:Gt}:{source:l==="commit"&&dt?{kind:"commit",hash:dt}:l==="branch"&&Ee&&ue?{kind:"branch",baseRef:Ee,headRef:ue}:{kind:"working-tree",scope:l==="staged"||l==="working"?l:"all"}}),J&&L?P(L,{mode:"walkthrough",targetDirectory:K}):H(K??n,"walkthrough")},mi=n=>{switch(n){case"walkthrough":return Zn?{label:d("walkthrough.action.open"),icon:t.jsx(q,{name:"route",className:"size-4"}),on:!1,select:es}:null;case"tree":return Ke?null:{label:d("diffView.fileTree.showAsTree"),icon:t.jsx(q,{name:"node-tree",className:"size-4"}),on:$e==="tree",select:()=>zt($e==="tree"?"flat":"tree")};case"wrap":return{label:d("diffView.actions.wrapLines"),icon:t.jsx(q,{name:"text-wrap",className:"size-4"}),on:gt,select:()=>Fe(!ht)};case"whitespace":return{label:d("diffView.actions.hideWhitespace"),icon:t.jsx(is,{hidden:ae,className:"size-4"}),on:ae,select:()=>_t(!ae)};case"layout":{const r=pn==="side-by-side";return{label:d("diffView.layout.sideBySide"),icon:t.jsx(q,{name:"layout-column",className:"size-4"}),on:r,select:()=>Jn(r?"unified":"side-by-side")}}}};return t.jsxs("div",{ref:yt,"data-find-surface":"",className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsx(lr,{children:t.jsxs("div",{ref:p,className:je("flex min-w-0 items-center gap-2",k?"flex-1 py-1 pe-1":"px-3 py-2 bg-background"),children:[ne?t.jsx(cr,{repositories:ne,selectedRepository:ee??null,onSelectRepository:n=>{K&&X(K,n)},repositoryRoot:K??void 0}):null,!te&&!J&&(l!=="all"?t.jsx(Dr,{scope:l,workingCount:Fs,stagedCount:Ds,turnCount:Ts,branchCount:qs,commitCount:l==="commit"?Vn?.length??null:null,prCount:l==="pr"?se.files?.length??null:null,showCommitOption:!Ie(),showBranchOption:un,changeRequestProvider:Se.provider,onScopeChange:n=>{Qe(n),C?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:z&&!F?d("diffView.state.loadingChanges"):_.length===1?d("diffView.summary.changedFilesSingle",{count:_.length}):d("diffView.summary.changedFilesPlural",{count:_.length})})})),l==="branch"&&t.jsx(yi,{branches:cn?.all??[],currentBranch:ue,base:Ee,automatic:Bs!=="chosen",onSelect:n=>{h&&ue&&As(h,ue,n)},onSelectAutomatic:()=>{h&&ue&&Ps(h,ue)}},JSON.stringify([h,ue])),l==="commit"&&t.jsx(bi,{commits:tt.commits,selectedHash:dt,loading:tt.loading,error:tt.error,onSelect:tt.select,onRefresh:()=>{tt.refresh()}},JSON.stringify([h,ue])),l==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(wi,{comparison:Se},JSON.stringify([fe,h,ue])),Ue&&t.jsx(ve,{variant:"ghost",size:"sm",disabled:se.loading,"aria-label":d("session.githubIssuePicker.actions.refresh"),title:d("session.githubIssuePicker.actions.refresh"),onClick:()=>{se.refresh()},children:t.jsx(q,{name:"refresh",className:"size-4"})})]}),_.length>0&&t.jsxs(ve,{variant:"ghost",size:"sm",onClick:Hs,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ms-auto"),title:ge.size>0?d("diffView.actions.collapseAll"):d("diffView.actions.expandAll"),children:[t.jsx(q,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:ge.size>0?d("diffView.actions.collapseAll"):d("diffView.actions.expandAll")})]}),_.length>0&&at&&t.jsxs(ve,{variant:"default",size:"sm",onClick:()=>ke(!0),disabled:gn,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":d("diffView.actions.reviewAria"),children:[gn?t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(q,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:d("diffView.actions.review")})]}),Zn&&t.jsxs(ve,{variant:"outline",size:"sm",onClick:es,className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",dr),"aria-label":d("walkthrough.action.open"),children:[t.jsx(q,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:d("walkthrough.action.open")})]}),_.length>0&&!Ke&&t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>zt($e==="tree"?"flat":"tree"),"aria-pressed":$e==="tree",className:je("diff-toolbar__tree-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",$e==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d($e==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:t.jsx(q,{name:"node-tree",className:"size-4"})}),_.length>0&&t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>Fe(!ht),className:je("diff-toolbar__wrap-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",gt?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d(gt?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(q,{name:"text-wrap",className:"size-4"})}),_.length>0&&t.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>_t(!ae),"aria-pressed":ae,className:je("diff-toolbar__whitespace-toggle h-5 w-5 flex-shrink-0 p-0 transition-opacity",ae?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:d(ae?"diffView.whitespace.hidden":"diffView.whitespace.shown"),"aria-label":d("diffView.actions.hideWhitespace"),children:t.jsx(is,{hidden:ae,className:"size-4"})}),pn&&t.jsx(xs,{mode:pn==="side-by-side"?"side-by-side":"unified",onModeChange:Jn,className:"diff-toolbar__layout-toggle flex-shrink-0"}),_.length>0&&t.jsxs(ys,{onOpenChange:N,children:[t.jsxs(Ki,{children:[t.jsx(Gi,{asChild:!0,children:t.jsx("span",{className:"diff-toolbar__more flex-shrink-0",children:t.jsx(bs,{asChild:!0,children:t.jsx(ve,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":d("diffView.actions.moreActions"),children:t.jsx(q,{name:"more",className:"size-4"})})})})}),t.jsx(Hi,{side:"bottom",sideOffset:6,children:d("diffView.actions.moreActions")})]}),t.jsx(ws,{align:"end",className:"min-w-56",children:m.map(n=>{const r=mi(n);return r?t.jsxs(Ui,{className:"flex items-center gap-2",onClick:r.select,children:[r.icon,t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:r.label}),r.on?t.jsx(q,{name:"check",className:"ms-auto size-4 text-foreground"}):null]},n):null})})]})]})}),t.jsx(Xi,{open:It,onOpenChange:ke,projectDirectory:h??null,submitting:gn,onConfirm:Xs}),fi()]})};function Br(){return new Set}function Ir(a){return{original:a.original??"",modified:a.modified??"",isBinary:a.isBinary,submodule:a.submodule,contextMode:"full"}}function _r(a){return a.addProject}function zr(a){return a.openNewSessionDraft}function Or(){return new Set}function Wr(a){return a+1}export{ol as DiffView,Mr as MultiFileDiffEntry};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as r,j as n,f as we,r as Mt,c as nu}from"./vendor-react-BUCujlKS.js";import{aK as su,k as hr,ae as Jo,b6 as ru,av as iu,b7 as au,b8 as ou,ap as lu,at as cu,ao as Oe,a5 as tt,u as Be,b9 as uu,b5 as pr,t as vo,ba as wo,bb as ui,bc as du,bd as fu,b4 as Zo,b3 as mu,be as hu,ac as pu,bf as gu,bg as _t,bh as vu}from"./katex.min-u4DtE8E5.js";import{u as $e,y as xs,B as I,N as q,az as wu,ay as xu,as as bu,at as yu,av as ju,I as E,gh as Nu,gi as yi,gj as Su,bl as Ni,bm as Cu,gk as Fu,ef as ku,gl as Eu,dp as Bn,el as gr,gm as Ru,gn as Tu,b7 as Mu,aG as Pu,aF as Vu,aE as Du,fZ as zu,aD as di,b5 as Lu,d8 as Au,A as H,fD as Iu,fC as Ou,aa as xo,go as Bu,aI as $u,dr as Wu,gp as cr,a1 as bo,bT as fi,gq as ps,P as Uu,a5 as Ku,gr as gs,dD as _u,gs as mi,gt as yo,gu as jo,gv as No,gw as So,gx as Gu,gy as Hu,gz as qu,df as Xu,gA as Yu,aK as Ju,gB as Zu,dq as Co,gC as Qu,t as Qo,q as el,D as tl,l as nl,F as sl,o as rl,aR as vr,aS as wr,aT as xr,aU as On,n as hi,aV as ur,aW as pi,V as Gt,W as Ht,X as qt,es as il,am as ed,ap as td,bg as al,gD as nd,gE as sd,gF as rd,ep as ol,eo as ll,aA as br,eq as id,gG as ad,gH as od,gI as ld,gJ as cd,gK as ud,gL as dd,gM as fd,gN as md}from"./useAppFontEffects-DAUhSLPu.js";import{s as hd,c as Fo,P as Ln,C as pd}from"./flexokiTheme-BG4cSAMb.js";import{a as cl,E as gd,i as ul,S as dl,R as ji,l as vd}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as nt,k as Si,f as wd,j as xd,m as bd,g as yd,V as jd,G as Nd}from"./vendor-codemirror-view-B66jUSmE.js";import{v as Sd,z as Cd,A as Fd,B as kd}from"./vendor-codemirror-language-DyL0aCoH.js";import{D as Ed,a as Rd,m as Td,b as Md,G as Pd}from"./moveWorkspacePath-CVdEBQ6v.js";import{a9 as Vd,$ as Dd,aa as zd,ab as Ld,Q as Ad}from"./runtimeEndpointReset-D7viEboD.js";import{c as Id,b as Od,u as ko,F as Eo}from"./useMarkdownLocalAssets-CnMxnDdI.js";import{V as Bd,J as $d,F as Wd}from"./JsonTreeView-BwELoub1.js";import{s as Ud}from"./shikiHighlight-CLj7Oan9.js";import{ensurePierreThemeRegistered as Ro,getResolvedShikiTheme as Kd}from"./appThemeRegistry-CDGE1wtP.js";import{V as _d,W as Gd}from"./Virtualizer-BP6uuKe_.js";import{V as Hd}from"./Virtualizer-Cmng0Q1E.js";import{D as qd}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as Xd,h as Yd}from"./vendor-codemirror-search-BKAwkhkm.js";import{a as Jd,b as Zd}from"./vendor-codemirror-autocomplete-CIqXJolH.js";import{p as Qd}from"./parseDiffFromFile-DWemyyqU.js";import{o as ef,s as tf}from"./vendor-zod-DDir2TeQ.js";import{u as nf,n as sf}from"./useInlineCommentController-bYCeqE6r.js";import{c as rf}from"./scheduledTasksApi-FZ9stPNl.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-streamparser-CmlTsbN2.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-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-BgqasG86.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-D7rclQrA.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./textMateThemeFromAppTheme-C-jxkZJj.js";import"./vendor-diff-C3JhlQdm.js";const af=(i,e)=>{if(!e)return null;const a=Number.parseInt(i.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,e.state.doc.lines)},To=(i,e)=>{const a=i.state.doc.lineAt(e.main.head);return{lineNumber:a.number,character:e.main.head-a.from+1,selection:e}},Mo=(i,e,a)=>{const s=i.state.doc.line(e),c=Math.max(1,Math.min(a,s.length+1)),d=s.from+c-1;i.dispatch({selection:cl.cursor(d),effects:nt.scrollIntoView(d,{y:"center"})})};function of({open:i,onOpenChange:e,viewRef:a,variant:s="overlay"}){const{t:c}=$e(),d=a.current,[g,f]=r.useState(""),p=r.useRef(null),j=r.useRef(!1),v=r.useRef(null),w=r.useRef(null),b=r.useMemo(()=>af(g,d),[g,d]);r.useEffect(()=>{!i||!d||(j.current=!1,p.current=To(d,d.state.selection),f(""))},[i,d]),r.useEffect(()=>{i&&window.requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()})},[i]),r.useEffect(()=>{if(!(!i||!d||!p.current)){if(b===null){const{selection:C}=p.current;d.dispatch({selection:C,effects:nt.scrollIntoView(C.main.from,{y:"center"})});return}Mo(d,b,p.current.character)}},[b,i,d]);const N=r.useCallback(()=>{if(!d||j.current||!p.current)return;const{selection:C}=p.current;d.dispatch({selection:C,effects:nt.scrollIntoView(C.main.from,{y:"center"})})},[d]),R=r.useRef(i);r.useEffect(()=>{R.current&&!i&&N(),R.current=i},[i,N]);const S=r.useCallback(C=>{C||N(),e(C)},[e,N]),F=r.useCallback(()=>{!d||b===null||!p.current||(j.current=!0,Mo(d,b,p.current.character),e(!1),d.focus())},[b,e,d]);r.useEffect(()=>{if(!i)return;const C=D=>{const h=v.current,O=D.target;!h||!(O instanceof Element)||h.contains(O)||O.closest("[data-go-to-line-toggle]")||S(!1)},V=D=>{D.key==="Escape"&&(D.preventDefault(),S(!1))};return document.addEventListener("pointerdown",C,!0),document.addEventListener("keydown",V,!0),()=>{document.removeEventListener("pointerdown",C,!0),document.removeEventListener("keydown",V,!0)}},[S,i,s]);const T=r.useMemo(()=>{if(!d)return c("goToLineDialog.helper.editorUnavailable");if(b===null){const C=p.current??To(d,d.state.selection);return c("goToLineDialog.helper.currentLineRange",{current:C.lineNumber,max:d.state.doc.lines})}return c("goToLineDialog.helper.goToLine",{line:b})},[b,c,d]);return s==="inline"?i?n.jsxs("div",{ref:v,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[n.jsx(xs,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),F())},placeholder:c("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:F,disabled:!d||b===null,className:"h-6 px-2",children:c("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:v,"data-editor-overlay":!0,className:q("absolute inset-s-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",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(xs,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),F())},placeholder:c("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const lf=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),cf=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),uf=new Set(["ArrowFunction","FunctionExpression"]),df=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),fl=/^(?:ATXHeading|SetextHeading)([1-6])$/,ml=(i,e)=>{for(let a=i.firstChild;a;a=a.nextSibling)if(e.has(a.name))return a;return null},ff=i=>{if(fl.test(i.name))return"heading";const e=lf.get(i.name);if(e)return e;const a=cf.get(i.name);return a&&ml(i,uf)?a:null},mf=(i,e)=>i.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),hf=(i,e=200)=>{const a=Sd(i,i.doc.length,e);if(!a)return[];const s=[],c=[];return a.iterate({enter:d=>{const g=ff(d.node);if(!g)return;let f,p;if(g==="heading")f=mf(i,d.node),p=d.from;else{const v=ml(d.node,df);if(!v)return;f=i.sliceDoc(v.from,v.to),p=v.from}if(!f)return;for(;c.length>0&&c[c.length-1]<=d.from;)c.pop();const j=g==="heading"?Number(fl.exec(d.name)?.[1]??1)-1:c.length;s.push({name:f,kind:g,line:i.doc.lineAt(p).number,from:p,depth:j}),g!=="heading"&&c.push(d.to)}}),s},pf={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},gf="data-document-symbols-toggle";function Po({open:i,onOpenChange:e,viewRef:a}){const{t:s}=$e(),c=a.current,d=r.useRef(null),[g,f]=r.useState([]),[p,j]=r.useState("");r.useEffect(()=>{i&&(j(""),f(c?hf(c.state):[]))},[i,c]);const v=r.useCallback(()=>{e(!1),c?.focus()},[e,c]);r.useEffect(()=>{if(!i)return;const b=N=>{const R=N.target;!(R instanceof Element)||!d.current||d.current.contains(R)||R.closest(`[${gf}]`)||e(!1)};return document.addEventListener("pointerdown",b,!0),()=>document.removeEventListener("pointerdown",b,!0)},[e,i]);const w=r.useCallback(b=>{c&&c.dispatch({selection:cl.cursor(b.from),effects:nt.scrollIntoView(b.from,{y:"center"})}),v()},[v,c]);return i?n.jsx("div",{ref:d,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),v())},children:n.jsxs(wu,{loop:!0,filter:(b,N)=>b.split("\0")[0].toLowerCase().includes(N.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[n.jsx(xu,{autoFocus:!0,value:p,onValueChange:j,placeholder:s("filesView.symbols.placeholder"),"aria-label":s("filesView.symbols.placeholder")}),n.jsxs(bu,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[n.jsx(yu,{className:"px-3 py-4 typography-meta text-muted-foreground",children:g.length===0?s("filesView.symbols.noneInFile"):s("filesView.symbols.noMatches")}),g.map(b=>n.jsxs(ju,{value:`${b.name}\0${b.from}`,onSelect:()=>w(b),className:"gap-2",children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${b.depth*12}px`},children:[n.jsx(E,{name:pf[b.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-foreground",children:b.name})]}),n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:b.line})]},`${b.from}:${b.name}`))]})]})}):null}const vf=(i,e)=>{const a=e.trim().toLowerCase(),s=[];if(!a)return s;const c=i.toLowerCase();let d=0;for(;;){const g=c.indexOf(a,d);if(g===-1)break;s.push({start:g,end:g+a.length}),d=g+a.length}return s},jr="data-md-find",gi="data-md-find-current",hl="rounded-[2px] bg-status-warning/30 text-foreground",wf="rounded-[2px] bg-status-warning/60 text-foreground",xf=120,bf=i=>i instanceof Element&&i.hasAttribute(jr),yf=i=>i.target instanceof Element&&i.target.hasAttribute(jr)?!0:[...i.addedNodes].some(e=>bf(e)),pl=i=>{const e=new Set;i.querySelectorAll(`mark[${jr}]`).forEach(a=>{const s=a.parentNode;s&&(s.replaceChild(document.createTextNode(a.textContent??""),a),e.add(s))}),e.forEach(a=>a.normalize())},jf=(i,e)=>{pl(i);const a=e.trim().toLowerCase();if(!a)return[];const s=[],c=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(g){const f=g.parentElement;return!f||f.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),d=[];for(;c.nextNode();){const g=c.currentNode;g instanceof Text&&d.push(g)}for(const g of d){const f=g.nodeValue??"";if(!f)continue;const p=vf(f,a);if(p.length===0)continue;const j=g.parentNode;if(!j)continue;const v=document.createDocumentFragment();let w=0;for(const b of p){b.start>w&&v.appendChild(document.createTextNode(f.slice(w,b.start)));const N=document.createElement("mark");N.setAttribute(jr,""),N.className=hl,N.textContent=f.slice(b.start,b.end),v.appendChild(N),s.push(N),w=b.end}w<f.length&&v.appendChild(document.createTextNode(f.slice(w))),j.replaceChild(v,g)}return s},Vo=({containerRef:i,open:e,onOpenChange:a,focusNonce:s,className:c})=>{const{t:d}=$e(),[g,f]=r.useState(""),[p,j]=r.useState(0),[v,w]=r.useState(0),b=r.useRef(null),N=r.useRef([]),R=r.useRef(g);R.current=g;const S=r.useRef(null),F=r.useRef(null),T=r.useCallback((M,B=!1)=>{const A=i.current;if(!A){N.current=[],j(0),w(0);return}N.current=jf(A,M);const $=N.current.length;j($),w(re=>!B||$===0?0:Math.min(re,$-1))},[i]),C=r.useCallback((M,B=!1)=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,T(M,B)},xf)},[T]);r.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const V=r.useCallback(()=>{a(!1);const M=F.current;F.current=null,M?.isConnected&&M.focus()},[a]);r.useEffect(()=>{const M=i.current;if(!e||!M)return;const B=new MutationObserver(A=>{!R.current.trim()||!A.some(re=>!yf(re))||C(R.current,!0)});return B.observe(M,{childList:!0,subtree:!0,characterData:!0}),()=>{B.disconnect(),pl(M)}},[i,e,C]),r.useEffect(()=>{if(!e)return;const M=document.activeElement;M instanceof HTMLElement&&!F.current&&(F.current=M),b.current?.focus()},[e]),r.useEffect(()=>{e&&s>0&&(b.current?.focus(),b.current?.select())},[e,s]),r.useEffect(()=>{const M=i.current;if(!M||(M.querySelectorAll(`mark[${gi}]`).forEach(A=>{A.removeAttribute(gi),A.className=hl}),p===0))return;const B=N.current[Math.min(Math.max(v,0),p-1)];B&&(B.setAttribute(gi,""),B.className=wf,B.scrollIntoView({block:"nearest"}))},[i,v,p]);const D=r.useCallback(()=>{w(M=>p===0?0:(M+1)%p)},[p]),h=r.useCallback(()=>{w(M=>p===0?0:(M-1+p)%p)},[p]),O=r.useCallback(M=>{M.key==="Enter"?(M.preventDefault(),M.shiftKey?h():D()):M.key==="Escape"&&(M.preventDefault(),V())},[V,D,h]);return e?n.jsxs("div",{className:q("absolute inset-e-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",c),children:[n.jsx(E,{name:"search",className:"ms-0.5 size-3.5 text-muted-foreground"}),n.jsx(xs,{ref:b,value:g,onChange:M=>{f(M.target.value),C(M.target.value)},onKeyDown:O,placeholder:d("filesView.preview.find.placeholder"),"aria-label":d("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":p>0?d("filesView.preview.find.countAria",{current:v+1,total:p}):d("filesView.preview.find.noMatches"),children:g.trim()&&p===0?d("filesView.preview.find.noMatches"):p>0?`${v+1}/${p}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:h,title:d("filesView.preview.find.previousAria"),"aria-label":d("filesView.preview.find.previousAria"),disabled:p===0,children:n.jsx(E,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:d("filesView.preview.find.nextAria"),"aria-label":d("filesView.preview.find.nextAria"),disabled:p===0,children:n.jsx(E,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:d("filesView.preview.find.closeAria"),"aria-label":d("filesView.preview.find.closeAria"),children:n.jsx(E,{name:"close",className:"size-3.5"})})]}):null},Nf=1,Do=({stat:i,showsFailure:e,sawMissing:a,hasUnsavedChanges:s,moving:c})=>i==="missing"?s||c?"none":"show-missing":i==="failed"?"none":e?a?"reload":"none":"check-changes",Sf=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=Nf,Cf=({selectedPath:i,targetPath:e,targetShown:a,targetSettled:s,showsText:c,canEdit:d,textViewMode:g})=>i!==e?a?"wait":"select-target":s?c?g==="edit"?"jump":d?"show-editor":"end":"end":"wait";function zo(){const i=we.c(8),[e]=Mt.useState(Ff),a=Mt.useRef(!1);let s;i[0]!==e?(s=p=>{if(p==null){e.cleanUp(),a.current=!1;return}a.current||(a.current=!0,e.setup(p,p.firstElementChild??void 0))},i[0]=e,i[1]=s):s=i[1];const c=s;let d,g;i[2]!==e?(d=()=>()=>{a.current=!1,e.cleanUp()},g=[e],i[2]=e,i[3]=d,i[4]=g):(d=i[3],g=i[4]),Mt.useLayoutEffect(d,g);let f;return i[5]!==c||i[6]!==e?(f={virtualizer:e,setScroller:c},i[5]=c,i[6]=e,i[7]=f):f=i[7],f}function Ff(){return new Hd}const An=new Map,kf=100;function dr(i){const[e,a]=Mt.useState(null),s=Mt.useRef(null),c=Mt.useRef(null),d=Mt.useRef(null),g=Mt.useCallback((f,p)=>{f&&p instanceof Bd&&(d.current={key:i,file:p,node:f});const j=s.current,v=c.current,w=()=>{s.current===j&&(j?.(),v?.())};p?queueMicrotask(w):w()},[i]);return Mt.useLayoutEffect(()=>{if(!e||!i)return;const f=An.get(i)??{top:0,left:0};let p=!0;const j=()=>d.current?.key===i?d.current.file:null,v=T=>d.current?.key===i?d.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${T-1}"]`):null,w=()=>{N.disconnect(),R.disconnect()},b=()=>{if(!p)return;const T=j(),C=f.line&&T?.getLinePosition(f.line.number),V=f.line&&v(f.line.number);let D=f.top;f.line&&C&&(D=(T?.top??0)+C.top-f.line.offset),f.line&&V&&(D=e.scrollTop+V.getBoundingClientRect().top-e.getBoundingClientRect().top-f.line.offset),e.scrollTop=D,e.scrollLeft=f.left,(!f.line||V)&&Math.abs(e.scrollTop-D)<1&&Math.abs(e.scrollLeft-f.left)<1&&(p=!1,w())},N=new ResizeObserver(b),R=new MutationObserver(()=>{if(p){for(const T of e.children)N.observe(T);b()}});N.observe(e);for(const T of e.children)N.observe(T);R.observe(e,{childList:!0,subtree:!0});const S=()=>{if(p)return;const T=j(),C=T?.getNumericScrollAnchor(e.scrollTop-(T.top??0)),V=C&&v(C.lineNumber),D=V?V.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(An.delete(i),An.set(i,{top:e.scrollTop,left:e.scrollLeft,line:C&&D!==null&&D>=0&&D<e.clientHeight?{number:C.lineNumber,offset:D}:void 0}),An.size>kf){const h=An.keys().next().value;h!==void 0&&An.delete(h)}},F=()=>{p=!1,w()};return s.current=b,c.current=S,b(),e.addEventListener("scroll",S,{passive:!0}),e.addEventListener("wheel",F,{passive:!0}),e.addEventListener("touchstart",F,{passive:!0}),e.addEventListener("pointerdown",F,{passive:!0}),e.addEventListener("keydown",F),()=>{s.current=null,c.current=null,d.current?.key===i&&(d.current=null),w(),e.removeEventListener("scroll",S),e.removeEventListener("wheel",F),e.removeEventListener("touchstart",F),e.removeEventListener("pointerdown",F),e.removeEventListener("keydown",F)}},[i,e]),{setScroller:a,restore:g}}function Ef(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||i.wouldEmptyFile||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function Rf(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const gl=2e5,Tf=i=>{let e=0,a=0;for(let s=0;s<i.length;s++)i.charCodeAt(s)===10&&(s>0&&i.charCodeAt(s-1)===13?e++:a++);return e>a?`\r
|
|
1
|
+
import{R as r,j as n,f as we,r as Mt,c as nu}from"./vendor-react-BUCujlKS.js";import{aK as su,k as hr,ae as Jo,b6 as ru,av as iu,b7 as au,b8 as ou,ap as lu,at as cu,ao as Oe,a5 as tt,u as Be,b9 as uu,b5 as pr,t as vo,ba as wo,bb as ui,bc as du,bd as fu,b4 as Zo,b3 as mu,be as hu,ac as pu,bf as gu,bg as _t,bh as vu}from"./katex.min-F4TD1ekM.js";import{u as $e,y as xs,B as I,N as q,az as wu,ay as xu,as as bu,at as yu,av as ju,I as E,gi as Nu,gj as yi,gk as Su,bl as Ni,bm as Cu,gl as Fu,eg as ku,gm as Eu,dq as Bn,em as gr,gn as Ru,go as Tu,b7 as Mu,aG as Pu,aF as Vu,aE as Du,f_ as zu,aD as di,b5 as Lu,d9 as Au,A as H,fE as Iu,fD as Ou,aa as xo,gp as Bu,aI as $u,ds as Wu,gq as cr,a1 as bo,bU as fi,gr as ps,P as Uu,a5 as Ku,gs,dE as _u,gt as mi,gu as yo,gv as jo,gw as No,gx as So,gy as Gu,gz as Hu,gA as qu,dg as Xu,gB as Yu,aK as Ju,gC as Zu,dr as Co,gD as Qu,t as Qo,q as el,D as tl,l as nl,F as sl,o as rl,aR as vr,aS as wr,aT as xr,aU as On,n as hi,aV as ur,aW as pi,V as Gt,W as Ht,X as qt,et as il,am as ed,ap as td,bg as al,gE as nd,gF as sd,gG as rd,eq as ol,ep as ll,aA as br,er as id,gH as ad,gI as od,gJ as ld,gK as cd,gL as ud,gM as dd,gN as fd,gO as md}from"./useAppFontEffects-Dm6zEvrf.js";import{s as hd,c as Fo,P as Ln,C as pd}from"./flexokiTheme-PoX6Vqyn.js";import{a as cl,E as gd,i as ul,S as dl,R as ji,l as vd}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as nt,k as Si,f as wd,j as xd,m as bd,g as yd,V as jd,G as Nd}from"./vendor-codemirror-view-B66jUSmE.js";import{v as Sd,z as Cd,A as Fd,B as kd}from"./vendor-codemirror-language-DyL0aCoH.js";import{D as Ed,a as Rd,m as Td,b as Md,G as Pd}from"./moveWorkspacePath-CENAo75W.js";import{a9 as Vd,$ as Dd,aa as zd,ab as Ld,Q as Ad}from"./runtimeEndpointReset-lg1O2gVX.js";import{c as Id,b as Od,u as ko,F as Eo}from"./useMarkdownLocalAssets-BEApAshz.js";import{V as Bd,J as $d,F as Wd}from"./JsonTreeView-BpJU14WJ.js";import{s as Ud}from"./shikiHighlight-DBj_a_TN.js";import{ensurePierreThemeRegistered as Ro,getResolvedShikiTheme as Kd}from"./appThemeRegistry-BWap7OfW.js";import{V as _d,W as Gd}from"./Virtualizer-BP6uuKe_.js";import{V as Hd}from"./Virtualizer-nenVQKi3.js";import{D as qd}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as Xd,h as Yd}from"./vendor-codemirror-search-BKAwkhkm.js";import{a as Jd,b as Zd}from"./vendor-codemirror-autocomplete-CIqXJolH.js";import{p as Qd}from"./parseDiffFromFile-BSmRvd3V.js";import{o as ef,s as tf}from"./vendor-zod-DDir2TeQ.js";import{u as nf,n as sf}from"./useInlineCommentController-a2JepiF3.js";import{c as rf}from"./scheduledTasksApi-CJBNpwgy.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-streamparser-CmlTsbN2.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-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-VzNDjH03.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-DDyA16hp.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-Dpm-_Qu8.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./textMateThemeFromAppTheme-tYpAceV3.js";import"./vendor-diff-C3JhlQdm.js";const af=(i,e)=>{if(!e)return null;const a=Number.parseInt(i.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,e.state.doc.lines)},To=(i,e)=>{const a=i.state.doc.lineAt(e.main.head);return{lineNumber:a.number,character:e.main.head-a.from+1,selection:e}},Mo=(i,e,a)=>{const s=i.state.doc.line(e),c=Math.max(1,Math.min(a,s.length+1)),d=s.from+c-1;i.dispatch({selection:cl.cursor(d),effects:nt.scrollIntoView(d,{y:"center"})})};function of({open:i,onOpenChange:e,viewRef:a,variant:s="overlay"}){const{t:c}=$e(),d=a.current,[g,f]=r.useState(""),p=r.useRef(null),j=r.useRef(!1),v=r.useRef(null),w=r.useRef(null),b=r.useMemo(()=>af(g,d),[g,d]);r.useEffect(()=>{!i||!d||(j.current=!1,p.current=To(d,d.state.selection),f(""))},[i,d]),r.useEffect(()=>{i&&window.requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()})},[i]),r.useEffect(()=>{if(!(!i||!d||!p.current)){if(b===null){const{selection:C}=p.current;d.dispatch({selection:C,effects:nt.scrollIntoView(C.main.from,{y:"center"})});return}Mo(d,b,p.current.character)}},[b,i,d]);const N=r.useCallback(()=>{if(!d||j.current||!p.current)return;const{selection:C}=p.current;d.dispatch({selection:C,effects:nt.scrollIntoView(C.main.from,{y:"center"})})},[d]),R=r.useRef(i);r.useEffect(()=>{R.current&&!i&&N(),R.current=i},[i,N]);const S=r.useCallback(C=>{C||N(),e(C)},[e,N]),F=r.useCallback(()=>{!d||b===null||!p.current||(j.current=!0,Mo(d,b,p.current.character),e(!1),d.focus())},[b,e,d]);r.useEffect(()=>{if(!i)return;const C=D=>{const h=v.current,O=D.target;!h||!(O instanceof Element)||h.contains(O)||O.closest("[data-go-to-line-toggle]")||S(!1)},V=D=>{D.key==="Escape"&&(D.preventDefault(),S(!1))};return document.addEventListener("pointerdown",C,!0),document.addEventListener("keydown",V,!0),()=>{document.removeEventListener("pointerdown",C,!0),document.removeEventListener("keydown",V,!0)}},[S,i,s]);const T=r.useMemo(()=>{if(!d)return c("goToLineDialog.helper.editorUnavailable");if(b===null){const C=p.current??To(d,d.state.selection);return c("goToLineDialog.helper.currentLineRange",{current:C.lineNumber,max:d.state.doc.lines})}return c("goToLineDialog.helper.goToLine",{line:b})},[b,c,d]);return s==="inline"?i?n.jsxs("div",{ref:v,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[n.jsx(xs,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),F())},placeholder:c("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:F,disabled:!d||b===null,className:"h-6 px-2",children:c("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:v,"data-editor-overlay":!0,className:q("absolute inset-s-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",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(xs,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),F())},placeholder:c("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const lf=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),cf=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),uf=new Set(["ArrowFunction","FunctionExpression"]),df=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),fl=/^(?:ATXHeading|SetextHeading)([1-6])$/,ml=(i,e)=>{for(let a=i.firstChild;a;a=a.nextSibling)if(e.has(a.name))return a;return null},ff=i=>{if(fl.test(i.name))return"heading";const e=lf.get(i.name);if(e)return e;const a=cf.get(i.name);return a&&ml(i,uf)?a:null},mf=(i,e)=>i.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),hf=(i,e=200)=>{const a=Sd(i,i.doc.length,e);if(!a)return[];const s=[],c=[];return a.iterate({enter:d=>{const g=ff(d.node);if(!g)return;let f,p;if(g==="heading")f=mf(i,d.node),p=d.from;else{const v=ml(d.node,df);if(!v)return;f=i.sliceDoc(v.from,v.to),p=v.from}if(!f)return;for(;c.length>0&&c[c.length-1]<=d.from;)c.pop();const j=g==="heading"?Number(fl.exec(d.name)?.[1]??1)-1:c.length;s.push({name:f,kind:g,line:i.doc.lineAt(p).number,from:p,depth:j}),g!=="heading"&&c.push(d.to)}}),s},pf={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},gf="data-document-symbols-toggle";function Po({open:i,onOpenChange:e,viewRef:a}){const{t:s}=$e(),c=a.current,d=r.useRef(null),[g,f]=r.useState([]),[p,j]=r.useState("");r.useEffect(()=>{i&&(j(""),f(c?hf(c.state):[]))},[i,c]);const v=r.useCallback(()=>{e(!1),c?.focus()},[e,c]);r.useEffect(()=>{if(!i)return;const b=N=>{const R=N.target;!(R instanceof Element)||!d.current||d.current.contains(R)||R.closest(`[${gf}]`)||e(!1)};return document.addEventListener("pointerdown",b,!0),()=>document.removeEventListener("pointerdown",b,!0)},[e,i]);const w=r.useCallback(b=>{c&&c.dispatch({selection:cl.cursor(b.from),effects:nt.scrollIntoView(b.from,{y:"center"})}),v()},[v,c]);return i?n.jsx("div",{ref:d,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),v())},children:n.jsxs(wu,{loop:!0,filter:(b,N)=>b.split("\0")[0].toLowerCase().includes(N.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[n.jsx(xu,{autoFocus:!0,value:p,onValueChange:j,placeholder:s("filesView.symbols.placeholder"),"aria-label":s("filesView.symbols.placeholder")}),n.jsxs(bu,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[n.jsx(yu,{className:"px-3 py-4 typography-meta text-muted-foreground",children:g.length===0?s("filesView.symbols.noneInFile"):s("filesView.symbols.noMatches")}),g.map(b=>n.jsxs(ju,{value:`${b.name}\0${b.from}`,onSelect:()=>w(b),className:"gap-2",children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${b.depth*12}px`},children:[n.jsx(E,{name:pf[b.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-foreground",children:b.name})]}),n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:b.line})]},`${b.from}:${b.name}`))]})]})}):null}const vf=(i,e)=>{const a=e.trim().toLowerCase(),s=[];if(!a)return s;const c=i.toLowerCase();let d=0;for(;;){const g=c.indexOf(a,d);if(g===-1)break;s.push({start:g,end:g+a.length}),d=g+a.length}return s},jr="data-md-find",gi="data-md-find-current",hl="rounded-[2px] bg-status-warning/30 text-foreground",wf="rounded-[2px] bg-status-warning/60 text-foreground",xf=120,bf=i=>i instanceof Element&&i.hasAttribute(jr),yf=i=>i.target instanceof Element&&i.target.hasAttribute(jr)?!0:[...i.addedNodes].some(e=>bf(e)),pl=i=>{const e=new Set;i.querySelectorAll(`mark[${jr}]`).forEach(a=>{const s=a.parentNode;s&&(s.replaceChild(document.createTextNode(a.textContent??""),a),e.add(s))}),e.forEach(a=>a.normalize())},jf=(i,e)=>{pl(i);const a=e.trim().toLowerCase();if(!a)return[];const s=[],c=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(g){const f=g.parentElement;return!f||f.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),d=[];for(;c.nextNode();){const g=c.currentNode;g instanceof Text&&d.push(g)}for(const g of d){const f=g.nodeValue??"";if(!f)continue;const p=vf(f,a);if(p.length===0)continue;const j=g.parentNode;if(!j)continue;const v=document.createDocumentFragment();let w=0;for(const b of p){b.start>w&&v.appendChild(document.createTextNode(f.slice(w,b.start)));const N=document.createElement("mark");N.setAttribute(jr,""),N.className=hl,N.textContent=f.slice(b.start,b.end),v.appendChild(N),s.push(N),w=b.end}w<f.length&&v.appendChild(document.createTextNode(f.slice(w))),j.replaceChild(v,g)}return s},Vo=({containerRef:i,open:e,onOpenChange:a,focusNonce:s,className:c})=>{const{t:d}=$e(),[g,f]=r.useState(""),[p,j]=r.useState(0),[v,w]=r.useState(0),b=r.useRef(null),N=r.useRef([]),R=r.useRef(g);R.current=g;const S=r.useRef(null),F=r.useRef(null),T=r.useCallback((M,B=!1)=>{const A=i.current;if(!A){N.current=[],j(0),w(0);return}N.current=jf(A,M);const $=N.current.length;j($),w(re=>!B||$===0?0:Math.min(re,$-1))},[i]),C=r.useCallback((M,B=!1)=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,T(M,B)},xf)},[T]);r.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const V=r.useCallback(()=>{a(!1);const M=F.current;F.current=null,M?.isConnected&&M.focus()},[a]);r.useEffect(()=>{const M=i.current;if(!e||!M)return;const B=new MutationObserver(A=>{!R.current.trim()||!A.some(re=>!yf(re))||C(R.current,!0)});return B.observe(M,{childList:!0,subtree:!0,characterData:!0}),()=>{B.disconnect(),pl(M)}},[i,e,C]),r.useEffect(()=>{if(!e)return;const M=document.activeElement;M instanceof HTMLElement&&!F.current&&(F.current=M),b.current?.focus()},[e]),r.useEffect(()=>{e&&s>0&&(b.current?.focus(),b.current?.select())},[e,s]),r.useEffect(()=>{const M=i.current;if(!M||(M.querySelectorAll(`mark[${gi}]`).forEach(A=>{A.removeAttribute(gi),A.className=hl}),p===0))return;const B=N.current[Math.min(Math.max(v,0),p-1)];B&&(B.setAttribute(gi,""),B.className=wf,B.scrollIntoView({block:"nearest"}))},[i,v,p]);const D=r.useCallback(()=>{w(M=>p===0?0:(M+1)%p)},[p]),h=r.useCallback(()=>{w(M=>p===0?0:(M-1+p)%p)},[p]),O=r.useCallback(M=>{M.key==="Enter"?(M.preventDefault(),M.shiftKey?h():D()):M.key==="Escape"&&(M.preventDefault(),V())},[V,D,h]);return e?n.jsxs("div",{className:q("absolute inset-e-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",c),children:[n.jsx(E,{name:"search",className:"ms-0.5 size-3.5 text-muted-foreground"}),n.jsx(xs,{ref:b,value:g,onChange:M=>{f(M.target.value),C(M.target.value)},onKeyDown:O,placeholder:d("filesView.preview.find.placeholder"),"aria-label":d("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":p>0?d("filesView.preview.find.countAria",{current:v+1,total:p}):d("filesView.preview.find.noMatches"),children:g.trim()&&p===0?d("filesView.preview.find.noMatches"):p>0?`${v+1}/${p}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:h,title:d("filesView.preview.find.previousAria"),"aria-label":d("filesView.preview.find.previousAria"),disabled:p===0,children:n.jsx(E,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:d("filesView.preview.find.nextAria"),"aria-label":d("filesView.preview.find.nextAria"),disabled:p===0,children:n.jsx(E,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:d("filesView.preview.find.closeAria"),"aria-label":d("filesView.preview.find.closeAria"),children:n.jsx(E,{name:"close",className:"size-3.5"})})]}):null},Nf=1,Do=({stat:i,showsFailure:e,sawMissing:a,hasUnsavedChanges:s,moving:c})=>i==="missing"?s||c?"none":"show-missing":i==="failed"?"none":e?a?"reload":"none":"check-changes",Sf=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=Nf,Cf=({selectedPath:i,targetPath:e,targetShown:a,targetSettled:s,showsText:c,canEdit:d,textViewMode:g})=>i!==e?a?"wait":"select-target":s?c?g==="edit"?"jump":d?"show-editor":"end":"end":"wait";function zo(){const i=we.c(8),[e]=Mt.useState(Ff),a=Mt.useRef(!1);let s;i[0]!==e?(s=p=>{if(p==null){e.cleanUp(),a.current=!1;return}a.current||(a.current=!0,e.setup(p,p.firstElementChild??void 0))},i[0]=e,i[1]=s):s=i[1];const c=s;let d,g;i[2]!==e?(d=()=>()=>{a.current=!1,e.cleanUp()},g=[e],i[2]=e,i[3]=d,i[4]=g):(d=i[3],g=i[4]),Mt.useLayoutEffect(d,g);let f;return i[5]!==c||i[6]!==e?(f={virtualizer:e,setScroller:c},i[5]=c,i[6]=e,i[7]=f):f=i[7],f}function Ff(){return new Hd}const An=new Map,kf=100;function dr(i){const[e,a]=Mt.useState(null),s=Mt.useRef(null),c=Mt.useRef(null),d=Mt.useRef(null),g=Mt.useCallback((f,p)=>{f&&p instanceof Bd&&(d.current={key:i,file:p,node:f});const j=s.current,v=c.current,w=()=>{s.current===j&&(j?.(),v?.())};p?queueMicrotask(w):w()},[i]);return Mt.useLayoutEffect(()=>{if(!e||!i)return;const f=An.get(i)??{top:0,left:0};let p=!0;const j=()=>d.current?.key===i?d.current.file:null,v=T=>d.current?.key===i?d.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${T-1}"]`):null,w=()=>{N.disconnect(),R.disconnect()},b=()=>{if(!p)return;const T=j(),C=f.line&&T?.getLinePosition(f.line.number),V=f.line&&v(f.line.number);let D=f.top;f.line&&C&&(D=(T?.top??0)+C.top-f.line.offset),f.line&&V&&(D=e.scrollTop+V.getBoundingClientRect().top-e.getBoundingClientRect().top-f.line.offset),e.scrollTop=D,e.scrollLeft=f.left,(!f.line||V)&&Math.abs(e.scrollTop-D)<1&&Math.abs(e.scrollLeft-f.left)<1&&(p=!1,w())},N=new ResizeObserver(b),R=new MutationObserver(()=>{if(p){for(const T of e.children)N.observe(T);b()}});N.observe(e);for(const T of e.children)N.observe(T);R.observe(e,{childList:!0,subtree:!0});const S=()=>{if(p)return;const T=j(),C=T?.getNumericScrollAnchor(e.scrollTop-(T.top??0)),V=C&&v(C.lineNumber),D=V?V.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(An.delete(i),An.set(i,{top:e.scrollTop,left:e.scrollLeft,line:C&&D!==null&&D>=0&&D<e.clientHeight?{number:C.lineNumber,offset:D}:void 0}),An.size>kf){const h=An.keys().next().value;h!==void 0&&An.delete(h)}},F=()=>{p=!1,w()};return s.current=b,c.current=S,b(),e.addEventListener("scroll",S,{passive:!0}),e.addEventListener("wheel",F,{passive:!0}),e.addEventListener("touchstart",F,{passive:!0}),e.addEventListener("pointerdown",F,{passive:!0}),e.addEventListener("keydown",F),()=>{s.current=null,c.current=null,d.current?.key===i&&(d.current=null),w(),e.removeEventListener("scroll",S),e.removeEventListener("wheel",F),e.removeEventListener("touchstart",F),e.removeEventListener("pointerdown",F),e.removeEventListener("keydown",F)}},[i,e]),{setScroller:a,restore:g}}function Ef(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||i.wouldEmptyFile||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function Rf(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const gl=2e5,Tf=i=>{let e=0,a=0;for(let s=0;s<i.length;s++)i.charCodeAt(s)===10&&(s>0&&i.charCodeAt(s-1)===13?e++:a++);return e>a?`\r
|
|
2
2
|
`:`
|
|
3
3
|
`},vl=i=>i.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|