@openchamber/web 1.18.4 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
- package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-C-F3AX6D.js} +1 -1
- package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-BPECg1jS.js} +1 -1
- package/dist/assets/DiagramView-D0YNMix8.js +1 -0
- package/dist/assets/DiffView-BHWaMYCC.js +4 -0
- package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
- package/dist/assets/{GitView-DBFrDDBv.js → GitView-Rp8P1KEI.js} +4 -4
- package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-KnXFN2A-.js} +1 -1
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +1 -0
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
- package/dist/assets/OnboardingScreen-CenIeD4v.js +1 -0
- package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-BzVOVog8.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
- package/dist/assets/PlanView-Czu1KMJa.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
- package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
- package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
- package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
- package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
- package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-CaSYE0lw.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +1 -0
- package/dist/assets/de-DFdX3ABv.js +9 -0
- package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
- package/dist/assets/es-iC-FKvV9.js +15 -0
- package/dist/assets/fr-BBbi_1AL.js +13 -0
- package/dist/assets/index-BiEgzzkg.js +1 -0
- package/dist/assets/index-Cwmuwk3V.js +7 -0
- package/dist/assets/index-GNm1wgUH.css +1 -0
- package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-BG53Ixxy.js} +1 -1
- package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-BbV-39jl.js} +1 -1
- package/dist/assets/ja-DQLQJL2J.js +15 -0
- package/dist/assets/ko-BeElEB4Y.js +15 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-Dpzo18z7.js +2 -0
- package/dist/assets/main-WMjtYzJs.js +921 -0
- package/dist/assets/markdownCore--tDmyI_v.js +2 -0
- package/dist/assets/miniChat-ldEghBLB.js +2 -0
- package/dist/assets/mobile-Dk-VGreF.js +2 -0
- package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BcFaMtMu.js} +1 -1
- package/dist/assets/pl-CLHt2_vV.js +15 -0
- package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
- package/dist/assets/renderMobileApp-CDfHS5rr.js +25 -0
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +1 -0
- package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DCT2Sq_z.js} +1 -1
- package/dist/assets/uk-PhsC-c4-.js +15 -0
- package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-B53Rb6m7.js} +168 -164
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
- package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-DsHmyMwp.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
- package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
- package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
- package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
- package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
- package/dist/assets/{web-components-GMc3oR3i.js → web-components-pcwCTWjC.js} +4 -4
- package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
- package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
- package/dist/index.html +5 -4
- package/dist/mini-chat.html +4 -3
- package/dist/mobile.html +4 -3
- package/package.json +3 -5
- package/server/index.js +152 -3
- package/server/lib/agent-memory/actions.js +243 -0
- package/server/lib/agent-memory/actions.test.js +343 -0
- package/server/lib/agent-memory/feature-flag.js +19 -0
- package/server/lib/agent-memory/feature-flag.test.js +38 -0
- package/server/lib/agent-memory/project-resolution.js +65 -0
- package/server/lib/agent-memory/project-resolution.test.js +94 -0
- package/server/lib/agent-memory/routes.http.test.js +270 -0
- package/server/lib/agent-memory/routes.js +169 -0
- package/server/lib/agent-memory/runtime.js +432 -0
- package/server/lib/agent-memory/runtime.test.js +344 -0
- package/server/lib/agent-memory/threat-patterns.js +61 -0
- package/server/lib/agent-memory/threat-patterns.test.js +61 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
- package/server/lib/agent-tool/runtime.js +63 -13
- package/server/lib/agent-tool/runtime.test.js +85 -2
- package/server/lib/context-obligatory/runtime.js +34 -3
- package/server/lib/context-obligatory/runtime.test.js +114 -0
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +149 -32
- package/server/lib/fs/routes.test.js +301 -0
- package/server/lib/git/DOCUMENTATION.md +8 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +206 -72
- package/server/lib/git/service.test.js +222 -0
- package/server/lib/github/DOCUMENTATION.md +14 -3
- package/server/lib/github/pr-status.js +188 -83
- package/server/lib/github/pr-status.test.js +182 -0
- package/server/lib/github/routes.js +36 -30
- package/server/lib/notifications/template-runtime.js +2 -3
- package/server/lib/openchamber-control/action-resolution.test.js +65 -0
- package/server/lib/openchamber-control/actions.js +78 -0
- package/server/lib/openchamber-control/service.js +7 -0
- package/server/lib/openchamber-sessions/routes.js +14 -0
- package/server/lib/opencode/DOCUMENTATION.md +12 -6
- package/server/lib/opencode/claude-cli-auth.js +60 -0
- package/server/lib/opencode/claude-cli-auth.test.js +54 -0
- package/server/lib/opencode/feature-routes-runtime.js +16 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/plugins.js +12 -3
- package/server/lib/opencode/plugins.test.js +18 -0
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
- package/server/lib/opencode/proxy.js +116 -6
- package/server/lib/opencode/proxy.test.js +158 -1
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/routes.js +4 -1
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +26 -0
- package/server/lib/opencode/settings-helpers.test.js +57 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +83 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/shared.js +120 -16
- package/server/lib/opencode/shared.test.js +185 -1
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +160 -0
- package/server/lib/project-context/routes.http.test.js +264 -0
- package/server/lib/project-context/routes.js +237 -0
- package/server/lib/project-context/runtime.js +672 -0
- package/server/lib/project-context/runtime.test.js +498 -0
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +17 -2
- package/server/lib/quota/providers/claude/auth.js +113 -0
- package/server/lib/quota/providers/claude/auth.test.js +117 -0
- package/server/lib/quota/providers/claude/index.js +151 -0
- package/server/lib/quota/providers/claude/index.test.js +147 -0
- package/server/lib/quota/providers/claude/transforms.js +127 -0
- package/server/lib/quota/providers/claude/transforms.test.js +82 -0
- package/server/lib/quota/providers/command-code.js +90 -0
- package/server/lib/quota/providers/command-code.test.js +85 -0
- package/server/lib/quota/providers/index.js +30 -2
- package/server/lib/quota/providers/index.test.js +10 -1
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/quota/utils/formatters.js +2 -1
- package/server/lib/scheduled-tasks/runtime.js +21 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +89 -0
- package/server/lib/session-knowledge/routes.js +107 -0
- package/server/lib/session-knowledge/runtime.js +331 -0
- package/server/lib/session-knowledge/runtime.test.js +275 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +10 -0
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +57 -6
- package/server/lib/small-model/index.test.js +102 -2
- package/server/lib/small-model/routes.js +4 -2
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
- package/dist/assets/DiffView-DZIoOnV7.js +0 -4
- package/dist/assets/FilesView-BKL6YlKG.js +0 -14
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
- package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
- package/dist/assets/SettingsView-5RmswFZe.js +0 -28
- package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
- package/dist/assets/ToolOutputDialog-Za6V4VMJ.js +0 -15
- package/dist/assets/ToolPartDiffPreview-BL-9ixyC.js +0 -8
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
- package/dist/assets/de-u7gSnqWs.js +0 -9
- package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
- package/dist/assets/es-T9O7aAOr.js +0 -15
- package/dist/assets/fr-Oor7ewbE.js +0 -13
- package/dist/assets/index-BzIpNlNE.css +0 -1
- package/dist/assets/index-C0yNhuZw.js +0 -1
- package/dist/assets/index-DRpChWux.js +0 -7
- package/dist/assets/ja-DHpqbVmr.js +0 -15
- package/dist/assets/ko-CwLkS3nx.js +0 -15
- package/dist/assets/main-D7UcL3VQ.js +0 -2
- package/dist/assets/main-DPMd2iKS.js +0 -915
- package/dist/assets/markdownCore-DDrHVneM.js +0 -2
- package/dist/assets/miniChat-O_GVoEbc.js +0 -2
- package/dist/assets/mobile-Br4TtAqc.js +0 -2
- package/dist/assets/pl-CcZILN8q.js +0 -15
- package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
- package/dist/assets/renderMobileApp-toj9cXoh.js +0 -25
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
- package/dist/assets/uk-BA2kZR38.js +0 -15
- package/dist/assets/useInlineCommentController-CYPvYJDt.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
- package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
- package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
- package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
- package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
- package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
- package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
- package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
- package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
- package/server/lib/quota/providers/claude.js +0 -107
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
package/README.md
CHANGED
|
@@ -115,6 +115,7 @@ OPENCODE_HOST=https://myhost:4096 OPENCODE_SKIP_START=true openchamber
|
|
|
115
115
|
| `OPENCHAMBER_VERBOSE_REQUEST_LOGS` | Set to `true` to log every HTTP request; disabled by default to keep user logs small |
|
|
116
116
|
| `OPENCHAMBER_SKIP_API_COMPRESSION` | Set to `true` to disable gzip compression for `/api/*` responses |
|
|
117
117
|
| `OPENCHAMBER_COMPRESS_API` | Set to `true` to force `/api/*` compression, or `false` to disable it. Desktop runtime disables API compression by default to reduce local sidecar CPU use |
|
|
118
|
+
| `OPENCHAMBER_FS_UPLOAD_MAX_BYTES` | Maximum file upload size in bytes (default: 100 MiB) |
|
|
118
119
|
| `OPENCHAMBER_TERMINAL_SHELL` | Preferred terminal shell executable used by the `Auto` setting before platform defaults |
|
|
119
120
|
|
|
120
121
|
</details>
|
package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-C36E738Y.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-DSfrIBKT.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 +1 @@
|
|
|
1
|
-
import{R as k,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ae}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ad as ze,aX as me,aY as fe,I as M,aZ as ue,h as J,B as Z,Z as Ee,gs as Te,bs as pe,bt as ge,bu as xe,bv as be,bw as ye,bx as ve,aV as Ie}from"./useAppFontEffects-BikB6enL.js";import{u as Ce}from"./index-DRpChWux.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Re(p);return ke[e]??Me}const $e=k.memo(function(e){const t=oe.c(58),{file:r,actionLabel:g,actionSymbol:x,onAction:m,onViewDiff:d,onRevert:l,isReverting:h,stats:I,rowPaddingClassName:f,indentPx:y,actionAtStart:A,showRevert:z}=e,v=y===void 0?0:y,o=A===void 0?!1:A,j=z===void 0?!0:z;let S;t[0]!==r?(S=He(r),t[0]=r,t[1]=S):S=t[1];const u=S,{t:E}=Q(),R=u.description,V=I?.insertions??0,w=I?.deletions??0;let D;t[2]!==m||t[3]!==d?(D=X=>{X.key===" "?(X.preventDefault(),m()):X.key==="Enter"&&(X.preventDefault(),d())},t[2]=m,t[3]=d,t[4]=D):D=t[4];const b=D;let H;t[5]!==m?(H=X=>{X.preventDefault(),X.stopPropagation(),m()},t[5]=m,t[6]=H):H=t[6];const $=H;let O;t[7]!==l?(O=X=>{X.preventDefault(),X.stopPropagation(),l()},t[7]=l,t[8]=O):O=t[8];const F=O;let P;t[9]!==g||t[10]!==x||t[11]!==$?(P=s.jsx("button",{type:"button",onClick:$,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":g,title:g,children:x}),t[9]=g,t[10]=x,t[11]=$,t[12]=P):P=t[12];const Y=P,_=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let T;t[13]!==v?(T=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=T):T=t[14];const W=o?Y:null;let G;t[15]!==u.color?(G={color:u.color},t[15]=u.color,t[16]=G):G=t[16];let L;t[17]!==u.code||t[18]!==R||t[19]!==G?(L=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:G,title:R,"aria-label":R,children:u.code}),t[17]=u.code,t[18]=R,t[19]=G,t[20]=L):L=t[20];let B;t[21]!==r.path?(B=s.jsx(ze,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=B):B=t[22];let K;if(t[23]!==r.path){e:{const X=r.path.lastIndexOf("/");if(X===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],K=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ve=r.path.slice(0,X),De=r.path.slice(X);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],K=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ve}),ie]})}t[23]=r.path,t[24]=K}else K=t[24];let U;t[30]===Symbol.for("react.memo_cache_sentinel")?(U={color:"var(--status-success)"},t[30]=U):U=t[30];let i;t[31]!==V?(i=s.jsxs("span",{style:U,children:["+",V]}),t[31]=V,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==w?(c=s.jsxs("span",{style:a,children:["-",w]}),t[35]=w,t[36]=c):c=t[36];let N;t[37]!==i||t[38]!==c?(N=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=N):N=t[39];let C;t[40]!==r.path||t[41]!==F||t[42]!==h||t[43]!==j||t[44]!==E?(C=j?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=F,t[42]=h,t[43]=j,t[44]=E,t[45]=C):C=t[45];const q=o?null:Y;let ee;return t[46]!==b||t[47]!==d||t[48]!==T||t[49]!==W||t[50]!==L||t[51]!==B||t[52]!==K||t[53]!==N||t[54]!==C||t[55]!==q||t[56]!==_?(ee=s.jsxs("div",{className:_,role:"button",tabIndex:0,onClick:d,onKeyDown:b,style:T,children:[W,L,B,K,N,C,q]}),t[46]=b,t[47]=d,t[48]=T,t[49]=W,t[50]=L,t[51]=B,t[52]=K,t[53]=N,t[54]=C,t[55]=q,t[56]=_,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const r=Se(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),x.length>0){let d="";for(const l of x){d=d?`${d}/${l}`:l;const h=m.children.get(l);if(h){h.files.push(t),m=h;continue}const I=we(d,l);I.files.push(t),m.children.set(l,I),m=I}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],r=(g,x)=>{const m=Array.from(g.children.values()).sort((l,h)=>l.path.localeCompare(h.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:x,directory:l}),e.has(l.path)&&r(l,x+1);const d=[...g.directFiles].sort((l,h)=>l.path.localeCompare(h.path));for(const l of d)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:x,file:l})};return r(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:g="bg-sidebar",onVisiblePathsChange:x,onRevertAll:m,onRevertDirectory:d})=>{const{t:l}=Q(),h=k.useRef(null),f=Ce(i=>i.gitChangesViewMode)==="tree",y=k.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[A,z]=k.useState(new Set),[v,o]=k.useState(new Set),[j,S]=k.useState(!1),[u,E]=k.useState(null),R=k.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),V=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(R[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[R,y]);k.useEffect(()=>{f&&o(i=>{const n=new Set,a=new Set(V);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),V.forEach(c=>n.add(c)),n})},[f,V]);const w=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!A.has(n.id)){if(f){const c=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&c.add(C.slice(n.id.length+1))}),Pe(R[a],c).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:a,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:a,directory:C.directory,depth:C.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[A,v,f,m,R,y]),D=w.length,b=D>=Le,H=Ae({count:D,enabled:b,getScrollElement:()=>h.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>w[i]?.key??i}),$=H.getVirtualItems(),O=k.useMemo(()=>{if(!b)return 0;const i=h.current?.scrollTop??0;return $.find(a=>a.end>i)?.index??0},[b,$,h]);k.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){x([]);return}if(!b){const n=[];for(const a of w)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;x(n);return}x(w.slice(O,O+Math.ceil((h.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[x,D,w,b,O]);const F=k.useCallback(i=>{z(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),P=k.useCallback((i,n)=>{o(a=>{const c=new Set(a),N=de(i,n);return c.has(N)?c.delete(N):c.add(N),c})},[]),Y=k.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),_=Y.length,T=u?r||u.paths.some(i=>t.has(i)):!1,W=k.useCallback(async()=>{!m||r||Y.length===0||(await m(Y),S(!1))},[Y,r,m]),G=k.useCallback(async()=>{!d||!u||T||(await d(u.paths),E(null))},[T,d,u]),L=k.useCallback((i,n)=>{const a=A.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",g,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(N=>N.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>F(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx(M,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[A,g,F]),B=k.useCallback((i,n,a)=>{const c=v.has(de(i.id,n.path)),N=n.files.map(q=>q.path),C=r||N.some(q=>t.has(q));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>P(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx(M,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(M,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:N,count:N.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(q=>q.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,l,P]),K=k.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>S(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(M,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return L(a,n);if(i.type==="directory")return B(a,i.directory,i.depth);const c=i.file;return s.jsx($e,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:a.showRevertActions!==!1})},[e,r,f,B,L,t,l,y]),U=k.useCallback(i=>{const n=w[i],a=w[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[w]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:b?s.jsx("div",{style:{height:H.getTotalSize(),position:"relative"},children:$.map(i=>{const n=w[i.index];return n?s.jsx("div",{"data-index":i.index,ref:H.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(U(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:w.map((i,n)=>s.jsx("div",{className:J("relative",U(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:h,disableHorizontal:!0})]}),s.jsx(pe,{open:j,onOpenChange:i=>{!r&&!i&&S(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:_===1?l("gitView.changes.revertAllDescriptionSingle",{count:_}):l("gitView.changes.revertAllDescriptionPlural",{count:_})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>S(!1),disabled:r,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{W()},disabled:r,children:l(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!u,onOpenChange:i=>{!T&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:u?u.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:T,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{G()},disabled:T||!u,children:l(T?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(20),{value:t,onChange:r,placeholder:g,disabled:x,hasTouchInput:m,isMobile:d}=p,l=x===void 0?!1:x,h=m===void 0?!1:m,I=d===void 0?!1:d,{t:f}=Q(),y=k.useRef(null),A=Ce(Oe);let z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{const b=y.current;if(!b)return;const H=document.activeElement===b,$=()=>{b.style.height=`${he}px`;const F=b.scrollHeight,P=Math.min(Math.max(F,he),ae);b.style.height=`${P}px`,b.style.overflowY=F>ae?"auto":"hidden",F>ae&&!H&&(b.scrollTop=b.scrollHeight)};$();const O=window.requestAnimationFrame($);return()=>{window.cancelAnimationFrame(O)}},e[0]=z):z=e[0];let v;e[1]!==t?(v=[t],e[1]=t,e[2]=v):v=e[2],k.useLayoutEffect(z,v);let o;e[3]!==r?(o=b=>r(b.target.value),e[3]=r,e[4]=o):o=e[4];let j;e[5]!==g||e[6]!==f?(j=g??f("gitView.commit.messagePlaceholder"),e[5]=g,e[6]=f,e[7]=j):j=e[7];const S=h?"on":"off",u=h?"sentences":"off",E=I||A,R=l&&"opacity-50";let V;e[8]!==R?(V=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",R),e[8]=R,e[9]=V):V=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={minHeight:he,maxHeight:ae},e[10]=w):w=e[10];let D;return e[11]!==l||e[12]!==E||e[13]!==V||e[14]!==o||e[15]!==j||e[16]!==S||e[17]!==u||e[18]!==t?(D=s.jsx("textarea",{ref:y,value:t,onChange:o,placeholder:j,rows:1,disabled:l,autoCorrect:S,autoCapitalize:u,spellCheck:E,className:V,style:w}),e[11]=l,e[12]=E,e[13]=V,e[14]=o,e[15]=j,e[16]=S,e[17]=u,e[18]=t,e[19]=D):D=e[19],D};function Oe(p){return p.inputSpellcheckEnabled}const _e=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:g}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const m=x;let d;e[3]!==g?(d=g("gitView.commit.aiHighlights.title"),e[3]=g,e[4]=d):d=e[4];let l;e[5]!==d?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=l):l=e[6];let h;e[7]!==g?(h=g("gitView.commit.aiHighlights.insertAria"),e[7]=g,e[8]=h):h=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(M,{name:"arrow-down",className:"size-4"}),e[9]=I):I=e[9];let f;e[10]!==m||e[11]!==h?(f=s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":h,children:I})}),e[10]=m,e[11]=h,e[12]=f):f=e[12];let y;e[13]!==g?(y=g("gitView.commit.aiHighlights.insertTooltip"),e[13]=g,e[14]=y):y=e[14];let A;e[15]!==y?(A=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=A):A=e[16];let z;e[17]!==f||e[18]!==A?(z=s.jsxs(me,{children:[f,A]}),e[17]=f,e[18]=A,e[19]=z):z=e[19];let v;e[20]!==l||e[21]!==z?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,z]}),e[20]=l,e[21]=z,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Be),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let S;return e[27]!==v||e[28]!==j?(S=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=S):S=e[29],S};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(75),{stagedCount:t,commitMessage:r,onCommitMessageChange:g,generatedHighlights:x,onInsertHighlights:m,onGenerateMessage:d,isGeneratingMessage:l,onCommit:h,onCommitAndPush:I,commitAction:f,hasPendingIndexMutation:y,gitmojiEnabled:A,onOpenGitmojiPicker:z}=p,v=y===void 0?!1:y,{t:o}=Q(),j=t>0;let S;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(S=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=S):S=e[4];const u=S,{isMobile:E,hasTouchInput:R}=Ie();let V;e[5]!==o?(V=o("gitView.commit.title"),e[5]=o,e[6]=V):V=e[6];let w;e[7]!==V?(w=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:V}),e[7]=V,e[8]=w):w=e[8];let D;e[9]!==j||e[10]!==o?(D=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=D):D=e[11];let b;e[12]!==w||e[13]!==D?(b=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[w,D]}),e[12]=w,e[13]=D,e[14]=b):b=e[14];let H;e[15]!==x||e[16]!==m?(H=s.jsx(_e,{highlights:x,onInsert:m}),e[15]=x,e[16]=m,e[17]=H):H=e[17];let $;e[18]!==o?($=o("gitView.commit.messagePlaceholder"),e[18]=o,e[19]=$):$=e[19];const O=f!==null;let F;e[20]!==r||e[21]!==R||e[22]!==E||e[23]!==g||e[24]!==$||e[25]!==O?(F=s.jsx(Ge,{value:r,onChange:g,placeholder:$,disabled:O,hasTouchInput:R,isMobile:E}),e[20]=r,e[21]=R,e[22]=E,e[23]=g,e[24]=$,e[25]=O,e[26]=F):F=e[26];let P;e[27]!==A||e[28]!==z||e[29]!==o?(P=A&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:z,className:"w-fit",type:"button",children:[s.jsx(M,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[27]=A,e[28]=z,e[29]=o,e[30]=P):P=e[30];const Y=l||f!==null||v||t===0;let _;e[31]!==o?(_=o("gitView.commit.generateAria"),e[31]=o,e[32]=_):_=e[32];let T;e[33]!==l?(T=l?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=l,e[34]=T):T=e[34];let W;e[35]!==o?(W=o("gitView.commit.generate"),e[35]=o,e[36]=W):W=e[36];let G;e[37]!==W?(G=s.jsx("span",{className:"commit-actions__label",children:W}),e[37]=W,e[38]=G):G=e[38];let L;e[39]!==d||e[40]!==Y||e[41]!==_||e[42]!==T||e[43]!==G?(L=s.jsxs(Z,{variant:"outline",size:"sm",onClick:d,disabled:Y,type:"button","aria-label":_,className:"commit-actions__btn",children:[T,G]}),e[39]=d,e[40]=Y,e[41]=_,e[42]=T,e[43]=G,e[44]=L):L=e[44];let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[45]=B):B=e[45];const K=!u||l;let U;e[46]!==o?(U=o("gitView.commit.commitAria"),e[46]=o,e[47]=U):U=e[47];let i;e[48]!==f||e[49]!==o?(i=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[48]=f,e[49]=o,e[50]=i):i=e[50];let n;e[51]!==h||e[52]!==K||e[53]!==U||e[54]!==i?(n=s.jsx(Z,{size:"sm",variant:"outline",onClick:h,disabled:K,className:"commit-actions__btn whitespace-nowrap","aria-label":U,children:i}),e[51]=h,e[52]=K,e[53]=U,e[54]=i,e[55]=n):n=e[55];let a;e[56]!==u||e[57]!==f||e[58]!==l||e[59]!==E||e[60]!==I||e[61]!==o?(a=E?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>I(),disabled:!u||l,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>I(),disabled:!u||l,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[56]=u,e[57]=f,e[58]=l,e[59]=E,e[60]=I,e[61]=o,e[62]=a):a=e[62];let c;e[63]!==L||e[64]!==n||e[65]!==a?(c=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[L,B,n,a]}),e[63]=L,e[64]=n,e[65]=a,e[66]=c):c=e[66];let N;e[67]!==F||e[68]!==P||e[69]!==c||e[70]!==H?(N=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[H,F,P,c]}),e[67]=F,e[68]=P,e[69]=c,e[70]=H,e[71]=N):N=e[71];let C;return e[72]!==N||e[73]!==b?(C=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[b,N]}),e[72]=N,e[73]=b,e[74]=C):C=e[74],C};export{Ye as C,Ze as a};
|
|
1
|
+
import{R as k,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ae}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ad as ze,aY as me,aZ as fe,I as M,a_ as ue,h as J,B as Z,Z as Ee,gM as Te,bu as pe,bv as ge,bw as xe,bx as be,by as ye,bz as ve,aW as Ie}from"./useAppFontEffects-B53Rb6m7.js";import{u as Ce}from"./index-Cwmuwk3V.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Re(p);return ke[e]??Me}const $e=k.memo(function(e){const t=oe.c(58),{file:r,actionLabel:g,actionSymbol:x,onAction:m,onViewDiff:d,onRevert:l,isReverting:h,stats:I,rowPaddingClassName:f,indentPx:y,actionAtStart:A,showRevert:z}=e,v=y===void 0?0:y,o=A===void 0?!1:A,j=z===void 0?!0:z;let S;t[0]!==r?(S=He(r),t[0]=r,t[1]=S):S=t[1];const u=S,{t:E}=Q(),R=u.description,D=I?.insertions??0,w=I?.deletions??0;let V;t[2]!==m||t[3]!==d?(V=W=>{W.key===" "?(W.preventDefault(),m()):W.key==="Enter"&&(W.preventDefault(),d())},t[2]=m,t[3]=d,t[4]=V):V=t[4];const b=V;let H;t[5]!==m?(H=W=>{W.preventDefault(),W.stopPropagation(),m()},t[5]=m,t[6]=H):H=t[6];const $=H;let O;t[7]!==l?(O=W=>{W.preventDefault(),W.stopPropagation(),l()},t[7]=l,t[8]=O):O=t[8];const F=O;let P;t[9]!==g||t[10]!==x||t[11]!==$?(P=s.jsx("button",{type:"button",onClick:$,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":g,title:g,children:x}),t[9]=g,t[10]=x,t[11]=$,t[12]=P):P=t[12];const Y=P,_=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let T;t[13]!==v?(T=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=T):T=t[14];const X=o?Y:null;let G;t[15]!==u.color?(G={color:u.color},t[15]=u.color,t[16]=G):G=t[16];let L;t[17]!==u.code||t[18]!==R||t[19]!==G?(L=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:G,title:R,"aria-label":R,children:u.code}),t[17]=u.code,t[18]=R,t[19]=G,t[20]=L):L=t[20];let B;t[21]!==r.path?(B=s.jsx(ze,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=B):B=t[22];let K;if(t[23]!==r.path){e:{const W=r.path.lastIndexOf("/");if(W===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],K=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const De=r.path.slice(0,W),Ve=r.path.slice(W);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:Ve.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],K=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=r.path,t[24]=K}else K=t[24];let U;t[30]===Symbol.for("react.memo_cache_sentinel")?(U={color:"var(--status-success)"},t[30]=U):U=t[30];let i;t[31]!==D?(i=s.jsxs("span",{style:U,children:["+",D]}),t[31]=D,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==w?(c=s.jsxs("span",{style:a,children:["-",w]}),t[35]=w,t[36]=c):c=t[36];let N;t[37]!==i||t[38]!==c?(N=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=N):N=t[39];let C;t[40]!==r.path||t[41]!==F||t[42]!==h||t[43]!==j||t[44]!==E?(C=j?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=F,t[42]=h,t[43]=j,t[44]=E,t[45]=C):C=t[45];const q=o?null:Y;let ee;return t[46]!==b||t[47]!==d||t[48]!==T||t[49]!==X||t[50]!==L||t[51]!==B||t[52]!==K||t[53]!==N||t[54]!==C||t[55]!==q||t[56]!==_?(ee=s.jsxs("div",{className:_,role:"button",tabIndex:0,onClick:d,onKeyDown:b,style:T,children:[X,L,B,K,N,C,q]}),t[46]=b,t[47]=d,t[48]=T,t[49]=X,t[50]=L,t[51]=B,t[52]=K,t[53]=N,t[54]=C,t[55]=q,t[56]=_,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const r=Se(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),x.length>0){let d="";for(const l of x){d=d?`${d}/${l}`:l;const h=m.children.get(l);if(h){h.files.push(t),m=h;continue}const I=we(d,l);I.files.push(t),m.children.set(l,I),m=I}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],r=(g,x)=>{const m=Array.from(g.children.values()).sort((l,h)=>l.path.localeCompare(h.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:x,directory:l}),e.has(l.path)&&r(l,x+1);const d=[...g.directFiles].sort((l,h)=>l.path.localeCompare(h.path));for(const l of d)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:x,file:l})};return r(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:g="bg-sidebar",onVisiblePathsChange:x,onRevertAll:m,onRevertDirectory:d})=>{const{t:l}=Q(),h=k.useRef(null),f=Ce(i=>i.gitChangesViewMode)==="tree",y=k.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[A,z]=k.useState(new Set),[v,o]=k.useState(new Set),[j,S]=k.useState(!1),[u,E]=k.useState(null),R=k.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),D=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(R[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[R,y]);k.useEffect(()=>{f&&o(i=>{const n=new Set,a=new Set(D);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),D.forEach(c=>n.add(c)),n})},[f,D]);const w=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!A.has(n.id)){if(f){const c=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&c.add(C.slice(n.id.length+1))}),Pe(R[a],c).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:a,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:a,directory:C.directory,depth:C.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[A,v,f,m,R,y]),V=w.length,b=V>=Le,H=Ae({count:V,enabled:b,getScrollElement:()=>h.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>w[i]?.key??i}),$=H.getVirtualItems(),O=k.useMemo(()=>{if(!b)return 0;const i=h.current?.scrollTop??0;return $.find(a=>a.end>i)?.index??0},[b,$,h]);k.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(V===0){x([]);return}if(!b){const n=[];for(const a of w)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;x(n);return}x(w.slice(O,O+Math.ceil((h.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[x,V,w,b,O]);const F=k.useCallback(i=>{z(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),P=k.useCallback((i,n)=>{o(a=>{const c=new Set(a),N=de(i,n);return c.has(N)?c.delete(N):c.add(N),c})},[]),Y=k.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),_=Y.length,T=u?r||u.paths.some(i=>t.has(i)):!1,X=k.useCallback(async()=>{!m||r||Y.length===0||(await m(Y),S(!1))},[Y,r,m]),G=k.useCallback(async()=>{!d||!u||T||(await d(u.paths),E(null))},[T,d,u]),L=k.useCallback((i,n)=>{const a=A.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",g,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(N=>N.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>F(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx(M,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[A,g,F]),B=k.useCallback((i,n,a)=>{const c=v.has(de(i.id,n.path)),N=n.files.map(q=>q.path),C=r||N.some(q=>t.has(q));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>P(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx(M,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(M,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:N,count:N.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(q=>q.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,l,P]),K=k.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>S(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(M,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return L(a,n);if(i.type==="directory")return B(a,i.directory,i.depth);const c=i.file;return s.jsx($e,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:a.showRevertActions!==!1})},[e,r,f,B,L,t,l,y]),U=k.useCallback(i=>{const n=w[i],a=w[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[w]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:b?s.jsx("div",{style:{height:H.getTotalSize(),position:"relative"},children:$.map(i=>{const n=w[i.index];return n?s.jsx("div",{"data-index":i.index,ref:H.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(U(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:w.map((i,n)=>s.jsx("div",{className:J("relative",U(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:h,disableHorizontal:!0})]}),s.jsx(pe,{open:j,onOpenChange:i=>{!r&&!i&&S(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:_===1?l("gitView.changes.revertAllDescriptionSingle",{count:_}):l("gitView.changes.revertAllDescriptionPlural",{count:_})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>S(!1),disabled:r,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{X()},disabled:r,children:l(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!u,onOpenChange:i=>{!T&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:u?u.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:T,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{G()},disabled:T||!u,children:l(T?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(20),{value:t,onChange:r,placeholder:g,disabled:x,hasTouchInput:m,isMobile:d}=p,l=x===void 0?!1:x,h=m===void 0?!1:m,I=d===void 0?!1:d,{t:f}=Q(),y=k.useRef(null),A=Ce(Oe);let z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{const b=y.current;if(!b)return;const H=document.activeElement===b,$=()=>{b.style.height=`${he}px`;const F=b.scrollHeight,P=Math.min(Math.max(F,he),ae);b.style.height=`${P}px`,b.style.overflowY=F>ae?"auto":"hidden",F>ae&&!H&&(b.scrollTop=b.scrollHeight)};$();const O=window.requestAnimationFrame($);return()=>{window.cancelAnimationFrame(O)}},e[0]=z):z=e[0];let v;e[1]!==t?(v=[t],e[1]=t,e[2]=v):v=e[2],k.useLayoutEffect(z,v);let o;e[3]!==r?(o=b=>r(b.target.value),e[3]=r,e[4]=o):o=e[4];let j;e[5]!==g||e[6]!==f?(j=g??f("gitView.commit.messagePlaceholder"),e[5]=g,e[6]=f,e[7]=j):j=e[7];const S=h?"on":"off",u=h?"sentences":"off",E=I||A,R=l&&"opacity-50";let D;e[8]!==R?(D=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",R),e[8]=R,e[9]=D):D=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={minHeight:he,maxHeight:ae},e[10]=w):w=e[10];let V;return e[11]!==l||e[12]!==E||e[13]!==D||e[14]!==o||e[15]!==j||e[16]!==S||e[17]!==u||e[18]!==t?(V=s.jsx("textarea",{ref:y,value:t,onChange:o,placeholder:j,rows:1,disabled:l,autoCorrect:S,autoCapitalize:u,spellCheck:E,className:D,style:w}),e[11]=l,e[12]=E,e[13]=D,e[14]=o,e[15]=j,e[16]=S,e[17]=u,e[18]=t,e[19]=V):V=e[19],V};function Oe(p){return p.inputSpellcheckEnabled}const _e=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:g}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const m=x;let d;e[3]!==g?(d=g("gitView.commit.aiHighlights.title"),e[3]=g,e[4]=d):d=e[4];let l;e[5]!==d?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=l):l=e[6];let h;e[7]!==g?(h=g("gitView.commit.aiHighlights.insertAria"),e[7]=g,e[8]=h):h=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(M,{name:"arrow-down",className:"size-4"}),e[9]=I):I=e[9];let f;e[10]!==m||e[11]!==h?(f=s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":h,children:I})}),e[10]=m,e[11]=h,e[12]=f):f=e[12];let y;e[13]!==g?(y=g("gitView.commit.aiHighlights.insertTooltip"),e[13]=g,e[14]=y):y=e[14];let A;e[15]!==y?(A=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=A):A=e[16];let z;e[17]!==f||e[18]!==A?(z=s.jsxs(me,{children:[f,A]}),e[17]=f,e[18]=A,e[19]=z):z=e[19];let v;e[20]!==l||e[21]!==z?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,z]}),e[20]=l,e[21]=z,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Be),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let S;return e[27]!==v||e[28]!==j?(S=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=S):S=e[29],S};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(75),{stagedCount:t,commitMessage:r,onCommitMessageChange:g,generatedHighlights:x,onInsertHighlights:m,onGenerateMessage:d,isGeneratingMessage:l,onCommit:h,onCommitAndPush:I,commitAction:f,hasPendingIndexMutation:y,gitmojiEnabled:A,onOpenGitmojiPicker:z}=p,v=y===void 0?!1:y,{t:o}=Q(),j=t>0;let S;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(S=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=S):S=e[4];const u=S,{isMobile:E,hasTouchInput:R}=Ie();let D;e[5]!==o?(D=o("gitView.commit.title"),e[5]=o,e[6]=D):D=e[6];let w;e[7]!==D?(w=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:D}),e[7]=D,e[8]=w):w=e[8];let V;e[9]!==j||e[10]!==o?(V=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=V):V=e[11];let b;e[12]!==w||e[13]!==V?(b=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[w,V]}),e[12]=w,e[13]=V,e[14]=b):b=e[14];let H;e[15]!==x||e[16]!==m?(H=s.jsx(_e,{highlights:x,onInsert:m}),e[15]=x,e[16]=m,e[17]=H):H=e[17];let $;e[18]!==o?($=o("gitView.commit.messagePlaceholder"),e[18]=o,e[19]=$):$=e[19];const O=f!==null;let F;e[20]!==r||e[21]!==R||e[22]!==E||e[23]!==g||e[24]!==$||e[25]!==O?(F=s.jsx(Ge,{value:r,onChange:g,placeholder:$,disabled:O,hasTouchInput:R,isMobile:E}),e[20]=r,e[21]=R,e[22]=E,e[23]=g,e[24]=$,e[25]=O,e[26]=F):F=e[26];let P;e[27]!==A||e[28]!==z||e[29]!==o?(P=A&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:z,className:"w-fit",type:"button",children:[s.jsx(M,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[27]=A,e[28]=z,e[29]=o,e[30]=P):P=e[30];const Y=l||f!==null||v||t===0;let _;e[31]!==o?(_=o("gitView.commit.generateAria"),e[31]=o,e[32]=_):_=e[32];let T;e[33]!==l?(T=l?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=l,e[34]=T):T=e[34];let X;e[35]!==o?(X=o("gitView.commit.generate"),e[35]=o,e[36]=X):X=e[36];let G;e[37]!==X?(G=s.jsx("span",{className:"commit-actions__label",children:X}),e[37]=X,e[38]=G):G=e[38];let L;e[39]!==d||e[40]!==Y||e[41]!==_||e[42]!==T||e[43]!==G?(L=s.jsxs(Z,{variant:"outline",size:"sm",onClick:d,disabled:Y,type:"button","aria-label":_,className:"commit-actions__btn",children:[T,G]}),e[39]=d,e[40]=Y,e[41]=_,e[42]=T,e[43]=G,e[44]=L):L=e[44];let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[45]=B):B=e[45];const K=!u||l;let U;e[46]!==o?(U=o("gitView.commit.commitAria"),e[46]=o,e[47]=U):U=e[47];let i;e[48]!==f||e[49]!==o?(i=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[48]=f,e[49]=o,e[50]=i):i=e[50];let n;e[51]!==h||e[52]!==K||e[53]!==U||e[54]!==i?(n=s.jsx(Z,{size:"sm",variant:"outline",onClick:h,disabled:K,className:"commit-actions__btn whitespace-nowrap","aria-label":U,children:i}),e[51]=h,e[52]=K,e[53]=U,e[54]=i,e[55]=n):n=e[55];let a;e[56]!==u||e[57]!==f||e[58]!==l||e[59]!==E||e[60]!==I||e[61]!==o?(a=E?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>I(),disabled:!u||l,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>I(),disabled:!u||l,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[56]=u,e[57]=f,e[58]=l,e[59]=E,e[60]=I,e[61]=o,e[62]=a):a=e[62];let c;e[63]!==L||e[64]!==n||e[65]!==a?(c=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[L,B,n,a]}),e[63]=L,e[64]=n,e[65]=a,e[66]=c):c=e[66];let N;e[67]!==F||e[68]!==P||e[69]!==c||e[70]!==H?(N=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[H,F,P,c]}),e[67]=F,e[68]=P,e[69]=c,e[70]=H,e[71]=N):N=e[71];let C;return e[72]!==N||e[73]!==b?(C=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[b,N]}),e[72]=N,e[73]=b,e[74]=C):C=e[74],C};export{Ye as C,Ze as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,j as h}from"./vendor-react-BUCujlKS.js";import{D as E}from"./vendor-react-drawio-Ct3Q0DsD.js";import{h as x}from"./useAppFontEffects-
|
|
1
|
+
import{R as e,j as h}from"./vendor-react-BUCujlKS.js";import{D as E}from"./vendor-react-drawio-Ct3Q0DsD.js";import{h as x}from"./useAppFontEffects-B53Rb6m7.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as r,j as i}from"./vendor-react-BUCujlKS.js";import{u as n}from"./index-Cwmuwk3V.js";import{f as j,V as b,I as m}from"./useAppFontEffects-B53Rb6m7.js";import{D as y}from"./DiagramEditor-BPECg1jS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C9ioTTSo.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DsHmyMwp.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BEARQjgn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-vch3tJ4c.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Ct3Q0DsD.js";function Yi(){const{t:s}=j(),{files:o}=b(),[e,g]=r.useState(null),[p,a]=r.useState(""),[x,l]=r.useState(!0),c=r.useRef(null),u=n(t=>t.pendingDiagramFile),f=r.useCallback(async t=>{l(!0),g(t);try{const d=await o?.readFile?.(t);d&&a(d.content)}catch{a("")}finally{l(!1)}},[o]);r.useEffect(()=>{if(!u)return;const t=n.getState().consumePendingDiagramFile();t&&f(t)},[f,u]);const h=r.useCallback(async()=>{const t=c.current?.getXml();e&&o?.writeFile&&t&&t!==p&&(await o.writeFile(e,t),a(t))},[e,o,p]),v=e?e.split("/").pop()||e:"";return e?x?i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[i.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),i.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.saveDiagram"),children:i.jsx(m,{name:"save-3",className:"size-4"})}),i.jsx("button",{type:"button",onClick:()=>n.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.closeDiagramView"),children:i.jsx(m,{name:"close",className:"size-4"})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(y,{ref:c,xml:p,className:"h-full"})})]}):i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx("div",{className:"typography-ui text-muted-foreground",children:s("filesView.editor.pickFileFromTree")})})}export{Yi as DiagramView};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{R as i,j as n,f as be}from"./vendor-react-BUCujlKS.js";import{W as pn,a as ot,u as te,E as Ge}from"./index-Cwmuwk3V.js";import{f as we,V as At,a0 as hn,aW as gn,a2 as xn,a1 as bn,a3 as wn,a4 as ae,y as yt,k as yn,hP as vn,hQ as jn,hR as Sn,ct as Nn,t as We,hS as Fn,ab as Ve,B as me,I as R,h as le,aY as Cn,aZ as kn,a_ as Rn,hh as Et,hT as Dn,fo as An,fs as $e,bW as rt,ad as Vt,aa as En,aS as Vn,aU as Bn,ft as Ln,aV as Mn}from"./useAppFontEffects-B53Rb6m7.js";import{c as Tn,p as _n}from"./vendor-zustand-BAGL70zf.js";import{P as In}from"./PierreDiffViewer-Dlby4XqT.js";import{b as On,v as zn,g as Pn,W as Gn}from"./main-WMjtYzJs.js";import{f as $n}from"./patchFileDiff-BcFaMtMu.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C9ioTTSo.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DsHmyMwp.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BEARQjgn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-vch3tJ4c.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-pcwCTWjC.js";import"./computeVirtualFileMetrics-DkRR5b75.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-lESMT-2b.js";import"./isDiffPlainText-BG53Ixxy.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-DSfrIBKT.js";import"./runtimeEndpointReset-ovNbaZ-x.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-IETz58DB.js";import"./scheduledTasksApi-BFSlqgnG.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const Wn="openchamber.git-base-branch",Kn=100,Ke=(s,e)=>JSON.stringify([ot(),s,e]),vt=Tn()(_n((s,e)=>({overrides:{},getOverride:(r,a)=>!r||!a?null:e().overrides[Ke(r,a)]??null,setOverride:(r,a,d)=>{!r||!a||!d||s(f=>{const p=Ke(r,a),h=Object.entries({...f.overrides,[p]:d});for(;h.length>Kn;)h.shift();return{overrides:Object.fromEntries(h)}})},clearOverride:(r,a)=>{!r||!a||s(d=>{const f=Ke(r,a);if(!(f in d.overrides))return d;const p={...d.overrides};return delete p[f],{overrides:p}})}}),{name:Wn,storage:pn(),partialize:s=>({overrides:s.overrides})})),Hn=(s,e)=>!!s&&e!==null&&s!==e,Un=(s,e,r,a)=>r?s===null||a&&e===null?!0:e!==null&&s===e:!1,qn=(s,e)=>s==="branch"&&!e?"working":s,Xn=(s,e,r)=>JSON.stringify([s,e,r]),Yn=(s,e,r,a,d,f)=>{const p=i.useRef({directory:"",attempts:0}),[h,u]=i.useState(()=>({directory:"",exhausted:!1})),m=i.useRef(d);m.current=d;const g=!!s&&h.directory===s&&h.exhausted;return i.useEffect(()=>{if(!s||!e||a||r)return;const l=p.current.directory===s?p.current.attempts:0;if(l>=f){h.directory===s&&h.exhausted||u({directory:s,exhausted:!0});return}p.current={directory:s,attempts:l+1},m.current()},[s,h,a,e,r,f]),g},Jn=(s,e,r,a)=>{const[d,f]=i.useState(()=>new Map),p=i.useRef(d);p.current=d;const h=i.useRef(r);h.current=r;const u=i.useCallback((m,g)=>{const l=new Map(p.current);if(g===null){if(!l.delete(m))return}else l.set(m,g);p.current=l,f(l)},[]);return i.useEffect(()=>{s&&(p.current=new Map,f(p.current))},[s]),i.useEffect(()=>{const m=h.current;if(!s||!m||!e)return;let g=!1;const l=new Set;for(const v of e.split("\0"))p.current.has(v)||(l.add(v),u(v,a),m(v).then(j=>{g||(l.delete(v),u(v,j))}).catch(()=>{g||(l.delete(v),u(v,null))}));return()=>{g=!0;for(const v of l)u(v,null)}},[e,a,s,u]),d},jt=(s,e)=>{if(e.length===0)return null;let r=null,a=null;for(const f of e)f.top<=s?(!r||f.top>r.top)&&(r=f):(!a||f.top<a.top)&&(a=f);const d=r??a;return d?{path:d.path,topOffset:d.top-s}:null},Qn=(s,e,r,a)=>Math.min(Math.max(0,a),Math.max(0,s+r-e)),St=s=>{if(!s)return null;const e=s.split(`
|
|
2
|
+
`);let r=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const f=Number.parseInt(d[1]??"",10);r=Number.isFinite(f)&&f>=1?f:null;continue}if(r!==null){if(a.startsWith(" ")){r+=1;continue}if(a.startsWith("+"))return r;if(a.startsWith("-"))return Math.max(1,r)}}return null},Zn=1100,es=15e3,Nt=500,Ft=300,ts=1e6,ns=3,ss=s=>s<=6?s:s<=12?6:s<=25?4:2,rs={original:"",modified:"",isBinary:!1,contextMode:"patch"},is=3,os=i.memo(()=>{const s=be.c(4),{t:e}=we();let r;s[0]!==e?(r=e("diffView.binary.unavailable"),s[0]=e,s[1]=r):r=s[1];let a;return s[2]!==r?(a=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:r})}),s[2]=r,s[3]=a):a=s[3],a}),Bt={"?":{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"}},as=Bt.M,ls=s=>{const e=s.index?.trim(),r=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):r?r.charAt(0):e?.charAt(0)||r?.charAt(0)||"M"},Lt=s=>{const e=ls(s);return Bt[e]??as},cs=s=>{const{index:e,working_dir:r}=s;return e==="A"||r==="A"||e==="?"||r==="?"},Ct=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},kt=s=>!!s.working_dir?.trim()||s.index==="?",us=(s,e)=>An(s,e),Rt=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),Dt=(s,e)=>{const r=s.split(`
|
|
3
|
+
`),a=e.split(`
|
|
4
|
+
`),d=Math.min(r.length,a.length);for(let f=0;f<d;f+=1)if(r[f]!==a[f])return f+1;return a.length>r.length?r.length+1:r.length>a.length?Math.max(1,a.length):1},fs=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),ds=s=>Array.isArray(s)?s.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],ms=s=>s==="added"?"A":s==="deleted"?"D":"M",it=(s,e,r)=>fs(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:r}:{original:"",modified:"",patch:e,fileDiff:$n(s,e),contextMode:r},Mt=(s,e,r)=>{const a=s??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",r?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},ps=i.memo(s=>{const e=be.c(58),{scope:r,workingCount:a,stagedCount:d,turnCount:f,branchCount:p,showBranchOption:h,onScopeChange:u}=s,{t:m}=we(),[g,l]=i.useState(!1),v=r==="staged"?d:r==="turn"?f:r==="branch"?p??0:a;let j;e[0]!==r||e[1]!==m?(j=m(r==="staged"?"diffView.scope.staged":r==="turn"?"diffView.scope.lastTurn":r==="branch"?"diffView.scope.branch":"diffView.scope.changed"),e[0]=r,e[1]=m,e[2]=j):j=e[2];const I=j;let M;e[3]!==m?(M=m("diffView.scope.selectorAria"),e[3]=m,e[4]=M):M=e[4];let ne;e[5]!==v?(ne=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",v]}),e[5]=v,e[6]=ne):ne=e[6];let y;e[7]!==I||e[8]!==ne?(y=n.jsxs("span",{className:"whitespace-nowrap",children:[I,ne]}),e[7]=I,e[8]=ne,e[9]=y):y=e[9];let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(R,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=V):V=e[10];let T;e[11]!==M||e[12]!==y?(T=n.jsx(Vn,{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":M,children:[y,V]})}),e[11]=M,e[12]=y,e[13]=T):T=e[13];let q;e[14]!==u?(q=ie=>{(ie==="working"||ie==="staged"||ie==="turn"||ie==="branch")&&(u?.(ie),l(!1))},e[14]=u,e[15]=q):q=e[15];let X;e[16]!==m?(X=m("diffView.scope.changed"),e[16]=m,e[17]=X):X=e[17];let se;e[18]!==X?(se=n.jsx("span",{children:X}),e[18]=X,e[19]=se):se=e[19];let Y;e[20]!==a?(Y=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=Y):Y=e[21];let J;e[22]!==Y||e[23]!==se?(J=n.jsx($e,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[se,Y]})}),e[22]=Y,e[23]=se,e[24]=J):J=e[24];let B;e[25]!==m?(B=m("diffView.scope.staged"),e[25]=m,e[26]=B):B=e[26];let _;e[27]!==B?(_=n.jsx("span",{children:B}),e[27]=B,e[28]=_):_=e[28];let re;e[29]!==d?(re=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=re):re=e[30];let L;e[31]!==_||e[32]!==re?(L=n.jsx($e,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[_,re]})}),e[31]=_,e[32]=re,e[33]=L):L=e[33];let P;e[34]!==m?(P=m("diffView.scope.lastTurn"),e[34]=m,e[35]=P):P=e[35];let G;e[36]!==P?(G=n.jsx("span",{children:P}),e[36]=P,e[37]=G):G=e[37];let D;e[38]!==f?(D=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=D):D=e[39];let $;e[40]!==G||e[41]!==D?($=n.jsx($e,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[G,D]})}),e[40]=G,e[41]=D,e[42]=$):$=e[42];let Q;e[43]!==p||e[44]!==h||e[45]!==m?(Q=h?n.jsx($e,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:m("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:p??"…"})]})}):null,e[43]=p,e[44]=h,e[45]=m,e[46]=Q):Q=e[46];let O;e[47]!==r||e[48]!==J||e[49]!==L||e[50]!==$||e[51]!==Q||e[52]!==q?(O=n.jsx(Bn,{align:"start",className:"w-40",children:n.jsxs(Ln,{value:r,onValueChange:q,children:[J,L,$,Q]})}),e[47]=r,e[48]=J,e[49]=L,e[50]=$,e[51]=Q,e[52]=q,e[53]=O):O=e[53];let W;return e[54]!==g||e[55]!==O||e[56]!==T?(W=n.jsxs(Mn,{open:g,onOpenChange:l,children:[T,O]}),e[54]=g,e[55]=O,e[56]=T,e[57]=W):W=e[57],W}),hs=i.memo(s=>{const e=be.c(11),{changedFiles:r,selectedFile:a,onSelectFile:d}=s,{t:f}=we();if(r.length===0)return null;let p;if(e[0]!==r||e[1]!==d||e[2]!==a||e[3]!==f){let u;e[5]!==d||e[6]!==a||e[7]!==f?(u=m=>{const g=Lt(m),l=a===m.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(m.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",l?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(Vt,{filePath:m.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:g.color},title:f(g.descriptionKey),"aria-label":f(g.descriptionKey),children:g.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:m.path,children:m.path}),Mt(m.insertions,m.deletions)]})},m.path)},e[5]=d,e[6]=a,e[7]=f,e[8]=u):u=e[8],p=r.map(u),e[0]=r,e[1]=d,e[2]=a,e[3]=f,e[4]=p}else p=e[4];let h;return e[9]!==p?(h=n.jsx(rt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:p})}),e[9]=p,e[10]=h):h=e[10],h}),gs=i.memo(s=>{const e=be.c(20),{filePath:r,diff:a,renderSideBySide:d}=s,{t:f}=we(),p=a.original.length>0,h=a.modified.length>0,u=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",m=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={contain:"layout"},e[0]=g):g=e[0];let l;e[1]!==a.original||e[2]!==r||e[3]!==p||e[4]!==m||e[5]!==d||e[6]!==f?(l=p&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:a.original,alt:f("diffView.image.originalAlt",{path:r}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=r,e[3]=p,e[4]=m,e[5]=d,e[6]=f,e[7]=l):l=e[7];let v;e[8]!==a.modified||e[9]!==r||e[10]!==h||e[11]!==p||e[12]!==m||e[13]!==d||e[14]!==f?(v=h&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(p?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:f("diffView.image.modifiedAlt",{path:r}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=r,e[10]=h,e[11]=p,e[12]=m,e[13]=d,e[14]=f,e[15]=v):v=e[15];let j;return e[16]!==u||e[17]!==l||e[18]!==v?(j=n.jsx("div",{className:"w-full overflow-auto p-4",style:g,children:n.jsxs("div",{className:u,children:[l,v]})}),e[16]=u,e[17]=l,e[18]=v,e[19]=j):j=e[19],j}),xs=i.memo(s=>{const e=be.c(16),{filePath:r,diff:a,renderSideBySide:d,wrapLines:f}=s;let p;e[0]!==r?(p=En(r)||"text",e[0]=r,e[1]=p):p=e[1];const h=p;if(a.isBinary){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(os,{}),e[2]=g):g=e[2],g}if(Ve(r)){let g;return e[3]!==a||e[4]!==r||e[5]!==d?(g=n.jsx(gs,{filePath:r,diff:a,renderSideBySide:d}),e[3]=a,e[4]=r,e[5]=d,e[6]=g):g=e[6],g}let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u={contain:"layout"},e[7]=u):u=e[7];let m;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==r||e[12]!==h||e[13]!==d||e[14]!==f?(m=n.jsx("div",{className:"w-full",style:u,children:n.jsx(In,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:h,fileName:r,renderSideBySide:d,wrapLines:f,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=r,e[12]=h,e[13]=d,e[14]=f,e[15]=m):m=e[15],m}),bs=i.memo(s=>{const e=be.c(7),{filePath:r,staged:a,busyAction:d,disabled:f,onAction:p}=s,{t:h}=we();let u;return e[0]!==d||e[1]!==f||e[2]!==r||e[3]!==p||e[4]!==a||e[5]!==h?(u=n.jsx("div",{className:"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:a?n.jsx(st,{label:h("gitView.changes.unstageFileAria",{path:r}),icon:"arrow-go-back",loading:d==="unstage",disabled:f,onClick:()=>p("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(st,{label:h("gitView.changes.revertFileAria",{path:r}),icon:"arrow-go-back",loading:d==="discard",disabled:f,tone:"failure",onClick:()=>p("discard")}),n.jsx(st,{label:h("gitView.changes.stageFileAria",{path:r}),icon:"add",loading:d==="stage",disabled:f,tone:"success",onClick:()=>p("stage")})]})}),e[0]=d,e[1]=f,e[2]=r,e[3]=p,e[4]=a,e[5]=h,e[6]=u):u=e[6],u}),st=s=>{const e=be.c(14),{label:r,icon:a,loading:d,disabled:f,tone:p,onClick:h}=s,u=p==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",m=p==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let g;e[0]!==u||e[1]!==m?(g=le("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",u,m),e[0]=u,e[1]=m,e[2]=g):g=e[2];let l;e[3]!==h?(l=I=>{I.stopPropagation(),h()},e[3]=h,e[4]=l):l=e[4];let v;e[5]!==a||e[6]!==d?(v=d?n.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(R,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=v):v=e[7];let j;return e[8]!==f||e[9]!==r||e[10]!==g||e[11]!==l||e[12]!==v?(j=n.jsx(me,{variant:"ghost",size:"sm",className:g,disabled:f,title:r,"aria-label":r,onClick:l,children:v}),e[8]=f,e[9]=r,e[10]=g,e[11]=l,e[12]=v,e[13]=j):j=e[13],j},ws=i.memo(({directory:s,file:e,layout:r,wrapLines:a,isSelected:d,isExpanded:f,isMounted:p,onSelect:h,onExpandedChange:u,registerSectionRef:m,showOpenInEditorAction:g=!1,isOpeningInEditor:l=!1,onOpenInEditor:v,staged:j=!1,loadFullFiles:I=!1,initialDiffData:M=null,readOnlyActions:ne=!1})=>{const{t:y}=we(),{git:V}=At(),T=ae(i.useCallback(b=>b.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),q=ae(b=>b.setDiff),X=ae(b=>b.fetchStatus),se=te(b=>b.setDiffFileLayout),[Y,J]=i.useState(0),[B,_]=i.useState(null),[re,L]=i.useState(!1),[P,G]=i.useState(null),[D,$]=i.useState(!1),[Q,O]=i.useState(null),[W,ie]=i.useState(null),ce=i.useRef(null),ke=i.useRef(null),pe=i.useMemo(()=>Lt(e),[e]),Be=r==="side-by-side",ye=I?"full":"patch",he=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Z=i.useMemo(()=>M||(j?W:Q||(T?{original:T.original,modified:T.modified,isBinary:T.isBinary,contextMode:"full"}:null)),[T,M,Q,j,W]),Re=Z?.contextMode===ye,x=i.useCallback(b=>{ke.current=b,m(e.path,b)},[e.path,m]),ge=i.useCallback(b=>{u(e.path,b)},[e.path,u]),ue=i.useCallback(()=>{h(e.path)},[e.path,h]);i.useEffect(()=>{j?ie(null):O(null),_(null),ce.current=null},[he,j]),i.useEffect(()=>{if(!f||!p)return;if(!s||M||Z&&Re){ce.current=null,L(!1);return}const b=`${s}::${e.path}::${j?"staged":"unstaged"}::${he}::${ye}::${Y}`;if(ce.current===b)return;ce.current=b,_(null),L(!0);let k=!1;const de=ot(),Le=I?ts:ns,Me=Ve(e.path)?V.getGitFileDiff(s,{path:e.path,staged:j}):V.getGitDiff(s,{path:e.path,staged:j,contextLines:Le}),Te=es,_e=new Promise((A,K)=>{setTimeout(()=>K(new Error(`Timed out after ${Te}ms`)),Te)});return Promise.race([Me,_e]).then(A=>{if(!k){if("diff"in A){const K=it(e.path,A.diff,ye);j?ie(K):O(K)}else{const K={original:A.original??"",modified:A.modified??"",isBinary:A.isBinary,contextMode:"full"};j?ie(K):q(s,e.path,K,de)}L(!1)}}).catch(A=>{if(k)return;const K=A instanceof Error?A.message:String(A);_(K),L(!1)}),()=>{k=!0,ce.current===b&&(ce.current=null)}},[ye,Z,Re,Y,s,e.path,he,V,M,f,p,I,q,j]);const De=i.useCallback(()=>{ge(!f),ue()},[ge,ue,f]),fe=i.useCallback(async b=>{if(!(!s||P!==null)){G(b);try{b==="stage"?await V.stageGitFile(s,e.path):b==="unstage"?await V.unstageGitFile(s,e.path):await V.revertGitFile(s,e.path,{scope:"working"}),J(k=>k+1),await X(s,V)}catch(k){const de=b==="unstage"?"gitView.toast.unstageFileFailed":b==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";We.error(k instanceof Error?k.message:y(de))}finally{G(k=>k===b?null:k)}}},[s,X,e.path,P,V,y]);return n.jsxs("div",{ref:x,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:De,onKeyDown:b=>{b.target===b.currentTarget&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),De())},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",d?"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:f?n.jsx(R,{name:"arrow-down-s",className:"size-4"}):n.jsx(R,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:pe.color},title:y(pe.descriptionKey),"aria-label":y(pe.descriptionKey),children:pe.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Vt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const b=e.path.lastIndexOf("/");if(b===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const k=e.path.slice(0,b),de=e.path.slice(b+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:k}),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:de})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Mt(e.insertions,e.deletions),g&&v?n.jsx(me,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:y("diffView.actions.openFileInEditorAtChange"),onClick:b=>{b.stopPropagation(),v(e.path,Z)},disabled:l,children:l?n.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(R,{name:"edit",className:"size-3.5"})}):null,n.jsx(Et,{mode:Be?"side-by-side":"unified",onModeChange:b=>{const k=b==="side-by-side"?"side-by-side":"inline";se(e.path,k)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!p&&!B?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,B?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:B}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(b=>b+1),children:y("diffView.actions.retry")})]}):null,p&&re&&!Z&&!B?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),y("diffView.state.loadingDiff")]}):null,p&&Z&&!D&&e.insertions+e.deletions>Nt?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:e.insertions+e.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:()=>$(!0),children:y("diffView.actions.renderAnyway")})]}):null,p&&Z&&(D||e.insertions+e.deletions<=Nt)?n.jsxs(n.Fragment,{children:[n.jsx(xs,{filePath:e.path,diff:Z,renderSideBySide:Be,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:ne?null:n.jsx(bs,{filePath:e.path,staged:j,busyAction:P,disabled:P!==null,onAction:fe})})})]}):null]})]})}),Bi=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:r=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:f,targetFilePath:p=null,flushContent:h=!1})=>{const{t:u}=we(),{git:m,files:g}=At(),l=hn(),v=te(t=>t.openContextSurface),j=On(t=>t.requestSource),{screenWidth:I,isMobile:M}=gn(),ne=xn(l??null),y=bn(l??null),V=wn(l??null),T=ae(t=>t.setActiveDirectory),q=ae(t=>t.ensureStatus),X=ae(t=>t.fetchStatus),se=ae(t=>t.fetchBranches),Y=ae(t=>t.clearDiffCache),J=ae(t=>t.setDiff),[B,_]=i.useState(null),[re,L]=i.useState(!1),[P,G]=i.useState(null),[D,$]=i.useState(()=>new Set),[Q,O]=i.useState(()=>new Set),[W,ie]=i.useState(!1),[ce,ke]=i.useState(0),[pe,Be]=i.useState(()=>new Map),[ye,he]=i.useState(!1),[Z,Re]=i.useState(!1),[x,ge]=i.useState(d);i.useEffect(()=>{ge(d)},[d]);const ue=te(t=>t.pendingDiffFile),De=te(t=>t.pendingDiffStaged),fe=te(t=>t.pendingDiffScope),b=te(t=>t.setPendingDiffFile),k=te(t=>t.diffLayoutPreference),de=te(t=>t.diffFileLayout),Le=te(t=>t.setDiffFileLayout),Me=te(t=>t.diffWrapLines),Te=te(t=>t.setDiffWrapLines),_e=te(t=>t.openContextFileAtLine),A=yt(t=>t.currentSessionId),K=yn(A??"",l??void 0),He=Me,Ue=x==="staged"?!0:x==="working"?!1:null,Ie=Ue??re,qe=M||I<=768,Tt=!!A&&x!=="turn"&&!qe&&!Ge(),_t=x!=="turn"&&!qe&&!Ge(),It=!s&&!qe&&I>=1024,ve=i.useRef(null),Ae=i.useRef(new Map),xe=i.useRef(null),z=i.useRef(null),je=i.useRef(!1),Se=i.useRef(null),at=i.useRef(null),Xe=i.useRef(null),Ye=i.useRef(null),lt=i.useCallback(()=>{const t=ve.current;if(!t)return null;const o=t.getBoundingClientRect().top,c=[];for(const[w,S]of Ae.current)S&&c.push({path:w,top:S.getBoundingClientRect().top});return jt(o,c)},[]),Ne=i.useCallback(()=>{xe.current=null,je.current=!1,G(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)},[]),Fe=i.useCallback(t=>{$(o=>{if(o.has(t))return o;const c=new Set(o);return c.add(t),c})},[]),Ee=i.useMemo(()=>{for(let t=K.length-1;t>=0;t-=1){const o=K[t];if(o.role==="user")return ds(o.summary?.diffs)}return[]},[K]),Ot=i.useMemo(()=>{const t=new Map;for(const o of Ee)if(o.file){if(typeof o.patch=="string"){t.set(o.file,it(o.file,o.patch,"patch"));continue}t.set(o.file,{original:o.before??"",modified:o.after??"",contextMode:"full"})}return t},[Ee]),zt=i.useMemo(()=>y?.files?y.files.filter(kt).length:0,[y]),Pt=i.useMemo(()=>y?.files?y.files.filter(Ct).length:0,[y]),Gt=Ee.length,C=y?.current??null,Ce=ae(t=>l?t.directories.get(l)?.branches??null:null),$t=ae(t=>l?t.directories.get(l)?.isLoadingBranches??!1:!1),Wt=i.useCallback(()=>{l&&se(l,m)},[l,se,m]),Kt=Yn(l??null,ne!==!1,$t,!!Ce,Wt,is),ct=i.useMemo(()=>{const t=y?.tracking?.trim().split("/")[0];return(t&&Ce?.defaultBranches?.[t])??Ce?.defaultBranches?.origin??null},[Ce,y?.tracking]),Je=!Ge()&&Hn(C,ct),Ht=y!==null,ut=Ge()||Kt||Un(C,ct,Ht,Ce!==null),Ut=vt(t=>t.setOverride),qt=vt(i.useCallback(t=>l&&C?t.overrides[Ke(l,C)]??null:null,[C,l])),[Xt,Qe]=i.useState(null),[Yt,Ze]=i.useState(!1),[ft,Jt]=i.useState("");i.useEffect(()=>{const t=qn(x,!ut);t!==x&&(ge(t),t==="working"&&f?.("working"))},[x,ut,f]),i.useEffect(()=>{if(!Je||!l||!C){Qe(null),Ze(!1);return}let t=!1;return Ze(!1),vn(l,C).then(o=>{t||Qe(o.base)}).catch(()=>{t||Qe(null)}).finally(()=>{t||Ze(!0)}),()=>{t=!0}},[C,l,Je]);const oe=qt??Xt,[Oe,dt]=i.useState(null),[mt,pt]=i.useState(null),ze=i.useRef(0),et=i.useCallback(()=>{if(!l||!C||!oe)return;const t=ze.current+1;ze.current=t,dt(null),pt(null),jn(l,{base:oe,head:C}).then(o=>{ze.current===t&&dt(o)}).catch(o=>{ze.current===t&&pt(o instanceof Error?o.message:u("diffView.branch.loadError"))})},[oe,C,l,u]);i.useEffect(()=>{x==="branch"&&et()},[x,et]);const ht=x==="branch"&&l&&C&&oe?Xn(l,oe,C):null,Qt=i.useMemo(()=>x==="branch"?Array.from(D).sort().join("\0"):"",[x,D]),Zt=i.useCallback(t=>!l||!oe||!C?Promise.reject(new Error("branch range is unavailable")):Sn(l,{base:oe,head:C,path:t}).then(o=>it(t,o.diff,"patch")),[oe,C,l]),en=Jn(ht,Qt,ht?Zt:null,rs),tn=Oe?.length??null,N=i.useMemo(()=>{if(x==="branch")return(Oe??[]).map(c=>({path:c.path,index:"",working_dir:c.status,insertions:0,deletions:0,isNew:c.status==="A"})).sort((c,w)=>c.path.localeCompare(w.path));if(x==="turn")return Ee.map(c=>({path:c.file??"",index:"",working_dir:ms(c.status),insertions:c.additions??0,deletions:c.deletions??0,isNew:c.status==="added"})).filter(c=>c.path).sort((c,w)=>c.path.localeCompare(w.path));if(!y?.files)return[];const t=y.diffStats??{},o=x==="staged"?Ct:x==="working"?kt:()=>!0;return y.files.filter(o).map(c=>({...c,insertions:t[c.path]?.insertions??0,deletions:t[c.path]?.deletions??0,isNew:cs(c)})).sort((c,w)=>c.path.localeCompare(w.path))},[x,Oe,Ee,y]),tt=i.useMemo(()=>N.map(t=>t.path).join("\0"),[N]);i.useEffect(()=>{const t=tt?tt.split("\0"):[],o=new Set(t),c=`${l??""}:${x}:${e?"collapsed":"default"}`,w=at.current!==c;at.current=c,$(S=>{if(w){const E=e?0:ss(t.length);return new Set(t.slice(0,E))}let H=!1;const F=new Set;for(const E of S){if(!o.has(E)){H=!0;continue}F.add(E)}return H?F:S}),O(S=>{if(w)return new Set;let H=!1;const F=new Set;for(const E of S){if(!o.has(E)){H=!0;continue}F.add(E)}return H?F:S})},[x,tt,l,e]);const gt=i.useCallback(()=>{Se.current=null;const t=ve.current;if(!t)return;const o=t.getBoundingClientRect(),c=o.top-Ft,w=o.bottom+Ft,S={},H=[];for(const[F,E]of Ae.current){if(!E)continue;const U=E.getBoundingClientRect();H.push({path:F,top:U.top}),D.has(F)&&(U.bottom<c||U.top>w||(S[F]=!0))}Xe.current=jt(o.top,H),O(F=>{let E=!1;const U=new Set(F);for(const wt of Object.keys(S))U.has(wt)||(U.add(wt),E=!0);return E?U:F})},[D]),ee=i.useCallback(()=>{typeof window>"u"||Se.current===null&&(Se.current=window.requestAnimationFrame(gt))},[gt]);i.useEffect(()=>{const t=ve.current;if(t)return ee(),t.addEventListener("scroll",ee,{passive:!0}),window.addEventListener("resize",ee),()=>{t.removeEventListener("scroll",ee),window.removeEventListener("resize",ee),Se.current!==null&&(window.cancelAnimationFrame(Se.current),Se.current=null)}},[N,D,ee]);const nt=i.useCallback(t=>{const o=de[t.path];if(o)return o;if(k==="inline")return"inline";if(k==="side-by-side")return"side-by-side";const c=I<Zn;return t.isNew||c?"inline":"side-by-side"},[de,k,I]),xt=i.useMemo(()=>N.length===0?null:N.every(t=>nt(t)==="side-by-side")?"side-by-side":"inline",[N,nt]);i.useEffect(()=>{l&&(T(l),q(l,m))},[l,T,q,m]),i.useEffect(()=>{if(l)return Nn.onGitRefreshHint(t=>{Rt(t.directory)===Rt(l)&&(t.paths?.length&&(Ye.current=lt()??Xe.current,Y(l,t.paths),Be(o=>{const c=new Map(o);for(const w of t.paths??[])c.set(w,(c.get(w)??0)+1);return c})),X(l,m,{silent:!0}))})},[lt,Y,l,X,m]),i.useLayoutEffect(()=>{const t=Ye.current;if(!t)return;Ye.current=null;const o=ve.current,c=Ae.current.get(t.path);if(!o||!c)return;const w=o.getBoundingClientRect().top,S=c.getBoundingClientRect().top-w;o.scrollTop=Qn(o.scrollTop,t.topOffset,S,o.scrollHeight-o.clientHeight),Xe.current=t},[pe]),i.useEffect(()=>{x!=="all"&&!fe||ue&&(fe&&ge(fe),_(ue),L(fe==="staged"||!fe&&De),b(null),je.current=!0,xe.current=ue,Fe(ue),ke(t=>t+1))},[x,Fe,ue,fe,De,b]),i.useEffect(()=>{if(x==="all")return;const t=p?.trim();t&&(_(t),L(x==="staged"),je.current=!0,xe.current=t,Fe(t),ke(o=>o+1))},[x,Fe,p]),i.useEffect(()=>{if(!B)return;N.some(o=>o.path===B)||(_(null),L(!1))},[N,B]);const nn=i.useCallback((t,o)=>{const c=Ae.current;o?c.set(t,o):c.delete(t),ee()},[ee]),sn=i.useCallback((t,o)=>{Ne(),$(c=>{const w=c.has(t);if(o===w)return c;const S=new Set(c);return o?S.add(t):S.delete(t),S}),o||O(c=>{if(!c.has(t))return c;const w=new Set(c);return w.delete(t),w}),ee()},[Ne,ee]),rn=i.useCallback(()=>{Ne(),$(t=>t.size>0?new Set:new Set(N.map(o=>o.path))),O(new Set),ee()},[Ne,N,ee]),on=i.useCallback(async t=>{if(!A)return;const o=yt.getState().getDirectoryForSession(A)||l||"";if(!o){We.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}Re(!0);try{await Fn({originalSessionID:A,directory:o,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}),he(!1)}catch(c){console.error("[review-flow] failed to start review flow",c),We.error(c instanceof Error?c.message:u("diffView.reviewDialog.toast.startFailed"))}finally{Re(!1)}},[A,l,u]),Pe=i.useCallback(t=>{const o=Ae.current.get(t),c=ve.current;if(!o||!c)return!1;const w=o.getBoundingClientRect().top-c.getBoundingClientRect().top;return c.scrollTo({top:c.scrollTop+w,behavior:"auto"}),!0},[]);i.useEffect(()=>{if(!xe.current)return;let o=0;const c=20;let w=!1;const S=(F=!0)=>{w||(w=!0,xe.current=null,je.current=!1,F&&G(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null))},H=()=>{if(w){z.current=null;return}const F=xe.current;if(!F){S(),z.current=null;return}if(!Pe(F)){o+=1,o<c?z.current=window.requestAnimationFrame(H):(S(),z.current=null);return}if(r&&je.current){G(F),S(!1);return}S()};return z.current=window.requestAnimationFrame(H),()=>{w=!0,z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)}},[r,ce,Pe]);const an=i.useCallback(t=>{},[]),ln=i.useCallback(t=>{Ne(),_(t),L(!1),je.current=!0,xe.current=t,Fe(t),ke(o=>o+1),Pe(t)},[Ne,Fe,Pe]),cn=i.useCallback(t=>{const o=t==="side-by-side"?"side-by-side":"inline";N.forEach(c=>{Le(c.path,o)})},[N,Le]),[un,bt]=i.useState(null),fn=i.useCallback(async(t,o)=>{if(!l||!t)return;bt(t);const c=ot();try{let w=null;if(o?.patch&&!o.isBinary&&!Ve(t)?w=St(o.patch):o&&o.contextMode==="full"&&!o.isBinary&&!Ve(t)&&(w=Dt(o.original,o.modified)),w===null)try{const U=await m.getGitDiff(l,{path:t,staged:Ie,contextLines:3});w=St(U.diff)}catch{w=null}let S=o;if(w===null||!S){const U=await m.getGitFileDiff(l,{path:t,staged:Ie});S={original:U.original??"",modified:U.modified??"",isBinary:U.isBinary},Ie||J(l,t,S,c)}const H=w??(S.isBinary||Ve(t)?1:Dt(S.original,S.modified)),F=us(l,t),E=await zn(g,F,{directory:l});if(!E.ok){We.error(Pn(E.reason));return}_e(l,F,H,1)}finally{bt(w=>w===t?null:w)}},[Ie,l,g,m,_e,J]),dn=()=>{if(!l)return null;const t=o=>Ue!==null?Ue:re&&o===B;return n.jsxs("div",{className:le("flex min-w-0 flex-1 min-h-0 h-full",h?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[It&&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:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),n.jsx(hs,{changedFiles:N,selectedFile:null,onSelectFile:ln})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(rt,{ref:ve,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:N.map(o=>n.jsx(ws,{directory:l,file:o,layout:nt(o),wrapLines:He,isSelected:!1,isExpanded:D.has(o.path),isMounted:Q.has(o.path)||o.path===P,onSelect:an,onExpandedChange:sn,registerSectionRef:nn,showOpenInEditorAction:a&&x!=="turn",isOpeningInEditor:un===o.path,onOpenInEditor:(c,w)=>{fn(c,w)},staged:t(o.path),loadFullFiles:W,readOnlyActions:x==="branch",initialDiffData:x==="turn"?Ot.get(o.path)??null:x==="branch"?en.get(o.path)??null:null},`${o.path}:${pe.get(o.path)??0}`))})})})]})},mn=()=>{if(!l)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(x!=="turn"&&V&&!y)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(x!=="turn"&&ne===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(x==="branch"){if(!Yt)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!oe){const t=ft.trim().toLowerCase(),o=(Ce?.all??[]).map(c=>c.replace(/^remotes\//,"")).filter(c=>c!==C&&!c.endsWith(`/${C}`)).filter(c=>!t||c.toLowerCase().includes(t)).sort();return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(R,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("diffView.branch.noBaseDescription")}),n.jsx("input",{type:"text",value:ft,onChange:c=>Jt(c.target.value),placeholder:u("gitView.branch.searchPlaceholder"),"aria-label":u("gitView.branch.searchPlaceholder"),className:"w-full max-w-sm rounded-md border border-border/60 bg-[var(--surface-elevated)] px-2.5 py-1.5 typography-meta text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"}),n.jsx(rt,{outerClassName:"max-h-48 w-full max-w-sm min-h-0",className:"px-1 py-1",children:o.length===0?n.jsx("div",{className:"px-2 py-3 typography-meta text-muted-foreground",children:u("gitView.branch.empty")}):n.jsx("div",{className:"flex flex-col gap-0.5",children:o.map(c=>n.jsxs("button",{type:"button",onClick:()=>l&&C&&Ut(l,C,c),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[n.jsx(R,{name:"git-branch",className:"size-3.5 text-primary"}),n.jsx("span",{className:"truncate typography-ui-label text-foreground",title:c,children:c})]},c))})})]})}if(mt)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:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:mt}),n.jsx(me,{variant:"outline",size:"sm",onClick:()=>et(),children:u("diffView.actions.retry")})]});if(Oe===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return N.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:x==="turn"?u("diffView.state.noLastTurnChanges"):x==="branch"&&oe?u("diffView.branch.empty",{base:oe}):u("diffView.state.cleanWorkingTree")}):dn()};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:[!M&&(x==="working"||x==="staged"||x==="turn"||x==="branch"?n.jsx(ps,{scope:x,workingCount:zt,stagedCount:Pt,turnCount:Gt,branchCount:tn,showBranchOption:Je,onScopeChange:t=>{ge(t),f?.(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:V&&!y?u("diffView.state.loadingChanges"):N.length===1?u("diffView.summary.changedFilesSingle",{count:N.length}):u("diffView.summary.changedFilesPlural",{count:N.length})})})),N.length>0&&n.jsxs(me,{variant:"ghost",size:"sm",onClick:rn,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:D.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(R,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:D.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),N.length>0&&Tt&&n.jsxs(me,{variant:"default",size:"sm",onClick:()=>he(!0),disabled:Z,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[Z?n.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(R,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),N.length>0&&_t&&n.jsxs(me,{variant:"outline",size:"sm",onClick:()=>{const t=l??"";j(t,{kind:"working-tree",scope:x==="staged"||x==="working"?x:"all"}),v(t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",Gn),"aria-label":u("walkthrough.action.open"),children:[n.jsx(R,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),N.length>0&&n.jsxs(Cn,{children:[n.jsx(kn,{asChild:!0,children:n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>ie(t=>!t),"aria-pressed":W,"aria-label":u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:le("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",W&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(R,{name:"file-download",className:"size-4"})})}),n.jsx(Rn,{children:n.jsx("p",{children:u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>Te(!Me),className:le("h-5 w-5 p-0 transition-opacity",He?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(He?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(R,{name:"text-wrap",className:"size-4"})}),xt&&n.jsx(Et,{mode:xt==="side-by-side"?"side-by-side":"unified",onModeChange:cn})]}),n.jsx(Dn,{open:ye,onOpenChange:he,projectDirectory:l??null,submitting:Z,onConfirm:on}),mn()]})};export{Bi as DiffView};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{R as n,j as s,f as Gt}from"./vendor-react-BUCujlKS.js";import{Q as Kn,R as Hn,S as qn,T as _n,aj as xi,n as Ee,u as me,cW as Jn,B as vi,v as Zn,r as wi,V as bi,e as Xn,cU as Yn,aJ as Qn,cV as ea,a as ta}from"./index-Cwmuwk3V.js";import{f as Ds,S as ks,B as k,h as B,V as sa,L as ra,aW as ia,a0 as na,a1 as aa,c0 as oa,h9 as yi,ha as la,gG as ca,t as O,l as ji,aa as tr,bX as js,ct as da,b as ua,hb as sr,ab as Fi,hc as Ni,bY as Ci,bZ as fa,fZ as ma,hd as pa,bt as ha,he as ga,bu as Ai,bv as Ii,bw as Oi,bx as Bi,by as $i,bz as Wi,I as g,aV as lr,aS as cr,ad as Ns,aU as dr,aR as Cs,aY as pt,aZ as ht,a_ as gt,bW as rr,ac as ir,bS as Si,bA as xa,bB as va,gF as nr,g as Ts,aT as wa,a$ as ba}from"./useAppFontEffects-B53Rb6m7.js";import{w as ya,x as ja,y as Fa,z as Na,A as Ca}from"./runtimeEndpointReset-ovNbaZ-x.js";import{c as ki,s as Sa,C as Ti,P as ar}from"./shikiHighlight-DCT2Sq_z.js";import{a as ka}from"./vendor-codemirror-state-C9awkmn-.js";import{E as kt}from"./vendor-codemirror-view-CiLROUVV.js";import{F as Ta,J as Va}from"./JsonTreeView-KnXFN2A-.js";import{ensurePierreThemeRegistered as Vi,getResolvedShikiTheme as Da}from"./appThemeRegistry-BK0dHKa6.js";import{u as Fs,c as Ra,e as Ea}from"./scheduledTasksApi-BFSlqgnG.js";import{D as Pa}from"./DiagramEditor-BPECg1jS.js";import{u as Ma,n as za}from"./useInlineCommentController-DSfrIBKT.js";import{b as La}from"./CodeMirrorCommentWidgets-C36E738Y.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C9ioTTSo.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DsHmyMwp.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BEARQjgn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-vch3tJ4c.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.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-pcwCTWjC.js";import"./computeVirtualFileMetrics-DkRR5b75.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-X_7XPoTH.js";import"./isFilePlainText-BbV-39jl.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Ct3Q0DsD.js";const Aa=(d,e)=>{if(!e)return null;const r=Number.parseInt(d.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Di=(d,e)=>{const r=d.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},Ri=(d,e,r)=>{const m=d.state.doc.line(e),x=Math.max(1,Math.min(r,m.length+1)),v=m.from+x-1;d.dispatch({selection:ka.cursor(v),effects:kt.scrollIntoView(v,{y:"center"})})};function Ia({open:d,onOpenChange:e,view:r,variant:m="overlay"}){const{t:x}=Ds(),[v,j]=n.useState(""),b=n.useRef(null),p=n.useRef(!1),F=n.useRef(null),h=n.useRef(null),N=n.useMemo(()=>Aa(v,r),[v,r]);n.useEffect(()=>{!d||!r||(p.current=!1,b.current=Di(r,r.state.selection),j(""))},[d,r]),n.useEffect(()=>{d&&window.requestAnimationFrame(()=>{h.current?.focus(),h.current?.select()})},[d]),n.useEffect(()=>{if(!(!d||!r||!b.current)){if(N===null){const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})});return}Ri(r,N,b.current.character)}},[N,d,r]);const L=n.useCallback(()=>{if(!r||p.current||!b.current)return;const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})})},[r]),R=n.useCallback(o=>{o||L(),e(o)},[e,L]),C=n.useCallback(()=>{!r||N===null||!b.current||(p.current=!0,Ri(r,N,b.current.character),e(!1),r.focus())},[N,e,r]);n.useEffect(()=>{if(!d)return;const o=W=>{const _=F.current,A=W.target;!_||!(A instanceof Node)||_.contains(A)||R(!1)},q=W=>{W.key==="Escape"&&(W.preventDefault(),R(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",q,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",q,!0)}},[R,d,m]);const E=n.useMemo(()=>{if(!r)return x("goToLineDialog.helper.editorUnavailable");if(N===null){const o=b.current??Di(r,r.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:N})},[N,x,r]);return m==="inline"?d?s.jsxs("div",{ref:F,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(ks,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>j(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(k,{variant:"outline",size:"xs",onClick:C,disabled:!r||N===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:F,className:B("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",d?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(ks,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>j(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:E})]})})}function Oa(d){return!(!d.autoSaveEnabled||!d.isDirty||!d.canWrite||d.isSaving||d.fileLoading||d.isNonEditableBinary||!d.selectedFilePath||d.loadedFilePath!==d.selectedFilePath)}function Ba(d){return d.selectedFilePath?d.isDirty?!(d.fileLoading||d.loadedFilePath!==d.selectedFilePath||d.isNonEditableBinary||d.draftContent===""&&d.fileContent!==""&&d.loadedFilePath!==d.selectedFilePath):!0:!1}const $a=d=>{const e=z(d);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const m=e.slice(0,r);return/^[A-Za-z]:$/.test(m)?`${m}/`:m},Wa=d=>{const e=Gt.c(8),{label:r,iconDataUrl:m}=d,[x,v]=n.useState(!1);let j;e[0]!==r?(j=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=j):j=e[1];const b=j;if(m&&!x){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>v(!0),e[2]=h):h=e[2];let N;return e[3]!==m?(N=s.jsx("img",{src:m,alt:"",className:"size-4 rounded-sm",onError:h}),e[3]=m,e[4]=N):N=e[4],N}let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=B("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=p):p=e[5];let F;return e[6]!==b?(F=s.jsx("span",{className:p,children:b}),e[6]=b,e[7]=F):F=e[7],F},Ua=d=>d.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),z=d=>{if(!d)return"";const e=d.replace(/\\/g,"/"),r=e.startsWith("//");let m=e.replace(/\/+/g,"/");r&&!m.startsWith("//")&&(m=`/${m}`);const x=m==="/",v=/^[A-Za-z]:\/$/.test(m);return!x&&!v&&(m=m.replace(/\/+$/,"")),m},Ga=d=>d.startsWith("/")||d.startsWith("//")||/^[A-Za-z]:\//.test(d),Ut=d=>/^[A-Za-z]:\//.test(d)?d.toLowerCase():d,Vs=(d,e)=>{const r=z(e),m=z(d);if(!r||!m)return!1;const x=Ut(r),v=Ut(m);return v===x||v.startsWith(`${x}/`)},Ei=(d,e)=>{const r=z(e),m=z(d);if(!Vs(m,r))return[];const v=m.slice(r.length).replace(/^\//,"").split("/"),j=[];let b=r;for(let p=0;p<v.length-1;p++)b=b?`${b}/${v[p]}`:v[p],j.push(b);return j},Ss=(d,e)=>{if(!e)return"";const r=z(e);if(!d||!Vs(r,d))return r;const m=r.slice(d.length);return m.startsWith("/")?m.slice(1):m},Ka=new Set(["node_modules"]),Ha=d=>{const e=Gt.c(3),{status:r}=d;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=m):m=e[0];const x=m[r];let v;return e[1]!==x?(v=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=v):v=e[2],v},Pi=d=>{const e=Gt.c(11),{name:r}=d,m=n.useRef(null),x=n.useRef(null),[v,j]=n.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const L=m.current,R=x.current;if(!L||!R)return;const C=()=>{j(R.scrollWidth>L.clientWidth+1)};C();const E=new ResizeObserver(C);return E.observe(L),E.observe(R),()=>{E.disconnect()}},e[0]=b):b=e[0];let p;e[1]!==r?(p=[r],e[1]=r,e[2]=p):p=e[2],n.useLayoutEffect(b,p);let F;e[3]!==r?(F=s.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=F):F=e[4];let h;e[5]!==r||e[6]!==v?(h=v?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=v,e[7]=h):h=e[7];let N;return e[8]!==F||e[9]!==h?(N=s.jsxs("span",{ref:m,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[F,h]}),e[8]=F,e[9]=h,e[10]=N):N=e[10],N},qa=d=>Ka.has(d),_a=d=>{const e=z(d);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Ja=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},Mi=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},is=2e5,Za=d=>{let e=0,r=0;for(let m=0;m<d.length;m+=1)d.charCodeAt(m)===10&&(m>0&&d.charCodeAt(m-1)===13?e+=1:r+=1);return e>r?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`},Ui=d=>d.replace(/\r\n/g,`
|
|
4
|
+
`).replace(/\r/g,`
|
|
5
|
+
`),Xa=(d,e)=>{const r=Ui(d);return e===`\r
|
|
6
|
+
`?r.replace(/\n/g,`\r
|
|
7
|
+
`):r},Gi=(d,e)=>s.jsx(Ns,{filePath:d,extension:e}),zi=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Ya=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},or=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Qa=d=>{const e=Gt.c(76),{node:r,root:m,isExpanded:x,isActive:v,isMobile:j,isBrowserClient:b,alwaysShowActions:p,status:F,badge:h,permissions:N,downloadFile:L,contextMenuPath:R,setContextMenuPath:C,rightClickMenuPath:E,setRightClickMenuPath:o,onSelect:q,onToggle:W,onRevealPath:_,onOpenDialog:A}=d,{t:V}=Ds(),D=r.type==="directory",{canRename:oe,canCreateFile:Y,canCreateFolder:Q,canDelete:I,canReveal:le}=N,Pe=!D&&!!L,U=le&&!b,J=oe||Y||Q||I||Pe||U;let ee;e[0]!==J||e[1]!==r.path||e[2]!==o?(ee=ue=>{J&&(ue?.preventDefault(),o(r.path))},e[0]=J,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const pe=ee;let te;e[4]!==D||e[5]!==r||e[6]!==q||e[7]!==W?(te=()=>{D?W(r.path):q(r)},e[4]=D,e[5]=r,e[6]=q,e[7]=W,e[8]=te):te=e[8];const he=te;let ce;e[9]!==r.path||e[10]!==C||e[11]!==o?(ce=ue=>{ue.stopPropagation(),o(null),C(r.path)},e[9]=r.path,e[10]=C,e[11]=o,e[12]=ce):ce=e[12];const et=ce;let Tt;e[13]!==Y||e[14]!==Q||e[15]!==I||e[16]!==oe||e[17]!==U||e[18]!==L||e[19]!==b||e[20]!==D||e[21]!==r||e[22]!==A||e[23]!==_||e[24]!==m||e[25]!==V?(Tt=ue=>{const{Item:xe,Separator:wt}=ue;return s.jsxs(s.Fragment,{children:[oe&&s.jsxs(xe,{onClick:S=>{S.stopPropagation(),A("rename",r)},children:[s.jsx(g,{name:"edit",className:"mr-2 size-4"})," ",V("sidebarFilesTree.menu.rename")]}),s.jsxs(xe,{onClick:S=>{S.stopPropagation(),Ts(r.path).then(ve=>{if(ve.ok){O.success(V("sidebarFilesTree.toast.pathCopied"));return}O.error(V("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy",className:"mr-2 size-4"})," ",V("sidebarFilesTree.menu.copyPath")]}),s.jsxs(xe,{onClick:S=>{S.stopPropagation();const ve=Ss(m,r.path)||r.path;Ts(ve).then(_e=>{if(_e.ok){O.success(V("filesView.toast.relativePathCopied"));return}O.error(V("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy-2",className:"mr-2 size-4"})," ",V("filesView.tree.menu.copyRelativePath")]}),!D&&L&&s.jsxs(xe,{onClick:S=>{S.stopPropagation(),L(r.path).catch(ve=>{console.error("Download failed:",ve),O.error(V("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"})," ",V(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&s.jsxs(xe,{onClick:S=>{S.stopPropagation(),_(r.path)},children:[s.jsx(g,{name:"folder-received",className:"mr-2 size-4"})," ",V(ba())]}),D&&(Y||Q)&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),Y&&s.jsxs(xe,{onClick:S=>{S.stopPropagation(),A("createFile",r)},children:[s.jsx(g,{name:"file-add",className:"mr-2 size-4"})," ",V("sidebarFilesTree.menu.newFile")]}),Q&&s.jsxs(xe,{onClick:S=>{S.stopPropagation(),A("createFolder",r)},children:[s.jsx(g,{name:"folder-add",className:"mr-2 size-4"})," ",V("sidebarFilesTree.menu.newFolder")]})]}),I&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),s.jsxs(xe,{onClick:S=>{S.stopPropagation(),A("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(g,{name:"delete-bin",className:"mr-2 size-4"})," ",V("sidebarFilesTree.menu.delete")]})]})]})},e[13]=Y,e[14]=Q,e[15]=I,e[16]=oe,e[17]=U,e[18]=L,e[19]=b,e[20]=D,e[21]=r,e[22]=A,e[23]=_,e[24]=m,e[25]=V,e[26]=Tt):Tt=e[26];const qe=Tt,G=E===r.path;let ye;e[27]!==r.path||e[28]!==o?(ye=ue=>o(ue?r.path:null),e[27]=r.path,e[28]=o,e[29]=ye):ye=e[29];const xt=j?void 0:pe;let Me;e[30]!==xt?(Me=s.jsx("div",{className:"group relative flex items-center",onContextMenu:xt}),e[30]=xt,e[31]=Me):Me=e[31];const ze=j?void 0:pe,vt=v?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ge;e[32]!==vt?(ge=B("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",vt),e[32]=vt,e[33]=ge):ge=e[33];let Le;e[34]!==D||e[35]!==x||e[36]!==r.extension||e[37]!==r.path?(Le=D?x?s.jsx(g,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(g,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Gi(r.path,r.extension),e[34]=D,e[35]=x,e[36]=r.extension,e[37]=r.path,e[38]=Le):Le=e[38];let de;e[39]!==r.name||e[40]!==r.path?(de=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=de):de=e[41];let je;e[42]!==D||e[43]!==F?(je=!D&&F&&s.jsx(Ha,{status:F}),e[42]=D,e[43]=F,e[44]=je):je=e[44];let tt;e[45]!==h||e[46]!==D?(tt=D&&h&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[h.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",h.modified]}),h.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",h.added]})]}),e[45]=h,e[46]=D,e[47]=tt):tt=e[47];let st;e[48]!==he||e[49]!==ge||e[50]!==Le||e[51]!==de||e[52]!==je||e[53]!==tt||e[54]!==ze?(st=s.jsxs("button",{type:"button",onClick:he,onContextMenu:ze,className:ge,children:[Le,de,je,tt]}),e[48]=he,e[49]=ge,e[50]=Le,e[51]=de,e[52]=je,e[53]=tt,e[54]=ze,e[55]=st):st=e[55];let Ae;e[56]!==p||e[57]!==R||e[58]!==et||e[59]!==J||e[60]!==j||e[61]!==r.path||e[62]!==qe||e[63]!==C?(Ae=J&&s.jsx("div",{className:B("absolute right-1 top-1/2 -translate-y-1/2",p?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(lr,{open:R===r.path,onOpenChange:ue=>C(ue?r.path:null),children:[s.jsx(cr,{asChild:!0,children:s.jsx(k,{variant:"ghost",size:"icon",className:"size-6",onClick:et,children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})}),s.jsx(dr,{align:"end",side:"bottom",onCloseAutoFocus:()=>C(null),children:qe({Item:Cs,Separator:wa})})]})}),e[56]=p,e[57]=R,e[58]=et,e[59]=J,e[60]=j,e[61]=r.path,e[62]=qe,e[63]=C,e[64]=Ae):Ae=e[64];let Ie;e[65]!==st||e[66]!==Ae||e[67]!==Me?(Ie=s.jsxs(Na,{render:Me,children:[st,Ae]}),e[65]=st,e[66]=Ae,e[67]=Me,e[68]=Ie):Ie=e[68];let Oe;e[69]!==qe?(Oe=s.jsx(ya,{className:"min-w-[180px]",children:qe({Item:Fa,Separator:ja})}),e[69]=qe,e[70]=Oe):Oe=e[70];let rt;return e[71]!==Ie||e[72]!==Oe||e[73]!==G||e[74]!==ye?(rt=s.jsxs(Ca,{open:G,onOpenChange:ye,children:[Ie,Oe]}),e[71]=Ie,e[72]=Oe,e[73]=G,e[74]=ye,e[75]=rt):rt=e[75],rt},eo=d=>{const e=Gt.c(83),{activeDialog:r,dialogData:m,dialogInputValue:x,onDialogInputChange:v,isDialogSubmitting:j,onDialogSubmit:b,onClose:p,inputRef:F}=d,{t:h}=Ds(),N=!!r;let L;e[0]!==p?(L=ce=>!ce&&p(),e[0]=p,e[1]=L):L=e[1];let R;e[2]!==r||e[3]!==h?(R=r==="createFile"&&h("filesView.dialog.createFile.title"),e[2]=r,e[3]=h,e[4]=R):R=e[4];let C;e[5]!==r||e[6]!==h?(C=r==="createFolder"&&h("filesView.dialog.createFolder.title"),e[5]=r,e[6]=h,e[7]=C):C=e[7];let E;e[8]!==r||e[9]!==h?(E=r==="rename"&&h("filesView.dialog.rename.title"),e[8]=r,e[9]=h,e[10]=E):E=e[10];let o;e[11]!==r||e[12]!==h?(o=r==="delete"&&h("filesView.dialog.delete.title"),e[11]=r,e[12]=h,e[13]=o):o=e[13];let q;e[14]!==R||e[15]!==C||e[16]!==E||e[17]!==o?(q=s.jsxs(Bi,{children:[R,C,E,o]}),e[14]=R,e[15]=C,e[16]=E,e[17]=o,e[18]=q):q=e[18];let W;e[19]!==r||e[20]!==m?.path||e[21]!==h?(W=r==="createFile"&&h("filesView.dialog.createFile.description",{path:m?.path??h("filesView.dialog.rootFallback")}),e[19]=r,e[20]=m?.path,e[21]=h,e[22]=W):W=e[22];let _;e[23]!==r||e[24]!==m?.path||e[25]!==h?(_=r==="createFolder"&&h("filesView.dialog.createFolder.description",{path:m?.path??h("filesView.dialog.rootFallback")}),e[23]=r,e[24]=m?.path,e[25]=h,e[26]=_):_=e[26];let A;e[27]!==r||e[28]!==m?.name||e[29]!==h?(A=r==="rename"&&h("filesView.dialog.rename.description",{name:m?.name??""}),e[27]=r,e[28]=m?.name,e[29]=h,e[30]=A):A=e[30];let V;e[31]!==r||e[32]!==m?.name||e[33]!==h?(V=r==="delete"&&h("filesView.dialog.delete.description",{name:m?.name??""}),e[31]=r,e[32]=m?.name,e[33]=h,e[34]=V):V=e[34];let D;e[35]!==A||e[36]!==V||e[37]!==W||e[38]!==_?(D=s.jsxs($i,{children:[W,_,A,V]}),e[35]=A,e[36]=V,e[37]=W,e[38]=_,e[39]=D):D=e[39];let oe;e[40]!==D||e[41]!==q?(oe=s.jsxs(Oi,{children:[q,D]}),e[40]=D,e[41]=q,e[42]=oe):oe=e[42];let Y;e[43]!==r||e[44]!==x||e[45]!==F||e[46]!==v||e[47]!==b||e[48]!==h?(Y=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(ks,{value:x,onChange:ce=>v(ce.target.value),placeholder:h(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ce=>{ce.key==="Enter"&&b()},ref:F})}),e[43]=r,e[44]=x,e[45]=F,e[46]=v,e[47]=b,e[48]=h,e[49]=Y):Y=e[49];let Q;e[50]!==h?(Q=h("filesView.dialog.cancel"),e[50]=h,e[51]=Q):Q=e[51];let I;e[52]!==j||e[53]!==p||e[54]!==Q?(I=s.jsx(k,{variant:"outline",onClick:p,disabled:j,children:Q}),e[52]=j,e[53]=p,e[54]=Q,e[55]=I):I=e[55];const le=r==="delete"?"destructive":"default";let Pe;e[56]!==b?(Pe=()=>{b()},e[56]=b,e[57]=Pe):Pe=e[57];let U;e[58]!==r||e[59]!==x||e[60]!==j?(U=j||r!=="delete"&&!x.trim(),e[58]=r,e[59]=x,e[60]=j,e[61]=U):U=e[61];let J;e[62]!==r||e[63]!==j||e[64]!==h?(J=j?s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}):h(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=j,e[64]=h,e[65]=J):J=e[65];let ee;e[66]!==le||e[67]!==Pe||e[68]!==U||e[69]!==J?(ee=s.jsx(k,{variant:le,onClick:Pe,disabled:U,children:J}),e[66]=le,e[67]=Pe,e[68]=U,e[69]=J,e[70]=ee):ee=e[70];let pe;e[71]!==I||e[72]!==ee?(pe=s.jsxs(Wi,{children:[I,ee]}),e[71]=I,e[72]=ee,e[73]=pe):pe=e[73];let te;e[74]!==F||e[75]!==oe||e[76]!==Y||e[77]!==pe?(te=s.jsxs(Ii,{initialFocus:F,children:[oe,Y,pe]}),e[74]=F,e[75]=oe,e[76]=Y,e[77]=pe,e[78]=te):te=e[78];let he;return e[79]!==N||e[80]!==L||e[81]!==te?(he=s.jsx(Ai,{open:N,onOpenChange:L,children:te}),e[79]=N,e[80]=L,e[81]=te,e[82]=he):he=e[82],he},Li=(d,e,r)=>{const m=Gt.c(8),[x,v]=n.useState(""),[j,b]=n.useState(0);let p,F;m[0]!==d||m[1]!==r||m[2]!==e?(p=()=>{if(!d){v("");return}let N=!1;v("");const L=Xn(),R=Yn(L);Qn(L).then(E=>{N||!E||(v(d),e(null))}).catch(E=>{N||(e(E instanceof Error?E.message:r),v(d))});const C=ea(()=>{N||(v(d),b(to),e(null))});return()=>{N=!0,R(),C()}},F=[d,e,r],m[0]=d,m[1]=r,m[2]=e,m[3]=p,m[4]=F):(p=m[3],F=m[4]),n.useEffect(p,F);let h;return m[5]!==j||m[6]!==x?(h={readyKey:x,nonce:j},m[5]=j,m[6]=x,m[7]=h):h=m[7],h},jc=({mode:d="full"})=>{const{t:e}=Ds(),{files:r,runtime:m}=sa(),{currentTheme:x,availableThemes:v,lightThemeId:j,darkThemeId:b}=ra(),{isMobile:p,isTablet:F,screenWidth:h}=ia(),N=Kn(m.platform),L=p||F,R=Hn(),C=qn(),E=na()??"",o=z(E.trim()),q=d!=="editor-only",W=d==="editor-only"&&!p,_=_n(t=>t.searchFiles),A=aa(E),[V,D]=n.useState(""),oe=oa(V,200),Y=n.useRef(null),[Q,I]=n.useState(!1),[le,Pe]=n.useState(!0),[U,J]=n.useState(!1),[ee,pe]=n.useState(!1),[te,he]=n.useState(!1),ce=n.useRef(null),et=n.useRef(0),Tt=n.useCallback(t=>{et.current=Math.max(0,et.current+(t?1:-1))},[]),qe=n.useCallback(t=>t instanceof Element?t.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);n.useEffect(()=>{if(!te)return;const t=i=>{et.current>0||qe(i.target)||ce.current&&!ce.current.contains(i.target)&&he(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[qe,te]);const[G,ye]=n.useState("edit"),[xt,Me]=n.useState("edit"),[ze,vt]=n.useState("tree"),[ge,Le]=n.useState("edit"),[de,je]=n.useState("preview"),[tt,st]=n.useState(0),Ae=n.useRef({}),Ie=n.useRef({}),Oe=n.useRef({}),rt=n.useRef({}),ue=n.useMemo(()=>v.find(t=>t.metadata.id===j)??xi(!1),[v,j]),xe=n.useMemo(()=>v.find(t=>t.metadata.id===b)??xi(!0),[v,b]);n.useEffect(()=>{Vi(ue),Vi(xe)},[ue,xe]);const wt=n.useMemo(()=>[],[]),S=Ee(t=>o?t.byRoot[o]?.openPaths??wt:wt),ve=Ee(t=>o?t.byRoot[o]?.selectedPath??null:null),_e=Ee(t=>o?t.byRoot[o]?.expandedPaths??wt:wt),Vt=Ee(t=>t.removeOpenPath),it=Ee(t=>t.removeOpenPathsByPrefix),ur=Ee(t=>t.removeExpandedPathsByPrefix),se=Ee(t=>t.setSelectedPath),fr=Ee(t=>t.toggleExpandedPath),ns=Ee(t=>t.expandPaths),Dt=n.useCallback(t=>{const i=z(t),a=i.split("/"),l=a[a.length-1]||i,u=l.includes(".")?l.split(".").pop()?.toLowerCase():void 0;return{name:l,path:i,type:"file",extension:u}},[]),Rt=n.useMemo(()=>S.map(Dt),[S,Dt]),Rs=n.useMemo(()=>{if(ve){const t=Ut(ve);if(S.some(i=>Ut(i)===t))return ve}return S[0]??null},[S,ve]),c=n.useMemo(()=>Rs?Dt(Rs):null,[Rs,Dt]),Be=c?.path??"",[,Ki]=n.useState(0);n.useEffect(()=>{if(!o||!ve)return;const t=Ut(ve);S.some(a=>Ut(a)===t)||se(o,S[0]??null)},[S,o,ve,se]);const as=!!(o&&Be&&!Vs(Be,o)),mr=as?yi(Be):void 0,bt=n.useMemo(()=>({allowOutsideWorkspace:d==="editor-only"&&as,outsideFileGrant:mr,directory:o||void 0}),[d,as,mr,o]),$e=n.useCallback(async t=>{const i=yi(t),a=await la(t,o,d==="editor-only");return a.outsideFileGrant&&a.outsideFileGrant!==i&&Ki(l=>l+1),a},[d,o]),Es=n.useRef(null),[pr,Hi]=n.useState({left:!1,right:!1}),hr=n.useCallback(()=>{const t=Es.current;t&&Hi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),gr=n.useRef(hr);gr.current=hr,n.useEffect(()=>{const t=Es.current;if(!t)return;const i=()=>gr.current();i(),t.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(t),()=>{t.removeEventListener("scroll",i),a.disconnect()}},[Rt.length]);const[xr,Ps]=n.useState({}),[os,Kt]=n.useState({}),Fe=n.useRef(new Set),Ne=n.useRef(new Set),Je=n.useRef(new Map),vr=n.useRef(0),[wr,ls]=n.useState([]),[qi,cs]=n.useState(!1),[T,H]=n.useState(""),{isPlaying:ds,play:_i,stop:Ji}=ca(),[Ve,nt]=n.useState(!1),[Ze,Z]=n.useState(null),[Zi,Ce]=n.useState(""),[we,K]=n.useState(null),[$,X]=n.useState(""),[Et,Ms]=n.useState(!1),[br,Xi]=n.useState(`
|
|
8
|
+
`),Yi=n.useRef(null),We=n.useRef(null),be=n.useRef(null),at=n.useRef(""),Ht=n.useRef(""),Xe=n.useRef(null),yr=n.useRef(null),Ue=n.useRef(null),qt=n.useRef(0),Pt=n.useRef(null),[us,Qi]=n.useState(0),[en,Mt]=n.useState("idle"),[tn,fs]=n.useState(!1),[_t,jr]=n.useState(!1),re=me(t=>t.autoSaveEnabled),sn=me(t=>t.setAutoSaveEnabled),[zs,zt]=n.useState(!1),Lt=n.useRef(null),Jt=n.useRef(null),Zt=n.useRef(null),yt=n.useRef(!1),Xt=n.useRef(null),Yt=n.useRef(null),De=n.useRef(null),rn=n.useRef(null),[nn,Ls]=n.useState(0),At=n.useRef(null),jt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{At.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(At.current),At.current=null)},[]);const[Ft,As]=n.useState(null),[Nt,an]=n.useState(null),[ot,Fr]=n.useState(""),[on,Is]=n.useState(!1),[ln,cn]=n.useState(null),[dn,un]=n.useState(null),[fn,Nr]=n.useState(!1),[mn,Cr]=n.useState(!1),[pn,Os]=n.useState(!1),Sr=!!r.writeFile,kr=!!r.createDirectory,Tr=!!r.rename,Vr=!!r.delete,Dr=!!r.revealPath,hn=Fs(t=>t.availableApps),gn=Fs(t=>t.isCacheStale),Rr=Fs(t=>t.initialize),xn=Fs(t=>t.loadInstalledApps);n.useEffect(()=>{Rr()},[Rr]);const vn=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{O.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),wn=n.useCallback(async t=>{if(!c?.path||await Jn(c.path,t.id,t.appName)||await vi(c.path,t.appName))return;const l=$a(c.path)||o;l&&await vi(l,t.appName)||O.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),Bs=n.useCallback((t,i)=>{As(t),an(i),Fr(t==="rename"&&i.name||""),Is(!1)},[]),[P,Re]=n.useState(null),It=n.useRef(!1),lt=n.useRef(null),[Er,Ot]=n.useState(!1),Ge=me(t=>t.setMainTabGuard),Ke=me(t=>t.pendingFileNavigation),ms=me(t=>t.setPendingFileNavigation),$s=me(t=>t.pendingFileFocusPath),Ws=me(t=>t.setPendingFileFocusPath),Pr=me(t=>t.shortcutOverrides),Mr=me(t=>t.fileEditorKeymap),Qt=ji(t=>t.settingsDefaultFileViewerPreview),bn=ji(t=>t.showMessageTTSButtons),zr=me(t=>t.expandedEditorToolbar);n.useEffect(()=>{const t=()=>{It.current=!1,lt.current=null,Ot(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Xt.current!==null&&window.clearTimeout(Xt.current),Yt.current!==null&&window.clearTimeout(Yt.current)},[]);const yn=n.useCallback((t,i)=>{const a=t.split(`
|
|
9
|
+
`),l=Math.max(1,i.start),u=Math.min(a.length,i.end);return l>u?"":a.slice(l-1,u).join(`
|
|
10
|
+
`)},[]),jn=Ma({source:"file",fileLabel:c?.path??null,language:c?.path&&tr(c.path)||"text",getCodeForRange:t=>yn(T,za(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Lr,commentText:ps,setCommentText:Ar,editingDraftId:hs,setSelection:Ir,saveComment:Or,cancel:es,reset:Br,startEdit:$r,deleteDraft:Wr}=jn;n.useEffect(()=>{Re(null),Br(),Ge(null),X(""),Ms(!1)},[c?.path,Br,Ge]),n.useEffect(()=>{Ir(P)},[P,Ir]),n.useEffect(()=>{if(!P&&!hs)return;const t=a=>{const l=a.target;l.closest('[data-comment-input="true"]')||l.closest('[data-comment-card="true"]')||l.closest(".cm-gutterElement")||l.closest("[data-sonner-toast]")||l.closest("[data-sonner-toaster]")||ps.trim()||(Re(null),es())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[es,ps,hs,P]);const Ur=n.useCallback((t,i)=>{const a=i??P??void 0;i&&Re(i),Or(t,a),Re(null)},[P,Or]),Gr=n.useCallback((t,i)=>{const a=[];for(const l of i){if(!(l&&typeof l.name=="string"&&l.name.length>0)||!R&&l.name.startsWith(".")||!C&&qa(l.name))continue;const u=l.name,f=z(l.path||""),w=f?Ga(f)?f:z(`${t}/${f}`):z(`${t}/${u}`),y=l.isDirectory?"directory":"file",M=y==="file"&&u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;a.push({name:u,path:w,type:y,extension:M})}return Ua(a)},[C,R]),Se=n.useCallback(async t=>{const i=z(t.trim());if(!i||Fe.current.has(i)||Ne.current.has(i))return;Ne.current=new Set(Ne.current),Ne.current.add(i);const a=vr.current+1;vr.current=a,Je.current=new Map(Je.current),Je.current.set(i,a);const l=()=>Je.current.get(i)===a;await(r.listDirectory?r.listDirectory(i).then(f=>f.entries.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory}))):Zn.listLocalDirectory(i).then(f=>f.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory})))).then(f=>{if(!l())return;const w=Gr(i,f);Fe.current=new Set(Fe.current),Fe.current.add(i),Kt(y=>{if(!y[i])return y;const M={...y};return delete M[i],M}),Ps(y=>({...y,[i]:w}))}).catch(f=>{if(!l())return;const w=f instanceof Error?f.message:String(f??"");if(w==="Directory not found"&&o&&i!==o){ur(o,i),Kt(y=>{if(!y[i])return y;const M={...y};return delete M[i],M});return}console.error("Failed to load files directory:",f),Kt(y=>({...y,[i]:w}))}).finally(()=>{l()&&(Je.current=new Map(Je.current),Je.current.delete(i),Ne.current=new Set(Ne.current),Ne.current.delete(i))})},[r,Gr,ur,o]),gs=n.useCallback(async()=>{o&&(Fe.current=new Set,Ne.current=new Set,Je.current=new Map,Kt({}),Ps(t=>Object.keys(t).length===0?t:{}),await Se(o))},[Se,o]),He=n.useCallback(async t=>{if(!t){await gs();return}const i=z(t);Fe.current=new Set(Fe.current),Fe.current.delete(i),Ne.current=new Set(Ne.current),Ne.current.delete(i),await Se(i)},[Se,gs]),Kr=n.useRef(""),Hr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${R?"1":"0"}|g${C?"1":"0"}`,i=Kr.current!==o,a=Hr.current!==t;!i&&!a||(i&&(Kr.current=o,H(""),Z(null),Ce(""),K(null),I(!1)),a&&(Hr.current=t,Fe.current=new Set,Ne.current=new Set,Je.current=new Map,Kt({}),Ps(l=>Object.keys(l).length===0?l:{}),Se(o)))},[Se,o,C,R]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&_e.length>0)for(const i of _e)He(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[_e,r.listDirectory,He]),n.useEffect(()=>{if(!r.listDirectory||_e.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of _e)He(i)},8e3);return()=>clearInterval(t)},[_e,r.listDirectory,He]);const Fn=n.useCallback(async t=>{if(t?.preventDefault(),!Nt||!Ft)return;Is(!0);const i=()=>{As(null)},a=u=>{O.error(u)},l=()=>{Is(!1)};if(Ft==="createFile"){if(!ot.trim()){a(e("sidebarFilesTree.toast.filenameRequired")),l();return}if(!r.writeFile){a(e("sidebarFilesTree.toast.writeNotSupported")),l();return}const u=Nt.path,f=u?`${u}/`:"",w=z(`${f}${ot.trim()}`);await r.writeFile(w,"").then(async y=>{y.success&&(O.success(e("sidebarFilesTree.toast.fileCreated")),await He(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(l);return}if(Ft==="createFolder"){if(!ot.trim()){a(e("sidebarFilesTree.toast.folderNameRequired")),l();return}const u=Nt.path,f=u?`${u}/`:"",w=z(`${f}${ot.trim()}`);await r.createDirectory(w).then(async y=>{y.success&&(O.success(e("sidebarFilesTree.toast.folderCreated")),await He(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(l);return}if(Ft==="rename"){if(!ot.trim()){a(e("sidebarFilesTree.toast.nameRequired")),l();return}if(!r.rename){a(e("sidebarFilesTree.toast.renameNotSupported")),l();return}const u=Nt.path,f=u.split("/").slice(0,-1).join("/"),w=f?`${f}/`:"",y=z(`${w}${ot.trim()}`);await r.rename(u,y).then(async M=>{M.success&&(O.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await He(f),o&&it(o,u),(c?.path===u||c?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),Z(null),Ce(""),K(null),p&&I(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(l);return}if(Ft==="delete"){if(!r.delete){a(e("sidebarFilesTree.toast.deleteNotSupported")),l();return}const u=Nt.path,f=u.split("/").slice(0,-1).join("/");await r.delete(u).then(async w=>{w.success&&(O.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await He(f),o&&it(o,u),(c?.path===u||c?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),Z(null),Ce(""),K(null),p&&I(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(l);return}l()},[Ft,Nt,ot,r,He,p,it,o,c?.path,se,e]);n.useEffect(()=>{if(!E){ls([]),cs(!1);return}const t=oe.trim();if(!t){ls([]),cs(!1);return}let i=!1;return cs(!0),_(E,t,150,{includeHidden:R,respectGitignore:!C,type:"file"}).then(a=>{if(i)return;const u=a.filter(f=>C||!_a(f.path)).map(f=>({name:f.name,path:z(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));ls(u)}).catch(()=>{i||ls([])}).finally(()=>{i||cs(!1)}),()=>{i=!0}},[E,oe,_,R,C]);const qr=n.useCallback(async t=>{const i=await $e(t);if(r.readFile)return(await r.readFile(t,{...i,directory:o||void 0})).content??"";const a=new URLSearchParams({path:t});i.allowOutsideWorkspace&&a.set("allowOutsideWorkspace","true"),i.outsideFileGrant&&a.set("outsideFileGrant",i.outsideFileGrant),o&&a.set("directory",o);const l=await wi(`/api/fs/read?${a.toString()}`);if(!l.ok){const u=await l.json().catch(()=>({error:l.statusText}));throw new Error(u.error||e("filesView.error.readFileFailed"))}return l.text()},[r,$e,o,e]),ct=n.useCallback(async t=>{if(r.statFile){const i=await $e(t),a=await r.statFile(t,{...i,directory:o||void 0});return{path:a.path,size:a.size,mtimeMs:a.mtimeMs}}return null},[r,$e,o]);n.useEffect(()=>{if(!o||!r.statFile||S.length===0)return;let t=!1;const i=[...S];return Promise.all(i.map(async a=>{try{const l=await $e(a),u=await r.statFile?.(a,{...l,directory:o||void 0});!t&&u&&!u.isFile&&it(o,a)}catch(l){!t&&Mi(l)&&it(o,a)}})),()=>{t=!0}},[r,S,it,$e,o]);const Us=n.useMemo(()=>T.length>is?`${T.slice(0,is)}
|
|
11
|
+
|
|
12
|
+
… truncated …`:T,[T]),ie=$!==Us,Ct=n.useCallback(async()=>{if(!c||!r.writeFile)return O.error(e("filesView.toast.savingNotSupported")),!1;const t=js(c.path)||_t;if(!Ba({selectedFilePath:c.path,loadedFilePath:we,fileLoading:Ve,isDirty:ie,draftContent:$,fileContent:T,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):$===""&&T!==""&&we!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${T.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!ie)return!0;Ms(!0);try{const i=Xa($,br);if(!(await r.writeFile(c.path,i))?.success)return O.error(e("filesView.toast.writeFileFailed")),!1;if(H($),o&&Vs(c.path,o)){const l=Ss(o,c.path);l&&da.requestGitRefresh({directory:o,paths:[l]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(z(c.path))){const l=ua.getState().projects.find(u=>z(u.path)===z(o));if(l)try{await Ra(l.id)}catch{O.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&sr(c.path)&&(at.current=$,Ht.current=$),ct(c.path).then(l=>{l&&(Ue.current=l)}).catch(()=>{}),!0}catch(i){return O.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ms(!1)}},[_t,$,T,Ve,r,ie,br,we,ct,o,c,e]);n.useEffect(()=>{if(!ie){Ge(null);return}const t=i=>yt.current?(yt.current=!1,!0):(zt(!0),Jt.current=i,!1);return Ge(t),()=>{me.getState().mainTabGuard===t&&Ge(null)}},[ie,Ge]),n.useEffect(()=>{re||(Mt("idle"),We.current&&(clearTimeout(We.current),We.current=null))},[re]);const _r=1500;n.useEffect(()=>{const t=!!(c&&r.writeFile),i=!!(c?.path&&(js(c.path)||_t));if(Oa({autoSaveEnabled:re,isDirty:ie,canWrite:t,isSaving:Et,fileLoading:Ve,selectedFilePath:c?.path,loadedFilePath:we,isNonEditableBinary:i}))return We.current=setTimeout(()=>{Ct().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})},_r),()=>{We.current&&(clearTimeout(We.current),We.current=null)}},[re,_t,$,Ve,ie,we,c,r.writeFile,Et,Ct]),n.useEffect(()=>{Mt("idle")},[c?.path]),n.useEffect(()=>{const t=i=>{xa(i)&&(i.key.toLowerCase()==="s"?(i.preventDefault(),We.current&&(clearTimeout(We.current),We.current=null),Et||Ct().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})):i.key.toLowerCase()==="f"&&(i.preventDefault(),pe(!0)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Et,Ct]);const Jr=n.useCallback(async t=>{const i=qt.current+1;qt.current=i;const a=()=>{if(!o)return!1;const y=Ee.getState().byRoot[o],M=y?.selectedPath??y?.openPaths[0]??null;return qt.current===i&&M===t.path};if(Z(null),Ce(""),K(null),jr(!1),nt(!0),await $e(t.path),!a())return;const l=Fi(t.path),u=Ni(t.path),f=Ci(t.path),w=js(t.path);if(p&&I(!0),m.isDesktop&&l&&!u){H(""),X("");return}if(!m.isDesktop&&l&&!u){H(""),X(""),K(t.path),nt(!1);return}if(f){H(""),X(""),K(t.path),nt(!1);return}if(w){H(""),X(""),K(t.path),nt(!1);return}await qr(t.path).then(y=>{if(!a())return;if(fa(y)){jr(!0),H(""),X(""),K(t.path);return}const M=Ui(y);Xi(Za(y)),H(M),at.current=M,Ht.current=M,X(M.length>is?`${M.slice(0,is)}
|
|
13
|
+
|
|
14
|
+
… truncated …`:M),K(t.path),ct(t.path).then(ft=>{ft&&a()&&(Ue.current=ft)}).catch(()=>{})}).catch(y=>{if(a()){if(Ja(y)){if(nt(!1),o&&se(o,null),Z(null),H(""),X(""),K(null),Ue.current=null,V.trim().length>0&&D(""),p&&I(!1),o){const ft=[...Ei(t.path,o),t.path];ft.length>0&&ns(o,ft);for(const mt of ft)Fe.current.has(mt)||Se(mt)}return}if(Mi(y)){o&&it(o,t.path),H(""),X(""),Z(null),Ue.current=null,p&&I(!1);return}H(""),X(""),Z(y instanceof Error?y.message:e("filesView.error.readFileFailed")),Ue.current=null}}).finally(()=>{a()&&nt(!1)})},[ns,p,Se,qr,ct,it,$e,o,m.isDesktop,V,se,e]),xs=n.useCallback(async(t,i)=>{if(!o)return;const a=Ei(t,o),l=i?[...a,t]:a;l.length>0&&ns(o,l);const u=l.map(f=>{if(!Fe.current.has(f))return Se(f)}).filter(Boolean);await Promise.all(u)},[ns,Se,o]),Zr=n.useCallback((t,i)=>{const a=i.findIndex(l=>l.path===t);return a===-1||i.length<=1?null:i[a+1]??i[a-1]??null},[]),fe=n.useCallback(async t=>{if(yt.current)yt.current=!1;else if(ie){zt(!0),Lt.current=t;return}o&&(se(o,t.path),xs(t.path,!1)),Z(null),Ce(""),H(""),at.current="",Ht.current="",X(""),K(null),p&&I(!0)},[xs,ie,p,o,se]);n.useEffect(()=>{c?.path&&xs(c.path,!1)},[xs,c?.path]),n.useEffect(()=>{if(!c){qt.current+=1,Pt.current=null,nt(!1);return}if(we===c.path||Pt.current===c.path)return;const t=c.path;Pt.current=t,Jr(c).finally(()=>{Pt.current===t&&(Pt.current=null)})},[us,Jr,we,c]);const Gs=n.useRef(ie);Gs.current=ie,n.useEffect(()=>Ea(({runtimeKey:t,paths:i})=>{const a=c?.path;t!==ta()||!a||Gs.current||!i.includes(z(a))||(qt.current+=1,Pt.current=null,Ue.current=null,Ce(""),Z(null),K(null),Qi(l=>l+1))}),[c?.path]),n.useEffect(()=>{if(!c?.path||we!==c.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ct(c.path).then(a=>{if(t||!a)return;const l=Ue.current;if(!l||l.path!==c.path){Ue.current=a;return}const u=a.mtimeMs!==void 0&&l.mtimeMs!==void 0&&a.mtimeMs!==l.mtimeMs,f=a.size!==l.size;!u&&!f||Gs.current||(Ue.current=a,K(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[we,ct,c?.path]);const Nn=n.useCallback(()=>{const t=Lt.current,i=Jt.current,a=Zt.current;if(Lt.current=null,Jt.current=null,Zt.current=null,yt.current=!0,zt(!1),X(Us),a){o&&Vt(o,a),c?.path===a&&(t?fe(t):(o&&se(o,null),H(""),Z(null),Ce(""),K(null),p&&I(!1)));return}if(t){fe(t);return}i&&(Ge(null),me.getState().setActiveMainTab(i))},[Us,fe,p,Vt,o,c?.path,Ge,se]),Cn=n.useCallback(async()=>{const t=Lt.current,i=Jt.current,a=Zt.current;if(!await Ct()){yt.current=!1;return}if(Lt.current=null,Jt.current=null,Zt.current=null,yt.current=!0,zt(!1),a){o&&Vt(o,a),c?.path===a&&(t?await fe(t):(o&&se(o,null),H(""),Z(null),Ce(""),K(null),p&&I(!1)));return}if(t){await fe(t);return}i&&(Ge(null),me.getState().setActiveMainTab(i))},[fe,p,Vt,o,Ct,c?.path,Ge,se]),Xr=n.useCallback(t=>{const i=c?.path===t,a=Zr(t,Rt);if(i&&ie){zt(!0),Lt.current=a,Zt.current=t;return}if(o&&Vt(o,t),!!i){if(a){fe(a);return}o&&se(o,null),H(""),Z(null),Ce(""),K(null),p&&I(!1)}},[Zr,fe,ie,p,Rt,Vt,o,c?.path,se]),Sn=n.useCallback(t=>{if(S.includes(t))return"open";if(A?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=A.files.find(l=>l.path===i);if(a){if(a.index==="A"||a.working_dir==="?")return"git-added";if(a.index==="D")return"git-deleted";if(a.index==="M"||a.working_dir==="M")return"git-modified"}}return null},[S,A,o]),kn=n.useCallback(t=>{if(!A?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=i?`${i}/`:"";let l=0,u=0;for(const f of A.files)f.path.startsWith(a)&&((f.index==="M"||f.working_dir==="M")&&l++,(f.index==="A"||f.working_dir==="?")&&u++);return l+u>0?{modified:l,added:u}:null},[A,o]),Tn=n.useCallback(async t=>{const i=z(t);o&&(fr(o,i),Fe.current.has(i)||await Se(i))},[Se,o,fr]),Vn=n.useMemo(()=>({canRename:Tr,canCreateFile:Sr,canCreateFolder:kr,canDelete:Vr,canReveal:Dr}),[Tr,Sr,kr,Vr,Dr]);function Yr(t,i){const a=xr[t]??[];return a.map((l,u)=>{const f=l.type==="directory",w=f&&_e.includes(l.path),y=c?.path===l.path,M=u===a.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),M&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Qa,{node:l,root:o,isExpanded:w,isActive:y,isMobile:p,isBrowserClient:N,alwaysShowActions:L,status:f?void 0:Sn(l.path),badge:f?kn(l.path):void 0,permissions:Vn,downloadFile:r.downloadFile,contextMenuPath:ln,setContextMenuPath:cn,rightClickMenuPath:dn,setRightClickMenuPath:un,onSelect:fe,onToggle:Tn,onRevealPath:vn,onOpenDialog:Bs}),f&&w&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[os[l.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:os[l.path],children:os[l.path]}),s.jsxs(k,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{He(l.path)},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Yr(l.path,i+1)]})]},l.path)})}const ne=!!(c?.path&&Fi(c.path)),vs=!!(c?.path&&Ni(c.path)),ke=!!(c?.path&&Ci(c.path)),Ks=!!(c?.path&&(js(c.path)||_t)),Ye=Ks&&!ne&&!ke,Qr=n.useMemo(()=>z(Ke?.path??""),[Ke?.path]),Bt=!!(Ke&&Qr&&Be&&Be===Qr&&!Ve&&!Ze&&!ne&&!ke&&!Ye),dt=n.useMemo(()=>Ss(o,Be),[Be,o]),Dn=!!(c&&(!ne||vs)&&!ke&&!Ye&&T.length>0),Rn=!!(c&&dt.length>0),Te=!!(c&&!as&&!Ks&&!ne&&r.writeFile&&T.length<=is),ut=!!(c?.path&&zi(c.path)),ts=!!(c?.path&&Ya(c.path)),$t=!!(c?.path&&or(c.path)),ss=!!(c?.path&&sr(c.path)),Hs=!!(c&&!Ks&&!ne)&&!ut&&!ss&&!($t&&ge==="preview"),En=ut&&xt==="edit"||$t&&ge==="edit"||ts&&ze==="text"||!ut&&!$t&&!ts&&G==="edit",ws=n.useMemo(()=>Be?ma(Be):null,[Be]),[ei,qs]=n.useState(null);n.useEffect(()=>{let t=!1;const i=c?.path;if(!i||ws){qs(null);return}return qs(null),pa(i).then(a=>{t||qs(a)}),()=>{t=!0}},[c?.path,ws]),n.useEffect(()=>{!Te&&G==="edit"&&ye("view")},[Te,G]);const _s="openchamber:files:md-viewer-mode",Js="openchamber:files:html-viewer-mode",Zs="openchamber:files:json-viewer-mode";n.useEffect(()=>{const t=c?.path;if(!t)return;ye(Ae.current[t]??"edit");let i=Qt?"preview":"edit";try{const u=localStorage.getItem(_s);(u==="preview"||u==="edit")&&(i=u)}catch{}Me(Ie.current[t]??i);let a=Qt?"preview":"edit";try{const u=localStorage.getItem(Js);(u==="preview"||u==="edit")&&(a=u)}catch{}Le(Oe.current[t]??a),je(rt.current[t]??(Qt?"preview":"edit"));let l=Qt?"tree":"text";try{const u=localStorage.getItem(Zs);(u==="tree"||u==="text")&&(l=u)}catch{}vt(l)},[c?.path,Qt]);const Pn=n.useCallback(t=>{const i=c?.path;i&&(Ae.current[i]=t),ye(t)},[c?.path]),ti=n.useCallback(t=>{const i=c?.path;i&&(Ie.current[i]=t),Me(t);try{localStorage.setItem(_s,t)}catch{}},[c?.path]),ae=n.useCallback(()=>xt,[xt]),Mn=n.useCallback(t=>{vt(t);try{localStorage.setItem(Zs,t)}catch{}},[]),zn=n.useCallback(t=>{const i=c?.path;i&&(Oe.current[i]=t),Le(t);try{localStorage.setItem(Js,t)}catch{}},[c?.path]),Ln=n.useCallback(t=>{const i=c?.path;if(i&&(rt.current[i]=t),be.current&&(clearTimeout(be.current),be.current=null),Xe.current!==null&&(cancelAnimationFrame(Xe.current),Xe.current=null),t==="edit")X(at.current||T),je(t);else{at.current=$;const a=i;je("edit"),Xe.current=requestAnimationFrame(()=>{Xe.current=requestAnimationFrame(()=>{Xe.current=null,!(o&&a&&Ee.getState().byRoot[o]?.selectedPath!==a)&&(st(l=>l+1),je("preview"))})});return}},[$,T,o,c?.path]),Xs=n.useCallback(async(t,i)=>{if(!r.writeFile||i===Ht.current)return!1;if(!(await r.writeFile(t,i))?.success)return O.error(e("filesView.toast.writeFileFailed")),!1;at.current=i,Ht.current=i,X(i);const l=await ct(t).catch(()=>null);return l&&(Ue.current=l),!0},[r,ct,e]);n.useEffect(()=>()=>{be.current&&(clearTimeout(be.current),be.current=null),Xe.current!==null&&(cancelAnimationFrame(Xe.current),Xe.current=null)},[de,c?.path]);const An=n.useCallback(t=>{if(at.current=t,!re||!c?.path||de!=="preview"||!r.writeFile)return;be.current&&clearTimeout(be.current);const i=c.path;be.current=setTimeout(()=>{be.current=null,Xs(i,t).then(a=>{a&&(fs(!0),setTimeout(()=>fs(!1),1500))}).catch(a=>{O.error(a instanceof Error?a.message:e("filesView.toast.saveFailed"))})},_r)},[re,de,r.writeFile,Xs,c?.path,e]),In=n.useMemo(()=>ss&&(at.current||$)||T,[$,T,ss]),si=n.useCallback(()=>ge,[ge]);n.useEffect(()=>{const t=a=>{const l=a?"preview":"edit",u=a?"tree":"text";for(const f of S)Ae.current[f]="edit",zi(f)&&(Ie.current[f]=l),or(f)&&(Oe.current[f]=l),sr(f)&&(rt.current[f]=l);ye("edit"),Me(l),Le(l),je(l),vt(u);try{localStorage.setItem(_s,l),localStorage.setItem(Js,l),localStorage.setItem(Zs,u)}catch{}},i=a=>{const l=!!a.detail?.enabled;t(l)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[S]),n.useEffect(()=>{if(!Ke||!o)return;const t=()=>{typeof window>"u"||At.current===null&&(At.current=window.requestAnimationFrame(()=>{At.current=null,Ls(Qe=>Qe+1)}))},i=(Qe,St)=>{if(Qe.state.doc.length!==St.length)return!1;if(St.length===0)return!0;const er=Math.min(128,St.length);if(Qe.state.sliceDoc(0,er)!==St.slice(0,er))return!1;const gi=Math.max(0,St.length-er);return Qe.state.sliceDoc(gi,St.length)===St.slice(gi)},a=z(Ke.path);if(!a){ms(null),jt.current={key:"",attempts:0};return}const l=`${a}:${Ke.line}:${Ke.column??1}`;if(jt.current.key!==l&&(jt.current={key:l,attempts:0}),c?.path!==a){if(zs)return;fe(Dt(a));return}if(Ve||we!==a)return;if(Ze||ne||ke||Ye){ms(null),jt.current={key:"",attempts:0};return}if(!Te)return;if(G!=="edit"){ye("edit");return}const u=De.current;if(!u){t();return}if(!i(u,$)){t();return}const f=Math.max(1,Math.min(Ke.line,u.state.doc.lines)),w=u.state.doc.line(f),y=Math.max(1,Ke.column||1),M=Math.max(0,w.to-w.from),ft=Math.min(M,y-1),mt=w.from+ft;if(!(u.state.selection.main.head===mt)||jt.current.attempts===0){jt.current.attempts+=1,u.dispatch({selection:{anchor:mt},effects:kt.scrollIntoView(mt,{y:"center"})}),u.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const Qe=De.current;Qe&&(Qe.dispatch({selection:{anchor:mt},effects:kt.scrollIntoView(mt,{y:"center"})}),Qe.focus())}),ms(null),jt.current={key:"",attempts:0}},[Te,zs,$,nn,Ze,Ve,ne,ke,Ye,we,fe,Ke,o,c?.path,ms,G,Dt]),n.useEffect(()=>{if(!$s||!o)return;const t=z($s);if(!t){Ws(null);return}c?.path===t&&(Ve||we!==t||(!Ze&&!ne&&!ke&&!Ye&&Te&&G==="edit"&&De.current?.focus(),Ws(null)))},[Te,Ze,Ve,ne,ke,Ye,we,$s,o,c?.path,Ws,G]);const Wt=n.useCallback(t=>{if(!p||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const a=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,a-(i.offsetTop+i.height))<=0)return;const u=t.state.selection.main.head,f=t.coordsAtPos(u);if(!f)return;const w=Math.round(i.offsetTop+i.height),M=f.bottom+20-w;M<=0||(t.scrollDOM.scrollTop+=M)},[p]);n.useEffect(()=>{if(!p||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Wt(De.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[p,Wt]),n.useEffect(()=>{if(!Te||G!=="edit"||p)return;const t=ha("open_go_to_line",Pr),i=a=>{const l=a.target;if(l?.closest('[role="dialog"]'))return;const u=!!l?.closest(".cm-editor");l?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!u||!document.activeElement?.closest(".cm-editor")||va(a,t)&&(a.preventDefault(),Os(!0))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Te,p,Pr,G]);const bs=me(t=>t.editorFontSize),ri=n.useMemo(()=>{if(!c?.path)return[ki(x,{fontSize:bs})];const t=tr(c.path),i=[ki(x,t?{syntaxColors:!1,fontSize:bs}:{fontSize:bs})],a=ws??ei;return a&&i.push(a),t&&i.push(Sa({language:t,themeName:x.metadata.id,theme:Da(x)})),le&&i.push(kt.lineWrapping),p&&i.push(kt.updateListener.of(l=>{l.view.hasFocus&&(l.selectionSet||l.focusChanged||l.viewportChanged||l.geometryChanged)&&window.requestAnimationFrame(()=>{Wt(l.view)})})),i},[x,c?.path,ws,ei,le,p,Wt,bs]),ii=n.useMemo(()=>({light:ue.metadata.id,dark:xe.metadata.id}),[ue.metadata.id,xe.metadata.id]),rs=c?.path&&ke&&(!bt.allowOutsideWorkspace||bt.outsideFileGrant)?`${c.path}|${bt.allowOutsideWorkspace?"outside":"workspace"}|${bt.outsideFileGrant??""}|${us}`:"",ys=c?.path&&$t&&ge==="preview"&&!m.isVSCode?`${c.path}|${us}`:"",ni=e("filesView.error.readFileFailed"),{readyKey:ai,nonce:On}=Li(ys,Z,ni),{readyKey:oi,nonce:li}=Li(rs,Z,ni),Bn=!!(ys&&ai!==ys),ci=!!(rs&&oi!==rs),di=c?.path&&ne?vs?`data:${ga(c.path)};utf8,${encodeURIComponent(T)}`:Zi:"",ui=c?.path&&ke&&rs&&oi===rs?bi().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:bt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:bt.outsideFileGrant,directory:o||void 0}):"",fi=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:ui,className:"h-full w-full border-0",title:t.name},li)}),[ui,li]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!ne||vs){Ce("");return}Z(null);const l=await $e(c.path);if(t)return;await(r.readFileBinary?r.readFileBinary(c.path,l).then(f=>f.dataUrl):(async()=>{const f=await wi("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:l.allowOutsideWorkspace?"true":void 0,outsideFileGrant:l.outsideFileGrant,directory:o||void 0}});if(!f.ok)throw new Error(e("filesView.error.readFileFailed"));const w=await f.blob();return i=URL.createObjectURL(w),t?(URL.revokeObjectURL(i),i="",""):i})()).then(f=>{t||(Ce(f),K(c.path))}).catch(f=>{t||(Ce(""),Z(f instanceof Error?f.message:e("filesView.error.readFileFailed")),K(null))}).finally(()=>{t||nt(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[us,r,ne,vs,$e,o,c?.path,bt,e]);const $n=n.useCallback(()=>As(null),[]),Wn=n.useMemo(()=>La({drafts:Lr,editingDraftId:hs,commentText:ps,onTextChange:Ar,selection:P,isDragging:Er,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Ur,onCancel:()=>{Re(null),es()},onEdit:t=>{$r(t),Re({start:t.startLine,end:t.endLine})},onDelete:Wr}),[es,ps,Wr,hs,Lr,Ur,Er,P,c?.path,Ar,$r]),mi=n.useCallback((t,i)=>s.jsx("div",{className:"h-full",children:s.jsx(Ta,{file:{name:t.name,contents:i,lang:tr(t.path)||void 0},options:{disableFileHeader:!0,overflow:le?"wrap":"scroll",theme:ii,themeType:x.metadata.variant==="dark"?"dark":"light"},className:"block h-full w-full",style:{height:"100%"}})}),[x.metadata.variant,ii,le]),Ys=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",u=(f,w)=>s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:w})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:f})]});return s.jsxs("div",{className:l,children:[Te&&En&&s.jsxs(s.Fragment,{children:[Et?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(g,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):re&&en==="saved"&&!ie?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(g,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ie?u(e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${nr()}+S`}),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{Ct()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${nr()}+S`}),"aria-label":e("filesView.editor.saveAria",{shortcut:`${nr()}+S`}),children:s.jsx(g,{name:"save-3",className:"size-4"})})):null,u(e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>sn(!re),className:B("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",re?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:re?s.jsx(g,{name:"file-check-fill",className:"size-4"}):s.jsx(g,{name:"file-check",className:"size-4"})}))]}),s.jsxs(lr,{onOpenChange:Tt,children:[s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(cr,{asChild:!0,children:s.jsx(k,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(g,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(dr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[hn.map(f=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{wn(f)},children:[s.jsx(Wa,{label:f.label,iconDataUrl:f.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:f.label})]},f.id)),gn?s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{xn(!0)},children:[s.jsx(g,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!ne&&!ke&&!Ye&&s.jsxs(s.Fragment,{children:[u(e(le?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>Pe(!le),className:B("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",le?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(le?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(g,{name:"text-wrap",className:"size-4"})})),G==="edit"&&s.jsxs(s.Fragment,{children:[u(e("filesView.editor.findInFile"),s.jsx(k,{variant:"ghost",size:"sm",onClick:f=>{pe(!ee),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(g,{name:"search",className:"size-4"})})),u(e("filesView.editor.goToLine"),s.jsx(k,{variant:"ghost",size:"sm",onClick:f=>{Os(w=>!w),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(g,{name:"menu-fold-2",className:"size-4"})})),s.jsx(Ia,{open:pn,onOpenChange:Os,view:De.current,variant:"inline"})]})]}),Hs&&Te&&!ts&&!$t&&s.jsx(ar,{currentMode:G==="view"?"preview":"edit",onToggle:()=>{Pn(G==="view"?"edit":"view")}}),ut&&u(e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>ti(ae()==="preview"?"edit":"preview"),className:B("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})),or(c?.path??"")&&s.jsx(ar,{currentMode:si(),onToggle:()=>{zn(si()==="preview"?"edit":"preview")}}),ut&&ae()==="preview"&&bn&&s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(k,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ds?Ji():T.trim()&&_i(T)},children:ds?s.jsx(g,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"volume-up",className:"size-4"})})}),s.jsx(gt,{sideOffset:8,children:e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),ss&&s.jsxs(s.Fragment,{children:[s.jsx(ar,{currentMode:de,onToggle:()=>Ln(de==="preview"?"edit":"preview")}),de==="preview"&&s.jsx(k,{variant:"ghost",size:"sm",onClick:async()=>{const f=yr.current?.getXml();if(be.current&&(clearTimeout(be.current),be.current=null),c?.path&&f){if(!await Xs(c.path,f))return;fs(!0),setTimeout(()=>fs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:tn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"save-3",className:"size-4"})})]}),ts&&u(e(ze==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>Mn(ze==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ze==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ze==="tree"?s.jsx(g,{name:"code-sslash",className:"size-4"}):s.jsx(g,{name:"node-tree",className:"size-4"})})),Dn&&u(e("filesView.editor.copyFileContents"),s.jsx(k,{variant:"ghost",size:"sm",onClick:async()=>{(await Ts(T)).ok?(Nr(!0),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Nr(!1)},1200)):O.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:fn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"clipboard",className:"size-4"})})),Rn&&u(e("filesView.editor.copyFilePathTitle",{path:dt}),s.jsx(k,{variant:"ghost",size:"sm",onClick:async()=>{(await Ts(dt)).ok?(Cr(!0),Yt.current!==null&&window.clearTimeout(Yt.current),Yt.current=window.setTimeout(()=>{Cr(!1)},1200)):O.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:dt}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:dt}),children:mn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&u(e("filesView.editor.saveFile"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{const f=r.downloadFile;f&&f(c.path).catch(w=>{console.error("Download failed:",w),O.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(g,{name:"download",className:"size-4"})})),t?u(e("filesView.editor.exitFullscreen"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>J(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(g,{name:"fullscreen-exit",className:"size-4"})})):!p&&d==="full"&&u(e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>J(!U),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:U?s.jsx(g,{name:"fullscreen-exit",className:"size-4"}):s.jsx(g,{name:"fullscreen",className:"size-4"})}))]})},Qs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Ai,{open:zs,onOpenChange:t=>{t||zt(!0)},children:s.jsxs(Ii,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Oi,{children:[s.jsx(Bi,{children:e("filesView.unsaved.title")}),s.jsx($i,{children:e("filesView.unsaved.description")})]}),s.jsxs(Wi,{children:[s.jsx(k,{variant:"outline",onClick:()=>{Cn()},disabled:Et,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(k,{variant:"destructive",onClick:Nn,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:B("flex flex-col flex-shrink-0",q&&"border-b border-border/40"),children:[q?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[p&&Q&&s.jsx("button",{type:"button",onClick:()=>I(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(g,{name:"arrow-left-s",className:"size-5"})}),p?c?s.jsxs(lr,{children:[s.jsx(cr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(Ns,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Pi,{name:c.name}),s.jsx(g,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(dr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Rt.map(t=>{const i=c?.path===t.path;return s.jsxs(Cs,{onSelect:a=>{if(a.target.closest("[data-close-open-file]")){a.preventDefault();return}i||fe(t)},className:B("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Ns,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Pi,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:a=>{a.preventDefault(),a.stopPropagation()},onClick:a=>{a.preventDefault(),a.stopPropagation(),Xr(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Rt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),pr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Es,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Rt.map(t=>{const i=c?.path===t.path;return s.jsxs("div",{title:Ss(o,t.path),className:B("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(Ns,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||fe(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),Xr(t.path)},className:B("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!L&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,(zr||p)&&c?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[dt&&!p?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:dt,children:dt}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Ys({layout:"docked"})})]}):null]}),s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[c&&!ee&&!(zr||p)&&s.jsx("div",{ref:ce,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{et.current>0||he(!1)},children:te?Ys():s.jsxs("div",{className:"flex items-center gap-1",children:[ut?s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>ti(ae()==="preview"?"edit":"preview"),className:B("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode")})]}):null,s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex",onMouseEnter:()=>he(!0),children:s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>he(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":e("filesView.editor.showControlsAria"),title:e("filesView.editor.controlsTitle"),children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.controlsTitle")})]})]})}),s.jsx(rr,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:c?Ve||ci?W?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Ze?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:di,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):ke?fi(c):Ye?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),O.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&ss&&de==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Pa,{ref:yr,xml:In,onChange:An},`${c.path}:${tt}`)}):c&&ts&&ze==="tree"?s.jsx(ir,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Va,{jsonString:T,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&ut&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-3",children:[T.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(T.length/1024)})}),s.jsx(ir,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Si,{content:T,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):c&&$t&&ge==="preview"?Bn?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!m.isVSCode&&ai===ys?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return bi().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:m.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?T.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):T})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},On)}):c&&Hs&&G==="view"?mi(c,$):s.jsxs("div",{className:B("relative h-full",Bt&&"overflow-hidden"),ref:rn,children:[s.jsx("div",{className:B("h-full",Bt&&"invisible"),children:s.jsx(Ti,{value:$,onChange:X,readOnly:!Te,vimMode:Mr==="vim",extensions:ri,className:"h-full",blockWidgets:Wn,onViewReady:t=>{De.current=t,Ls(i=>i+1),window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{De.current&&(De.current=null),Ls(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:pe,highlightLines:P?{start:Math.min(P.start,P.end),end:Math.max(P.start,P.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const l=t.state.doc.lineAt(i.from).number;if(P&&!a.shiftKey&&Math.min(P.start,P.end)===l&&Math.max(P.start,P.end)===l)return Re(null),es(),It.current=!1,lt.current=null,Ot(!1),!0;if(p&&P&&!a.shiftKey){const u=Math.min(P.start,P.end,l),f=Math.max(P.start,P.end,l);return Re({start:u,end:f}),It.current=!1,lt.current=null,Ot(!1),!0}if(It.current=!0,lt.current=l,Ot(!0),P&&a.shiftKey){const u=Math.min(P.start,l),f=Math.max(P.end,l);Re({start:u,end:f})}else Re({start:l,end:l});return!0},mouseover:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!It.current||lt.current===null)return!1;const l=t.state.doc.lineAt(i.from).number,u=Math.min(lt.current,l),f=Math.max(lt.current,l);return Re({start:u,end:f}),Ot(!0),!1},mouseup:()=>(It.current=!1,lt.current=null,Ot(!1),!1)}}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})]})]}),Un=!!(o&&xr[o]),pi=o?os[o]:null,hi=s.jsxs("section",{className:B("flex min-h-0 flex-col overflow-hidden",p?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:B("flex flex-col gap-2 py-2",p?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(g,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(ks,{ref:Y,value:V,onChange:t=>D(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),V.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{D(""),Y.current?.focus()},children:s.jsx(g,{name:"close",className:"size-4"})})]}),s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>Bs("createFile",{path:E,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(g,{name:"file-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>Bs("createFolder",{path:E,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(g,{name:"folder-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(pt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{gs()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(g,{name:"refresh",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(rr,{outerClassName:"flex-1 min-h-0",className:B("py-2",p?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:qi?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):wr.length>0?wr.map(t=>{const i=c?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{fe(t)},className:B("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Gi(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):pi?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:pi}),s.jsxs(k,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{gs()},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Un?Yr(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Gn=d==="full"&&U&&c&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:Ys({exitFullscreenOnly:!0})}),s.jsx(rr,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Ve||ci?W?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Ze?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:di,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):ke?fi(c):Ye?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),O.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):ut&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-4",children:[T.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(T.length/1024)})}),s.jsx(ir,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Si,{content:T,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Hs&&G==="view"?mi(c,$):s.jsxs("div",{className:B("relative h-full",Bt&&"overflow-hidden"),children:[s.jsx("div",{className:B("h-full",Bt&&"invisible"),children:s.jsx(Ti,{value:$,onChange:X,readOnly:!Te,vimMode:Mr==="vim",extensions:ri,className:"h-full",onViewReady:t=>{De.current=t,window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{De.current&&(De.current=null)}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(eo,{activeDialog:Ft,dialogData:Nt,dialogInputValue:ot,onDialogInputChange:Fr,isDialogSubmitting:on,onDialogSubmit:Fn,onClose:$n,inputRef:Yi}),Gn,p?Q?Qs:hi:d==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Qs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[h>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:hi}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Qs})]})]})};function to(d){return d+1}export{jc as FilesView};
|