@vantran-se/openchamber-web 2.1.1 → 2.2.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 +32 -24
- package/bin/cli.js +1 -3
- package/bin/cli.test.js +40 -16
- package/bin/lib/DOCUMENTATION.md +6 -5
- package/bin/lib/cli-args.js +6 -1
- package/bin/lib/cli-args.test.js +34 -0
- package/bin/lib/cli-lifecycle.js +0 -1
- package/bin/lib/cli-network.js +8 -2
- package/bin/lib/cli-process.js +1 -1
- package/bin/lib/cli-settings-accessors.test.js +21 -13
- package/bin/lib/cli-startup.js +17 -11
- package/bin/lib/cli-startup.test.js +92 -2
- package/bin/lib/commands-connect-url.js +8 -1
- package/bin/lib/commands-schedule.js +8 -2
- package/bin/lib/commands-serve.js +15 -21
- package/bin/lib/commands-update.js +12 -24
- package/bin/lib/commands-update.test.js +14 -46
- package/dist/assets/DiffView-Cv9MSXl1.js +4 -0
- package/dist/assets/FilePreviewCommentMenu-D4kLseHj.js +4 -0
- package/dist/assets/FilesView-BVoD8I2x.js +14 -0
- package/dist/assets/{GitView-DzuzhIPx.js → GitView-Bzb8p-ew.js} +4 -4
- package/dist/assets/GuestSurfacePane-Crdbvsxo.js +1 -0
- package/dist/assets/InProgressOperationBanner-CwMjNQgk.js +2 -0
- package/dist/assets/{JsonTreeView-B_EPRjzy.js → JsonTreeView-DRKHZfsn.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DZtqT1Zn.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CqG7HCNd.js +10 -0
- package/dist/assets/OnboardingScreen-DMIxwYK5.js +1 -0
- package/dist/assets/{PatchDiff-6yh1csza.js → PatchDiff-CUcCg1jk.js} +1 -1
- package/dist/assets/PierreDiffViewer-CnnR-dnD.js +228 -0
- package/dist/assets/PlanView-RCBadcY7.js +5 -0
- package/dist/assets/SettingsView-CjBjZFRO.js +30 -0
- package/dist/assets/SettingsWindow-DyM7QuhI.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BWIfgMED.js +1 -0
- package/dist/assets/ToolOutputDialog-Q0P3FuAi.js +15 -0
- package/dist/assets/ToolPartDiffPreview-p7qR9FpU.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BTJVRkyo.js → VirtualizedFileDiff-CFpjL8Ns.js} +3 -3
- package/dist/assets/{Virtualizer-xCEYz34p.js → Virtualizer-C0IsclZn.js} +1 -1
- package/dist/assets/WalkthroughView-DI31zD02.js +4 -0
- package/dist/assets/appThemeRegistry-B9gkFq9i.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-CmPe29DM.js → computeVirtualFileMetrics-C2WM6JC2.js} +2 -2
- package/dist/assets/de-YKfk5MmC.js +14 -0
- package/dist/assets/es-_gwT0kr-.js +20 -0
- package/dist/assets/fileTreeStatus-D438yi8M.js +1 -0
- package/dist/assets/fr-DqzvXmIm.js +18 -0
- package/dist/assets/index-BLaHKdtx.js +1 -0
- package/dist/assets/index-BkMXRrVQ.css +1 -0
- package/dist/assets/index-DxNa7xYB.js +65 -0
- package/dist/assets/initializeSharedPreferences-Bck5EAWP.js +1 -0
- package/dist/assets/{isDiffPlainText-CQmDCnEv.js → isDiffPlainText-Dgbw8VKk.js} +1 -1
- package/dist/assets/{isFilePlainText-CYBUzW4I.js → isFilePlainText-_ZS5UYRj.js} +1 -1
- package/dist/assets/ja-B-GFYhQE.js +20 -0
- package/dist/assets/ko-mzksfqDC.js +20 -0
- package/dist/assets/main-C5Xx8dn_.js +2 -0
- package/dist/assets/main-CfBSQM1H.js +990 -0
- package/dist/assets/markdownCore-BmWwW1ll.js +7 -0
- package/dist/assets/miniChat-mnKwy4vQ.js +2 -0
- package/dist/assets/mobile-DeEQd0wZ.js +2 -0
- package/dist/assets/nl-CWQr6NSq.js +20 -0
- package/dist/assets/{parseDiffFromFile-Cy0PNxun.js → parseDiffFromFile-BUgn-T9p.js} +2 -2
- package/dist/assets/patchFileDiff-Dt8LhgBh.js +13 -0
- package/dist/assets/pl-UmRcDUX2.js +20 -0
- package/dist/assets/pt-BR-BSLybvVF.js +20 -0
- package/dist/assets/relocateRestoredSession-B5E9xb3T.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-C0a9A5_J.js +2 -0
- package/dist/assets/renderMobileApp-BNncg3Pk.js +25 -0
- package/dist/assets/runtimeEndpointReset-CZ5aafpl.js +62 -0
- package/dist/assets/{selectionMarkdown-TkYk5h9l.js → selectionMarkdown-CUN3wUld.js} +9 -9
- package/dist/assets/{sessionOwnership-Bs1xbRfB.js → sessionOwnership-BSuxCEhb.js} +1 -1
- package/dist/assets/shikiHighlight-DHDx-6eM.js +1 -0
- package/dist/assets/space-apply-DM_2pRW7.js +1 -0
- package/dist/assets/space-close-Bpomt8z0.js +1 -0
- package/dist/assets/{surface-B6n7wJtt.js → surface-C-jQaGnL.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CDlKffWz.js → textMateThemeFromAppTheme-DlsTphbY.js} +1 -1
- package/dist/assets/tr-gaTrX_HK.js +11 -0
- package/dist/assets/uk-CnJF6ykl.js +20 -0
- package/dist/assets/{useAppFontEffects-DCqCVGlT.js → useAppFontEffects-DGlvOqP_.js} +194 -233
- package/dist/assets/useInlineCommentController-kMN4Wg_D.js +2 -0
- package/dist/assets/{useRootScrollLock-BowwS8kq.js → useRootScrollLock-DMPpvpNP.js} +2 -2
- package/dist/assets/{vendor-base-ui-DX96QhTP.js → vendor-base-ui-Det7U81h.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DW1FQz9_.js → vendor-codemirror-autocomplete-BSHQHbKu.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-DpmhalwN.js → vendor-codemirror-commands-C4G_dPWe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BqExbN1M.js → vendor-codemirror-lang-angular-B6LbBGHB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DZA36HfS.js → vendor-codemirror-lang-cpp-BWWXBx7W.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-B07blnnZ.js → vendor-codemirror-lang-css-Cayfb29q.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-BM8K9D1-.js → vendor-codemirror-lang-go-BoKlCNKw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DaH9adfE.js → vendor-codemirror-lang-html-BQWerHsJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CsdC0viz.js → vendor-codemirror-lang-java-DWX7Fq_K.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-CpGYXGuo.js → vendor-codemirror-lang-javascript-DbpEcZM0.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-jinja-BBeGzXw5.js → vendor-codemirror-lang-jinja-D1JIJRA7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-58T70Hqs.js → vendor-codemirror-lang-json-BzgckzmB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BI-xCA59.js → vendor-codemirror-lang-less-B9EpDXFi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-zEcMa-zy.js → vendor-codemirror-lang-liquid-9U7kRbSf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BLKnlLP4.js → vendor-codemirror-lang-markdown-D2TEBIvZ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-9f35M83-.js → vendor-codemirror-lang-php-BT6sDVzE.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-python-jAMtYiA9.js +3 -0
- package/dist/assets/{vendor-codemirror-lang-rust-MNDL_jZQ.js → vendor-codemirror-lang-rust-CVO56EiL.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-p9epsSNm.js → vendor-codemirror-lang-sass-DZlOoUWu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-Bqzh0EXX.js → vendor-codemirror-lang-sql-fZ6t1DPw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BnNUWV-p.js → vendor-codemirror-lang-vue-DxbqrLiE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-C2a-oLmk.js → vendor-codemirror-lang-wast-DyU1Gt-I.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-xml-C9a_K5_p.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-yaml-C0sjswB0.js → vendor-codemirror-lang-yaml-Cptq8l0e.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-ByBn5zIW.js → vendor-codemirror-language-DufXoQvE.js} +2 -2
- package/dist/assets/vendor-codemirror-language-data-CtwSWKtX.js +2 -0
- package/dist/assets/{vendor-codemirror-search-ib-sHD5W.js → vendor-codemirror-search-CvXM_pZg.js} +1 -1
- package/dist/assets/{vendor-codemirror-state-G3UuR-be.js → vendor-codemirror-state-Dek9sMtw.js} +1 -1
- package/dist/assets/{vendor-codemirror-view-Bniqp7p5.js → vendor-codemirror-view-1e0FQ6Wn.js} +1 -1
- package/dist/assets/vendor-framer-motion-DxDVhOLc.js +9 -0
- package/dist/assets/vendor-katex-CuQvj9-L.js +257 -0
- package/dist/assets/vendor-katex-DdZNUVNG.css +1 -0
- package/dist/assets/{vendor-motion-dom-DcCgeG69.js → vendor-motion-dom-HXPOMxb7.js} +1 -1
- package/dist/assets/{vendor-opencode-client-DHzhmLwV.js → vendor-opencode-client-BmFcUkbQ.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-DkzqxN2H.js → vendor-replit-codemirror-vim-BlJRn-cW.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-virtual-H_JmXOFV.js → vendor-tanstack-react-virtual-CvuLsk7D.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dxc8hSTB.js → vendor-tanstack-virtual-core-DPaNcJcT.js} +1 -1
- package/dist/assets/zh-CN-t2vigSB1.js +20 -0
- package/dist/assets/zh-TW-jAgqBokB.js +20 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +8 -5
- package/server/index.js +80 -36
- package/server/lib/agent-memory/actions.js +1 -6
- package/server/lib/agent-memory/routes.js +1 -2
- package/server/lib/agent-memory/runtime.js +1 -8
- package/server/lib/agent-tool/DOCUMENTATION.md +7 -3
- package/server/lib/agent-tool/runtime.js +3 -6
- package/server/lib/agent-tool/runtime.test.js +0 -2
- package/server/lib/browser-control/DOCUMENTATION.md +6 -0
- package/server/lib/changelog/update-notes.js +1 -1
- package/server/lib/context-obligatory/runtime.js +1 -2
- package/server/lib/dev-tunnel/DOCUMENTATION.md +8 -0
- package/server/lib/dev-tunnel/client.js +21 -10
- package/server/lib/dev-tunnel/tunnel.test.js +34 -0
- package/server/lib/dispatch-results/runtime.js +1 -1
- package/server/lib/enterprise-mode.d.ts +1 -0
- package/server/lib/enterprise-mode.js +13 -2
- package/server/lib/enterprise-mode.test.js +21 -0
- package/server/lib/event-stream/DOCUMENTATION.md +2 -2
- package/server/lib/event-stream/index.js +1 -3
- package/server/lib/event-stream/translate-v2.js +1 -9
- package/server/lib/event-stream/translate-v2.test.js +0 -11
- package/server/lib/fs/DOCUMENTATION.md +5 -2
- package/server/lib/fs/routes.js +62 -15
- package/server/lib/fs/routes.test.js +278 -48
- package/server/lib/fs/workspace-file-names.js +104 -0
- package/server/lib/fs/workspace-file-names.test.js +62 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/contributor-provenance-storage.js +9 -6
- package/server/lib/git/contributor-provenance-storage.test.js +29 -0
- package/server/lib/git/credential-broker.js +1 -1
- package/server/lib/git/credential-resolver.js +1 -4
- package/server/lib/git/credentials.js +1 -0
- package/server/lib/git/discovery-endpoint.js +1 -1
- package/server/lib/git/identity-provisioning.js +2 -1
- package/server/lib/git/identity-storage.js +3 -4
- package/server/lib/git/lfs-discovery.js +14 -14
- package/server/lib/git/lfs-discovery.test.js +16 -6
- package/server/lib/git/network-operation-plan.js +50 -62
- package/server/lib/git/network-operation-plan.test.js +103 -1
- package/server/lib/git/network-operation-registry.js +4 -6
- package/server/lib/git/network-operation-storage.js +4 -6
- package/server/lib/git/network-operations.js +12 -4
- package/server/lib/git/network-operations.test.js +19 -6
- package/server/lib/git/redaction.js +2 -1
- package/server/lib/git/repository-credential-runtime.js +5 -3
- package/server/lib/git/repository-credential-runtime.test.js +22 -0
- package/server/lib/git/routes.js +31 -137
- package/server/lib/git/routes.test.js +2 -2
- package/server/lib/git/service.js +143 -27
- package/server/lib/git/service.test.js +215 -1
- package/server/lib/git/ssh-credential-storage.js +1 -4
- package/server/lib/git/submodule-discovery.js +1 -1
- package/server/lib/git/worktree-bootstrap-storage.js +3 -4
- package/server/lib/git/worktree-bootstrap-storage.test.js +15 -0
- package/server/lib/git/worktree-creation.js +194 -0
- package/server/lib/git/worktree-creation.test.js +155 -0
- package/server/lib/github/DOCUMENTATION.md +11 -6
- package/server/lib/github/auth.js +2 -4
- package/server/lib/github/device-flow.js +2 -2
- package/server/lib/github/gh-cli-credential.js +1 -0
- package/server/lib/github/octokit.js +31 -0
- package/server/lib/github/pr-status.js +35 -18
- package/server/lib/github/pr-status.test.js +271 -3
- package/server/lib/github/reference-search.js +102 -13
- package/server/lib/github/reference-search.test.js +48 -7
- package/server/lib/github/routes.auth.test.js +18 -0
- package/server/lib/github/routes.js +360 -6
- package/server/lib/github/routes.mutations.test.js +239 -0
- package/server/lib/github/routes.test.js +134 -2
- package/server/lib/gitlab/DOCUMENTATION.md +5 -1
- package/server/lib/gitlab/auth-storage.test.js +1 -0
- package/server/lib/gitlab/mappers.js +30 -1
- package/server/lib/gitlab/resources.js +230 -6
- package/server/lib/gitlab/resources.test.js +179 -0
- package/server/lib/gitlab/routes.js +200 -6
- package/server/lib/gitlab/routes.test.js +186 -2
- package/server/lib/gitlab/validation.js +1 -5
- package/server/lib/guests/DOCUMENTATION.md +1 -1
- package/server/lib/guests/oauth.js +2 -2
- package/server/lib/guests/service.js +1 -1
- package/server/lib/guests/sockets.js +1 -1
- package/server/lib/injected-env.d.ts +8 -0
- package/server/lib/injected-env.js +50 -0
- package/server/lib/injected-env.test.js +56 -0
- package/server/lib/linear/DOCUMENTATION.md +5 -6
- package/server/lib/linear/issues.js +62 -4
- package/server/lib/linear/issues.test.js +68 -0
- package/server/lib/linear/oauth.js +5 -5
- package/server/lib/linear/parse.js +2 -9
- package/server/lib/message-queue/DOCUMENTATION.md +23 -1
- package/server/lib/message-queue/runtime.js +85 -12
- package/server/lib/message-queue/runtime.test.js +172 -2
- package/server/lib/notifications/apns-runtime.js +5 -6
- package/server/lib/notifications/apns-runtime.test.js +20 -4
- package/server/lib/openchamber-control/DOCUMENTATION.md +19 -1
- package/server/lib/openchamber-control/actions.js +2 -1
- package/server/lib/openchamber-control/service.js +119 -20
- package/server/lib/openchamber-control/service.test.js +166 -0
- package/server/lib/openchamber-sessions/archive-store.js +1 -6
- package/server/lib/openchamber-sessions/routes.js +47 -12
- package/server/lib/openchamber-sessions/routes.test.js +65 -2
- package/server/lib/openchamber-sessions/session-metadata-store.js +1 -6
- package/server/lib/opencode/DOCUMENTATION.md +22 -8
- package/server/lib/opencode/agents.js +62 -0
- package/server/lib/opencode/auth-state-runtime.js +3 -1
- package/server/lib/opencode/auth.d.ts +1 -1
- package/server/lib/opencode/auth.js +8 -0
- package/server/lib/opencode/auth.test.js +31 -0
- package/server/lib/opencode/config-entity-routes.js +16 -0
- package/server/lib/opencode/config-entity-v2.test.js +16 -1
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.js +2 -4
- package/server/lib/opencode/feature-routes-runtime.js +89 -49
- package/server/lib/opencode/lifecycle.js +41 -21
- package/server/lib/opencode/lifecycle.test.js +50 -2
- package/server/lib/opencode/model-discovery.js +1 -1
- package/server/lib/opencode/model-discovery.test.js +17 -0
- package/server/lib/opencode/models-metadata.js +0 -2
- package/server/lib/opencode/openchamber-routes.test.js +3 -3
- package/server/lib/opencode/plugins.js +6 -9
- package/server/lib/opencode/provider-source-route.test.js +101 -3
- package/server/lib/opencode/providers-disabled.test.js +59 -0
- package/server/lib/opencode/providers.js +34 -0
- package/server/lib/opencode/proxy.js +11 -3
- package/server/lib/opencode/routes.js +40 -2
- package/server/lib/opencode/settings-helpers.js +27 -1
- package/server/lib/opencode/settings-helpers.test.js +19 -7
- package/server/lib/opencode/settings-registry.json +27 -16
- package/server/lib/opencode/settings-runtime.test.js +18 -0
- package/server/lib/opencode/shared-service-runtime.js +23 -104
- package/server/lib/opencode/shared.js +77 -46
- package/server/lib/opencode/shared.test.js +12 -12
- package/server/lib/opencode/shutdown-runtime.test.js +2 -3
- package/server/lib/opencode/skill-routes.js +123 -38
- package/server/lib/opencode/skill-routes.test.js +201 -0
- package/server/lib/opencode/skills.js +81 -34
- package/server/lib/opencode/skills.test.js +176 -21
- package/server/lib/opencode/startup-pipeline-runtime.js +6 -3
- package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -1
- package/server/lib/opencode/watcher.test.js +0 -54
- package/server/lib/outbound-proxy.js +52 -0
- package/server/lib/outbound-proxy.test.js +55 -0
- package/server/lib/package-manager.js +23 -17
- package/server/lib/package-manager.test.js +5 -18
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +1 -1
- package/server/lib/permission-auto-accept/runtime.js +19 -47
- package/server/lib/permission-auto-accept/runtime.test.js +2 -2
- package/server/lib/project-context/DOCUMENTATION.md +7 -1
- package/server/lib/project-context/routes.js +1 -2
- package/server/lib/project-context/runtime.js +12 -14
- package/server/lib/project-context/runtime.test.js +78 -2
- package/server/lib/projects/project-config.js +30 -15
- package/server/lib/projects/project-config.test.js +30 -0
- package/server/lib/projects/project-setup.js +1 -2
- package/server/lib/projects/routes.js +1 -2
- package/server/lib/quota/DOCUMENTATION.md +35 -7
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/claude/index.js +1 -1
- package/server/lib/quota/providers/cline-pass.js +1 -1
- package/server/lib/quota/providers/exe-dev.js +1 -1
- package/server/lib/quota/providers/google/index.js +1 -1
- package/server/lib/quota/providers/hyper.js +1 -1
- package/server/lib/quota/providers/kimi.js +116 -36
- package/server/lib/quota/providers/kimi.test.js +128 -3
- package/server/lib/quota/providers/opencode-go.js +144 -21
- package/server/lib/quota/providers/opencode-go.test.js +229 -6
- package/server/lib/quota/providers/openrouter.js +1 -1
- package/server/lib/quota/providers/zenmux.js +1 -1
- package/server/lib/quota/utils/auth.js +1 -0
- package/server/lib/quota/utils/transformers.js +2 -6
- package/server/lib/relay/DOCUMENTATION.md +18 -3
- package/server/lib/relay/e2ee.js +7 -7
- package/server/lib/relay/host-client.js +84 -13
- package/server/lib/relay/host-client.test.js +201 -1
- package/server/lib/relay/identity.js +6 -29
- package/server/lib/relay/identity.test.js +18 -28
- package/server/lib/relay/key-store.js +141 -0
- package/server/lib/relay/key-store.test.js +138 -0
- package/server/lib/relay/service.js +8 -8
- package/server/lib/relay/service.test.js +10 -5
- package/server/lib/relay/signing-key.js +13 -36
- package/server/lib/relay/tunnel-codec.js +10 -10
- package/server/lib/route-module-exports.test.js +22 -0
- package/server/lib/routing/DOCUMENTATION.md +23 -3
- package/server/lib/routing/cache.js +87 -0
- package/server/lib/routing/defaults.js +11 -0
- package/server/lib/routing/history.js +12 -4
- package/server/lib/routing/runtime.js +39 -3
- package/server/lib/routing/runtime.test.js +81 -2
- package/server/lib/routing/store.js +12 -1
- package/server/lib/routing/store.test.js +13 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +59 -1
- package/server/lib/scheduled-tasks/existing-session.js +119 -0
- package/server/lib/scheduled-tasks/existing-session.test.js +350 -0
- package/server/lib/scheduled-tasks/loops.js +1 -8
- package/server/lib/scheduled-tasks/routes.js +8 -8
- package/server/lib/scheduled-tasks/runtime.js +103 -13
- package/server/lib/scheduled-tasks/runtime.test.js +48 -0
- package/server/lib/scheduled-tasks/service.js +33 -11
- package/server/lib/scheduled-tasks/service.test.js +128 -2
- package/server/lib/scheduled-tasks/session-defaults.js +27 -0
- package/server/lib/scheduled-tasks/session-defaults.test.js +19 -0
- package/server/lib/session-assist/context.js +1 -0
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-goal/objectives.js +1 -1
- package/server/lib/session-knowledge/routes.js +2 -2
- package/server/lib/session-knowledge/runtime.js +1 -2
- package/server/lib/session-work/DOCUMENTATION.md +39 -14
- package/server/lib/session-work/questions.js +31 -2
- package/server/lib/session-work/runtime.js +22 -13
- package/server/lib/session-work/runtime.test.js +43 -26
- package/server/lib/session-work/state.js +10 -4
- package/server/lib/session-work/state.test.js +8 -1
- package/server/lib/shared/DOCUMENTATION.md +89 -0
- package/server/lib/shared/guards.js +53 -0
- package/server/lib/shared/guards.test.js +112 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -8
- package/server/lib/skills-catalog/cache.js +3 -2
- package/server/lib/skills-catalog/curated-sources.js +5 -1
- package/server/lib/skills-catalog/git.js +107 -20
- package/server/lib/skills-catalog/git.test.js +78 -0
- package/server/lib/skills-catalog/install.js +21 -12
- package/server/lib/skills-catalog/scan.js +25 -15
- package/server/lib/skills-catalog/source.js +26 -1
- package/server/lib/skills-catalog/source.test.js +27 -0
- package/server/lib/source-control/DOCUMENTATION.md +2 -1
- package/server/lib/source-control/audit-storage.js +7 -6
- package/server/lib/source-control/audit-storage.test.js +11 -0
- package/server/lib/source-control/binding-service.js +2 -5
- package/server/lib/source-control/change-request-worktree.js +90 -0
- package/server/lib/source-control/change-request-worktree.test.js +121 -0
- package/server/lib/source-control/mutation-executor.js +1 -1
- package/server/lib/source-control/mutation-storage.js +11 -5
- package/server/lib/source-control/provider-instance.js +1 -2
- package/server/lib/source-control/repository-identity.js +1 -1
- package/server/lib/source-control/routes.js +14 -2
- package/server/lib/spaces/DOCUMENTATION.md +42 -17
- package/server/lib/spaces/command-stream.test.js +15 -0
- package/server/lib/spaces/dispatcher.js +7 -0
- package/server/lib/spaces/dispatcher.test.js +17 -0
- package/server/lib/spaces/hardening.js +2 -2
- package/server/lib/spaces/hardening.test.js +1 -1
- package/server/lib/spaces/host.js +2 -0
- package/server/lib/spaces/journey.js +66 -5
- package/server/lib/spaces/journey.test.js +95 -4
- package/server/lib/spaces/layout.js +1 -1
- package/server/lib/spaces/places/docker-disk.js +38 -14
- package/server/lib/spaces/places/docker-disk.test.js +80 -1
- package/server/lib/spaces/places/docker.js +35 -11
- package/server/lib/spaces/places/fake-docker.js +22 -3
- package/server/lib/spaces/places/memory-place.js +3 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +1 -1
- package/server/lib/spaces/routes.js +5 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/run-command.js +9 -2
- package/server/lib/spaces/tools.js +4 -5
- package/server/lib/spaces/tools.test.js +2 -2
- package/server/lib/terminal/runtime.js +18 -6
- package/server/lib/terminal/runtime.test.js +66 -0
- package/server/lib/tts/index.js +3 -0
- package/server/lib/tts/service.js +4 -2
- package/server/lib/walkthrough/DOCUMENTATION.md +3 -1
- package/server/lib/walkthrough/index.js +2 -3
- package/server/lib/walkthrough/pr-source.test.js +22 -0
- package/server/lib/walkthrough/sources.js +6 -1
- package/server/opencode-proxy.test.js +127 -0
- package/bin/lib/commands-startup.test.js +0 -15
- package/dist/assets/CodeMirrorCommentWidgets-CVDSjcrP.js +0 -1
- package/dist/assets/DiffView-Ct7vL3fD.js +0 -4
- package/dist/assets/FilesView-DT0uEYgT.js +0 -17
- package/dist/assets/GuestSurfacePane-DVvk1VPu.js +0 -1
- package/dist/assets/LinearIssuesView-C10MwA9h.js +0 -1
- package/dist/assets/MarkdownImageGallery-BbN_K_3d.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BLt2Tkk9.js +0 -10
- package/dist/assets/OnboardingScreen-Bgp5A3WB.js +0 -1
- package/dist/assets/PierreDiffViewer-CWJLj-S-.js +0 -210
- package/dist/assets/PlanView-DsRWnsOI.js +0 -5
- package/dist/assets/PublishDialog-CCeKloRu.js +0 -2
- package/dist/assets/SettingsView-BuPPsNPp.js +0 -30
- package/dist/assets/SettingsWindow-CM5fL8Ot.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-CfsMcfiQ.js +0 -1
- package/dist/assets/ToolOutputDialog-mZrfSofz.js +0 -15
- package/dist/assets/ToolPartDiffPreview-BUGCRYEL.js +0 -8
- package/dist/assets/WalkthroughView-ClBo7PPd.js +0 -4
- package/dist/assets/appThemeRegistry-CxzMxR-H.js +0 -1
- package/dist/assets/de-CBla4hjd.js +0 -14
- package/dist/assets/es-BmnZtxTD.js +0 -20
- package/dist/assets/fileTreeStatus-BSHFIGEg.js +0 -1
- package/dist/assets/fr-OVKIBUZO.js +0 -18
- package/dist/assets/index-CKCFKmjF.js +0 -1
- package/dist/assets/index-Dbx4V4GN.css +0 -1
- package/dist/assets/index-vQ1Pg1cr.js +0 -61
- package/dist/assets/ja-6v-yr-gE.js +0 -20
- package/dist/assets/ko-I_ZLvgQ9.js +0 -20
- package/dist/assets/main-CmO4dRtR.js +0 -2
- package/dist/assets/main-b9vqhlYM.js +0 -999
- package/dist/assets/markdownCore-BPEZRQfP.js +0 -7
- package/dist/assets/miniChat-B5Oi7B-6.js +0 -2
- package/dist/assets/mobile-CVtShif9.js +0 -2
- package/dist/assets/nl-DcvIJf46.js +0 -20
- package/dist/assets/patchFileDiff-CW3wCH1O.js +0 -13
- package/dist/assets/pl-JxCUl0sd.js +0 -20
- package/dist/assets/pt-BR-L89mjja2.js +0 -20
- package/dist/assets/relocateRestoredSession-DYh_9oBa.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BD-1JHSg.js +0 -2
- package/dist/assets/renderMobileApp-7s5InXt1.js +0 -25
- package/dist/assets/runtimeEndpointReset-DqLJC6L1.js +0 -53
- package/dist/assets/shikiHighlight-CXgZnvHh.js +0 -1
- package/dist/assets/space-apply-1trGVIl8.js +0 -1
- package/dist/assets/space-close-y7j-NuBv.js +0 -1
- package/dist/assets/tr-ka5J1flt.js +0 -11
- package/dist/assets/uk-PyGe6Q_u.js +0 -20
- package/dist/assets/useInlineCommentController-CrjSGCpi.js +0 -2
- package/dist/assets/vendor-codemirror-lang-python-B7ClrMIT.js +0 -3
- package/dist/assets/vendor-codemirror-lang-xml-C8tGnS64.js +0 -1
- package/dist/assets/vendor-codemirror-language-data-q2bKO1EM.js +0 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +0 -1
- package/dist/assets/vendor-katex-CHD9BdDO.js +0 -257
- package/dist/assets/vendor-katex-Cp579UoJ.css +0 -1
- package/dist/assets/zh-CN-B0P2tybJ.js +0 -20
- package/dist/assets/zh-TW-Bs9C5cN8.js +0 -20
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as r,f as et,j as n}from"./vendor-react-BUCujlKS.js";import{u as Y,T as Ae,H as rs,o as fn,a as Te,G as is}from"./index-vQ1Pg1cr.js";import{c as os,b as as,u as ls,a as cs,B as us,C as ds,P as mn,h as fs,e as ms,g as ps,i as hs,f as gs}from"./patchFileDiff-CW3wCH1O.js";import{c as xs,b as ys,i as bs,u as ws,a as vs,d as js,S as Ns}from"./SubmoduleDiffSummary-CfsMcfiQ.js";import{f as $e,B as Se,I as O,h as le,N as Nn,aA as Ss,L as ae,aB as ks,aK as Cs,bP as Fs,K as Rs,aC as Ds,aJ as Es,z as pn,k as As,dU as Sn,t as Ze,lL as Ts,a$ as lt,lA as kn,lM as Ls,eT as Vs,b3 as Gt,iv as Ms,aS as Lt,aY as at,a_ as Bs,cE as Ht,aU as Is,aW as Ps,aX as zs,aT as _s}from"./useAppFontEffects-DCqCVGlT.js";import{ap as Os,be as Ws,N as $s,b7 as qt,q as Ks}from"./runtimeEndpointReset-DqLJC6L1.js";import{P as Gs}from"./PierreDiffViewer-CWJLj-S-.js";import{v as Hs,g as qs,W as Us}from"./main-b9vqhlYM.js";import{b as Xs,c as Js}from"./changesTree-CePHbFcj.js";import{p as Ys}from"./parseDiffFromFile-Cy0PNxun.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DHzhmLwV.js";import"./computeVirtualFileMetrics-CmPe29DM.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"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DX96QhTP.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-H_JmXOFV.js";import"./vendor-tanstack-virtual-core-Dxc8hSTB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.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-ByBn5zIW.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-G3UuR-be.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-Bniqp7p5.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-CpGYXGuo.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DW1FQz9_.js";import"./vendor-codemirror-lang-json-58T70Hqs.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B07blnnZ.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DaH9adfE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BLKnlLP4.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q2bKO1EM.js";import"./vendor-codemirror-lang-python-B7ClrMIT.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DpmhalwN.js";import"./vendor-legendapp-list-DViGR95I.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./space-apply-1trGVIl8.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-CQmDCnEv.js";import"./vendor-diff-C3JhlQdm.js";import"./VirtualizedFileDiff-BTJVRkyo.js";import"./Virtualizer-xCEYz34p.js";import"./useInlineCommentController-CrjSGCpi.js";import"./appThemeRegistry-CxzMxR-H.js";import"./textMateThemeFromAppTheme-CDlKffWz.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-BowwS8kq.js";import"./fileTreeStatus-BSHFIGEg.js";import"./sessionOwnership-Bs1xbRfB.js";const Qs=r.memo(function(e){const s=et.c(13),{index:u,staged:g,busyHunk:m,disabled:b,onAction:N}=e,{t:w}=$e();let o;s[0]!==g?(o=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=o):o=s[1];const v=o;let j;s[2]===Symbol.for("react.memo_cache_sentinel")?(j={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=j):j=s[2];let F;s[3]!==v||s[4]!==m||s[5]!==b||s[6]!==u||s[7]!==N||s[8]!==w?(F=n.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:v.map(y=>{const R=w(y==="stage"?"diffView.hunk.stageTitle":y==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),P=m?.index===u&&m.action===y;return n.jsx(Se,{variant:"ghost",size:"xs",className:le("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",y==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",y==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:b||m!==null,title:R,"aria-label":R,onPointerDown:Zs,onClick:D=>{D.stopPropagation(),N(u,y)},children:n.jsx(O,{name:P?"loader-4":y==="stage"?"add":"arrow-go-back",className:le(y==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},y)})}),s[3]=v,s[4]=m,s[5]=b,s[6]=u,s[7]=N,s[8]=w,s[9]=F):F=s[9];let p;return s[10]!==u||s[11]!==F?(p=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:j,"data-hunk-actions":u,children:F}),s[10]=u,s[11]=F,s[12]=p):p=s[12],p});function Zs(a){return a.stopPropagation()}const hn=(a,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=a?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-a}:null},er=(a,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,a+s-e)),Ot=a=>a.slice(a.lastIndexOf("/")+1),Cn=(a,e)=>{const s=[],u=(g,m)=>{const b=Array.from(g.children.values()).sort((w,o)=>w.name.localeCompare(o.name));for(const w of b){const{node:o,label:v}=Js(w),j=!e.has(o.path);s.push({kind:"directory",key:`dir:${o.path}`,depth:m,path:o.path,label:v,fileCount:o.files.length,expanded:j}),j&&u(o,m+1)}const N=[...g.directFiles].sort((w,o)=>Ot(w.path).localeCompare(Ot(o.path)));for(const w of N)s.push({kind:"file",key:`file:${w.path}`,depth:m,name:Ot(w.path),file:w})};return u(Xs(a),0),s},gn=a=>{if(!a)return null;const e=a.split(`
|
|
2
|
-
`);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},tr=1100,nr=15e3,xn=500,yn=300,Fn=1e6,$t=3,sr=a=>a<=6?a:a<=12?6:a<=25?4:2,bn={status:"loading"},rr=3,ir=r.memo(()=>{const a=et.c(4),{t:e}=$e();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let u;return a[2]!==s?(u=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),a[2]=s,a[3]=u):u=a[3],u}),or=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},wn=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},vn=a=>!!a.working_dir?.trim()||a.index==="?",ar=(a,e)=>Ms(a,e),jn=(a,e)=>{const s=a.split(`
|
|
3
|
-
`),u=e.split(`
|
|
4
|
-
`),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},lr=a=>a==="added"?"A":a==="deleted"?"D":"M",Kt=(a,e,s)=>hs(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:gs(a,e),contextMode:s},Rn=(a,e,s)=>{const u=a??0,g=e??0;return!u&&!g?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},cr=r.memo(a=>{const e=et.c(70),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:b,commitCount:N,prCount:w,showCommitOption:o,showBranchOption:v,changeRequestProvider:j,onScopeChange:F}=a,{t:p}=$e(),[y,R]=r.useState(!1),P=s==="pr"?w??0:s==="staged"?g:s==="turn"?m:s==="branch"?b??0:s==="commit"?N??0:u;let D;e[0]!==j||e[1]!==s||e[2]!==p?(D=p(s==="pr"?Lt("session.githubIntegration.tabs.pullRequests",j):s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=j,e[1]=s,e[2]=p,e[3]=D):D=e[3];const f=D;let k;e[4]!==p?(k=p("diffView.scope.selectorAria"),e[4]=p,e[5]=k):k=e[5];let $;e[6]!==P?($=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",P]}),e[6]=P,e[7]=$):$=e[7];let ie;e[8]!==f||e[9]!==$?(ie=n.jsxs("span",{className:"whitespace-nowrap",children:[f,$]}),e[8]=f,e[9]=$,e[10]=ie):ie=e[10];let U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(O,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[11]=U):U=e[11];let S;e[12]!==k||e[13]!==ie?(S=n.jsx(Is,{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":k,children:[ie,U]})}),e[12]=k,e[13]=ie,e[14]=S):S=e[14];let W;e[15]!==F?(W=de=>{(de==="working"||de==="staged"||de==="turn"||de==="branch"||de==="commit"||de==="pr")&&(F?.(de),R(!1))},e[15]=F,e[16]=W):W=e[16];let A;e[17]!==p?(A=p("diffView.scope.changed"),e[17]=p,e[18]=A):A=e[18];let ce;e[19]!==A?(ce=n.jsx("span",{children:A}),e[19]=A,e[20]=ce):ce=e[20];let te;e[21]!==u?(te=n.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[21]=u,e[22]=te):te=e[22];let ge;e[23]!==te||e[24]!==ce?(ge=n.jsx(at,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ce,te]})}),e[23]=te,e[24]=ce,e[25]=ge):ge=e[25];let ue;e[26]!==p?(ue=p("diffView.scope.staged"),e[26]=p,e[27]=ue):ue=e[27];let xe;e[28]!==ue?(xe=n.jsx("span",{children:ue}),e[28]=ue,e[29]=xe):xe=e[29];let ne;e[30]!==g?(ne=n.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[30]=g,e[31]=ne):ne=e[31];let X;e[32]!==xe||e[33]!==ne?(X=n.jsx(at,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[xe,ne]})}),e[32]=xe,e[33]=ne,e[34]=X):X=e[34];let ye;e[35]!==p?(ye=p("diffView.scope.lastTurn"),e[35]=p,e[36]=ye):ye=e[36];let K;e[37]!==ye?(K=n.jsx("span",{children:ye}),e[37]=ye,e[38]=K):K=e[38];let G;e[39]!==m?(G=n.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[39]=m,e[40]=G):G=e[40];let be;e[41]!==K||e[42]!==G?(be=n.jsx(at,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[K,G]})}),e[41]=K,e[42]=G,e[43]=be):be=e[43];let L;e[44]!==b||e[45]!==v||e[46]!==p?(L=v?n.jsx(at,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:b??"…"})]})}):null,e[44]=b,e[45]=v,e[46]=p,e[47]=L):L=e[47];let ke;e[48]!==N||e[49]!==o||e[50]!==p?(ke=o&&n.jsx(at,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N??"…"})]})}),e[48]=N,e[49]=o,e[50]=p,e[51]=ke):ke=e[51];let V;e[52]!==j||e[53]!==w||e[54]!==o||e[55]!==p?(V=o&&n.jsx(at,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p(Lt("session.githubIntegration.tabs.pullRequests",j))}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:w??"…"})]})}),e[52]=j,e[53]=w,e[54]=o,e[55]=p,e[56]=V):V=e[56];let B;e[57]!==s||e[58]!==ge||e[59]!==X||e[60]!==be||e[61]!==L||e[62]!==ke||e[63]!==V||e[64]!==W?(B=n.jsx(Ps,{align:"start",className:"w-40",children:n.jsxs(zs,{value:s,onValueChange:W,children:[ge,X,be,L,ke,V]})}),e[57]=s,e[58]=ge,e[59]=X,e[60]=be,e[61]=L,e[62]=ke,e[63]=V,e[64]=W,e[65]=B):B=e[65];let se;return e[66]!==y||e[67]!==B||e[68]!==S?(se=n.jsxs(_s,{open:y,onOpenChange:R,children:[S,B]}),e[66]=y,e[67]=B,e[68]=S,e[69]=se):se=e[69],se}),ur=r.memo(a=>{const e=et.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=a,{t:m}=$e();if(s.length===0)return null;let b;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let w;e[5]!==g||e[6]!==u||e[7]!==m?(w=o=>{const v=qt(o),j=u===o.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>g(o.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",j?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(Gt,{filePath:o.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:v.color},title:m(v.descriptionKey),"aria-label":m(v.descriptionKey),children:v.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:o.path,children:o.path}),Rn(o.insertions,o.deletions)]})},o.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=w):w=e[8],b=s.map(w),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=b}else b=e[4];let N;return e[9]!==b?(N=n.jsx(Ht,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:b})}),e[9]=b,e[10]=N):N=e[10],N}),Dn=12,En=8,Wt=160,dr=.5,fr=r.memo(a=>{const e=et.c(18),{changedFiles:s,selectedFile:u,onSelectFile:g}=a,{t:m}=$e(),[b,N]=r.useState(gr);let w;e[0]!==s||e[1]!==b?(w=Cn(s,b),e[0]=s,e[1]=b,e[2]=w):w=e[2];const o=w;let v,j;e[3]!==u?(v=()=>{u&&N(D=>{const f=Array.from(D).filter($=>u.startsWith(`${$}/`));if(f.length===0)return D;const k=new Set(D);return f.forEach($=>k.delete($)),k})},j=[u],e[3]=u,e[4]=v,e[5]=j):(v=e[4],j=e[5]),r.useEffect(v,j);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{N(f=>{const k=new Set(f);return k.delete(D)||k.add(D),k})},e[6]=F):F=e[6];const p=F,y=yr;let R;if(e[7]!==g||e[8]!==o||e[9]!==u||e[10]!==m){let D;e[12]!==g||e[13]!==u||e[14]!==m?(D=f=>{const k=`${En+f.depth*Dn}px`;if(f.kind==="directory")return n.jsxs("li",{className:"relative",children:[y(f.depth),n.jsxs("button",{type:"button",onClick:()=>p(f.path),"aria-expanded":f.expanded,"aria-label":f.expanded?m("diffView.fileTree.collapseDirectoryAria",{path:f.path}):m("diffView.fileTree.expandDirectoryAria",{path:f.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pr-2 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingLeft:k},title:f.path,children:[n.jsx(O,{name:"arrow-right-s",className:le("size-3.5 flex-shrink-0 transition-transform",f.expanded&&"rotate-90")}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:f.label})]})]},f.key);const $=qt(f.file),ie=u===f.file.path;return n.jsxs("li",{className:"relative",children:[y(f.depth),n.jsxs("button",{type:"button",onClick:()=>g(f.file.path),"aria-current":ie?"true":void 0,className:le("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left transition-colors",ie?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground/90 hover:bg-interactive-hover hover:text-foreground"),style:{paddingLeft:k},title:f.file.path,children:[n.jsx(Gt,{filePath:f.file.path,className:"ml-0.5 size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:f.name}),n.jsx("span",{className:"typography-micro font-semibold w-3 text-center uppercase",style:{color:$.color},title:m($.descriptionKey),"aria-label":m($.descriptionKey),children:$.code})]})]},f.key)},e[12]=g,e[13]=u,e[14]=m,e[15]=D):D=e[15],R=o.map(D),e[7]=g,e[8]=o,e[9]=u,e[10]=m,e[11]=R}else R=e[11];let P;return e[16]!==R?(P=n.jsx(Ht,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:n.jsx("ul",{className:"flex flex-col",children:R})}),e[16]=R,e[17]=P):P=e[17],P}),mr=r.memo(a=>{const e=et.c(20),{filePath:s,diff:u,renderSideBySide:g}=a,{t:m}=$e(),b=u.original.length>0,N=u.modified.length>0,w=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",o=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={contain:"layout"},e[0]=v):v=e[0];let j;e[1]!==u.original||e[2]!==s||e[3]!==b||e[4]!==o||e[5]!==g||e[6]!==m?(j=b&&n.jsxs("div",{className:o,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),n.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=b,e[4]=o,e[5]=g,e[6]=m,e[7]=j):j=e[7];let F;e[8]!==u.modified||e[9]!==s||e[10]!==N||e[11]!==b||e[12]!==o||e[13]!==g||e[14]!==m?(F=N&&n.jsxs("div",{className:o,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(b?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=N,e[11]=b,e[12]=o,e[13]=g,e[14]=m,e[15]=F):F=e[15];let p;return e[16]!==w||e[17]!==j||e[18]!==F?(p=n.jsx("div",{className:"w-full overflow-auto p-4",style:v,children:n.jsxs("div",{className:w,children:[j,F]})}),e[16]=w,e[17]=j,e[18]=F,e[19]=p):p=e[19],p}),pr=r.memo(a=>{const e=et.c(23),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:b,hunkActions:N,onExpandContextRequest:w,pendingContextExpansion:o,contextLoading:v}=a;let j;e[0]!==s?(j=Bs(s)||"text",e[0]=s,e[1]=j):j=e[1];const F=j;if(u.submodule){let R;return e[2]!==u.submodule||e[3]!==g?(R=n.jsx(Ns,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=R):R=e[4],R}if(u.isBinary){let R;return e[5]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(ir,{}),e[5]=R):R=e[5],R}if(lt(s)){let R;return e[6]!==u||e[7]!==s||e[8]!==m?(R=n.jsx(mr,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=R):R=e[9],R}let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p={contain:"layout"},e[10]=p):p=e[10];let y;return e[11]!==v||e[12]!==u.fileDiff||e[13]!==u.modified||e[14]!==u.original||e[15]!==s||e[16]!==N||e[17]!==F||e[18]!==w||e[19]!==o||e[20]!==m||e[21]!==b?(y=n.jsx("div",{className:"w-full",style:p,children:n.jsx(Gs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:F,fileName:s,renderSideBySide:m,wrapLines:b,layout:"inline",hunkActions:N,onExpandContextRequest:w,pendingContextExpansion:o,contextLoading:v})}),e[11]=v,e[12]=u.fileDiff,e[13]=u.modified,e[14]=u.original,e[15]=s,e[16]=N,e[17]=F,e[18]=w,e[19]=o,e[20]=m,e[21]=b,e[22]=y):y=e[22],y}),hr=r.memo(({visible:a=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:b,isMounted:N,onSelect:w,onExpandedChange:o,registerSectionRef:v,showOpenInEditorAction:j=!1,isOpeningInEditor:F=!1,onOpenInEditor:p,staged:y=!1,loadFullFiles:R=!1,initialDiffData:P=null,comparisonDiff:D,onRetryComparisonDiff:f,loadFullComparisonDiff:k,readOnlyActions:$=!1,hunkActionsEnabled:ie=!1,contentRevision:U=0})=>{const{t:S}=$e(),{git:W}=Nn(),A=ae(r.useCallback(x=>x.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),ce=ae(x=>x.setDiff),te=ae(x=>x.fetchStatus),ge=Y(x=>x.setDiffFileLayout),[ue,xe]=r.useState(0),[ne,X]=r.useState(null),[ye,K]=r.useState(!1),[G,be]=r.useState(null),L=G!==null&&G.source===D?G.result:D,ke=!!e&&!P&&(!D||!!k),V=r.useMemo(()=>L?L.status==="error"?{kind:"error",message:L.message}:null:ne,[L,ne]),B=L?L.status==="loading":ye,[se,de]=r.useState(null),Re=r.useRef(!1),[tt,Ke]=r.useState(null),[ct,Vt]=r.useState(!1),[ut,dt]=r.useState(null),[bt,Le]=r.useState(null),[De,ft]=r.useState(null),l=R||De!==null;r.useEffect(()=>{if(!De||!k||!D||D.status!=="ready"||G?.source===D)return;let x=!1;return k(s.path).then(z=>{if(!x){if(z.status==="error"){Ze.error(z.message),ft(null);return}be({source:D,result:z})}}),()=>{x=!0}},[De,s.path,G,k,D]);const re=r.useRef(null),Ge=r.useRef(null),He=r.useMemo(()=>qt(s),[s]),Ee=u==="side-by-side",qe=l?"full":"patch",we=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,fe=ie&&!$&&!P&&!L&&!lt(s.path),Ue=JSON.stringify([Te(),e,s.path,y,we,ue,U]),Q=tt?.scope===Ue?tt.patch:null,wt=tt?.scope===Ue?tt.submodule:null,Z=r.useMemo(()=>L?L.status==="ready"?L.data:null:P||(y?bt:ut||(A?{original:A.original,modified:A.modified,isBinary:A.isBinary,submodule:A.submodule,contextMode:"full"}:null)),[L,A,P,ut,y,bt]),vt=Z?.contextMode===qe,jt=r.useCallback(x=>{Ge.current=x,v(s.path,x)},[s.path,v]),me=r.useCallback(x=>{o(s.path,x)},[s.path,o]),nt=r.useCallback(()=>{w(s.path)},[s.path,w]),st=r.useRef({fileStatusKey:we,staged:y});r.useEffect(()=>{if(!a)return;const x=st.current;x.fileStatusKey===we&&x.staged===y||(st.current={fileStatusKey:we,staged:y},y?Le(null):dt(null),X(null),re.current=null)},[we,y,a]);const[mt,rt]=r.useState(U),Ce=mt===U;r.useEffect(()=>{Ce||(X(null),re.current=null)},[Ce]),r.useEffect(()=>{if(!a||!b||!N||ne)return;if(!e||L||P||Z&&vt&&Ce&&(!fe||Q!==null)){re.current=null,K(!1);return}const x=`${e}::${s.path}::${y?"staged":"unstaged"}::${we}::${qe}::${ue}::${U}`;if(re.current===x)return;re.current=x,X(null),K(!0);let z=!1;const pe=Te(),Be=l?Fn:$t,ee=lt(s.path)?W.getGitFileDiff(e,{path:s.path,staged:y}):!l&&Q!==null?Promise.resolve({diff:Q,submodule:wt}):W.getGitDiff(e,{path:s.path,staged:y,contextLines:Be}),Ie=fe&&l&&Q===null?W.getGitDiff(e,{path:s.path,staged:y,contextLines:$t}).then(M=>M.diff):Promise.resolve(Q),je=Promise.all([ee,Ie]),Pe=nr;let it;const Mt=new Promise((M,pt)=>{it=setTimeout(()=>pt(new Error(`Timed out after ${Pe}ms`)),Pe)});return Promise.race([je,Mt]).then(([M,pt])=>{if(z||pe!==Te())return;const ze="diff"in M&&!l?M.diff:pt;if(fe&&l&&ze!==null&&/^@@\s/m.test(ze)&&"diff"in M&&M.diff!==ze&&!fs(M.diff,ze))throw Ke(null),new Error(S("diffView.hunk.unavailable"));if(fe&&ze!==null&&Ke({scope:Ue,patch:ze,submodule:M.submodule}),"diff"in M){const Je={...Kt(s.path,M.diff,qe),submodule:M.submodule};y?Le(Je):dt(Je)}else{const Je={original:M.original??"",modified:M.modified??"",isBinary:M.isBinary,submodule:M.submodule,contextMode:"full"};y?Le(Je):ce(e,s.path,Je,pe)}rt(U),K(!1)}).catch(M=>{if(!(z||pe!==Te())){if(K(!1),M instanceof is){X({kind:"unavailable",reason:M.reason}),M.reason==="path_not_found"&&te(e,W,{force:!0,silent:!0});return}X({kind:"error",message:M instanceof Error?M.message:String(M)})}}).finally(()=>clearTimeout(it)),()=>{z=!0,clearTimeout(it),re.current===x&&(re.current=null)}},[Q,wt,U,fe,Ce,Ue,L,qe,Z,vt,ue,e,te,s.path,we,W,P,b,N,l,ne,ce,y,S,a]);const Nt=r.useCallback(()=>{me(!b),nt()},[me,nt,b]),Xe=r.useCallback(()=>{X(null),Ke(null),dt(null),Le(null),re.current=null,xe(x=>x+1)},[]),St=Vs(),{confirm:Fe}=St,Ve=r.useCallback(async(x,z)=>{if(!e||!fe||B||V||Re.current||se!==null)return;const pe=Q?ms(Q,x):null;if(!pe){Ze.error(S("diffView.hunk.unavailable"));return}if(y&&z!=="unstage"||!y&&z==="unstage"||z==="discard"&&!await Fe({title:S("diffView.hunk.discardDialogTitle"),message:S("diffView.hunk.discardDescription",{path:s.path}),action:S("diffView.hunk.discard"),destructive:!0})||Re.current)return;Re.current=!0;const Be=Te();de({index:x,action:z});try{const ee=z==="stage"?W.stageGitHunk:z==="unstage"?W.unstageGitHunk:W.revertGitHunk;if(!ee){Ze.error(S("diffView.hunk.unsupported"));return}if(await ee(e,s.path,pe),Be!==Te())return;Xe(),Sn.requestGitRefresh({directory:e,paths:[s.path]}),await te(e,W)}catch(ee){if(Be!==Te())return;Xe(),Ze.error(ee instanceof Error&&ee.message?ee.message:S("diffView.hunk.unavailable"))}finally{Re.current=!1,de(ee=>ee?.index===x&&ee.action===z?null:ee)}},[Q,Fe,fe,B,V,e,te,s.path,W,se,Xe,y,S]),ve=r.useMemo(()=>fe&&Q!==null?ps(Q):[],[Q,fe]),q=r.useCallback(x=>n.jsx(Qs,{index:x,staged:y,busyHunk:se,disabled:B||!!V,onAction:Ve}),[V,Ve,se,B,y]),Me=r.useMemo(()=>ve.length>0?{anchors:ve,render:q}:void 0,[ve,q]);return n.jsxs("div",{ref:jt,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:Nt,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),Nt())},className:le("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:b?n.jsx(O,{name:"arrow-down-s",className:"size-4"}):n.jsx(O,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:He.color},title:S(He.descriptionKey),"aria-label":S(He.descriptionKey),children:He.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Gt,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=s.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const z=s.path.slice(0,x),pe=s.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:z}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:pe})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Rn(s.insertions,s.deletions),j&&p?n.jsx(Se,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:S("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),p(s.path,Z)},disabled:F,children:F?n.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(O,{name:"edit",className:"size-3.5"})}):null,n.jsx(kn,{mode:Ee?"side-by-side":"unified",onModeChange:x=>{const z=x==="side-by-side"?"side-by-side":"inline";ge(s.path,z)},className:"opacity-70"})]})]})}),b&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!N&&!V?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,V?.kind==="unavailable"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:V.reason==="nested_repository"?S("diffView.unavailable.nestedRepositoryTitle"):V.reason==="untracked_directory"?S("diffView.unavailable.untrackedDirectoryTitle"):S("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:V.reason==="nested_repository"?S("diffView.unavailable.nestedRepositoryDescription"):V.reason==="untracked_directory"?S("diffView.unavailable.untrackedDirectoryDescription"):S("diffView.unavailable.missingDescription")}),V.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Xe,children:S("diffView.actions.retry")}):null]}):null,V?.kind==="error"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:S("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:V.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>L?f?.():Xe(),children:S("diffView.actions.retry")})]}):null,N&&B&&!Z&&!V?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),S("diffView.state.loadingDiff")]}):null,N&&Z&&!ct&&s.insertions+s.deletions>xn?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:S("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:S("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Vt(!0),children:S("diffView.actions.renderAnyway")})]}):null,N&&Z&&(ct||s.insertions+s.deletions<=xn)?n.jsx(n.Fragment,{children:n.jsx(pr,{filePath:s.path,diff:Z,staged:y,renderSideBySide:Ee,wrapLines:g,hunkActions:Me,onExpandContextRequest:ke?ft:void 0,pendingContextExpansion:De,contextLoading:De!==null&&Z.contextMode!=="full"&&!V})}):null]}),St.dialog]})}),zo=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:b,targetFilePath:N=null,flushContent:w=!1})=>{const{t:o}=$e(),{git:v,files:j,sourceControl:F}=Nn(),p=Ss(),y=ae(t=>t.runtimeKey),{rootIsGitRepo:R,gitDirectory:P,nestedRepos:D}=ks(p??null,{enabled:a}),f=P??p,k=Cs(f,F),$=Y(t=>t.openContextSurface),ie=Os(t=>t.requestTarget),{screenWidth:U,isMobile:S}=Fs(),W=Rs(f??null),A=Ds(f??null),ce=Es(f??null),te=ae(t=>t.setActiveDirectory),ge=ae(t=>t.ensureStatus),ue=ae(t=>t.selectNestedRepo),xe=ae(t=>t.fetchStatus),ne=ae(t=>t.fetchBranches),X=ae(t=>t.clearDiffCache),ye=ae(t=>t.setDiff),[K,G]=r.useState(null),[be,L]=r.useState(!1),[ke,V]=r.useState(null),[B,se]=r.useState(()=>new Set),[de,Re]=r.useState(()=>new Set),[tt,Ke]=r.useState(0),[ct,Vt]=r.useState(()=>new Map),[ut,dt]=r.useState(0),[bt,Le]=r.useState(!1),[De,ft]=r.useState(!1),[l,re]=r.useState(m);r.useEffect(()=>{re(m)},[m]);const Ge=Y(t=>t.pendingDiffFile),He=Y(t=>t.pendingDiffStaged),Ee=Y(t=>t.pendingDiffScope),qe=Y(t=>t.setPendingDiffFile),we=Y(t=>t.diffLayoutPreference),fe=Y(t=>t.diffFileLayout),Ue=Y(t=>t.setDiffFileLayout),Q=Y(t=>t.diffWrapLines),wt=Y(t=>t.setDiffWrapLines),Z=Y(t=>t.diffFileListMode),vt=Y(t=>t.setDiffFileListMode),jt=Y(t=>t.openContextFileAtLine),me=pn(t=>t.currentSessionId),nt=As(l==="turn"?me??"":"",p??void 0),st=Q,mt=l==="staged"?!0:l==="working"?!1:null,rt=mt??be,Ce=S||U<=768,Nt=!!me&&l!=="turn"&&l!=="commit"&&l!=="pr"&&!Ce&&!Ae(),Xe=l!=="turn"&&!Ce&&!Ae(),St=!e&&!Ce&&U>=1024,Fe=r.useRef(null),Ve=r.useRef(new Map),ve=r.useRef(null),q=r.useRef(null),Me=r.useRef(!1),x=r.useRef(null),z=r.useRef(null),pe=r.useRef(null),Be=r.useRef(null),ee=r.useCallback(()=>{const t=Fe.current;if(!t)return null;const i=t.getBoundingClientRect().top,c=[];for(const[d,h]of Ve.current)h&&c.push({path:d,top:h.getBoundingClientRect().top});return hn(i,c)},[]),Ie=r.useCallback(()=>{ve.current=null,Me.current=!1,V(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)},[]),je=r.useCallback(t=>{se(i=>{if(i.has(t))return i;const c=new Set(i);return c.add(t),c})},[]),[Pe,it]=r.useState([]),Mt=nt.length>0?nt[nt.length-1].id:"";r.useEffect(()=>{if(l!=="turn"||!me||!a)return;let t=!1;return rs.getSessionTurnDiff(me,{directory:p??void 0}).then(i=>{t||it(i.map(c=>({file:c.file,patch:c.patch,status:c.status,additions:c.additions,deletions:c.deletions})))}).catch(i=>{t||(console.warn("[diff-view] turn diff unavailable:",i instanceof Error?i.message:i),it([]))}),()=>{t=!0}},[l,me,Mt,p,a]);const M=r.useMemo(()=>{const t=new Map;for(const i of Pe)if(i.file){if(typeof i.patch=="string"){t.set(i.file,Kt(i.file,i.patch,"patch"));continue}t.set(i.file,{original:i.before??"",modified:i.after??"",contextMode:"full"})}return t},[Pe]),pt=r.useMemo(()=>A?.files?A.files.filter(vn).length:0,[A]),ze=r.useMemo(()=>A?.files?A.files.filter(wn).length:0,[A]),Je=Pe.length,H=A?.current??null,kt=k.contexts[0]?.provider==="github"||k.contexts[0]?.provider==="gitlab"?k.contexts[0]:null,oe=os(f??null,H,kt,a&&l==="pr"&&!Ae()),_e=oe.selectedSource,Oe=as(f??null,H,a&&l==="commit"&&!Ae()),Ye=Oe.selectedCommit?.hash??null;r.useEffect(()=>{(l==="commit"||l==="pr")&&Ae()&&(re("working"),b?.("working"))},[l,b]);const Qe=ae(t=>f?t.directories.get(f)?.branches??null:null),An=ae(t=>f?t.directories.get(f)?.isLoadingBranches??!1:!1),Tn=r.useCallback(()=>{f&&ne(f,v)},[f,ne,v]),Ln=xs(f??null,a&&W!==!1,An,!!Qe,Tn,rr),Ut=r.useMemo(()=>{const t=k.contexts[0]?.primaryRemote;return t?Qe?.defaultBranches?.[t]??null:null},[k.contexts,Qe]),Xt=!Ae()&&ys(H,Ut),Vn=A!==null,Jt=Ae()||Ln||bs(H,Ut,Vn,Qe!==null&&k.status==="ready"),Mn=ls(t=>t.setOverride),{base:ht,resolved:Bn,revision:Yt}=cs(f??null,H,a&&Xt&&l==="branch"),[In,Pn]=r.useState(0);r.useEffect(()=>{const t=js(l,!Jt);t!==l&&(re(t),t==="working"&&b?.("working"))},[l,Jt,b]);const We=r.useMemo(()=>{if(!ht||ht===H)return null;const t=Qe?.all??[];return Ws(ht,{localBranches:t.filter(i=>!i.startsWith("remotes/")),remoteBranches:t.filter(i=>i.startsWith("remotes/")).map(i=>i.slice(8)),remoteNames:new Set(k.read?.repository.remotes.map(i=>i.name)??[]),primaryRemote:k.contexts[0]?.primaryRemote})},[k.contexts,k.read,ht,Qe,H]),zn=r.useMemo(()=>l==="pr"?_e:l==="commit"&&Ye?{kind:"commit",hash:Ye}:l==="branch"&&We&&H?{kind:"branch",baseRef:We,headRef:H}:null,[l,We,H,Ye,_e]),_=ws(f??null,zn,a&&!Ae(),l==="branch"?Yt:"",oe.readContext,oe.provider),{fetchDiff:Qt,fetchFullFile:Zt}=_,en=l==="commit"?_.files:null,tn=l==="commit"?_.error:null,Ct=l==="branch"?_.files:null,nn=l==="branch"?_.error:null,sn=_.files?l==="pr"?JSON.stringify([_.key,_.revision]):_.key:null,_n=r.useMemo(()=>l==="branch"||l==="commit"||l==="pr"?Array.from(B).sort().join("\0"):"",[l,B]),Bt=r.useCallback(async(t,i=!1)=>{try{const c=await Qt(t,i?Fn:$t);return{status:"ready",data:Kt(t,c.diff,i?"full":"patch")}}catch(c){return{status:"error",message:c instanceof Error?c.message:o("diffView.state.failedToLoadDiff")}}},[Qt,o]),rn=r.useCallback(async t=>{try{const{original:i,modified:c}=await Zt(t),d=Ys({name:t,contents:i},{name:t,contents:c});return{status:"ready",data:{original:i,modified:c,fileDiff:d,contextMode:"full"}}}catch(i){return{status:"error",message:i instanceof Error?i.message:o("diffView.state.failedToLoadDiff")}}},[Zt,o]),On=r.useMemo(()=>l==="branch"||l==="commit"?t=>Bt(t,!0):l==="pr"?rn:void 0,[l,Bt,rn]),Wn=vs(sn,a?_n:"",sn?Bt:null,bn,JSON.stringify([l==="branch"?Yt:"",l==="pr"?_.revision:0,In])),$n=Ct?.length??null,T=r.useMemo(()=>{if(l==="commit"||l==="pr")return(_.files??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:d.insertions,deletions:d.deletions,isNew:d.status==="A"}));if(l==="branch")return(Ct??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:0,deletions:0,isNew:d.status==="A"})).sort((d,h)=>d.path.localeCompare(h.path));if(l==="turn")return Pe.map(d=>({path:d.file??"",index:"",working_dir:lr(d.status),insertions:d.additions??0,deletions:d.deletions??0,isNew:d.status==="added"})).filter(d=>d.path).sort((d,h)=>d.path.localeCompare(h.path));if(!A?.files)return[];const t=A.diffStats,i=l==="staged"?wn:l==="working"?vn:()=>!0,c=d=>{const h=t?.staged?.[d],C=t?.working?.[d];return l==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:l==="working"?{insertions:C?.insertions??0,deletions:C?.deletions??0}:{insertions:(h?.insertions??0)+(C?.insertions??0),deletions:(h?.deletions??0)+(C?.deletions??0)}};return A.files.filter(i).map(d=>{const h=c(d.path);return{...d,insertions:h.insertions,deletions:h.deletions,isNew:or(d)}}).sort((d,h)=>d.path.localeCompare(h.path))},[l,Ct,_.files,Pe,A]),It=r.useMemo(()=>T.map(t=>t.path).join("\0"),[T]);r.useEffect(()=>{const t=It?It.split("\0"):[],i=new Set(t),c=`${f??""}:${l}:${s?"collapsed":"default"}`,d=z.current!==c;z.current=c,se(h=>{if(d){const I=s?0:sr(t.length);return new Set(t.slice(0,I))}let C=!1;const E=new Set;for(const I of h){if(!i.has(I)){C=!0;continue}E.add(I)}return C?E:h}),Re(h=>{if(d)return new Set;let C=!1;const E=new Set;for(const I of h){if(!i.has(I)){C=!0;continue}E.add(I)}return C?E:h})},[l,It,f,s]);const on=r.useCallback(()=>{if(x.current=null,!a)return;const t=Fe.current;if(!t)return;const i=t.getBoundingClientRect(),c=i.top-yn,d=i.bottom+yn,h={},C=[];for(const[E,I]of Ve.current){if(!I)continue;const J=I.getBoundingClientRect();C.push({path:E,top:J.top}),B.has(E)&&(J.bottom<c||J.top>d||(h[E]=!0))}pe.current=hn(i.top,C),Re(E=>{let I=!1;const J=new Set(E);for(const yt of Object.keys(h))J.has(yt)||(J.add(yt),I=!0);return I?J:E})},[B,a]),he=r.useCallback(()=>{a&&(typeof window>"u"||x.current===null&&(x.current=window.requestAnimationFrame(on)))},[on,a]);r.useEffect(()=>{const t=Fe.current;if(!(!a||!t))return he(),t.addEventListener("scroll",he,{passive:!0}),window.addEventListener("resize",he),()=>{t.removeEventListener("scroll",he),window.removeEventListener("resize",he),x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}},[T,B,he,a]);const Pt=r.useCallback(t=>{const i=fe[t.path];if(i)return i;if(we==="inline")return"inline";if(we==="side-by-side")return"side-by-side";const c=U<tr;return t.isNew||c?"inline":"side-by-side"},[fe,we,U]),an=r.useMemo(()=>T.length===0?null:T.every(t=>Pt(t)==="side-by-side")?"side-by-side":"inline",[T,Pt]);r.useEffect(()=>{a&&f&&(te(f),ge(f,v))},[f,te,ge,v,a]);const Ft=JSON.stringify([y,f]),zt=r.useRef({scope:Ft,paths:new Set,dirty:!1,unscoped:!1}),ln=r.useRef(a);r.useEffect(()=>{const t=a&&!ln.current;if(ln.current=a,zt.current.scope!==Ft&&(zt.current={scope:Ft,paths:new Set,dirty:!1,unscoped:!1}),!f)return;const i=(d,h)=>{d.length&&(Be.current=ee()??pe.current,X(f,d),Vt(C=>{const E=new Map(C);for(const I of d)E.set(I,(E.get(I)??0)+1);return E})),h&&dt(C=>C+1),xe(f,v,{silent:!0})},c=zt.current;return a&&(t||c.dirty)&&(i([...c.paths],c.unscoped),c.paths.clear(),c.dirty=!1,c.unscoped=!1),Sn.onGitRefreshHint(d=>{if(fn(d.directory)!==fn(f))return;const h=d.paths??[],C=h.length===0;if(!a){c.dirty=!0,c.unscoped||=C;for(const E of h)c.paths.add(E);return}i(h,C)})},[ee,X,f,xe,v,Ft,a]),r.useLayoutEffect(()=>{const t=Be.current;if(!t)return;Be.current=null;const i=Fe.current,c=Ve.current.get(t.path);if(!i||!c)return;const d=i.getBoundingClientRect().top,h=c.getBoundingClientRect().top-d;i.scrollTop=er(i.scrollTop,t.topOffset,h,i.scrollHeight-i.clientHeight),pe.current=t},[ct]),r.useEffect(()=>{!a||l!=="all"&&!Ee||Ge&&(Ee&&re(Ee),G(Ge),L(Ee==="staged"||!Ee&&He),qe(null),Me.current=!0,ve.current=Ge,je(Ge),Ke(t=>t+1))},[l,je,Ge,Ee,He,qe,a]),r.useEffect(()=>{if(l==="all")return;const t=N?.trim();t&&(G(t),L(l==="staged"),Me.current=!0,ve.current=t,je(t),Ke(i=>i+1))},[l,je,N]),r.useEffect(()=>{if(!K)return;T.some(i=>i.path===K)||(G(null),L(!1))},[T,K]);const Kn=r.useCallback((t,i)=>{const c=Ve.current;i?c.set(t,i):c.delete(t),he()},[he]),Gn=r.useCallback((t,i)=>{Ie(),se(c=>{const d=c.has(t);if(i===d)return c;const h=new Set(c);return i?h.add(t):h.delete(t),h}),i||Re(c=>{if(!c.has(t))return c;const d=new Set(c);return d.delete(t),d}),he()},[Ie,he]),Hn=r.useCallback(()=>{Ie(),se(t=>t.size>0?new Set:new Set(T.map(i=>i.path))),Re(new Set),he()},[Ie,T,he]),qn=r.useCallback(async t=>{if(!me)return;const i=pn.getState().getDirectoryForSession(me)||p||"";if(!i){Ze.error(o("diffView.reviewDialog.toast.noSessionDirectory"));return}ft(!0);try{await Ts({originalSessionID:me,directory:i,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),Le(!1)}catch(c){console.error("[review-flow] failed to start review flow",c),Ze.error(c instanceof Error?c.message:o("diffView.reviewDialog.toast.startFailed"))}finally{ft(!1)}},[me,p,o]),Rt=r.useCallback(t=>{const i=Ve.current.get(t),c=Fe.current;if(!i||!c)return!1;const d=i.getBoundingClientRect().top-c.getBoundingClientRect().top;return c.scrollTo({top:c.scrollTop+d,behavior:"auto"}),!0},[]);r.useEffect(()=>{const t=ve.current;if(!a||!t)return;let i=0;const c=20;let d=!1;const h=(E=!0)=>{d||(d=!0,ve.current=null,Me.current=!1,E&&V(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null))},C=()=>{if(d){q.current=null;return}const E=ve.current;if(!E){h(),q.current=null;return}if(!Rt(E)){i+=1,i<c?q.current=window.requestAnimationFrame(C):(h(),q.current=null);return}if(u&&Me.current){V(E),h(!1);return}h()};return q.current=window.requestAnimationFrame(C),()=>{d=!0,q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)}},[u,tt,Rt,a]);const Un=r.useCallback(t=>{},[]),Ne=Z==="tree"&&!Ce,Xn=Y(t=>t.diffFileTreeWidth),Dt=Y(t=>t.setDiffFileTreeWidth),cn=r.useRef(null),[Jn,un]=r.useState(!1),gt=Math.max(Xn,Wt),Et=r.useCallback(t=>{const i=Math.max(Wt,(cn.current?.clientWidth??0)*dr);return Math.min(i,Math.max(Wt,t))},[]),Yn=r.useCallback(t=>{t.preventDefault();const i=t.clientX,c=gt;un(!0);const d=C=>{Dt(Et(c+C.clientX-i))},h=()=>{un(!1),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},[Et,gt,Dt]),Qn=r.useCallback(t=>{const i=t.shiftKey?40:10,c=t.key==="ArrowLeft"?-i:t.key==="ArrowRight"?i:0;c!==0&&(t.preventDefault(),Dt(Et(gt+c)))},[Et,gt,Dt]),_t=r.useMemo(()=>Ne?Cn(T,new Set).flatMap(t=>t.kind==="file"?[t.file]:[]):[],[T,Ne]),xt=Ne?_t:T,ot=Ne?_t.find(t=>t.path===K)??_t[0]??null:null,At=ot?.path??null;r.useEffect(()=>{At&&!B.has(At)&&je(At)},[je,B,At]);const Tt=r.useCallback(t=>{if(Ie(),Ne){G(t),L(!1),je(t),Fe.current?.scrollTo({top:0});return}G(t),L(!1),Me.current=!0,ve.current=t,je(t),Ke(i=>i+1),Rt(t)},[Ie,je,Ne,Rt]);r.useEffect(()=>{const t=i=>{if(!a||!i.altKey||i.metaKey||i.ctrlKey||i.shiftKey||i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const c=i.target;if(c instanceof HTMLElement&&(c.isContentEditable||c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.closest('[role="dialog"]'))||(i.preventDefault(),xt.length===0))return;const d=i.key==="ArrowDown"?1:-1,h=Ne?ot?.path:K,C=h?xt.findIndex(J=>J.path===h):-1,E=C===-1?d>0?0:xt.length-1:C+d,I=xt[E];I&&Tt(I.path)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[K,Tt,Ne,xt,ot,a]);const Zn=r.useCallback(t=>{const i=t==="side-by-side"?"side-by-side":"inline";T.forEach(c=>{Ue(c.path,i)})},[T,Ue]),[es,dn]=r.useState(null),ts=r.useCallback(async(t,i)=>{if(!f||!t)return;dn(t);const c=Te();try{let d=null;if(i?.patch&&!i.isBinary&&!lt(t)?d=gn(i.patch):i&&i.contextMode==="full"&&!i.isBinary&&!lt(t)&&(d=jn(i.original,i.modified)),d===null)try{const J=await v.getGitDiff(f,{path:t,staged:rt,contextLines:3});d=gn(J.diff)}catch{d=null}let h=i;if(d===null||!h){const J=await v.getGitFileDiff(f,{path:t,staged:rt}),yt={original:J.original??"",modified:J.modified??"",isBinary:J.isBinary,submodule:J.submodule};h=yt,rt||ye(f,t,yt,c)}const C=d??(h.isBinary||lt(t)?1:jn(h.original,h.modified)),E=ar(f,t),I=await Hs(j,E,{directory:f});if(!I.ok){Ze.error(qs(I.reason));return}jt(f,E,C,1)}finally{dn(d=>d===t?null:d)}},[rt,f,j,v,jt,ye]),ns=()=>{if(!f)return null;const t=(c,d=!1)=>n.jsx(hr,{visible:a,directory:f,file:c,layout:Pt(c),wrapLines:st,isSelected:!1,isExpanded:d||B.has(c.path),isMounted:d||de.has(c.path)||c.path===ke,onSelect:Un,onExpandedChange:Gn,registerSectionRef:Kn,showOpenInEditorAction:g&&l!=="turn",isOpeningInEditor:es===c.path,onOpenInEditor:(h,C)=>{ts(h,C)},staged:i(c.path),readOnlyActions:l==="branch"||l==="commit"||l==="pr",hunkActionsEnabled:l==="all"||l==="working"||l==="staged",contentRevision:ut,comparisonDiff:l==="branch"||l==="commit"||l==="pr"?Wn.get(c.path)??bn:void 0,onRetryComparisonDiff:()=>Pn(h=>h+1),loadFullComparisonDiff:On,initialDiffData:l==="turn"?M.get(c.path)??null:null},`${Te()}:${f}:${c.path}:${ct.get(c.path)??0}`),i=c=>mt!==null?mt:be&&c===K;return n.jsxs("div",{ref:cn,className:le("flex min-w-0 flex-1 min-h-0 h-full",w?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Ne&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${gt}px`},children:n.jsx(fr,{changedFiles:T,selectedFile:ot?.path??null,onSelectFile:Tt})}),n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("diffView.fileTree.resize"),tabIndex:0,onPointerDown:Yn,onKeyDown:Qn,className:le("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Jn&&"bg-interactive-selection")})]}),St&&!Ne&&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:o("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:T.length})]}),n.jsx(ur,{changedFiles:T,selectedFile:null,onSelectFile:Tt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(Ht,{ref:Fe,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:Ne?ot&&t(ot,!0):T.map(c=>t(c))})})})]})},ss=()=>{if(!f)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o("diffView.state.selectSessionDirectory")});if(l!=="turn"&&ce&&!A)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingRepositoryStatus")]});if(l!=="turn"&&W===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o("diffView.state.notGitRepository")});if(l==="pr"){if(!_e||_.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:_.error??oe.error??(oe.loading?o(Lt("session.githubPrPicker.loading.pullRequests",oe.provider)):o(Lt("pullRequestComparison.select",oe.provider)))}),(_.error||oe.error)&&n.jsx(Se,{variant:"outline",size:"sm",onClick:()=>{_e?_.refresh():oe.refresh()},children:o("diffView.actions.retry")}),!_e&&!oe.loading&&n.jsx(mn,{comparison:oe})]});if(!_.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingDiff")]})}if(l==="commit"){if(tn)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:tn}),n.jsx(Se,{variant:"outline",size:"sm",onClick:()=>{_.refresh()},children:o("diffView.actions.retry")})]});if(!Ye&&!Oe.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Oe.error??o("commitComparison.noCommits")});if(!en)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.state.loadingDiff")]})}if(l==="branch"){if(!Bn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.branch.resolvingBase")]});if(!We)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(O,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:o("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:o("gitView.pr.toast.baseBranchRequired")})]});if(nn)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:o("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:nn}),n.jsx(Se,{variant:"outline",size:"sm",onClick:()=>{_.refresh()},children:o("diffView.actions.retry")})]});if(Ct===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),o("diffView.branch.loadingFiles")]})}return T.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l==="turn"?o("diffView.state.noLastTurnChanges"):l==="pr"?o("walkthrough.blocked.emptyDiff.description"):l==="commit"?o("commitComparison.emptyDiff"):l==="branch"&&We?o("diffView.branch.empty",{base:Ks(We)}):o("diffView.state.cleanWorkingTree")}):ns()};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:[R===!1&&Array.isArray(D)&&D.length>0?n.jsx($s,{repositories:D,selectedRepository:P??null,onSelectRepository:t=>{p&&ue(p,t)},repositoryRoot:p??void 0}):null,!S&&(l!=="all"?n.jsx(cr,{scope:l,workingCount:pt,stagedCount:ze,turnCount:Je,branchCount:$n,commitCount:l==="commit"?en?.length??null:null,prCount:l==="pr"?_.files?.length??null:null,showCommitOption:!Ae(),showBranchOption:Xt,changeRequestProvider:oe.provider,onScopeChange:t=>{re(t),b?.(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:ce&&!A?o("diffView.state.loadingChanges"):T.length===1?o("diffView.summary.changedFilesSingle",{count:T.length}):o("diffView.summary.changedFilesPlural",{count:T.length})})})),l==="branch"&&n.jsx(us,{branches:Qe?.all??[],currentBranch:H,base:ht,onSelect:t=>{f&&H&&Mn(f,H,t)}},JSON.stringify([f,H])),l==="commit"&&n.jsx(ds,{commits:Oe.commits,selectedHash:Ye,loading:Oe.loading,error:Oe.error,onSelect:Oe.select,onRefresh:()=>{Oe.refresh()}},JSON.stringify([f,H])),l==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(mn,{comparison:oe},JSON.stringify([y,f,H])),_e&&n.jsx(Se,{variant:"ghost",size:"sm",disabled:_.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),title:o("session.githubIssuePicker.actions.refresh"),onClick:()=>{_.refresh()},children:n.jsx(O,{name:"refresh",className:"size-4"})})]}),T.length>0&&n.jsxs(Se,{variant:"ghost",size:"sm",onClick:Hn,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:B.size>0?o("diffView.actions.collapseAll"):o("diffView.actions.expandAll"),children:[n.jsx(O,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:B.size>0?o("diffView.actions.collapseAll"):o("diffView.actions.expandAll")})]}),T.length>0&&Nt&&n.jsxs(Se,{variant:"default",size:"sm",onClick:()=>Le(!0),disabled:De,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":o("diffView.actions.reviewAria"),children:[De?n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(O,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:o("diffView.actions.review")})]}),T.length>0&&Xe&&(l!=="pr"||kt)&&n.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>{const t=f??"";ie(t,l==="pr"&&_e&&kt?{source:_e,context:kt}:{source:l==="commit"&&Ye?{kind:"commit",hash:Ye}:l==="branch"&&We&&H?{kind:"branch",baseRef:We,headRef:H}:{kind:"working-tree",scope:l==="staged"||l==="working"?l:"all"}}),$(p??t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",Us),"aria-label":o("walkthrough.action.open"),children:[n.jsx(O,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:o("walkthrough.action.open")})]}),T.length>0&&!Ce&&n.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>vt(Z==="tree"?"flat":"tree"),"aria-pressed":Z==="tree",className:le("h-5 w-5 p-0 transition-opacity",Z==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:o(Z==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:n.jsx(O,{name:"node-tree",className:"size-4"})}),T.length>0&&n.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>wt(!Q),className:le("h-5 w-5 p-0 transition-opacity",st?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:o(st?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(O,{name:"text-wrap",className:"size-4"})}),an&&n.jsx(kn,{mode:an==="side-by-side"?"side-by-side":"unified",onModeChange:Zn})]}),n.jsx(Ls,{open:bt,onOpenChange:Le,projectDirectory:f??null,submitting:De,onConfirm:qn}),ss()]})};function gr(){return new Set}function xr(a,e){return n.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 w-px bg-border/50",style:{left:`${En+e*Dn+7}px`}},e)}function yr(a){return Array.from({length:a},xr)}export{zo as DiffView,hr as MultiFileDiffEntry};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{f as Ee,R as i,j as s,c as Is,r as Ft}from"./vendor-react-BUCujlKS.js";import{bI as uc,a as ut,h as Wn,ap as fo,dA as dc,a0 as fc,a5 as mc,a6 as hc,a7 as pc,a8 as gc,B as at,u as ct,fB as vc,P as Br,H as xc,eA as Da,ae as wc,fy as bc,N as yc,e as Cc,fz as jc,bc as Sc,fA as Nc}from"./index-vQ1Pg1cr.js";import{f as qe,bP as mo,z as Va,aA as ho,cV as Fc,I as P,h as J,lf as Ec,dt as kc,lg as Rc,a8 as Kn,B as U,e1 as Tc,e3 as Mc,dS as Pc,e2 as Dc,e0 as Vc,lh as Ac,li as _r,fe as Lc,cu as Kr,jD as zc,lj as Ic,lk as Oc,b3 as Un,iv as Bc,dd as _c,N as $c,_ as Wc,L as kr,aC as Uc,dk as Hc,t as Z,fA as Aa,km as Kc,i9 as qc,l as La,a_ as Rr,d9 as _n,dU as Gc,b as Xc,ll as $n,cx as Yc,a$ as Tr,lm as Mr,da as za,db as Ia,ln as Oa,lo as Ba,lp as Jc,lq as Zc,lr as Qc,dY as eu,ls as tu,j4 as nu,lt as su,lu as _a,lv as ru,cy as po,cz as go,cA as vo,cB as xo,cC as wo,cD as bo,aT as $r,aU as Wr,aW as Ur,bN as Os,cE as Pr,b4 as Ps,d3 as Dr,av as qt,aw as Gt,ax as Xt,cv as iu,cw as au,g as _s,bO as ou,de as lu,df as cu,dg as uu,dh as du,di as fu,dj as mu}from"./useAppFontEffects-DCqCVGlT.js";import{c as $a,s as hu,P as vn,C as pu}from"./shikiHighlight-CXgZnvHh.js";import{a as yo,E as gu,i as Co,S as jo,R as Hr,l as vu}from"./vendor-codemirror-state-G3UuR-be.js";import{E as dt,k as qr,f as xu,j as wu,m as bu,g as yu,V as Cu,G as ju}from"./vendor-codemirror-view-Bniqp7p5.js";import{v as Su,A as Nu,B as Fu,C as Eu}from"./vendor-codemirror-language-ByBn5zIW.js";import{a as ku,u as Ds,b as Ru,c as Tu,G as Mu}from"./fileTreeStatus-BSHFIGEg.js";import{V as Pu,J as Du,F as Vu}from"./JsonTreeView-B_EPRjzy.js";import{ensurePierreThemeRegistered as Wa,getResolvedShikiTheme as Au}from"./appThemeRegistry-CxzMxR-H.js";import{V as Lu,W as zu}from"./Virtualizer-CGNyscoc.js";import{E as Iu,bc as Ou,bd as Bu,bb as _u}from"./runtimeEndpointReset-DqLJC6L1.js";import{V as $u}from"./Virtualizer-xCEYz34p.js";import{D as Wu}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as Uu,h as Hu}from"./vendor-codemirror-search-ib-sHD5W.js";import{a as Ku,b as qu}from"./vendor-codemirror-autocomplete-DW1FQz9_.js";import{p as Gu}from"./parseDiffFromFile-Cy0PNxun.js";import{o as Xu,s as Yu}from"./vendor-zod-CxRSdNoV.js";import{I as Ju,u as Zu,n as Qu}from"./useInlineCommentController-CrjSGCpi.js";import{b as ed}from"./CodeMirrorCommentWidgets-CVDSjcrP.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DHzhmLwV.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DX96QhTP.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-H_JmXOFV.js";import"./vendor-tanstack-virtual-core-Dxc8hSTB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.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-lezer-highlight-CDMHUZ74.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-lang-javascript-CpGYXGuo.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-style-mod-NZ5MEPvj.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-58T70Hqs.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B07blnnZ.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DaH9adfE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BLKnlLP4.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q2bKO1EM.js";import"./vendor-codemirror-lang-python-B7ClrMIT.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DpmhalwN.js";import"./vendor-legendapp-list-DViGR95I.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-DkzqxN2H.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-CmPe29DM.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-CYBUzW4I.js";import"./textMateThemeFromAppTheme-CDlKffWz.js";import"./space-apply-1trGVIl8.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-diff-C3JhlQdm.js";function Ua(r){const e=Ee.c(63),{containerRef:t,filePath:a,fileContent:m}=r,{t:f}=qe(),{isMobile:p}=mo(),h=Va(cd),v=Va(ld),y=ho(),u=Fc(od),[x,S]=i.useState(null),[C,R]=i.useState(""),[b,F]=i.useState(!1),[j,l]=i.useState(""),M=i.useRef(!1),T=i.useRef(null),V=i.useRef(null),[z,k]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{S(null),R(""),F(!1),M.current=!1,V.current=null,k(null)},e[0]=D):D=e[0];const O=D;let E,A;e[1]!==t?(E=()=>{const _=t.current;if(!_)return;const q=()=>{if(M.current)return;const ce=window.getSelection(),he=ce?.toString().trim()??"";if(!ce||!he||ce.rangeCount===0){O();return}const le=ce.getRangeAt(0);if(!_.contains(le.commonAncestorContainer)){O();return}const xe=le.getBoundingClientRect();V.current=le.cloneRange(),R(he),S({x:xe.left+xe.width/2,y:xe.top-10})},Q=ce=>{T.current?.contains(ce.target)||M.current&&O()};return document.addEventListener("selectionchange",q),document.addEventListener("pointerdown",Q),()=>{document.removeEventListener("selectionchange",q),document.removeEventListener("pointerdown",Q)}},A=[t,O],e[1]=t,e[2]=E,e[3]=A):(E=e[2],A=e[3]),i.useEffect(E,A);let I;e[4]!==m?(I=_=>{const q=Je=>m.slice(0,Je).split(`
|
|
2
|
-
`).length,Q=id,ce=(Je,ee)=>{for(const Ze of Q(Je)){const Qe=m.indexOf(Ze,ee);if(Qe>=0)return Qe}return-1},he=_.length>=8?m.indexOf(_):-1;if(he>=0){const Je=q(he);return{start:Je,end:Je+_.split(`
|
|
3
|
-
`).length-1}}const le=_.split(`
|
|
4
|
-
`).map(rd).filter(Boolean);if(le.length===0)return null;const xe=ce(le[0],0);if(xe<0)return null;const Se=q(xe);if(le.length===1)return{start:Se,end:Se};const ge=ce(le[le.length-1],xe);return ge<0?null:{start:Se,end:Math.max(Se,q(ge))}},e[4]=m,e[5]=I):I=e[5];const H=I;let B;e[6]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{const _=V.current;if(!_){k(null);return}k(Ec(_))},e[6]=B):B=e[6];const K=B;let se,ie;e[7]!==b?(se=()=>{if(!b)return;let _=null;const q=()=>{_===null&&(_=window.requestAnimationFrame(()=>{_=null,K()}))};return document.addEventListener("scroll",q,{capture:!0,passive:!0}),window.addEventListener("resize",q),()=>{_!==null&&window.cancelAnimationFrame(_),document.removeEventListener("scroll",q,{capture:!0}),window.removeEventListener("resize",q)}},ie=[b,K],e[7]=b,e[8]=se,e[9]=ie):(se=e[8],ie=e[9]),i.useEffect(se,ie);let me;e[10]!==C?(me=_=>{C&&(l(_),F(!0),M.current=!0,K(),window.getSelection()?.removeAllRanges())},e[10]=C,e[11]=me):me=e[11];const Y=me;let ue,$;e[12]!==x||e[13]!==b||e[14]!==p||e[15]!==Y?($=()=>{if(!x||b||p)return;const _=q=>{const Q=Rc(q);Q&&(q.preventDefault(),Y(Q))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},ue=[x,b,p,Y],e[12]=x,e[13]=b,e[14]=p,e[15]=Y,e[16]=ue,e[17]=$):(ue=e[16],$=e[17]),i.useEffect($,ue);let te;e[18]!==u||e[19]!==h||e[20]!==y||e[21]!==a||e[22]!==v||e[23]!==H||e[24]!==C?(te=_=>{const q=h??(v?"draft":null);if(!C||!q||!y){O();return}const Q=H(C);u({directory:y,sessionKey:q},{source:"file-quote",fileLabel:a,startLine:Q?.start??0,endLine:Q?.end??0,code:C,language:"",text:_.trim()}),O(),queueMicrotask(sd)},e[18]=u,e[19]=h,e[20]=y,e[21]=a,e[22]=v,e[23]=H,e[24]=C,e[25]=te):te=e[25];const ke=te;if(!x)return null;let Ge;e[26]!==b||e[27]!==H||e[28]!==C?(Ge=b?H(C):null,e[26]=b,e[27]=H,e[28]=C,e[29]=Ge):Ge=e[29];const Re=Ge;let Xe;e[30]!==b||e[31]!==z?(Xe=b&&z&&z.length>0?s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:z.map(nd)}):null,e[30]=b,e[31]=z,e[32]=Xe):Xe=e[32];const ye=Xe;let Ye;e[33]!==Re?(Ye=Re?{start:Re.start,end:Re.end}:void 0,e[33]=Re,e[34]=Ye):Ye=e[34];let re;e[35]!==a||e[36]!==j||e[37]!==ke||e[38]!==Ye?(re=s.jsx(Ju,{initialText:j,fileLabel:a,lineRange:Ye,onSave:ke,onCancel:O}),e[35]=a,e[36]=j,e[37]=ke,e[38]=Ye,e[39]=re):re=e[39];const Ce=re;if(p){let _;e[40]===Symbol.for("react.memo_cache_sentinel")?(_={paddingBottom:"calc(0.5rem + env(safe-area-inset-bottom, 0px))"},e[40]=_):_=e[40];let q;e[41]!==Ce||e[42]!==b||e[43]!==Y||e[44]!==f?(q=s.jsx("div",{ref:T,className:"pointer-events-auto mx-auto max-w-[420px] px-3",style:_,children:b?Ce:s.jsx("div",{className:J("mx-auto w-fit","oc-glass-popover rounded-full border border-[var(--interactive-border)]","p-1 shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]"),children:s.jsxs("button",{type:"button",onMouseDown:td,onClick:()=>Y(""),className:J("flex min-w-0 items-center gap-2 rounded-full px-4 py-2","text-sm font-medium leading-tight text-foreground","active:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:[s.jsx(P,{name:"chat-1",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 whitespace-nowrap",children:f("chat.textSelection.actions.comment")})]})})}),e[41]=Ce,e[42]=b,e[43]=Y,e[44]=f,e[45]=q):q=e[45];let Q;return e[46]!==ye||e[47]!==q?(Q=Is.createPortal(s.jsxs("div",{className:"oc-keyboard-inset-surface pointer-events-none fixed inset-x-0 bottom-0 z-50",children:[ye,q]}),document.body),e[46]=ye,e[47]=q,e[48]=Q):Q=e[48],Q}let Te;e[49]!==x.x||e[50]!==x.y?(Te={left:x.x,top:x.y,transform:"translate(-50%, -100%)"},e[49]=x.x,e[50]=x.y,e[51]=Te):Te=e[51];let je;e[52]!==ye?(je=ye?Is.createPortal(ye,document.body):null,e[52]=ye,e[53]=je):je=e[53];let de;e[54]!==Ce||e[55]!==b||e[56]!==Y||e[57]!==f?(de=b?s.jsx("div",{className:"w-[min(420px,80vw)]",children:Ce}):s.jsx("div",{className:J("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:s.jsx("button",{type:"button",onClick:()=>Y(""),className:J("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:f("chat.textSelection.actions.comment")})}),e[54]=Ce,e[55]=b,e[56]=Y,e[57]=f,e[58]=de):de=e[58];let Me;return e[59]!==Te||e[60]!==je||e[61]!==de?(Me=Is.createPortal(s.jsxs("div",{ref:T,className:"fixed z-50",style:Te,children:[je,de]}),document.body),e[59]=Te,e[60]=je,e[61]=de,e[62]=Me):Me=e[62],Me}function td(r){return r.preventDefault()}function nd(r,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:r.left,top:r.top,width:r.width,height:r.height}},e)}function sd(){kc()}function rd(r){return r.trim()}function id(r){const e=r.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(ad)}function ad(r){return r.length>=8}function od(r){return r.addDraft}function ld(r){return r.newSessionDraft?.open}function cd(r){return r.currentSessionId}const ud=(r,e)=>{if(!e)return null;const t=Number.parseInt(r.trim(),10);return!Number.isFinite(t)||t<1?null:Math.min(t,e.state.doc.lines)},Ha=(r,e)=>{const t=r.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},Ka=(r,e,t)=>{const a=r.state.doc.line(e),m=Math.max(1,Math.min(t,a.length+1)),f=a.from+m-1;r.dispatch({selection:yo.cursor(f),effects:dt.scrollIntoView(f,{y:"center"})})};function dd({open:r,onOpenChange:e,view:t,variant:a="overlay"}){const{t:m}=qe(),[f,p]=i.useState(""),h=i.useRef(null),v=i.useRef(!1),y=i.useRef(null),u=i.useRef(null),x=i.useMemo(()=>ud(f,t),[f,t]);i.useEffect(()=>{!r||!t||(v.current=!1,h.current=Ha(t,t.state.selection),p(""))},[r,t]),i.useEffect(()=>{r&&window.requestAnimationFrame(()=>{u.current?.focus(),u.current?.select()})},[r]),i.useEffect(()=>{if(!(!r||!t||!h.current)){if(x===null){const{selection:j}=h.current;t.dispatch({selection:j,effects:dt.scrollIntoView(j.main.from,{y:"center"})});return}Ka(t,x,h.current.character)}},[x,r,t]);const S=i.useCallback(()=>{if(!t||v.current||!h.current)return;const{selection:j}=h.current;t.dispatch({selection:j,effects:dt.scrollIntoView(j.main.from,{y:"center"})})},[t]),C=i.useRef(r);i.useEffect(()=>{C.current&&!r&&S(),C.current=r},[r,S]);const R=i.useCallback(j=>{j||S(),e(j)},[e,S]),b=i.useCallback(()=>{!t||x===null||!h.current||(v.current=!0,Ka(t,x,h.current.character),e(!1),t.focus())},[x,e,t]);i.useEffect(()=>{if(!r)return;const j=M=>{const T=y.current,V=M.target;!T||!(V instanceof Element)||T.contains(V)||V.closest("[data-go-to-line-toggle]")||R(!1)},l=M=>{M.key==="Escape"&&(M.preventDefault(),R(!1))};return document.addEventListener("pointerdown",j,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",j,!0),document.removeEventListener("keydown",l,!0)}},[R,r,a]);const F=i.useMemo(()=>{if(!t)return m("goToLineDialog.helper.editorUnavailable");if(x===null){const j=h.current??Ha(t,t.state.selection);return m("goToLineDialog.helper.currentLineRange",{current:j.lineNumber,max:t.state.doc.lines})}return m("goToLineDialog.helper.goToLine",{line:x})},[x,m,t]);return a==="inline"?r?s.jsxs("div",{ref:y,"data-editor-overlay":!0,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Kn,{ref:u,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:j=>p(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b())},placeholder:m("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(U,{variant:"outline",size:"xs",onClick:b,disabled:!t||x===null,className:"h-6 px-2",children:m("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:y,"data-editor-overlay":!0,className:J("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",r?"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(Kn,{ref:u,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:j=>p(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b())},placeholder:m("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/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:F})]})})}const fd=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),md=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),hd=new Set(["ArrowFunction","FunctionExpression"]),pd=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),So=/^(?:ATXHeading|SetextHeading)([1-6])$/,No=(r,e)=>{for(let t=r.firstChild;t;t=t.nextSibling)if(e.has(t.name))return t;return null},gd=r=>{if(So.test(r.name))return"heading";const e=fd.get(r.name);if(e)return e;const t=md.get(r.name);return t&&No(r,hd)?t:null},vd=(r,e)=>r.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),xd=(r,e=200)=>{const t=Su(r,r.doc.length,e);if(!t)return[];const a=[],m=[];return t.iterate({enter:f=>{const p=gd(f.node);if(!p)return;let h,v;if(p==="heading")h=vd(r,f.node),v=f.from;else{const u=No(f.node,pd);if(!u)return;h=r.sliceDoc(u.from,u.to),v=u.from}if(!h)return;for(;m.length>0&&m[m.length-1]<=f.from;)m.pop();const y=p==="heading"?Number(So.exec(f.name)?.[1]??1)-1:m.length;a.push({name:h,kind:p,line:r.doc.lineAt(v).number,from:v,depth:y}),p!=="heading"&&m.push(f.to)}}),a},wd={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},bd="data-document-symbols-toggle";function qa(r){const e=Ee.c(44),{open:t,onOpenChange:a,view:m}=r,{t:f}=qe(),p=i.useRef(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[0]=h):h=e[0];const[v,y]=i.useState(h),[u,x]=i.useState("");let S,C;e[1]!==t||e[2]!==m?(S=()=>{t&&(x(""),y(m?xd(m.state):[]))},C=[t,m],e[1]=t,e[2]=m,e[3]=S,e[4]=C):(S=e[3],C=e[4]),i.useEffect(S,C);let R;e[5]!==a||e[6]!==m?(R=()=>{a(!1),m?.focus()},e[5]=a,e[6]=m,e[7]=R):R=e[7];const b=R;let F,j;e[8]!==a||e[9]!==t?(F=()=>{if(!t)return;const B=K=>{const se=K.target;!(se instanceof Element)||!p.current||p.current.contains(se)||se.closest(`[${bd}]`)||a(!1)};return document.addEventListener("pointerdown",B,!0),()=>document.removeEventListener("pointerdown",B,!0)},j=[a,t],e[8]=a,e[9]=t,e[10]=F,e[11]=j):(F=e[10],j=e[11]),i.useEffect(F,j);let l;e[12]!==b||e[13]!==m?(l=B=>{m&&m.dispatch({selection:yo.cursor(B.from),effects:dt.scrollIntoView(B.from,{y:"center"})}),b()},e[12]=b,e[13]=m,e[14]=l):l=e[14];const M=l;if(!t)return null;let T;e[15]!==b?(T=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),b())},e[15]=b,e[16]=T):T=e[16];let V;e[17]!==f?(V=f("filesView.symbols.placeholder"),e[17]=f,e[18]=V):V=e[18];let z;e[19]!==f?(z=f("filesView.symbols.placeholder"),e[19]=f,e[20]=z):z=e[20];let k;e[21]!==u||e[22]!==z||e[23]!==V?(k=s.jsx(Tc,{autoFocus:!0,value:u,onValueChange:x,placeholder:V,"aria-label":z}),e[21]=u,e[22]=z,e[23]=V,e[24]=k):k=e[24];let D;e[25]!==v.length||e[26]!==f?(D=v.length===0?f("filesView.symbols.noneInFile"):f("filesView.symbols.noMatches"),e[25]=v.length,e[26]=f,e[27]=D):D=e[27];let O;e[28]!==D?(O=s.jsx(Mc,{className:"px-3 py-4 typography-meta text-muted-foreground",children:D}),e[28]=D,e[29]=O):O=e[29];let E;if(e[30]!==M||e[31]!==v){let B;e[33]!==M?(B=K=>s.jsxs(Pc,{value:`${K.name}\0${K.from}`,onSelect:()=>M(K),className:"gap-2",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingLeft:`${K.depth*12}px`},children:[s.jsx(P,{name:wd[K.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-foreground",children:K.name})]}),s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:K.line})]},`${K.from}:${K.name}`),e[33]=M,e[34]=B):B=e[34],E=v.map(B),e[30]=M,e[31]=v,e[32]=E}else E=e[32];let A;e[35]!==O||e[36]!==E?(A=s.jsxs(Dc,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[O,E]}),e[35]=O,e[36]=E,e[37]=A):A=e[37];let I;e[38]!==k||e[39]!==A?(I=s.jsxs(Vc,{loop:!0,filter:yd,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[k,A]}),e[38]=k,e[39]=A,e[40]=I):I=e[40];let H;return e[41]!==I||e[42]!==T?(H=s.jsx("div",{ref:p,"data-editor-overlay":!0,className:"absolute left-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:T,children:I}),e[41]=I,e[42]=T,e[43]=H):H=e[43],H}function yd(r,e){return r.split("\0")[0].toLowerCase().includes(e.trim().toLowerCase())?1:0}const Cd=(r,e)=>{const t=e.trim().toLowerCase(),a=[];if(!t)return a;const m=r.toLowerCase();let f=0;for(;;){const p=m.indexOf(t,f);if(p===-1)break;a.push({start:p,end:p+t.length}),f=p+t.length}return a},Ws="data-md-find",Vr="data-md-find-current",Fo="rounded-[2px] bg-status-warning/30 text-foreground",jd="rounded-[2px] bg-status-warning/60 text-foreground",Sd=120,Nd=r=>r instanceof Element&&r.hasAttribute(Ws),Fd=r=>r.target instanceof Element&&r.target.hasAttribute(Ws)?!0:[...r.addedNodes].some(e=>Nd(e)),Eo=r=>{const e=new Set;r.querySelectorAll(`mark[${Ws}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},Ed=(r,e)=>{Eo(r);const t=e.trim().toLowerCase();if(!t)return[];const a=[],m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(p){const h=p.parentElement;return!h||h.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),f=[];for(;m.nextNode();){const p=m.currentNode;p instanceof Text&&f.push(p)}for(const p of f){const h=p.nodeValue??"";if(!h)continue;const v=Cd(h,t);if(v.length===0)continue;const y=p.parentNode;if(!y)continue;const u=document.createDocumentFragment();let x=0;for(const S of v){S.start>x&&u.appendChild(document.createTextNode(h.slice(x,S.start)));const C=document.createElement("mark");C.setAttribute(Ws,""),C.className=Fo,C.textContent=h.slice(S.start,S.end),u.appendChild(C),a.push(C),x=S.end}x<h.length&&u.appendChild(document.createTextNode(h.slice(x))),y.replaceChild(u,p)}return a},Ga=({containerRef:r,open:e,onOpenChange:t,focusNonce:a,className:m})=>{const{t:f}=qe(),[p,h]=i.useState(""),[v,y]=i.useState(0),[u,x]=i.useState(0),S=i.useRef(null),C=i.useRef([]),R=i.useRef(p);R.current=p;const b=i.useRef(null),F=i.useRef(null),j=i.useCallback((k,D=!1)=>{const O=r.current;if(!O){C.current=[],y(0),x(0);return}C.current=Ed(O,k);const E=C.current.length;y(E),x(A=>!D||E===0?0:Math.min(A,E-1))},[r]),l=i.useCallback((k,D=!1)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,j(k,D)},Sd)},[j]);i.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const M=i.useCallback(()=>{t(!1);const k=F.current;F.current=null,k?.isConnected&&k.focus()},[t]);i.useEffect(()=>{const k=r.current;if(!e||!k)return;const D=new MutationObserver(O=>{!R.current.trim()||!O.some(A=>!Fd(A))||l(R.current,!0)});return D.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{D.disconnect(),Eo(k)}},[r,e,l]),i.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!F.current&&(F.current=k),S.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(S.current?.focus(),S.current?.select())},[e,a]),i.useEffect(()=>{const k=r.current;if(!k||(k.querySelectorAll(`mark[${Vr}]`).forEach(O=>{O.removeAttribute(Vr),O.className=Fo}),v===0))return;const D=C.current[Math.min(Math.max(u,0),v-1)];D&&(D.setAttribute(Vr,""),D.className=jd,D.scrollIntoView({block:"nearest"}))},[r,u,v]);const T=i.useCallback(()=>{x(k=>v===0?0:(k+1)%v)},[v]),V=i.useCallback(()=>{x(k=>v===0?0:(k-1+v)%v)},[v]),z=i.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?V():T()):k.key==="Escape"&&(k.preventDefault(),M())},[M,T,V]);return e?s.jsxs("div",{className:J("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",m),children:[s.jsx(P,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),s.jsx(Kn,{ref:S,value:p,onChange:k=>{h(k.target.value),l(k.target.value)},onKeyDown:z,placeholder:f("filesView.preview.find.placeholder"),"aria-label":f("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),s.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":v>0?f("filesView.preview.find.countAria",{current:u+1,total:v}):f("filesView.preview.find.noMatches"),children:p.trim()&&v===0?f("filesView.preview.find.noMatches"):v>0?`${u+1}/${v}`:""}),s.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:v===0,children:s.jsx(P,{name:"arrow-up",className:"size-3.5"})}),s.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:f("filesView.preview.find.nextAria"),"aria-label":f("filesView.preview.find.nextAria"),disabled:v===0,children:s.jsx(P,{name:"arrow-down",className:"size-3.5"})}),s.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:f("filesView.preview.find.closeAria"),"aria-label":f("filesView.preview.find.closeAria"),children:s.jsx(P,{name:"close",className:"size-3.5"})})]}):null},kd=r=>{let e=!0;return{poll:async()=>{if(!e||r.isDirty())return!1;const t=r.getLoadedContent(),a=r.getLoadedRevision();try{const m=await r.readContent();if(!e||r.isDirty()||a!==r.getLoadedRevision())return!1;if(m===t)return!0;const f=await r.readContent();return!e||r.isDirty()||f!==m||a!==r.getLoadedRevision()?!1:(r.applyContent(m),!0)}catch{return!1}},dispose:()=>{e=!1}}},Rd=1,Td=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=Rd;function Xa(){const r=Ee.c(8),[e]=Ft.useState(Md),t=Ft.useRef(!1);let a;r[0]!==e?(a=v=>{if(v==null){e.cleanUp(),t.current=!1;return}t.current||(t.current=!0,e.setup(v,v.firstElementChild??void 0))},r[0]=e,r[1]=a):a=r[1];const m=a;let f,p;r[2]!==e?(f=()=>()=>{t.current=!1,e.cleanUp()},p=[e],r[2]=e,r[3]=f,r[4]=p):(f=r[3],p=r[4]),Ft.useLayoutEffect(f,p);let h;return r[5]!==m||r[6]!==e?(h={virtualizer:e,setScroller:m},r[5]=m,r[6]=e,r[7]=h):h=r[7],h}function Md(){return new $u}const xn=new Map,Pd=100;function Vs(r){const[e,t]=Ft.useState(null),a=Ft.useRef(null),m=Ft.useRef(null),f=Ft.useRef(null),p=Ft.useCallback((h,v)=>{h&&v instanceof Pu&&(f.current={key:r,file:v,node:h});const y=a.current,u=m.current,x=()=>{a.current===y&&(y?.(),u?.())};v?queueMicrotask(x):x()},[r]);return Ft.useLayoutEffect(()=>{if(!e||!r)return;const h=xn.get(r)??{top:0,left:0};let v=!0;const y=()=>f.current?.key===r?f.current.file:null,u=j=>f.current?.key===r?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${j-1}"]`):null,x=()=>{C.disconnect(),R.disconnect()},S=()=>{if(!v)return;const j=y(),l=h.line&&j?.getLinePosition(h.line.number),M=h.line&&u(h.line.number);let T=h.top;h.line&&l&&(T=(j?.top??0)+l.top-h.line.offset),h.line&&M&&(T=e.scrollTop+M.getBoundingClientRect().top-e.getBoundingClientRect().top-h.line.offset),e.scrollTop=T,e.scrollLeft=h.left,(!h.line||M)&&Math.abs(e.scrollTop-T)<1&&Math.abs(e.scrollLeft-h.left)<1&&(v=!1,x())},C=new ResizeObserver(S),R=new MutationObserver(()=>{if(v){for(const j of e.children)C.observe(j);S()}});C.observe(e);for(const j of e.children)C.observe(j);R.observe(e,{childList:!0,subtree:!0});const b=()=>{if(v)return;const j=y(),l=j?.getNumericScrollAnchor(e.scrollTop-(j.top??0)),M=l&&u(l.lineNumber),T=M?M.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(xn.delete(r),xn.set(r,{top:e.scrollTop,left:e.scrollLeft,line:l&&T!==null&&T>=0&&T<e.clientHeight?{number:l.lineNumber,offset:T}:void 0}),xn.size>Pd){const V=xn.keys().next().value;V!==void 0&&xn.delete(V)}},F=()=>{v=!1,x()};return a.current=S,m.current=b,S(),e.addEventListener("scroll",b,{passive:!0}),e.addEventListener("wheel",F,{passive:!0}),e.addEventListener("touchstart",F,{passive:!0}),e.addEventListener("pointerdown",F,{passive:!0}),e.addEventListener("keydown",F),()=>{a.current=null,m.current=null,f.current?.key===r&&(f.current=null),x(),e.removeEventListener("scroll",b),e.removeEventListener("wheel",F),e.removeEventListener("touchstart",F),e.removeEventListener("pointerdown",F),e.removeEventListener("keydown",F)}},[r,e]),{setScroller:t,restore:p}}function Dd(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||r.wouldEmptyFile||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function Vd(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const ko=2e5,Ad=r=>{let e=0,t=0;for(let a=0;a<r.length;a++)r.charCodeAt(a)===10&&(a>0&&r.charCodeAt(a-1)===13?e++:t++);return e>t?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`},Ro=r=>r.replace(/\r\n/g,`
|
|
7
|
-
`).replace(/\r/g,`
|
|
8
|
-
`),Ld=r=>({content:Ro(r),lineEnding:Ad(r)}),zd=(r,e)=>{const t=Ro(r);return e===`\r
|
|
9
|
-
`?t.replace(/\n/g,`\r
|
|
10
|
-
`):t},Id=(r,e)=>e??(r.length>ko?"view":"edit"),Od=r=>{let e=2166136261;for(let t=0;t<r.length;t++)e^=r.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${r.length}:${e.toString(16)}`},Bd='<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 Ya(){if(typeof document>"u")return!1;const r=document.documentElement.getAttribute("data-theme");return r==="dark"||!r&&window.matchMedia("(prefers-color-scheme: dark)").matches}const _d=i.forwardRef(function({xml:e,readOnly:t,className:a,onChange:m},f){const p=i.useRef(e),h=i.useRef(null),v=i.useRef(!1),[y,u]=i.useState(Ya),x=i.useRef(e),S=i.useRef(e);S.current!==e&&(S.current=e,x.current=e,p.current=e);const C=i.useRef(y);C.current!==y&&(C.current=y,x.current=p.current);const R=i.useRef(null);i.useEffect(()=>{const j=()=>u(Ya());j();const l=new MutationObserver(j);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>l.disconnect()},[]),i.useEffect(()=>{const j=setTimeout(()=>{R.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(j)},[]),i.useImperativeHandle(f,()=>({getXml:()=>p.current}));const b=i.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{h.current?.template({})},500))},[e]),F=i.useCallback(j=>{p.current=j.xml,m?.(j.xml)},[m]);return s.jsx("div",{ref:R,className:J("h-full w-full",a),children:s.jsx(Wu,{ref:h,xml:x.current||Bd,autosave:!0,urlParameters:{ui:t?"simple":y?"dark":"kennedy",spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:F},y?"dark":"light")})}),Ar={ok:!0,snapshot:null},$d=r=>r.hasCanvas&&r.viewMode==="preview"&&r.previewReady&&r.mountable,Ja=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1)||r,Wd=i.forwardRef(function(e,t){const{guestId:a,editorId:m,title:f,contentKind:p,path:h,content:v,readOnly:y}=e,{t:u}=qe(),x=i.useRef(e);x.current=e;const S=i.useCallback(j=>Ac(j,{onChange:l=>{l.edited&&x.current.onEdit(),x.current.onDirtyChange(l.dirty)},onSave:()=>x.current.onSaveRequest(),onUnsupported:()=>x.current.onUnsupported()}),[]),[C,R]=i.useState(()=>p==="text"?S({path:h,name:Ja(h),readOnly:y,encoding:"text",content:v}):null),[b]=i.useState(()=>({contentKind:p,path:h,readOnly:y}));i.useEffect(()=>{if(b.contentKind!=="binary")return;let j=!1;return x.current.loadBytes().then(l=>{if(!j){if(l.byteLength>_r){x.current.onTooLarge();return}R(S({path:b.path,name:Ja(b.path),readOnly:b.readOnly,encoding:"binary",bytes:l}))}},()=>{j||x.current.onLoadFailed()}),()=>{j=!0}},[b,S]),i.useImperativeHandle(t,()=>({getContent:async j=>{const l={ok:!1,message:u("filesView.fileEditor.snapshotFailed",{editor:f})};if(!C)return l;try{const M=await C.requestSnapshot(j);return"bytes"in M?p==="binary"?{ok:!0,snapshot:{bytes:M.bytes,signature:M.version}}:l:p==="text"?{ok:!0,snapshot:{content:M.content,signature:M.version}}:l}catch{return l}},markSaved:j=>{C?.markSaved(j),x.current.onDirtyChange(!1)}}),[C,p,u,f]);const F=i.useMemo(()=>C?{editorId:m,channel:C}:null,[C,m]);return F?s.jsx(Lc,{mode:uc(a),surface:"file",fileEditor:F}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:u("common.loading")})}),Ud=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1),To=(r,e)=>{const t=Ud(e);if(!t)return null;for(const a of r)if(!(!a.fileEditors?.length||!zc(a))){for(const m of a.fileEditors)if(m.match.some(f=>Ic(t,f)))return{guestId:a.id,editor:m}}return null},Hd=r=>{const e=Ee.c(3),t=Kr(Kd);let a;return e[0]!==r||e[1]!==t?(a=r?To(t,r):null,e[0]=r,e[1]=t,e[2]=a):a=e[2],a};function Kd(r){return r.guests}const qd=Fu.filter(r=>r.mac!==void 0),Gd=r=>{const e=document.createElement("span");e.className="cm-fold-marker";const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true");const a=document.createElementNS("http://www.w3.org/2000/svg","use");return a.setAttribute("href",r?"#oc-arrow-down-s":"#oc-arrow-right-s"),t.appendChild(a),e.appendChild(t),e},Xd=()=>[Nu({markerDOM:Gd}),qr.of(qd),dt.theme({".cm-foldGutter .cm-gutterElement":{display:"flex",alignItems:"center",justifyContent:"center"},".cm-fold-marker":{display:"inline-flex",width:"14px",height:"14px",cursor:"pointer",opacity:"0.6"},".cm-fold-marker:hover":{opacity:"1"},".cm-fold-marker svg":{width:"14px",height:"14px",fill:"currentColor"}})],Yd=()=>[Eu(),Ku(),qr.of(qu)],Jd=({vimMode:r})=>[gu.allowMultipleSelections.of(!0),xu(),wu(),bu(),r?[]:qr.of([{key:"Mod-d",run:Uu,preventDefault:!0}])],Zd=300,Qd=1e6,ef=(r,e)=>{const t=new Map;if(r===e)return t;const a=Gu({name:"file",contents:r},{name:"file",contents:e});for(const m of a.hunks)for(const f of m.hunkContent){if(f.type!=="change")continue;if(f.additions===0){const h=f.additionLineIndex<=0,v=h?1:f.additionLineIndex;t.has(v)||t.set(v,h?"deletedAbove":"deleted");continue}const p=f.deletions===0?"added":"modified";for(let h=0;h<f.additions;h+=1)t.set(f.additionLineIndex+h+1,p)}return t};class As extends ju{constructor(e){super(),this.kind=e}eq(e){return e.kind===this.kind}toDOM(){const e=document.createElement("div");return e.className=`cm-git-change cm-git-change-${this.kind}`,e}}const tf={added:new As("added"),modified:new As("modified"),deleted:new As("deleted"),deletedAbove:new As("deletedAbove")},nf=(r,e)=>{const t=new vu;for(const a of[...e.keys()].sort((m,f)=>m-f)){if(a<1||a>r.lines)continue;const m=e.get(a);m&&t.add(r.line(a).from,r.line(a).from,tf[m])}return t.finish()},Us=jo.define(),Mo=jo.define(),Gr=Co.define({create:()=>null,update(r,e){for(const t of e.effects)if(t.is(Us))return t.value;return r}}),Za=Co.define({create:()=>Hr.empty,update(r,e){for(const t of e.effects){if(t.is(Mo))return t.value;if(t.is(Us)&&t.value===null)return Hr.empty}return e.docChanged?r.map(e.changes):r}}),sf=Cu.fromClass(class{constructor(r){this.view=r}timer=null;update(r){r.transactions.some(t=>t.effects.some(a=>a.is(Us)))?this.schedule(0):r.docChanged&&this.schedule(Zd)}schedule(r){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null;const{state:e}=this.view,t=e.field(Gr),a=e.doc.toString(),m=t!==null&&Math.max(t.length,a.length)>Qd,f=t===null||m?Hr.empty:nf(e.doc,ef(t,a));this.view.dispatch({effects:Mo.of(f)})},r)}destroy(){this.timer&&clearTimeout(this.timer)}}),rf=r=>[Gr,Za,sf,yu({class:"cm-git-gutter",markers:e=>e.state.field(Za)}),dt.theme({".cm-git-gutter":{width:"6px"},".cm-git-gutter .cm-gutterElement":{position:"relative"},".cm-git-change":{position:"absolute",left:"1px",width:"3px",top:"0",bottom:"0"},".cm-git-change-added":{backgroundColor:r.added},".cm-git-change-modified":{backgroundColor:r.modified},".cm-git-change-deleted, .cm-git-change-deletedAbove":{top:"auto",height:"6px",width:"5px",left:"0",backgroundColor:r.removed,clipPath:"polygon(0 0, 100% 50%, 0 100%)"},".cm-git-change-deleted":{bottom:"-3px"},".cm-git-change-deletedAbove":{top:"-3px",bottom:"auto"}})],af=(r,e)=>{r.state.field(Gr,!1)!==void 0&&r.dispatch({effects:Us.of(e)})},qn=r=>{const e=Ee.c(18),{items:t,actions:a,className:m}=r;let f,p,h,v;if(e[0]!==a||e[1]!==m||e[2]!==t){v=Symbol.for("react.early_return_sentinel");e:{const S=t.filter(of);if(S.length===0&&!a){v=null;break e}e[7]!==m?(h=J("flex min-h-7 items-center gap-2 border-b border-border/40 bg-[var(--surface-subtle)] px-3 py-1",m),e[7]=m,e[8]=h):h=e[8],f="min-w-0 flex-1 truncate typography-meta text-muted-foreground",p=S.join(" · ")}e[0]=a,e[1]=m,e[2]=t,e[3]=f,e[4]=p,e[5]=h,e[6]=v}else f=e[3],p=e[4],h=e[5],v=e[6];if(v!==Symbol.for("react.early_return_sentinel"))return v;let y;e[9]!==f||e[10]!==p?(y=s.jsx("div",{className:f,children:p}),e[9]=f,e[10]=p,e[11]=y):y=e[11];let u;e[12]!==a?(u=a?s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a}):null,e[12]=a,e[13]=u):u=e[13];let x;return e[14]!==h||e[15]!==y||e[16]!==u?(x=s.jsxs("div",{className:h,children:[y,u]}),e[14]=h,e[15]=y,e[16]=u,e[17]=x):x=e[17],x};function of(r){return r.length>0}const Gn=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";if(r<1024)return`${r} B`;const e=["KB","MB","GB"];let t=r/1024;for(const a of e){if(t<1024||a===e[e.length-1])return`${t.toFixed(t>=10?0:1)} ${a}`;t/=1024}return""},lf=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";const e=Math.round(r),t=Math.floor(e/3600),a=Math.floor(e%3600/60),m=e%60,f=p=>String(p).padStart(2,"0");return t>0?`${t}:${f(a)}:${f(m)}`:`${a}:${f(m)}`},Po=r=>r&&r.width>0&&r.height>0?`${r.width} × ${r.height}`:"",cf=r=>{const e=Ee.c(28),{name:t,path:a,sizeBytes:m,download:f}=r,{t:p}=qe();let h,v,y,u,x,S,C;if(e[0]!==t||e[1]!==a||e[2]!==m||e[3]!==p){const j=Oc(a).toUpperCase();S="flex h-full min-h-0 flex-col",C=s.jsx(qn,{items:[j,Gn(m)]}),y="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==a?(u=s.jsx(Un,{filePath:a,className:"size-10"}),e[11]=a,e[12]=u):u=e[12],e[13]!==t?(x=s.jsx("div",{className:"max-w-full truncate typography-ui-header text-foreground",children:t}),e[13]=t,e[14]=x):x=e[14],h="max-w-md typography-ui text-muted-foreground",v=j?p("filesView.artifact.binary.descriptionWithType",{extension:j}):p("filesView.artifact.binary.description"),e[0]=t,e[1]=a,e[2]=m,e[3]=p,e[4]=h,e[5]=v,e[6]=y,e[7]=u,e[8]=x,e[9]=S,e[10]=C}else h=e[4],v=e[5],y=e[6],u=e[7],x=e[8],S=e[9],C=e[10];let R;e[15]!==h||e[16]!==v?(R=s.jsx("div",{className:h,children:v}),e[15]=h,e[16]=v,e[17]=R):R=e[17];let b;e[18]!==f||e[19]!==y||e[20]!==u||e[21]!==x||e[22]!==R?(b=s.jsxs("div",{className:y,children:[u,x,R,f]}),e[18]=f,e[19]=y,e[20]=u,e[21]=x,e[22]=R,e[23]=b):b=e[23];let F;return e[24]!==S||e[25]!==C||e[26]!==b?(F=s.jsxs("div",{className:S,children:[C,b]}),e[24]=S,e[25]=C,e[26]=b,e[27]=F):F=e[27],F},uf=[48,32,24,18,14],df=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let Lr=0;const ff=r=>{const e=Ee.c(16),{src:t,name:a,sizeBytes:m}=r,{t:f}=qe(),[p,h]=i.useState("loading"),[v]=i.useState(mf);let y,u;e[0]!==v||e[1]!==t?(y=()=>{let b=!1;h("loading");const F=new FontFace(v,`url("${t.replace(/"/g,"%22")}")`);return document.fonts.add(F),F.load().then(()=>{b||h("ready")}).catch(()=>{b||h("failed")}),()=>{b=!0,document.fonts.delete(F)}},u=[v,t],e[0]=v,e[1]=t,e[2]=y,e[3]=u):(y=e[2],u=e[3]),i.useEffect(y,u);let x;e[4]!==m?(x=Gn(m),e[4]=m,e[5]=x):x=e[5];let S;e[6]!==a||e[7]!==x?(S=s.jsx(qn,{items:[a,x]}),e[6]=a,e[7]=x,e[8]=S):S=e[8];let C;e[9]!==v||e[10]!==p||e[11]!==f?(C=p==="failed"?s.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-center typography-ui text-muted-foreground",children:f("filesView.artifact.font.loadFailed")}):p==="loading"?s.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[s.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),f("common.loading")]}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${v}"`},children:s.jsxs("div",{className:"flex flex-col gap-4",children:[uf.map(b=>s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("span",{className:"w-8 shrink-0 text-right font-sans typography-meta text-muted-foreground",children:b}),s.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${b}px`},children:f("filesView.artifact.font.sample")})]},b)),s.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:df.map(hf)})]})}),e[9]=v,e[10]=p,e[11]=f,e[12]=C):C=e[12];let R;return e[13]!==S||e[14]!==C?(R=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S,C]}),e[13]=S,e[14]=C,e[15]=R):R=e[15],R};function mf(){return Lr=Lr+1,`oc-font-preview-${Lr}`}function hf(r){return s.jsx("div",{className:"break-all leading-relaxed",children:r},r)}const $s=12,Do=.1,Vo=16,Qa=[.1,.25,.5,.75,1,1.5,2,3,4,6,8,12,16],pf=16,eo=30,gf=(r,e)=>{const t=e.width-$s*2,a=e.height-$s*2;return r.width<=0||r.height<=0||t<=0||a<=0?1:Math.min(1,t/r.width,a/r.height)},vf=(r,e)=>Math.min(Vo,Math.max(Math.min(Do,e),r)),to=(r,e)=>e===1?Qa.find(t=>t>r*1.001)??Vo:[...Qa].reverse().find(t=>t<r*.999)??Do,xf=(r,e)=>{const t=e===1?r*pf:r,a=Math.max(-eo,Math.min(eo,t));return Math.exp(-a/100)},no=(r,e)=>Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY),wf=({src:r,name:e,sizeBytes:t})=>{const{t:a}=qe(),[m,f]=i.useState(null),[p,h]=i.useState(null),[v,y]=i.useState(null),[u,x]=i.useState(!1),S=i.useRef(null),C=i.useRef(null),R=i.useRef(null),b=i.useRef(null);i.useEffect(()=>{h(null),f(null)},[r]),i.useEffect(()=>{const E=S.current;if(!E)return;const A=new ResizeObserver(()=>{y({width:E.clientWidth,height:E.clientHeight})});return A.observe(E),()=>A.disconnect()},[]);const F=p&&v?gf(p,v):1,j=m??F,l=m!==null&&p!==null&&v!==null&&(p.width*m+$s*2>v.width||p.height*m+$s*2>v.height),M=(E,A,I)=>{const H=C.current;if(!H||!p)return;const B=H.getBoundingClientRect(),K=H.clientWidth/p.width;K<=0||(R.current={imageX:(A-B.left-H.clientLeft)/K,imageY:(I-B.top-H.clientTop)/K,clientX:A,clientY:I},Is.flushSync(()=>f(vf(E,F))))},T=E=>{const A=S.current;if(!A)return;const I=A.getBoundingClientRect();M(E,I.left+I.width/2,I.top+I.height/2)};i.useLayoutEffect(()=>{const E=R.current,A=S.current,I=C.current;if(R.current=null,!E||!A||!I||m===null||I.naturalWidth<=0)return;const H=I.getBoundingClientRect(),B=I.clientWidth/I.naturalWidth;A.scrollLeft+=H.left+I.clientLeft+E.imageX*B-E.clientX,A.scrollTop+=H.top+I.clientTop+E.imageY*B-E.clientY},[m]);const V=i.useRef({zoomTo:M,shownScale:j});V.current={zoomTo:M,shownScale:j},i.useEffect(()=>{const E=S.current;if(!E)return;let A=0,I=null,H=null;const B=$=>{if(!$.ctrlKey&&!$.metaKey)return;$.preventDefault();const te=V.current;te.zoomTo(te.shownScale*xf($.deltaY,$.deltaMode),$.clientX,$.clientY)},K=$=>{A=$.touches.length,$.touches.length===2&&(I={distance:no($.touches[0],$.touches[1]),scale:V.current.shownScale})},se=$=>{if(!I||$.touches.length!==2||I.distance<=0)return;$.preventDefault();const[te,ke]=[$.touches[0],$.touches[1]];V.current.zoomTo(I.scale*(no(te,ke)/I.distance),(te.clientX+ke.clientX)/2,(te.clientY+ke.clientY)/2)},ie=$=>{A=$.touches.length,$.touches.length<2&&(I=null)},me=$=>{$.preventDefault(),H=A>0?null:V.current.shownScale},Y=$=>{$.preventDefault(),H!==null&&V.current.zoomTo(H*$.scale,$.clientX,$.clientY)},ue=$=>{$.preventDefault(),H=null};return E.addEventListener("wheel",B,{passive:!1}),E.addEventListener("touchstart",K,{passive:!0}),E.addEventListener("touchmove",se,{passive:!1}),E.addEventListener("touchend",ie,{passive:!0}),E.addEventListener("touchcancel",ie,{passive:!0}),E.addEventListener("gesturestart",me),E.addEventListener("gesturechange",Y),E.addEventListener("gestureend",ue),()=>{E.removeEventListener("wheel",B),E.removeEventListener("touchstart",K),E.removeEventListener("touchmove",se),E.removeEventListener("touchend",ie),E.removeEventListener("touchcancel",ie),E.removeEventListener("gesturestart",me),E.removeEventListener("gesturechange",Y),E.removeEventListener("gestureend",ue)}},[]);const z=E=>{if(!l||E.pointerType!=="mouse"||E.button!==0)return;const A=E.currentTarget,I=A.getBoundingClientRect();E.clientX-I.left>=A.clientWidth||E.clientY-I.top>=A.clientHeight||(E.preventDefault(),A.setPointerCapture(E.pointerId),b.current={pointerId:E.pointerId,x:E.clientX,y:E.clientY,left:A.scrollLeft,top:A.scrollTop},x(!0))},k=E=>{const A=b.current;!A||A.pointerId!==E.pointerId||(E.currentTarget.scrollLeft=A.left-(E.clientX-A.x),E.currentTarget.scrollTop=A.top-(E.clientY-A.y))},D=E=>{b.current?.pointerId===E.pointerId&&(b.current=null,x(!1))},O=E=>{if(m===null){M(1,E.clientX,E.clientY);return}f(null)};return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(qn,{items:[Po(p),Gn(t)],actions:s.jsxs(s.Fragment,{children:[s.jsx(U,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomOut"),title:a("filesView.artifact.image.zoomOut"),disabled:!p,onClick:()=>T(to(j,-1)),children:s.jsx(P,{name:"subtract",className:"size-3.5"})}),s.jsx(U,{variant:"ghost",size:"xs",className:"min-w-11 tabular-nums",title:a("filesView.artifact.image.actualTitle"),disabled:!p,onClick:()=>T(1),children:`${Math.round(j*100)}%`}),s.jsx(U,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomIn"),title:a("filesView.artifact.image.zoomIn"),disabled:!p,onClick:()=>T(to(j,1)),children:s.jsx(P,{name:"add",className:"size-3.5"})}),s.jsx(U,{variant:"chip",size:"xs","aria-pressed":m===null,title:a("filesView.artifact.image.fitTitle"),onClick:()=>f(null),children:a("filesView.artifact.image.fit")})]})}),s.jsx("div",{ref:S,className:J("min-h-0 flex-1 overflow-auto",l&&(u?"cursor-grabbing":"cursor-grab")),onPointerDown:z,onPointerMove:k,onPointerUp:D,onPointerCancel:D,onDoubleClick:O,children:s.jsx("div",{className:J("flex items-center justify-center p-3",m===null?"h-full w-full":"min-h-full min-w-full w-max"),children:s.jsx("img",{ref:C,src:r,alt:e,draggable:!1,onLoad:E=>{const A=E.currentTarget;h({width:A.naturalWidth,height:A.naturalHeight})},style:m!==null&&p?{width:p.width*m,height:p.height*m}:void 0,className:J("select-none rounded-md border border-border/30 bg-primary/10",m===null?"max-h-full max-w-full object-contain":"max-w-none shrink-0")},r)})})]})},bf=r=>{const e=Ee.c(24),{kind:t,src:a,name:m,sizeBytes:f,download:p}=r,{t:h}=qe(),[v,y]=i.useState(null),[u,x]=i.useState(null),[S,C]=i.useState(!1);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{y(null),x(null),C(!1)},e[0]=R):R=e[0];let b;e[1]!==a?(b=[a],e[1]=a,e[2]=b):b=e[2],i.useEffect(R,b);let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{const O=D.currentTarget;y(Number.isFinite(O.duration)?O.duration:null),O instanceof HTMLVideoElement&&x({width:O.videoWidth,height:O.videoHeight})},e[3]=F):F=e[3];const j=F;let l;e[4]!==v?(l=lf(v),e[4]=v,e[5]=l):l=e[5];let M;e[6]!==u?(M=Po(u),e[6]=u,e[7]=M):M=e[7];let T;e[8]!==f?(T=Gn(f),e[8]=f,e[9]=T):T=e[9];let V;e[10]!==l||e[11]!==M||e[12]!==T?(V=s.jsx(qn,{items:[l,M,T]}),e[10]=l,e[11]=M,e[12]=T,e[13]=V):V=e[13];let z;e[14]!==p||e[15]!==S||e[16]!==t||e[17]!==m||e[18]!==a||e[19]!==h?(z=S?s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:h("filesView.artifact.media.unplayable")}),p]}):t==="video"?s.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:s.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",title:m,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:j,onError:()=>C(!0)},a)}):s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[s.jsx("div",{className:"typography-ui-label truncate text-foreground",children:m}),s.jsx("audio",{src:a,controls:!0,preload:"metadata",title:m,className:"w-full max-w-lg",onLoadedMetadata:j,onError:()=>C(!0)},a)]}),e[14]=p,e[15]=S,e[16]=t,e[17]=m,e[18]=a,e[19]=h,e[20]=z):z=e[20];let k;return e[21]!==V||e[22]!==z?(k=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[V,z]}),e[21]=V,e[22]=z,e[23]=k):k=e[23],k},yf=2e3,Cf=r=>r.toLowerCase().endsWith(".tsv")?" ":",",jf=(r,e,t=yf)=>{const a=[];let m=0,f="",p=[],h=!1,v=!1;const y=()=>{p.push(f),f="",p.length===1&&p[0]===""&&!v||((m===0||a.length<=t)&&a.push(p),m+=1),p=[],v=!1},u=r.charCodeAt(0)===65279?r.slice(1):r;for(let b=0;b<u.length;b+=1){const F=u[b];if(h){F==='"'?u[b+1]==='"'?(f+='"',b+=1):h=!1:f+=F;continue}if(F==='"'){h=!0,v=!0;continue}if(F===e){p.push(f),f="",v=!0;continue}if(F===`
|
|
11
|
-
`||F==="\r"){F==="\r"&&u[b+1]===`
|
|
12
|
-
`&&(b+=1),y();continue}f+=F}(f.length>0||p.length>0||h)&&y();const x=a[0]??[],S=a.slice(1),C=a.reduce((b,F)=>Math.max(b,F.length),0),R=Math.max(0,m-1);return{header:x,rows:S,totalRows:R,columnCount:C,truncated:S.length<R}},Sf=r=>{const e=Ee.c(29),{path:t,content:a,sizeBytes:m}=r,{t:f}=qe();let p;e[0]!==a||e[1]!==t?(p=jf(a,Cf(t)),e[0]=a,e[1]=t,e[2]=p):p=e[2];const h=p;let v;e[3]!==f||e[4]!==h.columnCount||e[5]!==h.totalRows?(v=h.totalRows===1?f("filesView.artifact.table.rowsSingle",{rows:h.totalRows,columns:h.columnCount}):f("filesView.artifact.table.rowsPlural",{rows:h.totalRows,columns:h.columnCount}),e[3]=f,e[4]=h.columnCount,e[5]=h.totalRows,e[6]=v):v=e[6];const y=v;let u;e[7]!==h.columnCount?(u=Array.from({length:h.columnCount},Nf),e[7]=h.columnCount,e[8]=u):u=e[8];const x=u;let S;e[9]!==f||e[10]!==h.rows||e[11]!==h.totalRows||e[12]!==h.truncated?(S=h.truncated?f("filesView.artifact.table.truncated",{shown:h.rows.length,total:h.totalRows}):"",e[9]=f,e[10]=h.rows,e[11]=h.totalRows,e[12]=h.truncated,e[13]=S):S=e[13];let C;e[14]!==m?(C=Gn(m),e[14]=m,e[15]=C):C=e[15];let R;e[16]!==y||e[17]!==S||e[18]!==C?(R=s.jsx(qn,{items:[y,S,C]}),e[16]=y,e[17]=S,e[18]=C,e[19]=R):R=e[19];let b;e[20]!==x||e[21]!==f||e[22]!==h.columnCount||e[23]!==h.header||e[24]!==h.rows?(b=h.columnCount===0?s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:f("filesView.artifact.table.empty")}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[s.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:s.jsx("tr",{children:x.map(j=>s.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-r border-border/40 px-2 py-1 text-left font-medium text-foreground last:border-r-0",children:h.header[j]??""},j))})}),s.jsx("tbody",{children:h.rows.map((j,l)=>s.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:x.map(M=>s.jsx("td",{className:"max-w-[32rem] truncate border-b border-r border-border/30 px-2 py-1 align-top text-foreground last:border-r-0",title:j[M]??"",children:j[M]??""},M))},l))})]})}),e[20]=x,e[21]=f,e[22]=h.columnCount,e[23]=h.header,e[24]=h.rows,e[25]=b):b=e[25];let F;return e[26]!==R||e[27]!==b?(F=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[R,b]}),e[26]=R,e[27]=b,e[28]=F):F=e[28],F};function Nf(r,e){return e}const wn="data-oc-local-asset",Ff=25*1024*1024,Ls=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},Ef=r=>r.split(/[?#]/,1)[0]??"",kf=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),Rf=(r,e)=>{const t=Ao(e.replace(/^#/,"")).toLowerCase();if(!t)return!1;for(const a of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(a.id===t||kf(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},Ao=r=>{try{return decodeURIComponent(r)}catch{return r}},Tf=r=>r.split(",").flatMap(e=>{const[t,...a]=e.trim().split(/\s+/);return t?[{url:t,descriptor:a.join(" ")}]:[]}),zr="data-oc-media",Mf=/\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)/gi,so=(r,e)=>{for(const t of Array.from(r.querySelectorAll("picture > source[media]"))){const a=t.getAttribute(zr)??t.getAttribute("media")??"",m=a.replace(Mf,(f,p)=>p.toLowerCase()===e?"(min-width: 0px)":"(max-width: -1px)");m!==a&&(t.getAttribute(zr)!==a&&t.setAttribute(zr,a),t.getAttribute("media")!==m&&t.setAttribute("media",m))}},ro=({container:r,filePath:e,workspaceRoot:t,onOpenFile:a,enabled:m,colorScheme:f})=>{const p=i.useRef(a);p.current=a;const h=i.useRef(f);h.current=f,i.useEffect(()=>{m&&r&&so(r,f)},[f,r,m]),i.useEffect(()=>{if(!m||!r||!e)return;const v=e.slice(0,e.lastIndexOf("/")+1)||"/",y=l=>Bc(v,Ao(Ef(l))),u=l=>({path:l,allowOutsideWorkspace:t&&_c(l,t)?void 0:"true",directory:t||void 0});let x=!1;const S=ut(),C=new Map,R=l=>{const M=C.get(l);if(M)return M;const T=(async()=>{const V=await Wn("/api/fs/raw",{query:u(l),signal:AbortSignal.timeout(3e4)});if(!V.ok)throw new Error(`Image read failed (${V.status})`);const z=await V.blob();if(z.size>Ff)throw new Error("Image too large for preview");if(x||ut()!==S)throw new Error("Preview closed");return URL.createObjectURL(z)})();return C.set(l,T),T.catch(()=>C.delete(l)),T},b=()=>{for(const l of Array.from(r.querySelectorAll("img[src]"))){const M=l.getAttribute("src")??"";if(!Ls(M))continue;const T=y(M);l.setAttribute(wn,T),R(T).then(V=>{x||l.getAttribute(wn)!==T||l.getAttribute("src")!==V&&(l.src=V)}).catch(()=>{x||l.removeAttribute(wn)})}for(const l of Array.from(r.querySelectorAll("source[srcset], img[srcset]"))){const M=Tf(l.getAttribute("srcset")??"");if(!M.some(z=>Ls(z.url)))continue;const T=M.map(z=>({...z,path:Ls(z.url)?y(z.url):null})),V=T.map(z=>z.path??z.url).join(",");l.setAttribute(wn,V),Promise.all(T.map(async({url:z,descriptor:k,path:D})=>{const O=D?await R(D):z;return k?`${O} ${k}`:O})).then(z=>{if(x||l.getAttribute(wn)!==V)return;const k=z.join(", ");l.getAttribute("srcset")!==k&&l.setAttribute("srcset",k)}).catch(()=>{x||l.removeAttribute(wn)})}so(r,h.current)},F=l=>{if(l.defaultPrevented||l.button!==0||l.metaKey||l.ctrlKey||l.shiftKey||l.altKey)return;const M=l.target;if(!(M instanceof Element))return;const T=M.closest("a[href]");if(!(T instanceof HTMLAnchorElement)||!r.contains(T))return;const V=T.getAttribute("href")??"";if(V.startsWith("#")){l.preventDefault(),l.stopPropagation(),Rf(r,V);return}Ls(V)&&(l.preventDefault(),l.stopPropagation(),p.current(y(V)))};b();const j=new MutationObserver(b);return j.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src","srcset","media"]}),r.addEventListener("click",F,!0),()=>{x=!0,j.disconnect(),r.removeEventListener("click",F,!0);for(const l of C.values())l.then(M=>URL.revokeObjectURL(M)).catch(()=>{})}},[r,m,e,t])},Pf=Xu({grant:Yu().min(1)}),Df=async(r,e,t=Wn)=>{const a=await t("/api/fs/preview",{method:"POST",signal:e,query:{directory:r.directory||void 0},headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r.path})});if(!a.ok)throw new Error(`Preview grant request failed (${a.status})`);const m=Pf.safeParse(await a.json().catch(()=>null));if(!m.success)throw new Error("Preview grant response was invalid");return m.data.grant},Vf=(r,e)=>{const t=e.split("/").map(m=>encodeURIComponent(m)).join("/"),a=t.startsWith("/")?t:`/${t}`;return fo().api(`/api/fs/preview/${encodeURIComponent(r)}${a}`)},Af=(r,e,t)=>{const a=Ee.c(8),m=Df;let f;a[0]===Symbol.for("react.memo_cache_sentinel")?(f={status:"idle"},a[0]=f):f=a[0];const[p,h]=i.useState(f),v=r?.path??"",y=r?.directory??"",u=r?.revision??"";let x,S;return a[1]!==y||a[2]!==e||a[3]!==m||a[4]!==v||a[5]!==u?(x=()=>{if(!v){h({status:"idle"});return}const C=new AbortController;return h({status:"loading"}),(async()=>{try{const b=await m({path:v,directory:y,revision:u},C.signal);C.signal.aborted||h({status:"ready",url:Vf(b,v)})}catch(b){const F=b;if(C.signal.aborted)return;h({status:"error",message:F instanceof Error?F.message:e})}})(),()=>C.abort()},S=[v,y,u,e,m],a[1]=y,a[2]=e,a[3]=m,a[4]=v,a[5]=u,a[6]=x,a[7]=S):(x=a[6],S=a[7]),i.useEffect(x,S),p},Cn=[];let io=!1;const ao=()=>{dc()&&fc("desktop_set_close_tab_target",{active:Cn.length>0})},Lf=()=>{Cn[Cn.length-1]?.()},zf=r=>(io||(window.addEventListener("openchamber:close-tab",Lf),io=!0),Cn.push(r),ao(),()=>{const e=Cn.lastIndexOf(r);e>=0&&Cn.splice(e,1),ao()}),If=r=>{const e=ae(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const t=e.lastIndexOf("/");if(t<0)return e;if(t===0)return"/";const a=e.slice(0,t);return/^[A-Za-z]:$/.test(a)?`${a}/`:a},Of=r=>{const e=Ee.c(8),{label:t,iconDataUrl:a}=r,[m,f]=i.useState(!1);let p;e[0]!==t?(p=t.trim().slice(0,1).toUpperCase()||"?",e[0]=t,e[1]=p):p=e[1];const h=p;if(a&&!m){let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>f(!0),e[2]=u):u=e[2];let x;return e[3]!==a?(x=s.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:u}),e[3]=a,e[4]=x):x=e[4],x}let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=J("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=v):v=e[5];let y;return e[6]!==h?(y=s.jsx("span",{className:v,children:h}),e[6]=h,e[7]=y):y=e[7],y},Bf=r=>r.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),ae=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),t=e.startsWith("//");let a=e.replace(/\/+/g,"/");t&&!a.startsWith("//")&&(a=`/${a}`);const m=a==="/",f=/^[A-Za-z]:\/$/.test(a);return!m&&!f&&(a=a.replace(/\/+$/,"")),a},_f=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),yn=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,Hn=(r,e)=>{const t=ae(e),a=ae(r);if(!t||!a)return!1;const m=yn(t),f=yn(a);return f===m||f.startsWith(`${m}/`)},oo=(r,e)=>{const t=ae(e),a=ae(r);if(!Hn(a,t))return[];const f=a.slice(t.length).replace(/^\//,"").split("/"),p=[];let h=t;for(let v=0;v<f.length-1;v++)h=h?`${h}/${f[v]}`:f[v],p.push(h);return p},Bs=(r,e)=>{if(!e)return"";const t=ae(e);if(!r||!Hn(t,r))return t;const a=t.slice(r.length);return a.startsWith("/")?a.slice(1):a},$f=new Set(["node_modules"]),Wf=r=>{const e=Ee.c(3),{status:t}=r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={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]=a):a=e[0];const m=a[t];let f;return e[1]!==m?(f=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:m}}),e[1]=m,e[2]=f):f=e[2],f},lo=r=>{const e=Ee.c(11),{name:t}=r,a=i.useRef(null),m=i.useRef(null),[f,p]=i.useState(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const S=a.current,C=m.current;if(!S||!C)return;const R=()=>{p(C.scrollWidth>S.clientWidth+1)};R();const b=new ResizeObserver(R);return b.observe(S),b.observe(C),()=>{b.disconnect()}},e[0]=h):h=e[0];let v;e[1]!==t?(v=[t],e[1]=t,e[2]=v):v=e[2],i.useLayoutEffect(h,v);let y;e[3]!==t?(y=s.jsx("span",{ref:m,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=y):y=e[4];let u;e[5]!==t||e[6]!==f?(u=f?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:t}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):s.jsx("span",{className:"block min-w-0 truncate",children:t}),e[5]=t,e[6]=f,e[7]=u):u=e[7];let x;return e[8]!==y||e[9]!==u?(x=s.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[y,u]}),e[8]=y,e[9]=u,e[10]=x):x=e[10],x},Uf=r=>$f.has(r),Hf=r=>{const e=ae(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Kf=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},qf=2e5,Lo=(r,e)=>s.jsx(Un,{filePath:r,extension:e}),Ir=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const t=e.split(".").pop();return t==="md"||t==="markdown"},Or=r=>!!(r&&To(Kr.getState().guests,r)),co=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},zs=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Gf=r=>{const e=Ee.c(78),{node:t,root:a,isExpanded:m,isActive:f,isMobile:p,isBrowserClient:h,alwaysShowActions:v,status:y,badge:u,permissions:x,downloadFile:S,contextMenuPath:C,setContextMenuPath:R,rightClickMenuPath:b,setRightClickMenuPath:F,onSelect:j,onToggle:l,onRevealPath:M,onOpenDialog:T,canUpload:V,onPickFiles:z}=r,{t:k}=qe(),D=t.type==="directory",{canRename:O,canCreateFile:E,canCreateFolder:A,canDelete:I,canReveal:H}=x,B=!D&&!!S,K=H&&!h,se=D&&V,ie=O||E||A||se||I||B||K;let me;e[0]!==ie||e[1]!==t.path||e[2]!==F?(me=Se=>{ie&&(Se?.preventDefault(),F(t.path))},e[0]=ie,e[1]=t.path,e[2]=F,e[3]=me):me=e[3];const Y=me;let ue;e[4]!==D||e[5]!==t||e[6]!==j||e[7]!==l?(ue=()=>{D?l(t.path):j(t)},e[4]=D,e[5]=t,e[6]=j,e[7]=l,e[8]=ue):ue=e[8];const $=ue;let te;e[9]!==t.path||e[10]!==R||e[11]!==F?(te=Se=>{Se.stopPropagation(),F(null),R(t.path)},e[9]=t.path,e[10]=R,e[11]=F,e[12]=te):te=e[12];const ke=te;let Ge;e[13]!==E||e[14]!==A||e[15]!==I||e[16]!==O||e[17]!==K||e[18]!==se||e[19]!==S||e[20]!==h||e[21]!==D||e[22]!==t||e[23]!==T||e[24]!==z||e[25]!==M||e[26]!==a||e[27]!==k?(Ge=Se=>{const{Item:ge,Separator:Je}=Se;return s.jsxs(s.Fragment,{children:[O&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),T("rename",t)},children:[s.jsx(P,{name:"edit",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.rename")]}),s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),_s(t.path).then(Ze=>{if(Ze.ok){Z.success(k("sidebarFilesTree.toast.pathCopied"));return}Z.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(P,{name:"file-copy",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.copyPath")]}),s.jsxs(ge,{onClick:ee=>{ee.stopPropagation();const Ze=Bs(a,t.path)||t.path;_s(Ze).then(Qe=>{if(Qe.ok){Z.success(k("filesView.toast.relativePathCopied"));return}Z.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(P,{name:"file-copy-2",className:"mr-2 size-4"})," ",k("filesView.tree.menu.copyRelativePath")]}),!D&&S&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),S(t.path).catch(Ze=>{console.error("Download failed:",Ze),Z.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(P,{name:"download",className:"mr-2 size-4"})," ",k(h?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),K&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),M(t.path)},children:[s.jsx(P,{name:"folder-received",className:"mr-2 size-4"})," ",k(du())]}),!D&&K&&yc()&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),Br(t.path).then(Ze=>{Ze||Z.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(P,{name:"external-link",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.openInDefaultApp")]}),D&&(E||A||se)&&s.jsxs(s.Fragment,{children:[s.jsx(Je,{}),E&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),T("createFile",t)},children:[s.jsx(P,{name:"file-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFile")]}),A&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),T("createFolder",t)},children:[s.jsx(P,{name:"folder-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFolder")]}),se&&s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),z(t.path)},children:[s.jsx(P,{name:"upload-2",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.uploadFiles")]})]}),I&&s.jsxs(s.Fragment,{children:[s.jsx(Je,{}),s.jsxs(ge,{onClick:ee=>{ee.stopPropagation(),T("delete",t)},className:"text-destructive focus:text-destructive",children:[s.jsx(P,{name:"delete-bin",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.delete")]})]})]})},e[13]=E,e[14]=A,e[15]=I,e[16]=O,e[17]=K,e[18]=se,e[19]=S,e[20]=h,e[21]=D,e[22]=t,e[23]=T,e[24]=z,e[25]=M,e[26]=a,e[27]=k,e[28]=Ge):Ge=e[28];const Re=Ge,Xe=b===t.path;let ye;e[29]!==t.path||e[30]!==F?(ye=Se=>F(Se?t.path:null),e[29]=t.path,e[30]=F,e[31]=ye):ye=e[31];const Ye=p?void 0:Y;let re;e[32]!==Ye?(re=s.jsx("div",{className:"group relative flex items-center",onContextMenu:Ye}),e[32]=Ye,e[33]=re):re=e[33];const Ce=p?void 0:Y,Te=f?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let je;e[34]!==Te?(je=J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Te),e[34]=Te,e[35]=je):je=e[35];let de;e[36]!==D||e[37]!==m||e[38]!==t.extension||e[39]!==t.path?(de=D?m?s.jsx(P,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(P,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Lo(t.path,t.extension),e[36]=D,e[37]=m,e[38]=t.extension,e[39]=t.path,e[40]=de):de=e[40];let Me;e[41]!==t.name||e[42]!==t.path?(Me=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),e[41]=t.name,e[42]=t.path,e[43]=Me):Me=e[43];let _;e[44]!==D||e[45]!==y?(_=!D&&y&&s.jsx(Wf,{status:y}),e[44]=D,e[45]=y,e[46]=_):_=e[46];let q;e[47]!==u||e[48]!==D?(q=D&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[47]=u,e[48]=D,e[49]=q):q=e[49];let Q;e[50]!==$||e[51]!==je||e[52]!==de||e[53]!==Me||e[54]!==_||e[55]!==q||e[56]!==Ce?(Q=s.jsxs("button",{type:"button",onClick:$,onContextMenu:Ce,className:je,children:[de,Me,_,q]}),e[50]=$,e[51]=je,e[52]=de,e[53]=Me,e[54]=_,e[55]=q,e[56]=Ce,e[57]=Q):Q=e[57];let ce;e[58]!==v||e[59]!==C||e[60]!==ke||e[61]!==ie||e[62]!==p||e[63]!==t.path||e[64]!==Re||e[65]!==R?(ce=ie&&s.jsx("div",{className:J("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs($r,{open:C===t.path,onOpenChange:Se=>R(Se?t.path:null),children:[s.jsx(Wr,{asChild:!0,children:s.jsx(U,{variant:"ghost",size:"icon",className:"size-6",onClick:ke,children:s.jsx(P,{name:"more-2-fill",className:"size-4"})})}),s.jsx(Ur,{align:"end",side:"bottom",onCloseAutoFocus:()=>R(null),children:Re({Item:Os,Separator:ou})})]})}),e[58]=v,e[59]=C,e[60]=ke,e[61]=ie,e[62]=p,e[63]=t.path,e[64]=Re,e[65]=R,e[66]=ce):ce=e[66];let he;e[67]!==Q||e[68]!==ce||e[69]!==re?(he=s.jsxs(fu,{render:re,children:[Q,ce]}),e[67]=Q,e[68]=ce,e[69]=re,e[70]=he):he=e[70];let le;e[71]!==Re?(le=s.jsx(lu,{className:"min-w-[180px]",children:Re({Item:uu,Separator:cu})}),e[71]=Re,e[72]=le):le=e[72];let xe;return e[73]!==he||e[74]!==le||e[75]!==Xe||e[76]!==ye?(xe=s.jsxs(mu,{open:Xe,onOpenChange:ye,children:[he,le]}),e[73]=he,e[74]=le,e[75]=Xe,e[76]=ye,e[77]=xe):xe=e[77],xe},Xf=r=>{const e=Ee.c(83),{activeDialog:t,dialogData:a,dialogInputValue:m,onDialogInputChange:f,isDialogSubmitting:p,onDialogSubmit:h,onClose:v,inputRef:y}=r,{t:u}=qe(),x=!!t;let S;e[0]!==v?(S=Y=>!Y&&v(),e[0]=v,e[1]=S):S=e[1];let C;e[2]!==t||e[3]!==u?(C=t==="createFile"&&u("filesView.dialog.createFile.title"),e[2]=t,e[3]=u,e[4]=C):C=e[4];let R;e[5]!==t||e[6]!==u?(R=t==="createFolder"&&u("filesView.dialog.createFolder.title"),e[5]=t,e[6]=u,e[7]=R):R=e[7];let b;e[8]!==t||e[9]!==u?(b=t==="rename"&&u("filesView.dialog.rename.title"),e[8]=t,e[9]=u,e[10]=b):b=e[10];let F;e[11]!==t||e[12]!==u?(F=t==="delete"&&u("filesView.dialog.delete.title"),e[11]=t,e[12]=u,e[13]=F):F=e[13];let j;e[14]!==C||e[15]!==R||e[16]!==b||e[17]!==F?(j=s.jsxs(xo,{children:[C,R,b,F]}),e[14]=C,e[15]=R,e[16]=b,e[17]=F,e[18]=j):j=e[18];let l;e[19]!==t||e[20]!==a?.path||e[21]!==u?(l=t==="createFile"&&u("filesView.dialog.createFile.description",{path:a?.path??u("filesView.dialog.rootFallback")}),e[19]=t,e[20]=a?.path,e[21]=u,e[22]=l):l=e[22];let M;e[23]!==t||e[24]!==a?.path||e[25]!==u?(M=t==="createFolder"&&u("filesView.dialog.createFolder.description",{path:a?.path??u("filesView.dialog.rootFallback")}),e[23]=t,e[24]=a?.path,e[25]=u,e[26]=M):M=e[26];let T;e[27]!==t||e[28]!==a?.name||e[29]!==u?(T=t==="rename"&&u("filesView.dialog.rename.description",{name:a?.name??""}),e[27]=t,e[28]=a?.name,e[29]=u,e[30]=T):T=e[30];let V;e[31]!==t||e[32]!==a?.name||e[33]!==u?(V=t==="delete"&&u("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=u,e[34]=V):V=e[34];let z;e[35]!==T||e[36]!==V||e[37]!==l||e[38]!==M?(z=s.jsxs(wo,{children:[l,M,T,V]}),e[35]=T,e[36]=V,e[37]=l,e[38]=M,e[39]=z):z=e[39];let k;e[40]!==z||e[41]!==j?(k=s.jsxs(vo,{children:[j,z]}),e[40]=z,e[41]=j,e[42]=k):k=e[42];let D;e[43]!==t||e[44]!==m||e[45]!==y||e[46]!==f||e[47]!==h||e[48]!==u?(D=t!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Kn,{value:m,onChange:Y=>f(Y.target.value),placeholder:u(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:Y=>{Y.key==="Enter"&&h()},ref:y})}),e[43]=t,e[44]=m,e[45]=y,e[46]=f,e[47]=h,e[48]=u,e[49]=D):D=e[49];let O;e[50]!==u?(O=u("filesView.dialog.cancel"),e[50]=u,e[51]=O):O=e[51];let E;e[52]!==p||e[53]!==v||e[54]!==O?(E=s.jsx(U,{variant:"outline",onClick:v,disabled:p,children:O}),e[52]=p,e[53]=v,e[54]=O,e[55]=E):E=e[55];const A=t==="delete"?"destructive":"default";let I;e[56]!==h?(I=()=>{h()},e[56]=h,e[57]=I):I=e[57];let H;e[58]!==t||e[59]!==m||e[60]!==p?(H=p||t!=="delete"&&!m.trim(),e[58]=t,e[59]=m,e[60]=p,e[61]=H):H=e[61];let B;e[62]!==t||e[63]!==p||e[64]!==u?(B=p?s.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}):u(t==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=t,e[63]=p,e[64]=u,e[65]=B):B=e[65];let K;e[66]!==A||e[67]!==I||e[68]!==H||e[69]!==B?(K=s.jsx(U,{variant:A,onClick:I,disabled:H,children:B}),e[66]=A,e[67]=I,e[68]=H,e[69]=B,e[70]=K):K=e[70];let se;e[71]!==E||e[72]!==K?(se=s.jsxs(bo,{children:[E,K]}),e[71]=E,e[72]=K,e[73]=se):se=e[73];let ie;e[74]!==y||e[75]!==k||e[76]!==D||e[77]!==se?(ie=s.jsxs(go,{initialFocus:y,children:[k,D,se]}),e[74]=y,e[75]=k,e[76]=D,e[77]=se,e[78]=ie):ie=e[78];let me;return e[79]!==x||e[80]!==S||e[81]!==ie?(me=s.jsx(po,{open:x,onOpenChange:S,children:ie}),e[79]=x,e[80]=S,e[81]=ie,e[82]=me):me=e[82],me},bn=new Map,Yf=100,uo=r=>{const e=Ee.c(13);let t,a,m;e[0]!==r?({positionKey:a,onViewReady:t,...m}=r,e[0]=r,e[1]=t,e[2]=a,e[3]=m):(t=e[1],a=e[2],m=e[3]);const f=i.useRef(null);let p,h;e[4]!==a?(p=()=>()=>{const u=f.current;if(!u)return;const{anchor:x,head:S}=u.state.selection.main;if(bn.delete(a),bn.set(a,{scroll:u.scrollSnapshot(),anchor:x,head:S}),bn.size>Yf){const C=bn.keys().next().value;C!==void 0&&bn.delete(C)}},h=[a],e[4]=a,e[5]=p,e[6]=h):(p=e[5],h=e[6]),i.useLayoutEffect(p,h);let v;e[7]!==t||e[8]!==a?(v=u=>{f.current=u;const x=bn.get(a);x&&u.dispatch({selection:{anchor:Math.min(x.anchor,u.state.doc.length),head:Math.min(x.head,u.state.doc.length)},effects:x.scroll}),t?.(u)},e[7]=t,e[8]=a,e[9]=v):v=e[9];let y;return e[10]!==m||e[11]!==v?(y=s.jsx(pu,{...m,onViewReady:v}),e[10]=m,e[11]=v,e[12]=y):y=e[12],y},Jf=(r,e,t)=>{const a=Ee.c(8),[m,f]=i.useState(""),[p,h]=i.useState(0);let v,y;a[0]!==r||a[1]!==t||a[2]!==e?(v=()=>{if(!r){f("");return}let x=!1;f("");const S=Cc(),C=jc(S);Sc(S).then(b=>{x||!b||(f(r),e(null))}).catch(b=>{x||(e(b instanceof Error?b.message:t),f(r))});const R=Nc(()=>{x||(f(r),h(Zf),e(null))});return()=>{x=!0,C(),R()}},y=[r,e,t],a[0]=r,a[1]=t,a[2]=e,a[3]=v,a[4]=y):(v=a[3],y=a[4]),i.useEffect(v,y);let u;return a[5]!==p||a[6]!==m?(u={readyKey:m,nonce:p},a[5]=p,a[6]=m,a[7]=u):u=a[7],u},bp=({mode:r="full",visible:e=!0})=>{const{t}=qe(),{files:a,runtime:m,git:f}=$c(),{currentTheme:p,availableThemes:h,lightThemeId:v,darkThemeId:y}=Wc(),{isMobile:u,isTablet:x,screenWidth:S}=mo(),C=mc(m.platform),R=u||x,b=hc(),F=pc(),j=ho()??"",l=ae(j.trim()),M=u||r==="full",T=M&&e,V=kr(n=>n.runtimeKey),z=JSON.stringify([V,l]),k=i.useRef(z);k.current=z;const D=JSON.stringify([V,l,b,F]),O=i.useRef(D);O.current=D;const E=r!=="editor-only",A=r==="editor-only"&&!u,I=gc(n=>n.searchFiles),H=Uc(T?j:null),[B,K]=i.useState(""),se=Hc(B,200),ie=i.useRef(null),[me,Y]=i.useState(!1),[ue,$]=i.useState(!0),[te,ke]=i.useState(!1),Ge=i.useCallback(n=>{if(!Qs.current){ke(n);return}const o=wt.current;if(En.current){li.current?.().then(c=>{c&&wt.current===o&&ke(n)});return}Promise.resolve(en.current?.getContent("handoff")??Ar).then(c=>{if(wt.current===o){if(!c.ok){Z.error(c.message);return}c.snapshot&&"content"in c.snapshot&&(Fe(c.snapshot.content),pt(!1)),ke(n)}})},[]),[Re,Xe]=i.useState(!1),ye=i.useRef(0),Ye=i.useCallback(n=>{ye.current=Math.max(0,ye.current+(n?1:-1))},[]),[re,Ce]=i.useState("edit"),[Te,je]=i.useState("edit"),[de,Me]=i.useState("tree"),[_,q]=i.useState("edit"),[Q,ce]=i.useState("preview"),[he,le]=i.useState("preview"),[xe,Se]=i.useState("preview"),[ge,Je]=i.useState("preview"),[ee,Ze]=i.useState("table"),[Qe,Xr]=i.useState(null),[zo,Io]=i.useState(0),[Oo,Xn]=i.useState(0),Yn=i.useRef({}),Hs=i.useRef({}),Ks=i.useRef({}),Yr=i.useRef({}),Jr=i.useRef({}),Zr=i.useRef({}),qs=i.useRef({}),jn=i.useRef({}),Jn=i.useMemo(()=>h.find(n=>n.metadata.id===v)??Aa(!1),[h,v]),Zn=i.useMemo(()=>h.find(n=>n.metadata.id===y)??Aa(!0),[h,y]);i.useEffect(()=>{Wa(Jn),Wa(Zn)},[Jn,Zn]);const Qn=i.useMemo(()=>[],[]),Pe=at(n=>l?n.byRoot[l]?.openPaths??Qn:Qn),At=at(n=>l?n.byRoot[l]?.selectedPath??null:null),ft=at(n=>l?n.byRoot[l]?.expandedPaths??Qn:Qn),Bo=i.useMemo(()=>new Set(ft),[ft]),Yt=at(n=>n.removeOpenPath),Et=at(n=>n.removeOpenPathsByPrefix),Qr=at(n=>n.removeExpandedPathsByPrefix),De=at(n=>n.setSelectedPath),ei=at(n=>n.toggleExpandedPath),es=at(n=>n.expandPaths),Jt=i.useCallback(n=>{const o=ae(n),c=o.split("/"),g=c[c.length-1]||o,w=g.includes(".")?g.split(".").pop()?.toLowerCase():void 0;return{name:g,path:o,type:"file",extension:w}},[]),Zt=i.useMemo(()=>Pe.map(Jt),[Pe,Jt]),Gs=i.useMemo(()=>{if(At){const n=yn(At);if(Pe.some(o=>yn(o)===n))return At}return Pe[0]??null},[Pe,At]),d=i.useMemo(()=>Gs?Jt(Gs):null,[Gs,Jt]),Ie=d?.path??"",wt=i.useRef(Ie);wt.current=Ie,i.useEffect(()=>{if(!l||!At)return;const n=yn(At);Pe.some(c=>yn(c)===n)||De(l,Pe[0]??null)},[Pe,l,At,De]);const ts=!!(l&&Ie&&!Hn(Ie,l)),Xs=i.useMemo(()=>({allowOutsideWorkspace:ts,directory:l||void 0}),[ts,l]),mt=i.useCallback(n=>({allowOutsideWorkspace:!!(l&&!Hn(n,l))}),[l]),Ys=i.useRef(null),[ti,_o]=i.useState({left:!1,right:!1}),ni=i.useCallback(()=>{const n=Ys.current;n&&_o({left:n.scrollLeft>2,right:n.scrollLeft+n.clientWidth<n.scrollWidth-2})},[]),si=i.useRef(ni);si.current=ni,i.useEffect(()=>{const n=Ys.current;if(!n)return;const o=()=>si.current();o(),n.addEventListener("scroll",o,{passive:!0});const c=new ResizeObserver(o);return c.observe(n),()=>{n.removeEventListener("scroll",o),c.disconnect()}},[Zt.length]);const[ri,Js]=i.useState({}),[ns,Sn]=i.useState({}),et=i.useRef(new Set),Oe=i.useMemo(()=>new ku,[]);i.useEffect(()=>()=>Oe.clear(),[Oe]);const[ii,ss]=i.useState([]),[$o,rs]=i.useState(!1),[G,Ne]=i.useState(""),{isPlaying:is,play:Wo,stop:Uo}=Kc(),[Ve,kt]=i.useState(!1),[ot,we]=i.useState(null),[Ho,tt]=i.useState(""),[fe,ve]=i.useState(null),Rt=JSON.stringify([ut(),l,fe]),[oe,Fe]=i.useState(""),[Qt,Zs]=i.useState(!1),[ai,Ko]=i.useState(`
|
|
13
|
-
`),qo=i.useRef(null),ht=i.useRef(null),$e=i.useRef(null),Tt=i.useRef(""),Nn=i.useRef(""),bt=i.useRef(null),Lt=i.useRef(null),oi=i.useRef(null),en=i.useRef(null),[Fn,pt]=i.useState(!1),Qs=i.useRef(!1);Qs.current=Fn;const En=i.useRef(!1),li=i.useRef(null),nt=i.useRef(null),er=i.useRef(""),tr=i.useRef(0),tn=i.useRef(0),zt=i.useRef(null),[nn,Go]=i.useState(0),[Xo,sn]=i.useState("idle"),[Yo,as]=i.useState(!1),[Jo,ci]=i.useState(!1),[It,ui]=i.useState(!1),Ae=ct(n=>n.autoSaveEnabled),Zo=ct(n=>n.setAutoSaveEnabled),[nr,kn]=i.useState(!1),rn=i.useRef(null),Rn=i.useRef(null),Tn=i.useRef(!1),Mn=i.useRef(null),Pn=i.useRef(null),Le=i.useRef(null),Dn=i.useRef(null),di=i.useRef(null),fi=i.useRef(0),[Qo,sr]=i.useState(0),an=i.useRef(null),Ot=i.useRef({key:"",attempts:0});i.useEffect(()=>()=>{an.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(an.current),an.current=null)},[]);const[Bt,rr]=i.useState(null),[_t,el]=i.useState(null),[Mt,mi]=i.useState(""),[tl,ir]=i.useState(!1),[nl,sl]=i.useState(null),[rl,il]=i.useState(null),[al,hi]=i.useState(!1),[ol,pi]=i.useState(!1),[ll,ar]=i.useState(!1),[gi,os]=i.useState(!1),[vi,ls]=i.useState(!1),[xi,wi]=i.useState(0),cs=i.useRef(null),us=i.useCallback(n=>{const o=n?.currentTarget??cs.current;if(!o)return;const c=document.activeElement;c&&c!==document.body&&c!==o&&(qc(c)||o.contains(c))||o.focus({preventScroll:!0})},[]),ds=i.useRef(null),bi=!!a.writeFile,yi=!!a.createDirectory,Ci=!!a.rename,ji=!!a.delete,Si=!!a.revealPath,cl=Ds(n=>n.availableApps),ul=Ds(n=>n.isCacheStale),Ni=Ds(n=>n.initialize),dl=Ds(n=>n.loadInstalledApps);i.useEffect(()=>{Ni()},[Ni]);const fl=i.useCallback(n=>{a.revealPath&&a.revealPath(n).catch(()=>{Z.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),ml=i.useCallback(async n=>{if(!d?.path||await vc(d.path,n.id,n.appName)||await Br(d.path,n.appName))return;const g=If(d.path)||l;g&&await Br(g,n.appName)||Z.error(t("filesView.toast.openInAppFailed",{app:n.appName}))},[l,d?.path,t]),or=i.useCallback((n,o)=>{rr(n),el(o),mi(n==="rename"&&o.name||""),ir(!1)},[]),[ne,lt]=i.useState(null),on=i.useRef(!1),Pt=i.useRef(null),[Fi,ln]=i.useState(!1),gt=ct(n=>n.pendingFileNavigation),fs=ct(n=>n.setPendingFileNavigation),lr=ct(n=>n.pendingFileFocusPath),cr=ct(n=>n.setPendingFileFocusPath),ms=ct(n=>n.fileEditorKeymap),Vn=La(n=>n.settingsDefaultFileViewerPreview),hl=La(n=>n.showMessageTTSButtons);i.useEffect(()=>{const n=()=>{on.current=!1,Pt.current=null,ln(!1)};return document.addEventListener("mouseup",n),()=>document.removeEventListener("mouseup",n)},[]),i.useEffect(()=>()=>{Mn.current!==null&&window.clearTimeout(Mn.current),Pn.current!==null&&window.clearTimeout(Pn.current)},[]);const pl=i.useCallback((n,o)=>{const c=n.split(`
|
|
14
|
-
`),g=Math.max(1,o.start),w=Math.min(c.length,o.end);return g>w?"":c.slice(g-1,w).join(`
|
|
15
|
-
`)},[]),Ei=i.useRef(null),gl=Zu({source:"file",fileLabel:d?.path??null,language:d?.path&&Rr(d.path)||"text",getCodeForRange:n=>pl(G,Qu(n)),toStoreRange:n=>({startLine:n.start,endLine:n.end}),fromDraftRange:n=>({start:n.startLine,end:n.endLine})}),{drafts:ki,commentText:hs,setCommentText:Ri,editingDraftId:ps,setSelection:Ti,saveComment:Mi,cancel:An,reset:Pi,startEdit:Di,deleteDraft:Vi}=gl;i.useEffect(()=>{lt(null),Pi(),Fe(""),Zs(!1)},[d?.path,Pi]),i.useEffect(()=>{Ti(ne)},[ne,Ti]),i.useEffect(()=>{if(!ne&&!ps)return;const n=c=>{const g=c.target;g.closest('[data-comment-input="true"]')||g.closest('[data-comment-card="true"]')||g.closest(".cm-gutterElement")||g.closest("[data-sonner-toast]")||g.closest("[data-sonner-toaster]")||hs.trim()||(lt(null),An())},o=setTimeout(()=>{document.addEventListener("click",n)},100);return()=>{clearTimeout(o),document.removeEventListener("click",n)}},[An,hs,ps,ne]),i.useEffect(()=>{if(!u||!ne)return;const n=Le.current;if(!n)return;const o=n.state.selection.main;o.empty||n.dispatch({selection:{anchor:o.head}});const c=document.getSelection();c&&!c.isCollapsed&&c.anchorNode&&n.contentDOM.contains(c.anchorNode)&&c.removeAllRanges()},[u,ne]);const Ai=i.useCallback((n,o)=>{const c=o??ne??void 0;o&<(o),Mi(n,c),lt(null)},[ne,Mi]),Li=i.useCallback((n,o)=>{const c=[];for(const g of o){if(!(g&&typeof g.name=="string"&&g.name.length>0)||!b&&g.name.startsWith(".")||!F&&Uf(g.name))continue;const w=g.name,N=ae(g.path||""),L=N?_f(N)?N:ae(`${n}/${N}`):ae(`${n}/${w}`),X=g.isDirectory?"directory":"file",be=X==="file"&&w.includes(".")?w.split(".").pop()?.toLowerCase():void 0;c.push({name:w,path:L,type:X,extension:be})}return Bf(c)},[F,b]),Be=i.useCallback(async(n,o=!1)=>{if(!T)return;const c=ae(n.trim());if(!c||!o&&et.current.has(c))return;const g=O.current,w=ut();return Oe.run(c,async N=>{const L=()=>N()&&O.current===g&&ut()===w;try{const X=a.listDirectory?(await a.listDirectory(c)).entries:await xc.listLocalDirectory(c);if(!L())return;const be=Li(c,X);et.current=new Set(et.current),et.current.add(c),Sn(W=>{if(!W[c])return W;const pe={...W};return delete pe[c],pe}),Js(W=>W[c]&&Ru(W[c],be)?W:{...W,[c]:be})}catch(X){if(!L())return;const be=X instanceof Error?X.message:String(X??"");if(be==="Directory not found"&&l&&c!==l){Qr(l,c),Sn(W=>{if(!W[c])return W;const pe={...W};return delete pe[c],pe});return}console.error("Failed to load files directory:",X),Sn(W=>({...W,[c]:be}))}},o)},[Oe,a,Li,Qr,l,T]),gs=i.useCallback(async()=>{l&&(et.current=new Set,Oe.clear(),Sn({}),Js(n=>Object.keys(n).length===0?n:{}),await Be(l))},[Oe,Be,l]),We=i.useCallback(async n=>{if(!n){await gs();return}const o=ae(n);et.current=new Set(et.current),et.current.delete(o),await Be(o,!0)},[Be,gs]),{canUpload:zi,uploadingDirectory:vl,pickFiles:Ii,uploadElements:xl}=Iu({root:l,refreshDirectory:We}),vs=vl!==null,Oi=i.useRef(""),Bi=i.useRef("");i.useEffect(()=>{if(!l)return;const n=D,o=Oi.current!==z,c=Bi.current!==n;!o&&!c||(o&&(Oi.current=z,tn.current+=1,zt.current=null,Ne(""),we(null),tt(""),ve(null),Y(!1)),c&&(Bi.current=n,et.current=new Set,Oe.clear(),Sn({}),Js(g=>Object.keys(g).length===0?g:{}),Be(l)))},[Oe,z,Be,l,D]),i.useEffect(()=>{if(!T||!a.listDirectory)return;const n=()=>{if(!document.hidden&&ft.length>0)for(const o of ft)Oe.has(o)||We(o)};return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[Oe,ft,a.listDirectory,We,T]);const _i=i.useRef(!1);i.useEffect(()=>{const n=T&&!_i.current;if(_i.current=T,!(!T||!l)&&(Be(l),n))for(const o of ft)Oe.has(o)||We(o)},[Oe,ft,Be,We,l,T]),i.useEffect(()=>{if(!T||!a.listDirectory||ft.length===0)return;const n=setInterval(()=>{if(!document.hidden)for(const o of ft)Oe.has(o)||We(o)},8e3);return()=>clearInterval(n)},[Oe,ft,a.listDirectory,We,T]);const wl=i.useCallback(async n=>{if(n?.preventDefault(),!_t||!Bt)return;ir(!0);const o=()=>{rr(null)},c=w=>{Z.error(w)},g=()=>{ir(!1)};if(Bt==="createFile"){if(!Mt.trim()){c(t("sidebarFilesTree.toast.filenameRequired")),g();return}if(!a.writeFile){c(t("sidebarFilesTree.toast.writeNotSupported")),g();return}const w=_t.path,N=w?`${w}/`:"",L=ae(`${N}${Mt.trim()}`);await a.writeFile(L,"").then(async X=>{X.success&&(Z.success(t("sidebarFilesTree.toast.fileCreated")),await We(w)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}if(Bt==="createFolder"){if(!Mt.trim()){c(t("sidebarFilesTree.toast.folderNameRequired")),g();return}const w=_t.path,N=w?`${w}/`:"",L=ae(`${N}${Mt.trim()}`);await a.createDirectory(L).then(async X=>{X.success&&(Z.success(t("sidebarFilesTree.toast.folderCreated")),await We(w)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}if(Bt==="rename"){if(!Mt.trim()){c(t("sidebarFilesTree.toast.nameRequired")),g();return}if(!a.rename){c(t("sidebarFilesTree.toast.renameNotSupported")),g();return}const w=_t.path,N=w.split("/").slice(0,-1).join("/"),L=N?`${N}/`:"",X=ae(`${L}${Mt.trim()}`);await a.rename(w,X).then(async be=>{be.success&&(Z.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await We(N),l&&Et(l,w),(d?.path===w||d?.path.startsWith(`${w}/`))&&(l&&De(l,null),Ne(""),we(null),tt(""),ve(null),u&&Y(!1))),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}if(Bt==="delete"){if(!a.delete){c(t("sidebarFilesTree.toast.deleteNotSupported")),g();return}const w=_t.path,N=w.split("/").slice(0,-1).join("/");await a.delete(w).then(async L=>{L.success&&(Z.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await We(N),l&&Et(l,w),(d?.path===w||d?.path.startsWith(`${w}/`))&&(l&&De(l,null),Ne(""),we(null),tt(""),ve(null),u&&Y(!1))),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}g()},[Bt,_t,Mt,a,We,u,Et,l,d?.path,De,t]);i.useEffect(()=>{if(!j){ss([]),rs(!1);return}const n=se.trim();if(!n){ss([]),rs(!1);return}let o=!1;return rs(!0),I(j,n,150,{includeHidden:b,respectGitignore:!F,type:"file"}).then(c=>{if(o)return;const w=c.filter(N=>F||!Hf(N.path)).map(N=>({name:N.name,path:ae(N.path),type:"file",extension:N.extension,relativePath:N.relativePath}));ss(w)}).catch(()=>{o||ss([])}).finally(()=>{o||rs(!1)}),()=>{o=!0}},[j,se,I,b,F]);const xs=i.useCallback(async(n,o)=>{const c=mt(n);if(a.readFile)return(await a.readFile(n,{...c,directory:l||void 0,...o})).content??"";const g=new URLSearchParams({path:n});c.allowOutsideWorkspace&&g.set("allowOutsideWorkspace","true"),l&&g.set("directory",l);const w=await Wn(`/api/fs/read?${g.toString()}`,{cache:o?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!w.ok){const N=await w.json().catch(()=>({error:w.statusText}));throw new Error(N.error||t("filesView.error.readFileFailed"))}return w.text()},[a,mt,l,t]),vt=i.useCallback(async n=>{if(a.statFile){const o=mt(n),c=await a.statFile(n,{...o,directory:l||void 0});return{path:c.path,size:c.size,mtimeMs:c.mtimeMs}}return null},[a,mt,l]);i.useEffect(()=>{if(!l||!a.statFile||Pe.length===0)return;let n=!1;const o=[...Pe];return Promise.all(o.map(async c=>{try{const g=mt(c),w=await a.statFile?.(c,{...g,directory:l||void 0});!n&&w&&!w.isFile&&Et(l,c)}catch(g){!n&&Da(g)&&Et(l,c)}})),()=>{n=!0}},[a,Pe,Et,mt,l]);const Ue=oe!==G||Fn,Dt=i.useCallback((n,o=!0)=>{const{content:c,lineEnding:g}=Ld(n);return o&&Or(wt.current)&&Xn(w=>w+1),er.current=n,tr.current+=1,Ko(g),Ne(c),Tt.current=c,Nn.current=c,Fe(c),c},[]),yt=i.useCallback(async()=>{if(!d||!a.writeFile)return Z.error(t("filesView.toast.savingNotSupported")),!1;const n=(_n(d.path)||It)&&!En.current;if(!Vd({selectedFilePath:d.path,loadedFilePath:fe,fileLoading:Ve,isDirty:Ue,draftContent:oe,fileContent:G,isNonEditableBinary:n}))return n?console.warn(`[saveDraft] refusing to save binary file "${d.path}".`):oe===""&&G!==""&&fe!==d.path&&console.warn(`[saveDraft] refusing to save empty draft for "${d.path}" (${G.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(!Ue)return!0;Zs(!0);try{const o=Fn?en.current:null;Fn&&!o&&pt(!1);const c=o?await o.getContent("save"):Ar;if(!c.ok)return Z.error(c.message),!1;const g=c.snapshot;if(g&&"bytes"in g){if(!a.uploadFile)return Z.error(t("filesView.toast.savingNotSupported")),!1;if(nt.current=null,!(await a.uploadFile(d.path,new Blob([g.bytes]),{overwrite:!0}))?.success)return Z.error(t("filesView.toast.writeFileFailed")),!1;en.current?.markSaved(g.signature)}else{const w=zd(g?g.content:oe,ai);if(!(await a.writeFile(d.path,w))?.success)return Z.error(t("filesView.toast.writeFileFailed")),!1;g?(Dt(w,!1),en.current?.markSaved(g.signature)):(Ne(oe),er.current=w,tr.current+=1)}if(l&&Hn(d.path,l)){const w=Bs(l,d.path);w&&Gc.requestGitRefresh({directory:l,paths:[w]})}if(l&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(ae(d.path))){const w=Xc.getState().projects.find(N=>ae(N.path)===ae(l));if(w)try{await Ou(w.id)}catch{Z.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return d?.path&&$n(d.path)&&(Tt.current=oe,Nn.current=oe),vt(d.path).then(w=>{w&&(nt.current=w)}).catch(()=>{}),!0}catch(o){return Z.error(o instanceof Error?o.message:t("filesView.toast.saveFailed")),!1}finally{Zs(!1)}},[Dt,It,oe,Fn,G,Ve,a,Ue,ai,fe,vt,l,d,t]);li.current=yt,i.useEffect(()=>{Ae||(sn("idle"),ht.current&&(clearTimeout(ht.current),ht.current=null))},[Ae]);const ws=1500;i.useEffect(()=>{const n=!!(d&&a.writeFile),o=!!(d?.path&&(_n(d.path)||It))&&!En.current;if(!Dd({autoSaveEnabled:Ae,isDirty:Ue,canWrite:n,isSaving:Qt,fileLoading:Ve,selectedFilePath:d?.path,loadedFilePath:fe,isNonEditableBinary:o,wouldEmptyFile:oe===""&&G!==""}))return;const c=g=>{ht.current=setTimeout(()=>{const w=Date.now()-fi.current;if(w<ws){c(ws-w);return}yt().then(N=>{N&&(sn("saved"),setTimeout(()=>sn("idle"),2e3))})},g)};return c(ws),()=>{ht.current&&(clearTimeout(ht.current),ht.current=null)}},[Ae,It,oe,G,Ve,Ue,fe,d,a.writeFile,Qt,yt]),i.useEffect(()=>{sn("idle")},[d?.path]);const $i=i.useCallback(()=>{ht.current&&(clearTimeout(ht.current),ht.current=null),Qt||yt().then(n=>{n&&(sn("saved"),setTimeout(()=>sn("idle"),2e3))})},[Qt,yt]);Yc({save_file:n=>{if(!(n.target instanceof Node)||!Dn.current?.contains(n.target)&&!di.current?.contains(n.target))return!1;$i()},find_in_file:n=>{if(!(n.target instanceof Node))return!1;if(it&&Ke()==="preview"){if(u||!(te?ds.current:cs.current)?.contains(n.target))return!1;ls(!0),wi(c=>c+1);return}if(!Dn.current?.contains(n.target))return!1;Xe(!0)}});const Wi=i.useCallback(async n=>{const o=tn.current+1;tn.current=o;const c=ut(),g=k.current,w=()=>{if(!l||ut()!==c||k.current!==g)return!1;const W=at.getState().byRoot[l],pe=W?.selectedPath??W?.openPaths[0]??null;return tn.current===o&&pe===n.path};we(null),tt(""),ve(null),ui(!1),kt(!0);const N=Tr(n.path),L=Mr(n.path),X=za(n.path),be=_n(n.path);if(u&&Y(!0),m.isDesktop&&N&&!L){Ne(""),Fe("");return}if(!m.isDesktop&&N&&!L){Ne(""),Fe(""),ve(n.path),kt(!1);return}if(X){Ne(""),Fe(""),ve(n.path),kt(!1);return}if(be){Ne(""),Fe(""),ve(n.path),kt(!1);return}await xs(n.path).then(W=>{if(!w())return;if(Ia(W)){ui(!0),Ne(""),Fe(""),ve(n.path);return}const pe=Dt(W),Ht=Ir(n.path)||zs(n.path)||co(n.path)||$n(n.path)||Mr(n.path)||Oa(n.path)||Ba(n.path)||Or(n.path);Ce(Ht?"edit":Id(pe,Yn.current[n.path])),ve(n.path),vt(n.path).then(gn=>{gn&&w()&&(nt.current=gn)}).catch(()=>{})}).catch(W=>{if(w()){if(Kf(W)){if(kt(!1),l&&De(l,null),we(null),Ne(""),Fe(""),ve(null),nt.current=null,B.trim().length>0&&K(""),u&&Y(!1),l){const Ht=[...oo(n.path,l),n.path];Ht.length>0&&es(l,Ht);for(const gn of Ht)et.current.has(gn)||Be(gn)}return}if(Da(W)){l&&Et(l,n.path),Ne(""),Fe(""),we(null),nt.current=null,u&&Y(!1);return}Ne(""),Fe(""),we(W instanceof Error?W.message:t("filesView.error.readFileFailed")),nt.current=null}}).finally(()=>{w()&&kt(!1)})},[Dt,es,u,Be,xs,vt,Et,l,m.isDesktop,B,De,t]),bs=i.useCallback(async(n,o)=>{if(!e||!l)return;const c=oo(n,l),g=o?[...c,n]:c;if(g.length>0&&es(l,g),!T)return;const w=g.map(N=>{if(!et.current.has(N))return Be(N)}).filter(Boolean);await Promise.all(w)},[es,Be,l,T,e]),Ui=i.useCallback((n,o)=>{const c=o.findIndex(g=>g.path===n);return c===-1||o.length<=1?null:o[c+1]??o[c-1]??null},[]),_e=i.useCallback(async n=>{if(Tn.current)Tn.current=!1;else if(Ue){kn(!0),rn.current=n;return}l&&(De(l,n.path),bs(n.path,!1)),we(null),tt(""),Ne(""),Tt.current="",Nn.current="",pt(!1),Fe(""),ve(null),u&&Y(!0)},[bs,Ue,u,l,De]);i.useEffect(()=>{d?.path&&bs(d.path,!1)},[bs,d?.path]),i.useEffect(()=>{if(!e)return;if(!d){tn.current+=1,zt.current=null,kt(!1);return}if(fe===d.path||zt.current===d.path)return;const n=d.path;zt.current=n,Wi(d).finally(()=>{zt.current===n&&(zt.current=null)})},[nn,Wi,fe,d,e]);const ys=i.useRef(Ue);ys.current=Ue,i.useEffect(()=>Bu(({runtimeKey:n,paths:o})=>{const c=d?.path;n!==ut()||!c||ys.current||!o.includes(ae(c))||(tn.current+=1,zt.current=null,nt.current=null,tt(""),we(null),ve(null),Go(g=>g+1))}),[d?.path]),i.useEffect(()=>{if(!e||!d?.path||fe!==d.path)return;const n=d.path,o=ut(),c=k.current,g=()=>ys.current||$n(n)&&Tt.current!==Nn.current,w=!_n(n)&&!Tr(n)&&!It?kd({readContent:()=>xs(n,{fresh:!0}),getLoadedContent:()=>er.current,getLoadedRevision:()=>tr.current,isDirty:g,applyContent:W=>{if(!(N||ut()!==o||k.current!==c)){if(Ia(W)){ve(null);return}Dt(W)}}}):null;let N=!1,L=!1;const X=()=>{document.hidden||L||(L=!0,vt(n).then(async W=>{if(N||ut()!==o||k.current!==c||!W)return;const pe=nt.current;if(!pe||pe.path!==n){nt.current=W;return}if(Td(pe,W)){if(w&&W.size<=qf){await w.poll()&&!N&&(nt.current=W);return}ys.current||(nt.current=W,ve(null))}}).catch(()=>{}).finally(()=>{L=!1}))};X();const be=window.setInterval(X,2e3);return()=>{N=!0,w?.dispose(),window.clearInterval(be)}},[Dt,It,fe,xs,vt,d?.path,e]);const bl=i.useCallback(()=>{const n=rn.current,o=Rn.current;if(rn.current=null,Rn.current=null,Tn.current=!0,kn(!1),pt(!1),Xn(c=>c+1),Fe(G),o){l&&Yt(l,o),d?.path===o&&(n?_e(n):(l&&De(l,null),Ne(""),we(null),tt(""),ve(null),u&&Y(!1)));return}if(n){_e(n);return}},[G,_e,u,Yt,l,d?.path,De]),yl=i.useCallback(async()=>{const n=rn.current,o=Rn.current;if(!await yt()){Tn.current=!1;return}if(rn.current=null,Rn.current=null,Tn.current=!0,kn(!1),o){l&&Yt(l,o),d?.path===o&&(n?await _e(n):(l&&De(l,null),Ne(""),we(null),tt(""),ve(null),u&&Y(!1)));return}if(n){await _e(n);return}},[_e,u,Yt,l,yt,d?.path,De]),Ln=i.useCallback(n=>{const o=d?.path===n,c=Ui(n,Zt);if(o&&Ue){kn(!0),rn.current=c,Rn.current=n;return}if(l&&Yt(l,n),!!o){if(c){_e(c);return}l&&De(l,null),Ne(""),we(null),tt(""),ve(null),u&&Y(!1)}},[Ui,_e,Ue,u,Zt,Yt,l,d?.path,De]),Hi=i.useRef(Ln);i.useEffect(()=>{Hi.current=Ln},[Ln]);const ur=d?.path??null;i.useEffect(()=>{if(!(!e||!ur))return zf(()=>Hi.current(ur))},[ur,e]);const Ki=i.useMemo(()=>new Set(Pe),[Pe]),Cs=i.useMemo(()=>Tu(M?H?.files??[]:[]),[H?.files,M]),Cl=i.useCallback(n=>{if(Ki.has(n))return"open";const o=n.startsWith(l+"/")?n.slice(l.length+1):n;return Cs.statusByPath.get(o)??null},[Ki,Cs,l]),jl=i.useCallback(n=>{if(!H?.files)return null;const o=n.startsWith(l+"/")?n.slice(l.length+1):n;return Cs.badgeByDir.get(o)??null},[H,Cs,l]),Sl=i.useCallback(async n=>{const o=ae(n);l&&(ei(l,o),et.current.has(o)||await Be(o))},[Be,l,ei]),Nl=i.useMemo(()=>({canRename:Ci,canCreateFile:bi,canCreateFolder:yi,canDelete:ji,canReveal:Si}),[Ci,bi,yi,ji,Si]);function qi(n,o){const c=ri[n]??[];return c.map((g,w)=>{const N=g.type==="directory",L=N&&Bo.has(g.path),X=d?.path===g.path,be=w===c.length-1;return s.jsxs("li",{className:"relative",children:[o>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),be&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Gf,{node:g,root:l,isExpanded:L,isActive:X,isMobile:u,isBrowserClient:C,alwaysShowActions:R,status:N?void 0:Cl(g.path),badge:N?jl(g.path):void 0,permissions:Nl,downloadFile:a.downloadFile,contextMenuPath:nl,setContextMenuPath:sl,rightClickMenuPath:rl,setRightClickMenuPath:il,onSelect:_e,onToggle:Sl,onRevealPath:fl,onOpenDialog:or,canUpload:zi&&!vs,onPickFiles:Ii}),N&&L&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[ns[g.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:ns[g.path],children:ns[g.path]}),s.jsxs(U,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{We(g.path)},children:[s.jsx(P,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):null,qi(g.path,o+1)]})]},g.path)})}const He=!!(d?.path&&Tr(d.path)),st=!!(d?.path&&Mr(d.path)),Gi=st&&xe==="edit",Vt=!!(d?.path&&za(d.path)),Xi=!!(d?.path&&Jc(d.path)),dr=Xi||!!(d?.path&&Zc(d.path)),fr=!!(d?.path&&Qc(d.path)),js=!!(d?.path&&(_n(d.path)||It)),cn=js&&!He&&!Vt&&!dr&&!fr,Yi=js||He&&!Gi,Ji=i.useMemo(()=>ae(gt?.path??""),[gt?.path]),un=!!(gt&&Ji&&Ie&&Ie===Ji&&!Ve&&!ot&&!Yi),Ct=i.useMemo(()=>Bs(l,Ie),[Ie,l]),Fl=!!(d&&(!He||st)&&!Vt&&!cn&&G.length>0),El=!!(d&&Ct.length>0),rt=!!(d&&!ts&&!js&&(!He||st)&&a.writeFile),mr=!!(d&&!js&&(!He||st)),hr=Hd(d?.path),ze=hr&&(mr||hr.editor.content==="binary")?hr:null,jt=ze!==null,kl=eu(),zn=ze?.editor.content==="binary";En.current=zn;const it=!jt&&!!(d?.path&&Ir(d.path)),dn=!jt&&!!(d?.path&&co(d.path)),$t=!jt&&!!(d?.path&&zs(d.path)),In=!jt&&!kl&&!!(d?.path&&$n(d.path)),fn=!jt&&!!(d?.path&&Oa(d.path)),mn=!jt&&!!(d?.path&&Ba(d.path)),hn=jt,On=jt&&(zn?Qe===null||Qe<=_r:oe.length<=_r),Rl=Kr(n=>n.status),Tl=!jt&&mr&&Rl!=="unsupported"&&!!(d?.path&&tu(d.path)),Ss=mr&&!it&&!In&&!hn&&!($t&&_==="preview")&&!(st&&xe==="preview")&&!(fn&&ge==="preview")&&!(mn&&ee==="table"),Ml=it&&Te==="edit"||$t&&_==="edit"||hn&&(he==="edit"||!On)||st&&xe==="edit"||fn&&ge==="edit"||mn&&ee==="text"||dn&&de==="text"||!it&&!$t&&!dn&&!hn&&!st&&!fn&&!mn&&re==="edit",Ns=i.useMemo(()=>Ie?nu(Ie):null,[Ie]),[Zi,pr]=i.useState(null);i.useEffect(()=>{let n=!1;const o=d?.path;if(!o||Ns){pr(null);return}return pr(null),su(o).then(c=>{n||pr(c)}),()=>{n=!0}},[d?.path,Ns]),i.useEffect(()=>{!rt&&re==="edit"&&Ce("view")},[rt,re]);const gr="openchamber:files:md-viewer-mode",vr="openchamber:files:html-viewer-mode",xr="openchamber:files:json-viewer-mode";i.useEffect(()=>{const n=d?.path;if(!n)return;Ce(Yn.current[n]??"edit");let o=Vn?"preview":"edit";try{const w=localStorage.getItem(gr);(w==="preview"||w==="edit")&&(o=w)}catch{}je(Hs.current[n]??o);let c=Vn?"preview":"edit";try{const w=localStorage.getItem(vr);(w==="preview"||w==="edit")&&(c=w)}catch{}q(Ks.current[n]??c),ce(qs.current[n]??(Vn?"preview":"edit")),le(jn.current[n]??"preview"),Se(Yr.current[n]??"preview"),Je(Jr.current[n]??"preview"),Ze(Zr.current[n]??"table");let g=Vn?"tree":"text";try{const w=localStorage.getItem(xr);(w==="tree"||w==="text")&&(g=w)}catch{}Me(g)},[d?.path,Vn]);const Pl=i.useCallback(n=>{const o=d?.path;o&&(Yn.current[o]=n),Ce(n)},[d?.path]),Dl=i.useCallback(n=>{const o=d?.path;o&&(Hs.current[o]=n),je(n);try{localStorage.setItem(gr,n)}catch{}},[d?.path]),Ke=i.useCallback(()=>Te,[Te]),Vl=i.useCallback(n=>{const o=d?.path;o&&(Yr.current[o]=n),Se(n)},[d?.path]),Al=i.useCallback(n=>{const o=d?.path;o&&(Jr.current[o]=n),Je(n)},[d?.path]),Ll=i.useCallback(n=>{const o=d?.path;o&&(Zr.current[o]=n),Ze(n)},[d?.path]);i.useEffect(()=>{const n=d?.path;if(Xr(null),!n||fe!==n)return;let o=!1;return vt(n).then(c=>{!o&&c&&Xr(c.size)}).catch(()=>{}),()=>{o=!0}},[nn,fe,vt,d?.path]);const Qi=d&&it&&Ke()==="preview"&&!Ve?d.path:null;i.useEffect(()=>{!Qi||u||us()},[us,te,u,Qi]);const zl=i.useCallback(n=>{Me(n);try{localStorage.setItem(xr,n)}catch{}},[]),Il=i.useCallback(n=>{const o=d?.path;o&&(Ks.current[o]=n),q(n);try{localStorage.setItem(vr,n)}catch{}},[d?.path]),Ol=i.useCallback(n=>{const o=d?.path;if(o&&(qs.current[o]=n),$e.current&&(clearTimeout($e.current),$e.current=null),bt.current!==null&&(cancelAnimationFrame(bt.current),bt.current=null),n==="edit")Fe(Tt.current||G),ce(n);else{Tt.current=oe;const c=o;ce("edit"),bt.current=requestAnimationFrame(()=>{bt.current=requestAnimationFrame(()=>{bt.current=null,!(l&&c&&at.getState().byRoot[l]?.selectedPath!==c)&&(Io(g=>g+1),ce("preview"))})});return}},[oe,G,l,d?.path]),Bl=i.useCallback(n=>{const o=d?.path,c=()=>{o&&(jn.current[o]=n)};if(n==="edit"){if(!Qs.current){c(),pt(!1),le(n);return}Promise.resolve(en.current?.getContent("handoff")??Ar).then(w=>{if(wt.current===o){if(!w.ok){Z.error(w.message);return}c(),Fe(w.snapshot&&"content"in w.snapshot?w.snapshot.content:G),pt(!1),le(n)}});return}if(!On){ze&&Z.error(t("filesView.fileEditor.tooLarge",{editor:ze.editor.title}));return}c(),pt(!1);const g=o;Lt.current!==null&&cancelAnimationFrame(Lt.current),Lt.current=requestAnimationFrame(()=>{Lt.current=null,!(l&&g&&at.getState().byRoot[l]?.selectedPath!==g)&&(Xn(w=>w+1),le("preview"))})},[On,G,ze,l,d?.path,t]),wr=i.useCallback(async(n,o)=>{if(!a.writeFile||o===Nn.current)return!1;if(!(await a.writeFile(n,o))?.success)return Z.error(t("filesView.toast.writeFileFailed")),!1;Dt(o);const g=await vt(n).catch(()=>null);return g&&(nt.current=g),!0},[Dt,a,vt,t]);i.useEffect(()=>()=>{$e.current&&(clearTimeout($e.current),$e.current=null),bt.current!==null&&(cancelAnimationFrame(bt.current),bt.current=null)},[Q,d?.path]);const _l=i.useCallback(n=>{if(Tt.current=n,!Ae||!d?.path||Q!=="preview"||!a.writeFile)return;$e.current&&clearTimeout($e.current);const o=d.path;$e.current=setTimeout(()=>{$e.current=null,wr(o,n).then(c=>{c&&(as(!0),setTimeout(()=>as(!1),1500))}).catch(c=>{Z.error(c instanceof Error?c.message:t("filesView.toast.saveFailed"))})},ws)},[Ae,Q,a.writeFile,wr,d?.path,t]),$l=i.useMemo(()=>In&&(Tt.current||oe)||G,[oe,G,In]),Wl=i.useCallback(()=>{const n=wt.current;n&&(jn.current[n]="edit"),pt(!1),le("edit"),ze&&Z.error(t("filesView.fileEditor.unsupported",{editor:ze.editor.title}))},[ze,t]);i.useEffect(()=>()=>{Lt.current!==null&&(cancelAnimationFrame(Lt.current),Lt.current=null)},[he,d?.path]);const ea=i.useCallback(()=>_,[_]);i.useEffect(()=>{const n=c=>{const g=c?"preview":"edit",w=c?"tree":"text";for(const N of Pe)Yn.current[N]="edit",Ir(N)&&(Hs.current[N]=g),zs(N)&&(Ks.current[N]=g),$n(N)&&(qs.current[N]=g),Or(N)&&(jn.current[N]=g);Ce("edit"),je(g),q(g),ce(g),le(g),Me(w);try{localStorage.setItem(gr,g),localStorage.setItem(vr,g),localStorage.setItem(xr,w)}catch{}},o=c=>{const g=!!c.detail?.enabled;n(g)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",o),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",o)}},[Pe]),i.useEffect(()=>{if(!gt||!l)return;const n=()=>{typeof window>"u"||an.current===null&&(an.current=window.requestAnimationFrame(()=>{an.current=null,sr(Nt=>Nt+1)}))},o=(Nt,Kt)=>{if(Nt.state.doc.length!==Kt.length)return!1;if(Kt.length===0)return!0;const Er=Math.min(128,Kt.length);if(Nt.state.sliceDoc(0,Er)!==Kt.slice(0,Er))return!1;const Pa=Math.max(0,Kt.length-Er);return Nt.state.sliceDoc(Pa,Kt.length)===Kt.slice(Pa)},c=ae(gt.path);if(!c){fs(null),Ot.current={key:"",attempts:0};return}const g=`${c}:${gt.line}:${gt.column??1}`;if(Ot.current.key!==g&&(Ot.current={key:g,attempts:0}),d?.path!==c){if(nr)return;_e(Jt(c));return}if(Ve||fe!==c)return;if(ot||He||Vt||cn){fs(null),Ot.current={key:"",attempts:0};return}if(!rt)return;if(re!=="edit"){Ce("edit");return}const w=Le.current;if(!w){n();return}if(!o(w,oe)){n();return}const N=Math.max(1,Math.min(gt.line,w.state.doc.lines)),L=w.state.doc.line(N),X=Math.max(1,gt.column||1),be=Math.max(0,L.to-L.from),W=Math.min(be,X-1),pe=L.from+W;if(!(w.state.selection.main.head===pe)||Ot.current.attempts===0){Ot.current.attempts+=1,w.dispatch({selection:{anchor:pe},effects:dt.scrollIntoView(pe,{y:"center"})}),w.focus(),n();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const Nt=Le.current;Nt&&(Nt.dispatch({selection:{anchor:pe},effects:dt.scrollIntoView(pe,{y:"center"})}),Nt.focus())}),fs(null),Ot.current={key:"",attempts:0}},[rt,nr,oe,Qo,ot,Ve,He,Vt,cn,fe,_e,gt,l,d?.path,fs,re,Jt]),i.useEffect(()=>{if(!lr||!l)return;const n=ae(lr);if(!n){cr(null);return}d?.path===n&&(Ve||fe!==n||(!ot&&!He&&!Vt&&!cn&&rt&&re==="edit"&&Le.current?.focus(),cr(null)))},[rt,ot,Ve,He,Vt,cn,fe,lr,l,d?.path,cr,re]);const pn=i.useCallback(n=>{if(!u||!n||typeof window>"u")return;const o=document.activeElement,c=!n.hasFocus&&o instanceof HTMLElement&&n.dom.contains(o)?o.closest('[data-comment-input="true"]'):null;if(!n.hasFocus&&!c)return;const g=window.visualViewport;if(!g)return;const w=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,w-(g.offsetTop+g.height))<=0)return;const L=c?c.getBoundingClientRect():n.coordsAtPos(n.state.selection.main.head);if(!L)return;const X=Math.round(g.offsetTop+g.height),W=L.bottom+20-X;W<=0||(n.scrollDOM.scrollTop+=W)},[u]);i.useEffect(()=>{if(!u||typeof window>"u")return;const n=()=>{window.requestAnimationFrame(()=>{pn(Le.current)})},o=window.visualViewport;return o?.addEventListener("resize",n),o?.addEventListener("scroll",n,{passive:!0}),document.addEventListener("selectionchange",n),()=>{o?.removeEventListener("resize",n),o?.removeEventListener("scroll",n),document.removeEventListener("selectionchange",n)}},[u,pn]),_a("open_go_to_line",n=>{if(!rt||re!=="edit"||u)return!1;const o=n.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Dn.current?.contains(o))return!1;const c=!!o?.closest(".cm-editor");if(!!o?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!c)return!1;ar(!0)}),_a("open_document_symbols",n=>{if(!rt||re!=="edit"||u)return!1;const o=n.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Dn.current?.contains(o))return!1;os(!0)});const Wt=ct(n=>n.editorFontSize),ta=i.useMemo(()=>({"--text-markdown":`${Wt+1}px`,"--text-code":`${Wt-1}px`}),[Wt]),xt=d?.path&&l&&d.path.startsWith(`${l}/`)?d.path.slice(l.length+1):null,na=kr(n=>{if(!xt||!l)return null;const o=n.directories.get(j)?.status,c=o?.files.find(g=>g.path===xt)??null;return JSON.stringify([xt,o?.current??null,c])}),[br,yr]=i.useState(null);i.useEffect(()=>{if(!xt||!l||!na){yr(null);return}let n=!1;return f.getGitFileDiff(l,{path:xt}).then(o=>{if(n)return;const c=kr.getState().directories.get(j)?.status?.files.find(N=>N.path===xt),g=c!==void 0&&(c.index==="?"||c.index==="A"||c.working_dir==="?"),w=!o.isBinary&&!o.submodule&&(o.original!==""||g);yr({path:xt,text:w?o.original:null})}).catch(()=>{n||yr({path:xt,text:null})}),()=>{n=!0}},[j,f,na,l]);const sa=i.useRef(br);sa.current=br;const Fs=i.useCallback(n=>{if(!n)return;const o=sa.current;af(n,o&&o.path===xt?o.text:null)},[xt]);i.useEffect(()=>{Fs(Le.current)},[Fs,br]);const ra=i.useRef(()=>{});ra.current=()=>{if(!d?.path||!l)return;const n=wc(l),o=ct.getState(),c=o.contextPanelByDirectory[n]?.tabs.find(g=>g.preview&&g.targetPath===d.path);c&&o.pinContextPanelTab(n,c.id)};const ia=i.useMemo(()=>dt.updateListener.of(n=>{if(!n.docChanged)return;n.transactions.some(c=>c.isUserEvent("input")||c.isUserEvent("delete")||c.isUserEvent("undo")||c.isUserEvent("redo")||c.isUserEvent("move"))&&ra.current()}),[]),aa=i.useMemo(()=>{if(!d?.path)return[$a(p,{fontSize:Wt})];const n=Rr(d.path),o=[$a(p,n?{syntaxColors:!1,fontSize:Wt}:{fontSize:Wt})],c=Ns??Zi;c&&o.push(c),n&&o.push(hu({language:n,themeName:p.metadata.id,theme:Au(p)})),ue&&o.push(dt.lineWrapping);const g=p.colors.syntax.highlights;return o.push(rf({added:g?.diffAdded??p.colors.status.success,modified:g?.diffModified??p.colors.status.info,removed:g?.diffRemoved??p.colors.status.error}),Hu({highlightWordAroundCursor:!0,minSelectionLength:2}),ia,Yd()),u||o.push(Xd(),Jd({vimMode:ms==="vim"})),u&&o.push(dt.updateListener.of(w=>{w.view.hasFocus&&(w.selectionSet||w.focusChanged||w.viewportChanged||w.geometryChanged)&&window.requestAnimationFrame(()=>{pn(w.view)})})),o},[p,d?.path,Ns,Zi,ue,u,pn,Wt,ia,ms]),oa=i.useMemo(()=>({light:Jn.metadata.id,dark:Zn.metadata.id}),[Jn.metadata.id,Zn.metadata.id]),la=Vt||dr||fr,Bn=d?.path&&la?`${d.path}|${Xs.allowOutsideWorkspace?"outside":"workspace"}|${nn}`:"",Ul=i.useMemo(()=>d?.path&&$t&&_==="preview"&&!m.isVSCode?{path:d.path,directory:l||"",revision:String(nn)}:null,[d?.path,$t,_,m.isVSCode,l,nn]),ca=t("filesView.error.readFileFailed"),Ut=Af(Ul,ca);i.useEffect(()=>{Ut.status==="error"?we(Ut.message):Ut.status==="ready"&&we(null)},[Ut,we]);const{readyKey:ua,nonce:Es}=Jf(Bn,we,ca),Cr=!!(Bn&&ua!==Bn),Hl=d?.path&&He?st?`data:${ru(d.path)};utf8,${encodeURIComponent(G)}`:Ho:"",ks=d?.path&&la&&Bn&&ua===Bn?fo().authenticatedAsset(bc("/api/fs/raw",l),{path:d.path,allowOutsideWorkspace:Xs.allowOutsideWorkspace?"true":void 0,directory:l||void 0}):"",Kl=i.useCallback(n=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:ks,className:"h-full w-full border-0",title:n.name},Es)}),[ks,Es]),da=d&&a.downloadFile?s.jsxs(U,{type:"button",variant:"outline",size:"sm",onClick:()=>{const n=a.downloadFile;!n||!d||n(d.path).catch(o=>{console.error("Download failed:",o),Z.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(P,{name:"download",className:"mr-2 size-4"}),t("filesView.editor.saveFile")]}):null,Rs=d&&!Ve&&!Cr&&!ot?(n=>He&&!Gi?s.jsx(wf,{src:Hl,name:n.name,sizeBytes:Qe}):Vt?Kl(n):dr?s.jsx(bf,{kind:Xi?"video":"audio",src:ks,name:n.name,sizeBytes:Qe,download:da},Es):fr?s.jsx(ff,{src:ks,name:n.name,sizeBytes:Qe},Es):cn?s.jsx(cf,{name:n.name,path:n.path,sizeBytes:Qe,download:da}):mn&&ee==="table"?s.jsx(Sf,{path:n.path,content:G,sizeBytes:Qe}):fn&&ge==="preview"?s.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:s.jsx(Ps,{fallback:s.jsxs("div",{className:"m-3 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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx(Dr,{content:`\`\`\`mermaid
|
|
16
|
-
${G}
|
|
17
|
-
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(d):null;i.useEffect(()=>{let n=!1,o="";return(async()=>{if(!d?.path||!He||st){tt("");return}we(null);const g=mt(d.path);if(n)return;await(a.readFileBinary?a.readFileBinary(d.path,g).then(N=>N.dataUrl):(async()=>{const N=await Wn("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:d.path,allowOutsideWorkspace:g.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!N.ok)throw new Error(t("filesView.error.readFileFailed"));const L=await N.blob();return o=URL.createObjectURL(L),n?(URL.revokeObjectURL(o),o="",""):o})()).then(N=>{n||(tt(N),ve(d.path))}).catch(N=>{n||(tt(""),we(N instanceof Error?N.message:t("filesView.error.readFileFailed")),ve(null))}).finally(()=>{n||kt(!1)})})(),()=>{n=!0,o&&URL.revokeObjectURL(o)}},[nn,a,He,st,mt,l,d?.path,Xs,t]);const ql=i.useCallback(()=>rr(null),[]),Gl=i.useMemo(()=>ed({drafts:ki,editingDraftId:ps,commentText:hs,onTextChange:Ri,selection:ne,isDragging:Fi,fileLabel:d?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:n=>({start:n.startLine,end:n.endLine}),onSave:Ai,onCancel:()=>{lt(null),An()},onEdit:n=>{Di(n),lt({start:n.startLine,end:n.endLine})},onDelete:Vi}),[An,hs,Vi,ps,ki,Ai,Fi,ne,d?.path,Ri,Di]),fa=Xa(),ma=Xa(),Ts=!Ve&&!ot&&fe===Ie,jr=i.useMemo(()=>!!Ie&&$d({hasCanvas:hn,viewMode:he,previewReady:Ts,mountable:On}),[On,he,hn,Ts,Ie]),Ms=Ts&&Ss&&re==="view"&&!(dn&&de==="tree"),ha=Ts&&it&&Ke()==="preview",{setScroller:pa,restore:Xl}=Vs(Ms?`${Rt}:code`:null),{setScroller:ga,restore:Yl}=Vs(Ms?`${Rt}:code:fullscreen`:null),{setScroller:va}=Vs(ha?`${Rt}:markdown`:null),{setScroller:xa}=Vs(ha?`${Rt}:markdown:fullscreen`:null),{setScroller:wa}=fa,{setScroller:ba}=ma,Jl=i.useCallback(n=>{wa(n),pa(n)},[wa,pa]),Zl=i.useCallback(n=>{ba(n),ga(n)},[ba,ga]),[Ql,ec]=i.useState(null),[tc,nc]=i.useState(null),sc=i.useCallback(n=>{Ei.current=n,cs.current=n,ec(n),va(n)},[va]),rc=i.useCallback(n=>{ds.current=n,nc(n),xa(n)},[xa]),ya=i.useCallback(n=>{l&&ct.getState().openContextFile(l,n)},[l]),Ca=it&&Te==="preview"&&!Ve,ja=p.metadata.variant==="light"?"light":"dark";ro({container:Ql,filePath:d?.path??null,workspaceRoot:l||null,onOpenFile:ya,enabled:Ca,colorScheme:ja}),ro({container:tc,filePath:d?.path??null,workspaceRoot:l||null,onOpenFile:ya,enabled:Ca,colorScheme:ja});const Sr=_u("unified"),St=oe.length>ko,Nr=i.useMemo(()=>St&&Ms?Od(oe):void 0,[Ms,oe,St]),Sa=i.useCallback((n,o,c,g)=>{const w={name:n.name,contents:o,lang:Rr(n.path)||void 0},N=L=>s.jsx(Vu,{file:St&&Nr?{...w,cacheKey:`${n.path}:${Nr}`}:w,options:{disableFileHeader:!0,overflow:ue?"wrap":"scroll",theme:oa,themeType:p.metadata.variant==="dark"?"dark":"light",onPostRender:g},className:St?"block w-full":"block h-full w-full",style:St?void 0:{height:"100%"}},L);return St?s.jsx("div",{className:"h-full",children:s.jsx(Lu.Provider,{value:c.virtualizer,children:s.jsx(zu.Provider,{value:Sr,children:N(`${n.path}:${Sr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:N(n.path)})},[p.metadata.variant,St,Nr,oa,Sr,ue]),Na=({exitFullscreenOnly:n=!1,layout:o="floating"}={})=>{if(!d)return null;const c=o==="docked",g=iu(au("save_file")),w=c?"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",N=(L,X)=>s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:X})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:L})]});return s.jsxs("div",{className:w,children:[rt&&Ml&&s.jsxs(s.Fragment,{children:[Qt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(P,{name:"loader-4",className:"size-3.5 animate-spin"}),t("filesView.editor.saving")]}):Ae&&Xo==="saved"&&!Ue?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(P,{name:"check",className:"size-3.5"}),t("filesView.editor.saved")]}):Ue?N(t(Ae?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:g}),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{yt()},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:t(Ae?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:g}),"aria-label":t("filesView.editor.saveAria",{shortcut:g}),children:s.jsx(P,{name:"save-3",className:"size-4"})})):null,N(t(Ae?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Zo(!Ae),className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Ae?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(Ae?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":t(Ae?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Ae?s.jsx(P,{name:"file-check-fill",className:"size-4"}):s.jsx(P,{name:"file-check",className:"size-4"})}))]}),s.jsxs($r,{onOpenChange:Ye,children:[s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Wr,{asChild:!0,children:s.jsx(U,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.openInDesktopApp"),"aria-label":t("filesView.editor.openInDesktopApp"),children:s.jsx(P,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:t("filesView.editor.openInDesktopApp")})]}),s.jsxs(Ur,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[cl.map(L=>s.jsxs(Os,{className:"flex items-center gap-2",onClick:()=>{ml(L)},children:[s.jsx(Of,{label:L.label,iconDataUrl:L.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:L.label})]},L.id)),ul?s.jsxs(Os,{className:"flex items-center gap-2",onClick:()=>{dl(!0)},children:[s.jsx(P,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("filesView.editor.refreshApps")})]}):null]})]}),!Yi&&s.jsxs(s.Fragment,{children:[N(t(ue?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>$(!ue),className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",ue?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(ue?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(P,{name:"text-wrap",className:"size-4"})})),re==="edit"&&s.jsxs(s.Fragment,{children:[N(t("filesView.editor.findInFile"),s.jsx(U,{variant:"ghost",size:"sm",onClick:L=>{Xe(!Re),L.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.findInFile"),children:s.jsx(P,{name:"search",className:"size-4"})})),N(t("filesView.editor.goToLine"),s.jsx(U,{variant:"ghost",size:"sm",onClick:L=>{ar(X=>!X),L.currentTarget.blur()},"data-go-to-line-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.goToLine"),children:s.jsx(P,{name:"menu-fold-2",className:"size-4"})})),!u&&N(t("filesView.editor.symbols"),s.jsx(U,{variant:"ghost",size:"sm",onClick:L=>{os(X=>!X),L.currentTarget.blur()},"data-document-symbols-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":t("filesView.editor.symbols"),children:s.jsx(P,{name:"list-unordered",className:"size-4"})})),s.jsx(dd,{open:ll,onOpenChange:ar,view:Le.current,variant:"inline"})]})]}),Ss&&rt&&!dn&&!$t&&!st&&!fn&&!mn&&s.jsx(vn,{currentMode:re==="view"?"preview":"edit",onToggle:()=>{Pl(re==="view"?"edit":"view")}}),it&&N(t(Ke()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Dl(Ke()==="preview"?"edit":"preview"),className:J("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ke()==="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:t(Ke()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":t(Ke()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(P,{name:Ke()==="preview"?"eye":"eye-off",className:"size-4"})})),zs(d?.path??"")&&s.jsx(vn,{currentMode:ea(),onToggle:()=>{Il(ea()==="preview"?"edit":"preview")}}),st&&s.jsx(vn,{currentMode:xe,onToggle:()=>Vl(xe==="preview"?"edit":"preview")}),fn&&s.jsx(vn,{currentMode:ge,onToggle:()=>Al(ge==="preview"?"edit":"preview")}),mn&&N(t(ee==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Ll(ee==="table"?"text":"table"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:t(ee==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":t(ee==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:ee==="table"?s.jsx(P,{name:"code-sslash",className:"size-4"}):s.jsx(P,{name:"table-2",className:"size-4"})})),it&&Ke()==="preview"&&N(t("filesView.editor.findInFile"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{ls(!0),wi(L=>L+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.findInFile"),children:s.jsx(P,{name:"search",className:"size-4"})})),it&&Ke()==="preview"&&hl&&s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx(U,{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":t(is?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{is?Uo():G.trim()&&Wo(G)},children:s.jsx(P,{name:"volume-up",className:J("size-4",is&&"animate-pulse text-[var(--primary-text)]")})})}),s.jsx(Xt,{sideOffset:8,children:t(is?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),hn&&s.jsxs(s.Fragment,{children:[!zn&&s.jsx(vn,{currentMode:he,onToggle:()=>Bl(he==="preview"?"edit":"preview")}),he==="preview"&&s.jsx(U,{variant:"ghost",size:"sm",onClick:async()=>{await yt()&&(ci(!0),setTimeout(()=>ci(!1),1500))},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.fileEditor.save"),children:Jo?s.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(P,{name:"save-3",className:"size-4"})})]}),In&&s.jsxs(s.Fragment,{children:[s.jsx(vn,{currentMode:Q,onToggle:()=>Ol(Q==="preview"?"edit":"preview")}),Q==="preview"&&s.jsx(U,{variant:"ghost",size:"sm",onClick:async()=>{const L=oi.current?.getXml();if($e.current&&(clearTimeout($e.current),$e.current=null),d?.path&&L){if(!await wr(d.path,L))return;as(!0),setTimeout(()=>as(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.diagram.saveDiagram"),children:Yo?s.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(P,{name:"save-3",className:"size-4"})})]}),dn&&N(t(de==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>zl(de==="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:t(de==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:de==="tree"?s.jsx(P,{name:"code-sslash",className:"size-4"}):s.jsx(P,{name:"node-tree",className:"size-4"})})),Fl&&N(t("filesView.editor.copyFileContents"),s.jsx(U,{variant:"ghost",size:"sm",onClick:async()=>{(await _s(G)).ok?(hi(!0),Mn.current!==null&&window.clearTimeout(Mn.current),Mn.current=window.setTimeout(()=>{hi(!1)},1200)):Z.error(t("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.copyFileContents"),"aria-label":t("filesView.editor.copyFileContents"),children:al?s.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(P,{name:"clipboard",className:"size-4"})})),El&&N(t("filesView.editor.copyFilePathTitle",{path:Ct}),s.jsx(U,{variant:"ghost",size:"sm",onClick:async()=>{(await _s(Ct)).ok?(pi(!0),Pn.current!==null&&window.clearTimeout(Pn.current),Pn.current=window.setTimeout(()=>{pi(!1)},1200)):Z.error(t("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.copyFilePathTitle",{path:Ct}),"aria-label":t("filesView.editor.copyFilePathTitle",{path:Ct}),children:ol?s.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(P,{name:"file-copy-2",className:"size-4"})})),a.downloadFile&&N(t("filesView.editor.saveFile"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{const L=a.downloadFile;L&&L(d.path).catch(X=>{console.error("Download failed:",X),Z.error(t("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.saveFile"),"aria-label":t("filesView.editor.saveFile"),children:s.jsx(P,{name:"download",className:"size-4"})})),n?N(t("filesView.editor.exitFullscreen"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Ge(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.exitFullscreen"),"aria-label":t("filesView.editor.exitFullscreen"),children:s.jsx(P,{name:"fullscreen-exit",className:"size-4"})})):!u&&r==="full"&&N(t(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Ge(!te),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":t(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:te?s.jsx(P,{name:"fullscreen-exit",className:"size-4"}):s.jsx(P,{name:"fullscreen",className:"size-4"})}))]})},Fa=i.useRef(null);i.useEffect(()=>{fe&&(En.current&&Fa.current===fe&&Xn(n=>n+1),Fa.current=fe)},[fe]);const ic=i.useCallback(async()=>{const n=wt.current;if(!n)throw new Error("No file is open.");const o=mt(n),c=await Wn("/api/fs/raw",{signal:AbortSignal.timeout(6e4),cache:"no-store",query:{path:n,allowOutsideWorkspace:o.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!c.ok)throw new Error(t("filesView.error.readFileFailed"));return new Uint8Array(await c.arrayBuffer())},[mt,l,t]),Ea=i.useCallback(n=>{const o=wt.current;o&&(jn.current[o]="edit"),pt(!1),le("edit"),Z.error(n)},[]),ka=r==="full"&&te,ac=d?`${d.path}:${Oo}:${ka?"fullscreen":"docked"}`:"",Ra=jr&&d&&ze?s.jsx("div",{ref:di,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Wd,{ref:en,guestId:ze.guestId,editorId:ze.editor.id,title:ze.editor.title,contentKind:zn?"binary":"text",path:Ct||d.path,content:oe,loadBytes:ic,readOnly:!d||ts||!a.writeFile||zn&&!a.uploadFile,onDirtyChange:pt,onEdit:()=>{fi.current=Date.now()},onSaveRequest:$i,onUnsupported:Wl,onTooLarge:()=>Ea(t("filesView.fileEditor.tooLarge",{editor:ze.editor.title})),onLoadFailed:()=>Ea(t("filesView.error.readFileFailed"))},`${ac}:${ze.guestId}:${ze.editor.id}`)}):null,oc=i.useCallback(()=>{const n=ct.getState();n.requestSettingsJump("integrations","integrations.extensions.excalidraw"),n.setSettingsDialogOpen(!0)},[]),Fr=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(po,{open:nr,onOpenChange:n=>{n||kn(!0)},children:s.jsxs(go,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(vo,{children:[s.jsx(xo,{children:t("filesView.unsaved.title")}),s.jsx(wo,{children:t("filesView.unsaved.description")})]}),s.jsxs(bo,{children:[s.jsx(U,{variant:"outline",onClick:()=>{yl()},disabled:Qt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:t("filesView.unsaved.saveChanges")}),s.jsx(U,{variant:"destructive",onClick:bl,children:t("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:J("flex flex-col flex-shrink-0",E&&"border-b border-border/40"),children:[E?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[u&&me&&s.jsx("button",{type:"button",onClick:()=>Y(!1),"aria-label":t("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-ring",children:s.jsx(P,{name:"arrow-left-s",className:"size-5"})}),u?d?s.jsxs($r,{children:[s.jsx(Wr,{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":t("filesView.editor.openFilesAria"),children:[s.jsx(Un,{filePath:d.path,extension:d.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(lo,{name:d.name}),s.jsx(P,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(Ur,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Zt.map(n=>{const o=d?.path===n.path;return s.jsxs(Os,{onSelect:c=>{if(c.target.closest("[data-close-open-file]")){c.preventDefault();return}o||_e(n)},className:J("flex min-w-0 items-center justify-between gap-2 overflow-hidden",o&&"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(Un,{filePath:n.path,extension:n.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(lo,{name:n.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),Ln(n.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":t("filesView.editor.closeFileAria",{name:n.name}),children:s.jsx(P,{name:"close",className:"size-3.5"})})]},n.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")}):Zt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[ti.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"}),ti.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:Ys,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Zt.map(n=>{const o=d?.path===n.path;return s.jsxs("div",{title:Bs(l,n.path),className:J("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",o?"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(Un,{filePath:n.path,extension:n.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{o||_e(n)},className:"max-w-[12rem] truncate text-left",children:n.name}),s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),Ln(n.path)},className:J("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!o&&!R&&"opacity-0 group-hover:opacity-100"),"aria-label":t("filesView.editor.closeFileAria",{name:n.name}),children:s.jsx(P,{name:"close",className:"size-3.5"})})]},n.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")})]}):null,d?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:[Ct&&!u?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:Ct,children:Ct}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Na({layout:"docked"})})]}):null]}),Tl?s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border/40 bg-[var(--surface-muted)] px-3 py-1.5 typography-ui text-muted-foreground",children:[s.jsx(P,{name:"information",className:"size-4 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t("filesView.excalidraw.installHint")}),s.jsx(U,{type:"button",size:"xs",variant:"outline",onClick:oc,children:t("filesView.excalidraw.installAction")})]}):null,s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(Pr,{ref:Jl,outerClassName:"h-full min-w-0",className:J("h-full min-w-0",St&&"[overflow-anchor:none]"),children:d?Ve||Cr?A?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(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.loading")]}):ot?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:ot}):jr?ka?s.jsx("div",{className:"h-full"}):Ra:Rs||(d&&In&&Q==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(_d,{ref:oi,xml:$l,onChange:_l},`${d.path}:${zo}`)}):d&&dn&&de==="tree"?s.jsx(Ps,{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:t("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Du,{jsonString:G,maxHeight:"100%",initiallyExpandedDepth:2})})}):d&&it&&Ke()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:us,ref:sc,children:[s.jsx(Ua,{containerRef:Ei,filePath:d.path,fileContent:G}),G.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:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(G.length/1024)})}),s.jsx(Ps,{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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:ta,children:s.jsx(Dr,{content:G,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),!te&&s.jsx(Ga,{containerRef:cs,open:vi,onOpenChange:ls,focusNonce:xi})]}):d&&$t&&_==="preview"?!m.isVSCode&&Ut.status==="loading"?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:t("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:Ut.status==="ready"?Ut.url:void 0,srcDoc:m.isVSCode?(()=>{const n=d.path.substring(0,d.path.lastIndexOf("/")+1);return n?G.replace(/<head([^>]*)>/i,`<head$1><base href="${n}">`):G})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-downloads",title:t("filesView.editor.htmlPreviewTitle")})}):d&&Ss&&re==="view"?Sa(d,oe,fa,Xl):s.jsxs("div",{className:J("relative h-full",un&&"overflow-hidden"),ref:Dn,children:[!te&&s.jsx(qa,{open:gi,onOpenChange:os,view:Le.current}),s.jsx("div",{className:J("h-full",un&&"invisible"),children:s.jsx(uo,{positionKey:Rt,value:oe,onChange:Fe,readOnly:!rt,vimMode:ms==="vim",extensions:aa,className:"h-full",blockWidgets:Gl,onViewReady:n=>{Le.current=n,Fs(n),sr(o=>o+1),window.requestAnimationFrame(()=>{pn(n)})},onViewDestroy:()=>{Le.current&&(Le.current=null),sr(n=>n+1)},enableSearch:!0,searchOpen:Re,onSearchOpenChange:Xe,highlightLines:ne?{start:Math.min(ne.start,ne.end),end:Math.max(ne.start,ne.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(n,o,c)=>{if(!(c instanceof MouseEvent)||c.button!==0)return!1;c.preventDefault();const g=n.state.doc.lineAt(o.from).number;if(ne&&!c.shiftKey&&Math.min(ne.start,ne.end)===g&&Math.max(ne.start,ne.end)===g)return lt(null),An(),on.current=!1,Pt.current=null,ln(!1),!0;if(u&&ne&&!c.shiftKey){const w=Math.min(ne.start,ne.end,g),N=Math.max(ne.start,ne.end,g);return lt({start:w,end:N}),on.current=!1,Pt.current=null,ln(!1),!0}if(on.current=!0,Pt.current=g,ln(!0),ne&&c.shiftKey){const w=Math.min(ne.start,g),N=Math.max(ne.end,g);lt({start:w,end:N})}else lt({start:g,end:g});return!0},mouseover:(n,o,c)=>{if(!(c instanceof MouseEvent)||c.buttons!==1||!on.current||Pt.current===null)return!1;const g=n.state.doc.lineAt(o.from).number,w=Math.min(Pt.current,g),N=Math.max(Pt.current,g);return lt({start:w,end:N}),ln(!0),!1},mouseup:()=>(on.current=!1,Pt.current=null,ln(!1),!1)}}},Rt)}),un&&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(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]})):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("filesView.editor.pickFileFromTree")})})})]}),lc=!!(l&&ri[l]),Ta=l?ns[l]:null,Ma=M?s.jsxs("section",{className:J("flex min-h-0 flex-col overflow-hidden",u?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:J("flex flex-col gap-2 py-2",u?"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(P,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Kn,{ref:ie,value:B,onChange:n=>K(n.target.value),placeholder:t("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),B.trim().length>0&&s.jsx("button",{type:"button","aria-label":t("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:()=>{K(""),ie.current?.focus()},children:s.jsx(P,{name:"close",className:"size-4"})})]}),s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>or("createFile",{path:j,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFileTitle"),"aria-label":t("filesView.tree.actions.newFileTitle"),children:s.jsx(P,{name:"file-add",className:"size-4"})})})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFileTitle")})]}),s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>or("createFolder",{path:j,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFolderTitle"),"aria-label":t("filesView.tree.actions.newFolderTitle"),children:s.jsx(P,{name:"folder-add",className:"size-4"})})})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFolderTitle")})]}),zi&&s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Ii(l),disabled:!l||vs,className:"size-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":t("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(P,{name:vs?"loader-4":"upload-2",className:J("size-4",vs&&"animate-spin")})})})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsx(Mu,{className:"size-8"}),s.jsxs(qt,{children:[s.jsx(Gt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{gs()},className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.refreshTitle"),"aria-label":t("filesView.tree.actions.refreshTitle"),children:s.jsx(P,{name:"refresh",className:"size-4"})})})}),s.jsx(Xt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(Pr,{outerClassName:"flex-1 min-h-0",className:J("py-2",u?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:$o?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.tree.search.searching")]}):ii.length>0?ii.map(n=>{const o=d?.path===n.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{_e(n)},className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Lo(n.path,n.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:n.path,children:n.relativePath??n.path})]})},n.path)}):Ta?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:Ta}),s.jsxs(U,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{gs()},children:[s.jsx(P,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):lc?qi(l,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("filesView.state.loading")})})})]}):null,cc=r==="full"&&te&&d&&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:Na({exitFullscreenOnly:!0})}),s.jsx(Pr,{ref:Zl,outerClassName:"h-full min-w-0",className:J("h-full min-w-0",St&&"[overflow-anchor:none]"),children:Ve||Cr?A?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(P,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):ot?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:ot}):jr?Ra:Rs||(it&&Ke()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:us,ref:rc,children:[d?s.jsx(Ua,{containerRef:ds,filePath:d.path,fileContent:G}):null,G.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:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(G.length/1024)})}),s.jsx(Ps,{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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:ta,children:s.jsx(Dr,{content:G,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),s.jsx(Ga,{containerRef:ds,open:vi,onOpenChange:ls,focusNonce:xi,className:"right-4 top-16"})]}):Ss&&re==="view"?Sa(d,oe,ma,Yl):s.jsxs("div",{className:J("relative h-full",un&&"overflow-hidden"),children:[s.jsx(qa,{open:gi,onOpenChange:os,view:Le.current}),s.jsx("div",{className:J("h-full",un&&"invisible"),children:s.jsx(uo,{positionKey:`${Rt}:fullscreen`,value:oe,onChange:Fe,readOnly:!rt,vimMode:ms==="vim",extensions:aa,className:"h-full",onViewReady:n=>{Le.current=n,Fs(n),window.requestAnimationFrame(()=>{pn(n)})},onViewDestroy:()=>{Le.current&&(Le.current=null)}},`${Rt}:fullscreen`)}),un&&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(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]}))})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Xf,{activeDialog:Bt,dialogData:_t,dialogInputValue:Mt,onDialogInputChange:mi,isDialogSubmitting:tl,onDialogSubmit:wl,onClose:ql,inputRef:qo}),xl,cc,u?me?Fr:Ma:r==="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:Fr})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[S>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Ma}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Fr})]})]})};function Zf(r){return r+1}export{bp as FilesView};
|