@vantran-se/openchamber-web 2.0.5 → 2.0.7
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/bin/lib/commands-update.js +18 -6
- package/bin/lib/commands-update.test.js +14 -1
- package/dist/assets/{CodeMirrorCommentWidgets-DCAQTLMM.js → CodeMirrorCommentWidgets-C55OCQB7.js} +1 -1
- package/dist/assets/{DiffView-uzNpHBlV.js → DiffView-D80HdPcb.js} +1 -1
- package/dist/assets/{FilesView-Bkq0sjNx.js → FilesView-CPu9KAn_.js} +1 -1
- package/dist/assets/{GitView-BmibZC7n.js → GitView-Cyb4HROP.js} +1 -1
- package/dist/assets/{GuestAttachDialog-D7TJG1rt.js → GuestAttachDialog-CdC8RfDh.js} +1 -1
- package/dist/assets/{GuestSurfacePane-PAcYaFzP.js → GuestSurfacePane-ByCCvFv4.js} +1 -1
- package/dist/assets/{JsonTreeView-BNT2yUVu.js → JsonTreeView-pYH8Escm.js} +1 -1
- package/dist/assets/{LinearIssuesView-D3Azksju.js → LinearIssuesView-lyflKD5B.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-BGY6tuiK.js → MarkdownImageGallery-DOU9EkBG.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DJmhQ37f.js → MarkdownRendererImpl-BKISoFr4.js} +1 -1
- package/dist/assets/{OnboardingScreen-D_41H2qC.js → OnboardingScreen-_Ln6bjbQ.js} +1 -1
- package/dist/assets/{PatchDiff-C0RSqa9W.js → PatchDiff-DmYhtAwM.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BBE7tTY2.js → PierreDiffViewer-pRlYFUzk.js} +1 -1
- package/dist/assets/{PlanView-Bqc-xuDe.js → PlanView-Bjk4ILam.js} +1 -1
- package/dist/assets/{PluginPane-DQ0k41Q-.js → PluginPane-DJgKVT9D.js} +1 -1
- package/dist/assets/{SettingsView-BAiJU5hJ.js → SettingsView-DkZCkUK1.js} +1 -1
- package/dist/assets/{SettingsWindow-DuC4ecLw.js → SettingsWindow-fWY8N5ei.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-0HgmcMXz.js → SubmoduleDiffSummary-Dpv4MPVo.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DdHkQJEE.js → ToolOutputDialog-BK3T8zOg.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-DWdN0r5K.js → ToolPartDiffPreview-bT5jc7Fw.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-ClDezf2d.js → VirtualizedFileDiff-DOhvVx32.js} +1 -1
- package/dist/assets/{WalkthroughView-BJicp0RC.js → WalkthroughView-o4P1auMo.js} +1 -1
- package/dist/assets/{appThemeRegistry-CiuyzfSW.js → appThemeRegistry-CF0I57r1.js} +1 -1
- package/dist/assets/{commitAndPush-DTKb6IwT.js → commitAndPush-Dm3wnp4u.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-kM_zJNMt.js → computeVirtualFileMetrics-CcxmuPAX.js} +1 -1
- package/dist/assets/{de-BMnfXm-G.js → de-CFmy555r.js} +1 -1
- package/dist/assets/{es-DKEvCCL6.js → es-DLf8iVkG.js} +1 -1
- package/dist/assets/{fr-D9fgE2xE.js → fr-J24E2vLK.js} +1 -1
- package/dist/assets/{index-DWB8bR_g.js → index-CliHhehR.js} +1 -1
- package/dist/assets/{isDiffPlainText-DOoIsGqs.js → isDiffPlainText-Bwg3vzSL.js} +1 -1
- package/dist/assets/{isFilePlainText-bt5VHvcd.js → isFilePlainText-D7OOnOq1.js} +1 -1
- package/dist/assets/{ja-BEXad-KW.js → ja-lWSJzoL3.js} +1 -1
- package/dist/assets/{ko-DGrQ0lEe.js → ko-eOc96o9x.js} +1 -1
- package/dist/assets/{main-BpLQbZC2.js → main-C0R2Xb0E.js} +2 -2
- package/dist/assets/{main-CI9DtHJv.js → main-vkkdS1mY.js} +4 -4
- package/dist/assets/{markdownCore-DK2KK5RW.js → markdownCore-fx1suKTc.js} +1 -1
- package/dist/assets/{miniChat-CIWaR8wG.js → miniChat-zdTAhJRJ.js} +2 -2
- package/dist/assets/{mobile-CnWKEYIP.js → mobile-CygK96hE.js} +2 -2
- package/dist/assets/{patchFileDiff-Cqn0C0az.js → patchFileDiff-D3bSFjjg.js} +1 -1
- package/dist/assets/{pl-BlhkmR5b.js → pl-1eAnXR9t.js} +1 -1
- package/dist/assets/{pt-BR-Bs96Ew9I.js → pt-BR-BrGSooa_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-D9t0-9nV.js → renderElectronMiniChatApp-uJeO0EuJ.js} +2 -2
- package/dist/assets/{renderMobileApp-CW7fVs_s.js → renderMobileApp-B5ErILfl.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-D0PcCb3K.js → runtimeEndpointReset-BsoTecOZ.js} +3 -3
- package/dist/assets/{shikiHighlight-l-MbaNS4.js → shikiHighlight-U-ER5VqY.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-C-kGcOpD.js → textMateThemeFromAppTheme-CFZUMoyT.js} +1 -1
- package/dist/assets/{tr-CehUK1M9.js → tr-CCBiZbUG.js} +1 -1
- package/dist/assets/{uk-Bno5WGNz.js → uk-DdUzOSao.js} +1 -1
- package/dist/assets/{useAppFontEffects-DDjuwVqi.js → useAppFontEffects-Cfuya0Zd.js} +10 -10
- package/dist/assets/{useInlineCommentController-Clg8EO3A.js → useInlineCommentController-GbLdwSYb.js} +1 -1
- package/dist/assets/{useRootScrollLock-nDcRrgJ1.js → useRootScrollLock-1Q9TrnWg.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-oKF0MAwd.js → vendor-codemirror-language-data-CcqLCIWH.js} +2 -2
- package/dist/assets/{web-components-Bc1WPd4i.js → web-components-BWh2SieS.js} +1 -1
- package/dist/assets/{zh-CN-DnAweIWo.js → zh-CN-CyPbhaBn.js} +1 -1
- package/dist/assets/{zh-TW-BbBBK25p.js → zh-TW-D3yWw7PT.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/mini-chat.html +1 -1
- package/dist/mobile.html +1 -1
- package/package.json +2 -2
|
@@ -16,6 +16,17 @@ import {
|
|
|
16
16
|
logStatus,
|
|
17
17
|
} from '../cli-output.js';
|
|
18
18
|
|
|
19
|
+
export function partitionUpdateInstances(instances, readOptions = readInstanceOptions) {
|
|
20
|
+
const managed = [];
|
|
21
|
+
const foreground = [];
|
|
22
|
+
for (const instance of instances) {
|
|
23
|
+
const options = readOptions(instance.instanceFilePath) || {};
|
|
24
|
+
if (options.launchMode === 'foreground') foreground.push(instance);
|
|
25
|
+
else managed.push(instance);
|
|
26
|
+
}
|
|
27
|
+
return { managed, foreground };
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
function createUpdateCommand({ importFromFilePath, packageManagerPath, serveCommand }) {
|
|
20
31
|
return async function updateCommand(options = {}) {
|
|
21
32
|
const showOutput = shouldRenderHumanOutput(options);
|
|
@@ -29,6 +40,7 @@ function createUpdateCommand({ importFromFilePath, packageManagerPath, serveComm
|
|
|
29
40
|
} = await importFromFilePath(packageManagerPath);
|
|
30
41
|
|
|
31
42
|
const runningInstances = await discoverRunningInstances();
|
|
43
|
+
const { managed: managedInstances } = partitionUpdateInstances(runningInstances);
|
|
32
44
|
const currentVersion = getCurrentVersion();
|
|
33
45
|
|
|
34
46
|
if (showOutput) {
|
|
@@ -75,9 +87,9 @@ function createUpdateCommand({ importFromFilePath, packageManagerPath, serveComm
|
|
|
75
87
|
}
|
|
76
88
|
updateSpin?.message(`Updating to ${updateInfo.version || 'latest'}...`);
|
|
77
89
|
|
|
78
|
-
if (
|
|
79
|
-
updateSpin?.message(`Stopping ${
|
|
80
|
-
for (const instance of
|
|
90
|
+
if (managedInstances.length > 0) {
|
|
91
|
+
updateSpin?.message(`Stopping ${managedInstances.length} running instance(s)...`);
|
|
92
|
+
for (const instance of managedInstances) {
|
|
81
93
|
try {
|
|
82
94
|
const requested = await requestServerShutdown(instance.port, instance.host);
|
|
83
95
|
await stopInstanceProcess(instance.pid, {
|
|
@@ -101,9 +113,9 @@ function createUpdateCommand({ importFromFilePath, packageManagerPath, serveComm
|
|
|
101
113
|
throw new Error(`Update failed with exit code ${result.exitCode}`);
|
|
102
114
|
}
|
|
103
115
|
|
|
104
|
-
if (
|
|
105
|
-
updateSpin?.message(`Restarting ${
|
|
106
|
-
for (const instance of
|
|
116
|
+
if (managedInstances.length > 0) {
|
|
117
|
+
updateSpin?.message(`Restarting ${managedInstances.length} instance(s)...`);
|
|
118
|
+
for (const instance of managedInstances) {
|
|
107
119
|
const storedOptions = readInstanceOptions(instance.instanceFilePath) || { port: instance.port };
|
|
108
120
|
await serveCommand({
|
|
109
121
|
port: storedOptions.port || instance.port,
|
|
@@ -3,7 +3,7 @@ import os from 'os';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
|
-
import { createUpdateCommand } from './commands-update.js';
|
|
6
|
+
import { createUpdateCommand, partitionUpdateInstances } from './commands-update.js';
|
|
7
7
|
|
|
8
8
|
async function withTempOpenChamberDataDir(fn) {
|
|
9
9
|
const previous = process.env.OPENCHAMBER_DATA_DIR;
|
|
@@ -22,6 +22,19 @@ async function withTempOpenChamberDataDir(fn) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
describe('update command', () => {
|
|
25
|
+
it('leaves foreground service-manager instances running', () => {
|
|
26
|
+
const daemon = { port: 3000, instanceFilePath: '/daemon.json' };
|
|
27
|
+
const foreground = { port: 3069, instanceFilePath: '/foreground.json' };
|
|
28
|
+
const readOptions = vi.fn((filePath) => (
|
|
29
|
+
filePath === foreground.instanceFilePath ? { launchMode: 'foreground' } : { launchMode: 'daemon' }
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
expect(partitionUpdateInstances([daemon, foreground], readOptions)).toEqual({
|
|
33
|
+
managed: [daemon],
|
|
34
|
+
foreground: [foreground],
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
25
38
|
it('uses the package-manager helpers on the update-available path', async () => {
|
|
26
39
|
await withTempOpenChamberDataDir(async () => {
|
|
27
40
|
const originalWrite = process.stdout.write;
|
package/dist/assets/{CodeMirrorCommentWidgets-DCAQTLMM.js → CodeMirrorCommentWidgets-C55OCQB7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-
|
|
1
|
+
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-GbLdwSYb.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as r,f as Qe,j as n}from"./vendor-react-BUCujlKS.js";import{u as Q,P as Fe,C as Zn,a as Re,G as es}from"./index-Di6zUe5h.js";import{c as ts,b as ns,u as ss,a as rs,B as is,C as os,P as on,h as as,e as ls,g as cs,i as us,f as ds}from"./patchFileDiff-
|
|
1
|
+
import{R as r,f as Qe,j as n}from"./vendor-react-BUCujlKS.js";import{u as Q,P as Fe,C as Zn,a as Re,G as es}from"./index-Di6zUe5h.js";import{c as ts,b as ns,u as ss,a as rs,B as is,C as os,P as on,h as as,e as ls,g as cs,i as us,f as ds}from"./patchFileDiff-D3bSFjjg.js";import{c as fs,b as ms,i as ps,u as hs,a as gs,d as xs,S as ys}from"./SubmoduleDiffSummary-Dpv4MPVo.js";import{f as ze,B as je,I as O,h as le,_ as xn,ai as ws,K as ae,aj as bs,bj as vs,J as js,ak as ks,am as Ss,z as an,k as Ns,da as yn,t as Ye,l7 as Cs,az as lt,kY as wn,l8 as Fs,aA as _t,gZ as Rs,ax as at,ay as Ds,c8 as zt,at as As,av as Es,aw as Ts,as as Ls}from"./useAppFontEffects-Cfuya0Zd.js";import{j as Vs,f as Ms}from"./runtimeEndpointReset-BsoTecOZ.js";import{P as Bs}from"./PierreDiffViewer-pRlYFUzk.js";import{u as Is,v as Ps,g as _s,W as zs}from"./main-vkkdS1mY.js";import{b as Os,c as Ks}from"./changesTree-CePHbFcj.js";import{p as $s}from"./VirtualizedFileDiff-DOhvVx32.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./PluginPane-DJgKVT9D.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CcqLCIWH.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CdC8RfDh.js";import"./web-components-BWh2SieS.js";import"./computeVirtualFileMetrics-CcxmuPAX.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-GbLdwSYb.js";import"./appThemeRegistry-CF0I57r1.js";import"./textMateThemeFromAppTheme-CFZUMoyT.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-1Q9TrnWg.js";import"./scheduledTasksApi-Dahv3ws0.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-Bwg3vzSL.js";import"./vendor-diff-C3JhlQdm.js";const Gs=r.memo(function(e){const s=Qe.c(13),{index:u,staged:g,busyHunk:m,disabled:w,onAction:k}=e,{t:v}=ze();let a;s[0]!==g?(a=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=a):a=s[1];const j=a;let N;s[2]===Symbol.for("react.memo_cache_sentinel")?(N={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=N):N=s[2];let p;s[3]!==j||s[4]!==m||s[5]!==w||s[6]!==u||s[7]!==k||s[8]!==v?(p=n.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:j.map(b=>{const C=v(b==="stage"?"diffView.hunk.stageTitle":b==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),V=m?.index===u&&m.action===b;return n.jsx(je,{variant:"ghost",size:"xs",className:le("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",b==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",b==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:w||m!==null,title:C,"aria-label":C,onPointerDown:Ws,onClick:f=>{f.stopPropagation(),k(u,b)},children:n.jsx(O,{name:V?"loader-4":b==="stage"?"add":"arrow-go-back",className:le(b==="stage"?"size-4":"size-3.5",V&&"animate-spin")})},b)})}),s[3]=j,s[4]=m,s[5]=w,s[6]=u,s[7]=k,s[8]=v,s[9]=p):p=s[9];let E;return s[10]!==u||s[11]!==p?(E=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:N,"data-hunk-actions":u,children:p}),s[10]=u,s[11]=p,s[12]=E):E=s[12],E});function Ws(o){return o.stopPropagation()}const ln=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-o}:null},Hs=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Mt=o=>o.slice(o.lastIndexOf("/")+1),bn=(o,e)=>{const s=[],u=(g,m)=>{const w=Array.from(g.children.values()).sort((v,a)=>v.name.localeCompare(a.name));for(const v of w){const{node:a,label:j}=Ks(v),N=!e.has(a.path);s.push({kind:"directory",key:`dir:${a.path}`,depth:m,path:a.path,label:j,fileCount:a.files.length,expanded:N}),N&&u(a,m+1)}const k=[...g.directFiles].sort((v,a)=>Mt(v.path).localeCompare(Mt(a.path)));for(const v of k)s.push({kind:"file",key:`file:${v.path}`,depth:m,name:Mt(v.path),file:v})};return u(Os(o),0),s},cn=o=>{if(!o)return null;const e=o.split(`
|
|
2
2
|
`);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},qs=1100,Us=15e3,un=500,dn=300,vn=1e6,It=3,Xs=o=>o<=6?o:o<=12?6:o<=25?4:2,fn={status:"loading"},Js=3,Ys=r.memo(()=>{const o=Qe.c(4),{t:e}=ze();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),jn={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Qs=jn.M,Zs=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Ot=o=>{const e=Zs(o);return jn[e]??Qs},er=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},mn=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},pn=o=>!!o.working_dir?.trim()||o.index==="?",tr=(o,e)=>Rs(o,e),hn=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),gn=(o,e)=>{const s=o.split(`
|
|
3
3
|
`),u=e.split(`
|
|
4
4
|
`),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},nr=o=>o==="added"?"A":o==="deleted"?"D":"M",Pt=(o,e,s)=>us(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:ds(o,e),contextMode:s},kn=(o,e,s)=>{const u=o??0,g=e??0;return!u&&!g?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},sr=r.memo(o=>{const e=Qe.c(68),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:w,commitCount:k,prCount:v,showCommitOption:a,showBranchOption:j,onScopeChange:N}=o,{t:p}=ze(),[E,b]=r.useState(!1),C=s==="pr"?v??0:s==="staged"?g:s==="turn"?m:s==="branch"?w??0:s==="commit"?k??0:u;let V;e[0]!==s||e[1]!==p?(V=p(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=p,e[2]=V):V=e[2];const f=V;let S;e[3]!==p?(S=p("diffView.scope.selectorAria"),e[3]=p,e[4]=S):S=e[4];let M;e[5]!==C?(M=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",C]}),e[5]=C,e[6]=M):M=e[6];let I;e[7]!==f||e[8]!==M?(I=n.jsxs("span",{className:"whitespace-nowrap",children:[f,M]}),e[7]=f,e[8]=M,e[9]=I):I=e[9];let ce;e[10]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx(O,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=ce):ce=e[10];let U;e[11]!==S||e[12]!==I?(U=n.jsx(As,{asChild:!0,children:n.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":S,children:[I,ce]})}),e[11]=S,e[12]=I,e[13]=U):U=e[13];let y;e[14]!==N?(y=H=>{(H==="working"||H==="staged"||H==="turn"||H==="branch"||H==="commit"||H==="pr")&&(N?.(H),b(!1))},e[14]=N,e[15]=y):y=e[15];let K;e[16]!==p?(K=p("diffView.scope.changed"),e[16]=p,e[17]=K):K=e[17];let X;e[18]!==K?(X=n.jsx("span",{children:K}),e[18]=K,e[19]=X):X=e[19];let ue;e[20]!==u?(ue=n.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=ue):ue=e[21];let se;e[22]!==ue||e[23]!==X?(se=n.jsx(at,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,ue]})}),e[22]=ue,e[23]=X,e[24]=se):se=e[24];let xe;e[25]!==p?(xe=p("diffView.scope.staged"),e[25]=p,e[26]=xe):xe=e[26];let re;e[27]!==xe?(re=n.jsx("span",{children:xe}),e[27]=xe,e[28]=re):re=e[28];let ye;e[29]!==g?(ye=n.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[29]=g,e[30]=ye):ye=e[30];let ee;e[31]!==re||e[32]!==ye?(ee=n.jsx(at,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[re,ye]})}),e[31]=re,e[32]=ye,e[33]=ee):ee=e[33];let _;e[34]!==p?(_=p("diffView.scope.lastTurn"),e[34]=p,e[35]=_):_=e[35];let te;e[36]!==_?(te=n.jsx("span",{children:_}),e[36]=_,e[37]=te):te=e[37];let ne;e[38]!==m?(ne=n.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=ne):ne=e[39];let $;e[40]!==te||e[41]!==ne?($=n.jsx(at,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[te,ne]})}),e[40]=te,e[41]=ne,e[42]=$):$=e[42];let ke;e[43]!==w||e[44]!==j||e[45]!==p?(ke=j?n.jsx(at,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:w??"…"})]})}):null,e[43]=w,e[44]=j,e[45]=p,e[46]=ke):ke=e[46];let T;e[47]!==k||e[48]!==a||e[49]!==p?(T=a&&n.jsx(at,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:k??"…"})]})}),e[47]=k,e[48]=a,e[49]=p,e[50]=T):T=e[50];let W;e[51]!==v||e[52]!==a||e[53]!==p?(W=a&&n.jsx(at,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("session.githubIntegration.tabs.pullRequests")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[51]=v,e[52]=a,e[53]=p,e[54]=W):W=e[54];let A;e[55]!==s||e[56]!==se||e[57]!==ee||e[58]!==$||e[59]!==ke||e[60]!==T||e[61]!==W||e[62]!==y?(A=n.jsx(Es,{align:"start",className:"w-40",children:n.jsxs(Ts,{value:s,onValueChange:y,children:[se,ee,$,ke,T,W]})}),e[55]=s,e[56]=se,e[57]=ee,e[58]=$,e[59]=ke,e[60]=T,e[61]=W,e[62]=y,e[63]=A):A=e[63];let de;return e[64]!==E||e[65]!==A||e[66]!==U?(de=n.jsxs(Ls,{open:E,onOpenChange:b,children:[U,A]}),e[64]=E,e[65]=A,e[66]=U,e[67]=de):de=e[67],de}),rr=r.memo(o=>{const e=Qe.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze();if(s.length===0)return null;let w;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let v;e[5]!==g||e[6]!==u||e[7]!==m?(v=a=>{const j=Ot(a),N=u===a.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>g(a.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",N?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(_t,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:j.color},title:m(j.descriptionKey),"aria-label":m(j.descriptionKey),children:j.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),kn(a.insertions,a.deletions)]})},a.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=v):v=e[8],w=s.map(v),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=w}else w=e[4];let k;return e[9]!==w?(k=n.jsx(zt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:w})}),e[9]=w,e[10]=k):k=e[10],k}),Sn=12,Nn=8,Bt=160,ir=.5,or=r.memo(o=>{const e=Qe.c(18),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze(),[w,k]=r.useState(ur);let v;e[0]!==s||e[1]!==w?(v=bn(s,w),e[0]=s,e[1]=w,e[2]=v):v=e[2];const a=v;let j,N;e[3]!==u?(j=()=>{u&&k(f=>{const S=Array.from(f).filter(I=>u.startsWith(`${I}/`));if(S.length===0)return f;const M=new Set(f);return S.forEach(I=>M.delete(I)),M})},N=[u],e[3]=u,e[4]=j,e[5]=N):(j=e[4],N=e[5]),r.useEffect(j,N);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=f=>{k(S=>{const M=new Set(S);return M.delete(f)||M.add(f),M})},e[6]=p):p=e[6];const E=p,b=fr;let C;if(e[7]!==g||e[8]!==a||e[9]!==u||e[10]!==m){let f;e[12]!==g||e[13]!==u||e[14]!==m?(f=S=>{const M=`${Nn+S.depth*Sn}px`;if(S.kind==="directory")return n.jsxs("li",{className:"relative",children:[b(S.depth),n.jsxs("button",{type:"button",onClick:()=>E(S.path),"aria-expanded":S.expanded,"aria-label":S.expanded?m("diffView.fileTree.collapseDirectoryAria",{path:S.path}):m("diffView.fileTree.expandDirectoryAria",{path:S.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pr-2 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingLeft:M},title:S.path,children:[n.jsx(O,{name:"arrow-right-s",className:le("size-3.5 flex-shrink-0 transition-transform",S.expanded&&"rotate-90")}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:S.label})]})]},S.key);const I=Ot(S.file),ce=u===S.file.path;return n.jsxs("li",{className:"relative",children:[b(S.depth),n.jsxs("button",{type:"button",onClick:()=>g(S.file.path),"aria-current":ce?"true":void 0,className:le("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left transition-colors",ce?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground/90 hover:bg-interactive-hover hover:text-foreground"),style:{paddingLeft:M},title:S.file.path,children:[n.jsx(_t,{filePath:S.file.path,className:"ml-0.5 size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:S.name}),n.jsx("span",{className:"typography-micro font-semibold w-3 text-center uppercase",style:{color:I.color},title:m(I.descriptionKey),"aria-label":m(I.descriptionKey),children:I.code})]})]},S.key)},e[12]=g,e[13]=u,e[14]=m,e[15]=f):f=e[15],C=a.map(f),e[7]=g,e[8]=a,e[9]=u,e[10]=m,e[11]=C}else C=e[11];let V;return e[16]!==C?(V=n.jsx(zt,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:n.jsx("ul",{className:"flex flex-col",children:C})}),e[16]=C,e[17]=V):V=e[17],V}),ar=r.memo(o=>{const e=Qe.c(20),{filePath:s,diff:u,renderSideBySide:g}=o,{t:m}=ze(),w=u.original.length>0,k=u.modified.length>0,v=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",a=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={contain:"layout"},e[0]=j):j=e[0];let N;e[1]!==u.original||e[2]!==s||e[3]!==w||e[4]!==a||e[5]!==g||e[6]!==m?(N=w&&n.jsxs("div",{className:a,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),n.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=w,e[4]=a,e[5]=g,e[6]=m,e[7]=N):N=e[7];let p;e[8]!==u.modified||e[9]!==s||e[10]!==k||e[11]!==w||e[12]!==a||e[13]!==g||e[14]!==m?(p=k&&n.jsxs("div",{className:a,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(w?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=k,e[11]=w,e[12]=a,e[13]=g,e[14]=m,e[15]=p):p=e[15];let E;return e[16]!==v||e[17]!==N||e[18]!==p?(E=n.jsx("div",{className:"w-full overflow-auto p-4",style:j,children:n.jsxs("div",{className:v,children:[N,p]})}),e[16]=v,e[17]=N,e[18]=p,e[19]=E):E=e[19],E}),lr=r.memo(o=>{const e=Qe.c(23),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:w,hunkActions:k,onExpandContextRequest:v,pendingContextExpansion:a,contextLoading:j}=o;let N;e[0]!==s?(N=Ds(s)||"text",e[0]=s,e[1]=N):N=e[1];const p=N;if(u.submodule){let C;return e[2]!==u.submodule||e[3]!==g?(C=n.jsx(ys,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=C):C=e[4],C}if(u.isBinary){let C;return e[5]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Ys,{}),e[5]=C):C=e[5],C}if(lt(s)){let C;return e[6]!==u||e[7]!==s||e[8]!==m?(C=n.jsx(ar,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=C):C=e[9],C}let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={contain:"layout"},e[10]=E):E=e[10];let b;return e[11]!==j||e[12]!==u.fileDiff||e[13]!==u.modified||e[14]!==u.original||e[15]!==s||e[16]!==k||e[17]!==p||e[18]!==v||e[19]!==a||e[20]!==m||e[21]!==w?(b=n.jsx("div",{className:"w-full",style:E,children:n.jsx(Bs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:p,fileName:s,renderSideBySide:m,wrapLines:w,layout:"inline",hunkActions:k,onExpandContextRequest:v,pendingContextExpansion:a,contextLoading:j})}),e[11]=j,e[12]=u.fileDiff,e[13]=u.modified,e[14]=u.original,e[15]=s,e[16]=k,e[17]=p,e[18]=v,e[19]=a,e[20]=m,e[21]=w,e[22]=b):b=e[22],b}),cr=r.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:w,isMounted:k,onSelect:v,onExpandedChange:a,registerSectionRef:j,showOpenInEditorAction:N=!1,isOpeningInEditor:p=!1,onOpenInEditor:E,staged:b=!1,loadFullFiles:C=!1,initialDiffData:V=null,comparisonDiff:f,onRetryComparisonDiff:S,loadFullComparisonDiff:M,readOnlyActions:I=!1,hunkActionsEnabled:ce=!1,contentRevision:U=0})=>{const{t:y}=ze(),{git:K}=xn(),X=ae(r.useCallback(x=>x.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),ue=ae(x=>x.setDiff),se=ae(x=>x.fetchStatus),xe=Q(x=>x.setDiffFileLayout),[re,ye]=r.useState(0),[ee,_]=r.useState(null),[te,ne]=r.useState(!1),[$,ke]=r.useState(null),T=$!==null&&$.source===f?$.result:f,W=!!e&&!V&&(!f||!!M),A=r.useMemo(()=>T?T.status==="error"?{kind:"error",message:T.message}:null:ee,[T,ee]),de=T?T.status==="loading":te,[H,xt]=r.useState(null),Oe=r.useRef(!1),[Ke,ct]=r.useState(null),[yt,Ft]=r.useState(!1),[ut,$e]=r.useState(null),[Ze,Ge]=r.useState(null),[c,De]=r.useState(null),ie=C||c!==null;r.useEffect(()=>{if(!c||!M||!f||f.status!=="ready"||$?.source===f)return;let x=!1;return M(s.path).then(z=>{if(!x){if(z.status==="error"){Ye.error(z.message),De(null);return}ke({source:f,result:z})}}),()=>{x=!0}},[c,s.path,$,M,f]);const we=r.useRef(null),Ae=r.useRef(null),We=r.useMemo(()=>Ot(s),[s]),et=u==="side-by-side",He=ie?"full":"patch",Se=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,fe=ce&&!I&&!V&&!T&&!lt(s.path),tt=JSON.stringify([Re(),e,s.path,b,Se,re,U]),G=Ke?.scope===tt?Ke.patch:null,wt=Ke?.scope===tt?Ke.submodule:null,me=r.useMemo(()=>T?T.status==="ready"?T.data:null:V||(b?Ze:ut||(X?{original:X.original,modified:X.modified,isBinary:X.isBinary,submodule:X.submodule,contextMode:"full"}:null)),[T,X,V,ut,b,Ze]),pe=me?.contextMode===He,dt=r.useCallback(x=>{Ae.current=x,j(s.path,x)},[s.path,j]),nt=r.useCallback(x=>{a(s.path,x)},[s.path,a]),st=r.useCallback(()=>{v(s.path)},[s.path,v]),qe=r.useRef({fileStatusKey:Se,staged:b});r.useEffect(()=>{if(!o)return;const x=qe.current;x.fileStatusKey===Se&&x.staged===b||(qe.current={fileStatusKey:Se,staged:b},b?Ge(null):$e(null),_(null),we.current=null)},[Se,b,o]);const[Ue,Rt]=r.useState(U),rt=Ue===U;r.useEffect(()=>{rt||(_(null),we.current=null)},[rt]),r.useEffect(()=>{if(!o||!w||!k||ee)return;if(!e||T||V||me&&pe&&rt&&(!fe||G!==null)){we.current=null,ne(!1);return}const x=`${e}::${s.path}::${b?"staged":"unstaged"}::${Se}::${He}::${re}::${U}`;if(we.current===x)return;we.current=x,_(null),ne(!0);let z=!1;const he=Re(),Le=ie?vn:It,Z=lt(s.path)?K.getGitFileDiff(e,{path:s.path,staged:b}):!ie&&G!==null?Promise.resolve({diff:G,submodule:wt}):K.getGitDiff(e,{path:s.path,staged:b,contextLines:Le}),Ve=fe&&ie&&G===null?K.getGitDiff(e,{path:s.path,staged:b,contextLines:It}).then(L=>L.diff):Promise.resolve(G),Ne=Promise.all([Z,Ve]),Me=Us;let it;const Dt=new Promise((L,ft)=>{it=setTimeout(()=>ft(new Error(`Timed out after ${Me}ms`)),Me)});return Promise.race([Ne,Dt]).then(([L,ft])=>{if(z||he!==Re())return;const Be="diff"in L&&!ie?L.diff:ft;if(fe&&ie&&Be!==null&&/^@@\s/m.test(Be)&&"diff"in L&&L.diff!==Be&&!as(L.diff,Be))throw ct(null),new Error(y("diffView.hunk.unavailable"));if(fe&&Be!==null&&ct({scope:tt,patch:Be,submodule:L.submodule}),"diff"in L){const Xe={...Pt(s.path,L.diff,He),submodule:L.submodule};b?Ge(Xe):$e(Xe)}else{const Xe={original:L.original??"",modified:L.modified??"",isBinary:L.isBinary,submodule:L.submodule,contextMode:"full"};b?Ge(Xe):ue(e,s.path,Xe,he)}Rt(U),ne(!1)}).catch(L=>{if(!(z||he!==Re())){if(ne(!1),L instanceof es){_({kind:"unavailable",reason:L.reason}),L.reason==="path_not_found"&&se(e,K,{force:!0,silent:!0});return}_({kind:"error",message:L instanceof Error?L.message:String(L)})}}).finally(()=>clearTimeout(it)),()=>{z=!0,clearTimeout(it),we.current===x&&(we.current=null)}},[G,wt,U,fe,rt,tt,T,He,me,pe,re,e,se,s.path,Se,K,V,w,k,ie,ee,ue,b,y,o]);const bt=r.useCallback(()=>{nt(!w),st()},[nt,st,w]),oe=r.useCallback(()=>{_(null),ct(null),$e(null),Ge(null),we.current=null,ye(x=>x+1)},[]),Ee=r.useCallback(async(x,z)=>{if(!e||!fe||de||A||Oe.current||H!==null)return;const he=G?ls(G,x):null;if(!he){Ye.error(y("diffView.hunk.unavailable"));return}if(b&&z!=="unstage"||!b&&z==="unstage")return;Oe.current=!0;const Le=Re();xt({index:x,action:z});try{const Z=z==="stage"?K.stageGitHunk:z==="unstage"?K.unstageGitHunk:K.revertGitHunk;if(!Z){Ye.error(y("diffView.hunk.unsupported"));return}if(await Z(e,s.path,he),Le!==Re())return;oe(),yn.requestGitRefresh({directory:e,paths:[s.path]}),await se(e,K)}catch(Z){if(Le!==Re())return;oe(),Ye.error(Z instanceof Error&&Z.message?Z.message:y("diffView.hunk.unavailable"))}finally{Oe.current=!1,xt(Z=>Z?.index===x&&Z.action===z?null:Z)}},[G,fe,de,A,e,se,s.path,K,H,oe,b,y]),be=r.useMemo(()=>fe&&G!==null?cs(G):[],[G,fe]),q=r.useCallback(x=>n.jsx(Gs,{index:x,staged:b,busyHunk:H,disabled:de||!!A,onAction:Ee}),[A,Ee,H,de,b]),Te=r.useMemo(()=>be.length>0?{anchors:be,render:q}:void 0,[be,q]);return n.jsxs("div",{ref:dt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.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:n.jsxs("div",{role:"button",tabIndex:0,onClick:bt,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),bt())},className:le("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",m?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:w?n.jsx(O,{name:"arrow-down-s",className:"size-4"}):n.jsx(O,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:We.color},title:y(We.descriptionKey),"aria-label":y(We.descriptionKey),children:We.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_t,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=s.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const z=s.path.slice(0,x),he=s.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:z}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:he})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[kn(s.insertions,s.deletions),N&&E?n.jsx(je,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:y("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),E(s.path,me)},disabled:p,children:p?n.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(O,{name:"edit",className:"size-3.5"})}):null,n.jsx(wn,{mode:et?"side-by-side":"unified",onModeChange:x=>{const z=x==="side-by-side"?"side-by-side":"inline";xe(s.path,z)},className:"opacity-70"})]})]})}),w&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!k&&!A?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?.kind==="unavailable"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:A.reason==="nested_repository"?y("diffView.unavailable.nestedRepositoryTitle"):A.reason==="untracked_directory"?y("diffView.unavailable.untrackedDirectoryTitle"):y("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A.reason==="nested_repository"?y("diffView.unavailable.nestedRepositoryDescription"):A.reason==="untracked_directory"?y("diffView.unavailable.untrackedDirectoryDescription"):y("diffView.unavailable.missingDescription")}),A.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:oe,children:y("diffView.actions.retry")}):null]}):null,A?.kind==="error"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>T?S?.():oe(),children:y("diffView.actions.retry")})]}):null,k&&de&&!me&&!A?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),y("diffView.state.loadingDiff")]}):null,k&&me&&!yt&&s.insertions+s.deletions>un?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:y("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Ft(!0),children:y("diffView.actions.renderAnyway")})]}):null,k&&me&&(yt||s.insertions+s.deletions<=un)?n.jsx(n.Fragment,{children:n.jsx(lr,{filePath:s.path,diff:me,staged:b,renderSideBySide:et,wrapLines:g,hunkActions:Te,onExpandContextRequest:W?De:void 0,pendingContextExpansion:c,contextLoading:c!==null&&me.contextMode!=="full"&&!A})}):null]})]})}),Vo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:w,targetFilePath:k=null,flushContent:v=!1})=>{const{t:a}=ze(),{git:j,files:N}=xn(),p=ws(),E=ae(t=>t.runtimeKey),{rootIsGitRepo:b,gitDirectory:C,nestedRepos:V}=bs(p??null,{enabled:o}),f=C??p,S=Q(t=>t.openContextSurface),M=Is(t=>t.requestSource),{screenWidth:I,isMobile:ce}=vs(),U=js(f??null),y=ks(f??null),K=Ss(f??null),X=ae(t=>t.setActiveDirectory),ue=ae(t=>t.ensureStatus),se=ae(t=>t.selectNestedRepo),xe=ae(t=>t.fetchStatus),re=ae(t=>t.fetchBranches),ye=ae(t=>t.clearDiffCache),ee=ae(t=>t.setDiff),[_,te]=r.useState(null),[ne,$]=r.useState(!1),[ke,T]=r.useState(null),[W,A]=r.useState(()=>new Set),[de,H]=r.useState(()=>new Set),[xt,Oe]=r.useState(0),[Ke,ct]=r.useState(()=>new Map),[yt,Ft]=r.useState(0),[ut,$e]=r.useState(!1),[Ze,Ge]=r.useState(!1),[c,De]=r.useState(m);r.useEffect(()=>{De(m)},[m]);const ie=Q(t=>t.pendingDiffFile),we=Q(t=>t.pendingDiffStaged),Ae=Q(t=>t.pendingDiffScope),We=Q(t=>t.setPendingDiffFile),et=Q(t=>t.diffLayoutPreference),He=Q(t=>t.diffFileLayout),Se=Q(t=>t.setDiffFileLayout),fe=Q(t=>t.diffWrapLines),tt=Q(t=>t.setDiffWrapLines),G=Q(t=>t.diffFileListMode),wt=Q(t=>t.setDiffFileListMode),me=Q(t=>t.openContextFileAtLine),pe=an(t=>t.currentSessionId),dt=Ns(c==="turn"?pe??"":"",p??void 0),nt=fe,st=c==="staged"?!0:c==="working"?!1:null,qe=st??ne,Ue=ce||I<=768,Rt=!!pe&&c!=="turn"&&c!=="commit"&&c!=="pr"&&!Ue&&!Fe(),rt=c!=="turn"&&!Ue&&!Fe(),bt=!e&&!Ue&&I>=1024,oe=r.useRef(null),Ee=r.useRef(new Map),be=r.useRef(null),q=r.useRef(null),Te=r.useRef(!1),x=r.useRef(null),z=r.useRef(null),he=r.useRef(null),Le=r.useRef(null),Z=r.useCallback(()=>{const t=oe.current;if(!t)return null;const i=t.getBoundingClientRect().top,l=[];for(const[d,h]of Ee.current)h&&l.push({path:d,top:h.getBoundingClientRect().top});return ln(i,l)},[]),Ve=r.useCallback(()=>{be.current=null,Te.current=!1,T(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)},[]),Ne=r.useCallback(t=>{A(i=>{if(i.has(t))return i;const l=new Set(i);return l.add(t),l})},[]),[Me,it]=r.useState([]),Dt=dt.length>0?dt[dt.length-1].id:"";r.useEffect(()=>{if(c!=="turn"||!pe||!o)return;let t=!1;return Zn.getSessionTurnDiff(pe,{directory:p??void 0}).then(i=>{t||it(i.map(l=>({file:l.file,patch:l.patch,status:l.status,additions:l.additions,deletions:l.deletions})))}).catch(i=>{t||(console.warn("[diff-view] turn diff unavailable:",i instanceof Error?i.message:i),it([]))}),()=>{t=!0}},[c,pe,Dt,p,o]);const L=r.useMemo(()=>{const t=new Map;for(const i of Me)if(i.file){if(typeof i.patch=="string"){t.set(i.file,Pt(i.file,i.patch,"patch"));continue}t.set(i.file,{original:i.before??"",modified:i.after??"",contextMode:"full"})}return t},[Me]),ft=r.useMemo(()=>y?.files?y.files.filter(pn).length:0,[y]),Be=r.useMemo(()=>y?.files?y.files.filter(mn).length:0,[y]),Xe=Me.length,J=y?.current??null,Ie=ts(f??null,J,o&&c==="pr"&&!Fe()),Pe=Ie.selectedSource,_e=ns(f??null,J,o&&c==="commit"&&!Fe()),Je=_e.selectedCommit?.hash??null;r.useEffect(()=>{(c==="commit"||c==="pr")&&Fe()&&(De("working"),w?.("working"))},[c,w]);const ot=ae(t=>f?t.directories.get(f)?.branches??null:null),Cn=ae(t=>f?t.directories.get(f)?.isLoadingBranches??!1:!1),Fn=r.useCallback(()=>{f&&re(f,j)},[f,re,j]),Rn=fs(f??null,o&&U!==!1,Cn,!!ot,Fn,Js),Kt=r.useMemo(()=>{const t=y?.tracking?.trim().split("/")[0];return(t&&ot?.defaultBranches?.[t])??ot?.defaultBranches?.origin??null},[ot,y?.tracking]),$t=!Fe()&&ms(J,Kt),Dn=y!==null,Gt=Fe()||Rn||ps(J,Kt,Dn,ot!==null),An=ss(t=>t.setOverride),{base:Ce,resolved:En,revision:Wt}=rs(f??null,J,o&&$t&&c==="branch"),[Tn,Ln]=r.useState(0);r.useEffect(()=>{const t=xs(c,!Gt);t!==c&&(De(t),t==="working"&&w?.("working"))},[c,Gt,w]);const Vn=r.useMemo(()=>c==="pr"?Pe:c==="commit"&&Je?{kind:"commit",hash:Je}:c==="branch"&&Ce&&J?{kind:"branch",baseRef:Ce,headRef:J}:null,[c,Ce,J,Je,Pe]),P=hs(f??null,Vn,o&&!Fe(),c==="branch"?Wt:""),{fetchDiff:Ht,fetchFullFile:qt}=P,Ut=c==="commit"?P.files:null,Xt=c==="commit"?P.error:null,vt=c==="branch"?P.files:null,Jt=c==="branch"?P.error:null,Yt=P.files?c==="pr"?JSON.stringify([P.key,P.revision]):P.key:null,Mn=r.useMemo(()=>c==="branch"||c==="commit"||c==="pr"?Array.from(W).sort().join("\0"):"",[c,W]),At=r.useCallback(async(t,i=!1)=>{try{const l=await Ht(t,i?vn:It);return{status:"ready",data:Pt(t,l.diff,i?"full":"patch")}}catch(l){return{status:"error",message:l instanceof Error?l.message:a("diffView.state.failedToLoadDiff")}}},[Ht,a]),Qt=r.useCallback(async t=>{try{const{original:i,modified:l}=await qt(t),d=$s({name:t,contents:i},{name:t,contents:l});return{status:"ready",data:{original:i,modified:l,fileDiff:d,contextMode:"full"}}}catch(i){return{status:"error",message:i instanceof Error?i.message:a("diffView.state.failedToLoadDiff")}}},[qt,a]),Bn=r.useMemo(()=>c==="branch"||c==="commit"?t=>At(t,!0):c==="pr"?Qt:void 0,[c,At,Qt]),In=gs(Yt,o?Mn:"",Yt?At:null,fn,JSON.stringify([c==="branch"?Wt:"",c==="pr"?P.revision:0,Tn])),Pn=vt?.length??null,D=r.useMemo(()=>{if(c==="commit"||c==="pr")return(P.files??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:d.insertions,deletions:d.deletions,isNew:d.status==="A"}));if(c==="branch")return(vt??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:0,deletions:0,isNew:d.status==="A"})).sort((d,h)=>d.path.localeCompare(h.path));if(c==="turn")return Me.map(d=>({path:d.file??"",index:"",working_dir:nr(d.status),insertions:d.additions??0,deletions:d.deletions??0,isNew:d.status==="added"})).filter(d=>d.path).sort((d,h)=>d.path.localeCompare(h.path));if(!y?.files)return[];const t=y.diffStats,i=c==="staged"?mn:c==="working"?pn:()=>!0,l=d=>{const h=t?.staged?.[d],F=t?.working?.[d];return c==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:c==="working"?{insertions:F?.insertions??0,deletions:F?.deletions??0}:{insertions:(h?.insertions??0)+(F?.insertions??0),deletions:(h?.deletions??0)+(F?.deletions??0)}};return y.files.filter(i).map(d=>{const h=l(d.path);return{...d,insertions:h.insertions,deletions:h.deletions,isNew:er(d)}}).sort((d,h)=>d.path.localeCompare(h.path))},[c,vt,P.files,Me,y]),Et=r.useMemo(()=>D.map(t=>t.path).join("\0"),[D]);r.useEffect(()=>{const t=Et?Et.split("\0"):[],i=new Set(t),l=`${f??""}:${c}:${s?"collapsed":"default"}`,d=z.current!==l;z.current=l,A(h=>{if(d){const B=s?0:Xs(t.length);return new Set(t.slice(0,B))}let F=!1;const R=new Set;for(const B of h){if(!i.has(B)){F=!0;continue}R.add(B)}return F?R:h}),H(h=>{if(d)return new Set;let F=!1;const R=new Set;for(const B of h){if(!i.has(B)){F=!0;continue}R.add(B)}return F?R:h})},[c,Et,f,s]);const Zt=r.useCallback(()=>{if(x.current=null,!o)return;const t=oe.current;if(!t)return;const i=t.getBoundingClientRect(),l=i.top-dn,d=i.bottom+dn,h={},F=[];for(const[R,B]of Ee.current){if(!B)continue;const Y=B.getBoundingClientRect();F.push({path:R,top:Y.top}),W.has(R)&&(Y.bottom<l||Y.top>d||(h[R]=!0))}he.current=ln(i.top,F),H(R=>{let B=!1;const Y=new Set(R);for(const gt of Object.keys(h))Y.has(gt)||(Y.add(gt),B=!0);return B?Y:R})},[W,o]),ge=r.useCallback(()=>{o&&(typeof window>"u"||x.current===null&&(x.current=window.requestAnimationFrame(Zt)))},[Zt,o]);r.useEffect(()=>{const t=oe.current;if(!(!o||!t))return ge(),t.addEventListener("scroll",ge,{passive:!0}),window.addEventListener("resize",ge),()=>{t.removeEventListener("scroll",ge),window.removeEventListener("resize",ge),x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}},[D,W,ge,o]);const Tt=r.useCallback(t=>{const i=He[t.path];if(i)return i;if(et==="inline")return"inline";if(et==="side-by-side")return"side-by-side";const l=I<qs;return t.isNew||l?"inline":"side-by-side"},[He,et,I]),en=r.useMemo(()=>D.length===0?null:D.every(t=>Tt(t)==="side-by-side")?"side-by-side":"inline",[D,Tt]);r.useEffect(()=>{o&&f&&(X(f),ue(f,j))},[f,X,ue,j,o]);const jt=JSON.stringify([E,f]),Lt=r.useRef({scope:jt,paths:new Set,dirty:!1,unscoped:!1}),tn=r.useRef(o);r.useEffect(()=>{const t=o&&!tn.current;if(tn.current=o,Lt.current.scope!==jt&&(Lt.current={scope:jt,paths:new Set,dirty:!1,unscoped:!1}),!f)return;const i=(d,h)=>{d.length&&(Le.current=Z()??he.current,ye(f,d),ct(F=>{const R=new Map(F);for(const B of d)R.set(B,(R.get(B)??0)+1);return R})),h&&Ft(F=>F+1),xe(f,j,{silent:!0})},l=Lt.current;return o&&(t||l.dirty)&&(i([...l.paths],l.unscoped),l.paths.clear(),l.dirty=!1,l.unscoped=!1),yn.onGitRefreshHint(d=>{if(hn(d.directory)!==hn(f))return;const h=d.paths??[],F=h.length===0;if(!o){l.dirty=!0,l.unscoped||=F;for(const R of h)l.paths.add(R);return}i(h,F)})},[Z,ye,f,xe,j,jt,o]),r.useLayoutEffect(()=>{const t=Le.current;if(!t)return;Le.current=null;const i=oe.current,l=Ee.current.get(t.path);if(!i||!l)return;const d=i.getBoundingClientRect().top,h=l.getBoundingClientRect().top-d;i.scrollTop=Hs(i.scrollTop,t.topOffset,h,i.scrollHeight-i.clientHeight),he.current=t},[Ke]),r.useEffect(()=>{!o||c!=="all"&&!Ae||ie&&(Ae&&De(Ae),te(ie),$(Ae==="staged"||!Ae&&we),We(null),Te.current=!0,be.current=ie,Ne(ie),Oe(t=>t+1))},[c,Ne,ie,Ae,we,We,o]),r.useEffect(()=>{if(c==="all")return;const t=k?.trim();t&&(te(t),$(c==="staged"),Te.current=!0,be.current=t,Ne(t),Oe(i=>i+1))},[c,Ne,k]),r.useEffect(()=>{if(!_)return;D.some(i=>i.path===_)||(te(null),$(!1))},[D,_]);const _n=r.useCallback((t,i)=>{const l=Ee.current;i?l.set(t,i):l.delete(t),ge()},[ge]),zn=r.useCallback((t,i)=>{Ve(),A(l=>{const d=l.has(t);if(i===d)return l;const h=new Set(l);return i?h.add(t):h.delete(t),h}),i||H(l=>{if(!l.has(t))return l;const d=new Set(l);return d.delete(t),d}),ge()},[Ve,ge]),On=r.useCallback(()=>{Ve(),A(t=>t.size>0?new Set:new Set(D.map(i=>i.path))),H(new Set),ge()},[Ve,D,ge]),Kn=r.useCallback(async t=>{if(!pe)return;const i=an.getState().getDirectoryForSession(pe)||p||"";if(!i){Ye.error(a("diffView.reviewDialog.toast.noSessionDirectory"));return}Ge(!0);try{await Cs({originalSessionID:pe,directory:i,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),$e(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ye.error(l instanceof Error?l.message:a("diffView.reviewDialog.toast.startFailed"))}finally{Ge(!1)}},[pe,p,a]),kt=r.useCallback(t=>{const i=Ee.current.get(t),l=oe.current;if(!i||!l)return!1;const d=i.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+d,behavior:"auto"}),!0},[]);r.useEffect(()=>{const t=be.current;if(!o||!t)return;let i=0;const l=20;let d=!1;const h=(R=!0)=>{d||(d=!0,be.current=null,Te.current=!1,R&&T(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null))},F=()=>{if(d){q.current=null;return}const R=be.current;if(!R){h(),q.current=null;return}if(!kt(R)){i+=1,i<l?q.current=window.requestAnimationFrame(F):(h(),q.current=null);return}if(u&&Te.current){T(R),h(!1);return}h()};return q.current=window.requestAnimationFrame(F),()=>{d=!0,q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)}},[u,xt,kt,o]);const $n=r.useCallback(t=>{},[]),ve=G==="tree"&&!Ue,Gn=Q(t=>t.diffFileTreeWidth),St=Q(t=>t.setDiffFileTreeWidth),nn=r.useRef(null),[Wn,sn]=r.useState(!1),mt=Math.max(Gn,Bt),Nt=r.useCallback(t=>{const i=Math.max(Bt,(nn.current?.clientWidth??0)*ir);return Math.min(i,Math.max(Bt,t))},[]),Hn=r.useCallback(t=>{t.preventDefault();const i=t.clientX,l=mt;sn(!0);const d=F=>{St(Nt(l+F.clientX-i))},h=()=>{sn(!1),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},[Nt,mt,St]),qn=r.useCallback(t=>{const i=t.shiftKey?40:10,l=t.key==="ArrowLeft"?-i:t.key==="ArrowRight"?i:0;l!==0&&(t.preventDefault(),St(Nt(mt+l)))},[Nt,mt,St]),Vt=r.useMemo(()=>ve?bn(D,new Set).flatMap(t=>t.kind==="file"?[t.file]:[]):[],[D,ve]),pt=ve?Vt:D,ht=ve?Vt.find(t=>t.path===_)??Vt[0]??null:null,Ct=r.useCallback(t=>{if(Ve(),ve){te(t),$(!1),Ne(t),oe.current?.scrollTo({top:0});return}te(t),$(!1),Te.current=!0,be.current=t,Ne(t),Oe(i=>i+1),kt(t)},[Ve,Ne,ve,kt]);r.useEffect(()=>{const t=i=>{if(!o||!i.altKey||i.metaKey||i.ctrlKey||i.shiftKey||i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const l=i.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||pt.length===0)return;const d=i.key==="ArrowDown"?1:-1,h=ve?ht?.path:_,F=h?pt.findIndex(Y=>Y.path===h):-1,R=F===-1?d>0?0:pt.length-1:F+d,B=pt[R];B&&(i.preventDefault(),Ct(B.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[_,Ct,ve,pt,ht,o]);const Un=r.useCallback(t=>{const i=t==="side-by-side"?"side-by-side":"inline";D.forEach(l=>{Se(l.path,i)})},[D,Se]),[Xn,rn]=r.useState(null),Jn=r.useCallback(async(t,i)=>{if(!f||!t)return;rn(t);const l=Re();try{let d=null;if(i?.patch&&!i.isBinary&&!lt(t)?d=cn(i.patch):i&&i.contextMode==="full"&&!i.isBinary&&!lt(t)&&(d=gn(i.original,i.modified)),d===null)try{const Y=await j.getGitDiff(f,{path:t,staged:qe,contextLines:3});d=cn(Y.diff)}catch{d=null}let h=i;if(d===null||!h){const Y=await j.getGitFileDiff(f,{path:t,staged:qe}),gt={original:Y.original??"",modified:Y.modified??"",isBinary:Y.isBinary,submodule:Y.submodule};h=gt,qe||ee(f,t,gt,l)}const F=d??(h.isBinary||lt(t)?1:gn(h.original,h.modified)),R=tr(f,t),B=await Ps(N,R,{directory:f});if(!B.ok){Ye.error(_s(B.reason));return}me(f,R,F,1)}finally{rn(d=>d===t?null:d)}},[qe,f,N,j,me,ee]),Yn=()=>{if(!f)return null;const t=(l,d=!1)=>n.jsx(cr,{visible:o,directory:f,file:l,layout:Tt(l),wrapLines:nt,isSelected:!1,isExpanded:d||W.has(l.path),isMounted:d||de.has(l.path)||l.path===ke,onSelect:$n,onExpandedChange:zn,registerSectionRef:_n,showOpenInEditorAction:g&&c!=="turn",isOpeningInEditor:Xn===l.path,onOpenInEditor:(h,F)=>{Jn(h,F)},staged:i(l.path),readOnlyActions:c==="branch"||c==="commit"||c==="pr",hunkActionsEnabled:c==="all"||c==="working"||c==="staged",contentRevision:yt,comparisonDiff:c==="branch"||c==="commit"||c==="pr"?In.get(l.path)??fn:void 0,onRetryComparisonDiff:()=>Ln(h=>h+1),loadFullComparisonDiff:Bn,initialDiffData:c==="turn"?L.get(l.path)??null:null},`${Re()}:${f}:${l.path}:${Ke.get(l.path)??0}`),i=l=>st!==null?st:ne&&l===_;return n.jsxs("div",{ref:nn,className:le("flex min-w-0 flex-1 min-h-0 h-full",v?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ve&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${mt}px`},children:n.jsx(or,{changedFiles:D,selectedFile:ht?.path??null,onSelectFile:Ct})}),n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("diffView.fileTree.resize"),tabIndex:0,onPointerDown:Hn,onKeyDown:qn,className:le("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Wn&&"bg-interactive-selection")})]}),bt&&!ve&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:a("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:D.length})]}),n.jsx(rr,{changedFiles:D,selectedFile:null,onSelectFile:Ct})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(zt,{ref:oe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:ve?ht&&t(ht,!0):D.map(l=>t(l))})})})]})},Qn=()=>{if(!f)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a("diffView.state.selectSessionDirectory")});if(c!=="turn"&&K&&!y)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingRepositoryStatus")]});if(c!=="turn"&&U===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a("diffView.state.notGitRepository")});if(c==="pr"){if(!Pe||P.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:P.error??Ie.error??(Ie.loading?a("session.githubPrPicker.loading.pullRequests"):a("pullRequestComparison.select"))}),(P.error||Ie.error)&&n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{Pe?P.refresh():Ie.refresh()},children:a("diffView.actions.retry")}),!Pe&&!Ie.loading&&n.jsx(on,{comparison:Ie})]});if(!P.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingDiff")]})}if(c==="commit"){if(Xt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:Xt}),n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{P.refresh()},children:a("diffView.actions.retry")})]});if(!Je&&!_e.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:_e.error??a("commitComparison.noCommits")});if(!Ut)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingDiff")]})}if(c==="branch"){if(!En)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.branch.resolvingBase")]});if(!Ce)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(O,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:a("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:a("gitView.pr.toast.baseBranchRequired")})]});if(Jt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:a("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Jt}),n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{P.refresh()},children:a("diffView.actions.retry")})]});if(vt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.branch.loadingFiles")]})}return D.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c==="turn"?a("diffView.state.noLastTurnChanges"):c==="pr"?a("walkthrough.blocked.emptyDiff.description"):c==="commit"?a("commitComparison.emptyDiff"):c==="branch"&&Ce?a("diffView.branch.empty",{base:Ms(Ce)}):a("diffView.state.cleanWorkingTree")}):Yn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[b===!1&&Array.isArray(V)&&V.length>0?n.jsx(Vs,{repositories:V,selectedRepository:C??null,onSelectRepository:t=>{p&&se(p,t)},repositoryRoot:p??void 0}):null,!ce&&(c!=="all"?n.jsx(sr,{scope:c,workingCount:ft,stagedCount:Be,turnCount:Xe,branchCount:Pn,commitCount:c==="commit"?Ut?.length??null:null,prCount:c==="pr"?P.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:$t,onScopeChange:t=>{De(t),w?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:K&&!y?a("diffView.state.loadingChanges"):D.length===1?a("diffView.summary.changedFilesSingle",{count:D.length}):a("diffView.summary.changedFilesPlural",{count:D.length})})})),c==="branch"&&n.jsx(is,{branches:ot?.all??[],currentBranch:J,base:Ce,onSelect:t=>{f&&J&&An(f,J,t)}},JSON.stringify([f,J])),c==="commit"&&n.jsx(os,{commits:_e.commits,selectedHash:Je,loading:_e.loading,error:_e.error,onSelect:_e.select,onRefresh:()=>{_e.refresh()}},JSON.stringify([f,J])),c==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(on,{comparison:Ie},JSON.stringify([E,f,J])),Pe&&n.jsx(je,{variant:"ghost",size:"sm",disabled:P.loading,"aria-label":a("session.githubIssuePicker.actions.refresh"),title:a("session.githubIssuePicker.actions.refresh"),onClick:()=>{P.refresh()},children:n.jsx(O,{name:"refresh",className:"size-4"})})]}),D.length>0&&n.jsxs(je,{variant:"ghost",size:"sm",onClick:On,className:le("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:W.size>0?a("diffView.actions.collapseAll"):a("diffView.actions.expandAll"),children:[n.jsx(O,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:W.size>0?a("diffView.actions.collapseAll"):a("diffView.actions.expandAll")})]}),D.length>0&&Rt&&n.jsxs(je,{variant:"default",size:"sm",onClick:()=>$e(!0),disabled:Ze,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":a("diffView.actions.reviewAria"),children:[Ze?n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(O,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:a("diffView.actions.review")})]}),D.length>0&&rt&&n.jsxs(je,{variant:"outline",size:"sm",onClick:()=>{const t=f??"";M(t,c==="pr"&&Pe?Pe:c==="commit"&&Je?{kind:"commit",hash:Je}:c==="branch"&&Ce&&J?{kind:"branch",baseRef:Ce,headRef:J}:{kind:"working-tree",scope:c==="staged"||c==="working"?c:"all"}),S(p??t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",zs),"aria-label":a("walkthrough.action.open"),children:[n.jsx(O,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}),D.length>0&&!Ue&&n.jsx(je,{variant:"ghost",size:"sm",onClick:()=>wt(G==="tree"?"flat":"tree"),"aria-pressed":G==="tree",className:le("h-5 w-5 p-0 transition-opacity",G==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:a(G==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:n.jsx(O,{name:"node-tree",className:"size-4"})}),D.length>0&&n.jsx(je,{variant:"ghost",size:"sm",onClick:()=>tt(!fe),className:le("h-5 w-5 p-0 transition-opacity",nt?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:a(nt?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(O,{name:"text-wrap",className:"size-4"})}),en&&n.jsx(wn,{mode:en==="side-by-side"?"side-by-side":"unified",onModeChange:Un})]}),n.jsx(Fs,{open:ut,onOpenChange:$e,projectDirectory:f??null,submitting:Ze,onConfirm:Kn}),Qn()]})};function ur(){return new Set}function dr(o,e){return n.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 w-px bg-border/50",style:{left:`${Nn+e*Sn+7}px`}},e)}function fr(o){return Array.from({length:o},dr)}export{Vo as DiffView,cr as MultiFileDiffEntry};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as Re,R as i,c as Ei,j as r,r as ht}from"./vendor-react-BUCujlKS.js";import{a as tt,h as en,Z as Mo,_ as Do,$ as zo,a0 as Lo,x as et,u as mt,eb as Ao,J as Vi,C as Io,a4 as Pi,e8 as Oo,e as Bo,e9 as $o,a3 as _o,ea as Wo}from"./index-Di6zUe5h.js";import{f as st,z as Mi,ai as sa,cf as Uo,h as W,kI as Ko,g8 as Ho,X as Cs,B as I,I as E,kJ as qo,aA as Ns,gZ as Go,gX as Xo,_ as Jo,T as Zo,bj as Yo,K as Qo,ak as el,cA as tl,eI as Di,iD as sl,gu as rl,t as re,l as zi,ay as Kr,ct as bs,da as nl,b as il,kK as ys,c1 as al,az as Hr,kL as qr,cu as Li,cv as Ai,kM as Ii,kN as Oi,kO as ol,kP as ll,kQ as cl,hE as ul,kR as dl,kS as fl,kT as ml,c2 as ra,c3 as na,c4 as ia,c5 as aa,c6 as oa,c7 as la,as as tn,at as sn,av as rn,bh as ur,c8 as Gr,aB as ar,cp as Xr,ae as Mt,af as Dt,ag as zt,b$ as hl,c0 as pl,g as fr,bi as gl,cz as xl}from"./useAppFontEffects-
|
|
1
|
+
import{f as Re,R as i,c as Ei,j as r,r as ht}from"./vendor-react-BUCujlKS.js";import{a as tt,h as en,Z as Mo,_ as Do,$ as zo,a0 as Lo,x as et,u as mt,eb as Ao,J as Vi,C as Io,a4 as Pi,e8 as Oo,e as Bo,e9 as $o,a3 as _o,ea as Wo}from"./index-Di6zUe5h.js";import{f as st,z as Mi,ai as sa,cf as Uo,h as W,kI as Ko,g8 as Ho,X as Cs,B as I,I as E,kJ as qo,aA as Ns,gZ as Go,gX as Xo,_ as Jo,T as Zo,bj as Yo,K as Qo,ak as el,cA as tl,eI as Di,iD as sl,gu as rl,t as re,l as zi,ay as Kr,ct as bs,da as nl,b as il,kK as ys,c1 as al,az as Hr,kL as qr,cu as Li,cv as Ai,kM as Ii,kN as Oi,kO as ol,kP as ll,kQ as cl,hE as ul,kR as dl,kS as fl,kT as ml,c2 as ra,c3 as na,c4 as ia,c5 as aa,c6 as oa,c7 as la,as as tn,at as sn,av as rn,bh as ur,c8 as Gr,aB as ar,cp as Xr,ae as Mt,af as Dt,ag as zt,b$ as hl,c0 as pl,g as fr,bi as gl,cz as xl}from"./useAppFontEffects-Cfuya0Zd.js";import{l as vl,az as wl,ay as bl,Z as yl,_ as jl,$ as Nl,a0 as Sl,a1 as Cl}from"./runtimeEndpointReset-BsoTecOZ.js";import{c as Bi,s as Fl,P as js,C as kl}from"./shikiHighlight-U-ER5VqY.js";import{a as Rl}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Lt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Tl,J as El,F as Vl}from"./JsonTreeView-pYH8Escm.js";import{ensurePierreThemeRegistered as $i,getResolvedShikiTheme as Pl}from"./appThemeRegistry-CF0I57r1.js";import{V as Ml,W as Dl}from"./Virtualizer-CZlLSacm.js";import{V as zl}from"./Virtualizer-D_a8gKmg.js";import{D as Ll}from"./vendor-react-drawio-Ct3Q0DsD.js";import{a as Al,u as or,b as Il,g as Ol,h as Bl}from"./scheduledTasksApi-Dahv3ws0.js";import{I as $l,u as _l,n as Wl}from"./useInlineCommentController-GbLdwSYb.js";import{b as Ul}from"./CodeMirrorCommentWidgets-C55OCQB7.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CcqLCIWH.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CdC8RfDh.js";import"./PluginPane-DJgKVT9D.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-BWh2SieS.js";import"./computeVirtualFileMetrics-CcxmuPAX.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-D7OOnOq1.js";import"./textMateThemeFromAppTheme-CFZUMoyT.js";function _i(n){const e=Re.c(41),{containerRef:s,filePath:a,fileContent:w}=n,{t:f}=st(),v=Mi(Yl),d=Mi(Zl),x=sa(),p=Uo(Jl),[m,b]=i.useState(null),[y,F]=i.useState(""),[N,S]=i.useState(!1),g=i.useRef(!1),l=i.useRef(null),T=i.useRef(null),[R,M]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(null),F(""),S(!1),g.current=!1,T.current=null,M(null)},e[0]=D):D=e[0];const A=D;let k,V;e[1]!==s?(k=()=>{const K=s.current;if(!K)return;const ie=()=>{if(g.current)return;const ae=window.getSelection(),fe=ae?.toString().trim()??"";if(!ae||!fe||ae.rangeCount===0){A();return}const me=ae.getRangeAt(0);if(!K.contains(me.commonAncestorContainer)){A();return}const le=me.getBoundingClientRect();T.current=me.cloneRange(),F(fe),b({x:le.left+le.width/2,y:le.top-10})},_=ae=>{l.current?.contains(ae.target)||g.current&&A()};return document.addEventListener("selectionchange",ie),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",ie),document.removeEventListener("pointerdown",_)}},V=[s,A],e[1]=s,e[2]=k,e[3]=V):(k=e[2],V=e[3]),i.useEffect(k,V);let z;e[4]!==w?(z=K=>{const ie=he=>w.slice(0,he).split(`
|
|
2
2
|
`).length,_=Gl,ae=(he,ve)=>{for(const Ee of _(he)){const ye=w.indexOf(Ee,ve);if(ye>=0)return ye}return-1},fe=K.length>=8?w.indexOf(K):-1;if(fe>=0){const he=ie(fe);return{start:he,end:he+K.split(`
|
|
3
3
|
`).length-1}}const me=K.split(`
|
|
4
4
|
`).map(ql).filter(Boolean);if(me.length===0)return null;const le=ae(me[0],0);if(le<0)return null;const be=ie(le);if(me.length===1)return{start:be,end:be};const xe=ae(me[me.length-1],le);return xe<0?null:{start:be,end:Math.max(be,ie(xe))}},e[4]=w,e[5]=z):z=e[5];const B=z;let U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{const K=T.current;if(!K){M(null);return}M(Ko(K))},e[6]=U):U=e[6];const Y=U;let te,ee;e[7]!==N?(te=()=>{if(!N)return;let K=null;const ie=()=>{K===null&&(K=window.requestAnimationFrame(()=>{K=null,Y()}))};return document.addEventListener("scroll",ie,{capture:!0,passive:!0}),window.addEventListener("resize",ie),()=>{K!==null&&window.cancelAnimationFrame(K),document.removeEventListener("scroll",ie,{capture:!0}),window.removeEventListener("resize",ie)}},ee=[N,Y],e[7]=N,e[8]=te,e[9]=ee):(te=e[8],ee=e[9]),i.useEffect(te,ee);let G;e[10]!==y?(G=()=>{y&&(S(!0),g.current=!0,Y(),window.getSelection()?.removeAllRanges())},e[10]=y,e[11]=G):G=e[11];const X=G;let J;e[12]!==p||e[13]!==v||e[14]!==x||e[15]!==a||e[16]!==d||e[17]!==B||e[18]!==y?(J=K=>{const ie=v??(d?"draft":null);if(!y||!ie||!x){A();return}const _=B(y);p({directory:x,sessionKey:ie},{source:"file-quote",fileLabel:a,startLine:_?.start??0,endLine:_?.end??0,code:y,language:"",text:K.trim()}),A(),queueMicrotask(Hl)},e[12]=p,e[13]=v,e[14]=x,e[15]=a,e[16]=d,e[17]=B,e[18]=y,e[19]=J):J=e[19];const q=J;if(!m)return null;let Q;e[20]!==N||e[21]!==B||e[22]!==y?(Q=N?B(y):null,e[20]=N,e[21]=B,e[22]=y,e[23]=Q):Q=e[23];const _e=Q;let ne;e[24]!==m.x||e[25]!==m.y?(ne={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=ne):ne=e[26];let Te;e[27]!==N||e[28]!==R?(Te=N&&R&&R.length>0?Ei.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:R.map(Kl)}),document.body):null,e[27]=N,e[28]=R,e[29]=Te):Te=e[29];let De;e[30]!==N||e[31]!==a||e[32]!==_e||e[33]!==X||e[34]!==q||e[35]!==f?(De=N?r.jsx("div",{className:"w-[min(420px,80vw)]",children:r.jsx($l,{fileLabel:a,lineRange:_e?{start:_e.start,end:_e.end}:void 0,onSave:q,onCancel:A})}):r.jsx("div",{className:W("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:r.jsx("button",{type:"button",onClick:X,className:W("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:f("chat.textSelection.actions.comment")})}),e[30]=N,e[31]=a,e[32]=_e,e[33]=X,e[34]=q,e[35]=f,e[36]=De):De=e[36];let ze;return e[37]!==ne||e[38]!==Te||e[39]!==De?(ze=Ei.createPortal(r.jsxs("div",{ref:l,className:"fixed z-50",style:ne,children:[Te,De]}),document.body),e[37]=ne,e[38]=Te,e[39]=De,e[40]=ze):ze=e[40],ze}function Kl(n,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:n.left,top:n.top,width:n.width,height:n.height}},e)}function Hl(){Ho()}function ql(n){return n.trim()}function Gl(n){const e=n.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Xl)}function Xl(n){return n.length>=8}function Jl(n){return n.addDraft}function Zl(n){return n.newSessionDraft?.open}function Yl(n){return n.currentSessionId}const Ql=(n,e)=>{if(!e)return null;const s=Number.parseInt(n.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,e.state.doc.lines)},Wi=(n,e)=>{const s=n.state.doc.lineAt(e.main.head);return{lineNumber:s.number,character:e.main.head-s.from+1,selection:e}},Ui=(n,e,s)=>{const a=n.state.doc.line(e),w=Math.max(1,Math.min(s,a.length+1)),f=a.from+w-1;n.dispatch({selection:Rl.cursor(f),effects:Lt.scrollIntoView(f,{y:"center"})})};function ec({open:n,onOpenChange:e,view:s,variant:a="overlay"}){const{t:w}=st(),[f,v]=i.useState(""),d=i.useRef(null),x=i.useRef(!1),p=i.useRef(null),m=i.useRef(null),b=i.useMemo(()=>Ql(f,s),[f,s]);i.useEffect(()=>{!n||!s||(x.current=!1,d.current=Wi(s,s.state.selection),v(""))},[n,s]),i.useEffect(()=>{n&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[n]),i.useEffect(()=>{if(!(!n||!s||!d.current)){if(b===null){const{selection:g}=d.current;s.dispatch({selection:g,effects:Lt.scrollIntoView(g.main.from,{y:"center"})});return}Ui(s,b,d.current.character)}},[b,n,s]);const y=i.useCallback(()=>{if(!s||x.current||!d.current)return;const{selection:g}=d.current;s.dispatch({selection:g,effects:Lt.scrollIntoView(g.main.from,{y:"center"})})},[s]),F=i.useCallback(g=>{g||y(),e(g)},[e,y]),N=i.useCallback(()=>{!s||b===null||!d.current||(x.current=!0,Ui(s,b,d.current.character),e(!1),s.focus())},[b,e,s]);i.useEffect(()=>{if(!n)return;const g=T=>{const R=p.current,M=T.target;!R||!(M instanceof Node)||R.contains(M)||F(!1)},l=T=>{T.key==="Escape"&&(T.preventDefault(),F(!1))};return document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",l,!0)}},[F,n,a]);const S=i.useMemo(()=>{if(!s)return w("goToLineDialog.helper.editorUnavailable");if(b===null){const g=d.current??Wi(s,s.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:g.lineNumber,max:s.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:b})},[b,w,s]);return a==="inline"?n?r.jsxs("div",{ref:p,className:"ml-1 flex h-6 items-center gap-1",children:[r.jsx(Cs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:g=>v(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),r.jsx(I,{variant:"outline",size:"xs",onClick:N,disabled:!s||b===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:r.jsx("div",{ref:p,className:W("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",n?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(Cs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:g=>v(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:S})]})})}const tc=(n,e)=>{const s=e.trim().toLowerCase(),a=[];if(!s)return a;const w=n.toLowerCase();let f=0;for(;;){const v=w.indexOf(s,f);if(v===-1)break;a.push({start:v,end:v+s.length}),f=v+s.length}return a},mr="data-md-find",Jr="data-md-find-current",ca="rounded-[2px] bg-status-warning/30 text-foreground",sc="rounded-[2px] bg-status-warning/60 text-foreground",rc=120,nc=n=>n instanceof Element&&n.hasAttribute(mr),ic=n=>n.target instanceof Element&&n.target.hasAttribute(mr)?!0:[...n.addedNodes].some(e=>nc(e)),ua=n=>{const e=new Set;n.querySelectorAll(`mark[${mr}]`).forEach(s=>{const a=s.parentNode;a&&(a.replaceChild(document.createTextNode(s.textContent??""),s),e.add(a))}),e.forEach(s=>s.normalize())},ac=(n,e)=>{ua(n);const s=e.trim().toLowerCase();if(!s)return[];const a=[],w=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(v){const d=v.parentElement;return!d||d.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),f=[];for(;w.nextNode();){const v=w.currentNode;v instanceof Text&&f.push(v)}for(const v of f){const d=v.nodeValue??"";if(!d)continue;const x=tc(d,s);if(x.length===0)continue;const p=v.parentNode;if(!p)continue;const m=document.createDocumentFragment();let b=0;for(const y of x){y.start>b&&m.appendChild(document.createTextNode(d.slice(b,y.start)));const F=document.createElement("mark");F.setAttribute(mr,""),F.className=ca,F.textContent=d.slice(y.start,y.end),m.appendChild(F),a.push(F),b=y.end}b<d.length&&m.appendChild(document.createTextNode(d.slice(b))),p.replaceChild(m,v)}return a},Ki=({containerRef:n,open:e,onOpenChange:s,focusNonce:a,className:w})=>{const{t:f}=st(),[v,d]=i.useState(""),[x,p]=i.useState(0),[m,b]=i.useState(0),y=i.useRef(null),F=i.useRef([]),N=i.useRef(v);N.current=v;const S=i.useRef(null),g=i.useRef(null),l=i.useCallback((k,V=!1)=>{const z=n.current;if(!z){F.current=[],p(0),b(0);return}F.current=ac(z,k);const B=F.current.length;p(B),b(U=>!V||B===0?0:Math.min(U,B-1))},[n]),T=i.useCallback((k,V=!1)=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,l(k,V)},rc)},[l]);i.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const R=i.useCallback(()=>{s(!1);const k=g.current;g.current=null,k?.isConnected&&k.focus()},[s]);i.useEffect(()=>{const k=n.current;if(!e||!k)return;const V=new MutationObserver(z=>{!N.current.trim()||!z.some(U=>!ic(U))||T(N.current,!0)});return V.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{V.disconnect(),ua(k)}},[n,e,T]),i.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!g.current&&(g.current=k),y.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(y.current?.focus(),y.current?.select())},[e,a]),i.useEffect(()=>{const k=n.current;if(!k||(k.querySelectorAll(`mark[${Jr}]`).forEach(z=>{z.removeAttribute(Jr),z.className=ca}),x===0))return;const V=F.current[Math.min(Math.max(m,0),x-1)];V&&(V.setAttribute(Jr,""),V.className=sc,V.scrollIntoView({block:"nearest"}))},[n,m,x]);const M=i.useCallback(()=>{b(k=>x===0?0:(k+1)%x)},[x]),D=i.useCallback(()=>{b(k=>x===0?0:(k-1+x)%x)},[x]),A=i.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?D():M()):k.key==="Escape"&&(k.preventDefault(),R())},[R,M,D]);return e?r.jsxs("div",{className:W("absolute right-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",w),children:[r.jsx(E,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),r.jsx(Cs,{ref:y,value:v,onChange:k=>{d(k.target.value),T(k.target.value)},onKeyDown:A,placeholder:f("filesView.preview.find.placeholder"),"aria-label":f("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),r.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":x>0?f("filesView.preview.find.countAria",{current:m+1,total:x}):f("filesView.preview.find.noMatches"),children:v.trim()&&x===0?f("filesView.preview.find.noMatches"):x>0?`${m+1}/${x}`:""}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-up",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:f("filesView.preview.find.nextAria"),"aria-label":f("filesView.preview.find.nextAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-down",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:R,title:f("filesView.preview.find.closeAria"),"aria-label":f("filesView.preview.find.closeAria"),children:r.jsx(E,{name:"close",className:"size-3.5"})})]}):null},oc=n=>{let e=!0;return{poll:async()=>{if(!e||n.isDirty())return!1;const s=n.getLoadedContent(),a=n.getLoadedRevision();try{const w=await n.readContent();if(!e||n.isDirty()||a!==n.getLoadedRevision())return!1;if(w===s)return!0;const f=await n.readContent();return!e||n.isDirty()||f!==w||a!==n.getLoadedRevision()?!1:(n.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},lc=1,cc=(n,e)=>e.size!==n.size||e.mtimeMs!==void 0&&n.mtimeMs!==void 0&&Math.abs(e.mtimeMs-n.mtimeMs)>=lc;function Hi(){const n=Re.c(8),[e]=ht.useState(uc),s=ht.useRef(!1);let a;n[0]!==e?(a=x=>{if(x==null){e.cleanUp(),s.current=!1;return}s.current||(s.current=!0,e.setup(x,x.firstElementChild??void 0))},n[0]=e,n[1]=a):a=n[1];const w=a;let f,v;n[2]!==e?(f=()=>()=>{s.current=!1,e.cleanUp()},v=[e],n[2]=e,n[3]=f,n[4]=v):(f=n[3],v=n[4]),ht.useLayoutEffect(f,v);let d;return n[5]!==w||n[6]!==e?(d={virtualizer:e,setScroller:w},n[5]=w,n[6]=e,n[7]=d):d=n[7],d}function uc(){return new zl}const rs=new Map,dc=100;function lr(n){const[e,s]=ht.useState(null),a=ht.useRef(null),w=ht.useRef(null),f=ht.useRef(null),v=ht.useCallback((d,x)=>{d&&x instanceof Tl&&(f.current={key:n,file:x,node:d});const p=a.current,m=w.current,b=()=>{a.current===p&&(p?.(),m?.())};x?queueMicrotask(b):b()},[n]);return ht.useLayoutEffect(()=>{if(!e||!n)return;const d=rs.get(n)??{top:0,left:0};let x=!0;const p=()=>f.current?.key===n?f.current.file:null,m=l=>f.current?.key===n?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${l-1}"]`):null,b=()=>{F.disconnect(),N.disconnect()},y=()=>{if(!x)return;const l=p(),T=d.line&&l?.getLinePosition(d.line.number),R=d.line&&m(d.line.number);let M=d.top;d.line&&T&&(M=(l?.top??0)+T.top-d.line.offset),d.line&&R&&(M=e.scrollTop+R.getBoundingClientRect().top-e.getBoundingClientRect().top-d.line.offset),e.scrollTop=M,e.scrollLeft=d.left,(!d.line||R)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-d.left)<1&&(x=!1,b())},F=new ResizeObserver(y),N=new MutationObserver(()=>{if(x){for(const l of e.children)F.observe(l);y()}});F.observe(e);for(const l of e.children)F.observe(l);N.observe(e,{childList:!0,subtree:!0});const S=()=>{if(x)return;const l=p(),T=l?.getNumericScrollAnchor(e.scrollTop-(l.top??0)),R=T&&m(T.lineNumber),M=R?R.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(rs.delete(n),rs.set(n,{top:e.scrollTop,left:e.scrollLeft,line:T&&M!==null&&M>=0&&M<e.clientHeight?{number:T.lineNumber,offset:M}:void 0}),rs.size>dc){const D=rs.keys().next().value;D!==void 0&&rs.delete(D)}},g=()=>{x=!1,b()};return a.current=y,w.current=S,y(),e.addEventListener("scroll",S,{passive:!0}),e.addEventListener("wheel",g,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("pointerdown",g,{passive:!0}),e.addEventListener("keydown",g),()=>{a.current=null,w.current=null,f.current?.key===n&&(f.current=null),b(),e.removeEventListener("scroll",S),e.removeEventListener("wheel",g),e.removeEventListener("touchstart",g),e.removeEventListener("pointerdown",g),e.removeEventListener("keydown",g)}},[n,e]),{setScroller:s,restore:v}}function fc(n){return!(!n.autoSaveEnabled||!n.isDirty||!n.canWrite||n.isSaving||n.fileLoading||n.isNonEditableBinary||!n.selectedFilePath||n.loadedFilePath!==n.selectedFilePath)}function mc(n){return n.selectedFilePath?n.isDirty?!(n.fileLoading||n.loadedFilePath!==n.selectedFilePath||n.isNonEditableBinary||n.draftContent===""&&n.fileContent!==""&&n.loadedFilePath!==n.selectedFilePath):!0:!1}const da=2e5,hc=n=>{let e=0,s=0;for(let a=0;a<n.length;a++)n.charCodeAt(a)===10&&(a>0&&n.charCodeAt(a-1)===13?e++:s++);return e>s?`\r
|